import { jsxs as b, Fragment as N, jsx as e } from "react/jsx-runtime";
import { forwardRef as y } from "react";
import { cx as D } from "../../utils/classNames.js";
import { useArrowTheme as $ } from "../../hooks/useArrowTheme.js";
const j = y(
  ({
    id: o,
    behavior: f = "single",
    labelId: r,
    menuId: i,
    isExpanded: n = !1,
    selectedItems: t = [],
    disabled: s,
    isInvalid: d,
    describedBy: a = "",
    inverse: h,
    focused: g,
    className: v,
    ...l
  }, c) => {
    const x = $(), m = h ?? x.inverse, p = D(
      "tdds-field__select",
      "tdds-menu__trigger",
      {
        "force-focus": !!g
      },
      v
    );
    if (f === "multi") {
      const u = `${o}-selected-items-badge`, w = `${u} ${a}`.trim();
      return /* @__PURE__ */ b(N, { children: [
        /* @__PURE__ */ b(
          "span",
          {
            className: "tdds-field__leading-decoration tdds-field__leading-decoration--badge",
            id: u,
            "aria-hidden": "true",
            children: [
              t.length,
              /* @__PURE__ */ e("span", { children: ", items selected" })
            ]
          }
        ),
        /* @__PURE__ */ e(
          "button",
          {
            ref: c,
            className: p,
            "aria-controls": i,
            "aria-describedby": w || void 0,
            "aria-disabled": s || void 0,
            "aria-expanded": n,
            "aria-haspopup": "listbox",
            "aria-labelledby": r,
            "aria-invalid": d || void 0,
            type: "button",
            role: "combobox",
            id: o,
            ...m ? { "data-inverse": "true" } : {},
            ...l
          }
        )
      ] });
    }
    const _ = t.length > 0 ? t[0].text : "";
    return /* @__PURE__ */ e(
      "button",
      {
        ref: c,
        className: p,
        "aria-controls": i,
        "aria-describedby": (a == null ? void 0 : a.trim()) || void 0,
        "aria-disabled": s || void 0,
        "aria-expanded": n,
        "aria-haspopup": "listbox",
        "aria-labelledby": r,
        "aria-invalid": d || void 0,
        type: "button",
        role: "combobox",
        id: o,
        ...m ? { "data-inverse": "true" } : {},
        ...l,
        children: /* @__PURE__ */ e("span", { children: _ })
      }
    );
  }
);
j.displayName = "DropdownButton";
export {
  j as DropdownButton
};
//# sourceMappingURL=DropdownButton.js.map
