'use client';


import { SaveForm } from "../DictionaryFieldEditor/SaveForm/SaveForm.mjs";
import { NodeWrapper } from "./NodeWrapper/index.mjs";
import { createElement } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { useEditedContent, useFocusDictionary } from "@intlayer/editor-react";

//#region src/components/DictionaryEditor/DictionaryEditor.tsx
const DictionaryEditor = ({ dictionary, mode, onDelete,...props }) => {
	const { editedContent, addEditedContent } = useEditedContent();
	const { focusedContent, setFocusedContentKeyPath, setFocusedContent } = useFocusDictionary();
	const focusedKeyPath = focusedContent?.keyPath;
	return /* @__PURE__ */ jsxs("div", {
		className: "flex flex-1 flex-col justify-between gap-2",
		children: [/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ createElement(NodeWrapper, {
			...props,
			keyPath: [],
			dictionary,
			key: JSON.stringify((editedContent?.[dictionary.localId] ?? dictionary).content),
			editedContent: editedContent?.[dictionary.localId]?.content,
			focusedKeyPath,
			section: dictionary.content,
			onContentChange: (content) => {
				addEditedContent(dictionary.localId, content.newValue, content.keyPath);
			},
			onFocusKeyPath: setFocusedContentKeyPath
		}) }), /* @__PURE__ */ jsx(SaveForm, {
			dictionary,
			mode,
			className: "mb-4 flex-col",
			onDelete: () => {
				setFocusedContent(null);
				onDelete?.();
			}
		})]
	});
};

//#endregion
export { DictionaryEditor };
//# sourceMappingURL=DictionaryEditor.mjs.map