import { jsxs as c, jsx as t } from "@emotion/react/jsx-runtime";
import y, { useId as b } from "react";
import z from "clsx";
import { TEST_PROP_ID as C } from "../../test/constants_no_mock.js";
import { TEST_PROPS_DATA as A, COMPONENT_PREFIX as D, PROPERTY_VALUE_KEY_COMPONENT as s } from "./constants.js";
import { getNameDataTestId as x, getPropDataTestId as F } from "../../test/getNameDataTestId.js";
import { Icon as M } from "@m4l/base";
import { PropertyValueRootStyled as W, ContainerStartAdornmentStyled as $, ContainerPropertyAndValueStyled as j, NameStyled as q, ValueStyled as w, TypographyValueStyled as L } from "./slots/PropertyValueSlots.js";
import { getComponentSlotRoot as f } from "../../utils/getComponentSlotRoot.js";
import { getNullGuard as Y } from "../../utils/getNullGuard.js";
import { Label as G } from "../Label/Label.js";
import { useComponentSize as H } from "@m4l/graphics";
function ie(S) {
  const {
    property: l,
    startAdornment: o,
    value: e,
    className: h,
    isForm: n,
    dataTestId: m = "",
    disabled: p = !1,
    mandatory: P,
    mandatoryMessage: v,
    helperMessage: E,
    semanticWidth: a = "fullWidth",
    propertyWidth: N = 200,
    size: T = "medium",
    direction: u,
    valueHeight: g,
    iconVariant: I = "outlined",
    iconColor: V = "primary",
    borderStyle: O = "none"
  } = S, d = `property-value-${b()}`, { currentSize: i } = H(T), r = {
    propertyWidth: N,
    disabled: n && p ? p : !1,
    isForm: !!n,
    semanticWidth: a,
    valueHeight: g,
    size: i,
    direction: n && u === void 0 ? "column" : u ?? "row",
    iconVariant: I,
    iconColor: V,
    borderStyle: O
  }, _ = () => o ? typeof o == "string" ? /* @__PURE__ */ t(
    M,
    {
      src: o,
      color: "text.secondary"
    }
  ) : o : null, R = () => typeof e == "string" || typeof e == "number" || e === null || e === void 0 ? /* @__PURE__ */ t(L, { id: d, size: i, variant: "bodyDens", ownerState: r, children: Y(e) }) : y.isValidElement(e) ? y.cloneElement(e, { size: i, id: d }) : e;
  return /* @__PURE__ */ c(
    W,
    {
      role: n ? "property-value-form-role" : "property-value-role",
      className: z(
        f(s),
        a && `${f(s)}-semanticWidth-${a}`,
        h
      ),
      ...F(s, "root", m),
      ownerState: r,
      ...process.env.NODE_ENV !== "production" ? {
        [A]: JSON.stringify([{ property: !!l, value: !!e }]),
        [C]: x(D, "root", m)
      } : {},
      children: [
        o && /* @__PURE__ */ t($, { ownerState: r, children: _() }),
        /* @__PURE__ */ c(j, { ownerState: r, children: [
          /* @__PURE__ */ t(q, { ownerState: r, children: l && /* @__PURE__ */ t(
            G,
            {
              size: i,
              label: l,
              mandatory: P,
              mandatoryMessage: v,
              helperMessage: E,
              htmlFor: d
            }
          ) }),
          /* @__PURE__ */ t(w, { role: "property-value-value-role", ownerState: r, children: R() })
        ] })
      ]
    }
  );
}
export {
  ie as PropertyValue
};
