// engine/multi-teammate-review/report-formatter.ts — Report formatting utilities (SPEC-593)
// ---------------------------------------------------------------------------
// Constants
// ---------------------------------------------------------------------------
const SEVERITY_EMOJI = {
    critical: '🔴',
    suggestion: '🟡',
    nit: '🟢',
    'false-positive': '❌',
};
const SEVERITY_ORDER = ['critical', 'suggestion', 'nit', 'false-positive'];
// ---------------------------------------------------------------------------
// Markdown formatter
// ---------------------------------------------------------------------------
function buildHeader(input) {
    const parts = ['## Multi-Teammate Code Review Panel'];
    if (input.prNumber !== undefined) {
        parts.push(`\n**PR #${String(input.prNumber)}**`);
    }
    if (input.branch) {
        parts.push(` · branch: \`${input.branch}\``);
    }
    if (input.commitRange) {
        parts.push(` · range: \`${input.commitRange}\``);
    }
    return parts.join('');
}
function buildSummaryLine(decisions) {
    const counts = buildSeverityCounts(decisions);
    const parts = SEVERITY_ORDER.filter((s) => counts[s] > 0).map((s) => `${SEVERITY_EMOJI[s]} ${s}: ${String(counts[s])}`);
    return `**${String(decisions.length)} findings** · ${parts.join(' · ')}`;
}
function renderDecision(d) {
    const loc = d.line > 0 ? `${d.file}:${String(d.line)}` : d.file || '(repo-level)';
    const contributors = d.contributors.length > 0 ? ` _(${d.contributors.join(', ')})_` : '';
    const lines = [
        `#### ${SEVERITY_EMOJI[d.severity]} \`${loc}\`${contributors}`,
        '',
        `**${d.message}**`,
        '',
        `Recommendation: ${d.recommendation}`,
    ];
    if (d.justification) {
        lines.push('', `> ${d.justification}`);
    }
    return lines.join('\n');
}
export function formatAsMarkdown(decisions, input) {
    const sections = [buildHeader(input), '', buildSummaryLine(decisions), ''];
    if (decisions.length === 0) {
        sections.push('✅ No issues found. All 5 specialists passed.');
        return sections.join('\n');
    }
    for (const sev of SEVERITY_ORDER) {
        const group = decisions.filter((d) => d.severity === sev);
        if (group.length === 0) {
            continue;
        }
        const label = sev.charAt(0).toUpperCase() + sev.slice(1);
        sections.push(`### ${SEVERITY_EMOJI[sev]} ${label} (${String(group.length)})`);
        sections.push('');
        for (const d of group) {
            sections.push(renderDecision(d));
            sections.push('');
        }
    }
    sections.push('---');
    sections.push('_Reviewed by: Security · Correctness · Performance · Maintainability · Architecture specialists + Arbitrator_');
    return sections.join('\n');
}
// ---------------------------------------------------------------------------
// JSON formatter
// ---------------------------------------------------------------------------
function buildSeverityCounts(decisions) {
    const counts = {
        critical: 0,
        suggestion: 0,
        nit: 0,
        'false-positive': 0,
    };
    for (const d of decisions) {
        counts[d.severity]++;
    }
    return counts;
}
export function formatAsJson(decisions) {
    return {
        totalFindings: decisions.length,
        bySeverity: buildSeverityCounts(decisions),
        criticalFindings: decisions.filter((d) => d.severity === 'critical'),
        allFindings: decisions,
    };
}
//# sourceMappingURL=report-formatter.js.map