"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var design_color_picker_exports = {};
__export(design_color_picker_exports, {
  DesignColorPicker: () => DesignColorPicker
});
module.exports = __toCommonJS(design_color_picker_exports);
var import_react = __toESM(require("react"));
var import_ricos_context = require("./../../../ricos-context/index.js");
var import_bi_context_provider = require("./../../../_shared/bi-context-provider/bi-context-provider.js");
var import_color_manager_utils = require("./../../../_shared/color-manager-utils.js");
var import_new_color_picker = require("./../../../ui-components/color-picker/new-color-picker/index.js");
var import_defaults = require("../defaults.js");
const DesignColorPicker = ({
  config,
  modalId,
  currentColor,
  referenceElement,
  onColorSelected,
  onColorPreview,
  onColorPreviewStart,
  onColorPreviewEnd
}) => {
  const modalService = (0, import_react.useContext)(import_ricos_context.ModalServiceContext);
  const { colorManager, t, theme } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const themeColors = (0, import_react.useMemo)(
    () => (0, import_color_manager_utils.resolveThemeColorsPalette)(
      theme,
      config.colorScheme ? Object.values(config.colorScheme).map((c) => c.color) : []
    ),
    [config.colorScheme, theme]
  );
  const customColors = (0, import_color_manager_utils.useResolvedCustomColors)(colorManager, config.getUserColors);
  const logBi = (0, import_bi_context_provider.useBiNext)({
    modalId,
    pluginId: "textHighlight"
  });
  const onColorAdded = (color) => {
    (0, import_color_manager_utils.handleColorAdded)(color, colorManager, config.onColorAdded);
    onColorSelected(color);
  };
  const onColorDeletedHandler = (color) => {
    (0, import_color_manager_utils.handleColorDeleted)(color, colorManager);
  };
  const closeModal = () => modalService.closeModal(modalId);
  return /* @__PURE__ */ import_react.default.createElement(
    import_new_color_picker.NewColorPicker,
    {
      themeColors,
      customColors,
      currentColor: currentColor ?? import_defaults.DEFAULT_COLOR,
      title: t("Color_Picker_TextHighlightButton_Header"),
      closeModal,
      onColorSelected,
      onColorPreview,
      onColorAdded,
      onColorDeleted: colorManager || !config.getUserColors ? onColorDeletedHandler : void 0,
      onColorPreviewStart,
      onColorPreviewEnd,
      onResetColor: () => onColorSelected(void 0),
      referenceElement,
      logBi
    }
  );
};
//# sourceMappingURL=design-color-picker.js.map
