'use client';


import { ArrayWrapper } from "./ArrayWrapper.mjs";
import { ConditionWrapper } from "./ConditionWrapper.mjs";
import { EnumerationWrapper } from "./EnumerationWrapper.mjs";
import { StringWrapper } from "./StringWrapper.mjs";
import { FileWrapper } from "./FileWrapper.mjs";
import { InsertionWrapper } from "./InsertionWrapper.mjs";
import { MarkdownWrapper } from "./MarkdownWrapper.mjs";
import { NestedObjectWrapper } from "./NestedObjectWrapper.mjs";
import { TranslationWrapper } from "./TranslationWrapper.mjs";
import { memo, useMemo } from "react";
import { jsx } from "react/jsx-runtime";
import { getContentNodeByKeyPath, getNodeType } from "@intlayer/core";
import { useEditorLocale } from "@intlayer/editor-react";
import { NodeType } from "@intlayer/types";

//#region src/components/DictionaryEditor/NodeWrapper/index.tsx
const traceKeys = [
	"filePath",
	"id",
	"nodeType"
];
const NodeWrapper = memo((props) => {
	const currentLocale = useEditorLocale();
	const section = useMemo(() => {
		return getContentNodeByKeyPath(props.editedContent, props.keyPath, currentLocale) ?? props.section;
	}, [
		props.editedContent,
		props.keyPath,
		props.section
	]);
	const nodeType = useMemo(() => getNodeType(section), [section]);
	if (typeof section === "object") {
		if (nodeType === NodeType.ReactNode) return /* @__PURE__ */ jsx("span", {
			className: "text-neutral text-xs",
			children: "React node not editable"
		});
		if (nodeType === NodeType.Nested) return /* @__PURE__ */ jsx("div", {
			className: "ml-2 grid grid-cols-[auto,1fr] gap-2",
			children: "[Nested] Dictionary"
		});
		if (nodeType === NodeType.Markdown) return /* @__PURE__ */ jsx(MarkdownWrapper, {
			...props,
			section
		});
		if (nodeType === NodeType.Translation) return /* @__PURE__ */ jsx(TranslationWrapper, {
			...props,
			section
		});
		if (nodeType === NodeType.Enumeration) return /* @__PURE__ */ jsx(EnumerationWrapper, {
			...props,
			section
		});
		if (nodeType === NodeType.Condition) return /* @__PURE__ */ jsx(ConditionWrapper, {
			...props,
			section
		});
		if (nodeType === NodeType.Insertion) return /* @__PURE__ */ jsx(InsertionWrapper, {
			...props,
			section
		});
		if (nodeType === NodeType.Array) return /* @__PURE__ */ jsx(ArrayWrapper, {
			...props,
			section
		});
		if (nodeType === NodeType.File) return /* @__PURE__ */ jsx(FileWrapper, {
			...props,
			section
		});
		return /* @__PURE__ */ jsx(NestedObjectWrapper, {
			...props,
			section
		});
	}
	if (typeof section === "string") return /* @__PURE__ */ jsx(StringWrapper, {
		...props,
		section
	});
});

//#endregion
export { NodeWrapper, traceKeys };
//# sourceMappingURL=index.mjs.map