/**
 * A {@link ReadonlyMap} that cannot be modified after instantiation.
 * The implementation uses an inner map hidden via a private field, and the
 * immutability guarantee relies on it being impossible to get a reference
 * to this map.
 */ function _check_private_redeclaration(obj, privateCollection) {
    if (privateCollection.has(obj)) {
        throw new TypeError("Cannot initialize the same private elements twice on an object");
    }
}
function _class_apply_descriptor_get(receiver, descriptor) {
    if (descriptor.get) {
        return descriptor.get.call(receiver);
    }
    return descriptor.value;
}
function _class_apply_descriptor_set(receiver, descriptor, value) {
    if (descriptor.set) {
        descriptor.set.call(receiver, value);
    } else {
        if (!descriptor.writable) {
            throw new TypeError("attempted to set read only private field");
        }
        descriptor.value = value;
    }
}
function _class_extract_field_descriptor(receiver, privateMap, action) {
    if (!privateMap.has(receiver)) {
        throw new TypeError("attempted to " + action + " private field on non-instance");
    }
    return privateMap.get(receiver);
}
function _class_private_field_get(receiver, privateMap) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "get");
    return _class_apply_descriptor_get(receiver, descriptor);
}
function _class_private_field_init(obj, privateMap, value) {
    _check_private_redeclaration(obj, privateMap);
    privateMap.set(obj, value);
}
function _class_private_field_set(receiver, privateMap, value) {
    var descriptor = _class_extract_field_descriptor(receiver, privateMap, "set");
    _class_apply_descriptor_set(receiver, descriptor, value);
    return value;
}
var _map = /*#__PURE__*/ new WeakMap();
let _Symbol_iterator = Symbol.iterator;
class FrozenMap {
    get size() {
        return _class_private_field_get(this, _map).size;
    }
    [_Symbol_iterator]() {
        return _class_private_field_get(this, _map)[Symbol.iterator]();
    }
    entries() {
        return _class_private_field_get(this, _map).entries();
    }
    forEach(callbackfn, thisArg) {
        // We have to wrap the specified callback in order to prevent it from
        // receiving a reference to the inner map.
        return _class_private_field_get(this, _map).forEach((value, key, _map)=>callbackfn.call(thisArg, value, key, this));
    }
    get(key) {
        return _class_private_field_get(this, _map).get(key);
    }
    has(key) {
        return _class_private_field_get(this, _map).has(key);
    }
    keys() {
        return _class_private_field_get(this, _map).keys();
    }
    values() {
        return _class_private_field_get(this, _map).values();
    }
    toString() {
        return `FrozenMap(${this.size}) {${this.size > 0 ? ` ${[
            ...this.entries()
        ].map(([key, value])=>`${String(key)} => ${String(value)}`).join(', ')} ` : ''}}`;
    }
    constructor(entries){
        _class_private_field_init(this, _map, {
            writable: true,
            value: void 0
        });
        _class_private_field_set(this, _map, new Map(entries));
        Object.freeze(this);
    }
}
var _set = /*#__PURE__*/ new WeakMap();
let _Symbol_iterator1 = Symbol.iterator;
/**
 * A {@link ReadonlySet} that cannot be modified after instantiation.
 * The implementation uses an inner set hidden via a private field, and the
 * immutability guarantee relies on it being impossible to get a reference
 * to this set.
 */ class FrozenSet {
    get size() {
        return _class_private_field_get(this, _set).size;
    }
    [_Symbol_iterator1]() {
        return _class_private_field_get(this, _set)[Symbol.iterator]();
    }
    entries() {
        return _class_private_field_get(this, _set).entries();
    }
    forEach(callbackfn, thisArg) {
        // We have to wrap the specified callback in order to prevent it from
        // receiving a reference to the inner set.
        return _class_private_field_get(this, _set).forEach((value, value2, _set)=>callbackfn.call(thisArg, value, value2, this));
    }
    has(value) {
        return _class_private_field_get(this, _set).has(value);
    }
    keys() {
        return _class_private_field_get(this, _set).keys();
    }
    values() {
        return _class_private_field_get(this, _set).values();
    }
    toString() {
        return `FrozenSet(${this.size}) {${this.size > 0 ? ` ${[
            ...this.values()
        ].map((member)=>String(member)).join(', ')} ` : ''}}`;
    }
    constructor(values){
        _class_private_field_init(this, _set, {
            writable: true,
            value: void 0
        });
        _class_private_field_set(this, _set, new Set(values));
        Object.freeze(this);
    }
}
Object.freeze(FrozenMap);
Object.freeze(FrozenMap.prototype);
Object.freeze(FrozenSet);
Object.freeze(FrozenSet.prototype);
export { FrozenMap, FrozenSet };

//# sourceMappingURL=collections.js.map