const require_nodeType = require('../types/dist/esm/nodeType.cjs');
const require_deepTransform = require('../interpreter/getContent/deepTransform.cjs');

//#region ../chokidar/dist/esm/core/dist/esm/deepTransformPlugins/getFilteredLocalesContent.mjs
const filterTranslationsPlugin = (locales) => ({
	id: "filter-translations-plugin",
	canHandle: (node) => typeof node === "object" && node?.nodeType === require_nodeType.NodeType.Translation,
	transform: (node, props, deepTransformNode$1) => {
		const translationMap = node.translation;
		const filteredTranslationMap = Object.fromEntries(Object.entries(translationMap).filter(([key]) => locales.includes(key)));
		return {
			...node,
			translation: deepTransformNode$1(filteredTranslationMap, {
				...props,
				keyPath: [...props.keyPath, {
					type: require_nodeType.NodeType.Object,
					key: require_nodeType.NodeType.Translation
				}]
			})
		};
	}
});
const getFilteredLocalesContent = (node, locales, nodeProps) => {
	const plugins = [filterTranslationsPlugin(Array.isArray(locales) ? locales : [locales]), ...nodeProps.plugins ?? []];
	return require_deepTransform.deepTransformNode(node, {
		...nodeProps,
		plugins
	});
};
const getFilteredLocalesDictionary = (dictionary, locale) => {
	const localesArray = Array.isArray(locale) ? locale : [locale];
	return {
		...dictionary,
		content: getFilteredLocalesContent(dictionary.content, localesArray, {
			dictionaryKey: dictionary.key,
			keyPath: []
		})
	};
};

//#endregion
exports.getFilteredLocalesDictionary = getFilteredLocalesDictionary;
//# sourceMappingURL=getFilteredLocalesContent.cjs.map