Files
misode.github.io/assets/deepslate.esm.37434e44.js
2022-05-07 00:11:13 +00:00

88 lines
128 KiB
JavaScript

import{e as jn}from"./index.e29e5ef6.js";/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */const Gs=4,Wi=0,Ki=1,$s=2;function Ze(e){let i=e.length;for(;--i>=0;)e[i]=0}const Xs=0,Vn=1,js=2,Vs=3,Js=258,Li=29,ut=256,it=ut+1+Li,Ce=30,zi=19,Jn=2*it+1,Se=15,ti=16,Ws=7,Ui=256,Wn=16,Kn=17,qn=18,xi=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]),kt=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]),Ks=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Qn=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),qs=512,le=new Array((it+2)*2);Ze(le);const We=new Array(Ce*2);Ze(We);const nt=new Array(qs);Ze(nt);const st=new Array(Js-Vs+1);Ze(st);const Zi=new Array(Li);Ze(Zi);const Ft=new Array(Ce);Ze(Ft);function ii(e,i,t,n,s){this.static_tree=e,this.extra_bits=i,this.extra_base=t,this.elems=n,this.max_length=s,this.has_stree=e&&e.length}let es,ts,is;function ni(e,i){this.dyn_tree=e,this.max_code=0,this.stat_desc=i}const ns=e=>e<256?nt[e]:nt[256+(e>>>7)],rt=(e,i)=>{e.pending_buf[e.pending++]=i&255,e.pending_buf[e.pending++]=i>>>8&255},K=(e,i,t)=>{e.bi_valid>ti-t?(e.bi_buf|=i<<e.bi_valid&65535,rt(e,e.bi_buf),e.bi_buf=i>>ti-e.bi_valid,e.bi_valid+=t-ti):(e.bi_buf|=i<<e.bi_valid&65535,e.bi_valid+=t)},ne=(e,i,t)=>{K(e,t[i*2],t[i*2+1])},ss=(e,i)=>{let t=0;do t|=e&1,e>>>=1,t<<=1;while(--i>0);return t>>>1},Qs=e=>{e.bi_valid===16?(rt(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)},er=(e,i)=>{const t=i.dyn_tree,n=i.max_code,s=i.stat_desc.static_tree,r=i.stat_desc.has_stree,a=i.stat_desc.extra_bits,o=i.stat_desc.extra_base,c=i.stat_desc.max_length;let l,h,d,u,f,g,v=0;for(u=0;u<=Se;u++)e.bl_count[u]=0;for(t[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<Jn;l++)h=e.heap[l],u=t[t[h*2+1]*2+1]+1,u>c&&(u=c,v++),t[h*2+1]=u,!(h>n)&&(e.bl_count[u]++,f=0,h>=o&&(f=a[h-o]),g=t[h*2],e.opt_len+=g*(u+f),r&&(e.static_len+=g*(s[h*2+1]+f)));if(v!==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]--,v-=2}while(v>0);for(u=c;u!==0;u--)for(h=e.bl_count[u];h!==0;)d=e.heap[--l],!(d>n)&&(t[d*2+1]!==u&&(e.opt_len+=(u-t[d*2+1])*t[d*2],t[d*2+1]=u),h--)}},rs=(e,i,t)=>{const n=new Array(Se+1);let s=0,r,a;for(r=1;r<=Se;r++)n[r]=s=s+t[r-1]<<1;for(a=0;a<=i;a++){let o=e[a*2+1];o!==0&&(e[a*2]=ss(n[o]++,o))}},tr=()=>{let e,i,t,n,s;const r=new Array(Se+1);for(t=0,n=0;n<Li-1;n++)for(Zi[n]=t,e=0;e<1<<xi[n];e++)st[t++]=n;for(st[t-1]=n,s=0,n=0;n<16;n++)for(Ft[n]=s,e=0;e<1<<kt[n];e++)nt[s++]=n;for(s>>=7;n<Ce;n++)for(Ft[n]=s<<7,e=0;e<1<<kt[n]-7;e++)nt[256+s++]=n;for(i=0;i<=Se;i++)r[i]=0;for(e=0;e<=143;)le[e*2+1]=8,e++,r[8]++;for(;e<=255;)le[e*2+1]=9,e++,r[9]++;for(;e<=279;)le[e*2+1]=7,e++,r[7]++;for(;e<=287;)le[e*2+1]=8,e++,r[8]++;for(rs(le,it+1,r),e=0;e<Ce;e++)We[e*2+1]=5,We[e*2]=ss(e,5);es=new ii(le,xi,ut+1,it,Se),ts=new ii(We,kt,0,Ce,Se),is=new ii(new Array(0),Ks,0,zi,Ws)},as=e=>{let i;for(i=0;i<it;i++)e.dyn_ltree[i*2]=0;for(i=0;i<Ce;i++)e.dyn_dtree[i*2]=0;for(i=0;i<zi;i++)e.bl_tree[i*2]=0;e.dyn_ltree[Ui*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0},os=e=>{e.bi_valid>8?rt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},ir=(e,i,t,n)=>{os(e),n&&(rt(e,t),rt(e,~t)),e.pending_buf.set(e.window.subarray(i,i+t),e.pending),e.pending+=t},qi=(e,i,t,n)=>{const s=i*2,r=t*2;return e[s]<e[r]||e[s]===e[r]&&n[i]<=n[t]},si=(e,i,t)=>{const n=e.heap[t];let s=t<<1;for(;s<=e.heap_len&&(s<e.heap_len&&qi(i,e.heap[s+1],e.heap[s],e.depth)&&s++,!qi(i,n,e.heap[s],e.depth));)e.heap[t]=e.heap[s],t=s,s<<=1;e.heap[t]=n},Qi=(e,i,t)=>{let n,s,r=0,a,o;if(e.last_lit!==0)do n=e.pending_buf[e.d_buf+r*2]<<8|e.pending_buf[e.d_buf+r*2+1],s=e.pending_buf[e.l_buf+r],r++,n===0?ne(e,s,i):(a=st[s],ne(e,a+ut+1,i),o=xi[a],o!==0&&(s-=Zi[a],K(e,s,o)),n--,a=ns(n),ne(e,a,t),o=kt[a],o!==0&&(n-=Ft[a],K(e,n,o)));while(r<e.last_lit);ne(e,Ui,i)},Ei=(e,i)=>{const t=i.dyn_tree,n=i.stat_desc.static_tree,s=i.stat_desc.has_stree,r=i.stat_desc.elems;let a,o,c=-1,l;for(e.heap_len=0,e.heap_max=Jn,a=0;a<r;a++)t[a*2]!==0?(e.heap[++e.heap_len]=c=a,e.depth[a]=0):t[a*2+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,t[l*2]=1,e.depth[l]=0,e.opt_len--,s&&(e.static_len-=n[l*2+1]);for(i.max_code=c,a=e.heap_len>>1;a>=1;a--)si(e,t,a);l=r;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],si(e,t,1),o=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=o,t[l*2]=t[a*2]+t[o*2],e.depth[l]=(e.depth[a]>=e.depth[o]?e.depth[a]:e.depth[o])+1,t[a*2+1]=t[o*2+1]=l,e.heap[1]=l++,si(e,t,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],er(e,i),rs(t,c,e.bl_count)},en=(e,i,t)=>{let n,s=-1,r,a=i[0*2+1],o=0,c=7,l=4;for(a===0&&(c=138,l=3),i[(t+1)*2+1]=65535,n=0;n<=t;n++)r=a,a=i[(n+1)*2+1],!(++o<c&&r===a)&&(o<l?e.bl_tree[r*2]+=o:r!==0?(r!==s&&e.bl_tree[r*2]++,e.bl_tree[Wn*2]++):o<=10?e.bl_tree[Kn*2]++:e.bl_tree[qn*2]++,o=0,s=r,a===0?(c=138,l=3):r===a?(c=6,l=3):(c=7,l=4))},tn=(e,i,t)=>{let n,s=-1,r,a=i[0*2+1],o=0,c=7,l=4;for(a===0&&(c=138,l=3),n=0;n<=t;n++)if(r=a,a=i[(n+1)*2+1],!(++o<c&&r===a)){if(o<l)do ne(e,r,e.bl_tree);while(--o!==0);else r!==0?(r!==s&&(ne(e,r,e.bl_tree),o--),ne(e,Wn,e.bl_tree),K(e,o-3,2)):o<=10?(ne(e,Kn,e.bl_tree),K(e,o-3,3)):(ne(e,qn,e.bl_tree),K(e,o-11,7));o=0,s=r,a===0?(c=138,l=3):r===a?(c=6,l=3):(c=7,l=4)}},nr=e=>{let i;for(en(e,e.dyn_ltree,e.l_desc.max_code),en(e,e.dyn_dtree,e.d_desc.max_code),Ei(e,e.bl_desc),i=zi-1;i>=3&&e.bl_tree[Qn[i]*2+1]===0;i--);return e.opt_len+=3*(i+1)+5+5+4,i},sr=(e,i,t,n)=>{let s;for(K(e,i-257,5),K(e,t-1,5),K(e,n-4,4),s=0;s<n;s++)K(e,e.bl_tree[Qn[s]*2+1],3);tn(e,e.dyn_ltree,i-1),tn(e,e.dyn_dtree,t-1)},rr=e=>{let i=4093624447,t;for(t=0;t<=31;t++,i>>>=1)if(i&1&&e.dyn_ltree[t*2]!==0)return Wi;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return Ki;for(t=32;t<ut;t++)if(e.dyn_ltree[t*2]!==0)return Ki;return Wi};let nn=!1;const ar=e=>{nn||(tr(),nn=!0),e.l_desc=new ni(e.dyn_ltree,es),e.d_desc=new ni(e.dyn_dtree,ts),e.bl_desc=new ni(e.bl_tree,is),e.bi_buf=0,e.bi_valid=0,as(e)},ls=(e,i,t,n)=>{K(e,(Xs<<1)+(n?1:0),3),ir(e,i,t,!0)},or=e=>{K(e,Vn<<1,3),ne(e,Ui,le),Qs(e)},lr=(e,i,t,n)=>{let s,r,a=0;e.level>0?(e.strm.data_type===$s&&(e.strm.data_type=rr(e)),Ei(e,e.l_desc),Ei(e,e.d_desc),a=nr(e),s=e.opt_len+3+7>>>3,r=e.static_len+3+7>>>3,r<=s&&(s=r)):s=r=t+5,t+4<=s&&i!==-1?ls(e,i,t,n):e.strategy===Gs||r===s?(K(e,(Vn<<1)+(n?1:0),3),Qi(e,le,We)):(K(e,(js<<1)+(n?1:0),3),sr(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),Qi(e,e.dyn_ltree,e.dyn_dtree)),as(e),n&&os(e)},hr=(e,i,t)=>(e.pending_buf[e.d_buf+e.last_lit*2]=i>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=i&255,e.pending_buf[e.l_buf+e.last_lit]=t&255,e.last_lit++,i===0?e.dyn_ltree[t*2]++:(e.matches++,i--,e.dyn_ltree[(st[t]+ut+1)*2]++,e.dyn_dtree[ns(i)*2]++),e.last_lit===e.lit_bufsize-1);var cr=ar,fr=ls,dr=lr,ur=hr,gr=or,_r={_tr_init:cr,_tr_stored_block:fr,_tr_flush_block:dr,_tr_tally:ur,_tr_align:gr};const pr=(e,i,t,n)=>{let s=e&65535|0,r=e>>>16&65535|0,a=0;for(;t!==0;){a=t>2e3?2e3:t,t-=a;do s=s+i[n++]|0,r=r+s|0;while(--a);s%=65521,r%=65521}return s|r<<16|0};var at=pr;const vr=()=>{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},br=new Uint32Array(vr()),mr=(e,i,t,n)=>{const s=br,r=n+t;e^=-1;for(let a=n;a<r;a++)e=e>>>8^s[(e^i[a])&255];return e^-1};var j=mr,ye={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"},Ne={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:wr,_tr_stored_block:xr,_tr_flush_block:Er,_tr_tally:me,_tr_align:Sr}=_r,{Z_NO_FLUSH:Te,Z_PARTIAL_FLUSH:kr,Z_FULL_FLUSH:yr,Z_FINISH:we,Z_BLOCK:sn,Z_OK:se,Z_STREAM_END:rn,Z_STREAM_ERROR:Q,Z_DATA_ERROR:Ar,Z_BUF_ERROR:ri,Z_DEFAULT_COMPRESSION:Ir,Z_FILTERED:Rr,Z_HUFFMAN_ONLY:bt,Z_RLE:Nr,Z_FIXED:Tr,Z_DEFAULT_STRATEGY:Fr,Z_UNKNOWN:Br,Z_DEFLATED:Mt}=Ne,Pr=9,Dr=15,Cr=8,Or=29,Mr=256,Si=Mr+1+Or,Lr=30,zr=19,Ur=2*Si+1,Zr=15,T=3,ve=258,te=ve+T+1,Hr=32,Lt=42,ki=69,yt=73,At=91,It=103,ke=113,Ve=666,X=1,gt=2,Ae=3,He=4,Yr=3,be=(e,i)=>(e.msg=ye[i],i),an=e=>(e<<1)-(e>4?9:0),_e=e=>{let i=e.length;for(;--i>=0;)e[i]=0};let Gr=(e,i,t)=>(i<<e.hash_shift^t)&e.hash_mask,xe=Gr;const de=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))},J=(e,i)=>{Er(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,i),e.block_start=e.strstart,de(e.strm)},F=(e,i)=>{e.pending_buf[e.pending++]=i},Xe=(e,i)=>{e.pending_buf[e.pending++]=i>>>8&255,e.pending_buf[e.pending++]=i&255},$r=(e,i,t,n)=>{let s=e.avail_in;return s>n&&(s=n),s===0?0:(e.avail_in-=s,i.set(e.input.subarray(e.next_in,e.next_in+s),t),e.state.wrap===1?e.adler=at(e.adler,i,s,t):e.state.wrap===2&&(e.adler=j(e.adler,i,s,t)),e.next_in+=s,e.total_in+=s,s)},hs=(e,i)=>{let t=e.max_chain_length,n=e.strstart,s,r,a=e.prev_length,o=e.nice_match;const c=e.strstart>e.w_size-te?e.strstart-(e.w_size-te):0,l=e.window,h=e.w_mask,d=e.prev,u=e.strstart+ve;let f=l[n+a-1],g=l[n+a];e.prev_length>=e.good_match&&(t>>=2),o>e.lookahead&&(o=e.lookahead);do if(s=i,!(l[s+a]!==g||l[s+a-1]!==f||l[s]!==l[n]||l[++s]!==l[n+1])){n+=2,s++;do;while(l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&l[++n]===l[++s]&&n<u);if(r=ve-(u-n),n=u-ve,r>a){if(e.match_start=i,a=r,r>=o)break;f=l[n+a-1],g=l[n+a]}}while((i=d[i&h])>c&&--t!==0);return a<=e.lookahead?a:e.lookahead},Ie=e=>{const i=e.w_size;let t,n,s,r,a;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=i+(i-te)){e.window.set(e.window.subarray(i,i+i),0),e.match_start-=i,e.strstart-=i,e.block_start-=i,n=e.hash_size,t=n;do s=e.head[--t],e.head[t]=s>=i?s-i:0;while(--n);n=i,t=n;do s=e.prev[--t],e.prev[t]=s>=i?s-i:0;while(--n);r+=i}if(e.strm.avail_in===0)break;if(n=$r(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=n,e.lookahead+e.insert>=T)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=xe(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=xe(e,e.ins_h,e.window[a+T-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<T)););}while(e.lookahead<te&&e.strm.avail_in!==0)},Xr=(e,i)=>{let t=65535;for(t>e.pending_buf_size-5&&(t=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Ie(e),e.lookahead===0&&i===Te)return X;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;const n=e.block_start+t;if((e.strstart===0||e.strstart>=n)&&(e.lookahead=e.strstart-n,e.strstart=n,J(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-te&&(J(e,!1),e.strm.avail_out===0))return X}return e.insert=0,i===we?(J(e,!0),e.strm.avail_out===0?Ae:He):(e.strstart>e.block_start&&(J(e,!1),e.strm.avail_out===0),X)},ai=(e,i)=>{let t,n;for(;;){if(e.lookahead<te){if(Ie(e),e.lookahead<te&&i===Te)return X;if(e.lookahead===0)break}if(t=0,e.lookahead>=T&&(e.ins_h=xe(e,e.ins_h,e.window[e.strstart+T-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-te&&(e.match_length=hs(e,t)),e.match_length>=T)if(n=me(e,e.strstart-e.match_start,e.match_length-T),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=T){e.match_length--;do e.strstart++,e.ins_h=xe(e,e.ins_h,e.window[e.strstart+T-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=xe(e,e.ins_h,e.window[e.strstart+1]);else n=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(n&&(J(e,!1),e.strm.avail_out===0))return X}return e.insert=e.strstart<T-1?e.strstart:T-1,i===we?(J(e,!0),e.strm.avail_out===0?Ae:He):e.last_lit&&(J(e,!1),e.strm.avail_out===0)?X:gt},Fe=(e,i)=>{let t,n,s;for(;;){if(e.lookahead<te){if(Ie(e),e.lookahead<te&&i===Te)return X;if(e.lookahead===0)break}if(t=0,e.lookahead>=T&&(e.ins_h=xe(e,e.ins_h,e.window[e.strstart+T-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=T-1,t!==0&&e.prev_length<e.max_lazy_match&&e.strstart-t<=e.w_size-te&&(e.match_length=hs(e,t),e.match_length<=5&&(e.strategy===Rr||e.match_length===T&&e.strstart-e.match_start>4096)&&(e.match_length=T-1)),e.prev_length>=T&&e.match_length<=e.prev_length){s=e.strstart+e.lookahead-T,n=me(e,e.strstart-1-e.prev_match,e.prev_length-T),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=s&&(e.ins_h=xe(e,e.ins_h,e.window[e.strstart+T-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=T-1,e.strstart++,n&&(J(e,!1),e.strm.avail_out===0))return X}else if(e.match_available){if(n=me(e,0,e.window[e.strstart-1]),n&&J(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return X}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(n=me(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<T-1?e.strstart:T-1,i===we?(J(e,!0),e.strm.avail_out===0?Ae:He):e.last_lit&&(J(e,!1),e.strm.avail_out===0)?X:gt},jr=(e,i)=>{let t,n,s,r;const a=e.window;for(;;){if(e.lookahead<=ve){if(Ie(e),e.lookahead<=ve&&i===Te)return X;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=T&&e.strstart>0&&(s=e.strstart-1,n=a[s],n===a[++s]&&n===a[++s]&&n===a[++s])){r=e.strstart+ve;do;while(n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&s<r);e.match_length=ve-(r-s),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=T?(t=me(e,1,e.match_length-T),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(t=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),t&&(J(e,!1),e.strm.avail_out===0))return X}return e.insert=0,i===we?(J(e,!0),e.strm.avail_out===0?Ae:He):e.last_lit&&(J(e,!1),e.strm.avail_out===0)?X:gt},Vr=(e,i)=>{let t;for(;;){if(e.lookahead===0&&(Ie(e),e.lookahead===0)){if(i===Te)return X;break}if(e.match_length=0,t=me(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,t&&(J(e,!1),e.strm.avail_out===0))return X}return e.insert=0,i===we?(J(e,!0),e.strm.avail_out===0?Ae:He):e.last_lit&&(J(e,!1),e.strm.avail_out===0)?X:gt};function ie(e,i,t,n,s){this.good_length=e,this.max_lazy=i,this.nice_length=t,this.max_chain=n,this.func=s}const Je=[new ie(0,0,0,0,Xr),new ie(4,4,8,4,ai),new ie(4,5,16,8,ai),new ie(4,6,32,32,ai),new ie(4,4,16,16,Fe),new ie(8,16,32,32,Fe),new ie(8,16,128,128,Fe),new ie(8,32,128,256,Fe),new ie(32,128,258,1024,Fe),new ie(32,258,258,4096,Fe)],Jr=e=>{e.window_size=2*e.w_size,_e(e.head),e.max_lazy_match=Je[e.level].max_lazy,e.good_match=Je[e.level].good_length,e.nice_match=Je[e.level].nice_length,e.max_chain_length=Je[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=T-1,e.match_available=0,e.ins_h=0};function Wr(){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=Mt,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(Ur*2),this.dyn_dtree=new Uint16Array((2*Lr+1)*2),this.bl_tree=new Uint16Array((2*zr+1)*2),_e(this.dyn_ltree),_e(this.dyn_dtree),_e(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(Zr+1),this.heap=new Uint16Array(2*Si+1),_e(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Si+1),_e(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const cs=e=>{if(!e||!e.state)return be(e,Q);e.total_in=e.total_out=0,e.data_type=Br;const i=e.state;return i.pending=0,i.pending_out=0,i.wrap<0&&(i.wrap=-i.wrap),i.status=i.wrap?Lt:ke,e.adler=i.wrap===2?0:1,i.last_flush=Te,wr(i),se},fs=e=>{const i=cs(e);return i===se&&Jr(e.state),i},Kr=(e,i)=>!e||!e.state||e.state.wrap!==2?Q:(e.state.gzhead=i,se),ds=(e,i,t,n,s,r)=>{if(!e)return Q;let a=1;if(i===Ir&&(i=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),s<1||s>Pr||t!==Mt||n<8||n>15||i<0||i>9||r<0||r>Tr)return be(e,Q);n===8&&(n=9);const o=new Wr;return e.state=o,o.strm=e,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=s+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+T-1)/T),o.window=new Uint8Array(o.w_size*2),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<s+6,o.pending_buf_size=o.lit_bufsize*4,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=(1+2)*o.lit_bufsize,o.level=i,o.strategy=r,o.method=t,fs(e)},qr=(e,i)=>ds(e,i,Mt,Dr,Cr,Fr),Qr=(e,i)=>{let t,n;if(!e||!e.state||i>sn||i<0)return e?be(e,Q):Q;const s=e.state;if(!e.output||!e.input&&e.avail_in!==0||s.status===Ve&&i!==we)return be(e,e.avail_out===0?ri:Q);s.strm=e;const r=s.last_flush;if(s.last_flush=i,s.status===Lt)if(s.wrap===2)e.adler=0,F(s,31),F(s,139),F(s,8),s.gzhead?(F(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),F(s,s.gzhead.time&255),F(s,s.gzhead.time>>8&255),F(s,s.gzhead.time>>16&255),F(s,s.gzhead.time>>24&255),F(s,s.level===9?2:s.strategy>=bt||s.level<2?4:0),F(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length&&(F(s,s.gzhead.extra.length&255),F(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(e.adler=j(e.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=ki):(F(s,0),F(s,0),F(s,0),F(s,0),F(s,0),F(s,s.level===9?2:s.strategy>=bt||s.level<2?4:0),F(s,Yr),s.status=ke);else{let a=Mt+(s.w_bits-8<<4)<<8,o=-1;s.strategy>=bt||s.level<2?o=0:s.level<6?o=1:s.level===6?o=2:o=3,a|=o<<6,s.strstart!==0&&(a|=Hr),a+=31-a%31,s.status=ke,Xe(s,a),s.strstart!==0&&(Xe(s,e.adler>>>16),Xe(s,e.adler&65535)),e.adler=1}if(s.status===ki)if(s.gzhead.extra){for(t=s.pending;s.gzindex<(s.gzhead.extra.length&65535)&&!(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>t&&(e.adler=j(e.adler,s.pending_buf,s.pending-t,t)),de(e),t=s.pending,s.pending===s.pending_buf_size));)F(s,s.gzhead.extra[s.gzindex]&255),s.gzindex++;s.gzhead.hcrc&&s.pending>t&&(e.adler=j(e.adler,s.pending_buf,s.pending-t,t)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=yt)}else s.status=yt;if(s.status===yt)if(s.gzhead.name){t=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>t&&(e.adler=j(e.adler,s.pending_buf,s.pending-t,t)),de(e),t=s.pending,s.pending===s.pending_buf_size)){n=1;break}s.gzindex<s.gzhead.name.length?n=s.gzhead.name.charCodeAt(s.gzindex++)&255:n=0,F(s,n)}while(n!==0);s.gzhead.hcrc&&s.pending>t&&(e.adler=j(e.adler,s.pending_buf,s.pending-t,t)),n===0&&(s.gzindex=0,s.status=At)}else s.status=At;if(s.status===At)if(s.gzhead.comment){t=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>t&&(e.adler=j(e.adler,s.pending_buf,s.pending-t,t)),de(e),t=s.pending,s.pending===s.pending_buf_size)){n=1;break}s.gzindex<s.gzhead.comment.length?n=s.gzhead.comment.charCodeAt(s.gzindex++)&255:n=0,F(s,n)}while(n!==0);s.gzhead.hcrc&&s.pending>t&&(e.adler=j(e.adler,s.pending_buf,s.pending-t,t)),n===0&&(s.status=It)}else s.status=It;if(s.status===It&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&de(e),s.pending+2<=s.pending_buf_size&&(F(s,e.adler&255),F(s,e.adler>>8&255),e.adler=0,s.status=ke)):s.status=ke),s.pending!==0){if(de(e),e.avail_out===0)return s.last_flush=-1,se}else if(e.avail_in===0&&an(i)<=an(r)&&i!==we)return be(e,ri);if(s.status===Ve&&e.avail_in!==0)return be(e,ri);if(e.avail_in!==0||s.lookahead!==0||i!==Te&&s.status!==Ve){let a=s.strategy===bt?Vr(s,i):s.strategy===Nr?jr(s,i):Je[s.level].func(s,i);if((a===Ae||a===He)&&(s.status=Ve),a===X||a===Ae)return e.avail_out===0&&(s.last_flush=-1),se;if(a===gt&&(i===kr?Sr(s):i!==sn&&(xr(s,0,0,!1),i===yr&&(_e(s.head),s.lookahead===0&&(s.strstart=0,s.block_start=0,s.insert=0))),de(e),e.avail_out===0))return s.last_flush=-1,se}return i!==we?se:s.wrap<=0?rn:(s.wrap===2?(F(s,e.adler&255),F(s,e.adler>>8&255),F(s,e.adler>>16&255),F(s,e.adler>>24&255),F(s,e.total_in&255),F(s,e.total_in>>8&255),F(s,e.total_in>>16&255),F(s,e.total_in>>24&255)):(Xe(s,e.adler>>>16),Xe(s,e.adler&65535)),de(e),s.wrap>0&&(s.wrap=-s.wrap),s.pending!==0?se:rn)},ea=e=>{if(!e||!e.state)return Q;const i=e.state.status;return i!==Lt&&i!==ki&&i!==yt&&i!==At&&i!==It&&i!==ke&&i!==Ve?be(e,Q):(e.state=null,i===ke?be(e,Ar):se)},ta=(e,i)=>{let t=i.length;if(!e||!e.state)return Q;const n=e.state,s=n.wrap;if(s===2||s===1&&n.status!==Lt||n.lookahead)return Q;if(s===1&&(e.adler=at(e.adler,i,t,0)),n.wrap=0,t>=n.w_size){s===0&&(_e(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,a=e.next_in,o=e.input;for(e.avail_in=t,e.next_in=0,e.input=i,Ie(n);n.lookahead>=T;){let c=n.strstart,l=n.lookahead-(T-1);do n.ins_h=xe(n,n.ins_h,n.window[c+T-1]),n.prev[c&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=c,c++;while(--l);n.strstart=c,n.lookahead=T-1,Ie(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=T-1,n.match_available=0,e.next_in=a,e.input=o,e.avail_in=r,n.wrap=s,se};var ia=qr,na=ds,sa=fs,ra=cs,aa=Kr,oa=Qr,la=ea,ha=ta,ca="pako deflate (from Nodeca project)",Ke={deflateInit:ia,deflateInit2:na,deflateReset:sa,deflateResetKeep:ra,deflateSetHeader:aa,deflate:oa,deflateEnd:la,deflateSetDictionary:ha,deflateInfo:ca};const fa=(e,i)=>Object.prototype.hasOwnProperty.call(e,i);var da=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)fa(t,n)&&(e[n]=t[n])}}return e},ua=e=>{let i=0;for(let n=0,s=e.length;n<s;n++)i+=e[n].length;const t=new Uint8Array(i);for(let n=0,s=0,r=e.length;n<r;n++){let a=e[n];t.set(a,s),s+=a.length}return t},zt={assign:da,flattenChunks:ua};let us=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{us=!1}const ot=new Uint8Array(256);for(let e=0;e<256;e++)ot[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ot[254]=ot[254]=1;var ga=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let i,t,n,s,r,a=e.length,o=0;for(s=0;s<a;s++)t=e.charCodeAt(s),(t&64512)===55296&&s+1<a&&(n=e.charCodeAt(s+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),s++)),o+=t<128?1:t<2048?2:t<65536?3:4;for(i=new Uint8Array(o),r=0,s=0;r<o;s++)t=e.charCodeAt(s),(t&64512)===55296&&s+1<a&&(n=e.charCodeAt(s+1),(n&64512)===56320&&(t=65536+(t-55296<<10)+(n-56320),s++)),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 _a=(e,i)=>{if(i<65534&&e.subarray&&us)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 pa=(e,i)=>{const t=i||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,i));let n,s;const r=new Array(t*2);for(s=0,n=0;n<t;){let a=e[n++];if(a<128){r[s++]=a;continue}let o=ot[a];if(o>4){r[s++]=65533,n+=o-1;continue}for(a&=o===2?31:o===3?15:7;o>1&&n<t;)a=a<<6|e[n++]&63,o--;if(o>1){r[s++]=65533;continue}a<65536?r[s++]=a:(a-=65536,r[s++]=55296|a>>10&1023,r[s++]=56320|a&1023)}return _a(r,s)},va=(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+ot[e[t]]>i?t:i},lt={string2buf:ga,buf2string:pa,utf8border:va};function ba(){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 gs=ba;const _s=Object.prototype.toString,{Z_NO_FLUSH:ma,Z_SYNC_FLUSH:wa,Z_FULL_FLUSH:xa,Z_FINISH:Ea,Z_OK:Bt,Z_STREAM_END:Sa,Z_DEFAULT_COMPRESSION:ka,Z_DEFAULT_STRATEGY:ya,Z_DEFLATED:Aa}=Ne;function _t(e){this.options=zt.assign({level:ka,method:Aa,chunkSize:16384,windowBits:15,memLevel:8,strategy:ya},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 gs,this.strm.avail_out=0;let t=Ke.deflateInit2(this.strm,i.level,i.method,i.windowBits,i.memLevel,i.strategy);if(t!==Bt)throw new Error(ye[t]);if(i.header&&Ke.deflateSetHeader(this.strm,i.header),i.dictionary){let n;if(typeof i.dictionary=="string"?n=lt.string2buf(i.dictionary):_s.call(i.dictionary)==="[object ArrayBuffer]"?n=new Uint8Array(i.dictionary):n=i.dictionary,t=Ke.deflateSetDictionary(this.strm,n),t!==Bt)throw new Error(ye[t]);this._dict_set=!0}}_t.prototype.push=function(e,i){const t=this.strm,n=this.options.chunkSize;let s,r;if(this.ended)return!1;for(i===~~i?r=i:r=i===!0?Ea:ma,typeof e=="string"?t.input=lt.string2buf(e):_s.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===wa||r===xa)&&t.avail_out<=6){this.onData(t.output.subarray(0,t.next_out)),t.avail_out=0;continue}if(s=Ke.deflate(t,r),s===Sa)return t.next_out>0&&this.onData(t.output.subarray(0,t.next_out)),s=Ke.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===Bt;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};_t.prototype.onData=function(e){this.chunks.push(e)};_t.prototype.onEnd=function(e){e===Bt&&(this.result=zt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Hi(e,i){const t=new _t(i);if(t.push(e,!0),t.err)throw t.msg||ye[t.err];return t.result}function Ia(e,i){return i=i||{},i.raw=!0,Hi(e,i)}function Ra(e,i){return i=i||{},i.gzip=!0,Hi(e,i)}var Na=_t,Ta=Hi,Fa=Ia,Ba=Ra,Pa=Ne,Da={Deflate:Na,deflate:Ta,deflateRaw:Fa,gzip:Ba,constants:Pa};const mt=30,Ca=12;var Oa=function(i,t){let n,s,r,a,o,c,l,h,d,u,f,g,v,p,m,S,E,_,b,I,x,R,N,y;const A=i.state;n=i.next_in,N=i.input,s=n+(i.avail_in-5),r=i.next_out,y=i.output,a=r-(t-i.avail_out),o=r+(i.avail_out-257),c=A.dmax,l=A.wsize,h=A.whave,d=A.wnext,u=A.window,f=A.hold,g=A.bits,v=A.lencode,p=A.distcode,m=(1<<A.lenbits)-1,S=(1<<A.distbits)-1;e:do{g<15&&(f+=N[n++]<<g,g+=8,f+=N[n++]<<g,g+=8),E=v[f&m];t:for(;;){if(_=E>>>24,f>>>=_,g-=_,_=E>>>16&255,_===0)y[r++]=E&65535;else if(_&16){b=E&65535,_&=15,_&&(g<_&&(f+=N[n++]<<g,g+=8),b+=f&(1<<_)-1,f>>>=_,g-=_),g<15&&(f+=N[n++]<<g,g+=8,f+=N[n++]<<g,g+=8),E=p[f&S];i:for(;;){if(_=E>>>24,f>>>=_,g-=_,_=E>>>16&255,_&16){if(I=E&65535,_&=15,g<_&&(f+=N[n++]<<g,g+=8,g<_&&(f+=N[n++]<<g,g+=8)),I+=f&(1<<_)-1,I>c){i.msg="invalid distance too far back",A.mode=mt;break e}if(f>>>=_,g-=_,_=r-a,I>_){if(_=I-_,_>h&&A.sane){i.msg="invalid distance too far back",A.mode=mt;break e}if(x=0,R=u,d===0){if(x+=l-_,_<b){b-=_;do y[r++]=u[x++];while(--_);x=r-I,R=y}}else if(d<_){if(x+=l+d-_,_-=d,_<b){b-=_;do y[r++]=u[x++];while(--_);if(x=0,d<b){_=d,b-=_;do y[r++]=u[x++];while(--_);x=r-I,R=y}}}else if(x+=d-_,_<b){b-=_;do y[r++]=u[x++];while(--_);x=r-I,R=y}for(;b>2;)y[r++]=R[x++],y[r++]=R[x++],y[r++]=R[x++],b-=3;b&&(y[r++]=R[x++],b>1&&(y[r++]=R[x++]))}else{x=r-I;do y[r++]=y[x++],y[r++]=y[x++],y[r++]=y[x++],b-=3;while(b>2);b&&(y[r++]=y[x++],b>1&&(y[r++]=y[x++]))}}else if((_&64)===0){E=p[(E&65535)+(f&(1<<_)-1)];continue i}else{i.msg="invalid distance code",A.mode=mt;break e}break}}else if((_&64)===0){E=v[(E&65535)+(f&(1<<_)-1)];continue t}else if(_&32){A.mode=Ca;break e}else{i.msg="invalid literal/length code",A.mode=mt;break e}break}}while(n<s&&r<o);b=g>>3,n-=b,g-=b<<3,f&=(1<<g)-1,i.next_in=n,i.next_out=r,i.avail_in=n<s?5+(s-n):5-(n-s),i.avail_out=r<o?257+(o-r):257-(r-o),A.hold=f,A.bits=g};const Be=15,on=852,ln=592,hn=0,oi=1,cn=2,Ma=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]),La=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]),za=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]),Ua=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]),Za=(e,i,t,n,s,r,a,o)=>{const c=o.bits;let l=0,h=0,d=0,u=0,f=0,g=0,v=0,p=0,m=0,S=0,E,_,b,I,x,R=null,N=0,y;const A=new Uint16Array(Be+1),M=new Uint16Array(Be+1);let D=null,B=0,q,Y,L;for(l=0;l<=Be;l++)A[l]=0;for(h=0;h<n;h++)A[i[t+h]]++;for(f=c,u=Be;u>=1&&A[u]===0;u--);if(f>u&&(f=u),u===0)return s[r++]=1<<24|64<<16|0,s[r++]=1<<24|64<<16|0,o.bits=1,0;for(d=1;d<u&&A[d]===0;d++);for(f<d&&(f=d),p=1,l=1;l<=Be;l++)if(p<<=1,p-=A[l],p<0)return-1;if(p>0&&(e===hn||u!==1))return-1;for(M[1]=0,l=1;l<Be;l++)M[l+1]=M[l]+A[l];for(h=0;h<n;h++)i[t+h]!==0&&(a[M[i[t+h]]++]=h);if(e===hn?(R=D=a,y=19):e===oi?(R=Ma,N-=257,D=La,B-=257,y=256):(R=za,D=Ua,y=-1),S=0,h=0,l=d,x=r,g=f,v=0,b=-1,m=1<<f,I=m-1,e===oi&&m>on||e===cn&&m>ln)return 1;for(;;){q=l-v,a[h]<y?(Y=0,L=a[h]):a[h]>y?(Y=D[B+a[h]],L=R[N+a[h]]):(Y=32+64,L=0),E=1<<l-v,_=1<<g,d=_;do _-=E,s[x+(S>>v)+_]=q<<24|Y<<16|L|0;while(_!==0);for(E=1<<l-1;S&E;)E>>=1;if(E!==0?(S&=E-1,S+=E):S=0,h++,--A[l]===0){if(l===u)break;l=i[t+a[h]]}if(l>f&&(S&I)!==b){for(v===0&&(v=f),x+=d,g=l-v,p=1<<g;g+v<u&&(p-=A[g+v],!(p<=0));)g++,p<<=1;if(m+=1<<g,e===oi&&m>on||e===cn&&m>ln)return 1;b=S&I,s[b]=f<<24|g<<16|x-r|0}}return S!==0&&(s[x+S]=l-v<<24|64<<16|0),o.bits=f,0};var qe=Za;const Ha=0,ps=1,vs=2,{Z_FINISH:fn,Z_BLOCK:Ya,Z_TREES:wt,Z_OK:Re,Z_STREAM_END:Ga,Z_NEED_DICT:$a,Z_STREAM_ERROR:ee,Z_DATA_ERROR:bs,Z_MEM_ERROR:ms,Z_BUF_ERROR:Xa,Z_DEFLATED:dn}=Ne,ws=1,un=2,gn=3,_n=4,pn=5,vn=6,bn=7,mn=8,wn=9,xn=10,Pt=11,ae=12,li=13,En=14,hi=15,Sn=16,kn=17,yn=18,An=19,xt=20,Et=21,In=22,Rn=23,Nn=24,Tn=25,Fn=26,ci=27,Bn=28,Pn=29,C=30,xs=31,ja=32,Va=852,Ja=592,Wa=15,Ka=Wa,Dn=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function qa(){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 Es=e=>{if(!e||!e.state)return ee;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=ws,i.last=0,i.havedict=0,i.dmax=32768,i.head=null,i.hold=0,i.bits=0,i.lencode=i.lendyn=new Int32Array(Va),i.distcode=i.distdyn=new Int32Array(Ja),i.sane=1,i.back=-1,Re},Ss=e=>{if(!e||!e.state)return ee;const i=e.state;return i.wsize=0,i.whave=0,i.wnext=0,Es(e)},ks=(e,i)=>{let t;if(!e||!e.state)return ee;const n=e.state;return i<0?(t=0,i=-i):(t=(i>>4)+1,i<48&&(i&=15)),i&&(i<8||i>15)?ee:(n.window!==null&&n.wbits!==i&&(n.window=null),n.wrap=t,n.wbits=i,Ss(e))},ys=(e,i)=>{if(!e)return ee;const t=new qa;e.state=t,t.window=null;const n=ks(e,i);return n!==Re&&(e.state=null),n},Qa=e=>ys(e,Ka);let Cn=!0,fi,di;const eo=e=>{if(Cn){fi=new Int32Array(512),di=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(qe(ps,e.lens,0,288,fi,0,e.work,{bits:9}),i=0;i<32;)e.lens[i++]=5;qe(vs,e.lens,0,32,di,0,e.work,{bits:5}),Cn=!1}e.lencode=fi,e.lenbits=9,e.distcode=di,e.distbits=5},As=(e,i,t,n)=>{let s;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):(s=r.wsize-r.wnext,s>n&&(s=n),r.window.set(i.subarray(t-n,t-n+s),r.wnext),n-=s,n?(r.window.set(i.subarray(t-n,t),0),r.wnext=n,r.whave=r.wsize):(r.wnext+=s,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=s))),0},to=(e,i)=>{let t,n,s,r,a,o,c,l,h,d,u,f,g,v,p=0,m,S,E,_,b,I,x,R;const N=new Uint8Array(4);let y,A;const M=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return ee;t=e.state,t.mode===ae&&(t.mode=li),a=e.next_out,s=e.output,c=e.avail_out,r=e.next_in,n=e.input,o=e.avail_in,l=t.hold,h=t.bits,d=o,u=c,R=Re;e:for(;;)switch(t.mode){case ws:if(t.wrap===0){t.mode=li;break}for(;h<16;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if(t.wrap&2&&l===35615){t.check=0,N[0]=l&255,N[1]=l>>>8&255,t.check=j(t.check,N,2,0),l=0,h=0,t.mode=un;break}if(t.flags=0,t.head&&(t.head.done=!1),!(t.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",t.mode=C;break}if((l&15)!==dn){e.msg="unknown compression method",t.mode=C;break}if(l>>>=4,h-=4,x=(l&15)+8,t.wbits===0)t.wbits=x;else if(x>t.wbits){e.msg="invalid window size",t.mode=C;break}t.dmax=1<<t.wbits,e.adler=t.check=1,t.mode=l&512?xn:ae,l=0,h=0;break;case un:for(;h<16;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if(t.flags=l,(t.flags&255)!==dn){e.msg="unknown compression method",t.mode=C;break}if(t.flags&57344){e.msg="unknown header flags set",t.mode=C;break}t.head&&(t.head.text=l>>8&1),t.flags&512&&(N[0]=l&255,N[1]=l>>>8&255,t.check=j(t.check,N,2,0)),l=0,h=0,t.mode=gn;case gn:for(;h<32;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}t.head&&(t.head.time=l),t.flags&512&&(N[0]=l&255,N[1]=l>>>8&255,N[2]=l>>>16&255,N[3]=l>>>24&255,t.check=j(t.check,N,4,0)),l=0,h=0,t.mode=_n;case _n:for(;h<16;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}t.head&&(t.head.xflags=l&255,t.head.os=l>>8),t.flags&512&&(N[0]=l&255,N[1]=l>>>8&255,t.check=j(t.check,N,2,0)),l=0,h=0,t.mode=pn;case pn:if(t.flags&1024){for(;h<16;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}t.length=l,t.head&&(t.head.extra_len=l),t.flags&512&&(N[0]=l&255,N[1]=l>>>8&255,t.check=j(t.check,N,2,0)),l=0,h=0}else t.head&&(t.head.extra=null);t.mode=vn;case vn:if(t.flags&1024&&(f=t.length,f>o&&(f=o),f&&(t.head&&(x=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+f),x)),t.flags&512&&(t.check=j(t.check,n,f,r)),o-=f,r+=f,t.length-=f),t.length))break e;t.length=0,t.mode=bn;case bn:if(t.flags&2048){if(o===0)break e;f=0;do x=n[r+f++],t.head&&x&&t.length<65536&&(t.head.name+=String.fromCharCode(x));while(x&&f<o);if(t.flags&512&&(t.check=j(t.check,n,f,r)),o-=f,r+=f,x)break e}else t.head&&(t.head.name=null);t.length=0,t.mode=mn;case mn:if(t.flags&4096){if(o===0)break e;f=0;do x=n[r+f++],t.head&&x&&t.length<65536&&(t.head.comment+=String.fromCharCode(x));while(x&&f<o);if(t.flags&512&&(t.check=j(t.check,n,f,r)),o-=f,r+=f,x)break e}else t.head&&(t.head.comment=null);t.mode=wn;case wn:if(t.flags&512){for(;h<16;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if(l!==(t.check&65535)){e.msg="header crc mismatch",t.mode=C;break}l=0,h=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),e.adler=t.check=0,t.mode=ae;break;case xn:for(;h<32;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}e.adler=t.check=Dn(l),l=0,h=0,t.mode=Pt;case Pt:if(t.havedict===0)return e.next_out=a,e.avail_out=c,e.next_in=r,e.avail_in=o,t.hold=l,t.bits=h,$a;e.adler=t.check=1,t.mode=ae;case ae:if(i===Ya||i===wt)break e;case li:if(t.last){l>>>=h&7,h-=h&7,t.mode=ci;break}for(;h<3;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}switch(t.last=l&1,l>>>=1,h-=1,l&3){case 0:t.mode=En;break;case 1:if(eo(t),t.mode=xt,i===wt){l>>>=2,h-=2;break e}break;case 2:t.mode=kn;break;case 3:e.msg="invalid block type",t.mode=C}l>>>=2,h-=2;break;case En:for(l>>>=h&7,h-=h&7;h<32;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if((l&65535)!==(l>>>16^65535)){e.msg="invalid stored block lengths",t.mode=C;break}if(t.length=l&65535,l=0,h=0,t.mode=hi,i===wt)break e;case hi:t.mode=Sn;case Sn:if(f=t.length,f){if(f>o&&(f=o),f>c&&(f=c),f===0)break e;s.set(n.subarray(r,r+f),a),o-=f,r+=f,c-=f,a+=f,t.length-=f;break}t.mode=ae;break;case kn:for(;h<14;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if(t.nlen=(l&31)+257,l>>>=5,h-=5,t.ndist=(l&31)+1,l>>>=5,h-=5,t.ncode=(l&15)+4,l>>>=4,h-=4,t.nlen>286||t.ndist>30){e.msg="too many length or distance symbols",t.mode=C;break}t.have=0,t.mode=yn;case yn:for(;t.have<t.ncode;){for(;h<3;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}t.lens[M[t.have++]]=l&7,l>>>=3,h-=3}for(;t.have<19;)t.lens[M[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,y={bits:t.lenbits},R=qe(Ha,t.lens,0,19,t.lencode,0,t.work,y),t.lenbits=y.bits,R){e.msg="invalid code lengths set",t.mode=C;break}t.have=0,t.mode=An;case An:for(;t.have<t.nlen+t.ndist;){for(;p=t.lencode[l&(1<<t.lenbits)-1],m=p>>>24,S=p>>>16&255,E=p&65535,!(m<=h);){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if(E<16)l>>>=m,h-=m,t.lens[t.have++]=E;else{if(E===16){for(A=m+2;h<A;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if(l>>>=m,h-=m,t.have===0){e.msg="invalid bit length repeat",t.mode=C;break}x=t.lens[t.have-1],f=3+(l&3),l>>>=2,h-=2}else if(E===17){for(A=m+3;h<A;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}l>>>=m,h-=m,x=0,f=3+(l&7),l>>>=3,h-=3}else{for(A=m+7;h<A;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}l>>>=m,h-=m,x=0,f=11+(l&127),l>>>=7,h-=7}if(t.have+f>t.nlen+t.ndist){e.msg="invalid bit length repeat",t.mode=C;break}for(;f--;)t.lens[t.have++]=x}}if(t.mode===C)break;if(t.lens[256]===0){e.msg="invalid code -- missing end-of-block",t.mode=C;break}if(t.lenbits=9,y={bits:t.lenbits},R=qe(ps,t.lens,0,t.nlen,t.lencode,0,t.work,y),t.lenbits=y.bits,R){e.msg="invalid literal/lengths set",t.mode=C;break}if(t.distbits=6,t.distcode=t.distdyn,y={bits:t.distbits},R=qe(vs,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,y),t.distbits=y.bits,R){e.msg="invalid distances set",t.mode=C;break}if(t.mode=xt,i===wt)break e;case xt:t.mode=Et;case Et:if(o>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=r,e.avail_in=o,t.hold=l,t.bits=h,Oa(e,u),a=e.next_out,s=e.output,c=e.avail_out,r=e.next_in,n=e.input,o=e.avail_in,l=t.hold,h=t.bits,t.mode===ae&&(t.back=-1);break}for(t.back=0;p=t.lencode[l&(1<<t.lenbits)-1],m=p>>>24,S=p>>>16&255,E=p&65535,!(m<=h);){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if(S&&(S&240)===0){for(_=m,b=S,I=E;p=t.lencode[I+((l&(1<<_+b)-1)>>_)],m=p>>>24,S=p>>>16&255,E=p&65535,!(_+m<=h);){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}l>>>=_,h-=_,t.back+=_}if(l>>>=m,h-=m,t.back+=m,t.length=E,S===0){t.mode=Fn;break}if(S&32){t.back=-1,t.mode=ae;break}if(S&64){e.msg="invalid literal/length code",t.mode=C;break}t.extra=S&15,t.mode=In;case In:if(t.extra){for(A=t.extra;h<A;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}t.length+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=Rn;case Rn:for(;p=t.distcode[l&(1<<t.distbits)-1],m=p>>>24,S=p>>>16&255,E=p&65535,!(m<=h);){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if((S&240)===0){for(_=m,b=S,I=E;p=t.distcode[I+((l&(1<<_+b)-1)>>_)],m=p>>>24,S=p>>>16&255,E=p&65535,!(_+m<=h);){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}l>>>=_,h-=_,t.back+=_}if(l>>>=m,h-=m,t.back+=m,S&64){e.msg="invalid distance code",t.mode=C;break}t.offset=E,t.extra=S&15,t.mode=Nn;case Nn:if(t.extra){for(A=t.extra;h<A;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}t.offset+=l&(1<<t.extra)-1,l>>>=t.extra,h-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){e.msg="invalid distance too far back",t.mode=C;break}t.mode=Tn;case Tn:if(c===0)break e;if(f=u-c,t.offset>f){if(f=t.offset-f,f>t.whave&&t.sane){e.msg="invalid distance too far back",t.mode=C;break}f>t.wnext?(f-=t.wnext,g=t.wsize-f):g=t.wnext-f,f>t.length&&(f=t.length),v=t.window}else v=s,g=a-t.offset,f=t.length;f>c&&(f=c),c-=f,t.length-=f;do s[a++]=v[g++];while(--f);t.length===0&&(t.mode=Et);break;case Fn:if(c===0)break e;s[a++]=t.length,c--,t.mode=Et;break;case ci:if(t.wrap){for(;h<32;){if(o===0)break e;o--,l|=n[r++]<<h,h+=8}if(u-=c,e.total_out+=u,t.total+=u,u&&(e.adler=t.check=t.flags?j(t.check,s,u,a-u):at(t.check,s,u,a-u)),u=c,(t.flags?l:Dn(l))!==t.check){e.msg="incorrect data check",t.mode=C;break}l=0,h=0}t.mode=Bn;case Bn:if(t.wrap&&t.flags){for(;h<32;){if(o===0)break e;o--,l+=n[r++]<<h,h+=8}if(l!==(t.total&4294967295)){e.msg="incorrect length check",t.mode=C;break}l=0,h=0}t.mode=Pn;case Pn:R=Ga;break e;case C:R=bs;break e;case xs:return ms;case ja:default:return ee}return e.next_out=a,e.avail_out=c,e.next_in=r,e.avail_in=o,t.hold=l,t.bits=h,(t.wsize||u!==e.avail_out&&t.mode<C&&(t.mode<ci||i!==fn))&&As(e,e.output,e.next_out,u-e.avail_out),d-=e.avail_in,u-=e.avail_out,e.total_in+=d,e.total_out+=u,t.total+=u,t.wrap&&u&&(e.adler=t.check=t.flags?j(t.check,s,u,e.next_out-u):at(t.check,s,u,e.next_out-u)),e.data_type=t.bits+(t.last?64:0)+(t.mode===ae?128:0)+(t.mode===xt||t.mode===hi?256:0),(d===0&&u===0||i===fn)&&R===Re&&(R=Xa),R},io=e=>{if(!e||!e.state)return ee;let i=e.state;return i.window&&(i.window=null),e.state=null,Re},no=(e,i)=>{if(!e||!e.state)return ee;const t=e.state;return(t.wrap&2)===0?ee:(t.head=i,i.done=!1,Re)},so=(e,i)=>{const t=i.length;let n,s,r;return!e||!e.state||(n=e.state,n.wrap!==0&&n.mode!==Pt)?ee:n.mode===Pt&&(s=1,s=at(s,i,t,0),s!==n.check)?bs:(r=As(e,i,t,t),r?(n.mode=xs,ms):(n.havedict=1,Re))};var ro=Ss,ao=ks,oo=Es,lo=Qa,ho=ys,co=to,fo=io,uo=no,go=so,_o="pako inflate (from Nodeca project)",he={inflateReset:ro,inflateReset2:ao,inflateResetKeep:oo,inflateInit:lo,inflateInit2:ho,inflate:co,inflateEnd:fo,inflateGetHeader:uo,inflateSetDictionary:go,inflateInfo:_o};function po(){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 vo=po;const Is=Object.prototype.toString,{Z_NO_FLUSH:bo,Z_FINISH:mo,Z_OK:ht,Z_STREAM_END:ui,Z_NEED_DICT:gi,Z_STREAM_ERROR:wo,Z_DATA_ERROR:On,Z_MEM_ERROR:xo}=Ne;function pt(e){this.options=zt.assign({chunkSize:1024*64,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)===0&&(i.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new gs,this.strm.avail_out=0;let t=he.inflateInit2(this.strm,i.windowBits);if(t!==ht)throw new Error(ye[t]);if(this.header=new vo,he.inflateGetHeader(this.strm,this.header),i.dictionary&&(typeof i.dictionary=="string"?i.dictionary=lt.string2buf(i.dictionary):Is.call(i.dictionary)==="[object ArrayBuffer]"&&(i.dictionary=new Uint8Array(i.dictionary)),i.raw&&(t=he.inflateSetDictionary(this.strm,i.dictionary),t!==ht)))throw new Error(ye[t])}pt.prototype.push=function(e,i){const t=this.strm,n=this.options.chunkSize,s=this.options.dictionary;let r,a,o;if(this.ended)return!1;for(i===~~i?a=i:a=i===!0?mo:bo,Is.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=he.inflate(t,a),r===gi&&s&&(r=he.inflateSetDictionary(t,s),r===ht?r=he.inflate(t,a):r===On&&(r=gi));t.avail_in>0&&r===ui&&t.state.wrap>0&&e[t.next_in]!==0;)he.inflateReset(t),r=he.inflate(t,a);switch(r){case wo:case On:case gi:case xo:return this.onEnd(r),this.ended=!0,!1}if(o=t.avail_out,t.next_out&&(t.avail_out===0||r===ui))if(this.options.to==="string"){let c=lt.utf8border(t.output,t.next_out),l=t.next_out-c,h=lt.buf2string(t.output,c);t.next_out=l,t.avail_out=n-l,l&&t.output.set(t.output.subarray(c,c+l),0),this.onData(h)}else this.onData(t.output.length===t.next_out?t.output:t.output.subarray(0,t.next_out));if(!(r===ht&&o===0)){if(r===ui)return r=he.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(t.avail_in===0)break}}return!0};pt.prototype.onData=function(e){this.chunks.push(e)};pt.prototype.onEnd=function(e){e===ht&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=zt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Yi(e,i){const t=new pt(i);if(t.push(e),t.err)throw t.msg||ye[t.err];return t.result}function Eo(e,i){return i=i||{},i.raw=!0,Yi(e,i)}var So=pt,ko=Yi,yo=Eo,Ao=Yi,Io=Ne,Ro={Inflate:So,inflate:ko,inflateRaw:yo,ungzip:Ao,constants:Io};const{Deflate:No,deflate:To,deflateRaw:Fo,gzip:Bo}=Da,{Inflate:Po,inflate:Do,inflateRaw:Co,ungzip:Oo}=Ro;var Mo=No,Lo=To,zo=Fo,Uo=Bo,Zo=Po,Ho=Do,Yo=Co,Go=Oo,$o=Ne,Rs={Deflate:Mo,deflate:Lo,deflateRaw:zo,gzip:Uo,Inflate:Zo,inflate:Ho,inflateRaw:Yo,ungzip:Go,constants:$o},Rt=1e-6,ct=typeof Float32Array!="undefined"?Float32Array:Array,Xo=Math.PI/180;function yi(e){return e*Xo}Math.hypot||(Math.hypot=function(){for(var e=0,i=arguments.length;i--;)e+=arguments[i]*arguments[i];return Math.sqrt(e)});function Oe(){var e=new ct(16);return ct!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function jo(e,i){return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e}function Ai(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ze(e,i,t){var n=t[0],s=t[1],r=t[2],a,o,c,l,h,d,u,f,g,v,p,m;return i===e?(e[12]=i[0]*n+i[4]*s+i[8]*r+i[12],e[13]=i[1]*n+i[5]*s+i[9]*r+i[13],e[14]=i[2]*n+i[6]*s+i[10]*r+i[14],e[15]=i[3]*n+i[7]*s+i[11]*r+i[15]):(a=i[0],o=i[1],c=i[2],l=i[3],h=i[4],d=i[5],u=i[6],f=i[7],g=i[8],v=i[9],p=i[10],m=i[11],e[0]=a,e[1]=o,e[2]=c,e[3]=l,e[4]=h,e[5]=d,e[6]=u,e[7]=f,e[8]=g,e[9]=v,e[10]=p,e[11]=m,e[12]=a*n+h*s+g*r+i[12],e[13]=o*n+d*s+v*r+i[13],e[14]=c*n+u*s+p*r+i[14],e[15]=l*n+f*s+m*r+i[15]),e}function Ns(e,i,t){var n=t[0],s=t[1],r=t[2];return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=i[3]*n,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=i[7]*s,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=i[11]*r,e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e}function Vo(e,i,t,n){var s=n[0],r=n[1],a=n[2],o=Math.hypot(s,r,a),c,l,h,d,u,f,g,v,p,m,S,E,_,b,I,x,R,N,y,A,M,D,B,q;return o<Rt?null:(o=1/o,s*=o,r*=o,a*=o,c=Math.sin(t),l=Math.cos(t),h=1-l,d=i[0],u=i[1],f=i[2],g=i[3],v=i[4],p=i[5],m=i[6],S=i[7],E=i[8],_=i[9],b=i[10],I=i[11],x=s*s*h+l,R=r*s*h+a*c,N=a*s*h-r*c,y=s*r*h-a*c,A=r*r*h+l,M=a*r*h+s*c,D=s*a*h+r*c,B=r*a*h-s*c,q=a*a*h+l,e[0]=d*x+v*R+E*N,e[1]=u*x+p*R+_*N,e[2]=f*x+m*R+b*N,e[3]=g*x+S*R+I*N,e[4]=d*y+v*A+E*M,e[5]=u*y+p*A+_*M,e[6]=f*y+m*A+b*M,e[7]=g*y+S*A+I*M,e[8]=d*D+v*B+E*q,e[9]=u*D+p*B+_*q,e[10]=f*D+m*B+b*q,e[11]=g*D+S*B+I*q,i!==e&&(e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15]),e)}function Jo(e,i,t){var n=Math.sin(t),s=Math.cos(t),r=i[4],a=i[5],o=i[6],c=i[7],l=i[8],h=i[9],d=i[10],u=i[11];return i!==e&&(e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15]),e[4]=r*s+l*n,e[5]=a*s+h*n,e[6]=o*s+d*n,e[7]=c*s+u*n,e[8]=l*s-r*n,e[9]=h*s-a*n,e[10]=d*s-o*n,e[11]=u*s-c*n,e}function Wo(e,i,t){var n=Math.sin(t),s=Math.cos(t),r=i[0],a=i[1],o=i[2],c=i[3],l=i[8],h=i[9],d=i[10],u=i[11];return i!==e&&(e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15]),e[0]=r*s-l*n,e[1]=a*s-h*n,e[2]=o*s-d*n,e[3]=c*s-u*n,e[8]=r*n+l*s,e[9]=a*n+h*s,e[10]=o*n+d*s,e[11]=c*n+u*s,e}function Ko(e,i,t,n,s){var r=1/Math.tan(i/2),a;return e[0]=r/t,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0?(a=1/(n-s),e[10]=(s+n)*a,e[14]=2*s*n*a):(e[10]=-1,e[14]=-2*n),e}var qo=Ko;function Ts(){var e=new ct(3);return ct!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function Nt(e,i,t){var n=new ct(3);return n[0]=e,n[1]=i,n[2]=t,n}function Mn(e,i,t){return e[0]=i[0]-t[0],e[1]=i[1]-t[1],e[2]=i[2]-t[2],e}function Qo(e,i){return e[0]=-i[0],e[1]=-i[1],e[2]=-i[2],e}function el(e,i){var t=i[0],n=i[1],s=i[2],r=t*t+n*n+s*s;return r>0&&(r=1/Math.sqrt(r)),e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e}function tl(e,i,t){var n=i[0],s=i[1],r=i[2],a=t[0],o=t[1],c=t[2];return e[0]=s*c-r*o,e[1]=r*a-n*c,e[2]=n*o-s*a,e}function il(e,i,t){var n=i[0],s=i[1],r=i[2],a=t[3]*n+t[7]*s+t[11]*r+t[15];return a=a||1,e[0]=(t[0]*n+t[4]*s+t[8]*r+t[12])/a,e[1]=(t[1]*n+t[5]*s+t[9]*r+t[13])/a,e[2]=(t[2]*n+t[6]*s+t[10]*r+t[14])/a,e}function nl(e,i){var t=e[0],n=e[1],s=e[2],r=i[0],a=i[1],o=i[2];return Math.abs(t-r)<=Rt*Math.max(1,Math.abs(t),Math.abs(r))&&Math.abs(n-a)<=Rt*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-o)<=Rt*Math.max(1,Math.abs(s),Math.abs(o))}(function(){var e=Ts();return function(i,t,n,s,r,a){var o,c;for(t||(t=3),n||(n=0),s?c=Math.min(s*t+n,i.length):c=i.length,o=n;o<c;o+=t)e[0]=i[o],e[1]=i[o+1],e[2]=i[o+2],r(e,e,a),i[o]=e[0],i[o+1]=e[1],i[o+2]=e[2];return i}})();var O;(function(e){e.UP="up",e.DOWN="down",e.NORTH="north",e.EAST="east",e.SOUTH="south",e.WEST="west"})(O||(O={}));const sl={[O.UP]:[0,1,0],[O.DOWN]:[0,-1,0],[O.NORTH]:[0,0,-1],[O.EAST]:[1,0,0],[O.SOUTH]:[0,0,1],[O.WEST]:[-1,0,0]};var Ue;(function(e){e.ALL=[e.UP,e.DOWN,e.NORTH,e.EAST,e.SOUTH,e.WEST],e.normal=function(i){return sl[i]}})(O||(O={})),function(e){e.create=function(i,t,n){return[i,t,n]},e.offset=function(i,t,n,s){return[i[0]+t,i[1]+n,i[2]+s]},e.towards=function(i,t){return e.offset(i,...O.normal(t))}}(Ue||(Ue={}));const Qe={end:0,byte:1,short:2,int:3,long:4,float:5,double:6,byteArray:7,string:8,list:9,compound:10,intArray:11,longArray:12},Ln=["end","byte","short","int","long","float","double","byteArray","string","list","compound","intArray","longArray"];class rl{constructor(i,t=!1){this.byte=this.readNum.bind(this,"getInt8",1),this.short=this.readNum.bind(this,"getInt16",2),this.int=this.readNum.bind(this,"getInt32",4),this.float=this.readNum.bind(this,"getFloat32",4),this.double=this.readNum.bind(this,"getFloat64",8),this.offset=0,this.littleEndian=t,this.arrayView=i,this.dataView=new DataView(i.buffer,i.byteOffset)}end(){return null}readNum(i,t){const n=this.dataView[i](this.offset,this.littleEndian);return this.offset+=t,n}long(){return[this.int(),this.int()]}byteArray(){const i=this.int(),t=[];for(let n=0;n<i;n++)t.push(this.byte());return t}intArray(){const i=this.int(),t=[];for(let n=0;n<i;n++)t.push(this.int());return t}longArray(){const i=this.int(),t=[];for(let n=0;n<i;n++)t.push(this.long());return t}string(){const i=this.short(),t=this.arrayView.slice(this.offset,this.offset+i);return this.offset+=i,function(n){var s,r=[];for(s=0;s<n.length;s++)(128&n[s])==0?r.push(127&n[s]):s+1<n.length&&(224&n[s])==192&&(192&n[s+1])==128?r.push((31&n[s])<<6|63&n[s+1]):s+2<n.length&&(240&n[s])==224&&(192&n[s+1])==128&&(192&n[s+2])==128?r.push((15&n[s])<<12|(63&n[s+1])<<6|63&n[s+2]):s+3<n.length&&(248&n[s])==240&&(192&n[s+1])==128&&(192&n[s+2])==128&&(192&n[s+3])==128&&r.push((7&n[s])<<18|(63&n[s+1])<<12|(63&n[s+2])<<6|63&n[s+3]);return String.fromCharCode.apply(null,r)}(t)}list(){const i=Ln[this.byte()],t=this.int(),n=[];for(let s=0;s<t;s++)n.push(this[i]());return{type:i,value:n}}compound(){const i={};for(;;){const t=Ln[this.byte()];if(t==="end")break;const n=this.string(),s=this[t]();i[n]={type:t,value:s}}return i}}class al{constructor(i=!1){this.byte=this.writeNum.bind(this,"setInt8",1),this.short=this.writeNum.bind(this,"setInt16",2),this.int=this.writeNum.bind(this,"setInt32",4),this.float=this.writeNum.bind(this,"setFloat32",4),this.double=this.writeNum.bind(this,"setFloat64",8),this.offset=0,this.littleEndian=i,this.buffer=new ArrayBuffer(1024),this.arrayView=new Uint8Array(this.buffer),this.dataView=new DataView(this.buffer)}accommodate(i){const t=this.offset+i;if(this.buffer.byteLength>=t)return;let n=this.buffer.byteLength;for(;n<t;)n*=2;const s=new ArrayBuffer(n),r=new Uint8Array(s);r.set(this.arrayView),this.offset>this.buffer.byteLength&&r.fill(0,this.buffer.byteLength,this.offset),this.buffer=s,this.dataView=new DataView(s),this.arrayView=r}getData(){return this.accommodate(0),this.arrayView.slice(0,this.offset)}end(i){}writeNum(i,t,n){this.accommodate(t),this.dataView[i](this.offset,n,this.littleEndian),this.offset+=t}long(i){this.int(i[0]),this.int(i[1])}byteArray(i){this.int(i.length),this.accommodate(i.length),this.arrayView.set(i,this.offset),this.offset+=i.length}intArray(i){this.int(i.length);for(let t=0;t<i.length;t++)this.int(i[t])}longArray(i){this.int(i.length);for(let t=0;t<i.length;t++)this.long(i[t])}string(i){const t=function(n){var s,r,a=[];for(s=0;s<n.length;s++)(r=n.charCodeAt(s))<128?a.push(r):r<2048?(a.push(192|r>>6),a.push(128|63&r)):r<65536?(a.push(224|r>>12),a.push(128|r>>6&63),a.push(128|63&r)):(a.push(240|r>>18&7),a.push(128|r>>12&63),a.push(128|r>>6&63),a.push(128|63&r));return a}(i);this.short(t.length),this.accommodate(t.length),this.arrayView.set(t,this.offset),this.offset+=t.length}list(i){this.byte(Qe[i.type]),this.int(i.value.length),i.value;for(let t=0;t<i.value.length;t++)this[i.type](i.value[t])}compound(i){for(const t in i)this.byte(Qe[i[t].type]),this.string(t),this[i[t].type](i[t].value);this.byte(Qe.end)}}function Gi(e,i){const t=new rl(e,i);if(t.byte()!==Qe.compound)throw new Error("Top tag should be a compound");return{name:t.string(),value:t.compound()}}function Fs(e,i){return Gi(Rs.inflate(e),i)}function kl(e,i){return(t=new Uint8Array(e.slice(0,2))).length===2&&t[0]===31&&t[1]===139?{compressed:!0,result:Fs(e,i)}:{compressed:!1,result:Gi(e,i)};var t}function yl(e){const i=[];for(let t=0;t<32;t+=1)for(let n=0;n<32;n+=1){const s=4*((31&t)+32*(31&n));if(e[s+3]===0)continue;const r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],a=(e[s+4096]<<24)+(e[s+4097]<<16)+(e[s+4098]<<8)+e[s+4099],o=4096*r,c=(e[o]<<24)+(e[o+1]<<16)+(e[o+2]<<8)+e[o+3],l=e[o+4],h=e.slice(o+5,o+4+c);i.push({x:t,z:n,timestamp:a,compression:l,data:h})}return i}function Al(e,i,t){const n=Bs(e,i,t);switch(n.compression){case 1:case 2:n.nbt=Fs(n.data);break;case 3:n.nbt=Gi(n.data);break;default:throw new Error(`Invalid compression mode ${n.compression}`)}return n}function $i(e,i){const t=new al(i);return t.byte(Qe.compound),t.string(e.name),t.compound(e.value),t.getData()}function Ii(e,i,t){const n=$i(e,i);return Rs[t?"deflate":"gzip"](n)}function Il(e,i,t){return i?Ii(e,t):$i(e,t)}function Rl(e){let i=0;for(const r of e)i+=Math.ceil(r.data.length/4096);const t=new Uint8Array(8192+4096*i),n=new DataView(t.buffer);let s=2;for(const r of e){const a=4*((31&r.x)+32*(31&r.z)),o=Math.ceil(r.data.length/4096);n.setInt8(a,s>>16),n.setInt16(a+1,65535&s),n.setInt8(a+3,o),n.setInt32(a+4096,r.timestamp);const c=4096*s;n.setInt32(c,r.data.length+1),n.setInt8(c+4,r.compression),t.set(r.data,c+5),s+=o}return t}function Nl(e,i,t,n){const s=Bs(e,i,t);switch(s.compression){case 1:s.data=Ii(n);break;case 2:s.data=Ii(n,!1,!0);break;case 3:s.data=$i(n);break;default:throw new Error(`Invalid compression mode ${s.compression}`)}return s}function Bs(e,i,t){const n=e.find(s=>s.x===i&&s.z===t);if(n===void 0)throw new Error(`Cannot find chunk [${i}, ${t}]`);return n}function Me(e,i,t){if(!e[i])throw new Error(`Missing ${i} tag`);if(e[i].type!==t)throw new Error(`Expected ${i} to be of type ${t}, but found ${e[i].type}`);return e[i].value}function St(e,i,t,n){const s=Me(e,i,"list");if(s.type!==t)throw new Error(`Expected ${i} to be a list of ${t}s, but found ${s.type}s`);if(n&&s.value.length!==n)throw new Error(`Expected ${i} to be a list of length ${n}, but found length ${s.value.length}`);return s.value}function Ps(e,i){try{return e()}catch{return i}}var w,re,Ri,Le,et;(function(e){function i(t){return typeof t=="object"&&t!==null?t:void 0}e.readNumber=function(t){return typeof t=="number"?t:void 0},e.readInt=function(t){return typeof t=="number"?Math.floor(t):void 0},e.readString=function(t){return typeof t=="string"?t:void 0},e.readBoolean=function(t){return typeof t=="boolean"?t:void 0},e.readObject=i,e.readArray=function(t,n){if(Array.isArray(t))return t.map(s=>n(s))},e.readMap=function(t,n){var s;const r=(s=i(t))!==null&&s!==void 0?s:{};return Object.fromEntries(Object.entries(r).map(([a,o])=>[a,n(o)]))},e.compose=function(t,n,s){const r=n(t);return r?s(r):void 0}})(w||(w={}));class V{constructor(i,t={}){this.name=i,this.properties=t}getName(){return this.name}getProperties(){return this.properties}getProperty(i){return this.properties[i]}isFluid(){return this.name==="minecraft:water"||this.name==="minecraft:lava"}equals(i){return this.name===i.name&&Object.keys(this.properties).every(t=>i.properties[t]===this.properties[t])}toString(){return Object.keys(this.properties).length===0?this.name:`${this.name}[${Object.entries(this.properties).map(([i,t])=>i+"="+t).join(",")}]`}static fromNbt(i){const t=Me(i.value,"Name","string"),n=Ps(()=>Me(i.value,"Properties","compound"),{}),s=Object.keys(n).reduce((r,a)=>Object.assign(Object.assign({},r),{[a]:Me(n,a,"string")}),{});return new V(t,s)}static fromJson(i){var t,n;const s=(t=w.readObject(i))!==null&&t!==void 0?t:{},r=(n=w.readString(s.Name))!==null&&n!==void 0?n:"minecraft:stone",a=w.readMap(s.Properties,o=>{var c;return(c=w.readString(o))!==null&&c!==void 0?c:""});return new V(r,a)}}V.AIR=new V("minecraft:air");class pe{constructor(i){this.minY=i,this.storage=Array(pe.SIZE),this.palette=[V.AIR]}get minBlockY(){return this.minY<<4}index(i,t,n){return(i<<8)+(t<<4)+n}getBlockState(i,t,n){var s;const r=this.storage[this.index(i,t,n)];return(s=this.palette[r])!==null&&s!==void 0?s:V.AIR}setBlockState(i,t,n,s){let r=this.palette.findIndex(a=>a.equals(s));r===-1&&(r=this.palette.length,this.palette.push(s)),this.storage[this.index(i,t,n)]=r}}pe.WIDTH=16,pe.SIZE=pe.WIDTH*pe.WIDTH*pe.WIDTH;class Tl{constructor(i,t,n){this.minY=i,this.height=t,this.pos=n,this.sections=Array(this.sectionsCount).fill(null)}get maxY(){return this.minY+this.height}get minSection(){return this.minY>>4}get maxSection(){return 1+(this.maxY-1>>4)}get sectionsCount(){return this.maxSection-this.minSection}getSectionIndex(i){return(i>>4)-this.minSection}getBlockState(i){var t;const[n,s,r]=i,a=this.sections[this.getSectionIndex(s)];return(t=a==null?void 0:a.getBlockState(15&n,15&s,15&r))!==null&&t!==void 0?t:V.AIR}setBlockState(i,t){const[n,s,r]=i,a=this.getSectionIndex(s);let o=this.sections[a];if(o===null){if(t.equals(V.AIR))return;o=this.getOrCreateSection(a)}o.setBlockState(15&n,15&s,15&r,t)}getOrCreateSection(i){return this.sections[i]==null&&(this.sections[i]=new pe(this.minSection+i)),this.sections[i]}}(function(e){function i(t,n){return BigInt(4294967295&t)|BigInt(4294967295&n)<<BigInt(32)}e.create=function(t,n){return[t,n]},e.fromBlockPos=function(t){return[t[0]>>4,t[2]>>4]},e.fromLong=function(t){return[4294967295&Number(t),Number(t>>BigInt(32))]},e.toLong=function(t){return i(t[0],t[1])},e.asLong=i,e.minBlockX=function(t){return t[0]<<4},e.minBlockZ=function(t){return t[1]<<4},e.maxBlockX=function(t){return 15+(t[0]<<4)},e.maxBlockZ=function(t){return 15+(t[1]<<4)}})(re||(re={}));class Ds{constructor(i,t=[],n=[]){this.size=i,this.palette=t,this.blocks=n,this.blocksMap=[],n.forEach(s=>{if(!this.isInside(s.pos))throw new Error(`Found block at ${s.pos} which is outside the structure bounds ${this.size}`);this.blocksMap[s.pos[0]*i[1]*i[2]+s.pos[1]*i[2]+s.pos[2]]=s})}getSize(){return this.size}addBlock(i,t,n,s){if(!this.isInside(i))throw new Error(`Cannot add block at ${i} outside the structure bounds ${this.size}`);const r=new V(t,n);let a=this.palette.findIndex(o=>o.equals(r));return a===-1&&(a=this.palette.length,this.palette.push(r)),this.blocks.push({pos:i,state:a,nbt:s}),this.blocksMap[i[0]*this.size[1]*this.size[2]+i[1]*this.size[2]+i[2]]={pos:i,state:a,nbt:s},this}getBlocks(){return this.blocks.map(i=>({pos:i.pos,state:this.palette[i.state],nbt:i.nbt}))}getBlock(i){if(!this.isInside(i))return null;const t=this.blocksMap[i[0]*this.size[1]*this.size[2]+i[1]*this.size[2]+i[2]];return t?{pos:t.pos,state:this.palette[t.state],nbt:t.nbt}:null}isInside(i){return i[0]>=0&&i[0]<this.size[0]&&i[1]>=0&&i[1]<this.size[1]&&i[2]>=0&&i[2]<this.size[2]}static fromNbt(i){const t=St(i.value,"size","int",3),n=St(i.value,"palette","compound").map(r=>V.fromNbt({name:"",value:r})),s=St(i.value,"blocks","compound").map(r=>({pos:St(r,"pos","int",3),state:Me(r,"state","int"),nbt:Ps(()=>Me(r,"nbt","compound"),void 0)}));return new Ds(t,n,s)}}function _i(e){let i=null;return()=>(i==null&&(i=e()),i)}function Xi(e,i,t){const n=e.get(i);if(n)return n;const s=t(i);return e.set(i,s),s}function oe(e){return e*e}function ue(e,i,t){return Math.max(i,Math.min(t,e))}function $(e,i,t){return i+e*(t-i)}function Ni(e,i,t,n,s,r){return $(i,$(e,t,n),$(e,s,r))}function ol(e,i,t,n,s,r,a,o,c,l,h){return $(t,Ni(e,i,n,s,r,a),Ni(e,i,o,c,l,h))}function ft(e,i,t){return t<0?e:t>1?i:$(t,e,i)}function Cs(e,i,t){return(e-i)/(t-i)}function pi(e){return e*e*e*(e*(6*e-15)+10)}function ge(e,i,t,n,s){return $(Cs(e,i,t),n,s)}function ll(e,i,t,n,s){return ft(n,s,Cs(e,i,t))}function hl(e,i,t){let n=i-e;for(;n>0;){const s=Math.floor(n/2),r=e+s;t(r)?n=s:(e=r+1,n-=s+1)}return e}function Os(e,i,t){let n=BigInt(3129871*e)^BigInt(t)*BigInt(116129781)^BigInt(i);return n=n*n*BigInt(42317861)+n*BigInt(11),n>>BigInt(16)}function Ti(e,i,t,n,s,r,a,o){return BigInt(e)<<BigInt(56)|BigInt(i)<<BigInt(48)|BigInt(t)<<BigInt(40)|BigInt(n)<<BigInt(32)|BigInt(s)<<BigInt(24)|BigInt(r)<<BigInt(16)|BigInt(a)<<BigInt(8)|BigInt(o)}class z{constructor(i){this.seed=BigInt(0),this.setSeed(i)}fork(){return new z(this.nextLong())}forkPositional(){return new cl(this.seed)}setSeed(i){this.seed=i^z.MULTIPLIER&z.MODULUS_MASK}advance(){this.seed=this.seed*z.MULTIPLIER+z.INCREMENT&z.MODULUS_MASK}consume(i){for(let t=0;t<i;t+=1)this.advance()}next(i){this.advance();const t=Number(this.seed>>BigInt(z.MODULUS_BITS-i));return t>2147483647?t-4294967296:t}nextInt(i){if(i===void 0)return this.next(32);if((i&i-1)==0)return Number(BigInt(i)*BigInt(this.next(31))>>BigInt(31));let t,n;for(;(t=this.next(31))-(n=t%i)+(i-1)<0;);return n}nextLong(){return(BigInt(this.next(32))<<BigInt(32))+BigInt(this.next(32))}nextFloat(){return this.next(24)*z.FLOAT_MULTIPLIER}nextDouble(){const i=this.next(30);return this.advance(),i*z.DOUBLE_MULTIPLIER}}z.MODULUS_BITS=48,z.MODULUS_MASK=BigInt("281474976710655"),z.MULTIPLIER=BigInt("25214903917"),z.INCREMENT=BigInt("11"),z.FLOAT_MULTIPLIER=1/Math.pow(2,24),z.DOUBLE_MULTIPLIER=1/Math.pow(2,30);class cl{constructor(i){this.seed=i}at(i,t,n){const s=Os(i,t,n);return new z(s^this.seed)}fromHashOf(i){const t=jn(i,{asBytes:!0}),n=Ti(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]);return new z(n^this.seed)}}class P{constructor(i){this.seed=[BigInt(0),BigInt(0)],this.seed=i}static create(i){return new P(P.upgradeSeedTo128bit(i))}static mixStafford13(i){return((i=((i=(i^i>>BigInt(30))*BigInt("-4658895280553007687")&BigInt("0xFFFFFFFFFFFFFFFF"))^i>>BigInt(27))*BigInt("-7723592293110705685")&BigInt("0xFFFFFFFFFFFFFFFF"))^i>>BigInt(31))&BigInt("0xFFFFFFFFFFFFFFFF")}static upgradeSeedTo128bit(i){i<0&&(i+=BigInt("0x10000000000000000"));const t=i^P.SILVER_RATIO_64,n=t+P.GOLDEN_RATIO_64&BigInt("0xFFFFFFFFFFFFFFFF");return[P.mixStafford13(t),P.mixStafford13(n)]}static rotateLeft(i,t){return i<<t&BigInt("0xFFFFFFFFFFFFFFFF")|i>>BigInt(64)-t}setSeed(i){this.seed=P.upgradeSeedTo128bit(i)}fork(){return new P([this.next(),this.next()])}forkPositional(){return new fl(this.next(),this.next())}next(){const i=this.seed[0];let t=this.seed[1];const n=P.rotateLeft(i+t&BigInt("0xFFFFFFFFFFFFFFFF"),BigInt(17))+i&BigInt("0xFFFFFFFFFFFFFFFF");return t^=i,this.seed=[P.rotateLeft(i,BigInt(49))^t^t<<BigInt(21)&BigInt("0xFFFFFFFFFFFFFFFF"),P.rotateLeft(t,BigInt(28))],n}nextLong(){let i=this.next();return i>BigInt("0x8000000000000000")&&(i-=BigInt("0x10000000000000000")),i}consume(i){let t=this.seed[0],n=this.seed[1];for(let s=0;s<i;s+=1)n^=t,t=P.rotateLeft(t,BigInt(49))^n^n<<BigInt(21),n=P.rotateLeft(n,BigInt(28));this.seed=[t,n]}nextBits(i){return this.next()>>BigInt(64-i)}nextInt(i){let t=this.next()&BigInt(4294967295);if(i){const n=BigInt(i);let s=t*n,r=s&BigInt(4294967295);if(r<n){const o=((~n&BigInt(4294967295))+BigInt(1))%n;for(;r<o;)t=this.next()&BigInt(4294967295),s=t*n,r=s&BigInt(4294967295)}const a=s>>BigInt(32);return Number(a)}{let n=Number(t);return n>=2147483648&&(n-=4294967296),n}}nextFloat(){return Number(this.nextBits(24))*P.FLOAT_MULTIPLIER}nextDouble(){return Number(this.nextBits(53))*P.DOUBLE_MULTIPLIER}parityConfigString(){return"seedLo: "+this.seed[0]+", seedHi: "+this.seed[1]}}P.SILVER_RATIO_64=BigInt("7640891576956012809"),P.GOLDEN_RATIO_64=BigInt("-7046029254386353131"),P.FLOAT_MULTIPLIER=1/Math.pow(2,24),P.DOUBLE_MULTIPLIER=11102230246251565e-32;class fl{constructor(i,t){this.seedLo=i,this.seedHi=t}at(i,t,n){const s=Os(i,t,n)^this.seedLo;return new P([s,this.seedHi])}fromHashOf(i){const t=jn(i,{asBytes:!0}),n=Ti(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7]),s=Ti(t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]);return new P([n^this.seedLo,s^this.seedHi])}}class Z{constructor(i){this.xo=256*i.nextDouble(),this.yo=256*i.nextDouble(),this.zo=256*i.nextDouble(),this.p=Array(256);for(let t=0;t<256;t+=1)this.p[t]=t;for(let t=0;t<256;t+=1){const n=i.nextInt(256-t),s=this.p[t];this.p[t]=this.p[t+n],this.p[t+n]=s}}sample2D(i,t){let n,s,r;const a=(i+t)*Z.F2,o=Math.floor(i+a),c=i-(o-(n=(o+(s=Math.floor(t+a)))*Z.G2));let l,h;c>(r=t-(s-n))?(l=1,h=0):(l=0,h=1);const d=c-l+Z.G2,u=r-h+Z.G2,f=c-1+2*Z.G2,g=r-1+2*Z.G2,v=255&o,p=255&s,m=this.P(v+this.P(p))%12,S=this.P(v+l+this.P(p+h))%12,E=this.P(v+1+this.P(p+1))%12;return 70*(this.getCornerNoise3D(m,c,r,0,.5)+this.getCornerNoise3D(S,d,u,0,.5)+this.getCornerNoise3D(E,f,g,0,.5))}sample(i,t,n){const s=.3333333333333333*(i+t+n),r=Math.floor(i+s),a=Math.floor(t+s),o=Math.floor(n+s),c=.16666666666666666*(r+a+o),l=i-(r-c),h=t-(a-c),d=n-(o-c);let u,f,g,v,p,m;l>=h?h>=d?(u=1,f=0,g=0,v=1,p=1,m=0):l>=d?(u=1,f=0,g=0,v=1,p=0,m=1):(u=0,f=0,g=1,v=1,p=0,m=1):h<d?(u=0,f=0,g=1,v=0,p=1,m=1):l<d?(u=0,f=1,g=0,v=0,p=1,m=1):(u=0,f=1,g=0,v=1,p=1,m=0);const S=l-u+.16666666666666666,E=h-f+.16666666666666666,_=d-g+.16666666666666666,b=l-v+.3333333333333333,I=h-p+.3333333333333333,x=d-m+.3333333333333333,R=l-.5,N=h-.5,y=d-.5,A=255&r,M=255&a,D=255&o,B=this.P(A+this.P(M+this.P(D)))%12,q=this.P(A+u+this.P(M+f+this.P(D+g)))%12,Y=this.P(A+v+this.P(M+p+this.P(D+m)))%12,L=this.P(A+1+this.P(M+1+this.P(D+1)))%12;return 32*(this.getCornerNoise3D(B,l,h,d,.6)+this.getCornerNoise3D(q,S,E,_,.6)+this.getCornerNoise3D(Y,b,I,x,.6)+this.getCornerNoise3D(L,R,N,y,.6))}P(i){return this.p[255&i]}getCornerNoise3D(i,t,n,s,r){let a,o=r-t*t-n*n-s*s;return o<0?a=0:(o*=o,a=o*o*Z.gradDot(i,t,n,s)),a}static gradDot(i,t,n,s){const r=Z.GRADIENT[15&i];return r[0]*t+r[1]*n+r[2]*s}}Z.GRADIENT=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1],[1,1,0],[0,-1,1],[-1,1,0],[0,-1,-1]],Z.F2=.5*(Math.sqrt(3)-1),Z.G2=(3-Math.sqrt(3))/6;class zn{constructor(i){this.xo=256*i.nextDouble(),this.yo=256*i.nextDouble(),this.zo=256*i.nextDouble(),this.p=Array(256);for(let t=0;t<256;t+=1)this.p[t]=t>127?t-256:t;for(let t=0;t<256;t+=1){const n=i.nextInt(256-t),s=this.p[t];this.p[t]=this.p[t+n],this.p[t+n]=s}}sample(i,t,n,s=0,r=0){const a=i+this.xo,o=t+this.yo,c=n+this.zo,l=Math.floor(a),h=Math.floor(o),d=Math.floor(c),u=a-l,f=o-h,g=c-d;let v=0;if(s!==0){const p=r>=0&&r<f?r:f;v=Math.floor(p/s+1e-7)*s}return this.sampleAndLerp(l,h,d,u,f-v,g,f)}sampleAndLerp(i,t,n,s,r,a,o){const c=this.P(i),l=this.P(i+1),h=this.P(c+t),d=this.P(c+t+1),u=this.P(l+t),f=this.P(l+t+1),g=Z.gradDot(this.P(h+n),s,r,a),v=Z.gradDot(this.P(u+n),s-1,r,a),p=Z.gradDot(this.P(d+n),s,r-1,a),m=Z.gradDot(this.P(f+n),s-1,r-1,a),S=Z.gradDot(this.P(h+n+1),s,r,a-1),E=Z.gradDot(this.P(u+n+1),s-1,r,a-1),_=Z.gradDot(this.P(d+n+1),s,r-1,a-1),b=Z.gradDot(this.P(f+n+1),s-1,r-1,a-1);return ol(pi(s),pi(o),pi(a),g,v,p,m,S,E,_,b)}P(i){return 255&this.p[255&i]}}class W{constructor(i,t,n){if(i instanceof P){const s=i.forkPositional();this.noiseLevels=Array(n.length);for(let r=0;r<n.length;r++)if(n[r]!==0){const a=t+r;this.noiseLevels[r]=new zn(s.fromHashOf("octave_"+a))}}else{if(1-t<n.length)throw new Error("Positive octaves are not allowed when using LegacyRandom");this.noiseLevels=Array(n.length);for(let s=-t;s>=0;s-=1)s<n.length&&n[s]!==0?this.noiseLevels[s]=new zn(i):i.consume(262)}this.amplitudes=n,this.lowestFreqInputFactor=Math.pow(2,t),this.lowestFreqValueFactor=Math.pow(2,n.length-1)/(Math.pow(2,n.length)-1)}sample(i,t,n,s=0,r=0,a=!1){let o=0,c=this.lowestFreqInputFactor,l=this.lowestFreqValueFactor;for(let h=0;h<this.noiseLevels.length;h+=1){const d=this.noiseLevels[h];d&&(o+=this.amplitudes[h]*l*d.sample(W.wrap(i*c),a?-d.yo:W.wrap(t*c),W.wrap(n*c),s*c,r*c)),c*=2,l/=2}return o}getOctaveNoise(i){return this.noiseLevels[this.noiseLevels.length-1-i]}static wrap(i){return i-33554432*Math.floor(i/33554432+.5)}}class Un{constructor(i,t,n,s){this.cellWidth=n,this.cellHeight=s,this.minLimitNoise=new W(i,-15,[1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0]),this.maxLimitNoise=new W(i,-15,[1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0]),this.mainNoise=new W(i,-7,[1,1,1,1,1,0,0,0]),this.xzScale=684.412*t.xzScale,this.yScale=684.412*t.yScale,this.xzMainScale=this.xzScale/t.xzFactor,this.yMainScale=this.yScale/t.yFactor}sample(i,t,n){let s;i=Math.floor(i/this.cellWidth),t=Math.floor(t/this.cellHeight),n=Math.floor(n/this.cellWidth);let r=0,a=1;for(let l=0;l<8;l+=1){if(s=this.mainNoise.getOctaveNoise(l),s){const h=this.xzMainScale*a,d=this.yMainScale*a,u=W.wrap(i*h),f=W.wrap(t*d),g=W.wrap(n*h);r+=s.sample(u,f,g,d,t*d)/a}a/=2}r=(r/10+1)/2,a=1;let o=0,c=0;for(let l=0;l<16;l+=1){const h=this.xzScale*a,d=this.yScale*a,u=W.wrap(i*h),f=W.wrap(t*d),g=W.wrap(n*h);r<1&&(s=this.minLimitNoise.getOctaveNoise(l))&&(o+=s.sample(u,f,g,d,t*d)/a),r>0&&(s=this.maxLimitNoise.getOctaveNoise(l))&&(c+=s.sample(u,f,g,d,t*d)/a),a/=2}return ft(o/512,c/512,r)/128}}(function(e){e.fromJson=function(i){var t,n,s,r,a;const o=(t=w.readObject(i))!==null&&t!==void 0?t:{};return{xzScale:(n=w.readNumber(o.xz_scale))!==null&&n!==void 0?n:1,yScale:(s=w.readNumber(o.y_scale))!==null&&s!==void 0?s:1,xzFactor:(r=w.readNumber(o.xz_factor))!==null&&r!==void 0?r:80,yFactor:(a=w.readNumber(o.y_factor))!==null&&a!==void 0?a:80}}})(Ri||(Ri={}));class ce{constructor(i,{firstOctave:t,amplitudes:n}){this.first=new W(i,t,n),this.second=new W(i,t,n);let s=1/0,r=-1/0;for(let o=0;o<n.length;o+=1)n[o]!==0&&(s=Math.min(s,o),r=Math.max(r,o));const a=.1*(1+1/(r-s+1));this.valueFactor=1/6/a}sample(i,t,n){const s=i*ce.INPUT_FACTOR,r=t*ce.INPUT_FACTOR,a=n*ce.INPUT_FACTOR;return(this.first.sample(i,t,n)+this.second.sample(s,r,a))*this.valueFactor}}ce.INPUT_FACTOR=1.0181268882175227,function(e){e.create=function(i,t){return{firstOctave:i,amplitudes:t}},e.fromJson=function(i){var t,n,s;const r=(t=w.readObject(i))!==null&&t!==void 0?t:{};return{firstOctave:(n=w.readInt(r.firstOctave))!==null&&n!==void 0?n:0,amplitudes:(s=w.readArray(r.amplitudes,a=>{var o;return(o=w.readNumber(a))!==null&&o!==void 0?o:0}))!==null&&s!==void 0?s:[]}}}(Le||(Le={}));class Fl{constructor(i,t){const n=t[t.length-1],s=-t[0]+n+1,r=new Set(t),a=new Z(i);this.noiseLevels=Array(s),n>=0&&n<s&&r.has(0)&&(this.noiseLevels[n]=a);for(let o=n+1;o<s;o+=1)o>=0&&r.has(n-o)?this.noiseLevels[o]=new Z(i):i.consume(262);if(n>0)throw new Error("Positive octaves are not allowed");this.highestFreqInputFactor=Math.pow(2,n),this.highestFreqValueFactor=1/(Math.pow(2,s)-1)}sample(i,t,n){let s=0,r=this.highestFreqInputFactor,a=this.highestFreqValueFactor;for(let o=0;o<this.noiseLevels.length;o+=1){const c=this.noiseLevels[o];c&&(s+=a*c.sample2D(i*r+(n?c.xo:0),t*r+(n?c.yo:0))),r/=2,a*=2}return s}}(function(e){e.fromJson=function(i,t){var n,s,r,a;if(typeof i=="number")return new Fi(i);const o=(n=w.readObject(i))!==null&&n!==void 0?n:{},c=new G(t(o.coordinate)),l=(s=w.readArray(o.points,h=>{var d;return(d=w.readObject(h))!==null&&d!==void 0?d:{}}))!==null&&s!==void 0?s:[];if(l.length===0)return new Fi(0);for(const h of l){const d=(r=w.readNumber(h.location))!==null&&r!==void 0?r:0,u=e.fromJson(h.value,t),f=(a=w.readNumber(h.derivative))!==null&&a!==void 0?a:0;c.addPoint(d,u,f)}return c}})(et||(et={}));class Fi{constructor(i){this.value=i}apply(){return this.value}toJson(){return this.value}}class G{constructor(i,t=[],n=[],s=[]){this.coordinate=i,this.locations=t,this.values=n,this.derivatives=s}apply(i){const t=this.coordinate.apply(i),n=hl(0,this.locations.length,g=>t<this.locations[g])-1,s=this.locations.length-1;if(n<0)return this.values[0].apply(i)+this.derivatives[0]*(t-this.locations[0]);if(n===s)return this.values[s].apply(i)+this.derivatives[s]*(t-this.locations[s]);const r=this.locations[n],a=this.locations[n+1],o=this.derivatives[n],c=this.derivatives[n+1],l=(t-r)/(a-r),h=this.values[n].apply(i),d=this.values[n+1].apply(i),u=o*(a-r)-(d-h),f=-c*(a-r)+(d-h);return $(l,h,d)+l*(1-l)*$(l,u,f)}addPoint(i,t,n=0){return this.locations.push(i),this.values.push(typeof t=="number"?new Fi(t):t),this.derivatives.push(n),this}toJson(){return{coordinate:this.coordinate.toJson(),points:this.locations.map((i,t)=>({location:i,value:this.values[t].toJson(),derivative:this.derivatives[t]}))}}}const Ye=e=>[(e>>16&255)/256,(e>>8&255)/256,(255&e)/256],Ee=[124/256,189/256,107/256],dl=Ye(6396257),ul=Ye(8431445),je=Ye(4764952),vi=Ye(4159204),Zn=Ye(8431445),gl=Ye(2129968),Hn=e=>[e/8,1-e/32,64*e],Yn={large_fern:()=>Ee,tall_grass:()=>Ee,grass_block:()=>Ee,fern:()=>Ee,grass:()=>Ee,potted_fern:()=>Ee,spruce_leaves:()=>dl,birch_leaves:()=>ul,oak_leaves:()=>je,jungle_leaves:()=>je,acacia_leaves:()=>je,dark_oak_leaves:()=>je,vine:()=>je,water:()=>vi,bubble_column:()=>vi,cauldron:()=>vi,redstone_wire:e=>{var i;return(t=>{const n=t/15;return[.6*n+(n>0?.4:.3),ue(n*n*.7-.5,0,1),ue(n*n*.6-.7,0,1)]})(parseInt((i=e.power)!==null&&i!==void 0?i:"0"))},sugar_cane:()=>Ee,attached_melon_stem:()=>Zn,attached_pumpkin_stem:()=>Zn,melon_stem:e=>{var i;return Hn(parseInt((i=e.age)!==null&&i!==void 0?i:"0"))},pumpkin_stem:e=>{var i;return Hn(parseInt((i=e.age)!==null&&i!==void 0?i:"0"))},lily_pad:()=>gl};var Bi;function Dt(...e){let i=0;for(const s of e)i+=s.length;const t=new Float32Array(i);let n=0;for(const s of e)t.set(s,n),n+=s.length;return t}function Ct(e,i){const t=Ts();for(let n=0;n<e.length;n+=3)t[0]=e[n],t[1]=e[n+1],t[2]=e[n+2],il(t,t,i),e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2]}(function(e){e.rotate=function(i,t,n){let{up:s,down:r,north:a,east:o,south:c,west:l}=i;switch(n){case 90:[a,o,c,l]=[o,c,l,a];break;case 180:[a,o,c,l]=[c,l,a,o];break;case 270:[a,o,c,l]=[l,a,o,c]}switch(t){case 90:[s,a,r,c]=[a,r,c,s];break;case 180:[s,a,r,c]=[r,c,s,a];break;case 270:[s,a,r,c]=[c,s,a,r]}return{up:s,down:r,north:a,east:o,south:c,west:l}}})(Bi||(Bi={}));class ji{constructor(i,t,n){this.id=i,this.variants=t,this.multipart=n,this.variants=t}getModelVariants(i){if(this.variants){const t=Object.keys(this.variants).filter(s=>this.matchesVariant(s,i));if(t.length===0)return[];const n=this.variants[t[0]];return[Array.isArray(n)?n[0]:n]}return this.multipart?this.multipart.filter(t=>!t.when||this.matchesCase(t.when,i)).map(t=>Array.isArray(t.apply)?t.apply[0]:t.apply):[]}getBuffers(i,t,n,s,r,a){var o,c,l,h;const d=this.getModelVariants(t),u=[],f=[],g=[],v=[];for(const S of d){const E=Bi.rotate(a,(o=S.x)!==null&&o!==void 0?o:0,(c=S.y)!==null&&c!==void 0?c:0),_=s.getBlockModel(S.model).getBuffers(i,t,n,r,E);if(S.x||S.y){const b=Oe();Ai(b),ze(b,b,[8,8,8]),Wo(b,b,-yi((l=S.y)!==null&&l!==void 0?l:0)),Jo(b,b,-yi((h=S.x)!==null&&h!==void 0?h:0)),ze(b,b,[-8,-8,-8]),Ct(_.position,b)}u.push(_.position),f.push(..._.texCoord),g.push(..._.tintColor),v.push(..._.index),r+=_.texCoord.length/2}const p=Oe();Ai(p),Ns(p,p,[.0625,.0625,.0625]);const m=Dt(...u);return Ct(m,p),{position:m,texCoord:f,tintColor:g,index:v}}matchesVariant(i,t){return i.split(",").every(n=>{const[s,r]=n.split("=");return t[s]===r})}matchesCase(i,t){if(Array.isArray(i.OR))return i.OR.some(s=>this.matchesCase(s,t));const n=i;return Object.keys(n).every(s=>n[s].split("|").includes(t[s]))}static fromJson(i,t){return new ji(i,t.variants,t.multipart)}}const _l={0:[0,3,2,3,2,1,0,1],90:[2,3,2,1,0,1,0,3],180:[2,1,0,1,0,3,2,3],270:[0,1,0,3,2,3,2,1]},pl={x:[1,0,0],y:[0,1,0],z:[0,0,1]},Pe=1.41421356237,vl={x:[1,Pe,Pe],y:[Pe,1,Pe],z:[Pe,Pe,1]};class Ut{constructor(i,t,n,s){this.id=i,this.parent=t,this.textures=n,this.elements=s,this.flattened=!1}getBuffers(i,t,n,s,r){var a;const o=[],c=[],l=[],h=[];for(const d of(a=this.elements)!==null&&a!==void 0?a:[]){const u=this.getElementBuffers(i,t,d,s,n,r);o.push(u.position),c.push(...u.texCoord),l.push(...u.tintColor),h.push(...u.index),s+=u.texCoord.length/2}return{position:Dt(...o),texCoord:c,tintColor:l,index:h}}getElementBuffers(i,t,n,s,r,a){var o,c,l,h,d,u,f,g,v,p,m,S;const E=n.from[0],_=n.from[1],b=n.from[2],I=n.to[0],x=n.to[1],R=n.to[2],N=[],y=[],A=[],M=[],D=(Y,L,Zs)=>{var Zt,Ht,Yt,Gt,$t,Xt,jt,Vt,Jt,Wt,Kt,qt;const[Ge,$e,Hs,Ys]=r.getTextureUV(this.getTexture(Y.texture)),Qt=(Hs-Ge)/16,ei=(Ys-$e)/16,Vi=Qt/16,Ji=ei/16;L[0]=((Ht=(Zt=Y.uv)===null||Zt===void 0?void 0:Zt[0])!==null&&Ht!==void 0?Ht:L[0])*Qt+Vi,L[1]=((Gt=(Yt=Y.uv)===null||Yt===void 0?void 0:Yt[1])!==null&&Gt!==void 0?Gt:L[1])*ei+Ji,L[2]=((Xt=($t=Y.uv)===null||$t===void 0?void 0:$t[2])!==null&&Xt!==void 0?Xt:L[2])*Qt-Vi,L[3]=((Vt=(jt=Y.uv)===null||jt===void 0?void 0:jt[3])!==null&&Vt!==void 0?Vt:L[3])*ei-Ji;const fe=_l[(Jt=Y.rotation)!==null&&Jt!==void 0?Jt:0];y.push(Ge+L[fe[0]],$e+L[fe[1]],Ge+L[fe[2]],$e+L[fe[3]],Ge+L[fe[4]],$e+L[fe[5]],Ge+L[fe[6]],$e+L[fe[7]]);const vt=((Wt=Y.tintindex)!==null&&Wt!==void 0?Wt:-1)>=0&&(qt=(Kt=Yn[i.slice(10)])===null||Kt===void 0?void 0:Kt.call(Yn,t))!==null&&qt!==void 0?qt:[1,1,1];A.push(...vt,...vt,...vt,...vt),N.push(...Zs),M.push(s,s+1,s+2,s,s+2,s+3),s+=4};!(!((c=(o=n.faces)===null||o===void 0?void 0:o.up)===null||c===void 0)&&c.texture)||n.faces.up.cullface&&a[n.faces.up.cullface]||D(n.faces.up,[E,16-R,I,16-b],[E,x,R,I,x,R,I,x,b,E,x,b]),!(!((h=(l=n.faces)===null||l===void 0?void 0:l.down)===null||h===void 0)&&h.texture)||n.faces.down.cullface&&a[n.faces.down.cullface]||D(n.faces.down,[16-R,16-I,16-b,16-E],[E,_,b,I,_,b,I,_,R,E,_,R]),!(!((u=(d=n.faces)===null||d===void 0?void 0:d.south)===null||u===void 0)&&u.texture)||n.faces.south.cullface&&a[n.faces.south.cullface]||D(n.faces.south,[E,16-x,I,16-_],[E,_,R,I,_,R,I,x,R,E,x,R]),!(!((g=(f=n.faces)===null||f===void 0?void 0:f.north)===null||g===void 0)&&g.texture)||n.faces.north.cullface&&a[n.faces.north.cullface]||D(n.faces.north,[16-I,16-x,16-E,16-_],[I,_,b,E,_,b,E,x,b,I,x,b]),!(!((p=(v=n.faces)===null||v===void 0?void 0:v.east)===null||p===void 0)&&p.texture)||n.faces.east.cullface&&a[n.faces.east.cullface]||D(n.faces.east,[16-R,16-x,16-b,16-_],[I,_,R,I,_,b,I,x,b,I,x,R]),!(!((S=(m=n.faces)===null||m===void 0?void 0:m.west)===null||S===void 0)&&S.texture)||n.faces.west.cullface&&a[n.faces.west.cullface]||D(n.faces.west,[b,16-x,R,16-_],[E,_,b,E,_,R,E,x,R,E,x,b]);const B=Oe();if(Ai(B),n.rotation){const Y=Nt(...n.rotation.origin);ze(B,B,Y),Vo(B,B,yi(n.rotation.angle),pl[n.rotation.axis]),n.rotation.rescale&&Ns(B,B,vl[n.rotation.axis]),Qo(Y,Y),ze(B,B,Y)}const q=new Float32Array(N);return Ct(q,B),{position:q,texCoord:y,tintColor:A,index:M}}getTexture(i){for(var t,n;i.startsWith("#");)i=(n=(t=this.textures)===null||t===void 0?void 0:t[i.slice(1)])!==null&&n!==void 0?n:"";return i.startsWith("minecraft:")||(i="minecraft:"+i),i}flatten(i){var t;if(!this.flattened&&this.parent){const n=i.getBlockModel(this.parent);if(!n)return console.warn(`parent ${this.parent} does not exist!`),void(this.flattened=!0);n.flatten(i),this.elements||(this.elements=n.elements),this.textures||(this.textures={}),Object.keys((t=n.textures)!==null&&t!==void 0?t:{}).forEach(s=>{this.textures[s]||(this.textures[s]=n.textures[s])}),this.flattened=!0}}static fromJson(i,t){let n=t.parent;return n&&!n.startsWith("minecraft:")&&(n="minecraft:"+n),new Ut(i,n,t.textures,t.elements)}}class bi{constructor(i,t,n){this.gl=i,this.program=this.initShaderProgram(t,n)}getProgram(){return this.program}initShaderProgram(i,t){const n=this.loadShader(this.gl.VERTEX_SHADER,i),s=this.loadShader(this.gl.FRAGMENT_SHADER,t),r=this.gl.createProgram();if(this.gl.attachShader(r,n),this.gl.attachShader(r,s),this.gl.linkProgram(r),!this.gl.getProgramParameter(r,this.gl.LINK_STATUS))throw new Error(`Unable to link shader program: ${this.gl.getProgramInfoLog(r)}`);return r}loadShader(i,t){const n=this.gl.createShader(i);if(this.gl.shaderSource(n,t),this.gl.compileShader(n),!this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)){const s=new Error(`Compiling ${i===this.gl.VERTEX_SHADER?"vertex":"fragment"} shader: ${this.gl.getShaderInfoLog(n)}`);throw this.gl.deleteShader(n),s}return n}}function Ms(e,i,t,n,s){const r=new ji("",{"":{model:""}},void 0),a={getBlockModel:()=>s};return s.flatten(a),r.getBuffers(e,{},i,a,t,n)}function Gn(e,i,t,n,s,r){const a=s.up?16:[14.2,12.5,10.5,9,7,5.3,3.7,1.9,16,16,16,16,16,16,16,16][t];return Ms(`minecraft:${e}`,n,i,s,new Ut("","",{still:`minecraft:block/${e}_still`,flow:`minecraft:block/${e}_flow`},[{from:[0,0,0],to:[16,a,16],faces:{up:{texture:"#still",tintindex:r,cullface:O.UP},down:{texture:"#still",tintindex:r,cullface:O.DOWN},north:{texture:"#flow",tintindex:r,cullface:O.NORTH},east:{texture:"#flow",tintindex:r,cullface:O.EAST},south:{texture:"#flow",tintindex:r,cullface:O.SOUTH},west:{texture:"#flow",tintindex:r,cullface:O.WEST}}}]))}const Ls={"minecraft:water":(e,i,t,n)=>Gn("water",e,parseInt(i.level),t,n,0),"minecraft:lava":(e,i,t,n)=>Gn("lava",e,parseInt(i.level),t,n),"minecraft:chest":(e,i,t)=>function(n,s,r,a){return Ms("minecraft:chest",a,n,{},new Ut("","",{0:"minecraft:block/chest"},[{from:[1,0,1],to:[15,14,15],faces:{up:{texture:"#0"},down:{texture:"#0"},north:{texture:"#0"},east:{texture:"#0"},south:{texture:"#0"},west:{texture:"#0"}}}]))}(e,i.facing,i.type,t)},bl=new Set(Object.keys(Ls));class Bl{constructor(i,t,n,s){var r,a;this.gl=i,this.structure=t,this.resources=n,this.chunks=[],s!=null&&s.facesPerBuffer&&console.warn("webgl render warning: facesPerBuffer option has been removed in favor of chunkSize"),this.chunkSize=(r=s==null?void 0:s.chunkSize)!==null&&r!==void 0?r:16,this.useInvisibleBlockBuffer=(a=s==null?void 0:s.useInvisibleBlockBuffer)===null||a===void 0||a,this.shaderProgram=new bi(i,`
attribute vec4 vertPos;
attribute vec2 texCoord;
attribute vec3 tintColor;
attribute vec3 normal;
uniform mat4 mView;
uniform mat4 mProj;
varying highp vec2 vTexCoord;
varying highp vec3 vTintColor;
varying highp float vLighting;
void main(void) {
gl_Position = mProj * mView * vertPos;
vTexCoord = texCoord;
vTintColor = tintColor;
vLighting = normal.y * 0.2 + abs(normal.z) * 0.1 + 0.8;
}
`,`
precision highp float;
varying highp vec2 vTexCoord;
varying highp vec3 vTintColor;
varying highp float vLighting;
uniform sampler2D sampler;
void main(void) {
vec4 texColor = texture2D(sampler, vTexCoord);
if(texColor.a < 0.01) discard;
gl_FragColor = vec4(texColor.xyz * vTintColor * vLighting, texColor.a);
}
`).getProgram(),this.gridShaderProgram=new bi(i,`
attribute vec4 vertPos;
attribute vec3 vertColor;
uniform mat4 mView;
uniform mat4 mProj;
varying highp vec3 vColor;
void main(void) {
gl_Position = mProj * mView * vertPos;
vColor = vertColor;
}
`,`
precision highp float;
varying highp vec3 vColor;
void main(void) {
gl_FragColor = vec4(vColor, 1.0);
}
`).getProgram(),this.colorShaderProgram=new bi(i,`
attribute vec4 vertPos;
attribute vec3 blockPos;
uniform mat4 mView;
uniform mat4 mProj;
varying highp vec3 vColor;
void main(void) {
gl_Position = mProj * mView * vertPos;
vColor = blockPos / 256.0;
}
`,`
precision highp float;
varying highp vec3 vColor;
void main(void) {
gl_FragColor = vec4(vColor, 1.0);
}
`).getProgram(),this.updateStructureBuffers(),this.gridBuffers=this.getGridBuffers(),this.outlineBuffers=this.getOutlineBuffers(),this.invisibleBlockBuffers=this.getInvisibleBlockBuffers(),this.atlasTexture=this.getBlockTexture(),this.projMatrix=this.getPerspective(),this.activeShader=this.shaderProgram,this.initialize()}setStructure(i){this.structure=i,this.updateStructureBuffers(),this.gridBuffers=this.getGridBuffers(),this.invisibleBlockBuffers=this.getInvisibleBlockBuffers()}initialize(){this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LEQUAL),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enable(this.gl.CULL_FACE),this.gl.cullFace(this.gl.BACK)}getBlockTexture(){const i=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,i),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.resources.getTextureAtlas()),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),i}getPerspective(){const i=70*Math.PI/180,t=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,n=Oe();return qo(n,i,t,.1,500),n}getChunk(i){const t=2*Math.abs(i[0])+(i[0]<0?1:0),n=2*Math.abs(i[1])+(i[1]<0?1:0),s=2*Math.abs(i[2])+(i[2]<0?1:0);return this.chunks[t]||(this.chunks[t]=[]),this.chunks[t][n]||(this.chunks[t][n]=[]),this.chunks[t][n][s]||(this.chunks[t][n][s]={positions:[],textureCoordinates:[],tintColors:[],blockPositions:[],normals:[],indices:[],indexOffset:0}),this.chunks[t][n][s]}updateStructureBuffers(i){var t;const n=(o,c,l)=>{const h=Oe();ze(h,h,c),Ct(o.position,h),l.positions.push(o.position),l.textureCoordinates.push(...o.texCoord),l.tintColors.push(...o.tintColor);for(let d=0;d<o.position.length;d+=12){const u=Nt(o.position[d],o.position[d+1],o.position[d+2]),f=Nt(o.position[d+3],o.position[d+4],o.position[d+5]),g=Nt(o.position[d+6],o.position[d+7],o.position[d+8]);Mn(f,f,u),Mn(g,g,u),tl(f,f,g),el(f,f),l.normals.push(...f,...f,...f,...f)}for(let d=0;d<o.texCoord.length/2;d+=1)l.blockPositions.push(...c);l.indices.push(...o.index),l.indexOffset+=o.texCoord.length/2},s=o=>{o.positions=[],o.textureCoordinates=[],o.tintColors=[],o.blockPositions=[],o.normals=[],o.indices=[],o.indexOffset=0},r=o=>{o.buffer?(this.updateBuffer(o.buffer.position,this.gl.ARRAY_BUFFER,Dt(...o.positions)),this.updateBuffer(o.buffer.texCoord,this.gl.ARRAY_BUFFER,new Float32Array(o.textureCoordinates)),this.updateBuffer(o.buffer.tintColor,this.gl.ARRAY_BUFFER,new Float32Array(o.tintColors)),this.updateBuffer(o.buffer.normal,this.gl.ARRAY_BUFFER,new Float32Array(o.normals)),this.updateBuffer(o.buffer.blockPos,this.gl.ARRAY_BUFFER,new Float32Array(o.blockPositions)),this.updateBuffer(o.buffer.index,this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(o.indices)),o.buffer.length=o.indices.length):o.buffer={position:this.createBuffer(this.gl.ARRAY_BUFFER,Dt(...o.positions)),texCoord:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(o.textureCoordinates)),tintColor:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(o.tintColors)),blockPos:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(o.blockPositions)),normal:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(o.normals)),index:this.createBuffer(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(o.indices)),length:o.indices.length}};let a;i?i.forEach(o=>{const c=this.getChunk(o);s(c)}):this.chunks.forEach(o=>o.forEach(c=>c.forEach(l=>{s(l)})));for(const o of this.structure.getBlocks()){const c=o.state.getName(),l=o.state.getProperties(),h=(t=this.resources.getDefaultBlockProperties(c))!==null&&t!==void 0?t:{};Object.entries(h).forEach(([f,g])=>{l[f]||(l[f]=g)});const d=[Math.floor(o.pos[0]/this.chunkSize),Math.floor(o.pos[1]/this.chunkSize),Math.floor(o.pos[2]/this.chunkSize)];if(i&&!i.some(f=>nl(f,d)))continue;const u=this.getChunk(d);try{const f=this.resources.getBlockDefinition(c),g={up:this.needsCull(o,O.UP),down:this.needsCull(o,O.DOWN),west:this.needsCull(o,O.WEST),east:this.needsCull(o,O.EAST),north:this.needsCull(o,O.NORTH),south:this.needsCull(o,O.SOUTH)};f&&(a=f.getBuffers(c,l,this.resources,this.resources,u.indexOffset,g),n(a,o.pos,u)),bl.has(c)&&(a=Ls[c](u.indexOffset,l,this.resources,g),n(a,o.pos,u))}catch(f){console.error(`Error rendering block ${c}`,f)}}i?i.forEach(o=>{const c=this.getChunk(o);r(c)}):this.chunks.forEach(o=>o.forEach(c=>c.forEach(l=>{r(l)})))}needsCull(i,t){var n,s;const r=(n=this.structure.getBlock(Ue.towards(i.pos,t)))===null||n===void 0?void 0:n.state;return!!r&&(!((s=this.resources.getBlockFlags(r.getName()))===null||s===void 0)&&s.opaque?!(t===O.UP&&i.state.isFluid()):i.state.isFluid()&&r.isFluid())}getGridBuffers(){const[i,t,n]=this.structure.getSize(),s=[],r=[];s.push(0,0,0,i,0,0),r.push(1,0,0,1,0,0),s.push(0,0,0,0,0,n),r.push(0,0,1,0,0,1),s.push(0,0,0,0,t,0),s.push(i,0,0,i,t,0),s.push(0,0,n,0,t,n),s.push(i,0,n,i,t,n),s.push(0,t,0,0,t,n),s.push(i,t,0,i,t,n),s.push(0,t,0,i,t,0),s.push(0,t,n,i,t,n);for(let a=1;a<=i;a+=1)s.push(a,0,0,a,0,n);for(let a=1;a<=n;a+=1)s.push(0,0,a,i,0,a);for(let a=0;a<8+i+n;a+=1)r.push(.8,.8,.8,.8,.8,.8);return{position:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(s)),color:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(r)),length:s.length/3}}getOutlineBuffers(){const i=[],t=[];return this.addCube(i,t,[1,1,1],[0,0,0],[1,1,1]),{position:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(i)),color:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(t)),length:i.length/3}}getInvisibleBlockBuffers(){if(!this.useInvisibleBlockBuffer)return;const i=this.structure.getSize(),t=[],n=[];for(let s=0;s<i[0];s+=1)for(let r=0;r<i[1];r+=1)for(let a=0;a<i[2];a+=1){const o=this.structure.getBlock([s,r,a]);o!==void 0&&(o===null?this.addCube(t,n,[1,.25,.25],[s+.4375,r+.4375,a+.4375],[s+.5625,r+.5625,a+.5625]):o.state.getName()==="minecraft:air"?this.addCube(t,n,[.5,.5,1],[s+.375,r+.375,a+.375],[s+.625,r+.625,a+.625]):o.state.getName()==="minecraft:cave_air"&&this.addCube(t,n,[.5,1,.5],[s+.375,r+.375,a+.375],[s+.625,r+.625,a+.625]))}return{position:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(t)),color:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(n)),length:t.length/3}}addCube(i,t,n,s,r){i.push(s[0],s[1],s[2],s[0],s[1],r[2]),i.push(r[0],s[1],s[2],r[0],s[1],r[2]),i.push(s[0],s[1],s[2],r[0],s[1],s[2]),i.push(s[0],s[1],r[2],r[0],s[1],r[2]),i.push(s[0],s[1],s[2],s[0],r[1],s[2]),i.push(r[0],s[1],s[2],r[0],r[1],s[2]),i.push(s[0],s[1],r[2],s[0],r[1],r[2]),i.push(r[0],s[1],r[2],r[0],r[1],r[2]),i.push(s[0],r[1],s[2],s[0],r[1],r[2]),i.push(r[0],r[1],s[2],r[0],r[1],r[2]),i.push(s[0],r[1],s[2],r[0],r[1],s[2]),i.push(s[0],r[1],r[2],r[0],r[1],r[2]);for(let a=0;a<24;a+=1)t.push(...n)}createBuffer(i,t){const n=this.gl.createBuffer();return this.gl.bindBuffer(i,n),this.gl.bufferData(i,t,this.gl.DYNAMIC_DRAW),n}updateBuffer(i,t,n){this.gl.bindBuffer(t,i),this.gl.bufferData(t,n,this.gl.STATIC_DRAW)}drawGrid(i){this.setShader(this.gridShaderProgram),this.setVertexAttr("vertPos",3,this.gridBuffers.position),this.setVertexAttr("vertColor",3,this.gridBuffers.color),this.setUniform("mView",i),this.setUniform("mProj",this.projMatrix),this.gl.drawArrays(this.gl.LINES,0,this.gridBuffers.length)}drawInvisibleBlocks(i){this.useInvisibleBlockBuffer&&(this.setShader(this.gridShaderProgram),this.setVertexAttr("vertPos",3,this.invisibleBlockBuffers.position),this.setVertexAttr("vertColor",3,this.invisibleBlockBuffers.color),this.setUniform("mView",i),this.setUniform("mProj",this.projMatrix),this.gl.drawArrays(this.gl.LINES,0,this.invisibleBlockBuffers.length))}drawStructure(i){this.setShader(this.shaderProgram),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.atlasTexture),this.setUniform("mView",i),this.setUniform("mProj",this.projMatrix),this.chunks.forEach(t=>{t.forEach(n=>{n.forEach(s=>{s.buffer&&(this.setVertexAttr("vertPos",3,s.buffer.position),this.setVertexAttr("texCoord",2,s.buffer.texCoord),this.setVertexAttr("tintColor",3,s.buffer.tintColor),this.setVertexAttr("normal",3,s.buffer.normal),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,s.buffer.index),this.gl.drawElements(this.gl.TRIANGLES,s.buffer.length,this.gl.UNSIGNED_SHORT,0))})})})}drawColoredStructure(i){this.setShader(this.colorShaderProgram),this.setUniform("mView",i),this.setUniform("mProj",this.projMatrix),this.chunks.forEach(t=>{t.forEach(n=>{n.forEach(s=>{s.buffer&&(this.setVertexAttr("vertPos",3,s.buffer.position),this.setVertexAttr("blockPos",3,s.buffer.blockPos),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,s.buffer.index),this.gl.drawElements(this.gl.TRIANGLES,s.buffer.length,this.gl.UNSIGNED_SHORT,0))})})})}drawOutline(i,t){this.setShader(this.gridShaderProgram),this.setVertexAttr("vertPos",3,this.outlineBuffers.position),this.setVertexAttr("vertColor",3,this.outlineBuffers.color);const n=Oe();jo(n,i),ze(n,n,t),this.setUniform("mView",n),this.setUniform("mProj",this.projMatrix),this.gl.drawArrays(this.gl.LINES,0,this.outlineBuffers.length)}setViewport(i,t,n,s){this.gl.viewport(i,t,n,s),this.projMatrix=this.getPerspective()}setShader(i){this.gl.useProgram(i),this.activeShader=i}setVertexAttr(i,t,n){const s=this.gl.getAttribLocation(this.activeShader,i);this.gl.bindBuffer(this.gl.ARRAY_BUFFER,n),this.gl.vertexAttribPointer(s,t,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(s)}setUniform(i,t){const n=this.gl.getUniformLocation(this.activeShader,i);this.gl.uniformMatrix4fv(n,!1,t)}}/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function $n(e,i,t,n){return new(t||(t=Promise))(function(s,r){function a(l){try{c(n.next(l))}catch(h){r(h)}}function o(l){try{c(n.throw(l))}catch(h){r(h)}}function c(l){var h;l.done?s(l.value):(h=l.value,h instanceof t?h:new t(function(d){d(h)})).then(a,o)}c((n=n.apply(e,i||[])).next())})}class Tt{constructor(i,t){this.img=i,this.idMap=t,this.part=16/i.width}getTextureAtlas(){return this.img}getTextureUV(i){var t;return(t=this.idMap[i])!==null&&t!==void 0?t:[0,0,this.part,this.part]}static fromBlobs(i){return $n(this,void 0,void 0,function*(){const t=Math.sqrt(Object.keys(i).length+1),n=Math.pow(2,Math.ceil(Math.log(t)/Math.log(2))),s=16*n,r=1/n,a=document.createElement("canvas");a.width=s,a.height=s;const o=a.getContext("2d");this.drawInvalidTexture(o);const c={};let l=1;return yield Promise.all(Object.keys(i).map(h=>$n(this,void 0,void 0,function*(){const d=l%n,u=Math.floor(l/n);l+=1,c[h]=[r*d,r*u,r*d+r,r*u+r];const f=yield createImageBitmap(i[h]);o.drawImage(f,0,0,16,16,16*d,16*u,16,16)}))),new Tt(o.getImageData(0,0,s,s),c)})}static empty(){const i=document.createElement("canvas");i.width=16,i.height=16;const t=i.getContext("2d");return Tt.drawInvalidTexture(t),new Tt(t.getImageData(0,0,16,16),{})}static drawInvalidTexture(i){i.fillStyle="black",i.fillRect(0,0,16,16),i.fillStyle="magenta",i.fillRect(0,0,8,8),i.fillRect(8,8,8,8)}}var dt,Pi,U,De,Di,k,Ci,tt,Oi,Mi,mi,Xn,wi;(function(e){function i(l,h){return typeof l=="number"?new t(l,h!=null?h:l):l}e.target=function(l,h,d,u,f,g){return new s(l,h,d,u,f,g)},e.parameters=function(l,h,d,u,f,g,v){return new n(i(l),i(h),i(d),i(u),i(f),i(g),v)},e.param=i;class t{constructor(h,d){this.min=h,this.max=d}distance(h){const d=(typeof h=="number"?h:h.min)-this.max,u=this.min-(typeof h=="number"?h:h.max);return d>0?d:Math.max(u,0)}union(h){return new t(Math.min(this.min,h.min),Math.max(this.max,h.max))}static fromJson(h){var d;if(typeof h=="number")return new t(h,h);const[u,f]=(d=w.readArray(h,g=>w.readNumber(g)))!==null&&d!==void 0?d:[];return new t(u!=null?u:0,f!=null?f:0)}}e.Param=t;class n{constructor(h,d,u,f,g,v,p){this.temperature=h,this.humidity=d,this.continentalness=u,this.erosion=f,this.depth=g,this.weirdness=v,this.offset=p}fittness(h){return oe(this.temperature.distance(h.temperature))+oe(this.humidity.distance(h.humidity))+oe(this.continentalness.distance(h.continentalness))+oe(this.erosion.distance(h.erosion))+oe(this.depth.distance(h.depth))+oe(this.weirdness.distance(h.weirdness))+oe(this.offset-h.offset)}space(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,new t(this.offset,this.offset)]}static fromJson(h){var d,u;const f=(d=w.readObject(h))!==null&&d!==void 0?d:{};return new n(t.fromJson(f.temperature),t.fromJson(f.humidity),t.fromJson(f.continentalness),t.fromJson(f.erosion),t.fromJson(f.depth),t.fromJson(f.weirdness),(u=w.readInt(f.offset))!==null&&u!==void 0?u:0)}}e.ParamPoint=n;class s{constructor(h,d,u,f,g,v){this.temperature=h,this.humidity=d,this.continentalness=u,this.erosion=f,this.depth=g,this.weirdness=v}get offset(){return 0}toArray(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,this.offset]}}e.TargetPoint=s,e.Parameters=class{constructor(l){this.things=l,this.index=new r(l)}find(l){return this.index.search(l,(h,d)=>h.distance(d))}};class r{constructor(h){this.root=r.build(h.map(([d,u])=>new c(d,u)))}static build(h){if(h.length===1)return h[0];if(h.length<=r.CHILDREN_PER_NODE){const g=h.map(v=>{let p=0;for(let m=0;m<7;m+=1){const S=v.space[m];p+=Math.abs((S.min+S.max)/2)}return{key:p,node:v}}).sort((v,p)=>v.key-p.key).map(({node:v})=>v);return new o(g)}let d=1/0,u=-1,f=[];for(let g=0;g<7;++g){h=r.sort(h,g,!1),f=r.bucketize(h);let v=0;for(const p of f)v+=r.area(p.space);d>v&&(d=v,u=g)}return h=r.sort(h,u,!1),f=r.bucketize(h),f=r.sort(f,u,!0),new o(f.map(g=>r.build(g.children)))}static sort(h,d,u){return h.map(f=>{const g=f.space[d],v=(g.min+g.max)/2;return{key:u?Math.abs(v):v,node:f}}).sort((f,g)=>f.key-g.key).map(({node:f})=>f)}static bucketize(h){const d=[];let u=[];const f=Math.pow(10,Math.floor(Math.log(h.length-.01)/Math.log(10)));for(const g of h)u.push(g),u.length<f||(d.push(new o(u)),u=[]);return u.length!==0&&d.push(new o(u)),d}static area(h){let d=0;for(const u of h)d+=Math.abs(u.max-u.min);return d}search(h,d){return this.root.search(h.toArray(),d).thing()}}r.CHILDREN_PER_NODE=10,e.RTree=r;class a{constructor(h){this.space=h}distance(h){let d=0;for(let u=0;u<7;u+=1)d+=oe(this.space[u].distance(h[u]));return d}}e.RNode=a;class o extends a{constructor(h){super(o.buildSpace(h)),this.children=h}static buildSpace(h){let d=[...Array(7)].map(()=>new t(1/0,-1/0));for(const u of h)d=[...Array(7)].map((f,g)=>d[g].union(u.space[g]));return d}search(h,d){let u=1/0,f=null;for(const g of this.children){const v=d(g,h);if(u<=v)continue;const p=g.search(h,d),m=g==p?v:d(p,h);u<=m||(u=m,f=p)}return f}}e.RSubTree=o;class c extends a{constructor(h,d){super(h.space()),this.thing=d}search(){return this}}e.RLeaf=c})(dt||(dt={}));class zs{constructor(i){this.biome=i}getBiome(){return this.biome}static fromJson(i){var t,n;const s=(t=w.readObject(i))!==null&&t!==void 0?t:{},r=(n=w.readString(s.biome))!==null&&n!==void 0?n:"minecraft:the_void";return new zs(r)}}class Us{constructor(i){this.parameters=i}getBiome(i,t,n,s){const r=s(i,t,n);return this.parameters.find(r)}static fromJson(i){var t,n;const s=(t=w.readObject(i))!==null&&t!==void 0?t:{},r=((n=w.readArray(s.biomes,a=>{var o;return(c=>{var l;return{biome:(l=w.readString(c.biome))!==null&&l!==void 0?l:"minecraft:the_void",parameters:dt.ParamPoint.fromJson(c.parameters)}})((o=w.readObject(a))!==null&&o!==void 0?o:{})}))!==null&&n!==void 0?n:[]).map(a=>[a.parameters,()=>a.biome]);return new Us(new dt.Parameters(r))}}class H{constructor(i,t,n){this.offsetSampler=i,this.factorSampler=t,this.jaggednessSampler=n}static extractor(i){return{apply:t=>t[i],toJson:()=>i}}static fromJson(i){var t;const n=(t=w.readObject(i))!==null&&t!==void 0?t:{};return new H(et.fromJson(n.offset,this.EXTRACTOR),et.fromJson(n.factor,this.EXTRACTOR),et.fromJson(n.jaggedness,this.EXTRACTOR))}toJson(){return{offset:this.offsetSampler.toJson(),factor:this.factorSampler.toJson(),jaggedness:this.jaggednessSampler.toJson()}}offset(i){return this.offsetSampler.apply(i)+H.GLOBAL_OFFSET}factor(i){return this.factorSampler.apply(i)}jaggedness(i){return this.jaggednessSampler.apply(i)}static point(i,t,n){return{continents:i,erosion:t,weirdness:n,ridges:this.peaksAndValleys(n)}}static peaksAndValleys(i){return 3*-(Math.abs(Math.abs(i)-.6666667)-.33333334)}static overworld(){const i=this.buildErosionOffsetSpline(-.05,0,0,.1,0,-.03,!1,!1),t=this.buildErosionOffsetSpline(-.1,.03,.1,.1,.01,-.03,!1,!1),n=this.buildErosionOffsetSpline(-.1,.03,.1,.7,.01,-.03,!0,!0),s=this.buildErosionOffsetSpline(.3,.03,.1,1,.01,.01,!0,!0),r=new G(this.CONTINENTS).addPoint(-1.1,.044).addPoint(-1.02,-.2222).addPoint(-.51,-.2222).addPoint(-.44,-.12).addPoint(-.18,-.12).addPoint(-.16,i).addPoint(-.15,i).addPoint(-.1,t).addPoint(.25,n).addPoint(1,s),a=new G(this.CONTINENTS).addPoint(-.19,3.95).addPoint(-.15,this.getErosionFactor(6.25,!0)).addPoint(-.1,this.getErosionFactor(5.47,!0)).addPoint(.03,this.getErosionFactor(5.08,!0)).addPoint(.06,this.getErosionFactor(4.69,!1)),o=new G(this.CONTINENTS).addPoint(.11,0).addPoint(.03,this.buildErosionJaggednessSpline(1,.5,0,0)).addPoint(.65,this.buildErosionJaggednessSpline(1,1,1,0));return new H(r,a,o)}static getErosionFactor(i,t){const n=new G(this.WEIRDNESS).addPoint(-.2,6.3).addPoint(.2,i),s=new G(this.EROSION).addPoint(-.6,n).addPoint(-.5,new G(this.WEIRDNESS).addPoint(-.05,6.3).addPoint(.05,2.67)).addPoint(-.35,n).addPoint(-.25,n).addPoint(-.1,new G(this.WEIRDNESS).addPoint(-.05,2.67).addPoint(.05,6.3)).addPoint(.03,n);if(t){const r=new G(this.WEIRDNESS).addPoint(0,i).addPoint(.1,.625),a=new G(this.RIDGES).addPoint(-.9,i).addPoint(-.69,r);s.addPoint(.35,i).addPoint(.45,a).addPoint(.55,a).addPoint(.62,i)}else{const r=new G(this.RIDGES).addPoint(-.7,n).addPoint(-.15,1.37),a=new G(this.RIDGES).addPoint(.45,n).addPoint(.7,1.56);s.addPoint(.05,a).addPoint(.4,a).addPoint(.45,r).addPoint(.55,r).addPoint(.58,i)}return s}static buildErosionOffsetSpline(i,t,n,s,r,a,o,c){const l=this.buildMountainRidgeSplineWithPoints($(s,.6,1.5),c),h=this.buildMountainRidgeSplineWithPoints($(s,.6,1),c),d=this.buildMountainRidgeSplineWithPoints(s,c),u=this.ridgeSpline(i-.15,.5*s,$(.5,.5,.5)*s,.5*s,.6*s,.5),f=this.ridgeSpline(i,r*s,t*s,.5*s,.6*s,.5),g=this.ridgeSpline(i,r,r,t,n,.5),v=this.ridgeSpline(i,r,r,t,n,.5),p=new G(this.RIDGES).addPoint(-1,i).addPoint(-.4,g).addPoint(0,n+.07),m=this.ridgeSpline(-.02,a,a,t,n,0),S=new G(this.EROSION).addPoint(-.85,l).addPoint(-.7,h).addPoint(-.4,d).addPoint(-.35,u).addPoint(-.1,f).addPoint(.2,g);return o&&S.addPoint(.4,v).addPoint(.45,p).addPoint(.55,p).addPoint(.58,v),S.addPoint(.7,m),S}static buildMountainRidgeSplineWithPoints(i,t){const n=new G(this.RIDGES),s=this.mountainContinentalness(-1,i,-.7),r=this.mountainContinentalness(1,i,-.7),a=this.calculateMountainRidgeZeroContinentalnessPoint(i);if(-.65<a&&a<1){const o=this.mountainContinentalness(-.65,i,-.7),c=this.mountainContinentalness(-.75,i,-.7),l=this.calculateSlope(s,c,-1,-.75);n.addPoint(-1,s,l),n.addPoint(-.75,c),n.addPoint(-.65,o);const h=this.mountainContinentalness(a,i,-.7),d=this.calculateSlope(h,r,a,1);n.addPoint(a-.01,h),n.addPoint(a,h,d),n.addPoint(1,r,d)}else{const o=this.calculateSlope(s,r,-1,1);t?(n.addPoint(-1,Math.max(.2,s)),n.addPoint(0,$(.5,s,r),o)):n.addPoint(-1,s,o),n.addPoint(1,r,o)}return n}static mountainContinentalness(i,t,n){const s=.46082947*(i+1.17)*(1-.5*(1-t))-.5*(1-t);return i<n?Math.max(s,-.2222):Math.max(s,0)}static calculateMountainRidgeZeroContinentalnessPoint(i){return .5*(1-i)/(.46082947*(1-.5*(1-i)))-1.17}static calculateSlope(i,t,n,s){return(t-i)/(s-n)}static ridgeSpline(i,t,n,s,r,a){const o=Math.max(.5*(t-i),a),c=5*(n-t);return new G(this.RIDGES).addPoint(-1,i,o).addPoint(-.4,t,Math.min(o,c)).addPoint(0,n,c).addPoint(.4,s,2*(s-n)).addPoint(1,r,.7*(r-s))}static buildErosionJaggednessSpline(i,t,n,s){const r=this.buildRidgeJaggednessSpline(i,n),a=this.buildRidgeJaggednessSpline(t,s);return new G(this.EROSION).addPoint(-1,r).addPoint(-.78,a).addPoint(-.5775,a).addPoint(-.375,0)}static buildRidgeJaggednessSpline(i,t){const n=H.peaksAndValleys(.4),s=(n+H.peaksAndValleys(.56666666))/2;return new G(this.RIDGES).addPoint(n,0).addPoint(s,t>0?this.buildWeirdnessJaggednessSpline(t):0).addPoint(1,i>0?this.buildWeirdnessJaggednessSpline(i):0)}static buildWeirdnessJaggednessSpline(i){return new G(H.WEIRDNESS).addPoint(-.01,.63*i).addPoint(.01,.3*i)}}H.GLOBAL_OFFSET=-.50375,H.EXTRACTOR=e=>{var i;const t=(i=w.readString(e))!==null&&i!==void 0?i:"continents";return H.extractor(t)},H.CONTINENTS=H.extractor("continents"),H.EROSION=H.extractor("erosion"),H.WEIRDNESS=H.extractor("weirdness"),H.RIDGES=H.extractor("ridges"),function(e){e.fromList=function(i){return(t,n,s,r)=>{for(const a of i){const o=a(t,n,s,r);if(o)return o}return null}}}(Pi||(Pi={})),function(e){function i(t){return t.ySize<<2}e.fromJson=function(t){var n,s,r,a,o,c,l,h;const d=(n=w.readObject(t))!==null&&n!==void 0?n:{};return{minY:(s=w.readInt(d.min_y))!==null&&s!==void 0?s:0,height:(r=w.readInt(d.height))!==null&&r!==void 0?r:256,xzSize:(a=w.readInt(d.size_horizontal))!==null&&a!==void 0?a:1,ySize:(o=w.readInt(d.size_vertical))!==null&&o!==void 0?o:1,sampling:Ri.fromJson(d.sampling),topSlide:De.fromJson(d.top_slide),bottomSlide:De.fromJson(d.bottom_slide),terrainShaper:H.fromJson(d.terrain_shaper),islandNoiseOverride:(c=w.readBoolean(d.island_noise_override))!==null&&c!==void 0&&c,isAmplified:(l=w.readBoolean(d.amplified))!==null&&l!==void 0&&l,hasLargeBiomes:(h=w.readBoolean(d.large_biomes))!==null&&h!==void 0&&h}},e.cellHeight=i,e.cellWidth=function(t){return t.xzSize<<2},e.cellCountY=function(t){return t.height/i(t)},e.minCellY=function(t){return Math.floor(t.minY/i(t))}}(U||(U={})),function(e){e.fromJson=function(i){var t,n,s,r;const a=(t=w.readObject(i))!==null&&t!==void 0?t:{};return{target:(n=w.readNumber(a.target))!==null&&n!==void 0?n:0,size:(s=w.readInt(a.size))!==null&&s!==void 0?s:0,offset:(r=w.readInt(a.offset))!==null&&r!==void 0?r:0}},e.apply=function(i,t,n){if(i.size<=0)return t;const s=(n-i.offset)/i.size;return ft(i.target,t,s)}}(De||(De={}));class Ot{constructor(i,t){this.chunk=i,this.filler=t,this.noise000=0,this.noise001=0,this.noise100=0,this.noise101=0,this.noise010=0,this.noise011=0,this.noise110=0,this.noise111=0,this.valueXZ00=0,this.valueXZ10=0,this.valueXZ01=0,this.valueXZ11=0,this.valueZ0=0,this.valueZ1=0,this.value=0,this.slice0=Ot.allocateSlice(i.cellCountY,i.cellCountXZ),this.slice1=Ot.allocateSlice(i.cellCountY,i.cellCountXZ)}static allocateSlice(i,t){const n=Array(t+1);for(let s=0;s<t+1;s+=1)n[s]=Array(i+1);return n}initializeForFirstCellX(){this.fillSlice(this.slice0,this.chunk.firstCellX)}advanceCellX(i){this.fillSlice(this.slice1,this.chunk.firstCellX+i+1)}fillSlice(i,t){const n=U.cellWidth(this.chunk.settings.noise),s=U.cellHeight(this.chunk.settings.noise),r=t*n;for(let a=0;a<this.chunk.cellCountXZ+1;a+=1){const o=(this.chunk.firstCellZ+a)*n;for(let c=0;c<this.chunk.cellCountY+1;c+=1){const l=(this.chunk.cellCountNoiseMinY+c)*s;i[a][c]=this.filler(r,l,o)}}}selectCellYZ(i,t){this.noise000=this.slice0[t][i],this.noise001=this.slice0[t+1][i],this.noise100=this.slice1[t][i],this.noise101=this.slice1[t+1][i],this.noise010=this.slice0[t][i+1],this.noise011=this.slice0[t+1][i+1],this.noise110=this.slice1[t][i+1],this.noise111=this.slice1[t+1][i+1]}updateForY(i){this.valueXZ00=$(i,this.noise000,this.noise010),this.valueXZ10=$(i,this.noise100,this.noise110),this.valueXZ01=$(i,this.noise001,this.noise011),this.valueXZ11=$(i,this.noise101,this.noise111)}updateForX(i){this.valueZ0=$(i,this.valueXZ00,this.valueXZ10),this.valueZ1=$(i,this.valueXZ01,this.valueXZ11)}updateForZ(i){this.value=$(i,this.valueZ0,this.valueZ1)}sample(){return this.value}swapSlices(){[this.slice0,this.slice1]=[this.slice1,this.slice0]}}class ml{constructor(i,t,n,s,r,a,o,c){this.cellCountXZ=i,this.cellCountY=t,this.cellCountNoiseMinY=n,this.sampler=s,this.settings=c;const l=U.cellWidth(c.noise);this.firstCellX=Math.floor(r/l),this.firstCellZ=Math.floor(a/l),this.firstNoiseX=r>>2,this.firstNoiseZ=a>>2,this.interpolators=[];const h=i*l>>2;this.noiseData=Array(h+1);for(let d=0;d<=h;d+=1){const u=this.firstNoiseX+d;this.noiseData[d]=Array(h+1);for(let f=0;f<=h;f+=1){const g=this.firstNoiseZ+f;this.noiseData[d][f]=s.noiseData(u,g)}}this.preliminarySurfaceLevel=new Map,this.baseNoise=s.makeBaseNoiseFiller(this,o,c.noodleCavesEnabled)}getNoiseData(i,t){return this.noiseData[i-this.firstNoiseX][t-this.firstNoiseZ]}getPreliminarySurfaceLevel(i,t){return Xi(this.preliminarySurfaceLevel,re.asLong(i,t),()=>{const n=i-this.firstNoiseX,s=t-this.firstNoiseZ,r=this.noiseData.length,a=n>=0&&s>=0&&n<r&&s<r?this.noiseData[n][s].terrainInfo:this.sampler.noiseData(i,t).terrainInfo;return this.sampler.getPreliminarySurfaceLevel(i<<2,t<<2,a)})}createNoiseInterpolator(i){const t=new Ot(this,i);return this.interpolators.push(t),t.sample.bind(t)}initializeForFirstCellX(){this.interpolators.forEach(i=>i.initializeForFirstCellX())}advanceCellX(i){this.interpolators.forEach(t=>t.advanceCellX(i))}selectCellYZ(i,t){this.interpolators.forEach(n=>n.selectCellYZ(i,t))}updateForY(i){this.interpolators.forEach(t=>t.updateForY(i))}updateForX(i){this.interpolators.forEach(t=>t.updateForX(i))}updateForZ(i){this.interpolators.forEach(t=>t.updateForZ(i))}swapSlices(){this.interpolators.forEach(i=>i.swapSlices())}updateNoiseAndGenerateBaseState(i,t,n){return this.baseNoise(i,t,n)}}(function(e){e.create=function(i,t,n){return{offset:i,factor:t,jaggedness:n}}})(Di||(Di={})),function(e){const i=new Map;function t(n,s,r){const a=Object.assign({name:`minecraft:${n}`},Le.create(s,r));return i.set(n,a),a}e.TEMPERATURE=t("temperature",-10,[1.5,0,1,0,0,0]),e.VEGETATION=t("vegetation",-8,[1,1,0,0,0,0]),e.CONTINENTALNESS=t("continentalness",-9,[1,1,2,2,2,1,1,1,1]),e.EROSION=t("erosion",-9,[1,1,0,1,1]),e.TEMPERATURE_LARGE=t("temperature_large",-12,[1.5,0,1,0,0,0]),e.VEGETATION_LARGE=t("vegetation_large",-10,[1,1,0,0,0,0]),e.CONTINENTALNESS_LARGE=t("continentalness_large",-11,[1,1,2,2,2,1,1,1,1]),e.EROSION_LARGE=t("erosion_large",-11,[1,1,0,1,1]),e.RIDGE=t("ridge",-7,[1,2,1,0,0,0]),e.SHIFT=t("offset",-3,[1,1,1,0]),e.PILLAR=t("pillar",-7,[1,1]),e.PILLAR_RARENESS=t("pillar_rareness",-8,[1]),e.PILLAR_THICKNESS=t("pillar_thickness",-8,[1]),e.SPAGHETTI_2D=t("spaghetti_2d",-8,[1]),e.SPAGHETTI_2D_ELEVATION=t("spaghetti_2d_elevation",-8,[1]),e.SPAGHETTI_2D_MODULATOR=t("spaghetti_2d_modulator",-8,[1]),e.SPAGHETTI_2D_THICKNESS=t("spaghetti_2d_thickness",-8,[1]),e.SPAGHETTI_3D_1=t("spaghetti_3d_1",-8,[1]),e.SPAGHETTI_3D_2=t("spaghetti_3d_2",-8,[1]),e.SPAGHETTI_3D_RARITY=t("spaghetti_3d_rarity",-8,[1]),e.SPAGHETTI_3D_THICKNESS=t("spaghetti_3d_thickness",-8,[1]),e.SPAGHETTI_ROUGHNESS=t("spaghetti_roughness",-8,[1]),e.SPAGHETTI_ROUGHNESS_MODULATOR=t("spaghetti_roughness_modulator",-8,[1]),e.CAVE_ENTRANCE=t("cave_entrance",-7,[.4,.5,1]),e.CAVE_LAYER=t("cave_layer",-8,[1]),e.CAVE_CHEESE=t("cave_cheese",-8,[.5,1,2,1,2,1,0,2,0]),e.NOODLE=t("noodle",-8,[1]),e.NOODLE_THICKNESS=t("noodle_thickness",-8,[1]),e.NOODLE_RIDGE_A=t("noodle_ridge_a",-7,[1]),e.NOODLE_RIDGE_B=t("noodle_ridge_b",-7,[1]),e.JAGGED=t("jagged",-16,[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]),e.SURFACE=t("surface",-6,[1,1,1]),e.SURFACE_SECONDARY=t("surface_secondary",-6,[1,1,0,1]),e.instantiate=function(n,s){return new ce(n.fromHashOf(s.name),s)}}(k||(k={}));class wl{constructor(i,t,n,s=!1){this.settings=i,this.isNoiseCavesEnabled=t;const r=i.hasLargeBiomes,a=(s?new z(n):P.create(n)).forkPositional();s?(this.blendedNoise=new Un(new z(n),i.sampling,U.cellWidth(i),U.cellHeight(i)),this.temperatureNoise=new ce(new z(n),Le.create(-7,[1,1])),this.humidityNoise=new ce(new z(n+BigInt(1)),Le.create(-7,[1,1])),this.offsetNoise=new ce(new z(n+BigInt(5)),Le.create(0,[0]))):(this.blendedNoise=new Un(a.fromHashOf("minecraft:terrain"),i.sampling,U.cellWidth(i),U.cellHeight(i)),this.temperatureNoise=k.instantiate(a,r?k.TEMPERATURE_LARGE:k.TEMPERATURE),this.humidityNoise=k.instantiate(a,r?k.VEGETATION_LARGE:k.VEGETATION),this.offsetNoise=k.instantiate(a,k.SHIFT)),this.continentalnessNoise=k.instantiate(a,r?k.CONTINENTALNESS_LARGE:k.CONTINENTALNESS),this.erosionNoise=k.instantiate(a,r?k.EROSION_LARGE:k.EROSION),this.weirdnessNoise=k.instantiate(a,k.RIDGE),this.pillarNoise=k.instantiate(a,k.PILLAR),this.pillarRarenessModulator=k.instantiate(a,k.PILLAR_RARENESS),this.pillarThicknessModulator=k.instantiate(a,k.PILLAR_THICKNESS),this.spaghetti2DNoise=k.instantiate(a,k.SPAGHETTI_2D),this.spaghetti2DElevationModulator=k.instantiate(a,k.SPAGHETTI_2D_ELEVATION),this.spaghetti2DRarityModulator=k.instantiate(a,k.SPAGHETTI_2D_MODULATOR),this.spaghetti2DThicknessModulator=k.instantiate(a,k.SPAGHETTI_2D_THICKNESS),this.spaghetti3DNoise1=k.instantiate(a,k.SPAGHETTI_3D_1),this.spaghetti3DNoise2=k.instantiate(a,k.SPAGHETTI_3D_2),this.spaghetti3DRarityModulator=k.instantiate(a,k.SPAGHETTI_3D_RARITY),this.spaghetti3DThicknessModulator=k.instantiate(a,k.SPAGHETTI_3D_THICKNESS),this.spaghettiRoughnessNoise=k.instantiate(a,k.SPAGHETTI_ROUGHNESS),this.spaghettiRoughnessModulator=k.instantiate(a,k.SPAGHETTI_ROUGHNESS_MODULATOR),this.bigEntranceNoise=k.instantiate(a,k.CAVE_ENTRANCE),this.layerNoise=k.instantiate(a,k.CAVE_LAYER),this.cheeseNoise=k.instantiate(a,k.CAVE_CHEESE);const o=i.minY+4,c=o+i.height;this.noodleToggleNoise=this.yLimitedInterpolatable(k.instantiate(a,k.NOODLE),o,c,-1,1),this.noodleThicknessNoise=this.yLimitedInterpolatable(k.instantiate(a,k.NOODLE_THICKNESS),o,c,0,1),this.noodleRidgeANoise=this.yLimitedInterpolatable(k.instantiate(a,k.NOODLE_RIDGE_A),o,c,0,8/3),this.noodleRidgeBNoise=this.yLimitedInterpolatable(k.instantiate(a,k.NOODLE_RIDGE_B),o,c,0,8/3),this.jaggedNoise=k.instantiate(a,k.JAGGED),this.shaper=i.terrainShaper,this.baseNoise=l=>l.createNoiseInterpolator((h,d,u)=>this.calculateBlendedBaseNoise(h,d,u,l.getNoiseData(h>>2,u>>2).terrainInfo))}yLimitedInterpolatable(i,t,n,s,r){const a=(o,c,l)=>c>n||c<t?s:i.sample(o*r,c*r,l*r);return o=>o.createNoiseInterpolator(a)}noiseData(i,t){const n=i+this.getOffset(i,0,t),s=t+this.getOffset(t,i,0),r=this.getContinentalness(n,s),a=this.getErosion(n,s),o=this.getWeirdness(n,s),c=this.terrainInfo(r,a,o);return Ci.create(n,s,r,a,o,c)}sample(i,t,n){return this.target(i,t,n,this.noiseData(i,n))}target(i,t,n,s){const r=s.shiftedX,a=t+this.getOffset(t,n,i),o=s.shiftedZ,c=this.getTemperature(r,a,o),l=this.getHumidity(r,a,o),h=this.computeDimensionDensity(t<<2,s.terrainInfo);return dt.target(c,l,s.continentalness,s.erosion,h,s.weirdness)}terrainInfo(i,t,n){const s=H.point(i,t,n),r=this.shaper.offset(s),a=this.shaper.factor(s),o=this.shaper.jaggedness(s);return Di.create(r,a,o)}getOffset(i,t,n){return 4*this.offsetNoise.sample(i,t,n)}getTemperature(i,t,n){return this.temperatureNoise.sample(i,t,n)}getHumidity(i,t,n){return this.humidityNoise.sample(i,t,n)}getContinentalness(i,t){return this.continentalnessNoise.sample(i,0,t)}getErosion(i,t){return this.erosionNoise.sample(i,0,t)}getWeirdness(i,t){return this.weirdnessNoise.sample(i,0,t)}makeBaseNoiseFiller(i,t,n){const s=this.baseNoise(i),r=n?this.noodleToggleNoise(i):()=>-1,a=n?this.noodleThicknessNoise(i):()=>0,o=n?this.noodleRidgeANoise(i):()=>0,c=n?this.noodleRidgeBNoise(i):()=>0;return(l,h,d)=>{let u=s();if(u=ue(.64*u,-1,1),u=u/2-u*u*u/24,r()>=0){const f=ll(a(),-1,1,.05,.1),g=Math.abs(1.5*o())-f,v=Math.abs(1.5*c())-f;u=Math.min(u,Math.max(g,v))}return u+=t(l,h,d),u>0?null:V.AIR}}calculateBlendedBaseNoise(i,t,n,s){const r=this.blendedNoise.sample(i,t,n);return this.calculateBaseNoise(i,t,n,s,r,!this.isNoiseCavesEnabled,!0)}calculateBaseNoise(i,t,n,s,r,a,o){if(!this.settings.islandNoiseOverride){const h=o?this.sampleJaggedNoise(s.jaggedness,i,n):0,d=this.computeDimensionDensity(t,s),u=s.factor*(h+d);r+=u>0?4*u:u}let c=-64,l=64;if(!a&&r>=-64){const h=r-1.5625,d=this.getBigEntrances(i,t,n),u=this.getSpaghettiRoughness(i,t,n),f=this.getSpaghetti3D(i,t,n),g=Math.min(d,f+u);if(h<0)l=g;else{const v=this.getLayerizedCaverns(i,t,n);v>64?r=64:r=this.getCheese(i,t,n)+v+ft(.5,0,1.28*h);const p=this.getSpaghetti2D(i,t,n);c=this.getPillars(i,t,n),l=Math.min(g,p+u)}}return r=ue(r,c,l),r=ue(r=this.applySlide(r,t/U.cellHeight(this.settings)),-64,64)}sampleJaggedNoise(i,t,n){if(i===0)return 0;const s=this.jaggedNoise.sample(1500*t,0,1500*n);return s>0?i*s:i/2*s}computeDimensionDensity(i,t){return 1-i/128+t.offset}getBigEntrances(i,t,n){return this.bigEntranceNoise.sample(.75*i,.5*t,.75*n)+.37+ft(.3,0,(t+10)/40)}getSpaghettiRoughness(i,t,n){const s=this.spaghettiRoughnessNoise.sample(i,t,n),r=ge(this.spaghettiRoughnessModulator.sample(i,t,n),-1,1,0,1);return(.4-Math.abs(s))*r}getSpaghetti2D(i,t,n){const s=this.quantizeSpaghettiRarity2D(this.spaghetti2DRarityModulator.sample(2*i,t,2*n)),r=ge(this.spaghetti2DThicknessModulator.sample(2*i,t,2*n),-1,1,.6,1.3),a=this.sampleWithRarity(this.spaghetti2DNoise,i,t,n,s),o=Math.abs(s*a)-.083*r,c=U.minCellY(this.settings),l=ge(this.spaghetti2DElevationModulator.sample(i,0,n),-1,1,c,8),h=Math.abs(l-t/8)-1*r;return ue(Math.max(h,o),-1,1)}getSpaghetti3D(i,t,n){const s=this.quantizeSpaghettiRarity3D(this.spaghetti3DRarityModulator.sample(2*i,t,2*n)),r=ge(this.spaghetti3DThicknessModulator.sample(i,t,n),-1,1,.065,.088),a=this.sampleWithRarity(this.spaghetti3DNoise1,i,t,n,s),o=Math.abs(s*a)-r,c=this.sampleWithRarity(this.spaghetti3DNoise2,i,t,n,s),l=Math.abs(s*c)-r;return ue(Math.max(o,l),-1,1)}quantizeSpaghettiRarity2D(i){return i<-.75?.5:i<-.5?.75:i<.5?1:i<.75?2:3}quantizeSpaghettiRarity3D(i){return i<-.5?.75:i<0?1:i<.5?1.5:2}sampleWithRarity(i,t,n,s,r){return i.sample(t/r,n/r,s/r)}getLayerizedCaverns(i,t,n){return 4*oe(this.layerNoise.sample(i,8*t,n))}getCheese(i,t,n){return ue(this.cheeseNoise.sample(i,t/1.5,n)+.27,-1,1)}getPillars(i,t,n){const s=ge(this.pillarRarenessModulator.sample(i,t,n),-1,1,0,2),r=ge(this.pillarThicknessModulator.sample(i,t,n),-1,1,0,1.1),a=this.pillarNoise.sample(25*i,.3*t,25*n),o=Math.pow(r,3)*(2*a-s);return o<=.03?Number.MIN_SAFE_INTEGER:o}applySlide(i,t){const n=t-U.minCellY(this.settings);return i=De.apply(this.settings.topSlide,i,U.cellCountY(this.settings)-n),i=De.apply(this.settings.bottomSlide,i,n)}getPreliminarySurfaceLevel(i,t,n){const s=U.minCellY(this.settings)+U.cellCountY(this.settings),r=U.minCellY(this.settings),a=U.cellHeight(this.settings);for(let o=s;o>=r;o-=1){const c=o*a;if(this.calculateBaseNoise(i,c,t,n,-.703125,!0,!1)>=.390625)return c}return Number.MAX_SAFE_INTEGER}}(function(e){e.create=function(i,t,n,s,r,a){return{shiftedX:i,shiftedZ:t,continentalness:n,weirdness:s,erosion:r,terrainInfo:a}}})(Ci||(Ci={})),function(e){e.fromJson=function(i){var t,n,s,r;const a=(t=w.readObject(i))!==null&&t!==void 0?t:{};return a.absolute!==void 0?(o=(n=w.readNumber(a.absolute))!==null&&n!==void 0?n:0,()=>o):a.above_bottom!==void 0?function(c){return l=>l.minY+c}((s=w.readNumber(a.above_bottom))!==null&&s!==void 0?s:0):a.below_top!==void 0?function(c){return l=>l.maxY-c}((r=w.readNumber(a.below_top))!==null&&r!==void 0?r:0):()=>0;var o}}(tt||(tt={})),function(e){e.create=function(i,t){return{minY:i,height:t,maxY:i+t-1}}}(Oi||(Oi={}));class xl{constructor(i,t,n){this.rule=i,this.defaultBlock=t,this.random=P.create(n).forkPositional(),this.surfaceNoise=k.instantiate(this.random,k.SURFACE),this.surfaceSecondaryNoise=k.instantiate(this.random,k.SURFACE_SECONDARY),this.positionalRandoms=new Map}buildSurface(i,t,n,s){const r=re.minBlockX(i.pos),a=re.minBlockZ(i.pos),o=new El(this,i,t,n,s),c=this.rule(o);for(let l=0;l<16;l+=1){const h=r+l;for(let d=0;d<1;d+=1){const u=a+d;o.updateXZ(h,u);let f=0,g=Number.MIN_SAFE_INTEGER,v=Number.MAX_SAFE_INTEGER;for(let p=i.maxY;p>=i.minY;p-=1){const m=Ue.create(h,p,u),S=i.getBlockState(m);if(S.equals(V.AIR)){f=0,g=Number.MIN_SAFE_INTEGER;continue}if(S.isFluid()){g===Number.MIN_SAFE_INTEGER&&(g=p+1);continue}if(v>=p){v=Number.MIN_SAFE_INTEGER;for(let b=p-1;b>=i.minY;b-=1){const I=i.getBlockState(Ue.create(h,b,u));if(I.equals(V.AIR)||I.isFluid()){v=b+1;break}}}f+=1;const E=p-v+1;if(!S.equals(this.defaultBlock))continue;o.updateY(f,E,g,p);const _=c(h,p,u);_&&i.setBlockState(m,_)}}}}getSurfaceDepth(i,t){return 2.75*this.surfaceNoise.sample(i,0,t)+3+.25*this.random.at(i,0,t).nextDouble()}getSurfaceSecondary(i,t){return this.surfaceSecondaryNoise.sample(i,0,t)}getRandom(i){return Xi(this.positionalRandoms,i,()=>this.random.fromHashOf(i))}}class El{constructor(i,t,n,s,r){this.system=i,this.chunk=t,this.noiseChunk=n,this.context=s,this.getBiome=r,this.blockX=0,this.blockY=0,this.blockZ=0,this.stoneDepthAbove=0,this.stoneDepthBelow=0,this.surfaceDepth=0,this.waterHeight=0,this.biome=()=>"",this.surfaceSecondary=()=>0,this.minSurfaceLevel=()=>0}updateXZ(i,t){this.blockX=i,this.blockZ=t,this.surfaceDepth=this.system.getSurfaceDepth(i,t),this.surfaceSecondary=_i(()=>this.system.getSurfaceSecondary(i,t)),this.minSurfaceLevel=_i(()=>this.calculateMinSurfaceLevel(i,t))}updateY(i,t,n,s){this.blockY=s,this.stoneDepthAbove=i,this.stoneDepthBelow=t,this.waterHeight=n,this.biome=_i(()=>this.getBiome(Ue.create(this.blockX,this.blockY,this.blockZ)))}calculateMinSurfaceLevel(i,t){const n=i>>4,s=t>>4,r=this.noiseChunk.getPreliminarySurfaceLevel(n<<4,s<<4),a=this.noiseChunk.getPreliminarySurfaceLevel(n+1<<4,s<<4),o=this.noiseChunk.getPreliminarySurfaceLevel(n<<4,s+1<<4),c=this.noiseChunk.getPreliminarySurfaceLevel(n+1<<4,s+1<<4);return Math.floor(Ni((15&i)/16,(15&t)/16,r,a,o,c))+this.surfaceDepth-8}}(function(e){function i(s){return()=>()=>s}function t(s){return r=>{const a=s.map(o=>o(r));return(o,c,l)=>{for(const h of a){const d=h(o,c,l);if(d)return d}}}}function n(s,r){return a=>(o,c,l)=>{if(s(a))return r(a)(o,c,l)}}e.NOOP=()=>()=>{},e.fromJson=function(s){var r,a,o;const c=(r=w.readObject(s))!==null&&r!==void 0?r:{};switch((a=w.readString(c.type))===null||a===void 0?void 0:a.replace(/^minecraft:/,"")){case"block":return i(V.fromJson(c.result_state));case"sequence":return t((o=w.readArray(c.sequence,e.fromJson))!==null&&o!==void 0?o:[]);case"condition":return n(mi.fromJson(c.if_true),e.fromJson(c.then_run))}return e.NOOP},e.block=i,e.sequence=t,e.condition=n})(Mi||(Mi={})),function(e){function i(){return c=>c.blockY>=c.minSurfaceLevel()}function t(c){const l=new Set(c);return h=>l.has(h.biome())}function n(c){return l=>!c(l)}function s(c,l,h,d){return u=>{const f=d?u.stoneDepthBelow:u.stoneDepthAbove,g=l?u.surfaceDepth:0,v=h===0?0:ge(u.surfaceSecondary(),-1,1,0,h);return f<=1+c+g+v}}function r(c,l,h){return d=>{const u=l(d.context),f=h(d.context);if(d.blockY<=u)return!0;if(d.blockY>=f)return!1;const g=d.system.getRandom(c),v=ge(d.blockY,u,f,1,0);return g.nextFloat()<v}}function a(c,l,h){return d=>{if(d.waterHeight===Number.MIN_SAFE_INTEGER)return!0;const u=h?d.stoneDepthAbove:0;return d.blockY+u>=d.waterHeight+c+d.surfaceDepth*l}}function o(c,l,h){return d=>{const u=h?d.stoneDepthAbove:0;return d.blockY+u>=c(d.context)+d.surfaceDepth*l}}e.FALSE=()=>!1,e.TRUE=()=>!0,e.fromJson=function(c){var l,h,d,u,f,g,v,p,m,S,E,_;const b=(l=w.readObject(c))!==null&&l!==void 0?l:{};switch((h=w.readString(b.type))===null||h===void 0?void 0:h.replace(/^minecraft:/,"")){case"above_preliminary_surface":return I=>I.blockY>=I.minSurfaceLevel();case"biome":return t((d=w.readArray(b.biome_is,I=>{var x;return(x=w.readString(I))!==null&&x!==void 0?x:""}))!==null&&d!==void 0?d:[]);case"not":return n(e.fromJson(b.invert));case"stone_depth":return s((u=w.readInt(b.offset))!==null&&u!==void 0?u:0,(f=w.readBoolean(b.add_surface_depth))!==null&&f!==void 0&&f,(g=w.readInt(b.secondary_depth_range))!==null&&g!==void 0?g:0,w.readString(b.surface_type)==="ceiling");case"vertical_gradient":return r((v=w.readString(b.random_name))!==null&&v!==void 0?v:"",tt.fromJson(b.true_at_and_below),tt.fromJson(b.false_at_and_above));case"water":return a((p=w.readInt(b.offset))!==null&&p!==void 0?p:0,(m=w.readInt(b.surface_depth_multiplier))!==null&&m!==void 0?m:0,(S=w.readBoolean(b.add_surface_depth))!==null&&S!==void 0&&S);case"y_above":return o(tt.fromJson(b.anchor),(E=w.readInt(b.surface_depth_multiplier))!==null&&E!==void 0?E:0,(_=w.readBoolean(b.add_surface_depth))!==null&&_!==void 0&&_)}return e.FALSE},e.abovePreliminarySurface=i,e.biome=t,e.not=n,e.stoneDepth=s,e.verticalGradient=r,e.water=a,e.yAbove=o}(mi||(mi={}));class Pl{constructor(i,t,n){this.biomeSource=t,this.settings=n,this.sampler=new wl(n.noise,n.noiseCavesEnabled,i,n.legacyRandomSource),this.noiseChunkCache=new Map,this.materialRule=Pi.fromList([(s,r,a,o)=>s.updateNoiseAndGenerateBaseState(r,a,o)]),this.surfaceSystem=new xl(n.surfaceRule,n.defaultBlock,i)}fill(i){var t;const n=Math.max(i.minY,this.settings.noise.minY),s=Math.min(i.maxY,this.settings.noise.minY+this.settings.noise.height),r=U.cellWidth(this.settings.noise),a=U.cellHeight(this.settings.noise),o=Math.floor(16/r),c=Math.floor(n/a),l=Math.floor((s-n)/a),h=re.minBlockX(i.pos),d=re.minBlockZ(i.pos),u=this.getNoiseChunk(i);u.initializeForFirstCellX();for(let f=0;f<o;f+=1){u.advanceCellX(f);for(let g=0;g<o;g+=1){let v=i.getOrCreateSection(i.sectionsCount-1);for(let p=l-1;p>=0;p-=1){u.selectCellYZ(p,g);for(let m=a-1;m>=0;m-=1){const S=(c+p)*a+m,E=15&S,_=i.getSectionIndex(S);i.getSectionIndex(v.minBlockY)!==_&&(v=i.getOrCreateSection(_));const b=m/a;u.updateForY(b);for(let I=0;I<r;I+=1){const x=h+f*r+I,R=15&x,N=I/r;u.updateForX(N);for(let y=0;y<r;y+=1){const A=d+g*r+y,M=15&A,D=y/r;u.updateForZ(D);let B=(t=this.materialRule(u,x,S,A))!==null&&t!==void 0?t:this.settings.defaultBlock;if(B.equals(V.AIR)){if(!(S<this.settings.seaLevel))continue;B=this.settings.defaultFluid}v.setBlockState(R,E,M,B)}}}}}u.swapSlices()}}buildSurface(i,t="minecraft:plains"){const n=this.getNoiseChunk(i),s=Oi.create(this.settings.noise.minY,this.settings.noise.height);this.surfaceSystem.buildSurface(i,n,s,()=>t)}getNoiseChunk(i){return Xi(this.noiseChunkCache,re.toLong(i.pos),()=>{const t=Math.max(i.minY,this.settings.noise.minY),n=Math.min(i.maxY,this.settings.noise.minY+this.settings.noise.height),s=U.cellWidth(this.settings.noise),r=U.cellHeight(this.settings.noise),a=Math.floor(16/s),o=Math.floor(t/r),c=Math.floor((n-t)/r),l=re.minBlockX(i.pos),h=re.minBlockZ(i.pos);return new ml(a,c,o,this.sampler,l,h,()=>0,this.settings)})}}(function(e){e.fromJson=function(i){var t,n,s,r,a,o,c,l,h,d,u;const f=(t=w.readObject(i))!==null&&t!==void 0?t:{};return{structures:wi.fromJson(f.structures),surfaceRule:Mi.fromJson(f.surface_rule),noise:U.fromJson(f.noise),defaultBlock:V.fromJson(f.default_block),defaultFluid:V.fromJson(f.default_fluid),bedrockRoofPosition:(n=w.readInt(f.bedrock_roof_position))!==null&&n!==void 0?n:0,bedrockFloorPosition:(s=w.readInt(f.bedrock_floor_position))!==null&&s!==void 0?s:0,seaLevel:(r=w.readInt(f.sea_level))!==null&&r!==void 0?r:0,disableMobGeneration:(a=w.readBoolean(f.disable_mob_generation))!==null&&a!==void 0&&a,aquifersEnabled:(o=w.readBoolean(f.aquifers_enabled))!==null&&o!==void 0&&o,noiseCavesEnabled:(c=w.readBoolean(f.noise_caves_enabled))!==null&&c!==void 0&&c,deepslateEnabled:(l=w.readBoolean(f.deepslate_enabled))!==null&&l!==void 0&&l,oreVeinsEnabled:(h=w.readBoolean(f.ore_veins_enabled))!==null&&h!==void 0&&h,noodleCavesEnabled:(d=w.readBoolean(f.noodle_caves_enabled))!==null&&d!==void 0&&d,legacyRandomSource:(u=w.readBoolean(f.legacy_random_source))!==null&&u!==void 0&&u}}})(Xn||(Xn={})),function(e){e.fromJson=function(i){var t;const n=(t=w.readObject(i))!==null&&t!==void 0?t:{};return{stronghold:w.compose(n.stronghold,w.readObject,s=>{var r,a,o;return{distance:(r=w.readInt(s.distance))!==null&&r!==void 0?r:0,spread:(a=w.readInt(s.spread))!==null&&a!==void 0?a:0,count:(o=w.readInt(s.count))!==null&&o!==void 0?o:0}}),structures:w.readMap(n.structures,s=>{var r;return(a=>{var o,c,l;return{spacing:(o=w.readInt(a.spacing))!==null&&o!==void 0?o:0,separation:(c=w.readInt(a.separation))!==null&&c!==void 0?c:0,salt:(l=w.readInt(a.salt))!==null&&l!==void 0?l:0}})((r=w.readObject(s))!==null&&r!==void 0?r:{})})}}}(wi||(wi={}));export{Un as BlendedNoise,Yn as BlockColors,ji as BlockDefinition,Ut as BlockModel,Ue as BlockPos,V as BlockState,Tl as Chunk,re as ChunkPos,pe as ChunkSection,dt as Climate,Fi as ConstantProvider,O as Direction,zs as FixedBiome,Ci as FlatNoiseData,zn as ImprovedNoise,w as Json,cl as LegacyPositionalRandom,z as LegacyRandom,Pi as MaterialRule,Us as MultiNoise,rl as NbtReader,al as NbtWriter,ml as NoiseChunk,Pl as NoiseChunkGenerator,Xn as NoiseGeneratorSettings,Ot as NoiseInterpolator,Le as NoiseParameters,wl as NoiseSampler,Ri as NoiseSamplingSettings,U as NoiseSettings,De as NoiseSlideSettings,k as Noises,ce as NormalNoise,et as NumberProvider,W as PerlinNoise,Fl as PerlinSimplexNoise,Z as SimplexNoise,G as Spline,Ds as Structure,Bl as StructureRenderer,wi as StructureSettings,mi as SurfaceCondition,El as SurfaceContext,Mi as SurfaceRule,xl as SurfaceSystem,Di as TerrainInfo,H as TerrainShaper,Tt as TextureAtlas,tt as VerticalAnchor,Oi as WorldgenContext,fl as XoroshiroPositionalRandom,P as XoroshiroRandom,hl as binarySearch,ue as clamp,ft as clampedLerp,ll as clampedMap,Xi as computeIfAbsent,St as getListTag,Ps as getOptional,Os as getSeed,Me as getTag,Cs as inverseLerp,_i as lazy,$ as lerp,Ni as lerp2,ol as lerp3,Ti as longfromBytes,ge as map,kl as read,Al as readChunk,Fs as readCompressed,yl as readRegion,Gi as readUncompressed,pi as smoothstep,oe as square,Ln as tagNames,Qe as tagTypes,Il as write,Nl as writeChunk,Ii as writeCompressed,Rl as writeRegion,$i as writeUncompressed};
//# sourceMappingURL=deepslate.esm.37434e44.js.map