import { formatPath } from "@intlayer/chokidar";
import { colon, colorizeKey, colorizeNumber, getAppLogger, getConfiguration } from "@intlayer/config";
import { relative } from "node:path";
import { getUnmergedDictionaries } from "@intlayer/unmerged-dictionaries-entry";

//#region src/listContentDeclaration.ts
const listContentDeclarationRows = (options) => {
	const config = getConfiguration(options?.configOptions);
	const unmergedDictionariesRecord = getUnmergedDictionaries(config);
	return Object.values(unmergedDictionariesRecord).flat().map((dictionary) => ({
		key: dictionary.key ?? "",
		path: relative(config.content.baseDir, dictionary.filePath ?? "Remote")
	}));
};
const listContentDeclaration = (options) => {
	const appLogger = getAppLogger(getConfiguration(options?.configOptions), { config: { prefix: "" } });
	const rows = listContentDeclarationRows(options);
	const lines = rows.map((r) => [
		colon(` - ${colorizeKey(r.key)}`, {
			colSize: rows.map((r$1) => r$1.key.length),
			maxSize: 60
		}),
		" - ",
		formatPath(r.path)
	].join(""));
	appLogger(`Content declaration files:`);
	lines.forEach((l) => {
		appLogger(l, { level: "info" });
	});
	appLogger(`Total content declaration files: ${colorizeNumber(rows.length)}`);
};

//#endregion
export { listContentDeclaration, listContentDeclarationRows };
//# sourceMappingURL=listContentDeclaration.mjs.map