'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var _interface = require('./interface.cjs');
var Mask = require('./Mask.cjs');
var MobilePopupInner = require('./MobilePopupInner.cjs');
var PopupInner = require('./PopupInner.cjs');

var Popup = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  name: "Popup",
  inheritAttrs: false,
  props: _interface.popupProps,
  setup(props, {
    attrs,
    slots,
    expose
  }) {
    const innerVisible = vue.shallowRef(false);
    const inMobile = vue.shallowRef(false);
    const popupRef = vue.shallowRef();
    const rootRef = vue.shallowRef();
    vue.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 ? vue.createVNode(MobilePopupInner.default, {
        ...cloneProps,
        "mobile": props.mobile,
        "ref": popupRef
      }, {
        default: slots.default
      }) : vue.createVNode(PopupInner.default, {
        ...cloneProps,
        "ref": popupRef
      }, {
        default: slots.default
      });
      return vue.createVNode("div", {
        "ref": rootRef
      }, [vue.createVNode(Mask.default, cloneProps, null), popupNode]);
    };
  }
});

exports.default = Popup;
//# sourceMappingURL=index.cjs.map
