import { getPerLocaleDictionary } from "../deepTransformPlugins/getLocalizedContent.mjs";
import { translation } from "../transpiler/translation/translation.mjs";
import { orderDictionaries } from "./orderDictionaries.mjs";

//#region ../@intlayer/cli/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: translation({ [dictionary.locale]: dictionary.content })
	};
	const perLocaleContent = locales.reduce((acc, locale) => {
		acc[locale] = getPerLocaleDictionary(parsedDictionary, locale).content;
		return acc;
	}, {});
	return {
		...dictionary,
		content: translation(perLocaleContent)
	};
};
const normalizeDictionaries = (dictionaries, configuration) => {
	return orderDictionaries(dictionaries, configuration).map((dictionary) => normalizeDictionary(dictionary, configuration));
};

//#endregion
export { normalizeDictionaries };
//# sourceMappingURL=normalizeDictionary.mjs.map