const require_nodeType = require('../types/dist/esm/nodeType.cjs');

//#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 === require_nodeType.NodeType.Translation) currentValue = currentValue?.[require_nodeType.NodeType.Translation]?.[fallbackLocale];
		if (keyObj.type === require_nodeType.NodeType.Object || keyObj.type === require_nodeType.NodeType.Array) currentValue = currentValue?.[keyObj.key];
		if (keyObj.type === require_nodeType.NodeType.Translation || keyObj.type === require_nodeType.NodeType.Condition || keyObj.type === require_nodeType.NodeType.Enumeration) currentValue = currentValue?.[keyObj.type]?.[keyObj.key];
		if (keyObj.type === require_nodeType.NodeType.Markdown || keyObj.type === require_nodeType.NodeType.Insertion || keyObj.type === require_nodeType.NodeType.File) currentValue = currentValue?.[keyObj.type];
	}
	return currentValue;
};

//#endregion
exports.getContentNodeByKeyPath = getContentNodeByKeyPath;
//# sourceMappingURL=getContentNodeByKeyPath.cjs.map