import { jsx as t } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { AmountSkeleton as b } from "../AmountSkeleton/AmountSkeleton.js";
import { BASE_CLASS as y, PLACEHOLDER_CLASS as f, AMOUNT_CLASS as T, LABEL_CLASS as E, BODY_CLASS as N } from "./constants.js";
import { SummaryItemLabel as S } from "./SummaryItemLabel.js";
import { Tooltip as B } from "../../../../internal/Tooltip/Tooltip.js";
import { TypographyVariant as s, TypographyElement as I } from "../../../../internal/Typography/types.js";
import O from "../../../../internal/Typography/Typography.js";
import n from "classnames";
import { useEffect as _, useCallback as x } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
/* empty css                 */
import { useResponsiveContainer as D, containerQueries as H } from "../../../../../hooks/useResponsiveContainer.js";
import M from "../../../../../core/Context/preact/useCoreContext.js";
const $ = ({
  columnConfigs: p,
  isHeader: i = !1,
  showLabelUnderline: h = !1,
  isSkeletonVisible: a = !1,
  isLoading: d = !1,
  widths: l,
  onWidthsSet: u,
  isEmpty: C
}) => {
  const { i18n: o } = M();
  _(() => {
    const e = p.map((r) => r.ref?.current?.getBoundingClientRect().width ?? 0);
    u(e);
  }, [u]);
  const A = (e) => ({ width: l && l[e] ? l[e] : "auto" }), L = D(H.only.xs), c = x(
    (e, r) => e.valueHasLabelStyle ? s.CAPTION : r && !L ? s.BODY : s.TITLE,
    [L]
  );
  return /* @__PURE__ */ t("div", { className: n(y, { [N]: !i }), children: p.map((e, r) => {
    const m = e.getValue(), v = !!m && m.length > 15;
    return /* @__PURE__ */ t("div", { children: [
      i && /* @__PURE__ */ t("div", { role: "presentation", children: e.tooltipLabel ? /* @__PURE__ */ t(B, { content: o.get(`${e.tooltipLabel}`), isUnderlineVisible: h, children: /* @__PURE__ */ t(S, { config: e, i18n: o, isSkeletonVisible: a }) }) : /* @__PURE__ */ t(S, { config: e, i18n: o, isSkeletonVisible: a }) }),
      a ? /* @__PURE__ */ t(b, { isLoading: d, hasMargin: e.hasSkeletonMargin, width: e.skeletonWidth + "px" }) : C ? /* @__PURE__ */ t("span", { className: n([y, f]) }) : /* @__PURE__ */ t("div", { id: e.elemId, ref: e.ref, style: A(r), "aria-label": e.ariaLabel, role: "presentation", children: /* @__PURE__ */ t(
        O,
        {
          el: I.SPAN,
          variant: c(e, v),
          className: n({ [E]: e.valueHasLabelStyle, [T]: !e.valueHasLabelStyle }),
          children: m
        }
      ) })
    ] }, r);
  }) });
};
export {
  $ as SummaryItem
};
