"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/components/src/duotone-picker/color-list-picker/index.tsx
var color_list_picker_exports = {};
__export(color_list_picker_exports, {
  default: () => color_list_picker_default
});
module.exports = __toCommonJS(color_list_picker_exports);
var import_element = require("@wordpress/element");
var import_icons = require("@wordpress/icons");
var import_i18n = require("@wordpress/i18n");
var import_button = __toESM(require("../../button/index.cjs"), 1);
var import_color_palette = __toESM(require("../../color-palette/index.cjs"), 1);
var import_color_indicator = __toESM(require("../../color-indicator/index.cjs"), 1);
var import_icon = __toESM(require("../../icon/index.cjs"), 1);
var import_compose = require("@wordpress/compose");
var import_jsx_runtime = require("react/jsx-runtime");
function ColorOption({
  label,
  value,
  colors,
  disableCustomColors,
  enableAlpha,
  onChange
}) {
  const [isOpen, setIsOpen] = (0, import_element.useState)(false);
  const idRoot = (0, import_compose.useInstanceId)(ColorOption, "color-list-picker-option");
  const labelId = `${idRoot}__label`;
  const contentId = `${idRoot}__content`;
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
    children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.default, {
      __next40pxDefaultSize: true,
      className: "components-color-list-picker__swatch-button",
      id: labelId,
      onClick: () => setIsOpen((prev) => !prev),
      "aria-expanded": isOpen,
      "aria-controls": contentId,
      icon: value ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_color_indicator.default, {
        colorValue: value,
        className: "components-color-list-picker__swatch-color"
      }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icon.default, {
        icon: import_icons.swatch
      }),
      text: label
    }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
      role: "group",
      id: contentId,
      "aria-labelledby": labelId,
      "aria-hidden": !isOpen,
      children: isOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_color_palette.default, {
        "aria-label": (0, import_i18n.__)("Color options"),
        className: "components-color-list-picker__color-picker",
        colors,
        value,
        clearable: false,
        onChange,
        disableCustomColors,
        enableAlpha
      })
    })]
  });
}
function ColorListPicker({
  colors,
  labels,
  value = [],
  disableCustomColors,
  enableAlpha,
  onChange
}) {
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
    className: "components-color-list-picker",
    children: labels.map((label, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ColorOption, {
      label,
      value: value[index],
      colors,
      disableCustomColors,
      enableAlpha,
      onChange: (newColor) => {
        const newColors = value.slice();
        newColors[index] = newColor;
        onChange(newColors);
      }
    }, index))
  });
}
var color_list_picker_default = ColorListPicker;
//# sourceMappingURL=index.cjs.map
