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,IAAI,YAAY,EAAS,EAAM,QAAS,KAAK,MACrE,GAAI,KAAK,OAAO,OAAS,EAAc,CACnC,IAAI,EAAY,IAAI,WAAW,GAC/B,EAAU,IAAI,KAAK,QACnB,KAAK,OAAS,CAClB,CAGA,IAFA,IAAI,EAAY,GAAU,EACtB,EAAU,KAAO,EAAS,EACrB,EAAQ,EAAG,EAAQ,EAAM,OAAQ,IAOtC,GANI,EAAM,GACN,KAAK,OAAO,IAAc,EAG1B,KAAK,OAAO,KAAe,EAEf,IAAZ,EAAe,CAEf,IADA,GAAa,IACI,KAAK,OAAO,OACzB,MAEJ,EAAU,GACd,MAEI,IAAY,CAGxB,EAQA,EAAS,UAAU,QAAU,SAAU,EAAY,EAAO,QACxC,IAAV,IAAoB,EAAQ,QACpB,IAAR,IAAkB,EAA2B,EAArB,KAAK,OAAO,QAGxC,IAFA,IAAI,EAAY,GAAS,EACrB,EAAU,KAAO,EAAQ,EACpB,EAAW,EAAO,EAAW,EAAK,IACvC,KAAc,KAAK,OAAO,GAAa,GAAU,GACjC,IAAZ,GACA,GAAa,EACb,EAAU,KAGV,IAAY,CAGxB,EAMA,EAAS,UAAU,QAAU,WACzB,IAAK,IAAI,EAAI,EAAG,EAAI,KAAK,OAAO,OAAQ,IACpC,GAAuB,IAAnB,KAAK,OAAO,GACZ,OAAO,EAGf,OAAO,CACX,EACO,CACX,CAvI6B,GAwI7B,QAAQ,QAAU","file":"/npm/bitfield@4.2.0/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/bitfield@4.2.0/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * Converts a number of bits to a number of bytes.\n *\n * @param numberOfBits The number of bits to convert.\n * @returns The number of bytes that are needed to store the given number of bits.\n */\nfunction bitsToBytes(numberOfBits) {\n    return (numberOfBits >> 3) + Number(numberOfBits % 8 !== 0);\n}\nvar BitField = /** @class */ (function () {\n    /**\n     * Constructs a BitField.\n     *\n     * @param data Either a number representing the maximum number of supported bits, or a Uint8Array.\n     * @param opts Options for the bitfield.\n     */\n    function BitField(data, options) {\n        if (data === void 0) { data = 0; }\n        var grow = options === null || options === void 0 ? void 0 : options.grow;\n        this.grow = grow\n            ? Number.isFinite(grow)\n                ? bitsToBytes(grow)\n                : grow\n            : 0;\n        this.buffer =\n            typeof data === \"number\" ? new Uint8Array(bitsToBytes(data)) : data;\n    }\n    Object.defineProperty(BitField.prototype, \"length\", {\n        /** The number of bits in the bitfield. */\n        get: function () {\n            return this.buffer.length << 3;\n        },\n        enumerable: false,\n        configurable: true\n    });\n    /**\n     * Get a particular bit.\n     *\n     * @param bitIndex Bit index to retrieve.\n     * @returns A boolean indicating whether the `i`th bit is set.\n     */\n    BitField.prototype.get = function (bitIndex) {\n        var byteIndex = bitIndex >> 3;\n        return (byteIndex < this.buffer.length &&\n            !!(this.buffer[byteIndex] & (128 >> bitIndex % 8)));\n    };\n    /**\n     * Set a particular bit.\n     *\n     * Will grow the underlying array if the bit is out of bounds and the `grow` option is set.\n     *\n     * @param bitIndex Bit index to set.\n     * @param value Value to set the bit to. Defaults to `true`.\n     */\n    BitField.prototype.set = function (bitIndex, value) {\n        if (value === void 0) { value = true; }\n        var byteIndex = bitIndex >> 3;\n        if (value) {\n            if (byteIndex >= this.buffer.length) {\n                var newLength = Math.max(byteIndex + 1, Math.min(2 * this.buffer.length, this.grow));\n                if (newLength <= this.grow) {\n                    var newBuffer = new Uint8Array(newLength);\n                    newBuffer.set(this.buffer);\n                    this.buffer = newBuffer;\n                }\n            }\n            this.buffer[byteIndex] |= 128 >> bitIndex % 8;\n        }\n        else if (byteIndex < this.buffer.length) {\n            this.buffer[byteIndex] &= ~(128 >> bitIndex % 8);\n        }\n    };\n    /**\n     * Sets a value or an array of values.\n     *\n     * @param array An array of booleans to set.\n     * @param offset The bit offset at which the values are to be written.\n     */\n    BitField.prototype.setAll = function (array, offset) {\n        if (offset === void 0) { offset = 0; }\n        var targetLength = Math.min(bitsToBytes(offset + array.length), this.grow);\n        if (this.buffer.length < targetLength) {\n            var newBuffer = new Uint8Array(targetLength);\n            newBuffer.set(this.buffer);\n            this.buffer = newBuffer;\n        }\n        var byteIndex = offset >> 3;\n        var bitMask = 128 >> offset % 8;\n        for (var index = 0; index < array.length; index++) {\n            if (array[index]) {\n                this.buffer[byteIndex] |= bitMask;\n            }\n            else {\n                this.buffer[byteIndex] &= ~bitMask;\n            }\n            if (bitMask === 1) {\n                byteIndex += 1;\n                if (byteIndex >= this.buffer.length) {\n                    break;\n                }\n                bitMask = 128;\n            }\n            else {\n                bitMask >>= 1;\n            }\n        }\n    };\n    /**\n     * Loop through the bits in the bitfield.\n     *\n     * @param callbackfn Function to be called with the bit value and index.\n     * @param start Index of the first bit to look at.\n     * @param end Index of the first bit that should no longer be considered.\n     */\n    BitField.prototype.forEach = function (callbackfn, start, end) {\n        if (start === void 0) { start = 0; }\n        if (end === void 0) { end = this.buffer.length * 8; }\n        var byteIndex = start >> 3;\n        var bitMask = 128 >> start % 8;\n        for (var bitIndex = start; bitIndex < end; bitIndex++) {\n            callbackfn(!!(this.buffer[byteIndex] & bitMask), bitIndex);\n            if (bitMask === 1) {\n                byteIndex += 1;\n                bitMask = 128;\n            }\n            else {\n                bitMask >>= 1;\n            }\n        }\n    };\n    /**\n     * Check if all bits in the Bitfield are unset.\n     *\n     * @returns A boolean indicating whether all bits are unset.\n     */\n    BitField.prototype.isEmpty = function () {\n        for (var i = 0; i < this.buffer.length; i++) {\n            if (this.buffer[i] !== 0) {\n                return false;\n            }\n        }\n        return true;\n    };\n    return BitField;\n}());\nexports.default = BitField;\n"]}