import { useRect } from "../../../@vant/use/dist/index.esm.mjs";
import { ref, onMounted, nextTick, watch } from "vue";
import { onPopupReopen } from "./on-popup-reopen.mjs";
import { windowWidth, windowHeight } from "../utils/dom.mjs";
const useHeight = (element, withSafeArea) => {
  const height = ref();
  const setHeight = () => {
    height.value = useRect(element).height;
  };
  onMounted(() => {
    nextTick(setHeight);
    if (withSafeArea) {
      for (let i = 1; i <= 3; i++) {
        setTimeout(setHeight, 100 * i);
      }
    }
  });
  onPopupReopen(() => nextTick(setHeight));
  watch([windowWidth, windowHeight], setHeight);
  return height;
};
export {
  useHeight
};
