z-worker-pako.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502
  1. !function() {
  2. "use strict";
  3. const { Array: t, Object: e, Math: n, Error: s, Uint8Array: r, Uint16Array: a, Uint32Array: i, Int32Array: c, DataView: o, TextEncoder: l, crypto: h, postMessage: p } = globalThis, d = [];
  4. for (let t2 = 0; 256 > t2; t2++) {
  5. let e2 = t2;
  6. for (let t3 = 0; 8 > t3; t3++)
  7. 1 & e2 ? e2 = e2 >>> 1 ^ 3988292384 : e2 >>>= 1;
  8. d[t2] = e2;
  9. }
  10. class u {
  11. constructor(t2) {
  12. this.crc = t2 || -1;
  13. }
  14. append(t2) {
  15. let e2 = 0 | this.crc;
  16. for (let n2 = 0, s2 = 0 | t2.length; s2 > n2; n2++)
  17. e2 = e2 >>> 8 ^ d[255 & (e2 ^ t2[n2])];
  18. this.crc = e2;
  19. }
  20. get() {
  21. return ~this.crc;
  22. }
  23. }
  24. const f = { concat(t2, e2) {
  25. if (0 === t2.length || 0 === e2.length)
  26. return t2.concat(e2);
  27. const n2 = t2[t2.length - 1], s2 = f.getPartial(n2);
  28. return 32 === s2 ? t2.concat(e2) : f._shiftRight(e2, s2, 0 | n2, t2.slice(0, t2.length - 1));
  29. }, bitLength(t2) {
  30. const e2 = t2.length;
  31. if (0 === e2)
  32. return 0;
  33. const n2 = t2[e2 - 1];
  34. return 32 * (e2 - 1) + f.getPartial(n2);
  35. }, clamp(t2, e2) {
  36. if (32 * t2.length < e2)
  37. return t2;
  38. const s2 = (t2 = t2.slice(0, n.ceil(e2 / 32))).length;
  39. return e2 &= 31, s2 > 0 && e2 && (t2[s2 - 1] = f.partial(e2, t2[s2 - 1] & 2147483648 >> e2 - 1, 1)), t2;
  40. }, partial: (t2, e2, n2) => 32 === t2 ? e2 : (n2 ? 0 | e2 : e2 << 32 - t2) + 1099511627776 * t2, getPartial: (t2) => n.round(t2 / 1099511627776) || 32, _shiftRight(t2, e2, n2, s2) {
  41. for (void 0 === s2 && (s2 = []); e2 >= 32; e2 -= 32)
  42. s2.push(n2), n2 = 0;
  43. if (0 === e2)
  44. return s2.concat(t2);
  45. for (let r3 = 0; r3 < t2.length; r3++)
  46. s2.push(n2 | t2[r3] >>> e2), n2 = t2[r3] << 32 - e2;
  47. const r2 = t2.length ? t2[t2.length - 1] : 0, a2 = f.getPartial(r2);
  48. return s2.push(f.partial(e2 + a2 & 31, e2 + a2 > 32 ? n2 : s2.pop(), 1)), s2;
  49. } }, g = { bytes: { fromBits(t2) {
  50. const e2 = f.bitLength(t2) / 8, n2 = new r(e2);
  51. let s2;
  52. for (let r2 = 0; e2 > r2; r2++)
  53. 0 == (3 & r2) && (s2 = t2[r2 / 4]), n2[r2] = s2 >>> 24, s2 <<= 8;
  54. return n2;
  55. }, toBits(t2) {
  56. const e2 = [];
  57. let n2, s2 = 0;
  58. for (n2 = 0; n2 < t2.length; n2++)
  59. s2 = s2 << 8 | t2[n2], 3 == (3 & n2) && (e2.push(s2), s2 = 0);
  60. return 3 & n2 && e2.push(f.partial(8 * (3 & n2), s2)), e2;
  61. } } }, w = { sha1: function(t2) {
  62. t2 ? (this._h = t2._h.slice(0), this._buffer = t2._buffer.slice(0), this._length = t2._length) : this.reset();
  63. } };
  64. w.sha1.prototype = { blockSize: 512, reset: function() {
  65. const t2 = this;
  66. return t2._h = this._init.slice(0), t2._buffer = [], t2._length = 0, t2;
  67. }, update: function(t2) {
  68. const e2 = this;
  69. "string" == typeof t2 && (t2 = g.utf8String.toBits(t2));
  70. const n2 = e2._buffer = f.concat(e2._buffer, t2), r2 = e2._length, a2 = e2._length = r2 + f.bitLength(t2);
  71. if (a2 > 9007199254740991)
  72. throw new s("Cannot hash more than 2^53 - 1 bits");
  73. const c2 = new i(n2);
  74. let o2 = 0;
  75. for (let t3 = e2.blockSize + r2 - (e2.blockSize + r2 & e2.blockSize - 1); a2 >= t3; t3 += e2.blockSize)
  76. e2._block(c2.subarray(16 * o2, 16 * (o2 + 1))), o2 += 1;
  77. return n2.splice(0, 16 * o2), e2;
  78. }, finalize: function() {
  79. const t2 = this;
  80. let e2 = t2._buffer;
  81. const s2 = t2._h;
  82. e2 = f.concat(e2, [f.partial(1, 1)]);
  83. for (let t3 = e2.length + 2; 15 & t3; t3++)
  84. e2.push(0);
  85. for (e2.push(n.floor(t2._length / 4294967296)), e2.push(0 | t2._length); e2.length; )
  86. t2._block(e2.splice(0, 16));
  87. return t2.reset(), s2;
  88. }, _init: [1732584193, 4023233417, 2562383102, 271733878, 3285377520], _key: [1518500249, 1859775393, 2400959708, 3395469782], _f: (t2, e2, n2, s2) => t2 > 19 ? t2 > 39 ? t2 > 59 ? t2 > 79 ? void 0 : e2 ^ n2 ^ s2 : e2 & n2 | e2 & s2 | n2 & s2 : e2 ^ n2 ^ s2 : e2 & n2 | ~e2 & s2, _S: (t2, e2) => e2 << t2 | e2 >>> 32 - t2, _block: function(e2) {
  89. const s2 = this, r2 = s2._h, a2 = t(80);
  90. for (let t2 = 0; 16 > t2; t2++)
  91. a2[t2] = e2[t2];
  92. let i2 = r2[0], c2 = r2[1], o2 = r2[2], l2 = r2[3], h2 = r2[4];
  93. for (let t2 = 0; 79 >= t2; t2++) {
  94. 16 > t2 || (a2[t2] = s2._S(1, a2[t2 - 3] ^ a2[t2 - 8] ^ a2[t2 - 14] ^ a2[t2 - 16]));
  95. const e3 = s2._S(5, i2) + s2._f(t2, c2, o2, l2) + h2 + a2[t2] + s2._key[n.floor(t2 / 20)] | 0;
  96. h2 = l2, l2 = o2, o2 = s2._S(30, c2), c2 = i2, i2 = e3;
  97. }
  98. r2[0] = r2[0] + i2 | 0, r2[1] = r2[1] + c2 | 0, r2[2] = r2[2] + o2 | 0, r2[3] = r2[3] + l2 | 0, r2[4] = r2[4] + h2 | 0;
  99. } };
  100. const y = { getRandomValues(t2) {
  101. const e2 = new i(t2.buffer), s2 = (t3) => {
  102. let e3 = 987654321;
  103. const s3 = 4294967295;
  104. return () => (e3 = 36969 * (65535 & e3) + (e3 >> 16) & s3, (((e3 << 16) + (t3 = 18e3 * (65535 & t3) + (t3 >> 16) & s3) & s3) / 4294967296 + 0.5) * (n.random() > 0.5 ? 1 : -1));
  105. };
  106. for (let r2, a2 = 0; a2 < t2.length; a2 += 4) {
  107. const t3 = s2(4294967296 * (r2 || n.random()));
  108. r2 = 987654071 * t3(), e2[a2 / 4] = 4294967296 * t3() | 0;
  109. }
  110. return t2;
  111. } }, _ = { importKey: (t2) => new _.hmacSha1(g.bytes.toBits(t2)), pbkdf2(t2, e2, n2, r2) {
  112. if (n2 = n2 || 1e4, 0 > r2 || 0 > n2)
  113. throw new s("invalid params to pbkdf2");
  114. const a2 = 1 + (r2 >> 5) << 2;
  115. let i2, c2, l2, h2, p2;
  116. const d2 = new ArrayBuffer(a2), u2 = new o(d2);
  117. let w2 = 0;
  118. const y2 = f;
  119. for (e2 = g.bytes.toBits(e2), p2 = 1; (a2 || 1) > w2; p2++) {
  120. for (i2 = c2 = t2.encrypt(y2.concat(e2, [p2])), l2 = 1; n2 > l2; l2++)
  121. for (c2 = t2.encrypt(c2), h2 = 0; h2 < c2.length; h2++)
  122. i2[h2] ^= c2[h2];
  123. for (l2 = 0; (a2 || 1) > w2 && l2 < i2.length; l2++)
  124. u2.setInt32(w2, i2[l2]), w2 += 4;
  125. }
  126. return d2.slice(0, r2 / 8);
  127. }, hmacSha1: class {
  128. constructor(t2) {
  129. const e2 = this, n2 = e2._hash = w.sha1, s2 = [[], []], r2 = n2.prototype.blockSize / 32;
  130. e2._baseHash = [new n2(), new n2()], t2.length > r2 && (t2 = n2.hash(t2));
  131. for (let e3 = 0; r2 > e3; e3++)
  132. s2[0][e3] = 909522486 ^ t2[e3], s2[1][e3] = 1549556828 ^ t2[e3];
  133. e2._baseHash[0].update(s2[0]), e2._baseHash[1].update(s2[1]), e2._resultHash = new n2(e2._baseHash[0]);
  134. }
  135. reset() {
  136. const t2 = this;
  137. t2._resultHash = new t2._hash(t2._baseHash[0]), t2._updated = false;
  138. }
  139. update(t2) {
  140. this._updated = true, this._resultHash.update(t2);
  141. }
  142. digest() {
  143. const t2 = this, e2 = t2._resultHash.finalize(), n2 = new t2._hash(t2._baseHash[1]).update(e2).finalize();
  144. return t2.reset(), n2;
  145. }
  146. encrypt(t2) {
  147. if (this._updated)
  148. throw new s("encrypt on already updated hmac called!");
  149. return this.update(t2), this.digest(t2);
  150. }
  151. } }, m = "Invalid pasword", b = 16, k = { name: "PBKDF2" }, v = e.assign({ hash: { name: "HMAC" } }, k), z = e.assign({ iterations: 1e3, hash: { name: "SHA-1" } }, k), C = ["deriveBits"], S = [8, 12, 16], B = [16, 24, 32], I = 10, D = [0, 0, 0, 0], V = void 0 !== h, H = V && void 0 !== h.subtle, K = g.bytes, A = class {
  152. constructor(t2) {
  153. const e2 = this;
  154. e2._tables = [[[], [], [], [], []], [[], [], [], [], []]], e2._tables[0][0][0] || e2._precompute();
  155. const n2 = e2._tables[0][4], r2 = e2._tables[1], a2 = t2.length;
  156. let i2, c2, o2, l2 = 1;
  157. if (4 !== a2 && 6 !== a2 && 8 !== a2)
  158. throw new s("invalid aes key size");
  159. for (e2._key = [c2 = t2.slice(0), o2 = []], i2 = a2; 4 * a2 + 28 > i2; i2++) {
  160. let t3 = c2[i2 - 1];
  161. (i2 % a2 == 0 || 8 === a2 && i2 % a2 == 4) && (t3 = n2[t3 >>> 24] << 24 ^ n2[t3 >> 16 & 255] << 16 ^ n2[t3 >> 8 & 255] << 8 ^ n2[255 & t3], i2 % a2 == 0 && (t3 = t3 << 8 ^ t3 >>> 24 ^ l2 << 24, l2 = l2 << 1 ^ 283 * (l2 >> 7))), c2[i2] = c2[i2 - a2] ^ t3;
  162. }
  163. for (let t3 = 0; i2; t3++, i2--) {
  164. const e3 = c2[3 & t3 ? i2 : i2 - 4];
  165. o2[t3] = 4 >= i2 || 4 > t3 ? e3 : r2[0][n2[e3 >>> 24]] ^ r2[1][n2[e3 >> 16 & 255]] ^ r2[2][n2[e3 >> 8 & 255]] ^ r2[3][n2[255 & e3]];
  166. }
  167. }
  168. encrypt(t2) {
  169. return this._crypt(t2, 0);
  170. }
  171. decrypt(t2) {
  172. return this._crypt(t2, 1);
  173. }
  174. _precompute() {
  175. const t2 = this._tables[0], e2 = this._tables[1], n2 = t2[4], s2 = e2[4], r2 = [], a2 = [];
  176. let i2, c2, o2, l2;
  177. for (let t3 = 0; 256 > t3; t3++)
  178. a2[(r2[t3] = t3 << 1 ^ 283 * (t3 >> 7)) ^ t3] = t3;
  179. for (let h2 = i2 = 0; !n2[h2]; h2 ^= c2 || 1, i2 = a2[i2] || 1) {
  180. let a3 = i2 ^ i2 << 1 ^ i2 << 2 ^ i2 << 3 ^ i2 << 4;
  181. a3 = a3 >> 8 ^ 255 & a3 ^ 99, n2[h2] = a3, s2[a3] = h2, l2 = r2[o2 = r2[c2 = r2[h2]]];
  182. let p2 = 16843009 * l2 ^ 65537 * o2 ^ 257 * c2 ^ 16843008 * h2, d2 = 257 * r2[a3] ^ 16843008 * a3;
  183. for (let n3 = 0; 4 > n3; n3++)
  184. t2[n3][h2] = d2 = d2 << 24 ^ d2 >>> 8, e2[n3][a3] = p2 = p2 << 24 ^ p2 >>> 8;
  185. }
  186. for (let n3 = 0; 5 > n3; n3++)
  187. t2[n3] = t2[n3].slice(0), e2[n3] = e2[n3].slice(0);
  188. }
  189. _crypt(t2, e2) {
  190. if (4 !== t2.length)
  191. throw new s("invalid aes block size");
  192. const n2 = this._key[e2], r2 = n2.length / 4 - 2, a2 = [0, 0, 0, 0], i2 = this._tables[e2], c2 = i2[0], o2 = i2[1], l2 = i2[2], h2 = i2[3], p2 = i2[4];
  193. let d2, u2, f2, g2 = t2[0] ^ n2[0], w2 = t2[e2 ? 3 : 1] ^ n2[1], y2 = t2[2] ^ n2[2], _2 = t2[e2 ? 1 : 3] ^ n2[3], m2 = 4;
  194. for (let t3 = 0; r2 > t3; t3++)
  195. d2 = c2[g2 >>> 24] ^ o2[w2 >> 16 & 255] ^ l2[y2 >> 8 & 255] ^ h2[255 & _2] ^ n2[m2], u2 = c2[w2 >>> 24] ^ o2[y2 >> 16 & 255] ^ l2[_2 >> 8 & 255] ^ h2[255 & g2] ^ n2[m2 + 1], f2 = c2[y2 >>> 24] ^ o2[_2 >> 16 & 255] ^ l2[g2 >> 8 & 255] ^ h2[255 & w2] ^ n2[m2 + 2], _2 = c2[_2 >>> 24] ^ o2[g2 >> 16 & 255] ^ l2[w2 >> 8 & 255] ^ h2[255 & y2] ^ n2[m2 + 3], m2 += 4, g2 = d2, w2 = u2, y2 = f2;
  196. for (let t3 = 0; 4 > t3; t3++)
  197. a2[e2 ? 3 & -t3 : t3] = p2[g2 >>> 24] << 24 ^ p2[w2 >> 16 & 255] << 16 ^ p2[y2 >> 8 & 255] << 8 ^ p2[255 & _2] ^ n2[m2++], d2 = g2, g2 = w2, w2 = y2, y2 = _2, _2 = d2;
  198. return a2;
  199. }
  200. }, R = class {
  201. constructor(t2, e2) {
  202. this._prf = t2, this._initIv = e2, this._iv = e2;
  203. }
  204. reset() {
  205. this._iv = this._initIv;
  206. }
  207. update(t2) {
  208. return this.calculate(this._prf, t2, this._iv);
  209. }
  210. incWord(t2) {
  211. if (255 == (t2 >> 24 & 255)) {
  212. let e2 = t2 >> 16 & 255, n2 = t2 >> 8 & 255, s2 = 255 & t2;
  213. 255 === e2 ? (e2 = 0, 255 === n2 ? (n2 = 0, 255 === s2 ? s2 = 0 : ++s2) : ++n2) : ++e2, t2 = 0, t2 += e2 << 16, t2 += n2 << 8, t2 += s2;
  214. } else
  215. t2 += 1 << 24;
  216. return t2;
  217. }
  218. incCounter(t2) {
  219. 0 === (t2[0] = this.incWord(t2[0])) && (t2[1] = this.incWord(t2[1]));
  220. }
  221. calculate(t2, e2, n2) {
  222. let s2;
  223. if (!(s2 = e2.length))
  224. return [];
  225. const r2 = f.bitLength(e2);
  226. for (let r3 = 0; s2 > r3; r3 += 4) {
  227. this.incCounter(n2);
  228. const s3 = t2.encrypt(n2);
  229. e2[r3] ^= s3[0], e2[r3 + 1] ^= s3[1], e2[r3 + 2] ^= s3[2], e2[r3 + 3] ^= s3[3];
  230. }
  231. return f.clamp(e2, r2);
  232. }
  233. }, W = _.hmacSha1;
  234. class T {
  235. constructor(t2, n2, s2) {
  236. e.assign(this, { password: t2, signed: n2, strength: s2 - 1, pendingInput: new r(0) });
  237. }
  238. async append(e2) {
  239. const n2 = this;
  240. if (n2.password) {
  241. const r2 = E(e2, 0, S[n2.strength] + 2);
  242. await (async (t2, e3, n3) => {
  243. await L(t2, n3, E(e3, 0, S[t2.strength]));
  244. const r3 = E(e3, S[t2.strength]), a2 = t2.keys.passwordVerification;
  245. if (a2[0] != r3[0] || a2[1] != r3[1])
  246. throw new s(m);
  247. })(n2, r2, n2.password), n2.password = null, n2.aesCtrGladman = new R(new A(n2.keys.key), t.from(D)), n2.hmac = new W(n2.keys.authentication), e2 = E(e2, S[n2.strength] + 2);
  248. }
  249. return G(n2, e2, new r(e2.length - I - (e2.length - I) % b), 0, I, true);
  250. }
  251. flush() {
  252. const t2 = this, e2 = t2.pendingInput, n2 = E(e2, 0, e2.length - I), s2 = E(e2, e2.length - I);
  253. let a2 = new r(0);
  254. if (n2.length) {
  255. const e3 = K.toBits(n2);
  256. t2.hmac.update(e3);
  257. const s3 = t2.aesCtrGladman.update(e3);
  258. a2 = K.fromBits(s3);
  259. }
  260. let i2 = true;
  261. if (t2.signed) {
  262. const e3 = E(K.fromBits(t2.hmac.digest()), 0, I);
  263. for (let t3 = 0; I > t3; t3++)
  264. e3[t3] != s2[t3] && (i2 = false);
  265. }
  266. return { valid: i2, data: a2 };
  267. }
  268. }
  269. class U {
  270. constructor(t2, n2) {
  271. e.assign(this, { password: t2, strength: n2 - 1, pendingInput: new r(0) });
  272. }
  273. async append(e2) {
  274. const n2 = this;
  275. let s2 = new r(0);
  276. n2.password && (s2 = await (async (t2, e3) => {
  277. const n3 = (s3 = new r(S[t2.strength]), V && "function" == typeof h.getRandomValues ? h.getRandomValues(s3) : y.getRandomValues(s3));
  278. var s3;
  279. return await L(t2, e3, n3), P(n3, t2.keys.passwordVerification);
  280. })(n2, n2.password), n2.password = null, n2.aesCtrGladman = new R(new A(n2.keys.key), t.from(D)), n2.hmac = new W(n2.keys.authentication));
  281. const a2 = new r(s2.length + e2.length - e2.length % b);
  282. return a2.set(s2, 0), G(n2, e2, a2, s2.length, 0);
  283. }
  284. flush() {
  285. const t2 = this;
  286. let e2 = new r(0);
  287. if (t2.pendingInput.length) {
  288. const n3 = t2.aesCtrGladman.update(K.toBits(t2.pendingInput));
  289. t2.hmac.update(n3), e2 = K.fromBits(n3);
  290. }
  291. const n2 = E(K.fromBits(t2.hmac.digest()), 0, I);
  292. return { data: P(e2, n2), signature: n2 };
  293. }
  294. }
  295. function G(t2, e2, n2, s2, a2, i2) {
  296. const c2 = e2.length - a2;
  297. let o2;
  298. for (t2.pendingInput.length && (e2 = P(t2.pendingInput, e2), n2 = ((t3, e3) => {
  299. if (e3 && e3 > t3.length) {
  300. const n3 = t3;
  301. (t3 = new r(e3)).set(n3, 0);
  302. }
  303. return t3;
  304. })(n2, c2 - c2 % b)), o2 = 0; c2 - b >= o2; o2 += b) {
  305. const r2 = K.toBits(E(e2, o2, o2 + b));
  306. i2 && t2.hmac.update(r2);
  307. const a3 = t2.aesCtrGladman.update(r2);
  308. i2 || t2.hmac.update(a3), n2.set(K.fromBits(a3), o2 + s2);
  309. }
  310. return t2.pendingInput = E(e2, o2), n2;
  311. }
  312. async function L(t2, n2, s2) {
  313. const a2 = ((t3) => {
  314. if (void 0 === l) {
  315. const e2 = new r((t3 = unescape(encodeURIComponent(t3))).length);
  316. for (let n3 = 0; n3 < e2.length; n3++)
  317. e2[n3] = t3.charCodeAt(n3);
  318. return e2;
  319. }
  320. return new l().encode(t3);
  321. })(n2), i2 = await ((t3, e2, n3, s3, r2) => V && H && "function" == typeof h.subtle.importKey ? h.subtle.importKey("raw", e2, n3, false, r2) : _.importKey(e2))(0, a2, v, 0, C), c2 = await (async (t3, e2, n3) => V && H && "function" == typeof h.subtle.deriveBits ? await h.subtle.deriveBits(t3, e2, n3) : _.pbkdf2(e2, t3.salt, z.iterations, n3))(e.assign({ salt: s2 }, z), i2, 8 * (2 * B[t2.strength] + 2)), o2 = new r(c2);
  322. t2.keys = { key: K.toBits(E(o2, 0, B[t2.strength])), authentication: K.toBits(E(o2, B[t2.strength], 2 * B[t2.strength])), passwordVerification: E(o2, 2 * B[t2.strength]) };
  323. }
  324. function P(t2, e2) {
  325. let n2 = t2;
  326. return t2.length + e2.length && (n2 = new r(t2.length + e2.length), n2.set(t2, 0), n2.set(e2, t2.length)), n2;
  327. }
  328. function E(t2, e2, n2) {
  329. return t2.subarray(e2, n2);
  330. }
  331. class M {
  332. constructor(t2, n2) {
  333. e.assign(this, { password: t2, passwordVerification: n2 }), O(this, t2);
  334. }
  335. append(t2) {
  336. const e2 = this;
  337. if (e2.password) {
  338. const n2 = x(e2, t2.subarray(0, 12));
  339. if (e2.password = null, n2[11] != e2.passwordVerification)
  340. throw new s(m);
  341. t2 = t2.subarray(12);
  342. }
  343. return x(e2, t2);
  344. }
  345. flush() {
  346. return { valid: true, data: new r(0) };
  347. }
  348. }
  349. class j {
  350. constructor(t2, n2) {
  351. e.assign(this, { password: t2, passwordVerification: n2 }), O(this, t2);
  352. }
  353. append(t2) {
  354. const e2 = this;
  355. let n2, s2;
  356. if (e2.password) {
  357. e2.password = null;
  358. const a2 = h.getRandomValues(new r(12));
  359. a2[11] = e2.passwordVerification, n2 = new r(t2.length + a2.length), n2.set(F(e2, a2), 0), s2 = 12;
  360. } else
  361. n2 = new r(t2.length), s2 = 0;
  362. return n2.set(F(e2, t2), s2), n2;
  363. }
  364. flush() {
  365. return { data: new r(0) };
  366. }
  367. }
  368. function x(t2, e2) {
  369. const n2 = new r(e2.length);
  370. for (let s2 = 0; s2 < e2.length; s2++)
  371. n2[s2] = J(t2) ^ e2[s2], q(t2, n2[s2]);
  372. return n2;
  373. }
  374. function F(t2, e2) {
  375. const n2 = new r(e2.length);
  376. for (let s2 = 0; s2 < e2.length; s2++)
  377. n2[s2] = J(t2) ^ e2[s2], q(t2, e2[s2]);
  378. return n2;
  379. }
  380. function O(t2, e2) {
  381. t2.keys = [305419896, 591751049, 878082192], t2.crcKey0 = new u(t2.keys[0]), t2.crcKey2 = new u(t2.keys[2]);
  382. for (let n2 = 0; n2 < e2.length; n2++)
  383. q(t2, e2.charCodeAt(n2));
  384. }
  385. function q(t2, e2) {
  386. t2.crcKey0.append([e2]), t2.keys[0] = ~t2.crcKey0.get(), t2.keys[1] = Q(t2.keys[1] + N(t2.keys[0])), t2.keys[1] = Q(n.imul(t2.keys[1], 134775813) + 1), t2.crcKey2.append([t2.keys[1] >>> 24]), t2.keys[2] = ~t2.crcKey2.get();
  387. }
  388. function J(t2) {
  389. const e2 = 2 | t2.keys[2];
  390. return N(n.imul(e2, 1 ^ e2) >>> 8);
  391. }
  392. function N(t2) {
  393. return 255 & t2;
  394. }
  395. function Q(t2) {
  396. return 4294967295 & t2;
  397. }
  398. const X = "deflate", Y = "inflate", Z = "Invalid signature";
  399. class $ {
  400. constructor(t2, { signature: n2, password: s2, signed: r2, compressed: a2, zipCrypto: i2, passwordVerification: c2, encryptionStrength: o2 }, { chunkSize: l2 }) {
  401. const h2 = !!s2;
  402. e.assign(this, { signature: n2, encrypted: h2, signed: r2, compressed: a2, inflate: a2 && new t2({ chunkSize: l2 }), crc32: r2 && new u(), zipCrypto: i2, decrypt: h2 && i2 ? new M(s2, c2) : new T(s2, r2, o2) });
  403. }
  404. async append(t2) {
  405. const e2 = this;
  406. return e2.encrypted && t2.length && (t2 = await e2.decrypt.append(t2)), e2.compressed && t2.length && (t2 = await e2.inflate.append(t2)), (!e2.encrypted || e2.zipCrypto) && e2.signed && t2.length && e2.crc32.append(t2), t2;
  407. }
  408. async flush() {
  409. const t2 = this;
  410. let e2, n2 = new r(0);
  411. if (t2.encrypted) {
  412. const e3 = t2.decrypt.flush();
  413. if (!e3.valid)
  414. throw new s(Z);
  415. n2 = e3.data;
  416. }
  417. if ((!t2.encrypted || t2.zipCrypto) && t2.signed) {
  418. const n3 = new o(new r(4).buffer);
  419. if (e2 = t2.crc32.get(), n3.setUint32(0, e2), t2.signature != n3.getUint32(0, false))
  420. throw new s(Z);
  421. }
  422. return t2.compressed && (n2 = await t2.inflate.append(n2) || new r(0), await t2.inflate.flush()), { data: n2, signature: e2 };
  423. }
  424. }
  425. class tt {
  426. constructor(t2, { encrypted: n2, signed: s2, compressed: r2, level: a2, zipCrypto: i2, password: c2, passwordVerification: o2, encryptionStrength: l2 }, { chunkSize: h2 }) {
  427. e.assign(this, { encrypted: n2, signed: s2, compressed: r2, deflate: r2 && new t2({ level: a2 || 5, chunkSize: h2 }), crc32: s2 && new u(), zipCrypto: i2, encrypt: n2 && i2 ? new j(c2, o2) : new U(c2, l2) });
  428. }
  429. async append(t2) {
  430. const e2 = this;
  431. let n2 = t2;
  432. return e2.compressed && t2.length && (n2 = await e2.deflate.append(t2)), e2.encrypted && n2.length && (n2 = await e2.encrypt.append(n2)), (!e2.encrypted || e2.zipCrypto) && e2.signed && t2.length && e2.crc32.append(t2), n2;
  433. }
  434. async flush() {
  435. const t2 = this;
  436. let e2, n2 = new r(0);
  437. if (t2.compressed && (n2 = await t2.deflate.flush() || new r(0)), t2.encrypted) {
  438. n2 = await t2.encrypt.append(n2);
  439. const s2 = t2.encrypt.flush();
  440. e2 = s2.signature;
  441. const a2 = new r(n2.length + s2.data.length);
  442. a2.set(n2, 0), a2.set(s2.data, n2.length), n2 = a2;
  443. }
  444. return t2.encrypted && !t2.zipCrypto || !t2.signed || (e2 = t2.crc32.get()), { data: n2, signature: e2 };
  445. }
  446. }
  447. const et = { init(t2) {
  448. t2.scripts && t2.scripts.length && importScripts.apply(void 0, t2.scripts);
  449. const e2 = t2.options;
  450. let n2;
  451. self.initCodec && self.initCodec(), e2.codecType.startsWith(X) ? n2 = self.Deflate : e2.codecType.startsWith(Y) && (n2 = self.Inflate), nt = ((t3, e3, n3) => e3.codecType.startsWith(X) ? new tt(t3, e3, n3) : e3.codecType.startsWith(Y) ? new $(t3, e3, n3) : void 0)(n2, e2, t2.config);
  452. }, append: async (t2) => ({ data: await nt.append(t2.data) }), flush: () => nt.flush() };
  453. let nt;
  454. function st(t2, n2, s2) {
  455. return class {
  456. constructor(a3) {
  457. const i2 = this;
  458. i2.codec = new t2(e.assign({}, n2, a3)), s2(i2.codec, (t3) => {
  459. if (i2.pendingData) {
  460. const e2 = i2.pendingData;
  461. i2.pendingData = new r(e2.length + t3.length), i2.pendingData.set(e2, 0), i2.pendingData.set(t3, e2.length);
  462. } else
  463. i2.pendingData = new r(t3);
  464. });
  465. }
  466. append(t3) {
  467. return this.codec.push(t3), a2(this);
  468. }
  469. flush() {
  470. return this.codec.push(new r(0), true), a2(this);
  471. }
  472. };
  473. function a2(t3) {
  474. if (t3.pendingData) {
  475. const e2 = t3.pendingData;
  476. return t3.pendingData = null, e2;
  477. }
  478. return new r(0);
  479. }
  480. }
  481. addEventListener("message", async (t2) => {
  482. const e2 = t2.data, n2 = e2.type, s2 = et[n2];
  483. if (s2)
  484. try {
  485. e2.data && (e2.data = new r(e2.data));
  486. const t3 = await s2(e2) || {};
  487. if (t3.type = n2, t3.data)
  488. try {
  489. t3.data = t3.data.buffer, p(t3, [t3.data]);
  490. } catch (e3) {
  491. p(t3);
  492. }
  493. else
  494. p(t3);
  495. } catch (t3) {
  496. p({ type: n2, error: { message: t3.message, stack: t3.stack } });
  497. }
  498. }), self.initCodec = () => {
  499. const { Deflate: t2, Inflate: e2 } = ((t3, e3 = {}, n2) => ({ Deflate: st(t3.Deflate, e3.deflate, n2), Inflate: st(t3.Inflate, e3.inflate, n2) }))(pako, { deflate: { raw: true }, inflate: { raw: true } }, (t3, e3) => t3.onData = e3);
  500. self.Deflate = t2, self.Inflate = e2;
  501. };
  502. }();