import { defineComponent, ref, createVNode } from 'vue';
import '../../../utils/index.mjs';
import '../../../vue-components/index.mjs';
import Child from './DrawerChild.mjs';
import { drawerWrapperProps } from './props.mjs';
import { initDefaultProps } from '../../../utils/vue/initDefaultProps.mjs';
import PortalWrapper from '../../../vue-components/portal/src/PortalWrapper.mjs';

var DrawerWrapper = /* @__PURE__ */ defineComponent({
  compatConfig: {
    MODE: 3
  },
  inheritAttrs: false,
  name: "DrawerWrapper",
  props: initDefaultProps(drawerWrapperProps(), {
    prefixCls: "drawer",
    placement: "left",
    getContainer: "body",
    level: "all",
    duration: ".3s",
    ease: "cubic-bezier(0.78, 0.14, 0.15, 0.86)",
    afterVisibleChange: () => {
    },
    showMask: true,
    maskClosable: true,
    maskStyle: {},
    wrapperClassName: "",
    keyboard: true,
    forceRender: false,
    autofocus: true
  }),
  emits: ["handleClick", "close"],
  setup(props, {
    emit,
    slots
  }) {
    const dom = ref(null);
    const onHandleClick = (e) => {
      emit("handleClick", e);
    };
    const onClose = (e) => {
      emit("close", e);
    };
    return () => {
      const {
        getContainer,
        wrapperClassName,
        rootClassName,
        rootStyle,
        forceRender,
        ...otherProps
      } = props;
      let portal = null;
      if (!getContainer) {
        return createVNode(Child, {
          ...otherProps,
          "rootClassName": rootClassName,
          "rootStyle": rootStyle,
          "open": props.open,
          "onClose": onClose,
          "onHandleClick": onHandleClick,
          "inline": true
        }, slots);
      }
      const $forceRender = !!slots.handler || forceRender;
      if ($forceRender || props.open || dom.value) {
        portal = createVNode(PortalWrapper, {
          "autoLock": true,
          "visible": props.open,
          "forceRender": $forceRender,
          "getContainer": getContainer,
          "wrapperClassName": wrapperClassName
        }, {
          default: ({
            visible,
            afterClose,
            ...rest
          }) => createVNode(Child, {
            "ref": dom,
            ...otherProps,
            ...rest,
            "rootClassName": rootClassName,
            "rootStyle": rootStyle,
            "open": visible !== void 0 ? visible : props.open,
            "afterVisibleChange": afterClose !== void 0 ? afterClose : props.afterVisibleChange,
            "onClose": onClose,
            "onHandleClick": onHandleClick
          }, slots)
        });
      }
      return portal;
    };
  }
});

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