trzsz2 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.cn.md +64 -0
- package/README.md +70 -0
- package/dist/browser/buffer.d.ts +76 -0
- package/dist/browser/comm.d.ts +162 -0
- package/dist/browser/escape.d.ts +33 -0
- package/dist/browser/index.d.ts +17 -0
- package/dist/browser/options.d.ts +57 -0
- package/dist/browser/progress.d.ts +100 -0
- package/dist/browser/transfer.d.ts +259 -0
- package/dist/browser/trzsz2.js +6147 -0
- package/dist/browser/trzsz2.js.map +1 -0
- package/dist/browser/trzsz2.min.js +19 -0
- package/dist/buffer.d.ts +76 -0
- package/dist/cjs/buffer.cjs +252 -0
- package/dist/cjs/buffer.cjs.map +1 -0
- package/dist/cjs/buffer.d.ts +76 -0
- package/dist/cjs/comm.cjs +292 -0
- package/dist/cjs/comm.cjs.map +1 -0
- package/dist/cjs/comm.d.ts +162 -0
- package/dist/cjs/escape.cjs +86 -0
- package/dist/cjs/escape.cjs.map +1 -0
- package/dist/cjs/escape.d.ts +33 -0
- package/dist/cjs/index.cjs +30 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.ts +17 -0
- package/dist/cjs/node_modules/pako/dist/pako.esm.cjs +4177 -0
- package/dist/cjs/node_modules/pako/dist/pako.esm.cjs.map +1 -0
- package/dist/cjs/node_modules/ts-md5/dist/esm/md5.cjs +353 -0
- package/dist/cjs/node_modules/ts-md5/dist/esm/md5.cjs.map +1 -0
- package/dist/cjs/options.d.ts +57 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/progress.cjs +313 -0
- package/dist/cjs/progress.cjs.map +1 -0
- package/dist/cjs/progress.d.ts +100 -0
- package/dist/cjs/transfer.cjs +706 -0
- package/dist/cjs/transfer.cjs.map +1 -0
- package/dist/cjs/transfer.d.ts +259 -0
- package/dist/cjs-full/buffer.d.ts +76 -0
- package/dist/cjs-full/comm.d.ts +162 -0
- package/dist/cjs-full/escape.d.ts +33 -0
- package/dist/cjs-full/index.cjs +6144 -0
- package/dist/cjs-full/index.cjs.map +1 -0
- package/dist/cjs-full/index.d.ts +17 -0
- package/dist/cjs-full/options.d.ts +57 -0
- package/dist/cjs-full/package.json +3 -0
- package/dist/cjs-full/progress.d.ts +100 -0
- package/dist/cjs-full/transfer.d.ts +259 -0
- package/dist/comm.d.ts +162 -0
- package/dist/escape.d.ts +33 -0
- package/dist/esm/buffer.d.ts +76 -0
- package/dist/esm/buffer.js +252 -0
- package/dist/esm/buffer.js.map +1 -0
- package/dist/esm/comm.d.ts +162 -0
- package/dist/esm/comm.js +292 -0
- package/dist/esm/comm.js.map +1 -0
- package/dist/esm/escape.d.ts +33 -0
- package/dist/esm/escape.js +86 -0
- package/dist/esm/escape.js.map +1 -0
- package/dist/esm/index.d.ts +17 -0
- package/dist/esm/index.js +30 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/node_modules/pako/dist/pako.esm.js +4177 -0
- package/dist/esm/node_modules/pako/dist/pako.esm.js.map +1 -0
- package/dist/esm/node_modules/ts-md5/dist/esm/md5.js +353 -0
- package/dist/esm/node_modules/ts-md5/dist/esm/md5.js.map +1 -0
- package/dist/esm/options.d.ts +57 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/progress.d.ts +100 -0
- package/dist/esm/progress.js +313 -0
- package/dist/esm/progress.js.map +1 -0
- package/dist/esm/transfer.d.ts +259 -0
- package/dist/esm/transfer.js +706 -0
- package/dist/esm/transfer.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/options.d.ts +57 -0
- package/dist/progress.d.ts +100 -0
- package/dist/transfer.d.ts +259 -0
- package/package.json +108 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";var Trzsz2=function(D){"use strict";/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function oe(e){let i=e.length;for(;--i>=0;)e[i]=0}const cn=0,Ct=1,un=2,dn=3,_n=258,it=29,ge=256,be=ge+1+it,fe=30,nt=19,Nt=2*be+1,ee=15,at=16,wn=7,rt=256,Ot=16,Ut=17,Ft=18,lt=new Uint8Array([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]),Fe=new Uint8Array([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]),gn=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Zt=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bn=512,X=new Array((be+2)*2);oe(X);const pe=new Array(fe*2);oe(pe);const ye=new Array(bn);oe(ye);const me=new Array(_n-dn+1);oe(me);const st=new Array(it);oe(st);const Ze=new Array(fe);oe(Ze);function ot(e,i,t,n,a){this.static_tree=e,this.extra_bits=i,this.extra_base=t,this.elems=n,this.max_length=a,this.has_stree=e&&e.length}let $t,Mt,Ht;function ft(e,i){this.dyn_tree=e,this.max_code=0,this.stat_desc=i}const Pt=e=>e<256?ye[e]:ye[256+(e>>>7)],ve=(e,i)=>{e.pending_buf[e.pending++]=i&255,e.pending_buf[e.pending++]=i>>>8&255},U=(e,i,t)=>{e.bi_valid>at-t?(e.bi_buf|=i<<e.bi_valid&65535,ve(e,e.bi_buf),e.bi_buf=i>>at-e.bi_valid,e.bi_valid+=t-at):(e.bi_buf|=i<<e.bi_valid&65535,e.bi_valid+=t)},H=(e,i,t)=>{U(e,t[i*2],t[i*2+1])},jt=(e,i)=>{let t=0;do t|=e&1,e>>>=1,t<<=1;while(--i>0);return t>>>1},pn=e=>{e.bi_valid===16?(ve(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)},yn=(e,i)=>{const t=i.dyn_tree,n=i.max_code,a=i.stat_desc.static_tree,r=i.stat_desc.has_stree,l=i.stat_desc.extra_bits,s=i.stat_desc.extra_base,c=i.stat_desc.max_length;let o,f,g,u,h,_,z=0;for(u=0;u<=ee;u++)e.bl_count[u]=0;for(t[e.heap[e.heap_max]*2+1]=0,o=e.heap_max+1;o<Nt;o++)f=e.heap[o],u=t[t[f*2+1]*2+1]+1,u>c&&(u=c,z++),t[f*2+1]=u,!(f>n)&&(e.bl_count[u]++,h=0,f>=s&&(h=l[f-s]),_=t[f*2],e.opt_len+=_*(u+h),r&&(e.static_len+=_*(a[f*2+1]+h)));if(z!==0){do{for(u=c-1;e.bl_count[u]===0;)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[c]--,z-=2}while(z>0);for(u=c;u!==0;u--)for(f=e.bl_count[u];f!==0;)g=e.heap[--o],!(g>n)&&(t[g*2+1]!==u&&(e.opt_len+=(u-t[g*2+1])*t[g*2],t[g*2+1]=u),f--)}},Kt=(e,i,t)=>{const n=new Array(ee+1);let a=0,r,l;for(r=1;r<=ee;r++)a=a+t[r-1]<<1,n[r]=a;for(l=0;l<=i;l++){let s=e[l*2+1];s!==0&&(e[l*2]=jt(n[s]++,s))}},mn=()=>{let e,i,t,n,a;const r=new Array(ee+1);for(t=0,n=0;n<it-1;n++)for(st[n]=t,e=0;e<1<<lt[n];e++)me[t++]=n;for(me[t-1]=n,a=0,n=0;n<16;n++)for(Ze[n]=a,e=0;e<1<<Fe[n];e++)ye[a++]=n;for(a>>=7;n<fe;n++)for(Ze[n]=a<<7,e=0;e<1<<Fe[n]-7;e++)ye[256+a++]=n;for(i=0;i<=ee;i++)r[i]=0;for(e=0;e<=143;)X[e*2+1]=8,e++,r[8]++;for(;e<=255;)X[e*2+1]=9,e++,r[9]++;for(;e<=279;)X[e*2+1]=7,e++,r[7]++;for(;e<=287;)X[e*2+1]=8,e++,r[8]++;for(Kt(X,be+1,r),e=0;e<fe;e++)pe[e*2+1]=5,pe[e*2]=jt(e,5);$t=new ot(X,lt,ge+1,be,ee),Mt=new ot(pe,Fe,0,fe,ee),Ht=new ot(new Array(0),gn,0,nt,wn)},Xt=e=>{let i;for(i=0;i<be;i++)e.dyn_ltree[i*2]=0;for(i=0;i<fe;i++)e.dyn_dtree[i*2]=0;for(i=0;i<nt;i++)e.bl_tree[i*2]=0;e.dyn_ltree[rt*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},Gt=e=>{e.bi_valid>8?ve(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Yt=(e,i,t,n)=>{const a=i*2,r=t*2;return e[a]<e[r]||e[a]===e[r]&&n[i]<=n[t]},ht=(e,i,t)=>{const n=e.heap[t];let a=t<<1;for(;a<=e.heap_len&&(a<e.heap_len&&Yt(i,e.heap[a+1],e.heap[a],e.depth)&&a++,!Yt(i,n,e.heap[a],e.depth));)e.heap[t]=e.heap[a],t=a,a<<=1;e.heap[t]=n},Wt=(e,i,t)=>{let n,a,r=0,l,s;if(e.sym_next!==0)do n=e.pending_buf[e.sym_buf+r++]&255,n+=(e.pending_buf[e.sym_buf+r++]&255)<<8,a=e.pending_buf[e.sym_buf+r++],n===0?H(e,a,i):(l=me[a],H(e,l+ge+1,i),s=lt[l],s!==0&&(a-=st[l],U(e,a,s)),n--,l=Pt(n),H(e,l,t),s=Fe[l],s!==0&&(n-=Ze[l],U(e,n,s)));while(r<e.sym_next);H(e,rt,i)},ct=(e,i)=>{const t=i.dyn_tree,n=i.stat_desc.static_tree,a=i.stat_desc.has_stree,r=i.stat_desc.elems;let l,s,c=-1,o;for(e.heap_len=0,e.heap_max=Nt,l=0;l<r;l++)t[l*2]!==0?(e.heap[++e.heap_len]=c=l,e.depth[l]=0):t[l*2+1]=0;for(;e.heap_len<2;)o=e.heap[++e.heap_len]=c<2?++c:0,t[o*2]=1,e.depth[o]=0,e.opt_len--,a&&(e.static_len-=n[o*2+1]);for(i.max_code=c,l=e.heap_len>>1;l>=1;l--)ht(e,t,l);o=r;do l=e.heap[1],e.heap[1]=e.heap[e.heap_len--],ht(e,t,1),s=e.heap[1],e.heap[--e.heap_max]=l,e.heap[--e.heap_max]=s,t[o*2]=t[l*2]+t[s*2],e.depth[o]=(e.depth[l]>=e.depth[s]?e.depth[l]:e.depth[s])+1,t[l*2+1]=t[s*2+1]=o,e.heap[1]=o++,ht(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],yn(e,i),Kt(t,c,e.bl_count)},Vt=(e,i,t)=>{let n,a=-1,r,l=i[0*2+1],s=0,c=7,o=4;for(l===0&&(c=138,o=3),i[(t+1)*2+1]=65535,n=0;n<=t;n++)r=l,l=i[(n+1)*2+1],!(++s<c&&r===l)&&(s<o?e.bl_tree[r*2]+=s:r!==0?(r!==a&&e.bl_tree[r*2]++,e.bl_tree[Ot*2]++):s<=10?e.bl_tree[Ut*2]++:e.bl_tree[Ft*2]++,s=0,a=r,l===0?(c=138,o=3):r===l?(c=6,o=3):(c=7,o=4))},Jt=(e,i,t)=>{let n,a=-1,r,l=i[0*2+1],s=0,c=7,o=4;for(l===0&&(c=138,o=3),n=0;n<=t;n++)if(r=l,l=i[(n+1)*2+1],!(++s<c&&r===l)){if(s<o)do H(e,r,e.bl_tree);while(--s!==0);else r!==0?(r!==a&&(H(e,r,e.bl_tree),s--),H(e,Ot,e.bl_tree),U(e,s-3,2)):s<=10?(H(e,Ut,e.bl_tree),U(e,s-3,3)):(H(e,Ft,e.bl_tree),U(e,s-11,7));s=0,a=r,l===0?(c=138,o=3):r===l?(c=6,o=3):(c=7,o=4)}},vn=e=>{let i;for(Vt(e,e.dyn_ltree,e.l_desc.max_code),Vt(e,e.dyn_dtree,e.d_desc.max_code),ct(e,e.bl_desc),i=nt-1;i>=3&&e.bl_tree[Zt[i]*2+1]===0;i--);return e.opt_len+=3*(i+1)+5+5+4,i},Sn=(e,i,t,n)=>{let a;for(U(e,i-257,5),U(e,t-1,5),U(e,n-4,4),a=0;a<n;a++)U(e,e.bl_tree[Zt[a]*2+1],3);Jt(e,e.dyn_ltree,i-1),Jt(e,e.dyn_dtree,t-1)},xn=e=>{let i=4093624447,t;for(t=0;t<=31;t++,i>>>=1)if(i&1&&e.dyn_ltree[t*2]!==0)return 0;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return 1;for(t=32;t<ge;t++)if(e.dyn_ltree[t*2]!==0)return 1;return 0};let qt=!1;const An=e=>{qt||(mn(),qt=!0),e.l_desc=new ft(e.dyn_ltree,$t),e.d_desc=new ft(e.dyn_dtree,Mt),e.bl_desc=new ft(e.bl_tree,Ht),e.bi_buf=0,e.bi_valid=0,Xt(e)},Qt=(e,i,t,n)=>{U(e,(cn<<1)+(n?1:0),3),Gt(e),ve(e,t),ve(e,~t),t&&e.pending_buf.set(e.window.subarray(i,i+t),e.pending),e.pending+=t},En=e=>{U(e,Ct<<1,3),H(e,rt,X),pn(e)},kn=(e,i,t,n)=>{let a,r,l=0;e.level>0?(e.strm.data_type===2&&(e.strm.data_type=xn(e)),ct(e,e.l_desc),ct(e,e.d_desc),l=vn(e),a=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=a&&(a=r)):a=r=t+5,t+4<=a&&i!==-1?Qt(e,i,t,n):e.strategy===4||r===a?(U(e,(Ct<<1)+(n?1:0),3),Wt(e,X,pe)):(U(e,(un<<1)+(n?1:0),3),Sn(e,e.l_desc.max_code+1,e.d_desc.max_code+1,l+1),Wt(e,e.dyn_ltree,e.dyn_dtree)),Xt(e),n&&Gt(e)},Tn=(e,i,t)=>(e.pending_buf[e.sym_buf+e.sym_next++]=i,e.pending_buf[e.sym_buf+e.sym_next++]=i>>8,e.pending_buf[e.sym_buf+e.sym_next++]=t,i===0?e.dyn_ltree[t*2]++:(e.matches++,i--,e.dyn_ltree[(me[t]+ge+1)*2]++,e.dyn_dtree[Pt(i)*2]++),e.sym_next===e.sym_end);var In=An,zn=Qt,Dn=kn,Rn=Tn,Ln=En,Bn={_tr_init:In,_tr_stored_block:zn,_tr_flush_block:Dn,_tr_tally:Rn,_tr_align:Ln},Se=(e,i,t,n)=>{let a=e&65535|0,r=e>>>16&65535|0,l=0;for(;t!==0;){l=t>2e3?2e3:t,t-=l;do a=a+i[n++]|0,r=r+a|0;while(--l);a%=65521,r%=65521}return a|r<<16|0};const Cn=()=>{let e,i=[];for(var t=0;t<256;t++){e=t;for(var n=0;n<8;n++)e=e&1?3988292384^e>>>1:e>>>1;i[t]=e}return i},Nn=new Uint32Array(Cn());var B=(e,i,t,n)=>{const a=Nn,r=n+t;e^=-1;for(let l=n;l<r;l++)e=e>>>8^a[(e^i[l])&255];return e^-1},te={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},xe={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:On,_tr_stored_block:ut,_tr_flush_block:Un,_tr_tally:W,_tr_align:Fn}=Bn,{Z_NO_FLUSH:V,Z_PARTIAL_FLUSH:Zn,Z_FULL_FLUSH:$n,Z_FINISH:$,Z_BLOCK:ei,Z_OK:N,Z_STREAM_END:ti,Z_STREAM_ERROR:P,Z_DATA_ERROR:Mn,Z_BUF_ERROR:dt,Z_DEFAULT_COMPRESSION:Hn,Z_FILTERED:Pn,Z_HUFFMAN_ONLY:$e,Z_RLE:jn,Z_FIXED:Kn,Z_DEFAULT_STRATEGY:Xn,Z_UNKNOWN:Gn,Z_DEFLATED:Me}=xe,Yn=9,Wn=15,Vn=8,_t=256+1+29,Jn=30,qn=19,Qn=2*_t+1,ea=15,m=3,J=258,j=J+m+1,ta=32,he=42,wt=57,gt=69,bt=73,pt=91,yt=103,ie=113,Ae=666,O=1,ce=2,ne=3,ue=4,ia=3,ae=(e,i)=>(e.msg=te[i],i),ii=e=>e*2-(e>4?9:0),q=e=>{let i=e.length;for(;--i>=0;)e[i]=0},na=e=>{let i,t,n,a=e.w_size;i=e.hash_size,n=i;do t=e.head[--n],e.head[n]=t>=a?t-a:0;while(--i);i=a,n=i;do t=e.prev[--n],e.prev[n]=t>=a?t-a:0;while(--i)};let Q=(e,i,t)=>(i<<e.hash_shift^t)&e.hash_mask;const F=e=>{const i=e.state;let t=i.pending;t>e.avail_out&&(t=e.avail_out),t!==0&&(e.output.set(i.pending_buf.subarray(i.pending_out,i.pending_out+t),e.next_out),e.next_out+=t,i.pending_out+=t,e.total_out+=t,e.avail_out-=t,i.pending-=t,i.pending===0&&(i.pending_out=0))},Z=(e,i)=>{Un(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,i),e.block_start=e.strstart,F(e.strm)},A=(e,i)=>{e.pending_buf[e.pending++]=i},Ee=(e,i)=>{e.pending_buf[e.pending++]=i>>>8&255,e.pending_buf[e.pending++]=i&255},mt=(e,i,t,n)=>{let a=e.avail_in;return a>n&&(a=n),a===0?0:(e.avail_in-=a,i.set(e.input.subarray(e.next_in,e.next_in+a),t),e.state.wrap===1?e.adler=Se(e.adler,i,a,t):e.state.wrap===2&&(e.adler=B(e.adler,i,a,t)),e.next_in+=a,e.total_in+=a,a)},ni=(e,i)=>{let t=e.max_chain_length,n=e.strstart,a,r,l=e.prev_length,s=e.nice_match;const c=e.strstart>e.w_size-j?e.strstart-(e.w_size-j):0,o=e.window,f=e.w_mask,g=e.prev,u=e.strstart+J;let h=o[n+l-1],_=o[n+l];e.prev_length>=e.good_match&&(t>>=2),s>e.lookahead&&(s=e.lookahead);do if(a=i,!(o[a+l]!==_||o[a+l-1]!==h||o[a]!==o[n]||o[++a]!==o[n+1])){n+=2,a++;do;while(o[++n]===o[++a]&&o[++n]===o[++a]&&o[++n]===o[++a]&&o[++n]===o[++a]&&o[++n]===o[++a]&&o[++n]===o[++a]&&o[++n]===o[++a]&&o[++n]===o[++a]&&n<u);if(r=J-(u-n),n=u-J,r>l){if(e.match_start=i,l=r,r>=s)break;h=o[n+l-1],_=o[n+l]}}while((i=g[i&f])>c&&--t!==0);return l<=e.lookahead?l:e.lookahead},de=e=>{const i=e.w_size;let t,n,a;do{if(n=e.window_size-e.lookahead-e.strstart,e.strstart>=i+(i-j)&&(e.window.set(e.window.subarray(i,i+i-n),0),e.match_start-=i,e.strstart-=i,e.block_start-=i,e.insert>e.strstart&&(e.insert=e.strstart),na(e),n+=i),e.strm.avail_in===0)break;if(t=mt(e.strm,e.window,e.strstart+e.lookahead,n),e.lookahead+=t,e.lookahead+e.insert>=m)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=Q(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=Q(e,e.ins_h,e.window[a+m-1]),e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<m)););}while(e.lookahead<j&&e.strm.avail_in!==0)},ai=(e,i)=>{let t=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,n,a,r,l=0,s=e.strm.avail_in;do{if(n=65535,r=e.bi_valid+42>>3,e.strm.avail_out<r||(r=e.strm.avail_out-r,a=e.strstart-e.block_start,n>a+e.strm.avail_in&&(n=a+e.strm.avail_in),n>r&&(n=r),n<t&&(n===0&&i!==$||i===V||n!==a+e.strm.avail_in)))break;l=i===$&&n===a+e.strm.avail_in?1:0,ut(e,0,0,l),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,F(e.strm),a&&(a>n&&(a=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+a),e.strm.next_out),e.strm.next_out+=a,e.strm.avail_out-=a,e.strm.total_out+=a,e.block_start+=a,n-=a),n&&(mt(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(l===0);return s-=e.strm.avail_in,s&&(s>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=s&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-s,e.strm.next_in),e.strstart),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),l?ue:i!==V&&i!==$&&e.strm.avail_in===0&&e.strstart===e.block_start?ce:(r=e.window_size-e.strstart,e.strm.avail_in>r&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,r+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),r>e.strm.avail_in&&(r=e.strm.avail_in),r&&(mt(e.strm,e.window,e.strstart,r),e.strstart+=r,e.insert+=r>e.w_size-e.insert?e.w_size-e.insert:r),e.high_water<e.strstart&&(e.high_water=e.strstart),r=e.bi_valid+42>>3,r=e.pending_buf_size-r>65535?65535:e.pending_buf_size-r,t=r>e.w_size?e.w_size:r,a=e.strstart-e.block_start,(a>=t||(a||i===$)&&i!==V&&e.strm.avail_in===0&&a<=r)&&(n=a>r?r:a,l=i===$&&e.strm.avail_in===0&&n===a?1:0,ut(e,e.block_start,n,l),e.block_start+=n,F(e.strm)),l?ne:O)},vt=(e,i)=>{let t,n;for(;;){if(e.lookahead<j){if(de(e),e.lookahead<j&&i===V)return O;if(e.lookahead===0)break}if(t=0,e.lookahead>=m&&(e.ins_h=Q(e,e.ins_h,e.window[e.strstart+m-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),t!==0&&e.strstart-t<=e.w_size-j&&(e.match_length=ni(e,t)),e.match_length>=m)if(n=W(e,e.strstart-e.match_start,e.match_length-m),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=m){e.match_length--;do e.strstart++,e.ins_h=Q(e,e.ins_h,e.window[e.strstart+m-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Q(e,e.ins_h,e.window[e.strstart+1]);else n=W(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(Z(e,!1),e.strm.avail_out===0))return O}return e.insert=e.strstart<m-1?e.strstart:m-1,i===$?(Z(e,!0),e.strm.avail_out===0?ne:ue):e.sym_next&&(Z(e,!1),e.strm.avail_out===0)?O:ce},_e=(e,i)=>{let t,n,a;for(;;){if(e.lookahead<j){if(de(e),e.lookahead<j&&i===V)return O;if(e.lookahead===0)break}if(t=0,e.lookahead>=m&&(e.ins_h=Q(e,e.ins_h,e.window[e.strstart+m-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=m-1,t!==0&&e.prev_length<e.max_lazy_match&&e.strstart-t<=e.w_size-j&&(e.match_length=ni(e,t),e.match_length<=5&&(e.strategy===Pn||e.match_length===m&&e.strstart-e.match_start>4096)&&(e.match_length=m-1)),e.prev_length>=m&&e.match_length<=e.prev_length){a=e.strstart+e.lookahead-m,n=W(e,e.strstart-1-e.prev_match,e.prev_length-m),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=a&&(e.ins_h=Q(e,e.ins_h,e.window[e.strstart+m-1]),t=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=m-1,e.strstart++,n&&(Z(e,!1),e.strm.avail_out===0))return O}else if(e.match_available){if(n=W(e,0,e.window[e.strstart-1]),n&&Z(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return O}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=W(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<m-1?e.strstart:m-1,i===$?(Z(e,!0),e.strm.avail_out===0?ne:ue):e.sym_next&&(Z(e,!1),e.strm.avail_out===0)?O:ce},aa=(e,i)=>{let t,n,a,r;const l=e.window;for(;;){if(e.lookahead<=J){if(de(e),e.lookahead<=J&&i===V)return O;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=m&&e.strstart>0&&(a=e.strstart-1,n=l[a],n===l[++a]&&n===l[++a]&&n===l[++a])){r=e.strstart+J;do;while(n===l[++a]&&n===l[++a]&&n===l[++a]&&n===l[++a]&&n===l[++a]&&n===l[++a]&&n===l[++a]&&n===l[++a]&&a<r);e.match_length=J-(r-a),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=m?(t=W(e,1,e.match_length-m),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=W(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(Z(e,!1),e.strm.avail_out===0))return O}return e.insert=0,i===$?(Z(e,!0),e.strm.avail_out===0?ne:ue):e.sym_next&&(Z(e,!1),e.strm.avail_out===0)?O:ce},ra=(e,i)=>{let t;for(;;){if(e.lookahead===0&&(de(e),e.lookahead===0)){if(i===V)return O;break}if(e.match_length=0,t=W(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(Z(e,!1),e.strm.avail_out===0))return O}return e.insert=0,i===$?(Z(e,!0),e.strm.avail_out===0?ne:ue):e.sym_next&&(Z(e,!1),e.strm.avail_out===0)?O:ce};function K(e,i,t,n,a){this.good_length=e,this.max_lazy=i,this.nice_length=t,this.max_chain=n,this.func=a}const ke=[new K(0,0,0,0,ai),new K(4,4,8,4,vt),new K(4,5,16,8,vt),new K(4,6,32,32,vt),new K(4,4,16,16,_e),new K(8,16,32,32,_e),new K(8,16,128,128,_e),new K(8,32,128,256,_e),new K(32,128,258,1024,_e),new K(32,258,258,4096,_e)],la=e=>{e.window_size=2*e.w_size,q(e.head),e.max_lazy_match=ke[e.level].max_lazy,e.good_match=ke[e.level].good_length,e.nice_match=ke[e.level].nice_length,e.max_chain_length=ke[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=m-1,e.match_available=0,e.ins_h=0};function sa(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Me,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(Qn*2),this.dyn_dtree=new Uint16Array((2*Jn+1)*2),this.bl_tree=new Uint16Array((2*qn+1)*2),q(this.dyn_ltree),q(this.dyn_dtree),q(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(ea+1),this.heap=new Uint16Array(2*_t+1),q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*_t+1),q(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Te=e=>{if(!e)return 1;const i=e.state;return!i||i.strm!==e||i.status!==he&&i.status!==wt&&i.status!==gt&&i.status!==bt&&i.status!==pt&&i.status!==yt&&i.status!==ie&&i.status!==Ae?1:0},ri=e=>{if(Te(e))return ae(e,P);e.total_in=e.total_out=0,e.data_type=Gn;const i=e.state;return i.pending=0,i.pending_out=0,i.wrap<0&&(i.wrap=-i.wrap),i.status=i.wrap===2?wt:i.wrap?he:ie,e.adler=i.wrap===2?0:1,i.last_flush=-2,On(i),N},li=e=>{const i=ri(e);return i===N&&la(e.state),i},oa=(e,i)=>Te(e)||e.state.wrap!==2?P:(e.state.gzhead=i,N),si=(e,i,t,n,a,r)=>{if(!e)return P;let l=1;if(i===Hn&&(i=6),n<0?(l=0,n=-n):n>15&&(l=2,n-=16),a<1||a>Yn||t!==Me||n<8||n>15||i<0||i>9||r<0||r>Kn||n===8&&l!==1)return ae(e,P);n===8&&(n=9);const s=new sa;return e.state=s,s.strm=e,s.status=he,s.wrap=l,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=a+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+m-1)/m),s.window=new Uint8Array(s.w_size*2),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<a+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Uint8Array(s.pending_buf_size),s.sym_buf=s.lit_bufsize,s.sym_end=(s.lit_bufsize-1)*3,s.level=i,s.strategy=r,s.method=t,li(e)},fa=(e,i)=>si(e,i,Me,Wn,Vn,Xn),ha=(e,i)=>{if(Te(e)||i>ei||i<0)return e?ae(e,P):P;const t=e.state;if(!e.output||e.avail_in!==0&&!e.input||t.status===Ae&&i!==$)return ae(e,e.avail_out===0?dt:P);const n=t.last_flush;if(t.last_flush=i,t.pending!==0){if(F(e),e.avail_out===0)return t.last_flush=-1,N}else if(e.avail_in===0&&ii(i)<=ii(n)&&i!==$)return ae(e,dt);if(t.status===Ae&&e.avail_in!==0)return ae(e,dt);if(t.status===he&&t.wrap===0&&(t.status=ie),t.status===he){let a=Me+(t.w_bits-8<<4)<<8,r=-1;if(t.strategy>=$e||t.level<2?r=0:t.level<6?r=1:t.level===6?r=2:r=3,a|=r<<6,t.strstart!==0&&(a|=ta),a+=31-a%31,Ee(t,a),t.strstart!==0&&(Ee(t,e.adler>>>16),Ee(t,e.adler&65535)),e.adler=1,t.status=ie,F(e),t.pending!==0)return t.last_flush=-1,N}if(t.status===wt){if(e.adler=0,A(t,31),A(t,139),A(t,8),t.gzhead)A(t,(t.gzhead.text?1:0)+(t.gzhead.hcrc?2:0)+(t.gzhead.extra?4:0)+(t.gzhead.name?8:0)+(t.gzhead.comment?16:0)),A(t,t.gzhead.time&255),A(t,t.gzhead.time>>8&255),A(t,t.gzhead.time>>16&255),A(t,t.gzhead.time>>24&255),A(t,t.level===9?2:t.strategy>=$e||t.level<2?4:0),A(t,t.gzhead.os&255),t.gzhead.extra&&t.gzhead.extra.length&&(A(t,t.gzhead.extra.length&255),A(t,t.gzhead.extra.length>>8&255)),t.gzhead.hcrc&&(e.adler=B(e.adler,t.pending_buf,t.pending,0)),t.gzindex=0,t.status=gt;else if(A(t,0),A(t,0),A(t,0),A(t,0),A(t,0),A(t,t.level===9?2:t.strategy>=$e||t.level<2?4:0),A(t,ia),t.status=ie,F(e),t.pending!==0)return t.last_flush=-1,N}if(t.status===gt){if(t.gzhead.extra){let a=t.pending,r=(t.gzhead.extra.length&65535)-t.gzindex;for(;t.pending+r>t.pending_buf_size;){let s=t.pending_buf_size-t.pending;if(t.pending_buf.set(t.gzhead.extra.subarray(t.gzindex,t.gzindex+s),t.pending),t.pending=t.pending_buf_size,t.gzhead.hcrc&&t.pending>a&&(e.adler=B(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex+=s,F(e),t.pending!==0)return t.last_flush=-1,N;a=0,r-=s}let l=new Uint8Array(t.gzhead.extra);t.pending_buf.set(l.subarray(t.gzindex,t.gzindex+r),t.pending),t.pending+=r,t.gzhead.hcrc&&t.pending>a&&(e.adler=B(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex=0}t.status=bt}if(t.status===bt){if(t.gzhead.name){let a=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>a&&(e.adler=B(e.adler,t.pending_buf,t.pending-a,a)),F(e),t.pending!==0)return t.last_flush=-1,N;a=0}t.gzindex<t.gzhead.name.length?r=t.gzhead.name.charCodeAt(t.gzindex++)&255:r=0,A(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>a&&(e.adler=B(e.adler,t.pending_buf,t.pending-a,a)),t.gzindex=0}t.status=pt}if(t.status===pt){if(t.gzhead.comment){let a=t.pending,r;do{if(t.pending===t.pending_buf_size){if(t.gzhead.hcrc&&t.pending>a&&(e.adler=B(e.adler,t.pending_buf,t.pending-a,a)),F(e),t.pending!==0)return t.last_flush=-1,N;a=0}t.gzindex<t.gzhead.comment.length?r=t.gzhead.comment.charCodeAt(t.gzindex++)&255:r=0,A(t,r)}while(r!==0);t.gzhead.hcrc&&t.pending>a&&(e.adler=B(e.adler,t.pending_buf,t.pending-a,a))}t.status=yt}if(t.status===yt){if(t.gzhead.hcrc){if(t.pending+2>t.pending_buf_size&&(F(e),t.pending!==0))return t.last_flush=-1,N;A(t,e.adler&255),A(t,e.adler>>8&255),e.adler=0}if(t.status=ie,F(e),t.pending!==0)return t.last_flush=-1,N}if(e.avail_in!==0||t.lookahead!==0||i!==V&&t.status!==Ae){let a=t.level===0?ai(t,i):t.strategy===$e?ra(t,i):t.strategy===jn?aa(t,i):ke[t.level].func(t,i);if((a===ne||a===ue)&&(t.status=Ae),a===O||a===ne)return e.avail_out===0&&(t.last_flush=-1),N;if(a===ce&&(i===Zn?Fn(t):i!==ei&&(ut(t,0,0,!1),i===$n&&(q(t.head),t.lookahead===0&&(t.strstart=0,t.block_start=0,t.insert=0))),F(e),e.avail_out===0))return t.last_flush=-1,N}return i!==$?N:t.wrap<=0?ti:(t.wrap===2?(A(t,e.adler&255),A(t,e.adler>>8&255),A(t,e.adler>>16&255),A(t,e.adler>>24&255),A(t,e.total_in&255),A(t,e.total_in>>8&255),A(t,e.total_in>>16&255),A(t,e.total_in>>24&255)):(Ee(t,e.adler>>>16),Ee(t,e.adler&65535)),F(e),t.wrap>0&&(t.wrap=-t.wrap),t.pending!==0?N:ti)},ca=e=>{if(Te(e))return P;const i=e.state.status;return e.state=null,i===ie?ae(e,Mn):N},ua=(e,i)=>{let t=i.length;if(Te(e))return P;const n=e.state,a=n.wrap;if(a===2||a===1&&n.status!==he||n.lookahead)return P;if(a===1&&(e.adler=Se(e.adler,i,t,0)),n.wrap=0,t>=n.w_size){a===0&&(q(n.head),n.strstart=0,n.block_start=0,n.insert=0);let c=new Uint8Array(n.w_size);c.set(i.subarray(t-n.w_size,t),0),i=c,t=n.w_size}const r=e.avail_in,l=e.next_in,s=e.input;for(e.avail_in=t,e.next_in=0,e.input=i,de(n);n.lookahead>=m;){let c=n.strstart,o=n.lookahead-(m-1);do n.ins_h=Q(n,n.ins_h,n.window[c+m-1]),n.prev[c&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=c,c++;while(--o);n.strstart=c,n.lookahead=m-1,de(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=m-1,n.match_available=0,e.next_in=l,e.input=s,e.avail_in=r,n.wrap=a,N};var da=fa,_a=si,wa=li,ga=ri,ba=oa,pa=ha,ya=ca,ma=ua,va="pako deflate (from Nodeca project)",Ie={deflateInit:da,deflateInit2:_a,deflateReset:wa,deflateResetKeep:ga,deflateSetHeader:ba,deflate:pa,deflateEnd:ya,deflateSetDictionary:ma,deflateInfo:va};const Sa=(e,i)=>Object.prototype.hasOwnProperty.call(e,i);var xa=function(e){const i=Array.prototype.slice.call(arguments,1);for(;i.length;){const t=i.shift();if(t){if(typeof t!="object")throw new TypeError(t+"must be non-object");for(const n in t)Sa(t,n)&&(e[n]=t[n])}}return e},Aa=e=>{let i=0;for(let n=0,a=e.length;n<a;n++)i+=e[n].length;const t=new Uint8Array(i);for(let n=0,a=0,r=e.length;n<r;n++){let l=e[n];t.set(l,a),a+=l.length}return t},He={assign:xa,flattenChunks:Aa};let oi=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{oi=!1}const ze=new Uint8Array(256);for(let e=0;e<256;e++)ze[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ze[254]=ze[254]=1;var Ea=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let i,t,n,a,r,l=e.length,s=0;for(a=0;a<l;a++)t=e.charCodeAt(a),(t&64512)===55296&&a+1<l&&(n=e.charCodeAt(a+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),a++)),s+=t<128?1:t<2048?2:t<65536?3:4;for(i=new Uint8Array(s),r=0,a=0;r<s;a++)t=e.charCodeAt(a),(t&64512)===55296&&a+1<l&&(n=e.charCodeAt(a+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),a++)),t<128?i[r++]=t:t<2048?(i[r++]=192|t>>>6,i[r++]=128|t&63):t<65536?(i[r++]=224|t>>>12,i[r++]=128|t>>>6&63,i[r++]=128|t&63):(i[r++]=240|t>>>18,i[r++]=128|t>>>12&63,i[r++]=128|t>>>6&63,i[r++]=128|t&63);return i};const ka=(e,i)=>{if(i<65534&&e.subarray&&oi)return String.fromCharCode.apply(null,e.length===i?e:e.subarray(0,i));let t="";for(let n=0;n<i;n++)t+=String.fromCharCode(e[n]);return t};var Ta=(e,i)=>{const t=i||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,i));let n,a;const r=new Array(t*2);for(a=0,n=0;n<t;){let l=e[n++];if(l<128){r[a++]=l;continue}let s=ze[l];if(s>4){r[a++]=65533,n+=s-1;continue}for(l&=s===2?31:s===3?15:7;s>1&&n<t;)l=l<<6|e[n++]&63,s--;if(s>1){r[a++]=65533;continue}l<65536?r[a++]=l:(l-=65536,r[a++]=55296|l>>10&1023,r[a++]=56320|l&1023)}return ka(r,a)},Ia=(e,i)=>{i=i||e.length,i>e.length&&(i=e.length);let t=i-1;for(;t>=0&&(e[t]&192)===128;)t--;return t<0||t===0?i:t+ze[e[t]]>i?t:i},De={string2buf:Ea,buf2string:Ta,utf8border:Ia};function za(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var fi=za;const hi=Object.prototype.toString,{Z_NO_FLUSH:Da,Z_SYNC_FLUSH:Ra,Z_FULL_FLUSH:La,Z_FINISH:Ba,Z_OK:Pe,Z_STREAM_END:Ca,Z_DEFAULT_COMPRESSION:Na,Z_DEFAULT_STRATEGY:Oa,Z_DEFLATED:Ua}=xe;function Re(e){this.options=He.assign({level:Na,method:Ua,chunkSize:16384,windowBits:15,memLevel:8,strategy:Oa},e||{});let i=this.options;i.raw&&i.windowBits>0?i.windowBits=-i.windowBits:i.gzip&&i.windowBits>0&&i.windowBits<16&&(i.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new fi,this.strm.avail_out=0;let t=Ie.deflateInit2(this.strm,i.level,i.method,i.windowBits,i.memLevel,i.strategy);if(t!==Pe)throw new Error(te[t]);if(i.header&&Ie.deflateSetHeader(this.strm,i.header),i.dictionary){let n;if(typeof i.dictionary=="string"?n=De.string2buf(i.dictionary):hi.call(i.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(i.dictionary):n=i.dictionary,t=Ie.deflateSetDictionary(this.strm,n),t!==Pe)throw new Error(te[t]);this._dict_set=!0}}Re.prototype.push=function(e,i){const t=this.strm,n=this.options.chunkSize;let a,r;if(this.ended)return!1;for(i===~~i?r=i:r=i===!0?Ba:Da,typeof e=="string"?t.input=De.string2buf(e):hi.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){if(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),(r===Ra||r===La)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(a=Ie.deflate(t,r),a===Ca)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),a=Ie.deflateEnd(this.strm),this.onEnd(a),this.ended=!0,a===Pe;if(t.avail_out===0){this.onData(t.output);continue}if(r>0&&t.next_out>0){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(t.avail_in===0)break}return!0},Re.prototype.onData=function(e){this.chunks.push(e)},Re.prototype.onEnd=function(e){e===Pe&&(this.result=He.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function St(e,i){const t=new Re(i);if(t.push(e,!0),t.err)throw t.msg||te[t.err];return t.result}function Fa(e,i){return i=i||{},i.raw=!0,St(e,i)}function Za(e,i){return i=i||{},i.gzip=!0,St(e,i)}var $a=Re,Ma=St,Ha=Fa,Pa=Za,ja={Deflate:$a,deflate:Ma,deflateRaw:Ha,gzip:Pa};const je=16209,Ka=16191;var Xa=function(i,t){let n,a,r,l,s,c,o,f,g,u,h,_,z,S,p,k,y,d,E,C,w,T,x,b;const v=i.state;n=i.next_in,x=i.input,a=n+(i.avail_in-5),r=i.next_out,b=i.output,l=r-(t-i.avail_out),s=r+(i.avail_out-257),c=v.dmax,o=v.wsize,f=v.whave,g=v.wnext,u=v.window,h=v.hold,_=v.bits,z=v.lencode,S=v.distcode,p=(1<<v.lenbits)-1,k=(1<<v.distbits)-1;e:do{_<15&&(h+=x[n++]<<_,_+=8,h+=x[n++]<<_,_+=8),y=z[h&p];t:for(;;){if(d=y>>>24,h>>>=d,_-=d,d=y>>>16&255,d===0)b[r++]=y&65535;else if(d&16){E=y&65535,d&=15,d&&(_<d&&(h+=x[n++]<<_,_+=8),E+=h&(1<<d)-1,h>>>=d,_-=d),_<15&&(h+=x[n++]<<_,_+=8,h+=x[n++]<<_,_+=8),y=S[h&k];i:for(;;){if(d=y>>>24,h>>>=d,_-=d,d=y>>>16&255,d&16){if(C=y&65535,d&=15,_<d&&(h+=x[n++]<<_,_+=8,_<d&&(h+=x[n++]<<_,_+=8)),C+=h&(1<<d)-1,C>c){i.msg="invalid distance too far back",v.mode=je;break e}if(h>>>=d,_-=d,d=r-l,C>d){if(d=C-d,d>f&&v.sane){i.msg="invalid distance too far back",v.mode=je;break e}if(w=0,T=u,g===0){if(w+=o-d,d<E){E-=d;do b[r++]=u[w++];while(--d);w=r-C,T=b}}else if(g<d){if(w+=o+g-d,d-=g,d<E){E-=d;do b[r++]=u[w++];while(--d);if(w=0,g<E){d=g,E-=d;do b[r++]=u[w++];while(--d);w=r-C,T=b}}}else if(w+=g-d,d<E){E-=d;do b[r++]=u[w++];while(--d);w=r-C,T=b}for(;E>2;)b[r++]=T[w++],b[r++]=T[w++],b[r++]=T[w++],E-=3;E&&(b[r++]=T[w++],E>1&&(b[r++]=T[w++]))}else{w=r-C;do b[r++]=b[w++],b[r++]=b[w++],b[r++]=b[w++],E-=3;while(E>2);E&&(b[r++]=b[w++],E>1&&(b[r++]=b[w++]))}}else if(d&64){i.msg="invalid distance code",v.mode=je;break e}else{y=S[(y&65535)+(h&(1<<d)-1)];continue i}break}}else if(d&64)if(d&32){v.mode=Ka;break e}else{i.msg="invalid literal/length code",v.mode=je;break e}else{y=z[(y&65535)+(h&(1<<d)-1)];continue t}break}}while(n<a&&r<s);E=_>>3,n-=E,_-=E<<3,h&=(1<<_)-1,i.next_in=n,i.next_out=r,i.avail_in=n<a?5+(a-n):5-(n-a),i.avail_out=r<s?257+(s-r):257-(r-s),v.hold=h,v.bits=_};const we=15,ci=852,ui=592,di=0,xt=1,_i=2,Ga=new Uint16Array([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]),Ya=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Wa=new Uint16Array([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,0,0]),Va=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Le=(e,i,t,n,a,r,l,s)=>{const c=s.bits;let o=0,f=0,g=0,u=0,h=0,_=0,z=0,S=0,p=0,k=0,y,d,E,C,w,T=null,x;const b=new Uint16Array(we+1),v=new Uint16Array(we+1);let se=null,hn,et,tt;for(o=0;o<=we;o++)b[o]=0;for(f=0;f<n;f++)b[i[t+f]]++;for(h=c,u=we;u>=1&&b[u]===0;u--);if(h>u&&(h=u),u===0)return a[r++]=1<<24|64<<16|0,a[r++]=1<<24|64<<16|0,s.bits=1,0;for(g=1;g<u&&b[g]===0;g++);for(h<g&&(h=g),S=1,o=1;o<=we;o++)if(S<<=1,S-=b[o],S<0)return-1;if(S>0&&(e===di||u!==1))return-1;for(v[1]=0,o=1;o<we;o++)v[o+1]=v[o]+b[o];for(f=0;f<n;f++)i[t+f]!==0&&(l[v[i[t+f]]++]=f);if(e===di?(T=se=l,x=20):e===xt?(T=Ga,se=Ya,x=257):(T=Wa,se=Va,x=0),k=0,f=0,o=g,w=r,_=h,z=0,E=-1,p=1<<h,C=p-1,e===xt&&p>ci||e===_i&&p>ui)return 1;for(;;){hn=o-z,l[f]+1<x?(et=0,tt=l[f]):l[f]>=x?(et=se[l[f]-x],tt=T[l[f]-x]):(et=96,tt=0),y=1<<o-z,d=1<<_,g=d;do d-=y,a[w+(k>>z)+d]=hn<<24|et<<16|tt|0;while(d!==0);for(y=1<<o-1;k&y;)y>>=1;if(y!==0?(k&=y-1,k+=y):k=0,f++,--b[o]===0){if(o===u)break;o=i[t+l[f]]}if(o>h&&(k&C)!==E){for(z===0&&(z=h),w+=g,_=o-z,S=1<<_;_+z<u&&(S-=b[_+z],!(S<=0));)_++,S<<=1;if(p+=1<<_,e===xt&&p>ci||e===_i&&p>ui)return 1;E=k&C,a[E]=h<<24|_<<16|w-r|0}}return k!==0&&(a[w+k]=o-z<<24|64<<16|0),s.bits=h,0};const Ja=0,wi=1,gi=2,{Z_FINISH:bi,Z_BLOCK:qa,Z_TREES:Ke,Z_OK:re,Z_STREAM_END:Qa,Z_NEED_DICT:er,Z_STREAM_ERROR:M,Z_DATA_ERROR:pi,Z_MEM_ERROR:yi,Z_BUF_ERROR:tr,Z_DEFLATED:mi}=xe,Xe=16180,vi=16181,Si=16182,xi=16183,Ai=16184,Ei=16185,ki=16186,Ti=16187,Ii=16188,zi=16189,Ge=16190,G=16191,At=16192,Di=16193,Et=16194,Ri=16195,Li=16196,Bi=16197,Ci=16198,Ye=16199,We=16200,Ni=16201,Oi=16202,Ui=16203,Fi=16204,Zi=16205,kt=16206,$i=16207,Mi=16208,R=16209,Hi=16210,Pi=16211,ir=852,nr=592,ar=15,ji=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function rr(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const le=e=>{if(!e)return 1;const i=e.state;return!i||i.strm!==e||i.mode<Xe||i.mode>Pi?1:0},Ki=e=>{if(le(e))return M;const i=e.state;return e.total_in=e.total_out=i.total=0,e.msg="",i.wrap&&(e.adler=i.wrap&1),i.mode=Xe,i.last=0,i.havedict=0,i.flags=-1,i.dmax=32768,i.head=null,i.hold=0,i.bits=0,i.lencode=i.lendyn=new Int32Array(ir),i.distcode=i.distdyn=new Int32Array(nr),i.sane=1,i.back=-1,re},Xi=e=>{if(le(e))return M;const i=e.state;return i.wsize=0,i.whave=0,i.wnext=0,Ki(e)},Gi=(e,i)=>{let t;if(le(e))return M;const n=e.state;return i<0?(t=0,i=-i):(t=(i>>4)+5,i<48&&(i&=15)),i&&(i<8||i>15)?M:(n.window!==null&&n.wbits!==i&&(n.window=null),n.wrap=t,n.wbits=i,Xi(e))},Yi=(e,i)=>{if(!e)return M;const t=new rr;e.state=t,t.strm=e,t.window=null,t.mode=Xe;const n=Gi(e,i);return n!==re&&(e.state=null),n},lr=e=>Yi(e,ar);let Wi=!0,Tt,It;const sr=e=>{if(Wi){Tt=new Int32Array(512),It=new Int32Array(32);let i=0;for(;i<144;)e.lens[i++]=8;for(;i<256;)e.lens[i++]=9;for(;i<280;)e.lens[i++]=7;for(;i<288;)e.lens[i++]=8;for(Le(wi,e.lens,0,288,Tt,0,e.work,{bits:9}),i=0;i<32;)e.lens[i++]=5;Le(gi,e.lens,0,32,It,0,e.work,{bits:5}),Wi=!1}e.lencode=Tt,e.lenbits=9,e.distcode=It,e.distbits=5},Vi=(e,i,t,n)=>{let a;const r=e.state;return r.window===null&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),n>=r.wsize?(r.window.set(i.subarray(t-r.wsize,t),0),r.wnext=0,r.whave=r.wsize):(a=r.wsize-r.wnext,a>n&&(a=n),r.window.set(i.subarray(t-n,t-n+a),r.wnext),n-=a,n?(r.window.set(i.subarray(t-n,t),0),r.wnext=n,r.whave=r.wsize):(r.wnext+=a,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=a))),0},or=(e,i)=>{let t,n,a,r,l,s,c,o,f,g,u,h,_,z,S=0,p,k,y,d,E,C,w,T;const x=new Uint8Array(4);let b,v;const se=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(le(e)||!e.output||!e.input&&e.avail_in!==0)return M;t=e.state,t.mode===G&&(t.mode=At),l=e.next_out,a=e.output,c=e.avail_out,r=e.next_in,n=e.input,s=e.avail_in,o=t.hold,f=t.bits,g=s,u=c,T=re;e:for(;;)switch(t.mode){case Xe:if(t.wrap===0){t.mode=At;break}for(;f<16;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(t.wrap&2&&o===35615){t.wbits===0&&(t.wbits=15),t.check=0,x[0]=o&255,x[1]=o>>>8&255,t.check=B(t.check,x,2,0),o=0,f=0,t.mode=vi;break}if(t.head&&(t.head.done=!1),!(t.wrap&1)||(((o&255)<<8)+(o>>8))%31){e.msg="incorrect header check",t.mode=R;break}if((o&15)!==mi){e.msg="unknown compression method",t.mode=R;break}if(o>>>=4,f-=4,w=(o&15)+8,t.wbits===0&&(t.wbits=w),w>15||w>t.wbits){e.msg="invalid window size",t.mode=R;break}t.dmax=1<<t.wbits,t.flags=0,e.adler=t.check=1,t.mode=o&512?zi:G,o=0,f=0;break;case vi:for(;f<16;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(t.flags=o,(t.flags&255)!==mi){e.msg="unknown compression method",t.mode=R;break}if(t.flags&57344){e.msg="unknown header flags set",t.mode=R;break}t.head&&(t.head.text=o>>8&1),t.flags&512&&t.wrap&4&&(x[0]=o&255,x[1]=o>>>8&255,t.check=B(t.check,x,2,0)),o=0,f=0,t.mode=Si;case Si:for(;f<32;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}t.head&&(t.head.time=o),t.flags&512&&t.wrap&4&&(x[0]=o&255,x[1]=o>>>8&255,x[2]=o>>>16&255,x[3]=o>>>24&255,t.check=B(t.check,x,4,0)),o=0,f=0,t.mode=xi;case xi:for(;f<16;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}t.head&&(t.head.xflags=o&255,t.head.os=o>>8),t.flags&512&&t.wrap&4&&(x[0]=o&255,x[1]=o>>>8&255,t.check=B(t.check,x,2,0)),o=0,f=0,t.mode=Ai;case Ai:if(t.flags&1024){for(;f<16;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}t.length=o,t.head&&(t.head.extra_len=o),t.flags&512&&t.wrap&4&&(x[0]=o&255,x[1]=o>>>8&255,t.check=B(t.check,x,2,0)),o=0,f=0}else t.head&&(t.head.extra=null);t.mode=Ei;case Ei:if(t.flags&1024&&(h=t.length,h>s&&(h=s),h&&(t.head&&(w=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(n.subarray(r,r+h),w)),t.flags&512&&t.wrap&4&&(t.check=B(t.check,n,h,r)),s-=h,r+=h,t.length-=h),t.length))break e;t.length=0,t.mode=ki;case ki:if(t.flags&2048){if(s===0)break e;h=0;do w=n[r+h++],t.head&&w&&t.length<65536&&(t.head.name+=String.fromCharCode(w));while(w&&h<s);if(t.flags&512&&t.wrap&4&&(t.check=B(t.check,n,h,r)),s-=h,r+=h,w)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=Ti;case Ti:if(t.flags&4096){if(s===0)break e;h=0;do w=n[r+h++],t.head&&w&&t.length<65536&&(t.head.comment+=String.fromCharCode(w));while(w&&h<s);if(t.flags&512&&t.wrap&4&&(t.check=B(t.check,n,h,r)),s-=h,r+=h,w)break e}else t.head&&(t.head.comment=null);t.mode=Ii;case Ii:if(t.flags&512){for(;f<16;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(t.wrap&4&&o!==(t.check&65535)){e.msg="header crc mismatch",t.mode=R;break}o=0,f=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=G;break;case zi:for(;f<32;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}e.adler=t.check=ji(o),o=0,f=0,t.mode=Ge;case Ge:if(t.havedict===0)return e.next_out=l,e.avail_out=c,e.next_in=r,e.avail_in=s,t.hold=o,t.bits=f,er;e.adler=t.check=1,t.mode=G;case G:if(i===qa||i===Ke)break e;case At:if(t.last){o>>>=f&7,f-=f&7,t.mode=kt;break}for(;f<3;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}switch(t.last=o&1,o>>>=1,f-=1,o&3){case 0:t.mode=Di;break;case 1:if(sr(t),t.mode=Ye,i===Ke){o>>>=2,f-=2;break e}break;case 2:t.mode=Li;break;case 3:e.msg="invalid block type",t.mode=R}o>>>=2,f-=2;break;case Di:for(o>>>=f&7,f-=f&7;f<32;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if((o&65535)!==(o>>>16^65535)){e.msg="invalid stored block lengths",t.mode=R;break}if(t.length=o&65535,o=0,f=0,t.mode=Et,i===Ke)break e;case Et:t.mode=Ri;case Ri:if(h=t.length,h){if(h>s&&(h=s),h>c&&(h=c),h===0)break e;a.set(n.subarray(r,r+h),l),s-=h,r+=h,c-=h,l+=h,t.length-=h;break}t.mode=G;break;case Li:for(;f<14;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(t.nlen=(o&31)+257,o>>>=5,f-=5,t.ndist=(o&31)+1,o>>>=5,f-=5,t.ncode=(o&15)+4,o>>>=4,f-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=R;break}t.have=0,t.mode=Bi;case Bi:for(;t.have<t.ncode;){for(;f<3;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}t.lens[se[t.have++]]=o&7,o>>>=3,f-=3}for(;t.have<19;)t.lens[se[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,b={bits:t.lenbits},T=Le(Ja,t.lens,0,19,t.lencode,0,t.work,b),t.lenbits=b.bits,T){e.msg="invalid code lengths set",t.mode=R;break}t.have=0,t.mode=Ci;case Ci:for(;t.have<t.nlen+t.ndist;){for(;S=t.lencode[o&(1<<t.lenbits)-1],p=S>>>24,k=S>>>16&255,y=S&65535,!(p<=f);){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(y<16)o>>>=p,f-=p,t.lens[t.have++]=y;else{if(y===16){for(v=p+2;f<v;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(o>>>=p,f-=p,t.have===0){e.msg="invalid bit length repeat",t.mode=R;break}w=t.lens[t.have-1],h=3+(o&3),o>>>=2,f-=2}else if(y===17){for(v=p+3;f<v;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}o>>>=p,f-=p,w=0,h=3+(o&7),o>>>=3,f-=3}else{for(v=p+7;f<v;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}o>>>=p,f-=p,w=0,h=11+(o&127),o>>>=7,f-=7}if(t.have+h>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=R;break}for(;h--;)t.lens[t.have++]=w}}if(t.mode===R)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=R;break}if(t.lenbits=9,b={bits:t.lenbits},T=Le(wi,t.lens,0,t.nlen,t.lencode,0,t.work,b),t.lenbits=b.bits,T){e.msg="invalid literal/lengths set",t.mode=R;break}if(t.distbits=6,t.distcode=t.distdyn,b={bits:t.distbits},T=Le(gi,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,b),t.distbits=b.bits,T){e.msg="invalid distances set",t.mode=R;break}if(t.mode=Ye,i===Ke)break e;case Ye:t.mode=We;case We:if(s>=6&&c>=258){e.next_out=l,e.avail_out=c,e.next_in=r,e.avail_in=s,t.hold=o,t.bits=f,Xa(e,u),l=e.next_out,a=e.output,c=e.avail_out,r=e.next_in,n=e.input,s=e.avail_in,o=t.hold,f=t.bits,t.mode===G&&(t.back=-1);break}for(t.back=0;S=t.lencode[o&(1<<t.lenbits)-1],p=S>>>24,k=S>>>16&255,y=S&65535,!(p<=f);){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(k&&!(k&240)){for(d=p,E=k,C=y;S=t.lencode[C+((o&(1<<d+E)-1)>>d)],p=S>>>24,k=S>>>16&255,y=S&65535,!(d+p<=f);){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}o>>>=d,f-=d,t.back+=d}if(o>>>=p,f-=p,t.back+=p,t.length=y,k===0){t.mode=Zi;break}if(k&32){t.back=-1,t.mode=G;break}if(k&64){e.msg="invalid literal/length code",t.mode=R;break}t.extra=k&15,t.mode=Ni;case Ni:if(t.extra){for(v=t.extra;f<v;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}t.length+=o&(1<<t.extra)-1,o>>>=t.extra,f-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=Oi;case Oi:for(;S=t.distcode[o&(1<<t.distbits)-1],p=S>>>24,k=S>>>16&255,y=S&65535,!(p<=f);){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(!(k&240)){for(d=p,E=k,C=y;S=t.distcode[C+((o&(1<<d+E)-1)>>d)],p=S>>>24,k=S>>>16&255,y=S&65535,!(d+p<=f);){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}o>>>=d,f-=d,t.back+=d}if(o>>>=p,f-=p,t.back+=p,k&64){e.msg="invalid distance code",t.mode=R;break}t.offset=y,t.extra=k&15,t.mode=Ui;case Ui:if(t.extra){for(v=t.extra;f<v;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}t.offset+=o&(1<<t.extra)-1,o>>>=t.extra,f-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=R;break}t.mode=Fi;case Fi:if(c===0)break e;if(h=u-c,t.offset>h){if(h=t.offset-h,h>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=R;break}h>t.wnext?(h-=t.wnext,_=t.wsize-h):_=t.wnext-h,h>t.length&&(h=t.length),z=t.window}else z=a,_=l-t.offset,h=t.length;h>c&&(h=c),c-=h,t.length-=h;do a[l++]=z[_++];while(--h);t.length===0&&(t.mode=We);break;case Zi:if(c===0)break e;a[l++]=t.length,c--,t.mode=We;break;case kt:if(t.wrap){for(;f<32;){if(s===0)break e;s--,o|=n[r++]<<f,f+=8}if(u-=c,e.total_out+=u,t.total+=u,t.wrap&4&&u&&(e.adler=t.check=t.flags?B(t.check,a,u,l-u):Se(t.check,a,u,l-u)),u=c,t.wrap&4&&(t.flags?o:ji(o))!==t.check){e.msg="incorrect data check",t.mode=R;break}o=0,f=0}t.mode=$i;case $i:if(t.wrap&&t.flags){for(;f<32;){if(s===0)break e;s--,o+=n[r++]<<f,f+=8}if(t.wrap&4&&o!==(t.total&4294967295)){e.msg="incorrect length check",t.mode=R;break}o=0,f=0}t.mode=Mi;case Mi:T=Qa;break e;case R:T=pi;break e;case Hi:return yi;case Pi:default:return M}return e.next_out=l,e.avail_out=c,e.next_in=r,e.avail_in=s,t.hold=o,t.bits=f,(t.wsize||u!==e.avail_out&&t.mode<R&&(t.mode<kt||i!==bi))&&Vi(e,e.output,e.next_out,u-e.avail_out),g-=e.avail_in,u-=e.avail_out,e.total_in+=g,e.total_out+=u,t.total+=u,t.wrap&4&&u&&(e.adler=t.check=t.flags?B(t.check,a,u,e.next_out-u):Se(t.check,a,u,e.next_out-u)),e.data_type=t.bits+(t.last?64:0)+(t.mode===G?128:0)+(t.mode===Ye||t.mode===Et?256:0),(g===0&&u===0||i===bi)&&T===re&&(T=tr),T},fr=e=>{if(le(e))return M;let i=e.state;return i.window&&(i.window=null),e.state=null,re},hr=(e,i)=>{if(le(e))return M;const t=e.state;return t.wrap&2?(t.head=i,i.done=!1,re):M},cr=(e,i)=>{const t=i.length;let n,a,r;return le(e)||(n=e.state,n.wrap!==0&&n.mode!==Ge)?M:n.mode===Ge&&(a=1,a=Se(a,i,t,0),a!==n.check)?pi:(r=Vi(e,i,t,t),r?(n.mode=Hi,yi):(n.havedict=1,re))};var ur=Xi,dr=Gi,_r=Ki,wr=lr,gr=Yi,br=or,pr=fr,yr=hr,mr=cr,vr="pako inflate (from Nodeca project)",Y={inflateReset:ur,inflateReset2:dr,inflateResetKeep:_r,inflateInit:wr,inflateInit2:gr,inflate:br,inflateEnd:pr,inflateGetHeader:yr,inflateSetDictionary:mr,inflateInfo:vr};function Sr(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var xr=Sr;const Ji=Object.prototype.toString,{Z_NO_FLUSH:Ar,Z_FINISH:Er,Z_OK:Be,Z_STREAM_END:zt,Z_NEED_DICT:Dt,Z_STREAM_ERROR:kr,Z_DATA_ERROR:qi,Z_MEM_ERROR:Tr}=xe;function Ce(e){this.options=He.assign({chunkSize:65536,windowBits:15,to:""},e||{});const i=this.options;i.raw&&i.windowBits>=0&&i.windowBits<16&&(i.windowBits=-i.windowBits,i.windowBits===0&&(i.windowBits=-15)),i.windowBits>=0&&i.windowBits<16&&!(e&&e.windowBits)&&(i.windowBits+=32),i.windowBits>15&&i.windowBits<48&&(i.windowBits&15||(i.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new fi,this.strm.avail_out=0;let t=Y.inflateInit2(this.strm,i.windowBits);if(t!==Be)throw new Error(te[t]);if(this.header=new xr,Y.inflateGetHeader(this.strm,this.header),i.dictionary&&(typeof i.dictionary=="string"?i.dictionary=De.string2buf(i.dictionary):Ji.call(i.dictionary)==="[object ArrayBuffer]"&&(i.dictionary=new Uint8Array(i.dictionary)),i.raw&&(t=Y.inflateSetDictionary(this.strm,i.dictionary),t!==Be)))throw new Error(te[t])}Ce.prototype.push=function(e,i){const t=this.strm,n=this.options.chunkSize,a=this.options.dictionary;let r,l,s;if(this.ended)return!1;for(i===~~i?l=i:l=i===!0?Er:Ar,Ji.call(e)==="[object ArrayBuffer]"?t.input=new Uint8Array(e):t.input=e,t.next_in=0,t.avail_in=t.input.length;;){for(t.avail_out===0&&(t.output=new Uint8Array(n),t.next_out=0,t.avail_out=n),r=Y.inflate(t,l),r===Dt&&a&&(r=Y.inflateSetDictionary(t,a),r===Be?r=Y.inflate(t,l):r===qi&&(r=Dt));t.avail_in>0&&r===zt&&t.state.wrap>0&&e[t.next_in]!==0;)Y.inflateReset(t),r=Y.inflate(t,l);switch(r){case kr:case qi:case Dt:case Tr:return this.onEnd(r),this.ended=!0,!1}if(s=t.avail_out,t.next_out&&(t.avail_out===0||r===zt))if(this.options.to==="string"){let c=De.utf8border(t.output,t.next_out),o=t.next_out-c,f=De.buf2string(t.output,c);t.next_out=o,t.avail_out=n-o,o&&t.output.set(t.output.subarray(c,c+o),0),this.onData(f)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(r===Be&&s===0)){if(r===zt)return r=Y.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(t.avail_in===0)break}}return!0},Ce.prototype.onData=function(e){this.chunks.push(e)},Ce.prototype.onEnd=function(e){e===Be&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=He.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Rt(e,i){const t=new Ce(i);if(t.push(e),t.err)throw t.msg||te[t.err];return t.result}function Ir(e,i){return i=i||{},i.raw=!0,Rt(e,i)}var zr=Ce,Dr=Rt,Rr=Ir,Lr=Rt,Br={Inflate:zr,inflate:Dr,inflateRaw:Rr,ungzip:Lr};const{Deflate:Cr,deflate:Nr,deflateRaw:Or,gzip:Ur}=ja,{Inflate:Fr,inflate:Zr,inflateRaw:$r,ungzip:Mr}=Br;var Hr=Cr,Pr=Nr,jr=Or,Kr=Ur,Xr=Fr,Gr=Zr,Yr=$r,Wr=Mr,Vr=xe,Qi={Deflate:Hr,deflate:Pr,deflateRaw:jr,gzip:Kr,Inflate:Xr,inflate:Gr,inflateRaw:Yr,ungzip:Wr,constants:Vr};const en="2.0.0";function Ne(e){return Uint8Array.from(e,i=>i.charCodeAt(0))}async function Ve(e,i="binary"){return typeof Buffer=="function"?Buffer.from(e).toString(i):await new Promise(t=>{const n=new FileReader;n.onloadend=()=>t(n.result);const a=new ArrayBuffer(e.byteLength);new Uint8Array(a).set(e);const r=new Blob([a]);i==="binary"?n.readAsBinaryString(r):n.readAsText(r,i)})}function Jr(e){const i=Ne(e),t=new ArrayBuffer(i.byteLength);return new Uint8Array(t).set(i),t}const tn=typeof Buffer=="function";let Je;function nn(){if(Je===void 0)try{Je=require("zlib")}catch{Je=null}return Je??null}function qr(e){if(tn)return Buffer.from(e).toString("base64");let i="";for(let t=0;t<e.length;t++)i+=String.fromCharCode(e[t]);return btoa(i)}function Qr(e){if(tn)return Buffer.from(e,"base64");const i=atob(e),t=new Uint8Array(i.length);for(let n=0;n<i.length;n++)t[n]=i.charCodeAt(n);return t}function el(e){const i=typeof e=="string"?Ne(e):e,t=nn();if(t!=null){const n=t.deflateSync(i);return new Uint8Array(n)}return Qi.deflate(i)}function tl(e){const i=nn();if(i!=null){const t=i.inflateSync(e);return new Uint8Array(t)}return Qi.inflate(e)}function qe(e){const i=el(e);return qr(i)}function Qe(e){const i=Qr(e);return tl(i)}class I extends Error{constructor(i,t=null,n=!1){if(t==="fail"||t==="FAIL"||t==="EXIT")try{i=new TextDecoder().decode(Qe(i))}catch{i=`decode [${i}] error`}else t!==null&&(i=`[TrzszError] ${t}: ${i}`);super(i),Object.setPrototypeOf(this,I.prototype),typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,I),this.name="TrzszError",this.type=t,this.trace=n}isTraceBack(){return this.type==="fail"||this.type==="EXIT"?!1:this.trace}isRemoteExit(){return this.type==="EXIT"}isRemoteFail(){return this.type==="fail"||this.type==="FAIL"}isStopAndDelete(){return this.type!=="fail"?!1:this.message==="Stopped and deleted"}static getErrorMessage(i){return i instanceof I&&!i.isTraceBack()?i.message:typeof i.stack=="string"&&i.stack.length>0?i.stack.replace("TrzszError: ",""):i.toString()}}function il(e){const i=new Set;for(const t of e){const n=t.getRelPath().join("/");if(i.has(n))throw new I(`Duplicate name: ${n}`);i.add(n)}}function nl(e,i){if(!Array.isArray(e))return!1;for(const t of e)switch(i){case"string":if(typeof t!="string")return!1;break;case"number":if(typeof t!="number")return!1;break;case"boolean":if(typeof t!="boolean")return!1;break;case"object":if(typeof t!="object")return!1;break;case"function":if(typeof t!="function")return!1;break;case"undefined":if(typeof t<"u")return!1;break;default:return!1}return!0}function Lt(e){return e>=97&&e<=122||e>=65&&e<=90}function al(e){let i;if(typeof e=="string")i=Ne(e);else if(e instanceof ArrayBuffer)i=new Uint8Array(e);else if(e instanceof Uint8Array)i=e;else return e;const t=new Uint8Array(i.length);let n=!1,a=0;for(let l=0;l<i.length;l++){const s=i[l];n?Lt(s)&&(n=!1):s===27?n=!0:t[a++]=s}for(;a>0;){const l=t[a-1];if(l!==13&&l!==10)break;a--}const r=t.subarray(0,a);return r.length>100?e:String.fromCharCode.apply(null,Array.from(r))}const an={NoTmux:0,TmuxNormalMode:1,TmuxControlMode:2};function rl(e,i){let t=`Saved ${e.length} ${e.length>1?"files/directories":"file/directory"}`;return i.length>0&&(t+=` to ${i}`),[t].concat(e).join(`\r
|
|
2
|
+
- `)}function rn(e){for(;;){const i=e.indexOf("\x1BP=");if(i<0)return e;let t=i+3;const n=e.substring(t).indexOf("\x1BP=");if(n<0)return e.substring(0,i);t+=n+3;const a=e.substring(t).indexOf("\x1B\\");if(a<0)return e.substring(0,i);t+=a+2,e=e.substring(0,i)+e.substring(t)}}function ll(e){return e>=97&&e<=122||e>=65&&e<=90||e>=48&&e<=57||e===35||e===58||e===43||e===47||e===61}class ln{constructor(){this.bufArray=[],this.resolve=null,this.reject=null,this.bufHead=0,this.bufTail=0,this.nextIdx=0,this.nextBuf=null,this.arrBuf=new ArrayBuffer(128)}addBuffer(i){this.bufArray[this.bufTail++]=i,this.resolve!=null&&(this.resolve(),this.resolve=null,this.reject=null)}stopBuffer(){this.reject!=null&&(this.reject(new I("Stopped")),this.reject=null,this.resolve=null)}drainBuffer(){this.bufArray=[],this.bufHead=0,this.bufTail=0}async toUint8Array(i){if(typeof i=="string")return Ne(i);if(i instanceof ArrayBuffer)return new Uint8Array(i);if(i instanceof Uint8Array)return i;if(i instanceof Blob){const t=await i.arrayBuffer();return new Uint8Array(t)}else throw new I("The buffer type is not supported",null,!0)}async nextBuffer(){if(this.nextBuf!=null&&this.nextIdx<this.nextBuf.length)return this.nextBuf.subarray(this.nextIdx);this.bufHead===this.bufTail&&(this.bufHead!==0&&(this.bufHead=0,this.bufTail=0),await new Promise((t,n)=>{this.resolve=t,this.reject=n}));const i=this.bufArray[this.bufHead];if(this.bufArray[this.bufHead]=null,this.bufHead++,i==null)throw new I("Unexpected null buffer");return this.nextBuf=await this.toUint8Array(i),this.nextIdx=0,this.nextBuf}growBuffer(i,t,n){const a=Math.max(i.length*2,t+n);this.arrBuf=new ArrayBuffer(a);const r=new Uint8Array(this.arrBuf);return r.set(i.subarray(0,t)),r}appendBuffer(i,t,n){const a=i.length>=t+n.length?i:this.growBuffer(i,t,n.length);return a.set(n,t),a}async readLine(){let i=new Uint8Array(this.arrBuf),t=0;for(;;){let n=await this.nextBuffer();const a=n.indexOf(10);if(a>=0?(this.nextIdx+=a+1,n=n.subarray(0,a)):this.nextIdx+=n.length,n.includes(3))throw new I("Interrupted");if(i=this.appendBuffer(i,t,n),t+=n.length,a>=0)return await Ve(i.subarray(0,t))}}async readBinary(i){this.arrBuf.byteLength<i&&(this.arrBuf=new ArrayBuffer(i));const t=new Uint8Array(this.arrBuf,0,i);let n=0;for(;n<i;){const a=i-n;let r=await this.nextBuffer();r.length>a?(this.nextIdx+=a,r=r.subarray(0,a)):this.nextIdx+=r.length,t.set(r,n),n+=r.length}return t}async readLineOnWindows(){let i=new Uint8Array(this.arrBuf),t=27,n=!1,a=!1,r=!1,l=!1,s=!1,c=0;for(;;){let o=await this.nextBuffer();const f=o.indexOf(33);f>=0?(this.nextIdx+=f+1,o=o.subarray(0,f)):this.nextIdx+=o.length;for(let g=0;g<o.length;g++){const u=o[g];if(u===3)throw new I("Interrupted");if(u===10&&(a=!0),n)Lt(u)&&(n=!1,u===72&&t>=48&&t<=57&&(r=!0)),t===91&&u===72&&(l=!0),t=u;else if(u===27)n=!0,t=u;else if(ll(u)){if(r&&(r=!1,a&&c>0&&(u===i[c-1]||s))){i[c-1]=u;continue}c>=i.length&&(i=this.growBuffer(i,c,o.length)),i[c++]=u,s=l,l=!1,a=!1}}if(f>=0&&c>0&&!n)return await Ve(i.subarray(0,c))}}}class L{constructor(){this._dataLength=0,this._bufferLength=0,this._state=new Int32Array(4),this._buffer=new ArrayBuffer(68),this._buffer8=new Uint8Array(this._buffer,0,68),this._buffer32=new Uint32Array(this._buffer,0,17),this.start()}static hashStr(i,t=!1){return this.onePassHasher.start().appendStr(i).end(t)}static hashAsciiStr(i,t=!1){return this.onePassHasher.start().appendAsciiStr(i).end(t)}static _hex(i){const t=L.hexChars,n=L.hexOut;let a,r,l,s;for(s=0;s<4;s+=1)for(r=s*8,a=i[s],l=0;l<8;l+=2)n[r+1+l]=t.charAt(a&15),a>>>=4,n[r+0+l]=t.charAt(a&15),a>>>=4;return n.join("")}static _md5cycle(i,t){let n=i[0],a=i[1],r=i[2],l=i[3];n+=(a&r|~a&l)+t[0]-680876936|0,n=(n<<7|n>>>25)+a|0,l+=(n&a|~n&r)+t[1]-389564586|0,l=(l<<12|l>>>20)+n|0,r+=(l&n|~l&a)+t[2]+606105819|0,r=(r<<17|r>>>15)+l|0,a+=(r&l|~r&n)+t[3]-1044525330|0,a=(a<<22|a>>>10)+r|0,n+=(a&r|~a&l)+t[4]-176418897|0,n=(n<<7|n>>>25)+a|0,l+=(n&a|~n&r)+t[5]+1200080426|0,l=(l<<12|l>>>20)+n|0,r+=(l&n|~l&a)+t[6]-1473231341|0,r=(r<<17|r>>>15)+l|0,a+=(r&l|~r&n)+t[7]-45705983|0,a=(a<<22|a>>>10)+r|0,n+=(a&r|~a&l)+t[8]+1770035416|0,n=(n<<7|n>>>25)+a|0,l+=(n&a|~n&r)+t[9]-1958414417|0,l=(l<<12|l>>>20)+n|0,r+=(l&n|~l&a)+t[10]-42063|0,r=(r<<17|r>>>15)+l|0,a+=(r&l|~r&n)+t[11]-1990404162|0,a=(a<<22|a>>>10)+r|0,n+=(a&r|~a&l)+t[12]+1804603682|0,n=(n<<7|n>>>25)+a|0,l+=(n&a|~n&r)+t[13]-40341101|0,l=(l<<12|l>>>20)+n|0,r+=(l&n|~l&a)+t[14]-1502002290|0,r=(r<<17|r>>>15)+l|0,a+=(r&l|~r&n)+t[15]+1236535329|0,a=(a<<22|a>>>10)+r|0,n+=(a&l|r&~l)+t[1]-165796510|0,n=(n<<5|n>>>27)+a|0,l+=(n&r|a&~r)+t[6]-1069501632|0,l=(l<<9|l>>>23)+n|0,r+=(l&a|n&~a)+t[11]+643717713|0,r=(r<<14|r>>>18)+l|0,a+=(r&n|l&~n)+t[0]-373897302|0,a=(a<<20|a>>>12)+r|0,n+=(a&l|r&~l)+t[5]-701558691|0,n=(n<<5|n>>>27)+a|0,l+=(n&r|a&~r)+t[10]+38016083|0,l=(l<<9|l>>>23)+n|0,r+=(l&a|n&~a)+t[15]-660478335|0,r=(r<<14|r>>>18)+l|0,a+=(r&n|l&~n)+t[4]-405537848|0,a=(a<<20|a>>>12)+r|0,n+=(a&l|r&~l)+t[9]+568446438|0,n=(n<<5|n>>>27)+a|0,l+=(n&r|a&~r)+t[14]-1019803690|0,l=(l<<9|l>>>23)+n|0,r+=(l&a|n&~a)+t[3]-187363961|0,r=(r<<14|r>>>18)+l|0,a+=(r&n|l&~n)+t[8]+1163531501|0,a=(a<<20|a>>>12)+r|0,n+=(a&l|r&~l)+t[13]-1444681467|0,n=(n<<5|n>>>27)+a|0,l+=(n&r|a&~r)+t[2]-51403784|0,l=(l<<9|l>>>23)+n|0,r+=(l&a|n&~a)+t[7]+1735328473|0,r=(r<<14|r>>>18)+l|0,a+=(r&n|l&~n)+t[12]-1926607734|0,a=(a<<20|a>>>12)+r|0,n+=(a^r^l)+t[5]-378558|0,n=(n<<4|n>>>28)+a|0,l+=(n^a^r)+t[8]-2022574463|0,l=(l<<11|l>>>21)+n|0,r+=(l^n^a)+t[11]+1839030562|0,r=(r<<16|r>>>16)+l|0,a+=(r^l^n)+t[14]-35309556|0,a=(a<<23|a>>>9)+r|0,n+=(a^r^l)+t[1]-1530992060|0,n=(n<<4|n>>>28)+a|0,l+=(n^a^r)+t[4]+1272893353|0,l=(l<<11|l>>>21)+n|0,r+=(l^n^a)+t[7]-155497632|0,r=(r<<16|r>>>16)+l|0,a+=(r^l^n)+t[10]-1094730640|0,a=(a<<23|a>>>9)+r|0,n+=(a^r^l)+t[13]+681279174|0,n=(n<<4|n>>>28)+a|0,l+=(n^a^r)+t[0]-358537222|0,l=(l<<11|l>>>21)+n|0,r+=(l^n^a)+t[3]-722521979|0,r=(r<<16|r>>>16)+l|0,a+=(r^l^n)+t[6]+76029189|0,a=(a<<23|a>>>9)+r|0,n+=(a^r^l)+t[9]-640364487|0,n=(n<<4|n>>>28)+a|0,l+=(n^a^r)+t[12]-421815835|0,l=(l<<11|l>>>21)+n|0,r+=(l^n^a)+t[15]+530742520|0,r=(r<<16|r>>>16)+l|0,a+=(r^l^n)+t[2]-995338651|0,a=(a<<23|a>>>9)+r|0,n+=(r^(a|~l))+t[0]-198630844|0,n=(n<<6|n>>>26)+a|0,l+=(a^(n|~r))+t[7]+1126891415|0,l=(l<<10|l>>>22)+n|0,r+=(n^(l|~a))+t[14]-1416354905|0,r=(r<<15|r>>>17)+l|0,a+=(l^(r|~n))+t[5]-57434055|0,a=(a<<21|a>>>11)+r|0,n+=(r^(a|~l))+t[12]+1700485571|0,n=(n<<6|n>>>26)+a|0,l+=(a^(n|~r))+t[3]-1894986606|0,l=(l<<10|l>>>22)+n|0,r+=(n^(l|~a))+t[10]-1051523|0,r=(r<<15|r>>>17)+l|0,a+=(l^(r|~n))+t[1]-2054922799|0,a=(a<<21|a>>>11)+r|0,n+=(r^(a|~l))+t[8]+1873313359|0,n=(n<<6|n>>>26)+a|0,l+=(a^(n|~r))+t[15]-30611744|0,l=(l<<10|l>>>22)+n|0,r+=(n^(l|~a))+t[6]-1560198380|0,r=(r<<15|r>>>17)+l|0,a+=(l^(r|~n))+t[13]+1309151649|0,a=(a<<21|a>>>11)+r|0,n+=(r^(a|~l))+t[4]-145523070|0,n=(n<<6|n>>>26)+a|0,l+=(a^(n|~r))+t[11]-1120210379|0,l=(l<<10|l>>>22)+n|0,r+=(n^(l|~a))+t[2]+718787259|0,r=(r<<15|r>>>17)+l|0,a+=(l^(r|~n))+t[9]-343485551|0,a=(a<<21|a>>>11)+r|0,i[0]=n+i[0]|0,i[1]=a+i[1]|0,i[2]=r+i[2]|0,i[3]=l+i[3]|0}start(){return this._dataLength=0,this._bufferLength=0,this._state.set(L.stateIdentity),this}appendStr(i){const t=this._buffer8,n=this._buffer32;let a=this._bufferLength,r,l;for(l=0;l<i.length;l+=1){if(r=i.charCodeAt(l),r<128)t[a++]=r;else if(r<2048)t[a++]=(r>>>6)+192,t[a++]=r&63|128;else if(r<55296||r>56319)t[a++]=(r>>>12)+224,t[a++]=r>>>6&63|128,t[a++]=r&63|128;else{if(r=(r-55296)*1024+(i.charCodeAt(++l)-56320)+65536,r>1114111)throw new Error("Unicode standard supports code points up to U+10FFFF");t[a++]=(r>>>18)+240,t[a++]=r>>>12&63|128,t[a++]=r>>>6&63|128,t[a++]=r&63|128}a>=64&&(this._dataLength+=64,L._md5cycle(this._state,n),a-=64,n[0]=n[16])}return this._bufferLength=a,this}appendAsciiStr(i){const t=this._buffer8,n=this._buffer32;let a=this._bufferLength,r,l=0;for(;;){for(r=Math.min(i.length-l,64-a);r--;)t[a++]=i.charCodeAt(l++);if(a<64)break;this._dataLength+=64,L._md5cycle(this._state,n),a=0}return this._bufferLength=a,this}appendByteArray(i){const t=this._buffer8,n=this._buffer32;let a=this._bufferLength,r,l=0;for(;;){for(r=Math.min(i.length-l,64-a);r--;)t[a++]=i[l++];if(a<64)break;this._dataLength+=64,L._md5cycle(this._state,n),a=0}return this._bufferLength=a,this}getState(){const i=this._state;return{buffer:String.fromCharCode.apply(null,Array.from(this._buffer8)),buflen:this._bufferLength,length:this._dataLength,state:[i[0],i[1],i[2],i[3]]}}setState(i){const t=i.buffer,n=i.state,a=this._state;let r;for(this._dataLength=i.length,this._bufferLength=i.buflen,a[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],r=0;r<t.length;r+=1)this._buffer8[r]=t.charCodeAt(r)}end(i=!1){const t=this._bufferLength,n=this._buffer8,a=this._buffer32,r=(t>>2)+1;this._dataLength+=t;const l=this._dataLength*8;if(n[t]=128,n[t+1]=n[t+2]=n[t+3]=0,a.set(L.buffer32Identity.subarray(r),r),t>55&&(L._md5cycle(this._state,a),a.set(L.buffer32Identity)),l<=4294967295)a[14]=l;else{const s=l.toString(16).match(/(.*?)(.{0,8})$/);if(s===null)return;const c=parseInt(s[2],16),o=parseInt(s[1],16)||0;a[14]=c,a[15]=o}return L._md5cycle(this._state,a),i?this._state:L._hex(this._state)}}if(L.stateIdentity=new Int32Array([1732584193,-271733879,-1732584194,271733878]),L.buffer32Identity=new Int32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),L.hexChars="0123456789abcdef",L.hexOut=[],L.onePassHasher=new L,L.hashStr("hello")!=="5d41402abc4b2a76b9719d911017c592")throw new Error("Md5 self test failed.");/**
|
|
3
|
+
* trzsz2: https://github.com/zxdong262/trzsz2
|
|
4
|
+
* Copyright(c) 2024 Lonny Wong
|
|
5
|
+
* @license MIT
|
|
6
|
+
*
|
|
7
|
+
* Pure protocol implementation without fs/browser dependencies.
|
|
8
|
+
*/function sl(e){const i=[["\xEE","\xEE\xEE"],["~","\xEE1"]];if(e){const t="\r\x1B\x8D\x90\x91\x93\x9D";for(let n=0;n<t.length;n++)i.push([t[n],"\xEE"+String.fromCharCode(65+n)])}return i}function Bt(e){const i=[];for(let t=0;t<e.length;t++)i.push([e[t][0].charCodeAt(0),e[t][1].charCodeAt(0),e[t][1].charCodeAt(1)]);return i}function sn(e,i){if(i.length===0)return e;const t=new Uint8Array(e.length*2);let n=0;for(let a=0;a<e.length;a++){let r=-1;for(let l=0;l<i.length;l++)if(e[a]===i[l][0]){r=l;break}r<0?t[n++]=e[a]:(t[n++]=i[r][1],t[n++]=i[r][2])}return t.subarray(0,n)}function on(e,i){if(i.length===0)return e;const t=new Uint8Array(e.length);let n=0;for(let a=0;a<e.length;a++){let r=-1;if(a<e.length-1){for(let l=0;l<i.length;l++)if(e[a]===i[l][1]&&e[a+1]===i[l][2]){r=l;break}}r<0?t[n++]=e[a]:(t[n++]=i[r][0],a++)}return t.subarray(0,n)}class ol{constructor(i,t=!1){this.buffer=new ln,this.remoteIsWindows=!1,this.lastInputTime=0,this.openedFiles=[],this.createdFiles=[],this.tmuxOutputJunk=!1,this.cleanTimeoutInMilliseconds=100,this.transferConfig={},this.stopped=!1,this.maxChunkTimeInMilliseconds=0,this.protocolNewline=`
|
|
9
|
+
`,this.writer=i,this.isWindowsShell=t}cleanup(){for(const i of this.openedFiles)i.closeFile()}addReceivedData(i){this.stopped||this.buffer.addBuffer(i),this.lastInputTime=Date.now()}async stopTransferring(){this.cleanTimeoutInMilliseconds=Math.max(this.maxChunkTimeInMilliseconds*2,500),this.stopped=!0,this.buffer.stopBuffer()}async cleanInput(i){for(this.stopped=!0,this.buffer.drainBuffer(),this.lastInputTime=Date.now();;){const t=i-(Date.now()-this.lastInputTime);if(t<=0)return;await new Promise(n=>setTimeout(n,t))}}async sendLine(i,t){this.writer(`#${i}:${t}${this.protocolNewline}`)}async recvLine(i,t=!1){if(this.stopped)throw new I("Stopped");if(this.isWindowsShell||this.remoteIsWindows){let a=await this.buffer.readLineOnWindows();const r=a.lastIndexOf("#"+i+":");if(r>=0)a=a.substring(r);else{const l=a.lastIndexOf("#");l>0&&(a=a.substring(l))}return a}let n=await this.buffer.readLine();if(this.tmuxOutputJunk||t){if(n.length>0)for(;n[n.length-1]==="\r";)n=n.substring(0,n.length-1)+await this.buffer.readLine();const a=n.lastIndexOf("#"+i+":");if(a>=0)n=n.substring(a);else{const r=n.lastIndexOf("#");r>0&&(n=n.substring(r))}n=rn(n)}return n}async recvCheck(i,t=!1){const n=await this.recvLine(i,t),a=n.indexOf(":");if(a<1)throw new I(qe(n),"colon",!0);const r=n.substring(1,a),l=n.substring(a+1);if(r!==i)throw new I(l,r,!0);return l}async sendInteger(i,t){await this.sendLine(i,t.toString())}async recvInteger(i,t=!1){const n=await this.recvCheck(i,t);return Number(n)}async checkInteger(i){const t=await this.recvInteger("SUCC");if(t!==i)throw new I(`Integer check [${t}] <> [${i}]`,null,!0)}async sendString(i,t){await this.sendLine(i,qe(t))}async recvString(i,t=!1){const n=await this.recvCheck(i,t);return await Ve(Qe(n),"utf8")}async checkString(i){const t=await this.recvString("SUCC");if(t!==i)throw new I(`String check [${t}] <> [${i}]`,null,!0)}async sendBinary(i,t){await this.sendLine(i,qe(t))}async recvBinary(i,t=!1){const n=await this.recvCheck(i,t);return Qe(n)}async checkBinary(i){const t=await this.recvBinary("SUCC");if(t.length!==i.length)throw new I(`Binary length check [${t.length}] <> [${i.length}]`,null,!0);for(let n=0;n<t.length;n++)if(t[n]!==i[n])throw new I(`Binary check [${t[n]}] <> [${i[n]}]`,null,!0)}async sendData(i,t,n){if(!t){await this.sendBinary("DATA",i);return}const a=sn(i,n);this.writer(`#DATA:${a.length}
|
|
10
|
+
`),this.writer(a)}async recvData(i,t,n){return await Promise.race([new Promise((a,r)=>setTimeout(()=>{this.cleanTimeoutInMilliseconds=3e3,r(new I("Receive data timeout"))},n)),(async()=>{if(!i)return await this.recvBinary("DATA");const a=await this.recvInteger("DATA"),r=await this.buffer.readBinary(a);return on(r,t)})()])}async sendAction(i,t){const n={lang:"js",confirm:i,version:en,support_dir:!0};(this.isWindowsShell||t)&&(n.binary=!1,n.newline=`!
|
|
11
|
+
`),t&&(this.remoteIsWindows=!0,this.protocolNewline=`!
|
|
12
|
+
`),await this.sendString("ACT",JSON.stringify(n))}async recvAction(){const i=await this.recvString("ACT",!0),t=JSON.parse(i),n=t.newline;return typeof n=="string"&&n.length>0&&(this.protocolNewline=n),t}async sendConfig(i,t,n,a){const r={lang:"js"};i.quiet===!0&&(r.quiet=!0),i.binary===!0&&(r.binary=!0,r.escape_chars=t),i.directory===!0&&(r.directory=!0),typeof i.bufsize=="number"&&(r.bufsize=i.bufsize),typeof i.timeout=="number"&&(r.timeout=i.timeout),i.overwrite===!0&&(r.overwrite=!0),n===an.TmuxNormalMode&&(r.tmux_output_junk=!0),a>0&&(r.tmux_pane_width=a);let l=JSON.stringify(r);l=l.replace(/[\u007F-\uFFFF]/g,function(s){return"\\u"+("0000"+s.charCodeAt(0).toString(16)).slice(-4)}),this.transferConfig=r,await this.sendString("CFG",l)}async recvConfig(){const i=await this.recvString("CFG",!0);return this.transferConfig=JSON.parse(i),this.tmuxOutputJunk=this.transferConfig.tmux_output_junk===!0,this.transferConfig}async clientExit(i){await this.sendString("EXIT",i)}async recvExit(){return await this.recvString("EXIT")}async deleteCreatedFiles(){const i=[];for(const t of this.createdFiles){const n=await t.deleteFile();typeof n=="string"&&n.length>0&&i.push(n)}return i}async clientError(i){await this.cleanInput(this.cleanTimeoutInMilliseconds);const t=I.getErrorMessage(i);let n=!0;if(i instanceof I){if(n=i.isTraceBack(),i.isRemoteExit())return;if(i.isRemoteFail()){n&&console.log(t);return}}await this.sendString(n?"FAIL":"fail",t),n&&console.log(t)}async serverError(i){await this.cleanInput(this.cleanTimeoutInMilliseconds);const t=I.getErrorMessage(i);let n=!0;if(i instanceof I){if(i.isStopAndDelete()){const a=await this.deleteCreatedFiles();if(a.length>0){await this.serverExit([i.message+":"].concat(a).join(`\r
|
|
13
|
+
- `));return}}if(n=i.isTraceBack(),i.isRemoteExit()||i.isRemoteFail()){await this.serverExit(t);return}}await this.sendString(n?"FAIL":"fail",t),await this.serverExit(t)}async serverExit(i){}async sendFileNum(i,t){await this.sendInteger("NUM",i),await this.checkInteger(i),t?.onNum(i)}async sendFileName(i,t,n){const a=i.getRelPath(),r=a[a.length-1];if(t){const s={path_id:i.getPathId(),path_name:a,is_dir:i.isDir()};await this.sendString("NAME",JSON.stringify(s))}else await this.sendString("NAME",r);const l=await this.recvString("SUCC");return n?.onName(r),l}async sendFileSize(i,t){await this.sendInteger("SIZE",i),await this.checkInteger(i),t?.onSize(i)}async sendFileData(i,t,n,a,r,l){let s=0;l?.onStep(s);let c=1024,o=new ArrayBuffer(c);const f=new L;for(;s<t;){const g=Date.now(),u=await i.readFile(o);await this.sendData(u,n,a),f.appendByteArray(u),await this.checkInteger(u.length),s+=u.length,l?.onStep(s);const h=Date.now()-g;u.length===c&&h<500&&c<r?(c=Math.min(c*2,r),o=new ArrayBuffer(c)):h>=2e3&&c>1024&&(c=1024,o=new ArrayBuffer(c)),h>this.maxChunkTimeInMilliseconds&&(this.maxChunkTimeInMilliseconds=h)}return new Uint8Array(f.end(!0).buffer)}async sendFileMD5(i,t){await this.sendBinary("MD5",i),await this.checkBinary(i),t?.onDone()}async sendFiles(i,t){this.openedFiles.push(...i);const n=this.transferConfig.binary===!0,a=this.transferConfig.directory===!0,r=this.transferConfig.bufsize,l=typeof r=="number"?r:10*1024*1024,s=Array.isArray(this.transferConfig.escape_chars)?Bt(this.transferConfig.escape_chars):[];await this.sendFileNum(i.length,t);const c=[];for(const o of i){const f=await this.sendFileName(o,a,t);if(c.includes(f)||c.push(f),o.isDir())continue;const g=o.getSize();await this.sendFileSize(g,t);const u=await this.sendFileData(o,g,n,s,l,t);o.closeFile(),await this.sendFileMD5(u,t)}return c}async recvFileNum(i){const t=await this.recvInteger("NUM");return await this.sendInteger("SUCC",t),i?.onNum(t),t}async recvFileName(i,t,n,a,r){const l=await this.recvString("NAME"),s=await t(i,l,n,a);return this.createdFiles.push(s),await this.sendString("SUCC",s.getLocalName()),r?.onName(s.getFileName()),s}async recvFileSize(i){const t=await this.recvInteger("SIZE");return await this.sendInteger("SUCC",t),i?.onSize(t),t}async recvFileData(i,t,n,a,r,l){let s=0;l?.onStep(s);const c=new L;for(;s<t;){const o=Date.now(),f=await this.recvData(n,a,r);await i.writeFile(f),s+=f.length,l?.onStep(s),await this.sendInteger("SUCC",f.length),c.appendByteArray(f);const g=Date.now()-o;g>this.maxChunkTimeInMilliseconds&&(this.maxChunkTimeInMilliseconds=g)}return new Uint8Array(c.end(!0).buffer)}async recvFileMD5(i,t){const n=await this.recvBinary("MD5");if(i.length!==n.length)throw new I("Check MD5 failed");for(let a=0;a<i.length;a++)if(i[a]!==n[a])throw new I("Check MD5 failed");await this.sendBinary("SUCC",i),t?.onDone()}async recvFiles(i,t,n){const a=this.transferConfig.binary===!0,r=this.transferConfig.directory===!0,l=this.transferConfig.overwrite===!0,s=this.transferConfig.timeout,c=typeof s=="number"?s*1e3:1e5,o=Array.isArray(this.transferConfig.escape_chars)?Bt(this.transferConfig.escape_chars):[],f=await this.recvFileNum(n),g=[];for(let u=0;u<f;u++){const h=await this.recvFileName(i,t,r,l,n);if(g.includes(h.getLocalName())||g.push(h.getLocalName()),h.isDir())continue;this.openedFiles.push(h);const _=await this.recvFileSize(n),z=await this.recvFileData(h,_,a,o,c,n);h.closeFile(),await this.recvFileMD5(z,n)}return g}}/**
|
|
14
|
+
* trzsz2: https://github.com/zxdong262/trzsz2
|
|
15
|
+
* Copyright(c) 2024 Lonny Wong
|
|
16
|
+
* @license MIT
|
|
17
|
+
*
|
|
18
|
+
* Pure protocol implementation without fs/browser dependencies.
|
|
19
|
+
*/function fl(e){return e.replace(/[\u4e00-\u9fa5]/g,"**").length}function Oe(e,i){i-=3;let t=0,n="";for(let a=0;a<e.length;a++){if(e.charCodeAt(a)>=19968&&e.charCodeAt(a)<=40869){if(t+2>i)return{sub:n+"...",len:t+3};t+=2}else{if(t+1>i)return{sub:n+"...",len:t+3};t+=1}n+=e[a]}return{sub:n+"...",len:t+3}}function fn(e){let i="B";do{if(e<1024||(e=e/1024,i="KB",e<1024)||(e=e/1024,i="MB",e<1024)||(e=e/1024,i="GB",e<1024))break;e=e/1024,i="TB"}while(!1);return e>=100?`${e.toFixed(0)} ${i}`:e>=10?`${e.toFixed(1)} ${i}`:`${e.toFixed(2)} ${i}`}function hl(e){let i="";e>=3600&&(i+=Math.floor(e/3600).toString()+":",e%=3600);const t=Math.floor(e/60);i+=t>=10?t.toString():"0"+t.toString(),i+=":";const n=Math.round(e%60);return i+=n>=10?n.toString():"0"+n.toString(),i}const Ue=30;class cl{constructor(i,t,n=void 0){this.lastUpdateTime=0,this.fileCount=0,this.fileIdx=0,this.fileName="",this.fileSize=0,this.fileStep=0,this.startTime=0,this.firstWrite=!0,this.speedCnt=0,this.speedIdx=0,this.timeArray=new Array(Ue),this.stepArray=new Array(Ue),this.writer=i,this.tmuxPaneColumns=n??0,this.columns=this.tmuxPaneColumns>1?this.tmuxPaneColumns-1:t}setTerminalColumns(i){this.columns=i,this.tmuxPaneColumns>0&&(this.tmuxPaneColumns=0)}onNum(i){this.fileCount=i,this.fileIdx=0}onName(i){this.fileName=i,this.fileIdx+=1,this.startTime=Date.now(),this.timeArray[0]=this.startTime,this.stepArray[0]=0,this.speedCnt=1,this.speedIdx=1,this.fileStep=-1}onSize(i){this.fileSize=i}onStep(i){i<=this.fileStep||(this.fileStep=i,this.showProgress())}hideCursor(){this.writer("\x1B[?25l")}showCursor(){this.writer("\x1B[?25h")}showProgress(){const i=Date.now();if(i-this.lastUpdateTime<200)return;this.lastUpdateTime=i;let t="100%";this.fileSize!==0&&(t=Math.round(this.fileStep*100/this.fileSize).toString()+"%");const n=fn(this.fileStep),a=this.getSpeed(i);let r="--- B/s",l="--- ETA";a>0&&(r=fn(a)+"/s",l=hl(Math.round((this.fileSize-this.fileStep)/a))+" ETA");const s=this.getProgressText(t,n,r,l);if(this.firstWrite){this.firstWrite=!1,this.writer(s);return}this.tmuxPaneColumns>0?this.writer(`\x1B[${this.columns}D${s}`):this.writer(`\r${s}`)}getSpeed(i){let t;return this.speedCnt<=Ue?(this.speedCnt++,t=(this.fileStep-this.stepArray[0])*1e3/(i-this.timeArray[0])):t=(this.fileStep-this.stepArray[this.speedIdx])*1e3/(i-this.timeArray[this.speedIdx]),this.timeArray[this.speedIdx]=i,this.stepArray[this.speedIdx]=this.fileStep,this.speedIdx++,this.speedIdx>=Ue&&(this.speedIdx%=Ue),isFinite(t)?t:-1}getProgressText(i,t,n,a){let l=this.fileCount>1?`(${this.fileIdx}/${this.fileCount}) ${this.fileName}`:this.fileName,s=fl(l),c=` ${i} | ${t} | ${n} | ${a}`;do{if(this.columns-s-c.length>=24||(s>50&&({sub:l,len:s}=Oe(l,50)),this.columns-s-c.length>=24)||(s>40&&({sub:l,len:s}=Oe(l,40)),this.columns-s-c.length>=24)||(c=` ${i} | ${n} | ${a}`,this.columns-s-c.length>=24)||(s>30&&({sub:l,len:s}=Oe(l,30)),this.columns-s-c.length>=24)||(c=` ${i} | ${a}`,this.columns-s-c.length>=24)||(c=` ${i}`,this.columns-s-c.length>=24)||(s>20&&({sub:l,len:s}=Oe(l,20)),this.columns-s-c.length>=24))break;l="",s=0}while(!1);let o=this.columns-c.length;s>0&&(o-=s+1,l+=" ");const f=this.getProgressBar(o);return(l+f+c).trim()}getProgressBar(i){if(i<12)return"";const t=i-2;let n=t;return this.fileSize!==0&&(n=Math.round(t*this.fileStep/this.fileSize)),"[\x1B[36m"+"\u2588".repeat(n)+"\u2591".repeat(t-n)+"\x1B[0m]"}onDone(){this.fileSize!==0&&(this.fileStep=this.fileSize,this.lastUpdateTime=0,this.showProgress())}}return D.TextProgressBar=cl,D.TmuxMode=an,D.TrzszBuffer=ln,D.TrzszError=I,D.TrzszTransfer=ol,D.checkDuplicateNames=il,D.decodeBuffer=Qe,D.encodeBuffer=qe,D.escapeCharsToCodes=Bt,D.escapeData=sn,D.formatSavedFiles=rl,D.getEllipsisString=Oe,D.getEscapeChars=sl,D.isArrayOfType=nl,D.isVT100End=Lt,D.strToArrBuf=Jr,D.strToUint8=Ne,D.stripServerOutput=al,D.stripTmuxStatusLine=rn,D.trzszVersion=en,D.uint8ToStr=Ve,D.unescapeData=on,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"}),D}({});
|
package/dist/buffer.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* trzsz2: https://github.com/zxdong262/trzsz2
|
|
3
|
+
* Copyright(c) 2024 Lonny Wong
|
|
4
|
+
* @license MIT
|
|
5
|
+
*
|
|
6
|
+
* Pure protocol implementation without fs/browser dependencies.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* TrzszBuffer class for handling buffer operations.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TrzszBuffer {
|
|
12
|
+
private bufArray;
|
|
13
|
+
private resolve;
|
|
14
|
+
private reject;
|
|
15
|
+
private bufHead;
|
|
16
|
+
private bufTail;
|
|
17
|
+
private nextIdx;
|
|
18
|
+
private nextBuf;
|
|
19
|
+
private arrBuf;
|
|
20
|
+
/**
|
|
21
|
+
* Add a buffer to the queue.
|
|
22
|
+
* @param buf - The buffer to add.
|
|
23
|
+
*/
|
|
24
|
+
addBuffer(buf: string | ArrayBuffer | Uint8Array | Blob): void;
|
|
25
|
+
/**
|
|
26
|
+
* Stop the buffer and reject any pending operations.
|
|
27
|
+
*/
|
|
28
|
+
stopBuffer(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Drain all buffers.
|
|
31
|
+
*/
|
|
32
|
+
drainBuffer(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Convert a buffer to Uint8Array.
|
|
35
|
+
* @param buf - The buffer to convert.
|
|
36
|
+
* @return The resulting Uint8Array.
|
|
37
|
+
*/
|
|
38
|
+
private toUint8Array;
|
|
39
|
+
/**
|
|
40
|
+
* Get the next buffer.
|
|
41
|
+
* @return The next buffer.
|
|
42
|
+
*/
|
|
43
|
+
private nextBuffer;
|
|
44
|
+
/**
|
|
45
|
+
* Grow the buffer.
|
|
46
|
+
* @param dst - The destination buffer.
|
|
47
|
+
* @param idx - The current index.
|
|
48
|
+
* @param min - The minimum size needed.
|
|
49
|
+
* @return The grown buffer.
|
|
50
|
+
*/
|
|
51
|
+
private growBuffer;
|
|
52
|
+
/**
|
|
53
|
+
* Append a buffer to another.
|
|
54
|
+
* @param dst - The destination buffer.
|
|
55
|
+
* @param idx - The current index.
|
|
56
|
+
* @param src - The source buffer.
|
|
57
|
+
* @return The resulting buffer.
|
|
58
|
+
*/
|
|
59
|
+
private appendBuffer;
|
|
60
|
+
/**
|
|
61
|
+
* Read a line from the buffer.
|
|
62
|
+
* @return The line.
|
|
63
|
+
*/
|
|
64
|
+
readLine(): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Read binary data from the buffer.
|
|
67
|
+
* @param len - The length to read.
|
|
68
|
+
* @return The binary data.
|
|
69
|
+
*/
|
|
70
|
+
readBinary(len: number): Promise<Uint8Array>;
|
|
71
|
+
/**
|
|
72
|
+
* Read a line on Windows (handles VT100 escape sequences).
|
|
73
|
+
* @return The line.
|
|
74
|
+
*/
|
|
75
|
+
readLineOnWindows(): Promise<string>;
|
|
76
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const comm = require("./comm.cjs");
|
|
4
|
+
function isTrzszLetter(c) {
|
|
5
|
+
if (c >= 97 && c <= 122) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
if (c >= 65 && c <= 90) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
if (c >= 48 && c <= 57) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
if (c === 35 || c === 58 || c === 43 || c === 47 || c === 61) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
class TrzszBuffer {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.bufArray = [];
|
|
22
|
+
this.resolve = null;
|
|
23
|
+
this.reject = null;
|
|
24
|
+
this.bufHead = 0;
|
|
25
|
+
this.bufTail = 0;
|
|
26
|
+
this.nextIdx = 0;
|
|
27
|
+
this.nextBuf = null;
|
|
28
|
+
this.arrBuf = new ArrayBuffer(128);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Add a buffer to the queue.
|
|
32
|
+
* @param buf - The buffer to add.
|
|
33
|
+
*/
|
|
34
|
+
addBuffer(buf) {
|
|
35
|
+
this.bufArray[this.bufTail++] = buf;
|
|
36
|
+
if (this.resolve != null) {
|
|
37
|
+
this.resolve();
|
|
38
|
+
this.resolve = null;
|
|
39
|
+
this.reject = null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Stop the buffer and reject any pending operations.
|
|
44
|
+
*/
|
|
45
|
+
stopBuffer() {
|
|
46
|
+
if (this.reject != null) {
|
|
47
|
+
this.reject(new comm.TrzszError("Stopped"));
|
|
48
|
+
this.reject = null;
|
|
49
|
+
this.resolve = null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Drain all buffers.
|
|
54
|
+
*/
|
|
55
|
+
drainBuffer() {
|
|
56
|
+
this.bufArray = [];
|
|
57
|
+
this.bufHead = 0;
|
|
58
|
+
this.bufTail = 0;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Convert a buffer to Uint8Array.
|
|
62
|
+
* @param buf - The buffer to convert.
|
|
63
|
+
* @return The resulting Uint8Array.
|
|
64
|
+
*/
|
|
65
|
+
async toUint8Array(buf) {
|
|
66
|
+
if (typeof buf === "string") {
|
|
67
|
+
return comm.strToUint8(buf);
|
|
68
|
+
} else if (buf instanceof ArrayBuffer) {
|
|
69
|
+
return new Uint8Array(buf);
|
|
70
|
+
} else if (buf instanceof Uint8Array) {
|
|
71
|
+
return buf;
|
|
72
|
+
} else if (buf instanceof Blob) {
|
|
73
|
+
const buffer = await buf.arrayBuffer();
|
|
74
|
+
return new Uint8Array(buffer);
|
|
75
|
+
} else {
|
|
76
|
+
throw new comm.TrzszError("The buffer type is not supported", null, true);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get the next buffer.
|
|
81
|
+
* @return The next buffer.
|
|
82
|
+
*/
|
|
83
|
+
async nextBuffer() {
|
|
84
|
+
if (this.nextBuf != null && this.nextIdx < this.nextBuf.length) {
|
|
85
|
+
return this.nextBuf.subarray(this.nextIdx);
|
|
86
|
+
}
|
|
87
|
+
if (this.bufHead === this.bufTail) {
|
|
88
|
+
if (this.bufHead !== 0) {
|
|
89
|
+
this.bufHead = 0;
|
|
90
|
+
this.bufTail = 0;
|
|
91
|
+
}
|
|
92
|
+
await new Promise((resolve, reject) => {
|
|
93
|
+
this.resolve = resolve;
|
|
94
|
+
this.reject = reject;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
const buf = this.bufArray[this.bufHead];
|
|
98
|
+
this.bufArray[this.bufHead] = null;
|
|
99
|
+
this.bufHead++;
|
|
100
|
+
if (buf == null) {
|
|
101
|
+
throw new comm.TrzszError("Unexpected null buffer");
|
|
102
|
+
}
|
|
103
|
+
this.nextBuf = await this.toUint8Array(buf);
|
|
104
|
+
this.nextIdx = 0;
|
|
105
|
+
return this.nextBuf;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Grow the buffer.
|
|
109
|
+
* @param dst - The destination buffer.
|
|
110
|
+
* @param idx - The current index.
|
|
111
|
+
* @param min - The minimum size needed.
|
|
112
|
+
* @return The grown buffer.
|
|
113
|
+
*/
|
|
114
|
+
growBuffer(dst, idx, min) {
|
|
115
|
+
const len = Math.max(dst.length * 2, idx + min);
|
|
116
|
+
this.arrBuf = new ArrayBuffer(len);
|
|
117
|
+
const buf = new Uint8Array(this.arrBuf);
|
|
118
|
+
buf.set(dst.subarray(0, idx));
|
|
119
|
+
return buf;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Append a buffer to another.
|
|
123
|
+
* @param dst - The destination buffer.
|
|
124
|
+
* @param idx - The current index.
|
|
125
|
+
* @param src - The source buffer.
|
|
126
|
+
* @return The resulting buffer.
|
|
127
|
+
*/
|
|
128
|
+
appendBuffer(dst, idx, src) {
|
|
129
|
+
const buf = dst.length >= idx + src.length ? dst : this.growBuffer(dst, idx, src.length);
|
|
130
|
+
buf.set(src, idx);
|
|
131
|
+
return buf;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Read a line from the buffer.
|
|
135
|
+
* @return The line.
|
|
136
|
+
*/
|
|
137
|
+
async readLine() {
|
|
138
|
+
let buf = new Uint8Array(this.arrBuf);
|
|
139
|
+
let len = 0;
|
|
140
|
+
while (true) {
|
|
141
|
+
let next = await this.nextBuffer();
|
|
142
|
+
const newLineIdx = next.indexOf(10);
|
|
143
|
+
if (newLineIdx >= 0) {
|
|
144
|
+
this.nextIdx += newLineIdx + 1;
|
|
145
|
+
next = next.subarray(0, newLineIdx);
|
|
146
|
+
} else {
|
|
147
|
+
this.nextIdx += next.length;
|
|
148
|
+
}
|
|
149
|
+
if (next.includes(3)) {
|
|
150
|
+
throw new comm.TrzszError("Interrupted");
|
|
151
|
+
}
|
|
152
|
+
buf = this.appendBuffer(buf, len, next);
|
|
153
|
+
len += next.length;
|
|
154
|
+
if (newLineIdx >= 0) {
|
|
155
|
+
return await comm.uint8ToStr(buf.subarray(0, len));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Read binary data from the buffer.
|
|
161
|
+
* @param len - The length to read.
|
|
162
|
+
* @return The binary data.
|
|
163
|
+
*/
|
|
164
|
+
async readBinary(len) {
|
|
165
|
+
if (this.arrBuf.byteLength < len) {
|
|
166
|
+
this.arrBuf = new ArrayBuffer(len);
|
|
167
|
+
}
|
|
168
|
+
const buf = new Uint8Array(this.arrBuf, 0, len);
|
|
169
|
+
let idx = 0;
|
|
170
|
+
while (idx < len) {
|
|
171
|
+
const left = len - idx;
|
|
172
|
+
let next = await this.nextBuffer();
|
|
173
|
+
if (next.length > left) {
|
|
174
|
+
this.nextIdx += left;
|
|
175
|
+
next = next.subarray(0, left);
|
|
176
|
+
} else {
|
|
177
|
+
this.nextIdx += next.length;
|
|
178
|
+
}
|
|
179
|
+
buf.set(next, idx);
|
|
180
|
+
idx += next.length;
|
|
181
|
+
}
|
|
182
|
+
return buf;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Read a line on Windows (handles VT100 escape sequences).
|
|
186
|
+
* @return The line.
|
|
187
|
+
*/
|
|
188
|
+
async readLineOnWindows() {
|
|
189
|
+
let buf = new Uint8Array(this.arrBuf);
|
|
190
|
+
let lastByte = 27;
|
|
191
|
+
let skipVT100 = false;
|
|
192
|
+
let hasNewline = false;
|
|
193
|
+
let mayDuplicate = false;
|
|
194
|
+
let hasCursorHome = false;
|
|
195
|
+
let preHasCursorHome = false;
|
|
196
|
+
let idx = 0;
|
|
197
|
+
while (true) {
|
|
198
|
+
let next = await this.nextBuffer();
|
|
199
|
+
const newLineIdx = next.indexOf(33);
|
|
200
|
+
if (newLineIdx >= 0) {
|
|
201
|
+
this.nextIdx += newLineIdx + 1;
|
|
202
|
+
next = next.subarray(0, newLineIdx);
|
|
203
|
+
} else {
|
|
204
|
+
this.nextIdx += next.length;
|
|
205
|
+
}
|
|
206
|
+
for (let i = 0; i < next.length; i++) {
|
|
207
|
+
const c = next[i];
|
|
208
|
+
if (c === 3) {
|
|
209
|
+
throw new comm.TrzszError("Interrupted");
|
|
210
|
+
}
|
|
211
|
+
if (c === 10) {
|
|
212
|
+
hasNewline = true;
|
|
213
|
+
}
|
|
214
|
+
if (skipVT100) {
|
|
215
|
+
if (comm.isVT100End(c)) {
|
|
216
|
+
skipVT100 = false;
|
|
217
|
+
if (c === 72 && lastByte >= 48 && lastByte <= 57) {
|
|
218
|
+
mayDuplicate = true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (lastByte === 91 && c === 72) {
|
|
222
|
+
hasCursorHome = true;
|
|
223
|
+
}
|
|
224
|
+
lastByte = c;
|
|
225
|
+
} else if (c === 27) {
|
|
226
|
+
skipVT100 = true;
|
|
227
|
+
lastByte = c;
|
|
228
|
+
} else if (isTrzszLetter(c)) {
|
|
229
|
+
if (mayDuplicate) {
|
|
230
|
+
mayDuplicate = false;
|
|
231
|
+
if (hasNewline && idx > 0 && (c === buf[idx - 1] || preHasCursorHome)) {
|
|
232
|
+
buf[idx - 1] = c;
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (idx >= buf.length) {
|
|
237
|
+
buf = this.growBuffer(buf, idx, next.length);
|
|
238
|
+
}
|
|
239
|
+
buf[idx++] = c;
|
|
240
|
+
preHasCursorHome = hasCursorHome;
|
|
241
|
+
hasCursorHome = false;
|
|
242
|
+
hasNewline = false;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (newLineIdx >= 0 && idx > 0 && !skipVT100) {
|
|
246
|
+
return await comm.uint8ToStr(buf.subarray(0, idx));
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.TrzszBuffer = TrzszBuffer;
|
|
252
|
+
//# sourceMappingURL=buffer.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.cjs","sources":["../../src/buffer.ts"],"sourcesContent":["/**\n * trzsz2: https://github.com/zxdong262/trzsz2\n * Copyright(c) 2024 Lonny Wong\n * @license MIT\n *\n * Pure protocol implementation without fs/browser dependencies.\n */\n\nimport { strToUint8, uint8ToStr, TrzszError, isVT100End } from './comm'\n\n/**\n * Check if a character is a trzsz letter.\n * @param c - The character code.\n * @return True if it's a trzsz letter.\n */\nfunction isTrzszLetter (c: number): boolean {\n if (c >= 0x61 && c <= 0x7a) {\n // 'a' <= c && c <= 'z'\n return true\n }\n if (c >= 0x41 && c <= 0x5a) {\n // 'A' <= c && c <= 'Z'\n return true\n }\n if (c >= 0x30 && c <= 0x39) {\n // '0' <= c && c <= '9'\n return true\n }\n if (c === 0x23 || c === 0x3a || c === 0x2b || c === 0x2f || c === 0x3d) {\n // c == '#' || c == ':' || c == '+' || c == '/' || c == '='\n return true\n }\n return false\n}\n\n/**\n * TrzszBuffer class for handling buffer operations.\n */\nexport class TrzszBuffer {\n private bufArray: Array<string | ArrayBuffer | Uint8Array | Blob | null> = []\n private resolve: (() => void) | null = null\n private reject: ((err: Error) => void) | null = null\n private bufHead: number = 0\n private bufTail: number = 0\n private nextIdx: number = 0\n private nextBuf: Uint8Array | null = null\n private arrBuf: ArrayBuffer = new ArrayBuffer(128)\n\n /**\n * Add a buffer to the queue.\n * @param buf - The buffer to add.\n */\n public addBuffer (buf: string | ArrayBuffer | Uint8Array | Blob): void {\n this.bufArray[this.bufTail++] = buf\n if (this.resolve != null) {\n this.resolve()\n this.resolve = null\n this.reject = null\n }\n }\n\n /**\n * Stop the buffer and reject any pending operations.\n */\n public stopBuffer (): void {\n if (this.reject != null) {\n this.reject(new TrzszError('Stopped'))\n this.reject = null\n this.resolve = null\n }\n }\n\n /**\n * Drain all buffers.\n */\n public drainBuffer (): void {\n this.bufArray = []\n this.bufHead = 0\n this.bufTail = 0\n }\n\n /**\n * Convert a buffer to Uint8Array.\n * @param buf - The buffer to convert.\n * @return The resulting Uint8Array.\n */\n private async toUint8Array (buf: string | ArrayBuffer | Uint8Array | Blob): Promise<Uint8Array> {\n if (typeof buf === 'string') {\n return strToUint8(buf)\n } else if (buf instanceof ArrayBuffer) {\n return new Uint8Array(buf)\n } else if (buf instanceof Uint8Array) {\n return buf\n } else if (buf instanceof Blob) {\n const buffer = await buf.arrayBuffer()\n return new Uint8Array(buffer)\n } else {\n throw new TrzszError('The buffer type is not supported', null, true)\n }\n }\n\n /**\n * Get the next buffer.\n * @return The next buffer.\n */\n private async nextBuffer (): Promise<Uint8Array> {\n if ((this.nextBuf != null) && this.nextIdx < this.nextBuf.length) {\n return this.nextBuf.subarray(this.nextIdx)\n }\n if (this.bufHead === this.bufTail) {\n if (this.bufHead !== 0) {\n this.bufHead = 0\n this.bufTail = 0\n }\n await new Promise<void>((resolve, reject) => {\n this.resolve = resolve\n this.reject = reject\n })\n }\n const buf = this.bufArray[this.bufHead]\n this.bufArray[this.bufHead] = null\n this.bufHead++\n if (buf == null) {\n throw new TrzszError('Unexpected null buffer')\n }\n this.nextBuf = await this.toUint8Array(buf)\n this.nextIdx = 0\n return this.nextBuf\n }\n\n /**\n * Grow the buffer.\n * @param dst - The destination buffer.\n * @param idx - The current index.\n * @param min - The minimum size needed.\n * @return The grown buffer.\n */\n private growBuffer (dst: Uint8Array, idx: number, min: number): Uint8Array {\n const len = Math.max(dst.length * 2, idx + min)\n this.arrBuf = new ArrayBuffer(len)\n const buf = new Uint8Array(this.arrBuf)\n buf.set(dst.subarray(0, idx))\n return buf\n }\n\n /**\n * Append a buffer to another.\n * @param dst - The destination buffer.\n * @param idx - The current index.\n * @param src - The source buffer.\n * @return The resulting buffer.\n */\n private appendBuffer (dst: Uint8Array, idx: number, src: Uint8Array): Uint8Array {\n const buf = dst.length >= idx + src.length ? dst : this.growBuffer(dst, idx, src.length)\n buf.set(src, idx)\n return buf\n }\n\n /**\n * Read a line from the buffer.\n * @return The line.\n */\n public async readLine (): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n let buf = new Uint8Array(this.arrBuf) as Uint8Array\n let len = 0\n while (true) {\n let next = await this.nextBuffer()\n const newLineIdx = next.indexOf(0x0a) // '\\n'\n if (newLineIdx >= 0) {\n this.nextIdx += newLineIdx + 1 // +1 to ignore the '\\n'\n next = next.subarray(0, newLineIdx)\n } else {\n this.nextIdx += next.length\n }\n if (next.includes(0x03)) {\n // `ctrl + c` to interrupt\n throw new TrzszError('Interrupted')\n }\n buf = this.appendBuffer(buf, len, next)\n len += next.length\n if (newLineIdx >= 0) {\n return await uint8ToStr(buf.subarray(0, len))\n }\n }\n }\n\n /**\n * Read binary data from the buffer.\n * @param len - The length to read.\n * @return The binary data.\n */\n public async readBinary (len: number): Promise<Uint8Array> {\n if (this.arrBuf.byteLength < len) {\n this.arrBuf = new ArrayBuffer(len)\n }\n const buf = new Uint8Array(this.arrBuf, 0, len)\n let idx = 0\n while (idx < len) {\n const left = len - idx\n let next = await this.nextBuffer()\n if (next.length > left) {\n this.nextIdx += left\n next = next.subarray(0, left)\n } else {\n this.nextIdx += next.length\n }\n buf.set(next, idx)\n idx += next.length\n }\n return buf\n }\n\n /**\n * Read a line on Windows (handles VT100 escape sequences).\n * @return The line.\n */\n public async readLineOnWindows (): Promise<string> {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n let buf = new Uint8Array(this.arrBuf) as Uint8Array\n let lastByte = 0x1b\n let skipVT100 = false\n let hasNewline = false\n let mayDuplicate = false\n let hasCursorHome = false\n let preHasCursorHome = false\n let idx = 0\n while (true) {\n let next = await this.nextBuffer()\n const newLineIdx = next.indexOf(0x21) // '!'\n if (newLineIdx >= 0) {\n this.nextIdx += newLineIdx + 1 // +1 to ignore the '!'\n next = next.subarray(0, newLineIdx)\n } else {\n this.nextIdx += next.length\n }\n for (let i = 0; i < next.length; i++) {\n const c = next[i]\n if (c === 0x03) {\n // `ctrl + c` to interrupt\n throw new TrzszError('Interrupted')\n }\n if (c === 0x0a) {\n hasNewline = true\n }\n if (skipVT100) {\n if (isVT100End(c)) {\n skipVT100 = false\n // moving the cursor may result in duplicate characters\n if (c === 0x48 && lastByte >= 0x30 && lastByte <= 0x39) {\n mayDuplicate = true\n }\n }\n if (lastByte === 0x5b && c === 0x48) {\n hasCursorHome = true\n }\n lastByte = c\n } else if (c === 0x1b) {\n skipVT100 = true\n lastByte = c\n } else if (isTrzszLetter(c)) {\n if (mayDuplicate) {\n mayDuplicate = false\n // skip the duplicate characters, e.g., the \"8\" in \"8\\r\\n\\x1b[25;119H8\".\n if (hasNewline && idx > 0 && (c === buf[idx - 1] || preHasCursorHome)) {\n buf[idx - 1] = c\n continue\n }\n }\n if (idx >= buf.length) {\n buf = this.growBuffer(buf, idx, next.length)\n }\n buf[idx++] = c\n preHasCursorHome = hasCursorHome\n hasCursorHome = false\n hasNewline = false\n }\n }\n if (newLineIdx >= 0 && idx > 0 && !skipVT100) {\n return await uint8ToStr(buf.subarray(0, idx))\n }\n }\n }\n}\n"],"names":["TrzszError","strToUint8","uint8ToStr","isVT100End"],"mappings":"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"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* trzsz2: https://github.com/zxdong262/trzsz2
|
|
3
|
+
* Copyright(c) 2024 Lonny Wong
|
|
4
|
+
* @license MIT
|
|
5
|
+
*
|
|
6
|
+
* Pure protocol implementation without fs/browser dependencies.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* TrzszBuffer class for handling buffer operations.
|
|
10
|
+
*/
|
|
11
|
+
export declare class TrzszBuffer {
|
|
12
|
+
private bufArray;
|
|
13
|
+
private resolve;
|
|
14
|
+
private reject;
|
|
15
|
+
private bufHead;
|
|
16
|
+
private bufTail;
|
|
17
|
+
private nextIdx;
|
|
18
|
+
private nextBuf;
|
|
19
|
+
private arrBuf;
|
|
20
|
+
/**
|
|
21
|
+
* Add a buffer to the queue.
|
|
22
|
+
* @param buf - The buffer to add.
|
|
23
|
+
*/
|
|
24
|
+
addBuffer(buf: string | ArrayBuffer | Uint8Array | Blob): void;
|
|
25
|
+
/**
|
|
26
|
+
* Stop the buffer and reject any pending operations.
|
|
27
|
+
*/
|
|
28
|
+
stopBuffer(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Drain all buffers.
|
|
31
|
+
*/
|
|
32
|
+
drainBuffer(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Convert a buffer to Uint8Array.
|
|
35
|
+
* @param buf - The buffer to convert.
|
|
36
|
+
* @return The resulting Uint8Array.
|
|
37
|
+
*/
|
|
38
|
+
private toUint8Array;
|
|
39
|
+
/**
|
|
40
|
+
* Get the next buffer.
|
|
41
|
+
* @return The next buffer.
|
|
42
|
+
*/
|
|
43
|
+
private nextBuffer;
|
|
44
|
+
/**
|
|
45
|
+
* Grow the buffer.
|
|
46
|
+
* @param dst - The destination buffer.
|
|
47
|
+
* @param idx - The current index.
|
|
48
|
+
* @param min - The minimum size needed.
|
|
49
|
+
* @return The grown buffer.
|
|
50
|
+
*/
|
|
51
|
+
private growBuffer;
|
|
52
|
+
/**
|
|
53
|
+
* Append a buffer to another.
|
|
54
|
+
* @param dst - The destination buffer.
|
|
55
|
+
* @param idx - The current index.
|
|
56
|
+
* @param src - The source buffer.
|
|
57
|
+
* @return The resulting buffer.
|
|
58
|
+
*/
|
|
59
|
+
private appendBuffer;
|
|
60
|
+
/**
|
|
61
|
+
* Read a line from the buffer.
|
|
62
|
+
* @return The line.
|
|
63
|
+
*/
|
|
64
|
+
readLine(): Promise<string>;
|
|
65
|
+
/**
|
|
66
|
+
* Read binary data from the buffer.
|
|
67
|
+
* @param len - The length to read.
|
|
68
|
+
* @return The binary data.
|
|
69
|
+
*/
|
|
70
|
+
readBinary(len: number): Promise<Uint8Array>;
|
|
71
|
+
/**
|
|
72
|
+
* Read a line on Windows (handles VT100 escape sequences).
|
|
73
|
+
* @return The line.
|
|
74
|
+
*/
|
|
75
|
+
readLineOnWindows(): Promise<string>;
|
|
76
|
+
}
|