summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/wave/www/lib
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/tools/wave/www/lib
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/tools/wave/www/lib')
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/davidshimjs/LICENSE14
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/davidshimjs/qrcode.js1533
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/jszip.min.js15
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/keycodes.js88
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/qrcode.js1533
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/query-parser.js12
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/screen-console.js16
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/ui.js100
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/utils.js57
-rw-r--r--testing/web-platform/tests/tools/wave/www/lib/wave-service.js866
10 files changed, 4234 insertions, 0 deletions
diff --git a/testing/web-platform/tests/tools/wave/www/lib/davidshimjs/LICENSE b/testing/web-platform/tests/tools/wave/www/lib/davidshimjs/LICENSE
new file mode 100644
index 0000000000..93c33233fa
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/davidshimjs/LICENSE
@@ -0,0 +1,14 @@
+The MIT License (MIT)
+---------------------
+Copyright (c) 2012 davidshimjs
+
+Permission is hereby granted, free of charge,
+to any person obtaining a copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/testing/web-platform/tests/tools/wave/www/lib/davidshimjs/qrcode.js b/testing/web-platform/tests/tools/wave/www/lib/davidshimjs/qrcode.js
new file mode 100644
index 0000000000..45e5d7b974
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/davidshimjs/qrcode.js
@@ -0,0 +1,1533 @@
+/**
+ * @fileoverview
+ * - Using the 'QRCode for Javascript library'
+ * - Fixed dataset of 'QRCode for Javascript library' for support full-spec.
+ * - this library has no dependencies.
+ *
+ * @author davidshimjs
+ * @see <a href="http://www.d-project.com/" target="_blank">http://www.d-project.com/</a>
+ * @see <a href="http://jeromeetienne.github.com/jquery-qrcode/" target="_blank">http://jeromeetienne.github.com/jquery-qrcode/</a>
+ */
+var QRCode
+;(function () {
+ // ---------------------------------------------------------------------
+ // QRCode for JavaScript
+ //
+ // Copyright (c) 2009 Kazuhiko Arase
+ //
+ // URL: http://www.d-project.com/
+ //
+ // Licensed under the MIT license:
+ // http://www.opensource.org/licenses/mit-license.php
+ //
+ // The word "QR Code" is registered trademark of
+ // DENSO WAVE INCORPORATED
+ // http://www.denso-wave.com/qrcode/faqpatent-e.html
+ //
+ // ---------------------------------------------------------------------
+ function QR8bitByte (data) {
+ this.mode = QRMode.MODE_8BIT_BYTE
+ this.data = data
+ this.parsedData = []
+
+ // Added to support UTF-8 Characters
+ for (var i = 0, l = this.data.length; i < l; i++) {
+ var byteArray = []
+ var code = this.data.charCodeAt(i)
+
+ if (code > 0x10000) {
+ byteArray[0] = 0xf0 | ((code & 0x1c0000) >>> 18)
+ byteArray[1] = 0x80 | ((code & 0x3f000) >>> 12)
+ byteArray[2] = 0x80 | ((code & 0xfc0) >>> 6)
+ byteArray[3] = 0x80 | (code & 0x3f)
+ } else if (code > 0x800) {
+ byteArray[0] = 0xe0 | ((code & 0xf000) >>> 12)
+ byteArray[1] = 0x80 | ((code & 0xfc0) >>> 6)
+ byteArray[2] = 0x80 | (code & 0x3f)
+ } else if (code > 0x80) {
+ byteArray[0] = 0xc0 | ((code & 0x7c0) >>> 6)
+ byteArray[1] = 0x80 | (code & 0x3f)
+ } else {
+ byteArray[0] = code
+ }
+
+ this.parsedData.push(byteArray)
+ }
+
+ this.parsedData = Array.prototype.concat.apply([], this.parsedData)
+
+ if (this.parsedData.length != this.data.length) {
+ this.parsedData.unshift(191)
+ this.parsedData.unshift(187)
+ this.parsedData.unshift(239)
+ }
+ }
+
+ QR8bitByte.prototype = {
+ getLength: function (buffer) {
+ return this.parsedData.length
+ },
+ write: function (buffer) {
+ for (var i = 0, l = this.parsedData.length; i < l; i++) {
+ buffer.put(this.parsedData[i], 8)
+ }
+ }
+ }
+
+ function QRCodeModel (typeNumber, errorCorrectLevel) {
+ this.typeNumber = typeNumber
+ this.errorCorrectLevel = errorCorrectLevel
+ this.modules = null
+ this.moduleCount = 0
+ this.dataCache = null
+ this.dataList = []
+ }
+
+ QRCodeModel.prototype = {
+ addData: function (data) {
+ var newData = new QR8bitByte(data)
+ this.dataList.push(newData)
+ this.dataCache = null
+ },
+ isDark: function (row, col) {
+ if (
+ row < 0 ||
+ this.moduleCount <= row ||
+ col < 0 ||
+ this.moduleCount <= col
+ ) {
+ throw new Error(row + ',' + col)
+ }
+ return this.modules[row][col]
+ },
+ getModuleCount: function () {
+ return this.moduleCount
+ },
+ make: function () {
+ this.makeImpl(false, this.getBestMaskPattern())
+ },
+ makeImpl: function (test, maskPattern) {
+ this.moduleCount = this.typeNumber * 4 + 17
+ this.modules = new Array(this.moduleCount)
+ for (var row = 0; row < this.moduleCount; row++) {
+ this.modules[row] = new Array(this.moduleCount)
+ for (var col = 0; col < this.moduleCount; col++) {
+ this.modules[row][col] = null
+ }
+ }
+ this.setupPositionProbePattern(0, 0)
+ this.setupPositionProbePattern(this.moduleCount - 7, 0)
+ this.setupPositionProbePattern(0, this.moduleCount - 7)
+ this.setupPositionAdjustPattern()
+ this.setupTimingPattern()
+ this.setupTypeInfo(test, maskPattern)
+ if (this.typeNumber >= 7) {
+ this.setupTypeNumber(test)
+ }
+ if (this.dataCache == null) {
+ this.dataCache = QRCodeModel.createData(
+ this.typeNumber,
+ this.errorCorrectLevel,
+ this.dataList
+ )
+ }
+ this.mapData(this.dataCache, maskPattern)
+ },
+ setupPositionProbePattern: function (row, col) {
+ for (var r = -1; r <= 7; r++) {
+ if (row + r <= -1 || this.moduleCount <= row + r) continue
+ for (var c = -1; c <= 7; c++) {
+ if (col + c <= -1 || this.moduleCount <= col + c) continue
+ if (
+ (r >= 0 && r <= 6 && (c == 0 || c == 6)) ||
+ (c >= 0 && c <= 6 && (r == 0 || r == 6)) ||
+ (r >= 2 && r <= 4 && c >= 2 && c <= 4)
+ ) {
+ this.modules[row + r][col + c] = true
+ } else {
+ this.modules[row + r][col + c] = false
+ }
+ }
+ }
+ },
+ getBestMaskPattern: function () {
+ var minLostPoint = 0
+ var pattern = 0
+ for (var i = 0; i < 8; i++) {
+ this.makeImpl(true, i)
+ var lostPoint = QRUtil.getLostPoint(this)
+ if (i == 0 || minLostPoint > lostPoint) {
+ minLostPoint = lostPoint
+ pattern = i
+ }
+ }
+ return pattern
+ },
+ createMovieClip: function (target_mc, instance_name, depth) {
+ var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth)
+ var cs = 1
+ this.make()
+ for (var row = 0; row < this.modules.length; row++) {
+ var y = row * cs
+ for (var col = 0; col < this.modules[row].length; col++) {
+ var x = col * cs
+ var dark = this.modules[row][col]
+ if (dark) {
+ qr_mc.beginFill(0, 100)
+ qr_mc.moveTo(x, y)
+ qr_mc.lineTo(x + cs, y)
+ qr_mc.lineTo(x + cs, y + cs)
+ qr_mc.lineTo(x, y + cs)
+ qr_mc.endFill()
+ }
+ }
+ }
+ return qr_mc
+ },
+ setupTimingPattern: function () {
+ for (var r = 8; r < this.moduleCount - 8; r++) {
+ if (this.modules[r][6] != null) {
+ continue
+ }
+ this.modules[r][6] = r % 2 == 0
+ }
+ for (var c = 8; c < this.moduleCount - 8; c++) {
+ if (this.modules[6][c] != null) {
+ continue
+ }
+ this.modules[6][c] = c % 2 == 0
+ }
+ },
+ setupPositionAdjustPattern: function () {
+ var pos = QRUtil.getPatternPosition(this.typeNumber)
+ for (var i = 0; i < pos.length; i++) {
+ for (var j = 0; j < pos.length; j++) {
+ var row = pos[i]
+ var col = pos[j]
+ if (this.modules[row][col] != null) {
+ continue
+ }
+ for (var r = -2; r <= 2; r++) {
+ for (var c = -2; c <= 2; c++) {
+ if (
+ r == -2 ||
+ r == 2 ||
+ c == -2 ||
+ c == 2 ||
+ (r == 0 && c == 0)
+ ) {
+ this.modules[row + r][col + c] = true
+ } else {
+ this.modules[row + r][col + c] = false
+ }
+ }
+ }
+ }
+ }
+ },
+ setupTypeNumber: function (test) {
+ var bits = QRUtil.getBCHTypeNumber(this.typeNumber)
+ for (var i = 0; i < 18; i++) {
+ var mod = !test && ((bits >> i) & 1) == 1
+ this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod
+ }
+ for (var i = 0; i < 18; i++) {
+ var mod = !test && ((bits >> i) & 1) == 1
+ this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod
+ }
+ },
+ setupTypeInfo: function (test, maskPattern) {
+ var data = (this.errorCorrectLevel << 3) | maskPattern
+ var bits = QRUtil.getBCHTypeInfo(data)
+ for (var i = 0; i < 15; i++) {
+ var mod = !test && ((bits >> i) & 1) == 1
+ if (i < 6) {
+ this.modules[i][8] = mod
+ } else if (i < 8) {
+ this.modules[i + 1][8] = mod
+ } else {
+ this.modules[this.moduleCount - 15 + i][8] = mod
+ }
+ }
+ for (var i = 0; i < 15; i++) {
+ var mod = !test && ((bits >> i) & 1) == 1
+ if (i < 8) {
+ this.modules[8][this.moduleCount - i - 1] = mod
+ } else if (i < 9) {
+ this.modules[8][15 - i - 1 + 1] = mod
+ } else {
+ this.modules[8][15 - i - 1] = mod
+ }
+ }
+ this.modules[this.moduleCount - 8][8] = !test
+ },
+ mapData: function (data, maskPattern) {
+ var inc = -1
+ var row = this.moduleCount - 1
+ var bitIndex = 7
+ var byteIndex = 0
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
+ if (col == 6) col--
+ while (true) {
+ for (var c = 0; c < 2; c++) {
+ if (this.modules[row][col - c] == null) {
+ var dark = false
+ if (byteIndex < data.length) {
+ dark = ((data[byteIndex] >>> bitIndex) & 1) == 1
+ }
+ var mask = QRUtil.getMask(maskPattern, row, col - c)
+ if (mask) {
+ dark = !dark
+ }
+ this.modules[row][col - c] = dark
+ bitIndex--
+ if (bitIndex == -1) {
+ byteIndex++
+ bitIndex = 7
+ }
+ }
+ }
+ row += inc
+ if (row < 0 || this.moduleCount <= row) {
+ row -= inc
+ inc = -inc
+ break
+ }
+ }
+ }
+ }
+ }
+ QRCodeModel.PAD0 = 0xec
+ QRCodeModel.PAD1 = 0x11
+ QRCodeModel.createData = function (typeNumber, errorCorrectLevel, dataList) {
+ var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel)
+ var buffer = new QRBitBuffer()
+ for (var i = 0; i < dataList.length; i++) {
+ var data = dataList[i]
+ buffer.put(data.mode, 4)
+ buffer.put(
+ data.getLength(),
+ QRUtil.getLengthInBits(data.mode, typeNumber)
+ )
+ data.write(buffer)
+ }
+ var totalDataCount = 0
+ for (var i = 0; i < rsBlocks.length; i++) {
+ totalDataCount += rsBlocks[i].dataCount
+ }
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
+ throw new Error(
+ 'code length overflow. (' +
+ buffer.getLengthInBits() +
+ '>' +
+ totalDataCount * 8 +
+ ')'
+ )
+ }
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
+ buffer.put(0, 4)
+ }
+ while (buffer.getLengthInBits() % 8 != 0) {
+ buffer.putBit(false)
+ }
+ while (true) {
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
+ break
+ }
+ buffer.put(QRCodeModel.PAD0, 8)
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
+ break
+ }
+ buffer.put(QRCodeModel.PAD1, 8)
+ }
+ return QRCodeModel.createBytes(buffer, rsBlocks)
+ }
+ QRCodeModel.createBytes = function (buffer, rsBlocks) {
+ var offset = 0
+ var maxDcCount = 0
+ var maxEcCount = 0
+ var dcdata = new Array(rsBlocks.length)
+ var ecdata = new Array(rsBlocks.length)
+ for (var r = 0; r < rsBlocks.length; r++) {
+ var dcCount = rsBlocks[r].dataCount
+ var ecCount = rsBlocks[r].totalCount - dcCount
+ maxDcCount = Math.max(maxDcCount, dcCount)
+ maxEcCount = Math.max(maxEcCount, ecCount)
+ dcdata[r] = new Array(dcCount)
+ for (var i = 0; i < dcdata[r].length; i++) {
+ dcdata[r][i] = 0xff & buffer.buffer[i + offset]
+ }
+ offset += dcCount
+ var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount)
+ var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1)
+ var modPoly = rawPoly.mod(rsPoly)
+ ecdata[r] = new Array(rsPoly.getLength() - 1)
+ for (var i = 0; i < ecdata[r].length; i++) {
+ var modIndex = i + modPoly.getLength() - ecdata[r].length
+ ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0
+ }
+ }
+ var totalCodeCount = 0
+ for (var i = 0; i < rsBlocks.length; i++) {
+ totalCodeCount += rsBlocks[i].totalCount
+ }
+ var data = new Array(totalCodeCount)
+ var index = 0
+ for (var i = 0; i < maxDcCount; i++) {
+ for (var r = 0; r < rsBlocks.length; r++) {
+ if (i < dcdata[r].length) {
+ data[index++] = dcdata[r][i]
+ }
+ }
+ }
+ for (var i = 0; i < maxEcCount; i++) {
+ for (var r = 0; r < rsBlocks.length; r++) {
+ if (i < ecdata[r].length) {
+ data[index++] = ecdata[r][i]
+ }
+ }
+ }
+ return data
+ }
+ var QRMode = {
+ MODE_NUMBER: 1 << 0,
+ MODE_ALPHA_NUM: 1 << 1,
+ MODE_8BIT_BYTE: 1 << 2,
+ MODE_KANJI: 1 << 3
+ }
+ var QRErrorCorrectLevel = { L: 1, M: 0, Q: 3, H: 2 }
+ var QRMaskPattern = {
+ PATTERN000: 0,
+ PATTERN001: 1,
+ PATTERN010: 2,
+ PATTERN011: 3,
+ PATTERN100: 4,
+ PATTERN101: 5,
+ PATTERN110: 6,
+ PATTERN111: 7
+ }
+ var QRUtil = {
+ PATTERN_POSITION_TABLE: [
+ [],
+ [6, 18],
+ [6, 22],
+ [6, 26],
+ [6, 30],
+ [6, 34],
+ [6, 22, 38],
+ [6, 24, 42],
+ [6, 26, 46],
+ [6, 28, 50],
+ [6, 30, 54],
+ [6, 32, 58],
+ [6, 34, 62],
+ [6, 26, 46, 66],
+ [6, 26, 48, 70],
+ [6, 26, 50, 74],
+ [6, 30, 54, 78],
+ [6, 30, 56, 82],
+ [6, 30, 58, 86],
+ [6, 34, 62, 90],
+ [6, 28, 50, 72, 94],
+ [6, 26, 50, 74, 98],
+ [6, 30, 54, 78, 102],
+ [6, 28, 54, 80, 106],
+ [6, 32, 58, 84, 110],
+ [6, 30, 58, 86, 114],
+ [6, 34, 62, 90, 118],
+ [6, 26, 50, 74, 98, 122],
+ [6, 30, 54, 78, 102, 126],
+ [6, 26, 52, 78, 104, 130],
+ [6, 30, 56, 82, 108, 134],
+ [6, 34, 60, 86, 112, 138],
+ [6, 30, 58, 86, 114, 142],
+ [6, 34, 62, 90, 118, 146],
+ [6, 30, 54, 78, 102, 126, 150],
+ [6, 24, 50, 76, 102, 128, 154],
+ [6, 28, 54, 80, 106, 132, 158],
+ [6, 32, 58, 84, 110, 136, 162],
+ [6, 26, 54, 82, 110, 138, 166],
+ [6, 30, 58, 86, 114, 142, 170]
+ ],
+ G15:
+ (1 << 10) |
+ (1 << 8) |
+ (1 << 5) |
+ (1 << 4) |
+ (1 << 2) |
+ (1 << 1) |
+ (1 << 0),
+ G18:
+ (1 << 12) |
+ (1 << 11) |
+ (1 << 10) |
+ (1 << 9) |
+ (1 << 8) |
+ (1 << 5) |
+ (1 << 2) |
+ (1 << 0),
+ G15_MASK: (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
+ getBCHTypeInfo: function (data) {
+ var d = data << 10
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
+ d ^=
+ QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15))
+ }
+ return ((data << 10) | d) ^ QRUtil.G15_MASK
+ },
+ getBCHTypeNumber: function (data) {
+ var d = data << 12
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
+ d ^=
+ QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18))
+ }
+ return (data << 12) | d
+ },
+ getBCHDigit: function (data) {
+ var digit = 0
+ while (data != 0) {
+ digit++
+ data >>>= 1
+ }
+ return digit
+ },
+ getPatternPosition: function (typeNumber) {
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]
+ },
+ getMask: function (maskPattern, i, j) {
+ switch (maskPattern) {
+ case QRMaskPattern.PATTERN000:
+ return (i + j) % 2 == 0
+ case QRMaskPattern.PATTERN001:
+ return i % 2 == 0
+ case QRMaskPattern.PATTERN010:
+ return j % 3 == 0
+ case QRMaskPattern.PATTERN011:
+ return (i + j) % 3 == 0
+ case QRMaskPattern.PATTERN100:
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0
+ case QRMaskPattern.PATTERN101:
+ return (i * j) % 2 + (i * j) % 3 == 0
+ case QRMaskPattern.PATTERN110:
+ return ((i * j) % 2 + (i * j) % 3) % 2 == 0
+ case QRMaskPattern.PATTERN111:
+ return ((i * j) % 3 + (i + j) % 2) % 2 == 0
+ default:
+ throw new Error('bad maskPattern:' + maskPattern)
+ }
+ },
+ getErrorCorrectPolynomial: function (errorCorrectLength) {
+ var a = new QRPolynomial([1], 0)
+ for (var i = 0; i < errorCorrectLength; i++) {
+ a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0))
+ }
+ return a
+ },
+ getLengthInBits: function (mode, type) {
+ if (type >= 1 && type < 10) {
+ switch (mode) {
+ case QRMode.MODE_NUMBER:
+ return 10
+ case QRMode.MODE_ALPHA_NUM:
+ return 9
+ case QRMode.MODE_8BIT_BYTE:
+ return 8
+ case QRMode.MODE_KANJI:
+ return 8
+ default:
+ throw new Error('mode:' + mode)
+ }
+ } else if (type < 27) {
+ switch (mode) {
+ case QRMode.MODE_NUMBER:
+ return 12
+ case QRMode.MODE_ALPHA_NUM:
+ return 11
+ case QRMode.MODE_8BIT_BYTE:
+ return 16
+ case QRMode.MODE_KANJI:
+ return 10
+ default:
+ throw new Error('mode:' + mode)
+ }
+ } else if (type < 41) {
+ switch (mode) {
+ case QRMode.MODE_NUMBER:
+ return 14
+ case QRMode.MODE_ALPHA_NUM:
+ return 13
+ case QRMode.MODE_8BIT_BYTE:
+ return 16
+ case QRMode.MODE_KANJI:
+ return 12
+ default:
+ throw new Error('mode:' + mode)
+ }
+ } else {
+ throw new Error('type:' + type)
+ }
+ },
+ getLostPoint: function (qrCode) {
+ var moduleCount = qrCode.getModuleCount()
+ var lostPoint = 0
+ for (var row = 0; row < moduleCount; row++) {
+ for (var col = 0; col < moduleCount; col++) {
+ var sameCount = 0
+ var dark = qrCode.isDark(row, col)
+ for (var r = -1; r <= 1; r++) {
+ if (row + r < 0 || moduleCount <= row + r) {
+ continue
+ }
+ for (var c = -1; c <= 1; c++) {
+ if (col + c < 0 || moduleCount <= col + c) {
+ continue
+ }
+ if (r == 0 && c == 0) {
+ continue
+ }
+ if (dark == qrCode.isDark(row + r, col + c)) {
+ sameCount++
+ }
+ }
+ }
+ if (sameCount > 5) {
+ lostPoint += 3 + sameCount - 5
+ }
+ }
+ }
+ for (var row = 0; row < moduleCount - 1; row++) {
+ for (var col = 0; col < moduleCount - 1; col++) {
+ var count = 0
+ if (qrCode.isDark(row, col)) count++
+ if (qrCode.isDark(row + 1, col)) count++
+ if (qrCode.isDark(row, col + 1)) count++
+ if (qrCode.isDark(row + 1, col + 1)) count++
+ if (count == 0 || count == 4) {
+ lostPoint += 3
+ }
+ }
+ }
+ for (var row = 0; row < moduleCount; row++) {
+ for (var col = 0; col < moduleCount - 6; col++) {
+ if (
+ qrCode.isDark(row, col) &&
+ !qrCode.isDark(row, col + 1) &&
+ qrCode.isDark(row, col + 2) &&
+ qrCode.isDark(row, col + 3) &&
+ qrCode.isDark(row, col + 4) &&
+ !qrCode.isDark(row, col + 5) &&
+ qrCode.isDark(row, col + 6)
+ ) {
+ lostPoint += 40
+ }
+ }
+ }
+ for (var col = 0; col < moduleCount; col++) {
+ for (var row = 0; row < moduleCount - 6; row++) {
+ if (
+ qrCode.isDark(row, col) &&
+ !qrCode.isDark(row + 1, col) &&
+ qrCode.isDark(row + 2, col) &&
+ qrCode.isDark(row + 3, col) &&
+ qrCode.isDark(row + 4, col) &&
+ !qrCode.isDark(row + 5, col) &&
+ qrCode.isDark(row + 6, col)
+ ) {
+ lostPoint += 40
+ }
+ }
+ }
+ var darkCount = 0
+ for (var col = 0; col < moduleCount; col++) {
+ for (var row = 0; row < moduleCount; row++) {
+ if (qrCode.isDark(row, col)) {
+ darkCount++
+ }
+ }
+ }
+ var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5
+ lostPoint += ratio * 10
+ return lostPoint
+ }
+ }
+ var QRMath = {
+ glog: function (n) {
+ if (n < 1) {
+ throw new Error('glog(' + n + ')')
+ }
+ return QRMath.LOG_TABLE[n]
+ },
+ gexp: function (n) {
+ while (n < 0) {
+ n += 255
+ }
+ while (n >= 256) {
+ n -= 255
+ }
+ return QRMath.EXP_TABLE[n]
+ },
+ EXP_TABLE: new Array(256),
+ LOG_TABLE: new Array(256)
+ }
+ for (var i = 0; i < 8; i++) {
+ QRMath.EXP_TABLE[i] = 1 << i
+ }
+ for (var i = 8; i < 256; i++) {
+ QRMath.EXP_TABLE[i] =
+ QRMath.EXP_TABLE[i - 4] ^
+ QRMath.EXP_TABLE[i - 5] ^
+ QRMath.EXP_TABLE[i - 6] ^
+ QRMath.EXP_TABLE[i - 8]
+ }
+ for (var i = 0; i < 255; i++) {
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i
+ }
+ function QRPolynomial (num, shift) {
+ if (num.length == undefined) {
+ throw new Error(num.length + '/' + shift)
+ }
+ var offset = 0
+ while (offset < num.length && num[offset] == 0) {
+ offset++
+ }
+ this.num = new Array(num.length - offset + shift)
+ for (var i = 0; i < num.length - offset; i++) {
+ this.num[i] = num[i + offset]
+ }
+ }
+ QRPolynomial.prototype = {
+ get: function (index) {
+ return this.num[index]
+ },
+ getLength: function () {
+ return this.num.length
+ },
+ multiply: function (e) {
+ var num = new Array(this.getLength() + e.getLength() - 1)
+ for (var i = 0; i < this.getLength(); i++) {
+ for (var j = 0; j < e.getLength(); j++) {
+ num[i + j] ^= QRMath.gexp(
+ QRMath.glog(this.get(i)) + QRMath.glog(e.get(j))
+ )
+ }
+ }
+ return new QRPolynomial(num, 0)
+ },
+ mod: function (e) {
+ if (this.getLength() - e.getLength() < 0) {
+ return this
+ }
+ var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0))
+ var num = new Array(this.getLength())
+ for (var i = 0; i < this.getLength(); i++) {
+ num[i] = this.get(i)
+ }
+ for (var i = 0; i < e.getLength(); i++) {
+ num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio)
+ }
+ return new QRPolynomial(num, 0).mod(e)
+ }
+ }
+ function QRRSBlock (totalCount, dataCount) {
+ this.totalCount = totalCount
+ this.dataCount = dataCount
+ }
+ QRRSBlock.RS_BLOCK_TABLE = [
+ [1, 26, 19],
+ [1, 26, 16],
+ [1, 26, 13],
+ [1, 26, 9],
+ [1, 44, 34],
+ [1, 44, 28],
+ [1, 44, 22],
+ [1, 44, 16],
+ [1, 70, 55],
+ [1, 70, 44],
+ [2, 35, 17],
+ [2, 35, 13],
+ [1, 100, 80],
+ [2, 50, 32],
+ [2, 50, 24],
+ [4, 25, 9],
+ [1, 134, 108],
+ [2, 67, 43],
+ [2, 33, 15, 2, 34, 16],
+ [2, 33, 11, 2, 34, 12],
+ [2, 86, 68],
+ [4, 43, 27],
+ [4, 43, 19],
+ [4, 43, 15],
+ [2, 98, 78],
+ [4, 49, 31],
+ [2, 32, 14, 4, 33, 15],
+ [4, 39, 13, 1, 40, 14],
+ [2, 121, 97],
+ [2, 60, 38, 2, 61, 39],
+ [4, 40, 18, 2, 41, 19],
+ [4, 40, 14, 2, 41, 15],
+ [2, 146, 116],
+ [3, 58, 36, 2, 59, 37],
+ [4, 36, 16, 4, 37, 17],
+ [4, 36, 12, 4, 37, 13],
+ [2, 86, 68, 2, 87, 69],
+ [4, 69, 43, 1, 70, 44],
+ [6, 43, 19, 2, 44, 20],
+ [6, 43, 15, 2, 44, 16],
+ [4, 101, 81],
+ [1, 80, 50, 4, 81, 51],
+ [4, 50, 22, 4, 51, 23],
+ [3, 36, 12, 8, 37, 13],
+ [2, 116, 92, 2, 117, 93],
+ [6, 58, 36, 2, 59, 37],
+ [4, 46, 20, 6, 47, 21],
+ [7, 42, 14, 4, 43, 15],
+ [4, 133, 107],
+ [8, 59, 37, 1, 60, 38],
+ [8, 44, 20, 4, 45, 21],
+ [12, 33, 11, 4, 34, 12],
+ [3, 145, 115, 1, 146, 116],
+ [4, 64, 40, 5, 65, 41],
+ [11, 36, 16, 5, 37, 17],
+ [11, 36, 12, 5, 37, 13],
+ [5, 109, 87, 1, 110, 88],
+ [5, 65, 41, 5, 66, 42],
+ [5, 54, 24, 7, 55, 25],
+ [11, 36, 12],
+ [5, 122, 98, 1, 123, 99],
+ [7, 73, 45, 3, 74, 46],
+ [15, 43, 19, 2, 44, 20],
+ [3, 45, 15, 13, 46, 16],
+ [1, 135, 107, 5, 136, 108],
+ [10, 74, 46, 1, 75, 47],
+ [1, 50, 22, 15, 51, 23],
+ [2, 42, 14, 17, 43, 15],
+ [5, 150, 120, 1, 151, 121],
+ [9, 69, 43, 4, 70, 44],
+ [17, 50, 22, 1, 51, 23],
+ [2, 42, 14, 19, 43, 15],
+ [3, 141, 113, 4, 142, 114],
+ [3, 70, 44, 11, 71, 45],
+ [17, 47, 21, 4, 48, 22],
+ [9, 39, 13, 16, 40, 14],
+ [3, 135, 107, 5, 136, 108],
+ [3, 67, 41, 13, 68, 42],
+ [15, 54, 24, 5, 55, 25],
+ [15, 43, 15, 10, 44, 16],
+ [4, 144, 116, 4, 145, 117],
+ [17, 68, 42],
+ [17, 50, 22, 6, 51, 23],
+ [19, 46, 16, 6, 47, 17],
+ [2, 139, 111, 7, 140, 112],
+ [17, 74, 46],
+ [7, 54, 24, 16, 55, 25],
+ [34, 37, 13],
+ [4, 151, 121, 5, 152, 122],
+ [4, 75, 47, 14, 76, 48],
+ [11, 54, 24, 14, 55, 25],
+ [16, 45, 15, 14, 46, 16],
+ [6, 147, 117, 4, 148, 118],
+ [6, 73, 45, 14, 74, 46],
+ [11, 54, 24, 16, 55, 25],
+ [30, 46, 16, 2, 47, 17],
+ [8, 132, 106, 4, 133, 107],
+ [8, 75, 47, 13, 76, 48],
+ [7, 54, 24, 22, 55, 25],
+ [22, 45, 15, 13, 46, 16],
+ [10, 142, 114, 2, 143, 115],
+ [19, 74, 46, 4, 75, 47],
+ [28, 50, 22, 6, 51, 23],
+ [33, 46, 16, 4, 47, 17],
+ [8, 152, 122, 4, 153, 123],
+ [22, 73, 45, 3, 74, 46],
+ [8, 53, 23, 26, 54, 24],
+ [12, 45, 15, 28, 46, 16],
+ [3, 147, 117, 10, 148, 118],
+ [3, 73, 45, 23, 74, 46],
+ [4, 54, 24, 31, 55, 25],
+ [11, 45, 15, 31, 46, 16],
+ [7, 146, 116, 7, 147, 117],
+ [21, 73, 45, 7, 74, 46],
+ [1, 53, 23, 37, 54, 24],
+ [19, 45, 15, 26, 46, 16],
+ [5, 145, 115, 10, 146, 116],
+ [19, 75, 47, 10, 76, 48],
+ [15, 54, 24, 25, 55, 25],
+ [23, 45, 15, 25, 46, 16],
+ [13, 145, 115, 3, 146, 116],
+ [2, 74, 46, 29, 75, 47],
+ [42, 54, 24, 1, 55, 25],
+ [23, 45, 15, 28, 46, 16],
+ [17, 145, 115],
+ [10, 74, 46, 23, 75, 47],
+ [10, 54, 24, 35, 55, 25],
+ [19, 45, 15, 35, 46, 16],
+ [17, 145, 115, 1, 146, 116],
+ [14, 74, 46, 21, 75, 47],
+ [29, 54, 24, 19, 55, 25],
+ [11, 45, 15, 46, 46, 16],
+ [13, 145, 115, 6, 146, 116],
+ [14, 74, 46, 23, 75, 47],
+ [44, 54, 24, 7, 55, 25],
+ [59, 46, 16, 1, 47, 17],
+ [12, 151, 121, 7, 152, 122],
+ [12, 75, 47, 26, 76, 48],
+ [39, 54, 24, 14, 55, 25],
+ [22, 45, 15, 41, 46, 16],
+ [6, 151, 121, 14, 152, 122],
+ [6, 75, 47, 34, 76, 48],
+ [46, 54, 24, 10, 55, 25],
+ [2, 45, 15, 64, 46, 16],
+ [17, 152, 122, 4, 153, 123],
+ [29, 74, 46, 14, 75, 47],
+ [49, 54, 24, 10, 55, 25],
+ [24, 45, 15, 46, 46, 16],
+ [4, 152, 122, 18, 153, 123],
+ [13, 74, 46, 32, 75, 47],
+ [48, 54, 24, 14, 55, 25],
+ [42, 45, 15, 32, 46, 16],
+ [20, 147, 117, 4, 148, 118],
+ [40, 75, 47, 7, 76, 48],
+ [43, 54, 24, 22, 55, 25],
+ [10, 45, 15, 67, 46, 16],
+ [19, 148, 118, 6, 149, 119],
+ [18, 75, 47, 31, 76, 48],
+ [34, 54, 24, 34, 55, 25],
+ [20, 45, 15, 61, 46, 16]
+ ]
+ QRRSBlock.getRSBlocks = function (typeNumber, errorCorrectLevel) {
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel)
+ if (rsBlock == undefined) {
+ throw new Error(
+ 'bad rs block @ typeNumber:' +
+ typeNumber +
+ '/errorCorrectLevel:' +
+ errorCorrectLevel
+ )
+ }
+ var length = rsBlock.length / 3
+ var list = []
+ for (var i = 0; i < length; i++) {
+ var count = rsBlock[i * 3 + 0]
+ var totalCount = rsBlock[i * 3 + 1]
+ var dataCount = rsBlock[i * 3 + 2]
+ for (var j = 0; j < count; j++) {
+ list.push(new QRRSBlock(totalCount, dataCount))
+ }
+ }
+ return list
+ }
+ QRRSBlock.getRsBlockTable = function (typeNumber, errorCorrectLevel) {
+ switch (errorCorrectLevel) {
+ case QRErrorCorrectLevel.L:
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]
+ case QRErrorCorrectLevel.M:
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]
+ case QRErrorCorrectLevel.Q:
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]
+ case QRErrorCorrectLevel.H:
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]
+ default:
+ return undefined
+ }
+ }
+ function QRBitBuffer () {
+ this.buffer = []
+ this.length = 0
+ }
+ QRBitBuffer.prototype = {
+ get: function (index) {
+ var bufIndex = Math.floor(index / 8)
+ return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) == 1
+ },
+ put: function (num, length) {
+ for (var i = 0; i < length; i++) {
+ this.putBit(((num >>> (length - i - 1)) & 1) == 1)
+ }
+ },
+ getLengthInBits: function () {
+ return this.length
+ },
+ putBit: function (bit) {
+ var bufIndex = Math.floor(this.length / 8)
+ if (this.buffer.length <= bufIndex) {
+ this.buffer.push(0)
+ }
+ if (bit) {
+ this.buffer[bufIndex] |= 0x80 >>> (this.length % 8)
+ }
+ this.length++
+ }
+ }
+ var QRCodeLimitLength = [
+ [17, 14, 11, 7],
+ [32, 26, 20, 14],
+ [53, 42, 32, 24],
+ [78, 62, 46, 34],
+ [106, 84, 60, 44],
+ [134, 106, 74, 58],
+ [154, 122, 86, 64],
+ [192, 152, 108, 84],
+ [230, 180, 130, 98],
+ [271, 213, 151, 119],
+ [321, 251, 177, 137],
+ [367, 287, 203, 155],
+ [425, 331, 241, 177],
+ [458, 362, 258, 194],
+ [520, 412, 292, 220],
+ [586, 450, 322, 250],
+ [644, 504, 364, 280],
+ [718, 560, 394, 310],
+ [792, 624, 442, 338],
+ [858, 666, 482, 382],
+ [929, 711, 509, 403],
+ [1003, 779, 565, 439],
+ [1091, 857, 611, 461],
+ [1171, 911, 661, 511],
+ [1273, 997, 715, 535],
+ [1367, 1059, 751, 593],
+ [1465, 1125, 805, 625],
+ [1528, 1190, 868, 658],
+ [1628, 1264, 908, 698],
+ [1732, 1370, 982, 742],
+ [1840, 1452, 1030, 790],
+ [1952, 1538, 1112, 842],
+ [2068, 1628, 1168, 898],
+ [2188, 1722, 1228, 958],
+ [2303, 1809, 1283, 983],
+ [2431, 1911, 1351, 1051],
+ [2563, 1989, 1423, 1093],
+ [2699, 2099, 1499, 1139],
+ [2809, 2213, 1579, 1219],
+ [2953, 2331, 1663, 1273]
+ ]
+
+ function _isSupportCanvas () {
+ return typeof CanvasRenderingContext2D !== 'undefined'
+ }
+
+ // android 2.x doesn't support Data-URI spec
+ function _getAndroid () {
+ var android = false
+ var sAgent = navigator.userAgent
+
+ if (/android/i.test(sAgent)) {
+ // android
+ android = true
+ var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i)
+
+ if (aMat && aMat[1]) {
+ android = parseFloat(aMat[1])
+ }
+ }
+
+ return android
+ }
+
+ var svgDrawer = (function () {
+ var Drawing = function (el, htOption) {
+ this._el = el
+ this._htOption = htOption
+ }
+
+ Drawing.prototype.draw = function (oQRCode) {
+ var _htOption = this._htOption
+ var _el = this._el
+ var nCount = oQRCode.getModuleCount()
+ var nWidth = Math.floor(_htOption.width / nCount)
+ var nHeight = Math.floor(_htOption.height / nCount)
+
+ this.clear()
+
+ function makeSVG (tag, attrs) {
+ var el = document.createElementNS('http://www.w3.org/2000/svg', tag)
+ for (var k in attrs) {
+ if (attrs.hasOwnProperty(k)) el.setAttribute(k, attrs[k])
+ }
+ return el
+ }
+
+ var svg = makeSVG('svg', {
+ viewBox: '0 0 ' + String(nCount) + ' ' + String(nCount),
+ width: '100%',
+ height: '100%',
+ fill: _htOption.colorLight
+ })
+ svg.setAttributeNS(
+ 'http://www.w3.org/2000/xmlns/',
+ 'xmlns:xlink',
+ 'http://www.w3.org/1999/xlink'
+ )
+ _el.appendChild(svg)
+
+ svg.appendChild(
+ makeSVG('rect', {
+ fill: _htOption.colorLight,
+ width: '100%',
+ height: '100%'
+ })
+ )
+ svg.appendChild(
+ makeSVG('rect', {
+ fill: _htOption.colorDark,
+ width: '1',
+ height: '1',
+ id: 'template'
+ })
+ )
+
+ for (var row = 0; row < nCount; row++) {
+ for (var col = 0; col < nCount; col++) {
+ if (oQRCode.isDark(row, col)) {
+ var child = makeSVG('use', { x: String(col), y: String(row) })
+ child.setAttributeNS(
+ 'http://www.w3.org/1999/xlink',
+ 'href',
+ '#template'
+ )
+ svg.appendChild(child)
+ }
+ }
+ }
+ }
+ Drawing.prototype.clear = function () {
+ while (this._el.hasChildNodes()) this._el.removeChild(this._el.lastChild)
+ }
+ return Drawing
+ })()
+
+ var useSVG = document.documentElement.tagName.toLowerCase() === 'svg'
+
+ // Drawing in DOM by using Table tag
+ var Drawing = useSVG
+ ? svgDrawer
+ : !_isSupportCanvas()
+ ? (function () {
+ var Drawing = function (el, htOption) {
+ this._el = el
+ this._htOption = htOption
+ }
+
+ /**
+ * Draw the QRCode
+ *
+ * @param {QRCode} oQRCode
+ */
+ Drawing.prototype.draw = function (oQRCode) {
+ var _htOption = this._htOption
+ var _el = this._el
+ var nCount = oQRCode.getModuleCount()
+ var nWidth = Math.floor(_htOption.width / nCount)
+ var nHeight = Math.floor(_htOption.height / nCount)
+ var aHTML = ['<table style="border:0;border-collapse:collapse;">']
+
+ for (var row = 0; row < nCount; row++) {
+ aHTML.push('<tr>')
+
+ for (var col = 0; col < nCount; col++) {
+ aHTML.push(
+ '<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:' +
+ nWidth +
+ 'px;height:' +
+ nHeight +
+ 'px;background-color:' +
+ (oQRCode.isDark(row, col)
+ ? _htOption.colorDark
+ : _htOption.colorLight) +
+ ';"></td>'
+ )
+ }
+
+ aHTML.push('</tr>')
+ }
+
+ aHTML.push('</table>')
+ _el.innerHTML = aHTML.join('')
+
+ // Fix the margin values as real size.
+ var elTable = _el.childNodes[0]
+ var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2
+ var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2
+
+ if (nLeftMarginTable > 0 && nTopMarginTable > 0) {
+ elTable.style.margin =
+ nTopMarginTable + 'px ' + nLeftMarginTable + 'px'
+ }
+ }
+
+ /**
+ * Clear the QRCode
+ */
+ Drawing.prototype.clear = function () {
+ this._el.innerHTML = ''
+ }
+
+ return Drawing
+ })()
+ : (function () {
+ // Drawing in Canvas
+ function _onMakeImage () {
+ this._elImage.src = this._elCanvas.toDataURL('image/png')
+ this._elImage.style.display = 'block'
+ this._elCanvas.style.display = 'none'
+ }
+
+ // Android 2.1 bug workaround
+ // http://code.google.com/p/android/issues/detail?id=5141
+ if (this._android && this._android <= 2.1) {
+ var factor = 1 / window.devicePixelRatio
+ var drawImage = CanvasRenderingContext2D.prototype.drawImage
+ CanvasRenderingContext2D.prototype.drawImage = function (
+ image,
+ sx,
+ sy,
+ sw,
+ sh,
+ dx,
+ dy,
+ dw,
+ dh
+ ) {
+ if ('nodeName' in image && /img/i.test(image.nodeName)) {
+ for (var i = arguments.length - 1; i >= 1; i--) {
+ arguments[i] = arguments[i] * factor
+ }
+ } else if (typeof dw === 'undefined') {
+ arguments[1] *= factor
+ arguments[2] *= factor
+ arguments[3] *= factor
+ arguments[4] *= factor
+ }
+
+ drawImage.apply(this, arguments)
+ }
+ }
+
+ /**
+ * Check whether the user's browser supports Data URI or not
+ *
+ * @private
+ * @param {Function} fSuccess Occurs if it supports Data URI
+ * @param {Function} fFail Occurs if it doesn't support Data URI
+ */
+ function _safeSetDataURI (fSuccess, fFail) {
+ var self = this
+ self._fFail = fFail
+ self._fSuccess = fSuccess
+
+ // Check it just once
+ if (self._bSupportDataURI === null) {
+ var el = document.createElement('img')
+ var fOnError = function () {
+ self._bSupportDataURI = false
+
+ if (self._fFail) {
+ self._fFail.call(self)
+ }
+ }
+ var fOnSuccess = function () {
+ self._bSupportDataURI = true
+
+ if (self._fSuccess) {
+ self._fSuccess.call(self)
+ }
+ }
+
+ el.onabort = fOnError
+ el.onerror = fOnError
+ el.onload = fOnSuccess
+ el.src =
+ 'data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' // the Image contains 1px data.
+ } else if (self._bSupportDataURI === true && self._fSuccess) {
+ self._fSuccess.call(self)
+ } else if (self._bSupportDataURI === false && self._fFail) {
+ self._fFail.call(self)
+ }
+ }
+
+ /**
+ * Drawing QRCode by using canvas
+ *
+ * @constructor
+ * @param {HTMLElement} el
+ * @param {Object} htOption QRCode Options
+ */
+ var Drawing = function (el, htOption) {
+ this._bIsPainted = false
+ this._android = _getAndroid()
+
+ this._htOption = htOption
+ this._elCanvas = document.createElement('canvas')
+ this._elCanvas.width = htOption.width
+ this._elCanvas.height = htOption.height
+ el.appendChild(this._elCanvas)
+ this._el = el
+ this._oContext = this._elCanvas.getContext('2d')
+ this._bIsPainted = false
+ this._elImage = document.createElement('img')
+ this._elImage.alt = 'Scan me!'
+ this._elImage.style.display = 'none'
+ this._el.appendChild(this._elImage)
+ this._bSupportDataURI = null
+ }
+
+ /**
+ * Draw the QRCode
+ *
+ * @param {QRCode} oQRCode
+ */
+ Drawing.prototype.draw = function (oQRCode) {
+ var _elImage = this._elImage
+ var _oContext = this._oContext
+ var _htOption = this._htOption
+
+ var nCount = oQRCode.getModuleCount()
+ var nWidth = _htOption.width / nCount
+ var nHeight = _htOption.height / nCount
+ var nRoundedWidth = Math.round(nWidth)
+ var nRoundedHeight = Math.round(nHeight)
+
+ _elImage.style.display = 'none'
+ this.clear()
+
+ for (var row = 0; row < nCount; row++) {
+ for (var col = 0; col < nCount; col++) {
+ var bIsDark = oQRCode.isDark(row, col)
+ var nLeft = col * nWidth
+ var nTop = row * nHeight
+ _oContext.strokeStyle = bIsDark
+ ? _htOption.colorDark
+ : _htOption.colorLight
+ _oContext.lineWidth = 1
+ _oContext.fillStyle = bIsDark
+ ? _htOption.colorDark
+ : _htOption.colorLight
+ _oContext.fillRect(nLeft, nTop, nWidth, nHeight)
+
+ // 안티 앨리어싱 방지 처리
+ _oContext.strokeRect(
+ Math.floor(nLeft) + 0.5,
+ Math.floor(nTop) + 0.5,
+ nRoundedWidth,
+ nRoundedHeight
+ )
+
+ _oContext.strokeRect(
+ Math.ceil(nLeft) - 0.5,
+ Math.ceil(nTop) - 0.5,
+ nRoundedWidth,
+ nRoundedHeight
+ )
+ }
+ }
+
+ this._bIsPainted = true
+ }
+
+ /**
+ * Make the image from Canvas if the browser supports Data URI.
+ */
+ Drawing.prototype.makeImage = function () {
+ if (this._bIsPainted) {
+ _safeSetDataURI.call(this, _onMakeImage)
+ }
+ }
+
+ /**
+ * Return whether the QRCode is painted or not
+ *
+ * @return {Boolean}
+ */
+ Drawing.prototype.isPainted = function () {
+ return this._bIsPainted
+ }
+
+ /**
+ * Clear the QRCode
+ */
+ Drawing.prototype.clear = function () {
+ this._oContext.clearRect(
+ 0,
+ 0,
+ this._elCanvas.width,
+ this._elCanvas.height
+ )
+ this._bIsPainted = false
+ }
+
+ /**
+ * @private
+ * @param {Number} nNumber
+ */
+ Drawing.prototype.round = function (nNumber) {
+ if (!nNumber) {
+ return nNumber
+ }
+
+ return Math.floor(nNumber * 1000) / 1000
+ }
+
+ return Drawing
+ })()
+
+ /**
+ * Get the type by string length
+ *
+ * @private
+ * @param {String} sText
+ * @param {Number} nCorrectLevel
+ * @return {Number} type
+ */
+ function _getTypeNumber (sText, nCorrectLevel) {
+ var nType = 1
+ var length = _getUTF8Length(sText)
+
+ for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
+ var nLimit = 0
+
+ switch (nCorrectLevel) {
+ case QRErrorCorrectLevel.L:
+ nLimit = QRCodeLimitLength[i][0]
+ break
+ case QRErrorCorrectLevel.M:
+ nLimit = QRCodeLimitLength[i][1]
+ break
+ case QRErrorCorrectLevel.Q:
+ nLimit = QRCodeLimitLength[i][2]
+ break
+ case QRErrorCorrectLevel.H:
+ nLimit = QRCodeLimitLength[i][3]
+ break
+ }
+
+ if (length <= nLimit) {
+ break
+ } else {
+ nType++
+ }
+ }
+
+ if (nType > QRCodeLimitLength.length) {
+ throw new Error('Too long data')
+ }
+
+ return nType
+ }
+
+ function _getUTF8Length (sText) {
+ var replacedText = encodeURI(sText)
+ .toString()
+ .replace(/\%[0-9a-fA-F]{2}/g, 'a')
+ return replacedText.length + (replacedText.length != sText ? 3 : 0)
+ }
+
+ /**
+ * @class QRCode
+ * @constructor
+ * @example
+ * new QRCode(document.getElementById("test"), "http://jindo.dev.naver.com/collie");
+ *
+ * @example
+ * var oQRCode = new QRCode("test", {
+ * text : "http://naver.com",
+ * width : 128,
+ * height : 128
+ * });
+ *
+ * oQRCode.clear(); // Clear the QRCode.
+ * oQRCode.makeCode("http://map.naver.com"); // Re-create the QRCode.
+ *
+ * @param {HTMLElement|String} el target element or 'id' attribute of element.
+ * @param {Object|String} vOption
+ * @param {String} vOption.text QRCode link data
+ * @param {Number} [vOption.width=256]
+ * @param {Number} [vOption.height=256]
+ * @param {String} [vOption.colorDark="#000000"]
+ * @param {String} [vOption.colorLight="#ffffff"]
+ * @param {QRCode.CorrectLevel} [vOption.correctLevel=QRCode.CorrectLevel.H] [L|M|Q|H]
+ */
+ QRCode = function (el, vOption) {
+ this._htOption = {
+ width: 256,
+ height: 256,
+ typeNumber: 4,
+ colorDark: '#000000',
+ colorLight: '#ffffff',
+ correctLevel: QRErrorCorrectLevel.H
+ }
+
+ if (typeof vOption === 'string') {
+ vOption = {
+ text: vOption
+ }
+ }
+
+ // Overwrites options
+ if (vOption) {
+ for (var i in vOption) {
+ this._htOption[i] = vOption[i]
+ }
+ }
+
+ if (typeof el === 'string') {
+ el = document.getElementById(el)
+ }
+
+ if (this._htOption.useSVG) {
+ Drawing = svgDrawer
+ }
+
+ this._android = _getAndroid()
+ this._el = el
+ this._oQRCode = null
+ this._oDrawing = new Drawing(this._el, this._htOption)
+
+ if (this._htOption.text) {
+ this.makeCode(this._htOption.text)
+ }
+ }
+
+ /**
+ * Make the QRCode
+ *
+ * @param {String} sText link data
+ */
+ QRCode.prototype.makeCode = function (sText) {
+ this._oQRCode = new QRCodeModel(
+ _getTypeNumber(sText, this._htOption.correctLevel),
+ this._htOption.correctLevel
+ )
+ this._oQRCode.addData(sText)
+ this._oQRCode.make()
+ this._el.title = sText
+ this._oDrawing.draw(this._oQRCode)
+ this.makeImage()
+ }
+
+ /**
+ * Make the Image from Canvas element
+ * - It occurs automatically
+ * - Android below 3 doesn't support Data-URI spec.
+ *
+ * @private
+ */
+ QRCode.prototype.makeImage = function () {
+ if (
+ typeof this._oDrawing.makeImage === 'function' &&
+ (!this._android || this._android >= 3)
+ ) {
+ this._oDrawing.makeImage()
+ }
+ }
+
+ /**
+ * Clear the QRCode
+ */
+ QRCode.prototype.clear = function () {
+ this._oDrawing.clear()
+ }
+
+ /**
+ * @name QRCode.CorrectLevel
+ */
+ QRCode.CorrectLevel = QRErrorCorrectLevel
+})()
diff --git a/testing/web-platform/tests/tools/wave/www/lib/jszip.min.js b/testing/web-platform/tests/tools/wave/www/lib/jszip.min.js
new file mode 100644
index 0000000000..b9188736b7
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/jszip.min.js
@@ -0,0 +1,15 @@
+/*!
+
+JSZip v3.1.5 - A JavaScript class for generating and reading zip files
+<http://stuartk.com/jszip>
+
+(c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
+Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
+
+JSZip uses the library pako released under the MIT license :
+https://github.com/nodeca/pako/blob/master/LICENSE
+*/
+!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.JSZip=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";var d=a("./utils"),e=a("./support"),f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";c.encode=function(a){for(var b,c,e,g,h,i,j,k=[],l=0,m=a.length,n=m,o="string"!==d.getTypeOf(a);l<a.length;)n=m-l,o?(b=a[l++],c=l<m?a[l++]:0,e=l<m?a[l++]:0):(b=a.charCodeAt(l++),c=l<m?a.charCodeAt(l++):0,e=l<m?a.charCodeAt(l++):0),g=b>>2,h=(3&b)<<4|c>>4,i=n>1?(15&c)<<2|e>>6:64,j=n>2?63&e:64,k.push(f.charAt(g)+f.charAt(h)+f.charAt(i)+f.charAt(j));return k.join("")},c.decode=function(a){var b,c,d,g,h,i,j,k=0,l=0,m="data:";if(a.substr(0,m.length)===m)throw new Error("Invalid base64 input, it looks like a data url.");a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");var n=3*a.length/4;if(a.charAt(a.length-1)===f.charAt(64)&&n--,a.charAt(a.length-2)===f.charAt(64)&&n--,n%1!==0)throw new Error("Invalid base64 input, bad content length.");var o;for(o=e.uint8array?new Uint8Array(0|n):new Array(0|n);k<a.length;)g=f.indexOf(a.charAt(k++)),h=f.indexOf(a.charAt(k++)),i=f.indexOf(a.charAt(k++)),j=f.indexOf(a.charAt(k++)),b=g<<2|h>>4,c=(15&h)<<4|i>>2,d=(3&i)<<6|j,o[l++]=b,64!==i&&(o[l++]=c),64!==j&&(o[l++]=d);return o}},{"./support":30,"./utils":32}],2:[function(a,b,c){"use strict";function d(a,b,c,d,e){this.compressedSize=a,this.uncompressedSize=b,this.crc32=c,this.compression=d,this.compressedContent=e}var e=a("./external"),f=a("./stream/DataWorker"),g=a("./stream/DataLengthProbe"),h=a("./stream/Crc32Probe"),g=a("./stream/DataLengthProbe");d.prototype={getContentWorker:function(){var a=new f(e.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new g("data_length")),b=this;return a.on("end",function(){if(this.streamInfo.data_length!==b.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),a},getCompressedWorker:function(){return new f(e.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},d.createWorkerFrom=function(a,b,c){return a.pipe(new h).pipe(new g("uncompressedSize")).pipe(b.compressWorker(c)).pipe(new g("compressedSize")).withStreamInfo("compression",b)},b.exports=d},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(a,b,c){"use strict";var d=a("./stream/GenericWorker");c.STORE={magic:"\0\0",compressWorker:function(a){return new d("STORE compression")},uncompressWorker:function(){return new d("STORE decompression")}},c.DEFLATE=a("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(a,b,c){"use strict";function d(){for(var a,b=[],c=0;c<256;c++){a=c;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function e(a,b,c,d){var e=h,f=d+c;a^=-1;for(var g=d;g<f;g++)a=a>>>8^e[255&(a^b[g])];return a^-1}function f(a,b,c,d){var e=h,f=d+c;a^=-1;for(var g=d;g<f;g++)a=a>>>8^e[255&(a^b.charCodeAt(g))];return a^-1}var g=a("./utils"),h=d();b.exports=function(a,b){if("undefined"==typeof a||!a.length)return 0;var c="string"!==g.getTypeOf(a);return c?e(0|b,a,a.length,0):f(0|b,a,a.length,0)}},{"./utils":32}],5:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.createFolders=!0,c.date=null,c.compression=null,c.compressionOptions=null,c.comment=null,c.unixPermissions=null,c.dosPermissions=null},{}],6:[function(a,b,c){"use strict";var d=null;d="undefined"!=typeof Promise?Promise:a("lie"),b.exports={Promise:d}},{lie:58}],7:[function(a,b,c){"use strict";function d(a,b){h.call(this,"FlateWorker/"+a),this._pako=null,this._pakoAction=a,this._pakoOptions=b,this.meta={}}var e="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,f=a("pako"),g=a("./utils"),h=a("./stream/GenericWorker"),i=e?"uint8array":"array";c.magic="\b\0",g.inherits(d,h),d.prototype.processChunk=function(a){this.meta=a.meta,null===this._pako&&this._createPako(),this._pako.push(g.transformTo(i,a.data),!1)},d.prototype.flush=function(){h.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){h.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new f[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var a=this;this._pako.onData=function(b){a.push({data:b,meta:a.meta})}},c.compressWorker=function(a){return new d("Deflate",a)},c.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:59}],8:[function(a,b,c){"use strict";function d(a,b,c,d){f.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=b,this.zipPlatform=c,this.encodeFileName=d,this.streamFiles=a,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}var e=a("../utils"),f=a("../stream/GenericWorker"),g=a("../utf8"),h=a("../crc32"),i=a("../signature"),j=function(a,b){var c,d="";for(c=0;c<b;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},k=function(a,b){var c=a;return a||(c=b?16893:33204),(65535&c)<<16},l=function(a,b){return 63&(a||0)},m=function(a,b,c,d,f,m){var n,o,p=a.file,q=a.compression,r=m!==g.utf8encode,s=e.transformTo("string",m(p.name)),t=e.transformTo("string",g.utf8encode(p.name)),u=p.comment,v=e.transformTo("string",m(u)),w=e.transformTo("string",g.utf8encode(u)),x=t.length!==p.name.length,y=w.length!==u.length,z="",A="",B="",C=p.dir,D=p.date,E={crc32:0,compressedSize:0,uncompressedSize:0};b&&!c||(E.crc32=a.crc32,E.compressedSize=a.compressedSize,E.uncompressedSize=a.uncompressedSize);var F=0;b&&(F|=8),r||!x&&!y||(F|=2048);var G=0,H=0;C&&(G|=16),"UNIX"===f?(H=798,G|=k(p.unixPermissions,C)):(H=20,G|=l(p.dosPermissions,C)),n=D.getUTCHours(),n<<=6,n|=D.getUTCMinutes(),n<<=5,n|=D.getUTCSeconds()/2,o=D.getUTCFullYear()-1980,o<<=4,o|=D.getUTCMonth()+1,o<<=5,o|=D.getUTCDate(),x&&(A=j(1,1)+j(h(s),4)+t,z+="up"+j(A.length,2)+A),y&&(B=j(1,1)+j(h(v),4)+w,z+="uc"+j(B.length,2)+B);var I="";I+="\n\0",I+=j(F,2),I+=q.magic,I+=j(n,2),I+=j(o,2),I+=j(E.crc32,4),I+=j(E.compressedSize,4),I+=j(E.uncompressedSize,4),I+=j(s.length,2),I+=j(z.length,2);var J=i.LOCAL_FILE_HEADER+I+s+z,K=i.CENTRAL_FILE_HEADER+j(H,2)+I+j(v.length,2)+"\0\0\0\0"+j(G,4)+j(d,4)+s+z+v;return{fileRecord:J,dirRecord:K}},n=function(a,b,c,d,f){var g="",h=e.transformTo("string",f(d));return g=i.CENTRAL_DIRECTORY_END+"\0\0\0\0"+j(a,2)+j(a,2)+j(b,4)+j(c,4)+j(h.length,2)+h},o=function(a){var b="";return b=i.DATA_DESCRIPTOR+j(a.crc32,4)+j(a.compressedSize,4)+j(a.uncompressedSize,4)};e.inherits(d,f),d.prototype.push=function(a){var b=a.meta.percent||0,c=this.entriesCount,d=this._sources.length;this.accumulate?this.contentBuffer.push(a):(this.bytesWritten+=a.data.length,f.prototype.push.call(this,{data:a.data,meta:{currentFile:this.currentFile,percent:c?(b+100*(c-d-1))/c:100}}))},d.prototype.openedSource=function(a){this.currentSourceOffset=this.bytesWritten,this.currentFile=a.file.name;var b=this.streamFiles&&!a.file.dir;if(b){var c=m(a,b,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:c.fileRecord,meta:{percent:0}})}else this.accumulate=!0},d.prototype.closedSource=function(a){this.accumulate=!1;var b=this.streamFiles&&!a.file.dir,c=m(a,b,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(c.dirRecord),b)this.push({data:o(a),meta:{percent:100}});else for(this.push({data:c.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},d.prototype.flush=function(){for(var a=this.bytesWritten,b=0;b<this.dirRecords.length;b++)this.push({data:this.dirRecords[b],meta:{percent:100}});var c=this.bytesWritten-a,d=n(this.dirRecords.length,c,a,this.zipComment,this.encodeFileName);this.push({data:d,meta:{percent:100}})},d.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},d.prototype.registerPrevious=function(a){this._sources.push(a);var b=this;return a.on("data",function(a){b.processChunk(a)}),a.on("end",function(){b.closedSource(b.previous.streamInfo),b._sources.length?b.prepareNextSource():b.end()}),a.on("error",function(a){b.error(a)}),this},d.prototype.resume=function(){return!!f.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},d.prototype.error=function(a){var b=this._sources;if(!f.prototype.error.call(this,a))return!1;for(var c=0;c<b.length;c++)try{b[c].error(a)}catch(a){}return!0},d.prototype.lock=function(){f.prototype.lock.call(this);for(var a=this._sources,b=0;b<a.length;b++)a[b].lock()},b.exports=d},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(a,b,c){"use strict";var d=a("../compressions"),e=a("./ZipFileWorker"),f=function(a,b){var c=a||b,e=d[c];if(!e)throw new Error(c+" is not a valid compression method !");return e};c.generateWorker=function(a,b,c){var d=new e(b.streamFiles,c,b.platform,b.encodeFileName),g=0;try{a.forEach(function(a,c){g++;var e=f(c.options.compression,b.compression),h=c.options.compressionOptions||b.compressionOptions||{},i=c.dir,j=c.date;c._compressWorker(e,h).withStreamInfo("file",{name:a,dir:i,date:j,comment:c.comment||"",unixPermissions:c.unixPermissions,dosPermissions:c.dosPermissions}).pipe(d)}),d.entriesCount=g}catch(h){d.error(h)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(a,b,c){"use strict";function d(){if(!(this instanceof d))return new d;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files={},this.comment=null,this.root="",this.clone=function(){var a=new d;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a}}d.prototype=a("./object"),d.prototype.loadAsync=a("./load"),d.support=a("./support"),d.defaults=a("./defaults"),d.version="3.1.5",d.loadAsync=function(a,b){return(new d).loadAsync(a,b)},d.external=a("./external"),b.exports=d},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(a,b,c){"use strict";function d(a){return new f.Promise(function(b,c){var d=a.decompressed.getContentWorker().pipe(new i);d.on("error",function(a){c(a)}).on("end",function(){d.streamInfo.crc32!==a.decompressed.crc32?c(new Error("Corrupted zip : CRC32 mismatch")):b()}).resume()})}var e=a("./utils"),f=a("./external"),g=a("./utf8"),e=a("./utils"),h=a("./zipEntries"),i=a("./stream/Crc32Probe"),j=a("./nodejsUtils");b.exports=function(a,b){var c=this;return b=e.extend(b||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:g.utf8decode}),j.isNode&&j.isStream(a)?f.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):e.prepareContent("the loaded zip file",a,!0,b.optimizedBinaryString,b.base64).then(function(a){var c=new h(b);return c.load(a),c}).then(function(a){var c=[f.Promise.resolve(a)],e=a.files;if(b.checkCRC32)for(var g=0;g<e.length;g++)c.push(d(e[g]));return f.Promise.all(c)}).then(function(a){for(var d=a.shift(),e=d.files,f=0;f<e.length;f++){var g=e[f];c.file(g.fileNameStr,g.decompressed,{binary:!0,optimizedBinaryString:!0,date:g.date,dir:g.dir,comment:g.fileCommentStr.length?g.fileCommentStr:null,unixPermissions:g.unixPermissions,dosPermissions:g.dosPermissions,createFolders:b.createFolders})}return d.zipComment.length&&(c.comment=d.zipComment),c})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(a,b,c){"use strict";function d(a,b){f.call(this,"Nodejs stream input adapter for "+a),this._upstreamEnded=!1,this._bindStream(b)}var e=a("../utils"),f=a("../stream/GenericWorker");e.inherits(d,f),d.prototype._bindStream=function(a){var b=this;this._stream=a,a.pause(),a.on("data",function(a){b.push({data:a,meta:{percent:0}})}).on("error",function(a){b.isPaused?this.generatedError=a:b.error(a)}).on("end",function(){b.isPaused?b._upstreamEnded=!0:b.end()})},d.prototype.pause=function(){return!!f.prototype.pause.call(this)&&(this._stream.pause(),!0)},d.prototype.resume=function(){return!!f.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},b.exports=d},{"../stream/GenericWorker":28,"../utils":32}],13:[function(a,b,c){"use strict";function d(a,b,c){e.call(this,b),this._helper=a;var d=this;a.on("data",function(a,b){d.push(a)||d._helper.pause(),c&&c(b)}).on("error",function(a){d.emit("error",a)}).on("end",function(){d.push(null)})}var e=a("readable-stream").Readable,f=a("../utils");f.inherits(d,e),d.prototype._read=function(){this._helper.resume()},b.exports=d},{"../utils":32,"readable-stream":16}],14:[function(a,b,c){"use strict";b.exports={isNode:"undefined"!=typeof Buffer,newBufferFrom:function(a,b){return new Buffer(a,b)},allocBuffer:function(a){return Buffer.alloc?Buffer.alloc(a):new Buffer(a)},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&"function"==typeof a.on&&"function"==typeof a.pause&&"function"==typeof a.resume}}},{}],15:[function(a,b,c){"use strict";function d(a){return"[object RegExp]"===Object.prototype.toString.call(a)}var e=a("./utf8"),f=a("./utils"),g=a("./stream/GenericWorker"),h=a("./stream/StreamHelper"),i=a("./defaults"),j=a("./compressedObject"),k=a("./zipObject"),l=a("./generate"),m=a("./nodejsUtils"),n=a("./nodejs/NodejsStreamInputAdapter"),o=function(a,b,c){var d,e=f.getTypeOf(b),h=f.extend(c||{},i);h.date=h.date||new Date,null!==h.compression&&(h.compression=h.compression.toUpperCase()),"string"==typeof h.unixPermissions&&(h.unixPermissions=parseInt(h.unixPermissions,8)),h.unixPermissions&&16384&h.unixPermissions&&(h.dir=!0),h.dosPermissions&&16&h.dosPermissions&&(h.dir=!0),h.dir&&(a=q(a)),h.createFolders&&(d=p(a))&&r.call(this,d,!0);var l="string"===e&&h.binary===!1&&h.base64===!1;c&&"undefined"!=typeof c.binary||(h.binary=!l);var o=b instanceof j&&0===b.uncompressedSize;(o||h.dir||!b||0===b.length)&&(h.base64=!1,h.binary=!0,b="",h.compression="STORE",e="string");var s=null;s=b instanceof j||b instanceof g?b:m.isNode&&m.isStream(b)?new n(a,b):f.prepareContent(a,b,h.binary,h.optimizedBinaryString,h.base64);var t=new k(a,s,h);this.files[a]=t},p=function(a){"/"===a.slice(-1)&&(a=a.substring(0,a.length-1));var b=a.lastIndexOf("/");return b>0?a.substring(0,b):""},q=function(a){return"/"!==a.slice(-1)&&(a+="/"),a},r=function(a,b){return b="undefined"!=typeof b?b:i.createFolders,a=q(a),this.files[a]||o.call(this,a,null,{dir:!0,createFolders:b}),this.files[a]},s={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(a){var b,c,d;for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],c=b.slice(this.root.length,b.length),c&&b.slice(0,this.root.length)===this.root&&a(c,d))},filter:function(a){var b=[];return this.forEach(function(c,d){a(c,d)&&b.push(d)}),b},file:function(a,b,c){if(1===arguments.length){if(d(a)){var e=a;return this.filter(function(a,b){return!b.dir&&e.test(a)})}var f=this.files[this.root+a];return f&&!f.dir?f:null}return a=this.root+a,o.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(d(a))return this.filter(function(b,c){return c.dir&&a.test(b)});var b=this.root+a,c=r.call(this,b),e=this.clone();return e.root=c.name,e},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!==a.slice(-1)&&(a+="/"),b=this.files[a]),b&&!b.dir)delete this.files[a];else for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;d<c.length;d++)delete this.files[c[d].name];return this},generate:function(a){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(a){var b,c={};try{if(c=f.extend(a||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:e.utf8encode}),c.type=c.type.toLowerCase(),c.compression=c.compression.toUpperCase(),"binarystring"===c.type&&(c.type="string"),!c.type)throw new Error("No output type specified.");f.checkSupport(c.type),"darwin"!==c.platform&&"freebsd"!==c.platform&&"linux"!==c.platform&&"sunos"!==c.platform||(c.platform="UNIX"),"win32"===c.platform&&(c.platform="DOS");var d=c.comment||this.comment||"";b=l.generateWorker(this,c,d)}catch(i){b=new g("error"),b.error(i)}return new h(b,c.type||"string",c.mimeType)},generateAsync:function(a,b){return this.generateInternalStream(a).accumulate(b)},generateNodeStream:function(a,b){return a=a||{},a.type||(a.type="nodebuffer"),this.generateInternalStream(a).toNodejsStream(b)}};b.exports=s},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(a,b,c){b.exports=a("stream")},{stream:void 0}],17:[function(a,b,c){"use strict";function d(a){e.call(this,a);for(var b=0;b<this.data.length;b++)a[b]=255&a[b]}var e=a("./DataReader"),f=a("../utils");f.inherits(d,e),d.prototype.byteAt=function(a){return this.data[this.zero+a]},d.prototype.lastIndexOfSignature=function(a){for(var b=a.charCodeAt(0),c=a.charCodeAt(1),d=a.charCodeAt(2),e=a.charCodeAt(3),f=this.length-4;f>=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f-this.zero;return-1},d.prototype.readAndCheckSignature=function(a){var b=a.charCodeAt(0),c=a.charCodeAt(1),d=a.charCodeAt(2),e=a.charCodeAt(3),f=this.readData(4);return b===f[0]&&c===f[1]&&d===f[2]&&e===f[3]},d.prototype.readData=function(a){if(this.checkOffset(a),0===a)return[];var b=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,b},b.exports=d},{"../utils":32,"./DataReader":18}],18:[function(a,b,c){"use strict";function d(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}var e=a("../utils");d.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(a){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return e.transformTo("string",this.readData(a))},readData:function(a){},lastIndexOfSignature:function(a){},readAndCheckSignature:function(a){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},b.exports=d},{"../utils":32}],19:[function(a,b,c){"use strict";function d(a){e.call(this,a)}var e=a("./Uint8ArrayReader"),f=a("../utils");f.inherits(d,e),d.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,b},b.exports=d},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(a,b,c){"use strict";function d(a){e.call(this,a)}var e=a("./DataReader"),f=a("../utils");f.inherits(d,e),d.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},d.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},d.prototype.readAndCheckSignature=function(a){var b=this.readData(4);return a===b},d.prototype.readData=function(a){this.checkOffset(a);var b=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,b},b.exports=d},{"../utils":32,"./DataReader":18}],21:[function(a,b,c){"use strict";function d(a){e.call(this,a)}var e=a("./ArrayReader"),f=a("../utils");f.inherits(d,e),d.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var b=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,b},b.exports=d},{"../utils":32,"./ArrayReader":17}],22:[function(a,b,c){"use strict";var d=a("../utils"),e=a("../support"),f=a("./ArrayReader"),g=a("./StringReader"),h=a("./NodeBufferReader"),i=a("./Uint8ArrayReader");b.exports=function(a){var b=d.getTypeOf(a);return d.checkSupport(b),"string"!==b||e.uint8array?"nodebuffer"===b?new h(a):e.uint8array?new i(d.transformTo("uint8array",a)):new f(d.transformTo("array",a)):new g(a)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(a,b,c){"use strict";c.LOCAL_FILE_HEADER="PK",c.CENTRAL_FILE_HEADER="PK",c.CENTRAL_DIRECTORY_END="PK",c.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK",c.ZIP64_CENTRAL_DIRECTORY_END="PK",c.DATA_DESCRIPTOR="PK\b"},{}],24:[function(a,b,c){"use strict";function d(a){e.call(this,"ConvertWorker to "+a),this.destType=a}var e=a("./GenericWorker"),f=a("../utils");f.inherits(d,e),d.prototype.processChunk=function(a){this.push({data:f.transformTo(this.destType,a.data),meta:a.meta})},b.exports=d},{"../utils":32,"./GenericWorker":28}],25:[function(a,b,c){"use strict";function d(){e.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}var e=a("./GenericWorker"),f=a("../crc32"),g=a("../utils");g.inherits(d,e),d.prototype.processChunk=function(a){this.streamInfo.crc32=f(a.data,this.streamInfo.crc32||0),this.push(a)},b.exports=d},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(a,b,c){"use strict";function d(a){f.call(this,"DataLengthProbe for "+a),this.propName=a,this.withStreamInfo(a,0)}var e=a("../utils"),f=a("./GenericWorker");e.inherits(d,f),d.prototype.processChunk=function(a){if(a){var b=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=b+a.data.length}f.prototype.processChunk.call(this,a)},b.exports=d},{"../utils":32,"./GenericWorker":28}],27:[function(a,b,c){"use strict";function d(a){f.call(this,"DataWorker");var b=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,a.then(function(a){b.dataIsReady=!0,b.data=a,b.max=a&&a.length||0,b.type=e.getTypeOf(a),b.isPaused||b._tickAndRepeat()},function(a){b.error(a)})}var e=a("../utils"),f=a("./GenericWorker"),g=16384;e.inherits(d,f),d.prototype.cleanUp=function(){f.prototype.cleanUp.call(this),this.data=null},d.prototype.resume=function(){return!!f.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,e.delay(this._tickAndRepeat,[],this)),!0)},d.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(e.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},d.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var a=g,b=null,c=Math.min(this.max,this.index+a);if(this.index>=this.max)return this.end();switch(this.type){case"string":b=this.data.substring(this.index,c);break;case"uint8array":b=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":b=this.data.slice(this.index,c)}return this.index=c,this.push({data:b,meta:{percent:this.max?this.index/this.max*100:0}})},b.exports=d},{"../utils":32,"./GenericWorker":28}],28:[function(a,b,c){"use strict";function d(a){this.name=a||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}d.prototype={push:function(a){this.emit("data",a)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(a){this.emit("error",a)}return!0},error:function(a){return!this.isFinished&&(this.isPaused?this.generatedError=a:(this.isFinished=!0,this.emit("error",a),this.previous&&this.previous.error(a),this.cleanUp()),!0)},on:function(a,b){return this._listeners[a].push(b),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(a,b){if(this._listeners[a])for(var c=0;c<this._listeners[a].length;c++)this._listeners[a][c].call(this,b)},pipe:function(a){return a.registerPrevious(this)},registerPrevious:function(a){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=a.streamInfo,this.mergeStreamInfo(),this.previous=a;var b=this;return a.on("data",function(a){b.processChunk(a)}),a.on("end",function(){b.end()}),a.on("error",function(a){b.error(a)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var a=!1;return this.generatedError&&(this.error(this.generatedError),a=!0),this.previous&&this.previous.resume(),!a},flush:function(){},processChunk:function(a){this.push(a)},withStreamInfo:function(a,b){return this.extraStreamInfo[a]=b,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var a in this.extraStreamInfo)this.extraStreamInfo.hasOwnProperty(a)&&(this.streamInfo[a]=this.extraStreamInfo[a])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var a="Worker "+this.name;return this.previous?this.previous+" -> "+a:a}},b.exports=d},{}],29:[function(a,b,c){"use strict";function d(a,b,c){switch(a){case"blob":return h.newBlob(h.transformTo("arraybuffer",b),c);case"base64":return k.encode(b);default:return h.transformTo(a,b)}}function e(a,b){var c,d=0,e=null,f=0;for(c=0;c<b.length;c++)f+=b[c].length;switch(a){case"string":return b.join("");case"array":return Array.prototype.concat.apply([],b);case"uint8array":for(e=new Uint8Array(f),c=0;c<b.length;c++)e.set(b[c],d),d+=b[c].length;return e;case"nodebuffer":return Buffer.concat(b);default:throw new Error("concat : unsupported type '"+a+"'")}}function f(a,b){return new m.Promise(function(c,f){var g=[],h=a._internalType,i=a._outputType,j=a._mimeType;a.on("data",function(a,c){g.push(a),b&&b(c)}).on("error",function(a){g=[],f(a)}).on("end",function(){try{var a=d(i,e(h,g),j);c(a)}catch(b){f(b)}g=[]}).resume()})}function g(a,b,c){var d=b;switch(b){case"blob":case"arraybuffer":d="uint8array";break;case"base64":d="string"}try{this._internalType=d,this._outputType=b,this._mimeType=c,h.checkSupport(d),this._worker=a.pipe(new i(d)),a.lock()}catch(e){this._worker=new j("error"),this._worker.error(e)}}var h=a("../utils"),i=a("./ConvertWorker"),j=a("./GenericWorker"),k=a("../base64"),l=a("../support"),m=a("../external"),n=null;if(l.nodestream)try{n=a("../nodejs/NodejsStreamOutputAdapter")}catch(o){}g.prototype={accumulate:function(a){return f(this,a)},on:function(a,b){var c=this;return"data"===a?this._worker.on(a,function(a){b.call(c,a.data,a.meta)}):this._worker.on(a,function(){h.delay(b,arguments,c)}),this},resume:function(){return h.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(a){if(h.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new n(this,{objectMode:"nodebuffer"!==this._outputType},a)}},b.exports=g},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(a,b,c){"use strict";if(c.base64=!0,c.array=!0,c.string=!0,c.arraybuffer="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,c.nodebuffer="undefined"!=typeof Buffer,c.uint8array="undefined"!=typeof Uint8Array,"undefined"==typeof ArrayBuffer)c.blob=!1;else{var d=new ArrayBuffer(0);try{c.blob=0===new Blob([d],{type:"application/zip"}).size}catch(e){try{var f=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,g=new f;g.append(d),c.blob=0===g.getBlob("application/zip").size}catch(e){c.blob=!1}}}try{c.nodestream=!!a("readable-stream").Readable}catch(e){c.nodestream=!1}},{"readable-stream":16}],31:[function(a,b,c){"use strict";function d(){i.call(this,"utf-8 decode"),this.leftOver=null}function e(){i.call(this,"utf-8 encode")}for(var f=a("./utils"),g=a("./support"),h=a("./nodejsUtils"),i=a("./stream/GenericWorker"),j=new Array(256),k=0;k<256;k++)j[k]=k>=252?6:k>=248?5:k>=240?4:k>=224?3:k>=192?2:1;j[254]=j[254]=1;var l=function(a){var b,c,d,e,f,h=a.length,i=0;for(e=0;e<h;e++)c=a.charCodeAt(e),55296===(64512&c)&&e+1<h&&(d=a.charCodeAt(e+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),e++)),i+=c<128?1:c<2048?2:c<65536?3:4;for(b=g.uint8array?new Uint8Array(i):new Array(i),f=0,e=0;f<i;e++)c=a.charCodeAt(e),55296===(64512&c)&&e+1<h&&(d=a.charCodeAt(e+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),e++)),c<128?b[f++]=c:c<2048?(b[f++]=192|c>>>6,b[f++]=128|63&c):c<65536?(b[f++]=224|c>>>12,b[f++]=128|c>>>6&63,b[f++]=128|63&c):(b[f++]=240|c>>>18,b[f++]=128|c>>>12&63,b[f++]=128|c>>>6&63,b[f++]=128|63&c);return b},m=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return c<0?b:0===c?b:c+j[a[c]]>b?c:b},n=function(a){var b,c,d,e,g=a.length,h=new Array(2*g);for(c=0,b=0;b<g;)if(d=a[b++],d<128)h[c++]=d;else if(e=j[d],e>4)h[c++]=65533,b+=e-1;else{for(d&=2===e?31:3===e?15:7;e>1&&b<g;)d=d<<6|63&a[b++],e--;e>1?h[c++]=65533:d<65536?h[c++]=d:(d-=65536,h[c++]=55296|d>>10&1023,h[c++]=56320|1023&d)}return h.length!==c&&(h.subarray?h=h.subarray(0,c):h.length=c),f.applyFromCharCode(h)};c.utf8encode=function(a){return g.nodebuffer?h.newBufferFrom(a,"utf-8"):l(a)},c.utf8decode=function(a){return g.nodebuffer?f.transformTo("nodebuffer",a).toString("utf-8"):(a=f.transformTo(g.uint8array?"uint8array":"array",a),n(a))},f.inherits(d,i),d.prototype.processChunk=function(a){var b=f.transformTo(g.uint8array?"uint8array":"array",a.data);if(this.leftOver&&this.leftOver.length){if(g.uint8array){var d=b;b=new Uint8Array(d.length+this.leftOver.length),b.set(this.leftOver,0),b.set(d,this.leftOver.length)}else b=this.leftOver.concat(b);this.leftOver=null}var e=m(b),h=b;e!==b.length&&(g.uint8array?(h=b.subarray(0,e),this.leftOver=b.subarray(e,b.length)):(h=b.slice(0,e),this.leftOver=b.slice(e,b.length))),this.push({data:c.utf8decode(h),meta:a.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:c.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},c.Utf8DecodeWorker=d,f.inherits(e,i),e.prototype.processChunk=function(a){this.push({data:c.utf8encode(a.data),meta:a.meta})},c.Utf8EncodeWorker=e},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(a,b,c){"use strict";function d(a){var b=null;return b=i.uint8array?new Uint8Array(a.length):new Array(a.length),f(a,b)}function e(a){return a}function f(a,b){for(var c=0;c<a.length;++c)b[c]=255&a.charCodeAt(c);return b}function g(a){var b=65536,d=c.getTypeOf(a),e=!0;if("uint8array"===d?e=n.applyCanBeUsed.uint8array:"nodebuffer"===d&&(e=n.applyCanBeUsed.nodebuffer),e)for(;b>1;)try{return n.stringifyByChunk(a,d,b)}catch(f){b=Math.floor(b/2)}return n.stringifyByChar(a)}function h(a,b){for(var c=0;c<a.length;c++)b[c]=a[c];
+return b}var i=a("./support"),j=a("./base64"),k=a("./nodejsUtils"),l=a("core-js/library/fn/set-immediate"),m=a("./external");c.newBlob=function(a,b){c.checkSupport("blob");try{return new Blob([a],{type:b})}catch(d){try{var e=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,f=new e;return f.append(a),f.getBlob(b)}catch(d){throw new Error("Bug : can't construct the Blob.")}}};var n={stringifyByChunk:function(a,b,c){var d=[],e=0,f=a.length;if(f<=c)return String.fromCharCode.apply(null,a);for(;e<f;)"array"===b||"nodebuffer"===b?d.push(String.fromCharCode.apply(null,a.slice(e,Math.min(e+c,f)))):d.push(String.fromCharCode.apply(null,a.subarray(e,Math.min(e+c,f)))),e+=c;return d.join("")},stringifyByChar:function(a){for(var b="",c=0;c<a.length;c++)b+=String.fromCharCode(a[c]);return b},applyCanBeUsed:{uint8array:function(){try{return i.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch(a){return!1}}(),nodebuffer:function(){try{return i.nodebuffer&&1===String.fromCharCode.apply(null,k.allocBuffer(1)).length}catch(a){return!1}}()}};c.applyFromCharCode=g;var o={};o.string={string:e,array:function(a){return f(a,new Array(a.length))},arraybuffer:function(a){return o.string.uint8array(a).buffer},uint8array:function(a){return f(a,new Uint8Array(a.length))},nodebuffer:function(a){return f(a,k.allocBuffer(a.length))}},o.array={string:g,array:e,arraybuffer:function(a){return new Uint8Array(a).buffer},uint8array:function(a){return new Uint8Array(a)},nodebuffer:function(a){return k.newBufferFrom(a)}},o.arraybuffer={string:function(a){return g(new Uint8Array(a))},array:function(a){return h(new Uint8Array(a),new Array(a.byteLength))},arraybuffer:e,uint8array:function(a){return new Uint8Array(a)},nodebuffer:function(a){return k.newBufferFrom(new Uint8Array(a))}},o.uint8array={string:g,array:function(a){return h(a,new Array(a.length))},arraybuffer:function(a){return a.buffer},uint8array:e,nodebuffer:function(a){return k.newBufferFrom(a)}},o.nodebuffer={string:g,array:function(a){return h(a,new Array(a.length))},arraybuffer:function(a){return o.nodebuffer.uint8array(a).buffer},uint8array:function(a){return h(a,new Uint8Array(a.length))},nodebuffer:e},c.transformTo=function(a,b){if(b||(b=""),!a)return b;c.checkSupport(a);var d=c.getTypeOf(b),e=o[d][a](b);return e},c.getTypeOf=function(a){return"string"==typeof a?"string":"[object Array]"===Object.prototype.toString.call(a)?"array":i.nodebuffer&&k.isBuffer(a)?"nodebuffer":i.uint8array&&a instanceof Uint8Array?"uint8array":i.arraybuffer&&a instanceof ArrayBuffer?"arraybuffer":void 0},c.checkSupport=function(a){var b=i[a.toLowerCase()];if(!b)throw new Error(a+" is not supported by this platform")},c.MAX_VALUE_16BITS=65535,c.MAX_VALUE_32BITS=-1,c.pretty=function(a){var b,c,d="";for(c=0;c<(a||"").length;c++)b=a.charCodeAt(c),d+="\\x"+(b<16?"0":"")+b.toString(16).toUpperCase();return d},c.delay=function(a,b,c){l(function(){a.apply(c||null,b||[])})},c.inherits=function(a,b){var c=function(){};c.prototype=b.prototype,a.prototype=new c},c.extend=function(){var a,b,c={};for(a=0;a<arguments.length;a++)for(b in arguments[a])arguments[a].hasOwnProperty(b)&&"undefined"==typeof c[b]&&(c[b]=arguments[a][b]);return c},c.prepareContent=function(a,b,e,f,g){var h=m.Promise.resolve(b).then(function(a){var b=i.blob&&(a instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(a))!==-1);return b&&"undefined"!=typeof FileReader?new m.Promise(function(b,c){var d=new FileReader;d.onload=function(a){b(a.target.result)},d.onerror=function(a){c(a.target.error)},d.readAsArrayBuffer(a)}):a});return h.then(function(b){var h=c.getTypeOf(b);return h?("arraybuffer"===h?b=c.transformTo("uint8array",b):"string"===h&&(g?b=j.decode(b):e&&f!==!0&&(b=d(b))),b):m.Promise.reject(new Error("Can't read the data of '"+a+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,"core-js/library/fn/set-immediate":36}],33:[function(a,b,c){"use strict";function d(a){this.files=[],this.loadOptions=a}var e=a("./reader/readerFor"),f=a("./utils"),g=a("./signature"),h=a("./zipEntry"),i=(a("./utf8"),a("./support"));d.prototype={checkSignature:function(a){if(!this.reader.readAndCheckSignature(a)){this.reader.index-=4;var b=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+f.pretty(b)+", expected "+f.pretty(a)+")")}},isSignature:function(a,b){var c=this.reader.index;this.reader.setIndex(a);var d=this.reader.readString(4),e=d===b;return this.reader.setIndex(c),e},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var a=this.reader.readData(this.zipCommentLength),b=i.uint8array?"uint8array":"array",c=f.transformTo(b,a);this.zipComment=this.loadOptions.decodeFileName(c)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;e<d;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readData(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a<this.files.length;a++)b=this.files[a],this.reader.setIndex(b.localHeaderOffset),this.checkSignature(g.LOCAL_FILE_HEADER),b.readLocalPart(this.reader),b.handleUTF8(),b.processAttributes()},readCentralDir:function(){var a;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(g.CENTRAL_FILE_HEADER);)a=new h({zip64:this.zip64},this.loadOptions),a.readCentralPart(this.reader),this.files.push(a);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var a=this.reader.lastIndexOfSignature(g.CENTRAL_DIRECTORY_END);if(a<0){var b=!this.isSignature(0,g.LOCAL_FILE_HEADER);throw b?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory")}this.reader.setIndex(a);var c=a;if(this.checkSignature(g.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===f.MAX_VALUE_16BITS||this.diskWithCentralDirStart===f.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===f.MAX_VALUE_16BITS||this.centralDirRecords===f.MAX_VALUE_16BITS||this.centralDirSize===f.MAX_VALUE_32BITS||this.centralDirOffset===f.MAX_VALUE_32BITS){if(this.zip64=!0,a=this.reader.lastIndexOfSignature(g.ZIP64_CENTRAL_DIRECTORY_LOCATOR),a<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(a),this.checkSignature(g.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,g.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(g.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(g.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var e=c-d;if(e>0)this.isSignature(c,g.CENTRAL_FILE_HEADER)||(this.reader.zero=e);else if(e<0)throw new Error("Corrupted zip: missing "+Math.abs(e)+" bytes.")},prepareReader:function(a){this.reader=e(a)},load:function(a){this.prepareReader(a),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},b.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utf8":31,"./utils":32,"./zipEntry":34}],34:[function(a,b,c){"use strict";function d(a,b){this.options=a,this.loadOptions=b}var e=a("./reader/readerFor"),f=a("./utils"),g=a("./compressedObject"),h=a("./crc32"),i=a("./utf8"),j=a("./compressions"),k=a("./support"),l=0,m=3,n=function(a){for(var b in j)if(j.hasOwnProperty(b)&&j[b].magic===a)return j[b];return null};d.prototype={isEncrypted:function(){return 1===(1&this.bitFlag)},useUTF8:function(){return 2048===(2048&this.bitFlag)},readLocalPart:function(a){var b,c;if(a.skip(22),this.fileNameLength=a.readInt(2),c=a.readInt(2),this.fileName=a.readData(this.fileNameLength),a.skip(c),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(b=n(this.compressionMethod),null===b)throw new Error("Corrupted zip : compression "+f.pretty(this.compressionMethod)+" unknown (inner file : "+f.transformTo("string",this.fileName)+")");this.decompressed=new g(this.compressedSize,this.uncompressedSize,this.crc32,b,a.readData(this.compressedSize))},readCentralPart:function(a){this.versionMadeBy=a.readInt(2),a.skip(2),this.bitFlag=a.readInt(2),this.compressionMethod=a.readString(2),this.date=a.readDate(),this.crc32=a.readInt(4),this.compressedSize=a.readInt(4),this.uncompressedSize=a.readInt(4);var b=a.readInt(2);if(this.extraFieldsLength=a.readInt(2),this.fileCommentLength=a.readInt(2),this.diskNumberStart=a.readInt(2),this.internalFileAttributes=a.readInt(2),this.externalFileAttributes=a.readInt(4),this.localHeaderOffset=a.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");a.skip(b),this.readExtraFields(a),this.parseZIP64ExtraField(a),this.fileComment=a.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var a=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),a===l&&(this.dosPermissions=63&this.externalFileAttributes),a===m&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(a){if(this.extraFields[1]){var b=e(this.extraFields[1].value);this.uncompressedSize===f.MAX_VALUE_32BITS&&(this.uncompressedSize=b.readInt(8)),this.compressedSize===f.MAX_VALUE_32BITS&&(this.compressedSize=b.readInt(8)),this.localHeaderOffset===f.MAX_VALUE_32BITS&&(this.localHeaderOffset=b.readInt(8)),this.diskNumberStart===f.MAX_VALUE_32BITS&&(this.diskNumberStart=b.readInt(4))}},readExtraFields:function(a){var b,c,d,e=a.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});a.index<e;)b=a.readInt(2),c=a.readInt(2),d=a.readData(c),this.extraFields[b]={id:b,length:c,value:d}},handleUTF8:function(){var a=k.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=i.utf8decode(this.fileName),this.fileCommentStr=i.utf8decode(this.fileComment);else{var b=this.findExtraFieldUnicodePath();if(null!==b)this.fileNameStr=b;else{var c=f.transformTo(a,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(c)}var d=this.findExtraFieldUnicodeComment();if(null!==d)this.fileCommentStr=d;else{var e=f.transformTo(a,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(e)}}},findExtraFieldUnicodePath:function(){var a=this.extraFields[28789];if(a){var b=e(a.value);return 1!==b.readInt(1)?null:h(this.fileName)!==b.readInt(4)?null:i.utf8decode(b.readData(a.length-5))}return null},findExtraFieldUnicodeComment:function(){var a=this.extraFields[25461];if(a){var b=e(a.value);return 1!==b.readInt(1)?null:h(this.fileComment)!==b.readInt(4)?null:i.utf8decode(b.readData(a.length-5))}return null}},b.exports=d},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(a,b,c){"use strict";var d=a("./stream/StreamHelper"),e=a("./stream/DataWorker"),f=a("./utf8"),g=a("./compressedObject"),h=a("./stream/GenericWorker"),i=function(a,b,c){this.name=a,this.dir=c.dir,this.date=c.date,this.comment=c.comment,this.unixPermissions=c.unixPermissions,this.dosPermissions=c.dosPermissions,this._data=b,this._dataBinary=c.binary,this.options={compression:c.compression,compressionOptions:c.compressionOptions}};i.prototype={internalStream:function(a){var b=null,c="string";try{if(!a)throw new Error("No output type specified.");c=a.toLowerCase();var e="string"===c||"text"===c;"binarystring"!==c&&"text"!==c||(c="string"),b=this._decompressWorker();var g=!this._dataBinary;g&&!e&&(b=b.pipe(new f.Utf8EncodeWorker)),!g&&e&&(b=b.pipe(new f.Utf8DecodeWorker))}catch(i){b=new h("error"),b.error(i)}return new d(b,c,"")},async:function(a,b){return this.internalStream(a).accumulate(b)},nodeStream:function(a,b){return this.internalStream(a||"nodebuffer").toNodejsStream(b)},_compressWorker:function(a,b){if(this._data instanceof g&&this._data.compression.magic===a.magic)return this._data.getCompressedWorker();var c=this._decompressWorker();return this._dataBinary||(c=c.pipe(new f.Utf8EncodeWorker)),g.createWorkerFrom(c,a,b)},_decompressWorker:function(){return this._data instanceof g?this._data.getContentWorker():this._data instanceof h?this._data:new e(this._data)}};for(var j=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],k=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},l=0;l<j.length;l++)i.prototype[j[l]]=k;b.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(a,b,c){a("../modules/web.immediate"),b.exports=a("../modules/_core").setImmediate},{"../modules/_core":40,"../modules/web.immediate":56}],37:[function(a,b,c){b.exports=function(a){if("function"!=typeof a)throw TypeError(a+" is not a function!");return a}},{}],38:[function(a,b,c){var d=a("./_is-object");b.exports=function(a){if(!d(a))throw TypeError(a+" is not an object!");return a}},{"./_is-object":51}],39:[function(a,b,c){var d={}.toString;b.exports=function(a){return d.call(a).slice(8,-1)}},{}],40:[function(a,b,c){var d=b.exports={version:"2.3.0"};"number"==typeof __e&&(__e=d)},{}],41:[function(a,b,c){var d=a("./_a-function");b.exports=function(a,b,c){if(d(a),void 0===b)return a;switch(c){case 1:return function(c){return a.call(b,c)};case 2:return function(c,d){return a.call(b,c,d)};case 3:return function(c,d,e){return a.call(b,c,d,e)}}return function(){return a.apply(b,arguments)}}},{"./_a-function":37}],42:[function(a,b,c){b.exports=!a("./_fails")(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a})},{"./_fails":45}],43:[function(a,b,c){var d=a("./_is-object"),e=a("./_global").document,f=d(e)&&d(e.createElement);b.exports=function(a){return f?e.createElement(a):{}}},{"./_global":46,"./_is-object":51}],44:[function(a,b,c){var d=a("./_global"),e=a("./_core"),f=a("./_ctx"),g=a("./_hide"),h="prototype",i=function(a,b,c){var j,k,l,m=a&i.F,n=a&i.G,o=a&i.S,p=a&i.P,q=a&i.B,r=a&i.W,s=n?e:e[b]||(e[b]={}),t=s[h],u=n?d:o?d[b]:(d[b]||{})[h];n&&(c=b);for(j in c)k=!m&&u&&void 0!==u[j],k&&j in s||(l=k?u[j]:c[j],s[j]=n&&"function"!=typeof u[j]?c[j]:q&&k?f(l,d):r&&u[j]==l?function(a){var b=function(b,c,d){if(this instanceof a){switch(arguments.length){case 0:return new a;case 1:return new a(b);case 2:return new a(b,c)}return new a(b,c,d)}return a.apply(this,arguments)};return b[h]=a[h],b}(l):p&&"function"==typeof l?f(Function.call,l):l,p&&((s.virtual||(s.virtual={}))[j]=l,a&i.R&&t&&!t[j]&&g(t,j,l)))};i.F=1,i.G=2,i.S=4,i.P=8,i.B=16,i.W=32,i.U=64,i.R=128,b.exports=i},{"./_core":40,"./_ctx":41,"./_global":46,"./_hide":47}],45:[function(a,b,c){b.exports=function(a){try{return!!a()}catch(b){return!0}}},{}],46:[function(a,b,c){var d=b.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=d)},{}],47:[function(a,b,c){var d=a("./_object-dp"),e=a("./_property-desc");b.exports=a("./_descriptors")?function(a,b,c){return d.f(a,b,e(1,c))}:function(a,b,c){return a[b]=c,a}},{"./_descriptors":42,"./_object-dp":52,"./_property-desc":53}],48:[function(a,b,c){b.exports=a("./_global").document&&document.documentElement},{"./_global":46}],49:[function(a,b,c){b.exports=!a("./_descriptors")&&!a("./_fails")(function(){return 7!=Object.defineProperty(a("./_dom-create")("div"),"a",{get:function(){return 7}}).a})},{"./_descriptors":42,"./_dom-create":43,"./_fails":45}],50:[function(a,b,c){b.exports=function(a,b,c){var d=void 0===c;switch(b.length){case 0:return d?a():a.call(c);case 1:return d?a(b[0]):a.call(c,b[0]);case 2:return d?a(b[0],b[1]):a.call(c,b[0],b[1]);case 3:return d?a(b[0],b[1],b[2]):a.call(c,b[0],b[1],b[2]);case 4:return d?a(b[0],b[1],b[2],b[3]):a.call(c,b[0],b[1],b[2],b[3])}return a.apply(c,b)}},{}],51:[function(a,b,c){b.exports=function(a){return"object"==typeof a?null!==a:"function"==typeof a}},{}],52:[function(a,b,c){var d=a("./_an-object"),e=a("./_ie8-dom-define"),f=a("./_to-primitive"),g=Object.defineProperty;c.f=a("./_descriptors")?Object.defineProperty:function(a,b,c){if(d(a),b=f(b,!0),d(c),e)try{return g(a,b,c)}catch(h){}if("get"in c||"set"in c)throw TypeError("Accessors not supported!");return"value"in c&&(a[b]=c.value),a}},{"./_an-object":38,"./_descriptors":42,"./_ie8-dom-define":49,"./_to-primitive":55}],53:[function(a,b,c){b.exports=function(a,b){return{enumerable:!(1&a),configurable:!(2&a),writable:!(4&a),value:b}}},{}],54:[function(a,b,c){var d,e,f,g=a("./_ctx"),h=a("./_invoke"),i=a("./_html"),j=a("./_dom-create"),k=a("./_global"),l=k.process,m=k.setImmediate,n=k.clearImmediate,o=k.MessageChannel,p=0,q={},r="onreadystatechange",s=function(){var a=+this;if(q.hasOwnProperty(a)){var b=q[a];delete q[a],b()}},t=function(a){s.call(a.data)};m&&n||(m=function(a){for(var b=[],c=1;arguments.length>c;)b.push(arguments[c++]);return q[++p]=function(){h("function"==typeof a?a:Function(a),b)},d(p),p},n=function(a){delete q[a]},"process"==a("./_cof")(l)?d=function(a){l.nextTick(g(s,a,1))}:o?(e=new o,f=e.port2,e.port1.onmessage=t,d=g(f.postMessage,f,1)):k.addEventListener&&"function"==typeof postMessage&&!k.importScripts?(d=function(a){k.postMessage(a+"","*")},k.addEventListener("message",t,!1)):d=r in j("script")?function(a){i.appendChild(j("script"))[r]=function(){i.removeChild(this),s.call(a)}}:function(a){setTimeout(g(s,a,1),0)}),b.exports={set:m,clear:n}},{"./_cof":39,"./_ctx":41,"./_dom-create":43,"./_global":46,"./_html":48,"./_invoke":50}],55:[function(a,b,c){var d=a("./_is-object");b.exports=function(a,b){if(!d(a))return a;var c,e;if(b&&"function"==typeof(c=a.toString)&&!d(e=c.call(a)))return e;if("function"==typeof(c=a.valueOf)&&!d(e=c.call(a)))return e;if(!b&&"function"==typeof(c=a.toString)&&!d(e=c.call(a)))return e;throw TypeError("Can't convert object to primitive value")}},{"./_is-object":51}],56:[function(a,b,c){var d=a("./_export"),e=a("./_task");d(d.G+d.B,{setImmediate:e.set,clearImmediate:e.clear})},{"./_export":44,"./_task":54}],57:[function(a,b,c){(function(a){"use strict";function c(){k=!0;for(var a,b,c=l.length;c;){for(b=l,l=[],a=-1;++a<c;)b[a]();c=l.length}k=!1}function d(a){1!==l.push(a)||k||e()}var e,f=a.MutationObserver||a.WebKitMutationObserver;if(f){var g=0,h=new f(c),i=a.document.createTextNode("");h.observe(i,{characterData:!0}),e=function(){i.data=g=++g%2}}else if(a.setImmediate||"undefined"==typeof a.MessageChannel)e="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var b=a.document.createElement("script");b.onreadystatechange=function(){c(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a.document.documentElement.appendChild(b)}:function(){setTimeout(c,0)};else{var j=new a.MessageChannel;j.port1.onmessage=c,e=function(){j.port2.postMessage(0)}}var k,l=[];b.exports=d}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],58:[function(a,b,c){"use strict";function d(){}function e(a){if("function"!=typeof a)throw new TypeError("resolver must be a function");this.state=s,this.queue=[],this.outcome=void 0,a!==d&&i(this,a)}function f(a,b,c){this.promise=a,"function"==typeof b&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),"function"==typeof c&&(this.onRejected=c,this.callRejected=this.otherCallRejected)}function g(a,b,c){o(function(){var d;try{d=b(c)}catch(e){return p.reject(a,e)}d===a?p.reject(a,new TypeError("Cannot resolve promise with itself")):p.resolve(a,d)})}function h(a){var b=a&&a.then;if(a&&("object"==typeof a||"function"==typeof a)&&"function"==typeof b)return function(){b.apply(a,arguments)}}function i(a,b){function c(b){f||(f=!0,p.reject(a,b))}function d(b){f||(f=!0,p.resolve(a,b))}function e(){b(d,c)}var f=!1,g=j(e);"error"===g.status&&c(g.value)}function j(a,b){var c={};try{c.value=a(b),c.status="success"}catch(d){c.status="error",c.value=d}return c}function k(a){return a instanceof this?a:p.resolve(new this(d),a)}function l(a){var b=new this(d);return p.reject(b,a)}function m(a){function b(a,b){function d(a){g[b]=a,++h!==e||f||(f=!0,p.resolve(j,g))}c.resolve(a).then(d,function(a){f||(f=!0,p.reject(j,a))})}var c=this;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(new TypeError("must be an array"));var e=a.length,f=!1;if(!e)return this.resolve([]);for(var g=new Array(e),h=0,i=-1,j=new this(d);++i<e;)b(a[i],i);return j}function n(a){function b(a){c.resolve(a).then(function(a){f||(f=!0,p.resolve(h,a))},function(a){f||(f=!0,p.reject(h,a))})}var c=this;if("[object Array]"!==Object.prototype.toString.call(a))return this.reject(new TypeError("must be an array"));var e=a.length,f=!1;if(!e)return this.resolve([]);for(var g=-1,h=new this(d);++g<e;)b(a[g]);return h}var o=a("immediate"),p={},q=["REJECTED"],r=["FULFILLED"],s=["PENDING"];b.exports=e,e.prototype["catch"]=function(a){return this.then(null,a)},e.prototype.then=function(a,b){if("function"!=typeof a&&this.state===r||"function"!=typeof b&&this.state===q)return this;var c=new this.constructor(d);if(this.state!==s){var e=this.state===r?a:b;g(c,e,this.outcome)}else this.queue.push(new f(c,a,b));return c},f.prototype.callFulfilled=function(a){p.resolve(this.promise,a)},f.prototype.otherCallFulfilled=function(a){g(this.promise,this.onFulfilled,a)},f.prototype.callRejected=function(a){p.reject(this.promise,a)},f.prototype.otherCallRejected=function(a){g(this.promise,this.onRejected,a)},p.resolve=function(a,b){var c=j(h,b);if("error"===c.status)return p.reject(a,c.value);var d=c.value;if(d)i(a,d);else{a.state=r,a.outcome=b;for(var e=-1,f=a.queue.length;++e<f;)a.queue[e].callFulfilled(b)}return a},p.reject=function(a,b){a.state=q,a.outcome=b;for(var c=-1,d=a.queue.length;++c<d;)a.queue[c].callRejected(b);return a},e.resolve=k,e.reject=l,e.all=m,e.race=n},{immediate:57}],59:[function(a,b,c){"use strict";var d=a("./lib/utils/common").assign,e=a("./lib/deflate"),f=a("./lib/inflate"),g=a("./lib/zlib/constants"),h={};d(h,e,f,g),b.exports=h},{"./lib/deflate":60,"./lib/inflate":61,"./lib/utils/common":62,"./lib/zlib/constants":65}],60:[function(a,b,c){"use strict";function d(a){if(!(this instanceof d))return new d(a);this.options=i.assign({level:s,method:u,chunkSize:16384,windowBits:15,memLevel:8,strategy:t,to:""},a||{});var b=this.options;b.raw&&b.windowBits>0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var c=h.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(c!==p)throw new Error(k[c]);if(b.header&&h.deflateSetHeader(this.strm,b.header),b.dictionary){var e;if(e="string"==typeof b.dictionary?j.string2buf(b.dictionary):"[object ArrayBuffer]"===m.call(b.dictionary)?new Uint8Array(b.dictionary):b.dictionary,c=h.deflateSetDictionary(this.strm,e),c!==p)throw new Error(k[c]);this._dict_set=!0}}function e(a,b){var c=new d(b);if(c.push(a,!0),c.err)throw c.msg||k[c.err];return c.result}function f(a,b){return b=b||{},b.raw=!0,e(a,b)}function g(a,b){return b=b||{},b.gzip=!0,e(a,b)}var h=a("./zlib/deflate"),i=a("./utils/common"),j=a("./utils/strings"),k=a("./zlib/messages"),l=a("./zlib/zstream"),m=Object.prototype.toString,n=0,o=4,p=0,q=1,r=2,s=-1,t=0,u=8;d.prototype.push=function(a,b){var c,d,e=this.strm,f=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?o:n,"string"==typeof a?e.input=j.string2buf(a):"[object ArrayBuffer]"===m.call(a)?e.input=new Uint8Array(a):e.input=a,e.next_in=0,e.avail_in=e.input.length;do{if(0===e.avail_out&&(e.output=new i.Buf8(f),e.next_out=0,e.avail_out=f),c=h.deflate(e,d),c!==q&&c!==p)return this.onEnd(c),this.ended=!0,!1;0!==e.avail_out&&(0!==e.avail_in||d!==o&&d!==r)||("string"===this.options.to?this.onData(j.buf2binstring(i.shrinkBuf(e.output,e.next_out))):this.onData(i.shrinkBuf(e.output,e.next_out)))}while((e.avail_in>0||0===e.avail_out)&&c!==q);return d===o?(c=h.deflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===p):d!==r||(this.onEnd(p),e.avail_out=0,!0)},d.prototype.onData=function(a){this.chunks.push(a)},d.prototype.onEnd=function(a){a===p&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=i.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Deflate=d,c.deflate=e,c.deflateRaw=f,c.gzip=g},{"./utils/common":62,"./utils/strings":63,"./zlib/deflate":67,"./zlib/messages":72,"./zlib/zstream":74}],61:[function(a,b,c){"use strict";function d(a){if(!(this instanceof d))return new d(a);this.options=h.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new l,this.strm.avail_out=0;var c=g.inflateInit2(this.strm,b.windowBits);if(c!==j.Z_OK)throw new Error(k[c]);this.header=new m,g.inflateGetHeader(this.strm,this.header)}function e(a,b){var c=new d(b);if(c.push(a,!0),c.err)throw c.msg||k[c.err];return c.result}function f(a,b){return b=b||{},b.raw=!0,e(a,b)}var g=a("./zlib/inflate"),h=a("./utils/common"),i=a("./utils/strings"),j=a("./zlib/constants"),k=a("./zlib/messages"),l=a("./zlib/zstream"),m=a("./zlib/gzheader"),n=Object.prototype.toString;d.prototype.push=function(a,b){var c,d,e,f,k,l,m=this.strm,o=this.options.chunkSize,p=this.options.dictionary,q=!1;if(this.ended)return!1;d=b===~~b?b:b===!0?j.Z_FINISH:j.Z_NO_FLUSH,"string"==typeof a?m.input=i.binstring2buf(a):"[object ArrayBuffer]"===n.call(a)?m.input=new Uint8Array(a):m.input=a,m.next_in=0,m.avail_in=m.input.length;do{if(0===m.avail_out&&(m.output=new h.Buf8(o),m.next_out=0,m.avail_out=o),c=g.inflate(m,j.Z_NO_FLUSH),c===j.Z_NEED_DICT&&p&&(l="string"==typeof p?i.string2buf(p):"[object ArrayBuffer]"===n.call(p)?new Uint8Array(p):p,c=g.inflateSetDictionary(this.strm,l)),c===j.Z_BUF_ERROR&&q===!0&&(c=j.Z_OK,q=!1),c!==j.Z_STREAM_END&&c!==j.Z_OK)return this.onEnd(c),this.ended=!0,!1;m.next_out&&(0!==m.avail_out&&c!==j.Z_STREAM_END&&(0!==m.avail_in||d!==j.Z_FINISH&&d!==j.Z_SYNC_FLUSH)||("string"===this.options.to?(e=i.utf8border(m.output,m.next_out),f=m.next_out-e,k=i.buf2string(m.output,e),m.next_out=f,m.avail_out=o-f,f&&h.arraySet(m.output,m.output,e,f,0),this.onData(k)):this.onData(h.shrinkBuf(m.output,m.next_out)))),0===m.avail_in&&0===m.avail_out&&(q=!0)}while((m.avail_in>0||0===m.avail_out)&&c!==j.Z_STREAM_END);return c===j.Z_STREAM_END&&(d=j.Z_FINISH),d===j.Z_FINISH?(c=g.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===j.Z_OK):d!==j.Z_SYNC_FLUSH||(this.onEnd(j.Z_OK),m.avail_out=0,!0)},d.prototype.onData=function(a){this.chunks.push(a)},d.prototype.onEnd=function(a){a===j.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=h.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=d,c.inflate=e,c.inflateRaw=f,c.ungzip=e},{"./utils/common":62,"./utils/strings":63,"./zlib/constants":65,"./zlib/gzheader":68,"./zlib/inflate":70,"./zlib/messages":72,"./zlib/zstream":74}],62:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;c.assign=function(a){for(var b=Array.prototype.slice.call(arguments,1);b.length;){var c=b.shift();if(c){if("object"!=typeof c)throw new TypeError(c+"must be non-object");for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}}return a},c.shrinkBuf=function(a,b){return a.length===b?a:a.subarray?a.subarray(0,b):(a.length=b,a)};var e={arraySet:function(a,b,c,d,e){if(b.subarray&&a.subarray)return void a.set(b.subarray(c,c+d),e);for(var f=0;f<d;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;b<c;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;b<c;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;f<d;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],63:[function(a,b,c){"use strict";function d(a,b){if(b<65537&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;d<b;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;j<256;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;f<h;f++)c=a.charCodeAt(f),55296===(64512&c)&&f+1<h&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=c<128?1:c<2048?2:c<65536?3:4;for(b=new e.Buf8(i),g=0,f=0;g<i;f++)c=a.charCodeAt(f),55296===(64512&c)&&f+1<h&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),c<128?b[g++]=c:c<2048?(b[g++]=192|c>>>6,b[g++]=128|63&c):c<65536?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;c<d;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;c<h;)if(f=a[c++],f<128)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&c<h;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:f<65536?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return c<0?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":62}],64:[function(a,b,c){"use strict";function d(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0;
+}b.exports=d},{}],65:[function(a,b,c){"use strict";b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],66:[function(a,b,c){"use strict";function d(){for(var a,b=[],c=0;c<256;c++){a=c;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function e(a,b,c,d){var e=f,g=d+c;a^=-1;for(var h=d;h<g;h++)a=a>>>8^e[255&(a^b[h])];return a^-1}var f=d();b.exports=e},{}],67:[function(a,b,c){"use strict";function d(a,b){return a.msg=I[b],b}function e(a){return(a<<1)-(a>4?9:0)}function f(a){for(var b=a.length;--b>=0;)a[b]=0}function g(a){var b=a.state,c=b.pending;c>a.avail_out&&(c=a.avail_out),0!==c&&(E.arraySet(a.output,b.pending_buf,b.pending_out,c,a.next_out),a.next_out+=c,b.pending_out+=c,a.total_out+=c,a.avail_out-=c,b.pending-=c,0===b.pending&&(b.pending_out=0))}function h(a,b){F._tr_flush_block(a,a.block_start>=0?a.block_start:-1,a.strstart-a.block_start,b),a.block_start=a.strstart,g(a.strm)}function i(a,b){a.pending_buf[a.pending++]=b}function j(a,b){a.pending_buf[a.pending++]=b>>>8&255,a.pending_buf[a.pending++]=255&b}function k(a,b,c,d){var e=a.avail_in;return e>d&&(e=d),0===e?0:(a.avail_in-=e,E.arraySet(b,a.input,a.next_in,e,c),1===a.state.wrap?a.adler=G(a.adler,b,e,c):2===a.state.wrap&&(a.adler=H(a.adler,b,e,c)),a.next_in+=e,a.total_in+=e,e)}function l(a,b){var c,d,e=a.max_chain_length,f=a.strstart,g=a.prev_length,h=a.nice_match,i=a.strstart>a.w_size-la?a.strstart-(a.w_size-la):0,j=a.window,k=a.w_mask,l=a.prev,m=a.strstart+ka,n=j[f+g-1],o=j[f+g];a.prev_length>=a.good_match&&(e>>=2),h>a.lookahead&&(h=a.lookahead);do if(c=b,j[c+g]===o&&j[c+g-1]===n&&j[c]===j[f]&&j[++c]===j[f+1]){f+=2,c++;do;while(j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&f<m);if(d=ka-(m-f),f=m-ka,d>g){if(a.match_start=b,g=d,d>=h)break;n=j[f+g-1],o=j[f+g]}}while((b=l[b&k])>i&&0!==--e);return g<=a.lookahead?g:a.lookahead}function m(a){var b,c,d,e,f,g=a.w_size;do{if(e=a.window_size-a.lookahead-a.strstart,a.strstart>=g+(g-la)){E.arraySet(a.window,a.window,g,g,0),a.match_start-=g,a.strstart-=g,a.block_start-=g,c=a.hash_size,b=c;do d=a.head[--b],a.head[b]=d>=g?d-g:0;while(--c);c=g,b=c;do d=a.prev[--b],a.prev[b]=d>=g?d-g:0;while(--c);e+=g}if(0===a.strm.avail_in)break;if(c=k(a.strm,a.window,a.strstart+a.lookahead,e),a.lookahead+=c,a.lookahead+a.insert>=ja)for(f=a.strstart-a.insert,a.ins_h=a.window[f],a.ins_h=(a.ins_h<<a.hash_shift^a.window[f+1])&a.hash_mask;a.insert&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[f+ja-1])&a.hash_mask,a.prev[f&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=f,f++,a.insert--,!(a.lookahead+a.insert<ja)););}while(a.lookahead<la&&0!==a.strm.avail_in)}function n(a,b){var c=65535;for(c>a.pending_buf_size-5&&(c=a.pending_buf_size-5);;){if(a.lookahead<=1){if(m(a),0===a.lookahead&&b===J)return ua;if(0===a.lookahead)break}a.strstart+=a.lookahead,a.lookahead=0;var d=a.block_start+c;if((0===a.strstart||a.strstart>=d)&&(a.lookahead=a.strstart-d,a.strstart=d,h(a,!1),0===a.strm.avail_out))return ua;if(a.strstart-a.block_start>=a.w_size-la&&(h(a,!1),0===a.strm.avail_out))return ua}return a.insert=0,b===M?(h(a,!0),0===a.strm.avail_out?wa:xa):a.strstart>a.block_start&&(h(a,!1),0===a.strm.avail_out)?ua:ua}function o(a,b){for(var c,d;;){if(a.lookahead<la){if(m(a),a.lookahead<la&&b===J)return ua;if(0===a.lookahead)break}if(c=0,a.lookahead>=ja&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+ja-1])&a.hash_mask,c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),0!==c&&a.strstart-c<=a.w_size-la&&(a.match_length=l(a,c)),a.match_length>=ja)if(d=F._tr_tally(a,a.strstart-a.match_start,a.match_length-ja),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=ja){a.match_length--;do a.strstart++,a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+ja-1])&a.hash_mask,c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart;while(0!==--a.match_length);a.strstart++}else a.strstart+=a.match_length,a.match_length=0,a.ins_h=a.window[a.strstart],a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+1])&a.hash_mask;else d=F._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++;if(d&&(h(a,!1),0===a.strm.avail_out))return ua}return a.insert=a.strstart<ja-1?a.strstart:ja-1,b===M?(h(a,!0),0===a.strm.avail_out?wa:xa):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?ua:va}function p(a,b){for(var c,d,e;;){if(a.lookahead<la){if(m(a),a.lookahead<la&&b===J)return ua;if(0===a.lookahead)break}if(c=0,a.lookahead>=ja&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+ja-1])&a.hash_mask,c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart),a.prev_length=a.match_length,a.prev_match=a.match_start,a.match_length=ja-1,0!==c&&a.prev_length<a.max_lazy_match&&a.strstart-c<=a.w_size-la&&(a.match_length=l(a,c),a.match_length<=5&&(a.strategy===U||a.match_length===ja&&a.strstart-a.match_start>4096)&&(a.match_length=ja-1)),a.prev_length>=ja&&a.match_length<=a.prev_length){e=a.strstart+a.lookahead-ja,d=F._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-ja),a.lookahead-=a.prev_length-1,a.prev_length-=2;do++a.strstart<=e&&(a.ins_h=(a.ins_h<<a.hash_shift^a.window[a.strstart+ja-1])&a.hash_mask,c=a.prev[a.strstart&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=a.strstart);while(0!==--a.prev_length);if(a.match_available=0,a.match_length=ja-1,a.strstart++,d&&(h(a,!1),0===a.strm.avail_out))return ua}else if(a.match_available){if(d=F._tr_tally(a,0,a.window[a.strstart-1]),d&&h(a,!1),a.strstart++,a.lookahead--,0===a.strm.avail_out)return ua}else a.match_available=1,a.strstart++,a.lookahead--}return a.match_available&&(d=F._tr_tally(a,0,a.window[a.strstart-1]),a.match_available=0),a.insert=a.strstart<ja-1?a.strstart:ja-1,b===M?(h(a,!0),0===a.strm.avail_out?wa:xa):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?ua:va}function q(a,b){for(var c,d,e,f,g=a.window;;){if(a.lookahead<=ka){if(m(a),a.lookahead<=ka&&b===J)return ua;if(0===a.lookahead)break}if(a.match_length=0,a.lookahead>=ja&&a.strstart>0&&(e=a.strstart-1,d=g[e],d===g[++e]&&d===g[++e]&&d===g[++e])){f=a.strstart+ka;do;while(d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&e<f);a.match_length=ka-(f-e),a.match_length>a.lookahead&&(a.match_length=a.lookahead)}if(a.match_length>=ja?(c=F._tr_tally(a,1,a.match_length-ja),a.lookahead-=a.match_length,a.strstart+=a.match_length,a.match_length=0):(c=F._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++),c&&(h(a,!1),0===a.strm.avail_out))return ua}return a.insert=0,b===M?(h(a,!0),0===a.strm.avail_out?wa:xa):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?ua:va}function r(a,b){for(var c;;){if(0===a.lookahead&&(m(a),0===a.lookahead)){if(b===J)return ua;break}if(a.match_length=0,c=F._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++,c&&(h(a,!1),0===a.strm.avail_out))return ua}return a.insert=0,b===M?(h(a,!0),0===a.strm.avail_out?wa:xa):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?ua:va}function s(a,b,c,d,e){this.good_length=a,this.max_lazy=b,this.nice_length=c,this.max_chain=d,this.func=e}function t(a){a.window_size=2*a.w_size,f(a.head),a.max_lazy_match=D[a.level].max_lazy,a.good_match=D[a.level].good_length,a.nice_match=D[a.level].nice_length,a.max_chain_length=D[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=ja-1,a.match_available=0,a.ins_h=0}function u(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new E.Buf16(2*ha),this.dyn_dtree=new E.Buf16(2*(2*fa+1)),this.bl_tree=new E.Buf16(2*(2*ga+1)),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new E.Buf16(ia+1),this.heap=new E.Buf16(2*ea+1),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new E.Buf16(2*ea+1),f(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function v(a){var b;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=Z,b=a.state,b.pending=0,b.pending_out=0,b.wrap<0&&(b.wrap=-b.wrap),b.status=b.wrap?na:sa,a.adler=2===b.wrap?0:1,b.last_flush=J,F._tr_init(b),O):d(a,Q)}function w(a){var b=v(a);return b===O&&t(a.state),b}function x(a,b){return a&&a.state?2!==a.state.wrap?Q:(a.state.gzhead=b,O):Q}function y(a,b,c,e,f,g){if(!a)return Q;var h=1;if(b===T&&(b=6),e<0?(h=0,e=-e):e>15&&(h=2,e-=16),f<1||f>_||c!==$||e<8||e>15||b<0||b>9||g<0||g>X)return d(a,Q);8===e&&(e=9);var i=new u;return a.state=i,i.strm=a,i.wrap=h,i.gzhead=null,i.w_bits=e,i.w_size=1<<i.w_bits,i.w_mask=i.w_size-1,i.hash_bits=f+7,i.hash_size=1<<i.hash_bits,i.hash_mask=i.hash_size-1,i.hash_shift=~~((i.hash_bits+ja-1)/ja),i.window=new E.Buf8(2*i.w_size),i.head=new E.Buf16(i.hash_size),i.prev=new E.Buf16(i.w_size),i.lit_bufsize=1<<f+6,i.pending_buf_size=4*i.lit_bufsize,i.pending_buf=new E.Buf8(i.pending_buf_size),i.d_buf=1*i.lit_bufsize,i.l_buf=3*i.lit_bufsize,i.level=b,i.strategy=g,i.method=c,w(a)}function z(a,b){return y(a,b,$,aa,ba,Y)}function A(a,b){var c,h,k,l;if(!a||!a.state||b>N||b<0)return a?d(a,Q):Q;if(h=a.state,!a.output||!a.input&&0!==a.avail_in||h.status===ta&&b!==M)return d(a,0===a.avail_out?S:Q);if(h.strm=a,c=h.last_flush,h.last_flush=b,h.status===na)if(2===h.wrap)a.adler=0,i(h,31),i(h,139),i(h,8),h.gzhead?(i(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),i(h,255&h.gzhead.time),i(h,h.gzhead.time>>8&255),i(h,h.gzhead.time>>16&255),i(h,h.gzhead.time>>24&255),i(h,9===h.level?2:h.strategy>=V||h.level<2?4:0),i(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(i(h,255&h.gzhead.extra.length),i(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(a.adler=H(a.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=oa):(i(h,0),i(h,0),i(h,0),i(h,0),i(h,0),i(h,9===h.level?2:h.strategy>=V||h.level<2?4:0),i(h,ya),h.status=sa);else{var m=$+(h.w_bits-8<<4)<<8,n=-1;n=h.strategy>=V||h.level<2?0:h.level<6?1:6===h.level?2:3,m|=n<<6,0!==h.strstart&&(m|=ma),m+=31-m%31,h.status=sa,j(h,m),0!==h.strstart&&(j(h,a.adler>>>16),j(h,65535&a.adler)),a.adler=1}if(h.status===oa)if(h.gzhead.extra){for(k=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending!==h.pending_buf_size));)i(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=pa)}else h.status=pa;if(h.status===pa)if(h.gzhead.name){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindex<h.gzhead.name.length?255&h.gzhead.name.charCodeAt(h.gzindex++):0,i(h,l)}while(0!==l);h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.gzindex=0,h.status=qa)}else h.status=qa;if(h.status===qa)if(h.gzhead.comment){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindex<h.gzhead.comment.length?255&h.gzhead.comment.charCodeAt(h.gzindex++):0,i(h,l)}while(0!==l);h.gzhead.hcrc&&h.pending>k&&(a.adler=H(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.status=ra)}else h.status=ra;if(h.status===ra&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&g(a),h.pending+2<=h.pending_buf_size&&(i(h,255&a.adler),i(h,a.adler>>8&255),a.adler=0,h.status=sa)):h.status=sa),0!==h.pending){if(g(a),0===a.avail_out)return h.last_flush=-1,O}else if(0===a.avail_in&&e(b)<=e(c)&&b!==M)return d(a,S);if(h.status===ta&&0!==a.avail_in)return d(a,S);if(0!==a.avail_in||0!==h.lookahead||b!==J&&h.status!==ta){var o=h.strategy===V?r(h,b):h.strategy===W?q(h,b):D[h.level].func(h,b);if(o!==wa&&o!==xa||(h.status=ta),o===ua||o===wa)return 0===a.avail_out&&(h.last_flush=-1),O;if(o===va&&(b===K?F._tr_align(h):b!==N&&(F._tr_stored_block(h,0,0,!1),b===L&&(f(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),g(a),0===a.avail_out))return h.last_flush=-1,O}return b!==M?O:h.wrap<=0?P:(2===h.wrap?(i(h,255&a.adler),i(h,a.adler>>8&255),i(h,a.adler>>16&255),i(h,a.adler>>24&255),i(h,255&a.total_in),i(h,a.total_in>>8&255),i(h,a.total_in>>16&255),i(h,a.total_in>>24&255)):(j(h,a.adler>>>16),j(h,65535&a.adler)),g(a),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?O:P)}function B(a){var b;return a&&a.state?(b=a.state.status,b!==na&&b!==oa&&b!==pa&&b!==qa&&b!==ra&&b!==sa&&b!==ta?d(a,Q):(a.state=null,b===sa?d(a,R):O)):Q}function C(a,b){var c,d,e,g,h,i,j,k,l=b.length;if(!a||!a.state)return Q;if(c=a.state,g=c.wrap,2===g||1===g&&c.status!==na||c.lookahead)return Q;for(1===g&&(a.adler=G(a.adler,b,l,0)),c.wrap=0,l>=c.w_size&&(0===g&&(f(c.head),c.strstart=0,c.block_start=0,c.insert=0),k=new E.Buf8(c.w_size),E.arraySet(k,b,l-c.w_size,c.w_size,0),b=k,l=c.w_size),h=a.avail_in,i=a.next_in,j=a.input,a.avail_in=l,a.next_in=0,a.input=b,m(c);c.lookahead>=ja;){d=c.strstart,e=c.lookahead-(ja-1);do c.ins_h=(c.ins_h<<c.hash_shift^c.window[d+ja-1])&c.hash_mask,c.prev[d&c.w_mask]=c.head[c.ins_h],c.head[c.ins_h]=d,d++;while(--e);c.strstart=d,c.lookahead=ja-1,m(c)}return c.strstart+=c.lookahead,c.block_start=c.strstart,c.insert=c.lookahead,c.lookahead=0,c.match_length=c.prev_length=ja-1,c.match_available=0,a.next_in=i,a.input=j,a.avail_in=h,c.wrap=g,O}var D,E=a("../utils/common"),F=a("./trees"),G=a("./adler32"),H=a("./crc32"),I=a("./messages"),J=0,K=1,L=3,M=4,N=5,O=0,P=1,Q=-2,R=-3,S=-5,T=-1,U=1,V=2,W=3,X=4,Y=0,Z=2,$=8,_=9,aa=15,ba=8,ca=29,da=256,ea=da+1+ca,fa=30,ga=19,ha=2*ea+1,ia=15,ja=3,ka=258,la=ka+ja+1,ma=32,na=42,oa=69,pa=73,qa=91,ra=103,sa=113,ta=666,ua=1,va=2,wa=3,xa=4,ya=3;D=[new s(0,0,0,0,n),new s(4,4,8,4,o),new s(4,5,16,8,o),new s(4,6,32,32,o),new s(4,4,16,16,p),new s(8,16,32,32,p),new s(8,16,128,128,p),new s(8,32,128,256,p),new s(32,128,258,1024,p),new s(32,258,258,4096,p)],c.deflateInit=z,c.deflateInit2=y,c.deflateReset=w,c.deflateResetKeep=v,c.deflateSetHeader=x,c.deflate=A,c.deflateEnd=B,c.deflateSetDictionary=C,c.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":62,"./adler32":64,"./crc32":66,"./messages":72,"./trees":73}],68:[function(a,b,c){"use strict";function d(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=d},{}],69:[function(a,b,c){"use strict";var d=30,e=12;b.exports=function(a,b){var c,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;c=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=c.dmax,l=c.wsize,m=c.whave,n=c.wnext,o=c.window,p=c.hold,q=c.bits,r=c.lencode,s=c.distcode,t=(1<<c.lenbits)-1,u=(1<<c.distbits)-1;a:do{q<15&&(p+=B[f++]<<q,q+=8,p+=B[f++]<<q,q+=8),v=r[p&t];b:for(;;){if(w=v>>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<<w)-1)];continue b}if(32&w){c.mode=e;break a}a.msg="invalid literal/length code",c.mode=d;break a}x=65535&v,w&=15,w&&(q<w&&(p+=B[f++]<<q,q+=8),x+=p&(1<<w)-1,p>>>=w,q-=w),q<15&&(p+=B[f++]<<q,q+=8,p+=B[f++]<<q,q+=8),v=s[p&u];c:for(;;){if(w=v>>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<<w)-1)];continue c}a.msg="invalid distance code",c.mode=d;break a}if(y=65535&v,w&=15,q<w&&(p+=B[f++]<<q,q+=8,q<w&&(p+=B[f++]<<q,q+=8)),y+=p&(1<<w)-1,y>k){a.msg="invalid distance too far back",c.mode=d;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&c.sane){a.msg="invalid distance too far back",c.mode=d;break a}if(z=0,A=o,0===n){if(z+=l-w,w<x){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(n<w){if(z+=l+n-w,w-=n,w<x){x-=w;do C[h++]=o[z++];while(--w);if(z=0,n<x){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,w<x){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(f<g&&h<j);x=q>>3,f-=x,q-=x<<3,p&=(1<<q)-1,a.next_in=f,a.next_out=h,a.avail_in=f<g?5+(g-f):5-(f-g),a.avail_out=h<j?257+(j-h):257-(h-j),c.hold=p,c.bits=q}},{}],70:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=L,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new s.Buf32(pa),b.distcode=b.distdyn=new s.Buf32(qa),b.sane=1,b.back=-1,D):G}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):G}function h(a,b){var c,d;return a&&a.state?(d=a.state,b<0?(c=0,b=-b):(c=(b>>4)+1,b<48&&(b&=15)),b&&(b<8||b>15)?G:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):G}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==D&&(a.state=null),c):G}function j(a){return i(a,sa)}function k(a){if(ta){var b;for(q=new s.Buf32(512),r=new s.Buf32(32),b=0;b<144;)a.lens[b++]=8;for(;b<256;)a.lens[b++]=9;for(;b<280;)a.lens[b++]=7;for(;b<288;)a.lens[b++]=8;for(w(y,a.lens,0,288,q,0,a.work,{bits:9}),b=0;b<32;)a.lens[b++]=5;w(z,a.lens,0,32,r,0,a.work,{bits:5}),ta=!1}a.lencode=q,a.lenbits=9,a.distcode=r,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<<f.wbits,f.wnext=0,f.whave=0,f.window=new s.Buf8(f.wsize)),d>=f.wsize?(s.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),s.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(s.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whave<f.wsize&&(f.whave+=e))),0}function m(a,b){var c,e,f,g,h,i,j,m,n,o,p,q,r,pa,qa,ra,sa,ta,ua,va,wa,xa,ya,za,Aa=0,Ba=new s.Buf8(4),Ca=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!a||!a.state||!a.output||!a.input&&0!==a.avail_in)return G;c=a.state,c.mode===W&&(c.mode=X),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,o=i,p=j,xa=D;a:for(;;)switch(c.mode){case L:if(0===c.wrap){c.mode=X;break}for(;n<16;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(2&c.wrap&&35615===m){c.check=0,Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=u(c.check,Ba,2,0),m=0,n=0,c.mode=M;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=ma;break}if((15&m)!==K){a.msg="unknown compression method",c.mode=ma;break}if(m>>>=4,n-=4,wa=(15&m)+8,0===c.wbits)c.wbits=wa;else if(wa>c.wbits){a.msg="invalid window size",c.mode=ma;break}c.dmax=1<<wa,a.adler=c.check=1,c.mode=512&m?U:W,m=0,n=0;break;case M:for(;n<16;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(c.flags=m,(255&c.flags)!==K){a.msg="unknown compression method",c.mode=ma;break}if(57344&c.flags){a.msg="unknown header flags set",c.mode=ma;break}c.head&&(c.head.text=m>>8&1),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0,c.mode=N;case N:for(;n<32;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.head&&(c.head.time=m),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,Ba[2]=m>>>16&255,Ba[3]=m>>>24&255,c.check=u(c.check,Ba,4,0)),m=0,n=0,c.mode=O;case O:for(;n<16;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.head&&(c.head.xflags=255&m,c.head.os=m>>8),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0,c.mode=P;case P:if(1024&c.flags){for(;n<16;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.length=m,c.head&&(c.head.extra_len=m),512&c.flags&&(Ba[0]=255&m,Ba[1]=m>>>8&255,c.check=u(c.check,Ba,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=Q;case Q:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wa=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),s.arraySet(c.head.extra,e,g,q,wa)),512&c.flags&&(c.check=u(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=R;case R:if(2048&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.name+=String.fromCharCode(wa));while(wa&&q<i);if(512&c.flags&&(c.check=u(c.check,e,q,g)),i-=q,g+=q,wa)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=S;case S:if(4096&c.flags){if(0===i)break a;q=0;do wa=e[g+q++],c.head&&wa&&c.length<65536&&(c.head.comment+=String.fromCharCode(wa));while(wa&&q<i);if(512&c.flags&&(c.check=u(c.check,e,q,g)),i-=q,g+=q,wa)break a}else c.head&&(c.head.comment=null);c.mode=T;case T:if(512&c.flags){for(;n<16;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(m!==(65535&c.check)){a.msg="header crc mismatch",c.mode=ma;break}m=0,n=0}c.head&&(c.head.hcrc=c.flags>>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=W;break;case U:for(;n<32;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}a.adler=c.check=d(m),m=0,n=0,c.mode=V;case V:if(0===c.havedict)return a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,F;a.adler=c.check=1,c.mode=W;case W:if(b===B||b===C)break a;case X:if(c.last){m>>>=7&n,n-=7&n,c.mode=ja;break}for(;n<3;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}switch(c.last=1&m,m>>>=1,n-=1,3&m){case 0:c.mode=Y;break;case 1:if(k(c),c.mode=ca,b===C){m>>>=2,n-=2;break a}break;case 2:c.mode=_;break;case 3:a.msg="invalid block type",c.mode=ma}m>>>=2,n-=2;break;case Y:for(m>>>=7&n,n-=7&n;n<32;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if((65535&m)!==(m>>>16^65535)){a.msg="invalid stored block lengths",c.mode=ma;break}if(c.length=65535&m,m=0,n=0,c.mode=Z,b===C)break a;case Z:c.mode=$;case $:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;s.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=W;break;case _:for(;n<14;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(c.nlen=(31&m)+257,m>>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=ma;break}c.have=0,c.mode=aa;case aa:for(;c.have<c.ncode;){for(;n<3;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.lens[Ca[c.have++]]=7&m,m>>>=3,n-=3}for(;c.have<19;)c.lens[Ca[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,ya={bits:c.lenbits},xa=w(x,c.lens,0,19,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid code lengths set",c.mode=ma;break}c.have=0,c.mode=ba;case ba:for(;c.have<c.nlen+c.ndist;){for(;Aa=c.lencode[m&(1<<c.lenbits)-1],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(qa<=n);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(sa<16)m>>>=qa,n-=qa,c.lens[c.have++]=sa;else{if(16===sa){for(za=qa+2;n<za;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(m>>>=qa,n-=qa,0===c.have){a.msg="invalid bit length repeat",c.mode=ma;break}wa=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sa){for(za=qa+3;n<za;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}m>>>=qa,n-=qa,wa=0,q=3+(7&m),m>>>=3,n-=3}else{for(za=qa+7;n<za;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}m>>>=qa,n-=qa,wa=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=ma;break}for(;q--;)c.lens[c.have++]=wa}}if(c.mode===ma)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=ma;break}if(c.lenbits=9,ya={bits:c.lenbits},xa=w(y,c.lens,0,c.nlen,c.lencode,0,c.work,ya),c.lenbits=ya.bits,xa){a.msg="invalid literal/lengths set",c.mode=ma;break}if(c.distbits=6,c.distcode=c.distdyn,ya={bits:c.distbits},xa=w(z,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,ya),c.distbits=ya.bits,xa){a.msg="invalid distances set",c.mode=ma;break}if(c.mode=ca,b===C)break a;case ca:c.mode=da;case da:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,v(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===W&&(c.back=-1);break}for(c.back=0;Aa=c.lencode[m&(1<<c.lenbits)-1],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(qa<=n);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(ra&&0===(240&ra)){for(ta=qa,ua=ra,va=sa;Aa=c.lencode[va+((m&(1<<ta+ua)-1)>>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(ta+qa<=n);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}m>>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,c.length=sa,0===ra){c.mode=ia;break}if(32&ra){c.back=-1,c.mode=W;break}if(64&ra){a.msg="invalid literal/length code",c.mode=ma;break}c.extra=15&ra,c.mode=ea;case ea:if(c.extra){for(za=c.extra;n<za;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.length+=m&(1<<c.extra)-1,m>>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=fa;case fa:for(;Aa=c.distcode[m&(1<<c.distbits)-1],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(qa<=n);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(0===(240&ra)){for(ta=qa,ua=ra,va=sa;Aa=c.distcode[va+((m&(1<<ta+ua)-1)>>ta)],qa=Aa>>>24,ra=Aa>>>16&255,sa=65535&Aa,!(ta+qa<=n);){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}m>>>=ta,n-=ta,c.back+=ta}if(m>>>=qa,n-=qa,c.back+=qa,64&ra){a.msg="invalid distance code",c.mode=ma;break}c.offset=sa,c.extra=15&ra,c.mode=ga;case ga:if(c.extra){for(za=c.extra;n<za;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}c.offset+=m&(1<<c.extra)-1,m>>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=ma;break}c.mode=ha;case ha:if(0===j)break a;if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=ma;break}q>c.wnext?(q-=c.wnext,r=c.wsize-q):r=c.wnext-q,q>c.length&&(q=c.length),pa=c.window}else pa=f,r=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pa[r++];while(--q);0===c.length&&(c.mode=da);break;case ia:if(0===j)break a;f[h++]=c.length,j--,c.mode=da;break;case ja:if(c.wrap){for(;n<32;){if(0===i)break a;i--,m|=e[g++]<<n,n+=8}if(p-=j,a.total_out+=p,c.total+=p,p&&(a.adler=c.check=c.flags?u(c.check,f,p,h-p):t(c.check,f,p,h-p)),p=j,(c.flags?m:d(m))!==c.check){a.msg="incorrect data check",c.mode=ma;break}m=0,n=0}c.mode=ka;case ka:if(c.wrap&&c.flags){for(;n<32;){if(0===i)break a;i--,m+=e[g++]<<n,n+=8}if(m!==(4294967295&c.total)){a.msg="incorrect length check",c.mode=ma;break}m=0,n=0}c.mode=la;case la:xa=E;break a;case ma:xa=H;break a;case na:return I;case oa:default:return G}return a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,(c.wsize||p!==a.avail_out&&c.mode<ma&&(c.mode<ja||b!==A))&&l(a,a.output,a.next_out,p-a.avail_out)?(c.mode=na,I):(o-=a.avail_in,p-=a.avail_out,a.total_in+=o,a.total_out+=p,c.total+=p,c.wrap&&p&&(a.adler=c.check=c.flags?u(c.check,f,p,a.next_out-p):t(c.check,f,p,a.next_out-p)),a.data_type=c.bits+(c.last?64:0)+(c.mode===W?128:0)+(c.mode===ca||c.mode===Z?256:0),(0===o&&0===p||b===A)&&xa===D&&(xa=J),xa)}function n(a){if(!a||!a.state)return G;var b=a.state;return b.window&&(b.window=null),a.state=null,D}function o(a,b){var c;return a&&a.state?(c=a.state,0===(2&c.wrap)?G:(c.head=b,b.done=!1,D)):G}function p(a,b){var c,d,e,f=b.length;return a&&a.state?(c=a.state,0!==c.wrap&&c.mode!==V?G:c.mode===V&&(d=1,d=t(d,b,f,0),d!==c.check)?H:(e=l(a,b,f,f))?(c.mode=na,I):(c.havedict=1,D)):G}var q,r,s=a("../utils/common"),t=a("./adler32"),u=a("./crc32"),v=a("./inffast"),w=a("./inftrees"),x=0,y=1,z=2,A=4,B=5,C=6,D=0,E=1,F=2,G=-2,H=-3,I=-4,J=-5,K=8,L=1,M=2,N=3,O=4,P=5,Q=6,R=7,S=8,T=9,U=10,V=11,W=12,X=13,Y=14,Z=15,$=16,_=17,aa=18,ba=19,ca=20,da=21,ea=22,fa=23,ga=24,ha=25,ia=26,ja=27,ka=28,la=29,ma=30,na=31,oa=32,pa=852,qa=592,ra=15,sa=ra,ta=!0;c.inflateReset=g,c.inflateReset2=h,c.inflateResetKeep=f,c.inflateInit=j,c.inflateInit2=i,c.inflate=m,c.inflateEnd=n,c.inflateGetHeader=o,c.inflateSetDictionary=p,c.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":62,"./adler32":64,"./crc32":66,"./inffast":69,"./inftrees":71}],71:[function(a,b,c){"use strict";var d=a("../utils/common"),e=15,f=852,g=592,h=0,i=1,j=2,k=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],m=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],n=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];b.exports=function(a,b,c,o,p,q,r,s){var t,u,v,w,x,y,z,A,B,C=s.bits,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=null,O=0,P=new d.Buf16(e+1),Q=new d.Buf16(e+1),R=null,S=0;for(D=0;D<=e;D++)P[D]=0;for(E=0;E<o;E++)P[b[c+E]]++;for(H=C,G=e;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;F<G&&0===P[F];F++);for(H<F&&(H=F),K=1,D=1;D<=e;D++)if(K<<=1,K-=P[D],K<0)return-1;if(K>0&&(a===h||1!==G))return-1;for(Q[1]=0,D=1;D<e;D++)Q[D+1]=Q[D]+P[D];for(E=0;E<o;E++)0!==b[c+E]&&(r[Q[b[c+E]]++]=E);if(a===h?(N=R=r,y=19):a===i?(N=k,O-=257,R=l,S-=257,y=256):(N=m,R=n,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<<H,w=L-1,a===i&&L>f||a===j&&L>g)return 1;for(;;){z=D-J,r[E]<y?(A=0,B=r[E]):r[E]>y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<<D-J,u=1<<I,F=u;do u-=t,p[x+(M>>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<<D-1;M&t;)t>>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[c+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<<I;I+J<G&&(K-=P[I+J],!(K<=0));)I++,K<<=1;if(L+=1<<I,a===i&&L>f||a===j&&L>g)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":62}],72:[function(a,b,c){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],73:[function(a,b,c){"use strict";function d(a){for(var b=a.length;--b>=0;)a[b]=0}function e(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length}function f(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b}function g(a){return a<256?ia[a]:ia[256+(a>>>7)]}function h(a,b){a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255}function i(a,b,c){a.bi_valid>X-c?(a.bi_buf|=b<<a.bi_valid&65535,h(a,a.bi_buf),a.bi_buf=b>>X-a.bi_valid,a.bi_valid+=c-X):(a.bi_buf|=b<<a.bi_valid&65535,a.bi_valid+=c)}function j(a,b,c){i(a,c[2*b],c[2*b+1])}function k(a,b){var c=0;do c|=1&a,a>>>=1,c<<=1;while(--b>0);return c>>>1}function l(a){16===a.bi_valid?(h(a,a.bi_buf),a.bi_buf=0,a.bi_valid=0):a.bi_valid>=8&&(a.pending_buf[a.pending++]=255&a.bi_buf,a.bi_buf>>=8,a.bi_valid-=8)}function m(a,b){var c,d,e,f,g,h,i=b.dyn_tree,j=b.max_code,k=b.stat_desc.static_tree,l=b.stat_desc.has_stree,m=b.stat_desc.extra_bits,n=b.stat_desc.extra_base,o=b.stat_desc.max_length,p=0;for(f=0;f<=W;f++)a.bl_count[f]=0;for(i[2*a.heap[a.heap_max]+1]=0,
+c=a.heap_max+1;c<V;c++)d=a.heap[c],f=i[2*i[2*d+1]+1]+1,f>o&&(f=o,p++),i[2*d+1]=f,d>j||(a.bl_count[f]++,g=0,d>=n&&(g=m[d-n]),h=i[2*d],a.opt_len+=h*(f+g),l&&(a.static_len+=h*(k[2*d+1]+g)));if(0!==p){do{for(f=o-1;0===a.bl_count[f];)f--;a.bl_count[f]--,a.bl_count[f+1]+=2,a.bl_count[o]--,p-=2}while(p>0);for(f=o;0!==f;f--)for(d=a.bl_count[f];0!==d;)e=a.heap[--c],e>j||(i[2*e+1]!==f&&(a.opt_len+=(f-i[2*e+1])*i[2*e],i[2*e+1]=f),d--)}}function n(a,b,c){var d,e,f=new Array(W+1),g=0;for(d=1;d<=W;d++)f[d]=g=g+c[d-1]<<1;for(e=0;e<=b;e++){var h=a[2*e+1];0!==h&&(a[2*e]=k(f[h]++,h))}}function o(){var a,b,c,d,f,g=new Array(W+1);for(c=0,d=0;d<Q-1;d++)for(ka[d]=c,a=0;a<1<<ba[d];a++)ja[c++]=d;for(ja[c-1]=d,f=0,d=0;d<16;d++)for(la[d]=f,a=0;a<1<<ca[d];a++)ia[f++]=d;for(f>>=7;d<T;d++)for(la[d]=f<<7,a=0;a<1<<ca[d]-7;a++)ia[256+f++]=d;for(b=0;b<=W;b++)g[b]=0;for(a=0;a<=143;)ga[2*a+1]=8,a++,g[8]++;for(;a<=255;)ga[2*a+1]=9,a++,g[9]++;for(;a<=279;)ga[2*a+1]=7,a++,g[7]++;for(;a<=287;)ga[2*a+1]=8,a++,g[8]++;for(n(ga,S+1,g),a=0;a<T;a++)ha[2*a+1]=5,ha[2*a]=k(a,5);ma=new e(ga,ba,R+1,S,W),na=new e(ha,ca,0,T,W),oa=new e(new Array(0),da,0,U,Y)}function p(a){var b;for(b=0;b<S;b++)a.dyn_ltree[2*b]=0;for(b=0;b<T;b++)a.dyn_dtree[2*b]=0;for(b=0;b<U;b++)a.bl_tree[2*b]=0;a.dyn_ltree[2*Z]=1,a.opt_len=a.static_len=0,a.last_lit=a.matches=0}function q(a){a.bi_valid>8?h(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0}function r(a,b,c,d){q(a),d&&(h(a,c),h(a,~c)),G.arraySet(a.pending_buf,a.window,b,c,a.pending),a.pending+=c}function s(a,b,c,d){var e=2*b,f=2*c;return a[e]<a[f]||a[e]===a[f]&&d[b]<=d[c]}function t(a,b,c){for(var d=a.heap[c],e=c<<1;e<=a.heap_len&&(e<a.heap_len&&s(b,a.heap[e+1],a.heap[e],a.depth)&&e++,!s(b,d,a.heap[e],a.depth));)a.heap[c]=a.heap[e],c=e,e<<=1;a.heap[c]=d}function u(a,b,c){var d,e,f,h,k=0;if(0!==a.last_lit)do d=a.pending_buf[a.d_buf+2*k]<<8|a.pending_buf[a.d_buf+2*k+1],e=a.pending_buf[a.l_buf+k],k++,0===d?j(a,e,b):(f=ja[e],j(a,f+R+1,b),h=ba[f],0!==h&&(e-=ka[f],i(a,e,h)),d--,f=g(d),j(a,f,c),h=ca[f],0!==h&&(d-=la[f],i(a,d,h)));while(k<a.last_lit);j(a,Z,b)}function v(a,b){var c,d,e,f=b.dyn_tree,g=b.stat_desc.static_tree,h=b.stat_desc.has_stree,i=b.stat_desc.elems,j=-1;for(a.heap_len=0,a.heap_max=V,c=0;c<i;c++)0!==f[2*c]?(a.heap[++a.heap_len]=j=c,a.depth[c]=0):f[2*c+1]=0;for(;a.heap_len<2;)e=a.heap[++a.heap_len]=j<2?++j:0,f[2*e]=1,a.depth[e]=0,a.opt_len--,h&&(a.static_len-=g[2*e+1]);for(b.max_code=j,c=a.heap_len>>1;c>=1;c--)t(a,f,c);e=i;do c=a.heap[1],a.heap[1]=a.heap[a.heap_len--],t(a,f,1),d=a.heap[1],a.heap[--a.heap_max]=c,a.heap[--a.heap_max]=d,f[2*e]=f[2*c]+f[2*d],a.depth[e]=(a.depth[c]>=a.depth[d]?a.depth[c]:a.depth[d])+1,f[2*c+1]=f[2*d+1]=e,a.heap[1]=e++,t(a,f,1);while(a.heap_len>=2);a.heap[--a.heap_max]=a.heap[1],m(a,b),n(f,j,a.bl_count)}function w(a,b,c){var d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;d<=c;d++)e=g,g=b[2*(d+1)+1],++h<i&&e===g||(h<j?a.bl_tree[2*e]+=h:0!==e?(e!==f&&a.bl_tree[2*e]++,a.bl_tree[2*$]++):h<=10?a.bl_tree[2*_]++:a.bl_tree[2*aa]++,h=0,f=e,0===g?(i=138,j=3):e===g?(i=6,j=3):(i=7,j=4))}function x(a,b,c){var d,e,f=-1,g=b[1],h=0,k=7,l=4;for(0===g&&(k=138,l=3),d=0;d<=c;d++)if(e=g,g=b[2*(d+1)+1],!(++h<k&&e===g)){if(h<l){do j(a,e,a.bl_tree);while(0!==--h)}else 0!==e?(e!==f&&(j(a,e,a.bl_tree),h--),j(a,$,a.bl_tree),i(a,h-3,2)):h<=10?(j(a,_,a.bl_tree),i(a,h-3,3)):(j(a,aa,a.bl_tree),i(a,h-11,7));h=0,f=e,0===g?(k=138,l=3):e===g?(k=6,l=3):(k=7,l=4)}}function y(a){var b;for(w(a,a.dyn_ltree,a.l_desc.max_code),w(a,a.dyn_dtree,a.d_desc.max_code),v(a,a.bl_desc),b=U-1;b>=3&&0===a.bl_tree[2*ea[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b}function z(a,b,c,d){var e;for(i(a,b-257,5),i(a,c-1,5),i(a,d-4,4),e=0;e<d;e++)i(a,a.bl_tree[2*ea[e]+1],3);x(a,a.dyn_ltree,b-1),x(a,a.dyn_dtree,c-1)}function A(a){var b,c=4093624447;for(b=0;b<=31;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return I;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return J;for(b=32;b<R;b++)if(0!==a.dyn_ltree[2*b])return J;return I}function B(a){pa||(o(),pa=!0),a.l_desc=new f(a.dyn_ltree,ma),a.d_desc=new f(a.dyn_dtree,na),a.bl_desc=new f(a.bl_tree,oa),a.bi_buf=0,a.bi_valid=0,p(a)}function C(a,b,c,d){i(a,(L<<1)+(d?1:0),3),r(a,b,c,!0)}function D(a){i(a,M<<1,3),j(a,Z,ga),l(a)}function E(a,b,c,d){var e,f,g=0;a.level>0?(a.strm.data_type===K&&(a.strm.data_type=A(a)),v(a,a.l_desc),v(a,a.d_desc),g=y(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,f<=e&&(e=f)):e=f=c+5,c+4<=e&&b!==-1?C(a,b,c,d):a.strategy===H||f===e?(i(a,(M<<1)+(d?1:0),3),u(a,ga,ha)):(i(a,(N<<1)+(d?1:0),3),z(a,a.l_desc.max_code+1,a.d_desc.max_code+1,g+1),u(a,a.dyn_ltree,a.dyn_dtree)),p(a),d&&q(a)}function F(a,b,c){return a.pending_buf[a.d_buf+2*a.last_lit]=b>>>8&255,a.pending_buf[a.d_buf+2*a.last_lit+1]=255&b,a.pending_buf[a.l_buf+a.last_lit]=255&c,a.last_lit++,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(ja[c]+R+1)]++,a.dyn_dtree[2*g(b)]++),a.last_lit===a.lit_bufsize-1}var G=a("../utils/common"),H=4,I=0,J=1,K=2,L=0,M=1,N=2,O=3,P=258,Q=29,R=256,S=R+1+Q,T=30,U=19,V=2*S+1,W=15,X=16,Y=7,Z=256,$=16,_=17,aa=18,ba=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ca=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],da=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ea=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],fa=512,ga=new Array(2*(S+2));d(ga);var ha=new Array(2*T);d(ha);var ia=new Array(fa);d(ia);var ja=new Array(P-O+1);d(ja);var ka=new Array(Q);d(ka);var la=new Array(T);d(la);var ma,na,oa,pa=!1;c._tr_init=B,c._tr_stored_block=C,c._tr_flush_block=E,c._tr_tally=F,c._tr_align=D},{"../utils/common":62}],74:[function(a,b,c){"use strict";function d(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=d},{}]},{},[10])(10)}); \ No newline at end of file
diff --git a/testing/web-platform/tests/tools/wave/www/lib/keycodes.js b/testing/web-platform/tests/tools/wave/www/lib/keycodes.js
new file mode 100644
index 0000000000..2d01b035ab
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/keycodes.js
@@ -0,0 +1,88 @@
+if (typeof KeyEvent != "undefined") {
+ if (typeof KeyEvent.VK_LEFT != "undefined") {
+ var VK_LEFT = KeyEvent.VK_LEFT;
+ var VK_UP = KeyEvent.VK_UP;
+ var VK_RIGHT = KeyEvent.VK_RIGHT;
+ var VK_DOWN = KeyEvent.VK_DOWN;
+ }
+ if (typeof KeyEvent.VK_ENTER != "undefined") {
+ var VK_ENTER = KeyEvent.VK_ENTER;
+ }
+ if (typeof KeyEvent.VK_RED != "undefined") {
+ var VK_RED = KeyEvent.VK_RED;
+ var VK_GREEN = KeyEvent.VK_GREEN;
+ var VK_YELLOW = KeyEvent.VK_YELLOW;
+ var VK_BLUE = KeyEvent.VK_BLUE;
+ }
+ if (typeof KeyEvent.VK_PLAY != "undefined") {
+ var VK_PLAY = KeyEvent.VK_PLAY;
+ var VK_PAUSE = KeyEvent.VK_PAUSE;
+ var VK_STOP = KeyEvent.VK_STOP;
+ }
+ if (typeof KeyEvent.VK_BACK != "undefined") {
+ var VK_BACK = KeyEvent.VK_BACK;
+ }
+ if (typeof KeyEvent.VK_0 != "undefined") {
+ var VK_0 = KeyEvent.VK_0;
+ var VK_1 = KeyEvent.VK_1;
+ var VK_2 = KeyEvent.VK_2;
+ var VK_3 = KeyEvent.VK_3;
+ var VK_4 = KeyEvent.VK_4;
+ var VK_5 = KeyEvent.VK_5;
+ var VK_6 = KeyEvent.VK_6;
+ var VK_7 = KeyEvent.VK_7;
+ var VK_8 = KeyEvent.VK_8;
+ var VK_9 = KeyEvent.VK_9;
+ }
+}
+if (typeof VK_LEFT == "undefined") {
+ var VK_LEFT = 132;
+ var VK_UP = 130;
+ var VK_RIGHT = 133;
+ var VK_DOWN = 131;
+}
+if (typeof VK_ENTER == "undefined") {
+ var VK_ENTER = 13;
+}
+if (typeof VK_RED == "undefined") {
+ var VK_RED = 403;
+ var VK_GREEN = 404;
+ var VK_YELLOW = 502;
+ var VK_BLUE = 406;
+}
+if (typeof VK_PLAY == "undefined") {
+ var VK_PLAY = 19;
+ var VK_PAUSE = 19;
+ var VK_STOP = 413;
+}
+if (typeof VK_BACK == "undefined") {
+ var VK_BACK = 0xa6;
+}
+if (typeof VK_0 == "undefined") {
+ var VK_0 = 48;
+ var VK_1 = 49;
+ var VK_2 = 50;
+ var VK_3 = 51;
+ var VK_4 = 52;
+ var VK_5 = 53;
+ var VK_6 = 54;
+ var VK_7 = 55;
+ var VK_8 = 56;
+ var VK_9 = 57;
+}
+
+var NEXT_KEYS = [39, 133, 131];
+var PREV_KEYS = [37, 132, 130];
+var ACTION_KEYS = [13, 32];
+
+if (typeof KeyEvent != "undefined") {
+ if (typeof KeyEvent.VK_LEFT != "undefined") {
+ PREV_KEYS.push(KeyEvent.VK_LEFT);
+ PREV_KEYS.push(KeyEvent.VK_UP);
+ NEXT_KEYS.push(KeyEvent.VK_RIGHT);
+ NEXT_KEYS.push(KeyEvent.VK_DOWN);
+ }
+ if (typeof KeyEvent.VK_ENTER != "undefined") {
+ ACTION_KEYS.push(KeyEvent.VK_ENTER);
+ }
+} \ No newline at end of file
diff --git a/testing/web-platform/tests/tools/wave/www/lib/qrcode.js b/testing/web-platform/tests/tools/wave/www/lib/qrcode.js
new file mode 100644
index 0000000000..45e5d7b974
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/qrcode.js
@@ -0,0 +1,1533 @@
+/**
+ * @fileoverview
+ * - Using the 'QRCode for Javascript library'
+ * - Fixed dataset of 'QRCode for Javascript library' for support full-spec.
+ * - this library has no dependencies.
+ *
+ * @author davidshimjs
+ * @see <a href="http://www.d-project.com/" target="_blank">http://www.d-project.com/</a>
+ * @see <a href="http://jeromeetienne.github.com/jquery-qrcode/" target="_blank">http://jeromeetienne.github.com/jquery-qrcode/</a>
+ */
+var QRCode
+;(function () {
+ // ---------------------------------------------------------------------
+ // QRCode for JavaScript
+ //
+ // Copyright (c) 2009 Kazuhiko Arase
+ //
+ // URL: http://www.d-project.com/
+ //
+ // Licensed under the MIT license:
+ // http://www.opensource.org/licenses/mit-license.php
+ //
+ // The word "QR Code" is registered trademark of
+ // DENSO WAVE INCORPORATED
+ // http://www.denso-wave.com/qrcode/faqpatent-e.html
+ //
+ // ---------------------------------------------------------------------
+ function QR8bitByte (data) {
+ this.mode = QRMode.MODE_8BIT_BYTE
+ this.data = data
+ this.parsedData = []
+
+ // Added to support UTF-8 Characters
+ for (var i = 0, l = this.data.length; i < l; i++) {
+ var byteArray = []
+ var code = this.data.charCodeAt(i)
+
+ if (code > 0x10000) {
+ byteArray[0] = 0xf0 | ((code & 0x1c0000) >>> 18)
+ byteArray[1] = 0x80 | ((code & 0x3f000) >>> 12)
+ byteArray[2] = 0x80 | ((code & 0xfc0) >>> 6)
+ byteArray[3] = 0x80 | (code & 0x3f)
+ } else if (code > 0x800) {
+ byteArray[0] = 0xe0 | ((code & 0xf000) >>> 12)
+ byteArray[1] = 0x80 | ((code & 0xfc0) >>> 6)
+ byteArray[2] = 0x80 | (code & 0x3f)
+ } else if (code > 0x80) {
+ byteArray[0] = 0xc0 | ((code & 0x7c0) >>> 6)
+ byteArray[1] = 0x80 | (code & 0x3f)
+ } else {
+ byteArray[0] = code
+ }
+
+ this.parsedData.push(byteArray)
+ }
+
+ this.parsedData = Array.prototype.concat.apply([], this.parsedData)
+
+ if (this.parsedData.length != this.data.length) {
+ this.parsedData.unshift(191)
+ this.parsedData.unshift(187)
+ this.parsedData.unshift(239)
+ }
+ }
+
+ QR8bitByte.prototype = {
+ getLength: function (buffer) {
+ return this.parsedData.length
+ },
+ write: function (buffer) {
+ for (var i = 0, l = this.parsedData.length; i < l; i++) {
+ buffer.put(this.parsedData[i], 8)
+ }
+ }
+ }
+
+ function QRCodeModel (typeNumber, errorCorrectLevel) {
+ this.typeNumber = typeNumber
+ this.errorCorrectLevel = errorCorrectLevel
+ this.modules = null
+ this.moduleCount = 0
+ this.dataCache = null
+ this.dataList = []
+ }
+
+ QRCodeModel.prototype = {
+ addData: function (data) {
+ var newData = new QR8bitByte(data)
+ this.dataList.push(newData)
+ this.dataCache = null
+ },
+ isDark: function (row, col) {
+ if (
+ row < 0 ||
+ this.moduleCount <= row ||
+ col < 0 ||
+ this.moduleCount <= col
+ ) {
+ throw new Error(row + ',' + col)
+ }
+ return this.modules[row][col]
+ },
+ getModuleCount: function () {
+ return this.moduleCount
+ },
+ make: function () {
+ this.makeImpl(false, this.getBestMaskPattern())
+ },
+ makeImpl: function (test, maskPattern) {
+ this.moduleCount = this.typeNumber * 4 + 17
+ this.modules = new Array(this.moduleCount)
+ for (var row = 0; row < this.moduleCount; row++) {
+ this.modules[row] = new Array(this.moduleCount)
+ for (var col = 0; col < this.moduleCount; col++) {
+ this.modules[row][col] = null
+ }
+ }
+ this.setupPositionProbePattern(0, 0)
+ this.setupPositionProbePattern(this.moduleCount - 7, 0)
+ this.setupPositionProbePattern(0, this.moduleCount - 7)
+ this.setupPositionAdjustPattern()
+ this.setupTimingPattern()
+ this.setupTypeInfo(test, maskPattern)
+ if (this.typeNumber >= 7) {
+ this.setupTypeNumber(test)
+ }
+ if (this.dataCache == null) {
+ this.dataCache = QRCodeModel.createData(
+ this.typeNumber,
+ this.errorCorrectLevel,
+ this.dataList
+ )
+ }
+ this.mapData(this.dataCache, maskPattern)
+ },
+ setupPositionProbePattern: function (row, col) {
+ for (var r = -1; r <= 7; r++) {
+ if (row + r <= -1 || this.moduleCount <= row + r) continue
+ for (var c = -1; c <= 7; c++) {
+ if (col + c <= -1 || this.moduleCount <= col + c) continue
+ if (
+ (r >= 0 && r <= 6 && (c == 0 || c == 6)) ||
+ (c >= 0 && c <= 6 && (r == 0 || r == 6)) ||
+ (r >= 2 && r <= 4 && c >= 2 && c <= 4)
+ ) {
+ this.modules[row + r][col + c] = true
+ } else {
+ this.modules[row + r][col + c] = false
+ }
+ }
+ }
+ },
+ getBestMaskPattern: function () {
+ var minLostPoint = 0
+ var pattern = 0
+ for (var i = 0; i < 8; i++) {
+ this.makeImpl(true, i)
+ var lostPoint = QRUtil.getLostPoint(this)
+ if (i == 0 || minLostPoint > lostPoint) {
+ minLostPoint = lostPoint
+ pattern = i
+ }
+ }
+ return pattern
+ },
+ createMovieClip: function (target_mc, instance_name, depth) {
+ var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth)
+ var cs = 1
+ this.make()
+ for (var row = 0; row < this.modules.length; row++) {
+ var y = row * cs
+ for (var col = 0; col < this.modules[row].length; col++) {
+ var x = col * cs
+ var dark = this.modules[row][col]
+ if (dark) {
+ qr_mc.beginFill(0, 100)
+ qr_mc.moveTo(x, y)
+ qr_mc.lineTo(x + cs, y)
+ qr_mc.lineTo(x + cs, y + cs)
+ qr_mc.lineTo(x, y + cs)
+ qr_mc.endFill()
+ }
+ }
+ }
+ return qr_mc
+ },
+ setupTimingPattern: function () {
+ for (var r = 8; r < this.moduleCount - 8; r++) {
+ if (this.modules[r][6] != null) {
+ continue
+ }
+ this.modules[r][6] = r % 2 == 0
+ }
+ for (var c = 8; c < this.moduleCount - 8; c++) {
+ if (this.modules[6][c] != null) {
+ continue
+ }
+ this.modules[6][c] = c % 2 == 0
+ }
+ },
+ setupPositionAdjustPattern: function () {
+ var pos = QRUtil.getPatternPosition(this.typeNumber)
+ for (var i = 0; i < pos.length; i++) {
+ for (var j = 0; j < pos.length; j++) {
+ var row = pos[i]
+ var col = pos[j]
+ if (this.modules[row][col] != null) {
+ continue
+ }
+ for (var r = -2; r <= 2; r++) {
+ for (var c = -2; c <= 2; c++) {
+ if (
+ r == -2 ||
+ r == 2 ||
+ c == -2 ||
+ c == 2 ||
+ (r == 0 && c == 0)
+ ) {
+ this.modules[row + r][col + c] = true
+ } else {
+ this.modules[row + r][col + c] = false
+ }
+ }
+ }
+ }
+ }
+ },
+ setupTypeNumber: function (test) {
+ var bits = QRUtil.getBCHTypeNumber(this.typeNumber)
+ for (var i = 0; i < 18; i++) {
+ var mod = !test && ((bits >> i) & 1) == 1
+ this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod
+ }
+ for (var i = 0; i < 18; i++) {
+ var mod = !test && ((bits >> i) & 1) == 1
+ this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod
+ }
+ },
+ setupTypeInfo: function (test, maskPattern) {
+ var data = (this.errorCorrectLevel << 3) | maskPattern
+ var bits = QRUtil.getBCHTypeInfo(data)
+ for (var i = 0; i < 15; i++) {
+ var mod = !test && ((bits >> i) & 1) == 1
+ if (i < 6) {
+ this.modules[i][8] = mod
+ } else if (i < 8) {
+ this.modules[i + 1][8] = mod
+ } else {
+ this.modules[this.moduleCount - 15 + i][8] = mod
+ }
+ }
+ for (var i = 0; i < 15; i++) {
+ var mod = !test && ((bits >> i) & 1) == 1
+ if (i < 8) {
+ this.modules[8][this.moduleCount - i - 1] = mod
+ } else if (i < 9) {
+ this.modules[8][15 - i - 1 + 1] = mod
+ } else {
+ this.modules[8][15 - i - 1] = mod
+ }
+ }
+ this.modules[this.moduleCount - 8][8] = !test
+ },
+ mapData: function (data, maskPattern) {
+ var inc = -1
+ var row = this.moduleCount - 1
+ var bitIndex = 7
+ var byteIndex = 0
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
+ if (col == 6) col--
+ while (true) {
+ for (var c = 0; c < 2; c++) {
+ if (this.modules[row][col - c] == null) {
+ var dark = false
+ if (byteIndex < data.length) {
+ dark = ((data[byteIndex] >>> bitIndex) & 1) == 1
+ }
+ var mask = QRUtil.getMask(maskPattern, row, col - c)
+ if (mask) {
+ dark = !dark
+ }
+ this.modules[row][col - c] = dark
+ bitIndex--
+ if (bitIndex == -1) {
+ byteIndex++
+ bitIndex = 7
+ }
+ }
+ }
+ row += inc
+ if (row < 0 || this.moduleCount <= row) {
+ row -= inc
+ inc = -inc
+ break
+ }
+ }
+ }
+ }
+ }
+ QRCodeModel.PAD0 = 0xec
+ QRCodeModel.PAD1 = 0x11
+ QRCodeModel.createData = function (typeNumber, errorCorrectLevel, dataList) {
+ var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel)
+ var buffer = new QRBitBuffer()
+ for (var i = 0; i < dataList.length; i++) {
+ var data = dataList[i]
+ buffer.put(data.mode, 4)
+ buffer.put(
+ data.getLength(),
+ QRUtil.getLengthInBits(data.mode, typeNumber)
+ )
+ data.write(buffer)
+ }
+ var totalDataCount = 0
+ for (var i = 0; i < rsBlocks.length; i++) {
+ totalDataCount += rsBlocks[i].dataCount
+ }
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
+ throw new Error(
+ 'code length overflow. (' +
+ buffer.getLengthInBits() +
+ '>' +
+ totalDataCount * 8 +
+ ')'
+ )
+ }
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
+ buffer.put(0, 4)
+ }
+ while (buffer.getLengthInBits() % 8 != 0) {
+ buffer.putBit(false)
+ }
+ while (true) {
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
+ break
+ }
+ buffer.put(QRCodeModel.PAD0, 8)
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
+ break
+ }
+ buffer.put(QRCodeModel.PAD1, 8)
+ }
+ return QRCodeModel.createBytes(buffer, rsBlocks)
+ }
+ QRCodeModel.createBytes = function (buffer, rsBlocks) {
+ var offset = 0
+ var maxDcCount = 0
+ var maxEcCount = 0
+ var dcdata = new Array(rsBlocks.length)
+ var ecdata = new Array(rsBlocks.length)
+ for (var r = 0; r < rsBlocks.length; r++) {
+ var dcCount = rsBlocks[r].dataCount
+ var ecCount = rsBlocks[r].totalCount - dcCount
+ maxDcCount = Math.max(maxDcCount, dcCount)
+ maxEcCount = Math.max(maxEcCount, ecCount)
+ dcdata[r] = new Array(dcCount)
+ for (var i = 0; i < dcdata[r].length; i++) {
+ dcdata[r][i] = 0xff & buffer.buffer[i + offset]
+ }
+ offset += dcCount
+ var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount)
+ var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1)
+ var modPoly = rawPoly.mod(rsPoly)
+ ecdata[r] = new Array(rsPoly.getLength() - 1)
+ for (var i = 0; i < ecdata[r].length; i++) {
+ var modIndex = i + modPoly.getLength() - ecdata[r].length
+ ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0
+ }
+ }
+ var totalCodeCount = 0
+ for (var i = 0; i < rsBlocks.length; i++) {
+ totalCodeCount += rsBlocks[i].totalCount
+ }
+ var data = new Array(totalCodeCount)
+ var index = 0
+ for (var i = 0; i < maxDcCount; i++) {
+ for (var r = 0; r < rsBlocks.length; r++) {
+ if (i < dcdata[r].length) {
+ data[index++] = dcdata[r][i]
+ }
+ }
+ }
+ for (var i = 0; i < maxEcCount; i++) {
+ for (var r = 0; r < rsBlocks.length; r++) {
+ if (i < ecdata[r].length) {
+ data[index++] = ecdata[r][i]
+ }
+ }
+ }
+ return data
+ }
+ var QRMode = {
+ MODE_NUMBER: 1 << 0,
+ MODE_ALPHA_NUM: 1 << 1,
+ MODE_8BIT_BYTE: 1 << 2,
+ MODE_KANJI: 1 << 3
+ }
+ var QRErrorCorrectLevel = { L: 1, M: 0, Q: 3, H: 2 }
+ var QRMaskPattern = {
+ PATTERN000: 0,
+ PATTERN001: 1,
+ PATTERN010: 2,
+ PATTERN011: 3,
+ PATTERN100: 4,
+ PATTERN101: 5,
+ PATTERN110: 6,
+ PATTERN111: 7
+ }
+ var QRUtil = {
+ PATTERN_POSITION_TABLE: [
+ [],
+ [6, 18],
+ [6, 22],
+ [6, 26],
+ [6, 30],
+ [6, 34],
+ [6, 22, 38],
+ [6, 24, 42],
+ [6, 26, 46],
+ [6, 28, 50],
+ [6, 30, 54],
+ [6, 32, 58],
+ [6, 34, 62],
+ [6, 26, 46, 66],
+ [6, 26, 48, 70],
+ [6, 26, 50, 74],
+ [6, 30, 54, 78],
+ [6, 30, 56, 82],
+ [6, 30, 58, 86],
+ [6, 34, 62, 90],
+ [6, 28, 50, 72, 94],
+ [6, 26, 50, 74, 98],
+ [6, 30, 54, 78, 102],
+ [6, 28, 54, 80, 106],
+ [6, 32, 58, 84, 110],
+ [6, 30, 58, 86, 114],
+ [6, 34, 62, 90, 118],
+ [6, 26, 50, 74, 98, 122],
+ [6, 30, 54, 78, 102, 126],
+ [6, 26, 52, 78, 104, 130],
+ [6, 30, 56, 82, 108, 134],
+ [6, 34, 60, 86, 112, 138],
+ [6, 30, 58, 86, 114, 142],
+ [6, 34, 62, 90, 118, 146],
+ [6, 30, 54, 78, 102, 126, 150],
+ [6, 24, 50, 76, 102, 128, 154],
+ [6, 28, 54, 80, 106, 132, 158],
+ [6, 32, 58, 84, 110, 136, 162],
+ [6, 26, 54, 82, 110, 138, 166],
+ [6, 30, 58, 86, 114, 142, 170]
+ ],
+ G15:
+ (1 << 10) |
+ (1 << 8) |
+ (1 << 5) |
+ (1 << 4) |
+ (1 << 2) |
+ (1 << 1) |
+ (1 << 0),
+ G18:
+ (1 << 12) |
+ (1 << 11) |
+ (1 << 10) |
+ (1 << 9) |
+ (1 << 8) |
+ (1 << 5) |
+ (1 << 2) |
+ (1 << 0),
+ G15_MASK: (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1),
+ getBCHTypeInfo: function (data) {
+ var d = data << 10
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
+ d ^=
+ QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15))
+ }
+ return ((data << 10) | d) ^ QRUtil.G15_MASK
+ },
+ getBCHTypeNumber: function (data) {
+ var d = data << 12
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
+ d ^=
+ QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18))
+ }
+ return (data << 12) | d
+ },
+ getBCHDigit: function (data) {
+ var digit = 0
+ while (data != 0) {
+ digit++
+ data >>>= 1
+ }
+ return digit
+ },
+ getPatternPosition: function (typeNumber) {
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]
+ },
+ getMask: function (maskPattern, i, j) {
+ switch (maskPattern) {
+ case QRMaskPattern.PATTERN000:
+ return (i + j) % 2 == 0
+ case QRMaskPattern.PATTERN001:
+ return i % 2 == 0
+ case QRMaskPattern.PATTERN010:
+ return j % 3 == 0
+ case QRMaskPattern.PATTERN011:
+ return (i + j) % 3 == 0
+ case QRMaskPattern.PATTERN100:
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0
+ case QRMaskPattern.PATTERN101:
+ return (i * j) % 2 + (i * j) % 3 == 0
+ case QRMaskPattern.PATTERN110:
+ return ((i * j) % 2 + (i * j) % 3) % 2 == 0
+ case QRMaskPattern.PATTERN111:
+ return ((i * j) % 3 + (i + j) % 2) % 2 == 0
+ default:
+ throw new Error('bad maskPattern:' + maskPattern)
+ }
+ },
+ getErrorCorrectPolynomial: function (errorCorrectLength) {
+ var a = new QRPolynomial([1], 0)
+ for (var i = 0; i < errorCorrectLength; i++) {
+ a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0))
+ }
+ return a
+ },
+ getLengthInBits: function (mode, type) {
+ if (type >= 1 && type < 10) {
+ switch (mode) {
+ case QRMode.MODE_NUMBER:
+ return 10
+ case QRMode.MODE_ALPHA_NUM:
+ return 9
+ case QRMode.MODE_8BIT_BYTE:
+ return 8
+ case QRMode.MODE_KANJI:
+ return 8
+ default:
+ throw new Error('mode:' + mode)
+ }
+ } else if (type < 27) {
+ switch (mode) {
+ case QRMode.MODE_NUMBER:
+ return 12
+ case QRMode.MODE_ALPHA_NUM:
+ return 11
+ case QRMode.MODE_8BIT_BYTE:
+ return 16
+ case QRMode.MODE_KANJI:
+ return 10
+ default:
+ throw new Error('mode:' + mode)
+ }
+ } else if (type < 41) {
+ switch (mode) {
+ case QRMode.MODE_NUMBER:
+ return 14
+ case QRMode.MODE_ALPHA_NUM:
+ return 13
+ case QRMode.MODE_8BIT_BYTE:
+ return 16
+ case QRMode.MODE_KANJI:
+ return 12
+ default:
+ throw new Error('mode:' + mode)
+ }
+ } else {
+ throw new Error('type:' + type)
+ }
+ },
+ getLostPoint: function (qrCode) {
+ var moduleCount = qrCode.getModuleCount()
+ var lostPoint = 0
+ for (var row = 0; row < moduleCount; row++) {
+ for (var col = 0; col < moduleCount; col++) {
+ var sameCount = 0
+ var dark = qrCode.isDark(row, col)
+ for (var r = -1; r <= 1; r++) {
+ if (row + r < 0 || moduleCount <= row + r) {
+ continue
+ }
+ for (var c = -1; c <= 1; c++) {
+ if (col + c < 0 || moduleCount <= col + c) {
+ continue
+ }
+ if (r == 0 && c == 0) {
+ continue
+ }
+ if (dark == qrCode.isDark(row + r, col + c)) {
+ sameCount++
+ }
+ }
+ }
+ if (sameCount > 5) {
+ lostPoint += 3 + sameCount - 5
+ }
+ }
+ }
+ for (var row = 0; row < moduleCount - 1; row++) {
+ for (var col = 0; col < moduleCount - 1; col++) {
+ var count = 0
+ if (qrCode.isDark(row, col)) count++
+ if (qrCode.isDark(row + 1, col)) count++
+ if (qrCode.isDark(row, col + 1)) count++
+ if (qrCode.isDark(row + 1, col + 1)) count++
+ if (count == 0 || count == 4) {
+ lostPoint += 3
+ }
+ }
+ }
+ for (var row = 0; row < moduleCount; row++) {
+ for (var col = 0; col < moduleCount - 6; col++) {
+ if (
+ qrCode.isDark(row, col) &&
+ !qrCode.isDark(row, col + 1) &&
+ qrCode.isDark(row, col + 2) &&
+ qrCode.isDark(row, col + 3) &&
+ qrCode.isDark(row, col + 4) &&
+ !qrCode.isDark(row, col + 5) &&
+ qrCode.isDark(row, col + 6)
+ ) {
+ lostPoint += 40
+ }
+ }
+ }
+ for (var col = 0; col < moduleCount; col++) {
+ for (var row = 0; row < moduleCount - 6; row++) {
+ if (
+ qrCode.isDark(row, col) &&
+ !qrCode.isDark(row + 1, col) &&
+ qrCode.isDark(row + 2, col) &&
+ qrCode.isDark(row + 3, col) &&
+ qrCode.isDark(row + 4, col) &&
+ !qrCode.isDark(row + 5, col) &&
+ qrCode.isDark(row + 6, col)
+ ) {
+ lostPoint += 40
+ }
+ }
+ }
+ var darkCount = 0
+ for (var col = 0; col < moduleCount; col++) {
+ for (var row = 0; row < moduleCount; row++) {
+ if (qrCode.isDark(row, col)) {
+ darkCount++
+ }
+ }
+ }
+ var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5
+ lostPoint += ratio * 10
+ return lostPoint
+ }
+ }
+ var QRMath = {
+ glog: function (n) {
+ if (n < 1) {
+ throw new Error('glog(' + n + ')')
+ }
+ return QRMath.LOG_TABLE[n]
+ },
+ gexp: function (n) {
+ while (n < 0) {
+ n += 255
+ }
+ while (n >= 256) {
+ n -= 255
+ }
+ return QRMath.EXP_TABLE[n]
+ },
+ EXP_TABLE: new Array(256),
+ LOG_TABLE: new Array(256)
+ }
+ for (var i = 0; i < 8; i++) {
+ QRMath.EXP_TABLE[i] = 1 << i
+ }
+ for (var i = 8; i < 256; i++) {
+ QRMath.EXP_TABLE[i] =
+ QRMath.EXP_TABLE[i - 4] ^
+ QRMath.EXP_TABLE[i - 5] ^
+ QRMath.EXP_TABLE[i - 6] ^
+ QRMath.EXP_TABLE[i - 8]
+ }
+ for (var i = 0; i < 255; i++) {
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i
+ }
+ function QRPolynomial (num, shift) {
+ if (num.length == undefined) {
+ throw new Error(num.length + '/' + shift)
+ }
+ var offset = 0
+ while (offset < num.length && num[offset] == 0) {
+ offset++
+ }
+ this.num = new Array(num.length - offset + shift)
+ for (var i = 0; i < num.length - offset; i++) {
+ this.num[i] = num[i + offset]
+ }
+ }
+ QRPolynomial.prototype = {
+ get: function (index) {
+ return this.num[index]
+ },
+ getLength: function () {
+ return this.num.length
+ },
+ multiply: function (e) {
+ var num = new Array(this.getLength() + e.getLength() - 1)
+ for (var i = 0; i < this.getLength(); i++) {
+ for (var j = 0; j < e.getLength(); j++) {
+ num[i + j] ^= QRMath.gexp(
+ QRMath.glog(this.get(i)) + QRMath.glog(e.get(j))
+ )
+ }
+ }
+ return new QRPolynomial(num, 0)
+ },
+ mod: function (e) {
+ if (this.getLength() - e.getLength() < 0) {
+ return this
+ }
+ var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0))
+ var num = new Array(this.getLength())
+ for (var i = 0; i < this.getLength(); i++) {
+ num[i] = this.get(i)
+ }
+ for (var i = 0; i < e.getLength(); i++) {
+ num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio)
+ }
+ return new QRPolynomial(num, 0).mod(e)
+ }
+ }
+ function QRRSBlock (totalCount, dataCount) {
+ this.totalCount = totalCount
+ this.dataCount = dataCount
+ }
+ QRRSBlock.RS_BLOCK_TABLE = [
+ [1, 26, 19],
+ [1, 26, 16],
+ [1, 26, 13],
+ [1, 26, 9],
+ [1, 44, 34],
+ [1, 44, 28],
+ [1, 44, 22],
+ [1, 44, 16],
+ [1, 70, 55],
+ [1, 70, 44],
+ [2, 35, 17],
+ [2, 35, 13],
+ [1, 100, 80],
+ [2, 50, 32],
+ [2, 50, 24],
+ [4, 25, 9],
+ [1, 134, 108],
+ [2, 67, 43],
+ [2, 33, 15, 2, 34, 16],
+ [2, 33, 11, 2, 34, 12],
+ [2, 86, 68],
+ [4, 43, 27],
+ [4, 43, 19],
+ [4, 43, 15],
+ [2, 98, 78],
+ [4, 49, 31],
+ [2, 32, 14, 4, 33, 15],
+ [4, 39, 13, 1, 40, 14],
+ [2, 121, 97],
+ [2, 60, 38, 2, 61, 39],
+ [4, 40, 18, 2, 41, 19],
+ [4, 40, 14, 2, 41, 15],
+ [2, 146, 116],
+ [3, 58, 36, 2, 59, 37],
+ [4, 36, 16, 4, 37, 17],
+ [4, 36, 12, 4, 37, 13],
+ [2, 86, 68, 2, 87, 69],
+ [4, 69, 43, 1, 70, 44],
+ [6, 43, 19, 2, 44, 20],
+ [6, 43, 15, 2, 44, 16],
+ [4, 101, 81],
+ [1, 80, 50, 4, 81, 51],
+ [4, 50, 22, 4, 51, 23],
+ [3, 36, 12, 8, 37, 13],
+ [2, 116, 92, 2, 117, 93],
+ [6, 58, 36, 2, 59, 37],
+ [4, 46, 20, 6, 47, 21],
+ [7, 42, 14, 4, 43, 15],
+ [4, 133, 107],
+ [8, 59, 37, 1, 60, 38],
+ [8, 44, 20, 4, 45, 21],
+ [12, 33, 11, 4, 34, 12],
+ [3, 145, 115, 1, 146, 116],
+ [4, 64, 40, 5, 65, 41],
+ [11, 36, 16, 5, 37, 17],
+ [11, 36, 12, 5, 37, 13],
+ [5, 109, 87, 1, 110, 88],
+ [5, 65, 41, 5, 66, 42],
+ [5, 54, 24, 7, 55, 25],
+ [11, 36, 12],
+ [5, 122, 98, 1, 123, 99],
+ [7, 73, 45, 3, 74, 46],
+ [15, 43, 19, 2, 44, 20],
+ [3, 45, 15, 13, 46, 16],
+ [1, 135, 107, 5, 136, 108],
+ [10, 74, 46, 1, 75, 47],
+ [1, 50, 22, 15, 51, 23],
+ [2, 42, 14, 17, 43, 15],
+ [5, 150, 120, 1, 151, 121],
+ [9, 69, 43, 4, 70, 44],
+ [17, 50, 22, 1, 51, 23],
+ [2, 42, 14, 19, 43, 15],
+ [3, 141, 113, 4, 142, 114],
+ [3, 70, 44, 11, 71, 45],
+ [17, 47, 21, 4, 48, 22],
+ [9, 39, 13, 16, 40, 14],
+ [3, 135, 107, 5, 136, 108],
+ [3, 67, 41, 13, 68, 42],
+ [15, 54, 24, 5, 55, 25],
+ [15, 43, 15, 10, 44, 16],
+ [4, 144, 116, 4, 145, 117],
+ [17, 68, 42],
+ [17, 50, 22, 6, 51, 23],
+ [19, 46, 16, 6, 47, 17],
+ [2, 139, 111, 7, 140, 112],
+ [17, 74, 46],
+ [7, 54, 24, 16, 55, 25],
+ [34, 37, 13],
+ [4, 151, 121, 5, 152, 122],
+ [4, 75, 47, 14, 76, 48],
+ [11, 54, 24, 14, 55, 25],
+ [16, 45, 15, 14, 46, 16],
+ [6, 147, 117, 4, 148, 118],
+ [6, 73, 45, 14, 74, 46],
+ [11, 54, 24, 16, 55, 25],
+ [30, 46, 16, 2, 47, 17],
+ [8, 132, 106, 4, 133, 107],
+ [8, 75, 47, 13, 76, 48],
+ [7, 54, 24, 22, 55, 25],
+ [22, 45, 15, 13, 46, 16],
+ [10, 142, 114, 2, 143, 115],
+ [19, 74, 46, 4, 75, 47],
+ [28, 50, 22, 6, 51, 23],
+ [33, 46, 16, 4, 47, 17],
+ [8, 152, 122, 4, 153, 123],
+ [22, 73, 45, 3, 74, 46],
+ [8, 53, 23, 26, 54, 24],
+ [12, 45, 15, 28, 46, 16],
+ [3, 147, 117, 10, 148, 118],
+ [3, 73, 45, 23, 74, 46],
+ [4, 54, 24, 31, 55, 25],
+ [11, 45, 15, 31, 46, 16],
+ [7, 146, 116, 7, 147, 117],
+ [21, 73, 45, 7, 74, 46],
+ [1, 53, 23, 37, 54, 24],
+ [19, 45, 15, 26, 46, 16],
+ [5, 145, 115, 10, 146, 116],
+ [19, 75, 47, 10, 76, 48],
+ [15, 54, 24, 25, 55, 25],
+ [23, 45, 15, 25, 46, 16],
+ [13, 145, 115, 3, 146, 116],
+ [2, 74, 46, 29, 75, 47],
+ [42, 54, 24, 1, 55, 25],
+ [23, 45, 15, 28, 46, 16],
+ [17, 145, 115],
+ [10, 74, 46, 23, 75, 47],
+ [10, 54, 24, 35, 55, 25],
+ [19, 45, 15, 35, 46, 16],
+ [17, 145, 115, 1, 146, 116],
+ [14, 74, 46, 21, 75, 47],
+ [29, 54, 24, 19, 55, 25],
+ [11, 45, 15, 46, 46, 16],
+ [13, 145, 115, 6, 146, 116],
+ [14, 74, 46, 23, 75, 47],
+ [44, 54, 24, 7, 55, 25],
+ [59, 46, 16, 1, 47, 17],
+ [12, 151, 121, 7, 152, 122],
+ [12, 75, 47, 26, 76, 48],
+ [39, 54, 24, 14, 55, 25],
+ [22, 45, 15, 41, 46, 16],
+ [6, 151, 121, 14, 152, 122],
+ [6, 75, 47, 34, 76, 48],
+ [46, 54, 24, 10, 55, 25],
+ [2, 45, 15, 64, 46, 16],
+ [17, 152, 122, 4, 153, 123],
+ [29, 74, 46, 14, 75, 47],
+ [49, 54, 24, 10, 55, 25],
+ [24, 45, 15, 46, 46, 16],
+ [4, 152, 122, 18, 153, 123],
+ [13, 74, 46, 32, 75, 47],
+ [48, 54, 24, 14, 55, 25],
+ [42, 45, 15, 32, 46, 16],
+ [20, 147, 117, 4, 148, 118],
+ [40, 75, 47, 7, 76, 48],
+ [43, 54, 24, 22, 55, 25],
+ [10, 45, 15, 67, 46, 16],
+ [19, 148, 118, 6, 149, 119],
+ [18, 75, 47, 31, 76, 48],
+ [34, 54, 24, 34, 55, 25],
+ [20, 45, 15, 61, 46, 16]
+ ]
+ QRRSBlock.getRSBlocks = function (typeNumber, errorCorrectLevel) {
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel)
+ if (rsBlock == undefined) {
+ throw new Error(
+ 'bad rs block @ typeNumber:' +
+ typeNumber +
+ '/errorCorrectLevel:' +
+ errorCorrectLevel
+ )
+ }
+ var length = rsBlock.length / 3
+ var list = []
+ for (var i = 0; i < length; i++) {
+ var count = rsBlock[i * 3 + 0]
+ var totalCount = rsBlock[i * 3 + 1]
+ var dataCount = rsBlock[i * 3 + 2]
+ for (var j = 0; j < count; j++) {
+ list.push(new QRRSBlock(totalCount, dataCount))
+ }
+ }
+ return list
+ }
+ QRRSBlock.getRsBlockTable = function (typeNumber, errorCorrectLevel) {
+ switch (errorCorrectLevel) {
+ case QRErrorCorrectLevel.L:
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]
+ case QRErrorCorrectLevel.M:
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]
+ case QRErrorCorrectLevel.Q:
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]
+ case QRErrorCorrectLevel.H:
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]
+ default:
+ return undefined
+ }
+ }
+ function QRBitBuffer () {
+ this.buffer = []
+ this.length = 0
+ }
+ QRBitBuffer.prototype = {
+ get: function (index) {
+ var bufIndex = Math.floor(index / 8)
+ return ((this.buffer[bufIndex] >>> (7 - index % 8)) & 1) == 1
+ },
+ put: function (num, length) {
+ for (var i = 0; i < length; i++) {
+ this.putBit(((num >>> (length - i - 1)) & 1) == 1)
+ }
+ },
+ getLengthInBits: function () {
+ return this.length
+ },
+ putBit: function (bit) {
+ var bufIndex = Math.floor(this.length / 8)
+ if (this.buffer.length <= bufIndex) {
+ this.buffer.push(0)
+ }
+ if (bit) {
+ this.buffer[bufIndex] |= 0x80 >>> (this.length % 8)
+ }
+ this.length++
+ }
+ }
+ var QRCodeLimitLength = [
+ [17, 14, 11, 7],
+ [32, 26, 20, 14],
+ [53, 42, 32, 24],
+ [78, 62, 46, 34],
+ [106, 84, 60, 44],
+ [134, 106, 74, 58],
+ [154, 122, 86, 64],
+ [192, 152, 108, 84],
+ [230, 180, 130, 98],
+ [271, 213, 151, 119],
+ [321, 251, 177, 137],
+ [367, 287, 203, 155],
+ [425, 331, 241, 177],
+ [458, 362, 258, 194],
+ [520, 412, 292, 220],
+ [586, 450, 322, 250],
+ [644, 504, 364, 280],
+ [718, 560, 394, 310],
+ [792, 624, 442, 338],
+ [858, 666, 482, 382],
+ [929, 711, 509, 403],
+ [1003, 779, 565, 439],
+ [1091, 857, 611, 461],
+ [1171, 911, 661, 511],
+ [1273, 997, 715, 535],
+ [1367, 1059, 751, 593],
+ [1465, 1125, 805, 625],
+ [1528, 1190, 868, 658],
+ [1628, 1264, 908, 698],
+ [1732, 1370, 982, 742],
+ [1840, 1452, 1030, 790],
+ [1952, 1538, 1112, 842],
+ [2068, 1628, 1168, 898],
+ [2188, 1722, 1228, 958],
+ [2303, 1809, 1283, 983],
+ [2431, 1911, 1351, 1051],
+ [2563, 1989, 1423, 1093],
+ [2699, 2099, 1499, 1139],
+ [2809, 2213, 1579, 1219],
+ [2953, 2331, 1663, 1273]
+ ]
+
+ function _isSupportCanvas () {
+ return typeof CanvasRenderingContext2D !== 'undefined'
+ }
+
+ // android 2.x doesn't support Data-URI spec
+ function _getAndroid () {
+ var android = false
+ var sAgent = navigator.userAgent
+
+ if (/android/i.test(sAgent)) {
+ // android
+ android = true
+ var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i)
+
+ if (aMat && aMat[1]) {
+ android = parseFloat(aMat[1])
+ }
+ }
+
+ return android
+ }
+
+ var svgDrawer = (function () {
+ var Drawing = function (el, htOption) {
+ this._el = el
+ this._htOption = htOption
+ }
+
+ Drawing.prototype.draw = function (oQRCode) {
+ var _htOption = this._htOption
+ var _el = this._el
+ var nCount = oQRCode.getModuleCount()
+ var nWidth = Math.floor(_htOption.width / nCount)
+ var nHeight = Math.floor(_htOption.height / nCount)
+
+ this.clear()
+
+ function makeSVG (tag, attrs) {
+ var el = document.createElementNS('http://www.w3.org/2000/svg', tag)
+ for (var k in attrs) {
+ if (attrs.hasOwnProperty(k)) el.setAttribute(k, attrs[k])
+ }
+ return el
+ }
+
+ var svg = makeSVG('svg', {
+ viewBox: '0 0 ' + String(nCount) + ' ' + String(nCount),
+ width: '100%',
+ height: '100%',
+ fill: _htOption.colorLight
+ })
+ svg.setAttributeNS(
+ 'http://www.w3.org/2000/xmlns/',
+ 'xmlns:xlink',
+ 'http://www.w3.org/1999/xlink'
+ )
+ _el.appendChild(svg)
+
+ svg.appendChild(
+ makeSVG('rect', {
+ fill: _htOption.colorLight,
+ width: '100%',
+ height: '100%'
+ })
+ )
+ svg.appendChild(
+ makeSVG('rect', {
+ fill: _htOption.colorDark,
+ width: '1',
+ height: '1',
+ id: 'template'
+ })
+ )
+
+ for (var row = 0; row < nCount; row++) {
+ for (var col = 0; col < nCount; col++) {
+ if (oQRCode.isDark(row, col)) {
+ var child = makeSVG('use', { x: String(col), y: String(row) })
+ child.setAttributeNS(
+ 'http://www.w3.org/1999/xlink',
+ 'href',
+ '#template'
+ )
+ svg.appendChild(child)
+ }
+ }
+ }
+ }
+ Drawing.prototype.clear = function () {
+ while (this._el.hasChildNodes()) this._el.removeChild(this._el.lastChild)
+ }
+ return Drawing
+ })()
+
+ var useSVG = document.documentElement.tagName.toLowerCase() === 'svg'
+
+ // Drawing in DOM by using Table tag
+ var Drawing = useSVG
+ ? svgDrawer
+ : !_isSupportCanvas()
+ ? (function () {
+ var Drawing = function (el, htOption) {
+ this._el = el
+ this._htOption = htOption
+ }
+
+ /**
+ * Draw the QRCode
+ *
+ * @param {QRCode} oQRCode
+ */
+ Drawing.prototype.draw = function (oQRCode) {
+ var _htOption = this._htOption
+ var _el = this._el
+ var nCount = oQRCode.getModuleCount()
+ var nWidth = Math.floor(_htOption.width / nCount)
+ var nHeight = Math.floor(_htOption.height / nCount)
+ var aHTML = ['<table style="border:0;border-collapse:collapse;">']
+
+ for (var row = 0; row < nCount; row++) {
+ aHTML.push('<tr>')
+
+ for (var col = 0; col < nCount; col++) {
+ aHTML.push(
+ '<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:' +
+ nWidth +
+ 'px;height:' +
+ nHeight +
+ 'px;background-color:' +
+ (oQRCode.isDark(row, col)
+ ? _htOption.colorDark
+ : _htOption.colorLight) +
+ ';"></td>'
+ )
+ }
+
+ aHTML.push('</tr>')
+ }
+
+ aHTML.push('</table>')
+ _el.innerHTML = aHTML.join('')
+
+ // Fix the margin values as real size.
+ var elTable = _el.childNodes[0]
+ var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2
+ var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2
+
+ if (nLeftMarginTable > 0 && nTopMarginTable > 0) {
+ elTable.style.margin =
+ nTopMarginTable + 'px ' + nLeftMarginTable + 'px'
+ }
+ }
+
+ /**
+ * Clear the QRCode
+ */
+ Drawing.prototype.clear = function () {
+ this._el.innerHTML = ''
+ }
+
+ return Drawing
+ })()
+ : (function () {
+ // Drawing in Canvas
+ function _onMakeImage () {
+ this._elImage.src = this._elCanvas.toDataURL('image/png')
+ this._elImage.style.display = 'block'
+ this._elCanvas.style.display = 'none'
+ }
+
+ // Android 2.1 bug workaround
+ // http://code.google.com/p/android/issues/detail?id=5141
+ if (this._android && this._android <= 2.1) {
+ var factor = 1 / window.devicePixelRatio
+ var drawImage = CanvasRenderingContext2D.prototype.drawImage
+ CanvasRenderingContext2D.prototype.drawImage = function (
+ image,
+ sx,
+ sy,
+ sw,
+ sh,
+ dx,
+ dy,
+ dw,
+ dh
+ ) {
+ if ('nodeName' in image && /img/i.test(image.nodeName)) {
+ for (var i = arguments.length - 1; i >= 1; i--) {
+ arguments[i] = arguments[i] * factor
+ }
+ } else if (typeof dw === 'undefined') {
+ arguments[1] *= factor
+ arguments[2] *= factor
+ arguments[3] *= factor
+ arguments[4] *= factor
+ }
+
+ drawImage.apply(this, arguments)
+ }
+ }
+
+ /**
+ * Check whether the user's browser supports Data URI or not
+ *
+ * @private
+ * @param {Function} fSuccess Occurs if it supports Data URI
+ * @param {Function} fFail Occurs if it doesn't support Data URI
+ */
+ function _safeSetDataURI (fSuccess, fFail) {
+ var self = this
+ self._fFail = fFail
+ self._fSuccess = fSuccess
+
+ // Check it just once
+ if (self._bSupportDataURI === null) {
+ var el = document.createElement('img')
+ var fOnError = function () {
+ self._bSupportDataURI = false
+
+ if (self._fFail) {
+ self._fFail.call(self)
+ }
+ }
+ var fOnSuccess = function () {
+ self._bSupportDataURI = true
+
+ if (self._fSuccess) {
+ self._fSuccess.call(self)
+ }
+ }
+
+ el.onabort = fOnError
+ el.onerror = fOnError
+ el.onload = fOnSuccess
+ el.src =
+ 'data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==' // the Image contains 1px data.
+ } else if (self._bSupportDataURI === true && self._fSuccess) {
+ self._fSuccess.call(self)
+ } else if (self._bSupportDataURI === false && self._fFail) {
+ self._fFail.call(self)
+ }
+ }
+
+ /**
+ * Drawing QRCode by using canvas
+ *
+ * @constructor
+ * @param {HTMLElement} el
+ * @param {Object} htOption QRCode Options
+ */
+ var Drawing = function (el, htOption) {
+ this._bIsPainted = false
+ this._android = _getAndroid()
+
+ this._htOption = htOption
+ this._elCanvas = document.createElement('canvas')
+ this._elCanvas.width = htOption.width
+ this._elCanvas.height = htOption.height
+ el.appendChild(this._elCanvas)
+ this._el = el
+ this._oContext = this._elCanvas.getContext('2d')
+ this._bIsPainted = false
+ this._elImage = document.createElement('img')
+ this._elImage.alt = 'Scan me!'
+ this._elImage.style.display = 'none'
+ this._el.appendChild(this._elImage)
+ this._bSupportDataURI = null
+ }
+
+ /**
+ * Draw the QRCode
+ *
+ * @param {QRCode} oQRCode
+ */
+ Drawing.prototype.draw = function (oQRCode) {
+ var _elImage = this._elImage
+ var _oContext = this._oContext
+ var _htOption = this._htOption
+
+ var nCount = oQRCode.getModuleCount()
+ var nWidth = _htOption.width / nCount
+ var nHeight = _htOption.height / nCount
+ var nRoundedWidth = Math.round(nWidth)
+ var nRoundedHeight = Math.round(nHeight)
+
+ _elImage.style.display = 'none'
+ this.clear()
+
+ for (var row = 0; row < nCount; row++) {
+ for (var col = 0; col < nCount; col++) {
+ var bIsDark = oQRCode.isDark(row, col)
+ var nLeft = col * nWidth
+ var nTop = row * nHeight
+ _oContext.strokeStyle = bIsDark
+ ? _htOption.colorDark
+ : _htOption.colorLight
+ _oContext.lineWidth = 1
+ _oContext.fillStyle = bIsDark
+ ? _htOption.colorDark
+ : _htOption.colorLight
+ _oContext.fillRect(nLeft, nTop, nWidth, nHeight)
+
+ // 안티 앨리어싱 방지 처리
+ _oContext.strokeRect(
+ Math.floor(nLeft) + 0.5,
+ Math.floor(nTop) + 0.5,
+ nRoundedWidth,
+ nRoundedHeight
+ )
+
+ _oContext.strokeRect(
+ Math.ceil(nLeft) - 0.5,
+ Math.ceil(nTop) - 0.5,
+ nRoundedWidth,
+ nRoundedHeight
+ )
+ }
+ }
+
+ this._bIsPainted = true
+ }
+
+ /**
+ * Make the image from Canvas if the browser supports Data URI.
+ */
+ Drawing.prototype.makeImage = function () {
+ if (this._bIsPainted) {
+ _safeSetDataURI.call(this, _onMakeImage)
+ }
+ }
+
+ /**
+ * Return whether the QRCode is painted or not
+ *
+ * @return {Boolean}
+ */
+ Drawing.prototype.isPainted = function () {
+ return this._bIsPainted
+ }
+
+ /**
+ * Clear the QRCode
+ */
+ Drawing.prototype.clear = function () {
+ this._oContext.clearRect(
+ 0,
+ 0,
+ this._elCanvas.width,
+ this._elCanvas.height
+ )
+ this._bIsPainted = false
+ }
+
+ /**
+ * @private
+ * @param {Number} nNumber
+ */
+ Drawing.prototype.round = function (nNumber) {
+ if (!nNumber) {
+ return nNumber
+ }
+
+ return Math.floor(nNumber * 1000) / 1000
+ }
+
+ return Drawing
+ })()
+
+ /**
+ * Get the type by string length
+ *
+ * @private
+ * @param {String} sText
+ * @param {Number} nCorrectLevel
+ * @return {Number} type
+ */
+ function _getTypeNumber (sText, nCorrectLevel) {
+ var nType = 1
+ var length = _getUTF8Length(sText)
+
+ for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
+ var nLimit = 0
+
+ switch (nCorrectLevel) {
+ case QRErrorCorrectLevel.L:
+ nLimit = QRCodeLimitLength[i][0]
+ break
+ case QRErrorCorrectLevel.M:
+ nLimit = QRCodeLimitLength[i][1]
+ break
+ case QRErrorCorrectLevel.Q:
+ nLimit = QRCodeLimitLength[i][2]
+ break
+ case QRErrorCorrectLevel.H:
+ nLimit = QRCodeLimitLength[i][3]
+ break
+ }
+
+ if (length <= nLimit) {
+ break
+ } else {
+ nType++
+ }
+ }
+
+ if (nType > QRCodeLimitLength.length) {
+ throw new Error('Too long data')
+ }
+
+ return nType
+ }
+
+ function _getUTF8Length (sText) {
+ var replacedText = encodeURI(sText)
+ .toString()
+ .replace(/\%[0-9a-fA-F]{2}/g, 'a')
+ return replacedText.length + (replacedText.length != sText ? 3 : 0)
+ }
+
+ /**
+ * @class QRCode
+ * @constructor
+ * @example
+ * new QRCode(document.getElementById("test"), "http://jindo.dev.naver.com/collie");
+ *
+ * @example
+ * var oQRCode = new QRCode("test", {
+ * text : "http://naver.com",
+ * width : 128,
+ * height : 128
+ * });
+ *
+ * oQRCode.clear(); // Clear the QRCode.
+ * oQRCode.makeCode("http://map.naver.com"); // Re-create the QRCode.
+ *
+ * @param {HTMLElement|String} el target element or 'id' attribute of element.
+ * @param {Object|String} vOption
+ * @param {String} vOption.text QRCode link data
+ * @param {Number} [vOption.width=256]
+ * @param {Number} [vOption.height=256]
+ * @param {String} [vOption.colorDark="#000000"]
+ * @param {String} [vOption.colorLight="#ffffff"]
+ * @param {QRCode.CorrectLevel} [vOption.correctLevel=QRCode.CorrectLevel.H] [L|M|Q|H]
+ */
+ QRCode = function (el, vOption) {
+ this._htOption = {
+ width: 256,
+ height: 256,
+ typeNumber: 4,
+ colorDark: '#000000',
+ colorLight: '#ffffff',
+ correctLevel: QRErrorCorrectLevel.H
+ }
+
+ if (typeof vOption === 'string') {
+ vOption = {
+ text: vOption
+ }
+ }
+
+ // Overwrites options
+ if (vOption) {
+ for (var i in vOption) {
+ this._htOption[i] = vOption[i]
+ }
+ }
+
+ if (typeof el === 'string') {
+ el = document.getElementById(el)
+ }
+
+ if (this._htOption.useSVG) {
+ Drawing = svgDrawer
+ }
+
+ this._android = _getAndroid()
+ this._el = el
+ this._oQRCode = null
+ this._oDrawing = new Drawing(this._el, this._htOption)
+
+ if (this._htOption.text) {
+ this.makeCode(this._htOption.text)
+ }
+ }
+
+ /**
+ * Make the QRCode
+ *
+ * @param {String} sText link data
+ */
+ QRCode.prototype.makeCode = function (sText) {
+ this._oQRCode = new QRCodeModel(
+ _getTypeNumber(sText, this._htOption.correctLevel),
+ this._htOption.correctLevel
+ )
+ this._oQRCode.addData(sText)
+ this._oQRCode.make()
+ this._el.title = sText
+ this._oDrawing.draw(this._oQRCode)
+ this.makeImage()
+ }
+
+ /**
+ * Make the Image from Canvas element
+ * - It occurs automatically
+ * - Android below 3 doesn't support Data-URI spec.
+ *
+ * @private
+ */
+ QRCode.prototype.makeImage = function () {
+ if (
+ typeof this._oDrawing.makeImage === 'function' &&
+ (!this._android || this._android >= 3)
+ ) {
+ this._oDrawing.makeImage()
+ }
+ }
+
+ /**
+ * Clear the QRCode
+ */
+ QRCode.prototype.clear = function () {
+ this._oDrawing.clear()
+ }
+
+ /**
+ * @name QRCode.CorrectLevel
+ */
+ QRCode.CorrectLevel = QRErrorCorrectLevel
+})()
diff --git a/testing/web-platform/tests/tools/wave/www/lib/query-parser.js b/testing/web-platform/tests/tools/wave/www/lib/query-parser.js
new file mode 100644
index 0000000000..c8ab8333d2
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/query-parser.js
@@ -0,0 +1,12 @@
+var QueryParser = {};
+
+QueryParser.parseQuery = function () {
+ var queryParameters = {};
+ var keysAndValues = location.search.replace("?", "").split("&");
+ for (var i = 0; i < keysAndValues.length; i++) {
+ var key = keysAndValues[i].split("=")[0];
+ var value = keysAndValues[i].split("=")[1];
+ queryParameters[key] = value;
+ }
+ return queryParameters;
+};
diff --git a/testing/web-platform/tests/tools/wave/www/lib/screen-console.js b/testing/web-platform/tests/tools/wave/www/lib/screen-console.js
new file mode 100644
index 0000000000..0e13b963a6
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/screen-console.js
@@ -0,0 +1,16 @@
+function ScreenConsole(element) {
+ this._element = element;
+}
+
+ScreenConsole.prototype.log = function () {
+ var text = "";
+ for (var i = 0; i < arguments.length; i++) {
+ text += arguments[i] + " ";
+ }
+ console.log(text);
+ this._element.innerText += text + "\n";
+};
+
+ScreenConsole.prototype.clear = function () {
+ this._element.innerText = "";
+};
diff --git a/testing/web-platform/tests/tools/wave/www/lib/ui.js b/testing/web-platform/tests/tools/wave/www/lib/ui.js
new file mode 100644
index 0000000000..4abbece985
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/ui.js
@@ -0,0 +1,100 @@
+const UI = {
+ createElement: config => {
+ if (!config) return;
+ const elementType = config.element || "div";
+ const element = document.createElement(elementType);
+
+ Object.keys(config).forEach(property => {
+ const value = config[property];
+ switch (property.toLowerCase()) {
+ case "id":
+ case "src":
+ case "style":
+ case "placeholder":
+ case "title":
+ case "accept":
+ element.setAttribute(property, value);
+ return;
+ case "classname":
+ element.setAttribute("class", value);
+ return;
+ case "colspan":
+ element.setAttribute("colspan", value);
+ return;
+ case "text":
+ element.innerText = value;
+ return;
+ case "value":
+ element.value = value;
+ return;
+ case "html":
+ element.innerHTML = value;
+ return;
+ case "onclick":
+ element.onclick = value.bind(element);
+ return;
+ case "onchange":
+ element.onchange = value.bind(element);
+ return;
+ case "onkeydown":
+ element.onkeydown = value.bind(element);
+ return;
+ case "onkeyup":
+ element.onkeyup = value.bind(element);
+ return;
+ case "type":
+ if (elementType === "input") element.setAttribute("type", value);
+ return;
+ case "children":
+ if (value instanceof Array) {
+ value.forEach(child => {
+ const childElement =
+ child instanceof Element ? child : UI.createElement(child);
+ if (!childElement) return;
+ element.appendChild(childElement);
+ });
+ } else {
+ const child = value;
+ const childElement =
+ child instanceof Element ? child : UI.createElement(child);
+ if (!childElement) return;
+ element.appendChild(childElement);
+ element.appendChild(childElement);
+ }
+ return;
+ case "disabled":
+ if (value) element.setAttribute("disabled", true);
+ return;
+ case "checked":
+ if (value) element.setAttribute("checked", true);
+ return;
+ case "indeterminate":
+ element.indeterminate = value;
+ return;
+ }
+ });
+ return element;
+ },
+ getElement: id => {
+ return document.getElementById(id);
+ },
+ getRoot: () => {
+ return document.getElementsByTagName("body")[0];
+ },
+ scrollPositions: {},
+ saveScrollPosition: elementId => {
+ let scrollElement = UI.getElement(elementId);
+ if (!scrollElement) return;
+ UI.scrollPositions[elementId] = {
+ scrollLeft: scrollElement.scrollLeft,
+ scrollRight: scrollElement.scrollRight
+ };
+ },
+ loadScrollPosition: elementId => {
+ let scrollElement = UI.getElement(elementId);
+ if (!scrollElement) return;
+ if (!UI.scrollPositions[elementId]) return;
+ scrollElement.scrollLeft = UI.scrollPositions[elementId].scrollLeft;
+ scrollElement.scrollRight = UI.scrollPositions[elementId].scrollRight;
+ }
+};
diff --git a/testing/web-platform/tests/tools/wave/www/lib/utils.js b/testing/web-platform/tests/tools/wave/www/lib/utils.js
new file mode 100644
index 0000000000..d84a2cb69c
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/utils.js
@@ -0,0 +1,57 @@
+const utils = {
+ parseQuery: queryString => {
+ if (queryString.indexOf("?") === -1) return {};
+ queryString = queryString.split("?")[1];
+ const query = {};
+ for (let part of queryString.split("&")) {
+ const keyValue = part.split("=");
+ query[keyValue[0]] = keyValue[1] ? keyValue[1] : null;
+ }
+ return query;
+ },
+ percent: (count, total) => {
+ const percent = Math.floor((count / total) * 10000) / 100;
+ if (!percent) {
+ return 0;
+ }
+ return percent;
+ },
+ saveBlobAsFile: (blob, filename) => {
+ const url = URL.createObjectURL(blob);
+ const a = document.createElement("a");
+ a.style.display = "none";
+ document.body.appendChild(a);
+ a.href = url;
+ a.download = filename;
+ a.click();
+ document.body.removeChild(a);
+ },
+ millisToTimeString(totalMilliseconds) {
+ let milliseconds = (totalMilliseconds % 1000) + "";
+ milliseconds = milliseconds.padStart(3, "0");
+ let seconds = (Math.floor(totalMilliseconds / 1000) % 60) + "";
+ seconds = seconds.padStart(2, "0");
+ let minutes = (Math.floor(totalMilliseconds / 60000) % 60) + "";
+ minutes = minutes.padStart(2, "0");
+ let hours = Math.floor(totalMilliseconds / 3600000) + "";
+ hours = hours.padStart(2, "0");
+ return `${hours}:${minutes}:${seconds}`;
+ },
+ getBrowserIcon(browser) {
+ switch (browser.toLowerCase()) {
+ case "firefox":
+ return "fab fa-firefox";
+ case "edge":
+ return "fab fa-edge";
+ case "chrome":
+ case "chromium":
+ return "fab fa-chrome";
+ case "safari":
+ case "webkit":
+ return "fab fa-safari";
+ }
+ },
+ copyObject(object) {
+ return JSON.parse(JSON.stringify(object));
+ }
+};
diff --git a/testing/web-platform/tests/tools/wave/www/lib/wave-service.js b/testing/web-platform/tests/tools/wave/www/lib/wave-service.js
new file mode 100644
index 0000000000..f7a60e153d
--- /dev/null
+++ b/testing/web-platform/tests/tools/wave/www/lib/wave-service.js
@@ -0,0 +1,866 @@
+function sendRequest(method, uri, headers, data, onSuccess, onError) {
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function () {
+ if (xhr.status === 200) {
+ onSuccess(xhr.response);
+ } else {
+ if (onError) onError(xhr.status, xhr.response);
+ }
+ };
+ xhr.onerror = function () {
+ if (onError) onError();
+ };
+ xhr.open(method, WaveService.uriPrefix + uri, true);
+ for (var header in headers) {
+ xhr.setRequestHeader(header, headers[header]);
+ }
+ xhr.send(data);
+ return xhr;
+}
+
+var WEB_ROOT = "{{WEB_ROOT}}";
+var HTTP_PORT = "{{HTTP_PORT}}";
+var HTTPS_PORT = "{{HTTPS_PORT}}";
+var OPEN = "open";
+var CLOSED = "closed";
+
+var WaveService = {
+ uriPrefix: WEB_ROOT,
+ socket: {
+ state: CLOSED,
+ onMessage: function () {},
+ onOpen: function () {},
+ onClose: function () {},
+ send: function () {},
+ close: function () {},
+ onStateChange: function () {},
+ },
+ // SESSIONS API
+ createSession: function (configuration, onSuccess, onError) {
+ var data = JSON.stringify({
+ tests: configuration.tests,
+ types: configuration.types,
+ timeouts: configuration.timeouts,
+ reference_tokens: configuration.referenceTokens,
+ expiration_date: configuration.expirationDate,
+ labels: configuration.labels,
+ });
+ sendRequest(
+ "POST",
+ "api/sessions",
+ { "Content-Type": "application/json" },
+ data,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess(jsonObject.token);
+ },
+ onError
+ );
+ },
+ readSession: function (token, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/sessions/" + token,
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess({
+ token: jsonObject.token,
+ tests: jsonObject.tests,
+ types: jsonObject.types,
+ userAgent: jsonObject.user_agent,
+ labels: jsonObject.labels,
+ timeouts: jsonObject.timeouts,
+ browser: jsonObject.browser,
+ isPublic: jsonObject.is_public,
+ referenceTokens: jsonObject.reference_tokens,
+ });
+ },
+ onError
+ );
+ },
+ readMultipleSessions: function (tokens, onSuccess, onError) {
+ var requestsLeft = tokens.length;
+ if (requestsLeft === 0) onSuccess([]);
+ var configurations = [];
+ for (var i = 0; i < tokens.length; i++) {
+ var token = tokens[i];
+ WaveService.readSession(
+ token,
+ function (configuration) {
+ requestsLeft--;
+ configurations.push(configuration);
+ if (requestsLeft === 0) onSuccess(configurations);
+ },
+ function (status) {
+ if (status === 404) requestsLeft--;
+ if (status !== 404 && onError) onError();
+ if (requestsLeft === 0) onSuccess(configurations);
+ }
+ );
+ }
+ },
+ readSessionStatus: function (token, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/sessions/" + token + "/status",
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ var dateStarted = null;
+ if (jsonObject.date_started) {
+ dateStarted = new Date(jsonObject.date_started);
+ }
+ var dateFinished = null;
+ if (jsonObject.date_finished) {
+ dateFinished = new Date(jsonObject.date_finished);
+ }
+ var expirationDate = null;
+ if (jsonObject.expiration_date) {
+ expirationDate = new Date(jsonObject.expiration_date);
+ }
+ onSuccess({
+ token: jsonObject.token,
+ dateStarted: dateStarted,
+ dateFinished: dateFinished,
+ testFilesCount: jsonObject.test_files_count,
+ testFilesCompleted: jsonObject.test_files_completed,
+ status: jsonObject.status,
+ expirationDate: expirationDate,
+ });
+ },
+ function () {
+ if (onError) onError();
+ }
+ );
+ },
+ readMultipleSessionStatuses: function (tokens, onSuccess, onError) {
+ var requestsLeft = tokens.length;
+ if (requestsLeft === 0) onSuccess([]);
+ var statuses = [];
+ for (var i = 0; i < tokens.length; i++) {
+ var token = tokens[i];
+ WaveService.readSessionStatus(
+ token,
+ function (status) {
+ requestsLeft--;
+ statuses.push(status);
+ if (requestsLeft === 0) onSuccess(statuses);
+ },
+ function () {
+ requestsLeft--;
+ if (requestsLeft === 0) onSuccess(statuses);
+ }
+ );
+ }
+ },
+ readPublicSessions: function (onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/sessions/public",
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess(jsonObject);
+ },
+ onError
+ );
+ },
+ updateSession: function (token, configuration, onSuccess, onError) {
+ var data = JSON.stringify({
+ tests: configuration.tests,
+ types: configuration.types,
+ timeouts: configuration.timeouts,
+ reference_tokens: configuration.referenceTokens,
+ expiration_date: configuration.expirationDate,
+ type: configuration.type,
+ });
+ sendRequest(
+ "PUT",
+ "api/sessions/" + token,
+ { "Content-Type": "application/json" },
+ data,
+ function () {
+ onSuccess();
+ },
+ onError
+ );
+ },
+ updateLabels: function (token, labels, onSuccess, onError) {
+ var data = JSON.stringify({ labels: labels });
+ sendRequest(
+ "PUT",
+ "api/sessions/" + token + "/labels",
+ { "Content-Type": "application/json" },
+ data,
+ function () {
+ if (onSuccess) onSuccess();
+ },
+ onError
+ );
+ },
+ findToken: function (fragment, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/sessions/" + fragment,
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess(jsonObject.token);
+ },
+ onError
+ );
+ },
+ startSession: function (token, onSuccess, onError) {
+ sendRequest(
+ "POST",
+ "api/sessions/" + token + "/start",
+ null,
+ null,
+ function () {
+ onSuccess();
+ },
+ onError
+ );
+ },
+ pauseSession: function (token, onSuccess, onError) {
+ sendRequest(
+ "POST",
+ "api/sessions/" + token + "/pause",
+ null,
+ null,
+ function () {
+ onSuccess();
+ },
+ onError
+ );
+ },
+ stopSession: function (token, onSuccess, onError) {
+ sendRequest(
+ "POST",
+ "api/sessions/" + token + "/stop",
+ null,
+ null,
+ function () {
+ onSuccess();
+ },
+ onError
+ );
+ },
+ resumeSession: function (token, resumeToken, onSuccess, onError) {
+ var data = JSON.stringify({ resume_token: resumeToken });
+ sendRequest(
+ "POST",
+ "api/sessions/" + token + "/resume",
+ { "Content-Type": "application/json" },
+ data,
+ function () {
+ if (onSuccess) onSuccess();
+ },
+ function (response) {
+ if (onError) onError(response);
+ }
+ );
+ },
+ deleteSession: function (token, onSuccess, onError) {
+ sendRequest(
+ "DELETE",
+ "api/sessions/" + token,
+ null,
+ null,
+ function () {
+ onSuccess();
+ },
+ onError
+ );
+ },
+
+ // TESTS API
+ readTestList: function (onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/tests",
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess(jsonObject);
+ },
+ onError
+ );
+ },
+ readNextTest: function (token, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/tests/" + token + "/next",
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess(jsonObject.next_test);
+ },
+ onError
+ );
+ },
+ readLastCompletedTests: function (token, resultTypes, onSuccess, onError) {
+ var status = "";
+ if (resultTypes) {
+ for (var i = 0; i < resultTypes.length; i++) {
+ var type = resultTypes[i];
+ status += type + ",";
+ }
+ }
+ sendRequest(
+ "GET",
+ "api/tests/" + token + "/last_completed?status=" + status,
+ null,
+ null,
+ function (response) {
+ var tests = JSON.parse(response);
+ var parsedTests = [];
+ for (var status in tests) {
+ for (var i = 0; i < tests[status].length; i++) {
+ var path = tests[status][i];
+ parsedTests.push({ path: path, status: status });
+ }
+ }
+ onSuccess(parsedTests);
+ },
+ onError
+ );
+ },
+ readMalfunctioningTests: function (token, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/tests/" + token + "/malfunctioning",
+ null,
+ null,
+ function (response) {
+ var tests = JSON.parse(response);
+ onSuccess(tests);
+ },
+ function (response) {
+ var errorMessage = JSON.parse(response).error;
+ onError(errorMessage);
+ }
+ );
+ },
+ updateMalfunctioningTests: function (
+ token,
+ malfunctioningTests,
+ onSuccess,
+ onError
+ ) {
+ var data = JSON.stringify(malfunctioningTests);
+ sendRequest(
+ "PUT",
+ "api/tests/" + token + "/malfunctioning",
+ { "Content-Type": "application/json" },
+ data,
+ function () {
+ onSuccess();
+ },
+ function (response) {
+ var errorMessage = JSON.parse(response).error;
+ onError(errorMessage);
+ }
+ );
+ },
+ readAvailableApis: function (onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/tests/apis",
+ null,
+ null,
+ function (response) {
+ var apis = JSON.parse(response);
+ onSuccess(apis);
+ },
+ function (response) {
+ if (!onError) return;
+ var errorMessage = JSON.parse(response).error;
+ onError(errorMessage);
+ }
+ );
+ },
+
+ // RESULTS API
+ createResult: function (token, result, onSuccess, onError) {
+ sendRequest(
+ "POST",
+ "api/results/" + token,
+ { "Content-Type": "application/json" },
+ JSON.stringify(result),
+ function () {
+ onSuccess();
+ },
+ onError
+ );
+ },
+ readResults: function (token, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/results/" + token,
+ null,
+ null,
+ function (response) {
+ onSuccess(JSON.parse(response));
+ },
+ onError
+ );
+ },
+ readResultsCompact: function (token, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/results/" + token + "/compact",
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess(jsonObject);
+ },
+ onError
+ );
+ },
+ readResultComparison: function (tokens, onSuccess, onError) {
+ var comparison = {};
+ var fetchComplete = function (results) {
+ comparison.total = {};
+ for (var i = 0; i < results.length; i++) {
+ var result = results[i];
+ var token = result.token;
+ comparison[token] = {};
+ for (var api in result) {
+ if (api === "token") continue;
+ comparison[token][api] = result[api].pass;
+ if (!comparison.total[api]) {
+ var total = 0;
+ for (var status in result[api]) {
+ total = total + result[api][status];
+ }
+ comparison.total[api] = total;
+ }
+ }
+ }
+ onSuccess(comparison);
+ };
+ var requestsLeft = tokens.length;
+ if (requestsLeft === 0) onSuccess([]);
+ var results = [];
+ for (var i = 0; i < tokens.length; i++) {
+ var token = tokens[i];
+ (function (token) {
+ WaveService.readResultsCompact(
+ token,
+ function (result) {
+ requestsLeft--;
+ result.token = token;
+ results.push(result);
+ if (requestsLeft === 0) fetchComplete(results);
+ },
+ function (responseStatus) {
+ if (responseStatus === 404) requestsLeft--;
+ if (status !== 404 && onError) onError();
+ if (requestsLeft === 0) fetchComplete(results);
+ }
+ );
+ })(token);
+ }
+ },
+ downloadResults: function (token) {
+ location.href = "api/results/" + token + "/export";
+ },
+ downloadApiResult: function (token, api) {
+ location.href = "api/results/" + token + "/" + api + "/json";
+ },
+ downloadAllApiResults: function (token, api) {
+ location.href = "api/results/" + token + "/json";
+ },
+ downloadReport: function (token, api) {
+ location.href = "api/results/" + token + "/" + api + "/report";
+ },
+ importResults: function (data, onSuccess, onError) {
+ sendRequest(
+ "POST",
+ "api/results/import",
+ { "Content-Type": "application/octet-stream" },
+ data,
+ function (response) {
+ var token = JSON.parse(response).token;
+ onSuccess(token);
+ },
+ function (status, response) {
+ var errorMessage;
+ if (status === 500) {
+ errorMessage = "Internal server error.";
+ } else {
+ errorMessage = JSON.parse(response).error;
+ }
+ onError(errorMessage);
+ }
+ );
+ },
+ readReportUri: function (token, api, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/results/" + token + "/" + api + "/reporturl",
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess(jsonObject.uri);
+ },
+ onError
+ );
+ },
+ downloadMultiReport: function (tokens, api) {
+ location.href = "api/results/" + api + "/report?tokens=" + tokens.join(",");
+ },
+ readMultiReportUri: function (tokens, api, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/results/" + api + "/reporturl?tokens=" + tokens.join(","),
+ null,
+ null,
+ function (response) {
+ var jsonObject = JSON.parse(response);
+ onSuccess(jsonObject.uri);
+ },
+ onError
+ );
+ },
+ downloadResultsOverview: function (token) {
+ location.href = "api/results/" + token + "/overview";
+ },
+
+ // DEVICES API
+ _device_token: null,
+ _deviceEventListeners: {},
+ _deviceEventNumbers: {},
+ registerDevice: function (onSuccess, onError) {
+ sendRequest(
+ "POST",
+ "api/devices",
+ null,
+ null,
+ function (response) {
+ var data = JSON.parse(response);
+ WaveService._device_token = data.token;
+ onSuccess(data.token);
+ },
+ onError
+ );
+ },
+ readDevice: function (token, onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/devices/" + token,
+ null,
+ null,
+ function (response) {
+ if (!onSuccess) return;
+ var data = JSON.parse(response);
+ onSuccess(data);
+ },
+ function (error) {
+ if (!onError) return;
+ onError(error);
+ }
+ );
+ },
+ DEVICE_ADDED_EVENT: "device_added",
+ DEVICE_REMOVED_EVENT: "device_removed",
+ START_SESSION: "start_session",
+ addDeviceEventListener: function (token, callback) {
+ var listeners = WaveService._deviceEventListeners;
+ if (!listeners[token]) listeners[token] = [];
+ listeners[token].push(callback);
+ WaveService._deviceEventListeners = listeners;
+ WaveService.listenDeviceEvents(token);
+ },
+ removeDeviceEventListener: function (callback) {
+ var listeners = WaveService._deviceEventListeners;
+ for (var token of Object.keys(listeners)) {
+ var index = listeners[token].indexOf(callback);
+ if (index === -1) continue;
+ listeners[token].splice(index, 1);
+ break;
+ }
+ WaveService._deviceEventListeners = listeners;
+ },
+ listenDeviceEvents: function (token) {
+ var listeners = WaveService._deviceEventListeners;
+ if (!listeners[token] || listeners.length === 0) return;
+ var url = "api/devices/" + token + "/events";
+ var lastEventNumber = WaveService._deviceEventNumbers[token];
+ if (lastEventNumber) {
+ url += "?last_active=" + lastEventNumber;
+ }
+ WaveService.listenHttpPolling(
+ url,
+ function (response) {
+ if (!response) {
+ WaveService.listenDeviceEvents(token);
+ return;
+ }
+ for (var listener of listeners[token]) {
+ listener(response);
+ }
+ WaveService._deviceEventNumbers[token] = lastEventNumber;
+ WaveService.listenDeviceEvents(token);
+ },
+ function () {
+ setTimeout(function () {
+ WaveService.listenDeviceEvents();
+ }, 1000);
+ }
+ );
+ },
+ sendDeviceEvent: function (device_token, event, onSuccess, onError) {
+ var data = JSON.stringify({
+ type: event.type,
+ data: event.data,
+ });
+ sendRequest(
+ "POST",
+ "api/devices/" + device_token + "/events",
+ { "Content-Type": "application/json" },
+ data,
+ onSuccess,
+ onError
+ );
+ },
+ addGlobalDeviceEventListener: function (callback) {
+ WaveService._globalDeviceEventListeners.push(callback);
+ WaveService.listenGlobalDeviceEvents();
+ },
+ removeGlobalDeviceEventListener: function (callback) {
+ var index = WaveService._globalDeviceEventListeners.indexOf(callback);
+ WaveService._globalDeviceEventListeners.splice(index, 1);
+ },
+ listenGlobalDeviceEvents: function () {
+ var listeners = WaveService._globalDeviceEventListeners;
+ if (listeners.length === 0) return;
+ var query = "";
+ if (WaveService._device_token) {
+ query = "?device_token=" + WaveService._device_token;
+ }
+ WaveService.listenHttpPolling(
+ "api/devices/events" + query,
+ function (response) {
+ if (!response) {
+ WaveService.listenGlobalDeviceEvents();
+ return;
+ }
+ for (var listener of listeners) {
+ listener(response);
+ }
+ WaveService.listenGlobalDeviceEvents();
+ },
+ function () {
+ setTimeout(function () {
+ WaveService.listenGlobalDeviceEvents();
+ }, 1000);
+ }
+ );
+ },
+ sendGlobalDeviceEvent: function (event, onSuccess, onError) {
+ var data = JSON.stringify({
+ type: event.type,
+ data: event.data,
+ });
+ sendRequest(
+ "POST",
+ "api/devices/events",
+ { "Content-Type": "application/json" },
+ data,
+ onSuccess,
+ onError
+ );
+ },
+
+ // GENERAL API
+ readStatus: function (onSuccess, onError) {
+ sendRequest(
+ "GET",
+ "api/status",
+ null,
+ null,
+ function (response) {
+ var data = JSON.parse(response);
+ var configuration = {
+ readSessionsEnabled: data.read_sessions_enabled,
+ importResultsEnabled: data.import_results_enabled,
+ reportsEnabled: data.reports_enabled,
+ versionString: data.version_string,
+ testTypeSelectionEnabled: data.test_type_selection_enabled,
+ testFileSelectionEnabled: data.test_file_selection_enabled
+ };
+ onSuccess(configuration);
+ },
+ onError
+ );
+ },
+
+ // UTILITY
+ addRecentSession: function (token) {
+ if (!token) return;
+ var state = WaveService.getState();
+ if (!state.recent_sessions) state.recent_sessions = [];
+ if (state.recent_sessions.indexOf(token) !== -1) return;
+ state.recent_sessions.unshift(token);
+ WaveService.setState(state);
+ },
+ addRecentSessions: function (tokens) {
+ for (var i = 0; i < tokens.length; i++) {
+ var token = tokens[i];
+ WaveService.addRecentSession(token);
+ }
+ },
+ getPinnedSessions: function () {
+ var state = WaveService.getState();
+ if (!state || !state.pinned_sessions) return [];
+ return state.pinned_sessions;
+ },
+ addPinnedSession: function (token) {
+ if (!token) return;
+ var state = WaveService.getState();
+ if (!state.pinned_sessions) state.pinned_sessions = [];
+ if (state.pinned_sessions.indexOf(token) !== -1) return;
+ state.pinned_sessions.unshift(token);
+ WaveService.setState(state);
+ },
+ getRecentSessions: function () {
+ var state = WaveService.getState();
+ if (!state || !state.recent_sessions) return [];
+ return state.recent_sessions;
+ },
+ setRecentSessions: function (sessionTokens) {
+ var state = WaveService.getState();
+ state.recent_sessions = sessionTokens;
+ WaveService.setState(state);
+ },
+ removePinnedSession: function (token) {
+ if (!token) return;
+ var state = WaveService.getState();
+ if (!state.pinned_sessions) return;
+ var index = state.pinned_sessions.indexOf(token);
+ if (index === -1) return;
+ state.pinned_sessions.splice(index, 1);
+ WaveService.setState(state);
+ },
+ removeRecentSession: function (token) {
+ var state = WaveService.getState();
+ if (!state.recent_sessions) return;
+ var index = state.recent_sessions.indexOf(token);
+ if (index === -1) return;
+ state.recent_sessions.splice(index, 1);
+ WaveService.setState(state);
+ },
+ getState: function () {
+ if (!window.localStorage) return null;
+ var storage = window.localStorage;
+ var state = JSON.parse(storage.getItem("wave"));
+ if (!state) return {};
+ return state;
+ },
+ setState: function (state) {
+ if (!window.localStorage) return null;
+ var storage = window.localStorage;
+ storage.setItem("wave", JSON.stringify(state));
+ },
+ _globalDeviceEventListeners: [],
+ _sessionEventListeners: {},
+ _sessionEventNumbers: {},
+ listenHttpPolling: function (url, onSuccess, onError) {
+ var uniqueId = new Date().getTime();
+ if (url.indexOf("?") === -1) {
+ url = url + "?id=" + uniqueId;
+ } else {
+ url = url + "&id=" + uniqueId;
+ }
+ sendRequest(
+ "GET",
+ url,
+ null,
+ null,
+ function (response) {
+ if (!response) {
+ onSuccess(null);
+ return;
+ }
+ onSuccess(JSON.parse(response));
+ },
+ onError
+ );
+ },
+ addSessionEventListener: function (token, callback) {
+ var listeners = WaveService._sessionEventListeners;
+ if (!listeners[token]) listeners[token] = [];
+ if (listeners[token].indexOf(callback) >= 0) return;
+ listeners[token].push(callback);
+ WaveService._sessionEventListeners = listeners;
+ WaveService.listenSessionEvents(token);
+ },
+ removeSessionEventListener: function (callback) {
+ var listeners = WaveService._sessionEventListeners;
+ for (var token of Object.keys(listeners)) {
+ var index = listeners[token].indexOf(callback);
+ if (index === -1) continue;
+ listeners[token].splice(index, 1);
+ break;
+ }
+ WaveService._sessionEventListeners = listeners;
+ },
+ listenSessionEvents: function (token) {
+ var listeners = WaveService._sessionEventListeners;
+ if (!listeners[token] || listeners.length === 0) return;
+ var url = "api/sessions/" + token + "/events";
+ var lastEventNumber = WaveService._sessionEventNumbers[token];
+ if (lastEventNumber) {
+ url += "?last_event=" + lastEventNumber;
+ }
+ WaveService.listenHttpPolling(
+ url,
+ function (response) {
+ if (!response) {
+ WaveService.listenSessionEvents(token);
+ return;
+ }
+ var lastEventNumber = 0;
+ for (var listener of listeners[token]) {
+ for (var event of response) {
+ if (event.number > lastEventNumber) {
+ lastEventNumber = event.number;
+ }
+ listener(event);
+ }
+ }
+ WaveService._sessionEventNumbers[token] = lastEventNumber;
+ WaveService.listenSessionEvents(token);
+ },
+ function () {
+ setTimeout(function () {
+ WaveService.listenSessionEvents();
+ }, 1000);
+ }
+ );
+ },
+ openSession: function (token) {
+ location.href = "/results.html?token=" + token;
+ },
+};
+
+if (!Object.keys)
+ Object.keys = function (o) {
+ if (o !== Object(o))
+ throw new TypeError("Object.keys called on a non-object");
+ var k = [],
+ p;
+ for (p in o) if (Object.prototype.hasOwnProperty.call(o, p)) k.push(p);
+ return k;
+ };