const require_logger = require('../../../../../../config/dist/esm/logger.cjs');
const require_formatter = require('./utils/formatter.cjs');
const require_buildIntlayerDictionary = require('./buildIntlayerDictionary/buildIntlayerDictionary.cjs');
const require_createDictionaryEntryPoint = require('./createDictionaryEntryPoint/createDictionaryEntryPoint.cjs');
const require_createModuleAugmentation = require('./createType/createModuleAugmentation.cjs');
const require_createType = require('./createType/createType.cjs');
const require_loadLocalDictionaries = require('./loadDictionaries/loadLocalDictionaries.cjs');

//#region ../@intlayer/webpack/dist/esm/chokidar/dist/esm/handleAdditionalContentDeclarationFile.mjs
const handleAdditionalContentDeclarationFile = async (filePath, config) => {
	const appLogger = require_logger.getAppLogger(config);
	appLogger(`Additional file detected: ${require_formatter.formatPath(filePath)}`, { isVerbose: true });
	const dictionariesOutput = await require_buildIntlayerDictionary.buildDictionary(await require_loadLocalDictionaries.loadLocalDictionaries(filePath, config), config);
	await require_createType.createTypes(Object.values(dictionariesOutput?.mergedDictionaries ?? {}).map((dictionary) => dictionary.dictionaryPath), config);
	await require_createDictionaryEntryPoint.createDictionaryEntryPoint(config);
	appLogger("Dictionaries built", { isVerbose: true });
	require_createModuleAugmentation.createModuleAugmentation(config);
	appLogger("Module augmentation built", { isVerbose: true });
	for await (const plugin of config.plugins ?? []) {
		const { unmergedDictionaries, mergedDictionaries } = dictionariesOutput;
		await plugin.afterBuild?.({
			dictionaries: {
				unmergedDictionaries,
				mergedDictionaries
			},
			configuration: config
		});
	}
};

//#endregion
exports.handleAdditionalContentDeclarationFile = handleAdditionalContentDeclarationFile;
//# sourceMappingURL=handleAdditionalContentDeclarationFile.cjs.map