import { jsx, jsxs } from "react/jsx-runtime";
import { preventDefault } from "@cmpd/editor";
import { Trigger } from "@radix-ui/react-dropdown-menu";
import * as React from "react";
import { useTranslation } from "../../hooks/useTranslation/useTranslation.mjs";
import { Button } from "../primitives/Button.mjs";
import * as DropdownMenu from "../primitives/DropdownMenu.mjs";
const DoubleDropdownPicker = React.memo(function DoubleDropdownPicker2({
  label,
  uiTypeA,
  uiTypeB,
  labelA,
  labelB,
  itemsA,
  itemsB,
  styleA,
  styleB,
  valueA,
  valueB,
  onValueChange
}) {
  const msg = useTranslation();
  const iconA = React.useMemo(
    () => itemsA.find((item) => valueA.type === "shared" && valueA.value === item.value)?.icon ?? "mixed",
    [itemsA, valueA]
  );
  const iconB = React.useMemo(
    () => itemsB.find((item) => valueB.type === "shared" && valueB.value === item.value)?.icon ?? "mixed",
    [itemsB, valueB]
  );
  if (valueA === void 0 && valueB === void 0)
    return null;
  return /* @__PURE__ */ jsxs("div", { className: "tlui-style-panel__double-select-picker", children: [
    /* @__PURE__ */ jsx("div", { title: msg(label), className: "tlui-style-panel__double-select-picker-label", children: msg(label) }),
    /* @__PURE__ */ jsxs("div", { className: "tlui-buttons__horizontal", children: [
      /* @__PURE__ */ jsxs(DropdownMenu.Root, { id: `style panel ${uiTypeA} A`, children: [
        /* @__PURE__ */ jsx(
          Trigger,
          {
            asChild: true,
            onTouchEnd: (e) => preventDefault(e),
            children: /* @__PURE__ */ jsx(
              Button,
              {
                type: "icon",
                "data-testid": `style.${uiTypeA}`,
                title: msg(labelA) + " \u2014 " + (valueA === null || valueA.type === "mixed" ? msg("style-panel.mixed") : msg(`${uiTypeA}-style.${valueA.value}`)),
                icon: iconA,
                invertIcon: true,
                smallIcon: true
              }
            )
          }
        ),
        /* @__PURE__ */ jsx(DropdownMenu.Content, { side: "bottom", align: "end", sideOffset: 0, alignOffset: -2, children: /* @__PURE__ */ jsx("div", { className: "tlui-buttons__grid", children: itemsA.map((item) => {
          return /* @__PURE__ */ jsx(
            DropdownMenu.Item,
            {
              type: "icon",
              title: msg(labelA) + " \u2014 " + msg(`${uiTypeA}-style.${item.value}`),
              "data-testid": `style.${uiTypeA}.${item.value}`,
              icon: item.icon,
              onClick: () => onValueChange(styleA, item.value, false),
              invertIcon: true
            },
            item.value
          );
        }) }) })
      ] }),
      /* @__PURE__ */ jsxs(DropdownMenu.Root, { id: `style panel ${uiTypeB}`, children: [
        /* @__PURE__ */ jsx(
          Trigger,
          {
            asChild: true,
            onTouchEnd: (e) => preventDefault(e),
            children: /* @__PURE__ */ jsx(
              Button,
              {
                type: "icon",
                "data-testid": `style.${uiTypeB}`,
                title: msg(labelB) + " \u2014 " + (valueB === null || valueB.type === "mixed" ? msg("style-panel.mixed") : msg(`${uiTypeB}-style.${valueB.value}`)),
                icon: iconB,
                smallIcon: true
              }
            )
          }
        ),
        /* @__PURE__ */ jsx(DropdownMenu.Content, { side: "bottom", align: "end", sideOffset: 0, alignOffset: -2, children: /* @__PURE__ */ jsx("div", { className: "tlui-buttons__grid", children: itemsB.map((item) => {
          return /* @__PURE__ */ jsx(
            DropdownMenu.Item,
            {
              type: "icon",
              title: msg(labelB) + " \u2014 " + msg(`${uiTypeB}-style.${item.value}`),
              "data-testid": `style.${uiTypeB}.${item.value}`,
              icon: item.icon,
              onClick: () => onValueChange(styleB, item.value, false)
            },
            item.value
          );
        }) }) })
      ] })
    ] })
  ] });
});
export {
  DoubleDropdownPicker
};
//# sourceMappingURL=DoubleDropdownPicker.mjs.map
