import { NodeType } from "../types/dist/esm/nodeType.mjs";

//#region ../react-intlayer/dist/esm/@intlayer/editor-react/dist/esm/core/dist/esm/dictionaryManipulator/getContentNodeByKeyPath.mjs
const getContentNodeByKeyPath = (dictionaryContent, keyPath, fallbackLocale) => {
	let currentValue = structuredClone(dictionaryContent);
	for (const keyObj of keyPath) {
		if (fallbackLocale && currentValue?.nodeType === NodeType.Translation) currentValue = currentValue?.[NodeType.Translation]?.[fallbackLocale];
		if (keyObj.type === NodeType.Object || keyObj.type === NodeType.Array) currentValue = currentValue?.[keyObj.key];
		if (keyObj.type === NodeType.Translation || keyObj.type === NodeType.Condition || keyObj.type === NodeType.Enumeration) currentValue = currentValue?.[keyObj.type]?.[keyObj.key];
		if (keyObj.type === NodeType.Markdown || keyObj.type === NodeType.Insertion || keyObj.type === NodeType.File) currentValue = currentValue?.[keyObj.type];
	}
	return currentValue;
};

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