"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);

// packages/block-editor/src/components/colors-gradients/use-multiple-origin-colors-and-gradients.js
var use_multiple_origin_colors_and_gradients_exports = {};
__export(use_multiple_origin_colors_and_gradients_exports, {
  default: () => useMultipleOriginColorsAndGradients
});
module.exports = __toCommonJS(use_multiple_origin_colors_and_gradients_exports);
var import_element = require("@wordpress/element");
var import_i18n = require("@wordpress/i18n");
var import_use_settings = require("../use-settings");
function useMultipleOriginColorsAndGradients() {
  const [
    enableCustomColors,
    customColors,
    themeColors,
    defaultColors,
    shouldDisplayDefaultColors,
    enableCustomGradients,
    customGradients,
    themeGradients,
    defaultGradients,
    shouldDisplayDefaultGradients
  ] = (0, import_use_settings.useSettings)(
    "color.custom",
    "color.palette.custom",
    "color.palette.theme",
    "color.palette.default",
    "color.defaultPalette",
    "color.customGradient",
    "color.gradients.custom",
    "color.gradients.theme",
    "color.gradients.default",
    "color.defaultGradients"
  );
  const colorGradientSettings = {
    disableCustomColors: !enableCustomColors,
    disableCustomGradients: !enableCustomGradients
  };
  colorGradientSettings.colors = (0, import_element.useMemo)(() => {
    const result = [];
    if (themeColors && themeColors.length) {
      result.push({
        name: (0, import_i18n._x)(
          "Theme",
          "Indicates this palette comes from the theme."
        ),
        slug: "theme",
        colors: themeColors
      });
    }
    if (shouldDisplayDefaultColors && defaultColors && defaultColors.length) {
      result.push({
        name: (0, import_i18n._x)(
          "Default",
          "Indicates this palette comes from WordPress."
        ),
        slug: "default",
        colors: defaultColors
      });
    }
    if (customColors && customColors.length) {
      result.push({
        name: (0, import_i18n._x)(
          "Custom",
          "Indicates this palette is created by the user."
        ),
        slug: "custom",
        colors: customColors
      });
    }
    return result;
  }, [
    customColors,
    themeColors,
    defaultColors,
    shouldDisplayDefaultColors
  ]);
  colorGradientSettings.gradients = (0, import_element.useMemo)(() => {
    const result = [];
    if (themeGradients && themeGradients.length) {
      result.push({
        name: (0, import_i18n._x)(
          "Theme",
          "Indicates this palette comes from the theme."
        ),
        slug: "theme",
        gradients: themeGradients
      });
    }
    if (shouldDisplayDefaultGradients && defaultGradients && defaultGradients.length) {
      result.push({
        name: (0, import_i18n._x)(
          "Default",
          "Indicates this palette comes from WordPress."
        ),
        slug: "default",
        gradients: defaultGradients
      });
    }
    if (customGradients && customGradients.length) {
      result.push({
        name: (0, import_i18n._x)(
          "Custom",
          "Indicates this palette is created by the user."
        ),
        slug: "custom",
        gradients: customGradients
      });
    }
    return result;
  }, [
    customGradients,
    themeGradients,
    defaultGradients,
    shouldDisplayDefaultGradients
  ]);
  colorGradientSettings.hasColorsOrGradients = !!colorGradientSettings.colors.length || !!colorGradientSettings.gradients.length;
  return colorGradientSettings;
}
//# sourceMappingURL=use-multiple-origin-colors-and-gradients.js.map
