@xiaozhu2007/koishi-plugin-litematic-renderer 0.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/assets/java-bridge/litematic-render-bridge-0.1.2.jar +0 -0
- package/assets/standalone-renderer/litematic-standalone-renderer-0.2.6.jar +0 -0
- package/assets/threeviews/index.html +1270 -0
- package/assets/threeviews//346/210/221/347/232/204/344/270/226/347/225/214-Litematic/346/212/225/345/275/261/344/270/211/350/247/206/345/233/276/351/242/204/350/247/210_files/api.js./344/270/213/350/275/275 +917 -0
- package/assets/threeviews//346/210/221/347/232/204/344/270/226/347/225/214-Litematic/346/212/225/345/275/261/344/270/211/350/247/206/345/233/276/351/242/204/350/247/210_files/assets.js./344/270/213/350/275/275 +1 -0
- package/assets/threeviews//346/210/221/347/232/204/344/270/226/347/225/214-Litematic/346/212/225/345/275/261/344/270/211/350/247/206/345/233/276/351/242/204/350/247/210_files/atlas.png +0 -0
- package/assets/threeviews//346/210/221/347/232/204/344/270/226/347/225/214-Litematic/346/212/225/345/275/261/344/270/211/350/247/206/345/233/276/351/242/204/350/247/210_files/deepslate-helpers.js./344/270/213/350/275/275 +118 -0
- package/assets/threeviews//346/210/221/347/232/204/344/270/226/347/225/214-Litematic/346/212/225/345/275/261/344/270/211/350/247/206/345/233/276/351/242/204/350/247/210_files/deepslate.js./344/270/213/350/275/275 +2 -0
- package/assets/threeviews//346/210/221/347/232/204/344/270/226/347/225/214-Litematic/346/212/225/345/275/261/344/270/211/350/247/206/345/233/276/351/242/204/350/247/210_files/gl-matrix-min.js./344/270/213/350/275/275 +28 -0
- package/assets/threeviews//346/210/221/347/232/204/344/270/226/347/225/214-Litematic/346/212/225/345/275/261/344/270/211/350/247/206/345/233/276/351/242/204/350/247/210_files/litematic-utils.js./344/270/213/350/275/275 +174 -0
- package/assets/threeviews//346/210/221/347/232/204/344/270/226/347/225/214-Litematic/346/212/225/345/275/261/344/270/211/350/247/206/345/233/276/351/242/204/350/247/210_files/opaque.js./344/270/213/350/275/275 +413 -0
- package/assets/vanilla-resources/Minecraft-26.2-Vanilla-Resources.zip +0 -0
- package/lib/index.d.ts +114 -0
- package/lib/index.js +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var deepslateResources;
|
|
2
|
+
|
|
3
|
+
function upperPowerOfTwo(x) {
|
|
4
|
+
x -= 1
|
|
5
|
+
x |= x >> 1
|
|
6
|
+
x |= x >> 2
|
|
7
|
+
x |= x >> 4
|
|
8
|
+
x |= x >> 8
|
|
9
|
+
x |= x >> 18
|
|
10
|
+
x |= x >> 32
|
|
11
|
+
return x + 1
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Load Deepslate resources from texture atlas image
|
|
15
|
+
// Taken from Deepslate examples
|
|
16
|
+
function loadDeepslateResources(textureImage) {
|
|
17
|
+
console.log("loading resources...")
|
|
18
|
+
const blockDefinitions = {};
|
|
19
|
+
Object.keys(assets.blockstates).forEach(id => {
|
|
20
|
+
blockDefinitions['minecraft:' + id] = deepslate.BlockDefinition.fromJson(id, assets.blockstates[id]);
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const blockModels = {};
|
|
24
|
+
Object.keys(assets.models).forEach(id => {
|
|
25
|
+
blockModels['minecraft:' + id] = deepslate.BlockModel.fromJson(id, assets.models[id]);
|
|
26
|
+
})
|
|
27
|
+
Object.values(blockModels).forEach(m => m.flatten({ getBlockModel: id => blockModels[id] }));
|
|
28
|
+
|
|
29
|
+
const atlasCanvas = document.createElement('canvas');
|
|
30
|
+
const atlasSize = upperPowerOfTwo((textureImage.width >= textureImage.height) ? textureImage.width : textureImage.height);
|
|
31
|
+
atlasCanvas.width = textureImage.width;
|
|
32
|
+
atlasCanvas.height = textureImage.height;
|
|
33
|
+
|
|
34
|
+
const atlasCtx = atlasCanvas.getContext('2d');
|
|
35
|
+
atlasCtx.drawImage(textureImage, 0, 0);
|
|
36
|
+
|
|
37
|
+
const atlasData = atlasCtx.getImageData(0, 0, atlasSize, atlasSize);
|
|
38
|
+
|
|
39
|
+
const idMap = {};
|
|
40
|
+
|
|
41
|
+
Object.keys(assets.textures).forEach(id => {
|
|
42
|
+
const [u, v, du, dv] = assets.textures[id]
|
|
43
|
+
const dv2 = (du !== dv && id.startsWith('block/')) ? du : dv
|
|
44
|
+
idMap['minecraft:' + id] = [u / atlasSize, v / atlasSize, (u + du) / atlasSize, (v + dv2) / atlasSize]
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const textureAtlas = new deepslate.TextureAtlas(atlasData, idMap);
|
|
48
|
+
|
|
49
|
+
deepslateResources = {
|
|
50
|
+
getBlockDefinition(id) { return blockDefinitions[id] },
|
|
51
|
+
getBlockModel(id) { return blockModels[id] },
|
|
52
|
+
getTextureUV(id) { return textureAtlas.getTextureUV(id) },
|
|
53
|
+
getTextureAtlas() { return textureAtlas.getTextureAtlas() },
|
|
54
|
+
getBlockFlags(id) {
|
|
55
|
+
return {
|
|
56
|
+
opaque: OPAQUE_BLOCKS.has(id.toString()),
|
|
57
|
+
self_culling: !NON_SELF_CULLING.has(id.toString()),
|
|
58
|
+
semi_transparent: TRANSPARENT_BLOCKS.has(id.toString()),
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
getBlockProperties(id) { return null },
|
|
62
|
+
getDefaultBlockProperties(id) { return null },
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return deepslateResources;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function structureFromLitematic(litematic, y_min=0, y_max=-1) {
|
|
69
|
+
const bounds = { min: [Infinity, Infinity, Infinity], max: [-Infinity, -Infinity, -Infinity] };
|
|
70
|
+
for (const region of litematic.regions) {
|
|
71
|
+
const origin = region.position || { x: 0, y: 0, z: 0 };
|
|
72
|
+
const sizes = [Math.abs(region.width), Math.abs(region.height), Math.abs(region.depth)];
|
|
73
|
+
const directions = [region.width < 0 ? -1 : 1, region.height < 0 ? -1 : 1, region.depth < 0 ? -1 : 1];
|
|
74
|
+
const starts = [origin.x, origin.y, origin.z];
|
|
75
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
76
|
+
const end = starts[axis] + (sizes[axis] - 1) * directions[axis];
|
|
77
|
+
bounds.min[axis] = Math.min(bounds.min[axis], starts[axis], end);
|
|
78
|
+
bounds.max[axis] = Math.max(bounds.max[axis], starts[axis], end);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const structure = new deepslate.Structure(bounds.max.map((value, axis) => value - bounds.min[axis] + 1));
|
|
83
|
+
let blockCount = 0;
|
|
84
|
+
console.log("Building blocks from", litematic.regions.length, "regions...");
|
|
85
|
+
for (const region of litematic.regions) {
|
|
86
|
+
const blocks = region.blocks;
|
|
87
|
+
const blockPalette = region.blockPalette;
|
|
88
|
+
const origin = region.position || { x: 0, y: 0, z: 0 };
|
|
89
|
+
const directions = [region.width < 0 ? -1 : 1, region.height < 0 ? -1 : 1, region.depth < 0 ? -1 : 1];
|
|
90
|
+
const maxY = y_max === -1 ? blocks[0].length : Math.min(y_max, blocks[0].length);
|
|
91
|
+
for (let x = 0; x < blocks.length; x++) {
|
|
92
|
+
for (let y = Math.max(0, y_min); y < maxY; y++) {
|
|
93
|
+
for (let z = 0; z < blocks[x][y].length; z++) {
|
|
94
|
+
const blockID = blocks[x][y][z];
|
|
95
|
+
if (blockID <= 0) continue;
|
|
96
|
+
const blockInfo = blockPalette[blockID];
|
|
97
|
+
const position = [
|
|
98
|
+
origin.x + x * directions[0] - bounds.min[0],
|
|
99
|
+
origin.y + y * directions[1] - bounds.min[1],
|
|
100
|
+
origin.z + z * directions[2] - bounds.min[2],
|
|
101
|
+
];
|
|
102
|
+
if (blockInfo) {
|
|
103
|
+
blockCount++;
|
|
104
|
+
if (blockInfo.hasOwnProperty("Properties")) {
|
|
105
|
+
structure.addBlock(position, blockInfo.Name, blockInfo.Properties);
|
|
106
|
+
} else {
|
|
107
|
+
structure.addBlock(position, blockInfo.Name);
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
structure.addBlock(position, "minecraft:cake");
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
console.log("Done!", blockCount, "blocks");
|
|
117
|
+
return structure;
|
|
118
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).deepslate={})}(this,(function(t){"use strict";var e;t.Direction=void 0,(e=t.Direction||(t.Direction={})).UP="up",e.DOWN="down",e.NORTH="north",e.EAST="east",e.SOUTH="south",e.WEST="west";const i={[t.Direction.UP]:[0,1,0],[t.Direction.DOWN]:[0,-1,0],[t.Direction.NORTH]:[0,0,-1],[t.Direction.EAST]:[1,0,0],[t.Direction.SOUTH]:[0,0,1],[t.Direction.WEST]:[-1,0,0]};var n;!function(t){t.ALL=[t.UP,t.DOWN,t.NORTH,t.EAST,t.SOUTH,t.WEST],t.normal=function(t){return i[t]}}(t.Direction||(t.Direction={})),t.BlockPos=void 0,(n=t.BlockPos||(t.BlockPos={})).create=function(t,e,i){return[t,e,i]},n.ZERO=n.create(0,0,0),n.offset=function(t,e,i,n){return[t[0]+e,t[1]+i,t[2]+n]},n.towards=function(e,i){return n.offset(e,...t.Direction.normal(i))},n.equals=function(t,e){return t===e||t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},n.magnitude=function(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]};function s(t){let e=t.length;for(;--e>=0;)t[e]=0}const r=256,a=286,o=30,l=15,h=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]),u=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]),c=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),d=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f=new Array(576);s(f);const m=new Array(60);s(m);const p=new Array(512);s(p);const g=new Array(256);s(g);const _=new Array(29);s(_);const b=new Array(o);function w(t,e,i,n,s){this.static_tree=t,this.extra_bits=e,this.extra_base=i,this.elems=n,this.max_length=s,this.has_stree=t&&t.length}let v,y,x;function k(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}s(b);const A=t=>t<256?p[t]:p[256+(t>>>7)],S=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},E=(t,e,i)=>{t.bi_valid>16-i?(t.bi_buf|=e<<t.bi_valid&65535,S(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=i-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=i)},I=(t,e,i)=>{E(t,i[2*e],i[2*e+1])},N=(t,e)=>{let i=0;do{i|=1&t,t>>>=1,i<<=1}while(--e>0);return i>>>1},R=(t,e,i)=>{const n=new Array(16);let s,r,a=0;for(s=1;s<=l;s++)n[s]=a=a+i[s-1]<<1;for(r=0;r<=e;r++){let e=t[2*r+1];0!==e&&(t[2*r]=N(n[e]++,e))}},B=t=>{let e;for(e=0;e<a;e++)t.dyn_ltree[2*e]=0;for(e=0;e<o;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},M=t=>{t.bi_valid>8?S(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},T=(t,e,i,n)=>{const s=2*e,r=2*i;return t[s]<t[r]||t[s]===t[r]&&n[e]<=n[i]},C=(t,e,i)=>{const n=t.heap[i];let s=i<<1;for(;s<=t.heap_len&&(s<t.heap_len&&T(e,t.heap[s+1],t.heap[s],t.depth)&&s++,!T(e,n,t.heap[s],t.depth));)t.heap[i]=t.heap[s],i=s,s<<=1;t.heap[i]=n},O=(t,e,i)=>{let n,s,a,o,l=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*l]<<8|t.pending_buf[t.d_buf+2*l+1],s=t.pending_buf[t.l_buf+l],l++,0===n?I(t,s,e):(a=g[s],I(t,a+r+1,e),o=h[a],0!==o&&(s-=_[a],E(t,s,o)),n--,a=A(n),I(t,a,i),o=u[a],0!==o&&(n-=b[a],E(t,n,o)))}while(l<t.last_lit);I(t,256,e)},P=(t,e)=>{const i=e.dyn_tree,n=e.stat_desc.static_tree,s=e.stat_desc.has_stree,r=e.stat_desc.elems;let a,o,h,u=-1;for(t.heap_len=0,t.heap_max=573,a=0;a<r;a++)0!==i[2*a]?(t.heap[++t.heap_len]=u=a,t.depth[a]=0):i[2*a+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=u<2?++u:0,i[2*h]=1,t.depth[h]=0,t.opt_len--,s&&(t.static_len-=n[2*h+1]);for(e.max_code=u,a=t.heap_len>>1;a>=1;a--)C(t,i,a);h=r;do{a=t.heap[1],t.heap[1]=t.heap[t.heap_len--],C(t,i,1),o=t.heap[1],t.heap[--t.heap_max]=a,t.heap[--t.heap_max]=o,i[2*h]=i[2*a]+i[2*o],t.depth[h]=(t.depth[a]>=t.depth[o]?t.depth[a]:t.depth[o])+1,i[2*a+1]=i[2*o+1]=h,t.heap[1]=h++,C(t,i,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const i=e.dyn_tree,n=e.max_code,s=e.stat_desc.static_tree,r=e.stat_desc.has_stree,a=e.stat_desc.extra_bits,o=e.stat_desc.extra_base,h=e.stat_desc.max_length;let u,c,d,f,m,p,g=0;for(f=0;f<=l;f++)t.bl_count[f]=0;for(i[2*t.heap[t.heap_max]+1]=0,u=t.heap_max+1;u<573;u++)c=t.heap[u],f=i[2*i[2*c+1]+1]+1,f>h&&(f=h,g++),i[2*c+1]=f,c>n||(t.bl_count[f]++,m=0,c>=o&&(m=a[c-o]),p=i[2*c],t.opt_len+=p*(f+m),r&&(t.static_len+=p*(s[2*c+1]+m)));if(0!==g){do{for(f=h-1;0===t.bl_count[f];)f--;t.bl_count[f]--,t.bl_count[f+1]+=2,t.bl_count[h]--,g-=2}while(g>0);for(f=h;0!==f;f--)for(c=t.bl_count[f];0!==c;)d=t.heap[--u],d>n||(i[2*d+1]!==f&&(t.opt_len+=(f-i[2*d+1])*i[2*d],i[2*d+1]=f),c--)}})(t,e),R(i,u,t.bl_count)},F=(t,e,i)=>{let n,s,r=-1,a=e[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),e[2*(i+1)+1]=65535,n=0;n<=i;n++)s=a,a=e[2*(n+1)+1],++o<l&&s===a||(o<h?t.bl_tree[2*s]+=o:0!==s?(s!==r&&t.bl_tree[2*s]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,r=s,0===a?(l=138,h=3):s===a?(l=6,h=3):(l=7,h=4))},L=(t,e,i)=>{let n,s,r=-1,a=e[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),n=0;n<=i;n++)if(s=a,a=e[2*(n+1)+1],!(++o<l&&s===a)){if(o<h)do{I(t,s,t.bl_tree)}while(0!=--o);else 0!==s?(s!==r&&(I(t,s,t.bl_tree),o--),I(t,16,t.bl_tree),E(t,o-3,2)):o<=10?(I(t,17,t.bl_tree),E(t,o-3,3)):(I(t,18,t.bl_tree),E(t,o-11,7));o=0,r=s,0===a?(l=138,h=3):s===a?(l=6,h=3):(l=7,h=4)}};let D=!1;const z=(t,e,i,n)=>{E(t,0+(n?1:0),3),((t,e,i,n)=>{M(t),n&&(S(t,i),S(t,~i)),t.pending_buf.set(t.window.subarray(e,e+i),t.pending),t.pending+=i})(t,e,i,!0)};var U=(t,e,i,n)=>{let s,a,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<r;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),P(t,t.l_desc),P(t,t.d_desc),o=(t=>{let e;for(F(t,t.dyn_ltree,t.l_desc.max_code),F(t,t.dyn_dtree,t.d_desc.max_code),P(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*d[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),s=t.opt_len+3+7>>>3,a=t.static_len+3+7>>>3,a<=s&&(s=a)):s=a=i+5,i+4<=s&&-1!==e?z(t,e,i,n):4===t.strategy||a===s?(E(t,2+(n?1:0),3),O(t,f,m)):(E(t,4+(n?1:0),3),((t,e,i,n)=>{let s;for(E(t,e-257,5),E(t,i-1,5),E(t,n-4,4),s=0;s<n;s++)E(t,t.bl_tree[2*d[s]+1],3);L(t,t.dyn_ltree,e-1),L(t,t.dyn_dtree,i-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),O(t,t.dyn_ltree,t.dyn_dtree)),B(t),n&&M(t)},V={_tr_init:t=>{D||((()=>{let t,e,i,n,s;const r=new Array(16);for(i=0,n=0;n<28;n++)for(_[n]=i,t=0;t<1<<h[n];t++)g[i++]=n;for(g[i-1]=n,s=0,n=0;n<16;n++)for(b[n]=s,t=0;t<1<<u[n];t++)p[s++]=n;for(s>>=7;n<o;n++)for(b[n]=s<<7,t=0;t<1<<u[n]-7;t++)p[256+s++]=n;for(e=0;e<=l;e++)r[e]=0;for(t=0;t<=143;)f[2*t+1]=8,t++,r[8]++;for(;t<=255;)f[2*t+1]=9,t++,r[9]++;for(;t<=279;)f[2*t+1]=7,t++,r[7]++;for(;t<=287;)f[2*t+1]=8,t++,r[8]++;for(R(f,287,r),t=0;t<o;t++)m[2*t+1]=5,m[2*t]=N(t,5);v=new w(f,h,257,a,l),y=new w(m,u,0,o,l),x=new w(new Array(0),c,0,19,7)})(),D=!0),t.l_desc=new k(t.dyn_ltree,v),t.d_desc=new k(t.dyn_dtree,y),t.bl_desc=new k(t.bl_tree,x),t.bi_buf=0,t.bi_valid=0,B(t)},_tr_stored_block:z,_tr_flush_block:U,_tr_tally:(t,e,i)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&i,t.last_lit++,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(g[i]+r+1)]++,t.dyn_dtree[2*A(e)]++),t.last_lit===t.lit_bufsize-1),_tr_align:t=>{E(t,2,3),I(t,256,f),(t=>{16===t.bi_valid?(S(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var Z=(t,e,i,n)=>{let s=65535&t|0,r=t>>>16&65535|0,a=0;for(;0!==i;){a=i>2e3?2e3:i,i-=a;do{s=s+e[n++]|0,r=r+s|0}while(--a);s%=65521,r%=65521}return s|r<<16|0};const G=new Uint32Array((()=>{let t,e=[];for(var i=0;i<256;i++){t=i;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e})());var Y=(t,e,i,n)=>{const s=G,r=n+i;t^=-1;for(let i=n;i<r;i++)t=t>>>8^s[255&(t^e[i])];return-1^t},H={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"},j={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:X,_tr_stored_block:W,_tr_flush_block:q,_tr_tally:$,_tr_align:J}=V,{Z_NO_FLUSH:K,Z_PARTIAL_FLUSH:Q,Z_FULL_FLUSH:tt,Z_FINISH:et,Z_BLOCK:it,Z_OK:nt,Z_STREAM_END:st,Z_STREAM_ERROR:rt,Z_DATA_ERROR:at,Z_BUF_ERROR:ot,Z_DEFAULT_COMPRESSION:lt,Z_FILTERED:ht,Z_HUFFMAN_ONLY:ut,Z_RLE:ct,Z_FIXED:dt,Z_DEFAULT_STRATEGY:ft,Z_UNKNOWN:mt,Z_DEFLATED:pt}=j,gt=258,_t=262,bt=103,wt=113,vt=666,yt=(t,e)=>(t.msg=H[e],e),xt=t=>(t<<1)-(t>4?9:0),kt=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let At=(t,e,i)=>(e<<t.hash_shift^i)&t.hash_mask;const St=t=>{const e=t.state;let i=e.pending;i>t.avail_out&&(i=t.avail_out),0!==i&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+i),t.next_out),t.next_out+=i,e.pending_out+=i,t.total_out+=i,t.avail_out-=i,e.pending-=i,0===e.pending&&(e.pending_out=0))},Et=(t,e)=>{q(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,St(t.strm)},It=(t,e)=>{t.pending_buf[t.pending++]=e},Nt=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Rt=(t,e,i,n)=>{let s=t.avail_in;return s>n&&(s=n),0===s?0:(t.avail_in-=s,e.set(t.input.subarray(t.next_in,t.next_in+s),i),1===t.state.wrap?t.adler=Z(t.adler,e,s,i):2===t.state.wrap&&(t.adler=Y(t.adler,e,s,i)),t.next_in+=s,t.total_in+=s,s)},Bt=(t,e)=>{let i,n,s=t.max_chain_length,r=t.strstart,a=t.prev_length,o=t.nice_match;const l=t.strstart>t.w_size-_t?t.strstart-(t.w_size-_t):0,h=t.window,u=t.w_mask,c=t.prev,d=t.strstart+gt;let f=h[r+a-1],m=h[r+a];t.prev_length>=t.good_match&&(s>>=2),o>t.lookahead&&(o=t.lookahead);do{if(i=e,h[i+a]===m&&h[i+a-1]===f&&h[i]===h[r]&&h[++i]===h[r+1]){r+=2,i++;do{}while(h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&h[++r]===h[++i]&&r<d);if(n=gt-(d-r),r=d-gt,n>a){if(t.match_start=e,a=n,n>=o)break;f=h[r+a-1],m=h[r+a]}}}while((e=c[e&u])>l&&0!=--s);return a<=t.lookahead?a:t.lookahead},Mt=t=>{const e=t.w_size;let i,n,s,r,a;do{if(r=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-_t)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,i=n;do{s=t.head[--i],t.head[i]=s>=e?s-e:0}while(--n);n=e,i=n;do{s=t.prev[--i],t.prev[i]=s>=e?s-e:0}while(--n);r+=e}if(0===t.strm.avail_in)break;if(n=Rt(t.strm,t.window,t.strstart+t.lookahead,r),t.lookahead+=n,t.lookahead+t.insert>=3)for(a=t.strstart-t.insert,t.ins_h=t.window[a],t.ins_h=At(t,t.ins_h,t.window[a+1]);t.insert&&(t.ins_h=At(t,t.ins_h,t.window[a+3-1]),t.prev[a&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=a,a++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<_t&&0!==t.strm.avail_in)},Tt=(t,e)=>{let i,n;for(;;){if(t.lookahead<_t){if(Mt(t),t.lookahead<_t&&e===K)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=At(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==i&&t.strstart-i<=t.w_size-_t&&(t.match_length=Bt(t,i)),t.match_length>=3)if(n=$(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=At(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=At(t,t.ins_h,t.window[t.strstart+1]);else n=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Et(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===et?(Et(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Et(t,!1),0===t.strm.avail_out)?1:2},Ct=(t,e)=>{let i,n,s;for(;;){if(t.lookahead<_t){if(Mt(t),t.lookahead<_t&&e===K)return 1;if(0===t.lookahead)break}if(i=0,t.lookahead>=3&&(t.ins_h=At(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==i&&t.prev_length<t.max_lazy_match&&t.strstart-i<=t.w_size-_t&&(t.match_length=Bt(t,i),t.match_length<=5&&(t.strategy===ht||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){s=t.strstart+t.lookahead-3,n=$(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=s&&(t.ins_h=At(t,t.ins_h,t.window[t.strstart+3-1]),i=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(Et(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=$(t,0,t.window[t.strstart-1]),n&&Et(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=$(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===et?(Et(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Et(t,!1),0===t.strm.avail_out)?1:2};function Ot(t,e,i,n,s){this.good_length=t,this.max_lazy=e,this.nice_length=i,this.max_chain=n,this.func=s}const Pt=[new Ot(0,0,0,0,((t,e)=>{let i=65535;for(i>t.pending_buf_size-5&&(i=t.pending_buf_size-5);;){if(t.lookahead<=1){if(Mt(t),0===t.lookahead&&e===K)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+i;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,Et(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-_t&&(Et(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===et?(Et(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(Et(t,!1),t.strm.avail_out),1)})),new Ot(4,4,8,4,Tt),new Ot(4,5,16,8,Tt),new Ot(4,6,32,32,Tt),new Ot(4,4,16,16,Ct),new Ot(8,16,32,32,Ct),new Ot(8,16,128,128,Ct),new Ot(8,32,128,256,Ct),new Ot(32,128,258,1024,Ct),new Ot(32,258,258,4096,Ct)];function Ft(){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=pt,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(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),kt(this.dyn_ltree),kt(this.dyn_dtree),kt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),kt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),kt(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 Lt=t=>{if(!t||!t.state)return yt(t,rt);t.total_in=t.total_out=0,t.data_type=mt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:wt,t.adler=2===e.wrap?0:1,e.last_flush=K,X(e),nt},Dt=t=>{const e=Lt(t);var i;return e===nt&&((i=t.state).window_size=2*i.w_size,kt(i.head),i.max_lazy_match=Pt[i.level].max_lazy,i.good_match=Pt[i.level].good_length,i.nice_match=Pt[i.level].nice_length,i.max_chain_length=Pt[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),e},zt=(t,e,i,n,s,r)=>{if(!t)return rt;let a=1;if(e===lt&&(e=6),n<0?(a=0,n=-n):n>15&&(a=2,n-=16),s<1||s>9||i!==pt||n<8||n>15||e<0||e>9||r<0||r>dt)return yt(t,rt);8===n&&(n=9);const o=new Ft;return t.state=o,o.strm=t,o.wrap=a,o.gzhead=null,o.w_bits=n,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=s+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<s+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.d_buf=1*o.lit_bufsize,o.l_buf=3*o.lit_bufsize,o.level=e,o.strategy=r,o.method=i,Dt(t)};var Ut={deflateInit:(t,e)=>zt(t,e,pt,15,8,ft),deflateInit2:zt,deflateReset:Dt,deflateResetKeep:Lt,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?rt:(t.state.gzhead=e,nt):rt,deflate:(t,e)=>{let i,n;if(!t||!t.state||e>it||e<0)return t?yt(t,rt):rt;const s=t.state;if(!t.output||!t.input&&0!==t.avail_in||s.status===vt&&e!==et)return yt(t,0===t.avail_out?ot:rt);s.strm=t;const r=s.last_flush;if(s.last_flush=e,42===s.status)if(2===s.wrap)t.adler=0,It(s,31),It(s,139),It(s,8),s.gzhead?(It(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),It(s,255&s.gzhead.time),It(s,s.gzhead.time>>8&255),It(s,s.gzhead.time>>16&255),It(s,s.gzhead.time>>24&255),It(s,9===s.level?2:s.strategy>=ut||s.level<2?4:0),It(s,255&s.gzhead.os),s.gzhead.extra&&s.gzhead.extra.length&&(It(s,255&s.gzhead.extra.length),It(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(t.adler=Y(t.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=69):(It(s,0),It(s,0),It(s,0),It(s,0),It(s,0),It(s,9===s.level?2:s.strategy>=ut||s.level<2?4:0),It(s,3),s.status=wt);else{let e=pt+(s.w_bits-8<<4)<<8,i=-1;i=s.strategy>=ut||s.level<2?0:s.level<6?1:6===s.level?2:3,e|=i<<6,0!==s.strstart&&(e|=32),e+=31-e%31,s.status=wt,Nt(s,e),0!==s.strstart&&(Nt(s,t.adler>>>16),Nt(s,65535&t.adler)),t.adler=1}if(69===s.status)if(s.gzhead.extra){for(i=s.pending;s.gzindex<(65535&s.gzhead.extra.length)&&(s.pending!==s.pending_buf_size||(s.gzhead.hcrc&&s.pending>i&&(t.adler=Y(t.adler,s.pending_buf,s.pending-i,i)),St(t),i=s.pending,s.pending!==s.pending_buf_size));)It(s,255&s.gzhead.extra[s.gzindex]),s.gzindex++;s.gzhead.hcrc&&s.pending>i&&(t.adler=Y(t.adler,s.pending_buf,s.pending-i,i)),s.gzindex===s.gzhead.extra.length&&(s.gzindex=0,s.status=73)}else s.status=73;if(73===s.status)if(s.gzhead.name){i=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>i&&(t.adler=Y(t.adler,s.pending_buf,s.pending-i,i)),St(t),i=s.pending,s.pending===s.pending_buf_size)){n=1;break}n=s.gzindex<s.gzhead.name.length?255&s.gzhead.name.charCodeAt(s.gzindex++):0,It(s,n)}while(0!==n);s.gzhead.hcrc&&s.pending>i&&(t.adler=Y(t.adler,s.pending_buf,s.pending-i,i)),0===n&&(s.gzindex=0,s.status=91)}else s.status=91;if(91===s.status)if(s.gzhead.comment){i=s.pending;do{if(s.pending===s.pending_buf_size&&(s.gzhead.hcrc&&s.pending>i&&(t.adler=Y(t.adler,s.pending_buf,s.pending-i,i)),St(t),i=s.pending,s.pending===s.pending_buf_size)){n=1;break}n=s.gzindex<s.gzhead.comment.length?255&s.gzhead.comment.charCodeAt(s.gzindex++):0,It(s,n)}while(0!==n);s.gzhead.hcrc&&s.pending>i&&(t.adler=Y(t.adler,s.pending_buf,s.pending-i,i)),0===n&&(s.status=bt)}else s.status=bt;if(s.status===bt&&(s.gzhead.hcrc?(s.pending+2>s.pending_buf_size&&St(t),s.pending+2<=s.pending_buf_size&&(It(s,255&t.adler),It(s,t.adler>>8&255),t.adler=0,s.status=wt)):s.status=wt),0!==s.pending){if(St(t),0===t.avail_out)return s.last_flush=-1,nt}else if(0===t.avail_in&&xt(e)<=xt(r)&&e!==et)return yt(t,ot);if(s.status===vt&&0!==t.avail_in)return yt(t,ot);if(0!==t.avail_in||0!==s.lookahead||e!==K&&s.status!==vt){let i=s.strategy===ut?((t,e)=>{let i;for(;;){if(0===t.lookahead&&(Mt(t),0===t.lookahead)){if(e===K)return 1;break}if(t.match_length=0,i=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,i&&(Et(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===et?(Et(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Et(t,!1),0===t.strm.avail_out)?1:2})(s,e):s.strategy===ct?((t,e)=>{let i,n,s,r;const a=t.window;for(;;){if(t.lookahead<=gt){if(Mt(t),t.lookahead<=gt&&e===K)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(s=t.strstart-1,n=a[s],n===a[++s]&&n===a[++s]&&n===a[++s])){r=t.strstart+gt;do{}while(n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&n===a[++s]&&s<r);t.match_length=gt-(r-s),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(i=$(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(i=$(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),i&&(Et(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===et?(Et(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Et(t,!1),0===t.strm.avail_out)?1:2})(s,e):Pt[s.level].func(s,e);if(3!==i&&4!==i||(s.status=vt),1===i||3===i)return 0===t.avail_out&&(s.last_flush=-1),nt;if(2===i&&(e===Q?J(s):e!==it&&(W(s,0,0,!1),e===tt&&(kt(s.head),0===s.lookahead&&(s.strstart=0,s.block_start=0,s.insert=0))),St(t),0===t.avail_out))return s.last_flush=-1,nt}return e!==et?nt:s.wrap<=0?st:(2===s.wrap?(It(s,255&t.adler),It(s,t.adler>>8&255),It(s,t.adler>>16&255),It(s,t.adler>>24&255),It(s,255&t.total_in),It(s,t.total_in>>8&255),It(s,t.total_in>>16&255),It(s,t.total_in>>24&255)):(Nt(s,t.adler>>>16),Nt(s,65535&t.adler)),St(t),s.wrap>0&&(s.wrap=-s.wrap),0!==s.pending?nt:st)},deflateEnd:t=>{if(!t||!t.state)return rt;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==bt&&e!==wt&&e!==vt?yt(t,rt):(t.state=null,e===wt?yt(t,at):nt)},deflateSetDictionary:(t,e)=>{let i=e.length;if(!t||!t.state)return rt;const n=t.state,s=n.wrap;if(2===s||1===s&&42!==n.status||n.lookahead)return rt;if(1===s&&(t.adler=Z(t.adler,e,i,0)),n.wrap=0,i>=n.w_size){0===s&&(kt(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(i-n.w_size,i),0),e=t,i=n.w_size}const r=t.avail_in,a=t.next_in,o=t.input;for(t.avail_in=i,t.next_in=0,t.input=e,Mt(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=At(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,Mt(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=a,t.input=o,t.avail_in=r,n.wrap=s,nt},deflateInfo:"pako deflate (from Nodeca project)"};const Vt=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Zt=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const e in i)Vt(i,e)&&(t[e]=i[e])}}return t},Gt=t=>{let e=0;for(let i=0,n=t.length;i<n;i++)e+=t[i].length;const i=new Uint8Array(e);for(let e=0,n=0,s=t.length;e<s;e++){let s=t[e];i.set(s,n),n+=s.length}return i};let Yt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Yt=!1}const Ht=new Uint8Array(256);for(let t=0;t<256;t++)Ht[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Ht[254]=Ht[254]=1;var jt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,i,n,s,r,a=t.length,o=0;for(s=0;s<a;s++)i=t.charCodeAt(s),55296==(64512&i)&&s+1<a&&(n=t.charCodeAt(s+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),s++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(e=new Uint8Array(o),r=0,s=0;r<o;s++)i=t.charCodeAt(s),55296==(64512&i)&&s+1<a&&(n=t.charCodeAt(s+1),56320==(64512&n)&&(i=65536+(i-55296<<10)+(n-56320),s++)),i<128?e[r++]=i:i<2048?(e[r++]=192|i>>>6,e[r++]=128|63&i):i<65536?(e[r++]=224|i>>>12,e[r++]=128|i>>>6&63,e[r++]=128|63&i):(e[r++]=240|i>>>18,e[r++]=128|i>>>12&63,e[r++]=128|i>>>6&63,e[r++]=128|63&i);return e},Xt=(t,e)=>{const i=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,s;const r=new Array(2*i);for(s=0,n=0;n<i;){let e=t[n++];if(e<128){r[s++]=e;continue}let a=Ht[e];if(a>4)r[s++]=65533,n+=a-1;else{for(e&=2===a?31:3===a?15:7;a>1&&n<i;)e=e<<6|63&t[n++],a--;a>1?r[s++]=65533:e<65536?r[s++]=e:(e-=65536,r[s++]=55296|e>>10&1023,r[s++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Yt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let i="";for(let n=0;n<e;n++)i+=String.fromCharCode(t[n]);return i})(r,s)},Wt=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let i=e-1;for(;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Ht[t[i]]>e?i:e};var qt=function(){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};const $t=Object.prototype.toString,{Z_NO_FLUSH:Jt,Z_SYNC_FLUSH:Kt,Z_FULL_FLUSH:Qt,Z_FINISH:te,Z_OK:ee,Z_STREAM_END:ie,Z_DEFAULT_COMPRESSION:ne,Z_DEFAULT_STRATEGY:se,Z_DEFLATED:re}=j;function ae(t){this.options=Zt({level:ne,method:re,chunkSize:16384,windowBits:15,memLevel:8,strategy:se},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new qt,this.strm.avail_out=0;let i=Ut.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(i!==ee)throw new Error(H[i]);if(e.header&&Ut.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?jt(e.dictionary):"[object ArrayBuffer]"===$t.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,i=Ut.deflateSetDictionary(this.strm,t),i!==ee)throw new Error(H[i]);this._dict_set=!0}}function oe(t,e){const i=new ae(e);if(i.push(t,!0),i.err)throw i.msg||H[i.err];return i.result}ae.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize;let s,r;if(this.ended)return!1;for(r=e===~~e?e:!0===e?te:Jt,"string"==typeof t?i.input=jt(t):"[object ArrayBuffer]"===$t.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),(r===Kt||r===Qt)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(s=Ut.deflate(i,r),s===ie)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),s=Ut.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===ee;if(0!==i.avail_out){if(r>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},ae.prototype.onData=function(t){this.chunks.push(t)},ae.prototype.onEnd=function(t){t===ee&&(this.result=Gt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var le={Deflate:ae,deflate:oe,deflateRaw:function(t,e){return(e=e||{}).raw=!0,oe(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,oe(t,e)},constants:j};var he=function(t,e){let i,n,s,r,a,o,l,h,u,c,d,f,m,p,g,_,b,w,v,y,x,k,A,S;const E=t.state;i=t.next_in,A=t.input,n=i+(t.avail_in-5),s=t.next_out,S=t.output,r=s-(e-t.avail_out),a=s+(t.avail_out-257),o=E.dmax,l=E.wsize,h=E.whave,u=E.wnext,c=E.window,d=E.hold,f=E.bits,m=E.lencode,p=E.distcode,g=(1<<E.lenbits)-1,_=(1<<E.distbits)-1;t:do{f<15&&(d+=A[i++]<<f,f+=8,d+=A[i++]<<f,f+=8),b=m[d&g];e:for(;;){if(w=b>>>24,d>>>=w,f-=w,w=b>>>16&255,0===w)S[s++]=65535&b;else{if(!(16&w)){if(0==(64&w)){b=m[(65535&b)+(d&(1<<w)-1)];continue e}if(32&w){E.mode=12;break t}t.msg="invalid literal/length code",E.mode=30;break t}v=65535&b,w&=15,w&&(f<w&&(d+=A[i++]<<f,f+=8),v+=d&(1<<w)-1,d>>>=w,f-=w),f<15&&(d+=A[i++]<<f,f+=8,d+=A[i++]<<f,f+=8),b=p[d&_];i:for(;;){if(w=b>>>24,d>>>=w,f-=w,w=b>>>16&255,!(16&w)){if(0==(64&w)){b=p[(65535&b)+(d&(1<<w)-1)];continue i}t.msg="invalid distance code",E.mode=30;break t}if(y=65535&b,w&=15,f<w&&(d+=A[i++]<<f,f+=8,f<w&&(d+=A[i++]<<f,f+=8)),y+=d&(1<<w)-1,y>o){t.msg="invalid distance too far back",E.mode=30;break t}if(d>>>=w,f-=w,w=s-r,y>w){if(w=y-w,w>h&&E.sane){t.msg="invalid distance too far back",E.mode=30;break t}if(x=0,k=c,0===u){if(x+=l-w,w<v){v-=w;do{S[s++]=c[x++]}while(--w);x=s-y,k=S}}else if(u<w){if(x+=l+u-w,w-=u,w<v){v-=w;do{S[s++]=c[x++]}while(--w);if(x=0,u<v){w=u,v-=w;do{S[s++]=c[x++]}while(--w);x=s-y,k=S}}}else if(x+=u-w,w<v){v-=w;do{S[s++]=c[x++]}while(--w);x=s-y,k=S}for(;v>2;)S[s++]=k[x++],S[s++]=k[x++],S[s++]=k[x++],v-=3;v&&(S[s++]=k[x++],v>1&&(S[s++]=k[x++]))}else{x=s-y;do{S[s++]=S[x++],S[s++]=S[x++],S[s++]=S[x++],v-=3}while(v>2);v&&(S[s++]=S[x++],v>1&&(S[s++]=S[x++]))}break}}break}}while(i<n&&s<a);v=f>>3,i-=v,f-=v<<3,d&=(1<<f)-1,t.next_in=i,t.next_out=s,t.avail_in=i<n?n-i+5:5-(i-n),t.avail_out=s<a?a-s+257:257-(s-a),E.hold=d,E.bits=f};const ue=15,ce=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),de=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),fe=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),me=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var pe=(t,e,i,n,s,r,a,o)=>{const l=o.bits;let h,u,c,d,f,m,p=0,g=0,_=0,b=0,w=0,v=0,y=0,x=0,k=0,A=0,S=null,E=0;const I=new Uint16Array(16),N=new Uint16Array(16);let R,B,M,T=null,C=0;for(p=0;p<=ue;p++)I[p]=0;for(g=0;g<n;g++)I[e[i+g]]++;for(w=l,b=ue;b>=1&&0===I[b];b--);if(w>b&&(w=b),0===b)return s[r++]=20971520,s[r++]=20971520,o.bits=1,0;for(_=1;_<b&&0===I[_];_++);for(w<_&&(w=_),x=1,p=1;p<=ue;p++)if(x<<=1,x-=I[p],x<0)return-1;if(x>0&&(0===t||1!==b))return-1;for(N[1]=0,p=1;p<ue;p++)N[p+1]=N[p]+I[p];for(g=0;g<n;g++)0!==e[i+g]&&(a[N[e[i+g]]++]=g);if(0===t?(S=T=a,m=19):1===t?(S=ce,E-=257,T=de,C-=257,m=256):(S=fe,T=me,m=-1),A=0,g=0,p=_,f=r,v=w,y=0,c=-1,k=1<<w,d=k-1,1===t&&k>852||2===t&&k>592)return 1;for(;;){R=p-y,a[g]<m?(B=0,M=a[g]):a[g]>m?(B=T[C+a[g]],M=S[E+a[g]]):(B=96,M=0),h=1<<p-y,u=1<<v,_=u;do{u-=h,s[f+(A>>y)+u]=R<<24|B<<16|M|0}while(0!==u);for(h=1<<p-1;A&h;)h>>=1;if(0!==h?(A&=h-1,A+=h):A=0,g++,0==--I[p]){if(p===b)break;p=e[i+a[g]]}if(p>w&&(A&d)!==c){for(0===y&&(y=w),f+=_,v=p-y,x=1<<v;v+y<b&&(x-=I[v+y],!(x<=0));)v++,x<<=1;if(k+=1<<v,1===t&&k>852||2===t&&k>592)return 1;c=A&d,s[c]=w<<24|v<<16|f-r|0}}return 0!==A&&(s[f+A]=p-y<<24|64<<16|0),o.bits=w,0};const{Z_FINISH:ge,Z_BLOCK:_e,Z_TREES:be,Z_OK:we,Z_STREAM_END:ve,Z_NEED_DICT:ye,Z_STREAM_ERROR:xe,Z_DATA_ERROR:ke,Z_MEM_ERROR:Ae,Z_BUF_ERROR:Se,Z_DEFLATED:Ee}=j,Ie=12,Ne=30,Re=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Be(){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 Me=t=>{if(!t||!t.state)return xe;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,we},Te=t=>{if(!t||!t.state)return xe;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Me(t)},Ce=(t,e)=>{let i;if(!t||!t.state)return xe;const n=t.state;return e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?xe:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=i,n.wbits=e,Te(t))},Oe=(t,e)=>{if(!t)return xe;const i=new Be;t.state=i,i.window=null;const n=Ce(t,e);return n!==we&&(t.state=null),n};let Pe,Fe,Le=!0;const De=t=>{if(Le){Pe=new Int32Array(512),Fe=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(pe(1,t.lens,0,288,Pe,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;pe(2,t.lens,0,32,Fe,0,t.work,{bits:5}),Le=!1}t.lencode=Pe,t.lenbits=9,t.distcode=Fe,t.distbits=5},ze=(t,e,i,n)=>{let s;const r=t.state;return null===r.window&&(r.wsize=1<<r.wbits,r.wnext=0,r.whave=0,r.window=new Uint8Array(r.wsize)),n>=r.wsize?(r.window.set(e.subarray(i-r.wsize,i),0),r.wnext=0,r.whave=r.wsize):(s=r.wsize-r.wnext,s>n&&(s=n),r.window.set(e.subarray(i-n,i-n+s),r.wnext),(n-=s)?(r.window.set(e.subarray(i-n,i),0),r.wnext=n,r.whave=r.wsize):(r.wnext+=s,r.wnext===r.wsize&&(r.wnext=0),r.whave<r.wsize&&(r.whave+=s))),0};var Ue=(t,e)=>{let i,n,s,r,a,o,l,h,u,c,d,f,m,p,g,_,b,w,v,y,x,k,A=0;const S=new Uint8Array(4);let E,I;const N=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return xe;i=t.state,i.mode===Ie&&(i.mode=13),a=t.next_out,s=t.output,l=t.avail_out,r=t.next_in,n=t.input,o=t.avail_in,h=i.hold,u=i.bits,c=o,d=l,k=we;t:for(;;)switch(i.mode){case 1:if(0===i.wrap){i.mode=13;break}for(;u<16;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(2&i.wrap&&35615===h){i.check=0,S[0]=255&h,S[1]=h>>>8&255,i.check=Y(i.check,S,2,0),h=0,u=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",i.mode=Ne;break}if((15&h)!==Ee){t.msg="unknown compression method",i.mode=Ne;break}if(h>>>=4,u-=4,x=8+(15&h),0===i.wbits)i.wbits=x;else if(x>i.wbits){t.msg="invalid window size",i.mode=Ne;break}i.dmax=1<<i.wbits,t.adler=i.check=1,i.mode=512&h?10:Ie,h=0,u=0;break;case 2:for(;u<16;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(i.flags=h,(255&i.flags)!==Ee){t.msg="unknown compression method",i.mode=Ne;break}if(57344&i.flags){t.msg="unknown header flags set",i.mode=Ne;break}i.head&&(i.head.text=h>>8&1),512&i.flags&&(S[0]=255&h,S[1]=h>>>8&255,i.check=Y(i.check,S,2,0)),h=0,u=0,i.mode=3;case 3:for(;u<32;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}i.head&&(i.head.time=h),512&i.flags&&(S[0]=255&h,S[1]=h>>>8&255,S[2]=h>>>16&255,S[3]=h>>>24&255,i.check=Y(i.check,S,4,0)),h=0,u=0,i.mode=4;case 4:for(;u<16;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}i.head&&(i.head.xflags=255&h,i.head.os=h>>8),512&i.flags&&(S[0]=255&h,S[1]=h>>>8&255,i.check=Y(i.check,S,2,0)),h=0,u=0,i.mode=5;case 5:if(1024&i.flags){for(;u<16;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}i.length=h,i.head&&(i.head.extra_len=h),512&i.flags&&(S[0]=255&h,S[1]=h>>>8&255,i.check=Y(i.check,S,2,0)),h=0,u=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&(f=i.length,f>o&&(f=o),f&&(i.head&&(x=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(n.subarray(r,r+f),x)),512&i.flags&&(i.check=Y(i.check,n,f,r)),o-=f,r+=f,i.length-=f),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===o)break t;f=0;do{x=n[r+f++],i.head&&x&&i.length<65536&&(i.head.name+=String.fromCharCode(x))}while(x&&f<o);if(512&i.flags&&(i.check=Y(i.check,n,f,r)),o-=f,r+=f,x)break t}else i.head&&(i.head.name=null);i.length=0,i.mode=8;case 8:if(4096&i.flags){if(0===o)break t;f=0;do{x=n[r+f++],i.head&&x&&i.length<65536&&(i.head.comment+=String.fromCharCode(x))}while(x&&f<o);if(512&i.flags&&(i.check=Y(i.check,n,f,r)),o-=f,r+=f,x)break t}else i.head&&(i.head.comment=null);i.mode=9;case 9:if(512&i.flags){for(;u<16;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(h!==(65535&i.check)){t.msg="header crc mismatch",i.mode=Ne;break}h=0,u=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=Ie;break;case 10:for(;u<32;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}t.adler=i.check=Re(h),h=0,u=0,i.mode=11;case 11:if(0===i.havedict)return t.next_out=a,t.avail_out=l,t.next_in=r,t.avail_in=o,i.hold=h,i.bits=u,ye;t.adler=i.check=1,i.mode=Ie;case Ie:if(e===_e||e===be)break t;case 13:if(i.last){h>>>=7&u,u-=7&u,i.mode=27;break}for(;u<3;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}switch(i.last=1&h,h>>>=1,u-=1,3&h){case 0:i.mode=14;break;case 1:if(De(i),i.mode=20,e===be){h>>>=2,u-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=Ne}h>>>=2,u-=2;break;case 14:for(h>>>=7&u,u-=7&u;u<32;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if((65535&h)!=(h>>>16^65535)){t.msg="invalid stored block lengths",i.mode=Ne;break}if(i.length=65535&h,h=0,u=0,i.mode=15,e===be)break t;case 15:i.mode=16;case 16:if(f=i.length,f){if(f>o&&(f=o),f>l&&(f=l),0===f)break t;s.set(n.subarray(r,r+f),a),o-=f,r+=f,l-=f,a+=f,i.length-=f;break}i.mode=Ie;break;case 17:for(;u<14;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(i.nlen=257+(31&h),h>>>=5,u-=5,i.ndist=1+(31&h),h>>>=5,u-=5,i.ncode=4+(15&h),h>>>=4,u-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=Ne;break}i.have=0,i.mode=18;case 18:for(;i.have<i.ncode;){for(;u<3;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}i.lens[N[i.have++]]=7&h,h>>>=3,u-=3}for(;i.have<19;)i.lens[N[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,E={bits:i.lenbits},k=pe(0,i.lens,0,19,i.lencode,0,i.work,E),i.lenbits=E.bits,k){t.msg="invalid code lengths set",i.mode=Ne;break}i.have=0,i.mode=19;case 19:for(;i.have<i.nlen+i.ndist;){for(;A=i.lencode[h&(1<<i.lenbits)-1],g=A>>>24,_=A>>>16&255,b=65535&A,!(g<=u);){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(b<16)h>>>=g,u-=g,i.lens[i.have++]=b;else{if(16===b){for(I=g+2;u<I;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(h>>>=g,u-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=Ne;break}x=i.lens[i.have-1],f=3+(3&h),h>>>=2,u-=2}else if(17===b){for(I=g+3;u<I;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}h>>>=g,u-=g,x=0,f=3+(7&h),h>>>=3,u-=3}else{for(I=g+7;u<I;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}h>>>=g,u-=g,x=0,f=11+(127&h),h>>>=7,u-=7}if(i.have+f>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=Ne;break}for(;f--;)i.lens[i.have++]=x}}if(i.mode===Ne)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=Ne;break}if(i.lenbits=9,E={bits:i.lenbits},k=pe(1,i.lens,0,i.nlen,i.lencode,0,i.work,E),i.lenbits=E.bits,k){t.msg="invalid literal/lengths set",i.mode=Ne;break}if(i.distbits=6,i.distcode=i.distdyn,E={bits:i.distbits},k=pe(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,E),i.distbits=E.bits,k){t.msg="invalid distances set",i.mode=Ne;break}if(i.mode=20,e===be)break t;case 20:i.mode=21;case 21:if(o>=6&&l>=258){t.next_out=a,t.avail_out=l,t.next_in=r,t.avail_in=o,i.hold=h,i.bits=u,he(t,d),a=t.next_out,s=t.output,l=t.avail_out,r=t.next_in,n=t.input,o=t.avail_in,h=i.hold,u=i.bits,i.mode===Ie&&(i.back=-1);break}for(i.back=0;A=i.lencode[h&(1<<i.lenbits)-1],g=A>>>24,_=A>>>16&255,b=65535&A,!(g<=u);){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(_&&0==(240&_)){for(w=g,v=_,y=b;A=i.lencode[y+((h&(1<<w+v)-1)>>w)],g=A>>>24,_=A>>>16&255,b=65535&A,!(w+g<=u);){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}h>>>=w,u-=w,i.back+=w}if(h>>>=g,u-=g,i.back+=g,i.length=b,0===_){i.mode=26;break}if(32&_){i.back=-1,i.mode=Ie;break}if(64&_){t.msg="invalid literal/length code",i.mode=Ne;break}i.extra=15&_,i.mode=22;case 22:if(i.extra){for(I=i.extra;u<I;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}i.length+=h&(1<<i.extra)-1,h>>>=i.extra,u-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;A=i.distcode[h&(1<<i.distbits)-1],g=A>>>24,_=A>>>16&255,b=65535&A,!(g<=u);){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(0==(240&_)){for(w=g,v=_,y=b;A=i.distcode[y+((h&(1<<w+v)-1)>>w)],g=A>>>24,_=A>>>16&255,b=65535&A,!(w+g<=u);){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}h>>>=w,u-=w,i.back+=w}if(h>>>=g,u-=g,i.back+=g,64&_){t.msg="invalid distance code",i.mode=Ne;break}i.offset=b,i.extra=15&_,i.mode=24;case 24:if(i.extra){for(I=i.extra;u<I;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}i.offset+=h&(1<<i.extra)-1,h>>>=i.extra,u-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=Ne;break}i.mode=25;case 25:if(0===l)break t;if(f=d-l,i.offset>f){if(f=i.offset-f,f>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=Ne;break}f>i.wnext?(f-=i.wnext,m=i.wsize-f):m=i.wnext-f,f>i.length&&(f=i.length),p=i.window}else p=s,m=a-i.offset,f=i.length;f>l&&(f=l),l-=f,i.length-=f;do{s[a++]=p[m++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===l)break t;s[a++]=i.length,l--,i.mode=21;break;case 27:if(i.wrap){for(;u<32;){if(0===o)break t;o--,h|=n[r++]<<u,u+=8}if(d-=l,t.total_out+=d,i.total+=d,d&&(t.adler=i.check=i.flags?Y(i.check,s,d,a-d):Z(i.check,s,d,a-d)),d=l,(i.flags?h:Re(h))!==i.check){t.msg="incorrect data check",i.mode=Ne;break}h=0,u=0}i.mode=28;case 28:if(i.wrap&&i.flags){for(;u<32;){if(0===o)break t;o--,h+=n[r++]<<u,u+=8}if(h!==(4294967295&i.total)){t.msg="incorrect length check",i.mode=Ne;break}h=0,u=0}i.mode=29;case 29:k=ve;break t;case Ne:k=ke;break t;case 31:return Ae;default:return xe}return t.next_out=a,t.avail_out=l,t.next_in=r,t.avail_in=o,i.hold=h,i.bits=u,(i.wsize||d!==t.avail_out&&i.mode<Ne&&(i.mode<27||e!==ge))&&ze(t,t.output,t.next_out,d-t.avail_out),c-=t.avail_in,d-=t.avail_out,t.total_in+=c,t.total_out+=d,i.total+=d,i.wrap&&d&&(t.adler=i.check=i.flags?Y(i.check,s,d,t.next_out-d):Z(i.check,s,d,t.next_out-d)),t.data_type=i.bits+(i.last?64:0)+(i.mode===Ie?128:0)+(20===i.mode||15===i.mode?256:0),(0===c&&0===d||e===ge)&&k===we&&(k=Se),k},Ve={inflateReset:Te,inflateReset2:Ce,inflateResetKeep:Me,inflateInit:t=>Oe(t,15),inflateInit2:Oe,inflate:Ue,inflateEnd:t=>{if(!t||!t.state)return xe;let e=t.state;return e.window&&(e.window=null),t.state=null,we},inflateGetHeader:(t,e)=>{if(!t||!t.state)return xe;const i=t.state;return 0==(2&i.wrap)?xe:(i.head=e,e.done=!1,we)},inflateSetDictionary:(t,e)=>{const i=e.length;let n,s,r;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?xe:11===n.mode&&(s=1,s=Z(s,e,i,0),s!==n.check)?ke:(r=ze(t,e,i,i),r?(n.mode=31,Ae):(n.havedict=1,we))):xe},inflateInfo:"pako inflate (from Nodeca project)"};var Ze=function(){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};const Ge=Object.prototype.toString,{Z_NO_FLUSH:Ye,Z_FINISH:He,Z_OK:je,Z_STREAM_END:Xe,Z_NEED_DICT:We,Z_STREAM_ERROR:qe,Z_DATA_ERROR:$e,Z_MEM_ERROR:Je}=j;function Ke(t){this.options=Zt({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new qt,this.strm.avail_out=0;let i=Ve.inflateInit2(this.strm,e.windowBits);if(i!==je)throw new Error(H[i]);if(this.header=new Ze,Ve.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=jt(e.dictionary):"[object ArrayBuffer]"===Ge.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(i=Ve.inflateSetDictionary(this.strm,e.dictionary),i!==je)))throw new Error(H[i])}function Qe(t,e){const i=new Ke(e);if(i.push(t),i.err)throw i.msg||H[i.err];return i.result}Ke.prototype.push=function(t,e){const i=this.strm,n=this.options.chunkSize,s=this.options.dictionary;let r,a,o;if(this.ended)return!1;for(a=e===~~e?e:!0===e?He:Ye,"[object ArrayBuffer]"===Ge.call(t)?i.input=new Uint8Array(t):i.input=t,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(n),i.next_out=0,i.avail_out=n),r=Ve.inflate(i,a),r===We&&s&&(r=Ve.inflateSetDictionary(i,s),r===je?r=Ve.inflate(i,a):r===$e&&(r=We));i.avail_in>0&&r===Xe&&i.state.wrap>0&&0!==t[i.next_in];)Ve.inflateReset(i),r=Ve.inflate(i,a);switch(r){case qe:case $e:case We:case Je:return this.onEnd(r),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||r===Xe))if("string"===this.options.to){let t=Wt(i.output,i.next_out),e=i.next_out-t,s=Xt(i.output,t);i.next_out=e,i.avail_out=n-e,e&&i.output.set(i.output.subarray(t,t+e),0),this.onData(s)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(r!==je||0!==o){if(r===Xe)return r=Ve.inflateEnd(this.strm),this.onEnd(r),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Ke.prototype.onData=function(t){this.chunks.push(t)},Ke.prototype.onEnd=function(t){t===je&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Gt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var ti={Inflate:Ke,inflate:Qe,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Qe(t,e)},ungzip:Qe,constants:j};const{Deflate:ei,deflate:ii,deflateRaw:ni,gzip:si}=le,{Inflate:ri,inflate:ai,inflateRaw:oi,ungzip:li}=ti;var hi={Deflate:ei,deflate:ii,deflateRaw:ni,gzip:si,Inflate:ri,inflate:ai,inflateRaw:oi,ungzip:li,constants:j};const ui={end:0,byte:1,short:2,int:3,long:4,float:5,double:6,byteArray:7,string:8,list:9,compound:10,intArray:11,longArray:12},ci=["end","byte","short","int","long","float","double","byteArray","string","list","compound","intArray","longArray"];class di{constructor(t,e={}){var i,n;this.byte=this.readNum.bind(this,"getInt8",1),this.short=this.readNum.bind(this,"getInt16",2),this.int=this.readNum.bind(this,"getInt32",4),this.float=this.readNum.bind(this,"getFloat32",4),this.double=this.readNum.bind(this,"getFloat64",8),this.offset=null!=(i=e.offset)?i:0,this.littleEndian=null!=(n=e.littleEndian)&&n,this.array=t,this.view=new DataView(t.buffer,t.byteOffset)}end(){return null}readNum(t,e){const i=this.view[t](this.offset,this.littleEndian);return this.offset+=e,i}long(){return[this.int(),this.int()]}byteArray(){const t=this.int(),e=[];for(let i=0;i<t;i++)e.push(this.byte());return e}intArray(){const t=this.int(),e=[];for(let i=0;i<t;i++)e.push(this.int());return e}longArray(){const t=this.int(),e=[];for(let i=0;i<t;i++)e.push(this.long());return e}string(){const t=this.short(),e=this.array.slice(this.offset,this.offset+t);return this.offset+=t,function(t){var e,i=[];for(e=0;e<t.length;e++)0==(128&t[e])?i.push(127&t[e]):e+1<t.length&&192==(224&t[e])&&128==(192&t[e+1])?i.push((31&t[e])<<6|63&t[e+1]):e+2<t.length&&224==(240&t[e])&&128==(192&t[e+1])&&128==(192&t[e+2])?i.push((15&t[e])<<12|(63&t[e+1])<<6|63&t[e+2]):e+3<t.length&&240==(248&t[e])&&128==(192&t[e+1])&&128==(192&t[e+2])&&128==(192&t[e+3])&&i.push((7&t[e])<<18|(63&t[e+1])<<12|(63&t[e+2])<<6|63&t[e+3]);return String.fromCharCode.apply(null,i)}(e)}list(){const t=ci[this.byte()],e=this.int(),i=[];for(let n=0;n<e;n++)i.push(this[t]());return{type:t,value:i}}compound(){const t={};for(;;){const e=ci[this.byte()];if("end"===e)break;const i=this.string(),n=this[e]();t[i]={type:e,value:n}}return t}}class fi{constructor(t={}){var e,i;this.byte=this.writeNum.bind(this,"setInt8",1),this.short=this.writeNum.bind(this,"setInt16",2),this.int=this.writeNum.bind(this,"setInt32",4),this.float=this.writeNum.bind(this,"setFloat32",4),this.double=this.writeNum.bind(this,"setFloat64",8),this.offset=null!=(e=t.offset)?e:0,this.littleEndian=null!=(i=t.littleEndian)&&i,this.buffer=new ArrayBuffer(1024),this.array=new Uint8Array(this.buffer),this.view=new DataView(this.buffer)}accommodate(t){const e=this.offset+t;if(this.buffer.byteLength>=e)return;let i=this.buffer.byteLength;for(;i<e;)i*=2;const n=new ArrayBuffer(i),s=new Uint8Array(n);s.set(this.array),this.offset>this.buffer.byteLength&&s.fill(0,this.buffer.byteLength,this.offset),this.buffer=n,this.view=new DataView(n),this.array=s}getData(){return this.accommodate(0),this.array.slice(0,this.offset)}end(){}writeNum(t,e,i){this.accommodate(e),this.view[t](this.offset,i,this.littleEndian),this.offset+=e}long(t){this.int(t[0]),this.int(t[1])}byteArray(t){this.int(t.length),this.accommodate(t.length),this.array.set(t,this.offset),this.offset+=t.length}intArray(t){this.int(t.length);for(let e=0;e<t.length;e++)this.int(t[e])}longArray(t){this.int(t.length);for(let e=0;e<t.length;e++)this.long(t[e])}string(t){const e=function(t){var e,i,n=[];for(e=0;e<t.length;e++)(i=t.charCodeAt(e))<128?n.push(i):i<2048?(n.push(192|i>>6),n.push(128|63&i)):i<65536?(n.push(224|i>>12),n.push(128|i>>6&63),n.push(128|63&i)):(n.push(240|i>>18&7),n.push(128|i>>12&63),n.push(128|i>>6&63),n.push(128|63&i));return n}(t);this.short(e.length),this.accommodate(e.length),this.array.set(e,this.offset),this.offset+=e.length}list(t){this.byte(ui[t.type]),this.int(t.value.length),t.value;for(let e=0;e<t.value.length;e++)this[t.type](t.value[e])}compound(t){for(const e in t)this.byte(ui[t[e].type]),this.string(e),this[t[e].type](t[e].value);this.byte(ui.end)}}var mi,pi=Object.defineProperty,gi=Object.getOwnPropertySymbols,_i=Object.prototype.hasOwnProperty,bi=Object.prototype.propertyIsEnumerable,wi=(t,e,i)=>e in t?pi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,vi=(t,e)=>{for(var i in e||(e={}))_i.call(e,i)&&wi(t,i,e[i]);if(gi)for(var i of gi(e))bi.call(e,i)&&wi(t,i,e[i]);return t};function yi(t,e={}){const i=!1===e.bedrockHeader?void 0:function(t){const e=t.slice(0,8),i=new DataView(e.buffer,e.byteOffset),n=i.getUint32(0,!0),s=i.getUint32(4,!0);if(8===e.length&&n>0&&n<100&&s===t.byteLength-8)return n}(t),n="gzip"===e.compression||!i&&void 0===e.compression&&function(t){var e=t.slice(0,2);return 2===e.length&&31===e[0]&&139===e[1]}(t),s="zlib"===e.compression||!i&&void 0===e.compression&&function(t){const e=t.slice(0,2);return 2===e.length&&120===e[0]&&(1===e[1]||94===e[1]||156===e[1]||218===e[2])}(t),r=s||n?hi.inflate(t):t,a=!0===e.littleEndian||void 0!==i,{name:o,value:l}=xi(r,a,i&&8);return vi(vi(vi({value:l,name:o},n||s?{compression:n?"gzip":"zlib"}:{}),a?{littleEndian:a}:{}),i?{bedrockHeader:i}:{})}function xi(t,e,i){const n=new di(t,{littleEndian:e,offset:i});if(n.byte()!==ui.compound)throw new Error("Top tag should be a compound");return{name:n.string(),value:n.compound()}}function ki(t,e={}){var i;const n=!0===e.littleEndian||void 0!==e.bedrockHeader,s=Ai({value:t,name:null!=(i=e.name)?i:""},n,e.bedrockHeader&&8);if(e.bedrockHeader){const t=new DataView(s.buffer);t.setInt32(0,e.bedrockHeader,!0),t.setInt32(4,s.byteLength-8,!0)}return"gzip"===e.compression?hi.gzip(s):"zlib"===e.compression?hi.deflate(s):s}function Ai(t,e,i){const n=new fi({littleEndian:e,offset:i});return n.byte(ui.compound),n.string(t.name),n.compound(t.value),n.getData()}function Si(t,e,i){if(!t[e])throw new Error(`Missing ${e} tag`);if(t[e].type!==i)throw new Error(`Expected ${e} to be of type ${i}, but found ${t[e].type}`);return t[e].value}function Ei(t,e,i,n){const s=Si(t,e,"list");if(s.type!==i)throw new Error(`Expected ${e} to be a list of ${i}s, but found ${s.type}s`);if(n&&s.value.length!==n)throw new Error(`Expected ${e} to be a list of length ${n}, but found length ${s.value.length}`);return s.value}function Ii(t,e){try{return t()}catch(t){return e}}function Ni(t){let e=null;return()=>(null==e&&(e=t()),e)}function Ri(t,e,i){const n=t.get(e);if(n)return n;const s=i(e);return t.set(e,s),s}!function(t){function e(t){return"object"==typeof t&&null!==t?t:void 0}t.readNumber=function(t){return"number"==typeof t?t:void 0},t.readInt=function(t){return"number"==typeof t?Math.floor(t):void 0},t.readString=function(t){return"string"==typeof t?t:void 0},t.readBoolean=function(t){return"boolean"==typeof t?t:void 0},t.readObject=e,t.readArray=function(t,e){if(Array.isArray(t))return t.map((t=>e(t)))},t.readMap=function(t,i){var n;const s=null!=(n=e(t))?n:{};return Object.fromEntries(Object.entries(s).map((([t,e])=>[t,i(e)])))},t.compose=function(t,e,i){const n=e(t);return n?i(n):void 0},t.readEnum=function(t,e){return"string"!=typeof t?e[0]:e.includes(t)?t:e[0]}}(mi||(mi={}));const Bi=class{constructor(t,e){if(this.namespace=t,this.path=e,!t.match(/^[a-z0-9._-]+$/))throw new Error(`Non [a-z0-9._-] character in namespace of ${t}:${e}`);if(!e.match(/^[a-z0-9/._-]+$/))throw new Error(`Non [a-z0-9/._-] character in path of ${t}:${e}`)}equals(t){return this===t||this.namespace===t.namespace&&this.path===t.path}toString(){return`${this.namespace}:${this.path}`}static create(t){return new Bi(this.DEFAULT_NAMESPACE,t)}static parse(t){const e=t.indexOf(this.SEPARATOR);if(e>=0){const i=e>=1?t.substring(0,e):this.DEFAULT_NAMESPACE,n=t.substring(e+1);return new Bi(i,n)}return new Bi(this.DEFAULT_NAMESPACE,t)}};let Mi=Bi;Mi.DEFAULT_NAMESPACE="minecraft",Mi.SEPARATOR=":";var Ti=Object.defineProperty,Ci=Object.defineProperties,Oi=Object.getOwnPropertyDescriptors,Pi=Object.getOwnPropertySymbols,Fi=Object.prototype.hasOwnProperty,Li=Object.prototype.propertyIsEnumerable,Di=(t,e,i)=>e in t?Ti(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;const zi=class{constructor(t,e={}){this.properties=e,this.name="string"==typeof t?Mi.parse(t):t}getName(){return this.name}getProperties(){return this.properties}getProperty(t){return this.properties[t]}isFluid(){return this.is(zi.WATER)||this.is(zi.LAVA)}equals(t){return!!this.name.equals(t.name)&&Object.keys(this.properties).every((e=>t.properties[e]===this.properties[e]))}is(t){return this.name.equals(t.name)}toString(){return 0===Object.keys(this.properties).length?this.name.toString():`${this.name.toString()}[${Object.entries(this.properties).map((([t,e])=>t+"="+e)).join(",")}]`}static fromNbt(t){const e=Mi.parse(Si(t.value,"Name","string")),i=Ii((()=>Si(t.value,"Properties","compound")),{}),n=Object.keys(i).reduce(((t,e)=>{return n=((t,e)=>{for(var i in e||(e={}))Fi.call(e,i)&&Di(t,i,e[i]);if(Pi)for(var i of Pi(e))Li.call(e,i)&&Di(t,i,e[i]);return t})({},t),s={[e]:Si(i,e,"string")},Ci(n,Oi(s));var n,s}),{});return new zi(e,n)}static fromJson(t){var e,i;const n=null!=(e=mi.readObject(t))?e:{},s=Mi.parse(null!=(i=mi.readString(n.Name))?i:zi.STONE.name.toString()),r=mi.readMap(n.Properties,(t=>{var e;return null!=(e=mi.readString(t))?e:""}));return new zi(s,r)}};let Ui=zi;Ui.AIR=new zi(Mi.create("air")),Ui.STONE=new zi(Mi.create("stone")),Ui.WATER=new zi(Mi.create("water"),{level:"0"}),Ui.LAVA=new zi(Mi.create("lava"),{level:"0"});const Vi=class{constructor(t){this.minY=t,this.storage=Array(Vi.SIZE).fill(0),this.palette=[Ui.AIR]}get minBlockY(){return this.minY<<4}index(t,e,i){return(t<<8)+(e<<4)+i}getBlockState(t,e,i){var n;const s=this.storage[this.index(t,e,i)];return null!=(n=this.palette[s])?n:Ui.AIR}setBlockState(t,e,i,n){let s=this.palette.findIndex((t=>t.equals(n)));-1===s&&(s=this.palette.length,this.palette.push(n)),this.storage[this.index(t,e,i)]=s}};let Zi=Vi;Zi.WIDTH=16,Zi.SIZE=Vi.WIDTH*Vi.WIDTH*Vi.WIDTH;t.ChunkPos=void 0,function(t){function e(t,e){return BigInt(4294967295&t)|BigInt(4294967295&e)<<BigInt(32)}t.create=function(t,e){return[t,e]},t.fromBlockPos=function(t){return[t[0]>>4,t[2]>>4]},t.fromLong=function(t){return[4294967295&Number(t),Number(t>>BigInt(32))]},t.toLong=function(t){return e(t[0],t[1])},t.asLong=e,t.minBlockX=function(t){return t[0]<<4},t.minBlockZ=function(t){return t[1]<<4},t.maxBlockX=function(t){return 15+(t[0]<<4)},t.maxBlockZ=function(t){return 15+(t[1]<<4)}}(t.ChunkPos||(t.ChunkPos={})),t.Holder=void 0,function(t){function e(t){return{value:()=>t,key:()=>{}}}function i(t,e){return{value:()=>t.getOrThrow(e),key:()=>e}}t.parser=function(t,n){return s=>"string"==typeof s?i(t,Mi.parse(s)):e(n(s))},t.direct=e,t.reference=i}(t.Holder||(t.Holder={}));const Gi=class{constructor(t,e){this.key=t,this.parser=e,this.storage=new Map,this.builtin=new Map}register(e,i,n){return this.storage.set(e.toString(),i),n&&this.builtin.set(e.toString(),i),t.Holder.reference(this,e)}keys(){return[...this.storage.keys()].map((t=>Mi.parse(t)))}get(t){return this.storage.get(t.toString())}getOrThrow(t){const e=this.storage.get(t.toString());if(void 0===e)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}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 Gi(this.key,this.parser)}};let Yi=Gi;Yi.REGISTRY=new Gi(Mi.create("root"));class Hi{constructor(t,e=[],i=[]){this.size=t,this.palette=e,this.blocks=i,this.blocksMap=[],i.forEach((e=>{if(!this.isInside(e.pos))throw new Error(`Found block at ${e.pos} which is outside the structure bounds ${this.size}`);this.blocksMap[e.pos[0]*t[1]*t[2]+e.pos[1]*t[2]+e.pos[2]]=e}))}getSize(){return this.size}addBlock(t,e,i,n){if(!this.isInside(t))throw new Error(`Cannot add block at ${t} outside the structure bounds ${this.size}`);const s=new Ui(e,i);let r=this.palette.findIndex((t=>t.equals(s)));return-1===r&&(r=this.palette.length,this.palette.push(s)),this.blocks.push({pos:t,state:r,nbt:n}),this.blocksMap[t[0]*this.size[1]*this.size[2]+t[1]*this.size[2]+t[2]]={pos:t,state:r,nbt:n},this}getBlocks(){return this.blocks.map((t=>({pos:t.pos,state:this.palette[t.state],nbt:t.nbt})))}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]];if(!e)return null;return{pos:e.pos,state:this.palette[e.state],nbt:e.nbt}}isInside(t){return t[0]>=0&&t[0]<this.size[0]&&t[1]>=0&&t[1]<this.size[1]&&t[2]>=0&&t[2]<this.size[2]}static fromNbt(t){const e=Ei(t.value,"size","int",3),i=Ei(t.value,"palette","compound").map((t=>Ui.fromNbt({name:"",value:t}))),n=Ei(t.value,"blocks","compound").map((t=>({pos:Ei(t,"pos","int",3),state:Si(t,"state","int"),nbt:Ii((()=>Si(t,"nbt","compound")),void 0)})));return new Hi(e,i,n)}}function ji(t){return t*t}function Xi(t,e,i){return Math.max(e,Math.min(i,t))}function Wi(t,e,i){return e+t*(i-e)}function qi(t,e,i,n,s,r){return Wi(e,Wi(t,i,n),Wi(t,s,r))}function $i(t,e,i,n,s,r,a,o,l,h,u){return Wi(i,qi(t,e,n,s,r,a),qi(t,e,o,l,h,u))}function Ji(t,e,i){return 0===t?e():1===t?i():e()+t*(i()-e())}function Ki(t,e,i,n,s,r){return Ji(e,(()=>Ji(t,i,n)),(()=>Ji(t,s,r)))}function Qi(t,e,i,n,s,r,a,o,l,h,u){return Ji(i,(()=>Ki(t,e,n,s,r,a)),(()=>Ki(t,e,o,l,h,u)))}function tn(t,e,i){return i<0?t:i>1?e:Wi(i,t,e)}function en(t,e,i){return(t-e)/(i-e)}function nn(t){return t*t*t*(t*(6*t-15)+10)}function sn(t,e,i,n,s){return Wi(en(t,e,i),n,s)}function rn(t,e,i,n,s){return tn(n,s,en(t,e,i))}function an(t,e,i){let n=e-t;for(;n>0;){const e=Math.floor(n/2),s=t+e;i(s)?n=e:(t=s+1,n-=e+1)}return t}function on(t,e,i){let n=BigInt(3129871*t)^BigInt(i)*BigInt(116129781)^BigInt(e);return n=n*n*BigInt(42317861)+n*BigInt(11),n>>BigInt(16)}function ln(t,e,i,n,s,r,a,o){return BigInt(t)<<BigInt(56)|BigInt(e)<<BigInt(48)|BigInt(i)<<BigInt(40)|BigInt(n)<<BigInt(32)|BigInt(s)<<BigInt(24)|BigInt(r)<<BigInt(16)|BigInt(a)<<BigInt(8)|BigInt(o)}function hn(t){return 0==(t&t-1)}function un(t){return t-=1,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>18,(t|=t>>32)+1}t.MinMaxNumberFunction=void 0,(t.MinMaxNumberFunction||(t.MinMaxNumberFunction={})).is=function(t){return"object"==typeof t&&null!==t&&"minValue"in t&&"maxValue"in t},t.CubicSpline=void 0,function(e){e.fromJson=function t(e,s){var r,a,o,l;if("number"==typeof e)return new i(e);const h=null!=(r=mi.readObject(e))?r:{},u=new n(s(h.coordinate)),c=null!=(a=mi.readArray(h.points,(t=>{var e;return null!=(e=mi.readObject(t))?e:{}})))?a:[];if(0===c.length)return new i(0);for(const e of c){const i=null!=(o=mi.readNumber(e.location))?o:0,n=t(e.value,s),r=null!=(l=mi.readNumber(e.derivative))?l:0;u.addPoint(i,n,r)}return u};class i{constructor(t){this.value=t}compute(){return this.value}min(){return this.value}max(){return this.value}mapAll(){return this}calculateMinMax(){}}e.Constant=i;class n{constructor(t,e=[],i=[],n=[]){this.coordinate=t,this.locations=e,this.values=i,this.derivatives=n,this.calculatedMin=Number.NEGATIVE_INFINITY,this.calculatedMax=Number.POSITIVE_INFINITY}compute(t){const e=this.coordinate.compute(t),i=an(0,this.locations.length,(t=>e<this.locations[t]))-1,n=this.locations.length-1;if(i<0)return this.values[0].compute(t)+this.derivatives[0]*(e-this.locations[0]);if(i===n)return this.values[n].compute(t)+this.derivatives[n]*(e-this.locations[n]);const s=this.locations[i],r=this.locations[i+1],a=this.derivatives[i],o=this.derivatives[i+1],l=(e-s)/(r-s),h=this.values[i].compute(t),u=this.values[i+1].compute(t),c=a*(r-s)-(u-h),d=-o*(r-s)+(u-h);return Wi(l,h,u)+l*(1-l)*Wi(l,c,d)}min(){return this.calculatedMin}max(){return this.calculatedMax}mapAll(t){return new n(t(this.coordinate),this.locations,this.values.map((e=>e.mapAll(t))),this.derivatives)}addPoint(t,i,n=0){return this.locations.push(t),this.values.push("number"==typeof i?new e.Constant(i):i),this.derivatives.push(n),this}calculateMinMax(){if(!t.MinMaxNumberFunction.is(this.coordinate))return;const e=this.locations.length-1;var i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const r=this.coordinate.minValue(),a=this.coordinate.maxValue();for(const t of this.values)t.calculateMinMax();if(r<this.locations[0]){const t=n.linearExtend(r,this.locations,this.values[0].min(),this.derivatives,0),e=n.linearExtend(r,this.locations,this.values[0].max(),this.derivatives,0);i=Math.min(i,Math.min(t,e)),s=Math.max(s,Math.max(t,e))}if(a>this.locations[e]){const t=n.linearExtend(a,this.locations,this.values[e].min(),this.derivatives,e),r=n.linearExtend(a,this.locations,this.values[e].max(),this.derivatives,e);i=Math.min(i,Math.min(t,r)),s=Math.max(s,Math.max(t,r))}for(const t of this.values)i=Math.min(i,t.min()),s=Math.max(s,t.max());for(var o=0;o<e;++o){const t=this.locations[o],e=this.locations[o+1]-t,n=this.values[o],r=this.values[o+1],a=n.min(),l=n.max(),h=r.min(),u=r.max(),c=this.derivatives[o],d=this.derivatives[o+1];if(0!==c||0!==d){const t=c*e,n=d*e,r=Math.min(a,h),o=Math.max(l,u),f=t-u+a,m=t-h+l,p=-n+h-l,g=-n+u-a,_=Math.min(f,p),b=Math.max(m,g);i=Math.min(i,r+.25*_),s=Math.max(s,o+.25*b)}}this.calculatedMin=i,this.calculatedMax=s}static linearExtend(t,e,i,n,s){const r=n[s];return 0==r?i:i+r*(t-e[s])}}e.MultiPoint=n}(t.CubicSpline||(t.CubicSpline={}));var cn,dn,fn={exports:{}},mn={exports:{}};cn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",dn={rotl:function(t,e){return t<<e|t>>>32-e},rotr:function(t,e){return t<<32-e|t>>>e},endian:function(t){if(t.constructor==Number)return 16711935&dn.rotl(t,8)|4278255360&dn.rotl(t,24);for(var e=0;e<t.length;e++)t[e]=dn.endian(t[e]);return t},randomBytes:function(t){for(var e=[];t>0;t--)e.push(Math.floor(256*Math.random()));return e},bytesToWords:function(t){for(var e=[],i=0,n=0;i<t.length;i++,n+=8)e[n>>>5]|=t[i]<<24-n%32;return e},wordsToBytes:function(t){for(var e=[],i=0;i<32*t.length;i+=8)e.push(t[i>>>5]>>>24-i%32&255);return e},bytesToHex:function(t){for(var e=[],i=0;i<t.length;i++)e.push((t[i]>>>4).toString(16)),e.push((15&t[i]).toString(16));return e.join("")},hexToBytes:function(t){for(var e=[],i=0;i<t.length;i+=2)e.push(parseInt(t.substr(i,2),16));return e},bytesToBase64:function(t){for(var e=[],i=0;i<t.length;i+=3)for(var n=t[i]<<16|t[i+1]<<8|t[i+2],s=0;s<4;s++)8*i+6*s<=8*t.length?e.push(cn.charAt(n>>>6*(3-s)&63)):e.push("=");return e.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var e=[],i=0,n=0;i<t.length;n=++i%4)0!=n&&e.push((cn.indexOf(t.charAt(i-1))&Math.pow(2,-2*n+8)-1)<<2*n|cn.indexOf(t.charAt(i))>>>6-2*n);return e}},mn.exports=dn;var pn={utf8:{stringToBytes:function(t){return pn.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(pn.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var e=[],i=0;i<t.length;i++)e.push(255&t.charCodeAt(i));return e},bytesToString:function(t){for(var e=[],i=0;i<t.length;i++)e.push(String.fromCharCode(t[i]));return e.join("")}}},gn=pn,_n=function(t){return null!=t&&(bn(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&bn(t.slice(0,0))}(t)||!!t._isBuffer)};function bn(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}!function(){var t=mn.exports,e=gn.utf8,i=_n,n=gn.bin,s=function(r,a){r.constructor==String?r=a&&"binary"===a.encoding?n.stringToBytes(r):e.stringToBytes(r):i(r)?r=Array.prototype.slice.call(r,0):Array.isArray(r)||r.constructor===Uint8Array||(r=r.toString());for(var o=t.bytesToWords(r),l=8*r.length,h=1732584193,u=-271733879,c=-1732584194,d=271733878,f=0;f<o.length;f++)o[f]=16711935&(o[f]<<8|o[f]>>>24)|4278255360&(o[f]<<24|o[f]>>>8);o[l>>>5]|=128<<l%32,o[14+(l+64>>>9<<4)]=l;var m=s._ff,p=s._gg,g=s._hh,_=s._ii;for(f=0;f<o.length;f+=16){var b=h,w=u,v=c,y=d;h=m(h,u,c,d,o[f+0],7,-680876936),d=m(d,h,u,c,o[f+1],12,-389564586),c=m(c,d,h,u,o[f+2],17,606105819),u=m(u,c,d,h,o[f+3],22,-1044525330),h=m(h,u,c,d,o[f+4],7,-176418897),d=m(d,h,u,c,o[f+5],12,1200080426),c=m(c,d,h,u,o[f+6],17,-1473231341),u=m(u,c,d,h,o[f+7],22,-45705983),h=m(h,u,c,d,o[f+8],7,1770035416),d=m(d,h,u,c,o[f+9],12,-1958414417),c=m(c,d,h,u,o[f+10],17,-42063),u=m(u,c,d,h,o[f+11],22,-1990404162),h=m(h,u,c,d,o[f+12],7,1804603682),d=m(d,h,u,c,o[f+13],12,-40341101),c=m(c,d,h,u,o[f+14],17,-1502002290),h=p(h,u=m(u,c,d,h,o[f+15],22,1236535329),c,d,o[f+1],5,-165796510),d=p(d,h,u,c,o[f+6],9,-1069501632),c=p(c,d,h,u,o[f+11],14,643717713),u=p(u,c,d,h,o[f+0],20,-373897302),h=p(h,u,c,d,o[f+5],5,-701558691),d=p(d,h,u,c,o[f+10],9,38016083),c=p(c,d,h,u,o[f+15],14,-660478335),u=p(u,c,d,h,o[f+4],20,-405537848),h=p(h,u,c,d,o[f+9],5,568446438),d=p(d,h,u,c,o[f+14],9,-1019803690),c=p(c,d,h,u,o[f+3],14,-187363961),u=p(u,c,d,h,o[f+8],20,1163531501),h=p(h,u,c,d,o[f+13],5,-1444681467),d=p(d,h,u,c,o[f+2],9,-51403784),c=p(c,d,h,u,o[f+7],14,1735328473),h=g(h,u=p(u,c,d,h,o[f+12],20,-1926607734),c,d,o[f+5],4,-378558),d=g(d,h,u,c,o[f+8],11,-2022574463),c=g(c,d,h,u,o[f+11],16,1839030562),u=g(u,c,d,h,o[f+14],23,-35309556),h=g(h,u,c,d,o[f+1],4,-1530992060),d=g(d,h,u,c,o[f+4],11,1272893353),c=g(c,d,h,u,o[f+7],16,-155497632),u=g(u,c,d,h,o[f+10],23,-1094730640),h=g(h,u,c,d,o[f+13],4,681279174),d=g(d,h,u,c,o[f+0],11,-358537222),c=g(c,d,h,u,o[f+3],16,-722521979),u=g(u,c,d,h,o[f+6],23,76029189),h=g(h,u,c,d,o[f+9],4,-640364487),d=g(d,h,u,c,o[f+12],11,-421815835),c=g(c,d,h,u,o[f+15],16,530742520),h=_(h,u=g(u,c,d,h,o[f+2],23,-995338651),c,d,o[f+0],6,-198630844),d=_(d,h,u,c,o[f+7],10,1126891415),c=_(c,d,h,u,o[f+14],15,-1416354905),u=_(u,c,d,h,o[f+5],21,-57434055),h=_(h,u,c,d,o[f+12],6,1700485571),d=_(d,h,u,c,o[f+3],10,-1894986606),c=_(c,d,h,u,o[f+10],15,-1051523),u=_(u,c,d,h,o[f+1],21,-2054922799),h=_(h,u,c,d,o[f+8],6,1873313359),d=_(d,h,u,c,o[f+15],10,-30611744),c=_(c,d,h,u,o[f+6],15,-1560198380),u=_(u,c,d,h,o[f+13],21,1309151649),h=_(h,u,c,d,o[f+4],6,-145523070),d=_(d,h,u,c,o[f+11],10,-1120210379),c=_(c,d,h,u,o[f+2],15,718787259),u=_(u,c,d,h,o[f+9],21,-343485551),h=h+b>>>0,u=u+w>>>0,c=c+v>>>0,d=d+y>>>0}return t.endian([h,u,c,d])};s._ff=function(t,e,i,n,s,r,a){var o=t+(e&i|~e&n)+(s>>>0)+a;return(o<<r|o>>>32-r)+e},s._gg=function(t,e,i,n,s,r,a){var o=t+(e&n|i&~n)+(s>>>0)+a;return(o<<r|o>>>32-r)+e},s._hh=function(t,e,i,n,s,r,a){var o=t+(e^i^n)+(s>>>0)+a;return(o<<r|o>>>32-r)+e},s._ii=function(t,e,i,n,s,r,a){var o=t+(i^(e|~n))+(s>>>0)+a;return(o<<r|o>>>32-r)+e},s._blocksize=16,s._digestsize=16,fn.exports=function(e,i){if(null==e)throw new Error("Illegal argument "+e);var r=t.wordsToBytes(s(e,i));return i&&i.asBytes?r:i&&i.asString?n.bytesToString(r):t.bytesToHex(r)}}();var wn=fn.exports;const vn=class{constructor(t){this.seed=BigInt(0),this.setSeed(t)}fork(){return new vn(this.nextLong())}forkPositional(){return new xn(this.nextLong())}setSeed(t){this.seed=t^vn.MULTIPLIER&vn.MODULUS_MASK}advance(){this.seed=this.seed*vn.MULTIPLIER+vn.INCREMENT&vn.MODULUS_MASK}consume(t){for(let e=0;e<t;e+=1)this.advance()}next(t){this.advance();const e=Number(this.seed>>BigInt(vn.MODULUS_BITS-t));return e>2147483647?e-4294967296:e}nextInt(t){if(void 0===t)return this.next(32);if(0==(t&t-1))return Number(BigInt(t)*BigInt(this.next(31))>>BigInt(31));let e,i;for(;(e=this.next(31))-(i=e%t)+(t-1)<0;);return i}nextLong(){return(BigInt(this.next(32))<<BigInt(32))+BigInt(this.next(32))}nextFloat(){return this.next(24)*vn.FLOAT_MULTIPLIER}nextDouble(){const t=this.next(30);return this.advance(),t*vn.DOUBLE_MULTIPLIER}};let yn=vn;yn.MODULUS_BITS=48,yn.MODULUS_MASK=BigInt("281474976710655"),yn.MULTIPLIER=BigInt("25214903917"),yn.INCREMENT=BigInt("11"),yn.FLOAT_MULTIPLIER=1/Math.pow(2,24),yn.DOUBLE_MULTIPLIER=1/Math.pow(2,30);class xn{constructor(t){this.seed=t}at(t,e,i){const n=on(t,e,i);return new yn(n^this.seed)}fromHashOf(t){const e=wn(t,{asBytes:!0}),i=ln(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]);return new yn(i^this.seed)}seedKey(){return[this.seed,BigInt(0)]}}const kn=class{constructor(t){this.seed=[BigInt(0),BigInt(0)],this.seed=t}static create(t){return new kn(kn.upgradeSeedTo128bit(t))}static mixStafford13(t){return((t=((t=(t^t>>kn.BIGINT_30)*kn.STAFFORD_1&kn.MAX_ULONG)^t>>kn.BIGINT_27)*kn.STAFFORD_2&kn.MAX_ULONG)^t>>kn.BIGINT_31)&kn.MAX_ULONG}static upgradeSeedTo128bit(t){t<0&&(t+=kn.POW2_60);const e=t^kn.SILVER_RATIO_64,i=e+kn.GOLDEN_RATIO_64&kn.MAX_ULONG;return[kn.mixStafford13(e),kn.mixStafford13(i)]}static rotateLeft(t,e){return t<<e&kn.MAX_ULONG|t>>kn.BIGINT_64-e}setSeed(t){this.seed=kn.upgradeSeedTo128bit(t)}fork(){return new kn([this.next(),this.next()])}forkPositional(){return new Sn(this.next(),this.next())}next(){const t=this.seed[0];let e=this.seed[1];const i=kn.rotateLeft(t+e&kn.MAX_ULONG,kn.BIGINT_17)+t&kn.MAX_ULONG;return e^=t,this.seed=[kn.rotateLeft(t,kn.BIGINT_49)^e^e<<kn.BIGINT_21&kn.MAX_ULONG,kn.rotateLeft(e,kn.BIGINT_28)],i}nextLong(){let t=this.next();return t>kn.POW2_63&&(t-=kn.POW2_60),t}consume(t){let e=this.seed[0],i=this.seed[1];for(let n=0;n<t;n+=1)i^=e,e=kn.rotateLeft(e,kn.BIGINT_49)^i^i<<kn.BIGINT_21,i=kn.rotateLeft(i,kn.BIGINT_28);this.seed=[e,i]}nextBits(t){return this.next()>>BigInt(64-t)}nextInt(t){let e=this.next()&kn.MAX_UINT;if(t){const i=BigInt(t);let n=e*i,s=n&kn.MAX_UINT;if(s<i){const t=((~i&kn.MAX_UINT)+kn.BIGINT_1)%i;for(;s<t;)e=this.next()&kn.MAX_UINT,n=e*i,s=n&kn.MAX_UINT}const r=n>>kn.BIGINT_32;return Number(r)}{let t=Number(e);return t>=2147483648&&(t-=4294967296),t}}nextFloat(){return Number(this.nextBits(24))*kn.FLOAT_MULTIPLIER}nextDouble(){return Number(this.nextBits(53))*kn.DOUBLE_MULTIPLIER}parityConfigString(){return"seedLo: "+this.seed[0]+", seedHi: "+this.seed[1]}};let An=kn;An.SILVER_RATIO_64=BigInt("7640891576956012809"),An.GOLDEN_RATIO_64=BigInt("-7046029254386353131"),An.FLOAT_MULTIPLIER=1/Math.pow(2,24),An.DOUBLE_MULTIPLIER=11102230246251565e-32,An.BIGINT_1=BigInt(1),An.BIGINT_17=BigInt(17),An.BIGINT_21=BigInt(21),An.BIGINT_27=BigInt(27),An.BIGINT_28=BigInt(28),An.BIGINT_30=BigInt(30),An.BIGINT_31=BigInt(31),An.BIGINT_32=BigInt(32),An.BIGINT_49=BigInt(49),An.BIGINT_64=BigInt(64),An.STAFFORD_1=BigInt("-4658895280553007687"),An.STAFFORD_2=BigInt("-7723592293110705685"),An.MAX_ULONG=BigInt("0xFFFFFFFFFFFFFFFF"),An.POW2_60=BigInt("0x10000000000000000"),An.POW2_63=BigInt("0x8000000000000000"),An.MAX_UINT=BigInt(4294967295);class Sn{constructor(t,e){this.seedLo=t,this.seedHi=e}at(t,e,i){const n=on(t,e,i)^this.seedLo;return new An([n,this.seedHi])}fromHashOf(t){const e=wn(t,{asBytes:!0}),i=ln(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7]),n=ln(e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]);return new An([i^this.seedLo,n^this.seedHi])}seedKey(){return[this.seedLo,this.seedHi]}}const En=class{constructor(t){this.xo=256*t.nextDouble(),this.yo=256*t.nextDouble(),this.zo=256*t.nextDouble(),this.p=Array(256);for(let t=0;t<256;t+=1)this.p[t]=t;for(let e=0;e<256;e+=1){const i=t.nextInt(256-e),n=this.p[e];this.p[e]=this.p[e+i],this.p[e+i]=n}}sample2D(t,e){let i,n,s;const r=(t+e)*En.F2,a=Math.floor(t+r),o=t-(a-(i=(a+(n=Math.floor(e+r)))*En.G2));let l,h;o>(s=e-(n-i))?(l=1,h=0):(l=0,h=1);const u=o-l+En.G2,c=s-h+En.G2,d=o-1+2*En.G2,f=s-1+2*En.G2,m=255&a,p=255&n,g=this.P(m+this.P(p))%12,_=this.P(m+l+this.P(p+h))%12,b=this.P(m+1+this.P(p+1))%12;return 70*(this.getCornerNoise3D(g,o,s,0,.5)+this.getCornerNoise3D(_,u,c,0,.5)+this.getCornerNoise3D(b,d,f,0,.5))}sample(t,e,i){const n=.3333333333333333*(t+e+i),s=Math.floor(t+n),r=Math.floor(e+n),a=Math.floor(i+n),o=.16666666666666666*(s+r+a),l=t-(s-o),h=e-(r-o),u=i-(a-o);let c,d,f,m,p,g;l>=h?h>=u?(c=1,d=0,f=0,m=1,p=1,g=0):l>=u?(c=1,d=0,f=0,m=1,p=0,g=1):(c=0,d=0,f=1,m=1,p=0,g=1):h<u?(c=0,d=0,f=1,m=0,p=1,g=1):l<u?(c=0,d=1,f=0,m=0,p=1,g=1):(c=0,d=1,f=0,m=1,p=1,g=0);const _=l-c+.16666666666666666,b=h-d+.16666666666666666,w=u-f+.16666666666666666,v=l-m+.3333333333333333,y=h-p+.3333333333333333,x=u-g+.3333333333333333,k=l-.5,A=h-.5,S=u-.5,E=255&s,I=255&r,N=255&a,R=this.P(E+this.P(I+this.P(N)))%12,B=this.P(E+c+this.P(I+d+this.P(N+f)))%12,M=this.P(E+m+this.P(I+p+this.P(N+g)))%12,T=this.P(E+1+this.P(I+1+this.P(N+1)))%12;return 32*(this.getCornerNoise3D(R,l,h,u,.6)+this.getCornerNoise3D(B,_,b,w,.6)+this.getCornerNoise3D(M,v,y,x,.6)+this.getCornerNoise3D(T,k,A,S,.6))}P(t){return this.p[255&t]}getCornerNoise3D(t,e,i,n,s){let r,a=s-e*e-i*i-n*n;return a<0?r=0:(a*=a,r=a*a*En.gradDot(t,e,i,n)),r}static gradDot(t,e,i,n){const s=En.GRADIENT[15&t];return s[0]*e+s[1]*i+s[2]*n}};let In=En;In.GRADIENT=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1],[1,1,0],[0,-1,1],[-1,1,0],[0,-1,-1]],In.F2=.5*(Math.sqrt(3)-1),In.G2=(3-Math.sqrt(3))/6;class Nn{constructor(t){this.xo=256*t.nextDouble(),this.yo=256*t.nextDouble(),this.zo=256*t.nextDouble(),this.p=Array(256);for(let t=0;t<256;t+=1)this.p[t]=t>127?t-256:t;for(let e=0;e<256;e+=1){const i=t.nextInt(256-e),n=this.p[e];this.p[e]=this.p[e+i],this.p[e+i]=n}}sample(t,e,i,n=0,s=0){const r=t+this.xo,a=e+this.yo,o=i+this.zo,l=Math.floor(r),h=Math.floor(a),u=Math.floor(o),c=r-l,d=a-h,f=o-u;let m=0;if(0!==n){const t=s>=0&&s<d?s:d;m=Math.floor(t/n+1e-7)*n}return this.sampleAndLerp(l,h,u,c,d-m,f,d)}sampleAndLerp(t,e,i,n,s,r,a){const o=this.P(t),l=this.P(t+1),h=this.P(o+e),u=this.P(o+e+1),c=this.P(l+e),d=this.P(l+e+1),f=In.gradDot(this.P(h+i),n,s,r),m=In.gradDot(this.P(c+i),n-1,s,r),p=In.gradDot(this.P(u+i),n,s-1,r),g=In.gradDot(this.P(d+i),n-1,s-1,r),_=In.gradDot(this.P(h+i+1),n,s,r-1),b=In.gradDot(this.P(c+i+1),n-1,s,r-1),w=In.gradDot(this.P(u+i+1),n,s-1,r-1),v=In.gradDot(this.P(d+i+1),n-1,s-1,r-1);return $i(nn(n),nn(a),nn(r),f,m,p,g,_,b,w,v)}P(t){return 255&this.p[255&t]}}class Rn{constructor(t,e,i){if(t instanceof An){const n=t.forkPositional();this.noiseLevels=Array(i.length);for(let t=0;t<i.length;t++)if(0!==i[t]){const i=e+t;this.noiseLevels[t]=new Nn(n.fromHashOf("octave_"+i))}}else{if(1-e<i.length)throw new Error("Positive octaves are not allowed when using LegacyRandom");this.noiseLevels=Array(i.length);for(let n=-e;n>=0;n-=1)n<i.length&&0!==i[n]?this.noiseLevels[n]=new Nn(t):t.consume(262)}this.amplitudes=i,this.lowestFreqInputFactor=Math.pow(2,e),this.lowestFreqValueFactor=Math.pow(2,i.length-1)/(Math.pow(2,i.length)-1),this.maxValue=this.edgeValue(2)}sample(t,e,i,n=0,s=0,r=!1){let a=0,o=this.lowestFreqInputFactor,l=this.lowestFreqValueFactor;for(let h=0;h<this.noiseLevels.length;h+=1){const u=this.noiseLevels[h];u&&(a+=this.amplitudes[h]*l*u.sample(Rn.wrap(t*o),r?-u.yo:Rn.wrap(e*o),Rn.wrap(i*o),n*o,s*o)),o*=2,l/=2}return a}getOctaveNoise(t){return this.noiseLevels[this.noiseLevels.length-1-t]}edgeValue(t){let e=0,i=this.lowestFreqValueFactor;for(let n=0;n<this.noiseLevels.length;n+=1)this.noiseLevels[n]&&(e+=this.amplitudes[n]*t*i),i/=2;return e}static wrap(t){return t-33554432*Math.floor(t/33554432+.5)}}class Bn{constructor(t,e,i,n,s,r){this.xzScale=e,this.yScale=i,this.xzFactor=n,this.yFactor=s,this.smearScaleMultiplier=r,this.minLimitNoise=new Rn(t,-15,[1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0]),this.maxLimitNoise=new Rn(t,-15,[1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0]),this.mainNoise=new Rn(t,-7,[1,1,1,1,1,0,0,0]),this.xzMultiplier=684.412*e,this.yMultiplier=684.412*i,this.maxValue=this.minLimitNoise.edgeValue(this.yScale+2)}sample(t,e,i){const n=t*this.xzMultiplier,s=e*this.yMultiplier,r=i*this.xzMultiplier,a=n/this.xzFactor,o=s/this.yFactor,l=r/this.xzFactor,h=this.yMultiplier*this.smearScaleMultiplier,u=h/this.yFactor;let c,d=0,f=1;for(let t=0;t<8;t+=1){if(c=this.mainNoise.getOctaveNoise(t),c){const t=Rn.wrap(a*f),e=Rn.wrap(o*f),i=Rn.wrap(l*f);d+=c.sample(t,e,i,u*f,o*f)/f}f/=2}d=(d/10+1)/2,f=1;let m=0,p=0;for(let t=0;t<16;t+=1){const e=Rn.wrap(n*f),i=Rn.wrap(s*f),a=Rn.wrap(r*f),o=h*f;d<1&&(c=this.minLimitNoise.getOctaveNoise(t))&&(m+=c.sample(e,i,a,o,s*f)/f),d>0&&(c=this.maxLimitNoise.getOctaveNoise(t))&&(p+=c.sample(e,i,a,o,s*f)/f),f/=2}return tn(m/512,p/512,d)/128}}const Mn=class{constructor(t,{firstOctave:e,amplitudes:i}){this.first=new Rn(t,e,i),this.second=new Rn(t,e,i);let n=1/0,s=-1/0;for(let t=0;t<i.length;t+=1)0!==i[t]&&(n=Math.min(n,t),s=Math.max(s,t));const r=.1*(1+1/(s-n+1));this.valueFactor=1/6/r,this.maxValue=(this.first.maxValue+this.second.maxValue)*this.valueFactor}sample(t,e,i){const n=t*Mn.INPUT_FACTOR,s=e*Mn.INPUT_FACTOR,r=i*Mn.INPUT_FACTOR;return(this.first.sample(t,e,i)+this.second.sample(n,s,r))*this.valueFactor}};let Tn=Mn;var Cn;Tn.INPUT_FACTOR=1.0181268882175227,t.NoiseParameters=void 0,(Cn=t.NoiseParameters||(t.NoiseParameters={})).create=function(t,e){return{firstOctave:t,amplitudes:e}},Cn.fromJson=function(t){var e,i,n;const s=null!=(e=mi.readObject(t))?e:{};return{firstOctave:null!=(i=mi.readInt(s.firstOctave))?i:0,amplitudes:null!=(n=mi.readArray(s.amplitudes,(t=>{var e;return null!=(e=mi.readNumber(t))?e:0})))?n:[]}};const On=t=>[(t>>16&255)/256,(t>>8&255)/256,(255&t)/256],Pn=[124/256,189/256,107/256],Fn=On(6396257),Ln=On(8431445),Dn=On(4764952),zn=On(4159204),Un=On(8431445),Vn=On(2129968),Zn=t=>[t/8,1-t/32,64*t],Gn={large_fern:()=>Pn,tall_grass:()=>Pn,grass_block:()=>Pn,fern:()=>Pn,grass:()=>Pn,potted_fern:()=>Pn,spruce_leaves:()=>Fn,birch_leaves:()=>Ln,oak_leaves:()=>Dn,jungle_leaves:()=>Dn,acacia_leaves:()=>Dn,dark_oak_leaves:()=>Dn,vine:()=>Dn,water:()=>zn,bubble_column:()=>zn,cauldron:()=>zn,redstone_wire:t=>{var e;return(t=>{const e=t/15;return[.6*e+(e>0?.4:.3),Xi(e*e*.7-.5,0,1),Xi(e*e*.6-.7,0,1)]})(parseInt(null!=(e=t.power)?e:"0"))},sugar_cane:()=>Pn,attached_melon_stem:()=>Un,attached_pumpkin_stem:()=>Un,melon_stem:t=>{var e;return Zn(parseInt(null!=(e=t.age)?e:"0"))},pumpkin_stem:t=>{var e;return Zn(parseInt(null!=(e=t.age)?e:"0"))},lily_pad:()=>Vn};var Yn,Hn=1e-6,jn="undefined"!=typeof Float32Array?Float32Array:Array,Xn=Math.PI/180;function Wn(t){return t*Xn}function qn(){var t=new jn(16);return jn!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function $n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Jn(t,e,i){var n,s,r,a,o,l,h,u,c,d,f,m,p=i[0],g=i[1],_=i[2];return e===t?(t[12]=e[0]*p+e[4]*g+e[8]*_+e[12],t[13]=e[1]*p+e[5]*g+e[9]*_+e[13],t[14]=e[2]*p+e[6]*g+e[10]*_+e[14],t[15]=e[3]*p+e[7]*g+e[11]*_+e[15]):(n=e[0],s=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=e[6],u=e[7],c=e[8],d=e[9],f=e[10],m=e[11],t[0]=n,t[1]=s,t[2]=r,t[3]=a,t[4]=o,t[5]=l,t[6]=h,t[7]=u,t[8]=c,t[9]=d,t[10]=f,t[11]=m,t[12]=n*p+o*g+c*_+e[12],t[13]=s*p+l*g+d*_+e[13],t[14]=r*p+h*g+f*_+e[14],t[15]=a*p+u*g+m*_+e[15]),t}function Kn(t,e,i){var n=i[0],s=i[1],r=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Qn(t,e,i){var n=Math.sin(i),s=Math.cos(i),r=e[4],a=e[5],o=e[6],l=e[7],h=e[8],u=e[9],c=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=r*s+h*n,t[5]=a*s+u*n,t[6]=o*s+c*n,t[7]=l*s+d*n,t[8]=h*s-r*n,t[9]=u*s-a*n,t[10]=c*s-o*n,t[11]=d*s-l*n,t}function ts(){var t=new jn(3);return jn!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function es(t,e,i){var n=new jn(3);return n[0]=t,n[1]=e,n[2]=i,n}function is(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function ns(t,e){var i=e[0],n=e[1],s=e[2],r=i*i+n*n+s*s;return r>0&&(r=1/Math.sqrt(r)),t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function ss(t,e,i){var n=e[0],s=e[1],r=e[2],a=i[0],o=i[1],l=i[2];return t[0]=s*l-r*o,t[1]=r*a-n*l,t[2]=n*o-s*a,t}function rs(t,e,i){var n=e[0],s=e[1],r=e[2],a=i[3]*n+i[7]*s+i[11]*r+i[15];return a=a||1,t[0]=(i[0]*n+i[4]*s+i[8]*r+i[12])/a,t[1]=(i[1]*n+i[5]*s+i[9]*r+i[13])/a,t[2]=(i[2]*n+i[6]*s+i[10]*r+i[14])/a,t}function as(t,e){var i=t[0],n=t[1],s=t[2],r=e[0],a=e[1],o=e[2];return Math.abs(i-r)<=Hn*Math.max(1,Math.abs(i),Math.abs(r))&&Math.abs(n-a)<=Hn*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-o)<=Hn*Math.max(1,Math.abs(s),Math.abs(o))}function os(...t){let e=0;for(const i of t)e+=i.length;const i=new Float32Array(e);let n=0;for(const e of t)i.set(e,n),n+=e.length;return i}function ls(t,e){const i=ts();for(let n=0;n<t.length;n+=3)i[0]=t[n],i[1]=t[n+1],i[2]=t[n+2],rs(i,i,e),t[n]=i[0],t[n+1]=i[1],t[n+2]=i[2]}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),ts(),(Yn||(Yn={})).rotate=function(t,e,i){let{up:n,down:s,north:r,east:a,south:o,west:l}=t;switch(i){case 90:[r,a,o,l]=[a,o,l,r];break;case 180:[r,a,o,l]=[o,l,r,a];break;case 270:[r,a,o,l]=[l,r,a,o]}switch(e){case 90:[n,r,s,o]=[r,s,o,n];break;case 180:[n,r,s,o]=[s,o,n,r];break;case 270:[n,r,s,o]=[o,n,r,s]}return{up:n,down:s,north:r,east:a,south:o,west:l}};class hs{constructor(t,e,i){this.id=t,this.variants=e,this.multipart=i,this.variants=e}getModelVariants(t){if(this.variants){const e=Object.keys(this.variants).filter((e=>this.matchesVariant(e,t)));if(0===e.length)return[];const i=this.variants[e[0]];return[Array.isArray(i)?i[0]:i]}if(this.multipart){return this.multipart.filter((e=>!e.when||this.matchesCase(e.when,t))).map((t=>Array.isArray(t.apply)?t.apply[0]:t.apply))}return[]}getBuffers(t,e,i,n,s,r){var a,o,l,h;const u=this.getModelVariants(e),c=[],d=[],f=[],m=[];for(const N of u){const u=Yn.rotate(r,null!=(a=N.x)?a:0,null!=(o=N.y)?o:0),R=n.getBlockModel(Mi.parse(N.model));if(!R)throw new Error(`Cannot find block model ${N.model}`);const B=R.getBuffers(t,e,i,s,u);if(N.x||N.y){const t=qn();$n(t),Jn(t,t,[8,8,8]),p=t,g=t,_=-Wn(null!=(l=N.y)?l:0),b=void 0,w=void 0,v=void 0,y=void 0,x=void 0,k=void 0,A=void 0,S=void 0,E=void 0,I=void 0,b=Math.sin(_),w=Math.cos(_),v=g[0],y=g[1],x=g[2],k=g[3],A=g[8],S=g[9],E=g[10],I=g[11],g!==p&&(p[4]=g[4],p[5]=g[5],p[6]=g[6],p[7]=g[7],p[12]=g[12],p[13]=g[13],p[14]=g[14],p[15]=g[15]),p[0]=v*w-A*b,p[1]=y*w-S*b,p[2]=x*w-E*b,p[3]=k*w-I*b,p[8]=v*b+A*w,p[9]=y*b+S*w,p[10]=x*b+E*w,p[11]=k*b+I*w,Qn(t,t,-Wn(null!=(h=N.x)?h:0)),Jn(t,t,[-8,-8,-8]),ls(B.position,t)}c.push(B.position),d.push(...B.texCoord),f.push(...B.tintColor),m.push(...B.index),s+=B.texCoord.length/2}var p,g,_,b,w,v,y,x,k,A,S,E,I;const N=qn();$n(N),Kn(N,N,[.0625,.0625,.0625]);const R=os(...c);return ls(R,N),{position:R,texCoord:d,tintColor:f,index:m}}matchesVariant(t,e){return t.split(",").every((t=>{const[i,n]=t.split("=");return e[i]===n}))}matchesCase(t,e){if(Array.isArray(t.OR))return t.OR.some((t=>this.matchesCase(t,e)));const i=t;return Object.keys(i).every((t=>i[t].split("|").includes(e[t])))}static fromJson(t,e){return new hs(Mi.parse(t),e.variants,e.multipart)}}const us={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]},cs={x:[1,0,0],y:[0,1,0],z:[0,0,1]},ds=1.41421356237,fs={x:[1,ds,ds],y:[ds,1,ds],z:[ds,ds,1]};class ms{constructor(t,e,i,n){this.id=t,this.parent=e,this.textures=i,this.elements=n,this.flattened=!1}getBuffers(t,e,i,n,s){var r;const a=[],o=[],l=[],h=[];for(const u of null!=(r=this.elements)?r:[]){const r=this.getElementBuffers(t,e,u,n,i,s);a.push(r.position),o.push(...r.texCoord),l.push(...r.tintColor),h.push(...r.index),n+=r.texCoord.length/2}return{position:os(...a),texCoord:o,tintColor:l,index:h}}getElementBuffers(t,e,i,n,s,r){var a,o,l,h,u,c,d,f,m,p,g,_;const b=i.from[0],w=i.from[1],v=i.from[2],y=i.to[0],x=i.to[1],k=i.to[2],A=[],S=[],E=[],I=[],N=(i,r,a)=>{var o,l,h,u,c,d,f,m,p,g,_,b,w;const[v,y,x,k]=s.getTextureUV(this.getTexture(i.texture)),N=(x-v)/16,R=(k-y)/16,B=N/16,M=R/16;r[0]=(null!=(l=null==(o=i.uv)?void 0:o[0])?l:r[0])*N+B,r[1]=(null!=(u=null==(h=i.uv)?void 0:h[1])?u:r[1])*R+M,r[2]=(null!=(d=null==(c=i.uv)?void 0:c[2])?d:r[2])*N-B,r[3]=(null!=(m=null==(f=i.uv)?void 0:f[3])?m:r[3])*R-M;const T=us[null!=(p=i.rotation)?p:0];S.push(v+r[T[0]],y+r[T[1]],v+r[T[2]],y+r[T[3]],v+r[T[4]],y+r[T[5]],v+r[T[6]],y+r[T[7]]);const C=(null!=(g=i.tintindex)?g:-1)>=0&&null!=(w=null==(b=(_=Gn)[t.path])?void 0:b.call(_,e))?w:[1,1,1];E.push(...C,...C,...C,...C),A.push(...a),I.push(n,n+1,n+2,n,n+2,n+3),n+=4};!(null==(o=null==(a=i.faces)?void 0:a.up)?void 0:o.texture)||i.faces.up.cullface&&r[i.faces.up.cullface]||N(i.faces.up,[b,16-k,y,16-v],[b,x,k,y,x,k,y,x,v,b,x,v]),!(null==(h=null==(l=i.faces)?void 0:l.down)?void 0:h.texture)||i.faces.down.cullface&&r[i.faces.down.cullface]||N(i.faces.down,[16-k,16-y,16-v,16-b],[b,w,v,y,w,v,y,w,k,b,w,k]),!(null==(c=null==(u=i.faces)?void 0:u.south)?void 0:c.texture)||i.faces.south.cullface&&r[i.faces.south.cullface]||N(i.faces.south,[b,16-x,y,16-w],[b,w,k,y,w,k,y,x,k,b,x,k]),!(null==(f=null==(d=i.faces)?void 0:d.north)?void 0:f.texture)||i.faces.north.cullface&&r[i.faces.north.cullface]||N(i.faces.north,[16-y,16-x,16-b,16-w],[y,w,v,b,w,v,b,x,v,y,x,v]),!(null==(p=null==(m=i.faces)?void 0:m.east)?void 0:p.texture)||i.faces.east.cullface&&r[i.faces.east.cullface]||N(i.faces.east,[16-k,16-x,16-v,16-w],[y,w,k,y,w,v,y,x,v,y,x,k]),!(null==(_=null==(g=i.faces)?void 0:g.west)?void 0:_.texture)||i.faces.west.cullface&&r[i.faces.west.cullface]||N(i.faces.west,[v,16-x,k,16-w],[b,w,v,b,w,k,b,x,k,b,x,v]);const R=qn();if($n(R),i.rotation){const t=es(...i.rotation.origin);Jn(R,R,t),function(t,e,i,n){var s,r,a,o,l,h,u,c,d,f,m,p,g,_,b,w,v,y,x,k,A,S,E,I,N=n[0],R=n[1],B=n[2],M=Math.hypot(N,R,B);M<Hn||(N*=M=1/M,R*=M,B*=M,s=Math.sin(i),a=1-(r=Math.cos(i)),o=e[0],l=e[1],h=e[2],u=e[3],c=e[4],d=e[5],f=e[6],m=e[7],p=e[8],g=e[9],_=e[10],b=e[11],w=N*N*a+r,v=R*N*a+B*s,y=B*N*a-R*s,x=N*R*a-B*s,k=R*R*a+r,A=B*R*a+N*s,S=N*B*a+R*s,E=R*B*a-N*s,I=B*B*a+r,t[0]=o*w+c*v+p*y,t[1]=l*w+d*v+g*y,t[2]=h*w+f*v+_*y,t[3]=u*w+m*v+b*y,t[4]=o*x+c*k+p*A,t[5]=l*x+d*k+g*A,t[6]=h*x+f*k+_*A,t[7]=u*x+m*k+b*A,t[8]=o*S+c*E+p*I,t[9]=l*S+d*E+g*I,t[10]=h*S+f*E+_*I,t[11]=u*S+m*E+b*I,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]))}(R,R,Wn(i.rotation.angle),cs[i.rotation.axis]),i.rotation.rescale&&Kn(R,R,fs[i.rotation.axis]),M=t,(B=t)[0]=-M[0],B[1]=-M[1],B[2]=-M[2],Jn(R,R,t)}var B,M;const T=new Float32Array(A);return ls(T,R),{position:T,texCoord:S,tintColor:E,index:I}}getTexture(t){for(var e,i;t.startsWith("#");)t=null!=(i=null==(e=this.textures)?void 0:e[t.slice(1)])?i:"";return Mi.parse(t)}flatten(t){var e;if(!this.flattened&&this.parent){const i=t.getBlockModel(this.parent);if(!i)return console.warn(`parent ${this.parent} does not exist!`),void(this.flattened=!0);i.flatten(t),this.elements||(this.elements=i.elements),this.textures||(this.textures={}),Object.keys(null!=(e=i.textures)?e:{}).forEach((t=>{this.textures[t]||(this.textures[t]=i.textures[t])})),this.flattened=!0}}static fromJson(t,e){const i=void 0===e.parent?void 0:Mi.parse(e.parent);return new ms(Mi.parse(t),i,e.textures,e.elements)}}class ps{constructor(t,e,i){this.gl=t,this.program=this.initShaderProgram(e,i)}getProgram(){return this.program}initShaderProgram(t,e){const i=this.loadShader(this.gl.VERTEX_SHADER,t),n=this.loadShader(this.gl.FRAGMENT_SHADER,e),s=this.gl.createProgram();if(this.gl.attachShader(s,i),this.gl.attachShader(s,n),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 i=this.gl.createShader(t);if(this.gl.shaderSource(i,e),this.gl.compileShader(i),!this.gl.getShaderParameter(i,this.gl.COMPILE_STATUS)){const e=new Error(`Compiling ${t===this.gl.VERTEX_SHADER?"vertex":"fragment"} shader: ${this.gl.getShaderInfoLog(i)}`);throw this.gl.deleteShader(i),e}return i}}function gs(t,e,i,n,s){const r=new hs(t,{"":{model:"dummy"}},void 0),a={getBlockModel:()=>s};return s.flatten(a),r.getBuffers(t,{},e,a,i,n)}function _s(e,i,n,s,r,a){const o=r.up?16:[14.2,12.5,10.5,9,7,5.3,3.7,1.9,16,16,16,16,16,16,16,16][n],l=Mi.create(e);return gs(l,s,i,r,new ms(l,void 0,{still:`block/${e}_still`,flow:`block/${e}_flow`},[{from:[0,0,0],to:[16,o,16],faces:{up:{texture:"#still",tintindex:a,cullface:t.Direction.UP},down:{texture:"#still",tintindex:a,cullface:t.Direction.DOWN},north:{texture:"#flow",tintindex:a,cullface:t.Direction.NORTH},east:{texture:"#flow",tintindex:a,cullface:t.Direction.EAST},south:{texture:"#flow",tintindex:a,cullface:t.Direction.SOUTH},west:{texture:"#flow",tintindex:a,cullface:t.Direction.WEST}}}]))}const bs={"minecraft:water":(t,e,i,n)=>_s("water",t,parseInt(e.level),i,n,0),"minecraft:lava":(t,e,i,n)=>_s("lava",t,parseInt(e.level),i,n),"minecraft:chest":(t,e,i)=>function(t,e,i,n){const s=Mi.create("chest");return gs(s,n,t,{},new ms(s,void 0,{0:"block/chest"},[{from:[1,0,1],to:[15,14,15],faces:{up:{texture:"#0"},down:{texture:"#0"},north:{texture:"#0"},east:{texture:"#0"},south:{texture:"#0"},west:{texture:"#0"}}}]))}(t,e.facing,e.type,i)},ws=new Set(Object.keys(bs));var vs=(t,e,i)=>new Promise(((n,s)=>{var r=t=>{try{o(i.next(t))}catch(t){s(t)}},a=t=>{try{o(i.throw(t))}catch(t){s(t)}},o=t=>t.done?n(t.value):Promise.resolve(t.value).then(r,a);o((i=i.apply(t,e)).next())}));class ys{constructor(t,e){if(this.img=t,this.idMap=e,!hn(t.width)||!hn(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 null!=(e=this.idMap[t.toString()])?e:[0,0,this.part,this.part]}static fromBlobs(t){return vs(this,null,(function*(){const e=un(Math.sqrt(Object.keys(t).length+1)),i=16*e,n=1/e,s=document.createElement("canvas");s.width=i,s.height=i;const r=s.getContext("2d");this.drawInvalidTexture(r);const a={};let o=1;return yield Promise.all(Object.keys(t).map((i=>vs(this,null,(function*(){const s=o%e,l=Math.floor(o/e);o+=1,a[i]=[n*s,n*l,n*s+n,n*l+n];const h=yield createImageBitmap(t[i]);r.drawImage(h,0,0,16,16,16*s,16*l,16,16)}))))),new ys(r.getImageData(0,0,i,i),a)}))}static empty(){const t=document.createElement("canvas");t.width=16,t.height=16;const e=t.getContext("2d");return ys.drawInvalidTexture(e),new ys(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)}}t.WorldgenRegistries=void 0,function(t){function e(t){const e=new Yi(Mi.create(t));return Yi.REGISTRY.register(e.key,e),e}t.NOISE=e("worldgen/noise"),t.DENSITY_FUNCTION=e("worldgen/density_function")}(t.WorldgenRegistries||(t.WorldgenRegistries={}));class xs{minValue(){return-this.maxValue()}mapAll(t){return t.map(this)}}!function(e){e.context=function(t,e,i){return{x:t,y:e,z:i}};class i extends e{constructor(t){super(),this.input=t}compute(t){return this.transform(t,this.input.compute(t))}}const n=t.Holder.parser(t.WorldgenRegistries.NOISE,t.NoiseParameters.fromJson);e.fromJson=function e(i,s=e){var h,b,x,N,O,P,F,L,D,z,U,V,Z,G,Y,H,j,X,W,q;if("string"==typeof i)return new a(t.Holder.reference(t.WorldgenRegistries.DENSITY_FUNCTION,Mi.parse(i)));if("number"==typeof i)return new r(i);const $=null!=(h=mi.readObject(i))?h:{},J=null==(b=mi.readString($.type))?void 0:b.replace(/^minecraft:/,"");switch(J){case"blend_alpha":return new o(1,0,1);case"blend_offset":case"beardifier":return new o(0,-1/0,1/0);case"old_blended_noise":return new l(null!=(x=mi.readNumber($.xz_scale))?x:1,null!=(N=mi.readNumber($.y_scale))?N:1,null!=(O=mi.readNumber($.xz_factor))?O:80,null!=(P=mi.readNumber($.y_factor))?P:160,null!=(F=mi.readNumber($.smear_scale_multiplier))?F:8);case"flat_cache":return new u(s($.argument));case"interpolated":return new m(s($.argument));case"cache_2d":return new d(s($.argument));case"cache_once":return new f(s($.argument));case"cache_all_in_cell":return new c(s($.argument));case"noise":return new p(null!=(L=mi.readNumber($.xz_scale))?L:1,null!=(D=mi.readNumber($.y_scale))?D:1,n($.noise));case"end_islands":return new g;case"weird_scaled_sampler":return new w(s($.input),mi.readEnum($.rarity_value_mapper,_),n($.noise));case"shifted_noise":return new v(s($.shift_x),s($.shift_y),s($.shift_z),null!=(z=mi.readNumber($.xz_scale))?z:1,null!=(U=mi.readNumber($.y_scale))?U:1,n($.noise));case"range_choice":return new y(s($.input),null!=(V=mi.readNumber($.min_inclusive))?V:0,null!=(Z=mi.readNumber($.max_exclusive))?Z:1,s($.when_in_range),s($.when_out_of_range));case"shift_a":return new k(n($.argument));case"shift_b":return new A(n($.argument));case"shift":return new S(n($.argument));case"blend_density":return new E(s($.argument));case"clamp":return new I(s($.input),null!=(G=mi.readNumber($.min))?G:0,null!=(Y=mi.readNumber($.max))?Y:1);case"abs":case"square":case"cube":case"half_negative":case"quarter_negative":case"squeeze":return new R(J,s($.argument));case"add":case"mul":case"min":case"max":return new M(mi.readEnum(J,B),s($.argument1),s($.argument2));case"spline":return new T(t.CubicSpline.fromJson($.spline,s));case"constant":return new r(null!=(H=mi.readNumber($.argument))?H:0);case"y_clamped_gradient":return new C(null!=(j=mi.readInt($.from_y))?j:-4064,null!=(X=mi.readInt($.to_y))?X:4062,null!=(W=mi.readNumber($.from_value))?W:-4064,null!=(q=mi.readNumber($.to_value))?q:4062)}return r.ZERO};const s=class extends e{constructor(t){super(),this.value=t}compute(){return this.value}minValue(){return this.value}maxValue(){return this.value}};let r=s;r.ZERO=new s(0),r.ONE=new s(1),e.Constant=r;class a extends e{constructor(t){super(),this.holder=t}compute(t){return this.holder.value().compute(t)}minValue(){return this.holder.value().minValue()}maxValue(){return this.holder.value().maxValue()}}e.HolderHolder=a;class o extends e.Constant{constructor(t,e,i){super(t),this.min=e,this.max=i}minValue(){return this.min}maxValue(){return this.max}}e.ConstantMinMax=o;class l extends e{constructor(t,e,i,n,s,r){super(),this.xzScale=t,this.yScale=e,this.xzFactor=i,this.yFactor=n,this.smearScaleMultiplier=s,this.blendedNoise=r}compute(t){var e,i;return null!=(i=null==(e=this.blendedNoise)?void 0:e.sample(t.x,t.y,t.z))?i:0}maxValue(){var t,e;return null!=(e=null==(t=this.blendedNoise)?void 0:t.maxValue)?e:0}}e.OldBlendedNoise=l;class h extends e{constructor(t){super(),this.wrapped=t}minValue(){return this.wrapped.minValue()}maxValue(){return this.wrapped.maxValue()}}class u extends h{constructor(t){super(t),this.lastValue=0}compute(t){const i=t.x>>2,n=t.z>>2;return this.lastQuartX===i&&this.lastQuartZ===n||(this.lastValue=this.wrapped.compute(e.context(i<<2,0,n<<2)),this.lastQuartX=i,this.lastQuartZ=n),this.lastValue}mapAll(t){return t.map(new u(this.wrapped.mapAll(t)))}}e.FlatCache=u;class c extends h{constructor(t){super(t)}compute(t){return this.wrapped.compute(t)}mapAll(t){return t.map(new c(this.wrapped.mapAll(t)))}}e.CacheAllInCell=c;class d extends h{constructor(t){super(t),this.lastValue=0}compute(t){const e=t.x,i=t.z;return this.lastBlockX===e&&this.lastBlockZ===i||(this.lastValue=this.wrapped.compute(t),this.lastBlockX=e,this.lastBlockZ=i),this.lastValue}mapAll(t){return t.map(new d(this.wrapped.mapAll(t)))}}e.Cache2D=d;class f extends h{constructor(t){super(t),this.lastValue=0}compute(t){const e=t.x,i=t.y,n=t.z;return this.lastBlockX===e&&this.lastBlockY===i&&this.lastBlockZ===n||(this.lastValue=this.wrapped.compute(t),this.lastBlockX=e,this.lastBlockY=i,this.lastBlockZ=n),this.lastValue}mapAll(t){return t.map(new f(this.wrapped.mapAll(t)))}}e.CacheOnce=f;class m extends h{constructor(t,e=4,i=4){super(t),this.cellWidth=e,this.cellHeight=i,this.values=new Map}compute({x:t,y:e,z:i}){const n=this.cellWidth,s=this.cellHeight,r=(t%n+n)%n/n,a=(e%s+s)%s/s,o=(i%n+n)%n/n,l=Math.floor(t/n)*n,h=Math.floor(e/s)*s,u=Math.floor(i/n)*n;return Qi(r,a,o,(()=>this.computeCorner(l,h,u)),(()=>this.computeCorner(l+n,h,u)),(()=>this.computeCorner(l,h+s,u)),(()=>this.computeCorner(l+n,h+s,u)),(()=>this.computeCorner(l,h,u+n)),(()=>this.computeCorner(l+n,h,u+n)),(()=>this.computeCorner(l,h+s,u+n)),(()=>this.computeCorner(l+n,h+s,u+n)))}computeCorner(t,i,n){return Ri(this.values,`${t} ${i} ${n}`,(()=>this.wrapped.compute(e.context(t,i,n))))}mapAll(t){return t.map(new m(this.wrapped.mapAll(t)))}withCellSize(t,e){return new m(this.wrapped,t,e)}}e.Interpolated=m;class p extends e{constructor(t,e,i,n){super(),this.xzScale=t,this.yScale=e,this.noiseData=i,this.noise=n}compute(t){var e,i;return null!=(i=null==(e=this.noise)?void 0:e.sample(t.x*this.xzScale,t.y*this.yScale,t.z*this.xzScale))?i:0}maxValue(){var t,e;return null!=(e=null==(t=this.noise)?void 0:t.maxValue)?e:2}}e.Noise=p;class g extends e{compute(){return 0}minValue(){return-.84375}maxValue(){return.5625}}const _=["type_1","type_2"],b=class extends i{constructor(t,e,i,n){super(t),this.rarityValueMapper=e,this.noiseData=i,this.noise=n,this.mapper=b.ValueMapper[this.rarityValueMapper]}transform(t,e){if(!this.noise)return 0;const i=this.mapper(e);return i*Math.abs(this.noise.sample(t.x/i,t.y/i,t.z/i))}mapAll(t){return t.map(new b(this.input.mapAll(t),this.rarityValueMapper,this.noiseData,this.noise))}minValue(){return 0}maxValue(){return"type_1"===this.rarityValueMapper?2:3}static rarityValueMapper1(t){return t<-.5?.75:t<0?1:t<.5?1.5:2}static rarityValueMapper2(t){return t<-.75?.5:t<-.5?.75:t<.5?1:t<.75?2:3}};let w=b;w.ValueMapper={type_1:b.rarityValueMapper1,type_2:b.rarityValueMapper2},e.WeirdScaledSampler=w;class v extends p{constructor(t,e,i,n,s,r,a){super(n,s,r,a),this.shiftX=t,this.shiftY=e,this.shiftZ=i}compute(t){var e,i;const n=t.x*this.xzScale+this.shiftX.compute(t),s=t.y*this.yScale+this.shiftY.compute(t),r=t.z*this.xzScale+this.shiftZ.compute(t);return null!=(i=null==(e=this.noise)?void 0:e.sample(n,s,r))?i:0}mapAll(t){return t.map(new v(this.shiftX.mapAll(t),this.shiftY.mapAll(t),this.shiftZ.mapAll(t),this.xzScale,this.yScale,this.noiseData,this.noise))}}e.ShiftedNoise=v;class y extends e{constructor(t,e,i,n,s){super(),this.input=t,this.minInclusive=e,this.maxExclusive=i,this.whenInRange=n,this.whenOutOfRange=s}compute(t){const e=this.input.compute(t);return this.minInclusive<=e&&e<this.maxExclusive?this.whenInRange.compute(t):this.whenOutOfRange.compute(t)}mapAll(t){return t.map(new y(this.input.mapAll(t),this.minInclusive,this.maxExclusive,this.whenInRange.mapAll(t),this.whenOutOfRange.mapAll(t)))}minValue(){return Math.min(this.whenInRange.minValue(),this.whenOutOfRange.minValue())}maxValue(){return Math.max(this.whenInRange.maxValue(),this.whenOutOfRange.maxValue())}}e.RangeChoice=y;class x extends e{constructor(t,e){super(),this.noiseData=t,this.offsetNoise=e}compute(t){var e,i;return null!=(i=null==(e=this.offsetNoise)?void 0:e.sample(.25*t.x,.25*t.y,.25*t.z))?i:0}maxValue(){var t,e;return 4*(null!=(e=null==(t=this.offsetNoise)?void 0:t.maxValue)?e:2)}}e.ShiftNoise=x;class k extends x{constructor(t,e){super(t,e)}compute(t){return super.compute(e.context(t.x,0,t.z))}withNewNoise(t){return new k(this.noiseData,t)}}e.ShiftA=k;class A extends x{constructor(t,e){super(t,e)}compute(t){return super.compute(e.context(t.z,t.x,0))}withNewNoise(t){return new A(this.noiseData,t)}}e.ShiftB=A;class S extends x{constructor(t,e){super(t,e)}withNewNoise(t){return new S(this.noiseData,t)}}e.Shift=S;class E extends i{constructor(t){super(t)}transform(t,e){return e}mapAll(t){return t.map(new E(this.input.mapAll(t)))}minValue(){return-1/0}maxValue(){return 1/0}}e.BlendDensity=E;class I extends i{constructor(t,e,i){super(t),this.min=e,this.max=i}transform(t,e){return Xi(e,this.min,this.max)}mapAll(t){return t.map(new I(this.input.mapAll(t),this.min,this.max))}minValue(){return this.min}maxValue(){return this.max}}e.Clamp=I;const N=class extends i{constructor(t,e,i,n){super(e),this.type=t,this.min=i,this.max=n,this.transformer=N.MappedTypes[this.type]}transform(t,e){return this.transformer(e)}mapAll(t){return t.map(new N(this.type,this.input.mapAll(t)))}minValue(){var t;return null!=(t=this.min)?t:-1/0}maxValue(){var t;return null!=(t=this.max)?t:1/0}withMinMax(){const t=this.input.minValue();let e=this.transformer(t),i=this.transformer(this.input.maxValue());return"abs"!==this.type&&"square"!==this.type||(i=Math.max(e,i),e=Math.max(0,t)),new N(this.type,this.input,e,i)}};let R=N;R.MappedTypes={abs:t=>Math.abs(t),square:t=>t*t,cube:t=>t*t*t,half_negative:t=>t>0?t:.5*t,quarter_negative:t=>t>0?t:.25*t,squeeze:t=>{const e=Xi(t,-1,1);return e/2-e*e*e/24}},e.Mapped=R;const B=["add","mul","min","max"];class M extends e{constructor(t,e,i,n,s){super(),this.type=t,this.argument1=e,this.argument2=i,this.min=n,this.max=s}compute(t){const e=this.argument1.compute(t);switch(this.type){case"add":return e+this.argument2.compute(t);case"mul":return 0===e?0:e*this.argument2.compute(t);case"min":return e<this.argument2.minValue()?e:Math.min(e,this.argument2.compute(t));case"max":return e>this.argument2.maxValue()?e:Math.max(e,this.argument2.compute(t))}}mapAll(t){return t.map(new M(this.type,this.argument1.mapAll(t),this.argument2.mapAll(t)))}minValue(){var t;return null!=(t=this.min)?t:-1/0}maxValue(){var t;return null!=(t=this.max)?t:1/0}withMinMax(){const t=this.argument1.minValue(),e=this.argument2.minValue(),i=this.argument1.maxValue(),n=this.argument2.maxValue();let s,r;switch("min"!==this.type&&"max"!==this.type||!(t>=n||e>=i)||console.warn(`Creating a ${this.type} function between two non-overlapping inputs`),this.type){case"add":s=t+e,r=i+n;break;case"mul":s=t>0&&e>0?t*e||0:i<0&&n<0?i*n||0:Math.min(t*n||0,e*i||0),r=t>0&&e>0?i*n||0:i<0&&n<0?t*e||0:Math.max(t*e||0,i*n||0);break;case"min":s=Math.min(t,e),r=Math.min(i,n);break;case"max":s=Math.max(t,e),r=Math.max(i,n)}return new M(this.type,this.argument1,this.argument2,s,r)}}e.Ap2=M;class T extends e{constructor(t){super(),this.spline=t}compute(t){return this.spline.compute(t)}mapAll(t){const i=this.spline.mapAll((i=>i instanceof e?i.mapAll(t):i));return i.calculateMinMax(),t.map(new T(i))}minValue(){return this.spline.min()}maxValue(){return this.spline.max()}}e.Spline=T;class C extends e{constructor(t,e,i,n){super(),this.fromY=t,this.toY=e,this.fromValue=i,this.toValue=n}compute(t){return rn(t.y,this.fromY,this.toY,this.fromValue,this.toValue)}minValue(){return Math.min(this.fromValue,this.toValue)}maxValue(){return Math.max(this.fromValue,this.toValue)}}e.YClampedGradient=C}(xs||(xs={}));class ks{constructor(t,e){this.level=t,this.type=e}at(t){return t<this.level?this.type:Ui.AIR}}t.Aquifer=void 0,(t.Aquifer||(t.Aquifer={})).createDisabled=function(t){return{compute({x:e,y:i,z:n},s){if(!(s>0))return t(e,i,n).at(i)}}};const As=class{constructor(e,i,n,s,r,a,o,l,h,u){this.noiseChunk=e,this.barrierNoise=n,this.fluidLevelFloodednessNoise=s,this.fluidLevelSpreadNoise=r,this.lavaNoise=a,this.random=o,this.globalFluidPicker=u,this.minGridX=this.gridX(t.ChunkPos.minBlockX(i))-1,this.gridSizeX=this.gridX(t.ChunkPos.maxBlockX(i))+1-this.minGridX+1,this.minGridY=this.gridY(l)-1,this.minGridZ=this.gridZ(t.ChunkPos.minBlockZ(i))-1,this.gridSizeZ=this.gridZ(t.ChunkPos.maxBlockZ(i))+1-this.minGridZ+1;const c=this.gridY(l+h)+1-this.minGridY+1;this.gridSize=this.gridSizeX*c*this.gridSizeZ,this.aquiferCache=Array(this.gridSize).fill(void 0),this.aquiferLocationCache=Array(this.gridSize).fill(t.BlockPos.ZERO)}compute({x:e,y:i,z:n},s){if(s<=0){if(this.globalFluidPicker(e,i,n).at(i).is(Ui.LAVA))return Ui.LAVA;{const r=this.gridX(e-5),a=this.gridY(i+1),o=this.gridZ(n-5);let l=Number.MAX_SAFE_INTEGER,h=Number.MAX_SAFE_INTEGER,u=Number.MAX_SAFE_INTEGER,c=t.BlockPos.ZERO,d=t.BlockPos.ZERO,f=t.BlockPos.ZERO;for(let e=0;e<=1;e+=1)for(let i=-1;i<=1;i+=1)for(let n=0;n<=1;n+=1){const s=this.getLocation(r+e,a+i,o+n),m=t.BlockPos.magnitude(s);l>=m?(f=d,d=c,c=s,u=h,h=l,l=m):h>=m?(f=d,d=s,u=h,h=m):u>=m&&(f=s,u=m)}const m=this.getStatus(c),p=this.getStatus(d),g=this.getStatus(f),_=As.similarity(l,h),b=As.similarity(l,u),w=As.similarity(h,u);let v;if(m.at(i).is(Ui.WATER)&&this.globalFluidPicker(e,i-1,n).at(i-1).is(Ui.LAVA))v=1;else if(_>-1){const t=Ni((()=>this.barrierNoise.compute(xs.context(e,.5*i,n)))),s=this.calculatePressure(i,m,p,t),r=this.calculatePressure(i,m,g,t),a=this.calculatePressure(i,p,g,t),o=Math.max(s,r*Math.max(0,b),a*Math.max(w));v=Math.max(0,2*Math.max(0,_)*o)}else v=0;if(s+v<=0)return m.at(i)}}}static similarity(t,e){return 1-Math.abs(e-t)/25}calculatePressure(t,e,i,n){const s=e.at(t),r=i.at(t);if(s.is(Ui.LAVA)&&r.is(Ui.WATER)||s.is(Ui.WATER)&&r.is(Ui.LAVA))return 1;const a=Math.abs(e.level-i.level);if(0===a)return 0;const o=t+.5-(e.level+i.level)/2,l=a/2-Math.abs(o),h=o>0?l>0?l/1.5:l/2.5:l>-3?(l+3)/3:(l+3)/10;return h<-2||h>2?h:h+n()}getStatus(t){const[e,i,n]=t,s=this.getIndex(this.gridX(e),this.gridY(i),this.gridZ(n)),r=this.aquiferCache[s];if(void 0!==r)return r;const a=this.computeStatus(e,i,n);return this.aquiferCache[s]=a,a}computeStatus(t,e,i){const n=this.globalFluidPicker(t,e,i);let s=Number.MAX_SAFE_INTEGER,r=!1;for(const[a,o]of As.SURFACE_SAMPLING){const l=t+(o<<4),h=i+(o<<4),u=this.noiseChunk.getPreliminarySurfaceLevel(l,h);s=Math.min(s,u);const c=0===a&&0===o;if(c&&e-12>u+8)return n;if(c||e+12>u+8){const t=this.globalFluidPicker(l,u+8,h);if(!t.at(u+8).is(Ui.AIR)){if(c)return t;r=!0}}}const a=r?rn(s+8-e,0,64,1,0):0,o=Xi(this.fluidLevelFloodednessNoise.compute(xs.context(t,.67*e,i)),-1,1);if(o>sn(a,1,0,-.3,.8))return n;if(o<=sn(a,1,0,-.8,.4))return new ks(Number.MIN_SAFE_INTEGER,n.type);const l=Math.floor(e/40),h=this.fluidLevelSpreadNoise.compute(xs.context(Math.floor(t/16),l,Math.floor(i/16))),u=40*l+20+3*Math.floor(h/3),c=Math.min(s,u),d=this.getFluidType(t,e,i,n.type,u);return new ks(c,d)}getFluidType(t,e,i,n,s){if(s<=-10){const n=this.lavaNoise.compute(xs.context(Math.floor(t/64),Math.floor(e/40),Math.floor(i/64)));if(Math.abs(n)>.3)return Ui.LAVA}return n}getLocation(e,i,n){const s=this.getIndex(e,i,n),r=this.aquiferLocationCache[s];if(t.BlockPos.equals(r,t.BlockPos.ZERO))return r;const a=this.random.at(e,i,n),o=t.BlockPos.create(e*As.X_SPACING+a.nextInt(10),i*As.Y_SPACING+a.nextInt(9),n*As.Z_SPACING+a.nextInt(10));return this.aquiferLocationCache[s]=o,o}getIndex(t,e,i){const n=t-this.minGridX,s=e-this.minGridY,r=i-this.minGridZ,a=(s*this.gridSizeZ+r)*this.gridSizeX+n;if(a<0||a>=this.gridSize)throw new Error(`Invalid aquifer index at ${t} ${e} ${i}: 0 <= ${a} < ${this.gridSize}`);return a}gridX(t){return Math.floor(t/As.X_SPACING)}gridY(t){return Math.floor(t/As.Y_SPACING)}gridZ(t){return Math.floor(t/As.Z_SPACING)}};let Ss=As;Ss.X_SPACING=16,Ss.Y_SPACING=12,Ss.Z_SPACING=16,Ss.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]],t.Climate=void 0,function(t){function e(t,e){return"number"==typeof t?new i(t,null!=e?e:t):t}t.target=function(t,e,i,n,r,a){return new s(t,e,i,n,r,a)},t.parameters=function(t,i,s,r,a,o,l){return new n(e(t),e(i),e(s),e(r),e(a),e(o),l)},t.param=e;class i{constructor(t,e){this.min=t,this.max=e}distance(t){const e=("number"==typeof t?t:t.min)-this.max,i=this.min-("number"==typeof t?t:t.max);return e>0?e:Math.max(i,0)}union(t){return new i(Math.min(this.min,t.min),Math.max(this.max,t.max))}static fromJson(t){var e;if("number"==typeof t)return new i(t,t);const[n,s]=null!=(e=mi.readArray(t,(t=>mi.readNumber(t))))?e:[];return new i(null!=n?n:0,null!=s?s:0)}}t.Param=i;class n{constructor(t,e,i,n,s,r,a){this.temperature=t,this.humidity=e,this.continentalness=i,this.erosion=n,this.depth=s,this.weirdness=r,this.offset=a}fittness(t){return ji(this.temperature.distance(t.temperature))+ji(this.humidity.distance(t.humidity))+ji(this.continentalness.distance(t.continentalness))+ji(this.erosion.distance(t.erosion))+ji(this.depth.distance(t.depth))+ji(this.weirdness.distance(t.weirdness))+ji(this.offset-t.offset)}space(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,new i(this.offset,this.offset)]}static fromJson(t){var e,s;const r=null!=(e=mi.readObject(t))?e:{};return new n(i.fromJson(r.temperature),i.fromJson(r.humidity),i.fromJson(r.continentalness),i.fromJson(r.erosion),i.fromJson(r.depth),i.fromJson(r.weirdness),null!=(s=mi.readInt(r.offset))?s:0)}}t.ParamPoint=n;class s{constructor(t,e,i,n,s,r){this.temperature=t,this.humidity=e,this.continentalness=i,this.erosion=n,this.depth=s,this.weirdness=r}get offset(){return 0}toArray(){return[this.temperature,this.humidity,this.continentalness,this.erosion,this.depth,this.weirdness,this.offset]}}t.TargetPoint=s;t.Parameters=class{constructor(t){this.things=t,this.index=new a(t)}find(t){return this.index.search(t,((t,e)=>t.distance(e)))}};t.Sampler=class{constructor(t,e,i,n,s,r){this.temperature=t,this.humidity=e,this.continentalness=i,this.erosion=n,this.depth=s,this.weirdness=r}static fromRouter(e){return new t.Sampler(e.temperature,e.vegetation,e.continents,e.erosion,e.depth,e.ridges)}sample(e,i,n){const s=xs.context(e<<2,i<<2,n<<2);return t.target(this.temperature.compute(s),this.humidity.compute(s),this.continentalness.compute(s),this.erosion.compute(s),this.depth.compute(s),this.weirdness.compute(s))}};const r=class{constructor(t){this.root=r.build(t.map((([t,e])=>new h(t,e))))}static build(t){if(1===t.length)return t[0];if(t.length<=r.CHILDREN_PER_NODE){const e=t.map((t=>{let e=0;for(let i=0;i<7;i+=1){const n=t.space[i];e+=Math.abs((n.min+n.max)/2)}return{key:e,node:t}})).sort(((t,e)=>t.key-e.key)).map((({node:t})=>t));return new l(e)}let e=1/0,i=-1,n=[];for(let s=0;s<7;++s){t=r.sort(t,s,!1),n=r.bucketize(t);let a=0;for(const t of n)a+=r.area(t.space);e>a&&(e=a,i=s)}return t=r.sort(t,i,!1),n=r.bucketize(t),n=r.sort(n,i,!0),new l(n.map((t=>r.build(t.children))))}static sort(t,e,i){return t.map((t=>{const n=t.space[e],s=(n.min+n.max)/2;return{key:i?Math.abs(s):s,node:t}})).sort(((t,e)=>t.key-e.key)).map((({node:t})=>t))}static bucketize(t){const e=[];let i=[];const n=Math.pow(10,Math.floor(Math.log(t.length-.01)/Math.log(10)));for(const s of t)i.push(s),i.length<n||(e.push(new l(i)),i=[]);return 0!==i.length&&e.push(new l(i)),e}static area(t){let e=0;for(const i of t)e+=Math.abs(i.max-i.min);return e}search(t,e){return this.root.search(t.toArray(),e).thing()}};let a=r;a.CHILDREN_PER_NODE=10,t.RTree=a;class o{constructor(t){this.space=t}distance(t){let e=0;for(let i=0;i<7;i+=1)e+=ji(this.space[i].distance(t[i]));return e}}t.RNode=o;class l extends o{constructor(t){super(l.buildSpace(t)),this.children=t}static buildSpace(t){let e=[...Array(7)].map((()=>new i(1/0,-1/0)));for(const i of t)e=[...Array(7)].map(((t,n)=>e[n].union(i.space[n])));return e}search(t,e){let i=1/0,n=null;for(const s of this.children){const r=e(s,t);if(i<=r)continue;const a=s.search(t,e),o=s==a?r:e(a,t);i<=o||(i=o,n=a)}return n}}t.RSubTree=l;class h extends o{constructor(t,e){super(t.space()),this.thing=e}search(){return this}}t.RLeaf=h}(t.Climate||(t.Climate={}));class Es{constructor(t){this.biome=t}getBiome(){return this.biome}static fromJson(t){var e,i;const n=null!=(e=mi.readObject(t))?e:{},s=Mi.parse(null!=(i=mi.readString(n.biome))?i:"minecraft:the_void");return new Es(s)}}class Is{constructor(t){this.parameters=t}getBiome(t,e,i,n){const s=n.sample(t,e,i);return this.parameters.find(s)}static fromJson(e){var i,n;const s=null!=(i=mi.readObject(e))?i:{},r=(null!=(n=mi.readArray(s.biomes,(e=>{var i,n,s;return n=null!=(i=mi.readObject(e))?i:{},{biome:Mi.parse(null!=(s=mi.readString(n.biome))?s:"minecraft:the_void"),parameters:t.Climate.ParamPoint.fromJson(n.parameters)}})))?n:[]).map((t=>[t.parameters,()=>t.biome]));return new Is(new t.Climate.Parameters(r))}}var Ns;t.Noises=void 0,function(e){function i(e,i,n){return t.WorldgenRegistries.NOISE.register(Mi.create(e),t.NoiseParameters.create(i,n))}e.TEMPERATURE=i("temperature",-10,[1.5,0,1,0,0,0]),e.VEGETATION=i("vegetation",-8,[1,1,0,0,0,0]),e.CONTINENTALNESS=i("continentalness",-9,[1,1,2,2,2,1,1,1,1]),e.EROSION=i("erosion",-9,[1,1,0,1,1]),e.TEMPERATURE_LARGE=i("temperature_large",-12,[1.5,0,1,0,0,0]),e.VEGETATION_LARGE=i("vegetation_large",-10,[1,1,0,0,0,0]),e.CONTINENTALNESS_LARGE=i("continentalness_large",-11,[1,1,2,2,2,1,1,1,1]),e.EROSION_LARGE=i("erosion_large",-11,[1,1,0,1,1]),e.RIDGE=i("ridge",-7,[1,2,1,0,0,0]),e.SHIFT=i("offset",-3,[1,1,1,0]),e.AQUIFER_BARRIER=i("aquifer_barrier",-3,[1]),e.AQUIFER_FLUID_LEVEL_FLOODEDNESS=i("aquifer_fluid_level_floodedness",-7,[1]),e.AQUIFER_FLUID_LEVEL_SPREAD=i("aquifer_fluid_level_spread",-5,[1]),e.AQUIFER_LAVA=i("aquifer_lava",-1,[1]),e.PILLAR=i("pillar",-7,[1,1]),e.PILLAR_RARENESS=i("pillar_rareness",-8,[1]),e.PILLAR_THICKNESS=i("pillar_thickness",-8,[1]),e.SPAGHETTI_2D=i("spaghetti_2d",-8,[1]),e.SPAGHETTI_2D_ELEVATION=i("spaghetti_2d_elevation",-8,[1]),e.SPAGHETTI_2D_MODULATOR=i("spaghetti_2d_modulator",-8,[1]),e.SPAGHETTI_2D_THICKNESS=i("spaghetti_2d_thickness",-8,[1]),e.SPAGHETTI_3D_1=i("spaghetti_3d_1",-8,[1]),e.SPAGHETTI_3D_2=i("spaghetti_3d_2",-8,[1]),e.SPAGHETTI_3D_RARITY=i("spaghetti_3d_rarity",-8,[1]),e.SPAGHETTI_3D_THICKNESS=i("spaghetti_3d_thickness",-8,[1]),e.SPAGHETTI_ROUGHNESS=i("spaghetti_roughness",-8,[1]),e.SPAGHETTI_ROUGHNESS_MODULATOR=i("spaghetti_roughness_modulator",-8,[1]),e.CAVE_ENTRANCE=i("cave_entrance",-7,[.4,.5,1]),e.CAVE_LAYER=i("cave_layer",-8,[1]),e.CAVE_CHEESE=i("cave_cheese",-8,[.5,1,2,1,2,1,0,2,0]),e.NOODLE=i("noodle",-8,[1]),e.NOODLE_THICKNESS=i("noodle_thickness",-8,[1]),e.NOODLE_RIDGE_A=i("noodle_ridge_a",-7,[1]),e.NOODLE_RIDGE_B=i("noodle_ridge_b",-7,[1]),e.JAGGED=i("jagged",-16,[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]),e.SURFACE=i("surface",-6,[1,1,1]),e.SURFACE_SECONDARY=i("surface_secondary",-6,[1,1,0,1]);const n=new Map;e.instantiate=function(t,e){var i;const s=null==(i=e.key())?void 0:i.toString();if(!s)throw new Error("Cannot instantiate noise from direct holder");const r=t.seedKey(),a=n.get(s);if(a&&a[0]===r[0]&&a[1]===r[1])return a[2];const o=new Tn(t.fromHashOf(s),e.value());return n.set(s,[r[0],r[1],o]),o}}(t.Noises||(t.Noises={})),t.NoiseSettings=void 0,function(t){function e(t){return t.ySize<<2}t.fromJson=function(t){var e,i,n,s,r;const a=null!=(e=mi.readObject(t))?e:{};return{minY:null!=(i=mi.readInt(a.min_y))?i:0,height:null!=(n=mi.readInt(a.height))?n:256,xzSize:null!=(s=mi.readInt(a.size_horizontal))?s:1,ySize:null!=(r=mi.readInt(a.size_vertical))?r:1}},t.cellHeight=e,t.cellWidth=function(t){return t.xzSize<<2},t.cellCountY=function(t){return t.height/e(t)},t.minCellY=function(t){return Math.floor(t.minY/e(t))}}(t.NoiseSettings||(t.NoiseSettings={})),t.NoiseSlideSettings=void 0,(Ns=t.NoiseSlideSettings||(t.NoiseSlideSettings={})).fromJson=function(t){var e,i,n,s;const r=null!=(e=mi.readObject(t))?e:{};return{target:null!=(i=mi.readNumber(r.target))?i:0,size:null!=(n=mi.readInt(r.size))?n:0,offset:null!=(s=mi.readInt(r.offset))?s:0}},Ns.apply=function(t,e,i){if(t.size<=0)return e;const n=(i-t.offset)/t.size;return tn(t.target,e,n)};var Rs=Object.defineProperty,Bs=Object.defineProperties,Ms=Object.getOwnPropertyDescriptors,Ts=Object.getOwnPropertySymbols,Cs=Object.prototype.hasOwnProperty,Os=Object.prototype.propertyIsEnumerable,Ps=(t,e,i)=>e in t?Rs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Fs=(t,e)=>{for(var i in e||(e={}))Cs.call(e,i)&&Ps(t,i,e[i]);if(Ts)for(var i of Ts(e))Os.call(e,i)&&Ps(t,i,e[i]);return t};t.NoiseRouter=void 0,function(e){const i=e=>t.Holder.parser(t.WorldgenRegistries.DENSITY_FUNCTION,xs.fromJson)(e).value();e.fromJson=function(t){var e;const n=null!=(e=mi.readObject(t))?e:{};return{barrier:i(n.barrier),fluidLevelFloodedness:i(n.fluid_level_floodedness),fluidLevelSpread:i(n.fluid_level_spread),lava:i(n.lava),temperature:i(n.temperature),vegetation:i(n.vegetation),continents:i(n.continents),erosion:i(n.erosion),depth:i(n.depth),ridges:i(n.ridges),initialDensityWithoutJaggedness:i(n.initial_density_without_jaggedness),finalDensity:i(n.final_density),veinToggle:i(n.vein_toggle),veinRidged:i(n.vein_ridged),veinGap:i(n.vein_gap)}},e.create=function(t){return Fs({barrier:xs.Constant.ZERO,fluidLevelFloodedness:xs.Constant.ZERO,fluidLevelSpread:xs.Constant.ZERO,lava:xs.Constant.ZERO,temperature:xs.Constant.ZERO,vegetation:xs.Constant.ZERO,continents:xs.Constant.ZERO,erosion:xs.Constant.ZERO,depth:xs.Constant.ZERO,ridges:xs.Constant.ZERO,initialDensityWithoutJaggedness:xs.Constant.ZERO,finalDensity:xs.Constant.ZERO,veinToggle:xs.Constant.ZERO,veinRidged:xs.Constant.ZERO,veinGap:xs.Constant.ZERO},t)},e.withSettings=function(t,e,i,s=!1){const r=(s?new yn(i):An.create(i)).forkPositional(),a=new n(r,e);return o=Fs({},a.mapAll(t)),l={aquiferPositionalRandomFactory:r.fromHashOf(Mi.create("aquifer").toString()).forkPositional(),oreVeinsPositionalRandomFactory:r.fromHashOf(Mi.create("ore").toString()).forkPositional()},Bs(o,Ms(l));var o,l};class n{constructor(t,e){this.random=t,this.settings=e,this.mapped=new Map}map(e){if(e instanceof xs.HolderHolder){const t=e.holder.key();if(void 0!==t&&this.mapped.has(t.toString()))return this.mapped.get(t.toString());{const i=e.holder.value().mapAll(this);return void 0!==t&&this.mapped.set(t.toString(),i),i}}if(e instanceof xs.Interpolated)return e.withCellSize(t.NoiseSettings.cellWidth(this.settings),t.NoiseSettings.cellHeight(this.settings));if(e instanceof xs.ShiftedNoise){const i=t.Noises.instantiate(this.random,e.noiseData);return new xs.ShiftedNoise(e.shiftX,e.shiftY,e.shiftZ,e.xzScale,e.yScale,e.noiseData,i)}return e instanceof xs.Noise?new xs.Noise(e.xzScale,e.yScale,e.noiseData,t.Noises.instantiate(this.random,e.noiseData)):e instanceof xs.ShiftNoise?e.withNewNoise(t.Noises.instantiate(this.random,e.noiseData)):e instanceof xs.WeirdScaledSampler?new xs.WeirdScaledSampler(e.input,e.rarityValueMapper,e.noiseData,t.Noises.instantiate(this.random,e.noiseData)):e instanceof xs.OldBlendedNoise?new xs.OldBlendedNoise(e.xzScale,e.yScale,e.xzFactor,e.yFactor,e.smearScaleMultiplier,new Bn(this.random.fromHashOf(Mi.create("terrain").toString()),e.xzScale,e.yScale,e.xzFactor,e.yFactor,e.smearScaleMultiplier)):e instanceof xs.Mapped||e instanceof xs.Ap2?e.withMinMax():e}mapAll(t){return{barrier:t.barrier.mapAll(this),fluidLevelFloodedness:t.fluidLevelFloodedness.mapAll(this),fluidLevelSpread:t.fluidLevelSpread.mapAll(this),lava:t.lava.mapAll(this),temperature:t.temperature.mapAll(this),vegetation:t.vegetation.mapAll(this),continents:t.continents.mapAll(this),erosion:t.erosion.mapAll(this),depth:t.depth.mapAll(this),ridges:t.ridges.mapAll(this),initialDensityWithoutJaggedness:t.initialDensityWithoutJaggedness.mapAll(this),finalDensity:t.finalDensity.mapAll(this),veinToggle:t.veinToggle.mapAll(this),veinRidged:t.veinRidged.mapAll(this),veinGap:t.veinGap.mapAll(this)}}}e.Visitor=n,e.computePreliminarySurfaceLevelScanning=function(e,i,n,s){const r=t.NoiseSettings.minCellY(e)+t.NoiseSettings.cellCountY(e),a=t.NoiseSettings.minCellY(e),o=t.NoiseSettings.cellHeight(e);for(let t=r;t>=a;t-=1){const e=t*o;if(Xi(i.compute(xs.context(n,e,s)),-64,64)>=.390625)return e}return Number.MAX_SAFE_INTEGER}}(t.NoiseRouter||(t.NoiseRouter={}));class Ls{constructor(e,i,n,s,r,a,o,l,h){this.cellCountXZ=e,this.cellCountY=i,this.cellNoiseMinY=n,this.router=s,this.minX=r,this.minZ=a,this.settings=o,this.preliminarySurfaceLevel=new Map,this.cellWidth=t.NoiseSettings.cellWidth(o),this.cellHeight=t.NoiseSettings.cellHeight(o),this.firstCellX=Math.floor(r/this.cellWidth),this.firstCellZ=Math.floor(a/this.cellWidth),this.firstNoiseX=r>>2,this.firstNoiseZ=a>>2,this.noiseSizeXZ=e*this.cellWidth>>2,this.aquifer=t.Aquifer.createDisabled(h);const u=this.router.finalDensity;this.materialRule=t.MaterialRule.fromList([t=>this.aquifer.compute(t,u.compute(t))]),this.initialDensityWithoutJaggedness=this.router.initialDensityWithoutJaggedness}getFinalState(t,e,i){return this.materialRule({x:t,y:e,z:i})}getPreliminarySurfaceLevel(e,i){return Ri(this.preliminarySurfaceLevel,t.ChunkPos.asLong(e,i),(()=>t.NoiseRouter.computePreliminarySurfaceLevelScanning(this.settings,this.initialDensityWithoutJaggedness,e<<2,i<<2)))}getAquifer(){return this.aquifer}}t.MaterialRule=void 0,(t.MaterialRule||(t.MaterialRule={})).fromList=function(t){return e=>{for(const i of t){const t=i(e);if(t)return t}}},t.VerticalAnchor=void 0,(t.VerticalAnchor||(t.VerticalAnchor={})).fromJson=function(t){var e,i,n,s;const r=null!=(e=mi.readObject(t))?e:{};return void 0!==r.absolute?(a=null!=(i=mi.readNumber(r.absolute))?i:0,()=>a):void 0!==r.above_bottom?function(t){return e=>e.minY+t}(null!=(n=mi.readNumber(r.above_bottom))?n:0):void 0!==r.below_top?function(t){return e=>e.maxY-t}(null!=(s=mi.readNumber(r.below_top))?s:0):()=>0;var a},t.WorldgenContext=void 0,(t.WorldgenContext||(t.WorldgenContext={})).create=function(t,e){return{minY:t,height:e,maxY:t+e-1}};class Ds{constructor(e,i,n){this.rule=e,this.defaultBlock=i,this.random=An.create(n).forkPositional(),this.surfaceNoise=t.Noises.instantiate(this.random,t.Noises.SURFACE),this.surfaceSecondaryNoise=t.Noises.instantiate(this.random,t.Noises.SURFACE_SECONDARY),this.positionalRandoms=new Map}buildSurface(e,i,n,s){const r=t.ChunkPos.minBlockX(e.pos),a=t.ChunkPos.minBlockZ(e.pos),o=new zs(this,e,i,n,s),l=this.rule(o);for(let i=0;i<16;i+=1){const n=r+i;for(let i=0;i<1;i+=1){const s=a+i;o.updateXZ(n,s);let r=0,h=Number.MIN_SAFE_INTEGER,u=Number.MAX_SAFE_INTEGER;for(let i=e.maxY;i>=e.minY;i-=1){const a=t.BlockPos.create(n,i,s),c=e.getBlockState(a);if(c.equals(Ui.AIR)){r=0,h=Number.MIN_SAFE_INTEGER;continue}if(c.isFluid()){h===Number.MIN_SAFE_INTEGER&&(h=i+1);continue}if(u>=i){u=Number.MIN_SAFE_INTEGER;for(let r=i-1;r>=e.minY;r-=1){const i=e.getBlockState(t.BlockPos.create(n,r,s));if(i.equals(Ui.AIR)||i.isFluid()){u=r+1;break}}}r+=1;const d=i-u+1;if(!c.equals(this.defaultBlock))continue;o.updateY(r,d,h,i);const f=l(n,i,s);f&&e.setBlockState(a,f)}}}}getSurfaceDepth(t,e){return 2.75*this.surfaceNoise.sample(t,0,e)+3+.25*this.random.at(t,0,e).nextDouble()}getSurfaceSecondary(t,e){return this.surfaceSecondaryNoise.sample(t,0,e)}getRandom(t){return Ri(this.positionalRandoms,t,(()=>this.random.fromHashOf(t)))}}class zs{constructor(t,e,i,n,s){this.system=t,this.chunk=e,this.noiseChunk=i,this.context=n,this.getBiome=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}updateXZ(t,e){this.blockX=t,this.blockZ=e,this.surfaceDepth=this.system.getSurfaceDepth(t,e),this.surfaceSecondary=Ni((()=>this.system.getSurfaceSecondary(t,e))),this.minSurfaceLevel=Ni((()=>this.calculateMinSurfaceLevel(t,e)))}updateY(e,i,n,s){this.blockY=s,this.stoneDepthAbove=e,this.stoneDepthBelow=i,this.waterHeight=n,this.biome=Ni((()=>this.getBiome(t.BlockPos.create(this.blockX,this.blockY,this.blockZ))))}calculateMinSurfaceLevel(t,e){const i=t>>4,n=e>>4,s=this.noiseChunk.getPreliminarySurfaceLevel(i<<4,n<<4),r=this.noiseChunk.getPreliminarySurfaceLevel(i+1<<4,n<<4),a=this.noiseChunk.getPreliminarySurfaceLevel(i<<4,n+1<<4),o=this.noiseChunk.getPreliminarySurfaceLevel(i+1<<4,n+1<<4);return Math.floor(qi((15&t)/16,(15&e)/16,s,r,a,o))+this.surfaceDepth-8}}t.SurfaceRule=void 0,function(e){function i(t){return()=>()=>t}function n(t){return e=>{const i=t.map((t=>t(e)));return(t,e,n)=>{for(const s of i){const i=s(t,e,n);if(i)return i}}}}function s(t,e){return i=>(n,s,r)=>{if(t(i))return e(i)(n,s,r)}}e.NOOP=()=>()=>{},e.fromJson=function(r){var a,o,l;const h=null!=(a=mi.readObject(r))?a:{};switch(null==(o=mi.readString(h.type))?void 0:o.replace(/^minecraft:/,"")){case"block":return i(Ui.fromJson(h.result_state));case"sequence":return n(null!=(l=mi.readArray(h.sequence,e.fromJson))?l:[]);case"condition":return s(t.SurfaceCondition.fromJson(h.if_true),e.fromJson(h.then_run))}return e.NOOP},e.block=i,e.sequence=n,e.condition=s}(t.SurfaceRule||(t.SurfaceRule={})),t.SurfaceCondition=void 0,function(e){function i(){return t=>t.blockY>=t.minSurfaceLevel()}function n(t){const e=new Set(t);return t=>e.has(t.biome())}function s(t){return e=>!t(e)}function r(t,e,i,n){return s=>{const r=n?s.stoneDepthBelow:s.stoneDepthAbove,a=e?s.surfaceDepth:0,o=0===i?0:sn(s.surfaceSecondary(),-1,1,0,i);return r<=1+t+a+o}}function a(t,e,i){return n=>{const s=e(n.context),r=i(n.context);if(n.blockY<=s)return!0;if(n.blockY>=r)return!1;const a=n.system.getRandom(t),o=sn(n.blockY,s,r,1,0);return a.nextFloat()<o}}function o(t,e,i){return n=>{if(n.waterHeight===Number.MIN_SAFE_INTEGER)return!0;const s=i?n.stoneDepthAbove:0;return n.blockY+s>=n.waterHeight+t+n.surfaceDepth*e}}function l(t,e,i){return n=>{const s=i?n.stoneDepthAbove:0;return n.blockY+s>=t(n.context)+n.surfaceDepth*e}}e.FALSE=()=>!1,e.TRUE=()=>!0,e.fromJson=function(i){var h,u,c,d,f,m,p,g,_,b,w,v;const y=null!=(h=mi.readObject(i))?h:{};switch(null==(u=mi.readString(y.type))?void 0:u.replace(/^minecraft:/,"")){case"above_preliminary_surface":return t=>t.blockY>=t.minSurfaceLevel();case"biome":return n(null!=(c=mi.readArray(y.biome_is,(t=>{var e;return null!=(e=mi.readString(t))?e:""})))?c:[]);case"not":return s(e.fromJson(y.invert));case"stone_depth":return r(null!=(d=mi.readInt(y.offset))?d:0,null!=(f=mi.readBoolean(y.add_surface_depth))&&f,null!=(m=mi.readInt(y.secondary_depth_range))?m:0,"ceiling"===mi.readString(y.surface_type));case"vertical_gradient":return a(null!=(p=mi.readString(y.random_name))?p:"",t.VerticalAnchor.fromJson(y.true_at_and_below),t.VerticalAnchor.fromJson(y.false_at_and_above));case"water":return o(null!=(g=mi.readInt(y.offset))?g:0,null!=(_=mi.readInt(y.surface_depth_multiplier))?_:0,null!=(b=mi.readBoolean(y.add_surface_depth))&&b);case"y_above":return l(t.VerticalAnchor.fromJson(y.anchor),null!=(w=mi.readInt(y.surface_depth_multiplier))?w:0,null!=(v=mi.readBoolean(y.add_surface_depth))&&v)}return e.FALSE},e.abovePreliminarySurface=i,e.biome=n,e.not=s,e.stoneDepth=r,e.verticalGradient=a,e.water=o,e.yAbove=l}(t.SurfaceCondition||(t.SurfaceCondition={}));t.NoiseGeneratorSettings=void 0,(t.NoiseGeneratorSettings||(t.NoiseGeneratorSettings={})).fromJson=function(e){var i,n,s,r,a,o;const l=null!=(i=mi.readObject(e))?i:{};return{surfaceRule:t.SurfaceRule.fromJson(l.surface_rule),noise:t.NoiseSettings.fromJson(l.noise),defaultBlock:Ui.fromJson(l.default_block),defaultFluid:Ui.fromJson(l.default_fluid),noiseRouter:t.NoiseRouter.fromJson(l.noise_router),seaLevel:null!=(n=mi.readInt(l.sea_level))?n:0,disableMobGeneration:null!=(s=mi.readBoolean(l.disable_mob_generation))&&s,aquifersEnabled:null!=(r=mi.readBoolean(l.aquifers_enabled))&&r,oreVeinsEnabled:null!=(a=mi.readBoolean(l.ore_veins_enabled))&&a,legacyRandomSource:null!=(o=mi.readBoolean(l.legacy_random_source))&&o}},t.BlendedNoise=Bn,t.BlockColors=Gn,t.BlockDefinition=hs,t.BlockModel=ms,t.BlockState=Ui,t.Chunk=class{constructor(t,e,i){this.minY=t,this.height=e,this.pos=i,this.sections=Array(this.sectionsCount).fill(null)}get maxY(){return this.minY+this.height}get minSection(){return this.minY>>4}get maxSection(){return 1+(this.maxY-1>>4)}get sectionsCount(){return this.maxSection-this.minSection}getSectionIndex(t){return(t>>4)-this.minSection}getBlockState(t){var e;const[i,n,s]=t,r=this.sections[this.getSectionIndex(n)];return null!=(e=null==r?void 0:r.getBlockState(15&i,15&n,15&s))?e:Ui.AIR}setBlockState(t,e){const[i,n,s]=t,r=this.getSectionIndex(n);let a=this.sections[r];if(null===a){if(e.equals(Ui.AIR))return;a=this.getOrCreateSection(r)}a.setBlockState(15&i,15&n,15&s,e)}getOrCreateSection(t){return null==this.sections[t]&&(this.sections[t]=new Zi(this.minSection+t)),this.sections[t]}},t.ChunkSection=Zi,t.DensityFunction=xs,t.FixedBiome=Es,t.FluidStatus=ks,t.Identifier=Mi,t.ImprovedNoise=Nn,t.LegacyPositionalRandom=xn,t.LegacyRandom=yn,t.MultiNoise=Is,t.NbtReader=di,t.NbtWriter=fi,t.NoiseAquifer=Ss,t.NoiseChunk=Ls,t.NoiseChunkGenerator=class{constructor(e,i,n){this.biomeSource=i,this.settings=n,this.router=t.NoiseRouter.withSettings(n.noiseRouter,n.noise,e,n.legacyRandomSource),this.noiseChunkCache=new Map,this.surfaceSystem=new Ds(n.surfaceRule,n.defaultBlock,e);const s=new ks(-54,Ui.LAVA),r=new ks(n.seaLevel,n.defaultFluid);this.globalFluidPicker=(t,e,i)=>e<Math.min(-54,n.seaLevel)?s:r}fill(e,i=!1){var n;const s=Math.max(e.minY,this.settings.noise.minY),r=Math.min(e.maxY,this.settings.noise.minY+this.settings.noise.height),a=t.NoiseSettings.cellWidth(this.settings.noise),o=t.NoiseSettings.cellHeight(this.settings.noise),l=Math.floor(16/a),h=Math.floor(s/o),u=Math.floor((r-s)/o),c=t.ChunkPos.minBlockX(e.pos),d=t.ChunkPos.minBlockZ(e.pos),f=this.getNoiseChunk(e);for(let t=0;t<l;t+=1)for(let s=0;s<(i?1:l);s+=1){let r=e.getOrCreateSection(e.sectionsCount-1);for(let l=u-1;l>=0;l-=1)for(let u=o-1;u>=0;u-=1){const m=(h+l)*o+u,p=15&m,g=e.getSectionIndex(m);e.getSectionIndex(r.minBlockY)!==g&&(r=e.getOrCreateSection(g));for(let e=0;e<a;e+=1){const o=c+t*a+e,l=15&o;for(let t=0;t<(i?1:a);t+=1){const e=d+s*a+t,i=15&e,h=null!=(n=f.getFinalState(o,m,e))?n:this.settings.defaultBlock;r.setBlockState(l,p,i,h)}}}}}buildSurface(e,i="minecraft:plains"){const n=this.getNoiseChunk(e),s=t.WorldgenContext.create(this.settings.noise.minY,this.settings.noise.height);this.surfaceSystem.buildSurface(e,n,s,(()=>i))}getNoiseChunk(e){return Ri(this.noiseChunkCache,t.ChunkPos.toLong(e.pos),(()=>{const i=Math.max(e.minY,this.settings.noise.minY),n=Math.min(e.maxY,this.settings.noise.minY+this.settings.noise.height),s=t.NoiseSettings.cellWidth(this.settings.noise),r=t.NoiseSettings.cellHeight(this.settings.noise),a=Math.floor(16/s),o=Math.floor(i/r),l=Math.floor((n-i)/r),h=t.ChunkPos.minBlockX(e.pos),u=t.ChunkPos.minBlockZ(e.pos);return new Ls(a,l,o,this.router,h,u,this.settings.noise,this.settings.aquifersEnabled,this.globalFluidPicker)}))}},t.NormalNoise=Tn,t.PerlinNoise=Rn,t.PerlinSimplexNoise=class{constructor(t,e){const i=e[e.length-1],n=-e[0]+i+1,s=new Set(e),r=new In(t);this.noiseLevels=Array(n),i>=0&&i<n&&s.has(0)&&(this.noiseLevels[i]=r);for(let e=i+1;e<n;e+=1)e>=0&&s.has(i-e)?this.noiseLevels[e]=new In(t):t.consume(262);if(i>0)throw new Error("Positive octaves are not allowed");this.highestFreqInputFactor=Math.pow(2,i),this.highestFreqValueFactor=1/(Math.pow(2,n)-1)}sample(t,e,i){let n=0,s=this.highestFreqInputFactor,r=this.highestFreqValueFactor;for(let a=0;a<this.noiseLevels.length;a+=1){const o=this.noiseLevels[a];o&&(n+=r*o.sample2D(t*s+(i?o.xo:0),e*s+(i?o.yo:0))),s/=2,r*=2}return n}},t.Registry=Yi,t.SimplexNoise=In,t.Structure=Hi,t.StructureRenderer=class{constructor(t,e,i,n){var s,r;this.gl=t,this.structure=e,this.resources=i,this.chunks=[],(null==n?void 0:n.facesPerBuffer)&&console.warn("webgl render warning: facesPerBuffer option has been removed in favor of chunkSize"),this.chunkSize=null!=(s=null==n?void 0:n.chunkSize)?s:16,this.useInvisibleBlockBuffer=null==(r=null==n?void 0:n.useInvisibleBlockBuffer)||r,this.shaderProgram=new ps(t,"\n attribute vec4 vertPos;\n attribute vec2 texCoord;\n attribute vec3 tintColor;\n attribute vec3 normal;\n\n uniform mat4 mView;\n uniform mat4 mProj;\n\n varying highp vec2 vTexCoord;\n varying highp vec3 vTintColor;\n varying highp float vLighting;\n\n void main(void) {\n gl_Position = mProj * mView * vertPos;\n vTexCoord = texCoord;\n vTintColor = tintColor;\n vLighting = normal.y * 0.2 + abs(normal.z) * 0.1 + 0.8;\n }\n","\n precision highp float;\n varying highp vec2 vTexCoord;\n varying highp vec3 vTintColor;\n varying highp float vLighting;\n\n uniform sampler2D sampler;\n\n void main(void) {\n vec4 texColor = texture2D(sampler, vTexCoord);\n if(texColor.a < 0.01) discard;\n gl_FragColor = vec4(texColor.xyz * vTintColor * vLighting, texColor.a);\n }\n").getProgram(),this.gridShaderProgram=new ps(t,"\n attribute vec4 vertPos;\n attribute vec3 vertColor;\n\n uniform mat4 mView;\n uniform mat4 mProj;\n\n varying highp vec3 vColor;\n\n void main(void) {\n gl_Position = mProj * mView * vertPos;\n vColor = vertColor;\n }\n","\n precision highp float;\n varying highp vec3 vColor;\n\n void main(void) {\n gl_FragColor = vec4(vColor, 1.0);\n }\n").getProgram(),this.colorShaderProgram=new ps(t,"\n attribute vec4 vertPos;\n attribute vec3 blockPos;\n\n uniform mat4 mView;\n uniform mat4 mProj;\n\n varying highp vec3 vColor;\n\n void main(void) {\n gl_Position = mProj * mView * vertPos;\n vColor = blockPos / 256.0;\n }\n","\n precision highp float;\n varying highp vec3 vColor;\n\n void main(void) {\n gl_FragColor = vec4(vColor, 1.0);\n }\n").getProgram(),this.updateStructureBuffers(),this.gridBuffers=this.getGridBuffers(),this.outlineBuffers=this.getOutlineBuffers(),this.invisibleBlockBuffers=this.getInvisibleBlockBuffers(),this.atlasTexture=this.getBlockTexture(),this.projMatrix=this.getPerspective(),this.activeShader=this.shaderProgram,this.initialize()}setStructure(t){this.structure=t,this.updateStructureBuffers(),this.gridBuffers=this.getGridBuffers(),this.invisibleBlockBuffers=this.getInvisibleBlockBuffers()}initialize(){this.gl.enable(this.gl.DEPTH_TEST),this.gl.depthFunc(this.gl.LEQUAL),this.gl.enable(this.gl.BLEND),this.gl.blendFunc(this.gl.SRC_ALPHA,this.gl.ONE_MINUS_SRC_ALPHA),this.gl.enable(this.gl.CULL_FACE),this.gl.cullFace(this.gl.BACK)}getBlockTexture(){const t=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,t),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,this.resources.getTextureAtlas()),this.gl.generateMipmap(this.gl.TEXTURE_2D),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.NEAREST),t}getPerspective(){const t=70*Math.PI/180,e=this.gl.canvas.clientWidth/this.gl.canvas.clientHeight,i=qn();return function(t,e,i,n,s){var r,a=1/Math.tan(e/2);t[0]=a/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,null!=s&&s!==1/0?(r=1/(n-s),t[10]=(s+n)*r,t[14]=2*s*n*r):(t[10]=-1,t[14]=-2*n)}(i,t,e,.1,500),i}getChunk(t){const e=2*Math.abs(t[0])+(t[0]<0?1:0),i=2*Math.abs(t[1])+(t[1]<0?1:0),n=2*Math.abs(t[2])+(t[2]<0?1:0);return this.chunks[e]||(this.chunks[e]=[]),this.chunks[e][i]||(this.chunks[e][i]=[]),this.chunks[e][i][n]||(this.chunks[e][i][n]={positions:[],textureCoordinates:[],tintColors:[],blockPositions:[],normals:[],indices:[],indexOffset:0}),this.chunks[e][i][n]}updateStructureBuffers(e){var i;const n=(t,e,i)=>{const n=qn();Jn(n,n,e),ls(t.position,n),i.positions.push(t.position),i.textureCoordinates.push(...t.texCoord),i.tintColors.push(...t.tintColor);for(let e=0;e<t.position.length;e+=12){const n=es(t.position[e],t.position[e+1],t.position[e+2]),s=es(t.position[e+3],t.position[e+4],t.position[e+5]),r=es(t.position[e+6],t.position[e+7],t.position[e+8]);is(s,s,n),is(r,r,n),ss(s,s,r),ns(s,s),i.normals.push(...s,...s,...s,...s)}for(let n=0;n<t.texCoord.length/2;n+=1)i.blockPositions.push(...e);i.indices.push(...t.index),i.indexOffset+=t.texCoord.length/2},s=t=>{t.positions=[],t.textureCoordinates=[],t.tintColors=[],t.blockPositions=[],t.normals=[],t.indices=[],t.indexOffset=0},r=t=>{t.buffer?(this.updateBuffer(t.buffer.position,this.gl.ARRAY_BUFFER,os(...t.positions)),this.updateBuffer(t.buffer.texCoord,this.gl.ARRAY_BUFFER,new Float32Array(t.textureCoordinates)),this.updateBuffer(t.buffer.tintColor,this.gl.ARRAY_BUFFER,new Float32Array(t.tintColors)),this.updateBuffer(t.buffer.normal,this.gl.ARRAY_BUFFER,new Float32Array(t.normals)),this.updateBuffer(t.buffer.blockPos,this.gl.ARRAY_BUFFER,new Float32Array(t.blockPositions)),this.updateBuffer(t.buffer.index,this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(t.indices)),t.buffer.length=t.indices.length):t.buffer={position:this.createBuffer(this.gl.ARRAY_BUFFER,os(...t.positions)),texCoord:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(t.textureCoordinates)),tintColor:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(t.tintColors)),blockPos:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(t.blockPositions)),normal:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(t.normals)),index:this.createBuffer(this.gl.ELEMENT_ARRAY_BUFFER,new Uint16Array(t.indices)),length:t.indices.length}};let a;e?e.forEach((t=>{const e=this.getChunk(t);s(e)})):this.chunks.forEach((t=>t.forEach((t=>t.forEach((t=>{s(t)}))))));for(const s of this.structure.getBlocks()){const r=s.state.getName(),o=s.state.getProperties(),l=null!=(i=this.resources.getDefaultBlockProperties(r))?i:{};Object.entries(l).forEach((([t,e])=>{o[t]||(o[t]=e)}));const h=[Math.floor(s.pos[0]/this.chunkSize),Math.floor(s.pos[1]/this.chunkSize),Math.floor(s.pos[2]/this.chunkSize)];if(e&&!e.some((t=>as(t,h))))continue;const u=this.getChunk(h);try{const e=this.resources.getBlockDefinition(r),i={up:this.needsCull(s,t.Direction.UP),down:this.needsCull(s,t.Direction.DOWN),west:this.needsCull(s,t.Direction.WEST),east:this.needsCull(s,t.Direction.EAST),north:this.needsCull(s,t.Direction.NORTH),south:this.needsCull(s,t.Direction.SOUTH)};e&&(a=e.getBuffers(r,o,this.resources,this.resources,u.indexOffset,i),n(a,s.pos,u)),ws.has(r.toString())&&(a=bs[r.toString()](u.indexOffset,o,this.resources,i),n(a,s.pos,u))}catch(t){console.error(`Error rendering block ${r}`,t)}}e?e.forEach((t=>{const e=this.getChunk(t);r(e)})):this.chunks.forEach((t=>t.forEach((t=>t.forEach((t=>{r(t)}))))))}needsCull(e,i){var n,s;const r=null==(n=this.structure.getBlock(t.BlockPos.towards(e.pos,i)))?void 0:n.state;return!!r&&((null==(s=this.resources.getBlockFlags(r.getName()))?void 0:s.opaque)?!(i===t.Direction.UP&&e.state.isFluid()):e.state.isFluid()&&r.isFluid())}getGridBuffers(){const[t,e,i]=this.structure.getSize(),n=[],s=[];n.push(0,0,0,t,0,0),s.push(1,0,0,1,0,0),n.push(0,0,0,0,0,i),s.push(0,0,1,0,0,1),n.push(0,0,0,0,e,0),n.push(t,0,0,t,e,0),n.push(0,0,i,0,e,i),n.push(t,0,i,t,e,i),n.push(0,e,0,0,e,i),n.push(t,e,0,t,e,i),n.push(0,e,0,t,e,0),n.push(0,e,i,t,e,i);for(let e=1;e<=t;e+=1)n.push(e,0,0,e,0,i);for(let e=1;e<=i;e+=1)n.push(0,0,e,t,0,e);for(let e=0;e<8+t+i;e+=1)s.push(.8,.8,.8,.8,.8,.8);return{position:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(n)),color:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(s)),length:n.length/3}}getOutlineBuffers(){const t=[],e=[];return this.addCube(t,e,[1,1,1],[0,0,0],[1,1,1]),{position:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(t)),color:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(e)),length:t.length/3}}getInvisibleBlockBuffers(){if(!this.useInvisibleBlockBuffer)return;const t=this.structure.getSize(),e=[],i=[];for(let n=0;n<t[0];n+=1)for(let s=0;s<t[1];s+=1)for(let r=0;r<t[2];r+=1){const t=this.structure.getBlock([n,s,r]);void 0!==t&&(null===t?this.addCube(e,i,[1,.25,.25],[n+.4375,s+.4375,r+.4375],[n+.5625,s+.5625,r+.5625]):t.state.is(Ui.AIR)?this.addCube(e,i,[.5,.5,1],[n+.375,s+.375,r+.375],[n+.625,s+.625,r+.625]):t.state.is(new Ui("cave_air"))&&this.addCube(e,i,[.5,1,.5],[n+.375,s+.375,r+.375],[n+.625,s+.625,r+.625]))}return{position:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(e)),color:this.createBuffer(this.gl.ARRAY_BUFFER,new Float32Array(i)),length:e.length/3}}addCube(t,e,i,n,s){t.push(n[0],n[1],n[2],n[0],n[1],s[2]),t.push(s[0],n[1],n[2],s[0],n[1],s[2]),t.push(n[0],n[1],n[2],s[0],n[1],n[2]),t.push(n[0],n[1],s[2],s[0],n[1],s[2]),t.push(n[0],n[1],n[2],n[0],s[1],n[2]),t.push(s[0],n[1],n[2],s[0],s[1],n[2]),t.push(n[0],n[1],s[2],n[0],s[1],s[2]),t.push(s[0],n[1],s[2],s[0],s[1],s[2]),t.push(n[0],s[1],n[2],n[0],s[1],s[2]),t.push(s[0],s[1],n[2],s[0],s[1],s[2]),t.push(n[0],s[1],n[2],s[0],s[1],n[2]),t.push(n[0],s[1],s[2],s[0],s[1],s[2]);for(let t=0;t<24;t+=1)e.push(...i)}createBuffer(t,e){const i=this.gl.createBuffer();return this.gl.bindBuffer(t,i),this.gl.bufferData(t,e,this.gl.DYNAMIC_DRAW),i}updateBuffer(t,e,i){this.gl.bindBuffer(e,t),this.gl.bufferData(e,i,this.gl.STATIC_DRAW)}drawGrid(t){this.setShader(this.gridShaderProgram),this.setVertexAttr("vertPos",3,this.gridBuffers.position),this.setVertexAttr("vertColor",3,this.gridBuffers.color),this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix),this.gl.drawArrays(this.gl.LINES,0,this.gridBuffers.length)}drawInvisibleBlocks(t){this.useInvisibleBlockBuffer&&(this.setShader(this.gridShaderProgram),this.setVertexAttr("vertPos",3,this.invisibleBlockBuffers.position),this.setVertexAttr("vertColor",3,this.invisibleBlockBuffers.color),this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix),this.gl.drawArrays(this.gl.LINES,0,this.invisibleBlockBuffers.length))}drawStructure(t){this.setShader(this.shaderProgram),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.atlasTexture),this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix),this.chunks.forEach((t=>{t.forEach((t=>{t.forEach((t=>{t.buffer&&(this.setVertexAttr("vertPos",3,t.buffer.position),this.setVertexAttr("texCoord",2,t.buffer.texCoord),this.setVertexAttr("tintColor",3,t.buffer.tintColor),this.setVertexAttr("normal",3,t.buffer.normal),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t.buffer.index),this.gl.drawElements(this.gl.TRIANGLES,t.buffer.length,this.gl.UNSIGNED_SHORT,0))}))}))}))}drawColoredStructure(t){this.setShader(this.colorShaderProgram),this.setUniform("mView",t),this.setUniform("mProj",this.projMatrix),this.chunks.forEach((t=>{t.forEach((t=>{t.forEach((t=>{t.buffer&&(this.setVertexAttr("vertPos",3,t.buffer.position),this.setVertexAttr("blockPos",3,t.buffer.blockPos),this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER,t.buffer.index),this.gl.drawElements(this.gl.TRIANGLES,t.buffer.length,this.gl.UNSIGNED_SHORT,0))}))}))}))}drawOutline(t,e){this.setShader(this.gridShaderProgram),this.setVertexAttr("vertPos",3,this.outlineBuffers.position),this.setVertexAttr("vertColor",3,this.outlineBuffers.color);const i=qn();var n,s;s=t,(n=i)[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3],n[4]=s[4],n[5]=s[5],n[6]=s[6],n[7]=s[7],n[8]=s[8],n[9]=s[9],n[10]=s[10],n[11]=s[11],n[12]=s[12],n[13]=s[13],n[14]=s[14],n[15]=s[15],Jn(i,i,e),this.setUniform("mView",i),this.setUniform("mProj",this.projMatrix),this.gl.drawArrays(this.gl.LINES,0,this.outlineBuffers.length)}setViewport(t,e,i,n){this.gl.viewport(t,e,i,n),this.projMatrix=this.getPerspective()}setShader(t){this.gl.useProgram(t),this.activeShader=t}setVertexAttr(t,e,i){const n=this.gl.getAttribLocation(this.activeShader,t);this.gl.bindBuffer(this.gl.ARRAY_BUFFER,i),this.gl.vertexAttribPointer(n,e,this.gl.FLOAT,!1,0,0),this.gl.enableVertexAttribArray(n)}setUniform(t,e){const i=this.gl.getUniformLocation(this.activeShader,t);this.gl.uniformMatrix4fv(i,!1,e)}},t.SurfaceContext=zs,t.SurfaceSystem=Ds,t.TextureAtlas=ys,t.XoroshiroPositionalRandom=Sn,t.XoroshiroRandom=An,t.binarySearch=an,t.clamp=Xi,t.clampedLerp=tn,t.clampedMap=rn,t.getListTag=Ei,t.getOptional=Ii,t.getSeed=on,t.getTag=Si,t.inverseLerp=en,t.isPowerOfTwo=hn,t.lazyLerp=Ji,t.lazyLerp2=Ki,t.lazyLerp3=Qi,t.lerp=Wi,t.lerp2=qi,t.lerp3=$i,t.loadChunk=function(t){switch(t.compression){case 1:t.nbt=yi(t.data,{compression:"gzip"});break;case 2:t.nbt=yi(t.data,{compression:"zlib"});break;case 3:t.nbt=xi(t.data);break;default:throw new Error(`Invalid compression mode ${t.compression}`)}return t},t.longfromBytes=ln,t.map=sn,t.readNbt=yi,t.readNbtRaw=xi,t.readRegion=function(t){const e=[];for(let i=0;i<32;i+=1)for(let n=0;n<32;n+=1){const s=4*((31&i)+32*(31&n));if(0===t[s+3])continue;const r=(t[s]<<16)+(t[s+1]<<8)+t[s+2],a=(t[s+4096]<<24)+(t[s+4097]<<16)+(t[s+4098]<<8)+t[s+4099],o=4096*r,l=(t[o]<<24)+(t[o+1]<<16)+(t[o+2]<<8)+t[o+3],h=t[o+4],u=t.slice(o+5,o+4+l);e.push({x:i,z:n,timestamp:a,compression:h,data:u})}return e},t.saveChunk=function(t){if(!t.nbt)throw new Error("Cannot save chunk data, chunk is not loaded");const{name:e,value:i}=t.nbt;switch(t.compression){case 1:t.data=ki(i,{name:e,compression:"gzip"});break;case 2:t.data=ki(i,{name:e,compression:"zlib"});break;case 3:t.data=ki(i,{name:e});break;default:throw new Error(`Invalid compression mode ${t.compression}`)}return t},t.smoothstep=nn,t.square=ji,t.tagNames=ci,t.tagTypes=ui,t.upperPowerOfTwo=un,t.writeNbt=ki,t.writeNbtRaw=Ai,t.writeRegion=function(t){let e=0;for(const i of t)e+=Math.ceil(i.data.length/4096);const i=new Uint8Array(8192+4096*e),n=new DataView(i.buffer);let s=2;for(const e of t){const t=4*((31&e.x)+32*(31&e.z)),r=Math.ceil(e.data.length/4096);n.setInt8(t,s>>16),n.setInt16(t+1,65535&s),n.setInt8(t+3,r),n.setInt32(t+4096,e.timestamp);const a=4096*s;n.setInt32(a,e.data.length+1),n.setInt8(a+4,e.compression),i.set(e.data,a+5),s+=r}return i},Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=deepslate.umd.js.map
|