import GenesisEquivalenceComparisonBasis from "./GenesisEquivalenceComparisonBasis.js";
import WarpError from "../errors/WarpError.js";
/** Runtime-backed summary for a genesis replay equivalence proof. */
export default class GenesisEquivalenceProofSummary {
    basis;
    legacyFactCount;
    migratedFactCount;
    mismatchCount;
    constructor(fields) {
        const checkedFields = requireFields(fields);
        this.basis = requireBasis(checkedFields.basis);
        this.legacyFactCount = requireCount(checkedFields.legacyFactCount, 'legacyFactCount');
        this.migratedFactCount = requireCount(checkedFields.migratedFactCount, 'migratedFactCount');
        this.mismatchCount = requireCount(checkedFields.mismatchCount, 'mismatchCount');
        Object.freeze(this);
    }
}
/** Validates the constructor envelope. */
function requireFields(fields) {
    if (fields === null || fields === undefined) {
        throw new WarpError('GenesisEquivalenceProofSummary fields must be provided', 'E_VALIDATION');
    }
    return fields;
}
/** Requires a comparison basis instance. */
function requireBasis(basis) {
    if (!(basis instanceof GenesisEquivalenceComparisonBasis)) {
        throw new WarpError('basis must be a GenesisEquivalenceComparisonBasis', 'E_VALIDATION');
    }
    return basis;
}
/** Validates a non-negative count. */
function requireCount(value, name) {
    if (!Number.isSafeInteger(value) || value < 0) {
        throw new WarpError(`${name} must be a non-negative safe integer`, 'E_VALIDATION');
    }
    return value;
}
