"use strict";
const common_vendor = require("../../../../common/vendor.js");
require("../../../adapter-vue.js");
const TUIKit_utils_env = require("../../../utils/env.js");
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "index",
  props: {
    isFetching: { type: Boolean, default: false },
    isTerminateObserve: { type: Boolean, default: false }
  },
  emits: ["onExposed"],
  setup(__props, { emit: __emit }) {
    var _a;
    const emits = __emit;
    const props = __props;
    let observer = null;
    const selfDomRef = common_vendor.ref();
    const thisInstance = ((_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.proxy) || common_vendor.getCurrentInstance();
    common_vendor.onMounted(() => {
      if (props.isTerminateObserve) {
        return;
      }
      if (!TUIKit_utils_env.isUniFrameWork) {
        observer = new IntersectionObserver(([entry]) => {
          if (entry.isIntersecting) {
            emits("onExposed");
          }
        }, {
          threshold: 1
        });
        if (selfDomRef.value) {
          observer.observe(selfDomRef.value);
        }
      } else {
        observer = common_vendor.index.createIntersectionObserver(thisInstance).relativeToViewport();
        observer.observe(".fetch-more-block", () => {
          emits("onExposed");
        });
      }
    });
    common_vendor.onUnmounted(() => {
      if (observer) {
        observer.disconnect();
        observer = null;
      }
    });
    common_vendor.watch(() => props.isTerminateObserve, (isTerminateObserve) => {
      if (!observer) {
        return;
      }
      if (isTerminateObserve) {
        observer.disconnect();
      } else if (selfDomRef.value) {
        observer.disconnect();
        if (!TUIKit_utils_env.isUniFrameWork) {
          observer.observe(selfDomRef.value);
        } else {
          observer.observe(".fetch-more-block", () => {
            emits("onExposed");
          });
        }
      }
    });
    return (_ctx, _cache) => {
      return common_vendor.e({
        a: props.isFetching
      }, props.isFetching ? {
        b: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUIChat.正在加载"))
      } : {
        c: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUIChat.加载结束"))
      });
    };
  }
});
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-ab2918f1"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/common/FetchMore/index.js.map
