@zip.js/zip.js 2.6.25 → 2.6.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -17
- package/dist/z-worker-fflate.js +1 -1
- package/dist/z-worker-pako.js +1 -1
- package/dist/z-worker.js +1 -1
- package/dist/zip-fs-full.js +5593 -5582
- package/dist/zip-fs-full.min.js +1 -1
- package/dist/zip-fs.js +536 -514
- package/dist/zip-fs.min.js +1 -1
- package/dist/zip-full.js +4110 -4099
- package/dist/zip-full.min.js +1 -1
- package/dist/zip-no-worker-deflate.min.js +1 -1
- package/dist/zip-no-worker-inflate.min.js +1 -1
- package/dist/zip-no-worker.min.js +1 -1
- package/dist/zip.js +536 -514
- package/dist/zip.min.js +1 -1
- package/index.d.ts +46 -23
- package/index.js +2 -2
- package/lib/core/codec-interface.js +17 -9
- package/lib/core/codec-pool-worker.js +2 -3
- package/lib/core/codec-pool.js +1 -1
- package/lib/core/configuration.js +29 -8
- package/lib/core/io.js +36 -46
- package/lib/core/streams/aes-crypto-stream.js +87 -62
- package/lib/core/streams/codec-stream.js +4 -3
- package/lib/core/streams/codecs/crc32.js +3 -1
- package/lib/core/streams/codecs/deflate.js +1792 -1796
- package/lib/core/streams/codecs/inflate.js +1828 -1831
- package/lib/core/streams/common-crypto.js +3 -1
- package/lib/core/streams/crc32-stream.js +7 -7
- package/lib/core/streams/zip-crypto-stream.js +13 -14
- package/lib/core/streams/zip-entry-stream.js +42 -58
- package/lib/core/util/cp437-decode.js +6 -2
- package/lib/core/util/decode-text.js +4 -2
- package/lib/core/util/encode-text.js +3 -1
- package/lib/core/util/stream-codec-shim.js +6 -2
- package/lib/core/z-worker-core.js +9 -9
- package/lib/core/zip-entry.js +6 -2
- package/lib/core/zip-reader.js +15 -6
- package/lib/core/zip-writer.js +74 -50
- package/lib/z-worker-bootstrap-fflate.js +1 -1
- package/lib/z-worker-bootstrap-pako.js +1 -1
- package/lib/z-worker-inline-template.js +9 -7
- package/lib/z-worker-inline.js +1 -1
- package/lib/z-worker.js +2 -2
- package/lib/zip-fflate-shim.js +1 -1
- package/lib/zip-fs.js +2 -2
- package/lib/zip-full-fflate.js +2 -2
- package/lib/zip-full.js +4 -4
- package/lib/zip-no-worker-deflate.js +1 -1
- package/lib/zip-no-worker-inflate.js +1 -1
- package/lib/zip-no-worker.js +2 -2
- package/lib/zip.js +2 -2
- package/package.json +5 -2
- package/rollup-fflate.config.dev.js +2 -2
- package/rollup-fflate.config.js +2 -2
- package/rollup.config.dev.js +2 -2
- package/rollup.config.js +2 -2
- package/tests/all/test-streams.js +29 -0
- package/tests/tests-data.js +1 -0
- package/lib/z-worker-inline-template-base64.js +0 -36
package/dist/zip.js
CHANGED
|
@@ -4,216 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zip = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
const { Array, Object, String, BigInt, Math, Date, Map, URL, Error, Uint8Array, Uint16Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator } = globalThis;
|
|
8
|
-
|
|
9
|
-
/*
|
|
10
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
11
|
-
|
|
12
|
-
Redistribution and use in source and binary forms, with or without
|
|
13
|
-
modification, are permitted provided that the following conditions are met:
|
|
14
|
-
|
|
15
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
16
|
-
this list of conditions and the following disclaimer.
|
|
17
|
-
|
|
18
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
19
|
-
notice, this list of conditions and the following disclaimer in
|
|
20
|
-
the documentation and/or other materials provided with the distribution.
|
|
21
|
-
|
|
22
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
23
|
-
derived from this software without specific prior written permission.
|
|
24
|
-
|
|
25
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
26
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
27
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
28
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
29
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
30
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
31
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
32
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
33
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
34
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/* global navigator */
|
|
38
|
-
|
|
39
|
-
const MINIMUM_CHUNK_SIZE = 64;
|
|
40
|
-
const UNDEFINED_TYPE$2 = undefined;
|
|
41
|
-
const DEFAULT_CONFIGURATION = {
|
|
42
|
-
chunkSize: 512 * 1024,
|
|
43
|
-
maxWorkers: (typeof navigator != "undefined" && navigator.hardwareConcurrency) || 2,
|
|
44
|
-
terminateWorkerTimeout: 5000,
|
|
45
|
-
useWebWorkers: true,
|
|
46
|
-
workerScripts: undefined
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const config = Object.assign({}, DEFAULT_CONFIGURATION);
|
|
50
|
-
|
|
51
|
-
function getConfiguration() {
|
|
52
|
-
return config;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function getChunkSize(config) {
|
|
56
|
-
return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function configure(configuration) {
|
|
60
|
-
const {
|
|
61
|
-
baseURL,
|
|
62
|
-
chunkSize,
|
|
63
|
-
maxWorkers,
|
|
64
|
-
terminateWorkerTimeout,
|
|
65
|
-
useCompressionStream,
|
|
66
|
-
useWebWorkers,
|
|
67
|
-
Deflate,
|
|
68
|
-
Inflate,
|
|
69
|
-
workerScripts
|
|
70
|
-
} = configuration;
|
|
71
|
-
setIfDefined("baseURL", baseURL);
|
|
72
|
-
setIfDefined("chunkSize", chunkSize);
|
|
73
|
-
setIfDefined("maxWorkers", maxWorkers);
|
|
74
|
-
setIfDefined("terminateWorkerTimeout", terminateWorkerTimeout);
|
|
75
|
-
setIfDefined("useCompressionStream", useCompressionStream);
|
|
76
|
-
setIfDefined("useWebWorkers", useWebWorkers);
|
|
77
|
-
setIfDefined("Deflate", Deflate);
|
|
78
|
-
setIfDefined("Inflate", Inflate);
|
|
79
|
-
if (workerScripts !== UNDEFINED_TYPE$2) {
|
|
80
|
-
const { deflate, inflate } = workerScripts;
|
|
81
|
-
if (deflate || inflate) {
|
|
82
|
-
if (!config.workerScripts) {
|
|
83
|
-
config.workerScripts = {};
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (deflate) {
|
|
87
|
-
if (!Array.isArray(deflate)) {
|
|
88
|
-
throw new Error("workerScripts.deflate must be an array");
|
|
89
|
-
}
|
|
90
|
-
config.workerScripts.deflate = deflate;
|
|
91
|
-
}
|
|
92
|
-
if (inflate) {
|
|
93
|
-
if (!Array.isArray(inflate)) {
|
|
94
|
-
throw new Error("workerScripts.inflate must be an array");
|
|
95
|
-
}
|
|
96
|
-
config.workerScripts.inflate = inflate;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function setIfDefined(propertyName, propertyValue) {
|
|
102
|
-
if (propertyValue !== UNDEFINED_TYPE$2) {
|
|
103
|
-
config[propertyName] = propertyValue;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
var e=e=>{if("function"==typeof URL.createObjectURL){const t=()=>URL.createObjectURL(new Blob(['const{Array:t,Object:e,Math:n,Error:r,Uint8Array:s,Uint16Array:i,Uint32Array:o,Int32Array:c,DataView:f,Promise:l,TextEncoder:a,crypto:u,postMessage:w,TransformStream:h,ReadableStream:d,WritableStream:p,CompressionStream:b,DecompressionStream:y}=globalThis,m=[];for(let t=0;256>t;t++){let e=t;for(let t=0;8>t;t++)1&e?e=e>>>1^3988292384:e>>>=1;m[t]=e}class k{constructor(t){this.t=t||-1}append(t){let e=0|this.t;for(let n=0,r=0|t.length;r>n;n++)e=e>>>8^m[255&(e^t[n])];this.t=e}get(){return~this.t}}class g extends h{constructor(){super({start(){this.i=new k},transform(t){this.i.append(t)},flush(t){const e=new s(4);new f(e.buffer).setUint32(0,this.i.get()),t.enqueue(e)}})}}const v={concat(t,e){if(0===t.length||0===e.length)return t.concat(e);const n=t[t.length-1],r=v.o(n);return 32===r?t.concat(e):v.l(e,r,0|n,t.slice(0,t.length-1))},u(t){const e=t.length;if(0===e)return 0;const n=t[e-1];return 32*(e-1)+v.o(n)},h(t,e){if(32*t.length<e)return t;const r=(t=t.slice(0,n.ceil(e/32))).length;return e&=31,r>0&&e&&(t[r-1]=v.p(e,t[r-1]&2147483648>>e-1,1)),t},p:(t,e,n)=>32===t?e:(n?0|e:e<<32-t)+1099511627776*t,o:t=>n.round(t/1099511627776)||32,l(t,e,n,r){for(void 0===r&&(r=[]);e>=32;e-=32)r.push(n),n=0;if(0===e)return r.concat(t);for(let s=0;s<t.length;s++)r.push(n|t[s]>>>e),n=t[s]<<32-e;const s=t.length?t[t.length-1]:0,i=v.o(s);return r.push(v.p(e+i&31,e+i>32?n:r.pop(),1)),r}},S={m:{k(t){const e=v.u(t)/8,n=new s(e);let r;for(let s=0;e>s;s++)0==(3&s)&&(r=t[s/4]),n[s]=r>>>24,r<<=8;return n},g(t){const e=[];let n,r=0;for(n=0;n<t.length;n++)r=r<<8|t[n],3==(3&n)&&(e.push(r),r=0);return 3&n&&e.push(v.p(8*(3&n),r)),e}}},C={v:function(t){t?(this.S=t.S.slice(0),this.C=t.C.slice(0),this._=t._):this.reset()}};C.v.prototype={blockSize:512,reset(){const t=this;return t.S=this.I.slice(0),t.C=[],t._=0,t},update(t){const e=this;"string"==typeof t&&(t=S.A.g(t));const n=e.C=v.concat(e.C,t),s=e._,i=e._=s+v.u(t);if(i>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new o(n);let f=0;for(let t=e.blockSize+s-(e.blockSize+s&e.blockSize-1);i>=t;t+=e.blockSize)e.V(c.subarray(16*f,16*(f+1))),f+=1;return n.splice(0,16*f),e},M(){const t=this;let e=t.C;const r=t.S;e=v.concat(e,[v.p(1,1)]);for(let t=e.length+2;15&t;t++)e.push(0);for(e.push(n.floor(t._/4294967296)),e.push(0|t._);e.length;)t.V(e.splice(0,16));return t.reset(),r},I:[1732584193,4023233417,2562383102,271733878,3285377520],B:[1518500249,1859775393,2400959708,3395469782],D:(t,e,n,r)=>t>19?t>39?t>59?t>79?void 0:e^n^r:e&n|e&r|n&r:e^n^r:e&n|~e&r,T:(t,e)=>e<<t|e>>>32-t,V(e){const r=this,s=r.S,i=t(80);for(let t=0;16>t;t++)i[t]=e[t];let o=s[0],c=s[1],f=s[2],l=s[3],a=s[4];for(let t=0;79>=t;t++){16>t||(i[t]=r.T(1,i[t-3]^i[t-8]^i[t-14]^i[t-16]));const e=r.T(5,o)+r.D(t,c,f,l)+a+i[t]+r.B[n.floor(t/20)]|0;a=l,l=f,f=r.T(30,c),c=o,o=e}s[0]=s[0]+o|0,s[1]=s[1]+c|0,s[2]=s[2]+f|0,s[3]=s[3]+l|0,s[4]=s[4]+a|0}};const z={getRandomValues(t){const e=new o(t.buffer),r=t=>{let e=987654321;const r=4294967295;return()=>(e=36969*(65535&e)+(e>>16)&r,(((e<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r)/4294967296+.5)*(n.random()>.5?1:-1))};for(let s,i=0;i<t.length;i+=4){const t=r(4294967296*(s||n.random()));s=987654071*t(),e[i/4]=4294967296*t()|0}return t}},_={importKey:t=>new _.P(S.m.g(t)),R(t,e,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const i=1+(s>>5)<<2;let o,c,l,a,u;const w=new ArrayBuffer(i),h=new f(w);let d=0;const p=v;for(e=S.m.g(e),u=1;(i||1)>d;u++){for(o=c=t.encrypt(p.concat(e,[u])),l=1;n>l;l++)for(c=t.encrypt(c),a=0;a<c.length;a++)o[a]^=c[a];for(l=0;(i||1)>d&&l<o.length;l++)h.setInt32(d,o[l]),d+=4}return w.slice(0,s/8)},P:class{constructor(t){const e=this,n=e.U=C.v,r=[[],[]],s=n.prototype.blockSize/32;e.W=[new n,new n],t.length>s&&(t=n.hash(t));for(let e=0;s>e;e++)r[0][e]=909522486^t[e],r[1][e]=1549556828^t[e];e.W[0].update(r[0]),e.W[1].update(r[1]),e.H=new n(e.W[0])}reset(){const t=this;t.H=new t.U(t.W[0]),t.K=!1}update(t){this.K=!0,this.H.update(t)}digest(){const t=this,e=t.H.M(),n=new t.U(t.W[1]).update(e).M();return t.reset(),n}encrypt(t){if(this.K)throw new r("encrypt on already updated hmac called!");return this.update(t),this.digest(t)}}},I=void 0!==u&&"function"==typeof u.getRandomValues;function x(t){return I?u.getRandomValues(t):z.getRandomValues(t)}const A={name:"PBKDF2"},V=e.assign({hash:{name:"HMAC"}},A),M=e.assign({iterations:1e3,hash:{name:"SHA-1"}},A),B=["deriveBits"],D=[8,12,16],E=[16,24,32],T=[0,0,0,0],P=void 0!==u,R=P&&void 0!==u.subtle,U=P&&R&&"function"==typeof u.subtle.importKey,W=P&&R&&"function"==typeof u.subtle.deriveBits,H=S.m,K=class{constructor(t){const e=this;e.L=[[[],[],[],[],[]],[[],[],[],[],[]]],e.L[0][0][0]||e.N();const n=e.L[0][4],s=e.L[1],i=t.length;let o,c,f,l=1;if(4!==i&&6!==i&&8!==i)throw new r("invalid aes key size");for(e.B=[c=t.slice(0),f=[]],o=i;4*i+28>o;o++){let t=c[o-1];(o%i==0||8===i&&o%i==4)&&(t=n[t>>>24]<<24^n[t>>16&255]<<16^n[t>>8&255]<<8^n[255&t],o%i==0&&(t=t<<8^t>>>24^l<<24,l=l<<1^283*(l>>7))),c[o]=c[o-i]^t}for(let t=0;o;t++,o--){const e=c[3&t?o:o-4];f[t]=4>=o||4>t?e:s[0][n[e>>>24]]^s[1][n[e>>16&255]]^s[2][n[e>>8&255]]^s[3][n[255&e]]}}encrypt(t){return this.j(t,0)}decrypt(t){return this.j(t,1)}N(){const t=this.L[0],e=this.L[1],n=t[4],r=e[4],s=[],i=[];let o,c,f,l;for(let t=0;256>t;t++)i[(s[t]=t<<1^283*(t>>7))^t]=t;for(let a=o=0;!n[a];a^=c||1,o=i[o]||1){let i=o^o<<1^o<<2^o<<3^o<<4;i=i>>8^255&i^99,n[a]=i,r[i]=a,l=s[f=s[c=s[a]]];let u=16843009*l^65537*f^257*c^16843008*a,w=257*s[i]^16843008*i;for(let n=0;4>n;n++)t[n][a]=w=w<<24^w>>>8,e[n][i]=u=u<<24^u>>>8}for(let n=0;5>n;n++)t[n]=t[n].slice(0),e[n]=e[n].slice(0)}j(t,e){if(4!==t.length)throw new r("invalid aes block size");const n=this.B[e],s=n.length/4-2,i=[0,0,0,0],o=this.L[e],c=o[0],f=o[1],l=o[2],a=o[3],u=o[4];let w,h,d,p=t[0]^n[0],b=t[e?3:1]^n[1],y=t[2]^n[2],m=t[e?1:3]^n[3],k=4;for(let t=0;s>t;t++)w=c[p>>>24]^f[b>>16&255]^l[y>>8&255]^a[255&m]^n[k],h=c[b>>>24]^f[y>>16&255]^l[m>>8&255]^a[255&p]^n[k+1],d=c[y>>>24]^f[m>>16&255]^l[p>>8&255]^a[255&b]^n[k+2],m=c[m>>>24]^f[p>>16&255]^l[b>>8&255]^a[255&y]^n[k+3],k+=4,p=w,b=h,y=d;for(let t=0;4>t;t++)i[e?3&-t:t]=u[p>>>24]<<24^u[b>>16&255]<<16^u[y>>8&255]<<8^u[255&m]^n[k++],w=p,p=b,b=y,y=m,m=w;return i}},L=class{constructor(t,e){this.F=t,this.O=e,this.q=e}reset(){this.q=this.O}update(t){return this.G(this.F,t,this.q)}J(t){if(255==(t>>24&255)){let e=t>>16&255,n=t>>8&255,r=255&t;255===e?(e=0,255===n?(n=0,255===r?r=0:++r):++n):++e,t=0,t+=e<<16,t+=n<<8,t+=r}else t+=1<<24;return t}X(t){0===(t[0]=this.J(t[0]))&&(t[1]=this.J(t[1]))}G(t,e,n){let r;if(!(r=e.length))return[];const s=v.u(e);for(let s=0;r>s;s+=4){this.X(n);const r=t.encrypt(n);e[s]^=r[0],e[s+1]^=r[1],e[s+2]^=r[2],e[s+3]^=r[3]}return v.h(e,s)}},N=_.P;class j extends h{constructor(n,i,o){let c;super({start(){e.assign(this,{ready:new l((t=>this.Y=t)),password:n,signed:i,Z:o-1,pending:new s})},async transform(e,n){const i=this;if(i.password){const n=i.password;i.password=null;const s=J(e,0,D[i.Z]+2);await(async(t,e,n)=>{await q(t,n,J(e,0,D[t.Z]));const s=J(e,D[t.Z]),i=t.keys.passwordVerification;if(i[0]!=s[0]||i[1]!=s[1])throw new r("Invalid password")})(i,s,n),i.$=new L(new K(i.keys.key),t.from(T)),i.tt=new N(i.keys.et),e=J(e,D[i.Z]+2),i.Y()}else await i.ready;const o=new s(e.length-10-(e.length-10)%16);n.enqueue(O(i,e,o,0,10,!0))},async flush(t){const e=this;await e.ready;const n=e.pending,r=J(n,0,n.length-10),i=J(n,n.length-10);let o=new s;if(r.length){const t=X(H,r);e.tt.update(t);const n=e.$.update(t);o=Q(H,n)}if(c.valid=!0,e.signed){const t=J(Q(H,e.tt.digest()),0,10);for(let e=0;10>e;e++)t[e]!=i[e]&&(c.valid=!1)}t.enqueue(o)}}),c=this}}class F extends h{constructor(n,r){let i;super({start(){e.assign(this,{ready:new l((t=>this.Y=t)),password:n,Z:r-1,pending:new s})},async transform(e,n){const r=this;let i=new s;if(r.password){const e=r.password;r.password=null,i=await(async(t,e)=>{const n=x(new s(D[t.Z]));return await q(t,e,n),G(n,t.keys.passwordVerification)})(r,e),r.$=new L(new K(r.keys.key),t.from(T)),r.tt=new N(r.keys.et),r.Y()}else await r.ready;const o=new s(i.length+e.length-e.length%16);o.set(i,0),n.enqueue(O(r,e,o,i.length,0))},async flush(t){const e=this;await e.ready;let n=new s;if(e.pending.length){const t=e.$.update(X(H,e.pending));e.tt.update(t),n=Q(H,t)}i.signature=Q(H,e.tt.digest()).slice(0,10),t.enqueue(G(n,i.signature))}}),i=this}}function O(t,e,n,r,i,o){const c=e.length-i;let f;for(t.pending.length&&(e=G(t.pending,e),n=((t,e)=>{if(e&&e>t.length){const n=t;(t=new s(e)).set(n,0)}return t})(n,c-c%16)),f=0;c-16>=f;f+=16){const s=X(H,J(e,f,f+16));o&&t.tt.update(s);const i=t.$.update(s);o||t.tt.update(i),n.set(Q(H,i),f+r)}return t.pending=J(e,f),n}async function q(t,n,r){const i=(t=>{if(void 0===a){const e=new s((t=unescape(encodeURIComponent(t))).length);for(let n=0;n<e.length;n++)e[n]=t.charCodeAt(n);return e}return(new a).encode(t)})(n),o=await((t,e,n,r,s)=>U?u.subtle.importKey("raw",e,n,!1,s):_.importKey(e))(0,i,V,0,B),c=await(async(t,e,n)=>W?await u.subtle.deriveBits(t,e,n):_.R(e,t.salt,M.iterations,n))(e.assign({salt:r},M),o,8*(2*E[t.Z]+2)),f=new s(c);t.keys={key:X(H,J(f,0,E[t.Z])),et:X(H,J(f,E[t.Z],2*E[t.Z])),passwordVerification:J(f,2*E[t.Z])}}function G(t,e){let n=t;return t.length+e.length&&(n=new s(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function J(t,e,n){return t.subarray(e,n)}function Q(t,e){return t.k(e)}function X(t,e){return t.g(e)}class Y extends h{constructor(t,n){let s;super({start(){e.assign(this,{password:t,passwordVerification:n}),et(this,t)},transform(t,e){const n=this;if(n.password){const e=$(n,t.subarray(0,12));if(n.password=null,e[11]!=n.passwordVerification)throw new r("Invalid password");t=t.subarray(12)}e.enqueue($(n,t))},flush(){s.valid=!0}}),s=this}}class Z extends h{constructor(t,n){super({start(){e.assign(this,{password:t,passwordVerification:n}),et(this,t)},transform(t,e){const n=this;let r,i;if(n.password){n.password=null;const e=x(new s(12));e[11]=n.passwordVerification,r=new s(t.length+e.length),r.set(tt(n,e),0),i=12}else r=new s(t.length),i=0;r.set(tt(n,t),i),e.enqueue(r)},flush(){}})}}function $(t,e){const n=new s(e.length);for(let r=0;r<e.length;r++)n[r]=rt(t)^e[r],nt(t,n[r]);return n}function tt(t,e){const n=new s(e.length);for(let r=0;r<e.length;r++)n[r]=rt(t)^e[r],nt(t,e[r]);return n}function et(t,e){t.keys=[305419896,591751049,878082192],t.nt=new k(t.keys[0]),t.rt=new k(t.keys[2]);for(let n=0;n<e.length;n++)nt(t,e.charCodeAt(n))}function nt(t,e){t.nt.append([e]),t.keys[0]=~t.nt.get(),t.keys[1]=it(t.keys[1]+st(t.keys[0])),t.keys[1]=it(n.imul(t.keys[1],134775813)+1),t.rt.append([t.keys[1]>>>24]),t.keys[2]=~t.rt.get()}function rt(t){const e=2|t.keys[2];return st(n.imul(e,1^e)>>>8)}function st(t){return 255&t}function it(t){return 4294967295&t}class ot extends h{constructor(t,e){let n;super({start(){n=new t(e)},transform(t,e){t=n.append(t),e.enqueue(t)},flush(t){const e=n.flush();e&&t.enqueue(e)}})}}const ct=void 0===b,ft=void 0===y;let lt=!0,at=!0;class ut extends h{constructor(t,e,{chunkSize:n},...r){super({},...r);const{compressed:s,encrypted:i,useCompressionStream:o,password:c,passwordVerification:l,encryptionStrength:a,zipCrypto:u,signed:w,level:h}=e,d=this;let p,y,m=dt(super.readable);if(i&&!u||!w||([m,p]=m.tee(),p=p.pipeThrough(new g)),s)if(void 0!==o&&!o||ct&&!at)m=ht(t,m,{chunkSize:n,level:h});else try{m=m.pipeThrough(new b("deflate-raw"))}catch(e){at=!1,m=ht(t,m,{chunkSize:n,level:h})}i&&(u?m=m.pipeThrough(new Z(c,l)):(y=new F(c,a),m=m.pipeThrough(y))),pt(d,m,(async()=>{let t;i&&!u&&(t=y.signature),i&&!u||!w||(t=await p.getReader().read(),t=new f(t.value.buffer).getUint32(0)),d.signature=t}))}}class wt extends h{constructor(t,e,{chunkSize:n},...s){super({},...s);const{zipCrypto:i,encrypted:o,password:c,passwordVerification:l,signed:a,encryptionStrength:u,compressed:w,useCompressionStream:h}=e;let d,p,b=dt(super.readable);if(o&&(i?b=b.pipeThrough(new Y(c,l)):(p=new j(c,a,u),b=b.pipeThrough(p))),w)if(void 0!==h&&!h||ft&&!lt)b=ht(t,b,{chunkSize:n});else try{b=b.pipeThrough(new y("deflate-raw"))}catch(e){lt=!1,b=ht(t,b,{chunkSize:n})}o&&!i||!a||([b,d]=b.tee(),d=d.pipeThrough(new g)),pt(this,b,(async()=>{if(o&&!i&&!p.valid)throw new r("Invalid signature");if((!o||i)&&a){const t=await d.getReader().read(),n=new f(t.value.buffer);if(e.signature!=n.getUint32(0,!1))throw new r("Invalid signature")}}))}}function ht(t,e,n){return e.pipeThrough(new ot(t,n))}function dt(t){return t.pipeThrough(new h({transform(t,e){t&&t.length&&e.enqueue(t)}}))}function pt(t,n,r){n=n.pipeThrough(new h({flush:r})),e.defineProperty(t,"readable",{get:()=>n})}class bt{constructor(t,n,r,s,i){const{codecType:o}=s;let c;o.startsWith("deflate")?c=ut:o.startsWith("inflate")&&(c=wt),e.assign(this,{st:c,it:t,readable:n,writable:r,options:s,config:i})}async ot(){const{st:t,it:e,readable:n,writable:r,options:s,config:i}=this,o=new t(e,s,i);let c=0;await n.pipeThrough(o).pipeThrough(new h({transform(t,e){t&&t.length&&(c+=t.length,e.enqueue(t))}})).pipeTo(r,{preventClose:!0,ct:!0});const{signature:f}=o;return{size:c,signature:f}}}const yt=new Map,mt=new Map;let kt,gt=0;async function vt(t){try{const{options:e,scripts:n,config:r}=t,{codecType:s}=e;let i;n&&n.length&&importScripts.apply(void 0,n),self.initCodec&&self.initCodec(),s.startsWith("deflate")?i=self.Deflate:s.startsWith("inflate")&&(i=self.Inflate);const o={highWaterMark:1,size:()=>r.chunkSize},c=t.readable||new d({async pull(t){let e=new l((t=>yt.set(gt,t)));St({type:"pull",messageId:gt}),gt=(gt+1)%Number.MAX_SAFE_INTEGER;const{value:n,done:r}=await e;t.enqueue(n),r&&t.close()}},o),f=t.writable||new p({async write(t){let e;const n=new l((t=>e=t));mt.set(gt,e),St({type:"data",data:t,messageId:gt}),gt=(gt+1)%Number.MAX_SAFE_INTEGER,await n}},o);kt=new bt(i,c,f,e,r);const a=await kt.ot();t.writable&&!e.preventClose&&await t.writable.close(),St({type:"close",result:a})}catch(t){Ct(t)}}function St(t){if(t.data){let{data:e}=t;if(e&&e.length)try{e=new s(e),t.data=e.buffer,w(t,[t.data])}catch(e){w(t)}else w(t)}else w(t)}function Ct(t){const{message:e,stack:n,code:r,name:s}=t;w({error:{message:e,stack:n,code:r,name:s}})}addEventListener("message",(async t=>{const e=t.data,{type:n,messageId:r,data:i,done:o}=e;try{if("start"==n&&vt(e),"data"==n){const t=yt.get(r);yt.delete(r),t({value:new s(i),done:o})}if("ack"==n){const t=mt.get(r);mt.delete(r),t()}}catch(t){Ct(t)}}));const zt=(()=>{const e=-2;function o(e){return c(e.map((([e,n])=>new t(e).fill(n,0,e))))}function c(e){return e.reduce(((e,n)=>e.concat(t.isArray(n)?c(n):n)),[])}const f=[0,1,2,3].concat(...o([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function l(){const t=this;function e(t,e){let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1}t.ft=r=>{const s=t.lt,i=t.wt.ut,o=t.wt.ht;let c,f,l,a=-1;for(r.dt=0,r.bt=573,c=0;o>c;c++)0!==s[2*c]?(r.yt[++r.dt]=a=c,r.kt[c]=0):s[2*c+1]=0;for(;2>r.dt;)l=r.yt[++r.dt]=2>a?++a:0,s[2*l]=1,r.kt[l]=0,r.gt--,i&&(r.vt-=i[2*l+1]);for(t.St=a,c=n.floor(r.dt/2);c>=1;c--)r.Ct(s,c);l=o;do{c=r.yt[1],r.yt[1]=r.yt[r.dt--],r.Ct(s,1),f=r.yt[1],r.yt[--r.bt]=c,r.yt[--r.bt]=f,s[2*l]=s[2*c]+s[2*f],r.kt[l]=n.max(r.kt[c],r.kt[f])+1,s[2*c+1]=s[2*f+1]=l,r.yt[1]=l++,r.Ct(s,1)}while(r.dt>=2);r.yt[--r.bt]=r.yt[1],(e=>{const n=t.lt,r=t.wt.ut,s=t.wt.zt,i=t.wt._t,o=t.wt.It;let c,f,l,a,u,w,h=0;for(a=0;15>=a;a++)e.xt[a]=0;for(n[2*e.yt[e.bt]+1]=0,c=e.bt+1;573>c;c++)f=e.yt[c],a=n[2*n[2*f+1]+1]+1,a>o&&(a=o,h++),n[2*f+1]=a,f>t.St||(e.xt[a]++,u=0,i>f||(u=s[f-i]),w=n[2*f],e.gt+=w*(a+u),r&&(e.vt+=w*(r[2*f+1]+u)));if(0!==h){do{for(a=o-1;0===e.xt[a];)a--;e.xt[a]--,e.xt[a+1]+=2,e.xt[o]--,h-=2}while(h>0);for(a=o;0!==a;a--)for(f=e.xt[a];0!==f;)l=e.yt[--c],l>t.St||(n[2*l+1]!=a&&(e.gt+=(a-n[2*l+1])*n[2*l],n[2*l+1]=a),f--)}})(r),((t,n,r)=>{const s=[];let i,o,c,f=0;for(i=1;15>=i;i++)s[i]=f=f+r[i-1]<<1;for(o=0;n>=o;o++)c=t[2*o+1],0!==c&&(t[2*o]=e(s[c]++,c))})(s,t.St,r.xt)}}function a(t,e,n,r,s){const i=this;i.ut=t,i.zt=e,i._t=n,i.ht=r,i.It=s}l.At=[0,1,2,3,4,5,6,7].concat(...o([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),l.Vt=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],l.Mt=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],l.Bt=t=>256>t?f[t]:f[256+(t>>>7)],l.Dt=[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],l.Et=[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],l.Tt=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],l.Pt=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];const u=o([[144,8],[112,9],[24,7],[8,8]]);a.Rt=c([12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,19,275,147,403,83,339,211,467,51,307,179,435,115,371,243,499,11,267,139,395,75,331,203,459,43,299,171,427,107,363,235,491,27,283,155,411,91,347,219,475,59,315,187,443,123,379,251,507,7,263,135,391,71,327,199,455,39,295,167,423,103,359,231,487,23,279,151,407,87,343,215,471,55,311,183,439,119,375,247,503,15,271,143,399,79,335,207,463,47,303,175,431,111,367,239,495,31,287,159,415,95,351,223,479,63,319,191,447,127,383,255,511,0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116,3,131,67,195,35,163,99,227].map(((t,e)=>[t,u[e]])));const w=o([[30,5]]);function h(t,e,n,r,s){const i=this;i.Ut=t,i.Wt=e,i.Ht=n,i.Kt=r,i.Lt=s}a.Nt=c([0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23].map(((t,e)=>[t,w[e]]))),a.jt=new a(a.Rt,l.Dt,257,286,15),a.Ft=new a(a.Nt,l.Et,0,30,15),a.Ot=new a(null,l.Tt,0,19,7);const d=[new h(0,0,0,0,0),new h(4,4,8,4,1),new h(4,5,16,8,1),new h(4,6,32,32,1),new h(4,4,16,16,2),new h(8,16,32,32,2),new h(8,16,128,128,2),new h(8,32,128,256,2),new h(32,128,258,1024,2),new h(32,258,258,4096,2)],p=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],b=113,y=666,m=262;function k(t,e,n,r){const s=t[2*e],i=t[2*n];return i>s||s==i&&r[e]<=r[n]}function g(){const t=this;let r,o,c,f,u,w,h,g,v,S,C,z,_,I,x,A,V,M,B,D,E,T,P,R,U,W,H,K,L,N,j,F,O;const q=new l,G=new l,J=new l;let Q,X,Y,Z,$,tt;function et(){let e;for(e=0;286>e;e++)j[2*e]=0;for(e=0;30>e;e++)F[2*e]=0;for(e=0;19>e;e++)O[2*e]=0;j[512]=1,t.gt=t.vt=0,X=Y=0}function nt(t,e){let n,r=-1,s=t[1],i=0,o=7,c=4;0===s&&(o=138,c=3),t[2*(e+1)+1]=65535;for(let f=0;e>=f;f++)n=s,s=t[2*(f+1)+1],++i<o&&n==s||(c>i?O[2*n]+=i:0!==n?(n!=r&&O[2*n]++,O[32]++):i>10?O[36]++:O[34]++,i=0,r=n,0===s?(o=138,c=3):n==s?(o=6,c=3):(o=7,c=4))}function rt(e){t.qt[t.pending++]=e}function st(t){rt(255&t),rt(t>>>8&255)}function it(t,e){let n;const r=e;tt>16-r?(n=t,$|=n<<tt&65535,st($),$=n>>>16-tt,tt+=r-16):($|=t<<tt&65535,tt+=r)}function ot(t,e){const n=2*t;it(65535&e[n],65535&e[n+1])}function ct(t,e){let n,r,s=-1,i=t[1],o=0,c=7,f=4;for(0===i&&(c=138,f=3),n=0;e>=n;n++)if(r=i,i=t[2*(n+1)+1],++o>=c||r!=i){if(f>o)do{ot(r,O)}while(0!=--o);else 0!==r?(r!=s&&(ot(r,O),o--),ot(16,O),it(o-3,2)):o>10?(ot(18,O),it(o-11,7)):(ot(17,O),it(o-3,3));o=0,s=r,0===i?(c=138,f=3):r==i?(c=6,f=3):(c=7,f=4)}}function ft(){16==tt?(st($),$=0,tt=0):8>tt||(rt(255&$),$>>>=8,tt-=8)}function lt(e,r){let s,i,o;if(t.Gt[X]=e,t.Jt[X]=255&r,X++,0===e?j[2*r]++:(Y++,e--,j[2*(l.At[r]+256+1)]++,F[2*l.Bt(e)]++),0==(8191&X)&&H>2){for(s=8*X,i=E-V,o=0;30>o;o++)s+=F[2*o]*(5+l.Et[o]);if(s>>>=3,Y<n.floor(X/2)&&s<n.floor(i/2))return!0}return X==Q-1}function at(e,n){let r,s,i,o,c=0;if(0!==X)do{r=t.Gt[c],s=t.Jt[c],c++,0===r?ot(s,e):(i=l.At[s],ot(i+256+1,e),o=l.Dt[i],0!==o&&(s-=l.Vt[i],it(s,o)),r--,i=l.Bt(r),ot(i,n),o=l.Et[i],0!==o&&(r-=l.Mt[i],it(r,o)))}while(X>c);ot(256,e),Z=e[513]}function ut(){tt>8?st($):tt>0&&rt(255&$),$=0,tt=0}function wt(e,n,r){it(0+(r?1:0),3),((e,n)=>{ut(),Z=8,st(n),st(~n),t.qt.set(g.subarray(e,e+n),t.pending),t.pending+=n})(e,n)}function ht(e){((e,n,r)=>{let s,i,o=0;H>0?(q.ft(t),G.ft(t),o=(()=>{let e;for(nt(j,q.St),nt(F,G.St),J.ft(t),e=18;e>=3&&0===O[2*l.Pt[e]+1];e--);return t.gt+=14+3*(e+1),e})(),s=t.gt+3+7>>>3,i=t.vt+3+7>>>3,i>s||(s=i)):s=i=n+5,n+4>s||-1==e?i==s?(it(2+(r?1:0),3),at(a.Rt,a.Nt)):(it(4+(r?1:0),3),((t,e,n)=>{let r;for(it(t-257,5),it(e-1,5),it(n-4,4),r=0;n>r;r++)it(O[2*l.Pt[r]+1],3);ct(j,t-1),ct(F,e-1)})(q.St+1,G.St+1,o+1),at(j,F)):wt(e,n,r),et(),r&&ut()})(0>V?-1:V,E-V,e),V=E,r.Qt()}function dt(){let t,e,n,s;do{if(s=v-P-E,0===s&&0===E&&0===P)s=u;else if(-1==s)s--;else if(E>=u+u-m){g.set(g.subarray(u,u+u),0),T-=u,E-=u,V-=u,t=_,n=t;do{e=65535&C[--n],C[n]=u>e?0:e-u}while(0!=--t);t=u,n=t;do{e=65535&S[--n],S[n]=u>e?0:e-u}while(0!=--t);s+=u}if(0===r.Xt)return;t=r.Yt(g,E+P,s),P+=t,3>P||(z=255&g[E],z=(z<<A^255&g[E+1])&x)}while(m>P&&0!==r.Xt)}function pt(t){let e,n,r=U,s=E,i=R;const o=E>u-m?E-(u-m):0;let c=N;const f=h,l=E+258;let a=g[s+i-1],w=g[s+i];L>R||(r>>=2),c>P&&(c=P);do{if(e=t,g[e+i]==w&&g[e+i-1]==a&&g[e]==g[s]&&g[++e]==g[s+1]){s+=2,e++;do{}while(g[++s]==g[++e]&&g[++s]==g[++e]&&g[++s]==g[++e]&&g[++s]==g[++e]&&g[++s]==g[++e]&&g[++s]==g[++e]&&g[++s]==g[++e]&&g[++s]==g[++e]&&l>s);if(n=258-(l-s),s=l-258,n>i){if(T=t,i=n,n>=c)break;a=g[s+i-1],w=g[s+i]}}}while((t=65535&S[t&f])>o&&0!=--r);return i>P?P:i}t.kt=[],t.xt=[],t.yt=[],j=[],F=[],O=[],t.Ct=(e,n)=>{const r=t.yt,s=r[n];let i=n<<1;for(;i<=t.dt&&(i<t.dt&&k(e,r[i+1],r[i],t.kt)&&i++,!k(e,s,r[i],t.kt));)r[n]=r[i],n=i,i<<=1;r[n]=s},t.Zt=(r,l,p,y,m,k)=>(y||(y=8),m||(m=8),k||(k=0),r.$t=null,-1==l&&(l=6),1>m||m>9||8!=y||9>p||p>15||0>l||l>9||0>k||k>2?e:(r.te=t,w=p,u=1<<w,h=u-1,I=m+7,_=1<<I,x=_-1,A=n.floor((I+3-1)/3),g=new s(2*u),S=[],C=[],Q=1<<m+6,t.qt=new s(4*Q),c=4*Q,t.Gt=new i(Q),t.Jt=new s(Q),H=l,K=k,(e=>(e.ee=e.ne=0,e.$t=null,t.pending=0,t.re=0,o=b,f=0,q.lt=j,q.wt=a.jt,G.lt=F,G.wt=a.Ft,J.lt=O,J.wt=a.Ot,$=0,tt=0,Z=8,et(),(()=>{v=2*u,C[_-1]=0;for(let t=0;_-1>t;t++)C[t]=0;W=d[H].Wt,L=d[H].Ut,N=d[H].Ht,U=d[H].Kt,E=0,V=0,P=0,M=R=2,D=0,z=0})(),0))(r))),t.se=()=>42!=o&&o!=b&&o!=y?e:(t.Jt=null,t.Gt=null,t.qt=null,C=null,S=null,g=null,t.te=null,o==b?-3:0),t.ie=(t,n,r)=>{let s=0;return-1==n&&(n=6),0>n||n>9||0>r||r>2?e:(d[H].Lt!=d[n].Lt&&0!==t.ee&&(s=t.oe(1)),H!=n&&(H=n,W=d[H].Wt,L=d[H].Ut,N=d[H].Ht,U=d[H].Kt),K=r,s)},t.ce=(t,n,r)=>{let s,i=r,c=0;if(!n||42!=o)return e;if(3>i)return 0;for(i>u-m&&(i=u-m,c=r-i),g.set(n.subarray(c,c+i),0),E=i,V=i,z=255&g[0],z=(z<<A^255&g[1])&x,s=0;i-3>=s;s++)z=(z<<A^255&g[s+2])&x,S[s&h]=C[z],C[z]=s;return 0},t.oe=(n,s)=>{let i,l,k,v,I;if(s>4||0>s)return e;if(!n.fe||!n.le&&0!==n.Xt||o==y&&4!=s)return n.$t=p[4],e;if(0===n.ae)return n.$t=p[7],-5;var U;if(r=n,v=f,f=s,42==o&&(l=8+(w-8<<4)<<8,k=(H-1&255)>>1,k>3&&(k=3),l|=k<<6,0!==E&&(l|=32),l+=31-l%31,o=b,rt((U=l)>>8&255),rt(255&U)),0!==t.pending){if(r.Qt(),0===r.ae)return f=-1,0}else if(0===r.Xt&&v>=s&&4!=s)return r.$t=p[7],-5;if(o==y&&0!==r.Xt)return n.$t=p[7],-5;if(0!==r.Xt||0!==P||0!=s&&o!=y){switch(I=-1,d[H].Lt){case 0:I=(t=>{let e,n=65535;for(n>c-5&&(n=c-5);;){if(1>=P){if(dt(),0===P&&0==t)return 0;if(0===P)break}if(E+=P,P=0,e=V+n,(0===E||E>=e)&&(P=E-e,E=e,ht(!1),0===r.ae))return 0;if(E-V>=u-m&&(ht(!1),0===r.ae))return 0}return ht(4==t),0===r.ae?4==t?2:0:4==t?3:1})(s);break;case 1:I=(t=>{let e,n=0;for(;;){if(m>P){if(dt(),m>P&&0==t)return 0;if(0===P)break}if(3>P||(z=(z<<A^255&g[E+2])&x,n=65535&C[z],S[E&h]=C[z],C[z]=E),0===n||(E-n&65535)>u-m||2!=K&&(M=pt(n)),3>M)e=lt(0,255&g[E]),P--,E++;else if(e=lt(E-T,M-3),P-=M,M>W||3>P)E+=M,M=0,z=255&g[E],z=(z<<A^255&g[E+1])&x;else{M--;do{E++,z=(z<<A^255&g[E+2])&x,n=65535&C[z],S[E&h]=C[z],C[z]=E}while(0!=--M);E++}if(e&&(ht(!1),0===r.ae))return 0}return ht(4==t),0===r.ae?4==t?2:0:4==t?3:1})(s);break;case 2:I=(t=>{let e,n,s=0;for(;;){if(m>P){if(dt(),m>P&&0==t)return 0;if(0===P)break}if(3>P||(z=(z<<A^255&g[E+2])&x,s=65535&C[z],S[E&h]=C[z],C[z]=E),R=M,B=T,M=2,0!==s&&W>R&&u-m>=(E-s&65535)&&(2!=K&&(M=pt(s)),5>=M&&(1==K||3==M&&E-T>4096)&&(M=2)),3>R||M>R)if(0!==D){if(e=lt(0,255&g[E-1]),e&&ht(!1),E++,P--,0===r.ae)return 0}else D=1,E++,P--;else{n=E+P-3,e=lt(E-1-B,R-3),P-=R-1,R-=2;do{++E>n||(z=(z<<A^255&g[E+2])&x,s=65535&C[z],S[E&h]=C[z],C[z]=E)}while(0!=--R);if(D=0,M=2,E++,e&&(ht(!1),0===r.ae))return 0}}return 0!==D&&(e=lt(0,255&g[E-1]),D=0),ht(4==t),0===r.ae?4==t?2:0:4==t?3:1})(s)}if(2!=I&&3!=I||(o=y),0==I||2==I)return 0===r.ae&&(f=-1),0;if(1==I){if(1==s)it(2,3),ot(256,a.Rt),ft(),9>1+Z+10-tt&&(it(2,3),ot(256,a.Rt),ft()),Z=7;else if(wt(0,0,!1),3==s)for(i=0;_>i;i++)C[i]=0;if(r.Qt(),0===r.ae)return f=-1,0}}return 4!=s?0:1}}function v(){const t=this;t.ue=0,t.we=0,t.Xt=0,t.ee=0,t.ae=0,t.ne=0}return v.prototype={Zt(t,e){const n=this;return n.te=new g,e||(e=15),n.te.Zt(n,t,e)},oe(t){const n=this;return n.te?n.te.oe(n,t):e},se(){const t=this;if(!t.te)return e;const n=t.te.se();return t.te=null,n},ie(t,n){const r=this;return r.te?r.te.ie(r,t,n):e},ce(t,n){const r=this;return r.te?r.te.ce(r,t,n):e},Yt(t,e,n){const r=this;let s=r.Xt;return s>n&&(s=n),0===s?0:(r.Xt-=s,t.set(r.le.subarray(r.ue,r.ue+s),e),r.ue+=s,r.ee+=s,s)},Qt(){const t=this;let e=t.te.pending;e>t.ae&&(e=t.ae),0!==e&&(t.fe.set(t.te.qt.subarray(t.te.re,t.te.re+e),t.we),t.we+=e,t.te.re+=e,t.ne+=e,t.ae-=e,t.te.pending-=e,0===t.te.pending&&(t.te.re=0))}},function(t){const e=new v,i=(o=t&&t.chunkSize?t.chunkSize:65536)+5*(n.floor(o/16383)+1);var o;const c=new s(i);let f=t?t.level:-1;void 0===f&&(f=-1),e.Zt(f),e.fe=c,this.append=(t,n)=>{let o,f,l=0,a=0,u=0;const w=[];if(t.length){e.ue=0,e.le=t,e.Xt=t.length;do{if(e.we=0,e.ae=i,o=e.oe(0),0!=o)throw new r("deflating: "+e.$t);e.we&&(e.we==i?w.push(new s(c)):w.push(c.slice(0,e.we))),u+=e.we,n&&e.ue>0&&e.ue!=l&&(n(e.ue),l=e.ue)}while(e.Xt>0||0===e.ae);return w.length>1?(f=new s(u),w.forEach((t=>{f.set(t,a),a+=t.length}))):f=w[0]||new s,f}},this.flush=()=>{let t,n,o=0,f=0;const l=[];do{if(e.we=0,e.ae=i,t=e.oe(4),1!=t&&0!=t)throw new r("deflating: "+e.$t);i-e.ae>0&&l.push(c.slice(0,e.we)),f+=e.we}while(e.Xt>0||0===e.ae);return e.se(),n=new s(f),l.forEach((t=>{n.set(t,o),o+=t.length})),n}}})(),_t=(()=>{const t=-2,e=-3,i=-5,o=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],f=[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],l=[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],a=[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],u=[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],w=[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],h=[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];function d(){let t,n,r,s,o,f;function l(t,n,c,l,a,u,w,h,d,p,b){let y,m,k,g,v,S,C,z,_,I,x,A,V,M,B;I=0,v=c;do{r[t[n+I]]++,I++,v--}while(0!==v);if(r[0]==c)return w[0]=-1,h[0]=0,0;for(z=h[0],S=1;15>=S&&0===r[S];S++);for(C=S,S>z&&(z=S),v=15;0!==v&&0===r[v];v--);for(k=v,z>v&&(z=v),h[0]=z,M=1<<S;v>S;S++,M<<=1)if(0>(M-=r[S]))return e;if(0>(M-=r[v]))return e;for(r[v]+=M,f[1]=S=0,I=1,V=2;0!=--v;)f[V]=S+=r[I],V++,I++;v=0,I=0;do{0!==(S=t[n+I])&&(b[f[S]++]=v),I++}while(++v<c);for(c=f[k],f[0]=v=0,I=0,g=-1,A=-z,o[0]=0,x=0,B=0;k>=C;C++)for(y=r[C];0!=y--;){for(;C>A+z;){if(g++,A+=z,B=k-A,B=B>z?z:B,(m=1<<(S=C-A))>y+1&&(m-=y+1,V=C,B>S))for(;++S<B&&(m<<=1)>r[++V];)m-=r[V];if(B=1<<S,p[0]+B>1440)return e;o[g]=x=p[0],p[0]+=B,0!==g?(f[g]=v,s[0]=S,s[1]=z,S=v>>>A-z,s[2]=x-o[g-1]-S,d.set(s,3*(o[g-1]+S))):w[0]=x}for(s[1]=C-A,c>I?b[I]<l?(s[0]=256>b[I]?0:96,s[2]=b[I++]):(s[0]=u[b[I]-l]+16+64,s[2]=a[b[I++]-l]):s[0]=192,m=1<<C-A,S=v>>>A;B>S;S+=m)d.set(s,3*(x+S));for(S=1<<C-1;0!=(v&S);S>>>=1)v^=S;for(v^=S,_=(1<<A)-1;(v&_)!=f[g];)g--,A-=z,_=(1<<A)-1}return 0!==M&&1!=k?i:0}function d(e){let i;for(t||(t=[],n=[],r=new c(16),s=[],o=new c(15),f=new c(16)),n.length<e&&(n=[]),i=0;e>i;i++)n[i]=0;for(i=0;16>i;i++)r[i]=0;for(i=0;3>i;i++)s[i]=0;o.set(r.subarray(0,15),0),f.set(r.subarray(0,16),0)}this.he=(r,s,o,c,f)=>{let a;return d(19),t[0]=0,a=l(r,0,19,19,null,null,o,s,c,t,n),a==e?f.$t="oversubscribed dynamic bit lengths tree":a!=i&&0!==s[0]||(f.$t="incomplete dynamic bit lengths tree",a=e),a},this.de=(r,s,o,c,f,p,b,y,m)=>{let k;return d(288),t[0]=0,k=l(o,0,r,257,a,u,p,c,y,t,n),0!=k||0===c[0]?(k==e?m.$t="oversubscribed literal/length tree":-4!=k&&(m.$t="incomplete literal/length tree",k=e),k):(d(288),k=l(o,r,s,0,w,h,b,f,y,t,n),0!=k||0===f[0]&&r>257?(k==e?m.$t="oversubscribed distance tree":k==i?(m.$t="incomplete distance tree",k=e):-4!=k&&(m.$t="empty distance tree with lengths",k=e),k):0)}}function p(){const n=this;let r,s,i,c,f=0,l=0,a=0,u=0,w=0,h=0,d=0,p=0,b=0,y=0;function m(t,n,r,s,i,c,f,l){let a,u,w,h,d,p,b,y,m,k,g,v,S,C,z,_;b=l.ue,y=l.Xt,d=f.pe,p=f.be,m=f.write,k=m<f.read?f.read-m-1:f.end-m,g=o[t],v=o[n];do{for(;20>p;)y--,d|=(255&l.ye(b++))<<p,p+=8;if(a=d&g,u=r,w=s,_=3*(w+a),0!==(h=u[_]))for(;;){if(d>>=u[_+1],p-=u[_+1],0!=(16&h)){for(h&=15,S=u[_+2]+(d&o[h]),d>>=h,p-=h;15>p;)y--,d|=(255&l.ye(b++))<<p,p+=8;for(a=d&v,u=i,w=c,_=3*(w+a),h=u[_];;){if(d>>=u[_+1],p-=u[_+1],0!=(16&h)){for(h&=15;h>p;)y--,d|=(255&l.ye(b++))<<p,p+=8;if(C=u[_+2]+(d&o[h]),d>>=h,p-=h,k-=S,C>m){z=m-C;do{z+=f.end}while(0>z);if(h=f.end-z,S>h){if(S-=h,m-z>0&&h>m-z)do{f.me[m++]=f.me[z++]}while(0!=--h);else f.me.set(f.me.subarray(z,z+h),m),m+=h,z+=h,h=0;z=0}}else z=m-C,m-z>0&&2>m-z?(f.me[m++]=f.me[z++],f.me[m++]=f.me[z++],S-=2):(f.me.set(f.me.subarray(z,z+2),m),m+=2,z+=2,S-=2);if(m-z>0&&S>m-z)do{f.me[m++]=f.me[z++]}while(0!=--S);else f.me.set(f.me.subarray(z,z+S),m),m+=S,z+=S,S=0;break}if(0!=(64&h))return l.$t="invalid distance code",S=l.Xt-y,S=S>p>>3?p>>3:S,y+=S,b-=S,p-=S<<3,f.pe=d,f.be=p,l.Xt=y,l.ee+=b-l.ue,l.ue=b,f.write=m,e;a+=u[_+2],a+=d&o[h],_=3*(w+a),h=u[_]}break}if(0!=(64&h))return 0!=(32&h)?(S=l.Xt-y,S=S>p>>3?p>>3:S,y+=S,b-=S,p-=S<<3,f.pe=d,f.be=p,l.Xt=y,l.ee+=b-l.ue,l.ue=b,f.write=m,1):(l.$t="invalid literal/length code",S=l.Xt-y,S=S>p>>3?p>>3:S,y+=S,b-=S,p-=S<<3,f.pe=d,f.be=p,l.Xt=y,l.ee+=b-l.ue,l.ue=b,f.write=m,e);if(a+=u[_+2],a+=d&o[h],_=3*(w+a),0===(h=u[_])){d>>=u[_+1],p-=u[_+1],f.me[m++]=u[_+2],k--;break}}else d>>=u[_+1],p-=u[_+1],f.me[m++]=u[_+2],k--}while(k>=258&&y>=10);return S=l.Xt-y,S=S>p>>3?p>>3:S,y+=S,b-=S,p-=S<<3,f.pe=d,f.be=p,l.Xt=y,l.ee+=b-l.ue,l.ue=b,f.write=m,0}n.init=(t,e,n,o,f,l)=>{r=0,d=t,p=e,i=n,b=o,c=f,y=l,s=null},n.ke=(n,k,g)=>{let v,S,C,z,_,I,x,A=0,V=0,M=0;for(M=k.ue,z=k.Xt,A=n.pe,V=n.be,_=n.write,I=_<n.read?n.read-_-1:n.end-_;;)switch(r){case 0:if(I>=258&&z>=10&&(n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,g=m(d,p,i,b,c,y,n,k),M=k.ue,z=k.Xt,A=n.pe,V=n.be,_=n.write,I=_<n.read?n.read-_-1:n.end-_,0!=g)){r=1==g?7:9;break}a=d,s=i,l=b,r=1;case 1:for(v=a;v>V;){if(0===z)return n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);g=0,z--,A|=(255&k.ye(M++))<<V,V+=8}if(S=3*(l+(A&o[v])),A>>>=s[S+1],V-=s[S+1],C=s[S],0===C){u=s[S+2],r=6;break}if(0!=(16&C)){w=15&C,f=s[S+2],r=2;break}if(0==(64&C)){a=C,l=S/3+s[S+2];break}if(0!=(32&C)){r=7;break}return r=9,k.$t="invalid literal/length code",g=e,n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);case 2:for(v=w;v>V;){if(0===z)return n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);g=0,z--,A|=(255&k.ye(M++))<<V,V+=8}f+=A&o[v],A>>=v,V-=v,a=p,s=c,l=y,r=3;case 3:for(v=a;v>V;){if(0===z)return n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);g=0,z--,A|=(255&k.ye(M++))<<V,V+=8}if(S=3*(l+(A&o[v])),A>>=s[S+1],V-=s[S+1],C=s[S],0!=(16&C)){w=15&C,h=s[S+2],r=4;break}if(0==(64&C)){a=C,l=S/3+s[S+2];break}return r=9,k.$t="invalid distance code",g=e,n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);case 4:for(v=w;v>V;){if(0===z)return n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);g=0,z--,A|=(255&k.ye(M++))<<V,V+=8}h+=A&o[v],A>>=v,V-=v,r=5;case 5:for(x=_-h;0>x;)x+=n.end;for(;0!==f;){if(0===I&&(_==n.end&&0!==n.read&&(_=0,I=_<n.read?n.read-_-1:n.end-_),0===I&&(n.write=_,g=n.ge(k,g),_=n.write,I=_<n.read?n.read-_-1:n.end-_,_==n.end&&0!==n.read&&(_=0,I=_<n.read?n.read-_-1:n.end-_),0===I)))return n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);n.me[_++]=n.me[x++],I--,x==n.end&&(x=0),f--}r=0;break;case 6:if(0===I&&(_==n.end&&0!==n.read&&(_=0,I=_<n.read?n.read-_-1:n.end-_),0===I&&(n.write=_,g=n.ge(k,g),_=n.write,I=_<n.read?n.read-_-1:n.end-_,_==n.end&&0!==n.read&&(_=0,I=_<n.read?n.read-_-1:n.end-_),0===I)))return n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);g=0,n.me[_++]=u,I--,r=0;break;case 7:if(V>7&&(V-=8,z++,M--),n.write=_,g=n.ge(k,g),_=n.write,I=_<n.read?n.read-_-1:n.end-_,n.read!=n.write)return n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);r=8;case 8:return g=1,n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);case 9:return g=e,n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g);default:return g=t,n.pe=A,n.be=V,k.Xt=z,k.ee+=M-k.ue,k.ue=M,n.write=_,n.ge(k,g)}},n.ve=()=>{}}d.Se=(t,e,n,r)=>(t[0]=9,e[0]=5,n[0]=f,r[0]=l,0);const b=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function y(n,r){const f=this;let l,a=0,u=0,w=0,h=0;const y=[0],m=[0],k=new p;let g=0,v=new c(4320);const S=new d;f.be=0,f.pe=0,f.me=new s(r),f.end=r,f.read=0,f.write=0,f.reset=(t,e)=>{e&&(e[0]=0),6==a&&k.ve(t),a=0,f.be=0,f.pe=0,f.read=f.write=0},f.reset(n,null),f.ge=(t,e)=>{let n,r,s;return r=t.we,s=f.read,n=(s>f.write?f.end:f.write)-s,n>t.ae&&(n=t.ae),0!==n&&e==i&&(e=0),t.ae-=n,t.ne+=n,t.fe.set(f.me.subarray(s,s+n),r),r+=n,s+=n,s==f.end&&(s=0,f.write==f.end&&(f.write=0),n=f.write-s,n>t.ae&&(n=t.ae),0!==n&&e==i&&(e=0),t.ae-=n,t.ne+=n,t.fe.set(f.me.subarray(s,s+n),r),r+=n,s+=n),t.we=r,f.read=s,e},f.ke=(n,r)=>{let s,i,c,p,C,z,_,I;for(p=n.ue,C=n.Xt,i=f.pe,c=f.be,z=f.write,_=z<f.read?f.read-z-1:f.end-z;;){let x,A,V,M,B,D,E,T;switch(a){case 0:for(;3>c;){if(0===C)return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);r=0,C--,i|=(255&n.ye(p++))<<c,c+=8}switch(s=7&i,g=1&s,s>>>1){case 0:i>>>=3,c-=3,s=7&c,i>>>=s,c-=s,a=1;break;case 1:x=[],A=[],V=[[]],M=[[]],d.Se(x,A,V,M),k.init(x[0],A[0],V[0],0,M[0],0),i>>>=3,c-=3,a=6;break;case 2:i>>>=3,c-=3,a=3;break;case 3:return i>>>=3,c-=3,a=9,n.$t="invalid block type",r=e,f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r)}break;case 1:for(;32>c;){if(0===C)return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);r=0,C--,i|=(255&n.ye(p++))<<c,c+=8}if((~i>>>16&65535)!=(65535&i))return a=9,n.$t="invalid stored block lengths",r=e,f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);u=65535&i,i=c=0,a=0!==u?2:0!==g?7:0;break;case 2:if(0===C)return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);if(0===_&&(z==f.end&&0!==f.read&&(z=0,_=z<f.read?f.read-z-1:f.end-z),0===_&&(f.write=z,r=f.ge(n,r),z=f.write,_=z<f.read?f.read-z-1:f.end-z,z==f.end&&0!==f.read&&(z=0,_=z<f.read?f.read-z-1:f.end-z),0===_)))return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);if(r=0,s=u,s>C&&(s=C),s>_&&(s=_),f.me.set(n.Yt(p,s),z),p+=s,C-=s,z+=s,_-=s,0!=(u-=s))break;a=0!==g?7:0;break;case 3:for(;14>c;){if(0===C)return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);r=0,C--,i|=(255&n.ye(p++))<<c,c+=8}if(w=s=16383&i,(31&s)>29||(s>>5&31)>29)return a=9,n.$t="too many length or distance symbols",r=e,f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);if(s=258+(31&s)+(s>>5&31),!l||l.length<s)l=[];else for(I=0;s>I;I++)l[I]=0;i>>>=14,c-=14,h=0,a=4;case 4:for(;4+(w>>>10)>h;){for(;3>c;){if(0===C)return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);r=0,C--,i|=(255&n.ye(p++))<<c,c+=8}l[b[h++]]=7&i,i>>>=3,c-=3}for(;19>h;)l[b[h++]]=0;if(y[0]=7,s=S.he(l,y,m,v,n),0!=s)return(r=s)==e&&(l=null,a=9),f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);h=0,a=5;case 5:for(;s=w,258+(31&s)+(s>>5&31)>h;){let t,u;for(s=y[0];s>c;){if(0===C)return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);r=0,C--,i|=(255&n.ye(p++))<<c,c+=8}if(s=v[3*(m[0]+(i&o[s]))+1],u=v[3*(m[0]+(i&o[s]))+2],16>u)i>>>=s,c-=s,l[h++]=u;else{for(I=18==u?7:u-14,t=18==u?11:3;s+I>c;){if(0===C)return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);r=0,C--,i|=(255&n.ye(p++))<<c,c+=8}if(i>>>=s,c-=s,t+=i&o[I],i>>>=I,c-=I,I=h,s=w,I+t>258+(31&s)+(s>>5&31)||16==u&&1>I)return l=null,a=9,n.$t="invalid bit length repeat",r=e,f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);u=16==u?l[I-1]:0;do{l[I++]=u}while(0!=--t);h=I}}if(m[0]=-1,B=[],D=[],E=[],T=[],B[0]=9,D[0]=6,s=w,s=S.de(257+(31&s),1+(s>>5&31),l,B,D,E,T,v,n),0!=s)return s==e&&(l=null,a=9),r=s,f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);k.init(B[0],D[0],v,E[0],v,T[0]),a=6;case 6:if(f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,1!=(r=k.ke(f,n,r)))return f.ge(n,r);if(r=0,k.ve(n),p=n.ue,C=n.Xt,i=f.pe,c=f.be,z=f.write,_=z<f.read?f.read-z-1:f.end-z,0===g){a=0;break}a=7;case 7:if(f.write=z,r=f.ge(n,r),z=f.write,_=z<f.read?f.read-z-1:f.end-z,f.read!=f.write)return f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);a=8;case 8:return r=1,f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);case 9:return r=e,f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r);default:return r=t,f.pe=i,f.be=c,n.Xt=C,n.ee+=p-n.ue,n.ue=p,f.write=z,f.ge(n,r)}}},f.ve=t=>{f.reset(t,null),f.me=null,v=null},f.Ce=(t,e,n)=>{f.me.set(t.subarray(e,e+n),0),f.read=f.write=n},f.ze=()=>1==a?1:0}const m=13,k=[0,0,255,255];function g(){const n=this;function r(e){return e&&e._e?(e.ee=e.ne=0,e.$t=null,e._e.mode=7,e._e.Ie.reset(e,null),0):t}n.mode=0,n.method=0,n.xe=[0],n.Ae=0,n.marker=0,n.Ve=0,n.Me=t=>(n.Ie&&n.Ie.ve(t),n.Ie=null,0),n.Be=(e,s)=>(e.$t=null,n.Ie=null,8>s||s>15?(n.Me(e),t):(n.Ve=s,e._e.Ie=new y(e,1<<s),r(e),0)),n.De=(n,r)=>{let s,o;if(!n||!n._e||!n.le)return t;const c=n._e;for(r=4==r?i:0,s=i;;)switch(c.mode){case 0:if(0===n.Xt)return s;if(s=r,n.Xt--,n.ee++,8!=(15&(c.method=n.ye(n.ue++)))){c.mode=m,n.$t="unknown compression method",c.marker=5;break}if(8+(c.method>>4)>c.Ve){c.mode=m,n.$t="invalid win size",c.marker=5;break}c.mode=1;case 1:if(0===n.Xt)return s;if(s=r,n.Xt--,n.ee++,o=255&n.ye(n.ue++),((c.method<<8)+o)%31!=0){c.mode=m,n.$t="incorrect header check",c.marker=5;break}if(0==(32&o)){c.mode=7;break}c.mode=2;case 2:if(0===n.Xt)return s;s=r,n.Xt--,n.ee++,c.Ae=(255&n.ye(n.ue++))<<24&4278190080,c.mode=3;case 3:if(0===n.Xt)return s;s=r,n.Xt--,n.ee++,c.Ae+=(255&n.ye(n.ue++))<<16&16711680,c.mode=4;case 4:if(0===n.Xt)return s;s=r,n.Xt--,n.ee++,c.Ae+=(255&n.ye(n.ue++))<<8&65280,c.mode=5;case 5:return 0===n.Xt?s:(s=r,n.Xt--,n.ee++,c.Ae+=255&n.ye(n.ue++),c.mode=6,2);case 6:return c.mode=m,n.$t="need dictionary",c.marker=0,t;case 7:if(s=c.Ie.ke(n,s),s==e){c.mode=m,c.marker=0;break}if(0==s&&(s=r),1!=s)return s;s=r,c.Ie.reset(n,c.xe),c.mode=12;case 12:return n.Xt=0,1;case m:return e;default:return t}},n.Ee=(e,n,r)=>{let s=0,i=r;if(!e||!e._e||6!=e._e.mode)return t;const o=e._e;return i<1<<o.Ve||(i=(1<<o.Ve)-1,s=r-i),o.Ie.Ce(n,s,i),o.mode=7,0},n.Te=n=>{let s,o,c,f,l;if(!n||!n._e)return t;const a=n._e;if(a.mode!=m&&(a.mode=m,a.marker=0),0===(s=n.Xt))return i;for(o=n.ue,c=a.marker;0!==s&&4>c;)n.ye(o)==k[c]?c++:c=0!==n.ye(o)?0:4-c,o++,s--;return n.ee+=o-n.ue,n.ue=o,n.Xt=s,a.marker=c,4!=c?e:(f=n.ee,l=n.ne,r(n),n.ee=f,n.ne=l,a.mode=7,0)},n.Pe=e=>e&&e._e&&e._e.Ie?e._e.Ie.ze():t}function v(){}return v.prototype={Be(t){const e=this;return e._e=new g,t||(t=15),e._e.Be(e,t)},De(e){const n=this;return n._e?n._e.De(n,e):t},Me(){const e=this;if(!e._e)return t;const n=e._e.Me(e);return e._e=null,n},Te(){const e=this;return e._e?e._e.Te(e):t},Ee(e,n){const r=this;return r._e?r._e.Ee(r,e,n):t},ye(t){return this.le[t]},Yt(t,e){return this.le.subarray(t,t+e)}},function(t){const e=new v,o=t&&t.chunkSize?n.floor(2*t.chunkSize):131072,c=new s(o);let f=!1;e.Be(),e.fe=c,this.append=(t,n)=>{const l=[];let a,u,w=0,h=0,d=0;if(0!==t.length){e.ue=0,e.le=t,e.Xt=t.length;do{if(e.we=0,e.ae=o,0!==e.Xt||f||(e.ue=0,f=!0),a=e.De(0),f&&a===i){if(0!==e.Xt)throw new r("inflating: bad input")}else if(0!==a&&1!==a)throw new r("inflating: "+e.$t);if((f||1===a)&&e.Xt===t.length)throw new r("inflating: bad input");e.we&&(e.we===o?l.push(new s(c)):l.push(c.slice(0,e.we))),d+=e.we,n&&e.ue>0&&e.ue!=w&&(n(e.ue),w=e.ue)}while(e.Xt>0||0===e.ae);return l.length>1?(u=new s(d),l.forEach((t=>{u.set(t,h),h+=t.length}))):u=l[0]||new s,u}},this.flush=()=>{e.Me()}}})();self.initCodec=()=>{self.Deflate=zt,self.Inflate=_t};\n'],{type:"text/javascript"}));e({workerScripts:{inflate:[t],deflate:[t]}});}};
|
|
108
|
-
|
|
109
|
-
/*
|
|
110
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
111
|
-
|
|
112
|
-
Redistribution and use in source and binary forms, with or without
|
|
113
|
-
modification, are permitted provided that the following conditions are met:
|
|
114
|
-
|
|
115
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
116
|
-
this list of conditions and the following disclaimer.
|
|
117
|
-
|
|
118
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
119
|
-
notice, this list of conditions and the following disclaimer in
|
|
120
|
-
the documentation and/or other materials provided with the distribution.
|
|
121
|
-
|
|
122
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
123
|
-
derived from this software without specific prior written permission.
|
|
124
|
-
|
|
125
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
126
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
127
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
128
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
129
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
130
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
131
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
132
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
133
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
134
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
function getMimeType() {
|
|
138
|
-
return "application/octet-stream";
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/*
|
|
142
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
143
|
-
|
|
144
|
-
Redistribution and use in source and binary forms, with or without
|
|
145
|
-
modification, are permitted provided that the following conditions are met:
|
|
146
|
-
|
|
147
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
148
|
-
this list of conditions and the following disclaimer.
|
|
149
|
-
|
|
150
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
151
|
-
notice, this list of conditions and the following disclaimer in
|
|
152
|
-
the documentation and/or other materials provided with the distribution.
|
|
153
|
-
|
|
154
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
155
|
-
derived from this software without specific prior written permission.
|
|
156
|
-
|
|
157
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
158
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
159
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
160
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
161
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
162
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
163
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
164
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
165
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
166
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
167
|
-
*/
|
|
168
|
-
|
|
169
|
-
var streamCodecShim = (library, options = {}, registerDataHandler) => {
|
|
170
|
-
return {
|
|
171
|
-
Deflate: createCodecClass(library.Deflate, options.deflate, registerDataHandler),
|
|
172
|
-
Inflate: createCodecClass(library.Inflate, options.inflate, registerDataHandler)
|
|
173
|
-
};
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
function createCodecClass(constructor, constructorOptions, registerDataHandler) {
|
|
177
|
-
return class {
|
|
178
|
-
|
|
179
|
-
constructor(options) {
|
|
180
|
-
const codecAdapter = this;
|
|
181
|
-
const onData = data => {
|
|
182
|
-
if (codecAdapter.pendingData) {
|
|
183
|
-
const { pendingData } = codecAdapter;
|
|
184
|
-
codecAdapter.pendingData = new Uint8Array(pendingData.length + data.length);
|
|
185
|
-
pendingData.set(pendingData, 0);
|
|
186
|
-
pendingData.set(data, pendingData.length);
|
|
187
|
-
} else {
|
|
188
|
-
codecAdapter.pendingData = new Uint8Array(data);
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
if (Object.hasOwn(options, "level") && options.level === undefined) {
|
|
192
|
-
delete options.level;
|
|
193
|
-
}
|
|
194
|
-
codecAdapter.codec = new constructor(Object.assign({}, constructorOptions, options));
|
|
195
|
-
registerDataHandler(codecAdapter.codec, onData);
|
|
196
|
-
}
|
|
197
|
-
append(data) {
|
|
198
|
-
this.codec.push(data);
|
|
199
|
-
return getResponse(this);
|
|
200
|
-
}
|
|
201
|
-
flush() {
|
|
202
|
-
this.codec.push(new Uint8Array(), true);
|
|
203
|
-
return getResponse(this);
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
function getResponse(codec) {
|
|
208
|
-
if (codec.pendingData) {
|
|
209
|
-
const output = codec.pendingData;
|
|
210
|
-
codec.pendingData = null;
|
|
211
|
-
return output;
|
|
212
|
-
} else {
|
|
213
|
-
return new Uint8Array();
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
7
|
+
const { Array, Object, String, Number, BigInt, Math, Date, Map, Set, Response, URL, Error, Uint8Array, Uint16Array, Uint32Array, DataView, Blob, Promise, TextEncoder, TextDecoder, document, crypto, btoa, TransformStream, ReadableStream, WritableStream, CompressionStream, DecompressionStream, navigator } = globalThis;
|
|
217
8
|
|
|
218
9
|
/*
|
|
219
10
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
@@ -306,17 +97,15 @@
|
|
|
306
97
|
class Crc32Stream extends TransformStream {
|
|
307
98
|
|
|
308
99
|
constructor() {
|
|
100
|
+
const crc32 = new Crc32();
|
|
309
101
|
super({
|
|
310
|
-
start() {
|
|
311
|
-
this.crc32 = new Crc32();
|
|
312
|
-
},
|
|
313
102
|
transform(chunk) {
|
|
314
|
-
|
|
103
|
+
crc32.append(chunk);
|
|
315
104
|
},
|
|
316
105
|
flush(controller) {
|
|
317
106
|
const value = new Uint8Array(4);
|
|
318
107
|
const dataView = new DataView(value.buffer);
|
|
319
|
-
dataView.setUint32(0,
|
|
108
|
+
dataView.setUint32(0, crc32.get());
|
|
320
109
|
controller.enqueue(value);
|
|
321
110
|
}
|
|
322
111
|
});
|
|
@@ -1219,6 +1008,7 @@
|
|
|
1219
1008
|
const GET_RANDOM_VALUES_SUPPORTED = typeof crypto != "undefined" && typeof crypto.getRandomValues == "function";
|
|
1220
1009
|
|
|
1221
1010
|
const ERR_INVALID_PASSWORD = "Invalid password";
|
|
1011
|
+
const ERR_INVALID_SIGNATURE = "Invalid signature";
|
|
1222
1012
|
|
|
1223
1013
|
function getRandomValues(array) {
|
|
1224
1014
|
if (GET_RANDOM_VALUES_SUPPORTED) {
|
|
@@ -1268,12 +1058,13 @@
|
|
|
1268
1058
|
const KEY_LENGTH = [16, 24, 32];
|
|
1269
1059
|
const SIGNATURE_LENGTH = 10;
|
|
1270
1060
|
const COUNTER_DEFAULT_VALUE = [0, 0, 0, 0];
|
|
1271
|
-
const UNDEFINED_TYPE
|
|
1061
|
+
const UNDEFINED_TYPE = "undefined";
|
|
1272
1062
|
const FUNCTION_TYPE = "function";
|
|
1273
|
-
const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE
|
|
1274
|
-
const
|
|
1275
|
-
const
|
|
1276
|
-
const
|
|
1063
|
+
const CRYPTO_API_SUPPORTED = typeof crypto != UNDEFINED_TYPE;
|
|
1064
|
+
const subtle = CRYPTO_API_SUPPORTED && crypto.subtle;
|
|
1065
|
+
const SUBTLE_API_SUPPORTED = CRYPTO_API_SUPPORTED && typeof subtle != UNDEFINED_TYPE;
|
|
1066
|
+
const IMPORT_KEY_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.importKey == FUNCTION_TYPE;
|
|
1067
|
+
const DERIVE_BITS_SUPPORTED = CRYPTO_API_SUPPORTED && SUBTLE_API_SUPPORTED && typeof subtle.deriveBits == FUNCTION_TYPE;
|
|
1277
1068
|
const codecBytes = codec.bytes;
|
|
1278
1069
|
const Aes = cipher.aes;
|
|
1279
1070
|
const CtrGladman = mode.ctrGladman;
|
|
@@ -1282,7 +1073,6 @@
|
|
|
1282
1073
|
class AESDecryptionStream extends TransformStream {
|
|
1283
1074
|
|
|
1284
1075
|
constructor(password, signed, strength) {
|
|
1285
|
-
let stream;
|
|
1286
1076
|
super({
|
|
1287
1077
|
start() {
|
|
1288
1078
|
Object.assign(this, {
|
|
@@ -1295,47 +1085,51 @@
|
|
|
1295
1085
|
},
|
|
1296
1086
|
async transform(chunk, controller) {
|
|
1297
1087
|
const aesCrypto = this;
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1088
|
+
const {
|
|
1089
|
+
password,
|
|
1090
|
+
strength,
|
|
1091
|
+
resolveReady,
|
|
1092
|
+
ready
|
|
1093
|
+
} = aesCrypto;
|
|
1094
|
+
if (password) {
|
|
1095
|
+
await createDecryptionKeys(aesCrypto, strength, password, subarray(chunk, 0, SALT_LENGTH[strength] + 2));
|
|
1096
|
+
chunk = subarray(chunk, SALT_LENGTH[strength] + 2);
|
|
1097
|
+
resolveReady();
|
|
1307
1098
|
} else {
|
|
1308
|
-
await
|
|
1099
|
+
await ready;
|
|
1309
1100
|
}
|
|
1310
1101
|
const output = new Uint8Array(chunk.length - SIGNATURE_LENGTH - ((chunk.length - SIGNATURE_LENGTH) % BLOCK_LENGTH));
|
|
1311
1102
|
controller.enqueue(append(aesCrypto, chunk, output, 0, SIGNATURE_LENGTH, true));
|
|
1312
1103
|
},
|
|
1313
1104
|
async flush(controller) {
|
|
1314
|
-
const
|
|
1315
|
-
|
|
1316
|
-
|
|
1105
|
+
const {
|
|
1106
|
+
signed,
|
|
1107
|
+
ctr,
|
|
1108
|
+
hmac,
|
|
1109
|
+
pending,
|
|
1110
|
+
ready
|
|
1111
|
+
} = this;
|
|
1112
|
+
await ready;
|
|
1317
1113
|
const chunkToDecrypt = subarray(pending, 0, pending.length - SIGNATURE_LENGTH);
|
|
1318
1114
|
const originalSignature = subarray(pending, pending.length - SIGNATURE_LENGTH);
|
|
1319
1115
|
let decryptedChunkArray = new Uint8Array();
|
|
1320
1116
|
if (chunkToDecrypt.length) {
|
|
1321
1117
|
const encryptedChunk = toBits(codecBytes, chunkToDecrypt);
|
|
1322
|
-
|
|
1323
|
-
const decryptedChunk =
|
|
1118
|
+
hmac.update(encryptedChunk);
|
|
1119
|
+
const decryptedChunk = ctr.update(encryptedChunk);
|
|
1324
1120
|
decryptedChunkArray = fromBits(codecBytes, decryptedChunk);
|
|
1325
1121
|
}
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
const signature = subarray(fromBits(codecBytes, aesCrypto.hmac.digest()), 0, SIGNATURE_LENGTH);
|
|
1122
|
+
if (signed) {
|
|
1123
|
+
const signature = subarray(fromBits(codecBytes, hmac.digest()), 0, SIGNATURE_LENGTH);
|
|
1329
1124
|
for (let indexSignature = 0; indexSignature < SIGNATURE_LENGTH; indexSignature++) {
|
|
1330
1125
|
if (signature[indexSignature] != originalSignature[indexSignature]) {
|
|
1331
|
-
|
|
1126
|
+
throw new Error(ERR_INVALID_SIGNATURE);
|
|
1332
1127
|
}
|
|
1333
1128
|
}
|
|
1334
1129
|
}
|
|
1335
1130
|
controller.enqueue(decryptedChunkArray);
|
|
1336
1131
|
}
|
|
1337
1132
|
});
|
|
1338
|
-
stream = this;
|
|
1339
1133
|
}
|
|
1340
1134
|
}
|
|
1341
1135
|
|
|
@@ -1354,31 +1148,38 @@
|
|
|
1354
1148
|
},
|
|
1355
1149
|
async transform(chunk, controller) {
|
|
1356
1150
|
const aesCrypto = this;
|
|
1151
|
+
const {
|
|
1152
|
+
password,
|
|
1153
|
+
strength,
|
|
1154
|
+
resolveReady,
|
|
1155
|
+
ready
|
|
1156
|
+
} = aesCrypto;
|
|
1357
1157
|
let preamble = new Uint8Array();
|
|
1358
|
-
if (
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
preamble = await createEncryptionKeys(aesCrypto, password);
|
|
1362
|
-
aesCrypto.ctr = new CtrGladman(new Aes(aesCrypto.keys.key), Array.from(COUNTER_DEFAULT_VALUE));
|
|
1363
|
-
aesCrypto.hmac = new HmacSha1(aesCrypto.keys.authentication);
|
|
1364
|
-
aesCrypto.resolveReady();
|
|
1158
|
+
if (password) {
|
|
1159
|
+
preamble = await createEncryptionKeys(aesCrypto, strength, password);
|
|
1160
|
+
resolveReady();
|
|
1365
1161
|
} else {
|
|
1366
|
-
await
|
|
1162
|
+
await ready;
|
|
1367
1163
|
}
|
|
1368
1164
|
const output = new Uint8Array(preamble.length + chunk.length - (chunk.length % BLOCK_LENGTH));
|
|
1369
1165
|
output.set(preamble, 0);
|
|
1370
1166
|
controller.enqueue(append(aesCrypto, chunk, output, preamble.length, 0));
|
|
1371
1167
|
},
|
|
1372
1168
|
async flush(controller) {
|
|
1373
|
-
const
|
|
1374
|
-
|
|
1169
|
+
const {
|
|
1170
|
+
ctr,
|
|
1171
|
+
hmac,
|
|
1172
|
+
pending,
|
|
1173
|
+
ready
|
|
1174
|
+
} = this;
|
|
1175
|
+
await ready;
|
|
1375
1176
|
let encryptedChunkArray = new Uint8Array();
|
|
1376
|
-
if (
|
|
1377
|
-
const encryptedChunk =
|
|
1378
|
-
|
|
1177
|
+
if (pending.length) {
|
|
1178
|
+
const encryptedChunk = ctr.update(toBits(codecBytes, pending));
|
|
1179
|
+
hmac.update(encryptedChunk);
|
|
1379
1180
|
encryptedChunkArray = fromBits(codecBytes, encryptedChunk);
|
|
1380
1181
|
}
|
|
1381
|
-
stream.signature = fromBits(codecBytes,
|
|
1182
|
+
stream.signature = fromBits(codecBytes, hmac.digest()).slice(0, SIGNATURE_LENGTH);
|
|
1382
1183
|
controller.enqueue(concat(encryptedChunkArray, stream.signature));
|
|
1383
1184
|
}
|
|
1384
1185
|
});
|
|
@@ -1387,20 +1188,25 @@
|
|
|
1387
1188
|
}
|
|
1388
1189
|
|
|
1389
1190
|
function append(aesCrypto, input, output, paddingStart, paddingEnd, verifySignature) {
|
|
1191
|
+
const {
|
|
1192
|
+
ctr,
|
|
1193
|
+
hmac,
|
|
1194
|
+
pending
|
|
1195
|
+
} = aesCrypto;
|
|
1390
1196
|
const inputLength = input.length - paddingEnd;
|
|
1391
|
-
if (
|
|
1392
|
-
input = concat(
|
|
1197
|
+
if (pending.length) {
|
|
1198
|
+
input = concat(pending, input);
|
|
1393
1199
|
output = expand(output, inputLength - (inputLength % BLOCK_LENGTH));
|
|
1394
1200
|
}
|
|
1395
1201
|
let offset;
|
|
1396
1202
|
for (offset = 0; offset <= inputLength - BLOCK_LENGTH; offset += BLOCK_LENGTH) {
|
|
1397
1203
|
const inputChunk = toBits(codecBytes, subarray(input, offset, offset + BLOCK_LENGTH));
|
|
1398
1204
|
if (verifySignature) {
|
|
1399
|
-
|
|
1205
|
+
hmac.update(inputChunk);
|
|
1400
1206
|
}
|
|
1401
|
-
const outputChunk =
|
|
1207
|
+
const outputChunk = ctr.update(inputChunk);
|
|
1402
1208
|
if (!verifySignature) {
|
|
1403
|
-
|
|
1209
|
+
hmac.update(outputChunk);
|
|
1404
1210
|
}
|
|
1405
1211
|
output.set(fromBits(codecBytes, outputChunk), offset + paddingStart);
|
|
1406
1212
|
}
|
|
@@ -1408,36 +1214,44 @@
|
|
|
1408
1214
|
return output;
|
|
1409
1215
|
}
|
|
1410
1216
|
|
|
1411
|
-
async function createDecryptionKeys(decrypt,
|
|
1412
|
-
await createKeys$1(decrypt, password, subarray(
|
|
1413
|
-
const passwordVerification = subarray(
|
|
1414
|
-
const passwordVerificationKey = decrypt.keys.passwordVerification;
|
|
1217
|
+
async function createDecryptionKeys(decrypt, strength, password, preamble) {
|
|
1218
|
+
const passwordVerificationKey = await createKeys$1(decrypt, strength, password, subarray(preamble, 0, SALT_LENGTH[strength]));
|
|
1219
|
+
const passwordVerification = subarray(preamble, SALT_LENGTH[strength]);
|
|
1415
1220
|
if (passwordVerificationKey[0] != passwordVerification[0] || passwordVerificationKey[1] != passwordVerification[1]) {
|
|
1416
1221
|
throw new Error(ERR_INVALID_PASSWORD);
|
|
1417
1222
|
}
|
|
1418
1223
|
}
|
|
1419
1224
|
|
|
1420
|
-
async function createEncryptionKeys(encrypt, password) {
|
|
1421
|
-
const salt = getRandomValues(new Uint8Array(SALT_LENGTH[
|
|
1422
|
-
await createKeys$1(encrypt, password, salt);
|
|
1423
|
-
return concat(salt,
|
|
1225
|
+
async function createEncryptionKeys(encrypt, strength, password) {
|
|
1226
|
+
const salt = getRandomValues(new Uint8Array(SALT_LENGTH[strength]));
|
|
1227
|
+
const passwordVerification = await createKeys$1(encrypt, strength, password, salt);
|
|
1228
|
+
return concat(salt, passwordVerification);
|
|
1424
1229
|
}
|
|
1425
1230
|
|
|
1426
|
-
async function createKeys$1(
|
|
1231
|
+
async function createKeys$1(aesCrypto, strength, password, salt) {
|
|
1232
|
+
aesCrypto.password = null;
|
|
1427
1233
|
const encodedPassword = encodeText(password);
|
|
1428
|
-
const
|
|
1429
|
-
const derivedBits = await deriveBits(Object.assign({ salt }, DERIVED_BITS_ALGORITHM),
|
|
1234
|
+
const baseKey = await importKey(RAW_FORMAT, encodedPassword, BASE_KEY_ALGORITHM, false, DERIVED_BITS_USAGE);
|
|
1235
|
+
const derivedBits = await deriveBits(Object.assign({ salt }, DERIVED_BITS_ALGORITHM), baseKey, 8 * ((KEY_LENGTH[strength] * 2) + 2));
|
|
1430
1236
|
const compositeKey = new Uint8Array(derivedBits);
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1237
|
+
const key = toBits(codecBytes, subarray(compositeKey, 0, KEY_LENGTH[strength]));
|
|
1238
|
+
const authentication = toBits(codecBytes, subarray(compositeKey, KEY_LENGTH[strength], KEY_LENGTH[strength] * 2));
|
|
1239
|
+
const passwordVerification = subarray(compositeKey, KEY_LENGTH[strength] * 2);
|
|
1240
|
+
Object.assign(aesCrypto, {
|
|
1241
|
+
keys: {
|
|
1242
|
+
key,
|
|
1243
|
+
authentication,
|
|
1244
|
+
passwordVerification
|
|
1245
|
+
},
|
|
1246
|
+
ctr: new CtrGladman(new Aes(key), Array.from(COUNTER_DEFAULT_VALUE)),
|
|
1247
|
+
hmac: new HmacSha1(authentication)
|
|
1248
|
+
});
|
|
1249
|
+
return passwordVerification;
|
|
1436
1250
|
}
|
|
1437
1251
|
|
|
1438
1252
|
function importKey(format, password, algorithm, extractable, keyUsages) {
|
|
1439
1253
|
if (IMPORT_KEY_SUPPORTED) {
|
|
1440
|
-
return
|
|
1254
|
+
return subtle.importKey(format, password, algorithm, extractable, keyUsages);
|
|
1441
1255
|
} else {
|
|
1442
1256
|
return misc.importKey(password);
|
|
1443
1257
|
}
|
|
@@ -1445,7 +1259,7 @@
|
|
|
1445
1259
|
|
|
1446
1260
|
async function deriveBits(algorithm, baseKey, length) {
|
|
1447
1261
|
if (DERIVE_BITS_SUPPORTED) {
|
|
1448
|
-
return await
|
|
1262
|
+
return await subtle.deriveBits(algorithm, baseKey, length);
|
|
1449
1263
|
} else {
|
|
1450
1264
|
return misc.pbkdf2(baseKey, algorithm.salt, DERIVED_BITS_ALGORITHM.iterations, length);
|
|
1451
1265
|
}
|
|
@@ -1514,7 +1328,6 @@
|
|
|
1514
1328
|
class ZipCryptoDecryptionStream extends TransformStream {
|
|
1515
1329
|
|
|
1516
1330
|
constructor(password, passwordVerification) {
|
|
1517
|
-
let stream;
|
|
1518
1331
|
super({
|
|
1519
1332
|
start() {
|
|
1520
1333
|
Object.assign(this, {
|
|
@@ -1534,12 +1347,8 @@
|
|
|
1534
1347
|
chunk = chunk.subarray(HEADER_LENGTH);
|
|
1535
1348
|
}
|
|
1536
1349
|
controller.enqueue(decrypt(zipCrypto, chunk));
|
|
1537
|
-
},
|
|
1538
|
-
flush() {
|
|
1539
|
-
stream.valid = true;
|
|
1540
1350
|
}
|
|
1541
1351
|
});
|
|
1542
|
-
stream = this;
|
|
1543
1352
|
}
|
|
1544
1353
|
}
|
|
1545
1354
|
|
|
@@ -1597,21 +1406,25 @@
|
|
|
1597
1406
|
}
|
|
1598
1407
|
|
|
1599
1408
|
function createKeys(target, password) {
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1409
|
+
const keys = [0x12345678, 0x23456789, 0x34567890];
|
|
1410
|
+
Object.assign(target, {
|
|
1411
|
+
keys,
|
|
1412
|
+
crcKey0: new Crc32(keys[0]),
|
|
1413
|
+
crcKey2: new Crc32(keys[2]),
|
|
1414
|
+
});
|
|
1603
1415
|
for (let index = 0; index < password.length; index++) {
|
|
1604
1416
|
updateKeys(target, password.charCodeAt(index));
|
|
1605
1417
|
}
|
|
1606
1418
|
}
|
|
1607
1419
|
|
|
1608
1420
|
function updateKeys(target, byte) {
|
|
1421
|
+
let [key0, key1, key2] = target.keys;
|
|
1609
1422
|
target.crcKey0.append([byte]);
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
target.
|
|
1613
|
-
target.crcKey2.
|
|
1614
|
-
target.keys
|
|
1423
|
+
key0 = ~target.crcKey0.get();
|
|
1424
|
+
key1 = getInt32(Math.imul(getInt32(key1 + getInt8(key0)), 134775813) + 1);
|
|
1425
|
+
target.crcKey2.append([key1 >>> 24]);
|
|
1426
|
+
key2 = ~target.crcKey2.get();
|
|
1427
|
+
target.keys = [key0, key1, key2];
|
|
1615
1428
|
}
|
|
1616
1429
|
|
|
1617
1430
|
function getByte(target) {
|
|
@@ -1655,103 +1468,29 @@
|
|
|
1655
1468
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1656
1469
|
*/
|
|
1657
1470
|
|
|
1658
|
-
/*
|
|
1659
|
-
* This program is based on JZlib 1.0.2 ymnk, JCraft,Inc.
|
|
1660
|
-
* JZlib is based on zlib-1.1.3, so all credit should go authors
|
|
1661
|
-
* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
|
1662
|
-
* and contributors of zlib.
|
|
1663
|
-
*/
|
|
1664
|
-
|
|
1665
|
-
/* global TransformStream */
|
|
1666
|
-
|
|
1667
|
-
class CodecStream extends TransformStream {
|
|
1668
|
-
|
|
1669
|
-
constructor(Codec, options) {
|
|
1670
|
-
let codec;
|
|
1671
|
-
super({
|
|
1672
|
-
start() {
|
|
1673
|
-
codec = new Codec(options);
|
|
1674
|
-
},
|
|
1675
|
-
transform(chunk, controller) {
|
|
1676
|
-
chunk = codec.append(chunk);
|
|
1677
|
-
controller.enqueue(chunk);
|
|
1678
|
-
},
|
|
1679
|
-
flush(controller) {
|
|
1680
|
-
const chunk = codec.flush();
|
|
1681
|
-
if (chunk) {
|
|
1682
|
-
controller.enqueue(chunk);
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
});
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
/*
|
|
1690
|
-
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
1691
|
-
|
|
1692
|
-
Redistribution and use in source and binary forms, with or without
|
|
1693
|
-
modification, are permitted provided that the following conditions are met:
|
|
1694
|
-
|
|
1695
|
-
1. Redistributions of source code must retain the above copyright notice,
|
|
1696
|
-
this list of conditions and the following disclaimer.
|
|
1697
|
-
|
|
1698
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
1699
|
-
notice, this list of conditions and the following disclaimer in
|
|
1700
|
-
the documentation and/or other materials provided with the distribution.
|
|
1701
|
-
|
|
1702
|
-
3. The names of the authors may not be used to endorse or promote products
|
|
1703
|
-
derived from this software without specific prior written permission.
|
|
1704
|
-
|
|
1705
|
-
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
1706
|
-
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
1707
|
-
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
1708
|
-
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
1709
|
-
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
1710
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
1711
|
-
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
1712
|
-
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
1713
|
-
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
1714
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1715
|
-
*/
|
|
1716
|
-
|
|
1717
|
-
const ERR_INVALID_SIGNATURE = "Invalid signature";
|
|
1718
1471
|
const COMPRESSION_FORMAT = "deflate-raw";
|
|
1719
|
-
const UNDEFINED_TYPE = "undefined";
|
|
1720
|
-
const COMPRESSION_STREAM_API_SUPPORTED = typeof CompressionStream == UNDEFINED_TYPE;
|
|
1721
|
-
const DECOMPRESSION_STREAM_API_SUPPORTED = typeof DecompressionStream == UNDEFINED_TYPE;
|
|
1722
|
-
let INFLATE_RAW_SUPPORTED = true;
|
|
1723
|
-
let DEFLATE_RAW_SUPPORTED = true;
|
|
1724
1472
|
|
|
1725
1473
|
class DeflateStream extends TransformStream {
|
|
1726
1474
|
|
|
1727
|
-
constructor(
|
|
1728
|
-
super({}
|
|
1475
|
+
constructor(options, { chunkSize, CompressionStream, CompressionStreamNative }) {
|
|
1476
|
+
super({});
|
|
1729
1477
|
const { compressed, encrypted, useCompressionStream, password, passwordVerification, encryptionStrength, zipCrypto, signed, level } = options;
|
|
1730
1478
|
const stream = this;
|
|
1731
1479
|
let crc32Stream, encryptionStream;
|
|
1732
1480
|
let readable = filterEmptyChunks(super.readable);
|
|
1733
1481
|
if ((!encrypted || zipCrypto) && signed) {
|
|
1734
1482
|
[readable, crc32Stream] = readable.tee();
|
|
1735
|
-
crc32Stream =
|
|
1483
|
+
crc32Stream = pipeThrough(crc32Stream, new Crc32Stream());
|
|
1736
1484
|
}
|
|
1737
1485
|
if (compressed) {
|
|
1738
|
-
|
|
1739
|
-
readable = pipeCodecStream(codecConstructor, readable, { chunkSize, level });
|
|
1740
|
-
} else {
|
|
1741
|
-
try {
|
|
1742
|
-
readable = readable.pipeThrough(new CompressionStream(COMPRESSION_FORMAT));
|
|
1743
|
-
} catch (_error) {
|
|
1744
|
-
DEFLATE_RAW_SUPPORTED = false;
|
|
1745
|
-
readable = pipeCodecStream(codecConstructor, readable, { chunkSize, level });
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1486
|
+
readable = pipeThroughCommpressionStream(readable, useCompressionStream, { level, chunkSize }, CompressionStreamNative, CompressionStream);
|
|
1748
1487
|
}
|
|
1749
1488
|
if (encrypted) {
|
|
1750
1489
|
if (zipCrypto) {
|
|
1751
|
-
readable =
|
|
1490
|
+
readable = pipeThrough(readable, new ZipCryptoEncryptionStream(password, passwordVerification));
|
|
1752
1491
|
} else {
|
|
1753
1492
|
encryptionStream = new AESEncryptionStream(password, encryptionStrength);
|
|
1754
|
-
readable =
|
|
1493
|
+
readable = pipeThrough(readable, encryptionStream);
|
|
1755
1494
|
}
|
|
1756
1495
|
}
|
|
1757
1496
|
setReadable(stream, readable, async () => {
|
|
@@ -1770,46 +1509,31 @@
|
|
|
1770
1509
|
|
|
1771
1510
|
class InflateStream extends TransformStream {
|
|
1772
1511
|
|
|
1773
|
-
constructor(
|
|
1774
|
-
super({}
|
|
1775
|
-
const { zipCrypto, encrypted, password, passwordVerification, signed, encryptionStrength, compressed, useCompressionStream } = options;
|
|
1776
|
-
const stream = this;
|
|
1512
|
+
constructor(options, { chunkSize, DecompressionStream, DecompressionStreamNative }) {
|
|
1513
|
+
super({});
|
|
1514
|
+
const { zipCrypto, encrypted, password, passwordVerification, signed, signature, encryptionStrength, compressed, useCompressionStream } = options;
|
|
1777
1515
|
let crc32Stream, decryptionStream;
|
|
1778
1516
|
let readable = filterEmptyChunks(super.readable);
|
|
1779
1517
|
if (encrypted) {
|
|
1780
1518
|
if (zipCrypto) {
|
|
1781
|
-
readable =
|
|
1519
|
+
readable = pipeThrough(readable, new ZipCryptoDecryptionStream(password, passwordVerification));
|
|
1782
1520
|
} else {
|
|
1783
1521
|
decryptionStream = new AESDecryptionStream(password, signed, encryptionStrength);
|
|
1784
|
-
readable =
|
|
1522
|
+
readable = pipeThrough(readable, decryptionStream);
|
|
1785
1523
|
}
|
|
1786
1524
|
}
|
|
1787
1525
|
if (compressed) {
|
|
1788
|
-
|
|
1789
|
-
readable = pipeCodecStream(codecConstructor, readable, { chunkSize });
|
|
1790
|
-
} else {
|
|
1791
|
-
try {
|
|
1792
|
-
readable = readable.pipeThrough(new DecompressionStream(COMPRESSION_FORMAT));
|
|
1793
|
-
} catch (_error) {
|
|
1794
|
-
INFLATE_RAW_SUPPORTED = false;
|
|
1795
|
-
readable = pipeCodecStream(codecConstructor, readable, { chunkSize });
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1526
|
+
readable = pipeThroughCommpressionStream(readable, useCompressionStream, { chunkSize }, DecompressionStreamNative, DecompressionStream);
|
|
1798
1527
|
}
|
|
1799
1528
|
if ((!encrypted || zipCrypto) && signed) {
|
|
1800
1529
|
[readable, crc32Stream] = readable.tee();
|
|
1801
|
-
crc32Stream =
|
|
1530
|
+
crc32Stream = pipeThrough(crc32Stream, new Crc32Stream());
|
|
1802
1531
|
}
|
|
1803
|
-
setReadable(
|
|
1804
|
-
if (encrypted && !zipCrypto) {
|
|
1805
|
-
if (!decryptionStream.valid) {
|
|
1806
|
-
throw new Error(ERR_INVALID_SIGNATURE);
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1532
|
+
setReadable(this, readable, async () => {
|
|
1809
1533
|
if ((!encrypted || zipCrypto) && signed) {
|
|
1810
|
-
const
|
|
1811
|
-
const dataViewSignature = new DataView(
|
|
1812
|
-
if (
|
|
1534
|
+
const streamSignature = await crc32Stream.getReader().read();
|
|
1535
|
+
const dataViewSignature = new DataView(streamSignature.value.buffer);
|
|
1536
|
+
if (signature != dataViewSignature.getUint32(0, false)) {
|
|
1813
1537
|
throw new Error(ERR_INVALID_SIGNATURE);
|
|
1814
1538
|
}
|
|
1815
1539
|
}
|
|
@@ -1817,12 +1541,8 @@
|
|
|
1817
1541
|
}
|
|
1818
1542
|
}
|
|
1819
1543
|
|
|
1820
|
-
function pipeCodecStream(codecConstructor, readable, options) {
|
|
1821
|
-
return readable.pipeThrough(new CodecStream(codecConstructor, options));
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
1544
|
function filterEmptyChunks(readable) {
|
|
1825
|
-
return
|
|
1545
|
+
return pipeThrough(readable, new TransformStream({
|
|
1826
1546
|
transform(chunk, controller) {
|
|
1827
1547
|
if (chunk && chunk.length) {
|
|
1828
1548
|
controller.enqueue(chunk);
|
|
@@ -1832,7 +1552,7 @@
|
|
|
1832
1552
|
}
|
|
1833
1553
|
|
|
1834
1554
|
function setReadable(stream, readable, flush) {
|
|
1835
|
-
readable =
|
|
1555
|
+
readable = pipeThrough(readable, new TransformStream({ flush }));
|
|
1836
1556
|
Object.defineProperty(stream, "readable", {
|
|
1837
1557
|
get() {
|
|
1838
1558
|
return readable;
|
|
@@ -1840,6 +1560,82 @@
|
|
|
1840
1560
|
});
|
|
1841
1561
|
}
|
|
1842
1562
|
|
|
1563
|
+
function pipeThroughCommpressionStream(readable, useCompressionStream, options, CodecStreamNative, CodecStream) {
|
|
1564
|
+
try {
|
|
1565
|
+
const CompressionStream = useCompressionStream && CodecStreamNative ? CodecStreamNative : CodecStream;
|
|
1566
|
+
readable = pipeThrough(readable, new CompressionStream(COMPRESSION_FORMAT, options));
|
|
1567
|
+
} catch (error) {
|
|
1568
|
+
if (useCompressionStream) {
|
|
1569
|
+
readable = pipeThrough(readable, new CodecStream(COMPRESSION_FORMAT, options));
|
|
1570
|
+
} else {
|
|
1571
|
+
throw error;
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
return readable;
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
function pipeThrough(readable, transformStream) {
|
|
1578
|
+
return readable.pipeThrough(transformStream);
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/*
|
|
1582
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
1583
|
+
|
|
1584
|
+
Redistribution and use in source and binary forms, with or without
|
|
1585
|
+
modification, are permitted provided that the following conditions are met:
|
|
1586
|
+
|
|
1587
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
1588
|
+
this list of conditions and the following disclaimer.
|
|
1589
|
+
|
|
1590
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
1591
|
+
notice, this list of conditions and the following disclaimer in
|
|
1592
|
+
the documentation and/or other materials provided with the distribution.
|
|
1593
|
+
|
|
1594
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
1595
|
+
derived from this software without specific prior written permission.
|
|
1596
|
+
|
|
1597
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
1598
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
1599
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
1600
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
1601
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
1602
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
1603
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
1604
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
1605
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
1606
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1607
|
+
*/
|
|
1608
|
+
|
|
1609
|
+
/*
|
|
1610
|
+
* This program is based on JZlib 1.0.2 ymnk, JCraft,Inc.
|
|
1611
|
+
* JZlib is based on zlib-1.1.3, so all credit should go authors
|
|
1612
|
+
* Jean-loup Gailly(jloup@gzip.org) and Mark Adler(madler@alumni.caltech.edu)
|
|
1613
|
+
* and contributors of zlib.
|
|
1614
|
+
*/
|
|
1615
|
+
|
|
1616
|
+
/* global TransformStream */
|
|
1617
|
+
|
|
1618
|
+
class CodecStream extends TransformStream {
|
|
1619
|
+
|
|
1620
|
+
constructor(Codec, options) {
|
|
1621
|
+
let codec;
|
|
1622
|
+
super({
|
|
1623
|
+
start() {
|
|
1624
|
+
codec = new Codec(options);
|
|
1625
|
+
},
|
|
1626
|
+
transform(chunk, controller) {
|
|
1627
|
+
controller.enqueue(codec.append(chunk));
|
|
1628
|
+
},
|
|
1629
|
+
flush(controller) {
|
|
1630
|
+
const chunk = codec.flush();
|
|
1631
|
+
if (chunk) {
|
|
1632
|
+
controller.enqueue(chunk);
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
});
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1843
1639
|
/*
|
|
1844
1640
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
1845
1641
|
|
|
@@ -1879,17 +1675,16 @@
|
|
|
1879
1675
|
|
|
1880
1676
|
class Codec {
|
|
1881
1677
|
|
|
1882
|
-
constructor(
|
|
1678
|
+
constructor(readable, writable, options, config) {
|
|
1883
1679
|
const { codecType } = options;
|
|
1884
|
-
let
|
|
1680
|
+
let CodecStream;
|
|
1885
1681
|
if (codecType.startsWith(CODEC_DEFLATE)) {
|
|
1886
|
-
|
|
1682
|
+
CodecStream = DeflateStream;
|
|
1887
1683
|
} else if (codecType.startsWith(CODEC_INFLATE)) {
|
|
1888
|
-
|
|
1684
|
+
CodecStream = InflateStream;
|
|
1889
1685
|
}
|
|
1890
1686
|
Object.assign(this, {
|
|
1891
|
-
|
|
1892
|
-
CodecConstructor,
|
|
1687
|
+
CodecStream,
|
|
1893
1688
|
readable,
|
|
1894
1689
|
writable,
|
|
1895
1690
|
options,
|
|
@@ -1899,14 +1694,13 @@
|
|
|
1899
1694
|
|
|
1900
1695
|
async run() {
|
|
1901
1696
|
const {
|
|
1902
|
-
|
|
1903
|
-
CodecConstructor,
|
|
1697
|
+
CodecStream,
|
|
1904
1698
|
readable,
|
|
1905
1699
|
writable,
|
|
1906
1700
|
options,
|
|
1907
1701
|
config
|
|
1908
1702
|
} = this;
|
|
1909
|
-
const stream = new
|
|
1703
|
+
const stream = new CodecStream(options, config);
|
|
1910
1704
|
let size = 0;
|
|
1911
1705
|
await readable
|
|
1912
1706
|
.pipeThrough(stream)
|
|
@@ -1924,6 +1718,212 @@
|
|
|
1924
1718
|
}
|
|
1925
1719
|
}
|
|
1926
1720
|
|
|
1721
|
+
function getCodecStreamClass(Codec) {
|
|
1722
|
+
return class extends CodecStream {
|
|
1723
|
+
constructor(algorithm, options) {
|
|
1724
|
+
super(Codec, options);
|
|
1725
|
+
}
|
|
1726
|
+
};
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
/*
|
|
1730
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
1731
|
+
|
|
1732
|
+
Redistribution and use in source and binary forms, with or without
|
|
1733
|
+
modification, are permitted provided that the following conditions are met:
|
|
1734
|
+
|
|
1735
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
1736
|
+
this list of conditions and the following disclaimer.
|
|
1737
|
+
|
|
1738
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
1739
|
+
notice, this list of conditions and the following disclaimer in
|
|
1740
|
+
the documentation and/or other materials provided with the distribution.
|
|
1741
|
+
|
|
1742
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
1743
|
+
derived from this software without specific prior written permission.
|
|
1744
|
+
|
|
1745
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
1746
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
1747
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
1748
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
1749
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
1750
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
1751
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
1752
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
1753
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
1754
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1755
|
+
*/
|
|
1756
|
+
|
|
1757
|
+
const MINIMUM_CHUNK_SIZE = 64;
|
|
1758
|
+
const UNDEFINED_VALUE = undefined;
|
|
1759
|
+
let maxWorkers = 2;
|
|
1760
|
+
try {
|
|
1761
|
+
if (typeof navigator != "undefined" && navigator.hardwareConcurrency) {
|
|
1762
|
+
maxWorkers = navigator.hardwareConcurrency;
|
|
1763
|
+
}
|
|
1764
|
+
} catch (_error) {
|
|
1765
|
+
// ignored
|
|
1766
|
+
}
|
|
1767
|
+
const DEFAULT_CONFIGURATION = {
|
|
1768
|
+
chunkSize: 512 * 1024,
|
|
1769
|
+
maxWorkers,
|
|
1770
|
+
terminateWorkerTimeout: 5000,
|
|
1771
|
+
useWebWorkers: true,
|
|
1772
|
+
useCompressionStream: true,
|
|
1773
|
+
workerScripts: undefined,
|
|
1774
|
+
CompressionStreamNative: typeof CompressionStream != "undefined" && CompressionStream,
|
|
1775
|
+
DecompressionStreamNative: typeof DecompressionStream != "undefined" && DecompressionStream
|
|
1776
|
+
};
|
|
1777
|
+
|
|
1778
|
+
const config = Object.assign({}, DEFAULT_CONFIGURATION);
|
|
1779
|
+
|
|
1780
|
+
function getConfiguration() {
|
|
1781
|
+
return config;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
function getChunkSize(config) {
|
|
1785
|
+
return Math.max(config.chunkSize, MINIMUM_CHUNK_SIZE);
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
function configure(configuration) {
|
|
1789
|
+
const {
|
|
1790
|
+
baseURL,
|
|
1791
|
+
chunkSize,
|
|
1792
|
+
maxWorkers,
|
|
1793
|
+
terminateWorkerTimeout,
|
|
1794
|
+
useCompressionStream,
|
|
1795
|
+
useWebWorkers,
|
|
1796
|
+
Deflate,
|
|
1797
|
+
Inflate,
|
|
1798
|
+
CompressionStream,
|
|
1799
|
+
DecompressionStream,
|
|
1800
|
+
workerScripts
|
|
1801
|
+
} = configuration;
|
|
1802
|
+
setIfDefined("baseURL", baseURL);
|
|
1803
|
+
setIfDefined("chunkSize", chunkSize);
|
|
1804
|
+
setIfDefined("maxWorkers", maxWorkers);
|
|
1805
|
+
setIfDefined("terminateWorkerTimeout", terminateWorkerTimeout);
|
|
1806
|
+
setIfDefined("useCompressionStream", useCompressionStream);
|
|
1807
|
+
setIfDefined("useWebWorkers", useWebWorkers);
|
|
1808
|
+
if (Deflate) {
|
|
1809
|
+
config.CompressionStream = getCodecStreamClass(Deflate);
|
|
1810
|
+
}
|
|
1811
|
+
if (Inflate) {
|
|
1812
|
+
config.DecompressionStream = getCodecStreamClass(Inflate);
|
|
1813
|
+
}
|
|
1814
|
+
setIfDefined("CompressionStream", CompressionStream);
|
|
1815
|
+
setIfDefined("DecompressionStream", DecompressionStream);
|
|
1816
|
+
if (workerScripts !== UNDEFINED_VALUE) {
|
|
1817
|
+
const { deflate, inflate } = workerScripts;
|
|
1818
|
+
if (deflate || inflate) {
|
|
1819
|
+
if (!config.workerScripts) {
|
|
1820
|
+
config.workerScripts = {};
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
if (deflate) {
|
|
1824
|
+
if (!Array.isArray(deflate)) {
|
|
1825
|
+
throw new Error("workerScripts.deflate must be an array");
|
|
1826
|
+
}
|
|
1827
|
+
config.workerScripts.deflate = deflate;
|
|
1828
|
+
}
|
|
1829
|
+
if (inflate) {
|
|
1830
|
+
if (!Array.isArray(inflate)) {
|
|
1831
|
+
throw new Error("workerScripts.inflate must be an array");
|
|
1832
|
+
}
|
|
1833
|
+
config.workerScripts.inflate = inflate;
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
function setIfDefined(propertyName, propertyValue) {
|
|
1839
|
+
if (propertyValue !== UNDEFINED_VALUE) {
|
|
1840
|
+
config[propertyName] = propertyValue;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
function e(e){const t=()=>URL.createObjectURL(new Blob(['const{Array:e,Object:t,Math:n,Error:r,Uint8Array:s,Uint16Array:i,Uint32Array:o,Int32Array:c,Map:f,DataView:a,Promise:l,TextEncoder:u,crypto:w,postMessage:h,TransformStream:d,ReadableStream:p,WritableStream:y,CompressionStream:m,DecompressionStream:b}=globalThis,g=[];for(let e=0;256>e;e++){let t=e;for(let e=0;8>e;e++)1&t?t=t>>>1^3988292384:t>>>=1;g[e]=t}class k{constructor(e){this.t=e||-1}append(e){let t=0|this.t;for(let n=0,r=0|e.length;r>n;n++)t=t>>>8^g[255&(t^e[n])];this.t=t}get(){return~this.t}}class v extends d{constructor(){const e=new k;super({transform(t){e.append(t)},flush(t){const n=new s(4);new a(n.buffer).setUint32(0,e.get()),t.enqueue(n)}})}}const S={concat(e,t){if(0===e.length||0===t.length)return e.concat(t);const n=e[e.length-1],r=S.i(n);return 32===r?e.concat(t):S.o(t,r,0|n,e.slice(0,e.length-1))},l(e){const t=e.length;if(0===t)return 0;const n=e[t-1];return 32*(t-1)+S.i(n)},u(e,t){if(32*e.length<t)return e;const r=(e=e.slice(0,n.ceil(t/32))).length;return t&=31,r>0&&t&&(e[r-1]=S.h(t,e[r-1]&2147483648>>t-1,1)),e},h:(e,t,n)=>32===e?t:(n?0|t:t<<32-e)+1099511627776*e,i:e=>n.round(e/1099511627776)||32,o(e,t,n,r){for(void 0===r&&(r=[]);t>=32;t-=32)r.push(n),n=0;if(0===t)return r.concat(e);for(let s=0;s<e.length;s++)r.push(n|e[s]>>>t),n=e[s]<<32-t;const s=e.length?e[e.length-1]:0,i=S.i(s);return r.push(S.h(t+i&31,t+i>32?n:r.pop(),1)),r}},C={p:{m(e){const t=S.l(e)/8,n=new s(t);let r;for(let s=0;t>s;s++)0==(3&s)&&(r=e[s/4]),n[s]=r>>>24,r<<=8;return n},g(e){const t=[];let n,r=0;for(n=0;n<e.length;n++)r=r<<8|e[n],3==(3&n)&&(t.push(r),r=0);return 3&n&&t.push(S.h(8*(3&n),r)),t}}},z={k:function(e){e?(this.v=e.v.slice(0),this.S=e.S.slice(0),this.C=e.C):this.reset()}};z.k.prototype={blockSize:512,reset(){const e=this;return e.v=this._.slice(0),e.S=[],e.C=0,e},update(e){const t=this;"string"==typeof e&&(e=C.I.g(e));const n=t.S=S.concat(t.S,e),s=t.C,i=t.C=s+S.l(e);if(i>9007199254740991)throw new r("Cannot hash more than 2^53 - 1 bits");const c=new o(n);let f=0;for(let e=t.blockSize+s-(t.blockSize+s&t.blockSize-1);i>=e;e+=t.blockSize)t.A(c.subarray(16*f,16*(f+1))),f+=1;return n.splice(0,16*f),t},D(){const e=this;let t=e.S;const r=e.v;t=S.concat(t,[S.h(1,1)]);for(let e=t.length+2;15&e;e++)t.push(0);for(t.push(n.floor(e.C/4294967296)),t.push(0|e.C);t.length;)e.A(t.splice(0,16));return e.reset(),r},_:[1732584193,4023233417,2562383102,271733878,3285377520],V:[1518500249,1859775393,2400959708,3395469782],R:(e,t,n,r)=>e>19?e>39?e>59?e>79?void 0:t^n^r:t&n|t&r|n&r:t^n^r:t&n|~t&r,B:(e,t)=>t<<e|t>>>32-e,A(t){const r=this,s=r.v,i=e(80);for(let e=0;16>e;e++)i[e]=t[e];let o=s[0],c=s[1],f=s[2],a=s[3],l=s[4];for(let e=0;79>=e;e++){16>e||(i[e]=r.B(1,i[e-3]^i[e-8]^i[e-14]^i[e-16]));const t=r.B(5,o)+r.R(e,c,f,a)+l+i[e]+r.V[n.floor(e/20)]|0;l=a,a=f,f=r.B(30,c),c=o,o=t}s[0]=s[0]+o|0,s[1]=s[1]+c|0,s[2]=s[2]+f|0,s[3]=s[3]+a|0,s[4]=s[4]+l|0}};const _={getRandomValues(e){const t=new o(e.buffer),r=e=>{let t=987654321;const r=4294967295;return()=>(t=36969*(65535&t)+(t>>16)&r,(((t<<16)+(e=18e3*(65535&e)+(e>>16)&r)&r)/4294967296+.5)*(n.random()>.5?1:-1))};for(let s,i=0;i<e.length;i+=4){const e=r(4294967296*(s||n.random()));s=987654071*e(),t[i/4]=4294967296*e()|0}return e}},I={importKey:e=>new I.M(C.p.g(e)),K(e,t,n,s){if(n=n||1e4,0>s||0>n)throw new r("invalid params to pbkdf2");const i=1+(s>>5)<<2;let o,c,f,l,u;const w=new ArrayBuffer(i),h=new a(w);let d=0;const p=S;for(t=C.p.g(t),u=1;(i||1)>d;u++){for(o=c=e.encrypt(p.concat(t,[u])),f=1;n>f;f++)for(c=e.encrypt(c),l=0;l<c.length;l++)o[l]^=c[l];for(f=0;(i||1)>d&&f<o.length;f++)h.setInt32(d,o[f]),d+=4}return w.slice(0,s/8)},M:class{constructor(e){const t=this,n=t.N=z.k,r=[[],[]],s=n.prototype.blockSize/32;t.P=[new n,new n],e.length>s&&(e=n.hash(e));for(let t=0;s>t;t++)r[0][t]=909522486^e[t],r[1][t]=1549556828^e[t];t.P[0].update(r[0]),t.P[1].update(r[1]),t.T=new n(t.P[0])}reset(){const e=this;e.T=new e.N(e.P[0]),e.U=!1}update(e){this.U=!0,this.T.update(e)}digest(){const e=this,t=e.T.D(),n=new e.N(e.P[1]).update(t).D();return e.reset(),n}encrypt(e){if(this.U)throw new r("encrypt on already updated hmac called!");return this.update(e),this.digest(e)}}},x=void 0!==w&&"function"==typeof w.getRandomValues;function A(e){return x?w.getRandomValues(e):_.getRandomValues(e)}const D={name:"PBKDF2"},V=t.assign({hash:{name:"HMAC"}},D),R=t.assign({iterations:1e3,hash:{name:"SHA-1"}},D),B=["deriveBits"],E=[8,12,16],M=[16,24,32],K=[0,0,0,0],N=void 0!==w,P=N&&w.subtle,T=N&&void 0!==P,U=N&&T&&"function"==typeof P.importKey,W=N&&T&&"function"==typeof P.deriveBits,H=C.p,L=class{constructor(e){const t=this;t.W=[[[],[],[],[],[]],[[],[],[],[],[]]],t.W[0][0][0]||t.H();const n=t.W[0][4],s=t.W[1],i=e.length;let o,c,f,a=1;if(4!==i&&6!==i&&8!==i)throw new r("invalid aes key size");for(t.V=[c=e.slice(0),f=[]],o=i;4*i+28>o;o++){let e=c[o-1];(o%i==0||8===i&&o%i==4)&&(e=n[e>>>24]<<24^n[e>>16&255]<<16^n[e>>8&255]<<8^n[255&e],o%i==0&&(e=e<<8^e>>>24^a<<24,a=a<<1^283*(a>>7))),c[o]=c[o-i]^e}for(let e=0;o;e++,o--){const t=c[3&e?o:o-4];f[e]=4>=o||4>e?t:s[0][n[t>>>24]]^s[1][n[t>>16&255]]^s[2][n[t>>8&255]]^s[3][n[255&t]]}}encrypt(e){return this.L(e,0)}decrypt(e){return this.L(e,1)}H(){const e=this.W[0],t=this.W[1],n=e[4],r=t[4],s=[],i=[];let o,c,f,a;for(let e=0;256>e;e++)i[(s[e]=e<<1^283*(e>>7))^e]=e;for(let l=o=0;!n[l];l^=c||1,o=i[o]||1){let i=o^o<<1^o<<2^o<<3^o<<4;i=i>>8^255&i^99,n[l]=i,r[i]=l,a=s[f=s[c=s[l]]];let u=16843009*a^65537*f^257*c^16843008*l,w=257*s[i]^16843008*i;for(let n=0;4>n;n++)e[n][l]=w=w<<24^w>>>8,t[n][i]=u=u<<24^u>>>8}for(let n=0;5>n;n++)e[n]=e[n].slice(0),t[n]=t[n].slice(0)}L(e,t){if(4!==e.length)throw new r("invalid aes block size");const n=this.V[t],s=n.length/4-2,i=[0,0,0,0],o=this.W[t],c=o[0],f=o[1],a=o[2],l=o[3],u=o[4];let w,h,d,p=e[0]^n[0],y=e[t?3:1]^n[1],m=e[2]^n[2],b=e[t?1:3]^n[3],g=4;for(let e=0;s>e;e++)w=c[p>>>24]^f[y>>16&255]^a[m>>8&255]^l[255&b]^n[g],h=c[y>>>24]^f[m>>16&255]^a[b>>8&255]^l[255&p]^n[g+1],d=c[m>>>24]^f[b>>16&255]^a[p>>8&255]^l[255&y]^n[g+2],b=c[b>>>24]^f[p>>16&255]^a[y>>8&255]^l[255&m]^n[g+3],g+=4,p=w,y=h,m=d;for(let e=0;4>e;e++)i[t?3&-e:e]=u[p>>>24]<<24^u[y>>16&255]<<16^u[m>>8&255]<<8^u[255&b]^n[g++],w=p,p=y,y=m,m=b,b=w;return i}},j=class{constructor(e,t){this.j=e,this.F=t,this.O=t}reset(){this.O=this.F}update(e){return this.q(this.j,e,this.O)}G(e){if(255==(e>>24&255)){let t=e>>16&255,n=e>>8&255,r=255&e;255===t?(t=0,255===n?(n=0,255===r?r=0:++r):++n):++t,e=0,e+=t<<16,e+=n<<8,e+=r}else e+=1<<24;return e}J(e){0===(e[0]=this.G(e[0]))&&(e[1]=this.G(e[1]))}q(e,t,n){let r;if(!(r=t.length))return[];const s=S.l(t);for(let s=0;r>s;s+=4){this.J(n);const r=e.encrypt(n);t[s]^=r[0],t[s+1]^=r[1],t[s+2]^=r[2],t[s+3]^=r[3]}return S.u(t,s)}},F=I.M;class O extends d{constructor(e,n,i){super({start(){t.assign(this,{ready:new l((e=>this.X=e)),password:e,signed:n,Y:i-1,pending:new s})},async transform(e,t){const n=this,{password:i,Y:o,X:c,ready:f}=n;i?(await(async(e,t,n,s)=>{const i=await J(e,t,n,X(s,0,E[t])),o=X(s,E[t]);if(i[0]!=o[0]||i[1]!=o[1])throw new r("Invalid password")})(n,o,i,X(e,0,E[o]+2)),e=X(e,E[o]+2),c()):await f;const a=new s(e.length-10-(e.length-10)%16);t.enqueue(G(n,e,a,0,10,!0))},async flush(e){const{signed:t,Z:n,$:i,pending:o,ready:c}=this;await c;const f=X(o,0,o.length-10),a=X(o,o.length-10);let l=new s;if(f.length){const e=Z(H,f);i.update(e);const t=n.update(e);l=Y(H,t)}if(t){const e=X(Y(H,i.digest()),0,10);for(let t=0;10>t;t++)if(e[t]!=a[t])throw new r("Invalid signature")}e.enqueue(l)}})}}class q extends d{constructor(e,n){let r;super({start(){t.assign(this,{ready:new l((e=>this.X=e)),password:e,Y:n-1,pending:new s})},async transform(e,t){const n=this,{password:r,Y:i,X:o,ready:c}=n;let f=new s;r?(f=await(async(e,t,n)=>{const r=A(new s(E[t]));return Q(r,await J(e,t,n,r))})(n,i,r),o()):await c;const a=new s(f.length+e.length-e.length%16);a.set(f,0),t.enqueue(G(n,e,a,f.length,0))},async flush(e){const{Z:t,$:n,pending:i,ready:o}=this;await o;let c=new s;if(i.length){const e=t.update(Z(H,i));n.update(e),c=Y(H,e)}r.signature=Y(H,n.digest()).slice(0,10),e.enqueue(Q(c,r.signature))}}),r=this}}function G(e,t,n,r,i,o){const{Z:c,$:f,pending:a}=e,l=t.length-i;let u;for(a.length&&(t=Q(a,t),n=((e,t)=>{if(t&&t>e.length){const n=e;(e=new s(t)).set(n,0)}return e})(n,l-l%16)),u=0;l-16>=u;u+=16){const e=Z(H,X(t,u,u+16));o&&f.update(e);const s=c.update(e);o||f.update(s),n.set(Y(H,s),u+r)}return e.pending=X(t,u),n}async function J(n,r,i,o){n.password=null;const c=(e=>{if(void 0===u){const t=new s((e=unescape(encodeURIComponent(e))).length);for(let n=0;n<t.length;n++)t[n]=e.charCodeAt(n);return t}return(new u).encode(e)})(i),f=await((e,t,n,r,s)=>U?P.importKey("raw",t,n,!1,s):I.importKey(t))(0,c,V,0,B),a=await(async(e,t,n)=>W?await P.deriveBits(e,t,n):I.K(t,e.salt,R.iterations,n))(t.assign({salt:o},R),f,8*(2*M[r]+2)),l=new s(a),w=Z(H,X(l,0,M[r])),h=Z(H,X(l,M[r],2*M[r])),d=X(l,2*M[r]);return t.assign(n,{keys:{key:w,ee:h,passwordVerification:d},Z:new j(new L(w),e.from(K)),$:new F(h)}),d}function Q(e,t){let n=e;return e.length+t.length&&(n=new s(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function X(e,t,n){return e.subarray(t,n)}function Y(e,t){return e.m(t)}function Z(e,t){return e.g(t)}class $ extends d{constructor(e,n){super({start(){t.assign(this,{password:e,passwordVerification:n}),re(this,e)},transform(e,t){const n=this;if(n.password){const t=te(n,e.subarray(0,12));if(n.password=null,t[11]!=n.passwordVerification)throw new r("Invalid password");e=e.subarray(12)}t.enqueue(te(n,e))}})}}class ee extends d{constructor(e,n){super({start(){t.assign(this,{password:e,passwordVerification:n}),re(this,e)},transform(e,t){const n=this;let r,i;if(n.password){n.password=null;const t=A(new s(12));t[11]=n.passwordVerification,r=new s(e.length+t.length),r.set(ne(n,t),0),i=12}else r=new s(e.length),i=0;r.set(ne(n,e),i),t.enqueue(r)},flush(){}})}}function te(e,t){const n=new s(t.length);for(let r=0;r<t.length;r++)n[r]=ie(e)^t[r],se(e,n[r]);return n}function ne(e,t){const n=new s(t.length);for(let r=0;r<t.length;r++)n[r]=ie(e)^t[r],se(e,t[r]);return n}function re(e,n){const r=[305419896,591751049,878082192];t.assign(e,{keys:r,te:new k(r[0]),ne:new k(r[2])});for(let t=0;t<n.length;t++)se(e,n.charCodeAt(t))}function se(e,t){let[r,s,i]=e.keys;e.te.append([t]),r=~e.te.get(),s=ce(n.imul(ce(s+oe(r)),134775813)+1),e.ne.append([s>>>24]),i=~e.ne.get(),e.keys=[r,s,i]}function ie(e){const t=2|e.keys[2];return oe(n.imul(t,1^t)>>>8)}function oe(e){return 255&e}function ce(e){return 4294967295&e}class fe extends d{constructor(e,{chunkSize:t,CompressionStream:n,re:r}){super({});const{compressed:s,encrypted:i,useCompressionStream:o,password:c,passwordVerification:f,encryptionStrength:l,zipCrypto:u,signed:w,level:h}=e,d=this;let p,y,m=le(super.readable);i&&!u||!w||([m,p]=m.tee(),p=he(p,new v)),s&&(m=we(m,o,{level:h,chunkSize:t},r,n)),i&&(u?m=he(m,new ee(c,f)):(y=new q(c,l),m=he(m,y))),ue(d,m,(async()=>{let e;i&&!u&&(e=y.signature),i&&!u||!w||(e=await p.getReader().read(),e=new a(e.value.buffer).getUint32(0)),d.signature=e}))}}class ae extends d{constructor(e,{chunkSize:t,DecompressionStream:n,se:s}){super({});const{zipCrypto:i,encrypted:o,password:c,passwordVerification:f,signed:l,signature:u,encryptionStrength:w,compressed:h,useCompressionStream:d}=e;let p,y,m=le(super.readable);o&&(i?m=he(m,new $(c,f)):(y=new O(c,l,w),m=he(m,y))),h&&(m=we(m,d,{chunkSize:t},s,n)),o&&!i||!l||([m,p]=m.tee(),p=he(p,new v)),ue(this,m,(async()=>{if((!o||i)&&l){const e=await p.getReader().read(),t=new a(e.value.buffer);if(u!=t.getUint32(0,!1))throw new r("Invalid signature")}}))}}function le(e){return he(e,new d({transform(e,t){e&&e.length&&t.enqueue(e)}}))}function ue(e,n,r){n=he(n,new d({flush:r})),t.defineProperty(e,"readable",{get:()=>n})}function we(e,t,n,r,s){try{e=he(e,new(t&&r?r:s)("deflate-raw",n))}catch(r){if(!t)throw r;e=he(e,new s("deflate-raw",n))}return e}function he(e,t){return e.pipeThrough(t)}class de extends d{constructor(e,t){let n;super({start(){n=new e(t)},transform(e,t){t.enqueue(n.append(e))},flush(e){const t=n.flush();t&&e.enqueue(t)}})}}class pe{constructor(e,n,r,s){const{codecType:i}=r;let o;i.startsWith("deflate")?o=fe:i.startsWith("inflate")&&(o=ae),t.assign(this,{ie:o,readable:e,writable:n,options:r,config:s})}async oe(){const{ie:e,readable:t,writable:n,options:r,config:s}=this,i=new e(r,s);let o=0;await t.pipeThrough(i).pipeThrough(new d({transform(e,t){e&&e.length&&(o+=e.length,t.enqueue(e))}})).pipeTo(n,{preventClose:!0,ce:!0});const{signature:c}=i;return{size:o,signature:c}}}function ye(e){return class extends de{constructor(t,n){super(e,n)}}}const me=new f,be=new f;let ge,ke=0;async function ve(e){try{const{options:t,scripts:n,config:r}=e;n&&n.length&&importScripts.apply(void 0,n),self.initCodec&&self.initCodec(),r.re=self.CompressionStream,r.se=self.DecompressionStream,self.Deflate&&(r.CompressionStream=ye(self.Deflate)),self.Inflate&&(r.DecompressionStream=ye(self.Inflate));const s={highWaterMark:1,size:()=>r.chunkSize},i=e.readable||new p({async pull(e){let t=new l((e=>me.set(ke,e)));Se({type:"pull",messageId:ke}),ke=(ke+1)%Number.MAX_SAFE_INTEGER;const{value:n,done:r}=await t;e.enqueue(n),r&&e.close()}},s),o=e.writable||new y({async write(e){let t;const n=new l((e=>t=e));be.set(ke,t),Se({type:"data",data:e,messageId:ke}),ke=(ke+1)%Number.MAX_SAFE_INTEGER,await n}},s);ge=new pe(i,o,t,r);const c=await ge.oe();e.writable&&!t.preventClose&&await e.writable.close(),Se({type:"close",result:c})}catch(e){Ce(e)}}function Se(e){if(e.data){let{data:t}=e;if(t&&t.length)try{t=new s(t),e.data=t.buffer,h(e,[e.data])}catch(t){h(e)}else h(e)}else h(e)}function Ce(e){const{message:t,stack:n,code:r,name:s}=e;h({error:{message:t,stack:n,code:r,name:s}})}function ze(t){return _e(t.map((([t,n])=>new e(t).fill(n,0,t))))}function _e(t){return t.reduce(((t,n)=>t.concat(e.isArray(n)?_e(n):n)),[])}addEventListener("message",(async e=>{const t=e.data,{type:n,messageId:r,data:i,done:o}=t;try{if("start"==n&&ve(t),"data"==n){const e=me.get(r);me.delete(r),e({value:new s(i),done:o})}if("ack"==n){const e=be.get(r);be.delete(r),e()}}catch(e){Ce(e)}}));const Ie=[0,1,2,3].concat(...ze([[2,4],[2,5],[4,6],[4,7],[8,8],[8,9],[16,10],[16,11],[32,12],[32,13],[64,14],[64,15],[2,0],[1,16],[1,17],[2,18],[2,19],[4,20],[4,21],[8,22],[8,23],[16,24],[16,25],[32,26],[32,27],[64,28],[64,29]]));function xe(){const e=this;function t(e,t){let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1}e.fe=r=>{const s=e.ae,i=e.ue.le,o=e.ue.we;let c,f,a,l=-1;for(r.he=0,r.de=573,c=0;o>c;c++)0!==s[2*c]?(r.pe[++r.he]=l=c,r.ye[c]=0):s[2*c+1]=0;for(;2>r.he;)a=r.pe[++r.he]=2>l?++l:0,s[2*a]=1,r.ye[a]=0,r.me--,i&&(r.be-=i[2*a+1]);for(e.ge=l,c=n.floor(r.he/2);c>=1;c--)r.ke(s,c);a=o;do{c=r.pe[1],r.pe[1]=r.pe[r.he--],r.ke(s,1),f=r.pe[1],r.pe[--r.de]=c,r.pe[--r.de]=f,s[2*a]=s[2*c]+s[2*f],r.ye[a]=n.max(r.ye[c],r.ye[f])+1,s[2*c+1]=s[2*f+1]=a,r.pe[1]=a++,r.ke(s,1)}while(r.he>=2);r.pe[--r.de]=r.pe[1],(t=>{const n=e.ae,r=e.ue.le,s=e.ue.ve,i=e.ue.Se,o=e.ue.Ce;let c,f,a,l,u,w,h=0;for(l=0;15>=l;l++)t.ze[l]=0;for(n[2*t.pe[t.de]+1]=0,c=t.de+1;573>c;c++)f=t.pe[c],l=n[2*n[2*f+1]+1]+1,l>o&&(l=o,h++),n[2*f+1]=l,f>e.ge||(t.ze[l]++,u=0,i>f||(u=s[f-i]),w=n[2*f],t.me+=w*(l+u),r&&(t.be+=w*(r[2*f+1]+u)));if(0!==h){do{for(l=o-1;0===t.ze[l];)l--;t.ze[l]--,t.ze[l+1]+=2,t.ze[o]--,h-=2}while(h>0);for(l=o;0!==l;l--)for(f=t.ze[l];0!==f;)a=t.pe[--c],a>e.ge||(n[2*a+1]!=l&&(t.me+=(l-n[2*a+1])*n[2*a],n[2*a+1]=l),f--)}})(r),((e,n,r)=>{const s=[];let i,o,c,f=0;for(i=1;15>=i;i++)s[i]=f=f+r[i-1]<<1;for(o=0;n>=o;o++)c=e[2*o+1],0!==c&&(e[2*o]=t(s[c]++,c))})(s,e.ge,r.ze)}}function Ae(e,t,n,r,s){const i=this;i.le=e,i.ve=t,i.Se=n,i.we=r,i.Ce=s}xe._e=[0,1,2,3,4,5,6,7].concat(...ze([[2,8],[2,9],[2,10],[2,11],[4,12],[4,13],[4,14],[4,15],[8,16],[8,17],[8,18],[8,19],[16,20],[16,21],[16,22],[16,23],[32,24],[32,25],[32,26],[31,27],[1,28]])),xe.Ie=[0,1,2,3,4,5,6,7,8,10,12,14,16,20,24,28,32,40,48,56,64,80,96,112,128,160,192,224,0],xe.xe=[0,1,2,3,4,6,8,12,16,24,32,48,64,96,128,192,256,384,512,768,1024,1536,2048,3072,4096,6144,8192,12288,16384,24576],xe.Ae=e=>256>e?Ie[e]:Ie[256+(e>>>7)],xe.De=[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],xe.Ve=[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],xe.Re=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],xe.Be=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];const De=ze([[144,8],[112,9],[24,7],[8,8]]);Ae.Ee=_e([12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,19,275,147,403,83,339,211,467,51,307,179,435,115,371,243,499,11,267,139,395,75,331,203,459,43,299,171,427,107,363,235,491,27,283,155,411,91,347,219,475,59,315,187,443,123,379,251,507,7,263,135,391,71,327,199,455,39,295,167,423,103,359,231,487,23,279,151,407,87,343,215,471,55,311,183,439,119,375,247,503,15,271,143,399,79,335,207,463,47,303,175,431,111,367,239,495,31,287,159,415,95,351,223,479,63,319,191,447,127,383,255,511,0,64,32,96,16,80,48,112,8,72,40,104,24,88,56,120,4,68,36,100,20,84,52,116,3,131,67,195,35,163,99,227].map(((e,t)=>[e,De[t]])));const Ve=ze([[30,5]]);function Re(e,t,n,r,s){const i=this;i.Me=e,i.Ke=t,i.Ne=n,i.Pe=r,i.Te=s}Ae.Ue=_e([0,16,8,24,4,20,12,28,2,18,10,26,6,22,14,30,1,17,9,25,5,21,13,29,3,19,11,27,7,23].map(((e,t)=>[e,Ve[t]]))),Ae.We=new Ae(Ae.Ee,xe.De,257,286,15),Ae.He=new Ae(Ae.Ue,xe.Ve,0,30,15),Ae.Le=new Ae(null,xe.Re,0,19,7);const Be=[new Re(0,0,0,0,0),new Re(4,4,8,4,1),new Re(4,5,16,8,1),new Re(4,6,32,32,1),new Re(4,4,16,16,2),new Re(8,16,32,32,2),new Re(8,16,128,128,2),new Re(8,32,128,256,2),new Re(32,128,258,1024,2),new Re(32,258,258,4096,2)],Ee=["need dictionary","stream end","","","stream error","data error","","buffer error","",""];function Me(e,t,n,r){const s=e[2*t],i=e[2*n];return i>s||s==i&&r[t]<=r[n]}function Ke(){const e=this;let t,r,o,c,f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,C,z,_,I,x,A,D,V,R,B,E,M,K,N;const P=new xe,T=new xe,U=new xe;let W,H,L,j,F,O;function q(){let t;for(t=0;286>t;t++)M[2*t]=0;for(t=0;30>t;t++)K[2*t]=0;for(t=0;19>t;t++)N[2*t]=0;M[512]=1,e.me=e.be=0,H=L=0}function G(e,t){let n,r=-1,s=e[1],i=0,o=7,c=4;0===s&&(o=138,c=3),e[2*(t+1)+1]=65535;for(let f=0;t>=f;f++)n=s,s=e[2*(f+1)+1],++i<o&&n==s||(c>i?N[2*n]+=i:0!==n?(n!=r&&N[2*n]++,N[32]++):i>10?N[36]++:N[34]++,i=0,r=n,0===s?(o=138,c=3):n==s?(o=6,c=3):(o=7,c=4))}function J(t){e.je[e.pending++]=t}function Q(e){J(255&e),J(e>>>8&255)}function X(e,t){let n;const r=t;O>16-r?(n=e,F|=n<<O&65535,Q(F),F=n>>>16-O,O+=r-16):(F|=e<<O&65535,O+=r)}function Y(e,t){const n=2*e;X(65535&t[n],65535&t[n+1])}function Z(e,t){let n,r,s=-1,i=e[1],o=0,c=7,f=4;for(0===i&&(c=138,f=3),n=0;t>=n;n++)if(r=i,i=e[2*(n+1)+1],++o>=c||r!=i){if(f>o)do{Y(r,N)}while(0!=--o);else 0!==r?(r!=s&&(Y(r,N),o--),Y(16,N),X(o-3,2)):o>10?(Y(18,N),X(o-11,7)):(Y(17,N),X(o-3,3));o=0,s=r,0===i?(c=138,f=3):r==i?(c=6,f=3):(c=7,f=4)}}function $(){16==O?(Q(F),F=0,O=0):8>O||(J(255&F),F>>>=8,O-=8)}function ee(t,r){let s,i,o;if(e.Fe[H]=t,e.Oe[H]=255&r,H++,0===t?M[2*r]++:(L++,t--,M[2*(xe._e[r]+256+1)]++,K[2*xe.Ae(t)]++),0==(8191&H)&&V>2){for(s=8*H,i=z-k,o=0;30>o;o++)s+=K[2*o]*(5+xe.Ve[o]);if(s>>>=3,L<n.floor(H/2)&&s<n.floor(i/2))return!0}return H==W-1}function te(t,n){let r,s,i,o,c=0;if(0!==H)do{r=e.Fe[c],s=e.Oe[c],c++,0===r?Y(s,t):(i=xe._e[s],Y(i+256+1,t),o=xe.De[i],0!==o&&(s-=xe.Ie[i],X(s,o)),r--,i=xe.Ae(r),Y(i,n),o=xe.Ve[i],0!==o&&(r-=xe.xe[i],X(r,o)))}while(H>c);Y(256,t),j=t[513]}function ne(){O>8?Q(F):O>0&&J(255&F),F=0,O=0}function re(t,n,r){X(0+(r?1:0),3),((t,n)=>{ne(),j=8,Q(n),Q(~n),e.je.set(u.subarray(t,t+n),e.pending),e.pending+=n})(t,n)}function se(n){((t,n,r)=>{let s,i,o=0;V>0?(P.fe(e),T.fe(e),o=(()=>{let t;for(G(M,P.ge),G(K,T.ge),U.fe(e),t=18;t>=3&&0===N[2*xe.Be[t]+1];t--);return e.me+=14+3*(t+1),t})(),s=e.me+3+7>>>3,i=e.be+3+7>>>3,i>s||(s=i)):s=i=n+5,n+4>s||-1==t?i==s?(X(2+(r?1:0),3),te(Ae.Ee,Ae.Ue)):(X(4+(r?1:0),3),((e,t,n)=>{let r;for(X(e-257,5),X(t-1,5),X(n-4,4),r=0;n>r;r++)X(N[2*xe.Be[r]+1],3);Z(M,e-1),Z(K,t-1)})(P.ge+1,T.ge+1,o+1),te(M,K)):re(t,n,r),q(),r&&ne()})(0>k?-1:k,z-k,n),k=z,t.qe()}function ie(){let e,n,r,s;do{if(s=w-I-z,0===s&&0===z&&0===I)s=f;else if(-1==s)s--;else if(z>=f+f-262){u.set(u.subarray(f,f+f),0),_-=f,z-=f,k-=f,e=y,r=e;do{n=65535&d[--r],d[r]=f>n?0:n-f}while(0!=--e);e=f,r=e;do{n=65535&h[--r],h[r]=f>n?0:n-f}while(0!=--e);s+=f}if(0===t.Ge)return;e=t.Je(u,z+I,s),I+=e,3>I||(p=255&u[z],p=(p<<g^255&u[z+1])&b)}while(262>I&&0!==t.Ge)}function oe(e){let t,n,r=A,s=z,i=x;const o=z>f-262?z-(f-262):0;let c=E;const a=l,w=z+258;let d=u[s+i-1],p=u[s+i];B>x||(r>>=2),c>I&&(c=I);do{if(t=e,u[t+i]==p&&u[t+i-1]==d&&u[t]==u[s]&&u[++t]==u[s+1]){s+=2,t++;do{}while(u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&u[++s]==u[++t]&&w>s);if(n=258-(w-s),s=w-258,n>i){if(_=e,i=n,n>=c)break;d=u[s+i-1],p=u[s+i]}}}while((e=65535&h[e&a])>o&&0!=--r);return i>I?I:i}e.ye=[],e.ze=[],e.pe=[],M=[],K=[],N=[],e.ke=(t,n)=>{const r=e.pe,s=r[n];let i=n<<1;for(;i<=e.he&&(i<e.he&&Me(t,r[i+1],r[i],e.ye)&&i++,!Me(t,s,r[i],e.ye));)r[n]=r[i],n=i,i<<=1;r[n]=s},e.Qe=(t,S,_,H,L,G)=>(H||(H=8),L||(L=8),G||(G=0),t.Xe=null,-1==S&&(S=6),1>L||L>9||8!=H||9>_||_>15||0>S||S>9||0>G||G>2?-2:(t.Ye=e,a=_,f=1<<a,l=f-1,m=L+7,y=1<<m,b=y-1,g=n.floor((m+3-1)/3),u=new s(2*f),h=[],d=[],W=1<<L+6,e.je=new s(4*W),o=4*W,e.Fe=new i(W),e.Oe=new s(W),V=S,R=G,(t=>(t.Ze=t.$e=0,t.Xe=null,e.pending=0,e.et=0,r=113,c=0,P.ae=M,P.ue=Ae.We,T.ae=K,T.ue=Ae.He,U.ae=N,U.ue=Ae.Le,F=0,O=0,j=8,q(),(()=>{w=2*f,d[y-1]=0;for(let e=0;y-1>e;e++)d[e]=0;D=Be[V].Ke,B=Be[V].Me,E=Be[V].Ne,A=Be[V].Pe,z=0,k=0,I=0,v=x=2,C=0,p=0})(),0))(t))),e.tt=()=>42!=r&&113!=r&&666!=r?-2:(e.Oe=null,e.Fe=null,e.je=null,d=null,h=null,u=null,e.Ye=null,113==r?-3:0),e.nt=(e,t,n)=>{let r=0;return-1==t&&(t=6),0>t||t>9||0>n||n>2?-2:(Be[V].Te!=Be[t].Te&&0!==e.Ze&&(r=e.rt(1)),V!=t&&(V=t,D=Be[V].Ke,B=Be[V].Me,E=Be[V].Ne,A=Be[V].Pe),R=n,r)},e.st=(e,t,n)=>{let s,i=n,o=0;if(!t||42!=r)return-2;if(3>i)return 0;for(i>f-262&&(i=f-262,o=n-i),u.set(t.subarray(o,o+i),0),z=i,k=i,p=255&u[0],p=(p<<g^255&u[1])&b,s=0;i-3>=s;s++)p=(p<<g^255&u[s+2])&b,h[s&l]=d[p],d[p]=s;return 0},e.rt=(n,s)=>{let i,w,m,A,B;if(s>4||0>s)return-2;if(!n.it||!n.ot&&0!==n.Ge||666==r&&4!=s)return n.Xe=Ee[4],-2;if(0===n.ct)return n.Xe=Ee[7],-5;var E;if(t=n,A=c,c=s,42==r&&(w=8+(a-8<<4)<<8,m=(V-1&255)>>1,m>3&&(m=3),w|=m<<6,0!==z&&(w|=32),w+=31-w%31,r=113,J((E=w)>>8&255),J(255&E)),0!==e.pending){if(t.qe(),0===t.ct)return c=-1,0}else if(0===t.Ge&&A>=s&&4!=s)return t.Xe=Ee[7],-5;if(666==r&&0!==t.Ge)return n.Xe=Ee[7],-5;if(0!==t.Ge||0!==I||0!=s&&666!=r){switch(B=-1,Be[V].Te){case 0:B=(e=>{let n,r=65535;for(r>o-5&&(r=o-5);;){if(1>=I){if(ie(),0===I&&0==e)return 0;if(0===I)break}if(z+=I,I=0,n=k+r,(0===z||z>=n)&&(I=z-n,z=n,se(!1),0===t.ct))return 0;if(z-k>=f-262&&(se(!1),0===t.ct))return 0}return se(4==e),0===t.ct?4==e?2:0:4==e?3:1})(s);break;case 1:B=(e=>{let n,r=0;for(;;){if(262>I){if(ie(),262>I&&0==e)return 0;if(0===I)break}if(3>I||(p=(p<<g^255&u[z+2])&b,r=65535&d[p],h[z&l]=d[p],d[p]=z),0===r||(z-r&65535)>f-262||2!=R&&(v=oe(r)),3>v)n=ee(0,255&u[z]),I--,z++;else if(n=ee(z-_,v-3),I-=v,v>D||3>I)z+=v,v=0,p=255&u[z],p=(p<<g^255&u[z+1])&b;else{v--;do{z++,p=(p<<g^255&u[z+2])&b,r=65535&d[p],h[z&l]=d[p],d[p]=z}while(0!=--v);z++}if(n&&(se(!1),0===t.ct))return 0}return se(4==e),0===t.ct?4==e?2:0:4==e?3:1})(s);break;case 2:B=(e=>{let n,r,s=0;for(;;){if(262>I){if(ie(),262>I&&0==e)return 0;if(0===I)break}if(3>I||(p=(p<<g^255&u[z+2])&b,s=65535&d[p],h[z&l]=d[p],d[p]=z),x=v,S=_,v=2,0!==s&&D>x&&f-262>=(z-s&65535)&&(2!=R&&(v=oe(s)),5>=v&&(1==R||3==v&&z-_>4096)&&(v=2)),3>x||v>x)if(0!==C){if(n=ee(0,255&u[z-1]),n&&se(!1),z++,I--,0===t.ct)return 0}else C=1,z++,I--;else{r=z+I-3,n=ee(z-1-S,x-3),I-=x-1,x-=2;do{++z>r||(p=(p<<g^255&u[z+2])&b,s=65535&d[p],h[z&l]=d[p],d[p]=z)}while(0!=--x);if(C=0,v=2,z++,n&&(se(!1),0===t.ct))return 0}}return 0!==C&&(n=ee(0,255&u[z-1]),C=0),se(4==e),0===t.ct?4==e?2:0:4==e?3:1})(s)}if(2!=B&&3!=B||(r=666),0==B||2==B)return 0===t.ct&&(c=-1),0;if(1==B){if(1==s)X(2,3),Y(256,Ae.Ee),$(),9>1+j+10-O&&(X(2,3),Y(256,Ae.Ee),$()),j=7;else if(re(0,0,!1),3==s)for(i=0;y>i;i++)d[i]=0;if(t.qe(),0===t.ct)return c=-1,0}}return 4!=s?0:1}}function Ne(){const e=this;e.ft=0,e.lt=0,e.Ge=0,e.Ze=0,e.ct=0,e.$e=0}function Pe(e){const t=new Ne,i=(o=e&&e.chunkSize?e.chunkSize:65536)+5*(n.floor(o/16383)+1);var o;const c=new s(i);let f=e?e.level:-1;void 0===f&&(f=-1),t.Qe(f),t.it=c,this.append=(e,n)=>{let o,f,a=0,l=0,u=0;const w=[];if(e.length){t.ft=0,t.ot=e,t.Ge=e.length;do{if(t.lt=0,t.ct=i,o=t.rt(0),0!=o)throw new r("deflating: "+t.Xe);t.lt&&(t.lt==i?w.push(new s(c)):w.push(c.slice(0,t.lt))),u+=t.lt,n&&t.ft>0&&t.ft!=a&&(n(t.ft),a=t.ft)}while(t.Ge>0||0===t.ct);return w.length>1?(f=new s(u),w.forEach((e=>{f.set(e,l),l+=e.length}))):f=w[0]||new s,f}},this.flush=()=>{let e,n,o=0,f=0;const a=[];do{if(t.lt=0,t.ct=i,e=t.rt(4),1!=e&&0!=e)throw new r("deflating: "+t.Xe);i-t.ct>0&&a.push(c.slice(0,t.lt)),f+=t.lt}while(t.Ge>0||0===t.ct);return t.tt(),n=new s(f),a.forEach((e=>{n.set(e,o),o+=e.length})),n}}Ne.prototype={Qe(e,t){const n=this;return n.Ye=new Ke,t||(t=15),n.Ye.Qe(n,e,t)},rt(e){const t=this;return t.Ye?t.Ye.rt(t,e):-2},tt(){const e=this;if(!e.Ye)return-2;const t=e.Ye.tt();return e.Ye=null,t},nt(e,t){const n=this;return n.Ye?n.Ye.nt(n,e,t):-2},st(e,t){const n=this;return n.Ye?n.Ye.st(n,e,t):-2},Je(e,t,n){const r=this;let s=r.Ge;return s>n&&(s=n),0===s?0:(r.Ge-=s,e.set(r.ot.subarray(r.ft,r.ft+s),t),r.ft+=s,r.Ze+=s,s)},qe(){const e=this;let t=e.Ye.pending;t>e.ct&&(t=e.ct),0!==t&&(e.it.set(e.Ye.je.subarray(e.Ye.et,e.Ye.et+t),e.lt),e.lt+=t,e.Ye.et+=t,e.$e+=t,e.ct-=t,e.Ye.pending-=t,0===e.Ye.pending&&(e.Ye.et=0))}};const Te=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],Ue=[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],We=[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],He=[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],Le=[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],je=[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],Fe=[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];function Oe(){let e,t,n,r,s,i;function o(e,t,o,c,f,a,l,u,w,h,d){let p,y,m,b,g,k,v,S,C,z,_,I,x,A,D;z=0,g=o;do{n[e[t+z]]++,z++,g--}while(0!==g);if(n[0]==o)return l[0]=-1,u[0]=0,0;for(S=u[0],k=1;15>=k&&0===n[k];k++);for(v=k,k>S&&(S=k),g=15;0!==g&&0===n[g];g--);for(m=g,S>g&&(S=g),u[0]=S,A=1<<k;g>k;k++,A<<=1)if(0>(A-=n[k]))return-3;if(0>(A-=n[g]))return-3;for(n[g]+=A,i[1]=k=0,z=1,x=2;0!=--g;)i[x]=k+=n[z],x++,z++;g=0,z=0;do{0!==(k=e[t+z])&&(d[i[k]++]=g),z++}while(++g<o);for(o=i[m],i[0]=g=0,z=0,b=-1,I=-S,s[0]=0,_=0,D=0;m>=v;v++)for(p=n[v];0!=p--;){for(;v>I+S;){if(b++,I+=S,D=m-I,D=D>S?S:D,(y=1<<(k=v-I))>p+1&&(y-=p+1,x=v,D>k))for(;++k<D&&(y<<=1)>n[++x];)y-=n[x];if(D=1<<k,h[0]+D>1440)return-3;s[b]=_=h[0],h[0]+=D,0!==b?(i[b]=g,r[0]=k,r[1]=S,k=g>>>I-S,r[2]=_-s[b-1]-k,w.set(r,3*(s[b-1]+k))):l[0]=_}for(r[1]=v-I,o>z?d[z]<c?(r[0]=256>d[z]?0:96,r[2]=d[z++]):(r[0]=a[d[z]-c]+16+64,r[2]=f[d[z++]-c]):r[0]=192,y=1<<v-I,k=g>>>I;D>k;k+=y)w.set(r,3*(_+k));for(k=1<<v-1;0!=(g&k);k>>>=1)g^=k;for(g^=k,C=(1<<I)-1;(g&C)!=i[b];)b--,I-=S,C=(1<<I)-1}return 0!==A&&1!=m?-5:0}function f(o){let f;for(e||(e=[],t=[],n=new c(16),r=[],s=new c(15),i=new c(16)),t.length<o&&(t=[]),f=0;o>f;f++)t[f]=0;for(f=0;16>f;f++)n[f]=0;for(f=0;3>f;f++)r[f]=0;s.set(n.subarray(0,15),0),i.set(n.subarray(0,16),0)}this.ut=(n,r,s,i,c)=>{let a;return f(19),e[0]=0,a=o(n,0,19,19,null,null,s,r,i,e,t),-3==a?c.Xe="oversubscribed dynamic bit lengths tree":-5!=a&&0!==r[0]||(c.Xe="incomplete dynamic bit lengths tree",a=-3),a},this.wt=(n,r,s,i,c,a,l,u,w)=>{let h;return f(288),e[0]=0,h=o(s,0,n,257,He,Le,a,i,u,e,t),0!=h||0===i[0]?(-3==h?w.Xe="oversubscribed literal/length tree":-4!=h&&(w.Xe="incomplete literal/length tree",h=-3),h):(f(288),h=o(s,n,r,0,je,Fe,l,c,u,e,t),0!=h||0===c[0]&&n>257?(-3==h?w.Xe="oversubscribed distance tree":-5==h?(w.Xe="incomplete distance tree",h=-3):-4!=h&&(w.Xe="empty distance tree with lengths",h=-3),h):0)}}function qe(){const e=this;let t,n,r,s,i=0,o=0,c=0,f=0,a=0,l=0,u=0,w=0,h=0,d=0;function p(e,t,n,r,s,i,o,c){let f,a,l,u,w,h,d,p,y,m,b,g,k,v,S,C;d=c.ft,p=c.Ge,w=o.ht,h=o.dt,y=o.write,m=y<o.read?o.read-y-1:o.end-y,b=Te[e],g=Te[t];do{for(;20>h;)p--,w|=(255&c.yt(d++))<<h,h+=8;if(f=w&b,a=n,l=r,C=3*(l+f),0!==(u=a[C]))for(;;){if(w>>=a[C+1],h-=a[C+1],0!=(16&u)){for(u&=15,k=a[C+2]+(w&Te[u]),w>>=u,h-=u;15>h;)p--,w|=(255&c.yt(d++))<<h,h+=8;for(f=w&g,a=s,l=i,C=3*(l+f),u=a[C];;){if(w>>=a[C+1],h-=a[C+1],0!=(16&u)){for(u&=15;u>h;)p--,w|=(255&c.yt(d++))<<h,h+=8;if(v=a[C+2]+(w&Te[u]),w>>=u,h-=u,m-=k,v>y){S=y-v;do{S+=o.end}while(0>S);if(u=o.end-S,k>u){if(k-=u,y-S>0&&u>y-S)do{o.bt[y++]=o.bt[S++]}while(0!=--u);else o.bt.set(o.bt.subarray(S,S+u),y),y+=u,S+=u,u=0;S=0}}else S=y-v,y-S>0&&2>y-S?(o.bt[y++]=o.bt[S++],o.bt[y++]=o.bt[S++],k-=2):(o.bt.set(o.bt.subarray(S,S+2),y),y+=2,S+=2,k-=2);if(y-S>0&&k>y-S)do{o.bt[y++]=o.bt[S++]}while(0!=--k);else o.bt.set(o.bt.subarray(S,S+k),y),y+=k,S+=k,k=0;break}if(0!=(64&u))return c.Xe="invalid distance code",k=c.Ge-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ht=w,o.dt=h,c.Ge=p,c.Ze+=d-c.ft,c.ft=d,o.write=y,-3;f+=a[C+2],f+=w&Te[u],C=3*(l+f),u=a[C]}break}if(0!=(64&u))return 0!=(32&u)?(k=c.Ge-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ht=w,o.dt=h,c.Ge=p,c.Ze+=d-c.ft,c.ft=d,o.write=y,1):(c.Xe="invalid literal/length code",k=c.Ge-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ht=w,o.dt=h,c.Ge=p,c.Ze+=d-c.ft,c.ft=d,o.write=y,-3);if(f+=a[C+2],f+=w&Te[u],C=3*(l+f),0===(u=a[C])){w>>=a[C+1],h-=a[C+1],o.bt[y++]=a[C+2],m--;break}}else w>>=a[C+1],h-=a[C+1],o.bt[y++]=a[C+2],m--}while(m>=258&&p>=10);return k=c.Ge-p,k=k>h>>3?h>>3:k,p+=k,d-=k,h-=k<<3,o.ht=w,o.dt=h,c.Ge=p,c.Ze+=d-c.ft,c.ft=d,o.write=y,0}e.init=(e,i,o,c,f,a)=>{t=0,u=e,w=i,r=o,h=c,s=f,d=a,n=null},e.gt=(e,y,m)=>{let b,g,k,v,S,C,z,_=0,I=0,x=0;for(x=y.ft,v=y.Ge,_=e.ht,I=e.dt,S=e.write,C=S<e.read?e.read-S-1:e.end-S;;)switch(t){case 0:if(C>=258&&v>=10&&(e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,m=p(u,w,r,h,s,d,e,y),x=y.ft,v=y.Ge,_=e.ht,I=e.dt,S=e.write,C=S<e.read?e.read-S-1:e.end-S,0!=m)){t=1==m?7:9;break}c=u,n=r,o=h,t=1;case 1:for(b=c;b>I;){if(0===v)return e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);m=0,v--,_|=(255&y.yt(x++))<<I,I+=8}if(g=3*(o+(_&Te[b])),_>>>=n[g+1],I-=n[g+1],k=n[g],0===k){f=n[g+2],t=6;break}if(0!=(16&k)){a=15&k,i=n[g+2],t=2;break}if(0==(64&k)){c=k,o=g/3+n[g+2];break}if(0!=(32&k)){t=7;break}return t=9,y.Xe="invalid literal/length code",m=-3,e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);case 2:for(b=a;b>I;){if(0===v)return e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);m=0,v--,_|=(255&y.yt(x++))<<I,I+=8}i+=_&Te[b],_>>=b,I-=b,c=w,n=s,o=d,t=3;case 3:for(b=c;b>I;){if(0===v)return e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);m=0,v--,_|=(255&y.yt(x++))<<I,I+=8}if(g=3*(o+(_&Te[b])),_>>=n[g+1],I-=n[g+1],k=n[g],0!=(16&k)){a=15&k,l=n[g+2],t=4;break}if(0==(64&k)){c=k,o=g/3+n[g+2];break}return t=9,y.Xe="invalid distance code",m=-3,e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);case 4:for(b=a;b>I;){if(0===v)return e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);m=0,v--,_|=(255&y.yt(x++))<<I,I+=8}l+=_&Te[b],_>>=b,I-=b,t=5;case 5:for(z=S-l;0>z;)z+=e.end;for(;0!==i;){if(0===C&&(S==e.end&&0!==e.read&&(S=0,C=S<e.read?e.read-S-1:e.end-S),0===C&&(e.write=S,m=e.kt(y,m),S=e.write,C=S<e.read?e.read-S-1:e.end-S,S==e.end&&0!==e.read&&(S=0,C=S<e.read?e.read-S-1:e.end-S),0===C)))return e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);e.bt[S++]=e.bt[z++],C--,z==e.end&&(z=0),i--}t=0;break;case 6:if(0===C&&(S==e.end&&0!==e.read&&(S=0,C=S<e.read?e.read-S-1:e.end-S),0===C&&(e.write=S,m=e.kt(y,m),S=e.write,C=S<e.read?e.read-S-1:e.end-S,S==e.end&&0!==e.read&&(S=0,C=S<e.read?e.read-S-1:e.end-S),0===C)))return e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);m=0,e.bt[S++]=f,C--,t=0;break;case 7:if(I>7&&(I-=8,v++,x--),e.write=S,m=e.kt(y,m),S=e.write,C=S<e.read?e.read-S-1:e.end-S,e.read!=e.write)return e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);t=8;case 8:return m=1,e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);case 9:return m=-3,e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m);default:return m=-2,e.ht=_,e.dt=I,y.Ge=v,y.Ze+=x-y.ft,y.ft=x,e.write=S,e.kt(y,m)}},e.vt=()=>{}}Oe.St=(e,t,n,r)=>(e[0]=9,t[0]=5,n[0]=Ue,r[0]=We,0);const Ge=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];function Je(e,t){const n=this;let r,i=0,o=0,f=0,a=0;const l=[0],u=[0],w=new qe;let h=0,d=new c(4320);const p=new Oe;n.dt=0,n.ht=0,n.bt=new s(t),n.end=t,n.read=0,n.write=0,n.reset=(e,t)=>{t&&(t[0]=0),6==i&&w.vt(e),i=0,n.dt=0,n.ht=0,n.read=n.write=0},n.reset(e,null),n.kt=(e,t)=>{let r,s,i;return s=e.lt,i=n.read,r=(i>n.write?n.end:n.write)-i,r>e.ct&&(r=e.ct),0!==r&&-5==t&&(t=0),e.ct-=r,e.$e+=r,e.it.set(n.bt.subarray(i,i+r),s),s+=r,i+=r,i==n.end&&(i=0,n.write==n.end&&(n.write=0),r=n.write-i,r>e.ct&&(r=e.ct),0!==r&&-5==t&&(t=0),e.ct-=r,e.$e+=r,e.it.set(n.bt.subarray(i,i+r),s),s+=r,i+=r),e.lt=s,n.read=i,t},n.gt=(e,t)=>{let s,c,y,m,b,g,k,v;for(m=e.ft,b=e.Ge,c=n.ht,y=n.dt,g=n.write,k=g<n.read?n.read-g-1:n.end-g;;){let S,C,z,_,I,x,A,D;switch(i){case 0:for(;3>y;){if(0===b)return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);t=0,b--,c|=(255&e.yt(m++))<<y,y+=8}switch(s=7&c,h=1&s,s>>>1){case 0:c>>>=3,y-=3,s=7&y,c>>>=s,y-=s,i=1;break;case 1:S=[],C=[],z=[[]],_=[[]],Oe.St(S,C,z,_),w.init(S[0],C[0],z[0],0,_[0],0),c>>>=3,y-=3,i=6;break;case 2:c>>>=3,y-=3,i=3;break;case 3:return c>>>=3,y-=3,i=9,e.Xe="invalid block type",t=-3,n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t)}break;case 1:for(;32>y;){if(0===b)return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);t=0,b--,c|=(255&e.yt(m++))<<y,y+=8}if((~c>>>16&65535)!=(65535&c))return i=9,e.Xe="invalid stored block lengths",t=-3,n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);o=65535&c,c=y=0,i=0!==o?2:0!==h?7:0;break;case 2:if(0===b)return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);if(0===k&&(g==n.end&&0!==n.read&&(g=0,k=g<n.read?n.read-g-1:n.end-g),0===k&&(n.write=g,t=n.kt(e,t),g=n.write,k=g<n.read?n.read-g-1:n.end-g,g==n.end&&0!==n.read&&(g=0,k=g<n.read?n.read-g-1:n.end-g),0===k)))return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);if(t=0,s=o,s>b&&(s=b),s>k&&(s=k),n.bt.set(e.Je(m,s),g),m+=s,b-=s,g+=s,k-=s,0!=(o-=s))break;i=0!==h?7:0;break;case 3:for(;14>y;){if(0===b)return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);t=0,b--,c|=(255&e.yt(m++))<<y,y+=8}if(f=s=16383&c,(31&s)>29||(s>>5&31)>29)return i=9,e.Xe="too many length or distance symbols",t=-3,n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);if(s=258+(31&s)+(s>>5&31),!r||r.length<s)r=[];else for(v=0;s>v;v++)r[v]=0;c>>>=14,y-=14,a=0,i=4;case 4:for(;4+(f>>>10)>a;){for(;3>y;){if(0===b)return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);t=0,b--,c|=(255&e.yt(m++))<<y,y+=8}r[Ge[a++]]=7&c,c>>>=3,y-=3}for(;19>a;)r[Ge[a++]]=0;if(l[0]=7,s=p.ut(r,l,u,d,e),0!=s)return-3==(t=s)&&(r=null,i=9),n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);a=0,i=5;case 5:for(;s=f,258+(31&s)+(s>>5&31)>a;){let o,w;for(s=l[0];s>y;){if(0===b)return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);t=0,b--,c|=(255&e.yt(m++))<<y,y+=8}if(s=d[3*(u[0]+(c&Te[s]))+1],w=d[3*(u[0]+(c&Te[s]))+2],16>w)c>>>=s,y-=s,r[a++]=w;else{for(v=18==w?7:w-14,o=18==w?11:3;s+v>y;){if(0===b)return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);t=0,b--,c|=(255&e.yt(m++))<<y,y+=8}if(c>>>=s,y-=s,o+=c&Te[v],c>>>=v,y-=v,v=a,s=f,v+o>258+(31&s)+(s>>5&31)||16==w&&1>v)return r=null,i=9,e.Xe="invalid bit length repeat",t=-3,n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);w=16==w?r[v-1]:0;do{r[v++]=w}while(0!=--o);a=v}}if(u[0]=-1,I=[],x=[],A=[],D=[],I[0]=9,x[0]=6,s=f,s=p.wt(257+(31&s),1+(s>>5&31),r,I,x,A,D,d,e),0!=s)return-3==s&&(r=null,i=9),t=s,n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);w.init(I[0],x[0],d,A[0],d,D[0]),i=6;case 6:if(n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,1!=(t=w.gt(n,e,t)))return n.kt(e,t);if(t=0,w.vt(e),m=e.ft,b=e.Ge,c=n.ht,y=n.dt,g=n.write,k=g<n.read?n.read-g-1:n.end-g,0===h){i=0;break}i=7;case 7:if(n.write=g,t=n.kt(e,t),g=n.write,k=g<n.read?n.read-g-1:n.end-g,n.read!=n.write)return n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);i=8;case 8:return t=1,n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);case 9:return t=-3,n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t);default:return t=-2,n.ht=c,n.dt=y,e.Ge=b,e.Ze+=m-e.ft,e.ft=m,n.write=g,n.kt(e,t)}}},n.vt=e=>{n.reset(e,null),n.bt=null,d=null},n.Ct=(e,t,r)=>{n.bt.set(e.subarray(t,t+r),0),n.read=n.write=r},n.zt=()=>1==i?1:0}const Qe=[0,0,255,255];function Xe(){const e=this;function t(e){return e&&e._t?(e.Ze=e.$e=0,e.Xe=null,e._t.mode=7,e._t.It.reset(e,null),0):-2}e.mode=0,e.method=0,e.xt=[0],e.At=0,e.marker=0,e.Dt=0,e.Vt=t=>(e.It&&e.It.vt(t),e.It=null,0),e.Rt=(n,r)=>(n.Xe=null,e.It=null,8>r||r>15?(e.Vt(n),-2):(e.Dt=r,n._t.It=new Je(n,1<<r),t(n),0)),e.Bt=(e,t)=>{let n,r;if(!e||!e._t||!e.ot)return-2;const s=e._t;for(t=4==t?-5:0,n=-5;;)switch(s.mode){case 0:if(0===e.Ge)return n;if(n=t,e.Ge--,e.Ze++,8!=(15&(s.method=e.yt(e.ft++)))){s.mode=13,e.Xe="unknown compression method",s.marker=5;break}if(8+(s.method>>4)>s.Dt){s.mode=13,e.Xe="invalid win size",s.marker=5;break}s.mode=1;case 1:if(0===e.Ge)return n;if(n=t,e.Ge--,e.Ze++,r=255&e.yt(e.ft++),((s.method<<8)+r)%31!=0){s.mode=13,e.Xe="incorrect header check",s.marker=5;break}if(0==(32&r)){s.mode=7;break}s.mode=2;case 2:if(0===e.Ge)return n;n=t,e.Ge--,e.Ze++,s.At=(255&e.yt(e.ft++))<<24&4278190080,s.mode=3;case 3:if(0===e.Ge)return n;n=t,e.Ge--,e.Ze++,s.At+=(255&e.yt(e.ft++))<<16&16711680,s.mode=4;case 4:if(0===e.Ge)return n;n=t,e.Ge--,e.Ze++,s.At+=(255&e.yt(e.ft++))<<8&65280,s.mode=5;case 5:return 0===e.Ge?n:(n=t,e.Ge--,e.Ze++,s.At+=255&e.yt(e.ft++),s.mode=6,2);case 6:return s.mode=13,e.Xe="need dictionary",s.marker=0,-2;case 7:if(n=s.It.gt(e,n),-3==n){s.mode=13,s.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,s.It.reset(e,s.xt),s.mode=12;case 12:return e.Ge=0,1;case 13:return-3;default:return-2}},e.Et=(e,t,n)=>{let r=0,s=n;if(!e||!e._t||6!=e._t.mode)return-2;const i=e._t;return s<1<<i.Dt||(s=(1<<i.Dt)-1,r=n-s),i.It.Ct(t,r,s),i.mode=7,0},e.Mt=e=>{let n,r,s,i,o;if(!e||!e._t)return-2;const c=e._t;if(13!=c.mode&&(c.mode=13,c.marker=0),0===(n=e.Ge))return-5;for(r=e.ft,s=c.marker;0!==n&&4>s;)e.yt(r)==Qe[s]?s++:s=0!==e.yt(r)?0:4-s,r++,n--;return e.Ze+=r-e.ft,e.ft=r,e.Ge=n,c.marker=s,4!=s?-3:(i=e.Ze,o=e.$e,t(e),e.Ze=i,e.$e=o,c.mode=7,0)},e.Kt=e=>e&&e._t&&e._t.It?e._t.It.zt():-2}function Ye(){}function Ze(e){const t=new Ye,i=e&&e.chunkSize?n.floor(2*e.chunkSize):131072,o=new s(i);let c=!1;t.Rt(),t.it=o,this.append=(e,n)=>{const f=[];let a,l,u=0,w=0,h=0;if(0!==e.length){t.ft=0,t.ot=e,t.Ge=e.length;do{if(t.lt=0,t.ct=i,0!==t.Ge||c||(t.ft=0,c=!0),a=t.Bt(0),c&&-5===a){if(0!==t.Ge)throw new r("inflating: bad input")}else if(0!==a&&1!==a)throw new r("inflating: "+t.Xe);if((c||1===a)&&t.Ge===e.length)throw new r("inflating: bad input");t.lt&&(t.lt===i?f.push(new s(o)):f.push(o.slice(0,t.lt))),h+=t.lt,n&&t.ft>0&&t.ft!=u&&(n(t.ft),u=t.ft)}while(t.Ge>0||0===t.ct);return f.length>1?(l=new s(h),f.forEach((e=>{l.set(e,w),w+=e.length}))):l=f[0]||new s,l}},this.flush=()=>{t.Vt()}}Ye.prototype={Rt(e){const t=this;return t._t=new Xe,e||(e=15),t._t.Rt(t,e)},Bt(e){const t=this;return t._t?t._t.Bt(t,e):-2},Vt(){const e=this;if(!e._t)return-2;const t=e._t.Vt(e);return e._t=null,t},Mt(){const e=this;return e._t?e._t.Mt(e):-2},Et(e,t){const n=this;return n._t?n._t.Et(n,e,t):-2},yt(e){return this.ot[e]},Je(e,t){return this.ot.subarray(e,e+t)}},self.initCodec=()=>{self.Deflate=Pe,self.Inflate=Ze};\n'],{type:"text/javascript"}));e({workerScripts:{inflate:[t],deflate:[t]}});}
|
|
1845
|
+
|
|
1846
|
+
/*
|
|
1847
|
+
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
1848
|
+
|
|
1849
|
+
Redistribution and use in source and binary forms, with or without
|
|
1850
|
+
modification, are permitted provided that the following conditions are met:
|
|
1851
|
+
|
|
1852
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
1853
|
+
this list of conditions and the following disclaimer.
|
|
1854
|
+
|
|
1855
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
1856
|
+
notice, this list of conditions and the following disclaimer in
|
|
1857
|
+
the documentation and/or other materials provided with the distribution.
|
|
1858
|
+
|
|
1859
|
+
3. The names of the authors may not be used to endorse or promote products
|
|
1860
|
+
derived from this software without specific prior written permission.
|
|
1861
|
+
|
|
1862
|
+
THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
|
1863
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
1864
|
+
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT,
|
|
1865
|
+
INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
1866
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
1867
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
|
1868
|
+
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
1869
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
1870
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
1871
|
+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1872
|
+
*/
|
|
1873
|
+
|
|
1874
|
+
function getMimeType() {
|
|
1875
|
+
return "application/octet-stream";
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
function initShimAsyncCodec(library, options = {}, registerDataHandler) {
|
|
1879
|
+
return {
|
|
1880
|
+
Deflate: createCodecClass(library.Deflate, options.deflate, registerDataHandler),
|
|
1881
|
+
Inflate: createCodecClass(library.Inflate, options.inflate, registerDataHandler)
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
function createCodecClass(constructor, constructorOptions, registerDataHandler) {
|
|
1886
|
+
return class {
|
|
1887
|
+
|
|
1888
|
+
constructor(options) {
|
|
1889
|
+
const codecAdapter = this;
|
|
1890
|
+
const onData = data => {
|
|
1891
|
+
if (codecAdapter.pendingData) {
|
|
1892
|
+
const { pendingData } = codecAdapter;
|
|
1893
|
+
codecAdapter.pendingData = new Uint8Array(pendingData.length + data.length);
|
|
1894
|
+
pendingData.set(pendingData, 0);
|
|
1895
|
+
pendingData.set(data, pendingData.length);
|
|
1896
|
+
} else {
|
|
1897
|
+
codecAdapter.pendingData = new Uint8Array(data);
|
|
1898
|
+
}
|
|
1899
|
+
};
|
|
1900
|
+
if (Object.hasOwn(options, "level") && options.level === undefined) {
|
|
1901
|
+
delete options.level;
|
|
1902
|
+
}
|
|
1903
|
+
codecAdapter.codec = new constructor(Object.assign({}, constructorOptions, options));
|
|
1904
|
+
registerDataHandler(codecAdapter.codec, onData);
|
|
1905
|
+
}
|
|
1906
|
+
append(data) {
|
|
1907
|
+
this.codec.push(data);
|
|
1908
|
+
return getResponse(this);
|
|
1909
|
+
}
|
|
1910
|
+
flush() {
|
|
1911
|
+
this.codec.push(new Uint8Array(), true);
|
|
1912
|
+
return getResponse(this);
|
|
1913
|
+
}
|
|
1914
|
+
};
|
|
1915
|
+
|
|
1916
|
+
function getResponse(codec) {
|
|
1917
|
+
if (codec.pendingData) {
|
|
1918
|
+
const output = codec.pendingData;
|
|
1919
|
+
codec.pendingData = null;
|
|
1920
|
+
return output;
|
|
1921
|
+
} else {
|
|
1922
|
+
return new Uint8Array();
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
1927
|
/*
|
|
1928
1928
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
1929
1929
|
|
|
@@ -1960,10 +1960,9 @@
|
|
|
1960
1960
|
|
|
1961
1961
|
constructor(workerData, stream, workerOptions, onTaskFinished) {
|
|
1962
1962
|
const { readable, writable } = stream;
|
|
1963
|
-
const { options, config, streamOptions, useWebWorkers, transferStreams, scripts
|
|
1963
|
+
const { options, config, streamOptions, useWebWorkers, transferStreams, scripts } = workerOptions;
|
|
1964
1964
|
Object.assign(workerData, {
|
|
1965
1965
|
busy: true,
|
|
1966
|
-
codecConstructor,
|
|
1967
1966
|
readable,
|
|
1968
1967
|
writable,
|
|
1969
1968
|
options: Object.assign({}, options),
|
|
@@ -2016,7 +2015,7 @@
|
|
|
2016
2015
|
}
|
|
2017
2016
|
|
|
2018
2017
|
function createWorkerInterface(workerData, config) {
|
|
2019
|
-
const interfaceCodec = new Codec(workerData.
|
|
2018
|
+
const interfaceCodec = new Codec(workerData.readable, workerData.writable, workerData.options, config);
|
|
2020
2019
|
const { onTaskFinished } = workerData;
|
|
2021
2020
|
const codec = {
|
|
2022
2021
|
async run() {
|
|
@@ -2217,7 +2216,7 @@
|
|
|
2217
2216
|
const streamCopy = !compressed && !signed && !encrypted && !workerOptions.transferStreams;
|
|
2218
2217
|
workerOptions.useWebWorkers = !streamCopy && (useWebWorkers || (useWebWorkers === undefined && config.useWebWorkers));
|
|
2219
2218
|
workerOptions.scripts = workerOptions.useWebWorkers && workerScripts ? workerScripts[codecType] : [];
|
|
2220
|
-
options.useCompressionStream = useCompressionStream === undefined
|
|
2219
|
+
options.useCompressionStream = useCompressionStream || (useCompressionStream === undefined && config.useCompressionStream);
|
|
2221
2220
|
let worker;
|
|
2222
2221
|
if (pool.length < config.maxWorkers) {
|
|
2223
2222
|
const workerData = { indexWorker };
|
|
@@ -2369,52 +2368,6 @@
|
|
|
2369
2368
|
}
|
|
2370
2369
|
}
|
|
2371
2370
|
|
|
2372
|
-
class TextReader extends Reader {
|
|
2373
|
-
|
|
2374
|
-
constructor(text) {
|
|
2375
|
-
super();
|
|
2376
|
-
this.blobReader = new BlobReader(new Blob([text], { type: CONTENT_TYPE_TEXT_PLAIN }));
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
init() {
|
|
2380
|
-
const reader = this;
|
|
2381
|
-
super.init();
|
|
2382
|
-
reader.blobReader.init();
|
|
2383
|
-
reader.size = reader.blobReader.size;
|
|
2384
|
-
}
|
|
2385
|
-
|
|
2386
|
-
readUint8Array(offset, length) {
|
|
2387
|
-
return this.blobReader.readUint8Array(offset, length);
|
|
2388
|
-
}
|
|
2389
|
-
}
|
|
2390
|
-
|
|
2391
|
-
class TextWriter extends Writer {
|
|
2392
|
-
|
|
2393
|
-
constructor(encoding) {
|
|
2394
|
-
super();
|
|
2395
|
-
this.encoding = encoding;
|
|
2396
|
-
this.blob = new Blob([], { type: CONTENT_TYPE_TEXT_PLAIN });
|
|
2397
|
-
}
|
|
2398
|
-
|
|
2399
|
-
writeUint8Array(array) {
|
|
2400
|
-
this.blob = new Blob([this.blob, array.buffer], { type: CONTENT_TYPE_TEXT_PLAIN });
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
|
-
getData() {
|
|
2404
|
-
const writer = this;
|
|
2405
|
-
if (writer.blob.text && (writer.encoding === undefined || (writer.encoding && writer.encoding.toLowerCase() == "utf-8"))) {
|
|
2406
|
-
return writer.blob.text();
|
|
2407
|
-
} else {
|
|
2408
|
-
const reader = new FileReader();
|
|
2409
|
-
return new Promise((resolve, reject) => {
|
|
2410
|
-
reader.onload = event => resolve(event.target.result);
|
|
2411
|
-
reader.onerror = () => reject(reader.error);
|
|
2412
|
-
reader.readAsText(writer.blob, writer.encoding);
|
|
2413
|
-
});
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
}
|
|
2417
|
-
|
|
2418
2371
|
class Data64URIReader extends Reader {
|
|
2419
2372
|
|
|
2420
2373
|
constructor(dataURI) {
|
|
@@ -2511,6 +2464,42 @@
|
|
|
2511
2464
|
}
|
|
2512
2465
|
}
|
|
2513
2466
|
|
|
2467
|
+
class TextReader extends BlobReader {
|
|
2468
|
+
|
|
2469
|
+
constructor(text) {
|
|
2470
|
+
super(new Blob([text], { type: CONTENT_TYPE_TEXT_PLAIN }));
|
|
2471
|
+
}
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
class TextWriter extends BlobWriter {
|
|
2475
|
+
|
|
2476
|
+
constructor(encoding) {
|
|
2477
|
+
super(encoding);
|
|
2478
|
+
Object.assign(this, {
|
|
2479
|
+
encoding,
|
|
2480
|
+
utf8: !encoding || encoding.toLowerCase() == "utf-8"
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
async getData() {
|
|
2485
|
+
const {
|
|
2486
|
+
encoding,
|
|
2487
|
+
utf8
|
|
2488
|
+
} = this;
|
|
2489
|
+
const blob = await super.getData();
|
|
2490
|
+
if (blob.text && utf8) {
|
|
2491
|
+
return blob.text();
|
|
2492
|
+
} else {
|
|
2493
|
+
const reader = new FileReader();
|
|
2494
|
+
return new Promise((resolve, reject) => {
|
|
2495
|
+
reader.onload = ({ target }) => resolve(target.result);
|
|
2496
|
+
reader.onerror = () => reject(reader.error);
|
|
2497
|
+
reader.readAsText(blob, encoding);
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2514
2503
|
class FetchReader extends Reader {
|
|
2515
2504
|
|
|
2516
2505
|
constructor(url, options) {
|
|
@@ -2877,7 +2866,7 @@
|
|
|
2877
2866
|
const CP437 = "\0☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ".split("");
|
|
2878
2867
|
const VALID_CP437 = CP437.length == 256;
|
|
2879
2868
|
|
|
2880
|
-
|
|
2869
|
+
function decodeCP437(stringValue) {
|
|
2881
2870
|
if (VALID_CP437) {
|
|
2882
2871
|
let result = "";
|
|
2883
2872
|
for (let indexCharacter = 0; indexCharacter < stringValue.length; indexCharacter++) {
|
|
@@ -2887,7 +2876,7 @@
|
|
|
2887
2876
|
} else {
|
|
2888
2877
|
return new TextDecoder().decode(stringValue);
|
|
2889
2878
|
}
|
|
2890
|
-
}
|
|
2879
|
+
}
|
|
2891
2880
|
|
|
2892
2881
|
/*
|
|
2893
2882
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
@@ -3014,6 +3003,11 @@
|
|
|
3014
3003
|
class ZipReader {
|
|
3015
3004
|
|
|
3016
3005
|
constructor(reader, options = {}) {
|
|
3006
|
+
if (reader instanceof ReadableStream) {
|
|
3007
|
+
reader = {
|
|
3008
|
+
readable: reader
|
|
3009
|
+
};
|
|
3010
|
+
}
|
|
3017
3011
|
Object.assign(this, {
|
|
3018
3012
|
reader,
|
|
3019
3013
|
options,
|
|
@@ -3227,6 +3221,11 @@
|
|
|
3227
3221
|
const readable = reader.readable;
|
|
3228
3222
|
readable.offset = dataOffset;
|
|
3229
3223
|
const size = readable.size = compressedSize;
|
|
3224
|
+
if (writer instanceof WritableStream) {
|
|
3225
|
+
writer = {
|
|
3226
|
+
writable: writer
|
|
3227
|
+
};
|
|
3228
|
+
}
|
|
3230
3229
|
const { writable } = writer;
|
|
3231
3230
|
if (writable.size === undefined) {
|
|
3232
3231
|
writable.size = 0;
|
|
@@ -3252,8 +3251,7 @@
|
|
|
3252
3251
|
preventClose
|
|
3253
3252
|
},
|
|
3254
3253
|
config,
|
|
3255
|
-
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
3256
|
-
codecConstructor: config.Inflate
|
|
3254
|
+
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
3257
3255
|
};
|
|
3258
3256
|
writable.size += (await runWorker({ readable, writable }, workerOptions)).size;
|
|
3259
3257
|
if (!preventClose) {
|
|
@@ -3572,6 +3570,9 @@
|
|
|
3572
3570
|
class ZipWriter {
|
|
3573
3571
|
|
|
3574
3572
|
constructor(writer, options = {}) {
|
|
3573
|
+
if (writer instanceof WritableStream) {
|
|
3574
|
+
writer = { writable: writer };
|
|
3575
|
+
}
|
|
3575
3576
|
if (writer.writable.size == undefined) {
|
|
3576
3577
|
writer.writable.size = 0;
|
|
3577
3578
|
}
|
|
@@ -3644,12 +3645,12 @@
|
|
|
3644
3645
|
options.directory = name.endsWith(DIRECTORY_SIGNATURE);
|
|
3645
3646
|
}
|
|
3646
3647
|
const rawFilename = encodeText(name);
|
|
3647
|
-
if (rawFilename
|
|
3648
|
+
if (getLength(rawFilename) > MAX_16_BITS) {
|
|
3648
3649
|
throw new Error(ERR_INVALID_ENTRY_NAME);
|
|
3649
3650
|
}
|
|
3650
3651
|
const comment = options.comment || "";
|
|
3651
3652
|
const rawComment = encodeText(comment);
|
|
3652
|
-
if (rawComment
|
|
3653
|
+
if (getLength(rawComment) > MAX_16_BITS) {
|
|
3653
3654
|
throw new Error(ERR_INVALID_ENTRY_COMMENT);
|
|
3654
3655
|
}
|
|
3655
3656
|
const version = zipWriter.options.version || options.version || 0;
|
|
@@ -3674,19 +3675,19 @@
|
|
|
3674
3675
|
if (extraField) {
|
|
3675
3676
|
let extraFieldSize = 0;
|
|
3676
3677
|
let offset = 0;
|
|
3677
|
-
extraField.forEach(data => extraFieldSize += 4 + data
|
|
3678
|
+
extraField.forEach(data => extraFieldSize += 4 + getLength(data));
|
|
3678
3679
|
rawExtraField = new Uint8Array(extraFieldSize);
|
|
3679
3680
|
extraField.forEach((data, type) => {
|
|
3680
3681
|
if (type > MAX_16_BITS) {
|
|
3681
3682
|
throw new Error(ERR_INVALID_EXTRAFIELD_TYPE);
|
|
3682
3683
|
}
|
|
3683
|
-
if (data
|
|
3684
|
+
if (getLength(data) > MAX_16_BITS) {
|
|
3684
3685
|
throw new Error(ERR_INVALID_EXTRAFIELD_DATA);
|
|
3685
3686
|
}
|
|
3686
3687
|
arraySet(rawExtraField, new Uint16Array([type]), offset);
|
|
3687
|
-
arraySet(rawExtraField, new Uint16Array([data
|
|
3688
|
+
arraySet(rawExtraField, new Uint16Array([getLength(data)]), offset + 2);
|
|
3688
3689
|
arraySet(rawExtraField, data, offset + 4);
|
|
3689
|
-
offset += 4 + data
|
|
3690
|
+
offset += 4 + getLength(data);
|
|
3690
3691
|
});
|
|
3691
3692
|
}
|
|
3692
3693
|
let extendedTimestamp = getOptionValue(zipWriter, options, "extendedTimestamp");
|
|
@@ -3706,25 +3707,34 @@
|
|
|
3706
3707
|
}
|
|
3707
3708
|
const internalFileAttribute = getOptionValue(zipWriter, options, "internalFileAttribute") || 0;
|
|
3708
3709
|
const externalFileAttribute = getOptionValue(zipWriter, options, "externalFileAttribute") || 0;
|
|
3710
|
+
let zip64 = getOptionValue(zipWriter, options, "zip64");
|
|
3709
3711
|
if (reader) {
|
|
3712
|
+
if (reader instanceof ReadableStream) {
|
|
3713
|
+
reader = {
|
|
3714
|
+
readable: reader
|
|
3715
|
+
};
|
|
3716
|
+
}
|
|
3710
3717
|
await initStream(reader);
|
|
3711
3718
|
if (reader.size === undefined) {
|
|
3712
3719
|
options.dataDescriptor = true;
|
|
3720
|
+
if (zip64 === undefined) {
|
|
3721
|
+
zip64 = true;
|
|
3722
|
+
}
|
|
3713
3723
|
} else {
|
|
3714
3724
|
uncompressedSize = reader.size;
|
|
3715
3725
|
}
|
|
3716
3726
|
maximumCompressedSize = getMaximumCompressedSize(uncompressedSize);
|
|
3717
3727
|
}
|
|
3718
|
-
let zip64 = options.zip64 || zipWriter.options.zip64 || false;
|
|
3719
3728
|
if (zipWriter.offset + zipWriter.pendingEntriesSize >= MAX_32_BITS ||
|
|
3720
3729
|
uncompressedSize >= MAX_32_BITS ||
|
|
3721
3730
|
maximumCompressedSize >= MAX_32_BITS) {
|
|
3722
|
-
if (
|
|
3731
|
+
if (zip64 === false || !keepOrder) {
|
|
3723
3732
|
throw new Error(ERR_UNSUPPORTED_FORMAT);
|
|
3724
3733
|
} else {
|
|
3725
3734
|
zip64 = true;
|
|
3726
3735
|
}
|
|
3727
3736
|
}
|
|
3737
|
+
zip64 = zip64 || false;
|
|
3728
3738
|
const level = getOptionValue(zipWriter, options, "level");
|
|
3729
3739
|
const useWebWorkers = getOptionValue(zipWriter, options, "useWebWorkers");
|
|
3730
3740
|
const bufferedWrite = getOptionValue(zipWriter, options, "bufferedWrite");
|
|
@@ -3766,11 +3776,16 @@
|
|
|
3766
3776
|
});
|
|
3767
3777
|
const headerInfo = getHeaderInfo(options);
|
|
3768
3778
|
const dataDescriptorInfo = getDataDescriptorInfo(options);
|
|
3769
|
-
maximumEntrySize = headerInfo.localHeaderArray.
|
|
3779
|
+
maximumEntrySize = getLength(headerInfo.localHeaderArray, dataDescriptorInfo.dataDescriptorArray) + maximumCompressedSize;
|
|
3770
3780
|
zipWriter.pendingEntriesSize += maximumEntrySize;
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
zipWriter
|
|
3781
|
+
let fileEntry;
|
|
3782
|
+
try {
|
|
3783
|
+
fileEntry = await getFileEntry(zipWriter, name, reader, { headerInfo, dataDescriptorInfo }, options);
|
|
3784
|
+
} catch (error) {
|
|
3785
|
+
if (!error.corruptedEntry && maximumEntrySize) {
|
|
3786
|
+
zipWriter.pendingEntriesSize -= maximumEntrySize;
|
|
3787
|
+
}
|
|
3788
|
+
throw error;
|
|
3774
3789
|
}
|
|
3775
3790
|
Object.assign(fileEntry, { name, comment, extraField });
|
|
3776
3791
|
return new Entry(fileEntry);
|
|
@@ -3979,8 +3994,7 @@
|
|
|
3979
3994
|
transferStreams: false
|
|
3980
3995
|
},
|
|
3981
3996
|
config,
|
|
3982
|
-
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
3983
|
-
codecConstructor: config.Deflate
|
|
3997
|
+
streamOptions: { signal, size, onstart, onprogress, onend }
|
|
3984
3998
|
};
|
|
3985
3999
|
const result = await runWorker({ readable, writable }, workerOptions);
|
|
3986
4000
|
writable.size += result.size;
|
|
@@ -4011,7 +4025,7 @@
|
|
|
4011
4025
|
creationDate,
|
|
4012
4026
|
lastAccessDate,
|
|
4013
4027
|
encrypted,
|
|
4014
|
-
length: localHeaderArray
|
|
4028
|
+
length: getLength(localHeaderArray, dataDescriptorArray) + compressedSize,
|
|
4015
4029
|
compressionMethod,
|
|
4016
4030
|
version,
|
|
4017
4031
|
headerArray,
|
|
@@ -4038,10 +4052,10 @@
|
|
|
4038
4052
|
} = options;
|
|
4039
4053
|
let version = options.version || VERSION_DEFLATE;
|
|
4040
4054
|
const compressed = level !== 0 && !directory;
|
|
4041
|
-
const encrypted = Boolean(password && password
|
|
4055
|
+
const encrypted = Boolean(password && getLength(password));
|
|
4042
4056
|
let rawExtraFieldAES;
|
|
4043
4057
|
if (encrypted && !zipCrypto) {
|
|
4044
|
-
rawExtraFieldAES = new Uint8Array(EXTRAFIELD_DATA_AES
|
|
4058
|
+
rawExtraFieldAES = new Uint8Array(getLength(EXTRAFIELD_DATA_AES) + 2);
|
|
4045
4059
|
const extraFieldAESView = getDataView(rawExtraFieldAES);
|
|
4046
4060
|
setUint16(extraFieldAESView, 0, EXTRAFIELD_TYPE_AES);
|
|
4047
4061
|
arraySet(rawExtraFieldAES, EXTRAFIELD_DATA_AES, 2);
|
|
@@ -4055,7 +4069,7 @@
|
|
|
4055
4069
|
rawExtraFieldExtendedTimestamp = new Uint8Array(9 + (lastAccessDate ? 4 : 0) + (creationDate ? 4 : 0));
|
|
4056
4070
|
const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
|
|
4057
4071
|
setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
4058
|
-
setUint16(extraFieldExtendedTimestampView, 2, rawExtraFieldExtendedTimestamp
|
|
4072
|
+
setUint16(extraFieldExtendedTimestampView, 2, getLength(rawExtraFieldExtendedTimestamp) - 4);
|
|
4059
4073
|
const extraFieldExtendedTimestampFlag = 0x1 + (lastAccessDate ? 0x2 : 0) + (creationDate ? 0x4 : 0);
|
|
4060
4074
|
setUint8(extraFieldExtendedTimestampView, 4, extraFieldExtendedTimestampFlag);
|
|
4061
4075
|
setUint32(extraFieldExtendedTimestampView, 5, Math.floor(options.lastModDate.getTime() / 1000));
|
|
@@ -4122,18 +4136,18 @@
|
|
|
4122
4136
|
setUint16(dateView, 2, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate());
|
|
4123
4137
|
const rawLastModDate = dateArray[0];
|
|
4124
4138
|
setUint32(headerView, 6, rawLastModDate);
|
|
4125
|
-
setUint16(headerView, 22, rawFilename
|
|
4126
|
-
const extraFieldLength = rawExtraFieldAES
|
|
4139
|
+
setUint16(headerView, 22, getLength(rawFilename));
|
|
4140
|
+
const extraFieldLength = getLength(rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraField);
|
|
4127
4141
|
setUint16(headerView, 24, extraFieldLength);
|
|
4128
|
-
const localHeaderArray = new Uint8Array(30 + rawFilename
|
|
4142
|
+
const localHeaderArray = new Uint8Array(30 + getLength(rawFilename) + extraFieldLength);
|
|
4129
4143
|
const localHeaderView = getDataView(localHeaderArray);
|
|
4130
4144
|
setUint32(localHeaderView, 0, LOCAL_FILE_HEADER_SIGNATURE);
|
|
4131
4145
|
arraySet(localHeaderArray, headerArray, 4);
|
|
4132
4146
|
arraySet(localHeaderArray, rawFilename, 30);
|
|
4133
|
-
arraySet(localHeaderArray, rawExtraFieldAES, 30 + rawFilename
|
|
4134
|
-
arraySet(localHeaderArray, rawExtraFieldExtendedTimestamp, 30 + rawFilename
|
|
4135
|
-
arraySet(localHeaderArray, rawExtraFieldNTFS, 30 + rawFilename
|
|
4136
|
-
arraySet(localHeaderArray, rawExtraField, 30 + rawFilename
|
|
4147
|
+
arraySet(localHeaderArray, rawExtraFieldAES, 30 + getLength(rawFilename));
|
|
4148
|
+
arraySet(localHeaderArray, rawExtraFieldExtendedTimestamp, 30 + getLength(rawFilename, rawExtraFieldAES));
|
|
4149
|
+
arraySet(localHeaderArray, rawExtraFieldNTFS, 30 + getLength(rawFilename, rawExtraFieldAES, rawExtraFieldExtendedTimestamp));
|
|
4150
|
+
arraySet(localHeaderArray, rawExtraField, 30 + getLength(rawFilename, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS));
|
|
4137
4151
|
return {
|
|
4138
4152
|
localHeaderArray,
|
|
4139
4153
|
headerArray,
|
|
@@ -4231,13 +4245,14 @@
|
|
|
4231
4245
|
let filesLength = files.size;
|
|
4232
4246
|
for (const [, fileEntry] of files) {
|
|
4233
4247
|
directoryDataLength += 46 +
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4248
|
+
getLength(
|
|
4249
|
+
fileEntry.rawFilename,
|
|
4250
|
+
fileEntry.rawComment,
|
|
4251
|
+
fileEntry.rawExtraFieldZip64,
|
|
4252
|
+
fileEntry.rawExtraFieldAES,
|
|
4253
|
+
fileEntry.rawExtraFieldExtendedTimestamp,
|
|
4254
|
+
fileEntry.rawExtraFieldNTFS,
|
|
4255
|
+
fileEntry.rawExtraField);
|
|
4241
4256
|
}
|
|
4242
4257
|
let zip64 = options.zip64 || zipWriter.options.zip64 || false;
|
|
4243
4258
|
if (directoryOffset >= MAX_32_BITS || directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS) {
|
|
@@ -4271,18 +4286,18 @@
|
|
|
4271
4286
|
rawExtraFieldExtendedTimestamp = new Uint8Array(9);
|
|
4272
4287
|
const extraFieldExtendedTimestampView = getDataView(rawExtraFieldExtendedTimestamp);
|
|
4273
4288
|
setUint16(extraFieldExtendedTimestampView, 0, EXTRAFIELD_TYPE_EXTENDED_TIMESTAMP);
|
|
4274
|
-
setUint16(extraFieldExtendedTimestampView, 2, rawExtraFieldExtendedTimestamp
|
|
4289
|
+
setUint16(extraFieldExtendedTimestampView, 2, getLength(rawExtraFieldExtendedTimestamp) - 4);
|
|
4275
4290
|
setUint8(extraFieldExtendedTimestampView, 4, 0x1);
|
|
4276
4291
|
setUint32(extraFieldExtendedTimestampView, 5, Math.floor(fileEntry.lastModDate.getTime() / 1000));
|
|
4277
4292
|
} else {
|
|
4278
4293
|
rawExtraFieldNTFS = rawExtraFieldExtendedTimestamp = new Uint8Array();
|
|
4279
4294
|
}
|
|
4280
|
-
const extraFieldLength = rawExtraFieldZip64
|
|
4295
|
+
const extraFieldLength = getLength(rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS, rawExtraField);
|
|
4281
4296
|
setUint32(directoryView, offset, CENTRAL_FILE_HEADER_SIGNATURE);
|
|
4282
4297
|
setUint16(directoryView, offset + 4, versionMadeBy);
|
|
4283
4298
|
arraySet(directoryArray, headerArray, offset + 6);
|
|
4284
4299
|
setUint16(directoryView, offset + 30, extraFieldLength);
|
|
4285
|
-
setUint16(directoryView, offset + 32, rawComment
|
|
4300
|
+
setUint16(directoryView, offset + 32, getLength(rawComment));
|
|
4286
4301
|
setUint16(directoryView, offset + 36, internalFileAttribute);
|
|
4287
4302
|
if (externalFileAttribute) {
|
|
4288
4303
|
setUint32(directoryView, offset + 38, externalFileAttribute);
|
|
@@ -4295,13 +4310,13 @@
|
|
|
4295
4310
|
setUint32(directoryView, offset + 42, fileEntry.offset);
|
|
4296
4311
|
}
|
|
4297
4312
|
arraySet(directoryArray, rawFilename, offset + 46);
|
|
4298
|
-
arraySet(directoryArray, rawExtraFieldZip64, offset + 46 + rawFilename
|
|
4299
|
-
arraySet(directoryArray, rawExtraFieldAES, offset + 46 + rawFilename
|
|
4300
|
-
arraySet(directoryArray, rawExtraFieldExtendedTimestamp, offset + 46 + rawFilename
|
|
4301
|
-
arraySet(directoryArray, rawExtraFieldNTFS, offset + 46 + rawFilename
|
|
4302
|
-
arraySet(directoryArray, rawExtraField, offset + 46 + rawFilename
|
|
4303
|
-
arraySet(directoryArray, rawComment, offset + 46 + rawFilename
|
|
4304
|
-
offset += 46 + rawFilename
|
|
4313
|
+
arraySet(directoryArray, rawExtraFieldZip64, offset + 46 + getLength(rawFilename));
|
|
4314
|
+
arraySet(directoryArray, rawExtraFieldAES, offset + 46 + getLength(rawFilename, rawExtraFieldZip64));
|
|
4315
|
+
arraySet(directoryArray, rawExtraFieldExtendedTimestamp, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES));
|
|
4316
|
+
arraySet(directoryArray, rawExtraFieldNTFS, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp));
|
|
4317
|
+
arraySet(directoryArray, rawExtraField, offset + 46 + getLength(rawFilename, rawExtraFieldZip64, rawExtraFieldAES, rawExtraFieldExtendedTimestamp, rawExtraFieldNTFS));
|
|
4318
|
+
arraySet(directoryArray, rawComment, offset + 46 + getLength(rawFilename) + extraFieldLength);
|
|
4319
|
+
offset += 46 + getLength(rawFilename, rawComment) + extraFieldLength;
|
|
4305
4320
|
if (options.onprogress) {
|
|
4306
4321
|
try {
|
|
4307
4322
|
await options.onprogress(indexFileEntry + 1, files.size, new Entry(fileEntry));
|
|
@@ -4332,9 +4347,10 @@
|
|
|
4332
4347
|
setUint16(directoryView, offset + 10, filesLength);
|
|
4333
4348
|
setUint32(directoryView, offset + 12, directoryDataLength);
|
|
4334
4349
|
setUint32(directoryView, offset + 16, directoryOffset);
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4350
|
+
const commentLength = getLength(comment);
|
|
4351
|
+
if (commentLength) {
|
|
4352
|
+
if (commentLength <= MAX_16_BITS) {
|
|
4353
|
+
setUint16(directoryView, offset + 20, commentLength);
|
|
4338
4354
|
} else {
|
|
4339
4355
|
throw new Error(ERR_INVALID_COMMENT);
|
|
4340
4356
|
}
|
|
@@ -4342,7 +4358,7 @@
|
|
|
4342
4358
|
const { writable } = zipWriter.writer;
|
|
4343
4359
|
await initStream(zipWriter.writer);
|
|
4344
4360
|
await writeData(writable, directoryArray);
|
|
4345
|
-
if (
|
|
4361
|
+
if (commentLength) {
|
|
4346
4362
|
await writeData(writable, comment);
|
|
4347
4363
|
}
|
|
4348
4364
|
}
|
|
@@ -4358,7 +4374,7 @@
|
|
|
4358
4374
|
async function writeData(writable, array) {
|
|
4359
4375
|
const streamWriter = writable.getWriter();
|
|
4360
4376
|
await streamWriter.ready;
|
|
4361
|
-
writable.size += array
|
|
4377
|
+
writable.size += getLength(array);
|
|
4362
4378
|
await streamWriter.write(array);
|
|
4363
4379
|
streamWriter.releaseLock();
|
|
4364
4380
|
}
|
|
@@ -4401,6 +4417,12 @@
|
|
|
4401
4417
|
return new DataView(array.buffer);
|
|
4402
4418
|
}
|
|
4403
4419
|
|
|
4420
|
+
function getLength(...arrayLikes) {
|
|
4421
|
+
let result = 0;
|
|
4422
|
+
arrayLikes.forEach(arrayLike => arrayLike && (result += arrayLike.length));
|
|
4423
|
+
return result;
|
|
4424
|
+
}
|
|
4425
|
+
|
|
4404
4426
|
/*
|
|
4405
4427
|
Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
4406
4428
|
|
|
@@ -4476,7 +4498,7 @@
|
|
|
4476
4498
|
exports.ZipWriter = ZipWriter;
|
|
4477
4499
|
exports.configure = configure;
|
|
4478
4500
|
exports.getMimeType = getMimeType;
|
|
4479
|
-
exports.initShimAsyncCodec =
|
|
4501
|
+
exports.initShimAsyncCodec = initShimAsyncCodec;
|
|
4480
4502
|
exports.initStream = initStream;
|
|
4481
4503
|
exports.terminateWorkers = terminateWorkers;
|
|
4482
4504
|
|