1! function(e, t) { 2 "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? module.exports = t() : e.qrcode = t() 3}(this, function() { 4 function e(e, t) { 5 this.count = e, this.dataCodewords = t, this.__defineGetter__("Count", function() { 6 return this.count 7 }), this.__defineGetter__("DataCodewords", function() { 8 return this.dataCodewords 9 }) 10 } 11 12 function t(e, t, r) { 13 this.ecCodewordsPerBlock = e, this.ecBlocks = r ? new Array(t, r) : new Array(t), this.__defineGetter__("ECCodewordsPerBlock", function() { 14 return this.ecCodewordsPerBlock 15 }), this.__defineGetter__("TotalECCodewords", function() { 16 return this.ecCodewordsPerBlock * this.NumBlocks 17 }), this.__defineGetter__("NumBlocks", function() { 18 for (var e = 0, t = 0; t < this.ecBlocks.length; t++) e += this.ecBlocks[t].length; 19 return e 20 }), this.getECBlocks = function() { 21 return this.ecBlocks 22 } 23 } 24 25 function r(e, t, r, n, i, o) { 26 this.versionNumber = e, this.alignmentPatternCenters = t, this.ecBlocks = new Array(r, n, i, o); 27 for (var a = 0, s = r.ECCodewordsPerBlock, h = r.getECBlocks(), w = 0; w < h.length; w++) { 28 var f = h[w]; 29 a += f.Count * (f.DataCodewords + s) 30 } 31 this.totalCodewords = a, this.__defineGetter__("VersionNumber", function() { 32 return this.versionNumber 33 }), this.__defineGetter__("AlignmentPatternCenters", function() { 34 return this.alignmentPatternCenters 35 }), this.__defineGetter__("TotalCodewords", function() { 36 return this.totalCodewords 37 }), this.__defineGetter__("DimensionForVersion", function() { 38 return 17 + 4 * this.versionNumber 39 }), this.buildFunctionPattern = function() { 40 var e = this.DimensionForVersion, 41 t = new d(e); 42 t.setRegion(0, 0, 9, 9), t.setRegion(e - 8, 0, 8, 9), t.setRegion(0, e - 8, 9, 8); 43 for (var r = this.alignmentPatternCenters.length, n = 0; r > n; n++) 44 for (var i = this.alignmentPatternCenters[n] - 2, o = 0; r > o; o++) 0 == n && (0 == o || o == r - 1) || n == r - 1 && 0 == o || t.setRegion(this.alignmentPatternCenters[o] - 2, i, 5, 5); 45 return t.setRegion(6, 9, 1, e - 17), t.setRegion(9, 6, e - 17, 1), this.versionNumber > 6 && (t.setRegion(e - 11, 0, 3, 6), t.setRegion(0, e - 11, 6, 3)), t 46 }, this.getECBlocksForLevel = function(e) { 47 return this.ecBlocks[e.ordinal()] 48 } 49 } 50 51 function n() { 52 return new Array(new r(1, new Array, new t(7, new e(1, 19)), new t(10, new e(1, 16)), new t(13, new e(1, 13)), new t(17, new e(1, 9))), new r(2, new Array(6, 18), new t(10, new e(1, 34)), new t(16, new e(1, 28)), new t(22, new e(1, 22)), new t(28, new e(1, 16))), new r(3, new Array(6, 22), new t(15, new e(1, 55)), new t(26, new e(1, 44)), new t(18, new e(2, 17)), new t(22, new e(2, 13))), new r(4, new Array(6, 26), new t(20, new e(1, 80)), new t(18, new e(2, 32)), new t(26, new e(2, 24)), new t(16, new e(4, 9))), new r(5, new Array(6, 30), new t(26, new e(1, 108)), new t(24, new e(2, 43)), new t(18, new e(2, 15), new e(2, 16)), new t(22, new e(2, 11), new e(2, 12))), new r(6, new Array(6, 34), new t(18, new e(2, 68)), new t(16, new e(4, 27)), new t(24, new e(4, 19)), new t(28, new e(4, 15))), new r(7, new Array(6, 22, 38), new t(20, new e(2, 78)), new t(18, new e(4, 31)), new t(18, new e(2, 14), new e(4, 15)), new t(26, new e(4, 13), new e(1, 14))), new r(8, new Array(6, 24, 42), new t(24, new e(2, 97)), new t(22, new e(2, 38), new e(2, 39)), new t(22, new e(4, 18), new e(2, 19)), new t(26, new e(4, 14), new e(2, 15))), new r(9, new Array(6, 26, 46), new t(30, new e(2, 116)), new t(22, new e(3, 36), new e(2, 37)), new t(20, new e(4, 16), new e(4, 17)), new t(24, new e(4, 12), new e(4, 13))), new r(10, new Array(6, 28, 50), new t(18, new e(2, 68), new e(2, 69)), new t(26, new e(4, 43), new e(1, 44)), new t(24, new e(6, 19), new e(2, 20)), new t(28, new e(6, 15), new e(2, 16))), new r(11, new Array(6, 30, 54), new t(20, new e(4, 81
52)), new t(30, new e(1, 50), new e(4, 51)), new t(28, new e(4, 22), new e(4, 23)), new t(24, new e(3, 12), new e(8, 13))), new r(12, new Array(6, 32, 58), new t(24, new e(2, 92), new e(2, 93)), new t(22, new e(6, 36), new e(2, 37)), new t(26, new e(4, 20), new e(6, 21)), new t(28, new e(7, 14), new e(4, 15))), new r(13, new Array(6, 34, 62), new t(26, new e(4, 107)), new t(22, new e(8, 37), new e(1, 38)), new t(24, new e(8, 20), new e(4, 21)), new t(22, new e(12, 11), new e(4, 12))), new r(14, new Array(6, 26, 46, 66), new t(30, new e(3, 115), new e(1, 116)), new t(24, new e(4, 40), new e(5, 41)), new t(20, new e(11, 16), new e(5, 17)), new t(24, new e(11, 12), new e(5, 13))), new r(15, new Array(6, 26, 48, 70), new t(22, new e(5, 87), new e(1, 88)), new t(24, new e(5, 41), new e(5, 42)), new t(30, new e(5, 24), new e(7, 25)), new t(24, new e(11, 12), new e(7, 13))), new r(16, new Array(6, 26, 50, 74), new t(24, new e(5, 98), new e(1, 99)), new t(28, new e(7, 45), new e(3, 46)), new t(24, new e(15, 19), new e(2, 20)), new t(30, new e(3, 15), new e(13, 16))), new r(17, new Array(6, 30, 54, 78), new t(28, new e(1, 107), new e(5, 108)), new t(28, new e(10, 46), new e(1, 47)), new t(28, new e(1, 22), new e(15, 23)), new t(28, new e(2, 14), new e(17, 15))), new r(18, new Array(6, 30, 56, 82), new t(30, new e(5, 120), new e(1, 121)), new t(26, new e(9, 43), new e(4, 44)), new t(28, new e(17, 22), new e(1, 23)), new t(28, new e(2, 14), new e(19, 15))), new r(19, new Array(6, 30, 58, 86), new t(28, new e(3, 113), new e(4, 114)), new t(26, new e(3, 44), new e(11, 45)), new t(26, new e(17, 21), new e(4, 22)), new t(26, new e(9, 13), new e(16, 14))), new r(20, new Array(6, 34, 62, 90), new t(28, new e(3, 107), new e(5, 108)), new t(26, new e(3, 41), new e(13, 42)), new t(30, new e(15, 24), new e(5, 25)), new t(28, new e(15, 15), new e(10, 16))), new r(21, new Array(6, 28, 50, 72, 94), new t(28, new e(4, 116), new e(4, 117)), new t(26, new e(17, 42)), new t(28, new e(17, 22), new e(6, 23)), new t(30, new e(19, 16), new e(6, 17))), new r(22, new Array(6, 26, 50, 74, 98), new t(28, new e(2, 111), new e(7, 112)), new t(28, new e(17, 46)), new t(30, new e(7, 24), new e(16, 25)), new t(24, new e(34, 13))), new r(23, new Array(6, 30, 54, 74, 102), new t(30, new e(4, 121), new e(5, 122)), new t(28, new e(4, 47), new e(14, 48)), new t(30, new e(11, 24), new e(14, 25)), new t(30, new e(16, 15), new e(14, 16))), new r(24, new Array(6, 28, 54, 80, 106), new t(30, new e(6, 117), new e(4, 118)), new t(28, new e(6, 45), new e(14, 46)), new t(30, new e(11, 24), new e(16, 25)), new t(30, new e(30, 16), new e(2, 17))), new r(25, new Array(6, 32, 58, 84, 110), new t(26, new e(8, 106), new e(4, 107)), new t(28, new e(8, 47), new e(13, 48)), new t(30, new e(7, 24), new e(22, 25)), new t(30, new e(22, 15), new e(13, 16))), new r(26, new Array(6, 30, 58, 86, 114), new t(28, new e(10, 114), new e(2, 115)), new t(28, new e(19, 46), new e(4, 47)), new t(28, new e(28, 22), new e(6, 23)), new t(30, new e(33, 16), new e(4, 17))), new r(27, new Array(6, 34, 62, 90, 118), new t(30, new e(8, 122), new e(4, 123)), new t(28, new e(22, 45), new e(3, 46)), new t(30, new e(8, 23), new e(26, 24)), new t(30, new e(12, 15), new e(28, 16))), new r(28, new Array(6, 26, 50, 74, 98, 122), new t(30, new e(3, 117), new e(10, 118)), new t(28, new e(3, 45), new e(23, 46)), new t(30, new e(4, 24), new e(31, 25)), new t(30, new e(11, 15), new e(31, 16))), new r(29, new Array(6, 30, 54, 78, 102, 126), new t(30, new e(7, 116), new e(7, 117)), new t(28, new e(21, 45), new e(7, 46)), new t(30, new e(1, 23), new e(37, 24)), new t(30, new e(19, 15), new e(26, 16))), new r(30, new Array(6, 26, 52, 78, 104, 130), new t(30, new e(5, 115), new e(10, 116)), new t(28, new e(19, 47), new e(10, 48)), new t(30, new e(15, 24), new e(25, 25)), new t(30, new e(23, 15), new e(25, 16))), new r(31, new Array(6, 30, 56, 82, 108, 134), new t(30, new e(13, 115), new e(3, 116)), new t(28, new e(2, 46), new e(29, 47)), new t(30, new e(42, 24), new e(1, 25)), new t(30, new e(23, 15), new e(28, 16))), new r(32, new Array(6, 34, 60, 86, 112, 138), new t(30, new e(17, 115)), new t(28, new e(10, 46), new e(23, 47)), new t(30, new e(10, 24), new e(35, 25)), new t(30, new e(19, 15), new e(35, 16))), new r(33, new Array(6, 30, 58, 86, 114, 142), new t(30, new e(17, 115), new e(1, 116)), new t(28, new e(14, 46), new e(21, 47)), new t(30, new e(29, 24), new e(19, 25)), new t(30, new e(11, 15), new e(46, 16))), new r(34, new Array(6, 34, 62, 90, 118, 146), new t(30, new e(13, 115
52), new e(6, 116)), new t(28, new e(14, 46), new e(23, 47)), new t(30, new e(44, 24), new e(7, 25)), new t(30, new e(59, 16), new e(1, 17))), new r(35, new Array(6, 30, 54, 78, 102, 126, 150), new t(30, new e(12, 121), new e(7, 122)), new t(28, new e(12, 47), new e(26, 48)), new t(30, new e(39, 24), new e(14, 25)), new t(30, new e(22, 15), new e(41, 16))), new r(36, new Array(6, 24, 50, 76, 102, 128, 154), new t(30, new e(6, 121), new e(14, 122)), new t(28, new e(6, 47), new e(34, 48)), new t(30, new e(46, 24), new e(10, 25)), new t(30, new e(2, 15), new e(64, 16))), new r(37, new Array(6, 28, 54, 80, 106, 132, 158), new t(30, new e(17, 122), new e(4, 123)), new t(28, new e(29, 46), new e(14, 47)), new t(30, new e(49, 24), new e(10, 25)), new t(30, new e(24, 15), new e(46, 16))), new r(38, new Array(6, 32, 58, 84, 110, 136, 162), new t(30, new e(4, 122), new e(18, 123)), new t(28, new e(13, 46), new e(32, 47)), new t(30, new e(48, 24), new e(14, 25)), new t(30, new e(42, 15), new e(32, 16))), new r(39, new Array(6, 26, 54, 82, 110, 138, 166), new t(30, new e(20, 117), new e(4, 118)), new t(28, new e(40, 47), new e(7, 48)), new t(30, new e(43, 24), new e(22, 25)), new t(30, new e(10, 15), new e(67, 16))), new r(40, new Array(6, 30, 58, 86, 114, 142, 170), new t(30, new e(19, 118), new e(6, 119)), new t(28, new e(18, 47), new e(31, 48)), new t(30, new e(34, 24), new e(34, 25)), new t(30, new e(20, 15), new e(61, 16)))) 53 } 54 55 function i(e, t, r, n, o, a, s, h, d) { 56 this.a11 = e, this.a12 = n, this.a13 = s, this.a21 = t, this.a22 = o, this.a23 = h, this.a31 = r, this.a32 = a, this.a33 = d, this.transformPoints1 = function(e) { 57 for (var t = e.length, r = this.a11, n = this.a12, i = this.a13, o = this.a21, a = this.a22, s = this.a23, h = this.a31, d = this.a32, w = this.a33, f = 0; t > f; f += 2) { 58 var c = e[f], 59 u = e[f + 1], 60 l = i * c + s * u + w; 61 e[f] = (r * c + o * u + h) / l, e[f + 1] = (n * c + a * u + d) / l 62 } 63 }, this.transformPoints2 = function(e, t) { 64 for (var r = e.length, n = 0; r > n; n++) { 65 var i = e[n], 66 o = t[n], 67 a = this.a13 * i + this.a23 * o + this.a33; 68 e[n] = (this.a11 * i + this.a21 * o + this.a31) / a, t[n] = (this.a12 * i + this.a22 * o + this.a32) / a 69 } 70 }, this.buildAdjoint = function() { 71 return new i(this.a22 * this.a33 - this.a23 * this.a32, this.a23 * this.a31 - this.a21 * this.a33, this.a21 * this.a32 - this.a22 * this.a31, this.a13 * this.a32 - this.a12 * this.a33, this.a11 * this.a33 - this.a13 * this.a31, this.a12 * this.a31 - this.a11 * this.a32, this.a12 * this.a23 - this.a13 * this.a22, this.a13 * this.a21 - this.a11 * this.a23, this.a11 * this.a22 - this.a12 * this.a21) 72 }, this.times = function(e) { 73 return new i(this.a11 * e.a11 + this.a21 * e.a12 + this.a31 * e.a13, this.a11 * e.a21 + this.a21 * e.a22 + this.a31 * e.a23, this.a11 * e.a31 + this.a21 * e.a32 + this.a31 * e.a33, this.a12 * e.a11 + this.a22 * e.a12 + this.a32 * e.a13, this.a12 * e.a21 + this.a22 * e.a22 + this.a32 * e.a23, this.a12 * e.a31 + this.a22 * e.a32 + this.a32 * e.a33, this.a13 * e.a11 + this.a23 * e.a12 + this.a33 * e.a13, this.a13 * e.a21 + this.a23 * e.a22 + this.a33 * e.a23, this.a13 * e.a31 + this.a23 * e.a32 + this.a33 * e.a33) 74 } 75 } 76 77 function o(e, t) { 78 this.bits = e, this.points = t 79 } 80 81 function a(e) { 82 this.image = e, this.resultPointCallback = null, this.sizeOfBlackWhiteBlackRun = function(e, t, r, n) { 83 var i = Math.abs(n - t) > Math.abs(r - e); 84 if (i) { 85 var o = e; 86 e = t, t = o, o = r, r = n, n = o 87 } 88 for (var a = Math.abs(r - e), s = Math.abs(n - t), h = -a >> 1, d = n > t ? 1 : -1, w = r > e ? 1 : -1, f = 0, c = e, u = t; c != r; c += w) { 89 var l = i ? u : c, 90 v = i ? c : u; 91 if (1 == f ? this.image[l + v * qrcode.width] && f++ : this.image[l + v * qrcode.width] || f++, 3 == f) { 92 var g = c - e, 93 m = u - t; 94 return Math.sqrt(g * g + m * m) 95 } 96 if (h += s, h > 0) { 97 if (u == n) break; 98 u += d, h -= a 99 } 100 } 101 var y = r - e, 102 p = n - t; 103 return Math.sqrt(y * y + p * p) 104 }, this.sizeOfBlackWhiteBlackRunBothWays = function(e, t, r, n) { 105 var i = this.sizeOfBlackWhiteBlackRun(e, t, r, n), 106 o = 1, 107 a = e - (r - e); 108 0 > a ? (o = e / (e - a), a = 0) : a >= qrcode.width && (o = (qrcode.width - 1 - e) / (a - e), a = qrcode.width - 1); 109 var s = Math.floor(t - (n - t) * o); 110 return o = 1, 0 > s ? (o = t / (t - s), s = 0) : s >= qrcode.height && (o = (qrcode.height - 1 - t) / (s - t), s = qrcode.height - 1), a = Math.floor(e + (a - e) * o), i += this.sizeOfBlackWhiteBlackRun(e, t, a, s), i - 1 111 }, this.calculateModuleSizeOneWay = function(e, t) { 112 var r = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.X), Math.floor(e.Y), Math.floor(t.X), Math.floor(t.Y)), 113 n = this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.X), Math.floor(t.Y), Math.floor(e.X), Math.floor(e.Y)); 114 return isNaN(r) ? n / 7 : isNaN(n) ? r / 7 : (r + n) / 14 115 }, this.calculateModuleSize = function(e, t, r) { 116 return (this.calculateModuleSizeOneWay(e, t) + this.calculateModuleSizeOneWay(e, r)) / 2 117 }, this.distance = function(e, t) { 118 return xDiff = e.X - t.X, yDiff = e.Y - t.Y, Math.sqrt(xDiff * xDiff + yDiff * yDiff) 119 }, this.computeDimension = function(e, t, r, n) { 120 var i = Math.round(this.distance(e, t) / n), 121 o = Math.round(this.distance(e, r) / n), 122 a = (i + o >> 1) + 7; 123 switch (3 & a) { 124 case 0: 125 a++; 126 break; 127 case 2: 128 a--; 129 break; 130 case 3: 131 throw "Error" 132 } 133 return a 134 }, this.findAlignmentInRegion = function(e, t, r, n) { 135 var i = Math.floor(n * e), 136 o = Math.max(0, t - i), 137 a = Math.min(qrcode.width - 1, t + i); 138 if (3 * e > a - o) throw "Error"; 139 var s = Math.max(0, r - i), 140 h = Math.min(qrcode.height - 1, r + i), 141 d = new P(this.image, o, s, a - o, h - s, e, this.resultPointCallback); 142 return d.find() 143 }, this.createTransform = function(e, t, r, n, o) { 144 var a, s, h, d, w = o - 3.5; 145 null != n ? (a = n.X, s = n.Y, h = d = w - 3) : (a = t.X - e.X + r.X, s = t.Y - e.Y + r.Y, h = d = w); 146 var f = i.quadrilateralToQuadrilateral(3.5, 3.5, w, 3.5, h, d, 3.5, w, e.X, e.Y, t.X, t.Y, a, s, r.X, r.Y); 147 return f 148 }, this.sampleGrid = function(e, t, r) { 149 var n = GridSampler; 150 return n.sampleGrid3(e, r, t) 151 }, this.processFinderPatternInfo = function(e) { 152 var t = e.TopLeft, 153 n = e.TopRight, 154 i = e.BottomLeft, 155 a = this.calculateModuleSize(t, n, i); 156 if (1 > a) throw "Error"; 157 var s = this.computeDimension(t, n, i, a), 158 h = r.getProvisionalVersionForDimension(s), 159 d = h.DimensionForVersion - 7, 160 w = null; 161 if (h.AlignmentPatternCenters.length > 0) 162 for (var f = n.X - t.X + i.X, c = n.Y - t.Y + i.Y, u = 1 - 3 / d, l = Math.floor(t.X + u * (f - t.X)), v = Math.floor(t.Y + u * (c - t.Y)), g = 4; 16 >= g; g <<= 1) { 163 w = this.findAlignmentInRegion(a, l, v, g); 164 break 165 } 166 var m, y = this.createTransform(t, n, i, w, s), 167 p = this.sampleGrid(this.image, y, s); 168 return m = null == w ? new Array(i, t, n) : new Array(i, t, n, w), new o(p, m) 169 }, this.detect = function() { 170 var e = (new S).findFinderPattern(this.image); 171 return this.processFinderPatternInfo(e) 172 } 173 } 174 175 function s(e) { 176 this.errorCorrectionLevel = h.forBits(e >> 3 & 3), this.dataMask = 7 & e, this.__defineGetter__("ErrorCorrectionLevel", function() { 177 return this.errorCorrectionLevel 178 }), this.__defineGetter__("DataMask", function() { 179 return this.dataMask 180 }), this.GetHashCode = function() { 181 return this.errorCorrectionLevel.ordinal() << 3 | dataMask 182 }, this.Equals = function(e) { 183 var t = e; 184 return this.errorCorrectionLevel == t.errorCorrectionLevel && this.dataMask == t.dataMask 185 } 186 } 187 188 function h(e, t, r) { 189 this.ordinal_Renamed_Field = e, this.bits = t, this.name = r, this.__defineGetter__("Bits", function() { 190 return this.bits 191 }), this.__defineGetter__("Name", function() { 192 return this.name 193 }), this.ordinal = function() { 194 return this.ordinal_Renamed_Field 195 } 196 } 197 198 function d(e, t) { 199 if (t || (t = e), 1 > e || 1 > t) throw "Both dimensions must be greater than 0"; 200 this.width = e, this.height = t; 201 var r = e >> 5; 202 0 != (31 & e) && r++, this.rowSize = r, this.bits = new Array(r * t); 203 for (var n = 0; n < this.bits.length; n++) this.bits[n] = 0; 204 this.__defineGetter__("Width", function() { 205 return this.width 206 }), this.__defineGetter__("Height", function() { 207 return this.height 208 }), this.__defineGetter__("Dimension", function() { 209 if (this.width != this.height) throw "Can't call getDimension() on a non-square matrix"; 210 return this.width 211 }), this.get_Renamed = function(e, t) { 212 var r = t * this.rowSize + (e >> 5); 213 return 0 != (1 & A(this.bits[r], 31 & e)) 214 }, this.set_Renamed = function(e, t) { 215 var r = t * this.rowSize + (e >> 5); 216 this.bits[r] |= 1 << (31 & e) 217 }, this.flip = function(e, t) { 218 var r = t * this.rowSize + (e >> 5); 219 this.bits[r] ^= 1 << (31 & e) 220 }, this.clear = function() { 221 for (var e = this.bits.length, t = 0; e > t; t++) this.bits[t] = 0 222 }, this.setRegion = function(e, t, r, n) { 223 if (0 > t || 0 > e) throw "Left and top must be nonnegative"; 224 if (1 > n || 1 > r) throw "Height and width must be at least 1"; 225 var i = e + r, 226 o = t + n; 227 if (o > this.height || i > this.width) throw "The region must fit inside the matrix"; 228 for (var a = t; o > a; a++) 229 for (var s = a * this.rowSize, h = e; i > h; h++) this.bits[s + (h >> 5)] |= 1 << (31 & h) 230 } 231 } 232 233 function w(e, t) { 234 this.numDataCodewords = e, this.codewords = t, this.__defineGetter__("NumDataCodewords", function() { 235 return this.numDataCodewords 236 }), this.__defineGetter__("Codewords", function() {
237 return this.codewords 238 }) 239 } 240 241 function f(e) { 242 var t = e.Dimension; 243 if (21 > t || 1 != (3 & t)) throw "Error BitMatrixParser"; 244 this.bitMatrix = e, this.parsedVersion = null, this.parsedFormatInfo = null, this.copyBit = function(e, t, r) { 245 return this.bitMatrix.get_Renamed(e, t) ? r << 1 | 1 : r << 1 246 }, this.readFormatInformation = function() { 247 if (null != this.parsedFormatInfo) return this.parsedFormatInfo; 248 for (var e = 0, t = 0; 6 > t; t++) e = this.copyBit(t, 8, e); 249 e = this.copyBit(7, 8, e), e = this.copyBit(8, 8, e), e = this.copyBit(8, 7, e); 250 for (var r = 5; r >= 0; r--) e = this.copyBit(8, r, e); 251 if (this.parsedFormatInfo = s.decodeFormatInformation(e), null != this.parsedFormatInfo) return this.parsedFormatInfo; 252 var n = this.bitMatrix.Dimension; 253 e = 0; 254 for (var i = n - 8, t = n - 1; t >= i; t--) e = this.copyBit(t, 8, e); 255 for (var r = n - 7; n > r; r++) e = this.copyBit(8, r, e); 256 if (this.parsedFormatInfo = s.decodeFormatInformation(e), null != this.parsedFormatInfo) return this.parsedFormatInfo; 257 throw "Error readFormatInformation" 258 }, this.readVersion = function() { 259 if (null != this.parsedVersion) return this.parsedVersion; 260 var e = this.bitMatrix.Dimension, 261 t = e - 17 >> 2; 262 if (6 >= t) return r.getVersionForNumber(t); 263 for (var n = 0, i = e - 11, o = 5; o >= 0; o--) 264 for (var a = e - 9; a >= i; a--) n = this.copyBit(a, o, n); 265 if (this.parsedVersion = r.decodeVersionInformation(n), null != this.parsedVersion && this.parsedVersion.DimensionForVersion == e) return this.parsedVersion; 266 n = 0; 267 for (var a = 5; a >= 0; a--) 268 for (var o = e - 9; o >= i; o--) n = this.copyBit(a, o, n); 269 if (this.parsedVersion = r.decodeVersionInformation(n), null != this.parsedVersion && this.parsedVersion.DimensionForVersion == e) return this.parsedVersion; 270 throw "Error readVersion" 271 }, this.readCodewords = function() { 272 var e = this.readFormatInformation(), 273 t = this.readVersion(), 274 r = DataMask.forReference(e.DataMask), 275 n = this.bitMatrix.Dimension; 276 r.unmaskBitMatrix(this.bitMatrix, n); 277 for (var i = t.buildFunctionPattern(), o = !0, a = new Array(t.TotalCodewords), s = 0, h = 0, d = 0, w = n - 1; w > 0; w -= 2) { 278 6 == w && w--; 279 for (var f = 0; n > f; f++) 280 for (var c = o ? n - 1 - f : f, u = 0; 2 > u; u++) i.get_Renamed(w - u, c) || (d++, h <<= 1, this.bitMatrix.get_Renamed(w - u, c) && (h |= 1), 8 == d && (a[s++] = h, d = 0, h = 0)); 281 o ^= !0 282 } 283 if (s != t.TotalCodewords) throw "Error readCodewords"; 284 return a 285 } 286 } 287 288 function c() { 289 this.unmaskBitMatrix = function(e, t) { 290 for (var r = 0; t > r; r++) 291 for (var n = 0; t > n; n++) this.isMasked(r, n) && e.flip(n, r) 292 }, this.isMasked = function(e, t) { 293 return 0 == (e + t & 1) 294 } 295 } 296 297 function u() { 298 this.unmaskBitMatrix = function(e, t) { 299 for (var r = 0; t > r; r++) 300 for (var n = 0; t > n; n++) this.isMasked(r, n) && e.flip(n, r) 301 }, this.isMasked = function(e) { 302 return 0 == (1 & e) 303 } 304 } 305 306 function l() { 307 this.unmaskBitMatrix = function(e, t) { 308 for (var r = 0; t > r; r++) 309 for (var n = 0; t > n; n++) this.isMasked(r, n) && e.flip(n, r) 310 }, this.isMasked = function(e, t) { 311 return t % 3 == 0 312 } 313 } 314 315 function v() { 316 this.unmaskBitMatrix = function(e, t) { 317 for (var r = 0; t > r; r++) 318 for (var n = 0; t > n; n++) this.isMasked(r, n) && e.flip(n, r) 319 }, this.isMasked = function(e, t) { 320 return (e + t) % 3 == 0 321 } 322 } 323 324 function g() { 325 this.unmaskBitMatrix = function(e, t) { 326 for (var r = 0; t > r; r++) 327 for (var n = 0; t > n; n++) this.isMasked(r, n) && e.flip(n, r) 328 }, this.isMasked = function(e, t) { 329 return 0 == (A(e, 1) + t / 3 & 1) 330 } 331 } 332 333 function m() { 334 this.unmaskBitMatrix = function(e, t) { 335 for (var r = 0; t > r; r++) 336 for (var n = 0; t > n; n++) this.isMasked(r, n) && e.flip(n, r) 337 }, this.isMasked = function(e, t) { 338 var r = e * t; 339 return (1 & r) + r % 3 == 0 340 } 341 } 342 343 function y() { 344 this.unmaskBitMatrix = function(e, t) { 345 for (var r = 0; t > r; r++) 346 for (var n = 0; t > n; n++) this.isMasked(r, n) && e.flip(n, r) 347 }, this.isMasked = function(e, t) { 348 var r = e * t; 349 return 0 == ((1 & r) + r % 3 & 1) 350 } 351 } 352 353 function b() { 354 this.unmaskBitMatrix = function(e, t) { 355 for (var r = 0; t > r; r++) 356 for (var n = 0; t > n; n++) this.isMasked(r, n) && e.flip(n, r) 357 }, this.isMasked = function(e, t) { 358 return 0 == ((e + t & 1) + e * t % 3 & 1) 359 } 360 } 361 362 function C(e) { 363 this.field = e, this.decode = function(e, t) { 364 for (var r = new M(this.field, e), n = new Array(t), i = 0; i < n.length; i++) n[i] = 0; 365 for (var o = !1, a = !0, i = 0; t > i; i++) { 366 var s = r.evaluateAt(this.field.exp(o ? i + 1 : i)); 367 n[n.length - 1 - i] = s, 0 != s && (a = !1) 368 } 369 if (!a) 370 for (var h = new M(this.field, n), d = this.runEuclideanAlgorithm(this.field.buildMonomial(t, 1), h, t), w = d[0], f = d[1], c = this.findErrorLocations(w), u = this.findErrorMagnitudes(f, c, o), i = 0; i < c.length; i++) { 371 var l = e.length - 1 - this.field.log(c[i]); 372 if (0 > l) throw "ReedSolomonException Bad error location"; 373 e[l] = _.addOrSubtract(e[l], u[i]) 374 } 375 }, this.runEuclideanAlgorithm = function(e, t, r) { 376 if (e.Degree < t.Degree) { 377 var n = e; 378 e = t, t = n 379 } 380 for (var i = e, o = t, a = this.field.One, s = this.field.Zero, h = this.field.Zero, d = this.field.One; o.Degree >= Math.floor(r / 2);) { 381 var w = i, 382 f = a, 383 c = h; 384 if (i = o, a = s, h = d, i.Zero) throw "r_{i-1} was zero"; 385 o = w; 386 for (var u = this.field.Zero, l = i.getCoefficient(i.Degree), v = this.field.inverse(l); o.Degree >= i.Degree && !o.Zero;) { 387 var g = o.Degree - i.Degree, 388 m = this.field.multiply(o.getCoefficient(o.Degree), v); 389 u = u.addOrSubtract(this.field.buildMonomial(g, m)), o = o.addOrSubtract(i.multiplyByMonomial(g, m)) 390 } 391 s = u.multiply1(a).addOrSubtract(f), d = u.multiply1(h).addOrSubtract(c) 392 } 393 var y = d.getCoefficient(0); 394 if (0 == y) throw "ReedSolomonException sigmaTilde(0) was zero"; 395 var p = this.field.inverse(y), 396 b = d.multiply2(p), 397 C = o.multiply2(p); 398 return new Array(b, C) 399 }, this.findErrorLocations = function(e) { 400 var t = e.Degree; 401 if (1 == t) return new Array(e.getCoefficient(1)); 402 for (var r = new Array(t), n = 0, i = 1; 256 > i && t > n; i++) 0 == e.evaluateAt(i) && (r[n] = this.field.inverse(i), n++); 403 if (n != t) throw "Error locator degree does not match number of roots"; 404 return r 405 }, this.findErrorMagnitudes = function(e, t, r) { 406 for (var n = t.length, i = new Array(n), o = 0; n > o; o++) { 407 for (var a = this.field.inverse(t[o]), s = 1, h = 0; n > h; h++) o != h && (s = this.field.multiply(s, _.addOrSubtract(1, this.field.multiply(t[h], a)))); 408 i[o] = this.field.multiply(e.evaluateAt(a), this.field.inverse(s)), r && (i[o] = this.field.multiply(i[o], a)) 409 } 410 return i 411 } 412 } 413 414 function M(e, t) { 415 if (null == t || 0 == t.length) throw "System.ArgumentException"; 416 this.field = e; 417 var r = t.length; 418 if (r > 1 && 0 == t[0]) { 419 for (var n = 1; r > n && 0 == t[n];) n++; 420 if (n == r) this.coefficients = e.Zero.coefficients; 421 else { 422 this.coefficients = new Array(r - n); 423 for (var i = 0; i < this.coefficients.length; i++) this.coefficients[i] = 0; 424 for (var o = 0; o < this.coefficients.length; o++) this.coefficients[o] = t[n + o] 425 } 426 } else this.coefficients = t; 427 this.__defineGetter__("Zero", function() { 428 return 0 == this.coefficients[0] 429 }), this.__defineGetter__("Degree", function() { 430 return this.coefficients.length - 1 431 }), this.__defineGetter__("Coefficients", function() { 432 return this.coefficients 433 }), this.getCoefficient = function(e) { 434 return this.coefficients[this.coefficients.length - 1 - e] 435 }, this.evaluateAt = function(e) { 436 if (0 == e) return this.getCoefficient(0); 437 var t = this.coefficients.length; 438 if (1 == e) { 439 for (var r = 0, n = 0; t > n; n++) r = _.addOrSubtract(r, this.coefficients[n]); 440 return r 441 } 442 for (var i = this.coefficients[0], n = 1; t > n; n++) i = _.addOrSubtract(this.field.multiply(e, i), this.coefficients[n]); 443 return i 444 }, this.addOrSubtract = function(t) {
445 if (this.field != t.field) throw "GF256Polys do not have same GF256 field"; 446 if (this.Zero) return t; 447 if (t.Zero) return this; 448 var r = this.coefficients, 449 n = t.coefficients; 450 if (r.length > n.length) { 451 var i = r; 452 r = n, n = i 453 } 454 for (var o = new Array(n.length), a = n.length - r.length, s = 0; a > s; s++) o[s] = n[s]; 455 for (var h = a; h < n.length; h++) o[h] = _.addOrSubtract(r[h - a], n[h]); 456 return new M(e, o) 457 }, this.multiply1 = function(e) { 458 if (this.field != e.field) throw "GF256Polys do not have same GF256 field"; 459 if (this.Zero || e.Zero) return this.field.Zero; 460 for (var t = this.coefficients, r = t.length, n = e.coefficients, i = n.length, o = new Array(r + i - 1), a = 0; r > a; a++) 461 for (var s = t[a], h = 0; i > h; h++) o[a + h] = _.addOrSubtract(o[a + h], this.field.multiply(s, n[h])); 462 return new M(this.field, o) 463 }, this.multiply2 = function(e) { 464 if (0 == e) return this.field.Zero; 465 if (1 == e) return this; 466 for (var t = this.coefficients.length, r = new Array(t), n = 0; t > n; n++) r[n] = this.field.multiply(this.coefficients[n], e); 467 return new M(this.field, r) 468 }, this.multiplyByMonomial = function(e, t) { 469 if (0 > e) throw "System.ArgumentException"; 470 if (0 == t) return this.field.Zero; 471 for (var r = this.coefficients.length, n = new Array(r + e), i = 0; i < n.length; i++) n[i] = 0; 472 for (var i = 0; r > i; i++) n[i] = this.field.multiply(this.coefficients[i], t); 473 return new M(this.field, n) 474 }, this.divide = function(e) { 475 if (this.field != e.field) throw "GF256Polys do not have same GF256 field"; 476 if (e.Zero) throw "Divide by 0"; 477 for (var t = this.field.Zero, r = this, n = e.getCoefficient(e.Degree), i = this.field.inverse(n); r.Degree >= e.Degree && !r.Zero;) { 478 var o = r.Degree - e.Degree, 479 a = this.field.multiply(r.getCoefficient(r.Degree), i), 480 s = e.multiplyByMonomial(o, a), 481 h = this.field.buildMonomial(o, a); 482 t = t.addOrSubtract(h), r = r.addOrSubtract(s) 483 } 484 return new Array(t, r) 485 } 486 } 487 488 function _(e) { 489 this.expTable = new Array(256), this.logTable = new Array(256); 490 for (var t = 1, r = 0; 256 > r; r++) this.expTable[r] = t, t <<= 1, t >= 256 && (t ^= e); 491 for (var r = 0; 255 > r; r++) this.logTable[this.expTable[r]] = r; 492 var n = new Array(1); 493 n[0] = 0, this.zero = new M(this, new Array(n)); 494 var i = new Array(1); 495 i[0] = 1, this.one = new M(this, new Array(i)), this.__defineGetter__("Zero", function() { 496 return this.zero 497 }), this.__defineGetter__("One", function() { 498 return this.one 499 }), this.buildMonomial = function(e, t) { 500 if (0 > e) throw "System.ArgumentException"; 501 if (0 == t) return zero; 502 for (var r = new Array(e + 1), n = 0; n < r.length; n++) r[n] = 0; 503 return r[0] = t, new M(this, r) 504 }, this.exp = function(e) { 505 return this.expTable[e] 506 }, this.log = function(e) { 507 if (0 == e) throw "System.ArgumentException"; 508 return this.logTable[e] 509 }, this.inverse = function(e) { 510 if (0 == e) throw "System.ArithmeticException"; 511 return this.expTable[255 - this.logTable[e]] 512 }, this.multiply = function(e, t) { 513 return 0 == e || 0 == t ? 0 : 1 == e ? t : 1 == t ? e : this.expTable[(this.logTable[e] + this.logTable[t]) % 255] 514 } 515 } 516 517 function A(e, t) { 518 return e >= 0 ? e >> t : (e >> t) + (2 << ~t) 519 } 520 521 function q(e, t, r) { 522 this.x = e, this.y = t, this.count = 1, this.estimatedModuleSize = r, this.__defineGetter__("EstimatedModuleSize", function() { 523 return this.estimatedModuleSize 524 }), this.__defineGetter__("Count", function() { 525 return this.count 526 }), this.__defineGetter__("X", function() { 527 return this.x 528 }), this.__defineGetter__("Y", function() { 529 return this.y 530 }), this.incrementCount = function() { 531 this.count++ 532 }, this.aboutEquals = function(e, t, r) { 533 if (Math.abs(t - this.y) <= e && Math.abs(r - this.x) <= e) { 534 var n = Math.abs(e - this.estimatedModuleSize); 535 return 1 >= n || n / this.estimatedModuleSize <= 1 536 } 537 return !1 538 } 539 } 540 541 function k(e) { 542 this.bottomLeft = e[0], this.topLeft = e[1], this.topRight = e[2], this.__defineGetter__("BottomLeft", function() { 543 return this.bottomLeft 544 }), this.__defineGetter__("TopLeft", function() { 545 return this.topLeft 546 }), this.__defineGetter__("TopRight", function() { 547 return this.topRight 548 }) 549 } 550 551 function S() { 552 this.image = null, this.possibleCenters = [], this.hasSkipped = !1, this.crossCheckStateCount = new Array(0, 0, 0, 0, 0), this.resultPointCallback = null, this.__defineGetter__("CrossCheckStateCount", function() { 553 return this.crossCheckStateCount[0] = 0, this.crossCheckStateCount[1] = 0, this.crossCheckStateCount[2] = 0, this.crossCheckStateCount[3] = 0, this.crossCheckStateCount[4] = 0, this.crossCheckStateCount 554 }), this.foundPatternCross = function(e) { 555 for (var t = 0, r = 0; 5 > r; r++) { 556 var n = e[r]; 557 if (0 == n) return !1; 558 t += n 559 } 560 if (7 > t) return !1; 561 var i = Math.floor((t << L) / 7), 562 o = Math.floor(i / 2); 563 return Math.abs(i - (e[0] << L)) < o && Math.abs(i - (e[1] << L)) < o && Math.abs(3 * i - (e[2] << L)) < 3 * o && Math.abs(i - (e[3] << L)) < o && Math.abs(i - (e[4] << L)) < o 564 }, this.centerFromEnd = function(e, t) { 565 return t - e[4] - e[3] - e[2] / 2 566 }, this.crossCheckVertical = function(e, t, r, n) { 567 for (var i = this.image, o = qrcode.height, a = this.CrossCheckStateCount, s = e; s >= 0 && i[t + s * qrcode.width];) a[2]++, s--; 568 if (0 > s) return 0 / 0; 569 for (; s >= 0 && !i[t + s * qrcode.width] && a[1] <= r;) a[1]++, s--; 570 if (0 > s || a[1] > r) return 0 / 0; 571 for (; s >= 0 && i[t + s * qrcode.width] && a[0] <= r;) a[0]++, s--; 572 if (a[0] > r) return 0 / 0; 573 for (s = e + 1; o > s && i[t + s * qrcode.width];) a[2]++, s++; 574 if (s == o) return 0 / 0; 575 for (; o > s && !i[t + s * qrcode.width] && a[3] < r;) a[3]++, s++; 576 if (s == o || a[3] >= r) return 0 / 0; 577 for (; o > s && i[t + s * qrcode.width] && a[4] < r;) a[4]++, s++; 578 if (a[4] >= r) return 0 / 0; 579 var h = a[0] + a[1] + a[2] + a[3] + a[4]; 580 return 5 * Math.abs(h - n) >= 2 * n ? 0 / 0 : this.foundPatternCross(a) ? this.centerFromEnd(a, s) : 0 / 0 581 }, this.crossCheckHorizontal = function(e, t, r, n) { 582 for (var i = this.image, o = qrcode.width, a = this.CrossCheckStateCount, s = e; s >= 0 && i[s + t * qrcode.width];) a[2]++, s--; 583 if (0 > s) return 0 / 0; 584 for (; s >= 0 && !i[s + t * qrcode.width] && a[1] <= r;) a[1]++, s--; 585 if (0 > s || a[1] > r) return 0 / 0; 586 for (; s >= 0 && i[s + t * qrcode.width] && a[0] <= r;) a[0]++, s--; 587 if (a[0] > r) return 0 / 0; 588 for (s = e + 1; o > s && i[s + t * qrcode.width];) a[2]++, s++; 589 if (s == o) return 0 / 0; 590 for (; o > s && !i[s + t * qrcode.width] && a[3] < r;) a[3]++, s++; 591 if (s == o || a[3] >= r) return 0 / 0; 592 for (; o > s && i[s + t * qrcode.width] && a[4] < r;) a[4]++, s++; 593 if (a[4] >= r) return 0 / 0; 594 var h = a[0] + a[1] + a[2] + a[3] + a[4]; 595 return 5 * Math.abs(h - n) >= n ? 0 / 0 : this.foundPatternCross(a) ? this.centerFromEnd(a, s) : 0 / 0 596 }, this.handlePossibleCenter = function(e, t, r) { 597 var n = e[0] + e[1] + e[2] + e[3] + e[4], 598 i = this.centerFromEnd(e, r), 599 o = this.crossCheckVertical(t, Math.floor(i), e[2], n); 600 if (!isNaN(o) && (i = this.crossCheckHorizontal(Math.floor(i), Math.floor(o), e[2], n), !isNaN(i))
600) { 601 for (var a = n / 7, s = !1, h = this.possibleCenters.length, d = 0; h > d; d++) { 602 var w = this.possibleCenters[d]; 603 if (w.aboutEquals(a, o, i)) { 604 w.incrementCount(), s = !0; 605 break 606 } 607 } 608 if (!s) { 609 var f = new q(i, o, a); 610 this.possibleCenters.push(f), null != this.resultPointCallback && this.resultPointCallback.foundPossibleResultPoint(f) 611 } 612 return !0 613 } 614 return !1 615 }, this.selectBestPatterns = function() { 616 var e = this.possibleCenters.length; 617 if (3 > e) throw "Couldn't find enough finder patterns"; 618 if (e > 3) { 619 for (var t = 0, r = 0, n = 0; e > n; n++) { 620 var i = this.possibleCenters[n].EstimatedModuleSize; 621 t += i, r += i * i 622 } 623 var o = t / e; 624 this.possibleCenters.sort(function(e, t) { 625 var r = Math.abs(t.EstimatedModuleSize - o), 626 n = Math.abs(e.EstimatedModuleSize - o); 627 return n > r ? -1 : r == n ? 0 : 1 628 }); 629 for (var a = Math.sqrt(r / e - o * o), s = Math.max(.2 * o, a), n = 0; n < this.possibleCenters.length && this.possibleCenters.length > 3; n++) { 630 var h = this.possibleCenters[n]; 631 Math.abs(h.EstimatedModuleSize - o) > s && (this.possibleCenters.remove(n), n--) 632 } 633 } 634 return this.possibleCenters.length > 3 && this.possibleCenters.sort(function(e, t) { 635 return e.count > t.count ? -1 : e.count < t.count ? 1 : 0 636 }), new Array(this.possibleCenters[0], this.possibleCenters[1], this.possibleCenters[2]) 637 }, this.findRowSkip = function() { 638 var e = this.possibleCenters.length; 639 if (1 >= e) return 0; 640 for (var t = null, r = 0; e > r; r++) { 641 var n = this.possibleCenters[r]; 642 if (n.Count >= O) { 643 if (null != t) return this.hasSkipped = !0, Math.floor((Math.abs(t.X - n.X) - Math.abs(t.Y - n.Y)) / 2); 644 t = n 645 } 646 } 647 return 0 648 }, this.haveMultiplyConfirmedCenters = function() { 649 for (var e = 0, t = 0, r = this.possibleCenters.length, n = 0; r > n; n++) { 650 var i = this.possibleCenters[n]; 651 i.Count >= O && (e++, t += i.EstimatedModuleSize) 652 } 653 if (3 > e) return !1; 654 for (var o = t / r, a = 0, n = 0; r > n; n++) i = this.possibleCenters[n], a += Math.abs(i.EstimatedModuleSize - o); 655 return .05 * t >= a 656 }, this.findFinderPattern = function(e) { 657 var t = !1; 658 this.image = e; 659 var r = qrcode.height, 660 n = qrcode.width, 661 i = Math.floor(3 * r / (4 * V)); 662 (z > i || t) && (i = z); 663 for (var o = !1, a = new Array(5), s = i - 1; r > s && !o; s += i) { 664 a[0] = 0, a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 0; 665 for (var h = 0, d = 0; n > d; d++) 666 if (e[d + s * qrcode.width]) 1 == (1 & h) && h++, a[h]++; 667 else if (0 == (1 & h)) 668 if (4 == h) 669 if (this.foundPatternCross(a)) { 670 var w = this.handlePossibleCenter(a, s, d); 671 if (w) 672 if (i = 2, this.hasSkipped) o = this.haveMultiplyConfirmedCenters(); 673 else { 674 var f = this.findRowSkip(); 675 f > a[2] && (s += f - a[2] - i, d = n - 1) 676 } 677 else { 678 do d++; while (n > d && !e[d + s * qrcode.width]); 679 d-- 680 } 681 h = 0, a[0] = 0, a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 0 682 } else a[0] = a[2], a[1] = a[3], a[2] = a[4], a[3] = 1, a[4] = 0, h = 3; 683 else a[++h]++; 684 else a[h]++; 685 if (this.foundPatternCross(a)) { 686 var w = this.handlePossibleCenter(a, s, n); 687 w && (i = a[0], this.hasSkipped && (o = haveMultiplyConfirmedCenters())) 688 } 689 } 690 var c = this.selectBestPatterns(); 691 return qrcode.orderBestPatterns(c), new k(c) 692 } 693 } 694 695 function E(e, t, r) { 696 this.x = e, this.y = t, this.count = 1, this.estimatedModuleSize = r, this.__defineGetter__("EstimatedModuleSize", function() { 697 return this.estimatedModuleSize 698 }), this.__defineGetter__("Count", function() { 699 return this.count 700 }), this.__defineGetter__("X", function() { 701 return Math.floor(this.x) 702 }), this.__defineGetter__("Y", function() { 703 return Math.floor(this.y) 704 }), this.incrementCount = function() { 705 this.count++ 706 }, this.aboutEquals = function(e, t, r) { 707 if (Math.abs(t - this.y) <= e && Math.abs(r - this.x) <= e) { 708 var n = Math.abs(e - this.estimatedModuleSize); 709 return 1 >= n || n / this.estimatedModuleSize <= 1 710 } 711 return !1 712 } 713 } 714 715 function P(e, t, r, n, i, o, a) { 716 this.image = e, this.possibleCenters = new Array, this.startX = t, this.startY = r, this.width = n, this.height = i, this.moduleSize = o, this.crossCheckStateCount = new Array(0, 0, 0), this.resultPointCallback = a, this.centerFromEnd = function(e, t) { 717 return t - e[2] - e[1] / 2 718 }, this.foundPatternCross = function(e) { 719 for (var t = this.moduleSize, r = t / 2, n = 0; 3 > n; n++) 720 if (Math.abs(t - e[n]) >= r) return !1; 721 return !0 722 }, this.crossCheckVertical = function(e, t, r, n) { 723 var i = this.image, 724 o = qrcode.height, 725 a = this.crossCheckStateCount; 726 a[0] = 0, a[1] = 0, a[2] = 0; 727 for (var s = e; s >= 0 && i[t + s * qrcode.width] && a[1] <= r;) a[1]++, s--; 728 if (0 > s || a[1] > r) return 0 / 0; 729 for (; s >= 0 && !i[t + s * qrcode.width] && a[0] <= r;) a[0]++, s--; 730 if (a[0] > r) return 0 / 0; 731 for (s = e + 1; o > s && i[t + s * qrcode.width] && a[1] <= r;) a[1]++, s++; 732 if (s == o || a[1] > r) return 0 / 0; 733 for (; o > s && !i[t + s * qrcode.width] && a[2] <= r;) a[2]++, s++; 734 if (a[2] > r) return 0 / 0; 735 var h = a[0] + a[1] + a[2]; 736 return 5 * Math.abs(h - n) >= 2 * n ? 0 / 0 : this.foundPatternCross(a) ? this.centerFromEnd(a, s) : 0 / 0 737 }, this.handlePossibleCenter = function(e, t, r) { 738 var n = e[0] + e[1] + e[2], 739 i = this.centerFromEnd(e, r), 740 o = this.crossCheckVertical(t, Math.floor(i), 2 * e[1], n); 741 if (!isNaN(o)) { 742 for (var a = (e[0] + e[1] + e[2]) / 3, s = this.possibleCenters.length, h
742= 0; s > h; h++) { 743 var d = this.possibleCenters[h]; 744 if (d.aboutEquals(a, o, i)) return new E(i, o, a) 745 } 746 var w = new E(i, o, a); 747 this.possibleCenters.push(w), null != this.resultPointCallback && this.resultPointCallback.foundPossibleResultPoint(w) 748 } 749 return null 750 }, this.find = function() { 751 for (var t = this.startX, i = this.height, o = t + n, a = r + (i >> 1), s = new Array(0, 0, 0), h = 0; i > h; h++) { 752 var d = a + (0 == (1 & h) ? h + 1 >> 1 : -(h + 1 >> 1)); 753 s[0] = 0, s[1] = 0, s[2] = 0; 754 for (var w = t; o > w && !e[w + qrcode.width * d];) w++; 755 for (var f = 0; o > w;) { 756 if (e[w + d * qrcode.width]) 757 if (1 == f) s[f]++; 758 else if (2 == f) { 759 if (this.foundPatternCross(s)) { 760 var c = this.handlePossibleCenter(s, d, w); 761 if (null != c) return c 762 } 763 s[0] = s[2], s[1] = 1, s[2] = 0, f = 1 764 } else s[++f]++; 765 else 1 == f && f++, s[f]++; 766 w++ 767 } 768 if (this.foundPatternCross(s)) { 769 var c = this.handlePossibleCenter(s, d, o); 770 if (null != c) return c 771 } 772 } 773 if (0 != this.possibleCenters.length) return this.possibleCenters[0]; 774 throw "Couldn't find enough alignment patterns" 775 } 776 } 777 778 function D(e, t, r) { 779 this.blockPointer = 0, this.bitPointer = 7, this.dataLength = 0, this.blocks = e, this.numErrorCorrectionCode = r, 9 >= t ? this.dataLengthMode = 0 : t >= 10 && 26 >= t ? this.dataLengthMode = 1 : t >= 27 && 40 >= t && (this.dataLengthMode = 2), this.getNextBits = function(e) { 780 var t = 0; 781 if (e < this.bitPointer + 1) { 782 for (var r = 0, n = 0; e > n; n++) r += 1 << n; 783 return r <<= this.bitPointer - e + 1, t = (this.blocks[this.blockPointer] & r) >> this.bitPointer - e + 1, this.bitPointer -= e, t 784 } 785 if (e < this.bitPointer + 1 + 8) { 786 for (var i = 0, n = 0; n < this.bitPointer + 1; n++) i += 1 << n; 787 return t = (this.blocks[this.blockPointer] & i) << e - (this.bitPointer + 1), this.blockPointer++, t += this.blocks[this.blockPointer] >> 8 - (e - (this.bitPointer + 1)), this.bitPointer = this.bitPointer - e % 8, this.bitPointer < 0 && (this.bitPointer = 8 + this.bitPointer), t 788 } 789 if (e < this.bitPointer + 1 + 16) { 790 for (var i = 0, o = 0, n = 0; n < this.bitPointer + 1; n++) i += 1 << n; 791 var a = (this.blocks[this.blockPointer] & i) << e - (this.bitPointer + 1); 792 this.blockPointer++; 793 var s = this.blocks[this.blockPointer] << e - (this.bitPointer + 1 + 8); 794 this.blockPointer++; 795 for (var n = 0; n < e - (this.bitPointer + 1 + 8); n++) o += 1 << n; 796 o <<= 8 - (e - (this.bitPointer + 1 + 8)); 797 var h = (this.blocks[this.blockPointer] & o) >> 8 - (e - (this.bitPointer + 1 + 8)); 798 return t = a + s + h, this.bitPointer = this.bitPointer - (e - 8) % 8, this.bitPointer < 0 && (this.bitPointer = 8 + this.bitPointer), t 799 } 800 return 0 801 }, this.NextMode = function() { 802 return this.blockPointer > this.blocks.length - this.numErrorCorrectionCode - 2 ? 0 : this.getNextBits(4) 803 }, this.getDataLength = function(e) { 804 for (var t = 0;;) { 805 if (e >> t == 1) break; 806 t++ 807 } 808 return this.getNextBits(qrcode.sizeOfDataLengthInfo[this.dataLengthMode][t]) 809 }, this.getRomanAndFigureString = function(e) { 810 var t = e, 811 r = 0, 812 n = "", 813 i = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ", "$", "%", "*", "+", "-", ".", "/", ":"); 814 do 815 if (t > 1) { 816 r = this.getNextBits(11); 817 var o = Math.floor(r / 45), 818 a = r % 45; 819 n += i[o], n += i[a], t -= 2 820 } else 1 == t && (r = this.getNextBits(6), n += i[r], t -= 1); while (t > 0); 821 return n 822 }, this.getFigureString = function(e) { 823 var t = e, 824 r = 0, 825 n = ""; 826 do t >= 3 ? (r = this.getNextBits(10), 100 > r && (n += "0"), 10 > r && (n += "0"), t -= 3) : 2 == t ? (r = this.getNextBits(7), 10 > r && (n += "0"), t -= 2) : 1 == t && (r = this.getNextBits(4), t -= 1), n += r; while (t > 0); 827 return n 828 }, this.get8bitByteArray = function(e) { 829 var t = e, 830 r = 0, 831 n = new Array; 832 do r = this.getNextBits(8), n.push(r), t--; while (t > 0); 833 return n 834 }, this.getKanjiString = function(e) { 835 var t = e, 836 r = 0, 837 n = ""; 838 do { 839 r = getNextBits(13); 840 var i = r % 192, 841 o = r / 192, 842 a = (o << 8) + i, 843 s = 0; 844 s = 40956 >= a + 33088 ? a + 33088 : a + 49472, n += String.fromCharCode(s), t-- 845 } while (t > 0); 846 return n 847 }, this.__defineGetter__("DataByte", function() { 848 for (var e = new Array, t = 1, r = 2, n = 4, i = 8;;) { 849 var o = this.NextMode(); 850 if (0 == o) { 851 if (e.length > 0) break; 852 throw "Empty data block" 853 } 854 if (o != t && o != r && o != n && o != i) throw "Invalid mode: " + o + " in (block:" + this.blockPointer + " bit:" + this.bitPointer + ")"; 855 if (dataLength = this.getDataLength(o), 1 > dataLength) throw "Invalid data length: " + dataLength; 856 switch (o) { 857 case t: 858 for (var a = this.getFigureString(dataLength), s = new Array(a.length), h = 0; h < a.length; h++) s[h] = a.charCodeAt(h); 859 e.push(s); 860 break; 861 case r: 862 for (var a = this.getRomanAndFigureString(dataLength), s = new Array(a.length), h = 0; h < a.length; h++) s[h] = a.charCodeAt(h); 863 e.push(s); 864 break; 865 case n: 866 var d = this.get8bitByteArray(dataLength); 867 e.push(d); 868 break; 869 case i: 870 var a = this.getKanjiString(dataLength); 871 e.push(a) 872 } 873 } 874 return e 875 }) 876 } 877 GridSampler = {}, GridSampler.checkAndNudgePoints = function(e, t) { 878 for (var r = qrcode.width, n = qrcode.height, i = !0, o = 0; o < t.length && i; o += 2) { 879 var a = Math.floor(t[o]), 880 s = Math.floor(t[o + 1]); 881 if (-1 > a || a > r || -1 > s || s > n) throw "Error.checkAndNudgePoints "; 882 i = !1, -1 == a ? (t[o] = 0, i = !0) : a == r && (t[o] = r - 1, i = !0), -1 == s ? (t[o + 1] = 0, i = !0) : s == n && (t[o + 1] = n - 1, i = !0) 883 } 884 i = !0; 885 for (var o = t.length - 2; o >= 0 && i; o -= 2) { 886 var a = Math.floor(t[o]), 887 s = Math.floor(t[o + 1]); 888 if (-1 > a || a > r || -1 > s || s > n) throw "Error.checkAndNudgePoints "; 889 i = !1, -1 == a ? (t[o] = 0, i = !0) : a == r && (t[o] = r - 1, i = !0), -1 == s ? (t[o + 1] = 0, i = !0) : s == n && (t[o + 1] = n - 1, i = !0) 890 } 891 }, GridSampler.sampleGrid3 = function(e, t, r) { 892 for (var n = new d(t), i = new Array(t << 1), o = 0; t > o; o++) { 893 for (var a = i.length, s = o + .5, h = 0; a > h; h += 2) i[h] = (h >> 1) + .5, i[h + 1] = s; 894 r.transformPoints1(i), GridSampler.checkAndNudgePoints(e, i); 895 try { 896 for (var h = 0; a > h; h += 2) { 897 var w = 4 * Math.floor(i[h]) + Math.floor(i[h + 1]) * qrcode.width * 4, 898 f = e[Math.floor(i[h]) + qrcode.width * Math.floor(i[h + 1])]; 899 qrcode.imagedata.data[w] = f ? 255 : 0, qrcode.imagedata.data[w + 1] = f ? 255 : 0, qrcode.imagedata.data[w + 2] = 0, qrcode.imagedata.data[w + 3] = 255, f && n.set_Renamed(h >> 1, o) 900 } 901 } catch (c) { 902 throw "Error.checkAndNudgePoints" 903 } 904 } 905 return n 906 }, GridSampler.sampleGridx = function(e, t, r, n, o, a, s, h, d, w, f, c, u, l, v, g, m, y) { 907 var p = i.quadrilateralToQuadrilateral(r, n, o, a, s, h, d, w, f, c, u, l, v, g, m, y); 908 return GridSampler.sampleGrid3(e, t, p) 909 }, r.VERSION_DECODE_INFO = new Array(31892, 34236, 39577, 42195, 48118, 51042, 55367, 58893, 63784, 68472, 70749, 76311, 79154, 84390, 87683, 92361, 9
9096236, 102084, 102881, 110507, 110734, 117786, 119615, 126325, 127568, 133589, 136944, 141498, 145311, 150283, 152622, 158308, 161089, 167017), r.VERSIONS = n(), r.getVersionForNumber = function(e) { 910 if (1 > e || e > 40) throw "ArgumentException"; 911 return r.VERSIONS[e - 1] 912 }, r.getProvisionalVersionForDimension = function(e) { 913 if (e % 4 != 1) throw "Error getProvisionalVersionForDimension"; 914 try { 915 return r.getVersionForNumber(e - 17 >> 2) 916 } catch (t) { 917 throw "Error getVersionForNumber" 918 } 919 }, r.decodeVersionInformation = function(e) { 920 for (var t = 4294967295, n = 0, i = 0; i < r.VERSION_DECODE_INFO.length; i++) { 921 var o = r.VERSION_DECODE_INFO[i]; 922 if (o == e) return this.getVersionForNumber(i + 7); 923 var a = s.numBitsDiffering(e, o); 924 t > a && (n = i + 7, t = a) 925 } 926 return 3 >= t ? this.getVersionForNumber(n) : null 927 }, i.quadrilateralToQuadrilateral = function(e, t, r, n, i, o, a, s, h, d, w, f, c, u, l, v) { 928 var g = this.quadrilateralToSquare(e, t, r, n, i, o, a, s), 929 m = this.squareToQuadrilateral(h, d, w, f, c, u, l, v); 930 return m.times(g) 931 }, i.squareToQuadrilateral = function(e, t, r, n, o, a, s, h) { 932 return dy2 = h - a, dy3 = t - n + a - h, 0 == dy2 && 0 == dy3 ? new i(r - e, o - r, e, n - t, a - n, t, 0, 0, 1) : (dx1 = r - o, dx2 = s - o, dx3 = e - r + o - s, dy1 = n - a, denominator = dx1 * dy2 - dx2 * dy1, a13 = (dx3 * dy2 - dx2 * dy3) / denominator, a23 = (dx1 * dy3 - dx3 * dy1) / denominator, new i(r - e + a13 * r, s - e + a23 * s, e, n - t + a13 * n, h - t + a23 * h, t, a13, a23, 1)) 933 }, i.quadrilateralToSquare = function(e, t, r, n, i, o, a, s) { 934 return this.squareToQuadrilateral(e, t, r, n, i, o, a, s).buildAdjoint() 935 }; 936 var x = 21522, 937 B = new Array(new Array(21522, 0), new Array(20773, 1), new Array(24188, 2), new Array(23371, 3), new Array(17913, 4), new Array(16590, 5), new Array(20375, 6), new Array(19104, 7), new Array(30660, 8), new Array(29427, 9), new Array(32170, 10), new Array(30877, 11), new Array(26159, 12), new Array(25368, 13), new Array(27713, 14), new Array(26998, 15), new Array(5769, 16), new Array(5054, 17), new Array(7399, 18), new Array(6608, 19), new Array(1890, 20), new Array(597, 21), new Array(3340, 22), new Array(2107, 23), new Array(13663, 24), new Array(12392, 25), new Array(16177, 26), new Array(14854, 27), new Array(9396, 28), new Array(8579, 29), new Array(11994, 30), new Array(11245, 31)), 938 F = new Array(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4); 939 s.numBitsDiffering = function(e, t) { 940 return e ^= t, F[15 & e] + F[15 & A(e, 4)] + F[15 & A(e, 8)] + F[15 & A(e, 12)] + F[15 & A(e, 16)] + F[15 & A(e, 20)] + F[15 & A(e, 24)] + F[15 & A(e, 28)] 941 }, s.decodeFormatInformation = function(e) { 942 var t = s.doDecodeFormatInformation(e); 943 return null != t ? t : s.doDecodeFormatInformation(e ^ x) 944 }, s.doDecodeFormatInformation = function(e) { 945 for (var t = 4294967295, r = 0, n = 0; n < B.length; n++) { 946 var i = B[n], 947 o = i[0]; 948 if (o == e) return new s(i[1]); 949 var a = this.numBitsDiffering(e, o); 950 t > a && (r = i[1], t = a) 951 } 952 return 3 >= t ? new s(r) : null 953 }, h.forBits = function(e) { 954 if (0 > e || e >= R.length) throw "ArgumentException"; 955 return R[e] 956 }; 957 var G = new h(0, 1, "L"), 958 I = new h(1, 0, "M"), 959 T = new h(2, 3, "Q"), 960 N = new h(3, 2, "H"), 961 R = new Array(I, G, N, T); 962 w.getDataBlocks = function(e, t, r) { 963 if (e.length != t.TotalCodewords) throw "ArgumentException"; 964 for (var n = t.getECBlocksForLevel(r), i = 0, o = n.getECBlocks(), a = 0; a < o.length; a++) i += o[a].Count; 965 for (var s = new Array(i), h = 0, d = 0; d < o.length; d++) 966 for (var f = o[d], a = 0; a < f.Count; a++) { 967 var c = f.DataCodewords, 968 u = n.ECCodewordsPerBlock + c; 969 s[h++] = new w(c, new Array(u)) 970 }
971 for (var l = s[0].codewords.length, v = s.length - 1; v >= 0;) { 972 var g = s[v].codewords.length; 973 if (g == l) break; 974 v-- 975 } 976 v++; 977 for (var m = l - n.ECCodewordsPerBlock, y = 0, a = 0; m > a; a++) 978 for (var d = 0; h > d; d++) s[d].codewords[a] = e[y++]; 979 for (var d = v; h > d; d++) s[d].codewords[m] = e[y++]; 980 for (var p = s[0].codewords.length, a = m; p > a; a++) 981 for (var d = 0; h > d; d++) { 982 var b = v > d ? a : a + 1; 983 s[d].codewords[b] = e[y++] 984 } 985 return s 986 }, DataMask = {}, DataMask.forReference = function(e) { 987 if (0 > e || e > 7) throw "System.ArgumentException"; 988 return DataMask.DATA_MASKS[e] 989 }, DataMask.DATA_MASKS = new Array(new c, new u, new l, new v, new g, new m, new y, new b), _.QR_CODE_FIELD = new _(285), _.DATA_MATRIX_FIELD = new _(301), _.addOrSubtract = function(e, t) { 990 return e ^ t 991 }, Decoder = {}, Decoder.rsDecoder = new C(_.QR_CODE_FIELD), Decoder.correctErrors = function(e, t) { 992 for (var r = e.length, n = new Array(r), i = 0; r > i; i++) n[i] = 255 & e[i]; 993 var o = e.length - t; 994 try { 995 Decoder.rsDecoder.decode(n, o) 996 } catch (a) { 997 throw a 998 } 999 for (var i = 0; t > i; i++) e[i] = n[i] 1000 }, Decoder.decode = function(e) { 1001 for (var t = new f(e), r = t.readVersion(), n = t.readFormatInformation().ErrorCorrectionLevel, i = t.readCodewords(), o = w.getDataBlocks(i, r, n), a = 0, s = 0; s < o.length; s++) a += o[s].NumDataCodewords; 1002 for (var h = new Array(a), d = 0, c = 0; c < o.length; c++) { 1003 var u = o[c], 1004 l = u.Codewords, 1005 v = u.NumDataCodewords; 1006 Decoder.correctErrors(l, v); 1007 for (var s = 0; v > s; s++) h[d++] = l[s] 1008 } 1009 var g = new D(h, r.VersionNumber, n.Bits); 1010 return g 1011 }, qrcode = {}, qrcode.imagedata = null, qrcode.width = 0, qrcode.height = 0, qrcode.qrCodeSymbol = null, qrcode.debug = !1, qrcode.maxImgSize = 1048576, qrcode.canvasElement = null, qrcode.sizeOfDataLengthInfo = [ 1012 [10, 9, 8, 8], 1013 [12, 11, 16, 10], 1014 [14, 13, 16, 12] 1015 ], qrcode.callback = null, qrcode.setCanvasElement = function(e) { 1016 qrcode.canvasElement = e 1017 }, qrcode.decode = function(e, t) { 1018 if (0 == arguments.length) { 1019 var r = qrcode.canvasElement, 1020 n = r.getContext("2d"); 1021 return qrcode.width = r.width, qrcode.height = r.height, qrcode.imagedata = n.getImageData(0, 0, qrcode.width, qrcode.height), qrcode.result = qrcode.process(n), null != qrcode.callback && qrcode.callback(qrcode.result), qrcode.result 1022 } 1023 var i = new Image; 1024 i.onload = function() { 1025 var e = document.createElement("canvas"), 1026 r = e.getContext("2d"), 1027 n = i.height, 1028 o = i.width; 1029 if (i.width * i.height > qrcode.maxImgSize) { 1030 var a = i.width / i.height; 1031 n = Math.sqrt(qrcode.maxImgSize / a), o = a * n 1032 } 1033 e.width = o, e.height = n, r.drawImage(i, 0, 0, e.width, e.height), qrcode.width = e.width, qrcode.height = e.height; 1034 try { 1035 qrcode.imagedata = r.getImageData(0, 0, e.width, e.height) 1036 } catch (s) { 1037 return qrcode.result = "Cross domain Error", null != qrcode.callback && qrcode.callback(qrcode.result), void 0 1038 } 1039 try { 1040 qrcode.result = qrcode.process(r), t(null, qrcode.result) 1041 } catch (s) { 1042 qrcode.result = "Error decoding QR Code from Image", t(new Error("Error decoding QR Code from Image")) 1043 } 1044 null != qrcode.callback && qrcode.callback(qrcode.result) 1045 }, i.src = e 1046 }, qrcode.isUrl = function(e) { 1047 var t = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; 1048 return t.test(e) 1049 }, qrcode.decode_url = function(e) { 1050 var t = ""; 1051 try { 1052 t = escape(e) 1053 } catch (r) { 1054 t = e 1055 } 1056 var n = ""; 1057 try { 1058 n = decodeURIComponent(t) 1059 } catch (r) { 1060 n = t 1061 } 1062 return n 1063 }, qrcode.decode_utf8 = function(e) { 1064 return qrcode.isUrl(e) ? qrcode.decode_url(e) : e 1065 }, qrcode.process = function(e) { 1066 var t = ((new Date).getTime(), qrcode.grayScaleToBitmap(qrcode.grayscale())); 1067 if (qrcode.debug) { 1068 for (var r = 0; r < qrcode.height; r++) 1069 for (var n = 0; n < qrcode.width; n++) { 1070 var i = 4 * n + r * qrcode.width * 4; 1071 qrcode.imagedata.data[i] = t[n + r * qrcode.width] ? 0 : 0, qrcode.imagedata.data[i + 1] = t[n + r * qrcode.width] ? 0 : 0, qrcode.imagedata.data[i + 2] = t[n + r * qrcode.width] ? 255 : 0 1072 } 1073 e.putImageData(qrcode.imagedata, 0, 0) 1074 } 1075 var o = new a(t), 1076 s = o.detect(); 1077 qrcode.debug && e.putImageData(qrcode.imagedata, 0, 0); 1078 for (var h = Decoder.decode(s.bits), d = h.DataByte, w = "", f = 0; f < d.length; f++) 1079 for (var c = 0; c < d[f].length; c++) w += String.fromCharCode(d[f][c]); 1080 (new Date).getTime(); 1081 return qrcode.decode_utf8(w) 1082 }, qrcode.getPixel = function(e, t) { 1083 if (qrcode.width < e) throw "point error"; 1084 if (qrcode.height < t) throw "point error"; 1085 return point = 4 * e + t * qrcode.width * 4, p = (33 * qrcode.imagedata.data[point] + 34 * qrcode.imagedata.data[point + 1] + 33 * qrcode.imagedata.data[point + 2]) / 100 1086 }, qrcode.binarize = function(e) { 1087 for (var t = new Array(qrcode.width * qrcode.height), r = 0; r < qrcode.height; r++) 1088 for (var n = 0; n < qrcode.width; n++) { 1089 var i = qrcode.getPixel(n, r); 1090 t[n + r * qrcode.width] = e >= i ? !0 : !1 1091 } 1092 return t 1093 }, qrcode.getMiddleBrightnessPerArea = function(e) { 1094 for (var t = 4, r = Math.floor(qrcode.width / t), n = Math.floor(qrcode.height / t), i = new Array(t), o = 0; t > o; o++) { 1095 i[o] = new Array(t); 1096 for (var a = 0; t > a; a++) i[o][a] = new Array(0, 0) 1097 } 1098 for (var s = 0; t > s; s++) 1099 for (var h = 0; t > h; h++) { 1100 i[h][s][0] = 255; 1101 for (var d = 0; n > d; d++) 1102 for (var w = 0; r > w; w++) { 1103 var f = e[r * h + w + (n * s + d) * qrcode.width]; 1104 f < i[h][s][0] && (i[h][s][0] = f), f > i[h][s][1] && (i[h][s][1] = f) 1105 } 1106 } 1107 for (var c = new Array(t), u = 0; t > u; u++) c[u] = new Array(t); 1108 for (var s = 0; t > s; s++) 1109 for (var h = 0; t > h; h++) c[h][s] = Math.floor((i[h][s][0] + i[h][s][1]) / 2); 1110 return c 1111 }, qrcode.grayScaleToBitmap = function(e) { 1112 for (var t = qrcode.getMiddleBrightnessPerArea(e), r = t.length, n = Math.floor(qrcode.width / r), i = Math.floor(qrcode.height / r), o = new Array(qrcode.height * qrcode.width), a = 0; r > a; a++) 1113 for (var s = 0; r > s; s++) 1114 for (var h = 0; i > h; h++) 1115 for (var d = 0; n > d; d++) o[n * s + d + (i * a + h) * qrcode.width] = e[n * s + d + (i * a + h) * qrcode.width] < t[s][a] ? !0 : !1; 1116 return o 1117 }, qrcode.grayscale = function() { 1118 for (var e = new Array(qrcode.width * qrcode.height), t = 0; t < qrcode.height; t++) 1119 for (var r = 0; r < qrcode.width; r++) { 1120 var n = qrcode.getPixel(r, t); 1121 e[r + t * qrcode.width] = n 1122 } 1123 return e 1124 }, Array.prototype.remove = function(e, t) { 1125 var r = this.slice((t || e) + 1 || this.length); 1126 return this.length = 0 > e ? this.length + e : e, this.push.apply(this, r) 1127 }; 1128 var z = 3, 1129 V = 57, 1130 L = 8, 1131 O = 2; 1132 return qrcode.orderBestPatterns = function(e) { 1133 function t(e, t) { 1134 return xDiff = e.X - t.X, yDiff = e.Y - t.Y, Math.sqrt(xDiff * xDiff + yDiff * yDiff) 1135 } 1136 1137 function r(e, t, r) { 1138 var n = t.x, 1139 i = t.y;
1140 return (r.x - n) * (e.y - i) - (r.y - i) * (e.x - n) 1141 } 1142 var n, i, o, a = t(e[0], e[1]), 1143 s = t(e[1], e[2]), 1144 h = t(e[0], e[2]); 1145 if (s >= a && s >= h ? (i = e[0], n = e[1], o = e[2]) : h >= s && h >= a ? (i = e[1], n = e[0], o = e[2]) : (i = e[2], n = e[0], o = e[1]), r(n, i, o) < 0) { 1146 var d = n; 1147 n = o, o = d 1148 } 1149 e[0] = n, e[1] = i, e[2] = o 1150 }, qrcode 1151}), 1152function(e, t) { 1153 "function" == typeof define && define.amd ? define(["qrcode"], t) : "object" == typeof exports ? module.exports = t(require("../build/qrcode")) : e.QCodeDecoder = t(qrcode) 1154}(this, function(e) { 1155 "use strict"; 1156 1157 function t() { 1158 return this instanceof t ? (this.timerCapture = null, this.canvasElem = null, this.stream = null, this.videoConstraints = { 1159 video: !0, 1160 audio: !1 1161 }, void 0) : new t 1162 } 1163 return t.prototype.isCanvasSupported = function() { 1164 var e = document.createElement("canvas"); 1165 return !(!e.getContext || !e.getContext("2d")) 1166 }, t.prototype.hasGetUserMedia = function() { 1167 return navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia, !!navigator.getUserMedia 1168 }, t.prototype._prepareCanvas = function(t) { 1169 return this.canvasElem || (this.canvasElem = document.createElement("canvas"), this.canvasElem.style.width = t.videoWidth + "px", this.canvasElem.style.height = t.videoHeight + "px", this.canvasElem.width = t.videoWidth, this.canvasElem.height = t.videoHeight), e.setCanvasElement(this.canvasElem), this 1170 }, t.prototype._captureToCanvas = function(t, r, n) { 1171 if (this.timerCapture && clearTimeout(this.timerCapture), t.videoWidth && t.videoHeight) { 1172 this.canvasElem || this._prepareCanvas(t); 1173 var i = this.canvasElem.getContext("2d"); 1174 i.clearRect(0, 0, t.videoWidth, t.videoHeight), i.drawImage(t, 0, 0, t.videoWidth, t.videoHeight); 1175 try { 1176 if (r(null, e.decode()), n) return 1177 } catch (o) { 1178 "Couldn't find enough finder patterns" !== o && r(new Error(o)) 1179 } 1180 } 1181 this.timerCapture = setTimeout(function() { 1182 this._captureToCanvas.call(this, t, r, n) 1183 }.bind(this), 500) 1184 }, t.prototype.decodeFromCamera = function(e, t, r) { 1185 var n = (this.stop(), this); 1186 return this.hasGetUserMedia() || t(new Error("Couldn't get video from camera")), navigator.getUserMedia(this.videoConstraints, function(i) { 1187 e.src = window.URL.createObjectURL(i), n.videoElem = e, n.stream = i, n.videoDimensions = !1, setTimeout(function() { 1188 n._captureToCanvas.call(n, e, t, r) 1189 }, 500) 1190 }, t), this 1191 }, t.prototype.decodeFromVideo = function(e, t, r) { 1192 return setTimeout(function() { 1193 this._captureToCanvas.call(this, e, t, r) 1194 }.bind(this), 500), this 1195 }, t.prototype.decodeFromImage = function(t, r) { 1196 if (+t.nodeType > 0 && !t.src) throw new Error("The ImageElement must contain a src"); 1197 return t = t.src ? t.src : t, e.decode(t, r), this 1198 }, t.prototype.stop = function() { 1199 return this.stream && (this.stream.stop(), this.stream = void 0), this.timerCapture && (clearTimeout(this.timerCapture), this.timerCapture = void 0), this 1200 }, t.prototype.setSourceId = function(e) { 1201 return this.videoConstraints.video = e ? { 1202 optional: [{ 1203 sourceId: e 1204 }] 1205 } : !0, this 1206 }, t.prototype.getVideoSources = function(e) { 1207 var t = []; 1208 return MediaStreamTrack && MediaStreamTrack.getSources ? MediaStreamTrack.getSources(function(r) { 1209 r.forEach(function(e) { 1210 "video" === e.kind && t.push(e) 1211 }), e(null, t) 1212 }) : e(new Error("Current browser doest not support MediaStreamTrack.getSources")), this 1213 }, t 1214});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.