"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index_esm = require("../../../@vxe-ui/core/es/index.esm.js");
const contextMenu = require("./src/context-menu.js");
const index = require("../dynamics/index.js");
const VxeContextMenu = Object.assign({}, contextMenu.default, {
  install(app) {
    app.component(contextMenu.default.name, contextMenu.default);
  }
});
function openMenu(opts, x, y) {
  index.dynamicStore.globalContextMenu = {
    modelValue: true,
    options: opts.options,
    className: opts.className,
    size: opts.size,
    zIndex: opts.zIndex,
    x,
    y,
    position: "fixed",
    destroyOnClose: true,
    transfer: false,
    events: opts.events
  };
  index.checkDynamic();
}
const ContextMenuController = {
  open(options) {
    const opts = Object.assign({ x: 0, y: 0 }, options);
    openMenu(opts, opts.x, opts.y);
  },
  openByEvent(evnt, options) {
    evnt.preventDefault();
    evnt.stopPropagation();
    const opts = Object.assign({}, options);
    const x = evnt.clientX + 1;
    const y = evnt.clientY + 1;
    openMenu(opts, x, y);
  },
  close() {
    index.dynamicStore.globalContextMenu = null;
  }
};
index.dynamicApp.use(VxeContextMenu);
index_esm.VxeUI.component(contextMenu.default);
index_esm.VxeUI.contextMenu = ContextMenuController;
const ContextMenu = VxeContextMenu;
exports.ContextMenu = ContextMenu;
exports.ContextMenuController = ContextMenuController;
exports.VxeContextMenu = VxeContextMenu;
exports.default = VxeContextMenu;
