import { defineComponent, ref, computed, resolveComponent, resolveDirective, openBlock, createBlock, Teleport, withDirectives, createVNode, withCtx, createElementBlock, normalizeClass, normalizeStyle, renderSlot, createElementVNode, toDisplayString, createCommentVNode, vShow } from 'vue';
import { Close } from '@element-plus/icons-vue';
import { PsOverlay } from '../../overlay/index.mjs';
import '../../dialog/index.mjs';
import { PsIcon } from '../../icon/index.mjs';
import '../../../directives/index.mjs';
import '../../../hooks/index.mjs';
import { drawerProps } from './drawer2.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import TrapFocus from '../../../directives/trap-focus/index.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { useDialog } from '../../dialog/src/use-dialog.mjs';

const _sfc_main = defineComponent({
  name: "PsDrawer",
  components: {
    PsOverlay,
    PsIcon,
    Close
  },
  directives: {
    TrapFocus
  },
  props: drawerProps,
  setup(props, ctx) {
    const drawerRef = ref();
    const ns = useNamespace("drawer");
    const isHorizontal = computed(() => props.direction === "rtl" || props.direction === "ltr");
    const drawerSize = computed(() => typeof props.size === "number" ? `${props.size}px` : props.size);
    return {
      ...useDialog(props, ctx, drawerRef),
      drawerRef,
      isHorizontal,
      drawerSize,
      ns
    };
  }
});
const _hoisted_1 = ["aria-labelledby", "aria-label", "widget"];
const _hoisted_2 = ["id", "widget"];
const _hoisted_3 = ["title"];
const _hoisted_4 = ["aria-label"];
const _hoisted_5 = ["widget"];
const _hoisted_6 = ["widget"];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  const _component_close = resolveComponent("close");
  const _component_ps_icon = resolveComponent("ps-icon");
  const _component_ps_overlay = resolveComponent("ps-overlay");
  const _directive_trap_focus = resolveDirective("trap-focus");
  return openBlock(), createBlock(Teleport, {
    to: "body",
    disabled: !_ctx.appendToBody
  }, [
    withDirectives(createVNode(_component_ps_overlay, {
      mask: _ctx.modal,
      "overlay-class": (_ctx.modalClass || "") + (_ctx.widget ? ` ps--drawer-widget-class` : ""),
      "z-index": _ctx.zIndex
    }, {
      default: withCtx(() => [
        withDirectives((openBlock(), createElementBlock("div", {
          ref: "drawerRef",
          "aria-modal": "true",
          "aria-labelledby": _ctx.ns.e("title"),
          "aria-label": _ctx.title,
          class: normalizeClass([_ctx.ns.b(), _ctx.direction, _ctx.visible && "open", _ctx.customClass]),
          style: normalizeStyle(_ctx.isHorizontal ? "width: " + _ctx.drawerSize : "height: " + _ctx.drawerSize),
          role: "dialog",
          widget: _ctx.widget
        }, [
          _ctx.withHeader ? (openBlock(), createElementBlock("header", {
            key: 0,
            id: _ctx.ns.e("title"),
            class: normalizeClass(_ctx.ns.e("header")),
            widget: _ctx.widget ? "drawer:title:" + _ctx.widget.split(":")[1] : void 0
          }, [
            renderSlot(_ctx.$slots, "title", {}, () => [
              createElementVNode("span", {
                role: "heading",
                title: _ctx.title
              }, toDisplayString(_ctx.title), 9, _hoisted_3)
            ]),
            _ctx.showClose ? (openBlock(), createElementBlock("button", {
              key: 0,
              "aria-label": "close " + (_ctx.title || "drawer"),
              class: normalizeClass(_ctx.ns.e("close-btn")),
              type: "button"
            }, [
              createVNode(_component_ps_icon, {
                class: normalizeClass(_ctx.ns.e("close"))
              }, {
                default: withCtx(() => [
                  createVNode(_component_close)
                ]),
                _: 1
              }, 8, ["class"])
            ], 10, _hoisted_4)) : createCommentVNode("v-if", true)
          ], 10, _hoisted_2)) : createCommentVNode("v-if", true),
          _ctx.rendered ? (openBlock(), createElementBlock("section", {
            key: 1,
            class: normalizeClass(_ctx.ns.e("body")),
            widget: _ctx.widget ? "drawer:default:" + _ctx.widget.split(":")[1] : void 0
          }, [
            renderSlot(_ctx.$slots, "default")
          ], 10, _hoisted_5)) : createCommentVNode("v-if", true),
          _ctx.$slots.footer ? (openBlock(), createElementBlock("div", {
            key: 2,
            class: normalizeClass(_ctx.ns.e("footer")),
            widget: _ctx.widget ? "drawer:footer:" + _ctx.widget.split(":")[1] : void 0
          }, [
            renderSlot(_ctx.$slots, "footer")
          ], 10, _hoisted_6)) : createCommentVNode("v-if", true)
        ], 14, _hoisted_1)), [
          [_directive_trap_focus]
        ])
      ]),
      _: 3
    }, 8, ["mask", "overlay-class", "z-index"]), [
      [vShow, _ctx.visible]
    ])
  ], 8, ["disabled"]);
}
var Drawer = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/meng/workspace/element-ps/packages/components/drawer/src/drawer.vue"]]);

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