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

// packages/block-editor/src/hooks/use-color-props.js
var use_color_props_exports = {};
__export(use_color_props_exports, {
  getColorClassesAndStyles: () => getColorClassesAndStyles,
  useColorProps: () => useColorProps
});
module.exports = __toCommonJS(use_color_props_exports);
var import_clsx = __toESM(require("clsx"));
var import_element = require("@wordpress/element");
var import_style = require("./style");
var import_colors = require("../components/colors");
var import_gradients = require("../components/gradients");
var import_use_settings = require("../components/use-settings");
function getColorClassesAndStyles(attributes) {
  const { backgroundColor, textColor, gradient, style } = attributes;
  const backgroundClass = (0, import_colors.getColorClassName)(
    "background-color",
    backgroundColor
  );
  const textClass = (0, import_colors.getColorClassName)("color", textColor);
  const gradientClass = (0, import_gradients.__experimentalGetGradientClass)(gradient);
  const hasGradient = gradientClass || style?.color?.gradient;
  const className = (0, import_clsx.default)(textClass, gradientClass, {
    // Don't apply the background class if there's a gradient.
    [backgroundClass]: !hasGradient && !!backgroundClass,
    "has-text-color": textColor || style?.color?.text,
    "has-background": backgroundColor || style?.color?.background || gradient || style?.color?.gradient,
    "has-link-color": style?.elements?.link?.color
  });
  const colorStyles = style?.color || {};
  const styleProp = (0, import_style.getInlineStyles)({ color: colorStyles });
  return {
    className: className || void 0,
    style: styleProp
  };
}
function useColorProps(attributes) {
  const { backgroundColor, textColor, gradient } = attributes;
  const [
    userPalette,
    themePalette,
    defaultPalette,
    userGradients,
    themeGradients,
    defaultGradients
  ] = (0, import_use_settings.useSettings)(
    "color.palette.custom",
    "color.palette.theme",
    "color.palette.default",
    "color.gradients.custom",
    "color.gradients.theme",
    "color.gradients.default"
  );
  const colors = (0, import_element.useMemo)(
    () => [
      ...userPalette || [],
      ...themePalette || [],
      ...defaultPalette || []
    ],
    [userPalette, themePalette, defaultPalette]
  );
  const gradients = (0, import_element.useMemo)(
    () => [
      ...userGradients || [],
      ...themeGradients || [],
      ...defaultGradients || []
    ],
    [userGradients, themeGradients, defaultGradients]
  );
  const colorProps = getColorClassesAndStyles(attributes);
  if (backgroundColor) {
    const backgroundColorObject = (0, import_colors.getColorObjectByAttributeValues)(
      colors,
      backgroundColor
    );
    colorProps.style.backgroundColor = backgroundColorObject.color;
  }
  if (gradient) {
    colorProps.style.background = (0, import_gradients.getGradientValueBySlug)(
      gradients,
      gradient
    );
  }
  if (textColor) {
    const textColorObject = (0, import_colors.getColorObjectByAttributeValues)(
      colors,
      textColor
    );
    colorProps.style.color = textColorObject.color;
  }
  return colorProps;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  getColorClassesAndStyles,
  useColorProps
});
//# sourceMappingURL=use-color-props.js.map
