'use strict';

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

var vue = require('vue');
require('../../../utils/index.cjs');
var PortalWrapper = require('../../portal/src/PortalWrapper.cjs');
var DrawerChild = require('./DrawerChild.cjs');
var IDrawerPropTypes = require('./IDrawerPropTypes.cjs');
var initDefaultProps = require('../../../utils/vue/initDefaultProps.cjs');

const DrawerWrapper = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  inheritAttrs: false,
  props: initDefaultProps.initDefaultProps(IDrawerPropTypes.drawerProps(), {
    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 = vue.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 vue.createVNode(DrawerChild.default, {
          ...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 = vue.createVNode(PortalWrapper.default, {
          "autoLock": true,
          "visible": props.open,
          "forceRender": $forceRender,
          "getContainer": getContainer,
          "wrapperClassName": wrapperClassName
        }, {
          default: ({
            visible,
            afterClose,
            ...rest
          }) => vue.createVNode(DrawerChild.default, {
            "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;
    };
  }
});

exports.default = DrawerWrapper;
//# sourceMappingURL=DrawerWrapper.cjs.map
