"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, {
  pluginLinkPreview: () => pluginLinkPreview
});
module.exports = __toCommonJS(editor_exports);
var import_wix_ui_icons_common = require("@wix/wix-ui-icons-common");
var import_ricos_types = require("./../ricos-types/index.js");
var import_tiptap = require("./../tiptap/index.js");
var import_consts = require("./consts.js");
var import_defaults = require("./defaults.js");
var import_embed_converter = require("./embed-converter.js");
var import_get_add_buttons = require("./get-add-buttons.js");
var import_get_toolbar_buttons = require("./get-toolbar-buttons.js");
var import_link_preview_converter = require("./link-preview-converter.js");
var import_insert_modal = require("./modals/insert-modal.js");
var import_tiptap2 = require("./tiptap/tiptap.js");
var import_types = require("./types.js");
const pluginLinkPreview = (config) => {
  const pluginConfig = {
    type: "linkPreview",
    ...import_defaults.DEFAULTS.config,
    ...config
  };
  return {
    config: pluginConfig,
    type: import_types.LINK_PREVIEW_TYPE,
    pmMarkConverters: [],
    pmNodeConverters: [import_link_preview_converter.linkPreviewConverter, import_embed_converter.embedConverter],
    tiptapExtensions: import_tiptap2.tiptapExtensions,
    getAddButtons: (config2, services) => (0, import_get_add_buttons.getAddButtons)(config2, services),
    toolbar: {
      names: [import_ricos_types.RicosPluginToolbarNames.LINK_PREVIEW, import_ricos_types.RicosPluginToolbarNames.EMBED],
      getButtons: (config2, services) => (0, import_get_toolbar_buttons.getToolbarButtons)(config2, services)
    },
    getQuickActions: ({ config: config2, pluginServices }) => {
      const { fetchData } = config2 || {};
      const isMobile = pluginServices.context.isMobile;
      const toggleInsertModal = ({
        id,
        socialType,
        modalService,
        editor
      }) => {
        modalService.togglePluginPanel({
          id,
          Component: import_insert_modal.InsertModal,
          componentProps: {
            fetchData,
            socialType
          },
          isMobile,
          positioning: {
            referenceElement: {
              getBoundingClientRect: () => (0, import_tiptap.posToDOMRect)(
                editor.view,
                editor.view.state.selection.from,
                editor.view.state.selection.to
              )
            },
            placement: isMobile ? "bottom" : "bottom-start"
          },
          mobileLayout: "drawer"
        });
      };
      return [
        {
          id: `${import_ricos_types.Node_Type.LINK_PREVIEW}.instagram`,
          title: "QuickActionsPlugin_ActionTitle_InstagramPost",
          icon: isMobile ? import_wix_ui_icons_common.Instagram : import_wix_ui_icons_common.InstagramSmall,
          section: import_ricos_types.quickActionsModalSections.Embed,
          tags: ["post", "photo", "video", "social media", "story", "ig post", "instagram"],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: import_consts.socialModals.instagram,
              socialType: "Instagram",
              modalService,
              editor
            });
          }
        },
        {
          id: `${import_ricos_types.Node_Type.LINK_PREVIEW}.tiktok`,
          title: "QuickActionsPlugin_ActionTitle_TikTokVideo",
          icon: isMobile ? import_wix_ui_icons_common.TikTok : import_wix_ui_icons_common.TikTokSmall,
          section: import_ricos_types.quickActionsModalSections.Embed,
          tags: ["video", "social media", "content", "short video", "clip", "tiktok"],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: import_consts.socialModals.tiktok,
              socialType: "TikTok",
              modalService,
              editor
            });
          }
        },
        {
          id: `${import_ricos_types.Node_Type.LINK_PREVIEW}.twitter`,
          title: "QuickActionsPlugin_ActionTitle_XPost",
          icon: isMobile ? import_wix_ui_icons_common.XCorp : import_wix_ui_icons_common.XCorpSmall,
          section: import_ricos_types.quickActionsModalSections.Embed,
          tags: [
            "social media",
            "tweet",
            "update",
            "content",
            "post",
            "link",
            "article",
            "blog",
            "twitter",
            "x"
          ],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: import_consts.socialModals.twitter,
              socialType: "Twitter",
              modalService,
              editor
            });
          }
        }
      ];
    }
  };
};
//# sourceMappingURL=editor.js.map
