import { loadContentDeclarations } from "./loadContentDeclaration.mjs";
import { relative, resolve } from "node:path";
import { mkdir } from "node:fs/promises";

//#region ../@intlayer/cli/dist/esm/chokidar/dist/esm/loadDictionaries/loadLocalDictionaries.mjs
const loadLocalDictionaries = async (contentDeclarationsPaths, configuration) => {
	const { content } = configuration;
	const { dictionariesDir, baseDir } = content;
	if (typeof contentDeclarationsPaths === "string") contentDeclarationsPaths = [contentDeclarationsPaths];
	await mkdir(resolve(dictionariesDir), { recursive: true });
	const result = [];
	for await (const contentDeclarationPath of contentDeclarationsPaths) {
		const dictionary = await loadContentDeclarations([contentDeclarationPath], configuration);
		const relativeFilePath = relative(baseDir, contentDeclarationPath);
		const dictionaryWithPath = {
			...dictionary[0],
			filePath: relativeFilePath
		};
		result.push(dictionaryWithPath);
	}
	return result;
};

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