var U=Uint8Array,b=Uint16Array,rr=Uint32Array,er=new U([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),fr=new U([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hr=new U([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ar=function(r,a){for(var v=new b(31),n=0;n<31;++n)v[n]=a+=1<>>1|(c&21845)<<1;$=($&52428)>>>2|($&13107)<<2,$=($&61680)>>>4|($&3855)<<4,cr[c]=(($&65280)>>>8|($&255)<<8)>>>1}var Y=function(r,a,v){for(var n=r.length,f=0,i=new b(a);f>>l]=w}else for(u=new b(n),f=0;f>>15-r[f];return u},_=new U(288);for(var c=0;c<144;++c)_[c]=8;for(var c=144;c<256;++c)_[c]=9;for(var c=256;c<280;++c)_[c]=7;for(var c=280;c<288;++c)_[c]=8;var ar=new U(32);for(var c=0;c<32;++c)ar[c]=5;var qr=Y(_,9,0),Br=Y(_,9,1),Tr=Y(ar,5,0),yr=Y(ar,5,1),lr=function(r){for(var a=r[0],v=1;va&&(a=r[v]);return a},Q=function(r,a,v){var n=a/8>>0;return(r[n]|r[n+1]<<8)>>>(a&7)&v},or=function(r,a){var v=a/8>>0;return(r[v]|r[v+1]<<8|r[v+2]<<16)>>>(a&7)},gr=function(r){return(r/8>>0)+(r&7&&1)},Sr=function(r,a,v){(a==null||a<0)&&(a=0),(v==null||v>r.length)&&(v=r.length);var n=new(r instanceof b?b:r instanceof rr?rr:U)(v-a);return n.set(r.subarray(a,v)),n},Dr=function(r,a,v){var n=r.length,f=!a||v,i=!v||v.i;v||(v={}),a||(a=new U(n*3));var h=function(vr){var m=a.length;if(vr>m){var L=new U(Math.max(m*2,vr));L.set(a),a=L}},u=v.f||0,l=v.p||0,w=v.b||0,e=v.l,g=v.d,M=v.m,t=v.n,C=n*8;do{if(!e){v.f=u=Q(r,l,1);var z=Q(r,l+1,3);if(l+=3,z)if(z==1)e=Br,g=yr,M=9,t=5;else if(z==2){var R=Q(r,l,31)+257,K=Q(r,l+10,15)+4,B=R+Q(r,l+5,31)+1;l+=14;for(var A=new U(B),x=new U(19),o=0;oC)break;for(var j=Y(x,N,1),o=0;o>>4;if(F<16)A[o++]=F;else{var G=0,O=0;for(F==16?(O=3+Q(r,l,3),l+=2,G=A[o-1]):F==17?(O=3+Q(r,l,7),l+=3):F==18&&(O=11+Q(r,l,127),l+=7);O--;)A[o++]=G}}var y=A.subarray(0,R),s=A.subarray(R);M=lr(y),t=lr(s),e=Y(y,M,1),g=Y(s,t,1)}else throw"invalid block type";else{var F=gr(l)+4,J=r[F-4]|r[F-3]<<8,q=F+J;if(q>n){if(i)throw"unexpected EOF";break}f&&h(w+J),a.set(r.subarray(F,q),w),v.b=w+=J,v.p=l=q*8;continue}if(l>C)throw"unexpected EOF"}f&&h(w+131072);for(var k=(1<>>4;if(l+=G&15,l>C)throw"unexpected EOF";if(!G)throw"invalid length/literal";if(W<256)a[w++]=W;else if(W==256){e=null;break}else{var I=W-254;if(W>264){var o=W-257,P=er[o];I=Q(r,l,(1<>>4;if(!X)throw"invalid distance";l+=X&15;var s=br[D];if(D>3){var P=fr[D];s+=or(r,l)&(1<C)throw"unexpected EOF";f&&h(w+131072);for(var S=w+I;w>0;r[n]|=v,r[n+1]|=v>>>8},p=function(r,a,v){v<<=a&7;var n=a/8>>0;r[n]|=v,r[n+1]|=v>>>8,r[n+2]|=v>>>16},wr=function(r,a){for(var v=[],n=0;nM&&(M=i[n].s);var t=new b(M+1),C=tr(v[e-1],t,0);if(C>a){var n=0,z=0,F=C-a,J=1<a)z+=J-(1<>>=F;z>0;){var R=i[n].s;t[R]=0&&z;--n){var K=i[n].s;t[K]==a&&(--t[K],++z)}C=a}return[new U(t),C]},tr=function(r,a,v){return r.s==-1?Math.max(tr(r.l,a,v+1),tr(r.r,a,v+1)):a[r.s]=v},kr=function(r){for(var a=r.length;a&&!r[--a];);for(var v=new b(++a),n=0,f=r[0],i=1,h=function(l){v[n++]=l},u=1;u<=a;++u)if(r[u]==f&&u!=a)++i;else{if(!f&&i>2){for(;i>138;i-=138)h(32754);i>2&&(h(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(h(f),--i;i>6;i-=6)h(8304);i>2&&(h(i-3<<5|8208),i=0)}for(;i--;)h(f);i=1,f=r[u]}return[v.subarray(0,n),a]},d=function(r,a){for(var v=0,n=0;n>>8,r[f+2]=r[f]^255,r[f+3]=r[f+1]^255;for(var i=0;i4&&!T[hr[E-1]];--E);var G=w+5<<3,O=d(f,_)+d(i,ar)+h,y=d(f,M)+d(i,z)+h+14+3*E+d(x,T)+(2*x[16]+3*x[17]+7*x[18]);if(G<=O&&G<=y)return nr(a,e,r.subarray(l,l+w));var s,k,H,V;if(Z(a,e,1+(y15&&(Z(a,e,X[o]>>>5&127),e+=X[o]>>>12)}}else s=qr,k=_,H=Tr,V=ar;for(var o=0;o255){var D=n[o]>>>18&31;p(a,e,s[D+257]),e+=k[D+257],D>7&&(Z(a,e,n[o]>>>23&31),e+=er[D]);var S=n[o]&31;p(a,e,H[S]),e+=V[S],S>3&&(p(a,e,n[o]>>>5&8191),e+=fr[S])}else p(a,e,s[n[o]]),e+=k[n[o]];return p(a,e,s[256]),e+k[256]},Gr=new rr([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hr=new U(0),Ir=function(r,a,v,n,f,i){var h=r.length,u=new U(n+h+5*(1+Math.floor(h/7e3))+f),l=u.subarray(n,u.length-f),w=0;if(!a||h<8)for(var e=0;e<=h;e+=65535){var g=e+65535;g>>13,C=M&8191,z=(1<7e3||T>24576)&&s>423){w=zr(r,l,0,B,A,x,N,T,E,e-E,w),T=o=N=0,E=e;for(var k=0;k<286;++k)A[k]=0;for(var k=0;k<30;++k)x[k]=0}var H=2,V=0,W=C,I=O-y&32767;if(s>2&&G==K(e-I))for(var P=Math.min(t,s)-1,X=Math.min(32767,e),D=Math.min(258,s);I<=X&&--W&&O!=y;){if(r[e+H]==r[e+H-I]){for(var S=0;SH){if(H=S,V=I,S>P)break;for(var vr=Math.min(I,S-2),m=0,k=0;km&&(m=Mr,y=L)}}}O=y,y=F[O],I+=O-y+32768&32767}if(V){B[T++]=268435456|ur[H]<<18|sr[V];var Fr=ur[H]&31,xr=sr[V]&31;N+=er[Fr]+fr[xr],++A[257+Fr],++x[xr],j=e+H,++o}else B[T++]=r[e],++A[r[e]]}}w=zr(r,l,i,B,A,x,N,T,E,e-E,w),i||(w=nr(l,w,Hr))}return Sr(u,0,n+gr(w)+f)},Jr=function(){var r=1,a=0;return{p:function(v){for(var n=r,f=a,i=v.length,h=0;h!=i;){for(var u=Math.min(h+5552,i);h>>8<<16|(a&255)<<8|a>>>8)+((r&255)<<23)*2}}},Kr=function(r,a,v,n,f){return Ir(r,a.level==null?6:a.level,a.mem==null?Math.ceil(Math.max(8,Math.min(13,Math.log(r.length)))*1.5):12+a.mem,v,n,!f)},Nr=function(r,a,v){for(;v;++a)r[a]=v,v>>>=8},Pr=function(r,a){var v=a.level,n=v==0?0:v<6?1:v==9?3:2;r[0]=120,r[1]=n<<6|(n?32-2*n:1)},Qr=function(r){if((r[0]&15)!=8||r[0]>>>4>7||(r[0]<<8|r[1])%31)throw"invalid zlib data";if(r[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function Rr(r,a){a===void 0&&(a={});var v=Jr();v.p(r);var n=Kr(r,a,2,4);return Pr(n,a),Nr(n,n.length-4,v.d()),n}function Vr(r,a){return Dr((Qr(r),r.subarray(2,-4)),a)}export{Vr as u,Rr as z};