"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var editor_exports = {};
__export(editor_exports, {
  pluginVerticalEmbed: () => pluginVerticalEmbed
});
module.exports = __toCommonJS(editor_exports);
var import_wix_ui_icons_common = require("@wix/wix-ui-icons-common");
var import_v1 = require("./../ricos-schema/legacy/wix/rich_content/v1/index.js");
var import_ricos_types = require("./../ricos-types/index.js");
var import_tiptap = require("./../tiptap/index.js");
var import_app_embed_converter = require("./app-embed-converter.js");
var import_constants = require("./constants.js");
var import_defaults = require("./defaults.js");
var import_get_add_buttons = require("./get-add-buttons.js");
var import_get_toolbar_buttons = require("./get-toolbar-buttons.js");
var import_insert_modal = require("./modals/insert-modal.js");
var import_tiptap2 = require("./tiptap/tiptap.js");
var import_types = require("./types.js");
const pluginVerticalEmbed = (config) => {
  const pluginConfig = { type: "verticalEmbed", ...import_defaults.DEFAULTS.config, ...config };
  return {
    config: pluginConfig,
    type: import_types.VERTICAL_EMBED_TYPE,
    tiptapExtensions: import_tiptap2.tiptapExtensions,
    pmMarkConverters: [],
    pmNodeConverters: [import_app_embed_converter.appEmbedConverter],
    toolbar: {
      names: [import_ricos_types.RicosPluginToolbarNames.APP_EMBED],
      getButtons: (config2, services) => (0, import_get_toolbar_buttons.getToolbarButtons)(config2, services)
    },
    getAddButtons: (config2, services) => (0, import_get_add_buttons.getAddButtons)(config2, services),
    getQuickActions: ({ pluginServices }) => {
      const isMobile = pluginServices?.context.isMobile;
      const toggleInsertModal = ({
        id,
        type,
        modalService,
        editor
      }) => modalService?.togglePluginPanel({
        id,
        Component: import_insert_modal.InsertModal,
        componentProps: {
          componentData: { type },
          modalId: id
        },
        positioning: {
          referenceElement: {
            getBoundingClientRect: () => (0, import_tiptap.posToDOMRect)(
              editor.view,
              editor.view.state.selection.from,
              editor.view.state.selection.to
            )
          },
          placement: "bottom-start"
        },
        isMobile
      });
      return [
        {
          id: `${import_ricos_types.Node_Type.APP_EMBED}.product`,
          title: "QuickActionsPlugin_ActionTitle_Product",
          icon: isMobile ? import_wix_ui_icons_common.Order : import_wix_ui_icons_common.OrderSmall,
          section: import_ricos_types.quickActionsModalSections.EmbedWix,
          tags: [
            "item",
            "merchandise",
            "product card",
            "shop item",
            "e-commerce",
            "online store",
            "store item"
          ],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: import_constants.verticalEmbedModals.insertProduct,
              type: import_v1.AppEmbedData_AppType.PRODUCT,
              modalService,
              editor
            });
          }
        },
        {
          id: `${import_ricos_types.Node_Type.APP_EMBED}.event`,
          title: "QuickActionsPlugin_ActionTitle_Event",
          icon: isMobile ? import_wix_ui_icons_common.DateChecked : import_wix_ui_icons_common.DateCheckedSmall,
          section: import_ricos_types.quickActionsModalSections.EmbedWix,
          tags: ["calendar", "meeting", "appointment", "schedule", "date", "time"],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: import_constants.verticalEmbedModals.insertEvent,
              type: import_v1.AppEmbedData_AppType.EVENT,
              modalService,
              editor
            });
          }
        },
        {
          id: `${import_ricos_types.Node_Type.APP_EMBED}.service`,
          title: "QuickActionsPlugin_ActionTitle_Service",
          icon: isMobile ? import_wix_ui_icons_common.WixBooking : import_wix_ui_icons_common.WixBookingSmall,
          section: import_ricos_types.quickActionsModalSections.EmbedWix,
          tags: ["reservation", "appointment", "schedule", "time", "calendar", "ticket", "booking"],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: import_constants.verticalEmbedModals.insertBooking,
              type: import_v1.AppEmbedData_AppType.BOOKING,
              modalService,
              editor
            });
          }
        }
      ];
    }
  };
};
//# sourceMappingURL=editor.js.map
