import { jsx as t, jsxs as g } from "react/jsx-runtime";
import L from "react";
import { Loader as j } from "lucide-react";
import k from "../kbd/KbdGroup.js";
import T from "../kbd/Kbd.js";
import { c as v } from "../../index-BtlgVD4m.js";
import { buttonSizes as I } from "./types/ButtonSize.js";
import { buttonVariants as X } from "./types/ButtonVariant.js";
import { buttonShapes as Z } from "./types/ButtonShape.js";
import y from "../icon/components/icon-extend/IconExtend.js";
const r = {
  base: "relative items-center justify-center text-[length:var(--typography-base-sizes-small-font-size)] font-[var(--font-weight-normal)] leading-[var(--typography-base-sizes-small-line-height)] transition-colors [&_svg]:shrink-0",
  rounded: "rounded-[var(--border-radius-default)]",
  states: {
    default: "hover:cursor-pointer focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-[var(--base-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-[var(--base-ring-offset)]",
    disabled: "disabled:opacity-50 disabled:cursor-not-allowed",
    loading: "disabled:opacity-50 disabled:cursor-progress"
  }
}, K = 16, U = 12, q = ["icon", "iconXs", "iconLg", "iconSm"], F = ["xs", "iconXs"], V = ({
  size: s = "default",
  variant: i = "default",
  shape: S = "default",
  isLoading: o = !1,
  icon: n,
  iconPosition: u = "left",
  disabled: f,
  label: a,
  badgeNum: c,
  fullWidth: N = !1,
  shortcut: e,
  ref: _,
  ...x
}) => {
  const w = q.includes(s), b = !a || a.trim() === "", l = w || n && b, d = F.includes(s) ? U : K;
  if (i === "link" && b)
    return console.warn("Button: Link variant requires a label (text content)"), null;
  if (l && !n)
    return console.warn("Button: Icon-only button requires an icon prop"), null;
  const m = n && u === "left" ? /* @__PURE__ */ t(y, { icon: n, size: d }) : null, O = n && u === "right" ? /* @__PURE__ */ t(y, { icon: n, size: d }) : null, B = o ? /* @__PURE__ */ t(j, { className: "animate-spin", size: d }) : !o && m && (i !== "link" || !!a) ? m : null, z = !l && (a ?? null), C = O ?? null, E = !l && (e != null && e.length) ? /* @__PURE__ */ t(k, { "aria-label": "Keyboard shortcut", children: e.map((p, h) => /* @__PURE__ */ g(L.Fragment, { children: [
    h > 0 && /* @__PURE__ */ t("span", { "aria-hidden": "true", children: "+" }),
    /* @__PURE__ */ t(T, { children: p })
  ] }, `${p}-${h}`)) }) : null;
  return /* @__PURE__ */ g(
    "button",
    {
      ref: _,
      type: "button",
      className: v(
        r.base,
        r.rounded,
        r.states.default,
        Z[S],
        o ? r.states.loading : f && r.states.disabled,
        X[i],
        l ? I[s].iconOnly : I[s].base,
        N ? "w-full" : ""
      ),
      disabled: f || o,
      ...x,
      "aria-keyshortcuts": e == null ? void 0 : e.join("+"),
      "aria-busy": o,
      children: [
        B,
        z,
        C,
        E,
        Number(c) > 0 && /* @__PURE__ */ t(
          "div",
          {
            className: v(
              "absolute -top-2 -right-2",
              "flex items-center justify-center",
              "border border-[var(--base-border)] rounded-[var(--border-radius-full)]",
              "bg-[var(--base-background)] h-[var(--height-h-5)] w-[var(--width-w-5)]",
              "text-[var(--base-foreground)] text-[length:var(--typography-base-sizes-extra-small-font-size)]"
            ),
            children: Number(c) > 9 ? "9+" : c
          }
        )
      ]
    }
  );
};
V.displayName = "Button";
export {
  V as default
};
//# sourceMappingURL=Button.js.map
