"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/justify-content-control/ui.js
var ui_exports = {};
__export(ui_exports, {
  default: () => ui_default
});
module.exports = __toCommonJS(ui_exports);
var import_components = require("@wordpress/components");
var import_icons = require("@wordpress/icons");
var import_i18n = require("@wordpress/i18n");
var import_jsx_runtime = require("react/jsx-runtime");
var icons = {
  left: import_icons.justifyLeft,
  center: import_icons.justifyCenter,
  right: import_icons.justifyRight,
  "space-between": import_icons.justifySpaceBetween,
  stretch: import_icons.justifyStretch
};
function JustifyContentUI({
  allowedControls = ["left", "center", "right", "space-between"],
  isCollapsed = true,
  onChange,
  value,
  popoverProps,
  isToolbar
}) {
  const handleClick = (next) => {
    if (next === value) {
      onChange(void 0);
    } else {
      onChange(next);
    }
  };
  const icon = value ? icons[value] : icons.left;
  const allControls = [
    {
      name: "left",
      icon: import_icons.justifyLeft,
      title: (0, import_i18n.__)("Justify items left"),
      isActive: "left" === value,
      onClick: () => handleClick("left")
    },
    {
      name: "center",
      icon: import_icons.justifyCenter,
      title: (0, import_i18n.__)("Justify items center"),
      isActive: "center" === value,
      onClick: () => handleClick("center")
    },
    {
      name: "right",
      icon: import_icons.justifyRight,
      title: (0, import_i18n.__)("Justify items right"),
      isActive: "right" === value,
      onClick: () => handleClick("right")
    },
    {
      name: "space-between",
      icon: import_icons.justifySpaceBetween,
      title: (0, import_i18n.__)("Space between items"),
      isActive: "space-between" === value,
      onClick: () => handleClick("space-between")
    },
    {
      name: "stretch",
      icon: import_icons.justifyStretch,
      title: (0, import_i18n.__)("Stretch items"),
      isActive: "stretch" === value,
      onClick: () => handleClick("stretch")
    }
  ];
  const UIComponent = isToolbar ? import_components.ToolbarGroup : import_components.ToolbarDropdownMenu;
  const extraProps = isToolbar ? { isCollapsed } : {};
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
    UIComponent,
    {
      icon,
      popoverProps,
      label: (0, import_i18n.__)("Change items justification"),
      controls: allControls.filter(
        (elem) => allowedControls.includes(elem.name)
      ),
      ...extraProps
    }
  );
}
var ui_default = JustifyContentUI;
//# sourceMappingURL=ui.js.map
