"use client";
import { jsx as a, jsxs as w } from "react/jsx-runtime";
import { forwardRef as B } from "react";
import { cn as j } from "../../utils/cn/cn.es.js";
import t from "../../components/Button/button.module.css";
import { Icon as m } from "../Icon/Icon.es.js";
const W = B(
  ({
    variant: d = "primary",
    size: r = "md",
    as: u = "button",
    disabled: i = !1,
    children: f,
    prefixIcon: e,
    suffixIcon: s,
    analyticsProps: o,
    loading: v,
    ...n
  }, C) => {
    const h = t[d] || "", N = t[r] || "", b = i ? t.disabled : "", y = (k) => {
      var l, c;
      o && ((l = window.eventBus) == null || l.emit("analytics", o)), (c = n.onClick) == null || c.call(n, k);
    };
    return /* @__PURE__ */ a(
      u,
      {
        ref: C,
        ...n,
        className: j(t.button, h, N, b),
        disabled: i,
        onClick: y,
        "data-type": "button",
        "data-loading": v,
        children: /* @__PURE__ */ w("div", { className: t.content, children: [
          e && /* @__PURE__ */ a("div", { className: t.iconWrap, children: /* @__PURE__ */ a(m, { name: e }) }),
          /* @__PURE__ */ a("div", { children: f }),
          s && /* @__PURE__ */ a("div", { className: t.iconWrap, children: /* @__PURE__ */ a(m, { name: s }) })
        ] })
      }
    );
  }
);
W.displayName = "Button";
export {
  W as Button
};
