@keeratita/heic-converter 0.2.0 → 0.3.0
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 +49 -14
- package/dist/heic-decoder.wasm +0 -0
- package/dist/index.d.mts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +6 -6
- package/dist/index.mjs +6 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @keeratita/heic-converter
|
|
2
2
|
|
|
3
|
-
A modern, lightweight TypeScript library to convert `.heic` and `.heif` images to standard web formats (JPEG, PNG, SVG) client-side in the browser or on the backend in Node.js.
|
|
3
|
+
A modern, lightweight TypeScript library to convert `.heic` and `.heif` images to standard web formats (JPEG, PNG, WebP, SVG) client-side in the browser or on the backend in Node.js.
|
|
4
4
|
|
|
5
5
|
Designed specifically for environments with strict **Content Security Policy (CSP)** rules, it is built with WebAssembly compiled **without** dynamic code execution (`eval()` or `new Function()`).
|
|
6
6
|
|
|
@@ -10,10 +10,10 @@ Designed specifically for environments with strict **Content Security Policy (CS
|
|
|
10
10
|
|
|
11
11
|
- 🔒 **CSP Compliant**: Emscripten glue code is compiled with `-s DYNAMIC_EXECUTION=0`. Safe to run without `'unsafe-eval'`.
|
|
12
12
|
- 🧩 **Dependency Injection Architecture**: Swap the decoder module easily by implementing a simple `IHeicDecoder` interface.
|
|
13
|
-
- ⚡ **Optimized Performance**:
|
|
13
|
+
- ⚡ **Optimized Performance**: A fresh decoder instance is created and released per conversion — memory is reclaimed promptly and concurrent conversions never share mutable WASM state.
|
|
14
14
|
- 🌐 **Isomorphic / Universal**: Runs in Node.js (decoding) and browser (decoding & canvas-based encoding).
|
|
15
15
|
- 📦 **No Bloat**: Zero external production dependencies. Small footprint.
|
|
16
|
-
- 🎨 **Format Support**: Convert to `jpeg` (with quality configuration), `png`, and `svg` (embedded lossless vector).
|
|
16
|
+
- 🎨 **Format Support**: Convert to `jpeg` (with quality configuration), `png`, `webp`, and `svg` (embedded lossless vector).
|
|
17
17
|
|
|
18
18
|
---
|
|
19
19
|
|
|
@@ -56,7 +56,32 @@ const imageUrl = URL.createObjectURL(jpegBlob);
|
|
|
56
56
|
document.querySelector('img').src = imageUrl;
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
### 2. Browser:
|
|
59
|
+
### 2. Browser: WebP Output
|
|
60
|
+
|
|
61
|
+
WebP offers excellent compression with quality configuration:
|
|
62
|
+
|
|
63
|
+
```typescript
|
|
64
|
+
import { convertHeic } from '@keeratita/heic-converter';
|
|
65
|
+
|
|
66
|
+
const webpBlob = await convertHeic(heicBlob, {
|
|
67
|
+
to: 'webp',
|
|
68
|
+
quality: 0.8,
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 3. Browser: SVG Output
|
|
73
|
+
|
|
74
|
+
SVG wraps the raster image as an embedded lossless PNG inside an SVG container:
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
import { convertHeic } from '@keeratita/heic-converter';
|
|
78
|
+
|
|
79
|
+
const svgBlob = await convertHeic(heicBlob, {
|
|
80
|
+
to: 'svg',
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 4. Browser: Serving and Locating WASM (Custom Assets Path)
|
|
60
85
|
|
|
61
86
|
By default, the library tries to fetch `heic-decoder.wasm` relative to the current module script path (`import.meta.url`).
|
|
62
87
|
|
|
@@ -93,7 +118,7 @@ const jpegBlob = await convertHeic(heicBlob, {
|
|
|
93
118
|
});
|
|
94
119
|
```
|
|
95
120
|
|
|
96
|
-
###
|
|
121
|
+
### 5. Node.js: Decoding Raw Pixel Data
|
|
97
122
|
|
|
98
123
|
Since Node.js lacks the native browser Canvas API, `convertHeic` (which relies on Canvas to encode raster formats) will throw an error on the backend.
|
|
99
124
|
|
|
@@ -110,11 +135,12 @@ async function convertNode() {
|
|
|
110
135
|
const decoder = new LibheifDecoder();
|
|
111
136
|
await decoder.initialize();
|
|
112
137
|
|
|
113
|
-
// Decodes to { width, height, data: Uint8ClampedArray (RGBA) }
|
|
138
|
+
// Decodes to { width, height, data: Uint8ClampedArray (RGBA) }.
|
|
139
|
+
// data is an independent copy — safe to use after decoder.free().
|
|
114
140
|
const { width, height, data } = await decoder.decode(heicData);
|
|
115
141
|
|
|
116
142
|
// Process raw pixels using sharp
|
|
117
|
-
await sharp(Buffer.from(data
|
|
143
|
+
await sharp(Buffer.from(data), {
|
|
118
144
|
raw: { width, height, channels: 4 },
|
|
119
145
|
})
|
|
120
146
|
.toFormat('jpeg')
|
|
@@ -125,7 +151,7 @@ async function convertNode() {
|
|
|
125
151
|
}
|
|
126
152
|
```
|
|
127
153
|
|
|
128
|
-
###
|
|
154
|
+
### 6. Progress Tracking (e.g. for Large Images)
|
|
129
155
|
|
|
130
156
|
For large images, you can pass an `onProgress` callback to track the conversion progress (0% to 100%):
|
|
131
157
|
|
|
@@ -168,8 +194,8 @@ Converts a HEIC image file to a standard web format.
|
|
|
168
194
|
|
|
169
195
|
- **`input`**: `Blob | File | ArrayBuffer | Uint8Array`
|
|
170
196
|
- **`options`**: (optional) `ConvertOptions`
|
|
171
|
-
- `to`: `'jpeg' | 'jpg' | 'png' | 'svg'` (Default: `'jpeg'`)
|
|
172
|
-
- `quality`: `number` (0.0 to 1.0,
|
|
197
|
+
- `to`: `'jpeg' | 'jpg' | 'png' | 'webp' | 'svg'` (Default: `'jpeg'`)
|
|
198
|
+
- `quality`: `number` (0.0 to 1.0, applicable to JPEG and WebP. Default: `0.92`)
|
|
173
199
|
- `decoder`: `IHeicDecoder` (Inject custom decoder instance)
|
|
174
200
|
- `onProgress`: `(percent: number) => void` (Optional callback, receives progress percentage from `0` to `100` during decoding)
|
|
175
201
|
- **Returns**: `Promise<Blob>`
|
|
@@ -182,13 +208,13 @@ The default WASM-based implementation of `IHeicDecoder`.
|
|
|
182
208
|
- `locateFile`: `(path: string, prefix: string) => string`
|
|
183
209
|
- `wasmBinary`: `ArrayBuffer`
|
|
184
210
|
- **Methods**:
|
|
185
|
-
- `initialize(): Promise<void>`: Loads and initializes the WASM wrapper.
|
|
186
|
-
- `decode(data: Uint8Array, onProgress?: (percent: number) => void): Promise<DecodedImage>`: Decodes the HEIC bytes to raw RGBA, with optional progress callback.
|
|
187
|
-
- `free(): void`: Releases allocated WebAssembly heap memory.
|
|
211
|
+
- `initialize(): Promise<void>`: Loads and initializes the WASM wrapper. Safe to call concurrently; the module loads at most once per instance.
|
|
212
|
+
- `decode(data: Uint8Array, onProgress?: (percent: number) => void): Promise<DecodedImage>`: Decodes the HEIC bytes to raw RGBA, with optional progress callback. Returns an independent copy of the pixel data — safe to use after `free()`.
|
|
213
|
+
- `free(): void`: Releases allocated WebAssembly heap memory. Idempotent.
|
|
188
214
|
|
|
189
215
|
### `freeSharedDecoder()`
|
|
190
216
|
|
|
191
|
-
|
|
217
|
+
Kept for **API compatibility**. Decoders are now created and released per conversion, so there is no shared instance to release — calling this function is a no-op.
|
|
192
218
|
|
|
193
219
|
```typescript
|
|
194
220
|
import { freeSharedDecoder } from '@keeratita/heic-converter';
|
|
@@ -225,6 +251,15 @@ npm run build
|
|
|
225
251
|
npm run test
|
|
226
252
|
```
|
|
227
253
|
|
|
254
|
+
### Run Browser E2E Tests
|
|
255
|
+
|
|
256
|
+
Real browser conversions against the CSP sandbox and the GitHub Pages demo (`docs/`):
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
npx playwright install chromium # one-time
|
|
260
|
+
npm run test:e2e
|
|
261
|
+
```
|
|
262
|
+
|
|
228
263
|
### Run Interactive CSP Sandbox
|
|
229
264
|
|
|
230
265
|
To test the converter in a local browser running under a strict Content Security Policy, start the sandbox server:
|
package/dist/heic-decoder.wasm
CHANGED
|
Binary file
|
package/dist/index.d.mts
CHANGED
|
@@ -19,7 +19,7 @@ interface IHeicDecoder {
|
|
|
19
19
|
*/
|
|
20
20
|
free(): void;
|
|
21
21
|
}
|
|
22
|
-
type ImageFormat = 'jpeg' | 'jpg' | 'png' | 'svg';
|
|
22
|
+
type ImageFormat = 'jpeg' | 'jpg' | 'png' | 'svg' | 'webp';
|
|
23
23
|
interface ConvertOptions {
|
|
24
24
|
/**
|
|
25
25
|
* Target format for the conversion.
|
|
@@ -28,7 +28,7 @@ interface ConvertOptions {
|
|
|
28
28
|
to?: ImageFormat;
|
|
29
29
|
/**
|
|
30
30
|
* Quality of the converted image (between 0.0 and 1.0).
|
|
31
|
-
*
|
|
31
|
+
* Applicable for 'jpeg', 'jpg', and 'webp' formats.
|
|
32
32
|
* @default 0.92
|
|
33
33
|
*/
|
|
34
34
|
quality?: number;
|
|
@@ -59,9 +59,15 @@ declare class LibheifDecoder implements IHeicDecoder {
|
|
|
59
59
|
private options?;
|
|
60
60
|
private module;
|
|
61
61
|
private decoderInstance;
|
|
62
|
+
/**
|
|
63
|
+
* Memoized module-loading promise so concurrent initialize()/decode() calls
|
|
64
|
+
* on the same instance never instantiate (or mutate) the module twice.
|
|
65
|
+
*/
|
|
66
|
+
private initPromise;
|
|
62
67
|
constructor(options?: LibheifDecoderOptions);
|
|
63
68
|
/**
|
|
64
69
|
* Initializes the WebAssembly module and instantiates the HEIC decoder.
|
|
70
|
+
* Safe to call concurrently: the module is loaded at most once per instance.
|
|
65
71
|
*/
|
|
66
72
|
initialize(): Promise<void>;
|
|
67
73
|
/**
|
|
@@ -72,17 +78,21 @@ declare class LibheifDecoder implements IHeicDecoder {
|
|
|
72
78
|
decode(data: Uint8Array, onProgress?: (percent: number) => void): Promise<DecodedImage>;
|
|
73
79
|
/**
|
|
74
80
|
* Cleans up the WebAssembly decoder instance and resources.
|
|
81
|
+
* Idempotent: safe to call multiple times. After free(), the instance must
|
|
82
|
+
* be re-initialized (createHeicDecoderModule runs again on the next call).
|
|
75
83
|
*/
|
|
76
84
|
free(): void;
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
/**
|
|
80
|
-
* Releases
|
|
81
|
-
*
|
|
88
|
+
* Releases any cached decoder resources.
|
|
89
|
+
*
|
|
90
|
+
* Decoders are now created and released per conversion, so there is no shared
|
|
91
|
+
* instance to free. This function is kept for API compatibility.
|
|
82
92
|
*/
|
|
83
93
|
declare function freeSharedDecoder(): void;
|
|
84
94
|
/**
|
|
85
|
-
* Converts HEIC image data to a standard web format (JPEG, PNG, or SVG).
|
|
95
|
+
* Converts HEIC image data to a standard web format (JPEG, PNG, WebP, or SVG).
|
|
86
96
|
*
|
|
87
97
|
* @param input HEIC image as a Blob, File, ArrayBuffer, or Uint8Array.
|
|
88
98
|
* @param options Conversion configuration options.
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ interface IHeicDecoder {
|
|
|
19
19
|
*/
|
|
20
20
|
free(): void;
|
|
21
21
|
}
|
|
22
|
-
type ImageFormat = 'jpeg' | 'jpg' | 'png' | 'svg';
|
|
22
|
+
type ImageFormat = 'jpeg' | 'jpg' | 'png' | 'svg' | 'webp';
|
|
23
23
|
interface ConvertOptions {
|
|
24
24
|
/**
|
|
25
25
|
* Target format for the conversion.
|
|
@@ -28,7 +28,7 @@ interface ConvertOptions {
|
|
|
28
28
|
to?: ImageFormat;
|
|
29
29
|
/**
|
|
30
30
|
* Quality of the converted image (between 0.0 and 1.0).
|
|
31
|
-
*
|
|
31
|
+
* Applicable for 'jpeg', 'jpg', and 'webp' formats.
|
|
32
32
|
* @default 0.92
|
|
33
33
|
*/
|
|
34
34
|
quality?: number;
|
|
@@ -59,9 +59,15 @@ declare class LibheifDecoder implements IHeicDecoder {
|
|
|
59
59
|
private options?;
|
|
60
60
|
private module;
|
|
61
61
|
private decoderInstance;
|
|
62
|
+
/**
|
|
63
|
+
* Memoized module-loading promise so concurrent initialize()/decode() calls
|
|
64
|
+
* on the same instance never instantiate (or mutate) the module twice.
|
|
65
|
+
*/
|
|
66
|
+
private initPromise;
|
|
62
67
|
constructor(options?: LibheifDecoderOptions);
|
|
63
68
|
/**
|
|
64
69
|
* Initializes the WebAssembly module and instantiates the HEIC decoder.
|
|
70
|
+
* Safe to call concurrently: the module is loaded at most once per instance.
|
|
65
71
|
*/
|
|
66
72
|
initialize(): Promise<void>;
|
|
67
73
|
/**
|
|
@@ -72,17 +78,21 @@ declare class LibheifDecoder implements IHeicDecoder {
|
|
|
72
78
|
decode(data: Uint8Array, onProgress?: (percent: number) => void): Promise<DecodedImage>;
|
|
73
79
|
/**
|
|
74
80
|
* Cleans up the WebAssembly decoder instance and resources.
|
|
81
|
+
* Idempotent: safe to call multiple times. After free(), the instance must
|
|
82
|
+
* be re-initialized (createHeicDecoderModule runs again on the next call).
|
|
75
83
|
*/
|
|
76
84
|
free(): void;
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
/**
|
|
80
|
-
* Releases
|
|
81
|
-
*
|
|
88
|
+
* Releases any cached decoder resources.
|
|
89
|
+
*
|
|
90
|
+
* Decoders are now created and released per conversion, so there is no shared
|
|
91
|
+
* instance to free. This function is kept for API compatibility.
|
|
82
92
|
*/
|
|
83
93
|
declare function freeSharedDecoder(): void;
|
|
84
94
|
/**
|
|
85
|
-
* Converts HEIC image data to a standard web format (JPEG, PNG, or SVG).
|
|
95
|
+
* Converts HEIC image data to a standard web format (JPEG, PNG, WebP, or SVG).
|
|
86
96
|
*
|
|
87
97
|
* @param input HEIC image as a Blob, File, ArrayBuffer, or Uint8Array.
|
|
88
98
|
* @param options Conversion configuration options.
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var Ea=(()=>{var S=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href));return(async function(P={}){var f=P,_,O;f.ready=new Promise((e,r)=>{_=e,O=r;});var z=Object.assign({},f),N="./this.program",fe=typeof window=="object",V=typeof importScripts=="function",K=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",L="";function Ne(e){return f.locateFile?f.locateFile(e,L):L+e}var me,Ve,De;if(K){let{createRequire:e}=await import('module');var Fe=e((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))),Ye=Fe("fs"),qe=Fe("path");V?L=qe.dirname(L)+"/":L=Fe("url").fileURLToPath(new URL("./",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)))),me=(r,t)=>(r=Cr(r)?new URL(r):qe.normalize(r),Ye.readFileSync(r,t?void 0:"utf8")),De=r=>{var t=me(r,true);return t.buffer||(t=new Uint8Array(t)),t},Ve=(r,t,n,o=true)=>{r=Cr(r)?new URL(r):qe.normalize(r),Ye.readFile(r,o?void 0:"utf8",(i,s)=>{i?n(i):t(o?s.buffer:s);});},!f.thisProgram&&process.argv.length>1&&(N=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2);}else (fe||V)&&(V?L=self.location.href:typeof document<"u"&&document.currentScript&&(L=document.currentScript.src),S&&(L=S),L.startsWith("blob:")?L="":L=L.substr(0,L.replace(/[?#].*/,"").lastIndexOf("/")+1),me=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.send(null),r.responseText},V&&(De=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Ve=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,true),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t();},n.onerror=t,n.send(null);});var Xe=f.print||console.log.bind(console),re=f.printErr||console.error.bind(console);Object.assign(f,z),z=null,f.arguments&&(f.arguments),f.thisProgram&&(N=f.thisProgram),f.quit&&(f.quit);var pe;f.wasmBinary&&(pe=f.wasmBinary);var Se,gr=false,I,x,de,ye,E,$,wr,_r;function Er(){var e=Se.buffer;f.HEAP8=I=new Int8Array(e),f.HEAP16=de=new Int16Array(e),f.HEAPU8=x=new Uint8Array(e),f.HEAPU16=ye=new Uint16Array(e),f.HEAP32=E=new Int32Array(e),f.HEAPU32=$=new Uint32Array(e),f.HEAPF32=wr=new Float32Array(e),f.HEAPF64=_r=new Float64Array(e);}var br=[],$r=[],kr=[];function at(){if(f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)st(f.preRun.shift());Je(br);}function ot(){!f.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=false,Je($r);}function it(){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)ut(f.postRun.shift());Je(kr);}function st(e){br.unshift(e);}function lt(e){$r.unshift(e);}function ut(e){kr.unshift(e);}var ae=0,ge=null;function Ke(e){ae++,f.monitorRunDependencies?.(ae);}function Ae(e){if(ae--,f.monitorRunDependencies?.(ae),ae==0&&(ge)){var r=ge;ge=null,r();}}function we(e){f.onAbort?.(e),e="Aborted("+e+")",re(e),gr=true,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw O(r),r}var ft="data:application/octet-stream;base64,",Pr=e=>e.startsWith(ft),Cr=e=>e.startsWith("file://"),oe;f.locateFile?(oe="heic-decoder.wasm",Pr(oe)||(oe=Ne(oe))):oe=new URL("heic-decoder.wasm",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))).href;function Tr(e){if(e==oe&&pe)return new Uint8Array(pe);if(De)return De(e);throw "both async and sync fetching of the wasm failed"}function dt(e){return !pe&&(fe||V)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw `failed to load wasm binary file at '${e}'`;return r.arrayBuffer()}).catch(()=>Tr(e)):Promise.resolve().then(()=>Tr(e))}function Dr(e,r,t){return dt(e).then(n=>WebAssembly.instantiate(n,r)).then(t,n=>{re(`failed to asynchronously prepare wasm: ${n}`),we(n);})}function ct(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!Pr(r)&&!K&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(o=>{var i=WebAssembly.instantiateStreaming(o,t);return i.then(n,function(s){return re(`wasm streaming compile failed: ${s}`),re("falling back to ArrayBuffer instantiation"),Dr(r,t,n)})}):Dr(r,t,n)}function vt(){var e={a:ca};function r(n,o){return B=n.exports,Se=B.Q,Er(),xr=B.T,lt(B.R),Ae(),B}Ke();function t(n){r(n.instance);}if(f.instantiateWasm)try{return f.instantiateWasm(e,r)}catch(n){re(`Module.instantiateWasm callback failed with error: ${n}`),O(n);}return ct(pe,oe,e,t).catch(O),{}}var b,j,Je=e=>{for(;e.length>0;)e.shift()(f);};f.noExitRuntime||true;var Fr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ce=(e,r,t)=>{for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.buffer&&Fr)return Fr.decode(e.subarray(r,o));for(var i="";r<o;){var s=e[r++];if(!(s&128)){i+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|l);continue}var u=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|u:s=(s&7)<<18|l<<12|u<<6|e[r++]&63,s<65536)i+=String.fromCharCode(s);else {var d=s-65536;i+=String.fromCharCode(55296|d>>10,56320|d&1023);}}return i},ie=(e,r)=>e?ce(x,e,r):"",ht=(e,r,t,n)=>{we(`Assertion failed: ${ie(e)}, at: `+[r?ie(r):"unknown filename",t,n?ie(n):"unknown function"]);};class mt{constructor(r){this.excPtr=r,this.ptr=r-24;}set_type(r){$[this.ptr+4>>2]=r;}get_type(){return $[this.ptr+4>>2]}set_destructor(r){$[this.ptr+8>>2]=r;}get_destructor(){return $[this.ptr+8>>2]}set_caught(r){r=r?1:0,I[this.ptr+12]=r;}get_caught(){return I[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,I[this.ptr+13]=r;}get_rethrown(){return I[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t);}set_adjusted_ptr(r){$[this.ptr+16>>2]=r;}get_adjusted_ptr(){return $[this.ptr+16>>2]}get_exception_ptr(){var r=Jr(this.get_type());if(r)return $[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Sr=0,yt=(e,r,t)=>{var n=new mt(e);throw n.init(r,t),Sr=e,Sr},Re={},Qe=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r);}};function _e(e){return this.fromWireType($[e>>2])}var ve={},se={},Me={},Ar,Oe=e=>{throw new Ar(e)},le=(e,r,t)=>{e.forEach(function(l){Me[l]=r;});function n(l){var u=t(l);u.length!==e.length&&Oe("Mismatched type converter count");for(var d=0;d<e.length;++d)q(e[d],u[d]);}var o=new Array(r.length),i=[],s=0;r.forEach((l,u)=>{se.hasOwnProperty(l)?o[u]=se[l]:(i.push(l),ve.hasOwnProperty(l)||(ve[l]=[]),ve[l].push(()=>{o[u]=se[l],++s,s===i.length&&n(o);}));}),i.length===0&&n(o);},gt=e=>{var r=Re[e];delete Re[e];var t=r.rawConstructor,n=r.rawDestructor,o=r.fields,i=o.map(s=>s.getterReturnType).concat(o.map(s=>s.setterArgumentType));le([e],i,s=>{var l={};return o.forEach((u,d)=>{var v=u.fieldName,y=s[d],p=u.getter,h=u.getterContext,g=s[d+o.length],D=u.setter,A=u.setterContext;l[v]={read:T=>y.fromWireType(p(h,T)),write:(T,c)=>{var m=[];D(A,T,g.toWireType(m,c)),Qe(m);}};}),[{name:r.name,fromWireType:u=>{var d={};for(var v in l)d[v]=l[v].read(u);return n(u),d},toWireType:(u,d)=>{for(var v in l)if(!(v in d))throw new TypeError(`Missing field: "${v}"`);var y=t();for(v in l)l[v].write(y,d[v]);return u!==null&&u.push(n,y),y},argPackAdvance:X,readValueFromPointer:_e,destructorFunction:n}]});},wt=(e,r,t,n,o)=>{},_t=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Rr=e;},Rr,U=e=>{for(var r="",t=e;x[t];)r+=Rr[x[t++]];return r},he,C=e=>{throw new he(e)};function Et(e,r,t={}){var n=r.name;if(e||C(`type "${n}" must have a positive integer typeid pointer`),se.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;C(`Cannot register type '${n}' twice`);}if(se[e]=r,delete Me[e],ve.hasOwnProperty(e)){var o=ve[e];delete ve[e],o.forEach(i=>i());}}function q(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Et(e,r,t)}var X=8,bt=(e,r,t,n)=>{r=U(r),q(e,{name:r,fromWireType:function(o){return !!o},toWireType:function(o,i){return i?t:n},argPackAdvance:X,readValueFromPointer:function(o){return this.fromWireType(x[o])},destructorFunction:null});},$t=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Ze=e=>{function r(t){return t.$$.ptrType.registeredClass.name}C(r(e)+" instance already deleted");},er=false,Mr=e=>{},kt=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr);},Or=e=>{e.count.value-=1;var r=e.count.value===0;r&&kt(e);},jr=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=jr(e,r,t.baseClass);return n===null?null:t.downcast(n)},Ir={},Pt=()=>Object.keys($e).length,Ct=()=>{var e=[];for(var r in $e)$e.hasOwnProperty(r)&&e.push($e[r]);return e},Ee=[],rr=()=>{for(;Ee.length;){var e=Ee.pop();e.$$.deleteScheduled=false,e.delete();}},be,Tt=e=>{be=e,Ee.length&&be&&be(rr);},Dt=()=>{f.getInheritedInstanceCount=Pt,f.getLiveInheritedInstances=Ct,f.flushPendingDeletes=rr,f.setDelayFunction=Tt;},$e={},Ft=(e,r)=>{for(r===void 0&&C("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},St=(e,r)=>(r=Ft(e,r),$e[r]),je=(e,r)=>{(!r.ptrType||!r.ptr)&&Oe("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Oe("Both smartPtrType and smartPtr must be specified"),r.count={value:1},ke(Object.create(e,{$$:{value:r,writable:true}}))};function At(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=St(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 o(){return this.isSmartPointer?je(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):je(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i=this.registeredClass.getActualType(r),s=Ir[i];if(!s)return o.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var u=jr(r,this.registeredClass,l.registeredClass);return u===null?o.call(this):this.isSmartPointer?je(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:e}):je(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var ke=e=>typeof FinalizationRegistry>"u"?(ke=r=>r,e):(er=new FinalizationRegistry(r=>{Or(r.$$);}),ke=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var o={$$:t};er.register(r,o,r);}return r},Mr=r=>er.unregister(r),ke(e)),Rt=()=>{Object.assign(Ie.prototype,{isAliasOf(e){if(!(this instanceof Ie)||!(e instanceof Ie))return false;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,o=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return r===n&&t===o},clone(){if(this.$$.ptr||Ze(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=ke(Object.create(Object.getPrototypeOf(this),{$$:{value:$t(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=false,e},delete(){this.$$.ptr||Ze(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&C("Object already scheduled for deletion"),Mr(this),Or(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0);},isDeleted(){return !this.$$.ptr},deleteLater(){return this.$$.ptr||Ze(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&C("Object already scheduled for deletion"),Ee.push(this),Ee.length===1&&be&&be(rr),this.$$.deleteScheduled=true,this}});};function Ie(){}var Pe=(e,r)=>Object.defineProperty(r,"name",{value:e}),Ur=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...o){return e[r].overloadTable.hasOwnProperty(o.length)||C(`Function '${t}' called with an invalid number of arguments (${o.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[o.length].apply(this,o)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n;}},tr=(e,r,t)=>{f.hasOwnProperty(e)?((t===void 0||f[e].overloadTable!==void 0&&f[e].overloadTable[t]!==void 0)&&C(`Cannot register public name '${e}' twice`),Ur(f,e,e),f.hasOwnProperty(t)&&C(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),f[e].overloadTable[t]=r):(f[e]=r,t!==void 0&&(f[e].numArguments=t));},Mt=48,Ot=57,jt=e=>{if(e===void 0)return "_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Mt&&r<=Ot?`_${e}`:e};function It(e,r,t,n,o,i,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[];}var nr=(e,r,t)=>{for(;r!==t;)r.upcast||C(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function Ut(e,r){if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),0;r.$$||C(`Cannot pass "${ur(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=nr(r.$$.ptr,t,this.registeredClass);return n}function Bt(e,r){var t;if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&C(`Cannot pass "${ur(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&C(`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=nr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&C("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:C(`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 o=r.clone();t=this.rawShare(t,W.toHandle(()=>o.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:C("Unsupporting sharing policy");}return t}function xt(e,r){if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),0;r.$$||C(`Cannot pass "${ur(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&C(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=nr(r.$$.ptr,t,this.registeredClass);return n}var Wt=()=>{Object.assign(Ue.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e);},argPackAdvance:X,readValueFromPointer:_e,fromWireType:At});};function Ue(e,r,t,n,o,i,s,l,u,d,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=d,this.rawDestructor=v,!o&&r.baseClass===void 0?n?(this.toWireType=Ut,this.destructorFunction=null):(this.toWireType=xt,this.destructorFunction=null):this.toWireType=Bt;}var Br=(e,r,t)=>{f.hasOwnProperty(e)||Oe("Replacing nonexistent public symbol"),f[e].overloadTable!==void 0&&t!==void 0?f[e].overloadTable[t]=r:(f[e]=r,f[e].argCount=t);},Ht=(e,r,t)=>{var n=f["dynCall_"+e];return n(r,...t)},Be=[],xr,Wr=e=>{var r=Be[e];return r||(e>=Be.length&&(Be.length=e+1),Be[e]=r=xr.get(e)),r},Lt=(e,r,t=[])=>{if(e.includes("j"))return Ht(e,r,t);var n=Wr(r)(...t);return n},zt=(e,r)=>(...t)=>Lt(e,r,t),Y=(e,r)=>{e=U(e);function t(){return e.includes("j")?zt(e,r):Wr(r)}var n=t();return typeof n!="function"&&C(`unknown function pointer with signature ${e}: ${r}`),n},Nt=(e,r)=>{var t=Pe(r,function(n){this.name=r,this.message=n;var o=new Error(n).stack;o!==void 0&&(this.stack=this.toString()+`
|
|
2
|
-
`+o.replace(/^Error(:[^\n]*)?\n/,""));});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},Hr,Lr=e=>{var r=Kr(e),t=U(r);return Z(r),t},xe=(e,r)=>{var t=[],n={};function o(i){if(!n[i]&&!se[i]){if(Me[i]){Me[i].forEach(o);return}t.push(i),n[i]=true;}}throw r.forEach(o),new Hr(`${e}: `+t.map(Lr).join([", "]))},Vt=(e,r,t,n,o,i,s,l,u,d,v,y,p)=>{v=U(v),i=Y(o,i),l&&=Y(s,l),d&&=Y(u,d),p=Y(y,p);var h=jt(v);tr(h,function(){xe(`Cannot construct ${v} due to unbound types`,[n]);}),le([e,r,t],n?[n]:[],g=>{g=g[0];var D,A;n?(D=g.registeredClass,A=D.instancePrototype):A=Ie.prototype;var T=Pe(v,function(...R){if(Object.getPrototypeOf(this)!==c)throw new he("Use 'new' to construct "+v);if(m.constructor_body===void 0)throw new he(v+" has no accessible constructor");var Zr=m.constructor_body[R.length];if(Zr===void 0)throw new he(`Tried to invoke ctor of ${v} with invalid number of parameters (${R.length}) - expected (${Object.keys(m.constructor_body).toString()}) parameters instead!`);return Zr.apply(this,R)}),c=Object.create(A,{constructor:{value:T}});T.prototype=c;var m=new It(v,T,c,p,D,i,l,d);m.baseClass&&(m.baseClass.__derivedClasses??=[],m.baseClass.__derivedClasses.push(m));var M=new Ue(v,m,true,false,false),k=new Ue(v+"*",m,false,false,false),H=new Ue(v+" const*",m,false,true,false);return Ir[e]={pointerType:k,constPointerType:H},Br(h,T),[M,k,H]});},ar=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push($[r+n*4>>2]);return t};function Yt(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return true;return false}function or(e,r,t,n,o,i){var s=r.length;s<2&&C("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=r[1]!==null&&t!==null,u=Yt(r),d=r[0].name!=="void",v=s-2,y=new Array(v),p=[],h=[],g=function(...D){D.length!==v&&C(`function ${e} called with ${D.length} arguments, expected ${v}`),h.length=0;var A;p.length=l?2:1,p[0]=o,l&&(A=r[1].toWireType(h,this),p[1]=A);for(var T=0;T<v;++T)y[T]=r[T+2].toWireType(h,D[T]),p.push(y[T]);var c=n(...p);function m(M){if(u)Qe(h);else for(var k=l?1:2;k<r.length;k++){var H=k===1?A:y[k-2];r[k].destructorFunction!==null&&r[k].destructorFunction(H);}if(d)return r[0].fromWireType(M)}return m(c)};return Pe(e,g)}var qt=(e,r,t,n,o,i)=>{var s=ar(r,t);o=Y(n,o),le([],[e],l=>{l=l[0];var u=`constructor ${l.name}`;if(l.registeredClass.constructor_body===void 0&&(l.registeredClass.constructor_body=[]),l.registeredClass.constructor_body[r-1]!==void 0)throw new he(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${l.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return l.registeredClass.constructor_body[r-1]=()=>{xe(`Cannot construct ${l.name} due to unbound types`,s);},le([],s,d=>(d.splice(1,0,null),l.registeredClass.constructor_body[r-1]=or(u,d,null,o,i),[])),[]});},zr=e=>{e=e.trim();let r=e.indexOf("(");return r!==-1?e.substr(0,r):e},Xt=(e,r,t,n,o,i,s,l,u)=>{var d=ar(t,n);r=U(r),r=zr(r),i=Y(o,i),le([],[e],v=>{v=v[0];var y=`${v.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&v.registeredClass.pureVirtualFunctions.push(r);function p(){xe(`Cannot call ${y} due to unbound types`,d);}var h=v.registeredClass.instancePrototype,g=h[r];return g===void 0||g.overloadTable===void 0&&g.className!==v.name&&g.argCount===t-2?(p.argCount=t-2,p.className=v.name,h[r]=p):(Ur(h,r,y),h[r].overloadTable[t-2]=p),le([],d,D=>{var A=or(y,D,v,i,s);return h[r].overloadTable===void 0?(A.argCount=t-2,h[r]=A):h[r].overloadTable[t-2]=A,[]}),[]});},ir=[],J=[],sr=e=>{e>9&&--J[e+1]===0&&(J[e]=void 0,ir.push(e));},Gt=()=>J.length/2-5-ir.length,Kt=()=>{J.push(0,1,void 0,1,null,1,true,1,false,1),f.count_emval_handles=Gt;},W={toValue:e=>(e||C("Cannot use deleted val. handle = "+e),J[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case true:return 6;case false:return 8;default:{let r=ir.pop()||J.length;return J[r]=e,J[r+1]=1,r}}}},Jt={name:"emscripten::val",fromWireType:e=>{var r=W.toValue(e);return sr(e),r},toWireType:(e,r)=>W.toHandle(r),argPackAdvance:X,readValueFromPointer:_e,destructorFunction:null},Qt=e=>q(e,Jt),Zt=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType(I[n])}:function(n){return this.fromWireType(x[n])};case 2:return t?function(n){return this.fromWireType(de[n>>1])}:function(n){return this.fromWireType(ye[n>>1])};case 4:return t?function(n){return this.fromWireType(E[n>>2])}:function(n){return this.fromWireType($[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},en=(e,r,t,n)=>{r=U(r);function o(){}o.values={},q(e,{name:r,constructor:o,fromWireType:function(i){return this.constructor.values[i]},toWireType:(i,s)=>s.value,argPackAdvance:X,readValueFromPointer:Zt(r,t,n),destructorFunction:null}),tr(r,o);},lr=(e,r)=>{var t=se[e];return t===void 0&&C(`${r} has unknown type ${Lr(e)}`),t},rn=(e,r,t)=>{var n=lr(e,"enum");r=U(r);var o=n.constructor,i=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:Pe(`${n.name}_${r}`,function(){})}});o.values[t]=i,o[r]=i;},ur=e=>{if(e===null)return "null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},tn=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(wr[t>>2])};case 8:return function(t){return this.fromWireType(_r[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},nn=(e,r,t)=>{r=U(r),q(e,{name:r,fromWireType:n=>n,toWireType:(n,o)=>o,argPackAdvance:X,readValueFromPointer:tn(r,t),destructorFunction:null});},an=(e,r,t,n,o,i,s)=>{var l=ar(r,t);e=U(e),e=zr(e),o=Y(n,o),tr(e,function(){xe(`Cannot call ${e} due to unbound types`,l);},r-1),le([],l,u=>{var d=[u[0],null].concat(u.slice(1));return Br(e,or(e,d,null,o,i),r-1),[]});},on=(e,r,t)=>{switch(r){case 1:return t?n=>I[n]:n=>x[n];case 2:return t?n=>de[n>>1]:n=>ye[n>>1];case 4:return t?n=>E[n>>2]:n=>$[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},sn=(e,r,t,n,o)=>{r=U(r);var i=v=>v;if(n===0){var s=32-8*t;i=v=>v<<s>>>s;}var l=r.includes("unsigned"),u=(v,y)=>{},d;l?d=function(v,y){return u(y,this.name),y>>>0}:d=function(v,y){return u(y,this.name),y},q(e,{name:r,fromWireType:i,toWireType:d,argPackAdvance:X,readValueFromPointer:on(r,t,n!==0),destructorFunction:null});},ln=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],o=n[r];function i(s){var l=$[s>>2],u=$[s+4>>2];return new o(I.buffer,u,l)}t=U(t),q(e,{name:t,fromWireType:i,argPackAdvance:X,readValueFromPointer:i},{ignoreDuplicateRegistrations:true});},fr=(e,r,t,n)=>{if(!(n>0))return 0;for(var o=t,i=t+n-1,s=0;s<e.length;++s){var l=e.charCodeAt(s);if(l>=55296&&l<=57343){var u=e.charCodeAt(++s);l=65536+((l&1023)<<10)|u&1023;}if(l<=127){if(t>=i)break;r[t++]=l;}else if(l<=2047){if(t+1>=i)break;r[t++]=192|l>>6,r[t++]=128|l&63;}else if(l<=65535){if(t+2>=i)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63;}else {if(t+3>=i)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63;}}return r[t]=0,t-o},un=(e,r,t)=>fr(e,x,r,t),dr=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},fn=(e,r)=>{r=U(r);var t=r==="std::string";q(e,{name:r,fromWireType(n){var o=$[n>>2],i=n+4,s;if(t)for(var l=i,u=0;u<=o;++u){var d=i+u;if(u==o||x[d]==0){var v=d-l,y=ie(l,v);s===void 0?s=y:(s+="\0",s+=y),l=d+1;}}else {for(var p=new Array(o),u=0;u<o;++u)p[u]=String.fromCharCode(x[i+u]);s=p.join("");}return Z(n),s},toWireType(n,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var i,s=typeof o=="string";s||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||C("Cannot pass non-string to std::string"),t&&s?i=dr(o):i=o.length;var l=pr(4+i+1),u=l+4;if($[l>>2]=i,t&&s)un(o,u,i+1);else if(s)for(var d=0;d<i;++d){var v=o.charCodeAt(d);v>255&&(Z(u),C("String has UTF-16 code units that do not fit in 8 bits")),x[u+d]=v;}else for(var d=0;d<i;++d)x[u+d]=o[d];return n!==null&&n.push(Z,l),l},argPackAdvance:X,readValueFromPointer:_e,destructorFunction(n){Z(n);}});},Nr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,dn=(e,r)=>{for(var t=e,n=t>>1,o=n+r/2;!(n>=o)&&ye[n];)++n;if(t=n<<1,t-e>32&&Nr)return Nr.decode(x.subarray(e,t));for(var i="",s=0;!(s>=r/2);++s){var l=de[e+s*2>>1];if(l==0)break;i+=String.fromCharCode(l);}return i},cn=(e,r,t)=>{if(t??=2147483647,t<2)return 0;t-=2;for(var n=r,o=t<e.length*2?t/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);de[r>>1]=s,r+=2;}return de[r>>1]=0,r-n},vn=e=>e.length*2,hn=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var o=E[e+t*4>>2];if(o==0)break;if(++t,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|i&1023);}else n+=String.fromCharCode(o);}return n},mn=(e,r,t)=>{if(t??=2147483647,t<4)return 0;for(var n=r,o=n+t-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343){var l=e.charCodeAt(++i);s=65536+((s&1023)<<10)|l&1023;}if(E[r>>2]=s,r+=4,r+4>o)break}return E[r>>2]=0,r-n},pn=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4;}return r},yn=(e,r,t)=>{t=U(t);var n,o,i,s;r===2?(n=dn,o=cn,s=vn,i=l=>ye[l>>1]):r===4&&(n=hn,o=mn,s=pn,i=l=>$[l>>2]),q(e,{name:t,fromWireType:l=>{for(var u=$[l>>2],d,v=l+4,y=0;y<=u;++y){var p=l+4+y*r;if(y==u||i(p)==0){var h=p-v,g=n(v,h);d===void 0?d=g:(d+="\0",d+=g),v=p+r;}}return Z(l),d},toWireType:(l,u)=>{typeof u!="string"&&C(`Cannot pass non-string to C++ string type ${t}`);var d=s(u),v=pr(4+d+r);return $[v>>2]=d/r,o(u,v+4,d+r),l!==null&&l.push(Z,v),v},argPackAdvance:X,readValueFromPointer:_e,destructorFunction(l){Z(l);}});},gn=(e,r,t,n,o,i)=>{Re[e]={name:U(r),rawConstructor:Y(t,n),rawDestructor:Y(o,i),fields:[]};},wn=(e,r,t,n,o,i,s,l,u,d)=>{Re[e].fields.push({fieldName:U(r),getterReturnType:t,getter:Y(n,o),getterContext:i,setterArgumentType:s,setter:Y(l,u),setterContext:d});},_n=(e,r)=>{r=U(r),q(e,{isVoid:true,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}});},We=[],En=(e,r,t,n)=>(e=We[e],r=W.toValue(r),e(null,r,t,n)),bn={},cr=e=>{var r=bn[e];return r===void 0?U(e):r},$n=(e,r,t,n,o)=>(e=We[e],r=W.toValue(r),t=cr(t),e(r,r[t],n,o)),Vr=()=>{if(typeof globalThis=="object")return globalThis;function e(r){r.$$$embind_global$$$=r;var t=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return t||delete r.$$$embind_global$$$,t}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&e(global)?$$$embind_global$$$=global:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")},kn=e=>e===0?W.toHandle(Vr()):(e=cr(e),W.toHandle(Vr()[e])),Pn=e=>{var r=We.length;return We.push(e),r},Cn=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=lr($[r+n*4>>2],"parameter "+n);return t},Tn=Reflect.construct,Dn=(e,r,t)=>{var n=[],o=e.toWireType(n,t);return n.length&&($[r>>2]=W.toHandle(n)),o},Fn=(e,r,t)=>{var n=Cn(e,r),o=n.shift();e--;var i=new Array(e),s=(u,d,v,y)=>{for(var p=0,h=0;h<e;++h)i[h]=n[h].readValueFromPointer(y+p),p+=n[h].argPackAdvance;var g=t===1?Tn(d,i):d.apply(u,i);return Dn(o,v,g)},l=`methodCaller<(${n.map(u=>u.name).join(", ")}) => ${o.name}>`;return Pn(Pe(l,s))},Sn=e=>{e>9&&(J[e+1]+=1);},An=()=>W.toHandle([]),Rn=e=>W.toHandle(cr(e)),Mn=()=>W.toHandle({}),On=e=>{var r=W.toValue(e);Qe(r),sr(e);},jn=(e,r,t)=>{e=W.toValue(e),r=W.toValue(r),t=W.toValue(t),e[r]=t;},In=(e,r)=>{e=lr(e,"_emval_take_value");var t=e.readValueFromPointer(r);return W.toHandle(t)},Un=()=>{we("");},Bn=(e,r,t)=>x.copyWithin(e,r,r+t),xn=()=>2147483648,Wn=e=>{var r=Se.buffer,t=(e-r.byteLength+65535)/65536;try{return Se.grow(t),Er(),1}catch{}},Hn=e=>{var r=x.length;e>>>=0;var t=xn();if(e>t)return false;for(var n=(u,d)=>u+(d-u%d)%d,o=1;o<=4;o*=2){var i=r*(1+.2/o);i=Math.min(i,e+100663296);var s=Math.min(t,n(Math.max(e,i),65536)),l=Wn(s);if(l)return true}return false},vr={},Ln=()=>N||"./this.program",Ce=()=>{if(!Ce.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Ln()};for(var t in vr)vr[t]===void 0?delete r[t]:r[t]=vr[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ce.strings=n;}return Ce.strings},zn=(e,r)=>{for(var t=0;t<e.length;++t)I[r++]=e.charCodeAt(t);I[r]=0;},Nn=(e,r)=>{var t=0;return Ce().forEach((n,o)=>{var i=r+t;$[e+o*4>>2]=i,zn(n,i),t+=n.length+1;}),0},Vn=(e,r)=>{var t=Ce();$[e>>2]=t.length;var n=0;return t.forEach(o=>n+=o.length+1),$[r>>2]=n,0},F={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 o=e[n];o==="."?e.splice(n,1):o===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--);}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=F.isAbs(e),t=e.substr(-1)==="/";return e=F.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=F.splitPath(e),t=r[0],n=r[1];return !t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return "/";e=F.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>F.normalize(e.join("/")),join2:(e,r)=>F.normalize(e+"/"+r)},Yn=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return n=>crypto.getRandomValues(n);if(K)try{var e=Fe("crypto"),r=e.randomFillSync;if(r)return n=>e.randomFillSync(n);var t=e.randomBytes;return n=>(n.set(t(n.byteLength)),n)}catch{}we("initRandomDevice");},Yr=e=>(Yr=Yn())(e),Q={resolve:(...e)=>{for(var r="",t=false,n=e.length-1;n>=-1&&!t;n--){var o=n>=0?e[n]:a.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return "";r=o+"/"+r,t=F.isAbs(o);}return r=F.normalizeArray(r.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=Q.resolve(e).substr(1),r=Q.resolve(r).substr(1);function t(d){for(var v=0;v<d.length&&d[v]==="";v++);for(var y=d.length-1;y>=0&&d[y]==="";y--);return v>y?[]:d.slice(v,y-v+1)}for(var n=t(e.split("/")),o=t(r.split("/")),i=Math.min(n.length,o.length),s=i,l=0;l<i;l++)if(n[l]!==o[l]){s=l;break}for(var u=[],l=s;l<n.length;l++)u.push("..");return u=u.concat(o.slice(s)),u.join("/")}},hr=[];function He(e,r,t){var n=dr(e)+1,o=new Array(n),i=fr(e,o,0,o.length);return r&&(o.length=i),o}var qn=()=>{if(!hr.length){var e=null;if(K){var r=256,t=Buffer.alloc(r),n=0,o=process.stdin.fd;try{n=Ye.readSync(o,t);}catch(i){if(i.toString().includes("EOF"))n=0;else throw i}n>0?e=t.slice(0,n).toString("utf-8"):e=null;}else typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
1
|
+
'use strict';var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var $a=(()=>{var F=(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href));return(async function($={}){var d=$,_,S;d.ready=new Promise((e,r)=>{_=e,S=r;});var B=Object.assign({},d),x="./this.program",te=typeof window=="object",j=typeof importScripts=="function",Q=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",Y="";function Ne(e){return d.locateFile?d.locateFile(e,Y):Y+e}var me,Ve,Te;if(Q){let{createRequire:e}=await import('module');var De=e((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))),Ye=De("fs"),qe=De("path");j?Y=qe.dirname(Y)+"/":Y=De("url").fileURLToPath(new URL("./",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)))),me=(r,t)=>(r=Pr(r)?new URL(r):qe.normalize(r),Ye.readFileSync(r,t?void 0:"utf8")),Te=r=>{var t=me(r,true);return t.buffer||(t=new Uint8Array(t)),t},Ve=(r,t,n,o=true)=>{r=Pr(r)?new URL(r):qe.normalize(r),Ye.readFile(r,o?void 0:"utf8",(i,s)=>{i?n(i):t(o?s.buffer:s);});},!d.thisProgram&&process.argv.length>1&&(x=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2);}else (te||j)&&(j?Y=self.location.href:typeof document<"u"&&document.currentScript&&(Y=document.currentScript.src),F&&(Y=F),Y.startsWith("blob:")?Y="":Y=Y.substr(0,Y.replace(/[?#].*/,"").lastIndexOf("/")+1),me=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.send(null),r.responseText},j&&(Te=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Ve=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,true),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t();},n.onerror=t,n.send(null);});var Xe=d.print||console.log.bind(console),ne=d.printErr||console.error.bind(console);Object.assign(d,B),B=null,d.arguments&&(d.arguments),d.thisProgram&&(x=d.thisProgram),d.quit&&(d.quit);var pe;d.wasmBinary&&(pe=d.wasmBinary);var Fe,yr=false,H,L,de,ye,E,k,gr,wr;function _r(){var e=Fe.buffer;d.HEAP8=H=new Int8Array(e),d.HEAP16=de=new Int16Array(e),d.HEAPU8=L=new Uint8Array(e),d.HEAPU16=ye=new Uint16Array(e),d.HEAP32=E=new Int32Array(e),d.HEAPU32=k=new Uint32Array(e),d.HEAPF32=gr=new Float32Array(e),d.HEAPF64=wr=new Float64Array(e);}var Er=[],br=[],$r=[];function nt(){if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)it(d.preRun.shift());Je(Er);}function at(){!d.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=false,Je(br);}function ot(){if(d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;)lt(d.postRun.shift());Je($r);}function it(e){Er.unshift(e);}function st(e){br.unshift(e);}function lt(e){$r.unshift(e);}var oe=0,ge=null;function Ke(e){oe++,d.monitorRunDependencies?.(oe);}function Ae(e){if(oe--,d.monitorRunDependencies?.(oe),oe==0&&(ge)){var r=ge;ge=null,r();}}function fe(e){d.onAbort?.(e),e="Aborted("+e+")",ne(e),yr=true,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw S(r),r}var ut="data:application/octet-stream;base64,",kr=e=>e.startsWith(ut),Pr=e=>e.startsWith("file://"),ie;d.locateFile?(ie="heic-decoder.wasm",kr(ie)||(ie=Ne(ie))):ie=new URL("heic-decoder.wasm",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href))).href;function Cr(e){if(e==ie&&pe)return new Uint8Array(pe);if(Te)return Te(e);throw "both async and sync fetching of the wasm failed"}function dt(e){return !pe&&(te||j)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw `failed to load wasm binary file at '${e}'`;return r.arrayBuffer()}).catch(()=>Cr(e)):Promise.resolve().then(()=>Cr(e))}function Tr(e,r,t){return dt(e).then(n=>WebAssembly.instantiate(n,r)).then(t,n=>{ne(`failed to asynchronously prepare wasm: ${n}`),fe(n);})}function ft(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!kr(r)&&!Q&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(o=>{var i=WebAssembly.instantiateStreaming(o,t);return i.then(n,function(s){return ne(`wasm streaming compile failed: ${s}`),ne("falling back to ArrayBuffer instantiation"),Tr(r,t,n)})}):Tr(r,t,n)}function ct(){var e={a:ca};function r(n,o){return I=n.exports,Fe=I.R,_r(),Hr=I.U,st(I.S),Ae(),I}Ke();function t(n){r(n.instance);}if(d.instantiateWasm)try{return d.instantiateWasm(e,r)}catch(n){ne(`Module.instantiateWasm callback failed with error: ${n}`),S(n);}return ft(pe,ie,e,t).catch(S),{}}var b,U,Je=e=>{for(;e.length>0;)e.shift()(d);};d.noExitRuntime||true;var Dr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ce=(e,r,t)=>{for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.buffer&&Dr)return Dr.decode(e.subarray(r,o));for(var i="";r<o;){var s=e[r++];if(!(s&128)){i+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|l);continue}var u=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|u:s=(s&7)<<18|l<<12|u<<6|e[r++]&63,s<65536)i+=String.fromCharCode(s);else {var f=s-65536;i+=String.fromCharCode(55296|f>>10,56320|f&1023);}}return i},se=(e,r)=>e?ce(L,e,r):"",vt=(e,r,t,n)=>{fe(`Assertion failed: ${se(e)}, at: `+[r?se(r):"unknown filename",t,n?se(n):"unknown function"]);};class ht{constructor(r){this.excPtr=r,this.ptr=r-24;}set_type(r){k[this.ptr+4>>2]=r;}get_type(){return k[this.ptr+4>>2]}set_destructor(r){k[this.ptr+8>>2]=r;}get_destructor(){return k[this.ptr+8>>2]}set_caught(r){r=r?1:0,H[this.ptr+12]=r;}get_caught(){return H[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,H[this.ptr+13]=r;}get_rethrown(){return H[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t);}set_adjusted_ptr(r){k[this.ptr+16>>2]=r;}get_adjusted_ptr(){return k[this.ptr+16>>2]}get_exception_ptr(){var r=Kr(this.get_type());if(r)return k[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Fr=0,pt=(e,r,t)=>{var n=new ht(e);throw n.init(r,t),Fr=e,Fr},A={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 o=e[n];o==="."?e.splice(n,1):o===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--);}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=A.isAbs(e),t=e.substr(-1)==="/";return e=A.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=A.splitPath(e),t=r[0],n=r[1];return !t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return "/";e=A.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>A.normalize(e.join("/")),join2:(e,r)=>A.normalize(e+"/"+r)},yt=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return n=>crypto.getRandomValues(n);if(Q)try{var e=De("crypto"),r=e.randomFillSync;if(r)return n=>e.randomFillSync(n);var t=e.randomBytes;return n=>(n.set(t(n.byteLength)),n)}catch{}fe("initRandomDevice");},Ar=e=>(Ar=yt())(e),Z={resolve:(...e)=>{for(var r="",t=false,n=e.length-1;n>=-1&&!t;n--){var o=n>=0?e[n]:a.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return "";r=o+"/"+r,t=A.isAbs(o);}return r=A.normalizeArray(r.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=Z.resolve(e).substr(1),r=Z.resolve(r).substr(1);function t(f){for(var v=0;v<f.length&&f[v]==="";v++);for(var y=f.length-1;y>=0&&f[y]==="";y--);return v>y?[]:f.slice(v,y-v+1)}for(var n=t(e.split("/")),o=t(r.split("/")),i=Math.min(n.length,o.length),s=i,l=0;l<i;l++)if(n[l]!==o[l]){s=l;break}for(var u=[],l=s;l<n.length;l++)u.push("..");return u=u.concat(o.slice(s)),u.join("/")}},Qe=[],Ze=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},er=(e,r,t,n)=>{if(!(n>0))return 0;for(var o=t,i=t+n-1,s=0;s<e.length;++s){var l=e.charCodeAt(s);if(l>=55296&&l<=57343){var u=e.charCodeAt(++s);l=65536+((l&1023)<<10)|u&1023;}if(l<=127){if(t>=i)break;r[t++]=l;}else if(l<=2047){if(t+1>=i)break;r[t++]=192|l>>6,r[t++]=128|l&63;}else if(l<=65535){if(t+2>=i)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63;}else {if(t+3>=i)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63;}}return r[t]=0,t-o};function Se(e,r,t){var n=Ze(e)+1,o=new Array(n),i=er(e,o,0,o.length);return r&&(o.length=i),o}var gt=()=>{if(!Qe.length){var e=null;if(Q){var r=256,t=Buffer.alloc(r),n=0,o=process.stdin.fd;try{n=Ye.readSync(o,t);}catch(i){if(i.toString().includes("EOF"))n=0;else throw i}n>0?e=t.slice(0,n).toString("utf-8"):e=null;}else typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
3
2
|
`)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
|
|
4
|
-
`));if(!e)return null;hr=He(e,true);}return hr.shift()},te={ttys:[],init(){},shutdown(){},register(e,r){te.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,te.stream_ops);},stream_ops:{open(e){var r=te.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=false;},close(e){e.tty.ops.fsync(e.tty);},fsync(e){e.tty.ops.fsync(e.tty);},read(e,r,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var i=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&&i===0)throw new a.ErrnoError(6);if(l==null)break;i++,r[t+s]=l;}return i&&(e.node.timestamp=Date.now()),i},write(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,r[t+i]);}catch{throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char(e){return qn()},put_char(e,r){r===null||r===10?(Xe(ce(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(Xe(ce(e.output,0)),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?(re(ce(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(re(ce(e.output,0)),e.output=[]);}}},qr=e=>{we();},w={ops_table:null,mount(e){return w.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);w.ops_table||={dir:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,lookup:w.node_ops.lookup,mknod:w.node_ops.mknod,rename:w.node_ops.rename,unlink:w.node_ops.unlink,rmdir:w.node_ops.rmdir,readdir:w.node_ops.readdir,symlink:w.node_ops.symlink},stream:{llseek:w.stream_ops.llseek}},file:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:{llseek:w.stream_ops.llseek,read:w.stream_ops.read,write:w.stream_ops.write,allocate:w.stream_ops.allocate,mmap:w.stream_ops.mmap,msync:w.stream_ops.msync}},link:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,readlink:w.node_ops.readlink},stream:{}},chrdev:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:a.chrdev_stream_ops}};var o=a.createNode(e,r,t,n);return a.isDir(o.mode)?(o.node_ops=w.ops_table.dir.node,o.stream_ops=w.ops_table.dir.stream,o.contents={}):a.isFile(o.mode)?(o.node_ops=w.ops_table.file.node,o.stream_ops=w.ops_table.file.stream,o.usedBytes=0,o.contents=null):a.isLink(o.mode)?(o.node_ops=w.ops_table.link.node,o.stream_ops=w.ops_table.link.stream):a.isChrdev(o.mode)&&(o.node_ops=w.ops_table.chrdev.node,o.stream_ops=w.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[r]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var o=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(o.subarray(0,e.usedBytes),0);}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else {var t=e.contents;e.contents=new Uint8Array(r),t&&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.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&w.resizeFileStorage(e,r.size);},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return w.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t);}catch{}if(n)for(var o in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r;},unlink(e,r){delete e.contents[r],e.timestamp=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.timestamp=Date.now();},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var n=w.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,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(s>8&&i.subarray)r.set(i.subarray(o,o+s),t);else for(var l=0;l<s;l++)r[t+l]=i[o+l];return s},write(e,r,t,n,o,i){if(r.buffer===I.buffer&&(i=false),!n)return 0;var s=e.node;if(s.timestamp=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=r.subarray(t,t+n),s.usedBytes=n,n;if(s.usedBytes===0&&o===0)return s.contents=r.slice(t,t+n),s.usedBytes=n,n;if(o+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),o),n}if(w.expandFileStorage(s,o+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),o);else for(var l=0;l<n;l++)s.contents[o+l]=r[t+l];return s.usedBytes=Math.max(s.usedBytes,o+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},allocate(e,r,t){w.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t);},mmap(e,r,t,n,o){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var i,s,l=e.node.contents;if(!(o&2)&&l.buffer===I.buffer)s=false,i=l.byteOffset;else {if((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),s=true,i=qr(),!i)throw new a.ErrnoError(48);I.set(l,i);}return {ptr:i,allocated:s}},msync(e,r,t,n,o){return w.stream_ops.write(e,r,0,n,t,false),0}}},Xn=(e,r,t,n)=>{var o=`al ${e}`;Ve(e,i=>{r(new Uint8Array(i)),o&&Ae();},i=>{if(t)t();else throw `Loading data file "${e}" failed.`}),o&&Ke();},Gn=(e,r,t,n,o,i)=>{a.createDataFile(e,r,t,n,o,i);},Kn=f.preloadPlugins||[],Jn=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var o=false;return Kn.forEach(i=>{o||i.canHandle(r)&&(i.handle(e,r,t,n),o=true);}),o},Qn=(e,r,t,n,o,i,s,l,u,d)=>{var v=r?Q.resolve(F.join2(e,r)):e;function p(h){function g(D){d?.(),l||Gn(e,r,D,n,o,u),i?.(),Ae();}Jn(h,v,g,()=>{s?.(),Ae();})||g(h);}Ke(),typeof t=="string"?Xn(t,p,s):p(t);},Zn=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},mr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e;}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.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{constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=a.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146;}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=Q.resolve(e),!e)return {path:"",node:null};var t={follow_mount:true,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(y=>!!y),o=a.root,i="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(o=a.lookupNode(o,n[s]),i=F.join2(i,n[s]),a.isMountpoint(o)&&(!l||l&&r.follow_mount)&&(o=o.mounted.root),!l||r.follow)for(var u=0;a.isLink(o.mode);){var d=a.readlink(i);i=Q.resolve(F.dirname(i),d);var v=a.lookupPath(i,{recurse_count:r.recurse_count+1});if(o=v.node,u++>40)throw new a.ErrnoError(32)}}return {path:i,node:o}},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),o=a.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===r)return o}return a.lookup(e,r)},createNode(e,r,t,n){var o=new a.FSNode(e,r,t,n);return a.hashAddNode(o),o},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){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(i){return i.errno}var o=a.nodePermissions(e,"wx");if(o)return o;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){return e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44},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 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},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=false),a.syncFSRequests++,a.syncFSRequests>1&&re(`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 o(s){return a.syncFSRequests--,r(s)}function i(s){if(s)return i.errored?void 0:(i.errored=true,o(s));++n>=t.length&&o(null);}t.forEach(s=>{if(!s.type.syncfs)return i(null);s.type.syncfs(s,e,i);});},mount(e,r,t){var n=t==="/",o=!t,i;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!o){var s=a.lookupPath(t,{follow_mount:false});if(t=s.path,i=s.node,a.isMountpoint(i))throw new a.ErrnoError(10);if(!a.isDir(i.mode))throw new a.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(l);return u.mount=l,l.root=u,n?a.root=u:i&&(i.mounted=l,i.mount&&i.mount.mounts.push(l)),u},unmount(e){var r=a.lookupPath(e,{follow_mount:false});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,o=a.getMounts(n);Object.keys(a.nameTable).forEach(s=>{for(var l=a.nameTable[s];l;){var u=l.name_next;o.includes(l.mount)&&a.destroyNode(l),l=u;}}),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1);},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=a.lookupPath(e,{parent:true}),o=n.node,i=F.basename(e);if(!i||i==="."||i==="..")throw new a.ErrnoError(28);var s=a.mayCreate(o,i);if(s)throw new a.ErrnoError(s);if(!o.node_ops.mknod)throw new a.ErrnoError(63);return o.node_ops.mknod(o,i,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{a.mkdir(n,r);}catch(i){if(i.errno!=20)throw i}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)},symlink(e,r){if(!Q.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:true}),n=t.node;if(!n)throw new a.ErrnoError(44);var o=F.basename(r),i=a.mayCreate(n,o);if(i)throw new a.ErrnoError(i);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,o,e)},rename(e,r){var t=F.dirname(e),n=F.dirname(r),o=F.basename(e),i=F.basename(r),s,l,u;if(s=a.lookupPath(e,{parent:true}),l=s.node,s=a.lookupPath(r,{parent:true}),u=s.node,!l||!u)throw new a.ErrnoError(44);if(l.mount!==u.mount)throw new a.ErrnoError(75);var d=a.lookupNode(l,o),v=Q.relative(e,n);if(v.charAt(0)!==".")throw new a.ErrnoError(28);if(v=Q.relative(r,t),v.charAt(0)!==".")throw new a.ErrnoError(55);var y;try{y=a.lookupNode(u,i);}catch{}if(d!==y){var p=a.isDir(d.mode),h=a.mayDelete(l,o,p);if(h)throw new a.ErrnoError(h);if(h=y?a.mayDelete(u,i,p):a.mayCreate(u,i),h)throw new a.ErrnoError(h);if(!l.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(d)||y&&a.isMountpoint(y))throw new a.ErrnoError(10);if(u!==l&&(h=a.nodePermissions(l,"w"),h))throw new a.ErrnoError(h);a.hashRemoveNode(d);try{l.node_ops.rename(d,u,i);}catch(g){throw g}finally{a.hashAddNode(d);}}},rmdir(e){var r=a.lookupPath(e,{parent:true}),t=r.node,n=F.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,true);if(i)throw new a.ErrnoError(i);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(o);},readdir(e){var r=a.lookupPath(e,{follow:true}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=a.lookupPath(e,{parent:true}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=F.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,false);if(i)throw new a.ErrnoError(i);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(o);},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 Q.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return a.stat(e,true)},chmod(e,r,t){var n;if(typeof e=="string"){var o=a.lookupPath(e,{follow:!t});n=o.node;}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()});},lchmod(e,r){a.chmod(e,r,true);},fchmod(e,r){var t=a.getStreamChecked(e);a.chmod(t.node,r);},chown(e,r,t,n){var o;if(typeof e=="string"){var i=a.lookupPath(e,{follow:!n});o=i.node;}else o=e;if(!o.node_ops.setattr)throw new a.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()});},lchown(e,r,t){a.chown(e,r,t,true);},fchown(e,r,t){var n=a.getStreamChecked(e);a.chown(n.node,r,t);},truncate(e,r){if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:true});t=n.node;}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var o=a.nodePermissions(t,"w");if(o)throw new a.ErrnoError(o);t.node_ops.setattr(t,{size:r,timestamp:Date.now()});},ftruncate(e,r){var t=a.getStreamChecked(e);if((t.flags&2097155)===0)throw new a.ErrnoError(28);a.truncate(t.node,r);},utime(e,r,t){var n=a.lookupPath(e,{follow:true}),o=n.node;o.node_ops.setattr(o,{timestamp:Math.max(r,t)});},open(e,r,t){if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?Zn(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else {e=F.normalize(e);try{var o=a.lookupPath(e,{follow:!(r&131072)});n=o.node;}catch{}}var i=false;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),i=true;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(!i){var s=a.mayOpen(n,r);if(s)throw new a.ErrnoError(s)}r&512&&!i&&a.truncate(n,0),r&=-131713;var l=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:true,position:0,stream_ops:n.stream_ops,ungotten:[],error:false});return l.stream_ops.open&&l.stream_ops.open(l),f.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),l},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,o){if(n<0||o<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 i=typeof o<"u";if(!i)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,o);return i||(e.position+=s),s},write(e,r,t,n,o,i){if(n<0||o<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 o<"u";if(!s)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,o,i);return s||(e.position+=l),l},allocate(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t);},mmap(e,r,t,n,o){if((n&2)!==0&&(o&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);return e.stream_ops.mmap(e,r,t,n,o)},msync(e,r,t,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):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={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=a.open(e,r.flags),o=a.stat(e),i=o.size,s=new Uint8Array(i);return a.read(n,s,0,i,0),r.encoding==="utf8"?t=ce(s,0):r.encoding==="binary"&&(t=s),a.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var o=new Uint8Array(dr(r)+1),i=fr(r,o,0,o.length);a.write(n,o,0,i,void 0,t.canOwn);}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n);},cwd:()=>a.currentPath,chdir(e){var r=a.lookupPath(e,{follow:true});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,o,i,s,l)=>s}),a.mkdev("/dev/null",a.makedev(1,3)),te.register(a.makedev(5,0),te.default_tty_ops),te.register(a.makedev(6,0),te.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&&(r=Yr(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.node_ops={lookup(t,n){var o=+n,i=a.getStreamChecked(o),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return s.parent=s,s}},r}},{},"/proc/self/fd");},createStandardStreams(){f.stdin?a.createDevice("/dev","stdin",f.stdin):a.symlink("/dev/tty","/dev/stdin"),f.stdout?a.createDevice("/dev","stdout",null,f.stdout):a.symlink("/dev/tty","/dev/stdout"),f.stderr?a.createDevice("/dev","stderr",null,f.stderr):a.symlink("/dev/tty1","/dev/stderr");a.open("/dev/stdin",0);a.open("/dev/stdout",1);a.open("/dev/stderr",1);},staticInit(){[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>";}),a.nameTable=new Array(4096),a.mount(w,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:w};},init(e,r,t){a.init.initialized=true,f.stdin=e||f.stdin,f.stdout=r||f.stdout,f.stderr=t||f.stderr,a.createStandardStreams();},quit(){a.init.initialized=false;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r);}},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:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,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=F.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(o){n.error=o.errno;}return n},createPath(e,r,t,n){e=typeof e=="string"?e:a.getPath(e);for(var o=r.split("/").reverse();o.length;){var i=o.pop();if(i){var s=F.join2(e,i);try{a.mkdir(s);}catch{}e=s;}}return s},createFile(e,r,t,n,o){var i=F.join2(typeof e=="string"?e:a.getPath(e),r),s=mr(n,o);return a.create(i,s)},createDataFile(e,r,t,n,o,i){var s=r;e&&(e=typeof e=="string"?e:a.getPath(e),s=r?F.join2(e,r):e);var l=mr(n,o),u=a.create(s,l);if(t){if(typeof t=="string"){for(var d=new Array(t.length),v=0,y=t.length;v<y;++v)d[v]=t.charCodeAt(v);t=d;}a.chmod(u,l|146);var p=a.open(u,577);a.write(p,t,0,t.length,0,i),a.close(p),a.chmod(u,l);}},createDevice(e,r,t,n){var o=F.join2(typeof e=="string"?e:a.getPath(e),r),i=mr(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(l){l.seekable=false;},close(l){n?.buffer?.length&&n(10);},read(l,u,d,v,y){for(var p=0,h=0;h<v;h++){var g;try{g=t();}catch{throw new a.ErrnoError(29)}if(g===void 0&&p===0)throw new a.ErrnoError(6);if(g==null)break;p++,u[d+h]=g;}return p&&(l.node.timestamp=Date.now()),p},write(l,u,d,v,y){for(var p=0;p<v;p++)try{n(u[d+p]);}catch{throw new a.ErrnoError(29)}return v&&(l.node.timestamp=Date.now()),p}}),a.mkdev(o,i,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return true;if(typeof XMLHttpRequest<"u")throw new Error("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.");if(me)try{e.contents=He(me(e.url),!0),e.usedBytes=e.contents.length;}catch{throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(e,r,t,n,o){class i{constructor(){this.lengthKnown=false,this.chunks=[];}get(h){if(!(h>this.length-1||h<0)){var g=h%this.chunkSize,D=h/this.chunkSize|0;return this.getter(D)[g]}}setDataGetter(h){this.getter=h;}cacheLength(){var h=new XMLHttpRequest;if(h.open("HEAD",t,false),h.send(null),!(h.status>=200&&h.status<300||h.status===304))throw new Error("Couldn't load "+t+". Status: "+h.status);var g=Number(h.getResponseHeader("Content-length")),D,A=(D=h.getResponseHeader("Accept-Ranges"))&&D==="bytes",T=(D=h.getResponseHeader("Content-Encoding"))&&D==="gzip",c=1024*1024;A||(c=g);var m=(k,H)=>{if(k>H)throw new Error("invalid range ("+k+", "+H+") or no bytes requested!");if(H>g-1)throw new Error("only "+g+" bytes available! programmer error!");var R=new XMLHttpRequest;if(R.open("GET",t,false),g!==c&&R.setRequestHeader("Range","bytes="+k+"-"+H),R.responseType="arraybuffer",R.overrideMimeType&&R.overrideMimeType("text/plain; charset=x-user-defined"),R.send(null),!(R.status>=200&&R.status<300||R.status===304))throw new Error("Couldn't load "+t+". Status: "+R.status);return R.response!==void 0?new Uint8Array(R.response||[]):He(R.responseText||"",true)},M=this;M.setDataGetter(k=>{var H=k*c,R=(k+1)*c-1;if(R=Math.min(R,g-1),typeof M.chunks[k]>"u"&&(M.chunks[k]=m(H,R)),typeof M.chunks[k]>"u")throw new Error("doXHR failed!");return M.chunks[k]}),(T||!g)&&(c=g=1,g=this.getter(0).length,c=g,Xe("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=c,this.lengthKnown=true;}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!V)throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i,l={isDevice:false,contents:s};}else var l={isDevice:false,url:t};var u=a.createFile(e,r,l,n,o);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var d={},v=Object.keys(u.stream_ops);v.forEach(p=>{var h=u.stream_ops[p];d[p]=(...g)=>(a.forceLoadFile(u),h(...g));});function y(p,h,g,D,A){var T=p.node.contents;if(A>=T.length)return 0;var c=Math.min(T.length-A,D);if(T.slice)for(var m=0;m<c;m++)h[g+m]=T[A+m];else for(var m=0;m<c;m++)h[g+m]=T.get(A+m);return c}return d.read=(p,h,g,D,A)=>(a.forceLoadFile(u),y(p,h,g,D,A)),d.mmap=(p,h,g,D,A)=>{a.forceLoadFile(u);var T=qr();if(!T)throw new a.ErrnoError(48);return y(p,I,T,h,g),{ptr:T,allocated:true}},u.stream_ops=d,u}},ne={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(F.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else {var o=ne.getStreamFromFD(e);n=o.path;}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return F.join2(n,r)},doStat(e,r,t){var n=e(r);E[t>>2]=n.dev,E[t+4>>2]=n.mode,$[t+8>>2]=n.nlink,E[t+12>>2]=n.uid,E[t+16>>2]=n.gid,E[t+20>>2]=n.rdev,j=[n.size>>>0,(b=n.size,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+24>>2]=j[0],E[t+28>>2]=j[1],E[t+32>>2]=4096,E[t+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),s=n.ctime.getTime();return j=[Math.floor(o/1e3)>>>0,(b=Math.floor(o/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+40>>2]=j[0],E[t+44>>2]=j[1],$[t+48>>2]=o%1e3*1e3,j=[Math.floor(i/1e3)>>>0,(b=Math.floor(i/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+56>>2]=j[0],E[t+60>>2]=j[1],$[t+64>>2]=i%1e3*1e3,j=[Math.floor(s/1e3)>>>0,(b=Math.floor(s/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+72>>2]=j[0],E[t+76>>2]=j[1],$[t+80>>2]=s%1e3*1e3,j=[n.ino>>>0,(b=n.ino,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+88>>2]=j[0],E[t+92>>2]=j[1],0},doMsync(e,r,t,n,o){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var i=x.slice(e,e+t);a.msync(r,i,o,t,n);},varargs:void 0,get(){var e=E[+ne.varargs>>2];return ne.varargs+=4,e},getp(){return ne.get()},getStr(e){var r=ie(e);return r},getStreamFromFD(e){var r=a.getStreamChecked(e);return r}};function ea(e){try{var r=ne.getStreamFromFD(e);return a.close(r),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var ra=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=$[r>>2],l=$[r+4>>2];r+=8;var u=a.read(e,I,s,l,n);if(u<0)return -1;if(o+=u,u<l)break;}return o};function ta(e,r,t,n){try{var o=ne.getStreamFromFD(e),i=ra(o,r,t);return $[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var na=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN;function aa(e,r,t,n,o){var i=na(r,t);try{if(isNaN(i))return 61;var s=ne.getStreamFromFD(e);return a.llseek(s,i,n),j=[s.position>>>0,(b=s.position,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[o>>2]=j[0],E[o+4>>2]=j[1],s.getdents&&i===0&&n===0&&(s.getdents=null),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var oa=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=$[r>>2],l=$[r+4>>2];r+=8;var u=a.write(e,I,s,l,n);if(u<0)return -1;o+=u;}return o};function ia(e,r,t,n){try{var o=ne.getStreamFromFD(e),i=oa(o,r,t);return $[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Le=e=>e%4===0&&(e%100!==0||e%400===0),sa=(e,r)=>{for(var t=0,n=0;n<=r;t+=e[n++]);return t},Xr=[31,29,31,30,31,30,31,31,30,31,30,31],Gr=[31,28,31,30,31,30,31,31,30,31,30,31],la=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var n=Le(t.getFullYear()),o=t.getMonth(),i=(n?Xr:Gr)[o];if(r>i-t.getDate())r-=i-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t},ua=(e,r)=>{I.set(e,r);},fa=(e,r,t,n)=>{var o=$[n+40>>2],i={tm_sec:E[n>>2],tm_min:E[n+4>>2],tm_hour:E[n+8>>2],tm_mday:E[n+12>>2],tm_mon:E[n+16>>2],tm_year:E[n+20>>2],tm_wday:E[n+24>>2],tm_yday:E[n+28>>2],tm_isdst:E[n+32>>2],tm_gmtoff:E[n+36>>2],tm_zone:o?ie(o):""},s=ie(t),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in l)s=s.replace(new RegExp(u,"g"),l[u]);var d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],v=["January","February","March","April","May","June","July","August","September","October","November","December"];function y(c,m,M){for(var k=typeof c=="number"?c.toString():c||"";k.length<m;)k=M[0]+k;return k}function p(c,m){return y(c,m,"0")}function h(c,m){function M(H){return H<0?-1:H>0?1:0}var k;return (k=M(c.getFullYear()-m.getFullYear()))===0&&(k=M(c.getMonth()-m.getMonth()))===0&&(k=M(c.getDate()-m.getDate())),k}function g(c){switch(c.getDay()){case 0:return new Date(c.getFullYear()-1,11,29);case 1:return c;case 2:return new Date(c.getFullYear(),0,3);case 3:return new Date(c.getFullYear(),0,2);case 4:return new Date(c.getFullYear(),0,1);case 5:return new Date(c.getFullYear()-1,11,31);case 6:return new Date(c.getFullYear()-1,11,30)}}function D(c){var m=la(new Date(c.tm_year+1900,0,1),c.tm_yday),M=new Date(m.getFullYear(),0,4),k=new Date(m.getFullYear()+1,0,4),H=g(M),R=g(k);return h(H,m)<=0?h(R,m)<=0?m.getFullYear()+1:m.getFullYear():m.getFullYear()-1}var A={"%a":c=>d[c.tm_wday].substring(0,3),"%A":c=>d[c.tm_wday],"%b":c=>v[c.tm_mon].substring(0,3),"%B":c=>v[c.tm_mon],"%C":c=>{var m=c.tm_year+1900;return p(m/100|0,2)},"%d":c=>p(c.tm_mday,2),"%e":c=>y(c.tm_mday,2," "),"%g":c=>D(c).toString().substring(2),"%G":D,"%H":c=>p(c.tm_hour,2),"%I":c=>{var m=c.tm_hour;return m==0?m=12:m>12&&(m-=12),p(m,2)},"%j":c=>p(c.tm_mday+sa(Le(c.tm_year+1900)?Xr:Gr,c.tm_mon-1),3),"%m":c=>p(c.tm_mon+1,2),"%M":c=>p(c.tm_min,2),"%n":()=>`
|
|
5
|
-
`,"%p":c=>c.tm_hour>=0&&c.tm_hour<12?"AM":"PM","%S":c=>p(c.tm_sec,2),"%t":()=>" ","%u":c=>c.tm_wday||7,"%U":c=>{var m=c.tm_yday+7-c.tm_wday;return p(Math.floor(m/7),2)},"%V":c=>{var m=Math.floor((c.tm_yday+7-(c.tm_wday+6)%7)/7);if((c.tm_wday+371-c.tm_yday-2)%7<=2&&m++,m){if(m==53){var k=(c.tm_wday+371-c.tm_yday)%7;k!=4&&(k!=3||!Le(c.tm_year))&&(m=1);}}else {m=52;var M=(c.tm_wday+7-c.tm_yday-1)%7;(M==4||M==5&&Le(c.tm_year%400-1))&&m++;}return p(m,2)},"%w":c=>c.tm_wday,"%W":c=>{var m=c.tm_yday+7-(c.tm_wday+6)%7;return p(Math.floor(m/7),2)},"%y":c=>(c.tm_year+1900).toString().substring(2),"%Y":c=>c.tm_year+1900,"%z":c=>{var m=c.tm_gmtoff,M=m>=0;return m=Math.abs(m)/60,m=m/60*100+m%60,(M?"+":"-")+("0000"+m).slice(-4)},"%Z":c=>c.tm_zone,"%%":()=>"%"};s=s.replace(/%%/g,"\0\0");for(var u in A)s.includes(u)&&(s=s.replace(new RegExp(u,"g"),A[u](i)));s=s.replace(/\0\0/g,"%");var T=He(s,false);return T.length>r?0:(ua(T,e),T.length-1)},da=(e,r,t,n,o)=>fa(e,r,t,n);Ar=f.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},_t(),he=f.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Rt(),Dt(),Wt(),Hr=f.UnboundTypeError=Nt(Error,"UnboundTypeError"),Kt(),a.createPreloadedFile=Qn,a.staticInit();var ca={a:ht,p:yt,N:gt,C:wt,L:bt,n:Vt,A:qt,y:Xt,K:Qt,j:en,b:rn,w:nn,f:an,i:sn,e:ln,v:fn,r:yn,O:gn,s:wn,M:_n,o:En,z:$n,c:sr,P:kn,l:Fn,q:Sn,x:An,g:Rn,m:Mn,k:On,h:jn,d:In,t:Un,J:Bn,H:Hn,E:Nn,F:Vn,I:ea,G:ta,B:aa,u:ia,D:da},B=vt(),pr=e=>(pr=B.S)(e),Z=e=>(Z=B.U)(e),Kr=e=>(Kr=B.V)(e),Jr=e=>(Jr=B.W)(e);f.dynCall_ji=(e,r)=>(f.dynCall_ji=B.X)(e,r);f.dynCall_iij=(e,r,t,n)=>(f.dynCall_iij=B.Y)(e,r,t,n);f.dynCall_jiji=(e,r,t,n,o)=>(f.dynCall_jiji=B.Z)(e,r,t,n,o);f.dynCall_viijii=(e,r,t,n,o,i,s)=>(f.dynCall_viijii=B._)(e,r,t,n,o,i,s);f.dynCall_iiiiij=(e,r,t,n,o,i,s)=>(f.dynCall_iiiiij=B.$)(e,r,t,n,o,i,s);f.dynCall_iiiiijj=(e,r,t,n,o,i,s,l,u)=>(f.dynCall_iiiiijj=B.aa)(e,r,t,n,o,i,s,l,u);f.dynCall_iiiiiijj=(e,r,t,n,o,i,s,l,u,d)=>(f.dynCall_iiiiiijj=B.ba)(e,r,t,n,o,i,s,l,u,d);var ze;ge=function e(){ze||Qr(),ze||(ge=e);};function Qr(){if(ae>0||(at(),ae>0))return;function e(){ze||(ze=true,f.calledRun=true,!gr&&(ot(),_(f),f.onRuntimeInitialized&&f.onRuntimeInitialized(),it()));}f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("");},1),e();},1)):e();}if(f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.pop()();return Qr(),P.ready})})(),et=Ea;var Te=class{options;module=null;decoderInstance=null;constructor(P){this.options=P;}async initialize(){if(this.module)return;let P={};this.options?.locateFile&&(P.locateFile=this.options.locateFile),this.options?.wasmBinary&&(P.wasmBinary=this.options.wasmBinary),this.module=await et(P),this.decoderInstance=new this.module.HeicDecoder;}async decode(P,f){(!this.module||!this.decoderInstance)&&await this.initialize();let _=this.decoderInstance.decode(P,f||null);if(!_)throw new Error("HEIC decoding failed");if(typeof _=="string")throw new Error(`HEIC decoding failed: ${_}`);let O=_.width,z=_.height,G=new Uint8ClampedArray(_.data.buffer,_.data.byteOffset,_.data.byteLength);return {width:O,height:z,data:G}}free(){this.decoderInstance&&(this.decoderInstance.delete(),this.decoderInstance=null),this.module=null;}};async function ba(S){if(typeof FileReader<"u")return new Promise((P,f)=>{let _=new FileReader;_.onloadend=()=>{typeof _.result=="string"?P(_.result):f(new Error("Failed to convert Blob to base64 string"));},_.onerror=()=>f(_.error),_.readAsDataURL(S);});try{let P=await S.arrayBuffer(),f=Buffer.from(P);return `data:${S.type};base64,${f.toString("base64")}`}catch(P){throw new Error(`Failed to convert Blob to base64 string: ${P instanceof Error?P.message:String(P)}`,{cause:P})}}function yr(S,P,f){return "convertToBlob"in S?S.convertToBlob({type:P,quality:f}):new Promise((_,O)=>{S.toBlob(z=>{z?_(z):O(new Error("Failed to convert canvas to blob"));},P,f);})}async function rt(S,P,f){let{width:_,height:O,data:z}=S,G=_*O*4;if(z.length!==G)throw new Error(`Image data length mismatch. Expected ${G} bytes for ${_}x${O}, got ${z.length}`);let N;if(typeof OffscreenCanvas<"u")N=new OffscreenCanvas(_,O);else if(typeof document<"u")N=document.createElement("canvas"),N.width=_,N.height=O;else throw new Error("Canvas is not supported in the current environment. Conversion requires a browser environment or canvas polyfills.");let ee=N.getContext("2d");if(!ee)throw new Error("Failed to acquire 2D rendering context from canvas");let fe;if(typeof ImageData<"u")fe=new ImageData(z,_,O);else {let K=ee.createImageData(_,O);K.data.set(z),fe=K;}ee.putImageData(fe,0,0);let V=P.toLowerCase();if(V==="png")return yr(N,"image/png");if(V==="jpeg"||V==="jpg")return yr(N,"image/jpeg",f);if(V==="svg"){let K=await yr(N,"image/png"),L=await ba(K),Ne=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${_} ${O}" width="${_}" height="${O}">
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
`));if(!e)return null;Qe=Se(e,true);}return Qe.shift()},ae={ttys:[],init(){},shutdown(){},register(e,r){ae.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,ae.stream_ops);},stream_ops:{open(e){var r=ae.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=false;},close(e){e.tty.ops.fsync(e.tty);},fsync(e){e.tty.ops.fsync(e.tty);},read(e,r,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var i=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&&i===0)throw new a.ErrnoError(6);if(l==null)break;i++,r[t+s]=l;}return i&&(e.node.timestamp=Date.now()),i},write(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,r[t+i]);}catch{throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char(e){return gt()},put_char(e,r){r===null||r===10?(Xe(ce(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(Xe(ce(e.output,0)),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?(ne(ce(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(ne(ce(e.output,0)),e.output=[]);}}},Sr=e=>{fe();},w={ops_table:null,mount(e){return w.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);w.ops_table||={dir:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,lookup:w.node_ops.lookup,mknod:w.node_ops.mknod,rename:w.node_ops.rename,unlink:w.node_ops.unlink,rmdir:w.node_ops.rmdir,readdir:w.node_ops.readdir,symlink:w.node_ops.symlink},stream:{llseek:w.stream_ops.llseek}},file:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:{llseek:w.stream_ops.llseek,read:w.stream_ops.read,write:w.stream_ops.write,allocate:w.stream_ops.allocate,mmap:w.stream_ops.mmap,msync:w.stream_ops.msync}},link:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,readlink:w.node_ops.readlink},stream:{}},chrdev:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:a.chrdev_stream_ops}};var o=a.createNode(e,r,t,n);return a.isDir(o.mode)?(o.node_ops=w.ops_table.dir.node,o.stream_ops=w.ops_table.dir.stream,o.contents={}):a.isFile(o.mode)?(o.node_ops=w.ops_table.file.node,o.stream_ops=w.ops_table.file.stream,o.usedBytes=0,o.contents=null):a.isLink(o.mode)?(o.node_ops=w.ops_table.link.node,o.stream_ops=w.ops_table.link.stream):a.isChrdev(o.mode)&&(o.node_ops=w.ops_table.chrdev.node,o.stream_ops=w.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[r]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var o=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(o.subarray(0,e.usedBytes),0);}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else {var t=e.contents;e.contents=new Uint8Array(r),t&&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.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&w.resizeFileStorage(e,r.size);},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return w.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t);}catch{}if(n)for(var o in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r;},unlink(e,r){delete e.contents[r],e.timestamp=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.timestamp=Date.now();},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var n=w.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,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(s>8&&i.subarray)r.set(i.subarray(o,o+s),t);else for(var l=0;l<s;l++)r[t+l]=i[o+l];return s},write(e,r,t,n,o,i){if(r.buffer===H.buffer&&(i=false),!n)return 0;var s=e.node;if(s.timestamp=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=r.subarray(t,t+n),s.usedBytes=n,n;if(s.usedBytes===0&&o===0)return s.contents=r.slice(t,t+n),s.usedBytes=n,n;if(o+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),o),n}if(w.expandFileStorage(s,o+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),o);else for(var l=0;l<n;l++)s.contents[o+l]=r[t+l];return s.usedBytes=Math.max(s.usedBytes,o+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},allocate(e,r,t){w.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t);},mmap(e,r,t,n,o){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var i,s,l=e.node.contents;if(!(o&2)&&l.buffer===H.buffer)s=false,i=l.byteOffset;else {if((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),s=true,i=Sr(),!i)throw new a.ErrnoError(48);H.set(l,i);}return {ptr:i,allocated:s}},msync(e,r,t,n,o){return w.stream_ops.write(e,r,0,n,t,false),0}}},wt=(e,r,t,n)=>{var o=`al ${e}`;Ve(e,i=>{r(new Uint8Array(i)),o&&Ae();},i=>{if(t)t();else throw `Loading data file "${e}" failed.`}),o&&Ke();},_t=(e,r,t,n,o,i)=>{a.createDataFile(e,r,t,n,o,i);},Et=d.preloadPlugins||[],bt=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var o=false;return Et.forEach(i=>{o||i.canHandle(r)&&(i.handle(e,r,t,n),o=true);}),o},$t=(e,r,t,n,o,i,s,l,u,f)=>{var v=r?Z.resolve(A.join2(e,r)):e;function p(h){function g(D){f?.(),l||_t(e,r,D,n,o,u),i?.(),Ae();}bt(h,v,g,()=>{s?.(),Ae();})||g(h);}Ke(),typeof t=="string"?wt(t,p,s):p(t);},kt=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},rr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e;}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.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{constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=a.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146;}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=Z.resolve(e),!e)return {path:"",node:null};var t={follow_mount:true,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(y=>!!y),o=a.root,i="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(o=a.lookupNode(o,n[s]),i=A.join2(i,n[s]),a.isMountpoint(o)&&(!l||l&&r.follow_mount)&&(o=o.mounted.root),!l||r.follow)for(var u=0;a.isLink(o.mode);){var f=a.readlink(i);i=Z.resolve(A.dirname(i),f);var v=a.lookupPath(i,{recurse_count:r.recurse_count+1});if(o=v.node,u++>40)throw new a.ErrnoError(32)}}return {path:i,node:o}},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),o=a.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===r)return o}return a.lookup(e,r)},createNode(e,r,t,n){var o=new a.FSNode(e,r,t,n);return a.hashAddNode(o),o},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){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(i){return i.errno}var o=a.nodePermissions(e,"wx");if(o)return o;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){return e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44},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 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},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=false),a.syncFSRequests++,a.syncFSRequests>1&&ne(`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 o(s){return a.syncFSRequests--,r(s)}function i(s){if(s)return i.errored?void 0:(i.errored=true,o(s));++n>=t.length&&o(null);}t.forEach(s=>{if(!s.type.syncfs)return i(null);s.type.syncfs(s,e,i);});},mount(e,r,t){var n=t==="/",o=!t,i;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!o){var s=a.lookupPath(t,{follow_mount:false});if(t=s.path,i=s.node,a.isMountpoint(i))throw new a.ErrnoError(10);if(!a.isDir(i.mode))throw new a.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(l);return u.mount=l,l.root=u,n?a.root=u:i&&(i.mounted=l,i.mount&&i.mount.mounts.push(l)),u},unmount(e){var r=a.lookupPath(e,{follow_mount:false});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,o=a.getMounts(n);Object.keys(a.nameTable).forEach(s=>{for(var l=a.nameTable[s];l;){var u=l.name_next;o.includes(l.mount)&&a.destroyNode(l),l=u;}}),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1);},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=a.lookupPath(e,{parent:true}),o=n.node,i=A.basename(e);if(!i||i==="."||i==="..")throw new a.ErrnoError(28);var s=a.mayCreate(o,i);if(s)throw new a.ErrnoError(s);if(!o.node_ops.mknod)throw new a.ErrnoError(63);return o.node_ops.mknod(o,i,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{a.mkdir(n,r);}catch(i){if(i.errno!=20)throw i}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)},symlink(e,r){if(!Z.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:true}),n=t.node;if(!n)throw new a.ErrnoError(44);var o=A.basename(r),i=a.mayCreate(n,o);if(i)throw new a.ErrnoError(i);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,o,e)},rename(e,r){var t=A.dirname(e),n=A.dirname(r),o=A.basename(e),i=A.basename(r),s,l,u;if(s=a.lookupPath(e,{parent:true}),l=s.node,s=a.lookupPath(r,{parent:true}),u=s.node,!l||!u)throw new a.ErrnoError(44);if(l.mount!==u.mount)throw new a.ErrnoError(75);var f=a.lookupNode(l,o),v=Z.relative(e,n);if(v.charAt(0)!==".")throw new a.ErrnoError(28);if(v=Z.relative(r,t),v.charAt(0)!==".")throw new a.ErrnoError(55);var y;try{y=a.lookupNode(u,i);}catch{}if(f!==y){var p=a.isDir(f.mode),h=a.mayDelete(l,o,p);if(h)throw new a.ErrnoError(h);if(h=y?a.mayDelete(u,i,p):a.mayCreate(u,i),h)throw new a.ErrnoError(h);if(!l.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(f)||y&&a.isMountpoint(y))throw new a.ErrnoError(10);if(u!==l&&(h=a.nodePermissions(l,"w"),h))throw new a.ErrnoError(h);a.hashRemoveNode(f);try{l.node_ops.rename(f,u,i);}catch(g){throw g}finally{a.hashAddNode(f);}}},rmdir(e){var r=a.lookupPath(e,{parent:true}),t=r.node,n=A.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,true);if(i)throw new a.ErrnoError(i);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(o);},readdir(e){var r=a.lookupPath(e,{follow:true}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=a.lookupPath(e,{parent:true}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=A.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,false);if(i)throw new a.ErrnoError(i);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(o);},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 Z.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return a.stat(e,true)},chmod(e,r,t){var n;if(typeof e=="string"){var o=a.lookupPath(e,{follow:!t});n=o.node;}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()});},lchmod(e,r){a.chmod(e,r,true);},fchmod(e,r){var t=a.getStreamChecked(e);a.chmod(t.node,r);},chown(e,r,t,n){var o;if(typeof e=="string"){var i=a.lookupPath(e,{follow:!n});o=i.node;}else o=e;if(!o.node_ops.setattr)throw new a.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()});},lchown(e,r,t){a.chown(e,r,t,true);},fchown(e,r,t){var n=a.getStreamChecked(e);a.chown(n.node,r,t);},truncate(e,r){if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:true});t=n.node;}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var o=a.nodePermissions(t,"w");if(o)throw new a.ErrnoError(o);t.node_ops.setattr(t,{size:r,timestamp:Date.now()});},ftruncate(e,r){var t=a.getStreamChecked(e);if((t.flags&2097155)===0)throw new a.ErrnoError(28);a.truncate(t.node,r);},utime(e,r,t){var n=a.lookupPath(e,{follow:true}),o=n.node;o.node_ops.setattr(o,{timestamp:Math.max(r,t)});},open(e,r,t){if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?kt(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else {e=A.normalize(e);try{var o=a.lookupPath(e,{follow:!(r&131072)});n=o.node;}catch{}}var i=false;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),i=true;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(!i){var s=a.mayOpen(n,r);if(s)throw new a.ErrnoError(s)}r&512&&!i&&a.truncate(n,0),r&=-131713;var l=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:true,position:0,stream_ops:n.stream_ops,ungotten:[],error:false});return l.stream_ops.open&&l.stream_ops.open(l),d.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),l},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,o){if(n<0||o<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 i=typeof o<"u";if(!i)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,o);return i||(e.position+=s),s},write(e,r,t,n,o,i){if(n<0||o<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 o<"u";if(!s)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,o,i);return s||(e.position+=l),l},allocate(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t);},mmap(e,r,t,n,o){if((n&2)!==0&&(o&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);return e.stream_ops.mmap(e,r,t,n,o)},msync(e,r,t,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):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={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=a.open(e,r.flags),o=a.stat(e),i=o.size,s=new Uint8Array(i);return a.read(n,s,0,i,0),r.encoding==="utf8"?t=ce(s,0):r.encoding==="binary"&&(t=s),a.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var o=new Uint8Array(Ze(r)+1),i=er(r,o,0,o.length);a.write(n,o,0,i,void 0,t.canOwn);}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n);},cwd:()=>a.currentPath,chdir(e){var r=a.lookupPath(e,{follow:true});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,o,i,s,l)=>s}),a.mkdev("/dev/null",a.makedev(1,3)),ae.register(a.makedev(5,0),ae.default_tty_ops),ae.register(a.makedev(6,0),ae.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&&(r=Ar(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.node_ops={lookup(t,n){var o=+n,i=a.getStreamChecked(o),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return s.parent=s,s}},r}},{},"/proc/self/fd");},createStandardStreams(){d.stdin?a.createDevice("/dev","stdin",d.stdin):a.symlink("/dev/tty","/dev/stdin"),d.stdout?a.createDevice("/dev","stdout",null,d.stdout):a.symlink("/dev/tty","/dev/stdout"),d.stderr?a.createDevice("/dev","stderr",null,d.stderr):a.symlink("/dev/tty1","/dev/stderr");a.open("/dev/stdin",0);a.open("/dev/stdout",1);a.open("/dev/stderr",1);},staticInit(){[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>";}),a.nameTable=new Array(4096),a.mount(w,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:w};},init(e,r,t){a.init.initialized=true,d.stdin=e||d.stdin,d.stdout=r||d.stdout,d.stderr=t||d.stderr,a.createStandardStreams();},quit(){a.init.initialized=false;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r);}},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:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,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=A.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(o){n.error=o.errno;}return n},createPath(e,r,t,n){e=typeof e=="string"?e:a.getPath(e);for(var o=r.split("/").reverse();o.length;){var i=o.pop();if(i){var s=A.join2(e,i);try{a.mkdir(s);}catch{}e=s;}}return s},createFile(e,r,t,n,o){var i=A.join2(typeof e=="string"?e:a.getPath(e),r),s=rr(n,o);return a.create(i,s)},createDataFile(e,r,t,n,o,i){var s=r;e&&(e=typeof e=="string"?e:a.getPath(e),s=r?A.join2(e,r):e);var l=rr(n,o),u=a.create(s,l);if(t){if(typeof t=="string"){for(var f=new Array(t.length),v=0,y=t.length;v<y;++v)f[v]=t.charCodeAt(v);t=f;}a.chmod(u,l|146);var p=a.open(u,577);a.write(p,t,0,t.length,0,i),a.close(p),a.chmod(u,l);}},createDevice(e,r,t,n){var o=A.join2(typeof e=="string"?e:a.getPath(e),r),i=rr(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(l){l.seekable=false;},close(l){n?.buffer?.length&&n(10);},read(l,u,f,v,y){for(var p=0,h=0;h<v;h++){var g;try{g=t();}catch{throw new a.ErrnoError(29)}if(g===void 0&&p===0)throw new a.ErrnoError(6);if(g==null)break;p++,u[f+h]=g;}return p&&(l.node.timestamp=Date.now()),p},write(l,u,f,v,y){for(var p=0;p<v;p++)try{n(u[f+p]);}catch{throw new a.ErrnoError(29)}return v&&(l.node.timestamp=Date.now()),p}}),a.mkdev(o,i,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return true;if(typeof XMLHttpRequest<"u")throw new Error("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.");if(me)try{e.contents=Se(me(e.url),!0),e.usedBytes=e.contents.length;}catch{throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(e,r,t,n,o){class i{constructor(){this.lengthKnown=false,this.chunks=[];}get(h){if(!(h>this.length-1||h<0)){var g=h%this.chunkSize,D=h/this.chunkSize|0;return this.getter(D)[g]}}setDataGetter(h){this.getter=h;}cacheLength(){var h=new XMLHttpRequest;if(h.open("HEAD",t,false),h.send(null),!(h.status>=200&&h.status<300||h.status===304))throw new Error("Couldn't load "+t+". Status: "+h.status);var g=Number(h.getResponseHeader("Content-length")),D,R=(D=h.getResponseHeader("Accept-Ranges"))&&D==="bytes",T=(D=h.getResponseHeader("Content-Encoding"))&&D==="gzip",c=1024*1024;R||(c=g);var m=(P,N)=>{if(P>N)throw new Error("invalid range ("+P+", "+N+") or no bytes requested!");if(N>g-1)throw new Error("only "+g+" bytes available! programmer error!");var M=new XMLHttpRequest;if(M.open("GET",t,false),g!==c&&M.setRequestHeader("Range","bytes="+P+"-"+N),M.responseType="arraybuffer",M.overrideMimeType&&M.overrideMimeType("text/plain; charset=x-user-defined"),M.send(null),!(M.status>=200&&M.status<300||M.status===304))throw new Error("Couldn't load "+t+". Status: "+M.status);return M.response!==void 0?new Uint8Array(M.response||[]):Se(M.responseText||"",true)},O=this;O.setDataGetter(P=>{var N=P*c,M=(P+1)*c-1;if(M=Math.min(M,g-1),typeof O.chunks[P]>"u"&&(O.chunks[P]=m(N,M)),typeof O.chunks[P]>"u")throw new Error("doXHR failed!");return O.chunks[P]}),(T||!g)&&(c=g=1,g=this.getter(0).length,c=g,Xe("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=c,this.lengthKnown=true;}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!j)throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i,l={isDevice:false,contents:s};}else var l={isDevice:false,url:t};var u=a.createFile(e,r,l,n,o);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var f={},v=Object.keys(u.stream_ops);v.forEach(p=>{var h=u.stream_ops[p];f[p]=(...g)=>(a.forceLoadFile(u),h(...g));});function y(p,h,g,D,R){var T=p.node.contents;if(R>=T.length)return 0;var c=Math.min(T.length-R,D);if(T.slice)for(var m=0;m<c;m++)h[g+m]=T[R+m];else for(var m=0;m<c;m++)h[g+m]=T.get(R+m);return c}return f.read=(p,h,g,D,R)=>(a.forceLoadFile(u),y(p,h,g,D,R)),f.mmap=(p,h,g,D,R)=>{a.forceLoadFile(u);var T=Sr();if(!T)throw new a.ErrnoError(48);return y(p,H,T,h,g),{ptr:T,allocated:true}},u.stream_ops=f,u}},X={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(A.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else {var o=X.getStreamFromFD(e);n=o.path;}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return A.join2(n,r)},doStat(e,r,t){var n=e(r);E[t>>2]=n.dev,E[t+4>>2]=n.mode,k[t+8>>2]=n.nlink,E[t+12>>2]=n.uid,E[t+16>>2]=n.gid,E[t+20>>2]=n.rdev,U=[n.size>>>0,(b=n.size,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+24>>2]=U[0],E[t+28>>2]=U[1],E[t+32>>2]=4096,E[t+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),s=n.ctime.getTime();return U=[Math.floor(o/1e3)>>>0,(b=Math.floor(o/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+40>>2]=U[0],E[t+44>>2]=U[1],k[t+48>>2]=o%1e3*1e3,U=[Math.floor(i/1e3)>>>0,(b=Math.floor(i/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+56>>2]=U[0],E[t+60>>2]=U[1],k[t+64>>2]=i%1e3*1e3,U=[Math.floor(s/1e3)>>>0,(b=Math.floor(s/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+72>>2]=U[0],E[t+76>>2]=U[1],k[t+80>>2]=s%1e3*1e3,U=[n.ino>>>0,(b=n.ino,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+88>>2]=U[0],E[t+92>>2]=U[1],0},doMsync(e,r,t,n,o){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var i=L.slice(e,e+t);a.msync(r,i,o,t,n);},varargs:void 0,get(){var e=E[+X.varargs>>2];return X.varargs+=4,e},getp(){return X.get()},getStr(e){var r=se(e);return r},getStreamFromFD(e){var r=a.getStreamChecked(e);return r}};function Pt(e,r,t){try{return r=X.getStr(r),r=X.calculateAt(e,r),t===0?a.unlink(r):t===512?a.rmdir(r):fe("Invalid flags passed to unlinkat"),0}catch(n){if(typeof a>"u"||n.name!=="ErrnoError")throw n;return -n.errno}}var Re={},tr=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r);}};function we(e){return this.fromWireType(k[e>>2])}var ve={},le={},Me={},Rr,je=e=>{throw new Rr(e)},ue=(e,r,t)=>{e.forEach(function(l){Me[l]=r;});function n(l){var u=t(l);u.length!==e.length&&je("Mismatched type converter count");for(var f=0;f<e.length;++f)G(e[f],u[f]);}var o=new Array(r.length),i=[],s=0;r.forEach((l,u)=>{le.hasOwnProperty(l)?o[u]=le[l]:(i.push(l),ve.hasOwnProperty(l)||(ve[l]=[]),ve[l].push(()=>{o[u]=le[l],++s,s===i.length&&n(o);}));}),i.length===0&&n(o);},Ct=e=>{var r=Re[e];delete Re[e];var t=r.rawConstructor,n=r.rawDestructor,o=r.fields,i=o.map(s=>s.getterReturnType).concat(o.map(s=>s.setterArgumentType));ue([e],i,s=>{var l={};return o.forEach((u,f)=>{var v=u.fieldName,y=s[f],p=u.getter,h=u.getterContext,g=s[f+o.length],D=u.setter,R=u.setterContext;l[v]={read:T=>y.fromWireType(p(h,T)),write:(T,c)=>{var m=[];D(R,T,g.toWireType(m,c)),tr(m);}};}),[{name:r.name,fromWireType:u=>{var f={};for(var v in l)f[v]=l[v].read(u);return n(u),f},toWireType:(u,f)=>{for(var v in l)if(!(v in f))throw new TypeError(`Missing field: "${v}"`);var y=t();for(v in l)l[v].write(y,f[v]);return u!==null&&u.push(n,y),y},argPackAdvance:K,readValueFromPointer:we,destructorFunction:n}]});},Tt=(e,r,t,n,o)=>{},Dt=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Mr=e;},Mr,W=e=>{for(var r="",t=e;L[t];)r+=Mr[L[t++]];return r},he,C=e=>{throw new he(e)};function Ft(e,r,t={}){var n=r.name;if(e||C(`type "${n}" must have a positive integer typeid pointer`),le.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;C(`Cannot register type '${n}' twice`);}if(le[e]=r,delete Me[e],ve.hasOwnProperty(e)){var o=ve[e];delete ve[e],o.forEach(i=>i());}}function G(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Ft(e,r,t)}var K=8,At=(e,r,t,n)=>{r=W(r),G(e,{name:r,fromWireType:function(o){return !!o},toWireType:function(o,i){return i?t:n},argPackAdvance:K,readValueFromPointer:function(o){return this.fromWireType(L[o])},destructorFunction:null});},St=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),nr=e=>{function r(t){return t.$$.ptrType.registeredClass.name}C(r(e)+" instance already deleted");},ar=false,jr=e=>{},Rt=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr);},Or=e=>{e.count.value-=1;var r=e.count.value===0;r&&Rt(e);},Ir=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=Ir(e,r,t.baseClass);return n===null?null:t.downcast(n)},Ur={},Mt=()=>Object.keys(be).length,jt=()=>{var e=[];for(var r in be)be.hasOwnProperty(r)&&e.push(be[r]);return e},_e=[],or=()=>{for(;_e.length;){var e=_e.pop();e.$$.deleteScheduled=false,e.delete();}},Ee,Ot=e=>{Ee=e,_e.length&&Ee&&Ee(or);},It=()=>{d.getInheritedInstanceCount=Mt,d.getLiveInheritedInstances=jt,d.flushPendingDeletes=or,d.setDelayFunction=Ot;},be={},Ut=(e,r)=>{for(r===void 0&&C("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},Bt=(e,r)=>(r=Ut(e,r),be[r]),Oe=(e,r)=>{(!r.ptrType||!r.ptr)&&je("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&je("Both smartPtrType and smartPtr must be specified"),r.count={value:1},$e(Object.create(e,{$$:{value:r,writable:true}}))};function xt(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Bt(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 o(){return this.isSmartPointer?Oe(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Oe(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i=this.registeredClass.getActualType(r),s=Ur[i];if(!s)return o.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var u=Ir(r,this.registeredClass,l.registeredClass);return u===null?o.call(this):this.isSmartPointer?Oe(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:e}):Oe(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var $e=e=>typeof FinalizationRegistry>"u"?($e=r=>r,e):(ar=new FinalizationRegistry(r=>{Or(r.$$);}),$e=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var o={$$:t};ar.register(r,o,r);}return r},jr=r=>ar.unregister(r),$e(e)),Ht=()=>{Object.assign(Ie.prototype,{isAliasOf(e){if(!(this instanceof Ie)||!(e instanceof Ie))return false;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,o=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return r===n&&t===o},clone(){if(this.$$.ptr||nr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=$e(Object.create(Object.getPrototypeOf(this),{$$:{value:St(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=false,e},delete(){this.$$.ptr||nr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&C("Object already scheduled for deletion"),jr(this),Or(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0);},isDeleted(){return !this.$$.ptr},deleteLater(){return this.$$.ptr||nr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&C("Object already scheduled for deletion"),_e.push(this),_e.length===1&&Ee&&Ee(or),this.$$.deleteScheduled=true,this}});};function Ie(){}var ke=(e,r)=>Object.defineProperty(r,"name",{value:e}),Br=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...o){return e[r].overloadTable.hasOwnProperty(o.length)||C(`Function '${t}' called with an invalid number of arguments (${o.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[o.length].apply(this,o)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n;}},ir=(e,r,t)=>{d.hasOwnProperty(e)?((t===void 0||d[e].overloadTable!==void 0&&d[e].overloadTable[t]!==void 0)&&C(`Cannot register public name '${e}' twice`),Br(d,e,e),d.hasOwnProperty(t)&&C(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),d[e].overloadTable[t]=r):(d[e]=r,t!==void 0&&(d[e].numArguments=t));},Wt=48,Lt=57,zt=e=>{if(e===void 0)return "_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Wt&&r<=Lt?`_${e}`:e};function Nt(e,r,t,n,o,i,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[];}var sr=(e,r,t)=>{for(;r!==t;)r.upcast||C(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function Vt(e,r){if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),0;r.$$||C(`Cannot pass "${vr(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=sr(r.$$.ptr,t,this.registeredClass);return n}function Yt(e,r){var t;if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&C(`Cannot pass "${vr(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&C(`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=sr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&C("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:C(`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 o=r.clone();t=this.rawShare(t,z.toHandle(()=>o.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:C("Unsupporting sharing policy");}return t}function qt(e,r){if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),0;r.$$||C(`Cannot pass "${vr(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&C(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=sr(r.$$.ptr,t,this.registeredClass);return n}var Xt=()=>{Object.assign(Ue.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e);},argPackAdvance:K,readValueFromPointer:we,fromWireType:xt});};function Ue(e,r,t,n,o,i,s,l,u,f,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=f,this.rawDestructor=v,!o&&r.baseClass===void 0?n?(this.toWireType=Vt,this.destructorFunction=null):(this.toWireType=qt,this.destructorFunction=null):this.toWireType=Yt;}var xr=(e,r,t)=>{d.hasOwnProperty(e)||je("Replacing nonexistent public symbol"),d[e].overloadTable!==void 0&&t!==void 0?d[e].overloadTable[t]=r:(d[e]=r,d[e].argCount=t);},Gt=(e,r,t)=>{var n=d["dynCall_"+e];return n(r,...t)},Be=[],Hr,Wr=e=>{var r=Be[e];return r||(e>=Be.length&&(Be.length=e+1),Be[e]=r=Hr.get(e)),r},Kt=(e,r,t=[])=>{if(e.includes("j"))return Gt(e,r,t);var n=Wr(r)(...t);return n},Jt=(e,r)=>(...t)=>Kt(e,r,t),q=(e,r)=>{e=W(e);function t(){return e.includes("j")?Jt(e,r):Wr(r)}var n=t();return typeof n!="function"&&C(`unknown function pointer with signature ${e}: ${r}`),n},Qt=(e,r)=>{var t=ke(r,function(n){this.name=r,this.message=n;var o=new Error(n).stack;o!==void 0&&(this.stack=this.toString()+`
|
|
4
|
+
`+o.replace(/^Error(:[^\n]*)?\n/,""));});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},Lr,zr=e=>{var r=Gr(e),t=W(r);return re(r),t},xe=(e,r)=>{var t=[],n={};function o(i){if(!n[i]&&!le[i]){if(Me[i]){Me[i].forEach(o);return}t.push(i),n[i]=true;}}throw r.forEach(o),new Lr(`${e}: `+t.map(zr).join([", "]))},Zt=(e,r,t,n,o,i,s,l,u,f,v,y,p)=>{v=W(v),i=q(o,i),l&&=q(s,l),f&&=q(u,f),p=q(y,p);var h=zt(v);ir(h,function(){xe(`Cannot construct ${v} due to unbound types`,[n]);}),ue([e,r,t],n?[n]:[],g=>{g=g[0];var D,R;n?(D=g.registeredClass,R=D.instancePrototype):R=Ie.prototype;var T=ke(v,function(...M){if(Object.getPrototypeOf(this)!==c)throw new he("Use 'new' to construct "+v);if(m.constructor_body===void 0)throw new he(v+" has no accessible constructor");var Qr=m.constructor_body[M.length];if(Qr===void 0)throw new he(`Tried to invoke ctor of ${v} with invalid number of parameters (${M.length}) - expected (${Object.keys(m.constructor_body).toString()}) parameters instead!`);return Qr.apply(this,M)}),c=Object.create(R,{constructor:{value:T}});T.prototype=c;var m=new Nt(v,T,c,p,D,i,l,f);m.baseClass&&(m.baseClass.__derivedClasses??=[],m.baseClass.__derivedClasses.push(m));var O=new Ue(v,m,true,false,false),P=new Ue(v+"*",m,false,false,false),N=new Ue(v+" const*",m,false,true,false);return Ur[e]={pointerType:P,constPointerType:N},xr(h,T),[O,P,N]});},lr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(k[r+n*4>>2]);return t};function en(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return true;return false}function ur(e,r,t,n,o,i){var s=r.length;s<2&&C("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=r[1]!==null&&t!==null,u=en(r),f=r[0].name!=="void",v=s-2,y=new Array(v),p=[],h=[],g=function(...D){D.length!==v&&C(`function ${e} called with ${D.length} arguments, expected ${v}`),h.length=0;var R;p.length=l?2:1,p[0]=o,l&&(R=r[1].toWireType(h,this),p[1]=R);for(var T=0;T<v;++T)y[T]=r[T+2].toWireType(h,D[T]),p.push(y[T]);var c=n(...p);function m(O){if(u)tr(h);else for(var P=l?1:2;P<r.length;P++){var N=P===1?R:y[P-2];r[P].destructorFunction!==null&&r[P].destructorFunction(N);}if(f)return r[0].fromWireType(O)}return m(c)};return ke(e,g)}var rn=(e,r,t,n,o,i)=>{var s=lr(r,t);o=q(n,o),ue([],[e],l=>{l=l[0];var u=`constructor ${l.name}`;if(l.registeredClass.constructor_body===void 0&&(l.registeredClass.constructor_body=[]),l.registeredClass.constructor_body[r-1]!==void 0)throw new he(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${l.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return l.registeredClass.constructor_body[r-1]=()=>{xe(`Cannot construct ${l.name} due to unbound types`,s);},ue([],s,f=>(f.splice(1,0,null),l.registeredClass.constructor_body[r-1]=ur(u,f,null,o,i),[])),[]});},Nr=e=>{e=e.trim();let r=e.indexOf("(");return r!==-1?e.substr(0,r):e},tn=(e,r,t,n,o,i,s,l,u)=>{var f=lr(t,n);r=W(r),r=Nr(r),i=q(o,i),ue([],[e],v=>{v=v[0];var y=`${v.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&v.registeredClass.pureVirtualFunctions.push(r);function p(){xe(`Cannot call ${y} due to unbound types`,f);}var h=v.registeredClass.instancePrototype,g=h[r];return g===void 0||g.overloadTable===void 0&&g.className!==v.name&&g.argCount===t-2?(p.argCount=t-2,p.className=v.name,h[r]=p):(Br(h,r,y),h[r].overloadTable[t-2]=p),ue([],f,D=>{var R=ur(y,D,v,i,s);return h[r].overloadTable===void 0?(R.argCount=t-2,h[r]=R):h[r].overloadTable[t-2]=R,[]}),[]});},dr=[],ee=[],fr=e=>{e>9&&--ee[e+1]===0&&(ee[e]=void 0,dr.push(e));},nn=()=>ee.length/2-5-dr.length,an=()=>{ee.push(0,1,void 0,1,null,1,true,1,false,1),d.count_emval_handles=nn;},z={toValue:e=>(e||C("Cannot use deleted val. handle = "+e),ee[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case true:return 6;case false:return 8;default:{let r=dr.pop()||ee.length;return ee[r]=e,ee[r+1]=1,r}}}},on={name:"emscripten::val",fromWireType:e=>{var r=z.toValue(e);return fr(e),r},toWireType:(e,r)=>z.toHandle(r),argPackAdvance:K,readValueFromPointer:we,destructorFunction:null},sn=e=>G(e,on),ln=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType(H[n])}:function(n){return this.fromWireType(L[n])};case 2:return t?function(n){return this.fromWireType(de[n>>1])}:function(n){return this.fromWireType(ye[n>>1])};case 4:return t?function(n){return this.fromWireType(E[n>>2])}:function(n){return this.fromWireType(k[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},un=(e,r,t,n)=>{r=W(r);function o(){}o.values={},G(e,{name:r,constructor:o,fromWireType:function(i){return this.constructor.values[i]},toWireType:(i,s)=>s.value,argPackAdvance:K,readValueFromPointer:ln(r,t,n),destructorFunction:null}),ir(r,o);},cr=(e,r)=>{var t=le[e];return t===void 0&&C(`${r} has unknown type ${zr(e)}`),t},dn=(e,r,t)=>{var n=cr(e,"enum");r=W(r);var o=n.constructor,i=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:ke(`${n.name}_${r}`,function(){})}});o.values[t]=i,o[r]=i;},vr=e=>{if(e===null)return "null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},fn=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(gr[t>>2])};case 8:return function(t){return this.fromWireType(wr[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},cn=(e,r,t)=>{r=W(r),G(e,{name:r,fromWireType:n=>n,toWireType:(n,o)=>o,argPackAdvance:K,readValueFromPointer:fn(r,t),destructorFunction:null});},vn=(e,r,t,n,o,i,s)=>{var l=lr(r,t);e=W(e),e=Nr(e),o=q(n,o),ir(e,function(){xe(`Cannot call ${e} due to unbound types`,l);},r-1),ue([],l,u=>{var f=[u[0],null].concat(u.slice(1));return xr(e,ur(e,f,null,o,i),r-1),[]});},hn=(e,r,t)=>{switch(r){case 1:return t?n=>H[n]:n=>L[n];case 2:return t?n=>de[n>>1]:n=>ye[n>>1];case 4:return t?n=>E[n>>2]:n=>k[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},mn=(e,r,t,n,o)=>{r=W(r);var i=v=>v;if(n===0){var s=32-8*t;i=v=>v<<s>>>s;}var l=r.includes("unsigned"),u=(v,y)=>{},f;l?f=function(v,y){return u(y,this.name),y>>>0}:f=function(v,y){return u(y,this.name),y},G(e,{name:r,fromWireType:i,toWireType:f,argPackAdvance:K,readValueFromPointer:hn(r,t,n!==0),destructorFunction:null});},pn=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],o=n[r];function i(s){var l=k[s>>2],u=k[s+4>>2];return new o(H.buffer,u,l)}t=W(t),G(e,{name:t,fromWireType:i,argPackAdvance:K,readValueFromPointer:i},{ignoreDuplicateRegistrations:true});},yn=(e,r,t)=>er(e,L,r,t),gn=(e,r)=>{r=W(r);var t=r==="std::string";G(e,{name:r,fromWireType(n){var o=k[n>>2],i=n+4,s;if(t)for(var l=i,u=0;u<=o;++u){var f=i+u;if(u==o||L[f]==0){var v=f-l,y=se(l,v);s===void 0?s=y:(s+="\0",s+=y),l=f+1;}}else {for(var p=new Array(o),u=0;u<o;++u)p[u]=String.fromCharCode(L[i+u]);s=p.join("");}return re(n),s},toWireType(n,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var i,s=typeof o=="string";s||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||C("Cannot pass non-string to std::string"),t&&s?i=Ze(o):i=o.length;var l=pr(4+i+1),u=l+4;if(k[l>>2]=i,t&&s)yn(o,u,i+1);else if(s)for(var f=0;f<i;++f){var v=o.charCodeAt(f);v>255&&(re(u),C("String has UTF-16 code units that do not fit in 8 bits")),L[u+f]=v;}else for(var f=0;f<i;++f)L[u+f]=o[f];return n!==null&&n.push(re,l),l},argPackAdvance:K,readValueFromPointer:we,destructorFunction(n){re(n);}});},Vr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,wn=(e,r)=>{for(var t=e,n=t>>1,o=n+r/2;!(n>=o)&&ye[n];)++n;if(t=n<<1,t-e>32&&Vr)return Vr.decode(L.subarray(e,t));for(var i="",s=0;!(s>=r/2);++s){var l=de[e+s*2>>1];if(l==0)break;i+=String.fromCharCode(l);}return i},_n=(e,r,t)=>{if(t??=2147483647,t<2)return 0;t-=2;for(var n=r,o=t<e.length*2?t/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);de[r>>1]=s,r+=2;}return de[r>>1]=0,r-n},En=e=>e.length*2,bn=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var o=E[e+t*4>>2];if(o==0)break;if(++t,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|i&1023);}else n+=String.fromCharCode(o);}return n},$n=(e,r,t)=>{if(t??=2147483647,t<4)return 0;for(var n=r,o=n+t-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343){var l=e.charCodeAt(++i);s=65536+((s&1023)<<10)|l&1023;}if(E[r>>2]=s,r+=4,r+4>o)break}return E[r>>2]=0,r-n},kn=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4;}return r},Pn=(e,r,t)=>{t=W(t);var n,o,i,s;r===2?(n=wn,o=_n,s=En,i=l=>ye[l>>1]):r===4&&(n=bn,o=$n,s=kn,i=l=>k[l>>2]),G(e,{name:t,fromWireType:l=>{for(var u=k[l>>2],f,v=l+4,y=0;y<=u;++y){var p=l+4+y*r;if(y==u||i(p)==0){var h=p-v,g=n(v,h);f===void 0?f=g:(f+="\0",f+=g),v=p+r;}}return re(l),f},toWireType:(l,u)=>{typeof u!="string"&&C(`Cannot pass non-string to C++ string type ${t}`);var f=s(u),v=pr(4+f+r);return k[v>>2]=f/r,o(u,v+4,f+r),l!==null&&l.push(re,v),v},argPackAdvance:K,readValueFromPointer:we,destructorFunction(l){re(l);}});},Cn=(e,r,t,n,o,i)=>{Re[e]={name:W(r),rawConstructor:q(t,n),rawDestructor:q(o,i),fields:[]};},Tn=(e,r,t,n,o,i,s,l,u,f)=>{Re[e].fields.push({fieldName:W(r),getterReturnType:t,getter:q(n,o),getterContext:i,setterArgumentType:s,setter:q(l,u),setterContext:f});},Dn=(e,r)=>{r=W(r),G(e,{isVoid:true,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}});},He=[],Fn=(e,r,t,n)=>(e=He[e],r=z.toValue(r),e(null,r,t,n)),An={},hr=e=>{var r=An[e];return r===void 0?W(e):r},Sn=(e,r,t,n,o)=>(e=He[e],r=z.toValue(r),t=hr(t),e(r,r[t],n,o)),Yr=()=>{if(typeof globalThis=="object")return globalThis;function e(r){r.$$$embind_global$$$=r;var t=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return t||delete r.$$$embind_global$$$,t}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&e(global)?$$$embind_global$$$=global:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")},Rn=e=>e===0?z.toHandle(Yr()):(e=hr(e),z.toHandle(Yr()[e])),Mn=e=>{var r=He.length;return He.push(e),r},jn=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=cr(k[r+n*4>>2],"parameter "+n);return t},On=Reflect.construct,In=(e,r,t)=>{var n=[],o=e.toWireType(n,t);return n.length&&(k[r>>2]=z.toHandle(n)),o},Un=(e,r,t)=>{var n=jn(e,r),o=n.shift();e--;var i=new Array(e),s=(u,f,v,y)=>{for(var p=0,h=0;h<e;++h)i[h]=n[h].readValueFromPointer(y+p),p+=n[h].argPackAdvance;var g=t===1?On(f,i):f.apply(u,i);return In(o,v,g)},l=`methodCaller<(${n.map(u=>u.name).join(", ")}) => ${o.name}>`;return Mn(ke(l,s))},Bn=e=>{e>9&&(ee[e+1]+=1);},xn=()=>z.toHandle([]),Hn=e=>z.toHandle(hr(e)),Wn=()=>z.toHandle({}),Ln=e=>{var r=z.toValue(e);tr(r),fr(e);},zn=(e,r,t)=>{e=z.toValue(e),r=z.toValue(r),t=z.toValue(t),e[r]=t;},Nn=(e,r)=>{e=cr(e,"_emval_take_value");var t=e.readValueFromPointer(r);return z.toHandle(t)},Vn=()=>{fe("");},Yn=(e,r,t)=>L.copyWithin(e,r,r+t),qn=()=>2147483648,Xn=e=>{var r=Fe.buffer,t=(e-r.byteLength+65535)/65536;try{return Fe.grow(t),_r(),1}catch{}},Gn=e=>{var r=L.length;e>>>=0;var t=qn();if(e>t)return false;for(var n=(u,f)=>u+(f-u%f)%f,o=1;o<=4;o*=2){var i=r*(1+.2/o);i=Math.min(i,e+100663296);var s=Math.min(t,n(Math.max(e,i),65536)),l=Xn(s);if(l)return true}return false},mr={},Kn=()=>x||"./this.program",Pe=()=>{if(!Pe.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Kn()};for(var t in mr)mr[t]===void 0?delete r[t]:r[t]=mr[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Pe.strings=n;}return Pe.strings},Jn=(e,r)=>{for(var t=0;t<e.length;++t)H[r++]=e.charCodeAt(t);H[r]=0;},Qn=(e,r)=>{var t=0;return Pe().forEach((n,o)=>{var i=r+t;k[e+o*4>>2]=i,Jn(n,i),t+=n.length+1;}),0},Zn=(e,r)=>{var t=Pe();k[e>>2]=t.length;var n=0;return t.forEach(o=>n+=o.length+1),k[r>>2]=n,0};function ea(e){try{var r=X.getStreamFromFD(e);return a.close(r),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var ra=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=k[r>>2],l=k[r+4>>2];r+=8;var u=a.read(e,H,s,l,n);if(u<0)return -1;if(o+=u,u<l)break;}return o};function ta(e,r,t,n){try{var o=X.getStreamFromFD(e),i=ra(o,r,t);return k[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var na=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN;function aa(e,r,t,n,o){var i=na(r,t);try{if(isNaN(i))return 61;var s=X.getStreamFromFD(e);return a.llseek(s,i,n),U=[s.position>>>0,(b=s.position,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[o>>2]=U[0],E[o+4>>2]=U[1],s.getdents&&i===0&&n===0&&(s.getdents=null),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var oa=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=k[r>>2],l=k[r+4>>2];r+=8;var u=a.write(e,H,s,l,n);if(u<0)return -1;o+=u;}return o};function ia(e,r,t,n){try{var o=X.getStreamFromFD(e),i=oa(o,r,t);return k[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var We=e=>e%4===0&&(e%100!==0||e%400===0),sa=(e,r)=>{for(var t=0,n=0;n<=r;t+=e[n++]);return t},qr=[31,29,31,30,31,30,31,31,30,31,30,31],Xr=[31,28,31,30,31,30,31,31,30,31,30,31],la=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var n=We(t.getFullYear()),o=t.getMonth(),i=(n?qr:Xr)[o];if(r>i-t.getDate())r-=i-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t},ua=(e,r)=>{H.set(e,r);},da=(e,r,t,n)=>{var o=k[n+40>>2],i={tm_sec:E[n>>2],tm_min:E[n+4>>2],tm_hour:E[n+8>>2],tm_mday:E[n+12>>2],tm_mon:E[n+16>>2],tm_year:E[n+20>>2],tm_wday:E[n+24>>2],tm_yday:E[n+28>>2],tm_isdst:E[n+32>>2],tm_gmtoff:E[n+36>>2],tm_zone:o?se(o):""},s=se(t),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in l)s=s.replace(new RegExp(u,"g"),l[u]);var f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],v=["January","February","March","April","May","June","July","August","September","October","November","December"];function y(c,m,O){for(var P=typeof c=="number"?c.toString():c||"";P.length<m;)P=O[0]+P;return P}function p(c,m){return y(c,m,"0")}function h(c,m){function O(N){return N<0?-1:N>0?1:0}var P;return (P=O(c.getFullYear()-m.getFullYear()))===0&&(P=O(c.getMonth()-m.getMonth()))===0&&(P=O(c.getDate()-m.getDate())),P}function g(c){switch(c.getDay()){case 0:return new Date(c.getFullYear()-1,11,29);case 1:return c;case 2:return new Date(c.getFullYear(),0,3);case 3:return new Date(c.getFullYear(),0,2);case 4:return new Date(c.getFullYear(),0,1);case 5:return new Date(c.getFullYear()-1,11,31);case 6:return new Date(c.getFullYear()-1,11,30)}}function D(c){var m=la(new Date(c.tm_year+1900,0,1),c.tm_yday),O=new Date(m.getFullYear(),0,4),P=new Date(m.getFullYear()+1,0,4),N=g(O),M=g(P);return h(N,m)<=0?h(M,m)<=0?m.getFullYear()+1:m.getFullYear():m.getFullYear()-1}var R={"%a":c=>f[c.tm_wday].substring(0,3),"%A":c=>f[c.tm_wday],"%b":c=>v[c.tm_mon].substring(0,3),"%B":c=>v[c.tm_mon],"%C":c=>{var m=c.tm_year+1900;return p(m/100|0,2)},"%d":c=>p(c.tm_mday,2),"%e":c=>y(c.tm_mday,2," "),"%g":c=>D(c).toString().substring(2),"%G":D,"%H":c=>p(c.tm_hour,2),"%I":c=>{var m=c.tm_hour;return m==0?m=12:m>12&&(m-=12),p(m,2)},"%j":c=>p(c.tm_mday+sa(We(c.tm_year+1900)?qr:Xr,c.tm_mon-1),3),"%m":c=>p(c.tm_mon+1,2),"%M":c=>p(c.tm_min,2),"%n":()=>`
|
|
5
|
+
`,"%p":c=>c.tm_hour>=0&&c.tm_hour<12?"AM":"PM","%S":c=>p(c.tm_sec,2),"%t":()=>" ","%u":c=>c.tm_wday||7,"%U":c=>{var m=c.tm_yday+7-c.tm_wday;return p(Math.floor(m/7),2)},"%V":c=>{var m=Math.floor((c.tm_yday+7-(c.tm_wday+6)%7)/7);if((c.tm_wday+371-c.tm_yday-2)%7<=2&&m++,m){if(m==53){var P=(c.tm_wday+371-c.tm_yday)%7;P!=4&&(P!=3||!We(c.tm_year))&&(m=1);}}else {m=52;var O=(c.tm_wday+7-c.tm_yday-1)%7;(O==4||O==5&&We(c.tm_year%400-1))&&m++;}return p(m,2)},"%w":c=>c.tm_wday,"%W":c=>{var m=c.tm_yday+7-(c.tm_wday+6)%7;return p(Math.floor(m/7),2)},"%y":c=>(c.tm_year+1900).toString().substring(2),"%Y":c=>c.tm_year+1900,"%z":c=>{var m=c.tm_gmtoff,O=m>=0;return m=Math.abs(m)/60,m=m/60*100+m%60,(O?"+":"-")+("0000"+m).slice(-4)},"%Z":c=>c.tm_zone,"%%":()=>"%"};s=s.replace(/%%/g,"\0\0");for(var u in R)s.includes(u)&&(s=s.replace(new RegExp(u,"g"),R[u](i)));s=s.replace(/\0\0/g,"%");var T=Se(s,false);return T.length>r?0:(ua(T,e),T.length-1)},fa=(e,r,t,n,o)=>da(e,r,t,n);a.createPreloadedFile=$t,a.staticInit(),Rr=d.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},Dt(),he=d.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Ht(),It(),Xt(),Lr=d.UnboundTypeError=Qt(Error,"UnboundTypeError"),an();var ca={a:vt,m:pt,F:Pt,O:Ct,C:Tt,M:At,o:Zt,A:rn,y:tn,L:sn,j:un,b:dn,x:cn,e:vn,i:mn,f:pn,w:gn,r:Pn,P:Cn,t:Tn,N:Dn,p:Fn,z:Sn,c:fr,Q:Rn,l:Un,q:Bn,s:xn,h:Hn,n:Wn,k:Ln,g:zn,d:Nn,u:Vn,K:Yn,E:Gn,I:Qn,J:Zn,G:ea,H:ta,B:aa,v:ia,D:fa},I=ct(),pr=e=>(pr=I.T)(e),re=e=>(re=I.V)(e),Gr=e=>(Gr=I.W)(e),Kr=e=>(Kr=I.X)(e);d.dynCall_ji=(e,r)=>(d.dynCall_ji=I.Y)(e,r);d.dynCall_iij=(e,r,t,n)=>(d.dynCall_iij=I.Z)(e,r,t,n);d.dynCall_jijj=(e,r,t,n,o,i)=>(d.dynCall_jijj=I._)(e,r,t,n,o,i);d.dynCall_vijj=(e,r,t,n,o,i)=>(d.dynCall_vijj=I.$)(e,r,t,n,o,i);d.dynCall_jiji=(e,r,t,n,o)=>(d.dynCall_jiji=I.aa)(e,r,t,n,o);d.dynCall_viijii=(e,r,t,n,o,i,s)=>(d.dynCall_viijii=I.ba)(e,r,t,n,o,i,s);d.dynCall_iiiiij=(e,r,t,n,o,i,s)=>(d.dynCall_iiiiij=I.ca)(e,r,t,n,o,i,s);d.dynCall_iiiiijj=(e,r,t,n,o,i,s,l,u)=>(d.dynCall_iiiiijj=I.da)(e,r,t,n,o,i,s,l,u);d.dynCall_iiiiiijj=(e,r,t,n,o,i,s,l,u,f)=>(d.dynCall_iiiiiijj=I.ea)(e,r,t,n,o,i,s,l,u,f);var Le;ge=function e(){Le||Jr(),Le||(ge=e);};function Jr(){if(oe>0||(nt(),oe>0))return;function e(){Le||(Le=true,d.calledRun=true,!yr&&(at(),_(d),d.onRuntimeInitialized&&d.onRuntimeInitialized(),ot()));}d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("");},1),e();},1)):e();}if(d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);d.preInit.length>0;)d.preInit.pop()();return Jr(),$.ready})})(),Zr=$a;var Ce=class{options;module=null;decoderInstance=null;initPromise=null;constructor($){this.options=$;}async initialize(){if(!this.initPromise){let $={};this.options?.locateFile&&($.locateFile=this.options.locateFile),this.options?.wasmBinary&&($.wasmBinary=this.options.wasmBinary),this.initPromise=Zr($).then(d=>(this.module=d,this.decoderInstance=new d.HeicDecoder,d)).catch(d=>{throw this.initPromise=null,d});}await this.initPromise;}async decode($,d){(!this.module||!this.decoderInstance)&&await this.initialize();let _=this.decoderInstance.decode($,d??null);if(!_)throw new Error("HEIC decoding failed");if(typeof _=="string")throw new Error(`HEIC decoding failed: ${_}`);let S=_.width,B=_.height,V=new Uint8ClampedArray(_.data);return {width:S,height:B,data:V}}free(){this.decoderInstance&&(this.decoderInstance.delete(),this.decoderInstance=null),this.module=null,this.initPromise=null;}};async function ka(F){if(typeof FileReader<"u")return new Promise(($,d)=>{let _=new FileReader;_.onloadend=()=>{typeof _.result=="string"?$(_.result):d(new Error("Failed to convert Blob to base64 string"));},_.onerror=()=>d(_.error),_.readAsDataURL(F);});try{let $=await F.arrayBuffer(),d=new Uint8Array($),_="",S=32768;for(let V=0;V<d.length;V+=S)_+=String.fromCharCode(...d.subarray(V,V+S));let B=btoa(_);return `data:${F.type};base64,${B}`}catch($){throw new Error(`Failed to convert Blob to base64 string: ${$ instanceof Error?$.message:String($)}`,{cause:$})}}function ze(F,$,d){return "convertToBlob"in F?F.convertToBlob({type:$,quality:d}):new Promise((_,S)=>{F.toBlob(B=>{B?_(B):S(new Error(`Failed to convert canvas to blob (type: ${$})`));},$,d);})}async function et(F,$,d){let{width:_,height:S,data:B}=F;if(!Number.isInteger(_)||_<=0||!Number.isInteger(S)||S<=0)throw new Error(`Invalid image dimensions: ${_}x${S}. Width and height must be positive integers.`);let V=_*S*4;if(B.length!==V)throw new Error(`Image data length mismatch. Expected ${V} bytes for ${_}x${S}, got ${B.length}`);let x;if(typeof OffscreenCanvas<"u")x=new OffscreenCanvas(_,S);else if(typeof document<"u")x=document.createElement("canvas"),x.width=_,x.height=S;else throw new Error("Canvas is not supported in the current environment. Conversion requires a browser environment or canvas polyfills.");let J=x.getContext("2d");if(!J)throw new Error("Failed to acquire 2D rendering context from canvas");let te;if(typeof ImageData<"u")te=new ImageData(B,_,S);else {let Q=J.createImageData(_,S);Q.data.set(B),te=Q;}J.putImageData(te,0,0);let j=$.toLowerCase();if(j==="png")return ze(x,"image/png");if(j==="jpeg"||j==="jpg")return ze(x,"image/jpeg",d);if(j==="webp")return ze(x,"image/webp",d);if(j==="svg"){let Q=await ze(x,"image/png"),Y=await ka(Q),Ne=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${_} ${S}" width="${_}" height="${S}">
|
|
6
|
+
<image width="${_}" height="${S}" href="${Y}" />
|
|
7
|
+
</svg>`;return new Blob([Ne],{type:"image/svg+xml"})}else throw new Error(`Unsupported output format: ${$}`)}function xa(){}function Pa(F){if(typeof F!="number"||Number.isNaN(F)||F<0||F>1)throw new Error(`Quality must be a number between 0.0 and 1.0, got: ${F}`)}async function Ha(F,$){let d;if(F instanceof Uint8Array)d=F;else if(F instanceof ArrayBuffer)d=new Uint8Array(F);else if(typeof Blob<"u"&&F instanceof Blob){let x=await F.arrayBuffer();d=new Uint8Array(x);}else throw new Error(`Unsupported input type. Expected Blob, File, ArrayBuffer, or Uint8Array. Got: ${Object.prototype.toString.call(F)}`);$?.quality!==void 0&&Pa($.quality);let _=$?.decoder??new Ce,S=!$?.decoder,B=false,V=()=>{if(!(!S||B)){B=true;try{_.free();}catch{}}};try{try{await _.initialize();}catch(j){throw new Error(`Failed to initialize HEIC decoder: ${j instanceof Error?j.message:String(j)}`,{cause:j})}let x=await _.decode(d,$?.onProgress);V();let J=$?.to||"jpeg",te=$?.quality!==void 0?$.quality:.92;try{return await et(x,J,te)}catch(j){throw new Error(`Failed to render and encode image as ${J}: ${j instanceof Error?j.message:String(j)}`,{cause:j})}}finally{V();}}exports.LibheifDecoder=Ce;exports.convertHeic=Ha;exports.freeSharedDecoder=xa;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var Ea=(()=>{var S=import.meta.url;return(async function(P={}){var f=P,_,O;f.ready=new Promise((e,r)=>{_=e,O=r;});var z=Object.assign({},f),N="./this.program",fe=typeof window=="object",V=typeof importScripts=="function",K=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",L="";function Ne(e){return f.locateFile?f.locateFile(e,L):L+e}var me,Ve,De;if(K){let{createRequire:e}=await import('module');var Fe=e(import.meta.url),Ye=Fe("fs"),qe=Fe("path");V?L=qe.dirname(L)+"/":L=Fe("url").fileURLToPath(new URL("./",import.meta.url)),me=(r,t)=>(r=Cr(r)?new URL(r):qe.normalize(r),Ye.readFileSync(r,t?void 0:"utf8")),De=r=>{var t=me(r,true);return t.buffer||(t=new Uint8Array(t)),t},Ve=(r,t,n,o=true)=>{r=Cr(r)?new URL(r):qe.normalize(r),Ye.readFile(r,o?void 0:"utf8",(i,s)=>{i?n(i):t(o?s.buffer:s);});},!f.thisProgram&&process.argv.length>1&&(N=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2);}else (fe||V)&&(V?L=self.location.href:typeof document<"u"&&document.currentScript&&(L=document.currentScript.src),S&&(L=S),L.startsWith("blob:")?L="":L=L.substr(0,L.replace(/[?#].*/,"").lastIndexOf("/")+1),me=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.send(null),r.responseText},V&&(De=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Ve=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,true),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t();},n.onerror=t,n.send(null);});var Xe=f.print||console.log.bind(console),re=f.printErr||console.error.bind(console);Object.assign(f,z),z=null,f.arguments&&(f.arguments),f.thisProgram&&(N=f.thisProgram),f.quit&&(f.quit);var pe;f.wasmBinary&&(pe=f.wasmBinary);var Se,gr=false,I,x,de,ye,E,$,wr,_r;function Er(){var e=Se.buffer;f.HEAP8=I=new Int8Array(e),f.HEAP16=de=new Int16Array(e),f.HEAPU8=x=new Uint8Array(e),f.HEAPU16=ye=new Uint16Array(e),f.HEAP32=E=new Int32Array(e),f.HEAPU32=$=new Uint32Array(e),f.HEAPF32=wr=new Float32Array(e),f.HEAPF64=_r=new Float64Array(e);}var br=[],$r=[],kr=[];function at(){if(f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)st(f.preRun.shift());Je(br);}function ot(){!f.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=false,Je($r);}function it(){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)ut(f.postRun.shift());Je(kr);}function st(e){br.unshift(e);}function lt(e){$r.unshift(e);}function ut(e){kr.unshift(e);}var ae=0,ge=null;function Ke(e){ae++,f.monitorRunDependencies?.(ae);}function Ae(e){if(ae--,f.monitorRunDependencies?.(ae),ae==0&&(ge)){var r=ge;ge=null,r();}}function we(e){f.onAbort?.(e),e="Aborted("+e+")",re(e),gr=true,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw O(r),r}var ft="data:application/octet-stream;base64,",Pr=e=>e.startsWith(ft),Cr=e=>e.startsWith("file://"),oe;f.locateFile?(oe="heic-decoder.wasm",Pr(oe)||(oe=Ne(oe))):oe=new URL("heic-decoder.wasm",import.meta.url).href;function Tr(e){if(e==oe&&pe)return new Uint8Array(pe);if(De)return De(e);throw "both async and sync fetching of the wasm failed"}function dt(e){return !pe&&(fe||V)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw `failed to load wasm binary file at '${e}'`;return r.arrayBuffer()}).catch(()=>Tr(e)):Promise.resolve().then(()=>Tr(e))}function Dr(e,r,t){return dt(e).then(n=>WebAssembly.instantiate(n,r)).then(t,n=>{re(`failed to asynchronously prepare wasm: ${n}`),we(n);})}function ct(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!Pr(r)&&!K&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(o=>{var i=WebAssembly.instantiateStreaming(o,t);return i.then(n,function(s){return re(`wasm streaming compile failed: ${s}`),re("falling back to ArrayBuffer instantiation"),Dr(r,t,n)})}):Dr(r,t,n)}function vt(){var e={a:ca};function r(n,o){return B=n.exports,Se=B.Q,Er(),xr=B.T,lt(B.R),Ae(),B}Ke();function t(n){r(n.instance);}if(f.instantiateWasm)try{return f.instantiateWasm(e,r)}catch(n){re(`Module.instantiateWasm callback failed with error: ${n}`),O(n);}return ct(pe,oe,e,t).catch(O),{}}var b,j,Je=e=>{for(;e.length>0;)e.shift()(f);};f.noExitRuntime||true;var Fr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ce=(e,r,t)=>{for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.buffer&&Fr)return Fr.decode(e.subarray(r,o));for(var i="";r<o;){var s=e[r++];if(!(s&128)){i+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|l);continue}var u=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|u:s=(s&7)<<18|l<<12|u<<6|e[r++]&63,s<65536)i+=String.fromCharCode(s);else {var d=s-65536;i+=String.fromCharCode(55296|d>>10,56320|d&1023);}}return i},ie=(e,r)=>e?ce(x,e,r):"",ht=(e,r,t,n)=>{we(`Assertion failed: ${ie(e)}, at: `+[r?ie(r):"unknown filename",t,n?ie(n):"unknown function"]);};class mt{constructor(r){this.excPtr=r,this.ptr=r-24;}set_type(r){$[this.ptr+4>>2]=r;}get_type(){return $[this.ptr+4>>2]}set_destructor(r){$[this.ptr+8>>2]=r;}get_destructor(){return $[this.ptr+8>>2]}set_caught(r){r=r?1:0,I[this.ptr+12]=r;}get_caught(){return I[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,I[this.ptr+13]=r;}get_rethrown(){return I[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t);}set_adjusted_ptr(r){$[this.ptr+16>>2]=r;}get_adjusted_ptr(){return $[this.ptr+16>>2]}get_exception_ptr(){var r=Jr(this.get_type());if(r)return $[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Sr=0,yt=(e,r,t)=>{var n=new mt(e);throw n.init(r,t),Sr=e,Sr},Re={},Qe=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r);}};function _e(e){return this.fromWireType($[e>>2])}var ve={},se={},Me={},Ar,Oe=e=>{throw new Ar(e)},le=(e,r,t)=>{e.forEach(function(l){Me[l]=r;});function n(l){var u=t(l);u.length!==e.length&&Oe("Mismatched type converter count");for(var d=0;d<e.length;++d)q(e[d],u[d]);}var o=new Array(r.length),i=[],s=0;r.forEach((l,u)=>{se.hasOwnProperty(l)?o[u]=se[l]:(i.push(l),ve.hasOwnProperty(l)||(ve[l]=[]),ve[l].push(()=>{o[u]=se[l],++s,s===i.length&&n(o);}));}),i.length===0&&n(o);},gt=e=>{var r=Re[e];delete Re[e];var t=r.rawConstructor,n=r.rawDestructor,o=r.fields,i=o.map(s=>s.getterReturnType).concat(o.map(s=>s.setterArgumentType));le([e],i,s=>{var l={};return o.forEach((u,d)=>{var v=u.fieldName,y=s[d],p=u.getter,h=u.getterContext,g=s[d+o.length],D=u.setter,A=u.setterContext;l[v]={read:T=>y.fromWireType(p(h,T)),write:(T,c)=>{var m=[];D(A,T,g.toWireType(m,c)),Qe(m);}};}),[{name:r.name,fromWireType:u=>{var d={};for(var v in l)d[v]=l[v].read(u);return n(u),d},toWireType:(u,d)=>{for(var v in l)if(!(v in d))throw new TypeError(`Missing field: "${v}"`);var y=t();for(v in l)l[v].write(y,d[v]);return u!==null&&u.push(n,y),y},argPackAdvance:X,readValueFromPointer:_e,destructorFunction:n}]});},wt=(e,r,t,n,o)=>{},_t=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Rr=e;},Rr,U=e=>{for(var r="",t=e;x[t];)r+=Rr[x[t++]];return r},he,C=e=>{throw new he(e)};function Et(e,r,t={}){var n=r.name;if(e||C(`type "${n}" must have a positive integer typeid pointer`),se.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;C(`Cannot register type '${n}' twice`);}if(se[e]=r,delete Me[e],ve.hasOwnProperty(e)){var o=ve[e];delete ve[e],o.forEach(i=>i());}}function q(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Et(e,r,t)}var X=8,bt=(e,r,t,n)=>{r=U(r),q(e,{name:r,fromWireType:function(o){return !!o},toWireType:function(o,i){return i?t:n},argPackAdvance:X,readValueFromPointer:function(o){return this.fromWireType(x[o])},destructorFunction:null});},$t=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),Ze=e=>{function r(t){return t.$$.ptrType.registeredClass.name}C(r(e)+" instance already deleted");},er=false,Mr=e=>{},kt=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr);},Or=e=>{e.count.value-=1;var r=e.count.value===0;r&&kt(e);},jr=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=jr(e,r,t.baseClass);return n===null?null:t.downcast(n)},Ir={},Pt=()=>Object.keys($e).length,Ct=()=>{var e=[];for(var r in $e)$e.hasOwnProperty(r)&&e.push($e[r]);return e},Ee=[],rr=()=>{for(;Ee.length;){var e=Ee.pop();e.$$.deleteScheduled=false,e.delete();}},be,Tt=e=>{be=e,Ee.length&&be&&be(rr);},Dt=()=>{f.getInheritedInstanceCount=Pt,f.getLiveInheritedInstances=Ct,f.flushPendingDeletes=rr,f.setDelayFunction=Tt;},$e={},Ft=(e,r)=>{for(r===void 0&&C("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},St=(e,r)=>(r=Ft(e,r),$e[r]),je=(e,r)=>{(!r.ptrType||!r.ptr)&&Oe("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&Oe("Both smartPtrType and smartPtr must be specified"),r.count={value:1},ke(Object.create(e,{$$:{value:r,writable:true}}))};function At(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=St(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 o(){return this.isSmartPointer?je(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):je(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i=this.registeredClass.getActualType(r),s=Ir[i];if(!s)return o.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var u=jr(r,this.registeredClass,l.registeredClass);return u===null?o.call(this):this.isSmartPointer?je(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:e}):je(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var ke=e=>typeof FinalizationRegistry>"u"?(ke=r=>r,e):(er=new FinalizationRegistry(r=>{Or(r.$$);}),ke=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var o={$$:t};er.register(r,o,r);}return r},Mr=r=>er.unregister(r),ke(e)),Rt=()=>{Object.assign(Ie.prototype,{isAliasOf(e){if(!(this instanceof Ie)||!(e instanceof Ie))return false;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,o=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return r===n&&t===o},clone(){if(this.$$.ptr||Ze(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=ke(Object.create(Object.getPrototypeOf(this),{$$:{value:$t(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=false,e},delete(){this.$$.ptr||Ze(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&C("Object already scheduled for deletion"),Mr(this),Or(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0);},isDeleted(){return !this.$$.ptr},deleteLater(){return this.$$.ptr||Ze(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&C("Object already scheduled for deletion"),Ee.push(this),Ee.length===1&&be&&be(rr),this.$$.deleteScheduled=true,this}});};function Ie(){}var Pe=(e,r)=>Object.defineProperty(r,"name",{value:e}),Ur=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...o){return e[r].overloadTable.hasOwnProperty(o.length)||C(`Function '${t}' called with an invalid number of arguments (${o.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[o.length].apply(this,o)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n;}},tr=(e,r,t)=>{f.hasOwnProperty(e)?((t===void 0||f[e].overloadTable!==void 0&&f[e].overloadTable[t]!==void 0)&&C(`Cannot register public name '${e}' twice`),Ur(f,e,e),f.hasOwnProperty(t)&&C(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),f[e].overloadTable[t]=r):(f[e]=r,t!==void 0&&(f[e].numArguments=t));},Mt=48,Ot=57,jt=e=>{if(e===void 0)return "_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Mt&&r<=Ot?`_${e}`:e};function It(e,r,t,n,o,i,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[];}var nr=(e,r,t)=>{for(;r!==t;)r.upcast||C(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function Ut(e,r){if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),0;r.$$||C(`Cannot pass "${ur(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=nr(r.$$.ptr,t,this.registeredClass);return n}function Bt(e,r){var t;if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&C(`Cannot pass "${ur(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&C(`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=nr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&C("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:C(`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 o=r.clone();t=this.rawShare(t,W.toHandle(()=>o.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:C("Unsupporting sharing policy");}return t}function xt(e,r){if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),0;r.$$||C(`Cannot pass "${ur(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&C(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=nr(r.$$.ptr,t,this.registeredClass);return n}var Wt=()=>{Object.assign(Ue.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e);},argPackAdvance:X,readValueFromPointer:_e,fromWireType:At});};function Ue(e,r,t,n,o,i,s,l,u,d,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=d,this.rawDestructor=v,!o&&r.baseClass===void 0?n?(this.toWireType=Ut,this.destructorFunction=null):(this.toWireType=xt,this.destructorFunction=null):this.toWireType=Bt;}var Br=(e,r,t)=>{f.hasOwnProperty(e)||Oe("Replacing nonexistent public symbol"),f[e].overloadTable!==void 0&&t!==void 0?f[e].overloadTable[t]=r:(f[e]=r,f[e].argCount=t);},Ht=(e,r,t)=>{var n=f["dynCall_"+e];return n(r,...t)},Be=[],xr,Wr=e=>{var r=Be[e];return r||(e>=Be.length&&(Be.length=e+1),Be[e]=r=xr.get(e)),r},Lt=(e,r,t=[])=>{if(e.includes("j"))return Ht(e,r,t);var n=Wr(r)(...t);return n},zt=(e,r)=>(...t)=>Lt(e,r,t),Y=(e,r)=>{e=U(e);function t(){return e.includes("j")?zt(e,r):Wr(r)}var n=t();return typeof n!="function"&&C(`unknown function pointer with signature ${e}: ${r}`),n},Nt=(e,r)=>{var t=Pe(r,function(n){this.name=r,this.message=n;var o=new Error(n).stack;o!==void 0&&(this.stack=this.toString()+`
|
|
2
|
-
`+o.replace(/^Error(:[^\n]*)?\n/,""));});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},Hr,Lr=e=>{var r=Kr(e),t=U(r);return Z(r),t},xe=(e,r)=>{var t=[],n={};function o(i){if(!n[i]&&!se[i]){if(Me[i]){Me[i].forEach(o);return}t.push(i),n[i]=true;}}throw r.forEach(o),new Hr(`${e}: `+t.map(Lr).join([", "]))},Vt=(e,r,t,n,o,i,s,l,u,d,v,y,p)=>{v=U(v),i=Y(o,i),l&&=Y(s,l),d&&=Y(u,d),p=Y(y,p);var h=jt(v);tr(h,function(){xe(`Cannot construct ${v} due to unbound types`,[n]);}),le([e,r,t],n?[n]:[],g=>{g=g[0];var D,A;n?(D=g.registeredClass,A=D.instancePrototype):A=Ie.prototype;var T=Pe(v,function(...R){if(Object.getPrototypeOf(this)!==c)throw new he("Use 'new' to construct "+v);if(m.constructor_body===void 0)throw new he(v+" has no accessible constructor");var Zr=m.constructor_body[R.length];if(Zr===void 0)throw new he(`Tried to invoke ctor of ${v} with invalid number of parameters (${R.length}) - expected (${Object.keys(m.constructor_body).toString()}) parameters instead!`);return Zr.apply(this,R)}),c=Object.create(A,{constructor:{value:T}});T.prototype=c;var m=new It(v,T,c,p,D,i,l,d);m.baseClass&&(m.baseClass.__derivedClasses??=[],m.baseClass.__derivedClasses.push(m));var M=new Ue(v,m,true,false,false),k=new Ue(v+"*",m,false,false,false),H=new Ue(v+" const*",m,false,true,false);return Ir[e]={pointerType:k,constPointerType:H},Br(h,T),[M,k,H]});},ar=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push($[r+n*4>>2]);return t};function Yt(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return true;return false}function or(e,r,t,n,o,i){var s=r.length;s<2&&C("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=r[1]!==null&&t!==null,u=Yt(r),d=r[0].name!=="void",v=s-2,y=new Array(v),p=[],h=[],g=function(...D){D.length!==v&&C(`function ${e} called with ${D.length} arguments, expected ${v}`),h.length=0;var A;p.length=l?2:1,p[0]=o,l&&(A=r[1].toWireType(h,this),p[1]=A);for(var T=0;T<v;++T)y[T]=r[T+2].toWireType(h,D[T]),p.push(y[T]);var c=n(...p);function m(M){if(u)Qe(h);else for(var k=l?1:2;k<r.length;k++){var H=k===1?A:y[k-2];r[k].destructorFunction!==null&&r[k].destructorFunction(H);}if(d)return r[0].fromWireType(M)}return m(c)};return Pe(e,g)}var qt=(e,r,t,n,o,i)=>{var s=ar(r,t);o=Y(n,o),le([],[e],l=>{l=l[0];var u=`constructor ${l.name}`;if(l.registeredClass.constructor_body===void 0&&(l.registeredClass.constructor_body=[]),l.registeredClass.constructor_body[r-1]!==void 0)throw new he(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${l.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return l.registeredClass.constructor_body[r-1]=()=>{xe(`Cannot construct ${l.name} due to unbound types`,s);},le([],s,d=>(d.splice(1,0,null),l.registeredClass.constructor_body[r-1]=or(u,d,null,o,i),[])),[]});},zr=e=>{e=e.trim();let r=e.indexOf("(");return r!==-1?e.substr(0,r):e},Xt=(e,r,t,n,o,i,s,l,u)=>{var d=ar(t,n);r=U(r),r=zr(r),i=Y(o,i),le([],[e],v=>{v=v[0];var y=`${v.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&v.registeredClass.pureVirtualFunctions.push(r);function p(){xe(`Cannot call ${y} due to unbound types`,d);}var h=v.registeredClass.instancePrototype,g=h[r];return g===void 0||g.overloadTable===void 0&&g.className!==v.name&&g.argCount===t-2?(p.argCount=t-2,p.className=v.name,h[r]=p):(Ur(h,r,y),h[r].overloadTable[t-2]=p),le([],d,D=>{var A=or(y,D,v,i,s);return h[r].overloadTable===void 0?(A.argCount=t-2,h[r]=A):h[r].overloadTable[t-2]=A,[]}),[]});},ir=[],J=[],sr=e=>{e>9&&--J[e+1]===0&&(J[e]=void 0,ir.push(e));},Gt=()=>J.length/2-5-ir.length,Kt=()=>{J.push(0,1,void 0,1,null,1,true,1,false,1),f.count_emval_handles=Gt;},W={toValue:e=>(e||C("Cannot use deleted val. handle = "+e),J[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case true:return 6;case false:return 8;default:{let r=ir.pop()||J.length;return J[r]=e,J[r+1]=1,r}}}},Jt={name:"emscripten::val",fromWireType:e=>{var r=W.toValue(e);return sr(e),r},toWireType:(e,r)=>W.toHandle(r),argPackAdvance:X,readValueFromPointer:_e,destructorFunction:null},Qt=e=>q(e,Jt),Zt=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType(I[n])}:function(n){return this.fromWireType(x[n])};case 2:return t?function(n){return this.fromWireType(de[n>>1])}:function(n){return this.fromWireType(ye[n>>1])};case 4:return t?function(n){return this.fromWireType(E[n>>2])}:function(n){return this.fromWireType($[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},en=(e,r,t,n)=>{r=U(r);function o(){}o.values={},q(e,{name:r,constructor:o,fromWireType:function(i){return this.constructor.values[i]},toWireType:(i,s)=>s.value,argPackAdvance:X,readValueFromPointer:Zt(r,t,n),destructorFunction:null}),tr(r,o);},lr=(e,r)=>{var t=se[e];return t===void 0&&C(`${r} has unknown type ${Lr(e)}`),t},rn=(e,r,t)=>{var n=lr(e,"enum");r=U(r);var o=n.constructor,i=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:Pe(`${n.name}_${r}`,function(){})}});o.values[t]=i,o[r]=i;},ur=e=>{if(e===null)return "null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},tn=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(wr[t>>2])};case 8:return function(t){return this.fromWireType(_r[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},nn=(e,r,t)=>{r=U(r),q(e,{name:r,fromWireType:n=>n,toWireType:(n,o)=>o,argPackAdvance:X,readValueFromPointer:tn(r,t),destructorFunction:null});},an=(e,r,t,n,o,i,s)=>{var l=ar(r,t);e=U(e),e=zr(e),o=Y(n,o),tr(e,function(){xe(`Cannot call ${e} due to unbound types`,l);},r-1),le([],l,u=>{var d=[u[0],null].concat(u.slice(1));return Br(e,or(e,d,null,o,i),r-1),[]});},on=(e,r,t)=>{switch(r){case 1:return t?n=>I[n]:n=>x[n];case 2:return t?n=>de[n>>1]:n=>ye[n>>1];case 4:return t?n=>E[n>>2]:n=>$[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},sn=(e,r,t,n,o)=>{r=U(r);var i=v=>v;if(n===0){var s=32-8*t;i=v=>v<<s>>>s;}var l=r.includes("unsigned"),u=(v,y)=>{},d;l?d=function(v,y){return u(y,this.name),y>>>0}:d=function(v,y){return u(y,this.name),y},q(e,{name:r,fromWireType:i,toWireType:d,argPackAdvance:X,readValueFromPointer:on(r,t,n!==0),destructorFunction:null});},ln=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],o=n[r];function i(s){var l=$[s>>2],u=$[s+4>>2];return new o(I.buffer,u,l)}t=U(t),q(e,{name:t,fromWireType:i,argPackAdvance:X,readValueFromPointer:i},{ignoreDuplicateRegistrations:true});},fr=(e,r,t,n)=>{if(!(n>0))return 0;for(var o=t,i=t+n-1,s=0;s<e.length;++s){var l=e.charCodeAt(s);if(l>=55296&&l<=57343){var u=e.charCodeAt(++s);l=65536+((l&1023)<<10)|u&1023;}if(l<=127){if(t>=i)break;r[t++]=l;}else if(l<=2047){if(t+1>=i)break;r[t++]=192|l>>6,r[t++]=128|l&63;}else if(l<=65535){if(t+2>=i)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63;}else {if(t+3>=i)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63;}}return r[t]=0,t-o},un=(e,r,t)=>fr(e,x,r,t),dr=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},fn=(e,r)=>{r=U(r);var t=r==="std::string";q(e,{name:r,fromWireType(n){var o=$[n>>2],i=n+4,s;if(t)for(var l=i,u=0;u<=o;++u){var d=i+u;if(u==o||x[d]==0){var v=d-l,y=ie(l,v);s===void 0?s=y:(s+="\0",s+=y),l=d+1;}}else {for(var p=new Array(o),u=0;u<o;++u)p[u]=String.fromCharCode(x[i+u]);s=p.join("");}return Z(n),s},toWireType(n,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var i,s=typeof o=="string";s||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||C("Cannot pass non-string to std::string"),t&&s?i=dr(o):i=o.length;var l=pr(4+i+1),u=l+4;if($[l>>2]=i,t&&s)un(o,u,i+1);else if(s)for(var d=0;d<i;++d){var v=o.charCodeAt(d);v>255&&(Z(u),C("String has UTF-16 code units that do not fit in 8 bits")),x[u+d]=v;}else for(var d=0;d<i;++d)x[u+d]=o[d];return n!==null&&n.push(Z,l),l},argPackAdvance:X,readValueFromPointer:_e,destructorFunction(n){Z(n);}});},Nr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,dn=(e,r)=>{for(var t=e,n=t>>1,o=n+r/2;!(n>=o)&&ye[n];)++n;if(t=n<<1,t-e>32&&Nr)return Nr.decode(x.subarray(e,t));for(var i="",s=0;!(s>=r/2);++s){var l=de[e+s*2>>1];if(l==0)break;i+=String.fromCharCode(l);}return i},cn=(e,r,t)=>{if(t??=2147483647,t<2)return 0;t-=2;for(var n=r,o=t<e.length*2?t/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);de[r>>1]=s,r+=2;}return de[r>>1]=0,r-n},vn=e=>e.length*2,hn=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var o=E[e+t*4>>2];if(o==0)break;if(++t,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|i&1023);}else n+=String.fromCharCode(o);}return n},mn=(e,r,t)=>{if(t??=2147483647,t<4)return 0;for(var n=r,o=n+t-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343){var l=e.charCodeAt(++i);s=65536+((s&1023)<<10)|l&1023;}if(E[r>>2]=s,r+=4,r+4>o)break}return E[r>>2]=0,r-n},pn=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4;}return r},yn=(e,r,t)=>{t=U(t);var n,o,i,s;r===2?(n=dn,o=cn,s=vn,i=l=>ye[l>>1]):r===4&&(n=hn,o=mn,s=pn,i=l=>$[l>>2]),q(e,{name:t,fromWireType:l=>{for(var u=$[l>>2],d,v=l+4,y=0;y<=u;++y){var p=l+4+y*r;if(y==u||i(p)==0){var h=p-v,g=n(v,h);d===void 0?d=g:(d+="\0",d+=g),v=p+r;}}return Z(l),d},toWireType:(l,u)=>{typeof u!="string"&&C(`Cannot pass non-string to C++ string type ${t}`);var d=s(u),v=pr(4+d+r);return $[v>>2]=d/r,o(u,v+4,d+r),l!==null&&l.push(Z,v),v},argPackAdvance:X,readValueFromPointer:_e,destructorFunction(l){Z(l);}});},gn=(e,r,t,n,o,i)=>{Re[e]={name:U(r),rawConstructor:Y(t,n),rawDestructor:Y(o,i),fields:[]};},wn=(e,r,t,n,o,i,s,l,u,d)=>{Re[e].fields.push({fieldName:U(r),getterReturnType:t,getter:Y(n,o),getterContext:i,setterArgumentType:s,setter:Y(l,u),setterContext:d});},_n=(e,r)=>{r=U(r),q(e,{isVoid:true,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}});},We=[],En=(e,r,t,n)=>(e=We[e],r=W.toValue(r),e(null,r,t,n)),bn={},cr=e=>{var r=bn[e];return r===void 0?U(e):r},$n=(e,r,t,n,o)=>(e=We[e],r=W.toValue(r),t=cr(t),e(r,r[t],n,o)),Vr=()=>{if(typeof globalThis=="object")return globalThis;function e(r){r.$$$embind_global$$$=r;var t=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return t||delete r.$$$embind_global$$$,t}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&e(global)?$$$embind_global$$$=global:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")},kn=e=>e===0?W.toHandle(Vr()):(e=cr(e),W.toHandle(Vr()[e])),Pn=e=>{var r=We.length;return We.push(e),r},Cn=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=lr($[r+n*4>>2],"parameter "+n);return t},Tn=Reflect.construct,Dn=(e,r,t)=>{var n=[],o=e.toWireType(n,t);return n.length&&($[r>>2]=W.toHandle(n)),o},Fn=(e,r,t)=>{var n=Cn(e,r),o=n.shift();e--;var i=new Array(e),s=(u,d,v,y)=>{for(var p=0,h=0;h<e;++h)i[h]=n[h].readValueFromPointer(y+p),p+=n[h].argPackAdvance;var g=t===1?Tn(d,i):d.apply(u,i);return Dn(o,v,g)},l=`methodCaller<(${n.map(u=>u.name).join(", ")}) => ${o.name}>`;return Pn(Pe(l,s))},Sn=e=>{e>9&&(J[e+1]+=1);},An=()=>W.toHandle([]),Rn=e=>W.toHandle(cr(e)),Mn=()=>W.toHandle({}),On=e=>{var r=W.toValue(e);Qe(r),sr(e);},jn=(e,r,t)=>{e=W.toValue(e),r=W.toValue(r),t=W.toValue(t),e[r]=t;},In=(e,r)=>{e=lr(e,"_emval_take_value");var t=e.readValueFromPointer(r);return W.toHandle(t)},Un=()=>{we("");},Bn=(e,r,t)=>x.copyWithin(e,r,r+t),xn=()=>2147483648,Wn=e=>{var r=Se.buffer,t=(e-r.byteLength+65535)/65536;try{return Se.grow(t),Er(),1}catch{}},Hn=e=>{var r=x.length;e>>>=0;var t=xn();if(e>t)return false;for(var n=(u,d)=>u+(d-u%d)%d,o=1;o<=4;o*=2){var i=r*(1+.2/o);i=Math.min(i,e+100663296);var s=Math.min(t,n(Math.max(e,i),65536)),l=Wn(s);if(l)return true}return false},vr={},Ln=()=>N||"./this.program",Ce=()=>{if(!Ce.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Ln()};for(var t in vr)vr[t]===void 0?delete r[t]:r[t]=vr[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Ce.strings=n;}return Ce.strings},zn=(e,r)=>{for(var t=0;t<e.length;++t)I[r++]=e.charCodeAt(t);I[r]=0;},Nn=(e,r)=>{var t=0;return Ce().forEach((n,o)=>{var i=r+t;$[e+o*4>>2]=i,zn(n,i),t+=n.length+1;}),0},Vn=(e,r)=>{var t=Ce();$[e>>2]=t.length;var n=0;return t.forEach(o=>n+=o.length+1),$[r>>2]=n,0},F={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 o=e[n];o==="."?e.splice(n,1):o===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--);}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=F.isAbs(e),t=e.substr(-1)==="/";return e=F.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=F.splitPath(e),t=r[0],n=r[1];return !t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return "/";e=F.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>F.normalize(e.join("/")),join2:(e,r)=>F.normalize(e+"/"+r)},Yn=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return n=>crypto.getRandomValues(n);if(K)try{var e=Fe("crypto"),r=e.randomFillSync;if(r)return n=>e.randomFillSync(n);var t=e.randomBytes;return n=>(n.set(t(n.byteLength)),n)}catch{}we("initRandomDevice");},Yr=e=>(Yr=Yn())(e),Q={resolve:(...e)=>{for(var r="",t=false,n=e.length-1;n>=-1&&!t;n--){var o=n>=0?e[n]:a.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return "";r=o+"/"+r,t=F.isAbs(o);}return r=F.normalizeArray(r.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=Q.resolve(e).substr(1),r=Q.resolve(r).substr(1);function t(d){for(var v=0;v<d.length&&d[v]==="";v++);for(var y=d.length-1;y>=0&&d[y]==="";y--);return v>y?[]:d.slice(v,y-v+1)}for(var n=t(e.split("/")),o=t(r.split("/")),i=Math.min(n.length,o.length),s=i,l=0;l<i;l++)if(n[l]!==o[l]){s=l;break}for(var u=[],l=s;l<n.length;l++)u.push("..");return u=u.concat(o.slice(s)),u.join("/")}},hr=[];function He(e,r,t){var n=dr(e)+1,o=new Array(n),i=fr(e,o,0,o.length);return r&&(o.length=i),o}var qn=()=>{if(!hr.length){var e=null;if(K){var r=256,t=Buffer.alloc(r),n=0,o=process.stdin.fd;try{n=Ye.readSync(o,t);}catch(i){if(i.toString().includes("EOF"))n=0;else throw i}n>0?e=t.slice(0,n).toString("utf-8"):e=null;}else typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
1
|
+
var $a=(()=>{var F=import.meta.url;return(async function($={}){var d=$,_,S;d.ready=new Promise((e,r)=>{_=e,S=r;});var B=Object.assign({},d),x="./this.program",te=typeof window=="object",j=typeof importScripts=="function",Q=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",Y="";function Ne(e){return d.locateFile?d.locateFile(e,Y):Y+e}var me,Ve,Te;if(Q){let{createRequire:e}=await import('module');var De=e(import.meta.url),Ye=De("fs"),qe=De("path");j?Y=qe.dirname(Y)+"/":Y=De("url").fileURLToPath(new URL("./",import.meta.url)),me=(r,t)=>(r=Pr(r)?new URL(r):qe.normalize(r),Ye.readFileSync(r,t?void 0:"utf8")),Te=r=>{var t=me(r,true);return t.buffer||(t=new Uint8Array(t)),t},Ve=(r,t,n,o=true)=>{r=Pr(r)?new URL(r):qe.normalize(r),Ye.readFile(r,o?void 0:"utf8",(i,s)=>{i?n(i):t(o?s.buffer:s);});},!d.thisProgram&&process.argv.length>1&&(x=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2);}else (te||j)&&(j?Y=self.location.href:typeof document<"u"&&document.currentScript&&(Y=document.currentScript.src),F&&(Y=F),Y.startsWith("blob:")?Y="":Y=Y.substr(0,Y.replace(/[?#].*/,"").lastIndexOf("/")+1),me=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.send(null),r.responseText},j&&(Te=e=>{var r=new XMLHttpRequest;return r.open("GET",e,false),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Ve=(e,r,t)=>{var n=new XMLHttpRequest;n.open("GET",e,true),n.responseType="arraybuffer",n.onload=()=>{if(n.status==200||n.status==0&&n.response){r(n.response);return}t();},n.onerror=t,n.send(null);});var Xe=d.print||console.log.bind(console),ne=d.printErr||console.error.bind(console);Object.assign(d,B),B=null,d.arguments&&(d.arguments),d.thisProgram&&(x=d.thisProgram),d.quit&&(d.quit);var pe;d.wasmBinary&&(pe=d.wasmBinary);var Fe,yr=false,H,L,de,ye,E,k,gr,wr;function _r(){var e=Fe.buffer;d.HEAP8=H=new Int8Array(e),d.HEAP16=de=new Int16Array(e),d.HEAPU8=L=new Uint8Array(e),d.HEAPU16=ye=new Uint16Array(e),d.HEAP32=E=new Int32Array(e),d.HEAPU32=k=new Uint32Array(e),d.HEAPF32=gr=new Float32Array(e),d.HEAPF64=wr=new Float64Array(e);}var Er=[],br=[],$r=[];function nt(){if(d.preRun)for(typeof d.preRun=="function"&&(d.preRun=[d.preRun]);d.preRun.length;)it(d.preRun.shift());Je(Er);}function at(){!d.noFSInit&&!a.init.initialized&&a.init(),a.ignorePermissions=false,Je(br);}function ot(){if(d.postRun)for(typeof d.postRun=="function"&&(d.postRun=[d.postRun]);d.postRun.length;)lt(d.postRun.shift());Je($r);}function it(e){Er.unshift(e);}function st(e){br.unshift(e);}function lt(e){$r.unshift(e);}var oe=0,ge=null;function Ke(e){oe++,d.monitorRunDependencies?.(oe);}function Ae(e){if(oe--,d.monitorRunDependencies?.(oe),oe==0&&(ge)){var r=ge;ge=null,r();}}function fe(e){d.onAbort?.(e),e="Aborted("+e+")",ne(e),yr=true,e+=". Build with -sASSERTIONS for more info.";var r=new WebAssembly.RuntimeError(e);throw S(r),r}var ut="data:application/octet-stream;base64,",kr=e=>e.startsWith(ut),Pr=e=>e.startsWith("file://"),ie;d.locateFile?(ie="heic-decoder.wasm",kr(ie)||(ie=Ne(ie))):ie=new URL("heic-decoder.wasm",import.meta.url).href;function Cr(e){if(e==ie&&pe)return new Uint8Array(pe);if(Te)return Te(e);throw "both async and sync fetching of the wasm failed"}function dt(e){return !pe&&(te||j)&&typeof fetch=="function"?fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw `failed to load wasm binary file at '${e}'`;return r.arrayBuffer()}).catch(()=>Cr(e)):Promise.resolve().then(()=>Cr(e))}function Tr(e,r,t){return dt(e).then(n=>WebAssembly.instantiate(n,r)).then(t,n=>{ne(`failed to asynchronously prepare wasm: ${n}`),fe(n);})}function ft(e,r,t,n){return !e&&typeof WebAssembly.instantiateStreaming=="function"&&!kr(r)&&!Q&&typeof fetch=="function"?fetch(r,{credentials:"same-origin"}).then(o=>{var i=WebAssembly.instantiateStreaming(o,t);return i.then(n,function(s){return ne(`wasm streaming compile failed: ${s}`),ne("falling back to ArrayBuffer instantiation"),Tr(r,t,n)})}):Tr(r,t,n)}function ct(){var e={a:ca};function r(n,o){return I=n.exports,Fe=I.R,_r(),Hr=I.U,st(I.S),Ae(),I}Ke();function t(n){r(n.instance);}if(d.instantiateWasm)try{return d.instantiateWasm(e,r)}catch(n){ne(`Module.instantiateWasm callback failed with error: ${n}`),S(n);}return ft(pe,ie,e,t).catch(S),{}}var b,U,Je=e=>{for(;e.length>0;)e.shift()(d);};d.noExitRuntime||true;var Dr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,ce=(e,r,t)=>{for(var n=r+t,o=r;e[o]&&!(o>=n);)++o;if(o-r>16&&e.buffer&&Dr)return Dr.decode(e.subarray(r,o));for(var i="";r<o;){var s=e[r++];if(!(s&128)){i+=String.fromCharCode(s);continue}var l=e[r++]&63;if((s&224)==192){i+=String.fromCharCode((s&31)<<6|l);continue}var u=e[r++]&63;if((s&240)==224?s=(s&15)<<12|l<<6|u:s=(s&7)<<18|l<<12|u<<6|e[r++]&63,s<65536)i+=String.fromCharCode(s);else {var f=s-65536;i+=String.fromCharCode(55296|f>>10,56320|f&1023);}}return i},se=(e,r)=>e?ce(L,e,r):"",vt=(e,r,t,n)=>{fe(`Assertion failed: ${se(e)}, at: `+[r?se(r):"unknown filename",t,n?se(n):"unknown function"]);};class ht{constructor(r){this.excPtr=r,this.ptr=r-24;}set_type(r){k[this.ptr+4>>2]=r;}get_type(){return k[this.ptr+4>>2]}set_destructor(r){k[this.ptr+8>>2]=r;}get_destructor(){return k[this.ptr+8>>2]}set_caught(r){r=r?1:0,H[this.ptr+12]=r;}get_caught(){return H[this.ptr+12]!=0}set_rethrown(r){r=r?1:0,H[this.ptr+13]=r;}get_rethrown(){return H[this.ptr+13]!=0}init(r,t){this.set_adjusted_ptr(0),this.set_type(r),this.set_destructor(t);}set_adjusted_ptr(r){k[this.ptr+16>>2]=r;}get_adjusted_ptr(){return k[this.ptr+16>>2]}get_exception_ptr(){var r=Kr(this.get_type());if(r)return k[this.excPtr>>2];var t=this.get_adjusted_ptr();return t!==0?t:this.excPtr}}var Fr=0,pt=(e,r,t)=>{var n=new ht(e);throw n.init(r,t),Fr=e,Fr},A={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 o=e[n];o==="."?e.splice(n,1):o===".."?(e.splice(n,1),t++):t&&(e.splice(n,1),t--);}if(r)for(;t;t--)e.unshift("..");return e},normalize:e=>{var r=A.isAbs(e),t=e.substr(-1)==="/";return e=A.normalizeArray(e.split("/").filter(n=>!!n),!r).join("/"),!e&&!r&&(e="."),e&&t&&(e+="/"),(r?"/":"")+e},dirname:e=>{var r=A.splitPath(e),t=r[0],n=r[1];return !t&&!n?".":(n&&(n=n.substr(0,n.length-1)),t+n)},basename:e=>{if(e==="/")return "/";e=A.normalize(e),e=e.replace(/\/$/,"");var r=e.lastIndexOf("/");return r===-1?e:e.substr(r+1)},join:(...e)=>A.normalize(e.join("/")),join2:(e,r)=>A.normalize(e+"/"+r)},yt=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return n=>crypto.getRandomValues(n);if(Q)try{var e=De("crypto"),r=e.randomFillSync;if(r)return n=>e.randomFillSync(n);var t=e.randomBytes;return n=>(n.set(t(n.byteLength)),n)}catch{}fe("initRandomDevice");},Ar=e=>(Ar=yt())(e),Z={resolve:(...e)=>{for(var r="",t=false,n=e.length-1;n>=-1&&!t;n--){var o=n>=0?e[n]:a.cwd();if(typeof o!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!o)return "";r=o+"/"+r,t=A.isAbs(o);}return r=A.normalizeArray(r.split("/").filter(i=>!!i),!t).join("/"),(t?"/":"")+r||"."},relative:(e,r)=>{e=Z.resolve(e).substr(1),r=Z.resolve(r).substr(1);function t(f){for(var v=0;v<f.length&&f[v]==="";v++);for(var y=f.length-1;y>=0&&f[y]==="";y--);return v>y?[]:f.slice(v,y-v+1)}for(var n=t(e.split("/")),o=t(r.split("/")),i=Math.min(n.length,o.length),s=i,l=0;l<i;l++)if(n[l]!==o[l]){s=l;break}for(var u=[],l=s;l<n.length;l++)u.push("..");return u=u.concat(o.slice(s)),u.join("/")}},Qe=[],Ze=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},er=(e,r,t,n)=>{if(!(n>0))return 0;for(var o=t,i=t+n-1,s=0;s<e.length;++s){var l=e.charCodeAt(s);if(l>=55296&&l<=57343){var u=e.charCodeAt(++s);l=65536+((l&1023)<<10)|u&1023;}if(l<=127){if(t>=i)break;r[t++]=l;}else if(l<=2047){if(t+1>=i)break;r[t++]=192|l>>6,r[t++]=128|l&63;}else if(l<=65535){if(t+2>=i)break;r[t++]=224|l>>12,r[t++]=128|l>>6&63,r[t++]=128|l&63;}else {if(t+3>=i)break;r[t++]=240|l>>18,r[t++]=128|l>>12&63,r[t++]=128|l>>6&63,r[t++]=128|l&63;}}return r[t]=0,t-o};function Se(e,r,t){var n=Ze(e)+1,o=new Array(n),i=er(e,o,0,o.length);return r&&(o.length=i),o}var gt=()=>{if(!Qe.length){var e=null;if(Q){var r=256,t=Buffer.alloc(r),n=0,o=process.stdin.fd;try{n=Ye.readSync(o,t);}catch(i){if(i.toString().includes("EOF"))n=0;else throw i}n>0?e=t.slice(0,n).toString("utf-8"):e=null;}else typeof window<"u"&&typeof window.prompt=="function"?(e=window.prompt("Input: "),e!==null&&(e+=`
|
|
3
2
|
`)):typeof readline=="function"&&(e=readline(),e!==null&&(e+=`
|
|
4
|
-
`));if(!e)return null;hr=He(e,true);}return hr.shift()},te={ttys:[],init(){},shutdown(){},register(e,r){te.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,te.stream_ops);},stream_ops:{open(e){var r=te.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=false;},close(e){e.tty.ops.fsync(e.tty);},fsync(e){e.tty.ops.fsync(e.tty);},read(e,r,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var i=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&&i===0)throw new a.ErrnoError(6);if(l==null)break;i++,r[t+s]=l;}return i&&(e.node.timestamp=Date.now()),i},write(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,r[t+i]);}catch{throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char(e){return qn()},put_char(e,r){r===null||r===10?(Xe(ce(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(Xe(ce(e.output,0)),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?(re(ce(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(re(ce(e.output,0)),e.output=[]);}}},qr=e=>{we();},w={ops_table:null,mount(e){return w.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);w.ops_table||={dir:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,lookup:w.node_ops.lookup,mknod:w.node_ops.mknod,rename:w.node_ops.rename,unlink:w.node_ops.unlink,rmdir:w.node_ops.rmdir,readdir:w.node_ops.readdir,symlink:w.node_ops.symlink},stream:{llseek:w.stream_ops.llseek}},file:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:{llseek:w.stream_ops.llseek,read:w.stream_ops.read,write:w.stream_ops.write,allocate:w.stream_ops.allocate,mmap:w.stream_ops.mmap,msync:w.stream_ops.msync}},link:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,readlink:w.node_ops.readlink},stream:{}},chrdev:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:a.chrdev_stream_ops}};var o=a.createNode(e,r,t,n);return a.isDir(o.mode)?(o.node_ops=w.ops_table.dir.node,o.stream_ops=w.ops_table.dir.stream,o.contents={}):a.isFile(o.mode)?(o.node_ops=w.ops_table.file.node,o.stream_ops=w.ops_table.file.stream,o.usedBytes=0,o.contents=null):a.isLink(o.mode)?(o.node_ops=w.ops_table.link.node,o.stream_ops=w.ops_table.link.stream):a.isChrdev(o.mode)&&(o.node_ops=w.ops_table.chrdev.node,o.stream_ops=w.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[r]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var o=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(o.subarray(0,e.usedBytes),0);}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else {var t=e.contents;e.contents=new Uint8Array(r),t&&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.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&w.resizeFileStorage(e,r.size);},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return w.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t);}catch{}if(n)for(var o in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r;},unlink(e,r){delete e.contents[r],e.timestamp=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.timestamp=Date.now();},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var n=w.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,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(s>8&&i.subarray)r.set(i.subarray(o,o+s),t);else for(var l=0;l<s;l++)r[t+l]=i[o+l];return s},write(e,r,t,n,o,i){if(r.buffer===I.buffer&&(i=false),!n)return 0;var s=e.node;if(s.timestamp=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=r.subarray(t,t+n),s.usedBytes=n,n;if(s.usedBytes===0&&o===0)return s.contents=r.slice(t,t+n),s.usedBytes=n,n;if(o+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),o),n}if(w.expandFileStorage(s,o+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),o);else for(var l=0;l<n;l++)s.contents[o+l]=r[t+l];return s.usedBytes=Math.max(s.usedBytes,o+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},allocate(e,r,t){w.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t);},mmap(e,r,t,n,o){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var i,s,l=e.node.contents;if(!(o&2)&&l.buffer===I.buffer)s=false,i=l.byteOffset;else {if((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),s=true,i=qr(),!i)throw new a.ErrnoError(48);I.set(l,i);}return {ptr:i,allocated:s}},msync(e,r,t,n,o){return w.stream_ops.write(e,r,0,n,t,false),0}}},Xn=(e,r,t,n)=>{var o=`al ${e}`;Ve(e,i=>{r(new Uint8Array(i)),o&&Ae();},i=>{if(t)t();else throw `Loading data file "${e}" failed.`}),o&&Ke();},Gn=(e,r,t,n,o,i)=>{a.createDataFile(e,r,t,n,o,i);},Kn=f.preloadPlugins||[],Jn=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var o=false;return Kn.forEach(i=>{o||i.canHandle(r)&&(i.handle(e,r,t,n),o=true);}),o},Qn=(e,r,t,n,o,i,s,l,u,d)=>{var v=r?Q.resolve(F.join2(e,r)):e;function p(h){function g(D){d?.(),l||Gn(e,r,D,n,o,u),i?.(),Ae();}Jn(h,v,g,()=>{s?.(),Ae();})||g(h);}Ke(),typeof t=="string"?Xn(t,p,s):p(t);},Zn=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},mr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e;}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.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{constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=a.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146;}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=Q.resolve(e),!e)return {path:"",node:null};var t={follow_mount:true,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(y=>!!y),o=a.root,i="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(o=a.lookupNode(o,n[s]),i=F.join2(i,n[s]),a.isMountpoint(o)&&(!l||l&&r.follow_mount)&&(o=o.mounted.root),!l||r.follow)for(var u=0;a.isLink(o.mode);){var d=a.readlink(i);i=Q.resolve(F.dirname(i),d);var v=a.lookupPath(i,{recurse_count:r.recurse_count+1});if(o=v.node,u++>40)throw new a.ErrnoError(32)}}return {path:i,node:o}},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),o=a.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===r)return o}return a.lookup(e,r)},createNode(e,r,t,n){var o=new a.FSNode(e,r,t,n);return a.hashAddNode(o),o},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){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(i){return i.errno}var o=a.nodePermissions(e,"wx");if(o)return o;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){return e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44},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 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},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=false),a.syncFSRequests++,a.syncFSRequests>1&&re(`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 o(s){return a.syncFSRequests--,r(s)}function i(s){if(s)return i.errored?void 0:(i.errored=true,o(s));++n>=t.length&&o(null);}t.forEach(s=>{if(!s.type.syncfs)return i(null);s.type.syncfs(s,e,i);});},mount(e,r,t){var n=t==="/",o=!t,i;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!o){var s=a.lookupPath(t,{follow_mount:false});if(t=s.path,i=s.node,a.isMountpoint(i))throw new a.ErrnoError(10);if(!a.isDir(i.mode))throw new a.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(l);return u.mount=l,l.root=u,n?a.root=u:i&&(i.mounted=l,i.mount&&i.mount.mounts.push(l)),u},unmount(e){var r=a.lookupPath(e,{follow_mount:false});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,o=a.getMounts(n);Object.keys(a.nameTable).forEach(s=>{for(var l=a.nameTable[s];l;){var u=l.name_next;o.includes(l.mount)&&a.destroyNode(l),l=u;}}),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1);},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=a.lookupPath(e,{parent:true}),o=n.node,i=F.basename(e);if(!i||i==="."||i==="..")throw new a.ErrnoError(28);var s=a.mayCreate(o,i);if(s)throw new a.ErrnoError(s);if(!o.node_ops.mknod)throw new a.ErrnoError(63);return o.node_ops.mknod(o,i,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{a.mkdir(n,r);}catch(i){if(i.errno!=20)throw i}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)},symlink(e,r){if(!Q.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:true}),n=t.node;if(!n)throw new a.ErrnoError(44);var o=F.basename(r),i=a.mayCreate(n,o);if(i)throw new a.ErrnoError(i);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,o,e)},rename(e,r){var t=F.dirname(e),n=F.dirname(r),o=F.basename(e),i=F.basename(r),s,l,u;if(s=a.lookupPath(e,{parent:true}),l=s.node,s=a.lookupPath(r,{parent:true}),u=s.node,!l||!u)throw new a.ErrnoError(44);if(l.mount!==u.mount)throw new a.ErrnoError(75);var d=a.lookupNode(l,o),v=Q.relative(e,n);if(v.charAt(0)!==".")throw new a.ErrnoError(28);if(v=Q.relative(r,t),v.charAt(0)!==".")throw new a.ErrnoError(55);var y;try{y=a.lookupNode(u,i);}catch{}if(d!==y){var p=a.isDir(d.mode),h=a.mayDelete(l,o,p);if(h)throw new a.ErrnoError(h);if(h=y?a.mayDelete(u,i,p):a.mayCreate(u,i),h)throw new a.ErrnoError(h);if(!l.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(d)||y&&a.isMountpoint(y))throw new a.ErrnoError(10);if(u!==l&&(h=a.nodePermissions(l,"w"),h))throw new a.ErrnoError(h);a.hashRemoveNode(d);try{l.node_ops.rename(d,u,i);}catch(g){throw g}finally{a.hashAddNode(d);}}},rmdir(e){var r=a.lookupPath(e,{parent:true}),t=r.node,n=F.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,true);if(i)throw new a.ErrnoError(i);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(o);},readdir(e){var r=a.lookupPath(e,{follow:true}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=a.lookupPath(e,{parent:true}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=F.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,false);if(i)throw new a.ErrnoError(i);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(o);},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 Q.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return a.stat(e,true)},chmod(e,r,t){var n;if(typeof e=="string"){var o=a.lookupPath(e,{follow:!t});n=o.node;}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()});},lchmod(e,r){a.chmod(e,r,true);},fchmod(e,r){var t=a.getStreamChecked(e);a.chmod(t.node,r);},chown(e,r,t,n){var o;if(typeof e=="string"){var i=a.lookupPath(e,{follow:!n});o=i.node;}else o=e;if(!o.node_ops.setattr)throw new a.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()});},lchown(e,r,t){a.chown(e,r,t,true);},fchown(e,r,t){var n=a.getStreamChecked(e);a.chown(n.node,r,t);},truncate(e,r){if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:true});t=n.node;}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var o=a.nodePermissions(t,"w");if(o)throw new a.ErrnoError(o);t.node_ops.setattr(t,{size:r,timestamp:Date.now()});},ftruncate(e,r){var t=a.getStreamChecked(e);if((t.flags&2097155)===0)throw new a.ErrnoError(28);a.truncate(t.node,r);},utime(e,r,t){var n=a.lookupPath(e,{follow:true}),o=n.node;o.node_ops.setattr(o,{timestamp:Math.max(r,t)});},open(e,r,t){if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?Zn(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else {e=F.normalize(e);try{var o=a.lookupPath(e,{follow:!(r&131072)});n=o.node;}catch{}}var i=false;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),i=true;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(!i){var s=a.mayOpen(n,r);if(s)throw new a.ErrnoError(s)}r&512&&!i&&a.truncate(n,0),r&=-131713;var l=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:true,position:0,stream_ops:n.stream_ops,ungotten:[],error:false});return l.stream_ops.open&&l.stream_ops.open(l),f.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),l},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,o){if(n<0||o<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 i=typeof o<"u";if(!i)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,o);return i||(e.position+=s),s},write(e,r,t,n,o,i){if(n<0||o<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 o<"u";if(!s)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,o,i);return s||(e.position+=l),l},allocate(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t);},mmap(e,r,t,n,o){if((n&2)!==0&&(o&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);return e.stream_ops.mmap(e,r,t,n,o)},msync(e,r,t,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):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={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=a.open(e,r.flags),o=a.stat(e),i=o.size,s=new Uint8Array(i);return a.read(n,s,0,i,0),r.encoding==="utf8"?t=ce(s,0):r.encoding==="binary"&&(t=s),a.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var o=new Uint8Array(dr(r)+1),i=fr(r,o,0,o.length);a.write(n,o,0,i,void 0,t.canOwn);}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n);},cwd:()=>a.currentPath,chdir(e){var r=a.lookupPath(e,{follow:true});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,o,i,s,l)=>s}),a.mkdev("/dev/null",a.makedev(1,3)),te.register(a.makedev(5,0),te.default_tty_ops),te.register(a.makedev(6,0),te.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&&(r=Yr(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.node_ops={lookup(t,n){var o=+n,i=a.getStreamChecked(o),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return s.parent=s,s}},r}},{},"/proc/self/fd");},createStandardStreams(){f.stdin?a.createDevice("/dev","stdin",f.stdin):a.symlink("/dev/tty","/dev/stdin"),f.stdout?a.createDevice("/dev","stdout",null,f.stdout):a.symlink("/dev/tty","/dev/stdout"),f.stderr?a.createDevice("/dev","stderr",null,f.stderr):a.symlink("/dev/tty1","/dev/stderr");a.open("/dev/stdin",0);a.open("/dev/stdout",1);a.open("/dev/stderr",1);},staticInit(){[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>";}),a.nameTable=new Array(4096),a.mount(w,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:w};},init(e,r,t){a.init.initialized=true,f.stdin=e||f.stdin,f.stdout=r||f.stdout,f.stderr=t||f.stderr,a.createStandardStreams();},quit(){a.init.initialized=false;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r);}},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:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,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=F.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(o){n.error=o.errno;}return n},createPath(e,r,t,n){e=typeof e=="string"?e:a.getPath(e);for(var o=r.split("/").reverse();o.length;){var i=o.pop();if(i){var s=F.join2(e,i);try{a.mkdir(s);}catch{}e=s;}}return s},createFile(e,r,t,n,o){var i=F.join2(typeof e=="string"?e:a.getPath(e),r),s=mr(n,o);return a.create(i,s)},createDataFile(e,r,t,n,o,i){var s=r;e&&(e=typeof e=="string"?e:a.getPath(e),s=r?F.join2(e,r):e);var l=mr(n,o),u=a.create(s,l);if(t){if(typeof t=="string"){for(var d=new Array(t.length),v=0,y=t.length;v<y;++v)d[v]=t.charCodeAt(v);t=d;}a.chmod(u,l|146);var p=a.open(u,577);a.write(p,t,0,t.length,0,i),a.close(p),a.chmod(u,l);}},createDevice(e,r,t,n){var o=F.join2(typeof e=="string"?e:a.getPath(e),r),i=mr(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(l){l.seekable=false;},close(l){n?.buffer?.length&&n(10);},read(l,u,d,v,y){for(var p=0,h=0;h<v;h++){var g;try{g=t();}catch{throw new a.ErrnoError(29)}if(g===void 0&&p===0)throw new a.ErrnoError(6);if(g==null)break;p++,u[d+h]=g;}return p&&(l.node.timestamp=Date.now()),p},write(l,u,d,v,y){for(var p=0;p<v;p++)try{n(u[d+p]);}catch{throw new a.ErrnoError(29)}return v&&(l.node.timestamp=Date.now()),p}}),a.mkdev(o,i,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return true;if(typeof XMLHttpRequest<"u")throw new Error("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.");if(me)try{e.contents=He(me(e.url),!0),e.usedBytes=e.contents.length;}catch{throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(e,r,t,n,o){class i{constructor(){this.lengthKnown=false,this.chunks=[];}get(h){if(!(h>this.length-1||h<0)){var g=h%this.chunkSize,D=h/this.chunkSize|0;return this.getter(D)[g]}}setDataGetter(h){this.getter=h;}cacheLength(){var h=new XMLHttpRequest;if(h.open("HEAD",t,false),h.send(null),!(h.status>=200&&h.status<300||h.status===304))throw new Error("Couldn't load "+t+". Status: "+h.status);var g=Number(h.getResponseHeader("Content-length")),D,A=(D=h.getResponseHeader("Accept-Ranges"))&&D==="bytes",T=(D=h.getResponseHeader("Content-Encoding"))&&D==="gzip",c=1024*1024;A||(c=g);var m=(k,H)=>{if(k>H)throw new Error("invalid range ("+k+", "+H+") or no bytes requested!");if(H>g-1)throw new Error("only "+g+" bytes available! programmer error!");var R=new XMLHttpRequest;if(R.open("GET",t,false),g!==c&&R.setRequestHeader("Range","bytes="+k+"-"+H),R.responseType="arraybuffer",R.overrideMimeType&&R.overrideMimeType("text/plain; charset=x-user-defined"),R.send(null),!(R.status>=200&&R.status<300||R.status===304))throw new Error("Couldn't load "+t+". Status: "+R.status);return R.response!==void 0?new Uint8Array(R.response||[]):He(R.responseText||"",true)},M=this;M.setDataGetter(k=>{var H=k*c,R=(k+1)*c-1;if(R=Math.min(R,g-1),typeof M.chunks[k]>"u"&&(M.chunks[k]=m(H,R)),typeof M.chunks[k]>"u")throw new Error("doXHR failed!");return M.chunks[k]}),(T||!g)&&(c=g=1,g=this.getter(0).length,c=g,Xe("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=c,this.lengthKnown=true;}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!V)throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i,l={isDevice:false,contents:s};}else var l={isDevice:false,url:t};var u=a.createFile(e,r,l,n,o);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var d={},v=Object.keys(u.stream_ops);v.forEach(p=>{var h=u.stream_ops[p];d[p]=(...g)=>(a.forceLoadFile(u),h(...g));});function y(p,h,g,D,A){var T=p.node.contents;if(A>=T.length)return 0;var c=Math.min(T.length-A,D);if(T.slice)for(var m=0;m<c;m++)h[g+m]=T[A+m];else for(var m=0;m<c;m++)h[g+m]=T.get(A+m);return c}return d.read=(p,h,g,D,A)=>(a.forceLoadFile(u),y(p,h,g,D,A)),d.mmap=(p,h,g,D,A)=>{a.forceLoadFile(u);var T=qr();if(!T)throw new a.ErrnoError(48);return y(p,I,T,h,g),{ptr:T,allocated:true}},u.stream_ops=d,u}},ne={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(F.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else {var o=ne.getStreamFromFD(e);n=o.path;}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return F.join2(n,r)},doStat(e,r,t){var n=e(r);E[t>>2]=n.dev,E[t+4>>2]=n.mode,$[t+8>>2]=n.nlink,E[t+12>>2]=n.uid,E[t+16>>2]=n.gid,E[t+20>>2]=n.rdev,j=[n.size>>>0,(b=n.size,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+24>>2]=j[0],E[t+28>>2]=j[1],E[t+32>>2]=4096,E[t+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),s=n.ctime.getTime();return j=[Math.floor(o/1e3)>>>0,(b=Math.floor(o/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+40>>2]=j[0],E[t+44>>2]=j[1],$[t+48>>2]=o%1e3*1e3,j=[Math.floor(i/1e3)>>>0,(b=Math.floor(i/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+56>>2]=j[0],E[t+60>>2]=j[1],$[t+64>>2]=i%1e3*1e3,j=[Math.floor(s/1e3)>>>0,(b=Math.floor(s/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+72>>2]=j[0],E[t+76>>2]=j[1],$[t+80>>2]=s%1e3*1e3,j=[n.ino>>>0,(b=n.ino,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+88>>2]=j[0],E[t+92>>2]=j[1],0},doMsync(e,r,t,n,o){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var i=x.slice(e,e+t);a.msync(r,i,o,t,n);},varargs:void 0,get(){var e=E[+ne.varargs>>2];return ne.varargs+=4,e},getp(){return ne.get()},getStr(e){var r=ie(e);return r},getStreamFromFD(e){var r=a.getStreamChecked(e);return r}};function ea(e){try{var r=ne.getStreamFromFD(e);return a.close(r),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var ra=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=$[r>>2],l=$[r+4>>2];r+=8;var u=a.read(e,I,s,l,n);if(u<0)return -1;if(o+=u,u<l)break;}return o};function ta(e,r,t,n){try{var o=ne.getStreamFromFD(e),i=ra(o,r,t);return $[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var na=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN;function aa(e,r,t,n,o){var i=na(r,t);try{if(isNaN(i))return 61;var s=ne.getStreamFromFD(e);return a.llseek(s,i,n),j=[s.position>>>0,(b=s.position,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[o>>2]=j[0],E[o+4>>2]=j[1],s.getdents&&i===0&&n===0&&(s.getdents=null),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var oa=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=$[r>>2],l=$[r+4>>2];r+=8;var u=a.write(e,I,s,l,n);if(u<0)return -1;o+=u;}return o};function ia(e,r,t,n){try{var o=ne.getStreamFromFD(e),i=oa(o,r,t);return $[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var Le=e=>e%4===0&&(e%100!==0||e%400===0),sa=(e,r)=>{for(var t=0,n=0;n<=r;t+=e[n++]);return t},Xr=[31,29,31,30,31,30,31,31,30,31,30,31],Gr=[31,28,31,30,31,30,31,31,30,31,30,31],la=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var n=Le(t.getFullYear()),o=t.getMonth(),i=(n?Xr:Gr)[o];if(r>i-t.getDate())r-=i-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t},ua=(e,r)=>{I.set(e,r);},fa=(e,r,t,n)=>{var o=$[n+40>>2],i={tm_sec:E[n>>2],tm_min:E[n+4>>2],tm_hour:E[n+8>>2],tm_mday:E[n+12>>2],tm_mon:E[n+16>>2],tm_year:E[n+20>>2],tm_wday:E[n+24>>2],tm_yday:E[n+28>>2],tm_isdst:E[n+32>>2],tm_gmtoff:E[n+36>>2],tm_zone:o?ie(o):""},s=ie(t),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in l)s=s.replace(new RegExp(u,"g"),l[u]);var d=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],v=["January","February","March","April","May","June","July","August","September","October","November","December"];function y(c,m,M){for(var k=typeof c=="number"?c.toString():c||"";k.length<m;)k=M[0]+k;return k}function p(c,m){return y(c,m,"0")}function h(c,m){function M(H){return H<0?-1:H>0?1:0}var k;return (k=M(c.getFullYear()-m.getFullYear()))===0&&(k=M(c.getMonth()-m.getMonth()))===0&&(k=M(c.getDate()-m.getDate())),k}function g(c){switch(c.getDay()){case 0:return new Date(c.getFullYear()-1,11,29);case 1:return c;case 2:return new Date(c.getFullYear(),0,3);case 3:return new Date(c.getFullYear(),0,2);case 4:return new Date(c.getFullYear(),0,1);case 5:return new Date(c.getFullYear()-1,11,31);case 6:return new Date(c.getFullYear()-1,11,30)}}function D(c){var m=la(new Date(c.tm_year+1900,0,1),c.tm_yday),M=new Date(m.getFullYear(),0,4),k=new Date(m.getFullYear()+1,0,4),H=g(M),R=g(k);return h(H,m)<=0?h(R,m)<=0?m.getFullYear()+1:m.getFullYear():m.getFullYear()-1}var A={"%a":c=>d[c.tm_wday].substring(0,3),"%A":c=>d[c.tm_wday],"%b":c=>v[c.tm_mon].substring(0,3),"%B":c=>v[c.tm_mon],"%C":c=>{var m=c.tm_year+1900;return p(m/100|0,2)},"%d":c=>p(c.tm_mday,2),"%e":c=>y(c.tm_mday,2," "),"%g":c=>D(c).toString().substring(2),"%G":D,"%H":c=>p(c.tm_hour,2),"%I":c=>{var m=c.tm_hour;return m==0?m=12:m>12&&(m-=12),p(m,2)},"%j":c=>p(c.tm_mday+sa(Le(c.tm_year+1900)?Xr:Gr,c.tm_mon-1),3),"%m":c=>p(c.tm_mon+1,2),"%M":c=>p(c.tm_min,2),"%n":()=>`
|
|
5
|
-
`,"%p":c=>c.tm_hour>=0&&c.tm_hour<12?"AM":"PM","%S":c=>p(c.tm_sec,2),"%t":()=>" ","%u":c=>c.tm_wday||7,"%U":c=>{var m=c.tm_yday+7-c.tm_wday;return p(Math.floor(m/7),2)},"%V":c=>{var m=Math.floor((c.tm_yday+7-(c.tm_wday+6)%7)/7);if((c.tm_wday+371-c.tm_yday-2)%7<=2&&m++,m){if(m==53){var k=(c.tm_wday+371-c.tm_yday)%7;k!=4&&(k!=3||!Le(c.tm_year))&&(m=1);}}else {m=52;var M=(c.tm_wday+7-c.tm_yday-1)%7;(M==4||M==5&&Le(c.tm_year%400-1))&&m++;}return p(m,2)},"%w":c=>c.tm_wday,"%W":c=>{var m=c.tm_yday+7-(c.tm_wday+6)%7;return p(Math.floor(m/7),2)},"%y":c=>(c.tm_year+1900).toString().substring(2),"%Y":c=>c.tm_year+1900,"%z":c=>{var m=c.tm_gmtoff,M=m>=0;return m=Math.abs(m)/60,m=m/60*100+m%60,(M?"+":"-")+("0000"+m).slice(-4)},"%Z":c=>c.tm_zone,"%%":()=>"%"};s=s.replace(/%%/g,"\0\0");for(var u in A)s.includes(u)&&(s=s.replace(new RegExp(u,"g"),A[u](i)));s=s.replace(/\0\0/g,"%");var T=He(s,false);return T.length>r?0:(ua(T,e),T.length-1)},da=(e,r,t,n,o)=>fa(e,r,t,n);Ar=f.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},_t(),he=f.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Rt(),Dt(),Wt(),Hr=f.UnboundTypeError=Nt(Error,"UnboundTypeError"),Kt(),a.createPreloadedFile=Qn,a.staticInit();var ca={a:ht,p:yt,N:gt,C:wt,L:bt,n:Vt,A:qt,y:Xt,K:Qt,j:en,b:rn,w:nn,f:an,i:sn,e:ln,v:fn,r:yn,O:gn,s:wn,M:_n,o:En,z:$n,c:sr,P:kn,l:Fn,q:Sn,x:An,g:Rn,m:Mn,k:On,h:jn,d:In,t:Un,J:Bn,H:Hn,E:Nn,F:Vn,I:ea,G:ta,B:aa,u:ia,D:da},B=vt(),pr=e=>(pr=B.S)(e),Z=e=>(Z=B.U)(e),Kr=e=>(Kr=B.V)(e),Jr=e=>(Jr=B.W)(e);f.dynCall_ji=(e,r)=>(f.dynCall_ji=B.X)(e,r);f.dynCall_iij=(e,r,t,n)=>(f.dynCall_iij=B.Y)(e,r,t,n);f.dynCall_jiji=(e,r,t,n,o)=>(f.dynCall_jiji=B.Z)(e,r,t,n,o);f.dynCall_viijii=(e,r,t,n,o,i,s)=>(f.dynCall_viijii=B._)(e,r,t,n,o,i,s);f.dynCall_iiiiij=(e,r,t,n,o,i,s)=>(f.dynCall_iiiiij=B.$)(e,r,t,n,o,i,s);f.dynCall_iiiiijj=(e,r,t,n,o,i,s,l,u)=>(f.dynCall_iiiiijj=B.aa)(e,r,t,n,o,i,s,l,u);f.dynCall_iiiiiijj=(e,r,t,n,o,i,s,l,u,d)=>(f.dynCall_iiiiiijj=B.ba)(e,r,t,n,o,i,s,l,u,d);var ze;ge=function e(){ze||Qr(),ze||(ge=e);};function Qr(){if(ae>0||(at(),ae>0))return;function e(){ze||(ze=true,f.calledRun=true,!gr&&(ot(),_(f),f.onRuntimeInitialized&&f.onRuntimeInitialized(),it()));}f.setStatus?(f.setStatus("Running..."),setTimeout(function(){setTimeout(function(){f.setStatus("");},1),e();},1)):e();}if(f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.pop()();return Qr(),P.ready})})(),et=Ea;var Te=class{options;module=null;decoderInstance=null;constructor(P){this.options=P;}async initialize(){if(this.module)return;let P={};this.options?.locateFile&&(P.locateFile=this.options.locateFile),this.options?.wasmBinary&&(P.wasmBinary=this.options.wasmBinary),this.module=await et(P),this.decoderInstance=new this.module.HeicDecoder;}async decode(P,f){(!this.module||!this.decoderInstance)&&await this.initialize();let _=this.decoderInstance.decode(P,f||null);if(!_)throw new Error("HEIC decoding failed");if(typeof _=="string")throw new Error(`HEIC decoding failed: ${_}`);let O=_.width,z=_.height,G=new Uint8ClampedArray(_.data.buffer,_.data.byteOffset,_.data.byteLength);return {width:O,height:z,data:G}}free(){this.decoderInstance&&(this.decoderInstance.delete(),this.decoderInstance=null),this.module=null;}};async function ba(S){if(typeof FileReader<"u")return new Promise((P,f)=>{let _=new FileReader;_.onloadend=()=>{typeof _.result=="string"?P(_.result):f(new Error("Failed to convert Blob to base64 string"));},_.onerror=()=>f(_.error),_.readAsDataURL(S);});try{let P=await S.arrayBuffer(),f=Buffer.from(P);return `data:${S.type};base64,${f.toString("base64")}`}catch(P){throw new Error(`Failed to convert Blob to base64 string: ${P instanceof Error?P.message:String(P)}`,{cause:P})}}function yr(S,P,f){return "convertToBlob"in S?S.convertToBlob({type:P,quality:f}):new Promise((_,O)=>{S.toBlob(z=>{z?_(z):O(new Error("Failed to convert canvas to blob"));},P,f);})}async function rt(S,P,f){let{width:_,height:O,data:z}=S,G=_*O*4;if(z.length!==G)throw new Error(`Image data length mismatch. Expected ${G} bytes for ${_}x${O}, got ${z.length}`);let N;if(typeof OffscreenCanvas<"u")N=new OffscreenCanvas(_,O);else if(typeof document<"u")N=document.createElement("canvas"),N.width=_,N.height=O;else throw new Error("Canvas is not supported in the current environment. Conversion requires a browser environment or canvas polyfills.");let ee=N.getContext("2d");if(!ee)throw new Error("Failed to acquire 2D rendering context from canvas");let fe;if(typeof ImageData<"u")fe=new ImageData(z,_,O);else {let K=ee.createImageData(_,O);K.data.set(z),fe=K;}ee.putImageData(fe,0,0);let V=P.toLowerCase();if(V==="png")return yr(N,"image/png");if(V==="jpeg"||V==="jpg")return yr(N,"image/jpeg",f);if(V==="svg"){let K=await yr(N,"image/png"),L=await ba(K),Ne=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${_} ${O}" width="${_}" height="${O}">
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
`));if(!e)return null;Qe=Se(e,true);}return Qe.shift()},ae={ttys:[],init(){},shutdown(){},register(e,r){ae.ttys[e]={input:[],output:[],ops:r},a.registerDevice(e,ae.stream_ops);},stream_ops:{open(e){var r=ae.ttys[e.node.rdev];if(!r)throw new a.ErrnoError(43);e.tty=r,e.seekable=false;},close(e){e.tty.ops.fsync(e.tty);},fsync(e){e.tty.ops.fsync(e.tty);},read(e,r,t,n,o){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var i=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&&i===0)throw new a.ErrnoError(6);if(l==null)break;i++,r[t+s]=l;}return i&&(e.node.timestamp=Date.now()),i},write(e,r,t,n,o){if(!e.tty||!e.tty.ops.put_char)throw new a.ErrnoError(60);try{for(var i=0;i<n;i++)e.tty.ops.put_char(e.tty,r[t+i]);}catch{throw new a.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char(e){return gt()},put_char(e,r){r===null||r===10?(Xe(ce(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(Xe(ce(e.output,0)),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?(ne(ce(e.output,0)),e.output=[]):r!=0&&e.output.push(r);},fsync(e){e.output&&e.output.length>0&&(ne(ce(e.output,0)),e.output=[]);}}},Sr=e=>{fe();},w={ops_table:null,mount(e){return w.createNode(null,"/",16895,0)},createNode(e,r,t,n){if(a.isBlkdev(t)||a.isFIFO(t))throw new a.ErrnoError(63);w.ops_table||={dir:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,lookup:w.node_ops.lookup,mknod:w.node_ops.mknod,rename:w.node_ops.rename,unlink:w.node_ops.unlink,rmdir:w.node_ops.rmdir,readdir:w.node_ops.readdir,symlink:w.node_ops.symlink},stream:{llseek:w.stream_ops.llseek}},file:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:{llseek:w.stream_ops.llseek,read:w.stream_ops.read,write:w.stream_ops.write,allocate:w.stream_ops.allocate,mmap:w.stream_ops.mmap,msync:w.stream_ops.msync}},link:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr,readlink:w.node_ops.readlink},stream:{}},chrdev:{node:{getattr:w.node_ops.getattr,setattr:w.node_ops.setattr},stream:a.chrdev_stream_ops}};var o=a.createNode(e,r,t,n);return a.isDir(o.mode)?(o.node_ops=w.ops_table.dir.node,o.stream_ops=w.ops_table.dir.stream,o.contents={}):a.isFile(o.mode)?(o.node_ops=w.ops_table.file.node,o.stream_ops=w.ops_table.file.stream,o.usedBytes=0,o.contents=null):a.isLink(o.mode)?(o.node_ops=w.ops_table.link.node,o.stream_ops=w.ops_table.link.stream):a.isChrdev(o.mode)&&(o.node_ops=w.ops_table.chrdev.node,o.stream_ops=w.ops_table.chrdev.stream),o.timestamp=Date.now(),e&&(e.contents[r]=o,e.timestamp=o.timestamp),o},getFileDataAsTypedArray(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage(e,r){var t=e.contents?e.contents.length:0;if(!(t>=r)){var n=1024*1024;r=Math.max(r,t*(t<n?2:1.125)>>>0),t!=0&&(r=Math.max(r,256));var o=e.contents;e.contents=new Uint8Array(r),e.usedBytes>0&&e.contents.set(o.subarray(0,e.usedBytes),0);}},resizeFileStorage(e,r){if(e.usedBytes!=r)if(r==0)e.contents=null,e.usedBytes=0;else {var t=e.contents;e.contents=new Uint8Array(r),t&&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.timestamp),r.mtime=new Date(e.timestamp),r.ctime=new Date(e.timestamp),r.blksize=4096,r.blocks=Math.ceil(r.size/r.blksize),r},setattr(e,r){r.mode!==void 0&&(e.mode=r.mode),r.timestamp!==void 0&&(e.timestamp=r.timestamp),r.size!==void 0&&w.resizeFileStorage(e,r.size);},lookup(e,r){throw a.genericErrors[44]},mknod(e,r,t,n){return w.createNode(e,r,t,n)},rename(e,r,t){if(a.isDir(e.mode)){var n;try{n=a.lookupNode(r,t);}catch{}if(n)for(var o in n.contents)throw new a.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=t,r.contents[t]=e,r.timestamp=e.parent.timestamp,e.parent=r;},unlink(e,r){delete e.contents[r],e.timestamp=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.timestamp=Date.now();},readdir(e){var r=[".",".."];for(var t of Object.keys(e.contents))r.push(t);return r},symlink(e,r,t){var n=w.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,o){var i=e.node.contents;if(o>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-o,n);if(s>8&&i.subarray)r.set(i.subarray(o,o+s),t);else for(var l=0;l<s;l++)r[t+l]=i[o+l];return s},write(e,r,t,n,o,i){if(r.buffer===H.buffer&&(i=false),!n)return 0;var s=e.node;if(s.timestamp=Date.now(),r.subarray&&(!s.contents||s.contents.subarray)){if(i)return s.contents=r.subarray(t,t+n),s.usedBytes=n,n;if(s.usedBytes===0&&o===0)return s.contents=r.slice(t,t+n),s.usedBytes=n,n;if(o+n<=s.usedBytes)return s.contents.set(r.subarray(t,t+n),o),n}if(w.expandFileStorage(s,o+n),s.contents.subarray&&r.subarray)s.contents.set(r.subarray(t,t+n),o);else for(var l=0;l<n;l++)s.contents[o+l]=r[t+l];return s.usedBytes=Math.max(s.usedBytes,o+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},allocate(e,r,t){w.expandFileStorage(e.node,r+t),e.node.usedBytes=Math.max(e.node.usedBytes,r+t);},mmap(e,r,t,n,o){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var i,s,l=e.node.contents;if(!(o&2)&&l.buffer===H.buffer)s=false,i=l.byteOffset;else {if((t>0||t+r<l.length)&&(l.subarray?l=l.subarray(t,t+r):l=Array.prototype.slice.call(l,t,t+r)),s=true,i=Sr(),!i)throw new a.ErrnoError(48);H.set(l,i);}return {ptr:i,allocated:s}},msync(e,r,t,n,o){return w.stream_ops.write(e,r,0,n,t,false),0}}},wt=(e,r,t,n)=>{var o=`al ${e}`;Ve(e,i=>{r(new Uint8Array(i)),o&&Ae();},i=>{if(t)t();else throw `Loading data file "${e}" failed.`}),o&&Ke();},_t=(e,r,t,n,o,i)=>{a.createDataFile(e,r,t,n,o,i);},Et=d.preloadPlugins||[],bt=(e,r,t,n)=>{typeof Browser<"u"&&Browser.init();var o=false;return Et.forEach(i=>{o||i.canHandle(r)&&(i.handle(e,r,t,n),o=true);}),o},$t=(e,r,t,n,o,i,s,l,u,f)=>{var v=r?Z.resolve(A.join2(e,r)):e;function p(h){function g(D){f?.(),l||_t(e,r,D,n,o,u),i?.(),Ae();}bt(h,v,g,()=>{s?.(),Ae();})||g(h);}Ke(),typeof t=="string"?wt(t,p,s):p(t);},kt=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},rr=(e,r)=>{var t=0;return e&&(t|=365),r&&(t|=146),t},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:false,ignorePermissions:true,ErrnoError:class{constructor(e){this.name="ErrnoError",this.errno=e;}},genericErrors:{},filesystems:null,syncFSRequests:0,FSStream:class{constructor(){this.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{constructor(e,r,t,n){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=a.nextInode++,this.name=r,this.mode=t,this.node_ops={},this.stream_ops={},this.rdev=n,this.readMode=365,this.writeMode=146;}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=Z.resolve(e),!e)return {path:"",node:null};var t={follow_mount:true,recurse_count:0};if(r=Object.assign(t,r),r.recurse_count>8)throw new a.ErrnoError(32);for(var n=e.split("/").filter(y=>!!y),o=a.root,i="/",s=0;s<n.length;s++){var l=s===n.length-1;if(l&&r.parent)break;if(o=a.lookupNode(o,n[s]),i=A.join2(i,n[s]),a.isMountpoint(o)&&(!l||l&&r.follow_mount)&&(o=o.mounted.root),!l||r.follow)for(var u=0;a.isLink(o.mode);){var f=a.readlink(i);i=Z.resolve(A.dirname(i),f);var v=a.lookupPath(i,{recurse_count:r.recurse_count+1});if(o=v.node,u++>40)throw new a.ErrnoError(32)}}return {path:i,node:o}},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),o=a.nameTable[n];o;o=o.name_next){var i=o.name;if(o.parent.id===e.id&&i===r)return o}return a.lookup(e,r)},createNode(e,r,t,n){var o=new a.FSNode(e,r,t,n);return a.hashAddNode(o),o},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){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(i){return i.errno}var o=a.nodePermissions(e,"wx");if(o)return o;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){return e?a.isLink(e.mode)?32:a.isDir(e.mode)&&(a.flagsToPermissionString(r)!=="r"||r&512)?31:a.nodePermissions(e,a.flagsToPermissionString(r)):44},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 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},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=false),a.syncFSRequests++,a.syncFSRequests>1&&ne(`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 o(s){return a.syncFSRequests--,r(s)}function i(s){if(s)return i.errored?void 0:(i.errored=true,o(s));++n>=t.length&&o(null);}t.forEach(s=>{if(!s.type.syncfs)return i(null);s.type.syncfs(s,e,i);});},mount(e,r,t){var n=t==="/",o=!t,i;if(n&&a.root)throw new a.ErrnoError(10);if(!n&&!o){var s=a.lookupPath(t,{follow_mount:false});if(t=s.path,i=s.node,a.isMountpoint(i))throw new a.ErrnoError(10);if(!a.isDir(i.mode))throw new a.ErrnoError(54)}var l={type:e,opts:r,mountpoint:t,mounts:[]},u=e.mount(l);return u.mount=l,l.root=u,n?a.root=u:i&&(i.mounted=l,i.mount&&i.mount.mounts.push(l)),u},unmount(e){var r=a.lookupPath(e,{follow_mount:false});if(!a.isMountpoint(r.node))throw new a.ErrnoError(28);var t=r.node,n=t.mounted,o=a.getMounts(n);Object.keys(a.nameTable).forEach(s=>{for(var l=a.nameTable[s];l;){var u=l.name_next;o.includes(l.mount)&&a.destroyNode(l),l=u;}}),t.mounted=null;var i=t.mount.mounts.indexOf(n);t.mount.mounts.splice(i,1);},lookup(e,r){return e.node_ops.lookup(e,r)},mknod(e,r,t){var n=a.lookupPath(e,{parent:true}),o=n.node,i=A.basename(e);if(!i||i==="."||i==="..")throw new a.ErrnoError(28);var s=a.mayCreate(o,i);if(s)throw new a.ErrnoError(s);if(!o.node_ops.mknod)throw new a.ErrnoError(63);return o.node_ops.mknod(o,i,r,t)},create(e,r){return r=r!==void 0?r:438,r&=4095,r|=32768,a.mknod(e,r,0)},mkdir(e,r){return r=r!==void 0?r:511,r&=1023,r|=16384,a.mknod(e,r,0)},mkdirTree(e,r){for(var t=e.split("/"),n="",o=0;o<t.length;++o)if(t[o]){n+="/"+t[o];try{a.mkdir(n,r);}catch(i){if(i.errno!=20)throw i}}},mkdev(e,r,t){return typeof t>"u"&&(t=r,r=438),r|=8192,a.mknod(e,r,t)},symlink(e,r){if(!Z.resolve(e))throw new a.ErrnoError(44);var t=a.lookupPath(r,{parent:true}),n=t.node;if(!n)throw new a.ErrnoError(44);var o=A.basename(r),i=a.mayCreate(n,o);if(i)throw new a.ErrnoError(i);if(!n.node_ops.symlink)throw new a.ErrnoError(63);return n.node_ops.symlink(n,o,e)},rename(e,r){var t=A.dirname(e),n=A.dirname(r),o=A.basename(e),i=A.basename(r),s,l,u;if(s=a.lookupPath(e,{parent:true}),l=s.node,s=a.lookupPath(r,{parent:true}),u=s.node,!l||!u)throw new a.ErrnoError(44);if(l.mount!==u.mount)throw new a.ErrnoError(75);var f=a.lookupNode(l,o),v=Z.relative(e,n);if(v.charAt(0)!==".")throw new a.ErrnoError(28);if(v=Z.relative(r,t),v.charAt(0)!==".")throw new a.ErrnoError(55);var y;try{y=a.lookupNode(u,i);}catch{}if(f!==y){var p=a.isDir(f.mode),h=a.mayDelete(l,o,p);if(h)throw new a.ErrnoError(h);if(h=y?a.mayDelete(u,i,p):a.mayCreate(u,i),h)throw new a.ErrnoError(h);if(!l.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(f)||y&&a.isMountpoint(y))throw new a.ErrnoError(10);if(u!==l&&(h=a.nodePermissions(l,"w"),h))throw new a.ErrnoError(h);a.hashRemoveNode(f);try{l.node_ops.rename(f,u,i);}catch(g){throw g}finally{a.hashAddNode(f);}}},rmdir(e){var r=a.lookupPath(e,{parent:true}),t=r.node,n=A.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,true);if(i)throw new a.ErrnoError(i);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.rmdir(t,n),a.destroyNode(o);},readdir(e){var r=a.lookupPath(e,{follow:true}),t=r.node;if(!t.node_ops.readdir)throw new a.ErrnoError(54);return t.node_ops.readdir(t)},unlink(e){var r=a.lookupPath(e,{parent:true}),t=r.node;if(!t)throw new a.ErrnoError(44);var n=A.basename(e),o=a.lookupNode(t,n),i=a.mayDelete(t,n,false);if(i)throw new a.ErrnoError(i);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(o))throw new a.ErrnoError(10);t.node_ops.unlink(t,n),a.destroyNode(o);},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 Z.resolve(a.getPath(t.parent),t.node_ops.readlink(t))},stat(e,r){var t=a.lookupPath(e,{follow:!r}),n=t.node;if(!n)throw new a.ErrnoError(44);if(!n.node_ops.getattr)throw new a.ErrnoError(63);return n.node_ops.getattr(n)},lstat(e){return a.stat(e,true)},chmod(e,r,t){var n;if(typeof e=="string"){var o=a.lookupPath(e,{follow:!t});n=o.node;}else n=e;if(!n.node_ops.setattr)throw new a.ErrnoError(63);n.node_ops.setattr(n,{mode:r&4095|n.mode&-4096,timestamp:Date.now()});},lchmod(e,r){a.chmod(e,r,true);},fchmod(e,r){var t=a.getStreamChecked(e);a.chmod(t.node,r);},chown(e,r,t,n){var o;if(typeof e=="string"){var i=a.lookupPath(e,{follow:!n});o=i.node;}else o=e;if(!o.node_ops.setattr)throw new a.ErrnoError(63);o.node_ops.setattr(o,{timestamp:Date.now()});},lchown(e,r,t){a.chown(e,r,t,true);},fchown(e,r,t){var n=a.getStreamChecked(e);a.chown(n.node,r,t);},truncate(e,r){if(r<0)throw new a.ErrnoError(28);var t;if(typeof e=="string"){var n=a.lookupPath(e,{follow:true});t=n.node;}else t=e;if(!t.node_ops.setattr)throw new a.ErrnoError(63);if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var o=a.nodePermissions(t,"w");if(o)throw new a.ErrnoError(o);t.node_ops.setattr(t,{size:r,timestamp:Date.now()});},ftruncate(e,r){var t=a.getStreamChecked(e);if((t.flags&2097155)===0)throw new a.ErrnoError(28);a.truncate(t.node,r);},utime(e,r,t){var n=a.lookupPath(e,{follow:true}),o=n.node;o.node_ops.setattr(o,{timestamp:Math.max(r,t)});},open(e,r,t){if(e==="")throw new a.ErrnoError(44);r=typeof r=="string"?kt(r):r,t=typeof t>"u"?438:t,r&64?t=t&4095|32768:t=0;var n;if(typeof e=="object")n=e;else {e=A.normalize(e);try{var o=a.lookupPath(e,{follow:!(r&131072)});n=o.node;}catch{}}var i=false;if(r&64)if(n){if(r&128)throw new a.ErrnoError(20)}else n=a.mknod(e,t,0),i=true;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(!i){var s=a.mayOpen(n,r);if(s)throw new a.ErrnoError(s)}r&512&&!i&&a.truncate(n,0),r&=-131713;var l=a.createStream({node:n,path:a.getPath(n),flags:r,seekable:true,position:0,stream_ops:n.stream_ops,ungotten:[],error:false});return l.stream_ops.open&&l.stream_ops.open(l),d.logReadFiles&&!(r&1)&&(a.readFiles||(a.readFiles={}),e in a.readFiles||(a.readFiles[e]=1)),l},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,o){if(n<0||o<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 i=typeof o<"u";if(!i)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,r,t,n,o);return i||(e.position+=s),s},write(e,r,t,n,o,i){if(n<0||o<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 o<"u";if(!s)o=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var l=e.stream_ops.write(e,r,t,n,o,i);return s||(e.position+=l),l},allocate(e,r,t){if(a.isClosed(e))throw new a.ErrnoError(8);if(r<0||t<=0)throw new a.ErrnoError(28);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(!a.isFile(e.node.mode)&&!a.isDir(e.node.mode))throw new a.ErrnoError(43);if(!e.stream_ops.allocate)throw new a.ErrnoError(138);e.stream_ops.allocate(e,r,t);},mmap(e,r,t,n,o){if((n&2)!==0&&(o&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);return e.stream_ops.mmap(e,r,t,n,o)},msync(e,r,t,n,o){return e.stream_ops.msync?e.stream_ops.msync(e,r,t,n,o):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={}){if(r.flags=r.flags||0,r.encoding=r.encoding||"binary",r.encoding!=="utf8"&&r.encoding!=="binary")throw new Error(`Invalid encoding type "${r.encoding}"`);var t,n=a.open(e,r.flags),o=a.stat(e),i=o.size,s=new Uint8Array(i);return a.read(n,s,0,i,0),r.encoding==="utf8"?t=ce(s,0):r.encoding==="binary"&&(t=s),a.close(n),t},writeFile(e,r,t={}){t.flags=t.flags||577;var n=a.open(e,t.flags,t.mode);if(typeof r=="string"){var o=new Uint8Array(Ze(r)+1),i=er(r,o,0,o.length);a.write(n,o,0,i,void 0,t.canOwn);}else if(ArrayBuffer.isView(r))a.write(n,r,0,r.byteLength,void 0,t.canOwn);else throw new Error("Unsupported data type");a.close(n);},cwd:()=>a.currentPath,chdir(e){var r=a.lookupPath(e,{follow:true});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,o,i,s,l)=>s}),a.mkdev("/dev/null",a.makedev(1,3)),ae.register(a.makedev(5,0),ae.default_tty_ops),ae.register(a.makedev(6,0),ae.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&&(r=Ar(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.node_ops={lookup(t,n){var o=+n,i=a.getStreamChecked(o),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>i.path}};return s.parent=s,s}},r}},{},"/proc/self/fd");},createStandardStreams(){d.stdin?a.createDevice("/dev","stdin",d.stdin):a.symlink("/dev/tty","/dev/stdin"),d.stdout?a.createDevice("/dev","stdout",null,d.stdout):a.symlink("/dev/tty","/dev/stdout"),d.stderr?a.createDevice("/dev","stderr",null,d.stderr):a.symlink("/dev/tty1","/dev/stderr");a.open("/dev/stdin",0);a.open("/dev/stdout",1);a.open("/dev/stderr",1);},staticInit(){[44].forEach(e=>{a.genericErrors[e]=new a.ErrnoError(e),a.genericErrors[e].stack="<generic error, no stack>";}),a.nameTable=new Array(4096),a.mount(w,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:w};},init(e,r,t){a.init.initialized=true,d.stdin=e||d.stdin,d.stdout=r||d.stdout,d.stderr=t||d.stderr,a.createStandardStreams();},quit(){a.init.initialized=false;for(var e=0;e<a.streams.length;e++){var r=a.streams[e];r&&a.close(r);}},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:false,exists:false,error:0,name:null,path:null,object:null,parentExists:false,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=A.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(o){n.error=o.errno;}return n},createPath(e,r,t,n){e=typeof e=="string"?e:a.getPath(e);for(var o=r.split("/").reverse();o.length;){var i=o.pop();if(i){var s=A.join2(e,i);try{a.mkdir(s);}catch{}e=s;}}return s},createFile(e,r,t,n,o){var i=A.join2(typeof e=="string"?e:a.getPath(e),r),s=rr(n,o);return a.create(i,s)},createDataFile(e,r,t,n,o,i){var s=r;e&&(e=typeof e=="string"?e:a.getPath(e),s=r?A.join2(e,r):e);var l=rr(n,o),u=a.create(s,l);if(t){if(typeof t=="string"){for(var f=new Array(t.length),v=0,y=t.length;v<y;++v)f[v]=t.charCodeAt(v);t=f;}a.chmod(u,l|146);var p=a.open(u,577);a.write(p,t,0,t.length,0,i),a.close(p),a.chmod(u,l);}},createDevice(e,r,t,n){var o=A.join2(typeof e=="string"?e:a.getPath(e),r),i=rr(!!t,!!n);a.createDevice.major||(a.createDevice.major=64);var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(l){l.seekable=false;},close(l){n?.buffer?.length&&n(10);},read(l,u,f,v,y){for(var p=0,h=0;h<v;h++){var g;try{g=t();}catch{throw new a.ErrnoError(29)}if(g===void 0&&p===0)throw new a.ErrnoError(6);if(g==null)break;p++,u[f+h]=g;}return p&&(l.node.timestamp=Date.now()),p},write(l,u,f,v,y){for(var p=0;p<v;p++)try{n(u[f+p]);}catch{throw new a.ErrnoError(29)}return v&&(l.node.timestamp=Date.now()),p}}),a.mkdev(o,i,s)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return true;if(typeof XMLHttpRequest<"u")throw new Error("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.");if(me)try{e.contents=Se(me(e.url),!0),e.usedBytes=e.contents.length;}catch{throw new a.ErrnoError(29)}else throw new Error("Cannot load without read() or XMLHttpRequest.")},createLazyFile(e,r,t,n,o){class i{constructor(){this.lengthKnown=false,this.chunks=[];}get(h){if(!(h>this.length-1||h<0)){var g=h%this.chunkSize,D=h/this.chunkSize|0;return this.getter(D)[g]}}setDataGetter(h){this.getter=h;}cacheLength(){var h=new XMLHttpRequest;if(h.open("HEAD",t,false),h.send(null),!(h.status>=200&&h.status<300||h.status===304))throw new Error("Couldn't load "+t+". Status: "+h.status);var g=Number(h.getResponseHeader("Content-length")),D,R=(D=h.getResponseHeader("Accept-Ranges"))&&D==="bytes",T=(D=h.getResponseHeader("Content-Encoding"))&&D==="gzip",c=1024*1024;R||(c=g);var m=(P,N)=>{if(P>N)throw new Error("invalid range ("+P+", "+N+") or no bytes requested!");if(N>g-1)throw new Error("only "+g+" bytes available! programmer error!");var M=new XMLHttpRequest;if(M.open("GET",t,false),g!==c&&M.setRequestHeader("Range","bytes="+P+"-"+N),M.responseType="arraybuffer",M.overrideMimeType&&M.overrideMimeType("text/plain; charset=x-user-defined"),M.send(null),!(M.status>=200&&M.status<300||M.status===304))throw new Error("Couldn't load "+t+". Status: "+M.status);return M.response!==void 0?new Uint8Array(M.response||[]):Se(M.responseText||"",true)},O=this;O.setDataGetter(P=>{var N=P*c,M=(P+1)*c-1;if(M=Math.min(M,g-1),typeof O.chunks[P]>"u"&&(O.chunks[P]=m(N,M)),typeof O.chunks[P]>"u")throw new Error("doXHR failed!");return O.chunks[P]}),(T||!g)&&(c=g=1,g=this.getter(0).length,c=g,Xe("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=g,this._chunkSize=c,this.lengthKnown=true;}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(typeof XMLHttpRequest<"u"){if(!j)throw "Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var s=new i,l={isDevice:false,contents:s};}else var l={isDevice:false,url:t};var u=a.createFile(e,r,l,n,o);l.contents?u.contents=l.contents:l.url&&(u.contents=null,u.url=l.url),Object.defineProperties(u,{usedBytes:{get:function(){return this.contents.length}}});var f={},v=Object.keys(u.stream_ops);v.forEach(p=>{var h=u.stream_ops[p];f[p]=(...g)=>(a.forceLoadFile(u),h(...g));});function y(p,h,g,D,R){var T=p.node.contents;if(R>=T.length)return 0;var c=Math.min(T.length-R,D);if(T.slice)for(var m=0;m<c;m++)h[g+m]=T[R+m];else for(var m=0;m<c;m++)h[g+m]=T.get(R+m);return c}return f.read=(p,h,g,D,R)=>(a.forceLoadFile(u),y(p,h,g,D,R)),f.mmap=(p,h,g,D,R)=>{a.forceLoadFile(u);var T=Sr();if(!T)throw new a.ErrnoError(48);return y(p,H,T,h,g),{ptr:T,allocated:true}},u.stream_ops=f,u}},X={DEFAULT_POLLMASK:5,calculateAt(e,r,t){if(A.isAbs(r))return r;var n;if(e===-100)n=a.cwd();else {var o=X.getStreamFromFD(e);n=o.path;}if(r.length==0){if(!t)throw new a.ErrnoError(44);return n}return A.join2(n,r)},doStat(e,r,t){var n=e(r);E[t>>2]=n.dev,E[t+4>>2]=n.mode,k[t+8>>2]=n.nlink,E[t+12>>2]=n.uid,E[t+16>>2]=n.gid,E[t+20>>2]=n.rdev,U=[n.size>>>0,(b=n.size,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+24>>2]=U[0],E[t+28>>2]=U[1],E[t+32>>2]=4096,E[t+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),s=n.ctime.getTime();return U=[Math.floor(o/1e3)>>>0,(b=Math.floor(o/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+40>>2]=U[0],E[t+44>>2]=U[1],k[t+48>>2]=o%1e3*1e3,U=[Math.floor(i/1e3)>>>0,(b=Math.floor(i/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+56>>2]=U[0],E[t+60>>2]=U[1],k[t+64>>2]=i%1e3*1e3,U=[Math.floor(s/1e3)>>>0,(b=Math.floor(s/1e3),+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+72>>2]=U[0],E[t+76>>2]=U[1],k[t+80>>2]=s%1e3*1e3,U=[n.ino>>>0,(b=n.ino,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[t+88>>2]=U[0],E[t+92>>2]=U[1],0},doMsync(e,r,t,n,o){if(!a.isFile(r.node.mode))throw new a.ErrnoError(43);if(n&2)return 0;var i=L.slice(e,e+t);a.msync(r,i,o,t,n);},varargs:void 0,get(){var e=E[+X.varargs>>2];return X.varargs+=4,e},getp(){return X.get()},getStr(e){var r=se(e);return r},getStreamFromFD(e){var r=a.getStreamChecked(e);return r}};function Pt(e,r,t){try{return r=X.getStr(r),r=X.calculateAt(e,r),t===0?a.unlink(r):t===512?a.rmdir(r):fe("Invalid flags passed to unlinkat"),0}catch(n){if(typeof a>"u"||n.name!=="ErrnoError")throw n;return -n.errno}}var Re={},tr=e=>{for(;e.length;){var r=e.pop(),t=e.pop();t(r);}};function we(e){return this.fromWireType(k[e>>2])}var ve={},le={},Me={},Rr,je=e=>{throw new Rr(e)},ue=(e,r,t)=>{e.forEach(function(l){Me[l]=r;});function n(l){var u=t(l);u.length!==e.length&&je("Mismatched type converter count");for(var f=0;f<e.length;++f)G(e[f],u[f]);}var o=new Array(r.length),i=[],s=0;r.forEach((l,u)=>{le.hasOwnProperty(l)?o[u]=le[l]:(i.push(l),ve.hasOwnProperty(l)||(ve[l]=[]),ve[l].push(()=>{o[u]=le[l],++s,s===i.length&&n(o);}));}),i.length===0&&n(o);},Ct=e=>{var r=Re[e];delete Re[e];var t=r.rawConstructor,n=r.rawDestructor,o=r.fields,i=o.map(s=>s.getterReturnType).concat(o.map(s=>s.setterArgumentType));ue([e],i,s=>{var l={};return o.forEach((u,f)=>{var v=u.fieldName,y=s[f],p=u.getter,h=u.getterContext,g=s[f+o.length],D=u.setter,R=u.setterContext;l[v]={read:T=>y.fromWireType(p(h,T)),write:(T,c)=>{var m=[];D(R,T,g.toWireType(m,c)),tr(m);}};}),[{name:r.name,fromWireType:u=>{var f={};for(var v in l)f[v]=l[v].read(u);return n(u),f},toWireType:(u,f)=>{for(var v in l)if(!(v in f))throw new TypeError(`Missing field: "${v}"`);var y=t();for(v in l)l[v].write(y,f[v]);return u!==null&&u.push(n,y),y},argPackAdvance:K,readValueFromPointer:we,destructorFunction:n}]});},Tt=(e,r,t,n,o)=>{},Dt=()=>{for(var e=new Array(256),r=0;r<256;++r)e[r]=String.fromCharCode(r);Mr=e;},Mr,W=e=>{for(var r="",t=e;L[t];)r+=Mr[L[t++]];return r},he,C=e=>{throw new he(e)};function Ft(e,r,t={}){var n=r.name;if(e||C(`type "${n}" must have a positive integer typeid pointer`),le.hasOwnProperty(e)){if(t.ignoreDuplicateRegistrations)return;C(`Cannot register type '${n}' twice`);}if(le[e]=r,delete Me[e],ve.hasOwnProperty(e)){var o=ve[e];delete ve[e],o.forEach(i=>i());}}function G(e,r,t={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");return Ft(e,r,t)}var K=8,At=(e,r,t,n)=>{r=W(r),G(e,{name:r,fromWireType:function(o){return !!o},toWireType:function(o,i){return i?t:n},argPackAdvance:K,readValueFromPointer:function(o){return this.fromWireType(L[o])},destructorFunction:null});},St=e=>({count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType}),nr=e=>{function r(t){return t.$$.ptrType.registeredClass.name}C(r(e)+" instance already deleted");},ar=false,jr=e=>{},Rt=e=>{e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr);},Or=e=>{e.count.value-=1;var r=e.count.value===0;r&&Rt(e);},Ir=(e,r,t)=>{if(r===t)return e;if(t.baseClass===void 0)return null;var n=Ir(e,r,t.baseClass);return n===null?null:t.downcast(n)},Ur={},Mt=()=>Object.keys(be).length,jt=()=>{var e=[];for(var r in be)be.hasOwnProperty(r)&&e.push(be[r]);return e},_e=[],or=()=>{for(;_e.length;){var e=_e.pop();e.$$.deleteScheduled=false,e.delete();}},Ee,Ot=e=>{Ee=e,_e.length&&Ee&&Ee(or);},It=()=>{d.getInheritedInstanceCount=Mt,d.getLiveInheritedInstances=jt,d.flushPendingDeletes=or,d.setDelayFunction=Ot;},be={},Ut=(e,r)=>{for(r===void 0&&C("ptr should not be undefined");e.baseClass;)r=e.upcast(r),e=e.baseClass;return r},Bt=(e,r)=>(r=Ut(e,r),be[r]),Oe=(e,r)=>{(!r.ptrType||!r.ptr)&&je("makeClassHandle requires ptr and ptrType");var t=!!r.smartPtrType,n=!!r.smartPtr;return t!==n&&je("Both smartPtrType and smartPtr must be specified"),r.count={value:1},$e(Object.create(e,{$$:{value:r,writable:true}}))};function xt(e){var r=this.getPointee(e);if(!r)return this.destructor(e),null;var t=Bt(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 o(){return this.isSmartPointer?Oe(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:r,smartPtrType:this,smartPtr:e}):Oe(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var i=this.registeredClass.getActualType(r),s=Ur[i];if(!s)return o.call(this);var l;this.isConst?l=s.constPointerType:l=s.pointerType;var u=Ir(r,this.registeredClass,l.registeredClass);return u===null?o.call(this):this.isSmartPointer?Oe(l.registeredClass.instancePrototype,{ptrType:l,ptr:u,smartPtrType:this,smartPtr:e}):Oe(l.registeredClass.instancePrototype,{ptrType:l,ptr:u})}var $e=e=>typeof FinalizationRegistry>"u"?($e=r=>r,e):(ar=new FinalizationRegistry(r=>{Or(r.$$);}),$e=r=>{var t=r.$$,n=!!t.smartPtr;if(n){var o={$$:t};ar.register(r,o,r);}return r},jr=r=>ar.unregister(r),$e(e)),Ht=()=>{Object.assign(Ie.prototype,{isAliasOf(e){if(!(this instanceof Ie)||!(e instanceof Ie))return false;var r=this.$$.ptrType.registeredClass,t=this.$$.ptr;e.$$=e.$$;for(var n=e.$$.ptrType.registeredClass,o=e.$$.ptr;r.baseClass;)t=r.upcast(t),r=r.baseClass;for(;n.baseClass;)o=n.upcast(o),n=n.baseClass;return r===n&&t===o},clone(){if(this.$$.ptr||nr(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e=$e(Object.create(Object.getPrototypeOf(this),{$$:{value:St(this.$$)}}));return e.$$.count.value+=1,e.$$.deleteScheduled=false,e},delete(){this.$$.ptr||nr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&C("Object already scheduled for deletion"),jr(this),Or(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0);},isDeleted(){return !this.$$.ptr},deleteLater(){return this.$$.ptr||nr(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&C("Object already scheduled for deletion"),_e.push(this),_e.length===1&&Ee&&Ee(or),this.$$.deleteScheduled=true,this}});};function Ie(){}var ke=(e,r)=>Object.defineProperty(r,"name",{value:e}),Br=(e,r,t)=>{if(e[r].overloadTable===void 0){var n=e[r];e[r]=function(...o){return e[r].overloadTable.hasOwnProperty(o.length)||C(`Function '${t}' called with an invalid number of arguments (${o.length}) - expects one of (${e[r].overloadTable})!`),e[r].overloadTable[o.length].apply(this,o)},e[r].overloadTable=[],e[r].overloadTable[n.argCount]=n;}},ir=(e,r,t)=>{d.hasOwnProperty(e)?((t===void 0||d[e].overloadTable!==void 0&&d[e].overloadTable[t]!==void 0)&&C(`Cannot register public name '${e}' twice`),Br(d,e,e),d.hasOwnProperty(t)&&C(`Cannot register multiple overloads of a function with the same number of arguments (${t})!`),d[e].overloadTable[t]=r):(d[e]=r,t!==void 0&&(d[e].numArguments=t));},Wt=48,Lt=57,zt=e=>{if(e===void 0)return "_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return r>=Wt&&r<=Lt?`_${e}`:e};function Nt(e,r,t,n,o,i,s,l){this.name=e,this.constructor=r,this.instancePrototype=t,this.rawDestructor=n,this.baseClass=o,this.getActualType=i,this.upcast=s,this.downcast=l,this.pureVirtualFunctions=[];}var sr=(e,r,t)=>{for(;r!==t;)r.upcast||C(`Expected null or instance of ${t.name}, got an instance of ${r.name}`),e=r.upcast(e),r=r.baseClass;return e};function Vt(e,r){if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),0;r.$$||C(`Cannot pass "${vr(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=sr(r.$$.ptr,t,this.registeredClass);return n}function Yt(e,r){var t;if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),this.isSmartPointer?(t=this.rawConstructor(),e!==null&&e.push(this.rawDestructor,t),t):0;(!r||!r.$$)&&C(`Cannot pass "${vr(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&r.$$.ptrType.isConst&&C(`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=sr(r.$$.ptr,n,this.registeredClass),this.isSmartPointer)switch(r.$$.smartPtr===void 0&&C("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:r.$$.smartPtrType===this?t=r.$$.smartPtr:C(`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 o=r.clone();t=this.rawShare(t,z.toHandle(()=>o.delete())),e!==null&&e.push(this.rawDestructor,t);}break;default:C("Unsupporting sharing policy");}return t}function qt(e,r){if(r===null)return this.isReference&&C(`null is not a valid ${this.name}`),0;r.$$||C(`Cannot pass "${vr(r)}" as a ${this.name}`),r.$$.ptr||C(`Cannot pass deleted object as a pointer of type ${this.name}`),r.$$.ptrType.isConst&&C(`Cannot convert argument of type ${r.$$.ptrType.name} to parameter type ${this.name}`);var t=r.$$.ptrType.registeredClass,n=sr(r.$$.ptr,t,this.registeredClass);return n}var Xt=()=>{Object.assign(Ue.prototype,{getPointee(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e},destructor(e){this.rawDestructor?.(e);},argPackAdvance:K,readValueFromPointer:we,fromWireType:xt});};function Ue(e,r,t,n,o,i,s,l,u,f,v){this.name=e,this.registeredClass=r,this.isReference=t,this.isConst=n,this.isSmartPointer=o,this.pointeeType=i,this.sharingPolicy=s,this.rawGetPointee=l,this.rawConstructor=u,this.rawShare=f,this.rawDestructor=v,!o&&r.baseClass===void 0?n?(this.toWireType=Vt,this.destructorFunction=null):(this.toWireType=qt,this.destructorFunction=null):this.toWireType=Yt;}var xr=(e,r,t)=>{d.hasOwnProperty(e)||je("Replacing nonexistent public symbol"),d[e].overloadTable!==void 0&&t!==void 0?d[e].overloadTable[t]=r:(d[e]=r,d[e].argCount=t);},Gt=(e,r,t)=>{var n=d["dynCall_"+e];return n(r,...t)},Be=[],Hr,Wr=e=>{var r=Be[e];return r||(e>=Be.length&&(Be.length=e+1),Be[e]=r=Hr.get(e)),r},Kt=(e,r,t=[])=>{if(e.includes("j"))return Gt(e,r,t);var n=Wr(r)(...t);return n},Jt=(e,r)=>(...t)=>Kt(e,r,t),q=(e,r)=>{e=W(e);function t(){return e.includes("j")?Jt(e,r):Wr(r)}var n=t();return typeof n!="function"&&C(`unknown function pointer with signature ${e}: ${r}`),n},Qt=(e,r)=>{var t=ke(r,function(n){this.name=r,this.message=n;var o=new Error(n).stack;o!==void 0&&(this.stack=this.toString()+`
|
|
4
|
+
`+o.replace(/^Error(:[^\n]*)?\n/,""));});return t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},t},Lr,zr=e=>{var r=Gr(e),t=W(r);return re(r),t},xe=(e,r)=>{var t=[],n={};function o(i){if(!n[i]&&!le[i]){if(Me[i]){Me[i].forEach(o);return}t.push(i),n[i]=true;}}throw r.forEach(o),new Lr(`${e}: `+t.map(zr).join([", "]))},Zt=(e,r,t,n,o,i,s,l,u,f,v,y,p)=>{v=W(v),i=q(o,i),l&&=q(s,l),f&&=q(u,f),p=q(y,p);var h=zt(v);ir(h,function(){xe(`Cannot construct ${v} due to unbound types`,[n]);}),ue([e,r,t],n?[n]:[],g=>{g=g[0];var D,R;n?(D=g.registeredClass,R=D.instancePrototype):R=Ie.prototype;var T=ke(v,function(...M){if(Object.getPrototypeOf(this)!==c)throw new he("Use 'new' to construct "+v);if(m.constructor_body===void 0)throw new he(v+" has no accessible constructor");var Qr=m.constructor_body[M.length];if(Qr===void 0)throw new he(`Tried to invoke ctor of ${v} with invalid number of parameters (${M.length}) - expected (${Object.keys(m.constructor_body).toString()}) parameters instead!`);return Qr.apply(this,M)}),c=Object.create(R,{constructor:{value:T}});T.prototype=c;var m=new Nt(v,T,c,p,D,i,l,f);m.baseClass&&(m.baseClass.__derivedClasses??=[],m.baseClass.__derivedClasses.push(m));var O=new Ue(v,m,true,false,false),P=new Ue(v+"*",m,false,false,false),N=new Ue(v+" const*",m,false,true,false);return Ur[e]={pointerType:P,constPointerType:N},xr(h,T),[O,P,N]});},lr=(e,r)=>{for(var t=[],n=0;n<e;n++)t.push(k[r+n*4>>2]);return t};function en(e){for(var r=1;r<e.length;++r)if(e[r]!==null&&e[r].destructorFunction===void 0)return true;return false}function ur(e,r,t,n,o,i){var s=r.length;s<2&&C("argTypes array size mismatch! Must at least get return value and 'this' types!");var l=r[1]!==null&&t!==null,u=en(r),f=r[0].name!=="void",v=s-2,y=new Array(v),p=[],h=[],g=function(...D){D.length!==v&&C(`function ${e} called with ${D.length} arguments, expected ${v}`),h.length=0;var R;p.length=l?2:1,p[0]=o,l&&(R=r[1].toWireType(h,this),p[1]=R);for(var T=0;T<v;++T)y[T]=r[T+2].toWireType(h,D[T]),p.push(y[T]);var c=n(...p);function m(O){if(u)tr(h);else for(var P=l?1:2;P<r.length;P++){var N=P===1?R:y[P-2];r[P].destructorFunction!==null&&r[P].destructorFunction(N);}if(f)return r[0].fromWireType(O)}return m(c)};return ke(e,g)}var rn=(e,r,t,n,o,i)=>{var s=lr(r,t);o=q(n,o),ue([],[e],l=>{l=l[0];var u=`constructor ${l.name}`;if(l.registeredClass.constructor_body===void 0&&(l.registeredClass.constructor_body=[]),l.registeredClass.constructor_body[r-1]!==void 0)throw new he(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${l.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return l.registeredClass.constructor_body[r-1]=()=>{xe(`Cannot construct ${l.name} due to unbound types`,s);},ue([],s,f=>(f.splice(1,0,null),l.registeredClass.constructor_body[r-1]=ur(u,f,null,o,i),[])),[]});},Nr=e=>{e=e.trim();let r=e.indexOf("(");return r!==-1?e.substr(0,r):e},tn=(e,r,t,n,o,i,s,l,u)=>{var f=lr(t,n);r=W(r),r=Nr(r),i=q(o,i),ue([],[e],v=>{v=v[0];var y=`${v.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),l&&v.registeredClass.pureVirtualFunctions.push(r);function p(){xe(`Cannot call ${y} due to unbound types`,f);}var h=v.registeredClass.instancePrototype,g=h[r];return g===void 0||g.overloadTable===void 0&&g.className!==v.name&&g.argCount===t-2?(p.argCount=t-2,p.className=v.name,h[r]=p):(Br(h,r,y),h[r].overloadTable[t-2]=p),ue([],f,D=>{var R=ur(y,D,v,i,s);return h[r].overloadTable===void 0?(R.argCount=t-2,h[r]=R):h[r].overloadTable[t-2]=R,[]}),[]});},dr=[],ee=[],fr=e=>{e>9&&--ee[e+1]===0&&(ee[e]=void 0,dr.push(e));},nn=()=>ee.length/2-5-dr.length,an=()=>{ee.push(0,1,void 0,1,null,1,true,1,false,1),d.count_emval_handles=nn;},z={toValue:e=>(e||C("Cannot use deleted val. handle = "+e),ee[e]),toHandle:e=>{switch(e){case void 0:return 2;case null:return 4;case true:return 6;case false:return 8;default:{let r=dr.pop()||ee.length;return ee[r]=e,ee[r+1]=1,r}}}},on={name:"emscripten::val",fromWireType:e=>{var r=z.toValue(e);return fr(e),r},toWireType:(e,r)=>z.toHandle(r),argPackAdvance:K,readValueFromPointer:we,destructorFunction:null},sn=e=>G(e,on),ln=(e,r,t)=>{switch(r){case 1:return t?function(n){return this.fromWireType(H[n])}:function(n){return this.fromWireType(L[n])};case 2:return t?function(n){return this.fromWireType(de[n>>1])}:function(n){return this.fromWireType(ye[n>>1])};case 4:return t?function(n){return this.fromWireType(E[n>>2])}:function(n){return this.fromWireType(k[n>>2])};default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},un=(e,r,t,n)=>{r=W(r);function o(){}o.values={},G(e,{name:r,constructor:o,fromWireType:function(i){return this.constructor.values[i]},toWireType:(i,s)=>s.value,argPackAdvance:K,readValueFromPointer:ln(r,t,n),destructorFunction:null}),ir(r,o);},cr=(e,r)=>{var t=le[e];return t===void 0&&C(`${r} has unknown type ${zr(e)}`),t},dn=(e,r,t)=>{var n=cr(e,"enum");r=W(r);var o=n.constructor,i=Object.create(n.constructor.prototype,{value:{value:t},constructor:{value:ke(`${n.name}_${r}`,function(){})}});o.values[t]=i,o[r]=i;},vr=e=>{if(e===null)return "null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e},fn=(e,r)=>{switch(r){case 4:return function(t){return this.fromWireType(gr[t>>2])};case 8:return function(t){return this.fromWireType(wr[t>>3])};default:throw new TypeError(`invalid float width (${r}): ${e}`)}},cn=(e,r,t)=>{r=W(r),G(e,{name:r,fromWireType:n=>n,toWireType:(n,o)=>o,argPackAdvance:K,readValueFromPointer:fn(r,t),destructorFunction:null});},vn=(e,r,t,n,o,i,s)=>{var l=lr(r,t);e=W(e),e=Nr(e),o=q(n,o),ir(e,function(){xe(`Cannot call ${e} due to unbound types`,l);},r-1),ue([],l,u=>{var f=[u[0],null].concat(u.slice(1));return xr(e,ur(e,f,null,o,i),r-1),[]});},hn=(e,r,t)=>{switch(r){case 1:return t?n=>H[n]:n=>L[n];case 2:return t?n=>de[n>>1]:n=>ye[n>>1];case 4:return t?n=>E[n>>2]:n=>k[n>>2];default:throw new TypeError(`invalid integer width (${r}): ${e}`)}},mn=(e,r,t,n,o)=>{r=W(r);var i=v=>v;if(n===0){var s=32-8*t;i=v=>v<<s>>>s;}var l=r.includes("unsigned"),u=(v,y)=>{},f;l?f=function(v,y){return u(y,this.name),y>>>0}:f=function(v,y){return u(y,this.name),y},G(e,{name:r,fromWireType:i,toWireType:f,argPackAdvance:K,readValueFromPointer:hn(r,t,n!==0),destructorFunction:null});},pn=(e,r,t)=>{var n=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],o=n[r];function i(s){var l=k[s>>2],u=k[s+4>>2];return new o(H.buffer,u,l)}t=W(t),G(e,{name:t,fromWireType:i,argPackAdvance:K,readValueFromPointer:i},{ignoreDuplicateRegistrations:true});},yn=(e,r,t)=>er(e,L,r,t),gn=(e,r)=>{r=W(r);var t=r==="std::string";G(e,{name:r,fromWireType(n){var o=k[n>>2],i=n+4,s;if(t)for(var l=i,u=0;u<=o;++u){var f=i+u;if(u==o||L[f]==0){var v=f-l,y=se(l,v);s===void 0?s=y:(s+="\0",s+=y),l=f+1;}}else {for(var p=new Array(o),u=0;u<o;++u)p[u]=String.fromCharCode(L[i+u]);s=p.join("");}return re(n),s},toWireType(n,o){o instanceof ArrayBuffer&&(o=new Uint8Array(o));var i,s=typeof o=="string";s||o instanceof Uint8Array||o instanceof Uint8ClampedArray||o instanceof Int8Array||C("Cannot pass non-string to std::string"),t&&s?i=Ze(o):i=o.length;var l=pr(4+i+1),u=l+4;if(k[l>>2]=i,t&&s)yn(o,u,i+1);else if(s)for(var f=0;f<i;++f){var v=o.charCodeAt(f);v>255&&(re(u),C("String has UTF-16 code units that do not fit in 8 bits")),L[u+f]=v;}else for(var f=0;f<i;++f)L[u+f]=o[f];return n!==null&&n.push(re,l),l},argPackAdvance:K,readValueFromPointer:we,destructorFunction(n){re(n);}});},Vr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,wn=(e,r)=>{for(var t=e,n=t>>1,o=n+r/2;!(n>=o)&&ye[n];)++n;if(t=n<<1,t-e>32&&Vr)return Vr.decode(L.subarray(e,t));for(var i="",s=0;!(s>=r/2);++s){var l=de[e+s*2>>1];if(l==0)break;i+=String.fromCharCode(l);}return i},_n=(e,r,t)=>{if(t??=2147483647,t<2)return 0;t-=2;for(var n=r,o=t<e.length*2?t/2:e.length,i=0;i<o;++i){var s=e.charCodeAt(i);de[r>>1]=s,r+=2;}return de[r>>1]=0,r-n},En=e=>e.length*2,bn=(e,r)=>{for(var t=0,n="";!(t>=r/4);){var o=E[e+t*4>>2];if(o==0)break;if(++t,o>=65536){var i=o-65536;n+=String.fromCharCode(55296|i>>10,56320|i&1023);}else n+=String.fromCharCode(o);}return n},$n=(e,r,t)=>{if(t??=2147483647,t<4)return 0;for(var n=r,o=n+t-4,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343){var l=e.charCodeAt(++i);s=65536+((s&1023)<<10)|l&1023;}if(E[r>>2]=s,r+=4,r+4>o)break}return E[r>>2]=0,r-n},kn=e=>{for(var r=0,t=0;t<e.length;++t){var n=e.charCodeAt(t);n>=55296&&n<=57343&&++t,r+=4;}return r},Pn=(e,r,t)=>{t=W(t);var n,o,i,s;r===2?(n=wn,o=_n,s=En,i=l=>ye[l>>1]):r===4&&(n=bn,o=$n,s=kn,i=l=>k[l>>2]),G(e,{name:t,fromWireType:l=>{for(var u=k[l>>2],f,v=l+4,y=0;y<=u;++y){var p=l+4+y*r;if(y==u||i(p)==0){var h=p-v,g=n(v,h);f===void 0?f=g:(f+="\0",f+=g),v=p+r;}}return re(l),f},toWireType:(l,u)=>{typeof u!="string"&&C(`Cannot pass non-string to C++ string type ${t}`);var f=s(u),v=pr(4+f+r);return k[v>>2]=f/r,o(u,v+4,f+r),l!==null&&l.push(re,v),v},argPackAdvance:K,readValueFromPointer:we,destructorFunction(l){re(l);}});},Cn=(e,r,t,n,o,i)=>{Re[e]={name:W(r),rawConstructor:q(t,n),rawDestructor:q(o,i),fields:[]};},Tn=(e,r,t,n,o,i,s,l,u,f)=>{Re[e].fields.push({fieldName:W(r),getterReturnType:t,getter:q(n,o),getterContext:i,setterArgumentType:s,setter:q(l,u),setterContext:f});},Dn=(e,r)=>{r=W(r),G(e,{isVoid:true,name:r,argPackAdvance:0,fromWireType:()=>{},toWireType:(t,n)=>{}});},He=[],Fn=(e,r,t,n)=>(e=He[e],r=z.toValue(r),e(null,r,t,n)),An={},hr=e=>{var r=An[e];return r===void 0?W(e):r},Sn=(e,r,t,n,o)=>(e=He[e],r=z.toValue(r),t=hr(t),e(r,r[t],n,o)),Yr=()=>{if(typeof globalThis=="object")return globalThis;function e(r){r.$$$embind_global$$$=r;var t=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return t||delete r.$$$embind_global$$$,t}if(typeof $$$embind_global$$$=="object"||(typeof global=="object"&&e(global)?$$$embind_global$$$=global:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")},Rn=e=>e===0?z.toHandle(Yr()):(e=hr(e),z.toHandle(Yr()[e])),Mn=e=>{var r=He.length;return He.push(e),r},jn=(e,r)=>{for(var t=new Array(e),n=0;n<e;++n)t[n]=cr(k[r+n*4>>2],"parameter "+n);return t},On=Reflect.construct,In=(e,r,t)=>{var n=[],o=e.toWireType(n,t);return n.length&&(k[r>>2]=z.toHandle(n)),o},Un=(e,r,t)=>{var n=jn(e,r),o=n.shift();e--;var i=new Array(e),s=(u,f,v,y)=>{for(var p=0,h=0;h<e;++h)i[h]=n[h].readValueFromPointer(y+p),p+=n[h].argPackAdvance;var g=t===1?On(f,i):f.apply(u,i);return In(o,v,g)},l=`methodCaller<(${n.map(u=>u.name).join(", ")}) => ${o.name}>`;return Mn(ke(l,s))},Bn=e=>{e>9&&(ee[e+1]+=1);},xn=()=>z.toHandle([]),Hn=e=>z.toHandle(hr(e)),Wn=()=>z.toHandle({}),Ln=e=>{var r=z.toValue(e);tr(r),fr(e);},zn=(e,r,t)=>{e=z.toValue(e),r=z.toValue(r),t=z.toValue(t),e[r]=t;},Nn=(e,r)=>{e=cr(e,"_emval_take_value");var t=e.readValueFromPointer(r);return z.toHandle(t)},Vn=()=>{fe("");},Yn=(e,r,t)=>L.copyWithin(e,r,r+t),qn=()=>2147483648,Xn=e=>{var r=Fe.buffer,t=(e-r.byteLength+65535)/65536;try{return Fe.grow(t),_r(),1}catch{}},Gn=e=>{var r=L.length;e>>>=0;var t=qn();if(e>t)return false;for(var n=(u,f)=>u+(f-u%f)%f,o=1;o<=4;o*=2){var i=r*(1+.2/o);i=Math.min(i,e+100663296);var s=Math.min(t,n(Math.max(e,i),65536)),l=Xn(s);if(l)return true}return false},mr={},Kn=()=>x||"./this.program",Pe=()=>{if(!Pe.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",r={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:Kn()};for(var t in mr)mr[t]===void 0?delete r[t]:r[t]=mr[t];var n=[];for(var t in r)n.push(`${t}=${r[t]}`);Pe.strings=n;}return Pe.strings},Jn=(e,r)=>{for(var t=0;t<e.length;++t)H[r++]=e.charCodeAt(t);H[r]=0;},Qn=(e,r)=>{var t=0;return Pe().forEach((n,o)=>{var i=r+t;k[e+o*4>>2]=i,Jn(n,i),t+=n.length+1;}),0},Zn=(e,r)=>{var t=Pe();k[e>>2]=t.length;var n=0;return t.forEach(o=>n+=o.length+1),k[r>>2]=n,0};function ea(e){try{var r=X.getStreamFromFD(e);return a.close(r),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return t.errno}}var ra=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=k[r>>2],l=k[r+4>>2];r+=8;var u=a.read(e,H,s,l,n);if(u<0)return -1;if(o+=u,u<l)break;}return o};function ta(e,r,t,n){try{var o=X.getStreamFromFD(e),i=ra(o,r,t);return k[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var na=(e,r)=>r+2097152>>>0<4194305-!!e?(e>>>0)+r*4294967296:NaN;function aa(e,r,t,n,o){var i=na(r,t);try{if(isNaN(i))return 61;var s=X.getStreamFromFD(e);return a.llseek(s,i,n),U=[s.position>>>0,(b=s.position,+Math.abs(b)>=1?b>0?+Math.floor(b/4294967296)>>>0:~~+Math.ceil((b-+(~~b>>>0))/4294967296)>>>0:0)],E[o>>2]=U[0],E[o+4>>2]=U[1],s.getdents&&i===0&&n===0&&(s.getdents=null),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var oa=(e,r,t,n)=>{for(var o=0,i=0;i<t;i++){var s=k[r>>2],l=k[r+4>>2];r+=8;var u=a.write(e,H,s,l,n);if(u<0)return -1;o+=u;}return o};function ia(e,r,t,n){try{var o=X.getStreamFromFD(e),i=oa(o,r,t);return k[n>>2]=i,0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return s.errno}}var We=e=>e%4===0&&(e%100!==0||e%400===0),sa=(e,r)=>{for(var t=0,n=0;n<=r;t+=e[n++]);return t},qr=[31,29,31,30,31,30,31,31,30,31,30,31],Xr=[31,28,31,30,31,30,31,31,30,31,30,31],la=(e,r)=>{for(var t=new Date(e.getTime());r>0;){var n=We(t.getFullYear()),o=t.getMonth(),i=(n?qr:Xr)[o];if(r>i-t.getDate())r-=i-t.getDate()+1,t.setDate(1),o<11?t.setMonth(o+1):(t.setMonth(0),t.setFullYear(t.getFullYear()+1));else return t.setDate(t.getDate()+r),t}return t},ua=(e,r)=>{H.set(e,r);},da=(e,r,t,n)=>{var o=k[n+40>>2],i={tm_sec:E[n>>2],tm_min:E[n+4>>2],tm_hour:E[n+8>>2],tm_mday:E[n+12>>2],tm_mon:E[n+16>>2],tm_year:E[n+20>>2],tm_wday:E[n+24>>2],tm_yday:E[n+28>>2],tm_isdst:E[n+32>>2],tm_gmtoff:E[n+36>>2],tm_zone:o?se(o):""},s=se(t),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var u in l)s=s.replace(new RegExp(u,"g"),l[u]);var f=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],v=["January","February","March","April","May","June","July","August","September","October","November","December"];function y(c,m,O){for(var P=typeof c=="number"?c.toString():c||"";P.length<m;)P=O[0]+P;return P}function p(c,m){return y(c,m,"0")}function h(c,m){function O(N){return N<0?-1:N>0?1:0}var P;return (P=O(c.getFullYear()-m.getFullYear()))===0&&(P=O(c.getMonth()-m.getMonth()))===0&&(P=O(c.getDate()-m.getDate())),P}function g(c){switch(c.getDay()){case 0:return new Date(c.getFullYear()-1,11,29);case 1:return c;case 2:return new Date(c.getFullYear(),0,3);case 3:return new Date(c.getFullYear(),0,2);case 4:return new Date(c.getFullYear(),0,1);case 5:return new Date(c.getFullYear()-1,11,31);case 6:return new Date(c.getFullYear()-1,11,30)}}function D(c){var m=la(new Date(c.tm_year+1900,0,1),c.tm_yday),O=new Date(m.getFullYear(),0,4),P=new Date(m.getFullYear()+1,0,4),N=g(O),M=g(P);return h(N,m)<=0?h(M,m)<=0?m.getFullYear()+1:m.getFullYear():m.getFullYear()-1}var R={"%a":c=>f[c.tm_wday].substring(0,3),"%A":c=>f[c.tm_wday],"%b":c=>v[c.tm_mon].substring(0,3),"%B":c=>v[c.tm_mon],"%C":c=>{var m=c.tm_year+1900;return p(m/100|0,2)},"%d":c=>p(c.tm_mday,2),"%e":c=>y(c.tm_mday,2," "),"%g":c=>D(c).toString().substring(2),"%G":D,"%H":c=>p(c.tm_hour,2),"%I":c=>{var m=c.tm_hour;return m==0?m=12:m>12&&(m-=12),p(m,2)},"%j":c=>p(c.tm_mday+sa(We(c.tm_year+1900)?qr:Xr,c.tm_mon-1),3),"%m":c=>p(c.tm_mon+1,2),"%M":c=>p(c.tm_min,2),"%n":()=>`
|
|
5
|
+
`,"%p":c=>c.tm_hour>=0&&c.tm_hour<12?"AM":"PM","%S":c=>p(c.tm_sec,2),"%t":()=>" ","%u":c=>c.tm_wday||7,"%U":c=>{var m=c.tm_yday+7-c.tm_wday;return p(Math.floor(m/7),2)},"%V":c=>{var m=Math.floor((c.tm_yday+7-(c.tm_wday+6)%7)/7);if((c.tm_wday+371-c.tm_yday-2)%7<=2&&m++,m){if(m==53){var P=(c.tm_wday+371-c.tm_yday)%7;P!=4&&(P!=3||!We(c.tm_year))&&(m=1);}}else {m=52;var O=(c.tm_wday+7-c.tm_yday-1)%7;(O==4||O==5&&We(c.tm_year%400-1))&&m++;}return p(m,2)},"%w":c=>c.tm_wday,"%W":c=>{var m=c.tm_yday+7-(c.tm_wday+6)%7;return p(Math.floor(m/7),2)},"%y":c=>(c.tm_year+1900).toString().substring(2),"%Y":c=>c.tm_year+1900,"%z":c=>{var m=c.tm_gmtoff,O=m>=0;return m=Math.abs(m)/60,m=m/60*100+m%60,(O?"+":"-")+("0000"+m).slice(-4)},"%Z":c=>c.tm_zone,"%%":()=>"%"};s=s.replace(/%%/g,"\0\0");for(var u in R)s.includes(u)&&(s=s.replace(new RegExp(u,"g"),R[u](i)));s=s.replace(/\0\0/g,"%");var T=Se(s,false);return T.length>r?0:(ua(T,e),T.length-1)},fa=(e,r,t,n,o)=>da(e,r,t,n);a.createPreloadedFile=$t,a.staticInit(),Rr=d.InternalError=class extends Error{constructor(r){super(r),this.name="InternalError";}},Dt(),he=d.BindingError=class extends Error{constructor(r){super(r),this.name="BindingError";}},Ht(),It(),Xt(),Lr=d.UnboundTypeError=Qt(Error,"UnboundTypeError"),an();var ca={a:vt,m:pt,F:Pt,O:Ct,C:Tt,M:At,o:Zt,A:rn,y:tn,L:sn,j:un,b:dn,x:cn,e:vn,i:mn,f:pn,w:gn,r:Pn,P:Cn,t:Tn,N:Dn,p:Fn,z:Sn,c:fr,Q:Rn,l:Un,q:Bn,s:xn,h:Hn,n:Wn,k:Ln,g:zn,d:Nn,u:Vn,K:Yn,E:Gn,I:Qn,J:Zn,G:ea,H:ta,B:aa,v:ia,D:fa},I=ct(),pr=e=>(pr=I.T)(e),re=e=>(re=I.V)(e),Gr=e=>(Gr=I.W)(e),Kr=e=>(Kr=I.X)(e);d.dynCall_ji=(e,r)=>(d.dynCall_ji=I.Y)(e,r);d.dynCall_iij=(e,r,t,n)=>(d.dynCall_iij=I.Z)(e,r,t,n);d.dynCall_jijj=(e,r,t,n,o,i)=>(d.dynCall_jijj=I._)(e,r,t,n,o,i);d.dynCall_vijj=(e,r,t,n,o,i)=>(d.dynCall_vijj=I.$)(e,r,t,n,o,i);d.dynCall_jiji=(e,r,t,n,o)=>(d.dynCall_jiji=I.aa)(e,r,t,n,o);d.dynCall_viijii=(e,r,t,n,o,i,s)=>(d.dynCall_viijii=I.ba)(e,r,t,n,o,i,s);d.dynCall_iiiiij=(e,r,t,n,o,i,s)=>(d.dynCall_iiiiij=I.ca)(e,r,t,n,o,i,s);d.dynCall_iiiiijj=(e,r,t,n,o,i,s,l,u)=>(d.dynCall_iiiiijj=I.da)(e,r,t,n,o,i,s,l,u);d.dynCall_iiiiiijj=(e,r,t,n,o,i,s,l,u,f)=>(d.dynCall_iiiiiijj=I.ea)(e,r,t,n,o,i,s,l,u,f);var Le;ge=function e(){Le||Jr(),Le||(ge=e);};function Jr(){if(oe>0||(nt(),oe>0))return;function e(){Le||(Le=true,d.calledRun=true,!yr&&(at(),_(d),d.onRuntimeInitialized&&d.onRuntimeInitialized(),ot()));}d.setStatus?(d.setStatus("Running..."),setTimeout(function(){setTimeout(function(){d.setStatus("");},1),e();},1)):e();}if(d.preInit)for(typeof d.preInit=="function"&&(d.preInit=[d.preInit]);d.preInit.length>0;)d.preInit.pop()();return Jr(),$.ready})})(),Zr=$a;var Ce=class{options;module=null;decoderInstance=null;initPromise=null;constructor($){this.options=$;}async initialize(){if(!this.initPromise){let $={};this.options?.locateFile&&($.locateFile=this.options.locateFile),this.options?.wasmBinary&&($.wasmBinary=this.options.wasmBinary),this.initPromise=Zr($).then(d=>(this.module=d,this.decoderInstance=new d.HeicDecoder,d)).catch(d=>{throw this.initPromise=null,d});}await this.initPromise;}async decode($,d){(!this.module||!this.decoderInstance)&&await this.initialize();let _=this.decoderInstance.decode($,d??null);if(!_)throw new Error("HEIC decoding failed");if(typeof _=="string")throw new Error(`HEIC decoding failed: ${_}`);let S=_.width,B=_.height,V=new Uint8ClampedArray(_.data);return {width:S,height:B,data:V}}free(){this.decoderInstance&&(this.decoderInstance.delete(),this.decoderInstance=null),this.module=null,this.initPromise=null;}};async function ka(F){if(typeof FileReader<"u")return new Promise(($,d)=>{let _=new FileReader;_.onloadend=()=>{typeof _.result=="string"?$(_.result):d(new Error("Failed to convert Blob to base64 string"));},_.onerror=()=>d(_.error),_.readAsDataURL(F);});try{let $=await F.arrayBuffer(),d=new Uint8Array($),_="",S=32768;for(let V=0;V<d.length;V+=S)_+=String.fromCharCode(...d.subarray(V,V+S));let B=btoa(_);return `data:${F.type};base64,${B}`}catch($){throw new Error(`Failed to convert Blob to base64 string: ${$ instanceof Error?$.message:String($)}`,{cause:$})}}function ze(F,$,d){return "convertToBlob"in F?F.convertToBlob({type:$,quality:d}):new Promise((_,S)=>{F.toBlob(B=>{B?_(B):S(new Error(`Failed to convert canvas to blob (type: ${$})`));},$,d);})}async function et(F,$,d){let{width:_,height:S,data:B}=F;if(!Number.isInteger(_)||_<=0||!Number.isInteger(S)||S<=0)throw new Error(`Invalid image dimensions: ${_}x${S}. Width and height must be positive integers.`);let V=_*S*4;if(B.length!==V)throw new Error(`Image data length mismatch. Expected ${V} bytes for ${_}x${S}, got ${B.length}`);let x;if(typeof OffscreenCanvas<"u")x=new OffscreenCanvas(_,S);else if(typeof document<"u")x=document.createElement("canvas"),x.width=_,x.height=S;else throw new Error("Canvas is not supported in the current environment. Conversion requires a browser environment or canvas polyfills.");let J=x.getContext("2d");if(!J)throw new Error("Failed to acquire 2D rendering context from canvas");let te;if(typeof ImageData<"u")te=new ImageData(B,_,S);else {let Q=J.createImageData(_,S);Q.data.set(B),te=Q;}J.putImageData(te,0,0);let j=$.toLowerCase();if(j==="png")return ze(x,"image/png");if(j==="jpeg"||j==="jpg")return ze(x,"image/jpeg",d);if(j==="webp")return ze(x,"image/webp",d);if(j==="svg"){let Q=await ze(x,"image/png"),Y=await ka(Q),Ne=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${_} ${S}" width="${_}" height="${S}">
|
|
6
|
+
<image width="${_}" height="${S}" href="${Y}" />
|
|
7
|
+
</svg>`;return new Blob([Ne],{type:"image/svg+xml"})}else throw new Error(`Unsupported output format: ${$}`)}function xa(){}function Pa(F){if(typeof F!="number"||Number.isNaN(F)||F<0||F>1)throw new Error(`Quality must be a number between 0.0 and 1.0, got: ${F}`)}async function Ha(F,$){let d;if(F instanceof Uint8Array)d=F;else if(F instanceof ArrayBuffer)d=new Uint8Array(F);else if(typeof Blob<"u"&&F instanceof Blob){let x=await F.arrayBuffer();d=new Uint8Array(x);}else throw new Error(`Unsupported input type. Expected Blob, File, ArrayBuffer, or Uint8Array. Got: ${Object.prototype.toString.call(F)}`);$?.quality!==void 0&&Pa($.quality);let _=$?.decoder??new Ce,S=!$?.decoder,B=false,V=()=>{if(!(!S||B)){B=true;try{_.free();}catch{}}};try{try{await _.initialize();}catch(j){throw new Error(`Failed to initialize HEIC decoder: ${j instanceof Error?j.message:String(j)}`,{cause:j})}let x=await _.decode(d,$?.onProgress);V();let J=$?.to||"jpeg",te=$?.quality!==void 0?$.quality:.92;try{return await et(x,J,te)}catch(j){throw new Error(`Failed to render and encode image as ${J}: ${j instanceof Error?j.message:String(j)}`,{cause:j})}}finally{V();}}export{Ce as LibheifDecoder,Ha as convertHeic,xa as freeSharedDecoder};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keeratita/heic-converter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Convert HEIC images to standard web formats (JPG, PNG, SVG) without breaking CSP",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"build:wasm": "bash build-scripts/build-wasm.sh",
|
|
29
29
|
"test": "vitest run",
|
|
30
30
|
"test:watch": "vitest",
|
|
31
|
-
"test:
|
|
31
|
+
"test:e2e": "node test/browser/test-playwright.mjs",
|
|
32
32
|
"test:coverage": "vitest run --coverage",
|
|
33
33
|
"sandbox": "node test/browser/server.mjs",
|
|
34
34
|
"lint": "eslint .",
|