UNPKG

lixin-web

Version:

vue and bootstrap

1,247 lines (1,155 loc) 112 kB
/// © 2015 Nathan Rugg <nmrugg@gmail.com> | MIT /// See LICENSE for more details. /* jshint noarg:true, boss:true, unused:strict, strict:true, undef:true, noarg: true, forin:true, evil:true, newcap:false, -W041, -W021, worker:true, browser:true, node:true */ /* global setImmediate, setTimeout, window, onmessage */ /** xs */ ///NOTE: This is the master file that is used to generate lzma-c.js and lzma-d.js. /// Comments are used to determine which parts are to be removed. /// /// cs-ce (compression start-end) /// ds-de (decompression start-end) /// xs-xe (only in this file start-end) /// co (compression only) /// do (decompression only) /** xe */ var LZMA = (function () { "use strict"; var /** cs */ action_compress = 1, /** ce */ /** ds */ action_decompress = 2, /** de */ action_progress = 3, wait = typeof setImmediate == "function" ? setImmediate : setTimeout, __4294967296 = 4294967296, N1_longLit = [4294967295, -__4294967296], /** cs */ MIN_VALUE = [0, -9223372036854775808], /** ce */ P0_longLit = [0, 0], P1_longLit = [1, 0]; function update_progress(percent, cbn) { postMessage({ action: action_progress, cbn: cbn, result: percent }); } function initDim(len) { ///NOTE: This is MUCH faster than "new Array(len)" in newer versions of v8 (starting with Node.js 0.11.15, which uses v8 3.28.73). var a = []; a[len - 1] = undefined; return a; } function add(a, b) { return create(a[0] + b[0], a[1] + b[1]); } /** cs */ function and(a, b) { return makeFromBits(~~Math.max(Math.min(a[1] / __4294967296, 2147483647), -2147483648) & ~~Math.max(Math.min(b[1] / __4294967296, 2147483647), -2147483648), lowBits_0(a) & lowBits_0(b)); } /** ce */ function compare(a, b) { var nega, negb; if (a[0] == b[0] && a[1] == b[1]) { return 0; } nega = a[1] < 0; negb = b[1] < 0; if (nega && !negb) { return -1; } if (!nega && negb) { return 1; } if (sub(a, b)[1] < 0) { return -1; } return 1; } function create(valueLow, valueHigh) { var diffHigh, diffLow; valueHigh %= 1.8446744073709552E19; valueLow %= 1.8446744073709552E19; diffHigh = valueHigh % __4294967296; diffLow = Math.floor(valueLow / __4294967296) * __4294967296; valueHigh = valueHigh - diffHigh + diffLow; valueLow = valueLow - diffLow + diffHigh; while (valueLow < 0) { valueLow += __4294967296; valueHigh -= __4294967296; } while (valueLow > 4294967295) { valueLow -= __4294967296; valueHigh += __4294967296; } valueHigh = valueHigh % 1.8446744073709552E19; while (valueHigh > 9223372032559808512) { valueHigh -= 1.8446744073709552E19; } while (valueHigh < -9223372036854775808) { valueHigh += 1.8446744073709552E19; } return [valueLow, valueHigh]; } /** cs */ function eq(a, b) { return a[0] == b[0] && a[1] == b[1]; } /** ce */ function fromInt(value) { if (value >= 0) { return [value, 0]; } else { return [value + __4294967296, -__4294967296]; } } function lowBits_0(a) { if (a[0] >= 2147483648) { return ~~Math.max(Math.min(a[0] - __4294967296, 2147483647), -2147483648); } else { return ~~Math.max(Math.min(a[0], 2147483647), -2147483648); } } /** cs */ function makeFromBits(highBits, lowBits) { var high, low; high = highBits * __4294967296; low = lowBits; if (lowBits < 0) { low += __4294967296; } return [low, high]; } function pwrAsDouble(n) { if (n <= 30) { return 1 << n; } else { return pwrAsDouble(30) * pwrAsDouble(n - 30); } } function shl(a, n) { var diff, newHigh, newLow, twoToN; n &= 63; if (eq(a, MIN_VALUE)) { if (!n) { return a; } return P0_longLit; } if (a[1] < 0) { throw new Error("Neg"); } twoToN = pwrAsDouble(n); newHigh = a[1] * twoToN % 1.8446744073709552E19; newLow = a[0] * twoToN; diff = newLow - newLow % __4294967296; newHigh += diff; newLow -= diff; if (newHigh >= 9223372036854775807) { newHigh -= 1.8446744073709552E19; } return [newLow, newHigh]; } function shr(a, n) { var shiftFact; n &= 63; shiftFact = pwrAsDouble(n); return create(Math.floor(a[0] / shiftFact), a[1] / shiftFact); } function shru(a, n) { var sr; n &= 63; sr = shr(a, n); if (a[1] < 0) { sr = add(sr, shl([2, 0], 63 - n)); } return sr; } /** ce */ function sub(a, b) { return create(a[0] - b[0], a[1] - b[1]); } function $ByteArrayInputStream(this$static, buf) { this$static.buf = buf; this$static.pos = 0; this$static.count = buf.length; return this$static; } /** ds */ function $read(this$static) { if (this$static.pos >= this$static.count) return -1; return this$static.buf[this$static.pos++] & 255; } /** de */ /** cs */ function $read_0(this$static, buf, off, len) { if (this$static.pos >= this$static.count) return -1; len = Math.min(len, this$static.count - this$static.pos); arraycopy(this$static.buf, this$static.pos, buf, off, len); this$static.pos += len; return len; } /** ce */ function $ByteArrayOutputStream(this$static) { this$static.buf = initDim(32); this$static.count = 0; return this$static; } function $toByteArray(this$static) { var data = this$static.buf; data.length = this$static.count; return data; } /** cs */ function $write(this$static, b) { this$static.buf[this$static.count++] = b << 24 >> 24; } /** ce */ function $write_0(this$static, buf, off, len) { arraycopy(buf, off, this$static.buf, this$static.count, len); this$static.count += len; } /** cs */ function $getChars(this$static, srcBegin, srcEnd, dst, dstBegin) { var srcIdx; for (srcIdx = srcBegin; srcIdx < srcEnd; ++srcIdx) { dst[dstBegin++] = this$static.charCodeAt(srcIdx); } } /** ce */ function arraycopy(src, srcOfs, dest, destOfs, len) { for (var i = 0; i < len; ++i) { dest[destOfs + i] = src[srcOfs + i]; } } /** cs */ function $configure(this$static, encoder) { $SetDictionarySize_0(encoder, 1 << this$static.s); encoder._numFastBytes = this$static.f; $SetMatchFinder(encoder, this$static.m); /// lc is always 3 /// lp is always 0 /// pb is always 2 encoder._numLiteralPosStateBits = 0; encoder._numLiteralContextBits = 3; encoder._posStateBits = 2; ///this$static._posStateMask = (1 << pb) - 1; encoder._posStateMask = 3; } function $init(this$static, input, output, length_0, mode) { var encoder, i; if (compare(length_0, N1_longLit) < 0) throw new Error("invalid length " + length_0); this$static.length_0 = length_0; encoder = $Encoder({}); $configure(mode, encoder); encoder._writeEndMark = typeof LZMA.disableEndMark == "undefined"; $WriteCoderProperties(encoder, output); for (i = 0; i < 64; i += 8) $write(output, lowBits_0(shr(length_0, i)) & 255); this$static.chunker = (encoder._needReleaseMFStream = 0 , (encoder._inStream = input , encoder._finished = 0 , $Create_2(encoder) , encoder._rangeEncoder.Stream = output , $Init_4(encoder) , $FillDistancesPrices(encoder) , $FillAlignPrices(encoder) , encoder._lenEncoder._tableSize = encoder._numFastBytes + 1 - 2 , $UpdateTables(encoder._lenEncoder, 1 << encoder._posStateBits) , encoder._repMatchLenEncoder._tableSize = encoder._numFastBytes + 1 - 2 , $UpdateTables(encoder._repMatchLenEncoder, 1 << encoder._posStateBits) , encoder.nowPos64 = P0_longLit , undefined) , $Chunker_0({}, encoder)); } function $LZMAByteArrayCompressor(this$static, data, mode) { this$static.output = $ByteArrayOutputStream({}); $init(this$static, $ByteArrayInputStream({}, data), this$static.output, fromInt(data.length), mode); return this$static; } /** ce */ /** ds */ function $init_0(this$static, input, output) { var decoder, hex_length = "", i, properties = [], r, tmp_length; for (i = 0; i < 5; ++i) { r = $read(input); if (r == -1) throw new Error("truncated input"); properties[i] = r << 24 >> 24; } decoder = $Decoder({}); if (!$SetDecoderProperties(decoder, properties)) { throw new Error("corrupted input"); } for (i = 0; i < 64; i += 8) { r = $read(input); if (r == -1) throw new Error("truncated input"); r = r.toString(16); if (r.length == 1) r = "0" + r; hex_length = r + "" + hex_length; } /// Was the length set in the header (if it was compressed from a stream, the length is all f"s). if (/^0+$|^f+$/i.test(hex_length)) { /// The length is unknown, so set to -1. this$static.length_0 = N1_longLit; } else { ///NOTE: If there is a problem with the decoder because of the length, you can always set the length to -1 (N1_longLit) which means unknown. tmp_length = parseInt(hex_length, 16); /// If the length is too long to handle, just set it to unknown. if (tmp_length > 4294967295) { this$static.length_0 = N1_longLit; } else { this$static.length_0 = fromInt(tmp_length); } } this$static.chunker = $CodeInChunks(decoder, input, output, this$static.length_0); } function $LZMAByteArrayDecompressor(this$static, data) { this$static.output = $ByteArrayOutputStream({}); $init_0(this$static, $ByteArrayInputStream({}, data), this$static.output); return this$static; } /** de */ /** cs */ function $Create_4(this$static, keepSizeBefore, keepSizeAfter, keepSizeReserv) { var blockSize; this$static._keepSizeBefore = keepSizeBefore; this$static._keepSizeAfter = keepSizeAfter; blockSize = keepSizeBefore + keepSizeAfter + keepSizeReserv; if (this$static._bufferBase == null || this$static._blockSize != blockSize) { this$static._bufferBase = null; this$static._blockSize = blockSize; this$static._bufferBase = initDim(this$static._blockSize); } this$static._pointerToLastSafePosition = this$static._blockSize - keepSizeAfter; } function $GetIndexByte(this$static, index) { return this$static._bufferBase[this$static._bufferOffset + this$static._pos + index]; } function $GetMatchLen(this$static, index, distance, limit) { var i, pby; if (this$static._streamEndWasReached) { if (this$static._pos + index + limit > this$static._streamPos) { limit = this$static._streamPos - (this$static._pos + index); } } ++distance; pby = this$static._bufferOffset + this$static._pos + index; for (i = 0; i < limit && this$static._bufferBase[pby + i] == this$static._bufferBase[pby + i - distance]; ++i) { } return i; } function $GetNumAvailableBytes(this$static) { return this$static._streamPos - this$static._pos; } function $MoveBlock(this$static) { var i, numBytes, offset; offset = this$static._bufferOffset + this$static._pos - this$static._keepSizeBefore; if (offset > 0) { --offset; } numBytes = this$static._bufferOffset + this$static._streamPos - offset; for (i = 0; i < numBytes; ++i) { this$static._bufferBase[i] = this$static._bufferBase[offset + i]; } this$static._bufferOffset -= offset; } function $MovePos_1(this$static) { var pointerToPostion; ++this$static._pos; if (this$static._pos > this$static._posLimit) { pointerToPostion = this$static._bufferOffset + this$static._pos; if (pointerToPostion > this$static._pointerToLastSafePosition) { $MoveBlock(this$static); } $ReadBlock(this$static); } } function $ReadBlock(this$static) { var numReadBytes, pointerToPostion, size; if (this$static._streamEndWasReached) return; while (1) { size = -this$static._bufferOffset + this$static._blockSize - this$static._streamPos; if (!size) return; numReadBytes = $read_0(this$static._stream, this$static._bufferBase, this$static._bufferOffset + this$static._streamPos, size); if (numReadBytes == -1) { this$static._posLimit = this$static._streamPos; pointerToPostion = this$static._bufferOffset + this$static._posLimit; if (pointerToPostion > this$static._pointerToLastSafePosition) { this$static._posLimit = this$static._pointerToLastSafePosition - this$static._bufferOffset; } this$static._streamEndWasReached = 1; return; } this$static._streamPos += numReadBytes; if (this$static._streamPos >= this$static._pos + this$static._keepSizeAfter) { this$static._posLimit = this$static._streamPos - this$static._keepSizeAfter; } } } function $ReduceOffsets(this$static, subValue) { this$static._bufferOffset += subValue; this$static._posLimit -= subValue; this$static._pos -= subValue; this$static._streamPos -= subValue; } var CrcTable = (function () { var i, j, r, CrcTable = []; for (i = 0; i < 256; ++i) { r = i; for (j = 0; j < 8; ++j) if ((r & 1) != 0) { r = r >>> 1 ^ -306674912; } else { r >>>= 1; } CrcTable[i] = r; } return CrcTable; }()); function $Create_3(this$static, historySize, keepAddBufferBefore, matchMaxLen, keepAddBufferAfter) { var cyclicBufferSize, hs, windowReservSize; if (historySize < 1073741567) { this$static._cutValue = 16 + (matchMaxLen >> 1); windowReservSize = ~~((historySize + keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2) + 256; $Create_4(this$static, historySize + keepAddBufferBefore, matchMaxLen + keepAddBufferAfter, windowReservSize); this$static._matchMaxLen = matchMaxLen; cyclicBufferSize = historySize + 1; if (this$static._cyclicBufferSize != cyclicBufferSize) { this$static._son = initDim((this$static._cyclicBufferSize = cyclicBufferSize) * 2); } hs = 65536; if (this$static.HASH_ARRAY) { hs = historySize - 1; hs |= hs >> 1; hs |= hs >> 2; hs |= hs >> 4; hs |= hs >> 8; hs >>= 1; hs |= 65535; if (hs > 16777216) hs >>= 1; this$static._hashMask = hs; ++hs; hs += this$static.kFixHashSize; } if (hs != this$static._hashSizeSum) { this$static._hash = initDim(this$static._hashSizeSum = hs); } } } function $GetMatches(this$static, distances) { var count, cur, curMatch, curMatch2, curMatch3, cyclicPos, delta, hash2Value, hash3Value, hashValue, len, len0, len1, lenLimit, matchMinPos, maxLen, offset, pby1, ptr0, ptr1, temp; if (this$static._pos + this$static._matchMaxLen <= this$static._streamPos) { lenLimit = this$static._matchMaxLen; } else { lenLimit = this$static._streamPos - this$static._pos; if (lenLimit < this$static.kMinMatchCheck) { $MovePos_0(this$static); return 0; } } offset = 0; matchMinPos = this$static._pos > this$static._cyclicBufferSize?this$static._pos - this$static._cyclicBufferSize:0; cur = this$static._bufferOffset + this$static._pos; maxLen = 1; hash2Value = 0; hash3Value = 0; if (this$static.HASH_ARRAY) { temp = CrcTable[this$static._bufferBase[cur] & 255] ^ this$static._bufferBase[cur + 1] & 255; hash2Value = temp & 1023; temp ^= (this$static._bufferBase[cur + 2] & 255) << 8; hash3Value = temp & 65535; hashValue = (temp ^ CrcTable[this$static._bufferBase[cur + 3] & 255] << 5) & this$static._hashMask; } else { hashValue = this$static._bufferBase[cur] & 255 ^ (this$static._bufferBase[cur + 1] & 255) << 8; } curMatch = this$static._hash[this$static.kFixHashSize + hashValue] || 0; if (this$static.HASH_ARRAY) { curMatch2 = this$static._hash[hash2Value] || 0; curMatch3 = this$static._hash[1024 + hash3Value] || 0; this$static._hash[hash2Value] = this$static._pos; this$static._hash[1024 + hash3Value] = this$static._pos; if (curMatch2 > matchMinPos) { if (this$static._bufferBase[this$static._bufferOffset + curMatch2] == this$static._bufferBase[cur]) { distances[offset++] = maxLen = 2; distances[offset++] = this$static._pos - curMatch2 - 1; } } if (curMatch3 > matchMinPos) { if (this$static._bufferBase[this$static._bufferOffset + curMatch3] == this$static._bufferBase[cur]) { if (curMatch3 == curMatch2) { offset -= 2; } distances[offset++] = maxLen = 3; distances[offset++] = this$static._pos - curMatch3 - 1; curMatch2 = curMatch3; } } if (offset != 0 && curMatch2 == curMatch) { offset -= 2; maxLen = 1; } } this$static._hash[this$static.kFixHashSize + hashValue] = this$static._pos; ptr0 = (this$static._cyclicBufferPos << 1) + 1; ptr1 = this$static._cyclicBufferPos << 1; len0 = len1 = this$static.kNumHashDirectBytes; if (this$static.kNumHashDirectBytes != 0) { if (curMatch > matchMinPos) { if (this$static._bufferBase[this$static._bufferOffset + curMatch + this$static.kNumHashDirectBytes] != this$static._bufferBase[cur + this$static.kNumHashDirectBytes]) { distances[offset++] = maxLen = this$static.kNumHashDirectBytes; distances[offset++] = this$static._pos - curMatch - 1; } } } count = this$static._cutValue; while (1) { if (curMatch <= matchMinPos || count-- == 0) { this$static._son[ptr0] = this$static._son[ptr1] = 0; break; } delta = this$static._pos - curMatch; cyclicPos = (delta <= this$static._cyclicBufferPos?this$static._cyclicBufferPos - delta:this$static._cyclicBufferPos - delta + this$static._cyclicBufferSize) << 1; pby1 = this$static._bufferOffset + curMatch; len = len0 < len1?len0:len1; if (this$static._bufferBase[pby1 + len] == this$static._bufferBase[cur + len]) { while (++len != lenLimit) { if (this$static._bufferBase[pby1 + len] != this$static._bufferBase[cur + len]) { break; } } if (maxLen < len) { distances[offset++] = maxLen = len; distances[offset++] = delta - 1; if (len == lenLimit) { this$static._son[ptr1] = this$static._son[cyclicPos]; this$static._son[ptr0] = this$static._son[cyclicPos + 1]; break; } } } if ((this$static._bufferBase[pby1 + len] & 255) < (this$static._bufferBase[cur + len] & 255)) { this$static._son[ptr1] = curMatch; ptr1 = cyclicPos + 1; curMatch = this$static._son[ptr1]; len1 = len; } else { this$static._son[ptr0] = curMatch; ptr0 = cyclicPos; curMatch = this$static._son[ptr0]; len0 = len; } } $MovePos_0(this$static); return offset; } function $Init_5(this$static) { this$static._bufferOffset = 0; this$static._pos = 0; this$static._streamPos = 0; this$static._streamEndWasReached = 0; $ReadBlock(this$static); this$static._cyclicBufferPos = 0; $ReduceOffsets(this$static, -1); } function $MovePos_0(this$static) { var subValue; if (++this$static._cyclicBufferPos >= this$static._cyclicBufferSize) { this$static._cyclicBufferPos = 0; } $MovePos_1(this$static); if (this$static._pos == 1073741823) { subValue = this$static._pos - this$static._cyclicBufferSize; $NormalizeLinks(this$static._son, this$static._cyclicBufferSize * 2, subValue); $NormalizeLinks(this$static._hash, this$static._hashSizeSum, subValue); $ReduceOffsets(this$static, subValue); } } ///NOTE: This is only called after reading one whole gigabyte. function $NormalizeLinks(items, numItems, subValue) { var i, value; for (i = 0; i < numItems; ++i) { value = items[i] || 0; if (value <= subValue) { value = 0; } else { value -= subValue; } items[i] = value; } } function $SetType(this$static, numHashBytes) { this$static.HASH_ARRAY = numHashBytes > 2; if (this$static.HASH_ARRAY) { this$static.kNumHashDirectBytes = 0; this$static.kMinMatchCheck = 4; this$static.kFixHashSize = 66560; } else { this$static.kNumHashDirectBytes = 2; this$static.kMinMatchCheck = 3; this$static.kFixHashSize = 0; } } function $Skip(this$static, num) { var count, cur, curMatch, cyclicPos, delta, hash2Value, hash3Value, hashValue, len, len0, len1, lenLimit, matchMinPos, pby1, ptr0, ptr1, temp; do { if (this$static._pos + this$static._matchMaxLen <= this$static._streamPos) { lenLimit = this$static._matchMaxLen; } else { lenLimit = this$static._streamPos - this$static._pos; if (lenLimit < this$static.kMinMatchCheck) { $MovePos_0(this$static); continue; } } matchMinPos = this$static._pos > this$static._cyclicBufferSize?this$static._pos - this$static._cyclicBufferSize:0; cur = this$static._bufferOffset + this$static._pos; if (this$static.HASH_ARRAY) { temp = CrcTable[this$static._bufferBase[cur] & 255] ^ this$static._bufferBase[cur + 1] & 255; hash2Value = temp & 1023; this$static._hash[hash2Value] = this$static._pos; temp ^= (this$static._bufferBase[cur + 2] & 255) << 8; hash3Value = temp & 65535; this$static._hash[1024 + hash3Value] = this$static._pos; hashValue = (temp ^ CrcTable[this$static._bufferBase[cur + 3] & 255] << 5) & this$static._hashMask; } else { hashValue = this$static._bufferBase[cur] & 255 ^ (this$static._bufferBase[cur + 1] & 255) << 8; } curMatch = this$static._hash[this$static.kFixHashSize + hashValue]; this$static._hash[this$static.kFixHashSize + hashValue] = this$static._pos; ptr0 = (this$static._cyclicBufferPos << 1) + 1; ptr1 = this$static._cyclicBufferPos << 1; len0 = len1 = this$static.kNumHashDirectBytes; count = this$static._cutValue; while (1) { if (curMatch <= matchMinPos || count-- == 0) { this$static._son[ptr0] = this$static._son[ptr1] = 0; break; } delta = this$static._pos - curMatch; cyclicPos = (delta <= this$static._cyclicBufferPos?this$static._cyclicBufferPos - delta:this$static._cyclicBufferPos - delta + this$static._cyclicBufferSize) << 1; pby1 = this$static._bufferOffset + curMatch; len = len0 < len1?len0:len1; if (this$static._bufferBase[pby1 + len] == this$static._bufferBase[cur + len]) { while (++len != lenLimit) { if (this$static._bufferBase[pby1 + len] != this$static._bufferBase[cur + len]) { break; } } if (len == lenLimit) { this$static._son[ptr1] = this$static._son[cyclicPos]; this$static._son[ptr0] = this$static._son[cyclicPos + 1]; break; } } if ((this$static._bufferBase[pby1 + len] & 255) < (this$static._bufferBase[cur + len] & 255)) { this$static._son[ptr1] = curMatch; ptr1 = cyclicPos + 1; curMatch = this$static._son[ptr1]; len1 = len; } else { this$static._son[ptr0] = curMatch; ptr0 = cyclicPos; curMatch = this$static._son[ptr0]; len0 = len; } } $MovePos_0(this$static); } while (--num != 0); } /** ce */ /** ds */ function $CopyBlock(this$static, distance, len) { var pos = this$static._pos - distance - 1; if (pos < 0) { pos += this$static._windowSize; } for (; len != 0; --len) { if (pos >= this$static._windowSize) { pos = 0; } this$static._buffer[this$static._pos++] = this$static._buffer[pos++]; if (this$static._pos >= this$static._windowSize) { $Flush_0(this$static); } } } function $Create_5(this$static, windowSize) { if (this$static._buffer == null || this$static._windowSize != windowSize) { this$static._buffer = initDim(windowSize); } this$static._windowSize = windowSize; this$static._pos = 0; this$static._streamPos = 0; } function $Flush_0(this$static) { var size = this$static._pos - this$static._streamPos; if (!size) { return; } $write_0(this$static._stream, this$static._buffer, this$static._streamPos, size); if (this$static._pos >= this$static._windowSize) { this$static._pos = 0; } this$static._streamPos = this$static._pos; } function $GetByte(this$static, distance) { var pos = this$static._pos - distance - 1; if (pos < 0) { pos += this$static._windowSize; } return this$static._buffer[pos]; } function $PutByte(this$static, b) { this$static._buffer[this$static._pos++] = b; if (this$static._pos >= this$static._windowSize) { $Flush_0(this$static); } } function $ReleaseStream(this$static) { $Flush_0(this$static); this$static._stream = null; } /** de */ function GetLenToPosState(len) { len -= 2; if (len < 4) { return len; } return 3; } function StateUpdateChar(index) { if (index < 4) { return 0; } if (index < 10) { return index - 3; } return index - 6; } /** cs */ function $Chunker_0(this$static, encoder) { this$static.encoder = encoder; this$static.decoder = null; this$static.alive = 1; return this$static; } /** ce */ /** ds */ function $Chunker(this$static, decoder) { this$static.decoder = decoder; this$static.encoder = null; this$static.alive = 1; return this$static; } /** de */ function $processChunk(this$static) { if (!this$static.alive) { throw new Error("bad state"); } if (this$static.encoder) { /// do:throw new Error("No encoding"); /** cs */ $processEncoderChunk(this$static); /** ce */ } else { /// co:throw new Error("No decoding"); /** ds */ $processDecoderChunk(this$static); /** de */ } return this$static.alive; } /** ds */ function $processDecoderChunk(this$static) { var result = $CodeOneChunk(this$static.decoder); if (result == -1) { throw new Error("corrupted input"); } this$static.inBytesProcessed = N1_longLit; this$static.outBytesProcessed = this$static.decoder.nowPos64; if (result || compare(this$static.decoder.outSize, P0_longLit) >= 0 && compare(this$static.decoder.nowPos64, this$static.decoder.outSize) >= 0) { $Flush_0(this$static.decoder.m_OutWindow); $ReleaseStream(this$static.decoder.m_OutWindow); this$static.decoder.m_RangeDecoder.Stream = null; this$static.alive = 0; } } /** de */ /** cs */ function $processEncoderChunk(this$static) { $CodeOneBlock(this$static.encoder, this$static.encoder.processedInSize, this$static.encoder.processedOutSize, this$static.encoder.finished); this$static.inBytesProcessed = this$static.encoder.processedInSize[0]; if (this$static.encoder.finished[0]) { $ReleaseStreams(this$static.encoder); this$static.alive = 0; } } /** ce */ /** ds */ function $CodeInChunks(this$static, inStream, outStream, outSize) { this$static.m_RangeDecoder.Stream = inStream; $ReleaseStream(this$static.m_OutWindow); this$static.m_OutWindow._stream = outStream; $Init_1(this$static); this$static.state = 0; this$static.rep0 = 0; this$static.rep1 = 0; this$static.rep2 = 0; this$static.rep3 = 0; this$static.outSize = outSize; this$static.nowPos64 = P0_longLit; this$static.prevByte = 0; return $Chunker({}, this$static); } function $CodeOneChunk(this$static) { var decoder2, distance, len, numDirectBits, posSlot, posState; posState = lowBits_0(this$static.nowPos64) & this$static.m_PosStateMask; if (!$DecodeBit(this$static.m_RangeDecoder, this$static.m_IsMatchDecoders, (this$static.state << 4) + posState)) { decoder2 = $GetDecoder(this$static.m_LiteralDecoder, lowBits_0(this$static.nowPos64), this$static.prevByte); if (this$static.state < 7) { this$static.prevByte = $DecodeNormal(decoder2, this$static.m_RangeDecoder); } else { this$static.prevByte = $DecodeWithMatchByte(decoder2, this$static.m_RangeDecoder, $GetByte(this$static.m_OutWindow, this$static.rep0)); } $PutByte(this$static.m_OutWindow, this$static.prevByte); this$static.state = StateUpdateChar(this$static.state); this$static.nowPos64 = add(this$static.nowPos64, P1_longLit); } else { if ($DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRepDecoders, this$static.state)) { len = 0; if (!$DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRepG0Decoders, this$static.state)) { if (!$DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRep0LongDecoders, (this$static.state << 4) + posState)) { this$static.state = this$static.state < 7?9:11; len = 1; } } else { if (!$DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRepG1Decoders, this$static.state)) { distance = this$static.rep1; } else { if (!$DecodeBit(this$static.m_RangeDecoder, this$static.m_IsRepG2Decoders, this$static.state)) { distance = this$static.rep2; } else { distance = this$static.rep3; this$static.rep3 = this$static.rep2; } this$static.rep2 = this$static.rep1; } this$static.rep1 = this$static.rep0; this$static.rep0 = distance; } if (!len) { len = $Decode(this$static.m_RepLenDecoder, this$static.m_RangeDecoder, posState) + 2; this$static.state = this$static.state < 7?8:11; } } else { this$static.rep3 = this$static.rep2; this$static.rep2 = this$static.rep1; this$static.rep1 = this$static.rep0; len = 2 + $Decode(this$static.m_LenDecoder, this$static.m_RangeDecoder, posState); this$static.state = this$static.state < 7?7:10; posSlot = $Decode_0(this$static.m_PosSlotDecoder[GetLenToPosState(len)], this$static.m_RangeDecoder); if (posSlot >= 4) { numDirectBits = (posSlot >> 1) - 1; this$static.rep0 = (2 | posSlot & 1) << numDirectBits; if (posSlot < 14) { this$static.rep0 += ReverseDecode(this$static.m_PosDecoders, this$static.rep0 - posSlot - 1, this$static.m_RangeDecoder, numDirectBits); } else { this$static.rep0 += $DecodeDirectBits(this$static.m_RangeDecoder, numDirectBits - 4) << 4; this$static.rep0 += $ReverseDecode(this$static.m_PosAlignDecoder, this$static.m_RangeDecoder); if (this$static.rep0 < 0) { if (this$static.rep0 == -1) { return 1; } return -1; } } } else this$static.rep0 = posSlot; } if (compare(fromInt(this$static.rep0), this$static.nowPos64) >= 0 || this$static.rep0 >= this$static.m_DictionarySizeCheck) { return -1; } $CopyBlock(this$static.m_OutWindow, this$static.rep0, len); this$static.nowPos64 = add(this$static.nowPos64, fromInt(len)); this$static.prevByte = $GetByte(this$static.m_OutWindow, 0); } return 0; } function $Decoder(this$static) { this$static.m_OutWindow = {}; this$static.m_RangeDecoder = {}; this$static.m_IsMatchDecoders = initDim(192); this$static.m_IsRepDecoders = initDim(12); this$static.m_IsRepG0Decoders = initDim(12); this$static.m_IsRepG1Decoders = initDim(12); this$static.m_IsRepG2Decoders = initDim(12); this$static.m_IsRep0LongDecoders = initDim(192); this$static.m_PosSlotDecoder = initDim(4); this$static.m_PosDecoders = initDim(114); this$static.m_PosAlignDecoder = $BitTreeDecoder({}, 4); this$static.m_LenDecoder = $Decoder$LenDecoder({}); this$static.m_RepLenDecoder = $Decoder$LenDecoder({}); this$static.m_LiteralDecoder = {}; for (var i = 0; i < 4; ++i) { this$static.m_PosSlotDecoder[i] = $BitTreeDecoder({}, 6); } return this$static; } function $Init_1(this$static) { this$static.m_OutWindow._streamPos = 0; this$static.m_OutWindow._pos = 0; InitBitModels(this$static.m_IsMatchDecoders); InitBitModels(this$static.m_IsRep0LongDecoders); InitBitModels(this$static.m_IsRepDecoders); InitBitModels(this$static.m_IsRepG0Decoders); InitBitModels(this$static.m_IsRepG1Decoders); InitBitModels(this$static.m_IsRepG2Decoders); InitBitModels(this$static.m_PosDecoders); $Init_0(this$static.m_LiteralDecoder); for (var i = 0; i < 4; ++i) { InitBitModels(this$static.m_PosSlotDecoder[i].Models); } $Init(this$static.m_LenDecoder); $Init(this$static.m_RepLenDecoder); InitBitModels(this$static.m_PosAlignDecoder.Models); $Init_8(this$static.m_RangeDecoder); } function $SetDecoderProperties(this$static, properties) { var dictionarySize, i, lc, lp, pb, remainder, val; if (properties.length < 5) return 0; val = properties[0] & 255; lc = val % 9; remainder = ~~(val / 9); lp = remainder % 5; pb = ~~(remainder / 5); dictionarySize = 0; for (i = 0; i < 4; ++i) { dictionarySize += (properties[1 + i] & 255) << i * 8; } ///NOTE: If the input is bad, it might call for an insanely large dictionary size, which would crash the script. if (dictionarySize > 99999999 || !$SetLcLpPb(this$static, lc, lp, pb)) { return 0; } return $SetDictionarySize(this$static, dictionarySize); } function $SetDictionarySize(this$static, dictionarySize) { if (dictionarySize < 0) { return 0; } if (this$static.m_DictionarySize != dictionarySize) { this$static.m_DictionarySize = dictionarySize; this$static.m_DictionarySizeCheck = Math.max(this$static.m_DictionarySize, 1); $Create_5(this$static.m_OutWindow, Math.max(this$static.m_DictionarySizeCheck, 4096)); } return 1; } function $SetLcLpPb(this$static, lc, lp, pb) { if (lc > 8 || lp > 4 || pb > 4) { return 0; } $Create_0(this$static.m_LiteralDecoder, lp, lc); var numPosStates = 1 << pb; $Create(this$static.m_LenDecoder, numPosStates); $Create(this$static.m_RepLenDecoder, numPosStates); this$static.m_PosStateMask = numPosStates - 1; return 1; } function $Create(this$static, numPosStates) { for (; this$static.m_NumPosStates < numPosStates; ++this$static.m_NumPosStates) { this$static.m_LowCoder[this$static.m_NumPosStates] = $BitTreeDecoder({}, 3); this$static.m_MidCoder[this$static.m_NumPosStates] = $BitTreeDecoder({}, 3); } } function $Decode(this$static, rangeDecoder, posState) { if (!$DecodeBit(rangeDecoder, this$static.m_Choice, 0)) { return $Decode_0(this$static.m_LowCoder[posState], rangeDecoder); } var symbol = 8; if (!$DecodeBit(rangeDecoder, this$static.m_Choice, 1)) { symbol += $Decode_0(this$static.m_MidCoder[posState], rangeDecoder); } else { symbol += 8 + $Decode_0(this$static.m_HighCoder, rangeDecoder); } return symbol; } function $Decoder$LenDecoder(this$static) { this$static.m_Choice = initDim(2); this$static.m_LowCoder = initDim(16); this$static.m_MidCoder = initDim(16); this$static.m_HighCoder = $BitTreeDecoder({}, 8); this$static.m_NumPosStates = 0; return this$static; } function $Init(this$static) { InitBitModels(this$static.m_Choice); for (var posState = 0; posState < this$static.m_NumPosStates; ++posState) { InitBitModels(this$static.m_LowCoder[posState].Models); InitBitModels(this$static.m_MidCoder[posState].Models); } InitBitModels(this$static.m_HighCoder.Models); } function $Create_0(this$static, numPosBits, numPrevBits) { var i, numStates; if (this$static.m_Coders != null && this$static.m_NumPrevBits == numPrevBits && this$static.m_NumPosBits == numPosBits) return; this$static.m_NumPosBits = numPosBits; this$static.m_PosMask = (1 << numPosBits) - 1; this$static.m_NumPrevBits = numPrevBits; numStates = 1 << this$static.m_NumPrevBits + this$static.m_NumPosBits; this$static.m_Coders = initDim(numStates); for (i = 0; i < numStates; ++i) this$static.m_Coders[i] = $Decoder$LiteralDecoder$Decoder2({}); } function $GetDecoder(this$static, pos, prevByte) { return this$static.m_Coders[((pos & this$static.m_PosMask) << this$static.m_NumPrevBits) + ((prevByte & 255) >>> 8 - this$static.m_NumPrevBits)]; } function $Init_0(this$static) { var i, numStates; numStates = 1 << this$static.m_NumPrevBits + this$static.m_NumPosBits; for (i = 0; i < numStates; ++i) { InitBitModels(this$static.m_Coders[i].m_Decoders); } } function $DecodeNormal(this$static, rangeDecoder) { var symbol = 1; do { symbol = symbol << 1 | $DecodeBit(rangeDecoder, this$static.m_Decoders, symbol); } while (symbol < 256); return symbol << 24 >> 24; } function $DecodeWithMatchByte(this$static, rangeDecoder, matchByte) { var bit, matchBit, symbol = 1; do { matchBit = matchByte >> 7 & 1; matchByte <<= 1; bit = $DecodeBit(rangeDecoder, this$static.m_Decoders, (1 + matchBit << 8) + symbol); symbol = symbol << 1 | bit; if (matchBit != bit) { while (symbol < 256) { symbol = symbol << 1 | $DecodeBit(rangeDecoder, this$static.m_Decoders, symbol); } break; } } while (symbol < 256); return symbol << 24 >> 24; } function $Decoder$LiteralDecoder$Decoder2(this$static) { this$static.m_Decoders = initDim(768); return this$static; } /** de */ /** cs */ var g_FastPos = (function () { var j, k, slotFast, c = 2, g_FastPos = [0, 1]; for (slotFast = 2; slotFast < 22; ++slotFast) { k = 1 << (slotFast >> 1) - 1; for (j = 0; j < k; ++j , ++c) g_FastPos[c] = slotFast << 24 >> 24; } return g_FastPos; }()); function $Backward(this$static, cur) { var backCur, backMem, posMem, posPrev; this$static._optimumEndIndex = cur; posMem = this$static._optimum[cur].PosPrev; backMem = this$static._optimum[cur].BackPrev; do { if (this$static._optimum[cur].Prev1IsChar) { $MakeAsChar(this$static._optimum[posMem]); this$static._optimum[posMem].PosPrev = posMem - 1; if (this$static._optimum[cur].Prev2) { this$static._optimum[posMem - 1].Prev1IsChar = 0; this$static._optimum[posMem - 1].PosPrev = this$static._optimum[cur].PosPrev2; this$static._optimum[posMem - 1].BackPrev = this$static._optimum[cur].BackPrev2; } } posPrev = posMem; backCur = backMem; backMem = this$static._optimum[posPrev].BackPrev; posMem = this$static._optimum[posPrev].PosPrev; this$static._optimum[posPrev].BackPrev = backCur; this$static._optimum[posPrev].PosPrev = cur; cur = posPrev; } while (cur > 0); this$static.backRes = this$static._optimum[0].BackPrev; this$static._optimumCurrentIndex = this$static._optimum[0].PosPrev; return this$static._optimumCurrentIndex; } function $BaseInit(this$static) { this$static._state = 0; this$static._previousByte = 0; for (var i = 0; i < 4; ++i) { this$static._repDistances[i] = 0; } } function $CodeOneBlock(this$static, inSize, outSize, finished) { var baseVal, complexState, curByte, distance, footerBits, i, len, lenToPosState, matchByte, pos, posReduced, posSlot, posState, progressPosValuePrev, subCoder; inSize[0] = P0_longLit; outSize[0] = P0_longLit; finished[0] = 1; if (this$static._inStream) { this$static._matchFinder._stream = this$static._inStream; $Init_5(this$static._matchFinder); this$static._needReleaseMFStream = 1; this$static._inStream = null; } if (this$static._finished) { return; } this$static._finished = 1; progressPosValuePrev = this$static.nowPos64; if (eq(this$static.nowPos64, P0_longLit)) { if (!$GetNumAvailableBytes(this$static._matchFinder)) { $Flush(this$static, lowBits_0(this$static.nowPos64)); return; } $ReadMatchDistances(this$static); posState = lowBits_0(this$static.nowPos64) & this$static._posStateMask; $Encode_3(this$static._rangeEncoder, this$static._isMatch, (this$static._state << 4) + posState, 0); this$static._state = StateUpdateChar(this$static._state); curByte = $GetIndexByte(this$static._matchFinder, -this$static._additionalOffset); $Encode_1($GetSubCoder(this$static._literalEncoder, lowBits_0(this$static.nowPos64), this$static._previousByte), this$static._rangeEncoder, curByte); this$static._previousByte = curByte; --this$static._additionalOffset; this$static.nowPos64 = add(this$static.nowPos64, P1_longLit); } if (!$GetNumAvailableBytes(this$static._matchFinder)) { $Flush(this$static, lowBits_0(this$static.nowPos64)); return; } while (1) { len = $GetOptimum(this$static, lowBits_0(this$static.nowPos64)); pos = this$static.backRes; posState = lowBits_0(this$static.nowPos64) & this$static._posStateMask; complexState = (this$static._state << 4) + posState; if (len == 1 && pos == -1) { $Encode_3(this$static._rangeEncoder, this$static._isMatch, complexState, 0); curByte = $GetIndexByte(this$static._matchFinder, -this$static._additionalOffset); subCoder = $GetSubCoder(this$static._literalEncoder, lowBits_0(this$static.nowPos64), this$static._previousByte); if (this$static._state < 7) { $Encode_1(subCoder, this$static._rangeEncoder, curByte); } else { matchByte = $GetIndexByte(this$static._matchFinder, -this$static._repDistances[0] - 1 - this$static._additionalOffset); $EncodeMatched(subCoder, this$static._rangeEncoder, matchByte, curByte); } this$static._previousByte = curByte; this$static._state = StateUpdateChar(this$static._state); } else { $Encode_3(this$static._rangeEncoder, this$static._isMatch, complexState, 1); if (pos < 4) { $Encode_3(this$static._rangeEncoder, this$static._isRep, this$static._state, 1); if (!pos) { $Encode_3(this$static._rangeEncoder, this$static._isRepG0, this$static._state, 0); if (len == 1) { $Encode_3(this$static._rangeEncoder, this$static._isRep0Long, complexState, 0); } else { $Encode_3(this$static._rangeEncoder, this$static._isRep0Long, complexState, 1); } } else { $Encode_3(this$static._rangeEncoder, this$static._isRepG0, this$static._state, 1); if (pos == 1) { $Encode_3(this$static._rangeEncoder, this$static._isRepG1, this$static._state, 0); } else {