import { cx as e } from "../../../theme/tools.js";
import { HighlightCode as t } from "../../../atomic/molecules/highlight/HighlightCode.js";
import { LazyMarkdownRenderer as n } from "../../../atomic/molecules/markdown/LazyMarkdownRenderer.js";
import { BackofficeJsonViewer as r } from "../backoffice_json_viewer/BackofficeJsonViewer.js";
import { resolveBackofficePayloadTextContent as i } from "./BackofficePayloadViewer.helpers.js";
import { container as a, details as o, detailsSummary as s, empty as c } from "./backofficePayloadViewer.css.js";
import { useMemo as l } from "react";
import { jsx as u, jsxs as d } from "react/jsx-runtime";
import { useTranslation as f } from "react-i18next";
//#region src/backoffice/molecules/backoffice_payload_viewer/BackofficePayloadViewer.tsx
var p = ({ content: p, format: m, summary: h, mode: g = "inline", initiallyExpanded: _ = !1, emptyState: v, labels: y, className: b, maxHeight: x }) => {
	let { t: S } = f("ui"), C = v ?? S("backoffice.payloadViewer.emptyState"), w = l(() => i(p), [p]), T = w.trim() === "", E = l(() => {
		if (x != null) return {
			maxHeight: x,
			overflow: "auto"
		};
	}, [x]), D;
	if (T) D = /* @__PURE__ */ u("span", {
		className: c,
		children: C
	});
	else if (m === "json") D = /* @__PURE__ */ u(r, {
		value: p,
		title: y?.jsonTitle,
		maxHeight: x,
		truncate: g === "details" && !_,
		truncateLabel: y?.jsonCollapse,
		expandLabel: y?.jsonExpand,
		copyLabel: y?.copy,
		copiedLabel: y?.copied
	});
	else if (m === "markdown") D = /* @__PURE__ */ u(n, { content: w });
	else {
		let e = y?.textBadge ?? S("backoffice.payloadViewer.text");
		m === "code" && (e = y?.codeBadge ?? S("backoffice.payloadViewer.code")), D = /* @__PURE__ */ u("div", {
			style: E,
			children: /* @__PURE__ */ u(t, {
				badgeLabel: e,
				copyCode: w,
				fallbackCodeText: w
			})
		});
	}
	let O = D;
	return g === "details" && (O = /* @__PURE__ */ d("details", {
		className: o,
		open: _,
		children: [/* @__PURE__ */ u("summary", {
			className: s,
			children: y?.details ?? S("backoffice.payloadViewer.details")
		}), D]
	})), /* @__PURE__ */ d("div", {
		className: e(a, b),
		children: [h != null && /* @__PURE__ */ u("div", {
			className: "wrqh461 txvbqb1bg3 txvbqb9j",
			children: h
		}), O]
	});
};
//#endregion
export { p as BackofficePayloadViewer, p as default };

//# sourceMappingURL=BackofficePayloadViewer.js.map