import { jsxs as u, jsx as t } from "react/jsx-runtime";
import { useFocusRing as b } from "@react-aria/focus";
import F from "../../foundation/Icon/Generated/IconCaretDown.es.js";
import S from "../../foundation/Icon/Generated/IconCross.es.js";
import C from "../../foundation/Icon/Generated/IconExclamationMarkTriangle.es.js";
import N from "../../foundation/Icon/Generated/IconTrashBin.es.js";
import { IconSize as w } from "../../foundation/Icon/IconSize.es.js";
import { FOCUS_STYLE as m, FOCUS_VISIBLE_STYLE as I } from "../../utilities/focusStyle.es.js";
import { merge as e } from "../../utilities/merge.es.js";
import { Validation as a, validationClassMap as z } from "../../utilities/validation.es.js";
var D = /* @__PURE__ */ ((r) => (r.Default = "Default", r.Weak = "Weak", r))(D || {});
const y = (r, i, s, l, o) => e([
  "tw-group tw-relative tw-flex tw-w-full tw-items-center tw-justify-between tw-border tw-rounded tw-transition-colors tw-min-h-[36px]",
  r && m,
  i ? "tw-border-black-5 tw-bg-black-5 tw-pointer-events-none" : e([
    "hover:tw-border-line-xx-strong",
    l === "Weak" ? "" : "tw-bg-base",
    s ? "tw-border-line-xx-strong" : "tw-border-line",
    l === "Weak" ? "tw-border-0 hover:tw-outline hover:tw-outline-1" : z[o]
  ])
]), T = ({
  buttonProps: r,
  onClear: i,
  onDelete: s,
  children: l,
  disabled: o = !1,
  isOpen: c = !1,
  isFocusVisible: d = !1,
  size: f = "Small",
  showClear: p = !1,
  validation: n = a.Default,
  emphasis: x = "Default"
  /* Default */
}) => {
  const { focusProps: g, isFocusVisible: k } = b(), { focusProps: h, isFocusVisible: v } = b();
  return /* @__PURE__ */ u(
    "div",
    {
      "data-test-id": "trigger",
      className: y(d, o, c, x, n),
      children: [
        l,
        /* @__PURE__ */ u(
          "div",
          {
            className: e([
              "tw-flex-none tw-flex tw-items-center tw-absolute",
              f === "Large" ? "tw-right-5 tw-gap-1.5" : "tw-right-3 tw-gap-1"
            ]),
            children: [
              p && /* @__PURE__ */ t(
                "button",
                {
                  ...g,
                  "data-test-id": "dropdown-clear-button",
                  "aria-label": "Clear selection",
                  type: "button",
                  className: e([
                    k && m,
                    o ? "tw-pointer-events-none tw-text-black-40" : "tw-text-black-80"
                  ]),
                  onClick: () => !!i && i(),
                  children: /* @__PURE__ */ t(S, { size: w.Size12 })
                }
              ),
              !!s && /* @__PURE__ */ t(
                "button",
                {
                  ...h,
                  "data-test-id": "dropdown-delete-button",
                  "aria-label": "Delete selection",
                  type: "button",
                  className: e([
                    "tw-rounded",
                    v && m,
                    o ? "tw-pointer-events-none tw-text-black-40" : "tw-text-black-80"
                  ]),
                  onClick: s,
                  children: /* @__PURE__ */ t(N, { size: w.Size12 })
                }
              ),
              /* @__PURE__ */ t(
                "button",
                {
                  ...r,
                  type: "button",
                  tabIndex: -1,
                  disabled: o,
                  "aria-hidden": !0,
                  className: e([
                    "tw-rounded",
                    o ? "tw-pointer-events-none tw-text-black-40" : e([
                      "group-hover:tw-text-black ",
                      c ? "tw-text-black-100" : "tw-text-black-80",
                      I
                    ])
                  ]),
                  children: /* @__PURE__ */ t("div", { className: e(["tw-transition-transform", c && "tw-rotate-180"]), children: /* @__PURE__ */ t(F, { size: w.Size16 }) })
                }
              ),
              (n === a.Error || n === a.Warning) && /* @__PURE__ */ t(
                "span",
                {
                  className: e([
                    "tw-flex tw-items-center tw-justify-center",
                    n === a.Error && "tw-text-text-negative",
                    n === a.Warning && "tw-text-text-warning"
                  ]),
                  "data-test-id": "error-state-exclamation-mark-icon",
                  children: /* @__PURE__ */ t(C, {})
                }
              )
            ]
          }
        )
      ]
    }
  );
};
T.displayName = "FondueTrigger";
export {
  T as Trigger,
  D as TriggerEmphasis
};
//# sourceMappingURL=Trigger.es.js.map
