"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const comp = require("../ui/src/comp.js");
const index_esm = require("../../../@vxe-ui/core/es/index.esm.js");
let dynamicContainerElem;
const dynamicStore = vue.reactive({
  modals: [],
  drawers: [],
  globalLoading: null,
  globalWatermark: null,
  globalContextMenu: null
});
const VxeDynamics = comp.defineVxeComponent({
  setup() {
    const VxeUIModalComponent = index_esm.VxeUI.getComponent("vxe-modal");
    const VxeUIDrawerComponent = index_esm.VxeUI.getComponent("vxe-drawer");
    const VxeUILoadingComponent = index_esm.VxeUI.getComponent("vxe-loading");
    const VxeUIWatermarkComponent = index_esm.VxeUI.getComponent("vxe-watermark");
    const VxeUIContextMenuComponent = index_esm.VxeUI.getComponent("vxe-context-menu");
    return () => {
      const { modals, drawers, globalWatermark, globalLoading, globalContextMenu } = dynamicStore;
      let cmOpts = globalContextMenu;
      if (globalContextMenu) {
        const events = globalContextMenu.events || {};
        const { optionClick, show, hide } = events;
        cmOpts = Object.assign({}, globalContextMenu, {
          onShow(params) {
            if (show) {
              show(params);
            }
          },
          onHide(params) {
            if (hide) {
              hide(params);
            }
            dynamicStore.globalContextMenu = null;
          },
          onOptionClick(params) {
            if (optionClick) {
              optionClick(params);
            }
          }
        }, { events: void 0 });
      }
      return [
        modals.length ? vue.h("div", {
          key: 1,
          class: "vxe-dynamics--modal"
        }, modals.map((item) => vue.h(VxeUIModalComponent, item))) : vue.createCommentVNode(),
        drawers.length ? vue.h("div", {
          key: 2,
          class: "vxe-dynamics--drawer"
        }, drawers.map((item) => vue.h(VxeUIDrawerComponent, item))) : vue.createCommentVNode(),
        globalWatermark ? vue.h(VxeUIWatermarkComponent, globalWatermark) : vue.createCommentVNode(),
        globalLoading ? vue.h(VxeUILoadingComponent, globalLoading) : vue.createCommentVNode(),
        globalContextMenu ? vue.h(VxeUIContextMenuComponent, cmOpts) : vue.createCommentVNode()
      ];
    };
  }
});
const dynamicApp = vue.createApp(VxeDynamics);
function checkDynamic() {
  if (!dynamicContainerElem) {
    dynamicContainerElem = document.createElement("div");
    dynamicContainerElem.className = "vxe-dynamics";
    document.body.appendChild(dynamicContainerElem);
    dynamicApp.mount(dynamicContainerElem);
  }
}
exports.checkDynamic = checkDynamic;
exports.dynamicApp = dynamicApp;
exports.dynamicStore = dynamicStore;
