"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Vue = require("vue");
const index_esm = require("../../../@vant/use/dist/index.esm.js");
const basic = require("../utils/basic.js");
function useVisibilityChange(target, onChange) {
  if (!basic.inBrowser || !window.IntersectionObserver) {
    return;
  }
  const observer = new IntersectionObserver(
    (entries) => {
      onChange(entries[0].intersectionRatio > 0);
    },
    { root: document.body }
  );
  const observe = () => {
    if (target.value) {
      observer.observe(target.value);
    }
  };
  const unobserve = () => {
    if (target.value) {
      observer.unobserve(target.value);
    }
  };
  Vue.onDeactivated(unobserve);
  Vue.onBeforeUnmount(unobserve);
  index_esm.onMountedOrActivated(observe);
}
exports.useVisibilityChange = useVisibilityChange;
