const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
const require_logger_index = require('../../../logger/index.cjs');
const require__utils_asset = require('../../../_virtual/_utils_asset.cjs');
const require_utils_extractJSON = require('../../extractJSON.cjs');
let ai = require("ai");
ai = require_rolldown_runtime.__toESM(ai);

//#region src/utils/AI/auditDictionaryMetadata/index.ts
const CHAT_GPT_PROMPT = require__utils_asset.readAsset("./PROMPT.md");
const aiDefaultOptions = {};
/**
* Audits a content declaration file by constructing a prompt for AI models.
* The prompt includes details about the project's locales, file paths of content declarations,
* and requests for identifying issues or inconsistencies.
*/
const auditDictionaryMetadata = async ({ tags, fileContent, applicationContext, aiConfig }) => {
	const prompt = CHAT_GPT_PROMPT.replace("{{tags}}", `${JSON.stringify(tags.map(({ key, description }) => `- ${key}: ${description}`).join("\n\n"), null, 2)}`).replace("{{contentDeclaration}}", fileContent).replace("{{applicationContext}}", applicationContext ?? "");
	if (!aiConfig) {
		require_logger_index.logger.error("Failed to configure AI model");
		return;
	}
	const { text: newContent, usage } = await (0, ai.generateText)({
		...aiConfig,
		messages: [{
			role: "system",
			content: prompt
		}]
	});
	require_logger_index.logger.info(`${usage?.totalTokens ?? 0} tokens used in the request`);
	return {
		fileContent: require_utils_extractJSON.extractJson(newContent),
		tokenUsed: usage?.totalTokens ?? 0
	};
};

//#endregion
exports.aiDefaultOptions = aiDefaultOptions;
exports.auditDictionaryMetadata = auditDictionaryMetadata;
//# sourceMappingURL=index.cjs.map