import { jsx as a, jsxs as N } from "@emotion/react/jsx-runtime";
import { useModuleSkeleton as g, getPropertyByString as j } from "@m4l/core";
import { useTheme as k } from "@mui/material";
import { forwardRef as C } from "react";
import { useComponentSize as T } from "../../../../hooks/useComponentSize/index.js";
import { BUTTON_CLASSES as d } from "./constants.js";
import R from "clsx";
import { SkeletonButtonStyled as v, ButtonRootStyled as A, TextButtonStyled as E, ButtonIconStyled as W } from "./slots/ButtonSlots.js";
const $ = C((i, S) => {
  const {
    className: p,
    endIcon: B,
    label: I,
    startIcon: h,
    color: n = "default",
    disabled: e = !1,
    size: u,
    variant: r = "contained",
    skeletonWidth: b = "15%",
    fullWidth: x = !1,
    ...y
  } = i, { currentSize: s } = T(u), w = g(), c = k(), z = j(
    c.vars.palette,
    e ? "default" : n || "default",
    c.vars.palette.default
  ), o = {
    size: s,
    variant: r,
    disabled: e,
    paletteColor: z,
    color: n,
    fullWidth: x
  };
  if (w)
    return /* @__PURE__ */ a(v, { "data-testid": "SkeletonButton", width: b, ownerState: { ...o } });
  const m = ((t, l) => l === "contained" ? `${t}.contrastText` : `${t}.enabled`)(n, r), f = (t, l) => t ? typeof t != "string" ? t : /* @__PURE__ */ a(
    W,
    {
      color: m,
      ownerState: { ...o },
      src: t,
      alt: "icon",
      size: s,
      disabled: e,
      instaceDataTestId: l,
      className: d.buttonIcon
    }
  ) : null;
  return /* @__PURE__ */ N(
    A,
    {
      "aria-disabled": e,
      role: "button",
      startIcon: f(h, "ButtonStartIcon"),
      endIcon: f(B, "ButtonEndIcon"),
      className: R(p, d.buttonRoot),
      variant: r,
      size: u,
      disabled: e,
      disableRipple: !0,
      tabIndex: 0,
      ownerState: { ...o },
      ref: S,
      ...y,
      children: [
        /* @__PURE__ */ a(
          E,
          {
            ownerState: { ...o },
            color: m,
            size: s,
            className: d.textButton,
            children: I
          }
        ),
        i.children
      ]
    }
  );
});
$.displayName = "Button";
export {
  $ as Button
};
