import { buildGateReport } from "./gate-report.js";
/**
 * Build the result and write it in the requested form.
 * @param checks - Every doctor check, already run
 * @param resolvedTarget - Absolute project root
 * @param options - Parsed command options
 * @param write - Output sink
 * @returns The result, for callers that consume it directly
 */
export async function renderDoctorResult(checks, resolvedTarget, options, write) {
    if (options.json !== true) {
        write(checks
            .map(check => `${check.status.toUpperCase()} ${check.name}: ${check.detail}`)
            .join("\n"));
        return { checks };
    }
    const result = {
        checks,
        gateReport: await buildGateReport({
            projectRoot: resolvedTarget,
            offline: options.offline === true,
        }),
    };
    write(JSON.stringify(result, null, 2));
    return result;
}
//# sourceMappingURL=doctor-render.js.map