import { defineComponent, shallowRef, watch, createVNode } from 'vue';
import { popupProps } from './interface.mjs';
import Mask from './Mask.mjs';
import MobilePopupInner from './MobilePopupInner.mjs';
import PopupInner from './PopupInner.mjs';

var Popup = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Popup",
  inheritAttrs: false,
  props: popupProps,
  setup(props, {
    attrs,
    slots,
    expose
  }) {
    const innerVisible = shallowRef(false);
    const inMobile = shallowRef(false);
    const popupRef = shallowRef();
    const rootRef = shallowRef();
    watch([() => props.visible, () => props.mobile], () => {
      innerVisible.value = props.visible;
      if (props.visible && props.mobile)
        inMobile.value = true;
    }, {
      immediate: true,
      flush: "post"
    });
    expose({
      forceAlign: () => {
        var _a;
        (_a = popupRef.value) == null ? void 0 : _a.forceAlign();
      },
      getElement: () => {
        var _a;
        return (_a = popupRef.value) == null ? void 0 : _a.getElement();
      }
    });
    return () => {
      const cloneProps = {
        ...props,
        ...attrs,
        visible: innerVisible.value
      };
      const popupNode = inMobile.value ? createVNode(MobilePopupInner, {
        ...cloneProps,
        "mobile": props.mobile,
        "ref": popupRef
      }, {
        default: slots.default
      }) : createVNode(PopupInner, {
        ...cloneProps,
        "ref": popupRef
      }, {
        default: slots.default
      });
      return createVNode("div", {
        "ref": rootRef
      }, [createVNode(Mask, cloneProps, null), popupNode]);
    };
  }
});

export { Popup as default };
//# sourceMappingURL=index.mjs.map
