import { j as t } from "../../_virtual/jsx-runtime.js";
import x from "react";
import { getId as j } from "../../utils/index.js";
import { getSpinnerVariant as p } from "./utils.js";
import { StyledButton as u, SpinnerWrapper as g, IconContainer as d, ContentWrapper as S } from "./styles.js";
import { Spinner as h } from "../Spinner/index.js";
const _ = x.forwardRef(
  ({
    variant: r = "primary",
    size: l = "large",
    children: a,
    type: s = "button",
    disabled: m = !1,
    isLoading: n = !1,
    fullWidth: c = !1,
    iconPosition: i = "leading",
    ...e
  }, f) => {
    const o = j(e["data-testid"]);
    return /* @__PURE__ */ t.jsx(
      u,
      {
        ...e,
        variant: r,
        size: l,
        ref: f,
        disabled: m,
        isLoading: n,
        type: s,
        fullWidth: c,
        "data-status": n ? "loading" : null,
        children: n ? /* @__PURE__ */ t.jsx(g, { children: /* @__PURE__ */ t.jsx(
          h,
          {
            "data-testid": o("spinner"),
            variant: p(r),
            size: "S"
          }
        ) }) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
          i === "leading" && e.icon && /* @__PURE__ */ t.jsx(d, { children: e.icon }),
          a && /* @__PURE__ */ t.jsx(S, { "data-testid": o("content"), children: a }),
          i === "trailing" && e.icon && /* @__PURE__ */ t.jsx(d, { children: e.icon })
        ] })
      }
    );
  }
);
export {
  _ as Button
};
