diff --git a/dist/deflate.js b/dist/deflate.js deleted file mode 100644 index 30f2fb78..00000000 --- a/dist/deflate.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";!function(t){const e=256,n=256,i=-2,a=-5,o=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];function _(){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.build_tree=function(n){const i=t.dyn_tree,a=t.stat_desc.static_tree,o=t.stat_desc.elems;let _,r,l,u=-1;for(n.heap_len=0,n.heap_max=573,_=0;_=1;_--)n.pqdownheap(i,_);l=o;do{_=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(i,1),r=n.heap[1],n.heap[--n.heap_max]=_,n.heap[--n.heap_max]=r,i[2*l]=i[2*_]+i[2*r],n.depth[l]=Math.max(n.depth[_],n.depth[r])+1,i[2*_+1]=i[2*r+1]=l,n.heap[1]=l++,n.pqdownheap(i,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],function(e){const n=t.dyn_tree,i=t.stat_desc.static_tree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,_=t.stat_desc.max_length;let r,l,u,d,f,s,c=0;for(d=0;d<=15;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<573;r++)l=e.heap[r],d=n[2*n[2*l+1]+1]+1,d>_&&(d=_,c++),n[2*l+1]=d,l>t.max_code||(e.bl_count[d]++,f=0,l>=o&&(f=a[l-o]),s=n[2*l],e.opt_len+=s*(d+f),i&&(e.static_len+=s*(i[2*l+1]+f)));if(0!==c){do{for(d=_-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[_]--,c-=2}while(c>0);for(d=_;0!==d;d--)for(l=e.bl_count[d];0!==l;)u=e.heap[--r],u>t.max_code||(n[2*u+1]!=d&&(e.opt_len+=(d-n[2*u+1])*n[2*u],n[2*u+1]=d),l--)}}(n),function(t,n,i){const a=[];let o,_,r,l=0;for(o=1;o<=15;o++)a[o]=l=l+i[o-1]<<1;for(_=0;_<=n;_++)r=t[2*_+1],0!==r&&(t[2*_]=e(a[r]++,r))}(i,t.max_code,n.bl_count)}}function r(t,e,n,i,a){const o=this;o.static_tree=t,o.extra_bits=e,o.extra_base=n,o.elems=i,o.max_length=a}_._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],_.base_length=[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],_.base_dist=[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],_.d_code=function(t){return t<256?o[t]:o[256+(t>>>7)]},_.extra_lbits=[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],_.extra_dbits=[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],_.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],_.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],r.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8],r.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5],r.static_l_desc=new r(r.static_ltree,_.extra_lbits,257,286,15),r.static_d_desc=new r(r.static_dtree,_.extra_dbits,0,30,15),r.static_bl_desc=new r(null,_.extra_blbits,0,19,7);function l(t,e,n,i,a){const o=this;o.good_length=t,o.max_lazy=e,o.nice_length=n,o.max_chain=i,o.func=a}const u=[new l(0,0,0,0,0),new l(4,4,8,4,1),new l(4,5,16,8,1),new l(4,6,32,32,1),new l(4,4,16,16,2),new l(8,16,32,32,2),new l(8,16,128,128,2),new l(8,32,128,256,2),new l(32,128,258,1024,2),new l(32,258,258,4096,2)],d=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],f=113,s=666,c=258,h=262;function p(t,e,n,i){const a=t[2*e],o=t[2*n];return a>>8&255)}function lt(t,e){let n;const i=e;it>16-i?(n=t,nt|=n<>>16-it,it+=i-16):(nt|=t<=8&&(_t(255&nt),nt>>>=8,it-=8)}function st(n,i){let a,o,r;if(t.pending_buf[$+2*Y]=n>>>8&255,t.pending_buf[$+2*Y+1]=255&n,t.pending_buf[W+Y]=255&i,Y++,0===n?N[2*i]++:(tt++,n--,N[2*(_._length_code[i]+e+1)]++,O[2*_.d_code(n)]++),0==(8191&Y)&&H>2){for(a=8*Y,o=Z-I,r=0;r<30;r++)a+=O[2*r]*(5+_.extra_dbits[r]);if(a>>>=3,tt8?rt(nt):it>0&&_t(255&nt),nt=0,it=0}function pt(e,n,i){lt(0+(i?1:0),3),function(e,n,i){ht(),et=8,i&&(rt(n),rt(~n)),t.pending_buf.set(v.subarray(e,e+n),t.pending),t.pending+=n}(e,n,!0)}function xt(e,n,i){let a,o,l=0;H>0?(R.build_tree(t),T.build_tree(t),l=function(){let e;for(ot(N,R.max_code),ot(O,T.max_code),V.build_tree(t),e=18;e>=3&&0===Q[2*_.bl_order[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(),a=t.opt_len+3+7>>>3,o=t.static_len+3+7>>>3,o<=a&&(a=o)):a=o=n+5,n+4<=a&&-1!=e?pt(e,n,i):o==a?(lt(2+(i?1:0),3),ct(r.static_ltree,r.static_dtree)):(lt(4+(i?1:0),3),function(t,e,n){let i;for(lt(t-257,5),lt(e-1,5),lt(n-4,4),i=0;i=0?I:-1,Z-I,t),I=Z,o.flush_pending()}function gt(){let t,e,n,i;do{if(i=y-B-Z,0===i&&0===Z&&0===B)i=g;else if(-1==i)i--;else if(Z>=g+g-h){v.set(v.subarray(g,g+g),0),j-=g,Z-=g,I-=g,t=k,n=t;do{e=65535&E[--n],E[n]=e>=g?e-g:0}while(0!=--t);t=g,n=t;do{e=65535&A[--n],A[n]=e>=g?e-g:0}while(0!=--t);i+=g}if(0===o.avail_in)return;t=o.read_buf(v,Z+B,i),B+=t,B>=3&&(U=255&v[Z],U=(U<g-h?Z-(g-h):0;let r=L;const l=m,u=Z+c;let d=v[a+o-1],f=v[a+o];C>=K&&(i>>=2),r>B&&(r=B);do{if(e=t,v[e+o]==f&&v[e+o-1]==d&&v[e]==v[a]&&v[++e]==v[a+1]){a+=2,e++;do{}while(v[++a]==v[++e]&&v[++a]==v[++e]&&v[++a]==v[++e]&&v[++a]==v[++e]&&v[++a]==v[++e]&&v[++a]==v[++e]&&v[++a]==v[++e]&&v[++a]==v[++e]&&ao){if(j=t,o=n,n>=r)break;d=v[a+o-1],f=v[a+o]}}}while((t=65535&A[t&l])>_&&0!=--i);return o<=B?o:B}function mt(e){return e.total_in=e.total_out=0,e.msg=null,t.pending=0,t.pending_out=0,l=f,b=0,R.dyn_tree=N,R.stat_desc=r.static_l_desc,T.dyn_tree=O,T.stat_desc=r.static_d_desc,V.dyn_tree=Q,V.stat_desc=r.static_bl_desc,nt=0,it=0,et=8,at(),function(){y=2*g,E[k-1]=0;for(let t=0;t9||8!=o||a<9||a>15||n<0||n>9||r<0||r>2?i:(e.dstate=t,w=a,g=1<9||n<0||n>2?i:(u[H].func!=u[e].func&&0!==t.total_in&&(a=t.deflate(1)),H!=e&&(H=e,G=u[H].max_lazy,K=u[H].good_length,L=u[H].nice_length,F=u[H].max_chain),J=n,a)},t.deflateSetDictionary=function(t,e,n){let a,o=n,_=0;if(!e||42!=l)return i;if(o<3)return 0;for(o>g-h&&(o=g-h,_=n-o),v.set(e.subarray(_,_+o),0),Z=o,I=o,U=255&v[0],U=(U<4||_<0)return i;if(!e.next_out||!e.next_in&&0!==e.avail_in||l==s&&4!=_)return e.msg=d[4],i;if(0===e.avail_out)return e.msg=d[7],a;var K;if(o=e,M=b,b=_,42==l&&(p=8+(w-8<<4)<<8,y=(H-1&255)>>1,y>3&&(y=3),p|=y<<6,0!==Z&&(p|=32),p+=31-p%31,l=f,_t((K=p)>>8&255),_t(255&K)),0!==t.pending){if(o.flush_pending(),0===o.avail_out)return b=-1,0}else if(0===o.avail_in&&_<=M&&4!=_)return o.msg=d[7],a;if(l==s&&0!==o.avail_in)return e.msg=d[7],a;if(0!==o.avail_in||0!==B||0!=_&&l!=s){switch(F=-1,u[H].func){case 0:F=function(t){let e,n=65535;for(n>x-5&&(n=x-5);;){if(B<=1){if(gt(),0===B&&0==t)return 0;if(0===B)break}if(Z+=B,B=0,e=I+n,(0===Z||Z>=e)&&(B=Z-e,Z=e,bt(!1),0===o.avail_out))return 0;if(Z-I>=g-h&&(bt(!1),0===o.avail_out))return 0}return bt(4==t),0===o.avail_out?4==t?2:0:4==t?3:1}(_);break;case 1:F=function(t){let e,n=0;for(;;){if(B=3&&(U=(U<=3)if(e=st(Z-j,z-3),B-=z,z<=G&&B>=3){z--;do{Z++,U=(U<=3&&(U=(U<4096)&&(z=2)),C>=3&&z<=C){n=Z+B-3,e=st(Z-1-P,C-3),B-=C-1,C-=2;do{++Z<=n&&(U=(U<n&&(a=n),0===a?0:(i.avail_in-=a,t.set(i.next_in.subarray(i.next_in_index,i.next_in_index+a),e),i.next_in_index+=a,i.total_in+=a,a)},flush_pending:function(){const t=this;let e=t.dstate.pending;e>t.avail_out&&(e=t.avail_out),0!==e&&(t.next_out.set(t.dstate.pending_buf.subarray(t.dstate.pending_out,t.dstate.pending_out+e),t.next_out_index),t.next_out_index+=e,t.dstate.pending_out+=e,t.total_out+=e,t.avail_out-=e,t.dstate.pending-=e,0===t.dstate.pending&&(t.dstate.pending_out=0))}},t.ZipDeflate=function(t){const e=new b,n=512,i=new Uint8Array(n);let a=t?t.level:-1;void 0===a&&(a=-1),e.deflateInit(a),e.next_out=i,this.append=function(t,a){let o,_,r=0,l=0,u=0;const d=[];if(t.length){e.next_in_index=0,e.next_in=t,e.avail_in=t.length;do{if(e.next_out_index=0,e.avail_out=n,o=e.deflate(0),0!=o)throw new Error("deflating: "+e.msg);e.next_out_index&&(e.next_out_index==n?d.push(new Uint8Array(i)):d.push(new Uint8Array(i.subarray(0,e.next_out_index)))),u+=e.next_out_index,a&&e.next_in_index>0&&e.next_in_index!=r&&(a(e.next_in_index),r=e.next_in_index)}while(e.avail_in>0||0===e.avail_out);return _=new Uint8Array(u),d.forEach((function(t){_.set(t,l),l+=t.length})),_}},this.flush=function(){let t,a,o=0,_=0;const r=[];do{if(e.next_out_index=0,e.avail_out=n,t=e.deflate(4),1!=t&&0!=t)throw new Error("deflating: "+e.msg);n-e.avail_out>0&&r.push(new Uint8Array(i.subarray(0,e.next_out_index))),_+=e.next_out_index}while(e.avail_in>0||0===e.avail_out);return e.deflateEnd(),a=new Uint8Array(_),r.forEach((function(t){a.set(t,o),o+=t.length})),a}}}(this); \ No newline at end of file diff --git a/dist/inflate.js b/dist/inflate.js deleted file mode 100644 index ff0b23c1..00000000 --- a/dist/inflate.js +++ /dev/null @@ -1 +0,0 @@ -!function(i){"use strict";const e=-2,n=-3,t=-5,a=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],r=[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],_=[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],l=[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],d=[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],o=[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],f=[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],s=15;function b(){let i,e,a,r,_,b;function u(i,e,l,d,o,f,u,x,w,c,h){let k,v,m,y,g,p,A,E,I,S,U,D,z,P,Z;S=0,g=l;do{a[i[e+S]]++,S++,g--}while(0!==g);if(a[0]==l)return u[0]=-1,x[0]=0,0;for(E=x[0],p=1;p<=s&&0===a[p];p++);for(A=p,Eg&&(E=g),x[0]=E,P=1<D+E;){if(y++,D+=E,Z=m-D,Z=Z>E?E:Z,(v=1<<(p=A-D))>k+1&&(v-=k+1,z=A,p1440)return n;_[y]=U=c[0],c[0]+=Z,0!==y?(b[y]=g,r[0]=p,r[1]=E,p=g>>>D-E,r[2]=U-_[y-1]-p,w.set(r,3*(_[y-1]+p))):u[0]=U}for(r[1]=A-D,S>=l?r[0]=192:h[S]>>D;p>>=1)g^=p;for(g^=p,I=(1<257?(v==n?k.msg="oversubscribed distance tree":v==t?(k.msg="incomplete distance tree",v=n):-4!=v&&(k.msg="empty distance tree with lengths",v=n),v):0)}}b.inflate_trees_fixed=function(i,e,n,t){return i[0]=9,e[0]=5,n[0]=r,t[0]=_,0};function u(){const i=this;let t,r,_,l,d=0,o=0,f=0,s=0,b=0,u=0,x=0,w=0,c=0,h=0;function k(i,e,t,r,_,l,d,o){let f,s,b,u,x,w,c,h,k,v,m,y,g,p,A,E;c=o.next_in_index,h=o.avail_in,x=d.bitb,w=d.bitk,k=d.write,v=k>=s[E+1],w-=s[E+1],0!=(16&u)){for(u&=15,g=s[E+2]+(x&a[u]),x>>=u,w-=u;w<15;)h--,x|=(255&o.read_byte(c++))<>=s[E+1],w-=s[E+1],0!=(16&u)){for(u&=15;w>=u,w-=u,v-=g,k>=p)A=k-p,k-A>0&&2>k-A?(d.window[k++]=d.window[A++],d.window[k++]=d.window[A++],g-=2):(d.window.set(d.window.subarray(A,A+2),k),k+=2,A+=2,g-=2);else{A=k-p;do{A+=d.end}while(A<0);if(u=d.end-A,g>u){if(g-=u,k-A>0&&u>k-A)do{d.window[k++]=d.window[A++]}while(0!=--u);else d.window.set(d.window.subarray(A,A+u),k),k+=u,A+=u,u=0;A=0}}if(k-A>0&&g>k-A)do{d.window[k++]=d.window[A++]}while(0!=--g);else d.window.set(d.window.subarray(A,A+g),k),k+=g,A+=g,g=0;break}if(0!=(64&u))return o.msg="invalid distance code",g=o.avail_in-h,g=w>>3>3:g,h+=g,c-=g,w-=g<<3,d.bitb=x,d.bitk=w,o.avail_in=h,o.total_in+=c-o.next_in_index,o.next_in_index=c,d.write=k,n;f+=s[E+2],f+=x&a[u],E=3*(b+f),u=s[E]}break}if(0!=(64&u))return 0!=(32&u)?(g=o.avail_in-h,g=w>>3>3:g,h+=g,c-=g,w-=g<<3,d.bitb=x,d.bitk=w,o.avail_in=h,o.total_in+=c-o.next_in_index,o.next_in_index=c,d.write=k,1):(o.msg="invalid literal/length code",g=o.avail_in-h,g=w>>3>3:g,h+=g,c-=g,w-=g<<3,d.bitb=x,d.bitk=w,o.avail_in=h,o.total_in+=c-o.next_in_index,o.next_in_index=c,d.write=k,n);if(f+=s[E+2],f+=x&a[u],E=3*(b+f),0===(u=s[E])){x>>=s[E+1],w-=s[E+1],d.window[k++]=s[E+2],v--;break}}else x>>=s[E+1],w-=s[E+1],d.window[k++]=s[E+2],v--}while(v>=258&&h>=10);return g=o.avail_in-h,g=w>>3>3:g,h+=g,c-=g,w-=g<<3,d.bitb=x,d.bitk=w,o.avail_in=h,o.total_in+=c-o.next_in_index,o.next_in_index=c,d.write=k,0}i.init=function(i,e,n,a,d,o){t=0,x=i,w=e,_=n,c=a,l=d,h=o,r=null},i.proc=function(i,v,m){let y,g,p,A,E,I,S,U=0,D=0,z=0;for(z=v.next_in_index,A=v.avail_in,U=i.bitb,D=i.bitk,E=i.write,I=E=258&&A>=10&&(i.bitb=U,i.bitk=D,v.avail_in=A,v.total_in+=z-v.next_in_index,v.next_in_index=z,i.write=E,m=k(x,w,_,c,l,h,i,v),z=v.next_in_index,A=v.avail_in,U=i.bitb,D=i.bitk,E=i.write,I=E>>=r[g+1],D-=r[g+1],p=r[g],0===p){s=r[g+2],t=6;break}if(0!=(16&p)){b=15&p,d=r[g+2],t=2;break}if(0==(64&p)){f=p,o=g/3+r[g+2];break}if(0!=(32&p)){t=7;break}return t=9,v.msg="invalid literal/length code",m=n,i.bitb=U,i.bitk=D,v.avail_in=A,v.total_in+=z-v.next_in_index,v.next_in_index=z,i.write=E,i.inflate_flush(v,m);case 2:for(y=b;D>=y,D-=y,f=w,r=l,o=h,t=3;case 3:for(y=f;D>=r[g+1],D-=r[g+1],p=r[g],0!=(16&p)){b=15&p,u=r[g+2],t=4;break}if(0==(64&p)){f=p,o=g/3+r[g+2];break}return t=9,v.msg="invalid distance code",m=n,i.bitb=U,i.bitk=D,v.avail_in=A,v.total_in+=z-v.next_in_index,v.next_in_index=z,i.write=E,i.inflate_flush(v,m);case 4:for(y=b;D>=y,D-=y,t=5;case 5:for(S=E-u;S<0;)S+=i.end;for(;0!==d;){if(0===I&&(E==i.end&&0!==i.read&&(E=0,I=E7&&(D-=8,A++,z--),i.write=E,m=i.inflate_flush(v,m),E=i.write,I=Ei.avail_out&&(n=i.avail_out),0!==n&&e==t&&(e=0),i.avail_out-=n,i.total_out+=n,i.next_out.set(_.window.subarray(r,r+n),a),a+=n,r+=n,r==_.end&&(r=0,_.write==_.end&&(_.write=0),n=_.write-r,n>i.avail_out&&(n=i.avail_out),0!==n&&e==t&&(e=0),i.avail_out-=n,i.total_out+=n,i.next_out.set(_.window.subarray(r,r+n),a),a+=n,r+=n),i.next_out_index=a,_.read=r,e},_.proc=function(i,t){let r,u,y,g,p,A,E,I;for(g=i.next_in_index,p=i.avail_in,u=_.bitb,y=_.bitk,A=_.write,E=A<_.read?_.read-A-1:_.end-A;;){let S,U,D,z,P,Z,j,q;switch(d){case 0:for(;y<3;){if(0===p)return _.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);t=0,p--,u|=(255&i.read_byte(g++))<>>1){case 0:u>>>=3,y-=3,r=7&y,u>>>=r,y-=r,d=1;break;case 1:S=[],U=[],D=[[]],z=[[]],b.inflate_trees_fixed(S,U,D,z),h.init(S[0],U[0],D[0],0,z[0],0),u>>>=3,y-=3,d=6;break;case 2:u>>>=3,y-=3,d=3;break;case 3:return u>>>=3,y-=3,d=9,i.msg="invalid block type",t=n,_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t)}break;case 1:for(;y<32;){if(0===p)return _.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);t=0,p--,u|=(255&i.read_byte(g++))<>>16&65535)!=(65535&u))return d=9,i.msg="invalid stored block lengths",t=n,_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);o=65535&u,u=y=0,d=0!==o?2:0!==k?7:0;break;case 2:if(0===p)return _.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);if(0===E&&(A==_.end&&0!==_.read&&(A=0,E=A<_.read?_.read-A-1:_.end-A),0===E&&(_.write=A,t=_.inflate_flush(i,t),A=_.write,E=A<_.read?_.read-A-1:_.end-A,A==_.end&&0!==_.read&&(A=0,E=A<_.read?_.read-A-1:_.end-A),0===E)))return _.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);if(t=0,r=o,r>p&&(r=p),r>E&&(r=E),_.window.set(i.read_buf(g,r),A),g+=r,p-=r,A+=r,E-=r,0!=(o-=r))break;d=0!==k?7:0;break;case 3:for(;y<14;){if(0===p)return _.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);t=0,p--,u|=(255&i.read_byte(g++))<29||(r>>5&31)>29)return d=9,i.msg="too many length or distance symbols",t=n,_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);if(r=258+(31&r)+(r>>5&31),!l||l.length>>=14,y-=14,s=0,d=4;case 4:for(;s<4+(f>>>10);){for(;y<3;){if(0===p)return _.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);t=0,p--,u|=(255&i.read_byte(g++))<>>=3,y-=3}for(;s<19;)l[x[s++]]=0;if(w[0]=7,r=m.inflate_trees_bits(l,w,c,v,i),0!=r)return(t=r)==n&&(l=null,d=9),_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);s=0,d=5;case 5:for(;r=f,!(s>=258+(31&r)+(r>>5&31));){let e,o;for(r=w[0];y>>=r,y-=r,l[s++]=o;else{for(I=18==o?7:o-14,e=18==o?11:3;y>>=r,y-=r,e+=u&a[I],u>>>=I,y-=I,I=s,r=f,I+e>258+(31&r)+(r>>5&31)||16==o&&I<1)return l=null,d=9,i.msg="invalid bit length repeat",t=n,_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);o=16==o?l[I-1]:0;do{l[I++]=o}while(0!=--e);s=I}}if(c[0]=-1,P=[],Z=[],j=[],q=[],P[0]=9,Z[0]=6,r=f,r=m.inflate_trees_dynamic(257+(31&r),1+(r>>5&31),l,P,Z,j,q,v,i),0!=r)return r==n&&(l=null,d=9),t=r,_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);h.init(P[0],Z[0],v,j[0],v,q[0]),d=6;case 6:if(_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,1!=(t=h.proc(_,i,t)))return _.inflate_flush(i,t);if(t=0,h.free(i),g=i.next_in_index,p=i.avail_in,u=_.bitb,y=_.bitk,A=_.write,E=A<_.read?_.read-A-1:_.end-A,0===k){d=0;break}d=7;case 7:if(_.write=A,t=_.inflate_flush(i,t),A=_.write,E=A<_.read?_.read-A-1:_.end-A,_.read!=_.write)return _.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);d=8;case 8:return t=1,_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);case 9:return t=n,_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t);default:return t=e,_.bitb=u,_.bitk=y,i.avail_in=p,i.total_in+=g-i.next_in_index,i.next_in_index=g,_.write=A,_.inflate_flush(i,t)}}},_.free=function(i){_.reset(i,null),_.window=null,v=null},_.set_dictionary=function(i,e,n){_.window.set(i.subarray(e,e+n),0),_.read=_.write=n},_.sync_point=function(){return 1==d?1:0}}const c=13,h=[0,0,255,255];function k(){const i=this;function a(i){return i&&i.istate?(i.total_in=i.total_out=0,i.msg=null,i.istate.mode=7,i.istate.blocks.reset(i,null),0):e}i.mode=0,i.method=0,i.was=[0],i.need=0,i.marker=0,i.wbits=0,i.inflateEnd=function(e){return i.blocks&&i.blocks.free(e),i.blocks=null,0},i.inflateInit=function(n,t){return n.msg=null,i.blocks=null,t<8||t>15?(i.inflateEnd(n),e):(i.wbits=t,n.istate.blocks=new w(n,1<>4)>l.wbits){l.mode=c,i.msg="invalid window size",l.marker=5;break}l.mode=1;case 1:if(0===i.avail_in)return r;if(r=a,i.avail_in--,i.total_in++,_=255&i.read_byte(i.next_in_index++),((l.method<<8)+_)%31!=0){l.mode=c,i.msg="incorrect header check",l.marker=5;break}if(0==(32&_)){l.mode=7;break}l.mode=2;case 2:if(0===i.avail_in)return r;r=a,i.avail_in--,i.total_in++,l.need=(255&i.read_byte(i.next_in_index++))<<24&4278190080,l.mode=3;case 3:if(0===i.avail_in)return r;r=a,i.avail_in--,i.total_in++,l.need+=(255&i.read_byte(i.next_in_index++))<<16&16711680,l.mode=4;case 4:if(0===i.avail_in)return r;r=a,i.avail_in--,i.total_in++,l.need+=(255&i.read_byte(i.next_in_index++))<<8&65280,l.mode=5;case 5:return 0===i.avail_in?r:(r=a,i.avail_in--,i.total_in++,l.need+=255&i.read_byte(i.next_in_index++),l.mode=6,2);case 6:return l.mode=c,i.msg="need dictionary",l.marker=0,e;case 7:if(r=l.blocks.proc(i,r),r==n){l.mode=c,l.marker=0;break}if(0==r&&(r=a),1!=r)return r;r=a,l.blocks.reset(i,l.was),l.mode=12;case 12:return 1;case c:return n;default:return e}},i.inflateSetDictionary=function(i,n,t){let a=0,r=t;if(!i||!i.istate||6!=i.istate.mode)return e;const _=i.istate;return r>=1<<_.wbits&&(r=(1<<_.wbits)-1,a=t-r),_.blocks.set_dictionary(n,a,r),_.mode=7,0},i.inflateSync=function(i){let r,_,l,d,o;if(!i||!i.istate)return e;const f=i.istate;if(f.mode!=c&&(f.mode=c,f.marker=0),0===(r=i.avail_in))return t;for(_=i.next_in_index,l=f.marker;0!==r&&l<4;)i.read_byte(_)==h[l]?l++:l=0!==i.read_byte(_)?0:4-l,_++,r--;return i.total_in+=_-i.next_in_index,i.next_in_index=_,i.avail_in=r,f.marker=l,4!=l?n:(d=i.total_in,o=i.total_out,a(i),i.total_in=d,i.total_out=o,f.mode=7,0)},i.inflateSyncPoint=function(i){return i&&i.istate&&i.istate.blocks?i.istate.blocks.sync_point():e}}function v(){}v.prototype={inflateInit:function(i){const e=this;return e.istate=new k,i||(i=15),e.istate.inflateInit(e,i)},inflate:function(i){const n=this;return n.istate?n.istate.inflate(n,i):e},inflateEnd:function(){const i=this;if(!i.istate)return e;const n=i.istate.inflateEnd(i);return i.istate=null,n},inflateSync:function(){const i=this;return i.istate?i.istate.inflateSync(i):e},inflateSetDictionary:function(i,n){const t=this;return t.istate?t.istate.inflateSetDictionary(t,i,n):e},read_byte:function(i){return this.next_in.subarray(i,i+1)[0]},read_buf:function(i,e){return this.next_in.subarray(i,i+e)}},i.ZipInflate=function(){const i=new v,e=new Uint8Array(512);let n=!1;i.inflateInit(),i.next_out=e,this.append=function(a,r){const _=[];let l,d,o=0,f=0,s=0;if(0!==a.length){i.next_in_index=0,i.next_in=a,i.avail_in=a.length;do{if(i.next_out_index=0,i.avail_out=512,0!==i.avail_in||n||(i.next_in_index=0,n=!0),l=i.inflate(0),n&&l===t){if(0!==i.avail_in)throw new Error("inflating: bad input")}else if(0!==l&&1!==l)throw new Error("inflating: "+i.msg);if((n||1===l)&&i.avail_in===a.length)throw new Error("inflating: bad input");i.next_out_index&&(512===i.next_out_index?_.push(new Uint8Array(e)):_.push(new Uint8Array(e.subarray(0,i.next_out_index)))),s+=i.next_out_index,r&&i.next_in_index>0&&i.next_in_index!=o&&(r(i.next_in_index),o=i.next_in_index)}while(i.avail_in>0||0===i.avail_out);return d=new Uint8Array(s),_.forEach((function(i){d.set(i,f),f+=i.length})),d}},this.flush=function(){i.inflateEnd()}}}(this); \ No newline at end of file diff --git a/dist/z-worker-pako.js b/dist/z-worker-pako.js index cff90942..65d5613e 100644 --- a/dist/z-worker-pako.js +++ b/dist/z-worker-pako.js @@ -1 +1 @@ -!function(){"use strict";const t="function";function e(e,n){return class{constructor(s){const i=t=>{if(this.pendingData){const e=this.pendingData;this.pendingData=new Uint8Array(e.length+t.length),this.pendingData.set(e,0),this.pendingData.set(t,e.length)}else this.pendingData=new Uint8Array(t)};if(this.codec=new e(Object.assign({},n,s)),typeof this.codec.onData==t)this.codec.onData=i;else{if(typeof this.codec.on!=t)throw new Error("Cannot register the callback function");this.codec.on("data",i)}}async append(t){return this.codec.push(t),s(this)}async flush(){return this.codec.push(new Uint8Array(0),!0),s(this)}};function s(t){if(t.pendingData){const e=t.pendingData;return t.pendingData=null,e}return new Uint8Array(0)}}class n{constructor(){this.crc=-1,this.table=(()=>{const t=[];for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)1&n?n=n>>>1^3988292384:n>>>=1;t[e]=n}return t})()}append(t){const e=this.table;let n=0|this.crc;for(let s=0,i=0|t.length;s>>8^e[255&(n^t[s])];this.crc=n}get(){return~this.crc}}const s="Invalid pasword",i=16,a="raw",r={name:"PBKDF2"},c={name:"HMAC"},h="SHA-1",p={name:"AES-CTR"},o=Object.assign({hash:c},r),u=Object.assign({iterations:1e3,hash:{name:h}},r),d=Object.assign({hash:h},c),l=Object.assign({length:i},p),y=["deriveBits"],g=["sign"],w=528,f=10,b=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],A=crypto.subtle;class U{constructor(t,e){this.password=t,this.signed=e,this.input=e&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(t){const e=async(s=0)=>{if(s+i<=r.length-f){const t=r.subarray(s,s+i),a=await A.decrypt(Object.assign({counter:this.counter},l),this.keys.decrypt,t);return D(this.counter),n.set(new Uint8Array(a),s),e(s+i)}return this.pendingInput=r.subarray(s),this.signed&&(this.input=I(this.input,t)),n};if(this.password){const e=t.subarray(0,18);await async function(t,e,n){t.counter=new Uint8Array(b);const i=e.subarray(0,16),r=e.subarray(16),c=(new TextEncoder).encode(n),h=await A.importKey(a,c,o,!1,y),l=await A.deriveBits(Object.assign({salt:i},u),h,528),w=new Uint8Array(l),f=w.subarray(64);if(t.keys={decrypt:await A.importKey(a,w.subarray(0,32),p,!0,["decrypt"]),authentication:await A.importKey(a,w.subarray(32,64),d,!1,g),passwordVerification:f},f[0]!=r[0]||f[1]!=r[1])throw new Error(s)}(this,e,this.password),this.password=null,t=t.subarray(18)}let n=new Uint8Array(t.length-f-(t.length-f)%i),r=t;return this.pendingInput.length&&(r=I(this.pendingInput,t),n=k(n,r.length-f-(r.length-f)%i)),e()}async flush(){const t=this.pendingInput,e=this.keys,n=t.subarray(0,t.length-f),s=t.subarray(t.length-f);let i=new Uint8Array(0);if(n.length){const t=await A.decrypt(Object.assign({counter:this.counter},l),e.decrypt,n);i=new Uint8Array(t)}let a=!0;if(this.signed){const t=await A.sign(c,e.authentication,this.input.subarray(0,this.input.length-f)),n=new Uint8Array(t);this.input=null;for(let t=0;t{if(a+i<=t.length){const r=t.subarray(a,a+i),c=await A.encrypt(Object.assign({counter:this.counter},l),this.keys.encrypt,r);return D(this.counter),s.set(new Uint8Array(c),a+n.length),e(a+i)}return this.pendingInput=t.subarray(a),this.output=I(this.output,s),s};let n=new Uint8Array(0);this.password&&(n=await async function(t,e){t.counter=new Uint8Array(b);const n=crypto.getRandomValues(new Uint8Array(16)),s=(new TextEncoder).encode(e),i=await A.importKey(a,s,o,!1,y),r=await A.deriveBits(Object.assign({salt:n},u),i,w),c=new Uint8Array(r);return t.keys={encrypt:await A.importKey(a,c.subarray(0,32),p,!0,["encrypt"]),authentication:await A.importKey(a,c.subarray(32,64),d,!1,g),passwordVerification:c.subarray(64)},I(n,t.keys.passwordVerification)}(this,this.password),this.password=null);let s=new Uint8Array(n.length+t.length-t.length%i);return s.set(n,0),this.pendingInput.length&&(t=I(this.pendingInput,t),s=k(s,t.length-t.length%i)),e()}async flush(){let t=new Uint8Array(0);if(this.pendingInput.length){const e=await A.encrypt(Object.assign({counter:this.counter},l),this.keys.encrypt,this.pendingInput);t=new Uint8Array(e),this.output=I(this.output,t)}const e=await A.sign(c,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(e).subarray(0,f);return{data:I(t,n),signature:n}}}function D(t){for(let e=0;e<16;e++){if(255!=t[e]){t[e]++;break}t[e]=0}}function I(t,e){let n=t;return t.length+e.length&&(n=new Uint8Array(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function k(t,e){if(e&&e>t.length){const n=t;(t=new Uint8Array(e)).set(n,0)}return t}const v="Invalid signature";class E{constructor(t){this.signature=t.inputSignature,this.encrypted=Boolean(t.inputPassword),this.signed=t.inputSigned,this.compressed=t.inputCompressed,this.inflate=this.compressed&&new ZipInflate,this.crc32=this.signed&&this.signed&&new n,this.decrypt=this.encrypted&&new U(t.inputPassword)}async append(t){return this.encrypted&&(t=await this.decrypt.append(t)),this.compressed&&t.length&&(t=await this.inflate.append(t)),!this.encrypted&&this.signed&&this.crc32.append(t),t}async flush(){let t,e=new Uint8Array(0);if(this.encrypted){const t=await this.decrypt.flush();if(!t.valid)throw new Error(v);e=t.data}else if(this.signed){const e=new DataView(new Uint8Array(4).buffer);if(t=this.crc32.get(),e.setUint32(0,t),this.signature!=e.getUint32(0,!1))throw new Error(v)}return this.compressed&&(e=await this.inflate.append(e)||new Uint8Array(0),await this.inflate.flush()),{data:e,signature:t}}}class j{constructor(t){this.encrypted=t.outputEncrypted,this.signed=t.outputSigned,this.compressed=t.outputCompressed,this.deflate=this.compressed&&new ZipDeflate({level:t.level||5}),this.crc32=this.signed&&new n,this.encrypt=this.encrypted&&new m(t.outputPassword)}async append(t){let e=t;return this.compressed&&t.length&&(e=await this.deflate.append(t)),this.encrypted?e=await this.encrypt.append(e):this.signed&&this.crc32.append(t),e}async flush(){let t,e=new Uint8Array(0);if(this.compressed&&(e=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){e=await this.encrypt.append(e);const n=await this.encrypt.flush();t=n.signature;const s=new Uint8Array(e.length+n.data.length);s.set(e,0),s.set(n.data,e.length),e=s}else this.signed&&(t=this.crc32.get());return{data:e,signature:t}}}const O={init(t){t.scripts&&t.scripts.length&&importScripts.apply(void 0,t.scripts);const e=t.options;self.initExternalCodec&&self.initExternalCodec(),C=function(t){return t.codecType.startsWith("deflate")?new j(t):t.codecType.startsWith("inflate")?new E(t):void 0}(e)},append:async t=>({data:await C.append(t.data)}),flush:()=>C.flush()};let C;addEventListener("message",(async t=>{const e=t.data,n=e.type,s=O[n];if(s)try{const t=await s(e)||{};if(t.type=n,t.data)try{postMessage(t,[t.data.buffer])}catch(e){postMessage(t)}else postMessage(t)}catch(t){postMessage({type:n,error:{message:t.message,stack:t.stack}})}})),self.initExternalCodec=()=>{const{ZipDeflate:t,ZipInflate:n}=((t,n={})=>({ZipDeflate:e(t.Deflate,n.deflate),ZipInflate:e(t.Inflate,n.inflate)}))(pako,{deflate:{raw:!0},inflate:{raw:!0}});self.ZipDeflate=t,self.ZipInflate=n}}(); +!function(){"use strict";class t{constructor(){this.crc=-1,this.table=(()=>{const t=[];for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)1&n?n=n>>>1^3988292384:n>>>=1;t[e]=n}return t})()}append(t){const e=this.table;let n=0|this.crc;for(let s=0,i=0|t.length;s>>8^e[255&(n^t[s])];this.crc=n}get(){return~this.crc}}const e="Invalid pasword",n=16,s="raw",i={name:"PBKDF2"},a={name:"HMAC"},r="SHA-1",c={name:"AES-CTR"},h=Object.assign({hash:a},i),o=Object.assign({iterations:1e3,hash:{name:r}},i),p=Object.assign({hash:r},a),u=Object.assign({length:n},c),d=["deriveBits"],l=["sign"],y=528,g=10,w=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=crypto.subtle;class b{constructor(t,e){this.password=t,this.signed=e,this.input=e&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(t){const i=async(e=0)=>{if(e+n<=r.length-g){const t=r.subarray(e,e+n),s=await f.decrypt(Object.assign({counter:this.counter},u),this.keys.decrypt,t);return U(this.counter),a.set(new Uint8Array(s),e),i(e+n)}return this.pendingInput=r.subarray(e),this.signed&&(this.input=m(this.input,t)),a};if(this.password){const n=t.subarray(0,18);await async function(t,n,i){t.counter=new Uint8Array(w);const a=n.subarray(0,16),r=n.subarray(16),u=(new TextEncoder).encode(i),y=await f.importKey(s,u,h,!1,d),g=await f.deriveBits(Object.assign({salt:a},o),y,528),b=new Uint8Array(g),A=b.subarray(64);if(t.keys={decrypt:await f.importKey(s,b.subarray(0,32),c,!0,["decrypt"]),authentication:await f.importKey(s,b.subarray(32,64),p,!1,l),passwordVerification:A},A[0]!=r[0]||A[1]!=r[1])throw new Error(e)}(this,n,this.password),this.password=null,t=t.subarray(18)}let a=new Uint8Array(t.length-g-(t.length-g)%n),r=t;return this.pendingInput.length&&(r=m(this.pendingInput,t),a=D(a,r.length-g-(r.length-g)%n)),i()}async flush(){const t=this.pendingInput,e=this.keys,n=t.subarray(0,t.length-g),s=t.subarray(t.length-g);let i=new Uint8Array(0);if(n.length){const t=await f.decrypt(Object.assign({counter:this.counter},u),e.decrypt,n);i=new Uint8Array(t)}let r=!0;if(this.signed){const t=await f.sign(a,e.authentication,this.input.subarray(0,this.input.length-g)),n=new Uint8Array(t);this.input=null;for(let t=0;t{if(s+n<=t.length){const r=t.subarray(s,s+n),c=await f.encrypt(Object.assign({counter:this.counter},u),this.keys.encrypt,r);return U(this.counter),a.set(new Uint8Array(c),s+i.length),e(s+n)}return this.pendingInput=t.subarray(s),this.output=m(this.output,a),a};let i=new Uint8Array(0);this.password&&(i=await async function(t,e){t.counter=new Uint8Array(w);const n=crypto.getRandomValues(new Uint8Array(16)),i=(new TextEncoder).encode(e),a=await f.importKey(s,i,h,!1,d),r=await f.deriveBits(Object.assign({salt:n},o),a,y),u=new Uint8Array(r);return t.keys={encrypt:await f.importKey(s,u.subarray(0,32),c,!0,["encrypt"]),authentication:await f.importKey(s,u.subarray(32,64),p,!1,l),passwordVerification:u.subarray(64)},m(n,t.keys.passwordVerification)}(this,this.password),this.password=null);let a=new Uint8Array(i.length+t.length-t.length%n);return a.set(i,0),this.pendingInput.length&&(t=m(this.pendingInput,t),a=D(a,t.length-t.length%n)),e()}async flush(){let t=new Uint8Array(0);if(this.pendingInput.length){const e=await f.encrypt(Object.assign({counter:this.counter},u),this.keys.encrypt,this.pendingInput);t=new Uint8Array(e),this.output=m(this.output,t)}const e=await f.sign(a,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(e).subarray(0,g);return{data:m(t,n),signature:n}}}function U(t){for(let e=0;e<16;e++){if(255!=t[e]){t[e]++;break}t[e]=0}}function m(t,e){let n=t;return t.length+e.length&&(n=new Uint8Array(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function D(t,e){if(e&&e>t.length){const n=t;(t=new Uint8Array(e)).set(n,0)}return t}const I="deflate",k="inflate",v="Invalid signature";class C{constructor(e){this.signature=e.inputSignature,this.encrypted=Boolean(e.inputPassword),this.signed=e.inputSigned,this.compressed=e.inputCompressed,this.inflate=this.compressed&&new e.codecConstructor,this.crc32=this.signed&&this.signed&&new t,this.decrypt=this.encrypted&&new b(e.inputPassword)}async append(t){return this.encrypted&&(t=await this.decrypt.append(t)),this.compressed&&t.length&&(t=await this.inflate.append(t)),!this.encrypted&&this.signed&&this.crc32.append(t),t}async flush(){let t,e=new Uint8Array(0);if(this.encrypted){const t=await this.decrypt.flush();if(!t.valid)throw new Error(v);e=t.data}else if(this.signed){const e=new DataView(new Uint8Array(4).buffer);if(t=this.crc32.get(),e.setUint32(0,t),this.signature!=e.getUint32(0,!1))throw new Error(v)}return this.compressed&&(e=await this.inflate.append(e)||new Uint8Array(0),await this.inflate.flush()),{data:e,signature:t}}}class j{constructor(e){this.encrypted=e.outputEncrypted,this.signed=e.outputSigned,this.compressed=e.outputCompressed,this.deflate=this.compressed&&new e.codecConstructor({level:e.level||5}),this.crc32=this.signed&&new t,this.encrypt=this.encrypted&&new A(e.outputPassword)}async append(t){let e=t;return this.compressed&&t.length&&(e=await this.deflate.append(t)),this.encrypted?e=await this.encrypt.append(e):this.signed&&this.crc32.append(t),e}async flush(){let t,e=new Uint8Array(0);if(this.compressed&&(e=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){e=await this.encrypt.append(e);const n=await this.encrypt.flush();t=n.signature;const s=new Uint8Array(e.length+n.data.length);s.set(e,0),s.set(n.data,e.length),e=s}else this.signed&&(t=this.crc32.get());return{data:e,signature:t}}}const O={init(t){t.scripts&&t.scripts.length&&importScripts.apply(void 0,t.scripts);const e=t.options;self.initCodec&&self.initCodec(),e.codecType.startsWith(I)?e.codecConstructor=self.Deflate:e.codecType.startsWith(k)&&(e.codecConstructor=self.Inflate),E=function(t){return t.codecType.startsWith(I)?new j(t):t.codecType.startsWith(k)?new C(t):void 0}(e)},append:async t=>({data:await E.append(t.data)}),flush:()=>E.flush()};let E;addEventListener("message",(async t=>{const e=t.data,n=e.type,s=O[n];if(s)try{const t=await s(e)||{};if(t.type=n,t.data)try{postMessage(t,[t.data.buffer])}catch(e){postMessage(t)}else postMessage(t)}catch(t){postMessage({type:n,error:{message:t.message,stack:t.stack}})}}));const K="function";function T(t,e){return class{constructor(n){const s=t=>{if(this.pendingData){const e=this.pendingData;this.pendingData=new Uint8Array(e.length+t.length),this.pendingData.set(e,0),this.pendingData.set(t,e.length)}else this.pendingData=new Uint8Array(t)};if(this.codec=new t(Object.assign({},e,n)),typeof this.codec.onData==K)this.codec.onData=s;else{if(typeof this.codec.on!=K)throw new Error("Cannot register the callback function");this.codec.on("data",s)}}async append(t){return this.codec.push(t),n(this)}async flush(){return this.codec.push(new Uint8Array(0),!0),n(this)}};function n(t){if(t.pendingData){const e=t.pendingData;return t.pendingData=null,e}return new Uint8Array(0)}}self.initCodec=()=>{const{Deflate:t,Inflate:e}=((t,e={})=>({Deflate:T(t.Deflate,e.deflate),Inflate:T(t.Inflate,e.inflate)}))(pako,{deflate:{raw:!0},inflate:{raw:!0}});self.Deflate=t,self.Inflate=e}}(); diff --git a/dist/z-worker.js b/dist/z-worker.js index ad2718b1..372f446a 100644 --- a/dist/z-worker.js +++ b/dist/z-worker.js @@ -1 +1 @@ -!function(){"use strict";class t{constructor(){this.crc=-1,this.table=(()=>{const t=[];for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)1&n?n=n>>>1^3988292384:n>>>=1;t[e]=n}return t})()}append(t){const e=this.table;let n=0|this.crc;for(let s=0,i=0|t.length;s>>8^e[255&(n^t[s])];this.crc=n}get(){return~this.crc}}const e="Invalid pasword",n=16,s="raw",i={name:"PBKDF2"},r={name:"HMAC"},a="SHA-1",c={name:"AES-CTR"},h=Object.assign({hash:r},i),p=Object.assign({iterations:1e3,hash:{name:a}},i),o=Object.assign({hash:a},r),u=Object.assign({length:n},c),d=["deriveBits"],y=["sign"],l=528,g=10,w=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=crypto.subtle;class b{constructor(t,e){this.password=t,this.signed=e,this.input=e&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(t){const i=async(e=0)=>{if(e+n<=a.length-g){const t=a.subarray(e,e+n),s=await f.decrypt(Object.assign({counter:this.counter},u),this.keys.decrypt,t);return U(this.counter),r.set(new Uint8Array(s),e),i(e+n)}return this.pendingInput=a.subarray(e),this.signed&&(this.input=m(this.input,t)),r};if(this.password){const n=t.subarray(0,18);await async function(t,n,i){t.counter=new Uint8Array(w);const r=n.subarray(0,16),a=n.subarray(16),u=(new TextEncoder).encode(i),l=await f.importKey(s,u,h,!1,d),g=await f.deriveBits(Object.assign({salt:r},p),l,528),b=new Uint8Array(g),A=b.subarray(64);if(t.keys={decrypt:await f.importKey(s,b.subarray(0,32),c,!0,["decrypt"]),authentication:await f.importKey(s,b.subarray(32,64),o,!1,y),passwordVerification:A},A[0]!=a[0]||A[1]!=a[1])throw new Error(e)}(this,n,this.password),this.password=null,t=t.subarray(18)}let r=new Uint8Array(t.length-g-(t.length-g)%n),a=t;return this.pendingInput.length&&(a=m(this.pendingInput,t),r=I(r,a.length-g-(a.length-g)%n)),i()}async flush(){const t=this.pendingInput,e=this.keys,n=t.subarray(0,t.length-g),s=t.subarray(t.length-g);let i=new Uint8Array(0);if(n.length){const t=await f.decrypt(Object.assign({counter:this.counter},u),e.decrypt,n);i=new Uint8Array(t)}let a=!0;if(this.signed){const t=await f.sign(r,e.authentication,this.input.subarray(0,this.input.length-g)),n=new Uint8Array(t);this.input=null;for(let t=0;t{if(s+n<=t.length){const a=t.subarray(s,s+n),c=await f.encrypt(Object.assign({counter:this.counter},u),this.keys.encrypt,a);return U(this.counter),r.set(new Uint8Array(c),s+i.length),e(s+n)}return this.pendingInput=t.subarray(s),this.output=m(this.output,r),r};let i=new Uint8Array(0);this.password&&(i=await async function(t,e){t.counter=new Uint8Array(w);const n=crypto.getRandomValues(new Uint8Array(16)),i=(new TextEncoder).encode(e),r=await f.importKey(s,i,h,!1,d),a=await f.deriveBits(Object.assign({salt:n},p),r,l),u=new Uint8Array(a);return t.keys={encrypt:await f.importKey(s,u.subarray(0,32),c,!0,["encrypt"]),authentication:await f.importKey(s,u.subarray(32,64),o,!1,y),passwordVerification:u.subarray(64)},m(n,t.keys.passwordVerification)}(this,this.password),this.password=null);let r=new Uint8Array(i.length+t.length-t.length%n);return r.set(i,0),this.pendingInput.length&&(t=m(this.pendingInput,t),r=I(r,t.length-t.length%n)),e()}async flush(){let t=new Uint8Array(0);if(this.pendingInput.length){const e=await f.encrypt(Object.assign({counter:this.counter},u),this.keys.encrypt,this.pendingInput);t=new Uint8Array(e),this.output=m(this.output,t)}const e=await f.sign(r,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(e).subarray(0,g);return{data:m(t,n),signature:n}}}function U(t){for(let e=0;e<16;e++){if(255!=t[e]){t[e]++;break}t[e]=0}}function m(t,e){let n=t;return t.length+e.length&&(n=new Uint8Array(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function I(t,e){if(e&&e>t.length){const n=t;(t=new Uint8Array(e)).set(n,0)}return t}const v="Invalid signature";class k{constructor(e){this.signature=e.inputSignature,this.encrypted=Boolean(e.inputPassword),this.signed=e.inputSigned,this.compressed=e.inputCompressed,this.inflate=this.compressed&&new ZipInflate,this.crc32=this.signed&&this.signed&&new t,this.decrypt=this.encrypted&&new b(e.inputPassword)}async append(t){return this.encrypted&&(t=await this.decrypt.append(t)),this.compressed&&t.length&&(t=await this.inflate.append(t)),!this.encrypted&&this.signed&&this.crc32.append(t),t}async flush(){let t,e=new Uint8Array(0);if(this.encrypted){const t=await this.decrypt.flush();if(!t.valid)throw new Error(v);e=t.data}else if(this.signed){const e=new DataView(new Uint8Array(4).buffer);if(t=this.crc32.get(),e.setUint32(0,t),this.signature!=e.getUint32(0,!1))throw new Error(v)}return this.compressed&&(e=await this.inflate.append(e)||new Uint8Array(0),await this.inflate.flush()),{data:e,signature:t}}}class j{constructor(e){this.encrypted=e.outputEncrypted,this.signed=e.outputSigned,this.compressed=e.outputCompressed,this.deflate=this.compressed&&new ZipDeflate({level:e.level||5}),this.crc32=this.signed&&new t,this.encrypt=this.encrypted&&new A(e.outputPassword)}async append(t){let e=t;return this.compressed&&t.length&&(e=await this.deflate.append(t)),this.encrypted?e=await this.encrypt.append(e):this.signed&&this.crc32.append(t),e}async flush(){let t,e=new Uint8Array(0);if(this.compressed&&(e=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){e=await this.encrypt.append(e);const n=await this.encrypt.flush();t=n.signature;const s=new Uint8Array(e.length+n.data.length);s.set(e,0),s.set(n.data,e.length),e=s}else this.signed&&(t=this.crc32.get());return{data:e,signature:t}}}const E={init(t){t.scripts&&t.scripts.length&&importScripts.apply(void 0,t.scripts);const e=t.options;self.initExternalCodec&&self.initExternalCodec(),O=function(t){return t.codecType.startsWith("deflate")?new j(t):t.codecType.startsWith("inflate")?new k(t):void 0}(e)},append:async t=>({data:await O.append(t.data)}),flush:()=>O.flush()};let O;addEventListener("message",(async t=>{const e=t.data,n=e.type,s=E[n];if(s)try{const t=await s(e)||{};if(t.type=n,t.data)try{postMessage(t,[t.data.buffer])}catch(e){postMessage(t)}else postMessage(t)}catch(t){postMessage({type:n,error:{message:t.message,stack:t.stack}})}}))}(); +!function(){"use strict";class t{constructor(){this.crc=-1,this.table=(()=>{const t=[];for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)1&n?n=n>>>1^3988292384:n>>>=1;t[e]=n}return t})()}append(t){const e=this.table;let n=0|this.crc;for(let i=0,a=0|t.length;i>>8^e[255&(n^t[i])];this.crc=n}get(){return~this.crc}}const e="Invalid pasword",n=16,i="raw",a={name:"PBKDF2"},r={name:"HMAC"},s="SHA-1",l={name:"AES-CTR"},o=Object.assign({hash:r},a),_=Object.assign({iterations:1e3,hash:{name:s}},a),d=Object.assign({hash:s},r),u=Object.assign({length:n},l),f=["deriveBits"],c=["sign"],h=528,b=10,w=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x=crypto.subtle;class p{constructor(t,e){this.password=t,this.signed=e,this.input=e&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(t){const a=async(e=0)=>{if(e+n<=s.length-b){const t=s.subarray(e,e+n),i=await x.decrypt(Object.assign({counter:this.counter},u),this.keys.decrypt,t);return g(this.counter),r.set(new Uint8Array(i),e),a(e+n)}return this.pendingInput=s.subarray(e),this.signed&&(this.input=m(this.input,t)),r};if(this.password){const n=t.subarray(0,18);await async function(t,n,a){t.counter=new Uint8Array(w);const r=n.subarray(0,16),s=n.subarray(16),u=(new TextEncoder).encode(a),h=await x.importKey(i,u,o,!1,f),b=await x.deriveBits(Object.assign({salt:r},_),h,528),p=new Uint8Array(b),y=p.subarray(64);if(t.keys={decrypt:await x.importKey(i,p.subarray(0,32),l,!0,["decrypt"]),authentication:await x.importKey(i,p.subarray(32,64),d,!1,c),passwordVerification:y},y[0]!=s[0]||y[1]!=s[1])throw new Error(e)}(this,n,this.password),this.password=null,t=t.subarray(18)}let r=new Uint8Array(t.length-b-(t.length-b)%n),s=t;return this.pendingInput.length&&(s=m(this.pendingInput,t),r=v(r,s.length-b-(s.length-b)%n)),a()}async flush(){const t=this.pendingInput,e=this.keys,n=t.subarray(0,t.length-b),i=t.subarray(t.length-b);let a=new Uint8Array(0);if(n.length){const t=await x.decrypt(Object.assign({counter:this.counter},u),e.decrypt,n);a=new Uint8Array(t)}let s=!0;if(this.signed){const t=await x.sign(r,e.authentication,this.input.subarray(0,this.input.length-b)),n=new Uint8Array(t);this.input=null;for(let t=0;t{if(i+n<=t.length){const s=t.subarray(i,i+n),l=await x.encrypt(Object.assign({counter:this.counter},u),this.keys.encrypt,s);return g(this.counter),r.set(new Uint8Array(l),i+a.length),e(i+n)}return this.pendingInput=t.subarray(i),this.output=m(this.output,r),r};let a=new Uint8Array(0);this.password&&(a=await async function(t,e){t.counter=new Uint8Array(w);const n=crypto.getRandomValues(new Uint8Array(16)),a=(new TextEncoder).encode(e),r=await x.importKey(i,a,o,!1,f),s=await x.deriveBits(Object.assign({salt:n},_),r,h),u=new Uint8Array(s);return t.keys={encrypt:await x.importKey(i,u.subarray(0,32),l,!0,["encrypt"]),authentication:await x.importKey(i,u.subarray(32,64),d,!1,c),passwordVerification:u.subarray(64)},m(n,t.keys.passwordVerification)}(this,this.password),this.password=null);let r=new Uint8Array(a.length+t.length-t.length%n);return r.set(a,0),this.pendingInput.length&&(t=m(this.pendingInput,t),r=v(r,t.length-t.length%n)),e()}async flush(){let t=new Uint8Array(0);if(this.pendingInput.length){const e=await x.encrypt(Object.assign({counter:this.counter},u),this.keys.encrypt,this.pendingInput);t=new Uint8Array(e),this.output=m(this.output,t)}const e=await x.sign(r,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(e).subarray(0,b);return{data:m(t,n),signature:n}}}function g(t){for(let e=0;e<16;e++){if(255!=t[e]){t[e]++;break}t[e]=0}}function m(t,e){let n=t;return t.length+e.length&&(n=new Uint8Array(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function v(t,e){if(e&&e>t.length){const n=t;(t=new Uint8Array(e)).set(n,0)}return t}const k="deflate",A="inflate",U="Invalid signature";class I{constructor(e){this.signature=e.inputSignature,this.encrypted=Boolean(e.inputPassword),this.signed=e.inputSigned,this.compressed=e.inputCompressed,this.inflate=this.compressed&&new e.codecConstructor,this.crc32=this.signed&&this.signed&&new t,this.decrypt=this.encrypted&&new p(e.inputPassword)}async append(t){return this.encrypted&&(t=await this.decrypt.append(t)),this.compressed&&t.length&&(t=await this.inflate.append(t)),!this.encrypted&&this.signed&&this.crc32.append(t),t}async flush(){let t,e=new Uint8Array(0);if(this.encrypted){const t=await this.decrypt.flush();if(!t.valid)throw new Error(U);e=t.data}else if(this.signed){const e=new DataView(new Uint8Array(4).buffer);if(t=this.crc32.get(),e.setUint32(0,t),this.signature!=e.getUint32(0,!1))throw new Error(U)}return this.compressed&&(e=await this.inflate.append(e)||new Uint8Array(0),await this.inflate.flush()),{data:e,signature:t}}}class E{constructor(e){this.encrypted=e.outputEncrypted,this.signed=e.outputSigned,this.compressed=e.outputCompressed,this.deflate=this.compressed&&new e.codecConstructor({level:e.level||5}),this.crc32=this.signed&&new t,this.encrypt=this.encrypted&&new y(e.outputPassword)}async append(t){let e=t;return this.compressed&&t.length&&(e=await this.deflate.append(t)),this.encrypted?e=await this.encrypt.append(e):this.signed&&this.crc32.append(t),e}async flush(){let t,e=new Uint8Array(0);if(this.compressed&&(e=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){e=await this.encrypt.append(e);const n=await this.encrypt.flush();t=n.signature;const i=new Uint8Array(e.length+n.data.length);i.set(e,0),i.set(n.data,e.length),e=i}else this.signed&&(t=this.crc32.get());return{data:e,signature:t}}}const S={init(t){t.scripts&&t.scripts.length&&importScripts.apply(void 0,t.scripts);const e=t.options;self.initCodec&&self.initCodec(),e.codecType.startsWith(k)?e.codecConstructor=self.Deflate:e.codecType.startsWith(A)&&(e.codecConstructor=self.Inflate),C=function(t){return t.codecType.startsWith(k)?new E(t):t.codecType.startsWith(A)?new I(t):void 0}(e)},append:async t=>({data:await C.append(t.data)}),flush:()=>C.flush()};let C;addEventListener("message",(async t=>{const e=t.data,n=e.type,i=S[n];if(i)try{const t=await i(e)||{};if(t.type=n,t.data)try{postMessage(t,[t.data.buffer])}catch(e){postMessage(t)}else postMessage(t)}catch(t){postMessage({type:n,error:{message:t.message,stack:t.stack}})}}));const M=256,j=256,D=-2,O=-5,P=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];function K(){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.build_tree=function(n){const i=t.dyn_tree,a=t.stat_desc.static_tree,r=t.stat_desc.elems;let s,l,o,_=-1;for(n.heap_len=0,n.heap_max=573,s=0;s=1;s--)n.pqdownheap(i,s);o=r;do{s=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(i,1),l=n.heap[1],n.heap[--n.heap_max]=s,n.heap[--n.heap_max]=l,i[2*o]=i[2*s]+i[2*l],n.depth[o]=Math.max(n.depth[s],n.depth[l])+1,i[2*s+1]=i[2*l+1]=o,n.heap[1]=o++,n.pqdownheap(i,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],function(e){const n=t.dyn_tree,i=t.stat_desc.static_tree,a=t.stat_desc.extra_bits,r=t.stat_desc.extra_base,s=t.stat_desc.max_length;let l,o,_,d,u,f,c=0;for(d=0;d<=15;d++)e.bl_count[d]=0;for(n[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)o=e.heap[l],d=n[2*n[2*o+1]+1]+1,d>s&&(d=s,c++),n[2*o+1]=d,o>t.max_code||(e.bl_count[d]++,u=0,o>=r&&(u=a[o-r]),f=n[2*o],e.opt_len+=f*(d+u),i&&(e.static_len+=f*(i[2*o+1]+u)));if(0!==c){do{for(d=s-1;0===e.bl_count[d];)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[s]--,c-=2}while(c>0);for(d=s;0!==d;d--)for(o=e.bl_count[d];0!==o;)_=e.heap[--l],_>t.max_code||(n[2*_+1]!=d&&(e.opt_len+=(d-n[2*_+1])*n[2*_],n[2*_+1]=d),o--)}}(n),function(t,n,i){const a=[];let r,s,l,o=0;for(r=1;r<=15;r++)a[r]=o=o+i[r-1]<<1;for(s=0;s<=n;s++)l=t[2*s+1],0!==l&&(t[2*s]=e(a[l]++,l))}(i,t.max_code,n.bl_count)}}function T(t,e,n,i,a){const r=this;r.static_tree=t,r.extra_bits=e,r.extra_base=n,r.elems=i,r.max_length=a}K._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],K.base_length=[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],K.base_dist=[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],K.d_code=function(t){return t<256?P[t]:P[256+(t>>>7)]},K.extra_lbits=[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],K.extra_dbits=[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],K.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],K.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],T.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8],T.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5],T.static_l_desc=new T(T.static_ltree,K.extra_lbits,257,286,15),T.static_d_desc=new T(T.static_dtree,K.extra_dbits,0,30,15),T.static_bl_desc=new T(null,K.extra_blbits,0,19,7);function B(t,e,n,i,a){const r=this;r.good_length=t,r.max_lazy=e,r.nice_length=n,r.max_chain=i,r.func=a}const V=[new B(0,0,0,0,0),new B(4,4,8,4,1),new B(4,5,16,8,1),new B(4,6,32,32,1),new B(4,4,16,16,2),new B(8,16,32,32,2),new B(8,16,128,128,2),new B(8,32,128,256,2),new B(32,128,258,1024,2),new B(32,258,258,4096,2)],q=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],z=113,W=666,H=258,R=262;function F(t,e,n,i){const a=t[2*e],r=t[2*n];return a>>8&255)}function ot(t,e){let n;const i=e;it>16-i?(n=t,nt|=n<>>16-it,it+=i-16):(nt|=t<=8&&(st(255&nt),nt>>>=8,it-=8)}function ft(e,n){let i,a,r;if(t.pending_buf[$+2*Z]=e>>>8&255,t.pending_buf[$+2*Z+1]=255&e,t.pending_buf[X+Z]=255&n,Z++,0===e?B[2*n]++:(tt++,e--,B[2*(K._length_code[n]+M+1)]++,L[2*K.d_code(e)]++),0==(8191&Z)&&E>2){for(i=8*Z,a=m-x,r=0;r<30;r++)i+=L[2*r]*(5+K.extra_dbits[r]);if(i>>>=3,tt8?lt(nt):it>0&&st(255&nt),nt=0,it=0}function bt(e,n,i){ot(0+(i?1:0),3),function(e,n,i){ht(),et=8,i&&(lt(n),lt(~n)),t.pending_buf.set(o.subarray(e,e+n),t.pending),t.pending+=n}(e,n,!0)}function wt(e,n,i){let a,r,s=0;E>0?(J.build_tree(t),N.build_tree(t),s=function(){let e;for(rt(B,J.max_code),rt(L,N.max_code),Q.build_tree(t),e=18;e>=3&&0===G[2*K.bl_order[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(),a=t.opt_len+3+7>>>3,r=t.static_len+3+7>>>3,r<=a&&(a=r)):a=r=n+5,n+4<=a&&-1!=e?bt(e,n,i):r==a?(ot(2+(i?1:0),3),ct(T.static_ltree,T.static_dtree)):(ot(4+(i?1:0),3),function(t,e,n){let i;for(ot(t-257,5),ot(e-1,5),ot(n-4,4),i=0;i=0?x:-1,m-x,t),x=m,e.flush_pending()}function pt(){let t,n,i,a;do{if(a=_-k-m,0===a&&0===m&&0===k)a=r;else if(-1==a)a--;else if(m>=r+r-R){o.set(o.subarray(r,r+r),0),v-=r,m-=r,x-=r,t=c,i=t;do{n=65535&u[--i],u[i]=n>=r?n-r:0}while(0!=--t);t=r,i=t;do{n=65535&d[--i],d[i]=n>=r?n-r:0}while(0!=--t);a+=r}if(0===e.avail_in)return;t=e.read_buf(o,m+k,a),k+=t,k>=3&&(f=255&o[m],f=(f<r-R?m-(r-R):0;let u=P;const f=l,c=m+H;let h=o[a+s-1],b=o[a+s];A>=C&&(i>>=2),u>k&&(u=k);do{if(e=t,o[e+s]==b&&o[e+s-1]==h&&o[e]==o[a]&&o[++e]==o[a+1]){a+=2,e++;do{}while(o[++a]==o[++e]&&o[++a]==o[++e]&&o[++a]==o[++e]&&o[++a]==o[++e]&&o[++a]==o[++e]&&o[++a]==o[++e]&&o[++a]==o[++e]&&o[++a]==o[++e]&&as){if(v=t,s=n,n>=u)break;h=o[a+s-1],b=o[a+s]}}}while((t=65535&d[t&f])>_&&0!=--i);return s<=k?s:k}function gt(e){return e.total_in=e.total_out=0,e.msg=null,t.pending=0,t.pending_out=0,n=z,a=0,J.dyn_tree=B,J.stat_desc=T.static_l_desc,N.dyn_tree=L,N.stat_desc=T.static_d_desc,Q.dyn_tree=G,Q.stat_desc=T.static_bl_desc,nt=0,it=0,et=8,at(),function(){_=2*r,u[c-1]=0;for(let t=0;t9||8!=_||a<9||a>15||n<0||n>9||x<0||x>2?D:(e.dstate=t,s=a,r=1<9||n<0||n>2?D:(V[E].func!=V[e].func&&0!==t.total_in&&(i=t.deflate(1)),E!=e&&(E=e,I=V[E].max_lazy,C=V[E].good_length,P=V[E].nice_length,U=V[E].max_chain),S=n,i)},t.deflateSetDictionary=function(t,e,i){let a,s=i,_=0;if(!e||42!=n)return D;if(s<3)return 0;for(s>r-R&&(s=r-R,_=i-s),o.set(e.subarray(_,_+s),0),m=s,x=s,f=255&o[0],f=(f<4||h<0)return D;if(!_.next_out||!_.next_in&&0!==_.avail_in||n==W&&4!=h)return _.msg=q[4],D;if(0===_.avail_out)return _.msg=q[7],O;var B;if(e=_,P=a,a=h,42==n&&(C=8+(s-8<<4)<<8,M=(E-1&255)>>1,M>3&&(M=3),C|=M<<6,0!==m&&(C|=32),C+=31-C%31,n=z,st((B=C)>>8&255),st(255&B)),0!==t.pending){if(e.flush_pending(),0===e.avail_out)return a=-1,0}else if(0===e.avail_in&&h<=P&&4!=h)return e.msg=q[7],O;if(n==W&&0!==e.avail_in)return _.msg=q[7],O;if(0!==e.avail_in||0!==k||0!=h&&n!=W){switch(K=-1,V[E].func){case 0:K=function(t){let n,a=65535;for(a>i-5&&(a=i-5);;){if(k<=1){if(pt(),0===k&&0==t)return 0;if(0===k)break}if(m+=k,k=0,n=x+a,(0===m||m>=n)&&(k=m-n,m=n,xt(!1),0===e.avail_out))return 0;if(m-x>=r-R&&(xt(!1),0===e.avail_out))return 0}return xt(4==t),0===e.avail_out?4==t?2:0:4==t?3:1}(h);break;case 1:K=function(t){let n,i=0;for(;;){if(k=3&&(f=(f<=3)if(n=ft(m-v,p-3),k-=p,p<=I&&k>=3){p--;do{m++,f=(f<=3&&(f=(f<4096)&&(p=2)),A>=3&&p<=A){i=m+k-3,n=ft(m-1-y,A-3),k-=A-1,A-=2;do{++m<=i&&(f=(f<0&&e.next_in_index!=l&&(a(e.next_in_index),l=e.next_in_index)}while(e.avail_in>0||0===e.avail_out);return s=new Uint8Array(_),d.forEach((function(t){s.set(t,o),o+=t.length})),s}},this.flush=function(){let t,a,r=0,s=0;const l=[];do{if(e.next_out_index=0,e.avail_out=n,t=e.deflate(4),1!=t&&0!=t)throw new Error("deflating: "+e.msg);n-e.avail_out>0&&l.push(new Uint8Array(i.subarray(0,e.next_out_index))),s+=e.next_out_index}while(e.avail_in>0||0===e.avail_out);return e.deflateEnd(),a=new Uint8Array(s),l.forEach((function(t){a.set(t,r),r+=t.length})),a}}G.prototype={deflateInit:function(t,e){const n=this;return n.dstate=new L,e||(e=15),n.dstate.deflateInit(n,t,e)},deflate:function(t){const e=this;return e.dstate?e.dstate.deflate(e,t):D},deflateEnd:function(){const t=this;if(!t.dstate)return D;const e=t.dstate.deflateEnd();return t.dstate=null,e},deflateParams:function(t,e){const n=this;return n.dstate?n.dstate.deflateParams(n,t,e):D},deflateSetDictionary:function(t,e){const n=this;return n.dstate?n.dstate.deflateSetDictionary(n,t,e):D},read_buf:function(t,e,n){const i=this;let a=i.avail_in;return a>n&&(a=n),0===a?0:(i.avail_in-=a,t.set(i.next_in.subarray(i.next_in_index,i.next_in_index+a),e),i.next_in_index+=a,i.total_in+=a,a)},flush_pending:function(){const t=this;let e=t.dstate.pending;e>t.avail_out&&(e=t.avail_out),0!==e&&(t.next_out.set(t.dstate.pending_buf.subarray(t.dstate.pending_out,t.dstate.pending_out+e),t.next_out_index),t.next_out_index+=e,t.dstate.pending_out+=e,t.total_out+=e,t.avail_out-=e,t.dstate.pending-=e,0===t.dstate.pending&&(t.dstate.pending_out=0))}};const N=-2,Q=-3,X=-5,Y=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],Z=[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],$=[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],tt=[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],et=[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],nt=[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],it=[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],at=15;function rt(){let t,e,n,i,a,r;function s(t,e,s,l,o,_,d,u,f,c,h){let b,w,x,p,y,g,m,v,k,A,U,I,E,S,C;A=0,y=s;do{n[t[e+A]]++,A++,y--}while(0!==y);if(n[0]==s)return d[0]=-1,u[0]=0,0;for(v=u[0],g=1;g<=at&&0===n[g];g++);for(m=g,vy&&(v=y),u[0]=v,S=1<I+v;){if(p++,I+=v,C=x-I,C=C>v?v:C,(w=1<<(g=m-I))>b+1&&(w-=b+1,E=m,g1440)return Q;a[p]=U=c[0],c[0]+=C,0!==p?(r[p]=y,i[0]=g,i[1]=v,g=y>>>I-v,i[2]=U-a[p-1]-g,f.set(i,3*(a[p-1]+g))):d[0]=U}for(i[1]=m-I,A>=s?i[0]=192:h[A]>>I;g>>=1)y^=g;for(y^=g,k=(1<257?(c==Q?f.msg="oversubscribed distance tree":c==X?(f.msg="incomplete distance tree",c=Q):-4!=c&&(f.msg="empty distance tree with lengths",c=Q),c):0)}}rt.inflate_trees_fixed=function(t,e,n,i){return t[0]=9,e[0]=5,n[0]=Z,i[0]=$,0};function st(){const t=this;let e,n,i,a,r=0,s=0,l=0,o=0,_=0,d=0,u=0,f=0,c=0,h=0;function b(t,e,n,i,a,r,s,l){let o,_,d,u,f,c,h,b,w,x,p,y,g,m,v,k;h=l.next_in_index,b=l.avail_in,f=s.bitb,c=s.bitk,w=s.write,x=w>=_[k+1],c-=_[k+1],0!=(16&u)){for(u&=15,g=_[k+2]+(f&Y[u]),f>>=u,c-=u;c<15;)b--,f|=(255&l.read_byte(h++))<>=_[k+1],c-=_[k+1],0!=(16&u)){for(u&=15;c>=u,c-=u,x-=g,w>=m)v=w-m,w-v>0&&2>w-v?(s.window[w++]=s.window[v++],s.window[w++]=s.window[v++],g-=2):(s.window.set(s.window.subarray(v,v+2),w),w+=2,v+=2,g-=2);else{v=w-m;do{v+=s.end}while(v<0);if(u=s.end-v,g>u){if(g-=u,w-v>0&&u>w-v)do{s.window[w++]=s.window[v++]}while(0!=--u);else s.window.set(s.window.subarray(v,v+u),w),w+=u,v+=u,u=0;v=0}}if(w-v>0&&g>w-v)do{s.window[w++]=s.window[v++]}while(0!=--g);else s.window.set(s.window.subarray(v,v+g),w),w+=g,v+=g,g=0;break}if(0!=(64&u))return l.msg="invalid distance code",g=l.avail_in-b,g=c>>3>3:g,b+=g,h-=g,c-=g<<3,s.bitb=f,s.bitk=c,l.avail_in=b,l.total_in+=h-l.next_in_index,l.next_in_index=h,s.write=w,Q;o+=_[k+2],o+=f&Y[u],k=3*(d+o),u=_[k]}break}if(0!=(64&u))return 0!=(32&u)?(g=l.avail_in-b,g=c>>3>3:g,b+=g,h-=g,c-=g<<3,s.bitb=f,s.bitk=c,l.avail_in=b,l.total_in+=h-l.next_in_index,l.next_in_index=h,s.write=w,1):(l.msg="invalid literal/length code",g=l.avail_in-b,g=c>>3>3:g,b+=g,h-=g,c-=g<<3,s.bitb=f,s.bitk=c,l.avail_in=b,l.total_in+=h-l.next_in_index,l.next_in_index=h,s.write=w,Q);if(o+=_[k+2],o+=f&Y[u],k=3*(d+o),0===(u=_[k])){f>>=_[k+1],c-=_[k+1],s.window[w++]=_[k+2],x--;break}}else f>>=_[k+1],c-=_[k+1],s.window[w++]=_[k+2],x--}while(x>=258&&b>=10);return g=l.avail_in-b,g=c>>3>3:g,b+=g,h-=g,c-=g<<3,s.bitb=f,s.bitk=c,l.avail_in=b,l.total_in+=h-l.next_in_index,l.next_in_index=h,s.write=w,0}t.init=function(t,r,s,l,o,_){e=0,u=t,f=r,i=s,c=l,a=o,h=_,n=null},t.proc=function(t,w,x){let p,y,g,m,v,k,A,U=0,I=0,E=0;for(E=w.next_in_index,m=w.avail_in,U=t.bitb,I=t.bitk,v=t.write,k=v=258&&m>=10&&(t.bitb=U,t.bitk=I,w.avail_in=m,w.total_in+=E-w.next_in_index,w.next_in_index=E,t.write=v,x=b(u,f,i,c,a,h,t,w),E=w.next_in_index,m=w.avail_in,U=t.bitb,I=t.bitk,v=t.write,k=v>>=n[y+1],I-=n[y+1],g=n[y],0===g){o=n[y+2],e=6;break}if(0!=(16&g)){_=15&g,r=n[y+2],e=2;break}if(0==(64&g)){l=g,s=y/3+n[y+2];break}if(0!=(32&g)){e=7;break}return e=9,w.msg="invalid literal/length code",x=Q,t.bitb=U,t.bitk=I,w.avail_in=m,w.total_in+=E-w.next_in_index,w.next_in_index=E,t.write=v,t.inflate_flush(w,x);case 2:for(p=_;I>=p,I-=p,l=f,n=a,s=h,e=3;case 3:for(p=l;I>=n[y+1],I-=n[y+1],g=n[y],0!=(16&g)){_=15&g,d=n[y+2],e=4;break}if(0==(64&g)){l=g,s=y/3+n[y+2];break}return e=9,w.msg="invalid distance code",x=Q,t.bitb=U,t.bitk=I,w.avail_in=m,w.total_in+=E-w.next_in_index,w.next_in_index=E,t.write=v,t.inflate_flush(w,x);case 4:for(p=_;I>=p,I-=p,e=5;case 5:for(A=v-d;A<0;)A+=t.end;for(;0!==r;){if(0===k&&(v==t.end&&0!==t.read&&(v=0,k=v7&&(I-=8,m++,E--),t.write=v,x=t.inflate_flush(w,x),v=t.write,k=vt.avail_out&&(i=t.avail_out),0!==i&&e==X&&(e=0),t.avail_out-=i,t.total_out+=i,t.next_out.set(n.window.subarray(r,r+i),a),a+=i,r+=i,r==n.end&&(r=0,n.write==n.end&&(n.write=0),i=n.write-r,i>t.avail_out&&(i=t.avail_out),0!==i&&e==X&&(e=0),t.avail_out-=i,t.total_out+=i,t.next_out.set(n.window.subarray(r,r+i),a),a+=i,r+=i),t.next_out_index=a,n.read=r,e},n.proc=function(t,e){let h,b,w,x,p,y,g,m;for(x=t.next_in_index,p=t.avail_in,b=n.bitb,w=n.bitk,y=n.write,g=y>>1){case 0:b>>>=3,w-=3,h=7&w,b>>>=h,w-=h,a=1;break;case 1:v=[],k=[],A=[[]],U=[[]],rt.inflate_trees_fixed(v,k,A,U),d.init(v[0],k[0],A[0],0,U[0],0),b>>>=3,w-=3,a=6;break;case 2:b>>>=3,w-=3,a=3;break;case 3:return b>>>=3,w-=3,a=9,t.msg="invalid block type",e=Q,n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e)}break;case 1:for(;w<32;){if(0===p)return n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);e=0,p--,b|=(255&t.read_byte(x++))<>>16&65535)!=(65535&b))return a=9,t.msg="invalid stored block lengths",e=Q,n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);r=65535&b,b=w=0,a=0!==r?2:0!==u?7:0;break;case 2:if(0===p)return n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);if(0===g&&(y==n.end&&0!==n.read&&(y=0,g=yp&&(h=p),h>g&&(h=g),n.window.set(t.read_buf(x,h),y),x+=h,p-=h,y+=h,g-=h,0!=(r-=h))break;a=0!==u?7:0;break;case 3:for(;w<14;){if(0===p)return n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);e=0,p--,b|=(255&t.read_byte(x++))<29||(h>>5&31)>29)return a=9,t.msg="too many length or distance symbols",e=Q,n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);if(h=258+(31&h)+(h>>5&31),!i||i.length>>=14,w-=14,l=0,a=4;case 4:for(;l<4+(s>>>10);){for(;w<3;){if(0===p)return n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);e=0,p--,b|=(255&t.read_byte(x++))<>>=3,w-=3}for(;l<19;)i[lt[l++]]=0;if(o[0]=7,h=c.inflate_trees_bits(i,o,_,f,t),0!=h)return(e=h)==Q&&(i=null,a=9),n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);l=0,a=5;case 5:for(;h=s,!(l>=258+(31&h)+(h>>5&31));){let r,d;for(h=o[0];w>>=h,w-=h,i[l++]=d;else{for(m=18==d?7:d-14,r=18==d?11:3;w>>=h,w-=h,r+=b&Y[m],b>>>=m,w-=m,m=l,h=s,m+r>258+(31&h)+(h>>5&31)||16==d&&m<1)return i=null,a=9,t.msg="invalid bit length repeat",e=Q,n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);d=16==d?i[m-1]:0;do{i[m++]=d}while(0!=--r);l=m}}if(_[0]=-1,I=[],E=[],S=[],C=[],I[0]=9,E[0]=6,h=s,h=c.inflate_trees_dynamic(257+(31&h),1+(h>>5&31),i,I,E,S,C,f,t),0!=h)return h==Q&&(i=null,a=9),e=h,n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,n.inflate_flush(t,e);d.init(I[0],E[0],f,S[0],f,C[0]),a=6;case 6:if(n.bitb=b,n.bitk=w,t.avail_in=p,t.total_in+=x-t.next_in_index,t.next_in_index=x,n.write=y,1!=(e=d.proc(n,t,e)))return n.inflate_flush(t,e);if(e=0,d.free(t),x=t.next_in_index,p=t.avail_in,b=n.bitb,w=n.bitk,y=n.write,g=y15?(t.inflateEnd(n),N):(t.wbits=i,n.istate.blocks=new ot(n,1<>4)>a.wbits){a.mode=_t,t.msg="invalid window size",a.marker=5;break}a.mode=1;case 1:if(0===t.avail_in)return n;if(n=e,t.avail_in--,t.total_in++,i=255&t.read_byte(t.next_in_index++),((a.method<<8)+i)%31!=0){a.mode=_t,t.msg="incorrect header check",a.marker=5;break}if(0==(32&i)){a.mode=7;break}a.mode=2;case 2:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,a.need=(255&t.read_byte(t.next_in_index++))<<24&4278190080,a.mode=3;case 3:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,a.need+=(255&t.read_byte(t.next_in_index++))<<16&16711680,a.mode=4;case 4:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,a.need+=(255&t.read_byte(t.next_in_index++))<<8&65280,a.mode=5;case 5:return 0===t.avail_in?n:(n=e,t.avail_in--,t.total_in++,a.need+=255&t.read_byte(t.next_in_index++),a.mode=6,2);case 6:return a.mode=_t,t.msg="need dictionary",a.marker=0,N;case 7:if(n=a.blocks.proc(t,n),n==Q){a.mode=_t,a.marker=0;break}if(0==n&&(n=e),1!=n)return n;n=e,a.blocks.reset(t,a.was),a.mode=12;case 12:return 1;case _t:return Q;default:return N}},t.inflateSetDictionary=function(t,e,n){let i=0,a=n;if(!t||!t.istate||6!=t.istate.mode)return N;const r=t.istate;return a>=1<0&&t.next_in_index!=o&&(a(t.next_in_index),o=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return l=new Uint8Array(d),r.forEach((function(t){l.set(t,_),_+=t.length})),l}},this.flush=function(){t.inflateEnd()}}ft.prototype={inflateInit:function(t){const e=this;return e.istate=new ut,t||(t=15),e.istate.inflateInit(e,t)},inflate:function(t){const e=this;return e.istate?e.istate.inflate(e,t):N},inflateEnd:function(){const t=this;if(!t.istate)return N;const e=t.istate.inflateEnd(t);return t.istate=null,e},inflateSync:function(){const t=this;return t.istate?t.istate.inflateSync(t):N},inflateSetDictionary:function(t,e){const n=this;return n.istate?n.istate.inflateSetDictionary(n,t,e):N},read_byte:function(t){return this.next_in.subarray(t,t+1)[0]},read_buf:function(t,e){return this.next_in.subarray(t,t+e)}},self.initCodec=()=>{self.Deflate=J,self.Inflate=ct}}(); diff --git a/dist/zip-fs-full.min.js b/dist/zip-fs-full.min.js index 9f7f0b7c..a2e3bdd9 100644 --- a/dist/zip-fs-full.min.js +++ b/dist/zip-fs-full.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zip={})}(this,(function(e){"use strict";const t="HTTP error ",n="HTTP Range not supported",s="text/plain";class r{constructor(){this.size=0}init(){this.initialized=!0}}class i extends r{}class a extends r{writeUint8Array(e){this.size+=e.length}}class o extends i{constructor(e){super(),this.blobReader=new l(new Blob([e],{type:s}))}init(){super.init(),this.blobReader.init(),this.size=this.blobReader.size}readUint8Array(e,t){return this.blobReader.readUint8Array(e,t)}}class d extends a{constructor(e){super(),this.encoding=e,this.blob=new Blob([],{type:s})}writeUint8Array(e){super.writeUint8Array(e),this.blob=new Blob([this.blob,e.buffer],{type:s})}getData(){const e=new FileReader;return new Promise(((t,n)=>{e.onload=e=>t(e.target.result),e.onerror=n,e.readAsText(this.blob,this.encoding)}))}}class c extends i{constructor(e){super(),this.dataURI=e;let t=e.length;for(;"="==e.charAt(t-1);)t--;this.dataStart=e.indexOf(",")+1,this.size=Math.floor(.75*(t-this.dataStart))}readUint8Array(e,t){const n=new Uint8Array(t),s=4*Math.floor(e/3),r=atob(this.dataURI.substring(s+this.dataStart,4*Math.ceil((e+t)/3)+this.dataStart)),i=e-3*Math.floor(s/4);for(let e=i;e2?this.data+=btoa(n):this.pending=n}getData(){return this.data+btoa(this.pending)}}class l extends i{constructor(e){super(),this.blob=e,this.size=e.size}readUint8Array(e,t){const n=new FileReader;return new Promise(((s,r)=>{n.onload=e=>s(new Uint8Array(e.target.result)),n.onerror=r,n.readAsArrayBuffer(this.blob.slice(e,e+t))}))}}class m extends a{constructor(e){super(),this.offset=0,this.contentType=e,this.blob=new Blob([],{type:e})}writeUint8Array(e){super.writeUint8Array(e),this.blob=new Blob([this.blob,e.buffer],{type:this.contentType}),this.offset=this.blob.size}getData(){return this.blob}}class f extends i{constructor(e){super(),this.url=e}async init(){if(super.init(),function(e){if("undefined"!=typeof document){const t=document.createElement("a");return t.href=e,"http:"==t.protocol||"https:"==t.protocol}return/^https?:\/\//i.test(e)}(this.url))return new Promise(((e,n)=>{const s=new XMLHttpRequest;s.addEventListener("load",(()=>{s.status<400?(this.size=Number(s.getResponseHeader("Content-Length")),this.size?e():x().then((()=>e())).catch(n)):n(t+(s.statusText||s.status)+".")}),!1),s.addEventListener("error",n,!1),s.open("HEAD",this.url),s.send()}));await x()}async readUint8Array(e,t){return this.data||await x(this,this.url),new Uint8Array(this.data.subarray(e,e+t))}}class h extends i{constructor(e){super(),this.url=e}init(){return super.init(),new Promise(((e,s)=>{const r=new XMLHttpRequest;r.addEventListener("load",(()=>{r.status<400?(this.size=Number(r.getResponseHeader("Content-Length")),"bytes"==r.getResponseHeader("Accept-Ranges")?e():s(new Error(n))):s(t+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",s,!1),r.open("HEAD",this.url),r.send()}))}readUint8Array(e,n){return new Promise(((s,r)=>{const i=new XMLHttpRequest;i.open("GET",this.url),i.responseType="arraybuffer",i.setRequestHeader("Range","bytes="+e+"-"+(e+n-1)),i.addEventListener("load",(()=>{i.status<400?s(new Uint8Array(i.response)):r(t+(i.statusText||i.status)+".")}),!1),i.addEventListener("error",r,!1),i.send()}))}}class u extends a{constructor(){super(),this.array=new Uint8Array(0)}writeUint8Array(e){super.writeUint8Array(e);const t=this.array;this.array=new Uint8Array(t.length+e.length),this.array.set(t),this.array.set(e,t.length)}getData(){return this.array}}function x(e,n){return new Promise(((s,r)=>{const i=new XMLHttpRequest;i.addEventListener("load",(()=>{i.status<400?(e.size||(e.size=Number(i.getResponseHeader("Content-Length"))||Number(i.response.byteLength)),e.data=new Uint8Array(i.response),s()):r(t+(i.statusText||i.status)+".")}),!1),i.addEventListener("error",r,!1),i.open("GET",n),i.responseType="arraybuffer",i.send()}))}const g=4294967295,v=65535,w=1347093252,y=1347094280,b=1347092738,k=1347093766,U=1347094022,z=1347094023,E=39169,A=2048;class R{constructor(){this.crc=-1,this.table=(()=>{const e=[];for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)1&n?n=n>>>1^3988292384:n>>>=1;e[t]=n}return e})()}append(e){const t=this.table;let n=0|this.crc;for(let s=0,r=0|e.length;s>>8^t[255&(n^e[s])];this.crc=n}get(){return~this.crc}}const D="Invalid pasword",j=16,F="raw",S={name:"PBKDF2"},I={name:"HMAC"},T="SHA-1",B={name:"AES-CTR"},L=Object.assign({hash:I},S),_=Object.assign({iterations:1e3,hash:{name:T}},S),C=Object.assign({hash:T},I),q=Object.assign({length:j},B),N=["deriveBits"],O=["sign"],M=528,W=10,P=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],V=crypto.subtle;class Z{constructor(e,t){this.password=e,this.signed=t,this.input=t&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(e){const t=async(r=0)=>{if(r+j<=s.length-W){const e=s.subarray(r,r+j),i=await V.decrypt(Object.assign({counter:this.counter},q),this.keys.decrypt,e);return K(this.counter),n.set(new Uint8Array(i),r),t(r+j)}return this.pendingInput=s.subarray(r),this.signed&&(this.input=Y(this.input,e)),n};if(this.password){const t=e.subarray(0,18);await async function(e,t,n){e.counter=new Uint8Array(P);const s=t.subarray(0,16),r=t.subarray(16),i=(new TextEncoder).encode(n),a=await V.importKey(F,i,L,!1,N),o=await V.deriveBits(Object.assign({salt:s},_),a,528),d=new Uint8Array(o),c=d.subarray(64);if(e.keys={decrypt:await V.importKey(F,d.subarray(0,32),B,!0,["decrypt"]),authentication:await V.importKey(F,d.subarray(32,64),C,!1,O),passwordVerification:c},c[0]!=r[0]||c[1]!=r[1])throw new Error(D)}(this,t,this.password),this.password=null,e=e.subarray(18)}let n=new Uint8Array(e.length-W-(e.length-W)%j),s=e;return this.pendingInput.length&&(s=Y(this.pendingInput,e),n=X(n,s.length-W-(s.length-W)%j)),t()}async flush(){const e=this.pendingInput,t=this.keys,n=e.subarray(0,e.length-W),s=e.subarray(e.length-W);let r=new Uint8Array(0);if(n.length){const e=await V.decrypt(Object.assign({counter:this.counter},q),t.decrypt,n);r=new Uint8Array(e)}let i=!0;if(this.signed){const e=await V.sign(I,t.authentication,this.input.subarray(0,this.input.length-W)),n=new Uint8Array(e);this.input=null;for(let e=0;e{if(r+j<=e.length){const i=e.subarray(r,r+j),a=await V.encrypt(Object.assign({counter:this.counter},q),this.keys.encrypt,i);return K(this.counter),s.set(new Uint8Array(a),r+n.length),t(r+j)}return this.pendingInput=e.subarray(r),this.output=Y(this.output,s),s};let n=new Uint8Array(0);this.password&&(n=await async function(e,t){e.counter=new Uint8Array(P);const n=crypto.getRandomValues(new Uint8Array(16)),s=(new TextEncoder).encode(t),r=await V.importKey(F,s,L,!1,N),i=await V.deriveBits(Object.assign({salt:n},_),r,M),a=new Uint8Array(i);return e.keys={encrypt:await V.importKey(F,a.subarray(0,32),B,!0,["encrypt"]),authentication:await V.importKey(F,a.subarray(32,64),C,!1,O),passwordVerification:a.subarray(64)},Y(n,e.keys.passwordVerification)}(this,this.password),this.password=null);let s=new Uint8Array(n.length+e.length-e.length%j);return s.set(n,0),this.pendingInput.length&&(e=Y(this.pendingInput,e),s=X(s,e.length-e.length%j)),t()}async flush(){let e=new Uint8Array(0);if(this.pendingInput.length){const t=await V.encrypt(Object.assign({counter:this.counter},q),this.keys.encrypt,this.pendingInput);e=new Uint8Array(t),this.output=Y(this.output,e)}const t=await V.sign(I,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(t).subarray(0,W);return{data:Y(e,n),signature:n}}}function K(e){for(let t=0;t<16;t++){if(255!=e[t]){e[t]++;break}e[t]=0}}function Y(e,t){let n=e;return e.length+t.length&&(n=new Uint8Array(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function X(e,t){if(t&&t>e.length){const n=e;(e=new Uint8Array(t)).set(n,0)}return e}const G="deflate",J="inflate",Q="Invalid signature";class ${constructor(e){this.signature=e.inputSignature,this.encrypted=Boolean(e.inputPassword),this.signed=e.inputSigned,this.compressed=e.inputCompressed,this.inflate=this.compressed&&new ZipInflate,this.crc32=this.signed&&this.signed&&new R,this.decrypt=this.encrypted&&new Z(e.inputPassword)}async append(e){return this.encrypted&&(e=await this.decrypt.append(e)),this.compressed&&e.length&&(e=await this.inflate.append(e)),!this.encrypted&&this.signed&&this.crc32.append(e),e}async flush(){let e,t=new Uint8Array(0);if(this.encrypted){const e=await this.decrypt.flush();if(!e.valid)throw new Error(Q);t=e.data}else if(this.signed){const t=new DataView(new Uint8Array(4).buffer);if(e=this.crc32.get(),t.setUint32(0,e),this.signature!=t.getUint32(0,!1))throw new Error(Q)}return this.compressed&&(t=await this.inflate.append(t)||new Uint8Array(0),await this.inflate.flush()),{data:t,signature:e}}}class ee{constructor(e){this.encrypted=e.outputEncrypted,this.signed=e.outputSigned,this.compressed=e.outputCompressed,this.deflate=this.compressed&&new ZipDeflate({level:e.level||5}),this.crc32=this.signed&&new R,this.encrypt=this.encrypted&&new H(e.outputPassword)}async append(e){let t=e;return this.compressed&&e.length&&(t=await this.deflate.append(e)),this.encrypted?t=await this.encrypt.append(t):this.signed&&this.crc32.append(e),t}async flush(){let e,t=new Uint8Array(0);if(this.compressed&&(t=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){t=await this.encrypt.append(t);const n=await this.encrypt.flush();e=n.signature;const s=new Uint8Array(t.length+n.data.length);s.set(t,0),s.set(n.data,t.length),t=s}else this.signed&&(e=this.crc32.get());return{data:t,signature:e}}}const te="init",ne="append",se="flush",re="message",ie="z-worker.js",ae={deflate:[ie,"deflate.js"],inflate:[ie,"inflate.js"]},oe={pool:[],pendingRequests:[]};function de(e,t){const n=oe.pool,s=!(t.inputCompressed||t.inputSigned||t.inputEncrypted||t.outputCompressed||t.outputSigned||t.outputEncrypted);let r;if(t.useWebWorkers||void 0===t.useWebWorkers&&e.useWebWorkers&&!s){const n=t.codecType;e.workerScripts?(i=e.workerScripts[n],r="undefined"!=typeof document?i.map((e=>new URL(e,document.baseURI).href)):i):(r=ae[n].slice(0),r[0]=(e.workerScriptsPath||"")+r[0])}var i;if(n.length!e.busy));return e?ce(e,t,r):new Promise((e=>oe.pendingRequests.push({resolve:e,options:t,scripts:r})))}}function ce(e,t,n){return e.busy=!0,e.options=t,e.scripts=n,n?function(e){let t;e.interface||(e.worker=new Worker(e.scripts[0]),e.worker.addEventListener(re,r,!1),e.interface={append:e=>n({type:ne,data:e}),flush:()=>n({type:se})});return e.interface;async function n(n){if(!t){const t=e.scripts.slice(1);await s(Object.assign({type:te,options:e.options,scripts:t}))}return s(n)}function s(n){const s=e.worker,r=new Promise(((e,n)=>t={resolve:e,reject:n}));try{if(n.data)try{s.postMessage(n,[n.data.buffer])}catch(e){s.postMessage(n)}else s.postMessage(n)}catch(n){t.reject(n),t=null,pe(e)}return r}function r(n){const s=n.data;if(t){const n=s.error;if(n){const s=new Error(n.message);s.stack=n.stack,t.reject(s),t=null,pe(e)}else s.type!=te&&s.type!=se&&s.type!=ne||(s.type==se?(t.resolve({data:new Uint8Array(s.data),signature:s.signature}),t=null,pe(e)):t.resolve(s.data&&new Uint8Array(s.data)))}}}(e):function(e){const t=function(e){return e.codecType.startsWith(G)?new ee(e):e.codecType.startsWith(J)?new $(e):void 0}(e.options);return{async append(n){try{return await t.append(n)}catch(t){throw pe(e),t}},async flush(){try{return await t.flush()}finally{pe(e)}}}}(e)}function pe(e){if(e.busy=!1,oe.pendingRequests.length){const[{resolve:t,options:n,scripts:s}]=oe.pendingRequests.splice(0,1);t(ce(e,n,s))}else e.worker&&e.worker.terminate(),oe.pool=oe.pool.filter((t=>t!=e))}async function le(e,t,n,s,r,i,a){const o=Math.max(i.chunkSize,64);return async function i(d=0,c=0){const p=d*o;if(p","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","⌂","Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","¢","£","¥","₧","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","⌐","¬","½","¼","¡","«","»","░","▒","▓","│","┤","╡","╢","╖","╕","╣","║","╗","╝","╜","╛","┐","└","┴","┬","├","─","┼","╞","╟","╚","╔","╩","╦","╠","═","╬","╧","╨","╤","╥","╙","╘","╒","╓","╫","╪","┘","┌","█","▄","▌","▐","▀","α","ß","Γ","π","Σ","σ","µ","τ","Φ","Θ","Ω","δ","∞","φ","ε","∩","≡","±","≥","≤","⌠","⌡","÷","≈","°","∙","·","√","ⁿ","²","■"," "];class Ae{constructor(e,t,n){this.reader=e,this.config=t,this.options=n}async getData(e,t={}){const n=this.reader;n.initialized||await n.init();const s=await n.readUint8Array(this.offset,30),r=new DataView(s.buffer),i=void 0===t.password?this.options.password:t.password;let a=i&&i.length&&i;if(this.extraFieldAES){if(99!=this.extraFieldAES.originalCompressionMethod)throw new Error(ke);if(3!=this.extraFieldAES.strength)throw new Error(be)}if(0!=this.compressionMethod&&8!=this.compressionMethod)throw new Error(ke);if(r.getUint32(0,!1)!=w)throw new Error(ve);const o=this.localDirectory={};Re(o,r,4),o.rawExtraField=s.subarray(this.offset+30+o.filenameLength,this.offset+30+o.filenameLength+o.extraFieldLength),De(this,o,r,4);let d=this.offset+30+o.filenameLength+o.extraFieldLength;const c=this.bitFlag.encrypted&&o.bitFlag.encrypted;if(c&&!a)throw new Error(ye);const p=await de(this.config,{codecType:J,inputPassword:a,inputSigned:void 0===t.checkSignature?this.options.checkSignature:t.checkSignature,inputSignature:this.signature,inputCompressed:0!=this.compressionMethod,inputEncrypted:c,useWebWorkers:void 0===t.useWebWorkers?this.options.useWebWorkers:t.useWebWorkers});return e.initialized||await e.init(),await le(p,n,e,d,this.compressedSize,this.config,{onprogress:t.onprogress}),e.getData()}}function Re(e,t,n){e.version=t.getUint16(n,!0);const s=e.rawBitFlag=t.getUint16(n+2,!0);e.bitFlag={encrypted:1==(1&s),level:(6&s)>>1,dataDescriptor:8==(8&s),languageEncodingFlag:(s&A)==A},e.encrypted=e.bitFlag.encrypted,e.rawLastModDate=t.getUint32(n+6,!0),e.lastModDate=function(e){const t=(4294901760&e)>>16,n=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(e){}}(e.rawLastModDate),e.filenameLength=t.getUint16(n+22,!0),e.extraFieldLength=t.getUint16(n+24,!0)}function De(e,t,n,s){const r=t.rawExtraField,i=t.extraField=new Map,a=new DataView(new Uint8Array(r).buffer);let o=0;try{for(;ot[e]==g));for(let t=0;t{if(t[n]==g){if(!e||void 0===e[n])throw new Error(we);t[n]=e[n]}}))}(c,t);const p=t.extraFieldUnicodePath=i.get(28789);p&&je(p,"filename","rawFilename",t,e);let l=t.extraFieldUnicodeComment=i.get(25461);l&&je(l,"comment","rawComment",t,e);const m=t.extraFieldAES=i.get(39169);m?function(e,t,n){if(e){const s=new DataView(e.data.buffer);e.vendorVersion=s.getUint8(0),e.vendorId=s.getUint8(2);const r=s.getUint8(4);e.strength=r,e.originalCompressionMethod=n,t.compressionMethod=e.compressionMethod=s.getUint16(5,!0)}else t.compressionMethod=n}(m,t,d):t.compressionMethod=d,8==t.compressionMethod&&(t.bitFlag.enhancedDeflating=16!=(16&t.rawBitFlag))}function je(e,t,n,s,r){const i=new DataView(e.data.buffer);e.version=i.getUint8(0),e.signature=i.getUint32(1,!0);const a=new R;a.append(r[n]);const o=new DataView(new Uint8Array(4).buffer);o.setUint32(0,a.get()),e[t]=(new TextDecoder).decode(e.data.subarray(5)),r.bitFlag.languageEncodingFlag||e.signature!=o.getUint32(0,!1)||(s[t]=e[t])}function Fe(e,t){if(t&&"cp437"!=t.trim().toLowerCase())return new TextDecoder(t).decode(e);{let t="";for(let n=0;n{if(this.pendingData){const t=this.pendingData;this.pendingData=new Uint8Array(t.length+e.length),this.pendingData.set(t,0),this.pendingData.set(e,t.length)}else this.pendingData=new Uint8Array(e)};if(this.codec=new e(Object.assign({},t,n)),typeof this.codec.onData==Oe)this.codec.onData=s;else{if(typeof this.codec.on!=Oe)throw new Error("Cannot register the callback function");this.codec.on("data",s)}}async append(e){return this.codec.push(e),n(this)}async flush(){return this.codec.push(new Uint8Array(0),!0),n(this)}};function n(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new Uint8Array(0)}}const We={chunkSize:524288,maxWorkers:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||2,workerScriptsPath:void 0,useWebWorkers:!0};let Pe=Object.assign({},We);class Ve extends class{constructor(e,t={},n={}){this.reader=e,this.options=t,this.config=n}async getEntries(e={}){const t=this.reader;t.initialized||await t.init();const n=await async function(e,t,n,s){const r=new Uint8Array(4);if(new DataView(r.buffer).setUint32(0,t),e.size=0;e--)if(i[e]==r[0]&&i[e+1]==r[1]&&i[e+2]==r[2]&&i[e+3]==r[3])return{offset:s,buffer:i.slice(e,e+n).buffer}}}(t,k,22,v);if(!n)throw new Error(he);const s=new DataView(n.buffer);let r,i=s.getUint32(16,!0),a=s.getUint16(8,!0);if(i==g||a==v){r=!0;const e=await t.readUint8Array(n.offset-20,20),s=new DataView(e.buffer);if(Number(s.getUint32(0,!1))!=z)throw new Error(ue);i=Number(s.getBigUint64(8,!0));const o=await t.readUint8Array(i,56),d=new DataView(o.buffer);if(Number(d.getUint32(0,!1))!=U)throw new Error(xe);a=Number(d.getBigUint64(24,!0)),i-=Number(d.getBigUint64(40,!0))}if(i<0||!r&&(i>=t.size||a>=v))throw new Error(fe);const o=await t.readUint8Array(i,t.size-i),d=new DataView(o.buffer),c=[];let p=0;for(let t=0;tv)throw new Error(Be);const r=(new TextEncoder).encode(n.comment||"");if(r.length>v)throw new Error(Te);const i=this.options.version||n.version||0;if(i>v)throw new Error(Le);const a=n.lastModDate||new Date;if(a.getFullYear()<1980)throw new Error(_e);t&&!t.initialized&&await t.init();let o=new Uint8Array(0);const d=n.extraField;if(d){let e=4,t=0;d.forEach((t=>e+=t.length)),o=new Uint8Array(e),d.forEach(((e,n)=>{if(n>v)throw new Error(Ce);if(e.length>v)throw new Error(qe);o.set(new Uint16Array([n]),t),o.set(new Uint16Array([e.length]),t+2),o.set(e,t+4),t+=4+e.length}))}let c=n.zip64||this.zip64;(this.offset>=g||t&&(t.size>=g||this.offset+t.size>=g))&&(c=!0),await async function(e,t,n,s){const r=e.files,i=e.writer;let a;r.set(t,null);try{let o,d;try{s.bufferedWrite||e.options.bufferedWrite||e.lockWrite?(o=new u,o.init()):(e.lockWrite=new Promise((e=>a=e)),i.initialized||await i.init(),o=i),d=await async function(e,t,n,s,r,i){const a=i.rawFilename,o=i.lastModDate,d=new Uint8Array(26),c=new DataView(d.buffer),p=void 0===i.password?r.password:i.password,l=p&&p.length&&p,m=void 0===i.level?r.level:i.level,f=0!==m&&!i.directory,h=void 0===p||!p.length,u=i.zip64;let x;if(l){x=new Uint8Array(Ne.length+2);new DataView(x.buffer).setUint16(0,E,!0),x.set(Ne,2)}else x=new Uint8Array(0);const v={version:i.version||20,zip64:u,headerArray:d,directory:i.directory,filename:e,rawFilename:a,comment:i.comment,rawComment:i.rawComment,extraFieldZip64:u?new Uint8Array(28):new Uint8Array(0),extraFieldAES:x,rawExtraField:i.rawExtraField};let b=2056,k=0;f&&(k=8);u&&(v.version=v.version>45?v.version:45);l&&(v.encrypted=!0,v.version=v.version>51?v.version:51,b|=1,k=99,f&&(v.extraFieldAES[9]=8));c.setUint16(0,v.version,!0),c.setUint16(2,b,!0),c.setUint16(4,k,!0),c.setUint16(6,(o.getHours()<<6|o.getMinutes())<<5|o.getSeconds()/2,!0),c.setUint16(8,(o.getFullYear()-1980<<4|o.getMonth()+1)<<5|o.getDate(),!0),c.setUint16(22,a.length,!0),c.setUint16(24,0,!0);const U=new Uint8Array(30+a.length);let z;if(new DataView(U.buffer).setUint32(0,w),U.set(d,4),U.set(a,30),t){const e=await de(s,{codecType:G,level:m,outputPassword:p,outputSigned:h,outputCompressed:f,outputEncrypted:Boolean(p),useWebWorkers:void 0===i.useWebWorkers?r.useWebWorkers:i.useWebWorkers});await n.writeUint8Array(U),z=await le(e,t,n,0,t.size,s,{onprogress:i.onprogress}),v.compressedSize=z.length}else await n.writeUint8Array(U);const A=new Uint8Array(u?24:16),R=new DataView(A.buffer);if(R.setUint32(0,y),t)if(l||void 0===z.signature||(c.setUint32(10,z.signature,!0),R.setUint32(4,z.signature,!0)),u){c.setUint32(14,g,!0),R.setBigUint64(8,BigInt(v.compressedSize),!0),c.setUint32(18,g,!0),R.setBigUint64(16,BigInt(t.size),!0);const e=new DataView(v.extraFieldZip64.buffer);e.setUint16(0,1,!0),e.setUint16(2,24,!0),e.setBigUint64(4,BigInt(t.size),!0),e.setBigUint64(12,BigInt(v.compressedSize),!0)}else c.setUint32(14,v.compressedSize,!0),R.setUint32(8,v.compressedSize,!0),c.setUint32(18,t.size,!0),R.setUint32(12,t.size,!0);return await n.writeUint8Array(A),v.length=U.length+(z?z.length:0)+A.length,v}(t,n,o,e.config,e.options,s)}catch(e){throw r.delete(t),e}if(r.set(t,d),o!=i&&(e.lockWrite&&await e.lockWrite,await i.writeUint8Array(o.getData())),d.offset=e.offset,d.zip64){new DataView(d.extraFieldZip64.buffer).setBigUint64(20,BigInt(d.offset),!0)}e.offset+=d.length}finally{a&&(e.lockWrite=null,a())}}(this,e,t,Object.assign({},n,{rawFilename:s,rawComment:r,version:i,lastModDate:a,rawExtraField:o,zip64:c}))}async close(e=new Uint8Array(0)){const t=this.writer,n=this.files;let s=0,r=0,i=this.offset,a=n.size;if(e.length){if(!(e.length<=v))throw new Error(Ie);d.setUint16(s+20,e.length,!0)}for(const[,e]of n)r+=46+e.rawFilename.length+e.rawComment.length+e.extraFieldZip64.length+e.extraFieldAES.length+e.rawExtraField.length;(i+r>=g||a>=v)&&(this.zip64=!0);const o=new Uint8Array(r+(this.zip64?98:22)),d=new DataView(o.buffer);for(const[,e]of n){const t=e.rawFilename,n=e.extraFieldZip64,r=e.extraFieldAES,i=n.length+r.length+e.rawExtraField.length;d.setUint32(s,b),d.setUint16(s+4,e.version,!0),o.set(e.headerArray,s+6),d.setUint16(s+30,i,!0),d.setUint16(s+32,e.rawComment.length,!0),e.directory&&d.setUint8(s+38,16),e.zip64?d.setUint32(s+42,g,!0):d.setUint32(s+42,e.offset,!0),o.set(t,s+46),o.set(n,s+46+t.length),o.set(r,s+46+t.length+n.length),o.set(e.rawExtraField,46+t.length+n.length+r.length),o.set(e.rawComment,s+46+t.length+i),s+=46+t.length+i+e.rawComment.length}return this.zip64&&(d.setUint32(s,U),d.setBigUint64(s+4,BigInt(44),!0),d.setUint16(s+12,45,!0),d.setUint16(s+14,45,!0),d.setBigUint64(s+24,BigInt(a),!0),d.setBigUint64(s+32,BigInt(a),!0),d.setBigUint64(s+40,BigInt(r),!0),d.setBigUint64(s+48,BigInt(i),!0),d.setUint32(s+56,z),d.setBigUint64(s+64,BigInt(i+r),!0),d.setUint32(s+72,1,!0),a=v,i=g,s+=76),d.setUint32(s,k),d.setUint16(s+8,a,!0),d.setUint16(s+10,a,!0),d.setUint32(s+12,r,!0),d.setUint32(s+16,i,!0),await t.writeUint8Array(o),await t.writeUint8Array(e),t.getData()}}{constructor(e,t){super(e,t,Pe)}}const He=524288;class Ke{constructor(e,t,n,s){if(e.root&&s&&s.getChildByName(t))throw new Error("Entry filename already exists");n||(n={}),this.fs=e,this.name=t,this.data=n.data,this.id=e.entries.length,this.parent=s,this.children=[],this.uncompressedSize=0,e.entries.push(this),s&&this.parent.children.push(this)}moveTo(e){if(!e.directory)throw new Error("Target entry is not a directory");if(e.isDescendantOf(this))throw new Error("Entry is a ancestor of target entry");if(this!=e){if(e.getChildByName(this.name))throw new Error("Entry filename already exists");et(this),this.parent=e,e.children.push(this)}}getFullname(){let e=this.name,t=this.parent;for(;t;)e=(t.name?t.name+"/":"")+e,t=t.parent;return e}isDescendantOf(e){let t=this.parent;for(;t&&t.id!=e.id;)t=t.parent;return Boolean(t)}}class Ye extends Ke{constructor(e,t,n,s){super(e,t,n,s),this.Reader=n.Reader,this.Writer=n.Writer,n.getData&&(this.getData=n.getData)}async getData(e,t={}){return!e||e.constructor==this.Writer&&this.data?this.data:(this.reader||(this.reader=new this.Reader(this.data)),await this.reader.init(),await e.init(),this.uncompressedSize=this.reader.size,async function(e,t,n){return s();async function s(r=0){const i=r*He;if(n.onprogress&&n.onprogress(i,e.size),i{t.file((s=>{e.addBlob(t.name,s),n()}),s)}));function n(e){return new Promise(((t,n)=>{let s=[];function r(e){e.readEntries((n=>{n.length?(s=s.concat(n),r(e)):t(s)}),n)}e.isDirectory&&r(e.createReader()),e.isFile&&t(s)}))}async function s(e,t){const r=await n(t);for(const t of r)t.isDirectory&&await s(e.addDirectory(t.name)),await new Promise(((n,s)=>{t.isFile&&t.file((s=>{const r=e.addBlob(t.name,s);r.uncompressedSize=s.size,n(r)}),s)}))}}(this,e)}async addData(e,t){return nt(this,e,t)}async importBlob(e,t={}){await this.importZip(new l(e),t)}async importData64URI(e,t={}){await this.importZip(new c(e),t)}async importHttpContent(e,t={}){await this.importZip(t.useRangeHeader?new h(e):new f(e),t)}async exportBlob(e={}){return this.exportZip(new m("application/zip"),e)}async exportData64URI(e={}){return this.exportZip(new p("application/zip"),e)}async importZip(e,t){await e.init();const n=new Ve(e,t),s=await n.getEntries();let r=0;const i=Je(s,"compressedSize");s.forEach((e=>{let n=this,s=e.filename.split("/"),a=s.pop();if(s.forEach((e=>n=n.getChildByName(e)||new Xe(this.fs,e,null,n))),!e.directory){let s=r;nt(n,a,{data:e,Reader:Qe(Object.assign({},{onprogress:e=>{t.onprogress&&t.onprogress(s+e,i)}}))}),r+=e.compressedSize}}))}async exportZip(e,t){await $e(this);const n=new Ze(e,t);return await async function(e,t,n,s){let r=0;async function i(e,t){async function a(){let a=0;for(const o of t.children){let t=r;await e.add(o.getFullname(),o.reader,Object.assign({directory:o.directory},{onprogress:e=>{s.onprogress&&s.onprogress(t+a+e,n)}})),r+=o.uncompressedSize,await i(e,o),a++}}await a()}await i(e,t)}(n,this,Je([this],"uncompressedSize"),t),await n.close(),e.getData()}getChildByName(e){for(let t=0;t{n.id==e.id&&t.splice(s,1)}))}function tt(e){e.entries=[],e.root=new Xe(e)}function nt(e,t,n,s){if(e.directory)return s?new Xe(e.fs,t,n,e):new Ye(e.fs,t,n,e);throw new Error("Parent entry is not a directory")}const st={application:{"andrew-inset":"ez",annodex:"anx","atom+xml":"atom","atomcat+xml":"atomcat","atomserv+xml":"atomsrv",bbolin:"lin",cap:["cap","pcap"],"cu-seeme":"cu","davmount+xml":"davmount",dsptype:"tsp",ecmascript:["es","ecma"],futuresplash:"spl",hta:"hta","java-archive":"jar","java-serialized-object":"ser","java-vm":"class",javascript:"js",m3g:"m3g","mac-binhex40":"hqx",mathematica:["nb","ma","mb"],msaccess:"mdb",msword:["doc","dot"],mxf:"mxf",oda:"oda",ogg:"ogx",pdf:"pdf","pgp-keys":"key","pgp-signature":["asc","sig"],"pics-rules":"prf",postscript:["ps","ai","eps","epsi","epsf","eps2","eps3"],rar:"rar","rdf+xml":"rdf","rss+xml":"rss",rtf:"rtf",smil:["smi","smil"],"xhtml+xml":["xhtml","xht"],xml:["xml","xsl","xsd"],"xspf+xml":"xspf",zip:"zip","vnd.android.package-archive":"apk","vnd.cinderella":"cdy","vnd.google-earth.kml+xml":"kml","vnd.google-earth.kmz":"kmz","vnd.mozilla.xul+xml":"xul","vnd.ms-excel":["xls","xlb","xlt","xlm","xla","xlc","xlw"],"vnd.ms-pki.seccat":"cat","vnd.ms-pki.stl":"stl","vnd.ms-powerpoint":["ppt","pps","pot"],"vnd.oasis.opendocument.chart":"odc","vnd.oasis.opendocument.database":"odb","vnd.oasis.opendocument.formula":"odf","vnd.oasis.opendocument.graphics":"odg","vnd.oasis.opendocument.graphics-template":"otg","vnd.oasis.opendocument.image":"odi","vnd.oasis.opendocument.presentation":"odp","vnd.oasis.opendocument.presentation-template":"otp","vnd.oasis.opendocument.spreadsheet":"ods","vnd.oasis.opendocument.spreadsheet-template":"ots","vnd.oasis.opendocument.text":"odt","vnd.oasis.opendocument.text-master":"odm","vnd.oasis.opendocument.text-template":"ott","vnd.oasis.opendocument.text-web":"oth","vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","vnd.openxmlformats-officedocument.spreadsheetml.template":"xltx","vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","vnd.openxmlformats-officedocument.presentationml.slideshow":"ppsx","vnd.openxmlformats-officedocument.presentationml.template":"potx","vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","vnd.openxmlformats-officedocument.wordprocessingml.template":"dotx","vnd.smaf":"mmf","vnd.stardivision.calc":"sdc","vnd.stardivision.chart":"sds","vnd.stardivision.draw":"sda","vnd.stardivision.impress":"sdd","vnd.stardivision.math":["sdf","smf"],"vnd.stardivision.writer":["sdw","vor"],"vnd.stardivision.writer-global":"sgl","vnd.sun.xml.calc":"sxc","vnd.sun.xml.calc.template":"stc","vnd.sun.xml.draw":"sxd","vnd.sun.xml.draw.template":"std","vnd.sun.xml.impress":"sxi","vnd.sun.xml.impress.template":"sti","vnd.sun.xml.math":"sxm","vnd.sun.xml.writer":"sxw","vnd.sun.xml.writer.global":"sxg","vnd.sun.xml.writer.template":"stw","vnd.symbian.install":["sis","sisx"],"vnd.visio":["vsd","vst","vss","vsw"],"vnd.wap.wbxml":"wbxml","vnd.wap.wmlc":"wmlc","vnd.wap.wmlscriptc":"wmlsc","vnd.wordperfect":"wpd","vnd.wordperfect5.1":"wp5","x-123":"wk","x-7z-compressed":"7z","x-abiword":"abw","x-apple-diskimage":"dmg","x-bcpio":"bcpio","x-bittorrent":"torrent","x-cbr":["cbr","cba","cbt","cb7"],"x-cbz":"cbz","x-cdf":["cdf","cda"],"x-cdlink":"vcd","x-chess-pgn":"pgn","x-cpio":"cpio","x-csh":"csh","x-debian-package":["deb","udeb"],"x-director":["dcr","dir","dxr","cst","cct","cxt","w3d","fgd","swa"],"x-dms":"dms","x-doom":"wad","x-dvi":"dvi","x-httpd-eruby":"rhtml","x-font":"pcf.Z","x-freemind":"mm","x-gnumeric":"gnumeric","x-go-sgf":"sgf","x-graphing-calculator":"gcf","x-gtar":["gtar","taz"],"x-hdf":"hdf","x-httpd-php":["phtml","pht","php"],"x-httpd-php-source":"phps","x-httpd-php3":"php3","x-httpd-php3-preprocessed":"php3p","x-httpd-php4":"php4","x-httpd-php5":"php5","x-ica":"ica","x-info":"info","x-internet-signup":["ins","isp"],"x-iphone":"iii","x-iso9660-image":"iso","x-java-jnlp-file":"jnlp","x-jmol":"jmz","x-killustrator":"kil","x-koan":["skp","skd","skt","skm"],"x-kpresenter":["kpr","kpt"],"x-kword":["kwd","kwt"],"x-latex":"latex","x-lha":"lha","x-lyx":"lyx","x-lzh":"lzh","x-lzx":"lzx","x-maker":["frm","maker","frame","fm","fb","book","fbdoc"],"x-ms-wmd":"wmd","x-ms-wmz":"wmz","x-msdos-program":["com","exe","bat","dll"],"x-msi":"msi","x-netcdf":["nc","cdf"],"x-ns-proxy-autoconfig":["pac","dat"],"x-nwc":"nwc","x-object":"o","x-oz-application":"oza","x-pkcs7-certreqresp":"p7r","x-python-code":["pyc","pyo"],"x-qgis":["qgs","shp","shx"],"x-quicktimeplayer":"qtl","x-redhat-package-manager":"rpm","x-ruby":"rb","x-sh":"sh","x-shar":"shar","x-shockwave-flash":["swf","swfl"],"x-silverlight":"scr","x-stuffit":"sit","x-sv4cpio":"sv4cpio","x-sv4crc":"sv4crc","x-tar":"tar","x-tcl":"tcl","x-tex-gf":"gf","x-tex-pk":"pk","x-texinfo":["texinfo","texi"],"x-trash":["~","%","bak","old","sik"],"x-troff":["t","tr","roff"],"x-troff-man":"man","x-troff-me":"me","x-troff-ms":"ms","x-ustar":"ustar","x-wais-source":"src","x-wingz":"wz","x-x509-ca-cert":["crt","der","cer"],"x-xcf":"xcf","x-xfig":"fig","x-xpinstall":"xpi",applixware:"aw","atomsvc+xml":"atomsvc","ccxml+xml":"ccxml","cdmi-capability":"cdmia","cdmi-container":"cdmic","cdmi-domain":"cdmid","cdmi-object":"cdmio","cdmi-queue":"cdmiq","docbook+xml":"dbk","dssc+der":"dssc","dssc+xml":"xdssc","emma+xml":"emma","epub+zip":"epub",exi:"exi","font-tdpfr":"pfr","gml+xml":"gml","gpx+xml":"gpx",gxf:"gxf",hyperstudio:"stk","inkml+xml":["ink","inkml"],ipfix:"ipfix",json:"json","jsonml+json":"jsonml","lost+xml":"lostxml","mads+xml":"mads",marc:"mrc","marcxml+xml":"mrcx","mathml+xml":"mathml",mbox:"mbox","mediaservercontrol+xml":"mscml","metalink+xml":"metalink","metalink4+xml":"meta4","mets+xml":"mets","mods+xml":"mods",mp21:["m21","mp21"],mp4:"mp4s","oebps-package+xml":"opf","omdoc+xml":"omdoc",onenote:["onetoc","onetoc2","onetmp","onepkg"],oxps:"oxps","patch-ops-error+xml":"xer","pgp-encrypted":"pgp",pkcs10:"p10","pkcs7-mime":["p7m","p7c"],"pkcs7-signature":"p7s",pkcs8:"p8","pkix-attr-cert":"ac","pkix-crl":"crl","pkix-pkipath":"pkipath",pkixcmp:"pki","pls+xml":"pls","prs.cww":"cww","pskc+xml":"pskcxml","reginfo+xml":"rif","relax-ng-compact-syntax":"rnc","resource-lists+xml":"rl","resource-lists-diff+xml":"rld","rls-services+xml":"rs","rpki-ghostbusters":"gbr","rpki-manifest":"mft","rpki-roa":"roa","rsd+xml":"rsd","sbml+xml":"sbml","scvp-cv-request":"scq","scvp-cv-response":"scs","scvp-vp-request":"spq","scvp-vp-response":"spp",sdp:"sdp","set-payment-initiation":"setpay","set-registration-initiation":"setreg","shf+xml":"shf","sparql-query":"rq","sparql-results+xml":"srx",srgs:"gram","srgs+xml":"grxml","sru+xml":"sru","ssdl+xml":"ssdl","ssml+xml":"ssml","tei+xml":["tei","teicorpus"],"thraud+xml":"tfi","timestamped-data":"tsd","vnd.3gpp.pic-bw-large":"plb","vnd.3gpp.pic-bw-small":"psb","vnd.3gpp.pic-bw-var":"pvb","vnd.3gpp2.tcap":"tcap","vnd.3m.post-it-notes":"pwn","vnd.accpac.simply.aso":"aso","vnd.accpac.simply.imp":"imp","vnd.acucobol":"acu","vnd.acucorp":["atc","acutc"],"vnd.adobe.air-application-installer-package+zip":"air","vnd.adobe.formscentral.fcdt":"fcdt","vnd.adobe.fxp":["fxp","fxpl"],"vnd.adobe.xdp+xml":"xdp","vnd.adobe.xfdf":"xfdf","vnd.ahead.space":"ahead","vnd.airzip.filesecure.azf":"azf","vnd.airzip.filesecure.azs":"azs","vnd.amazon.ebook":"azw","vnd.americandynamics.acc":"acc","vnd.amiga.ami":"ami","vnd.anser-web-certificate-issue-initiation":"cii","vnd.anser-web-funds-transfer-initiation":"fti","vnd.antix.game-component":"atx","vnd.apple.installer+xml":"mpkg","vnd.apple.mpegurl":"m3u8","vnd.aristanetworks.swi":"swi","vnd.astraea-software.iota":"iota","vnd.audiograph":"aep","vnd.blueice.multipass":"mpm","vnd.bmi":"bmi","vnd.businessobjects":"rep","vnd.chemdraw+xml":"cdxml","vnd.chipnuts.karaoke-mmd":"mmd","vnd.claymore":"cla","vnd.cloanto.rp9":"rp9","vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"vnd.cluetrust.cartomobile-config":"c11amc","vnd.cluetrust.cartomobile-config-pkg":"c11amz","vnd.commonspace":"csp","vnd.contact.cmsg":"cdbcmsg","vnd.cosmocaller":"cmc","vnd.crick.clicker":"clkx","vnd.crick.clicker.keyboard":"clkk","vnd.crick.clicker.palette":"clkp","vnd.crick.clicker.template":"clkt","vnd.crick.clicker.wordbank":"clkw","vnd.criticaltools.wbs+xml":"wbs","vnd.ctc-posml":"pml","vnd.cups-ppd":"ppd","vnd.curl.car":"car","vnd.curl.pcurl":"pcurl","vnd.dart":"dart","vnd.data-vision.rdz":"rdz","vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"vnd.dece.ttml+xml":["uvt","uvvt"],"vnd.dece.unspecified":["uvx","uvvx"],"vnd.dece.zip":["uvz","uvvz"],"vnd.denovo.fcselayout-link":"fe_launch","vnd.dna":"dna","vnd.dolby.mlp":"mlp","vnd.dpgraph":"dpg","vnd.dreamfactory":"dfac","vnd.ds-keypoint":"kpxx","vnd.dvb.ait":"ait","vnd.dvb.service":"svc","vnd.dynageo":"geo","vnd.ecowin.chart":"mag","vnd.enliven":"nml","vnd.epson.esf":"esf","vnd.epson.msf":"msf","vnd.epson.quickanime":"qam","vnd.epson.salt":"slt","vnd.epson.ssf":"ssf","vnd.eszigno3+xml":["es3","et3"],"vnd.ezpix-album":"ez2","vnd.ezpix-package":"ez3","vnd.fdf":"fdf","vnd.fdsn.mseed":"mseed","vnd.fdsn.seed":["seed","dataless"],"vnd.flographit":"gph","vnd.fluxtime.clip":"ftc","vnd.framemaker":["fm","frame","maker","book"],"vnd.frogans.fnc":"fnc","vnd.frogans.ltf":"ltf","vnd.fsc.weblaunch":"fsc","vnd.fujitsu.oasys":"oas","vnd.fujitsu.oasys2":"oa2","vnd.fujitsu.oasys3":"oa3","vnd.fujitsu.oasysgp":"fg5","vnd.fujitsu.oasysprs":"bh2","vnd.fujixerox.ddd":"ddd","vnd.fujixerox.docuworks":"xdw","vnd.fujixerox.docuworks.binder":"xbd","vnd.fuzzysheet":"fzs","vnd.genomatix.tuxedo":"txd","vnd.geogebra.file":"ggb","vnd.geogebra.tool":"ggt","vnd.geometry-explorer":["gex","gre"],"vnd.geonext":"gxt","vnd.geoplan":"g2w","vnd.geospace":"g3w","vnd.gmx":"gmx","vnd.grafeq":["gqf","gqs"],"vnd.groove-account":"gac","vnd.groove-help":"ghf","vnd.groove-identity-message":"gim","vnd.groove-injector":"grv","vnd.groove-tool-message":"gtm","vnd.groove-tool-template":"tpl","vnd.groove-vcard":"vcg","vnd.hal+xml":"hal","vnd.handheld-entertainment+xml":"zmm","vnd.hbci":"hbci","vnd.hhe.lesson-player":"les","vnd.hp-hpgl":"hpgl","vnd.hp-hpid":"hpid","vnd.hp-hps":"hps","vnd.hp-jlyt":"jlt","vnd.hp-pcl":"pcl","vnd.hp-pclxl":"pclxl","vnd.hydrostatix.sof-data":"sfd-hdstx","vnd.ibm.minipay":"mpy","vnd.ibm.modcap":["afp","listafp","list3820"],"vnd.ibm.rights-management":"irm","vnd.ibm.secure-container":"sc","vnd.iccprofile":["icc","icm"],"vnd.igloader":"igl","vnd.immervision-ivp":"ivp","vnd.immervision-ivu":"ivu","vnd.insors.igm":"igm","vnd.intercon.formnet":["xpw","xpx"],"vnd.intergeo":"i2g","vnd.intu.qbo":"qbo","vnd.intu.qfx":"qfx","vnd.ipunplugged.rcprofile":"rcprofile","vnd.irepository.package+xml":"irp","vnd.is-xpr":"xpr","vnd.isac.fcs":"fcs","vnd.jam":"jam","vnd.jcp.javame.midlet-rms":"rms","vnd.jisp":"jisp","vnd.joost.joda-archive":"joda","vnd.kahootz":["ktz","ktr"],"vnd.kde.karbon":"karbon","vnd.kde.kchart":"chrt","vnd.kde.kformula":"kfo","vnd.kde.kivio":"flw","vnd.kde.kontour":"kon","vnd.kde.kpresenter":["kpr","kpt"],"vnd.kde.kspread":"ksp","vnd.kde.kword":["kwd","kwt"],"vnd.kenameaapp":"htke","vnd.kidspiration":"kia","vnd.kinar":["kne","knp"],"vnd.koan":["skp","skd","skt","skm"],"vnd.kodak-descriptor":"sse","vnd.las.las+xml":"lasxml","vnd.llamagraphics.life-balance.desktop":"lbd","vnd.llamagraphics.life-balance.exchange+xml":"lbe","vnd.lotus-1-2-3":"123","vnd.lotus-approach":"apr","vnd.lotus-freelance":"pre","vnd.lotus-notes":"nsf","vnd.lotus-organizer":"org","vnd.lotus-screencam":"scm","vnd.lotus-wordpro":"lwp","vnd.macports.portpkg":"portpkg","vnd.mcd":"mcd","vnd.medcalcdata":"mc1","vnd.mediastation.cdkey":"cdkey","vnd.mfer":"mwf","vnd.mfmp":"mfm","vnd.micrografx.flo":"flo","vnd.micrografx.igx":"igx","vnd.mif":"mif","vnd.mobius.daf":"daf","vnd.mobius.dis":"dis","vnd.mobius.mbk":"mbk","vnd.mobius.mqy":"mqy","vnd.mobius.msl":"msl","vnd.mobius.plc":"plc","vnd.mobius.txf":"txf","vnd.mophun.application":"mpn","vnd.mophun.certificate":"mpc","vnd.ms-artgalry":"cil","vnd.ms-cab-compressed":"cab","vnd.ms-excel.addin.macroenabled.12":"xlam","vnd.ms-excel.sheet.binary.macroenabled.12":"xlsb","vnd.ms-excel.sheet.macroenabled.12":"xlsm","vnd.ms-excel.template.macroenabled.12":"xltm","vnd.ms-fontobject":"eot","vnd.ms-htmlhelp":"chm","vnd.ms-ims":"ims","vnd.ms-lrm":"lrm","vnd.ms-officetheme":"thmx","vnd.ms-powerpoint.addin.macroenabled.12":"ppam","vnd.ms-powerpoint.presentation.macroenabled.12":"pptm","vnd.ms-powerpoint.slide.macroenabled.12":"sldm","vnd.ms-powerpoint.slideshow.macroenabled.12":"ppsm","vnd.ms-powerpoint.template.macroenabled.12":"potm","vnd.ms-project":["mpp","mpt"],"vnd.ms-word.document.macroenabled.12":"docm","vnd.ms-word.template.macroenabled.12":"dotm","vnd.ms-works":["wps","wks","wcm","wdb"],"vnd.ms-wpl":"wpl","vnd.ms-xpsdocument":"xps","vnd.mseq":"mseq","vnd.musician":"mus","vnd.muvee.style":"msty","vnd.mynfc":"taglet","vnd.neurolanguage.nlu":"nlu","vnd.nitf":["ntf","nitf"],"vnd.noblenet-directory":"nnd","vnd.noblenet-sealer":"nns","vnd.noblenet-web":"nnw","vnd.nokia.n-gage.data":"ngdat","vnd.nokia.n-gage.symbian.install":"n-gage","vnd.nokia.radio-preset":"rpst","vnd.nokia.radio-presets":"rpss","vnd.novadigm.edm":"edm","vnd.novadigm.edx":"edx","vnd.novadigm.ext":"ext","vnd.oasis.opendocument.chart-template":"otc","vnd.oasis.opendocument.formula-template":"odft","vnd.oasis.opendocument.image-template":"oti","vnd.olpc-sugar":"xo","vnd.oma.dd2+xml":"dd2","vnd.openofficeorg.extension":"oxt","vnd.openxmlformats-officedocument.presentationml.slide":"sldx","vnd.osgeo.mapguide.package":"mgp","vnd.osgi.dp":"dp","vnd.osgi.subsystem":"esa","vnd.palm":["pdb","pqa","oprc"],"vnd.pawaafile":"paw","vnd.pg.format":"str","vnd.pg.osasli":"ei6","vnd.picsel":"efif","vnd.pmi.widget":"wg","vnd.pocketlearn":"plf","vnd.powerbuilder6":"pbd","vnd.previewsystems.box":"box","vnd.proteus.magazine":"mgz","vnd.publishare-delta-tree":"qps","vnd.pvi.ptid1":"ptid","vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"vnd.realvnc.bed":"bed","vnd.recordare.musicxml":"mxl","vnd.recordare.musicxml+xml":"musicxml","vnd.rig.cryptonote":"cryptonote","vnd.rn-realmedia":"rm","vnd.rn-realmedia-vbr":"rmvb","vnd.route66.link66+xml":"link66","vnd.sailingtracker.track":"st","vnd.seemail":"see","vnd.sema":"sema","vnd.semd":"semd","vnd.semf":"semf","vnd.shana.informed.formdata":"ifm","vnd.shana.informed.formtemplate":"itp","vnd.shana.informed.interchange":"iif","vnd.shana.informed.package":"ipk","vnd.simtech-mindmapper":["twd","twds"],"vnd.smart.teacher":"teacher","vnd.solent.sdkm+xml":["sdkm","sdkd"],"vnd.spotfire.dxp":"dxp","vnd.spotfire.sfs":"sfs","vnd.stepmania.package":"smzip","vnd.stepmania.stepchart":"sm","vnd.sus-calendar":["sus","susp"],"vnd.svd":"svd","vnd.syncml+xml":"xsm","vnd.syncml.dm+wbxml":"bdm","vnd.syncml.dm+xml":"xdm","vnd.tao.intent-module-archive":"tao","vnd.tcpdump.pcap":["pcap","cap","dmp"],"vnd.tmobile-livetv":"tmo","vnd.trid.tpt":"tpt","vnd.triscape.mxs":"mxs","vnd.trueapp":"tra","vnd.ufdl":["ufd","ufdl"],"vnd.uiq.theme":"utz","vnd.umajin":"umj","vnd.unity":"unityweb","vnd.uoml+xml":"uoml","vnd.vcx":"vcx","vnd.visionary":"vis","vnd.vsf":"vsf","vnd.webturbo":"wtb","vnd.wolfram.player":"nbp","vnd.wqd":"wqd","vnd.wt.stf":"stf","vnd.xara":"xar","vnd.xfdl":"xfdl","vnd.yamaha.hv-dic":"hvd","vnd.yamaha.hv-script":"hvs","vnd.yamaha.hv-voice":"hvp","vnd.yamaha.openscoreformat":"osf","vnd.yamaha.openscoreformat.osfpvg+xml":"osfpvg","vnd.yamaha.smaf-audio":"saf","vnd.yamaha.smaf-phrase":"spf","vnd.yellowriver-custom-menu":"cmp","vnd.zul":["zir","zirz"],"vnd.zzazz.deck+xml":"zaz","voicexml+xml":"vxml",widget:"wgt",winhlp:"hlp","wsdl+xml":"wsdl","wspolicy+xml":"wspolicy","x-ace-compressed":"ace","x-authorware-bin":["aab","x32","u32","vox"],"x-authorware-map":"aam","x-authorware-seg":"aas","x-blorb":["blb","blorb"],"x-bzip":"bz","x-bzip2":["bz2","boz"],"x-cfs-compressed":"cfs","x-chat":"chat","x-conference":"nsc","x-dgc-compressed":"dgc","x-dtbncx+xml":"ncx","x-dtbook+xml":"dtb","x-dtbresource+xml":"res","x-eva":"eva","x-font-bdf":"bdf","x-font-ghostscript":"gsf","x-font-linux-psf":"psf","x-font-otf":"otf","x-font-pcf":"pcf","x-font-snf":"snf","x-font-ttf":["ttf","ttc"],"x-font-type1":["pfa","pfb","pfm","afm"],"x-font-woff":"woff","x-freearc":"arc","x-gca-compressed":"gca","x-glulx":"ulx","x-gramps-xml":"gramps","x-install-instructions":"install","x-lzh-compressed":["lzh","lha"],"x-mie":"mie","x-mobipocket-ebook":["prc","mobi"],"x-ms-application":"application","x-ms-shortcut":"lnk","x-ms-xbap":"xbap","x-msbinder":"obd","x-mscardfile":"crd","x-msclip":"clp","x-msdownload":["exe","dll","com","bat","msi"],"x-msmediaview":["mvb","m13","m14"],"x-msmetafile":["wmf","wmz","emf","emz"],"x-msmoney":"mny","x-mspublisher":"pub","x-msschedule":"scd","x-msterminal":"trm","x-mswrite":"wri","x-nzb":"nzb","x-pkcs12":["p12","pfx"],"x-pkcs7-certificates":["p7b","spc"],"x-research-info-systems":"ris","x-silverlight-app":"xap","x-sql":"sql","x-stuffitx":"sitx","x-subrip":"srt","x-t3vm-image":"t3","x-tads":"gam","x-tex":"tex","x-tex-tfm":"tfm","x-tgif":"obj","x-xliff+xml":"xlf","x-xz":"xz","x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"xaml+xml":"xaml","xcap-diff+xml":"xdf","xenc+xml":"xenc","xml-dtd":"dtd","xop+xml":"xop","xproc+xml":"xpl","xslt+xml":"xslt","xv+xml":["mxml","xhvml","xvml","xvm"],yang:"yang","yin+xml":"yin",envoy:"evy",fractals:"fif","internet-property-stream":"acx",olescript:"axs","vnd.ms-outlook":"msg","vnd.ms-pkicertstore":"sst","x-compress":"z","x-compressed":"tgz","x-gzip":"gz","x-perfmon":["pma","pmc","pml","pmr","pmw"],"x-pkcs7-mime":["p7c","p7m"],"ynd.ms-pkipko":"pko"},audio:{amr:"amr","amr-wb":"awb",annodex:"axa",basic:["au","snd"],flac:"flac",midi:["mid","midi","kar","rmi"],mpeg:["mpga","mpega","mp2","mp3","m4a","mp2a","m2a","m3a"],mpegurl:"m3u",ogg:["oga","ogg","spx"],"prs.sid":"sid","x-aiff":["aif","aiff","aifc"],"x-gsm":"gsm","x-ms-wma":"wma","x-ms-wax":"wax","x-pn-realaudio":"ram","x-realaudio":"ra","x-sd2":"sd2","x-wav":"wav",adpcm:"adp",mp4:"mp4a",s3m:"s3m",silk:"sil","vnd.dece.audio":["uva","uvva"],"vnd.digital-winds":"eol","vnd.dra":"dra","vnd.dts":"dts","vnd.dts.hd":"dtshd","vnd.lucent.voice":"lvp","vnd.ms-playready.media.pya":"pya","vnd.nuera.ecelp4800":"ecelp4800","vnd.nuera.ecelp7470":"ecelp7470","vnd.nuera.ecelp9600":"ecelp9600","vnd.rip":"rip",webm:"weba","x-aac":"aac","x-caf":"caf","x-matroska":"mka","x-pn-realaudio-plugin":"rmp",xm:"xm",mid:["mid","rmi"]},chemical:{"x-alchemy":"alc","x-cache":["cac","cache"],"x-cache-csf":"csf","x-cactvs-binary":["cbin","cascii","ctab"],"x-cdx":"cdx","x-chem3d":"c3d","x-cif":"cif","x-cmdf":"cmdf","x-cml":"cml","x-compass":"cpa","x-crossfire":"bsd","x-csml":["csml","csm"],"x-ctx":"ctx","x-cxf":["cxf","cef"],"x-embl-dl-nucleotide":["emb","embl"],"x-gamess-input":["inp","gam","gamin"],"x-gaussian-checkpoint":["fch","fchk"],"x-gaussian-cube":"cub","x-gaussian-input":["gau","gjc","gjf"],"x-gaussian-log":"gal","x-gcg8-sequence":"gcg","x-genbank":"gen","x-hin":"hin","x-isostar":["istr","ist"],"x-jcamp-dx":["jdx","dx"],"x-kinemage":"kin","x-macmolecule":"mcm","x-macromodel-input":["mmd","mmod"],"x-mdl-molfile":"mol","x-mdl-rdfile":"rd","x-mdl-rxnfile":"rxn","x-mdl-sdfile":["sd","sdf"],"x-mdl-tgf":"tgf","x-mmcif":"mcif","x-mol2":"mol2","x-molconn-Z":"b","x-mopac-graph":"gpt","x-mopac-input":["mop","mopcrt","mpc","zmt"],"x-mopac-out":"moo","x-ncbi-asn1":"asn","x-ncbi-asn1-ascii":["prt","ent"],"x-ncbi-asn1-binary":["val","aso"],"x-pdb":["pdb","ent"],"x-rosdal":"ros","x-swissprot":"sw","x-vamas-iso14976":"vms","x-vmd":"vmd","x-xtel":"xtel","x-xyz":"xyz"},image:{gif:"gif",ief:"ief",jpeg:["jpeg","jpg","jpe"],pcx:"pcx",png:"png","svg+xml":["svg","svgz"],tiff:["tiff","tif"],"vnd.djvu":["djvu","djv"],"vnd.wap.wbmp":"wbmp","x-canon-cr2":"cr2","x-canon-crw":"crw","x-cmu-raster":"ras","x-coreldraw":"cdr","x-coreldrawpattern":"pat","x-coreldrawtemplate":"cdt","x-corelphotopaint":"cpt","x-epson-erf":"erf","x-icon":"ico","x-jg":"art","x-jng":"jng","x-nikon-nef":"nef","x-olympus-orf":"orf","x-photoshop":"psd","x-portable-anymap":"pnm","x-portable-bitmap":"pbm","x-portable-graymap":"pgm","x-portable-pixmap":"ppm","x-rgb":"rgb","x-xbitmap":"xbm","x-xpixmap":"xpm","x-xwindowdump":"xwd",bmp:"bmp",cgm:"cgm",g3fax:"g3",ktx:"ktx","prs.btif":"btif",sgi:"sgi","vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"vnd.dwg":"dwg","vnd.dxf":"dxf","vnd.fastbidsheet":"fbs","vnd.fpx":"fpx","vnd.fst":"fst","vnd.fujixerox.edmics-mmr":"mmr","vnd.fujixerox.edmics-rlc":"rlc","vnd.ms-modi":"mdi","vnd.ms-photo":"wdp","vnd.net-fpx":"npx","vnd.xiff":"xif",webp:"webp","x-3ds":"3ds","x-cmx":"cmx","x-freehand":["fh","fhc","fh4","fh5","fh7"],"x-pict":["pic","pct"],"x-tga":"tga","cis-cod":"cod",pipeg:"jfif"},message:{rfc822:["eml","mime","mht","mhtml","nws"]},model:{iges:["igs","iges"],mesh:["msh","mesh","silo"],vrml:["wrl","vrml"],"x3d+vrml":["x3dv","x3dvz"],"x3d+xml":["x3d","x3dz"],"x3d+binary":["x3db","x3dbz"],"vnd.collada+xml":"dae","vnd.dwf":"dwf","vnd.gdl":"gdl","vnd.gtw":"gtw","vnd.mts":"mts","vnd.vtu":"vtu"},text:{"cache-manifest":["manifest","appcache"],calendar:["ics","icz","ifb"],css:"css",csv:"csv",h323:"323",html:["html","htm","shtml","stm"],iuls:"uls",mathml:"mml",plain:["txt","text","brf","conf","def","list","log","in","bas"],richtext:"rtx",scriptlet:["sct","wsc"],texmacs:["tm","ts"],"tab-separated-values":"tsv","vnd.sun.j2me.app-descriptor":"jad","vnd.wap.wml":"wml","vnd.wap.wmlscript":"wmls","x-bibtex":"bib","x-boo":"boo","x-c++hdr":["h++","hpp","hxx","hh"],"x-c++src":["c++","cpp","cxx","cc"],"x-component":"htc","x-dsrc":"d","x-diff":["diff","patch"],"x-haskell":"hs","x-java":"java","x-literate-haskell":"lhs","x-moc":"moc","x-pascal":["p","pas"],"x-pcs-gcd":"gcd","x-perl":["pl","pm"],"x-python":"py","x-scala":"scala","x-setext":"etx","x-tcl":["tcl","tk"],"x-tex":["tex","ltx","sty","cls"],"x-vcalendar":"vcs","x-vcard":"vcf",n3:"n3","prs.lines.tag":"dsc",sgml:["sgml","sgm"],troff:["t","tr","roff","man","me","ms"],turtle:"ttl","uri-list":["uri","uris","urls"],vcard:"vcard","vnd.curl":"curl","vnd.curl.dcurl":"dcurl","vnd.curl.scurl":"scurl","vnd.curl.mcurl":"mcurl","vnd.dvb.subtitle":"sub","vnd.fly":"fly","vnd.fmi.flexstor":"flx","vnd.graphviz":"gv","vnd.in3d.3dml":"3dml","vnd.in3d.spot":"spot","x-asm":["s","asm"],"x-c":["c","cc","cxx","cpp","h","hh","dic"],"x-fortran":["f","for","f77","f90"],"x-opml":"opml","x-nfo":"nfo","x-sfv":"sfv","x-uuencode":"uu",webviewhtml:"htt"},video:{avif:".avif","3gpp":"3gp",annodex:"axv",dl:"dl",dv:["dif","dv"],fli:"fli",gl:"gl",mpeg:["mpeg","mpg","mpe","m1v","m2v","mp2","mpa","mpv2"],mp4:["mp4","mp4v","mpg4"],quicktime:["qt","mov"],ogg:"ogv","vnd.mpegurl":["mxu","m4u"],"x-flv":"flv","x-la-asf":["lsf","lsx"],"x-mng":"mng","x-ms-asf":["asf","asx","asr"],"x-ms-wm":"wm","x-ms-wmv":"wmv","x-ms-wmx":"wmx","x-ms-wvx":"wvx","x-msvideo":"avi","x-sgi-movie":"movie","x-matroska":["mpv","mkv","mk3d","mks"],"3gpp2":"3g2",h261:"h261",h263:"h263",h264:"h264",jpeg:"jpgv",jpm:["jpm","jpgm"],mj2:["mj2","mjp2"],"vnd.dece.hd":["uvh","uvvh"],"vnd.dece.mobile":["uvm","uvvm"],"vnd.dece.pd":["uvp","uvvp"],"vnd.dece.sd":["uvs","uvvs"],"vnd.dece.video":["uvv","uvvv"],"vnd.dvb.file":"dvb","vnd.fvt":"fvt","vnd.ms-playready.media.pyv":"pyv","vnd.uvvu.mp4":["uvu","uvvu"],"vnd.vivo":"viv",webm:"webm","x-f4v":"f4v","x-m4v":"m4v","x-ms-vob":"vob","x-smv":"smv"},"x-conference":{"x-cooltalk":"ice"},"x-world":{"x-vrml":["vrm","vrml","wrl","flr","wrz","xaf","xof"]}},rt=(()=>{const e={};for(let t in st)if(st.hasOwnProperty(t))for(let n in st[t])if(st[t].hasOwnProperty(n)){const s=st[t][n];if("string"==typeof s)e[s]=t+"/"+n;else for(let r=0;r({ZipDeflate:Me(e.Deflate,t.deflate),ZipInflate:Me(e.Inflate,t.inflate)}),Object.defineProperty(e,"__esModule",{value:!0})})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).zip={})}(this,(function(e){"use strict";const t=256,n=256,i=-2,r=-5,a=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];function s(){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.build_tree=function(n){const i=e.dyn_tree,r=e.stat_desc.static_tree,a=e.stat_desc.elems;let s,o,d,l=-1;for(n.heap_len=0,n.heap_max=573,s=0;s=1;s--)n.pqdownheap(i,s);d=a;do{s=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(i,1),o=n.heap[1],n.heap[--n.heap_max]=s,n.heap[--n.heap_max]=o,i[2*d]=i[2*s]+i[2*o],n.depth[d]=Math.max(n.depth[s],n.depth[o])+1,i[2*s+1]=i[2*o+1]=d,n.heap[1]=d++,n.pqdownheap(i,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],function(t){const n=e.dyn_tree,i=e.stat_desc.static_tree,r=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,s=e.stat_desc.max_length;let o,d,l,c,p,f,m=0;for(c=0;c<=15;c++)t.bl_count[c]=0;for(n[2*t.heap[t.heap_max]+1]=0,o=t.heap_max+1;o<573;o++)d=t.heap[o],c=n[2*n[2*d+1]+1]+1,c>s&&(c=s,m++),n[2*d+1]=c,d>e.max_code||(t.bl_count[c]++,p=0,d>=a&&(p=r[d-a]),f=n[2*d],t.opt_len+=f*(c+p),i&&(t.static_len+=f*(i[2*d+1]+p)));if(0!==m){do{for(c=s-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[s]--,m-=2}while(m>0);for(c=s;0!==c;c--)for(d=t.bl_count[c];0!==d;)l=t.heap[--o],l>e.max_code||(n[2*l+1]!=c&&(t.opt_len+=(c-n[2*l+1])*n[2*l],n[2*l+1]=c),d--)}}(n),function(e,n,i){const r=[];let a,s,o,d=0;for(a=1;a<=15;a++)r[a]=d=d+i[a-1]<<1;for(s=0;s<=n;s++)o=e[2*s+1],0!==o&&(e[2*s]=t(r[o]++,o))}(i,e.max_code,n.bl_count)}}function o(e,t,n,i,r){const a=this;a.static_tree=e,a.extra_bits=t,a.extra_base=n,a.elems=i,a.max_length=r}s._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],s.base_length=[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],s.base_dist=[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],s.d_code=function(e){return e<256?a[e]:a[256+(e>>>7)]},s.extra_lbits=[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],s.extra_dbits=[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],s.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],s.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],o.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8],o.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5],o.static_l_desc=new o(o.static_ltree,s.extra_lbits,257,286,15),o.static_d_desc=new o(o.static_dtree,s.extra_dbits,0,30,15),o.static_bl_desc=new o(null,s.extra_blbits,0,19,7);function d(e,t,n,i,r){const a=this;a.good_length=e,a.max_lazy=t,a.nice_length=n,a.max_chain=i,a.func=r}const l=[new d(0,0,0,0,0),new d(4,4,8,4,1),new d(4,5,16,8,1),new d(4,6,32,32,1),new d(4,4,16,16,2),new d(8,16,32,32,2),new d(8,16,128,128,2),new d(8,32,128,256,2),new d(32,128,258,1024,2),new d(32,258,258,4096,2)],c=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],p=113,f=666,m=258,u=262;function x(e,t,n,i){const r=e[2*t],a=e[2*n];return r>>8&255)}function de(e,t){let n;const i=t;ie>16-i?(n=e,ne|=n<>>16-ie,ie+=i-16):(ne|=e<=8&&(se(255&ne),ne>>>=8,ie-=8)}function fe(n,i){let r,a,o;if(e.pending_buf[$+2*Q]=n>>>8&255,e.pending_buf[$+2*Q+1]=255&n,e.pending_buf[G+Q]=255&i,Q++,0===n?V[2*i]++:(ee++,n--,V[2*(s._length_code[i]+t+1)]++,H[2*s.d_code(n)]++),0==(8191&Q)&&O>2){for(r=8*Q,a=T-j,o=0;o<30;o++)r+=H[2*o]*(5+s.extra_dbits[o]);if(r>>>=3,ee8?oe(ne):ie>0&&se(255&ne),ne=0,ie=0}function xe(t,n,i){de(0+(i?1:0),3),function(t,n,i){ue(),te=8,i&&(oe(n),oe(~n)),e.pending_buf.set(_.subarray(t,t+n),e.pending),e.pending+=n}(t,n,!0)}function he(t,n,i){let r,a,d=0;O>0?(K.build_tree(e),Y.build_tree(e),d=function(){let t;for(ae(V,K.max_code),ae(H,Y.max_code),X.build_tree(e),t=18;t>=3&&0===Z[2*s.bl_order[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t}(),r=e.opt_len+3+7>>>3,a=e.static_len+3+7>>>3,a<=r&&(r=a)):r=a=n+5,n+4<=r&&-1!=t?xe(t,n,i):a==r?(de(2+(i?1:0),3),me(o.static_ltree,o.static_dtree)):(de(4+(i?1:0),3),function(e,t,n){let i;for(de(e-257,5),de(t-1,5),de(n-4,4),i=0;i=0?j:-1,T-j,e),j=T,a.flush_pending()}function we(){let e,t,n,i;do{if(i=y-L-T,0===i&&0===T&&0===L)i=w;else if(-1==i)i--;else if(T>=w+w-u){_.set(_.subarray(w,w+w),0),C-=w,T-=w,j-=w,e=A,n=e;do{t=65535&E[--n],E[n]=t>=w?t-w:0}while(0!=--e);e=w,n=e;do{t=65535&k[--n],k[n]=t>=w?t-w:0}while(0!=--e);i+=w}if(0===a.avail_in)return;e=a.read_buf(_,T+L,i),L+=e,L>=3&&(z=255&_[T],z=(z<w-u?T-(w-u):0;let o=B;const d=b,l=T+m;let c=_[r+a-1],p=_[r+a];q>=P&&(i>>=2),o>L&&(o=L);do{if(t=e,_[t+a]==p&&_[t+a-1]==c&&_[t]==_[r]&&_[++t]==_[r+1]){r+=2,t++;do{}while(_[++r]==_[++t]&&_[++r]==_[++t]&&_[++r]==_[++t]&&_[++r]==_[++t]&&_[++r]==_[++t]&&_[++r]==_[++t]&&_[++r]==_[++t]&&_[++r]==_[++t]&&ra){if(C=e,a=n,n>=o)break;c=_[r+a-1],p=_[r+a]}}}while((e=65535&k[e&d])>s&&0!=--i);return a<=L?a:L}function be(t){return t.total_in=t.total_out=0,t.msg=null,e.pending=0,e.pending_out=0,d=p,v=0,K.dyn_tree=V,K.stat_desc=o.static_l_desc,Y.dyn_tree=H,Y.stat_desc=o.static_d_desc,X.dyn_tree=Z,X.stat_desc=o.static_bl_desc,ne=0,ie=0,te=8,re(),function(){y=2*w,E[A-1]=0;for(let e=0;e9||8!=a||r<9||r>15||n<0||n>9||o<0||o>2?i:(t.dstate=e,g=r,w=1<9||n<0||n>2?i:(l[O].func!=l[t].func&&0!==e.total_in&&(r=e.deflate(1)),O!=t&&(O=t,N=l[O].max_lazy,P=l[O].good_length,B=l[O].nice_length,M=l[O].max_chain),W=n,r)},e.deflateSetDictionary=function(e,t,n){let r,a=n,s=0;if(!t||42!=d)return i;if(a<3)return 0;for(a>w-u&&(a=w-u,s=n-a),_.set(t.subarray(s,s+a),0),T=a,j=a,z=255&_[0],z=(z<4||s<0)return i;if(!t.next_out||!t.next_in&&0!==t.avail_in||d==f&&4!=s)return t.msg=c[4],i;if(0===t.avail_out)return t.msg=c[7],r;var P;if(a=t,U=v,v=s,42==d&&(x=8+(g-8<<4)<<8,y=(O-1&255)>>1,y>3&&(y=3),x|=y<<6,0!==T&&(x|=32),x+=31-x%31,d=p,se((P=x)>>8&255),se(255&P)),0!==e.pending){if(a.flush_pending(),0===a.avail_out)return v=-1,0}else if(0===a.avail_in&&s<=U&&4!=s)return a.msg=c[7],r;if(d==f&&0!==a.avail_in)return t.msg=c[7],r;if(0!==a.avail_in||0!==L||0!=s&&d!=f){switch(M=-1,l[O].func){case 0:M=function(e){let t,n=65535;for(n>h-5&&(n=h-5);;){if(L<=1){if(we(),0===L&&0==e)return 0;if(0===L)break}if(T+=L,L=0,t=j+n,(0===T||T>=t)&&(L=T-t,T=t,ve(!1),0===a.avail_out))return 0;if(T-j>=w-u&&(ve(!1),0===a.avail_out))return 0}return ve(4==e),0===a.avail_out?4==e?2:0:4==e?3:1}(s);break;case 1:M=function(e){let t,n=0;for(;;){if(L=3&&(z=(z<=3)if(t=fe(T-C,I-3),L-=I,I<=N&&L>=3){I--;do{T++,z=(z<=3&&(z=(z<4096)&&(I=2)),q>=3&&I<=q){n=T+L-3,t=fe(T-1-S,q-3),L-=q-1,q-=2;do{++T<=n&&(z=(z<n&&(r=n),0===r?0:(i.avail_in-=r,e.set(i.next_in.subarray(i.next_in_index,i.next_in_index+r),t),i.next_in_index+=r,i.total_in+=r,r)},flush_pending:function(){const e=this;let t=e.dstate.pending;t>e.avail_out&&(t=e.avail_out),0!==t&&(e.next_out.set(e.dstate.pending_buf.subarray(e.dstate.pending_out,e.dstate.pending_out+t),e.next_out_index),e.next_out_index+=t,e.dstate.pending_out+=t,e.total_out+=t,e.avail_out-=t,e.dstate.pending-=t,0===e.dstate.pending&&(e.dstate.pending_out=0))}};const w=-2,g=-3,b=-5,_=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],y=[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],k=[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],E=[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],z=[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],A=[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],U=[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],R=15;function D(){let e,t,n,i,r,a;function s(e,t,s,o,d,l,c,p,f,m,u){let x,h,v,w,_,y,k,E,z,A,U,D,j,I,S;A=0,_=s;do{n[e[t+A]]++,A++,_--}while(0!==_);if(n[0]==s)return c[0]=-1,p[0]=0,0;for(E=p[0],y=1;y<=R&&0===n[y];y++);for(k=y,E_&&(E=_),p[0]=E,I=1<D+E;){if(w++,D+=E,S=v-D,S=S>E?E:S,(h=1<<(y=k-D))>x+1&&(h-=x+1,j=k,y1440)return g;r[w]=U=m[0],m[0]+=S,0!==w?(a[w]=_,i[0]=y,i[1]=E,y=_>>>D-E,i[2]=U-r[w-1]-y,f.set(i,3*(r[w-1]+y))):c[0]=U}for(i[1]=k-D,A>=s?i[0]=192:u[A]>>D;y>>=1)_^=y;for(_^=y,z=(1<257?(m==g?f.msg="oversubscribed distance tree":m==b?(f.msg="incomplete distance tree",m=g):-4!=m&&(f.msg="empty distance tree with lengths",m=g),m):0)}}D.inflate_trees_fixed=function(e,t,n,i){return e[0]=9,t[0]=5,n[0]=y,i[0]=k,0};function j(){const e=this;let t,n,i,r,a=0,s=0,o=0,d=0,l=0,c=0,p=0,f=0,m=0,u=0;function x(e,t,n,i,r,a,s,o){let d,l,c,p,f,m,u,x,h,v,w,b,y,k,E,z;u=o.next_in_index,x=o.avail_in,f=s.bitb,m=s.bitk,h=s.write,v=h>=l[z+1],m-=l[z+1],0!=(16&p)){for(p&=15,y=l[z+2]+(f&_[p]),f>>=p,m-=p;m<15;)x--,f|=(255&o.read_byte(u++))<>=l[z+1],m-=l[z+1],0!=(16&p)){for(p&=15;m>=p,m-=p,v-=y,h>=k)E=h-k,h-E>0&&2>h-E?(s.window[h++]=s.window[E++],s.window[h++]=s.window[E++],y-=2):(s.window.set(s.window.subarray(E,E+2),h),h+=2,E+=2,y-=2);else{E=h-k;do{E+=s.end}while(E<0);if(p=s.end-E,y>p){if(y-=p,h-E>0&&p>h-E)do{s.window[h++]=s.window[E++]}while(0!=--p);else s.window.set(s.window.subarray(E,E+p),h),h+=p,E+=p,p=0;E=0}}if(h-E>0&&y>h-E)do{s.window[h++]=s.window[E++]}while(0!=--y);else s.window.set(s.window.subarray(E,E+y),h),h+=y,E+=y,y=0;break}if(0!=(64&p))return o.msg="invalid distance code",y=o.avail_in-x,y=m>>3>3:y,x+=y,u-=y,m-=y<<3,s.bitb=f,s.bitk=m,o.avail_in=x,o.total_in+=u-o.next_in_index,o.next_in_index=u,s.write=h,g;d+=l[z+2],d+=f&_[p],z=3*(c+d),p=l[z]}break}if(0!=(64&p))return 0!=(32&p)?(y=o.avail_in-x,y=m>>3>3:y,x+=y,u-=y,m-=y<<3,s.bitb=f,s.bitk=m,o.avail_in=x,o.total_in+=u-o.next_in_index,o.next_in_index=u,s.write=h,1):(o.msg="invalid literal/length code",y=o.avail_in-x,y=m>>3>3:y,x+=y,u-=y,m-=y<<3,s.bitb=f,s.bitk=m,o.avail_in=x,o.total_in+=u-o.next_in_index,o.next_in_index=u,s.write=h,g);if(d+=l[z+2],d+=f&_[p],z=3*(c+d),0===(p=l[z])){f>>=l[z+1],m-=l[z+1],s.window[h++]=l[z+2],v--;break}}else f>>=l[z+1],m-=l[z+1],s.window[h++]=l[z+2],v--}while(v>=258&&x>=10);return y=o.avail_in-x,y=m>>3>3:y,x+=y,u-=y,m-=y<<3,s.bitb=f,s.bitk=m,o.avail_in=x,o.total_in+=u-o.next_in_index,o.next_in_index=u,s.write=h,0}e.init=function(e,a,s,o,d,l){t=0,p=e,f=a,i=s,m=o,r=d,u=l,n=null},e.proc=function(e,h,v){let b,y,k,E,z,A,U,R=0,D=0,j=0;for(j=h.next_in_index,E=h.avail_in,R=e.bitb,D=e.bitk,z=e.write,A=z=258&&E>=10&&(e.bitb=R,e.bitk=D,h.avail_in=E,h.total_in+=j-h.next_in_index,h.next_in_index=j,e.write=z,v=x(p,f,i,m,r,u,e,h),j=h.next_in_index,E=h.avail_in,R=e.bitb,D=e.bitk,z=e.write,A=z>>=n[y+1],D-=n[y+1],k=n[y],0===k){d=n[y+2],t=6;break}if(0!=(16&k)){l=15&k,a=n[y+2],t=2;break}if(0==(64&k)){o=k,s=y/3+n[y+2];break}if(0!=(32&k)){t=7;break}return t=9,h.msg="invalid literal/length code",v=g,e.bitb=R,e.bitk=D,h.avail_in=E,h.total_in+=j-h.next_in_index,h.next_in_index=j,e.write=z,e.inflate_flush(h,v);case 2:for(b=l;D>=b,D-=b,o=f,n=r,s=u,t=3;case 3:for(b=o;D>=n[y+1],D-=n[y+1],k=n[y],0!=(16&k)){l=15&k,c=n[y+2],t=4;break}if(0==(64&k)){o=k,s=y/3+n[y+2];break}return t=9,h.msg="invalid distance code",v=g,e.bitb=R,e.bitk=D,h.avail_in=E,h.total_in+=j-h.next_in_index,h.next_in_index=j,e.write=z,e.inflate_flush(h,v);case 4:for(b=l;D>=b,D-=b,t=5;case 5:for(U=z-c;U<0;)U+=e.end;for(;0!==a;){if(0===A&&(z==e.end&&0!==e.read&&(z=0,A=z7&&(D-=8,E++,j--),e.write=z,v=e.inflate_flush(h,v),z=e.write,A=ze.avail_out&&(i=e.avail_out),0!==i&&t==b&&(t=0),e.avail_out-=i,e.total_out+=i,e.next_out.set(n.window.subarray(a,a+i),r),r+=i,a+=i,a==n.end&&(a=0,n.write==n.end&&(n.write=0),i=n.write-a,i>e.avail_out&&(i=e.avail_out),0!==i&&t==b&&(t=0),e.avail_out-=i,e.total_out+=i,e.next_out.set(n.window.subarray(a,a+i),r),r+=i,a+=i),e.next_out_index=r,n.read=a,t},n.proc=function(e,t){let u,x,h,v,b,y,k,E;for(v=e.next_in_index,b=e.avail_in,x=n.bitb,h=n.bitk,y=n.write,k=y>>1){case 0:x>>>=3,h-=3,u=7&h,x>>>=u,h-=u,r=1;break;case 1:z=[],A=[],U=[[]],R=[[]],D.inflate_trees_fixed(z,A,U,R),c.init(z[0],A[0],U[0],0,R[0],0),x>>>=3,h-=3,r=6;break;case 2:x>>>=3,h-=3,r=3;break;case 3:return x>>>=3,h-=3,r=9,e.msg="invalid block type",t=g,n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t)}break;case 1:for(;h<32;){if(0===b)return n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);t=0,b--,x|=(255&e.read_byte(v++))<>>16&65535)!=(65535&x))return r=9,e.msg="invalid stored block lengths",t=g,n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);a=65535&x,x=h=0,r=0!==a?2:0!==p?7:0;break;case 2:if(0===b)return n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);if(0===k&&(y==n.end&&0!==n.read&&(y=0,k=yb&&(u=b),u>k&&(u=k),n.window.set(e.read_buf(v,u),y),v+=u,b-=u,y+=u,k-=u,0!=(a-=u))break;r=0!==p?7:0;break;case 3:for(;h<14;){if(0===b)return n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);t=0,b--,x|=(255&e.read_byte(v++))<29||(u>>5&31)>29)return r=9,e.msg="too many length or distance symbols",t=g,n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);if(u=258+(31&u)+(u>>5&31),!i||i.length>>=14,h-=14,o=0,r=4;case 4:for(;o<4+(s>>>10);){for(;h<3;){if(0===b)return n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);t=0,b--,x|=(255&e.read_byte(v++))<>>=3,h-=3}for(;o<19;)i[I[o++]]=0;if(d[0]=7,u=m.inflate_trees_bits(i,d,l,f,e),0!=u)return(t=u)==g&&(i=null,r=9),n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);o=0,r=5;case 5:for(;u=s,!(o>=258+(31&u)+(u>>5&31));){let a,c;for(u=d[0];h>>=u,h-=u,i[o++]=c;else{for(E=18==c?7:c-14,a=18==c?11:3;h>>=u,h-=u,a+=x&_[E],x>>>=E,h-=E,E=o,u=s,E+a>258+(31&u)+(u>>5&31)||16==c&&E<1)return i=null,r=9,e.msg="invalid bit length repeat",t=g,n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);c=16==c?i[E-1]:0;do{i[E++]=c}while(0!=--a);o=E}}if(l[0]=-1,j=[],S=[],F=[],T=[],j[0]=9,S[0]=6,u=s,u=m.inflate_trees_dynamic(257+(31&u),1+(u>>5&31),i,j,S,F,T,f,e),0!=u)return u==g&&(i=null,r=9),t=u,n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,n.inflate_flush(e,t);c.init(j[0],S[0],f,F[0],f,T[0]),r=6;case 6:if(n.bitb=x,n.bitk=h,e.avail_in=b,e.total_in+=v-e.next_in_index,e.next_in_index=v,n.write=y,1!=(t=c.proc(n,e,t)))return n.inflate_flush(e,t);if(t=0,c.free(e),v=e.next_in_index,b=e.avail_in,x=n.bitb,h=n.bitk,y=n.write,k=y15?(e.inflateEnd(n),w):(e.wbits=i,n.istate.blocks=new S(n,1<>4)>r.wbits){r.mode=F,e.msg="invalid window size",r.marker=5;break}r.mode=1;case 1:if(0===e.avail_in)return n;if(n=t,e.avail_in--,e.total_in++,i=255&e.read_byte(e.next_in_index++),((r.method<<8)+i)%31!=0){r.mode=F,e.msg="incorrect header check",r.marker=5;break}if(0==(32&i)){r.mode=7;break}r.mode=2;case 2:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,r.need=(255&e.read_byte(e.next_in_index++))<<24&4278190080,r.mode=3;case 3:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,r.need+=(255&e.read_byte(e.next_in_index++))<<16&16711680,r.mode=4;case 4:if(0===e.avail_in)return n;n=t,e.avail_in--,e.total_in++,r.need+=(255&e.read_byte(e.next_in_index++))<<8&65280,r.mode=5;case 5:return 0===e.avail_in?n:(n=t,e.avail_in--,e.total_in++,r.need+=255&e.read_byte(e.next_in_index++),r.mode=6,2);case 6:return r.mode=F,e.msg="need dictionary",r.marker=0,w;case 7:if(n=r.blocks.proc(e,n),n==g){r.mode=F,r.marker=0;break}if(0==n&&(n=t),1!=n)return n;n=t,r.blocks.reset(e,r.was),r.mode=12;case 12:return 1;case F:return g;default:return w}},e.inflateSetDictionary=function(e,t,n){let i=0,r=n;if(!e||!e.istate||6!=e.istate.mode)return w;const a=e.istate;return r>=1<{e.onload=e=>t(e.target.result),e.onerror=n,e.readAsText(this.blob,this.encoding)}))}}class H extends W{constructor(e){super(),this.dataURI=e;let t=e.length;for(;"="==e.charAt(t-1);)t--;this.dataStart=e.indexOf(",")+1,this.size=Math.floor(.75*(t-this.dataStart))}readUint8Array(e,t){const n=new Uint8Array(t),i=4*Math.floor(e/3),r=atob(this.dataURI.substring(i+this.dataStart,4*Math.ceil((e+t)/3)+this.dataStart)),a=e-3*Math.floor(i/4);for(let e=a;e2?this.data+=btoa(n):this.pending=n}getData(){return this.data+btoa(this.pending)}}class K extends W{constructor(e){super(),this.blob=e,this.size=e.size}readUint8Array(e,t){const n=new FileReader;return new Promise(((i,r)=>{n.onload=e=>i(new Uint8Array(e.target.result)),n.onerror=r,n.readAsArrayBuffer(this.blob.slice(e,e+t))}))}}class Y extends P{constructor(e){super(),this.offset=0,this.contentType=e,this.blob=new Blob([],{type:e})}writeUint8Array(e){super.writeUint8Array(e),this.blob=new Blob([this.blob,e.buffer],{type:this.contentType}),this.offset=this.blob.size}getData(){return this.blob}}class X extends W{constructor(e){super(),this.url=e}async init(){if(super.init(),function(e){if("undefined"!=typeof document){const t=document.createElement("a");return t.href=e,"http:"==t.protocol||"https:"==t.protocol}return/^https?:\/\//i.test(e)}(this.url))return new Promise(((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",(()=>{n.status<400?(this.size=Number(n.getResponseHeader("Content-Length")),this.size?e():Q().then((()=>e())).catch(t)):t(q+(n.statusText||n.status)+".")}),!1),n.addEventListener("error",t,!1),n.open("HEAD",this.url),n.send()}));await Q()}async readUint8Array(e,t){return this.data||await Q(this,this.url),new Uint8Array(this.data.subarray(e,e+t))}}class G extends W{constructor(e){super(),this.url=e}init(){return super.init(),new Promise(((e,t)=>{const n=new XMLHttpRequest;n.addEventListener("load",(()=>{n.status<400?(this.size=Number(n.getResponseHeader("Content-Length")),"bytes"==n.getResponseHeader("Accept-Ranges")?e():t(new Error(M))):t(q+(n.statusText||n.status)+".")}),!1),n.addEventListener("error",t,!1),n.open("HEAD",this.url),n.send()}))}readUint8Array(e,t){return new Promise(((n,i)=>{const r=new XMLHttpRequest;r.open("GET",this.url),r.responseType="arraybuffer",r.setRequestHeader("Range","bytes="+e+"-"+(e+t-1)),r.addEventListener("load",(()=>{r.status<400?n(new Uint8Array(r.response)):i(q+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",i,!1),r.send()}))}}class J extends P{constructor(){super(),this.array=new Uint8Array(0)}writeUint8Array(e){super.writeUint8Array(e);const t=this.array;this.array=new Uint8Array(t.length+e.length),this.array.set(t),this.array.set(e,t.length)}getData(){return this.array}}function Q(e,t){return new Promise(((n,i)=>{const r=new XMLHttpRequest;r.addEventListener("load",(()=>{r.status<400?(e.size||(e.size=Number(r.getResponseHeader("Content-Length"))||Number(r.response.byteLength)),e.data=new Uint8Array(r.response),n()):i(q+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",i,!1),r.open("GET",t),r.responseType="arraybuffer",r.send()}))}const $=4294967295,ee=65535,te=67324752,ne=134695760,ie=33639248,re=101010256,ae=101075792,se=117853008,oe=39169,de=2048;class le{constructor(){this.crc=-1,this.table=(()=>{const e=[];for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)1&n?n=n>>>1^3988292384:n>>>=1;e[t]=n}return e})()}append(e){const t=this.table;let n=0|this.crc;for(let i=0,r=0|e.length;i>>8^t[255&(n^e[i])];this.crc=n}get(){return~this.crc}}const ce="Invalid pasword",pe=16,fe="raw",me={name:"PBKDF2"},ue={name:"HMAC"},xe="SHA-1",he={name:"AES-CTR"},ve=Object.assign({hash:ue},me),we=Object.assign({iterations:1e3,hash:{name:xe}},me),ge=Object.assign({hash:xe},ue),be=Object.assign({length:pe},he),_e=["deriveBits"],ye=["sign"],ke=528,Ee=10,ze=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ae=crypto.subtle;class Ue{constructor(e,t){this.password=e,this.signed=t,this.input=t&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(e){const t=async(r=0)=>{if(r+pe<=i.length-Ee){const e=i.subarray(r,r+pe),a=await Ae.decrypt(Object.assign({counter:this.counter},be),this.keys.decrypt,e);return De(this.counter),n.set(new Uint8Array(a),r),t(r+pe)}return this.pendingInput=i.subarray(r),this.signed&&(this.input=je(this.input,e)),n};if(this.password){const t=e.subarray(0,18);await async function(e,t,n){e.counter=new Uint8Array(ze);const i=t.subarray(0,16),r=t.subarray(16),a=(new TextEncoder).encode(n),s=await Ae.importKey(fe,a,ve,!1,_e),o=await Ae.deriveBits(Object.assign({salt:i},we),s,528),d=new Uint8Array(o),l=d.subarray(64);if(e.keys={decrypt:await Ae.importKey(fe,d.subarray(0,32),he,!0,["decrypt"]),authentication:await Ae.importKey(fe,d.subarray(32,64),ge,!1,ye),passwordVerification:l},l[0]!=r[0]||l[1]!=r[1])throw new Error(ce)}(this,t,this.password),this.password=null,e=e.subarray(18)}let n=new Uint8Array(e.length-Ee-(e.length-Ee)%pe),i=e;return this.pendingInput.length&&(i=je(this.pendingInput,e),n=Ie(n,i.length-Ee-(i.length-Ee)%pe)),t()}async flush(){const e=this.pendingInput,t=this.keys,n=e.subarray(0,e.length-Ee),i=e.subarray(e.length-Ee);let r=new Uint8Array(0);if(n.length){const e=await Ae.decrypt(Object.assign({counter:this.counter},be),t.decrypt,n);r=new Uint8Array(e)}let a=!0;if(this.signed){const e=await Ae.sign(ue,t.authentication,this.input.subarray(0,this.input.length-Ee)),n=new Uint8Array(e);this.input=null;for(let e=0;e{if(r+pe<=e.length){const a=e.subarray(r,r+pe),s=await Ae.encrypt(Object.assign({counter:this.counter},be),this.keys.encrypt,a);return De(this.counter),i.set(new Uint8Array(s),r+n.length),t(r+pe)}return this.pendingInput=e.subarray(r),this.output=je(this.output,i),i};let n=new Uint8Array(0);this.password&&(n=await async function(e,t){e.counter=new Uint8Array(ze);const n=crypto.getRandomValues(new Uint8Array(16)),i=(new TextEncoder).encode(t),r=await Ae.importKey(fe,i,ve,!1,_e),a=await Ae.deriveBits(Object.assign({salt:n},we),r,ke),s=new Uint8Array(a);return e.keys={encrypt:await Ae.importKey(fe,s.subarray(0,32),he,!0,["encrypt"]),authentication:await Ae.importKey(fe,s.subarray(32,64),ge,!1,ye),passwordVerification:s.subarray(64)},je(n,e.keys.passwordVerification)}(this,this.password),this.password=null);let i=new Uint8Array(n.length+e.length-e.length%pe);return i.set(n,0),this.pendingInput.length&&(e=je(this.pendingInput,e),i=Ie(i,e.length-e.length%pe)),t()}async flush(){let e=new Uint8Array(0);if(this.pendingInput.length){const t=await Ae.encrypt(Object.assign({counter:this.counter},be),this.keys.encrypt,this.pendingInput);e=new Uint8Array(t),this.output=je(this.output,e)}const t=await Ae.sign(ue,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(t).subarray(0,Ee);return{data:je(e,n),signature:n}}}function De(e){for(let t=0;t<16;t++){if(255!=e[t]){e[t]++;break}e[t]=0}}function je(e,t){let n=e;return e.length+t.length&&(n=new Uint8Array(e.length+t.length),n.set(e,0),n.set(t,e.length)),n}function Ie(e,t){if(t&&t>e.length){const n=e;(e=new Uint8Array(t)).set(n,0)}return e}const Se="deflate",Fe="inflate",Te="Invalid signature";class Ce{constructor(e){this.signature=e.inputSignature,this.encrypted=Boolean(e.inputPassword),this.signed=e.inputSigned,this.compressed=e.inputCompressed,this.inflate=this.compressed&&new e.codecConstructor,this.crc32=this.signed&&this.signed&&new le,this.decrypt=this.encrypted&&new Ue(e.inputPassword)}async append(e){return this.encrypted&&(e=await this.decrypt.append(e)),this.compressed&&e.length&&(e=await this.inflate.append(e)),!this.encrypted&&this.signed&&this.crc32.append(e),e}async flush(){let e,t=new Uint8Array(0);if(this.encrypted){const e=await this.decrypt.flush();if(!e.valid)throw new Error(Te);t=e.data}else if(this.signed){const t=new DataView(new Uint8Array(4).buffer);if(e=this.crc32.get(),t.setUint32(0,e),this.signature!=t.getUint32(0,!1))throw new Error(Te)}return this.compressed&&(t=await this.inflate.append(t)||new Uint8Array(0),await this.inflate.flush()),{data:t,signature:e}}}class Le{constructor(e){this.encrypted=e.outputEncrypted,this.signed=e.outputSigned,this.compressed=e.outputCompressed,this.deflate=this.compressed&&new e.codecConstructor({level:e.level||5}),this.crc32=this.signed&&new le,this.encrypt=this.encrypted&&new Re(e.outputPassword)}async append(e){let t=e;return this.compressed&&e.length&&(t=await this.deflate.append(e)),this.encrypted?t=await this.encrypt.append(t):this.signed&&this.crc32.append(e),t}async flush(){let e,t=new Uint8Array(0);if(this.compressed&&(t=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){t=await this.encrypt.append(t);const n=await this.encrypt.flush();e=n.signature;const i=new Uint8Array(t.length+n.data.length);i.set(t,0),i.set(n.data,t.length),t=i}else this.signed&&(e=this.crc32.get());return{data:t,signature:e}}}const qe="init",Me="append",Ne="flush",Oe="message",We="z-worker.js",Pe={deflate:[We],inflate:[We]},Be={pool:[],pendingRequests:[]};function Ve(e,t){const n=Be.pool,i=!(t.inputCompressed||t.inputSigned||t.inputEncrypted||t.outputCompressed||t.outputSigned||t.outputEncrypted);let r;if(t.useWebWorkers||void 0===t.useWebWorkers&&e.useWebWorkers&&!i){const n=t.codecType;e.workerScripts?(a=e.workerScripts[n],r="undefined"!=typeof document?a.map((e=>new URL(e,document.baseURI).href)):a):(r=Pe[n].slice(0),r[0]=(e.workerScriptsPath||"")+r[0])}var a;if(n.length!e.busy));return e?He(e,t,r):new Promise((e=>Be.pendingRequests.push({resolve:e,options:t,scripts:r})))}}function He(e,t,n){return e.busy=!0,e.options=t,e.scripts=n,n?function(e){let t;e.interface||(e.worker=new Worker(e.scripts[0]),e.worker.addEventListener(Oe,r,!1),e.interface={append:e=>n({type:Me,data:e}),flush:()=>n({type:Ne})});return e.interface;async function n(n){if(!t){const t=e.options,n=e.scripts.slice(1);await i(Object.assign({scripts:n,type:qe,options:{codecType:t.codecType,inputPassword:t.inputPassword,inputSigned:t.inputSigned,inputSignature:t.signature,inputCompressed:t.inputCompressed,inputEncrypted:t.inputEncrypted,level:t.level,outputPassword:t.outputPassword,outputSigned:t.outputSigned,outputCompressed:t.outputCompressed,outputEncrypted:t.outputEncrypted}}))}return i(n)}function i(n){const i=e.worker,r=new Promise(((e,n)=>t={resolve:e,reject:n}));try{if(n.data)try{i.postMessage(n,[n.data.buffer])}catch(e){i.postMessage(n)}else i.postMessage(n)}catch(n){t.reject(n),t=null,Ze(e)}return r}function r(n){const i=n.data;if(t){const n=i.error;if(n){const i=new Error(n.message);i.stack=n.stack,t.reject(i),t=null,Ze(e)}else i.type!=qe&&i.type!=Ne&&i.type!=Me||(i.type==Ne?(t.resolve({data:new Uint8Array(i.data),signature:i.signature}),t=null,Ze(e)):t.resolve(i.data&&new Uint8Array(i.data)))}}}(e):function(e){const t=function(e){return e.codecType.startsWith(Se)?new Le(e):e.codecType.startsWith(Fe)?new Ce(e):void 0}(e.options);return{async append(n){try{return await t.append(n)}catch(t){throw Ze(e),t}},async flush(){try{return await t.flush()}finally{Ze(e)}}}}(e)}function Ze(e){if(e.busy=!1,Be.pendingRequests.length){const[{resolve:t,options:n,scripts:i}]=Be.pendingRequests.splice(0,1);t(He(e,n,i))}else e.worker&&e.worker.terminate(),Be.pool=Be.pool.filter((t=>t!=e))}async function Ke(e,t,n,i,r,a,s){const o=Math.max(a.chunkSize,64);return async function a(d=0,l=0){const c=d*o;if(c","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","⌂","Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","¢","£","¥","₧","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","⌐","¬","½","¼","¡","«","»","░","▒","▓","│","┤","╡","╢","╖","╕","╣","║","╗","╝","╜","╛","┐","└","┴","┬","├","─","┼","╞","╟","╚","╔","╩","╦","╠","═","╬","╧","╨","╤","╥","╙","╘","╒","╓","╫","╪","┘","┌","█","▄","▌","▐","▀","α","ß","Γ","π","Σ","σ","µ","τ","Φ","Θ","Ω","δ","∞","φ","ε","∩","≡","±","≥","≤","⌠","⌡","÷","≈","°","∙","·","√","ⁿ","²","■"," "];class dt{constructor(e,t,n){this.reader=e,this.config=t,this.options=n}async getData(e,t={}){const n=this.reader;n.initialized||await n.init();const i=await n.readUint8Array(this.offset,30),r=new DataView(i.buffer),a=void 0===t.password?this.options.password:t.password;let s=a&&a.length&&a;if(this.extraFieldAES){if(99!=this.extraFieldAES.originalCompressionMethod)throw new Error(rt);if(3!=this.extraFieldAES.strength)throw new Error(it)}if(0!=this.compressionMethod&&8!=this.compressionMethod)throw new Error(rt);if(xt(r,0)!=te)throw new Error(et);const o=this.localDirectory={};lt(o,r,4),o.rawExtraField=i.subarray(this.offset+30+o.filenameLength,this.offset+30+o.filenameLength+o.extraFieldLength),ct(this,o,r,4);let d=this.offset+30+o.filenameLength+o.extraFieldLength;const l=this.bitFlag.encrypted&&o.bitFlag.encrypted;if(l&&!s)throw new Error(nt);const c=await Ve(this.config,{codecType:Fe,codecConstructor:this.config.Inflate,inputPassword:s,inputSigned:void 0===t.checkSignature?this.options.checkSignature:t.checkSignature,inputSignature:this.signature,inputCompressed:0!=this.compressionMethod,inputEncrypted:l,useWebWorkers:void 0===t.useWebWorkers?this.options.useWebWorkers:t.useWebWorkers});return e.initialized||await e.init(),await Ke(c,n,e,d,this.compressedSize,this.config,{onprogress:t.onprogress}),e.getData()}}function lt(e,t,n){e.version=ut(t,n);const i=e.rawBitFlag=ut(t,n+2);e.bitFlag={encrypted:1==(1&i),level:(6&i)>>1,dataDescriptor:8==(8&i),languageEncodingFlag:(i&de)==de},e.encrypted=e.bitFlag.encrypted,e.rawLastModDate=xt(t,n+6),e.lastModDate=function(e){const t=(4294901760&e)>>16,n=65535&e;try{return new Date(1980+((65024&t)>>9),((480&t)>>5)-1,31&t,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(e){}}(e.rawLastModDate),e.filenameLength=ut(t,n+22),e.extraFieldLength=ut(t,n+24)}function ct(e,t,n,i){const r=t.rawExtraField,a=t.extraField=new Map,s=new DataView(new Uint8Array(r).buffer);let o=0;try{for(;ot[e]==$));for(let t=0;t{if(t[n]==$){if(!e||void 0===e[n])throw new Error(tt);t[n]=e[n]}}))}(l,t);const c=t.extraFieldUnicodePath=a.get(28789);c&&pt(c,"filename","rawFilename",t,e);let p=t.extraFieldUnicodeComment=a.get(25461);p&&pt(p,"comment","rawComment",t,e);const f=t.extraFieldAES=a.get(39169);f?function(e,t,n){if(e){const i=new DataView(e.data.buffer);e.vendorVersion=mt(i,0),e.vendorId=mt(i,2);const r=mt(i,4);e.strength=r,e.originalCompressionMethod=n,t.compressionMethod=e.compressionMethod=ut(i,5)}else t.compressionMethod=n}(f,t,d):t.compressionMethod=d,8==t.compressionMethod&&(t.bitFlag.enhancedDeflating=16!=(16&t.rawBitFlag))}function pt(e,t,n,i,r){const a=new DataView(e.data.buffer);e.version=mt(a,0),e.signature=xt(a,1);const s=new le;s.append(r[n]);const o=new DataView(new Uint8Array(4).buffer);o.setUint32(0,s.get()),e[t]=(new TextDecoder).decode(e.data.subarray(5)),r.bitFlag.languageEncodingFlag||e.signature!=xt(o,0)||(i[t]=e[t])}function ft(e,t){if(t&&"cp437"!=t.trim().toLowerCase())return new TextDecoder(t).decode(e);{let t="";for(let n=0;n{if(this.pendingData){const t=this.pendingData;this.pendingData=new Uint8Array(t.length+e.length),this.pendingData.set(t,0),this.pendingData.set(e,t.length)}else this.pendingData=new Uint8Array(e)};if(this.codec=new e(Object.assign({},t,n)),typeof this.codec.onData==jt)this.codec.onData=i;else{if(typeof this.codec.on!=jt)throw new Error("Cannot register the callback function");this.codec.on("data",i)}}async append(e){return this.codec.push(e),n(this)}async flush(){return this.codec.push(new Uint8Array(0),!0),n(this)}};function n(e){if(e.pendingData){const t=e.pendingData;return e.pendingData=null,t}return new Uint8Array(0)}}const St={chunkSize:524288,maxWorkers:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||2,workerScriptsPath:void 0,useWebWorkers:!0,Deflate:function(e){const t=new v,n=512,i=new Uint8Array(n);let r=e?e.level:-1;void 0===r&&(r=-1),t.deflateInit(r),t.next_out=i,this.append=function(e,r){let a,s,o=0,d=0,l=0;const c=[];if(e.length){t.next_in_index=0,t.next_in=e,t.avail_in=e.length;do{if(t.next_out_index=0,t.avail_out=n,a=t.deflate(0),0!=a)throw new Error("deflating: "+t.msg);t.next_out_index&&(t.next_out_index==n?c.push(new Uint8Array(i)):c.push(new Uint8Array(i.subarray(0,t.next_out_index)))),l+=t.next_out_index,r&&t.next_in_index>0&&t.next_in_index!=o&&(r(t.next_in_index),o=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return s=new Uint8Array(l),c.forEach((function(e){s.set(e,d),d+=e.length})),s}},this.flush=function(){let e,r,a=0,s=0;const o=[];do{if(t.next_out_index=0,t.avail_out=n,e=t.deflate(4),1!=e&&0!=e)throw new Error("deflating: "+t.msg);n-t.avail_out>0&&o.push(new Uint8Array(i.subarray(0,t.next_out_index))),s+=t.next_out_index}while(t.avail_in>0||0===t.avail_out);return t.deflateEnd(),r=new Uint8Array(s),o.forEach((function(e){r.set(e,a),a+=e.length})),r}},Inflate:function(){const e=new L,t=new Uint8Array(512);let n=!1;e.inflateInit(),e.next_out=t,this.append=function(i,r){const a=[];let s,o,d=0,l=0,c=0;if(0!==i.length){e.next_in_index=0,e.next_in=i,e.avail_in=i.length;do{if(e.next_out_index=0,e.avail_out=512,0!==e.avail_in||n||(e.next_in_index=0,n=!0),s=e.inflate(0),n&&s===b){if(0!==e.avail_in)throw new Error("inflating: bad input")}else if(0!==s&&1!==s)throw new Error("inflating: "+e.msg);if((n||1===s)&&e.avail_in===i.length)throw new Error("inflating: bad input");e.next_out_index&&(512===e.next_out_index?a.push(new Uint8Array(t)):a.push(new Uint8Array(t.subarray(0,e.next_out_index)))),c+=e.next_out_index,r&&e.next_in_index>0&&e.next_in_index!=d&&(r(e.next_in_index),d=e.next_in_index)}while(e.avail_in>0||0===e.avail_out);return o=new Uint8Array(c),a.forEach((function(e){o.set(e,l),l+=e.length})),o}},this.flush=function(){e.inflateEnd()}}};let Ft=Object.assign({},St);class Tt extends class{constructor(e,t={},n={}){this.reader=e,this.options=t,this.config=n}async getEntries(e={}){const t=this.reader;t.initialized||await t.init();const n=await async function(e,t,n,i){const r=new Uint8Array(4);if(function(e,t,n){e.setUint32(t,n,!0)}(new DataView(r.buffer),0,t),e.size=0;e--)if(a[e]==r[0]&&a[e+1]==r[1]&&a[e+2]==r[2]&&a[e+3]==r[3])return{offset:i,buffer:a.slice(e,e+n).buffer}}}(t,re,22,ee);if(!n)throw new Error(Ge);const i=new DataView(n.buffer);let r,a=xt(i,16),s=ut(i,8);if(a==$||s==ee){r=!0;const e=await t.readUint8Array(n.offset-20,20),i=new DataView(e.buffer);if(Number(xt(i,0))!=se)throw new Error(Je);a=Number(ht(i,8));const o=await t.readUint8Array(a,56),d=new DataView(o.buffer);if(Number(xt(d,0))!=ae)throw new Error(Qe);s=Number(ht(d,24)),a-=Number(ht(d,40))}if(a<0||!r&&(a>=t.size||s>=ee))throw new Error(Xe);const o=await t.readUint8Array(a,t.size-a),d=new DataView(o.buffer),l=[];let c=0;for(let t=0;tee)throw new Error(bt);const r=(new TextEncoder).encode(n.comment||"");if(r.length>ee)throw new Error(gt);const a=this.options.version||n.version||0;if(a>ee)throw new Error(_t);const s=n.lastModDate||new Date;if(s.getFullYear()<1980)throw new Error(yt);t&&!t.initialized&&await t.init();let o=new Uint8Array(0);const d=n.extraField;if(d){let e=4,t=0;d.forEach((t=>e+=t.length)),o=new Uint8Array(e),d.forEach(((e,n)=>{if(n>ee)throw new Error(kt);if(e.length>ee)throw new Error(Et);o.set(new Uint16Array([n]),t),o.set(new Uint16Array([e.length]),t+2),o.set(e,t+4),t+=4+e.length}))}const l=n.zip64||this.options.zip64||this.offset>=$||t&&(t.size>=$||this.offset+t.size>=$),c=void 0===n.password?this.options.password:n.password,p=void 0===n.level?this.options.level:n.level,f=void 0===n.useWebWorkers?this.options.useWebWorkers:n.useWebWorkers;await async function(e,t,n,i){const r=e.files,a=e.writer;let s;r.set(t,null);try{let o,d;try{i.bufferedWrite||e.options.bufferedWrite||e.lockWrite?(o=new J,o.init()):(e.lockWrite=new Promise((e=>s=e)),a.initialized||await a.init(),o=a),d=await async function(e,t,n,i){const r=i.rawFilename,a=i.lastModDate,s=i.password,o=s&&s.length,d=i.level,l=0!==d&&!i.directory,c=i.zip64;let p;if(o){p=new Uint8Array(zt.length+2);Ut(new DataView(p.buffer),0,oe),p.set(zt,2)}else p=new Uint8Array(0);const f={version:i.version||20,zip64:c,directory:i.directory,rawFilename:r,rawComment:i.rawComment,extraFieldZip64:c?new Uint8Array(28):new Uint8Array(0),extraFieldAES:p,rawExtraField:i.rawExtraField};let m=2056,u=0;l&&(u=8);c&&(f.version=f.version>45?f.version:45);o&&(f.version=f.version>51?f.version:51,m|=1,u=99,l&&(f.extraFieldAES[9]=8));const x=f.headerArray=new Uint8Array(26),h=new DataView(x.buffer);Ut(h,0,f.version),Ut(h,2,m),Ut(h,4,u),Ut(h,6,(a.getHours()<<6|a.getMinutes())<<5|a.getSeconds()/2),Ut(h,8,(a.getFullYear()-1980<<4|a.getMonth()+1)<<5|a.getDate()),Ut(h,22,r.length),Ut(h,24,0);const v=new Uint8Array(30+r.length);let w,g,b;if(Rt(new DataView(v.buffer),0,te),v.set(x,4),v.set(r,30),e){g=e.size;const r=await Ve(n,{codecType:Se,codecConstructor:n.Deflate,level:d,outputPassword:s,outputSigned:!0,outputCompressed:l,outputEncrypted:o,useWebWorkers:i.useWebWorkers});await t.writeUint8Array(v),w=await Ke(r,e,t,0,g,n,{onprogress:i.onprogress}),b=w.length}else await t.writeUint8Array(v);const _=new Uint8Array(c?24:16),y=new DataView(_.buffer);if(Rt(y,0,ne),e)if(o||void 0===w.signature||(Rt(h,10,w.signature),Rt(y,4,w.signature)),c){const e=new DataView(f.extraFieldZip64.buffer);Ut(e,0,1),Ut(e,2,24),Rt(h,14,$),Dt(y,8,BigInt(b)),Dt(e,12,BigInt(b)),Rt(h,18,$),Dt(y,16,BigInt(g)),Dt(e,4,BigInt(g))}else Rt(h,14,b),Rt(y,8,b),Rt(h,18,g),Rt(y,12,g);return await t.writeUint8Array(_),f.length=v.length+(w?w.length:0)+_.length,f}(n,o,e.config,i)}catch(e){throw r.delete(t),e}if(r.set(t,d),o!=a&&(e.lockWrite&&await e.lockWrite,await a.writeUint8Array(o.getData())),d.offset=e.offset,d.zip64){Dt(new DataView(d.extraFieldZip64.buffer),20,BigInt(d.offset))}e.offset+=d.length}finally{s&&(e.lockWrite=null,s())}}(this,e,t,Object.assign({},n,{rawFilename:i,rawComment:r,version:a,lastModDate:s,rawExtraField:o,zip64:l,password:c,level:p,useWebWorkers:f}))}async close(e=new Uint8Array(0)){const t=this.writer,n=this.files;let i=0,r=0,a=this.offset,s=n.size;if(e.length){if(!(e.length<=ee))throw new Error(wt);Ut(l,i+20,e.length)}for(const[,e]of n)r+=46+e.rawFilename.length+e.rawComment.length+e.extraFieldZip64.length+e.extraFieldAES.length+e.rawExtraField.length;const o=this.options.zip64||a+r>=$||s>=ee,d=new Uint8Array(r+(o?98:22)),l=new DataView(d.buffer);for(const[,e]of n){const t=e.rawFilename,n=e.extraFieldZip64,r=e.extraFieldAES,a=n.length+r.length+e.rawExtraField.length;Rt(l,i,ie),Ut(l,i+4,e.version),d.set(e.headerArray,i+6),Ut(l,i+30,a),Ut(l,i+32,e.rawComment.length),e.directory&&At(l,i+38,16),e.zip64?Rt(l,i+42,$):Rt(l,i+42,e.offset),d.set(t,i+46),d.set(n,i+46+t.length),d.set(r,i+46+t.length+n.length),d.set(e.rawExtraField,46+t.length+n.length+r.length),d.set(e.rawComment,i+46+t.length+a),i+=46+t.length+a+e.rawComment.length}return o&&(Rt(l,i,ae),Dt(l,i+4,BigInt(44)),Ut(l,i+12,45),Ut(l,i+14,45),Dt(l,i+24,BigInt(s)),Dt(l,i+32,BigInt(s)),Dt(l,i+40,BigInt(r)),Dt(l,i+48,BigInt(a)),Rt(l,i+56,se),Dt(l,i+64,BigInt(a+r)),Rt(l,i+72,1),s=ee,a=$,i+=76),Rt(l,i,re),Ut(l,i+8,s),Ut(l,i+10,s),Rt(l,i+12,r),Rt(l,i+16,a),await t.writeUint8Array(d),await t.writeUint8Array(e),t.getData()}}{constructor(e,t){super(e,t,Ft)}}const Lt=524288;class qt{constructor(e,t,n,i){if(e.root&&i&&i.getChildByName(t))throw new Error("Entry filename already exists");n||(n={}),this.fs=e,this.name=t,this.data=n.data,this.id=e.entries.length,this.parent=i,this.children=[],this.uncompressedSize=0,e.entries.push(this),i&&this.parent.children.push(this)}moveTo(e){if(!e.directory)throw new Error("Target entry is not a directory");if(e.isDescendantOf(this))throw new Error("Entry is a ancestor of target entry");if(this!=e){if(e.getChildByName(this.name))throw new Error("Entry filename already exists");Vt(this),this.parent=e,e.children.push(this)}}getFullname(){let e=this.name,t=this.parent;for(;t;)e=(t.name?t.name+"/":"")+e,t=t.parent;return e}isDescendantOf(e){let t=this.parent;for(;t&&t.id!=e.id;)t=t.parent;return Boolean(t)}}class Mt extends qt{constructor(e,t,n,i){super(e,t,n,i),this.Reader=n.Reader,this.Writer=n.Writer,n.getData&&(this.getData=n.getData)}async getData(e,t={}){return!e||e.constructor==this.Writer&&this.data?this.data:(this.reader||(this.reader=new this.Reader(this.data)),await this.reader.init(),await e.init(),this.uncompressedSize=this.reader.size,async function(e,t,n){return i();async function i(r=0){const a=r*Lt;if(n.onprogress&&n.onprogress(a,e.size),a{t.file((i=>{e.addBlob(t.name,i),n()}),i)}));function n(e){return new Promise(((t,n)=>{let i=[];function r(e){e.readEntries((n=>{n.length?(i=i.concat(n),r(e)):t(i)}),n)}e.isDirectory&&r(e.createReader()),e.isFile&&t(i)}))}async function i(e,t){const r=await n(t);for(const t of r)t.isDirectory&&await i(e.addDirectory(t.name)),await new Promise(((n,i)=>{t.isFile&&t.file((i=>{const r=e.addBlob(t.name,i);r.uncompressedSize=i.size,n(r)}),i)}))}}(this,e)}async addData(e,t){return Zt(this,e,t)}async importBlob(e,t={}){await this.importZip(new K(e),t)}async importData64URI(e,t={}){await this.importZip(new H(e),t)}async importHttpContent(e,t={}){await this.importZip(t.useRangeHeader?new G(e):new X(e),t)}async exportBlob(e={}){return this.exportZip(new Y("application/zip"),e)}async exportData64URI(e={}){return this.exportZip(new Z("application/zip"),e)}async importZip(e,t){await e.init();const n=new Tt(e,t),i=await n.getEntries();let r=0;const a=Wt(i,"compressedSize");i.forEach((e=>{let n=this,i=e.filename.split("/"),s=i.pop();if(i.forEach((e=>n=n.getChildByName(e)||new Nt(this.fs,e,null,n))),!e.directory){let i=r;Zt(n,s,{data:e,Reader:Pt(Object.assign({},{onprogress:e=>{t.onprogress&&t.onprogress(i+e,a)}}))}),r+=e.compressedSize}}))}async exportZip(e,t){await Bt(this);const n=new Ct(e,t);return await async function(e,t,n,i){let r=0;async function a(e,t){async function s(){let s=0;for(const o of t.children){let t=r;await e.add(o.getFullname(),o.reader,Object.assign({directory:o.directory},{onprogress:e=>{i.onprogress&&i.onprogress(t+s+e,n)}})),r+=o.uncompressedSize,await a(e,o),s++}}await s()}await a(e,t)}(n,this,Wt([this],"uncompressedSize"),t),await n.close(),e.getData()}getChildByName(e){for(let t=0;t{n.id==e.id&&t.splice(i,1)}))}function Ht(e){e.entries=[],e.root=new Nt(e)}function Zt(e,t,n,i){if(e.directory)return i?new Nt(e.fs,t,n,e):new Mt(e.fs,t,n,e);throw new Error("Parent entry is not a directory")}const Kt={application:{"andrew-inset":"ez",annodex:"anx","atom+xml":"atom","atomcat+xml":"atomcat","atomserv+xml":"atomsrv",bbolin:"lin",cap:["cap","pcap"],"cu-seeme":"cu","davmount+xml":"davmount",dsptype:"tsp",ecmascript:["es","ecma"],futuresplash:"spl",hta:"hta","java-archive":"jar","java-serialized-object":"ser","java-vm":"class",javascript:"js",m3g:"m3g","mac-binhex40":"hqx",mathematica:["nb","ma","mb"],msaccess:"mdb",msword:["doc","dot"],mxf:"mxf",oda:"oda",ogg:"ogx",pdf:"pdf","pgp-keys":"key","pgp-signature":["asc","sig"],"pics-rules":"prf",postscript:["ps","ai","eps","epsi","epsf","eps2","eps3"],rar:"rar","rdf+xml":"rdf","rss+xml":"rss",rtf:"rtf",smil:["smi","smil"],"xhtml+xml":["xhtml","xht"],xml:["xml","xsl","xsd"],"xspf+xml":"xspf",zip:"zip","vnd.android.package-archive":"apk","vnd.cinderella":"cdy","vnd.google-earth.kml+xml":"kml","vnd.google-earth.kmz":"kmz","vnd.mozilla.xul+xml":"xul","vnd.ms-excel":["xls","xlb","xlt","xlm","xla","xlc","xlw"],"vnd.ms-pki.seccat":"cat","vnd.ms-pki.stl":"stl","vnd.ms-powerpoint":["ppt","pps","pot"],"vnd.oasis.opendocument.chart":"odc","vnd.oasis.opendocument.database":"odb","vnd.oasis.opendocument.formula":"odf","vnd.oasis.opendocument.graphics":"odg","vnd.oasis.opendocument.graphics-template":"otg","vnd.oasis.opendocument.image":"odi","vnd.oasis.opendocument.presentation":"odp","vnd.oasis.opendocument.presentation-template":"otp","vnd.oasis.opendocument.spreadsheet":"ods","vnd.oasis.opendocument.spreadsheet-template":"ots","vnd.oasis.opendocument.text":"odt","vnd.oasis.opendocument.text-master":"odm","vnd.oasis.opendocument.text-template":"ott","vnd.oasis.opendocument.text-web":"oth","vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","vnd.openxmlformats-officedocument.spreadsheetml.template":"xltx","vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","vnd.openxmlformats-officedocument.presentationml.slideshow":"ppsx","vnd.openxmlformats-officedocument.presentationml.template":"potx","vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","vnd.openxmlformats-officedocument.wordprocessingml.template":"dotx","vnd.smaf":"mmf","vnd.stardivision.calc":"sdc","vnd.stardivision.chart":"sds","vnd.stardivision.draw":"sda","vnd.stardivision.impress":"sdd","vnd.stardivision.math":["sdf","smf"],"vnd.stardivision.writer":["sdw","vor"],"vnd.stardivision.writer-global":"sgl","vnd.sun.xml.calc":"sxc","vnd.sun.xml.calc.template":"stc","vnd.sun.xml.draw":"sxd","vnd.sun.xml.draw.template":"std","vnd.sun.xml.impress":"sxi","vnd.sun.xml.impress.template":"sti","vnd.sun.xml.math":"sxm","vnd.sun.xml.writer":"sxw","vnd.sun.xml.writer.global":"sxg","vnd.sun.xml.writer.template":"stw","vnd.symbian.install":["sis","sisx"],"vnd.visio":["vsd","vst","vss","vsw"],"vnd.wap.wbxml":"wbxml","vnd.wap.wmlc":"wmlc","vnd.wap.wmlscriptc":"wmlsc","vnd.wordperfect":"wpd","vnd.wordperfect5.1":"wp5","x-123":"wk","x-7z-compressed":"7z","x-abiword":"abw","x-apple-diskimage":"dmg","x-bcpio":"bcpio","x-bittorrent":"torrent","x-cbr":["cbr","cba","cbt","cb7"],"x-cbz":"cbz","x-cdf":["cdf","cda"],"x-cdlink":"vcd","x-chess-pgn":"pgn","x-cpio":"cpio","x-csh":"csh","x-debian-package":["deb","udeb"],"x-director":["dcr","dir","dxr","cst","cct","cxt","w3d","fgd","swa"],"x-dms":"dms","x-doom":"wad","x-dvi":"dvi","x-httpd-eruby":"rhtml","x-font":"pcf.Z","x-freemind":"mm","x-gnumeric":"gnumeric","x-go-sgf":"sgf","x-graphing-calculator":"gcf","x-gtar":["gtar","taz"],"x-hdf":"hdf","x-httpd-php":["phtml","pht","php"],"x-httpd-php-source":"phps","x-httpd-php3":"php3","x-httpd-php3-preprocessed":"php3p","x-httpd-php4":"php4","x-httpd-php5":"php5","x-ica":"ica","x-info":"info","x-internet-signup":["ins","isp"],"x-iphone":"iii","x-iso9660-image":"iso","x-java-jnlp-file":"jnlp","x-jmol":"jmz","x-killustrator":"kil","x-koan":["skp","skd","skt","skm"],"x-kpresenter":["kpr","kpt"],"x-kword":["kwd","kwt"],"x-latex":"latex","x-lha":"lha","x-lyx":"lyx","x-lzh":"lzh","x-lzx":"lzx","x-maker":["frm","maker","frame","fm","fb","book","fbdoc"],"x-ms-wmd":"wmd","x-ms-wmz":"wmz","x-msdos-program":["com","exe","bat","dll"],"x-msi":"msi","x-netcdf":["nc","cdf"],"x-ns-proxy-autoconfig":["pac","dat"],"x-nwc":"nwc","x-object":"o","x-oz-application":"oza","x-pkcs7-certreqresp":"p7r","x-python-code":["pyc","pyo"],"x-qgis":["qgs","shp","shx"],"x-quicktimeplayer":"qtl","x-redhat-package-manager":"rpm","x-ruby":"rb","x-sh":"sh","x-shar":"shar","x-shockwave-flash":["swf","swfl"],"x-silverlight":"scr","x-stuffit":"sit","x-sv4cpio":"sv4cpio","x-sv4crc":"sv4crc","x-tar":"tar","x-tcl":"tcl","x-tex-gf":"gf","x-tex-pk":"pk","x-texinfo":["texinfo","texi"],"x-trash":["~","%","bak","old","sik"],"x-troff":["t","tr","roff"],"x-troff-man":"man","x-troff-me":"me","x-troff-ms":"ms","x-ustar":"ustar","x-wais-source":"src","x-wingz":"wz","x-x509-ca-cert":["crt","der","cer"],"x-xcf":"xcf","x-xfig":"fig","x-xpinstall":"xpi",applixware:"aw","atomsvc+xml":"atomsvc","ccxml+xml":"ccxml","cdmi-capability":"cdmia","cdmi-container":"cdmic","cdmi-domain":"cdmid","cdmi-object":"cdmio","cdmi-queue":"cdmiq","docbook+xml":"dbk","dssc+der":"dssc","dssc+xml":"xdssc","emma+xml":"emma","epub+zip":"epub",exi:"exi","font-tdpfr":"pfr","gml+xml":"gml","gpx+xml":"gpx",gxf:"gxf",hyperstudio:"stk","inkml+xml":["ink","inkml"],ipfix:"ipfix",json:"json","jsonml+json":"jsonml","lost+xml":"lostxml","mads+xml":"mads",marc:"mrc","marcxml+xml":"mrcx","mathml+xml":"mathml",mbox:"mbox","mediaservercontrol+xml":"mscml","metalink+xml":"metalink","metalink4+xml":"meta4","mets+xml":"mets","mods+xml":"mods",mp21:["m21","mp21"],mp4:"mp4s","oebps-package+xml":"opf","omdoc+xml":"omdoc",onenote:["onetoc","onetoc2","onetmp","onepkg"],oxps:"oxps","patch-ops-error+xml":"xer","pgp-encrypted":"pgp",pkcs10:"p10","pkcs7-mime":["p7m","p7c"],"pkcs7-signature":"p7s",pkcs8:"p8","pkix-attr-cert":"ac","pkix-crl":"crl","pkix-pkipath":"pkipath",pkixcmp:"pki","pls+xml":"pls","prs.cww":"cww","pskc+xml":"pskcxml","reginfo+xml":"rif","relax-ng-compact-syntax":"rnc","resource-lists+xml":"rl","resource-lists-diff+xml":"rld","rls-services+xml":"rs","rpki-ghostbusters":"gbr","rpki-manifest":"mft","rpki-roa":"roa","rsd+xml":"rsd","sbml+xml":"sbml","scvp-cv-request":"scq","scvp-cv-response":"scs","scvp-vp-request":"spq","scvp-vp-response":"spp",sdp:"sdp","set-payment-initiation":"setpay","set-registration-initiation":"setreg","shf+xml":"shf","sparql-query":"rq","sparql-results+xml":"srx",srgs:"gram","srgs+xml":"grxml","sru+xml":"sru","ssdl+xml":"ssdl","ssml+xml":"ssml","tei+xml":["tei","teicorpus"],"thraud+xml":"tfi","timestamped-data":"tsd","vnd.3gpp.pic-bw-large":"plb","vnd.3gpp.pic-bw-small":"psb","vnd.3gpp.pic-bw-var":"pvb","vnd.3gpp2.tcap":"tcap","vnd.3m.post-it-notes":"pwn","vnd.accpac.simply.aso":"aso","vnd.accpac.simply.imp":"imp","vnd.acucobol":"acu","vnd.acucorp":["atc","acutc"],"vnd.adobe.air-application-installer-package+zip":"air","vnd.adobe.formscentral.fcdt":"fcdt","vnd.adobe.fxp":["fxp","fxpl"],"vnd.adobe.xdp+xml":"xdp","vnd.adobe.xfdf":"xfdf","vnd.ahead.space":"ahead","vnd.airzip.filesecure.azf":"azf","vnd.airzip.filesecure.azs":"azs","vnd.amazon.ebook":"azw","vnd.americandynamics.acc":"acc","vnd.amiga.ami":"ami","vnd.anser-web-certificate-issue-initiation":"cii","vnd.anser-web-funds-transfer-initiation":"fti","vnd.antix.game-component":"atx","vnd.apple.installer+xml":"mpkg","vnd.apple.mpegurl":"m3u8","vnd.aristanetworks.swi":"swi","vnd.astraea-software.iota":"iota","vnd.audiograph":"aep","vnd.blueice.multipass":"mpm","vnd.bmi":"bmi","vnd.businessobjects":"rep","vnd.chemdraw+xml":"cdxml","vnd.chipnuts.karaoke-mmd":"mmd","vnd.claymore":"cla","vnd.cloanto.rp9":"rp9","vnd.clonk.c4group":["c4g","c4d","c4f","c4p","c4u"],"vnd.cluetrust.cartomobile-config":"c11amc","vnd.cluetrust.cartomobile-config-pkg":"c11amz","vnd.commonspace":"csp","vnd.contact.cmsg":"cdbcmsg","vnd.cosmocaller":"cmc","vnd.crick.clicker":"clkx","vnd.crick.clicker.keyboard":"clkk","vnd.crick.clicker.palette":"clkp","vnd.crick.clicker.template":"clkt","vnd.crick.clicker.wordbank":"clkw","vnd.criticaltools.wbs+xml":"wbs","vnd.ctc-posml":"pml","vnd.cups-ppd":"ppd","vnd.curl.car":"car","vnd.curl.pcurl":"pcurl","vnd.dart":"dart","vnd.data-vision.rdz":"rdz","vnd.dece.data":["uvf","uvvf","uvd","uvvd"],"vnd.dece.ttml+xml":["uvt","uvvt"],"vnd.dece.unspecified":["uvx","uvvx"],"vnd.dece.zip":["uvz","uvvz"],"vnd.denovo.fcselayout-link":"fe_launch","vnd.dna":"dna","vnd.dolby.mlp":"mlp","vnd.dpgraph":"dpg","vnd.dreamfactory":"dfac","vnd.ds-keypoint":"kpxx","vnd.dvb.ait":"ait","vnd.dvb.service":"svc","vnd.dynageo":"geo","vnd.ecowin.chart":"mag","vnd.enliven":"nml","vnd.epson.esf":"esf","vnd.epson.msf":"msf","vnd.epson.quickanime":"qam","vnd.epson.salt":"slt","vnd.epson.ssf":"ssf","vnd.eszigno3+xml":["es3","et3"],"vnd.ezpix-album":"ez2","vnd.ezpix-package":"ez3","vnd.fdf":"fdf","vnd.fdsn.mseed":"mseed","vnd.fdsn.seed":["seed","dataless"],"vnd.flographit":"gph","vnd.fluxtime.clip":"ftc","vnd.framemaker":["fm","frame","maker","book"],"vnd.frogans.fnc":"fnc","vnd.frogans.ltf":"ltf","vnd.fsc.weblaunch":"fsc","vnd.fujitsu.oasys":"oas","vnd.fujitsu.oasys2":"oa2","vnd.fujitsu.oasys3":"oa3","vnd.fujitsu.oasysgp":"fg5","vnd.fujitsu.oasysprs":"bh2","vnd.fujixerox.ddd":"ddd","vnd.fujixerox.docuworks":"xdw","vnd.fujixerox.docuworks.binder":"xbd","vnd.fuzzysheet":"fzs","vnd.genomatix.tuxedo":"txd","vnd.geogebra.file":"ggb","vnd.geogebra.tool":"ggt","vnd.geometry-explorer":["gex","gre"],"vnd.geonext":"gxt","vnd.geoplan":"g2w","vnd.geospace":"g3w","vnd.gmx":"gmx","vnd.grafeq":["gqf","gqs"],"vnd.groove-account":"gac","vnd.groove-help":"ghf","vnd.groove-identity-message":"gim","vnd.groove-injector":"grv","vnd.groove-tool-message":"gtm","vnd.groove-tool-template":"tpl","vnd.groove-vcard":"vcg","vnd.hal+xml":"hal","vnd.handheld-entertainment+xml":"zmm","vnd.hbci":"hbci","vnd.hhe.lesson-player":"les","vnd.hp-hpgl":"hpgl","vnd.hp-hpid":"hpid","vnd.hp-hps":"hps","vnd.hp-jlyt":"jlt","vnd.hp-pcl":"pcl","vnd.hp-pclxl":"pclxl","vnd.hydrostatix.sof-data":"sfd-hdstx","vnd.ibm.minipay":"mpy","vnd.ibm.modcap":["afp","listafp","list3820"],"vnd.ibm.rights-management":"irm","vnd.ibm.secure-container":"sc","vnd.iccprofile":["icc","icm"],"vnd.igloader":"igl","vnd.immervision-ivp":"ivp","vnd.immervision-ivu":"ivu","vnd.insors.igm":"igm","vnd.intercon.formnet":["xpw","xpx"],"vnd.intergeo":"i2g","vnd.intu.qbo":"qbo","vnd.intu.qfx":"qfx","vnd.ipunplugged.rcprofile":"rcprofile","vnd.irepository.package+xml":"irp","vnd.is-xpr":"xpr","vnd.isac.fcs":"fcs","vnd.jam":"jam","vnd.jcp.javame.midlet-rms":"rms","vnd.jisp":"jisp","vnd.joost.joda-archive":"joda","vnd.kahootz":["ktz","ktr"],"vnd.kde.karbon":"karbon","vnd.kde.kchart":"chrt","vnd.kde.kformula":"kfo","vnd.kde.kivio":"flw","vnd.kde.kontour":"kon","vnd.kde.kpresenter":["kpr","kpt"],"vnd.kde.kspread":"ksp","vnd.kde.kword":["kwd","kwt"],"vnd.kenameaapp":"htke","vnd.kidspiration":"kia","vnd.kinar":["kne","knp"],"vnd.koan":["skp","skd","skt","skm"],"vnd.kodak-descriptor":"sse","vnd.las.las+xml":"lasxml","vnd.llamagraphics.life-balance.desktop":"lbd","vnd.llamagraphics.life-balance.exchange+xml":"lbe","vnd.lotus-1-2-3":"123","vnd.lotus-approach":"apr","vnd.lotus-freelance":"pre","vnd.lotus-notes":"nsf","vnd.lotus-organizer":"org","vnd.lotus-screencam":"scm","vnd.lotus-wordpro":"lwp","vnd.macports.portpkg":"portpkg","vnd.mcd":"mcd","vnd.medcalcdata":"mc1","vnd.mediastation.cdkey":"cdkey","vnd.mfer":"mwf","vnd.mfmp":"mfm","vnd.micrografx.flo":"flo","vnd.micrografx.igx":"igx","vnd.mif":"mif","vnd.mobius.daf":"daf","vnd.mobius.dis":"dis","vnd.mobius.mbk":"mbk","vnd.mobius.mqy":"mqy","vnd.mobius.msl":"msl","vnd.mobius.plc":"plc","vnd.mobius.txf":"txf","vnd.mophun.application":"mpn","vnd.mophun.certificate":"mpc","vnd.ms-artgalry":"cil","vnd.ms-cab-compressed":"cab","vnd.ms-excel.addin.macroenabled.12":"xlam","vnd.ms-excel.sheet.binary.macroenabled.12":"xlsb","vnd.ms-excel.sheet.macroenabled.12":"xlsm","vnd.ms-excel.template.macroenabled.12":"xltm","vnd.ms-fontobject":"eot","vnd.ms-htmlhelp":"chm","vnd.ms-ims":"ims","vnd.ms-lrm":"lrm","vnd.ms-officetheme":"thmx","vnd.ms-powerpoint.addin.macroenabled.12":"ppam","vnd.ms-powerpoint.presentation.macroenabled.12":"pptm","vnd.ms-powerpoint.slide.macroenabled.12":"sldm","vnd.ms-powerpoint.slideshow.macroenabled.12":"ppsm","vnd.ms-powerpoint.template.macroenabled.12":"potm","vnd.ms-project":["mpp","mpt"],"vnd.ms-word.document.macroenabled.12":"docm","vnd.ms-word.template.macroenabled.12":"dotm","vnd.ms-works":["wps","wks","wcm","wdb"],"vnd.ms-wpl":"wpl","vnd.ms-xpsdocument":"xps","vnd.mseq":"mseq","vnd.musician":"mus","vnd.muvee.style":"msty","vnd.mynfc":"taglet","vnd.neurolanguage.nlu":"nlu","vnd.nitf":["ntf","nitf"],"vnd.noblenet-directory":"nnd","vnd.noblenet-sealer":"nns","vnd.noblenet-web":"nnw","vnd.nokia.n-gage.data":"ngdat","vnd.nokia.n-gage.symbian.install":"n-gage","vnd.nokia.radio-preset":"rpst","vnd.nokia.radio-presets":"rpss","vnd.novadigm.edm":"edm","vnd.novadigm.edx":"edx","vnd.novadigm.ext":"ext","vnd.oasis.opendocument.chart-template":"otc","vnd.oasis.opendocument.formula-template":"odft","vnd.oasis.opendocument.image-template":"oti","vnd.olpc-sugar":"xo","vnd.oma.dd2+xml":"dd2","vnd.openofficeorg.extension":"oxt","vnd.openxmlformats-officedocument.presentationml.slide":"sldx","vnd.osgeo.mapguide.package":"mgp","vnd.osgi.dp":"dp","vnd.osgi.subsystem":"esa","vnd.palm":["pdb","pqa","oprc"],"vnd.pawaafile":"paw","vnd.pg.format":"str","vnd.pg.osasli":"ei6","vnd.picsel":"efif","vnd.pmi.widget":"wg","vnd.pocketlearn":"plf","vnd.powerbuilder6":"pbd","vnd.previewsystems.box":"box","vnd.proteus.magazine":"mgz","vnd.publishare-delta-tree":"qps","vnd.pvi.ptid1":"ptid","vnd.quark.quarkxpress":["qxd","qxt","qwd","qwt","qxl","qxb"],"vnd.realvnc.bed":"bed","vnd.recordare.musicxml":"mxl","vnd.recordare.musicxml+xml":"musicxml","vnd.rig.cryptonote":"cryptonote","vnd.rn-realmedia":"rm","vnd.rn-realmedia-vbr":"rmvb","vnd.route66.link66+xml":"link66","vnd.sailingtracker.track":"st","vnd.seemail":"see","vnd.sema":"sema","vnd.semd":"semd","vnd.semf":"semf","vnd.shana.informed.formdata":"ifm","vnd.shana.informed.formtemplate":"itp","vnd.shana.informed.interchange":"iif","vnd.shana.informed.package":"ipk","vnd.simtech-mindmapper":["twd","twds"],"vnd.smart.teacher":"teacher","vnd.solent.sdkm+xml":["sdkm","sdkd"],"vnd.spotfire.dxp":"dxp","vnd.spotfire.sfs":"sfs","vnd.stepmania.package":"smzip","vnd.stepmania.stepchart":"sm","vnd.sus-calendar":["sus","susp"],"vnd.svd":"svd","vnd.syncml+xml":"xsm","vnd.syncml.dm+wbxml":"bdm","vnd.syncml.dm+xml":"xdm","vnd.tao.intent-module-archive":"tao","vnd.tcpdump.pcap":["pcap","cap","dmp"],"vnd.tmobile-livetv":"tmo","vnd.trid.tpt":"tpt","vnd.triscape.mxs":"mxs","vnd.trueapp":"tra","vnd.ufdl":["ufd","ufdl"],"vnd.uiq.theme":"utz","vnd.umajin":"umj","vnd.unity":"unityweb","vnd.uoml+xml":"uoml","vnd.vcx":"vcx","vnd.visionary":"vis","vnd.vsf":"vsf","vnd.webturbo":"wtb","vnd.wolfram.player":"nbp","vnd.wqd":"wqd","vnd.wt.stf":"stf","vnd.xara":"xar","vnd.xfdl":"xfdl","vnd.yamaha.hv-dic":"hvd","vnd.yamaha.hv-script":"hvs","vnd.yamaha.hv-voice":"hvp","vnd.yamaha.openscoreformat":"osf","vnd.yamaha.openscoreformat.osfpvg+xml":"osfpvg","vnd.yamaha.smaf-audio":"saf","vnd.yamaha.smaf-phrase":"spf","vnd.yellowriver-custom-menu":"cmp","vnd.zul":["zir","zirz"],"vnd.zzazz.deck+xml":"zaz","voicexml+xml":"vxml",widget:"wgt",winhlp:"hlp","wsdl+xml":"wsdl","wspolicy+xml":"wspolicy","x-ace-compressed":"ace","x-authorware-bin":["aab","x32","u32","vox"],"x-authorware-map":"aam","x-authorware-seg":"aas","x-blorb":["blb","blorb"],"x-bzip":"bz","x-bzip2":["bz2","boz"],"x-cfs-compressed":"cfs","x-chat":"chat","x-conference":"nsc","x-dgc-compressed":"dgc","x-dtbncx+xml":"ncx","x-dtbook+xml":"dtb","x-dtbresource+xml":"res","x-eva":"eva","x-font-bdf":"bdf","x-font-ghostscript":"gsf","x-font-linux-psf":"psf","x-font-otf":"otf","x-font-pcf":"pcf","x-font-snf":"snf","x-font-ttf":["ttf","ttc"],"x-font-type1":["pfa","pfb","pfm","afm"],"x-font-woff":"woff","x-freearc":"arc","x-gca-compressed":"gca","x-glulx":"ulx","x-gramps-xml":"gramps","x-install-instructions":"install","x-lzh-compressed":["lzh","lha"],"x-mie":"mie","x-mobipocket-ebook":["prc","mobi"],"x-ms-application":"application","x-ms-shortcut":"lnk","x-ms-xbap":"xbap","x-msbinder":"obd","x-mscardfile":"crd","x-msclip":"clp","x-msdownload":["exe","dll","com","bat","msi"],"x-msmediaview":["mvb","m13","m14"],"x-msmetafile":["wmf","wmz","emf","emz"],"x-msmoney":"mny","x-mspublisher":"pub","x-msschedule":"scd","x-msterminal":"trm","x-mswrite":"wri","x-nzb":"nzb","x-pkcs12":["p12","pfx"],"x-pkcs7-certificates":["p7b","spc"],"x-research-info-systems":"ris","x-silverlight-app":"xap","x-sql":"sql","x-stuffitx":"sitx","x-subrip":"srt","x-t3vm-image":"t3","x-tads":"gam","x-tex":"tex","x-tex-tfm":"tfm","x-tgif":"obj","x-xliff+xml":"xlf","x-xz":"xz","x-zmachine":["z1","z2","z3","z4","z5","z6","z7","z8"],"xaml+xml":"xaml","xcap-diff+xml":"xdf","xenc+xml":"xenc","xml-dtd":"dtd","xop+xml":"xop","xproc+xml":"xpl","xslt+xml":"xslt","xv+xml":["mxml","xhvml","xvml","xvm"],yang:"yang","yin+xml":"yin",envoy:"evy",fractals:"fif","internet-property-stream":"acx",olescript:"axs","vnd.ms-outlook":"msg","vnd.ms-pkicertstore":"sst","x-compress":"z","x-compressed":"tgz","x-gzip":"gz","x-perfmon":["pma","pmc","pml","pmr","pmw"],"x-pkcs7-mime":["p7c","p7m"],"ynd.ms-pkipko":"pko"},audio:{amr:"amr","amr-wb":"awb",annodex:"axa",basic:["au","snd"],flac:"flac",midi:["mid","midi","kar","rmi"],mpeg:["mpga","mpega","mp2","mp3","m4a","mp2a","m2a","m3a"],mpegurl:"m3u",ogg:["oga","ogg","spx"],"prs.sid":"sid","x-aiff":["aif","aiff","aifc"],"x-gsm":"gsm","x-ms-wma":"wma","x-ms-wax":"wax","x-pn-realaudio":"ram","x-realaudio":"ra","x-sd2":"sd2","x-wav":"wav",adpcm:"adp",mp4:"mp4a",s3m:"s3m",silk:"sil","vnd.dece.audio":["uva","uvva"],"vnd.digital-winds":"eol","vnd.dra":"dra","vnd.dts":"dts","vnd.dts.hd":"dtshd","vnd.lucent.voice":"lvp","vnd.ms-playready.media.pya":"pya","vnd.nuera.ecelp4800":"ecelp4800","vnd.nuera.ecelp7470":"ecelp7470","vnd.nuera.ecelp9600":"ecelp9600","vnd.rip":"rip",webm:"weba","x-aac":"aac","x-caf":"caf","x-matroska":"mka","x-pn-realaudio-plugin":"rmp",xm:"xm",mid:["mid","rmi"]},chemical:{"x-alchemy":"alc","x-cache":["cac","cache"],"x-cache-csf":"csf","x-cactvs-binary":["cbin","cascii","ctab"],"x-cdx":"cdx","x-chem3d":"c3d","x-cif":"cif","x-cmdf":"cmdf","x-cml":"cml","x-compass":"cpa","x-crossfire":"bsd","x-csml":["csml","csm"],"x-ctx":"ctx","x-cxf":["cxf","cef"],"x-embl-dl-nucleotide":["emb","embl"],"x-gamess-input":["inp","gam","gamin"],"x-gaussian-checkpoint":["fch","fchk"],"x-gaussian-cube":"cub","x-gaussian-input":["gau","gjc","gjf"],"x-gaussian-log":"gal","x-gcg8-sequence":"gcg","x-genbank":"gen","x-hin":"hin","x-isostar":["istr","ist"],"x-jcamp-dx":["jdx","dx"],"x-kinemage":"kin","x-macmolecule":"mcm","x-macromodel-input":["mmd","mmod"],"x-mdl-molfile":"mol","x-mdl-rdfile":"rd","x-mdl-rxnfile":"rxn","x-mdl-sdfile":["sd","sdf"],"x-mdl-tgf":"tgf","x-mmcif":"mcif","x-mol2":"mol2","x-molconn-Z":"b","x-mopac-graph":"gpt","x-mopac-input":["mop","mopcrt","mpc","zmt"],"x-mopac-out":"moo","x-ncbi-asn1":"asn","x-ncbi-asn1-ascii":["prt","ent"],"x-ncbi-asn1-binary":["val","aso"],"x-pdb":["pdb","ent"],"x-rosdal":"ros","x-swissprot":"sw","x-vamas-iso14976":"vms","x-vmd":"vmd","x-xtel":"xtel","x-xyz":"xyz"},image:{gif:"gif",ief:"ief",jpeg:["jpeg","jpg","jpe"],pcx:"pcx",png:"png","svg+xml":["svg","svgz"],tiff:["tiff","tif"],"vnd.djvu":["djvu","djv"],"vnd.wap.wbmp":"wbmp","x-canon-cr2":"cr2","x-canon-crw":"crw","x-cmu-raster":"ras","x-coreldraw":"cdr","x-coreldrawpattern":"pat","x-coreldrawtemplate":"cdt","x-corelphotopaint":"cpt","x-epson-erf":"erf","x-icon":"ico","x-jg":"art","x-jng":"jng","x-nikon-nef":"nef","x-olympus-orf":"orf","x-photoshop":"psd","x-portable-anymap":"pnm","x-portable-bitmap":"pbm","x-portable-graymap":"pgm","x-portable-pixmap":"ppm","x-rgb":"rgb","x-xbitmap":"xbm","x-xpixmap":"xpm","x-xwindowdump":"xwd",bmp:"bmp",cgm:"cgm",g3fax:"g3",ktx:"ktx","prs.btif":"btif",sgi:"sgi","vnd.dece.graphic":["uvi","uvvi","uvg","uvvg"],"vnd.dwg":"dwg","vnd.dxf":"dxf","vnd.fastbidsheet":"fbs","vnd.fpx":"fpx","vnd.fst":"fst","vnd.fujixerox.edmics-mmr":"mmr","vnd.fujixerox.edmics-rlc":"rlc","vnd.ms-modi":"mdi","vnd.ms-photo":"wdp","vnd.net-fpx":"npx","vnd.xiff":"xif",webp:"webp","x-3ds":"3ds","x-cmx":"cmx","x-freehand":["fh","fhc","fh4","fh5","fh7"],"x-pict":["pic","pct"],"x-tga":"tga","cis-cod":"cod",pipeg:"jfif"},message:{rfc822:["eml","mime","mht","mhtml","nws"]},model:{iges:["igs","iges"],mesh:["msh","mesh","silo"],vrml:["wrl","vrml"],"x3d+vrml":["x3dv","x3dvz"],"x3d+xml":["x3d","x3dz"],"x3d+binary":["x3db","x3dbz"],"vnd.collada+xml":"dae","vnd.dwf":"dwf","vnd.gdl":"gdl","vnd.gtw":"gtw","vnd.mts":"mts","vnd.vtu":"vtu"},text:{"cache-manifest":["manifest","appcache"],calendar:["ics","icz","ifb"],css:"css",csv:"csv",h323:"323",html:["html","htm","shtml","stm"],iuls:"uls",mathml:"mml",plain:["txt","text","brf","conf","def","list","log","in","bas"],richtext:"rtx",scriptlet:["sct","wsc"],texmacs:["tm","ts"],"tab-separated-values":"tsv","vnd.sun.j2me.app-descriptor":"jad","vnd.wap.wml":"wml","vnd.wap.wmlscript":"wmls","x-bibtex":"bib","x-boo":"boo","x-c++hdr":["h++","hpp","hxx","hh"],"x-c++src":["c++","cpp","cxx","cc"],"x-component":"htc","x-dsrc":"d","x-diff":["diff","patch"],"x-haskell":"hs","x-java":"java","x-literate-haskell":"lhs","x-moc":"moc","x-pascal":["p","pas"],"x-pcs-gcd":"gcd","x-perl":["pl","pm"],"x-python":"py","x-scala":"scala","x-setext":"etx","x-tcl":["tcl","tk"],"x-tex":["tex","ltx","sty","cls"],"x-vcalendar":"vcs","x-vcard":"vcf",n3:"n3","prs.lines.tag":"dsc",sgml:["sgml","sgm"],troff:["t","tr","roff","man","me","ms"],turtle:"ttl","uri-list":["uri","uris","urls"],vcard:"vcard","vnd.curl":"curl","vnd.curl.dcurl":"dcurl","vnd.curl.scurl":"scurl","vnd.curl.mcurl":"mcurl","vnd.dvb.subtitle":"sub","vnd.fly":"fly","vnd.fmi.flexstor":"flx","vnd.graphviz":"gv","vnd.in3d.3dml":"3dml","vnd.in3d.spot":"spot","x-asm":["s","asm"],"x-c":["c","cc","cxx","cpp","h","hh","dic"],"x-fortran":["f","for","f77","f90"],"x-opml":"opml","x-nfo":"nfo","x-sfv":"sfv","x-uuencode":"uu",webviewhtml:"htt"},video:{avif:".avif","3gpp":"3gp",annodex:"axv",dl:"dl",dv:["dif","dv"],fli:"fli",gl:"gl",mpeg:["mpeg","mpg","mpe","m1v","m2v","mp2","mpa","mpv2"],mp4:["mp4","mp4v","mpg4"],quicktime:["qt","mov"],ogg:"ogv","vnd.mpegurl":["mxu","m4u"],"x-flv":"flv","x-la-asf":["lsf","lsx"],"x-mng":"mng","x-ms-asf":["asf","asx","asr"],"x-ms-wm":"wm","x-ms-wmv":"wmv","x-ms-wmx":"wmx","x-ms-wvx":"wvx","x-msvideo":"avi","x-sgi-movie":"movie","x-matroska":["mpv","mkv","mk3d","mks"],"3gpp2":"3g2",h261:"h261",h263:"h263",h264:"h264",jpeg:"jpgv",jpm:["jpm","jpgm"],mj2:["mj2","mjp2"],"vnd.dece.hd":["uvh","uvvh"],"vnd.dece.mobile":["uvm","uvvm"],"vnd.dece.pd":["uvp","uvvp"],"vnd.dece.sd":["uvs","uvvs"],"vnd.dece.video":["uvv","uvvv"],"vnd.dvb.file":"dvb","vnd.fvt":"fvt","vnd.ms-playready.media.pyv":"pyv","vnd.uvvu.mp4":["uvu","uvvu"],"vnd.vivo":"viv",webm:"webm","x-f4v":"f4v","x-m4v":"m4v","x-ms-vob":"vob","x-smv":"smv"},"x-conference":{"x-cooltalk":"ice"},"x-world":{"x-vrml":["vrm","vrml","wrl","flr","wrz","xaf","xof"]}},Yt=(()=>{const e={};for(let t in Kt)if(Kt.hasOwnProperty(t))for(let n in Kt[t])if(Kt[t].hasOwnProperty(n)){const i=Kt[t][n];if("string"==typeof i)e[i]=t+"/"+n;else for(let r=0;r({Deflate:It(e.Deflate,t.deflate),Inflate:It(e.Inflate,t.inflate)}),Object.defineProperty(e,"__esModule",{value:!0})})); diff --git a/dist/zip-fs.js b/dist/zip-fs.js index a927e163..2cfe1e51 100644 --- a/dist/zip-fs.js +++ b/dist/zip-fs.js @@ -4,6 +4,4212 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zip = {})); }(this, (function (exports) { 'use strict'; + /* + Copyright (c) 2021 Gildas Lormeau. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + // Global + + const MAX_BITS = 15; + const D_CODES = 30; + const BL_CODES = 19; + + const LENGTH_CODES = 29; + const LITERALS = 256; + const L_CODES = (LITERALS + 1 + LENGTH_CODES); + const HEAP_SIZE = (2 * L_CODES + 1); + + const END_BLOCK = 256; + + // Bit length codes must not exceed MAX_BL_BITS bits + const MAX_BL_BITS = 7; + + // repeat previous bit length 3-6 times (2 bits of repeat count) + const REP_3_6 = 16; + + // repeat a zero length 3-10 times (3 bits of repeat count) + const REPZ_3_10 = 17; + + // repeat a zero length 11-138 times (7 bits of repeat count) + const REPZ_11_138 = 18; + + // The lengths of the bit length codes are sent in order of decreasing + // probability, to avoid transmitting the lengths for unused bit + // length codes. + + const Buf_size = 8 * 2; + + // JZlib version : "1.0.2" + const Z_DEFAULT_COMPRESSION = -1; + + // compression strategy + const Z_FILTERED = 1; + const Z_HUFFMAN_ONLY = 2; + const Z_DEFAULT_STRATEGY = 0; + + const Z_NO_FLUSH = 0; + const Z_PARTIAL_FLUSH = 1; + const Z_FULL_FLUSH = 3; + const Z_FINISH = 4; + + const Z_OK = 0; + const Z_STREAM_END = 1; + const Z_NEED_DICT = 2; + const Z_STREAM_ERROR = -2; + const Z_DATA_ERROR = -3; + const Z_BUF_ERROR = -5; + + // Tree + + // see definition of array dist_code below + const _dist_code = [0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, + 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]; + + function Tree() { + const that = this; + + // dyn_tree; // the dynamic tree + // max_code; // largest code with non zero frequency + // stat_desc; // the corresponding static tree + + // Compute the optimal bit lengths for a tree and update the total bit + // length + // for the current block. + // IN assertion: the fields freq and dad are set, heap[heap_max] and + // above are the tree nodes sorted by increasing frequency. + // OUT assertions: the field len is set to the optimal bit length, the + // array bl_count contains the frequencies for each bit length. + // The length opt_len is updated; static_len is also updated if stree is + // not null. + function gen_bitlen(s) { + const tree = that.dyn_tree; + const stree = that.stat_desc.static_tree; + const extra = that.stat_desc.extra_bits; + const base = that.stat_desc.extra_base; + const max_length = that.stat_desc.max_length; + let h; // heap index + let n, m; // iterate over the tree elements + let bits; // bit length + let xbits; // extra bits + let f; // frequency + let overflow = 0; // number of elements with bit length too large + + for (bits = 0; bits <= MAX_BITS; bits++) + s.bl_count[bits] = 0; + + // In a first pass, compute the optimal bit lengths (which may + // overflow in the case of the bit length tree). + tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap + + for (h = s.heap_max + 1; h < HEAP_SIZE; h++) { + n = s.heap[h]; + bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; + if (bits > max_length) { + bits = max_length; + overflow++; + } + tree[n * 2 + 1] = bits; + // We overwrite tree[n*2+1] which is no longer needed + + if (n > that.max_code) + continue; // not a leaf node + + s.bl_count[bits]++; + xbits = 0; + if (n >= base) + xbits = extra[n - base]; + f = tree[n * 2]; + s.opt_len += f * (bits + xbits); + if (stree) + s.static_len += f * (stree[n * 2 + 1] + xbits); + } + if (overflow === 0) + return; + + // This happens for example on obj2 and pic of the Calgary corpus + // Find the first bit length which could increase: + do { + bits = max_length - 1; + while (s.bl_count[bits] === 0) + bits--; + s.bl_count[bits]--; // move one leaf down the tree + s.bl_count[bits + 1] += 2; // move one overflow item as its brother + s.bl_count[max_length]--; + // The brother of the overflow item also moves one step up, + // but this does not affect bl_count[max_length] + overflow -= 2; + } while (overflow > 0); + + for (bits = max_length; bits !== 0; bits--) { + n = s.bl_count[bits]; + while (n !== 0) { + m = s.heap[--h]; + if (m > that.max_code) + continue; + if (tree[m * 2 + 1] != bits) { + s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2]; + tree[m * 2 + 1] = bits; + } + n--; + } + } + } + + // Reverse the first len bits of a code, using straightforward code (a + // faster + // method would use a table) + // IN assertion: 1 <= len <= 15 + function bi_reverse(code, // the value to invert + len // its bit length + ) { + let res = 0; + do { + res |= code & 1; + code >>>= 1; + res <<= 1; + } while (--len > 0); + return res >>> 1; + } + + // Generate the codes for a given tree and bit counts (which need not be + // optimal). + // IN assertion: the array bl_count contains the bit length statistics for + // the given tree and the field len is set for all tree elements. + // OUT assertion: the field code is set for all tree elements of non + // zero code length. + function gen_codes(tree, // the tree to decorate + max_code, // largest code with non zero frequency + bl_count // number of codes at each bit length + ) { + const next_code = []; // next code value for each + // bit length + let code = 0; // running code value + let bits; // bit index + let n; // code index + let len; + + // The distribution counts are first used to generate the code values + // without bit reversal. + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = ((code + bl_count[bits - 1]) << 1); + } + + // Check that the bit counts in bl_count are consistent. The last code + // must be all ones. + // Assert (code + bl_count[MAX_BITS]-1 == (1<= 1; n--) + s.pqdownheap(tree, n); + + // Construct the Huffman tree by repeatedly combining the least two + // frequent nodes. + + node = elems; // next internal node of the tree + do { + // n = node of least frequency + n = s.heap[1]; + s.heap[1] = s.heap[s.heap_len--]; + s.pqdownheap(tree, 1); + m = s.heap[1]; // m = node of next least frequency + + s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency + s.heap[--s.heap_max] = m; + + // Create a new node father of n and m + tree[node * 2] = (tree[n * 2] + tree[m * 2]); + s.depth[node] = Math.max(s.depth[n], s.depth[m]) + 1; + tree[n * 2 + 1] = tree[m * 2 + 1] = node; + + // and insert the new node in the heap + s.heap[1] = node++; + s.pqdownheap(tree, 1); + } while (s.heap_len >= 2); + + s.heap[--s.heap_max] = s.heap[1]; + + // At this point, the fields freq and dad are set. We can now + // generate the bit lengths. + + gen_bitlen(s); + + // The field len is now set, we can generate the bit codes + gen_codes(tree, that.max_code, s.bl_count); + }; + + } + + Tree._length_code = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, + 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28]; + + Tree.base_length = [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]; + + Tree.base_dist = [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]; + + // Mapping from a distance to a distance code. dist is the distance - 1 and + // must not have side effects. _dist_code[256] and _dist_code[257] are never + // used. + Tree.d_code = function (dist) { + return ((dist) < 256 ? _dist_code[dist] : _dist_code[256 + ((dist) >>> 7)]); + }; + + // extra bits for each length code + Tree.extra_lbits = [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]; + + // extra bits for each distance code + Tree.extra_dbits = [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]; + + // extra bits for each bit length code + Tree.extra_blbits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]; + + Tree.bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; + + // StaticTree + + function StaticTree(static_tree, extra_bits, extra_base, elems, max_length) { + const that = this; + that.static_tree = static_tree; + that.extra_bits = extra_bits; + that.extra_base = extra_base; + that.elems = elems; + that.max_length = max_length; + } + + StaticTree.static_ltree = [12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, + 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, + 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, + 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, + 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, + 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, + 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, + 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, + 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, + 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, + 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, + 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, + 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, + 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7, 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, + 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, + 99, 8, 227, 8]; + + StaticTree.static_dtree = [0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, + 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5]; + + StaticTree.static_l_desc = new StaticTree(StaticTree.static_ltree, Tree.extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); + + StaticTree.static_d_desc = new StaticTree(StaticTree.static_dtree, Tree.extra_dbits, 0, D_CODES, MAX_BITS); + + StaticTree.static_bl_desc = new StaticTree(null, Tree.extra_blbits, 0, BL_CODES, MAX_BL_BITS); + + // Deflate + + const MAX_MEM_LEVEL = 9; + const DEF_MEM_LEVEL = 8; + + function Config(good_length, max_lazy, nice_length, max_chain, func) { + const that = this; + that.good_length = good_length; + that.max_lazy = max_lazy; + that.nice_length = nice_length; + that.max_chain = max_chain; + that.func = func; + } + + const STORED = 0; + const FAST = 1; + const SLOW = 2; + const config_table = [ + new Config(0, 0, 0, 0, STORED), + new Config(4, 4, 8, 4, FAST), + new Config(4, 5, 16, 8, FAST), + new Config(4, 6, 32, 32, FAST), + new Config(4, 4, 16, 16, SLOW), + new Config(8, 16, 32, 32, SLOW), + new Config(8, 16, 128, 128, SLOW), + new Config(8, 32, 128, 256, SLOW), + new Config(32, 128, 258, 1024, SLOW), + new Config(32, 258, 258, 4096, SLOW) + ]; + + const z_errmsg = ["need dictionary", // Z_NEED_DICT + // 2 + "stream end", // Z_STREAM_END 1 + "", // Z_OK 0 + "", // Z_ERRNO (-1) + "stream error", // Z_STREAM_ERROR (-2) + "data error", // Z_DATA_ERROR (-3) + "", // Z_MEM_ERROR (-4) + "buffer error", // Z_BUF_ERROR (-5) + "",// Z_VERSION_ERROR (-6) + ""]; + + // block not completed, need more input or more output + const NeedMore = 0; + + // block flush performed + const BlockDone = 1; + + // finish started, need only more output at next deflate + const FinishStarted = 2; + + // finish done, accept no more input or output + const FinishDone = 3; + + // preset dictionary flag in zlib header + const PRESET_DICT = 0x20; + + const INIT_STATE = 42; + const BUSY_STATE = 113; + const FINISH_STATE = 666; + + // The deflate compression method + const Z_DEFLATED = 8; + + const STORED_BLOCK = 0; + const STATIC_TREES = 1; + const DYN_TREES = 2; + + const MIN_MATCH = 3; + const MAX_MATCH = 258; + const MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); + + function smaller(tree, n, m, depth) { + const tn2 = tree[n * 2]; + const tm2 = tree[m * 2]; + return (tn2 < tm2 || (tn2 == tm2 && depth[n] <= depth[m])); + } + + function Deflate() { + + const that = this; + let strm; // pointer back to this zlib stream + let status; // as the name implies + // pending_buf; // output still pending + let pending_buf_size; // size of pending_buf + // pending_out; // next pending byte to output to the stream + // pending; // nb of bytes in the pending buffer + let last_flush; // value of flush param for previous deflate call + + let w_size; // LZ77 window size (32K by default) + let w_bits; // log2(w_size) (8..16) + let w_mask; // w_size - 1 + + let window; + // Sliding window. Input bytes are read into the second half of the window, + // and move to the first half later to keep a dictionary of at least wSize + // bytes. With this organization, matches are limited to a distance of + // wSize-MAX_MATCH bytes, but this ensures that IO is always + // performed with a length multiple of the block size. Also, it limits + // the window size to 64K, which is quite useful on MSDOS. + // To do: use the user input buffer as sliding window. + + let window_size; + // Actual size of window: 2*wSize, except when the user input buffer + // is directly used as sliding window. + + let prev; + // Link to older string with same hash index. To limit the size of this + // array to 64K, this link is maintained only for the last 32K strings. + // An index in this array is thus a window index modulo 32K. + + let head; // Heads of the hash chains or NIL. + + let ins_h; // hash index of string to be inserted + let hash_size; // number of elements in hash table + let hash_bits; // log2(hash_size) + let hash_mask; // hash_size-1 + + // Number of bits by which ins_h must be shifted at each input + // step. It must be such that after MIN_MATCH steps, the oldest + // byte no longer takes part in the hash key, that is: + // hash_shift * MIN_MATCH >= hash_bits + let hash_shift; + + // Window position at the beginning of the current output block. Gets + // negative when the window is moved backwards. + + let block_start; + + let match_length; // length of best match + let prev_match; // previous match + let match_available; // set if previous match exists + let strstart; // start of string to insert + let match_start; // start of matching string + let lookahead; // number of valid bytes ahead in window + + // Length of the best match at previous step. Matches not greater than this + // are discarded. This is used in the lazy match evaluation. + let prev_length; + + // To speed up deflation, hash chains are never searched beyond this + // length. A higher limit improves compression ratio but degrades the speed. + let max_chain_length; + + // Attempt to find a better match only when the current match is strictly + // smaller than this value. This mechanism is used only for compression + // levels >= 4. + let max_lazy_match; + + // Insert new strings in the hash table only if the match length is not + // greater than this length. This saves time but degrades compression. + // max_insert_length is used only for compression levels <= 3. + + let level; // compression level (1..9) + let strategy; // favor or force Huffman coding + + // Use a faster search when the previous match is longer than this + let good_match; + + // Stop searching when current match exceeds this + let nice_match; + + let dyn_ltree; // literal and length tree + let dyn_dtree; // distance tree + let bl_tree; // Huffman tree for bit lengths + + const l_desc = new Tree(); // desc for literal tree + const d_desc = new Tree(); // desc for distance tree + const bl_desc = new Tree(); // desc for bit length tree + + // that.heap_len; // number of elements in the heap + // that.heap_max; // element of largest frequency + // The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + // The same heap array is used to build all trees. + + // Depth of each subtree used as tie breaker for trees of equal frequency + that.depth = []; + + let l_buf; // index for literals or lengths */ + + // Size of match buffer for literals/lengths. There are 4 reasons for + // limiting lit_bufsize to 64K: + // - frequencies can be kept in 16 bit counters + // - if compression is not successful for the first block, all input + // data is still in the window so we can still emit a stored block even + // when input comes from standard input. (This can also be done for + // all blocks if lit_bufsize is not greater than 32K.) + // - if compression is not successful for a file smaller than 64K, we can + // even emit a stored file instead of a stored block (saving 5 bytes). + // This is applicable only for zip (not gzip or zlib). + // - creating new Huffman trees less frequently may not provide fast + // adaptation to changes in the input data statistics. (Take for + // example a binary file with poorly compressible code followed by + // a highly compressible string table.) Smaller buffer sizes give + // fast adaptation but have of course the overhead of transmitting + // trees more frequently. + // - I can't count above 4 + let lit_bufsize; + + let last_lit; // running index in l_buf + + // Buffer for distances. To simplify the code, d_buf and l_buf have + // the same number of elements. To use different lengths, an extra flag + // array would be necessary. + + let d_buf; // index of pendig_buf + + // that.opt_len; // bit length of current block with optimal trees + // that.static_len; // bit length of current block with static trees + let matches; // number of string matches in current block + let last_eob_len; // bit length of EOB code for last block + + // Output buffer. bits are inserted starting at the bottom (least + // significant bits). + let bi_buf; + + // Number of valid bits in bi_buf. All bits above the last valid bit + // are always zero. + let bi_valid; + + // number of codes at each bit length for an optimal tree + that.bl_count = []; + + // heap used to build the Huffman trees + that.heap = []; + + dyn_ltree = []; + dyn_dtree = []; + bl_tree = []; + + function lm_init() { + window_size = 2 * w_size; + + head[hash_size - 1] = 0; + for (let i = 0; i < hash_size - 1; i++) { + head[i] = 0; + } + + // Set the default configuration parameters: + max_lazy_match = config_table[level].max_lazy; + good_match = config_table[level].good_length; + nice_match = config_table[level].nice_length; + max_chain_length = config_table[level].max_chain; + + strstart = 0; + block_start = 0; + lookahead = 0; + match_length = prev_length = MIN_MATCH - 1; + match_available = 0; + ins_h = 0; + } + + function init_block() { + let i; + // Initialize the trees. + for (i = 0; i < L_CODES; i++) + dyn_ltree[i * 2] = 0; + for (i = 0; i < D_CODES; i++) + dyn_dtree[i * 2] = 0; + for (i = 0; i < BL_CODES; i++) + bl_tree[i * 2] = 0; + + dyn_ltree[END_BLOCK * 2] = 1; + that.opt_len = that.static_len = 0; + last_lit = matches = 0; + } + + // Initialize the tree data structures for a new zlib stream. + function tr_init() { + + l_desc.dyn_tree = dyn_ltree; + l_desc.stat_desc = StaticTree.static_l_desc; + + d_desc.dyn_tree = dyn_dtree; + d_desc.stat_desc = StaticTree.static_d_desc; + + bl_desc.dyn_tree = bl_tree; + bl_desc.stat_desc = StaticTree.static_bl_desc; + + bi_buf = 0; + bi_valid = 0; + last_eob_len = 8; // enough lookahead for inflate + + // Initialize the first block of the first file: + init_block(); + } + + // Restore the heap property by moving down the tree starting at node k, + // exchanging a node with the smallest of its two sons if necessary, + // stopping + // when the heap property is re-established (each father smaller than its + // two sons). + that.pqdownheap = function (tree, // the tree to restore + k // node to move down + ) { + const heap = that.heap; + const v = heap[k]; + let j = k << 1; // left son of k + while (j <= that.heap_len) { + // Set j to the smallest of the two sons: + if (j < that.heap_len && smaller(tree, heap[j + 1], heap[j], that.depth)) { + j++; + } + // Exit if v is smaller than both sons + if (smaller(tree, v, heap[j], that.depth)) + break; + + // Exchange v with the smallest son + heap[k] = heap[j]; + k = j; + // And continue down the tree, setting j to the left son of k + j <<= 1; + } + heap[k] = v; + }; + + // Scan a literal or distance tree to determine the frequencies of the codes + // in the bit length tree. + function scan_tree(tree,// the tree to be scanned + max_code // and its largest code of non zero frequency + ) { + let prevlen = -1; // last emitted length + let curlen; // length of current code + let nextlen = tree[0 * 2 + 1]; // length of next code + let count = 0; // repeat count of the current code + let max_count = 7; // max repeat count + let min_count = 4; // min repeat count + + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + tree[(max_code + 1) * 2 + 1] = 0xffff; // guard + + for (let n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[(n + 1) * 2 + 1]; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + bl_tree[curlen * 2] += count; + } else if (curlen !== 0) { + if (curlen != prevlen) + bl_tree[curlen * 2]++; + bl_tree[REP_3_6 * 2]++; + } else if (count <= 10) { + bl_tree[REPZ_3_10 * 2]++; + } else { + bl_tree[REPZ_11_138 * 2]++; + } + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } else if (curlen == nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; + } + } + } + + // Construct the Huffman tree for the bit lengths and return the index in + // bl_order of the last bit length code to send. + function build_bl_tree() { + let max_blindex; // index of last bit length code of non zero freq + + // Determine the bit length frequencies for literal and distance trees + scan_tree(dyn_ltree, l_desc.max_code); + scan_tree(dyn_dtree, d_desc.max_code); + + // Build the bit length tree: + bl_desc.build_tree(that); + // opt_len now includes the length of the tree representations, except + // the lengths of the bit lengths codes and the 5+5+4 bits for the + // counts. + + // Determine the number of bit length codes to send. The pkzip format + // requires that at least 4 bit length codes be sent. (appnote.txt says + // 3 but the actual value used is 4.) + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { + if (bl_tree[Tree.bl_order[max_blindex] * 2 + 1] !== 0) + break; + } + // Update opt_len to include the bit length tree and counts + that.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; + + return max_blindex; + } + + // Output a byte on the stream. + // IN assertion: there is enough room in pending_buf. + function put_byte(p) { + that.pending_buf[that.pending++] = p; + } + + function put_short(w) { + put_byte(w & 0xff); + put_byte((w >>> 8) & 0xff); + } + + function putShortMSB(b) { + put_byte((b >> 8) & 0xff); + put_byte((b & 0xff) & 0xff); + } + + function send_bits(value, length) { + let val; + const len = length; + if (bi_valid > Buf_size - len) { + val = value; + // bi_buf |= (val << bi_valid); + bi_buf |= ((val << bi_valid) & 0xffff); + put_short(bi_buf); + bi_buf = val >>> (Buf_size - bi_valid); + bi_valid += len - Buf_size; + } else { + // bi_buf |= (value) << bi_valid; + bi_buf |= (((value) << bi_valid) & 0xffff); + bi_valid += len; + } + } + + function send_code(c, tree) { + const c2 = c * 2; + send_bits(tree[c2] & 0xffff, tree[c2 + 1] & 0xffff); + } + + // Send a literal or distance tree in compressed form, using the codes in + // bl_tree. + function send_tree(tree,// the tree to be sent + max_code // and its largest code of non zero frequency + ) { + let n; // iterates over all tree elements + let prevlen = -1; // last emitted length + let curlen; // length of current code + let nextlen = tree[0 * 2 + 1]; // length of next code + let count = 0; // repeat count of the current code + let max_count = 7; // max repeat count + let min_count = 4; // min repeat count + + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[(n + 1) * 2 + 1]; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { + send_code(curlen, bl_tree); + } while (--count !== 0); + } else if (curlen !== 0) { + if (curlen != prevlen) { + send_code(curlen, bl_tree); + count--; + } + send_code(REP_3_6, bl_tree); + send_bits(count - 3, 2); + } else if (count <= 10) { + send_code(REPZ_3_10, bl_tree); + send_bits(count - 3, 3); + } else { + send_code(REPZ_11_138, bl_tree); + send_bits(count - 11, 7); + } + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } else if (curlen == nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; + } + } + } + + // Send the header for a block using dynamic Huffman trees: the counts, the + // lengths of the bit length codes, the literal tree and the distance tree. + // IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + function send_all_trees(lcodes, dcodes, blcodes) { + let rank; // index in bl_order + + send_bits(lcodes - 257, 5); // not +255 as stated in appnote.txt + send_bits(dcodes - 1, 5); + send_bits(blcodes - 4, 4); // not -3 as stated in appnote.txt + for (rank = 0; rank < blcodes; rank++) { + send_bits(bl_tree[Tree.bl_order[rank] * 2 + 1], 3); + } + send_tree(dyn_ltree, lcodes - 1); // literal tree + send_tree(dyn_dtree, dcodes - 1); // distance tree + } + + // Flush the bit buffer, keeping at most 7 bits in it. + function bi_flush() { + if (bi_valid == 16) { + put_short(bi_buf); + bi_buf = 0; + bi_valid = 0; + } else if (bi_valid >= 8) { + put_byte(bi_buf & 0xff); + bi_buf >>>= 8; + bi_valid -= 8; + } + } + + // Send one empty static block to give enough lookahead for inflate. + // This takes 10 bits, of which 7 may remain in the bit buffer. + // The current inflate code requires 9 bits of lookahead. If the + // last two codes for the previous block (real code plus EOB) were coded + // on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode + // the last real code. In this case we send two empty static blocks instead + // of one. (There are no problems if the previous block is stored or fixed.) + // To simplify the code, we assume the worst case of last real code encoded + // on one bit only. + function _tr_align() { + send_bits(STATIC_TREES << 1, 3); + send_code(END_BLOCK, StaticTree.static_ltree); + + bi_flush(); + + // Of the 10 bits for the empty block, we have already sent + // (10 - bi_valid) bits. The lookahead for the last real code (before + // the EOB of the previous block) was thus at least one plus the length + // of the EOB plus what we have just sent of the empty static block. + if (1 + last_eob_len + 10 - bi_valid < 9) { + send_bits(STATIC_TREES << 1, 3); + send_code(END_BLOCK, StaticTree.static_ltree); + bi_flush(); + } + last_eob_len = 7; + } + + // Save the match info and tally the frequency counts. Return true if + // the current block must be flushed. + function _tr_tally(dist, // distance of matched string + lc // match length-MIN_MATCH or unmatched char (if dist==0) + ) { + let out_length, in_length, dcode; + that.pending_buf[d_buf + last_lit * 2] = (dist >>> 8) & 0xff; + that.pending_buf[d_buf + last_lit * 2 + 1] = dist & 0xff; + + that.pending_buf[l_buf + last_lit] = lc & 0xff; + last_lit++; + + if (dist === 0) { + // lc is the unmatched char + dyn_ltree[lc * 2]++; + } else { + matches++; + // Here, lc is the match length - MIN_MATCH + dist--; // dist = match distance - 1 + dyn_ltree[(Tree._length_code[lc] + LITERALS + 1) * 2]++; + dyn_dtree[Tree.d_code(dist) * 2]++; + } + + if ((last_lit & 0x1fff) === 0 && level > 2) { + // Compute an upper bound for the compressed length + out_length = last_lit * 8; + in_length = strstart - block_start; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += dyn_dtree[dcode * 2] * (5 + Tree.extra_dbits[dcode]); + } + out_length >>>= 3; + if ((matches < Math.floor(last_lit / 2)) && out_length < Math.floor(in_length / 2)) + return true; + } + + return (last_lit == lit_bufsize - 1); + // We avoid equality with lit_bufsize because of wraparound at 64K + // on 16 bit machines and because stored blocks are restricted to + // 64K-1 bytes. + } + + // Send the block data compressed using the given Huffman trees + function compress_block(ltree, dtree) { + let dist; // distance of matched string + let lc; // match length or unmatched char (if dist === 0) + let lx = 0; // running index in l_buf + let code; // the code to send + let extra; // number of extra bits to send + + if (last_lit !== 0) { + do { + dist = ((that.pending_buf[d_buf + lx * 2] << 8) & 0xff00) | (that.pending_buf[d_buf + lx * 2 + 1] & 0xff); + lc = (that.pending_buf[l_buf + lx]) & 0xff; + lx++; + + if (dist === 0) { + send_code(lc, ltree); // send a literal byte + } else { + // Here, lc is the match length - MIN_MATCH + code = Tree._length_code[lc]; + + send_code(code + LITERALS + 1, ltree); // send the length + // code + extra = Tree.extra_lbits[code]; + if (extra !== 0) { + lc -= Tree.base_length[code]; + send_bits(lc, extra); // send the extra length bits + } + dist--; // dist is now the match distance - 1 + code = Tree.d_code(dist); + + send_code(code, dtree); // send the distance code + extra = Tree.extra_dbits[code]; + if (extra !== 0) { + dist -= Tree.base_dist[code]; + send_bits(dist, extra); // send the extra distance bits + } + } // literal or match pair ? + + // Check that the overlay between pending_buf and d_buf+l_buf is + // ok: + } while (lx < last_lit); + } + + send_code(END_BLOCK, ltree); + last_eob_len = ltree[END_BLOCK * 2 + 1]; + } + + // Flush the bit buffer and align the output on a byte boundary + function bi_windup() { + if (bi_valid > 8) { + put_short(bi_buf); + } else if (bi_valid > 0) { + put_byte(bi_buf & 0xff); + } + bi_buf = 0; + bi_valid = 0; + } + + // Copy a stored block, storing first the length and its + // one's complement if requested. + function copy_block(buf, // the input data + len, // its length + header // true if block header must be written + ) { + bi_windup(); // align on byte boundary + last_eob_len = 8; // enough lookahead for inflate + + if (header) { + put_short(len); + put_short(~len); + } + + that.pending_buf.set(window.subarray(buf, buf + len), that.pending); + that.pending += len; + } + + // Send a stored block + function _tr_stored_block(buf, // input block + stored_len, // length of input block + eof // true if this is the last block for a file + ) { + send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3); // send block type + copy_block(buf, stored_len, true); // with header + } + + // Determine the best encoding for the current block: dynamic trees, static + // trees or store, and output the encoded block to the zip file. + function _tr_flush_block(buf, // input block, or NULL if too old + stored_len, // length of input block + eof // true if this is the last block for a file + ) { + let opt_lenb, static_lenb;// opt_len and static_len in bytes + let max_blindex = 0; // index of last bit length code of non zero freq + + // Build the Huffman trees unless a stored block is forced + if (level > 0) { + // Construct the literal and distance trees + l_desc.build_tree(that); + + d_desc.build_tree(that); + + // At this point, opt_len and static_len are the total bit lengths + // of + // the compressed block data, excluding the tree representations. + + // Build the bit length tree for the above two trees, and get the + // index + // in bl_order of the last bit length code to send. + max_blindex = build_bl_tree(); + + // Determine the best encoding. Compute first the block length in + // bytes + opt_lenb = (that.opt_len + 3 + 7) >>> 3; + static_lenb = (that.static_len + 3 + 7) >>> 3; + + if (static_lenb <= opt_lenb) + opt_lenb = static_lenb; + } else { + opt_lenb = static_lenb = stored_len + 5; // force a stored block + } + + if ((stored_len + 4 <= opt_lenb) && buf != -1) { + // 4: two words for the lengths + // The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + // Otherwise we can't have processed more than WSIZE input bytes + // since + // the last block flush, because compression would have been + // successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + // transform a block into a stored block. + _tr_stored_block(buf, stored_len, eof); + } else if (static_lenb == opt_lenb) { + send_bits((STATIC_TREES << 1) + (eof ? 1 : 0), 3); + compress_block(StaticTree.static_ltree, StaticTree.static_dtree); + } else { + send_bits((DYN_TREES << 1) + (eof ? 1 : 0), 3); + send_all_trees(l_desc.max_code + 1, d_desc.max_code + 1, max_blindex + 1); + compress_block(dyn_ltree, dyn_dtree); + } + + // The above check is made mod 2^32, for files larger than 512 MB + // and uLong implemented on 32 bits. + + init_block(); + + if (eof) { + bi_windup(); + } + } + + function flush_block_only(eof) { + _tr_flush_block(block_start >= 0 ? block_start : -1, strstart - block_start, eof); + block_start = strstart; + strm.flush_pending(); + } + + // Fill the window when the lookahead becomes insufficient. + // Updates strstart and lookahead. + // + // IN assertion: lookahead < MIN_LOOKAHEAD + // OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + // At least one byte has been read, or avail_in === 0; reads are + // performed for at least two bytes (required for the zip translate_eol + // option -- not supported here). + function fill_window() { + let n, m; + let p; + let more; // Amount of free space at the end of the window. + + do { + more = (window_size - lookahead - strstart); + + // Deal with !@#$% 64K limit: + if (more === 0 && strstart === 0 && lookahead === 0) { + more = w_size; + } else if (more == -1) { + // Very unlikely, but possible on 16 bit machine if strstart == + // 0 + // and lookahead == 1 (input done one byte at time) + more--; + + // If the window is almost full and there is insufficient + // lookahead, + // move the upper half to the lower one to make room in the + // upper half. + } else if (strstart >= w_size + w_size - MIN_LOOKAHEAD) { + window.set(window.subarray(w_size, w_size + w_size), 0); + + match_start -= w_size; + strstart -= w_size; // we now have strstart >= MAX_DIST + block_start -= w_size; + + // Slide the hash table (could be avoided with 32 bit values + // at the expense of memory usage). We slide even when level == + // 0 + // to keep the hash table consistent if we switch back to level + // > 0 + // later. (Using level 0 permanently is not an optimal usage of + // zlib, so we don't care about this pathological case.) + + n = hash_size; + p = n; + do { + m = (head[--p] & 0xffff); + head[p] = (m >= w_size ? m - w_size : 0); + } while (--n !== 0); + + n = w_size; + p = n; + do { + m = (prev[--p] & 0xffff); + prev[p] = (m >= w_size ? m - w_size : 0); + // If n is not on any hash chain, prev[n] is garbage but + // its value will never be used. + } while (--n !== 0); + more += w_size; + } + + if (strm.avail_in === 0) + return; + + // If there was no sliding: + // strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + // more == window_size - lookahead - strstart + // => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + // => more >= window_size - 2*WSIZE + 2 + // In the BIG_MEM or MMAP case (not yet supported), + // window_size == input_size + MIN_LOOKAHEAD && + // strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + // Otherwise, window_size == 2*WSIZE so more >= 2. + // If there was sliding, more >= WSIZE. So in all cases, more >= 2. + + n = strm.read_buf(window, strstart + lookahead, more); + lookahead += n; + + // Initialize the hash value now that we have some input: + if (lookahead >= MIN_MATCH) { + ins_h = window[strstart] & 0xff; + ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask; + } + // If the whole input has less than MIN_MATCH bytes, ins_h is + // garbage, + // but this is not important since only literal bytes will be + // emitted. + } while (lookahead < MIN_LOOKAHEAD && strm.avail_in !== 0); + } + + // Copy without compression as much as possible from the input stream, + // return + // the current block state. + // This function does not insert new strings in the dictionary since + // uncompressible data is probably not useful. This function is used + // only for the level=0 compression option. + // NOTE: this function should be optimized to avoid extra copying from + // window to pending_buf. + function deflate_stored(flush) { + // Stored blocks are limited to 0xffff bytes, pending_buf is limited + // to pending_buf_size, and each stored block has a 5 byte header: + + let max_block_size = 0xffff; + let max_start; + + if (max_block_size > pending_buf_size - 5) { + max_block_size = pending_buf_size - 5; + } + + // Copy as much as possible from input to output: + // eslint-disable-next-line no-constant-condition + while (true) { + // Fill the window as much as possible: + if (lookahead <= 1) { + fill_window(); + if (lookahead === 0 && flush == Z_NO_FLUSH) + return NeedMore; + if (lookahead === 0) + break; // flush the current block + } + + strstart += lookahead; + lookahead = 0; + + // Emit a stored block if pending_buf will be full: + max_start = block_start + max_block_size; + if (strstart === 0 || strstart >= max_start) { + // strstart === 0 is possible when wraparound on 16-bit machine + lookahead = (strstart - max_start); + strstart = max_start; + + flush_block_only(false); + if (strm.avail_out === 0) + return NeedMore; + + } + + // Flush if we may have to slide, otherwise block_start may become + // negative and the data will be gone: + if (strstart - block_start >= w_size - MIN_LOOKAHEAD) { + flush_block_only(false); + if (strm.avail_out === 0) + return NeedMore; + } + } + + flush_block_only(flush == Z_FINISH); + if (strm.avail_out === 0) + return (flush == Z_FINISH) ? FinishStarted : NeedMore; + + return flush == Z_FINISH ? FinishDone : BlockDone; + } + + function longest_match(cur_match) { + let chain_length = max_chain_length; // max hash chain length + let scan = strstart; // current string + let match; // matched string + let len; // length of current match + let best_len = prev_length; // best match length so far + const limit = strstart > (w_size - MIN_LOOKAHEAD) ? strstart - (w_size - MIN_LOOKAHEAD) : 0; + let _nice_match = nice_match; + + // Stop when cur_match becomes <= limit. To simplify the code, + // we prevent matches with the string of window index 0. + + const wmask = w_mask; + + const strend = strstart + MAX_MATCH; + let scan_end1 = window[scan + best_len - 1]; + let scan_end = window[scan + best_len]; + + // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of + // 16. + // It is easy to get rid of this optimization if necessary. + + // Do not waste too much time if we already have a good match: + if (prev_length >= good_match) { + chain_length >>= 2; + } + + // Do not look for matches beyond the end of the input. This is + // necessary + // to make deflate deterministic. + if (_nice_match > lookahead) + _nice_match = lookahead; + + do { + match = cur_match; + + // Skip to next match if the match length cannot increase + // or if the match length is less than 2: + if (window[match + best_len] != scan_end || window[match + best_len - 1] != scan_end1 || window[match] != window[scan] + || window[++match] != window[scan + 1]) + continue; + + // The check at best_len-1 can be removed because it will be made + // again later. (This heuristic is not always a win.) + // It is not necessary to compare scan[2] and match[2] since they + // are always equal when the other bytes match, given that + // the hash keys are equal and that HASH_BITS >= 8. + scan += 2; + match++; + + // We check for insufficient lookahead only every 8th comparison; + // the 256th check will be made at strstart+258. + // eslint-disable-next-line no-empty + do { + } while (window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] + && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] + && window[++scan] == window[++match] && window[++scan] == window[++match] && scan < strend); + + len = MAX_MATCH - (strend - scan); + scan = strend - MAX_MATCH; + + if (len > best_len) { + match_start = cur_match; + best_len = len; + if (len >= _nice_match) + break; + scan_end1 = window[scan + best_len - 1]; + scan_end = window[scan + best_len]; + } + + } while ((cur_match = (prev[cur_match & wmask] & 0xffff)) > limit && --chain_length !== 0); + + if (best_len <= lookahead) + return best_len; + return lookahead; + } + + // Compress as much as possible from the input stream, return the current + // block state. + // This function does not perform lazy evaluation of matches and inserts + // new strings in the dictionary only for unmatched strings or for short + // matches. It is used only for the fast compression options. + function deflate_fast(flush) { + // short hash_head = 0; // head of the hash chain + let hash_head = 0; // head of the hash chain + let bflush; // set if current block must be flushed + + // eslint-disable-next-line no-constant-condition + while (true) { + // Make sure that we always have enough lookahead, except + // at the end of the input file. We need MAX_MATCH bytes + // for the next match, plus MIN_MATCH bytes to insert the + // string following the next match. + if (lookahead < MIN_LOOKAHEAD) { + fill_window(); + if (lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return NeedMore; + } + if (lookahead === 0) + break; // flush the current block + } + + // Insert the string window[strstart .. strstart+2] in the + // dictionary, and set hash_head to the head of the hash chain: + if (lookahead >= MIN_MATCH) { + ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + + // prev[strstart&w_mask]=hash_head=head[ins_h]; + hash_head = (head[ins_h] & 0xffff); + prev[strstart & w_mask] = head[ins_h]; + head[ins_h] = strstart; + } + + // Find the longest match, discarding those <= prev_length. + // At this point we have always match_length < MIN_MATCH + + if (hash_head !== 0 && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) { + // To simplify the code, we prevent matches with the string + // of window index 0 (in particular we have to avoid a match + // of the string with itself at the start of the input file). + if (strategy != Z_HUFFMAN_ONLY) { + match_length = longest_match(hash_head); + } + // longest_match() sets match_start + } + if (match_length >= MIN_MATCH) { + // check_match(strstart, match_start, match_length); + + bflush = _tr_tally(strstart - match_start, match_length - MIN_MATCH); + + lookahead -= match_length; + + // Insert new strings in the hash table only if the match length + // is not too large. This saves time but degrades compression. + if (match_length <= max_lazy_match && lookahead >= MIN_MATCH) { + match_length--; // string at strstart already in hash table + do { + strstart++; + + ins_h = ((ins_h << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + // prev[strstart&w_mask]=hash_head=head[ins_h]; + hash_head = (head[ins_h] & 0xffff); + prev[strstart & w_mask] = head[ins_h]; + head[ins_h] = strstart; + + // strstart never exceeds WSIZE-MAX_MATCH, so there are + // always MIN_MATCH bytes ahead. + } while (--match_length !== 0); + strstart++; + } else { + strstart += match_length; + match_length = 0; + ins_h = window[strstart] & 0xff; + + ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask; + // If lookahead < MIN_MATCH, ins_h is garbage, but it does + // not + // matter since it will be recomputed at next deflate call. + } + } else { + // No match, output a literal byte + + bflush = _tr_tally(0, window[strstart] & 0xff); + lookahead--; + strstart++; + } + if (bflush) { + + flush_block_only(false); + if (strm.avail_out === 0) + return NeedMore; + } + } + + flush_block_only(flush == Z_FINISH); + if (strm.avail_out === 0) { + if (flush == Z_FINISH) + return FinishStarted; + else + return NeedMore; + } + return flush == Z_FINISH ? FinishDone : BlockDone; + } + + // Same as above, but achieves better compression. We use a lazy + // evaluation for matches: a match is finally adopted only if there is + // no better match at the next window position. + function deflate_slow(flush) { + // short hash_head = 0; // head of hash chain + let hash_head = 0; // head of hash chain + let bflush; // set if current block must be flushed + let max_insert; + + // Process the input block. + // eslint-disable-next-line no-constant-condition + while (true) { + // Make sure that we always have enough lookahead, except + // at the end of the input file. We need MAX_MATCH bytes + // for the next match, plus MIN_MATCH bytes to insert the + // string following the next match. + + if (lookahead < MIN_LOOKAHEAD) { + fill_window(); + if (lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return NeedMore; + } + if (lookahead === 0) + break; // flush the current block + } + + // Insert the string window[strstart .. strstart+2] in the + // dictionary, and set hash_head to the head of the hash chain: + + if (lookahead >= MIN_MATCH) { + ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + // prev[strstart&w_mask]=hash_head=head[ins_h]; + hash_head = (head[ins_h] & 0xffff); + prev[strstart & w_mask] = head[ins_h]; + head[ins_h] = strstart; + } + + // Find the longest match, discarding those <= prev_length. + prev_length = match_length; + prev_match = match_start; + match_length = MIN_MATCH - 1; + + if (hash_head !== 0 && prev_length < max_lazy_match && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) { + // To simplify the code, we prevent matches with the string + // of window index 0 (in particular we have to avoid a match + // of the string with itself at the start of the input file). + + if (strategy != Z_HUFFMAN_ONLY) { + match_length = longest_match(hash_head); + } + // longest_match() sets match_start + + if (match_length <= 5 && (strategy == Z_FILTERED || (match_length == MIN_MATCH && strstart - match_start > 4096))) { + + // If prev_match is also MIN_MATCH, match_start is garbage + // but we will ignore the current match anyway. + match_length = MIN_MATCH - 1; + } + } + + // If there was a match at the previous step and the current + // match is not better, output the previous match: + if (prev_length >= MIN_MATCH && match_length <= prev_length) { + max_insert = strstart + lookahead - MIN_MATCH; + // Do not insert strings in hash table beyond this. + + // check_match(strstart-1, prev_match, prev_length); + + bflush = _tr_tally(strstart - 1 - prev_match, prev_length - MIN_MATCH); + + // Insert in hash table all strings up to the end of the match. + // strstart-1 and strstart are already inserted. If there is not + // enough lookahead, the last two strings are not inserted in + // the hash table. + lookahead -= prev_length - 1; + prev_length -= 2; + do { + if (++strstart <= max_insert) { + ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + // prev[strstart&w_mask]=hash_head=head[ins_h]; + hash_head = (head[ins_h] & 0xffff); + prev[strstart & w_mask] = head[ins_h]; + head[ins_h] = strstart; + } + } while (--prev_length !== 0); + match_available = 0; + match_length = MIN_MATCH - 1; + strstart++; + + if (bflush) { + flush_block_only(false); + if (strm.avail_out === 0) + return NeedMore; + } + } else if (match_available !== 0) { + + // If there was no match at the previous position, output a + // single literal. If there was a match but the current match + // is longer, truncate the previous match to a single literal. + + bflush = _tr_tally(0, window[strstart - 1] & 0xff); + + if (bflush) { + flush_block_only(false); + } + strstart++; + lookahead--; + if (strm.avail_out === 0) + return NeedMore; + } else { + // There is no previous match to compare with, wait for + // the next step to decide. + + match_available = 1; + strstart++; + lookahead--; + } + } + + if (match_available !== 0) { + bflush = _tr_tally(0, window[strstart - 1] & 0xff); + match_available = 0; + } + flush_block_only(flush == Z_FINISH); + + if (strm.avail_out === 0) { + if (flush == Z_FINISH) + return FinishStarted; + else + return NeedMore; + } + + return flush == Z_FINISH ? FinishDone : BlockDone; + } + + function deflateReset(strm) { + strm.total_in = strm.total_out = 0; + strm.msg = null; // + + that.pending = 0; + that.pending_out = 0; + + status = BUSY_STATE; + + last_flush = Z_NO_FLUSH; + + tr_init(); + lm_init(); + return Z_OK; + } + + that.deflateInit = function (strm, _level, bits, _method, memLevel, _strategy) { + if (!_method) + _method = Z_DEFLATED; + if (!memLevel) + memLevel = DEF_MEM_LEVEL; + if (!_strategy) + _strategy = Z_DEFAULT_STRATEGY; + + // byte[] my_version=ZLIB_VERSION; + + // + // if (!version || version[0] != my_version[0] + // || stream_size != sizeof(z_stream)) { + // return Z_VERSION_ERROR; + // } + + strm.msg = null; + + if (_level == Z_DEFAULT_COMPRESSION) + _level = 6; + + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || _method != Z_DEFLATED || bits < 9 || bits > 15 || _level < 0 || _level > 9 || _strategy < 0 + || _strategy > Z_HUFFMAN_ONLY) { + return Z_STREAM_ERROR; + } + + strm.dstate = that; + + w_bits = bits; + w_size = 1 << w_bits; + w_mask = w_size - 1; + + hash_bits = memLevel + 7; + hash_size = 1 << hash_bits; + hash_mask = hash_size - 1; + hash_shift = Math.floor((hash_bits + MIN_MATCH - 1) / MIN_MATCH); + + window = new Uint8Array(w_size * 2); + prev = []; + head = []; + + lit_bufsize = 1 << (memLevel + 6); // 16K elements by default + + // We overlay pending_buf and d_buf+l_buf. This works since the average + // output size for (length,distance) codes is <= 24 bits. + that.pending_buf = new Uint8Array(lit_bufsize * 4); + pending_buf_size = lit_bufsize * 4; + + d_buf = Math.floor(lit_bufsize / 2); + l_buf = (1 + 2) * lit_bufsize; + + level = _level; + + strategy = _strategy; + + return deflateReset(strm); + }; + + that.deflateEnd = function () { + if (status != INIT_STATE && status != BUSY_STATE && status != FINISH_STATE) { + return Z_STREAM_ERROR; + } + // Deallocate in reverse order of allocations: + that.pending_buf = null; + head = null; + prev = null; + window = null; + // free + that.dstate = null; + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; + }; + + that.deflateParams = function (strm, _level, _strategy) { + let err = Z_OK; + + if (_level == Z_DEFAULT_COMPRESSION) { + _level = 6; + } + if (_level < 0 || _level > 9 || _strategy < 0 || _strategy > Z_HUFFMAN_ONLY) { + return Z_STREAM_ERROR; + } + + if (config_table[level].func != config_table[_level].func && strm.total_in !== 0) { + // Flush the last buffer: + err = strm.deflate(Z_PARTIAL_FLUSH); + } + + if (level != _level) { + level = _level; + max_lazy_match = config_table[level].max_lazy; + good_match = config_table[level].good_length; + nice_match = config_table[level].nice_length; + max_chain_length = config_table[level].max_chain; + } + strategy = _strategy; + return err; + }; + + that.deflateSetDictionary = function (strm, dictionary, dictLength) { + let length = dictLength; + let n, index = 0; + + if (!dictionary || status != INIT_STATE) + return Z_STREAM_ERROR; + + if (length < MIN_MATCH) + return Z_OK; + if (length > w_size - MIN_LOOKAHEAD) { + length = w_size - MIN_LOOKAHEAD; + index = dictLength - length; // use the tail of the dictionary + } + window.set(dictionary.subarray(index, index + length), 0); + + strstart = length; + block_start = length; + + // Insert all strings in the hash table (except for the last two bytes). + // s->lookahead stays null, so s->ins_h will be recomputed at the next + // call of fill_window. + + ins_h = window[0] & 0xff; + ins_h = (((ins_h) << hash_shift) ^ (window[1] & 0xff)) & hash_mask; + + for (n = 0; n <= length - MIN_MATCH; n++) { + ins_h = (((ins_h) << hash_shift) ^ (window[(n) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + prev[n & w_mask] = head[ins_h]; + head[ins_h] = n; + } + return Z_OK; + }; + + that.deflate = function (_strm, flush) { + let i, header, level_flags, old_flush, bstate; + + if (flush > Z_FINISH || flush < 0) { + return Z_STREAM_ERROR; + } + + if (!_strm.next_out || (!_strm.next_in && _strm.avail_in !== 0) || (status == FINISH_STATE && flush != Z_FINISH)) { + _strm.msg = z_errmsg[Z_NEED_DICT - (Z_STREAM_ERROR)]; + return Z_STREAM_ERROR; + } + if (_strm.avail_out === 0) { + _strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; + return Z_BUF_ERROR; + } + + strm = _strm; // just in case + old_flush = last_flush; + last_flush = flush; + + // Write the zlib header + if (status == INIT_STATE) { + header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8; + level_flags = ((level - 1) & 0xff) >> 1; + + if (level_flags > 3) + level_flags = 3; + header |= (level_flags << 6); + if (strstart !== 0) + header |= PRESET_DICT; + header += 31 - (header % 31); + + status = BUSY_STATE; + putShortMSB(header); + } + + // Flush as much pending output as possible + if (that.pending !== 0) { + strm.flush_pending(); + if (strm.avail_out === 0) { + // console.log(" avail_out==0"); + // Since avail_out is 0, deflate will be called again with + // more output space, but possibly with both pending and + // avail_in equal to zero. There won't be anything to do, + // but this is not an error situation so make sure we + // return OK instead of BUF_ERROR at next call of deflate: + last_flush = -1; + return Z_OK; + } + + // Make sure there is something to do and avoid duplicate + // consecutive + // flushes. For repeated and useless calls with Z_FINISH, we keep + // returning Z_STREAM_END instead of Z_BUFF_ERROR. + } else if (strm.avail_in === 0 && flush <= old_flush && flush != Z_FINISH) { + strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; + return Z_BUF_ERROR; + } + + // User must not provide more input after the first FINISH: + if (status == FINISH_STATE && strm.avail_in !== 0) { + _strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; + return Z_BUF_ERROR; + } + + // Start a new block or continue the current one. + if (strm.avail_in !== 0 || lookahead !== 0 || (flush != Z_NO_FLUSH && status != FINISH_STATE)) { + bstate = -1; + switch (config_table[level].func) { + case STORED: + bstate = deflate_stored(flush); + break; + case FAST: + bstate = deflate_fast(flush); + break; + case SLOW: + bstate = deflate_slow(flush); + break; + } + + if (bstate == FinishStarted || bstate == FinishDone) { + status = FINISH_STATE; + } + if (bstate == NeedMore || bstate == FinishStarted) { + if (strm.avail_out === 0) { + last_flush = -1; // avoid BUF_ERROR next call, see above + } + return Z_OK; + // If flush != Z_NO_FLUSH && avail_out === 0, the next call + // of deflate should use the same flush parameter to make sure + // that the flush is complete. So we don't have to output an + // empty block here, this will be done at next call. This also + // ensures that for a very small output buffer, we emit at most + // one empty block. + } + + if (bstate == BlockDone) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(); + } else { // FULL_FLUSH or SYNC_FLUSH + _tr_stored_block(0, 0, false); + // For a full flush, this empty block will be recognized + // as a special marker by inflate_sync(). + if (flush == Z_FULL_FLUSH) { + // state.head[s.hash_size-1]=0; + for (i = 0; i < hash_size/*-1*/; i++) + // forget history + head[i] = 0; + } + } + strm.flush_pending(); + if (strm.avail_out === 0) { + last_flush = -1; // avoid BUF_ERROR at next call, see above + return Z_OK; + } + } + } + + if (flush != Z_FINISH) + return Z_OK; + return Z_STREAM_END; + }; + } + + // ZStream + + function ZStream() { + const that = this; + that.next_in_index = 0; + that.next_out_index = 0; + // that.next_in; // next input byte + that.avail_in = 0; // number of bytes available at next_in + that.total_in = 0; // total nb of input bytes read so far + // that.next_out; // next output byte should be put there + that.avail_out = 0; // remaining free space at next_out + that.total_out = 0; // total nb of bytes output so far + // that.msg; + // that.dstate; + } + + ZStream.prototype = { + deflateInit: function (level, bits) { + const that = this; + that.dstate = new Deflate(); + if (!bits) + bits = MAX_BITS; + return that.dstate.deflateInit(that, level, bits); + }, + + deflate: function (flush) { + const that = this; + if (!that.dstate) { + return Z_STREAM_ERROR; + } + return that.dstate.deflate(that, flush); + }, + + deflateEnd: function () { + const that = this; + if (!that.dstate) + return Z_STREAM_ERROR; + const ret = that.dstate.deflateEnd(); + that.dstate = null; + return ret; + }, + + deflateParams: function (level, strategy) { + const that = this; + if (!that.dstate) + return Z_STREAM_ERROR; + return that.dstate.deflateParams(that, level, strategy); + }, + + deflateSetDictionary: function (dictionary, dictLength) { + const that = this; + if (!that.dstate) + return Z_STREAM_ERROR; + return that.dstate.deflateSetDictionary(that, dictionary, dictLength); + }, + + // Read a new buffer from the current input stream, update the + // total number of bytes read. All deflate() input goes through + // this function so some applications may wish to modify it to avoid + // allocating a large strm->next_in buffer and copying from it. + // (See also flush_pending()). + read_buf: function (buf, start, size) { + const that = this; + let len = that.avail_in; + if (len > size) + len = size; + if (len === 0) + return 0; + that.avail_in -= len; + buf.set(that.next_in.subarray(that.next_in_index, that.next_in_index + len), start); + that.next_in_index += len; + that.total_in += len; + return len; + }, + + // Flush as much pending output as possible. All deflate() output goes + // through this function so some applications may wish to modify it + // to avoid allocating a large strm->next_out buffer and copying into it. + // (See also read_buf()). + flush_pending: function () { + const that = this; + let len = that.dstate.pending; + + if (len > that.avail_out) + len = that.avail_out; + if (len === 0) + return; + + // if (that.dstate.pending_buf.length <= that.dstate.pending_out || that.next_out.length <= that.next_out_index + // || that.dstate.pending_buf.length < (that.dstate.pending_out + len) || that.next_out.length < (that.next_out_index + + // len)) { + // console.log(that.dstate.pending_buf.length + ", " + that.dstate.pending_out + ", " + that.next_out.length + ", " + + // that.next_out_index + ", " + len); + // console.log("avail_out=" + that.avail_out); + // } + + that.next_out.set(that.dstate.pending_buf.subarray(that.dstate.pending_out, that.dstate.pending_out + len), that.next_out_index); + + that.next_out_index += len; + that.dstate.pending_out += len; + that.total_out += len; + that.avail_out -= len; + that.dstate.pending -= len; + if (that.dstate.pending === 0) { + that.dstate.pending_out = 0; + } + } + }; + + // Deflate + + function ZipDeflate(options) { + const that = this; + const z = new ZStream(); + const bufsize = 512; + const flush = Z_NO_FLUSH; + const buf = new Uint8Array(bufsize); + let level = options ? options.level : Z_DEFAULT_COMPRESSION; + if (typeof level == "undefined") + level = Z_DEFAULT_COMPRESSION; + z.deflateInit(level); + z.next_out = buf; + + that.append = function (data, onprogress) { + let err, array, lastIndex = 0, bufferIndex = 0, bufferSize = 0; + const buffers = []; + if (!data.length) + return; + z.next_in_index = 0; + z.next_in = data; + z.avail_in = data.length; + do { + z.next_out_index = 0; + z.avail_out = bufsize; + err = z.deflate(flush); + if (err != Z_OK) + throw new Error("deflating: " + z.msg); + if (z.next_out_index) + if (z.next_out_index == bufsize) + buffers.push(new Uint8Array(buf)); + else + buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); + bufferSize += z.next_out_index; + if (onprogress && z.next_in_index > 0 && z.next_in_index != lastIndex) { + onprogress(z.next_in_index); + lastIndex = z.next_in_index; + } + } while (z.avail_in > 0 || z.avail_out === 0); + array = new Uint8Array(bufferSize); + buffers.forEach(function (chunk) { + array.set(chunk, bufferIndex); + bufferIndex += chunk.length; + }); + return array; + }; + that.flush = function () { + let err, array, bufferIndex = 0, bufferSize = 0; + const buffers = []; + do { + z.next_out_index = 0; + z.avail_out = bufsize; + err = z.deflate(Z_FINISH); + if (err != Z_STREAM_END && err != Z_OK) + throw new Error("deflating: " + z.msg); + if (bufsize - z.avail_out > 0) + buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); + bufferSize += z.next_out_index; + } while (z.avail_in > 0 || z.avail_out === 0); + z.deflateEnd(); + array = new Uint8Array(bufferSize); + buffers.forEach(function (chunk) { + array.set(chunk, bufferIndex); + bufferIndex += chunk.length; + }); + return array; + }; + } + + /* + Copyright (c) 2021 Gildas Lormeau. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + // Global + const MAX_BITS$1 = 15; + + const Z_OK$1 = 0; + const Z_STREAM_END$1 = 1; + const Z_NEED_DICT$1 = 2; + const Z_STREAM_ERROR$1 = -2; + const Z_DATA_ERROR$1 = -3; + const Z_MEM_ERROR = -4; + const Z_BUF_ERROR$1 = -5; + + const inflate_mask = [0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, + 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff]; + + const MANY = 1440; + + // JZlib version : "1.0.2" + const Z_NO_FLUSH$1 = 0; + const Z_FINISH$1 = 4; + + // InfTree + const fixed_bl = 9; + const fixed_bd = 5; + + const fixed_tl = [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]; + const fixed_td = [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]; + + // Tables for deflate from PKZIP's appnote.txt. + const cplens = [ // Copy lengths for literal codes 257..285 + 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]; + + // see note #13 above about 258 + const cplext = [ // Extra bits for literal codes 257..285 + 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 // 112==invalid + ]; + + const cpdist = [ // Copy offsets for distance codes 0..29 + 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]; + + const cpdext = [ // Extra bits for distance codes + 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]; + + // If BMAX needs to be larger than 16, then h and x[] should be uLong. + const BMAX = 15; // maximum bit length of any code + + function InfTree() { + const that = this; + + let hn; // hufts used in space + let v; // work area for huft_build + let c; // bit length count table + let r; // table entry for structure assignment + let u; // table stack + let x; // bit offsets, then code stack + + function huft_build(b, // code lengths in bits (all assumed <= + // BMAX) + bindex, n, // number of codes (assumed <= 288) + s, // number of simple-valued codes (0..s-1) + d, // list of base values for non-simple codes + e, // list of extra bits for non-simple codes + t, // result: starting table + m, // maximum lookup bits, returns actual + hp,// space for trees + hn,// hufts used in space + v // working area: values in order of bit length + ) { + // Given a list of code lengths and a maximum table size, make a set of + // tables to decode that set of codes. Return Z_OK on success, + // Z_BUF_ERROR + // if the given code set is incomplete (the tables are still built in + // this + // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set + // of + // lengths), or Z_MEM_ERROR if not enough memory. + + let a; // counter for codes of length k + let f; // i repeats in table every f entries + let g; // maximum code length + let h; // table level + let i; // counter, current code + let j; // counter + let k; // number of bits in current code + let l; // bits per table (returned in m) + let mask; // (1 << w) - 1, to avoid cc -O bug on HP + let p; // pointer into c[], b[], or v[] + let q; // points to current table + let w; // bits before this table == (l * h) + let xp; // pointer into x + let y; // number of dummy codes added + let z; // number of entries in current table + + // Generate counts for each bit length + + p = 0; + i = n; + do { + c[b[bindex + p]]++; + p++; + i--; // assume all entries <= BMAX + } while (i !== 0); + + if (c[0] == n) { // null input--all zero length codes + t[0] = -1; + m[0] = 0; + return Z_OK$1; + } + + // Find minimum and maximum length, bound *m by those + l = m[0]; + for (j = 1; j <= BMAX; j++) + if (c[j] !== 0) + break; + k = j; // minimum code length + if (l < j) { + l = j; + } + for (i = BMAX; i !== 0; i--) { + if (c[i] !== 0) + break; + } + g = i; // maximum code length + if (l > i) { + l = i; + } + m[0] = l; + + // Adjust last length count to fill out codes, if needed + for (y = 1 << j; j < i; j++, y <<= 1) { + if ((y -= c[j]) < 0) { + return Z_DATA_ERROR$1; + } + } + if ((y -= c[i]) < 0) { + return Z_DATA_ERROR$1; + } + c[i] += y; + + // Generate starting offsets into the value table for each length + x[1] = j = 0; + p = 1; + xp = 2; + while (--i !== 0) { // note that i == g from above + x[xp] = (j += c[p]); + xp++; + p++; + } + + // Make a table of values in order of bit lengths + i = 0; + p = 0; + do { + if ((j = b[bindex + p]) !== 0) { + v[x[j]++] = i; + } + p++; + } while (++i < n); + n = x[g]; // set n to length of v + + // Generate the Huffman codes and for each, make the table entries + x[0] = i = 0; // first Huffman code is zero + p = 0; // grab values in bit order + h = -1; // no tables yet--level -1 + w = -l; // bits decoded == (l * h) + u[0] = 0; // just to keep compilers happy + q = 0; // ditto + z = 0; // ditto + + // go through the bit lengths (k already is bits in shortest code) + for (; k <= g; k++) { + a = c[k]; + while (a-- !== 0) { + // here i is the Huffman code of length k bits for value *p + // make tables up to required level + while (k > w + l) { + h++; + w += l; // previous table always l bits + // compute minimum size table less than or equal to l bits + z = g - w; + z = (z > l) ? l : z; // table size upper limit + if ((f = 1 << (j = k - w)) > a + 1) { // try a k-w bit table + // too few codes for + // k-w bit table + f -= a + 1; // deduct codes from patterns left + xp = k; + if (j < z) { + while (++j < z) { // try smaller tables up to z bits + if ((f <<= 1) <= c[++xp]) + break; // enough codes to use up j bits + f -= c[xp]; // else deduct codes from patterns + } + } + } + z = 1 << j; // table entries for j-bit table + + // allocate new table + if (hn[0] + z > MANY) { // (note: doesn't matter for fixed) + return Z_DATA_ERROR$1; // overflow of MANY + } + u[h] = q = /* hp+ */hn[0]; // DEBUG + hn[0] += z; + + // connect to last table, if there is one + if (h !== 0) { + x[h] = i; // save pattern for backing up + r[0] = /* (byte) */j; // bits in this table + r[1] = /* (byte) */l; // bits to dump before this table + j = i >>> (w - l); + r[2] = /* (int) */(q - u[h - 1] - j); // offset to this table + hp.set(r, (u[h - 1] + j) * 3); + // to + // last + // table + } else { + t[0] = q; // first table is returned result + } + } + + // set up table entry in r + r[1] = /* (byte) */(k - w); + if (p >= n) { + r[0] = 128 + 64; // out of values--invalid code + } else if (v[p] < s) { + r[0] = /* (byte) */(v[p] < 256 ? 0 : 32 + 64); // 256 is + // end-of-block + r[2] = v[p++]; // simple code is just the value + } else { + r[0] = /* (byte) */(e[v[p] - s] + 16 + 64); // non-simple--look + // up in lists + r[2] = d[v[p++] - s]; + } + + // fill code-like entries with r + f = 1 << (k - w); + for (j = i >>> w; j < z; j += f) { + hp.set(r, (q + j) * 3); + } + + // backwards increment the k-bit code i + for (j = 1 << (k - 1); (i & j) !== 0; j >>>= 1) { + i ^= j; + } + i ^= j; + + // backup over finished tables + mask = (1 << w) - 1; // needed on HP, cc -O bug + while ((i & mask) != x[h]) { + h--; // don't need to update q + w -= l; + mask = (1 << w) - 1; + } + } + } + // Return Z_BUF_ERROR if we were given an incomplete table + return y !== 0 && g != 1 ? Z_BUF_ERROR$1 : Z_OK$1; + } + + function initWorkArea(vsize) { + let i; + if (!hn) { + hn = []; // []; //new Array(1); + v = []; // new Array(vsize); + c = new Int32Array(BMAX + 1); // new Array(BMAX + 1); + r = []; // new Array(3); + u = new Int32Array(BMAX); // new Array(BMAX); + x = new Int32Array(BMAX + 1); // new Array(BMAX + 1); + } + if (v.length < vsize) { + v = []; // new Array(vsize); + } + for (i = 0; i < vsize; i++) { + v[i] = 0; + } + for (i = 0; i < BMAX + 1; i++) { + c[i] = 0; + } + for (i = 0; i < 3; i++) { + r[i] = 0; + } + // for(int i=0; i 257)) { + if (result == Z_DATA_ERROR$1) { + z.msg = "oversubscribed distance tree"; + } else if (result == Z_BUF_ERROR$1) { + z.msg = "incomplete distance tree"; + result = Z_DATA_ERROR$1; + } else if (result != Z_MEM_ERROR) { + z.msg = "empty distance tree with lengths"; + result = Z_DATA_ERROR$1; + } + return result; + } + + return Z_OK$1; + }; + + } + + InfTree.inflate_trees_fixed = function (bl, // literal desired/actual bit depth + bd, // distance desired/actual bit depth + tl,// literal/length tree result + td// distance tree result + ) { + bl[0] = fixed_bl; + bd[0] = fixed_bd; + tl[0] = fixed_tl; + td[0] = fixed_td; + return Z_OK$1; + }; + + // InfCodes + + // waiting for "i:"=input, + // "o:"=output, + // "x:"=nothing + const START = 0; // x: set up for LEN + const LEN = 1; // i: get length/literal/eob next + const LENEXT = 2; // i: getting length extra (have base) + const DIST = 3; // i: get distance next + const DISTEXT = 4;// i: getting distance extra + const COPY = 5; // o: copying bytes in window, waiting + // for space + const LIT = 6; // o: got literal, waiting for output + // space + const WASH = 7; // o: got eob, possibly still output + // waiting + const END = 8; // x: got eob and all data flushed + const BADCODE = 9;// x: got error + + function InfCodes() { + const that = this; + + let mode; // current inflate_codes mode + + // mode dependent information + let len = 0; + + let tree; // pointer into tree + let tree_index = 0; + let need = 0; // bits needed + + let lit = 0; + + // if EXT or COPY, where and how much + let get = 0; // bits to get for extra + let dist = 0; // distance back to copy from + + let lbits = 0; // ltree bits decoded per branch + let dbits = 0; // dtree bits decoder per branch + let ltree; // literal/length/eob tree + let ltree_index = 0; // literal/length/eob tree + let dtree; // distance tree + let dtree_index = 0; // distance tree + + // Called with number of bytes left to write in window at least 258 + // (the maximum string length) and number of input bytes available + // at least ten. The ten bytes are six bytes for the longest length/ + // distance pair plus four bytes for overloading the bit buffer. + + function inflate_fast(bl, bd, tl, tl_index, td, td_index, s, z) { + let t; // temporary pointer + let tp; // temporary pointer + let tp_index; // temporary pointer + let e; // extra bits or operation + let b; // bit buffer + let k; // bits in bit buffer + let p; // input data pointer + let n; // bytes available there + let q; // output window write pointer + let m; // bytes to end of window or read pointer + let ml; // mask for literal/length tree + let md; // mask for distance tree + let c; // bytes to copy + let d; // distance back to copy from + let r; // copy source pointer + + let tp_index_t_3; // (tp_index+t)*3 + + // load input, output, bit values + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + // initialize masks + ml = inflate_mask[bl]; + md = inflate_mask[bd]; + + // do until not enough input or output space for fast loop + do { // assume called with m >= 258 && n >= 10 + // get literal/length code + while (k < (20)) { // max bits for literal/length code + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + t = b & ml; + tp = tl; + tp_index = tl_index; + tp_index_t_3 = (tp_index + t) * 3; + if ((e = tp[tp_index_t_3]) === 0) { + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2]; + m--; + continue; + } + do { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + if ((e & 16) !== 0) { + e &= 15; + c = tp[tp_index_t_3 + 2] + (/* (int) */b & inflate_mask[e]); + + b >>= e; + k -= e; + + // decode distance base of block to copy + while (k < (15)) { // max bits for distance code + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + t = b & md; + tp = td; + tp_index = td_index; + tp_index_t_3 = (tp_index + t) * 3; + e = tp[tp_index_t_3]; + + do { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + if ((e & 16) !== 0) { + // get extra bits to add to distance base + e &= 15; + while (k < (e)) { // get extra bits (up to 13) + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + d = tp[tp_index_t_3 + 2] + (b & inflate_mask[e]); + + b >>= (e); + k -= (e); + + // do the copy + m -= c; + if (q >= d) { // offset before dest + // just copy + r = q - d; + if (q - r > 0 && 2 > (q - r)) { + s.window[q++] = s.window[r++]; // minimum + // count is + // three, + s.window[q++] = s.window[r++]; // so unroll + // loop a + // little + c -= 2; + } else { + s.window.set(s.window.subarray(r, r + 2), q); + q += 2; + r += 2; + c -= 2; + } + } else { // else offset after destination + r = q - d; + do { + r += s.end; // force pointer in window + } while (r < 0); // covers invalid distances + e = s.end - r; + if (c > e) { // if source crosses, + c -= e; // wrapped copy + if (q - r > 0 && e > (q - r)) { + do { + s.window[q++] = s.window[r++]; + } while (--e !== 0); + } else { + s.window.set(s.window.subarray(r, r + e), q); + q += e; + r += e; + e = 0; + } + r = 0; // copy rest from start of window + } + + } + + // copy all or what's left + if (q - r > 0 && c > (q - r)) { + do { + s.window[q++] = s.window[r++]; + } while (--c !== 0); + } else { + s.window.set(s.window.subarray(r, r + c), q); + q += c; + r += c; + c = 0; + } + break; + } else if ((e & 64) === 0) { + t += tp[tp_index_t_3 + 2]; + t += (b & inflate_mask[e]); + tp_index_t_3 = (tp_index + t) * 3; + e = tp[tp_index_t_3]; + } else { + z.msg = "invalid distance code"; + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_DATA_ERROR$1; + } + // eslint-disable-next-line no-constant-condition + } while (true); + break; + } + + if ((e & 64) === 0) { + t += tp[tp_index_t_3 + 2]; + t += (b & inflate_mask[e]); + tp_index_t_3 = (tp_index + t) * 3; + if ((e = tp[tp_index_t_3]) === 0) { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2]; + m--; + break; + } + } else if ((e & 32) !== 0) { + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_STREAM_END$1; + } else { + z.msg = "invalid literal/length code"; + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_DATA_ERROR$1; + } + // eslint-disable-next-line no-constant-condition + } while (true); + } while (m >= 258 && n >= 10); + + // not enough input or output--restore pointers and return + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_OK$1; + } + + that.init = function (bl, bd, tl, tl_index, td, td_index) { + mode = START; + lbits = /* (byte) */bl; + dbits = /* (byte) */bd; + ltree = tl; + ltree_index = tl_index; + dtree = td; + dtree_index = td_index; + tree = null; + }; + + that.proc = function (s, z, r) { + let j; // temporary storage + let tindex; // temporary pointer + let e; // extra bits or operation + let b = 0; // bit buffer + let k = 0; // bits in bit buffer + let p = 0; // input data pointer + let n; // bytes available there + let q; // output window write pointer + let m; // bytes to end of window or read pointer + let f; // pointer to copy strings from + + // copy input/output information to locals (UPDATE macro restores) + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + // process input and output based on current state + // eslint-disable-next-line no-constant-condition + while (true) { + switch (mode) { + // waiting for "i:"=input, "o:"=output, "x:"=nothing + case START: // x: set up for LEN + if (m >= 258 && n >= 10) { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); + + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (r != Z_OK$1) { + mode = r == Z_STREAM_END$1 ? WASH : BADCODE; + break; + } + } + need = lbits; + tree = ltree; + tree_index = ltree_index; + + mode = LEN; + /* falls through */ + case LEN: // i: get length/literal/eob next + j = need; + + while (k < (j)) { + if (n !== 0) + r = Z_OK$1; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & inflate_mask[j])) * 3; + + b >>>= (tree[tindex + 1]); + k -= (tree[tindex + 1]); + + e = tree[tindex]; + + if (e === 0) { // literal + lit = tree[tindex + 2]; + mode = LIT; + break; + } + if ((e & 16) !== 0) { // length + get = e & 15; + len = tree[tindex + 2]; + mode = LENEXT; + break; + } + if ((e & 64) === 0) { // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + if ((e & 32) !== 0) { // end of block + mode = WASH; + break; + } + mode = BADCODE; // invalid code + z.msg = "invalid literal/length code"; + r = Z_DATA_ERROR$1; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case LENEXT: // i: getting length extra (have base) + j = get; + + while (k < (j)) { + if (n !== 0) + r = Z_OK$1; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + len += (b & inflate_mask[j]); + + b >>= j; + k -= j; + + need = dbits; + tree = dtree; + tree_index = dtree_index; + mode = DIST; + /* falls through */ + case DIST: // i: get distance next + j = need; + + while (k < (j)) { + if (n !== 0) + r = Z_OK$1; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & inflate_mask[j])) * 3; + + b >>= tree[tindex + 1]; + k -= tree[tindex + 1]; + + e = (tree[tindex]); + if ((e & 16) !== 0) { // distance + get = e & 15; + dist = tree[tindex + 2]; + mode = DISTEXT; + break; + } + if ((e & 64) === 0) { // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + mode = BADCODE; // invalid code + z.msg = "invalid distance code"; + r = Z_DATA_ERROR$1; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case DISTEXT: // i: getting distance extra + j = get; + + while (k < (j)) { + if (n !== 0) + r = Z_OK$1; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + dist += (b & inflate_mask[j]); + + b >>= j; + k -= j; + + mode = COPY; + /* falls through */ + case COPY: // o: copying bytes in window, waiting for space + f = q - dist; + while (f < 0) { // modulo window size-"while" instead + f += s.end; // of "if" handles invalid distances + } + while (len !== 0) { + + if (m === 0) { + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + + if (m === 0) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + } + + s.window[q++] = s.window[f++]; + m--; + + if (f == s.end) + f = 0; + len--; + } + mode = START; + break; + case LIT: // o: got literal, waiting for output space + if (m === 0) { + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + } + r = Z_OK$1; + + s.window[q++] = /* (byte) */lit; + m--; + + mode = START; + break; + case WASH: // o: got eob, possibly more output + if (k > 7) { // return unused byte, if any + k -= 8; + n++; + p--; // can always return one + } + + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (s.read != s.write) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + mode = END; + /* falls through */ + case END: + r = Z_STREAM_END$1; + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case BADCODE: // x: got error + + r = Z_DATA_ERROR$1; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + default: + r = Z_STREAM_ERROR$1; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + }; + + that.free = function () { + // ZFREE(z, c); + }; + + } + + // InfBlocks + + // Table for deflate from PKZIP's appnote.txt. + const border = [ // Order of the bit length code lengths + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; + + const TYPE = 0; // get type bits (3, including end bit) + const LENS = 1; // get lengths for stored + const STORED$1 = 2;// processing stored block + const TABLE = 3; // get table lengths + const BTREE = 4; // get bit lengths tree for a dynamic + // block + const DTREE = 5; // get length, distance trees for a + // dynamic block + const CODES = 6; // processing fixed or dynamic block + const DRY = 7; // output remaining window bytes + const DONELOCKS = 8; // finished last block, done + const BADBLOCKS = 9; // ot a data error--stuck here + + function InfBlocks(z, w) { + const that = this; + + let mode = TYPE; // current inflate_block mode + + let left = 0; // if STORED, bytes left to copy + + let table = 0; // table lengths (14 bits) + let index = 0; // index into blens (or border) + let blens; // bit lengths of codes + const bb = [0]; // bit length tree depth + const tb = [0]; // bit length decoding tree + + const codes = new InfCodes(); // if CODES, current state + + let last = 0; // true if this block is the last block + + let hufts = new Int32Array(MANY * 3); // single malloc for tree space + const check = 0; // check on output + const inftree = new InfTree(); + + that.bitk = 0; // bits in bit buffer + that.bitb = 0; // bit buffer + that.window = new Uint8Array(w); // sliding window + that.end = w; // one byte after sliding window + that.read = 0; // window read pointer + that.write = 0; // window write pointer + + that.reset = function (z, c) { + if (c) + c[0] = check; + // if (mode == BTREE || mode == DTREE) { + // } + if (mode == CODES) { + codes.free(z); + } + mode = TYPE; + that.bitk = 0; + that.bitb = 0; + that.read = that.write = 0; + }; + + that.reset(z, null); + + // copy as much as possible from the sliding window to the output area + that.inflate_flush = function (z, r) { + let n; + let p; + let q; + + // local copies of source and destination pointers + p = z.next_out_index; + q = that.read; + + // compute number of bytes to copy as far as end of window + n = /* (int) */((q <= that.write ? that.write : that.end) - q); + if (n > z.avail_out) + n = z.avail_out; + if (n !== 0 && r == Z_BUF_ERROR$1) + r = Z_OK$1; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // copy as far as end of window + z.next_out.set(that.window.subarray(q, q + n), p); + p += n; + q += n; + + // see if more to copy at beginning of window + if (q == that.end) { + // wrap pointers + q = 0; + if (that.write == that.end) + that.write = 0; + + // compute bytes to copy + n = that.write - q; + if (n > z.avail_out) + n = z.avail_out; + if (n !== 0 && r == Z_BUF_ERROR$1) + r = Z_OK$1; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // copy + z.next_out.set(that.window.subarray(q, q + n), p); + p += n; + q += n; + } + + // update pointers + z.next_out_index = p; + that.read = q; + + // done + return r; + }; + + that.proc = function (z, r) { + let t; // temporary storage + let b; // bit buffer + let k; // bits in bit buffer + let p; // input data pointer + let n; // bytes available there + let q; // output window write pointer + let m; // bytes to end of window or read pointer + + let i; + + // copy input/output information to locals (UPDATE macro restores) + // { + p = z.next_in_index; + n = z.avail_in; + b = that.bitb; + k = that.bitk; + // } + // { + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + // } + + // process input based on current state + // DEBUG dtree + // eslint-disable-next-line no-constant-condition + while (true) { + let bl, bd, tl, td, bl_, bd_, tl_, td_; + switch (mode) { + case TYPE: + + while (k < (3)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + t = /* (int) */(b & 7); + last = t & 1; + + switch (t >>> 1) { + case 0: // stored + // { + b >>>= (3); + k -= (3); + // } + t = k & 7; // go to byte boundary + + // { + b >>>= (t); + k -= (t); + // } + mode = LENS; // get length of stored block + break; + case 1: // fixed + // { + bl = []; // new Array(1); + bd = []; // new Array(1); + tl = [[]]; // new Array(1); + td = [[]]; // new Array(1); + + InfTree.inflate_trees_fixed(bl, bd, tl, td); + codes.init(bl[0], bd[0], tl[0], 0, td[0], 0); + // } + + // { + b >>>= (3); + k -= (3); + // } + + mode = CODES; + break; + case 2: // dynamic + + // { + b >>>= (3); + k -= (3); + // } + + mode = TABLE; + break; + case 3: // illegal + + // { + b >>>= (3); + k -= (3); + // } + mode = BADBLOCKS; + z.msg = "invalid block type"; + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + break; + case LENS: + + while (k < (32)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + if ((((~b) >>> 16) & 0xffff) != (b & 0xffff)) { + mode = BADBLOCKS; + z.msg = "invalid stored block lengths"; + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + left = (b & 0xffff); + b = k = 0; // dump bits + mode = left !== 0 ? STORED$1 : (last !== 0 ? DRY : TYPE); + break; + case STORED$1: + if (n === 0) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + if (m === 0) { + if (q == that.end && that.read !== 0) { + q = 0; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + } + if (m === 0) { + that.write = q; + r = that.inflate_flush(z, r); + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + if (q == that.end && that.read !== 0) { + q = 0; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + } + if (m === 0) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + } + } + r = Z_OK$1; + + t = left; + if (t > n) + t = n; + if (t > m) + t = m; + that.window.set(z.read_buf(p, t), q); + p += t; + n -= t; + q += t; + m -= t; + if ((left -= t) !== 0) + break; + mode = last !== 0 ? DRY : TYPE; + break; + case TABLE: + + while (k < (14)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + table = t = (b & 0x3fff); + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) { + mode = BADBLOCKS; + z.msg = "too many length or distance symbols"; + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); + if (!blens || blens.length < t) { + blens = []; // new Array(t); + } else { + for (i = 0; i < t; i++) { + blens[i] = 0; + } + } + + // { + b >>>= (14); + k -= (14); + // } + + index = 0; + mode = BTREE; + /* falls through */ + case BTREE: + while (index < 4 + (table >>> 10)) { + while (k < (3)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + blens[border[index++]] = b & 7; + + // { + b >>>= (3); + k -= (3); + // } + } + + while (index < 19) { + blens[border[index++]] = 0; + } + + bb[0] = 7; + t = inftree.inflate_trees_bits(blens, bb, tb, hufts, z); + if (t != Z_OK$1) { + r = t; + if (r == Z_DATA_ERROR$1) { + blens = null; + mode = BADBLOCKS; + } + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + index = 0; + mode = DTREE; + /* falls through */ + case DTREE: + // eslint-disable-next-line no-constant-condition + while (true) { + t = table; + if (index >= 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) { + break; + } + + let j, c; + + t = bb[0]; + + while (k < (t)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + // if (tb[0] == -1) { + // System.err.println("null..."); + // } + + t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1]; + c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2]; + + if (c < 16) { + b >>>= (t); + k -= (t); + blens[index++] = c; + } else { // c == 16..18 + i = c == 18 ? 7 : c - 14; + j = c == 18 ? 11 : 3; + + while (k < (t + i)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + b >>>= (t); + k -= (t); + + j += (b & inflate_mask[i]); + + b >>>= (i); + k -= (i); + + i = index; + t = table; + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) { + blens = null; + mode = BADBLOCKS; + z.msg = "invalid bit length repeat"; + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + c = c == 16 ? blens[i - 1] : 0; + do { + blens[i++] = c; + } while (--j !== 0); + index = i; + } + } + + tb[0] = -1; + // { + bl_ = []; // new Array(1); + bd_ = []; // new Array(1); + tl_ = []; // new Array(1); + td_ = []; // new Array(1); + bl_[0] = 9; // must be <= 9 for lookahead assumptions + bd_[0] = 6; // must be <= 9 for lookahead assumptions + + t = table; + t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl_, bd_, tl_, td_, hufts, z); + + if (t != Z_OK$1) { + if (t == Z_DATA_ERROR$1) { + blens = null; + mode = BADBLOCKS; + } + r = t; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + codes.init(bl_[0], bd_[0], hufts, tl_[0], hufts, td_[0]); + // } + mode = CODES; + /* falls through */ + case CODES: + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + + if ((r = codes.proc(that, z, r)) != Z_STREAM_END$1) { + return that.inflate_flush(z, r); + } + r = Z_OK$1; + codes.free(z); + + p = z.next_in_index; + n = z.avail_in; + b = that.bitb; + k = that.bitk; + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + + if (last === 0) { + mode = TYPE; + break; + } + mode = DRY; + /* falls through */ + case DRY: + that.write = q; + r = that.inflate_flush(z, r); + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + if (that.read != that.write) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + mode = DONELOCKS; + /* falls through */ + case DONELOCKS: + r = Z_STREAM_END$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + case BADBLOCKS: + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + + default: + r = Z_STREAM_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + } + }; + + that.free = function (z) { + that.reset(z, null); + that.window = null; + hufts = null; + // ZFREE(z, s); + }; + + that.set_dictionary = function (d, start, n) { + that.window.set(d.subarray(start, start + n), 0); + that.read = that.write = n; + }; + + // Returns true if inflate is currently at the end of a block generated + // by Z_SYNC_FLUSH or Z_FULL_FLUSH. + that.sync_point = function () { + return mode == LENS ? 1 : 0; + }; + + } + + // Inflate + + // preset dictionary flag in zlib header + const PRESET_DICT$1 = 0x20; + + const Z_DEFLATED$1 = 8; + + const METHOD = 0; // waiting for method byte + const FLAG = 1; // waiting for flag byte + const DICT4 = 2; // four dictionary check bytes to go + const DICT3 = 3; // three dictionary check bytes to go + const DICT2 = 4; // two dictionary check bytes to go + const DICT1 = 5; // one dictionary check byte to go + const DICT0 = 6; // waiting for inflateSetDictionary + const BLOCKS = 7; // decompressing blocks + const DONE = 12; // finished check, done + const BAD = 13; // got an error--stay here + + const mark = [0, 0, 0xff, 0xff]; + + function Inflate() { + const that = this; + + that.mode = 0; // current inflate mode + + // mode dependent information + that.method = 0; // if FLAGS, method byte + + // if CHECK, check values to compare + that.was = [0]; // new Array(1); // computed check value + that.need = 0; // stream check value + + // if BAD, inflateSync's marker bytes count + that.marker = 0; + + // mode independent information + that.wbits = 0; // log2(window size) (8..15, defaults to 15) + + // this.blocks; // current inflate_blocks state + + function inflateReset(z) { + if (!z || !z.istate) + return Z_STREAM_ERROR$1; + + z.total_in = z.total_out = 0; + z.msg = null; + z.istate.mode = BLOCKS; + z.istate.blocks.reset(z, null); + return Z_OK$1; + } + + that.inflateEnd = function (z) { + if (that.blocks) + that.blocks.free(z); + that.blocks = null; + // ZFREE(z, z->state); + return Z_OK$1; + }; + + that.inflateInit = function (z, w) { + z.msg = null; + that.blocks = null; + + // set window size + if (w < 8 || w > 15) { + that.inflateEnd(z); + return Z_STREAM_ERROR$1; + } + that.wbits = w; + + z.istate.blocks = new InfBlocks(z, 1 << w); + + // reset state + inflateReset(z); + return Z_OK$1; + }; + + that.inflate = function (z, f) { + let r; + let b; + + if (!z || !z.istate || !z.next_in) + return Z_STREAM_ERROR$1; + const istate = z.istate; + f = f == Z_FINISH$1 ? Z_BUF_ERROR$1 : Z_OK$1; + r = Z_BUF_ERROR$1; + // eslint-disable-next-line no-constant-condition + while (true) { + switch (istate.mode) { + case METHOD: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + if (((istate.method = z.read_byte(z.next_in_index++)) & 0xf) != Z_DEFLATED$1) { + istate.mode = BAD; + z.msg = "unknown compression method"; + istate.marker = 5; // can't try inflateSync + break; + } + if ((istate.method >> 4) + 8 > istate.wbits) { + istate.mode = BAD; + z.msg = "invalid window size"; + istate.marker = 5; // can't try inflateSync + break; + } + istate.mode = FLAG; + /* falls through */ + case FLAG: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + b = (z.read_byte(z.next_in_index++)) & 0xff; + + if ((((istate.method << 8) + b) % 31) !== 0) { + istate.mode = BAD; + z.msg = "incorrect header check"; + istate.marker = 5; // can't try inflateSync + break; + } + + if ((b & PRESET_DICT$1) === 0) { + istate.mode = BLOCKS; + break; + } + istate.mode = DICT4; + /* falls through */ + case DICT4: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + istate.need = ((z.read_byte(z.next_in_index++) & 0xff) << 24) & 0xff000000; + istate.mode = DICT3; + /* falls through */ + case DICT3: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 16) & 0xff0000; + istate.mode = DICT2; + /* falls through */ + case DICT2: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 8) & 0xff00; + istate.mode = DICT1; + /* falls through */ + case DICT1: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + istate.need += (z.read_byte(z.next_in_index++) & 0xff); + istate.mode = DICT0; + return Z_NEED_DICT$1; + case DICT0: + istate.mode = BAD; + z.msg = "need dictionary"; + istate.marker = 0; // can try inflateSync + return Z_STREAM_ERROR$1; + case BLOCKS: + + r = istate.blocks.proc(z, r); + if (r == Z_DATA_ERROR$1) { + istate.mode = BAD; + istate.marker = 0; // can try inflateSync + break; + } + if (r == Z_OK$1) { + r = f; + } + if (r != Z_STREAM_END$1) { + return r; + } + r = f; + istate.blocks.reset(z, istate.was); + istate.mode = DONE; + /* falls through */ + case DONE: + return Z_STREAM_END$1; + case BAD: + return Z_DATA_ERROR$1; + default: + return Z_STREAM_ERROR$1; + } + } + }; + + that.inflateSetDictionary = function (z, dictionary, dictLength) { + let index = 0, length = dictLength; + if (!z || !z.istate || z.istate.mode != DICT0) + return Z_STREAM_ERROR$1; + const istate = z.istate; + if (length >= (1 << istate.wbits)) { + length = (1 << istate.wbits) - 1; + index = dictLength - length; + } + istate.blocks.set_dictionary(dictionary, index, length); + istate.mode = BLOCKS; + return Z_OK$1; + }; + + that.inflateSync = function (z) { + let n; // number of bytes to look at + let p; // pointer to bytes + let m; // number of marker bytes found in a row + let r, w; // temporaries to save total_in and total_out + + // set up + if (!z || !z.istate) + return Z_STREAM_ERROR$1; + const istate = z.istate; + if (istate.mode != BAD) { + istate.mode = BAD; + istate.marker = 0; + } + if ((n = z.avail_in) === 0) + return Z_BUF_ERROR$1; + p = z.next_in_index; + m = istate.marker; + + // search + while (n !== 0 && m < 4) { + if (z.read_byte(p) == mark[m]) { + m++; + } else if (z.read_byte(p) !== 0) { + m = 0; + } else { + m = 4 - m; + } + p++; + n--; + } + + // restore + z.total_in += p - z.next_in_index; + z.next_in_index = p; + z.avail_in = n; + istate.marker = m; + + // return no joy or set up to restart on a new block + if (m != 4) { + return Z_DATA_ERROR$1; + } + r = z.total_in; + w = z.total_out; + inflateReset(z); + z.total_in = r; + z.total_out = w; + istate.mode = BLOCKS; + return Z_OK$1; + }; + + // Returns true if inflate is currently at the end of a block generated + // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + // implementation to provide an additional safety check. PPP uses + // Z_SYNC_FLUSH + // but removes the length bytes of the resulting empty stored block. When + // decompressing, PPP checks that at the end of input packet, inflate is + // waiting for these length bytes. + that.inflateSyncPoint = function (z) { + if (!z || !z.istate || !z.istate.blocks) + return Z_STREAM_ERROR$1; + return z.istate.blocks.sync_point(); + }; + } + + // ZStream + + function ZStream$1() { + } + + ZStream$1.prototype = { + inflateInit: function (bits) { + const that = this; + that.istate = new Inflate(); + if (!bits) + bits = MAX_BITS$1; + return that.istate.inflateInit(that, bits); + }, + + inflate: function (f) { + const that = this; + if (!that.istate) + return Z_STREAM_ERROR$1; + return that.istate.inflate(that, f); + }, + + inflateEnd: function () { + const that = this; + if (!that.istate) + return Z_STREAM_ERROR$1; + const ret = that.istate.inflateEnd(that); + that.istate = null; + return ret; + }, + + inflateSync: function () { + const that = this; + if (!that.istate) + return Z_STREAM_ERROR$1; + return that.istate.inflateSync(that); + }, + inflateSetDictionary: function (dictionary, dictLength) { + const that = this; + if (!that.istate) + return Z_STREAM_ERROR$1; + return that.istate.inflateSetDictionary(that, dictionary, dictLength); + }, + read_byte: function (start) { + const that = this; + return that.next_in.subarray(start, start + 1)[0]; + }, + read_buf: function (start, size) { + const that = this; + return that.next_in.subarray(start, start + size); + } + }; + + // Inflater + + function ZipInflate() { + const that = this; + const z = new ZStream$1(); + const bufsize = 512; + const flush = Z_NO_FLUSH$1; + const buf = new Uint8Array(bufsize); + let nomoreinput = false; + + z.inflateInit(); + z.next_out = buf; + + that.append = function (data, onprogress) { + const buffers = []; + let err, array, lastIndex = 0, bufferIndex = 0, bufferSize = 0; + if (data.length === 0) + return; + z.next_in_index = 0; + z.next_in = data; + z.avail_in = data.length; + do { + z.next_out_index = 0; + z.avail_out = bufsize; + if ((z.avail_in === 0) && (!nomoreinput)) { // if buffer is empty and more input is available, refill it + z.next_in_index = 0; + nomoreinput = true; + } + err = z.inflate(flush); + if (nomoreinput && (err === Z_BUF_ERROR$1)) { + if (z.avail_in !== 0) + throw new Error("inflating: bad input"); + } else if (err !== Z_OK$1 && err !== Z_STREAM_END$1) + throw new Error("inflating: " + z.msg); + if ((nomoreinput || err === Z_STREAM_END$1) && (z.avail_in === data.length)) + throw new Error("inflating: bad input"); + if (z.next_out_index) + if (z.next_out_index === bufsize) + buffers.push(new Uint8Array(buf)); + else + buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); + bufferSize += z.next_out_index; + if (onprogress && z.next_in_index > 0 && z.next_in_index != lastIndex) { + onprogress(z.next_in_index); + lastIndex = z.next_in_index; + } + } while (z.avail_in > 0 || z.avail_out === 0); + array = new Uint8Array(bufferSize); + buffers.forEach(function (chunk) { + array.set(chunk, bufferIndex); + bufferIndex += chunk.length; + }); + return array; + }; + that.flush = function () { + z.inflateEnd(); + }; + } + /* Copyright (c) 2021 Gildas Lormeau. All rights reserved. @@ -378,12 +4584,12 @@ const COMPRESSION_METHOD_STORE = 0x00; const COMPRESSION_METHOD_AES = 0x63; - const LOCAL_FILE_HEADER_SIGNATURE = 0x504b0304; - const DATA_DESCRIPTOR_RECORD_SIGNATURE = 0x504b0708; - const CENTRAL_FILE_HEADER_SIGNATURE = 0x504b0102; - const END_OF_CENTRAL_DIR_SIGNATURE = 0x504b0506; - const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x504b0606; - const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x504b0607; + const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50; + const DATA_DESCRIPTOR_RECORD_SIGNATURE = 0x08074b50; + const CENTRAL_FILE_HEADER_SIGNATURE = 0x02014b50; + const END_OF_CENTRAL_DIR_SIGNATURE = 0x06054b50; + const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x06064b50; + const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x07064b50; const END_OF_CENTRAL_DIR_LENGTH = 22; const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH = 20; const ZIP64_END_OF_CENTRAL_DIR_LENGTH = 56; @@ -739,14 +4945,14 @@ const CODEC_INFLATE = "inflate"; const ERR_INVALID_SIGNATURE = "Invalid signature"; - class Inflate { + class Inflate$1 { constructor(options) { this.signature = options.inputSignature; this.encrypted = Boolean(options.inputPassword); this.signed = options.inputSigned; this.compressed = options.inputCompressed; - this.inflate = this.compressed && new ZipInflate(); + this.inflate = this.compressed && new options.codecConstructor(); this.crc32 = this.signed && this.signed && new Crc32(); this.decrypt = this.encrypted && new ZipDecrypt(options.inputPassword); } @@ -788,13 +4994,13 @@ } } - class Deflate { + class Deflate$1 { constructor(options) { this.encrypted = options.outputEncrypted; this.signed = options.outputSigned; this.compressed = options.outputCompressed; - this.deflate = this.compressed && new ZipDeflate({ level: options.level || 5 }); + this.deflate = this.compressed && new options.codecConstructor({ level: options.level || 5 }); this.crc32 = this.signed && new Crc32(); this.encrypt = this.encrypted && new ZipEncrypt(options.outputPassword); } @@ -834,9 +5040,9 @@ function createCodec(options) { if (options.codecType.startsWith(CODEC_DEFLATE)) { - return new Deflate(options); + return new Deflate$1(options); } else if (options.codecType.startsWith(CODEC_INFLATE)) { - return new Inflate(options); + return new Inflate$1(options); } } @@ -875,8 +5081,8 @@ const Z_WORKER_SCRIPT_PATH = "z-worker.js"; const DEFAULT_WORKER_SCRIPTS = { - deflate: [Z_WORKER_SCRIPT_PATH, "deflate.js"], - inflate: [Z_WORKER_SCRIPT_PATH, "inflate.js"] + deflate: [Z_WORKER_SCRIPT_PATH], + inflate: [Z_WORKER_SCRIPT_PATH] }; const workers = { pool: [], @@ -958,8 +5164,24 @@ async function initAndSendMessage(message) { if (!task) { + const options = workerData.options; const scripts = workerData.scripts.slice(1); - await sendMessage(Object.assign({ type: MESSAGE_INIT, options: workerData.options, scripts })); + await sendMessage(Object.assign({ + scripts, + type: MESSAGE_INIT, options: { + codecType: options.codecType, + inputPassword: options.inputPassword, + inputSigned: options.inputSigned, + inputSignature: options.signature, + inputCompressed: options.inputCompressed, + inputEncrypted: options.inputEncrypted, + level: options.level, + outputPassword: options.outputPassword, + outputSigned: options.outputSigned, + outputCompressed: options.outputCompressed, + outputEncrypted: options.outputEncrypted + } + })); } return sendMessage(message); } @@ -1153,23 +5375,23 @@ } const endOfDirectoryView = new DataView(endOfDirectoryInfo.buffer); let zip64; - let directoryDataOffset = endOfDirectoryView.getUint32(16, true); - let filesLength = endOfDirectoryView.getUint16(8, true); + let directoryDataOffset = getUint32(endOfDirectoryView, 16); + let filesLength = getUint16(endOfDirectoryView, 8); if (directoryDataOffset == MAX_32_BITS || filesLength == MAX_16_BITS) { zip64 = true; const endOfDirectoryLocatorArray = await reader.readUint8Array(endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH); const endOfDirectoryLocatorView = new DataView(endOfDirectoryLocatorArray.buffer); - if (Number(endOfDirectoryLocatorView.getUint32(0, false)) != ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) { + if (Number(getUint32(endOfDirectoryLocatorView, 0)) != ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) { throw new Error(ERR_EOCDR_ZIP64_NOT_FOUND); } - directoryDataOffset = Number(endOfDirectoryLocatorView.getBigUint64(8, true)); + directoryDataOffset = Number(getBigUint64(endOfDirectoryLocatorView, 8)); const endOfDirectoryArray = await reader.readUint8Array(directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH); const endOfDirectoryView = new DataView(endOfDirectoryArray.buffer); - if (Number(endOfDirectoryView.getUint32(0, false)) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) { + if (Number(getUint32(endOfDirectoryView, 0)) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) { throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND); } - filesLength = Number(endOfDirectoryView.getBigUint64(24, true)); - directoryDataOffset -= Number(endOfDirectoryView.getBigUint64(40, true)); + filesLength = Number(getBigUint64(endOfDirectoryView, 24)); + directoryDataOffset -= Number(getBigUint64(endOfDirectoryView, 40)); } if (directoryDataOffset < 0 || (!zip64 && (directoryDataOffset >= reader.size || filesLength >= MAX_16_BITS))) { throw new Error(ERR_BAD_FORMAT); @@ -1180,15 +5402,15 @@ let offset = 0; for (let indexFile = 0; indexFile < filesLength; indexFile++) { const fileEntry = new Entry(this.reader, this.config, this.options); - if (directoryView.getUint32(offset, false) != CENTRAL_FILE_HEADER_SIGNATURE) { + if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) { throw new Error(ERR_CENTRAL_DIRECTORY_NOT_FOUND); } fileEntry.compressedSize = 0; fileEntry.uncompressedSize = 0; readCommonHeader(fileEntry, directoryView, offset + 6); - fileEntry.commentLength = directoryView.getUint16(offset + 32, true); - fileEntry.directory = ((directoryView.getUint8(offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK); - fileEntry.offset = directoryView.getUint32(offset + 42, true); + fileEntry.commentLength = getUint16(directoryView, offset + 32); + fileEntry.directory = (getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK; + fileEntry.offset = getUint32(directoryView, offset + 42); fileEntry.rawFilename = directoryArray.subarray(offset + 46, offset + 46 + fileEntry.filenameLength); const filenameEncoding = options.filenameEncoding === undefined ? this.options.filenameEncoding : options.filenameEncoding; fileEntry.filename = decodeString(fileEntry.rawFilename, fileEntry.bitFlag.languageEncodingFlag ? CHARSET_UTF8 : filenameEncoding); @@ -1239,7 +5461,7 @@ if (this.compressionMethod != COMPRESSION_METHOD_STORE && this.compressionMethod != COMPRESSION_METHOD_DEFLATE) { throw new Error(ERR_UNSUPPORTED_COMPRESSION); } - if (dataView.getUint32(0, false) != LOCAL_FILE_HEADER_SIGNATURE) { + if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) { throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND); } const localDirectory = this.localDirectory = {}; @@ -1253,6 +5475,7 @@ } const codec = await createWorkerCodec(this.config, { codecType: CODEC_INFLATE, + codecConstructor: this.config.Inflate, inputPassword, inputSigned: options.checkSignature === undefined ? this.options.checkSignature : options.checkSignature, inputSignature: this.signature, @@ -1269,8 +5492,8 @@ } function readCommonHeader(directory, dataView, offset) { - directory.version = dataView.getUint16(offset, true); - const rawBitFlag = directory.rawBitFlag = dataView.getUint16(offset + 2, true); + directory.version = getUint16(dataView, offset); + const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2); directory.bitFlag = { encrypted: (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED, level: (rawBitFlag & BITFLAG_LEVEL) >> 1, @@ -1278,10 +5501,10 @@ languageEncodingFlag: (rawBitFlag & BITFLAG_LANG_ENCODING_FLAG) == BITFLAG_LANG_ENCODING_FLAG }; directory.encrypted = directory.bitFlag.encrypted; - directory.rawLastModDate = dataView.getUint32(offset + 6, true); + directory.rawLastModDate = getUint32(dataView, offset + 6); directory.lastModDate = getDate(directory.rawLastModDate); - directory.filenameLength = dataView.getUint16(offset + 22, true); - directory.extraFieldLength = dataView.getUint16(offset + 24, true); + directory.filenameLength = getUint16(dataView, offset + 22); + directory.extraFieldLength = getUint16(dataView, offset + 24); } function readCommonFooter(fileEntry, directory, dataView, offset) { @@ -1291,8 +5514,8 @@ let offsetExtraField = 0; try { while (offsetExtraField < rawExtraField.length) { - const type = rawExtraFieldView.getUint16(offsetExtraField, true); - const size = rawExtraFieldView.getUint16(offsetExtraField + 2, true); + const type = getUint16(rawExtraFieldView, offsetExtraField); + const size = getUint16(rawExtraFieldView, offsetExtraField + 2); extraField.set(type, { type, data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size) @@ -1302,10 +5525,10 @@ } catch (error) { // ignored } - const compressionMethod = dataView.getUint16(offset + 4, true); - directory.signature = dataView.getUint32(offset + 10, true); - directory.uncompressedSize = dataView.getUint32(offset + 18, true); - directory.compressedSize = dataView.getUint32(offset + 14, true); + const compressionMethod = getUint16(dataView, offset + 4); + directory.signature = getUint32(dataView, offset + 10); + directory.uncompressedSize = getUint32(dataView, offset + 18); + directory.compressedSize = getUint32(dataView, offset + 14); const extraFieldZip64 = directory.extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64); if (extraFieldZip64) { readExtraFieldZip64(extraFieldZip64, directory); @@ -1334,7 +5557,7 @@ const extraFieldView = new DataView(extraFieldZip64.data.buffer); extraFieldZip64.values = []; for (let indexValue = 0; indexValue < Math.floor(extraFieldZip64.data.length / 8); indexValue++) { - extraFieldZip64.values.push(Number(extraFieldView.getBigUint64(0 + indexValue * 8, true))); + extraFieldZip64.values.push(Number(getBigUint64(extraFieldView, 0 + indexValue * 8))); } const missingProperties = ZIP64_PROPERTIES.filter(propertyName => directory[propertyName] == MAX_32_BITS); for (let indexMissingProperty = 0; indexMissingProperty < missingProperties.length; indexMissingProperty++) { @@ -1353,14 +5576,14 @@ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) { const extraFieldView = new DataView(extraFieldUnicode.data.buffer); - extraFieldUnicode.version = extraFieldView.getUint8(0); - extraFieldUnicode.signature = extraFieldView.getUint32(1, true); + extraFieldUnicode.version = getUint8(extraFieldView, 0); + extraFieldUnicode.signature = getUint32(extraFieldView, 1); const crc32 = new Crc32(); crc32.append(fileEntry[rawPropertyName]); const dataViewSignature = new DataView(new Uint8Array(4).buffer); dataViewSignature.setUint32(0, crc32.get()); extraFieldUnicode[propertyName] = (new TextDecoder()).decode(extraFieldUnicode.data.subarray(5)); - if (!fileEntry.bitFlag.languageEncodingFlag && extraFieldUnicode.signature == dataViewSignature.getUint32(0, false)) { + if (!fileEntry.bitFlag.languageEncodingFlag && extraFieldUnicode.signature == getUint32(dataViewSignature, 0)) { directory[propertyName] = extraFieldUnicode[propertyName]; } } @@ -1368,12 +5591,12 @@ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) { if (extraFieldAES) { const extraFieldView = new DataView(extraFieldAES.data.buffer); - extraFieldAES.vendorVersion = extraFieldView.getUint8(0); - extraFieldAES.vendorId = extraFieldView.getUint8(2); - const strength = extraFieldView.getUint8(4); + extraFieldAES.vendorVersion = getUint8(extraFieldView, 0); + extraFieldAES.vendorId = getUint8(extraFieldView, 2); + const strength = getUint8(extraFieldView, 4); extraFieldAES.strength = strength; extraFieldAES.originalCompressionMethod = compressionMethod; - directory.compressionMethod = extraFieldAES.compressionMethod = extraFieldView.getUint16(5, true); + directory.compressionMethod = extraFieldAES.compressionMethod = getUint16(extraFieldView, 5); } else { directory.compressionMethod = compressionMethod; } @@ -1382,7 +5605,7 @@ async function seekSignature(reader, signature, minimumBytes, maximumLength) { const signatureArray = new Uint8Array(4); const signatureView = new DataView(signatureArray.buffer); - signatureView.setUint32(0, signature); + setUint32(signatureView, 0, signature); if (reader.size < minimumBytes) { throw new Error(ERR_BAD_FORMAT); } @@ -1430,6 +5653,26 @@ } } + function getUint8(view, offset) { + return view.getUint8(offset); + } + + function getUint16(view, offset) { + return view.getUint16(offset, true); + } + + function getUint32(view, offset) { + return view.getUint32(offset, true); + } + + function getBigUint64(view, offset) { + return view.getBigUint64(offset, true); + } + + function setUint32(view, offset, value) { + view.setUint32(offset, value, true); + } + /* Copyright (c) 2021 Gildas Lormeau. All rights reserved. @@ -1478,7 +5721,6 @@ this.config = config; this.files = new Map(); this.offset = writer.size; - this.zip64 = options.zip64; } async add(name = "", reader, options = {}) { @@ -1527,11 +5769,11 @@ offset += 4 + data.length; }); } - let zip64 = options.zip64 || this.zip64; - if (this.offset >= MAX_32_BITS || (reader && (reader.size >= MAX_32_BITS || this.offset + reader.size >= MAX_32_BITS))) { - zip64 = true; - } - await addFile(this, name, reader, Object.assign({}, options, { rawFilename, rawComment, version, lastModDate, rawExtraField, zip64 })); + const zip64 = options.zip64 || this.options.zip64 || this.offset >= MAX_32_BITS || (reader && (reader.size >= MAX_32_BITS || this.offset + reader.size >= MAX_32_BITS)); + const password = options.password === undefined ? this.options.password : options.password; + const level = options.level === undefined ? this.options.level : options.level; + const useWebWorkers = options.useWebWorkers === undefined ? this.options.useWebWorkers : options.useWebWorkers; + await addFile(this, name, reader, Object.assign({}, options, { rawFilename, rawComment, version, lastModDate, rawExtraField, zip64, password, level, useWebWorkers })); } async close(comment = new Uint8Array(0)) { @@ -1540,7 +5782,7 @@ let offset = 0, directoryDataLength = 0, directoryOffset = this.offset, filesLength = files.size; if (comment.length) { if (comment.length <= MAX_16_BITS) { - directoryView.setUint16(offset + 20, comment.length, true); + setUint16(directoryView, offset + 20, comment.length); } else { throw new Error(ERR_INVALID_COMMENT); } @@ -1548,28 +5790,26 @@ for (const [, fileEntry] of files) { directoryDataLength += 46 + fileEntry.rawFilename.length + fileEntry.rawComment.length + fileEntry.extraFieldZip64.length + fileEntry.extraFieldAES.length + fileEntry.rawExtraField.length; } - if (directoryOffset + directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS) { - this.zip64 = true; - } - const directoryArray = new Uint8Array(directoryDataLength + (this.zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH)); + const zip64 = this.options.zip64 || directoryOffset + directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS; + const directoryArray = new Uint8Array(directoryDataLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH)); const directoryView = new DataView(directoryArray.buffer); for (const [, fileEntry] of files) { const rawFilename = fileEntry.rawFilename; const extraFieldZip64 = fileEntry.extraFieldZip64; const extraFieldAES = fileEntry.extraFieldAES; const extraFieldLength = extraFieldZip64.length + extraFieldAES.length + fileEntry.rawExtraField.length; - directoryView.setUint32(offset, CENTRAL_FILE_HEADER_SIGNATURE); - directoryView.setUint16(offset + 4, fileEntry.version, true); + setUint32$1(directoryView, offset, CENTRAL_FILE_HEADER_SIGNATURE); + setUint16(directoryView, offset + 4, fileEntry.version); directoryArray.set(fileEntry.headerArray, offset + 6); - directoryView.setUint16(offset + 30, extraFieldLength, true); - directoryView.setUint16(offset + 32, fileEntry.rawComment.length, true); + setUint16(directoryView, offset + 30, extraFieldLength); + setUint16(directoryView, offset + 32, fileEntry.rawComment.length); if (fileEntry.directory) { - directoryView.setUint8(offset + 38, FILE_ATTR_MSDOS_DIR_MASK); + setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK); } if (fileEntry.zip64) { - directoryView.setUint32(offset + 42, MAX_32_BITS, true); + setUint32$1(directoryView, offset + 42, MAX_32_BITS); } else { - directoryView.setUint32(offset + 42, fileEntry.offset, true); + setUint32$1(directoryView, offset + 42, fileEntry.offset); } directoryArray.set(rawFilename, offset + 46); directoryArray.set(extraFieldZip64, offset + 46 + rawFilename.length); @@ -1578,27 +5818,27 @@ directoryArray.set(fileEntry.rawComment, offset + 46 + rawFilename.length + extraFieldLength); offset += 46 + rawFilename.length + extraFieldLength + fileEntry.rawComment.length; } - if (this.zip64) { - directoryView.setUint32(offset, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE); - directoryView.setBigUint64(offset + 4, BigInt(44), true); - directoryView.setUint16(offset + 12, 45, true); - directoryView.setUint16(offset + 14, 45, true); - directoryView.setBigUint64(offset + 24, BigInt(filesLength), true); - directoryView.setBigUint64(offset + 32, BigInt(filesLength), true); - directoryView.setBigUint64(offset + 40, BigInt(directoryDataLength), true); - directoryView.setBigUint64(offset + 48, BigInt(directoryOffset), true); - directoryView.setUint32(offset + 56, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE); - directoryView.setBigUint64(offset + 64, BigInt(directoryOffset + directoryDataLength), true); - directoryView.setUint32(offset + 72, ZIP64_TOTAL_NUMBER_OF_DISKS, true); + if (zip64) { + setUint32$1(directoryView, offset, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE); + setBigUint64(directoryView, offset + 4, BigInt(44)); + setUint16(directoryView, offset + 12, 45); + setUint16(directoryView, offset + 14, 45); + setBigUint64(directoryView, offset + 24, BigInt(filesLength)); + setBigUint64(directoryView, offset + 32, BigInt(filesLength)); + setBigUint64(directoryView, offset + 40, BigInt(directoryDataLength)); + setBigUint64(directoryView, offset + 48, BigInt(directoryOffset)); + setUint32$1(directoryView, offset + 56, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE); + setBigUint64(directoryView, offset + 64, BigInt(directoryOffset + directoryDataLength)); + setUint32$1(directoryView, offset + 72, ZIP64_TOTAL_NUMBER_OF_DISKS); filesLength = MAX_16_BITS; directoryOffset = MAX_32_BITS; offset += 76; } - directoryView.setUint32(offset, END_OF_CENTRAL_DIR_SIGNATURE); - directoryView.setUint16(offset + 8, filesLength, true); - directoryView.setUint16(offset + 10, filesLength, true); - directoryView.setUint32(offset + 12, directoryDataLength, true); - directoryView.setUint32(offset + 16, directoryOffset, true); + setUint32$1(directoryView, offset, END_OF_CENTRAL_DIR_SIGNATURE); + setUint16(directoryView, offset + 8, filesLength); + setUint16(directoryView, offset + 10, filesLength); + setUint32$1(directoryView, offset + 12, directoryDataLength); + setUint32$1(directoryView, offset + 16, directoryOffset); await writer.writeUint8Array(directoryArray); await writer.writeUint8Array(comment); return writer.getData(); @@ -1622,8 +5862,7 @@ } fileWriter = writer; } - - fileEntry = await createFileEntry(name, reader, fileWriter, zipWriter.config, zipWriter.options, options); + fileEntry = await createFileEntry(reader, fileWriter, zipWriter.config, options); } catch (error) { files.delete(name); throw error; @@ -1638,7 +5877,7 @@ fileEntry.offset = zipWriter.offset; if (fileEntry.zip64) { const extraFieldZip64View = new DataView(fileEntry.extraFieldZip64.buffer); - extraFieldZip64View.setBigUint64(20, BigInt(fileEntry.offset), true); + setBigUint64(extraFieldZip64View, 20, BigInt(fileEntry.offset)); } zipWriter.offset += fileEntry.length; } finally { @@ -1649,22 +5888,19 @@ } } - async function createFileEntry(filename, reader, writer, config, zipWriterOptions, options) { + async function createFileEntry(reader, writer, config, options) { const rawFilename = options.rawFilename; - const date = options.lastModDate; - const headerArray = new Uint8Array(26); - const headerView = new DataView(headerArray.buffer); - const password = options.password === undefined ? zipWriterOptions.password : options.password; - const outputPassword = password && password.length && password; - const level = options.level === undefined ? zipWriterOptions.level : options.level; - const compressed = level !== 0 && !options.directory; - const outputSigned = password === undefined || !password.length; + const lastModDate = options.lastModDate; + const outputPassword = options.password; + const outputEncrypted = outputPassword && outputPassword.length; + const level = options.level; + const outputCompressed = level !== 0 && !options.directory; const zip64 = options.zip64; let extraFieldAES; - if (outputPassword) { + if (outputEncrypted) { extraFieldAES = new Uint8Array(EXTRAFIELD_DATA_AES.length + 2); const extraFieldAESView = new DataView(extraFieldAES.buffer); - extraFieldAESView.setUint16(0, EXTRAFIELD_TYPE_AES, true); + setUint16(extraFieldAESView, 0, EXTRAFIELD_TYPE_AES); extraFieldAES.set(EXTRAFIELD_DATA_AES, 2); } else { extraFieldAES = new Uint8Array(0); @@ -1672,11 +5908,8 @@ const fileEntry = { version: options.version || VERSION_DEFLATE, zip64, - headerArray: headerArray, directory: options.directory, - filename, rawFilename, - comment: options.comment, rawComment: options.rawComment, extraFieldZip64: zip64 ? new Uint8Array(EXTRAFIELD_LENGTH_ZIP64 + 4) : new Uint8Array(0), extraFieldAES, @@ -1684,73 +5917,76 @@ }; let bitFlag = BITFLAG_DATA_DESCRIPTOR | BITFLAG_LANG_ENCODING_FLAG; let compressionMethod = COMPRESSION_METHOD_STORE; - if (compressed) { + if (outputCompressed) { compressionMethod = COMPRESSION_METHOD_DEFLATE; } if (zip64) { fileEntry.version = fileEntry.version > VERSION_ZIP64 ? fileEntry.version : VERSION_ZIP64; } - if (outputPassword) { - fileEntry.encrypted = true; + if (outputEncrypted) { fileEntry.version = fileEntry.version > VERSION_AES ? fileEntry.version : VERSION_AES; bitFlag = bitFlag | BITFLAG_ENCRYPTED; compressionMethod = COMPRESSION_METHOD_AES; - if (compressed) { + if (outputCompressed) { fileEntry.extraFieldAES[9] = COMPRESSION_METHOD_DEFLATE; } } - headerView.setUint16(0, fileEntry.version, true); - headerView.setUint16(2, bitFlag, true); - headerView.setUint16(4, compressionMethod, true); - headerView.setUint16(6, (((date.getHours() << 6) | date.getMinutes()) << 5) | date.getSeconds() / 2, true); - headerView.setUint16(8, ((((date.getFullYear() - 1980) << 4) | (date.getMonth() + 1)) << 5) | date.getDate(), true); - headerView.setUint16(22, rawFilename.length, true); - headerView.setUint16(24, 0, true); + const headerArray = fileEntry.headerArray = new Uint8Array(26); + const headerView = new DataView(headerArray.buffer); + setUint16(headerView, 0, fileEntry.version); + setUint16(headerView, 2, bitFlag); + setUint16(headerView, 4, compressionMethod); + setUint16(headerView, 6, (((lastModDate.getHours() << 6) | lastModDate.getMinutes()) << 5) | lastModDate.getSeconds() / 2); + setUint16(headerView, 8, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate()); + setUint16(headerView, 22, rawFilename.length); + setUint16(headerView, 24, 0); const fileDataArray = new Uint8Array(30 + rawFilename.length); const fileDataView = new DataView(fileDataArray.buffer); - fileDataView.setUint32(0, LOCAL_FILE_HEADER_SIGNATURE); + setUint32$1(fileDataView, 0, LOCAL_FILE_HEADER_SIGNATURE); fileDataArray.set(headerArray, 4); fileDataArray.set(rawFilename, 30); - let result; + let result, unCompressedSize, compressedSize; if (reader) { + unCompressedSize = reader.size; const codec = await createWorkerCodec(config, { codecType: CODEC_DEFLATE, + codecConstructor: config.Deflate, level, - outputPassword: password, - outputSigned, - outputCompressed: compressed, - outputEncrypted: Boolean(password), - useWebWorkers: options.useWebWorkers === undefined ? zipWriterOptions.useWebWorkers : options.useWebWorkers + outputPassword, + outputSigned: true, + outputCompressed, + outputEncrypted, + useWebWorkers: options.useWebWorkers }); await writer.writeUint8Array(fileDataArray); - result = await processData(codec, reader, writer, 0, reader.size, config, { onprogress: options.onprogress }); - fileEntry.compressedSize = result.length; + result = await processData(codec, reader, writer, 0, unCompressedSize, config, { onprogress: options.onprogress }); + compressedSize = result.length; } else { await writer.writeUint8Array(fileDataArray); } const footerArray = new Uint8Array(zip64 ? 24 : 16); const footerView = new DataView(footerArray.buffer); - footerView.setUint32(0, DATA_DESCRIPTOR_RECORD_SIGNATURE); + setUint32$1(footerView, 0, DATA_DESCRIPTOR_RECORD_SIGNATURE); if (reader) { - if (!outputPassword && result.signature !== undefined) { - headerView.setUint32(10, result.signature, true); - footerView.setUint32(4, result.signature, true); + if (!outputEncrypted && result.signature !== undefined) { + setUint32$1(headerView, 10, result.signature); + setUint32$1(footerView, 4, result.signature); } if (zip64) { - headerView.setUint32(14, MAX_32_BITS, true); - footerView.setBigUint64(8, BigInt(fileEntry.compressedSize), true); - headerView.setUint32(18, MAX_32_BITS, true); - footerView.setBigUint64(16, BigInt(reader.size), true); const extraFieldZip64View = new DataView(fileEntry.extraFieldZip64.buffer); - extraFieldZip64View.setUint16(0, EXTRAFIELD_TYPE_ZIP64, true); - extraFieldZip64View.setUint16(2, EXTRAFIELD_LENGTH_ZIP64, true); - extraFieldZip64View.setBigUint64(4, BigInt(reader.size), true); - extraFieldZip64View.setBigUint64(12, BigInt(fileEntry.compressedSize), true); + setUint16(extraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64); + setUint16(extraFieldZip64View, 2, EXTRAFIELD_LENGTH_ZIP64); + setUint32$1(headerView, 14, MAX_32_BITS); + setBigUint64(footerView, 8, BigInt(compressedSize)); + setBigUint64(extraFieldZip64View, 12, BigInt(compressedSize)); + setUint32$1(headerView, 18, MAX_32_BITS); + setBigUint64(footerView, 16, BigInt(unCompressedSize)); + setBigUint64(extraFieldZip64View, 4, BigInt(unCompressedSize)); } else { - headerView.setUint32(14, fileEntry.compressedSize, true); - footerView.setUint32(8, fileEntry.compressedSize, true); - headerView.setUint32(18, reader.size, true); - footerView.setUint32(12, reader.size, true); + setUint32$1(headerView, 14, compressedSize); + setUint32$1(footerView, 8, compressedSize); + setUint32$1(headerView, 18, unCompressedSize); + setUint32$1(footerView, 12, unCompressedSize); } } await writer.writeUint8Array(footerArray); @@ -1758,12 +5994,28 @@ return fileEntry; } + function setUint8(view, offset, value) { + view.setUint8(offset, value); + } + + function setUint16(view, offset, value) { + view.setUint16(offset, value, true); + } + + function setUint32$1(view, offset, value) { + view.setUint32(offset, value, true); + } + + function setBigUint64(view, offset, value) { + view.setBigUint64(offset, value, true); + } + const FUNCTION_TYPE = "function"; var streamCodecShim = (library, options = {}) => { return { - ZipDeflate: createCodecClass(library.Deflate, options.deflate), - ZipInflate: createCodecClass(library.Inflate, options.inflate) + Deflate: createCodecClass(library.Deflate, options.deflate), + Inflate: createCodecClass(library.Inflate, options.inflate) }; }; @@ -1842,7 +6094,9 @@ chunkSize: 512 * 1024, maxWorkers: (typeof navigator != "undefined" && navigator.hardwareConcurrency) || 2, workerScriptsPath: undefined, - useWebWorkers: true + useWebWorkers: true, + Deflate: ZipDeflate, + Inflate: ZipInflate }; let config = Object.assign({}, DEFAULT_CONFIGURATION); diff --git a/dist/zip-fs.min.js b/dist/zip-fs.min.js index 76d91be1..6beb7cd1 100644 --- a/dist/zip-fs.min.js +++ b/dist/zip-fs.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).zip={})}(this,(function(t){"use strict";const e="HTTP error ",n="HTTP Range not supported",r="text/plain";class i{constructor(){this.size=0}init(){this.initialized=!0}}class s extends i{}class a extends i{writeUint8Array(t){this.size+=t.length}}class o extends s{constructor(t){super(),this.blobReader=new l(new Blob([t],{type:r}))}init(){super.init(),this.blobReader.init(),this.size=this.blobReader.size}readUint8Array(t,e){return this.blobReader.readUint8Array(t,e)}}class c extends a{constructor(t){super(),this.encoding=t,this.blob=new Blob([],{type:r})}writeUint8Array(t){super.writeUint8Array(t),this.blob=new Blob([this.blob,t.buffer],{type:r})}getData(){const t=new FileReader;return new Promise(((e,n)=>{t.onload=t=>e(t.target.result),t.onerror=n,t.readAsText(this.blob,this.encoding)}))}}class h extends s{constructor(t){super(),this.dataURI=t;let e=t.length;for(;"="==t.charAt(e-1);)e--;this.dataStart=t.indexOf(",")+1,this.size=Math.floor(.75*(e-this.dataStart))}readUint8Array(t,e){const n=new Uint8Array(e),r=4*Math.floor(t/3),i=atob(this.dataURI.substring(r+this.dataStart,4*Math.ceil((t+e)/3)+this.dataStart)),s=t-3*Math.floor(r/4);for(let t=s;t2?this.data+=btoa(n):this.pending=n}getData(){return this.data+btoa(this.pending)}}class l extends s{constructor(t){super(),this.blob=t,this.size=t.size}readUint8Array(t,e){const n=new FileReader;return new Promise(((r,i)=>{n.onload=t=>r(new Uint8Array(t.target.result)),n.onerror=i,n.readAsArrayBuffer(this.blob.slice(t,t+e))}))}}class u extends a{constructor(t){super(),this.offset=0,this.contentType=t,this.blob=new Blob([],{type:t})}writeUint8Array(t){super.writeUint8Array(t),this.blob=new Blob([this.blob,t.buffer],{type:this.contentType}),this.offset=this.blob.size}getData(){return this.blob}}class p extends s{constructor(t){super(),this.url=t}async init(){if(super.init(),function(t){if("undefined"!=typeof document){const e=document.createElement("a");return e.href=t,"http:"==e.protocol||"https:"==e.protocol}return/^https?:\/\//i.test(t)}(this.url))return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.addEventListener("load",(()=>{r.status<400?(this.size=Number(r.getResponseHeader("Content-Length")),this.size?t():f().then((()=>t())).catch(n)):n(e+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",n,!1),r.open("HEAD",this.url),r.send()}));await f()}async readUint8Array(t,e){return this.data||await f(this,this.url),new Uint8Array(this.data.subarray(t,t+e))}}class w extends s{constructor(t){super(),this.url=t}init(){return super.init(),new Promise(((t,r)=>{const i=new XMLHttpRequest;i.addEventListener("load",(()=>{i.status<400?(this.size=Number(i.getResponseHeader("Content-Length")),"bytes"==i.getResponseHeader("Accept-Ranges")?t():r(new Error(n))):r(e+(i.statusText||i.status)+".")}),!1),i.addEventListener("error",r,!1),i.open("HEAD",this.url),i.send()}))}readUint8Array(t,n){return new Promise(((r,i)=>{const s=new XMLHttpRequest;s.open("GET",this.url),s.responseType="arraybuffer",s.setRequestHeader("Range","bytes="+t+"-"+(t+n-1)),s.addEventListener("load",(()=>{s.status<400?r(new Uint8Array(s.response)):i(e+(s.statusText||s.status)+".")}),!1),s.addEventListener("error",i,!1),s.send()}))}}class g extends a{constructor(){super(),this.array=new Uint8Array(0)}writeUint8Array(t){super.writeUint8Array(t);const e=this.array;this.array=new Uint8Array(e.length+t.length),this.array.set(e),this.array.set(t,e.length)}getData(){return this.array}}function f(t,n){return new Promise(((r,i)=>{const s=new XMLHttpRequest;s.addEventListener("load",(()=>{s.status<400?(t.size||(t.size=Number(s.getResponseHeader("Content-Length"))||Number(s.response.byteLength)),t.data=new Uint8Array(s.response),r()):i(e+(s.statusText||s.status)+".")}),!1),s.addEventListener("error",i,!1),s.open("GET",n),s.responseType="arraybuffer",s.send()}))}const y=4294967295,m=65535,U=1347093252,b=1347094280,E=1347092738,A=1347093766,R=1347094022,D=1347094023,x=39169,F=2048;class z{constructor(){this.crc=-1,this.table=(()=>{const t=[];for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)1&n?n=n>>>1^3988292384:n>>>=1;t[e]=n}return t})()}append(t){const e=this.table;let n=0|this.crc;for(let r=0,i=0|t.length;r>>8^e[255&(n^t[r])];this.crc=n}get(){return~this.crc}}const S="Invalid pasword",I=16,v="raw",T={name:"PBKDF2"},B={name:"HMAC"},L="SHA-1",_={name:"AES-CTR"},k=Object.assign({hash:B},T),C=Object.assign({iterations:1e3,hash:{name:L}},T),N=Object.assign({hash:L},B),O=Object.assign({length:I},_),M=["deriveBits"],W=["sign"],P=528,V=10,Z=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],H=crypto.subtle;class j{constructor(t,e){this.password=t,this.signed=e,this.input=e&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(t){const e=async(i=0)=>{if(i+I<=r.length-V){const t=r.subarray(i,i+I),s=await H.decrypt(Object.assign({counter:this.counter},O),this.keys.decrypt,t);return q(this.counter),n.set(new Uint8Array(s),i),e(i+I)}return this.pendingInput=r.subarray(i),this.signed&&(this.input=Y(this.input,t)),n};if(this.password){const e=t.subarray(0,18);await async function(t,e,n){t.counter=new Uint8Array(Z);const r=e.subarray(0,16),i=e.subarray(16),s=(new TextEncoder).encode(n),a=await H.importKey(v,s,k,!1,M),o=await H.deriveBits(Object.assign({salt:r},C),a,528),c=new Uint8Array(o),h=c.subarray(64);if(t.keys={decrypt:await H.importKey(v,c.subarray(0,32),_,!0,["decrypt"]),authentication:await H.importKey(v,c.subarray(32,64),N,!1,W),passwordVerification:h},h[0]!=i[0]||h[1]!=i[1])throw new Error(S)}(this,e,this.password),this.password=null,t=t.subarray(18)}let n=new Uint8Array(t.length-V-(t.length-V)%I),r=t;return this.pendingInput.length&&(r=Y(this.pendingInput,t),n=X(n,r.length-V-(r.length-V)%I)),e()}async flush(){const t=this.pendingInput,e=this.keys,n=t.subarray(0,t.length-V),r=t.subarray(t.length-V);let i=new Uint8Array(0);if(n.length){const t=await H.decrypt(Object.assign({counter:this.counter},O),e.decrypt,n);i=new Uint8Array(t)}let s=!0;if(this.signed){const t=await H.sign(B,e.authentication,this.input.subarray(0,this.input.length-V)),n=new Uint8Array(t);this.input=null;for(let t=0;t{if(i+I<=t.length){const s=t.subarray(i,i+I),a=await H.encrypt(Object.assign({counter:this.counter},O),this.keys.encrypt,s);return q(this.counter),r.set(new Uint8Array(a),i+n.length),e(i+I)}return this.pendingInput=t.subarray(i),this.output=Y(this.output,r),r};let n=new Uint8Array(0);this.password&&(n=await async function(t,e){t.counter=new Uint8Array(Z);const n=crypto.getRandomValues(new Uint8Array(16)),r=(new TextEncoder).encode(e),i=await H.importKey(v,r,k,!1,M),s=await H.deriveBits(Object.assign({salt:n},C),i,P),a=new Uint8Array(s);return t.keys={encrypt:await H.importKey(v,a.subarray(0,32),_,!0,["encrypt"]),authentication:await H.importKey(v,a.subarray(32,64),N,!1,W),passwordVerification:a.subarray(64)},Y(n,t.keys.passwordVerification)}(this,this.password),this.password=null);let r=new Uint8Array(n.length+t.length-t.length%I);return r.set(n,0),this.pendingInput.length&&(t=Y(this.pendingInput,t),r=X(r,t.length-t.length%I)),e()}async flush(){let t=new Uint8Array(0);if(this.pendingInput.length){const e=await H.encrypt(Object.assign({counter:this.counter},O),this.keys.encrypt,this.pendingInput);t=new Uint8Array(e),this.output=Y(this.output,t)}const e=await H.sign(B,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(e).subarray(0,V);return{data:Y(t,n),signature:n}}}function q(t){for(let e=0;e<16;e++){if(255!=t[e]){t[e]++;break}t[e]=0}}function Y(t,e){let n=t;return t.length+e.length&&(n=new Uint8Array(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function X(t,e){if(e&&e>t.length){const n=t;(t=new Uint8Array(e)).set(n,0)}return t}const G="deflate",J="inflate",Q="Invalid signature";class ${constructor(t){this.signature=t.inputSignature,this.encrypted=Boolean(t.inputPassword),this.signed=t.inputSigned,this.compressed=t.inputCompressed,this.inflate=this.compressed&&new ZipInflate,this.crc32=this.signed&&this.signed&&new z,this.decrypt=this.encrypted&&new j(t.inputPassword)}async append(t){return this.encrypted&&(t=await this.decrypt.append(t)),this.compressed&&t.length&&(t=await this.inflate.append(t)),!this.encrypted&&this.signed&&this.crc32.append(t),t}async flush(){let t,e=new Uint8Array(0);if(this.encrypted){const t=await this.decrypt.flush();if(!t.valid)throw new Error(Q);e=t.data}else if(this.signed){const e=new DataView(new Uint8Array(4).buffer);if(t=this.crc32.get(),e.setUint32(0,t),this.signature!=e.getUint32(0,!1))throw new Error(Q)}return this.compressed&&(e=await this.inflate.append(e)||new Uint8Array(0),await this.inflate.flush()),{data:e,signature:t}}}class tt{constructor(t){this.encrypted=t.outputEncrypted,this.signed=t.outputSigned,this.compressed=t.outputCompressed,this.deflate=this.compressed&&new ZipDeflate({level:t.level||5}),this.crc32=this.signed&&new z,this.encrypt=this.encrypted&&new K(t.outputPassword)}async append(t){let e=t;return this.compressed&&t.length&&(e=await this.deflate.append(t)),this.encrypted?e=await this.encrypt.append(e):this.signed&&this.crc32.append(t),e}async flush(){let t,e=new Uint8Array(0);if(this.compressed&&(e=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){e=await this.encrypt.append(e);const n=await this.encrypt.flush();t=n.signature;const r=new Uint8Array(e.length+n.data.length);r.set(e,0),r.set(n.data,e.length),e=r}else this.signed&&(t=this.crc32.get());return{data:e,signature:t}}}const et="init",nt="append",rt="flush",it="message",st="z-worker.js",at={deflate:[st,"deflate.js"],inflate:[st,"inflate.js"]},ot={pool:[],pendingRequests:[]};function ct(t,e){const n=ot.pool,r=!(e.inputCompressed||e.inputSigned||e.inputEncrypted||e.outputCompressed||e.outputSigned||e.outputEncrypted);let i;if(e.useWebWorkers||void 0===e.useWebWorkers&&t.useWebWorkers&&!r){const n=e.codecType;t.workerScripts?(s=t.workerScripts[n],i="undefined"!=typeof document?s.map((t=>new URL(t,document.baseURI).href)):s):(i=at[n].slice(0),i[0]=(t.workerScriptsPath||"")+i[0])}var s;if(n.length!t.busy));return t?ht(t,e,i):new Promise((t=>ot.pendingRequests.push({resolve:t,options:e,scripts:i})))}}function ht(t,e,n){return t.busy=!0,t.options=e,t.scripts=n,n?function(t){let e;t.interface||(t.worker=new Worker(t.scripts[0]),t.worker.addEventListener(it,i,!1),t.interface={append:t=>n({type:nt,data:t}),flush:()=>n({type:rt})});return t.interface;async function n(n){if(!e){const e=t.scripts.slice(1);await r(Object.assign({type:et,options:t.options,scripts:e}))}return r(n)}function r(n){const r=t.worker,i=new Promise(((t,n)=>e={resolve:t,reject:n}));try{if(n.data)try{r.postMessage(n,[n.data.buffer])}catch(t){r.postMessage(n)}else r.postMessage(n)}catch(n){e.reject(n),e=null,dt(t)}return i}function i(n){const r=n.data;if(e){const n=r.error;if(n){const r=new Error(n.message);r.stack=n.stack,e.reject(r),e=null,dt(t)}else r.type!=et&&r.type!=rt&&r.type!=nt||(r.type==rt?(e.resolve({data:new Uint8Array(r.data),signature:r.signature}),e=null,dt(t)):e.resolve(r.data&&new Uint8Array(r.data)))}}}(t):function(t){const e=function(t){return t.codecType.startsWith(G)?new tt(t):t.codecType.startsWith(J)?new $(t):void 0}(t.options);return{async append(n){try{return await e.append(n)}catch(e){throw dt(t),e}},async flush(){try{return await e.flush()}finally{dt(t)}}}}(t)}function dt(t){if(t.busy=!1,ot.pendingRequests.length){const[{resolve:e,options:n,scripts:r}]=ot.pendingRequests.splice(0,1);e(ht(t,n,r))}else t.worker&&t.worker.terminate(),ot.pool=ot.pool.filter((e=>e!=t))}async function lt(t,e,n,r,i,s,a){const o=Math.max(s.chunkSize,64);return async function s(c=0,h=0){const d=c*o;if(d","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","⌂","Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","¢","£","¥","₧","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","⌐","¬","½","¼","¡","«","»","░","▒","▓","│","┤","╡","╢","╖","╕","╣","║","╗","╝","╜","╛","┐","└","┴","┬","├","─","┼","╞","╟","╚","╔","╩","╦","╠","═","╬","╧","╨","╤","╥","╙","╘","╒","╓","╫","╪","┘","┌","█","▄","▌","▐","▀","α","ß","Γ","π","Σ","σ","µ","τ","Φ","Θ","Ω","δ","∞","φ","ε","∩","≡","±","≥","≤","⌠","⌡","÷","≈","°","∙","·","√","ⁿ","²","■"," "];class Ft{constructor(t,e,n){this.reader=t,this.config=e,this.options=n}async getData(t,e={}){const n=this.reader;n.initialized||await n.init();const r=await n.readUint8Array(this.offset,30),i=new DataView(r.buffer),s=void 0===e.password?this.options.password:e.password;let a=s&&s.length&&s;if(this.extraFieldAES){if(99!=this.extraFieldAES.originalCompressionMethod)throw new Error(At);if(3!=this.extraFieldAES.strength)throw new Error(Et)}if(0!=this.compressionMethod&&8!=this.compressionMethod)throw new Error(At);if(i.getUint32(0,!1)!=U)throw new Error(mt);const o=this.localDirectory={};zt(o,i,4),o.rawExtraField=r.subarray(this.offset+30+o.filenameLength,this.offset+30+o.filenameLength+o.extraFieldLength),St(this,o,i,4);let c=this.offset+30+o.filenameLength+o.extraFieldLength;const h=this.bitFlag.encrypted&&o.bitFlag.encrypted;if(h&&!a)throw new Error(bt);const d=await ct(this.config,{codecType:J,inputPassword:a,inputSigned:void 0===e.checkSignature?this.options.checkSignature:e.checkSignature,inputSignature:this.signature,inputCompressed:0!=this.compressionMethod,inputEncrypted:h,useWebWorkers:void 0===e.useWebWorkers?this.options.useWebWorkers:e.useWebWorkers});return t.initialized||await t.init(),await lt(d,n,t,c,this.compressedSize,this.config,{onprogress:e.onprogress}),t.getData()}}function zt(t,e,n){t.version=e.getUint16(n,!0);const r=t.rawBitFlag=e.getUint16(n+2,!0);t.bitFlag={encrypted:1==(1&r),level:(6&r)>>1,dataDescriptor:8==(8&r),languageEncodingFlag:(r&F)==F},t.encrypted=t.bitFlag.encrypted,t.rawLastModDate=e.getUint32(n+6,!0),t.lastModDate=function(t){const e=(4294901760&t)>>16,n=65535&t;try{return new Date(1980+((65024&e)>>9),((480&e)>>5)-1,31&e,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(t){}}(t.rawLastModDate),t.filenameLength=e.getUint16(n+22,!0),t.extraFieldLength=e.getUint16(n+24,!0)}function St(t,e,n,r){const i=e.rawExtraField,s=e.extraField=new Map,a=new DataView(new Uint8Array(i).buffer);let o=0;try{for(;oe[t]==y));for(let e=0;e{if(e[n]==y){if(!t||void 0===t[n])throw new Error(Ut);e[n]=t[n]}}))}(h,e);const d=e.extraFieldUnicodePath=s.get(28789);d&&It(d,"filename","rawFilename",e,t);let l=e.extraFieldUnicodeComment=s.get(25461);l&&It(l,"comment","rawComment",e,t);const u=e.extraFieldAES=s.get(39169);u?function(t,e,n){if(t){const r=new DataView(t.data.buffer);t.vendorVersion=r.getUint8(0),t.vendorId=r.getUint8(2);const i=r.getUint8(4);t.strength=i,t.originalCompressionMethod=n,e.compressionMethod=t.compressionMethod=r.getUint16(5,!0)}else e.compressionMethod=n}(u,e,c):e.compressionMethod=c,8==e.compressionMethod&&(e.bitFlag.enhancedDeflating=16!=(16&e.rawBitFlag))}function It(t,e,n,r,i){const s=new DataView(t.data.buffer);t.version=s.getUint8(0),t.signature=s.getUint32(1,!0);const a=new z;a.append(i[n]);const o=new DataView(new Uint8Array(4).buffer);o.setUint32(0,a.get()),t[e]=(new TextDecoder).decode(t.data.subarray(5)),i.bitFlag.languageEncodingFlag||t.signature!=o.getUint32(0,!1)||(r[e]=t[e])}function vt(t,e){if(e&&"cp437"!=e.trim().toLowerCase())return new TextDecoder(e).decode(t);{let e="";for(let n=0;n{if(this.pendingData){const e=this.pendingData;this.pendingData=new Uint8Array(e.length+t.length),this.pendingData.set(e,0),this.pendingData.set(t,e.length)}else this.pendingData=new Uint8Array(t)};if(this.codec=new t(Object.assign({},e,n)),typeof this.codec.onData==Wt)this.codec.onData=r;else{if(typeof this.codec.on!=Wt)throw new Error("Cannot register the callback function");this.codec.on("data",r)}}async append(t){return this.codec.push(t),n(this)}async flush(){return this.codec.push(new Uint8Array(0),!0),n(this)}};function n(t){if(t.pendingData){const e=t.pendingData;return t.pendingData=null,e}return new Uint8Array(0)}}const Vt={chunkSize:524288,maxWorkers:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||2,workerScriptsPath:void 0,useWebWorkers:!0};let Zt=Object.assign({},Vt);class Ht extends class{constructor(t,e={},n={}){this.reader=t,this.options=e,this.config=n}async getEntries(t={}){const e=this.reader;e.initialized||await e.init();const n=await async function(t,e,n,r){const i=new Uint8Array(4);if(new DataView(i.buffer).setUint32(0,e),t.size=0;t--)if(s[t]==i[0]&&s[t+1]==i[1]&&s[t+2]==i[2]&&s[t+3]==i[3])return{offset:r,buffer:s.slice(t,t+n).buffer}}}(e,A,22,m);if(!n)throw new Error(wt);const r=new DataView(n.buffer);let i,s=r.getUint32(16,!0),a=r.getUint16(8,!0);if(s==y||a==m){i=!0;const t=await e.readUint8Array(n.offset-20,20),r=new DataView(t.buffer);if(Number(r.getUint32(0,!1))!=D)throw new Error(gt);s=Number(r.getBigUint64(8,!0));const o=await e.readUint8Array(s,56),c=new DataView(o.buffer);if(Number(c.getUint32(0,!1))!=R)throw new Error(ft);a=Number(c.getBigUint64(24,!0)),s-=Number(c.getBigUint64(40,!0))}if(s<0||!i&&(s>=e.size||a>=m))throw new Error(pt);const o=await e.readUint8Array(s,e.size-s),c=new DataView(o.buffer),h=[];let d=0;for(let e=0;em)throw new Error(_t);const i=(new TextEncoder).encode(n.comment||"");if(i.length>m)throw new Error(Lt);const s=this.options.version||n.version||0;if(s>m)throw new Error(kt);const a=n.lastModDate||new Date;if(a.getFullYear()<1980)throw new Error(Ct);e&&!e.initialized&&await e.init();let o=new Uint8Array(0);const c=n.extraField;if(c){let t=4,e=0;c.forEach((e=>t+=e.length)),o=new Uint8Array(t),c.forEach(((t,n)=>{if(n>m)throw new Error(Nt);if(t.length>m)throw new Error(Ot);o.set(new Uint16Array([n]),e),o.set(new Uint16Array([t.length]),e+2),o.set(t,e+4),e+=4+t.length}))}let h=n.zip64||this.zip64;(this.offset>=y||e&&(e.size>=y||this.offset+e.size>=y))&&(h=!0),await async function(t,e,n,r){const i=t.files,s=t.writer;let a;i.set(e,null);try{let o,c;try{r.bufferedWrite||t.options.bufferedWrite||t.lockWrite?(o=new g,o.init()):(t.lockWrite=new Promise((t=>a=t)),s.initialized||await s.init(),o=s),c=await async function(t,e,n,r,i,s){const a=s.rawFilename,o=s.lastModDate,c=new Uint8Array(26),h=new DataView(c.buffer),d=void 0===s.password?i.password:s.password,l=d&&d.length&&d,u=void 0===s.level?i.level:s.level,p=0!==u&&!s.directory,w=void 0===d||!d.length,g=s.zip64;let f;if(l){f=new Uint8Array(Mt.length+2);new DataView(f.buffer).setUint16(0,x,!0),f.set(Mt,2)}else f=new Uint8Array(0);const m={version:s.version||20,zip64:g,headerArray:c,directory:s.directory,filename:t,rawFilename:a,comment:s.comment,rawComment:s.rawComment,extraFieldZip64:g?new Uint8Array(28):new Uint8Array(0),extraFieldAES:f,rawExtraField:s.rawExtraField};let E=2056,A=0;p&&(A=8);g&&(m.version=m.version>45?m.version:45);l&&(m.encrypted=!0,m.version=m.version>51?m.version:51,E|=1,A=99,p&&(m.extraFieldAES[9]=8));h.setUint16(0,m.version,!0),h.setUint16(2,E,!0),h.setUint16(4,A,!0),h.setUint16(6,(o.getHours()<<6|o.getMinutes())<<5|o.getSeconds()/2,!0),h.setUint16(8,(o.getFullYear()-1980<<4|o.getMonth()+1)<<5|o.getDate(),!0),h.setUint16(22,a.length,!0),h.setUint16(24,0,!0);const R=new Uint8Array(30+a.length);let D;if(new DataView(R.buffer).setUint32(0,U),R.set(c,4),R.set(a,30),e){const t=await ct(r,{codecType:G,level:u,outputPassword:d,outputSigned:w,outputCompressed:p,outputEncrypted:Boolean(d),useWebWorkers:void 0===s.useWebWorkers?i.useWebWorkers:s.useWebWorkers});await n.writeUint8Array(R),D=await lt(t,e,n,0,e.size,r,{onprogress:s.onprogress}),m.compressedSize=D.length}else await n.writeUint8Array(R);const F=new Uint8Array(g?24:16),z=new DataView(F.buffer);if(z.setUint32(0,b),e)if(l||void 0===D.signature||(h.setUint32(10,D.signature,!0),z.setUint32(4,D.signature,!0)),g){h.setUint32(14,y,!0),z.setBigUint64(8,BigInt(m.compressedSize),!0),h.setUint32(18,y,!0),z.setBigUint64(16,BigInt(e.size),!0);const t=new DataView(m.extraFieldZip64.buffer);t.setUint16(0,1,!0),t.setUint16(2,24,!0),t.setBigUint64(4,BigInt(e.size),!0),t.setBigUint64(12,BigInt(m.compressedSize),!0)}else h.setUint32(14,m.compressedSize,!0),z.setUint32(8,m.compressedSize,!0),h.setUint32(18,e.size,!0),z.setUint32(12,e.size,!0);return await n.writeUint8Array(F),m.length=R.length+(D?D.length:0)+F.length,m}(e,n,o,t.config,t.options,r)}catch(t){throw i.delete(e),t}if(i.set(e,c),o!=s&&(t.lockWrite&&await t.lockWrite,await s.writeUint8Array(o.getData())),c.offset=t.offset,c.zip64){new DataView(c.extraFieldZip64.buffer).setBigUint64(20,BigInt(c.offset),!0)}t.offset+=c.length}finally{a&&(t.lockWrite=null,a())}}(this,t,e,Object.assign({},n,{rawFilename:r,rawComment:i,version:s,lastModDate:a,rawExtraField:o,zip64:h}))}async close(t=new Uint8Array(0)){const e=this.writer,n=this.files;let r=0,i=0,s=this.offset,a=n.size;if(t.length){if(!(t.length<=m))throw new Error(Bt);c.setUint16(r+20,t.length,!0)}for(const[,t]of n)i+=46+t.rawFilename.length+t.rawComment.length+t.extraFieldZip64.length+t.extraFieldAES.length+t.rawExtraField.length;(s+i>=y||a>=m)&&(this.zip64=!0);const o=new Uint8Array(i+(this.zip64?98:22)),c=new DataView(o.buffer);for(const[,t]of n){const e=t.rawFilename,n=t.extraFieldZip64,i=t.extraFieldAES,s=n.length+i.length+t.rawExtraField.length;c.setUint32(r,E),c.setUint16(r+4,t.version,!0),o.set(t.headerArray,r+6),c.setUint16(r+30,s,!0),c.setUint16(r+32,t.rawComment.length,!0),t.directory&&c.setUint8(r+38,16),t.zip64?c.setUint32(r+42,y,!0):c.setUint32(r+42,t.offset,!0),o.set(e,r+46),o.set(n,r+46+e.length),o.set(i,r+46+e.length+n.length),o.set(t.rawExtraField,46+e.length+n.length+i.length),o.set(t.rawComment,r+46+e.length+s),r+=46+e.length+s+t.rawComment.length}return this.zip64&&(c.setUint32(r,R),c.setBigUint64(r+4,BigInt(44),!0),c.setUint16(r+12,45,!0),c.setUint16(r+14,45,!0),c.setBigUint64(r+24,BigInt(a),!0),c.setBigUint64(r+32,BigInt(a),!0),c.setBigUint64(r+40,BigInt(i),!0),c.setBigUint64(r+48,BigInt(s),!0),c.setUint32(r+56,D),c.setBigUint64(r+64,BigInt(s+i),!0),c.setUint32(r+72,1,!0),a=m,s=y,r+=76),c.setUint32(r,A),c.setUint16(r+8,a,!0),c.setUint16(r+10,a,!0),c.setUint32(r+12,i,!0),c.setUint32(r+16,s,!0),await e.writeUint8Array(o),await e.writeUint8Array(t),e.getData()}}{constructor(t,e){super(t,e,Zt)}}const Kt=524288;class qt{constructor(t,e,n,r){if(t.root&&r&&r.getChildByName(e))throw new Error("Entry filename already exists");n||(n={}),this.fs=t,this.name=e,this.data=n.data,this.id=t.entries.length,this.parent=r,this.children=[],this.uncompressedSize=0,t.entries.push(this),r&&this.parent.children.push(this)}moveTo(t){if(!t.directory)throw new Error("Target entry is not a directory");if(t.isDescendantOf(this))throw new Error("Entry is a ancestor of target entry");if(this!=t){if(t.getChildByName(this.name))throw new Error("Entry filename already exists");te(this),this.parent=t,t.children.push(this)}}getFullname(){let t=this.name,e=this.parent;for(;e;)t=(e.name?e.name+"/":"")+t,e=e.parent;return t}isDescendantOf(t){let e=this.parent;for(;e&&e.id!=t.id;)e=e.parent;return Boolean(e)}}class Yt extends qt{constructor(t,e,n,r){super(t,e,n,r),this.Reader=n.Reader,this.Writer=n.Writer,n.getData&&(this.getData=n.getData)}async getData(t,e={}){return!t||t.constructor==this.Writer&&this.data?this.data:(this.reader||(this.reader=new this.Reader(this.data)),await this.reader.init(),await t.init(),this.uncompressedSize=this.reader.size,async function(t,e,n){return r();async function r(i=0){const s=i*Kt;if(n.onprogress&&n.onprogress(s,t.size),s{e.file((r=>{t.addBlob(e.name,r),n()}),r)}));function n(t){return new Promise(((e,n)=>{let r=[];function i(t){t.readEntries((n=>{n.length?(r=r.concat(n),i(t)):e(r)}),n)}t.isDirectory&&i(t.createReader()),t.isFile&&e(r)}))}async function r(t,e){const i=await n(e);for(const e of i)e.isDirectory&&await r(t.addDirectory(e.name)),await new Promise(((n,r)=>{e.isFile&&e.file((r=>{const i=t.addBlob(e.name,r);i.uncompressedSize=r.size,n(i)}),r)}))}}(this,t)}async addData(t,e){return ne(this,t,e)}async importBlob(t,e={}){await this.importZip(new l(t),e)}async importData64URI(t,e={}){await this.importZip(new h(t),e)}async importHttpContent(t,e={}){await this.importZip(e.useRangeHeader?new w(t):new p(t),e)}async exportBlob(t={}){return this.exportZip(new u("application/zip"),t)}async exportData64URI(t={}){return this.exportZip(new d("application/zip"),t)}async importZip(t,e){await t.init();const n=new Ht(t,e),r=await n.getEntries();let i=0;const s=Jt(r,"compressedSize");r.forEach((t=>{let n=this,r=t.filename.split("/"),a=r.pop();if(r.forEach((t=>n=n.getChildByName(t)||new Xt(this.fs,t,null,n))),!t.directory){let r=i;ne(n,a,{data:t,Reader:Qt(Object.assign({},{onprogress:t=>{e.onprogress&&e.onprogress(r+t,s)}}))}),i+=t.compressedSize}}))}async exportZip(t,e){await $t(this);const n=new jt(t,e);return await async function(t,e,n,r){let i=0;async function s(t,e){async function a(){let a=0;for(const o of e.children){let e=i;await t.add(o.getFullname(),o.reader,Object.assign({directory:o.directory},{onprogress:t=>{r.onprogress&&r.onprogress(e+a+t,n)}})),i+=o.uncompressedSize,await s(t,o),a++}}await a()}await s(t,e)}(n,this,Jt([this],"uncompressedSize"),e),await n.close(),t.getData()}getChildByName(t){for(let e=0;e{n.id==t.id&&e.splice(r,1)}))}function ee(t){t.entries=[],t.root=new Xt(t)}function ne(t,e,n,r){if(t.directory)return r?new Xt(t.fs,e,n,t):new Yt(t.fs,e,n,t);throw new Error("Parent entry is not a directory")}t.BlobReader=l,t.BlobWriter=u,t.Data64URIReader=h,t.Data64URIWriter=d,t.ERR_BAD_FORMAT=pt,t.ERR_CENTRAL_DIRECTORY_NOT_FOUND=yt,t.ERR_DUPLICATED_NAME=Tt,t.ERR_ENCRYPTED=bt,t.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND=ft,t.ERR_EOCDR_NOT_FOUND=wt,t.ERR_EOCDR_ZIP64_NOT_FOUND=gt,t.ERR_EXTRAFIELD_ZIP64_NOT_FOUND=Ut,t.ERR_HTTP_RANGE=n,t.ERR_INVALID_COMMENT=Bt,t.ERR_INVALID_DATE=Ct,t.ERR_INVALID_ENTRY_COMMENT=Lt,t.ERR_INVALID_ENTRY_NAME=_t,t.ERR_INVALID_EXTRAFIELD_DATA=Ot,t.ERR_INVALID_EXTRAFIELD_TYPE=Nt,t.ERR_INVALID_PASSORD=S,t.ERR_INVALID_SIGNATURE=Q,t.ERR_INVALID_VERSION=kt,t.ERR_LOCAL_FILE_HEADER_NOT_FOUND=mt,t.ERR_UNSUPPORTED_COMPRESSION=At,t.ERR_UNSUPPORTED_ENCRYPTION=Et,t.HttpRangeReader=w,t.HttpReader=p,t.Reader=s,t.TextReader=o,t.TextWriter=c,t.Uint8ArrayReader=class extends s{constructor(t){super(),this.array=t,this.size=t.length}readUint8Array(t,e){return this.array.slice(t,t+e)}},t.Uint8ArrayWriter=g,t.Writer=a,t.ZipReader=Ht,t.ZipWriter=jt,t.configure=function(t){if(Zt=Object.assign({},Zt,t),null!=Zt.workerScripts&&null!=Zt.workerScriptsPath)throw new Error("Either workerScripts or workerScriptsPath may be set, not both");if(Zt.workerScripts){if(Zt.workerScripts.deflate&&!Array.isArray(Zt.workerScripts.deflate))throw new Error("workerScripts.deflate must be an array");if(Zt.workerScripts.inflate&&!Array.isArray(Zt.workerScripts.inflate))throw new Error("workerScripts.inflate must be an array")}},t.fs=Gt,t.getMimeType=function(){return"application/octet-stream"},t.initShimAsyncCodec=(t,e={})=>({ZipDeflate:Pt(t.Deflate,e.deflate),ZipInflate:Pt(t.Inflate,e.inflate)}),Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).zip={})}(this,(function(t){"use strict";const e=256,n=256,i=-2,r=-5,a=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];function s(){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.build_tree=function(n){const i=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.elems;let s,o,l,d=-1;for(n.heap_len=0,n.heap_max=573,s=0;s=1;s--)n.pqdownheap(i,s);l=a;do{s=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(i,1),o=n.heap[1],n.heap[--n.heap_max]=s,n.heap[--n.heap_max]=o,i[2*l]=i[2*s]+i[2*o],n.depth[l]=Math.max(n.depth[s],n.depth[o])+1,i[2*s+1]=i[2*o+1]=l,n.heap[1]=l++,n.pqdownheap(i,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],function(e){const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,s=t.stat_desc.max_length;let o,l,d,c,u,f,h=0;for(c=0;c<=15;c++)e.bl_count[c]=0;for(n[2*e.heap[e.heap_max]+1]=0,o=e.heap_max+1;o<573;o++)l=e.heap[o],c=n[2*n[2*l+1]+1]+1,c>s&&(c=s,h++),n[2*l+1]=c,l>t.max_code||(e.bl_count[c]++,u=0,l>=a&&(u=r[l-a]),f=n[2*l],e.opt_len+=f*(c+u),i&&(e.static_len+=f*(i[2*l+1]+u)));if(0!==h){do{for(c=s-1;0===e.bl_count[c];)c--;e.bl_count[c]--,e.bl_count[c+1]+=2,e.bl_count[s]--,h-=2}while(h>0);for(c=s;0!==c;c--)for(l=e.bl_count[c];0!==l;)d=e.heap[--o],d>t.max_code||(n[2*d+1]!=c&&(e.opt_len+=(c-n[2*d+1])*n[2*d],n[2*d+1]=c),l--)}}(n),function(t,n,i){const r=[];let a,s,o,l=0;for(a=1;a<=15;a++)r[a]=l=l+i[a-1]<<1;for(s=0;s<=n;s++)o=t[2*s+1],0!==o&&(t[2*s]=e(r[o]++,o))}(i,t.max_code,n.bl_count)}}function o(t,e,n,i,r){const a=this;a.static_tree=t,a.extra_bits=e,a.extra_base=n,a.elems=i,a.max_length=r}s._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],s.base_length=[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],s.base_dist=[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],s.d_code=function(t){return t<256?a[t]:a[256+(t>>>7)]},s.extra_lbits=[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],s.extra_dbits=[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],s.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],s.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],o.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8],o.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5],o.static_l_desc=new o(o.static_ltree,s.extra_lbits,257,286,15),o.static_d_desc=new o(o.static_dtree,s.extra_dbits,0,30,15),o.static_bl_desc=new o(null,s.extra_blbits,0,19,7);function l(t,e,n,i,r){const a=this;a.good_length=t,a.max_lazy=e,a.nice_length=n,a.max_chain=i,a.func=r}const d=[new l(0,0,0,0,0),new l(4,4,8,4,1),new l(4,5,16,8,1),new l(4,6,32,32,1),new l(4,4,16,16,2),new l(8,16,32,32,2),new l(8,16,128,128,2),new l(8,32,128,256,2),new l(32,128,258,1024,2),new l(32,258,258,4096,2)],c=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],u=113,f=666,h=258,_=262;function w(t,e,n,i){const r=t[2*e],a=t[2*n];return r>>8&255)}function lt(t,e){let n;const i=e;it>16-i?(n=t,nt|=n<>>16-it,it+=i-16):(nt|=t<=8&&(st(255&nt),nt>>>=8,it-=8)}function ft(n,i){let r,a,o;if(t.pending_buf[$+2*Q]=n>>>8&255,t.pending_buf[$+2*Q+1]=255&n,t.pending_buf[G+Q]=255&i,Q++,0===n?Z[2*i]++:(tt++,n--,Z[2*(s._length_code[i]+e+1)]++,j[2*s.d_code(n)]++),0==(8191&Q)&&O>2){for(r=8*Q,a=C-S,o=0;o<30;o++)r+=j[2*o]*(5+s.extra_dbits[o]);if(r>>>=3,tt8?ot(nt):it>0&&st(255&nt),nt=0,it=0}function wt(e,n,i){lt(0+(i?1:0),3),function(e,n,i){_t(),et=8,i&&(ot(n),ot(~n)),t.pending_buf.set(m.subarray(e,e+n),t.pending),t.pending+=n}(e,n,!0)}function pt(e,n,i){let r,a,l=0;O>0?(K.build_tree(t),Y.build_tree(t),l=function(){let e;for(at(Z,K.max_code),at(j,Y.max_code),X.build_tree(t),e=18;e>=3&&0===q[2*s.bl_order[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(),r=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=r&&(r=a)):r=a=n+5,n+4<=r&&-1!=e?wt(e,n,i):a==r?(lt(2+(i?1:0),3),ht(o.static_ltree,o.static_dtree)):(lt(4+(i?1:0),3),function(t,e,n){let i;for(lt(t-257,5),lt(e-1,5),lt(n-4,4),i=0;i=0?S:-1,C-S,t),S=C,a.flush_pending()}function bt(){let t,e,n,i;do{if(i=v-M-C,0===i&&0===C&&0===M)i=b;else if(-1==i)i--;else if(C>=b+b-_){m.set(m.subarray(b,b+b),0),L-=b,C-=b,S-=b,t=U,n=t;do{e=65535&A[--n],A[n]=e>=b?e-b:0}while(0!=--t);t=b,n=t;do{e=65535&E[--n],E[n]=e>=b?e-b:0}while(0!=--t);i+=b}if(0===a.avail_in)return;t=a.read_buf(m,C+M,i),M+=t,M>=3&&(k=255&m[C],k=(k<b-_?C-(b-_):0;let o=H;const l=x,d=C+h;let c=m[r+a-1],u=m[r+a];N>=V&&(i>>=2),o>M&&(o=M);do{if(e=t,m[e+a]==u&&m[e+a-1]==c&&m[e]==m[r]&&m[++e]==m[r+1]){r+=2,e++;do{}while(m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&ra){if(L=t,a=n,n>=o)break;c=m[r+a-1],u=m[r+a]}}}while((t=65535&E[t&l])>s&&0!=--i);return a<=M?a:M}function xt(e){return e.total_in=e.total_out=0,e.msg=null,t.pending=0,t.pending_out=0,l=u,g=0,K.dyn_tree=Z,K.stat_desc=o.static_l_desc,Y.dyn_tree=j,Y.stat_desc=o.static_d_desc,X.dyn_tree=q,X.stat_desc=o.static_bl_desc,nt=0,it=0,et=8,rt(),function(){v=2*b,A[U-1]=0;for(let t=0;t9||8!=a||r<9||r>15||n<0||n>9||o<0||o>2?i:(e.dstate=t,y=r,b=1<9||n<0||n>2?i:(d[O].func!=d[e].func&&0!==t.total_in&&(r=t.deflate(1)),O!=e&&(O=e,B=d[O].max_lazy,V=d[O].good_length,H=d[O].nice_length,W=d[O].max_chain),P=n,r)},t.deflateSetDictionary=function(t,e,n){let r,a=n,s=0;if(!e||42!=l)return i;if(a<3)return 0;for(a>b-_&&(a=b-_,s=n-a),m.set(e.subarray(s,s+a),0),C=a,S=a,k=255&m[0],k=(k<4||s<0)return i;if(!e.next_out||!e.next_in&&0!==e.avail_in||l==f&&4!=s)return e.msg=c[4],i;if(0===e.avail_out)return e.msg=c[7],r;var V;if(a=e,R=g,g=s,42==l&&(w=8+(y-8<<4)<<8,v=(O-1&255)>>1,v>3&&(v=3),w|=v<<6,0!==C&&(w|=32),w+=31-w%31,l=u,st((V=w)>>8&255),st(255&V)),0!==t.pending){if(a.flush_pending(),0===a.avail_out)return g=-1,0}else if(0===a.avail_in&&s<=R&&4!=s)return a.msg=c[7],r;if(l==f&&0!==a.avail_in)return e.msg=c[7],r;if(0!==a.avail_in||0!==M||0!=s&&l!=f){switch(W=-1,d[O].func){case 0:W=function(t){let e,n=65535;for(n>p-5&&(n=p-5);;){if(M<=1){if(bt(),0===M&&0==t)return 0;if(0===M)break}if(C+=M,M=0,e=S+n,(0===C||C>=e)&&(M=C-e,C=e,gt(!1),0===a.avail_out))return 0;if(C-S>=b-_&&(gt(!1),0===a.avail_out))return 0}return gt(4==t),0===a.avail_out?4==t?2:0:4==t?3:1}(s);break;case 1:W=function(t){let e,n=0;for(;;){if(M<_){if(bt(),M<_&&0==t)return 0;if(0===M)break}if(M>=3&&(k=(k<=3)if(e=ft(C-L,F-3),M-=F,F<=B&&M>=3){F--;do{C++,k=(k<=3&&(k=(k<4096)&&(F=2)),N>=3&&F<=N){n=C+M-3,e=ft(C-1-z,N-3),M-=N-1,N-=2;do{++C<=n&&(k=(k<n&&(r=n),0===r?0:(i.avail_in-=r,t.set(i.next_in.subarray(i.next_in_index,i.next_in_index+r),e),i.next_in_index+=r,i.total_in+=r,r)},flush_pending:function(){const t=this;let e=t.dstate.pending;e>t.avail_out&&(e=t.avail_out),0!==e&&(t.next_out.set(t.dstate.pending_buf.subarray(t.dstate.pending_out,t.dstate.pending_out+e),t.next_out_index),t.next_out_index+=e,t.dstate.pending_out+=e,t.total_out+=e,t.avail_out-=e,t.dstate.pending-=e,0===t.dstate.pending&&(t.dstate.pending_out=0))}};const b=-2,y=-3,x=-5,m=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],v=[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],E=[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],k=[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],U=[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],R=[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],D=15;function I(){let t,e,n,i,r,a;function s(t,e,s,o,l,d,c,u,f,h,_){let w,p,g,b,m,v,E,A,k,U,R,I,S,F,z;U=0,m=s;do{n[t[e+U]]++,U++,m--}while(0!==m);if(n[0]==s)return c[0]=-1,u[0]=0,0;for(A=u[0],v=1;v<=D&&0===n[v];v++);for(E=v,Am&&(A=m),u[0]=A,F=1<I+A;){if(b++,I+=A,z=g-I,z=z>A?A:z,(p=1<<(v=E-I))>w+1&&(p-=w+1,S=E,v1440)return y;r[b]=R=h[0],h[0]+=z,0!==b?(a[b]=m,i[0]=v,i[1]=A,v=m>>>I-A,i[2]=R-r[b-1]-v,f.set(i,3*(r[b-1]+v))):c[0]=R}for(i[1]=E-I,U>=s?i[0]=192:_[U]>>I;v>>=1)m^=v;for(m^=v,k=(1<257?(h==y?f.msg="oversubscribed distance tree":h==x?(f.msg="incomplete distance tree",h=y):-4!=h&&(f.msg="empty distance tree with lengths",h=y),h):0)}}I.inflate_trees_fixed=function(t,e,n,i){return t[0]=9,e[0]=5,n[0]=v,i[0]=E,0};function S(){const t=this;let e,n,i,r,a=0,s=0,o=0,l=0,d=0,c=0,u=0,f=0,h=0,_=0;function w(t,e,n,i,r,a,s,o){let l,d,c,u,f,h,_,w,p,g,b,x,v,E,A,k;_=o.next_in_index,w=o.avail_in,f=s.bitb,h=s.bitk,p=s.write,g=p>=d[k+1],h-=d[k+1],0!=(16&u)){for(u&=15,v=d[k+2]+(f&m[u]),f>>=u,h-=u;h<15;)w--,f|=(255&o.read_byte(_++))<>=d[k+1],h-=d[k+1],0!=(16&u)){for(u&=15;h>=u,h-=u,g-=v,p>=E)A=p-E,p-A>0&&2>p-A?(s.window[p++]=s.window[A++],s.window[p++]=s.window[A++],v-=2):(s.window.set(s.window.subarray(A,A+2),p),p+=2,A+=2,v-=2);else{A=p-E;do{A+=s.end}while(A<0);if(u=s.end-A,v>u){if(v-=u,p-A>0&&u>p-A)do{s.window[p++]=s.window[A++]}while(0!=--u);else s.window.set(s.window.subarray(A,A+u),p),p+=u,A+=u,u=0;A=0}}if(p-A>0&&v>p-A)do{s.window[p++]=s.window[A++]}while(0!=--v);else s.window.set(s.window.subarray(A,A+v),p),p+=v,A+=v,v=0;break}if(0!=(64&u))return o.msg="invalid distance code",v=o.avail_in-w,v=h>>3>3:v,w+=v,_-=v,h-=v<<3,s.bitb=f,s.bitk=h,o.avail_in=w,o.total_in+=_-o.next_in_index,o.next_in_index=_,s.write=p,y;l+=d[k+2],l+=f&m[u],k=3*(c+l),u=d[k]}break}if(0!=(64&u))return 0!=(32&u)?(v=o.avail_in-w,v=h>>3>3:v,w+=v,_-=v,h-=v<<3,s.bitb=f,s.bitk=h,o.avail_in=w,o.total_in+=_-o.next_in_index,o.next_in_index=_,s.write=p,1):(o.msg="invalid literal/length code",v=o.avail_in-w,v=h>>3>3:v,w+=v,_-=v,h-=v<<3,s.bitb=f,s.bitk=h,o.avail_in=w,o.total_in+=_-o.next_in_index,o.next_in_index=_,s.write=p,y);if(l+=d[k+2],l+=f&m[u],k=3*(c+l),0===(u=d[k])){f>>=d[k+1],h-=d[k+1],s.window[p++]=d[k+2],g--;break}}else f>>=d[k+1],h-=d[k+1],s.window[p++]=d[k+2],g--}while(g>=258&&w>=10);return v=o.avail_in-w,v=h>>3>3:v,w+=v,_-=v,h-=v<<3,s.bitb=f,s.bitk=h,o.avail_in=w,o.total_in+=_-o.next_in_index,o.next_in_index=_,s.write=p,0}t.init=function(t,a,s,o,l,d){e=0,u=t,f=a,i=s,h=o,r=l,_=d,n=null},t.proc=function(t,p,g){let x,v,E,A,k,U,R,D=0,I=0,S=0;for(S=p.next_in_index,A=p.avail_in,D=t.bitb,I=t.bitk,k=t.write,U=k=258&&A>=10&&(t.bitb=D,t.bitk=I,p.avail_in=A,p.total_in+=S-p.next_in_index,p.next_in_index=S,t.write=k,g=w(u,f,i,h,r,_,t,p),S=p.next_in_index,A=p.avail_in,D=t.bitb,I=t.bitk,k=t.write,U=k>>=n[v+1],I-=n[v+1],E=n[v],0===E){l=n[v+2],e=6;break}if(0!=(16&E)){d=15&E,a=n[v+2],e=2;break}if(0==(64&E)){o=E,s=v/3+n[v+2];break}if(0!=(32&E)){e=7;break}return e=9,p.msg="invalid literal/length code",g=y,t.bitb=D,t.bitk=I,p.avail_in=A,p.total_in+=S-p.next_in_index,p.next_in_index=S,t.write=k,t.inflate_flush(p,g);case 2:for(x=d;I>=x,I-=x,o=f,n=r,s=_,e=3;case 3:for(x=o;I>=n[v+1],I-=n[v+1],E=n[v],0!=(16&E)){d=15&E,c=n[v+2],e=4;break}if(0==(64&E)){o=E,s=v/3+n[v+2];break}return e=9,p.msg="invalid distance code",g=y,t.bitb=D,t.bitk=I,p.avail_in=A,p.total_in+=S-p.next_in_index,p.next_in_index=S,t.write=k,t.inflate_flush(p,g);case 4:for(x=d;I>=x,I-=x,e=5;case 5:for(R=k-c;R<0;)R+=t.end;for(;0!==a;){if(0===U&&(k==t.end&&0!==t.read&&(k=0,U=k7&&(I-=8,A++,S--),t.write=k,g=t.inflate_flush(p,g),k=t.write,U=kt.avail_out&&(i=t.avail_out),0!==i&&e==x&&(e=0),t.avail_out-=i,t.total_out+=i,t.next_out.set(n.window.subarray(a,a+i),r),r+=i,a+=i,a==n.end&&(a=0,n.write==n.end&&(n.write=0),i=n.write-a,i>t.avail_out&&(i=t.avail_out),0!==i&&e==x&&(e=0),t.avail_out-=i,t.total_out+=i,t.next_out.set(n.window.subarray(a,a+i),r),r+=i,a+=i),t.next_out_index=r,n.read=a,e},n.proc=function(t,e){let _,w,p,g,x,v,E,A;for(g=t.next_in_index,x=t.avail_in,w=n.bitb,p=n.bitk,v=n.write,E=v>>1){case 0:w>>>=3,p-=3,_=7&p,w>>>=_,p-=_,r=1;break;case 1:k=[],U=[],R=[[]],D=[[]],I.inflate_trees_fixed(k,U,R,D),c.init(k[0],U[0],R[0],0,D[0],0),w>>>=3,p-=3,r=6;break;case 2:w>>>=3,p-=3,r=3;break;case 3:return w>>>=3,p-=3,r=9,t.msg="invalid block type",e=y,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e)}break;case 1:for(;p<32;){if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);e=0,x--,w|=(255&t.read_byte(g++))<>>16&65535)!=(65535&w))return r=9,t.msg="invalid stored block lengths",e=y,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);a=65535&w,w=p=0,r=0!==a?2:0!==u?7:0;break;case 2:if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);if(0===E&&(v==n.end&&0!==n.read&&(v=0,E=vx&&(_=x),_>E&&(_=E),n.window.set(t.read_buf(g,_),v),g+=_,x-=_,v+=_,E-=_,0!=(a-=_))break;r=0!==u?7:0;break;case 3:for(;p<14;){if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);e=0,x--,w|=(255&t.read_byte(g++))<29||(_>>5&31)>29)return r=9,t.msg="too many length or distance symbols",e=y,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);if(_=258+(31&_)+(_>>5&31),!i||i.length<_)i=[];else for(A=0;A<_;A++)i[A]=0;w>>>=14,p-=14,o=0,r=4;case 4:for(;o<4+(s>>>10);){for(;p<3;){if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);e=0,x--,w|=(255&t.read_byte(g++))<>>=3,p-=3}for(;o<19;)i[F[o++]]=0;if(l[0]=7,_=h.inflate_trees_bits(i,l,d,f,t),0!=_)return(e=_)==y&&(i=null,r=9),n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);o=0,r=5;case 5:for(;_=s,!(o>=258+(31&_)+(_>>5&31));){let a,c;for(_=l[0];p<_;){if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);e=0,x--,w|=(255&t.read_byte(g++))<>>=_,p-=_,i[o++]=c;else{for(A=18==c?7:c-14,a=18==c?11:3;p<_+A;){if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);e=0,x--,w|=(255&t.read_byte(g++))<>>=_,p-=_,a+=w&m[A],w>>>=A,p-=A,A=o,_=s,A+a>258+(31&_)+(_>>5&31)||16==c&&A<1)return i=null,r=9,t.msg="invalid bit length repeat",e=y,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);c=16==c?i[A-1]:0;do{i[A++]=c}while(0!=--a);o=A}}if(d[0]=-1,S=[],z=[],T=[],C=[],S[0]=9,z[0]=6,_=s,_=h.inflate_trees_dynamic(257+(31&_),1+(_>>5&31),i,S,z,T,C,f,t),0!=_)return _==y&&(i=null,r=9),e=_,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,n.inflate_flush(t,e);c.init(S[0],z[0],f,T[0],f,C[0]),r=6;case 6:if(n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=g-t.next_in_index,t.next_in_index=g,n.write=v,1!=(e=c.proc(n,t,e)))return n.inflate_flush(t,e);if(e=0,c.free(t),g=t.next_in_index,x=t.avail_in,w=n.bitb,p=n.bitk,v=n.write,E=v15?(t.inflateEnd(n),b):(t.wbits=i,n.istate.blocks=new z(n,1<>4)>r.wbits){r.mode=T,t.msg="invalid window size",r.marker=5;break}r.mode=1;case 1:if(0===t.avail_in)return n;if(n=e,t.avail_in--,t.total_in++,i=255&t.read_byte(t.next_in_index++),((r.method<<8)+i)%31!=0){r.mode=T,t.msg="incorrect header check",r.marker=5;break}if(0==(32&i)){r.mode=7;break}r.mode=2;case 2:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,r.need=(255&t.read_byte(t.next_in_index++))<<24&4278190080,r.mode=3;case 3:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,r.need+=(255&t.read_byte(t.next_in_index++))<<16&16711680,r.mode=4;case 4:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,r.need+=(255&t.read_byte(t.next_in_index++))<<8&65280,r.mode=5;case 5:return 0===t.avail_in?n:(n=e,t.avail_in--,t.total_in++,r.need+=255&t.read_byte(t.next_in_index++),r.mode=6,2);case 6:return r.mode=T,t.msg="need dictionary",r.marker=0,b;case 7:if(n=r.blocks.proc(t,n),n==y){r.mode=T,r.marker=0;break}if(0==n&&(n=e),1!=n)return n;n=e,r.blocks.reset(t,r.was),r.mode=12;case 12:return 1;case T:return y;default:return b}},t.inflateSetDictionary=function(t,e,n){let i=0,r=n;if(!t||!t.istate||6!=t.istate.mode)return b;const a=t.istate;return r>=1<{t.onload=t=>e(t.target.result),t.onerror=n,t.readAsText(this.blob,this.encoding)}))}}class j extends P{constructor(t){super(),this.dataURI=t;let e=t.length;for(;"="==t.charAt(e-1);)e--;this.dataStart=t.indexOf(",")+1,this.size=Math.floor(.75*(e-this.dataStart))}readUint8Array(t,e){const n=new Uint8Array(e),i=4*Math.floor(t/3),r=atob(this.dataURI.substring(i+this.dataStart,4*Math.ceil((t+e)/3)+this.dataStart)),a=t-3*Math.floor(i/4);for(let t=a;t2?this.data+=btoa(n):this.pending=n}getData(){return this.data+btoa(this.pending)}}class K extends P{constructor(t){super(),this.blob=t,this.size=t.size}readUint8Array(t,e){const n=new FileReader;return new Promise(((i,r)=>{n.onload=t=>i(new Uint8Array(t.target.result)),n.onerror=r,n.readAsArrayBuffer(this.blob.slice(t,t+e))}))}}class Y extends V{constructor(t){super(),this.offset=0,this.contentType=t,this.blob=new Blob([],{type:t})}writeUint8Array(t){super.writeUint8Array(t),this.blob=new Blob([this.blob,t.buffer],{type:this.contentType}),this.offset=this.blob.size}getData(){return this.blob}}class X extends P{constructor(t){super(),this.url=t}async init(){if(super.init(),function(t){if("undefined"!=typeof document){const e=document.createElement("a");return e.href=t,"http:"==e.protocol||"https:"==e.protocol}return/^https?:\/\//i.test(t)}(this.url))return new Promise(((t,e)=>{const n=new XMLHttpRequest;n.addEventListener("load",(()=>{n.status<400?(this.size=Number(n.getResponseHeader("Content-Length")),this.size?t():Q().then((()=>t())).catch(e)):e(N+(n.statusText||n.status)+".")}),!1),n.addEventListener("error",e,!1),n.open("HEAD",this.url),n.send()}));await Q()}async readUint8Array(t,e){return this.data||await Q(this,this.url),new Uint8Array(this.data.subarray(t,t+e))}}class G extends P{constructor(t){super(),this.url=t}init(){return super.init(),new Promise(((t,e)=>{const n=new XMLHttpRequest;n.addEventListener("load",(()=>{n.status<400?(this.size=Number(n.getResponseHeader("Content-Length")),"bytes"==n.getResponseHeader("Accept-Ranges")?t():e(new Error(W))):e(N+(n.statusText||n.status)+".")}),!1),n.addEventListener("error",e,!1),n.open("HEAD",this.url),n.send()}))}readUint8Array(t,e){return new Promise(((n,i)=>{const r=new XMLHttpRequest;r.open("GET",this.url),r.responseType="arraybuffer",r.setRequestHeader("Range","bytes="+t+"-"+(t+e-1)),r.addEventListener("load",(()=>{r.status<400?n(new Uint8Array(r.response)):i(N+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",i,!1),r.send()}))}}class J extends V{constructor(){super(),this.array=new Uint8Array(0)}writeUint8Array(t){super.writeUint8Array(t);const e=this.array;this.array=new Uint8Array(e.length+t.length),this.array.set(e),this.array.set(t,e.length)}getData(){return this.array}}function Q(t,e){return new Promise(((n,i)=>{const r=new XMLHttpRequest;r.addEventListener("load",(()=>{r.status<400?(t.size||(t.size=Number(r.getResponseHeader("Content-Length"))||Number(r.response.byteLength)),t.data=new Uint8Array(r.response),n()):i(N+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",i,!1),r.open("GET",e),r.responseType="arraybuffer",r.send()}))}const $=4294967295,tt=65535,et=67324752,nt=134695760,it=33639248,rt=101010256,at=101075792,st=117853008,ot=39169,lt=2048;class dt{constructor(){this.crc=-1,this.table=(()=>{const t=[];for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)1&n?n=n>>>1^3988292384:n>>>=1;t[e]=n}return t})()}append(t){const e=this.table;let n=0|this.crc;for(let i=0,r=0|t.length;i>>8^e[255&(n^t[i])];this.crc=n}get(){return~this.crc}}const ct="Invalid pasword",ut=16,ft="raw",ht={name:"PBKDF2"},_t={name:"HMAC"},wt="SHA-1",pt={name:"AES-CTR"},gt=Object.assign({hash:_t},ht),bt=Object.assign({iterations:1e3,hash:{name:wt}},ht),yt=Object.assign({hash:wt},_t),xt=Object.assign({length:ut},pt),mt=["deriveBits"],vt=["sign"],Et=528,At=10,kt=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ut=crypto.subtle;class Rt{constructor(t,e){this.password=t,this.signed=e,this.input=e&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(t){const e=async(r=0)=>{if(r+ut<=i.length-At){const t=i.subarray(r,r+ut),a=await Ut.decrypt(Object.assign({counter:this.counter},xt),this.keys.decrypt,t);return It(this.counter),n.set(new Uint8Array(a),r),e(r+ut)}return this.pendingInput=i.subarray(r),this.signed&&(this.input=St(this.input,t)),n};if(this.password){const e=t.subarray(0,18);await async function(t,e,n){t.counter=new Uint8Array(kt);const i=e.subarray(0,16),r=e.subarray(16),a=(new TextEncoder).encode(n),s=await Ut.importKey(ft,a,gt,!1,mt),o=await Ut.deriveBits(Object.assign({salt:i},bt),s,528),l=new Uint8Array(o),d=l.subarray(64);if(t.keys={decrypt:await Ut.importKey(ft,l.subarray(0,32),pt,!0,["decrypt"]),authentication:await Ut.importKey(ft,l.subarray(32,64),yt,!1,vt),passwordVerification:d},d[0]!=r[0]||d[1]!=r[1])throw new Error(ct)}(this,e,this.password),this.password=null,t=t.subarray(18)}let n=new Uint8Array(t.length-At-(t.length-At)%ut),i=t;return this.pendingInput.length&&(i=St(this.pendingInput,t),n=Ft(n,i.length-At-(i.length-At)%ut)),e()}async flush(){const t=this.pendingInput,e=this.keys,n=t.subarray(0,t.length-At),i=t.subarray(t.length-At);let r=new Uint8Array(0);if(n.length){const t=await Ut.decrypt(Object.assign({counter:this.counter},xt),e.decrypt,n);r=new Uint8Array(t)}let a=!0;if(this.signed){const t=await Ut.sign(_t,e.authentication,this.input.subarray(0,this.input.length-At)),n=new Uint8Array(t);this.input=null;for(let t=0;t{if(r+ut<=t.length){const a=t.subarray(r,r+ut),s=await Ut.encrypt(Object.assign({counter:this.counter},xt),this.keys.encrypt,a);return It(this.counter),i.set(new Uint8Array(s),r+n.length),e(r+ut)}return this.pendingInput=t.subarray(r),this.output=St(this.output,i),i};let n=new Uint8Array(0);this.password&&(n=await async function(t,e){t.counter=new Uint8Array(kt);const n=crypto.getRandomValues(new Uint8Array(16)),i=(new TextEncoder).encode(e),r=await Ut.importKey(ft,i,gt,!1,mt),a=await Ut.deriveBits(Object.assign({salt:n},bt),r,Et),s=new Uint8Array(a);return t.keys={encrypt:await Ut.importKey(ft,s.subarray(0,32),pt,!0,["encrypt"]),authentication:await Ut.importKey(ft,s.subarray(32,64),yt,!1,vt),passwordVerification:s.subarray(64)},St(n,t.keys.passwordVerification)}(this,this.password),this.password=null);let i=new Uint8Array(n.length+t.length-t.length%ut);return i.set(n,0),this.pendingInput.length&&(t=St(this.pendingInput,t),i=Ft(i,t.length-t.length%ut)),e()}async flush(){let t=new Uint8Array(0);if(this.pendingInput.length){const e=await Ut.encrypt(Object.assign({counter:this.counter},xt),this.keys.encrypt,this.pendingInput);t=new Uint8Array(e),this.output=St(this.output,t)}const e=await Ut.sign(_t,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(e).subarray(0,At);return{data:St(t,n),signature:n}}}function It(t){for(let e=0;e<16;e++){if(255!=t[e]){t[e]++;break}t[e]=0}}function St(t,e){let n=t;return t.length+e.length&&(n=new Uint8Array(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function Ft(t,e){if(e&&e>t.length){const n=t;(t=new Uint8Array(e)).set(n,0)}return t}const zt="deflate",Tt="inflate",Ct="Invalid signature";class Lt{constructor(t){this.signature=t.inputSignature,this.encrypted=Boolean(t.inputPassword),this.signed=t.inputSigned,this.compressed=t.inputCompressed,this.inflate=this.compressed&&new t.codecConstructor,this.crc32=this.signed&&this.signed&&new dt,this.decrypt=this.encrypted&&new Rt(t.inputPassword)}async append(t){return this.encrypted&&(t=await this.decrypt.append(t)),this.compressed&&t.length&&(t=await this.inflate.append(t)),!this.encrypted&&this.signed&&this.crc32.append(t),t}async flush(){let t,e=new Uint8Array(0);if(this.encrypted){const t=await this.decrypt.flush();if(!t.valid)throw new Error(Ct);e=t.data}else if(this.signed){const e=new DataView(new Uint8Array(4).buffer);if(t=this.crc32.get(),e.setUint32(0,t),this.signature!=e.getUint32(0,!1))throw new Error(Ct)}return this.compressed&&(e=await this.inflate.append(e)||new Uint8Array(0),await this.inflate.flush()),{data:e,signature:t}}}class Mt{constructor(t){this.encrypted=t.outputEncrypted,this.signed=t.outputSigned,this.compressed=t.outputCompressed,this.deflate=this.compressed&&new t.codecConstructor({level:t.level||5}),this.crc32=this.signed&&new dt,this.encrypt=this.encrypted&&new Dt(t.outputPassword)}async append(t){let e=t;return this.compressed&&t.length&&(e=await this.deflate.append(t)),this.encrypted?e=await this.encrypt.append(e):this.signed&&this.crc32.append(t),e}async flush(){let t,e=new Uint8Array(0);if(this.compressed&&(e=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){e=await this.encrypt.append(e);const n=await this.encrypt.flush();t=n.signature;const i=new Uint8Array(e.length+n.data.length);i.set(e,0),i.set(n.data,e.length),e=i}else this.signed&&(t=this.crc32.get());return{data:e,signature:t}}}const Nt="init",Wt="append",Bt="flush",Ot="message",Pt="z-worker.js",Vt={deflate:[Pt],inflate:[Pt]},Ht={pool:[],pendingRequests:[]};function Zt(t,e){const n=Ht.pool,i=!(e.inputCompressed||e.inputSigned||e.inputEncrypted||e.outputCompressed||e.outputSigned||e.outputEncrypted);let r;if(e.useWebWorkers||void 0===e.useWebWorkers&&t.useWebWorkers&&!i){const n=e.codecType;t.workerScripts?(a=t.workerScripts[n],r="undefined"!=typeof document?a.map((t=>new URL(t,document.baseURI).href)):a):(r=Vt[n].slice(0),r[0]=(t.workerScriptsPath||"")+r[0])}var a;if(n.length!t.busy));return t?jt(t,e,r):new Promise((t=>Ht.pendingRequests.push({resolve:t,options:e,scripts:r})))}}function jt(t,e,n){return t.busy=!0,t.options=e,t.scripts=n,n?function(t){let e;t.interface||(t.worker=new Worker(t.scripts[0]),t.worker.addEventListener(Ot,r,!1),t.interface={append:t=>n({type:Wt,data:t}),flush:()=>n({type:Bt})});return t.interface;async function n(n){if(!e){const e=t.options,n=t.scripts.slice(1);await i(Object.assign({scripts:n,type:Nt,options:{codecType:e.codecType,inputPassword:e.inputPassword,inputSigned:e.inputSigned,inputSignature:e.signature,inputCompressed:e.inputCompressed,inputEncrypted:e.inputEncrypted,level:e.level,outputPassword:e.outputPassword,outputSigned:e.outputSigned,outputCompressed:e.outputCompressed,outputEncrypted:e.outputEncrypted}}))}return i(n)}function i(n){const i=t.worker,r=new Promise(((t,n)=>e={resolve:t,reject:n}));try{if(n.data)try{i.postMessage(n,[n.data.buffer])}catch(t){i.postMessage(n)}else i.postMessage(n)}catch(n){e.reject(n),e=null,qt(t)}return r}function r(n){const i=n.data;if(e){const n=i.error;if(n){const i=new Error(n.message);i.stack=n.stack,e.reject(i),e=null,qt(t)}else i.type!=Nt&&i.type!=Bt&&i.type!=Wt||(i.type==Bt?(e.resolve({data:new Uint8Array(i.data),signature:i.signature}),e=null,qt(t)):e.resolve(i.data&&new Uint8Array(i.data)))}}}(t):function(t){const e=function(t){return t.codecType.startsWith(zt)?new Mt(t):t.codecType.startsWith(Tt)?new Lt(t):void 0}(t.options);return{async append(n){try{return await e.append(n)}catch(e){throw qt(t),e}},async flush(){try{return await e.flush()}finally{qt(t)}}}}(t)}function qt(t){if(t.busy=!1,Ht.pendingRequests.length){const[{resolve:e,options:n,scripts:i}]=Ht.pendingRequests.splice(0,1);e(jt(t,n,i))}else t.worker&&t.worker.terminate(),Ht.pool=Ht.pool.filter((e=>e!=t))}async function Kt(t,e,n,i,r,a,s){const o=Math.max(a.chunkSize,64);return async function a(l=0,d=0){const c=l*o;if(c","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","⌂","Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","¢","£","¥","₧","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","⌐","¬","½","¼","¡","«","»","░","▒","▓","│","┤","╡","╢","╖","╕","╣","║","╗","╝","╜","╛","┐","└","┴","┬","├","─","┼","╞","╟","╚","╔","╩","╦","╠","═","╬","╧","╨","╤","╥","╙","╘","╒","╓","╫","╪","┘","┌","█","▄","▌","▐","▀","α","ß","Γ","π","Σ","σ","µ","τ","Φ","Θ","Ω","δ","∞","φ","ε","∩","≡","±","≥","≤","⌠","⌡","÷","≈","°","∙","·","√","ⁿ","²","■"," "];class le{constructor(t,e,n){this.reader=t,this.config=e,this.options=n}async getData(t,e={}){const n=this.reader;n.initialized||await n.init();const i=await n.readUint8Array(this.offset,30),r=new DataView(i.buffer),a=void 0===e.password?this.options.password:e.password;let s=a&&a.length&&a;if(this.extraFieldAES){if(99!=this.extraFieldAES.originalCompressionMethod)throw new Error(re);if(3!=this.extraFieldAES.strength)throw new Error(ie)}if(0!=this.compressionMethod&&8!=this.compressionMethod)throw new Error(re);if(we(r,0)!=et)throw new Error(te);const o=this.localDirectory={};de(o,r,4),o.rawExtraField=i.subarray(this.offset+30+o.filenameLength,this.offset+30+o.filenameLength+o.extraFieldLength),ce(this,o,r,4);let l=this.offset+30+o.filenameLength+o.extraFieldLength;const d=this.bitFlag.encrypted&&o.bitFlag.encrypted;if(d&&!s)throw new Error(ne);const c=await Zt(this.config,{codecType:Tt,codecConstructor:this.config.Inflate,inputPassword:s,inputSigned:void 0===e.checkSignature?this.options.checkSignature:e.checkSignature,inputSignature:this.signature,inputCompressed:0!=this.compressionMethod,inputEncrypted:d,useWebWorkers:void 0===e.useWebWorkers?this.options.useWebWorkers:e.useWebWorkers});return t.initialized||await t.init(),await Kt(c,n,t,l,this.compressedSize,this.config,{onprogress:e.onprogress}),t.getData()}}function de(t,e,n){t.version=_e(e,n);const i=t.rawBitFlag=_e(e,n+2);t.bitFlag={encrypted:1==(1&i),level:(6&i)>>1,dataDescriptor:8==(8&i),languageEncodingFlag:(i<)==lt},t.encrypted=t.bitFlag.encrypted,t.rawLastModDate=we(e,n+6),t.lastModDate=function(t){const e=(4294901760&t)>>16,n=65535&t;try{return new Date(1980+((65024&e)>>9),((480&e)>>5)-1,31&e,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(t){}}(t.rawLastModDate),t.filenameLength=_e(e,n+22),t.extraFieldLength=_e(e,n+24)}function ce(t,e,n,i){const r=e.rawExtraField,a=e.extraField=new Map,s=new DataView(new Uint8Array(r).buffer);let o=0;try{for(;oe[t]==$));for(let e=0;e{if(e[n]==$){if(!t||void 0===t[n])throw new Error(ee);e[n]=t[n]}}))}(d,e);const c=e.extraFieldUnicodePath=a.get(28789);c&&ue(c,"filename","rawFilename",e,t);let u=e.extraFieldUnicodeComment=a.get(25461);u&&ue(u,"comment","rawComment",e,t);const f=e.extraFieldAES=a.get(39169);f?function(t,e,n){if(t){const i=new DataView(t.data.buffer);t.vendorVersion=he(i,0),t.vendorId=he(i,2);const r=he(i,4);t.strength=r,t.originalCompressionMethod=n,e.compressionMethod=t.compressionMethod=_e(i,5)}else e.compressionMethod=n}(f,e,l):e.compressionMethod=l,8==e.compressionMethod&&(e.bitFlag.enhancedDeflating=16!=(16&e.rawBitFlag))}function ue(t,e,n,i,r){const a=new DataView(t.data.buffer);t.version=he(a,0),t.signature=we(a,1);const s=new dt;s.append(r[n]);const o=new DataView(new Uint8Array(4).buffer);o.setUint32(0,s.get()),t[e]=(new TextDecoder).decode(t.data.subarray(5)),r.bitFlag.languageEncodingFlag||t.signature!=we(o,0)||(i[e]=t[e])}function fe(t,e){if(e&&"cp437"!=e.trim().toLowerCase())return new TextDecoder(e).decode(t);{let e="";for(let n=0;n{if(this.pendingData){const e=this.pendingData;this.pendingData=new Uint8Array(e.length+t.length),this.pendingData.set(e,0),this.pendingData.set(t,e.length)}else this.pendingData=new Uint8Array(t)};if(this.codec=new t(Object.assign({},e,n)),typeof this.codec.onData==Se)this.codec.onData=i;else{if(typeof this.codec.on!=Se)throw new Error("Cannot register the callback function");this.codec.on("data",i)}}async append(t){return this.codec.push(t),n(this)}async flush(){return this.codec.push(new Uint8Array(0),!0),n(this)}};function n(t){if(t.pendingData){const e=t.pendingData;return t.pendingData=null,e}return new Uint8Array(0)}}const ze={chunkSize:524288,maxWorkers:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||2,workerScriptsPath:void 0,useWebWorkers:!0,Deflate:function(t){const e=new g,n=512,i=new Uint8Array(n);let r=t?t.level:-1;void 0===r&&(r=-1),e.deflateInit(r),e.next_out=i,this.append=function(t,r){let a,s,o=0,l=0,d=0;const c=[];if(t.length){e.next_in_index=0,e.next_in=t,e.avail_in=t.length;do{if(e.next_out_index=0,e.avail_out=n,a=e.deflate(0),0!=a)throw new Error("deflating: "+e.msg);e.next_out_index&&(e.next_out_index==n?c.push(new Uint8Array(i)):c.push(new Uint8Array(i.subarray(0,e.next_out_index)))),d+=e.next_out_index,r&&e.next_in_index>0&&e.next_in_index!=o&&(r(e.next_in_index),o=e.next_in_index)}while(e.avail_in>0||0===e.avail_out);return s=new Uint8Array(d),c.forEach((function(t){s.set(t,l),l+=t.length})),s}},this.flush=function(){let t,r,a=0,s=0;const o=[];do{if(e.next_out_index=0,e.avail_out=n,t=e.deflate(4),1!=t&&0!=t)throw new Error("deflating: "+e.msg);n-e.avail_out>0&&o.push(new Uint8Array(i.subarray(0,e.next_out_index))),s+=e.next_out_index}while(e.avail_in>0||0===e.avail_out);return e.deflateEnd(),r=new Uint8Array(s),o.forEach((function(t){r.set(t,a),a+=t.length})),r}},Inflate:function(){const t=new M,e=new Uint8Array(512);let n=!1;t.inflateInit(),t.next_out=e,this.append=function(i,r){const a=[];let s,o,l=0,d=0,c=0;if(0!==i.length){t.next_in_index=0,t.next_in=i,t.avail_in=i.length;do{if(t.next_out_index=0,t.avail_out=512,0!==t.avail_in||n||(t.next_in_index=0,n=!0),s=t.inflate(0),n&&s===x){if(0!==t.avail_in)throw new Error("inflating: bad input")}else if(0!==s&&1!==s)throw new Error("inflating: "+t.msg);if((n||1===s)&&t.avail_in===i.length)throw new Error("inflating: bad input");t.next_out_index&&(512===t.next_out_index?a.push(new Uint8Array(e)):a.push(new Uint8Array(e.subarray(0,t.next_out_index)))),c+=t.next_out_index,r&&t.next_in_index>0&&t.next_in_index!=l&&(r(t.next_in_index),l=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return o=new Uint8Array(c),a.forEach((function(t){o.set(t,d),d+=t.length})),o}},this.flush=function(){t.inflateEnd()}}};let Te=Object.assign({},ze);class Ce extends class{constructor(t,e={},n={}){this.reader=t,this.options=e,this.config=n}async getEntries(t={}){const e=this.reader;e.initialized||await e.init();const n=await async function(t,e,n,i){const r=new Uint8Array(4);if(function(t,e,n){t.setUint32(e,n,!0)}(new DataView(r.buffer),0,e),t.size=0;t--)if(a[t]==r[0]&&a[t+1]==r[1]&&a[t+2]==r[2]&&a[t+3]==r[3])return{offset:i,buffer:a.slice(t,t+n).buffer}}}(e,rt,22,tt);if(!n)throw new Error(Gt);const i=new DataView(n.buffer);let r,a=we(i,16),s=_e(i,8);if(a==$||s==tt){r=!0;const t=await e.readUint8Array(n.offset-20,20),i=new DataView(t.buffer);if(Number(we(i,0))!=st)throw new Error(Jt);a=Number(pe(i,8));const o=await e.readUint8Array(a,56),l=new DataView(o.buffer);if(Number(we(l,0))!=at)throw new Error(Qt);s=Number(pe(l,24)),a-=Number(pe(l,40))}if(a<0||!r&&(a>=e.size||s>=tt))throw new Error(Xt);const o=await e.readUint8Array(a,e.size-a),l=new DataView(o.buffer),d=[];let c=0;for(let e=0;ett)throw new Error(xe);const r=(new TextEncoder).encode(n.comment||"");if(r.length>tt)throw new Error(ye);const a=this.options.version||n.version||0;if(a>tt)throw new Error(me);const s=n.lastModDate||new Date;if(s.getFullYear()<1980)throw new Error(ve);e&&!e.initialized&&await e.init();let o=new Uint8Array(0);const l=n.extraField;if(l){let t=4,e=0;l.forEach((e=>t+=e.length)),o=new Uint8Array(t),l.forEach(((t,n)=>{if(n>tt)throw new Error(Ee);if(t.length>tt)throw new Error(Ae);o.set(new Uint16Array([n]),e),o.set(new Uint16Array([t.length]),e+2),o.set(t,e+4),e+=4+t.length}))}const d=n.zip64||this.options.zip64||this.offset>=$||e&&(e.size>=$||this.offset+e.size>=$),c=void 0===n.password?this.options.password:n.password,u=void 0===n.level?this.options.level:n.level,f=void 0===n.useWebWorkers?this.options.useWebWorkers:n.useWebWorkers;await async function(t,e,n,i){const r=t.files,a=t.writer;let s;r.set(e,null);try{let o,l;try{i.bufferedWrite||t.options.bufferedWrite||t.lockWrite?(o=new J,o.init()):(t.lockWrite=new Promise((t=>s=t)),a.initialized||await a.init(),o=a),l=await async function(t,e,n,i){const r=i.rawFilename,a=i.lastModDate,s=i.password,o=s&&s.length,l=i.level,d=0!==l&&!i.directory,c=i.zip64;let u;if(o){u=new Uint8Array(ke.length+2);Re(new DataView(u.buffer),0,ot),u.set(ke,2)}else u=new Uint8Array(0);const f={version:i.version||20,zip64:c,directory:i.directory,rawFilename:r,rawComment:i.rawComment,extraFieldZip64:c?new Uint8Array(28):new Uint8Array(0),extraFieldAES:u,rawExtraField:i.rawExtraField};let h=2056,_=0;d&&(_=8);c&&(f.version=f.version>45?f.version:45);o&&(f.version=f.version>51?f.version:51,h|=1,_=99,d&&(f.extraFieldAES[9]=8));const w=f.headerArray=new Uint8Array(26),p=new DataView(w.buffer);Re(p,0,f.version),Re(p,2,h),Re(p,4,_),Re(p,6,(a.getHours()<<6|a.getMinutes())<<5|a.getSeconds()/2),Re(p,8,(a.getFullYear()-1980<<4|a.getMonth()+1)<<5|a.getDate()),Re(p,22,r.length),Re(p,24,0);const g=new Uint8Array(30+r.length);let b,y,x;if(De(new DataView(g.buffer),0,et),g.set(w,4),g.set(r,30),t){y=t.size;const r=await Zt(n,{codecType:zt,codecConstructor:n.Deflate,level:l,outputPassword:s,outputSigned:!0,outputCompressed:d,outputEncrypted:o,useWebWorkers:i.useWebWorkers});await e.writeUint8Array(g),b=await Kt(r,t,e,0,y,n,{onprogress:i.onprogress}),x=b.length}else await e.writeUint8Array(g);const m=new Uint8Array(c?24:16),v=new DataView(m.buffer);if(De(v,0,nt),t)if(o||void 0===b.signature||(De(p,10,b.signature),De(v,4,b.signature)),c){const t=new DataView(f.extraFieldZip64.buffer);Re(t,0,1),Re(t,2,24),De(p,14,$),Ie(v,8,BigInt(x)),Ie(t,12,BigInt(x)),De(p,18,$),Ie(v,16,BigInt(y)),Ie(t,4,BigInt(y))}else De(p,14,x),De(v,8,x),De(p,18,y),De(v,12,y);return await e.writeUint8Array(m),f.length=g.length+(b?b.length:0)+m.length,f}(n,o,t.config,i)}catch(t){throw r.delete(e),t}if(r.set(e,l),o!=a&&(t.lockWrite&&await t.lockWrite,await a.writeUint8Array(o.getData())),l.offset=t.offset,l.zip64){Ie(new DataView(l.extraFieldZip64.buffer),20,BigInt(l.offset))}t.offset+=l.length}finally{s&&(t.lockWrite=null,s())}}(this,t,e,Object.assign({},n,{rawFilename:i,rawComment:r,version:a,lastModDate:s,rawExtraField:o,zip64:d,password:c,level:u,useWebWorkers:f}))}async close(t=new Uint8Array(0)){const e=this.writer,n=this.files;let i=0,r=0,a=this.offset,s=n.size;if(t.length){if(!(t.length<=tt))throw new Error(be);Re(d,i+20,t.length)}for(const[,t]of n)r+=46+t.rawFilename.length+t.rawComment.length+t.extraFieldZip64.length+t.extraFieldAES.length+t.rawExtraField.length;const o=this.options.zip64||a+r>=$||s>=tt,l=new Uint8Array(r+(o?98:22)),d=new DataView(l.buffer);for(const[,t]of n){const e=t.rawFilename,n=t.extraFieldZip64,r=t.extraFieldAES,a=n.length+r.length+t.rawExtraField.length;De(d,i,it),Re(d,i+4,t.version),l.set(t.headerArray,i+6),Re(d,i+30,a),Re(d,i+32,t.rawComment.length),t.directory&&Ue(d,i+38,16),t.zip64?De(d,i+42,$):De(d,i+42,t.offset),l.set(e,i+46),l.set(n,i+46+e.length),l.set(r,i+46+e.length+n.length),l.set(t.rawExtraField,46+e.length+n.length+r.length),l.set(t.rawComment,i+46+e.length+a),i+=46+e.length+a+t.rawComment.length}return o&&(De(d,i,at),Ie(d,i+4,BigInt(44)),Re(d,i+12,45),Re(d,i+14,45),Ie(d,i+24,BigInt(s)),Ie(d,i+32,BigInt(s)),Ie(d,i+40,BigInt(r)),Ie(d,i+48,BigInt(a)),De(d,i+56,st),Ie(d,i+64,BigInt(a+r)),De(d,i+72,1),s=tt,a=$,i+=76),De(d,i,rt),Re(d,i+8,s),Re(d,i+10,s),De(d,i+12,r),De(d,i+16,a),await e.writeUint8Array(l),await e.writeUint8Array(t),e.getData()}}{constructor(t,e){super(t,e,Te)}}const Me=524288;class Ne{constructor(t,e,n,i){if(t.root&&i&&i.getChildByName(e))throw new Error("Entry filename already exists");n||(n={}),this.fs=t,this.name=e,this.data=n.data,this.id=t.entries.length,this.parent=i,this.children=[],this.uncompressedSize=0,t.entries.push(this),i&&this.parent.children.push(this)}moveTo(t){if(!t.directory)throw new Error("Target entry is not a directory");if(t.isDescendantOf(this))throw new Error("Entry is a ancestor of target entry");if(this!=t){if(t.getChildByName(this.name))throw new Error("Entry filename already exists");Ze(this),this.parent=t,t.children.push(this)}}getFullname(){let t=this.name,e=this.parent;for(;e;)t=(e.name?e.name+"/":"")+t,e=e.parent;return t}isDescendantOf(t){let e=this.parent;for(;e&&e.id!=t.id;)e=e.parent;return Boolean(e)}}class We extends Ne{constructor(t,e,n,i){super(t,e,n,i),this.Reader=n.Reader,this.Writer=n.Writer,n.getData&&(this.getData=n.getData)}async getData(t,e={}){return!t||t.constructor==this.Writer&&this.data?this.data:(this.reader||(this.reader=new this.Reader(this.data)),await this.reader.init(),await t.init(),this.uncompressedSize=this.reader.size,async function(t,e,n){return i();async function i(r=0){const a=r*Me;if(n.onprogress&&n.onprogress(a,t.size),a{e.file((i=>{t.addBlob(e.name,i),n()}),i)}));function n(t){return new Promise(((e,n)=>{let i=[];function r(t){t.readEntries((n=>{n.length?(i=i.concat(n),r(t)):e(i)}),n)}t.isDirectory&&r(t.createReader()),t.isFile&&e(i)}))}async function i(t,e){const r=await n(e);for(const e of r)e.isDirectory&&await i(t.addDirectory(e.name)),await new Promise(((n,i)=>{e.isFile&&e.file((i=>{const r=t.addBlob(e.name,i);r.uncompressedSize=i.size,n(r)}),i)}))}}(this,t)}async addData(t,e){return qe(this,t,e)}async importBlob(t,e={}){await this.importZip(new K(t),e)}async importData64URI(t,e={}){await this.importZip(new j(t),e)}async importHttpContent(t,e={}){await this.importZip(e.useRangeHeader?new G(t):new X(t),e)}async exportBlob(t={}){return this.exportZip(new Y("application/zip"),t)}async exportData64URI(t={}){return this.exportZip(new q("application/zip"),t)}async importZip(t,e){await t.init();const n=new Ce(t,e),i=await n.getEntries();let r=0;const a=Pe(i,"compressedSize");i.forEach((t=>{let n=this,i=t.filename.split("/"),s=i.pop();if(i.forEach((t=>n=n.getChildByName(t)||new Be(this.fs,t,null,n))),!t.directory){let i=r;qe(n,s,{data:t,Reader:Ve(Object.assign({},{onprogress:t=>{e.onprogress&&e.onprogress(i+t,a)}}))}),r+=t.compressedSize}}))}async exportZip(t,e){await He(this);const n=new Le(t,e);return await async function(t,e,n,i){let r=0;async function a(t,e){async function s(){let s=0;for(const o of e.children){let e=r;await t.add(o.getFullname(),o.reader,Object.assign({directory:o.directory},{onprogress:t=>{i.onprogress&&i.onprogress(e+s+t,n)}})),r+=o.uncompressedSize,await a(t,o),s++}}await s()}await a(t,e)}(n,this,Pe([this],"uncompressedSize"),e),await n.close(),t.getData()}getChildByName(t){for(let e=0;e{n.id==t.id&&e.splice(i,1)}))}function je(t){t.entries=[],t.root=new Be(t)}function qe(t,e,n,i){if(t.directory)return i?new Be(t.fs,e,n,t):new We(t.fs,e,n,t);throw new Error("Parent entry is not a directory")}t.BlobReader=K,t.BlobWriter=Y,t.Data64URIReader=j,t.Data64URIWriter=q,t.ERR_BAD_FORMAT=Xt,t.ERR_CENTRAL_DIRECTORY_NOT_FOUND=$t,t.ERR_DUPLICATED_NAME=ge,t.ERR_ENCRYPTED=ne,t.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND=Qt,t.ERR_EOCDR_NOT_FOUND=Gt,t.ERR_EOCDR_ZIP64_NOT_FOUND=Jt,t.ERR_EXTRAFIELD_ZIP64_NOT_FOUND=ee,t.ERR_HTTP_RANGE=W,t.ERR_INVALID_COMMENT=be,t.ERR_INVALID_DATE=ve,t.ERR_INVALID_ENTRY_COMMENT=ye,t.ERR_INVALID_ENTRY_NAME=xe,t.ERR_INVALID_EXTRAFIELD_DATA=Ae,t.ERR_INVALID_EXTRAFIELD_TYPE=Ee,t.ERR_INVALID_PASSORD=ct,t.ERR_INVALID_SIGNATURE=Ct,t.ERR_INVALID_VERSION=me,t.ERR_LOCAL_FILE_HEADER_NOT_FOUND=te,t.ERR_UNSUPPORTED_COMPRESSION=re,t.ERR_UNSUPPORTED_ENCRYPTION=ie,t.HttpRangeReader=G,t.HttpReader=X,t.Reader=P,t.TextReader=H,t.TextWriter=Z,t.Uint8ArrayReader=class extends P{constructor(t){super(),this.array=t,this.size=t.length}readUint8Array(t,e){return this.array.slice(t,t+e)}},t.Uint8ArrayWriter=J,t.Writer=V,t.ZipReader=Ce,t.ZipWriter=Le,t.configure=function(t){if(Te=Object.assign({},Te,t),null!=Te.workerScripts&&null!=Te.workerScriptsPath)throw new Error("Either workerScripts or workerScriptsPath may be set, not both");if(Te.workerScripts){if(Te.workerScripts.deflate&&!Array.isArray(Te.workerScripts.deflate))throw new Error("workerScripts.deflate must be an array");if(Te.workerScripts.inflate&&!Array.isArray(Te.workerScripts.inflate))throw new Error("workerScripts.inflate must be an array")}},t.fs=Oe,t.getMimeType=function(){return"application/octet-stream"},t.initShimAsyncCodec=(t,e={})=>({Deflate:Fe(t.Deflate,e.deflate),Inflate:Fe(t.Inflate,e.inflate)}),Object.defineProperty(t,"__esModule",{value:!0})})); diff --git a/dist/zip.js b/dist/zip.js index 828654ba..52f927c1 100644 --- a/dist/zip.js +++ b/dist/zip.js @@ -4,6 +4,4212 @@ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.zip = {})); }(this, (function (exports) { 'use strict'; + /* + Copyright (c) 2021 Gildas Lormeau. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + // Global + + const MAX_BITS = 15; + const D_CODES = 30; + const BL_CODES = 19; + + const LENGTH_CODES = 29; + const LITERALS = 256; + const L_CODES = (LITERALS + 1 + LENGTH_CODES); + const HEAP_SIZE = (2 * L_CODES + 1); + + const END_BLOCK = 256; + + // Bit length codes must not exceed MAX_BL_BITS bits + const MAX_BL_BITS = 7; + + // repeat previous bit length 3-6 times (2 bits of repeat count) + const REP_3_6 = 16; + + // repeat a zero length 3-10 times (3 bits of repeat count) + const REPZ_3_10 = 17; + + // repeat a zero length 11-138 times (7 bits of repeat count) + const REPZ_11_138 = 18; + + // The lengths of the bit length codes are sent in order of decreasing + // probability, to avoid transmitting the lengths for unused bit + // length codes. + + const Buf_size = 8 * 2; + + // JZlib version : "1.0.2" + const Z_DEFAULT_COMPRESSION = -1; + + // compression strategy + const Z_FILTERED = 1; + const Z_HUFFMAN_ONLY = 2; + const Z_DEFAULT_STRATEGY = 0; + + const Z_NO_FLUSH = 0; + const Z_PARTIAL_FLUSH = 1; + const Z_FULL_FLUSH = 3; + const Z_FINISH = 4; + + const Z_OK = 0; + const Z_STREAM_END = 1; + const Z_NEED_DICT = 2; + const Z_STREAM_ERROR = -2; + const Z_DATA_ERROR = -3; + const Z_BUF_ERROR = -5; + + // Tree + + // see definition of array dist_code below + const _dist_code = [0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, + 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 18, 18, 19, 19, + 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, + 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]; + + function Tree() { + const that = this; + + // dyn_tree; // the dynamic tree + // max_code; // largest code with non zero frequency + // stat_desc; // the corresponding static tree + + // Compute the optimal bit lengths for a tree and update the total bit + // length + // for the current block. + // IN assertion: the fields freq and dad are set, heap[heap_max] and + // above are the tree nodes sorted by increasing frequency. + // OUT assertions: the field len is set to the optimal bit length, the + // array bl_count contains the frequencies for each bit length. + // The length opt_len is updated; static_len is also updated if stree is + // not null. + function gen_bitlen(s) { + const tree = that.dyn_tree; + const stree = that.stat_desc.static_tree; + const extra = that.stat_desc.extra_bits; + const base = that.stat_desc.extra_base; + const max_length = that.stat_desc.max_length; + let h; // heap index + let n, m; // iterate over the tree elements + let bits; // bit length + let xbits; // extra bits + let f; // frequency + let overflow = 0; // number of elements with bit length too large + + for (bits = 0; bits <= MAX_BITS; bits++) + s.bl_count[bits] = 0; + + // In a first pass, compute the optimal bit lengths (which may + // overflow in the case of the bit length tree). + tree[s.heap[s.heap_max] * 2 + 1] = 0; // root of the heap + + for (h = s.heap_max + 1; h < HEAP_SIZE; h++) { + n = s.heap[h]; + bits = tree[tree[n * 2 + 1] * 2 + 1] + 1; + if (bits > max_length) { + bits = max_length; + overflow++; + } + tree[n * 2 + 1] = bits; + // We overwrite tree[n*2+1] which is no longer needed + + if (n > that.max_code) + continue; // not a leaf node + + s.bl_count[bits]++; + xbits = 0; + if (n >= base) + xbits = extra[n - base]; + f = tree[n * 2]; + s.opt_len += f * (bits + xbits); + if (stree) + s.static_len += f * (stree[n * 2 + 1] + xbits); + } + if (overflow === 0) + return; + + // This happens for example on obj2 and pic of the Calgary corpus + // Find the first bit length which could increase: + do { + bits = max_length - 1; + while (s.bl_count[bits] === 0) + bits--; + s.bl_count[bits]--; // move one leaf down the tree + s.bl_count[bits + 1] += 2; // move one overflow item as its brother + s.bl_count[max_length]--; + // The brother of the overflow item also moves one step up, + // but this does not affect bl_count[max_length] + overflow -= 2; + } while (overflow > 0); + + for (bits = max_length; bits !== 0; bits--) { + n = s.bl_count[bits]; + while (n !== 0) { + m = s.heap[--h]; + if (m > that.max_code) + continue; + if (tree[m * 2 + 1] != bits) { + s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2]; + tree[m * 2 + 1] = bits; + } + n--; + } + } + } + + // Reverse the first len bits of a code, using straightforward code (a + // faster + // method would use a table) + // IN assertion: 1 <= len <= 15 + function bi_reverse(code, // the value to invert + len // its bit length + ) { + let res = 0; + do { + res |= code & 1; + code >>>= 1; + res <<= 1; + } while (--len > 0); + return res >>> 1; + } + + // Generate the codes for a given tree and bit counts (which need not be + // optimal). + // IN assertion: the array bl_count contains the bit length statistics for + // the given tree and the field len is set for all tree elements. + // OUT assertion: the field code is set for all tree elements of non + // zero code length. + function gen_codes(tree, // the tree to decorate + max_code, // largest code with non zero frequency + bl_count // number of codes at each bit length + ) { + const next_code = []; // next code value for each + // bit length + let code = 0; // running code value + let bits; // bit index + let n; // code index + let len; + + // The distribution counts are first used to generate the code values + // without bit reversal. + for (bits = 1; bits <= MAX_BITS; bits++) { + next_code[bits] = code = ((code + bl_count[bits - 1]) << 1); + } + + // Check that the bit counts in bl_count are consistent. The last code + // must be all ones. + // Assert (code + bl_count[MAX_BITS]-1 == (1<= 1; n--) + s.pqdownheap(tree, n); + + // Construct the Huffman tree by repeatedly combining the least two + // frequent nodes. + + node = elems; // next internal node of the tree + do { + // n = node of least frequency + n = s.heap[1]; + s.heap[1] = s.heap[s.heap_len--]; + s.pqdownheap(tree, 1); + m = s.heap[1]; // m = node of next least frequency + + s.heap[--s.heap_max] = n; // keep the nodes sorted by frequency + s.heap[--s.heap_max] = m; + + // Create a new node father of n and m + tree[node * 2] = (tree[n * 2] + tree[m * 2]); + s.depth[node] = Math.max(s.depth[n], s.depth[m]) + 1; + tree[n * 2 + 1] = tree[m * 2 + 1] = node; + + // and insert the new node in the heap + s.heap[1] = node++; + s.pqdownheap(tree, 1); + } while (s.heap_len >= 2); + + s.heap[--s.heap_max] = s.heap[1]; + + // At this point, the fields freq and dad are set. We can now + // generate the bit lengths. + + gen_bitlen(s); + + // The field len is now set, we can generate the bit codes + gen_codes(tree, that.max_code, s.bl_count); + }; + + } + + Tree._length_code = [0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, + 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, + 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, + 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, + 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, + 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, + 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28]; + + Tree.base_length = [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]; + + Tree.base_dist = [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]; + + // Mapping from a distance to a distance code. dist is the distance - 1 and + // must not have side effects. _dist_code[256] and _dist_code[257] are never + // used. + Tree.d_code = function (dist) { + return ((dist) < 256 ? _dist_code[dist] : _dist_code[256 + ((dist) >>> 7)]); + }; + + // extra bits for each length code + Tree.extra_lbits = [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]; + + // extra bits for each distance code + Tree.extra_dbits = [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]; + + // extra bits for each bit length code + Tree.extra_blbits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7]; + + Tree.bl_order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; + + // StaticTree + + function StaticTree(static_tree, extra_bits, extra_base, elems, max_length) { + const that = this; + that.static_tree = static_tree; + that.extra_bits = extra_bits; + that.extra_base = extra_base; + that.elems = elems; + that.max_length = max_length; + } + + StaticTree.static_ltree = [12, 8, 140, 8, 76, 8, 204, 8, 44, 8, 172, 8, 108, 8, 236, 8, 28, 8, 156, 8, 92, 8, 220, 8, 60, 8, 188, 8, 124, 8, 252, 8, 2, 8, + 130, 8, 66, 8, 194, 8, 34, 8, 162, 8, 98, 8, 226, 8, 18, 8, 146, 8, 82, 8, 210, 8, 50, 8, 178, 8, 114, 8, 242, 8, 10, 8, 138, 8, 74, 8, 202, 8, 42, + 8, 170, 8, 106, 8, 234, 8, 26, 8, 154, 8, 90, 8, 218, 8, 58, 8, 186, 8, 122, 8, 250, 8, 6, 8, 134, 8, 70, 8, 198, 8, 38, 8, 166, 8, 102, 8, 230, 8, + 22, 8, 150, 8, 86, 8, 214, 8, 54, 8, 182, 8, 118, 8, 246, 8, 14, 8, 142, 8, 78, 8, 206, 8, 46, 8, 174, 8, 110, 8, 238, 8, 30, 8, 158, 8, 94, 8, + 222, 8, 62, 8, 190, 8, 126, 8, 254, 8, 1, 8, 129, 8, 65, 8, 193, 8, 33, 8, 161, 8, 97, 8, 225, 8, 17, 8, 145, 8, 81, 8, 209, 8, 49, 8, 177, 8, 113, + 8, 241, 8, 9, 8, 137, 8, 73, 8, 201, 8, 41, 8, 169, 8, 105, 8, 233, 8, 25, 8, 153, 8, 89, 8, 217, 8, 57, 8, 185, 8, 121, 8, 249, 8, 5, 8, 133, 8, + 69, 8, 197, 8, 37, 8, 165, 8, 101, 8, 229, 8, 21, 8, 149, 8, 85, 8, 213, 8, 53, 8, 181, 8, 117, 8, 245, 8, 13, 8, 141, 8, 77, 8, 205, 8, 45, 8, + 173, 8, 109, 8, 237, 8, 29, 8, 157, 8, 93, 8, 221, 8, 61, 8, 189, 8, 125, 8, 253, 8, 19, 9, 275, 9, 147, 9, 403, 9, 83, 9, 339, 9, 211, 9, 467, 9, + 51, 9, 307, 9, 179, 9, 435, 9, 115, 9, 371, 9, 243, 9, 499, 9, 11, 9, 267, 9, 139, 9, 395, 9, 75, 9, 331, 9, 203, 9, 459, 9, 43, 9, 299, 9, 171, 9, + 427, 9, 107, 9, 363, 9, 235, 9, 491, 9, 27, 9, 283, 9, 155, 9, 411, 9, 91, 9, 347, 9, 219, 9, 475, 9, 59, 9, 315, 9, 187, 9, 443, 9, 123, 9, 379, + 9, 251, 9, 507, 9, 7, 9, 263, 9, 135, 9, 391, 9, 71, 9, 327, 9, 199, 9, 455, 9, 39, 9, 295, 9, 167, 9, 423, 9, 103, 9, 359, 9, 231, 9, 487, 9, 23, + 9, 279, 9, 151, 9, 407, 9, 87, 9, 343, 9, 215, 9, 471, 9, 55, 9, 311, 9, 183, 9, 439, 9, 119, 9, 375, 9, 247, 9, 503, 9, 15, 9, 271, 9, 143, 9, + 399, 9, 79, 9, 335, 9, 207, 9, 463, 9, 47, 9, 303, 9, 175, 9, 431, 9, 111, 9, 367, 9, 239, 9, 495, 9, 31, 9, 287, 9, 159, 9, 415, 9, 95, 9, 351, 9, + 223, 9, 479, 9, 63, 9, 319, 9, 191, 9, 447, 9, 127, 9, 383, 9, 255, 9, 511, 9, 0, 7, 64, 7, 32, 7, 96, 7, 16, 7, 80, 7, 48, 7, 112, 7, 8, 7, 72, 7, + 40, 7, 104, 7, 24, 7, 88, 7, 56, 7, 120, 7, 4, 7, 68, 7, 36, 7, 100, 7, 20, 7, 84, 7, 52, 7, 116, 7, 3, 8, 131, 8, 67, 8, 195, 8, 35, 8, 163, 8, + 99, 8, 227, 8]; + + StaticTree.static_dtree = [0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, + 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5]; + + StaticTree.static_l_desc = new StaticTree(StaticTree.static_ltree, Tree.extra_lbits, LITERALS + 1, L_CODES, MAX_BITS); + + StaticTree.static_d_desc = new StaticTree(StaticTree.static_dtree, Tree.extra_dbits, 0, D_CODES, MAX_BITS); + + StaticTree.static_bl_desc = new StaticTree(null, Tree.extra_blbits, 0, BL_CODES, MAX_BL_BITS); + + // Deflate + + const MAX_MEM_LEVEL = 9; + const DEF_MEM_LEVEL = 8; + + function Config(good_length, max_lazy, nice_length, max_chain, func) { + const that = this; + that.good_length = good_length; + that.max_lazy = max_lazy; + that.nice_length = nice_length; + that.max_chain = max_chain; + that.func = func; + } + + const STORED = 0; + const FAST = 1; + const SLOW = 2; + const config_table = [ + new Config(0, 0, 0, 0, STORED), + new Config(4, 4, 8, 4, FAST), + new Config(4, 5, 16, 8, FAST), + new Config(4, 6, 32, 32, FAST), + new Config(4, 4, 16, 16, SLOW), + new Config(8, 16, 32, 32, SLOW), + new Config(8, 16, 128, 128, SLOW), + new Config(8, 32, 128, 256, SLOW), + new Config(32, 128, 258, 1024, SLOW), + new Config(32, 258, 258, 4096, SLOW) + ]; + + const z_errmsg = ["need dictionary", // Z_NEED_DICT + // 2 + "stream end", // Z_STREAM_END 1 + "", // Z_OK 0 + "", // Z_ERRNO (-1) + "stream error", // Z_STREAM_ERROR (-2) + "data error", // Z_DATA_ERROR (-3) + "", // Z_MEM_ERROR (-4) + "buffer error", // Z_BUF_ERROR (-5) + "",// Z_VERSION_ERROR (-6) + ""]; + + // block not completed, need more input or more output + const NeedMore = 0; + + // block flush performed + const BlockDone = 1; + + // finish started, need only more output at next deflate + const FinishStarted = 2; + + // finish done, accept no more input or output + const FinishDone = 3; + + // preset dictionary flag in zlib header + const PRESET_DICT = 0x20; + + const INIT_STATE = 42; + const BUSY_STATE = 113; + const FINISH_STATE = 666; + + // The deflate compression method + const Z_DEFLATED = 8; + + const STORED_BLOCK = 0; + const STATIC_TREES = 1; + const DYN_TREES = 2; + + const MIN_MATCH = 3; + const MAX_MATCH = 258; + const MIN_LOOKAHEAD = (MAX_MATCH + MIN_MATCH + 1); + + function smaller(tree, n, m, depth) { + const tn2 = tree[n * 2]; + const tm2 = tree[m * 2]; + return (tn2 < tm2 || (tn2 == tm2 && depth[n] <= depth[m])); + } + + function Deflate() { + + const that = this; + let strm; // pointer back to this zlib stream + let status; // as the name implies + // pending_buf; // output still pending + let pending_buf_size; // size of pending_buf + // pending_out; // next pending byte to output to the stream + // pending; // nb of bytes in the pending buffer + let last_flush; // value of flush param for previous deflate call + + let w_size; // LZ77 window size (32K by default) + let w_bits; // log2(w_size) (8..16) + let w_mask; // w_size - 1 + + let window; + // Sliding window. Input bytes are read into the second half of the window, + // and move to the first half later to keep a dictionary of at least wSize + // bytes. With this organization, matches are limited to a distance of + // wSize-MAX_MATCH bytes, but this ensures that IO is always + // performed with a length multiple of the block size. Also, it limits + // the window size to 64K, which is quite useful on MSDOS. + // To do: use the user input buffer as sliding window. + + let window_size; + // Actual size of window: 2*wSize, except when the user input buffer + // is directly used as sliding window. + + let prev; + // Link to older string with same hash index. To limit the size of this + // array to 64K, this link is maintained only for the last 32K strings. + // An index in this array is thus a window index modulo 32K. + + let head; // Heads of the hash chains or NIL. + + let ins_h; // hash index of string to be inserted + let hash_size; // number of elements in hash table + let hash_bits; // log2(hash_size) + let hash_mask; // hash_size-1 + + // Number of bits by which ins_h must be shifted at each input + // step. It must be such that after MIN_MATCH steps, the oldest + // byte no longer takes part in the hash key, that is: + // hash_shift * MIN_MATCH >= hash_bits + let hash_shift; + + // Window position at the beginning of the current output block. Gets + // negative when the window is moved backwards. + + let block_start; + + let match_length; // length of best match + let prev_match; // previous match + let match_available; // set if previous match exists + let strstart; // start of string to insert + let match_start; // start of matching string + let lookahead; // number of valid bytes ahead in window + + // Length of the best match at previous step. Matches not greater than this + // are discarded. This is used in the lazy match evaluation. + let prev_length; + + // To speed up deflation, hash chains are never searched beyond this + // length. A higher limit improves compression ratio but degrades the speed. + let max_chain_length; + + // Attempt to find a better match only when the current match is strictly + // smaller than this value. This mechanism is used only for compression + // levels >= 4. + let max_lazy_match; + + // Insert new strings in the hash table only if the match length is not + // greater than this length. This saves time but degrades compression. + // max_insert_length is used only for compression levels <= 3. + + let level; // compression level (1..9) + let strategy; // favor or force Huffman coding + + // Use a faster search when the previous match is longer than this + let good_match; + + // Stop searching when current match exceeds this + let nice_match; + + let dyn_ltree; // literal and length tree + let dyn_dtree; // distance tree + let bl_tree; // Huffman tree for bit lengths + + const l_desc = new Tree(); // desc for literal tree + const d_desc = new Tree(); // desc for distance tree + const bl_desc = new Tree(); // desc for bit length tree + + // that.heap_len; // number of elements in the heap + // that.heap_max; // element of largest frequency + // The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. + // The same heap array is used to build all trees. + + // Depth of each subtree used as tie breaker for trees of equal frequency + that.depth = []; + + let l_buf; // index for literals or lengths */ + + // Size of match buffer for literals/lengths. There are 4 reasons for + // limiting lit_bufsize to 64K: + // - frequencies can be kept in 16 bit counters + // - if compression is not successful for the first block, all input + // data is still in the window so we can still emit a stored block even + // when input comes from standard input. (This can also be done for + // all blocks if lit_bufsize is not greater than 32K.) + // - if compression is not successful for a file smaller than 64K, we can + // even emit a stored file instead of a stored block (saving 5 bytes). + // This is applicable only for zip (not gzip or zlib). + // - creating new Huffman trees less frequently may not provide fast + // adaptation to changes in the input data statistics. (Take for + // example a binary file with poorly compressible code followed by + // a highly compressible string table.) Smaller buffer sizes give + // fast adaptation but have of course the overhead of transmitting + // trees more frequently. + // - I can't count above 4 + let lit_bufsize; + + let last_lit; // running index in l_buf + + // Buffer for distances. To simplify the code, d_buf and l_buf have + // the same number of elements. To use different lengths, an extra flag + // array would be necessary. + + let d_buf; // index of pendig_buf + + // that.opt_len; // bit length of current block with optimal trees + // that.static_len; // bit length of current block with static trees + let matches; // number of string matches in current block + let last_eob_len; // bit length of EOB code for last block + + // Output buffer. bits are inserted starting at the bottom (least + // significant bits). + let bi_buf; + + // Number of valid bits in bi_buf. All bits above the last valid bit + // are always zero. + let bi_valid; + + // number of codes at each bit length for an optimal tree + that.bl_count = []; + + // heap used to build the Huffman trees + that.heap = []; + + dyn_ltree = []; + dyn_dtree = []; + bl_tree = []; + + function lm_init() { + window_size = 2 * w_size; + + head[hash_size - 1] = 0; + for (let i = 0; i < hash_size - 1; i++) { + head[i] = 0; + } + + // Set the default configuration parameters: + max_lazy_match = config_table[level].max_lazy; + good_match = config_table[level].good_length; + nice_match = config_table[level].nice_length; + max_chain_length = config_table[level].max_chain; + + strstart = 0; + block_start = 0; + lookahead = 0; + match_length = prev_length = MIN_MATCH - 1; + match_available = 0; + ins_h = 0; + } + + function init_block() { + let i; + // Initialize the trees. + for (i = 0; i < L_CODES; i++) + dyn_ltree[i * 2] = 0; + for (i = 0; i < D_CODES; i++) + dyn_dtree[i * 2] = 0; + for (i = 0; i < BL_CODES; i++) + bl_tree[i * 2] = 0; + + dyn_ltree[END_BLOCK * 2] = 1; + that.opt_len = that.static_len = 0; + last_lit = matches = 0; + } + + // Initialize the tree data structures for a new zlib stream. + function tr_init() { + + l_desc.dyn_tree = dyn_ltree; + l_desc.stat_desc = StaticTree.static_l_desc; + + d_desc.dyn_tree = dyn_dtree; + d_desc.stat_desc = StaticTree.static_d_desc; + + bl_desc.dyn_tree = bl_tree; + bl_desc.stat_desc = StaticTree.static_bl_desc; + + bi_buf = 0; + bi_valid = 0; + last_eob_len = 8; // enough lookahead for inflate + + // Initialize the first block of the first file: + init_block(); + } + + // Restore the heap property by moving down the tree starting at node k, + // exchanging a node with the smallest of its two sons if necessary, + // stopping + // when the heap property is re-established (each father smaller than its + // two sons). + that.pqdownheap = function (tree, // the tree to restore + k // node to move down + ) { + const heap = that.heap; + const v = heap[k]; + let j = k << 1; // left son of k + while (j <= that.heap_len) { + // Set j to the smallest of the two sons: + if (j < that.heap_len && smaller(tree, heap[j + 1], heap[j], that.depth)) { + j++; + } + // Exit if v is smaller than both sons + if (smaller(tree, v, heap[j], that.depth)) + break; + + // Exchange v with the smallest son + heap[k] = heap[j]; + k = j; + // And continue down the tree, setting j to the left son of k + j <<= 1; + } + heap[k] = v; + }; + + // Scan a literal or distance tree to determine the frequencies of the codes + // in the bit length tree. + function scan_tree(tree,// the tree to be scanned + max_code // and its largest code of non zero frequency + ) { + let prevlen = -1; // last emitted length + let curlen; // length of current code + let nextlen = tree[0 * 2 + 1]; // length of next code + let count = 0; // repeat count of the current code + let max_count = 7; // max repeat count + let min_count = 4; // min repeat count + + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + tree[(max_code + 1) * 2 + 1] = 0xffff; // guard + + for (let n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[(n + 1) * 2 + 1]; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + bl_tree[curlen * 2] += count; + } else if (curlen !== 0) { + if (curlen != prevlen) + bl_tree[curlen * 2]++; + bl_tree[REP_3_6 * 2]++; + } else if (count <= 10) { + bl_tree[REPZ_3_10 * 2]++; + } else { + bl_tree[REPZ_11_138 * 2]++; + } + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } else if (curlen == nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; + } + } + } + + // Construct the Huffman tree for the bit lengths and return the index in + // bl_order of the last bit length code to send. + function build_bl_tree() { + let max_blindex; // index of last bit length code of non zero freq + + // Determine the bit length frequencies for literal and distance trees + scan_tree(dyn_ltree, l_desc.max_code); + scan_tree(dyn_dtree, d_desc.max_code); + + // Build the bit length tree: + bl_desc.build_tree(that); + // opt_len now includes the length of the tree representations, except + // the lengths of the bit lengths codes and the 5+5+4 bits for the + // counts. + + // Determine the number of bit length codes to send. The pkzip format + // requires that at least 4 bit length codes be sent. (appnote.txt says + // 3 but the actual value used is 4.) + for (max_blindex = BL_CODES - 1; max_blindex >= 3; max_blindex--) { + if (bl_tree[Tree.bl_order[max_blindex] * 2 + 1] !== 0) + break; + } + // Update opt_len to include the bit length tree and counts + that.opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; + + return max_blindex; + } + + // Output a byte on the stream. + // IN assertion: there is enough room in pending_buf. + function put_byte(p) { + that.pending_buf[that.pending++] = p; + } + + function put_short(w) { + put_byte(w & 0xff); + put_byte((w >>> 8) & 0xff); + } + + function putShortMSB(b) { + put_byte((b >> 8) & 0xff); + put_byte((b & 0xff) & 0xff); + } + + function send_bits(value, length) { + let val; + const len = length; + if (bi_valid > Buf_size - len) { + val = value; + // bi_buf |= (val << bi_valid); + bi_buf |= ((val << bi_valid) & 0xffff); + put_short(bi_buf); + bi_buf = val >>> (Buf_size - bi_valid); + bi_valid += len - Buf_size; + } else { + // bi_buf |= (value) << bi_valid; + bi_buf |= (((value) << bi_valid) & 0xffff); + bi_valid += len; + } + } + + function send_code(c, tree) { + const c2 = c * 2; + send_bits(tree[c2] & 0xffff, tree[c2 + 1] & 0xffff); + } + + // Send a literal or distance tree in compressed form, using the codes in + // bl_tree. + function send_tree(tree,// the tree to be sent + max_code // and its largest code of non zero frequency + ) { + let n; // iterates over all tree elements + let prevlen = -1; // last emitted length + let curlen; // length of current code + let nextlen = tree[0 * 2 + 1]; // length of next code + let count = 0; // repeat count of the current code + let max_count = 7; // max repeat count + let min_count = 4; // min repeat count + + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } + + for (n = 0; n <= max_code; n++) { + curlen = nextlen; + nextlen = tree[(n + 1) * 2 + 1]; + if (++count < max_count && curlen == nextlen) { + continue; + } else if (count < min_count) { + do { + send_code(curlen, bl_tree); + } while (--count !== 0); + } else if (curlen !== 0) { + if (curlen != prevlen) { + send_code(curlen, bl_tree); + count--; + } + send_code(REP_3_6, bl_tree); + send_bits(count - 3, 2); + } else if (count <= 10) { + send_code(REPZ_3_10, bl_tree); + send_bits(count - 3, 3); + } else { + send_code(REPZ_11_138, bl_tree); + send_bits(count - 11, 7); + } + count = 0; + prevlen = curlen; + if (nextlen === 0) { + max_count = 138; + min_count = 3; + } else if (curlen == nextlen) { + max_count = 6; + min_count = 3; + } else { + max_count = 7; + min_count = 4; + } + } + } + + // Send the header for a block using dynamic Huffman trees: the counts, the + // lengths of the bit length codes, the literal tree and the distance tree. + // IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. + function send_all_trees(lcodes, dcodes, blcodes) { + let rank; // index in bl_order + + send_bits(lcodes - 257, 5); // not +255 as stated in appnote.txt + send_bits(dcodes - 1, 5); + send_bits(blcodes - 4, 4); // not -3 as stated in appnote.txt + for (rank = 0; rank < blcodes; rank++) { + send_bits(bl_tree[Tree.bl_order[rank] * 2 + 1], 3); + } + send_tree(dyn_ltree, lcodes - 1); // literal tree + send_tree(dyn_dtree, dcodes - 1); // distance tree + } + + // Flush the bit buffer, keeping at most 7 bits in it. + function bi_flush() { + if (bi_valid == 16) { + put_short(bi_buf); + bi_buf = 0; + bi_valid = 0; + } else if (bi_valid >= 8) { + put_byte(bi_buf & 0xff); + bi_buf >>>= 8; + bi_valid -= 8; + } + } + + // Send one empty static block to give enough lookahead for inflate. + // This takes 10 bits, of which 7 may remain in the bit buffer. + // The current inflate code requires 9 bits of lookahead. If the + // last two codes for the previous block (real code plus EOB) were coded + // on 5 bits or less, inflate may have only 5+3 bits of lookahead to decode + // the last real code. In this case we send two empty static blocks instead + // of one. (There are no problems if the previous block is stored or fixed.) + // To simplify the code, we assume the worst case of last real code encoded + // on one bit only. + function _tr_align() { + send_bits(STATIC_TREES << 1, 3); + send_code(END_BLOCK, StaticTree.static_ltree); + + bi_flush(); + + // Of the 10 bits for the empty block, we have already sent + // (10 - bi_valid) bits. The lookahead for the last real code (before + // the EOB of the previous block) was thus at least one plus the length + // of the EOB plus what we have just sent of the empty static block. + if (1 + last_eob_len + 10 - bi_valid < 9) { + send_bits(STATIC_TREES << 1, 3); + send_code(END_BLOCK, StaticTree.static_ltree); + bi_flush(); + } + last_eob_len = 7; + } + + // Save the match info and tally the frequency counts. Return true if + // the current block must be flushed. + function _tr_tally(dist, // distance of matched string + lc // match length-MIN_MATCH or unmatched char (if dist==0) + ) { + let out_length, in_length, dcode; + that.pending_buf[d_buf + last_lit * 2] = (dist >>> 8) & 0xff; + that.pending_buf[d_buf + last_lit * 2 + 1] = dist & 0xff; + + that.pending_buf[l_buf + last_lit] = lc & 0xff; + last_lit++; + + if (dist === 0) { + // lc is the unmatched char + dyn_ltree[lc * 2]++; + } else { + matches++; + // Here, lc is the match length - MIN_MATCH + dist--; // dist = match distance - 1 + dyn_ltree[(Tree._length_code[lc] + LITERALS + 1) * 2]++; + dyn_dtree[Tree.d_code(dist) * 2]++; + } + + if ((last_lit & 0x1fff) === 0 && level > 2) { + // Compute an upper bound for the compressed length + out_length = last_lit * 8; + in_length = strstart - block_start; + for (dcode = 0; dcode < D_CODES; dcode++) { + out_length += dyn_dtree[dcode * 2] * (5 + Tree.extra_dbits[dcode]); + } + out_length >>>= 3; + if ((matches < Math.floor(last_lit / 2)) && out_length < Math.floor(in_length / 2)) + return true; + } + + return (last_lit == lit_bufsize - 1); + // We avoid equality with lit_bufsize because of wraparound at 64K + // on 16 bit machines and because stored blocks are restricted to + // 64K-1 bytes. + } + + // Send the block data compressed using the given Huffman trees + function compress_block(ltree, dtree) { + let dist; // distance of matched string + let lc; // match length or unmatched char (if dist === 0) + let lx = 0; // running index in l_buf + let code; // the code to send + let extra; // number of extra bits to send + + if (last_lit !== 0) { + do { + dist = ((that.pending_buf[d_buf + lx * 2] << 8) & 0xff00) | (that.pending_buf[d_buf + lx * 2 + 1] & 0xff); + lc = (that.pending_buf[l_buf + lx]) & 0xff; + lx++; + + if (dist === 0) { + send_code(lc, ltree); // send a literal byte + } else { + // Here, lc is the match length - MIN_MATCH + code = Tree._length_code[lc]; + + send_code(code + LITERALS + 1, ltree); // send the length + // code + extra = Tree.extra_lbits[code]; + if (extra !== 0) { + lc -= Tree.base_length[code]; + send_bits(lc, extra); // send the extra length bits + } + dist--; // dist is now the match distance - 1 + code = Tree.d_code(dist); + + send_code(code, dtree); // send the distance code + extra = Tree.extra_dbits[code]; + if (extra !== 0) { + dist -= Tree.base_dist[code]; + send_bits(dist, extra); // send the extra distance bits + } + } // literal or match pair ? + + // Check that the overlay between pending_buf and d_buf+l_buf is + // ok: + } while (lx < last_lit); + } + + send_code(END_BLOCK, ltree); + last_eob_len = ltree[END_BLOCK * 2 + 1]; + } + + // Flush the bit buffer and align the output on a byte boundary + function bi_windup() { + if (bi_valid > 8) { + put_short(bi_buf); + } else if (bi_valid > 0) { + put_byte(bi_buf & 0xff); + } + bi_buf = 0; + bi_valid = 0; + } + + // Copy a stored block, storing first the length and its + // one's complement if requested. + function copy_block(buf, // the input data + len, // its length + header // true if block header must be written + ) { + bi_windup(); // align on byte boundary + last_eob_len = 8; // enough lookahead for inflate + + if (header) { + put_short(len); + put_short(~len); + } + + that.pending_buf.set(window.subarray(buf, buf + len), that.pending); + that.pending += len; + } + + // Send a stored block + function _tr_stored_block(buf, // input block + stored_len, // length of input block + eof // true if this is the last block for a file + ) { + send_bits((STORED_BLOCK << 1) + (eof ? 1 : 0), 3); // send block type + copy_block(buf, stored_len, true); // with header + } + + // Determine the best encoding for the current block: dynamic trees, static + // trees or store, and output the encoded block to the zip file. + function _tr_flush_block(buf, // input block, or NULL if too old + stored_len, // length of input block + eof // true if this is the last block for a file + ) { + let opt_lenb, static_lenb;// opt_len and static_len in bytes + let max_blindex = 0; // index of last bit length code of non zero freq + + // Build the Huffman trees unless a stored block is forced + if (level > 0) { + // Construct the literal and distance trees + l_desc.build_tree(that); + + d_desc.build_tree(that); + + // At this point, opt_len and static_len are the total bit lengths + // of + // the compressed block data, excluding the tree representations. + + // Build the bit length tree for the above two trees, and get the + // index + // in bl_order of the last bit length code to send. + max_blindex = build_bl_tree(); + + // Determine the best encoding. Compute first the block length in + // bytes + opt_lenb = (that.opt_len + 3 + 7) >>> 3; + static_lenb = (that.static_len + 3 + 7) >>> 3; + + if (static_lenb <= opt_lenb) + opt_lenb = static_lenb; + } else { + opt_lenb = static_lenb = stored_len + 5; // force a stored block + } + + if ((stored_len + 4 <= opt_lenb) && buf != -1) { + // 4: two words for the lengths + // The test buf != NULL is only necessary if LIT_BUFSIZE > WSIZE. + // Otherwise we can't have processed more than WSIZE input bytes + // since + // the last block flush, because compression would have been + // successful. If LIT_BUFSIZE <= WSIZE, it is never too late to + // transform a block into a stored block. + _tr_stored_block(buf, stored_len, eof); + } else if (static_lenb == opt_lenb) { + send_bits((STATIC_TREES << 1) + (eof ? 1 : 0), 3); + compress_block(StaticTree.static_ltree, StaticTree.static_dtree); + } else { + send_bits((DYN_TREES << 1) + (eof ? 1 : 0), 3); + send_all_trees(l_desc.max_code + 1, d_desc.max_code + 1, max_blindex + 1); + compress_block(dyn_ltree, dyn_dtree); + } + + // The above check is made mod 2^32, for files larger than 512 MB + // and uLong implemented on 32 bits. + + init_block(); + + if (eof) { + bi_windup(); + } + } + + function flush_block_only(eof) { + _tr_flush_block(block_start >= 0 ? block_start : -1, strstart - block_start, eof); + block_start = strstart; + strm.flush_pending(); + } + + // Fill the window when the lookahead becomes insufficient. + // Updates strstart and lookahead. + // + // IN assertion: lookahead < MIN_LOOKAHEAD + // OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + // At least one byte has been read, or avail_in === 0; reads are + // performed for at least two bytes (required for the zip translate_eol + // option -- not supported here). + function fill_window() { + let n, m; + let p; + let more; // Amount of free space at the end of the window. + + do { + more = (window_size - lookahead - strstart); + + // Deal with !@#$% 64K limit: + if (more === 0 && strstart === 0 && lookahead === 0) { + more = w_size; + } else if (more == -1) { + // Very unlikely, but possible on 16 bit machine if strstart == + // 0 + // and lookahead == 1 (input done one byte at time) + more--; + + // If the window is almost full and there is insufficient + // lookahead, + // move the upper half to the lower one to make room in the + // upper half. + } else if (strstart >= w_size + w_size - MIN_LOOKAHEAD) { + window.set(window.subarray(w_size, w_size + w_size), 0); + + match_start -= w_size; + strstart -= w_size; // we now have strstart >= MAX_DIST + block_start -= w_size; + + // Slide the hash table (could be avoided with 32 bit values + // at the expense of memory usage). We slide even when level == + // 0 + // to keep the hash table consistent if we switch back to level + // > 0 + // later. (Using level 0 permanently is not an optimal usage of + // zlib, so we don't care about this pathological case.) + + n = hash_size; + p = n; + do { + m = (head[--p] & 0xffff); + head[p] = (m >= w_size ? m - w_size : 0); + } while (--n !== 0); + + n = w_size; + p = n; + do { + m = (prev[--p] & 0xffff); + prev[p] = (m >= w_size ? m - w_size : 0); + // If n is not on any hash chain, prev[n] is garbage but + // its value will never be used. + } while (--n !== 0); + more += w_size; + } + + if (strm.avail_in === 0) + return; + + // If there was no sliding: + // strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + // more == window_size - lookahead - strstart + // => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + // => more >= window_size - 2*WSIZE + 2 + // In the BIG_MEM or MMAP case (not yet supported), + // window_size == input_size + MIN_LOOKAHEAD && + // strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + // Otherwise, window_size == 2*WSIZE so more >= 2. + // If there was sliding, more >= WSIZE. So in all cases, more >= 2. + + n = strm.read_buf(window, strstart + lookahead, more); + lookahead += n; + + // Initialize the hash value now that we have some input: + if (lookahead >= MIN_MATCH) { + ins_h = window[strstart] & 0xff; + ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask; + } + // If the whole input has less than MIN_MATCH bytes, ins_h is + // garbage, + // but this is not important since only literal bytes will be + // emitted. + } while (lookahead < MIN_LOOKAHEAD && strm.avail_in !== 0); + } + + // Copy without compression as much as possible from the input stream, + // return + // the current block state. + // This function does not insert new strings in the dictionary since + // uncompressible data is probably not useful. This function is used + // only for the level=0 compression option. + // NOTE: this function should be optimized to avoid extra copying from + // window to pending_buf. + function deflate_stored(flush) { + // Stored blocks are limited to 0xffff bytes, pending_buf is limited + // to pending_buf_size, and each stored block has a 5 byte header: + + let max_block_size = 0xffff; + let max_start; + + if (max_block_size > pending_buf_size - 5) { + max_block_size = pending_buf_size - 5; + } + + // Copy as much as possible from input to output: + // eslint-disable-next-line no-constant-condition + while (true) { + // Fill the window as much as possible: + if (lookahead <= 1) { + fill_window(); + if (lookahead === 0 && flush == Z_NO_FLUSH) + return NeedMore; + if (lookahead === 0) + break; // flush the current block + } + + strstart += lookahead; + lookahead = 0; + + // Emit a stored block if pending_buf will be full: + max_start = block_start + max_block_size; + if (strstart === 0 || strstart >= max_start) { + // strstart === 0 is possible when wraparound on 16-bit machine + lookahead = (strstart - max_start); + strstart = max_start; + + flush_block_only(false); + if (strm.avail_out === 0) + return NeedMore; + + } + + // Flush if we may have to slide, otherwise block_start may become + // negative and the data will be gone: + if (strstart - block_start >= w_size - MIN_LOOKAHEAD) { + flush_block_only(false); + if (strm.avail_out === 0) + return NeedMore; + } + } + + flush_block_only(flush == Z_FINISH); + if (strm.avail_out === 0) + return (flush == Z_FINISH) ? FinishStarted : NeedMore; + + return flush == Z_FINISH ? FinishDone : BlockDone; + } + + function longest_match(cur_match) { + let chain_length = max_chain_length; // max hash chain length + let scan = strstart; // current string + let match; // matched string + let len; // length of current match + let best_len = prev_length; // best match length so far + const limit = strstart > (w_size - MIN_LOOKAHEAD) ? strstart - (w_size - MIN_LOOKAHEAD) : 0; + let _nice_match = nice_match; + + // Stop when cur_match becomes <= limit. To simplify the code, + // we prevent matches with the string of window index 0. + + const wmask = w_mask; + + const strend = strstart + MAX_MATCH; + let scan_end1 = window[scan + best_len - 1]; + let scan_end = window[scan + best_len]; + + // The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of + // 16. + // It is easy to get rid of this optimization if necessary. + + // Do not waste too much time if we already have a good match: + if (prev_length >= good_match) { + chain_length >>= 2; + } + + // Do not look for matches beyond the end of the input. This is + // necessary + // to make deflate deterministic. + if (_nice_match > lookahead) + _nice_match = lookahead; + + do { + match = cur_match; + + // Skip to next match if the match length cannot increase + // or if the match length is less than 2: + if (window[match + best_len] != scan_end || window[match + best_len - 1] != scan_end1 || window[match] != window[scan] + || window[++match] != window[scan + 1]) + continue; + + // The check at best_len-1 can be removed because it will be made + // again later. (This heuristic is not always a win.) + // It is not necessary to compare scan[2] and match[2] since they + // are always equal when the other bytes match, given that + // the hash keys are equal and that HASH_BITS >= 8. + scan += 2; + match++; + + // We check for insufficient lookahead only every 8th comparison; + // the 256th check will be made at strstart+258. + // eslint-disable-next-line no-empty + do { + } while (window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] + && window[++scan] == window[++match] && window[++scan] == window[++match] && window[++scan] == window[++match] + && window[++scan] == window[++match] && window[++scan] == window[++match] && scan < strend); + + len = MAX_MATCH - (strend - scan); + scan = strend - MAX_MATCH; + + if (len > best_len) { + match_start = cur_match; + best_len = len; + if (len >= _nice_match) + break; + scan_end1 = window[scan + best_len - 1]; + scan_end = window[scan + best_len]; + } + + } while ((cur_match = (prev[cur_match & wmask] & 0xffff)) > limit && --chain_length !== 0); + + if (best_len <= lookahead) + return best_len; + return lookahead; + } + + // Compress as much as possible from the input stream, return the current + // block state. + // This function does not perform lazy evaluation of matches and inserts + // new strings in the dictionary only for unmatched strings or for short + // matches. It is used only for the fast compression options. + function deflate_fast(flush) { + // short hash_head = 0; // head of the hash chain + let hash_head = 0; // head of the hash chain + let bflush; // set if current block must be flushed + + // eslint-disable-next-line no-constant-condition + while (true) { + // Make sure that we always have enough lookahead, except + // at the end of the input file. We need MAX_MATCH bytes + // for the next match, plus MIN_MATCH bytes to insert the + // string following the next match. + if (lookahead < MIN_LOOKAHEAD) { + fill_window(); + if (lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return NeedMore; + } + if (lookahead === 0) + break; // flush the current block + } + + // Insert the string window[strstart .. strstart+2] in the + // dictionary, and set hash_head to the head of the hash chain: + if (lookahead >= MIN_MATCH) { + ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + + // prev[strstart&w_mask]=hash_head=head[ins_h]; + hash_head = (head[ins_h] & 0xffff); + prev[strstart & w_mask] = head[ins_h]; + head[ins_h] = strstart; + } + + // Find the longest match, discarding those <= prev_length. + // At this point we have always match_length < MIN_MATCH + + if (hash_head !== 0 && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) { + // To simplify the code, we prevent matches with the string + // of window index 0 (in particular we have to avoid a match + // of the string with itself at the start of the input file). + if (strategy != Z_HUFFMAN_ONLY) { + match_length = longest_match(hash_head); + } + // longest_match() sets match_start + } + if (match_length >= MIN_MATCH) { + // check_match(strstart, match_start, match_length); + + bflush = _tr_tally(strstart - match_start, match_length - MIN_MATCH); + + lookahead -= match_length; + + // Insert new strings in the hash table only if the match length + // is not too large. This saves time but degrades compression. + if (match_length <= max_lazy_match && lookahead >= MIN_MATCH) { + match_length--; // string at strstart already in hash table + do { + strstart++; + + ins_h = ((ins_h << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + // prev[strstart&w_mask]=hash_head=head[ins_h]; + hash_head = (head[ins_h] & 0xffff); + prev[strstart & w_mask] = head[ins_h]; + head[ins_h] = strstart; + + // strstart never exceeds WSIZE-MAX_MATCH, so there are + // always MIN_MATCH bytes ahead. + } while (--match_length !== 0); + strstart++; + } else { + strstart += match_length; + match_length = 0; + ins_h = window[strstart] & 0xff; + + ins_h = (((ins_h) << hash_shift) ^ (window[strstart + 1] & 0xff)) & hash_mask; + // If lookahead < MIN_MATCH, ins_h is garbage, but it does + // not + // matter since it will be recomputed at next deflate call. + } + } else { + // No match, output a literal byte + + bflush = _tr_tally(0, window[strstart] & 0xff); + lookahead--; + strstart++; + } + if (bflush) { + + flush_block_only(false); + if (strm.avail_out === 0) + return NeedMore; + } + } + + flush_block_only(flush == Z_FINISH); + if (strm.avail_out === 0) { + if (flush == Z_FINISH) + return FinishStarted; + else + return NeedMore; + } + return flush == Z_FINISH ? FinishDone : BlockDone; + } + + // Same as above, but achieves better compression. We use a lazy + // evaluation for matches: a match is finally adopted only if there is + // no better match at the next window position. + function deflate_slow(flush) { + // short hash_head = 0; // head of hash chain + let hash_head = 0; // head of hash chain + let bflush; // set if current block must be flushed + let max_insert; + + // Process the input block. + // eslint-disable-next-line no-constant-condition + while (true) { + // Make sure that we always have enough lookahead, except + // at the end of the input file. We need MAX_MATCH bytes + // for the next match, plus MIN_MATCH bytes to insert the + // string following the next match. + + if (lookahead < MIN_LOOKAHEAD) { + fill_window(); + if (lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { + return NeedMore; + } + if (lookahead === 0) + break; // flush the current block + } + + // Insert the string window[strstart .. strstart+2] in the + // dictionary, and set hash_head to the head of the hash chain: + + if (lookahead >= MIN_MATCH) { + ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + // prev[strstart&w_mask]=hash_head=head[ins_h]; + hash_head = (head[ins_h] & 0xffff); + prev[strstart & w_mask] = head[ins_h]; + head[ins_h] = strstart; + } + + // Find the longest match, discarding those <= prev_length. + prev_length = match_length; + prev_match = match_start; + match_length = MIN_MATCH - 1; + + if (hash_head !== 0 && prev_length < max_lazy_match && ((strstart - hash_head) & 0xffff) <= w_size - MIN_LOOKAHEAD) { + // To simplify the code, we prevent matches with the string + // of window index 0 (in particular we have to avoid a match + // of the string with itself at the start of the input file). + + if (strategy != Z_HUFFMAN_ONLY) { + match_length = longest_match(hash_head); + } + // longest_match() sets match_start + + if (match_length <= 5 && (strategy == Z_FILTERED || (match_length == MIN_MATCH && strstart - match_start > 4096))) { + + // If prev_match is also MIN_MATCH, match_start is garbage + // but we will ignore the current match anyway. + match_length = MIN_MATCH - 1; + } + } + + // If there was a match at the previous step and the current + // match is not better, output the previous match: + if (prev_length >= MIN_MATCH && match_length <= prev_length) { + max_insert = strstart + lookahead - MIN_MATCH; + // Do not insert strings in hash table beyond this. + + // check_match(strstart-1, prev_match, prev_length); + + bflush = _tr_tally(strstart - 1 - prev_match, prev_length - MIN_MATCH); + + // Insert in hash table all strings up to the end of the match. + // strstart-1 and strstart are already inserted. If there is not + // enough lookahead, the last two strings are not inserted in + // the hash table. + lookahead -= prev_length - 1; + prev_length -= 2; + do { + if (++strstart <= max_insert) { + ins_h = (((ins_h) << hash_shift) ^ (window[(strstart) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + // prev[strstart&w_mask]=hash_head=head[ins_h]; + hash_head = (head[ins_h] & 0xffff); + prev[strstart & w_mask] = head[ins_h]; + head[ins_h] = strstart; + } + } while (--prev_length !== 0); + match_available = 0; + match_length = MIN_MATCH - 1; + strstart++; + + if (bflush) { + flush_block_only(false); + if (strm.avail_out === 0) + return NeedMore; + } + } else if (match_available !== 0) { + + // If there was no match at the previous position, output a + // single literal. If there was a match but the current match + // is longer, truncate the previous match to a single literal. + + bflush = _tr_tally(0, window[strstart - 1] & 0xff); + + if (bflush) { + flush_block_only(false); + } + strstart++; + lookahead--; + if (strm.avail_out === 0) + return NeedMore; + } else { + // There is no previous match to compare with, wait for + // the next step to decide. + + match_available = 1; + strstart++; + lookahead--; + } + } + + if (match_available !== 0) { + bflush = _tr_tally(0, window[strstart - 1] & 0xff); + match_available = 0; + } + flush_block_only(flush == Z_FINISH); + + if (strm.avail_out === 0) { + if (flush == Z_FINISH) + return FinishStarted; + else + return NeedMore; + } + + return flush == Z_FINISH ? FinishDone : BlockDone; + } + + function deflateReset(strm) { + strm.total_in = strm.total_out = 0; + strm.msg = null; // + + that.pending = 0; + that.pending_out = 0; + + status = BUSY_STATE; + + last_flush = Z_NO_FLUSH; + + tr_init(); + lm_init(); + return Z_OK; + } + + that.deflateInit = function (strm, _level, bits, _method, memLevel, _strategy) { + if (!_method) + _method = Z_DEFLATED; + if (!memLevel) + memLevel = DEF_MEM_LEVEL; + if (!_strategy) + _strategy = Z_DEFAULT_STRATEGY; + + // byte[] my_version=ZLIB_VERSION; + + // + // if (!version || version[0] != my_version[0] + // || stream_size != sizeof(z_stream)) { + // return Z_VERSION_ERROR; + // } + + strm.msg = null; + + if (_level == Z_DEFAULT_COMPRESSION) + _level = 6; + + if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || _method != Z_DEFLATED || bits < 9 || bits > 15 || _level < 0 || _level > 9 || _strategy < 0 + || _strategy > Z_HUFFMAN_ONLY) { + return Z_STREAM_ERROR; + } + + strm.dstate = that; + + w_bits = bits; + w_size = 1 << w_bits; + w_mask = w_size - 1; + + hash_bits = memLevel + 7; + hash_size = 1 << hash_bits; + hash_mask = hash_size - 1; + hash_shift = Math.floor((hash_bits + MIN_MATCH - 1) / MIN_MATCH); + + window = new Uint8Array(w_size * 2); + prev = []; + head = []; + + lit_bufsize = 1 << (memLevel + 6); // 16K elements by default + + // We overlay pending_buf and d_buf+l_buf. This works since the average + // output size for (length,distance) codes is <= 24 bits. + that.pending_buf = new Uint8Array(lit_bufsize * 4); + pending_buf_size = lit_bufsize * 4; + + d_buf = Math.floor(lit_bufsize / 2); + l_buf = (1 + 2) * lit_bufsize; + + level = _level; + + strategy = _strategy; + + return deflateReset(strm); + }; + + that.deflateEnd = function () { + if (status != INIT_STATE && status != BUSY_STATE && status != FINISH_STATE) { + return Z_STREAM_ERROR; + } + // Deallocate in reverse order of allocations: + that.pending_buf = null; + head = null; + prev = null; + window = null; + // free + that.dstate = null; + return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; + }; + + that.deflateParams = function (strm, _level, _strategy) { + let err = Z_OK; + + if (_level == Z_DEFAULT_COMPRESSION) { + _level = 6; + } + if (_level < 0 || _level > 9 || _strategy < 0 || _strategy > Z_HUFFMAN_ONLY) { + return Z_STREAM_ERROR; + } + + if (config_table[level].func != config_table[_level].func && strm.total_in !== 0) { + // Flush the last buffer: + err = strm.deflate(Z_PARTIAL_FLUSH); + } + + if (level != _level) { + level = _level; + max_lazy_match = config_table[level].max_lazy; + good_match = config_table[level].good_length; + nice_match = config_table[level].nice_length; + max_chain_length = config_table[level].max_chain; + } + strategy = _strategy; + return err; + }; + + that.deflateSetDictionary = function (strm, dictionary, dictLength) { + let length = dictLength; + let n, index = 0; + + if (!dictionary || status != INIT_STATE) + return Z_STREAM_ERROR; + + if (length < MIN_MATCH) + return Z_OK; + if (length > w_size - MIN_LOOKAHEAD) { + length = w_size - MIN_LOOKAHEAD; + index = dictLength - length; // use the tail of the dictionary + } + window.set(dictionary.subarray(index, index + length), 0); + + strstart = length; + block_start = length; + + // Insert all strings in the hash table (except for the last two bytes). + // s->lookahead stays null, so s->ins_h will be recomputed at the next + // call of fill_window. + + ins_h = window[0] & 0xff; + ins_h = (((ins_h) << hash_shift) ^ (window[1] & 0xff)) & hash_mask; + + for (n = 0; n <= length - MIN_MATCH; n++) { + ins_h = (((ins_h) << hash_shift) ^ (window[(n) + (MIN_MATCH - 1)] & 0xff)) & hash_mask; + prev[n & w_mask] = head[ins_h]; + head[ins_h] = n; + } + return Z_OK; + }; + + that.deflate = function (_strm, flush) { + let i, header, level_flags, old_flush, bstate; + + if (flush > Z_FINISH || flush < 0) { + return Z_STREAM_ERROR; + } + + if (!_strm.next_out || (!_strm.next_in && _strm.avail_in !== 0) || (status == FINISH_STATE && flush != Z_FINISH)) { + _strm.msg = z_errmsg[Z_NEED_DICT - (Z_STREAM_ERROR)]; + return Z_STREAM_ERROR; + } + if (_strm.avail_out === 0) { + _strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; + return Z_BUF_ERROR; + } + + strm = _strm; // just in case + old_flush = last_flush; + last_flush = flush; + + // Write the zlib header + if (status == INIT_STATE) { + header = (Z_DEFLATED + ((w_bits - 8) << 4)) << 8; + level_flags = ((level - 1) & 0xff) >> 1; + + if (level_flags > 3) + level_flags = 3; + header |= (level_flags << 6); + if (strstart !== 0) + header |= PRESET_DICT; + header += 31 - (header % 31); + + status = BUSY_STATE; + putShortMSB(header); + } + + // Flush as much pending output as possible + if (that.pending !== 0) { + strm.flush_pending(); + if (strm.avail_out === 0) { + // console.log(" avail_out==0"); + // Since avail_out is 0, deflate will be called again with + // more output space, but possibly with both pending and + // avail_in equal to zero. There won't be anything to do, + // but this is not an error situation so make sure we + // return OK instead of BUF_ERROR at next call of deflate: + last_flush = -1; + return Z_OK; + } + + // Make sure there is something to do and avoid duplicate + // consecutive + // flushes. For repeated and useless calls with Z_FINISH, we keep + // returning Z_STREAM_END instead of Z_BUFF_ERROR. + } else if (strm.avail_in === 0 && flush <= old_flush && flush != Z_FINISH) { + strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; + return Z_BUF_ERROR; + } + + // User must not provide more input after the first FINISH: + if (status == FINISH_STATE && strm.avail_in !== 0) { + _strm.msg = z_errmsg[Z_NEED_DICT - (Z_BUF_ERROR)]; + return Z_BUF_ERROR; + } + + // Start a new block or continue the current one. + if (strm.avail_in !== 0 || lookahead !== 0 || (flush != Z_NO_FLUSH && status != FINISH_STATE)) { + bstate = -1; + switch (config_table[level].func) { + case STORED: + bstate = deflate_stored(flush); + break; + case FAST: + bstate = deflate_fast(flush); + break; + case SLOW: + bstate = deflate_slow(flush); + break; + } + + if (bstate == FinishStarted || bstate == FinishDone) { + status = FINISH_STATE; + } + if (bstate == NeedMore || bstate == FinishStarted) { + if (strm.avail_out === 0) { + last_flush = -1; // avoid BUF_ERROR next call, see above + } + return Z_OK; + // If flush != Z_NO_FLUSH && avail_out === 0, the next call + // of deflate should use the same flush parameter to make sure + // that the flush is complete. So we don't have to output an + // empty block here, this will be done at next call. This also + // ensures that for a very small output buffer, we emit at most + // one empty block. + } + + if (bstate == BlockDone) { + if (flush == Z_PARTIAL_FLUSH) { + _tr_align(); + } else { // FULL_FLUSH or SYNC_FLUSH + _tr_stored_block(0, 0, false); + // For a full flush, this empty block will be recognized + // as a special marker by inflate_sync(). + if (flush == Z_FULL_FLUSH) { + // state.head[s.hash_size-1]=0; + for (i = 0; i < hash_size/*-1*/; i++) + // forget history + head[i] = 0; + } + } + strm.flush_pending(); + if (strm.avail_out === 0) { + last_flush = -1; // avoid BUF_ERROR at next call, see above + return Z_OK; + } + } + } + + if (flush != Z_FINISH) + return Z_OK; + return Z_STREAM_END; + }; + } + + // ZStream + + function ZStream() { + const that = this; + that.next_in_index = 0; + that.next_out_index = 0; + // that.next_in; // next input byte + that.avail_in = 0; // number of bytes available at next_in + that.total_in = 0; // total nb of input bytes read so far + // that.next_out; // next output byte should be put there + that.avail_out = 0; // remaining free space at next_out + that.total_out = 0; // total nb of bytes output so far + // that.msg; + // that.dstate; + } + + ZStream.prototype = { + deflateInit: function (level, bits) { + const that = this; + that.dstate = new Deflate(); + if (!bits) + bits = MAX_BITS; + return that.dstate.deflateInit(that, level, bits); + }, + + deflate: function (flush) { + const that = this; + if (!that.dstate) { + return Z_STREAM_ERROR; + } + return that.dstate.deflate(that, flush); + }, + + deflateEnd: function () { + const that = this; + if (!that.dstate) + return Z_STREAM_ERROR; + const ret = that.dstate.deflateEnd(); + that.dstate = null; + return ret; + }, + + deflateParams: function (level, strategy) { + const that = this; + if (!that.dstate) + return Z_STREAM_ERROR; + return that.dstate.deflateParams(that, level, strategy); + }, + + deflateSetDictionary: function (dictionary, dictLength) { + const that = this; + if (!that.dstate) + return Z_STREAM_ERROR; + return that.dstate.deflateSetDictionary(that, dictionary, dictLength); + }, + + // Read a new buffer from the current input stream, update the + // total number of bytes read. All deflate() input goes through + // this function so some applications may wish to modify it to avoid + // allocating a large strm->next_in buffer and copying from it. + // (See also flush_pending()). + read_buf: function (buf, start, size) { + const that = this; + let len = that.avail_in; + if (len > size) + len = size; + if (len === 0) + return 0; + that.avail_in -= len; + buf.set(that.next_in.subarray(that.next_in_index, that.next_in_index + len), start); + that.next_in_index += len; + that.total_in += len; + return len; + }, + + // Flush as much pending output as possible. All deflate() output goes + // through this function so some applications may wish to modify it + // to avoid allocating a large strm->next_out buffer and copying into it. + // (See also read_buf()). + flush_pending: function () { + const that = this; + let len = that.dstate.pending; + + if (len > that.avail_out) + len = that.avail_out; + if (len === 0) + return; + + // if (that.dstate.pending_buf.length <= that.dstate.pending_out || that.next_out.length <= that.next_out_index + // || that.dstate.pending_buf.length < (that.dstate.pending_out + len) || that.next_out.length < (that.next_out_index + + // len)) { + // console.log(that.dstate.pending_buf.length + ", " + that.dstate.pending_out + ", " + that.next_out.length + ", " + + // that.next_out_index + ", " + len); + // console.log("avail_out=" + that.avail_out); + // } + + that.next_out.set(that.dstate.pending_buf.subarray(that.dstate.pending_out, that.dstate.pending_out + len), that.next_out_index); + + that.next_out_index += len; + that.dstate.pending_out += len; + that.total_out += len; + that.avail_out -= len; + that.dstate.pending -= len; + if (that.dstate.pending === 0) { + that.dstate.pending_out = 0; + } + } + }; + + // Deflate + + function ZipDeflate(options) { + const that = this; + const z = new ZStream(); + const bufsize = 512; + const flush = Z_NO_FLUSH; + const buf = new Uint8Array(bufsize); + let level = options ? options.level : Z_DEFAULT_COMPRESSION; + if (typeof level == "undefined") + level = Z_DEFAULT_COMPRESSION; + z.deflateInit(level); + z.next_out = buf; + + that.append = function (data, onprogress) { + let err, array, lastIndex = 0, bufferIndex = 0, bufferSize = 0; + const buffers = []; + if (!data.length) + return; + z.next_in_index = 0; + z.next_in = data; + z.avail_in = data.length; + do { + z.next_out_index = 0; + z.avail_out = bufsize; + err = z.deflate(flush); + if (err != Z_OK) + throw new Error("deflating: " + z.msg); + if (z.next_out_index) + if (z.next_out_index == bufsize) + buffers.push(new Uint8Array(buf)); + else + buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); + bufferSize += z.next_out_index; + if (onprogress && z.next_in_index > 0 && z.next_in_index != lastIndex) { + onprogress(z.next_in_index); + lastIndex = z.next_in_index; + } + } while (z.avail_in > 0 || z.avail_out === 0); + array = new Uint8Array(bufferSize); + buffers.forEach(function (chunk) { + array.set(chunk, bufferIndex); + bufferIndex += chunk.length; + }); + return array; + }; + that.flush = function () { + let err, array, bufferIndex = 0, bufferSize = 0; + const buffers = []; + do { + z.next_out_index = 0; + z.avail_out = bufsize; + err = z.deflate(Z_FINISH); + if (err != Z_STREAM_END && err != Z_OK) + throw new Error("deflating: " + z.msg); + if (bufsize - z.avail_out > 0) + buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); + bufferSize += z.next_out_index; + } while (z.avail_in > 0 || z.avail_out === 0); + z.deflateEnd(); + array = new Uint8Array(bufferSize); + buffers.forEach(function (chunk) { + array.set(chunk, bufferIndex); + bufferIndex += chunk.length; + }); + return array; + }; + } + + /* + Copyright (c) 2021 Gildas Lormeau. All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the distribution. + + 3. The names of the authors may not be used to endorse or promote products + derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, + INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + // Global + const MAX_BITS$1 = 15; + + const Z_OK$1 = 0; + const Z_STREAM_END$1 = 1; + const Z_NEED_DICT$1 = 2; + const Z_STREAM_ERROR$1 = -2; + const Z_DATA_ERROR$1 = -3; + const Z_MEM_ERROR = -4; + const Z_BUF_ERROR$1 = -5; + + const inflate_mask = [0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, + 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff]; + + const MANY = 1440; + + // JZlib version : "1.0.2" + const Z_NO_FLUSH$1 = 0; + const Z_FINISH$1 = 4; + + // InfTree + const fixed_bl = 9; + const fixed_bd = 5; + + const fixed_tl = [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]; + const fixed_td = [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]; + + // Tables for deflate from PKZIP's appnote.txt. + const cplens = [ // Copy lengths for literal codes 257..285 + 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]; + + // see note #13 above about 258 + const cplext = [ // Extra bits for literal codes 257..285 + 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 // 112==invalid + ]; + + const cpdist = [ // Copy offsets for distance codes 0..29 + 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]; + + const cpdext = [ // Extra bits for distance codes + 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]; + + // If BMAX needs to be larger than 16, then h and x[] should be uLong. + const BMAX = 15; // maximum bit length of any code + + function InfTree() { + const that = this; + + let hn; // hufts used in space + let v; // work area for huft_build + let c; // bit length count table + let r; // table entry for structure assignment + let u; // table stack + let x; // bit offsets, then code stack + + function huft_build(b, // code lengths in bits (all assumed <= + // BMAX) + bindex, n, // number of codes (assumed <= 288) + s, // number of simple-valued codes (0..s-1) + d, // list of base values for non-simple codes + e, // list of extra bits for non-simple codes + t, // result: starting table + m, // maximum lookup bits, returns actual + hp,// space for trees + hn,// hufts used in space + v // working area: values in order of bit length + ) { + // Given a list of code lengths and a maximum table size, make a set of + // tables to decode that set of codes. Return Z_OK on success, + // Z_BUF_ERROR + // if the given code set is incomplete (the tables are still built in + // this + // case), Z_DATA_ERROR if the input is invalid (an over-subscribed set + // of + // lengths), or Z_MEM_ERROR if not enough memory. + + let a; // counter for codes of length k + let f; // i repeats in table every f entries + let g; // maximum code length + let h; // table level + let i; // counter, current code + let j; // counter + let k; // number of bits in current code + let l; // bits per table (returned in m) + let mask; // (1 << w) - 1, to avoid cc -O bug on HP + let p; // pointer into c[], b[], or v[] + let q; // points to current table + let w; // bits before this table == (l * h) + let xp; // pointer into x + let y; // number of dummy codes added + let z; // number of entries in current table + + // Generate counts for each bit length + + p = 0; + i = n; + do { + c[b[bindex + p]]++; + p++; + i--; // assume all entries <= BMAX + } while (i !== 0); + + if (c[0] == n) { // null input--all zero length codes + t[0] = -1; + m[0] = 0; + return Z_OK$1; + } + + // Find minimum and maximum length, bound *m by those + l = m[0]; + for (j = 1; j <= BMAX; j++) + if (c[j] !== 0) + break; + k = j; // minimum code length + if (l < j) { + l = j; + } + for (i = BMAX; i !== 0; i--) { + if (c[i] !== 0) + break; + } + g = i; // maximum code length + if (l > i) { + l = i; + } + m[0] = l; + + // Adjust last length count to fill out codes, if needed + for (y = 1 << j; j < i; j++, y <<= 1) { + if ((y -= c[j]) < 0) { + return Z_DATA_ERROR$1; + } + } + if ((y -= c[i]) < 0) { + return Z_DATA_ERROR$1; + } + c[i] += y; + + // Generate starting offsets into the value table for each length + x[1] = j = 0; + p = 1; + xp = 2; + while (--i !== 0) { // note that i == g from above + x[xp] = (j += c[p]); + xp++; + p++; + } + + // Make a table of values in order of bit lengths + i = 0; + p = 0; + do { + if ((j = b[bindex + p]) !== 0) { + v[x[j]++] = i; + } + p++; + } while (++i < n); + n = x[g]; // set n to length of v + + // Generate the Huffman codes and for each, make the table entries + x[0] = i = 0; // first Huffman code is zero + p = 0; // grab values in bit order + h = -1; // no tables yet--level -1 + w = -l; // bits decoded == (l * h) + u[0] = 0; // just to keep compilers happy + q = 0; // ditto + z = 0; // ditto + + // go through the bit lengths (k already is bits in shortest code) + for (; k <= g; k++) { + a = c[k]; + while (a-- !== 0) { + // here i is the Huffman code of length k bits for value *p + // make tables up to required level + while (k > w + l) { + h++; + w += l; // previous table always l bits + // compute minimum size table less than or equal to l bits + z = g - w; + z = (z > l) ? l : z; // table size upper limit + if ((f = 1 << (j = k - w)) > a + 1) { // try a k-w bit table + // too few codes for + // k-w bit table + f -= a + 1; // deduct codes from patterns left + xp = k; + if (j < z) { + while (++j < z) { // try smaller tables up to z bits + if ((f <<= 1) <= c[++xp]) + break; // enough codes to use up j bits + f -= c[xp]; // else deduct codes from patterns + } + } + } + z = 1 << j; // table entries for j-bit table + + // allocate new table + if (hn[0] + z > MANY) { // (note: doesn't matter for fixed) + return Z_DATA_ERROR$1; // overflow of MANY + } + u[h] = q = /* hp+ */hn[0]; // DEBUG + hn[0] += z; + + // connect to last table, if there is one + if (h !== 0) { + x[h] = i; // save pattern for backing up + r[0] = /* (byte) */j; // bits in this table + r[1] = /* (byte) */l; // bits to dump before this table + j = i >>> (w - l); + r[2] = /* (int) */(q - u[h - 1] - j); // offset to this table + hp.set(r, (u[h - 1] + j) * 3); + // to + // last + // table + } else { + t[0] = q; // first table is returned result + } + } + + // set up table entry in r + r[1] = /* (byte) */(k - w); + if (p >= n) { + r[0] = 128 + 64; // out of values--invalid code + } else if (v[p] < s) { + r[0] = /* (byte) */(v[p] < 256 ? 0 : 32 + 64); // 256 is + // end-of-block + r[2] = v[p++]; // simple code is just the value + } else { + r[0] = /* (byte) */(e[v[p] - s] + 16 + 64); // non-simple--look + // up in lists + r[2] = d[v[p++] - s]; + } + + // fill code-like entries with r + f = 1 << (k - w); + for (j = i >>> w; j < z; j += f) { + hp.set(r, (q + j) * 3); + } + + // backwards increment the k-bit code i + for (j = 1 << (k - 1); (i & j) !== 0; j >>>= 1) { + i ^= j; + } + i ^= j; + + // backup over finished tables + mask = (1 << w) - 1; // needed on HP, cc -O bug + while ((i & mask) != x[h]) { + h--; // don't need to update q + w -= l; + mask = (1 << w) - 1; + } + } + } + // Return Z_BUF_ERROR if we were given an incomplete table + return y !== 0 && g != 1 ? Z_BUF_ERROR$1 : Z_OK$1; + } + + function initWorkArea(vsize) { + let i; + if (!hn) { + hn = []; // []; //new Array(1); + v = []; // new Array(vsize); + c = new Int32Array(BMAX + 1); // new Array(BMAX + 1); + r = []; // new Array(3); + u = new Int32Array(BMAX); // new Array(BMAX); + x = new Int32Array(BMAX + 1); // new Array(BMAX + 1); + } + if (v.length < vsize) { + v = []; // new Array(vsize); + } + for (i = 0; i < vsize; i++) { + v[i] = 0; + } + for (i = 0; i < BMAX + 1; i++) { + c[i] = 0; + } + for (i = 0; i < 3; i++) { + r[i] = 0; + } + // for(int i=0; i 257)) { + if (result == Z_DATA_ERROR$1) { + z.msg = "oversubscribed distance tree"; + } else if (result == Z_BUF_ERROR$1) { + z.msg = "incomplete distance tree"; + result = Z_DATA_ERROR$1; + } else if (result != Z_MEM_ERROR) { + z.msg = "empty distance tree with lengths"; + result = Z_DATA_ERROR$1; + } + return result; + } + + return Z_OK$1; + }; + + } + + InfTree.inflate_trees_fixed = function (bl, // literal desired/actual bit depth + bd, // distance desired/actual bit depth + tl,// literal/length tree result + td// distance tree result + ) { + bl[0] = fixed_bl; + bd[0] = fixed_bd; + tl[0] = fixed_tl; + td[0] = fixed_td; + return Z_OK$1; + }; + + // InfCodes + + // waiting for "i:"=input, + // "o:"=output, + // "x:"=nothing + const START = 0; // x: set up for LEN + const LEN = 1; // i: get length/literal/eob next + const LENEXT = 2; // i: getting length extra (have base) + const DIST = 3; // i: get distance next + const DISTEXT = 4;// i: getting distance extra + const COPY = 5; // o: copying bytes in window, waiting + // for space + const LIT = 6; // o: got literal, waiting for output + // space + const WASH = 7; // o: got eob, possibly still output + // waiting + const END = 8; // x: got eob and all data flushed + const BADCODE = 9;// x: got error + + function InfCodes() { + const that = this; + + let mode; // current inflate_codes mode + + // mode dependent information + let len = 0; + + let tree; // pointer into tree + let tree_index = 0; + let need = 0; // bits needed + + let lit = 0; + + // if EXT or COPY, where and how much + let get = 0; // bits to get for extra + let dist = 0; // distance back to copy from + + let lbits = 0; // ltree bits decoded per branch + let dbits = 0; // dtree bits decoder per branch + let ltree; // literal/length/eob tree + let ltree_index = 0; // literal/length/eob tree + let dtree; // distance tree + let dtree_index = 0; // distance tree + + // Called with number of bytes left to write in window at least 258 + // (the maximum string length) and number of input bytes available + // at least ten. The ten bytes are six bytes for the longest length/ + // distance pair plus four bytes for overloading the bit buffer. + + function inflate_fast(bl, bd, tl, tl_index, td, td_index, s, z) { + let t; // temporary pointer + let tp; // temporary pointer + let tp_index; // temporary pointer + let e; // extra bits or operation + let b; // bit buffer + let k; // bits in bit buffer + let p; // input data pointer + let n; // bytes available there + let q; // output window write pointer + let m; // bytes to end of window or read pointer + let ml; // mask for literal/length tree + let md; // mask for distance tree + let c; // bytes to copy + let d; // distance back to copy from + let r; // copy source pointer + + let tp_index_t_3; // (tp_index+t)*3 + + // load input, output, bit values + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + // initialize masks + ml = inflate_mask[bl]; + md = inflate_mask[bd]; + + // do until not enough input or output space for fast loop + do { // assume called with m >= 258 && n >= 10 + // get literal/length code + while (k < (20)) { // max bits for literal/length code + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + t = b & ml; + tp = tl; + tp_index = tl_index; + tp_index_t_3 = (tp_index + t) * 3; + if ((e = tp[tp_index_t_3]) === 0) { + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2]; + m--; + continue; + } + do { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + if ((e & 16) !== 0) { + e &= 15; + c = tp[tp_index_t_3 + 2] + (/* (int) */b & inflate_mask[e]); + + b >>= e; + k -= e; + + // decode distance base of block to copy + while (k < (15)) { // max bits for distance code + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + t = b & md; + tp = td; + tp_index = td_index; + tp_index_t_3 = (tp_index + t) * 3; + e = tp[tp_index_t_3]; + + do { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + if ((e & 16) !== 0) { + // get extra bits to add to distance base + e &= 15; + while (k < (e)) { // get extra bits (up to 13) + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + d = tp[tp_index_t_3 + 2] + (b & inflate_mask[e]); + + b >>= (e); + k -= (e); + + // do the copy + m -= c; + if (q >= d) { // offset before dest + // just copy + r = q - d; + if (q - r > 0 && 2 > (q - r)) { + s.window[q++] = s.window[r++]; // minimum + // count is + // three, + s.window[q++] = s.window[r++]; // so unroll + // loop a + // little + c -= 2; + } else { + s.window.set(s.window.subarray(r, r + 2), q); + q += 2; + r += 2; + c -= 2; + } + } else { // else offset after destination + r = q - d; + do { + r += s.end; // force pointer in window + } while (r < 0); // covers invalid distances + e = s.end - r; + if (c > e) { // if source crosses, + c -= e; // wrapped copy + if (q - r > 0 && e > (q - r)) { + do { + s.window[q++] = s.window[r++]; + } while (--e !== 0); + } else { + s.window.set(s.window.subarray(r, r + e), q); + q += e; + r += e; + e = 0; + } + r = 0; // copy rest from start of window + } + + } + + // copy all or what's left + if (q - r > 0 && c > (q - r)) { + do { + s.window[q++] = s.window[r++]; + } while (--c !== 0); + } else { + s.window.set(s.window.subarray(r, r + c), q); + q += c; + r += c; + c = 0; + } + break; + } else if ((e & 64) === 0) { + t += tp[tp_index_t_3 + 2]; + t += (b & inflate_mask[e]); + tp_index_t_3 = (tp_index + t) * 3; + e = tp[tp_index_t_3]; + } else { + z.msg = "invalid distance code"; + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_DATA_ERROR$1; + } + // eslint-disable-next-line no-constant-condition + } while (true); + break; + } + + if ((e & 64) === 0) { + t += tp[tp_index_t_3 + 2]; + t += (b & inflate_mask[e]); + tp_index_t_3 = (tp_index + t) * 3; + if ((e = tp[tp_index_t_3]) === 0) { + + b >>= (tp[tp_index_t_3 + 1]); + k -= (tp[tp_index_t_3 + 1]); + + s.window[q++] = /* (byte) */tp[tp_index_t_3 + 2]; + m--; + break; + } + } else if ((e & 32) !== 0) { + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_STREAM_END$1; + } else { + z.msg = "invalid literal/length code"; + + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_DATA_ERROR$1; + } + // eslint-disable-next-line no-constant-condition + } while (true); + } while (m >= 258 && n >= 10); + + // not enough input or output--restore pointers and return + c = z.avail_in - n; + c = (k >> 3) < c ? k >> 3 : c; + n += c; + p -= c; + k -= c << 3; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + + return Z_OK$1; + } + + that.init = function (bl, bd, tl, tl_index, td, td_index) { + mode = START; + lbits = /* (byte) */bl; + dbits = /* (byte) */bd; + ltree = tl; + ltree_index = tl_index; + dtree = td; + dtree_index = td_index; + tree = null; + }; + + that.proc = function (s, z, r) { + let j; // temporary storage + let tindex; // temporary pointer + let e; // extra bits or operation + let b = 0; // bit buffer + let k = 0; // bits in bit buffer + let p = 0; // input data pointer + let n; // bytes available there + let q; // output window write pointer + let m; // bytes to end of window or read pointer + let f; // pointer to copy strings from + + // copy input/output information to locals (UPDATE macro restores) + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + // process input and output based on current state + // eslint-disable-next-line no-constant-condition + while (true) { + switch (mode) { + // waiting for "i:"=input, "o:"=output, "x:"=nothing + case START: // x: set up for LEN + if (m >= 258 && n >= 10) { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + r = inflate_fast(lbits, dbits, ltree, ltree_index, dtree, dtree_index, s, z); + + p = z.next_in_index; + n = z.avail_in; + b = s.bitb; + k = s.bitk; + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (r != Z_OK$1) { + mode = r == Z_STREAM_END$1 ? WASH : BADCODE; + break; + } + } + need = lbits; + tree = ltree; + tree_index = ltree_index; + + mode = LEN; + /* falls through */ + case LEN: // i: get length/literal/eob next + j = need; + + while (k < (j)) { + if (n !== 0) + r = Z_OK$1; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & inflate_mask[j])) * 3; + + b >>>= (tree[tindex + 1]); + k -= (tree[tindex + 1]); + + e = tree[tindex]; + + if (e === 0) { // literal + lit = tree[tindex + 2]; + mode = LIT; + break; + } + if ((e & 16) !== 0) { // length + get = e & 15; + len = tree[tindex + 2]; + mode = LENEXT; + break; + } + if ((e & 64) === 0) { // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + if ((e & 32) !== 0) { // end of block + mode = WASH; + break; + } + mode = BADCODE; // invalid code + z.msg = "invalid literal/length code"; + r = Z_DATA_ERROR$1; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case LENEXT: // i: getting length extra (have base) + j = get; + + while (k < (j)) { + if (n !== 0) + r = Z_OK$1; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + len += (b & inflate_mask[j]); + + b >>= j; + k -= j; + + need = dbits; + tree = dtree; + tree_index = dtree_index; + mode = DIST; + /* falls through */ + case DIST: // i: get distance next + j = need; + + while (k < (j)) { + if (n !== 0) + r = Z_OK$1; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + tindex = (tree_index + (b & inflate_mask[j])) * 3; + + b >>= tree[tindex + 1]; + k -= tree[tindex + 1]; + + e = (tree[tindex]); + if ((e & 16) !== 0) { // distance + get = e & 15; + dist = tree[tindex + 2]; + mode = DISTEXT; + break; + } + if ((e & 64) === 0) { // next table + need = e; + tree_index = tindex / 3 + tree[tindex + 2]; + break; + } + mode = BADCODE; // invalid code + z.msg = "invalid distance code"; + r = Z_DATA_ERROR$1; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case DISTEXT: // i: getting distance extra + j = get; + + while (k < (j)) { + if (n !== 0) + r = Z_OK$1; + else { + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + dist += (b & inflate_mask[j]); + + b >>= j; + k -= j; + + mode = COPY; + /* falls through */ + case COPY: // o: copying bytes in window, waiting for space + f = q - dist; + while (f < 0) { // modulo window size-"while" instead + f += s.end; // of "if" handles invalid distances + } + while (len !== 0) { + + if (m === 0) { + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + + if (m === 0) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + } + + s.window[q++] = s.window[f++]; + m--; + + if (f == s.end) + f = 0; + len--; + } + mode = START; + break; + case LIT: // o: got literal, waiting for output space + if (m === 0) { + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (q == s.end && s.read !== 0) { + q = 0; + m = q < s.read ? s.read - q - 1 : s.end - q; + } + if (m === 0) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + } + r = Z_OK$1; + + s.window[q++] = /* (byte) */lit; + m--; + + mode = START; + break; + case WASH: // o: got eob, possibly more output + if (k > 7) { // return unused byte, if any + k -= 8; + n++; + p--; // can always return one + } + + s.write = q; + r = s.inflate_flush(z, r); + q = s.write; + m = q < s.read ? s.read - q - 1 : s.end - q; + + if (s.read != s.write) { + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + mode = END; + /* falls through */ + case END: + r = Z_STREAM_END$1; + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + case BADCODE: // x: got error + + r = Z_DATA_ERROR$1; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + + default: + r = Z_STREAM_ERROR$1; + + s.bitb = b; + s.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + s.write = q; + return s.inflate_flush(z, r); + } + } + }; + + that.free = function () { + // ZFREE(z, c); + }; + + } + + // InfBlocks + + // Table for deflate from PKZIP's appnote.txt. + const border = [ // Order of the bit length code lengths + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; + + const TYPE = 0; // get type bits (3, including end bit) + const LENS = 1; // get lengths for stored + const STORED$1 = 2;// processing stored block + const TABLE = 3; // get table lengths + const BTREE = 4; // get bit lengths tree for a dynamic + // block + const DTREE = 5; // get length, distance trees for a + // dynamic block + const CODES = 6; // processing fixed or dynamic block + const DRY = 7; // output remaining window bytes + const DONELOCKS = 8; // finished last block, done + const BADBLOCKS = 9; // ot a data error--stuck here + + function InfBlocks(z, w) { + const that = this; + + let mode = TYPE; // current inflate_block mode + + let left = 0; // if STORED, bytes left to copy + + let table = 0; // table lengths (14 bits) + let index = 0; // index into blens (or border) + let blens; // bit lengths of codes + const bb = [0]; // bit length tree depth + const tb = [0]; // bit length decoding tree + + const codes = new InfCodes(); // if CODES, current state + + let last = 0; // true if this block is the last block + + let hufts = new Int32Array(MANY * 3); // single malloc for tree space + const check = 0; // check on output + const inftree = new InfTree(); + + that.bitk = 0; // bits in bit buffer + that.bitb = 0; // bit buffer + that.window = new Uint8Array(w); // sliding window + that.end = w; // one byte after sliding window + that.read = 0; // window read pointer + that.write = 0; // window write pointer + + that.reset = function (z, c) { + if (c) + c[0] = check; + // if (mode == BTREE || mode == DTREE) { + // } + if (mode == CODES) { + codes.free(z); + } + mode = TYPE; + that.bitk = 0; + that.bitb = 0; + that.read = that.write = 0; + }; + + that.reset(z, null); + + // copy as much as possible from the sliding window to the output area + that.inflate_flush = function (z, r) { + let n; + let p; + let q; + + // local copies of source and destination pointers + p = z.next_out_index; + q = that.read; + + // compute number of bytes to copy as far as end of window + n = /* (int) */((q <= that.write ? that.write : that.end) - q); + if (n > z.avail_out) + n = z.avail_out; + if (n !== 0 && r == Z_BUF_ERROR$1) + r = Z_OK$1; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // copy as far as end of window + z.next_out.set(that.window.subarray(q, q + n), p); + p += n; + q += n; + + // see if more to copy at beginning of window + if (q == that.end) { + // wrap pointers + q = 0; + if (that.write == that.end) + that.write = 0; + + // compute bytes to copy + n = that.write - q; + if (n > z.avail_out) + n = z.avail_out; + if (n !== 0 && r == Z_BUF_ERROR$1) + r = Z_OK$1; + + // update counters + z.avail_out -= n; + z.total_out += n; + + // copy + z.next_out.set(that.window.subarray(q, q + n), p); + p += n; + q += n; + } + + // update pointers + z.next_out_index = p; + that.read = q; + + // done + return r; + }; + + that.proc = function (z, r) { + let t; // temporary storage + let b; // bit buffer + let k; // bits in bit buffer + let p; // input data pointer + let n; // bytes available there + let q; // output window write pointer + let m; // bytes to end of window or read pointer + + let i; + + // copy input/output information to locals (UPDATE macro restores) + // { + p = z.next_in_index; + n = z.avail_in; + b = that.bitb; + k = that.bitk; + // } + // { + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + // } + + // process input based on current state + // DEBUG dtree + // eslint-disable-next-line no-constant-condition + while (true) { + let bl, bd, tl, td, bl_, bd_, tl_, td_; + switch (mode) { + case TYPE: + + while (k < (3)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + t = /* (int) */(b & 7); + last = t & 1; + + switch (t >>> 1) { + case 0: // stored + // { + b >>>= (3); + k -= (3); + // } + t = k & 7; // go to byte boundary + + // { + b >>>= (t); + k -= (t); + // } + mode = LENS; // get length of stored block + break; + case 1: // fixed + // { + bl = []; // new Array(1); + bd = []; // new Array(1); + tl = [[]]; // new Array(1); + td = [[]]; // new Array(1); + + InfTree.inflate_trees_fixed(bl, bd, tl, td); + codes.init(bl[0], bd[0], tl[0], 0, td[0], 0); + // } + + // { + b >>>= (3); + k -= (3); + // } + + mode = CODES; + break; + case 2: // dynamic + + // { + b >>>= (3); + k -= (3); + // } + + mode = TABLE; + break; + case 3: // illegal + + // { + b >>>= (3); + k -= (3); + // } + mode = BADBLOCKS; + z.msg = "invalid block type"; + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + break; + case LENS: + + while (k < (32)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + if ((((~b) >>> 16) & 0xffff) != (b & 0xffff)) { + mode = BADBLOCKS; + z.msg = "invalid stored block lengths"; + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + left = (b & 0xffff); + b = k = 0; // dump bits + mode = left !== 0 ? STORED$1 : (last !== 0 ? DRY : TYPE); + break; + case STORED$1: + if (n === 0) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + if (m === 0) { + if (q == that.end && that.read !== 0) { + q = 0; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + } + if (m === 0) { + that.write = q; + r = that.inflate_flush(z, r); + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + if (q == that.end && that.read !== 0) { + q = 0; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + } + if (m === 0) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + } + } + r = Z_OK$1; + + t = left; + if (t > n) + t = n; + if (t > m) + t = m; + that.window.set(z.read_buf(p, t), q); + p += t; + n -= t; + q += t; + m -= t; + if ((left -= t) !== 0) + break; + mode = last !== 0 ? DRY : TYPE; + break; + case TABLE: + + while (k < (14)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + table = t = (b & 0x3fff); + if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) { + mode = BADBLOCKS; + z.msg = "too many length or distance symbols"; + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); + if (!blens || blens.length < t) { + blens = []; // new Array(t); + } else { + for (i = 0; i < t; i++) { + blens[i] = 0; + } + } + + // { + b >>>= (14); + k -= (14); + // } + + index = 0; + mode = BTREE; + /* falls through */ + case BTREE: + while (index < 4 + (table >>> 10)) { + while (k < (3)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + blens[border[index++]] = b & 7; + + // { + b >>>= (3); + k -= (3); + // } + } + + while (index < 19) { + blens[border[index++]] = 0; + } + + bb[0] = 7; + t = inftree.inflate_trees_bits(blens, bb, tb, hufts, z); + if (t != Z_OK$1) { + r = t; + if (r == Z_DATA_ERROR$1) { + blens = null; + mode = BADBLOCKS; + } + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + index = 0; + mode = DTREE; + /* falls through */ + case DTREE: + // eslint-disable-next-line no-constant-condition + while (true) { + t = table; + if (index >= 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) { + break; + } + + let j, c; + + t = bb[0]; + + while (k < (t)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + // if (tb[0] == -1) { + // System.err.println("null..."); + // } + + t = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 1]; + c = hufts[(tb[0] + (b & inflate_mask[t])) * 3 + 2]; + + if (c < 16) { + b >>>= (t); + k -= (t); + blens[index++] = c; + } else { // c == 16..18 + i = c == 18 ? 7 : c - 14; + j = c == 18 ? 11 : 3; + + while (k < (t + i)) { + if (n !== 0) { + r = Z_OK$1; + } else { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + n--; + b |= (z.read_byte(p++) & 0xff) << k; + k += 8; + } + + b >>>= (t); + k -= (t); + + j += (b & inflate_mask[i]); + + b >>>= (i); + k -= (i); + + i = index; + t = table; + if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || (c == 16 && i < 1)) { + blens = null; + mode = BADBLOCKS; + z.msg = "invalid bit length repeat"; + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + + c = c == 16 ? blens[i - 1] : 0; + do { + blens[i++] = c; + } while (--j !== 0); + index = i; + } + } + + tb[0] = -1; + // { + bl_ = []; // new Array(1); + bd_ = []; // new Array(1); + tl_ = []; // new Array(1); + td_ = []; // new Array(1); + bl_[0] = 9; // must be <= 9 for lookahead assumptions + bd_[0] = 6; // must be <= 9 for lookahead assumptions + + t = table; + t = inftree.inflate_trees_dynamic(257 + (t & 0x1f), 1 + ((t >> 5) & 0x1f), blens, bl_, bd_, tl_, td_, hufts, z); + + if (t != Z_OK$1) { + if (t == Z_DATA_ERROR$1) { + blens = null; + mode = BADBLOCKS; + } + r = t; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + codes.init(bl_[0], bd_[0], hufts, tl_[0], hufts, td_[0]); + // } + mode = CODES; + /* falls through */ + case CODES: + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + + if ((r = codes.proc(that, z, r)) != Z_STREAM_END$1) { + return that.inflate_flush(z, r); + } + r = Z_OK$1; + codes.free(z); + + p = z.next_in_index; + n = z.avail_in; + b = that.bitb; + k = that.bitk; + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + + if (last === 0) { + mode = TYPE; + break; + } + mode = DRY; + /* falls through */ + case DRY: + that.write = q; + r = that.inflate_flush(z, r); + q = that.write; + m = /* (int) */(q < that.read ? that.read - q - 1 : that.end - q); + if (that.read != that.write) { + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + mode = DONELOCKS; + /* falls through */ + case DONELOCKS: + r = Z_STREAM_END$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + case BADBLOCKS: + r = Z_DATA_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + + default: + r = Z_STREAM_ERROR$1; + + that.bitb = b; + that.bitk = k; + z.avail_in = n; + z.total_in += p - z.next_in_index; + z.next_in_index = p; + that.write = q; + return that.inflate_flush(z, r); + } + } + }; + + that.free = function (z) { + that.reset(z, null); + that.window = null; + hufts = null; + // ZFREE(z, s); + }; + + that.set_dictionary = function (d, start, n) { + that.window.set(d.subarray(start, start + n), 0); + that.read = that.write = n; + }; + + // Returns true if inflate is currently at the end of a block generated + // by Z_SYNC_FLUSH or Z_FULL_FLUSH. + that.sync_point = function () { + return mode == LENS ? 1 : 0; + }; + + } + + // Inflate + + // preset dictionary flag in zlib header + const PRESET_DICT$1 = 0x20; + + const Z_DEFLATED$1 = 8; + + const METHOD = 0; // waiting for method byte + const FLAG = 1; // waiting for flag byte + const DICT4 = 2; // four dictionary check bytes to go + const DICT3 = 3; // three dictionary check bytes to go + const DICT2 = 4; // two dictionary check bytes to go + const DICT1 = 5; // one dictionary check byte to go + const DICT0 = 6; // waiting for inflateSetDictionary + const BLOCKS = 7; // decompressing blocks + const DONE = 12; // finished check, done + const BAD = 13; // got an error--stay here + + const mark = [0, 0, 0xff, 0xff]; + + function Inflate() { + const that = this; + + that.mode = 0; // current inflate mode + + // mode dependent information + that.method = 0; // if FLAGS, method byte + + // if CHECK, check values to compare + that.was = [0]; // new Array(1); // computed check value + that.need = 0; // stream check value + + // if BAD, inflateSync's marker bytes count + that.marker = 0; + + // mode independent information + that.wbits = 0; // log2(window size) (8..15, defaults to 15) + + // this.blocks; // current inflate_blocks state + + function inflateReset(z) { + if (!z || !z.istate) + return Z_STREAM_ERROR$1; + + z.total_in = z.total_out = 0; + z.msg = null; + z.istate.mode = BLOCKS; + z.istate.blocks.reset(z, null); + return Z_OK$1; + } + + that.inflateEnd = function (z) { + if (that.blocks) + that.blocks.free(z); + that.blocks = null; + // ZFREE(z, z->state); + return Z_OK$1; + }; + + that.inflateInit = function (z, w) { + z.msg = null; + that.blocks = null; + + // set window size + if (w < 8 || w > 15) { + that.inflateEnd(z); + return Z_STREAM_ERROR$1; + } + that.wbits = w; + + z.istate.blocks = new InfBlocks(z, 1 << w); + + // reset state + inflateReset(z); + return Z_OK$1; + }; + + that.inflate = function (z, f) { + let r; + let b; + + if (!z || !z.istate || !z.next_in) + return Z_STREAM_ERROR$1; + const istate = z.istate; + f = f == Z_FINISH$1 ? Z_BUF_ERROR$1 : Z_OK$1; + r = Z_BUF_ERROR$1; + // eslint-disable-next-line no-constant-condition + while (true) { + switch (istate.mode) { + case METHOD: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + if (((istate.method = z.read_byte(z.next_in_index++)) & 0xf) != Z_DEFLATED$1) { + istate.mode = BAD; + z.msg = "unknown compression method"; + istate.marker = 5; // can't try inflateSync + break; + } + if ((istate.method >> 4) + 8 > istate.wbits) { + istate.mode = BAD; + z.msg = "invalid window size"; + istate.marker = 5; // can't try inflateSync + break; + } + istate.mode = FLAG; + /* falls through */ + case FLAG: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + b = (z.read_byte(z.next_in_index++)) & 0xff; + + if ((((istate.method << 8) + b) % 31) !== 0) { + istate.mode = BAD; + z.msg = "incorrect header check"; + istate.marker = 5; // can't try inflateSync + break; + } + + if ((b & PRESET_DICT$1) === 0) { + istate.mode = BLOCKS; + break; + } + istate.mode = DICT4; + /* falls through */ + case DICT4: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + istate.need = ((z.read_byte(z.next_in_index++) & 0xff) << 24) & 0xff000000; + istate.mode = DICT3; + /* falls through */ + case DICT3: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 16) & 0xff0000; + istate.mode = DICT2; + /* falls through */ + case DICT2: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + istate.need += ((z.read_byte(z.next_in_index++) & 0xff) << 8) & 0xff00; + istate.mode = DICT1; + /* falls through */ + case DICT1: + + if (z.avail_in === 0) + return r; + r = f; + + z.avail_in--; + z.total_in++; + istate.need += (z.read_byte(z.next_in_index++) & 0xff); + istate.mode = DICT0; + return Z_NEED_DICT$1; + case DICT0: + istate.mode = BAD; + z.msg = "need dictionary"; + istate.marker = 0; // can try inflateSync + return Z_STREAM_ERROR$1; + case BLOCKS: + + r = istate.blocks.proc(z, r); + if (r == Z_DATA_ERROR$1) { + istate.mode = BAD; + istate.marker = 0; // can try inflateSync + break; + } + if (r == Z_OK$1) { + r = f; + } + if (r != Z_STREAM_END$1) { + return r; + } + r = f; + istate.blocks.reset(z, istate.was); + istate.mode = DONE; + /* falls through */ + case DONE: + return Z_STREAM_END$1; + case BAD: + return Z_DATA_ERROR$1; + default: + return Z_STREAM_ERROR$1; + } + } + }; + + that.inflateSetDictionary = function (z, dictionary, dictLength) { + let index = 0, length = dictLength; + if (!z || !z.istate || z.istate.mode != DICT0) + return Z_STREAM_ERROR$1; + const istate = z.istate; + if (length >= (1 << istate.wbits)) { + length = (1 << istate.wbits) - 1; + index = dictLength - length; + } + istate.blocks.set_dictionary(dictionary, index, length); + istate.mode = BLOCKS; + return Z_OK$1; + }; + + that.inflateSync = function (z) { + let n; // number of bytes to look at + let p; // pointer to bytes + let m; // number of marker bytes found in a row + let r, w; // temporaries to save total_in and total_out + + // set up + if (!z || !z.istate) + return Z_STREAM_ERROR$1; + const istate = z.istate; + if (istate.mode != BAD) { + istate.mode = BAD; + istate.marker = 0; + } + if ((n = z.avail_in) === 0) + return Z_BUF_ERROR$1; + p = z.next_in_index; + m = istate.marker; + + // search + while (n !== 0 && m < 4) { + if (z.read_byte(p) == mark[m]) { + m++; + } else if (z.read_byte(p) !== 0) { + m = 0; + } else { + m = 4 - m; + } + p++; + n--; + } + + // restore + z.total_in += p - z.next_in_index; + z.next_in_index = p; + z.avail_in = n; + istate.marker = m; + + // return no joy or set up to restart on a new block + if (m != 4) { + return Z_DATA_ERROR$1; + } + r = z.total_in; + w = z.total_out; + inflateReset(z); + z.total_in = r; + z.total_out = w; + istate.mode = BLOCKS; + return Z_OK$1; + }; + + // Returns true if inflate is currently at the end of a block generated + // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP + // implementation to provide an additional safety check. PPP uses + // Z_SYNC_FLUSH + // but removes the length bytes of the resulting empty stored block. When + // decompressing, PPP checks that at the end of input packet, inflate is + // waiting for these length bytes. + that.inflateSyncPoint = function (z) { + if (!z || !z.istate || !z.istate.blocks) + return Z_STREAM_ERROR$1; + return z.istate.blocks.sync_point(); + }; + } + + // ZStream + + function ZStream$1() { + } + + ZStream$1.prototype = { + inflateInit: function (bits) { + const that = this; + that.istate = new Inflate(); + if (!bits) + bits = MAX_BITS$1; + return that.istate.inflateInit(that, bits); + }, + + inflate: function (f) { + const that = this; + if (!that.istate) + return Z_STREAM_ERROR$1; + return that.istate.inflate(that, f); + }, + + inflateEnd: function () { + const that = this; + if (!that.istate) + return Z_STREAM_ERROR$1; + const ret = that.istate.inflateEnd(that); + that.istate = null; + return ret; + }, + + inflateSync: function () { + const that = this; + if (!that.istate) + return Z_STREAM_ERROR$1; + return that.istate.inflateSync(that); + }, + inflateSetDictionary: function (dictionary, dictLength) { + const that = this; + if (!that.istate) + return Z_STREAM_ERROR$1; + return that.istate.inflateSetDictionary(that, dictionary, dictLength); + }, + read_byte: function (start) { + const that = this; + return that.next_in.subarray(start, start + 1)[0]; + }, + read_buf: function (start, size) { + const that = this; + return that.next_in.subarray(start, start + size); + } + }; + + // Inflater + + function ZipInflate() { + const that = this; + const z = new ZStream$1(); + const bufsize = 512; + const flush = Z_NO_FLUSH$1; + const buf = new Uint8Array(bufsize); + let nomoreinput = false; + + z.inflateInit(); + z.next_out = buf; + + that.append = function (data, onprogress) { + const buffers = []; + let err, array, lastIndex = 0, bufferIndex = 0, bufferSize = 0; + if (data.length === 0) + return; + z.next_in_index = 0; + z.next_in = data; + z.avail_in = data.length; + do { + z.next_out_index = 0; + z.avail_out = bufsize; + if ((z.avail_in === 0) && (!nomoreinput)) { // if buffer is empty and more input is available, refill it + z.next_in_index = 0; + nomoreinput = true; + } + err = z.inflate(flush); + if (nomoreinput && (err === Z_BUF_ERROR$1)) { + if (z.avail_in !== 0) + throw new Error("inflating: bad input"); + } else if (err !== Z_OK$1 && err !== Z_STREAM_END$1) + throw new Error("inflating: " + z.msg); + if ((nomoreinput || err === Z_STREAM_END$1) && (z.avail_in === data.length)) + throw new Error("inflating: bad input"); + if (z.next_out_index) + if (z.next_out_index === bufsize) + buffers.push(new Uint8Array(buf)); + else + buffers.push(new Uint8Array(buf.subarray(0, z.next_out_index))); + bufferSize += z.next_out_index; + if (onprogress && z.next_in_index > 0 && z.next_in_index != lastIndex) { + onprogress(z.next_in_index); + lastIndex = z.next_in_index; + } + } while (z.avail_in > 0 || z.avail_out === 0); + array = new Uint8Array(bufferSize); + buffers.forEach(function (chunk) { + array.set(chunk, bufferIndex); + bufferIndex += chunk.length; + }); + return array; + }; + that.flush = function () { + z.inflateEnd(); + }; + } + /* Copyright (c) 2021 Gildas Lormeau. All rights reserved. @@ -378,12 +4584,12 @@ const COMPRESSION_METHOD_STORE = 0x00; const COMPRESSION_METHOD_AES = 0x63; - const LOCAL_FILE_HEADER_SIGNATURE = 0x504b0304; - const DATA_DESCRIPTOR_RECORD_SIGNATURE = 0x504b0708; - const CENTRAL_FILE_HEADER_SIGNATURE = 0x504b0102; - const END_OF_CENTRAL_DIR_SIGNATURE = 0x504b0506; - const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x504b0606; - const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x504b0607; + const LOCAL_FILE_HEADER_SIGNATURE = 0x04034b50; + const DATA_DESCRIPTOR_RECORD_SIGNATURE = 0x08074b50; + const CENTRAL_FILE_HEADER_SIGNATURE = 0x02014b50; + const END_OF_CENTRAL_DIR_SIGNATURE = 0x06054b50; + const ZIP64_END_OF_CENTRAL_DIR_SIGNATURE = 0x06064b50; + const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE = 0x07064b50; const END_OF_CENTRAL_DIR_LENGTH = 22; const ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH = 20; const ZIP64_END_OF_CENTRAL_DIR_LENGTH = 56; @@ -739,14 +4945,14 @@ const CODEC_INFLATE = "inflate"; const ERR_INVALID_SIGNATURE = "Invalid signature"; - class Inflate { + class Inflate$1 { constructor(options) { this.signature = options.inputSignature; this.encrypted = Boolean(options.inputPassword); this.signed = options.inputSigned; this.compressed = options.inputCompressed; - this.inflate = this.compressed && new ZipInflate(); + this.inflate = this.compressed && new options.codecConstructor(); this.crc32 = this.signed && this.signed && new Crc32(); this.decrypt = this.encrypted && new ZipDecrypt(options.inputPassword); } @@ -788,13 +4994,13 @@ } } - class Deflate { + class Deflate$1 { constructor(options) { this.encrypted = options.outputEncrypted; this.signed = options.outputSigned; this.compressed = options.outputCompressed; - this.deflate = this.compressed && new ZipDeflate({ level: options.level || 5 }); + this.deflate = this.compressed && new options.codecConstructor({ level: options.level || 5 }); this.crc32 = this.signed && new Crc32(); this.encrypt = this.encrypted && new ZipEncrypt(options.outputPassword); } @@ -834,9 +5040,9 @@ function createCodec(options) { if (options.codecType.startsWith(CODEC_DEFLATE)) { - return new Deflate(options); + return new Deflate$1(options); } else if (options.codecType.startsWith(CODEC_INFLATE)) { - return new Inflate(options); + return new Inflate$1(options); } } @@ -875,8 +5081,8 @@ const Z_WORKER_SCRIPT_PATH = "z-worker.js"; const DEFAULT_WORKER_SCRIPTS = { - deflate: [Z_WORKER_SCRIPT_PATH, "deflate.js"], - inflate: [Z_WORKER_SCRIPT_PATH, "inflate.js"] + deflate: [Z_WORKER_SCRIPT_PATH], + inflate: [Z_WORKER_SCRIPT_PATH] }; const workers = { pool: [], @@ -958,8 +5164,24 @@ async function initAndSendMessage(message) { if (!task) { + const options = workerData.options; const scripts = workerData.scripts.slice(1); - await sendMessage(Object.assign({ type: MESSAGE_INIT, options: workerData.options, scripts })); + await sendMessage(Object.assign({ + scripts, + type: MESSAGE_INIT, options: { + codecType: options.codecType, + inputPassword: options.inputPassword, + inputSigned: options.inputSigned, + inputSignature: options.signature, + inputCompressed: options.inputCompressed, + inputEncrypted: options.inputEncrypted, + level: options.level, + outputPassword: options.outputPassword, + outputSigned: options.outputSigned, + outputCompressed: options.outputCompressed, + outputEncrypted: options.outputEncrypted + } + })); } return sendMessage(message); } @@ -1153,23 +5375,23 @@ } const endOfDirectoryView = new DataView(endOfDirectoryInfo.buffer); let zip64; - let directoryDataOffset = endOfDirectoryView.getUint32(16, true); - let filesLength = endOfDirectoryView.getUint16(8, true); + let directoryDataOffset = getUint32(endOfDirectoryView, 16); + let filesLength = getUint16(endOfDirectoryView, 8); if (directoryDataOffset == MAX_32_BITS || filesLength == MAX_16_BITS) { zip64 = true; const endOfDirectoryLocatorArray = await reader.readUint8Array(endOfDirectoryInfo.offset - ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_LENGTH); const endOfDirectoryLocatorView = new DataView(endOfDirectoryLocatorArray.buffer); - if (Number(endOfDirectoryLocatorView.getUint32(0, false)) != ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) { + if (Number(getUint32(endOfDirectoryLocatorView, 0)) != ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE) { throw new Error(ERR_EOCDR_ZIP64_NOT_FOUND); } - directoryDataOffset = Number(endOfDirectoryLocatorView.getBigUint64(8, true)); + directoryDataOffset = Number(getBigUint64(endOfDirectoryLocatorView, 8)); const endOfDirectoryArray = await reader.readUint8Array(directoryDataOffset, ZIP64_END_OF_CENTRAL_DIR_LENGTH); const endOfDirectoryView = new DataView(endOfDirectoryArray.buffer); - if (Number(endOfDirectoryView.getUint32(0, false)) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) { + if (Number(getUint32(endOfDirectoryView, 0)) != ZIP64_END_OF_CENTRAL_DIR_SIGNATURE) { throw new Error(ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND); } - filesLength = Number(endOfDirectoryView.getBigUint64(24, true)); - directoryDataOffset -= Number(endOfDirectoryView.getBigUint64(40, true)); + filesLength = Number(getBigUint64(endOfDirectoryView, 24)); + directoryDataOffset -= Number(getBigUint64(endOfDirectoryView, 40)); } if (directoryDataOffset < 0 || (!zip64 && (directoryDataOffset >= reader.size || filesLength >= MAX_16_BITS))) { throw new Error(ERR_BAD_FORMAT); @@ -1180,15 +5402,15 @@ let offset = 0; for (let indexFile = 0; indexFile < filesLength; indexFile++) { const fileEntry = new Entry(this.reader, this.config, this.options); - if (directoryView.getUint32(offset, false) != CENTRAL_FILE_HEADER_SIGNATURE) { + if (getUint32(directoryView, offset) != CENTRAL_FILE_HEADER_SIGNATURE) { throw new Error(ERR_CENTRAL_DIRECTORY_NOT_FOUND); } fileEntry.compressedSize = 0; fileEntry.uncompressedSize = 0; readCommonHeader(fileEntry, directoryView, offset + 6); - fileEntry.commentLength = directoryView.getUint16(offset + 32, true); - fileEntry.directory = ((directoryView.getUint8(offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK); - fileEntry.offset = directoryView.getUint32(offset + 42, true); + fileEntry.commentLength = getUint16(directoryView, offset + 32); + fileEntry.directory = (getUint8(directoryView, offset + 38) & FILE_ATTR_MSDOS_DIR_MASK) == FILE_ATTR_MSDOS_DIR_MASK; + fileEntry.offset = getUint32(directoryView, offset + 42); fileEntry.rawFilename = directoryArray.subarray(offset + 46, offset + 46 + fileEntry.filenameLength); const filenameEncoding = options.filenameEncoding === undefined ? this.options.filenameEncoding : options.filenameEncoding; fileEntry.filename = decodeString(fileEntry.rawFilename, fileEntry.bitFlag.languageEncodingFlag ? CHARSET_UTF8 : filenameEncoding); @@ -1239,7 +5461,7 @@ if (this.compressionMethod != COMPRESSION_METHOD_STORE && this.compressionMethod != COMPRESSION_METHOD_DEFLATE) { throw new Error(ERR_UNSUPPORTED_COMPRESSION); } - if (dataView.getUint32(0, false) != LOCAL_FILE_HEADER_SIGNATURE) { + if (getUint32(dataView, 0) != LOCAL_FILE_HEADER_SIGNATURE) { throw new Error(ERR_LOCAL_FILE_HEADER_NOT_FOUND); } const localDirectory = this.localDirectory = {}; @@ -1253,6 +5475,7 @@ } const codec = await createWorkerCodec(this.config, { codecType: CODEC_INFLATE, + codecConstructor: this.config.Inflate, inputPassword, inputSigned: options.checkSignature === undefined ? this.options.checkSignature : options.checkSignature, inputSignature: this.signature, @@ -1269,8 +5492,8 @@ } function readCommonHeader(directory, dataView, offset) { - directory.version = dataView.getUint16(offset, true); - const rawBitFlag = directory.rawBitFlag = dataView.getUint16(offset + 2, true); + directory.version = getUint16(dataView, offset); + const rawBitFlag = directory.rawBitFlag = getUint16(dataView, offset + 2); directory.bitFlag = { encrypted: (rawBitFlag & BITFLAG_ENCRYPTED) == BITFLAG_ENCRYPTED, level: (rawBitFlag & BITFLAG_LEVEL) >> 1, @@ -1278,10 +5501,10 @@ languageEncodingFlag: (rawBitFlag & BITFLAG_LANG_ENCODING_FLAG) == BITFLAG_LANG_ENCODING_FLAG }; directory.encrypted = directory.bitFlag.encrypted; - directory.rawLastModDate = dataView.getUint32(offset + 6, true); + directory.rawLastModDate = getUint32(dataView, offset + 6); directory.lastModDate = getDate(directory.rawLastModDate); - directory.filenameLength = dataView.getUint16(offset + 22, true); - directory.extraFieldLength = dataView.getUint16(offset + 24, true); + directory.filenameLength = getUint16(dataView, offset + 22); + directory.extraFieldLength = getUint16(dataView, offset + 24); } function readCommonFooter(fileEntry, directory, dataView, offset) { @@ -1291,8 +5514,8 @@ let offsetExtraField = 0; try { while (offsetExtraField < rawExtraField.length) { - const type = rawExtraFieldView.getUint16(offsetExtraField, true); - const size = rawExtraFieldView.getUint16(offsetExtraField + 2, true); + const type = getUint16(rawExtraFieldView, offsetExtraField); + const size = getUint16(rawExtraFieldView, offsetExtraField + 2); extraField.set(type, { type, data: rawExtraField.slice(offsetExtraField + 4, offsetExtraField + 4 + size) @@ -1302,10 +5525,10 @@ } catch (error) { // ignored } - const compressionMethod = dataView.getUint16(offset + 4, true); - directory.signature = dataView.getUint32(offset + 10, true); - directory.uncompressedSize = dataView.getUint32(offset + 18, true); - directory.compressedSize = dataView.getUint32(offset + 14, true); + const compressionMethod = getUint16(dataView, offset + 4); + directory.signature = getUint32(dataView, offset + 10); + directory.uncompressedSize = getUint32(dataView, offset + 18); + directory.compressedSize = getUint32(dataView, offset + 14); const extraFieldZip64 = directory.extraFieldZip64 = extraField.get(EXTRAFIELD_TYPE_ZIP64); if (extraFieldZip64) { readExtraFieldZip64(extraFieldZip64, directory); @@ -1334,7 +5557,7 @@ const extraFieldView = new DataView(extraFieldZip64.data.buffer); extraFieldZip64.values = []; for (let indexValue = 0; indexValue < Math.floor(extraFieldZip64.data.length / 8); indexValue++) { - extraFieldZip64.values.push(Number(extraFieldView.getBigUint64(0 + indexValue * 8, true))); + extraFieldZip64.values.push(Number(getBigUint64(extraFieldView, 0 + indexValue * 8))); } const missingProperties = ZIP64_PROPERTIES.filter(propertyName => directory[propertyName] == MAX_32_BITS); for (let indexMissingProperty = 0; indexMissingProperty < missingProperties.length; indexMissingProperty++) { @@ -1353,14 +5576,14 @@ function readExtraFieldUnicode(extraFieldUnicode, propertyName, rawPropertyName, directory, fileEntry) { const extraFieldView = new DataView(extraFieldUnicode.data.buffer); - extraFieldUnicode.version = extraFieldView.getUint8(0); - extraFieldUnicode.signature = extraFieldView.getUint32(1, true); + extraFieldUnicode.version = getUint8(extraFieldView, 0); + extraFieldUnicode.signature = getUint32(extraFieldView, 1); const crc32 = new Crc32(); crc32.append(fileEntry[rawPropertyName]); const dataViewSignature = new DataView(new Uint8Array(4).buffer); dataViewSignature.setUint32(0, crc32.get()); extraFieldUnicode[propertyName] = (new TextDecoder()).decode(extraFieldUnicode.data.subarray(5)); - if (!fileEntry.bitFlag.languageEncodingFlag && extraFieldUnicode.signature == dataViewSignature.getUint32(0, false)) { + if (!fileEntry.bitFlag.languageEncodingFlag && extraFieldUnicode.signature == getUint32(dataViewSignature, 0)) { directory[propertyName] = extraFieldUnicode[propertyName]; } } @@ -1368,12 +5591,12 @@ function readExtraFieldAES(extraFieldAES, directory, compressionMethod) { if (extraFieldAES) { const extraFieldView = new DataView(extraFieldAES.data.buffer); - extraFieldAES.vendorVersion = extraFieldView.getUint8(0); - extraFieldAES.vendorId = extraFieldView.getUint8(2); - const strength = extraFieldView.getUint8(4); + extraFieldAES.vendorVersion = getUint8(extraFieldView, 0); + extraFieldAES.vendorId = getUint8(extraFieldView, 2); + const strength = getUint8(extraFieldView, 4); extraFieldAES.strength = strength; extraFieldAES.originalCompressionMethod = compressionMethod; - directory.compressionMethod = extraFieldAES.compressionMethod = extraFieldView.getUint16(5, true); + directory.compressionMethod = extraFieldAES.compressionMethod = getUint16(extraFieldView, 5); } else { directory.compressionMethod = compressionMethod; } @@ -1382,7 +5605,7 @@ async function seekSignature(reader, signature, minimumBytes, maximumLength) { const signatureArray = new Uint8Array(4); const signatureView = new DataView(signatureArray.buffer); - signatureView.setUint32(0, signature); + setUint32(signatureView, 0, signature); if (reader.size < minimumBytes) { throw new Error(ERR_BAD_FORMAT); } @@ -1430,6 +5653,26 @@ } } + function getUint8(view, offset) { + return view.getUint8(offset); + } + + function getUint16(view, offset) { + return view.getUint16(offset, true); + } + + function getUint32(view, offset) { + return view.getUint32(offset, true); + } + + function getBigUint64(view, offset) { + return view.getBigUint64(offset, true); + } + + function setUint32(view, offset, value) { + view.setUint32(offset, value, true); + } + /* Copyright (c) 2021 Gildas Lormeau. All rights reserved. @@ -1478,7 +5721,6 @@ this.config = config; this.files = new Map(); this.offset = writer.size; - this.zip64 = options.zip64; } async add(name = "", reader, options = {}) { @@ -1527,11 +5769,11 @@ offset += 4 + data.length; }); } - let zip64 = options.zip64 || this.zip64; - if (this.offset >= MAX_32_BITS || (reader && (reader.size >= MAX_32_BITS || this.offset + reader.size >= MAX_32_BITS))) { - zip64 = true; - } - await addFile(this, name, reader, Object.assign({}, options, { rawFilename, rawComment, version, lastModDate, rawExtraField, zip64 })); + const zip64 = options.zip64 || this.options.zip64 || this.offset >= MAX_32_BITS || (reader && (reader.size >= MAX_32_BITS || this.offset + reader.size >= MAX_32_BITS)); + const password = options.password === undefined ? this.options.password : options.password; + const level = options.level === undefined ? this.options.level : options.level; + const useWebWorkers = options.useWebWorkers === undefined ? this.options.useWebWorkers : options.useWebWorkers; + await addFile(this, name, reader, Object.assign({}, options, { rawFilename, rawComment, version, lastModDate, rawExtraField, zip64, password, level, useWebWorkers })); } async close(comment = new Uint8Array(0)) { @@ -1540,7 +5782,7 @@ let offset = 0, directoryDataLength = 0, directoryOffset = this.offset, filesLength = files.size; if (comment.length) { if (comment.length <= MAX_16_BITS) { - directoryView.setUint16(offset + 20, comment.length, true); + setUint16(directoryView, offset + 20, comment.length); } else { throw new Error(ERR_INVALID_COMMENT); } @@ -1548,28 +5790,26 @@ for (const [, fileEntry] of files) { directoryDataLength += 46 + fileEntry.rawFilename.length + fileEntry.rawComment.length + fileEntry.extraFieldZip64.length + fileEntry.extraFieldAES.length + fileEntry.rawExtraField.length; } - if (directoryOffset + directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS) { - this.zip64 = true; - } - const directoryArray = new Uint8Array(directoryDataLength + (this.zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH)); + const zip64 = this.options.zip64 || directoryOffset + directoryDataLength >= MAX_32_BITS || filesLength >= MAX_16_BITS; + const directoryArray = new Uint8Array(directoryDataLength + (zip64 ? ZIP64_END_OF_CENTRAL_DIR_TOTAL_LENGTH : END_OF_CENTRAL_DIR_LENGTH)); const directoryView = new DataView(directoryArray.buffer); for (const [, fileEntry] of files) { const rawFilename = fileEntry.rawFilename; const extraFieldZip64 = fileEntry.extraFieldZip64; const extraFieldAES = fileEntry.extraFieldAES; const extraFieldLength = extraFieldZip64.length + extraFieldAES.length + fileEntry.rawExtraField.length; - directoryView.setUint32(offset, CENTRAL_FILE_HEADER_SIGNATURE); - directoryView.setUint16(offset + 4, fileEntry.version, true); + setUint32$1(directoryView, offset, CENTRAL_FILE_HEADER_SIGNATURE); + setUint16(directoryView, offset + 4, fileEntry.version); directoryArray.set(fileEntry.headerArray, offset + 6); - directoryView.setUint16(offset + 30, extraFieldLength, true); - directoryView.setUint16(offset + 32, fileEntry.rawComment.length, true); + setUint16(directoryView, offset + 30, extraFieldLength); + setUint16(directoryView, offset + 32, fileEntry.rawComment.length); if (fileEntry.directory) { - directoryView.setUint8(offset + 38, FILE_ATTR_MSDOS_DIR_MASK); + setUint8(directoryView, offset + 38, FILE_ATTR_MSDOS_DIR_MASK); } if (fileEntry.zip64) { - directoryView.setUint32(offset + 42, MAX_32_BITS, true); + setUint32$1(directoryView, offset + 42, MAX_32_BITS); } else { - directoryView.setUint32(offset + 42, fileEntry.offset, true); + setUint32$1(directoryView, offset + 42, fileEntry.offset); } directoryArray.set(rawFilename, offset + 46); directoryArray.set(extraFieldZip64, offset + 46 + rawFilename.length); @@ -1578,27 +5818,27 @@ directoryArray.set(fileEntry.rawComment, offset + 46 + rawFilename.length + extraFieldLength); offset += 46 + rawFilename.length + extraFieldLength + fileEntry.rawComment.length; } - if (this.zip64) { - directoryView.setUint32(offset, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE); - directoryView.setBigUint64(offset + 4, BigInt(44), true); - directoryView.setUint16(offset + 12, 45, true); - directoryView.setUint16(offset + 14, 45, true); - directoryView.setBigUint64(offset + 24, BigInt(filesLength), true); - directoryView.setBigUint64(offset + 32, BigInt(filesLength), true); - directoryView.setBigUint64(offset + 40, BigInt(directoryDataLength), true); - directoryView.setBigUint64(offset + 48, BigInt(directoryOffset), true); - directoryView.setUint32(offset + 56, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE); - directoryView.setBigUint64(offset + 64, BigInt(directoryOffset + directoryDataLength), true); - directoryView.setUint32(offset + 72, ZIP64_TOTAL_NUMBER_OF_DISKS, true); + if (zip64) { + setUint32$1(directoryView, offset, ZIP64_END_OF_CENTRAL_DIR_SIGNATURE); + setBigUint64(directoryView, offset + 4, BigInt(44)); + setUint16(directoryView, offset + 12, 45); + setUint16(directoryView, offset + 14, 45); + setBigUint64(directoryView, offset + 24, BigInt(filesLength)); + setBigUint64(directoryView, offset + 32, BigInt(filesLength)); + setBigUint64(directoryView, offset + 40, BigInt(directoryDataLength)); + setBigUint64(directoryView, offset + 48, BigInt(directoryOffset)); + setUint32$1(directoryView, offset + 56, ZIP64_END_OF_CENTRAL_DIR_LOCATOR_SIGNATURE); + setBigUint64(directoryView, offset + 64, BigInt(directoryOffset + directoryDataLength)); + setUint32$1(directoryView, offset + 72, ZIP64_TOTAL_NUMBER_OF_DISKS); filesLength = MAX_16_BITS; directoryOffset = MAX_32_BITS; offset += 76; } - directoryView.setUint32(offset, END_OF_CENTRAL_DIR_SIGNATURE); - directoryView.setUint16(offset + 8, filesLength, true); - directoryView.setUint16(offset + 10, filesLength, true); - directoryView.setUint32(offset + 12, directoryDataLength, true); - directoryView.setUint32(offset + 16, directoryOffset, true); + setUint32$1(directoryView, offset, END_OF_CENTRAL_DIR_SIGNATURE); + setUint16(directoryView, offset + 8, filesLength); + setUint16(directoryView, offset + 10, filesLength); + setUint32$1(directoryView, offset + 12, directoryDataLength); + setUint32$1(directoryView, offset + 16, directoryOffset); await writer.writeUint8Array(directoryArray); await writer.writeUint8Array(comment); return writer.getData(); @@ -1622,8 +5862,7 @@ } fileWriter = writer; } - - fileEntry = await createFileEntry(name, reader, fileWriter, zipWriter.config, zipWriter.options, options); + fileEntry = await createFileEntry(reader, fileWriter, zipWriter.config, options); } catch (error) { files.delete(name); throw error; @@ -1638,7 +5877,7 @@ fileEntry.offset = zipWriter.offset; if (fileEntry.zip64) { const extraFieldZip64View = new DataView(fileEntry.extraFieldZip64.buffer); - extraFieldZip64View.setBigUint64(20, BigInt(fileEntry.offset), true); + setBigUint64(extraFieldZip64View, 20, BigInt(fileEntry.offset)); } zipWriter.offset += fileEntry.length; } finally { @@ -1649,22 +5888,19 @@ } } - async function createFileEntry(filename, reader, writer, config, zipWriterOptions, options) { + async function createFileEntry(reader, writer, config, options) { const rawFilename = options.rawFilename; - const date = options.lastModDate; - const headerArray = new Uint8Array(26); - const headerView = new DataView(headerArray.buffer); - const password = options.password === undefined ? zipWriterOptions.password : options.password; - const outputPassword = password && password.length && password; - const level = options.level === undefined ? zipWriterOptions.level : options.level; - const compressed = level !== 0 && !options.directory; - const outputSigned = password === undefined || !password.length; + const lastModDate = options.lastModDate; + const outputPassword = options.password; + const outputEncrypted = outputPassword && outputPassword.length; + const level = options.level; + const outputCompressed = level !== 0 && !options.directory; const zip64 = options.zip64; let extraFieldAES; - if (outputPassword) { + if (outputEncrypted) { extraFieldAES = new Uint8Array(EXTRAFIELD_DATA_AES.length + 2); const extraFieldAESView = new DataView(extraFieldAES.buffer); - extraFieldAESView.setUint16(0, EXTRAFIELD_TYPE_AES, true); + setUint16(extraFieldAESView, 0, EXTRAFIELD_TYPE_AES); extraFieldAES.set(EXTRAFIELD_DATA_AES, 2); } else { extraFieldAES = new Uint8Array(0); @@ -1672,11 +5908,8 @@ const fileEntry = { version: options.version || VERSION_DEFLATE, zip64, - headerArray: headerArray, directory: options.directory, - filename, rawFilename, - comment: options.comment, rawComment: options.rawComment, extraFieldZip64: zip64 ? new Uint8Array(EXTRAFIELD_LENGTH_ZIP64 + 4) : new Uint8Array(0), extraFieldAES, @@ -1684,73 +5917,76 @@ }; let bitFlag = BITFLAG_DATA_DESCRIPTOR | BITFLAG_LANG_ENCODING_FLAG; let compressionMethod = COMPRESSION_METHOD_STORE; - if (compressed) { + if (outputCompressed) { compressionMethod = COMPRESSION_METHOD_DEFLATE; } if (zip64) { fileEntry.version = fileEntry.version > VERSION_ZIP64 ? fileEntry.version : VERSION_ZIP64; } - if (outputPassword) { - fileEntry.encrypted = true; + if (outputEncrypted) { fileEntry.version = fileEntry.version > VERSION_AES ? fileEntry.version : VERSION_AES; bitFlag = bitFlag | BITFLAG_ENCRYPTED; compressionMethod = COMPRESSION_METHOD_AES; - if (compressed) { + if (outputCompressed) { fileEntry.extraFieldAES[9] = COMPRESSION_METHOD_DEFLATE; } } - headerView.setUint16(0, fileEntry.version, true); - headerView.setUint16(2, bitFlag, true); - headerView.setUint16(4, compressionMethod, true); - headerView.setUint16(6, (((date.getHours() << 6) | date.getMinutes()) << 5) | date.getSeconds() / 2, true); - headerView.setUint16(8, ((((date.getFullYear() - 1980) << 4) | (date.getMonth() + 1)) << 5) | date.getDate(), true); - headerView.setUint16(22, rawFilename.length, true); - headerView.setUint16(24, 0, true); + const headerArray = fileEntry.headerArray = new Uint8Array(26); + const headerView = new DataView(headerArray.buffer); + setUint16(headerView, 0, fileEntry.version); + setUint16(headerView, 2, bitFlag); + setUint16(headerView, 4, compressionMethod); + setUint16(headerView, 6, (((lastModDate.getHours() << 6) | lastModDate.getMinutes()) << 5) | lastModDate.getSeconds() / 2); + setUint16(headerView, 8, ((((lastModDate.getFullYear() - 1980) << 4) | (lastModDate.getMonth() + 1)) << 5) | lastModDate.getDate()); + setUint16(headerView, 22, rawFilename.length); + setUint16(headerView, 24, 0); const fileDataArray = new Uint8Array(30 + rawFilename.length); const fileDataView = new DataView(fileDataArray.buffer); - fileDataView.setUint32(0, LOCAL_FILE_HEADER_SIGNATURE); + setUint32$1(fileDataView, 0, LOCAL_FILE_HEADER_SIGNATURE); fileDataArray.set(headerArray, 4); fileDataArray.set(rawFilename, 30); - let result; + let result, unCompressedSize, compressedSize; if (reader) { + unCompressedSize = reader.size; const codec = await createWorkerCodec(config, { codecType: CODEC_DEFLATE, + codecConstructor: config.Deflate, level, - outputPassword: password, - outputSigned, - outputCompressed: compressed, - outputEncrypted: Boolean(password), - useWebWorkers: options.useWebWorkers === undefined ? zipWriterOptions.useWebWorkers : options.useWebWorkers + outputPassword, + outputSigned: true, + outputCompressed, + outputEncrypted, + useWebWorkers: options.useWebWorkers }); await writer.writeUint8Array(fileDataArray); - result = await processData(codec, reader, writer, 0, reader.size, config, { onprogress: options.onprogress }); - fileEntry.compressedSize = result.length; + result = await processData(codec, reader, writer, 0, unCompressedSize, config, { onprogress: options.onprogress }); + compressedSize = result.length; } else { await writer.writeUint8Array(fileDataArray); } const footerArray = new Uint8Array(zip64 ? 24 : 16); const footerView = new DataView(footerArray.buffer); - footerView.setUint32(0, DATA_DESCRIPTOR_RECORD_SIGNATURE); + setUint32$1(footerView, 0, DATA_DESCRIPTOR_RECORD_SIGNATURE); if (reader) { - if (!outputPassword && result.signature !== undefined) { - headerView.setUint32(10, result.signature, true); - footerView.setUint32(4, result.signature, true); + if (!outputEncrypted && result.signature !== undefined) { + setUint32$1(headerView, 10, result.signature); + setUint32$1(footerView, 4, result.signature); } if (zip64) { - headerView.setUint32(14, MAX_32_BITS, true); - footerView.setBigUint64(8, BigInt(fileEntry.compressedSize), true); - headerView.setUint32(18, MAX_32_BITS, true); - footerView.setBigUint64(16, BigInt(reader.size), true); const extraFieldZip64View = new DataView(fileEntry.extraFieldZip64.buffer); - extraFieldZip64View.setUint16(0, EXTRAFIELD_TYPE_ZIP64, true); - extraFieldZip64View.setUint16(2, EXTRAFIELD_LENGTH_ZIP64, true); - extraFieldZip64View.setBigUint64(4, BigInt(reader.size), true); - extraFieldZip64View.setBigUint64(12, BigInt(fileEntry.compressedSize), true); + setUint16(extraFieldZip64View, 0, EXTRAFIELD_TYPE_ZIP64); + setUint16(extraFieldZip64View, 2, EXTRAFIELD_LENGTH_ZIP64); + setUint32$1(headerView, 14, MAX_32_BITS); + setBigUint64(footerView, 8, BigInt(compressedSize)); + setBigUint64(extraFieldZip64View, 12, BigInt(compressedSize)); + setUint32$1(headerView, 18, MAX_32_BITS); + setBigUint64(footerView, 16, BigInt(unCompressedSize)); + setBigUint64(extraFieldZip64View, 4, BigInt(unCompressedSize)); } else { - headerView.setUint32(14, fileEntry.compressedSize, true); - footerView.setUint32(8, fileEntry.compressedSize, true); - headerView.setUint32(18, reader.size, true); - footerView.setUint32(12, reader.size, true); + setUint32$1(headerView, 14, compressedSize); + setUint32$1(footerView, 8, compressedSize); + setUint32$1(headerView, 18, unCompressedSize); + setUint32$1(footerView, 12, unCompressedSize); } } await writer.writeUint8Array(footerArray); @@ -1758,12 +5994,28 @@ return fileEntry; } + function setUint8(view, offset, value) { + view.setUint8(offset, value); + } + + function setUint16(view, offset, value) { + view.setUint16(offset, value, true); + } + + function setUint32$1(view, offset, value) { + view.setUint32(offset, value, true); + } + + function setBigUint64(view, offset, value) { + view.setBigUint64(offset, value, true); + } + const FUNCTION_TYPE = "function"; var streamCodecShim = (library, options = {}) => { return { - ZipDeflate: createCodecClass(library.Deflate, options.deflate), - ZipInflate: createCodecClass(library.Inflate, options.inflate) + Deflate: createCodecClass(library.Deflate, options.deflate), + Inflate: createCodecClass(library.Inflate, options.inflate) }; }; @@ -1842,7 +6094,9 @@ chunkSize: 512 * 1024, maxWorkers: (typeof navigator != "undefined" && navigator.hardwareConcurrency) || 2, workerScriptsPath: undefined, - useWebWorkers: true + useWebWorkers: true, + Deflate: ZipDeflate, + Inflate: ZipInflate }; let config = Object.assign({}, DEFAULT_CONFIGURATION); diff --git a/dist/zip.min.js b/dist/zip.min.js index 63cc0980..c236fa84 100644 --- a/dist/zip.min.js +++ b/dist/zip.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).zip={})}(this,(function(t){"use strict";const e="HTTP error ",n="HTTP Range not supported",r="text/plain";class i{constructor(){this.size=0}init(){this.initialized=!0}}class s extends i{}class a extends i{writeUint8Array(t){this.size+=t.length}}class o extends s{constructor(t){super(),this.blob=t,this.size=t.size}readUint8Array(t,e){const n=new FileReader;return new Promise(((r,i)=>{n.onload=t=>r(new Uint8Array(t.target.result)),n.onerror=i,n.readAsArrayBuffer(this.blob.slice(t,t+e))}))}}class c extends a{constructor(){super(),this.array=new Uint8Array(0)}writeUint8Array(t){super.writeUint8Array(t);const e=this.array;this.array=new Uint8Array(e.length+t.length),this.array.set(e),this.array.set(t,e.length)}getData(){return this.array}}function h(t,n){return new Promise(((r,i)=>{const s=new XMLHttpRequest;s.addEventListener("load",(()=>{s.status<400?(t.size||(t.size=Number(s.getResponseHeader("Content-Length"))||Number(s.response.byteLength)),t.data=new Uint8Array(s.response),r()):i(e+(s.statusText||s.status)+".")}),!1),s.addEventListener("error",i,!1),s.open("GET",n),s.responseType="arraybuffer",s.send()}))}const l=4294967295,d=65535,u=1347093252,p=1347094280,g=1347092738,w=1347093766,f=1347094022,y=1347094023,U=39169,m=2048;class b{constructor(){this.crc=-1,this.table=(()=>{const t=[];for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)1&n?n=n>>>1^3988292384:n>>>=1;t[e]=n}return t})()}append(t){const e=this.table;let n=0|this.crc;for(let r=0,i=0|t.length;r>>8^e[255&(n^t[r])];this.crc=n}get(){return~this.crc}}const A="Invalid pasword",E=16,R="raw",D={name:"PBKDF2"},x={name:"HMAC"},F="SHA-1",v={name:"AES-CTR"},S=Object.assign({hash:x},D),z=Object.assign({iterations:1e3,hash:{name:F}},D),I=Object.assign({hash:F},x),T=Object.assign({length:E},v),L=["deriveBits"],_=["sign"],k=528,C=10,B=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],M=crypto.subtle;class N{constructor(t,e){this.password=t,this.signed=e,this.input=e&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(t){const e=async(i=0)=>{if(i+E<=r.length-C){const t=r.subarray(i,i+E),s=await M.decrypt(Object.assign({counter:this.counter},T),this.keys.decrypt,t);return W(this.counter),n.set(new Uint8Array(s),i),e(i+E)}return this.pendingInput=r.subarray(i),this.signed&&(this.input=P(this.input,t)),n};if(this.password){const e=t.subarray(0,18);await async function(t,e,n){t.counter=new Uint8Array(B);const r=e.subarray(0,16),i=e.subarray(16),s=(new TextEncoder).encode(n),a=await M.importKey(R,s,S,!1,L),o=await M.deriveBits(Object.assign({salt:r},z),a,528),c=new Uint8Array(o),h=c.subarray(64);if(t.keys={decrypt:await M.importKey(R,c.subarray(0,32),v,!0,["decrypt"]),authentication:await M.importKey(R,c.subarray(32,64),I,!1,_),passwordVerification:h},h[0]!=i[0]||h[1]!=i[1])throw new Error(A)}(this,e,this.password),this.password=null,t=t.subarray(18)}let n=new Uint8Array(t.length-C-(t.length-C)%E),r=t;return this.pendingInput.length&&(r=P(this.pendingInput,t),n=V(n,r.length-C-(r.length-C)%E)),e()}async flush(){const t=this.pendingInput,e=this.keys,n=t.subarray(0,t.length-C),r=t.subarray(t.length-C);let i=new Uint8Array(0);if(n.length){const t=await M.decrypt(Object.assign({counter:this.counter},T),e.decrypt,n);i=new Uint8Array(t)}let s=!0;if(this.signed){const t=await M.sign(x,e.authentication,this.input.subarray(0,this.input.length-C)),n=new Uint8Array(t);this.input=null;for(let t=0;t{if(i+E<=t.length){const s=t.subarray(i,i+E),a=await M.encrypt(Object.assign({counter:this.counter},T),this.keys.encrypt,s);return W(this.counter),r.set(new Uint8Array(a),i+n.length),e(i+E)}return this.pendingInput=t.subarray(i),this.output=P(this.output,r),r};let n=new Uint8Array(0);this.password&&(n=await async function(t,e){t.counter=new Uint8Array(B);const n=crypto.getRandomValues(new Uint8Array(16)),r=(new TextEncoder).encode(e),i=await M.importKey(R,r,S,!1,L),s=await M.deriveBits(Object.assign({salt:n},z),i,k),a=new Uint8Array(s);return t.keys={encrypt:await M.importKey(R,a.subarray(0,32),v,!0,["encrypt"]),authentication:await M.importKey(R,a.subarray(32,64),I,!1,_),passwordVerification:a.subarray(64)},P(n,t.keys.passwordVerification)}(this,this.password),this.password=null);let r=new Uint8Array(n.length+t.length-t.length%E);return r.set(n,0),this.pendingInput.length&&(t=P(this.pendingInput,t),r=V(r,t.length-t.length%E)),e()}async flush(){let t=new Uint8Array(0);if(this.pendingInput.length){const e=await M.encrypt(Object.assign({counter:this.counter},T),this.keys.encrypt,this.pendingInput);t=new Uint8Array(e),this.output=P(this.output,t)}const e=await M.sign(x,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(e).subarray(0,C);return{data:P(t,n),signature:n}}}function W(t){for(let e=0;e<16;e++){if(255!=t[e]){t[e]++;break}t[e]=0}}function P(t,e){let n=t;return t.length+e.length&&(n=new Uint8Array(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function V(t,e){if(e&&e>t.length){const n=t;(t=new Uint8Array(e)).set(n,0)}return t}const j="deflate",H="inflate",Z="Invalid signature";class K{constructor(t){this.signature=t.inputSignature,this.encrypted=Boolean(t.inputPassword),this.signed=t.inputSigned,this.compressed=t.inputCompressed,this.inflate=this.compressed&&new ZipInflate,this.crc32=this.signed&&this.signed&&new b,this.decrypt=this.encrypted&&new N(t.inputPassword)}async append(t){return this.encrypted&&(t=await this.decrypt.append(t)),this.compressed&&t.length&&(t=await this.inflate.append(t)),!this.encrypted&&this.signed&&this.crc32.append(t),t}async flush(){let t,e=new Uint8Array(0);if(this.encrypted){const t=await this.decrypt.flush();if(!t.valid)throw new Error(Z);e=t.data}else if(this.signed){const e=new DataView(new Uint8Array(4).buffer);if(t=this.crc32.get(),e.setUint32(0,t),this.signature!=e.getUint32(0,!1))throw new Error(Z)}return this.compressed&&(e=await this.inflate.append(e)||new Uint8Array(0),await this.inflate.flush()),{data:e,signature:t}}}class q{constructor(t){this.encrypted=t.outputEncrypted,this.signed=t.outputSigned,this.compressed=t.outputCompressed,this.deflate=this.compressed&&new ZipDeflate({level:t.level||5}),this.crc32=this.signed&&new b,this.encrypt=this.encrypted&&new O(t.outputPassword)}async append(t){let e=t;return this.compressed&&t.length&&(e=await this.deflate.append(t)),this.encrypted?e=await this.encrypt.append(e):this.signed&&this.crc32.append(t),e}async flush(){let t,e=new Uint8Array(0);if(this.compressed&&(e=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){e=await this.encrypt.append(e);const n=await this.encrypt.flush();t=n.signature;const r=new Uint8Array(e.length+n.data.length);r.set(e,0),r.set(n.data,e.length),e=r}else this.signed&&(t=this.crc32.get());return{data:e,signature:t}}}const Y="init",X="append",G="flush",J="message",Q="z-worker.js",$={deflate:[Q,"deflate.js"],inflate:[Q,"inflate.js"]},tt={pool:[],pendingRequests:[]};function et(t,e){const n=tt.pool,r=!(e.inputCompressed||e.inputSigned||e.inputEncrypted||e.outputCompressed||e.outputSigned||e.outputEncrypted);let i;if(e.useWebWorkers||void 0===e.useWebWorkers&&t.useWebWorkers&&!r){const n=e.codecType;t.workerScripts?(s=t.workerScripts[n],i="undefined"!=typeof document?s.map((t=>new URL(t,document.baseURI).href)):s):(i=$[n].slice(0),i[0]=(t.workerScriptsPath||"")+i[0])}var s;if(n.length!t.busy));return t?nt(t,e,i):new Promise((t=>tt.pendingRequests.push({resolve:t,options:e,scripts:i})))}}function nt(t,e,n){return t.busy=!0,t.options=e,t.scripts=n,n?function(t){let e;t.interface||(t.worker=new Worker(t.scripts[0]),t.worker.addEventListener(J,i,!1),t.interface={append:t=>n({type:X,data:t}),flush:()=>n({type:G})});return t.interface;async function n(n){if(!e){const e=t.scripts.slice(1);await r(Object.assign({type:Y,options:t.options,scripts:e}))}return r(n)}function r(n){const r=t.worker,i=new Promise(((t,n)=>e={resolve:t,reject:n}));try{if(n.data)try{r.postMessage(n,[n.data.buffer])}catch(t){r.postMessage(n)}else r.postMessage(n)}catch(n){e.reject(n),e=null,rt(t)}return i}function i(n){const r=n.data;if(e){const n=r.error;if(n){const r=new Error(n.message);r.stack=n.stack,e.reject(r),e=null,rt(t)}else r.type!=Y&&r.type!=G&&r.type!=X||(r.type==G?(e.resolve({data:new Uint8Array(r.data),signature:r.signature}),e=null,rt(t)):e.resolve(r.data&&new Uint8Array(r.data)))}}}(t):function(t){const e=function(t){return t.codecType.startsWith(j)?new q(t):t.codecType.startsWith(H)?new K(t):void 0}(t.options);return{async append(n){try{return await e.append(n)}catch(e){throw rt(t),e}},async flush(){try{return await e.flush()}finally{rt(t)}}}}(t)}function rt(t){if(t.busy=!1,tt.pendingRequests.length){const[{resolve:e,options:n,scripts:r}]=tt.pendingRequests.splice(0,1);e(nt(t,n,r))}else t.worker&&t.worker.terminate(),tt.pool=tt.pool.filter((e=>e!=t))}async function it(t,e,n,r,i,s,a){const o=Math.max(s.chunkSize,64);return async function s(c=0,h=0){const l=c*o;if(l","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","⌂","Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","¢","£","¥","₧","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","⌐","¬","½","¼","¡","«","»","░","▒","▓","│","┤","╡","╢","╖","╕","╣","║","╗","╝","╜","╛","┐","└","┴","┬","├","─","┼","╞","╟","╚","╔","╩","╦","╠","═","╬","╧","╨","╤","╥","╙","╘","╒","╓","╫","╪","┘","┌","█","▄","▌","▐","▀","α","ß","Γ","π","Σ","σ","µ","τ","Φ","Θ","Ω","δ","∞","φ","ε","∩","≡","±","≥","≤","⌠","⌡","÷","≈","°","∙","·","√","ⁿ","²","■"," "];class mt{constructor(t,e,n){this.reader=t,this.config=e,this.options=n}async getData(t,e={}){const n=this.reader;n.initialized||await n.init();const r=await n.readUint8Array(this.offset,30),i=new DataView(r.buffer),s=void 0===e.password?this.options.password:e.password;let a=s&&s.length&&s;if(this.extraFieldAES){if(99!=this.extraFieldAES.originalCompressionMethod)throw new Error(wt);if(3!=this.extraFieldAES.strength)throw new Error(gt)}if(0!=this.compressionMethod&&8!=this.compressionMethod)throw new Error(wt);if(i.getUint32(0,!1)!=u)throw new Error(dt);const o=this.localDirectory={};bt(o,i,4),o.rawExtraField=r.subarray(this.offset+30+o.filenameLength,this.offset+30+o.filenameLength+o.extraFieldLength),At(this,o,i,4);let c=this.offset+30+o.filenameLength+o.extraFieldLength;const h=this.bitFlag.encrypted&&o.bitFlag.encrypted;if(h&&!a)throw new Error(pt);const l=await et(this.config,{codecType:H,inputPassword:a,inputSigned:void 0===e.checkSignature?this.options.checkSignature:e.checkSignature,inputSignature:this.signature,inputCompressed:0!=this.compressionMethod,inputEncrypted:h,useWebWorkers:void 0===e.useWebWorkers?this.options.useWebWorkers:e.useWebWorkers});return t.initialized||await t.init(),await it(l,n,t,c,this.compressedSize,this.config,{onprogress:e.onprogress}),t.getData()}}function bt(t,e,n){t.version=e.getUint16(n,!0);const r=t.rawBitFlag=e.getUint16(n+2,!0);t.bitFlag={encrypted:1==(1&r),level:(6&r)>>1,dataDescriptor:8==(8&r),languageEncodingFlag:(r&m)==m},t.encrypted=t.bitFlag.encrypted,t.rawLastModDate=e.getUint32(n+6,!0),t.lastModDate=function(t){const e=(4294901760&t)>>16,n=65535&t;try{return new Date(1980+((65024&e)>>9),((480&e)>>5)-1,31&e,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(t){}}(t.rawLastModDate),t.filenameLength=e.getUint16(n+22,!0),t.extraFieldLength=e.getUint16(n+24,!0)}function At(t,e,n,r){const i=e.rawExtraField,s=e.extraField=new Map,a=new DataView(new Uint8Array(i).buffer);let o=0;try{for(;oe[t]==l));for(let e=0;e{if(e[n]==l){if(!t||void 0===t[n])throw new Error(ut);e[n]=t[n]}}))}(h,e);const d=e.extraFieldUnicodePath=s.get(28789);d&&Et(d,"filename","rawFilename",e,t);let u=e.extraFieldUnicodeComment=s.get(25461);u&&Et(u,"comment","rawComment",e,t);const p=e.extraFieldAES=s.get(39169);p?function(t,e,n){if(t){const r=new DataView(t.data.buffer);t.vendorVersion=r.getUint8(0),t.vendorId=r.getUint8(2);const i=r.getUint8(4);t.strength=i,t.originalCompressionMethod=n,e.compressionMethod=t.compressionMethod=r.getUint16(5,!0)}else e.compressionMethod=n}(p,e,c):e.compressionMethod=c,8==e.compressionMethod&&(e.bitFlag.enhancedDeflating=16!=(16&e.rawBitFlag))}function Et(t,e,n,r,i){const s=new DataView(t.data.buffer);t.version=s.getUint8(0),t.signature=s.getUint32(1,!0);const a=new b;a.append(i[n]);const o=new DataView(new Uint8Array(4).buffer);o.setUint32(0,a.get()),t[e]=(new TextDecoder).decode(t.data.subarray(5)),i.bitFlag.languageEncodingFlag||t.signature!=o.getUint32(0,!1)||(r[e]=t[e])}function Rt(t,e){if(e&&"cp437"!=e.trim().toLowerCase())return new TextDecoder(e).decode(t);{let e="";for(let n=0;n{if(this.pendingData){const e=this.pendingData;this.pendingData=new Uint8Array(e.length+t.length),this.pendingData.set(e,0),this.pendingData.set(t,e.length)}else this.pendingData=new Uint8Array(t)};if(this.codec=new t(Object.assign({},e,n)),typeof this.codec.onData==_t)this.codec.onData=r;else{if(typeof this.codec.on!=_t)throw new Error("Cannot register the callback function");this.codec.on("data",r)}}async append(t){return this.codec.push(t),n(this)}async flush(){return this.codec.push(new Uint8Array(0),!0),n(this)}};function n(t){if(t.pendingData){const e=t.pendingData;return t.pendingData=null,e}return new Uint8Array(0)}}const Ct={chunkSize:524288,maxWorkers:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||2,workerScriptsPath:void 0,useWebWorkers:!0};let Bt=Object.assign({},Ct);t.BlobReader=o,t.BlobWriter=class extends a{constructor(t){super(),this.offset=0,this.contentType=t,this.blob=new Blob([],{type:t})}writeUint8Array(t){super.writeUint8Array(t),this.blob=new Blob([this.blob,t.buffer],{type:this.contentType}),this.offset=this.blob.size}getData(){return this.blob}},t.Data64URIReader=class extends s{constructor(t){super(),this.dataURI=t;let e=t.length;for(;"="==t.charAt(e-1);)e--;this.dataStart=t.indexOf(",")+1,this.size=Math.floor(.75*(e-this.dataStart))}readUint8Array(t,e){const n=new Uint8Array(e),r=4*Math.floor(t/3),i=atob(this.dataURI.substring(r+this.dataStart,4*Math.ceil((t+e)/3)+this.dataStart)),s=t-3*Math.floor(r/4);for(let t=s;t2?this.data+=btoa(n):this.pending=n}getData(){return this.data+btoa(this.pending)}},t.ERR_BAD_FORMAT=at,t.ERR_CENTRAL_DIRECTORY_NOT_FOUND=lt,t.ERR_DUPLICATED_NAME=Dt,t.ERR_ENCRYPTED=pt,t.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND=ht,t.ERR_EOCDR_NOT_FOUND=ot,t.ERR_EOCDR_ZIP64_NOT_FOUND=ct,t.ERR_EXTRAFIELD_ZIP64_NOT_FOUND=ut,t.ERR_HTTP_RANGE=n,t.ERR_INVALID_COMMENT=xt,t.ERR_INVALID_DATE=zt,t.ERR_INVALID_ENTRY_COMMENT=Ft,t.ERR_INVALID_ENTRY_NAME=vt,t.ERR_INVALID_EXTRAFIELD_DATA=Tt,t.ERR_INVALID_EXTRAFIELD_TYPE=It,t.ERR_INVALID_PASSORD=A,t.ERR_INVALID_SIGNATURE=Z,t.ERR_INVALID_VERSION=St,t.ERR_LOCAL_FILE_HEADER_NOT_FOUND=dt,t.ERR_UNSUPPORTED_COMPRESSION=wt,t.ERR_UNSUPPORTED_ENCRYPTION=gt,t.HttpRangeReader=class extends s{constructor(t){super(),this.url=t}init(){return super.init(),new Promise(((t,r)=>{const i=new XMLHttpRequest;i.addEventListener("load",(()=>{i.status<400?(this.size=Number(i.getResponseHeader("Content-Length")),"bytes"==i.getResponseHeader("Accept-Ranges")?t():r(new Error(n))):r(e+(i.statusText||i.status)+".")}),!1),i.addEventListener("error",r,!1),i.open("HEAD",this.url),i.send()}))}readUint8Array(t,n){return new Promise(((r,i)=>{const s=new XMLHttpRequest;s.open("GET",this.url),s.responseType="arraybuffer",s.setRequestHeader("Range","bytes="+t+"-"+(t+n-1)),s.addEventListener("load",(()=>{s.status<400?r(new Uint8Array(s.response)):i(e+(s.statusText||s.status)+".")}),!1),s.addEventListener("error",i,!1),s.send()}))}},t.HttpReader=class extends s{constructor(t){super(),this.url=t}async init(){if(super.init(),function(t){if("undefined"!=typeof document){const e=document.createElement("a");return e.href=t,"http:"==e.protocol||"https:"==e.protocol}return/^https?:\/\//i.test(t)}(this.url))return new Promise(((t,n)=>{const r=new XMLHttpRequest;r.addEventListener("load",(()=>{r.status<400?(this.size=Number(r.getResponseHeader("Content-Length")),this.size?t():h().then((()=>t())).catch(n)):n(e+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",n,!1),r.open("HEAD",this.url),r.send()}));await h()}async readUint8Array(t,e){return this.data||await h(this,this.url),new Uint8Array(this.data.subarray(t,t+e))}},t.Reader=s,t.TextReader=class extends s{constructor(t){super(),this.blobReader=new o(new Blob([t],{type:r}))}init(){super.init(),this.blobReader.init(),this.size=this.blobReader.size}readUint8Array(t,e){return this.blobReader.readUint8Array(t,e)}},t.TextWriter=class extends a{constructor(t){super(),this.encoding=t,this.blob=new Blob([],{type:r})}writeUint8Array(t){super.writeUint8Array(t),this.blob=new Blob([this.blob,t.buffer],{type:r})}getData(){const t=new FileReader;return new Promise(((e,n)=>{t.onload=t=>e(t.target.result),t.onerror=n,t.readAsText(this.blob,this.encoding)}))}},t.Uint8ArrayReader=class extends s{constructor(t){super(),this.array=t,this.size=t.length}readUint8Array(t,e){return this.array.slice(t,t+e)}},t.Uint8ArrayWriter=c,t.Writer=a,t.ZipReader=class extends class{constructor(t,e={},n={}){this.reader=t,this.options=e,this.config=n}async getEntries(t={}){const e=this.reader;e.initialized||await e.init();const n=await async function(t,e,n,r){const i=new Uint8Array(4);if(new DataView(i.buffer).setUint32(0,e),t.size=0;t--)if(s[t]==i[0]&&s[t+1]==i[1]&&s[t+2]==i[2]&&s[t+3]==i[3])return{offset:r,buffer:s.slice(t,t+n).buffer}}}(e,w,22,d);if(!n)throw new Error(ot);const r=new DataView(n.buffer);let i,s=r.getUint32(16,!0),a=r.getUint16(8,!0);if(s==l||a==d){i=!0;const t=await e.readUint8Array(n.offset-20,20),r=new DataView(t.buffer);if(Number(r.getUint32(0,!1))!=y)throw new Error(ct);s=Number(r.getBigUint64(8,!0));const o=await e.readUint8Array(s,56),c=new DataView(o.buffer);if(Number(c.getUint32(0,!1))!=f)throw new Error(ht);a=Number(c.getBigUint64(24,!0)),s-=Number(c.getBigUint64(40,!0))}if(s<0||!i&&(s>=e.size||a>=d))throw new Error(at);const o=await e.readUint8Array(s,e.size-s),c=new DataView(o.buffer),h=[];let u=0;for(let e=0;ed)throw new Error(vt);const i=(new TextEncoder).encode(n.comment||"");if(i.length>d)throw new Error(Ft);const s=this.options.version||n.version||0;if(s>d)throw new Error(St);const a=n.lastModDate||new Date;if(a.getFullYear()<1980)throw new Error(zt);e&&!e.initialized&&await e.init();let o=new Uint8Array(0);const h=n.extraField;if(h){let t=4,e=0;h.forEach((e=>t+=e.length)),o=new Uint8Array(t),h.forEach(((t,n)=>{if(n>d)throw new Error(It);if(t.length>d)throw new Error(Tt);o.set(new Uint16Array([n]),e),o.set(new Uint16Array([t.length]),e+2),o.set(t,e+4),e+=4+t.length}))}let g=n.zip64||this.zip64;(this.offset>=l||e&&(e.size>=l||this.offset+e.size>=l))&&(g=!0),await async function(t,e,n,r){const i=t.files,s=t.writer;let a;i.set(e,null);try{let o,h;try{r.bufferedWrite||t.options.bufferedWrite||t.lockWrite?(o=new c,o.init()):(t.lockWrite=new Promise((t=>a=t)),s.initialized||await s.init(),o=s),h=await async function(t,e,n,r,i,s){const a=s.rawFilename,o=s.lastModDate,c=new Uint8Array(26),h=new DataView(c.buffer),d=void 0===s.password?i.password:s.password,g=d&&d.length&&d,w=void 0===s.level?i.level:s.level,f=0!==w&&!s.directory,y=void 0===d||!d.length,m=s.zip64;let b;if(g){b=new Uint8Array(Lt.length+2);new DataView(b.buffer).setUint16(0,U,!0),b.set(Lt,2)}else b=new Uint8Array(0);const A={version:s.version||20,zip64:m,headerArray:c,directory:s.directory,filename:t,rawFilename:a,comment:s.comment,rawComment:s.rawComment,extraFieldZip64:m?new Uint8Array(28):new Uint8Array(0),extraFieldAES:b,rawExtraField:s.rawExtraField};let E=2056,R=0;f&&(R=8);m&&(A.version=A.version>45?A.version:45);g&&(A.encrypted=!0,A.version=A.version>51?A.version:51,E|=1,R=99,f&&(A.extraFieldAES[9]=8));h.setUint16(0,A.version,!0),h.setUint16(2,E,!0),h.setUint16(4,R,!0),h.setUint16(6,(o.getHours()<<6|o.getMinutes())<<5|o.getSeconds()/2,!0),h.setUint16(8,(o.getFullYear()-1980<<4|o.getMonth()+1)<<5|o.getDate(),!0),h.setUint16(22,a.length,!0),h.setUint16(24,0,!0);const D=new Uint8Array(30+a.length);let x;if(new DataView(D.buffer).setUint32(0,u),D.set(c,4),D.set(a,30),e){const t=await et(r,{codecType:j,level:w,outputPassword:d,outputSigned:y,outputCompressed:f,outputEncrypted:Boolean(d),useWebWorkers:void 0===s.useWebWorkers?i.useWebWorkers:s.useWebWorkers});await n.writeUint8Array(D),x=await it(t,e,n,0,e.size,r,{onprogress:s.onprogress}),A.compressedSize=x.length}else await n.writeUint8Array(D);const F=new Uint8Array(m?24:16),v=new DataView(F.buffer);if(v.setUint32(0,p),e)if(g||void 0===x.signature||(h.setUint32(10,x.signature,!0),v.setUint32(4,x.signature,!0)),m){h.setUint32(14,l,!0),v.setBigUint64(8,BigInt(A.compressedSize),!0),h.setUint32(18,l,!0),v.setBigUint64(16,BigInt(e.size),!0);const t=new DataView(A.extraFieldZip64.buffer);t.setUint16(0,1,!0),t.setUint16(2,24,!0),t.setBigUint64(4,BigInt(e.size),!0),t.setBigUint64(12,BigInt(A.compressedSize),!0)}else h.setUint32(14,A.compressedSize,!0),v.setUint32(8,A.compressedSize,!0),h.setUint32(18,e.size,!0),v.setUint32(12,e.size,!0);return await n.writeUint8Array(F),A.length=D.length+(x?x.length:0)+F.length,A}(e,n,o,t.config,t.options,r)}catch(t){throw i.delete(e),t}if(i.set(e,h),o!=s&&(t.lockWrite&&await t.lockWrite,await s.writeUint8Array(o.getData())),h.offset=t.offset,h.zip64){new DataView(h.extraFieldZip64.buffer).setBigUint64(20,BigInt(h.offset),!0)}t.offset+=h.length}finally{a&&(t.lockWrite=null,a())}}(this,t,e,Object.assign({},n,{rawFilename:r,rawComment:i,version:s,lastModDate:a,rawExtraField:o,zip64:g}))}async close(t=new Uint8Array(0)){const e=this.writer,n=this.files;let r=0,i=0,s=this.offset,a=n.size;if(t.length){if(!(t.length<=d))throw new Error(xt);c.setUint16(r+20,t.length,!0)}for(const[,t]of n)i+=46+t.rawFilename.length+t.rawComment.length+t.extraFieldZip64.length+t.extraFieldAES.length+t.rawExtraField.length;(s+i>=l||a>=d)&&(this.zip64=!0);const o=new Uint8Array(i+(this.zip64?98:22)),c=new DataView(o.buffer);for(const[,t]of n){const e=t.rawFilename,n=t.extraFieldZip64,i=t.extraFieldAES,s=n.length+i.length+t.rawExtraField.length;c.setUint32(r,g),c.setUint16(r+4,t.version,!0),o.set(t.headerArray,r+6),c.setUint16(r+30,s,!0),c.setUint16(r+32,t.rawComment.length,!0),t.directory&&c.setUint8(r+38,16),t.zip64?c.setUint32(r+42,l,!0):c.setUint32(r+42,t.offset,!0),o.set(e,r+46),o.set(n,r+46+e.length),o.set(i,r+46+e.length+n.length),o.set(t.rawExtraField,46+e.length+n.length+i.length),o.set(t.rawComment,r+46+e.length+s),r+=46+e.length+s+t.rawComment.length}return this.zip64&&(c.setUint32(r,f),c.setBigUint64(r+4,BigInt(44),!0),c.setUint16(r+12,45,!0),c.setUint16(r+14,45,!0),c.setBigUint64(r+24,BigInt(a),!0),c.setBigUint64(r+32,BigInt(a),!0),c.setBigUint64(r+40,BigInt(i),!0),c.setBigUint64(r+48,BigInt(s),!0),c.setUint32(r+56,y),c.setBigUint64(r+64,BigInt(s+i),!0),c.setUint32(r+72,1,!0),a=d,s=l,r+=76),c.setUint32(r,w),c.setUint16(r+8,a,!0),c.setUint16(r+10,a,!0),c.setUint32(r+12,i,!0),c.setUint32(r+16,s,!0),await e.writeUint8Array(o),await e.writeUint8Array(t),e.getData()}}{constructor(t,e){super(t,e,Bt)}},t.configure=function(t){if(Bt=Object.assign({},Bt,t),null!=Bt.workerScripts&&null!=Bt.workerScriptsPath)throw new Error("Either workerScripts or workerScriptsPath may be set, not both");if(Bt.workerScripts){if(Bt.workerScripts.deflate&&!Array.isArray(Bt.workerScripts.deflate))throw new Error("workerScripts.deflate must be an array");if(Bt.workerScripts.inflate&&!Array.isArray(Bt.workerScripts.inflate))throw new Error("workerScripts.inflate must be an array")}},t.getMimeType=function(){return"application/octet-stream"},t.initShimAsyncCodec=(t,e={})=>({ZipDeflate:kt(t.Deflate,e.deflate),ZipInflate:kt(t.Inflate,e.inflate)}),Object.defineProperty(t,"__esModule",{value:!0})})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).zip={})}(this,(function(t){"use strict";const e=256,n=256,i=-2,r=-5,a=[0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,0,0,16,17,18,18,19,19,20,20,20,20,21,21,21,21,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29];function s(){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.build_tree=function(n){const i=t.dyn_tree,r=t.stat_desc.static_tree,a=t.stat_desc.elems;let s,o,l,d=-1;for(n.heap_len=0,n.heap_max=573,s=0;s=1;s--)n.pqdownheap(i,s);l=a;do{s=n.heap[1],n.heap[1]=n.heap[n.heap_len--],n.pqdownheap(i,1),o=n.heap[1],n.heap[--n.heap_max]=s,n.heap[--n.heap_max]=o,i[2*l]=i[2*s]+i[2*o],n.depth[l]=Math.max(n.depth[s],n.depth[o])+1,i[2*s+1]=i[2*o+1]=l,n.heap[1]=l++,n.pqdownheap(i,1)}while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],function(e){const n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.extra_bits,a=t.stat_desc.extra_base,s=t.stat_desc.max_length;let o,l,d,c,u,f,_=0;for(c=0;c<=15;c++)e.bl_count[c]=0;for(n[2*e.heap[e.heap_max]+1]=0,o=e.heap_max+1;o<573;o++)l=e.heap[o],c=n[2*n[2*l+1]+1]+1,c>s&&(c=s,_++),n[2*l+1]=c,l>t.max_code||(e.bl_count[c]++,u=0,l>=a&&(u=r[l-a]),f=n[2*l],e.opt_len+=f*(c+u),i&&(e.static_len+=f*(i[2*l+1]+u)));if(0!==_){do{for(c=s-1;0===e.bl_count[c];)c--;e.bl_count[c]--,e.bl_count[c+1]+=2,e.bl_count[s]--,_-=2}while(_>0);for(c=s;0!==c;c--)for(l=e.bl_count[c];0!==l;)d=e.heap[--o],d>t.max_code||(n[2*d+1]!=c&&(e.opt_len+=(c-n[2*d+1])*n[2*d],n[2*d+1]=c),l--)}}(n),function(t,n,i){const r=[];let a,s,o,l=0;for(a=1;a<=15;a++)r[a]=l=l+i[a-1]<<1;for(s=0;s<=n;s++)o=t[2*s+1],0!==o&&(t[2*s]=e(r[o]++,o))}(i,t.max_code,n.bl_count)}}function o(t,e,n,i,r){const a=this;a.static_tree=t,a.extra_bits=e,a.extra_base=n,a.elems=i,a.max_length=r}s._length_code=[0,1,2,3,4,5,6,7,8,8,9,9,10,10,11,11,12,12,12,12,13,13,13,13,14,14,14,14,15,15,15,15,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28],s.base_length=[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],s.base_dist=[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],s.d_code=function(t){return t<256?a[t]:a[256+(t>>>7)]},s.extra_lbits=[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],s.extra_dbits=[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],s.extra_blbits=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],s.bl_order=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],o.static_ltree=[12,8,140,8,76,8,204,8,44,8,172,8,108,8,236,8,28,8,156,8,92,8,220,8,60,8,188,8,124,8,252,8,2,8,130,8,66,8,194,8,34,8,162,8,98,8,226,8,18,8,146,8,82,8,210,8,50,8,178,8,114,8,242,8,10,8,138,8,74,8,202,8,42,8,170,8,106,8,234,8,26,8,154,8,90,8,218,8,58,8,186,8,122,8,250,8,6,8,134,8,70,8,198,8,38,8,166,8,102,8,230,8,22,8,150,8,86,8,214,8,54,8,182,8,118,8,246,8,14,8,142,8,78,8,206,8,46,8,174,8,110,8,238,8,30,8,158,8,94,8,222,8,62,8,190,8,126,8,254,8,1,8,129,8,65,8,193,8,33,8,161,8,97,8,225,8,17,8,145,8,81,8,209,8,49,8,177,8,113,8,241,8,9,8,137,8,73,8,201,8,41,8,169,8,105,8,233,8,25,8,153,8,89,8,217,8,57,8,185,8,121,8,249,8,5,8,133,8,69,8,197,8,37,8,165,8,101,8,229,8,21,8,149,8,85,8,213,8,53,8,181,8,117,8,245,8,13,8,141,8,77,8,205,8,45,8,173,8,109,8,237,8,29,8,157,8,93,8,221,8,61,8,189,8,125,8,253,8,19,9,275,9,147,9,403,9,83,9,339,9,211,9,467,9,51,9,307,9,179,9,435,9,115,9,371,9,243,9,499,9,11,9,267,9,139,9,395,9,75,9,331,9,203,9,459,9,43,9,299,9,171,9,427,9,107,9,363,9,235,9,491,9,27,9,283,9,155,9,411,9,91,9,347,9,219,9,475,9,59,9,315,9,187,9,443,9,123,9,379,9,251,9,507,9,7,9,263,9,135,9,391,9,71,9,327,9,199,9,455,9,39,9,295,9,167,9,423,9,103,9,359,9,231,9,487,9,23,9,279,9,151,9,407,9,87,9,343,9,215,9,471,9,55,9,311,9,183,9,439,9,119,9,375,9,247,9,503,9,15,9,271,9,143,9,399,9,79,9,335,9,207,9,463,9,47,9,303,9,175,9,431,9,111,9,367,9,239,9,495,9,31,9,287,9,159,9,415,9,95,9,351,9,223,9,479,9,63,9,319,9,191,9,447,9,127,9,383,9,255,9,511,9,0,7,64,7,32,7,96,7,16,7,80,7,48,7,112,7,8,7,72,7,40,7,104,7,24,7,88,7,56,7,120,7,4,7,68,7,36,7,100,7,20,7,84,7,52,7,116,7,3,8,131,8,67,8,195,8,35,8,163,8,99,8,227,8],o.static_dtree=[0,5,16,5,8,5,24,5,4,5,20,5,12,5,28,5,2,5,18,5,10,5,26,5,6,5,22,5,14,5,30,5,1,5,17,5,9,5,25,5,5,5,21,5,13,5,29,5,3,5,19,5,11,5,27,5,7,5,23,5],o.static_l_desc=new o(o.static_ltree,s.extra_lbits,257,286,15),o.static_d_desc=new o(o.static_dtree,s.extra_dbits,0,30,15),o.static_bl_desc=new o(null,s.extra_blbits,0,19,7);function l(t,e,n,i,r){const a=this;a.good_length=t,a.max_lazy=e,a.nice_length=n,a.max_chain=i,a.func=r}const d=[new l(0,0,0,0,0),new l(4,4,8,4,1),new l(4,5,16,8,1),new l(4,6,32,32,1),new l(4,4,16,16,2),new l(8,16,32,32,2),new l(8,16,128,128,2),new l(8,32,128,256,2),new l(32,128,258,1024,2),new l(32,258,258,4096,2)],c=["need dictionary","stream end","","","stream error","data error","","buffer error","",""],u=113,f=666,_=258,h=262;function w(t,e,n,i){const r=t[2*e],a=t[2*n];return r>>8&255)}function lt(t,e){let n;const i=e;it>16-i?(n=t,nt|=n<>>16-it,it+=i-16):(nt|=t<=8&&(st(255&nt),nt>>>=8,it-=8)}function ft(n,i){let r,a,o;if(t.pending_buf[$+2*Q]=n>>>8&255,t.pending_buf[$+2*Q+1]=255&n,t.pending_buf[G+Q]=255&i,Q++,0===n?H[2*i]++:(tt++,n--,H[2*(s._length_code[i]+e+1)]++,Z[2*s.d_code(n)]++),0==(8191&Q)&&P>2){for(r=8*Q,a=C-I,o=0;o<30;o++)r+=Z[2*o]*(5+s.extra_dbits[o]);if(r>>>=3,tt8?ot(nt):it>0&&st(255&nt),nt=0,it=0}function wt(e,n,i){lt(0+(i?1:0),3),function(e,n,i){ht(),et=8,i&&(ot(n),ot(~n)),t.pending_buf.set(m.subarray(e,e+n),t.pending),t.pending+=n}(e,n,!0)}function pt(e,n,i){let r,a,l=0;P>0?(K.build_tree(t),Y.build_tree(t),l=function(){let e;for(at(H,K.max_code),at(Z,Y.max_code),X.build_tree(t),e=18;e>=3&&0===q[2*s.bl_order[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(),r=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=r&&(r=a)):r=a=n+5,n+4<=r&&-1!=e?wt(e,n,i):a==r?(lt(2+(i?1:0),3),_t(o.static_ltree,o.static_dtree)):(lt(4+(i?1:0),3),function(t,e,n){let i;for(lt(t-257,5),lt(e-1,5),lt(n-4,4),i=0;i=0?I:-1,C-I,t),I=C,a.flush_pending()}function gt(){let t,e,n,i;do{if(i=v-M-C,0===i&&0===C&&0===M)i=g;else if(-1==i)i--;else if(C>=g+g-h){m.set(m.subarray(g,g+g),0),z-=g,C-=g,I-=g,t=U,n=t;do{e=65535&A[--n],A[n]=e>=g?e-g:0}while(0!=--t);t=g,n=t;do{e=65535&E[--n],E[n]=e>=g?e-g:0}while(0!=--t);i+=g}if(0===a.avail_in)return;t=a.read_buf(m,C+M,i),M+=t,M>=3&&(k=255&m[C],k=(k<g-h?C-(g-h):0;let o=j;const l=x,d=C+_;let c=m[r+a-1],u=m[r+a];N>=B&&(i>>=2),o>M&&(o=M);do{if(e=t,m[e+a]==u&&m[e+a-1]==c&&m[e]==m[r]&&m[++e]==m[r+1]){r+=2,e++;do{}while(m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&m[++r]==m[++e]&&ra){if(z=t,a=n,n>=o)break;c=m[r+a-1],u=m[r+a]}}}while((t=65535&E[t&l])>s&&0!=--i);return a<=M?a:M}function xt(e){return e.total_in=e.total_out=0,e.msg=null,t.pending=0,t.pending_out=0,l=u,b=0,K.dyn_tree=H,K.stat_desc=o.static_l_desc,Y.dyn_tree=Z,Y.stat_desc=o.static_d_desc,X.dyn_tree=q,X.stat_desc=o.static_bl_desc,nt=0,it=0,et=8,rt(),function(){v=2*g,A[U-1]=0;for(let t=0;t9||8!=a||r<9||r>15||n<0||n>9||o<0||o>2?i:(e.dstate=t,y=r,g=1<9||n<0||n>2?i:(d[P].func!=d[e].func&&0!==t.total_in&&(r=t.deflate(1)),P!=e&&(P=e,W=d[P].max_lazy,B=d[P].good_length,j=d[P].nice_length,O=d[P].max_chain),V=n,r)},t.deflateSetDictionary=function(t,e,n){let r,a=n,s=0;if(!e||42!=l)return i;if(a<3)return 0;for(a>g-h&&(a=g-h,s=n-a),m.set(e.subarray(s,s+a),0),C=a,I=a,k=255&m[0],k=(k<4||s<0)return i;if(!e.next_out||!e.next_in&&0!==e.avail_in||l==f&&4!=s)return e.msg=c[4],i;if(0===e.avail_out)return e.msg=c[7],r;var B;if(a=e,R=b,b=s,42==l&&(w=8+(y-8<<4)<<8,v=(P-1&255)>>1,v>3&&(v=3),w|=v<<6,0!==C&&(w|=32),w+=31-w%31,l=u,st((B=w)>>8&255),st(255&B)),0!==t.pending){if(a.flush_pending(),0===a.avail_out)return b=-1,0}else if(0===a.avail_in&&s<=R&&4!=s)return a.msg=c[7],r;if(l==f&&0!==a.avail_in)return e.msg=c[7],r;if(0!==a.avail_in||0!==M||0!=s&&l!=f){switch(O=-1,d[P].func){case 0:O=function(t){let e,n=65535;for(n>p-5&&(n=p-5);;){if(M<=1){if(gt(),0===M&&0==t)return 0;if(0===M)break}if(C+=M,M=0,e=I+n,(0===C||C>=e)&&(M=C-e,C=e,bt(!1),0===a.avail_out))return 0;if(C-I>=g-h&&(bt(!1),0===a.avail_out))return 0}return bt(4==t),0===a.avail_out?4==t?2:0:4==t?3:1}(s);break;case 1:O=function(t){let e,n=0;for(;;){if(M=3&&(k=(k<=3)if(e=ft(C-z,S-3),M-=S,S<=W&&M>=3){S--;do{C++,k=(k<=3&&(k=(k<4096)&&(S=2)),N>=3&&S<=N){n=C+M-3,e=ft(C-1-T,N-3),M-=N-1,N-=2;do{++C<=n&&(k=(k<n&&(r=n),0===r?0:(i.avail_in-=r,t.set(i.next_in.subarray(i.next_in_index,i.next_in_index+r),e),i.next_in_index+=r,i.total_in+=r,r)},flush_pending:function(){const t=this;let e=t.dstate.pending;e>t.avail_out&&(e=t.avail_out),0!==e&&(t.next_out.set(t.dstate.pending_buf.subarray(t.dstate.pending_out,t.dstate.pending_out+e),t.next_out_index),t.next_out_index+=e,t.dstate.pending_out+=e,t.total_out+=e,t.avail_out-=e,t.dstate.pending-=e,0===t.dstate.pending&&(t.dstate.pending_out=0))}};const g=-2,y=-3,x=-5,m=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535],v=[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],E=[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],k=[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],U=[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],R=[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],D=15;function F(){let t,e,n,i,r,a;function s(t,e,s,o,l,d,c,u,f,_,h){let w,p,b,g,m,v,E,A,k,U,R,F,I,S,T;U=0,m=s;do{n[t[e+U]]++,U++,m--}while(0!==m);if(n[0]==s)return c[0]=-1,u[0]=0,0;for(A=u[0],v=1;v<=D&&0===n[v];v++);for(E=v,Am&&(A=m),u[0]=A,S=1<F+A;){if(g++,F+=A,T=b-F,T=T>A?A:T,(p=1<<(v=E-F))>w+1&&(p-=w+1,I=E,v1440)return y;r[g]=R=_[0],_[0]+=T,0!==g?(a[g]=m,i[0]=v,i[1]=A,v=m>>>F-A,i[2]=R-r[g-1]-v,f.set(i,3*(r[g-1]+v))):c[0]=R}for(i[1]=E-F,U>=s?i[0]=192:h[U]>>F;v>>=1)m^=v;for(m^=v,k=(1<257?(_==y?f.msg="oversubscribed distance tree":_==x?(f.msg="incomplete distance tree",_=y):-4!=_&&(f.msg="empty distance tree with lengths",_=y),_):0)}}F.inflate_trees_fixed=function(t,e,n,i){return t[0]=9,e[0]=5,n[0]=v,i[0]=E,0};function I(){const t=this;let e,n,i,r,a=0,s=0,o=0,l=0,d=0,c=0,u=0,f=0,_=0,h=0;function w(t,e,n,i,r,a,s,o){let l,d,c,u,f,_,h,w,p,b,g,x,v,E,A,k;h=o.next_in_index,w=o.avail_in,f=s.bitb,_=s.bitk,p=s.write,b=p>=d[k+1],_-=d[k+1],0!=(16&u)){for(u&=15,v=d[k+2]+(f&m[u]),f>>=u,_-=u;_<15;)w--,f|=(255&o.read_byte(h++))<<_,_+=8;for(l=f&x,d=r,c=a,k=3*(c+l),u=d[k];;){if(f>>=d[k+1],_-=d[k+1],0!=(16&u)){for(u&=15;_>=u,_-=u,b-=v,p>=E)A=p-E,p-A>0&&2>p-A?(s.window[p++]=s.window[A++],s.window[p++]=s.window[A++],v-=2):(s.window.set(s.window.subarray(A,A+2),p),p+=2,A+=2,v-=2);else{A=p-E;do{A+=s.end}while(A<0);if(u=s.end-A,v>u){if(v-=u,p-A>0&&u>p-A)do{s.window[p++]=s.window[A++]}while(0!=--u);else s.window.set(s.window.subarray(A,A+u),p),p+=u,A+=u,u=0;A=0}}if(p-A>0&&v>p-A)do{s.window[p++]=s.window[A++]}while(0!=--v);else s.window.set(s.window.subarray(A,A+v),p),p+=v,A+=v,v=0;break}if(0!=(64&u))return o.msg="invalid distance code",v=o.avail_in-w,v=_>>3>3:v,w+=v,h-=v,_-=v<<3,s.bitb=f,s.bitk=_,o.avail_in=w,o.total_in+=h-o.next_in_index,o.next_in_index=h,s.write=p,y;l+=d[k+2],l+=f&m[u],k=3*(c+l),u=d[k]}break}if(0!=(64&u))return 0!=(32&u)?(v=o.avail_in-w,v=_>>3>3:v,w+=v,h-=v,_-=v<<3,s.bitb=f,s.bitk=_,o.avail_in=w,o.total_in+=h-o.next_in_index,o.next_in_index=h,s.write=p,1):(o.msg="invalid literal/length code",v=o.avail_in-w,v=_>>3>3:v,w+=v,h-=v,_-=v<<3,s.bitb=f,s.bitk=_,o.avail_in=w,o.total_in+=h-o.next_in_index,o.next_in_index=h,s.write=p,y);if(l+=d[k+2],l+=f&m[u],k=3*(c+l),0===(u=d[k])){f>>=d[k+1],_-=d[k+1],s.window[p++]=d[k+2],b--;break}}else f>>=d[k+1],_-=d[k+1],s.window[p++]=d[k+2],b--}while(b>=258&&w>=10);return v=o.avail_in-w,v=_>>3>3:v,w+=v,h-=v,_-=v<<3,s.bitb=f,s.bitk=_,o.avail_in=w,o.total_in+=h-o.next_in_index,o.next_in_index=h,s.write=p,0}t.init=function(t,a,s,o,l,d){e=0,u=t,f=a,i=s,_=o,r=l,h=d,n=null},t.proc=function(t,p,b){let x,v,E,A,k,U,R,D=0,F=0,I=0;for(I=p.next_in_index,A=p.avail_in,D=t.bitb,F=t.bitk,k=t.write,U=k=258&&A>=10&&(t.bitb=D,t.bitk=F,p.avail_in=A,p.total_in+=I-p.next_in_index,p.next_in_index=I,t.write=k,b=w(u,f,i,_,r,h,t,p),I=p.next_in_index,A=p.avail_in,D=t.bitb,F=t.bitk,k=t.write,U=k>>=n[v+1],F-=n[v+1],E=n[v],0===E){l=n[v+2],e=6;break}if(0!=(16&E)){d=15&E,a=n[v+2],e=2;break}if(0==(64&E)){o=E,s=v/3+n[v+2];break}if(0!=(32&E)){e=7;break}return e=9,p.msg="invalid literal/length code",b=y,t.bitb=D,t.bitk=F,p.avail_in=A,p.total_in+=I-p.next_in_index,p.next_in_index=I,t.write=k,t.inflate_flush(p,b);case 2:for(x=d;F>=x,F-=x,o=f,n=r,s=h,e=3;case 3:for(x=o;F>=n[v+1],F-=n[v+1],E=n[v],0!=(16&E)){d=15&E,c=n[v+2],e=4;break}if(0==(64&E)){o=E,s=v/3+n[v+2];break}return e=9,p.msg="invalid distance code",b=y,t.bitb=D,t.bitk=F,p.avail_in=A,p.total_in+=I-p.next_in_index,p.next_in_index=I,t.write=k,t.inflate_flush(p,b);case 4:for(x=d;F>=x,F-=x,e=5;case 5:for(R=k-c;R<0;)R+=t.end;for(;0!==a;){if(0===U&&(k==t.end&&0!==t.read&&(k=0,U=k7&&(F-=8,A++,I--),t.write=k,b=t.inflate_flush(p,b),k=t.write,U=kt.avail_out&&(i=t.avail_out),0!==i&&e==x&&(e=0),t.avail_out-=i,t.total_out+=i,t.next_out.set(n.window.subarray(a,a+i),r),r+=i,a+=i,a==n.end&&(a=0,n.write==n.end&&(n.write=0),i=n.write-a,i>t.avail_out&&(i=t.avail_out),0!==i&&e==x&&(e=0),t.avail_out-=i,t.total_out+=i,t.next_out.set(n.window.subarray(a,a+i),r),r+=i,a+=i),t.next_out_index=r,n.read=a,e},n.proc=function(t,e){let h,w,p,b,x,v,E,A;for(b=t.next_in_index,x=t.avail_in,w=n.bitb,p=n.bitk,v=n.write,E=v>>1){case 0:w>>>=3,p-=3,h=7&p,w>>>=h,p-=h,r=1;break;case 1:k=[],U=[],R=[[]],D=[[]],F.inflate_trees_fixed(k,U,R,D),c.init(k[0],U[0],R[0],0,D[0],0),w>>>=3,p-=3,r=6;break;case 2:w>>>=3,p-=3,r=3;break;case 3:return w>>>=3,p-=3,r=9,t.msg="invalid block type",e=y,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e)}break;case 1:for(;p<32;){if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);e=0,x--,w|=(255&t.read_byte(b++))<>>16&65535)!=(65535&w))return r=9,t.msg="invalid stored block lengths",e=y,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);a=65535&w,w=p=0,r=0!==a?2:0!==u?7:0;break;case 2:if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);if(0===E&&(v==n.end&&0!==n.read&&(v=0,E=vx&&(h=x),h>E&&(h=E),n.window.set(t.read_buf(b,h),v),b+=h,x-=h,v+=h,E-=h,0!=(a-=h))break;r=0!==u?7:0;break;case 3:for(;p<14;){if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);e=0,x--,w|=(255&t.read_byte(b++))<29||(h>>5&31)>29)return r=9,t.msg="too many length or distance symbols",e=y,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);if(h=258+(31&h)+(h>>5&31),!i||i.length>>=14,p-=14,o=0,r=4;case 4:for(;o<4+(s>>>10);){for(;p<3;){if(0===x)return n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);e=0,x--,w|=(255&t.read_byte(b++))<>>=3,p-=3}for(;o<19;)i[S[o++]]=0;if(l[0]=7,h=_.inflate_trees_bits(i,l,d,f,t),0!=h)return(e=h)==y&&(i=null,r=9),n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);o=0,r=5;case 5:for(;h=s,!(o>=258+(31&h)+(h>>5&31));){let a,c;for(h=l[0];p>>=h,p-=h,i[o++]=c;else{for(A=18==c?7:c-14,a=18==c?11:3;p>>=h,p-=h,a+=w&m[A],w>>>=A,p-=A,A=o,h=s,A+a>258+(31&h)+(h>>5&31)||16==c&&A<1)return i=null,r=9,t.msg="invalid bit length repeat",e=y,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);c=16==c?i[A-1]:0;do{i[A++]=c}while(0!=--a);o=A}}if(d[0]=-1,I=[],T=[],L=[],C=[],I[0]=9,T[0]=6,h=s,h=_.inflate_trees_dynamic(257+(31&h),1+(h>>5&31),i,I,T,L,C,f,t),0!=h)return h==y&&(i=null,r=9),e=h,n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,n.inflate_flush(t,e);c.init(I[0],T[0],f,L[0],f,C[0]),r=6;case 6:if(n.bitb=w,n.bitk=p,t.avail_in=x,t.total_in+=b-t.next_in_index,t.next_in_index=b,n.write=v,1!=(e=c.proc(n,t,e)))return n.inflate_flush(t,e);if(e=0,c.free(t),b=t.next_in_index,x=t.avail_in,w=n.bitb,p=n.bitk,v=n.write,E=v15?(t.inflateEnd(n),g):(t.wbits=i,n.istate.blocks=new T(n,1<>4)>r.wbits){r.mode=L,t.msg="invalid window size",r.marker=5;break}r.mode=1;case 1:if(0===t.avail_in)return n;if(n=e,t.avail_in--,t.total_in++,i=255&t.read_byte(t.next_in_index++),((r.method<<8)+i)%31!=0){r.mode=L,t.msg="incorrect header check",r.marker=5;break}if(0==(32&i)){r.mode=7;break}r.mode=2;case 2:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,r.need=(255&t.read_byte(t.next_in_index++))<<24&4278190080,r.mode=3;case 3:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,r.need+=(255&t.read_byte(t.next_in_index++))<<16&16711680,r.mode=4;case 4:if(0===t.avail_in)return n;n=e,t.avail_in--,t.total_in++,r.need+=(255&t.read_byte(t.next_in_index++))<<8&65280,r.mode=5;case 5:return 0===t.avail_in?n:(n=e,t.avail_in--,t.total_in++,r.need+=255&t.read_byte(t.next_in_index++),r.mode=6,2);case 6:return r.mode=L,t.msg="need dictionary",r.marker=0,g;case 7:if(n=r.blocks.proc(t,n),n==y){r.mode=L,r.marker=0;break}if(0==n&&(n=e),1!=n)return n;n=e,r.blocks.reset(t,r.was),r.mode=12;case 12:return 1;case L:return y;default:return g}},t.inflateSetDictionary=function(t,e,n){let i=0,r=n;if(!t||!t.istate||6!=t.istate.mode)return g;const a=t.istate;return r>=1<{n.onload=t=>i(new Uint8Array(t.target.result)),n.onerror=r,n.readAsArrayBuffer(this.blob.slice(t,t+e))}))}}class H extends B{constructor(){super(),this.array=new Uint8Array(0)}writeUint8Array(t){super.writeUint8Array(t);const e=this.array;this.array=new Uint8Array(e.length+t.length),this.array.set(e),this.array.set(t,e.length)}getData(){return this.array}}function Z(t,e){return new Promise(((n,i)=>{const r=new XMLHttpRequest;r.addEventListener("load",(()=>{r.status<400?(t.size||(t.size=Number(r.getResponseHeader("Content-Length"))||Number(r.response.byteLength)),t.data=new Uint8Array(r.response),n()):i(N+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",i,!1),r.open("GET",e),r.responseType="arraybuffer",r.send()}))}const q=4294967295,K=65535,Y=67324752,X=134695760,G=33639248,J=101010256,Q=101075792,$=117853008,tt=39169,et=2048;class nt{constructor(){this.crc=-1,this.table=(()=>{const t=[];for(let e=0;e<256;e++){let n=e;for(let t=0;t<8;t++)1&n?n=n>>>1^3988292384:n>>>=1;t[e]=n}return t})()}append(t){const e=this.table;let n=0|this.crc;for(let i=0,r=0|t.length;i>>8^e[255&(n^t[i])];this.crc=n}get(){return~this.crc}}const it="Invalid pasword",rt=16,at="raw",st={name:"PBKDF2"},ot={name:"HMAC"},lt="SHA-1",dt={name:"AES-CTR"},ct=Object.assign({hash:ot},st),ut=Object.assign({iterations:1e3,hash:{name:lt}},st),ft=Object.assign({hash:lt},ot),_t=Object.assign({length:rt},dt),ht=["deriveBits"],wt=["sign"],pt=528,bt=10,gt=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],yt=crypto.subtle;class xt{constructor(t,e){this.password=t,this.signed=e,this.input=e&&new Uint8Array(0),this.pendingInput=new Uint8Array(0)}async append(t){const e=async(r=0)=>{if(r+rt<=i.length-bt){const t=i.subarray(r,r+rt),a=await yt.decrypt(Object.assign({counter:this.counter},_t),this.keys.decrypt,t);return vt(this.counter),n.set(new Uint8Array(a),r),e(r+rt)}return this.pendingInput=i.subarray(r),this.signed&&(this.input=Et(this.input,t)),n};if(this.password){const e=t.subarray(0,18);await async function(t,e,n){t.counter=new Uint8Array(gt);const i=e.subarray(0,16),r=e.subarray(16),a=(new TextEncoder).encode(n),s=await yt.importKey(at,a,ct,!1,ht),o=await yt.deriveBits(Object.assign({salt:i},ut),s,528),l=new Uint8Array(o),d=l.subarray(64);if(t.keys={decrypt:await yt.importKey(at,l.subarray(0,32),dt,!0,["decrypt"]),authentication:await yt.importKey(at,l.subarray(32,64),ft,!1,wt),passwordVerification:d},d[0]!=r[0]||d[1]!=r[1])throw new Error(it)}(this,e,this.password),this.password=null,t=t.subarray(18)}let n=new Uint8Array(t.length-bt-(t.length-bt)%rt),i=t;return this.pendingInput.length&&(i=Et(this.pendingInput,t),n=At(n,i.length-bt-(i.length-bt)%rt)),e()}async flush(){const t=this.pendingInput,e=this.keys,n=t.subarray(0,t.length-bt),i=t.subarray(t.length-bt);let r=new Uint8Array(0);if(n.length){const t=await yt.decrypt(Object.assign({counter:this.counter},_t),e.decrypt,n);r=new Uint8Array(t)}let a=!0;if(this.signed){const t=await yt.sign(ot,e.authentication,this.input.subarray(0,this.input.length-bt)),n=new Uint8Array(t);this.input=null;for(let t=0;t{if(r+rt<=t.length){const a=t.subarray(r,r+rt),s=await yt.encrypt(Object.assign({counter:this.counter},_t),this.keys.encrypt,a);return vt(this.counter),i.set(new Uint8Array(s),r+n.length),e(r+rt)}return this.pendingInput=t.subarray(r),this.output=Et(this.output,i),i};let n=new Uint8Array(0);this.password&&(n=await async function(t,e){t.counter=new Uint8Array(gt);const n=crypto.getRandomValues(new Uint8Array(16)),i=(new TextEncoder).encode(e),r=await yt.importKey(at,i,ct,!1,ht),a=await yt.deriveBits(Object.assign({salt:n},ut),r,pt),s=new Uint8Array(a);return t.keys={encrypt:await yt.importKey(at,s.subarray(0,32),dt,!0,["encrypt"]),authentication:await yt.importKey(at,s.subarray(32,64),ft,!1,wt),passwordVerification:s.subarray(64)},Et(n,t.keys.passwordVerification)}(this,this.password),this.password=null);let i=new Uint8Array(n.length+t.length-t.length%rt);return i.set(n,0),this.pendingInput.length&&(t=Et(this.pendingInput,t),i=At(i,t.length-t.length%rt)),e()}async flush(){let t=new Uint8Array(0);if(this.pendingInput.length){const e=await yt.encrypt(Object.assign({counter:this.counter},_t),this.keys.encrypt,this.pendingInput);t=new Uint8Array(e),this.output=Et(this.output,t)}const e=await yt.sign(ot,this.keys.authentication,this.output.subarray(18));this.output=null;const n=new Uint8Array(e).subarray(0,bt);return{data:Et(t,n),signature:n}}}function vt(t){for(let e=0;e<16;e++){if(255!=t[e]){t[e]++;break}t[e]=0}}function Et(t,e){let n=t;return t.length+e.length&&(n=new Uint8Array(t.length+e.length),n.set(t,0),n.set(e,t.length)),n}function At(t,e){if(e&&e>t.length){const n=t;(t=new Uint8Array(e)).set(n,0)}return t}const kt="deflate",Ut="inflate",Rt="Invalid signature";class Dt{constructor(t){this.signature=t.inputSignature,this.encrypted=Boolean(t.inputPassword),this.signed=t.inputSigned,this.compressed=t.inputCompressed,this.inflate=this.compressed&&new t.codecConstructor,this.crc32=this.signed&&this.signed&&new nt,this.decrypt=this.encrypted&&new xt(t.inputPassword)}async append(t){return this.encrypted&&(t=await this.decrypt.append(t)),this.compressed&&t.length&&(t=await this.inflate.append(t)),!this.encrypted&&this.signed&&this.crc32.append(t),t}async flush(){let t,e=new Uint8Array(0);if(this.encrypted){const t=await this.decrypt.flush();if(!t.valid)throw new Error(Rt);e=t.data}else if(this.signed){const e=new DataView(new Uint8Array(4).buffer);if(t=this.crc32.get(),e.setUint32(0,t),this.signature!=e.getUint32(0,!1))throw new Error(Rt)}return this.compressed&&(e=await this.inflate.append(e)||new Uint8Array(0),await this.inflate.flush()),{data:e,signature:t}}}class Ft{constructor(t){this.encrypted=t.outputEncrypted,this.signed=t.outputSigned,this.compressed=t.outputCompressed,this.deflate=this.compressed&&new t.codecConstructor({level:t.level||5}),this.crc32=this.signed&&new nt,this.encrypt=this.encrypted&&new mt(t.outputPassword)}async append(t){let e=t;return this.compressed&&t.length&&(e=await this.deflate.append(t)),this.encrypted?e=await this.encrypt.append(e):this.signed&&this.crc32.append(t),e}async flush(){let t,e=new Uint8Array(0);if(this.compressed&&(e=await this.deflate.flush()||new Uint8Array(0)),this.encrypted){e=await this.encrypt.append(e);const n=await this.encrypt.flush();t=n.signature;const i=new Uint8Array(e.length+n.data.length);i.set(e,0),i.set(n.data,e.length),e=i}else this.signed&&(t=this.crc32.get());return{data:e,signature:t}}}const It="init",St="append",Tt="flush",Lt="message",Ct="z-worker.js",zt={deflate:[Ct],inflate:[Ct]},Mt={pool:[],pendingRequests:[]};function Nt(t,e){const n=Mt.pool,i=!(e.inputCompressed||e.inputSigned||e.inputEncrypted||e.outputCompressed||e.outputSigned||e.outputEncrypted);let r;if(e.useWebWorkers||void 0===e.useWebWorkers&&t.useWebWorkers&&!i){const n=e.codecType;t.workerScripts?(a=t.workerScripts[n],r="undefined"!=typeof document?a.map((t=>new URL(t,document.baseURI).href)):a):(r=zt[n].slice(0),r[0]=(t.workerScriptsPath||"")+r[0])}var a;if(n.length!t.busy));return t?Ot(t,e,r):new Promise((t=>Mt.pendingRequests.push({resolve:t,options:e,scripts:r})))}}function Ot(t,e,n){return t.busy=!0,t.options=e,t.scripts=n,n?function(t){let e;t.interface||(t.worker=new Worker(t.scripts[0]),t.worker.addEventListener(Lt,r,!1),t.interface={append:t=>n({type:St,data:t}),flush:()=>n({type:Tt})});return t.interface;async function n(n){if(!e){const e=t.options,n=t.scripts.slice(1);await i(Object.assign({scripts:n,type:It,options:{codecType:e.codecType,inputPassword:e.inputPassword,inputSigned:e.inputSigned,inputSignature:e.signature,inputCompressed:e.inputCompressed,inputEncrypted:e.inputEncrypted,level:e.level,outputPassword:e.outputPassword,outputSigned:e.outputSigned,outputCompressed:e.outputCompressed,outputEncrypted:e.outputEncrypted}}))}return i(n)}function i(n){const i=t.worker,r=new Promise(((t,n)=>e={resolve:t,reject:n}));try{if(n.data)try{i.postMessage(n,[n.data.buffer])}catch(t){i.postMessage(n)}else i.postMessage(n)}catch(n){e.reject(n),e=null,Wt(t)}return r}function r(n){const i=n.data;if(e){const n=i.error;if(n){const i=new Error(n.message);i.stack=n.stack,e.reject(i),e=null,Wt(t)}else i.type!=It&&i.type!=Tt&&i.type!=St||(i.type==Tt?(e.resolve({data:new Uint8Array(i.data),signature:i.signature}),e=null,Wt(t)):e.resolve(i.data&&new Uint8Array(i.data)))}}}(t):function(t){const e=function(t){return t.codecType.startsWith(kt)?new Ft(t):t.codecType.startsWith(Ut)?new Dt(t):void 0}(t.options);return{async append(n){try{return await e.append(n)}catch(e){throw Wt(t),e}},async flush(){try{return await e.flush()}finally{Wt(t)}}}}(t)}function Wt(t){if(t.busy=!1,Mt.pendingRequests.length){const[{resolve:e,options:n,scripts:i}]=Mt.pendingRequests.splice(0,1);e(Ot(t,n,i))}else t.worker&&t.worker.terminate(),Mt.pool=Mt.pool.filter((e=>e!=t))}async function Pt(t,e,n,i,r,a,s){const o=Math.max(a.chunkSize,64);return async function a(l=0,d=0){const c=l*o;if(c","?","@","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","{","|","}","~","⌂","Ç","ü","é","â","ä","à","å","ç","ê","ë","è","ï","î","ì","Ä","Å","É","æ","Æ","ô","ö","ò","û","ù","ÿ","Ö","Ü","¢","£","¥","₧","ƒ","á","í","ó","ú","ñ","Ñ","ª","º","¿","⌐","¬","½","¼","¡","«","»","░","▒","▓","│","┤","╡","╢","╖","╕","╣","║","╗","╝","╜","╛","┐","└","┴","┬","├","─","┼","╞","╟","╚","╔","╩","╦","╠","═","╬","╧","╨","╤","╥","╙","╘","╒","╓","╫","╪","┘","┌","█","▄","▌","▐","▀","α","ß","Γ","π","Σ","σ","µ","τ","Φ","Θ","Ω","δ","∞","φ","ε","∩","≡","±","≥","≤","⌠","⌡","÷","≈","°","∙","·","√","ⁿ","²","■"," "];class ee{constructor(t,e,n){this.reader=t,this.config=e,this.options=n}async getData(t,e={}){const n=this.reader;n.initialized||await n.init();const i=await n.readUint8Array(this.offset,30),r=new DataView(i.buffer),a=void 0===e.password?this.options.password:e.password;let s=a&&a.length&&a;if(this.extraFieldAES){if(99!=this.extraFieldAES.originalCompressionMethod)throw new Error(Jt);if(3!=this.extraFieldAES.strength)throw new Error(Gt)}if(0!=this.compressionMethod&&8!=this.compressionMethod)throw new Error(Jt);if(le(r,0)!=Y)throw new Error(Kt);const o=this.localDirectory={};ne(o,r,4),o.rawExtraField=i.subarray(this.offset+30+o.filenameLength,this.offset+30+o.filenameLength+o.extraFieldLength),ie(this,o,r,4);let l=this.offset+30+o.filenameLength+o.extraFieldLength;const d=this.bitFlag.encrypted&&o.bitFlag.encrypted;if(d&&!s)throw new Error(Xt);const c=await Nt(this.config,{codecType:Ut,codecConstructor:this.config.Inflate,inputPassword:s,inputSigned:void 0===e.checkSignature?this.options.checkSignature:e.checkSignature,inputSignature:this.signature,inputCompressed:0!=this.compressionMethod,inputEncrypted:d,useWebWorkers:void 0===e.useWebWorkers?this.options.useWebWorkers:e.useWebWorkers});return t.initialized||await t.init(),await Pt(c,n,t,l,this.compressedSize,this.config,{onprogress:e.onprogress}),t.getData()}}function ne(t,e,n){t.version=oe(e,n);const i=t.rawBitFlag=oe(e,n+2);t.bitFlag={encrypted:1==(1&i),level:(6&i)>>1,dataDescriptor:8==(8&i),languageEncodingFlag:(i&et)==et},t.encrypted=t.bitFlag.encrypted,t.rawLastModDate=le(e,n+6),t.lastModDate=function(t){const e=(4294901760&t)>>16,n=65535&t;try{return new Date(1980+((65024&e)>>9),((480&e)>>5)-1,31&e,(63488&n)>>11,(2016&n)>>5,2*(31&n),0)}catch(t){}}(t.rawLastModDate),t.filenameLength=oe(e,n+22),t.extraFieldLength=oe(e,n+24)}function ie(t,e,n,i){const r=e.rawExtraField,a=e.extraField=new Map,s=new DataView(new Uint8Array(r).buffer);let o=0;try{for(;oe[t]==q));for(let e=0;e{if(e[n]==q){if(!t||void 0===t[n])throw new Error(Yt);e[n]=t[n]}}))}(d,e);const c=e.extraFieldUnicodePath=a.get(28789);c&&re(c,"filename","rawFilename",e,t);let u=e.extraFieldUnicodeComment=a.get(25461);u&&re(u,"comment","rawComment",e,t);const f=e.extraFieldAES=a.get(39169);f?function(t,e,n){if(t){const i=new DataView(t.data.buffer);t.vendorVersion=se(i,0),t.vendorId=se(i,2);const r=se(i,4);t.strength=r,t.originalCompressionMethod=n,e.compressionMethod=t.compressionMethod=oe(i,5)}else e.compressionMethod=n}(f,e,l):e.compressionMethod=l,8==e.compressionMethod&&(e.bitFlag.enhancedDeflating=16!=(16&e.rawBitFlag))}function re(t,e,n,i,r){const a=new DataView(t.data.buffer);t.version=se(a,0),t.signature=le(a,1);const s=new nt;s.append(r[n]);const o=new DataView(new Uint8Array(4).buffer);o.setUint32(0,s.get()),t[e]=(new TextDecoder).decode(t.data.subarray(5)),r.bitFlag.languageEncodingFlag||t.signature!=le(o,0)||(i[e]=t[e])}function ae(t,e){if(e&&"cp437"!=e.trim().toLowerCase())return new TextDecoder(e).decode(t);{let e="";for(let n=0;n{if(this.pendingData){const e=this.pendingData;this.pendingData=new Uint8Array(e.length+t.length),this.pendingData.set(e,0),this.pendingData.set(t,e.length)}else this.pendingData=new Uint8Array(t)};if(this.codec=new t(Object.assign({},e,n)),typeof this.codec.onData==Ee)this.codec.onData=i;else{if(typeof this.codec.on!=Ee)throw new Error("Cannot register the callback function");this.codec.on("data",i)}}async append(t){return this.codec.push(t),n(this)}async flush(){return this.codec.push(new Uint8Array(0),!0),n(this)}};function n(t){if(t.pendingData){const e=t.pendingData;return t.pendingData=null,e}return new Uint8Array(0)}}const ke={chunkSize:524288,maxWorkers:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||2,workerScriptsPath:void 0,useWebWorkers:!0,Deflate:function(t){const e=new b,n=512,i=new Uint8Array(n);let r=t?t.level:-1;void 0===r&&(r=-1),e.deflateInit(r),e.next_out=i,this.append=function(t,r){let a,s,o=0,l=0,d=0;const c=[];if(t.length){e.next_in_index=0,e.next_in=t,e.avail_in=t.length;do{if(e.next_out_index=0,e.avail_out=n,a=e.deflate(0),0!=a)throw new Error("deflating: "+e.msg);e.next_out_index&&(e.next_out_index==n?c.push(new Uint8Array(i)):c.push(new Uint8Array(i.subarray(0,e.next_out_index)))),d+=e.next_out_index,r&&e.next_in_index>0&&e.next_in_index!=o&&(r(e.next_in_index),o=e.next_in_index)}while(e.avail_in>0||0===e.avail_out);return s=new Uint8Array(d),c.forEach((function(t){s.set(t,l),l+=t.length})),s}},this.flush=function(){let t,r,a=0,s=0;const o=[];do{if(e.next_out_index=0,e.avail_out=n,t=e.deflate(4),1!=t&&0!=t)throw new Error("deflating: "+e.msg);n-e.avail_out>0&&o.push(new Uint8Array(i.subarray(0,e.next_out_index))),s+=e.next_out_index}while(e.avail_in>0||0===e.avail_out);return e.deflateEnd(),r=new Uint8Array(s),o.forEach((function(t){r.set(t,a),a+=t.length})),r}},Inflate:function(){const t=new M,e=new Uint8Array(512);let n=!1;t.inflateInit(),t.next_out=e,this.append=function(i,r){const a=[];let s,o,l=0,d=0,c=0;if(0!==i.length){t.next_in_index=0,t.next_in=i,t.avail_in=i.length;do{if(t.next_out_index=0,t.avail_out=512,0!==t.avail_in||n||(t.next_in_index=0,n=!0),s=t.inflate(0),n&&s===x){if(0!==t.avail_in)throw new Error("inflating: bad input")}else if(0!==s&&1!==s)throw new Error("inflating: "+t.msg);if((n||1===s)&&t.avail_in===i.length)throw new Error("inflating: bad input");t.next_out_index&&(512===t.next_out_index?a.push(new Uint8Array(e)):a.push(new Uint8Array(e.subarray(0,t.next_out_index)))),c+=t.next_out_index,r&&t.next_in_index>0&&t.next_in_index!=l&&(r(t.next_in_index),l=t.next_in_index)}while(t.avail_in>0||0===t.avail_out);return o=new Uint8Array(c),a.forEach((function(t){o.set(t,d),d+=t.length})),o}},this.flush=function(){t.inflateEnd()}}};let Ue=Object.assign({},ke);t.BlobReader=j,t.BlobWriter=class extends B{constructor(t){super(),this.offset=0,this.contentType=t,this.blob=new Blob([],{type:t})}writeUint8Array(t){super.writeUint8Array(t),this.blob=new Blob([this.blob,t.buffer],{type:this.contentType}),this.offset=this.blob.size}getData(){return this.blob}},t.Data64URIReader=class extends V{constructor(t){super(),this.dataURI=t;let e=t.length;for(;"="==t.charAt(e-1);)e--;this.dataStart=t.indexOf(",")+1,this.size=Math.floor(.75*(e-this.dataStart))}readUint8Array(t,e){const n=new Uint8Array(e),i=4*Math.floor(t/3),r=atob(this.dataURI.substring(i+this.dataStart,4*Math.ceil((t+e)/3)+this.dataStart)),a=t-3*Math.floor(i/4);for(let t=a;t2?this.data+=btoa(n):this.pending=n}getData(){return this.data+btoa(this.pending)}},t.ERR_BAD_FORMAT=Bt,t.ERR_CENTRAL_DIRECTORY_NOT_FOUND=qt,t.ERR_DUPLICATED_NAME=ce,t.ERR_ENCRYPTED=Xt,t.ERR_EOCDR_LOCATOR_ZIP64_NOT_FOUND=Zt,t.ERR_EOCDR_NOT_FOUND=jt,t.ERR_EOCDR_ZIP64_NOT_FOUND=Ht,t.ERR_EXTRAFIELD_ZIP64_NOT_FOUND=Yt,t.ERR_HTTP_RANGE=O,t.ERR_INVALID_COMMENT=ue,t.ERR_INVALID_DATE=we,t.ERR_INVALID_ENTRY_COMMENT=fe,t.ERR_INVALID_ENTRY_NAME=_e,t.ERR_INVALID_EXTRAFIELD_DATA=be,t.ERR_INVALID_EXTRAFIELD_TYPE=pe,t.ERR_INVALID_PASSORD=it,t.ERR_INVALID_SIGNATURE=Rt,t.ERR_INVALID_VERSION=he,t.ERR_LOCAL_FILE_HEADER_NOT_FOUND=Kt,t.ERR_UNSUPPORTED_COMPRESSION=Jt,t.ERR_UNSUPPORTED_ENCRYPTION=Gt,t.HttpRangeReader=class extends V{constructor(t){super(),this.url=t}init(){return super.init(),new Promise(((t,e)=>{const n=new XMLHttpRequest;n.addEventListener("load",(()=>{n.status<400?(this.size=Number(n.getResponseHeader("Content-Length")),"bytes"==n.getResponseHeader("Accept-Ranges")?t():e(new Error(O))):e(N+(n.statusText||n.status)+".")}),!1),n.addEventListener("error",e,!1),n.open("HEAD",this.url),n.send()}))}readUint8Array(t,e){return new Promise(((n,i)=>{const r=new XMLHttpRequest;r.open("GET",this.url),r.responseType="arraybuffer",r.setRequestHeader("Range","bytes="+t+"-"+(t+e-1)),r.addEventListener("load",(()=>{r.status<400?n(new Uint8Array(r.response)):i(N+(r.statusText||r.status)+".")}),!1),r.addEventListener("error",i,!1),r.send()}))}},t.HttpReader=class extends V{constructor(t){super(),this.url=t}async init(){if(super.init(),function(t){if("undefined"!=typeof document){const e=document.createElement("a");return e.href=t,"http:"==e.protocol||"https:"==e.protocol}return/^https?:\/\//i.test(t)}(this.url))return new Promise(((t,e)=>{const n=new XMLHttpRequest;n.addEventListener("load",(()=>{n.status<400?(this.size=Number(n.getResponseHeader("Content-Length")),this.size?t():Z().then((()=>t())).catch(e)):e(N+(n.statusText||n.status)+".")}),!1),n.addEventListener("error",e,!1),n.open("HEAD",this.url),n.send()}));await Z()}async readUint8Array(t,e){return this.data||await Z(this,this.url),new Uint8Array(this.data.subarray(t,t+e))}},t.Reader=V,t.TextReader=class extends V{constructor(t){super(),this.blobReader=new j(new Blob([t],{type:W}))}init(){super.init(),this.blobReader.init(),this.size=this.blobReader.size}readUint8Array(t,e){return this.blobReader.readUint8Array(t,e)}},t.TextWriter=class extends B{constructor(t){super(),this.encoding=t,this.blob=new Blob([],{type:W})}writeUint8Array(t){super.writeUint8Array(t),this.blob=new Blob([this.blob,t.buffer],{type:W})}getData(){const t=new FileReader;return new Promise(((e,n)=>{t.onload=t=>e(t.target.result),t.onerror=n,t.readAsText(this.blob,this.encoding)}))}},t.Uint8ArrayReader=class extends V{constructor(t){super(),this.array=t,this.size=t.length}readUint8Array(t,e){return this.array.slice(t,t+e)}},t.Uint8ArrayWriter=H,t.Writer=B,t.ZipReader=class extends class{constructor(t,e={},n={}){this.reader=t,this.options=e,this.config=n}async getEntries(t={}){const e=this.reader;e.initialized||await e.init();const n=await async function(t,e,n,i){const r=new Uint8Array(4);if(function(t,e,n){t.setUint32(e,n,!0)}(new DataView(r.buffer),0,e),t.size=0;t--)if(a[t]==r[0]&&a[t+1]==r[1]&&a[t+2]==r[2]&&a[t+3]==r[3])return{offset:i,buffer:a.slice(t,t+n).buffer}}}(e,J,22,K);if(!n)throw new Error(jt);const i=new DataView(n.buffer);let r,a=le(i,16),s=oe(i,8);if(a==q||s==K){r=!0;const t=await e.readUint8Array(n.offset-20,20),i=new DataView(t.buffer);if(Number(le(i,0))!=$)throw new Error(Ht);a=Number(de(i,8));const o=await e.readUint8Array(a,56),l=new DataView(o.buffer);if(Number(le(l,0))!=Q)throw new Error(Zt);s=Number(de(l,24)),a-=Number(de(l,40))}if(a<0||!r&&(a>=e.size||s>=K))throw new Error(Bt);const o=await e.readUint8Array(a,e.size-a),l=new DataView(o.buffer),d=[];let c=0;for(let e=0;eK)throw new Error(_e);const r=(new TextEncoder).encode(n.comment||"");if(r.length>K)throw new Error(fe);const a=this.options.version||n.version||0;if(a>K)throw new Error(he);const s=n.lastModDate||new Date;if(s.getFullYear()<1980)throw new Error(we);e&&!e.initialized&&await e.init();let o=new Uint8Array(0);const l=n.extraField;if(l){let t=4,e=0;l.forEach((e=>t+=e.length)),o=new Uint8Array(t),l.forEach(((t,n)=>{if(n>K)throw new Error(pe);if(t.length>K)throw new Error(be);o.set(new Uint16Array([n]),e),o.set(new Uint16Array([t.length]),e+2),o.set(t,e+4),e+=4+t.length}))}const d=n.zip64||this.options.zip64||this.offset>=q||e&&(e.size>=q||this.offset+e.size>=q),c=void 0===n.password?this.options.password:n.password,u=void 0===n.level?this.options.level:n.level,f=void 0===n.useWebWorkers?this.options.useWebWorkers:n.useWebWorkers;await async function(t,e,n,i){const r=t.files,a=t.writer;let s;r.set(e,null);try{let o,l;try{i.bufferedWrite||t.options.bufferedWrite||t.lockWrite?(o=new H,o.init()):(t.lockWrite=new Promise((t=>s=t)),a.initialized||await a.init(),o=a),l=await async function(t,e,n,i){const r=i.rawFilename,a=i.lastModDate,s=i.password,o=s&&s.length,l=i.level,d=0!==l&&!i.directory,c=i.zip64;let u;if(o){u=new Uint8Array(ge.length+2);xe(new DataView(u.buffer),0,tt),u.set(ge,2)}else u=new Uint8Array(0);const f={version:i.version||20,zip64:c,directory:i.directory,rawFilename:r,rawComment:i.rawComment,extraFieldZip64:c?new Uint8Array(28):new Uint8Array(0),extraFieldAES:u,rawExtraField:i.rawExtraField};let _=2056,h=0;d&&(h=8);c&&(f.version=f.version>45?f.version:45);o&&(f.version=f.version>51?f.version:51,_|=1,h=99,d&&(f.extraFieldAES[9]=8));const w=f.headerArray=new Uint8Array(26),p=new DataView(w.buffer);xe(p,0,f.version),xe(p,2,_),xe(p,4,h),xe(p,6,(a.getHours()<<6|a.getMinutes())<<5|a.getSeconds()/2),xe(p,8,(a.getFullYear()-1980<<4|a.getMonth()+1)<<5|a.getDate()),xe(p,22,r.length),xe(p,24,0);const b=new Uint8Array(30+r.length);let g,y,x;if(me(new DataView(b.buffer),0,Y),b.set(w,4),b.set(r,30),t){y=t.size;const r=await Nt(n,{codecType:kt,codecConstructor:n.Deflate,level:l,outputPassword:s,outputSigned:!0,outputCompressed:d,outputEncrypted:o,useWebWorkers:i.useWebWorkers});await e.writeUint8Array(b),g=await Pt(r,t,e,0,y,n,{onprogress:i.onprogress}),x=g.length}else await e.writeUint8Array(b);const m=new Uint8Array(c?24:16),v=new DataView(m.buffer);if(me(v,0,X),t)if(o||void 0===g.signature||(me(p,10,g.signature),me(v,4,g.signature)),c){const t=new DataView(f.extraFieldZip64.buffer);xe(t,0,1),xe(t,2,24),me(p,14,q),ve(v,8,BigInt(x)),ve(t,12,BigInt(x)),me(p,18,q),ve(v,16,BigInt(y)),ve(t,4,BigInt(y))}else me(p,14,x),me(v,8,x),me(p,18,y),me(v,12,y);return await e.writeUint8Array(m),f.length=b.length+(g?g.length:0)+m.length,f}(n,o,t.config,i)}catch(t){throw r.delete(e),t}if(r.set(e,l),o!=a&&(t.lockWrite&&await t.lockWrite,await a.writeUint8Array(o.getData())),l.offset=t.offset,l.zip64){ve(new DataView(l.extraFieldZip64.buffer),20,BigInt(l.offset))}t.offset+=l.length}finally{s&&(t.lockWrite=null,s())}}(this,t,e,Object.assign({},n,{rawFilename:i,rawComment:r,version:a,lastModDate:s,rawExtraField:o,zip64:d,password:c,level:u,useWebWorkers:f}))}async close(t=new Uint8Array(0)){const e=this.writer,n=this.files;let i=0,r=0,a=this.offset,s=n.size;if(t.length){if(!(t.length<=K))throw new Error(ue);xe(d,i+20,t.length)}for(const[,t]of n)r+=46+t.rawFilename.length+t.rawComment.length+t.extraFieldZip64.length+t.extraFieldAES.length+t.rawExtraField.length;const o=this.options.zip64||a+r>=q||s>=K,l=new Uint8Array(r+(o?98:22)),d=new DataView(l.buffer);for(const[,t]of n){const e=t.rawFilename,n=t.extraFieldZip64,r=t.extraFieldAES,a=n.length+r.length+t.rawExtraField.length;me(d,i,G),xe(d,i+4,t.version),l.set(t.headerArray,i+6),xe(d,i+30,a),xe(d,i+32,t.rawComment.length),t.directory&&ye(d,i+38,16),t.zip64?me(d,i+42,q):me(d,i+42,t.offset),l.set(e,i+46),l.set(n,i+46+e.length),l.set(r,i+46+e.length+n.length),l.set(t.rawExtraField,46+e.length+n.length+r.length),l.set(t.rawComment,i+46+e.length+a),i+=46+e.length+a+t.rawComment.length}return o&&(me(d,i,Q),ve(d,i+4,BigInt(44)),xe(d,i+12,45),xe(d,i+14,45),ve(d,i+24,BigInt(s)),ve(d,i+32,BigInt(s)),ve(d,i+40,BigInt(r)),ve(d,i+48,BigInt(a)),me(d,i+56,$),ve(d,i+64,BigInt(a+r)),me(d,i+72,1),s=K,a=q,i+=76),me(d,i,J),xe(d,i+8,s),xe(d,i+10,s),me(d,i+12,r),me(d,i+16,a),await e.writeUint8Array(l),await e.writeUint8Array(t),e.getData()}}{constructor(t,e){super(t,e,Ue)}},t.configure=function(t){if(Ue=Object.assign({},Ue,t),null!=Ue.workerScripts&&null!=Ue.workerScriptsPath)throw new Error("Either workerScripts or workerScriptsPath may be set, not both");if(Ue.workerScripts){if(Ue.workerScripts.deflate&&!Array.isArray(Ue.workerScripts.deflate))throw new Error("workerScripts.deflate must be an array");if(Ue.workerScripts.inflate&&!Array.isArray(Ue.workerScripts.inflate))throw new Error("workerScripts.inflate must be an array")}},t.getMimeType=function(){return"application/octet-stream"},t.initShimAsyncCodec=(t,e={})=>({Deflate:Ae(t.Deflate,e.deflate),Inflate:Ae(t.Inflate,e.inflate)}),Object.defineProperty(t,"__esModule",{value:!0})}));