import { JsonViewer as e } from "../../editors/json-viewer.js";
import { t } from "../../utils-B7XIe3qq.js";
import * as n from "react";
import { jsx as r } from "react/jsx-runtime";
//#region src/react/editors/json-viewer.tsx
function i({ defaultValue: i, value: a, onChange: o, className: s, ...c }) {
	let l = n.useRef(null), u = n.useRef(null), d = n.useRef(!1), f = n.useRef(o);
	return f.current = o, n.useEffect(() => {
		if (typeof document > "u" || !l.current) return;
		let t = a ?? i ?? "";
		return u.current = new e({
			...c,
			container: l.current,
			value: t,
			onChange: (e) => {
				d.current || f.current?.(e);
			}
		}), () => {
			u.current?.destroy(), u.current = null;
		};
	}, []), n.useEffect(() => {
		let e = u.current;
		!e || a === void 0 || e.getValue() !== a && (d.current = !0, e.setValue(a), d.current = !1);
	}, [a]), /* @__PURE__ */ r("div", {
		ref: l,
		"data-slot": "json-viewer",
		className: t("w-full", s)
	});
}
i.displayName = "JsonViewer";
//#endregion
export { i as JsonViewer };

//# sourceMappingURL=json-viewer.js.map