/**
 * Read-side version-vector view for public immutable snapshots.
 */
export default class SnapshotVersionVector {
    #entries;
    constructor(source) {
        this.#entries = new Map(source.entries());
        Object.freeze(this);
    }
    get(writerId) {
        return this.#entries.get(writerId);
    }
    has(writerId) {
        return this.#entries.has(writerId);
    }
    get size() {
        return this.#entries.size;
    }
    [Symbol.iterator]() {
        return this.#entries[Symbol.iterator]();
    }
    keys() {
        return this.#entries.keys();
    }
    values() {
        return this.#entries.values();
    }
    entries() {
        return this.#entries.entries();
    }
    descends(other) {
        for (const [writerId, counter] of other) {
            const thisCounter = this.#entries.get(writerId) ?? 0;
            if (thisCounter < counter) {
                return false;
            }
        }
        return true;
    }
    contains(dot) {
        const counter = this.#entries.get(dot.writerId) ?? 0;
        return dot.counter <= counter;
    }
    equals(other) {
        if (this.#entries.size !== other.size) {
            return false;
        }
        for (const [writerId, counter] of this.#entries) {
            if (other.get(writerId) !== counter) {
                return false;
            }
        }
        return true;
    }
}
