(function(u,At){typeof exports=="object"&&typeof module<"u"?At(exports):typeof define=="function"&&define.amd?define(["exports"],At):(u=typeof globalThis<"u"?globalThis:u||self,At(u.deepslate={}))})(this,function(u){"use strict";var au=Object.defineProperty;var ou=(u,At,Se)=>At in u?au(u,At,{enumerable:!0,configurable:!0,writable:!0,value:Se}):u[At]=Se;var _=(u,At,Se)=>(ou(u,typeof At!="symbol"?At+"":At,Se),Se);function At(e){var t=e.slice(0,2);return t.length===2&&t[0]===31&&t[1]===139}function Se(e){const t=e.slice(0,2);return t.length===2&&t[0]===120&&(t[1]===1||t[1]===94||t[1]===156||t[2]===218)}function ra(e){const t=e.slice(0,8),n=new DataView(t.buffer,t.byteOffset),r=n.getUint32(0,!0),i=n.getUint32(4,!0);if(t.length===8&&r>0&&r<100&&i===e.byteLength-8)return r}function ia(e){var t=[],n,r;for(n=0;n>6),t.push(128|r&63)):r<65536?(t.push(224|r>>12),t.push(128|r>>6&63),t.push(128|r&63)):(t.push(240|r>>18&7),t.push(128|r>>12&63),t.push(128|r>>6&63),t.push(128|r&63));return t}function sa(e){var t=[],n;for(n=0;n=n)return;let r=this.buffer.byteLength;for(;rthis.buffer.byteLength&&s.fill(0,this.buffer.byteLength,this.offset),this.buffer=i,this.view=new DataView(i),this.array=s}writeNumber(t,n,r){this.accommodate(n),this.view[t](this.offset,r,this.littleEndian),this.offset+=n}writeBytes(t){this.accommodate(t.length),this.array.set(t,this.offset),this.offset+=t.length}writeString(t){const n=ia(t);this.writeShort(n.length),this.writeBytes(n)}getData(){return this.accommodate(0),this.array.slice(0,this.offset)}}u.Json=void 0,(e=>{function t(h){return typeof h=="number"?h:void 0}e.readNumber=t;function n(h){return typeof h=="number"?Math.floor(h):void 0}e.readInt=n;function r(h){return typeof h=="string"?h:void 0}e.readString=r;function i(h){return typeof h=="boolean"?h:void 0}e.readBoolean=i;function s(h){return typeof h=="object"&&h!==null&&!Array.isArray(h)?h:void 0}e.readObject=s;function a(h,d){if(!!Array.isArray(h))return d?h.map(f=>d(f)):h}e.readArray=a;function o(h,d){if(!!Array.isArray(h))return[0,1].map(f=>d(h[f]))}e.readPair=o;function g(h,d){var p;const f=(p=s(h))!=null?p:{};return Object.fromEntries(Object.entries(f).map(([v,m])=>[v,d(m)]))}e.readMap=g;function c(h,d,f){const p=d(h);return p?f(p):void 0}e.compose=c;function l(h,d){return typeof h!="string"?d[0]:d.includes(h)?h:d[0]}e.readEnum=l})(u.Json||(u.Json={})),u.Color=void 0,(e=>{function t(i){const s=u.Json.readNumber(i);if(s)return r(s);const a=u.Json.readArray(i,o=>{var g;return(g=u.Json.readNumber(o))!=null?g:0});if(!(a===void 0||a.length!==3))return a}e.fromJson=t;function n(i){if(i.isNumber())return r(i.getAsNumber());if(!i.isListOrArray())return;const s=i.getItems();if(!(s.length<3))return s.map(a=>a.getAsNumber())}e.fromNbt=n;function r(i){const s=i>>16&255,a=i>>8&255,o=i&255;return[s/255,a/255,o/255]}e.intToRgb=r})(u.Color||(u.Color={}));class St{constructor(t){_(this,"source");_(this,"cursor");this.source=t,this.cursor=0}get remainingLength(){return this.source.length-this.cursor}get totalLength(){return this.source.length}getRead(t=0){return this.source.substring(t,this.cursor)}getRemaining(){return this.source.substring(this.cursor)}canRead(t=1){return this.cursor+t<=this.source.length}peek(t=0){return this.source.charAt(this.cursor+t)}read(){return this.source.charAt(this.cursor++)}skip(){this.cursor+=1}skipWhitespace(){for(;this.canRead()&&St.isWhitespace(this.peek());)this.skip()}expect(t,n=!1){if(n&&this.skipWhitespace(),!this.canRead()||this.peek()!==t)throw this.createError(`Expected '${t}'`);this.skip()}readInt(){const t=this.cursor;for(;this.canRead()&&St.isAllowedInNumber(this.peek());)this.skip();const n=this.getRead(t);if(n.length===0)throw this.createError("Expected integer");try{const r=Number(n);if(isNaN(r)||!Number.isInteger(r))throw new Error;return r}catch{throw this.cursor=t,this.createError(`Invalid integer '${n}'`)}}readFloat(){const t=this.cursor;for(;this.canRead()&&St.isAllowedInNumber(this.peek());)this.skip();const n=this.getRead(t);if(n.length===0)throw this.createError("Expected float");try{const r=Number(n);if(isNaN(r))throw new Error;return r}catch{throw this.cursor=t,this.createError(`Invalid float '${n}'`)}}readUnquotedString(){const t=this.cursor;for(;this.canRead()&&St.isAllowedInUnquotedString(this.peek());)this.skip();return this.getRead(t)}readQuotedString(){if(!this.canRead())return"";const t=this.peek();if(!St.isQuotedStringStart(t))throw this.createError("Expected quote to start a string");return this.skip(),this.readStringUntil(t)}readString(){if(!this.canRead())return"";const t=this.peek();return St.isQuotedStringStart(t)?(this.skip(),this.readStringUntil(t)):this.readUnquotedString()}readStringUntil(t){const n=[];let r=!1;for(;this.canRead();){const i=this.read();if(r)if(i===t||i==="\\")n.push(i),r=!1;else throw this.cursor-=1,this.createError(`Invalid escape sequence '${i}' in quoted string`);else if(i==="\\")r=!0;else{if(i===t)return n.join("");n.push(i)}}throw this.createError("Unclosed quoted string")}readBoolean(){const t=this.cursor,n=this.readUnquotedString();if(n.length===0)throw this.createError("Expected bool");if(n==="true")return!0;if(n==="false")return!1;throw this.cursor=t,this.createError(`Invalid bool, expected true or false but found '${n}'`)}static isAllowedInNumber(t){return t>="0"&&t<="9"||t==="."||t==="-"}static isAllowedInUnquotedString(t){return t>="0"&&t<="9"||t>="A"&&t<="Z"||t>="a"&&t<="z"||t==="_"||t==="-"||t==="."||t==="+"}static isQuotedStringStart(t){return t==="'"||t==='"'}static isWhitespace(t){return t===" "||t===" "||t===` `||t==="\r"}createError(t){const n=Math.min(this.source.length,this.cursor),r=(n>10?"...":"")+this.source.substring(Math.max(0,n-10),n);return new Error(`${t} at position ${this.cursor}: ${r}<--[HERE]`)}}function rn(e){let t=null;return()=>(t==null&&(t=e()),t)}function Ee(e,t,n){const r=e.get(t);if(r!==void 0)return r;const i=n(t);return e.set(t,i),i}function mr(e,t,n,r){const i=e.get(t),s=i!=null?i:n;return r(s,t),e.set(t,s),s}/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */const aa=4,ui=0,hi=1,oa=2;function Ze(e){let t=e.length;for(;--t>=0;)e[t]=0}const ca=0,fi=1,la=2,ua=3,ha=258,pr=29,sn=256,an=sn+1+pr,Ge=30,wr=19,di=2*an+1,Ie=15,vr=16,fa=7,_r=256,gi=16,mi=17,pi=18,br=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]),On=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]),da=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),wi=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ga=512,Wt=new Array((an+2)*2);Ze(Wt);const on=new Array(Ge*2);Ze(on);const cn=new Array(ga);Ze(cn);const ln=new Array(ha-ua+1);Ze(ln);const yr=new Array(pr);Ze(yr);const Jn=new Array(Ge);Ze(Jn);function Sr(e,t,n,r,i){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=r,this.max_length=i,this.has_stree=e&&e.length}let vi,_i,bi;function Er(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}const yi=e=>e<256?cn[e]:cn[256+(e>>>7)],un=(e,t)=>{e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255},Et=(e,t,n)=>{e.bi_valid>vr-n?(e.bi_buf|=t<>vr-e.bi_valid,e.bi_valid+=n-vr):(e.bi_buf|=t<{Et(e,n[t*2],n[t*2+1])},Si=(e,t)=>{let n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1},ma=e=>{e.bi_valid===16?(un(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)},pa=(e,t)=>{const n=t.dyn_tree,r=t.max_code,i=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,g=t.stat_desc.max_length;let c,l,h,d,f,p,v=0;for(d=0;d<=Ie;d++)e.bl_count[d]=0;for(n[e.heap[e.heap_max]*2+1]=0,c=e.heap_max+1;cg&&(d=g,v++),n[l*2+1]=d,!(l>r)&&(e.bl_count[d]++,f=0,l>=o&&(f=a[l-o]),p=n[l*2],e.opt_len+=p*(d+f),s&&(e.static_len+=p*(i[l*2+1]+f)));if(v!==0){do{for(d=g-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[g]--,v-=2}while(v>0);for(d=g;d!==0;d--)for(l=e.bl_count[d];l!==0;)h=e.heap[--c],!(h>r)&&(n[h*2+1]!==d&&(e.opt_len+=(d-n[h*2+1])*n[h*2],n[h*2+1]=d),l--)}},Ei=(e,t,n)=>{const r=new Array(Ie+1);let i=0,s,a;for(s=1;s<=Ie;s++)r[s]=i=i+n[s-1]<<1;for(a=0;a<=t;a++){let o=e[a*2+1];o!==0&&(e[a*2]=Si(r[o]++,o))}},wa=()=>{let e,t,n,r,i;const s=new Array(Ie+1);for(n=0,r=0;r>=7;r{let t;for(t=0;t{e.bi_valid>8?un(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},va=(e,t,n,r)=>{ki(e),r&&(un(e,n),un(e,~n)),e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n},Ai=(e,t,n,r)=>{const i=t*2,s=n*2;return e[i]{const r=e.heap[n];let i=n<<1;for(;i<=e.heap_len&&(i{let r,i,s=0,a,o;if(e.last_lit!==0)do r=e.pending_buf[e.d_buf+s*2]<<8|e.pending_buf[e.d_buf+s*2+1],i=e.pending_buf[e.l_buf+s],s++,r===0?Ht(e,i,t):(a=ln[i],Ht(e,a+sn+1,t),o=br[a],o!==0&&(i-=yr[a],Et(e,i,o)),r--,a=yi(r),Ht(e,a,n),o=On[a],o!==0&&(r-=Jn[a],Et(e,r,o)));while(s{const n=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems;let a,o,g=-1,c;for(e.heap_len=0,e.heap_max=di,a=0;a>1;a>=1;a--)Ir(e,n,a);c=s;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Ir(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=o,n[c*2]=n[a*2]+n[o*2],e.depth[c]=(e.depth[a]>=e.depth[o]?e.depth[a]:e.depth[o])+1,n[a*2+1]=n[o*2+1]=c,e.heap[1]=c++,Ir(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],pa(e,t),Ei(n,g,e.bl_count)},Mi=(e,t,n)=>{let r,i=-1,s,a=t[0*2+1],o=0,g=7,c=4;for(a===0&&(g=138,c=3),t[(n+1)*2+1]=65535,r=0;r<=n;r++)s=a,a=t[(r+1)*2+1],!(++o{let r,i=-1,s,a=t[0*2+1],o=0,g=7,c=4;for(a===0&&(g=138,c=3),r=0;r<=n;r++)if(s=a,a=t[(r+1)*2+1],!(++o{let t;for(Mi(e,e.dyn_ltree,e.l_desc.max_code),Mi(e,e.dyn_dtree,e.d_desc.max_code),kr(e,e.bl_desc),t=wr-1;t>=3&&e.bl_tree[wi[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t},ba=(e,t,n,r)=>{let i;for(Et(e,t-257,5),Et(e,n-1,5),Et(e,r-4,4),i=0;i{let t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return ui;if(e.dyn_ltree[9*2]!==0||e.dyn_ltree[10*2]!==0||e.dyn_ltree[13*2]!==0)return hi;for(n=32;n{Ni||(wa(),Ni=!0),e.l_desc=new Er(e.dyn_ltree,vi),e.d_desc=new Er(e.dyn_dtree,_i),e.bl_desc=new Er(e.bl_tree,bi),e.bi_buf=0,e.bi_valid=0,Ii(e)},Ci=(e,t,n,r)=>{Et(e,(ca<<1)+(r?1:0),3),va(e,t,n,!0)},Ea=e=>{Et(e,fi<<1,3),Ht(e,_r,Wt),ma(e)},Ia=(e,t,n,r)=>{let i,s,a=0;e.level>0?(e.strm.data_type===oa&&(e.strm.data_type=ya(e)),kr(e,e.l_desc),kr(e,e.d_desc),a=_a(e),i=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=i&&(i=s)):i=s=n+5,n+4<=i&&t!==-1?Ci(e,t,n,r):e.strategy===aa||s===i?(Et(e,(fi<<1)+(r?1:0),3),xi(e,Wt,on)):(Et(e,(la<<1)+(r?1:0),3),ba(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),xi(e,e.dyn_ltree,e.dyn_dtree)),Ii(e),r&&ki(e)},ka=(e,t,n)=>(e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(ln[n]+sn+1)*2]++,e.dyn_dtree[yi(t)*2]++),e.last_lit===e.lit_bufsize-1);var Aa=Sa,xa=Ci,Ma=Ia,Ra=ka,Na=Ea,Ca={_tr_init:Aa,_tr_stored_block:xa,_tr_flush_block:Ma,_tr_tally:Ra,_tr_align:Na},hn=(e,t,n,r)=>{let i=e&65535|0,s=e>>>16&65535|0,a=0;for(;n!==0;){a=n>2e3?2e3:n,n-=a;do i=i+t[r++]|0,s=s+i|0;while(--a);i%=65521,s%=65521}return i|s<<16|0};const Ba=()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t},Ta=new Uint32Array(Ba());var dt=(e,t,n,r)=>{const i=Ta,s=r+n;e^=-1;for(let a=r;a>>8^i[(e^t[a])&255];return e^-1},ke={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"},Ae={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:La,_tr_stored_block:Pa,_tr_flush_block:Oa,_tr_tally:oe,_tr_align:Ja}=Ca,{Z_NO_FLUSH:xe,Z_PARTIAL_FLUSH:za,Z_FULL_FLUSH:Da,Z_FINISH:ce,Z_BLOCK:Bi,Z_OK:Zt,Z_STREAM_END:Ti,Z_STREAM_ERROR:Nt,Z_DATA_ERROR:Fa,Z_BUF_ERROR:Ar,Z_DEFAULT_COMPRESSION:Ua,Z_FILTERED:Ha,Z_HUFFMAN_ONLY:zn,Z_RLE:Za,Z_FIXED:Ga,Z_DEFAULT_STRATEGY:Va,Z_UNKNOWN:$a,Z_DEFLATED:Dn}=Ae,Ya=9,qa=15,Wa=8,Xa=29,xr=256+1+Xa,ja=30,Ka=19,Qa=2*xr+1,to=15,K=3,le=258,zt=le+K+1,eo=32,Fn=42,Mr=69,Un=73,Hn=91,Zn=103,Me=113,fn=666,ht=1,dn=2,Re=3,Ve=4,no=3,ue=(e,t)=>(e.msg=ke[t],t),Li=e=>(e<<1)-(e>4?9:0),he=e=>{let t=e.length;for(;--t>=0;)e[t]=0};let fe=(e,t,n)=>(t<{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))},mt=(e,t)=>{Oa(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,de(e.strm)},tt=(e,t)=>{e.pending_buf[e.pending++]=t},gn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255},ro=(e,t,n,r)=>{let i=e.avail_in;return i>r&&(i=r),i===0?0:(e.avail_in-=i,t.set(e.input.subarray(e.next_in,e.next_in+i),n),e.state.wrap===1?e.adler=hn(e.adler,t,i,n):e.state.wrap===2&&(e.adler=dt(e.adler,t,i,n)),e.next_in+=i,e.total_in+=i,i)},Pi=(e,t)=>{let n=e.max_chain_length,r=e.strstart,i,s,a=e.prev_length,o=e.nice_match;const g=e.strstart>e.w_size-zt?e.strstart-(e.w_size-zt):0,c=e.window,l=e.w_mask,h=e.prev,d=e.strstart+le;let f=c[r+a-1],p=c[r+a];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do if(i=t,!(c[i+a]!==p||c[i+a-1]!==f||c[i]!==c[r]||c[++i]!==c[r+1])){r+=2,i++;do;while(c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&c[++r]===c[++i]&&ra){if(e.match_start=t,a=s,s>=o)break;f=c[r+a-1],p=c[r+a]}}while((t=h[t&l])>g&&--n!==0);return a<=e.lookahead?a:e.lookahead},Ne=e=>{const t=e.w_size;let n,r,i,s,a;do{if(s=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-zt)){e.window.set(e.window.subarray(t,t+t),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,r=e.hash_size,n=r;do i=e.head[--n],e.head[n]=i>=t?i-t:0;while(--r);r=t,n=r;do i=e.prev[--n],e.prev[n]=i>=t?i-t:0;while(--r);s+=t}if(e.strm.avail_in===0)break;if(r=ro(e.strm,e.window,e.strstart+e.lookahead,s),e.lookahead+=r,e.lookahead+e.insert>=K)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=fe(e,e.ins_h,e.window[a+1]);e.insert&&(e.ins_h=fe(e,e.ins_h,e.window[a+K-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{let n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(Ne(e),e.lookahead===0&&t===xe)return ht;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;const r=e.block_start+n;if((e.strstart===0||e.strstart>=r)&&(e.lookahead=e.strstart-r,e.strstart=r,mt(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-zt&&(mt(e,!1),e.strm.avail_out===0))return ht}return e.insert=0,t===ce?(mt(e,!0),e.strm.avail_out===0?Re:Ve):(e.strstart>e.block_start&&(mt(e,!1),e.strm.avail_out===0),ht)},Rr=(e,t)=>{let n,r;for(;;){if(e.lookahead=K&&(e.ins_h=fe(e,e.ins_h,e.window[e.strstart+K-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-zt&&(e.match_length=Pi(e,n)),e.match_length>=K)if(r=oe(e,e.strstart-e.match_start,e.match_length-K),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=K){e.match_length--;do e.strstart++,e.ins_h=fe(e,e.ins_h,e.window[e.strstart+K-1]),n=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=fe(e,e.ins_h,e.window[e.strstart+1]);else r=oe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(mt(e,!1),e.strm.avail_out===0))return ht}return e.insert=e.strstart{let n,r,i;for(;;){if(e.lookahead=K&&(e.ins_h=fe(e,e.ins_h,e.window[e.strstart+K-1]),n=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=K-1,n!==0&&e.prev_length4096)&&(e.match_length=K-1)),e.prev_length>=K&&e.match_length<=e.prev_length){i=e.strstart+e.lookahead-K,r=oe(e,e.strstart-1-e.prev_match,e.prev_length-K),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=i&&(e.ins_h=fe(e,e.ins_h,e.window[e.strstart+K-1]),n=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=K-1,e.strstart++,r&&(mt(e,!1),e.strm.avail_out===0))return ht}else if(e.match_available){if(r=oe(e,0,e.window[e.strstart-1]),r&&mt(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return ht}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=oe(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart{let n,r,i,s;const a=e.window;for(;;){if(e.lookahead<=le){if(Ne(e),e.lookahead<=le&&t===xe)return ht;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=K&&e.strstart>0&&(i=e.strstart-1,r=a[i],r===a[++i]&&r===a[++i]&&r===a[++i])){s=e.strstart+le;do;while(r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&r===a[++i]&&ie.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=K?(n=oe(e,1,e.match_length-K),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=oe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(mt(e,!1),e.strm.avail_out===0))return ht}return e.insert=0,t===ce?(mt(e,!0),e.strm.avail_out===0?Re:Ve):e.last_lit&&(mt(e,!1),e.strm.avail_out===0)?ht:dn},ao=(e,t)=>{let n;for(;;){if(e.lookahead===0&&(Ne(e),e.lookahead===0)){if(t===xe)return ht;break}if(e.match_length=0,n=oe(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(mt(e,!1),e.strm.avail_out===0))return ht}return e.insert=0,t===ce?(mt(e,!0),e.strm.avail_out===0?Re:Ve):e.last_lit&&(mt(e,!1),e.strm.avail_out===0)?ht:dn};function Gt(e,t,n,r,i){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=r,this.func=i}const mn=[new Gt(0,0,0,0,io),new Gt(4,4,8,4,Rr),new Gt(4,5,16,8,Rr),new Gt(4,6,32,32,Rr),new Gt(4,4,16,16,$e),new Gt(8,16,32,32,$e),new Gt(8,16,128,128,$e),new Gt(8,32,128,256,$e),new Gt(32,128,258,1024,$e),new Gt(32,258,258,4096,$e)],oo=e=>{e.window_size=2*e.w_size,he(e.head),e.max_lazy_match=mn[e.level].max_lazy,e.good_match=mn[e.level].good_length,e.nice_match=mn[e.level].nice_length,e.max_chain_length=mn[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=K-1,e.match_available=0,e.ins_h=0};function co(){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=Dn,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(Qa*2),this.dyn_dtree=new Uint16Array((2*ja+1)*2),this.bl_tree=new Uint16Array((2*Ka+1)*2),he(this.dyn_ltree),he(this.dyn_dtree),he(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(to+1),this.heap=new Uint16Array(2*xr+1),he(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*xr+1),he(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 Oi=e=>{if(!e||!e.state)return ue(e,Nt);e.total_in=e.total_out=0,e.data_type=$a;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Fn:Me,e.adler=t.wrap===2?0:1,t.last_flush=xe,La(t),Zt},Ji=e=>{const t=Oi(e);return t===Zt&&oo(e.state),t},lo=(e,t)=>!e||!e.state||e.state.wrap!==2?Nt:(e.state.gzhead=t,Zt),zi=(e,t,n,r,i,s)=>{if(!e)return Nt;let a=1;if(t===Ua&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),i<1||i>Ya||n!==Dn||r<8||r>15||t<0||t>9||s<0||s>Ga)return ue(e,Nt);r===8&&(r=9);const o=new co;return e.state=o,o.strm=e,o.wrap=a,o.gzhead=null,o.w_bits=r,o.w_size=1<zi(e,t,Dn,qa,Wa,Va),ho=(e,t)=>{let n,r;if(!e||!e.state||t>Bi||t<0)return e?ue(e,Nt):Nt;const i=e.state;if(!e.output||!e.input&&e.avail_in!==0||i.status===fn&&t!==ce)return ue(e,e.avail_out===0?Ar:Nt);i.strm=e;const s=i.last_flush;if(i.last_flush=t,i.status===Fn)if(i.wrap===2)e.adler=0,tt(i,31),tt(i,139),tt(i,8),i.gzhead?(tt(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),tt(i,i.gzhead.time&255),tt(i,i.gzhead.time>>8&255),tt(i,i.gzhead.time>>16&255),tt(i,i.gzhead.time>>24&255),tt(i,i.level===9?2:i.strategy>=zn||i.level<2?4:0),tt(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(tt(i,i.gzhead.extra.length&255),tt(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=dt(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=Mr):(tt(i,0),tt(i,0),tt(i,0),tt(i,0),tt(i,0),tt(i,i.level===9?2:i.strategy>=zn||i.level<2?4:0),tt(i,no),i.status=Me);else{let a=Dn+(i.w_bits-8<<4)<<8,o=-1;i.strategy>=zn||i.level<2?o=0:i.level<6?o=1:i.level===6?o=2:o=3,a|=o<<6,i.strstart!==0&&(a|=eo),a+=31-a%31,i.status=Me,gn(i,a),i.strstart!==0&&(gn(i,e.adler>>>16),gn(i,e.adler&65535)),e.adler=1}if(i.status===Mr)if(i.gzhead.extra){for(n=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=dt(e.adler,i.pending_buf,i.pending-n,n)),de(e),n=i.pending,i.pending===i.pending_buf_size));)tt(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>n&&(e.adler=dt(e.adler,i.pending_buf,i.pending-n,n)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Un)}else i.status=Un;if(i.status===Un)if(i.gzhead.name){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=dt(e.adler,i.pending_buf,i.pending-n,n)),de(e),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}i.gzindexn&&(e.adler=dt(e.adler,i.pending_buf,i.pending-n,n)),r===0&&(i.gzindex=0,i.status=Hn)}else i.status=Hn;if(i.status===Hn)if(i.gzhead.comment){n=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>n&&(e.adler=dt(e.adler,i.pending_buf,i.pending-n,n)),de(e),n=i.pending,i.pending===i.pending_buf_size)){r=1;break}i.gzindexn&&(e.adler=dt(e.adler,i.pending_buf,i.pending-n,n)),r===0&&(i.status=Zn)}else i.status=Zn;if(i.status===Zn&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&de(e),i.pending+2<=i.pending_buf_size&&(tt(i,e.adler&255),tt(i,e.adler>>8&255),e.adler=0,i.status=Me)):i.status=Me),i.pending!==0){if(de(e),e.avail_out===0)return i.last_flush=-1,Zt}else if(e.avail_in===0&&Li(t)<=Li(s)&&t!==ce)return ue(e,Ar);if(i.status===fn&&e.avail_in!==0)return ue(e,Ar);if(e.avail_in!==0||i.lookahead!==0||t!==xe&&i.status!==fn){let a=i.strategy===zn?ao(i,t):i.strategy===Za?so(i,t):mn[i.level].func(i,t);if((a===Re||a===Ve)&&(i.status=fn),a===ht||a===Re)return e.avail_out===0&&(i.last_flush=-1),Zt;if(a===dn&&(t===za?Ja(i):t!==Bi&&(Pa(i,0,0,!1),t===Da&&(he(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),de(e),e.avail_out===0))return i.last_flush=-1,Zt}return t!==ce?Zt:i.wrap<=0?Ti:(i.wrap===2?(tt(i,e.adler&255),tt(i,e.adler>>8&255),tt(i,e.adler>>16&255),tt(i,e.adler>>24&255),tt(i,e.total_in&255),tt(i,e.total_in>>8&255),tt(i,e.total_in>>16&255),tt(i,e.total_in>>24&255)):(gn(i,e.adler>>>16),gn(i,e.adler&65535)),de(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?Zt:Ti)},fo=e=>{if(!e||!e.state)return Nt;const t=e.state.status;return t!==Fn&&t!==Mr&&t!==Un&&t!==Hn&&t!==Zn&&t!==Me&&t!==fn?ue(e,Nt):(e.state=null,t===Me?ue(e,Fa):Zt)},go=(e,t)=>{let n=t.length;if(!e||!e.state)return Nt;const r=e.state,i=r.wrap;if(i===2||i===1&&r.status!==Fn||r.lookahead)return Nt;if(i===1&&(e.adler=hn(e.adler,t,n,0)),r.wrap=0,n>=r.w_size){i===0&&(he(r.head),r.strstart=0,r.block_start=0,r.insert=0);let g=new Uint8Array(r.w_size);g.set(t.subarray(n-r.w_size,n),0),t=g,n=r.w_size}const s=e.avail_in,a=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Ne(r);r.lookahead>=K;){let g=r.strstart,c=r.lookahead-(K-1);do r.ins_h=fe(r,r.ins_h,r.window[g+K-1]),r.prev[g&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=g,g++;while(--c);r.strstart=g,r.lookahead=K-1,Ne(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=K-1,r.match_available=0,e.next_in=a,e.input=o,e.avail_in=s,r.wrap=i,Zt};var mo=uo,po=zi,wo=Ji,vo=Oi,_o=lo,bo=ho,yo=fo,So=go,Eo="pako deflate (from Nodeca project)",pn={deflateInit:mo,deflateInit2:po,deflateReset:wo,deflateResetKeep:vo,deflateSetHeader:_o,deflate:bo,deflateEnd:yo,deflateSetDictionary:So,deflateInfo:Eo};const Io=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var ko=function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(!!n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(const r in n)Io(n,r)&&(e[r]=n[r])}}return e},Ao=e=>{let t=0;for(let r=0,i=e.length;r=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;wn[254]=wn[254]=1;var xo=e=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(e);let t,n,r,i,s,a=e.length,o=0;for(i=0;i>>6,t[s++]=128|n&63):n<65536?(t[s++]=224|n>>>12,t[s++]=128|n>>>6&63,t[s++]=128|n&63):(t[s++]=240|n>>>18,t[s++]=128|n>>>12&63,t[s++]=128|n>>>6&63,t[s++]=128|n&63);return t};const Mo=(e,t)=>{if(t<65534&&e.subarray&&Di)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let r=0;r{const n=t||e.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(e.subarray(0,t));let r,i;const s=new Array(n*2);for(i=0,r=0;r4){s[i++]=65533,r+=o-1;continue}for(a&=o===2?31:o===3?15:7;o>1&&r1){s[i++]=65533;continue}a<65536?s[i++]=a:(a-=65536,s[i++]=55296|a>>10&1023,s[i++]=56320|a&1023)}return Mo(s,i)},No=(e,t)=>{t=t||e.length,t>e.length&&(t=e.length);let n=t-1;for(;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+wn[e[n]]>t?n:t},vn={string2buf:xo,buf2string:Ro,utf8border:No};function Co(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Fi=Co;const Ui=Object.prototype.toString,{Z_NO_FLUSH:Bo,Z_SYNC_FLUSH:To,Z_FULL_FLUSH:Lo,Z_FINISH:Po,Z_OK:Vn,Z_STREAM_END:Oo,Z_DEFAULT_COMPRESSION:Jo,Z_DEFAULT_STRATEGY:zo,Z_DEFLATED:Do}=Ae;function _n(e){this.options=Gn.assign({level:Jo,method:Do,chunkSize:16384,windowBits:15,memLevel:8,strategy:zo},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Fi,this.strm.avail_out=0;let n=pn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==Vn)throw new Error(ke[n]);if(t.header&&pn.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=vn.string2buf(t.dictionary):Ui.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,n=pn.deflateSetDictionary(this.strm,r),n!==Vn)throw new Error(ke[n]);this._dict_set=!0}}_n.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize;let i,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?Po:Bo,typeof e=="string"?n.input=vn.string2buf(e):Ui.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){if(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),(s===To||s===Lo)&&n.avail_out<=6){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(i=pn.deflate(n,s),i===Oo)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),i=pn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Vn;if(n.avail_out===0){this.onData(n.output);continue}if(s>0&&n.next_out>0){this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;continue}if(n.avail_in===0)break}return!0},_n.prototype.onData=function(e){this.chunks.push(e)},_n.prototype.onEnd=function(e){e===Vn&&(this.result=Gn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Nr(e,t){const n=new _n(t);if(n.push(e,!0),n.err)throw n.msg||ke[n.err];return n.result}function Fo(e,t){return t=t||{},t.raw=!0,Nr(e,t)}function Uo(e,t){return t=t||{},t.gzip=!0,Nr(e,t)}var Ho=_n,Zo=Nr,Go=Fo,Vo=Uo,$o=Ae,Yo={Deflate:Ho,deflate:Zo,deflateRaw:Go,gzip:Vo,constants:$o};const $n=30,qo=12;var Wo=function(t,n){let r,i,s,a,o,g,c,l,h,d,f,p,v,m,w,S,E,y,k,R,I,M,T,x;const N=t.state;r=t.next_in,T=t.input,i=r+(t.avail_in-5),s=t.next_out,x=t.output,a=s-(n-t.avail_out),o=s+(t.avail_out-257),g=N.dmax,c=N.wsize,l=N.whave,h=N.wnext,d=N.window,f=N.hold,p=N.bits,v=N.lencode,m=N.distcode,w=(1<>>24,f>>>=y,p-=y,y=E>>>16&255,y===0)x[s++]=E&65535;else if(y&16){k=E&65535,y&=15,y&&(p>>=y,p-=y),p<15&&(f+=T[r++]<>>24,f>>>=y,p-=y,y=E>>>16&255,y&16){if(R=E&65535,y&=15,pg){t.msg="invalid distance too far back",N.mode=$n;break t}if(f>>>=y,p-=y,y=s-a,R>y){if(y=R-y,y>l&&N.sane){t.msg="invalid distance too far back",N.mode=$n;break t}if(I=0,M=d,h===0){if(I+=c-y,y2;)x[s++]=M[I++],x[s++]=M[I++],x[s++]=M[I++],k-=3;k&&(x[s++]=M[I++],k>1&&(x[s++]=M[I++]))}else{I=s-R;do x[s++]=x[I++],x[s++]=x[I++],x[s++]=x[I++],k-=3;while(k>2);k&&(x[s++]=x[I++],k>1&&(x[s++]=x[I++]))}}else if((y&64)===0){E=m[(E&65535)+(f&(1<>3,r-=k,p-=k<<3,f&=(1<{const g=o.bits;let c=0,l=0,h=0,d=0,f=0,p=0,v=0,m=0,w=0,S=0,E,y,k,R,I,M=null,T=0,x;const N=new Uint16Array(Ye+1),P=new Uint16Array(Ye+1);let F=null,U=0,Y,B,J;for(c=0;c<=Ye;c++)N[c]=0;for(l=0;l=1&&N[d]===0;d--);if(f>d&&(f=d),d===0)return i[s++]=1<<24|64<<16|0,i[s++]=1<<24|64<<16|0,o.bits=1,0;for(h=1;h0&&(e===Gi||d!==1))return-1;for(P[1]=0,c=1;cHi||e===Vi&&w>Zi)return 1;for(;;){Y=c-v,a[l]x?(B=F[U+a[l]],J=M[T+a[l]]):(B=32+64,J=0),E=1<>v)+y]=Y<<24|B<<16|J|0;while(y!==0);for(E=1<>=1;if(E!==0?(S&=E-1,S+=E):S=0,l++,--N[c]===0){if(c===d)break;c=t[n+a[l]]}if(c>f&&(S&R)!==k){for(v===0&&(v=f),I+=h,p=c-v,m=1<Hi||e===Vi&&w>Zi)return 1;k=S&R,i[k]=f<<24|p<<16|I-s|0}}return S!==0&&(i[I+S]=c-v<<24|64<<16|0),o.bits=f,0};const tc=0,$i=1,Yi=2,{Z_FINISH:qi,Z_BLOCK:ec,Z_TREES:Yn,Z_OK:Ce,Z_STREAM_END:nc,Z_NEED_DICT:rc,Z_STREAM_ERROR:Ct,Z_DATA_ERROR:Wi,Z_MEM_ERROR:Xi,Z_BUF_ERROR:ic,Z_DEFLATED:ji}=Ae,Ki=1,Qi=2,ts=3,es=4,ns=5,rs=6,is=7,ss=8,as=9,os=10,qn=11,Xt=12,Br=13,cs=14,Tr=15,ls=16,us=17,hs=18,fs=19,Wn=20,Xn=21,ds=22,gs=23,ms=24,ps=25,ws=26,Lr=27,vs=28,_s=29,st=30,bs=31,sc=32,ac=852,oc=592,cc=15,ys=e=>(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24);function lc(){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 Ss=e=>{if(!e||!e.state)return Ct;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=Ki,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(ac),t.distcode=t.distdyn=new Int32Array(oc),t.sane=1,t.back=-1,Ce},Es=e=>{if(!e||!e.state)return Ct;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ss(e)},Is=(e,t)=>{let n;if(!e||!e.state)return Ct;const r=e.state;return t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15)?Ct:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=n,r.wbits=t,Es(e))},ks=(e,t)=>{if(!e)return Ct;const n=new lc;e.state=n,n.window=null;const r=Is(e,t);return r!==Ce&&(e.state=null),r},uc=e=>ks(e,cc);let As=!0,Pr,Or;const hc=e=>{if(As){Pr=new Int32Array(512),Or=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(bn($i,e.lens,0,288,Pr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;bn(Yi,e.lens,0,32,Or,0,e.work,{bits:5}),As=!1}e.lencode=Pr,e.lenbits=9,e.distcode=Or,e.distbits=5},xs=(e,t,n,r)=>{let i;const s=e.state;return s.window===null&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(n-r,n-r+i),s.wnext),r-=i,r?(s.window.set(t.subarray(n-r,n),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave{let n,r,i,s,a,o,g,c,l,h,d,f,p,v,m=0,w,S,E,y,k,R,I,M;const T=new Uint8Array(4);let x,N;const P=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 Ct;n=e.state,n.mode===Xt&&(n.mode=Br),a=e.next_out,i=e.output,g=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,h=o,d=g,M=Ce;t:for(;;)switch(n.mode){case Ki:if(n.wrap===0){n.mode=Br;break}for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>>8&255,n.check=dt(n.check,T,2,0),c=0,l=0,n.mode=Qi;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((c&255)<<8)+(c>>8))%31){e.msg="incorrect header check",n.mode=st;break}if((c&15)!==ji){e.msg="unknown compression method",n.mode=st;break}if(c>>>=4,l-=4,I=(c&15)+8,n.wbits===0)n.wbits=I;else if(I>n.wbits){e.msg="invalid window size",n.mode=st;break}n.dmax=1<>8&1),n.flags&512&&(T[0]=c&255,T[1]=c>>>8&255,n.check=dt(n.check,T,2,0)),c=0,l=0,n.mode=ts;case ts:for(;l<32;){if(o===0)break t;o--,c+=r[s++]<>>8&255,T[2]=c>>>16&255,T[3]=c>>>24&255,n.check=dt(n.check,T,4,0)),c=0,l=0,n.mode=es;case es:for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>8),n.flags&512&&(T[0]=c&255,T[1]=c>>>8&255,n.check=dt(n.check,T,2,0)),c=0,l=0,n.mode=ns;case ns:if(n.flags&1024){for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>>8&255,n.check=dt(n.check,T,2,0)),c=0,l=0}else n.head&&(n.head.extra=null);n.mode=rs;case rs:if(n.flags&1024&&(f=n.length,f>o&&(f=o),f&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(r.subarray(s,s+f),I)),n.flags&512&&(n.check=dt(n.check,r,f,s)),o-=f,s+=f,n.length-=f),n.length))break t;n.length=0,n.mode=is;case is:if(n.flags&2048){if(o===0)break t;f=0;do I=r[s+f++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I));while(I&&f>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=Xt;break;case os:for(;l<32;){if(o===0)break t;o--,c+=r[s++]<>>=l&7,l-=l&7,n.mode=Lr;break}for(;l<3;){if(o===0)break t;o--,c+=r[s++]<>>=1,l-=1,c&3){case 0:n.mode=cs;break;case 1:if(hc(n),n.mode=Wn,t===Yn){c>>>=2,l-=2;break t}break;case 2:n.mode=us;break;case 3:e.msg="invalid block type",n.mode=st}c>>>=2,l-=2;break;case cs:for(c>>>=l&7,l-=l&7;l<32;){if(o===0)break t;o--,c+=r[s++]<>>16^65535)){e.msg="invalid stored block lengths",n.mode=st;break}if(n.length=c&65535,c=0,l=0,n.mode=Tr,t===Yn)break t;case Tr:n.mode=ls;case ls:if(f=n.length,f){if(f>o&&(f=o),f>g&&(f=g),f===0)break t;i.set(r.subarray(s,s+f),a),o-=f,s+=f,g-=f,a+=f,n.length-=f;break}n.mode=Xt;break;case us:for(;l<14;){if(o===0)break t;o--,c+=r[s++]<>>=5,l-=5,n.ndist=(c&31)+1,c>>>=5,l-=5,n.ncode=(c&15)+4,c>>>=4,l-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=st;break}n.have=0,n.mode=hs;case hs:for(;n.have>>=3,l-=3}for(;n.have<19;)n.lens[P[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,x={bits:n.lenbits},M=bn(tc,n.lens,0,19,n.lencode,0,n.work,x),n.lenbits=x.bits,M){e.msg="invalid code lengths set",n.mode=st;break}n.have=0,n.mode=fs;case fs:for(;n.have>>24,S=m>>>16&255,E=m&65535,!(w<=l);){if(o===0)break t;o--,c+=r[s++]<>>=w,l-=w,n.lens[n.have++]=E;else{if(E===16){for(N=w+2;l>>=w,l-=w,n.have===0){e.msg="invalid bit length repeat",n.mode=st;break}I=n.lens[n.have-1],f=3+(c&3),c>>>=2,l-=2}else if(E===17){for(N=w+3;l>>=w,l-=w,I=0,f=3+(c&7),c>>>=3,l-=3}else{for(N=w+7;l>>=w,l-=w,I=0,f=11+(c&127),c>>>=7,l-=7}if(n.have+f>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=st;break}for(;f--;)n.lens[n.have++]=I}}if(n.mode===st)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=st;break}if(n.lenbits=9,x={bits:n.lenbits},M=bn($i,n.lens,0,n.nlen,n.lencode,0,n.work,x),n.lenbits=x.bits,M){e.msg="invalid literal/lengths set",n.mode=st;break}if(n.distbits=6,n.distcode=n.distdyn,x={bits:n.distbits},M=bn(Yi,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,x),n.distbits=x.bits,M){e.msg="invalid distances set",n.mode=st;break}if(n.mode=Wn,t===Yn)break t;case Wn:n.mode=Xn;case Xn:if(o>=6&&g>=258){e.next_out=a,e.avail_out=g,e.next_in=s,e.avail_in=o,n.hold=c,n.bits=l,Wo(e,d),a=e.next_out,i=e.output,g=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,c=n.hold,l=n.bits,n.mode===Xt&&(n.back=-1);break}for(n.back=0;m=n.lencode[c&(1<>>24,S=m>>>16&255,E=m&65535,!(w<=l);){if(o===0)break t;o--,c+=r[s++]<>y)],w=m>>>24,S=m>>>16&255,E=m&65535,!(y+w<=l);){if(o===0)break t;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=w,l-=w,n.back+=w,n.length=E,S===0){n.mode=ws;break}if(S&32){n.back=-1,n.mode=Xt;break}if(S&64){e.msg="invalid literal/length code",n.mode=st;break}n.extra=S&15,n.mode=ds;case ds:if(n.extra){for(N=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=gs;case gs:for(;m=n.distcode[c&(1<>>24,S=m>>>16&255,E=m&65535,!(w<=l);){if(o===0)break t;o--,c+=r[s++]<>y)],w=m>>>24,S=m>>>16&255,E=m&65535,!(y+w<=l);){if(o===0)break t;o--,c+=r[s++]<>>=y,l-=y,n.back+=y}if(c>>>=w,l-=w,n.back+=w,S&64){e.msg="invalid distance code",n.mode=st;break}n.offset=E,n.extra=S&15,n.mode=ms;case ms:if(n.extra){for(N=n.extra;l>>=n.extra,l-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=st;break}n.mode=ps;case ps:if(g===0)break t;if(f=d-g,n.offset>f){if(f=n.offset-f,f>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=st;break}f>n.wnext?(f-=n.wnext,p=n.wsize-f):p=n.wnext-f,f>n.length&&(f=n.length),v=n.window}else v=i,p=a-n.offset,f=n.length;f>g&&(f=g),g-=f,n.length-=f;do i[a++]=v[p++];while(--f);n.length===0&&(n.mode=Xn);break;case ws:if(g===0)break t;i[a++]=n.length,g--,n.mode=Xn;break;case Lr:if(n.wrap){for(;l<32;){if(o===0)break t;o--,c|=r[s++]<{if(!e||!e.state)return Ct;let t=e.state;return t.window&&(t.window=null),e.state=null,Ce},gc=(e,t)=>{if(!e||!e.state)return Ct;const n=e.state;return(n.wrap&2)===0?Ct:(n.head=t,t.done=!1,Ce)},mc=(e,t)=>{const n=t.length;let r,i,s;return!e||!e.state||(r=e.state,r.wrap!==0&&r.mode!==qn)?Ct:r.mode===qn&&(i=1,i=hn(i,t,n,0),i!==r.check)?Wi:(s=xs(e,t,n,n),s?(r.mode=bs,Xi):(r.havedict=1,Ce))};var pc=Es,wc=Is,vc=Ss,_c=uc,bc=ks,yc=fc,Sc=dc,Ec=gc,Ic=mc,kc="pako inflate (from Nodeca project)",jt={inflateReset:pc,inflateReset2:wc,inflateResetKeep:vc,inflateInit:_c,inflateInit2:bc,inflate:yc,inflateEnd:Sc,inflateGetHeader:Ec,inflateSetDictionary:Ic,inflateInfo:kc};function Ac(){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 xc=Ac;const Ms=Object.prototype.toString,{Z_NO_FLUSH:Mc,Z_FINISH:Rc,Z_OK:yn,Z_STREAM_END:Jr,Z_NEED_DICT:zr,Z_STREAM_ERROR:Nc,Z_DATA_ERROR:Rs,Z_MEM_ERROR:Cc}=Ae;function Sn(e){this.options=Gn.assign({chunkSize:1024*64,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Fi,this.strm.avail_out=0;let n=jt.inflateInit2(this.strm,t.windowBits);if(n!==yn)throw new Error(ke[n]);if(this.header=new xc,jt.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=vn.string2buf(t.dictionary):Ms.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=jt.inflateSetDictionary(this.strm,t.dictionary),n!==yn)))throw new Error(ke[n])}Sn.prototype.push=function(e,t){const n=this.strm,r=this.options.chunkSize,i=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(t===~~t?a=t:a=t===!0?Rc:Mc,Ms.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(n.avail_out===0&&(n.output=new Uint8Array(r),n.next_out=0,n.avail_out=r),s=jt.inflate(n,a),s===zr&&i&&(s=jt.inflateSetDictionary(n,i),s===yn?s=jt.inflate(n,a):s===Rs&&(s=zr));n.avail_in>0&&s===Jr&&n.state.wrap>0&&e[n.next_in]!==0;)jt.inflateReset(n),s=jt.inflate(n,a);switch(s){case Nc:case Rs:case zr:case Cc:return this.onEnd(s),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(n.avail_out===0||s===Jr))if(this.options.to==="string"){let g=vn.utf8border(n.output,n.next_out),c=n.next_out-g,l=vn.buf2string(n.output,g);n.next_out=c,n.avail_out=r-c,c&&n.output.set(n.output.subarray(g,g+c),0),this.onData(l)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(!(s===yn&&o===0)){if(s===Jr)return s=jt.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(n.avail_in===0)break}}return!0},Sn.prototype.onData=function(e){this.chunks.push(e)},Sn.prototype.onEnd=function(e){e===yn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Gn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function Dr(e,t){const n=new Sn(t);if(n.push(e),n.err)throw n.msg||ke[n.err];return n.result}function Bc(e,t){return t=t||{},t.raw=!0,Dr(e,t)}var Tc=Sn,Lc=Dr,Pc=Bc,Oc=Dr,Jc=Ae,zc={Inflate:Tc,inflate:Lc,inflateRaw:Pc,ungzip:Oc,constants:Jc};const{Deflate:Dc,deflate:Fc,deflateRaw:Uc,gzip:Hc}=Yo,{Inflate:Zc,inflate:Gc,inflateRaw:Vc,ungzip:$c}=zc;var Yc=Dc,qc=Fc,Wc=Uc,Xc=Hc,jc=Zc,Kc=Gc,Qc=Vc,tl=$c,el=Ae,Fr={Deflate:Yc,deflate:qc,deflateRaw:Wc,gzip:Xc,Inflate:jc,inflate:Kc,inflateRaw:Qc,ungzip:tl,constants:el},D=(e=>(e[e.End=0]="End",e[e.Byte=1]="Byte",e[e.Short=2]="Short",e[e.Int=3]="Int",e[e.Long=4]="Long",e[e.Float=5]="Float",e[e.Double=6]="Double",e[e.ByteArray=7]="ByteArray",e[e.String=8]="String",e[e.List=9]="List",e[e.Compound=10]="Compound",e[e.IntArray=11]="IntArray",e[e.LongArray=12]="LongArray",e))(D||{});const dr=class{static register(t,n){const r=n.create().getId();if(r!==t)throw new Error(`Registered factory ${D[r]} does not match type ${D[t]}`);dr.FACTORIES.set(t,n)}isEnd(){return this.getId()===D.End}isByte(){return this.getId()===D.Byte}isShort(){return this.getId()===D.Short}isInt(){return this.getId()===D.Int}isLong(){return this.getId()===D.Long}isFloat(){return this.getId()===D.Float}isDouble(){return this.getId()===D.Double}isByteArray(){return this.getId()===D.ByteArray}isString(){return this.getId()===D.String}isList(){return this.getId()===D.List}isCompound(){return this.getId()===D.Compound}isIntArray(){return this.getId()===D.IntArray}isLongArray(){return this.getId()===D.LongArray}isNumber(){return this.isByte()||this.isShort()||this.isInt()||this.isLong()||this.isFloat()||this.isDouble()}isArray(){return this.isByteArray()||this.isIntArray()||this.isLongArray()}isListOrArray(){return this.isList()||this.isArray()}getAsNumber(){return 0}getAsString(){return""}toJsonWithId(){return{type:this.getId(),value:this.toJson()}}static getFactory(t){const n=this.FACTORIES.get(t);if(!n)throw new Error(`Invalid tag id ${t}`);return n}static create(t){return this.getFactory(t).create()}static fromString(t){const n=typeof t=="string"?new St(t):t;return this.getFactory(D.Compound).fromString(n)}static fromJson(t,n=D.Compound){return this.getFactory(n).fromJson(t)}static fromJsonWithId(t){var i,s,a;const n=(i=u.Json.readObject(t))!=null?i:{},r=(s=u.Json.readInt(n.type))!=null?s:0;return dr.fromJson((a=n.value)!=null?a:{},r)}static fromBytes(t,n=D.Compound){return this.getFactory(n).fromBytes(t)}};let et=dr;_(et,"FACTORIES",new Map);const Fe=class extends et{constructor(n){super();_(this,"value");this.value=typeof n=="number"?n:n?1:0}getId(){return D.Byte}equals(n){return n.isByte()&&this.value===n.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()+"b"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(n){n.writeByte(this.value)}static create(){return Fe.ZERO}static fromJson(n){var r;return new Fe((r=u.Json.readInt(n))!=null?r:0)}static fromBytes(n){const r=n.readByte();return new Fe(r)}};let Bt=Fe;_(Bt,"ZERO",new Fe(0)),_(Bt,"ONE",new Fe(1)),et.register(D.Byte,Bt);class En extends et{constructor(n){super();_(this,"items");this.items=n}getItems(){return this.items.slice(0)}getAsTuple(n,r){return[...Array(n)].map((i,s)=>r(this.items[s]))}get(n){if(n=Math.floor(n),!(n<0||n>=this.items.length))return this.items[n]}get length(){return this.items.length}map(n){return this.items.map(n)}filter(n){return this.items.filter(n)}forEach(n){this.items.forEach(n)}set(n,r){this.items[n]=r}add(n){this.items.push(n)}insert(n,r){this.items.splice(n,0,r)}delete(n){this.items.splice(n,1)}clear(){this.items=[]}}class ge extends En{constructor(t){super(Array.from(t!=null?t:[],n=>typeof n=="number"?new Bt(n):n))}getId(){return D.ByteArray}equals(t){return t.isByteArray()&&this.length===t.length&&this.items.every((n,r)=>n.equals(t.items[r]))}getType(){return D.Byte}toString(){return"[B;"+this.items.map(n=>n.getAsNumber().toFixed()+"B").join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsNumber())}toJson(){return this.items.map(t=>t.getAsNumber())}toBytes(t){t.writeInt(this.items.length),t.writeBytes(this.items.map(n=>n.getAsNumber()))}static create(){return new ge([])}static fromJson(t){var r;const n=(r=u.Json.readArray(t,i=>{var s;return(s=u.Json.readNumber(i))!=null?s:0}))!=null?r:[];return new ge(n)}static fromBytes(t){const n=t.readInt(),r=t.readBytes(n);return new ge(r)}}et.register(D.ByteArray,ge);class Be extends et{constructor(n){super();_(this,"value");this.value=n}getId(){return D.Float}equals(n){return n.isFloat()&&this.value===n.value}getAsNumber(){return this.value}toString(){return this.value.toString()+"f"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(n){n.writeFloat(this.value)}static create(){return new Be(0)}static fromJson(n){var r;return new Be((r=u.Json.readNumber(n))!=null?r:0)}static fromBytes(n){const r=n.readFloat();return new Be(r)}}et.register(D.Float,Be);class Dt extends et{constructor(n){super();_(this,"value");this.value=n}getId(){return D.Int}equals(n){return n.isInt()&&this.value===n.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(n){n.writeInt(this.value)}static create(){return new Dt(0)}static fromJson(n){var r;return new Dt((r=u.Json.readInt(n))!=null?r:0)}static fromBytes(n){const r=n.readInt();return new Dt(r)}}et.register(D.Int,Dt);class me extends En{constructor(t){super(Array.from(t!=null?t:[],n=>typeof n=="number"?new Dt(n):n))}getId(){return D.IntArray}equals(t){return t.isIntArray()&&this.length===t.length&&this.items.every((n,r)=>n.equals(t.items[r]))}getType(){return D.Int}get length(){return this.items.length}toString(){return"[I;"+this.items.map(n=>n.getAsNumber().toFixed()).join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsNumber())}toJson(){return this.items.map(t=>t.getAsNumber())}toBytes(t){t.writeInt(this.items.length);for(const n of this.items)t.writeInt(n.getAsNumber())}static create(){return new me}static fromJson(t){var r;const n=(r=u.Json.readArray(t,i=>{var s;return(s=u.Json.readNumber(i))!=null?s:0}))!=null?r:[];return new me(n)}static fromBytes(t){const n=t.readInt(),r=[];for(let i=0;inew n(i)))}getId(){return D.List}equals(n){return n.isList()&&this.type===n.type&&this.length===n.length&&this.items.every((r,i)=>r.equals(n.items[i]))}getType(){return this.type}getNumber(n){const r=this.get(n);return r!=null&&r.isNumber()?r.getAsNumber():0}getString(n){const r=this.get(n);return r!=null&&r.isString()?r.getAsString():""}getList(n,r){const i=this.get(n);return(i==null?void 0:i.isList())&&i.getType()===r?i:Tt.create()}getCompound(n){const r=this.get(n);return r!=null&&r.isCompound()?r:gt.create()}set(n,r){this.updateType(r),super.set(n,r)}add(n){this.updateType(n),super.add(n)}insert(n,r){this.updateType(r),super.insert(n,r)}updateType(n){if(n.getId()!==D.End){if(this.type===D.End)this.type=n.getId();else if(this.type!==n.getId())throw new Error(`Trying to add tag of type ${D[n.getId()]} to list of ${D[this.type]}`)}}clear(){super.clear(),this.type=D.End}toString(){return"["+this.items.map(n=>n.toString()).join(",")+"]"}toPrettyString(n=" ",r=0){if(this.length===0)return"[]";const i=n.repeat(r),s=n.repeat(r+1);return`[ `+this.map(a=>s+a.toPrettyString(n,r+1)).join(`, `)+` `+i+"]"}toSimplifiedJson(){return this.map(n=>n.toSimplifiedJson())}toJson(){return{type:this.type,items:this.items.map(n=>n.toJson())}}toBytes(n){this.items.length===0?this.type=D.End:this.type=this.items[0].getId(),n.writeByte(this.type),n.writeInt(this.items.length);for(const r of this.items)r.toBytes(n)}static create(){return new Tt}static fromJson(n){var a,o,g;const r=(a=u.Json.readObject(n))!=null?a:{},i=(o=u.Json.readNumber(r.type))!=null?o:D.Compound,s=((g=u.Json.readArray(r.items))!=null?g:[]).flatMap(c=>c!==void 0?[et.fromJson(c,i)]:[]);return new Tt(s,i)}static fromBytes(n){const r=n.readByte(),i=n.readInt();if(r===D.End&&i>0)throw new Error(`Missing type on ListTag but length is ${i}`);const s=[];for(let a=0;atypeof r=="number"?r:0):[0,0])}static fromBytes(n){const r=n.readInt(),i=n.readInt();return new ft([r,i])}};let Te=ft;_(Te,"dataview",new DataView(new Uint8Array(8).buffer)),et.register(D.Long,Te);class pe extends En{constructor(t){super(Array.from(t!=null?t:[],n=>typeof n=="bigint"||Array.isArray(n)?new Te(n):n))}getId(){return D.LongArray}equals(t){return t.isLongArray()&&this.length===t.length&&this.items.every((n,r)=>n.equals(t.items[r]))}getType(){return D.Long}get length(){return this.items.length}toString(){return"[I;"+this.items.map(n=>n.toString()).join(",")+"]"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.items.map(t=>t.getAsPair())}toJson(){return this.items.map(t=>t.getAsPair())}toBytes(t){t.writeInt(this.items.length);for(const n of this.items){const[r,i]=n.getAsPair();t.writeInt(r),t.writeInt(i)}}static create(){return new pe}static fromJson(t){var r;const n=(r=u.Json.readArray(t,i=>{var s;return(s=u.Json.readPair(i,a=>{var o;return(o=u.Json.readNumber(a))!=null?o:0}))!=null?s:[0,0]}))!=null?r:[];return new pe(n)}static fromBytes(t){const n=t.readInt(),r=[];for(let i=0;i{const t=new RegExp("^[-+]?(?:[0-9]+[.]|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?$","i"),n=new RegExp("^[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?d$","i"),r=new RegExp("^[-+]?(?:[0-9]+[.]?|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?f$","i"),i=new RegExp("^[-+]?(?:0|[1-9][0-9]*)b$","i"),s=new RegExp("^[-+]?(?:0|[1-9][0-9]*)l$","i"),a=new RegExp("^[-+]?(?:0|[1-9][0-9]*)s$","i"),o=new RegExp("^[-+]?(?:0|[1-9][0-9]*)$","i");function g(f){if(f.skipWhitespace(),!f.canRead())throw f.createError("Expected value");const p=f.peek();if(p==="{")return c(f);if(p==="[")if(f.canRead(3)&&!St.isQuotedStringStart(f.peek(1))&&f.peek(2)===";"){f.expect("[",!0);const v=f.cursor,m=f.read();if(f.skip(),f.skipWhitespace(),f.canRead()){if(m==="B")return h(f,ge,D.ByteArray,D.Byte);if(m==="L")return h(f,pe,D.LongArray,D.Long);if(m==="I")return h(f,me,D.IntArray,D.Int);throw f.cursor=v,f.createError(`Invalid array type '${m}'`)}else throw f.createError("Expected value")}else return l(f);else{f.skipWhitespace();const v=f.cursor;if(St.isQuotedStringStart(f.peek()))return new vt(f.readQuotedString());{const m=f.readUnquotedString();if(m.length===0)throw f.cursor=v,f.createError("Expected value");try{if(r.test(m)){const w=Number(m.substring(0,m.length-1));return new Be(w)}else if(i.test(m)){const w=Number(m.substring(0,m.length-1));return new Bt(Math.floor(w))}else if(s.test(m)){const w=BigInt(m.substring(0,m.length-1));return new Te(w)}else if(a.test(m)){const w=Number(m.substring(0,m.length-1));return new Le(Math.floor(w))}else if(o.test(m)){const w=Number(m);return new Dt(Math.floor(w))}else if(n.test(m)){const w=Number(m.substring(0,m.length-1));return new Qt(w)}else if(t.test(m)){const w=Number(m);return new Qt(w)}else{if(m.toLowerCase()==="true")return Bt.ONE;if(m.toLowerCase()==="false")return Bt.ZERO}}catch{}return m.length===0?vt.EMPTY:new vt(m)}}}e.readTag=g;function c(f){f.expect("{",!0);const p=new Map;for(f.skipWhitespace();f.canRead()&&f.peek()!=="}";){const v=f.cursor;if(f.skipWhitespace(),!f.canRead())throw f.createError("Expected key");const m=f.readString();if(m.length===0)throw f.cursor=v,f.createError("Expected key");f.expect(":",!0);const w=g(f);if(p.set(m,w),!d(f))break;if(!f.canRead())throw f.createError("Expected key")}return f.expect("}",!0),new gt(p)}function l(f){if(f.expect("[",!0),f.skipWhitespace(),!f.canRead())throw f.createError("Expected value");const p=[];let v=D.End;for(;f.peek()!=="]";){const m=f.cursor,w=g(f),S=w.getId();if(v===D.End)v=S;else if(S!==v)throw f.cursor=m,f.createError(`Can't insert ${D[S]} into list of ${D[v]}`);if(p.push(w),!d(f))break;if(!f.canRead())throw f.createError("Expected value")}return f.expect("]",!0),new Tt(p,v)}function h(f,p,v,m){const w=[];for(;f.peek()!=="]";){const S=g(f);if(S.getId()!==m)throw f.createError(`Can't insert ${D[S.getId()]} into ${D[v]}`);if(w.push(S.isLong()?S.getAsPair():S.getAsNumber()),!d(f))break;if(!f.canRead())throw f.createError("Expected value")}return f.expect("]"),new p(w)}function d(f){return f.skipWhitespace(),f.canRead()&&f.peek()===","?(f.skip(),f.skipWhitespace(),!0):!1}})(jn||(jn={}));class gt extends et{constructor(n){super();_(this,"properties");this.properties=n!=null?n:new Map}getId(){return D.Compound}equals(n){return n.isCompound()&&this.size===n.size&&[...this.properties.entries()].every(([r,i])=>{const s=n.properties.get(r);return s!==void 0&&i.equals(s)})}has(n){return this.properties.has(n)}hasNumber(n){var r,i;return(i=(r=this.get(n))==null?void 0:r.isNumber())!=null?i:!1}hasString(n){var r,i;return(i=(r=this.get(n))==null?void 0:r.isString())!=null?i:!1}hasList(n,r,i){var a;const s=this.get(n);return(a=(s==null?void 0:s.isList())&&(r===void 0||s.getType()===r)&&(i===void 0||s.length===i))!=null?a:!1}hasCompound(n){var r,i;return(i=(r=this.get(n))==null?void 0:r.isCompound())!=null?i:!1}get(n){return this.properties.get(n)}getString(n){var r,i;return(i=(r=this.get(n))==null?void 0:r.getAsString())!=null?i:""}getNumber(n){var r,i;return(i=(r=this.get(n))==null?void 0:r.getAsNumber())!=null?i:0}getBoolean(n){return this.getNumber(n)!==0}getList(n,r){const i=this.get(n);return(i==null?void 0:i.isList())&&(r===void 0||i.getType()===r)?i:Tt.create()}getCompound(n){const r=this.get(n);return r!=null&&r.isCompound()?r:gt.create()}getByteArray(n){const r=this.get(n);return r!=null&&r.isByteArray()?r:ge.create()}getIntArray(n){const r=this.get(n);return r!=null&&r.isIntArray()?r:me.create()}getLongArray(n){const r=this.get(n);return r!=null&&r.isLongArray()?r:pe.create()}keys(){return this.properties.keys()}get size(){return this.properties.size}map(n){return Object.fromEntries([...this.properties.entries()].map(([r,i])=>n(r,i,this)))}forEach(n){[...this.properties.entries()].forEach(([r,i])=>n(r,i,this))}set(n,r){return this.properties.set(n,r),this}delete(n){return this.properties.delete(n)}clear(){return this.properties.clear(),this}toString(){const n=[];for(const[r,i]of this.properties.entries()){const s=r.split("").some(a=>!St.isAllowedInUnquotedString(a));n.push((s?JSON.stringify(r):r)+":"+i.toString())}return"{"+n.join(",")+"}"}toPrettyString(n=" ",r=0){if(this.size===0)return"{}";const i=n.repeat(r),s=n.repeat(r+1),a=[];for(const[o,g]of this.properties.entries()){const c=o.split("").some(l=>!St.isAllowedInUnquotedString(l));a.push((c?JSON.stringify(o):o)+": "+g.toPrettyString(n,r+1))}return`{ `+a.map(o=>s+o).join(`, `)+` `+i+"}"}toSimplifiedJson(){return this.map((n,r)=>[n,r.toSimplifiedJson()])}toJson(){return this.map((n,r)=>[n,{type:r.getId(),value:r.toJson()}])}toBytes(n){for(const[r,i]of this.properties.entries()){const s=i.getId();n.writeByte(s),n.writeString(r),i.toBytes(n)}n.writeByte(D.End)}static create(){return new gt}static fromString(n){return jn.readTag(n)}static fromJson(n){const r=u.Json.readMap(n,i=>{var c;const{type:s,value:a}=(c=u.Json.readObject(i))!=null?c:{},o=u.Json.readNumber(s);return et.fromJson(a!=null?a:{},o)});return new gt(new Map(Object.entries(r)))}static fromBytes(n){const r=new Map;for(;;){const i=n.readByte();if(i===D.End)break;const s=n.readString(),a=et.fromBytes(n,i);r.set(s,a)}return new gt(r)}}et.register(D.Compound,gt);const be=class{constructor(t,n,r,i,s){this.name=t,this.root=n,this.compression=r,this.littleEndian=i,this.bedrockHeader=s}writeNamedTag(t){t.writeByte(D.Compound),t.writeString(this.name),this.root.toBytes(t)}write(){const t=this.littleEndian===!0||this.bedrockHeader!==void 0,n=new li({littleEndian:t,offset:this.bedrockHeader&&8});if(this.writeNamedTag(n),this.bedrockHeader!==void 0){const i=n.offset;n.offset=0,n.writeInt(this.bedrockHeader),n.writeInt(i-8),n.offset=i}const r=n.getData();return this.compression==="gzip"?Fr.gzip(r):this.compression==="zlib"?Fr.deflate(r):r}static readNamedTag(t){if(t.readByte()!==D.Compound)throw new Error("Top tag should be a compound");return{name:t.readString(),root:gt.fromBytes(t)}}static create(t={}){var o,g,c;const n=(o=t.name)!=null?o:be.DEFAULT_NAME,r=gt.create(),i=(g=t.compression)!=null?g:"none",s=typeof t.bedrockHeader=="boolean"?be.DEFAULT_BEDROCK_HEADER:t.bedrockHeader,a=(c=t.littleEndian)!=null?c:t.bedrockHeader!==void 0;return new be(n,r,i,a,s)}static read(t,n={}){var d;const r=typeof n.bedrockHeader=="number"?n.bedrockHeader:n.bedrockHeader?ra(t):void 0,i=n.compression==="gzip"||!r&&n.compression===void 0&&At(t),s=n.compression==="zlib"||!r&&n.compression===void 0&&Se(t),a=s||i?Fr.inflate(t):t,o=n.littleEndian||r!==void 0,g=i?"gzip":s?"zlib":"none",c=new ci(a,{littleEndian:o,offset:r&&8}),{name:l,root:h}=be.readNamedTag(c);return new be((d=n.name)!=null?d:l,h,g,o,r)}toJson(){var t;return{name:this.name,root:this.root.toJson(),compression:this.compression,littleEndian:this.littleEndian,bedrockHeader:(t=this.bedrockHeader)!=null?t:null}}static fromJson(t){var g,c,l,h,d;const n=(g=u.Json.readObject(t))!=null?g:{},r=(c=u.Json.readString(n.name))!=null?c:"",i=gt.fromJson((l=n.root)!=null?l:{}),s=(h=u.Json.readString(n.compression))!=null?h:"none",a=(d=u.Json.readBoolean(n.littleEndian))!=null?d:!1,o=u.Json.readNumber(n.bedrockHeader);return new be(r,i,s,a,o)}};let Vt=be;_(Vt,"DEFAULT_NAME",""),_(Vt,"DEFAULT_BEDROCK_HEADER",4);class Kt{constructor(t,n,r,i,s){_(this,"file");_(this,"dirty");this.x=t,this.z=n,this.compression=r,this.timestamp=i,this.raw=s,this.dirty=!1}getCompression(){switch(this.compression){case 1:return"gzip";case 2:return"zlib";case 3:return"none";default:throw new Error(`Invalid compression mode ${this.compression}`)}}setCompression(t){switch(t){case"gzip":this.compression=1;break;case"zlib":this.compression=2;break;case"none":this.compression=3;break;default:throw new Error(`Invalid compression mode ${t}`)}}getFile(){return this.file===void 0&&(this.file=Vt.read(this.raw,{compression:this.getCompression()})),this.file}getRoot(){return this.getFile().root}setRoot(t){this.file===void 0&&(this.file=Vt.create({compression:this.getCompression()})),this.file.root=t,this.markDirty()}markDirty(){this.dirty=!0}getRaw(){if(this.file===void 0||this.dirty===!1)return this.raw;this.file.compression=this.getCompression();const t=this.file.write();return this.raw=t,this.dirty=!1,t}toJson(){return{x:this.x,z:this.z,compression:this.compression,timestamp:this.timestamp,size:this.raw.byteLength}}toRef(t){return new Kt.Ref(this.x,this.z,this.compression,this.timestamp,this.raw.byteLength,t)}static create(t,n,r,i){const s=new Kt(t,n,0,i!=null?i:0,r.write());return s.setCompression(r.compression),s}static fromJson(t,n){var c,l,h,d,f,p;const r=(c=u.Json.readObject(t))!=null?c:{},i=(l=u.Json.readInt(r.x))!=null?l:0,s=(h=u.Json.readInt(r.z))!=null?h:0,a=(d=u.Json.readNumber(r.compression))!=null?d:2,o=(f=u.Json.readInt(r.timestamp))!=null?f:0,g=(p=u.Json.readInt(r.size))!=null?p:0;return new Kt.Ref(i,s,a,o,g,n)}}(e=>{class t{constructor(r,i,s,a,o,g){_(this,"file");this.x=r,this.z=i,this.compression=s,this.timestamp=a,this.size=o,this.resolver=g}getFile(){if(this.file instanceof Vt)return this.file}getRoot(){if(this.file instanceof Vt)return this.file.root}async getFileAsync(){return this.file?this.file:(this.file=(async()=>{const r=await this.resolver(this.x,this.z);return this.file=r,r})(),this.file)}async getRootAsync(){return(await this.getFileAsync()).root}isResolved(){return this.file instanceof Vt}}e.Ref=t})(Kt||(Kt={}));class Ns{constructor(t){_(this,"chunks");this.chunks=Array(32*32).fill(void 0);for(const n of t){const r=we.getIndex(n.x,n.z);this.chunks[r]=n}}getChunkPositions(){return this.chunks.flatMap(t=>t?[[t.x,t.z]]:[])}getChunk(t){if(!(t<0||t>=32*32))return this.chunks[t]}findChunk(t,n){return this.getChunk(we.getIndex(t,n))}getFirstChunk(){return this.chunks.filter(t=>t!==void 0)[0]}filter(t){return this.chunks.filter(n=>n!==void 0&&t(n))}map(t){return this.chunks.flatMap(n=>n!==void 0?[t(n)]:[])}}class we extends Ns{constructor(t){super(t)}write(){let t=0;for(const s of this.chunks)s!==void 0&&(t+=Math.ceil(s.getRaw().length/4096));const n=new Uint8Array(8192+t*4096),r=new DataView(n.buffer);let i=2;for(const s of this.chunks){if(s===void 0)continue;const a=s.getRaw(),o=4*((s.x&31)+(s.z&31)*32),g=Math.ceil(a.length/4096);r.setInt8(o,i>>16),r.setInt16(o+1,i&65535),r.setInt8(o+3,g),r.setInt32(o+4096,s.timestamp);const c=i*4096;r.setInt32(c,a.length+1),r.setInt8(c+4,s.compression),n.set(a,c+5),i+=g}return n}static read(t){const n=[];for(let r=0;r<32;r+=1)for(let i=0;i<32;i+=1){const s=4*((r&31)+(i&31)*32);if(t[s+3]===0)continue;const o=(t[s]<<16)+(t[s+1]<<8)+t[s+2],g=(t[s+4096]<<24)+(t[s+4097]<<16)+(t[s+4098]<<8)+t[s+4099],c=o*4096,l=(t[c]<<24)+(t[c+1]<<16)+(t[c+2]<<8)+t[c+3],h=t[c+4],d=t.slice(c+5,c+4+l);n.push(new Kt(r,i,h,g,d))}return new we(n)}static getIndex(t,n){return(t&31)+(n&31)*32}toJson(){return{chunks:this.map(t=>t.toJson())}}static fromJson(t,n){var a,o;const r=(a=u.Json.readObject(t))!=null?a:{},s=((o=u.Json.readArray(r.chunks))!=null?o:[]).flatMap(g=>g!==void 0?[Kt.fromJson(g,n)]:[]);return new we.Ref(s)}}(e=>{class t extends Ns{}e.Ref=t})(we||(we={}));class Qt extends et{constructor(n){super();_(this,"value");this.value=n}getId(){return D.Double}equals(n){return n.isDouble()&&this.value===n.value}getAsNumber(){return this.value}toString(){return Number.isInteger(this.value)?this.value.toFixed(1):this.value.toString()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(n){n.writeDouble(this.value)}static create(){return new Qt(0)}static fromJson(n){var r;return new Qt((r=u.Json.readNumber(n))!=null?r:0)}static fromBytes(n){const r=n.readDouble();return new Qt(r)}}et.register(D.Double,Qt);const Qe=class extends et{constructor(){super()}getId(){return D.End}equals(t){return t.isEnd()}toString(){return"END"}toPrettyString(){return this.toString()}toSimplifiedJson(){return null}toJson(){return null}toBytes(){}static create(){return Qe.INSTANCE}static fromJson(){return Qe.INSTANCE}static fromBytes(){return Qe.INSTANCE}};let In=Qe;_(In,"INSTANCE",new Qe),et.register(D.End,In);function Ur(e){return typeof e=="string"?new vt(e):typeof e=="number"?Number.isInteger(e)?new Dt(e):new Qt(e):typeof e=="boolean"?new Bt(e):Array.isArray(e)?new Tt(e.map(Ur)):typeof e=="object"&&e!==null?new gt(new Map(Object.entries(e!=null?e:{}).map(([t,n])=>[t,Ur(n)]))):new Bt(0)}u.Direction=(e=>(e.UP="up",e.DOWN="down",e.NORTH="north",e.EAST="east",e.SOUTH="south",e.WEST="west",e))(u.Direction||{});const nl={up:[0,1,0],down:[0,-1,0],north:[0,0,-1],east:[1,0,0],south:[0,0,1],west:[-1,0,0]};(e=>{e.ALL=["up","down","north","east","south","west"];function t(n){return nl[n]}e.normal=t})(u.Direction||(u.Direction={})),u.BlockPos=void 0,(e=>{function t(h,d,f){return[h,d,f]}e.create=t,e.ZERO=e.create(0,0,0);function n(h,d,f,p){return[h[0]+d,h[1]+f,h[2]+p]}e.offset=n;function r(h,d){return[h[0]-d[0],h[1]-d[1],h[2]-d[2]]}e.subtract=r;function i(h,d){return[h[0]+d[0],h[1]+d[1],h[2]+d[2]]}e.add=i;function s(h,d){return e.offset(h,...u.Direction.normal(d))}e.towards=s;function a(h,d){return h===d?!0:h[0]===d[0]&&h[1]===d[1]&&h[2]===d[2]}e.equals=a;function o(h){return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]}e.magnitude=o;function g(h){return new Tt(h.map(d=>new Dt(d)))}e.toNbt=g;function c(h){return h.getAsTuple(3,d=>d!=null&&d.isInt()?d.getAsNumber():0)}e.fromNbt=c;function l(h){var f;const d=(f=u.Json.readArray(h,p=>{var v;return(v=u.Json.readInt(p))!=null?v:0}))!=null?f:[0,0,0];return t(d[0],d[1],d[2])}e.fromJson=l})(u.BlockPos||(u.BlockPos={}));const ae=class{constructor(t,n){this.namespace=t,this.path=n}is(t){return this.equals(ae.parse(t))}equals(t){return this===t?!0:t instanceof ae?this.namespace===t.namespace&&this.path===t.path:!1}toString(){return this.namespace+ae.SEPARATOR+this.path}withPrefix(t){return new ae(this.namespace,t+this.path)}static create(t){return new ae(this.DEFAULT_NAMESPACE,t)}static parse(t){const n=t.indexOf(this.SEPARATOR);if(n>=0){const r=n>=1?t.substring(0,n):this.DEFAULT_NAMESPACE,i=t.substring(n+1);return new ae(r,i)}return new ae(this.DEFAULT_NAMESPACE,t)}};let C=ae;_(C,"DEFAULT_NAMESPACE","minecraft"),_(C,"SEPARATOR",":");const bt=class{constructor(t,n={}){_(this,"name");this.properties=n,this.name=typeof t=="string"?C.parse(t):t}getName(){return this.name}getProperties(){return this.properties}getProperty(t){return this.properties[t]}isFluid(){return this.is(bt.WATER)||this.is(bt.LAVA)}isWaterlogged(){return this.is(bt.WATER)||this.is(bt.LAVA)||this.is("bubble_column")||this.is("kelp")||this.is("kelp_plant")||this.is("seagrass")||this.is("tall_seagrass")||this.properties.waterlogged==="true"}equals(t){return this.name.equals(t.name)?Object.keys(this.properties).every(n=>t.properties[n]===this.properties[n]):!1}is(t){return typeof t=="string"?this.name.equals(C.parse(t)):t instanceof C?this.name.equals(t):this.name.equals(t.name)}toString(){return Object.keys(this.properties).length===0?this.name.toString():`${this.name.toString()}[${Object.entries(this.properties).map(([t,n])=>t+"="+n).join(",")}]`}static parse(t){const n=t.indexOf("[");if(n===-1)return new bt(t);{const r=t.substring(0,n),i=t.substring(n+1,t.length-1).split(","),s=Object.fromEntries(i.map(a=>a.split("=")));return new bt(r,s)}}static fromNbt(t){const n=C.parse(t.getString("Name")),r=t.getCompound("Properties").map((i,s)=>[i,s.getAsString()]);return new bt(n,r)}static fromJson(t){var s,a;const n=(s=u.Json.readObject(t))!=null?s:{},r=C.parse((a=u.Json.readString(n.Name))!=null?a:bt.STONE.name.toString()),i=u.Json.readMap(n.Properties,o=>{var g;return(g=u.Json.readString(o))!=null?g:""});return new bt(r,i)}};let j=bt;_(j,"AIR",new bt(C.create("air"))),_(j,"STONE",new bt(C.create("stone"))),_(j,"WATER",new bt(C.create("water"),{level:"0"})),_(j,"LAVA",new bt(C.create("lava"),{level:"0"}));class Cs{constructor(t,n){_(this,"storage");_(this,"palette");this.size=t,this.defaultValue=n,this.storage=Array(t).fill(0),this.palette=[n]}index(t,n,r){return(t<<8)+(n<<4)+r}get(t,n,r){const i=this.storage[this.index(t,n,r)];return this.palette[i]}set(t,n,r,i){let s=this.palette.findIndex(a=>a.equals(i));s===-1&&(s=this.palette.length,this.palette.push(i)),this.storage[this.index(t,n,r)]=s}}const tn=class{constructor(t){_(this,"states");this.minY=t,this.states=new Cs(tn.SIZE,j.AIR)}get minBlockY(){return this.minY<<4}getBlockState(t,n,r){return this.states.get(t,n,r)}setBlockState(t,n,r,i){this.states.set(t,n,r,i)}};let qe=tn;_(qe,"WIDTH",16),_(qe,"SIZE",tn.WIDTH*tn.WIDTH*tn.WIDTH);class rl{constructor(t,n,r){_(this,"sections");this.minY=t,this.height=n,this.pos=r,this.sections=Array(this.sectionsCount).fill(null)}get maxY(){return this.minY+this.height}get minSection(){return this.minY>>4}get maxSection(){return(this.maxY-1>>4)+1}get sectionsCount(){return this.maxSection-this.minSection}getSectionIndex(t){return(t>>4)-this.minSection}getBlockState(t){var a;const[n,r,i]=t,s=this.sections[this.getSectionIndex(r)];return(a=s==null?void 0:s.getBlockState(n&15,r&15,i&15))!=null?a:j.AIR}setBlockState(t,n){const[r,i,s]=t,a=this.getSectionIndex(i);let o=this.sections[a];if(o===null){if(n.equals(j.AIR))return;o=this.getOrCreateSection(a)}o.setBlockState(r&15,i&15,s&15,n)}getOrCreateSection(t){return this.sections[t]==null&&(this.sections[t]=new qe(this.minSection+t)),this.sections[t]}}u.ChunkPos=void 0,(e=>{function t(l,h){return[l,h]}e.create=t;function n(l){return[l[0]>>4,l[2]>>4]}e.fromBlockPos=n;function r(l){return[Number(l)&4294967295,Number(l>>BigInt(32))]}e.fromLong=r;function i(l){return s(l[0],l[1])}e.toLong=i;function s(l,h){return BigInt(l&4294967295)|BigInt(h&4294967295)<{function t(n){return{effect:C.parse(n.getString("id")),duration:n.getNumber("duration"),amplifier:n.getNumber("amplifier")}}e.fromNbt=t})(u.MobEffectInstance||(u.MobEffectInstance={}));const Ts=new Map([["minecraft:empty",[]],["minecraft:water",[]],["minecraft:mundane",[]],["minecraft:thick",[]],["minecraft:awkward",[]],["minecraft:night_vision",[{effect:C.create("night_vision"),duration:3600,amplifier:0}]],["minecraft:long_night_vision",[{effect:C.create("night_vision"),duration:9600,amplifier:0}]],["minecraft:invisibility",[{effect:C.create("invisibility"),duration:3600,amplifier:0}]],["minecraft:long_invisibility",[{effect:C.create("invisibility"),duration:9600,amplifier:0}]],["minecraft:leaping",[{effect:C.create("jump_boost"),duration:3600,amplifier:0}]],["minecraft:long_leaping",[{effect:C.create("jump_boost"),duration:9600,amplifier:0}]],["minecraft:strong_leaping",[{effect:C.create("jump_boost"),duration:1800,amplifier:1}]],["minecraft:fire_resistance",[{effect:C.create("fire_resistance"),duration:3600,amplifier:0}]],["minecraft:long_fire_resistance",[{effect:C.create("fire_resistance"),duration:9600,amplifier:0}]],["minecraft:swiftness",[{effect:C.create("speed"),duration:3600,amplifier:0}]],["minecraft:long_swiftness",[{effect:C.create("speed"),duration:9600,amplifier:0}]],["minecraft:strong_swiftness",[{effect:C.create("speed"),duration:1800,amplifier:1}]],["minecraft:slowness",[{effect:C.create("slowness"),duration:1800,amplifier:0}]],["minecraft:long_slowness",[{effect:C.create("slowness"),duration:4800,amplifier:0}]],["minecraft:strong_slowness",[{effect:C.create("slowness"),duration:400,amplifier:3}]],["minecraft:turtle_master",[{effect:C.create("slowness"),duration:400,amplifier:3},{effect:C.create("resistance"),duration:400,amplifier:2}]],["minecraft:long_turtle_master",[{effect:C.create("slowness"),duration:800,amplifier:3},{effect:C.create("resistance"),duration:800,amplifier:2}]],["minecraft:strong_turtle_master",[{effect:C.create("slowness"),duration:400,amplifier:5},{effect:C.create("resistance"),duration:400,amplifier:3}]],["minecraft:water_breathing",[{effect:C.create("water_breathing"),duration:3600,amplifier:0}]],["minecraft:long_water_breathing",[{effect:C.create("water_breathing"),duration:9600,amplifier:0}]],["minecraft:healing",[{effect:C.create("instant_health"),duration:1,amplifier:0}]],["minecraft:strong_healing",[{effect:C.create("instant_health"),duration:1,amplifier:1}]],["minecraft:harming",[{effect:C.create("instant_damage"),duration:1,amplifier:0}]],["minecraft:strong_harming",[{effect:C.create("instant_damage"),duration:1,amplifier:1}]],["minecraft:poison",[{effect:C.create("poison"),duration:900,amplifier:0}]],["minecraft:long_poison",[{effect:C.create("poison"),duration:1800,amplifier:0}]],["minecraft:strong_poison",[{effect:C.create("poison"),duration:432,amplifier:1}]],["minecraft:regeneration",[{effect:C.create("regeneration"),duration:900,amplifier:0}]],["minecraft:long_regeneration",[{effect:C.create("regeneration"),duration:1800,amplifier:0}]],["minecraft:strong_regeneration",[{effect:C.create("regeneration"),duration:450,amplifier:1}]],["minecraft:strength",[{effect:C.create("strength"),duration:3600,amplifier:0}]],["minecraft:long_strength",[{effect:C.create("strength"),duration:9600,amplifier:0}]],["minecraft:strong_strength",[{effect:C.create("strength"),duration:1800,amplifier:1}]],["minecraft:weakness",[{effect:C.create("weakness"),duration:1800,amplifier:0}]],["minecraft:long_weakness",[{effect:C.create("weakness"),duration:4800,amplifier:0}]],["minecraft:luck",[{effect:C.create("luck"),duration:6e3,amplifier:0}]],["minecraft:slow_falling",[{effect:C.create("slow_falling"),duration:1800,amplifier:0}]],["minecraft:long_slow_falling",[{effect:C.create("slow_falling"),duration:4800,amplifier:0}]],["minecraft:wind_charged",[{effect:C.create("wind_charged"),duration:3600,amplifier:0}]],["minecraft:weaving",[{effect:C.create("weaving"),duration:3600,amplifier:0}]],["minecraft:oozing",[{effect:C.create("oozing"),duration:3600,amplifier:0}]],["minecraft:infested",[{effect:C.create("infested"),duration:3600,amplifier:0}]]]);u.PotionContents=void 0,(e=>{function t(s){const a={};return s.isString()?a.potion=C.parse(s.getAsString()):s.isCompound()&&(s.hasString("potion")&&(a.potion=C.parse(s.getString("potion"))),s.hasNumber("custom_color")&&(a.customColor=s.getNumber("custom_color")),s.hasList("custom_effects")&&(a.customEffects=s.getList("custom_effects",D.Compound).map(u.MobEffectInstance.fromNbt))),a}e.fromNbt=t;function n(s){if(s.customColor)return u.Color.intToRgb(s.customColor);const a=r(s);return i(a)}e.getColor=n;function r(s){var o;const a=[];return s.potion&&a.push(...(o=Ts.get(s.potion.toString()))!=null?o:[]),s.customEffects&&a.push(...s.customEffects),a}e.getAllEffects=r;function i(s){let[a,o,g]=[0,0,0],c=0;for(const l of s){const h=Bs.get(l.effect.toString());if(h===void 0)continue;const d=u.Color.intToRgb(h),f=l.amplifier+1;a+=f*d[0],o+=f*d[1],g+=f*d[2],c+=f}return c===0?u.Color.intToRgb(-13083194):(a=a/c,o=o/c,g=g/c,[a,o,g])}})(u.PotionContents||(u.PotionContents={})),u.Holder=void 0,(e=>{function t(i,s){return a=>typeof a=="string"?r(i,C.parse(a)):n(s(a))}e.parser=t;function n(i,s){return{value:()=>i,key:()=>s}}e.direct=n;function r(i,s,a=!0){return a?{value:()=>i.getOrThrow(s),key:()=>s}:{value:()=>i.get(s),key:()=>s}}e.reference=r})(u.Holder||(u.Holder={}));class ve{constructor(t){this.entries=t}static parser(t,n){const r=n!=null?n:i=>{var s;return u.Holder.reference(t,C.parse((s=u.Json.readString(i))!=null?s:""))};return i=>{var s,a;return typeof i=="string"?i.startsWith("#")?u.Holder.reference(t.getTagRegistry(),C.parse(i.substring(1))):u.Holder.direct(new ve([])):u.Holder.direct((a=new ve((s=u.Json.readArray(i,r))!=null?s:[]))!=null?a:[])}}static fromJson(t,n,r){var o,g,c;const i=(o=u.Json.readObject(n))!=null?o:{},s=(g=u.Json.readBoolean(i.replace))!=null?g:!1,a=(c=u.Json.readArray(i.values,l=>{var f,p,v;var h=!0,d="";if(typeof l=="string")d=l;else{const m=(f=u.Json.readObject(l))!=null?f:{};h=(p=u.Json.readBoolean(m.required))!=null?p:!1,d=(v=u.Json.readString(m.id))!=null?v:""}return d.startsWith("#")?u.Holder.reference(t.getTagRegistry(),C.parse(d.substring(1)),h):u.Holder.reference(t,C.parse(d),h)}))!=null?c:[];return r&&!s&&t.getTagRegistry().has(r)&&(a==null||a.push(u.Holder.direct(t.getTagRegistry().get(r)))),new ve(a)}*getEntries(){for(const t of this.entries){const n=t.value();n!==void 0&&(n instanceof ve?yield*n.getEntries():yield t)}}}class $t{constructor(t,n,r=new Map){this.id=t,this.count=n,this.components=r}getComponent(t,n){var i;if(typeof t=="string"&&(t=C.parse(t)),this.components.has("!"+t.toString()))return;const r=this.components.get(t.toString());if(r)return r;if(n)return(i=n.getItemComponents(this.id))==null?void 0:i.get(t.toString())}hasComponent(t,n){var r;return typeof t=="string"&&(t=C.parse(t)),this.components.has("!"+t.toString())?!1:this.components.has(t.toString())?!0:n?(r=n.getItemComponents(this.id))==null?void 0:r.has(t.toString()):!1}clone(){const t=new Map(this.components);return new $t(this.id,this.count,t)}is(t){return typeof t=="string"?this.id.equals(C.parse(t)):t instanceof C?this.id.equals(t):this.id.equals(t.id)}equals(t){return this===t?!0:t instanceof $t?this.count===t.count&&this.isSameItemSameComponents(t):!1}isSameItemSameComponents(t){if(!this.id.equals(t.id)||this.components.size!==t.components.size)return!1;for(const[n,r]of this.components){const i=t.components.get(n);if(r.toString()!==(i==null?void 0:i.toString()))return!1}return!0}toString(){let t=this.id.toString();return this.components.size>0&&(t+=`[${[...this.components.entries()].map(([n,r])=>n.startsWith("!")?n:`${n}=${r.toString()}`).join(",")}]`),this.count>1&&(t+=` ${this.count}`),t}static fromString(t){const n=new St(t);for(;n.canRead()&&n.peek()!=="[";)n.skip();const r=C.parse(n.getRead());if(!n.canRead())return new $t(r,1);const i=new Map;if(n.skip(),n.peek()==="]")return new $t(r,1,i);do{if(n.peek()==="!"){n.skip();const s=n.cursor;for(;n.canRead()&&n.peek()!=="]"&&n.peek()!==",";)n.skip();i.set("!"+C.parse(n.getRead(s)).toString(),new gt)}else{const s=n.cursor;for(;n.canRead()&&n.peek()!=="=";)n.skip();const a=C.parse(n.getRead(s)).toString();if(!n.canRead())break;n.skip();const o=jn.readTag(n);i.set(a,o)}if(!n.canRead())break;if(n.peek()==="]")return new $t(r,1,i);if(n.peek()!==",")throw new Error("Expected , or ]");n.skip()}while(n.canRead());throw new Error("Missing closing ]")}toNbt(){const t=new gt().set("id",new vt(this.id.toString()));return this.count>1&&t.set("count",new Dt(this.count)),this.components.size>0&&t.set("components",new gt(this.components)),t}static fromNbt(t){const n=C.parse(t.getString("id")),r=t.hasNumber("count")?t.getNumber("count"):1,i=new Map(Object.entries(t.getCompound("components").map((s,a)=>s.startsWith("!")?["!"+C.parse(s).toString(),new gt]:[C.parse(s).toString(),a])));return new $t(n,r,i)}}const Ue=class{constructor(t,n){_(this,"storage",new Map);_(this,"builtin",new Map);_(this,"tags");this.key=t,this.parser=n}static createAndRegister(t,n){const r=new Ue(C.create(t),n);return Ue.REGISTRY.register(r.key,r),r}register(t,n,r){return this.storage.set(t.toString(),n),r&&this.builtin.set(t.toString(),n),u.Holder.reference(this,t)}delete(t){const n=this.storage.delete(t.toString());return this.builtin.delete(t.toString()),n}keys(){return[...this.storage.keys()].map(t=>C.parse(t))}has(t){return this.storage.has(t.toString())}get(t){var n=this.storage.get(t.toString());return n instanceof Function&&(n=n(),this.storage.set(t.toString(),n)),n}getOrThrow(t){const n=this.get(t);if(n===void 0)throw new Error(`Missing key in ${this.key.toString()}: ${t.toString()}`);return n}parse(t){if(!this.parser)throw new Error(`No parser exists for ${this.key.toString()}`);return this.parser(t)}clear(){this.storage.clear();for(const[t,n]of this.builtin.entries())this.storage.set(t,n);return this.tags&&this.tags.clear(),this}assign(t){if(!this.key.equals(t.key))throw new Error(`Cannot assign registry of type ${t.key.toString()} to registry of type ${this.key.toString()}`);for(const n of t.keys())this.storage.set(n.toString(),t.getOrThrow(n));return this}cloneEmpty(){return new Ue(this.key,this.parser)}forEach(t){for(const[n,r]of this.storage.entries())t(C.parse(n),r instanceof Function?r():r,this)}map(t){return[...this.storage.entries()].map(([n,r])=>t(C.parse(n),r instanceof Function?r():r,this))}getTagRegistry(){return this.tags===void 0&&(this.tags=new Ue(new C(this.key.namespace,`tags/${this.key.path}`))),this.tags}};let xt=Ue;_(xt,"REGISTRY",new Ue(C.create("root"))),u.Rotation=(e=>(e.NONE="none",e.CLOCKWISE_90="clockwise_90",e.CLOCKWISE_180="180",e.COUNTERCLOCKWISE_90="counterclockwise_90",e))(u.Rotation||{}),(e=>{function t(n){return["none","clockwise_90","180","counterclockwise_90"][n.nextInt(4)]}e.getRandom=t})(u.Rotation||(u.Rotation={}));const gr=class{constructor(t,n=[],r=[]){_(this,"blocksMap",[]);this.size=t,this.palette=n,this.blocks=r,r.forEach(i=>{if(!this.isInside(i.pos))throw new Error(`Found block at ${i.pos} which is outside the structure bounds ${this.size}`);this.blocksMap[i.pos[0]*t[1]*t[2]+i.pos[1]*t[2]+i.pos[2]]=i})}getSize(){return this.size}addBlock(t,n,r,i){if(!this.isInside(t))throw new Error(`Cannot add block at ${t} outside the structure bounds ${this.size}`);const s=new j(n,r);let a=this.palette.findIndex(o=>o.equals(s));return a===-1&&(a=this.palette.length,this.palette.push(s)),this.blocks.push({pos:t,state:a,nbt:i}),this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]]={pos:t,state:a,nbt:i},this}getBlocks(){return this.blocks.map(t=>this.toPlacedBlock(t))}getBlock(t){if(!this.isInside(t))return null;const n=this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]];return n?this.toPlacedBlock(n):null}toPlacedBlock(t){const n=this.palette[t.state];if(!n)throw new Error(`Block at ${t.pos.join(" ")} in structure references invalid palette index ${t.state}`);return{pos:t.pos,state:n,nbt:t.nbt}}isInside(t){return t[0]>=0&&t[0]=0&&t[1]=0&&t[2]j.fromNbt(s)),i=t.getList("blocks",D.Compound).map(s=>{const a=u.BlockPos.fromNbt(s.getList("pos")),o=s.getNumber("state"),g=s.getCompound("nbt");return{pos:a,state:o,nbt:g.size>0?g:void 0}});return new gr(n,r,i)}static transform(t,n,r){switch(n){case u.Rotation.COUNTERCLOCKWISE_90:return u.BlockPos.create(r[0]-r[2]+t[2],t[1],r[0]+r[2]-t[0]);case u.Rotation.CLOCKWISE_90:return u.BlockPos.create(r[0]+r[2]-t[2],t[1],r[2]-r[0]+t[0]);case u.Rotation.CLOCKWISE_180:return u.BlockPos.create(r[0]+r[0]-t[0],t[1],r[2]+r[2]-t[2]);default:return t}}};let te=gr;_(te,"REGISTRY",xt.createAndRegister("structures")),_(te,"EMPTY",new gr(u.BlockPos.ZERO));function ee(e){return e*e}function Mt(e,t,n){return Math.max(t,Math.min(n,e))}function ne(e,t,n){return t+e*(n-t)}function Kn(e,t,n,r,i,s){return ne(t,ne(e,n,r),ne(e,i,s))}function Ls(e,t,n,r,i,s,a,o,g,c,l){return ne(n,Kn(e,t,r,i,s,a),Kn(e,t,o,g,c,l))}function kn(e,t,n){return e===0?t():e===1?n():t()+e*(n()-t())}function Hr(e,t,n,r,i,s){return kn(t,()=>kn(e,n,r),()=>kn(e,i,s))}function Ps(e,t,n,r,i,s,a,o,g,c,l){return kn(n,()=>Hr(e,t,r,i,s,a),()=>Hr(e,t,o,g,c,l))}function Qn(e,t,n){return n<0?e:n>1?t:ne(n,e,t)}function Zr(e,t,n){return(e-t)/(n-t)}function tr(e){return e*e*e*(e*(e*6-15)+10)}function An(e,t,n,r,i){return ne(Zr(e,t,n),r,i)}function Gr(e,t,n,r,i){return Qn(r,i,Zr(e,t,n))}function Os(e,t,n){let r=t-e;for(;r>0;){const i=Math.floor(r/2),s=e+i;if(n(s)){r=i;continue}e=s+1,r-=i+1}return e}function Vr(e,t,n){let r=BigInt(e*3129871)^BigInt(n)*BigInt(116129781)^BigInt(t);return r=r*r*BigInt(42317861)+r*BigInt(11),r>>BigInt(16)}function er(e,t,n,r,i,s,a,o){return BigInt(e)<>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>18,e|=e>>32,e+1}function nr(e,t,n){return e.nextInt(n-t+1)+t}function rr(e,t,n){return t>=n?t:e.nextInt(n-t+1)+t}function zs(e,t){for(var n=e.length;n>1;n--){const r=t.nextInt(n),i=e[r];e[r]=e[n-1],e[n-1]=i}}u.MinMaxNumberFunction=void 0,(e=>{function t(n){return typeof n=="object"&&n!==null&&"minValue"in n&&"maxValue"in n}e.is=t})(u.MinMaxNumberFunction||(u.MinMaxNumberFunction={})),u.CubicSpline=void 0,(e=>{function t(i,s){var c,l,h,d;if(typeof i=="number")return new n(i);const a=(c=u.Json.readObject(i))!=null?c:{},o=new r(s(a.coordinate)),g=(l=u.Json.readArray(a.points,f=>{var p;return(p=u.Json.readObject(f))!=null?p:{}}))!=null?l:[];if(g.length===0)return new n(0);for(const f of g){const p=(h=u.Json.readNumber(f.location))!=null?h:0,v=t(f.value,s),m=(d=u.Json.readNumber(f.derivative))!=null?d:0;o.addPoint(p,v,m)}return o}e.fromJson=t;class n{constructor(s){this.value=s}compute(){return this.value}min(){return this.value}max(){return this.value}mapAll(){return this}calculateMinMax(){}}e.Constant=n;class r{constructor(s,a=[],o=[],g=[]){_(this,"calculatedMin",Number.NEGATIVE_INFINITY);_(this,"calculatedMax",Number.POSITIVE_INFINITY);this.coordinate=s,this.locations=a,this.values=o,this.derivatives=g}compute(s){const a=this.coordinate.compute(s),o=Os(0,this.locations.length,E=>aa.mapAll(s)),this.derivatives)}addPoint(s,a,o=0){return this.locations.push(s),this.values.push(typeof a=="number"?new e.Constant(a):a),this.derivatives.push(o),this}calculateMinMax(){if(!u.MinMaxNumberFunction.is(this.coordinate))return;const s=this.locations.length-1;var a=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;const g=this.coordinate.minValue(),c=this.coordinate.maxValue();for(const h of this.values)h.calculateMinMax();if(gthis.locations[s]){const h=r.linearExtend(c,this.locations,this.values[s].min(),this.derivatives,s),d=r.linearExtend(c,this.locations,this.values[s].max(),this.derivatives,s);a=Math.min(a,Math.min(h,d)),o=Math.max(o,Math.max(h,d))}for(const h of this.values)a=Math.min(a,h.min()),o=Math.max(o,h.max());for(var l=0;l>>32-r},rotr:function(n,r){return n<<32-r|n>>>r},endian:function(n){if(n.constructor==Number)return t.rotl(n,8)&16711935|t.rotl(n,24)&4278255360;for(var r=0;r0;n--)r.push(Math.floor(Math.random()*256));return r},bytesToWords:function(n){for(var r=[],i=0,s=0;i>>5]|=n[i]<<24-s%32;return r},wordsToBytes:function(n){for(var r=[],i=0;i>>5]>>>24-i%32&255);return r},bytesToHex:function(n){for(var r=[],i=0;i>>4).toString(16)),r.push((n[i]&15).toString(16));return r.join("")},hexToBytes:function(n){for(var r=[],i=0;i>>6*(3-a)&63)):r.push("=");return r.join("")},base64ToBytes:function(n){n=n.replace(/[^A-Z0-9+\/]/ig,"");for(var r=[],i=0,s=0;i>>6-s*2);return r}};Fs.exports=t})();var jr={utf8:{stringToBytes:function(e){return jr.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(jr.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n * @license MIT */var Fl=function(e){return e!=null&&(Hs(e)||Ul(e)||!!e._isBuffer)};function Hs(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function Ul(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Hs(e.slice(0,0))}(function(){var e=Fs.exports,t=Us.utf8,n=Fl,r=Us.bin,i=function(s,a){s.constructor==String?a&&a.encoding==="binary"?s=r.stringToBytes(s):s=t.stringToBytes(s):n(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var o=e.bytesToWords(s),g=s.length*8,c=1732584193,l=-271733879,h=-1732584194,d=271733878,f=0;f>>24)&16711935|(o[f]<<24|o[f]>>>8)&4278255360;o[g>>>5]|=128<>>9<<4)+14]=g;for(var p=i._ff,v=i._gg,m=i._hh,w=i._ii,f=0;f>>0,l=l+E>>>0,h=h+y>>>0,d=d+k>>>0}return e.endian([c,l,h,d])};i._ff=function(s,a,o,g,c,l,h){var d=s+(a&o|~a&g)+(c>>>0)+h;return(d<>>32-l)+a},i._gg=function(s,a,o,g,c,l,h){var d=s+(a&g|o&~g)+(c>>>0)+h;return(d<>>32-l)+a},i._hh=function(s,a,o,g,c,l,h){var d=s+(a^o^g)+(c>>>0)+h;return(d<>>32-l)+a},i._ii=function(s,a,o,g,c,l,h){var d=s+(o^(a|~g))+(c>>>0)+h;return(d<>>32-l)+a},i._blocksize=16,i._digestsize=16,Xr.exports=function(s,a){if(s==null)throw new Error("Illegal argument "+s);var o=e.wordsToBytes(i(s,a));return a&&a.asBytes?o:a&&a.asString?r.bytesToString(o):e.bytesToHex(o)}})();const Rt=class{constructor(t){_(this,"seed",BigInt(0));this.setSeed(t)}static fromLargeFeatureSeed(t,n,r){const i=new Rt(t),s=i.nextLong(),a=i.nextLong(),o=BigInt(n)*s^BigInt(r)*a^t;return i.setSeed(o),i}static fromLargeFeatureWithSalt(t,n,r,i){const s=BigInt(n)*BigInt("341873128712")+BigInt(r)*BigInt("132897987541")+t+BigInt(i);return new Rt(s)}fork(){return new Rt(this.nextLong())}forkPositional(){return new Zs(this.nextLong())}setSeed(t){this.seed=(t^Rt.MULTIPLIER)&Rt.MODULUS_MASK}advance(){this.seed=this.seed*Rt.MULTIPLIER+Rt.INCREMENT&Rt.MODULUS_MASK}consume(t){for(let n=0;n>BigInt(Rt.MODULUS_BITS-t));return n>2147483647?n-4294967296:n}nextInt(t){if(t===void 0)return this.next(32);if((t&t-1)==0)return Number(BigInt(t)*BigInt(this.next(31))>>BigInt(31));let n,r;for(;(n=this.next(31))-(r=n%t)+(t-1)<0;);return r}nextLong(){return(BigInt(this.next(32))<>$.BIGINT_30)*$.STAFFORD_1&$.MAX_ULONG,t=(t^t>>$.BIGINT_27)*$.STAFFORD_2&$.MAX_ULONG,(t^t>>$.BIGINT_31)&$.MAX_ULONG}static upgradeSeedTo128bit(t){t<0&&(t+=$.POW2_60);const n=t^$.SILVER_RATIO_64,r=n+$.GOLDEN_RATIO_64&$.MAX_ULONG;return[$.mixStafford13(n),$.mixStafford13(r)]}static rotateLeft(t,n){return t<>$.BIGINT_64-n}setSeed(t){this.seed=$.upgradeSeedTo128bit(t)}fork(){return new $([this.next(),this.next()])}forkPositional(){return new Gs(this.next(),this.next())}next(){const t=this.seed[0];let n=this.seed[1];const r=$.rotateLeft(t+n&$.MAX_ULONG,$.BIGINT_17)+t&$.MAX_ULONG;return n^=t,this.seed=[$.rotateLeft(t,$.BIGINT_49)^n^n<<$.BIGINT_21&$.MAX_ULONG,$.rotateLeft(n,$.BIGINT_28)],r}nextLong(){let t=this.next();return t>$.POW2_63&&(t-=$.POW2_60),t}consume(t){let n=this.seed[0],r=this.seed[1];for(let i=0;i>BigInt(64-t)}nextInt(t){let n=this.next()&$.MAX_UINT;if(t){const r=BigInt(t);let i=n*r,s=i&$.MAX_UINT;if(s>$.BIGINT_32;return Number(a)}else{let r=Number(n);return r>=2147483648&&(r-=4294967296),r}}nextFloat(){return Number(this.nextBits(24))*$.FLOAT_MULTIPLIER}nextDouble(){return Number(this.nextBits(53))*$.DOUBLE_MULTIPLIER}parityConfigString(){return"seedLo: "+this.seed[0]+", seedHi: "+this.seed[1]}};let nt=$;_(nt,"SILVER_RATIO_64",BigInt("7640891576956012809")),_(nt,"GOLDEN_RATIO_64",BigInt("-7046029254386353131")),_(nt,"FLOAT_MULTIPLIER",1/Math.pow(2,24)),_(nt,"DOUBLE_MULTIPLIER",11102230246251565e-32),_(nt,"BIGINT_1",BigInt(1)),_(nt,"BIGINT_17",BigInt(17)),_(nt,"BIGINT_21",BigInt(21)),_(nt,"BIGINT_27",BigInt(27)),_(nt,"BIGINT_28",BigInt(28)),_(nt,"BIGINT_30",BigInt(30)),_(nt,"BIGINT_31",BigInt(31)),_(nt,"BIGINT_32",BigInt(32)),_(nt,"BIGINT_49",BigInt(49)),_(nt,"BIGINT_64",BigInt(64)),_(nt,"STAFFORD_1",BigInt("-4658895280553007687")),_(nt,"STAFFORD_2",BigInt("-7723592293110705685")),_(nt,"MAX_ULONG",BigInt("0xFFFFFFFFFFFFFFFF")),_(nt,"POW2_60",BigInt("0x10000000000000000")),_(nt,"POW2_63",BigInt("0x8000000000000000")),_(nt,"MAX_UINT",BigInt(4294967295));class Gs{constructor(t,n){this.seedLo=t,this.seedHi=n}at(t,n,r){const s=Vr(t,n,r)^this.seedLo;return new nt([s,this.seedHi])}fromHashOf(t){const n=Xr.exports(t,{asBytes:!0}),r=er(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]),i=er(n[8],n[9],n[10],n[11],n[12],n[13],n[14],n[15]);return new nt([r^this.seedLo,i^this.seedHi])}seedKey(){return[this.seedLo,this.seedHi]}}const qt=class{constructor(t){_(this,"p");_(this,"xo");_(this,"yo");_(this,"zo");this.xo=t.nextDouble()*256,this.yo=t.nextDouble()*256,this.zo=t.nextDouble()*256,this.p=Array(256);for(let n=0;n<256;n+=1)this.p[n]=n;for(let n=0;n<256;n+=1){const r=t.nextInt(256-n),i=this.p[n];this.p[n]=this.p[n+r],this.p[n+r]=i}}sample2D(t,n){let r,i,s;const a=(t+n)*qt.F2,o=Math.floor(t+a),g=o-(r=(o+(i=Math.floor(n+a)))*qt.G2),c=t-g;let l,h;c>(s=n-(i-r))?(l=1,h=0):(l=0,h=1);const d=c-l+qt.G2,f=s-h+qt.G2,p=c-1+2*qt.G2,v=s-1+2*qt.G2,m=o&255,w=i&255,S=this.P(m+this.P(w))%12,E=this.P(m+l+this.P(w+h))%12,y=this.P(m+1+this.P(w+1))%12,k=this.getCornerNoise3D(S,c,s,0,.5),R=this.getCornerNoise3D(E,d,f,0,.5),I=this.getCornerNoise3D(y,p,v,0,.5);return 70*(k+R+I)}sample(t,n,r){const i=(t+n+r)*.3333333333333333,s=Math.floor(t+i),a=Math.floor(n+i),o=Math.floor(r+i),g=(s+a+o)*.16666666666666666,c=t-(s-g),l=n-(a-g),h=r-(o-g);let d,f,p,v,m,w;c>=l?l>=h?(d=1,f=0,p=0,v=1,m=1,w=0):c>=h?(d=1,f=0,p=0,v=1,m=0,w=1):(d=0,f=0,p=1,v=1,m=0,w=1):l127?n-256:n;for(let n=0;n<256;n+=1){const r=t.nextInt(256-n),i=this.p[n];this.p[n]=this.p[n+r],this.p[n+r]=i}}sample(t,n,r,i=0,s=0){const a=t+this.xo,o=n+this.yo,g=r+this.zo,c=Math.floor(a),l=Math.floor(o),h=Math.floor(g),d=a-c,f=o-l,p=g-h;let v=0;if(i!==0){const m=s>=0&&s=0;s-=1)s0&&(d=this.maxLimitNoise.getOctaveNoise(w))&&(m+=d.sample(S,E,y,k,s*p)/p),p/=2}return Qn(v/512,m/512,f)/128}}const Bn=class{constructor(t,{firstOctave:n,amplitudes:r}){_(this,"valueFactor");_(this,"first");_(this,"second");_(this,"maxValue");this.first=new wt(t,n,r),this.second=new wt(t,n,r);let i=1/0,s=-1/0;for(let o=0;o{function t(r,i){return{firstOctave:r,amplitudes:i}}e.create=t;function n(r){var s,a,o;const i=(s=u.Json.readObject(r))!=null?s:{};return{firstOctave:(a=u.Json.readInt(i.firstOctave))!=null?a:0,amplitudes:(o=u.Json.readArray(i.amplitudes,g=>{var c;return(c=u.Json.readNumber(g))!=null?c:0}))!=null?o:[]}}e.fromJson=n})(u.NoiseParameters||(u.NoiseParameters={}));class Hl{constructor(t,n){_(this,"noiseLevels");_(this,"highestFreqInputFactor");_(this,"highestFreqValueFactor");const r=n[n.length-1],s=-n[0]+r+1,a=new Set(n),o=new pt(t);this.noiseLevels=Array(s),r>=0&&r=0&&a.has(r-g)?this.noiseLevels[g]=new pt(t):t.consume(262);if(r>0)throw new Error("Positive octaves are not allowed");this.highestFreqInputFactor=Math.pow(2,r),this.highestFreqValueFactor=1/(Math.pow(2,s)-1)}sample(t,n,r){let i=0,s=this.highestFreqInputFactor,a=this.highestFreqValueFactor;for(let o=0;o{const t=e/15,n=t*.6+(t>0?.4:.3),r=Mt(t*t*.7-.5,0,1),i=Mt(t*t*.6-.7,0,1);return[n,r,i]},Ys=e=>[e/8,1-e/32,e*64],Pe={large_fern:()=>se,tall_grass:()=>se,grass_block:()=>se,fern:()=>se,grass:()=>se,short_grass:()=>se,potted_fern:()=>se,pink_petals:()=>se,spruce_leaves:()=>Zl,birch_leaves:()=>Gl,oak_leaves:()=>We,jungle_leaves:()=>We,acacia_leaves:()=>We,dark_oak_leaves:()=>We,vine:()=>We,mangrove_leaves:()=>We,water:()=>ar,bubble_column:()=>ar,cauldron:()=>ar,water_cauldron:()=>ar,redstone_wire:e=>{var t;return $l(parseInt((t=e.power)!=null?t:"0"))},sugar_cane:()=>se,attached_melon_stem:()=>$s,attached_pumpkin_stem:()=>$s,melon_stem:e=>{var t;return Ys(parseInt((t=e.age)!=null?t:"0"))},pumpkin_stem:e=>{var t;return Ys(parseInt((t=e.age)!=null?t:"0"))},lily_pad:()=>Vl};u.Cull=void 0,(e=>{function t(r,i,s){let{up:a,down:o,north:g,east:c,south:l,west:h}=r;switch(s){case 90:[g,c,l,h]=[c,l,h,g];break;case 180:[g,c,l,h]=[l,h,g,c];break;case 270:[g,c,l,h]=[h,g,c,l]}switch(i){case 90:[a,g,o,l]=[g,o,l,a];break;case 180:[a,g,o,l]=[o,l,a,g];break;case 270:[a,g,o,l]=[l,a,g,o]}return{up:a,down:o,north:g,east:c,south:l,west:h}}e.rotate=t;function n(){return Object.create(null)}e.none=n})(u.Cull||(u.Cull={}));const Ut=class{constructor(t,n,r,i,s){this.pos=t,this.color=n,this.texture=r,this.normal=i,this.blockPos=s}transform(t){return Ut.VEC[0]=this.pos.x,Ut.VEC[1]=this.pos.y,Ut.VEC[2]=this.pos.z,zl(Ut.VEC,Ut.VEC,t),this.pos=new q(Ut.VEC[0],Ut.VEC[1],Ut.VEC[2]),this}static fromPos(t){return new Ut(t,[0,0,0],[0,0],void 0,void 0)}};let Pt=Ut;_(Pt,"VEC",Wr());class or{constructor(t,n){this.v1=t,this.v2=n}vertices(){return[this.v1,this.v2]}forEach(t){return t(this.v1),t(this.v2),this}transform(t){return this.forEach(n=>n.transform(t)),this}setColor(t){return this.forEach(n=>n.color=t),this}toString(){return`Line(${this.v1.pos.toString()}, ${this.v2.pos.toString()})`}static fromPoints(t,n){return new or(Pt.fromPos(t),Pt.fromPos(n))}}class it{constructor(t=[],n=[]){_(this,"posBuffer");_(this,"colorBuffer");_(this,"textureBuffer");_(this,"normalBuffer");_(this,"blockPosBuffer");_(this,"indexBuffer");_(this,"linePosBuffer");_(this,"lineColorBuffer");this.quads=t,this.lines=n}clear(){return this.quads=[],this.lines=[],this}isEmpty(){return this.quads.length===0&&this.lines.length===0}quadVertices(){return this.quads.length*4}quadIndices(){return this.quads.length*6}lineVertices(){return this.lines.length*2}merge(t){return this.quads=this.quads.concat(t.quads),this.lines=this.lines.concat(t.lines),this}addLine(t,n,r,i,s,a,o){const g=new or(Pt.fromPos(new q(t,n,r)),Pt.fromPos(new q(i,s,a))).setColor(o);return this.lines.push(g),this}addLineCube(t,n,r,i,s,a,o){return this.addLine(t,n,r,t,n,a,o),this.addLine(i,n,r,i,n,a,o),this.addLine(t,n,r,i,n,r,o),this.addLine(t,n,a,i,n,a,o),this.addLine(t,n,r,t,s,r,o),this.addLine(i,n,r,i,s,r,o),this.addLine(t,n,a,t,s,a,o),this.addLine(i,n,a,i,s,a,o),this.addLine(t,s,r,t,s,a,o),this.addLine(i,s,r,i,s,a,o),this.addLine(t,s,r,i,s,r,o),this.addLine(t,s,a,i,s,a,o),this}transform(t){for(const n of this.quads)n.transform(t);return this}computeNormals(){for(const t of this.quads){const n=t.normal();t.forEach(r=>r.normal=n)}}rebuild(t,n){const r=(s,a,o)=>{var g;if(s||(s=(g=t.createBuffer())!=null?g:void 0),!s)throw new Error("Cannot create new buffer");return t.bindBuffer(a,s),t.bufferData(a,o,t.DYNAMIC_DRAW),s},i=(s,a,o)=>{if(s.length===0){a&&t.deleteBuffer(a);return}const g=s.flatMap(c=>c.vertices().flatMap(l=>{const h=o(l);if(!h)throw new Error("Missing vertex component");return h}));return r(a,t.ARRAY_BUFFER,new Float32Array(g))};return n.pos&&(this.posBuffer=i(this.quads,this.posBuffer,s=>s.pos.components()),this.linePosBuffer=i(this.lines,this.linePosBuffer,s=>s.pos.components())),n.color&&(this.colorBuffer=i(this.quads,this.colorBuffer,s=>s.color),this.lineColorBuffer=i(this.lines,this.lineColorBuffer,s=>s.color)),n.texture&&(this.textureBuffer=i(this.quads,this.textureBuffer,s=>s.texture)),n.normal&&(this.normalBuffer=i(this.quads,this.normalBuffer,s=>{var a;return(a=s.normal)==null?void 0:a.components()})),n.blockPos&&(this.blockPosBuffer=i(this.quads,this.blockPosBuffer,s=>{var a;return(a=s.blockPos)==null?void 0:a.components()})),this.quads.length===0?(this.indexBuffer&&t.deleteBuffer(this.indexBuffer),this.indexBuffer=void 0):this.indexBuffer=r(this.indexBuffer,t.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.quads.flatMap((s,a)=>[4*a,4*a+1,4*a+2,a*4,4*a+2,4*a+3],!0))),this}}class Qr{constructor(t,n){this.variants=t,this.multipart=n}getModelVariants(t){if(this.variants){const n=Object.keys(this.variants).filter(i=>this.matchesVariant(i,t));if(n.length===0)return[];const r=this.variants[n[0]];return[Array.isArray(r)?r[0]:r]}else if(this.multipart)return this.multipart.filter(r=>r.when?this.matchesCase(r.when,t):!0).map(r=>Array.isArray(r.apply)?r.apply[0]:r.apply);return[]}getMesh(t,n,r,i,s){var c,l,h,d,f;const a=this.getModelVariants(n),o=new it;for(const p of a){const v=u.Cull.rotate(s,(c=p.x)!=null?c:0,(l=p.y)!=null?l:0),m=i.getBlockModel(C.parse(p.model));if(!m)throw new Error(`Cannot find block model ${p.model}`);const w=t?(h=Pe[t.path])==null?void 0:h.call(Pe,n):void 0,S=m.getMesh(r,v,w);if(p.x||p.y){const E=rt();X(E,E,[8,8,8]),_t(E,E,-Yr((d=p.y)!=null?d:0)),xn(E,E,-Yr((f=p.x)!=null?f:0)),X(E,E,[-8,-8,-8]),S.transform(E)}o.merge(S)}const g=rt();return Lt(g,g,[.0625,.0625,.0625]),o.transform(g)}matchesVariant(t,n){return t.split(",").every(r=>{const[i,s]=r.split("=");return n[i]===s})}matchesCase(t,n){if(Array.isArray(t.OR))return t.OR.some(i=>this.matchesCase(i,n));const r=t;return Object.keys(r).every(i=>r[i].split("|").includes(n[i]))}static fromJson(t){return new Qr(t.variants,t.multipart)}}class Yt{constructor(t,n,r,i){this.v1=t,this.v2=n,this.v3=r,this.v4=i}vertices(){return[this.v1,this.v2,this.v3,this.v4]}forEach(t){return t(this.v1),t(this.v2),t(this.v3),t(this.v4),this}transform(t){return this.forEach(n=>n.transform(t)),this}normal(){const t=this.v2.pos.sub(this.v1.pos),n=this.v3.pos.sub(this.v1.pos);return t.cross(n).normalize()}reverse(){return[this.v1,this.v2,this.v3,this.v4]=[this.v4,this.v3,this.v2,this.v1],this}setColor(t){return this.forEach(n=>n.color=t),this}setTexture(t){return this.v1.texture=[t[0],t[1]],this.v2.texture=[t[2],t[3]],this.v3.texture=[t[4],t[5]],this.v4.texture=[t[6],t[7]],this}toString(){return`Quad(${this.v1.pos.toString()}, ${this.v2.pos.toString()}, ${this.v3.pos.toString()}, ${this.v4.pos.toString()})`}static fromPoints(t,n,r,i){return new Yt(Pt.fromPos(t),Pt.fromPos(n),Pt.fromPos(r),Pt.fromPos(i))}}const Yl={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]},ql={x:[1,0,0],y:[0,1,0],z:[0,0,1]},Xe=1.41421356237,Wl={x:[1,Xe,Xe],y:[Xe,1,Xe],z:[Xe,Xe,1]},en=class{constructor(t,n,r,i,s){_(this,"generationMarker",!1);_(this,"uvEpsilon",1/16);this.parent=t,this.textures=n,this.elements=r,this.display=i,this.guiLight=s}getDisplayTransform(t){var i;const n=(i=this.display)==null?void 0:i[t],r=rt();return X(r,r,[8,8,8]),n!=null&&n.translation&&X(r,r,n.translation),n!=null&&n.rotation&&(xn(r,r,n.rotation[0]*Math.PI/180),_t(r,r,n.rotation[1]*Math.PI/180),Ds(r,r,-n.rotation[2]*Math.PI/180)),n!=null&&n.scale&&Lt(r,r,n.scale),X(r,r,[-8,-8,-8]),r}getMesh(t,n,r){var a;const i=new it,s=o=>r===void 0?[1,1,1]:o===void 0||o<0?[1,1,1]:typeof r=="function"?r(o):r;for(const o of(a=this.elements)!=null?a:[])i.merge(this.getElementMesh(o,t,n,s));return i}getElementMesh(t,n,r,i){var p,v,m,w,S,E,y,k,R,I,M,T;const s=new it,[a,o,g]=t.from,[c,l,h]=t.to,d=(x,N,P)=>{var Z,Q,It,kt,yt,ut,lt,H,O;const F=Yt.fromPoints(new q(P[0],P[1],P[2]),new q(P[3],P[4],P[5]),new q(P[6],P[7],P[8]),new q(P[9],P[10],P[11])),U=i(x.tintindex);F.setColor(U);const[Y,B,J,G]=n.getTextureUV(this.getTexture(x.texture)),V=(J-Y)/16,A=(G-B)/16,b=V*this.uvEpsilon,L=A*this.uvEpsilon;N[0]=((Q=(Z=x.uv)==null?void 0:Z[0])!=null?Q:N[0])*V+b,N[1]=((kt=(It=x.uv)==null?void 0:It[1])!=null?kt:N[1])*A+L,N[2]=((ut=(yt=x.uv)==null?void 0:yt[2])!=null?ut:N[2])*V-b,N[3]=((H=(lt=x.uv)==null?void 0:lt[3])!=null?H:N[3])*A-L;const z=Yl[(O=x.rotation)!=null?O:0];F.setTexture([Y+N[z[0]],B+N[z[1]],Y+N[z[2]],B+N[z[3]],Y+N[z[4]],B+N[z[5]],Y+N[z[6]],B+N[z[7]]]),s.quads.push(F)};((v=(p=t.faces)==null?void 0:p.up)==null?void 0:v.texture)&&(!t.faces.up.cullface||!r[t.faces.up.cullface])&&d(t.faces.up,[a,16-h,c,16-g],[a,l,h,c,l,h,c,l,g,a,l,g]),((w=(m=t.faces)==null?void 0:m.down)==null?void 0:w.texture)&&(!t.faces.down.cullface||!r[t.faces.down.cullface])&&d(t.faces.down,[16-h,16-c,16-g,16-a],[a,o,g,c,o,g,c,o,h,a,o,h]),((E=(S=t.faces)==null?void 0:S.south)==null?void 0:E.texture)&&(!t.faces.south.cullface||!r[t.faces.south.cullface])&&d(t.faces.south,[a,16-l,c,16-o],[a,o,h,c,o,h,c,l,h,a,l,h]),((k=(y=t.faces)==null?void 0:y.north)==null?void 0:k.texture)&&(!t.faces.north.cullface||!r[t.faces.north.cullface])&&d(t.faces.north,[16-c,16-l,16-a,16-o],[c,o,g,a,o,g,a,l,g,c,l,g]),((I=(R=t.faces)==null?void 0:R.east)==null?void 0:I.texture)&&(!t.faces.east.cullface||!r[t.faces.east.cullface])&&d(t.faces.east,[16-h,16-l,16-g,16-o],[c,o,h,c,o,g,c,l,g,c,l,h]),((T=(M=t.faces)==null?void 0:M.west)==null?void 0:T.texture)&&(!t.faces.west.cullface||!r[t.faces.west.cullface])&&d(t.faces.west,[g,16-l,h,16-o],[a,o,g,a,o,h,a,l,h,a,l,g]);const f=rt();if(t.rotation){const x=Ol(...t.rotation.origin);X(f,f,x),kl(f,f,Yr(t.rotation.angle),ql[t.rotation.axis]),t.rotation.rescale&&Lt(f,f,Wl[t.rotation.axis]),Jl(x,x),X(f,f,x)}return s.transform(f)}getTexture(t){var n,r;for(;t.startsWith("#");)t=(r=(n=this.textures)==null?void 0:n[t.slice(1)])!=null?r:"";return C.parse(t)}withUvEpsilon(t){return this.uvEpsilon=t,this}flatten(t){var r,i,s,a;if(!this.parent)return;if(this.parent.equals(en.BUILTIN_GENERATED)){this.generationMarker=!0;return}const n=this.getParent(t);if(!n){console.warn(`parent ${this.parent} does not exist!`),this.parent=void 0;return}if(n.flatten(t),this.elements||(this.elements=n.elements),this.textures||(this.textures={}),Object.keys((r=n.textures)!=null?r:{}).forEach(o=>{this.textures[o]||(this.textures[o]=n.textures[o])}),this.display||(this.display={}),Object.keys((i=n.display)!=null?i:{}).forEach(o=>{var c;const g=o;this.display[g]?Object.keys((c=n.display[g])!=null?c:{}).forEach(l=>{const h=l;this.display[g][h]||(this.display[g][h]=n.display[g][h])}):this.display[g]=n.display[g]}),this.guiLight||(this.guiLight=n.guiLight),n.generationMarker&&(this.generationMarker=!0),this.generationMarker&&((a=(s=this.elements)==null?void 0:s.length)!=null?a:0)===0)for(let o=0;o{function t(B){return J=>new ot(void 0,{0:B.withPrefix("entity/chest/").toString()},[{from:[1,0,1],to:[15,10,15],faces:{north:{uv:[10.5,8.25,14,10.75],rotation:180,texture:"#0"},east:{uv:[7,8.25,10.5,10.75],rotation:180,texture:"#0"},south:{uv:[3.5,8.25,7,10.75],rotation:180,texture:"#0"},west:{uv:[0,8.25,3.5,10.75],rotation:180,texture:"#0"},up:{uv:[7,4.75,10.5,8.25],texture:"#0"},down:{uv:[3.5,4.75,7,8.25],texture:"#0"}}},{from:[1,10,1],to:[15,14,15],faces:{north:{uv:[10.5,3.75,14,4.75],rotation:180,texture:"#0"},east:{uv:[7,3.75,10.5,4.75],rotation:180,texture:"#0"},south:{uv:[3.5,3.75,7,4.75],rotation:180,texture:"#0"},west:{uv:[0,3.75,3.5,4.75],rotation:180,texture:"#0"},up:{uv:[7,0,10.5,3.5],texture:"#0"},down:{uv:[3.5,0,7,3.5],texture:"#0"}}},{from:[7,7,0],to:[9,11,2],faces:{north:{uv:[.25,.25,.75,1.25],rotation:180,texture:"#0"},east:{uv:[0,.25,.25,1.25],rotation:180,texture:"#0"},south:{uv:[1,.25,1.5,1.25],rotation:180,texture:"#0"},west:{uv:[.75,.25,1,1.25],rotation:180,texture:"#0"},up:{uv:[.25,0,.75,.25],rotation:180,texture:"#0"},down:{uv:[.75,0,1.25,.25],rotation:180,texture:"#0"}}}]).getMesh(J,u.Cull.none())}e.chestRenderer=t;function n(B){return new ot(void 0,{0:"entity/decorated_pot/decorated_pot_side",1:"entity/decorated_pot/decorated_pot_base"},[{from:[1,0,1],to:[15,16,15],faces:{north:{uv:[1,0,15,16],texture:"#0"},east:{uv:[1,0,15,16],texture:"#0"},south:{uv:[1,0,15,16],texture:"#0"},west:{uv:[1,0,15,16],texture:"#0"},up:{uv:[0,6.5,7,13.5],texture:"#1"},down:{uv:[7,6.5,14,13.5],texture:"#1"}}},{from:[5,16,5],to:[11,17,11],faces:{north:{uv:[0,5.5,3,6],texture:"#1"},east:{uv:[3,5.5,6,6],texture:"#1"},south:{uv:[6,5.5,9,6],texture:"#1"},west:{uv:[9,5.5,12,6],texture:"#1"}}},{from:[4,17,4],to:[12,20,12],faces:{north:{uv:[0,4,4,5.5],texture:"#1"},east:{uv:[4,4,8,5.5],texture:"#1"},south:{uv:[8,4,12,5.5],texture:"#1"},west:{uv:[12,4,16,5.5],texture:"#1"},up:{uv:[4,0,8,4],texture:"#1"},down:{uv:[8,0,12,4],texture:"#1"}}}]).getMesh(B,u.Cull.none())}e.decoratedPotRenderer=n;function r(B){return new ot(void 0,{0:"entity/shield_base_nopattern"},[{from:[-6,-11,-2],to:[6,11,-1],faces:{north:{uv:[3.5,.25,6.5,5.75],texture:"#0"},east:{uv:[3.25,.25,3.5,5.75],texture:"#0"},south:{uv:[.25,.25,3.25,5.75],texture:"#0"},west:{uv:[0,.25,.25,5.75],texture:"#0"},up:{uv:[.25,0,3.25,.25],texture:"#0"},down:{uv:[3.25,0,6.25,.25],texture:"#0"}}}]).getMesh(B,u.Cull.none())}e.shieldRenderer=r;function i(B,J){return G=>new ot(void 0,{0:B.withPrefix("entity/").toString()},[{from:[4,0,4],to:[12,8,12],faces:{north:{uv:[6,2*J,8,4*J],texture:"#0"},east:{uv:[2,2*J,0,4*J],texture:"#0"},south:{uv:[2,2*J,4,4*J],texture:"#0"},west:{uv:[6,2*J,4,4*J],texture:"#0"},up:{uv:[2,0*J,4,2*J],texture:"#0"},down:{uv:[4,0*J,6,2*J],texture:"#0"}}}]).getMesh(G,u.Cull.none())}e.headRenderer=i;function s(B=C.create("enderdragon/dragon")){return J=>{const G=rt();return X(G,G,[8,8,8]),Lt(G,G,[.75,.75,.75]),_t(G,G,Math.PI),X(G,G,[-8,-11.2,-8]),new ot(void 0,{0:B.withPrefix("entity/").toString()},[{from:[2,4,-16],to:[14,9,0],faces:{north:{uv:[12,3.75,12.75,4.0625],texture:"#0"},east:{uv:[11,3.75,12,4.0625],texture:"#0"},south:{uv:[13.75,3.75,14.5,4.0625],texture:"#0"},west:{uv:[12.75,3.75,13.75,4.0625],texture:"#0"},up:{uv:[12.75,3.75,12,2.75],texture:"#0"},down:{uv:[13.5,2.75,12.75,3.75],texture:"#0"}}},{from:[0,0,-2],to:[16,16,14],faces:{north:{uv:[8,2.875,9,3.875],texture:"#0"},east:{uv:[7,2.875,8,3.875],texture:"#0"},south:{uv:[10,2.875,11,3.875],texture:"#0"},west:{uv:[9,2.875,10,3.875],texture:"#0"},up:{uv:[9,2.875,8,1.875],texture:"#0"},down:{uv:[10,1.875,9,2.875],texture:"#0"}}},{from:[2,0,-16],to:[14,4,0],rotation:{angle:-.2*180/Math.PI,axis:"x",origin:[8,4,-2]},faces:{north:{uv:[12,5.0625,12.75,5.3125],texture:"#0"},east:{uv:[11,5.0625,12,5.3125],texture:"#0"},south:{uv:[13.75,5.0625,14.5,5.3125],texture:"#0"},west:{uv:[12.75,5.0625,13.75,5.3125],texture:"#0"},up:{uv:[12.75,5.0625,12,4.0625],texture:"#0"},down:{uv:[13.5,4.0625,12.75,5.0625],texture:"#0"}}},{from:[3,16,4],to:[5,20,10],faces:{north:{uv:[.375,.375,.5,.625],texture:"#0"},east:{uv:[0,.375,.375,.625],texture:"#0"},south:{uv:[.875,.375,1,.625],texture:"#0"},west:{uv:[.5,.375,.875,.625],texture:"#0"},up:{uv:[.5,.375,.375,0],texture:"#0"},down:{uv:[.625,0,.5,.375],texture:"#0"}}},{from:[11,16,4],to:[13,20,10],faces:{north:{uv:[.375,.375,.5,.625],texture:"#0"},east:{uv:[0,.375,.375,.625],texture:"#0"},south:{uv:[.875,.375,1,.625],texture:"#0"},west:{uv:[.5,.375,.875,.625],texture:"#0"},up:{uv:[.5,.375,.375,0],texture:"#0"},down:{uv:[.625,0,.5,.375],texture:"#0"}}},{from:[3,9,-14],to:[5,11,-10],faces:{north:{uv:[7.25,.25,7.375,.375],texture:"#0"},east:{uv:[7,.25,7.25,.375],texture:"#0"},south:{uv:[7.625,.25,7.75,.375],texture:"#0"},west:{uv:[7.375,.25,7.625,.375],texture:"#0"},up:{uv:[7.375,.25,7.25,0],texture:"#0"},down:{uv:[7.5,0,7.375,.25],texture:"#0"}}},{from:[11,9,-14],to:[13,11,-10],faces:{north:{uv:[7.25,.25,7.375,.375],texture:"#0"},east:{uv:[7,.25,7.25,.375],texture:"#0"},south:{uv:[7.625,.25,7.75,.375],texture:"#0"},west:{uv:[7.375,.25,7.625,.375],texture:"#0"},up:{uv:[7.375,.25,7.25,0],texture:"#0"},down:{uv:[7.5,0,7.375,.25],texture:"#0"}}}]).withUvEpsilon(1/256).getMesh(J,u.Cull.none()).transform(G)}}e.dragonHeadRenderer=s;function a(B=C.create("piglin/piglin")){return J=>new ot(void 0,{0:B.withPrefix("entity/").toString()},[{from:[3,0,4],to:[13,8,12],faces:{north:{uv:[6.5,2,9,4],texture:"#0"},east:{uv:[2,2,0,4],texture:"#0"},south:{uv:[2,2,4.5,4],texture:"#0"},west:{uv:[6.5,2,4.5,4],texture:"#0"},up:{uv:[2,0,4.5,2],texture:"#0"},down:{uv:[4.5,0,7,2],texture:"#0"}}},{from:[6,0,12],to:[10,4,13],faces:{north:{uv:[9.25,.5,10.25,1.5],texture:"#0"},east:{uv:[7.75,.5,8,1.5],texture:"#0"},south:{uv:[8,.5,9,1.5],texture:"#0"},west:{uv:[9,.5,9.25,1.5],texture:"#0"},up:{uv:[8,.25,9,.5],texture:"#0"},down:{uv:[9,.25,10,.5],texture:"#0"}}},{from:[5,0,12],to:[6,2,13],faces:{north:{uv:[1.25,.25,1.5,.75],texture:"#0"},east:{uv:[.5,.25,.75,.75],texture:"#0"},south:{uv:[.75,.25,1,.75],texture:"#0"},west:{uv:[1,.25,1.25,.75],texture:"#0"},up:{uv:[.75,0,1,.25],texture:"#0"},down:{uv:[1,0,1.25,.25],texture:"#0"}}},{from:[10,0,12],to:[11,2,13],faces:{north:{uv:[1.25,1.25,1.5,1.75],texture:"#0"},east:{uv:[.5,1.25,.75,1.75],texture:"#0"},south:{uv:[.75,1.25,1,1.75],texture:"#0"},west:{uv:[1,1.25,1.25,1.75],texture:"#0"},up:{uv:[.75,1,1,1.25],texture:"#0"},down:{uv:[1,1,1.25,1.25],texture:"#0"}}},{from:[2.5,1.5,6],to:[3.5,6.5,10],rotation:{angle:-30,axis:"z",origin:[3,7,8]},faces:{north:{uv:[12,2.5,12.25,3.75],texture:"#0"},east:{uv:[9.75,2.5,10.75,3.75],texture:"#0"},south:{uv:[10.75,2.5,11,3.75],texture:"#0"},west:{uv:[11,2.5,12,3.75],texture:"#0"},up:{uv:[10.75,1.5,11,2.5],texture:"#0"},down:{uv:[11,1.5,11.25,2.5],texture:"#0"}}},{from:[12.5,1.5,6],to:[13.5,6.5,10],rotation:{angle:30,axis:"z",origin:[13,7,8]},faces:{north:{uv:[15.25,2.5,15,3.75],texture:"#0"},east:{uv:[15,2.5,14,3.75],texture:"#0"},south:{uv:[14,2.5,13.75,3.75],texture:"#0"},west:{uv:[13.75,2.5,12.75,3.75],texture:"#0"},up:{uv:[14,1.5,13.75,2.5],texture:"#0"},down:{uv:[14.25,1.5,14,2.5],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}e.piglinHeadRenderer=a;function o(B){return J=>new ot(void 0,{0:B.withPrefix("entity/signs/").toString()},[{from:[-4,8,7],to:[20,20,9],faces:{north:{uv:[.5,1,6.5,7],texture:"#0"},east:{uv:[0,1,.5,7],texture:"#0"},south:{uv:[7,1,13,7],texture:"#0"},west:{uv:[6.5,1,7,7],texture:"#0"},up:{uv:[6.5,1,.5,0],texture:"#0"},down:{uv:[12.5,0,6.5,1],texture:"#0"}}},{from:[7,-6,7],to:[9,8,9],faces:{north:{uv:[.5,8,1,15],texture:"#0"},east:{uv:[0,8,.5,15],texture:"#0"},south:{uv:[1.5,8,2,15],texture:"#0"},west:{uv:[1,8,1.5,15],texture:"#0"},up:{uv:[1,8,.5,7],texture:"#0"},down:{uv:[1.5,7,1,8],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}e.signRenderer=o;function g(B){return J=>new ot(void 0,{0:B.withPrefix("entity/signs/").toString()},[{from:[-4,4,17],to:[20,16,19],faces:{north:{uv:[.5,1,6.5,7],texture:"#0"},east:{uv:[0,1,.5,7],texture:"#0"},south:{uv:[7,1,13,7],texture:"#0"},west:{uv:[6.5,1,7,7],texture:"#0"},up:{uv:[6.5,1,.5,0],texture:"#0"},down:{uv:[12.5,0,6.5,1],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}e.wallSignRenderer=g;function c(B){return(J,G)=>J?new ot(void 0,{0:B.withPrefix("entity/signs/hanging/").toString()},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[2,10,8],to:[14,16,8],faces:{north:{uv:[3.5,3,6.5,6],texture:"#0"},south:{uv:[3.5,3,6.5,6],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(G,u.Cull.none()):new ot(void 0,{0:B.withPrefix("entity/signs/hanging/").toString()},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[1.5,10,8],to:[4.5,16,8],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[3,10,6.5],to:[3,16,9.5],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}},{from:[11.5,10,8],to:[14.5,16,8],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[13,10,6.5],to:[13,16,9.5],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(G,u.Cull.none())}e.hangingSignRenderer=c;function l(B){return J=>new ot(void 0,{0:`entity/signs/hanging/${B}`},[{from:[1,0,7],to:[15,10,9],faces:{north:{uv:[.5,7,4,12],texture:"#0"},east:{uv:[0,7,.5,12],texture:"#0"},south:{uv:[4.5,7,8,12],texture:"#0"},west:{uv:[4,7,4.5,12],texture:"#0"},up:{uv:[4,7,.5,6],texture:"#0"},down:{uv:[7.5,6,4,7],texture:"#0"}}},{from:[0,14,6],to:[16,16,10],faces:{north:{uv:[1,2,5,3],texture:"#0"},east:{uv:[0,2,1,3],texture:"#0"},south:{uv:[6,2,10,3],texture:"#0"},west:{uv:[5,2,6,3],texture:"#0"},up:{uv:[5,2,1,0],texture:"#0"},down:{uv:[9,0,5,2],texture:"#0"}}},{from:[1.5,10,8],to:[4.5,16,8],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[3,10,6.5],to:[3,16,9.5],rotation:{angle:45,axis:"y",origin:[3,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}},{from:[11.5,10,8],to:[14.5,16,8],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{north:{uv:[0,3,.75,6],texture:"#0"},south:{uv:[0,3,.75,6],texture:"#0"}}},{from:[13,10,6.5],to:[13,16,9.5],rotation:{angle:45,axis:"y",origin:[13,12,8]},faces:{east:{uv:[1.5,3,2.25,6],texture:"#0"},west:{uv:[1.5,3,2.25,6],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}e.wallHangingSignRenderer=l;function h(B){return new ot(void 0,{0:"entity/conduit/base"},[{from:[5,5,5],to:[11,11,11],faces:{north:{uv:[3,6,6,12],texture:"#0"},east:{uv:[0,6,3,12],texture:"#0"},south:{uv:[9,6,12,12],texture:"#0"},west:{uv:[6,6,9,12],texture:"#0"},up:{uv:[6,6,3,0],texture:"#0"},down:{uv:[9,0,6,6],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(B,u.Cull.none())}e.conduitRenderer=h;function d(B){return J=>new ot(void 0,{0:B.withPrefix("entity/shulker/").toString()},[{from:[0,0,0],to:[16,8,16],faces:{north:{uv:[4,11,8,13],texture:"#0"},east:{uv:[0,11,4,13],texture:"#0"},south:{uv:[12,11,16,13],texture:"#0"},west:{uv:[8,11,12,13],texture:"#0"},up:{uv:[8,11,4,7],texture:"#0"},down:{uv:[12,7,8,11],texture:"#0"}}},{from:[0,4,0],to:[16,16,16],faces:{north:{uv:[4,4,8,7],texture:"#0"},east:{uv:[0,4,4,7],texture:"#0"},south:{uv:[12,4,16,7],texture:"#0"},west:{uv:[8,4,12,7],texture:"#0"},up:{uv:[8,4,4,0],texture:"#0"},down:{uv:[12,0,8,4],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(J,u.Cull.none())}e.shulkerBoxRenderer=d;function f(B){return J=>new ot(void 0,{0:"entity/banner_base"},[{from:[-2,-8,9],to:[18,32,10],faces:{north:{uv:[.25,.25,5.25,10.25],texture:"#0"},east:{uv:[0,.25,.25,10.25],texture:"#0"},south:{uv:[5.5,.25,10.5,10.25],texture:"#0"},west:{uv:[5.25,.25,5.5,10.25],texture:"#0"},up:{uv:[5.25,.25,.25,0],texture:"#0"},down:{uv:[10.25,0,5.25,.25],texture:"#0"}}},{from:[7,-12,7],to:[9,30,9],faces:{north:{uv:[11.5,.5,12,11],texture:"#0"},east:{uv:[11,.5,11.5,11],texture:"#0"},south:{uv:[12.5,.5,13,11],texture:"#0"},west:{uv:[12,.5,12.5,11],texture:"#0"},up:{uv:[12,.5,11.5,0],texture:"#0"},down:{uv:[12.5,0,12,.5],texture:"#0"}}},{from:[-2,30,7],to:[18,32,9],faces:{north:{uv:[.5,11,5.5,11.5],texture:"#0"},east:{uv:[0,11,.5,11.5],texture:"#0"},south:{uv:[6,11,11,11.5],texture:"#0"},west:{uv:[5.5,11,6,11.5],texture:"#0"},up:{uv:[5.5,11,.5,10.5],texture:"#0"},down:{uv:[10.5,10.5,5.5,11],texture:"#0"}}}]).getMesh(J,u.Cull.none())}e.bannerRenderer=f;function p(B){return J=>new ot(void 0,{0:"entity/banner_base"},[{from:[-2,-8,-1.5],to:[18,32,-.5],faces:{north:{uv:[.25,.25,5.25,10.25],texture:"#0"},east:{uv:[0,.25,.25,10.25],texture:"#0"},south:{uv:[5.5,.25,10.5,10.25],texture:"#0"},west:{uv:[5.25,.25,5.5,10.25],texture:"#0"},up:{uv:[5.25,.25,.25,0],texture:"#0"},down:{uv:[10.25,0,5.25,.25],texture:"#0"}}},{from:[-2,30,-3.5],to:[18,32,-1.5],faces:{north:{uv:[.5,11,5.5,11.5],texture:"#0"},east:{uv:[0,11,.5,11.5],texture:"#0"},south:{uv:[6,11,11,11.5],texture:"#0"},west:{uv:[5.5,11,6,11.5],texture:"#0"},up:{uv:[5.5,11,.5,10.5],texture:"#0"},down:{uv:[10.5,10.5,5.5,11],texture:"#0"}}}]).getMesh(J,u.Cull.none())}e.wallBannerRenderer=p;function v(B){return new ot(void 0,{0:"entity/bell/bell_body"},[{from:[5,3,5],to:[11,10,11],faces:{north:{uv:[3,3,6,6.5],texture:"#0"},east:{uv:[0,3,3,6.5],texture:"#0"},south:{uv:[9,3,12,6.5],texture:"#0"},west:{uv:[6,3,9,6.5],texture:"#0"},up:{uv:[6,3,3,0],texture:"#0"},down:{uv:[9,0,6,3],texture:"#0"}}},{from:[4,10,4],to:[12,12,12],faces:{north:{uv:[4,10.5,8,11.5],texture:"#0"},east:{uv:[0,10.5,4,11.5],texture:"#0"},south:{uv:[12,10.5,16,11.5],texture:"#0"},west:{uv:[8,10.5,12,11.5],texture:"#0"},up:{uv:[8,10.5,4,6.5],texture:"#0"},down:{uv:[12,6.5,8,10.5],texture:"#0"}}}]).withUvEpsilon(1/64).getMesh(B,u.Cull.none())}e.bellRenderer=v;function m(B){return(J,G)=>J==="foot"?new ot(void 0,{0:B.withPrefix("entity/bed/").toString()},[{from:[0,3,0],to:[16,9,16],faces:{north:{uv:[5.5,5.5,9.5,7],rotation:180,texture:"#0"},east:{uv:[0,7,1.5,11],rotation:270,texture:"#0"},west:{uv:[5.5,7,7,11],rotation:90,texture:"#0"},up:{uv:[5.5,11,1.5,7],texture:"#0"},down:{uv:[11,7,7,11],texture:"#0"}}},{from:[0,0,0],to:[3,3,3],faces:{north:{uv:[12.5,5.25,13.25,6],texture:"#0"},east:{uv:[14.75,5.25,15.5,6],texture:"#0"},south:{uv:[14,5.25,14.75,6],texture:"#0"},west:{uv:[13.25,5.25,14,6],texture:"#0"},up:{uv:[13.25,4.5,14,5.25],texture:"#0"},down:{uv:[14,4.5,14.75,5.25],texture:"#0"}}},{from:[13,0,0],to:[16,3,3],faces:{north:{uv:[13.25,3.75,14,4.5],texture:"#0"},east:{uv:[12.5,3.75,13.25,4.5],texture:"#0"},south:{uv:[14.75,3.75,15.5,4.5],texture:"#0"},west:{uv:[14,3.75,14.75,4.5],texture:"#0"},up:{uv:[13.25,3,14,3.75],texture:"#0"},down:{uv:[14,3,14.75,3.75],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(G,u.Cull.none()):new ot(void 0,{0:B.withPrefix("entity/bed/").toString()},[{from:[0,3,0],to:[16,9,16],faces:{east:{uv:[0,1.5,1.5,5.5],rotation:270,texture:"#0"},south:{uv:[1.5,0,5.5,1.5],rotation:180,texture:"#0"},west:{uv:[5.5,1.5,7,5.5],rotation:90,texture:"#0"},up:{uv:[5.5,5.5,1.5,1.5],texture:"#0"},down:{uv:[11,1.5,7,5.5],texture:"#0"}}},{from:[0,0,13],to:[3,3,16],faces:{north:{uv:[14.75,.75,15.5,1.5],texture:"#0"},east:{uv:[14,.75,14.75,1.5],texture:"#0"},south:{uv:[13.25,.75,14,1.5],texture:"#0"},west:{uv:[12.5,.75,13.25,1.5],texture:"#0"},up:{uv:[13.25,0,14,.75],texture:"#0"},down:{uv:[14,0,14.75,.75],texture:"#0"}}},{from:[13,0,13],to:[16,3,16],faces:{north:{uv:[14,2.25,14.75,3],texture:"#0"},east:{uv:[13.25,2.25,14,3],texture:"#0"},south:{uv:[12.5,2.25,13.25,3],texture:"#0"},west:{uv:[14.75,2.25,15.5,3],texture:"#0"},up:{uv:[13.25,1.5,14,2.25],texture:"#0"},down:{uv:[14,1.5,14.75,2.25],texture:"#0"}}}]).withUvEpsilon(1/128).getMesh(G,u.Cull.none())}e.bedRenderer=m;function w(B,J,G=""){var V;return(V=B.getProperty(J))!=null?V:G}function S(B,J,G="0"){var V;return parseInt((V=B.getProperty(J))!=null?V:G)}const E=new Map(Object.entries({"minecraft:chest":e.chestRenderer(C.create("normal")),"minecraft:ender_chest":e.chestRenderer(C.create("ender")),"minecraft:trapped_chest":e.chestRenderer(C.create("trapped"))})),y=new Map(Object.entries({"minecraft:skeleton_skull":e.headRenderer(C.create("skeleton/skeleton"),2),"minecraft:wither_skeleton_skull":e.headRenderer(C.create("skeleton/wither_skeleton"),2),"minecraft:zombie_head":e.headRenderer(C.create("zombie/zombie"),1),"minecraft:creeper_head":e.headRenderer(C.create("creeper/creeper"),2),"minecraft:dragon_head":e.dragonHeadRenderer(),"minecraft:piglin_head":e.piglinHeadRenderer(),"minecraft:player_head":e.headRenderer(C.create("player/wide/steve"),1)})),k=["oak","spruce","birch","jungle","acacia","dark_oak","mangrove","cherry","bamboo","crimson","warped"],R=new Map(k.map(B=>[`minecraft:${B}_sign`,e.signRenderer(C.create(B))])),I=new Map(k.map(B=>[`minecraft:${B}_wall_sign`,e.wallSignRenderer(C.create(B))])),M=new Map(k.map(B=>[`minecraft:${B}_hanging_sign`,e.hangingSignRenderer(C.create(B))])),T=new Map(k.map(B=>[`minecraft:${B}_wall_hanging_sign`,e.wallHangingSignRenderer(B)])),x=["white","orange","magenta","light_blue","yellow","lime","pink","gray","light_gray","cyan","purple","blue","brown","green","red","black"],N=new Map(x.map(B=>[`minecraft:${B}_shulker_box`,e.shulkerBoxRenderer(C.create(`shulker_${B}`))])),P=new Map(x.map(B=>[`minecraft:${B}_bed`,e.bedRenderer(C.create(B))])),F=new Map(x.map(B=>[`minecraft:${B}_banner`,e.bannerRenderer(B)])),U=new Map(x.map(B=>[`minecraft:${B}_wall_banner`,e.wallBannerRenderer(B)]));function Y(B,J,G){if(B.is("water"))return ti("water",S(B,"level"),J,G,0);if(B.is("lava"))return ti("lava",S(B,"level"),J,G);const V=new it,A=E.get(B.getName().toString());if(A!==void 0){const H=w(B,"facing","south"),O=rt();X(O,O,[8,8,8]),_t(O,O,H==="west"?Math.PI/2:H==="south"?Math.PI:H==="east"?Math.PI*3/2:0),X(O,O,[-8,-8,-8]),V.merge(A(J).transform(O))}B.is("decorated_pot")&&V.merge(n(J));const b=y.get(B.getName().toString());if(b!==void 0){const H=S(B,"rotation")/16*Math.PI*2,O=rt();X(O,O,[8,8,8]),_t(O,O,H),X(O,O,[-8,-8,-8]),V.merge(b(J).transform(O))}const L=R.get(B.getName().toString());if(L!==void 0){const H=S(B,"rotation")/16*Math.PI*2,O=rt();X(O,O,[8,8,8]),_t(O,O,H),Lt(O,O,[2/3,2/3,2/3]),X(O,O,[-8,-8,-8]),V.merge(L(J).transform(O))}const z=I.get(B.getName().toString());if(z!==void 0){const H=w(B,"facing","south"),O=rt();X(O,O,[8,8,8]),_t(O,O,H==="west"?Math.PI/2:H==="south"?Math.PI:H==="east"?Math.PI*3/2:0),Lt(O,O,[2/3,2/3,2/3]),X(O,O,[-8,-8,-8]),V.merge(z(J).transform(O))}const Z=M.get(B.getName().toString());if(Z!==void 0){const H=w(B,"attached","false")==="true",O=S(B,"rotation")/16*Math.PI*2,ct=rt();X(ct,ct,[8,8,8]),_t(ct,ct,O),Lt(ct,ct,[2/3,2/3,2/3]),X(ct,ct,[-8,-8,-8]),V.merge(Z(H,J).transform(ct))}const Q=T.get(B.getName().toString());if(Q!==void 0){const H=w(B,"facing","south"),O=rt();X(O,O,[8,8,8]),_t(O,O,H==="west"?Math.PI/2:H==="south"?Math.PI:H==="east"?Math.PI*3/2:0),X(O,O,[-8,-8,-8]),V.merge(Q(J).transform(O))}B.is("conduit")&&V.merge(h(J));const It=N.get(B.getName().toString());if(It!==void 0){const H=w(B,"facing","up"),O=rt();X(O,O,[8,8,8]),H==="down"?xn(O,O,Math.PI):H!=="up"&&(_t(O,O,H==="east"?Math.PI/2:H==="north"?Math.PI:H==="west"?Math.PI*3/2:0),xn(O,O,Math.PI/2)),X(O,O,[-8,-8,-8]),V.merge(It(J).transform(O))}if(B.is("bell")){const H=rt();X(H,H,[8,8,8]),Lt(H,H,[1,-1,-1]),X(H,H,[-8,-8,-8]),V.merge(v(J).transform(H))}const kt=P.get(B.getName().toString());if(kt!==void 0){const H=w(B,"part","head"),O=w(B,"facing","south"),ct=rt();X(ct,ct,[8,8,8]),_t(ct,ct,O==="east"?Math.PI/2:O==="north"?Math.PI:O==="west"?Math.PI*3/2:0),X(ct,ct,[-8,-8,-8]),V.merge(kt(H,J).transform(ct))}const yt=F.get(B.getName().toString());if(yt!==void 0){const H=S(B,"rotation")/16*Math.PI*2,O=rt();X(O,O,[8,24,8]),_t(O,O,H),Lt(O,O,[2/3,2/3,2/3]),X(O,O,[-8,-24,-8]),V.merge(yt(J).transform(O))}const ut=U.get(B.getName().toString());if(ut!==void 0){const H=w(B,"facing","south"),O=rt();X(O,O,[8,8,8]),_t(O,O,H==="east"?Math.PI/2:H==="north"?Math.PI:H==="west"?Math.PI*3/2:0),Lt(O,O,[2/3,2/3,2/3]),X(O,O,[-8,-23.2,-8]),V.merge(ut(J).transform(O))}B.isWaterlogged()&&V.merge(ti("water",0,J,G,0));const lt=rt();return Lt(lt,lt,[.0625,.0625,.0625]),V.transform(lt)}e.getBlockMesh=Y})(u.SpecialRenderers||(u.SpecialRenderers={}));class qs{constructor(t,n,r,i=16){_(this,"chunks",[]);_(this,"chunkSize");this.gl=t,this.structure=n,this.resources=r,this.chunkSize=typeof i=="number"?[i,i,i]:i,this.updateStructureBuffers()}setStructure(t){this.structure=t,this.updateStructureBuffers()}updateStructureBuffers(t){var n,r;if(!!this.structure){t?t.forEach(i=>{const s=this.getChunk(i);s.mesh.clear(),s.transparentMesh.clear()}):this.chunks.forEach(i=>i.forEach(s=>s.forEach(a=>{a.mesh.clear(),a.transparentMesh.clear()})));for(const i of this.structure.getBlocks()){const s=i.state.getName(),a=i.state.getProperties(),o=(n=this.resources.getDefaultBlockProperties(s))!=null?n:{};Object.entries(o).forEach(([l,h])=>{a[l]||(a[l]=h)});const g=[Math.floor(i.pos[0]/this.chunkSize[0]),Math.floor(i.pos[1]/this.chunkSize[1]),Math.floor(i.pos[2]/this.chunkSize[2])];if(t&&!t.some(l=>Dl(l,g)))continue;const c=this.getChunk(g);try{const l=this.resources.getBlockDefinition(s),h={up:this.needsCull(i,u.Direction.UP),down:this.needsCull(i,u.Direction.DOWN),west:this.needsCull(i,u.Direction.WEST),east:this.needsCull(i,u.Direction.EAST),north:this.needsCull(i,u.Direction.NORTH),south:this.needsCull(i,u.Direction.SOUTH)},d=new it;l&&d.merge(l.getMesh(s,a,this.resources,this.resources,h));const f=u.SpecialRenderers.getBlockMesh(i.state,this.resources,h);f.isEmpty()||d.merge(f),d.isEmpty()||(this.finishChunkMesh(d,i.pos),(r=this.resources.getBlockFlags(i.state.getName()))!=null&&r.semi_transparent?c.transparentMesh.merge(d):c.mesh.merge(d))}catch(l){console.error(`Error rendering block ${s}`,l)}}t?t.forEach(i=>{const s=this.getChunk(i);s.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0,blockPos:!0}),s.transparentMesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0,blockPos:!0})}):this.chunks.forEach(i=>i.forEach(s=>s.forEach(a=>{a.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0,blockPos:!0}),a.transparentMesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0,blockPos:!0})})))}}getMeshes(){const t=this.chunks.flatMap(n=>n.flatMap(r=>r.flatMap(i=>i!=null?i:[])));return t.flatMap(n=>n.mesh.isEmpty()?[]:n.mesh).concat(t.flatMap(n=>n.transparentMesh.isEmpty()?[]:n.transparentMesh))}needsCull(t,n){var s;const r=(s=this.structure.getBlock(u.BlockPos.towards(t.pos,n)))==null?void 0:s.state;if(!r)return!1;const i=this.resources.getBlockFlags(r.getName());return t.state.getName().equals(r.getName())&&(i==null?void 0:i.self_culling)?!0:i!=null&&i.opaque?!(n===u.Direction.UP&&t.state.isWaterlogged()):t.state.isWaterlogged()&&r.isWaterlogged()}finishChunkMesh(t,n){const r=rt();X(r,r,n),t.transform(r);for(const i of t.quads){const s=i.normal();i.forEach(a=>a.normal=s),i.forEach(a=>a.blockPos=new q(n[0],n[1],n[2]))}}getChunk(t){const n=Math.abs(t[0])*2+(t[0]<0?1:0),r=Math.abs(t[1])*2+(t[1]<0?1:0),i=Math.abs(t[2])*2+(t[2]<0?1:0);return this.chunks[n]||(this.chunks[n]=[]),this.chunks[n][r]||(this.chunks[n][r]=[]),this.chunks[n][r][i]||(this.chunks[n][r][i]={mesh:new it,transparentMesh:new it}),this.chunks[n][r][i]}}class cr{}const Oe=[0,0,0];(e=>{function t(l){var f,p,v,m,w,S,E,y,k,R,I,M;const h=(f=u.Json.readObject(l))!=null?f:{},d=(p=u.Json.readString(h.type))==null?void 0:p.replace(/^minecraft:/,"");switch(d){case"constant":return new n((v=u.Color.fromJson(h.value))!=null?v:Oe);case"dye":return new r((m=u.Color.fromJson(h.default))!=null?m:Oe);case"grass":return new i((w=u.Json.readNumber(h.temperature))!=null?w:0,(S=u.Json.readNumber(h.downfall))!=null?S:0);case"firework":return new s((E=u.Color.fromJson(h.default))!=null?E:Oe);case"potion":return new a((y=u.Color.fromJson(h.default))!=null?y:Oe);case"map_color":return new o((k=u.Color.fromJson(h.default))!=null?k:Oe);case"custom_model_data":return new g((R=u.Json.readInt(h.index))!=null?R:0,(I=u.Color.fromJson(h.default))!=null?I:Oe);case"team":return new c((M=u.Color.fromJson(h.default))!=null?M:Oe);default:throw new Error(`Invalid item tint type ${d}`)}}e.fromJson=t;class n extends e{constructor(h){super(),this.value=h}getTint(h){return this.value}}e.Constant=n;class r extends e{constructor(h){super(),this.default_color=h}getTint(h){const d=h.getComponent("dyed_color");return d?d.isCompound()?u.Color.intToRgb(d.getNumber("rgb")):u.Color.intToRgb(d.getAsNumber()):this.default_color}}e.Dye=r;class i extends e{constructor(h,d){super(),this.temperature=h,this.downfall=d}getTint(h){return[124/255,189/255,107/255]}}e.Grass=i;class s extends e{constructor(h){super(),this.default_color=h}getTint(h){const d=h.getComponent("firework_explosion");if(!(d!=null&&d.isCompound()))return this.default_color;const f=d.get("colors");return!f||!f.isListOrArray()?this.default_color:(()=>{if(f.length===1)return u.Color.intToRgb(f.get(0).getAsNumber());let[v,m,w]=[0,0,0];for(const S of f.getItems())v+=(S.getAsNumber()&16711680)>>16,m+=(S.getAsNumber()&65280)>>8,w+=(S.getAsNumber()&255)>>0;return v/=f.length,m/=f.length,w/=f.length,[v/255,m/255,w/255]})()}}e.Firework=s;class a extends e{constructor(h){super(),this.default_color=h}getTint(h){const d=h.getComponent("potion_contents");if(!d)return this.default_color;const f=u.PotionContents.fromNbt(d);return u.PotionContents.getColor(f)}}e.Potion=a;class o extends e{constructor(h){super(),this.default_color=h}getTint(h){const d=h.getComponent("map_color");return d?u.Color.intToRgb(d.getAsNumber()):this.default_color}}e.MapColor=o;class g extends e{constructor(h,d){super(),this.index=h,this.default_color=d}getTint(h){var p;const d=h.getComponent("custom_model_data");if(!(d!=null&&d.isCompound()))return this.default_color;const f=d.getList("colors").get(this.index);return f?(p=u.Color.fromNbt(f))!=null?p:this.default_color:this.default_color}}e.CustomModelData=g;class c extends e{constructor(h){super(),this.default_color=h}getTint(h,d){var f;return(f=d.context_entity_team_color)!=null?f:this.default_color}}e.Team=c})(cr||(cr={}));class ei{}(e=>{function t(f){var m,w,S,E,y,k,R,I,M,T,x,N,P;const p=(m=u.Json.readObject(f))!=null?m:{},v=(w=u.Json.readString(p.type))==null?void 0:w.replace(/^minecraft:/,"");switch(v){case"bed":return new n(C.parse((S=u.Json.readString(p.texture))!=null?S:""));case"banner":return new r((E=u.Json.readString(p.color))!=null?E:"");case"conduit":return new i;case"chest":return new s(C.parse((y=u.Json.readString(p.texture))!=null?y:""),(k=u.Json.readNumber(p.openness))!=null?k:0);case"head":return new a((R=u.Json.readString(p.kind))!=null?R:"",typeof p.texture=="string"?C.parse(p.texture):void 0,(I=u.Json.readNumber(p.animation))!=null?I:0);case"shulker_box":return new o(C.parse((M=u.Json.readString(p.texture))!=null?M:""),(T=u.Json.readNumber(p.openness))!=null?T:0,(x=u.Json.readString(p.orientation))!=null?x:"up");case"shield":return new g;case"trident":return new c;case"decorated_pot":return new l;case"standing_sign":return new h((N=u.Json.readString(p.wood_type))!=null?N:"",typeof p.texture=="string"?C.parse(p.texture):void 0);case"hanging_sign":return new d((P=u.Json.readString(p.wood_type))!=null?P:"",typeof p.texture=="string"?C.parse(p.texture):void 0);default:throw new Error(`Invalid item model type ${v}`)}}e.fromJson=t;class n extends e{constructor(v){super();_(this,"renderer");this.renderer=u.SpecialRenderers.bedRenderer(v)}getMesh(v,m){const w=this.renderer("head",m),S=this.renderer("foot",m),E=rt();return X(E,E,[0,0,-16]),w.merge(S.transform(E))}}class r extends e{constructor(v){super();_(this,"renderer");this.renderer=u.SpecialRenderers.bannerRenderer(v)}getMesh(v,m){return this.renderer(m)}}class i extends e{constructor(){super()}getMesh(p,v){return u.SpecialRenderers.conduitRenderer(v)}}class s extends e{constructor(v,m){super();_(this,"renderer");this.renderer=u.SpecialRenderers.chestRenderer(v)}getMesh(v,m){const w=rt();return X(w,w,[8,8,8]),_t(w,w,Math.PI),X(w,w,[-8,-8,-8]),this.renderer(m).transform(w)}}class a extends e{constructor(v,m,w){var S;super();_(this,"renderer");this.renderer=((S={skeleton:()=>u.SpecialRenderers.headRenderer(m!=null?m:C.create("skeleton/skeleton"),2),wither_skeleton:()=>u.SpecialRenderers.headRenderer(m!=null?m:C.create("skeleton/wither_skeleton"),2),zombie:()=>u.SpecialRenderers.headRenderer(m!=null?m:C.create("zombie/zombie"),1),creeper:()=>u.SpecialRenderers.headRenderer(m!=null?m:C.create("creeper/creeper"),2),dragon:()=>u.SpecialRenderers.dragonHeadRenderer(m),piglin:()=>u.SpecialRenderers.piglinHeadRenderer(m),player:()=>u.SpecialRenderers.headRenderer(m!=null?m:C.create("player/wide/steve"),1)}[v])!=null?S:()=>()=>new it)()}getMesh(v,m){return this.renderer(m)}}class o extends e{constructor(v,m,w){super();_(this,"renderer");this.renderer=u.SpecialRenderers.shulkerBoxRenderer(v)}getMesh(v,m){return this.renderer(m)}}class g extends e{constructor(){super()}getMesh(p,v){const m=u.SpecialRenderers.shieldRenderer(v),w=rt();return X(w,w,[-3,1,0]),xn(w,w,-10*Math.PI/180),_t(w,w,-10*Math.PI/180),Ds(w,w,-5*Math.PI/180),m.transform(w)}}class c extends e{constructor(){super()}getMesh(p,v){return new it}}class l extends e{constructor(){super()}getMesh(p,v){return u.SpecialRenderers.decoratedPotRenderer(v)}}class h extends e{constructor(v,m){super();_(this,"renderer");this.renderer=u.SpecialRenderers.signRenderer(m!=null?m:C.create(v))}getMesh(v,m){return this.renderer(m)}}class d extends e{constructor(v,m){super();_(this,"renderer");this.renderer=u.SpecialRenderers.hangingSignRenderer(m!=null?m:C.create(v))}getMesh(v,m){return this.renderer(!1,m)}}})(ei||(ei={}));class ni{}const Ws=new it;(e=>{function t(l){var f,p,v,m,w,S,E,y;const h=(f=u.Json.readObject(l))!=null?f:{},d=(p=u.Json.readString(h.type))==null?void 0:p.replace(/^minecraft:/,"");switch(d){case"empty":return new n;case"model":return new r(C.parse((v=u.Json.readString(h.model))!=null?v:""),(m=u.Json.readArray(h.tints,cr.fromJson))!=null?m:[]);case"composite":return new i((w=u.Json.readArray(h.models,e.fromJson))!=null?w:[]);case"condition":return new s(s.propertyFromJson(h),e.fromJson(h.on_true),e.fromJson(h.on_false));case"select":return new a(a.propertyFromJson(h),new Map(u.Json.readArray(h.cases,k=>{var I,M;const R=(I=u.Json.readObject(k))!=null?I:{};return[(M=u.Json.readString(R.when))!=null?M:"",e.fromJson(R.model)]})),h.fallback?e.fromJson(h.fallback):void 0);case"range_dispatch":return new o(o.propertyFromJson(h),(S=u.Json.readNumber(h.scale))!=null?S:1,(E=u.Json.readArray(h.entries,k=>{var I,M;const R=(I=u.Json.readObject(k))!=null?I:{};return{threshold:(M=u.Json.readNumber(R.threshold))!=null?M:0,model:e.fromJson(R.model)}}))!=null?E:[],h.fallback?e.fromJson(h.fallback):void 0);case"special":return new g(ei.fromJson(h.model),C.parse((y=u.Json.readString(h.base))!=null?y:""));case"bundle/selected_item":return new c;default:throw new Error(`Invalid item model type ${d}`)}}e.fromJson=t;class n extends e{getMesh(h,d,f){return new it}}e.Empty=n;class r extends e{constructor(h,d){super(),this.modelId=h,this.tints=d}getMesh(h,d,f){var w;const p=d.getBlockModel(this.modelId);if(!p)throw new Error(`Model ${this.modelId} does not exist (trying to render ${h.toString()})`);const v=S=>Sp.merge(v.getMesh(h,d,f))),p}}e.Composite=i;class s extends e{constructor(h,d,f){super(),this.property=h,this.onTrue=d,this.onFalse=f}getMesh(h,d,f){return(this.property(h,f)?this.onTrue:this.onFalse).getMesh(h,d,f)}static propertyFromJson(h){var f,p,v,m,w;const d=(f=u.Json.readString(h.property))==null?void 0:f.replace(/^minecraft:/,"");switch(d){case"fishing_rod/cast":case"selected":case"carried":case"extended_view":return(k,R)=>{var I;return(I=R[d])!=null?I:!1};case"view_entity":return(k,R)=>{var I;return(I=R.context_entity_is_view_entity)!=null?I:!1};case"using_item":return(k,R)=>{var I;return((I=R.use_duration)!=null?I:-1)>=0};case"bundle/has_selected_item":return(k,R)=>{var I;return((I=R["bundle/selected_item"])!=null?I:-1)>=0};case"broken":return(k,R)=>{var T,x;const I=(T=k.getComponent("damage"))==null?void 0:T.getAsNumber(),M=(x=k.getComponent("max_damage"))==null?void 0:x.getAsNumber();return I!==void 0&&M!==void 0&&I>=M-1};case"damaged":return(k,R)=>{var T,x;const I=(T=k.getComponent("damage"))==null?void 0:T.getAsNumber(),M=(x=k.getComponent("max_damage"))==null?void 0:x.getAsNumber();return I!==void 0&&M!==void 0&&I>=1};case"has_component":const S=C.parse((p=u.Json.readString(h.component))!=null?p:"");return(v=u.Json.readBoolean(h.ignore_default))!=null,(k,R)=>k.hasComponent(S);case"keybind_down":const E=(m=u.Json.readString(h.keybind))!=null?m:"";return(k,R)=>{var I,M;return(M=(I=R.keybind_down)==null?void 0:I.includes(E))!=null?M:!1};case"custom_model_data":const y=(w=u.Json.readInt(h.index))!=null?w:0;return(k,R)=>{const I=k.getComponent("custom_model_data");if(!(I!=null&&I.isCompound()))return!1;const M=I.getList("flags").getNumber(y);return M!==void 0&&M!==0};default:throw new Error(`Invalid condition property ${d}`)}}}e.Condition=s;class a extends e{constructor(h,d,f){super(),this.property=h,this.cases=d,this.fallback=f}getMesh(h,d,f){var v,m,w;const p=this.property(h,f);return(w=(m=(v=p!==null?this.cases.get(p):void 0)!=null?v:this.fallback)==null?void 0:m.getMesh(h,d,f))!=null?w:Ws}static propertyFromJson(h){var f,p,v;const d=(f=u.Json.readString(h.property))==null?void 0:f.replace(/^minecraft:/,"");switch(d){case"main_hand":return(E,y)=>{var k;return(k=y.main_hand)!=null?k:"right"};case"display_context":return(E,y)=>{var k;return(k=y.display_context)!=null?k:"gui"};case"context_dimension":return(E,y)=>{var k,R;return(R=(k=y.context_dimension)==null?void 0:k.toString())!=null?R:null};case"charge_type":const m=C.create("firework_rocket");return(E,y)=>{const k=E.getComponent("charged_projectiles");return!(k!=null&&k.isList())||k.length===0?"none":k.filter(R=>R.isCompound()?C.parse(R.getString("id")).equals(m):!1).length>0?"rocket":"arrow"};case"trim_material":return(E,y)=>{const k=E.getComponent("trim");return k!=null&&k.isCompound()?C.parse(k.getString("material")).toString():null};case"block_state":const w=(p=u.Json.readString(h.block_state_property))!=null?p:"";return(E,y)=>{const k=E.getComponent("block_state");return k!=null&&k.isCompound()?k.getString(w):null};case"local_time":return(E,y)=>"NOT IMPLEMENTED";case"context_entity_type":return(E,y)=>{var k,R;return(R=(k=y.context_entity_type)==null?void 0:k.toString())!=null?R:null};case"custom_model_data":const S=(v=u.Json.readInt(h.index))!=null?v:0;return(E,y)=>{const k=E.getComponent("custom_model_data");if(!(k!=null&&k.isCompound()))return null;const R=k.getList("strings");return R.length<=S?null:R.getString(S)};default:throw new Error(`Invalid select property ${d}`)}}}e.Select=a;class o extends e{constructor(d,f,p,v){super();_(this,"entries");this.property=d,this.scale=f,this.fallback=v,this.entries=p.sort((m,w)=>m.threshold-w.threshold)}getMesh(d,f,p){var w;const v=this.property(d,p)*this.scale;let m=this.fallback;for(const S of this.entries)if(S.threshold<=v)m=S.model;else break;return(w=m==null?void 0:m.getMesh(d,f,p))!=null?w:Ws}static propertyFromJson(d){var p,v,m,w,S,E,y;const f=(p=u.Json.readString(d.property))==null?void 0:p.replace(/^minecraft:/,"");switch(f){case"bundle/fullness":let k=function(x){const N=x.getComponent("bundle_contents");return N!=null&&N.isListOrArray()?N.map(F=>F.isCompound()?$t.fromNbt(F):void 0).reduce((F,U)=>{var J,G;if(U===void 0)return F;if(U.hasComponent("bundle_contents"))return F+k(U)+.0625;const Y=U.getComponent("bees");if((Y==null?void 0:Y.isListOrArray())&&Y.length>0)return F+1;const B=(G=(J=U.getComponent("max_stack_size"))==null?void 0:J.getAsNumber())!=null?G:1;return F+U.count/B},0):0};return(x,N)=>k(x);case"damage":{const x=(v=u.Json.readBoolean(d.normalize))!=null?v:!0;return(N,P)=>{var Y,B,J,G;const F=(B=(Y=N.getComponent("max_damage"))==null?void 0:Y.getAsNumber())!=null?B:0,U=Mt((G=(J=N.getComponent("damage"))==null?void 0:J.getAsNumber())!=null?G:0,0,F);return x?Mt(U/F,0,1):Mt(U,0,F)}}case"count":{const x=(m=u.Json.readBoolean(d.normalize))!=null?m:!0;return(N,P)=>{var U,Y;const F=(Y=(U=N.getComponent("max_stack_size"))==null?void 0:U.getAsNumber())!=null?Y:1;return x?Mt(N.count/F,0,1):Mt(N.count,0,F)}}case"cooldown":return(x,N)=>{var U,Y,B;const P=x.getComponent("use_cooldown"),F=P!=null&&P.isCompound()?C.parse((U=P.getString("cooldown_group"))!=null?U:x.id):x.id;return(B=(Y=N.cooldown_percentage)==null?void 0:Y[F.toString()])!=null?B:0};case"time":switch((w=u.Json.readString(d.source))!=null?w:"daytime"){case"moon_phase":return(x,N)=>{var P;return((P=N.game_time)!=null?P:0)/24e3%8/8};case"random":return(x,N)=>Math.random();default:return(x,N)=>{var Y;const F=((Y=N.game_time)!=null?Y:0)/24e3%1-.25,U=.5-Math.cos(F*Math.PI)/2;return(F*2+U)/3}}case"compass":return(x,N)=>{var P;return(P=N.compass_angle)!=null?P:0};case"crossbow/pull":return(x,N)=>{var P;return(P=N["crossbow/pull"])!=null?P:0};case"use_duration":const I=(S=u.Json.readBoolean(d.remaining))!=null?S:!0;return(x,N)=>{var P;return N.use_duration===void 0||N.use_duration<0?0:I?Math.max(((P=N.max_use_duration)!=null?P:0)-N.use_duration,0):N.use_duration};case"use_cycle":const M=(E=u.Json.readNumber(d.period))!=null?E:1;return(x,N)=>{var P,F;return N.use_duration===void 0||N.use_duration<0?0:Math.max(((P=N.max_use_duration)!=null?P:0)-((F=N.use_duration)!=null?F:0),0)%M};case"custom_model_data":const T=(y=u.Json.readInt(d.index))!=null?y:0;return(x,N)=>{const P=x.getComponent("custom_model_data");return P!=null&&P.isCompound()?P.getList("floats").getNumber(T):0};default:throw new Error(`Invalid select property ${f}`)}}}e.RangeDispatch=o;class g extends e{constructor(h,d){super(),this.specialModel=h,this.base=d}getMesh(h,d,f){var m;const p=this.specialModel.getMesh(h,d),v=d.getBlockModel(this.base);if(!v)throw new Error(`Base model ${this.base} does not exist (trying to render ${h.toString()})`);return p.transform(v.getDisplayTransform((m=f.display_context)!=null?m:"gui")),p}}e.Special=g;class c extends e{getMesh(h,d,f){const p=f["bundle/selected_item"];if(p===void 0||p<0)return new it;const v=h.getComponent("bundle_contents");if(!(v!=null&&v.isListOrArray()))return new it;const m=v.get(p);return m===void 0||!m.isCompound()?new it:($t.fromNbt(m),new it)}}e.BundleSelectedItem=c})(ni||(ni={}));class Rn{constructor(t,n,r){_(this,"gl");_(this,"program");this.gl=t,this.program=this.initShaderProgram(n,r)}getProgram(){return this.program}initShaderProgram(t,n){const r=this.loadShader(this.gl.VERTEX_SHADER,t),i=this.loadShader(this.gl.FRAGMENT_SHADER,n),s=this.gl.createProgram();if(this.gl.attachShader(s,r),this.gl.attachShader(s,i),this.gl.linkProgram(s),!this.gl.getProgramParameter(s,this.gl.LINK_STATUS))throw new Error(`Unable to link shader program: ${this.gl.getProgramInfoLog(s)}`);return s}loadShader(t,n){const r=this.gl.createShader(t);if(this.gl.shaderSource(r,n),this.gl.compileShader(r),!this.gl.getShaderParameter(r,this.gl.COMPILE_STATUS)){const i=new Error(`Compiling ${t===this.gl.VERTEX_SHADER?"vertex":"fragment"} shader: ${this.gl.getShaderInfoLog(r)}`);throw this.gl.deleteShader(r),i}return r}}const Xl=` attribute vec4 vertPos; attribute vec2 texCoord; attribute vec3 vertColor; 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 = vertColor; vLighting = normal.y * 0.2 + abs(normal.z) * 0.1 + 0.8; } `,jl=` 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); } `;class lr{constructor(t){_(this,"shaderProgram");_(this,"projMatrix");_(this,"activeShader");this.gl=t,this.shaderProgram=new Rn(t,Xl,jl).getProgram(),this.activeShader=this.shaderProgram,this.projMatrix=this.getPerspective(),this.initialize()}setViewport(t,n,r,i){this.gl.viewport(t,n,r,i),this.projMatrix=this.getPerspective()}getPerspective(){const t=70*Math.PI/180,n=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,r=rt();return Ml(r,t,n,.1,500),r}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)}setShader(t){this.gl.useProgram(t),this.activeShader=t}setVertexAttr(t,n,r){if(r===void 0)throw new Error(`Expected buffer for ${t}`);const i=this.gl.getAttribLocation(this.activeShader,t);this.gl.bindBuffer(this.gl.ARRAY_BUFFER,r),this.gl.vertexAttribPointer(i,n,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(i)}setUniform(t,n){const r=this.gl.getUniformLocation(this.activeShader,t);this.gl.uniformMatrix4fv(r,!1,n)}setTexture(t){this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t)}createAtlasTexture(t){const n=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,n),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),n}prepareDraw(t){this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix)}drawMesh(t,n){if(t.quadVertices()>0){if(n.pos&&this.setVertexAttr("vertPos",3,t.posBuffer),n.color&&this.setVertexAttr("vertColor",3,t.colorBuffer),n.texture&&this.setVertexAttr("texCoord",2,t.textureBuffer),n.normal&&this.setVertexAttr("normal",3,t.normalBuffer),n.blockPos&&this.setVertexAttr("blockPos",3,t.blockPosBuffer),!t.indexBuffer)throw new Error("Expected index buffer");this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t.indexBuffer),this.gl.drawElements(this.gl.TRIANGLES,t.quadIndices(),this.gl.UNSIGNED_SHORT,0)}t.lineVertices()>0&&(n.pos&&this.setVertexAttr("vertPos",3,t.linePosBuffer),n.color&&this.setVertexAttr("vertColor",3,t.lineColorBuffer),this.gl.drawArrays(this.gl.LINES,0,t.lineVertices()))}}class ri extends lr{constructor(n,r,i,s={}){super(n);_(this,"mesh");_(this,"atlasTexture");this.item=r,this.resources=i,this.updateMesh(s),this.atlasTexture=this.createAtlasTexture(this.resources.getTextureAtlas())}setItem(n,r={}){this.item=n,this.updateMesh(r)}updateMesh(n={}){this.mesh=ri.getItemMesh(this.item,this.resources,n),this.mesh.computeNormals(),this.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0})}static getItemMesh(n,r,i){var g;const s=(g=n.getComponent("item_model",r))==null?void 0:g.getAsString();if(s===void 0)return new it;const a=r.getItemModel(C.parse(s));if(!a)throw new Error(`Item model ${s} does not exist (defined by item ${n.toString()})`);return a.getMesh(n,r,i)}getPerspective(){const n=rt();return Rl(n,0,16,0,16,.1,500),n}drawItem(){const n=rt();X(n,n,[0,0,-32]),this.setShader(this.shaderProgram),this.setTexture(this.atlasTexture),this.prepareDraw(n),this.drawMesh(this.mesh,{pos:!0,color:!0,texture:!0,normal:!0})}}const Kl=` 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; } `,Ql=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `,tu=` 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; } `,eu=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `;class nu extends lr{constructor(n,r,i,s){var o,g;super(n);_(this,"gridShaderProgram");_(this,"colorShaderProgram");_(this,"gridMesh",new it);_(this,"outlineMesh",new it);_(this,"invisibleBlocksMesh",new it);_(this,"atlasTexture");_(this,"useInvisibleBlocks");_(this,"chunkBuilder");this.structure=r,this.resources=i;const a=(o=s==null?void 0:s.chunkSize)!=null?o:16;this.chunkBuilder=new qs(n,r,i,a),s!=null&&s.facesPerBuffer&&console.warn("[deepslate renderer warning]: facesPerBuffer option has been removed in favor of chunkSize"),this.useInvisibleBlocks=(g=s==null?void 0:s.useInvisibleBlockBuffer)!=null?g:!0,this.gridShaderProgram=new Rn(n,tu,eu).getProgram(),this.colorShaderProgram=new Rn(n,Kl,Ql).getProgram(),this.gridMesh=this.getGridMesh(),this.outlineMesh=this.getOutlineMesh(),this.invisibleBlocksMesh=this.getInvisibleBlocksMesh(),this.atlasTexture=this.createAtlasTexture(this.resources.getTextureAtlas())}setStructure(n){this.structure=n,this.chunkBuilder.setStructure(n),this.gridMesh=this.getGridMesh(),this.invisibleBlocksMesh=this.getInvisibleBlocksMesh()}updateStructureBuffers(n){this.chunkBuilder.updateStructureBuffers(n)}getGridMesh(){const[n,r,i]=this.structure.getSize(),s=new it;s.addLine(0,0,0,n,0,0,[1,0,0]),s.addLine(0,0,0,0,0,i,[0,0,1]);const a=[.8,.8,.8];s.addLine(0,0,0,0,r,0,a),s.addLine(n,0,0,n,r,0,a),s.addLine(0,0,i,0,r,i,a),s.addLine(n,0,i,n,r,i,a),s.addLine(0,r,0,0,r,i,a),s.addLine(n,r,0,n,r,i,a),s.addLine(0,r,0,n,r,0,a),s.addLine(0,r,i,n,r,i,a);for(let o=1;o<=n;o+=1)s.addLine(o,0,0,o,0,i,a);for(let o=1;o<=i;o+=1)s.addLine(0,0,o,n,0,o,a);return s.rebuild(this.gl,{pos:!0,color:!0})}getOutlineMesh(){return new it().addLineCube(0,0,0,1,1,1,[1,1,1]).rebuild(this.gl,{pos:!0,color:!0})}getInvisibleBlocksMesh(){const n=new it;if(!this.useInvisibleBlocks)return n;const r=this.structure.getSize();for(let i=0;i{this.drawMesh(r,{pos:!0,color:!0,texture:!0,normal:!0})})}drawColoredStructure(n){this.setShader(this.colorShaderProgram),this.prepareDraw(n),this.chunkBuilder.getMeshes().forEach(r=>{this.drawMesh(r,{pos:!0,color:!0,normal:!0,blockPos:!0})})}drawOutline(n,r){this.setShader(this.gridShaderProgram);const i=rt();yl(i,n),X(i,i,r),this.prepareDraw(i),this.drawMesh(this.outlineMesh,{pos:!0,color:!0})}}class Nn{constructor(t,n){_(this,"part");if(this.img=t,this.idMap=n,!$r(t.width)||!$r(t.height))throw new Error(`Expected texture atlas dimensions to be powers of two, got ${t.width}x${t.height}.`);this.part=16/t.width}getTextureAtlas(){return this.img}getTextureUV(t){var n;return(n=this.idMap[t.toString()])!=null?n:[0,0,this.part,this.part]}static async fromBlobs(t){const n=Math.sqrt(Object.keys(t).length+1),r=Js(n),i=r*16,s=1/r,a=document.createElement("canvas");a.width=i,a.height=i;const o=a.getContext("2d");this.drawInvalidTexture(o);const g={};let c=1;return await Promise.all(Object.keys(t).map(async l=>{const h=c%r,d=Math.floor(c/r);c+=1,g[l]=[s*h,s*d,s*h+s,s*d+s];const f=await createImageBitmap(t[l]);o.drawImage(f,0,0,16,16,16*h,16*d,16,16)})),new Nn(o.getImageData(0,0,i,i),g)}static empty(){const t=document.createElement("canvas");t.width=16,t.height=16;const n=t.getContext("2d");return Nn.drawInvalidTexture(n),new Nn(n.getImageData(0,0,16,16),{})}static drawInvalidTexture(t){t.fillStyle="black",t.fillRect(0,0,16,16),t.fillStyle="magenta",t.fillRect(0,0,8,8),t.fillRect(8,8,8,8)}}const ru=` 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; } `,iu=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `;class su extends lr{constructor(n){super(n);_(this,"voxelShaderProgram");_(this,"voxels",[]);_(this,"quads",[]);_(this,"meshes",[]);this.voxelShaderProgram=new Rn(n,ru,iu).getProgram()}setVoxels(n){this.voxels=n,this.quads=this.getQuads(),this.meshes=this.getMeshes()}getQuads(){var i,s,a,o,g,c,l,h,d,f,p,v;const n=new Map;for(const m of this.voxels)mr(n,m.x,new Map,w=>{mr(w,m.y,new Set,S=>{S.add(m.z)})});const r=[];for(const m of this.voxels)(s=(i=n.get(m.x+1))==null?void 0:i.get(m.y))!=null&&s.has(m.z)||r.push(Yt.fromPoints(new q(m.x+1,m.y,m.z),new q(m.x+1,m.y+1,m.z),new q(m.x+1,m.y+1,m.z+1),new q(m.x+1,m.y,m.z+1)).setColor(m.color)),(o=(a=n.get(m.x-1))==null?void 0:a.get(m.y))!=null&&o.has(m.z)||r.push(Yt.fromPoints(new q(m.x,m.y,m.z+1),new q(m.x,m.y+1,m.z+1),new q(m.x,m.y+1,m.z),new q(m.x,m.y,m.z)).setColor(m.color)),(c=(g=n.get(m.x))==null?void 0:g.get(m.y+1))!=null&&c.has(m.z)||r.push(Yt.fromPoints(new q(m.x,m.y+1,m.z+1),new q(m.x+1,m.y+1,m.z+1),new q(m.x+1,m.y+1,m.z),new q(m.x,m.y+1,m.z)).setColor(m.color)),(h=(l=n.get(m.x))==null?void 0:l.get(m.y-1))!=null&&h.has(m.z)||r.push(Yt.fromPoints(new q(m.x,m.y,m.z),new q(m.x+1,m.y,m.z),new q(m.x+1,m.y,m.z+1),new q(m.x,m.y,m.z+1)).setColor(m.color)),(f=(d=n.get(m.x))==null?void 0:d.get(m.y))!=null&&f.has(m.z+1)||r.push(Yt.fromPoints(new q(m.x,m.y,m.z+1),new q(m.x+1,m.y,m.z+1),new q(m.x+1,m.y+1,m.z+1),new q(m.x,m.y+1,m.z+1)).setColor(m.color)),(v=(p=n.get(m.x))==null?void 0:p.get(m.y))!=null&&v.has(m.z-1)||r.push(Yt.fromPoints(new q(m.x,m.y+1,m.z),new q(m.x+1,m.y+1,m.z),new q(m.x+1,m.y,m.z),new q(m.x,m.y,m.z)).setColor(m.color));return console.debug(`Converted ${this.voxels.length} voxels into ${r.length} quads!`),r}getMeshes(){const n=[];let r=new it;for(const i of this.quads){const s=i.normal(),a=(s.y*.25+Math.abs(s.z)*.125+.75)/256;i.forEach(o=>o.color=[o.color[0]*a,o.color[1]*a,o.color[2]*a]),r.quads.push(i),r.quadVertices()>65e3&&(n.push(r),r=new it)}r.isEmpty()||n.push(r);for(const i of n)i.rebuild(this.gl,{pos:!0,color:!0});return n}draw(n){if(console.debug(`Drawing ${this.meshes.length} meshes...`),this.setShader(this.voxelShaderProgram),this.prepareDraw(n),this.meshes.length===0){this.gl.clearColor(0,0,0,0),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);return}for(const r of this.meshes)this.drawMesh(r,{pos:!0,color:!0})}}u.NoiseRouter=void 0,(e=>{const t=o=>new W.HolderHolder(u.Holder.parser(u.WorldgenRegistries.DENSITY_FUNCTION,W.fromJson)(o));function n(o){var c;const g=(c=u.Json.readObject(o))!=null?c:{};return{barrier:t(g.barrier),fluidLevelFloodedness:t(g.fluid_level_floodedness),fluidLevelSpread:t(g.fluid_level_spread),lava:t(g.lava),temperature:t(g.temperature),vegetation:t(g.vegetation),continents:t(g.continents),erosion:t(g.erosion),depth:t(g.depth),ridges:t(g.ridges),initialDensityWithoutJaggedness:t(g.initial_density_without_jaggedness),finalDensity:t(g.final_density),veinToggle:t(g.vein_toggle),veinRidged:t(g.vein_ridged),veinGap:t(g.vein_gap)}}e.fromJson=n;function r(o){return{barrier:W.Constant.ZERO,fluidLevelFloodedness:W.Constant.ZERO,fluidLevelSpread:W.Constant.ZERO,lava:W.Constant.ZERO,temperature:W.Constant.ZERO,vegetation:W.Constant.ZERO,continents:W.Constant.ZERO,erosion:W.Constant.ZERO,depth:W.Constant.ZERO,ridges:W.Constant.ZERO,initialDensityWithoutJaggedness:W.Constant.ZERO,finalDensity:W.Constant.ZERO,veinToggle:W.Constant.ZERO,veinRidged:W.Constant.ZERO,veinGap:W.Constant.ZERO,...o}}e.create=r;function i(o,g){return{barrier:o.barrier.mapAll(g),fluidLevelFloodedness:o.fluidLevelFloodedness.mapAll(g),fluidLevelSpread:o.fluidLevelSpread.mapAll(g),lava:o.lava.mapAll(g),temperature:o.temperature.mapAll(g),vegetation:o.vegetation.mapAll(g),continents:o.continents.mapAll(g),erosion:o.erosion.mapAll(g),depth:o.depth.mapAll(g),ridges:o.ridges.mapAll(g),initialDensityWithoutJaggedness:o.initialDensityWithoutJaggedness.mapAll(g),finalDensity:o.finalDensity.mapAll(g),veinToggle:o.veinToggle.mapAll(g),veinRidged:o.veinRidged.mapAll(g),veinGap:o.veinGap.mapAll(g)}}e.mapAll=i;const s=new Map;function a(o,g){var f;const c=(f=g.key())==null?void 0:f.toString();if(!c)throw new Error("Cannot instantiate noise from direct holder");const l=o.seedKey(),h=s.get(c);if(h&&h[0]===l[0]&&h[1]===l[1])return h[2];const d=new ie(o.fromHashOf(c),g.value());return s.set(c,[l[0],l[1],d]),d}e.instantiate=a})(u.NoiseRouter||(u.NoiseRouter={})),u.NoiseSettings=void 0,(e=>{function t(o){var c,l,h,d,f;const g=(c=u.Json.readObject(o))!=null?c:{};return{minY:(l=u.Json.readInt(g.min_y))!=null?l:0,height:(h=u.Json.readInt(g.height))!=null?h:256,xzSize:(d=u.Json.readInt(g.size_horizontal))!=null?d:1,ySize:(f=u.Json.readInt(g.size_vertical))!=null?f:1}}e.fromJson=t;function n(o){return{minY:0,height:256,xzSize:1,ySize:1,...o}}e.create=n;function r(o){return o.ySize<<2}e.cellHeight=r;function i(o){return o.xzSize<<2}e.cellWidth=i;function s(o){return o.height/r(o)}e.cellCountY=s;function a(o){return Math.floor(o.minY/r(o))}e.minCellY=a})(u.NoiseSettings||(u.NoiseSettings={})),u.NoiseSlideSettings=void 0,(e=>{function t(r){var s,a,o,g;const i=(s=u.Json.readObject(r))!=null?s:{};return{target:(a=u.Json.readNumber(i.target))!=null?a:0,size:(o=u.Json.readInt(i.size))!=null?o:0,offset:(g=u.Json.readInt(i.offset))!=null?g:0}}e.fromJson=t;function n(r,i,s){if(r.size<=0)return i;const a=(s-r.offset)/r.size;return Qn(r.target,i,a)}e.apply=n})(u.NoiseSlideSettings||(u.NoiseSlideSettings={})),u.VerticalAnchor=void 0,(e=>{function t(s){var o,g,c,l;const a=(o=u.Json.readObject(s))!=null?o:{};return a.absolute!==void 0?n((g=u.Json.readNumber(a.absolute))!=null?g:0):a.above_bottom!==void 0?r((c=u.Json.readNumber(a.above_bottom))!=null?c:0):a.below_top!==void 0?i((l=u.Json.readNumber(a.below_top))!=null?l:0):()=>0}e.fromJson=t;function n(s){return()=>s}e.absolute=n;function r(s){return a=>a.minY+s}e.aboveBottom=r;function i(s){return a=>a.minY+a.height-1-s}e.belowTop=i})(u.VerticalAnchor||(u.VerticalAnchor={}));class Xs{constructor(t,n,r){_(this,"surfaceNoise");_(this,"surfaceSecondaryNoise");_(this,"random");_(this,"positionalRandoms");this.rule=t,this.defaultBlock=n,this.random=nt.create(r).forkPositional(),this.surfaceNoise=u.NoiseRouter.instantiate(this.random,u.WorldgenRegistries.SURFACE_NOISE),this.surfaceSecondaryNoise=u.NoiseRouter.instantiate(this.random,u.WorldgenRegistries.SURFACE_SECONDARY_NOISE),this.positionalRandoms=new Map}buildSurface(t,n,r,i){const s=u.ChunkPos.minBlockX(t.pos),a=u.ChunkPos.minBlockZ(t.pos),o=new js(this,t,n,r,i),g=this.rule(o);for(let c=0;c<16;c+=1){const l=s+c;for(let h=0;h<1;h+=1){const d=a+h;o.updateXZ(l,d);let f=0,p=Number.MIN_SAFE_INTEGER,v=Number.MAX_SAFE_INTEGER;for(let m=t.maxY;m>=t.minY;m-=1){const w=u.BlockPos.create(l,m,d),S=t.getBlockState(w);if(S.equals(j.AIR)){f=0,p=Number.MIN_SAFE_INTEGER;continue}if(S.isFluid()){p===Number.MIN_SAFE_INTEGER&&(p=m+1);continue}if(v>=m){v=Number.MIN_SAFE_INTEGER;for(let k=m-1;k>=t.minY;k-=1){const R=t.getBlockState(u.BlockPos.create(l,k,d));if(R.equals(j.AIR)||R.isFluid()){v=k+1;break}}}f+=1;const E=m-v+1;if(!S.equals(this.defaultBlock))continue;o.updateY(f,E,p,m);const y=g(l,m,d);y&&t.setBlockState(w,y)}}}}getSurfaceDepth(t,n){const r=this.surfaceNoise.sample(t,0,n),i=this.random.at(t,0,n).nextDouble()*.25;return r*2.75+3+i}getSurfaceSecondary(t,n){return this.surfaceSecondaryNoise.sample(t,0,n)}getRandom(t){return Ee(this.positionalRandoms,t,()=>this.random.fromHashOf(t))}}class js{constructor(t,n,r,i,s){_(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);this.system=t,this.chunk=n,this.noiseChunk=r,this.context=i,this.getBiome=s}updateXZ(t,n){this.blockX=t,this.blockZ=n,this.surfaceDepth=this.system.getSurfaceDepth(t,n),this.surfaceSecondary=rn(()=>this.system.getSurfaceSecondary(t,n)),this.minSurfaceLevel=rn(()=>this.calculateMinSurfaceLevel(t,n))}updateY(t,n,r,i){this.blockY=i,this.stoneDepthAbove=t,this.stoneDepthBelow=n,this.waterHeight=r,this.biome=rn(()=>this.getBiome(u.BlockPos.create(this.blockX,this.blockY,this.blockZ)))}calculateMinSurfaceLevel(t,n){const r=t>>4,i=n>>4,s=this.noiseChunk.getPreliminarySurfaceLevel(r<<4,i<<4),a=this.noiseChunk.getPreliminarySurfaceLevel(r+1<<4,i<<4),o=this.noiseChunk.getPreliminarySurfaceLevel(r<<4,i+1<<4),g=this.noiseChunk.getPreliminarySurfaceLevel(r+1<<4,i+1<<4);return Math.floor(Kn((t&15)/16,(n&15)/16,s,a,o,g))+this.surfaceDepth-8}}u.SurfaceRule=void 0,(e=>{e.NOOP=()=>()=>{};function t(s){var g,c,l;const a=(g=u.Json.readObject(s))!=null?g:{};switch((c=u.Json.readString(a.type))==null?void 0:c.replace(/^minecraft:/,"")){case"block":return n(j.fromJson(a.result_state));case"sequence":return r((l=u.Json.readArray(a.sequence,e.fromJson))!=null?l:[]);case"condition":return i(u.SurfaceCondition.fromJson(a.if_true),e.fromJson(a.then_run))}return e.NOOP}e.fromJson=t;function n(s){return()=>()=>s}e.block=n;function r(s){return a=>{const o=s.map(g=>g(a));return(g,c,l)=>{for(const h of o){const d=h(g,c,l);if(d)return d}}}}e.sequence=r;function i(s,a){return o=>(g,c,l)=>{if(s(o))return a(o)(g,c,l)}}e.condition=i})(u.SurfaceRule||(u.SurfaceRule={})),u.SurfaceCondition=void 0,(e=>{e.FALSE=()=>!1,e.TRUE=()=>!0;function t(c){var d,f,p,v,m,w,S,E,y,k,R,I;const l=(d=u.Json.readObject(c))!=null?d:{};switch((f=u.Json.readString(l.type))==null?void 0:f.replace(/^minecraft:/,"")){case"above_preliminary_surface":return n();case"biome":return r((p=u.Json.readArray(l.biome_is,M=>{var T;return(T=u.Json.readString(M))!=null?T:""}))!=null?p:[]);case"not":return i(e.fromJson(l.invert));case"stone_depth":return s((v=u.Json.readInt(l.offset))!=null?v:0,(m=u.Json.readBoolean(l.add_surface_depth))!=null?m:!1,(w=u.Json.readInt(l.secondary_depth_range))!=null?w:0,u.Json.readString(l.surface_type)==="ceiling");case"vertical_gradient":return a((S=u.Json.readString(l.random_name))!=null?S:"",u.VerticalAnchor.fromJson(l.true_at_and_below),u.VerticalAnchor.fromJson(l.false_at_and_above));case"water":return o((E=u.Json.readInt(l.offset))!=null?E:0,(y=u.Json.readInt(l.surface_depth_multiplier))!=null?y:0,(k=u.Json.readBoolean(l.add_surface_depth))!=null?k:!1);case"y_above":return g(u.VerticalAnchor.fromJson(l.anchor),(R=u.Json.readInt(l.surface_depth_multiplier))!=null?R:0,(I=u.Json.readBoolean(l.add_surface_depth))!=null?I:!1)}return e.FALSE}e.fromJson=t;function n(){return c=>c.blockY>=c.minSurfaceLevel()}e.abovePreliminarySurface=n;function r(c){const l=new Set(c);return h=>l.has(h.biome())}e.biome=r;function i(c){return l=>!c(l)}e.not=i;function s(c,l,h,d){return f=>{const p=d?f.stoneDepthBelow:f.stoneDepthAbove,v=l?f.surfaceDepth:0,m=h===0?0:An(f.surfaceSecondary(),-1,1,0,h);return p<=1+c+v+m}}e.stoneDepth=s;function a(c,l,h){return d=>{const f=l(d.context),p=h(d.context);if(d.blockY<=f)return!0;if(d.blockY>=p)return!1;const v=d.system.getRandom(c),m=An(d.blockY,f,p,1,0);return v.nextFloat(){if(d.waterHeight===Number.MIN_SAFE_INTEGER)return!0;const f=h?d.stoneDepthAbove:0;return d.blockY+f>=d.waterHeight+c+d.surfaceDepth*l}}e.water=o;function g(c,l,h){return d=>{const f=h?d.stoneDepthAbove:0;return d.blockY+f>=c(d.context)+d.surfaceDepth*l}}e.yAbove=g})(u.SurfaceCondition||(u.SurfaceCondition={})),u.NoiseGeneratorSettings=void 0,(e=>{function t(r){var s,a,o,g,c,l;const i=(s=u.Json.readObject(r))!=null?s:{};return{surfaceRule:u.SurfaceRule.fromJson(i.surface_rule),noise:u.NoiseSettings.fromJson(i.noise),defaultBlock:j.fromJson(i.default_block),defaultFluid:j.fromJson(i.default_fluid),noiseRouter:u.NoiseRouter.fromJson(i.noise_router),seaLevel:(a=u.Json.readInt(i.sea_level))!=null?a:0,disableMobGeneration:(o=u.Json.readBoolean(i.disable_mob_generation))!=null?o:!1,aquifersEnabled:(g=u.Json.readBoolean(i.aquifers_enabled))!=null?g:!1,oreVeinsEnabled:(c=u.Json.readBoolean(i.ore_veins_enabled))!=null?c:!1,legacyRandomSource:(l=u.Json.readBoolean(i.legacy_random_source))!=null?l:!1}}e.fromJson=t;function n(r){return{surfaceRule:u.SurfaceRule.NOOP,noise:u.NoiseSettings.create({}),defaultBlock:j.STONE,defaultFluid:j.WATER,noiseRouter:u.NoiseRouter.create({}),seaLevel:0,disableMobGeneration:!1,aquifersEnabled:!1,oreVeinsEnabled:!1,legacyRandomSource:!1,...r}}e.create=n})(u.NoiseGeneratorSettings||(u.NoiseGeneratorSettings={})),u.WorldgenRegistries=void 0,(e=>{e.NOISE=xt.createAndRegister("worldgen/noise",u.NoiseParameters.fromJson),e.DENSITY_FUNCTION=xt.createAndRegister("worldgen/density_function",n=>W.fromJson(n)),e.NOISE_SETTINGS=xt.createAndRegister("worldgen/noise_settings",u.NoiseGeneratorSettings.fromJson),e.BIOME=xt.createAndRegister("worldgen/biome"),e.SURFACE_NOISE=t("surface",-6,[1,1,1]),e.SURFACE_SECONDARY_NOISE=t("surface_secondary",-6,[1,1,0,1]);function t(n,r,i){return e.NOISE.register(C.create(n),u.NoiseParameters.create(r,i),!0)}})(u.WorldgenRegistries||(u.WorldgenRegistries={}));class W{minValue(){return-this.maxValue()}mapAll(t){return t.map(this)}}(e=>{function t(V,A,b){return{x:V,y:A,z:b}}e.context=t;class n extends e{constructor(A){super(),this.input=A}compute(A){return this.transform(A,this.input.compute(A))}}const r=u.Holder.parser(u.WorldgenRegistries.NOISE,u.NoiseParameters.fromJson);function i(V,A=i){var z,Z,Q,It,kt,yt,ut,lt,H,O,ct,nn,Ln,Pn,si,ai,oi,ta,ea,na;if(typeof V=="string")return new a(u.Holder.reference(u.WorldgenRegistries.DENSITY_FUNCTION,C.parse(V)));if(typeof V=="number")return new s(V);const b=(z=u.Json.readObject(V))!=null?z:{},L=(Z=u.Json.readString(b.type))==null?void 0:Z.replace(/^minecraft:/,"");switch(L){case"blend_alpha":return new o(1,0,1);case"blend_offset":return new o(0,-1/0,1/0);case"beardifier":return new o(0,-1/0,1/0);case"old_blended_noise":return new g((Q=u.Json.readNumber(b.xz_scale))!=null?Q:1,(It=u.Json.readNumber(b.y_scale))!=null?It:1,(kt=u.Json.readNumber(b.xz_factor))!=null?kt:80,(yt=u.Json.readNumber(b.y_factor))!=null?yt:160,(ut=u.Json.readNumber(b.smear_scale_multiplier))!=null?ut:8);case"flat_cache":return new l(A(b.argument));case"interpolated":return new p(A(b.argument));case"cache_2d":return new d(A(b.argument));case"cache_once":return new f(A(b.argument));case"cache_all_in_cell":return new h(A(b.argument));case"noise":return new v((lt=u.Json.readNumber(b.xz_scale))!=null?lt:1,(H=u.Json.readNumber(b.y_scale))!=null?H:1,r(b.noise));case"end_islands":return new m;case"weird_scaled_sampler":return new S(A(b.input),u.Json.readEnum(b.rarity_value_mapper,w),r(b.noise));case"shifted_noise":return new E(A(b.shift_x),A(b.shift_y),A(b.shift_z),(O=u.Json.readNumber(b.xz_scale))!=null?O:1,(ct=u.Json.readNumber(b.y_scale))!=null?ct:1,r(b.noise));case"range_choice":return new y(A(b.input),(nn=u.Json.readNumber(b.min_inclusive))!=null?nn:0,(Ln=u.Json.readNumber(b.max_exclusive))!=null?Ln:1,A(b.when_in_range),A(b.when_out_of_range));case"shift_a":return new R(r(b.argument));case"shift_b":return new I(r(b.argument));case"shift":return new M(r(b.argument));case"blend_density":return new T(A(b.argument));case"clamp":return new x(A(b.input),(Pn=u.Json.readNumber(b.min))!=null?Pn:0,(si=u.Json.readNumber(b.max))!=null?si:1);case"abs":case"square":case"cube":case"half_negative":case"quarter_negative":case"squeeze":return new N(L,A(b.argument));case"add":case"mul":case"min":case"max":return new F(u.Json.readEnum(L,P),A(b.argument1),A(b.argument2));case"spline":return new U(u.CubicSpline.fromJson(b.spline,A));case"constant":return new s((ai=u.Json.readNumber(b.argument))!=null?ai:0);case"y_clamped_gradient":return new Y((oi=u.Json.readInt(b.from_y))!=null?oi:-4064,(ta=u.Json.readInt(b.to_y))!=null?ta:4062,(ea=u.Json.readNumber(b.from_value))!=null?ea:-4064,(na=u.Json.readNumber(b.to_value))!=null?na:4062)}return s.ZERO}e.fromJson=i;const B=class extends e{constructor(A){super(),this.value=A}compute(){return this.value}minValue(){return this.value}maxValue(){return this.value}};let s=B;_(s,"ZERO",new B(0)),_(s,"ONE",new B(1)),e.Constant=s;class a extends e{constructor(A){super(),this.holder=A}compute(A){return this.holder.value().compute(A)}minValue(){return this.holder.value().minValue()}maxValue(){return this.holder.value().maxValue()}}e.HolderHolder=a;class o extends e.Constant{constructor(A,b,L){super(A),this.min=b,this.max=L}minValue(){return this.min}maxValue(){return this.max}}e.ConstantMinMax=o;class g extends e{constructor(A,b,L,z,Z,Q){super(),this.xzScale=A,this.yScale=b,this.xzFactor=L,this.yFactor=z,this.smearScaleMultiplier=Z,this.blendedNoise=Q}compute(A){var b,L;return(L=(b=this.blendedNoise)==null?void 0:b.sample(A.x,A.y,A.z))!=null?L:0}maxValue(){var A,b;return(b=(A=this.blendedNoise)==null?void 0:A.maxValue)!=null?b:0}}e.OldBlendedNoise=g;class c extends e{constructor(A){super(),this.wrapped=A}minValue(){return this.wrapped.minValue()}maxValue(){return this.wrapped.maxValue()}}class l extends c{constructor(b){super(b);_(this,"lastQuartX");_(this,"lastQuartZ");_(this,"lastValue",0)}compute(b){const L=b.x>>2,z=b.z>>2;return(this.lastQuartX!==L||this.lastQuartZ!==z)&&(this.lastValue=this.wrapped.compute(e.context(L<<2,0,z<<2)),this.lastQuartX=L,this.lastQuartZ=z),this.lastValue}mapAll(b){return b.map(new l(this.wrapped.mapAll(b)))}}e.FlatCache=l;class h extends c{constructor(A){super(A)}compute(A){return this.wrapped.compute(A)}mapAll(A){return A.map(new h(this.wrapped.mapAll(A)))}}e.CacheAllInCell=h;class d extends c{constructor(b){super(b);_(this,"lastBlockX");_(this,"lastBlockZ");_(this,"lastValue",0)}compute(b){const L=b.x,z=b.z;return(this.lastBlockX!==L||this.lastBlockZ!==z)&&(this.lastValue=this.wrapped.compute(b),this.lastBlockX=L,this.lastBlockZ=z),this.lastValue}mapAll(b){return b.map(new d(this.wrapped.mapAll(b)))}}e.Cache2D=d;class f extends c{constructor(b){super(b);_(this,"lastBlockX");_(this,"lastBlockY");_(this,"lastBlockZ");_(this,"lastValue",0)}compute(b){const L=b.x,z=b.y,Z=b.z;return(this.lastBlockX!==L||this.lastBlockY!==z||this.lastBlockZ!==Z)&&(this.lastValue=this.wrapped.compute(b),this.lastBlockX=L,this.lastBlockY=z,this.lastBlockZ=Z),this.lastValue}mapAll(b){return b.map(new f(this.wrapped.mapAll(b)))}}e.CacheOnce=f;class p extends c{constructor(b,L=4,z=4){super(b);_(this,"values");this.cellWidth=L,this.cellHeight=z,this.values=new Map}compute({x:b,y:L,z}){const Z=this.cellWidth,Q=this.cellHeight,It=(b%Z+Z)%Z/Z,kt=(L%Q+Q)%Q/Q,yt=(z%Z+Z)%Z/Z,ut=Math.floor(b/Z)*Z,lt=Math.floor(L/Q)*Q,H=Math.floor(z/Z)*Z;return Ps(It,kt,yt,()=>this.computeCorner(ut,lt,H),()=>this.computeCorner(ut+Z,lt,H),()=>this.computeCorner(ut,lt+Q,H),()=>this.computeCorner(ut+Z,lt+Q,H),()=>this.computeCorner(ut,lt,H+Z),()=>this.computeCorner(ut+Z,lt,H+Z),()=>this.computeCorner(ut,lt+Q,H+Z),()=>this.computeCorner(ut+Z,lt+Q,H+Z))}computeCorner(b,L,z){return Ee(this.values,`${b} ${L} ${z}`,()=>this.wrapped.compute(e.context(b,L,z)))}mapAll(b){return b.map(new p(this.wrapped.mapAll(b)))}withCellSize(b,L){return new p(this.wrapped,b,L)}}e.Interpolated=p;class v extends e{constructor(A,b,L,z){super(),this.xzScale=A,this.yScale=b,this.noiseData=L,this.noise=z}compute(A){var b,L;return(L=(b=this.noise)==null?void 0:b.sample(A.x*this.xzScale,A.y*this.yScale,A.z*this.xzScale))!=null?L:0}maxValue(){var A,b;return(b=(A=this.noise)==null?void 0:A.maxValue)!=null?b:2}}e.Noise=v;class m extends e{constructor(b){super();_(this,"islandNoise");const L=new at(b!=null?b:BigInt(0));L.consume(17292),this.islandNoise=new pt(L)}getHeightValue(b,L){const z=Math.floor(b/2),Z=Math.floor(L/2),Q=b%2,It=L%2;let kt=Mt(100-Math.sqrt(b*b+L*L)*8,-100,80);for(let yt=-12;yt<=12;yt+=1)for(let ut=-12;ut<=12;ut+=1){const lt=z+yt,H=Z+ut;if(lt*lt+H*H<=4096||this.islandNoise.sample2D(lt,H)>=-.9)continue;const O=(Math.abs(lt)*3439+Math.abs(H)*147)%13+9,ct=Q+yt*2,nn=It+ut*2,Ln=100-Math.sqrt(ct*ct+nn*nn)*O,Pn=Mt(Ln,-100,80);kt=Math.max(kt,Pn)}return kt}compute({x:b,y:L,z}){return(this.getHeightValue(Math.floor(b/8),Math.floor(z/8))-8)/128}minValue(){return-.84375}maxValue(){return .5625}}e.EndIslands=m;const w=["type_1","type_2"],J=class extends n{constructor(b,L,z,Z){super(b);_(this,"mapper");this.rarityValueMapper=L,this.noiseData=z,this.noise=Z,this.mapper=J.ValueMapper[this.rarityValueMapper]}transform(b,L){if(!this.noise)return 0;const z=this.mapper(L);return z*Math.abs(this.noise.sample(b.x/z,b.y/z,b.z/z))}mapAll(b){return b.map(new J(this.input.mapAll(b),this.rarityValueMapper,this.noiseData,this.noise))}minValue(){return 0}maxValue(){return this.rarityValueMapper==="type_1"?2:3}static rarityValueMapper1(b){return b<-.5?.75:b<0?1:b<.5?1.5:2}static rarityValueMapper2(b){return b<-.75?.5:b<-.5?.75:b<.5?1:b<.75?2:3}};let S=J;_(S,"ValueMapper",{type_1:J.rarityValueMapper1,type_2:J.rarityValueMapper2}),e.WeirdScaledSampler=S;class E extends v{constructor(A,b,L,z,Z,Q,It){super(z,Z,Q,It),this.shiftX=A,this.shiftY=b,this.shiftZ=L}compute(A){var Z,Q;const b=A.x*this.xzScale+this.shiftX.compute(A),L=A.y*this.yScale+this.shiftY.compute(A),z=A.z*this.xzScale+this.shiftZ.compute(A);return(Q=(Z=this.noise)==null?void 0:Z.sample(b,L,z))!=null?Q:0}mapAll(A){return A.map(new E(this.shiftX.mapAll(A),this.shiftY.mapAll(A),this.shiftZ.mapAll(A),this.xzScale,this.yScale,this.noiseData,this.noise))}}e.ShiftedNoise=E;class y extends e{constructor(A,b,L,z,Z){super(),this.input=A,this.minInclusive=b,this.maxExclusive=L,this.whenInRange=z,this.whenOutOfRange=Z}compute(A){const b=this.input.compute(A);return this.minInclusive<=b&&bMath.abs(b),square:b=>b*b,cube:b=>b*b*b,half_negative:b=>b>0?b:b*.5,quarter_negative:b=>b>0?b:b*.25,squeeze:b=>{const L=Mt(b,-1,1);return L/2-L*L*L/24}}),e.Mapped=N;const P=["add","mul","min","max"];class F extends e{constructor(A,b,L,z,Z){super(),this.type=A,this.argument1=b,this.argument2=L,this.min=z,this.max=Z}compute(A){const b=this.argument1.compute(A);switch(this.type){case"add":return b+this.argument2.compute(A);case"mul":return b===0?0:b*this.argument2.compute(A);case"min":return bthis.argument2.maxValue()?b:Math.max(b,this.argument2.compute(A))}}mapAll(A){return A.map(new F(this.type,this.argument1.mapAll(A),this.argument2.mapAll(A)))}minValue(){var A;return(A=this.min)!=null?A:-1/0}maxValue(){var A;return(A=this.max)!=null?A:1/0}withMinMax(){const A=this.argument1.minValue(),b=this.argument2.minValue(),L=this.argument1.maxValue(),z=this.argument2.maxValue();(this.type==="min"||this.type==="max")&&(A>=z||b>=L)&&console.warn(`Creating a ${this.type} function between two non-overlapping inputs`);let Z,Q;switch(this.type){case"add":Z=A+b,Q=L+z;break;case"mul":Z=A>0&&b>0?A*b||0:L<0&&z<0?L*z||0:Math.min(A*z||0,b*L||0),Q=A>0&&b>0?L*z||0:L<0&&z<0?A*b||0:Math.max(A*b||0,L*z||0);break;case"min":Z=Math.min(A,b),Q=Math.min(L,z);break;case"max":Z=Math.max(A,b),Q=Math.max(L,z);break}return new F(this.type,this.argument1,this.argument2,Z,Q)}}e.Ap2=F;class U extends e{constructor(A){super(),this.spline=A}compute(A){return this.spline.compute(A)}mapAll(A){const b=this.spline.mapAll(L=>L instanceof e?L.mapAll(A):L);return b.calculateMinMax(),A.map(new U(b))}minValue(){return this.spline.min()}maxValue(){return this.spline.max()}}e.Spline=U;class Y extends e{constructor(A,b,L,z){super(),this.fromY=A,this.toY=b,this.fromValue=L,this.toValue=z}compute(A){return Gr(A.y,this.fromY,this.toY,this.fromValue,this.toValue)}minValue(){return Math.min(this.fromValue,this.toValue)}maxValue(){return Math.max(this.fromValue,this.toValue)}}e.YClampedGradient=Y})(W||(W={}));class Cn{constructor(t,n){this.level=t,this.type=n}at(t){return t{function t(n){return{compute({x:r,y:i,z:s},a){if(!(a>0))return n(r,i,s).at(i)}}}e.createDisabled=t})(u.Aquifer||(u.Aquifer={}));const Jt=class{constructor(t,n,r,i,s,a,o){_(this,"minGridX");_(this,"minGridY");_(this,"minGridZ");_(this,"gridSizeX");_(this,"gridSizeZ");_(this,"gridSize");_(this,"aquiferCache");_(this,"aquiferLocationCache");this.noiseChunk=t,this.router=r,this.random=i,this.globalFluidPicker=o,this.minGridX=this.gridX(u.ChunkPos.minBlockX(n))-1,this.gridSizeX=this.gridX(u.ChunkPos.maxBlockX(n))+1-this.minGridX+1,this.minGridY=this.gridY(s)-1,this.minGridZ=this.gridZ(u.ChunkPos.minBlockZ(n))-1,this.gridSizeZ=this.gridZ(u.ChunkPos.maxBlockZ(n))+1-this.minGridZ+1;const g=this.gridY(s+a)+1-this.minGridY+1;this.gridSize=this.gridSizeX*g*this.gridSizeZ,this.aquiferCache=Array(this.gridSize).fill(void 0),this.aquiferLocationCache=Array(this.gridSize).fill(u.BlockPos.ZERO)}compute({x:t,y:n,z:r},i){if(i<=0){if(this.globalFluidPicker(t,n,r).at(n).is(j.LAVA))return j.LAVA;{const s=this.gridX(t-5),a=this.gridY(n+1),o=this.gridZ(r-5);let g=Number.MAX_SAFE_INTEGER,c=Number.MAX_SAFE_INTEGER,l=Number.MAX_SAFE_INTEGER,h=u.BlockPos.ZERO,d=u.BlockPos.ZERO,f=u.BlockPos.ZERO;for(let k=0;k<=1;k+=1)for(let R=-1;R<=1;R+=1)for(let I=0;I<=1;I+=1){const M=this.getLocation(s+k,a+R,o+I),T=u.BlockPos.magnitude(M);g>=T?(f=d,d=h,h=M,l=c,c=g,g=T):c>=T?(f=d,d=M,l=c,c=T):l>=T&&(f=M,l=T)}const p=this.getStatus(h),v=this.getStatus(d),m=this.getStatus(f),w=Jt.similarity(g,c),S=Jt.similarity(g,l),E=Jt.similarity(c,l);let y;if(p.at(n).is(j.WATER)&&this.globalFluidPicker(t,n-1,r).at(n-1).is(j.LAVA))y=1;else if(w>-1){const k=rn(()=>this.router.barrier.compute(W.context(t,n*.5,r))),R=this.calculatePressure(n,p,v,k),I=this.calculatePressure(n,p,m,k),M=this.calculatePressure(n,v,m,k),T=Math.max(R,I*Math.max(0,S),M*Math.max(E));y=Math.max(0,2*Math.max(0,w)*T)}else y=0;if(i+y<=0)return p.at(n)}}}static similarity(t,n){return 1-Math.abs(n-t)/25}calculatePressure(t,n,r,i){const s=n.at(t),a=r.at(t);if(s.is(j.LAVA)&&a.is(j.WATER)||s.is(j.WATER)&&a.is(j.LAVA))return 1;const o=Math.abs(n.level-r.level);if(o===0)return 0;const g=(n.level+r.level)/2,c=t+.5-g,l=o/2-Math.abs(c),h=c>0?l>0?l/1.5:l/2.5:l>-3?(l+3)/3:(l+3)/10;return h<-2||h>2?h:h+i()}getStatus(t){const[n,r,i]=t,s=this.getIndex(this.gridX(n),this.gridY(r),this.gridZ(i)),a=this.aquiferCache[s];if(a!==void 0)return a;const o=this.computeStatus(n,r,i);return this.aquiferCache[s]=o,o}computeStatus(t,n,r){const i=this.globalFluidPicker(t,n,r);let s=Number.MAX_SAFE_INTEGER,a=!1;for(const[p,v]of Jt.SURFACE_SAMPLING){const m=t+(v<<4),w=r+(v<<4),S=this.noiseChunk.getPreliminarySurfaceLevel(m,w);s=Math.min(s,S);const E=p===0&&v===0;if(E&&n-12>S+8)return i;if(E||n+12>S+8){const y=this.globalFluidPicker(m,S+8,w);if(!y.at(S+8).is(j.AIR)){if(E)return y;a=!0}}}const o=a?Gr(s+8-n,0,64,1,0):0,g=Mt(this.router.fluidLevelFloodedness.compute(W.context(t,n*.67,r)),-1,1);if(g>An(o,1,0,-.3,.8))return i;if(g<=An(o,1,0,-.8,.4))return new Cn(Number.MIN_SAFE_INTEGER,i.type);const c=Math.floor(n/40),l=this.router.fluidLevelSpread.compute(W.context(Math.floor(t/16),c,Math.floor(r/16))),h=c*40+20+Math.floor(l/3)*3,d=Math.min(s,h),f=this.getFluidType(t,n,r,i.type,h);return new Cn(d,f)}getFluidType(t,n,r,i,s){if(s<=-10){const a=this.router.lava.compute(W.context(Math.floor(t/64),Math.floor(n/40),Math.floor(r/64)));if(Math.abs(a)>.3)return j.LAVA}return i}getLocation(t,n,r){const i=this.getIndex(t,n,r),s=this.aquiferLocationCache[i];if(u.BlockPos.equals(s,u.BlockPos.ZERO))return s;const a=this.random.at(t,n,r),o=u.BlockPos.create(t*Jt.X_SPACING+a.nextInt(10),n*Jt.Y_SPACING+a.nextInt(9),r*Jt.Z_SPACING+a.nextInt(10));return this.aquiferLocationCache[i]=o,o}getIndex(t,n,r){const i=t-this.minGridX,s=n-this.minGridY,a=r-this.minGridZ,o=(s*this.gridSizeZ+a)*this.gridSizeX+i;if(o<0||o>=this.gridSize)throw new Error(`Invalid aquifer index at ${t} ${n} ${r}: 0 <= ${o} < ${this.gridSize}`);return o}gridX(t){return Math.floor(t/Jt.X_SPACING)}gridY(t){return Math.floor(t/Jt.Y_SPACING)}gridZ(t){return Math.floor(t/Jt.Z_SPACING)}};let Je=Jt;_(Je,"X_SPACING",16),_(Je,"Y_SPACING",12),_(Je,"Z_SPACING",16),_(Je,"SURFACE_SAMPLING",[[-2,-1],[-1,-1],[0,-1],[1,-1],[-3,0],[-2,0],[-1,0],[0,0],[1,0],[-2,1],[-1,1],[0,1],[1,1]]),u.HeightProvider=void 0,(e=>{function t(g){var h,d,f;const c=(h=u.Json.readObject(g))!=null?h:{};switch((d=u.Json.readString(c.type))==null?void 0:d.replace(/^minecraft:/,"")){case void 0:return n(u.VerticalAnchor.fromJson(g));case"constant":return n(u.VerticalAnchor.fromJson(c.value));case"uniform":return r(u.VerticalAnchor.fromJson(c.min_inclusive),u.VerticalAnchor.fromJson(c.max_inclusive));case"biased_to_bottom":return i(u.VerticalAnchor.fromJson(c.min_inclusive),u.VerticalAnchor.fromJson(c.max_inclusive),u.Json.readInt(c.inner));case"very_biased_to_bottom":return s(u.VerticalAnchor.fromJson(c.min_inclusive),u.VerticalAnchor.fromJson(c.max_inclusive),u.Json.readInt(c.inner));case"trapezoid":return a(u.VerticalAnchor.fromJson(c.min_inclusive),u.VerticalAnchor.fromJson(c.max_inclusive),u.Json.readInt(c.plateau));case"weighted_list":return o((f=u.Json.readArray(c.distribution,p=>{var m,w;const v=(m=u.Json.readObject(p))!=null?m:{};return{weight:(w=u.Json.readInt(v.weight))!=null?w:1,data:t(v.data)}}))!=null?f:[])}return()=>0}e.fromJson=t;function n(g){return(c,l)=>g(l)}e.constant=n;function r(g,c){return(l,h)=>{const d=g(h),f=c(h);return d>f?d:l.nextInt(f-d+1)+d}}e.uniform=r;function i(g,c,l=1){return(h,d)=>{const f=g(d),p=c(d);if(p-f-l+1<=0)return f;{const v=h.nextInt(p-f-l+1);return h.nextInt(v+l)+f}}}e.biased_to_bottom=i;function s(g,c,l=1){return(h,d)=>{const f=g(d),p=c(d);if(p-f-l+1<=0)return f;{const v=rr(h,f+l,p),m=rr(h,f,v-1);return rr(h,f,m-1+l)}}}e.very_biased_to_bottom=s;function a(g,c,l=0){return(h,d)=>{const f=g(d),p=c(d);if(f>p)return f;{const v=p-f;if(l>=v)return nr(h,f,p);{const m=(v-l)/2,w=v-m;return f+nr(h,0,w)+nr(h,0,m)}}}}e.trapezoid=a;function o(g){const c=g.reduce((l,h,d)=>l+h.weight,0);return(l,h)=>{let d=l.nextInt(c);for(const f of g)if(d-=f.weight,d<=0)return f.data(l,h);return 0}}e.weighted_list=o})(u.HeightProvider||(u.HeightProvider={})),u.Heightmap=void 0,(e=>{function t(n){if(typeof n=="string"&&(n==="WORLD_SURFACE_WG"||n==="WORLD_SURFACE"||n==="OCEAN_FLOOR_WG"||n==="OCEAN_FLOOR"||n==="MOTION_BLOCKING"||n==="MOTION_BLOCKING_NO_LEAVES"))return n}e.fromJson=t})(u.Heightmap||(u.Heightmap={}));class ii{constructor(t,n,r,i,s,a,o,g,c){_(this,"cellWidth");_(this,"cellHeight");_(this,"firstCellX");_(this,"firstCellZ");_(this,"firstNoiseX");_(this,"firstNoiseZ");_(this,"noiseSizeXZ");_(this,"preliminarySurfaceLevel",new Map);_(this,"aquifer");_(this,"materialRule");_(this,"initialDensity");this.cellCountXZ=t,this.cellCountY=n,this.cellNoiseMinY=r,this.minX=s,this.minZ=a,this.settings=o,this.cellWidth=u.NoiseSettings.cellWidth(o),this.cellHeight=u.NoiseSettings.cellHeight(o),this.firstCellX=Math.floor(s/this.cellWidth),this.firstCellZ=Math.floor(a/this.cellWidth),this.firstNoiseX=s>>2,this.firstNoiseZ=a>>2,this.noiseSizeXZ=t*this.cellWidth>>2,this.aquifer=u.Aquifer.createDisabled(c);const l=i.router.finalDensity;this.materialRule=u.MaterialRule.fromList([h=>this.aquifer.compute(h,l.compute(h))]),this.initialDensity=i.router.initialDensityWithoutJaggedness}getFinalState(t,n,r){return this.materialRule({x:t,y:n,z:r})}getPreliminarySurfaceLevel(t,n){return Ee(this.preliminarySurfaceLevel,u.ChunkPos.asLong(t,n),()=>{const r=t<<2,i=n<<2;for(let s=this.settings.minY+this.settings.height;s>=this.settings.minY;s-=this.cellHeight)if(this.initialDensity.compute(W.context(r,s,i))>.390625)return s;return Number.MAX_SAFE_INTEGER})}}u.MaterialRule=void 0,(e=>{function t(n){return r=>{for(const i of n){const s=i(r);if(s)return s}}}e.fromList=t})(u.MaterialRule||(u.MaterialRule={}));class Ks{constructor(t,n){_(this,"noiseChunkCache");_(this,"globalFluidPicker");this.biomeSource=t,this.settings=n,this.noiseChunkCache=new Map;const r=new Cn(-54,j.LAVA),i=new Cn(n.seaLevel,n.defaultFluid);this.globalFluidPicker=(s,a,o)=>ao.equals(j.STONE):s=o=>!o.equals(j.AIR),(a=this.iterateNoiseColumn(i,t,n,void 0,s,j.STONE))!=null?a:this.settings.noise.minY}iterateNoiseColumn(t,n,r,i,s,a){var v,m;const o=this.settings.noise.minY,g=u.NoiseSettings.cellHeight(this.settings.noise),c=Math.floor(o/g),l=Math.floor(this.settings.noise.height/g);if(l<=0)return;const h=u.NoiseSettings.cellWidth(this.settings.noise),d=Math.floor(n/h),f=Math.floor(r/h),p=new ii(1,l,c,t,d,f,this.settings.noise,this.settings.aquifersEnabled,this.globalFluidPicker);for(let w=l-1;w>=0;w-=1)for(let S=g-1;S>=0;S-=1){const E=(c+w)*g+S,y=(m=(v=p.getFinalState(n,E,r))!=null?v:a)!=null?m:this.settings.defaultBlock;if(i!==void 0&&(i[E+o]=y),s!==void 0&&s(y))return E+1}}fill(t,n,r=!1){var p;const i=Math.max(n.minY,this.settings.noise.minY),s=Math.min(n.maxY,this.settings.noise.minY+this.settings.noise.height),a=u.NoiseSettings.cellWidth(this.settings.noise),o=u.NoiseSettings.cellHeight(this.settings.noise),g=Math.floor(16/a),c=Math.floor(i/o),l=Math.floor((s-i)/o),h=u.ChunkPos.minBlockX(n.pos),d=u.ChunkPos.minBlockZ(n.pos),f=this.getOrCreateNoiseChunk(t,n);for(let v=0;v=0;S-=1)for(let E=o-1;E>=0;E-=1){const y=(c+S)*o+E,k=y&15,R=n.getSectionIndex(y);n.getSectionIndex(w.minBlockY)!==R&&(w=n.getOrCreateSection(R));for(let I=0;Ir)}computeBiome(t,n,r,i){return this.biomeSource.getBiome(n,r,i,t.sampler)}getOrCreateNoiseChunk(t,n){return Ee(this.noiseChunkCache,u.ChunkPos.toLong(n.pos),()=>{const r=Math.max(n.minY,this.settings.noise.minY),i=Math.min(n.maxY,this.settings.noise.minY+this.settings.noise.height),s=u.NoiseSettings.cellWidth(this.settings.noise),a=u.NoiseSettings.cellHeight(this.settings.noise),o=Math.floor(16/s),g=Math.floor(r/a),c=Math.floor((i-r)/a),l=u.ChunkPos.minBlockX(n.pos),h=u.ChunkPos.minBlockZ(n.pos);return new ii(o,c,g,t,l,h,this.settings.noise,this.settings.aquifersEnabled,this.globalFluidPicker)})}}class ur{constructor(t,n){_(this,"n");if(this.shift=t,this.biomes=n,n.length===0)throw new Error("Cannot create checkerboard biome source without biomes");this.n=n.length}getBiome(t,n,r){const i=(((t>>this.shift)+(r>>this.shift))%this.n+this.n)%this.n;return C.parse(this.biomes[i].toString())}static fromJson(t){var s,a,o;const n=(s=u.Json.readObject(t))!=null?s:{},r=(a=u.Json.readInt(n.scale))!=null?a:2;let i;return typeof n.biomes=="string"?i=[C.parse(n.biomes)]:i=(o=u.Json.readArray(n.biomes,g=>{var c;return C.parse((c=u.Json.readString(g))!=null?c:"")}))!=null?o:[],new ur(r+2,i)}}class je{constructor(t){this.biome=t}getBiome(){return this.biome}static fromJson(t){var i,s;const n=(i=u.Json.readObject(t))!=null?i:{},r=C.parse((s=u.Json.readString(n.biome))!=null?s:"plains");return new je(r)}}u.Climate=void 0,(e=>{function n(v,m,w,S,E,y){return new o(v,m,w,S,E,y)}e.target=n;function r(v,m,w,S,E,y,k){return new a(i(v),i(m),i(w),i(S),i(E),i(y),k)}e.parameters=r;function i(v,m){return typeof v=="number"?new s(v,m!=null?m:v):v}e.param=i;class s{constructor(m,w){this.min=m,this.max=w}distance(m){const w=(typeof m=="number"?m:m.min)-this.max,S=this.min-(typeof m=="number"?m:m.max);return w>0?w:Math.max(S,0)}union(m){return new s(Math.min(this.min,m.min),Math.max(this.max,m.max))}static fromJson(m){var E;if(typeof m=="number")return new s(m,m);const[w,S]=(E=u.Json.readArray(m,y=>u.Json.readNumber(y)))!=null?E:[];return new s(w!=null?w:0,S!=null?S:0)}}e.Param=s;class a{constructor(m,w,S,E,y,k,R){this.temperature=m,this.humidity=w,this.continentalness=S,this.erosion=E,this.depth=y,this.weirdness=k,this.offset=R}fittness(m){return ee(this.temperature.distance(m.temperature))+ee(this.humidity.distance(m.humidity))+ee(this.continentalness.distance(m.continentalness))+ee(this.erosion.distance(m.erosion))+ee(this.depth.distance(m.depth))+ee(this.weirdness.distance(m.weirdness))+ee(this.offset-m.offset)}space(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,new s(this.offset,this.offset)]}static fromJson(m){var S,E;const w=(S=u.Json.readObject(m))!=null?S:{};return new a(s.fromJson(w.temperature),s.fromJson(w.humidity),s.fromJson(w.continentalness),s.fromJson(w.erosion),s.fromJson(w.depth),s.fromJson(w.weirdness),(E=u.Json.readNumber(w.offset))!=null?E:0)}}e.ParamPoint=a;class o{constructor(m,w,S,E,y,k){this.temperature=m,this.humidity=w,this.continentalness=S,this.erosion=E,this.depth=y,this.weirdness=k}get offset(){return 0}toArray(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,this.offset]}}e.TargetPoint=o;class g{constructor(m){_(this,"index");this.things=m,this.index=new l(m)}find(m){return this.index.search(m,(w,S)=>w.distance(S))}}e.Parameters=g;class c{constructor(m,w,S,E,y,k){this.temperature=m,this.humidity=w,this.continentalness=S,this.erosion=E,this.depth=y,this.weirdness=k}static fromRouter(m){return new e.Sampler(m.temperature,m.vegetation,m.continents,m.erosion,m.depth,m.ridges)}sample(m,w,S){const E=W.context(m<<2,w<<2,S<<2);return e.target(this.temperature.compute(E),this.humidity.compute(E),this.continentalness.compute(E),this.erosion.compute(E),this.depth.compute(E),this.weirdness.compute(E))}}e.Sampler=c;const p=class{constructor(m){_(this,"root");_(this,"last_leaf",null);if(m.length===0)throw new Error("At least one point is required to build search tree");this.root=p.build(m.map(([w,S])=>new f(w,S)))}static build(m){if(m.length===1)return m[0];if(m.length<=p.CHILDREN_PER_NODE){const y=m.map(k=>{let R=0;for(let I=0;I<7;I+=1){const M=k.space[I];R+=Math.abs((M.min+M.max)/2)}return{key:R,node:k}}).sort((k,R)=>k.key-R.key).map(({node:k})=>k);return new d(y)}let w=1/0,S=-1,E=[];for(let y=0;y<7;++y){m=p.sort(m,y,!1),E=p.bucketize(m);let k=0;for(const R of E)k+=p.area(R.space);w>k&&(w=k,S=y)}return m=p.sort(m,S,!1),E=p.bucketize(m),E=p.sort(E,S,!0),new d(E.map(y=>p.build(y.children)))}static sort(m,w,S){return m.map(E=>{const y=E.space[w],k=(y.min+y.max)/2;return{key:S?Math.abs(k):k,node:E}}).sort((E,y)=>E.key-y.key).map(({node:E})=>E)}static bucketize(m){const w=[];let S=[];const E=Math.pow(10,Math.floor(Math.log(m.length-.01)/Math.log(10)));for(const y of m)S.push(y),!(S.lengthnew s(1/0,-1/0));for(const S of m)w=[...Array(7)].map((E,y)=>w[y].union(S.space[y]));return w}search(m,w,S){let E=w?S(w,m):1/0,y=w;for(const k of this.children){const R=S(k,m);if(E<=R)continue;const I=k.search(m,y,S);if(I===null)continue;const M=k==I?R:S(I,m);if(M===0)return I;E<=M||(E=M,y=I)}return y}}e.RSubTree=d;class f extends h{constructor(m,w){super(m.space()),this.thing=w}search(){return this}}e.RLeaf=f})(u.Climate||(u.Climate={}));class hr{constructor(t){_(this,"parameters");this.parameters=new u.Climate.Parameters(t)}getBiome(t,n,r,i){const s=i.sample(t,n,r);return this.parameters.find(s)}static fromJson(t){var s,a;const n=(s=u.Json.readObject(t))!=null?s:{},i=((a=u.Json.readArray(n.biomes,o=>{var g;return(c=>{var l;return{biome:C.parse((l=u.Json.readString(c.biome))!=null?l:"plains"),parameters:u.Climate.ParamPoint.fromJson(c.parameters)}})((g=u.Json.readObject(o))!=null?g:{})}))!=null?a:[]).map(o=>[o.parameters,()=>o.biome]);return new hr(i)}}const ye=class{getBiome(t,n,r,i){const s=t<<2,a=n<<2,o=r<<2,g=s>>4,c=o>>4;if(g*g+c*c<=4096)return ye.END;const l=W.context((g*2+1)*8,a,(c*2+1)*8),h=i.erosion.compute(l);return h>.25?ye.HIGHLANDS:h>=-.0625?ye.MIDLANDS:h>=-.21875?ye.BARRENS:ye.ISLANDS}static fromJson(t){return new ye}};let _e=ye;_(_e,"END",C.create("the_end")),_(_e,"HIGHLANDS",C.create("end_highlands")),_(_e,"MIDLANDS",C.create("end_midlands")),_(_e,"ISLANDS",C.create("small_end_islands")),_(_e,"BARRENS",C.create("end_barrens")),u.BiomeSource=void 0,(e=>{function t(r){var a,o;const i=(a=u.Json.readObject(r))!=null?a:{};switch((o=u.Json.readString(i.type))==null?void 0:o.replace(/^minecraft:/,"")){case"fixed":return je.fromJson(r);case"checkerboard":return ur.fromJson(r);case"multi_noise":return hr.fromJson(r);case"the_end":return _e.fromJson(r);default:return new je(C.create("plains"))}}e.fromJson=t;function n(r,i,s,a,o,g,c,l,h=1,d=!1){if(r instanceof je)return g(r.getBiome())?d?{pos:u.BlockPos.create(i,s,a),biome:r.getBiome()}:{pos:u.BlockPos.create(i-o+c.nextInt(o*2+1),s,a-o+c.nextInt(o*2+1)),biome:r.getBiome()}:void 0;const f=i>>2,p=a>>2,v=o>>2,m=s>>2;for(var w=void 0,S=0,E=d?0:v,y=E;y<=v;y+=h)for(var k=-y;k<=y;k+=h){const I=Math.abs(k)===y;for(var R=-y;R<=y;R+=h){if(d&&!(Math.abs(R)===y)&&!I)continue;const M=f+R,T=p+k,x=r.getBiome(M,m,T,l);if(g(x)){if((w===void 0||c.nextInt(S+1)<=.5)&&(w={pos:u.BlockPos.create(M<<2,s,T<<2),biome:x},d))return w;S++}}}return w}e.findBiomeHorizontal=n})(u.BiomeSource||(u.BiomeSource={}));class Qs{constructor(t,n){_(this,"noiseCache");_(this,"randomCache");_(this,"random");_(this,"aquiferRandom");_(this,"oreRandom");_(this,"surfaceSystem");_(this,"router");_(this,"sampler");this.seed=n,this.noiseCache=new Map,this.randomCache=new Map,this.random=(t.legacyRandomSource?new at(n):nt.create(n)).forkPositional(),this.aquiferRandom=this.random.fromHashOf(C.create("aquifer").toString()).forkPositional(),this.oreRandom=this.random.fromHashOf(C.create("ore").toString()).forkPositional(),this.surfaceSystem=new Xs(t.surfaceRule,t.defaultBlock,n),this.router=u.NoiseRouter.mapAll(t.noiseRouter,this.createVisitor(t.noise,t.legacyRandomSource)),this.sampler=u.Climate.Sampler.fromRouter(this.router)}createVisitor(t,n){const r=new Map,i=a=>{const o=a.key();if(o===void 0)throw new Error("Cannot create noise without key");if(n){if(o.equals(C.create("temperature")))return new ie(new at(this.seed+BigInt(0)),u.NoiseParameters.create(-7,[1,1]));if(o.equals(C.create("vegetation")))return new ie(new at(this.seed+BigInt(1)),u.NoiseParameters.create(-7,[1,1]));if(o.equals(C.create("offset")))return new ie(this.random.fromHashOf("offset"),u.NoiseParameters.create(0,[0]))}return this.getOrCreateNoise(o)},s={map:a=>{if(a instanceof W.HolderHolder){const o=a.holder.key();if(o!==void 0&&r.has(o.toString()))return r.get(o.toString());{const g=a.holder.value().mapAll(s);return o!==void 0&&r.set(o.toString(),g),g}}if(a instanceof W.Interpolated)return a.withCellSize(u.NoiseSettings.cellWidth(t),u.NoiseSettings.cellHeight(t));if(a instanceof W.ShiftedNoise)return new W.ShiftedNoise(a.shiftX,a.shiftY,a.shiftZ,a.xzScale,a.yScale,a.noiseData,i(a.noiseData));if(a instanceof W.Noise)return new W.Noise(a.xzScale,a.yScale,a.noiseData,i(a.noiseData));if(a instanceof W.ShiftNoise)return a.withNewNoise(i(a.noiseData));if(a instanceof W.WeirdScaledSampler)return new W.WeirdScaledSampler(a.input,a.rarityValueMapper,a.noiseData,i(a.noiseData));if(a instanceof W.OldBlendedNoise){const o=n?new at(this.seed+BigInt(0)):this.random.fromHashOf(C.create("terrain").toString());return new W.OldBlendedNoise(a.xzScale,a.yScale,a.xzFactor,a.yFactor,a.smearScaleMultiplier,new Vs(o,a.xzScale,a.yScale,a.xzFactor,a.yFactor,a.smearScaleMultiplier))}return a instanceof W.EndIslands?new W.EndIslands(this.seed):a instanceof W.Mapped||a instanceof W.Ap2?a.withMinMax():a}};return s}getOrCreateNoise(t){const n=xt.REGISTRY.getOrThrow(C.create("worldgen/noise"));return Ee(this.noiseCache,t.toString(),r=>new ie(this.random.fromHashOf(r),n.getOrThrow(t)))}getOrCreateRandom(t){return Ee(this.randomCache,t.toString(),n=>this.random.fromHashOf(n).forkPositional())}}class Ft{static fromJson(t){var r,i,s,a;const n=(r=u.Json.readObject(t))!=null?r:{};switch((i=u.Json.readString(n.element_type))==null?void 0:i.replace(/^minecraft:/,"")){case"single_pool_element":case"legacy_single_pool_element":const o=C.parse((s=u.Json.readString(n.location))!=null?s:""),g={key:()=>o,value:()=>{var l;return(l=te.REGISTRY.get(o))!=null?l:te.EMPTY}};return new Ft.SinlgePoolElement(g);case"list_pool_element":const c=(a=u.Json.readArray("elements",Ft.fromJson))!=null?a:[];return new Ft.ListPoolElement(c);case"feature_pool_element":return new Ft.FeaturePoolElement;case"empty_pool_element":default:return new Ft.EmptyPoolElement}}}(e=>{class t extends e{getBoundingBox(o,g){throw new Error("Invalid call of EmptyPoolElement")}getShuffledJigsawBlocks(o,g){return[]}toString(){return"[Empty Pool Element]"}}e.EmptyPoolElement=t;class n extends e{constructor(){super();_(this,"defaultJigsawNBT");const g=new Map;g.set("name",new vt("minecraft:bottom")),g.set("final_state",new vt("minecraft:air")),g.set("pool",new vt("minecraft:empty")),g.set("target",new vt("minecraft:empty")),g.set("joint",new vt("rollable")),this.defaultJigsawNBT=new gt(g)}getBoundingBox(g,c){return[g,g]}getShuffledJigsawBlocks(g,c){return[{pos:[0,0,0],state:new j(C.create("jigsaw"),{orientation:"down_south"}),nbt:this.defaultJigsawNBT}]}toString(){return"[Feature Pool Element]"}}e.FeaturePoolElement=n;const s=class extends e{constructor(o){super(),this.template=o}getBoundingBox(o,g){const c=u.BlockPos.offset(this.template.value().getSize(),-1,-1,-1),l=o,h=u.BlockPos.add(te.transform(c,g,u.BlockPos.ZERO),o),d=u.BlockPos.create(Math.min(l[0],h[0]),l[1],Math.min(l[2],h[2])),f=u.BlockPos.create(Math.max(l[0],h[0]),h[1],Math.max(l[2],h[2]));return[d,f]}getShuffledJigsawBlocks(o,g){const c=this.template.value().getBlocks().filter(l=>l.state.getName().equals(s.JIGSAW_ID));return c.forEach(l=>l.pos=te.transform(l.pos,o,u.BlockPos.ZERO)),zs(c,g),c}toString(){return`[Single Pool Element: ${this.template.key()}]`}};let r=s;_(r,"JIGSAW_ID",C.parse("jigsaw")),e.SinlgePoolElement=r;class i extends e{constructor(o){super(),this.elements=o}getBoundingBox(o,g){var c=void 0,l=void 0;for(const h of this.elements){const d=h.getBoundingBox(o,g);!c||!l?(c=d[0],l=d[1]):(c[0]=Math.min(c[0],d[0][0]),c[1]=Math.min(c[1],d[0][1]),c[2]=Math.min(c[2],d[0][2]),l[0]=Math.min(c[0],d[1][0]),l[1]=Math.min(c[1],d[1][1]),l[2]=Math.min(c[2],d[1][2]))}return[c,l]}getShuffledJigsawBlocks(o,g){return this.elements[0].getShuffledJigsawBlocks(o,g)}toString(){return`[List Pool Element: ${"; ".concat(...this.elements.map(o=>o.toString()))}]`}}e.ListPoolElement=i})(Ft||(Ft={}));const He=class{constructor(t,n){_(this,"totalWeight");this.rawTemplates=t,this.fallback=n,this.totalWeight=t.reduce((r,i)=>r+i.weight,0)}static fromJson(t){var s,a,o;const n=(s=u.Json.readObject(t))!=null?s:{},r=He.structurePoolParser((a=n.fallback)!=null?a:""),i=(o=u.Json.readArray(n.elements,g=>{var d,f;const c=(d=u.Json.readObject(g))!=null?d:{},l=Ft.fromJson(c.element),h=(f=u.Json.readInt(c.weight))!=null?f:1;return{element:l,weight:h}}))!=null?o:[];return new He(i,r)}getRandomTemplate(t){var n=t.nextInt(this.totalWeight);for(const r of this.rawTemplates)if(n-=r.weight,n<0)return r.element;return this.rawTemplates[this.rawTemplates.length-1].element}};let ze=He;_(ze,"REGISTRY",xt.createAndRegister("worldgen/template_pool",He.fromJson)),_(ze,"structurePoolParser",u.Holder.parser(He.REGISTRY,He.fromJson));class fr{constructor(t){this.settings=t}onTopOfChunkCenter(t,n,r,i="WORLD_SURFACE_WG"){const s=(n<<4)+8,a=(r<<4)+8;return[s,t.chunkGenerator.getBaseHeight(s,a,i,t.randomState)-1,a]}getLowestY(t,n,r,i,s){return Math.min(t.chunkGenerator.getBaseHeight(n,r,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(n,r+s,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(n+i,r,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(n+i,r+s,"WORLD_SURFACE_WG",t.randomState)-1)}getLowestYIn5by5BoxOffset7Blocks(t,n,r,i){let s=5,a=5;i===u.Rotation.CLOCKWISE_90?s=-5:i===u.Rotation.CLOCKWISE_180?(s=-5,a=-5):i===u.Rotation.COUNTERCLOCKWISE_90&&(a=-5);const o=(n<<4)+7,g=(r<<4)+7;return u.BlockPos.create(o,this.getLowestY(t,o,g,s,a),g)}tryGenerate(t,n,r){const i=at.fromLargeFeatureSeed(r.seed,t,n),s=this.findGenerationPoint(t,n,i,r);if(s===void 0)return;const a=r.biomeSource.getBiome(s[0]>>2,s[1],s[2]>>2,r.randomState.sampler);return[...this.settings.validBiomes.getEntries()].findIndex(o=>{var g;return(g=o.key())==null?void 0:g.equals(a)})>=0?s:void 0}}(e=>{e.REGISTRY=xt.createAndRegister("worldgen/structure",i);class t{constructor(I){this.validBiomes=I}}e.StructureSettings=t;class n{constructor(I,M,T,x){_(this,"chunkGenerator");_(this,"randomState");this.seed=I,this.biomeSource=M,this.settings=T,this.levelHeight=x,this.randomState=new Qs(T,I),this.chunkGenerator=new Ks(M,T)}}e.GenerationContext=n;const r=u.Holder.parser(ze.REGISTRY,ze.fromJson);function i(R){var N,P,F;const I=ve.parser(u.WorldgenRegistries.BIOME),M=(N=u.Json.readObject(R))!=null?N:{},T=I(M.biomes),x=new t(T.value());switch((P=u.Json.readString(M.type))==null?void 0:P.replace(/^minecraft:/,"")){case"buried_treasure":return new a(x);case"desert_pyramid":return new g(x);case"end_city":return new c(x);case"fortress":return new l(x);case"igloo":return new h(x);case"jigsaw":const U=u.HeightProvider.fromJson(M.start_height),Y=r(M.start_pool),B=u.Json.readString(M.start_jigsaw_name),J=B?C.parse(B):void 0,G=u.Heightmap.fromJson(M.project_start_to_heightmap),V=s.DimensionPadding.fromJson(M.dimension_padding);return new s(x,Y,U,G,J,V);case"jungle_temple":return new d(x);case"mineshaft":const A=u.Json.readString(M.mineshaft_type)==="mesa"?"mesa":"normal";return new f(x,A);case"nether_fossil":return new l(x);case"ocean_monument":return new v(x);case"ocean_ruin":return new m(x);case"ruined_portal":return new w(x);case"shipwreck":const b=(F=u.Json.readBoolean(M.is_beached))!=null?F:!1;return new S(x,b);case"stronghold":return new E(x);case"swamp_hut":return new y(x);case"woodland_mansion":return new k(x)}return new a(x)}e.fromJson=i;class s extends e{constructor(I,M,T,x,N,P){super(I),this.startingPoolHolder=M,this.startHeight=T,this.projectStartToHeightmap=x,this.startJigsawName=N,this.dimensionPadding=P}findGenerationPoint(I,M,T,x){var N=this.startHeight(T,x.settings.noise);const P=u.BlockPos.create(I<<4,N,M<<4),F=u.Rotation.getRandom(T),Y=this.startingPoolHolder.value().getRandomTemplate(T);if(!(Y instanceof Ft.EmptyPoolElement)){var B;if(this.startJigsawName){const z=s.getRandomNamedJigsaw(Y,this.startJigsawName,F,T);if(z===void 0)return;B=z}else B=u.BlockPos.ZERO;const J=u.BlockPos.subtract(P,B),G=Y.getBoundingBox(J,F),V=(G[1][0]+G[0][0])/2^0,A=(G[1][2]+G[0][2])/2^0;var N;return this.projectStartToHeightmap?N=P[1]+x.chunkGenerator.getBaseHeight(V,A,this.projectStartToHeightmap,x.randomState):N=J[1],G.forEach(z=>z[1]+=N-G[0][1]-1),s.isStartTooCloseToWorldHeightLimits(this.dimensionPadding,G,x.levelHeight)?void 0:u.BlockPos.create(V,N+B[1],A)}}static isStartTooCloseToWorldHeightLimits(I,M,T){if(I===s.DimensionPadding.ZERO)return!1;const x=T.minY+I.bottom,N=T.minY+T.height-I.top;return M[0][1]N}static getRandomNamedJigsaw(I,M,T,x){var P,F;const N=I.getShuffledJigsawBlocks(T,x);for(const U of N)if(C.parse((F=(P=U.nbt)==null?void 0:P.getString("name"))!=null?F:"minecraft:empty").equals(M))return U.pos}}e.JigsawStructure=s,(R=>{const M=class{constructor(x,N){this.top=x,this.bottom=N}static fromJson(x){var P,F,U;if(x===void 0)return M.ZERO;if(typeof x=="number")return new M(x,x);const N=(P=u.Json.readObject(x))!=null?P:{};return new M((F=u.Json.readInt(N.top))!=null?F:0,(U=u.Json.readInt(N.bottom))!=null?U:0)}};let I=M;_(I,"ZERO",new M(0,0)),R.DimensionPadding=I})(s=e.JigsawStructure||(e.JigsawStructure={}));class a extends e{findGenerationPoint(I,M,T,x){return this.onTopOfChunkCenter(x,I,M,"OCEAN_FLOOR_WG")}}e.BuriedTreasureStructure=a;class o extends e{constructor(I,M,T){super(I),this.width=M,this.depth=T}findGenerationPoint(I,M,T,x){if(!(this.getLowestY(x,I<<4,M<<4,this.width,this.depth)o+g.weight,0);for(;s.length>0;){let o=i.nextInt(a),g,c;for([g,c]of s.entries())if(o-=c.weight,o<0)break;const l=c.structure.value().tryGenerate(t,n,r);if(l!==void 0)return{id:c.structure.key(),pos:l};s.splice(g,1),a-=c.weight}}}};let De=Tn;_(De,"REGISTRY",xt.createAndRegister("worldgen/structure_set",Tn.fromJson)),(e=>{class t{constructor(r,i){this.structure=r,this.weight=i}static fromJson(r){var s,a,o;const i=(s=u.Json.readObject(r))!=null?s:{};return new t(u.Holder.reference(fr.REGISTRY,C.parse((a=u.Json.readString(i.structure))!=null?a:"minecraft:empty")),(o=u.Json.readInt(i.weight))!=null?o:1)}}e.StructureSelectionEntry=t})(De||(De={}));class Ot{constructor(t,n,r,i,s){this.locateOffset=t,this.frequencyReductionMethod=n,this.frequency=r,this.salt=i,this.exclusionZone=s}static fromJson(t){var c,l,h,d,f,p,v,m,w,S;const n=(c=u.Json.readObject(t))!=null?c:{},r=(l=u.Json.readString(n.type))==null?void 0:l.replace(/^minecraft:/,""),i=u.BlockPos.fromJson(n.locate_offset),s=Ot.FrequencyReducer.fromType((h=u.Json.readString(n.frequency_reduction_method))!=null?h:"default"),a=(d=u.Json.readNumber(n.frequency))!=null?d:1,o=(f=u.Json.readInt(n.salt))!=null?f:0,g="exclusion_zone"in n?Ot.ExclusionZone.fromJson(n.exclusion_zone):void 0;switch(r){case"random_spread":const E=(p=u.Json.readInt(n.spacing))!=null?p:1,y=(v=u.Json.readInt(n.separation))!=null?v:1,k=Ot.SpreadType.fromJson(n.spread_type);return new Ot.RandomSpreadStructurePlacement(i,s,a,o,g,E,y,k);case"concentric_rings":const R=(m=u.Json.readInt(n.distance))!=null?m:1,I=(w=u.Json.readInt(n.spread))!=null?w:1,M=(S=u.Json.readInt(n.count))!=null?S:1,T=ve.parser(u.WorldgenRegistries.BIOME)(n.preferred_biomes);return new Ot.ConcentricRingsStructurePlacement(i,s,a,o,g,R,I,M,T)}return new Ot.RandomSpreadStructurePlacement([0,0,0],Ot.FrequencyReducer.ProbabilityReducer,1,0,void 0,1,1,"linear")}isStructureChunk(t,n,r){return this.isPlacementChunk(t,n,r)?this.frequency<1&&!this.frequencyReductionMethod(t,this.salt,n,r,this.frequency)?!1:!(this.exclusionZone&&this.exclusionZone.isPlacementForbidden(t,n,r)):!1}prepare(t,n,r){}}(e=>{(s=>{function a(h){switch(h){case"legacy_type_1":return l;case"legacy_type_2":return c;case"legacy_type_3":return g;case"default":default:return o}}s.fromType=a;function o(h,d,f,p,v){return at.fromLargeFeatureWithSalt(h,d,f,p).nextFloat()>4,w=p>>4,S=new at(BigInt(m^w<<4)^h);return S.nextInt(),S.nextInt(Math.floor(1/v))===0}s.LegacyPillagerOutpostReducer=l})(e.FrequencyReducer||(e.FrequencyReducer={}));class t{constructor(a,o){this.otherSet=a,this.chunkCount=o}static fromJson(a){var g,c,l;const o=(g=u.Json.readObject(a))!=null?g:{};return new t(u.Holder.reference(De.REGISTRY,C.parse((c=u.Json.readString(o.other_set))!=null?c:"")),(l=u.Json.readInt(o.chunk_count))!=null?l:1)}isPlacementForbidden(a,o,g){const c=this.otherSet.value().placement;return c.getPotentialStructureChunks(a,o-this.chunkCount,g-this.chunkCount,o+this.chunkCount,g+this.chunkCount).findIndex(l=>Math.abs(l[0]-o)<=this.chunkCount&&Math.abs(l[1]-g)<=this.chunkCount&&c.isStructureChunk(a,l[0],l[1]))>=0}}e.ExclusionZone=t,(s=>{function a(o){var c;return((c=u.Json.readString(o))!=null?c:"linear")==="triangular"?"triangular":"linear"}s.fromJson=a})(e.SpreadType||(e.SpreadType={}));class n extends e{constructor(a,o,g,c,l,h,d,f){super(a,o,g,c,l),this.spacing=h,this.separation=d,this.spreadType=f}evaluateSpread(a,o){switch(this.spreadType){case"linear":return a.nextInt(o);case"triangular":return Math.floor((a.nextInt(o)+a.nextInt(o))/2)}}getPotentialStructureChunk(a,o,g){const c=Math.floor(o/this.spacing),l=Math.floor(g/this.spacing),h=at.fromLargeFeatureWithSalt(a,c,l,this.salt),d=this.spacing-this.separation,f=this.evaluateSpread(h,d),p=this.evaluateSpread(h,d);return[c*this.spacing+f,l*this.spacing+p]}isPlacementChunk(a,o,g){const[c,l]=this.getPotentialStructureChunk(a,o,g);return c===o&&l===g}getPotentialStructureChunks(a,o,g,c,l){const h=[];for(let d=Math.floor(o/this.spacing)*this.spacing;d<=c;d+=this.spacing)for(let f=Math.floor(g/this.spacing)*this.spacing;f<=l;f+=this.spacing)h.push(this.getPotentialStructureChunk(a,d,f));return h}}e.RandomSpreadStructurePlacement=n;const r=112;class i extends e{constructor(o,g,c,l,h,d,f,p,v){super(o,g,c,l,h);_(this,"positions");this.distance=d,this.spread=f,this.count=p,this.preferredBiomes=v}prepare(o,g,c){if(this.positions!==void 0||(this.positions=[],this.count===0))return;const l=new at(c);var h=l.nextDouble()*Math.PI*2,d=this.spread,f=0,p=0;const v=[...this.preferredBiomes.value().getEntries()].flatMap(w=>{var S;return(S=w.key())!=null?S:[]});for(var m=0;m{const M=u.BiomeSource.findBiomeHorizontal(o,y,0,k,r,T=>v.findIndex(x=>x.equals(T))>=0,R,g);return M?[M.pos[0]>>4,M.pos[2]>>4]:[S,E]};this.positions.push({center:[S,E],real:I}),h+=Math.PI*2/d,p++,p==d&&(f++,p=0,d+=2*d/(f+1),d=Math.min(d,this.count-m),h+=l.nextDouble()*Math.PI*2)}}isPlacementChunk(o,g,c){return this.positions===void 0?(console.warn("trying to access concentric rings placement before position calculation"),!1):this.getPotentialStructureChunks(o,g,c,g,c).findIndex(l=>l[0]===g&&l[1]===c)>=0}getPotentialStructureChunks(o,g,c,l,h){if(this.positions===void 0)return console.warn("trying to access concentric rings placement before position calculation"),[];const d=[];for(const f of this.positions)f.center[0]>4)||f.center[0]>l+(r>>4)||f.center[1]>4)||f.center[1]>h+(r>>4)||(f.real instanceof Function&&(f.real=f.real()),d.push(f.real));return d}}e.ConcentricRingsStructurePlacement=i})(Ot||(Ot={})),u.BlendedNoise=Vs,u.BlockColors=Pe,u.BlockDefinition=Qr,u.BlockModel=ot,u.BlockState=j,u.CheckerboardBiomeSource=ur,u.Chunk=rl,u.ChunkBuilder=qs,u.ChunkSection=qe,u.DensityFunction=W,u.EFFECT_COLORS=Bs,u.FixedBiomeSource=je,u.FluidStatus=Cn,u.HolderSet=ve,u.Identifier=C,u.ImprovedNoise=Kr,u.ItemModel=ni,u.ItemRenderer=ri,u.ItemStack=$t,u.ItemTint=cr,u.LegacyPositionalRandom=Zs,u.LegacyRandom=at,u.Line=or,u.Matrix3=Mn,u.Matrix4=sr,u.Mesh=it,u.MultiNoiseBiomeSource=hr,u.NbtAbstractList=En,u.NbtByte=Bt,u.NbtByteArray=ge,u.NbtChunk=Kt,u.NbtCompound=gt,u.NbtDouble=Qt,u.NbtEnd=In,u.NbtFile=Vt,u.NbtFloat=Be,u.NbtInt=Dt,u.NbtIntArray=me,u.NbtList=Tt,u.NbtLong=Te,u.NbtLongArray=pe,u.NbtRegion=we,u.NbtShort=Le,u.NbtString=vt,u.NbtTag=et,u.NbtType=D,u.NoiseAquifer=Je,u.NoiseChunk=ii,u.NoiseChunkGenerator=Ks,u.NormalNoise=ie,u.POTION_EFFECTS=Ts,u.PalettedContainer=Cs,u.PerlinNoise=wt,u.PerlinSimplexNoise=Hl,u.Quad=Yt,u.RandomState=Qs,u.RawDataInput=ci,u.RawDataOutput=li,u.Registry=xt,u.Renderer=lr,u.ShaderProgram=Rn,u.SimplexNoise=pt,u.StringReader=St,u.Structure=te,u.StructurePlacement=Ot,u.StructurePoolElement=Ft,u.StructureRenderer=nu,u.StructureSet=De,u.StructureTemplatePool=ze,u.SurfaceContext=js,u.SurfaceSystem=Xs,u.TextureAtlas=Nn,u.Vector=q,u.Vertex=Pt,u.VoxelRenderer=su,u.WorldgenStructure=fr,u.XoroshiroPositionalRandom=Gs,u.XoroshiroRandom=nt,u.binarySearch=Os,u.clamp=Mt,u.clampedLerp=Qn,u.clampedMap=Gr,u.computeIfAbsent=Ee,u.getSeed=Vr,u.inverseLerp=Zr,u.isPowerOfTwo=$r,u.jsonToNbt=Ur,u.lazy=rn,u.lazyLerp=kn,u.lazyLerp2=Hr,u.lazyLerp3=Ps,u.lerp=ne,u.lerp2=Kn,u.lerp3=Ls,u.longfromBytes=er,u.map=An,u.mutateWithDefault=mr,u.nextInt=rr,u.randomBetweenInclusive=nr,u.shuffle=zs,u.smoothstep=tr,u.square=ee,u.upperPowerOfTwo=Js,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});