import { jsxs as E, jsx as k } from "react/jsx-runtime";
import { forwardRef as Y, useState as L, useRef as $ } from "react";
import { noop as w } from "es-toolkit/function";
import B from "../../utils/classNames.js";
import { createButtonRipple as S } from "../../utils/buttonEffect.js";
import F from "../../hooks/useMergeRefs.js";
import { getAutoTrackingAttributes as G } from "../../utils/analytics/autoTracking.js";
const z = {
  DEFAULT: "default",
  UNSTYLED: "unstyled",
  PRIMARY: "primary",
  SECONDARY: "secondary",
  INFO: "info",
  WARNING: "warning",
  DANGER: "danger",
  SUCCESS: "success",
  MUTED: "muted",
  MUTED_FILLED: "muted-filled"
}, i = {
  VARIANT_LINK: "link",
  VARIANT_LINK_INLINE: "link-inline",
  VARIANT_OUTLINE: "outline",
  VARIANT_ACTION: "action"
}, W = {
  XS: "xs",
  SM: "sm",
  MD: "md",
  LG: "lg"
}, u = Y((_, C) => {
  const {
    as: a = "button",
    active: n = !1,
    disabled: e = !1,
    asToggle: f = !1,
    onClick: l = w,
    bsStyle: y = "default",
    bsSize: b,
    variant: s,
    iconOnly: O = !1,
    iconName: o,
    iconRight: h = !1,
    multiline: D = !1,
    block: M = !1,
    className: V = "",
    noRippleEffect: N = !1,
    autoTrackingKey: v,
    type: U = "button",
    tabIndex: A = 0,
    children: m,
    ...r
  } = _, I = G({
    autoTrackingKey: v,
    props: r,
    source: "button"
  }), [g, d] = L(n), T = $(null), p = F(T, C), [x, P] = L(n);
  n !== x && (d(n), P(n));
  const j = (t) => {
    if (N || S(t.nativeEvent, t.currentTarget), f) {
      const c = !g;
      d(c), c && T.current?.blur(), l(c);
    } else
      l(t);
  }, K = (t) => {
    if (e) {
      t.preventDefault();
      return;
    }
    N || S(t.nativeEvent, t.currentTarget), l(t);
  }, R = B(
    "btn",
    `btn-${y}`,
    s === i.VARIANT_LINK && "btn-link",
    s === i.VARIANT_LINK_INLINE && "btn-link btn-link-inline",
    s === i.VARIANT_OUTLINE && "btn-outline",
    s === i.VARIANT_ACTION && "btn-action",
    b && `btn-${b}`,
    f && "btn-toggle",
    g && "active",
    O && "btn-icon-only",
    h && "btn-icon-right",
    D && "btn-multiline",
    M && "btn-block",
    a === "a" && "gap-0",
    a === "a" && e && "disabled",
    "btn-component",
    V
  );
  return a === "a" ? /* @__PURE__ */ E(
    "a",
    {
      ref: p,
      ...r,
      ...I,
      className: R,
      onClick: K,
      "aria-disabled": e || void 0,
      tabIndex: e ? -1 : A,
      children: [
        o && /* @__PURE__ */ k("span", { className: `rioglyph ${o}` }),
        m
      ]
    }
  ) : /* @__PURE__ */ E(
    "button",
    {
      ref: p,
      type: U,
      ...r,
      ...I,
      className: R,
      onClick: j,
      disabled: e,
      tabIndex: A,
      children: [
        o && /* @__PURE__ */ k("span", { className: `rioglyph ${o}` }),
        m
      ]
    }
  );
});
Object.assign(u, z);
Object.assign(u, i);
Object.assign(u, W);
export {
  W as SIZES_MAP,
  z as STYLES_MAP,
  i as VARIANTS_MAP,
  u as default
};
//# sourceMappingURL=Button.js.map
