const require_getLocalizedContent = require('../deepTransformPlugins/getLocalizedContent.cjs');
const require_translation = require('../transpiler/translation/translation.cjs');
const require_orderDictionaries = require('./orderDictionaries.cjs');

//#region ../@intlayer/webpack/dist/esm/chokidar/dist/esm/core/dist/esm/dictionaryManipulator/normalizeDictionary.mjs
const normalizeDictionary = (dictionary, configuration) => {
	const { locales } = configuration.internationalization;
	const parsedDictionary = JSON.parse(JSON.stringify(dictionary));
	if (dictionary.locale) return {
		...dictionary,
		locale: void 0,
		content: require_translation.translation({ [dictionary.locale]: dictionary.content })
	};
	const perLocaleContent = locales.reduce((acc, locale) => {
		acc[locale] = require_getLocalizedContent.getPerLocaleDictionary(parsedDictionary, locale).content;
		return acc;
	}, {});
	return {
		...dictionary,
		content: require_translation.translation(perLocaleContent)
	};
};
const normalizeDictionaries = (dictionaries, configuration) => {
	return require_orderDictionaries.orderDictionaries(dictionaries, configuration).map((dictionary) => normalizeDictionary(dictionary, configuration));
};

//#endregion
exports.normalizeDictionaries = normalizeDictionaries;
//# sourceMappingURL=normalizeDictionary.cjs.map