import { cx as e } from "../../../theme/tools.js";
import { Button as t } from "../../../atomic/atoms/button/Button.js";
import n from "../../../hooks/useClipboardCopy.js";
import { feedback as r, root as i, value as a, valueNoTruncate as o } from "./copyableText.css.js";
import { useMemo as s } from "react";
import { jsx as c, jsxs as l } from "react/jsx-runtime";
import { useTranslation as u } from "react-i18next";
//#region src/backoffice/atoms/copyable_text/CopyableText.tsx
var d = ({ value: d, copyValue: f, className: p, truncate: m = !0, copyLabel: h, copiedLabel: g }) => {
	let { t: _ } = u("ui", { useSuspense: !1 }), { copiedKey: v, copyText: y } = n(1400), b = h ?? _("backoffice.copyableText.copy", { defaultValue: "Copy" }), x = g ?? _("backoffice.copyableText.copied", { defaultValue: "Copied" }), S = f ?? d, C = S, w = v === C, T = s(() => {
		let t = null;
		return m || (t = o), e(a, t, p);
	}, [p, m]), E = () => {
		y(S, C).catch(() => {});
	}, D = null;
	return w && (D = /* @__PURE__ */ c("span", {
		className: r,
		role: "status",
		"aria-live": "polite",
		children: x
	})), /* @__PURE__ */ l("span", {
		className: i,
		children: [
			/* @__PURE__ */ c("span", {
				className: T,
				title: d,
				children: d
			}),
			/* @__PURE__ */ c(t, {
				type: "button",
				variant: "secondary",
				size: "small",
				onClick: E,
				children: b
			}),
			D
		]
	});
};
//#endregion
export { d as CopyableText, d as default };

//# sourceMappingURL=CopyableText.js.map