const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
const require_test_listMissingTranslations = require('./listMissingTranslations.cjs');
let __intlayer_chokidar = require("@intlayer/chokidar");
let __intlayer_config = require("@intlayer/config");

//#region src/test/index.ts
const testMissingTranslations = async (options) => {
	const config = (0, __intlayer_config.getConfiguration)(options?.configOptions);
	const { locales, requiredLocales } = config.internationalization;
	const appLogger = (0, __intlayer_config.getAppLogger)(config, { config: { prefix: "" } });
	if (options?.build === true) await (0, __intlayer_chokidar.prepareIntlayer)(config, { forceRun: true });
	else if (typeof options?.build === "undefined") await (0, __intlayer_chokidar.prepareIntlayer)(config);
	const result = require_test_listMissingTranslations.listMissingTranslations(options?.configOptions);
	const maxKeyColSize = result.missingTranslations.map((t) => ` - ${t.key}`).reduce((max, t) => Math.max(max, t.length), 0);
	const maxLocalesColSize = result.missingTranslations.map((t) => (0, __intlayer_chokidar.formatLocale)(t.locales, false)).reduce((max, t) => Math.max(max, t.length), 0);
	const formattedMissingTranslations = result.missingTranslations.map((translation) => [
		(0, __intlayer_config.colon)(` - ${(0, __intlayer_config.colorizeKey)(translation.key)}`, {
			colSize: maxKeyColSize,
			maxSize: 40
		}),
		" - ",
		(0, __intlayer_config.colon)((0, __intlayer_chokidar.formatLocale)(translation.locales, __intlayer_config.ANSIColors.RED), {
			colSize: maxLocalesColSize,
			maxSize: 40
		}),
		translation.filePath ? ` - ${(0, __intlayer_chokidar.formatPath)(translation.filePath)}` : "",
		translation.id ? " - remote" : ""
	].join(""));
	appLogger(`Missing translations:`, { level: "info" });
	formattedMissingTranslations.forEach((t) => {
		appLogger(t, { level: "info" });
	});
	appLogger(`Locales: ${(0, __intlayer_chokidar.formatLocale)(locales)}`);
	appLogger(`Required locales: ${(0, __intlayer_chokidar.formatLocale)(requiredLocales ?? locales)}`);
	appLogger(`Missing locales: ${result.missingLocales.length === 0 ? (0, __intlayer_config.colorize)("-", __intlayer_config.ANSIColors.GREEN) : (0, __intlayer_chokidar.formatLocale)(result.missingLocales, __intlayer_config.ANSIColors.RED)}`);
	appLogger(`Missing required locales: ${result.missingRequiredLocales.length === 0 ? (0, __intlayer_config.colorize)("-", __intlayer_config.ANSIColors.GREEN) : (0, __intlayer_chokidar.formatLocale)(result.missingRequiredLocales, __intlayer_config.ANSIColors.RED)}`);
	appLogger(`Total missing locales: ${(0, __intlayer_config.colorizeNumber)(result.missingLocales.length, {
		one: __intlayer_config.ANSIColors.RED,
		other: __intlayer_config.ANSIColors.RED,
		zero: __intlayer_config.ANSIColors.GREEN
	})}`);
	appLogger(`Total missing required locales: ${(0, __intlayer_config.colorizeNumber)(result.missingRequiredLocales.length, {
		one: __intlayer_config.ANSIColors.RED,
		other: __intlayer_config.ANSIColors.RED,
		zero: __intlayer_config.ANSIColors.GREEN
	})}`);
};

//#endregion
exports.listMissingTranslations = require_test_listMissingTranslations.listMissingTranslations;
exports.testMissingTranslations = testMissingTranslations;
//# sourceMappingURL=index.cjs.map