"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class ReadOnlyArray extends Array {
    constructor(mutable) {
        super();
        return Object.freeze(mutable.slice());
    }
}
function setReadOnly(target, key, v, deep = true) {
    let value = v;
    if (deep && typeof value === 'object') {
        if (Array.isArray(value)) {
            value = new ReadOnlyArray(value);
        }
        else {
            Object.entries(value).forEach(([k, v]) => setReadOnly(value, k, v));
        }
    }
    return Object.defineProperty(target, key, {
        writable: false,
        get() {
            return value;
        },
        set() {
            console.error(`Can not modify readonly value "${key}"`);
        },
    });
}
exports.setReadOnly = setReadOnly;
//# sourceMappingURL=common.js.map