"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, {
  pluginImage: () => pluginImage
});
module.exports = __toCommonJS(editor_exports);
var import_wix_ui_icons_common = require("@wix/wix-ui-icons-common");
var import_plugin_figure = require("./../plugin-figure/index.js");
var import_ricos_content = require("./../ricos-content/index.js");
var import_ricos_types = require("./../ricos-types/index.js");
var import_consts = require("./consts.js");
var import_context = require("./context.js");
var import_image_converter = require("./converter/image-converter.js");
var import_get_add_buttons = require("./get-add-buttons.js");
var import_get_toolbar_buttons = require("./get-toolbar-buttons.js");
var import_handle_image_upload = require("./handle-image-upload.js");
var import_image_tiptap_extension = require("./tiptap/image-tiptap-extension.js");
const pluginImage = (config) => {
  const pluginConfig = {
    type: "image",
    ...import_consts.DEFAULTS.config,
    ...config
  };
  return {
    config: pluginConfig,
    type: import_ricos_content.IMAGE_TYPE,
    pmMarkConverters: [],
    pmNodeConverters: [import_image_converter.imageConverter],
    tiptapExtensions: [import_image_tiptap_extension.imageTiptapExtension],
    toolbar: {
      names: [import_ricos_types.RicosPluginToolbarNames.IMAGE],
      getButtons: (config2, services) => (0, import_get_toolbar_buttons.getToolbarButtons)(config2, services),
      isVisible: (selection) => {
        if (!("node" in selection) || !selection.node) {
          return false;
        }
        if (selection.node.type.name === import_ricos_content.TIPTAP_IMAGE_TYPE) {
          return true;
        }
        return selection.node.type.name === import_ricos_content.TIPTAP_FIGURE_TYPE && selection.node.firstChild?.type.name === import_ricos_content.TIPTAP_IMAGE_TYPE;
      }
    },
    getAddButtons: (config2, services) => (0, import_get_add_buttons.getAddButtons)(config2, services),
    getQuickActions: ({ pluginServices, config: config2 }) => [
      {
        id: import_ricos_types.Node_Type.IMAGE,
        title: "QuickActionsPlugin_ActionTitle_Image",
        icon: pluginServices?.context.isMobile ? import_wix_ui_icons_common.Image : import_wix_ui_icons_common.ImageSmall,
        section: import_ricos_types.quickActionsModalSections.Media,
        tags: ["photo", "picture", "graphic", "visual", "illustration"],
        command: ({ publicCommands }) => {
          (0, import_handle_image_upload.handleImageUpload)({ services: pluginServices, config: config2, publicCommands });
        }
      }
    ],
    dependencies: [import_plugin_figure.pluginFigure],
    Provider: import_context.ImagePluginContextProvider
  };
};
//# sourceMappingURL=editor.js.map
