import { jsx as a, jsxs as d, Fragment as S } from "@emotion/react/jsx-runtime";
import { useEnvironment as N, useModuleSkeleton as v } from "@m4l/core";
import w from "clsx";
import { LABEL_KEY_COMPONENT as z, classLabelRoot as _, LAB_SPECIFY as k } from "./constants.js";
import { useComponentSize as C } from "../../hooks/useComponentSize/index.js";
import { LabelRootStyled as E, TypographyStyled as x, TypographyMandatoryMessageStyled as I, IconHelperMessageStyled as j, SkeletonStyled as l } from "./slots/LabelSlots.js";
const P = (p) => {
  const { helperMessage: s, label: y, mandatory: i, mandatoryMessage: r, htmlFor: h, id: g, error: u, size: c = "medium", disabled: t, className: b } = p, { host_static_assets: f, environment_assets: M } = N(), L = v(), { currentSize: o } = C(c), m = typeof s == "string" && s.length > 0, n = o === "small" || o === "medium" ? o : "medium", e = {
    disabled: t,
    size: c
  };
  return /* @__PURE__ */ a(
    E,
    {
      "aria-label": z,
      ownerState: { ...e },
      htmlFor: h,
      id: g,
      children: L ? /* @__PURE__ */ d(S, { children: [
        /* @__PURE__ */ a(l, { ownerState: { ...e }, variant: "rectangular", className: "SkeletonWidthLabel" }),
        i && /* @__PURE__ */ a(l, { ownerState: { ...e }, variant: "circular", className: "MandatoryLabel" }),
        m && /* @__PURE__ */ a(l, { ownerState: { ...e }, variant: "circular", className: "HelperIconLabel" })
      ] }) : /* @__PURE__ */ d(S, { children: [
        /* @__PURE__ */ a(
          x,
          {
            className: w(_, k, "M4lclassCssSpecificity", b),
            ownerState: { ...e },
            variant: "bodyStandard",
            size: n,
            disabled: t,
            children: y
          }
        ),
        i && /* @__PURE__ */ a(
          I,
          {
            ownerState: { ...e },
            variant: "bodyStandard",
            className: r ? "mandatoryMessage" : "mandatoryAsterisk",
            size: n,
            disabled: t,
            children: r || "*"
          }
        ),
        m && /* @__PURE__ */ a(
          j,
          {
            tooltipContent: s,
            ownerState: { ...e },
            placement: "right",
            size: n,
            className: u ? "helper-icon-error" : "helper-icon",
            disabled: t,
            src: `${f}/${M}/frontend/components/LabelMessage/assets/icons/infoSmall.svg`
          }
        )
      ] })
    }
  );
};
export {
  P as Label
};
