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

//#region ../@intlayer/cli/dist/esm/core/dist/esm/deepTransformPlugins/getMissingLocalesContent.mjs
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
const checkMissingLocalesPlugin = (locales, onMissingLocale) => ({
	id: "check-missing-locales-plugin",
	canHandle: (node) => typeof node === "object" && node?.nodeType === require_nodeType.NodeType.Translation,
	transform: (node, props, deepTransformNode$1) => {
		for (const locale of locales) if (!node[require_nodeType.NodeType.Translation][locale]) onMissingLocale(locale);
		const translations = node[require_nodeType.NodeType.Translation];
		for (const key in translations) {
			const child = translations[key];
			deepTransformNode$1(child, {
				...props,
				children: child
			});
		}
		return node;
	}
});
/**
* Return the content of a node with only the translation plugin.
*
* @param node The node to transform.
* @param locales The locales to check for missing translations.
*/
const getMissingLocalesContent = (node, locales = require_built.built_default?.internationalization?.locales, nodeProps) => {
	const missingLocales = /* @__PURE__ */ new Set();
	const plugins = [checkMissingLocalesPlugin(locales, (locale) => missingLocales.add(locale)), ...nodeProps.plugins ?? []];
	require_deepTransform.deepTransformNode(node, {
		...nodeProps,
		plugins
	});
	return Array.from(missingLocales);
};
const getMissingLocalesContentFromDictionary = (dictionary, locales = require_built.built_default?.internationalization?.locales) => getMissingLocalesContent(dictionary.content, locales, {
	dictionaryKey: dictionary.key,
	keyPath: []
});

//#endregion
exports.getMissingLocalesContentFromDictionary = getMissingLocalesContentFromDictionary;
//# sourceMappingURL=getMissingLocalesContent.cjs.map