{“ast”:null,“code”:“'use strict';nnvar zlib_inflate = require('./zlib/inflate');nnvar utils = require('./utils/common');nnvar strings = require('./utils/strings');nnvar c = require('./zlib/constants');nnvar msg = require('./zlib/messages');nnvar ZStream = require('./zlib/zstream');nnvar GZheader = require('./zlib/gzheader');nnvar toString = Object.prototype.toString;n/**n * class Inflaten *n * Generic JS-style wrapper for zlib calls. If you don't needn * streaming behaviour - use more simple functions: [[inflate]]n * and [[inflateRaw]].n **/nn/* internaln * inflate.chunks -> Arrayn *n * Chunks of output data, if [[Inflate#onData]] not overridden.n **/nn/**n * Inflate.result -> Uint8Array|Array|Stringn *n * Uncompressed result, generated by default [[Inflate#onData]]n * and [[Inflate#onEnd]] handlers. Filled after you push last chunkn * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if youn * push a chunk with explicit flush (call [[Inflate#push]] withn * `Z_SYNC_FLUSH` param).n **/nn/**n * Inflate.err -> Numbern *n * Error code after inflate finished. 0 (Z_OK) on success.n * Should be checked if broken data possible.n **/nn/**n * Inflate.msg -> Stringn *n * Error message, if [[Inflate.err]] != 0n **/nn/**n * new Inflate(options)n * - options (Object
): zlib inflate options.n *n * Creates new inflator instance with specified params. Throws exceptionn * on bad params. Supported options:n *n * - `windowBits`n * - `dictionary`n *n * [zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)n * for more information on these.n *n * Additional options, for internal needs:n *n * - `chunkSize` - size of generated data chunks (16K by default)n * - `raw` (Boolean) - do raw inflaten * - `to` (String) - if equal to 'string', then result will be convertedn * from utf8 to utf16 (javascript) string. When string output requested,n * chunk length can differ from `chunkSize`, depending on content.n *n * By default, when no options set, autodetect deflate/gzip data format vian * wrapper header.n *n * ##### Example:n *n * “`javascriptn * var pako = require('pako')n * , chunk1 = Uint8Array()n * , chunk2 = Uint8Array();n *n * var inflate = new pako.Inflate({ level: 3});n *n * inflate.push(chunk1, false);n * inflate.push(chunk2, true); // true -> last chunkn *n * if (inflate.err) { throw new Error(inflate.err); }n *n * console.log(inflate.result);n * “`n **/nnfunction Inflate(options) {n if (!(this instanceof Inflate)) return new Inflate(options);n this.options = utils.assign({n chunkSize: 16384,n windowBits: 0,n to: ''n }, options || {});n var opt = this.options; // Force window size for `raw` data, if not set directly,n // because we have no header for autodetect.nn if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {n opt.windowBits = -opt.windowBits;nn if (opt.windowBits === 0) {n opt.windowBits = -15;n }n } // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflatennn if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {n opt.windowBits += 32;n } // Gzip header has no info about windows size, we can do autodetect onlyn // for deflate. So, if window size not set, force it to max when gzip possiblennn if (opt.windowBits > 15 && opt.windowBits < 48) {n // bit 3 (16) -> gzipped datan // bit 4 (32) -> autodetect gzip/deflaten if ((opt.windowBits & 15) === 0) {n opt.windowBits |= 15;n }n }nn this.err = 0; // error code, if happens (0 = Z_OK)nn this.msg = ''; // error messagenn this.ended = false; // used to avoid multiple onEnd() callsnn this.chunks = []; // chunks of compressed datann this.strm = new ZStream();n this.strm.avail_out = 0;n var status = zlib_inflate.inflateInit2(this.strm, opt.windowBits);nn if (status !== c.Z_OK) {n throw new Error(msg);n }nn this.header = new GZheader();n zlib_inflate.inflateGetHeader(this.strm, this.header); // Setup dictionarynn if (opt.dictionary) {n // Convert data if neededn if (typeof opt.dictionary === 'string') {n opt.dictionary = strings.string2buf(opt.dictionary);n } else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {n opt.dictionary = new Uint8Array(opt.dictionary);n }nn if (opt.raw) {n //In raw mode we need to set the dictionary earlyn status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);nn if (status !== c.Z_OK) {n throw new Error(msg);n }n }n }n}n/**n * Inflate#push(data[, mode]) -> Booleann * - data (Uint8Array|Array|ArrayBuffer|String): input datan * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` means Z_FINISH.n *n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls withn * new output chunks. Returns `true` on success. The last data block must haven * mode Z_FINISH (or `true`). That will flush internal pending buffers and calln * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) youn * can use mode Z_SYNC_FLUSH, keeping the decompression context.n *n * On fail call [[Inflate#onEnd]] with error code and return false.n *n * We strongly recommend to use `Uint8Array` on input for best speed (outputn * format is detected automatically). Also, don't skip last param and alwaysn * use the same type in your code (boolean or number). That will improve JS speed.n *n * For regular `Array`-s make sure all elements are [0..255].n *n * ##### Examplen *n * “`javascriptn * push(chunk, false); // push one of data chunksn * …n * push(chunk, true); // push last chunkn * “`n **/nnnInflate.prototype.push = function (data, mode) {n var strm = this.strm;n var chunkSize = this.options.chunkSize;n var dictionary = this.options.dictionary;nn var status, _mode;nn var next_out_utf8, tail, utf8str; // Flag to properly process Z_BUF_ERROR on testing inflate calln // when we check that all output data was flushed.nn var allowBufError = false;nn if (this.ended) {n return false;n }nn _mode = mode === ~~mode ? mode : mode === true ? c.Z_FINISH : c.Z_NO_FLUSH; // Convert data if needednn if (typeof data === 'string') {n // Only binary strings can be decompressed on practicen strm.input = strings.binstring2buf(data);n } else if (toString.call(data) === '[object ArrayBuffer]') {n strm.input = new Uint8Array(data);n } else {n strm.input = data;n }nn strm.next_in = 0;n strm.avail_in = strm.input.length;nn do {n if (strm.avail_out === 0) {n strm.output = new utils.Buf8(chunkSize);n strm.next_out = 0;n strm.avail_out = chunkSize;n }nn status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH);n /* no bad return value */nn if (status === c.Z_NEED_DICT && dictionary) {n status = zlib_inflate.inflateSetDictionary(this.strm, dictionary);n }nn if (status === c.Z_BUF_ERROR && allowBufError === true) {n status = c.Z_OK;n allowBufError = false;n }nn if (status !== c.Z_STREAM_END && status !== c.Z_OK) {n this.onEnd(status);n this.ended = true;n return false;n }nn if (strm.next_out) {n if (strm.avail_out === 0 || status === c.Z_STREAM_END || strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH)) {n if (this.options.to === 'string') {n next_out_utf8 = strings.utf8border(strm.output, strm.next_out);n tail = strm.next_out - next_out_utf8;n utf8str = strings.buf2string(strm.output, next_out_utf8); // move tailnn strm.next_out = tail;n strm.avail_out = chunkSize - tail;nn if (tail) {n utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0);n }nn this.onData(utf8str);n } else {n this.onData(utils.shrinkBuf(strm.output, strm.next_out));n }n }n } // When no more input data, we should check that internal inflate buffersn // are flushed. The only way to do it when avail_out = 0 - run one moren // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.n // Here we set flag to process this error properly.n //n // NOTE. Deflate does not return error in this case and does not needs suchn // logic.nnn if (strm.avail_in === 0 && strm.avail_out === 0) {n allowBufError = true;n }n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);nn if (status === c.Z_STREAM_END) {n _mode = c.Z_FINISH;n } // Finalize on the last chunk.nnn if (_mode === c.Z_FINISH) {n status = zlib_inflate.inflateEnd(this.strm);n this.onEnd(status);n this.ended = true;n return status === c.Z_OK;n } // callback interim results if Z_SYNC_FLUSH.nnn if (_mode === c.Z_SYNC_FLUSH) {n this.onEnd(c.Z_OK);n strm.avail_out = 0;n return true;n }nn return true;n};n/**n * Inflate#onData(chunk) -> Voidn * - chunk (Uint8Array|Array|String): output data. Type
of array dependsn * on js engine support. When string output requested, each chunkn * will be string.n *n * By default, stores data blocks in `chunks[]` property and gluen * those in `onEnd`. Override this handler, if you need another behaviour.n **/nnnInflate.prototype.onData = function (chunk) {n this.chunks.push(chunk);n};n/**n * Inflate#onEnd(status) -> Voidn * - status (Number
): inflate status. 0 (Z_OK) on success,n * other if not.n *n * Called either after you tell inflate that the input stream isn * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)n * or if an error happened. By default - join collected chunks,n * free memory and fill `results` / `err` properties.n **/nnnInflate.prototype.onEnd = function (status) {n // On success - joinn if (status === c.Z_OK) {n if (this.options.to === 'string') {n // Glue & convert here, until we teach pako to sendn // utf8 aligned strings to onDatan this.result = this.chunks.join('');n } else {n this.result = utils.flattenChunks(this.chunks);n }n }nn this.chunks = [];n this.err = status;n this.msg = this.strm.msg;n};n/**n * inflate(data[, options]) -> Uint8Array|Array|Stringn * - data (Uint8Array|Array|String): input data to decompress.n * - options (Object
): zlib inflate options.n *n * Decompress `data` with inflate/ungzip and `options`. Autodetectn * format via wrapper header by default. That's why we don't providen * separate `ungzip` method.n *n * Supported options are:n *n * - windowBitsn *n * [zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)n * for more information.n *n * Sugar (options):n *n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specifyn * negative windowBits implicitly.n * - `to` (String) - if equal to 'string', then result will be convertedn * from utf8 to utf16 (javascript) string. When string output requested,n * chunk length can differ from `chunkSize`, depending on content.n *n *n * ##### Example:n *n * “`javascriptn * var pako = require('pako')n * , input = pako.deflate()n * , output;n *n * try {n * output = pako.inflate(input);n * } catch (err)n * console.log(err);n * }n * “`n **/nnnfunction inflate(input, options) {n var inflator = new Inflate(options);n inflator.push(input, true); // That will never happens, if you don't cheat with options :)nn if (inflator.err) {n throw inflator.msg || msg;n }nn return inflator.result;n}n/**n * inflateRaw(data[, options]) -> Uint8Array|Array|Stringn * - data (Uint8Array|Array|String): input data to decompress.n * - options (Object
): zlib inflate options.n *n * The same as [[inflate]], but creates raw data, without wrappern * (header and adler32 crc).n **/nnnfunction inflateRaw(input, options) {n options = options || {};n options.raw = true;n return inflate(input, options);n}n/**n * ungzip(data[, options]) -> Uint8Array|Array|Stringn * - data (Uint8Array|Array|String): input data to decompress.n * - options (Object
): zlib inflate options.n *n * Just shortcut to [[inflate]], because it autodetects formatn * by header.content. Done for convenience.n **/nnnexports.Inflate = Inflate;nexports.inflate = inflate;nexports.inflateRaw = inflateRaw;nexports.ungzip = inflate;”,“map”:null,“metadata”:{},“sourceType”:“module”}