/**
 * Consolidates multiple actuals sources with priority:
 *   explicit > progress.md > WIP > git-derived
 *
 * Returns null when no actuals source has any data.
 */
export function consolidateActuals(specEstimation, explicitActuals, wipData, gitDerived, progressData) {
    if (explicitActuals) {
        return {
            ...explicitActuals,
            source: 'explicit',
            confidence: 'high',
        };
    }
    if (progressData) {
        return convertProgressToConsolidated(specEstimation, progressData);
    }
    if (wipData) {
        return convertWipToConsolidated(wipData);
    }
    if (gitDerived) {
        return convertGitDerivedToConsolidated(specEstimation, gitDerived);
    }
    return null;
}
function convertWipToConsolidated(wip) {
    return {
        devHours: 0,
        reviewHours: 0,
        tokensOpus: wip.tokensOpus,
        tokensSonnet: wip.tokensSonnet,
        apiCostUsd: wip.apiCostAccumulated,
        humanCostUsd: 0,
        totalCostUsd: wip.apiCostAccumulated,
        completedAt: wip.lastUpdated,
        notes: wip.notes,
        source: 'wip',
        confidence: 'medium',
    };
}
function convertProgressToConsolidated(specEstimation, progress) {
    const devHours = progress.devHours ?? 0;
    const reviewHours = progress.reviewHours ?? 0;
    const humanCostUsd = devHours * specEstimation.hourlyRate;
    const totalCostUsd = progress.totalCostUsd ?? humanCostUsd;
    return {
        devHours,
        reviewHours,
        tokensOpus: 0,
        tokensSonnet: 0,
        apiCostUsd: 0,
        humanCostUsd,
        totalCostUsd,
        completedAt: progress.completedAt ?? new Date().toISOString(),
        notes: `Derived from progress.md${progress.status ? ` (status: ${progress.status})` : ''}`,
        source: 'progress',
        confidence: 'medium',
    };
}
function convertGitDerivedToConsolidated(specEstimation, gitDerived) {
    const humanCostUsd = gitDerived.devHours * specEstimation.hourlyRate;
    return {
        devHours: gitDerived.devHours,
        reviewHours: gitDerived.reviewHours,
        tokensOpus: 0,
        tokensSonnet: 0,
        apiCostUsd: 0,
        humanCostUsd,
        totalCostUsd: humanCostUsd,
        completedAt: gitDerived.completedAt,
        notes: `Derived from ${gitDerived.commitCount} git commit(s), ${gitDerived.linesChanged} lines changed`,
        source: 'git-derived',
        confidence: 'low',
    };
}
//# sourceMappingURL=consolidator.js.map