/**
 * Ordered provenance entries carried by a boundary transition.
 *
 * This is a domain value: it names the replay-sufficient patch sequence
 * without claiming anything about wire shape.
 */
import WarpError from "../../errors/WarpError.js";
function copyPatchEntry(entry) {
    return Object.freeze({
        patch: entry.patch,
        sha: entry.sha,
    });
}
export default class BoundaryTransitionProvenance {
    #entries;
    constructor(entries = []) {
        if (!Array.isArray(entries)) {
            throw new WarpError('BoundaryTransitionProvenance requires an array of patch entries', 'E_BOUNDARY_TRANSITION_PROVENANCE_INVALID');
        }
        this.#entries = Object.freeze(entries.map(copyPatchEntry));
        Object.freeze(this);
    }
    static identity() {
        return new BoundaryTransitionProvenance([]);
    }
    get length() {
        return this.#entries.length;
    }
    entries() {
        return this.#entries.map(copyPatchEntry);
    }
    at(index) {
        const entry = this.#entries.at(index);
        return entry === undefined ? undefined : copyPatchEntry(entry);
    }
    [Symbol.iterator]() {
        return this.entries()[Symbol.iterator]();
    }
}
export { BoundaryTransitionProvenance };
