pako
Version:
zlib port to javascript - fast, modularized, with browser support
2 lines • 26.6 kB
JavaScript
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.pako={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=4,n=0,r=1,i=2;function a(e){let t=e.length;for(;--t>=0;)e[t]=0}var o=0,s=1,c=2,l=29,u=256,d=286,f=30,p=19,m=573,h=15,g=16,_=7,ee=256,te=16,ne=17,re=18,ie=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]),v=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]),ae=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),oe=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),se=512,y=Array(288*2);a(y);var b=Array(f*2);a(b);var x=Array(se);a(x);var S=Array(256);a(S);var ce=Array(l);a(ce);var C=Array(f);a(C);var le=class{constructor(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}},ue,de,fe,pe=class{constructor(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}},me=e=>e<256?x[e]:x[256+(e>>>7)],w=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},T=(e,t,n)=>{e.bi_valid>g-n?(e.bi_buf|=t<<e.bi_valid&65535,w(e,e.bi_buf),e.bi_buf=t>>g-e.bi_valid,e.bi_valid+=n-g):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},E=(e,t,n)=>{T(e,n[t*2],n[t*2+1])},he=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},ge=e=>{e.bi_valid===16?(w(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)},_e=(e,t)=>{let n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,a=t.stat_desc.has_stree,o=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,d,f,p,g,_=0;for(f=0;f<=h;f++)e.bl_count[f]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<m;l++)u=e.heap[l],f=n[n[u*2+1]*2+1]+1,f>c&&(f=c,_++),n[u*2+1]=f,!(u>r)&&(e.bl_count[f]++,p=0,u>=s&&(p=o[u-s]),g=n[u*2],e.opt_len+=g*(f+p),a&&(e.static_len+=g*(i[u*2+1]+p)));if(_!==0){do{for(f=c-1;e.bl_count[f]===0;)f--;e.bl_count[f]--,e.bl_count[f+1]+=2,e.bl_count[c]--,_-=2}while(_>0);for(f=c;f!==0;f--)for(u=e.bl_count[f];u!==0;)d=e.heap[--l],!(d>r)&&(n[d*2+1]!==f&&(e.opt_len+=(f-n[d*2+1])*n[d*2],n[d*2+1]=f),u--)}},ve=(e,t,n)=>{let r=Array(16),i=0,a,o;for(a=1;a<=h;a++)i=i+n[a-1]<<1,r[a]=i;for(o=0;o<=t;o++){let t=e[o*2+1];t!==0&&(e[o*2]=he(r[t]++,t))}},ye=()=>{let e,t,n,r,i,a=Array(16);for(n=0,r=0;r<l-1;r++)for(ce[r]=n,e=0;e<1<<ie[r];e++)S[n++]=r;for(S[n-1]=r,i=0,r=0;r<16;r++)for(C[r]=i,e=0;e<1<<v[r];e++)x[i++]=r;for(i>>=7;r<f;r++)for(C[r]=i<<7,e=0;e<1<<v[r]-7;e++)x[256+i++]=r;for(t=0;t<=h;t++)a[t]=0;for(e=0;e<=143;)y[e*2+1]=8,e++,a[8]++;for(;e<=255;)y[e*2+1]=9,e++,a[9]++;for(;e<=279;)y[e*2+1]=7,e++,a[7]++;for(;e<=287;)y[e*2+1]=8,e++,a[8]++;for(ve(y,287,a),e=0;e<f;e++)b[e*2+1]=5,b[e*2]=he(e,5);ue=new le(y,ie,257,d,h),de=new le(b,v,0,f,h),fe=new le([],ae,0,p,_)},be=e=>{let t;for(t=0;t<d;t++)e.dyn_ltree[t*2]=0;for(t=0;t<f;t++)e.dyn_dtree[t*2]=0;for(t=0;t<p;t++)e.bl_tree[t*2]=0;e.dyn_ltree[ee*2]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},xe=e=>{e.bi_valid>8?w(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},Se=(e,t,n,r)=>{let i=t*2,a=n*2;return e[i]<e[a]||e[i]===e[a]&&r[t]<=r[n]},Ce=(e,t,n)=>{let r=e.heap[n],i=n<<1;for(;i<=e.heap_len&&(i<e.heap_len&&Se(t,e.heap[i+1],e.heap[i],e.depth)&&i++,!Se(t,r,e.heap[i],e.depth));)e.heap[n]=e.heap[i],n=i,i<<=1;e.heap[n]=r},we=(e,t,n)=>{let r,i,a=0,o,s;if(e.sym_next!==0)do r=e.pending_buf[e.sym_buf+a++]&255,r+=(e.pending_buf[e.sym_buf+a++]&255)<<8,i=e.pending_buf[e.sym_buf+a++],r===0?E(e,i,t):(o=S[i],E(e,o+u+1,t),s=ie[o],s!==0&&(i-=ce[o],T(e,i,s)),r--,o=me(r),E(e,o,n),s=v[o],s!==0&&(r-=C[o],T(e,r,s)));while(a<e.sym_next);E(e,ee,t)},Te=(e,t)=>{let n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,a=t.stat_desc.elems,o,s,c=-1,l;for(e.heap_len=0,e.heap_max=m,o=0;o<a;o++)n[o*2]===0?n[o*2+1]=0:(e.heap[++e.heap_len]=c=o,e.depth[o]=0);for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,i&&(e.static_len-=r[l*2+1]);for(t.max_code=c,o=e.heap_len>>1;o>=1;o--)Ce(e,n,o);l=a;do o=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ce(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=o,e.heap[--e.heap_max]=s,n[l*2]=n[o*2]+n[s*2],e.depth[l]=(e.depth[o]>=e.depth[s]?e.depth[o]:e.depth[s])+1,n[o*2+1]=n[s*2+1]=l,e.heap[1]=l++,Ce(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],_e(e,t),ve(n,c,e.bl_count)},Ee=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)&&(s<l?e.bl_tree[a*2]+=s:a===0?s<=10?e.bl_tree[ne*2]++:e.bl_tree[re*2]++:(a!==i&&e.bl_tree[a*2]++,e.bl_tree[te*2]++),s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4))},De=(e,t,n)=>{let r,i=-1,a,o=t[1],s=0,c=7,l=4;for(o===0&&(c=138,l=3),r=0;r<=n;r++)if(a=o,o=t[(r+1)*2+1],!(++s<c&&a===o)){if(s<l)do E(e,a,e.bl_tree);while(--s!==0);else a===0?s<=10?(E(e,ne,e.bl_tree),T(e,s-3,3)):(E(e,re,e.bl_tree),T(e,s-11,7)):(a!==i&&(E(e,a,e.bl_tree),s--),E(e,te,e.bl_tree),T(e,s-3,2));s=0,i=a,o===0?(c=138,l=3):a===o?(c=6,l=3):(c=7,l=4)}},Oe=e=>{let t;for(Ee(e,e.dyn_ltree,e.l_desc.max_code),Ee(e,e.dyn_dtree,e.d_desc.max_code),Te(e,e.bl_desc),t=p-1;t>=3&&e.bl_tree[oe[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},ke=(e,t,n,r)=>{let i;for(T(e,t-257,5),T(e,n-1,5),T(e,r-4,4),i=0;i<r;i++)T(e,e.bl_tree[oe[i]*2+1],3);De(e,e.dyn_ltree,t-1),De(e,e.dyn_dtree,n-1)},Ae=e=>{let t=4093624447,i;for(i=0;i<=31;i++,t>>>=1)if(t&1&&e.dyn_ltree[i*2]!==0)return n;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return r;for(i=32;i<u;i++)if(e.dyn_ltree[i*2]!==0)return r;return n},je=!1,Me=e=>{je||(ye(),je=!0),e.l_desc=new pe(e.dyn_ltree,ue),e.d_desc=new pe(e.dyn_dtree,de),e.bl_desc=new pe(e.bl_tree,fe),e.bi_buf=0,e.bi_valid=0,be(e)},Ne=(e,t,n,r)=>{T(e,(o<<1)+ +!!r,3),xe(e),w(e,n),w(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},Pe=e=>{T(e,s<<1,3),E(e,ee,y),ge(e)},Fe=(e,n,r,a)=>{let o,l,u=0;e.level>0?(e.strm.data_type===i&&(e.strm.data_type=Ae(e)),Te(e,e.l_desc),Te(e,e.d_desc),u=Oe(e),o=e.opt_len+3+7>>>3,l=e.static_len+3+7>>>3,l<=o&&(o=l)):o=l=r+5,r+4<=o&&n!==-1?Ne(e,n,r,a):e.strategy===t||l===o?(T(e,(s<<1)+ +!!a,3),we(e,y,b)):(T(e,(c<<1)+ +!!a,3),ke(e,e.l_desc.max_code+1,e.d_desc.max_code+1,u+1),we(e,e.dyn_ltree,e.dyn_dtree)),be(e),a&&xe(e)},D=(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(S[n]+u+1)*2]++,e.dyn_dtree[me(t)*2]++),e.sym_next===e.sym_end),Ie=(e,t,n,r)=>{let i=e&65535|0,a=e>>>16&65535|0,o=0;for(;n!==0;){o=n>2e3?2e3:n,n-=o;do i=i+t[r++]|0,a=a+i|0;while(--o);i%=65521,a%=65521}return i|a<<16|0},Le=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t})()),O=(e,t,n,r)=>{let i=Le,a=r+n;e^=-1;for(let n=r;n<a;n++)e=e>>>8^i[(e^t[n])&255];return e^-1},k={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`},Re=9,ze=573,A=3,j=258,M=262,Be=32,N=42,Ve=57,He=69,Ue=73,We=91,Ge=103,P=113,F=666,I=1,L=2,R=3,z=4,Ke=3,B=(e,t)=>(e.msg=k[t],t),qe=e=>e*2-(e>4?9:0),V=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Je=e=>{let t,n,r,i=e.w_size;t=e.hash_size,r=t;do n=e.head[--r],e.head[r]=n>=i?n-i:0;while(--t);t=i,r=t;do n=e.prev[--r],e.prev[r]=n>=i?n-i:0;while(--t)},Ye=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask,H=(e,t)=>{let n;if(e.legacy_hash)n=e.ins_h=Ye(e,e.ins_h,e.window[t+A-1]);else{let r=e.window,i=r[t]|r[t+1]<<8|r[t+2]<<16|r[t+3]<<24;n=e.ins_h=Math.imul(i,66521)+66521>>>16&e.hash_mask}let r=e.prev[t&e.w_mask]=e.head[n];return e.head[n]=t,r},U=e=>{let t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},W=(e,t)=>{Fe(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,U(e.strm)},G=(e,t)=>{e.pending_buf[e.pending++]=t},K=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},Xe=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=Ie(e.adler,t,i,n):e.state.wrap===2&&(e.adler=O(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},Ze=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,a,o=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-M?e.strstart-(e.w_size-M):0,l=e.window,u=e.w_mask,d=e.prev,f=e.strstart+j,p=l[r+o-1],m=l[r+o];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do{if(i=t,l[i+o]!==m||l[i+o-1]!==p||l[i]!==l[r]||l[++i]!==l[r+1])continue;r+=2,i++;do;while(l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&l[++r]===l[++i]&&r<f);if(a=j-(f-r),r=f-j,a>o){if(e.match_start=t,o=a,a>=s)break;p=l[r+o-1],m=l[r+o]}}while((t=d[t&u])>c&&--n!==0);return o<=e.lookahead?o:e.lookahead},q=e=>{let t=e.w_size,n,r,i;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-M)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Je(e),r+=t),e.strm.avail_in===0)break;if(n=Xe(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,!e.legacy_hash){if(e.lookahead+e.insert>A)for(i=e.strstart-e.insert;e.insert&&(H(e,i),i++,e.insert--,!(e.lookahead+e.insert<=A)););}else if(e.lookahead+e.insert>=A)for(i=e.strstart-e.insert,e.ins_h=e.window[i],e.ins_h=Ye(e,e.ins_h,e.window[i+1]);e.insert&&(H(e,i),i++,e.insert--,!(e.lookahead+e.insert<A)););}while(e.lookahead<M&&e.strm.avail_in!==0)},Qe=(e,t)=>{let n=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r,i,a,o=0,s=e.strm.avail_in;do{if(r=65535,a=e.bi_valid+42>>3,e.strm.avail_out<a||(a=e.strm.avail_out-a,i=e.strstart-e.block_start,r>i+e.strm.avail_in&&(r=i+e.strm.avail_in),r>a&&(r=a),r<n&&(r===0&&t!==4||t===0||r!==i+e.strm.avail_in)))break;o=+(t===4&&r===i+e.strm.avail_in),Ne(e,0,0,o),e.pending_buf[e.pending-4]=r,e.pending_buf[e.pending-3]=r>>8,e.pending_buf[e.pending-2]=~r,e.pending_buf[e.pending-1]=~r>>8,U(e.strm),i&&(i>r&&(i=r),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+i),e.strm.next_out),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i,e.block_start+=i,r-=i),r&&(Xe(e.strm,e.strm.output,e.strm.next_out,r),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r)}while(o===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),o?z:t!==0&&t!==4&&e.strm.avail_in===0&&e.strstart===e.block_start?L:(a=e.window_size-e.strstart,e.strm.avail_in>a&&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++,a+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),a>e.strm.avail_in&&(a=e.strm.avail_in),a&&(Xe(e.strm,e.window,e.strstart,a),e.strstart+=a,e.insert+=a>e.w_size-e.insert?e.w_size-e.insert:a),e.high_water<e.strstart&&(e.high_water=e.strstart),a=e.bi_valid+42>>3,a=e.pending_buf_size-a>65535?65535:e.pending_buf_size-a,n=a>e.w_size?e.w_size:a,i=e.strstart-e.block_start,(i>=n||(i||t===4)&&t!==0&&e.strm.avail_in===0&&i<=a)&&(r=i>a?a:i,o=+(t===4&&e.strm.avail_in===0&&r===i),Ne(e,e.block_start,r,o),e.block_start+=r,U(e.strm)),o?R:I)},$e=(e,t)=>{let n,r;for(;;){if(e.lookahead<M){if(q(e),e.lookahead<M&&t===0)return I;if(e.lookahead===0)break}if(n=0,e.lookahead>=A&&(n=H(e,e.strstart)),n!==0&&e.strstart-n<=e.w_size-M&&(e.match_length=Ze(e,n)),e.match_length>=A)if(r=D(e,e.strstart-e.match_start,e.match_length-A),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=A){e.match_length--;do e.strstart++,n=H(e,e.strstart);while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.legacy_hash&&(e.ins_h=e.window[e.strstart],e.ins_h=Ye(e,e.ins_h,e.window[e.strstart+1]));else r=D(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(W(e,!1),e.strm.avail_out===0))return I}return e.insert=e.strstart<A-1?e.strstart:A-1,t===4?(W(e,!0),e.strm.avail_out===0?R:z):e.sym_next&&(W(e,!1),e.strm.avail_out===0)?I:L},J=(e,t)=>{let n,r,i;for(;;){if(e.lookahead<M){if(q(e),e.lookahead<M&&t===0)return I;if(e.lookahead===0)break}if(n=0,e.lookahead>=A&&(n=H(e,e.strstart)),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=A-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-M&&(e.match_length=Ze(e,n),e.match_length<=5&&(e.strategy===1||e.match_length===A&&e.strstart-e.match_start>4096)&&(e.match_length=A-1)),e.prev_length>=A&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-A,r=D(e,e.strstart-1-e.prev_match,e.prev_length-A),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(n=H(e,e.strstart));while(--e.prev_length!==0);if(e.match_available=0,e.match_length=A-1,e.strstart++,r&&(W(e,!1),e.strm.avail_out===0))return I}else if(e.match_available){if(r=D(e,0,e.window[e.strstart-1]),r&&W(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return I}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=D(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<A-1?e.strstart:A-1,t===4?(W(e,!0),e.strm.avail_out===0?R:z):e.sym_next&&(W(e,!1),e.strm.avail_out===0)?I:L},et=(e,t)=>{let n,r,i,a,o=e.window;for(;;){if(e.lookahead<=j){if(q(e),e.lookahead<=j&&t===0)return I;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=A&&e.strstart>0&&(i=e.strstart-1,r=o[i],r===o[++i]&&r===o[++i]&&r===o[++i])){a=e.strstart+j;do;while(r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&r===o[++i]&&i<a);e.match_length=j-(a-i),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=A?(n=D(e,1,e.match_length-A),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=D(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(W(e,!1),e.strm.avail_out===0))return I}return e.insert=0,t===4?(W(e,!0),e.strm.avail_out===0?R:z):e.sym_next&&(W(e,!1),e.strm.avail_out===0)?I:L},tt=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(q(e),e.lookahead===0)){if(t===0)return I;break}if(e.match_length=0,n=D(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(W(e,!1),e.strm.avail_out===0))return I}return e.insert=0,t===4?(W(e,!0),e.strm.avail_out===0?R:z):e.sym_next&&(W(e,!1),e.strm.avail_out===0)?I:L},Y=class{constructor(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}},X=[new Y(0,0,0,0,Qe),new Y(4,4,8,4,$e),new Y(4,5,16,8,$e),new Y(4,6,32,32,$e),new Y(4,4,16,16,J),new Y(8,16,32,32,J),new Y(8,16,128,128,J),new Y(8,32,128,256,J),new Y(32,128,258,1024,J),new Y(32,258,258,4096,J)],nt=e=>{e.window_size=2*e.w_size,V(e.head),e.max_lazy_match=X[e.level].max_lazy,e.good_match=X[e.level].good_length,e.nice_match=X[e.level].nice_length,e.max_chain_length=X[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=A-1,e.match_available=0,e.ins_h=0},rt=class{constructor(){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=8,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.legacy_hash=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(ze*2),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),V(this.dyn_ltree),V(this.dyn_dtree),V(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),V(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),V(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}},Z=e=>{if(!e)return 1;let t=e.state;return+(!t||t.strm!==e||t.status!==N&&t.status!==Ve&&t.status!==He&&t.status!==Ue&&t.status!==We&&t.status!==Ge&&t.status!==P&&t.status!==F)},it=e=>{if(Z(e))return B(e,-2);e.total_in=e.total_out=0,e.data_type=2;let t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap===2?Ve:t.wrap?N:P,e.adler=t.wrap===2?0:1,t.last_flush=-2,Me(t),0},at=e=>{let t=it(e);return t===0&&nt(e.state),t},ot=(e,t,n,r,i,a,o)=>{if(!e)return-2;let s=1;if(t===-1&&(t=6),r<0?(s=0,r=-r):r>15&&(s=2,r-=16),i<1||i>Re||n!==8||r<8||r>15||t<0||t>9||a<0||a>4||r===8&&s!==1)return B(e,-2);r===8&&(r=9);let c=new rt;return e.state=c,c.strm=e,c.status=N,c.wrap=s,c.gzhead=null,c.w_bits=r,c.w_size=1<<c.w_bits,c.w_mask=c.w_size-1,c.legacy_hash=+!!o,c.hash_bits=i+7,!c.legacy_hash&&c.hash_bits<15&&(c.hash_bits=15),c.hash_size=1<<c.hash_bits,c.hash_mask=c.hash_size-1,c.hash_shift=~~((c.hash_bits+A-1)/A),c.window=new Uint8Array(c.w_size*2),c.head=new Uint16Array(c.hash_size),c.prev=new Uint16Array(c.w_size),c.lit_bufsize=1<<i+6,c.pending_buf_size=c.lit_bufsize*4,c.pending_buf=new Uint8Array(c.pending_buf_size),c.sym_buf=c.lit_bufsize,c.sym_end=(c.lit_bufsize-1)*3,c.level=t,c.strategy=a,c.method=n,at(e)},st=(e,t)=>{if(Z(e)||t>5||t<0)return e?B(e,-2):-2;let n=e.state;if(!e.output||e.avail_in!==0&&!e.input||n.status===F&&t!==4)return B(e,e.avail_out===0?-5:-2);let r=n.last_flush;if(n.last_flush=t,n.pending!==0){if(U(e),e.avail_out===0)return n.last_flush=-1,0}else if(e.avail_in===0&&qe(t)<=qe(r)&&t!==4)return B(e,-5);if(n.status===F&&e.avail_in!==0)return B(e,-5);if(n.status===N&&n.wrap===0&&(n.status=P),n.status===N){let t=8+(n.w_bits-8<<4)<<8,r=-1;if(r=n.strategy>=2||n.level<2?0:n.level<6?1:n.level===6?2:3,t|=r<<6,n.strstart!==0&&(t|=Be),t+=31-t%31,K(n,t),n.strstart!==0&&(K(n,e.adler>>>16),K(n,e.adler&65535)),e.adler=1,n.status=P,U(e),n.pending!==0)return n.last_flush=-1,0}if(n.status===Ve){if(e.adler=0,G(n,31),G(n,139),G(n,8),n.gzhead)G(n,+!!n.gzhead.text+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),G(n,n.gzhead.time&255),G(n,n.gzhead.time>>8&255),G(n,n.gzhead.time>>16&255),G(n,n.gzhead.time>>24&255),G(n,n.level===9?2:n.strategy>=2||n.level<2?4:0),G(n,n.gzhead.os&255),n.gzhead.extra&&n.gzhead.extra.length&&(G(n,n.gzhead.extra.length&255),G(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=O(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=He;else if(G(n,0),G(n,0),G(n,0),G(n,0),G(n,0),G(n,n.level===9?2:n.strategy>=2||n.level<2?4:0),G(n,Ke),n.status=P,U(e),n.pending!==0)return n.last_flush=-1,0}if(n.status===He){if(n.gzhead.extra){let t=n.pending,r=(n.gzhead.extra.length&65535)-n.gzindex;for(;n.pending+r>n.pending_buf_size;){let i=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=O(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=i,U(e),n.pending!==0)return n.last_flush=-1,0;t=0,r-=i}let i=new Uint8Array(n.gzhead.extra);n.pending_buf.set(i.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending+=r,n.gzhead.hcrc&&n.pending>t&&(e.adler=O(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=Ue}if(n.status===Ue){if(n.gzhead.name){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=O(e.adler,n.pending_buf,n.pending-t,t)),U(e),n.pending!==0)return n.last_flush=-1,0;t=0}r=n.gzindex<n.gzhead.name.length?n.gzhead.name.charCodeAt(n.gzindex++)&255:0,G(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=O(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=We}if(n.status===We){if(n.gzhead.comment){let t=n.pending,r;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>t&&(e.adler=O(e.adler,n.pending_buf,n.pending-t,t)),U(e),n.pending!==0)return n.last_flush=-1,0;t=0}r=n.gzindex<n.gzhead.comment.length?n.gzhead.comment.charCodeAt(n.gzindex++)&255:0,G(n,r)}while(r!==0);n.gzhead.hcrc&&n.pending>t&&(e.adler=O(e.adler,n.pending_buf,n.pending-t,t))}n.status=Ge}if(n.status===Ge){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(U(e),n.pending!==0))return n.last_flush=-1,0;G(n,e.adler&255),G(n,e.adler>>8&255),e.adler=0}if(n.status=P,U(e),n.pending!==0)return n.last_flush=-1,0}if(e.avail_in!==0||n.lookahead!==0||t!==0&&n.status!==F){let r=n.level===0?Qe(n,t):n.strategy===2?tt(n,t):n.strategy===3?et(n,t):X[n.level].func(n,t);if((r===R||r===z)&&(n.status=F),r===I||r===R)return e.avail_out===0&&(n.last_flush=-1),0;if(r===L&&(t===1?Pe(n):t!==5&&(Ne(n,0,0,!1),t===3&&(V(n.head),n.lookahead===0&&(n.strstart=0,n.block_start=0,n.insert=0))),U(e),e.avail_out===0))return n.last_flush=-1,0}return t===4?n.wrap<=0?1:(n.wrap===2?(G(n,e.adler&255),G(n,e.adler>>8&255),G(n,e.adler>>16&255),G(n,e.adler>>24&255),G(n,e.total_in&255),G(n,e.total_in>>8&255),G(n,e.total_in>>16&255),G(n,e.total_in>>24&255)):(K(n,e.adler>>>16),K(n,e.adler&65535)),U(e),n.wrap>0&&(n.wrap=-n.wrap),+(n.pending===0)):0},ct=e=>{if(Z(e))return-2;let t=e.state.status;return e.state=null,t===P?B(e,-3):0},lt=(e,t)=>{let n=t.length;if(Z(e))return-2;let r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==N||r.lookahead)return-2;if(i===1&&(e.adler=Ie(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(V(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(n-r.w_size,n),0),t=e,n=r.w_size}let a=e.avail_in,o=e.next_in,s=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,q(r);r.lookahead>=A;){let e=r.strstart,t=r.lookahead-(A-1);do H(r,e),e++;while(--t);r.strstart=e,r.lookahead=A-1,q(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=A-1,r.match_available=0,e.next_in=o,e.input=s,e.avail_in=a,r.wrap=i,0};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]),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,199,75]),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]),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 ut=class{constructor(){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}},dt=e=>{let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t};function Q(e){"@babel/helpers - typeof";return Q=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Q(e)}function ft(e,t){if(Q(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Q(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function pt(e){var t=ft(e,`string`);return Q(t)==`symbol`?t:t+``}function $(e,t,n){return(t=pt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var mt=Object.prototype.toString,ht={level:-1,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,raw:!1,gzip:!1,legacyHash:!1,dictionary:new Uint8Array},gt=class{constructor(e={}){$(this,`options`,void 0),$(this,`err`,void 0),$(this,`msg`,void 0),$(this,`ended`,void 0),$(this,`started`,void 0),$(this,`chunks`,void 0),$(this,`strm`,void 0),$(this,`result`,void 0),this.options=Object.assign({},ht,e);let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg=``,this.ended=!1,this.started=!1,this.chunks=[],this.result=new Uint8Array,this.strm=new ut,this.strm.avail_out=0;let n=ot(this.strm,t.level,8,t.windowBits,t.memLevel,t.strategy,t.legacyHash);if(n!==0)throw Error(k[n]);mt.call(t.dictionary)===`[object ArrayBuffer]`&&(t.dictionary=new Uint8Array(t.dictionary));let r=t.dictionary;if(r.length){if(t.gzip)throw Error(`dictionary is not supported with gzip`);if(n=lt(this.strm,r),n!==0)throw Error(k[n])}}push(e,t=!1){let n=this.strm,r=this.options.chunkSize,i,a;if(this.ended)return!1;for(a=typeof t==`number`?t:t===!0?4:0,typeof e==`string`?n.input=new TextEncoder().encode(e):mt.call(e)===`[object ArrayBuffer]`?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length,this.started||(this.started=!0,this.onStart(n));;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(a===2||a===3)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=st(n,a),i===1){n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=ct(this.strm);break}if(n.avail_out===0){this.onData(n.output);continue}if(a>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)return!0}return this.err=i,this.msg=n.msg||k[i],this.ended=!0,this.onEnd(i),i===0}onStart(e){}onData(e){this.chunks.push(e)}onEnd(e){e===0&&(this.result=dt(this.chunks)),this.chunks=[]}};function _t(e,t={}){let n=new gt(t);if(n.push(e,!0),n.err)throw Error(n.msg);return n.result}function vt(e,t={}){return _t(e,Object.assign({},t,{raw:!0}))}function yt(e,t={}){return _t(e,Object.assign({},t,{gzip:!0}))}e.Deflate=gt,e.deflate=_t,e.deflateRaw=vt,e.gzip=yt});
//# sourceMappingURL=pako_deflate.umd.min.js.map