e57-js 1.0.2
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/README.md +223 -0
- package/dist/index.mjs +21 -0
- package/dist/libe57-js.js +8886 -0
- package/dist/libe57-js.wasm +0 -0
- package/package.json +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# e57-js
|
|
2
|
+
|
|
3
|
+
Node.js library for reading and writing **E57 point cloud files**.
|
|
4
|
+
|
|
5
|
+
> **What is a point cloud?** A point cloud is a collection of 3D points in space, typically captured by a laser scanner (LiDAR). Each point has X, Y, Z coordinates and optionally colour, intensity, and other data. E57 is the standard file format for storing them.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install e57-js
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Requires **Node.js 18 or higher**.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Setup
|
|
20
|
+
|
|
21
|
+
Before doing anything, call `E57.Init()` once and wait for it to finish. This loads the underlying WebAssembly module.
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { E57, E57Reader, E57Writer } from 'e57-js'
|
|
25
|
+
|
|
26
|
+
await E57.Init()
|
|
27
|
+
|
|
28
|
+
// Now you can create readers and writers
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Reading a file
|
|
34
|
+
|
|
35
|
+
### Open the file
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
const reader = new E57Reader('scan.e57')
|
|
39
|
+
|
|
40
|
+
console.log(reader.GetData3DCount()) // number of 3D scans
|
|
41
|
+
console.log(reader.GetImage2DCount()) // number of embedded images
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Read the points from a scan
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
const scan = reader.GetScan(0) // get the first scan (index 0)
|
|
48
|
+
|
|
49
|
+
const header = scan.GetHeader()
|
|
50
|
+
console.log(`This scan has ${header.pointCount} points`)
|
|
51
|
+
|
|
52
|
+
// Read all points at once
|
|
53
|
+
const points = await scan.ReadScan()
|
|
54
|
+
|
|
55
|
+
for (let i = 0; i < points.size(); i++) {
|
|
56
|
+
const pt = points.get(i)
|
|
57
|
+
console.log(pt.cartesianX, pt.cartesianY, pt.cartesianZ)
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Read in chunks (better for large files)
|
|
62
|
+
|
|
63
|
+
Reading millions of points all at once can use a lot of memory. Use `ScanPoints` to process them in smaller batches:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
await scan.ScanPoints(1000, (chunk) => {
|
|
67
|
+
for (let i = 0; i < chunk.size(); i++) {
|
|
68
|
+
const pt = chunk.get(i)
|
|
69
|
+
// process pt...
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Apply the scan pose (position and orientation)
|
|
75
|
+
|
|
76
|
+
A scan's pose describes where the scanner was placed in the world. When you read with `ReadScan()` the pose is applied automatically — the returned coordinates are already in world space.
|
|
77
|
+
|
|
78
|
+
Pass `false` to get the raw local coordinates instead:
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
const worldPoints = await scan.ReadScan() // world coordinates (default)
|
|
82
|
+
const localPoints = await scan.ReadScan(false) // raw scanner-local coordinates
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Read an embedded image
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
const image = reader.GetImage(0)
|
|
89
|
+
const header = image.GetHeader()
|
|
90
|
+
console.log(header.width, header.height)
|
|
91
|
+
|
|
92
|
+
// Get the image as a byte buffer
|
|
93
|
+
const bytes = await image.ReadImage() // Uint8Array
|
|
94
|
+
|
|
95
|
+
// Or save it directly to disk (extension is auto-detected)
|
|
96
|
+
await image.Save('output') // writes output.jpeg or output.png
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Synchronous versions
|
|
100
|
+
|
|
101
|
+
Every async method has a sync equivalent if you prefer blocking calls:
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const points = scan.ReadScanSync()
|
|
105
|
+
const bytes = image.ReadImageSync()
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Writing a file
|
|
111
|
+
|
|
112
|
+
### Create the file
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
const writer = new E57Writer('output.e57')
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Write a 3D scan
|
|
119
|
+
|
|
120
|
+
First, describe what fields your points will have (the header), then pass your array of points:
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
// 1 — describe the scan
|
|
124
|
+
const header = new E57.LibE57.Data3D()
|
|
125
|
+
header.guid = 'my-unique-scan-id'
|
|
126
|
+
header.pointFields.cartesianXField = true
|
|
127
|
+
header.pointFields.cartesianYField = true
|
|
128
|
+
header.pointFields.cartesianZField = true
|
|
129
|
+
|
|
130
|
+
// 2 — build the points
|
|
131
|
+
const points = []
|
|
132
|
+
for (let i = 0; i < 100; i++) {
|
|
133
|
+
const pt = new E57.LibE57.Point()
|
|
134
|
+
pt.cartesianX = i * 0.1
|
|
135
|
+
pt.cartesianY = 0
|
|
136
|
+
pt.cartesianZ = 0
|
|
137
|
+
points.push(pt)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// 3 — write (async)
|
|
141
|
+
const scanIndex = await writer.AddScan(header, points)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Write a scan with colour
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
const header = new E57.LibE57.Data3D()
|
|
148
|
+
header.pointFields.cartesianXField = true
|
|
149
|
+
header.pointFields.cartesianYField = true
|
|
150
|
+
header.pointFields.cartesianZField = true
|
|
151
|
+
header.pointFields.colorRedField = true
|
|
152
|
+
header.pointFields.colorGreenField = true
|
|
153
|
+
header.pointFields.colorBlueField = true
|
|
154
|
+
header.colorLimits.colorRedMaximum = 255
|
|
155
|
+
header.colorLimits.colorGreenMaximum = 255
|
|
156
|
+
header.colorLimits.colorBlueMaximum = 255
|
|
157
|
+
|
|
158
|
+
const pt = new E57.LibE57.Point()
|
|
159
|
+
pt.cartesianX = 1.0; pt.cartesianY = 2.0; pt.cartesianZ = 3.0
|
|
160
|
+
pt.colorRed = 255; pt.colorGreen = 0; pt.colorBlue = 0 // red point
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Set the scanner position (pose)
|
|
164
|
+
|
|
165
|
+
If you know where the scanner was placed, you can store that as a pose. Use an identity quaternion `(w=1, x=0, y=0, z=0)` if there is no rotation:
|
|
166
|
+
|
|
167
|
+
```js
|
|
168
|
+
header.pose.rotation.w = 1.0
|
|
169
|
+
header.pose.rotation.x = 0.0
|
|
170
|
+
header.pose.rotation.y = 0.0
|
|
171
|
+
header.pose.rotation.z = 0.0
|
|
172
|
+
header.pose.translation.x = 10.0 // scanner was 10 m east
|
|
173
|
+
header.pose.translation.y = 20.0 // 20 m north
|
|
174
|
+
header.pose.translation.z = 1.5 // 1.5 m above ground
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Write an image
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
import { E57WriterImage } from 'e57-js'
|
|
181
|
+
|
|
182
|
+
const image = new E57WriterImage(
|
|
183
|
+
'photo.jpg',
|
|
184
|
+
E57.LibE57.Image2DType.ImageJPEG,
|
|
185
|
+
E57.LibE57.Image2DProjection.ProjectionVisual
|
|
186
|
+
)
|
|
187
|
+
image.setName('Front camera')
|
|
188
|
+
|
|
189
|
+
await writer.AddImage(image)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### Close the file
|
|
193
|
+
|
|
194
|
+
Always call `Close()` when you are done. This finalises the file — skipping it will produce a corrupt file.
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
writer.Close()
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
## Point fields reference
|
|
203
|
+
|
|
204
|
+
| Field | Description |
|
|
205
|
+
|---|---|
|
|
206
|
+
| `cartesianX` / `Y` / `Z` | 3D position in metres |
|
|
207
|
+
| `colorRed` / `Green` / `Blue` | RGB colour (0–255 or 0–65535) |
|
|
208
|
+
| `intensity` | Reflected signal strength |
|
|
209
|
+
| `sphericalRange` / `Azimuth` / `Elevation` | Position in spherical coordinates |
|
|
210
|
+
| `normalX` / `Y` / `Z` | Surface normal vector |
|
|
211
|
+
| `timeStamp` | When the point was captured |
|
|
212
|
+
| `rowIndex` / `columnIndex` | Grid position (structured scans) |
|
|
213
|
+
| `returnIndex` / `returnCount` | Multi-return laser data |
|
|
214
|
+
|
|
215
|
+
The fields a scan actually contains depend on how it was written. Check `scan.GetHeader().pointFields` to see which ones are present.
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
For more examples of how to read and write E57 files with this library, have a look at the test files:
|
|
220
|
+
|
|
221
|
+
- [tests/io.test.js](tests/io.test.js) — synchronous read/write examples
|
|
222
|
+
- [tests/io.async.test.js](tests/io.async.test.js) — async read/write examples
|
|
223
|
+
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
async function Qn(te={}){var p;(function(){function e(d){d=d.split("-")[0];for(var c=d.split(".").slice(0,3);c.length<3;)c.push("00");return c=c.map((v,m,h)=>v.padStart(2,"0")),c.join("")}var r=d=>[d/1e4|0,(d/100|0)%100,d%100].join("."),t=2147483647,n=typeof process<"u"&&process.versions?.node?e(process.versions.node):t;if(n<180300)throw new Error(`This emscripten-generated code requires node v${r(180300)} (detected v${r(n)})`);var i=typeof navigator<"u"&&navigator.userAgent;if(i){var o=i.includes("Safari/")&&!i.includes("Chrome/")&&i.match(/Version\/(\d+\.?\d*\.?\d*)/)?e(i.match(/Version\/(\d+\.?\d*\.?\d*)/)[1]):t;if(o<15e4)throw new Error(`This emscripten-generated code requires Safari v${r(15e4)} (detected v${o})`);var s=i.match(/Firefox\/(\d+(?:\.\d+)?)/)?parseFloat(i.match(/Firefox\/(\d+(?:\.\d+)?)/)[1]):t;if(s<114)throw new Error(`This emscripten-generated code requires Firefox v114 (detected v${s})`);var l=i.match(/Chrome\/(\d+(?:\.\d+)?)/)?parseFloat(i.match(/Chrome\/(\d+(?:\.\d+)?)/)[1]):t;if(l<85)throw new Error(`This emscripten-generated code requires Chrome v85 (detected v${l})`)}})();var f=te,M=!!globalThis.window,L=!!globalThis.WorkerGlobalScope,C=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer",fe=!M&&!C&&!L,w=L&&globalThis.name?.startsWith("em-pthread");if(w&&(_(!globalThis.moduleLoaded,"module should only be loaded once on each pthread worker"),globalThis.moduleLoaded=!0),C){let{createRequire:e}=await import("node:module");var oe=e(import.meta.url),Ye=oe("node:worker_threads");globalThis.Worker=Ye.Worker,L=!Ye.isMainThread,w=L&&Ye.workerData=="em-pthread"}var ct=[],kr="./this.program",Tr=(e,r)=>{throw r},Fr=import.meta.url,Je="";function si(e){return f.locateFile?f.locateFile(e,Je):Je+e}var Ze,We;if(C){if(!(globalThis.process?.versions?.node&&globalThis.process?.type!="renderer"))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");var I=oe("node:fs");Fr.startsWith("file:")&&(Je=oe("node:path").dirname(oe("node:url").fileURLToPath(Fr))+"/"),We=r=>{r=Qe(r)?new URL(r):r;var t=I.readFileSync(r);return _(Buffer.isBuffer(t)),t},Ze=async(r,t=!0)=>{r=Qe(r)?new URL(r):r;var n=I.readFileSync(r,t?void 0:"utf8");return _(t?Buffer.isBuffer(n):typeof n=="string"),n},process.argv.length>1&&(kr=process.argv[1].replace(/\\/g,"/")),ct=process.argv.slice(2),Tr=(r,t)=>{throw process.exitCode=r,t}}else if(!fe)if(M||L){try{Je=new URL(".",Fr).href}catch{}if(!(globalThis.window||globalThis.WorkerGlobalScope))throw new Error("not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)");C||(L&&(We=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Ze=async e=>{_(!Qe(e),"readAsync does not work with file:// URLs");var r=await fetch(e,{credentials:"same-origin"});if(r.ok)return r.arrayBuffer();throw new Error(r.status+" : "+r.url)})}else throw new Error("environment detection error");var ft=console.log.bind(console),_t=console.error.bind(console);if(C){var li=oe("node:util"),vt=e=>typeof e=="object"?li.inspect(e):e;ft=(...e)=>I.writeSync(1,e.map(vt).join(" ")+`
|
|
2
|
+
`),_t=(...e)=>I.writeSync(2,e.map(vt).join(" ")+`
|
|
3
|
+
`)}var _e=ft,A=_t,Vo="IDBFS is no longer included by default; build with -lidbfs.js",qo="PROXYFS is no longer included by default; build with -lproxyfs.js",Ko="WORKERFS is no longer included by default; build with -lworkerfs.js",Xo="FETCHFS is no longer included by default; build with -lfetchfs.js",Yo="ICASEFS is no longer included by default; build with -licasefs.js",Jo="JSFILEFS is no longer included by default; build with -ljsfilefs.js",Zo="OPFS is no longer included by default; build with -lopfs.js";_(M||L||C,"pthreads do not work in this environment yet (need Web Workers, or an alternative to them)"),_(!M,"web environment detected but not enabled at build time (add `web` to `-sENVIRONMENT` to enable)"),_(!fe,"shell environment detected but not enabled at build time (add `shell` to `-sENVIRONMENT` to enable)");var Le;globalThis.WebAssembly||A("no native wasm support detected");var pe,Ce=!1,Ae;function _(e,r){e||H("Assertion failed"+(r?": "+r:""))}var Qe=e=>e.startsWith("file://");function mt(){var e=tt();_((e&3)==0),e==0&&(e+=4),(u(),y)[e>>2]=34821223,(u(),y)[e+4>>2]=2310721022,(u(),y)[0]=1668509029}function xe(){if(!Ce){var e=tt();e==0&&(e+=4);var r=(u(),y)[e>>2],t=(u(),y)[e+4>>2];(r!=34821223||t!=2310721022)&&H(`Stack overflow! Stack cookie has been overwritten at ${me(e)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${me(t)} ${me(r)}`),(u(),y)[0]!=1668509029&&H("Runtime error: The application has corrupted its heap memory area (address zero)!")}}class di{}class Qo extends di{}var ht=!0;function Pr(...e){if(!(!ht&&typeof ht<"u"))if(C){let n=function(i){switch(typeof i){case"object":return t.inspect(i);case"undefined":return"undefined"}return i};var r=oe("node:fs"),t=oe("node:util");r.writeSync(2,e.map(n).join(" ")+`
|
|
4
|
+
`)}else console.warn(...e)}(()=>{var e=new Int16Array(1),r=new Int8Array(e.buffer);e[0]=25459,(r[0]!==115||r[1]!==99)&&H("Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)")})();function er(e){Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,set(){H(`Attempt to set \`Module.${e}\` after it has already been processed. This can happen, for example, when code is injected via '--post-js' rather than '--pre-js'`)}})}function N(e){return()=>_(!1,`call to '${e}' via reference taken before Wasm module initialization`)}function ge(e){Object.getOwnPropertyDescriptor(f,e)&&H(`\`Module.${e}\` was supplied but \`${e}\` not included in INCOMING_MODULE_JS_API`)}function ui(e){return e==="FS_createPath"||e==="FS_createDataFile"||e==="FS_createPreloadedFile"||e==="FS_preloadFile"||e==="FS_unlink"||e==="addRunDependency"||e==="FS_createLazyFile"||e==="FS_createDevice"||e==="removeRunDependency"}function ci(e){pt(e)}function pt(e){w||Object.getOwnPropertyDescriptor(f,e)||Object.defineProperty(f,e,{configurable:!0,get(){var r=`'${e}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;ui(e)&&(r+=". Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you"),H(r)}})}function fi(){function e(){var t=0;return Oe&&typeof Fe<"u"&&(t=Fe()),`w:${yt},t:${me(t)}:`}var r=Pr;Pr=(...t)=>r(e(),...t)}fi();function u(){se.buffer!=W.buffer&&rr()}var Cr,Ar;if(C&&w){globalThis.self=globalThis;var gt=Ye.parentPort;globalThis.postMessage||(gt.on("message",e=>globalThis.onmessage?.({data:e})),globalThis.postMessage=e=>gt.postMessage(e)),process.on("uncaughtException",e=>{postMessage({cmd:"uncaughtException",error:e}),process.exit(1)})}var yt=0,wt;if(w){let e=function(r){try{var t=r.data,n=t.cmd;if(n==="load"){yt=t.workerID;let i=[];self.onmessage=o=>i.push(o),wt=()=>{postMessage({cmd:"loaded"});for(let o of i)e(o);self.onmessage=e};for(let o of t.handlers)(!f[o]||f[o].proxy)&&(f[o]=(...s)=>{postMessage({cmd:"callHandler",handler:o,args:s})},o=="print"&&(_e=f[o]),o=="printErr"&&(A=f[o]));se=t.wasmMemory,rr(),pe=t.wasmModule,St(),Sr()}else if(n==="run"){_(t.pthread_ptr),Ti(t.pthread_ptr),et(t.pthread_ptr,0,0,1,0,0),P.threadInitTLS(),Jr(t.pthread_ptr),Or||(Un(),Or=!0);try{Fi(t.start_routine,t.arg)}catch(i){if(i!="unwind")throw i}}else t.target==="setimmediate"||(n==="checkMailbox"?Or&&wr():n&&(A(`worker: received unknown command ${n}`),A(t)))}catch(i){throw A(`worker: onmessage() captured an uncaught exception: ${i}`),i?.stack&&A(i.stack),Bn(),i}};var Or=!1;self.onunhandledrejection=r=>{throw r.reason||r},self.onmessage=e}var Oe=!1;function rr(){var e=se.buffer;W=new Int8Array(e),J=new Int16Array(e),f.HEAPU8=K=new Uint8Array(e),ye=new Uint16Array(e),S=new Int32Array(e),y=new Uint32Array(e),tr=new Float32Array(e),Re=new Float64Array(e),V=new BigInt64Array(e),Tt=new BigUint64Array(e)}function _i(){if(!w){if(f.wasmMemory)se=f.wasmMemory;else{var e=f.INITIAL_MEMORY||16777216;_(e>=65536,`INITIAL_MEMORY should be larger than STACK_SIZE, was ${e}! (STACK_SIZE=65536)`),se=new WebAssembly.Memory({initial:e/65536,maximum:32768,shared:!0})}rr()}}_(globalThis.Int32Array&&globalThis.Float64Array&&Int32Array.prototype.subarray&&Int32Array.prototype.set,"JS engine does not provide full typed array support");function vi(){if(_(!w),f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)Ot(f.preRun.shift());er("preRun"),Ct(At)}function Et(){if(_(!Oe),Oe=!0,w)return wt();xe(),T.root=a.mount(T,{},null),!f.noFSInit&&!a.initialized&&a.init(),ce.init(),Pe.__wasm_call_ctors(),a.ignorePermissions=!1}function mi(){if(xe(),!w){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)ki(f.postRun.shift());er("postRun"),Ct(Mt)}}function H(e){f.onAbort?.(e),e=`Aborted(${e})`,A(e),Ce=!0;var r=new WebAssembly.RuntimeError(e);throw Ar?.(r),r}function q(e,r){return(...t)=>{_(Oe,`native function \`${e}\` called before runtime initialization`);var n=Pe[e];return _(n,`exported native function \`${e}\` not found`),_(t.length<=r,`native function \`${e}\` called with ${t.length} args but expects ${r}`),n(...t)}}var Rr;function hi(){return f.locateFile?si("libe57-js.wasm"):new URL("libe57-js.wasm",import.meta.url).href}function pi(e){if(e==Rr&&Le)return new Uint8Array(Le);if(We)return We(e);throw"both async and sync fetching of the wasm failed"}async function gi(e){if(!Le)try{var r=await Ze(e);return new Uint8Array(r)}catch{}return pi(e)}async function yi(e,r){try{var t=await gi(e),n=await WebAssembly.instantiate(t,r);return n}catch(i){A(`failed to asynchronously prepare wasm: ${i}`),Qe(e)&&A(`warning: Loading from a file URI (${e}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`),H(i)}}async function wi(e,r,t){if(!e&&!C)try{var n=fetch(r,{credentials:"same-origin"}),i=await WebAssembly.instantiateStreaming(n,t);return i}catch(o){A(`wasm streaming compile failed: ${o}`),A("falling back to ArrayBuffer instantiation")}return yi(r,t)}function bt(){jo();var e={env:st,wasi_snapshot_preview1:st};return e}async function St(){function e(l,d){return Pe=l.exports,Pi(Pe._emscripten_tls_init),Uo(Pe),pe=d,Pe}var r=f;function t(l){return _(f===r,"the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?"),r=null,e(l.instance,l.module)}var n=bt();if(f.instantiateWasm)return new Promise((l,d)=>{try{f.instantiateWasm(n,(c,v)=>{l(e(c,v))})}catch(c){A(`Module.instantiateWasm callback failed with error: ${c}`),d(c)}});if(w){_(pe,"wasmModule should have been received via postMessage");var i=new WebAssembly.Instance(pe,bt());return e(i,pe)}Rr??=hi();var o=await wi(Le,Rr,n),s=t(o);return s}class kt{name="ExitStatus";constructor(r){this.message=`Program terminated with exit(${r})`,this.status=r}}var J,S,V,W,tr,Re,ye,y,Tt,K,Ft=e=>{e.terminate(),e.onmessage=r=>{var t=r.data.cmd;A(`received "${t}" command from terminated worker: ${e.workerID}`)}},Pt=e=>{_(!w,"cleanupThread() should only be called from the main thread"),_(e,"null pthread_ptr passed to cleanupThread");var r=P.pthreads[e];_(r),P.returnWorkerToPool(r)},Ct=e=>{for(;e.length>0;)e.shift()(f)},At=[],Ot=e=>At.push(e),we=0,Ue=null,De={},ve=null,Dr=e=>{if(we--,f.monitorRunDependencies?.(we),_(e,"removeRunDependency requires an ID"),_(De[e]),delete De[e],we==0&&(ve!==null&&(clearInterval(ve),ve=null),Ue)){var r=Ue;Ue=null,r()}},$r=e=>{we++,f.monitorRunDependencies?.(we),_(e,"addRunDependency requires an ID"),_(!De[e]),De[e]=1,ve===null&&globalThis.setInterval&&(ve=setInterval(()=>{if(Ce){clearInterval(ve),ve=null;return}var r=!1;for(var t in De)r||(r=!0,A("still waiting on run dependencies:")),A(`dependency: ${t}`);r&&A("(end of list)")},1e4),ve.unref?.())},Rt=e=>{_(!w,"spawnThread() should only be called from the main thread"),_(e.pthread_ptr,"spawnThread called with null pthread ptr");var r=P.getNewWorker();if(!r)return 6;_(!r.pthread_ptr),P.runningWorkers.push(r),P.pthreads[e.pthread_ptr]=r,r.pthread_ptr=e.pthread_ptr;var t={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return C&&r.unref(),r.postMessage(t,e.transferList),0},nr=0,ir=()=>Nr||nr>0,Ei=()=>at(),Dt=e=>Yn(e),bi=e=>Jn(e),B=(e,r,t,...n)=>{var i=8*n.length*2,o=Ei(),s=bi(i),l=s>>3;for(var d of n)typeof d=="bigint"?((u(),V)[l++]=1n,(u(),V)[l++]=d):((u(),V)[l++]=0n,(u(),Re)[l++]=d);var c=Gn(e,r,i,s,t);return Dt(o),c};function $t(e){if(w)return B(0,0,1,e);Ae=e,ir()||(P.terminateAllThreads(),f.onExit?.(e),Ce=!0),Tr(e,new kt(e))}function It(e){if(w)return B(1,0,0,e);Ir(e)}var Si=(e,r)=>{if(Ae=e,Bo(),w)throw _(!r),It(e),"unwind";if(ir()&&!r){var t=`program exited (with status: ${e}), but keepRuntimeAlive() is set (counter=${nr}) due to an async operation, so halting execution but not exiting the runtime or preventing further async execution (you can use emscripten_force_exit, if you want to force a true shutdown)`;Ar?.(t),A(t)}$t(e)},Ir=Si,Nt=!Atomics.waitAsync||globalThis.navigator?.userAgent&&Number((navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./)||[])[2])<91;function me(e){return _(typeof e=="number",`ptrToString expects a number, got ${typeof e}`),e>>>=0,"0x"+e.toString(16).padStart(8,"0")}var P={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},nextWorkerID:1,init(){w||P.initMainThread()},initMainThread(){for(var e=8;e--;)P.allocateUnusedWorker();Ot(async()=>{var r=P.loadWasmModuleToAllWorkers();$r("loading-workers"),await r,Dr("loading-workers")})},terminateAllThreads:()=>{_(!w,"terminateAllThreads() should only be called from the main thread");for(var e of P.runningWorkers)Ft(e);for(var e of P.unusedWorkers)Ft(e);P.unusedWorkers=[],P.runningWorkers=[],P.pthreads={}},terminateRuntime:()=>{_(!w,"terminateRuntime() should only be called from the main thread"),P.terminateAllThreads();var e=Fe();Hn(0,0,0,1),Nt||Atomics.notify((u(),S),e>>2)},returnWorkerToPool:e=>{var r=e.pthread_ptr;delete P.pthreads[r],P.unusedWorkers.push(e),P.runningWorkers.splice(P.runningWorkers.indexOf(e),1),e.pthread_ptr=0,Vn(r)},threadInitTLS(){P.tlsInitFunctions.forEach(e=>e())},loadWasmModuleToWorker:e=>new Promise(r=>{e.onmessage=o=>{var s=o.data,l=s.cmd;if(s.targetThread&&s.targetThread!=Fe()){var d=P.pthreads[s.targetThread];d?d.postMessage(s,s.transferList):A(`worker sent message (${l}) to pthread (${s.targetThread}) that no longer exists`);return}l==="checkMailbox"?wr():l==="spawnThread"?Rt(s):l==="cleanupThread"?Pn(()=>Pt(s.thread)):l==="loaded"?(e.loaded=!0,C&&!e.pthread_ptr&&e.unref(),r(e)):s.target==="setimmediate"?e.postMessage(s):l==="uncaughtException"?e.onerror(s.error):l==="callHandler"?f[s.handler](...s.args):l&&A(`worker sent an unknown command ${l}`)},e.onerror=o=>{var s="worker sent an error!";throw e.pthread_ptr&&(s=`Pthread ${me(e.pthread_ptr)} sent an error!`),A(`${s} ${o.filename}:${o.lineno}: ${o.message}`),o},C&&(e.on("message",o=>e.onmessage({data:o})),e.on("error",o=>e.onerror(o))),_(se instanceof WebAssembly.Memory,"wasmMemory should have been loaded by now"),_(pe instanceof WebAssembly.Module,"wasmModule should have been loaded by now");var t=[],n=["onExit","onAbort","print","printErr"];for(var i of n)f.propertyIsEnumerable(i)&&t.push(i);e.postMessage({cmd:"load",handlers:t,wasmMemory:se,wasmModule:pe,workerID:e.workerID})}),async loadWasmModuleToAllWorkers(){return w?void 0:Promise.all(P.unusedWorkers.map(P.loadWasmModuleToWorker))},allocateUnusedWorker(){var e;if(f.mainScriptUrlOrBlob){var r=f.mainScriptUrlOrBlob;typeof r!="string"&&(r=URL.createObjectURL(r)),e=new Worker(r,{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID})}else e=new Worker(new URL("libe57-js.js",import.meta.url),{type:"module",workerData:"em-pthread",name:"em-pthread-"+P.nextWorkerID});e.workerID=P.nextWorkerID++,P.unusedWorkers.push(e)},getNewWorker(){return P.unusedWorkers.length==0&&(C||A("Tried to spawn a new thread, but the thread pool is exhausted.\nThis might result in a deadlock unless some threads eventually exit or the code explicitly breaks out to the event loop.\nIf you want to increase the pool size, use setting `-sPTHREAD_POOL_SIZE=...`.\nIf you want to throw an explicit error instead of the risk of deadlocking in those cases, use setting `-sPTHREAD_POOL_SIZE_STRICT=2`."),P.allocateUnusedWorker(),P.loadWasmModuleToWorker(P.unusedWorkers[0])),P.unusedWorkers.pop()}},Mt=[],ki=e=>Mt.push(e);function Ti(e){var r=(u(),y)[e+48>>2],t=(u(),y)[e+52>>2],n=r-t;_(r!=0),_(n!=0),_(r>n,"stackHigh must be higher then stackLow"),Xn(r,n),Dt(r),mt()}function es(e,r="i8"){switch(r.endsWith("*")&&(r="*"),r){case"i1":return(u(),W)[e];case"i8":return(u(),W)[e];case"i16":return(u(),J)[e>>1];case"i32":return(u(),S)[e>>2];case"i64":return(u(),V)[e>>3];case"float":return(u(),tr)[e>>2];case"double":return(u(),Re)[e>>3];case"*":return(u(),y)[e>>2];default:H(`invalid type for getValue: ${r}`)}}var Wt=[],Lt=e=>{var r=Wt[e];return r||(Wt[e]=r=ot.get(e)),_(ot.get(e)==r,"table mirror is out of date"),r},Fi=(e,r)=>{nr=0,Nr=0;var t=Lt(e)(r);xe();function n(i){if(ir()){Ae=i;return}it(i)}n(t)},Nr=!0,Pi=e=>P.tlsInitFunctions.push(e);function rs(e,r,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":(u(),W)[e]=r;break;case"i8":(u(),W)[e]=r;break;case"i16":(u(),J)[e>>1]=r;break;case"i32":(u(),S)[e>>2]=r;break;case"i64":(u(),V)[e>>3]=BigInt(r);break;case"float":(u(),tr)[e>>2]=r;break;case"double":(u(),Re)[e>>3]=r;break;case"*":(u(),y)[e>>2]=r;break;default:H(`invalid type for setValue: ${t}`)}}var Ee=e=>{Ee.shown||={},Ee.shown[e]||(Ee.shown[e]=1,C&&(e="warning: "+e),A(e))},se,xt=globalThis.TextDecoder&&new TextDecoder,Ut=(e,r,t,n)=>{var i=r+t;if(n)return i;for(;e[r]&&!(r>=i);)++r;return r},$e=(e,r=0,t,n)=>{var i=Ut(e,r,t,n);if(i-r>16&&e.buffer&&xt)return xt.decode(e.buffer instanceof ArrayBuffer?e.subarray(r,i):e.slice(r,i));for(var o="";r<i;){var s=e[r++];if(!(s&128)){o+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){o+=String.fromCharCode((s&31)<<6|l);continue}var d=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|d:((s&248)!=240&&Ee(`Invalid UTF-8 leading byte ${me(s)} encountered when deserializing a UTF-8 string in wasm memory to a JS string!`),s=(s&7)<<18|l<<12|d<<6|e[r++]&63),s<65536)o+=String.fromCharCode(s);else{var c=s-65536;o+=String.fromCharCode(55296|c>>10,56320|c&1023)}}return o},le=(e,r,t)=>(_(typeof e=="number",`UTF8ToString expects a number (got ${typeof e})`),e?$e((u(),K),e,r,t):""),Ci=(e,r,t,n)=>H(`Assertion failed: ${le(e)}, at: `+[r?le(r):"unknown filename",t,n?le(n):"unknown function"]);class Ai{constructor(r){this.excPtr=r,this.ptr=r-24}set_type(r){(u(),y)[this.ptr+4>>2]=r}get_type(){return(u(),y)[this.ptr+4>>2]}set_destructor(r){(u(),y)[this.ptr+8>>2]=r}get_destructor(){return(u(),y)[this.ptr+8>>2]}set_caught(r){r=r?1:0,(u(),W)[this.ptr+12]=r}get_caught(){return(u(),W)[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,(u(),W)[this.ptr+13]=r}get_rethrown(){return(u(),W)[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t)}set_adjusted_ptr(r){(u(),y)[this.ptr+16>>2]=r}get_adjusted_ptr(){return(u(),y)[this.ptr+16>>2]}}var Oi=0,Ri=(e,r,t)=>{var n=new Ai(e);n.init(r,t),Oi++,_(!1,"Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.")};function jt(e,r,t,n){return w?B(2,0,1,e,r,t,n):Ht(e,r,t,n)}var Di=()=>!!globalThis.SharedArrayBuffer,Ht=(e,r,t,n)=>{if(!Di())return Pr("pthread_create: environment does not support SharedArrayBuffer, pthreads are not available"),6;var i=[],o=0;if(w&&(i.length===0||o))return jt(e,r,t,n);if(o)return o;var s={startRoutine:t,pthread_ptr:e,arg:n,transferList:i};return w?(s.cmd="spawnThread",postMessage(s,i),0):Rt(s)},$i=()=>{if(C){var e=oe("node:crypto");return r=>e.randomFillSync(r)}return r=>(r.set(crypto.getRandomValues(new Uint8Array(r.byteLength))),0)},Mr=e=>(Mr=$i())(e),$={isAbs:e=>e.charAt(0)==="/",splitPath:e=>{var r=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return r.exec(e).slice(1)},normalizeArray:(e,r)=>{for(var t=0,n=e.length-1;n>=0;n--){var i=e[n];i==="."?e.splice(n,1):i===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--)}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=$.isAbs(e),t=e.slice(-1)==="/";return e=$.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=$.splitPath(e),t=r[0],n=r[1];return!t&&!n?".":(n&&(n=n.slice(0,-1)),t+n)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>$.normalize(e.join("/")),join2:(e,r)=>$.normalize(e+"/"+r)},Ie={resolve:(...e)=>{for(var r="",t=!1,n=e.length-1;n>=-1&&!t;n--){var i=n>=0?e[n]:a.cwd();if(typeof i!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";r=i+"/"+r,t=$.isAbs(i)}return r=$.normalizeArray(r.split("/").filter(o=>!!o),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=Ie.resolve(e).slice(1),r=Ie.resolve(r).slice(1);function t(c){for(var v=0;v<c.length&&c[v]==="";v++);for(var m=c.length-1;m>=0&&c[m]==="";m--);return v>m?[]:c.slice(v,m-v+1)}for(var n=t(e.split("/")),i=t(r.split("/")),o=Math.min(n.length,i.length),s=o,l=0;l<o;l++)if(n[l]!==i[l]){s=l;break}for(var d=[],l=s;l<n.length;l++)d.push("..");return d=d.concat(i.slice(s)),d.join("/")}},Wr=[],be=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n<=127?r++:n<=2047?r+=2:n>=55296&&n<=57343?(r+=4,++t):r+=3}return r},Bt=(e,r,t,n)=>{if(_(typeof e=="string",`stringToUTF8Array expects a string (got ${typeof e})`),!(n>0))return 0;for(var i=t,o=t+n-1,s=0;s<e.length;++s){var l=e.codePointAt(s);if(l<=127){if(t>=o)break;r[t++]=l}else if(l<=2047){if(t+1>=o)break;r[t++]=192|l>>6,r[t++]=128|l&63}else if(l<=65535){if(t+2>=o)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63}else{if(t+3>=o)break;l>1114111&&Ee(`Invalid Unicode code point ${me(l)} encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).`),r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63,s++}}return r[t]=0,t-i},Lr=(e,r,t)=>{var n=t>0?t:be(e)+1,i=new Array(n),o=Bt(e,i,0,i.length);return r&&(i.length=o),i},Ii=()=>{if(!Wr.length){var e=null;if(C){var r=256,t=Buffer.alloc(r),n=0,i=process.stdin.fd;try{n=I.readSync(i,t,0,r)}catch(o){if(o.toString().includes("EOF"))n=0;else throw o}n>0&&(e=t.slice(0,n).toString("utf-8"))}if(!e)return null;Wr=Lr(e,!0)}return Wr.shift()},ce={ttys:[],init(){},shutdown(){},register(e,r){ce.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,ce.stream_ops)},stream_ops:{open(e){var r=ce.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,r,t,n,i){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var o=0,s=0;s<n;s++){var l;try{l=e.tty.ops.get_char(e.tty)}catch{throw new a.ErrnoError(29)}if(l===void 0&&o===0)throw new a.ErrnoError(6);if(l==null)break;o++,r[t+s]=l}return o&&(e.node.atime=Date.now()),o},write(e,r,t,n,i){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var o=0;o<n;o++)e.tty.ops.put_char(e.tty,r[t+o])}catch{throw new a.ErrnoError(29)}return n&&(e.node.mtime=e.node.ctime=Date.now()),o}},default_tty_ops:{get_char(e){return Ii()},put_char(e,r){r===null||r===10?(_e($e(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(_e($e(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,r,t){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,r){r===null||r===10?(A($e(e.output)),e.output=[]):r!=0&&e.output.push(r)},fsync(e){e.output?.length>0&&(A($e(e.output)),e.output=[])}}},xr=e=>{H("internal error: mmapAlloc called but `emscripten_builtin_memalign` native symbol not exported")},F={ops_table:null,mount(e){return F.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);F.ops_table||={dir:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,lookup:F.node_ops.lookup,mknod:F.node_ops.mknod,rename:F.node_ops.rename,unlink:F.node_ops.unlink,rmdir:F.node_ops.rmdir,readdir:F.node_ops.readdir,symlink:F.node_ops.symlink},stream:{llseek:F.stream_ops.llseek}},file:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:{llseek:F.stream_ops.llseek,read:F.stream_ops.read,write:F.stream_ops.write,mmap:F.stream_ops.mmap,msync:F.stream_ops.msync}},link:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr,readlink:F.node_ops.readlink},stream:{}},chrdev:{node:{getattr:F.node_ops.getattr,setattr:F.node_ops.setattr},stream:a.chrdev_stream_ops}};var i=a.createNode(e,r,t,n);return a.isDir(i.mode)?(i.node_ops=F.ops_table.dir.node,i.stream_ops=F.ops_table.dir.stream,i.contents={}):a.isFile(i.mode)?(i.node_ops=F.ops_table.file.node,i.stream_ops=F.ops_table.file.stream,i.usedBytes=0,i.contents=F.emptyFileContents??=new Uint8Array(0)):a.isLink(i.mode)?(i.node_ops=F.ops_table.link.node,i.stream_ops=F.ops_table.link.stream):a.isChrdev(i.mode)&&(i.node_ops=F.ops_table.chrdev.node,i.stream_ops=F.ops_table.chrdev.stream),i.atime=i.mtime=i.ctime=Date.now(),e&&(e.contents[r]=i,e.atime=e.mtime=e.ctime=i.atime),i},getFileDataAsTypedArray(e){return _(a.isFile(e.mode),"getFileDataAsTypedArray called on non-file"),e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,r){var t=e.contents.length;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t&&(r=Math.max(r,256));var i=F.getFileDataAsTypedArray(e);e.contents=new Uint8Array(r),e.contents.set(i)}},resizeFileStorage(e,r){if(e.usedBytes!=r){var t=e.contents;e.contents=new Uint8Array(r),e.contents.set(t.subarray(0,Math.min(r,e.usedBytes))),e.usedBytes=r}},node_ops:{getattr(e){var r={};return r.dev=a.isChrdev(e.mode)?e.id:1,r.ino=e.id,r.mode=e.mode,r.nlink=1,r.uid=0,r.gid=0,r.rdev=e.rdev,a.isDir(e.mode)?r.size=4096:a.isFile(e.mode)?r.size=e.usedBytes:a.isLink(e.mode)?r.size=e.link.length:r.size=0,r.atime=new Date(e.atime),r.mtime=new Date(e.mtime),r.ctime=new Date(e.ctime),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){for(let t of["mode","atime","mtime","ctime"])r[t]!=null&&(e[t]=r[t]);r.size!==void 0&&F.resizeFileStorage(e,r.size)},lookup(e,r){throw new a.ErrnoError(44)},mknod(e,r,t,n){return F.createNode(e,r,t,n)},rename(e,r,t){var n;try{n=a.lookupNode(r,t)}catch{}if(n){if(a.isDir(e.mode))for(var i in n.contents)throw new a.ErrnoError(55);a.hashRemoveNode(n)}delete e.parent.contents[e.name],r.contents[t]=e,e.name=t,r.ctime=r.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,r){delete e.contents[r],e.ctime=e.mtime=Date.now()},rmdir(e,r){var t=a.lookupNode(e,r);for(var n in t.contents)throw new a.ErrnoError(55);delete e.contents[r],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,r,t){var n=F.createNode(e,r,41471,0);return n.link=t,n},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,r,t,n,i){var o=e.node.contents;if(i>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-i,n);return _(s>=0),r.set(o.subarray(i,i+s),t),s},write(e,r,t,n,i,o){if(_(r.subarray,"FS.write expects a TypedArray"),r.buffer===(u(),W).buffer&&(o=!1),!n)return 0;var s=e.node;return s.mtime=s.ctime=Date.now(),o?(_(i===0,"canOwn must imply no weird position inside the file"),s.contents=r.subarray(t,t+n),s.usedBytes=n):s.usedBytes===0&&i===0?(s.contents=r.slice(t,t+n),s.usedBytes=n):(F.expandFileStorage(s,i+n),s.contents.set(r.subarray(t,t+n),i),s.usedBytes=Math.max(s.usedBytes,i+n)),n},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&a.isFile(e.node.mode)&&(n+=e.node.usedBytes),n<0)throw new a.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var o,s,l=e.node.contents;if(!(i&2)&&l.buffer===(u(),W).buffer)s=!1,o=l.byteOffset;else{if(s=!0,o=xr(r),!o)throw new a.ErrnoError(48);l&&((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),(u(),W).set(l,o))}return{ptr:o,allocated:s}},msync(e,r,t,n,i){return F.stream_ops.write(e,r,0,n,t,!1),0}}},Ni=e=>{if(typeof e!="string")return e;var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},t=r[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},zt=e=>(typeof e=="string"&&(e=Lr(e,!0)),e.subarray||(e=new Uint8Array(e)),e),Ur=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},ar={EPERM:63,ENOENT:44,ESRCH:71,EINTR:27,EIO:29,ENXIO:60,E2BIG:1,ENOEXEC:45,EBADF:8,ECHILD:12,EAGAIN:6,EWOULDBLOCK:6,ENOMEM:48,EACCES:2,EFAULT:21,ENOTBLK:105,EBUSY:10,EEXIST:20,EXDEV:75,ENODEV:43,ENOTDIR:54,EISDIR:31,EINVAL:28,ENFILE:41,EMFILE:33,ENOTTY:59,ETXTBSY:74,EFBIG:22,ENOSPC:51,ESPIPE:70,EROFS:69,EMLINK:34,EPIPE:64,EDOM:18,ERANGE:68,ENOMSG:49,EIDRM:24,ECHRNG:106,EL2NSYNC:156,EL3HLT:107,EL3RST:108,ELNRNG:109,EUNATCH:110,ENOCSI:111,EL2HLT:112,EDEADLK:16,ENOLCK:46,EBADE:113,EBADR:114,EXFULL:115,ENOANO:104,EBADRQC:103,EBADSLT:102,EDEADLOCK:16,EBFONT:101,ENOSTR:100,ENODATA:116,ETIME:117,ENOSR:118,ENONET:119,ENOPKG:120,EREMOTE:121,ENOLINK:47,EADV:122,ESRMNT:123,ECOMM:124,EPROTO:65,EMULTIHOP:36,EDOTDOT:125,EBADMSG:9,ENOTUNIQ:126,EBADFD:127,EREMCHG:128,ELIBACC:129,ELIBBAD:130,ELIBSCN:131,ELIBMAX:132,ELIBEXEC:133,ENOSYS:52,ENOTEMPTY:55,ENAMETOOLONG:37,ELOOP:32,EOPNOTSUPP:138,EPFNOSUPPORT:139,ECONNRESET:15,ENOBUFS:42,EAFNOSUPPORT:5,EPROTOTYPE:67,ENOTSOCK:57,ENOPROTOOPT:50,ESHUTDOWN:140,ECONNREFUSED:14,EADDRINUSE:3,ECONNABORTED:13,ENETUNREACH:40,ENETDOWN:38,ETIMEDOUT:73,EHOSTDOWN:142,EHOSTUNREACH:23,EINPROGRESS:26,EALREADY:7,EDESTADDRREQ:17,EMSGSIZE:35,EPROTONOSUPPORT:66,ESOCKTNOSUPPORT:137,EADDRNOTAVAIL:4,ENETRESET:39,EISCONN:30,ENOTCONN:53,ETOOMANYREFS:141,EUSERS:136,EDQUOT:19,ESTALE:72,ENOTSUP:138,ENOMEDIUM:148,EILSEQ:25,EOVERFLOW:61,ECANCELED:11,ENOTRECOVERABLE:56,EOWNERDEAD:62,ESTRPIPE:135},b={isWindows:!1,staticInit(){b.isWindows=!!process.platform.match(/^win/);var e=process.binding("constants").fs;b.flagsForNodeMap={1024:e.O_APPEND,64:e.O_CREAT,128:e.O_EXCL,256:e.O_NOCTTY,0:e.O_RDONLY,2:e.O_RDWR,4096:e.O_SYNC,512:e.O_TRUNC,1:e.O_WRONLY,131072:e.O_NOFOLLOW},_(b.flagsForNodeMap[0]===0)},convertNodeCode(e){var r=e.code;return _(r in ar,`unexpected node error code: ${r} (${e})`),ar[r]},tryFSOperation(e){try{return e()}catch(r){throw r.code?r.code==="UNKNOWN"?new a.ErrnoError(28):new a.ErrnoError(b.convertNodeCode(r)):r}},mount(e){return _(C),b.createNode(null,"/",b.getMode(e.opts.root),0)},createNode(e,r,t,n){if(!a.isDir(t)&&!a.isFile(t)&&!a.isLink(t))throw new a.ErrnoError(28);var i=a.createNode(e,r,t);return i.node_ops=b.node_ops,i.stream_ops=b.stream_ops,i},getMode(e){return b.tryFSOperation(()=>{var r=I.lstatSync(e).mode;return b.isWindows&&(r|=(r&292)>>2),r})},realPath(e){for(var r=[];e.parent!==e;)r.push(e.name),e=e.parent;return r.push(e.mount.opts.root),r.reverse(),$.join(...r)},flagsForNode(e){e&=-2097153,e&=-2049,e&=-32769,e&=-524289,e&=-65537;var r=0;for(var t in b.flagsForNodeMap)e&t&&(r|=b.flagsForNodeMap[t],e^=t);if(e)throw new a.ErrnoError(28);return r},getattr(e,r){var t=b.tryFSOperation(e);return b.isWindows&&(t.blksize||(t.blksize=4096),t.blocks||(t.blocks=(t.size+t.blksize-1)/t.blksize|0),t.mode|=(t.mode&292)>>2),{dev:t.dev,ino:r.id,mode:t.mode,nlink:t.nlink,uid:t.uid,gid:t.gid,rdev:t.rdev,size:t.size,atime:t.atime,mtime:t.mtime,ctime:t.ctime,blksize:t.blksize,blocks:t.blocks}},setattr(e,r,t,n,i,o,s){b.tryFSOperation(()=>{if(t.mode!==void 0){var l=t.mode;b.isWindows&&(l&=384),n(e,l),r.mode=t.mode}if(typeof(t.atime??t.mtime)=="number"){var d=new Date(t.atime??s(e).atime),c=new Date(t.mtime??s(e).mtime);i(e,d,c)}t.size!==void 0&&o(e,t.size)})},node_ops:{getattr(e){var r=b.realPath(e);return b.getattr(()=>I.lstatSync(r),e)},setattr(e,r){var t=b.realPath(e);if(r.mode!=null&&r.dontFollow)throw new a.ErrnoError(52);b.setattr(t,e,r,I.chmodSync,I.utimesSync,I.truncateSync,I.lstatSync)},lookup(e,r){var t=$.join2(b.realPath(e),r),n=b.getMode(t);return b.createNode(e,r,n)},mknod(e,r,t,n){var i=b.createNode(e,r,t,n),o=b.realPath(i);return b.tryFSOperation(()=>{a.isDir(i.mode)?I.mkdirSync(o,i.mode):I.writeFileSync(o,"",{mode:i.mode})}),i},rename(e,r,t){var n=b.realPath(e),i=$.join2(b.realPath(r),t);try{a.unlink(i)}catch{}b.tryFSOperation(()=>I.renameSync(n,i)),e.name=t},unlink(e,r){var t=$.join2(b.realPath(e),r);b.tryFSOperation(()=>I.unlinkSync(t))},rmdir(e,r){var t=$.join2(b.realPath(e),r);b.tryFSOperation(()=>I.rmdirSync(t))},readdir(e){var r=b.realPath(e);return b.tryFSOperation(()=>I.readdirSync(r))},symlink(e,r,t){var n=$.join2(b.realPath(e),r);b.tryFSOperation(()=>I.symlinkSync(t,n))},readlink(e){var r=b.realPath(e);return b.tryFSOperation(()=>I.readlinkSync(r))},statfs(e){var r=b.tryFSOperation(()=>I.statfsSync(e));return r.frsize=r.bsize,r}},stream_ops:{getattr(e){return b.getattr(()=>I.fstatSync(e.nfd),e.node)},setattr(e,r){b.setattr(e.nfd,e.node,r,I.fchmodSync,I.futimesSync,I.ftruncateSync,I.fstatSync)},open(e){var r=b.realPath(e.node);b.tryFSOperation(()=>{e.shared.refcount=1,e.nfd=I.openSync(r,b.flagsForNode(e.flags))})},close(e){b.tryFSOperation(()=>{e.nfd&&--e.shared.refcount===0&&I.closeSync(e.nfd)})},dup(e){e.shared.refcount++},read(e,r,t,n,i){return b.tryFSOperation(()=>I.readSync(e.nfd,r,t,n,i))},write(e,r,t,n,i){return b.tryFSOperation(()=>I.writeSync(e.nfd,r,t,n,i))},llseek(e,r,t){var n=r;if(t===1?n+=e.position:t===2&&a.isFile(e.node.mode)&&b.tryFSOperation(()=>{var i=I.fstatSync(e.nfd);n+=i.size}),n<0)throw new a.ErrnoError(28);return n},mmap(e,r,t,n,i){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var o=xr(r);return b.stream_ops.read(e,(u(),W),o,r,t),{ptr:o,allocated:!0}},msync(e,r,t,n,i){return b.stream_ops.write(e,r,0,n,t,!1),0}}},Mi=e=>le(jn(e)),Wi=async e=>{var r=await Ze(e);return _(r,`Loading data file "${e}" failed (no arrayBuffer).`),new Uint8Array(r)},Gt=(...e)=>a.createDataFile(...e),Li=e=>{for(var r=e;;){if(!De[e])return e;e=r+Math.random()}},Vt=[],xi=async(e,r)=>{typeof Browser<"u"&&Browser.init();for(var t of Vt)if(t.canHandle(r))return _(t.handle.constructor.name==="AsyncFunction","Filesystem plugin handlers must be async functions (See #24914)"),t.handle(e,r);return e},jr=async(e,r,t,n,i,o,s,l)=>{var d=r?Ie.resolve($.join2(e,r)):e,c=Li(`cp ${d}`);$r(c);try{var v=t;typeof t=="string"&&(v=await Wi(t)),v=await xi(v,d),l?.(),o||Gt(e,r,v,n,i,s)}finally{Dr(c)}},Ui=(e,r,t,n,i,o,s,l,d,c)=>{jr(e,r,t,n,i,l,d,c).then(o).catch(s)},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class extends Error{name="ErrnoError";constructor(e){super(Oe?Mi(e):""),this.errno=e;for(var r in ar)if(ar[r]===e){this.code=r;break}}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.id=a.nextInode++,this.name=r,this.mode=t,this.rdev=n,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return a.isDir(this.mode)}get isDevice(){return a.isChrdev(this.mode)}},lookupPath(e,r={}){if(!e)throw new a.ErrnoError(44);r.follow_mount??=!0,$.isAbs(e)||(e=a.cwd()+"/"+e);e:for(var t=0;t<40;t++){for(var n=e.split("/").filter(c=>!!c),i=a.root,o="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(n[s]!=="."){if(n[s]===".."){if(o=$.dirname(o),a.isRoot(i)){e=o+"/"+n.slice(s+1).join("/"),t--;continue e}else i=i.parent;continue}o=$.join2(o,n[s]);try{i=a.lookupNode(i,n[s])}catch(c){if(c?.errno===44&&l&&r.noent_okay)return{path:o};throw c}if(a.isMountpoint(i)&&(!l||r.follow_mount)&&(i=i.mounted.root),a.isLink(i.mode)&&(!l||r.follow)){if(!i.node_ops.readlink)throw new a.ErrnoError(52);var d=i.node_ops.readlink(i);$.isAbs(d)||(d=$.dirname(o)+"/"+d),e=d+"/"+n.slice(s+1).join("/");continue e}}}return{path:o,node:i}}throw new a.ErrnoError(32)},getPath(e){for(var r;;){if(a.isRoot(e)){var t=e.mount.mountpoint;return r?t[t.length-1]!=="/"?`${t}/${r}`:t+r:t}r=r?`${e.name}/${r}`:e.name,e=e.parent}},hashName(e,r){for(var t=0,n=0;n<r.length;n++)t=(t<<5)-t+r.charCodeAt(n)|0;return(e+t>>>0)%a.nameTable.length},hashAddNode(e){var r=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[r],a.nameTable[r]=e},hashRemoveNode(e){var r=a.hashName(e.parent.id,e.name);if(a.nameTable[r]===e)a.nameTable[r]=e.name_next;else for(var t=a.nameTable[r];t;){if(t.name_next===e){t.name_next=e.name_next;break}t=t.name_next}},lookupNode(e,r){var t=a.mayLookup(e);if(t)throw new a.ErrnoError(t);for(var n=a.hashName(e.id,r),i=a.nameTable[n];i;i=i.name_next){var o=i.name;if(i.parent.id===e.id&&o===r)return i}return a.lookup(e,r)},createNode(e,r,t,n){_(typeof e=="object");var i=new a.FSNode(e,r,t,n);return a.hashAddNode(i),i},destroyNode(e){a.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var r=["r","w","rw"][e&3];return e&512&&(r+="w"),r},nodePermissions(e,r){return a.ignorePermissions?0:r.includes("r")&&!(e.mode&292)||r.includes("w")&&!(e.mode&146)||r.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!a.isDir(e.mode))return 54;var r=a.nodePermissions(e,"x");return r||(e.node_ops.lookup?0:2)},mayCreate(e,r){if(!a.isDir(e.mode))return 54;try{var t=a.lookupNode(e,r);return 20}catch{}return a.nodePermissions(e,"wx")},mayDelete(e,r,t){var n;try{n=a.lookupNode(e,r)}catch(o){return o.errno}var i=a.nodePermissions(e,"wx");if(i)return i;if(t){if(!a.isDir(n.mode))return 54;if(a.isRoot(n)||a.getPath(n)===a.cwd())return 10}else if(a.isDir(n.mode))return 31;return 0},mayOpen(e,r){if(!e)return 44;if(a.isLink(e.mode))return 32;var t=a.flagsToPermissionString(r);return a.isDir(e.mode)&&(t!=="r"||r&576)?31:a.nodePermissions(e,t)},checkOpExists(e,r){if(!e)throw new a.ErrnoError(r);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked(e){var r=a.getStream(e);if(!r)throw new a.ErrnoError(8);return r},getStream:e=>a.streams[e],createStream(e,r=-1){return _(r>=-1),e=Object.assign(new a.FSStream,e),r==-1&&(r=a.nextfd()),e.fd=r,a.streams[r]=e,e},closeStream(e){a.streams[e]=null},dupStream(e,r=-1){var t=a.createStream(e,r);return t.stream_ops?.dup?.(t),t},doSetAttr(e,r,t){var n=e?.stream_ops.setattr,i=n?e:r;n??=r.node_ops.setattr,a.checkOpExists(n,63);try{n(i,t)}catch(o){throw o instanceof RangeError?new a.ErrnoError(22):o}},chrdev_stream_ops:{open(e){var r=a.getDevice(e.node.rdev);e.stream_ops=r.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,r)=>e<<8|r,registerDevice(e,r){a.devices[e]={stream_ops:r}},getDevice:e=>a.devices[e],getMounts(e){for(var r=[],t=[e];t.length;){var n=t.pop();r.push(n),t.push(...n.mounts)}return r},syncfs(e,r){typeof e=="function"&&(r=e,e=!1),a.syncFSRequests++,a.syncFSRequests>1&&A(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var t=a.getMounts(a.root.mount),n=0;function i(l){return _(a.syncFSRequests>0),a.syncFSRequests--,r(l)}function o(l){if(l)return o.errored?void 0:(o.errored=!0,i(l));++n>=t.length&&i(null)}for(var s of t)s.type.syncfs?s.type.syncfs(s,e,o):o(null)},mount(e,r,t){if(typeof e=="string")throw e;var n=t==="/",i=!t,o;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!i){var s=a.lookupPath(t,{follow_mount:!1});if(t=s.path,o=s.node,a.isMountpoint(o))throw new a.ErrnoError(10);if(!a.isDir(o.mode))throw new a.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},d=e.mount(l);return d.mount=l,l.root=d,n?a.root=d:o&&(o.mounted=l,o.mount&&o.mount.mounts.push(l)),d},unmount(e){var r=a.lookupPath(e,{follow_mount:!1});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,i=a.getMounts(n);for(var[o,s]of Object.entries(a.nameTable))for(;s;){var l=s.name_next;i.includes(s.mount)&&a.destroyNode(s),s=l}t.mounted=null;var d=t.mount.mounts.indexOf(n);_(d!==-1),t.mount.mounts.splice(d,1)},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=a.lookupPath(e,{parent:!0}),i=n.node,o=$.basename(e);if(!o)throw new a.ErrnoError(28);if(o==="."||o==="..")throw new a.ErrnoError(20);var s=a.mayCreate(i,o);if(s)throw new a.ErrnoError(s);if(!i.node_ops.mknod)throw new a.ErrnoError(63);return i.node_ops.mknod(i,o,r,t)},statfs(e){return a.statfsNode(a.lookupPath(e,{follow:!0}).node)},statfsStream(e){return a.statfsNode(e.node)},statfsNode(e){var r={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:a.nextInode,ffree:a.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(r,e.node_ops.statfs(e.mount.opts.root)),r},create(e,r=438){return r&=4095,r|=32768,a.mknod(e,r,0)},mkdir(e,r=511){return r&=1023,r|=16384,a.mknod(e,r,0)},mkdirTree(e,r){var t=e.split("/"),n="";for(var i of t)if(i){(n||$.isAbs(e))&&(n+="/"),n+=i;try{a.mkdir(n,r)}catch(o){if(o.errno!=20)throw o}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)},symlink(e,r){if(!Ie.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:!0}),n=t.node;if(!n)throw new a.ErrnoError(44);var i=$.basename(r),o=a.mayCreate(n,i);if(o)throw new a.ErrnoError(o);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,i,e)},rename(e,r){var t=$.dirname(e),n=$.dirname(r),i=$.basename(e),o=$.basename(r),s,l,d;if(s=a.lookupPath(e,{parent:!0}),l=s.node,s=a.lookupPath(r,{parent:!0}),d=s.node,!l||!d)throw new a.ErrnoError(44);if(l.mount!==d.mount)throw new a.ErrnoError(75);var c=a.lookupNode(l,i),v=Ie.relative(e,n);if(v.charAt(0)!==".")throw new a.ErrnoError(28);if(v=Ie.relative(r,t),v.charAt(0)!==".")throw new a.ErrnoError(55);var m;try{m=a.lookupNode(d,o)}catch{}if(c!==m){var h=a.isDir(c.mode),g=a.mayDelete(l,i,h);if(g)throw new a.ErrnoError(g);if(g=m?a.mayDelete(d,o,h):a.mayCreate(d,o),g)throw new a.ErrnoError(g);if(!l.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(c)||m&&a.isMountpoint(m))throw new a.ErrnoError(10);if(d!==l&&(g=a.nodePermissions(l,"w"),g))throw new a.ErrnoError(g);a.hashRemoveNode(c);try{l.node_ops.rename(c,d,o),c.parent=d}catch(E){throw E}finally{a.hashAddNode(c)}}},rmdir(e){var r=a.lookupPath(e,{parent:!0}),t=r.node,n=$.basename(e),i=a.lookupNode(t,n),o=a.mayDelete(t,n,!0);if(o)throw new a.ErrnoError(o);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(i))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(i)},readdir(e){var r=a.lookupPath(e,{follow:!0}),t=r.node,n=a.checkOpExists(t.node_ops.readdir,54);return n(t)},unlink(e){var r=a.lookupPath(e,{parent:!0}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=$.basename(e),i=a.lookupNode(t,n),o=a.mayDelete(t,n,!1);if(o)throw new a.ErrnoError(o);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(i))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(i)},readlink(e){var r=a.lookupPath(e),t=r.node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,r){var t=a.lookupPath(e,{follow:!r}),n=t.node,i=a.checkOpExists(n.node_ops.getattr,63);return i(n)},fstat(e){var r=a.getStreamChecked(e),t=r.node,n=r.stream_ops.getattr,i=n?r:t;return n??=t.node_ops.getattr,a.checkOpExists(n,63),n(i)},lstat(e){return a.stat(e,!0)},doChmod(e,r,t,n){a.doSetAttr(e,r,{mode:t&4095|r.mode&-4096,ctime:Date.now(),dontFollow:n})},chmod(e,r,t){var n;if(typeof e=="string"){var i=a.lookupPath(e,{follow:!t});n=i.node}else n=e;a.doChmod(null,n,r,t)},lchmod(e,r){a.chmod(e,r,!0)},fchmod(e,r){var t=a.getStreamChecked(e);a.doChmod(t,t.node,r,!1)},doChown(e,r,t){a.doSetAttr(e,r,{timestamp:Date.now(),dontFollow:t})},chown(e,r,t,n){var i;if(typeof e=="string"){var o=a.lookupPath(e,{follow:!n});i=o.node}else i=e;a.doChown(null,i,n)},lchown(e,r,t){a.chown(e,r,t,!0)},fchown(e,r,t){var n=a.getStreamChecked(e);a.doChown(n,n.node,!1)},doTruncate(e,r,t){if(a.isDir(r.mode))throw new a.ErrnoError(31);if(!a.isFile(r.mode))throw new a.ErrnoError(28);var n=a.nodePermissions(r,"w");if(n)throw new a.ErrnoError(n);a.doSetAttr(e,r,{size:t,timestamp:Date.now()})},truncate(e,r){if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:!0});t=n.node}else t=e;a.doTruncate(null,t,r)},ftruncate(e,r){var t=a.getStreamChecked(e);if(r<0||(t.flags&2097155)===0)throw new a.ErrnoError(28);a.doTruncate(t,t.node,r)},utime(e,r,t){var n=a.lookupPath(e,{follow:!0}),i=n.node,o=a.checkOpExists(i.node_ops.setattr,63);o(i,{atime:r,mtime:t})},open(e,r,t=438){if(e==="")throw new a.ErrnoError(44);r=Ni(r),r&64?t=t&4095|32768:t=0;var n,i;if(typeof e=="object")n=e;else{i=e.endsWith("/");var o=a.lookupPath(e,{follow:!(r&131072),noent_okay:!0});n=o.node,e=o.path}var s=!1;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else{if(i)throw new a.ErrnoError(31);n=a.mknod(e,t|511,0),s=!0}if(!n)throw new a.ErrnoError(44);if(a.isChrdev(n.mode)&&(r&=-513),r&65536&&!a.isDir(n.mode))throw new a.ErrnoError(54);if(!s){var l=a.mayOpen(n,r);if(l)throw new a.ErrnoError(l)}r&512&&!s&&a.truncate(n,0),r&=-131713;var d=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:!0,position:0,stream_ops:n.stream_ops,ungotten:[],error:!1});return d.stream_ops.open&&d.stream_ops.open(d),s&&a.chmod(n,t&511),d},close(e){if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(r){throw r}finally{a.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(t!=0&&t!=1&&t!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,r,t),e.ungotten=[],e.position},read(e,r,t,n,i){if(_(t>=0),n<0||i<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var o=typeof i<"u";if(!o)i=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,i);return o||(e.position+=s),s},write(e,r,t,n,i,o){if(_(t>=0),_(r.subarray,"FS.write expects a TypedArray"),n<0||i<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var s=typeof i<"u";if(!s)i=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,i,o);return s||(e.position+=l),l},mmap(e,r,t,n,i){if((n&2)!==0&&(i&2)===0&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);if(!r)throw new a.ErrnoError(28);return e.stream_ops.mmap(e,r,t,n,i)},msync(e,r,t,n,i){return _(t>=0),e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,i):0},ioctl(e,r,t){if(!e.stream_ops.ioctl)throw new a.ErrnoError(59);return e.stream_ops.ioctl(e,r,t)},readFile(e,r={}){r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary"&&H(`Invalid encoding type "${r.encoding}"`);var t=a.open(e,r.flags),n=a.stat(e),i=n.size,o=new Uint8Array(i);return a.read(t,o,0,i,0),r.encoding==="utf8"&&(o=$e(o)),a.close(t),o},writeFile(e,r,t={}){t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);r=zt(r),a.write(n,r,0,r.byteLength,void 0,t.canOwn),a.close(n)},cwd:()=>a.currentPath,chdir(e){var r=a.lookupPath(e,{follow:!0});if(r.node===null)throw new a.ErrnoError(44);if(!a.isDir(r.node.mode))throw new a.ErrnoError(54);var t=a.nodePermissions(r.node,"x");if(t)throw new a.ErrnoError(t);a.currentPath=r.path},createDefaultDirectories(){a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user")},createDefaultDevices(){a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(n,i,o,s,l)=>s,llseek:()=>0}),a.mkdev("/dev/null",a.makedev(1,3)),ce.register(a.makedev(5,0),ce.default_tty_ops),ce.register(a.makedev(6,0),ce.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),r=0,t=()=>(r===0&&(Mr(e),r=e.byteLength),e[--r]);a.createDevice("/dev","random",t),a.createDevice("/dev","urandom",t),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp")},createSpecialDirectories(){a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount(){var r=a.createNode(e,"fd",16895,73);return r.stream_ops={llseek:F.stream_ops.llseek},r.node_ops={lookup(t,n){var i=+n,o=a.getStreamChecked(i),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>o.path},id:i+1};return s.parent=s,s},readdir(){return Array.from(a.streams.entries()).filter(([t,n])=>n).map(([t,n])=>t.toString())}},r}},{},"/proc/self/fd")},createStandardStreams(e,r,t){e?a.createDevice("/dev","stdin",e):a.symlink("/dev/tty","/dev/stdin"),r?a.createDevice("/dev","stdout",null,r):a.symlink("/dev/tty","/dev/stdout"),t?a.createDevice("/dev","stderr",null,t):a.symlink("/dev/tty1","/dev/stderr");var n=a.open("/dev/stdin",0),i=a.open("/dev/stdout",1),o=a.open("/dev/stderr",1);_(n.fd===0,`invalid handle for stdin (${n.fd})`),_(i.fd===1,`invalid handle for stdout (${i.fd})`),_(o.fd===2,`invalid handle for stderr (${o.fd})`)},staticInit(){a.nameTable=new Array(4096),a.mount(F,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:F,NODEFS:b}},init(e,r,t){_(!a.initialized,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)"),a.initialized=!0,e??=f.stdin,r??=f.stdout,t??=f.stderr,a.createStandardStreams(e,r,t)},quit(){a.initialized=!1,rt(0);for(var e of a.streams)e&&a.close(e)},findObject(e,r){var t=a.analyzePath(e,r);return t.exists?t.object:null},analyzePath(e,r){try{var t=a.lookupPath(e,{follow:!r});e=t.path}catch{}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var t=a.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=t.path,n.parentObject=t.node,n.name=$.basename(e),t=a.lookupPath(e,{follow:!r}),n.exists=!0,n.path=t.path,n.object=t.node,n.name=t.node.name,n.isRoot=t.path==="/"}catch(i){n.error=i.errno}return n},createPath(e,r,t,n){e=typeof e=="string"?e:a.getPath(e);for(var i=r.split("/").reverse();i.length;){var o=i.pop();if(o){var s=$.join2(e,o);try{a.mkdir(s)}catch(l){if(l.errno!=20)throw l}e=s}}return s},createFile(e,r,t,n,i){var o=$.join2(typeof e=="string"?e:a.getPath(e),r),s=Ur(n,i);return a.create(o,s)},createDataFile(e,r,t,n,i,o){var s=r;e&&(e=typeof e=="string"?e:a.getPath(e),s=r?$.join2(e,r):e);var l=Ur(n,i),d=a.create(s,l);if(t){t=zt(t),a.chmod(d,l|146);var c=a.open(d,577);a.write(c,t,0,t.length,0,o),a.close(c),a.chmod(d,l)}},createDevice(e,r,t,n){var i=$.join2(typeof e=="string"?e:a.getPath(e),r),o=Ur(!!t,!!n);a.createDevice.major??=64;var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(l){l.seekable=!1},close(l){n?.buffer?.length&&n(10)},read(l,d,c,v,m){for(var h=0,g=0;g<v;g++){var E;try{E=t()}catch{throw new a.ErrnoError(29)}if(E===void 0&&h===0)throw new a.ErrnoError(6);if(E==null)break;h++,d[c+g]=E}return h&&(l.node.atime=Date.now()),h},write(l,d,c,v,m){for(var h=0;h<v;h++)try{n(d[c+h])}catch{throw new a.ErrnoError(29)}return v&&(l.node.mtime=l.node.ctime=Date.now()),h}}),a.mkdev(i,o,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)H("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=We(e.url)}catch{throw new a.ErrnoError(29)}},createLazyFile(e,r,t,n,i){class o{lengthKnown=!1;chunks=[];get(h){if(!(h>this.length-1||h<0)){var g=h%this.chunkSize,E=h/this.chunkSize|0;return this.getter(E)[g]}}setDataGetter(h){this.getter=h}cacheLength(){var h=new XMLHttpRequest;h.open("HEAD",t,!1),h.send(null),h.status>=200&&h.status<300||h.status===304||H("Couldn't load "+t+". Status: "+h.status);var g=Number(h.getResponseHeader("Content-length")),E,k=(E=h.getResponseHeader("Accept-Ranges"))&&E==="bytes",R=(E=h.getResponseHeader("Content-Encoding"))&&E==="gzip",D=1024*1024;k||(D=g);var x=(ee,ne)=>{ee>ne&&H("invalid range ("+ee+", "+ne+") or no bytes requested!"),ne>g-1&&H("only "+g+" bytes available! programmer error!");var j=new XMLHttpRequest;return j.open("GET",t,!1),g!==D&&j.setRequestHeader("Range","bytes="+ee+"-"+ne),j.responseType="arraybuffer",j.overrideMimeType&&j.overrideMimeType("text/plain; charset=x-user-defined"),j.send(null),j.status>=200&&j.status<300||j.status===304||H("Couldn't load "+t+". Status: "+j.status),j.response!==void 0?new Uint8Array(j.response||[]):Lr(j.responseText||"",!0)},U=this;U.setDataGetter(ee=>{var ne=ee*D,j=(ee+1)*D-1;return j=Math.min(j,g-1),typeof U.chunks[ee]>"u"&&(U.chunks[ee]=x(ne,j)),typeof U.chunks[ee]>"u"&&H("doXHR failed!"),U.chunks[ee]}),(R||!g)&&(D=g=1,g=this.getter(0).length,D=g,_e("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=D,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){L||H("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s=new o,l={isDevice:!1,contents:s}}else var l={isDevice:!1,url:t};var d=a.createFile(e,r,l,n,i);l.contents?d.contents=l.contents:l.url&&(d.contents=null,d.url=l.url),Object.defineProperties(d,{usedBytes:{get:function(){return this.contents.length}}});var c={};for(let[m,h]of Object.entries(d.stream_ops))c[m]=(...g)=>(a.forceLoadFile(d),h(...g));function v(m,h,g,E,k){var R=m.node.contents;if(k>=R.length)return 0;var D=Math.min(R.length-k,E);if(_(D>=0),R.slice)for(var x=0;x<D;x++)h[g+x]=R[k+x];else for(var x=0;x<D;x++)h[g+x]=R.get(k+x);return D}return c.read=(m,h,g,E,k)=>(a.forceLoadFile(d),v(m,h,g,E,k)),c.mmap=(m,h,g,E,k)=>{a.forceLoadFile(d);var R=xr(h);if(!R)throw new a.ErrnoError(48);return v(m,(u(),W),R,h,g),{ptr:R,allocated:!0}},d.stream_ops=c,d}},T={websocketArgs:{},callbacks:{},on(e,r){T.callbacks[e]=r},emit(e,r){T.callbacks[e]?.(r)},mount(e){return T.websocketArgs=f.websocket||{},(f.websocket??={}).on=T.on,a.createNode(null,"/",16895,0)},createSocket(e,r,t){if(e!=2)throw new a.ErrnoError(5);if(r&=-526337,r!=1&&r!=2)throw new a.ErrnoError(28);var n=r==1;if(n&&t&&t!=6)throw new a.ErrnoError(66);var i={family:e,type:r,protocol:t,server:null,error:null,peers:{},pending:[],recv_queue:[],sock_ops:T.websocket_sock_ops},o=T.nextname(),s=a.createNode(T.root,o,49152,0);s.sock=i;var l=a.createStream({path:o,node:s,flags:2,seekable:!1,stream_ops:T.stream_ops});return i.stream=l,i},getSocket(e){var r=a.getStream(e);return!r||!a.isSocket(r.node.mode)?null:r.node.sock},stream_ops:{poll(e){var r=e.node.sock;return r.sock_ops.poll(r)},ioctl(e,r,t){var n=e.node.sock;return n.sock_ops.ioctl(n,r,t)},read(e,r,t,n,i){var o=e.node.sock,s=o.sock_ops.recvmsg(o,n);return s?(r.set(s.buffer,t),s.buffer.length):0},write(e,r,t,n,i){var o=e.node.sock;return o.sock_ops.sendmsg(o,r,t,n)},close(e){var r=e.node.sock;r.sock_ops.close(r)}},nextname(){return T.nextname.current||(T.nextname.current=0),`socket[${T.nextname.current++}]`},websocket_sock_ops:{createPeer(e,r,t){var n;if(typeof r=="object"&&(n=r,r=null,t=null),n)if(n._socket)r=n._socket.remoteAddress,t=n._socket.remotePort;else{var i=/ws[s]?:\/\/([^:]+):(\d+)/.exec(n.url);if(!i)throw new Error("WebSocket URL must be in the format ws(s)://address:port");r=i[1],t=parseInt(i[2],10)}else try{var o="ws://".replace("#","//"),s="binary",l=void 0;if(T.websocketArgs.url&&(o=T.websocketArgs.url),T.websocketArgs.subprotocol?s=T.websocketArgs.subprotocol:T.websocketArgs.subprotocol===null&&(s="null"),o==="ws://"||o==="wss://"){var d=r.split("/");o=o+d[0]+":"+t+"/"+d.slice(1).join("/")}s!=="null"&&(s=s.replace(/^ +| +$/g,"").split(/ *, */),l=s);var c;C?c=oe("ws"):c=WebSocket,n=new c(o,l),n.binaryType="arraybuffer"}catch{throw new a.ErrnoError(23)}var v={addr:r,port:t,socket:n,msg_send_queue:[]};return T.websocket_sock_ops.addPeer(e,v),T.websocket_sock_ops.handlePeerEvents(e,v),e.type===2&&typeof e.sport<"u"&&v.msg_send_queue.push(new Uint8Array([255,255,255,255,112,111,114,116,(e.sport&65280)>>8,e.sport&255])),v},getPeer(e,r,t){return e.peers[r+":"+t]},addPeer(e,r){e.peers[r.addr+":"+r.port]=r},removePeer(e,r){delete e.peers[r.addr+":"+r.port]},handlePeerEvents(e,r){var t=!0;function n(){e.connecting=!1,T.emit("open",e.stream.fd);try{for(var o=r.msg_send_queue.shift();o;)r.socket.send(o),o=r.msg_send_queue.shift()}catch{r.socket.close()}}function i(o){if(typeof o=="string"){var s=new TextEncoder;o=s.encode(o)}else{if(_(o.byteLength!==void 0),o.byteLength==0)return;o=new Uint8Array(o)}var l=t;if(t=!1,l&&o.length===10&&o[0]===255&&o[1]===255&&o[2]===255&&o[3]===255&&o[4]===112&&o[5]===111&&o[6]===114&&o[7]===116){var d=o[8]<<8|o[9];T.websocket_sock_ops.removePeer(e,r),r.port=d,T.websocket_sock_ops.addPeer(e,r);return}e.recv_queue.push({addr:r.addr,port:r.port,data:o}),T.emit("message",e.stream.fd)}if(C){r.socket.on("open",n),r.socket.on("message",(o,s)=>{s&&i(new Uint8Array(o).buffer)}),r.socket.on("close",()=>T.emit("close",e.stream.fd)),r.socket.on("error",o=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])});return}r.socket.onopen=n,r.socket.onclose=()=>T.emit("close",e.stream.fd),r.socket.onmessage=o=>i(o.data),r.socket.onerror=o=>{e.error=14,T.emit("error",[e.stream.fd,e.error,"ECONNREFUSED: Connection refused"])}},poll(e){if(e.type===1&&e.server)return e.pending.length?65:0;var r=0,t=e.type===1?T.websocket_sock_ops.getPeer(e,e.daddr,e.dport):null;return(e.recv_queue.length||!t||t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(r|=65),(!t||t&&t.socket.readyState===t.socket.OPEN)&&(r|=4),(t&&t.socket.readyState===t.socket.CLOSING||t&&t.socket.readyState===t.socket.CLOSED)&&(e.connecting?r|=4:r|=16),r},ioctl(e,r,t){switch(r){case 21531:var n=0;return e.recv_queue.length&&(n=e.recv_queue[0].data.length),(u(),S)[t>>2]=n,0;case 21537:var i=(u(),S)[t>>2];return i?e.stream.flags|=2048:e.stream.flags&=-2049,0;default:return 28}},close(e){if(e.server){try{e.server.close()}catch{}e.server=null}for(var r of Object.values(e.peers)){try{r.socket.close()}catch{}T.websocket_sock_ops.removePeer(e,r)}return 0},bind(e,r,t){if(typeof e.saddr<"u"||typeof e.sport<"u")throw new a.ErrnoError(28);if(e.saddr=r,e.sport=t,e.type===2){e.server&&(e.server.close(),e.server=null);try{e.sock_ops.listen(e,0)}catch(n){if(n.name!=="ErrnoError"||n.errno!==138)throw n}}},connect(e,r,t){if(e.server)throw new a.ErrnoError(138);if(typeof e.daddr<"u"&&typeof e.dport<"u"){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(n)throw n.socket.readyState===n.socket.CONNECTING?new a.ErrnoError(7):new a.ErrnoError(30)}var i=T.websocket_sock_ops.createPeer(e,r,t);e.daddr=i.addr,e.dport=i.port,e.connecting=!0},listen(e,r){if(!C)throw new a.ErrnoError(138);if(e.server)throw new a.ErrnoError(28);var t=oe("ws").Server,n=e.saddr;e.server=new t({host:n,port:e.sport}),T.emit("listen",e.stream.fd),e.server.on("connection",i=>{if(e.type===1){var o=T.createSocket(e.family,e.type,e.protocol),s=T.websocket_sock_ops.createPeer(o,i);o.daddr=s.addr,o.dport=s.port,e.pending.push(o),T.emit("connection",o.stream.fd)}else T.websocket_sock_ops.createPeer(e,i),T.emit("connection",e.stream.fd)}),e.server.on("close",()=>{T.emit("close",e.stream.fd),e.server=null}),e.server.on("error",i=>{e.error=23,T.emit("error",[e.stream.fd,e.error,"EHOSTUNREACH: Host is unreachable"])})},accept(e){if(!e.server||!e.pending.length)throw new a.ErrnoError(28);var r=e.pending.shift();return r.stream.flags=e.stream.flags,r},getname(e,r){var t,n;if(r){if(e.daddr===void 0||e.dport===void 0)throw new a.ErrnoError(53);t=e.daddr,n=e.dport}else t=e.saddr||0,n=e.sport||0;return{addr:t,port:n}},sendmsg(e,r,t,n,i,o){if(e.type===2){if((i===void 0||o===void 0)&&(i=e.daddr,o=e.dport),i===void 0||o===void 0)throw new a.ErrnoError(17)}else i=e.daddr,o=e.dport;var s=T.websocket_sock_ops.getPeer(e,i,o);if(e.type===1&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED))throw new a.ErrnoError(53);ArrayBuffer.isView(r)&&(t+=r.byteOffset,r=r.buffer);var l=r.slice(t,t+n);if(l instanceof SharedArrayBuffer&&(l=new Uint8Array(new Uint8Array(l)).buffer),!s||s.socket.readyState!==s.socket.OPEN)return e.type===2&&(!s||s.socket.readyState===s.socket.CLOSING||s.socket.readyState===s.socket.CLOSED)&&(s=T.websocket_sock_ops.createPeer(e,i,o)),s.msg_send_queue.push(l),n;try{return s.socket.send(l),n}catch{throw new a.ErrnoError(28)}},recvmsg(e,r){if(e.type===1&&e.server)throw new a.ErrnoError(53);var t=e.recv_queue.shift();if(!t){if(e.type===1){var n=T.websocket_sock_ops.getPeer(e,e.daddr,e.dport);if(!n)throw new a.ErrnoError(53);if(n.socket.readyState===n.socket.CLOSING||n.socket.readyState===n.socket.CLOSED)return null;throw new a.ErrnoError(6)}throw new a.ErrnoError(6)}var i=t.data.byteLength||t.data.length,o=t.data.byteOffset||0,s=t.data.buffer||t.data,l=Math.min(r,i),d={buffer:new Uint8Array(s,o,l),addr:t.addr,port:t.port};if(e.type===1&&l<i){var c=i-l;t.data=new Uint8Array(s,o+l,c),e.recv_queue.unshift(t)}return d}}},Hr=e=>{var r=T.getSocket(e);if(!r)throw new a.ErrnoError(8);return r},Br=e=>(e&255)+"."+(e>>8&255)+"."+(e>>16&255)+"."+(e>>24&255),qt=e=>{var r="",t=0,n=0,i=0,o=0,s=0,l=0,d=[e[0]&65535,e[0]>>16,e[1]&65535,e[1]>>16,e[2]&65535,e[2]>>16,e[3]&65535,e[3]>>16],c=!0,v="";for(l=0;l<5;l++)if(d[l]!==0){c=!1;break}if(c){if(v=Br(d[6]|d[7]<<16),d[5]===-1)return r="::ffff:",r+=v,r;if(d[5]===0)return r="::",v==="0.0.0.0"&&(v=""),v==="0.0.0.1"&&(v="1"),r+=v,r}for(t=0;t<8;t++)d[t]===0&&(t-i>1&&(s=0),i=t,s++),s>n&&(n=s,o=t-n+1);for(t=0;t<8;t++){if(n>1&&d[t]===0&&t>=o&&t<o+n){t===o&&(r+=":",o===0&&(r+=":"));continue}r+=Number(nt(d[t]&65535)).toString(16),r+=t<7?":":""}return r},ji=(e,r)=>{var t=(u(),J)[e>>1],n=nt((u(),ye)[e+2>>1]),i;switch(t){case 2:if(r!==16)return{errno:28};i=(u(),S)[e+4>>2],i=Br(i);break;case 10:if(r!==28)return{errno:28};i=[(u(),S)[e+8>>2],(u(),S)[e+12>>2],(u(),S)[e+16>>2],(u(),S)[e+20>>2]],i=qt(i);break;default:return{errno:5}}return{family:t,addr:i,port:n}},or=e=>{for(var r=e.split("."),t=0;t<4;t++){var n=Number(r[t]);if(isNaN(n))return null;r[t]=n}return(r[0]|r[1]<<8|r[2]<<16|r[3]<<24)>>>0},zr=e=>{var r,t,n,i,o,s=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,l=[];if(!s.test(e))return null;if(e==="::")return[0,0,0,0,0,0,0,0];for(e.startsWith("::")?e=e.replace("::","Z:"):e=e.replace("::",":Z:"),e.indexOf(".")>0?(e=e.replace(new RegExp("[.]","g"),":"),r=e.split(":"),r[r.length-4]=Number(r[r.length-4])+Number(r[r.length-3])*256,r[r.length-3]=Number(r[r.length-2])+Number(r[r.length-1])*256,r=r.slice(0,r.length-2)):r=e.split(":"),n=0,i=0,t=0;t<r.length;t++)if(typeof r[t]=="string")if(r[t]==="Z"){for(i=0;i<8-r.length+1;i++)l[t+i]=0;n=i-1}else l[t+n]=br(parseInt(r[t],16));else l[t+n]=r[t];return[l[1]<<16|l[0],l[3]<<16|l[2],l[5]<<16|l[4],l[7]<<16|l[6]]},de={address_map:{id:1,addrs:{},names:{}},lookup_name(e){var r=or(e);if(r!==null||(r=zr(e),r!==null))return e;var t;if(de.address_map.addrs[e])t=de.address_map.addrs[e];else{var n=de.address_map.id++;_(n<65535,"exceeded max address mappings of 65535"),t="172.29."+(n&255)+"."+(n&65280),de.address_map.names[t]=e,de.address_map.addrs[e]=t}return t},lookup_addr(e){return de.address_map.names[e]?de.address_map.names[e]:null}},Kt=(e,r)=>{var t=ji(e,r);if(t.errno)throw new a.ErrnoError(t.errno);return t.addr=de.lookup_addr(t.addr)||t.addr,t};function Xt(e,r,t,n,i,o){if(w)return B(3,0,1,e,r,t,n,i,o);try{var s=Hr(e),l=Kt(r,t);return s.sock_ops.connect(s,l.addr,l.port),0}catch(d){if(typeof a>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}var z={currentUmask:18,calculateAt(e,r,t){if($.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else{var i=z.getStreamFromFD(e);n=i.path}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return n+"/"+r},writeStat(e,r){(u(),y)[e>>2]=r.dev,(u(),y)[e+4>>2]=r.mode,(u(),y)[e+8>>2]=r.nlink,(u(),y)[e+12>>2]=r.uid,(u(),y)[e+16>>2]=r.gid,(u(),y)[e+20>>2]=r.rdev,(u(),V)[e+24>>3]=BigInt(r.size),(u(),S)[e+32>>2]=4096,(u(),S)[e+36>>2]=r.blocks;var t=r.atime.getTime(),n=r.mtime.getTime(),i=r.ctime.getTime();return(u(),V)[e+40>>3]=BigInt(Math.floor(t/1e3)),(u(),y)[e+48>>2]=t%1e3*1e3*1e3,(u(),V)[e+56>>3]=BigInt(Math.floor(n/1e3)),(u(),y)[e+64>>2]=n%1e3*1e3*1e3,(u(),V)[e+72>>3]=BigInt(Math.floor(i/1e3)),(u(),y)[e+80>>2]=i%1e3*1e3*1e3,(u(),V)[e+88>>3]=BigInt(r.ino),0},writeStatFs(e,r){(u(),y)[e+4>>2]=r.bsize,(u(),y)[e+60>>2]=r.bsize,(u(),V)[e+8>>3]=BigInt(r.blocks),(u(),V)[e+16>>3]=BigInt(r.bfree),(u(),V)[e+24>>3]=BigInt(r.bavail),(u(),V)[e+32>>3]=BigInt(r.files),(u(),V)[e+40>>3]=BigInt(r.ffree),(u(),y)[e+48>>2]=r.fsid,(u(),y)[e+64>>2]=r.flags,(u(),y)[e+56>>2]=r.namelen},doMsync(e,r,t,n,i){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var o=(u(),K).slice(e,e+t);a.msync(r,o,i,t,n)},getStreamFromFD(e){var r=a.getStreamChecked(e);return r},varargs:void 0,getStr(e){var r=le(e);return r}};function Yt(e){if(w)return B(4,0,1,e);try{var r=z.getStreamFromFD(e);return a.dupStream(r).fd}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}var sr=()=>{_(z.varargs!=null);var e=(u(),S)[+z.varargs>>2];return z.varargs+=4,e},Ne=sr;function Jt(e,r,t){if(w)return B(5,0,1,e,r,t);z.varargs=t;try{var n=z.getStreamFromFD(e);switch(r){case 0:{var i=sr();if(i<0)return-28;for(;a.streams[i];)i++;var o;return o=a.dupStream(n,i),o.fd}case 1:case 2:return 0;case 3:return n.flags;case 4:{var i=sr(),s=289792;return n.flags=n.flags&~s|i&s,0}case 12:{var i=Ne(),l=0;return(u(),J)[i+l>>1]=2,0}case 13:case 14:return 0}return-28}catch(d){if(typeof a>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}var he=(e,r,t)=>(_(typeof t=="number","stringToUTF8 requires a third parameter that specifies the length of the output buffer"),Bt(e,(u(),K),r,t));function Zt(e,r){if(w)return B(6,0,1,e,r);try{if(r===0)return-28;var t=a.cwd(),n=be(t)+1;return r<n?-68:(he(t,e,r),n)}catch(i){if(typeof a>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Qt(e,r,t){if(w)return B(7,0,1,e,r,t);z.varargs=t;try{var n=z.getStreamFromFD(e);switch(r){case 21509:return n.tty?0:-59;case 21505:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcgets){var i=n.tty.ops.ioctl_tcgets(n),o=Ne();(u(),S)[o>>2]=i.c_iflag||0,(u(),S)[o+4>>2]=i.c_oflag||0,(u(),S)[o+8>>2]=i.c_cflag||0,(u(),S)[o+12>>2]=i.c_lflag||0;for(var s=0;s<32;s++)(u(),W)[o+s+17]=i.c_cc[s]||0;return 0}return 0}case 21510:case 21511:case 21512:return n.tty?0:-59;case 21506:case 21507:case 21508:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tcsets){for(var o=Ne(),l=(u(),S)[o>>2],d=(u(),S)[o+4>>2],c=(u(),S)[o+8>>2],v=(u(),S)[o+12>>2],m=[],s=0;s<32;s++)m.push((u(),W)[o+s+17]);return n.tty.ops.ioctl_tcsets(n.tty,r,{c_iflag:l,c_oflag:d,c_cflag:c,c_lflag:v,c_cc:m})}return 0}case 21519:{if(!n.tty)return-59;var o=Ne();return(u(),S)[o>>2]=0,0}case 21520:return n.tty?-28:-59;case 21537:case 21531:{var o=Ne();return a.ioctl(n,r,o)}case 21523:{if(!n.tty)return-59;if(n.tty.ops.ioctl_tiocgwinsz){var h=n.tty.ops.ioctl_tiocgwinsz(n.tty),o=Ne();(u(),J)[o>>1]=h[0],(u(),J)[o+2>>1]=h[1]}return 0}case 21524:return n.tty?0:-59;case 21515:return n.tty?0:-59;default:return-28}}catch(g){if(typeof a>"u"||g.name!=="ErrnoError")throw g;return-g.errno}}function en(e,r,t,n){if(w)return B(8,0,1,e,r,t,n);z.varargs=n;try{r=z.getStr(r),r=z.calculateAt(e,r);var i=n?sr():0;return t&64&&(i&=~z.currentUmask),a.open(r,t,i).fd}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function rn(e,r,t,n){if(w)return B(9,0,1,e,r,t,n);try{if(r=z.getStr(r),r=z.calculateAt(e,r),n<=0)return-28;var i=a.readlink(r),o=Math.min(n,be(i)),s=(u(),W)[t+o];return he(i,t,n+1),(u(),W)[t+o]=s,o}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}var tn=(e,r)=>(u(),K).fill(0,e,e+r),nn=(e,r,t,n,i)=>{switch(r){case 2:t=or(t),tn(e,16),i&&((u(),S)[i>>2]=16),(u(),J)[e>>1]=r,(u(),S)[e+4>>2]=t,(u(),J)[e+2>>1]=br(n);break;case 10:t=zr(t),tn(e,28),i&&((u(),S)[i>>2]=28),(u(),S)[e>>2]=r,(u(),S)[e+8>>2]=t[0],(u(),S)[e+12>>2]=t[1],(u(),S)[e+16>>2]=t[2],(u(),S)[e+20>>2]=t[3],(u(),J)[e+2>>1]=br(n);break;default:return 5}return 0};function an(e,r,t,n,i,o){if(w)return B(10,0,1,e,r,t,n,i,o);try{var s=Hr(e),l=s.sock_ops.recvmsg(s,t);if(!l)return 0;if(i){var d=nn(i,s.family,de.lookup_name(l.addr),l.port,o);_(!d)}return(u(),K).set(l.buffer,r),l.buffer.byteLength}catch(c){if(typeof a>"u"||c.name!=="ErrnoError")throw c;return-c.errno}}function on(e){if(w)return B(11,0,1,e);try{return e=z.getStr(e),a.rmdir(e),0}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function sn(e,r,t,n,i,o){if(w)return B(12,0,1,e,r,t,n,i,o);try{var s=Hr(e);if(!i)return a.write(s.stream,(u(),W),r,t);var l=Kt(i,o);return s.sock_ops.sendmsg(s,(u(),W),r,t,l.addr,l.port)}catch(d){if(typeof a>"u"||d.name!=="ErrnoError")throw d;return-d.errno}}function ln(e,r,t){if(w)return B(13,0,1,e,r,t);try{var n=T.createSocket(e,r,t);return _(n.stream.fd<64),n.stream.fd}catch(i){if(typeof a>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function dn(e,r,t){if(w)return B(14,0,1,e,r,t);try{if(r=z.getStr(r),r=z.calculateAt(e,r),!t)a.unlink(r);else if(t===512)a.rmdir(r);else return-28;return 0}catch(n){if(typeof a>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}var Hi=()=>H("native code called abort()"),lr={},dr=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r)}};function je(e){return this.fromWireType((u(),y)[e>>2])}var Me={},Se={},ur={},Bi=class extends Error{constructor(r){super(r),this.name="InternalError"}},cr=e=>{throw new Bi(e)},ie=(e,r,t)=>{e.forEach(l=>ur[l]=r);function n(l){var d=t(l);d.length!==e.length&&cr("Mismatched type converter count");for(var c=0;c<e.length;++c)Z(e[c],d[c])}var i=new Array(r.length),o=[],s=0;for(let[l,d]of r.entries())Se.hasOwnProperty(d)?i[l]=Se[d]:(o.push(d),Me.hasOwnProperty(d)||(Me[d]=[]),Me[d].push(()=>{i[l]=Se[d],++s,s===o.length&&n(i)}));o.length===0&&n(i)},zi=e=>{var r=lr[e];delete lr[e];var t=r.rawConstructor,n=r.rawDestructor,i=r.fields,o=i.map(s=>s.getterReturnType).concat(i.map(s=>s.setterArgumentType));ie([e],o,s=>{var l={};for(var[d,c]of i.entries()){let v=s[d],m=c.getter,h=c.getterContext,g=s[d+i.length],E=c.setter,k=c.setterContext;l[c.fieldName]={read:R=>v.fromWireType(m(h,R)),write:(R,D)=>{var x=[];E(k,R,g.toWireType(x,D)),dr(x)},optional:v.optional}}return[{name:r.name,fromWireType:v=>{var m={};for(var h in l)m[h]=l[h].read(v);return n(v),m},toWireType:(v,m)=>{for(var h in l)if(!(h in m)&&!l[h].optional)throw new TypeError(`Missing field: "${h}"`);var g=t();for(h in l)l[h].write(g,m[h]);return v!==null&&v.push(n,g),g},readValueFromPointer:je,destructorFunction:n}]})},G=e=>{for(var r="";;){var t=(u(),K)[e++];if(!t)return r;r+=String.fromCharCode(t)}},He=class extends Error{constructor(r){super(r),this.name="BindingError"}},O=e=>{throw new He(e)};function Gi(e,r,t={}){var n=r.name;if(e||O(`type "${n}" must have a positive integer typeid pointer`),Se.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;O(`Cannot register type '${n}' twice`)}if(Se[e]=r,delete ur[e],Me.hasOwnProperty(e)){var i=Me[e];delete Me[e],i.forEach(o=>o())}}function Z(e,r,t={}){return Gi(e,r,t)}var un=(e,r,t)=>{switch(r){case 1:return t?n=>(u(),W)[n]:n=>(u(),K)[n];case 2:return t?n=>(u(),J)[n>>1]:n=>(u(),ye)[n>>1];case 4:return t?n=>(u(),S)[n>>2]:n=>(u(),y)[n>>2];case 8:return t?n=>(u(),V)[n>>3]:n=>(u(),Tt)[n>>3];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},ke=e=>{if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},cn=(e,r,t,n)=>{if(r<t||r>n)throw new TypeError(`Passing a number "${ke(r)}" from JS side to C/C++ side to an argument of type "${e}", which is outside the valid range [${t}, ${n}]!`)},Vi=(e,r,t,n,i)=>{r=G(r);let o=n===0n,s=l=>l;if(o){let l=t*8;s=d=>BigInt.asUintN(l,d),i=s(i)}Z(e,{name:r,fromWireType:s,toWireType:(l,d)=>{if(typeof d=="number")d=BigInt(d);else if(typeof d!="bigint")throw new TypeError(`Cannot convert "${ke(d)}" to ${r}`);return cn(r,d,n,i),d},readValueFromPointer:un(r,t,!o),destructorFunction:null})},qi=(e,r,t,n)=>{r=G(r),Z(e,{name:r,fromWireType:function(i){return!!i},toWireType:function(i,o){return o?t:n},readValueFromPointer:function(i){return this.fromWireType((u(),K)[i])},destructorFunction:null})},Ki=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Gr=e=>{function r(t){return t.$$.ptrType.registeredClass.name}O(r(e)+" instance already deleted")},Vr=!1,fn=e=>{},Xi=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)},_n=e=>{e.count.value-=1;var r=e.count.value===0;r&&Xi(e)},vn=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=vn(e,r,t.baseClass);return n===null?null:t.downcast(n)},mn={},Yi={},Ji=(e,r)=>{for(r===void 0&&O("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},Zi=(e,r)=>(r=Ji(e,r),Yi[r]),fr=(e,r)=>{(!r.ptrType||!r.ptr)&&cr("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&cr("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Be(Object.create(e,{$$:{value:r,writable:!0}}))};function hn(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Zi(this.registeredClass,r);if(t!==void 0){if(t.$$.count.value===0)return t.$$.ptr=r,t.$$.smartPtr=e,t.clone();var n=t.clone();return this.destructor(e),n}function i(){return this.isSmartPointer?fr(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):fr(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var o=this.registeredClass.getActualType(r),s=mn[o];if(!s)return i.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var d=vn(r,this.registeredClass,l.registeredClass);return d===null?i.call(this):this.isSmartPointer?fr(l.registeredClass.instancePrototype,{ptrType:l,ptr:d,smartPtrType:this,smartPtr:e}):fr(l.registeredClass.instancePrototype,{ptrType:l,ptr:d})}var Be=e=>globalThis.FinalizationRegistry?(Vr=new FinalizationRegistry(r=>{console.warn(r.leakWarning),_n(r.$$)}),Be=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var i={$$:t},o=t.ptrType.registeredClass,s=new Error(`Embind found a leaked C++ instance ${o.name} <${me(t.ptr)}>.
|
|
5
|
+
We'll free it automatically in this case, but this functionality is not reliable across various environments.
|
|
6
|
+
Make sure to invoke .delete() manually once you're done with the instance instead.
|
|
7
|
+
Originally allocated`);"captureStackTrace"in Error&&Error.captureStackTrace(s,hn),i.leakWarning=s.stack.replace(/^Error: /,""),Vr.register(r,i,r)}return r},fn=r=>Vr.unregister(r),Be(e)):(Be=r=>r,e),_r=[],Qi=()=>{for(;_r.length;){var e=_r.pop();e.$$.deleteScheduled=!1,e.delete()}},pn,ea=()=>{let e=vr.prototype;Object.assign(e,{isAliasOf(t){if(!(this instanceof vr)||!(t instanceof vr))return!1;var n=this.$$.ptrType.registeredClass,i=this.$$.ptr;t.$$=t.$$;for(var o=t.$$.ptrType.registeredClass,s=t.$$.ptr;n.baseClass;)i=n.upcast(i),n=n.baseClass;for(;o.baseClass;)s=o.upcast(s),o=o.baseClass;return n===o&&i===s},clone(){if(this.$$.ptr||Gr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var t=Be(Object.create(Object.getPrototypeOf(this),{$$:{value:Ki(this.$$)}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t},delete(){this.$$.ptr||Gr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&O("Object already scheduled for deletion"),fn(this),_n(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||Gr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&O("Object already scheduled for deletion"),_r.push(this),_r.length===1&&pn&&pn(Qi),this.$$.deleteScheduled=!0,this}});let r=Symbol.dispose;r&&(e[r]=e.delete)};function vr(){}var mr=(e,r)=>Object.defineProperty(r,"name",{value:e}),qr=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...i){return e[r].overloadTable.hasOwnProperty(i.length)||O(`Function '${t}' called with an invalid number of arguments (${i.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[i.length].apply(this,i)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n}},ze=(e,r,t)=>{f.hasOwnProperty(e)?((t===void 0||f[e].overloadTable!==void 0&&f[e].overloadTable[t]!==void 0)&&O(`Cannot register public name '${e}' twice`),qr(f,e,e),f[e].overloadTable.hasOwnProperty(t)&&O(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),f[e].overloadTable[t]=r):(f[e]=r,f[e].argCount=t)},ra=48,ta=57,na=e=>{_(typeof e=="string"),e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=ra&&r<=ta?`_${e}`:e};function ia(e,r,t,n,i,o,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=i,this.getActualType=o,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[]}var hr=(e,r,t)=>{for(;r!==t;)r.upcast||O(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function aa(e,r){if(r===null)return this.isReference&&O(`null is not a valid ${this.name}`),0;r.$$||O(`Cannot pass "${ke(r)}" as a ${this.name}`),r.$$.ptr||O(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=hr(r.$$.ptr,t,this.registeredClass);return n}function oa(e,r){var t;if(r===null)return this.isReference&&O(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&O(`Cannot pass "${ke(r)}" as a ${this.name}`),r.$$.ptr||O(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&O(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);var n=r.$$.ptrType.registeredClass;if(t=hr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&O("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:O(`Cannot convert argument of type ${r.$$.smartPtrType?r.$$.smartPtrType.name:r.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:t=r.$$.smartPtr;break;case 2:if(r.$$.smartPtrType===this)t=r.$$.smartPtr;else{var i=r.clone();t=this.rawShare(t,X.toHandle(()=>i.delete())),e!==null&&e.push(this.rawDestructor,t)}break;default:O("Unsupported sharing policy")}return t}function sa(e,r){if(r===null)return this.isReference&&O(`null is not a valid ${this.name}`),0;r.$$||O(`Cannot pass "${ke(r)}" as a ${this.name}`),r.$$.ptr||O(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&O(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=hr(r.$$.ptr,t,this.registeredClass);return n}var la=()=>{Object.assign(pr.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e)},readValueFromPointer:je,fromWireType:hn})};function pr(e,r,t,n,i,o,s,l,d,c,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=i,this.pointeeType=o,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=d,this.rawShare=c,this.rawDestructor=v,!i&&r.baseClass===void 0?n?(this.toWireType=aa,this.destructorFunction=null):(this.toWireType=sa,this.destructorFunction=null):this.toWireType=oa}var gn=(e,r,t)=>{f.hasOwnProperty(e)||cr("Replacing nonexistent public symbol"),f[e].overloadTable!==void 0&&t!==void 0?f[e].overloadTable[t]=r:(f[e]=r,f[e].argCount=t)},Q=(e,r,t=!1)=>{_(!t,"async bindings are only supported with JSPI"),e=G(e);function n(){var o=Lt(r);return o}var i=n();return typeof i!="function"&&O(`unknown function pointer with signature ${e}: ${r}`),i};class da extends Error{}var yn=e=>{var r=xn(e),t=G(r);return ue(r),t},Te=(e,r)=>{var t=[],n={};function i(o){if(!n[o]&&!Se[o]){if(ur[o]){ur[o].forEach(i);return}t.push(o),n[o]=!0}}throw r.forEach(i),new da(`${e}: `+t.map(yn).join([", "]))},ua=(e,r,t,n,i,o,s,l,d,c,v,m,h)=>{v=G(v),o=Q(i,o),l&&=Q(s,l),c&&=Q(d,c),h=Q(m,h);var g=na(v);ze(g,function(){Te(`Cannot construct ${v} due to unbound types`,[n])}),ie([e,r,t],n?[n]:[],E=>{E=E[0];var k,R;n?(k=E.registeredClass,R=k.instancePrototype):R=vr.prototype;var D=mr(v,function(...re){if(Object.getPrototypeOf(this)!==x)throw new He(`Use 'new' to construct ${v}`);if(U.constructor_body===void 0)throw new He(`${v} has no accessible constructor`);var Ke=U.constructor_body[re.length];if(Ke===void 0)throw new He(`Tried to invoke ctor of ${v} with invalid number of parameters (${re.length}) - expected (${Object.keys(U.constructor_body).toString()}) parameters instead!`);return Ke.apply(this,re)}),x=Object.create(R,{constructor:{value:D}});D.prototype=x;var U=new ia(v,D,x,h,k,o,l,c);U.baseClass&&(U.baseClass.__derivedClasses??=[],U.baseClass.__derivedClasses.push(U));var ee=new pr(v,U,!0,!1,!1),ne=new pr(v+"*",U,!1,!1,!1),j=new pr(v+" const*",U,!1,!0,!1);return mn[e]={pointerType:ne,constPointerType:j},gn(g,D),[ee,ne,j]})};function wn(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return!0;return!1}function ca(e,r,t,n,i){if(e<r||e>t){var o=r==t?r:`${r} to ${t}`;i(`function ${n} called with ${e} arguments, expected ${o}`)}}function fa(e,r,t,n){var i=wn(e),o=e.length-2,s=[],l=["fn"];r&&l.push("thisWired");for(var d=0;d<o;++d)s.push(`arg${d}`),l.push(`arg${d}Wired`);s=s.join(","),l=l.join(",");var c=`return function (${s}) {
|
|
8
|
+
`;c+=`checkArgCount(arguments.length, minArgs, maxArgs, humanName, throwBindingError);
|
|
9
|
+
`,i&&(c+=`var destructors = [];
|
|
10
|
+
`);var v=i?"destructors":"null",m=["humanName","throwBindingError","invoker","fn","runDestructors","fromRetWire","toClassParamWire"];r&&(c+=`var thisWired = toClassParamWire(${v}, this);
|
|
11
|
+
`);for(var d=0;d<o;++d){var h=`toArg${d}Wire`;c+=`var arg${d}Wired = ${h}(${v}, arg${d});
|
|
12
|
+
`,m.push(h)}c+=(t||n?"var rv = ":"")+`invoker(${l});
|
|
13
|
+
`;var g=t?"rv":"";if(i)c+=`runDestructors(destructors);
|
|
14
|
+
`;else for(var d=r?1:2;d<e.length;++d){var E=d===1?"thisWired":"arg"+(d-2)+"Wired";e[d].destructorFunction!==null&&(c+=`${E}_dtor(${E});
|
|
15
|
+
`,m.push(`${E}_dtor`))}return t&&(c+=`var ret = fromRetWire(rv);
|
|
16
|
+
return ret;
|
|
17
|
+
`),c+=`}
|
|
18
|
+
`,m.push("checkArgCount","minArgs","maxArgs"),c=`if (arguments.length !== ${m.length}){ throw new Error(humanName + "Expected ${m.length} closure arguments " + arguments.length + " given."); }
|
|
19
|
+
${c}`,new Function(m,c)}function _a(e){for(var r=e.length-2,t=e.length-1;t>=2&&e[t].optional;--t)r--;return r}function gr(e,r,t,n,i,o){var s=r.length;s<2&&O("argTypes array size mismatch! Must at least get return value and 'this' types!"),_(!o,"async bindings are only supported with JSPI");for(var l=r[1]!==null&&t!==null,d=wn(r),c=!r[0].isVoid,v=s-2,m=_a(r),h=r[0],g=r[1],E=[e,O,n,i,dr,h.fromWireType.bind(h),g?.toWireType.bind(g)],k=2;k<s;++k){var R=r[k];E.push(R.toWireType.bind(R))}if(!d)for(var k=l?1:2;k<r.length;++k)r[k].destructorFunction!==null&&E.push(r[k].destructorFunction);E.push(ca,m,v);var x=fa(r,l,c,o)(...E);return mr(e,x)}var yr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push((u(),y)[r+n*4>>2]);return t},Kr=e=>{e=e.trim();let r=e.indexOf("(");return r===-1?e:(_(e.endsWith(")"),"Parentheses for argument names should match."),e.slice(0,r))},va=(e,r,t,n,i,o,s,l,d)=>{var c=yr(t,n);r=G(r),r=Kr(r),o=Q(i,o,l),ie([],[e],v=>{v=v[0];var m=`${v.name}.${r}`;function h(){Te(`Cannot call ${m} due to unbound types`,c)}r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var g=v.registeredClass.constructor;return g[r]===void 0?(h.argCount=t-1,g[r]=h):(qr(g,r,m),g[r].overloadTable[t-1]=h),ie([],c,E=>{var k=[E[0],null].concat(E.slice(1)),R=gr(m,k,null,o,s,l);if(g[r].overloadTable===void 0?(R.argCount=t-1,g[r]=R):g[r].overloadTable[t-1]=R,v.registeredClass.__derivedClasses)for(let D of v.registeredClass.__derivedClasses)D.constructor.hasOwnProperty(r)||(D.constructor[r]=R);return[]}),[]})},ma=(e,r,t,n,i,o)=>{_(r>0);var s=yr(r,t);i=Q(n,i);var l=[o],d=[];ie([],[e],c=>{c=c[0];var v=`constructor ${c.name}`;if(c.registeredClass.constructor_body===void 0&&(c.registeredClass.constructor_body=[]),c.registeredClass.constructor_body[r-1]!==void 0)throw new He(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${c.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return c.registeredClass.constructor_body[r-1]=()=>{Te(`Cannot construct ${c.name} due to unbound types`,s)},ie([],s,m=>(m.splice(1,0,null),c.registeredClass.constructor_body[r-1]=gr(v,m,null,i,o),[])),[]})},ha=(e,r,t,n,i,o,s,l,d,c)=>{var v=yr(t,n);r=G(r),r=Kr(r),o=Q(i,o,d),ie([],[e],m=>{m=m[0];var h=`${m.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&m.registeredClass.pureVirtualFunctions.push(r);function g(){Te(`Cannot call ${h} due to unbound types`,v)}var E=m.registeredClass.instancePrototype,k=E[r];return k===void 0||k.overloadTable===void 0&&k.className!==m.name&&k.argCount===t-2?(g.argCount=t-2,g.className=m.name,E[r]=g):(qr(E,r,h),E[r].overloadTable[t-2]=g),ie([],v,R=>{var D=gr(h,R,m,o,s,d);return E[r].overloadTable===void 0?(D.argCount=t-2,E[r]=D):E[r].overloadTable[t-2]=D,[]}),[]})},En=(e,r,t)=>(e instanceof Object||O(`${t} with invalid "this": ${e}`),e instanceof r.registeredClass.constructor||O(`${t} incompatible with "this" of type ${e.constructor.name}`),e.$$.ptr||O(`cannot call emscripten binding method ${t} on deleted object`),hr(e.$$.ptr,e.$$.ptrType.registeredClass,r.registeredClass)),pa=(e,r,t,n,i,o,s,l,d,c)=>{r=G(r),i=Q(n,i),ie([],[e],v=>{v=v[0];var m=`${v.name}.${r}`,h={get(){Te(`Cannot access ${m} due to unbound types`,[t,s])},enumerable:!0,configurable:!0};return d?h.set=()=>Te(`Cannot access ${m} due to unbound types`,[t,s]):h.set=g=>O(m+" is a read-only property"),Object.defineProperty(v.registeredClass.instancePrototype,r,h),ie([],d?[t,s]:[t],g=>{var E=g[0],k={get(){var D=En(this,v,m+" getter");return E.fromWireType(i(o,D))},enumerable:!0};if(d){d=Q(l,d);var R=g[1];k.set=function(D){var x=En(this,v,m+" setter"),U=[];d(c,x,R.toWireType(U,D)),dr(U)}}return Object.defineProperty(v.registeredClass.instancePrototype,r,k),[]}),[]})},bn=[],ae=[0,1,,1,null,1,!0,1,!1,1],Xr=e=>{if(e>9&&--ae[e+1]===0){_(ae[e]!==void 0,"decref for unallocated handle");var r=ae[e];ae[e]=void 0,bn.push(e)}},X={toValue:e=>(e||O(`Cannot use deleted val. handle = ${e}`),_(e===2||ae[e]!==void 0&&e%2===0,`invalid handle: ${e}`),ae[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let r=bn.pop()||ae.length;return ae[r]=e,ae[r+1]=1,r}}}},Sn={name:"emscripten::val",fromWireType:e=>{var r=X.toValue(e);return Xr(e),r},toWireType:(e,r)=>X.toHandle(r),readValueFromPointer:je,destructorFunction:null},ga=e=>Z(e,Sn),Yr=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType((u(),W)[n])}:function(n){return this.fromWireType((u(),K)[n])};case 2:return t?function(n){return this.fromWireType((u(),J)[n>>1])}:function(n){return this.fromWireType((u(),ye)[n>>1])};case 4:return t?function(n){return this.fromWireType((u(),S)[n>>2])}:function(n){return this.fromWireType((u(),y)[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}};function ya(e){return e===0?"object":e===1?"number":"string"}var wa=(e,r,t,n,i)=>{r=G(r);let o=ya(i);switch(o){case"object":{let c=function(){};c.values={},Z(e,{name:r,constructor:c,valueType:o,fromWireType:function(v){return this.constructor.values[v]},toWireType:(v,m)=>m.value,readValueFromPointer:Yr(r,t,n),destructorFunction:null}),ze(r,c);break}case"number":{var s={};Z(e,{name:r,keysMap:s,valueType:o,fromWireType:c=>c,toWireType:(c,v)=>v,readValueFromPointer:Yr(r,t,n),destructorFunction:null}),ze(r,s),delete f[r].argCount;break}case"string":{var l={},d={},s={};Z(e,{name:r,valuesMap:l,reverseMap:d,keysMap:s,valueType:o,fromWireType:function(v){return this.reverseMap[v]},toWireType:function(v,m){return this.valuesMap[m]},readValueFromPointer:Yr(r,t,n),destructorFunction:null}),ze(r,s),delete f[r].argCount;break}}},kn=(e,r)=>{var t=Se[e];return t===void 0&&O(`${r} has unknown type ${yn(e)}`),t},Ea=(e,r,t)=>{var n=kn(e,"enum");switch(r=G(r),n.valueType){case"object":{var i=n.constructor,o=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:mr(`${n.name}_${r}`,function(){})}});i.values[t]=o,i[r]=o;break}case"number":{n.keysMap[r]=t;break}case"string":{n.valuesMap[r]=t,n.reverseMap[t]=r,n.keysMap[r]=r;break}}},ba=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType((u(),tr)[t>>2])};case 8:return function(t){return this.fromWireType((u(),Re)[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},Sa=(e,r,t)=>{r=G(r),Z(e,{name:r,fromWireType:n=>n,toWireType:(n,i)=>{if(typeof i!="number"&&typeof i!="boolean")throw new TypeError(`Cannot convert ${ke(i)} to ${r}`);return i},readValueFromPointer:ba(r,t),destructorFunction:null})},ka=(e,r,t,n,i,o,s,l)=>{var d=yr(r,t);e=G(e),e=Kr(e),i=Q(n,i,s),ze(e,function(){Te(`Cannot call ${e} due to unbound types`,d)},r-1),ie([],d,c=>{var v=[c[0],null].concat(c.slice(1));return gn(e,gr(e,v,null,i,o,s),r-1),[]})},Ta=(e,r,t,n,i)=>{r=G(r);let o=n===0,s=d=>d;if(o){var l=32-8*t;s=d=>d<<l>>>l,i=s(i)}Z(e,{name:r,fromWireType:s,toWireType:(d,c)=>{if(typeof c!="number"&&typeof c!="boolean")throw new TypeError(`Cannot convert "${ke(c)}" to ${r}`);return cn(r,c,n,i),c},readValueFromPointer:un(r,t,n!==0),destructorFunction:null})},Fa=(e,r,t)=>{let n=(i,o)=>{let s=0;return{next(){if(s>=i)return{done:!0};let l=s;return s++,{value:o(l),done:!1}},[Symbol.iterator](){return this}}};e[Symbol.iterator]||(e[Symbol.iterator]=function(){let i=this[r]();return n(i,o=>this[t](o))})},Pa=(e,r,t,n)=>{t=G(t),n=G(n),ie([],[e,r],i=>{let o=i[0];return Fa(o.registeredClass.instancePrototype,t,n),[]})},Ca=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],i=n[r];function o(s){var l=(u(),y)[s>>2],d=(u(),y)[s+4>>2];return new i((u(),W).buffer,d,l)}t=G(t),Z(e,{name:t,fromWireType:o,readValueFromPointer:o},{ignoreDuplicateRegistrations:!0})},Aa=Object.assign({optional:!0},Sn),Oa=(e,r)=>{Z(e,Aa)},Ra=(e,r)=>{r=G(r);var t=!0;Z(e,{name:r,fromWireType(n){var i=(u(),y)[n>>2],o=n+4,s;if(t)s=le(o,i,!0);else{s="";for(var l=0;l<i;++l)s+=String.fromCharCode((u(),K)[o+l])}return ue(n),s},toWireType(n,i){i instanceof ArrayBuffer&&(i=new Uint8Array(i));var o,s=typeof i=="string";s||ArrayBuffer.isView(i)&&i.BYTES_PER_ELEMENT==1||O("Cannot pass non-string to std::string"),t&&s?o=be(i):o=i.length;var l=Ve(4+o+1),d=l+4;if((u(),y)[l>>2]=o,s)if(t)he(i,d,o+1);else for(var c=0;c<o;++c){var v=i.charCodeAt(c);v>255&&(ue(l),O("String has UTF-16 code units that do not fit in 8 bits")),(u(),K)[d+c]=v}else(u(),K).set(i,d);return n!==null&&n.push(ue,l),l},readValueFromPointer:je,destructorFunction(n){ue(n)}})},Tn=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,Da=(e,r,t)=>{_(e%2==0,"pointer passed to UTF16ToString must be 2-byte aligned");var n=e>>1,i=Ut((u(),ye),n,r/2,t);if(i-n>16&&Tn)return Tn.decode((u(),ye).slice(n,i));for(var o="",s=n;s<i;++s){var l=(u(),ye)[s];o+=String.fromCharCode(l)}return o},$a=(e,r,t)=>{if(_(r%2==0,"pointer passed to stringToUTF16 must be 2-byte aligned"),_(typeof t=="number","stringToUTF16 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<2)return 0;t-=2;for(var n=r,i=t<e.length*2?t/2:e.length,o=0;o<i;++o){var s=e.charCodeAt(o);(u(),J)[r>>1]=s,r+=2}return(u(),J)[r>>1]=0,r-n},Ia=e=>e.length*2,Na=(e,r,t)=>{_(e%4==0,"pointer passed to UTF32ToString must be 2-byte aligned");for(var n="",i=e>>2,o=0;!(o>=r/4);o++){var s=(u(),y)[i+o];if(!s&&!t)break;n+=String.fromCodePoint(s)}return n},Ma=(e,r,t)=>{if(_(r%4==0,"pointer passed to stringToUTF32 must be 4-byte aligned"),_(typeof t=="number","stringToUTF32 requires a third parameter that specifies the length of the output buffer"),t??=2147483647,t<4)return 0;for(var n=r,i=n+t-4,o=0;o<e.length;++o){var s=e.codePointAt(o);if(s>65535&&o++,(u(),S)[r>>2]=s,r+=4,r+4>i)break}return(u(),S)[r>>2]=0,r-n},Wa=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.codePointAt(t);n>65535&&t++,r+=4}return r},La=(e,r,t)=>{t=G(t);var n,i,o;r===2?(n=Da,i=$a,o=Ia):(_(r===4,"only 2-byte and 4-byte strings are currently supported"),n=Na,i=Ma,o=Wa),Z(e,{name:t,fromWireType:s=>{var l=(u(),y)[s>>2],d=n(s+4,l*r,!0);return ue(s),d},toWireType:(s,l)=>{typeof l!="string"&&O(`Cannot pass non-string to C++ string type ${t}`);var d=o(l),c=Ve(4+d+r);return(u(),y)[c>>2]=d/r,i(l,c+4,d+r),s!==null&&s.push(ue,c),c},readValueFromPointer:je,destructorFunction(s){ue(s)}})},xa=(e,r,t,n,i,o)=>{lr[e]={name:G(r),rawConstructor:Q(t,n),rawDestructor:Q(i,o),fields:[]}},Ua=(e,r,t,n,i,o,s,l,d,c)=>{lr[e].fields.push({fieldName:G(r),getterReturnType:t,getter:Q(n,i),getterContext:o,setterArgumentType:s,setter:Q(l,d),setterContext:c})},ja=(e,r)=>{r=G(r),Z(e,{isVoid:!0,name:r,fromWireType:()=>{},toWireType:(t,n)=>{}})},Ha=e=>{et(e,!L,1,!M,65536,!1),P.threadInitTLS()},Fn=e=>{if(e instanceof kt||e=="unwind")return Ae;xe(),e instanceof WebAssembly.RuntimeError&&at()<=0&&A("Stack overflow detected. You can try increasing -sSTACK_SIZE (currently set to 65536)"),Tr(1,e)},Ba=()=>{if(!ir())try{if(w){Fe()&&it(Ae);return}Ir(Ae)}catch(e){Fn(e)}},Pn=e=>{if(Ce){A("user callback triggered after runtime exited or application aborted. Ignoring.");return}try{return e()}catch(r){Fn(r)}finally{Ba()}},Jr=e=>{if(!Nt){var r=Atomics.waitAsync((u(),S),e>>2,e);_(r.async),r.value.then(wr);var t=e+120;Atomics.store((u(),S),t>>2,1)}},wr=()=>{var e=Fe();e&&Pn(()=>{Jr(e),qn()})},za=(e,r)=>{if(e==r)setTimeout(wr);else if(w)postMessage({targetThread:e,cmd:"checkMailbox"});else{var t=P.pthreads[e];if(!t){A(`Cannot send message to thread with ID ${e}, unknown thread ID!`);return}t.postMessage({cmd:"checkMailbox"})}},Er=[],Ga=(e,r,t,n,i,o,s)=>{Er.length=0;for(var l=i>>3,d=i+n>>3;l<d;){var c;(u(),V)[l++]?c=(u(),V)[l++]:c=(u(),Re)[l++],Er.push(c)}_(!r);var v=Oo[e];_(!(e&&r)),_(v.length==Er.length,"Call args mismatch in _emscripten_receive_on_main_thread_js"),P.currentProxiedOperationCallerThread=t;var m=v(...Er);if(P.currentProxiedOperationCallerThread=0,o){m.then(h=>zn(o,s,h));return}return _(typeof m!="bigint"),m},Va=e=>{w?postMessage({cmd:"cleanupThread",thread:e}):Pt(e)},qa=e=>{C&&P.pthreads[e].ref()},Zr=[],Ka=e=>{var r=Zr.length;return Zr.push(e),r},Xa=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=kn((u(),y)[r+n*4>>2],`parameter ${n}`);return t},Ya=(e,r,t)=>{var n=[],i=e(n,t);return n.length&&((u(),y)[r>>2]=X.toHandle(n)),i},Ja={},Cn=e=>{var r=Ja[e];return r===void 0?G(e):r},Za=(e,r,t)=>{var n=8,[i,...o]=Xa(e,r),s=i.toWireType.bind(i),l=o.map(g=>g.readValueFromPointer.bind(g));e--;var d={toValue:X.toValue},c=l.map((g,E)=>{var k=`argFromPtr${E}`;return d[k]=g,`${k}(args${E?"+"+E*n:""})`}),v;switch(t){case 0:v="toValue(handle)";break;case 2:v="new (toValue(handle))";break;case 3:v="";break;case 1:d.getStringOrSymbol=Cn,v="toValue(handle)[getStringOrSymbol(methodName)]";break}v+=`(${c})`,i.isVoid||(d.toReturnWire=s,d.emval_returnValue=Ya,v=`return emval_returnValue(toReturnWire, destructorsRef, ${v})`),v=`return function (handle, methodName, destructorsRef, args) {
|
|
20
|
+
${v}
|
|
21
|
+
}`;var m=new Function(Object.keys(d),v)(...Object.values(d)),h=`methodCaller<(${o.map(g=>g.name)}) => ${i.name}>`;return Ka(mr(h,m))},Qa=(e,r)=>(e=X.toValue(e),r=X.toValue(r),X.toHandle(e[r])),eo=e=>{e>9&&(ae[e+1]+=1)},An=(e,r,t,n,i)=>Zr[e](r,t,n,i),ro=(e,r,t,n,i)=>An(e,r,t,n,i),to=e=>X.toHandle(Cn(e)),no=e=>{var r=X.toValue(e);dr(r),Xr(e)},io=(e,r,t,n)=>{var i=new Date().getFullYear(),o=new Date(i,0,1),s=new Date(i,6,1),l=o.getTimezoneOffset(),d=s.getTimezoneOffset(),c=Math.max(l,d);(u(),y)[e>>2]=c*60,(u(),S)[r>>2]=+(l!=d);var v=g=>{var E=g>=0?"-":"+",k=Math.abs(g),R=String(Math.floor(k/60)).padStart(2,"0"),D=String(k%60).padStart(2,"0");return`UTC${E}${R}${D}`},m=v(l),h=v(d);_(m),_(h),_(be(m)<=16,`timezone name truncated to fit in TZNAME_MAX (${m})`),_(be(h)<=16,`timezone name truncated to fit in TZNAME_MAX (${h})`),d<l?(he(m,t,17),he(h,n,17)):(he(m,n,17),he(h,t,17))},On=()=>performance.timeOrigin+performance.now(),ao=()=>Date.now(),oo=1,so=e=>e>=0&&e<=3,lo=9007199254740992,uo=-9007199254740992,Rn=e=>e<uo||e>lo?NaN:Number(e);function co(e,r,t){if(r=Rn(r),!so(e))return 28;var n;if(e===0)n=ao();else if(oo)n=On();else return 52;var i=Math.round(n*1e3*1e3);return(u(),V)[t>>3]=BigInt(i),0}var fo=()=>{C||L||Ee("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},_o=e=>A(le(e)),vo=()=>{nr+=1},mo=()=>{throw vo(),"unwind"},ho=()=>2147483648,po=(e,r)=>(_(r,"alignment argument is required"),Math.ceil(e/r)*r),go=e=>{var r=se.buffer.byteLength,t=(e-r+65535)/65536|0;try{return se.grow(t),rr(),1}catch(n){A(`growMemory: Attempted to grow heap from ${r} bytes to ${e} bytes, but got error: ${n}`)}},yo=e=>{var r=(u(),K).length;if(e>>>=0,e<=r)return!1;var t=ho();if(e>t)return A(`Cannot enlarge memory, requested ${e} bytes, but the limit is ${t} bytes!`),!1;for(var n=1;n<=4;n*=2){var i=r*(1+.2/n);i=Math.min(i,e+100663296);var o=Math.min(t,po(Math.max(e,i),65536)),s=go(o);if(s)return!0}return A(`Failed to grow the heap from ${r} bytes to ${o} bytes, not enough memory!`),!1},Qr={},wo=()=>kr||"./this.program",Ge=()=>{if(!Ge.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:wo()};for(var t in Qr)Qr[t]===void 0?delete r[t]:r[t]=Qr[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ge.strings=n}return Ge.strings};function Dn(e,r){if(w)return B(15,0,1,e,r);var t=0,n=0;for(var i of Ge()){var o=r+t;(u(),y)[e+n>>2]=o,t+=he(i,o,1/0)+1,n+=4}return 0}function $n(e,r){if(w)return B(16,0,1,e,r);var t=Ge();(u(),y)[e>>2]=t.length;var n=0;for(var i of t)n+=be(i)+1;return(u(),y)[r>>2]=n,0}function In(e){if(w)return B(17,0,1,e);try{var r=z.getStreamFromFD(e);return a.close(r),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var Eo=(e,r,t,n)=>{for(var i=0,o=0;o<t;o++){var s=(u(),y)[r>>2],l=(u(),y)[r+4>>2];r+=8;var d=a.read(e,(u(),W),s,l,n);if(d<0)return-1;if(i+=d,d<l)break;typeof n<"u"&&(n+=d)}return i};function Nn(e,r,t,n){if(w)return B(18,0,1,e,r,t,n);try{var i=z.getStreamFromFD(e),o=Eo(i,r,t);return(u(),y)[n>>2]=o,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Mn(e,r,t,n){if(w)return B(19,0,1,e,r,t,n);r=Rn(r);try{if(isNaN(r))return 22;var i=z.getStreamFromFD(e);return a.llseek(i,r,t),(u(),V)[n>>3]=BigInt(i.position),i.getdents&&r===0&&t===0&&(i.getdents=null),0}catch(o){if(typeof a>"u"||o.name!=="ErrnoError")throw o;return o.errno}}var bo=(e,r,t,n)=>{for(var i=0,o=0;o<t;o++){var s=(u(),y)[r>>2],l=(u(),y)[r+4>>2];r+=8;var d=a.write(e,(u(),W),s,l,n);if(d<0)return-1;if(i+=d,d<l)break;typeof n<"u"&&(n+=d)}return i};function Wn(e,r,t,n){if(w)return B(20,0,1,e,r,t,n);try{var i=z.getStreamFromFD(e),o=bo(i,r,t);return(u(),y)[n>>2]=o,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}function Ln(e,r,t,n){if(w)return B(21,0,1,e,r,t,n);var i=[],o=null,s=0,l=0,d=0,c=0,v=0,m=0,h,g;function E(k,R,D,x,U,ee){var ne,j,re,Ke;return j=k===10?28:16,U=k===10?qt(U):Br(U),ne=Ve(j),Ke=nn(ne,k,U,ee),_(!Ke),re=Ve(32),(u(),S)[re+4>>2]=k,(u(),S)[re+8>>2]=R,(u(),S)[re+12>>2]=D,(u(),y)[re+24>>2]=x,(u(),y)[re+20>>2]=ne,k===10?(u(),S)[re+16>>2]=28:(u(),S)[re+16>>2]=16,(u(),S)[re+28>>2]=0,re}if(t&&(d=(u(),S)[t>>2],c=(u(),S)[t+4>>2],v=(u(),S)[t+8>>2],m=(u(),S)[t+12>>2]),v&&!m&&(m=v===2?17:6),!v&&m&&(v=m===17?2:1),m===0&&(m=6),v===0&&(v=1),!e&&!r)return-2;if(d&-1088||t!==0&&(u(),S)[t>>2]&2&&!e)return-1;if(d&32)return-2;if(v!==0&&v!==1&&v!==2)return-7;if(c!==0&&c!==2&&c!==10)return-6;if(r&&(r=le(r),l=parseInt(r,10),isNaN(l)))return d&1024?-2:-8;if(!e)return c===0&&(c=2),(d&1)===0&&(c===2?s=qe(2130706433):s=[0,0,0,qe(1)]),h=E(c,v,m,null,s,l),(u(),y)[n>>2]=h,0;if(e=le(e),s=or(e),s!==null)if(c===0||c===2)c=2;else if(c===10&&d&8)s=[0,0,qe(65535),s],c=10;else return-2;else if(s=zr(e),s!==null)if(c===0||c===10)c=10;else return-2;return s!=null?(h=E(c,v,m,e,s,l),(u(),y)[n>>2]=h,0):d&4?-2:(e=de.lookup_name(e),s=or(e),c===0?c=2:c===10&&(s=[0,0,qe(65535),s]),h=E(c,v,m,null,s,l),(u(),y)[n>>2]=h,0)}var So=(e,r)=>Mr((u(),K).subarray(e,e+r)),ko=(...e)=>a.createPath(...e),To=(...e)=>a.unlink(...e),Fo=(...e)=>a.createLazyFile(...e),Po=(...e)=>a.createDevice(...e);P.init(),a.createPreloadedFile=Ui,a.preloadFile=jr,a.staticInit(),C&&b.staticInit(),ea(),la(),_(ae.length===10);{if(_i(),f.noExitRuntime&&(Nr=f.noExitRuntime),f.preloadPlugins&&(Vt=f.preloadPlugins),f.print&&(_e=f.print),f.printErr&&(A=f.printErr),f.wasmBinary&&(Le=f.wasmBinary),Ro(),f.arguments&&(ct=f.arguments),f.thisProgram&&(kr=f.thisProgram),_(typeof f.memoryInitializerPrefixURL>"u","Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead"),_(typeof f.pthreadMainPrefixURL>"u","Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead"),_(typeof f.cdInitializerPrefixURL>"u","Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead"),_(typeof f.filePackagePrefixURL>"u","Module.filePackagePrefixURL option was removed, use Module.locateFile instead"),_(typeof f.read>"u","Module.read option was removed"),_(typeof f.readAsync>"u","Module.readAsync option was removed (modify readAsync in JS)"),_(typeof f.readBinary>"u","Module.readBinary option was removed (modify readBinary in JS)"),_(typeof f.setWindowTitle>"u","Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)"),_(typeof f.TOTAL_MEMORY>"u","Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY"),_(typeof f.ENVIRONMENT>"u","Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)"),_(typeof f.STACK_SIZE>"u","STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time"),f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.shift()();er("preInit")}f.addRunDependency=$r,f.removeRunDependency=Dr,f.FS_preloadFile=jr,f.FS_unlink=To,f.FS_createPath=ko,f.FS_createDevice=Po,f.FS=a,f.FS_createDataFile=Gt,f.FS_createLazyFile=Fo;var Co=["writeI53ToI64","writeI53ToI64Clamped","writeI53ToI64Signaling","writeI53ToU64Clamped","writeI53ToU64Signaling","readI53FromI64","readI53FromU64","convertI32PairToI53","convertI32PairToI53Checked","convertU32PairToI53","getTempRet0","setTempRet0","withStackSave","readEmAsmArgs","jstoi_q","autoResumeAudioContext","getDynCaller","dynCall","runtimeKeepalivePop","asmjsMangle","HandleAllocator","addOnInit","addOnPostCtor","addOnPreMain","addOnExit","STACK_SIZE","STACK_ALIGN","POINTER_SIZE","ASSERTIONS","ccall","cwrap","convertJsFunctionToWasm","getEmptyTableSlot","updateTableMap","getFunctionAddress","addFunction","removeFunction","intArrayToString","stringToAscii","stringToNewUTF8","stringToUTF8OnStack","writeArrayToMemory","registerKeyEventCallback","maybeCStringToJsString","findEventTarget","getBoundingClientRect","fillMouseEventData","registerMouseEventCallback","registerWheelEventCallback","registerUiEventCallback","registerFocusEventCallback","fillDeviceOrientationEventData","registerDeviceOrientationEventCallback","fillDeviceMotionEventData","registerDeviceMotionEventCallback","screenOrientation","fillOrientationChangeEventData","registerOrientationChangeEventCallback","fillFullscreenChangeEventData","registerFullscreenChangeEventCallback","JSEvents_requestFullscreen","JSEvents_resizeCanvasForFullscreen","registerRestoreOldStyle","hideEverythingExceptGivenElement","restoreHiddenElements","setLetterbox","softFullscreenResizeWebGLRenderTarget","doRequestFullscreen","fillPointerlockChangeEventData","registerPointerlockChangeEventCallback","registerPointerlockErrorEventCallback","requestPointerLock","fillVisibilityChangeEventData","registerVisibilityChangeEventCallback","registerTouchEventCallback","fillGamepadEventData","registerGamepadEventCallback","registerBeforeUnloadEventCallback","fillBatteryEventData","registerBatteryEventCallback","setCanvasElementSizeCallingThread","setCanvasElementSizeMainThread","setCanvasElementSize","getCanvasSizeCallingThread","getCanvasSizeMainThread","getCanvasElementSize","jsStackTrace","getCallstack","convertPCtoSourceLocation","wasiRightsToMuslOFlags","wasiOFlagsToMuslOFlags","safeSetTimeout","setImmediateWrapped","safeRequestAnimationFrame","clearImmediateWrapped","registerPostMainLoop","registerPreMainLoop","getPromise","makePromise","idsToPromises","makePromiseCallback","findMatchingCatch","incrementUncaughtExceptionCount","decrementUncaughtExceptionCount","Browser_asyncPrepareDataCounter","isLeapYear","ydayFromDate","arraySum","addDays","FS_mkdirTree","_setNetworkCallback","heapObjectForWebGLType","toTypedArrayIndex","webgl_enable_ANGLE_instanced_arrays","webgl_enable_OES_vertex_array_object","webgl_enable_WEBGL_draw_buffers","webgl_enable_WEBGL_multi_draw","webgl_enable_EXT_polygon_offset_clamp","webgl_enable_EXT_clip_control","webgl_enable_WEBGL_polygon_mode","emscriptenWebGLGet","computeUnpackAlignedImageSize","colorChannelsInGlTextureFormat","emscriptenWebGLGetTexPixelData","emscriptenWebGLGetUniform","webglGetUniformLocation","webglPrepareUniformLocationsBeforeFirstUse","webglGetLeftBracePos","emscriptenWebGLGetVertexAttrib","__glGetActiveAttribOrUniform","writeGLArray","emscripten_webgl_destroy_context_before_on_calling_thread","registerWebGlEventCallback","runAndAbortIfError","ALLOC_NORMAL","ALLOC_STACK","allocate","writeStringToMemory","writeAsciiToMemory","allocateUTF8","allocateUTF8OnStack","demangle","stackTrace","getNativeTypeSize","getFunctionArgsName","createJsInvokerSignature","PureVirtualError","registerInheritedInstance","unregisterInheritedInstance","getInheritedInstanceCount","getLiveInheritedInstances","setDelayFunction","count_emval_handles"];Co.forEach(ci);var Ao=["run","out","err","callMain","abort","wasmExports","writeStackCookie","checkStackCookie","INT53_MAX","INT53_MIN","bigintToI53Checked","HEAP8","HEAP16","HEAPU16","HEAP32","HEAPU32","HEAPF32","HEAPF64","HEAP64","HEAPU64","stackSave","stackRestore","stackAlloc","createNamedFunction","ptrToString","zeroMemory","exitJS","getHeapMax","growMemory","ENV","ERRNO_CODES","strError","inetPton4","inetNtop4","inetPton6","inetNtop6","readSockaddr","writeSockaddr","DNS","Protocols","Sockets","timers","warnOnce","readEmAsmArgsArray","getExecutableName","handleException","keepRuntimeAlive","runtimeKeepalivePush","callUserCallback","maybeExit","asyncLoad","alignMemory","mmapAlloc","wasmTable","wasmMemory","getUniqueRunDependency","noExitRuntime","addOnPreRun","addOnPostRun","freeTableIndexes","functionsInTableMap","setValue","getValue","PATH","PATH_FS","UTF8Decoder","UTF8ArrayToString","UTF8ToString","stringToUTF8Array","stringToUTF8","lengthBytesUTF8","intArrayFromString","AsciiToString","UTF16Decoder","UTF16ToString","stringToUTF16","lengthBytesUTF16","UTF32ToString","stringToUTF32","lengthBytesUTF32","JSEvents","specialHTMLTargets","findCanvasEventTarget","currentFullscreenStrategy","restoreOldWindowedStyle","UNWIND_CACHE","ExitStatus","getEnvStrings","checkWasiClock","doReadv","doWritev","initRandomFill","randomFill","emSetImmediate","emClearImmediate_deps","emClearImmediate","promiseMap","uncaughtExceptionCount","exceptionCaught","ExceptionInfo","Browser","requestFullscreen","requestFullScreen","setCanvasSize","getUserMedia","createContext","getPreloadedImageData__data","wget","MONTH_DAYS_REGULAR","MONTH_DAYS_LEAP","MONTH_DAYS_REGULAR_CUMULATIVE","MONTH_DAYS_LEAP_CUMULATIVE","SYSCALLS","getSocketFromFD","getSocketAddress","preloadPlugins","FS_createPreloadedFile","FS_modeStringToFlags","FS_getMode","FS_fileDataToTypedArray","FS_stdin_getChar_buffer","FS_stdin_getChar","FS_readFile","FS_root","FS_mounts","FS_devices","FS_streams","FS_nextInode","FS_nameTable","FS_currentPath","FS_initialized","FS_ignorePermissions","FS_filesystems","FS_syncFSRequests","FS_lookupPath","FS_getPath","FS_hashName","FS_hashAddNode","FS_hashRemoveNode","FS_lookupNode","FS_createNode","FS_destroyNode","FS_isRoot","FS_isMountpoint","FS_isFile","FS_isDir","FS_isLink","FS_isChrdev","FS_isBlkdev","FS_isFIFO","FS_isSocket","FS_flagsToPermissionString","FS_nodePermissions","FS_mayLookup","FS_mayCreate","FS_mayDelete","FS_mayOpen","FS_checkOpExists","FS_nextfd","FS_getStreamChecked","FS_getStream","FS_createStream","FS_closeStream","FS_dupStream","FS_doSetAttr","FS_chrdev_stream_ops","FS_major","FS_minor","FS_makedev","FS_registerDevice","FS_getDevice","FS_getMounts","FS_syncfs","FS_mount","FS_unmount","FS_lookup","FS_mknod","FS_statfs","FS_statfsStream","FS_statfsNode","FS_create","FS_mkdir","FS_mkdev","FS_symlink","FS_rename","FS_rmdir","FS_readdir","FS_readlink","FS_stat","FS_fstat","FS_lstat","FS_doChmod","FS_chmod","FS_lchmod","FS_fchmod","FS_doChown","FS_chown","FS_lchown","FS_fchown","FS_doTruncate","FS_truncate","FS_ftruncate","FS_utime","FS_open","FS_close","FS_isClosed","FS_llseek","FS_read","FS_write","FS_mmap","FS_msync","FS_ioctl","FS_writeFile","FS_cwd","FS_chdir","FS_createDefaultDirectories","FS_createDefaultDevices","FS_createSpecialDirectories","FS_createStandardStreams","FS_staticInit","FS_init","FS_quit","FS_findObject","FS_analyzePath","FS_createFile","FS_forceLoadFile","MEMFS","TTY","PIPEFS","SOCKFS","tempFixedLengthArray","miniTempWebGLFloatBuffers","miniTempWebGLIntBuffers","GL","AL","GLUT","EGL","GLEW","IDBStore","SDL","SDL_gfx","waitAsyncPolyfilled","print","printErr","jstoi_s","PThread","terminateWorker","cleanupThread","registerTLSInit","spawnThread","exitOnMainThread","proxyToMainThread","proxiedJSCallArgs","invokeEntryPoint","checkMailbox","InternalError","BindingError","throwInternalError","throwBindingError","registeredTypes","awaitingDependencies","typeDependencies","tupleRegistrations","structRegistrations","sharedRegisterType","whenDependentTypesAreResolved","getTypeName","getFunctionName","heap32VectorToArray","requireRegisteredType","usesDestructorStack","checkArgCount","getEnumValueType","getRequiredArgCount","createJsInvoker","UnboundTypeError","EmValType","EmValOptionalType","throwUnboundTypeError","ensureOverloadTable","exposePublicSymbol","replacePublicSymbol","embindRepr","registeredInstances","getBasestPointer","getInheritedInstance","registeredPointers","registerType","integerReadValueFromPointer","enumReadValueFromPointer","floatReadValueFromPointer","assertIntegerRange","readPointer","installIndexedIterator","runDestructors","craftInvokerFunction","embind__requireFunction","genericPointerToWireType","constNoSmartPtrRawPointerToWireType","nonConstNoSmartPtrRawPointerToWireType","init_RegisteredPointer","RegisteredPointer","RegisteredPointer_fromWireType","runDestructor","releaseClassHandle","finalizationRegistry","detachFinalizer_deps","detachFinalizer","attachFinalizer","makeClassHandle","init_ClassHandle","ClassHandle","throwInstanceAlreadyDeleted","deletionQueue","flushPendingDeletes","delayFunction","RegisteredClass","shallowCopyInternalPointer","downcastPointer","upcastPointer","validateThis","char_0","char_9","makeLegalFunctionName","emval_freelist","emval_handles","emval_symbols","getStringOrSymbol","Emval","emval_returnValue","emval_lookupTypes","emval_methodCallers","emval_addMethodCaller","NODEFS"];Ao.forEach(pt);var Oo=[$t,It,jt,Xt,Yt,Jt,Zt,Qt,en,rn,an,on,sn,ln,dn,Dn,$n,In,Nn,Mn,Wn,Ln];function Ro(){ge("fetchSettings"),ge("logReadFiles"),ge("loadSplitModule"),ge("onMalloc"),ge("onRealloc"),ge("onFree"),ge("onSbrkGrow")}function Do(){var e,r,t=new Promise(function(n,i){e=n,r=i});return X.toHandle({promise:t,resolve:e,reject:r})}function $o(e,r){X.toValue(e)(X.toValue(r))}function Io(e,r){X.toValue(e)(new Error(le(r)))}function No(e,r,t){var n=(u(),K).subarray(e,e+r*t);return globalThis._e57Finalizer||(globalThis._e57Finalizer=new FinalizationRegistry(function(i){ue(i)})),globalThis._e57Finalizer.register(n,e),X.toHandle(n)}var xn=N("___getTypeName"),Un=N("__embind_initialize_bindings"),Ve=f._malloc=N("_malloc"),ue=f._free=N("_free"),Fe=N("_pthread_self"),jn=N("_strerror"),Mo=N("__emscripten_tls_init"),et=N("__emscripten_thread_init"),Hn=N("___set_thread_state"),Bn=N("__emscripten_thread_crashed"),rt=N("_fflush"),qe=N("_htonl"),br=N("_htons"),tt=N("_emscripten_stack_get_end"),Wo=N("_emscripten_stack_get_base"),nt=N("_ntohs"),zn=N("__emscripten_run_js_on_main_thread_done"),Gn=N("__emscripten_run_js_on_main_thread"),Vn=N("__emscripten_thread_free_data"),it=N("__emscripten_thread_exit"),qn=N("__emscripten_check_mailbox"),Kn=N("_emscripten_stack_init"),Xn=N("_emscripten_stack_set_limits"),Lo=N("_emscripten_stack_get_free"),Yn=N("__emscripten_stack_restore"),Jn=N("__emscripten_stack_alloc"),at=N("_emscripten_stack_get_current"),xo=N("__indirect_function_table"),ot=N("wasmTable");function Uo(e){_(typeof e.__getTypeName<"u","missing Wasm export: __getTypeName"),_(typeof e._embind_initialize_bindings<"u","missing Wasm export: _embind_initialize_bindings"),_(typeof e.malloc<"u","missing Wasm export: malloc"),_(typeof e.free<"u","missing Wasm export: free"),_(typeof e.pthread_self<"u","missing Wasm export: pthread_self"),_(typeof e.strerror<"u","missing Wasm export: strerror"),_(typeof e._emscripten_tls_init<"u","missing Wasm export: _emscripten_tls_init"),_(typeof e._emscripten_thread_init<"u","missing Wasm export: _emscripten_thread_init"),_(typeof e.__set_thread_state<"u","missing Wasm export: __set_thread_state"),_(typeof e._emscripten_thread_crashed<"u","missing Wasm export: _emscripten_thread_crashed"),_(typeof e.fflush<"u","missing Wasm export: fflush"),_(typeof e.htonl<"u","missing Wasm export: htonl"),_(typeof e.htons<"u","missing Wasm export: htons"),_(typeof e.emscripten_stack_get_end<"u","missing Wasm export: emscripten_stack_get_end"),_(typeof e.emscripten_stack_get_base<"u","missing Wasm export: emscripten_stack_get_base"),_(typeof e.ntohs<"u","missing Wasm export: ntohs"),_(typeof e._emscripten_run_js_on_main_thread_done<"u","missing Wasm export: _emscripten_run_js_on_main_thread_done"),_(typeof e._emscripten_run_js_on_main_thread<"u","missing Wasm export: _emscripten_run_js_on_main_thread"),_(typeof e._emscripten_thread_free_data<"u","missing Wasm export: _emscripten_thread_free_data"),_(typeof e._emscripten_thread_exit<"u","missing Wasm export: _emscripten_thread_exit"),_(typeof e._emscripten_check_mailbox<"u","missing Wasm export: _emscripten_check_mailbox"),_(typeof e.emscripten_stack_init<"u","missing Wasm export: emscripten_stack_init"),_(typeof e.emscripten_stack_set_limits<"u","missing Wasm export: emscripten_stack_set_limits"),_(typeof e.emscripten_stack_get_free<"u","missing Wasm export: emscripten_stack_get_free"),_(typeof e._emscripten_stack_restore<"u","missing Wasm export: _emscripten_stack_restore"),_(typeof e._emscripten_stack_alloc<"u","missing Wasm export: _emscripten_stack_alloc"),_(typeof e.emscripten_stack_get_current<"u","missing Wasm export: emscripten_stack_get_current"),_(typeof e.__indirect_function_table<"u","missing Wasm export: __indirect_function_table"),xn=q("__getTypeName",1),Un=q("_embind_initialize_bindings",0),Ve=f._malloc=q("malloc",1),ue=f._free=q("free",1),Fe=e.pthread_self,jn=q("strerror",1),Mo=q("_emscripten_tls_init",0),et=q("_emscripten_thread_init",6),Hn=q("__set_thread_state",4),Bn=q("_emscripten_thread_crashed",0),rt=q("fflush",1),qe=q("htonl",1),br=q("htons",1),tt=e.emscripten_stack_get_end,Wo=e.emscripten_stack_get_base,nt=q("ntohs",1),zn=q("_emscripten_run_js_on_main_thread_done",3),Gn=q("_emscripten_run_js_on_main_thread",5),Vn=q("_emscripten_thread_free_data",1),it=q("_emscripten_thread_exit",1),qn=q("_emscripten_check_mailbox",0),Kn=e.emscripten_stack_init,Xn=e.emscripten_stack_set_limits,Lo=e.emscripten_stack_get_free,Yn=e._emscripten_stack_restore,Jn=e._emscripten_stack_alloc,at=e.emscripten_stack_get_current,xo=ot=e.__indirect_function_table}var st;function jo(){st={__assert_fail:Ci,__cxa_throw:Ri,__pthread_create_js:Ht,__syscall_connect:Xt,__syscall_dup:Yt,__syscall_fcntl64:Jt,__syscall_getcwd:Zt,__syscall_ioctl:Qt,__syscall_openat:en,__syscall_readlinkat:rn,__syscall_recvfrom:an,__syscall_rmdir:on,__syscall_sendto:sn,__syscall_socket:ln,__syscall_unlinkat:dn,_abort_js:Hi,_embind_finalize_value_object:zi,_embind_register_bigint:Vi,_embind_register_bool:qi,_embind_register_class:ua,_embind_register_class_class_function:va,_embind_register_class_constructor:ma,_embind_register_class_function:ha,_embind_register_class_property:pa,_embind_register_emval:ga,_embind_register_enum:wa,_embind_register_enum_value:Ea,_embind_register_float:Sa,_embind_register_function:ka,_embind_register_integer:Ta,_embind_register_iterable:Pa,_embind_register_memory_view:Ca,_embind_register_optional:Oa,_embind_register_std_string:Ra,_embind_register_std_wstring:La,_embind_register_value_object:xa,_embind_register_value_object_field:Ua,_embind_register_void:ja,_emjs_array_view:No,_emjs_call_reject:Io,_emjs_call_resolve:$o,_emjs_make_deferred:Do,_emscripten_init_main_thread_js:Ha,_emscripten_notify_mailbox_postmessage:za,_emscripten_receive_on_main_thread_js:Ga,_emscripten_thread_cleanup:Va,_emscripten_thread_mailbox_await:Jr,_emscripten_thread_set_strongref:qa,_emval_create_invoker:Za,_emval_decref:Xr,_emval_get_property:Qa,_emval_incref:eo,_emval_invoke:An,_emval_invoke_i64:ro,_emval_new_cstring:to,_emval_run_destructors:no,_tzset_js:io,clock_time_get:co,emscripten_check_blocking_allowed:fo,emscripten_err:_o,emscripten_exit_with_live_runtime:mo,emscripten_get_now:On,emscripten_resize_heap:yo,environ_get:Dn,environ_sizes_get:$n,exit:Ir,fd_close:In,fd_read:Nn,fd_seek:Mn,fd_write:Wn,getaddrinfo:Ln,memory:se,random_get:So}}var Zn;function Ho(){_(!w),Kn(),mt()}function Sr(){if(we>0){Ue=Sr;return}if(w){Cr?.(f),Et();return}if(Ho(),vi(),we>0){Ue=Sr;return}function e(){_(!Zn),Zn=!0,f.calledRun=!0,!Ce&&(Et(),Cr?.(f),f.onRuntimeInitialized?.(),er("onRuntimeInitialized"),_(!f._main,'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'),mi())}f.setStatus?(f.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>f.setStatus(""),1),e()},1)):e(),xe()}function Bo(){var e=_e,r=A,t=!1;_e=A=d=>{t=!0};try{rt(0);for(var n of["stdout","stderr"]){var i=a.analyzePath("/dev/"+n);if(!i)return;var o=i.object,s=o.rdev,l=ce.ttys[s];l?.output?.length&&(t=!0)}}catch{}_e=e,A=r,t&&Ee("stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.")}var Pe;w||(Pe=await St(),Sr()),Oe?p=f:p=new Promise((e,r)=>{Cr=e,Ar=r});for(let e of Object.keys(f))e in te||Object.defineProperty(te,e,{configurable:!0,get(){H(`Access to module property ('${e}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)}});return p}var ei=Qn,ri=globalThis.name?.startsWith("em-pthread"),zo=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";zo&&(ri=(await import("node:worker_threads")).workerData==="em-pthread");ri&&Qn();var Y=class te{static LibE57=null;static RootDir="/root ";static Init(){return te.LibE57!==null?Promise.resolve():ei().then(function(p){p.FS.mkdir(te.RootDir),p.FS.mount(p.FS.filesystems.NODEFS,{root:"/"},te.RootDir),te.LibE57=p})}};import lt from"path";import Go from"fs";var dt=class{constructor(p,f){this.e57Reader=p,this.scanIdx=f}GetHeader(){return this.e57Reader.GetData3DHeader(this.scanIdx)}ReadScan(p=!0){var f=this.GetHeader(),M=f.pointCount;return this.ReadPoints(M,p)}ReadScanSync(p=!0){let f=Number(this.GetHeader().pointCount);return this.ReadPointsSync(f,p)}ReadPoints(p,f=!0){return this.e57Reader.ReadScan(this.scanIdx,p,f)}ReadPointsSync(p,f=!0){return this.e57Reader.ReadScanSync(this.scanIdx,p,f)}ScanPoints(p,f,M=!0){let L=Number(this.GetHeader().pointCount),C=Math.ceil(L/p);if(f){for(let w=0;w<C;w++)f(this.ReadPointsSync(p,M));return}let fe=[];for(let w=0;w<C;w++)fe.push(this.ReadPointsSync(p,M));return fe}},ut=class{constructor(p,f){this._e57Reader=p,this._imageIdx=f}GetHeader(){return this._e57Reader.GetImage2DHeader(this._imageIdx)}ReadImage(){return this._e57Reader.ReadImage(this._imageIdx)}ReadImageSync(){return this._e57Reader.ReadImageSync(this._imageIdx)}ToBase64(){return this.ReadImage().then(p=>Buffer.from(p).toString("base64"))}Extension(){switch(this.GetHeader().imageType){case Y.LibE57.Image2DType.ImageJPEG:return".jpeg";case Y.LibE57.Image2DType.ImagePNG:return".png";case Y.LibE57.Image2DType.ImageMaskPNG:return".png";case Y.LibE57.Image2DType.E57_JPEG_IMAGE:return".jpeg";case Y.LibE57.Image2DType.E57_PNG_IMAGE:return".png";case Y.LibE57.Image2DType.E57_PNG_IMAGE_MASK:return".png";default:return".jpg"}}Save(p){let f=this.Extension(),M=p.replace(lt.extname(p),f);return this.ReadImage().then(L=>Go.writeFile(M,L,C=>{if(C)throw C}))}},ti=class{constructor(p){let f=lt.resolve(p),M=lt.join(Y.RootDir,f);this.reader=new Y.LibE57.E57Reader(M);var L=this.GetData3DCount();this.scans=new Array(L);for(var C=0;C<L;C++)this.scans[C]=new dt(this.reader,C);var fe=this.GetImage2DCount();this.images=new Array(fe);for(var w=0;w<fe;w++)this.images[w]=new ut(this.reader,w)}GetHeader(){return this.reader.GetHeader()}GetData3DCount(){return Number(this.reader.GetData3DCount())}GetImage2DCount(){return Number(this.reader.GetImage2DCount())}GetScan(p){return this.scans[p]}GetImage(p){return this.images[p]}};import ni from"path";import oi from"fs";import Xe from"sharp";var ii=class{constructor(p,f,M){this._imgPath=p,this._imgType=f,this._imgProjection=M,this._imageHeader=new Y.LibE57.ImageHeader}getPath(){return this._imgPath}setPath(p){this._imgPath=p}getType(){return this._imgType}setType(p){this._imgType=p}getProjection(){return this._imgProjection}setProjection(p){this._imgProjection=p}getMetadata(){return Xe(this._imgPath).metadata()}async getDimensions(){let p=await Xe(this._imgPath).metadata();return[p.width,p.height]}async getWidth(){return(await Xe(this._imgPath).metadata()).width}async getHeight(){return(await Xe(this._imgPath).metadata()).height}getPose(){return this._imageHeader.pose}setPose(p){this._imageHeader.pose=p}getName(){return this._imageHeader.name}setName(p){this._imageHeader.name=p}getGuid(){return this._imageHeader.guid}setGuid(p){this._imageHeader.guid=p}getHeader(){return this._imageHeader}setHeader(p){this._imageHeader=p}async getBuffer(){let p=await oi.promises.readFile(this.getPath());return new Uint8Array(p)}setTrasnlation(p,f,M){this._imageHeader.pose.translation.x=p,this._imageHeader.pose.translation.y=f,this._imageHeader.pose.translation.z=M}setRotation(p,f,M,L){this._imageHeader.pose.rotation.w=p,this._imageHeader.pose.rotation.x=f,this._imageHeader.pose.rotation.y=M,this._imageHeader.pose.rotation.z=L}},ai=class{constructor(p){let f=ni.resolve(p),M=ni.join(Y.RootDir,f);this.writer=new Y.LibE57.E57Writer(M)}AddImageSync(p,f,M){let L=oi.readFileSync(p.getPath()),C=new Uint8Array(L);return Number(this.writer.AddImageSync(p.getHeader(),p.getType(),p.getProjection(),0,C,C.length,f,M))}async AddImage(p){let[f,M]=await Promise.all([p.getBuffer(),Xe(p.getPath()).metadata()]),L=new Uint8Array(f);return this.writer.AddImage(p.getHeader(),p.getType(),p.getProjection(),0,L,L.length,M.width,M.height).then(Number)}AddScanSync(p,f){return Number(this.writer.AddScanSync(p,f))}AddScan(p,f){return this.writer.AddScan(p,f).then(Number)}Close(){this.writer.Close()}};export{Y as E57,ti as E57Reader,ut as E57ReaderImage,dt as E57ReaderScan,ai as E57Writer,ii as E57WriterImage};
|