// Planu — Compliance evidence package builder (SPEC-402)
import { analyzeComplianceGaps } from './gap-analyzer.js';
export function buildEvidencePackage(framework, projectId, specs, auditEvents) {
    const gapAnalysis = analyzeComplianceGaps(framework, specs);
    const doneSpecs = specs.filter((s) => s.status === 'done');
    const approvalEvents = auditEvents.filter((e) => e.action === 'status:approved');
    const controlMatrix = gapAnalysis.coverage.map((c) => ({
        controlId: c.controlId,
        controlName: c.controlName,
        status: c.status,
        specIds: c.coveringSpecIds,
        evidence: c.coveringSpecIds.length > 0
            ? `Covered by ${c.coveringSpecIds.length} spec(s): ${c.coveringSpecIds.join(', ')}`
            : 'No specs found for this control',
    }));
    return {
        framework,
        projectId,
        generatedAt: new Date().toISOString(),
        summary: {
            totalSpecs: specs.length,
            doneSpecs: doneSpecs.length,
            approvalEvents: approvalEvents.length,
            complianceScore: gapAnalysis.score,
        },
        controlMatrix,
        changeManagementEvidence: approvalEvents.slice(-20).map((e) => ({
            timestamp: e.timestamp,
            specId: e.specId,
            actor: e.actor ?? 'unknown',
            action: e.action,
        })),
        gaps: gapAnalysis.recommendations,
    };
}
//# sourceMappingURL=evidence-builder.js.map