"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildEvalRouter = buildEvalRouter;
const express_1 = require("express");
const http_1 = require("../utils/http");
function buildEvalRouter(services) {
    const router = (0, express_1.Router)();
    router.post("/api/eval/run", async (req, res, next) => {
        try {
            const body = (req.body ?? {});
            const report = await services.evalService.run({
                normalizeConfig: (body.normalizeConfig ?? {}),
                caseIds: Array.isArray(body.caseIds) ? body.caseIds : undefined,
                useMock: Boolean(body.useMock),
                mode: body.mode ?? "standard",
                caseSetFile: typeof body.caseSetFile === "string" ? body.caseSetFile : undefined,
                rawQuestions: typeof body.rawQuestions === "string" ? body.rawQuestions : undefined,
                evalTarget: body.eval_target ?? "normalizer",
                compareWithReportFile: typeof body.compare_with_report_file === "string"
                    ? body.compare_with_report_file
                    : typeof body.comparisonBaselineReportFile === "string"
                        ? body.comparisonBaselineReportFile
                        : undefined
            });
            (0, http_1.ok)(res, {
                ok: true,
                report
            });
        }
        catch (error) {
            next(error);
        }
    });
    return router;
}
