import { jsx as u, Fragment as d } from "@emotion/react/jsx-runtime";
import M, { useMemo as $ } from "react";
import { clsx as g } from "clsx";
import { getPropertyByString as p } from "@m4l/core";
import { UncertaintyFormatterRootStyled as C } from "./slots/UncertaintyFormatterSlots.js";
import { useComponentSize as U } from "../../../hooks/useComponentSize/index.js";
import { getPropDataTestId as x } from "../../../test/getNameDataTestId.js";
import { getComponentSlotRoot as F } from "../../../utils/getComponentSlotRoot.js";
import { UNCERTAINTY_FORMATTER_KEY_COMPONENT as y } from "./constants.js";
import { UncertaintyFormatterSlots as S } from "./slots/UncertaintyFormatterEnum.js";
function T(o, c, m, i) {
  let r = "";
  const e = p(o, c), a = p(o, m), n = p(o, i);
  return e == null || !Array.isArray(e) || typeof a != "string" || typeof n != "string" ? "[]" : (e.map((t, l) => {
    const f = t.cmcMinClosed !== !0 ? "<" : "≤", s = t.cmcMaxClosed !== !0 ? "<" : "≤";
    return r = r.concat(
      `${l > 0 ? " " : ""}`,
      t.cmcMin !== t.cmcMax ? `[${t.cmcMin}${n} ${f} ${a} ${s} ${t.cmcMax}${n} ± ${t.cmcUncertainty}]` : `[${t.cmcMin}${n} ± ${t.cmcUncertainty}]`
    ), r;
  }), r);
}
function P(o) {
  const { obProps: c, fieldValue: m, fieldSymbol: i, fieldUnit: r, Component: e = C, size: a = "medium", color: n, dataTestid: t, className: l } = o, { currentSize: f } = U(a), s = $(
    () => T(c, m, i, r),
    [c, m, i, r]
  );
  return e === M.Fragment ? /* @__PURE__ */ u(d, { children: s }) : /* @__PURE__ */ u(
    e,
    {
      size: f,
      variant: "body",
      color: n,
      className: g(F(y), l),
      ...x(y, S.root, t),
      children: s
    }
  );
}
export {
  P as UncertaintyFormatter,
  T as getUncertaintyFormat
};
