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

//#region ../chokidar/dist/esm/core/dist/esm/interpreter/getContent/plugins.mjs
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
const translationPlugin = (locale, fallback) => ({
	id: "translation-plugin",
	canHandle: (node) => typeof node === "object" && node?.nodeType === require_nodeType.NodeType.Translation,
	transform: (node, props, deepTransformNode) => {
		const result = structuredClone(node[require_nodeType.NodeType.Translation]);
		for (const key in result) {
			const childProps = {
				...props,
				children: result[key],
				keyPath: [...props.keyPath, {
					type: require_nodeType.NodeType.Translation,
					key
				}]
			};
			result[key] = deepTransformNode(result[key], childProps);
		}
		return require_getTranslation.getTranslation(result, locale, fallback);
	}
});

//#endregion
exports.translationPlugin = translationPlugin;
//# sourceMappingURL=plugins.cjs.map