UNPKG

vue-book-reader

Version:

vue-book-reader is a vue wrapper for [foliate-js](https://github.com/johnfactotum/foliate-js) - library for rendering e-books in the browser. Supports EPUB, MOBI, KF8 (AZW3), FB2, CBZ, PDF (experimental; requires PDF.js), or add support for other formats

962 lines 78.5 kB
const Z = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535], $t = [96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 192, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 160, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 224, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 144, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 208, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 176, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 240, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 200, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 168, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 232, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 152, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 216, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 184, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 248, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 196, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 164, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 228, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 148, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 212, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 180, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 244, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 204, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 172, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 236, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 156, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 220, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 188, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 252, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 194, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 162, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 226, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 146, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 210, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 178, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 242, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 202, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 170, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 234, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 154, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 218, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 186, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 250, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 198, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 166, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 230, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 150, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 214, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 182, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 246, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 206, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 174, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 238, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 158, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 222, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 190, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 254, 96, 7, 256, 0, 8, 80, 0, 8, 16, 84, 8, 115, 82, 7, 31, 0, 8, 112, 0, 8, 48, 0, 9, 193, 80, 7, 10, 0, 8, 96, 0, 8, 32, 0, 9, 161, 0, 8, 0, 0, 8, 128, 0, 8, 64, 0, 9, 225, 80, 7, 6, 0, 8, 88, 0, 8, 24, 0, 9, 145, 83, 7, 59, 0, 8, 120, 0, 8, 56, 0, 9, 209, 81, 7, 17, 0, 8, 104, 0, 8, 40, 0, 9, 177, 0, 8, 8, 0, 8, 136, 0, 8, 72, 0, 9, 241, 80, 7, 4, 0, 8, 84, 0, 8, 20, 85, 8, 227, 83, 7, 43, 0, 8, 116, 0, 8, 52, 0, 9, 201, 81, 7, 13, 0, 8, 100, 0, 8, 36, 0, 9, 169, 0, 8, 4, 0, 8, 132, 0, 8, 68, 0, 9, 233, 80, 7, 8, 0, 8, 92, 0, 8, 28, 0, 9, 153, 84, 7, 83, 0, 8, 124, 0, 8, 60, 0, 9, 217, 82, 7, 23, 0, 8, 108, 0, 8, 44, 0, 9, 185, 0, 8, 12, 0, 8, 140, 0, 8, 76, 0, 9, 249, 80, 7, 3, 0, 8, 82, 0, 8, 18, 85, 8, 163, 83, 7, 35, 0, 8, 114, 0, 8, 50, 0, 9, 197, 81, 7, 11, 0, 8, 98, 0, 8, 34, 0, 9, 165, 0, 8, 2, 0, 8, 130, 0, 8, 66, 0, 9, 229, 80, 7, 7, 0, 8, 90, 0, 8, 26, 0, 9, 149, 84, 7, 67, 0, 8, 122, 0, 8, 58, 0, 9, 213, 82, 7, 19, 0, 8, 106, 0, 8, 42, 0, 9, 181, 0, 8, 10, 0, 8, 138, 0, 8, 74, 0, 9, 245, 80, 7, 5, 0, 8, 86, 0, 8, 22, 192, 8, 0, 83, 7, 51, 0, 8, 118, 0, 8, 54, 0, 9, 205, 81, 7, 15, 0, 8, 102, 0, 8, 38, 0, 9, 173, 0, 8, 6, 0, 8, 134, 0, 8, 70, 0, 9, 237, 80, 7, 9, 0, 8, 94, 0, 8, 30, 0, 9, 157, 84, 7, 99, 0, 8, 126, 0, 8, 62, 0, 9, 221, 82, 7, 27, 0, 8, 110, 0, 8, 46, 0, 9, 189, 0, 8, 14, 0, 8, 142, 0, 8, 78, 0, 9, 253, 96, 7, 256, 0, 8, 81, 0, 8, 17, 85, 8, 131, 82, 7, 31, 0, 8, 113, 0, 8, 49, 0, 9, 195, 80, 7, 10, 0, 8, 97, 0, 8, 33, 0, 9, 163, 0, 8, 1, 0, 8, 129, 0, 8, 65, 0, 9, 227, 80, 7, 6, 0, 8, 89, 0, 8, 25, 0, 9, 147, 83, 7, 59, 0, 8, 121, 0, 8, 57, 0, 9, 211, 81, 7, 17, 0, 8, 105, 0, 8, 41, 0, 9, 179, 0, 8, 9, 0, 8, 137, 0, 8, 73, 0, 9, 243, 80, 7, 4, 0, 8, 85, 0, 8, 21, 80, 8, 258, 83, 7, 43, 0, 8, 117, 0, 8, 53, 0, 9, 203, 81, 7, 13, 0, 8, 101, 0, 8, 37, 0, 9, 171, 0, 8, 5, 0, 8, 133, 0, 8, 69, 0, 9, 235, 80, 7, 8, 0, 8, 93, 0, 8, 29, 0, 9, 155, 84, 7, 83, 0, 8, 125, 0, 8, 61, 0, 9, 219, 82, 7, 23, 0, 8, 109, 0, 8, 45, 0, 9, 187, 0, 8, 13, 0, 8, 141, 0, 8, 77, 0, 9, 251, 80, 7, 3, 0, 8, 83, 0, 8, 19, 85, 8, 195, 83, 7, 35, 0, 8, 115, 0, 8, 51, 0, 9, 199, 81, 7, 11, 0, 8, 99, 0, 8, 35, 0, 9, 167, 0, 8, 3, 0, 8, 131, 0, 8, 67, 0, 9, 231, 80, 7, 7, 0, 8, 91, 0, 8, 27, 0, 9, 151, 84, 7, 67, 0, 8, 123, 0, 8, 59, 0, 9, 215, 82, 7, 19, 0, 8, 107, 0, 8, 43, 0, 9, 183, 0, 8, 11, 0, 8, 139, 0, 8, 75, 0, 9, 247, 80, 7, 5, 0, 8, 87, 0, 8, 23, 192, 8, 0, 83, 7, 51, 0, 8, 119, 0, 8, 55, 0, 9, 207, 81, 7, 15, 0, 8, 103, 0, 8, 39, 0, 9, 175, 0, 8, 7, 0, 8, 135, 0, 8, 71, 0, 9, 239, 80, 7, 9, 0, 8, 95, 0, 8, 31, 0, 9, 159, 84, 7, 99, 0, 8, 127, 0, 8, 63, 0, 9, 223, 82, 7, 27, 0, 8, 111, 0, 8, 47, 0, 9, 191, 0, 8, 15, 0, 8, 143, 0, 8, 79, 0, 9, 255], en = [80, 5, 1, 87, 5, 257, 83, 5, 17, 91, 5, 4097, 81, 5, 5, 89, 5, 1025, 85, 5, 65, 93, 5, 16385, 80, 5, 3, 88, 5, 513, 84, 5, 33, 92, 5, 8193, 82, 5, 9, 90, 5, 2049, 86, 5, 129, 192, 5, 24577, 80, 5, 2, 87, 5, 385, 83, 5, 25, 91, 5, 6145, 81, 5, 7, 89, 5, 1537, 85, 5, 97, 93, 5, 24577, 80, 5, 4, 88, 5, 769, 84, 5, 49, 92, 5, 12289, 82, 5, 13, 90, 5, 3073, 86, 5, 193, 192, 5, 24577], tn = [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], nn = [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, 112, 112], rn = [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], an = [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], be = 15; function We() { let n, t, e, r, a, l; function s(d, _, w, g, y, z, c, p, i, o, u) { let b, x, k, m, h, A, D, U, v, S, E, O, W, F, C; S = 0, h = w; do e[d[_ + S]]++, S++, h--; while (h !== 0); if (e[0] == w) return c[0] = -1, p[0] = 0, 0; for (U = p[0], A = 1; A <= be && e[A] === 0; A++) ; for (D = A, U < A && (U = A), h = be; h !== 0 && e[h] === 0; h--) ; for (k = h, U > h && (U = h), p[0] = U, F = 1 << A; A < h; A++, F <<= 1) if ((F -= e[A]) < 0) return -3; if ((F -= e[h]) < 0) return -3; for (e[h] += F, l[1] = A = 0, S = 1, W = 2; --h != 0; ) l[W] = A += e[S], W++, S++; h = 0, S = 0; do (A = d[_ + S]) !== 0 && (u[l[A]++] = h), S++; while (++h < w); for (w = l[k], l[0] = h = 0, S = 0, m = -1, O = -U, a[0] = 0, E = 0, C = 0; D <= k; D++) for (b = e[D]; b-- != 0; ) { for (; D > O + U; ) { if (m++, O += U, C = k - O, C = C > U ? U : C, (x = 1 << (A = D - O)) > b + 1 && (x -= b + 1, W = D, A < C)) for (; ++A < C && !((x <<= 1) <= e[++W]); ) x -= e[W]; if (C = 1 << A, o[0] + C > 1440) return -3; a[m] = E = o[0], o[0] += C, m !== 0 ? (l[m] = h, r[0] = A, r[1] = U, A = h >>> O - U, r[2] = E - a[m - 1] - A, i.set(r, 3 * (a[m - 1] + A))) : c[0] = E; } for (r[1] = D - O, S >= w ? r[0] = 192 : u[S] < g ? (r[0] = u[S] < 256 ? 0 : 96, r[2] = u[S++]) : (r[0] = z[u[S] - g] + 16 + 64, r[2] = y[u[S++] - g]), x = 1 << D - O, A = h >>> O; A < C; A += x) i.set(r, 3 * (E + A)); for (A = 1 << D - 1; h & A; A >>>= 1) h ^= A; for (h ^= A, v = (1 << O) - 1; (h & v) != l[m]; ) m--, O -= U, v = (1 << O) - 1; } return F !== 0 && k != 1 ? -5 : 0; } function f(d) { let _; for (n || (n = [], t = [], e = new Int32Array(16), r = [], a = new Int32Array(be), l = new Int32Array(16)), t.length < d && (t = []), _ = 0; _ < d; _++) t[_] = 0; for (_ = 0; _ < 16; _++) e[_] = 0; for (_ = 0; _ < 3; _++) r[_] = 0; a.set(e.subarray(0, be), 0), l.set(e.subarray(0, 16), 0); } this.inflate_trees_bits = function(d, _, w, g, y) { let z; return f(19), n[0] = 0, z = s(d, 0, 19, 19, null, null, w, _, g, n, t), z == -3 ? y.msg = "oversubscribed dynamic bit lengths tree" : z != -5 && _[0] !== 0 || (y.msg = "incomplete dynamic bit lengths tree", z = -3), z; }, this.inflate_trees_dynamic = function(d, _, w, g, y, z, c, p, i) { let o; return f(288), n[0] = 0, o = s(w, 0, d, 257, tn, nn, z, g, p, n, t), o != 0 || g[0] === 0 ? (o == -3 ? i.msg = "oversubscribed literal/length tree" : o != -4 && (i.msg = "incomplete literal/length tree", o = -3), o) : (f(288), o = s(w, d, _, 0, rn, an, c, y, p, n, t), o != 0 || y[0] === 0 && d > 257 ? (o == -3 ? i.msg = "oversubscribed distance tree" : o == -5 ? (i.msg = "incomplete distance tree", o = -3) : o != -4 && (i.msg = "empty distance tree with lengths", o = -3), o) : 0); }; } We.inflate_trees_fixed = function(n, t, e, r) { return n[0] = 9, t[0] = 5, e[0] = $t, r[0] = en, 0; }; function sn() { const n = this; let t, e, r, a, l = 0, s = 0, f = 0, d = 0, _ = 0, w = 0, g = 0, y = 0, z = 0, c = 0; function p(i, o, u, b, x, k, m, h) { let A, D, U, v, S, E, O, W, F, C, j, K, T, R, M, L; O = h.next_in_index, W = h.avail_in, S = m.bitb, E = m.bitk, F = m.write, C = F < m.read ? m.read - F - 1 : m.end - F, j = Z[i], K = Z[o]; do { for (; E < 20; ) W--, S |= (255 & h.read_byte(O++)) << E, E += 8; if (A = S & j, D = u, U = b, L = 3 * (U + A), (v = D[L]) !== 0) for (; ; ) { if (S >>= D[L + 1], E -= D[L + 1], 16 & v) { for (v &= 15, T = D[L + 2] + (S & Z[v]), S >>= v, E -= v; E < 15; ) W--, S |= (255 & h.read_byte(O++)) << E, E += 8; for (A = S & K, D = x, U = k, L = 3 * (U + A), v = D[L]; ; ) { if (S >>= D[L + 1], E -= D[L + 1], 16 & v) { for (v &= 15; E < v; ) W--, S |= (255 & h.read_byte(O++)) << E, E += 8; if (R = D[L + 2] + (S & Z[v]), S >>= v, E -= v, C -= T, F >= R) M = F - R, F - M > 0 && 2 > F - M ? (m.win[F++] = m.win[M++], m.win[F++] = m.win[M++], T -= 2) : (m.win.set(m.win.subarray(M, M + 2), F), F += 2, M += 2, T -= 2); else { M = F - R; do M += m.end; while (M < 0); if (v = m.end - M, T > v) { if (T -= v, F - M > 0 && v > F - M) do m.win[F++] = m.win[M++]; while (--v != 0); else m.win.set(m.win.subarray(M, M + v), F), F += v, M += v, v = 0; M = 0; } } if (F - M > 0 && T > F - M) do m.win[F++] = m.win[M++]; while (--T != 0); else m.win.set(m.win.subarray(M, M + T), F), F += T, M += T, T = 0; break; } if (64 & v) return h.msg = "invalid distance code", T = h.avail_in - W, T = E >> 3 < T ? E >> 3 : T, W += T, O -= T, E -= T << 3, m.bitb = S, m.bitk = E, h.avail_in = W, h.total_in += O - h.next_in_index, h.next_in_index = O, m.write = F, -3; A += D[L + 2], A += S & Z[v], L = 3 * (U + A), v = D[L]; } break; } if (64 & v) return 32 & v ? (T = h.avail_in - W, T = E >> 3 < T ? E >> 3 : T, W += T, O -= T, E -= T << 3, m.bitb = S, m.bitk = E, h.avail_in = W, h.total_in += O - h.next_in_index, h.next_in_index = O, m.write = F, 1) : (h.msg = "invalid literal/length code", T = h.avail_in - W, T = E >> 3 < T ? E >> 3 : T, W += T, O -= T, E -= T << 3, m.bitb = S, m.bitk = E, h.avail_in = W, h.total_in += O - h.next_in_index, h.next_in_index = O, m.write = F, -3); if (A += D[L + 2], A += S & Z[v], L = 3 * (U + A), (v = D[L]) === 0) { S >>= D[L + 1], E -= D[L + 1], m.win[F++] = D[L + 2], C--; break; } } else S >>= D[L + 1], E -= D[L + 1], m.win[F++] = D[L + 2], C--; } while (C >= 258 && W >= 10); return T = h.avail_in - W, T = E >> 3 < T ? E >> 3 : T, W += T, O -= T, E -= T << 3, m.bitb = S, m.bitk = E, h.avail_in = W, h.total_in += O - h.next_in_index, h.next_in_index = O, m.write = F, 0; } n.init = function(i, o, u, b, x, k) { t = 0, g = i, y = o, r = u, z = b, a = x, c = k, e = null; }, n.proc = function(i, o, u) { let b, x, k, m, h, A, D, U = 0, v = 0, S = 0; for (S = o.next_in_index, m = o.avail_in, U = i.bitb, v = i.bitk, h = i.write, A = h < i.read ? i.read - h - 1 : i.end - h; ; ) switch (t) { case 0: if (A >= 258 && m >= 10 && (i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, u = p(g, y, r, z, a, c, i, o), S = o.next_in_index, m = o.avail_in, U = i.bitb, v = i.bitk, h = i.write, A = h < i.read ? i.read - h - 1 : i.end - h, u != 0)) { t = u == 1 ? 7 : 9; break; } f = g, e = r, s = z, t = 1; case 1: for (b = f; v < b; ) { if (m === 0) return i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); u = 0, m--, U |= (255 & o.read_byte(S++)) << v, v += 8; } if (x = 3 * (s + (U & Z[b])), U >>>= e[x + 1], v -= e[x + 1], k = e[x], k === 0) { d = e[x + 2], t = 6; break; } if (16 & k) { _ = 15 & k, l = e[x + 2], t = 2; break; } if (!(64 & k)) { f = k, s = x / 3 + e[x + 2]; break; } if (32 & k) { t = 7; break; } return t = 9, o.msg = "invalid literal/length code", u = -3, i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); case 2: for (b = _; v < b; ) { if (m === 0) return i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); u = 0, m--, U |= (255 & o.read_byte(S++)) << v, v += 8; } l += U & Z[b], U >>= b, v -= b, f = y, e = a, s = c, t = 3; case 3: for (b = f; v < b; ) { if (m === 0) return i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); u = 0, m--, U |= (255 & o.read_byte(S++)) << v, v += 8; } if (x = 3 * (s + (U & Z[b])), U >>= e[x + 1], v -= e[x + 1], k = e[x], 16 & k) { _ = 15 & k, w = e[x + 2], t = 4; break; } if (!(64 & k)) { f = k, s = x / 3 + e[x + 2]; break; } return t = 9, o.msg = "invalid distance code", u = -3, i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); case 4: for (b = _; v < b; ) { if (m === 0) return i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); u = 0, m--, U |= (255 & o.read_byte(S++)) << v, v += 8; } w += U & Z[b], U >>= b, v -= b, t = 5; case 5: for (D = h - w; D < 0; ) D += i.end; for (; l !== 0; ) { if (A === 0 && (h == i.end && i.read !== 0 && (h = 0, A = h < i.read ? i.read - h - 1 : i.end - h), A === 0 && (i.write = h, u = i.inflate_flush(o, u), h = i.write, A = h < i.read ? i.read - h - 1 : i.end - h, h == i.end && i.read !== 0 && (h = 0, A = h < i.read ? i.read - h - 1 : i.end - h), A === 0))) return i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); i.win[h++] = i.win[D++], A--, D == i.end && (D = 0), l--; } t = 0; break; case 6: if (A === 0 && (h == i.end && i.read !== 0 && (h = 0, A = h < i.read ? i.read - h - 1 : i.end - h), A === 0 && (i.write = h, u = i.inflate_flush(o, u), h = i.write, A = h < i.read ? i.read - h - 1 : i.end - h, h == i.end && i.read !== 0 && (h = 0, A = h < i.read ? i.read - h - 1 : i.end - h), A === 0))) return i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); u = 0, i.win[h++] = d, A--, t = 0; break; case 7: if (v > 7 && (v -= 8, m++, S--), i.write = h, u = i.inflate_flush(o, u), h = i.write, A = h < i.read ? i.read - h - 1 : i.end - h, i.read != i.write) return i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); t = 8; case 8: return u = 1, i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); case 9: return u = -3, i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); default: return u = -2, i.bitb = U, i.bitk = v, o.avail_in = m, o.total_in += S - o.next_in_index, o.next_in_index = S, i.write = h, i.inflate_flush(o, u); } }, n.free = function() { }; } const Ge = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; function on(n, t) { const e = this; let r, a = 0, l = 0, s = 0, f = 0; const d = [0], _ = [0], w = new sn(); let g = 0, y = new Int32Array(4320); const z = new We(); e.bitk = 0, e.bitb = 0, e.win = new Uint8Array(t), e.end = t, e.read = 0, e.write = 0, e.reset = function(c, p) { p && (p[0] = 0), a == 6 && w.free(c), a = 0, e.bitk = 0, e.bitb = 0, e.read = e.write = 0; }, e.reset(n, null), e.inflate_flush = function(c, p) { let i, o, u; return o = c.next_out_index, u = e.read, i = (u <= e.write ? e.write : e.end) - u, i > c.avail_out && (i = c.avail_out), i !== 0 && p == -5 && (p = 0), c.avail_out -= i, c.total_out += i, c.next_out.set(e.win.subarray(u, u + i), o), o += i, u += i, u == e.end && (u = 0, e.write == e.end && (e.write = 0), i = e.write - u, i > c.avail_out && (i = c.avail_out), i !== 0 && p == -5 && (p = 0), c.avail_out -= i, c.total_out += i, c.next_out.set(e.win.subarray(u, u + i), o), o += i, u += i), c.next_out_index = o, e.read = u, p; }, e.proc = function(c, p) { let i, o, u, b, x, k, m, h; for (b = c.next_in_index, x = c.avail_in, o = e.bitb, u = e.bitk, k = e.write, m = k < e.read ? e.read - k - 1 : e.end - k; ; ) { let A, D, U, v, S, E, O, W; switch (a) { case 0: for (; u < 3; ) { if (x === 0) return e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); p = 0, x--, o |= (255 & c.read_byte(b++)) << u, u += 8; } switch (i = 7 & o, g = 1 & i, i >>> 1) { case 0: o >>>= 3, u -= 3, i = 7 & u, o >>>= i, u -= i, a = 1; break; case 1: A = [], D = [], U = [[]], v = [[]], We.inflate_trees_fixed(A, D, U, v), w.init(A[0], D[0], U[0], 0, v[0], 0), o >>>= 3, u -= 3, a = 6; break; case 2: o >>>= 3, u -= 3, a = 3; break; case 3: return o >>>= 3, u -= 3, a = 9, c.msg = "invalid block type", p = -3, e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); } break; case 1: for (; u < 32; ) { if (x === 0) return e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); p = 0, x--, o |= (255 & c.read_byte(b++)) << u, u += 8; } if ((~o >>> 16 & 65535) != (65535 & o)) return a = 9, c.msg = "invalid stored block lengths", p = -3, e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); l = 65535 & o, o = u = 0, a = l !== 0 ? 2 : g !== 0 ? 7 : 0; break; case 2: if (x === 0 || m === 0 && (k == e.end && e.read !== 0 && (k = 0, m = k < e.read ? e.read - k - 1 : e.end - k), m === 0 && (e.write = k, p = e.inflate_flush(c, p), k = e.write, m = k < e.read ? e.read - k - 1 : e.end - k, k == e.end && e.read !== 0 && (k = 0, m = k < e.read ? e.read - k - 1 : e.end - k), m === 0))) return e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); if (p = 0, i = l, i > x && (i = x), i > m && (i = m), e.win.set(c.read_buf(b, i), k), b += i, x -= i, k += i, m -= i, (l -= i) != 0) break; a = g !== 0 ? 7 : 0; break; case 3: for (; u < 14; ) { if (x === 0) return e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); p = 0, x--, o |= (255 & c.read_byte(b++)) << u, u += 8; } if (s = i = 16383 & o, (31 & i) > 29 || (i >> 5 & 31) > 29) return a = 9, c.msg = "too many length or distance symbols", p = -3, e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); if (i = 258 + (31 & i) + (i >> 5 & 31), !r || r.length < i) r = []; else for (h = 0; h < i; h++) r[h] = 0; o >>>= 14, u -= 14, f = 0, a = 4; case 4: for (; f < 4 + (s >>> 10); ) { for (; u < 3; ) { if (x === 0) return e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); p = 0, x--, o |= (255 & c.read_byte(b++)) << u, u += 8; } r[Ge[f++]] = 7 & o, o >>>= 3, u -= 3; } for (; f < 19; ) r[Ge[f++]] = 0; if (d[0] = 7, i = z.inflate_trees_bits(r, d, _, y, c), i != 0) return (p = i) == -3 && (r = null, a = 9), e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); f = 0, a = 5; case 5: for (; i = s, !(f >= 258 + (31 & i) + (i >> 5 & 31)); ) { let F, C; for (i = d[0]; u < i; ) { if (x === 0) return e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); p = 0, x--, o |= (255 & c.read_byte(b++)) << u, u += 8; } if (i = y[3 * (_[0] + (o & Z[i])) + 1], C = y[3 * (_[0] + (o & Z[i])) + 2], C < 16) o >>>= i, u -= i, r[f++] = C; else { for (h = C == 18 ? 7 : C - 14, F = C == 18 ? 11 : 3; u < i + h; ) { if (x === 0) return e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); p = 0, x--, o |= (255 & c.read_byte(b++)) << u, u += 8; } if (o >>>= i, u -= i, F += o & Z[h], o >>>= h, u -= h, h = f, i = s, h + F > 258 + (31 & i) + (i >> 5 & 31) || C == 16 && h < 1) return r = null, a = 9, c.msg = "invalid bit length repeat", p = -3, e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); C = C == 16 ? r[h - 1] : 0; do r[h++] = C; while (--F != 0); f = h; } } if (_[0] = -1, S = [], E = [], O = [], W = [], S[0] = 9, E[0] = 6, i = s, i = z.inflate_trees_dynamic(257 + (31 & i), 1 + (i >> 5 & 31), r, S, E, O, W, y, c), i != 0) return i == -3 && (r = null, a = 9), p = i, e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); w.init(S[0], E[0], y, O[0], y, W[0]), a = 6; case 6: if (e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, (p = w.proc(e, c, p)) != 1) return e.inflate_flush(c, p); if (p = 0, w.free(c), b = c.next_in_index, x = c.avail_in, o = e.bitb, u = e.bitk, k = e.write, m = k < e.read ? e.read - k - 1 : e.end - k, g === 0) { a = 0; break; } a = 7; case 7: if (e.write = k, p = e.inflate_flush(c, p), k = e.write, m = k < e.read ? e.read - k - 1 : e.end - k, e.read != e.write) return e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); a = 8; case 8: return p = 1, e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); case 9: return p = -3, e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); default: return p = -2, e.bitb = o, e.bitk = u, c.avail_in = x, c.total_in += b - c.next_in_index, c.next_in_index = b, e.write = k, e.inflate_flush(c, p); } } }, e.free = function(c) { e.reset(c, null), e.win = null, y = null; }, e.set_dictionary = function(c, p, i) { e.win.set(c.subarray(p, p + i), 0), e.read = e.write = i; }, e.sync_point = function() { return a == 1 ? 1 : 0; }; } const X = 13, ln = [0, 0, 255, 255]; function cn() { const n = this; function t(e) { return e && e.istate ? (e.total_in = e.total_out = 0, e.msg = null, e.istate.mode = 7, e.istate.blocks.reset(e, null), 0) : -2; } n.mode = 0, n.method = 0, n.was = [0], n.need = 0, n.marker = 0, n.wbits = 0, n.inflateEnd = function(e) { return n.blocks && n.blocks.free(e), n.blocks = null, 0; }, n.inflateInit = function(e, r) { return e.msg = null, n.blocks = null, r < 8 || r > 15 ? (n.inflateEnd(e), -2) : (n.wbits = r, e.istate.blocks = new on(e, 1 << r), t(e), 0); }, n.inflate = function(e, r) { let a, l; if (!e || !e.istate || !e.next_in) return -2; const s = e.istate; for (r = r == 4 ? -5 : 0, a = -5; ; ) switch (s.mode) { case 0: if (e.avail_in === 0) return a; if (a = r, e.avail_in--, e.total_in++, (15 & (s.method = e.read_byte(e.next_in_index++))) != 8) { s.mode = X, e.msg = "unknown compression method", s.marker = 5; break; } if (8 + (s.method >> 4) > s.wbits) { s.mode = X, e.msg = "invalid win size", s.marker = 5; break; } s.mode = 1; case 1: if (e.avail_in === 0) return a; if (a = r, e.avail_in--, e.total_in++, l = 255 & e.read_byte(e.next_in_index++), ((s.method << 8) + l) % 31 != 0) { s.mode = X, e.msg = "incorrect header check", s.marker = 5; break; } if (!(32 & l)) { s.mode = 7; break; } s.mode = 2; case 2: if (e.avail_in === 0) return a; a = r, e.avail_in--, e.total_in++, s.need = (255 & e.read_byte(e.next_in_index++)) << 24 & 4278190080, s.mode = 3; case 3: if (e.avail_in === 0) return a; a = r, e.avail_in--, e.total_in++, s.need += (255 & e.read_byte(e.next_in_index++)) << 16 & 16711680, s.mode = 4; case 4: if (e.avail_in === 0) return a; a = r, e.avail_in--, e.total_in++, s.need += (255 & e.read_byte(e.next_in_index++)) << 8 & 65280, s.mode = 5; case 5: return e.avail_in === 0 ? a : (a = r, e.avail_in--, e.total_in++, s.need += 255 & e.read_byte(e.next_in_index++), s.mode = 6, 2); case 6: return s.mode = X, e.msg = "need dictionary", s.marker = 0, -2; case 7: if (a = s.blocks.proc(e, a), a == -3) { s.mode = X, s.marker = 0; break; } if (a == 0 && (a = r), a != 1) return a; a = r, s.blocks.reset(e, s.was), s.mode = 12; case 12: return e.avail_in = 0, 1; case X: return -3; default: return -2; } }, n.inflateSetDictionary = function(e, r, a) { let l = 0, s = a; if (!e || !e.istate || e.istate.mode != 6) return -2; const f = e.istate; return s >= 1 << f.wbits && (s = (1 << f.wbits) - 1, l = a - s), f.blocks.set_dictionary(r, l, s), f.mode = 7, 0; }, n.inflateSync = function(e) { let r, a, l, s, f; if (!e || !e.istate) return -2; const d = e.istate; if (d.mode != X && (d.mode = X, d.marker = 0), (r = e.avail_in) === 0) return -5; for (a = e.next_in_index, l = d.marker; r !== 0 && l < 4; ) e.read_byte(a) == ln[l] ? l++ : l = e.read_byte(a) !== 0 ? 0 : 4 - l, a++, r--; return e.total_in += a - e.next_in_index, e.next_in_index = a, e.avail_in = r, d.marker = l, l != 4 ? -3 : (s = e.total_in, f = e.total_out, t(e), e.total_in = s, e.total_out = f, d.mode = 7, 0); }, n.inflateSyncPoint = function(e) { return e && e.istate && e.istate.blocks ? e.istate.blocks.sync_point() : -2; }; } function pt() { } pt.prototype = { inflateInit(n) { const t = this; return t.istate = new cn(), n || (n = 15), t.istate.inflateInit(t, n); }, inflate(n) { const t = this; return t.istate ? t.istate.inflate(t, n) : -2; }, inflateEnd() { const n = this; if (!n.istate) return -2; const t = n.istate.inflateEnd(n); return n.istate = null, t; }, inflateSync() { const n = this; return n.istate ? n.istate.inflateSync(n) : -2; }, inflateSetDictionary(n, t) { const e = this; return e.istate ? e.istate.inflateSetDictionary(e, n, t) : -2; }, read_byte(n) { return this.next_in[n]; }, read_buf(n, t) { return this.next_in.subarray(n, n + t); } }; const ie = 4294967295, re = 65535, Je = 33639248, Qe = 101075792, ae = 22, H = void 0, te = "undefined", _e = "function"; class Xe { constructor(t) { return class extends TransformStream { constructor(e, r) { const a = new t(r); super({ transform(l, s) { s.enqueue(a.append(l)); }, flush(l) { const s = a.flush(); s && l.enqueue(s); } }); } }; } } let mt = 2; try { typeof navigator != te && navigator.hardwareConcurrency && (mt = navigator.hardwareConcurrency); } catch { } const un = { chunkSize: 524288, maxWorkers: mt, terminateWorkerTimeout: 5e3, useWebWorkers: !0, useCompressionStream: !0, workerScripts: H, CompressionStreamNative: typeof CompressionStream != te && CompressionStream, DecompressionStreamNative: typeof DecompressionStream != te && DecompressionStream }, ee = Object.assign({}, un); function dn(n) { const { baseURL: t, chunkSize: e, maxWorkers: r, terminateWorkerTimeout: a, useCompressionStream: l, useWebWorkers: s, Deflate: f, Inflate: d, CompressionStream: _, DecompressionStream: w, workerScripts: g } = n; if (Y("baseURL", t), Y("chunkSize", e), Y("maxWorkers", r), Y("terminateWorkerTimeout", a), Y("useCompressionStream", l), Y("useWebWorkers", s), f && (ee.CompressionStream = new Xe(f)), d && (ee.DecompressionStream = new Xe(d)), Y("CompressionStream", _), Y("DecompressionStream", w), g !== H) { const { deflate: y, inflate: z } = g; if ((y || z) && (ee.workerScripts || (ee.workerScripts = {})), y) { if (!Array.isArray(y)) throw new Error("workerScripts.deflate must be an array"); ee.workerScripts.deflate = y; } if (z) { if (!Array.isArray(z)) throw new Error("workerScripts.inflate must be an array"); ee.workerScripts.inflate = z; } } } function Y(n, t) { t !== H && (ee[n] = t); } const xt = []; for (let n = 0; n < 256; n++) { let t = n; for (let e = 0; e < 8; e++) 1 & t ? t = t >>> 1 ^ 3988292384 : t >>>= 1; xt[n] = t; } class ye { constructor(t) { this.crc = t || -1; } append(t) { let e = 0 | this.crc; for (let r = 0, a = 0 | t.length; r < a; r++) e = e >>> 8 ^ xt[255 & (e ^ t[r])]; this.crc = e; } get() { return ~this.crc; } } class yt extends TransformStream { constructor() { let t; const e = new ye(); super({ transform(r, a) { e.append(r), a.enqueue(r); }, flush() { const r = new Uint8Array(4); new DataView(r.buffer).setUint32(0, e.get()), t.value = r; } }), t = this; } } const q = { concat(n, t) { if (n.length === 0 || t.length === 0) return n.concat(t); const e = n[n.length - 1], r = q.getPartial(e); return r === 32 ? n.concat(t) : q._shiftRight(t, r, 0 | e, n.slice(0, n.length - 1)); }, bitLength(n) { const t = n.length; if (t === 0) return 0; const e = n[t - 1]; return 32 * (t - 1) + q.getPartial(e); }, clamp(n, t) { if (32 * n.length < t) return n; const e = (n = n.slice(0, Math.ceil(t / 32))).length; return t &= 31, e > 0 && t && (n[e - 1] = q.partial(t, n[e - 1] & 2147483648 >> t - 1, 1)), n; }, partial: (n, t, e) => n === 32 ? t : (e ? 0 | t : t << 32 - n) + 1099511627776 * n, getPartial: (n) => Math.round(n / 1099511627776) || 32, _shiftRight(n, t, e, r) { for (r === void 0 && (r = []); t >= 32; t -= 32) r.push(e), e = 0; if (t === 0) return r.concat(n); for (let s = 0; s < n.length; s++) r.push(e | n[s] >>> t), e = n[s] << 32 - t; const a = n.length ? n[n.length - 1] : 0, l = q.getPartial(a); return r.push(q.partial(t + l & 31, t + l > 32 ? e : r.pop(), 1)), r; } }, ge = { bytes: { fromBits(n) { const t = q.bitLength(n) / 8, e = new Uint8Array(t); let r; for (let a = 0; a < t; a++) 3 & a || (r = n[a / 4]), e[a] = r >>> 24, r <<= 8; return e; }, toBits(n) { const t = []; let e, r = 0; for (e = 0; e < n.length; e++) r = r << 8 | n[e], 3 & ~e || (t.push(r), r = 0); return 3 & e && t.push(q.partial(8 * (3 & e), r)), t; } } }, fn = { sha1: class { constructor(n) { const t = this; t.blockSize = 512, t._init = [1732584193, 4023233417, 2562383102, 271733878, 3285377520], t._key = [1518500249, 1859775393, 2400959708, 3395469782], n ? (t._h = n._h.slice(0), t._buffer = n._buffer.slice(0), t._length = n._length) : t.reset(); } reset() { const n = this; return n._h = n._init.slice(0), n._buffer = [], n._length = 0, n; } update(n) { const t = this; typeof n == "string" && (n = ge.utf8String.toBits(n)); const e = t._buffer = q.concat(t._buffer, n), r = t._length, a = t._length = r + q.bitLength(n); if (a > 9007199254740991) throw new Error("Cannot hash more than 2^53 - 1 bits"); const l = new Uint32Array(e); let s = 0; for (let f = t.blockSize + r - (t.blockSize + r & t.blockSize - 1); f <= a; f += t.blockSize) t._block(l.subarray(16 * s, 16 * (s + 1))), s += 1; return e.splice(0, 16 * s), t; } finalize() { const n = this; let t = n._buffer; const e = n._h; t = q.concat(t, [q.partial(1, 1)]); for (let r = t.length + 2; 15 & r; r++) t.push(0); for (t.push(Math.floor(n._length / 4294967296)), t.push(0 | n._length); t.length; ) n._block(t.splice(0, 16)); return n.reset(), e; } _f(n, t, e, r) { return n <= 19 ? t & e | ~t & r : n <= 39 ? t ^ e ^ r : n <= 59 ? t & e | t & r | e & r : n <= 79 ? t ^ e ^ r : void 0; } _S(n, t) { return t << n | t >>> 32 - n; } _block(n) { const t = this, e = t._h, r = Array(80); for (let _ = 0; _ < 16; _++) r[_] = n[_]; let a = e[0], l = e[1], s = e[2], f = e[3], d = e[4]; for (let _ = 0; _ <= 79; _++) { _ >= 16 && (r[_] = t._S(1, r[_ - 3] ^ r[_ - 8] ^ r[_ - 14] ^ r[_ - 16])); const w = t._S(5, a) + t._f(_, l, s, f) + d + r[_] + t._key[Math.floor(_ / 20)] | 0; d = f, f = s, s = t._S(30, l), l = a, a = w; } e[0] = e[0] + a | 0, e[1] = e[1] + l | 0, e[2] = e[2] + s | 0, e[3] = e[3] + f | 0, e[4] = e[4] + d | 0; } } }, hn = { aes: class { constructor(n) { const t = this; t._tables = [[[], [], [], [], []], [[], [], [], [], []]], t._tables[0][0][0] || t._precompute(); const e = t._tables[0][4], r = t._tables[1], a = n.length; let l, s, f, d = 1; if (a !== 4 && a !== 6 && a !== 8) throw new Error("invalid aes key size"); for (t._key = [s = n.slice(0), f = []], l = a; l < 4 * a + 28; l++) { let _ = s[l - 1]; (l % a == 0 || a === 8 && l % a == 4) && (_ = e[_ >>> 24] << 24 ^ e[_ >> 16 & 255] << 16 ^ e[_ >> 8 & 255] << 8 ^ e[255 & _], l % a == 0 && (_ = _ << 8 ^ _ >>> 24 ^ d << 24, d = d << 1 ^ 283 * (d >> 7))), s[l] = s[l - a] ^ _; } for (let _ = 0; l; _++, l--) { const w = s[3 & _ ? l : l - 4]; f[_] = l <= 4 || _ < 4 ? w : r[0][e[w >>> 24]] ^ r[1][e[w >> 16 & 255]] ^ r[2][e[w >> 8 & 255]] ^ r[3][e[255 & w]]; } } encrypt(n) { return this._crypt(n, 0); } decrypt(n) { return this._crypt(n, 1); } _precompute() { const n = this._tables[0], t = this._tables[1], e = n[4], r = t[4], a = [], l = []; let s, f, d, _; for (let w = 0; w < 256; w++) l[(a[w] = w << 1 ^ 283 * (w >> 7)) ^ w] = w; for (let w = s = 0; !e[w]; w ^= f || 1, s = l[s] || 1) { let g = s ^ s << 1 ^ s << 2 ^ s << 3 ^ s << 4; g = g >> 8 ^ 255 & g ^ 99, e[w] = g, r[g] = w, _ = a[d = a[f = a[w]]]; let y = 16843009 * _ ^ 65537 * d ^ 257 * f ^ 16843008 * w, z = 257 * a[g] ^ 16843008 * g; for (let c = 0; c < 4; c++) n[c][w] = z = z << 24 ^ z >>> 8, t[c][g] = y = y << 24 ^ y >>> 8; } for (let w = 0; w < 5; w++) n[w] = n[w].slice(0), t[w] = t[w].slice(0); } _crypt(n, t) { if (n.length !== 4) throw new Error("invalid aes block size"); const e = this._key[t], r = e.length / 4 - 2, a = [0, 0, 0, 0], l = this._tables[t], s = l[0], f = l[1], d = l[2], _ = l[3], w = l[4]; let g, y, z, c = n[0] ^ e[0], p = n[t ? 3 : 1] ^ e[1], i = n[2] ^ e[2], o = n[t ? 1 : 3] ^ e[3], u = 4; for (let b = 0; b < r; b++) g = s[c >>> 24] ^ f[p >> 16 & 255] ^ d[i >> 8 & 255] ^ _[255 & o] ^ e[u], y = s[p >>> 24] ^ f[i >> 16 & 255] ^ d[o >> 8 & 255] ^ _[255 & c] ^ e[u + 1], z = s[i >>> 24] ^ f[o >> 16 & 255] ^ d[c >> 8 & 255] ^ _[255 & p] ^ e[u + 2], o = s[o >>> 24] ^ f[c >> 16 & 255] ^ d[p >> 8 & 255] ^ _[255 & i] ^ e[u + 3], u += 4, c = g, p = y, i = z; for (let b = 0; b < 4; b++) a[t ? 3 & -b : b] = w[c >>> 24] << 24 ^ w[p >> 16 & 255] << 16 ^ w[i >> 8 & 255] << 8 ^ w[255 & o] ^ e[u++], g = c, c = p, p = i, i = o, o = g; return a; } } }, _n = { getRandomValues(n) { const t = new Uint32Array(n.buffer), e = (r) => { let a = 987654321; const l = 4294967295; return function() { return a = 36969 * (65535 & a) + (a >> 16) & l, (((a << 16) + (r = 18e3 * (65535 & r) + (r >> 16) & l) & l) / 4294967296 + 0.5) * (Math.random() > 0.5 ? 1 : -1); }; }; for (let r, a = 0; a < n.length; a += 4) { const l = e(4294967296 * (r || Math.random())); r = 987654071 * l(), t[a / 4] = 4294967296 * l() | 0; } return n; } }, wn = { ctrGladman: class { constructor(n, t) { this._prf = n, this._initIv = t, this._iv = t; } reset() { this._iv = this._initIv; } update(n) { return this.calculate(this._prf, n, this._iv); } incWord(n) { if (255 & ~(n >> 24)) n += 1 << 24; else { let t = n >> 16 & 255, e = n >> 8 & 255, r = 255 & n; t === 255 ? (t = 0, e === 255 ? (e = 0, r === 255 ? r = 0 : ++r) : ++e) : ++t, n = 0, n += t << 16, n += e << 8, n += r; } return n; } incCounter(n) { (n[0] = this.incWord(n[0])) === 0 && (n[1] = this.incWord(n[1])); } calculate(n, t, e) { let r; if (!(r = t.length)) return []; const a = q.bitLength(t); for (let l = 0; l < r; l += 4) { this.incCounter(e); const s = n.encrypt(e); t[l] ^= s[0], t[l + 1] ^= s[1], t[l + 2] ^= s[2], t[l + 3] ^= s[3]; } return q.clamp(t, a); } } }, se = { importKey: (n) => new se.hmacSha1(ge.bytes.toBits(n)), pbkdf2(n, t, e, r) { if (e = e || 1e4, r < 0 || e < 0) throw new Error("invalid params to pbkdf2"); const a = 1 + (r >> 5) << 2; let l, s, f, d, _; const w = new ArrayBuffer(a), g = new DataView(w); let y = 0; const z = q; for (t = ge.bytes.toBits(t), _ = 1; y < (a || 1); _++) { for (l = s = n.encrypt(z.concat(t, [_])), f = 1; f < e; f++) for (s = n.encrypt(s), d = 0; d < s.length; d++) l[d] ^= s[d]; for (f = 0; y < (a || 1) && f < l.length; f++) g.setInt32(y, l[f]), y += 4; } return w.slice(0, r / 8); }, hmacSha1: class { constructor(n) { const t = this, e = t._hash = fn.sha1, r = [[], []]; t._baseHash = [new e(), new e()]; const a = t._baseHash[0].blockSize / 32; n.length > a && (n = new e().update(n).finalize()); for (let l = 0; l < a; l++) r[0][l] = 909522486 ^ n[l], r[1][l] = 1549556828 ^ n[l]; t._baseHash[0].update(r[0]), t._baseHash[1].update(r[1]), t._resultHash = new e(t._baseHash[0]); } reset() { const n = this; n._resultHash = new n._hash(n._baseHash[0]), n._updated = !1; } update(n) { this._updated = !0, this._resultHash.update(n); } digest() { const n = this, t = n._resultHash.finalize(), e = new n._hash(n._baseHash[1]).update(t).finalize(); return n.reset(), e; } encrypt(n) { if (this._updated) throw new Error("encrypt on already updated hmac called!"); return this.update(n), this.digest(n); } } }, bn = typeof crypto != te && typeof crypto.getRandomValues == _e, gt = "Invalid password", kt = "Invalid signature", Pe = "zipjs-abort-check-password"; function vt(n) { return bn ? crypto.getRandomValues(n) : _n.getRandomValues(n); } const oe = 16, St = { name: "PBKDF2" }, pn = Object.assign({ hash: { name: "HMAC" } }, St), Ue = Object.assign({ iterations: 1e3, hash: { name: "SHA-1" } }, St), mn = ["deriveBits"], ue = [8, 12, 16], ce = [16, 24, 32], $ = 10, xn = [0, 0, 0, 0], Se = typeof crypto != te, de = Se && crypto.subtle, zt = Se && typeof de != te, J = ge.bytes, yn = hn.aes, gn = wn.ctrGladman, kn = se.hmacSha1; let Ye = Se && zt && typeof de.importKey == _e, $e = Se && zt && typeof de.deriveBits == _e; class vn extends TransformStream { constructor({ password: t, rawPassword: e, signed: r, encryptionStrength: a, checkPasswordOnly: l }) { super({ start() { Object.assign(this, { ready: new Promise((s) => this.resolveReady = s), password: Dt(t, e), signed: r, strength: a - 1, pending: new Uint8Array() }); }, async transform(s, f) { const d = this, { password: _, strength: w, resolveReady: g, ready: y } = d; _ ? (await async function(c, p, i, o) { const u = await Ut(c, p, i, G(o, 0, ue[p])), b = G(o, ue[p]); if (u[0] != b[0] || u[1] != b[1]) throw new Error(gt); }(d, w, _, G(s, 0, ue[w] + 2)), s = G(s, ue[w] + 2), l ? f.error(new Error(Pe)) : g()) : await y; const z = new Uint8Array(s.length - $ - (s.length - $) % oe); f.enqueue(At(d, s, z, 0, $, !0)); }, async flush(s) { const { signed: f, ctr: d, hmac: _, pending: w, ready: g } = this; if (_ && d) { await g; const y = G(w, 0, w.length - $), z = G(w, w.length - $); let c = new Uint8Array(); if (y.length) { const p = he(J, y); _.update(p); const i = d.update(p); c = fe(J, i); } if (f) { const p = G(fe(J, _.digest()), 0, $); for (let i = 0; i < $; i++) if (p[i] != z[i]) throw new Error(kt); } s.enqueue(c); } } }); } } class Sn extends TransformStream { constructor({ password: t, rawPassword: e, encryptionStrength: r }) { let a; super({ start() { Object.assign(this, { ready: new Promise((l) => this.resolveReady = l), password: Dt(t, e), strength: r - 1, pending: new Uint8Array() }); }, async transform(l, s) { const f = this, { password: d, strength: _, resolveReady: w, ready: g } = f; let y = new Uint8Array(); d ? (y = await async function(c, p, i) { const o = vt(new Uint8Array(ue[p])), u = await Ut(c, p, i, o); return Ce(o, u); }(f, _, d), w()) : await g; const z = new Uint8Array(y.length + l.length - l.length % oe); z.set(y, 0), s.enqueue(At(f, l, z, y.length, 0)); }, async flush(l) { const { ctr: s, hmac: f, pending: d, ready: _ } = this; if (f && s) { await _; let w = new Uint8Array(); if (d.length) { const g = s.update(he(J, d)); f.update(g), w = fe(J, g); } a.signature = fe(J, f.digest()).slice(0, $), l.enqueue(Ce(w, a.signature)); } } }), a = this; } } function At(n, t, e, r, a, l) { const { ctr: s, hmac: f, pending: d } = n, _ = t.length - a; let w; for (d.length && (t = Ce(d, t), e = function(g, y) { if (y && y > g.length) { const z = g; (g = new Uint8Array(y)).set(z, 0); } return g; }(e, _ - _ % oe)), w = 0; w <= _ - oe; w += oe) { const g = he(J, G(t, w, w + oe)); l && f.update(g); const y = s.update(g); l || f.update(y), e.set(fe(J, y), w + r); } return n.pending = G(t, w), e; } async function Ut(n, t, e, r) { n.password = null; const a = await async function(w, g, y, z, c) { if (!Ye) return se.importKey(g); try { return await de.importKey(w, g, y, z, c); } catch { return Ye = !1, se.importKey(g); } }("raw", e, pn, !1, mn), l = await async function(w, g, y) { if (!$e) return se.pbkdf2(g, w.salt, Ue.iterations, y); try { return await de.deriveBits(w, g, y); } catch { return $e = !1, se.pbkdf2(g, w.salt, Ue.iterations, y); } }(Object.assign({ salt: r }, Ue), a, 8 * (2 * ce[t] + 2)), s = new Uint8Array(l), f = he(J, G(s, 0, ce[t])), d = he(J, G(s, ce[t], 2 * ce[t])), _ = G(s, 2 * ce[t]); return Object.assign(n, { keys: { key: f, authentication: d, passwordVerification: _ }, ctr: new gn(new yn(f), Array.from(xn)), hmac: new kn(d) }), _; } function Dt(n, t) { return t === H ? function(e) { if (typeof TextEncoder == te) { e = unescape(encodeURIComponent(e)); const r = new Uint8Array(e.length); for (let a = 0; a < r.length; a++) r[a] = e.charCodeAt(a); return r; } return new TextEncoder().encode(e); }(n) : t; } function Ce(n, t) { let e = n; return n.length + t.length && (e = new Uint8Array(n.length + t.length), e.set(n, 0), e.set(t, n.length)), e; } function G(n, t, e) { return n.subarray(t, e); } function fe(n, t) { return n.fromBits(t); } function he(n, t) { return n.toBits(t); } const ke = 12; class zn extends TransformStream { constructor({ password: t, passwordVerification: e, checkPasswordOnly: r }) { super({ start() { Object.assign(this, { password: t, passwordVerification: e }), Et(this, t); }, transform(a, l) { const s = this; if (s.password) { const f = et(s, a.subarray(0, ke)); if (s.password = null, f[11] != s.passwordVerification) throw new Error(gt); a = a.subarray(ke); } r ? l.error(new Error(Pe)) : l.enqueue(et(s, a)); } }); } } class An extends TransformStream { constructor({ password: t, passwordVerification: e }) { super({ start() { Object.assign(this, { password: t, passwordVerification: e }), Et(this, t); }, transform(r, a) { const l = this; let s, f; if (l.password) { l.password = null; const d = vt(new Uint8Array(ke)); d[11] = l.passwordVerification, s = new Uint8Array(r.length + d.length), s.set(tt(l, d), 0), f = ke; } else s = new Uint8Array(r.length), f = 0; s.set(tt(l, r), f), a.enqueue(s); } }); } } function et(n, t) { const e = new Uint8Array(t.length); for (let r = 0; r < t.length; r++) e[r] = Tt(n) ^ t[r], Re(n, e[r]); return e; } function tt(n, t) { const e = new Uint8Array(t.length); for (let r = 0; r < t.length; r++) e[r] = Tt(n) ^ t[r], Re(n, t[r]); return e; } function Et(n, t) { const e = [305419896, 591751049, 878082192]; Object.assign(n, { keys: e, crcKey0: new ye(e[0]), crcKey2: new ye(e[2]) }); for (let r = 0; r < t.length; r++) Re(n, t.charCodeAt(r)); } function Re(n, t) { let [e, r, a] = n.keys; n.crcKey0.append([t]), e = ~n.crcKey0.get(), r = nt(Math.imul(nt(r + Ft