import { jsxs as j, jsx as B } from "react/jsx-runtime";
import { useButton as I } from "@react-aria/button";
import { useFocusRing as O } from "@react-aria/focus";
import { forwardRef as V, cloneElement as _ } from "react";
import { buttonTypeMap as k, buttonIconSizeMap as z } from "./mappings.es.js";
import { FOCUS_VISIBLE_STYLE as T } from "../../utilities/focusStyle.es.js";
import { merge as r } from "../../utilities/merge.es.js";
import { useForwardedRef as U } from "../../utilities/useForwardedRef.es.js";
import { ButtonStyleClasses as W, ButtonDisabledClasses as Y, ButtonCommonClasses as q, ButtonRoundingClasses as v, ButtonSizeClasses as d, IconSpacingClasses as A } from "./ButtonClasses.es.js";
import { ButtonType as G, ButtonRounding as H, ButtonSize as J, ButtonStyle as o, ButtonEmphasis as u } from "./ButtonTypes.es.js";
const K = ({
  type: S = G.Button,
  title: b = "",
  style: t = o.Default,
  size: n = J.Medium,
  rounding: y = H.Medium,
  emphasis: s = u.Strong,
  hideLabel: i = !1,
  disabled: e = !1,
  icon: m,
  children: a,
  onClick: p,
  hugWidth: C = !0,
  "aria-label": g,
  "aria-describedby": w,
  formId: D,
  solid: x,
  inverted: F,
  "data-test-id": l = "button"
}, N) => {
  t === o.Primary ? (t = o.Default, s = u.Strong) : t === o.Secondary && (t = o.Default, s = u.Default), x === !1 && (s = u.Weak);
  const c = U(N), { buttonProps: R } = I(
    {
      onPress: () => {
        p && p();
      },
      isDisabled: e,
      type: k[S]
    },
    c
  ), { isFocusVisible: E, focusProps: M } = O(), f = ($) => e ? Y : `${W[s][t][$]}`, P = r([
    f("button"),
    q,
    v[y],
    m && !a || i ? d[n].iconOnly : d[n].default,
    !C && "tw-w-full"
  ]);
  return /* @__PURE__ */ j(
    "button",
    {
      "data-test-id": l,
      "aria-label": g,
      "aria-disabled": e,
      "aria-describedby": w,
      ref: c,
      className: r([P, F && "tw-dark", E && T]),
      disabled: e,
      form: D,
      title: b,
      ...R,
      ...M,
      children: [
        m ? /* @__PURE__ */ B(
          "span",
          {
            "data-test-id": `${l}-icon`,
            className: r([a && !i ? A[n] : "", f("icon")]),
            children: _(m, { size: z[n] })
          }
        ) : null,
        a ? /* @__PURE__ */ B(
          "span",
          {
            "data-test-id": `${l}-text`,
            className: r([f("text"), i && "tw-sr-only"]),
            children: a
          }
        ) : null
      ]
    }
  );
}, L = V(K);
L.displayName = "FondueButton";
export {
  L as Button
};
//# sourceMappingURL=Button.es.js.map
