(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 iu=Object.defineProperty;var su=(u,At,Se)=>At in u?iu(u,At,{enumerable:!0,configurable:!0,writable:!0,value:Se}):u[At]=Se;var _=(u,At,Se)=>(su(u,typeof At!="symbol"?At+"":At,Se),Se);function At(n){var t=n.slice(0,2);return t.length===2&&t[0]===31&&t[1]===139}function Se(n){const t=n.slice(0,2);return t.length===2&&t[0]===120&&(t[1]===1||t[1]===94||t[1]===156||t[2]===218)}function ea(n){const t=n.slice(0,8),e=new DataView(t.buffer,t.byteOffset),r=e.getUint32(0,!0),i=e.getUint32(4,!0);if(t.length===8&&r>0&&r<100&&i===n.byteLength-8)return r}function na(n){var t=[],e,r;for(e=0;e>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 ra(n){var t=[],e;for(e=0;e=e)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,e,r){this.accommodate(e),this.view[t](this.offset,r,this.littleEndian),this.offset+=e}writeBytes(t){this.accommodate(t.length),this.array.set(t,this.offset),this.offset+=t.length}writeString(t){const e=na(t);this.writeShort(e.length),this.writeBytes(e)}getData(){return this.accommodate(0),this.array.slice(0,this.offset)}}u.Json=void 0,(n=>{function t(h){return typeof h=="number"?h:void 0}n.readNumber=t;function e(h){return typeof h=="number"?Math.floor(h):void 0}n.readInt=e;function r(h){return typeof h=="string"?h:void 0}n.readString=r;function i(h){return typeof h=="boolean"?h:void 0}n.readBoolean=i;function s(h){return typeof h=="object"&&h!==null&&!Array.isArray(h)?h:void 0}n.readObject=s;function a(h,d){if(!!Array.isArray(h))return d?h.map(f=>d(f)):h}n.readArray=a;function o(h,d){if(!!Array.isArray(h))return[0,1].map(f=>d(h[f]))}n.readPair=o;function m(h,d){var w;const f=(w=s(h))!=null?w:{};return Object.fromEntries(Object.entries(f).map(([v,g])=>[v,d(g)]))}n.readMap=m;function c(h,d,f){const w=d(h);return w?f(w):void 0}n.compose=c;function l(h,d){return typeof h!="string"?d[0]:d.includes(h)?h:d[0]}n.readEnum=l})(u.Json||(u.Json={})),u.Color=void 0,(n=>{function t(i){const s=u.Json.readNumber(i);if(s)return r(s);const a=u.Json.readArray(i,o=>{var m;return(m=u.Json.readNumber(o))!=null?m:0});if(!(a===void 0||a.length!==3))return a}n.fromJson=t;function e(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())}n.fromNbt=e;function r(i){const s=i>>16&255,a=i>>8&255,o=i&255;return[s/255,a/255,o/255]}n.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,e=!1){if(e&&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 e=this.getRead(t);if(e.length===0)throw this.createError("Expected integer");try{const r=Number(e);if(isNaN(r)||!Number.isInteger(r))throw new Error;return r}catch{throw this.cursor=t,this.createError(`Invalid integer '${e}'`)}}readFloat(){const t=this.cursor;for(;this.canRead()&&St.isAllowedInNumber(this.peek());)this.skip();const e=this.getRead(t);if(e.length===0)throw this.createError("Expected float");try{const r=Number(e);if(isNaN(r))throw new Error;return r}catch{throw this.cursor=t,this.createError(`Invalid float '${e}'`)}}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 e=[];let r=!1;for(;this.canRead();){const i=this.read();if(r)if(i===t||i==="\\")e.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 e.join("");e.push(i)}}throw this.createError("Unclosed quoted string")}readBoolean(){const t=this.cursor,e=this.readUnquotedString();if(e.length===0)throw this.createError("Expected bool");if(e==="true")return!0;if(e==="false")return!1;throw this.cursor=t,this.createError(`Invalid bool, expected true or false but found '${e}'`)}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 e=Math.min(this.source.length,this.cursor),r=(e>10?"...":"")+this.source.substring(Math.max(0,e-10),e);return new Error(`${t} at position ${this.cursor}: ${r}<--[HERE]`)}}function rn(n){let t=null;return()=>(t==null&&(t=n()),t)}function Ee(n,t,e){const r=n.get(t);if(r!==void 0)return r;const i=e(t);return n.set(t,i),i}function gr(n,t,e,r){const i=n.get(t),s=i!=null?i:e;return r(s,t),n.set(t,s),s}/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */const ia=4,ci=0,li=1,sa=2;function Ze(n){let t=n.length;for(;--t>=0;)n[t]=0}const aa=0,ui=1,oa=2,ca=3,la=258,wr=29,sn=256,an=sn+1+wr,Ge=30,pr=19,hi=2*an+1,Ie=15,vr=16,ua=7,_r=256,fi=16,di=17,mi=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]),ha=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),gi=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fa=512,Wt=new Array((an+2)*2);Ze(Wt);const on=new Array(Ge*2);Ze(on);const cn=new Array(fa);Ze(cn);const ln=new Array(la-ca+1);Ze(ln);const yr=new Array(wr);Ze(yr);const Jn=new Array(Ge);Ze(Jn);function Sr(n,t,e,r,i){this.static_tree=n,this.extra_bits=t,this.extra_base=e,this.elems=r,this.max_length=i,this.has_stree=n&&n.length}let wi,pi,vi;function Er(n,t){this.dyn_tree=n,this.max_code=0,this.stat_desc=t}const _i=n=>n<256?cn[n]:cn[256+(n>>>7)],un=(n,t)=>{n.pending_buf[n.pending++]=t&255,n.pending_buf[n.pending++]=t>>>8&255},Et=(n,t,e)=>{n.bi_valid>vr-e?(n.bi_buf|=t<>vr-n.bi_valid,n.bi_valid+=e-vr):(n.bi_buf|=t<{Et(n,e[t*2],e[t*2+1])},bi=(n,t)=>{let e=0;do e|=n&1,n>>>=1,e<<=1;while(--t>0);return e>>>1},da=n=>{n.bi_valid===16?(un(n,n.bi_buf),n.bi_buf=0,n.bi_valid=0):n.bi_valid>=8&&(n.pending_buf[n.pending++]=n.bi_buf&255,n.bi_buf>>=8,n.bi_valid-=8)},ma=(n,t)=>{const e=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,m=t.stat_desc.max_length;let c,l,h,d,f,w,v=0;for(d=0;d<=Ie;d++)n.bl_count[d]=0;for(e[n.heap[n.heap_max]*2+1]=0,c=n.heap_max+1;cm&&(d=m,v++),e[l*2+1]=d,!(l>r)&&(n.bl_count[d]++,f=0,l>=o&&(f=a[l-o]),w=e[l*2],n.opt_len+=w*(d+f),s&&(n.static_len+=w*(i[l*2+1]+f)));if(v!==0){do{for(d=m-1;n.bl_count[d]===0;)d--;n.bl_count[d]--,n.bl_count[d+1]+=2,n.bl_count[m]--,v-=2}while(v>0);for(d=m;d!==0;d--)for(l=n.bl_count[d];l!==0;)h=n.heap[--c],!(h>r)&&(e[h*2+1]!==d&&(n.opt_len+=(d-e[h*2+1])*e[h*2],e[h*2+1]=d),l--)}},yi=(n,t,e)=>{const r=new Array(Ie+1);let i=0,s,a;for(s=1;s<=Ie;s++)r[s]=i=i+e[s-1]<<1;for(a=0;a<=t;a++){let o=n[a*2+1];o!==0&&(n[a*2]=bi(r[o]++,o))}},ga=()=>{let n,t,e,r,i;const s=new Array(Ie+1);for(e=0,r=0;r>=7;r{let t;for(t=0;t{n.bi_valid>8?un(n,n.bi_buf):n.bi_valid>0&&(n.pending_buf[n.pending++]=n.bi_buf),n.bi_buf=0,n.bi_valid=0},wa=(n,t,e,r)=>{Ei(n),r&&(un(n,e),un(n,~e)),n.pending_buf.set(n.window.subarray(t,t+e),n.pending),n.pending+=e},Ii=(n,t,e,r)=>{const i=t*2,s=e*2;return n[i]{const r=n.heap[e];let i=e<<1;for(;i<=n.heap_len&&(i{let r,i,s=0,a,o;if(n.last_lit!==0)do r=n.pending_buf[n.d_buf+s*2]<<8|n.pending_buf[n.d_buf+s*2+1],i=n.pending_buf[n.l_buf+s],s++,r===0?Ht(n,i,t):(a=ln[i],Ht(n,a+sn+1,t),o=br[a],o!==0&&(i-=yr[a],Et(n,i,o)),r--,a=_i(r),Ht(n,a,e),o=On[a],o!==0&&(r-=Jn[a],Et(n,r,o)));while(s{const e=t.dyn_tree,r=t.stat_desc.static_tree,i=t.stat_desc.has_stree,s=t.stat_desc.elems;let a,o,m=-1,c;for(n.heap_len=0,n.heap_max=hi,a=0;a>1;a>=1;a--)Ir(n,e,a);c=s;do a=n.heap[1],n.heap[1]=n.heap[n.heap_len--],Ir(n,e,1),o=n.heap[1],n.heap[--n.heap_max]=a,n.heap[--n.heap_max]=o,e[c*2]=e[a*2]+e[o*2],n.depth[c]=(n.depth[a]>=n.depth[o]?n.depth[a]:n.depth[o])+1,e[a*2+1]=e[o*2+1]=c,n.heap[1]=c++,Ir(n,e,1);while(n.heap_len>=2);n.heap[--n.heap_max]=n.heap[1],ma(n,t),yi(e,m,n.bl_count)},Ai=(n,t,e)=>{let r,i=-1,s,a=t[0*2+1],o=0,m=7,c=4;for(a===0&&(m=138,c=3),t[(e+1)*2+1]=65535,r=0;r<=e;r++)s=a,a=t[(r+1)*2+1],!(++o{let r,i=-1,s,a=t[0*2+1],o=0,m=7,c=4;for(a===0&&(m=138,c=3),r=0;r<=e;r++)if(s=a,a=t[(r+1)*2+1],!(++o{let t;for(Ai(n,n.dyn_ltree,n.l_desc.max_code),Ai(n,n.dyn_dtree,n.d_desc.max_code),kr(n,n.bl_desc),t=pr-1;t>=3&&n.bl_tree[gi[t]*2+1]===0;t--);return n.opt_len+=3*(t+1)+5+5+4,t},va=(n,t,e,r)=>{let i;for(Et(n,t-257,5),Et(n,e-1,5),Et(n,r-4,4),i=0;i{let t=4093624447,e;for(e=0;e<=31;e++,t>>>=1)if(t&1&&n.dyn_ltree[e*2]!==0)return ci;if(n.dyn_ltree[9*2]!==0||n.dyn_ltree[10*2]!==0||n.dyn_ltree[13*2]!==0)return li;for(e=32;e{xi||(ga(),xi=!0),n.l_desc=new Er(n.dyn_ltree,wi),n.d_desc=new Er(n.dyn_dtree,pi),n.bl_desc=new Er(n.bl_tree,vi),n.bi_buf=0,n.bi_valid=0,Si(n)},Ri=(n,t,e,r)=>{Et(n,(aa<<1)+(r?1:0),3),wa(n,t,e,!0)},ya=n=>{Et(n,ui<<1,3),Ht(n,_r,Wt),da(n)},Sa=(n,t,e,r)=>{let i,s,a=0;n.level>0?(n.strm.data_type===sa&&(n.strm.data_type=_a(n)),kr(n,n.l_desc),kr(n,n.d_desc),a=pa(n),i=n.opt_len+3+7>>>3,s=n.static_len+3+7>>>3,s<=i&&(i=s)):i=s=e+5,e+4<=i&&t!==-1?Ri(n,t,e,r):n.strategy===ia||s===i?(Et(n,(ui<<1)+(r?1:0),3),ki(n,Wt,on)):(Et(n,(oa<<1)+(r?1:0),3),va(n,n.l_desc.max_code+1,n.d_desc.max_code+1,a+1),ki(n,n.dyn_ltree,n.dyn_dtree)),Si(n),r&&Ei(n)},Ea=(n,t,e)=>(n.pending_buf[n.d_buf+n.last_lit*2]=t>>>8&255,n.pending_buf[n.d_buf+n.last_lit*2+1]=t&255,n.pending_buf[n.l_buf+n.last_lit]=e&255,n.last_lit++,t===0?n.dyn_ltree[e*2]++:(n.matches++,t--,n.dyn_ltree[(ln[e]+sn+1)*2]++,n.dyn_dtree[_i(t)*2]++),n.last_lit===n.lit_bufsize-1);var Ia=ba,ka=Ri,Aa=Sa,Ma=Ea,xa=ya,Ra={_tr_init:Ia,_tr_stored_block:ka,_tr_flush_block:Aa,_tr_tally:Ma,_tr_align:xa},hn=(n,t,e,r)=>{let i=n&65535|0,s=n>>>16&65535|0,a=0;for(;e!==0;){a=e>2e3?2e3:e,e-=a;do i=i+t[r++]|0,s=s+i|0;while(--a);i%=65521,s%=65521}return i|s<<16|0};const Na=()=>{let n,t=[];for(var e=0;e<256;e++){n=e;for(var r=0;r<8;r++)n=n&1?3988292384^n>>>1:n>>>1;t[e]=n}return t},Ca=new Uint32Array(Na());var dt=(n,t,e,r)=>{const i=Ca,s=r+e;n^=-1;for(let a=r;a>>8^i[(n^t[a])&255];return n^-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:Ba,_tr_stored_block:Ta,_tr_flush_block:La,_tr_tally:oe,_tr_align:Pa}=Ra,{Z_NO_FLUSH:Me,Z_PARTIAL_FLUSH:Oa,Z_FULL_FLUSH:Ja,Z_FINISH:ce,Z_BLOCK:Ni,Z_OK:Zt,Z_STREAM_END:Ci,Z_STREAM_ERROR:Nt,Z_DATA_ERROR:za,Z_BUF_ERROR:Ar,Z_DEFAULT_COMPRESSION:Da,Z_FILTERED:Fa,Z_HUFFMAN_ONLY:zn,Z_RLE:Ua,Z_FIXED:Ha,Z_DEFAULT_STRATEGY:Za,Z_UNKNOWN:Ga,Z_DEFLATED:Dn}=Ae,Va=9,$a=15,Ya=8,qa=29,Mr=256+1+qa,Wa=30,Xa=19,ja=2*Mr+1,Ka=15,K=3,le=258,zt=le+K+1,Qa=32,Fn=42,xr=69,Un=73,Hn=91,Zn=103,xe=113,fn=666,ht=1,dn=2,Re=3,Ve=4,to=3,ue=(n,t)=>(n.msg=ke[t],t),Bi=n=>(n<<1)-(n>4?9:0),he=n=>{let t=n.length;for(;--t>=0;)n[t]=0};let fe=(n,t,e)=>(t<{const t=n.state;let e=t.pending;e>n.avail_out&&(e=n.avail_out),e!==0&&(n.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+e),n.next_out),n.next_out+=e,t.pending_out+=e,n.total_out+=e,n.avail_out-=e,t.pending-=e,t.pending===0&&(t.pending_out=0))},gt=(n,t)=>{La(n,n.block_start>=0?n.block_start:-1,n.strstart-n.block_start,t),n.block_start=n.strstart,de(n.strm)},tt=(n,t)=>{n.pending_buf[n.pending++]=t},mn=(n,t)=>{n.pending_buf[n.pending++]=t>>>8&255,n.pending_buf[n.pending++]=t&255},eo=(n,t,e,r)=>{let i=n.avail_in;return i>r&&(i=r),i===0?0:(n.avail_in-=i,t.set(n.input.subarray(n.next_in,n.next_in+i),e),n.state.wrap===1?n.adler=hn(n.adler,t,i,e):n.state.wrap===2&&(n.adler=dt(n.adler,t,i,e)),n.next_in+=i,n.total_in+=i,i)},Ti=(n,t)=>{let e=n.max_chain_length,r=n.strstart,i,s,a=n.prev_length,o=n.nice_match;const m=n.strstart>n.w_size-zt?n.strstart-(n.w_size-zt):0,c=n.window,l=n.w_mask,h=n.prev,d=n.strstart+le;let f=c[r+a-1],w=c[r+a];n.prev_length>=n.good_match&&(e>>=2),o>n.lookahead&&(o=n.lookahead);do if(i=t,!(c[i+a]!==w||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(n.match_start=t,a=s,s>=o)break;f=c[r+a-1],w=c[r+a]}}while((t=h[t&l])>m&&--e!==0);return a<=n.lookahead?a:n.lookahead},Ne=n=>{const t=n.w_size;let e,r,i,s,a;do{if(s=n.window_size-n.lookahead-n.strstart,n.strstart>=t+(t-zt)){n.window.set(n.window.subarray(t,t+t),0),n.match_start-=t,n.strstart-=t,n.block_start-=t,r=n.hash_size,e=r;do i=n.head[--e],n.head[e]=i>=t?i-t:0;while(--r);r=t,e=r;do i=n.prev[--e],n.prev[e]=i>=t?i-t:0;while(--r);s+=t}if(n.strm.avail_in===0)break;if(r=eo(n.strm,n.window,n.strstart+n.lookahead,s),n.lookahead+=r,n.lookahead+n.insert>=K)for(a=n.strstart-n.insert,n.ins_h=n.window[a],n.ins_h=fe(n,n.ins_h,n.window[a+1]);n.insert&&(n.ins_h=fe(n,n.ins_h,n.window[a+K-1]),n.prev[a&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=a,a++,n.insert--,!(n.lookahead+n.insert{let e=65535;for(e>n.pending_buf_size-5&&(e=n.pending_buf_size-5);;){if(n.lookahead<=1){if(Ne(n),n.lookahead===0&&t===Me)return ht;if(n.lookahead===0)break}n.strstart+=n.lookahead,n.lookahead=0;const r=n.block_start+e;if((n.strstart===0||n.strstart>=r)&&(n.lookahead=n.strstart-r,n.strstart=r,gt(n,!1),n.strm.avail_out===0)||n.strstart-n.block_start>=n.w_size-zt&&(gt(n,!1),n.strm.avail_out===0))return ht}return n.insert=0,t===ce?(gt(n,!0),n.strm.avail_out===0?Re:Ve):(n.strstart>n.block_start&&(gt(n,!1),n.strm.avail_out===0),ht)},Rr=(n,t)=>{let e,r;for(;;){if(n.lookahead=K&&(n.ins_h=fe(n,n.ins_h,n.window[n.strstart+K-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),e!==0&&n.strstart-e<=n.w_size-zt&&(n.match_length=Ti(n,e)),n.match_length>=K)if(r=oe(n,n.strstart-n.match_start,n.match_length-K),n.lookahead-=n.match_length,n.match_length<=n.max_lazy_match&&n.lookahead>=K){n.match_length--;do n.strstart++,n.ins_h=fe(n,n.ins_h,n.window[n.strstart+K-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart;while(--n.match_length!==0);n.strstart++}else n.strstart+=n.match_length,n.match_length=0,n.ins_h=n.window[n.strstart],n.ins_h=fe(n,n.ins_h,n.window[n.strstart+1]);else r=oe(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++;if(r&&(gt(n,!1),n.strm.avail_out===0))return ht}return n.insert=n.strstart{let e,r,i;for(;;){if(n.lookahead=K&&(n.ins_h=fe(n,n.ins_h,n.window[n.strstart+K-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart),n.prev_length=n.match_length,n.prev_match=n.match_start,n.match_length=K-1,e!==0&&n.prev_length4096)&&(n.match_length=K-1)),n.prev_length>=K&&n.match_length<=n.prev_length){i=n.strstart+n.lookahead-K,r=oe(n,n.strstart-1-n.prev_match,n.prev_length-K),n.lookahead-=n.prev_length-1,n.prev_length-=2;do++n.strstart<=i&&(n.ins_h=fe(n,n.ins_h,n.window[n.strstart+K-1]),e=n.prev[n.strstart&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=n.strstart);while(--n.prev_length!==0);if(n.match_available=0,n.match_length=K-1,n.strstart++,r&&(gt(n,!1),n.strm.avail_out===0))return ht}else if(n.match_available){if(r=oe(n,0,n.window[n.strstart-1]),r&>(n,!1),n.strstart++,n.lookahead--,n.strm.avail_out===0)return ht}else n.match_available=1,n.strstart++,n.lookahead--}return n.match_available&&(r=oe(n,0,n.window[n.strstart-1]),n.match_available=0),n.insert=n.strstart{let e,r,i,s;const a=n.window;for(;;){if(n.lookahead<=le){if(Ne(n),n.lookahead<=le&&t===Me)return ht;if(n.lookahead===0)break}if(n.match_length=0,n.lookahead>=K&&n.strstart>0&&(i=n.strstart-1,r=a[i],r===a[++i]&&r===a[++i]&&r===a[++i])){s=n.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]&&in.lookahead&&(n.match_length=n.lookahead)}if(n.match_length>=K?(e=oe(n,1,n.match_length-K),n.lookahead-=n.match_length,n.strstart+=n.match_length,n.match_length=0):(e=oe(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++),e&&(gt(n,!1),n.strm.avail_out===0))return ht}return n.insert=0,t===ce?(gt(n,!0),n.strm.avail_out===0?Re:Ve):n.last_lit&&(gt(n,!1),n.strm.avail_out===0)?ht:dn},io=(n,t)=>{let e;for(;;){if(n.lookahead===0&&(Ne(n),n.lookahead===0)){if(t===Me)return ht;break}if(n.match_length=0,e=oe(n,0,n.window[n.strstart]),n.lookahead--,n.strstart++,e&&(gt(n,!1),n.strm.avail_out===0))return ht}return n.insert=0,t===ce?(gt(n,!0),n.strm.avail_out===0?Re:Ve):n.last_lit&&(gt(n,!1),n.strm.avail_out===0)?ht:dn};function Gt(n,t,e,r,i){this.good_length=n,this.max_lazy=t,this.nice_length=e,this.max_chain=r,this.func=i}const gn=[new Gt(0,0,0,0,no),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)],so=n=>{n.window_size=2*n.w_size,he(n.head),n.max_lazy_match=gn[n.level].max_lazy,n.good_match=gn[n.level].good_length,n.nice_match=gn[n.level].nice_length,n.max_chain_length=gn[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=K-1,n.match_available=0,n.ins_h=0};function ao(){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(ja*2),this.dyn_dtree=new Uint16Array((2*Wa+1)*2),this.bl_tree=new Uint16Array((2*Xa+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(Ka+1),this.heap=new Uint16Array(2*Mr+1),he(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*Mr+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 Li=n=>{if(!n||!n.state)return ue(n,Nt);n.total_in=n.total_out=0,n.data_type=Ga;const t=n.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Fn:xe,n.adler=t.wrap===2?0:1,t.last_flush=Me,Ba(t),Zt},Pi=n=>{const t=Li(n);return t===Zt&&so(n.state),t},oo=(n,t)=>!n||!n.state||n.state.wrap!==2?Nt:(n.state.gzhead=t,Zt),Oi=(n,t,e,r,i,s)=>{if(!n)return Nt;let a=1;if(t===Da&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),i<1||i>Va||e!==Dn||r<8||r>15||t<0||t>9||s<0||s>Ha)return ue(n,Nt);r===8&&(r=9);const o=new ao;return n.state=o,o.strm=n,o.wrap=a,o.gzhead=null,o.w_bits=r,o.w_size=1<Oi(n,t,Dn,$a,Ya,Za),lo=(n,t)=>{let e,r;if(!n||!n.state||t>Ni||t<0)return n?ue(n,Nt):Nt;const i=n.state;if(!n.output||!n.input&&n.avail_in!==0||i.status===fn&&t!==ce)return ue(n,n.avail_out===0?Ar:Nt);i.strm=n;const s=i.last_flush;if(i.last_flush=t,i.status===Fn)if(i.wrap===2)n.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&&(n.adler=dt(n.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=xr):(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,to),i.status=xe);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|=Qa),a+=31-a%31,i.status=xe,mn(i,a),i.strstart!==0&&(mn(i,n.adler>>>16),mn(i,n.adler&65535)),n.adler=1}if(i.status===xr)if(i.gzhead.extra){for(e=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>e&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),de(n),e=i.pending,i.pending===i.pending_buf_size));)tt(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>e&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=Un)}else i.status=Un;if(i.status===Un)if(i.gzhead.name){e=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>e&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),de(n),e=i.pending,i.pending===i.pending_buf_size)){r=1;break}i.gzindexe&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),r===0&&(i.gzindex=0,i.status=Hn)}else i.status=Hn;if(i.status===Hn)if(i.gzhead.comment){e=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>e&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),de(n),e=i.pending,i.pending===i.pending_buf_size)){r=1;break}i.gzindexe&&(n.adler=dt(n.adler,i.pending_buf,i.pending-e,e)),r===0&&(i.status=Zn)}else i.status=Zn;if(i.status===Zn&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&de(n),i.pending+2<=i.pending_buf_size&&(tt(i,n.adler&255),tt(i,n.adler>>8&255),n.adler=0,i.status=xe)):i.status=xe),i.pending!==0){if(de(n),n.avail_out===0)return i.last_flush=-1,Zt}else if(n.avail_in===0&&Bi(t)<=Bi(s)&&t!==ce)return ue(n,Ar);if(i.status===fn&&n.avail_in!==0)return ue(n,Ar);if(n.avail_in!==0||i.lookahead!==0||t!==Me&&i.status!==fn){let a=i.strategy===zn?io(i,t):i.strategy===Ua?ro(i,t):gn[i.level].func(i,t);if((a===Re||a===Ve)&&(i.status=fn),a===ht||a===Re)return n.avail_out===0&&(i.last_flush=-1),Zt;if(a===dn&&(t===Oa?Pa(i):t!==Ni&&(Ta(i,0,0,!1),t===Ja&&(he(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),de(n),n.avail_out===0))return i.last_flush=-1,Zt}return t!==ce?Zt:i.wrap<=0?Ci:(i.wrap===2?(tt(i,n.adler&255),tt(i,n.adler>>8&255),tt(i,n.adler>>16&255),tt(i,n.adler>>24&255),tt(i,n.total_in&255),tt(i,n.total_in>>8&255),tt(i,n.total_in>>16&255),tt(i,n.total_in>>24&255)):(mn(i,n.adler>>>16),mn(i,n.adler&65535)),de(n),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?Zt:Ci)},uo=n=>{if(!n||!n.state)return Nt;const t=n.state.status;return t!==Fn&&t!==xr&&t!==Un&&t!==Hn&&t!==Zn&&t!==xe&&t!==fn?ue(n,Nt):(n.state=null,t===xe?ue(n,za):Zt)},ho=(n,t)=>{let e=t.length;if(!n||!n.state)return Nt;const r=n.state,i=r.wrap;if(i===2||i===1&&r.status!==Fn||r.lookahead)return Nt;if(i===1&&(n.adler=hn(n.adler,t,e,0)),r.wrap=0,e>=r.w_size){i===0&&(he(r.head),r.strstart=0,r.block_start=0,r.insert=0);let m=new Uint8Array(r.w_size);m.set(t.subarray(e-r.w_size,e),0),t=m,e=r.w_size}const s=n.avail_in,a=n.next_in,o=n.input;for(n.avail_in=e,n.next_in=0,n.input=t,Ne(r);r.lookahead>=K;){let m=r.strstart,c=r.lookahead-(K-1);do r.ins_h=fe(r,r.ins_h,r.window[m+K-1]),r.prev[m&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=m,m++;while(--c);r.strstart=m,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,n.next_in=a,n.input=o,n.avail_in=s,r.wrap=i,Zt};var fo=co,mo=Oi,go=Pi,wo=Li,po=oo,vo=lo,_o=uo,bo=ho,yo="pako deflate (from Nodeca project)",wn={deflateInit:fo,deflateInit2:mo,deflateReset:go,deflateResetKeep:wo,deflateSetHeader:po,deflate:vo,deflateEnd:_o,deflateSetDictionary:bo,deflateInfo:yo};const So=(n,t)=>Object.prototype.hasOwnProperty.call(n,t);var Eo=function(n){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const e=t.shift();if(!!e){if(typeof e!="object")throw new TypeError(e+"must be non-object");for(const r in e)So(e,r)&&(n[r]=e[r])}}return n},Io=n=>{let t=0;for(let r=0,i=n.length;r=252?6:n>=248?5:n>=240?4:n>=224?3:n>=192?2:1;pn[254]=pn[254]=1;var ko=n=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(n);let t,e,r,i,s,a=n.length,o=0;for(i=0;i>>6,t[s++]=128|e&63):e<65536?(t[s++]=224|e>>>12,t[s++]=128|e>>>6&63,t[s++]=128|e&63):(t[s++]=240|e>>>18,t[s++]=128|e>>>12&63,t[s++]=128|e>>>6&63,t[s++]=128|e&63);return t};const Ao=(n,t)=>{if(t<65534&&n.subarray&&Ji)return String.fromCharCode.apply(null,n.length===t?n:n.subarray(0,t));let e="";for(let r=0;r{const e=t||n.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(n.subarray(0,t));let r,i;const s=new Array(e*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 Ao(s,i)},xo=(n,t)=>{t=t||n.length,t>n.length&&(t=n.length);let e=t-1;for(;e>=0&&(n[e]&192)===128;)e--;return e<0||e===0?t:e+pn[n[e]]>t?e:t},vn={string2buf:ko,buf2string:Mo,utf8border:xo};function Ro(){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 zi=Ro;const Di=Object.prototype.toString,{Z_NO_FLUSH:No,Z_SYNC_FLUSH:Co,Z_FULL_FLUSH:Bo,Z_FINISH:To,Z_OK:Vn,Z_STREAM_END:Lo,Z_DEFAULT_COMPRESSION:Po,Z_DEFAULT_STRATEGY:Oo,Z_DEFLATED:Jo}=Ae;function _n(n){this.options=Gn.assign({level:Po,method:Jo,chunkSize:16384,windowBits:15,memLevel:8,strategy:Oo},n||{});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 zi,this.strm.avail_out=0;let e=wn.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(e!==Vn)throw new Error(ke[e]);if(t.header&&wn.deflateSetHeader(this.strm,t.header),t.dictionary){let r;if(typeof t.dictionary=="string"?r=vn.string2buf(t.dictionary):Di.call(t.dictionary)==="[object ArrayBuffer]"?r=new Uint8Array(t.dictionary):r=t.dictionary,e=wn.deflateSetDictionary(this.strm,r),e!==Vn)throw new Error(ke[e]);this._dict_set=!0}}_n.prototype.push=function(n,t){const e=this.strm,r=this.options.chunkSize;let i,s;if(this.ended)return!1;for(t===~~t?s=t:s=t===!0?To:No,typeof n=="string"?e.input=vn.string2buf(n):Di.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){if(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),(s===Co||s===Bo)&&e.avail_out<=6){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(i=wn.deflate(e,s),i===Lo)return e.next_out>0&&this.onData(e.output.subarray(0,e.next_out)),i=wn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===Vn;if(e.avail_out===0){this.onData(e.output);continue}if(s>0&&e.next_out>0){this.onData(e.output.subarray(0,e.next_out)),e.avail_out=0;continue}if(e.avail_in===0)break}return!0},_n.prototype.onData=function(n){this.chunks.push(n)},_n.prototype.onEnd=function(n){n===Vn&&(this.result=Gn.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Nr(n,t){const e=new _n(t);if(e.push(n,!0),e.err)throw e.msg||ke[e.err];return e.result}function zo(n,t){return t=t||{},t.raw=!0,Nr(n,t)}function Do(n,t){return t=t||{},t.gzip=!0,Nr(n,t)}var Fo=_n,Uo=Nr,Ho=zo,Zo=Do,Go=Ae,Vo={Deflate:Fo,deflate:Uo,deflateRaw:Ho,gzip:Zo,constants:Go};const $n=30,$o=12;var Yo=function(t,e){let r,i,s,a,o,m,c,l,h,d,f,w,v,g,p,S,E,y,k,x,I,R,B,A;const C=t.state;r=t.next_in,B=t.input,i=r+(t.avail_in-5),s=t.next_out,A=t.output,a=s-(e-t.avail_out),o=s+(t.avail_out-257),m=C.dmax,c=C.wsize,l=C.whave,h=C.wnext,d=C.window,f=C.hold,w=C.bits,v=C.lencode,g=C.distcode,p=(1<>>24,f>>>=y,w-=y,y=E>>>16&255,y===0)A[s++]=E&65535;else if(y&16){k=E&65535,y&=15,y&&(w>>=y,w-=y),w<15&&(f+=B[r++]<>>24,f>>>=y,w-=y,y=E>>>16&255,y&16){if(x=E&65535,y&=15,wm){t.msg="invalid distance too far back",C.mode=$n;break t}if(f>>>=y,w-=y,y=s-a,x>y){if(y=x-y,y>l&&C.sane){t.msg="invalid distance too far back",C.mode=$n;break t}if(I=0,R=d,h===0){if(I+=c-y,y2;)A[s++]=R[I++],A[s++]=R[I++],A[s++]=R[I++],k-=3;k&&(A[s++]=R[I++],k>1&&(A[s++]=R[I++]))}else{I=s-x;do A[s++]=A[I++],A[s++]=A[I++],A[s++]=A[I++],k-=3;while(k>2);k&&(A[s++]=A[I++],k>1&&(A[s++]=A[I++]))}}else if((y&64)===0){E=g[(E&65535)+(f&(1<>3,r-=k,w-=k<<3,f&=(1<{const m=o.bits;let c=0,l=0,h=0,d=0,f=0,w=0,v=0,g=0,p=0,S=0,E,y,k,x,I,R=null,B=0,A;const C=new Uint16Array(Ye+1),P=new Uint16Array(Ye+1);let F=null,U=0,j,T,J;for(c=0;c<=Ye;c++)C[c]=0;for(l=0;l=1&&C[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&&(n===Hi||d!==1))return-1;for(P[1]=0,c=1;cFi||n===Zi&&p>Ui)return 1;for(;;){j=c-v,a[l]A?(T=F[U+a[l]],J=R[B+a[l]]):(T=32+64,J=0),E=1<>v)+y]=j<<24|T<<16|J|0;while(y!==0);for(E=1<>=1;if(E!==0?(S&=E-1,S+=E):S=0,l++,--C[c]===0){if(c===d)break;c=t[e+a[l]]}if(c>f&&(S&x)!==k){for(v===0&&(v=f),I+=h,w=c-v,g=1<Fi||n===Zi&&p>Ui)return 1;k=S&x,i[k]=f<<24|w<<16|I-s|0}}return S!==0&&(i[I+S]=c-v<<24|64<<16|0),o.bits=f,0};const Ko=0,Gi=1,Vi=2,{Z_FINISH:$i,Z_BLOCK:Qo,Z_TREES:Yn,Z_OK:Ce,Z_STREAM_END:tc,Z_NEED_DICT:ec,Z_STREAM_ERROR:Ct,Z_DATA_ERROR:Yi,Z_MEM_ERROR:qi,Z_BUF_ERROR:nc,Z_DEFLATED:Wi}=Ae,Xi=1,ji=2,Ki=3,Qi=4,ts=5,es=6,ns=7,rs=8,is=9,ss=10,qn=11,Xt=12,Br=13,as=14,Tr=15,os=16,cs=17,ls=18,us=19,Wn=20,Xn=21,hs=22,fs=23,ds=24,ms=25,gs=26,Lr=27,ws=28,ps=29,st=30,vs=31,rc=32,ic=852,sc=592,ac=15,_s=n=>(n>>>24&255)+(n>>>8&65280)+((n&65280)<<8)+((n&255)<<24);function oc(){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 bs=n=>{if(!n||!n.state)return Ct;const t=n.state;return n.total_in=n.total_out=t.total=0,n.msg="",t.wrap&&(n.adler=t.wrap&1),t.mode=Xi,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(ic),t.distcode=t.distdyn=new Int32Array(sc),t.sane=1,t.back=-1,Ce},ys=n=>{if(!n||!n.state)return Ct;const t=n.state;return t.wsize=0,t.whave=0,t.wnext=0,bs(n)},Ss=(n,t)=>{let e;if(!n||!n.state)return Ct;const r=n.state;return t<0?(e=0,t=-t):(e=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15)?Ct:(r.window!==null&&r.wbits!==t&&(r.window=null),r.wrap=e,r.wbits=t,ys(n))},Es=(n,t)=>{if(!n)return Ct;const e=new oc;n.state=e,e.window=null;const r=Ss(n,t);return r!==Ce&&(n.state=null),r},cc=n=>Es(n,ac);let Is=!0,Pr,Or;const lc=n=>{if(Is){Pr=new Int32Array(512),Or=new Int32Array(32);let t=0;for(;t<144;)n.lens[t++]=8;for(;t<256;)n.lens[t++]=9;for(;t<280;)n.lens[t++]=7;for(;t<288;)n.lens[t++]=8;for(bn(Gi,n.lens,0,288,Pr,0,n.work,{bits:9}),t=0;t<32;)n.lens[t++]=5;bn(Vi,n.lens,0,32,Or,0,n.work,{bits:5}),Is=!1}n.lencode=Pr,n.lenbits=9,n.distcode=Or,n.distbits=5},ks=(n,t,e,r)=>{let i;const s=n.state;return s.window===null&&(s.wsize=1<=s.wsize?(s.window.set(t.subarray(e-s.wsize,e),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>r&&(i=r),s.window.set(t.subarray(e-r,e-r+i),s.wnext),r-=i,r?(s.window.set(t.subarray(e-r,e),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave{let e,r,i,s,a,o,m,c,l,h,d,f,w,v,g=0,p,S,E,y,k,x,I,R;const B=new Uint8Array(4);let A,C;const P=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!n||!n.state||!n.output||!n.input&&n.avail_in!==0)return Ct;e=n.state,e.mode===Xt&&(e.mode=Br),a=n.next_out,i=n.output,m=n.avail_out,s=n.next_in,r=n.input,o=n.avail_in,c=e.hold,l=e.bits,h=o,d=m,R=Ce;t:for(;;)switch(e.mode){case Xi:if(e.wrap===0){e.mode=Br;break}for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>>8&255,e.check=dt(e.check,B,2,0),c=0,l=0,e.mode=ji;break}if(e.flags=0,e.head&&(e.head.done=!1),!(e.wrap&1)||(((c&255)<<8)+(c>>8))%31){n.msg="incorrect header check",e.mode=st;break}if((c&15)!==Wi){n.msg="unknown compression method",e.mode=st;break}if(c>>>=4,l-=4,I=(c&15)+8,e.wbits===0)e.wbits=I;else if(I>e.wbits){n.msg="invalid window size",e.mode=st;break}e.dmax=1<>8&1),e.flags&512&&(B[0]=c&255,B[1]=c>>>8&255,e.check=dt(e.check,B,2,0)),c=0,l=0,e.mode=Ki;case Ki:for(;l<32;){if(o===0)break t;o--,c+=r[s++]<>>8&255,B[2]=c>>>16&255,B[3]=c>>>24&255,e.check=dt(e.check,B,4,0)),c=0,l=0,e.mode=Qi;case Qi:for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>8),e.flags&512&&(B[0]=c&255,B[1]=c>>>8&255,e.check=dt(e.check,B,2,0)),c=0,l=0,e.mode=ts;case ts:if(e.flags&1024){for(;l<16;){if(o===0)break t;o--,c+=r[s++]<>>8&255,e.check=dt(e.check,B,2,0)),c=0,l=0}else e.head&&(e.head.extra=null);e.mode=es;case es:if(e.flags&1024&&(f=e.length,f>o&&(f=o),f&&(e.head&&(I=e.head.extra_len-e.length,e.head.extra||(e.head.extra=new Uint8Array(e.head.extra_len)),e.head.extra.set(r.subarray(s,s+f),I)),e.flags&512&&(e.check=dt(e.check,r,f,s)),o-=f,s+=f,e.length-=f),e.length))break t;e.length=0,e.mode=ns;case ns:if(e.flags&2048){if(o===0)break t;f=0;do I=r[s+f++],e.head&&I&&e.length<65536&&(e.head.name+=String.fromCharCode(I));while(I&&f>9&1,e.head.done=!0),n.adler=e.check=0,e.mode=Xt;break;case ss:for(;l<32;){if(o===0)break t;o--,c+=r[s++]<>>=l&7,l-=l&7,e.mode=Lr;break}for(;l<3;){if(o===0)break t;o--,c+=r[s++]<>>=1,l-=1,c&3){case 0:e.mode=as;break;case 1:if(lc(e),e.mode=Wn,t===Yn){c>>>=2,l-=2;break t}break;case 2:e.mode=cs;break;case 3:n.msg="invalid block type",e.mode=st}c>>>=2,l-=2;break;case as:for(c>>>=l&7,l-=l&7;l<32;){if(o===0)break t;o--,c+=r[s++]<>>16^65535)){n.msg="invalid stored block lengths",e.mode=st;break}if(e.length=c&65535,c=0,l=0,e.mode=Tr,t===Yn)break t;case Tr:e.mode=os;case os:if(f=e.length,f){if(f>o&&(f=o),f>m&&(f=m),f===0)break t;i.set(r.subarray(s,s+f),a),o-=f,s+=f,m-=f,a+=f,e.length-=f;break}e.mode=Xt;break;case cs:for(;l<14;){if(o===0)break t;o--,c+=r[s++]<>>=5,l-=5,e.ndist=(c&31)+1,c>>>=5,l-=5,e.ncode=(c&15)+4,c>>>=4,l-=4,e.nlen>286||e.ndist>30){n.msg="too many length or distance symbols",e.mode=st;break}e.have=0,e.mode=ls;case ls:for(;e.have>>=3,l-=3}for(;e.have<19;)e.lens[P[e.have++]]=0;if(e.lencode=e.lendyn,e.lenbits=7,A={bits:e.lenbits},R=bn(Ko,e.lens,0,19,e.lencode,0,e.work,A),e.lenbits=A.bits,R){n.msg="invalid code lengths set",e.mode=st;break}e.have=0,e.mode=us;case us:for(;e.have>>24,S=g>>>16&255,E=g&65535,!(p<=l);){if(o===0)break t;o--,c+=r[s++]<>>=p,l-=p,e.lens[e.have++]=E;else{if(E===16){for(C=p+2;l>>=p,l-=p,e.have===0){n.msg="invalid bit length repeat",e.mode=st;break}I=e.lens[e.have-1],f=3+(c&3),c>>>=2,l-=2}else if(E===17){for(C=p+3;l>>=p,l-=p,I=0,f=3+(c&7),c>>>=3,l-=3}else{for(C=p+7;l>>=p,l-=p,I=0,f=11+(c&127),c>>>=7,l-=7}if(e.have+f>e.nlen+e.ndist){n.msg="invalid bit length repeat",e.mode=st;break}for(;f--;)e.lens[e.have++]=I}}if(e.mode===st)break;if(e.lens[256]===0){n.msg="invalid code -- missing end-of-block",e.mode=st;break}if(e.lenbits=9,A={bits:e.lenbits},R=bn(Gi,e.lens,0,e.nlen,e.lencode,0,e.work,A),e.lenbits=A.bits,R){n.msg="invalid literal/lengths set",e.mode=st;break}if(e.distbits=6,e.distcode=e.distdyn,A={bits:e.distbits},R=bn(Vi,e.lens,e.nlen,e.ndist,e.distcode,0,e.work,A),e.distbits=A.bits,R){n.msg="invalid distances set",e.mode=st;break}if(e.mode=Wn,t===Yn)break t;case Wn:e.mode=Xn;case Xn:if(o>=6&&m>=258){n.next_out=a,n.avail_out=m,n.next_in=s,n.avail_in=o,e.hold=c,e.bits=l,Yo(n,d),a=n.next_out,i=n.output,m=n.avail_out,s=n.next_in,r=n.input,o=n.avail_in,c=e.hold,l=e.bits,e.mode===Xt&&(e.back=-1);break}for(e.back=0;g=e.lencode[c&(1<>>24,S=g>>>16&255,E=g&65535,!(p<=l);){if(o===0)break t;o--,c+=r[s++]<>y)],p=g>>>24,S=g>>>16&255,E=g&65535,!(y+p<=l);){if(o===0)break t;o--,c+=r[s++]<>>=y,l-=y,e.back+=y}if(c>>>=p,l-=p,e.back+=p,e.length=E,S===0){e.mode=gs;break}if(S&32){e.back=-1,e.mode=Xt;break}if(S&64){n.msg="invalid literal/length code",e.mode=st;break}e.extra=S&15,e.mode=hs;case hs:if(e.extra){for(C=e.extra;l>>=e.extra,l-=e.extra,e.back+=e.extra}e.was=e.length,e.mode=fs;case fs:for(;g=e.distcode[c&(1<>>24,S=g>>>16&255,E=g&65535,!(p<=l);){if(o===0)break t;o--,c+=r[s++]<>y)],p=g>>>24,S=g>>>16&255,E=g&65535,!(y+p<=l);){if(o===0)break t;o--,c+=r[s++]<>>=y,l-=y,e.back+=y}if(c>>>=p,l-=p,e.back+=p,S&64){n.msg="invalid distance code",e.mode=st;break}e.offset=E,e.extra=S&15,e.mode=ds;case ds:if(e.extra){for(C=e.extra;l>>=e.extra,l-=e.extra,e.back+=e.extra}if(e.offset>e.dmax){n.msg="invalid distance too far back",e.mode=st;break}e.mode=ms;case ms:if(m===0)break t;if(f=d-m,e.offset>f){if(f=e.offset-f,f>e.whave&&e.sane){n.msg="invalid distance too far back",e.mode=st;break}f>e.wnext?(f-=e.wnext,w=e.wsize-f):w=e.wnext-f,f>e.length&&(f=e.length),v=e.window}else v=i,w=a-e.offset,f=e.length;f>m&&(f=m),m-=f,e.length-=f;do i[a++]=v[w++];while(--f);e.length===0&&(e.mode=Xn);break;case gs:if(m===0)break t;i[a++]=e.length,m--,e.mode=Xn;break;case Lr:if(e.wrap){for(;l<32;){if(o===0)break t;o--,c|=r[s++]<{if(!n||!n.state)return Ct;let t=n.state;return t.window&&(t.window=null),n.state=null,Ce},fc=(n,t)=>{if(!n||!n.state)return Ct;const e=n.state;return(e.wrap&2)===0?Ct:(e.head=t,t.done=!1,Ce)},dc=(n,t)=>{const e=t.length;let r,i,s;return!n||!n.state||(r=n.state,r.wrap!==0&&r.mode!==qn)?Ct:r.mode===qn&&(i=1,i=hn(i,t,e,0),i!==r.check)?Yi:(s=ks(n,t,e,e),s?(r.mode=vs,qi):(r.havedict=1,Ce))};var mc=ys,gc=Ss,wc=bs,pc=cc,vc=Es,_c=uc,bc=hc,yc=fc,Sc=dc,Ec="pako inflate (from Nodeca project)",jt={inflateReset:mc,inflateReset2:gc,inflateResetKeep:wc,inflateInit:pc,inflateInit2:vc,inflate:_c,inflateEnd:bc,inflateGetHeader:yc,inflateSetDictionary:Sc,inflateInfo:Ec};function Ic(){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 kc=Ic;const As=Object.prototype.toString,{Z_NO_FLUSH:Ac,Z_FINISH:Mc,Z_OK:yn,Z_STREAM_END:Jr,Z_NEED_DICT:zr,Z_STREAM_ERROR:xc,Z_DATA_ERROR:Ms,Z_MEM_ERROR:Rc}=Ae;function Sn(n){this.options=Gn.assign({chunkSize:1024*64,windowBits:15,to:""},n||{});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&&!(n&&n.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 zi,this.strm.avail_out=0;let e=jt.inflateInit2(this.strm,t.windowBits);if(e!==yn)throw new Error(ke[e]);if(this.header=new kc,jt.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=vn.string2buf(t.dictionary):As.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(e=jt.inflateSetDictionary(this.strm,t.dictionary),e!==yn)))throw new Error(ke[e])}Sn.prototype.push=function(n,t){const e=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?Mc:Ac,As.call(n)==="[object ArrayBuffer]"?e.input=new Uint8Array(n):e.input=n,e.next_in=0,e.avail_in=e.input.length;;){for(e.avail_out===0&&(e.output=new Uint8Array(r),e.next_out=0,e.avail_out=r),s=jt.inflate(e,a),s===zr&&i&&(s=jt.inflateSetDictionary(e,i),s===yn?s=jt.inflate(e,a):s===Ms&&(s=zr));e.avail_in>0&&s===Jr&&e.state.wrap>0&&n[e.next_in]!==0;)jt.inflateReset(e),s=jt.inflate(e,a);switch(s){case xc:case Ms:case zr:case Rc:return this.onEnd(s),this.ended=!0,!1}if(o=e.avail_out,e.next_out&&(e.avail_out===0||s===Jr))if(this.options.to==="string"){let m=vn.utf8border(e.output,e.next_out),c=e.next_out-m,l=vn.buf2string(e.output,m);e.next_out=c,e.avail_out=r-c,c&&e.output.set(e.output.subarray(m,m+c),0),this.onData(l)}else this.onData(e.output.length===e.next_out?e.output:e.output.subarray(0,e.next_out));if(!(s===yn&&o===0)){if(s===Jr)return s=jt.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(e.avail_in===0)break}}return!0},Sn.prototype.onData=function(n){this.chunks.push(n)},Sn.prototype.onEnd=function(n){n===yn&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=Gn.flattenChunks(this.chunks)),this.chunks=[],this.err=n,this.msg=this.strm.msg};function Dr(n,t){const e=new Sn(t);if(e.push(n),e.err)throw e.msg||ke[e.err];return e.result}function Nc(n,t){return t=t||{},t.raw=!0,Dr(n,t)}var Cc=Sn,Bc=Dr,Tc=Nc,Lc=Dr,Pc=Ae,Oc={Inflate:Cc,inflate:Bc,inflateRaw:Tc,ungzip:Lc,constants:Pc};const{Deflate:Jc,deflate:zc,deflateRaw:Dc,gzip:Fc}=Vo,{Inflate:Uc,inflate:Hc,inflateRaw:Zc,ungzip:Gc}=Oc;var Vc=Jc,$c=zc,Yc=Dc,qc=Fc,Wc=Uc,Xc=Hc,jc=Zc,Kc=Gc,Qc=Ae,Fr={Deflate:Vc,deflate:$c,deflateRaw:Yc,gzip:qc,Inflate:Wc,inflate:Xc,inflateRaw:jc,ungzip:Kc,constants:Qc},D=(n=>(n[n.End=0]="End",n[n.Byte=1]="Byte",n[n.Short=2]="Short",n[n.Int=3]="Int",n[n.Long=4]="Long",n[n.Float=5]="Float",n[n.Double=6]="Double",n[n.ByteArray=7]="ByteArray",n[n.String=8]="String",n[n.List=9]="List",n[n.Compound=10]="Compound",n[n.IntArray=11]="IntArray",n[n.LongArray=12]="LongArray",n))(D||{});const dr=class{static register(t,e){const r=e.create().getId();if(r!==t)throw new Error(`Registered factory ${D[r]} does not match type ${D[t]}`);dr.FACTORIES.set(t,e)}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 e=this.FACTORIES.get(t);if(!e)throw new Error(`Invalid tag id ${t}`);return e}static create(t){return this.getFactory(t).create()}static fromString(t){const e=typeof t=="string"?new St(t):t;return this.getFactory(D.Compound).fromString(e)}static fromJson(t,e=D.Compound){return this.getFactory(e).fromJson(t)}static fromJsonWithId(t){var i,s,a;const e=(i=u.Json.readObject(t))!=null?i:{},r=(s=u.Json.readInt(e.type))!=null?s:0;return dr.fromJson((a=e.value)!=null?a:{},r)}static fromBytes(t,e=D.Compound){return this.getFactory(e).fromBytes(t)}};let et=dr;_(et,"FACTORIES",new Map);const Fe=class extends et{constructor(e){super();_(this,"value");this.value=typeof e=="number"?e:e?1:0}getId(){return D.Byte}equals(e){return e.isByte()&&this.value===e.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()+"b"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(e){e.writeByte(this.value)}static create(){return Fe.ZERO}static fromJson(e){var r;return new Fe((r=u.Json.readInt(e))!=null?r:0)}static fromBytes(e){const r=e.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(e){super();_(this,"items");this.items=e}getItems(){return this.items.slice(0)}getAsTuple(e,r){return[...Array(e)].map((i,s)=>r(this.items[s]))}get(e){if(e=Math.floor(e),!(e<0||e>=this.items.length))return this.items[e]}get length(){return this.items.length}map(e){return this.items.map(e)}filter(e){return this.items.filter(e)}forEach(e){this.items.forEach(e)}set(e,r){this.items[e]=r}add(e){this.items.push(e)}insert(e,r){this.items.splice(e,0,r)}delete(e){this.items.splice(e,1)}clear(){this.items=[]}}class me extends En{constructor(t){super(Array.from(t!=null?t:[],e=>typeof e=="number"?new Bt(e):e))}getId(){return D.ByteArray}equals(t){return t.isByteArray()&&this.length===t.length&&this.items.every((e,r)=>e.equals(t.items[r]))}getType(){return D.Byte}toString(){return"[B;"+this.items.map(e=>e.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(e=>e.getAsNumber()))}static create(){return new me([])}static fromJson(t){var r;const e=(r=u.Json.readArray(t,i=>{var s;return(s=u.Json.readNumber(i))!=null?s:0}))!=null?r:[];return new me(e)}static fromBytes(t){const e=t.readInt(),r=t.readBytes(e);return new me(r)}}et.register(D.ByteArray,me);class Be extends et{constructor(e){super();_(this,"value");this.value=e}getId(){return D.Float}equals(e){return e.isFloat()&&this.value===e.value}getAsNumber(){return this.value}toString(){return this.value.toString()+"f"}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(e){e.writeFloat(this.value)}static create(){return new Be(0)}static fromJson(e){var r;return new Be((r=u.Json.readNumber(e))!=null?r:0)}static fromBytes(e){const r=e.readFloat();return new Be(r)}}et.register(D.Float,Be);class Dt extends et{constructor(e){super();_(this,"value");this.value=e}getId(){return D.Int}equals(e){return e.isInt()&&this.value===e.value}getAsNumber(){return this.value}toString(){return this.value.toFixed()}toPrettyString(){return this.toString()}toSimplifiedJson(){return this.value}toJson(){return this.value}toBytes(e){e.writeInt(this.value)}static create(){return new Dt(0)}static fromJson(e){var r;return new Dt((r=u.Json.readInt(e))!=null?r:0)}static fromBytes(e){const r=e.readInt();return new Dt(r)}}et.register(D.Int,Dt);class ge extends En{constructor(t){super(Array.from(t!=null?t:[],e=>typeof e=="number"?new Dt(e):e))}getId(){return D.IntArray}equals(t){return t.isIntArray()&&this.length===t.length&&this.items.every((e,r)=>e.equals(t.items[r]))}getType(){return D.Int}get length(){return this.items.length}toString(){return"[I;"+this.items.map(e=>e.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 e of this.items)t.writeInt(e.getAsNumber())}static create(){return new ge}static fromJson(t){var r;const e=(r=u.Json.readArray(t,i=>{var s;return(s=u.Json.readNumber(i))!=null?s:0}))!=null?r:[];return new ge(e)}static fromBytes(t){const e=t.readInt(),r=[];for(let i=0;inew e(i)))}getId(){return D.List}equals(e){return e.isList()&&this.type===e.type&&this.length===e.length&&this.items.every((r,i)=>r.equals(e.items[i]))}getType(){return this.type}getNumber(e){const r=this.get(e);return r!=null&&r.isNumber()?r.getAsNumber():0}getString(e){const r=this.get(e);return r!=null&&r.isString()?r.getAsString():""}getList(e,r){const i=this.get(e);return(i==null?void 0:i.isList())&&i.getType()===r?i:Tt.create()}getCompound(e){const r=this.get(e);return r!=null&&r.isCompound()?r:mt.create()}set(e,r){this.updateType(r),super.set(e,r)}add(e){this.updateType(e),super.add(e)}insert(e,r){this.updateType(r),super.insert(e,r)}updateType(e){if(e.getId()!==D.End){if(this.type===D.End)this.type=e.getId();else if(this.type!==e.getId())throw new Error(`Trying to add tag of type ${D[e.getId()]} to list of ${D[this.type]}`)}}clear(){super.clear(),this.type=D.End}toString(){return"["+this.items.map(e=>e.toString()).join(",")+"]"}toPrettyString(e=" ",r=0){if(this.length===0)return"[]";const i=e.repeat(r),s=e.repeat(r+1);return`[ `+this.map(a=>s+a.toPrettyString(e,r+1)).join(`, `)+` `+i+"]"}toSimplifiedJson(){return this.map(e=>e.toSimplifiedJson())}toJson(){return{type:this.type,items:this.items.map(e=>e.toJson())}}toBytes(e){this.items.length===0?this.type=D.End:this.type=this.items[0].getId(),e.writeByte(this.type),e.writeInt(this.items.length);for(const r of this.items)r.toBytes(e)}static create(){return new Tt}static fromJson(e){var a,o,m;const r=(a=u.Json.readObject(e))!=null?a:{},i=(o=u.Json.readNumber(r.type))!=null?o:D.Compound,s=((m=u.Json.readArray(r.items))!=null?m:[]).flatMap(c=>c!==void 0?[et.fromJson(c,i)]:[]);return new Tt(s,i)}static fromBytes(e){const r=e.readByte(),i=e.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(e){const r=e.readInt(),i=e.readInt();return new ft([r,i])}};let Te=ft;_(Te,"dataview",new DataView(new Uint8Array(8).buffer)),et.register(D.Long,Te);class we extends En{constructor(t){super(Array.from(t!=null?t:[],e=>typeof e=="bigint"||Array.isArray(e)?new Te(e):e))}getId(){return D.LongArray}equals(t){return t.isLongArray()&&this.length===t.length&&this.items.every((e,r)=>e.equals(t.items[r]))}getType(){return D.Long}get length(){return this.items.length}toString(){return"[I;"+this.items.map(e=>e.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 e of this.items){const[r,i]=e.getAsPair();t.writeInt(r),t.writeInt(i)}}static create(){return new we}static fromJson(t){var r;const e=(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 we(e)}static fromBytes(t){const e=t.readInt(),r=[];for(let i=0;i{const t=new RegExp("^[-+]?(?:[0-9]+[.]|[0-9]*[.][0-9]+)(?:e[-+]?[0-9]+)?$","i"),e=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 m(f){if(f.skipWhitespace(),!f.canRead())throw f.createError("Expected value");const w=f.peek();if(w==="{")return c(f);if(w==="[")if(f.canRead(3)&&!St.isQuotedStringStart(f.peek(1))&&f.peek(2)===";"){f.expect("[",!0);const v=f.cursor,g=f.read();if(f.skip(),f.skipWhitespace(),f.canRead()){if(g==="B")return h(f,me,D.ByteArray,D.Byte);if(g==="L")return h(f,we,D.LongArray,D.Long);if(g==="I")return h(f,ge,D.IntArray,D.Int);throw f.cursor=v,f.createError(`Invalid array type '${g}'`)}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 g=f.readUnquotedString();if(g.length===0)throw f.cursor=v,f.createError("Expected value");try{if(r.test(g)){const p=Number(g.substring(0,g.length-1));return new Be(p)}else if(i.test(g)){const p=Number(g.substring(0,g.length-1));return new Bt(Math.floor(p))}else if(s.test(g)){const p=BigInt(g.substring(0,g.length-1));return new Te(p)}else if(a.test(g)){const p=Number(g.substring(0,g.length-1));return new Le(Math.floor(p))}else if(o.test(g)){const p=Number(g);return new Dt(Math.floor(p))}else if(e.test(g)){const p=Number(g.substring(0,g.length-1));return new Qt(p)}else if(t.test(g)){const p=Number(g);return new Qt(p)}else{if(g.toLowerCase()==="true")return Bt.ONE;if(g.toLowerCase()==="false")return Bt.ZERO}}catch{}return g.length===0?vt.EMPTY:new vt(g)}}}n.readTag=m;function c(f){f.expect("{",!0);const w=new Map;for(f.skipWhitespace();f.canRead()&&f.peek()!=="}";){const v=f.cursor;if(f.skipWhitespace(),!f.canRead())throw f.createError("Expected key");const g=f.readString();if(g.length===0)throw f.cursor=v,f.createError("Expected key");f.expect(":",!0);const p=m(f);if(w.set(g,p),!d(f))break;if(!f.canRead())throw f.createError("Expected key")}return f.expect("}",!0),new mt(w)}function l(f){if(f.expect("[",!0),f.skipWhitespace(),!f.canRead())throw f.createError("Expected value");const w=[];let v=D.End;for(;f.peek()!=="]";){const g=f.cursor,p=m(f),S=p.getId();if(v===D.End)v=S;else if(S!==v)throw f.cursor=g,f.createError(`Can't insert ${D[S]} into list of ${D[v]}`);if(w.push(p),!d(f))break;if(!f.canRead())throw f.createError("Expected value")}return f.expect("]",!0),new Tt(w,v)}function h(f,w,v,g){const p=[];for(;f.peek()!=="]";){const S=m(f);if(S.getId()!==g)throw f.createError(`Can't insert ${D[S.getId()]} into ${D[v]}`);if(p.push(S.isLong()?S.getAsPair():S.getAsNumber()),!d(f))break;if(!f.canRead())throw f.createError("Expected value")}return f.expect("]"),new w(p)}function d(f){return f.skipWhitespace(),f.canRead()&&f.peek()===","?(f.skip(),f.skipWhitespace(),!0):!1}})(jn||(jn={}));class mt extends et{constructor(e){super();_(this,"properties");this.properties=e!=null?e:new Map}getId(){return D.Compound}equals(e){return e.isCompound()&&this.size===e.size&&[...this.properties.entries()].every(([r,i])=>{const s=e.properties.get(r);return s!==void 0&&i.equals(s)})}has(e){return this.properties.has(e)}hasNumber(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.isNumber())!=null?i:!1}hasString(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.isString())!=null?i:!1}hasList(e,r,i){var a;const s=this.get(e);return(a=(s==null?void 0:s.isList())&&(r===void 0||s.getType()===r)&&(i===void 0||s.length===i))!=null?a:!1}hasCompound(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.isCompound())!=null?i:!1}get(e){return this.properties.get(e)}getString(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.getAsString())!=null?i:""}getNumber(e){var r,i;return(i=(r=this.get(e))==null?void 0:r.getAsNumber())!=null?i:0}getBoolean(e){return this.getNumber(e)!==0}getList(e,r){const i=this.get(e);return(i==null?void 0:i.isList())&&(r===void 0||i.getType()===r)?i:Tt.create()}getCompound(e){const r=this.get(e);return r!=null&&r.isCompound()?r:mt.create()}getByteArray(e){const r=this.get(e);return r!=null&&r.isByteArray()?r:me.create()}getIntArray(e){const r=this.get(e);return r!=null&&r.isIntArray()?r:ge.create()}getLongArray(e){const r=this.get(e);return r!=null&&r.isLongArray()?r:we.create()}keys(){return this.properties.keys()}get size(){return this.properties.size}map(e){return Object.fromEntries([...this.properties.entries()].map(([r,i])=>e(r,i,this)))}forEach(e){[...this.properties.entries()].forEach(([r,i])=>e(r,i,this))}set(e,r){return this.properties.set(e,r),this}delete(e){return this.properties.delete(e)}clear(){return this.properties.clear(),this}toString(){const e=[];for(const[r,i]of this.properties.entries()){const s=r.split("").some(a=>!St.isAllowedInUnquotedString(a));e.push((s?JSON.stringify(r):r)+":"+i.toString())}return"{"+e.join(",")+"}"}toPrettyString(e=" ",r=0){if(this.size===0)return"{}";const i=e.repeat(r),s=e.repeat(r+1),a=[];for(const[o,m]of this.properties.entries()){const c=o.split("").some(l=>!St.isAllowedInUnquotedString(l));a.push((c?JSON.stringify(o):o)+": "+m.toPrettyString(e,r+1))}return`{ `+a.map(o=>s+o).join(`, `)+` `+i+"}"}toSimplifiedJson(){return this.map((e,r)=>[e,r.toSimplifiedJson()])}toJson(){return this.map((e,r)=>[e,{type:r.getId(),value:r.toJson()}])}toBytes(e){for(const[r,i]of this.properties.entries()){const s=i.getId();e.writeByte(s),e.writeString(r),i.toBytes(e)}e.writeByte(D.End)}static create(){return new mt}static fromString(e){return jn.readTag(e)}static fromJson(e){const r=u.Json.readMap(e,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 mt(new Map(Object.entries(r)))}static fromBytes(e){const r=new Map;for(;;){const i=e.readByte();if(i===D.End)break;const s=e.readString(),a=et.fromBytes(e,i);r.set(s,a)}return new mt(r)}}et.register(D.Compound,mt);const be=class{constructor(t,e,r,i,s){this.name=t,this.root=e,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,e=new oi({littleEndian:t,offset:this.bedrockHeader&&8});if(this.writeNamedTag(e),this.bedrockHeader!==void 0){const i=e.offset;e.offset=0,e.writeInt(this.bedrockHeader),e.writeInt(i-8),e.offset=i}const r=e.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:mt.fromBytes(t)}}static create(t={}){var o,m,c;const e=(o=t.name)!=null?o:be.DEFAULT_NAME,r=mt.create(),i=(m=t.compression)!=null?m:"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(e,r,i,a,s)}static read(t,e={}){var d;const r=typeof e.bedrockHeader=="number"?e.bedrockHeader:e.bedrockHeader?ea(t):void 0,i=e.compression==="gzip"||!r&&e.compression===void 0&&At(t),s=e.compression==="zlib"||!r&&e.compression===void 0&&Se(t),a=s||i?Fr.inflate(t):t,o=e.littleEndian||r!==void 0,m=i?"gzip":s?"zlib":"none",c=new ai(a,{littleEndian:o,offset:r&&8}),{name:l,root:h}=be.readNamedTag(c);return new be((d=e.name)!=null?d:l,h,m,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 m,c,l,h,d;const e=(m=u.Json.readObject(t))!=null?m:{},r=(c=u.Json.readString(e.name))!=null?c:"",i=mt.fromJson((l=e.root)!=null?l:{}),s=(h=u.Json.readString(e.compression))!=null?h:"none",a=(d=u.Json.readBoolean(e.littleEndian))!=null?d:!1,o=u.Json.readNumber(e.bedrockHeader);return new be(r,i,s,a,o)}};let Vt=be;_(Vt,"DEFAULT_NAME",""),_(Vt,"DEFAULT_BEDROCK_HEADER",4);class Kt{constructor(t,e,r,i,s){_(this,"file");_(this,"dirty");this.x=t,this.z=e,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,e,r,i){const s=new Kt(t,e,0,i!=null?i:0,r.write());return s.setCompression(r.compression),s}static fromJson(t,e){var c,l,h,d,f,w;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,m=(w=u.Json.readInt(r.size))!=null?w:0;return new Kt.Ref(i,s,a,o,m,e)}}(n=>{class t{constructor(r,i,s,a,o,m){_(this,"file");this.x=r,this.z=i,this.compression=s,this.timestamp=a,this.size=o,this.resolver=m}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}}n.Ref=t})(Kt||(Kt={}));class xs{constructor(t){_(this,"chunks");this.chunks=Array(32*32).fill(void 0);for(const e of t){const r=pe.getIndex(e.x,e.z);this.chunks[r]=e}}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,e){return this.getChunk(pe.getIndex(t,e))}getFirstChunk(){return this.chunks.filter(t=>t!==void 0)[0]}filter(t){return this.chunks.filter(e=>e!==void 0&&t(e))}map(t){return this.chunks.flatMap(e=>e!==void 0?[t(e)]:[])}}class pe extends xs{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 e=new Uint8Array(8192+t*4096),r=new DataView(e.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),m=Math.ceil(a.length/4096);r.setInt8(o,i>>16),r.setInt16(o+1,i&65535),r.setInt8(o+3,m),r.setInt32(o+4096,s.timestamp);const c=i*4096;r.setInt32(c,a.length+1),r.setInt8(c+4,s.compression),e.set(a,c+5),i+=m}return e}static read(t){const e=[];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],m=(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);e.push(new Kt(r,i,h,m,d))}return new pe(e)}static getIndex(t,e){return(t&31)+(e&31)*32}toJson(){return{chunks:this.map(t=>t.toJson())}}static fromJson(t,e){var a,o;const r=(a=u.Json.readObject(t))!=null?a:{},s=((o=u.Json.readArray(r.chunks))!=null?o:[]).flatMap(m=>m!==void 0?[Kt.fromJson(m,e)]:[]);return new pe.Ref(s)}}(n=>{class t extends xs{}n.Ref=t})(pe||(pe={}));class Qt extends et{constructor(e){super();_(this,"value");this.value=e}getId(){return D.Double}equals(e){return e.isDouble()&&this.value===e.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(e){e.writeDouble(this.value)}static create(){return new Qt(0)}static fromJson(e){var r;return new Qt((r=u.Json.readNumber(e))!=null?r:0)}static fromBytes(e){const r=e.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(n){return typeof n=="string"?new vt(n):typeof n=="number"?Number.isInteger(n)?new Dt(n):new Qt(n):typeof n=="boolean"?new Bt(n):Array.isArray(n)?new Tt(n.map(Ur)):typeof n=="object"&&n!==null?new mt(new Map(Object.entries(n!=null?n:{}).map(([t,e])=>[t,Ur(e)]))):new Bt(0)}u.Direction=(n=>(n.UP="up",n.DOWN="down",n.NORTH="north",n.EAST="east",n.SOUTH="south",n.WEST="west",n))(u.Direction||{});const tl={up:[0,1,0],down:[0,-1,0],north:[0,0,-1],east:[1,0,0],south:[0,0,1],west:[-1,0,0]};(n=>{n.ALL=["up","down","north","east","south","west"];function t(e){return tl[e]}n.normal=t})(u.Direction||(u.Direction={})),u.BlockPos=void 0,(n=>{function t(h,d,f){return[h,d,f]}n.create=t,n.ZERO=n.create(0,0,0);function e(h,d,f,w){return[h[0]+d,h[1]+f,h[2]+w]}n.offset=e;function r(h,d){return[h[0]-d[0],h[1]-d[1],h[2]-d[2]]}n.subtract=r;function i(h,d){return[h[0]+d[0],h[1]+d[1],h[2]+d[2]]}n.add=i;function s(h,d){return n.offset(h,...u.Direction.normal(d))}n.towards=s;function a(h,d){return h===d?!0:h[0]===d[0]&&h[1]===d[1]&&h[2]===d[2]}n.equals=a;function o(h){return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]}n.magnitude=o;function m(h){return new Tt(h.map(d=>new Dt(d)))}n.toNbt=m;function c(h){return h.getAsTuple(3,d=>d!=null&&d.isInt()?d.getAsNumber():0)}n.fromNbt=c;function l(h){var f;const d=(f=u.Json.readArray(h,w=>{var v;return(v=u.Json.readInt(w))!=null?v:0}))!=null?f:[0,0,0];return t(d[0],d[1],d[2])}n.fromJson=l})(u.BlockPos||(u.BlockPos={}));const ae=class{constructor(t,e){this.namespace=t,this.path=e}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 e=t.indexOf(this.SEPARATOR);if(e>=0){const r=e>=1?t.substring(0,e):this.DEFAULT_NAMESPACE,i=t.substring(e+1);return new ae(r,i)}return new ae(this.DEFAULT_NAMESPACE,t)}};let N=ae;_(N,"DEFAULT_NAMESPACE","minecraft"),_(N,"SEPARATOR",":");const bt=class{constructor(t,e={}){_(this,"name");this.properties=e,this.name=typeof t=="string"?N.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(e=>t.properties[e]===this.properties[e]):!1}is(t){return typeof t=="string"?this.name.equals(N.parse(t)):t instanceof N?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,e])=>t+"="+e).join(",")}]`}static parse(t){const e=t.indexOf("[");if(e===-1)return new bt(t);{const r=t.substring(0,e),i=t.substring(e+1,t.length-1).split(","),s=Object.fromEntries(i.map(a=>a.split("=")));return new bt(r,s)}}static fromNbt(t){const e=N.parse(t.getString("Name")),r=t.getCompound("Properties").map((i,s)=>[i,s.getAsString()]);return new bt(e,r)}static fromJson(t){var s,a;const e=(s=u.Json.readObject(t))!=null?s:{},r=N.parse((a=u.Json.readString(e.Name))!=null?a:bt.STONE.name.toString()),i=u.Json.readMap(e.Properties,o=>{var m;return(m=u.Json.readString(o))!=null?m:""});return new bt(r,i)}};let X=bt;_(X,"AIR",new bt(N.create("air"))),_(X,"STONE",new bt(N.create("stone"))),_(X,"WATER",new bt(N.create("water"),{level:"0"})),_(X,"LAVA",new bt(N.create("lava"),{level:"0"}));class Rs{constructor(t,e){_(this,"storage");_(this,"palette");this.size=t,this.defaultValue=e,this.storage=Array(t).fill(0),this.palette=[e]}index(t,e,r){return(t<<8)+(e<<4)+r}get(t,e,r){const i=this.storage[this.index(t,e,r)];return this.palette[i]}set(t,e,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,e,r)]=s}}const tn=class{constructor(t){_(this,"states");this.minY=t,this.states=new Rs(tn.SIZE,X.AIR)}get minBlockY(){return this.minY<<4}getBlockState(t,e,r){return this.states.get(t,e,r)}setBlockState(t,e,r,i){this.states.set(t,e,r,i)}};let qe=tn;_(qe,"WIDTH",16),_(qe,"SIZE",tn.WIDTH*tn.WIDTH*tn.WIDTH);class el{constructor(t,e,r){_(this,"sections");this.minY=t,this.height=e,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[e,r,i]=t,s=this.sections[this.getSectionIndex(r)];return(a=s==null?void 0:s.getBlockState(e&15,r&15,i&15))!=null?a:X.AIR}setBlockState(t,e){const[r,i,s]=t,a=this.getSectionIndex(i);let o=this.sections[a];if(o===null){if(e.equals(X.AIR))return;o=this.getOrCreateSection(a)}o.setBlockState(r&15,i&15,s&15,e)}getOrCreateSection(t){return this.sections[t]==null&&(this.sections[t]=new qe(this.minSection+t)),this.sections[t]}}u.ChunkPos=void 0,(n=>{function t(l,h){return[l,h]}n.create=t;function e(l){return[l[0]>>4,l[2]>>4]}n.fromBlockPos=e;function r(l){return[Number(l)&4294967295,Number(l>>BigInt(32))]}n.fromLong=r;function i(l){return s(l[0],l[1])}n.toLong=i;function s(l,h){return BigInt(l&4294967295)|BigInt(h&4294967295)<{function t(e){return{effect:N.parse(e.getString("id")),duration:e.getNumber("duration"),amplifier:e.getNumber("amplifier")}}n.fromNbt=t})(u.MobEffectInstance||(u.MobEffectInstance={}));const Cs=new Map([["minecraft:empty",[]],["minecraft:water",[]],["minecraft:mundane",[]],["minecraft:thick",[]],["minecraft:awkward",[]],["minecraft:night_vision",[{effect:N.create("night_vision"),duration:3600,amplifier:0}]],["minecraft:long_night_vision",[{effect:N.create("night_vision"),duration:9600,amplifier:0}]],["minecraft:invisibility",[{effect:N.create("invisibility"),duration:3600,amplifier:0}]],["minecraft:long_invisibility",[{effect:N.create("invisibility"),duration:9600,amplifier:0}]],["minecraft:leaping",[{effect:N.create("jump_boost"),duration:3600,amplifier:0}]],["minecraft:long_leaping",[{effect:N.create("jump_boost"),duration:9600,amplifier:0}]],["minecraft:strong_leaping",[{effect:N.create("jump_boost"),duration:1800,amplifier:1}]],["minecraft:fire_resistance",[{effect:N.create("fire_resistance"),duration:3600,amplifier:0}]],["minecraft:long_fire_resistance",[{effect:N.create("fire_resistance"),duration:9600,amplifier:0}]],["minecraft:swiftness",[{effect:N.create("speed"),duration:3600,amplifier:0}]],["minecraft:long_swiftness",[{effect:N.create("speed"),duration:9600,amplifier:0}]],["minecraft:strong_swiftness",[{effect:N.create("speed"),duration:1800,amplifier:1}]],["minecraft:slowness",[{effect:N.create("slowness"),duration:1800,amplifier:0}]],["minecraft:long_slowness",[{effect:N.create("slowness"),duration:4800,amplifier:0}]],["minecraft:strong_slowness",[{effect:N.create("slowness"),duration:400,amplifier:3}]],["minecraft:turtle_master",[{effect:N.create("slowness"),duration:400,amplifier:3},{effect:N.create("resistance"),duration:400,amplifier:2}]],["minecraft:long_turtle_master",[{effect:N.create("slowness"),duration:800,amplifier:3},{effect:N.create("resistance"),duration:800,amplifier:2}]],["minecraft:strong_turtle_master",[{effect:N.create("slowness"),duration:400,amplifier:5},{effect:N.create("resistance"),duration:400,amplifier:3}]],["minecraft:water_breathing",[{effect:N.create("water_breathing"),duration:3600,amplifier:0}]],["minecraft:long_water_breathing",[{effect:N.create("water_breathing"),duration:9600,amplifier:0}]],["minecraft:healing",[{effect:N.create("instant_health"),duration:1,amplifier:0}]],["minecraft:strong_healing",[{effect:N.create("instant_health"),duration:1,amplifier:1}]],["minecraft:harming",[{effect:N.create("instant_damage"),duration:1,amplifier:0}]],["minecraft:strong_harming",[{effect:N.create("instant_damage"),duration:1,amplifier:1}]],["minecraft:poison",[{effect:N.create("poison"),duration:900,amplifier:0}]],["minecraft:long_poison",[{effect:N.create("poison"),duration:1800,amplifier:0}]],["minecraft:strong_poison",[{effect:N.create("poison"),duration:432,amplifier:1}]],["minecraft:regeneration",[{effect:N.create("regeneration"),duration:900,amplifier:0}]],["minecraft:long_regeneration",[{effect:N.create("regeneration"),duration:1800,amplifier:0}]],["minecraft:strong_regeneration",[{effect:N.create("regeneration"),duration:450,amplifier:1}]],["minecraft:strength",[{effect:N.create("strength"),duration:3600,amplifier:0}]],["minecraft:long_strength",[{effect:N.create("strength"),duration:9600,amplifier:0}]],["minecraft:strong_strength",[{effect:N.create("strength"),duration:1800,amplifier:1}]],["minecraft:weakness",[{effect:N.create("weakness"),duration:1800,amplifier:0}]],["minecraft:long_weakness",[{effect:N.create("weakness"),duration:4800,amplifier:0}]],["minecraft:luck",[{effect:N.create("luck"),duration:6e3,amplifier:0}]],["minecraft:slow_falling",[{effect:N.create("slow_falling"),duration:1800,amplifier:0}]],["minecraft:long_slow_falling",[{effect:N.create("slow_falling"),duration:4800,amplifier:0}]],["minecraft:wind_charged",[{effect:N.create("wind_charged"),duration:3600,amplifier:0}]],["minecraft:weaving",[{effect:N.create("weaving"),duration:3600,amplifier:0}]],["minecraft:oozing",[{effect:N.create("oozing"),duration:3600,amplifier:0}]],["minecraft:infested",[{effect:N.create("infested"),duration:3600,amplifier:0}]]]);u.PotionContents=void 0,(n=>{function t(s){const a={};return s.isString()?a.potion=N.parse(s.getAsString()):s.isCompound()&&(s.hasString("potion")&&(a.potion=N.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}n.fromNbt=t;function e(s){if(s.customColor)return u.Color.intToRgb(s.customColor);const a=r(s);return i(a)}n.getColor=e;function r(s){var o;const a=[];return s.potion&&a.push(...(o=Cs.get(s.potion.toString()))!=null?o:[]),s.customEffects&&a.push(...s.customEffects),a}n.getAllEffects=r;function i(s){let[a,o,m]=[0,0,0],c=0;for(const l of s){const h=Ns.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],m+=f*d[2],c+=f}return c===0?u.Color.intToRgb(-13083194):(a=a/c,o=o/c,m=m/c,[a,o,m])}})(u.PotionContents||(u.PotionContents={})),u.Holder=void 0,(n=>{function t(i,s){return a=>typeof a=="string"?r(i,N.parse(a)):e(s(a))}n.parser=t;function e(i,s){return{value:()=>i,key:()=>s}}n.direct=e;function r(i,s,a=!0){return a?{value:()=>i.getOrThrow(s),key:()=>s}:{value:()=>i.get(s),key:()=>s}}n.reference=r})(u.Holder||(u.Holder={}));class ve{constructor(t){this.entries=t}static parser(t,e){const r=e!=null?e:i=>{var s;return u.Holder.reference(t,N.parse((s=u.Json.readString(i))!=null?s:""))};return i=>{var s,a;return typeof i=="string"?i.startsWith("#")?u.Holder.reference(t.getTagRegistry(),N.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,e,r){var o,m,c;const i=(o=u.Json.readObject(e))!=null?o:{},s=(m=u.Json.readBoolean(i.replace))!=null?m:!1,a=(c=u.Json.readArray(i.values,l=>{var f,w,v;var h=!0,d="";if(typeof l=="string")d=l;else{const g=(f=u.Json.readObject(l))!=null?f:{};h=(w=u.Json.readBoolean(g.required))!=null?w:!1,d=(v=u.Json.readString(g.id))!=null?v:""}return d.startsWith("#")?u.Holder.reference(t.getTagRegistry(),N.parse(d.substring(1)),h):u.Holder.reference(t,N.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 e=t.value();e!==void 0&&(e instanceof ve?yield*e.getEntries():yield t)}}}class $t{constructor(t,e,r=new Map){this.id=t,this.count=e,this.components=r}getComponent(t,e){var i;if(typeof t=="string"&&(t=N.parse(t)),this.components.has("!"+t.toString()))return;const r=this.components.get(t.toString());if(r)return r;if(e)return(i=e.getItemComponents(this.id))==null?void 0:i.get(t.toString())}hasComponent(t,e){var r;return typeof t=="string"&&(t=N.parse(t)),this.components.has("!"+t.toString())?!1:this.components.has(t.toString())?!0:e?(r=e.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(N.parse(t)):t instanceof N?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[e,r]of this.components){const i=t.components.get(e);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(([e,r])=>e.startsWith("!")?e:`${e}=${r.toString()}`).join(",")}]`),this.count>1&&(t+=` ${this.count}`),t}static fromString(t){const e=new St(t);for(;e.canRead()&&e.peek()!=="[";)e.skip();const r=N.parse(e.getRead());if(!e.canRead())return new $t(r,1);const i=new Map;if(e.skip(),e.peek()==="]")return new $t(r,1,i);do{if(e.peek()==="!"){e.skip();const s=e.cursor;for(;e.canRead()&&e.peek()!=="]"&&e.peek()!==",";)e.skip();i.set("!"+N.parse(e.getRead(s)).toString(),new mt)}else{const s=e.cursor;for(;e.canRead()&&e.peek()!=="=";)e.skip();const a=N.parse(e.getRead(s)).toString();if(!e.canRead())break;e.skip();const o=jn.readTag(e);i.set(a,o)}if(!e.canRead())break;if(e.peek()==="]")return new $t(r,1,i);if(e.peek()!==",")throw new Error("Expected , or ]");e.skip()}while(e.canRead());throw new Error("Missing closing ]")}toNbt(){const t=new mt().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 mt(this.components)),t}static fromNbt(t){const e=N.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("!")?["!"+N.parse(s).toString(),new mt]:[N.parse(s).toString(),a])));return new $t(e,r,i)}}const Ue=class{constructor(t,e){_(this,"storage",new Map);_(this,"builtin",new Map);_(this,"tags");this.key=t,this.parser=e}static createAndRegister(t,e){const r=new Ue(N.create(t),e);return Ue.REGISTRY.register(r.key,r),r}register(t,e,r){return this.storage.set(t.toString(),e),r&&this.builtin.set(t.toString(),e),u.Holder.reference(this,t)}delete(t){const e=this.storage.delete(t.toString());return this.builtin.delete(t.toString()),e}keys(){return[...this.storage.keys()].map(t=>N.parse(t))}has(t){return this.storage.has(t.toString())}get(t){var e=this.storage.get(t.toString());return e instanceof Function&&(e=e(),this.storage.set(t.toString(),e)),e}getOrThrow(t){const e=this.get(t);if(e===void 0)throw new Error(`Missing key in ${this.key.toString()}: ${t.toString()}`);return e}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,e]of this.builtin.entries())this.storage.set(t,e);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 e of t.keys())this.storage.set(e.toString(),t.getOrThrow(e));return this}cloneEmpty(){return new Ue(this.key,this.parser)}forEach(t){for(const[e,r]of this.storage.entries())t(N.parse(e),r instanceof Function?r():r,this)}map(t){return[...this.storage.entries()].map(([e,r])=>t(N.parse(e),r instanceof Function?r():r,this))}getTagRegistry(){return this.tags===void 0&&(this.tags=new Ue(new N(this.key.namespace,`tags/${this.key.path}`))),this.tags}};let Mt=Ue;_(Mt,"REGISTRY",new Ue(N.create("root"))),u.Rotation=(n=>(n.NONE="none",n.CLOCKWISE_90="clockwise_90",n.CLOCKWISE_180="180",n.COUNTERCLOCKWISE_90="counterclockwise_90",n))(u.Rotation||{}),(n=>{function t(e){return["none","clockwise_90","180","counterclockwise_90"][e.nextInt(4)]}n.getRandom=t})(u.Rotation||(u.Rotation={}));const mr=class{constructor(t,e=[],r=[]){_(this,"blocksMap",[]);this.size=t,this.palette=e,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,e,r,i){if(!this.isInside(t))throw new Error(`Cannot add block at ${t} outside the structure bounds ${this.size}`);const s=new X(e,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 e=this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]];return e?this.toPlacedBlock(e):null}toPlacedBlock(t){const e=this.palette[t.state];if(!e)throw new Error(`Block at ${t.pos.join(" ")} in structure references invalid palette index ${t.state}`);return{pos:t.pos,state:e,nbt:t.nbt}}isInside(t){return t[0]>=0&&t[0]=0&&t[1]=0&&t[2]X.fromNbt(s)),i=t.getList("blocks",D.Compound).map(s=>{const a=u.BlockPos.fromNbt(s.getList("pos")),o=s.getNumber("state"),m=s.getCompound("nbt");return{pos:a,state:o,nbt:m.size>0?m:void 0}});return new mr(e,r,i)}static transform(t,e,r){switch(e){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=mr;_(te,"REGISTRY",Mt.createAndRegister("structures")),_(te,"EMPTY",new mr(u.BlockPos.ZERO));function ee(n){return n*n}function xt(n,t,e){return Math.max(t,Math.min(e,n))}function ne(n,t,e){return t+n*(e-t)}function Kn(n,t,e,r,i,s){return ne(t,ne(n,e,r),ne(n,i,s))}function Bs(n,t,e,r,i,s,a,o,m,c,l){return ne(e,Kn(n,t,r,i,s,a),Kn(n,t,o,m,c,l))}function kn(n,t,e){return n===0?t():n===1?e():t()+n*(e()-t())}function Hr(n,t,e,r,i,s){return kn(t,()=>kn(n,e,r),()=>kn(n,i,s))}function Ts(n,t,e,r,i,s,a,o,m,c,l){return kn(e,()=>Hr(n,t,r,i,s,a),()=>Hr(n,t,o,m,c,l))}function Qn(n,t,e){return e<0?n:e>1?t:ne(e,n,t)}function Zr(n,t,e){return(n-t)/(e-t)}function tr(n){return n*n*n*(n*(n*6-15)+10)}function An(n,t,e,r,i){return ne(Zr(n,t,e),r,i)}function Gr(n,t,e,r,i){return Qn(r,i,Zr(n,t,e))}function Ls(n,t,e){let r=t-n;for(;r>0;){const i=Math.floor(r/2),s=n+i;if(e(s)){r=i;continue}n=s+1,r-=i+1}return n}function Vr(n,t,e){let r=BigInt(n*3129871)^BigInt(e)*BigInt(116129781)^BigInt(t);return r=r*r*BigInt(42317861)+r*BigInt(11),r>>BigInt(16)}function er(n,t,e,r,i,s,a,o){return BigInt(n)<>1,n|=n>>2,n|=n>>4,n|=n>>8,n|=n>>18,n|=n>>32,n+1}function nr(n,t,e){return n.nextInt(e-t+1)+t}function rr(n,t,e){return t>=e?t:n.nextInt(e-t+1)+t}function Os(n,t){for(var e=n.length;e>1;e--){const r=t.nextInt(e),i=n[r];n[r]=n[e-1],n[e-1]=i}}u.MinMaxNumberFunction=void 0,(n=>{function t(e){return typeof e=="object"&&e!==null&&"minValue"in e&&"maxValue"in e}n.is=t})(u.MinMaxNumberFunction||(u.MinMaxNumberFunction={})),u.CubicSpline=void 0,(n=>{function t(i,s){var c,l,h,d;if(typeof i=="number")return new e(i);const a=(c=u.Json.readObject(i))!=null?c:{},o=new r(s(a.coordinate)),m=(l=u.Json.readArray(a.points,f=>{var w;return(w=u.Json.readObject(f))!=null?w:{}}))!=null?l:[];if(m.length===0)return new e(0);for(const f of m){const w=(h=u.Json.readNumber(f.location))!=null?h:0,v=t(f.value,s),g=(d=u.Json.readNumber(f.derivative))!=null?d:0;o.addPoint(w,v,g)}return o}n.fromJson=t;class e{constructor(s){this.value=s}compute(){return this.value}min(){return this.value}max(){return this.value}mapAll(){return this}calculateMinMax(){}}n.Constant=e;class r{constructor(s,a=[],o=[],m=[]){_(this,"calculatedMin",Number.NEGATIVE_INFINITY);_(this,"calculatedMax",Number.POSITIVE_INFINITY);this.coordinate=s,this.locations=a,this.values=o,this.derivatives=m}compute(s){const a=this.coordinate.compute(s),o=Ls(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 n.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 m=this.coordinate.minValue(),c=this.coordinate.maxValue();for(const h of this.values)h.calculateMinMax();if(mthis.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(e,r){return e<<32-r|e>>>r},endian:function(e){if(e.constructor==Number)return t.rotl(e,8)&16711935|t.rotl(e,24)&4278255360;for(var r=0;r0;e--)r.push(Math.floor(Math.random()*256));return r},bytesToWords:function(e){for(var r=[],i=0,s=0;i>>5]|=e[i]<<24-s%32;return r},wordsToBytes:function(e){for(var r=[],i=0;i>>5]>>>24-i%32&255);return r},bytesToHex:function(e){for(var r=[],i=0;i>>4).toString(16)),r.push((e[i]&15).toString(16));return r.join("")},hexToBytes:function(e){for(var r=[],i=0;i>>6*(3-a)&63)):r.push("=");return r.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/ig,"");for(var r=[],i=0,s=0;i>>6-s*2);return r}};zs.exports=t})();var jr={utf8:{stringToBytes:function(n){return jr.bin.stringToBytes(unescape(encodeURIComponent(n)))},bytesToString:function(n){return decodeURIComponent(escape(jr.bin.bytesToString(n)))}},bin:{stringToBytes:function(n){for(var t=[],e=0;e * @license MIT */var zl=function(n){return n!=null&&(Fs(n)||Dl(n)||!!n._isBuffer)};function Fs(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Dl(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Fs(n.slice(0,0))}(function(){var n=zs.exports,t=Ds.utf8,e=zl,r=Ds.bin,i=function(s,a){s.constructor==String?a&&a.encoding==="binary"?s=r.stringToBytes(s):s=t.stringToBytes(s):e(s)?s=Array.prototype.slice.call(s,0):!Array.isArray(s)&&s.constructor!==Uint8Array&&(s=s.toString());for(var o=n.bytesToWords(s),m=s.length*8,c=1732584193,l=-271733879,h=-1732584194,d=271733878,f=0;f>>24)&16711935|(o[f]<<24|o[f]>>>8)&4278255360;o[m>>>5]|=128<>>9<<4)+14]=m;for(var w=i._ff,v=i._gg,g=i._hh,p=i._ii,f=0;f>>0,l=l+E>>>0,h=h+y>>>0,d=d+k>>>0}return n.endian([c,l,h,d])};i._ff=function(s,a,o,m,c,l,h){var d=s+(a&o|~a&m)+(c>>>0)+h;return(d<>>32-l)+a},i._gg=function(s,a,o,m,c,l,h){var d=s+(a&m|o&~m)+(c>>>0)+h;return(d<>>32-l)+a},i._hh=function(s,a,o,m,c,l,h){var d=s+(a^o^m)+(c>>>0)+h;return(d<>>32-l)+a},i._ii=function(s,a,o,m,c,l,h){var d=s+(o^(a|~m))+(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=n.wordsToBytes(i(s,a));return a&&a.asBytes?o:a&&a.asString?r.bytesToString(o):n.bytesToHex(o)}})();const Rt=class{constructor(t){_(this,"seed",BigInt(0));this.setSeed(t)}static fromLargeFeatureSeed(t,e,r){const i=new Rt(t),s=i.nextLong(),a=i.nextLong(),o=BigInt(e)*s^BigInt(r)*a^t;return i.setSeed(o),i}static fromLargeFeatureWithSalt(t,e,r,i){const s=BigInt(e)*BigInt("341873128712")+BigInt(r)*BigInt("132897987541")+t+BigInt(i);return new Rt(s)}fork(){return new Rt(this.nextLong())}forkPositional(){return new Us(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 e=0;e>BigInt(Rt.MODULUS_BITS-t));return e>2147483647?e-4294967296:e}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 e,r;for(;(e=this.next(31))-(r=e%t)+(t-1)<0;);return r}nextLong(){return(BigInt(this.next(32))<>V.BIGINT_30)*V.STAFFORD_1&V.MAX_ULONG,t=(t^t>>V.BIGINT_27)*V.STAFFORD_2&V.MAX_ULONG,(t^t>>V.BIGINT_31)&V.MAX_ULONG}static upgradeSeedTo128bit(t){t<0&&(t+=V.POW2_60);const e=t^V.SILVER_RATIO_64,r=e+V.GOLDEN_RATIO_64&V.MAX_ULONG;return[V.mixStafford13(e),V.mixStafford13(r)]}static rotateLeft(t,e){return t<>V.BIGINT_64-e}setSeed(t){this.seed=V.upgradeSeedTo128bit(t)}fork(){return new V([this.next(),this.next()])}forkPositional(){return new Hs(this.next(),this.next())}next(){const t=this.seed[0];let e=this.seed[1];const r=V.rotateLeft(t+e&V.MAX_ULONG,V.BIGINT_17)+t&V.MAX_ULONG;return e^=t,this.seed=[V.rotateLeft(t,V.BIGINT_49)^e^e<V.POW2_63&&(t-=V.POW2_60),t}consume(t){let e=this.seed[0],r=this.seed[1];for(let i=0;i>BigInt(64-t)}nextInt(t){let e=this.next()&V.MAX_UINT;if(t){const r=BigInt(t);let i=e*r,s=i&V.MAX_UINT;if(s>V.BIGINT_32;return Number(a)}else{let r=Number(e);return r>=2147483648&&(r-=4294967296),r}}nextFloat(){return Number(this.nextBits(24))*V.FLOAT_MULTIPLIER}nextDouble(){return Number(this.nextBits(53))*V.DOUBLE_MULTIPLIER}parityConfigString(){return"seedLo: "+this.seed[0]+", seedHi: "+this.seed[1]}};let nt=V;_(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 Hs{constructor(t,e){this.seedLo=t,this.seedHi=e}at(t,e,r){const s=Vr(t,e,r)^this.seedLo;return new nt([s,this.seedHi])}fromHashOf(t){const e=Xr.exports(t,{asBytes:!0}),r=er(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]),i=er(e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[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 e=0;e<256;e+=1)this.p[e]=e;for(let e=0;e<256;e+=1){const r=t.nextInt(256-e),i=this.p[e];this.p[e]=this.p[e+r],this.p[e+r]=i}}sample2D(t,e){let r,i,s;const a=(t+e)*qt.F2,o=Math.floor(t+a),m=o-(r=(o+(i=Math.floor(e+a)))*qt.G2),c=t-m;let l,h;c>(s=e-(i-r))?(l=1,h=0):(l=0,h=1);const d=c-l+qt.G2,f=s-h+qt.G2,w=c-1+2*qt.G2,v=s-1+2*qt.G2,g=o&255,p=i&255,S=this.P(g+this.P(p))%12,E=this.P(g+l+this.P(p+h))%12,y=this.P(g+1+this.P(p+1))%12,k=this.getCornerNoise3D(S,c,s,0,.5),x=this.getCornerNoise3D(E,d,f,0,.5),I=this.getCornerNoise3D(y,w,v,0,.5);return 70*(k+x+I)}sample(t,e,r){const i=(t+e+r)*.3333333333333333,s=Math.floor(t+i),a=Math.floor(e+i),o=Math.floor(r+i),m=(s+a+o)*.16666666666666666,c=t-(s-m),l=e-(a-m),h=r-(o-m);let d,f,w,v,g,p;c>=l?l>=h?(d=1,f=0,w=0,v=1,g=1,p=0):c>=h?(d=1,f=0,w=0,v=1,g=0,p=1):(d=0,f=0,w=1,v=1,g=0,p=1):l127?e-256:e;for(let e=0;e<256;e+=1){const r=t.nextInt(256-e),i=this.p[e];this.p[e]=this.p[e+r],this.p[e+r]=i}}sample(t,e,r,i=0,s=0){const a=t+this.xo,o=e+this.yo,m=r+this.zo,c=Math.floor(a),l=Math.floor(o),h=Math.floor(m),d=a-c,f=o-l,w=m-h;let v=0;if(i!==0){const g=s>=0&&s=0;s-=1)s0&&(d=this.maxLimitNoise.getOctaveNoise(p))&&(g+=d.sample(S,E,y,k,s*w)/w),w/=2}return Qn(v/512,g/512,f)/128}}const Bn=class{constructor(t,{firstOctave:e,amplitudes:r}){_(this,"valueFactor");_(this,"first");_(this,"second");_(this,"maxValue");this.first=new pt(t,e,r),this.second=new pt(t,e,r);let i=1/0,s=-1/0;for(let o=0;o{function t(r,i){return{firstOctave:r,amplitudes:i}}n.create=t;function e(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,m=>{var c;return(c=u.Json.readNumber(m))!=null?c:0}))!=null?o:[]}}n.fromJson=e})(u.NoiseParameters||(u.NoiseParameters={}));class Fl{constructor(t,e){_(this,"noiseLevels");_(this,"highestFreqInputFactor");_(this,"highestFreqValueFactor");const r=e[e.length-1],s=-e[0]+r+1,a=new Set(e),o=new wt(t);this.noiseLevels=Array(s),r>=0&&r=0&&a.has(r-m)?this.noiseLevels[m]=new wt(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,e,r){let i=0,s=this.highestFreqInputFactor,a=this.highestFreqValueFactor;for(let o=0;o{const t=n/15,e=t*.6+(t>0?.4:.3),r=xt(t*t*.7-.5,0,1),i=xt(t*t*.6-.7,0,1);return[e,r,i]},Vs=n=>[n/8,1-n/32,n*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:()=>Ul,birch_leaves:()=>Hl,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:n=>{var t;return Gl(parseInt((t=n.power)!=null?t:"0"))},sugar_cane:()=>se,attached_melon_stem:()=>Gs,attached_pumpkin_stem:()=>Gs,melon_stem:n=>{var t;return Vs(parseInt((t=n.age)!=null?t:"0"))},pumpkin_stem:n=>{var t;return Vs(parseInt((t=n.age)!=null?t:"0"))},lily_pad:()=>Zl};u.Cull=void 0,(n=>{function t(r,i,s){let{up:a,down:o,north:m,east:c,south:l,west:h}=r;switch(s){case 90:[m,c,l,h]=[c,l,h,m];break;case 180:[m,c,l,h]=[l,h,m,c];break;case 270:[m,c,l,h]=[h,m,c,l]}switch(i){case 90:[a,m,o,l]=[m,o,l,a];break;case 180:[a,m,o,l]=[o,l,a,m];break;case 270:[a,m,o,l]=[l,a,m,o]}return{up:a,down:o,north:m,east:c,south:l,west:h}}n.rotate=t;function e(){return Object.create(null)}n.none=e})(u.Cull||(u.Cull={}));const Ut=class{constructor(t,e,r,i,s){this.pos=t,this.color=e,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,Ol(Ut.VEC,Ut.VEC,t),this.pos=new Y(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,e){this.v1=t,this.v2=e}vertices(){return[this.v1,this.v2]}forEach(t){return t(this.v1),t(this.v2),this}transform(t){return this.forEach(e=>e.transform(t)),this}setColor(t){return this.forEach(e=>e.color=t),this}toString(){return`Line(${this.v1.pos.toString()}, ${this.v2.pos.toString()})`}static fromPoints(t,e){return new or(Pt.fromPos(t),Pt.fromPos(e))}}class it{constructor(t=[],e=[]){_(this,"posBuffer");_(this,"colorBuffer");_(this,"textureBuffer");_(this,"normalBuffer");_(this,"blockPosBuffer");_(this,"indexBuffer");_(this,"linePosBuffer");_(this,"lineColorBuffer");this.quads=t,this.lines=e}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,e,r,i,s,a,o){const m=new or(Pt.fromPos(new Y(t,e,r)),Pt.fromPos(new Y(i,s,a))).setColor(o);return this.lines.push(m),this}addLineCube(t,e,r,i,s,a,o){return this.addLine(t,e,r,t,e,a,o),this.addLine(i,e,r,i,e,a,o),this.addLine(t,e,r,i,e,r,o),this.addLine(t,e,a,i,e,a,o),this.addLine(t,e,r,t,s,r,o),this.addLine(i,e,r,i,s,r,o),this.addLine(t,e,a,t,s,a,o),this.addLine(i,e,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 e of this.quads)e.transform(t);return this}computeNormals(){for(const t of this.quads){const e=t.normal();t.forEach(r=>r.normal=e)}}rebuild(t,e){const r=(s,a,o)=>{var m;if(s||(s=(m=t.createBuffer())!=null?m: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 m=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(m))};return e.pos&&(this.posBuffer=i(this.quads,this.posBuffer,s=>s.pos.components()),this.linePosBuffer=i(this.lines,this.linePosBuffer,s=>s.pos.components())),e.color&&(this.colorBuffer=i(this.quads,this.colorBuffer,s=>s.color),this.lineColorBuffer=i(this.lines,this.lineColorBuffer,s=>s.color)),e.texture&&(this.textureBuffer=i(this.quads,this.textureBuffer,s=>s.texture)),e.normal&&(this.normalBuffer=i(this.quads,this.normalBuffer,s=>{var a;return(a=s.normal)==null?void 0:a.components()})),e.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,e){this.variants=t,this.multipart=e}getModelVariants(t){if(this.variants){const e=Object.keys(this.variants).filter(i=>this.matchesVariant(i,t));if(e.length===0)return[];const r=this.variants[e[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,e,r,i,s){var c,l,h,d,f;const a=this.getModelVariants(e),o=new it;for(const w of a){const v=u.Cull.rotate(s,(c=w.x)!=null?c:0,(l=w.y)!=null?l:0),g=i.getBlockModel(N.parse(w.model));if(!g)throw new Error(`Cannot find block model ${w.model}`);const p=t?(h=Pe[t.path])==null?void 0:h.call(Pe,e):void 0,S=g.getMesh(r,v,p);if(w.x||w.y){const E=rt();W(E,E,[8,8,8]),_t(E,E,-Yr((d=w.y)!=null?d:0)),Mn(E,E,-Yr((f=w.x)!=null?f:0)),W(E,E,[-8,-8,-8]),S.transform(E)}o.merge(S)}const m=rt();return Lt(m,m,[.0625,.0625,.0625]),o.transform(m)}matchesVariant(t,e){return t.split(",").every(r=>{const[i,s]=r.split("=");return e[i]===s})}matchesCase(t,e){if(Array.isArray(t.OR))return t.OR.some(i=>this.matchesCase(i,e));const r=t;return Object.keys(r).every(i=>r[i].split("|").includes(e[i]))}static fromJson(t){return new Qr(t.variants,t.multipart)}}class Yt{constructor(t,e,r,i){this.v1=t,this.v2=e,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(e=>e.transform(t)),this}normal(){const t=this.v2.pos.sub(this.v1.pos),e=this.v3.pos.sub(this.v1.pos);return t.cross(e).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(e=>e.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,e,r,i){return new Yt(Pt.fromPos(t),Pt.fromPos(e),Pt.fromPos(r),Pt.fromPos(i))}}const Vl={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]},$l={x:[1,0,0],y:[0,1,0],z:[0,0,1]},Xe=1.41421356237,Yl={x:[1,Xe,Xe],y:[Xe,1,Xe],z:[Xe,Xe,1]},en=class{constructor(t,e,r,i,s){_(this,"generationMarker",!1);_(this,"uvEpsilon",1/16);this.parent=t,this.textures=e,this.elements=r,this.display=i,this.guiLight=s}getDisplayTransform(t){var i;const e=(i=this.display)==null?void 0:i[t],r=rt();return W(r,r,[8,8,8]),e!=null&&e.translation&&W(r,r,e.translation),e!=null&&e.rotation&&(Mn(r,r,e.rotation[0]*Math.PI/180),_t(r,r,e.rotation[1]*Math.PI/180),Js(r,r,-e.rotation[2]*Math.PI/180)),e!=null&&e.scale&&Lt(r,r,e.scale),W(r,r,[-8,-8,-8]),r}getMesh(t,e,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,e,s));return i}getElementMesh(t,e,r,i){var w,v,g,p,S,E,y,k,x,I,R,B;const s=new it,[a,o,m]=t.from,[c,l,h]=t.to,d=(A,C,P)=>{var Z,Q,It,kt,yt,ut,lt,H,O;const F=Yt.fromPoints(new Y(P[0],P[1],P[2]),new Y(P[3],P[4],P[5]),new Y(P[6],P[7],P[8]),new Y(P[9],P[10],P[11])),U=i(A.tintindex);F.setColor(U);const[j,T,J,$]=e.getTextureUV(this.getTexture(A.texture)),G=(J-j)/16,M=($-T)/16,b=G*this.uvEpsilon,L=M*this.uvEpsilon;C[0]=((Q=(Z=A.uv)==null?void 0:Z[0])!=null?Q:C[0])*G+b,C[1]=((kt=(It=A.uv)==null?void 0:It[1])!=null?kt:C[1])*M+L,C[2]=((ut=(yt=A.uv)==null?void 0:yt[2])!=null?ut:C[2])*G-b,C[3]=((H=(lt=A.uv)==null?void 0:lt[3])!=null?H:C[3])*M-L;const z=Vl[(O=A.rotation)!=null?O:0];F.setTexture([j+C[z[0]],T+C[z[1]],j+C[z[2]],T+C[z[3]],j+C[z[4]],T+C[z[5]],j+C[z[6]],T+C[z[7]]]),s.quads.push(F)};((v=(w=t.faces)==null?void 0:w.up)==null?void 0:v.texture)&&(!t.faces.up.cullface||!r[t.faces.up.cullface])&&d(t.faces.up,[a,16-h,c,16-m],[a,l,h,c,l,h,c,l,m,a,l,m]),((p=(g=t.faces)==null?void 0:g.down)==null?void 0:p.texture)&&(!t.faces.down.cullface||!r[t.faces.down.cullface])&&d(t.faces.down,[16-h,16-c,16-m,16-a],[a,o,m,c,o,m,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,m,a,o,m,a,l,m,c,l,m]),((I=(x=t.faces)==null?void 0:x.east)==null?void 0:I.texture)&&(!t.faces.east.cullface||!r[t.faces.east.cullface])&&d(t.faces.east,[16-h,16-l,16-m,16-o],[c,o,h,c,o,m,c,l,m,c,l,h]),((B=(R=t.faces)==null?void 0:R.west)==null?void 0:B.texture)&&(!t.faces.west.cullface||!r[t.faces.west.cullface])&&d(t.faces.west,[m,16-l,h,16-o],[a,o,m,a,o,h,a,l,h,a,l,m]);const f=rt();if(t.rotation){const A=Ll(...t.rotation.origin);W(f,f,A),El(f,f,Yr(t.rotation.angle),$l[t.rotation.axis]),t.rotation.rescale&&Lt(f,f,Yl[t.rotation.axis]),Pl(A,A),W(f,f,A)}return s.transform(f)}getTexture(t){var e,r;for(;t.startsWith("#");)t=(r=(e=this.textures)==null?void 0:e[t.slice(1)])!=null?r:"";return N.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 e=this.getParent(t);if(!e){console.warn(`parent ${this.parent} does not exist!`),this.parent=void 0;return}if(e.flatten(t),this.elements||(this.elements=e.elements),this.textures||(this.textures={}),Object.keys((r=e.textures)!=null?r:{}).forEach(o=>{this.textures[o]||(this.textures[o]=e.textures[o])}),this.display||(this.display={}),Object.keys((i=e.display)!=null?i:{}).forEach(o=>{var c;const m=o;this.display[m]?Object.keys((c=e.display[m])!=null?c:{}).forEach(l=>{const h=l;this.display[m][h]||(this.display[m][h]=e.display[m][h])}):this.display[m]=e.display[m]}),this.guiLight||(this.guiLight=e.guiLight),e.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(T){return J=>new ot(void 0,{0:T.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())}n.chestRenderer=t;function e(T){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(T,u.Cull.none())}n.decoratedPotRenderer=e;function r(T){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(T,u.Cull.none())}n.shieldRenderer=r;function i(T,J){return $=>new ot(void 0,{0:T.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($,u.Cull.none())}n.headRenderer=i;function s(T=N.create("enderdragon/dragon")){return J=>{const $=rt();return W($,$,[8,8,8]),Lt($,$,[.75,.75,.75]),_t($,$,Math.PI),W($,$,[-8,-11.2,-8]),new ot(void 0,{0:T.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($)}}n.dragonHeadRenderer=s;function a(T=N.create("piglin/piglin")){return J=>new ot(void 0,{0:T.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())}n.piglinHeadRenderer=a;function o(T){return J=>new ot(void 0,{0:T.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())}n.signRenderer=o;function m(T){return J=>new ot(void 0,{0:T.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())}n.wallSignRenderer=m;function c(T){return(J,$)=>J?new ot(void 0,{0:T.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($,u.Cull.none()):new ot(void 0,{0:T.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($,u.Cull.none())}n.hangingSignRenderer=c;function l(T){return J=>new ot(void 0,{0:`entity/signs/hanging/${T}`},[{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())}n.wallHangingSignRenderer=l;function h(T){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(T,u.Cull.none())}n.conduitRenderer=h;function d(T){return J=>new ot(void 0,{0:T.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())}n.shulkerBoxRenderer=d;function f(T){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())}n.bannerRenderer=f;function w(T){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())}n.wallBannerRenderer=w;function v(T){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(T,u.Cull.none())}n.bellRenderer=v;function g(T){return(J,$)=>J==="foot"?new ot(void 0,{0:T.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($,u.Cull.none()):new ot(void 0,{0:T.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($,u.Cull.none())}n.bedRenderer=g;function p(T,J,$=""){var G;return(G=T.getProperty(J))!=null?G:$}function S(T,J,$="0"){var G;return parseInt((G=T.getProperty(J))!=null?G:$)}const E=new Map(Object.entries({"minecraft:chest":n.chestRenderer(N.create("normal")),"minecraft:ender_chest":n.chestRenderer(N.create("ender")),"minecraft:trapped_chest":n.chestRenderer(N.create("trapped"))})),y=new Map(Object.entries({"minecraft:skeleton_skull":n.headRenderer(N.create("skeleton/skeleton"),2),"minecraft:wither_skeleton_skull":n.headRenderer(N.create("skeleton/wither_skeleton"),2),"minecraft:zombie_head":n.headRenderer(N.create("zombie/zombie"),1),"minecraft:creeper_head":n.headRenderer(N.create("creeper/creeper"),2),"minecraft:dragon_head":n.dragonHeadRenderer(),"minecraft:piglin_head":n.piglinHeadRenderer(),"minecraft:player_head":n.headRenderer(N.create("player/wide/steve"),1)})),k=["oak","spruce","birch","jungle","acacia","dark_oak","mangrove","cherry","bamboo","crimson","warped"],x=new Map(k.map(T=>[`minecraft:${T}_sign`,n.signRenderer(N.create(T))])),I=new Map(k.map(T=>[`minecraft:${T}_wall_sign`,n.wallSignRenderer(N.create(T))])),R=new Map(k.map(T=>[`minecraft:${T}_hanging_sign`,n.hangingSignRenderer(N.create(T))])),B=new Map(k.map(T=>[`minecraft:${T}_wall_hanging_sign`,n.wallHangingSignRenderer(T)])),A=["white","orange","magenta","light_blue","yellow","lime","pink","gray","light_gray","cyan","purple","blue","brown","green","red","black"],C=new Map(A.map(T=>[`minecraft:${T}_shulker_box`,n.shulkerBoxRenderer(N.create(`shulker_${T}`))])),P=new Map(A.map(T=>[`minecraft:${T}_bed`,n.bedRenderer(N.create(T))])),F=new Map(A.map(T=>[`minecraft:${T}_banner`,n.bannerRenderer(T)])),U=new Map(A.map(T=>[`minecraft:${T}_wall_banner`,n.wallBannerRenderer(T)]));function j(T,J,$){if(T.is("water"))return ti("water",S(T,"level"),J,$,0);if(T.is("lava"))return ti("lava",S(T,"level"),J,$);const G=new it,M=E.get(T.getName().toString());if(M!==void 0){const H=p(T,"facing","south"),O=rt();W(O,O,[8,8,8]),_t(O,O,H==="west"?Math.PI/2:H==="south"?Math.PI:H==="east"?Math.PI*3/2:0),W(O,O,[-8,-8,-8]),G.merge(M(J).transform(O))}T.is("decorated_pot")&&G.merge(e(J));const b=y.get(T.getName().toString());if(b!==void 0){const H=S(T,"rotation")/16*Math.PI*2,O=rt();W(O,O,[8,8,8]),_t(O,O,H),W(O,O,[-8,-8,-8]),G.merge(b(J).transform(O))}const L=x.get(T.getName().toString());if(L!==void 0){const H=S(T,"rotation")/16*Math.PI*2,O=rt();W(O,O,[8,8,8]),_t(O,O,H),Lt(O,O,[2/3,2/3,2/3]),W(O,O,[-8,-8,-8]),G.merge(L(J).transform(O))}const z=I.get(T.getName().toString());if(z!==void 0){const H=p(T,"facing","south"),O=rt();W(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]),W(O,O,[-8,-8,-8]),G.merge(z(J).transform(O))}const Z=R.get(T.getName().toString());if(Z!==void 0){const H=p(T,"attached","false")==="true",O=S(T,"rotation")/16*Math.PI*2,ct=rt();W(ct,ct,[8,8,8]),_t(ct,ct,O),Lt(ct,ct,[2/3,2/3,2/3]),W(ct,ct,[-8,-8,-8]),G.merge(Z(H,J).transform(ct))}const Q=B.get(T.getName().toString());if(Q!==void 0){const H=p(T,"facing","south"),O=rt();W(O,O,[8,8,8]),_t(O,O,H==="west"?Math.PI/2:H==="south"?Math.PI:H==="east"?Math.PI*3/2:0),W(O,O,[-8,-8,-8]),G.merge(Q(J).transform(O))}T.is("conduit")&&G.merge(h(J));const It=C.get(T.getName().toString());if(It!==void 0){const H=p(T,"facing","up"),O=rt();W(O,O,[8,8,8]),H==="down"?Mn(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),Mn(O,O,Math.PI/2)),W(O,O,[-8,-8,-8]),G.merge(It(J).transform(O))}if(T.is("bell")){const H=rt();W(H,H,[8,8,8]),Lt(H,H,[1,-1,-1]),W(H,H,[-8,-8,-8]),G.merge(v(J).transform(H))}const kt=P.get(T.getName().toString());if(kt!==void 0){const H=p(T,"part","head"),O=p(T,"facing","south"),ct=rt();W(ct,ct,[8,8,8]),_t(ct,ct,O==="east"?Math.PI/2:O==="north"?Math.PI:O==="west"?Math.PI*3/2:0),W(ct,ct,[-8,-8,-8]),G.merge(kt(H,J).transform(ct))}const yt=F.get(T.getName().toString());if(yt!==void 0){const H=S(T,"rotation")/16*Math.PI*2,O=rt();W(O,O,[8,24,8]),_t(O,O,H),Lt(O,O,[2/3,2/3,2/3]),W(O,O,[-8,-24,-8]),G.merge(yt(J).transform(O))}const ut=U.get(T.getName().toString());if(ut!==void 0){const H=p(T,"facing","south"),O=rt();W(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]),W(O,O,[-8,-23.2,-8]),G.merge(ut(J).transform(O))}T.isWaterlogged()&&G.merge(ti("water",0,J,$,0));const lt=rt();return Lt(lt,lt,[.0625,.0625,.0625]),G.transform(lt)}n.getBlockMesh=j})(u.SpecialRenderers||(u.SpecialRenderers={}));class $s{constructor(t,e,r,i=16){_(this,"chunks",[]);_(this,"chunkSize");this.gl=t,this.structure=e,this.resources=r,this.chunkSize=typeof i=="number"?[i,i,i]:i,this.updateStructureBuffers()}setStructure(t){this.structure=t,this.updateStructureBuffers()}updateStructureBuffers(t){var e,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=(e=this.resources.getDefaultBlockProperties(s))!=null?e:{};Object.entries(o).forEach(([l,h])=>{a[l]||(a[l]=h)});const m=[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=>Jl(l,m)))continue;const c=this.getChunk(m);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(e=>e.flatMap(r=>r.flatMap(i=>i!=null?i:[])));return t.flatMap(e=>e.mesh.isEmpty()?[]:e.mesh).concat(t.flatMap(e=>e.transparentMesh.isEmpty()?[]:e.transparentMesh))}needsCull(t,e){var s;const r=(s=this.structure.getBlock(u.BlockPos.towards(t.pos,e)))==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?!(e===u.Direction.UP&&t.state.isWaterlogged()):t.state.isWaterlogged()&&r.isWaterlogged()}finishChunkMesh(t,e){const r=rt();W(r,r,e),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 Y(e[0],e[1],e[2]))}}getChunk(t){const e=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[e]||(this.chunks[e]=[]),this.chunks[e][r]||(this.chunks[e][r]=[]),this.chunks[e][r][i]||(this.chunks[e][r][i]={mesh:new it,transparentMesh:new it}),this.chunks[e][r][i]}}class Rn{constructor(t,e,r){_(this,"gl");_(this,"program");this.gl=t,this.program=this.initShaderProgram(e,r)}getProgram(){return this.program}initShaderProgram(t,e){const r=this.loadShader(this.gl.VERTEX_SHADER,t),i=this.loadShader(this.gl.FRAGMENT_SHADER,e),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,e){const r=this.gl.createShader(t);if(this.gl.shaderSource(r,e),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 ql=` 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; } `,Wl=` 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 cr{constructor(t){_(this,"shaderProgram");_(this,"projMatrix");_(this,"activeShader");this.gl=t,this.shaderProgram=new Rn(t,ql,Wl).getProgram(),this.activeShader=this.shaderProgram,this.projMatrix=this.getPerspective(),this.initialize()}setViewport(t,e,r,i){this.gl.viewport(t,e,r,i),this.projMatrix=this.getPerspective()}getPerspective(){const t=70*Math.PI/180,e=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,r=rt();return Al(r,t,e,.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,e,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,e,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(i)}setUniform(t,e){const r=this.gl.getUniformLocation(this.activeShader,t);this.gl.uniformMatrix4fv(r,!1,e)}setTexture(t){this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,t)}createAtlasTexture(t){const e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),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),e}prepareDraw(t){this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix)}drawMesh(t,e){if(t.quadVertices()>0){if(e.pos&&this.setVertexAttr("vertPos",3,t.posBuffer),e.color&&this.setVertexAttr("vertColor",3,t.colorBuffer),e.texture&&this.setVertexAttr("texCoord",2,t.textureBuffer),e.normal&&this.setVertexAttr("normal",3,t.normalBuffer),e.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&&(e.pos&&this.setVertexAttr("vertPos",3,t.linePosBuffer),e.color&&this.setVertexAttr("vertColor",3,t.lineColorBuffer),this.gl.drawArrays(this.gl.LINES,0,t.lineVertices()))}}class lr extends cr{constructor(e,r,i,s={}){super(e);_(this,"mesh");_(this,"atlasTexture");this.item=r,this.resources=i,this.updateMesh(s),this.atlasTexture=this.createAtlasTexture(this.resources.getTextureAtlas())}setItem(e,r={}){this.item=e,this.updateMesh(r)}updateMesh(e={}){this.mesh=lr.getItemMesh(this.item,this.resources,e),this.mesh.computeNormals(),this.mesh.rebuild(this.gl,{pos:!0,color:!0,texture:!0,normal:!0})}static getItemMesh(e,r,i){var m;const s=(m=e.getComponent("item_model",r))==null?void 0:m.getAsString();if(s===void 0)return new it;const a=r.getItemModel(N.parse(s));if(!a)throw new Error(`Item model ${s} does not exist (defined by item ${e.toString()})`);return a.getMesh(e,r,i)}getPerspective(){const e=rt();return Ml(e,0,16,0,16,.1,500),e}drawItem(){const e=rt();W(e,e,[0,0,-32]),this.setShader(this.shaderProgram),this.setTexture(this.atlasTexture),this.prepareDraw(e),this.drawMesh(this.mesh,{pos:!0,color:!0,texture:!0,normal:!0})}}const Oe=[0,0,0];u.ItemTint=void 0,(n=>{function t(l){var f,w,v,g,p,S,E,y,k,x,I,R;const h=(f=u.Json.readObject(l))!=null?f:{},d=(w=u.Json.readString(h.type))==null?void 0:w.replace(/^minecraft:/,"");switch(d){case"constant":return new e((v=u.Color.fromJson(h.value))!=null?v:Oe);case"dye":return new r((g=u.Color.fromJson(h.default))!=null?g:Oe);case"grass":return new i((p=u.Json.readNumber(h.temperature))!=null?p: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 m((x=u.Json.readInt(h.index))!=null?x:0,(I=u.Color.fromJson(h.default))!=null?I:Oe);case"team":return new c((R=u.Color.fromJson(h.default))!=null?R:Oe);default:throw new Error(`Invalid item tint type ${d}`)}}n.fromJson=t;class e{constructor(h){this.value=h}getTint(h){return this.value}}n.Constant=e;class r{constructor(h){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}}n.Dye=r;class i{constructor(h,d){this.temperature=h,this.downfall=d}getTint(h){return[124/255,189/255,107/255]}}n.Grass=i;class s{constructor(h){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,g,p]=[0,0,0];for(const S of f.getItems())v+=(S.getAsNumber()&16711680)>>16,g+=(S.getAsNumber()&65280)>>8,p+=(S.getAsNumber()&255)>>0;return v/=f.length,g/=f.length,p/=f.length,[v/255,g/255,p/255]})()}}n.Firework=s;class a{constructor(h){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)}}n.Potion=a;class o{constructor(h){this.default_color=h}getTint(h){const d=h.getComponent("map_color");return d?u.Color.intToRgb(d.getAsNumber()):this.default_color}}n.MapColor=o;class m{constructor(h,d){this.index=h,this.default_color=d}getTint(h){var w;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?(w=u.Color.fromNbt(f))!=null?w:this.default_color:this.default_color}}n.CustomModelData=m;class c{constructor(h){this.default_color=h}getTint(h,d){var f;return(f=d.context_entity_team_color)!=null?f:this.default_color}}n.Team=c})(u.ItemTint||(u.ItemTint={}));var ei;(n=>{function t(f){var g,p,S,E,y,k,x,I,R,B,A,C,P;const w=(g=u.Json.readObject(f))!=null?g:{},v=(p=u.Json.readString(w.type))==null?void 0:p.replace(/^minecraft:/,"");switch(v){case"bed":return new e(N.parse((S=u.Json.readString(w.texture))!=null?S:""));case"banner":return new r((E=u.Json.readString(w.color))!=null?E:"");case"conduit":return new i;case"chest":return new s(N.parse((y=u.Json.readString(w.texture))!=null?y:""),(k=u.Json.readNumber(w.openness))!=null?k:0);case"head":return new a((x=u.Json.readString(w.kind))!=null?x:"",typeof w.texture=="string"?N.parse(w.texture):void 0,(I=u.Json.readNumber(w.animation))!=null?I:0);case"shulker_box":return new o(N.parse((R=u.Json.readString(w.texture))!=null?R:""),(B=u.Json.readNumber(w.openness))!=null?B:0,(A=u.Json.readString(w.orientation))!=null?A:"up");case"shield":return new m;case"trident":return new c;case"decorated_pot":return new l;case"standing_sign":return new h((C=u.Json.readString(w.wood_type))!=null?C:"",typeof w.texture=="string"?N.parse(w.texture):void 0);case"hanging_sign":return new d((P=u.Json.readString(w.wood_type))!=null?P:"",typeof w.texture=="string"?N.parse(w.texture):void 0);default:throw new Error(`Invalid item model type ${v}`)}}n.fromJson=t;class e{constructor(w){_(this,"renderer");this.renderer=u.SpecialRenderers.bedRenderer(w)}getMesh(w,v){const g=this.renderer("head",v),p=this.renderer("foot",v),S=rt();return W(S,S,[0,0,-16]),g.merge(p.transform(S))}}class r{constructor(w){_(this,"renderer");this.renderer=u.SpecialRenderers.bannerRenderer(w)}getMesh(w,v){return this.renderer(v)}}class i{getMesh(w,v){return u.SpecialRenderers.conduitRenderer(v)}}class s{constructor(w,v){_(this,"renderer");this.renderer=u.SpecialRenderers.chestRenderer(w)}getMesh(w,v){const g=rt();return W(g,g,[8,8,8]),_t(g,g,Math.PI),W(g,g,[-8,-8,-8]),this.renderer(v).transform(g)}}class a{constructor(w,v,g){_(this,"renderer");var p;this.renderer=((p={skeleton:()=>u.SpecialRenderers.headRenderer(v!=null?v:N.create("skeleton/skeleton"),2),wither_skeleton:()=>u.SpecialRenderers.headRenderer(v!=null?v:N.create("skeleton/wither_skeleton"),2),zombie:()=>u.SpecialRenderers.headRenderer(v!=null?v:N.create("zombie/zombie"),1),creeper:()=>u.SpecialRenderers.headRenderer(v!=null?v:N.create("creeper/creeper"),2),dragon:()=>u.SpecialRenderers.dragonHeadRenderer(v),piglin:()=>u.SpecialRenderers.piglinHeadRenderer(v),player:()=>u.SpecialRenderers.headRenderer(v!=null?v:N.create("player/wide/steve"),1)}[w])!=null?p:()=>()=>new it)()}getMesh(w,v){return this.renderer(v)}}class o{constructor(w,v,g){_(this,"renderer");this.renderer=u.SpecialRenderers.shulkerBoxRenderer(w)}getMesh(w,v){return this.renderer(v)}}class m{getMesh(w,v){const g=u.SpecialRenderers.shieldRenderer(v),p=rt();return W(p,p,[-3,1,0]),Mn(p,p,-10*Math.PI/180),_t(p,p,-10*Math.PI/180),Js(p,p,-5*Math.PI/180),g.transform(p)}}class c{getMesh(w,v){return new it}}class l{getMesh(w,v){return u.SpecialRenderers.decoratedPotRenderer(v)}}class h{constructor(w,v){_(this,"renderer");this.renderer=u.SpecialRenderers.signRenderer(v!=null?v:N.create(w))}getMesh(w,v){return this.renderer(v)}}class d{constructor(w,v){_(this,"renderer");this.renderer=u.SpecialRenderers.hangingSignRenderer(v!=null?v:N.create(w))}getMesh(w,v){return this.renderer(!1,v)}}})(ei||(ei={}));const Ys=new it;u.ItemModel=void 0,(n=>{function t(l){var f,w,v,g,p,S,E,y,k;const h=(f=u.Json.readObject(l))!=null?f:{},d=(w=u.Json.readString(h.type))==null?void 0:w.replace(/^minecraft:/,"");switch(d){case"empty":return new e;case"model":return new r(N.parse((v=u.Json.readString(h.model))!=null?v:""),(g=u.Json.readArray(h.tints,u.ItemTint.fromJson))!=null?g:[]);case"composite":return new i((p=u.Json.readArray(h.models,n.fromJson))!=null?p:[]);case"condition":return new s(s.propertyFromJson(h),n.fromJson(h.on_true),n.fromJson(h.on_false));case"select":return new a(a.propertyFromJson(h),new Map((S=u.Json.readArray(h.cases,x=>{var I;return(I=u.Json.readObject(x))!=null?I:{}}))==null?void 0:S.flatMap(x=>{var R;const I=n.fromJson(x.model);return Array.isArray(x.when)?x.when.map(B=>{var A;return[(A=u.Json.readString(B))!=null?A:"",I]}):[[(R=u.Json.readString(x.when))!=null?R:"",I]]})),h.fallback?n.fromJson(h.fallback):void 0);case"range_dispatch":return new o(o.propertyFromJson(h),(E=u.Json.readNumber(h.scale))!=null?E:1,(y=u.Json.readArray(h.entries,x=>{var R,B;const I=(R=u.Json.readObject(x))!=null?R:{};return{threshold:(B=u.Json.readNumber(I.threshold))!=null?B:0,model:n.fromJson(I.model)}}))!=null?y:[],h.fallback?n.fromJson(h.fallback):void 0);case"special":return new m(ei.fromJson(h.model),N.parse((k=u.Json.readString(h.base))!=null?k:""));case"bundle/selected_item":return new c;default:throw new Error(`Invalid item model type ${d}`)}}n.fromJson=t;class e{getMesh(h,d,f){return new it}}n.Empty=e;class r{constructor(h,d){this.modelId=h,this.tints=d}getMesh(h,d,f){var p;const w=d.getBlockModel(this.modelId);if(!w)throw new Error(`Model ${this.modelId} does not exist (trying to render ${h.toString()})`);const v=S=>Sw.merge(v.getMesh(h,d,f))),w}}n.Composite=i;class s{constructor(h,d,f){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,w,v,g,p;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,x)=>{var I;return(I=x[d])!=null?I:!1};case"view_entity":return(k,x)=>{var I;return(I=x.context_entity_is_view_entity)!=null?I:!1};case"using_item":return(k,x)=>{var I;return((I=x.use_duration)!=null?I:-1)>=0};case"bundle/has_selected_item":return(k,x)=>{var I;return((I=x["bundle/selected_item"])!=null?I:-1)>=0};case"broken":return(k,x)=>{var B,A;const I=(B=k.getComponent("damage"))==null?void 0:B.getAsNumber(),R=(A=k.getComponent("max_damage"))==null?void 0:A.getAsNumber();return I!==void 0&&R!==void 0&&I>=R-1};case"damaged":return(k,x)=>{var B,A;const I=(B=k.getComponent("damage"))==null?void 0:B.getAsNumber(),R=(A=k.getComponent("max_damage"))==null?void 0:A.getAsNumber();return I!==void 0&&R!==void 0&&I>=1};case"has_component":const S=N.parse((w=u.Json.readString(h.component))!=null?w:"");return(v=u.Json.readBoolean(h.ignore_default))!=null,(k,x)=>k.hasComponent(S);case"keybind_down":const E=(g=u.Json.readString(h.keybind))!=null?g:"";return(k,x)=>{var I,R;return(R=(I=x.keybind_down)==null?void 0:I.includes(E))!=null?R:!1};case"custom_model_data":const y=(p=u.Json.readInt(h.index))!=null?p:0;return(k,x)=>{const I=k.getComponent("custom_model_data");if(!(I!=null&&I.isCompound()))return!1;const R=I.getList("flags").getNumber(y);return R!==void 0&&R!==0};default:throw new Error(`Invalid condition property ${d}`)}}}n.Condition=s;class a{constructor(h,d,f){this.property=h,this.cases=d,this.fallback=f}getMesh(h,d,f){var v,g,p;const w=this.property(h,f);return(p=(g=(v=w!==null?this.cases.get(w):void 0)!=null?v:this.fallback)==null?void 0:g.getMesh(h,d,f))!=null?p:Ys}static propertyFromJson(h){var f,w,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,x;return(x=(k=y.context_dimension)==null?void 0:k.toString())!=null?x:null};case"charge_type":const g=N.create("firework_rocket");return(E,y)=>{const k=E.getComponent("charged_projectiles");return!(k!=null&&k.isList())||k.length===0?"none":k.filter(x=>x.isCompound()?N.parse(x.getString("id")).equals(g):!1).length>0?"rocket":"arrow"};case"trim_material":return(E,y)=>{const k=E.getComponent("trim");return k!=null&&k.isCompound()?N.parse(k.getString("material")).toString():null};case"block_state":const p=(w=u.Json.readString(h.block_state_property))!=null?w:"";return(E,y)=>{const k=E.getComponent("block_state");return k!=null&&k.isCompound()?k.getString(p):null};case"local_time":return(E,y)=>"NOT IMPLEMENTED";case"context_entity_type":return(E,y)=>{var k,x;return(x=(k=y.context_entity_type)==null?void 0:k.toString())!=null?x: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 x=k.getList("strings");return x.length<=S?null:x.getString(S)};default:throw new Error(`Invalid select property ${d}`)}}}n.Select=a;class o{constructor(h,d,f,w){_(this,"entries");this.property=h,this.scale=d,this.fallback=w,this.entries=f.sort((v,g)=>v.threshold-g.threshold)}getMesh(h,d,f){var g;const w=this.property(h,f)*this.scale;let v=this.fallback;for(const p of this.entries)if(p.threshold<=w)v=p.model;else break;return(g=v==null?void 0:v.getMesh(h,d,f))!=null?g:Ys}static propertyFromJson(h){var f,w,v,g,p,S,E;const d=(f=u.Json.readString(h.property))==null?void 0:f.replace(/^minecraft:/,"");switch(d){case"bundle/fullness":let y=function(B){const A=B.getComponent("bundle_contents");return A!=null&&A.isListOrArray()?A.map(P=>P.isCompound()?$t.fromNbt(P):void 0).reduce((P,F)=>{var T,J;if(F===void 0)return P;if(F.hasComponent("bundle_contents"))return P+y(F)+.0625;const U=F.getComponent("bees");if((U==null?void 0:U.isListOrArray())&&U.length>0)return P+1;const j=(J=(T=F.getComponent("max_stack_size"))==null?void 0:T.getAsNumber())!=null?J:1;return P+F.count/j},0):0};return(B,A)=>y(B);case"damage":{const B=(w=u.Json.readBoolean(h.normalize))!=null?w:!0;return(A,C)=>{var U,j,T,J;const P=(j=(U=A.getComponent("max_damage"))==null?void 0:U.getAsNumber())!=null?j:0,F=xt((J=(T=A.getComponent("damage"))==null?void 0:T.getAsNumber())!=null?J:0,0,P);return B?xt(F/P,0,1):xt(F,0,P)}}case"count":{const B=(v=u.Json.readBoolean(h.normalize))!=null?v:!0;return(A,C)=>{var F,U;const P=(U=(F=A.getComponent("max_stack_size"))==null?void 0:F.getAsNumber())!=null?U:1;return B?xt(A.count/P,0,1):xt(A.count,0,P)}}case"cooldown":return(B,A)=>{var F,U,j;const C=B.getComponent("use_cooldown"),P=C!=null&&C.isCompound()?N.parse((F=C.getString("cooldown_group"))!=null?F:B.id):B.id;return(j=(U=A.cooldown_percentage)==null?void 0:U[P.toString()])!=null?j:0};case"time":switch((g=u.Json.readString(h.source))!=null?g:"daytime"){case"moon_phase":return(B,A)=>{var C;return((C=A.game_time)!=null?C:0)/24e3%8/8};case"random":return(B,A)=>Math.random();default:return(B,A)=>{var U;const P=((U=A.game_time)!=null?U:0)/24e3%1-.25,F=.5-Math.cos(P*Math.PI)/2;return(P*2+F)/3}}case"compass":return(B,A)=>{var C;return(C=A.compass_angle)!=null?C:0};case"crossbow/pull":return(B,A)=>{var C;return(C=A["crossbow/pull"])!=null?C:0};case"use_duration":const x=(p=u.Json.readBoolean(h.remaining))!=null?p:!0;return(B,A)=>{var C;return A.use_duration===void 0||A.use_duration<0?0:x?Math.max(((C=A.max_use_duration)!=null?C:0)-A.use_duration,0):A.use_duration};case"use_cycle":const I=(S=u.Json.readNumber(h.period))!=null?S:1;return(B,A)=>{var C,P;return A.use_duration===void 0||A.use_duration<0?0:Math.max(((C=A.max_use_duration)!=null?C:0)-((P=A.use_duration)!=null?P:0),0)%I};case"custom_model_data":const R=(E=u.Json.readInt(h.index))!=null?E:0;return(B,A)=>{const C=B.getComponent("custom_model_data");return C!=null&&C.isCompound()?C.getList("floats").getNumber(R):0};default:throw new Error(`Invalid select property ${d}`)}}}n.RangeDispatch=o;class m{constructor(h,d){this.specialModel=h,this.base=d}getMesh(h,d,f){var g;const w=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 w.transform(v.getDisplayTransform((g=f.display_context)!=null?g:"gui")),w}}n.Special=m;class c{getMesh(h,d,f){const w=f["bundle/selected_item"];if(w===void 0||w<0)return new it;const v=h.getComponent("bundle_contents");if(!(v!=null&&v.isListOrArray()))return new it;const g=v.get(w);if(g===void 0||!g.isCompound())return new it;const p=$t.fromNbt(g);return lr.getItemMesh(p,d,{...f,"bundle/selected_item":-1,selected:!1,carried:!1,use_duration:-1})}}n.BundleSelectedItem=c})(u.ItemModel||(u.ItemModel={}));const Xl=` 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; } `,jl=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `,Kl=` 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; } `,Ql=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `;class tu extends cr{constructor(e,r,i,s){var o,m;super(e);_(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 $s(e,r,i,a),s!=null&&s.facesPerBuffer&&console.warn("[deepslate renderer warning]: facesPerBuffer option has been removed in favor of chunkSize"),this.useInvisibleBlocks=(m=s==null?void 0:s.useInvisibleBlockBuffer)!=null?m:!0,this.gridShaderProgram=new Rn(e,Kl,Ql).getProgram(),this.colorShaderProgram=new Rn(e,Xl,jl).getProgram(),this.gridMesh=this.getGridMesh(),this.outlineMesh=this.getOutlineMesh(),this.invisibleBlocksMesh=this.getInvisibleBlocksMesh(),this.atlasTexture=this.createAtlasTexture(this.resources.getTextureAtlas())}setStructure(e){this.structure=e,this.chunkBuilder.setStructure(e),this.gridMesh=this.getGridMesh(),this.invisibleBlocksMesh=this.getInvisibleBlocksMesh()}updateStructureBuffers(e){this.chunkBuilder.updateStructureBuffers(e)}getGridMesh(){const[e,r,i]=this.structure.getSize(),s=new it;s.addLine(0,0,0,e,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(e,0,0,e,r,0,a),s.addLine(0,0,i,0,r,i,a),s.addLine(e,0,i,e,r,i,a),s.addLine(0,r,0,0,r,i,a),s.addLine(e,r,0,e,r,i,a),s.addLine(0,r,0,e,r,0,a),s.addLine(0,r,i,e,r,i,a);for(let o=1;o<=e;o+=1)s.addLine(o,0,0,o,0,i,a);for(let o=1;o<=i;o+=1)s.addLine(0,0,o,e,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 e=new it;if(!this.useInvisibleBlocks)return e;const r=this.structure.getSize();for(let i=0;i{this.drawMesh(r,{pos:!0,color:!0,texture:!0,normal:!0})})}drawColoredStructure(e){this.setShader(this.colorShaderProgram),this.prepareDraw(e),this.chunkBuilder.getMeshes().forEach(r=>{this.drawMesh(r,{pos:!0,color:!0,normal:!0,blockPos:!0})})}drawOutline(e,r){this.setShader(this.gridShaderProgram);const i=rt();_l(i,e),W(i,i,r),this.prepareDraw(i),this.drawMesh(this.outlineMesh,{pos:!0,color:!0})}}class Nn{constructor(t,e){_(this,"part");if(this.img=t,this.idMap=e,!$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 e;return(e=this.idMap[t.toString()])!=null?e:[0,0,this.part,this.part]}static async fromBlobs(t){const e=Math.sqrt(Object.keys(t).length+1),r=Ps(e),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 m={};let c=1;return await Promise.all(Object.keys(t).map(async l=>{const h=c%r,d=Math.floor(c/r);c+=1,m[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),m)}static empty(){const t=document.createElement("canvas");t.width=16,t.height=16;const e=t.getContext("2d");return Nn.drawInvalidTexture(e),new Nn(e.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 eu=` 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; } `,nu=` precision highp float; varying highp vec3 vColor; void main(void) { gl_FragColor = vec4(vColor, 1.0); } `;class ru extends cr{constructor(e){super(e);_(this,"voxelShaderProgram");_(this,"voxels",[]);_(this,"quads",[]);_(this,"meshes",[]);this.voxelShaderProgram=new Rn(e,eu,nu).getProgram()}setVoxels(e){this.voxels=e,this.quads=this.getQuads(),this.meshes=this.getMeshes()}getQuads(){var i,s,a,o,m,c,l,h,d,f,w,v;const e=new Map;for(const g of this.voxels)gr(e,g.x,new Map,p=>{gr(p,g.y,new Set,S=>{S.add(g.z)})});const r=[];for(const g of this.voxels)(s=(i=e.get(g.x+1))==null?void 0:i.get(g.y))!=null&&s.has(g.z)||r.push(Yt.fromPoints(new Y(g.x+1,g.y,g.z),new Y(g.x+1,g.y+1,g.z),new Y(g.x+1,g.y+1,g.z+1),new Y(g.x+1,g.y,g.z+1)).setColor(g.color)),(o=(a=e.get(g.x-1))==null?void 0:a.get(g.y))!=null&&o.has(g.z)||r.push(Yt.fromPoints(new Y(g.x,g.y,g.z+1),new Y(g.x,g.y+1,g.z+1),new Y(g.x,g.y+1,g.z),new Y(g.x,g.y,g.z)).setColor(g.color)),(c=(m=e.get(g.x))==null?void 0:m.get(g.y+1))!=null&&c.has(g.z)||r.push(Yt.fromPoints(new Y(g.x,g.y+1,g.z+1),new Y(g.x+1,g.y+1,g.z+1),new Y(g.x+1,g.y+1,g.z),new Y(g.x,g.y+1,g.z)).setColor(g.color)),(h=(l=e.get(g.x))==null?void 0:l.get(g.y-1))!=null&&h.has(g.z)||r.push(Yt.fromPoints(new Y(g.x,g.y,g.z),new Y(g.x+1,g.y,g.z),new Y(g.x+1,g.y,g.z+1),new Y(g.x,g.y,g.z+1)).setColor(g.color)),(f=(d=e.get(g.x))==null?void 0:d.get(g.y))!=null&&f.has(g.z+1)||r.push(Yt.fromPoints(new Y(g.x,g.y,g.z+1),new Y(g.x+1,g.y,g.z+1),new Y(g.x+1,g.y+1,g.z+1),new Y(g.x,g.y+1,g.z+1)).setColor(g.color)),(v=(w=e.get(g.x))==null?void 0:w.get(g.y))!=null&&v.has(g.z-1)||r.push(Yt.fromPoints(new Y(g.x,g.y+1,g.z),new Y(g.x+1,g.y+1,g.z),new Y(g.x+1,g.y,g.z),new Y(g.x,g.y,g.z)).setColor(g.color));return console.debug(`Converted ${this.voxels.length} voxels into ${r.length} quads!`),r}getMeshes(){const e=[];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&&(e.push(r),r=new it)}r.isEmpty()||e.push(r);for(const i of e)i.rebuild(this.gl,{pos:!0,color:!0});return e}draw(e){if(console.debug(`Drawing ${this.meshes.length} meshes...`),this.setShader(this.voxelShaderProgram),this.prepareDraw(e),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,(n=>{const t=o=>new q.HolderHolder(u.Holder.parser(u.WorldgenRegistries.DENSITY_FUNCTION,q.fromJson)(o));function e(o){var c;const m=(c=u.Json.readObject(o))!=null?c:{};return{barrier:t(m.barrier),fluidLevelFloodedness:t(m.fluid_level_floodedness),fluidLevelSpread:t(m.fluid_level_spread),lava:t(m.lava),temperature:t(m.temperature),vegetation:t(m.vegetation),continents:t(m.continents),erosion:t(m.erosion),depth:t(m.depth),ridges:t(m.ridges),initialDensityWithoutJaggedness:t(m.initial_density_without_jaggedness),finalDensity:t(m.final_density),veinToggle:t(m.vein_toggle),veinRidged:t(m.vein_ridged),veinGap:t(m.vein_gap)}}n.fromJson=e;function r(o){return{barrier:q.Constant.ZERO,fluidLevelFloodedness:q.Constant.ZERO,fluidLevelSpread:q.Constant.ZERO,lava:q.Constant.ZERO,temperature:q.Constant.ZERO,vegetation:q.Constant.ZERO,continents:q.Constant.ZERO,erosion:q.Constant.ZERO,depth:q.Constant.ZERO,ridges:q.Constant.ZERO,initialDensityWithoutJaggedness:q.Constant.ZERO,finalDensity:q.Constant.ZERO,veinToggle:q.Constant.ZERO,veinRidged:q.Constant.ZERO,veinGap:q.Constant.ZERO,...o}}n.create=r;function i(o,m){return{barrier:o.barrier.mapAll(m),fluidLevelFloodedness:o.fluidLevelFloodedness.mapAll(m),fluidLevelSpread:o.fluidLevelSpread.mapAll(m),lava:o.lava.mapAll(m),temperature:o.temperature.mapAll(m),vegetation:o.vegetation.mapAll(m),continents:o.continents.mapAll(m),erosion:o.erosion.mapAll(m),depth:o.depth.mapAll(m),ridges:o.ridges.mapAll(m),initialDensityWithoutJaggedness:o.initialDensityWithoutJaggedness.mapAll(m),finalDensity:o.finalDensity.mapAll(m),veinToggle:o.veinToggle.mapAll(m),veinRidged:o.veinRidged.mapAll(m),veinGap:o.veinGap.mapAll(m)}}n.mapAll=i;const s=new Map;function a(o,m){var f;const c=(f=m.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),m.value());return s.set(c,[l[0],l[1],d]),d}n.instantiate=a})(u.NoiseRouter||(u.NoiseRouter={})),u.NoiseSettings=void 0,(n=>{function t(o){var c,l,h,d,f;const m=(c=u.Json.readObject(o))!=null?c:{};return{minY:(l=u.Json.readInt(m.min_y))!=null?l:0,height:(h=u.Json.readInt(m.height))!=null?h:256,xzSize:(d=u.Json.readInt(m.size_horizontal))!=null?d:1,ySize:(f=u.Json.readInt(m.size_vertical))!=null?f:1}}n.fromJson=t;function e(o){return{minY:0,height:256,xzSize:1,ySize:1,...o}}n.create=e;function r(o){return o.ySize<<2}n.cellHeight=r;function i(o){return o.xzSize<<2}n.cellWidth=i;function s(o){return o.height/r(o)}n.cellCountY=s;function a(o){return Math.floor(o.minY/r(o))}n.minCellY=a})(u.NoiseSettings||(u.NoiseSettings={})),u.NoiseSlideSettings=void 0,(n=>{function t(r){var s,a,o,m;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:(m=u.Json.readInt(i.offset))!=null?m:0}}n.fromJson=t;function e(r,i,s){if(r.size<=0)return i;const a=(s-r.offset)/r.size;return Qn(r.target,i,a)}n.apply=e})(u.NoiseSlideSettings||(u.NoiseSlideSettings={})),u.VerticalAnchor=void 0,(n=>{function t(s){var o,m,c,l;const a=(o=u.Json.readObject(s))!=null?o:{};return a.absolute!==void 0?e((m=u.Json.readNumber(a.absolute))!=null?m: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}n.fromJson=t;function e(s){return()=>s}n.absolute=e;function r(s){return a=>a.minY+s}n.aboveBottom=r;function i(s){return a=>a.minY+a.height-1-s}n.belowTop=i})(u.VerticalAnchor||(u.VerticalAnchor={}));class qs{constructor(t,e,r){_(this,"surfaceNoise");_(this,"surfaceSecondaryNoise");_(this,"random");_(this,"positionalRandoms");this.rule=t,this.defaultBlock=e,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,e,r,i){const s=u.ChunkPos.minBlockX(t.pos),a=u.ChunkPos.minBlockZ(t.pos),o=new Ws(this,t,e,r,i),m=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,w=Number.MIN_SAFE_INTEGER,v=Number.MAX_SAFE_INTEGER;for(let g=t.maxY;g>=t.minY;g-=1){const p=u.BlockPos.create(l,g,d),S=t.getBlockState(p);if(S.equals(X.AIR)){f=0,w=Number.MIN_SAFE_INTEGER;continue}if(S.isFluid()){w===Number.MIN_SAFE_INTEGER&&(w=g+1);continue}if(v>=g){v=Number.MIN_SAFE_INTEGER;for(let k=g-1;k>=t.minY;k-=1){const x=t.getBlockState(u.BlockPos.create(l,k,d));if(x.equals(X.AIR)||x.isFluid()){v=k+1;break}}}f+=1;const E=g-v+1;if(!S.equals(this.defaultBlock))continue;o.updateY(f,E,w,g);const y=m(l,g,d);y&&t.setBlockState(p,y)}}}}getSurfaceDepth(t,e){const r=this.surfaceNoise.sample(t,0,e),i=this.random.at(t,0,e).nextDouble()*.25;return r*2.75+3+i}getSurfaceSecondary(t,e){return this.surfaceSecondaryNoise.sample(t,0,e)}getRandom(t){return Ee(this.positionalRandoms,t,()=>this.random.fromHashOf(t))}}class Ws{constructor(t,e,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=e,this.noiseChunk=r,this.context=i,this.getBiome=s}updateXZ(t,e){this.blockX=t,this.blockZ=e,this.surfaceDepth=this.system.getSurfaceDepth(t,e),this.surfaceSecondary=rn(()=>this.system.getSurfaceSecondary(t,e)),this.minSurfaceLevel=rn(()=>this.calculateMinSurfaceLevel(t,e))}updateY(t,e,r,i){this.blockY=i,this.stoneDepthAbove=t,this.stoneDepthBelow=e,this.waterHeight=r,this.biome=rn(()=>this.getBiome(u.BlockPos.create(this.blockX,this.blockY,this.blockZ)))}calculateMinSurfaceLevel(t,e){const r=t>>4,i=e>>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),m=this.noiseChunk.getPreliminarySurfaceLevel(r+1<<4,i+1<<4);return Math.floor(Kn((t&15)/16,(e&15)/16,s,a,o,m))+this.surfaceDepth-8}}u.SurfaceRule=void 0,(n=>{n.NOOP=()=>()=>{};function t(s){var m,c,l;const a=(m=u.Json.readObject(s))!=null?m:{};switch((c=u.Json.readString(a.type))==null?void 0:c.replace(/^minecraft:/,"")){case"block":return e(X.fromJson(a.result_state));case"sequence":return r((l=u.Json.readArray(a.sequence,n.fromJson))!=null?l:[]);case"condition":return i(u.SurfaceCondition.fromJson(a.if_true),n.fromJson(a.then_run))}return n.NOOP}n.fromJson=t;function e(s){return()=>()=>s}n.block=e;function r(s){return a=>{const o=s.map(m=>m(a));return(m,c,l)=>{for(const h of o){const d=h(m,c,l);if(d)return d}}}}n.sequence=r;function i(s,a){return o=>(m,c,l)=>{if(s(o))return a(o)(m,c,l)}}n.condition=i})(u.SurfaceRule||(u.SurfaceRule={})),u.SurfaceCondition=void 0,(n=>{n.FALSE=()=>!1,n.TRUE=()=>!0;function t(c){var d,f,w,v,g,p,S,E,y,k,x,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 e();case"biome":return r((w=u.Json.readArray(l.biome_is,R=>{var B;return(B=u.Json.readString(R))!=null?B:""}))!=null?w:[]);case"not":return i(n.fromJson(l.invert));case"stone_depth":return s((v=u.Json.readInt(l.offset))!=null?v:0,(g=u.Json.readBoolean(l.add_surface_depth))!=null?g:!1,(p=u.Json.readInt(l.secondary_depth_range))!=null?p: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 m(u.VerticalAnchor.fromJson(l.anchor),(x=u.Json.readInt(l.surface_depth_multiplier))!=null?x:0,(I=u.Json.readBoolean(l.add_surface_depth))!=null?I:!1)}return n.FALSE}n.fromJson=t;function e(){return c=>c.blockY>=c.minSurfaceLevel()}n.abovePreliminarySurface=e;function r(c){const l=new Set(c);return h=>l.has(h.biome())}n.biome=r;function i(c){return l=>!c(l)}n.not=i;function s(c,l,h,d){return f=>{const w=d?f.stoneDepthBelow:f.stoneDepthAbove,v=l?f.surfaceDepth:0,g=h===0?0:An(f.surfaceSecondary(),-1,1,0,h);return w<=1+c+v+g}}n.stoneDepth=s;function a(c,l,h){return d=>{const f=l(d.context),w=h(d.context);if(d.blockY<=f)return!0;if(d.blockY>=w)return!1;const v=d.system.getRandom(c),g=An(d.blockY,f,w,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}}n.water=o;function m(c,l,h){return d=>{const f=h?d.stoneDepthAbove:0;return d.blockY+f>=c(d.context)+d.surfaceDepth*l}}n.yAbove=m})(u.SurfaceCondition||(u.SurfaceCondition={})),u.NoiseGeneratorSettings=void 0,(n=>{function t(r){var s,a,o,m,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:X.fromJson(i.default_block),defaultFluid:X.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:(m=u.Json.readBoolean(i.aquifers_enabled))!=null?m:!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}}n.fromJson=t;function e(r){return{surfaceRule:u.SurfaceRule.NOOP,noise:u.NoiseSettings.create({}),defaultBlock:X.STONE,defaultFluid:X.WATER,noiseRouter:u.NoiseRouter.create({}),seaLevel:0,disableMobGeneration:!1,aquifersEnabled:!1,oreVeinsEnabled:!1,legacyRandomSource:!1,...r}}n.create=e})(u.NoiseGeneratorSettings||(u.NoiseGeneratorSettings={})),u.WorldgenRegistries=void 0,(n=>{n.NOISE=Mt.createAndRegister("worldgen/noise",u.NoiseParameters.fromJson),n.DENSITY_FUNCTION=Mt.createAndRegister("worldgen/density_function",e=>q.fromJson(e)),n.NOISE_SETTINGS=Mt.createAndRegister("worldgen/noise_settings",u.NoiseGeneratorSettings.fromJson),n.BIOME=Mt.createAndRegister("worldgen/biome"),n.SURFACE_NOISE=t("surface",-6,[1,1,1]),n.SURFACE_SECONDARY_NOISE=t("surface_secondary",-6,[1,1,0,1]);function t(e,r,i){return n.NOISE.register(N.create(e),u.NoiseParameters.create(r,i),!0)}})(u.WorldgenRegistries||(u.WorldgenRegistries={}));class q{minValue(){return-this.maxValue()}mapAll(t){return t.map(this)}}(n=>{function t(G,M,b){return{x:G,y:M,z:b}}n.context=t;class e extends n{constructor(M){super(),this.input=M}compute(M){return this.transform(M,this.input.compute(M))}}const r=u.Holder.parser(u.WorldgenRegistries.NOISE,u.NoiseParameters.fromJson);function i(G,M=i){var z,Z,Q,It,kt,yt,ut,lt,H,O,ct,nn,Ln,Pn,ri,ii,si,Ks,Qs,ta;if(typeof G=="string")return new a(u.Holder.reference(u.WorldgenRegistries.DENSITY_FUNCTION,N.parse(G)));if(typeof G=="number")return new s(G);const b=(z=u.Json.readObject(G))!=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 m((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(M(b.argument));case"interpolated":return new w(M(b.argument));case"cache_2d":return new d(M(b.argument));case"cache_once":return new f(M(b.argument));case"cache_all_in_cell":return new h(M(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 g;case"weird_scaled_sampler":return new S(M(b.input),u.Json.readEnum(b.rarity_value_mapper,p),r(b.noise));case"shifted_noise":return new E(M(b.shift_x),M(b.shift_y),M(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(M(b.input),(nn=u.Json.readNumber(b.min_inclusive))!=null?nn:0,(Ln=u.Json.readNumber(b.max_exclusive))!=null?Ln:1,M(b.when_in_range),M(b.when_out_of_range));case"shift_a":return new x(r(b.argument));case"shift_b":return new I(r(b.argument));case"shift":return new R(r(b.argument));case"blend_density":return new B(M(b.argument));case"clamp":return new A(M(b.input),(Pn=u.Json.readNumber(b.min))!=null?Pn:0,(ri=u.Json.readNumber(b.max))!=null?ri:1);case"abs":case"square":case"cube":case"half_negative":case"quarter_negative":case"squeeze":return new C(L,M(b.argument));case"add":case"mul":case"min":case"max":return new F(u.Json.readEnum(L,P),M(b.argument1),M(b.argument2));case"spline":return new U(u.CubicSpline.fromJson(b.spline,M));case"constant":return new s((ii=u.Json.readNumber(b.argument))!=null?ii:0);case"y_clamped_gradient":return new j((si=u.Json.readInt(b.from_y))!=null?si:-4064,(Ks=u.Json.readInt(b.to_y))!=null?Ks:4062,(Qs=u.Json.readNumber(b.from_value))!=null?Qs:-4064,(ta=u.Json.readNumber(b.to_value))!=null?ta:4062)}return s.ZERO}n.fromJson=i;const T=class extends n{constructor(M){super(),this.value=M}compute(){return this.value}minValue(){return this.value}maxValue(){return this.value}};let s=T;_(s,"ZERO",new T(0)),_(s,"ONE",new T(1)),n.Constant=s;class a extends n{constructor(M){super(),this.holder=M}compute(M){return this.holder.value().compute(M)}minValue(){return this.holder.value().minValue()}maxValue(){return this.holder.value().maxValue()}}n.HolderHolder=a;class o extends n.Constant{constructor(M,b,L){super(M),this.min=b,this.max=L}minValue(){return this.min}maxValue(){return this.max}}n.ConstantMinMax=o;class m extends n{constructor(M,b,L,z,Z,Q){super(),this.xzScale=M,this.yScale=b,this.xzFactor=L,this.yFactor=z,this.smearScaleMultiplier=Z,this.blendedNoise=Q}compute(M){var b,L;return(L=(b=this.blendedNoise)==null?void 0:b.sample(M.x,M.y,M.z))!=null?L:0}maxValue(){var M,b;return(b=(M=this.blendedNoise)==null?void 0:M.maxValue)!=null?b:0}}n.OldBlendedNoise=m;class c extends n{constructor(M){super(),this.wrapped=M}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(n.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)))}}n.FlatCache=l;class h extends c{constructor(M){super(M)}compute(M){return this.wrapped.compute(M)}mapAll(M){return M.map(new h(this.wrapped.mapAll(M)))}}n.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)))}}n.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)))}}n.CacheOnce=f;class w 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 Ts(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(n.context(b,L,z)))}mapAll(b){return b.map(new w(this.wrapped.mapAll(b)))}withCellSize(b,L){return new w(this.wrapped,b,L)}}n.Interpolated=w;class v extends n{constructor(M,b,L,z){super(),this.xzScale=M,this.yScale=b,this.noiseData=L,this.noise=z}compute(M){var b,L;return(L=(b=this.noise)==null?void 0:b.sample(M.x*this.xzScale,M.y*this.yScale,M.z*this.xzScale))!=null?L:0}maxValue(){var M,b;return(b=(M=this.noise)==null?void 0:M.maxValue)!=null?b:2}}n.Noise=v;class g extends n{constructor(b){super();_(this,"islandNoise");const L=new at(b!=null?b:BigInt(0));L.consume(17292),this.islandNoise=new wt(L)}getHeightValue(b,L){const z=Math.floor(b/2),Z=Math.floor(L/2),Q=b%2,It=L%2;let kt=xt(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=xt(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}}n.EndIslands=g;const p=["type_1","type_2"],J=class extends e{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}),n.WeirdScaledSampler=S;class E extends v{constructor(M,b,L,z,Z,Q,It){super(z,Z,Q,It),this.shiftX=M,this.shiftY=b,this.shiftZ=L}compute(M){var Z,Q;const b=M.x*this.xzScale+this.shiftX.compute(M),L=M.y*this.yScale+this.shiftY.compute(M),z=M.z*this.xzScale+this.shiftZ.compute(M);return(Q=(Z=this.noise)==null?void 0:Z.sample(b,L,z))!=null?Q:0}mapAll(M){return M.map(new E(this.shiftX.mapAll(M),this.shiftY.mapAll(M),this.shiftZ.mapAll(M),this.xzScale,this.yScale,this.noiseData,this.noise))}}n.ShiftedNoise=E;class y extends n{constructor(M,b,L,z,Z){super(),this.input=M,this.minInclusive=b,this.maxExclusive=L,this.whenInRange=z,this.whenOutOfRange=Z}compute(M){const b=this.input.compute(M);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=xt(b,-1,1);return L/2-L*L*L/24}}),n.Mapped=C;const P=["add","mul","min","max"];class F extends n{constructor(M,b,L,z,Z){super(),this.type=M,this.argument1=b,this.argument2=L,this.min=z,this.max=Z}compute(M){const b=this.argument1.compute(M);switch(this.type){case"add":return b+this.argument2.compute(M);case"mul":return b===0?0:b*this.argument2.compute(M);case"min":return bthis.argument2.maxValue()?b:Math.max(b,this.argument2.compute(M))}}mapAll(M){return M.map(new F(this.type,this.argument1.mapAll(M),this.argument2.mapAll(M)))}minValue(){var M;return(M=this.min)!=null?M:-1/0}maxValue(){var M;return(M=this.max)!=null?M:1/0}withMinMax(){const M=this.argument1.minValue(),b=this.argument2.minValue(),L=this.argument1.maxValue(),z=this.argument2.maxValue();(this.type==="min"||this.type==="max")&&(M>=z||b>=L)&&console.warn(`Creating a ${this.type} function between two non-overlapping inputs`);let Z,Q;switch(this.type){case"add":Z=M+b,Q=L+z;break;case"mul":Z=M>0&&b>0?M*b||0:L<0&&z<0?L*z||0:Math.min(M*z||0,b*L||0),Q=M>0&&b>0?L*z||0:L<0&&z<0?M*b||0:Math.max(M*b||0,L*z||0);break;case"min":Z=Math.min(M,b),Q=Math.min(L,z);break;case"max":Z=Math.max(M,b),Q=Math.max(L,z);break}return new F(this.type,this.argument1,this.argument2,Z,Q)}}n.Ap2=F;class U extends n{constructor(M){super(),this.spline=M}compute(M){return this.spline.compute(M)}mapAll(M){const b=this.spline.mapAll(L=>L instanceof n?L.mapAll(M):L);return b.calculateMinMax(),M.map(new U(b))}minValue(){return this.spline.min()}maxValue(){return this.spline.max()}}n.Spline=U;class j extends n{constructor(M,b,L,z){super(),this.fromY=M,this.toY=b,this.fromValue=L,this.toValue=z}compute(M){return Gr(M.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)}}n.YClampedGradient=j})(q||(q={}));class Cn{constructor(t,e){this.level=t,this.type=e}at(t){return t{function t(e){return{compute({x:r,y:i,z:s},a){if(!(a>0))return e(r,i,s).at(i)}}}n.createDisabled=t})(u.Aquifer||(u.Aquifer={}));const Jt=class{constructor(t,e,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(e))-1,this.gridSizeX=this.gridX(u.ChunkPos.maxBlockX(e))+1-this.minGridX+1,this.minGridY=this.gridY(s)-1,this.minGridZ=this.gridZ(u.ChunkPos.minBlockZ(e))-1,this.gridSizeZ=this.gridZ(u.ChunkPos.maxBlockZ(e))+1-this.minGridZ+1;const m=this.gridY(s+a)+1-this.minGridY+1;this.gridSize=this.gridSizeX*m*this.gridSizeZ,this.aquiferCache=Array(this.gridSize).fill(void 0),this.aquiferLocationCache=Array(this.gridSize).fill(u.BlockPos.ZERO)}compute({x:t,y:e,z:r},i){if(i<=0){if(this.globalFluidPicker(t,e,r).at(e).is(X.LAVA))return X.LAVA;{const s=this.gridX(t-5),a=this.gridY(e+1),o=this.gridZ(r-5);let m=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 x=-1;x<=1;x+=1)for(let I=0;I<=1;I+=1){const R=this.getLocation(s+k,a+x,o+I),B=u.BlockPos.magnitude(R);m>=B?(f=d,d=h,h=R,l=c,c=m,m=B):c>=B?(f=d,d=R,l=c,c=B):l>=B&&(f=R,l=B)}const w=this.getStatus(h),v=this.getStatus(d),g=this.getStatus(f),p=Jt.similarity(m,c),S=Jt.similarity(m,l),E=Jt.similarity(c,l);let y;if(w.at(e).is(X.WATER)&&this.globalFluidPicker(t,e-1,r).at(e-1).is(X.LAVA))y=1;else if(p>-1){const k=rn(()=>this.router.barrier.compute(q.context(t,e*.5,r))),x=this.calculatePressure(e,w,v,k),I=this.calculatePressure(e,w,g,k),R=this.calculatePressure(e,v,g,k),B=Math.max(x,I*Math.max(0,S),R*Math.max(E));y=Math.max(0,2*Math.max(0,p)*B)}else y=0;if(i+y<=0)return w.at(e)}}}static similarity(t,e){return 1-Math.abs(e-t)/25}calculatePressure(t,e,r,i){const s=e.at(t),a=r.at(t);if(s.is(X.LAVA)&&a.is(X.WATER)||s.is(X.WATER)&&a.is(X.LAVA))return 1;const o=Math.abs(e.level-r.level);if(o===0)return 0;const m=(e.level+r.level)/2,c=t+.5-m,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[e,r,i]=t,s=this.getIndex(this.gridX(e),this.gridY(r),this.gridZ(i)),a=this.aquiferCache[s];if(a!==void 0)return a;const o=this.computeStatus(e,r,i);return this.aquiferCache[s]=o,o}computeStatus(t,e,r){const i=this.globalFluidPicker(t,e,r);let s=Number.MAX_SAFE_INTEGER,a=!1;for(const[w,v]of Jt.SURFACE_SAMPLING){const g=t+(v<<4),p=r+(v<<4),S=this.noiseChunk.getPreliminarySurfaceLevel(g,p);s=Math.min(s,S);const E=w===0&&v===0;if(E&&e-12>S+8)return i;if(E||e+12>S+8){const y=this.globalFluidPicker(g,S+8,p);if(!y.at(S+8).is(X.AIR)){if(E)return y;a=!0}}}const o=a?Gr(s+8-e,0,64,1,0):0,m=xt(this.router.fluidLevelFloodedness.compute(q.context(t,e*.67,r)),-1,1);if(m>An(o,1,0,-.3,.8))return i;if(m<=An(o,1,0,-.8,.4))return new Cn(Number.MIN_SAFE_INTEGER,i.type);const c=Math.floor(e/40),l=this.router.fluidLevelSpread.compute(q.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,e,r,i.type,h);return new Cn(d,f)}getFluidType(t,e,r,i,s){if(s<=-10){const a=this.router.lava.compute(q.context(Math.floor(t/64),Math.floor(e/40),Math.floor(r/64)));if(Math.abs(a)>.3)return X.LAVA}return i}getLocation(t,e,r){const i=this.getIndex(t,e,r),s=this.aquiferLocationCache[i];if(u.BlockPos.equals(s,u.BlockPos.ZERO))return s;const a=this.random.at(t,e,r),o=u.BlockPos.create(t*Jt.X_SPACING+a.nextInt(10),e*Jt.Y_SPACING+a.nextInt(9),r*Jt.Z_SPACING+a.nextInt(10));return this.aquiferLocationCache[i]=o,o}getIndex(t,e,r){const i=t-this.minGridX,s=e-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} ${e} ${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,(n=>{function t(m){var h,d,f;const c=(h=u.Json.readObject(m))!=null?h:{};switch((d=u.Json.readString(c.type))==null?void 0:d.replace(/^minecraft:/,"")){case void 0:return e(u.VerticalAnchor.fromJson(m));case"constant":return e(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,w=>{var g,p;const v=(g=u.Json.readObject(w))!=null?g:{};return{weight:(p=u.Json.readInt(v.weight))!=null?p:1,data:t(v.data)}}))!=null?f:[])}return()=>0}n.fromJson=t;function e(m){return(c,l)=>m(l)}n.constant=e;function r(m,c){return(l,h)=>{const d=m(h),f=c(h);return d>f?d:l.nextInt(f-d+1)+d}}n.uniform=r;function i(m,c,l=1){return(h,d)=>{const f=m(d),w=c(d);if(w-f-l+1<=0)return f;{const v=h.nextInt(w-f-l+1);return h.nextInt(v+l)+f}}}n.biased_to_bottom=i;function s(m,c,l=1){return(h,d)=>{const f=m(d),w=c(d);if(w-f-l+1<=0)return f;{const v=rr(h,f+l,w),g=rr(h,f,v-1);return rr(h,f,g-1+l)}}}n.very_biased_to_bottom=s;function a(m,c,l=0){return(h,d)=>{const f=m(d),w=c(d);if(f>w)return f;{const v=w-f;if(l>=v)return nr(h,f,w);{const g=(v-l)/2,p=v-g;return f+nr(h,0,p)+nr(h,0,g)}}}}n.trapezoid=a;function o(m){const c=m.reduce((l,h,d)=>l+h.weight,0);return(l,h)=>{let d=l.nextInt(c);for(const f of m)if(d-=f.weight,d<=0)return f.data(l,h);return 0}}n.weighted_list=o})(u.HeightProvider||(u.HeightProvider={})),u.Heightmap=void 0,(n=>{function t(e){if(typeof e=="string"&&(e==="WORLD_SURFACE_WG"||e==="WORLD_SURFACE"||e==="OCEAN_FLOOR_WG"||e==="OCEAN_FLOOR"||e==="MOTION_BLOCKING"||e==="MOTION_BLOCKING_NO_LEAVES"))return e}n.fromJson=t})(u.Heightmap||(u.Heightmap={}));class ni{constructor(t,e,r,i,s,a,o,m,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=e,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,e,r){return this.materialRule({x:t,y:e,z:r})}getPreliminarySurfaceLevel(t,e){return Ee(this.preliminarySurfaceLevel,u.ChunkPos.asLong(t,e),()=>{const r=t<<2,i=e<<2;for(let s=this.settings.minY+this.settings.height;s>=this.settings.minY;s-=this.cellHeight)if(this.initialDensity.compute(q.context(r,s,i))>.390625)return s;return Number.MAX_SAFE_INTEGER})}}u.MaterialRule=void 0,(n=>{function t(e){return r=>{for(const i of e){const s=i(r);if(s)return s}}}n.fromList=t})(u.MaterialRule||(u.MaterialRule={}));class Xs{constructor(t,e){_(this,"noiseChunkCache");_(this,"globalFluidPicker");this.biomeSource=t,this.settings=e,this.noiseChunkCache=new Map;const r=new Cn(-54,X.LAVA),i=new Cn(e.seaLevel,e.defaultFluid);this.globalFluidPicker=(s,a,o)=>ao.equals(X.STONE):s=o=>!o.equals(X.AIR),(a=this.iterateNoiseColumn(i,t,e,void 0,s,X.STONE))!=null?a:this.settings.noise.minY}iterateNoiseColumn(t,e,r,i,s,a){var v,g;const o=this.settings.noise.minY,m=u.NoiseSettings.cellHeight(this.settings.noise),c=Math.floor(o/m),l=Math.floor(this.settings.noise.height/m);if(l<=0)return;const h=u.NoiseSettings.cellWidth(this.settings.noise),d=Math.floor(e/h),f=Math.floor(r/h),w=new ni(1,l,c,t,d,f,this.settings.noise,this.settings.aquifersEnabled,this.globalFluidPicker);for(let p=l-1;p>=0;p-=1)for(let S=m-1;S>=0;S-=1){const E=(c+p)*m+S,y=(g=(v=w.getFinalState(e,E,r))!=null?v:a)!=null?g:this.settings.defaultBlock;if(i!==void 0&&(i[E+o]=y),s!==void 0&&s(y))return E+1}}fill(t,e,r=!1){var w;const i=Math.max(e.minY,this.settings.noise.minY),s=Math.min(e.maxY,this.settings.noise.minY+this.settings.noise.height),a=u.NoiseSettings.cellWidth(this.settings.noise),o=u.NoiseSettings.cellHeight(this.settings.noise),m=Math.floor(16/a),c=Math.floor(i/o),l=Math.floor((s-i)/o),h=u.ChunkPos.minBlockX(e.pos),d=u.ChunkPos.minBlockZ(e.pos),f=this.getOrCreateNoiseChunk(t,e);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,x=e.getSectionIndex(y);e.getSectionIndex(p.minBlockY)!==x&&(p=e.getOrCreateSection(x));for(let I=0;Ir)}computeBiome(t,e,r,i){return this.biomeSource.getBiome(e,r,i,t.sampler)}getOrCreateNoiseChunk(t,e){return Ee(this.noiseChunkCache,u.ChunkPos.toLong(e.pos),()=>{const r=Math.max(e.minY,this.settings.noise.minY),i=Math.min(e.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),m=Math.floor(r/a),c=Math.floor((i-r)/a),l=u.ChunkPos.minBlockX(e.pos),h=u.ChunkPos.minBlockZ(e.pos);return new ni(o,c,m,t,l,h,this.settings.noise,this.settings.aquifersEnabled,this.globalFluidPicker)})}}class ur{constructor(t,e){_(this,"n");if(this.shift=t,this.biomes=e,e.length===0)throw new Error("Cannot create checkerboard biome source without biomes");this.n=e.length}getBiome(t,e,r){const i=(((t>>this.shift)+(r>>this.shift))%this.n+this.n)%this.n;return N.parse(this.biomes[i].toString())}static fromJson(t){var s,a,o;const e=(s=u.Json.readObject(t))!=null?s:{},r=(a=u.Json.readInt(e.scale))!=null?a:2;let i;return typeof e.biomes=="string"?i=[N.parse(e.biomes)]:i=(o=u.Json.readArray(e.biomes,m=>{var c;return N.parse((c=u.Json.readString(m))!=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 e=(i=u.Json.readObject(t))!=null?i:{},r=N.parse((s=u.Json.readString(e.biome))!=null?s:"plains");return new je(r)}}u.Climate=void 0,(n=>{function e(v,g,p,S,E,y){return new o(v,g,p,S,E,y)}n.target=e;function r(v,g,p,S,E,y,k){return new a(i(v),i(g),i(p),i(S),i(E),i(y),k)}n.parameters=r;function i(v,g){return typeof v=="number"?new s(v,g!=null?g:v):v}n.param=i;class s{constructor(g,p){this.min=g,this.max=p}distance(g){const p=(typeof g=="number"?g:g.min)-this.max,S=this.min-(typeof g=="number"?g:g.max);return p>0?p:Math.max(S,0)}union(g){return new s(Math.min(this.min,g.min),Math.max(this.max,g.max))}static fromJson(g){var E;if(typeof g=="number")return new s(g,g);const[p,S]=(E=u.Json.readArray(g,y=>u.Json.readNumber(y)))!=null?E:[];return new s(p!=null?p:0,S!=null?S:0)}}n.Param=s;class a{constructor(g,p,S,E,y,k,x){this.temperature=g,this.humidity=p,this.continentalness=S,this.erosion=E,this.depth=y,this.weirdness=k,this.offset=x}fittness(g){return ee(this.temperature.distance(g.temperature))+ee(this.humidity.distance(g.humidity))+ee(this.continentalness.distance(g.continentalness))+ee(this.erosion.distance(g.erosion))+ee(this.depth.distance(g.depth))+ee(this.weirdness.distance(g.weirdness))+ee(this.offset-g.offset)}space(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,new s(this.offset,this.offset)]}static fromJson(g){var S,E;const p=(S=u.Json.readObject(g))!=null?S:{};return new a(s.fromJson(p.temperature),s.fromJson(p.humidity),s.fromJson(p.continentalness),s.fromJson(p.erosion),s.fromJson(p.depth),s.fromJson(p.weirdness),(E=u.Json.readNumber(p.offset))!=null?E:0)}}n.ParamPoint=a;class o{constructor(g,p,S,E,y,k){this.temperature=g,this.humidity=p,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]}}n.TargetPoint=o;class m{constructor(g){_(this,"index");this.things=g,this.index=new l(g)}find(g){return this.index.search(g,(p,S)=>p.distance(S))}}n.Parameters=m;class c{constructor(g,p,S,E,y,k){this.temperature=g,this.humidity=p,this.continentalness=S,this.erosion=E,this.depth=y,this.weirdness=k}static fromRouter(g){return new n.Sampler(g.temperature,g.vegetation,g.continents,g.erosion,g.depth,g.ridges)}sample(g,p,S){const E=q.context(g<<2,p<<2,S<<2);return n.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))}}n.Sampler=c;const w=class{constructor(g){_(this,"root");_(this,"last_leaf",null);if(g.length===0)throw new Error("At least one point is required to build search tree");this.root=w.build(g.map(([p,S])=>new f(p,S)))}static build(g){if(g.length===1)return g[0];if(g.length<=w.CHILDREN_PER_NODE){const y=g.map(k=>{let x=0;for(let I=0;I<7;I+=1){const R=k.space[I];x+=Math.abs((R.min+R.max)/2)}return{key:x,node:k}}).sort((k,x)=>k.key-x.key).map(({node:k})=>k);return new d(y)}let p=1/0,S=-1,E=[];for(let y=0;y<7;++y){g=w.sort(g,y,!1),E=w.bucketize(g);let k=0;for(const x of E)k+=w.area(x.space);p>k&&(p=k,S=y)}return g=w.sort(g,S,!1),E=w.bucketize(g),E=w.sort(E,S,!0),new d(E.map(y=>w.build(y.children)))}static sort(g,p,S){return g.map(E=>{const y=E.space[p],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(g){const p=[];let S=[];const E=Math.pow(10,Math.floor(Math.log(g.length-.01)/Math.log(10)));for(const y of g)S.push(y),!(S.lengthnew s(1/0,-1/0));for(const S of g)p=[...Array(7)].map((E,y)=>p[y].union(S.space[y]));return p}search(g,p,S){let E=p?S(p,g):1/0,y=p;for(const k of this.children){const x=S(k,g);if(E<=x)continue;const I=k.search(g,y,S);if(I===null)continue;const R=k==I?x:S(I,g);if(R===0)return I;E<=R||(E=R,y=I)}return y}}n.RSubTree=d;class f extends h{constructor(g,p){super(g.space()),this.thing=p}search(){return this}}n.RLeaf=f})(u.Climate||(u.Climate={}));class hr{constructor(t){_(this,"parameters");this.parameters=new u.Climate.Parameters(t)}getBiome(t,e,r,i){const s=i.sample(t,e,r);return this.parameters.find(s)}static fromJson(t){var s,a;const e=(s=u.Json.readObject(t))!=null?s:{},i=((a=u.Json.readArray(e.biomes,o=>{var m;return(c=>{var l;return{biome:N.parse((l=u.Json.readString(c.biome))!=null?l:"plains"),parameters:u.Climate.ParamPoint.fromJson(c.parameters)}})((m=u.Json.readObject(o))!=null?m:{})}))!=null?a:[]).map(o=>[o.parameters,()=>o.biome]);return new hr(i)}}const ye=class{getBiome(t,e,r,i){const s=t<<2,a=e<<2,o=r<<2,m=s>>4,c=o>>4;if(m*m+c*c<=4096)return ye.END;const l=q.context((m*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",N.create("the_end")),_(_e,"HIGHLANDS",N.create("end_highlands")),_(_e,"MIDLANDS",N.create("end_midlands")),_(_e,"ISLANDS",N.create("small_end_islands")),_(_e,"BARRENS",N.create("end_barrens")),u.BiomeSource=void 0,(n=>{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(N.create("plains"))}}n.fromJson=t;function e(r,i,s,a,o,m,c,l,h=1,d=!1){if(r instanceof je)return m(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,w=a>>2,v=o>>2,g=s>>2;for(var p=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 x=-y;x<=y;x+=h){if(d&&!(Math.abs(x)===y)&&!I)continue;const R=f+x,B=w+k,A=r.getBiome(R,g,B,l);if(m(A)){if((p===void 0||c.nextInt(S+1)<=.5)&&(p={pos:u.BlockPos.create(R<<2,s,B<<2),biome:A},d))return p;S++}}}return p}n.findBiomeHorizontal=e})(u.BiomeSource||(u.BiomeSource={}));class js{constructor(t,e){_(this,"noiseCache");_(this,"randomCache");_(this,"random");_(this,"aquiferRandom");_(this,"oreRandom");_(this,"surfaceSystem");_(this,"router");_(this,"sampler");this.seed=e,this.noiseCache=new Map,this.randomCache=new Map,this.random=(t.legacyRandomSource?new at(e):nt.create(e)).forkPositional(),this.aquiferRandom=this.random.fromHashOf(N.create("aquifer").toString()).forkPositional(),this.oreRandom=this.random.fromHashOf(N.create("ore").toString()).forkPositional(),this.surfaceSystem=new qs(t.surfaceRule,t.defaultBlock,e),this.router=u.NoiseRouter.mapAll(t.noiseRouter,this.createVisitor(t.noise,t.legacyRandomSource)),this.sampler=u.Climate.Sampler.fromRouter(this.router)}createVisitor(t,e){const r=new Map,i=a=>{const o=a.key();if(o===void 0)throw new Error("Cannot create noise without key");if(e){if(o.equals(N.create("temperature")))return new ie(new at(this.seed+BigInt(0)),u.NoiseParameters.create(-7,[1,1]));if(o.equals(N.create("vegetation")))return new ie(new at(this.seed+BigInt(1)),u.NoiseParameters.create(-7,[1,1]));if(o.equals(N.create("offset")))return new ie(this.random.fromHashOf("offset"),u.NoiseParameters.create(0,[0]))}return this.getOrCreateNoise(o)},s={map:a=>{if(a instanceof q.HolderHolder){const o=a.holder.key();if(o!==void 0&&r.has(o.toString()))return r.get(o.toString());{const m=a.holder.value().mapAll(s);return o!==void 0&&r.set(o.toString(),m),m}}if(a instanceof q.Interpolated)return a.withCellSize(u.NoiseSettings.cellWidth(t),u.NoiseSettings.cellHeight(t));if(a instanceof q.ShiftedNoise)return new q.ShiftedNoise(a.shiftX,a.shiftY,a.shiftZ,a.xzScale,a.yScale,a.noiseData,i(a.noiseData));if(a instanceof q.Noise)return new q.Noise(a.xzScale,a.yScale,a.noiseData,i(a.noiseData));if(a instanceof q.ShiftNoise)return a.withNewNoise(i(a.noiseData));if(a instanceof q.WeirdScaledSampler)return new q.WeirdScaledSampler(a.input,a.rarityValueMapper,a.noiseData,i(a.noiseData));if(a instanceof q.OldBlendedNoise){const o=e?new at(this.seed+BigInt(0)):this.random.fromHashOf(N.create("terrain").toString());return new q.OldBlendedNoise(a.xzScale,a.yScale,a.xzFactor,a.yFactor,a.smearScaleMultiplier,new Zs(o,a.xzScale,a.yScale,a.xzFactor,a.yFactor,a.smearScaleMultiplier))}return a instanceof q.EndIslands?new q.EndIslands(this.seed):a instanceof q.Mapped||a instanceof q.Ap2?a.withMinMax():a}};return s}getOrCreateNoise(t){const e=Mt.REGISTRY.getOrThrow(N.create("worldgen/noise"));return Ee(this.noiseCache,t.toString(),r=>new ie(this.random.fromHashOf(r),e.getOrThrow(t)))}getOrCreateRandom(t){return Ee(this.randomCache,t.toString(),e=>this.random.fromHashOf(e).forkPositional())}}class Ft{static fromJson(t){var r,i,s,a;const e=(r=u.Json.readObject(t))!=null?r:{};switch((i=u.Json.readString(e.element_type))==null?void 0:i.replace(/^minecraft:/,"")){case"single_pool_element":case"legacy_single_pool_element":const o=N.parse((s=u.Json.readString(e.location))!=null?s:""),m={key:()=>o,value:()=>{var l;return(l=te.REGISTRY.get(o))!=null?l:te.EMPTY}};return new Ft.SinlgePoolElement(m);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}}}(n=>{class t extends n{getBoundingBox(o,m){throw new Error("Invalid call of EmptyPoolElement")}getShuffledJigsawBlocks(o,m){return[]}toString(){return"[Empty Pool Element]"}}n.EmptyPoolElement=t;class e extends n{constructor(){super();_(this,"defaultJigsawNBT");const m=new Map;m.set("name",new vt("minecraft:bottom")),m.set("final_state",new vt("minecraft:air")),m.set("pool",new vt("minecraft:empty")),m.set("target",new vt("minecraft:empty")),m.set("joint",new vt("rollable")),this.defaultJigsawNBT=new mt(m)}getBoundingBox(m,c){return[m,m]}getShuffledJigsawBlocks(m,c){return[{pos:[0,0,0],state:new X(N.create("jigsaw"),{orientation:"down_south"}),nbt:this.defaultJigsawNBT}]}toString(){return"[Feature Pool Element]"}}n.FeaturePoolElement=e;const s=class extends n{constructor(o){super(),this.template=o}getBoundingBox(o,m){const c=u.BlockPos.offset(this.template.value().getSize(),-1,-1,-1),l=o,h=u.BlockPos.add(te.transform(c,m,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,m){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)),Os(c,m),c}toString(){return`[Single Pool Element: ${this.template.key()}]`}};let r=s;_(r,"JIGSAW_ID",N.parse("jigsaw")),n.SinlgePoolElement=r;class i extends n{constructor(o){super(),this.elements=o}getBoundingBox(o,m){var c=void 0,l=void 0;for(const h of this.elements){const d=h.getBoundingBox(o,m);!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,m){return this.elements[0].getShuffledJigsawBlocks(o,m)}toString(){return`[List Pool Element: ${"; ".concat(...this.elements.map(o=>o.toString()))}]`}}n.ListPoolElement=i})(Ft||(Ft={}));const He=class{constructor(t,e){_(this,"totalWeight");this.rawTemplates=t,this.fallback=e,this.totalWeight=t.reduce((r,i)=>r+i.weight,0)}static fromJson(t){var s,a,o;const e=(s=u.Json.readObject(t))!=null?s:{},r=He.structurePoolParser((a=e.fallback)!=null?a:""),i=(o=u.Json.readArray(e.elements,m=>{var d,f;const c=(d=u.Json.readObject(m))!=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 e=t.nextInt(this.totalWeight);for(const r of this.rawTemplates)if(e-=r.weight,e<0)return r.element;return this.rawTemplates[this.rawTemplates.length-1].element}};let ze=He;_(ze,"REGISTRY",Mt.createAndRegister("worldgen/template_pool",He.fromJson)),_(ze,"structurePoolParser",u.Holder.parser(He.REGISTRY,He.fromJson));class fr{constructor(t){this.settings=t}onTopOfChunkCenter(t,e,r,i="WORLD_SURFACE_WG"){const s=(e<<4)+8,a=(r<<4)+8;return[s,t.chunkGenerator.getBaseHeight(s,a,i,t.randomState)-1,a]}getLowestY(t,e,r,i,s){return Math.min(t.chunkGenerator.getBaseHeight(e,r,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(e,r+s,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(e+i,r,"WORLD_SURFACE_WG",t.randomState)-1,t.chunkGenerator.getBaseHeight(e+i,r+s,"WORLD_SURFACE_WG",t.randomState)-1)}getLowestYIn5by5BoxOffset7Blocks(t,e,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=(e<<4)+7,m=(r<<4)+7;return u.BlockPos.create(o,this.getLowestY(t,o,m,s,a),m)}tryGenerate(t,e,r){const i=at.fromLargeFeatureSeed(r.seed,t,e),s=this.findGenerationPoint(t,e,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 m;return(m=o.key())==null?void 0:m.equals(a)})>=0?s:void 0}}(n=>{n.REGISTRY=Mt.createAndRegister("worldgen/structure",i);class t{constructor(I){this.validBiomes=I}}n.StructureSettings=t;class e{constructor(I,R,B,A){_(this,"chunkGenerator");_(this,"randomState");this.seed=I,this.biomeSource=R,this.settings=B,this.levelHeight=A,this.randomState=new js(B,I),this.chunkGenerator=new Xs(R,B)}}n.GenerationContext=e;const r=u.Holder.parser(ze.REGISTRY,ze.fromJson);function i(x){var C,P,F;const I=ve.parser(u.WorldgenRegistries.BIOME),R=(C=u.Json.readObject(x))!=null?C:{},B=I(R.biomes),A=new t(B.value());switch((P=u.Json.readString(R.type))==null?void 0:P.replace(/^minecraft:/,"")){case"buried_treasure":return new a(A);case"desert_pyramid":return new m(A);case"end_city":return new c(A);case"fortress":return new l(A);case"igloo":return new h(A);case"jigsaw":const U=u.HeightProvider.fromJson(R.start_height),j=r(R.start_pool),T=u.Json.readString(R.start_jigsaw_name),J=T?N.parse(T):void 0,$=u.Heightmap.fromJson(R.project_start_to_heightmap),G=s.DimensionPadding.fromJson(R.dimension_padding);return new s(A,j,U,$,J,G);case"jungle_temple":return new d(A);case"mineshaft":const M=u.Json.readString(R.mineshaft_type)==="mesa"?"mesa":"normal";return new f(A,M);case"nether_fossil":return new l(A);case"ocean_monument":return new v(A);case"ocean_ruin":return new g(A);case"ruined_portal":return new p(A);case"shipwreck":const b=(F=u.Json.readBoolean(R.is_beached))!=null?F:!1;return new S(A,b);case"stronghold":return new E(A);case"swamp_hut":return new y(A);case"woodland_mansion":return new k(A)}return new a(A)}n.fromJson=i;class s extends n{constructor(I,R,B,A,C,P){super(I),this.startingPoolHolder=R,this.startHeight=B,this.projectStartToHeightmap=A,this.startJigsawName=C,this.dimensionPadding=P}findGenerationPoint(I,R,B,A){var C=this.startHeight(B,A.settings.noise);const P=u.BlockPos.create(I<<4,C,R<<4),F=u.Rotation.getRandom(B),j=this.startingPoolHolder.value().getRandomTemplate(B);if(!(j instanceof Ft.EmptyPoolElement)){var T;if(this.startJigsawName){const z=s.getRandomNamedJigsaw(j,this.startJigsawName,F,B);if(z===void 0)return;T=z}else T=u.BlockPos.ZERO;const J=u.BlockPos.subtract(P,T),$=j.getBoundingBox(J,F),G=($[1][0]+$[0][0])/2^0,M=($[1][2]+$[0][2])/2^0;var C;return this.projectStartToHeightmap?C=P[1]+A.chunkGenerator.getBaseHeight(G,M,this.projectStartToHeightmap,A.randomState):C=J[1],$.forEach(z=>z[1]+=C-$[0][1]-1),s.isStartTooCloseToWorldHeightLimits(this.dimensionPadding,$,A.levelHeight)?void 0:u.BlockPos.create(G,C+T[1],M)}}static isStartTooCloseToWorldHeightLimits(I,R,B){if(I===s.DimensionPadding.ZERO)return!1;const A=B.minY+I.bottom,C=B.minY+B.height-I.top;return R[0][1]C}static getRandomNamedJigsaw(I,R,B,A){var P,F;const C=I.getShuffledJigsawBlocks(B,A);for(const U of C)if(N.parse((F=(P=U.nbt)==null?void 0:P.getString("name"))!=null?F:"minecraft:empty").equals(R))return U.pos}}n.JigsawStructure=s,(x=>{const R=class{constructor(A,C){this.top=A,this.bottom=C}static fromJson(A){var P,F,U;if(A===void 0)return R.ZERO;if(typeof A=="number")return new R(A,A);const C=(P=u.Json.readObject(A))!=null?P:{};return new R((F=u.Json.readInt(C.top))!=null?F:0,(U=u.Json.readInt(C.bottom))!=null?U:0)}};let I=R;_(I,"ZERO",new R(0,0)),x.DimensionPadding=I})(s=n.JigsawStructure||(n.JigsawStructure={}));class a extends n{findGenerationPoint(I,R,B,A){return this.onTopOfChunkCenter(A,I,R,"OCEAN_FLOOR_WG")}}n.BuriedTreasureStructure=a;class o extends n{constructor(I,R,B){super(I),this.width=R,this.depth=B}findGenerationPoint(I,R,B,A){if(!(this.getLowestY(A,I<<4,R<<4,this.width,this.depth)o+m.weight,0);for(;s.length>0;){let o=i.nextInt(a),m,c;for([m,c]of s.entries())if(o-=c.weight,o<0)break;const l=c.structure.value().tryGenerate(t,e,r);if(l!==void 0)return{id:c.structure.key(),pos:l};s.splice(m,1),a-=c.weight}}}};let De=Tn;_(De,"REGISTRY",Mt.createAndRegister("worldgen/structure_set",Tn.fromJson)),(n=>{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,N.parse((a=u.Json.readString(i.structure))!=null?a:"minecraft:empty")),(o=u.Json.readInt(i.weight))!=null?o:1)}}n.StructureSelectionEntry=t})(De||(De={}));class Ot{constructor(t,e,r,i,s){this.locateOffset=t,this.frequencyReductionMethod=e,this.frequency=r,this.salt=i,this.exclusionZone=s}static fromJson(t){var c,l,h,d,f,w,v,g,p,S;const e=(c=u.Json.readObject(t))!=null?c:{},r=(l=u.Json.readString(e.type))==null?void 0:l.replace(/^minecraft:/,""),i=u.BlockPos.fromJson(e.locate_offset),s=Ot.FrequencyReducer.fromType((h=u.Json.readString(e.frequency_reduction_method))!=null?h:"default"),a=(d=u.Json.readNumber(e.frequency))!=null?d:1,o=(f=u.Json.readInt(e.salt))!=null?f:0,m="exclusion_zone"in e?Ot.ExclusionZone.fromJson(e.exclusion_zone):void 0;switch(r){case"random_spread":const E=(w=u.Json.readInt(e.spacing))!=null?w:1,y=(v=u.Json.readInt(e.separation))!=null?v:1,k=Ot.SpreadType.fromJson(e.spread_type);return new Ot.RandomSpreadStructurePlacement(i,s,a,o,m,E,y,k);case"concentric_rings":const x=(g=u.Json.readInt(e.distance))!=null?g:1,I=(p=u.Json.readInt(e.spread))!=null?p:1,R=(S=u.Json.readInt(e.count))!=null?S:1,B=ve.parser(u.WorldgenRegistries.BIOME)(e.preferred_biomes);return new Ot.ConcentricRingsStructurePlacement(i,s,a,o,m,x,I,R,B)}return new Ot.RandomSpreadStructurePlacement([0,0,0],Ot.FrequencyReducer.ProbabilityReducer,1,0,void 0,1,1,"linear")}isStructureChunk(t,e,r){return this.isPlacementChunk(t,e,r)?this.frequency<1&&!this.frequencyReductionMethod(t,this.salt,e,r,this.frequency)?!1:!(this.exclusionZone&&this.exclusionZone.isPlacementForbidden(t,e,r)):!1}prepare(t,e,r){}}(n=>{(s=>{function a(h){switch(h){case"legacy_type_1":return l;case"legacy_type_2":return c;case"legacy_type_3":return m;case"default":default:return o}}s.fromType=a;function o(h,d,f,w,v){return at.fromLargeFeatureWithSalt(h,d,f,w).nextFloat()>4,p=w>>4,S=new at(BigInt(g^p<<4)^h);return S.nextInt(),S.nextInt(Math.floor(1/v))===0}s.LegacyPillagerOutpostReducer=l})(n.FrequencyReducer||(n.FrequencyReducer={}));class t{constructor(a,o){this.otherSet=a,this.chunkCount=o}static fromJson(a){var m,c,l;const o=(m=u.Json.readObject(a))!=null?m:{};return new t(u.Holder.reference(De.REGISTRY,N.parse((c=u.Json.readString(o.other_set))!=null?c:"")),(l=u.Json.readInt(o.chunk_count))!=null?l:1)}isPlacementForbidden(a,o,m){const c=this.otherSet.value().placement;return c.getPotentialStructureChunks(a,o-this.chunkCount,m-this.chunkCount,o+this.chunkCount,m+this.chunkCount).findIndex(l=>Math.abs(l[0]-o)<=this.chunkCount&&Math.abs(l[1]-m)<=this.chunkCount&&c.isStructureChunk(a,l[0],l[1]))>=0}}n.ExclusionZone=t,(s=>{function a(o){var c;return((c=u.Json.readString(o))!=null?c:"linear")==="triangular"?"triangular":"linear"}s.fromJson=a})(n.SpreadType||(n.SpreadType={}));class e extends n{constructor(a,o,m,c,l,h,d,f){super(a,o,m,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,m){const c=Math.floor(o/this.spacing),l=Math.floor(m/this.spacing),h=at.fromLargeFeatureWithSalt(a,c,l,this.salt),d=this.spacing-this.separation,f=this.evaluateSpread(h,d),w=this.evaluateSpread(h,d);return[c*this.spacing+f,l*this.spacing+w]}isPlacementChunk(a,o,m){const[c,l]=this.getPotentialStructureChunk(a,o,m);return c===o&&l===m}getPotentialStructureChunks(a,o,m,c,l){const h=[];for(let d=Math.floor(o/this.spacing)*this.spacing;d<=c;d+=this.spacing)for(let f=Math.floor(m/this.spacing)*this.spacing;f<=l;f+=this.spacing)h.push(this.getPotentialStructureChunk(a,d,f));return h}}n.RandomSpreadStructurePlacement=e;const r=112;class i extends n{constructor(o,m,c,l,h,d,f,w,v){super(o,m,c,l,h);_(this,"positions");this.distance=d,this.spread=f,this.count=w,this.preferredBiomes=v}prepare(o,m,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,w=0;const v=[...this.preferredBiomes.value().getEntries()].flatMap(p=>{var S;return(S=p.key())!=null?S:[]});for(var g=0;g{const R=u.BiomeSource.findBiomeHorizontal(o,y,0,k,r,B=>v.findIndex(A=>A.equals(B))>=0,x,m);return R?[R.pos[0]>>4,R.pos[2]>>4]:[S,E]};this.positions.push({center:[S,E],real:I}),h+=Math.PI*2/d,w++,w==d&&(f++,w=0,d+=2*d/(f+1),d=Math.min(d,this.count-g),h+=l.nextDouble()*Math.PI*2)}}isPlacementChunk(o,m,c){return this.positions===void 0?(console.warn("trying to access concentric rings placement before position calculation"),!1):this.getPotentialStructureChunks(o,m,c,m,c).findIndex(l=>l[0]===m&&l[1]===c)>=0}getPotentialStructureChunks(o,m,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}}n.ConcentricRingsStructurePlacement=i})(Ot||(Ot={})),u.BlendedNoise=Zs,u.BlockColors=Pe,u.BlockDefinition=Qr,u.BlockModel=ot,u.BlockState=X,u.CheckerboardBiomeSource=ur,u.Chunk=el,u.ChunkBuilder=$s,u.ChunkSection=qe,u.DensityFunction=q,u.EFFECT_COLORS=Ns,u.FixedBiomeSource=je,u.FluidStatus=Cn,u.HolderSet=ve,u.Identifier=N,u.ImprovedNoise=Kr,u.ItemRenderer=lr,u.ItemStack=$t,u.LegacyPositionalRandom=Us,u.LegacyRandom=at,u.Line=or,u.Matrix3=xn,u.Matrix4=sr,u.Mesh=it,u.MultiNoiseBiomeSource=hr,u.NbtAbstractList=En,u.NbtByte=Bt,u.NbtByteArray=me,u.NbtChunk=Kt,u.NbtCompound=mt,u.NbtDouble=Qt,u.NbtEnd=In,u.NbtFile=Vt,u.NbtFloat=Be,u.NbtInt=Dt,u.NbtIntArray=ge,u.NbtList=Tt,u.NbtLong=Te,u.NbtLongArray=we,u.NbtRegion=pe,u.NbtShort=Le,u.NbtString=vt,u.NbtTag=et,u.NbtType=D,u.NoiseAquifer=Je,u.NoiseChunk=ni,u.NoiseChunkGenerator=Xs,u.NormalNoise=ie,u.POTION_EFFECTS=Cs,u.PalettedContainer=Rs,u.PerlinNoise=pt,u.PerlinSimplexNoise=Fl,u.Quad=Yt,u.RandomState=js,u.RawDataInput=ai,u.RawDataOutput=oi,u.Registry=Mt,u.Renderer=cr,u.ShaderProgram=Rn,u.SimplexNoise=wt,u.StringReader=St,u.Structure=te,u.StructurePlacement=Ot,u.StructurePoolElement=Ft,u.StructureRenderer=tu,u.StructureSet=De,u.StructureTemplatePool=ze,u.SurfaceContext=Ws,u.SurfaceSystem=qs,u.TextureAtlas=Nn,u.Vector=Y,u.Vertex=Pt,u.VoxelRenderer=ru,u.WorldgenStructure=fr,u.XoroshiroPositionalRandom=Hs,u.XoroshiroRandom=nt,u.binarySearch=Ls,u.clamp=xt,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=Ts,u.lerp=ne,u.lerp2=Kn,u.lerp3=Bs,u.longfromBytes=er,u.map=An,u.mutateWithDefault=gr,u.nextInt=rr,u.randomBetweenInclusive=nr,u.shuffle=Os,u.smoothstep=tr,u.square=ee,u.upperPowerOfTwo=Ps,Object.defineProperties(u,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});