import WarpError from "../errors/WarpError.js";
const RECEIPT_FAMILY_ID = 'receipt-family';
const SETTLEMENT_FAMILY_ID = 'settlement-family';
const NEIGHBORHOOD_CORE_FAMILY_ID = 'neighborhood-core-family';
const RUNTIME_BOUNDARY_FAMILY_ID = 'runtime-boundary-family';
export const CONTINUUM_FAMILY_IDS = Object.freeze([
    RECEIPT_FAMILY_ID,
    SETTLEMENT_FAMILY_ID,
    NEIGHBORHOOD_CORE_FAMILY_ID,
    RUNTIME_BOUNDARY_FAMILY_ID,
]);
/** Runtime-backed identifier for a Continuum-owned contract family. */
export default class ContinuumFamilyId {
    value;
    constructor(value) {
        this.value = requireContinuumFamilyId(value);
        Object.freeze(this);
    }
    /** Returns true when both ids name the same Continuum family. */
    equals(other) {
        return this.value === other.value;
    }
    /** Returns the stable family id string. */
    toString() {
        return this.value;
    }
}
/** Validates a raw family id string. */
export function requireContinuumFamilyId(value) {
    if (typeof value !== 'string') {
        throw new WarpError(`Continuum family id must be one of: ${CONTINUUM_FAMILY_IDS.join(', ')}`, 'E_VALIDATION');
    }
    const valid = CONTINUUM_FAMILY_IDS.find((candidate) => candidate === value);
    if (valid === undefined) {
        throw new WarpError(`Continuum family id must be one of: ${CONTINUUM_FAMILY_IDS.join(', ')}`, 'E_VALIDATION');
    }
    return valid;
}
