/**
 * Consolidates multiple actuals sources with priority:
 *   explicit > WIP > git-derived
 *
 * Returns null when no actuals source has any data.
 */
export function consolidateActuals(specEstimation, explicitActuals, wipData, gitDerived) {
    if (explicitActuals) {
        return {
            ...explicitActuals,
            source: 'explicit',
            confidence: 'high',
        };
    }
    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 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