import { jsx as t } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import D from "classnames";
import { useState as n, useRef as y, useLayoutEffect as C } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { Alert as M } from "../../../../internal/Alert/Alert.js";
import p from "../../../../internal/Typography/Typography.js";
import { AlertTypeOption as R } from "../../../../internal/Alert/types.js";
import { ButtonVariant as U } from "../../../../internal/Button/types.js";
import { TypographyVariant as u, TypographyElement as l } from "../../../../internal/Typography/types.js";
import { DISPUTE_DATA_ISSUER_COMMENT as T, DISPUTE_DATA_ISSUER_COMMENTS_ALERT as x, DISPUTE_DATA_ISSUER_COMMENTS_GROUP as H, DISPUTE_DATA_ISSUER_COMMENTS as P, DISPUTE_DATA_ISSUER_COMMENTS_TRUNCATED as N, DISPUTE_DATA_ISSUER_COMMENTS_EXPANDED as O } from "./constants.js";
/* empty css                 */
import v from "../../../../../core/Context/preact/useCoreContext.js";
import G from "../../../../internal/Button/Button.js";
const F = ({ issuerComments: h }) => {
  const { i18n: m } = v(), [E, S] = n(0), [d, g] = n(0), [a, _] = n(!1), [i, f] = n(!1), r = y(null), A = (e) => {
    e.preventDefault(), f(!i), r.current?.style.setProperty("max-height", `${i ? E : d}px`);
  };
  return C(() => {
    if (r.current) {
      const e = r.current, s = e.querySelector(`:scope .${T}`), I = s ? parseInt(getComputedStyle(s).getPropertyValue("line-height")) : 0, o = Math.min(s?.clientHeight || 1 / 0, I * 3), c = e.scrollHeight;
      S(o), g(c), _(c > o), r.current?.style.setProperty("max-height", `${o}px`);
    }
  }, []), /* @__PURE__ */ t(
    M,
    {
      type: R.HIGHLIGHT,
      description: /* @__PURE__ */ t("div", { className: x, children: [
        /* @__PURE__ */ t(p, { el: l.DIV, variant: u.BODY, strongest: !0, children: m.get("disputes.management.details.issuerComment") }),
        /* @__PURE__ */ t(
          "div",
          {
            className: D(P, {
              [O]: i,
              [N]: a
            }),
            children: /* @__PURE__ */ t("ul", { ref: r, className: H, children: h.map((e, s) => /* @__PURE__ */ t("li", { children: /* @__PURE__ */ t(
              p,
              {
                className: T,
                el: l.PARAGRAPH,
                variant: u.BODY,
                children: e
              }
            ) }, s)) })
          }
        ),
        a && /* @__PURE__ */ t(G, { variant: U.TERTIARY, onClick: A, children: m.get(
          i ? "disputes.management.details.issuerComment.showLess" : "disputes.management.details.issuerComment.showMore"
        ) })
      ] })
    }
  );
};
export {
  F as DisputeIssuerComments
};
