import GraphModelMigrationBasis from "./GraphModelMigrationBasis.js";
import WarpError from "../errors/WarpError.js";
/** Runtime-backed basis pair for a genesis replay equivalence proof. */
export default class GenesisEquivalenceComparisonBasis {
    legacyBasis;
    migratedBasis;
    constructor(fields) {
        const checkedFields = requireFields(fields);
        this.legacyBasis = requireBasis(checkedFields.legacyBasis, 'legacyBasis');
        this.migratedBasis = requireBasis(checkedFields.migratedBasis, 'migratedBasis');
        Object.freeze(this);
    }
    /** Returns a deterministic basis pair key. */
    toKey() {
        return `${this.legacyBasis.toKey()}\0${this.migratedBasis.toKey()}`;
    }
}
/** Validates the constructor envelope. */
function requireFields(fields) {
    if (fields === null || fields === undefined) {
        throw new WarpError('GenesisEquivalenceComparisonBasis fields must be provided', 'E_VALIDATION');
    }
    return fields;
}
/** Requires a migration basis instance. */
function requireBasis(basis, label) {
    if (!(basis instanceof GraphModelMigrationBasis)) {
        throw new WarpError(`${label} must be a GraphModelMigrationBasis`, 'E_VALIDATION');
    }
    return basis;
}
