@statsim/compiler 0.1.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.
@@ -0,0 +1,3169 @@
1
+
2
+ var createStatsim = (() => {
3
+ var _scriptName = typeof document != 'undefined' ? document.currentScript?.src : undefined;
4
+ if (typeof __filename != 'undefined') _scriptName ||= __filename;
5
+ return (
6
+ function(moduleArg = {}) {
7
+ var moduleRtn;
8
+
9
+ // include: shell.js
10
+ // The Module object: Our interface to the outside world. We import
11
+ // and export values on it. There are various ways Module can be used:
12
+ // 1. Not defined. We create it here
13
+ // 2. A function parameter, function(moduleArg) => Promise<Module>
14
+ // 3. pre-run appended it, var Module = {}; ..generated code..
15
+ // 4. External script tag defines var Module.
16
+ // We need to check if Module already exists (e.g. case 3 above).
17
+ // Substitution will be replaced with actual code on later stage of the build,
18
+ // this way Closure Compiler will not mangle it (e.g. case 4. above).
19
+ // Note that if you want to run closure, and also to use Module
20
+ // after the generated code, you will need to define var Module = {};
21
+ // before the code. Then that object will be used in the code, and you
22
+ // can continue to use Module afterwards as well.
23
+ var Module = moduleArg;
24
+
25
+ // Set up the promise that indicates the Module is initialized
26
+ var readyPromiseResolve, readyPromiseReject;
27
+ var readyPromise = new Promise((resolve, reject) => {
28
+ readyPromiseResolve = resolve;
29
+ readyPromiseReject = reject;
30
+ });
31
+ ["_memory","___indirect_function_table","onRuntimeInitialized"].forEach((prop) => {
32
+ if (!Object.getOwnPropertyDescriptor(readyPromise, prop)) {
33
+ Object.defineProperty(readyPromise, prop, {
34
+ get: () => abort('You are getting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
35
+ set: () => abort('You are setting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
36
+ });
37
+ }
38
+ });
39
+
40
+ // Determine the runtime environment we are in. You can customize this by
41
+ // setting the ENVIRONMENT setting at compile time (see settings.js).
42
+
43
+ // Attempt to auto-detect the environment
44
+ var ENVIRONMENT_IS_WEB = typeof window == 'object';
45
+ var ENVIRONMENT_IS_WORKER = typeof importScripts == 'function';
46
+ // N.b. Electron.js environment is simultaneously a NODE-environment, but
47
+ // also a web environment.
48
+ var ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string';
49
+ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER;
50
+
51
+ if (Module['ENVIRONMENT']) {
52
+ throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)');
53
+ }
54
+
55
+ if (ENVIRONMENT_IS_NODE) {
56
+ // `require()` is no-op in an ESM module, use `createRequire()` to construct
57
+ // the require()` function. This is only necessary for multi-environment
58
+ // builds, `-sENVIRONMENT=node` emits a static import declaration instead.
59
+ // TODO: Swap all `require()`'s with `import()`'s?
60
+
61
+ }
62
+
63
+ // --pre-jses are emitted after the Module integration code, so that they can
64
+ // refer to Module (if they choose; they can also define Module)
65
+
66
+
67
+ // Sometimes an existing Module object exists with properties
68
+ // meant to overwrite the default module functionality. Here
69
+ // we collect those properties and reapply _after_ we configure
70
+ // the current environment's defaults to avoid having to be so
71
+ // defensive during initialization.
72
+ var moduleOverrides = Object.assign({}, Module);
73
+
74
+ var arguments_ = [];
75
+ var thisProgram = './this.program';
76
+ var quit_ = (status, toThrow) => {
77
+ throw toThrow;
78
+ };
79
+
80
+ // `/` should be present at the end if `scriptDirectory` is not empty
81
+ var scriptDirectory = '';
82
+ function locateFile(path) {
83
+ if (Module['locateFile']) {
84
+ return Module['locateFile'](path, scriptDirectory);
85
+ }
86
+ return scriptDirectory + path;
87
+ }
88
+
89
+ // Hooks that are implemented differently in different runtime environments.
90
+ var readAsync, readBinary;
91
+
92
+ if (ENVIRONMENT_IS_NODE) {
93
+ if (typeof process == 'undefined' || !process.release || process.release.name !== 'node') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
94
+
95
+ var nodeVersion = process.versions.node;
96
+ var numericVersion = nodeVersion.split('.').slice(0, 3);
97
+ numericVersion = (numericVersion[0] * 10000) + (numericVersion[1] * 100) + (numericVersion[2].split('-')[0] * 1);
98
+ var minVersion = 160000;
99
+ if (numericVersion < 160000) {
100
+ throw new Error('This emscripten-generated code requires node v16.0.0 (detected v' + nodeVersion + ')');
101
+ }
102
+
103
+ // These modules will usually be used on Node.js. Load them eagerly to avoid
104
+ // the complexity of lazy-loading.
105
+ var fs = require('fs');
106
+ var nodePath = require('path');
107
+
108
+ scriptDirectory = __dirname + '/';
109
+
110
+ // include: node_shell_read.js
111
+ readBinary = (filename) => {
112
+ // We need to re-wrap `file://` strings to URLs. Normalizing isn't
113
+ // necessary in that case, the path should already be absolute.
114
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
115
+ var ret = fs.readFileSync(filename);
116
+ assert(ret.buffer);
117
+ return ret;
118
+ };
119
+
120
+ readAsync = (filename, binary = true) => {
121
+ // See the comment in the `readBinary` function.
122
+ filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename);
123
+ return new Promise((resolve, reject) => {
124
+ fs.readFile(filename, binary ? undefined : 'utf8', (err, data) => {
125
+ if (err) reject(err);
126
+ else resolve(binary ? data.buffer : data);
127
+ });
128
+ });
129
+ };
130
+ // end include: node_shell_read.js
131
+ if (!Module['thisProgram'] && process.argv.length > 1) {
132
+ thisProgram = process.argv[1].replace(/\\/g, '/');
133
+ }
134
+
135
+ arguments_ = process.argv.slice(2);
136
+
137
+ // MODULARIZE will export the module in the proper place outside, we don't need to export here
138
+
139
+ quit_ = (status, toThrow) => {
140
+ process.exitCode = status;
141
+ throw toThrow;
142
+ };
143
+
144
+ } else
145
+ if (ENVIRONMENT_IS_SHELL) {
146
+
147
+ if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof importScripts == 'function') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
148
+
149
+ } else
150
+
151
+ // Note that this includes Node.js workers when relevant (pthreads is enabled).
152
+ // Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
153
+ // ENVIRONMENT_IS_NODE.
154
+ if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
155
+ if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
156
+ scriptDirectory = self.location.href;
157
+ } else if (typeof document != 'undefined' && document.currentScript) { // web
158
+ scriptDirectory = document.currentScript.src;
159
+ }
160
+ // When MODULARIZE, this JS may be executed later, after document.currentScript
161
+ // is gone, so we saved it, and we use it here instead of any other info.
162
+ if (_scriptName) {
163
+ scriptDirectory = _scriptName;
164
+ }
165
+ // blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
166
+ // otherwise, slice off the final part of the url to find the script directory.
167
+ // if scriptDirectory does not contain a slash, lastIndexOf will return -1,
168
+ // and scriptDirectory will correctly be replaced with an empty string.
169
+ // If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
170
+ // they are removed because they could contain a slash.
171
+ if (scriptDirectory.startsWith('blob:')) {
172
+ scriptDirectory = '';
173
+ } else {
174
+ scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, '').lastIndexOf('/')+1);
175
+ }
176
+
177
+ if (!(typeof window == 'object' || typeof importScripts == 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
178
+
179
+ {
180
+ // include: web_or_worker_shell_read.js
181
+ if (ENVIRONMENT_IS_WORKER) {
182
+ readBinary = (url) => {
183
+ var xhr = new XMLHttpRequest();
184
+ xhr.open('GET', url, false);
185
+ xhr.responseType = 'arraybuffer';
186
+ xhr.send(null);
187
+ return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
188
+ };
189
+ }
190
+
191
+ readAsync = (url) => {
192
+ // Fetch has some additional restrictions over XHR, like it can't be used on a file:// url.
193
+ // See https://github.com/github/fetch/pull/92#issuecomment-140665932
194
+ // Cordova or Electron apps are typically loaded from a file:// url.
195
+ // So use XHR on webview if URL is a file URL.
196
+ if (isFileURI(url)) {
197
+ return new Promise((reject, resolve) => {
198
+ var xhr = new XMLHttpRequest();
199
+ xhr.open('GET', url, true);
200
+ xhr.responseType = 'arraybuffer';
201
+ xhr.onload = () => {
202
+ if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
203
+ resolve(xhr.response);
204
+ }
205
+ reject(xhr.status);
206
+ };
207
+ xhr.onerror = reject;
208
+ xhr.send(null);
209
+ });
210
+ }
211
+ return fetch(url, { credentials: 'same-origin' })
212
+ .then((response) => {
213
+ if (response.ok) {
214
+ return response.arrayBuffer();
215
+ }
216
+ return Promise.reject(new Error(response.status + ' : ' + response.url));
217
+ })
218
+ };
219
+ // end include: web_or_worker_shell_read.js
220
+ }
221
+ } else
222
+ {
223
+ throw new Error('environment detection error');
224
+ }
225
+
226
+ var out = Module['print'] || console.log.bind(console);
227
+ var err = Module['printErr'] || console.error.bind(console);
228
+
229
+ // Merge back in the overrides
230
+ Object.assign(Module, moduleOverrides);
231
+ // Free the object hierarchy contained in the overrides, this lets the GC
232
+ // reclaim data used.
233
+ moduleOverrides = null;
234
+ checkIncomingModuleAPI();
235
+
236
+ // Emit code to handle expected values on the Module object. This applies Module.x
237
+ // to the proper local x. This has two benefits: first, we only emit it if it is
238
+ // expected to arrive, and second, by using a local everywhere else that can be
239
+ // minified.
240
+
241
+ if (Module['arguments']) arguments_ = Module['arguments'];legacyModuleProp('arguments', 'arguments_');
242
+
243
+ if (Module['thisProgram']) thisProgram = Module['thisProgram'];legacyModuleProp('thisProgram', 'thisProgram');
244
+
245
+ if (Module['quit']) quit_ = Module['quit'];legacyModuleProp('quit', 'quit_');
246
+
247
+ // perform assertions in shell.js after we set up out() and err(), as otherwise if an assertion fails it cannot print the message
248
+ // Assertions on removed incoming Module JS APIs.
249
+ assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead');
250
+ assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead');
251
+ assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead');
252
+ assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead');
253
+ assert(typeof Module['read'] == 'undefined', 'Module.read option was removed');
254
+ assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)');
255
+ assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)');
256
+ assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify emscripten_set_window_title in JS)');
257
+ assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY');
258
+ legacyModuleProp('asm', 'wasmExports');
259
+ legacyModuleProp('readAsync', 'readAsync');
260
+ legacyModuleProp('readBinary', 'readBinary');
261
+ legacyModuleProp('setWindowTitle', 'setWindowTitle');
262
+ var IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js';
263
+ var PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js';
264
+ var WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js';
265
+ var FETCHFS = 'FETCHFS is no longer included by default; build with -lfetchfs.js';
266
+ var ICASEFS = 'ICASEFS is no longer included by default; build with -licasefs.js';
267
+ var JSFILEFS = 'JSFILEFS is no longer included by default; build with -ljsfilefs.js';
268
+ var OPFS = 'OPFS is no longer included by default; build with -lopfs.js';
269
+
270
+ var NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js';
271
+
272
+ assert(!ENVIRONMENT_IS_SHELL, 'shell environment detected but not enabled at build time. Add `shell` to `-sENVIRONMENT` to enable.');
273
+
274
+ // end include: shell.js
275
+
276
+ // include: preamble.js
277
+ // === Preamble library stuff ===
278
+
279
+ // Documentation for the public APIs defined in this file must be updated in:
280
+ // site/source/docs/api_reference/preamble.js.rst
281
+ // A prebuilt local version of the documentation is available at:
282
+ // site/build/text/docs/api_reference/preamble.js.txt
283
+ // You can also build docs locally as HTML or other formats in site/
284
+ // An online HTML version (which may be of a different version of Emscripten)
285
+ // is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
286
+
287
+ var wasmBinary;
288
+ if (Module['wasmBinary']) wasmBinary = Module['wasmBinary'];legacyModuleProp('wasmBinary', 'wasmBinary');
289
+
290
+ if (typeof WebAssembly != 'object') {
291
+ err('no native wasm support detected');
292
+ }
293
+
294
+ // Wasm globals
295
+
296
+ var wasmMemory;
297
+
298
+ //========================================
299
+ // Runtime essentials
300
+ //========================================
301
+
302
+ // whether we are quitting the application. no code should run after this.
303
+ // set in exit() and abort()
304
+ var ABORT = false;
305
+
306
+ // set by exit() and abort(). Passed to 'onExit' handler.
307
+ // NOTE: This is also used as the process return code code in shell environments
308
+ // but only when noExitRuntime is false.
309
+ var EXITSTATUS;
310
+
311
+ // In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
312
+ // don't define it at all in release modes. This matches the behaviour of
313
+ // MINIMAL_RUNTIME.
314
+ // TODO(sbc): Make this the default even without STRICT enabled.
315
+ /** @type {function(*, string=)} */
316
+ function assert(condition, text) {
317
+ if (!condition) {
318
+ abort('Assertion failed' + (text ? ': ' + text : ''));
319
+ }
320
+ }
321
+
322
+ // We used to include malloc/free by default in the past. Show a helpful error in
323
+ // builds with assertions.
324
+
325
+ // Memory management
326
+
327
+ var HEAP,
328
+ /** @type {!Int8Array} */
329
+ HEAP8,
330
+ /** @type {!Uint8Array} */
331
+ HEAPU8,
332
+ /** @type {!Int16Array} */
333
+ HEAP16,
334
+ /** @type {!Uint16Array} */
335
+ HEAPU16,
336
+ /** @type {!Int32Array} */
337
+ HEAP32,
338
+ /** @type {!Uint32Array} */
339
+ HEAPU32,
340
+ /** @type {!Float32Array} */
341
+ HEAPF32,
342
+ /** @type {!Float64Array} */
343
+ HEAPF64;
344
+
345
+ // include: runtime_shared.js
346
+ function updateMemoryViews() {
347
+ var b = wasmMemory.buffer;
348
+ Module['HEAP8'] = HEAP8 = new Int8Array(b);
349
+ Module['HEAP16'] = HEAP16 = new Int16Array(b);
350
+ Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
351
+ Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
352
+ Module['HEAP32'] = HEAP32 = new Int32Array(b);
353
+ Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
354
+ Module['HEAPF32'] = HEAPF32 = new Float32Array(b);
355
+ Module['HEAPF64'] = HEAPF64 = new Float64Array(b);
356
+ }
357
+ // end include: runtime_shared.js
358
+ assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time')
359
+
360
+ assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
361
+ 'JS engine does not provide full typed array support');
362
+
363
+ // If memory is defined in wasm, the user can't provide it, or set INITIAL_MEMORY
364
+ assert(!Module['wasmMemory'], 'Use of `wasmMemory` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally');
365
+ assert(!Module['INITIAL_MEMORY'], 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically');
366
+
367
+ // include: runtime_stack_check.js
368
+ // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
369
+ function writeStackCookie() {
370
+ var max = _emscripten_stack_get_end();
371
+ assert((max & 3) == 0);
372
+ // If the stack ends at address zero we write our cookies 4 bytes into the
373
+ // stack. This prevents interference with SAFE_HEAP and ASAN which also
374
+ // monitor writes to address zero.
375
+ if (max == 0) {
376
+ max += 4;
377
+ }
378
+ // The stack grow downwards towards _emscripten_stack_get_end.
379
+ // We write cookies to the final two words in the stack and detect if they are
380
+ // ever overwritten.
381
+ HEAPU32[((max)>>2)] = 0x02135467;
382
+ HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE;
383
+ // Also test the global address 0 for integrity.
384
+ HEAPU32[((0)>>2)] = 1668509029;
385
+ }
386
+
387
+ function checkStackCookie() {
388
+ if (ABORT) return;
389
+ var max = _emscripten_stack_get_end();
390
+ // See writeStackCookie().
391
+ if (max == 0) {
392
+ max += 4;
393
+ }
394
+ var cookie1 = HEAPU32[((max)>>2)];
395
+ var cookie2 = HEAPU32[(((max)+(4))>>2)];
396
+ if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) {
397
+ abort(`Stack overflow! Stack cookie has been overwritten at ${ptrToString(max)}, expected hex dwords 0x89BACDFE and 0x2135467, but received ${ptrToString(cookie2)} ${ptrToString(cookie1)}`);
398
+ }
399
+ // Also test the global address 0 for integrity.
400
+ if (HEAPU32[((0)>>2)] != 0x63736d65 /* 'emsc' */) {
401
+ abort('Runtime error: The application has corrupted its heap memory area (address zero)!');
402
+ }
403
+ }
404
+ // end include: runtime_stack_check.js
405
+ // include: runtime_assertions.js
406
+ // Endianness check
407
+ (function() {
408
+ var h16 = new Int16Array(1);
409
+ var h8 = new Int8Array(h16.buffer);
410
+ h16[0] = 0x6373;
411
+ if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)';
412
+ })();
413
+
414
+ // end include: runtime_assertions.js
415
+ var __ATPRERUN__ = []; // functions called before the runtime is initialized
416
+ var __ATINIT__ = []; // functions called during startup
417
+ var __ATEXIT__ = []; // functions called during shutdown
418
+ var __ATPOSTRUN__ = []; // functions called after the main() is called
419
+
420
+ var runtimeInitialized = false;
421
+
422
+ function preRun() {
423
+ if (Module['preRun']) {
424
+ if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']];
425
+ while (Module['preRun'].length) {
426
+ addOnPreRun(Module['preRun'].shift());
427
+ }
428
+ }
429
+ callRuntimeCallbacks(__ATPRERUN__);
430
+ }
431
+
432
+ function initRuntime() {
433
+ assert(!runtimeInitialized);
434
+ runtimeInitialized = true;
435
+
436
+ checkStackCookie();
437
+
438
+
439
+ callRuntimeCallbacks(__ATINIT__);
440
+ }
441
+
442
+ function postRun() {
443
+ checkStackCookie();
444
+
445
+ if (Module['postRun']) {
446
+ if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']];
447
+ while (Module['postRun'].length) {
448
+ addOnPostRun(Module['postRun'].shift());
449
+ }
450
+ }
451
+
452
+ callRuntimeCallbacks(__ATPOSTRUN__);
453
+ }
454
+
455
+ function addOnPreRun(cb) {
456
+ __ATPRERUN__.unshift(cb);
457
+ }
458
+
459
+ function addOnInit(cb) {
460
+ __ATINIT__.unshift(cb);
461
+ }
462
+
463
+ function addOnExit(cb) {
464
+ }
465
+
466
+ function addOnPostRun(cb) {
467
+ __ATPOSTRUN__.unshift(cb);
468
+ }
469
+
470
+ // include: runtime_math.js
471
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
472
+
473
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround
474
+
475
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32
476
+
477
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc
478
+
479
+ assert(Math.imul, 'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
480
+ assert(Math.fround, 'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
481
+ assert(Math.clz32, 'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
482
+ assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill');
483
+ // end include: runtime_math.js
484
+ // A counter of dependencies for calling run(). If we need to
485
+ // do asynchronous work before running, increment this and
486
+ // decrement it. Incrementing must happen in a place like
487
+ // Module.preRun (used by emcc to add file preloading).
488
+ // Note that you can add dependencies in preRun, even though
489
+ // it happens right before run - run will be postponed until
490
+ // the dependencies are met.
491
+ var runDependencies = 0;
492
+ var runDependencyWatcher = null;
493
+ var dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
494
+ var runDependencyTracking = {};
495
+
496
+ function getUniqueRunDependency(id) {
497
+ var orig = id;
498
+ while (1) {
499
+ if (!runDependencyTracking[id]) return id;
500
+ id = orig + Math.random();
501
+ }
502
+ }
503
+
504
+ function addRunDependency(id) {
505
+ runDependencies++;
506
+
507
+ Module['monitorRunDependencies']?.(runDependencies);
508
+
509
+ if (id) {
510
+ assert(!runDependencyTracking[id]);
511
+ runDependencyTracking[id] = 1;
512
+ if (runDependencyWatcher === null && typeof setInterval != 'undefined') {
513
+ // Check for missing dependencies every few seconds
514
+ runDependencyWatcher = setInterval(() => {
515
+ if (ABORT) {
516
+ clearInterval(runDependencyWatcher);
517
+ runDependencyWatcher = null;
518
+ return;
519
+ }
520
+ var shown = false;
521
+ for (var dep in runDependencyTracking) {
522
+ if (!shown) {
523
+ shown = true;
524
+ err('still waiting on run dependencies:');
525
+ }
526
+ err(`dependency: ${dep}`);
527
+ }
528
+ if (shown) {
529
+ err('(end of list)');
530
+ }
531
+ }, 10000);
532
+ }
533
+ } else {
534
+ err('warning: run dependency added without ID');
535
+ }
536
+ }
537
+
538
+ function removeRunDependency(id) {
539
+ runDependencies--;
540
+
541
+ Module['monitorRunDependencies']?.(runDependencies);
542
+
543
+ if (id) {
544
+ assert(runDependencyTracking[id]);
545
+ delete runDependencyTracking[id];
546
+ } else {
547
+ err('warning: run dependency removed without ID');
548
+ }
549
+ if (runDependencies == 0) {
550
+ if (runDependencyWatcher !== null) {
551
+ clearInterval(runDependencyWatcher);
552
+ runDependencyWatcher = null;
553
+ }
554
+ if (dependenciesFulfilled) {
555
+ var callback = dependenciesFulfilled;
556
+ dependenciesFulfilled = null;
557
+ callback(); // can add another dependenciesFulfilled
558
+ }
559
+ }
560
+ }
561
+
562
+ /** @param {string|number=} what */
563
+ function abort(what) {
564
+ Module['onAbort']?.(what);
565
+
566
+ what = 'Aborted(' + what + ')';
567
+ // TODO(sbc): Should we remove printing and leave it up to whoever
568
+ // catches the exception?
569
+ err(what);
570
+
571
+ ABORT = true;
572
+ EXITSTATUS = 1;
573
+
574
+ // Use a wasm runtime error, because a JS error might be seen as a foreign
575
+ // exception, which means we'd run destructors on it. We need the error to
576
+ // simply make the program stop.
577
+ // FIXME This approach does not work in Wasm EH because it currently does not assume
578
+ // all RuntimeErrors are from traps; it decides whether a RuntimeError is from
579
+ // a trap or not based on a hidden field within the object. So at the moment
580
+ // we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
581
+ // allows this in the wasm spec.
582
+
583
+ // Suppress closure compiler warning here. Closure compiler's builtin extern
584
+ // definition for WebAssembly.RuntimeError claims it takes no arguments even
585
+ // though it can.
586
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
587
+ /** @suppress {checkTypes} */
588
+ var e = new WebAssembly.RuntimeError(what);
589
+
590
+ readyPromiseReject(e);
591
+ // Throw the error whether or not MODULARIZE is set because abort is used
592
+ // in code paths apart from instantiation where an exception is expected
593
+ // to be thrown when abort is called.
594
+ throw e;
595
+ }
596
+
597
+ // include: memoryprofiler.js
598
+ // end include: memoryprofiler.js
599
+ // show errors on likely calls to FS when it was not included
600
+ var FS = {
601
+ error() {
602
+ abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM');
603
+ },
604
+ init() { FS.error() },
605
+ createDataFile() { FS.error() },
606
+ createPreloadedFile() { FS.error() },
607
+ createLazyFile() { FS.error() },
608
+ open() { FS.error() },
609
+ mkdev() { FS.error() },
610
+ registerDevice() { FS.error() },
611
+ analyzePath() { FS.error() },
612
+
613
+ ErrnoError() { FS.error() },
614
+ };
615
+ Module['FS_createDataFile'] = FS.createDataFile;
616
+ Module['FS_createPreloadedFile'] = FS.createPreloadedFile;
617
+
618
+ // include: URIUtils.js
619
+ // Prefix of data URIs emitted by SINGLE_FILE and related options.
620
+ var dataURIPrefix = 'data:application/octet-stream;base64,';
621
+
622
+ /**
623
+ * Indicates whether filename is a base64 data URI.
624
+ * @noinline
625
+ */
626
+ var isDataURI = (filename) => filename.startsWith(dataURIPrefix);
627
+
628
+ /**
629
+ * Indicates whether filename is delivered via file protocol (as opposed to http/https)
630
+ * @noinline
631
+ */
632
+ var isFileURI = (filename) => filename.startsWith('file://');
633
+ // end include: URIUtils.js
634
+ function createExportWrapper(name, nargs) {
635
+ return (...args) => {
636
+ assert(runtimeInitialized, `native function \`${name}\` called before runtime initialization`);
637
+ var f = wasmExports[name];
638
+ assert(f, `exported native function \`${name}\` not found`);
639
+ // Only assert for too many arguments. Too few can be valid since the missing arguments will be zero filled.
640
+ assert(args.length <= nargs, `native function \`${name}\` called with ${args.length} args but expects ${nargs}`);
641
+ return f(...args);
642
+ };
643
+ }
644
+
645
+ // include: runtime_exceptions.js
646
+ // end include: runtime_exceptions.js
647
+ function findWasmBinary() {
648
+ var f = 'statsim.wasm';
649
+ if (!isDataURI(f)) {
650
+ return locateFile(f);
651
+ }
652
+ return f;
653
+ }
654
+
655
+ var wasmBinaryFile;
656
+
657
+ function getBinarySync(file) {
658
+ if (file == wasmBinaryFile && wasmBinary) {
659
+ return new Uint8Array(wasmBinary);
660
+ }
661
+ if (readBinary) {
662
+ return readBinary(file);
663
+ }
664
+ throw 'both async and sync fetching of the wasm failed';
665
+ }
666
+
667
+ function getBinaryPromise(binaryFile) {
668
+ // If we don't have the binary yet, load it asynchronously using readAsync.
669
+ if (!wasmBinary
670
+ ) {
671
+ // Fetch the binary using readAsync
672
+ return readAsync(binaryFile).then(
673
+ (response) => new Uint8Array(/** @type{!ArrayBuffer} */(response)),
674
+ // Fall back to getBinarySync if readAsync fails
675
+ () => getBinarySync(binaryFile)
676
+ );
677
+ }
678
+
679
+ // Otherwise, getBinarySync should be able to get it synchronously
680
+ return Promise.resolve().then(() => getBinarySync(binaryFile));
681
+ }
682
+
683
+ function instantiateArrayBuffer(binaryFile, imports, receiver) {
684
+ return getBinaryPromise(binaryFile).then((binary) => {
685
+ return WebAssembly.instantiate(binary, imports);
686
+ }).then(receiver, (reason) => {
687
+ err(`failed to asynchronously prepare wasm: ${reason}`);
688
+
689
+ // Warn on some common problems.
690
+ if (isFileURI(wasmBinaryFile)) {
691
+ err(`warning: Loading from a file URI (${wasmBinaryFile}) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing`);
692
+ }
693
+ abort(reason);
694
+ });
695
+ }
696
+
697
+ function instantiateAsync(binary, binaryFile, imports, callback) {
698
+ if (!binary &&
699
+ typeof WebAssembly.instantiateStreaming == 'function' &&
700
+ !isDataURI(binaryFile) &&
701
+ // Don't use streaming for file:// delivered objects in a webview, fetch them synchronously.
702
+ !isFileURI(binaryFile) &&
703
+ // Avoid instantiateStreaming() on Node.js environment for now, as while
704
+ // Node.js v18.1.0 implements it, it does not have a full fetch()
705
+ // implementation yet.
706
+ //
707
+ // Reference:
708
+ // https://github.com/emscripten-core/emscripten/pull/16917
709
+ !ENVIRONMENT_IS_NODE &&
710
+ typeof fetch == 'function') {
711
+ return fetch(binaryFile, { credentials: 'same-origin' }).then((response) => {
712
+ // Suppress closure warning here since the upstream definition for
713
+ // instantiateStreaming only allows Promise<Repsponse> rather than
714
+ // an actual Response.
715
+ // TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure is fixed.
716
+ /** @suppress {checkTypes} */
717
+ var result = WebAssembly.instantiateStreaming(response, imports);
718
+
719
+ return result.then(
720
+ callback,
721
+ function(reason) {
722
+ // We expect the most common failure cause to be a bad MIME type for the binary,
723
+ // in which case falling back to ArrayBuffer instantiation should work.
724
+ err(`wasm streaming compile failed: ${reason}`);
725
+ err('falling back to ArrayBuffer instantiation');
726
+ return instantiateArrayBuffer(binaryFile, imports, callback);
727
+ });
728
+ });
729
+ }
730
+ return instantiateArrayBuffer(binaryFile, imports, callback);
731
+ }
732
+
733
+ function getWasmImports() {
734
+ // prepare imports
735
+ return {
736
+ 'env': wasmImports,
737
+ 'wasi_snapshot_preview1': wasmImports,
738
+ }
739
+ }
740
+
741
+ // Create the wasm instance.
742
+ // Receives the wasm imports, returns the exports.
743
+ function createWasm() {
744
+ var info = getWasmImports();
745
+ // Load the wasm module and create an instance of using native support in the JS engine.
746
+ // handle a generated wasm instance, receiving its exports and
747
+ // performing other necessary setup
748
+ /** @param {WebAssembly.Module=} module*/
749
+ function receiveInstance(instance, module) {
750
+ wasmExports = instance.exports;
751
+
752
+
753
+
754
+ wasmMemory = wasmExports['memory'];
755
+
756
+ assert(wasmMemory, 'memory not found in wasm exports');
757
+ updateMemoryViews();
758
+
759
+ wasmTable = wasmExports['__indirect_function_table'];
760
+
761
+ assert(wasmTable, 'table not found in wasm exports');
762
+
763
+ addOnInit(wasmExports['__wasm_call_ctors']);
764
+
765
+ removeRunDependency('wasm-instantiate');
766
+ return wasmExports;
767
+ }
768
+ // wait for the pthread pool (if any)
769
+ addRunDependency('wasm-instantiate');
770
+
771
+ // Prefer streaming instantiation if available.
772
+ // Async compilation can be confusing when an error on the page overwrites Module
773
+ // (for example, if the order of elements is wrong, and the one defining Module is
774
+ // later), so we save Module and check it later.
775
+ var trueModule = Module;
776
+ function receiveInstantiationResult(result) {
777
+ // 'result' is a ResultObject object which has both the module and instance.
778
+ // receiveInstance() will swap in the exports (to Module.asm) so they can be called
779
+ assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?');
780
+ trueModule = null;
781
+ // TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
782
+ // When the regression is fixed, can restore the above PTHREADS-enabled path.
783
+ receiveInstance(result['instance']);
784
+ }
785
+
786
+ // User shell pages can write their own Module.instantiateWasm = function(imports, successCallback) callback
787
+ // to manually instantiate the Wasm module themselves. This allows pages to
788
+ // run the instantiation parallel to any other async startup actions they are
789
+ // performing.
790
+ // Also pthreads and wasm workers initialize the wasm instance through this
791
+ // path.
792
+ if (Module['instantiateWasm']) {
793
+ try {
794
+ return Module['instantiateWasm'](info, receiveInstance);
795
+ } catch(e) {
796
+ err(`Module.instantiateWasm callback failed with error: ${e}`);
797
+ // If instantiation fails, reject the module ready promise.
798
+ readyPromiseReject(e);
799
+ }
800
+ }
801
+
802
+ if (!wasmBinaryFile) wasmBinaryFile = findWasmBinary();
803
+
804
+ // If instantiation fails, reject the module ready promise.
805
+ instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult).catch(readyPromiseReject);
806
+ return {}; // no exports yet; we'll fill them in later
807
+ }
808
+
809
+ // Globals used by JS i64 conversions (see makeSetValue)
810
+ var tempDouble;
811
+ var tempI64;
812
+
813
+ // include: runtime_debug.js
814
+ function legacyModuleProp(prop, newName, incoming=true) {
815
+ if (!Object.getOwnPropertyDescriptor(Module, prop)) {
816
+ Object.defineProperty(Module, prop, {
817
+ configurable: true,
818
+ get() {
819
+ let extra = incoming ? ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)' : '';
820
+ abort(`\`Module.${prop}\` has been replaced by \`${newName}\`` + extra);
821
+
822
+ }
823
+ });
824
+ }
825
+ }
826
+
827
+ function ignoredModuleProp(prop) {
828
+ if (Object.getOwnPropertyDescriptor(Module, prop)) {
829
+ abort(`\`Module.${prop}\` was supplied but \`${prop}\` not included in INCOMING_MODULE_JS_API`);
830
+ }
831
+ }
832
+
833
+ // forcing the filesystem exports a few things by default
834
+ function isExportedByForceFilesystem(name) {
835
+ return name === 'FS_createPath' ||
836
+ name === 'FS_createDataFile' ||
837
+ name === 'FS_createPreloadedFile' ||
838
+ name === 'FS_unlink' ||
839
+ name === 'addRunDependency' ||
840
+ // The old FS has some functionality that WasmFS lacks.
841
+ name === 'FS_createLazyFile' ||
842
+ name === 'FS_createDevice' ||
843
+ name === 'removeRunDependency';
844
+ }
845
+
846
+ function missingGlobal(sym, msg) {
847
+ if (typeof globalThis != 'undefined') {
848
+ Object.defineProperty(globalThis, sym, {
849
+ configurable: true,
850
+ get() {
851
+ warnOnce(`\`${sym}\` is not longer defined by emscripten. ${msg}`);
852
+ return undefined;
853
+ }
854
+ });
855
+ }
856
+ }
857
+
858
+ missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer');
859
+ missingGlobal('asm', 'Please use wasmExports instead');
860
+
861
+ function missingLibrarySymbol(sym) {
862
+ if (typeof globalThis != 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) {
863
+ Object.defineProperty(globalThis, sym, {
864
+ configurable: true,
865
+ get() {
866
+ // Can't `abort()` here because it would break code that does runtime
867
+ // checks. e.g. `if (typeof SDL === 'undefined')`.
868
+ var msg = `\`${sym}\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line`;
869
+ // DEFAULT_LIBRARY_FUNCS_TO_INCLUDE requires the name as it appears in
870
+ // library.js, which means $name for a JS name with no prefix, or name
871
+ // for a JS name like _name.
872
+ var librarySymbol = sym;
873
+ if (!librarySymbol.startsWith('_')) {
874
+ librarySymbol = '$' + sym;
875
+ }
876
+ msg += ` (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE='${librarySymbol}')`;
877
+ if (isExportedByForceFilesystem(sym)) {
878
+ msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
879
+ }
880
+ warnOnce(msg);
881
+ return undefined;
882
+ }
883
+ });
884
+ }
885
+ // Any symbol that is not included from the JS library is also (by definition)
886
+ // not exported on the Module object.
887
+ unexportedRuntimeSymbol(sym);
888
+ }
889
+
890
+ function unexportedRuntimeSymbol(sym) {
891
+ if (!Object.getOwnPropertyDescriptor(Module, sym)) {
892
+ Object.defineProperty(Module, sym, {
893
+ configurable: true,
894
+ get() {
895
+ var msg = `'${sym}' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ)`;
896
+ if (isExportedByForceFilesystem(sym)) {
897
+ msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you';
898
+ }
899
+ abort(msg);
900
+ }
901
+ });
902
+ }
903
+ }
904
+
905
+ // Used by XXXXX_DEBUG settings to output debug messages.
906
+ function dbg(...args) {
907
+ // TODO(sbc): Make this configurable somehow. Its not always convenient for
908
+ // logging to show up as warnings.
909
+ console.warn(...args);
910
+ }
911
+ // end include: runtime_debug.js
912
+ // === Body ===
913
+ // end include: preamble.js
914
+
915
+
916
+ /** @constructor */
917
+ function ExitStatus(status) {
918
+ this.name = 'ExitStatus';
919
+ this.message = `Program terminated with exit(${status})`;
920
+ this.status = status;
921
+ }
922
+
923
+ var callRuntimeCallbacks = (callbacks) => {
924
+ while (callbacks.length > 0) {
925
+ // Pass the module as the first argument.
926
+ callbacks.shift()(Module);
927
+ }
928
+ };
929
+
930
+
931
+ /**
932
+ * @param {number} ptr
933
+ * @param {string} type
934
+ */
935
+ function getValue(ptr, type = 'i8') {
936
+ if (type.endsWith('*')) type = '*';
937
+ switch (type) {
938
+ case 'i1': return HEAP8[ptr];
939
+ case 'i8': return HEAP8[ptr];
940
+ case 'i16': return HEAP16[((ptr)>>1)];
941
+ case 'i32': return HEAP32[((ptr)>>2)];
942
+ case 'i64': abort('to do getValue(i64) use WASM_BIGINT');
943
+ case 'float': return HEAPF32[((ptr)>>2)];
944
+ case 'double': return HEAPF64[((ptr)>>3)];
945
+ case '*': return HEAPU32[((ptr)>>2)];
946
+ default: abort(`invalid type for getValue: ${type}`);
947
+ }
948
+ }
949
+
950
+ var noExitRuntime = Module['noExitRuntime'] || true;
951
+
952
+ var ptrToString = (ptr) => {
953
+ assert(typeof ptr === 'number');
954
+ // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
955
+ ptr >>>= 0;
956
+ return '0x' + ptr.toString(16).padStart(8, '0');
957
+ };
958
+
959
+
960
+ /**
961
+ * @param {number} ptr
962
+ * @param {number} value
963
+ * @param {string} type
964
+ */
965
+ function setValue(ptr, value, type = 'i8') {
966
+ if (type.endsWith('*')) type = '*';
967
+ switch (type) {
968
+ case 'i1': HEAP8[ptr] = value; break;
969
+ case 'i8': HEAP8[ptr] = value; break;
970
+ case 'i16': HEAP16[((ptr)>>1)] = value; break;
971
+ case 'i32': HEAP32[((ptr)>>2)] = value; break;
972
+ case 'i64': abort('to do setValue(i64) use WASM_BIGINT');
973
+ case 'float': HEAPF32[((ptr)>>2)] = value; break;
974
+ case 'double': HEAPF64[((ptr)>>3)] = value; break;
975
+ case '*': HEAPU32[((ptr)>>2)] = value; break;
976
+ default: abort(`invalid type for setValue: ${type}`);
977
+ }
978
+ }
979
+
980
+ var stackRestore = (val) => __emscripten_stack_restore(val);
981
+
982
+ var stackSave = () => _emscripten_stack_get_current();
983
+
984
+ var warnOnce = (text) => {
985
+ warnOnce.shown ||= {};
986
+ if (!warnOnce.shown[text]) {
987
+ warnOnce.shown[text] = 1;
988
+ if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text;
989
+ err(text);
990
+ }
991
+ };
992
+
993
+ var UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined;
994
+
995
+ /**
996
+ * Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
997
+ * array that contains uint8 values, returns a copy of that string as a
998
+ * Javascript String object.
999
+ * heapOrArray is either a regular array, or a JavaScript typed array view.
1000
+ * @param {number} idx
1001
+ * @param {number=} maxBytesToRead
1002
+ * @return {string}
1003
+ */
1004
+ var UTF8ArrayToString = (heapOrArray, idx, maxBytesToRead) => {
1005
+ var endIdx = idx + maxBytesToRead;
1006
+ var endPtr = idx;
1007
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
1008
+ // null terminator by itself. Also, use the length info to avoid running tiny
1009
+ // strings through TextDecoder, since .subarray() allocates garbage.
1010
+ // (As a tiny code save trick, compare endPtr against endIdx using a negation,
1011
+ // so that undefined means Infinity)
1012
+ while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr;
1013
+
1014
+ if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
1015
+ return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
1016
+ }
1017
+ var str = '';
1018
+ // If building with TextDecoder, we have already computed the string length
1019
+ // above, so test loop end condition against that
1020
+ while (idx < endPtr) {
1021
+ // For UTF8 byte structure, see:
1022
+ // http://en.wikipedia.org/wiki/UTF-8#Description
1023
+ // https://www.ietf.org/rfc/rfc2279.txt
1024
+ // https://tools.ietf.org/html/rfc3629
1025
+ var u0 = heapOrArray[idx++];
1026
+ if (!(u0 & 0x80)) { str += String.fromCharCode(u0); continue; }
1027
+ var u1 = heapOrArray[idx++] & 63;
1028
+ if ((u0 & 0xE0) == 0xC0) { str += String.fromCharCode(((u0 & 31) << 6) | u1); continue; }
1029
+ var u2 = heapOrArray[idx++] & 63;
1030
+ if ((u0 & 0xF0) == 0xE0) {
1031
+ u0 = ((u0 & 15) << 12) | (u1 << 6) | u2;
1032
+ } else {
1033
+ if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte ' + ptrToString(u0) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!');
1034
+ u0 = ((u0 & 7) << 18) | (u1 << 12) | (u2 << 6) | (heapOrArray[idx++] & 63);
1035
+ }
1036
+
1037
+ if (u0 < 0x10000) {
1038
+ str += String.fromCharCode(u0);
1039
+ } else {
1040
+ var ch = u0 - 0x10000;
1041
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
1042
+ }
1043
+ }
1044
+ return str;
1045
+ };
1046
+
1047
+ /**
1048
+ * Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
1049
+ * emscripten HEAP, returns a copy of that string as a Javascript String object.
1050
+ *
1051
+ * @param {number} ptr
1052
+ * @param {number=} maxBytesToRead - An optional length that specifies the
1053
+ * maximum number of bytes to read. You can omit this parameter to scan the
1054
+ * string until the first 0 byte. If maxBytesToRead is passed, and the string
1055
+ * at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
1056
+ * string will cut short at that byte index (i.e. maxBytesToRead will not
1057
+ * produce a string of exact length [ptr, ptr+maxBytesToRead[) N.B. mixing
1058
+ * frequent uses of UTF8ToString() with and without maxBytesToRead may throw
1059
+ * JS JIT optimizations off, so it is worth to consider consistently using one
1060
+ * @return {string}
1061
+ */
1062
+ var UTF8ToString = (ptr, maxBytesToRead) => {
1063
+ assert(typeof ptr == 'number', `UTF8ToString expects a number (got ${typeof ptr})`);
1064
+ return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : '';
1065
+ };
1066
+ var ___assert_fail = (condition, filename, line, func) => {
1067
+ abort(`Assertion failed: ${UTF8ToString(condition)}, at: ` + [filename ? UTF8ToString(filename) : 'unknown filename', line, func ? UTF8ToString(func) : 'unknown function']);
1068
+ };
1069
+
1070
+ class ExceptionInfo {
1071
+ // excPtr - Thrown object pointer to wrap. Metadata pointer is calculated from it.
1072
+ constructor(excPtr) {
1073
+ this.excPtr = excPtr;
1074
+ this.ptr = excPtr - 24;
1075
+ }
1076
+
1077
+ set_type(type) {
1078
+ HEAPU32[(((this.ptr)+(4))>>2)] = type;
1079
+ }
1080
+
1081
+ get_type() {
1082
+ return HEAPU32[(((this.ptr)+(4))>>2)];
1083
+ }
1084
+
1085
+ set_destructor(destructor) {
1086
+ HEAPU32[(((this.ptr)+(8))>>2)] = destructor;
1087
+ }
1088
+
1089
+ get_destructor() {
1090
+ return HEAPU32[(((this.ptr)+(8))>>2)];
1091
+ }
1092
+
1093
+ set_caught(caught) {
1094
+ caught = caught ? 1 : 0;
1095
+ HEAP8[(this.ptr)+(12)] = caught;
1096
+ }
1097
+
1098
+ get_caught() {
1099
+ return HEAP8[(this.ptr)+(12)] != 0;
1100
+ }
1101
+
1102
+ set_rethrown(rethrown) {
1103
+ rethrown = rethrown ? 1 : 0;
1104
+ HEAP8[(this.ptr)+(13)] = rethrown;
1105
+ }
1106
+
1107
+ get_rethrown() {
1108
+ return HEAP8[(this.ptr)+(13)] != 0;
1109
+ }
1110
+
1111
+ // Initialize native structure fields. Should be called once after allocated.
1112
+ init(type, destructor) {
1113
+ this.set_adjusted_ptr(0);
1114
+ this.set_type(type);
1115
+ this.set_destructor(destructor);
1116
+ }
1117
+
1118
+ set_adjusted_ptr(adjustedPtr) {
1119
+ HEAPU32[(((this.ptr)+(16))>>2)] = adjustedPtr;
1120
+ }
1121
+
1122
+ get_adjusted_ptr() {
1123
+ return HEAPU32[(((this.ptr)+(16))>>2)];
1124
+ }
1125
+
1126
+ // Get pointer which is expected to be received by catch clause in C++ code. It may be adjusted
1127
+ // when the pointer is casted to some of the exception object base classes (e.g. when virtual
1128
+ // inheritance is used). When a pointer is thrown this method should return the thrown pointer
1129
+ // itself.
1130
+ get_exception_ptr() {
1131
+ // Work around a fastcomp bug, this code is still included for some reason in a build without
1132
+ // exceptions support.
1133
+ var isPointer = ___cxa_is_pointer_type(this.get_type());
1134
+ if (isPointer) {
1135
+ return HEAPU32[((this.excPtr)>>2)];
1136
+ }
1137
+ var adjusted = this.get_adjusted_ptr();
1138
+ if (adjusted !== 0) return adjusted;
1139
+ return this.excPtr;
1140
+ }
1141
+ }
1142
+
1143
+ var exceptionLast = 0;
1144
+
1145
+ var uncaughtExceptionCount = 0;
1146
+ var ___cxa_throw = (ptr, type, destructor) => {
1147
+ var info = new ExceptionInfo(ptr);
1148
+ // Initialize ExceptionInfo content after it was allocated in __cxa_allocate_exception.
1149
+ info.init(type, destructor);
1150
+ exceptionLast = ptr;
1151
+ uncaughtExceptionCount++;
1152
+ assert(false, 'Exception thrown, but exception catching is not enabled. Compile with -sNO_DISABLE_EXCEPTION_CATCHING or -sEXCEPTION_CATCHING_ALLOWED=[..] to catch.');
1153
+ };
1154
+
1155
+ var __abort_js = () => {
1156
+ abort('native code called abort()');
1157
+ };
1158
+
1159
+ var __embind_register_bigint = (primitiveType, name, size, minRange, maxRange) => {};
1160
+
1161
+ var embind_init_charCodes = () => {
1162
+ var codes = new Array(256);
1163
+ for (var i = 0; i < 256; ++i) {
1164
+ codes[i] = String.fromCharCode(i);
1165
+ }
1166
+ embind_charCodes = codes;
1167
+ };
1168
+ var embind_charCodes;
1169
+ var readLatin1String = (ptr) => {
1170
+ var ret = "";
1171
+ var c = ptr;
1172
+ while (HEAPU8[c]) {
1173
+ ret += embind_charCodes[HEAPU8[c++]];
1174
+ }
1175
+ return ret;
1176
+ };
1177
+
1178
+ var awaitingDependencies = {
1179
+ };
1180
+
1181
+ var registeredTypes = {
1182
+ };
1183
+
1184
+ var typeDependencies = {
1185
+ };
1186
+
1187
+ var BindingError;
1188
+ var throwBindingError = (message) => { throw new BindingError(message); };
1189
+
1190
+
1191
+
1192
+
1193
+ var InternalError;
1194
+ var throwInternalError = (message) => { throw new InternalError(message); };
1195
+ var whenDependentTypesAreResolved = (myTypes, dependentTypes, getTypeConverters) => {
1196
+ myTypes.forEach(function(type) {
1197
+ typeDependencies[type] = dependentTypes;
1198
+ });
1199
+
1200
+ function onComplete(typeConverters) {
1201
+ var myTypeConverters = getTypeConverters(typeConverters);
1202
+ if (myTypeConverters.length !== myTypes.length) {
1203
+ throwInternalError('Mismatched type converter count');
1204
+ }
1205
+ for (var i = 0; i < myTypes.length; ++i) {
1206
+ registerType(myTypes[i], myTypeConverters[i]);
1207
+ }
1208
+ }
1209
+
1210
+ var typeConverters = new Array(dependentTypes.length);
1211
+ var unregisteredTypes = [];
1212
+ var registered = 0;
1213
+ dependentTypes.forEach((dt, i) => {
1214
+ if (registeredTypes.hasOwnProperty(dt)) {
1215
+ typeConverters[i] = registeredTypes[dt];
1216
+ } else {
1217
+ unregisteredTypes.push(dt);
1218
+ if (!awaitingDependencies.hasOwnProperty(dt)) {
1219
+ awaitingDependencies[dt] = [];
1220
+ }
1221
+ awaitingDependencies[dt].push(() => {
1222
+ typeConverters[i] = registeredTypes[dt];
1223
+ ++registered;
1224
+ if (registered === unregisteredTypes.length) {
1225
+ onComplete(typeConverters);
1226
+ }
1227
+ });
1228
+ }
1229
+ });
1230
+ if (0 === unregisteredTypes.length) {
1231
+ onComplete(typeConverters);
1232
+ }
1233
+ };
1234
+ /** @param {Object=} options */
1235
+ function sharedRegisterType(rawType, registeredInstance, options = {}) {
1236
+ var name = registeredInstance.name;
1237
+ if (!rawType) {
1238
+ throwBindingError(`type "${name}" must have a positive integer typeid pointer`);
1239
+ }
1240
+ if (registeredTypes.hasOwnProperty(rawType)) {
1241
+ if (options.ignoreDuplicateRegistrations) {
1242
+ return;
1243
+ } else {
1244
+ throwBindingError(`Cannot register type '${name}' twice`);
1245
+ }
1246
+ }
1247
+
1248
+ registeredTypes[rawType] = registeredInstance;
1249
+ delete typeDependencies[rawType];
1250
+
1251
+ if (awaitingDependencies.hasOwnProperty(rawType)) {
1252
+ var callbacks = awaitingDependencies[rawType];
1253
+ delete awaitingDependencies[rawType];
1254
+ callbacks.forEach((cb) => cb());
1255
+ }
1256
+ }
1257
+ /** @param {Object=} options */
1258
+ function registerType(rawType, registeredInstance, options = {}) {
1259
+ if (!('argPackAdvance' in registeredInstance)) {
1260
+ throw new TypeError('registerType registeredInstance requires argPackAdvance');
1261
+ }
1262
+ return sharedRegisterType(rawType, registeredInstance, options);
1263
+ }
1264
+
1265
+ var GenericWireTypeSize = 8;
1266
+ /** @suppress {globalThis} */
1267
+ var __embind_register_bool = (rawType, name, trueValue, falseValue) => {
1268
+ name = readLatin1String(name);
1269
+ registerType(rawType, {
1270
+ name,
1271
+ 'fromWireType': function(wt) {
1272
+ // ambiguous emscripten ABI: sometimes return values are
1273
+ // true or false, and sometimes integers (0 or 1)
1274
+ return !!wt;
1275
+ },
1276
+ 'toWireType': function(destructors, o) {
1277
+ return o ? trueValue : falseValue;
1278
+ },
1279
+ 'argPackAdvance': GenericWireTypeSize,
1280
+ 'readValueFromPointer': function(pointer) {
1281
+ return this['fromWireType'](HEAPU8[pointer]);
1282
+ },
1283
+ destructorFunction: null, // This type does not need a destructor
1284
+ });
1285
+ };
1286
+
1287
+
1288
+ var emval_freelist = [];
1289
+
1290
+ var emval_handles = [];
1291
+ var __emval_decref = (handle) => {
1292
+ if (handle > 9 && 0 === --emval_handles[handle + 1]) {
1293
+ assert(emval_handles[handle] !== undefined, `Decref for unallocated handle.`);
1294
+ emval_handles[handle] = undefined;
1295
+ emval_freelist.push(handle);
1296
+ }
1297
+ };
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+ var count_emval_handles = () => {
1304
+ return emval_handles.length / 2 - 5 - emval_freelist.length;
1305
+ };
1306
+
1307
+ var init_emval = () => {
1308
+ // reserve 0 and some special values. These never get de-allocated.
1309
+ emval_handles.push(
1310
+ 0, 1,
1311
+ undefined, 1,
1312
+ null, 1,
1313
+ true, 1,
1314
+ false, 1,
1315
+ );
1316
+ assert(emval_handles.length === 5 * 2);
1317
+ Module['count_emval_handles'] = count_emval_handles;
1318
+ };
1319
+ var Emval = {
1320
+ toValue:(handle) => {
1321
+ if (!handle) {
1322
+ throwBindingError('Cannot use deleted val. handle = ' + handle);
1323
+ }
1324
+ // handle 2 is supposed to be `undefined`.
1325
+ assert(handle === 2 || emval_handles[handle] !== undefined && handle % 2 === 0, `invalid handle: ${handle}`);
1326
+ return emval_handles[handle];
1327
+ },
1328
+ toHandle:(value) => {
1329
+ switch (value) {
1330
+ case undefined: return 2;
1331
+ case null: return 4;
1332
+ case true: return 6;
1333
+ case false: return 8;
1334
+ default:{
1335
+ const handle = emval_freelist.pop() || emval_handles.length;
1336
+ emval_handles[handle] = value;
1337
+ emval_handles[handle + 1] = 1;
1338
+ return handle;
1339
+ }
1340
+ }
1341
+ },
1342
+ };
1343
+
1344
+ /** @suppress {globalThis} */
1345
+ function readPointer(pointer) {
1346
+ return this['fromWireType'](HEAPU32[((pointer)>>2)]);
1347
+ }
1348
+
1349
+ var EmValType = {
1350
+ name: 'emscripten::val',
1351
+ 'fromWireType': (handle) => {
1352
+ var rv = Emval.toValue(handle);
1353
+ __emval_decref(handle);
1354
+ return rv;
1355
+ },
1356
+ 'toWireType': (destructors, value) => Emval.toHandle(value),
1357
+ 'argPackAdvance': GenericWireTypeSize,
1358
+ 'readValueFromPointer': readPointer,
1359
+ destructorFunction: null, // This type does not need a destructor
1360
+
1361
+ // TODO: do we need a deleteObject here? write a test where
1362
+ // emval is passed into JS via an interface
1363
+ };
1364
+ var __embind_register_emval = (rawType) => registerType(rawType, EmValType);
1365
+
1366
+ var embindRepr = (v) => {
1367
+ if (v === null) {
1368
+ return 'null';
1369
+ }
1370
+ var t = typeof v;
1371
+ if (t === 'object' || t === 'array' || t === 'function') {
1372
+ return v.toString();
1373
+ } else {
1374
+ return '' + v;
1375
+ }
1376
+ };
1377
+
1378
+ var floatReadValueFromPointer = (name, width) => {
1379
+ switch (width) {
1380
+ case 4: return function(pointer) {
1381
+ return this['fromWireType'](HEAPF32[((pointer)>>2)]);
1382
+ };
1383
+ case 8: return function(pointer) {
1384
+ return this['fromWireType'](HEAPF64[((pointer)>>3)]);
1385
+ };
1386
+ default:
1387
+ throw new TypeError(`invalid float width (${width}): ${name}`);
1388
+ }
1389
+ };
1390
+
1391
+
1392
+ var __embind_register_float = (rawType, name, size) => {
1393
+ name = readLatin1String(name);
1394
+ registerType(rawType, {
1395
+ name,
1396
+ 'fromWireType': (value) => value,
1397
+ 'toWireType': (destructors, value) => {
1398
+ if (typeof value != "number" && typeof value != "boolean") {
1399
+ throw new TypeError(`Cannot convert ${embindRepr(value)} to ${this.name}`);
1400
+ }
1401
+ // The VM will perform JS to Wasm value conversion, according to the spec:
1402
+ // https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
1403
+ return value;
1404
+ },
1405
+ 'argPackAdvance': GenericWireTypeSize,
1406
+ 'readValueFromPointer': floatReadValueFromPointer(name, size),
1407
+ destructorFunction: null, // This type does not need a destructor
1408
+ });
1409
+ };
1410
+
1411
+ var createNamedFunction = (name, body) => Object.defineProperty(body, 'name', {
1412
+ value: name
1413
+ });
1414
+
1415
+ var runDestructors = (destructors) => {
1416
+ while (destructors.length) {
1417
+ var ptr = destructors.pop();
1418
+ var del = destructors.pop();
1419
+ del(ptr);
1420
+ }
1421
+ };
1422
+
1423
+
1424
+ function usesDestructorStack(argTypes) {
1425
+ // Skip return value at index 0 - it's not deleted here.
1426
+ for (var i = 1; i < argTypes.length; ++i) {
1427
+ // The type does not define a destructor function - must use dynamic stack
1428
+ if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) {
1429
+ return true;
1430
+ }
1431
+ }
1432
+ return false;
1433
+ }
1434
+
1435
+ function newFunc(constructor, argumentList) {
1436
+ if (!(constructor instanceof Function)) {
1437
+ throw new TypeError(`new_ called with constructor type ${typeof(constructor)} which is not a function`);
1438
+ }
1439
+ /*
1440
+ * Previously, the following line was just:
1441
+ * function dummy() {};
1442
+ * Unfortunately, Chrome was preserving 'dummy' as the object's name, even
1443
+ * though at creation, the 'dummy' has the correct constructor name. Thus,
1444
+ * objects created with IMVU.new would show up in the debugger as 'dummy',
1445
+ * which isn't very helpful. Using IMVU.createNamedFunction addresses the
1446
+ * issue. Doubly-unfortunately, there's no way to write a test for this
1447
+ * behavior. -NRD 2013.02.22
1448
+ */
1449
+ var dummy = createNamedFunction(constructor.name || 'unknownFunctionName', function(){});
1450
+ dummy.prototype = constructor.prototype;
1451
+ var obj = new dummy;
1452
+
1453
+ var r = constructor.apply(obj, argumentList);
1454
+ return (r instanceof Object) ? r : obj;
1455
+ }
1456
+
1457
+ function createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) {
1458
+ var needsDestructorStack = usesDestructorStack(argTypes);
1459
+ var argCount = argTypes.length;
1460
+ var argsList = "";
1461
+ var argsListWired = "";
1462
+ for (var i = 0; i < argCount - 2; ++i) {
1463
+ argsList += (i!==0?", ":"")+"arg"+i;
1464
+ argsListWired += (i!==0?", ":"")+"arg"+i+"Wired";
1465
+ }
1466
+
1467
+ var invokerFnBody = `
1468
+ return function (${argsList}) {
1469
+ if (arguments.length !== ${argCount - 2}) {
1470
+ throwBindingError('function ' + humanName + ' called with ' + arguments.length + ' arguments, expected ${argCount - 2}');
1471
+ }`;
1472
+
1473
+ if (needsDestructorStack) {
1474
+ invokerFnBody += "var destructors = [];\n";
1475
+ }
1476
+
1477
+ var dtorStack = needsDestructorStack ? "destructors" : "null";
1478
+ var args1 = ["humanName", "throwBindingError", "invoker", "fn", "runDestructors", "retType", "classParam"];
1479
+
1480
+ if (isClassMethodFunc) {
1481
+ invokerFnBody += "var thisWired = classParam['toWireType']("+dtorStack+", this);\n";
1482
+ }
1483
+
1484
+ for (var i = 0; i < argCount - 2; ++i) {
1485
+ invokerFnBody += "var arg"+i+"Wired = argType"+i+"['toWireType']("+dtorStack+", arg"+i+");\n";
1486
+ args1.push("argType"+i);
1487
+ }
1488
+
1489
+ if (isClassMethodFunc) {
1490
+ argsListWired = "thisWired" + (argsListWired.length > 0 ? ", " : "") + argsListWired;
1491
+ }
1492
+
1493
+ invokerFnBody +=
1494
+ (returns || isAsync ? "var rv = ":"") + "invoker(fn"+(argsListWired.length>0?", ":"")+argsListWired+");\n";
1495
+
1496
+ var returnVal = returns ? "rv" : "";
1497
+
1498
+ if (needsDestructorStack) {
1499
+ invokerFnBody += "runDestructors(destructors);\n";
1500
+ } else {
1501
+ for (var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
1502
+ var paramName = (i === 1 ? "thisWired" : ("arg"+(i - 2)+"Wired"));
1503
+ if (argTypes[i].destructorFunction !== null) {
1504
+ invokerFnBody += `${paramName}_dtor(${paramName});\n`;
1505
+ args1.push(`${paramName}_dtor`);
1506
+ }
1507
+ }
1508
+ }
1509
+
1510
+ if (returns) {
1511
+ invokerFnBody += "var ret = retType['fromWireType'](rv);\n" +
1512
+ "return ret;\n";
1513
+ } else {
1514
+ }
1515
+
1516
+ invokerFnBody += "}\n";
1517
+
1518
+ invokerFnBody = `if (arguments.length !== ${args1.length}){ throw new Error(humanName + "Expected ${args1.length} closure arguments " + arguments.length + " given."); }\n${invokerFnBody}`;
1519
+ return [args1, invokerFnBody];
1520
+ }
1521
+ function craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, /** boolean= */ isAsync) {
1522
+ // humanName: a human-readable string name for the function to be generated.
1523
+ // argTypes: An array that contains the embind type objects for all types in the function signature.
1524
+ // argTypes[0] is the type object for the function return value.
1525
+ // argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
1526
+ // argTypes[2...] are the actual function parameters.
1527
+ // classType: The embind type object for the class to be bound, or null if this is not a method of a class.
1528
+ // cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
1529
+ // cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
1530
+ // isAsync: Optional. If true, returns an async function. Async bindings are only supported with JSPI.
1531
+ var argCount = argTypes.length;
1532
+
1533
+ if (argCount < 2) {
1534
+ throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
1535
+ }
1536
+
1537
+ assert(!isAsync, 'Async bindings are only supported with JSPI.');
1538
+
1539
+ var isClassMethodFunc = (argTypes[1] !== null && classType !== null);
1540
+
1541
+ // Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
1542
+ // TODO: This omits argument count check - enable only at -O3 or similar.
1543
+ // if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
1544
+ // return FUNCTION_TABLE[fn];
1545
+ // }
1546
+
1547
+ // Determine if we need to use a dynamic stack to store the destructors for the function parameters.
1548
+ // TODO: Remove this completely once all function invokers are being dynamically generated.
1549
+ var needsDestructorStack = usesDestructorStack(argTypes);
1550
+
1551
+ var returns = (argTypes[0].name !== "void");
1552
+
1553
+ // Builld the arguments that will be passed into the closure around the invoker
1554
+ // function.
1555
+ var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, argTypes[0], argTypes[1]];
1556
+ for (var i = 0; i < argCount - 2; ++i) {
1557
+ closureArgs.push(argTypes[i+2]);
1558
+ }
1559
+ if (!needsDestructorStack) {
1560
+ for (var i = isClassMethodFunc?1:2; i < argTypes.length; ++i) { // Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
1561
+ if (argTypes[i].destructorFunction !== null) {
1562
+ closureArgs.push(argTypes[i].destructorFunction);
1563
+ }
1564
+ }
1565
+ }
1566
+
1567
+ let [args, invokerFnBody] = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync);
1568
+ args.push(invokerFnBody);
1569
+ var invokerFn = newFunc(Function, args)(...closureArgs);
1570
+ return createNamedFunction(humanName, invokerFn);
1571
+ }
1572
+
1573
+ var ensureOverloadTable = (proto, methodName, humanName) => {
1574
+ if (undefined === proto[methodName].overloadTable) {
1575
+ var prevFunc = proto[methodName];
1576
+ // Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
1577
+ proto[methodName] = function(...args) {
1578
+ // TODO This check can be removed in -O3 level "unsafe" optimizations.
1579
+ if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) {
1580
+ throwBindingError(`Function '${humanName}' called with an invalid number of arguments (${args.length}) - expects one of (${proto[methodName].overloadTable})!`);
1581
+ }
1582
+ return proto[methodName].overloadTable[args.length].apply(this, args);
1583
+ };
1584
+ // Move the previous function into the overload table.
1585
+ proto[methodName].overloadTable = [];
1586
+ proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
1587
+ }
1588
+ };
1589
+
1590
+ /** @param {number=} numArguments */
1591
+ var exposePublicSymbol = (name, value, numArguments) => {
1592
+ if (Module.hasOwnProperty(name)) {
1593
+ if (undefined === numArguments || (undefined !== Module[name].overloadTable && undefined !== Module[name].overloadTable[numArguments])) {
1594
+ throwBindingError(`Cannot register public name '${name}' twice`);
1595
+ }
1596
+
1597
+ // We are exposing a function with the same name as an existing function. Create an overload table and a function selector
1598
+ // that routes between the two.
1599
+ ensureOverloadTable(Module, name, name);
1600
+ if (Module.hasOwnProperty(numArguments)) {
1601
+ throwBindingError(`Cannot register multiple overloads of a function with the same number of arguments (${numArguments})!`);
1602
+ }
1603
+ // Add the new function into the overload table.
1604
+ Module[name].overloadTable[numArguments] = value;
1605
+ }
1606
+ else {
1607
+ Module[name] = value;
1608
+ if (undefined !== numArguments) {
1609
+ Module[name].numArguments = numArguments;
1610
+ }
1611
+ }
1612
+ };
1613
+
1614
+ var heap32VectorToArray = (count, firstElement) => {
1615
+ var array = [];
1616
+ for (var i = 0; i < count; i++) {
1617
+ // TODO(https://github.com/emscripten-core/emscripten/issues/17310):
1618
+ // Find a way to hoist the `>> 2` or `>> 3` out of this loop.
1619
+ array.push(HEAPU32[(((firstElement)+(i * 4))>>2)]);
1620
+ }
1621
+ return array;
1622
+ };
1623
+
1624
+
1625
+ /** @param {number=} numArguments */
1626
+ var replacePublicSymbol = (name, value, numArguments) => {
1627
+ if (!Module.hasOwnProperty(name)) {
1628
+ throwInternalError('Replacing nonexistent public symbol');
1629
+ }
1630
+ // If there's an overload table for this symbol, replace the symbol in the overload table instead.
1631
+ if (undefined !== Module[name].overloadTable && undefined !== numArguments) {
1632
+ Module[name].overloadTable[numArguments] = value;
1633
+ }
1634
+ else {
1635
+ Module[name] = value;
1636
+ Module[name].argCount = numArguments;
1637
+ }
1638
+ };
1639
+
1640
+
1641
+
1642
+ var dynCallLegacy = (sig, ptr, args) => {
1643
+ sig = sig.replace(/p/g, 'i')
1644
+ assert(('dynCall_' + sig) in Module, `bad function pointer type - dynCall function not found for sig '${sig}'`);
1645
+ if (args?.length) {
1646
+ // j (64-bit integer) must be passed in as two numbers [low 32, high 32].
1647
+ assert(args.length === sig.substring(1).replace(/j/g, '--').length);
1648
+ } else {
1649
+ assert(sig.length == 1);
1650
+ }
1651
+ var f = Module['dynCall_' + sig];
1652
+ return f(ptr, ...args);
1653
+ };
1654
+
1655
+ var wasmTableMirror = [];
1656
+
1657
+ /** @type {WebAssembly.Table} */
1658
+ var wasmTable;
1659
+ var getWasmTableEntry = (funcPtr) => {
1660
+ var func = wasmTableMirror[funcPtr];
1661
+ if (!func) {
1662
+ if (funcPtr >= wasmTableMirror.length) wasmTableMirror.length = funcPtr + 1;
1663
+ wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
1664
+ }
1665
+ assert(wasmTable.get(funcPtr) == func, 'JavaScript-side Wasm function table mirror is out of date!');
1666
+ return func;
1667
+ };
1668
+
1669
+ var dynCall = (sig, ptr, args = []) => {
1670
+ // Without WASM_BIGINT support we cannot directly call function with i64 as
1671
+ // part of their signature, so we rely on the dynCall functions generated by
1672
+ // wasm-emscripten-finalize
1673
+ if (sig.includes('j')) {
1674
+ return dynCallLegacy(sig, ptr, args);
1675
+ }
1676
+ assert(getWasmTableEntry(ptr), `missing table entry in dynCall: ${ptr}`);
1677
+ var rtn = getWasmTableEntry(ptr)(...args);
1678
+ return rtn;
1679
+ };
1680
+ var getDynCaller = (sig, ptr) => {
1681
+ assert(sig.includes('j') || sig.includes('p'), 'getDynCaller should only be called with i64 sigs')
1682
+ return (...args) => dynCall(sig, ptr, args);
1683
+ };
1684
+
1685
+
1686
+ var embind__requireFunction = (signature, rawFunction) => {
1687
+ signature = readLatin1String(signature);
1688
+
1689
+ function makeDynCaller() {
1690
+ if (signature.includes('j')) {
1691
+ return getDynCaller(signature, rawFunction);
1692
+ }
1693
+ return getWasmTableEntry(rawFunction);
1694
+ }
1695
+
1696
+ var fp = makeDynCaller();
1697
+ if (typeof fp != "function") {
1698
+ throwBindingError(`unknown function pointer with signature ${signature}: ${rawFunction}`);
1699
+ }
1700
+ return fp;
1701
+ };
1702
+
1703
+
1704
+
1705
+ var extendError = (baseErrorType, errorName) => {
1706
+ var errorClass = createNamedFunction(errorName, function(message) {
1707
+ this.name = errorName;
1708
+ this.message = message;
1709
+
1710
+ var stack = (new Error(message)).stack;
1711
+ if (stack !== undefined) {
1712
+ this.stack = this.toString() + '\n' +
1713
+ stack.replace(/^Error(:[^\n]*)?\n/, '');
1714
+ }
1715
+ });
1716
+ errorClass.prototype = Object.create(baseErrorType.prototype);
1717
+ errorClass.prototype.constructor = errorClass;
1718
+ errorClass.prototype.toString = function() {
1719
+ if (this.message === undefined) {
1720
+ return this.name;
1721
+ } else {
1722
+ return `${this.name}: ${this.message}`;
1723
+ }
1724
+ };
1725
+
1726
+ return errorClass;
1727
+ };
1728
+ var UnboundTypeError;
1729
+
1730
+
1731
+
1732
+ var getTypeName = (type) => {
1733
+ var ptr = ___getTypeName(type);
1734
+ var rv = readLatin1String(ptr);
1735
+ _free(ptr);
1736
+ return rv;
1737
+ };
1738
+ var throwUnboundTypeError = (message, types) => {
1739
+ var unboundTypes = [];
1740
+ var seen = {};
1741
+ function visit(type) {
1742
+ if (seen[type]) {
1743
+ return;
1744
+ }
1745
+ if (registeredTypes[type]) {
1746
+ return;
1747
+ }
1748
+ if (typeDependencies[type]) {
1749
+ typeDependencies[type].forEach(visit);
1750
+ return;
1751
+ }
1752
+ unboundTypes.push(type);
1753
+ seen[type] = true;
1754
+ }
1755
+ types.forEach(visit);
1756
+
1757
+ throw new UnboundTypeError(`${message}: ` + unboundTypes.map(getTypeName).join([', ']));
1758
+ };
1759
+
1760
+
1761
+ var getFunctionName = (signature) => {
1762
+ signature = signature.trim();
1763
+ const argsIndex = signature.indexOf("(");
1764
+ if (argsIndex !== -1) {
1765
+ assert(signature[signature.length - 1] == ")", "Parentheses for argument names should match.");
1766
+ return signature.substr(0, argsIndex);
1767
+ } else {
1768
+ return signature;
1769
+ }
1770
+ };
1771
+ var __embind_register_function = (name, argCount, rawArgTypesAddr, signature, rawInvoker, fn, isAsync) => {
1772
+ var argTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
1773
+ name = readLatin1String(name);
1774
+ name = getFunctionName(name);
1775
+
1776
+ rawInvoker = embind__requireFunction(signature, rawInvoker);
1777
+
1778
+ exposePublicSymbol(name, function() {
1779
+ throwUnboundTypeError(`Cannot call ${name} due to unbound types`, argTypes);
1780
+ }, argCount - 1);
1781
+
1782
+ whenDependentTypesAreResolved([], argTypes, (argTypes) => {
1783
+ var invokerArgsArray = [argTypes[0] /* return value */, null /* no class 'this'*/].concat(argTypes.slice(1) /* actual params */);
1784
+ replacePublicSymbol(name, craftInvokerFunction(name, invokerArgsArray, null /* no class 'this'*/, rawInvoker, fn, isAsync), argCount - 1);
1785
+ return [];
1786
+ });
1787
+ };
1788
+
1789
+
1790
+ var integerReadValueFromPointer = (name, width, signed) => {
1791
+ // integers are quite common, so generate very specialized functions
1792
+ switch (width) {
1793
+ case 1: return signed ?
1794
+ (pointer) => HEAP8[pointer] :
1795
+ (pointer) => HEAPU8[pointer];
1796
+ case 2: return signed ?
1797
+ (pointer) => HEAP16[((pointer)>>1)] :
1798
+ (pointer) => HEAPU16[((pointer)>>1)]
1799
+ case 4: return signed ?
1800
+ (pointer) => HEAP32[((pointer)>>2)] :
1801
+ (pointer) => HEAPU32[((pointer)>>2)]
1802
+ default:
1803
+ throw new TypeError(`invalid integer width (${width}): ${name}`);
1804
+ }
1805
+ };
1806
+
1807
+
1808
+ /** @suppress {globalThis} */
1809
+ var __embind_register_integer = (primitiveType, name, size, minRange, maxRange) => {
1810
+ name = readLatin1String(name);
1811
+ // LLVM doesn't have signed and unsigned 32-bit types, so u32 literals come
1812
+ // out as 'i32 -1'. Always treat those as max u32.
1813
+ if (maxRange === -1) {
1814
+ maxRange = 4294967295;
1815
+ }
1816
+
1817
+ var fromWireType = (value) => value;
1818
+
1819
+ if (minRange === 0) {
1820
+ var bitshift = 32 - 8*size;
1821
+ fromWireType = (value) => (value << bitshift) >>> bitshift;
1822
+ }
1823
+
1824
+ var isUnsignedType = (name.includes('unsigned'));
1825
+ var checkAssertions = (value, toTypeName) => {
1826
+ if (typeof value != "number" && typeof value != "boolean") {
1827
+ throw new TypeError(`Cannot convert "${embindRepr(value)}" to ${toTypeName}`);
1828
+ }
1829
+ if (value < minRange || value > maxRange) {
1830
+ throw new TypeError(`Passing a number "${embindRepr(value)}" from JS side to C/C++ side to an argument of type "${name}", which is outside the valid range [${minRange}, ${maxRange}]!`);
1831
+ }
1832
+ }
1833
+ var toWireType;
1834
+ if (isUnsignedType) {
1835
+ toWireType = function(destructors, value) {
1836
+ checkAssertions(value, this.name);
1837
+ return value >>> 0;
1838
+ }
1839
+ } else {
1840
+ toWireType = function(destructors, value) {
1841
+ checkAssertions(value, this.name);
1842
+ // The VM will perform JS to Wasm value conversion, according to the spec:
1843
+ // https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
1844
+ return value;
1845
+ }
1846
+ }
1847
+ registerType(primitiveType, {
1848
+ name,
1849
+ 'fromWireType': fromWireType,
1850
+ 'toWireType': toWireType,
1851
+ 'argPackAdvance': GenericWireTypeSize,
1852
+ 'readValueFromPointer': integerReadValueFromPointer(name, size, minRange !== 0),
1853
+ destructorFunction: null, // This type does not need a destructor
1854
+ });
1855
+ };
1856
+
1857
+
1858
+ var __embind_register_memory_view = (rawType, dataTypeIndex, name) => {
1859
+ var typeMapping = [
1860
+ Int8Array,
1861
+ Uint8Array,
1862
+ Int16Array,
1863
+ Uint16Array,
1864
+ Int32Array,
1865
+ Uint32Array,
1866
+ Float32Array,
1867
+ Float64Array,
1868
+ ];
1869
+
1870
+ var TA = typeMapping[dataTypeIndex];
1871
+
1872
+ function decodeMemoryView(handle) {
1873
+ var size = HEAPU32[((handle)>>2)];
1874
+ var data = HEAPU32[(((handle)+(4))>>2)];
1875
+ return new TA(HEAP8.buffer, data, size);
1876
+ }
1877
+
1878
+ name = readLatin1String(name);
1879
+ registerType(rawType, {
1880
+ name,
1881
+ 'fromWireType': decodeMemoryView,
1882
+ 'argPackAdvance': GenericWireTypeSize,
1883
+ 'readValueFromPointer': decodeMemoryView,
1884
+ }, {
1885
+ ignoreDuplicateRegistrations: true,
1886
+ });
1887
+ };
1888
+
1889
+
1890
+
1891
+
1892
+
1893
+ var stringToUTF8Array = (str, heap, outIdx, maxBytesToWrite) => {
1894
+ assert(typeof str === 'string', `stringToUTF8Array expects a string (got ${typeof str})`);
1895
+ // Parameter maxBytesToWrite is not optional. Negative values, 0, null,
1896
+ // undefined and false each don't write out any bytes.
1897
+ if (!(maxBytesToWrite > 0))
1898
+ return 0;
1899
+
1900
+ var startIdx = outIdx;
1901
+ var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
1902
+ for (var i = 0; i < str.length; ++i) {
1903
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
1904
+ // unit, not a Unicode code point of the character! So decode
1905
+ // UTF16->UTF32->UTF8.
1906
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
1907
+ // For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
1908
+ // and https://www.ietf.org/rfc/rfc2279.txt
1909
+ // and https://tools.ietf.org/html/rfc3629
1910
+ var u = str.charCodeAt(i); // possibly a lead surrogate
1911
+ if (u >= 0xD800 && u <= 0xDFFF) {
1912
+ var u1 = str.charCodeAt(++i);
1913
+ u = 0x10000 + ((u & 0x3FF) << 10) | (u1 & 0x3FF);
1914
+ }
1915
+ if (u <= 0x7F) {
1916
+ if (outIdx >= endIdx) break;
1917
+ heap[outIdx++] = u;
1918
+ } else if (u <= 0x7FF) {
1919
+ if (outIdx + 1 >= endIdx) break;
1920
+ heap[outIdx++] = 0xC0 | (u >> 6);
1921
+ heap[outIdx++] = 0x80 | (u & 63);
1922
+ } else if (u <= 0xFFFF) {
1923
+ if (outIdx + 2 >= endIdx) break;
1924
+ heap[outIdx++] = 0xE0 | (u >> 12);
1925
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
1926
+ heap[outIdx++] = 0x80 | (u & 63);
1927
+ } else {
1928
+ if (outIdx + 3 >= endIdx) break;
1929
+ if (u > 0x10FFFF) warnOnce('Invalid Unicode code point ' + ptrToString(u) + ' encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).');
1930
+ heap[outIdx++] = 0xF0 | (u >> 18);
1931
+ heap[outIdx++] = 0x80 | ((u >> 12) & 63);
1932
+ heap[outIdx++] = 0x80 | ((u >> 6) & 63);
1933
+ heap[outIdx++] = 0x80 | (u & 63);
1934
+ }
1935
+ }
1936
+ // Null-terminate the pointer to the buffer.
1937
+ heap[outIdx] = 0;
1938
+ return outIdx - startIdx;
1939
+ };
1940
+ var stringToUTF8 = (str, outPtr, maxBytesToWrite) => {
1941
+ assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
1942
+ return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
1943
+ };
1944
+
1945
+ var lengthBytesUTF8 = (str) => {
1946
+ var len = 0;
1947
+ for (var i = 0; i < str.length; ++i) {
1948
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
1949
+ // unit, not a Unicode code point of the character! So decode
1950
+ // UTF16->UTF32->UTF8.
1951
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
1952
+ var c = str.charCodeAt(i); // possibly a lead surrogate
1953
+ if (c <= 0x7F) {
1954
+ len++;
1955
+ } else if (c <= 0x7FF) {
1956
+ len += 2;
1957
+ } else if (c >= 0xD800 && c <= 0xDFFF) {
1958
+ len += 4; ++i;
1959
+ } else {
1960
+ len += 3;
1961
+ }
1962
+ }
1963
+ return len;
1964
+ };
1965
+
1966
+
1967
+
1968
+ var __embind_register_std_string = (rawType, name) => {
1969
+ name = readLatin1String(name);
1970
+ var stdStringIsUTF8
1971
+ //process only std::string bindings with UTF8 support, in contrast to e.g. std::basic_string<unsigned char>
1972
+ = (name === "std::string");
1973
+
1974
+ registerType(rawType, {
1975
+ name,
1976
+ // For some method names we use string keys here since they are part of
1977
+ // the public/external API and/or used by the runtime-generated code.
1978
+ 'fromWireType'(value) {
1979
+ var length = HEAPU32[((value)>>2)];
1980
+ var payload = value + 4;
1981
+
1982
+ var str;
1983
+ if (stdStringIsUTF8) {
1984
+ var decodeStartPtr = payload;
1985
+ // Looping here to support possible embedded '0' bytes
1986
+ for (var i = 0; i <= length; ++i) {
1987
+ var currentBytePtr = payload + i;
1988
+ if (i == length || HEAPU8[currentBytePtr] == 0) {
1989
+ var maxRead = currentBytePtr - decodeStartPtr;
1990
+ var stringSegment = UTF8ToString(decodeStartPtr, maxRead);
1991
+ if (str === undefined) {
1992
+ str = stringSegment;
1993
+ } else {
1994
+ str += String.fromCharCode(0);
1995
+ str += stringSegment;
1996
+ }
1997
+ decodeStartPtr = currentBytePtr + 1;
1998
+ }
1999
+ }
2000
+ } else {
2001
+ var a = new Array(length);
2002
+ for (var i = 0; i < length; ++i) {
2003
+ a[i] = String.fromCharCode(HEAPU8[payload + i]);
2004
+ }
2005
+ str = a.join('');
2006
+ }
2007
+
2008
+ _free(value);
2009
+
2010
+ return str;
2011
+ },
2012
+ 'toWireType'(destructors, value) {
2013
+ if (value instanceof ArrayBuffer) {
2014
+ value = new Uint8Array(value);
2015
+ }
2016
+
2017
+ var length;
2018
+ var valueIsOfTypeString = (typeof value == 'string');
2019
+
2020
+ if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
2021
+ throwBindingError('Cannot pass non-string to std::string');
2022
+ }
2023
+ if (stdStringIsUTF8 && valueIsOfTypeString) {
2024
+ length = lengthBytesUTF8(value);
2025
+ } else {
2026
+ length = value.length;
2027
+ }
2028
+
2029
+ // assumes POINTER_SIZE alignment
2030
+ var base = _malloc(4 + length + 1);
2031
+ var ptr = base + 4;
2032
+ HEAPU32[((base)>>2)] = length;
2033
+ if (stdStringIsUTF8 && valueIsOfTypeString) {
2034
+ stringToUTF8(value, ptr, length + 1);
2035
+ } else {
2036
+ if (valueIsOfTypeString) {
2037
+ for (var i = 0; i < length; ++i) {
2038
+ var charCode = value.charCodeAt(i);
2039
+ if (charCode > 255) {
2040
+ _free(ptr);
2041
+ throwBindingError('String has UTF-16 code units that do not fit in 8 bits');
2042
+ }
2043
+ HEAPU8[ptr + i] = charCode;
2044
+ }
2045
+ } else {
2046
+ for (var i = 0; i < length; ++i) {
2047
+ HEAPU8[ptr + i] = value[i];
2048
+ }
2049
+ }
2050
+ }
2051
+
2052
+ if (destructors !== null) {
2053
+ destructors.push(_free, base);
2054
+ }
2055
+ return base;
2056
+ },
2057
+ 'argPackAdvance': GenericWireTypeSize,
2058
+ 'readValueFromPointer': readPointer,
2059
+ destructorFunction(ptr) {
2060
+ _free(ptr);
2061
+ },
2062
+ });
2063
+ };
2064
+
2065
+
2066
+
2067
+
2068
+ var UTF16Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf-16le') : undefined;;
2069
+ var UTF16ToString = (ptr, maxBytesToRead) => {
2070
+ assert(ptr % 2 == 0, 'Pointer passed to UTF16ToString must be aligned to two bytes!');
2071
+ var endPtr = ptr;
2072
+ // TextDecoder needs to know the byte length in advance, it doesn't stop on
2073
+ // null terminator by itself.
2074
+ // Also, use the length info to avoid running tiny strings through
2075
+ // TextDecoder, since .subarray() allocates garbage.
2076
+ var idx = endPtr >> 1;
2077
+ var maxIdx = idx + maxBytesToRead / 2;
2078
+ // If maxBytesToRead is not passed explicitly, it will be undefined, and this
2079
+ // will always evaluate to true. This saves on code size.
2080
+ while (!(idx >= maxIdx) && HEAPU16[idx]) ++idx;
2081
+ endPtr = idx << 1;
2082
+
2083
+ if (endPtr - ptr > 32 && UTF16Decoder)
2084
+ return UTF16Decoder.decode(HEAPU8.subarray(ptr, endPtr));
2085
+
2086
+ // Fallback: decode without UTF16Decoder
2087
+ var str = '';
2088
+
2089
+ // If maxBytesToRead is not passed explicitly, it will be undefined, and the
2090
+ // for-loop's condition will always evaluate to true. The loop is then
2091
+ // terminated on the first null char.
2092
+ for (var i = 0; !(i >= maxBytesToRead / 2); ++i) {
2093
+ var codeUnit = HEAP16[(((ptr)+(i*2))>>1)];
2094
+ if (codeUnit == 0) break;
2095
+ // fromCharCode constructs a character from a UTF-16 code unit, so we can
2096
+ // pass the UTF16 string right through.
2097
+ str += String.fromCharCode(codeUnit);
2098
+ }
2099
+
2100
+ return str;
2101
+ };
2102
+
2103
+ var stringToUTF16 = (str, outPtr, maxBytesToWrite) => {
2104
+ assert(outPtr % 2 == 0, 'Pointer passed to stringToUTF16 must be aligned to two bytes!');
2105
+ assert(typeof maxBytesToWrite == 'number', 'stringToUTF16(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
2106
+ // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
2107
+ maxBytesToWrite ??= 0x7FFFFFFF;
2108
+ if (maxBytesToWrite < 2) return 0;
2109
+ maxBytesToWrite -= 2; // Null terminator.
2110
+ var startPtr = outPtr;
2111
+ var numCharsToWrite = (maxBytesToWrite < str.length*2) ? (maxBytesToWrite / 2) : str.length;
2112
+ for (var i = 0; i < numCharsToWrite; ++i) {
2113
+ // charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
2114
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
2115
+ HEAP16[((outPtr)>>1)] = codeUnit;
2116
+ outPtr += 2;
2117
+ }
2118
+ // Null-terminate the pointer to the HEAP.
2119
+ HEAP16[((outPtr)>>1)] = 0;
2120
+ return outPtr - startPtr;
2121
+ };
2122
+
2123
+ var lengthBytesUTF16 = (str) => {
2124
+ return str.length*2;
2125
+ };
2126
+
2127
+ var UTF32ToString = (ptr, maxBytesToRead) => {
2128
+ assert(ptr % 4 == 0, 'Pointer passed to UTF32ToString must be aligned to four bytes!');
2129
+ var i = 0;
2130
+
2131
+ var str = '';
2132
+ // If maxBytesToRead is not passed explicitly, it will be undefined, and this
2133
+ // will always evaluate to true. This saves on code size.
2134
+ while (!(i >= maxBytesToRead / 4)) {
2135
+ var utf32 = HEAP32[(((ptr)+(i*4))>>2)];
2136
+ if (utf32 == 0) break;
2137
+ ++i;
2138
+ // Gotcha: fromCharCode constructs a character from a UTF-16 encoded code (pair), not from a Unicode code point! So encode the code point to UTF-16 for constructing.
2139
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
2140
+ if (utf32 >= 0x10000) {
2141
+ var ch = utf32 - 0x10000;
2142
+ str += String.fromCharCode(0xD800 | (ch >> 10), 0xDC00 | (ch & 0x3FF));
2143
+ } else {
2144
+ str += String.fromCharCode(utf32);
2145
+ }
2146
+ }
2147
+ return str;
2148
+ };
2149
+
2150
+ var stringToUTF32 = (str, outPtr, maxBytesToWrite) => {
2151
+ assert(outPtr % 4 == 0, 'Pointer passed to stringToUTF32 must be aligned to four bytes!');
2152
+ assert(typeof maxBytesToWrite == 'number', 'stringToUTF32(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!');
2153
+ // Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
2154
+ maxBytesToWrite ??= 0x7FFFFFFF;
2155
+ if (maxBytesToWrite < 4) return 0;
2156
+ var startPtr = outPtr;
2157
+ var endPtr = startPtr + maxBytesToWrite - 4;
2158
+ for (var i = 0; i < str.length; ++i) {
2159
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
2160
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
2161
+ var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
2162
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) {
2163
+ var trailSurrogate = str.charCodeAt(++i);
2164
+ codeUnit = 0x10000 + ((codeUnit & 0x3FF) << 10) | (trailSurrogate & 0x3FF);
2165
+ }
2166
+ HEAP32[((outPtr)>>2)] = codeUnit;
2167
+ outPtr += 4;
2168
+ if (outPtr + 4 > endPtr) break;
2169
+ }
2170
+ // Null-terminate the pointer to the HEAP.
2171
+ HEAP32[((outPtr)>>2)] = 0;
2172
+ return outPtr - startPtr;
2173
+ };
2174
+
2175
+ var lengthBytesUTF32 = (str) => {
2176
+ var len = 0;
2177
+ for (var i = 0; i < str.length; ++i) {
2178
+ // Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code unit, not a Unicode code point of the character! We must decode the string to UTF-32 to the heap.
2179
+ // See http://unicode.org/faq/utf_bom.html#utf16-3
2180
+ var codeUnit = str.charCodeAt(i);
2181
+ if (codeUnit >= 0xD800 && codeUnit <= 0xDFFF) ++i; // possibly a lead surrogate, so skip over the tail surrogate.
2182
+ len += 4;
2183
+ }
2184
+
2185
+ return len;
2186
+ };
2187
+ var __embind_register_std_wstring = (rawType, charSize, name) => {
2188
+ name = readLatin1String(name);
2189
+ var decodeString, encodeString, readCharAt, lengthBytesUTF;
2190
+ if (charSize === 2) {
2191
+ decodeString = UTF16ToString;
2192
+ encodeString = stringToUTF16;
2193
+ lengthBytesUTF = lengthBytesUTF16;
2194
+ readCharAt = (pointer) => HEAPU16[((pointer)>>1)];
2195
+ } else if (charSize === 4) {
2196
+ decodeString = UTF32ToString;
2197
+ encodeString = stringToUTF32;
2198
+ lengthBytesUTF = lengthBytesUTF32;
2199
+ readCharAt = (pointer) => HEAPU32[((pointer)>>2)];
2200
+ }
2201
+ registerType(rawType, {
2202
+ name,
2203
+ 'fromWireType': (value) => {
2204
+ // Code mostly taken from _embind_register_std_string fromWireType
2205
+ var length = HEAPU32[((value)>>2)];
2206
+ var str;
2207
+
2208
+ var decodeStartPtr = value + 4;
2209
+ // Looping here to support possible embedded '0' bytes
2210
+ for (var i = 0; i <= length; ++i) {
2211
+ var currentBytePtr = value + 4 + i * charSize;
2212
+ if (i == length || readCharAt(currentBytePtr) == 0) {
2213
+ var maxReadBytes = currentBytePtr - decodeStartPtr;
2214
+ var stringSegment = decodeString(decodeStartPtr, maxReadBytes);
2215
+ if (str === undefined) {
2216
+ str = stringSegment;
2217
+ } else {
2218
+ str += String.fromCharCode(0);
2219
+ str += stringSegment;
2220
+ }
2221
+ decodeStartPtr = currentBytePtr + charSize;
2222
+ }
2223
+ }
2224
+
2225
+ _free(value);
2226
+
2227
+ return str;
2228
+ },
2229
+ 'toWireType': (destructors, value) => {
2230
+ if (!(typeof value == 'string')) {
2231
+ throwBindingError(`Cannot pass non-string to C++ string type ${name}`);
2232
+ }
2233
+
2234
+ // assumes POINTER_SIZE alignment
2235
+ var length = lengthBytesUTF(value);
2236
+ var ptr = _malloc(4 + length + charSize);
2237
+ HEAPU32[((ptr)>>2)] = length / charSize;
2238
+
2239
+ encodeString(value, ptr + 4, length + charSize);
2240
+
2241
+ if (destructors !== null) {
2242
+ destructors.push(_free, ptr);
2243
+ }
2244
+ return ptr;
2245
+ },
2246
+ 'argPackAdvance': GenericWireTypeSize,
2247
+ 'readValueFromPointer': readPointer,
2248
+ destructorFunction(ptr) {
2249
+ _free(ptr);
2250
+ }
2251
+ });
2252
+ };
2253
+
2254
+
2255
+ var __embind_register_void = (rawType, name) => {
2256
+ name = readLatin1String(name);
2257
+ registerType(rawType, {
2258
+ isVoid: true, // void return values can be optimized out sometimes
2259
+ name,
2260
+ 'argPackAdvance': 0,
2261
+ 'fromWireType': () => undefined,
2262
+ // TODO: assert if anything else is given?
2263
+ 'toWireType': (destructors, o) => undefined,
2264
+ });
2265
+ };
2266
+
2267
+ var __emscripten_memcpy_js = (dest, src, num) => HEAPU8.copyWithin(dest, src, src + num);
2268
+
2269
+
2270
+ var __emval_new_array = () => Emval.toHandle([]);
2271
+
2272
+ var emval_symbols = {
2273
+ };
2274
+
2275
+ var getStringOrSymbol = (address) => {
2276
+ var symbol = emval_symbols[address];
2277
+ if (symbol === undefined) {
2278
+ return readLatin1String(address);
2279
+ }
2280
+ return symbol;
2281
+ };
2282
+
2283
+ var __emval_new_cstring = (v) => Emval.toHandle(getStringOrSymbol(v));
2284
+
2285
+ var __emval_new_object = () => Emval.toHandle({});
2286
+
2287
+ var __emval_set_property = (handle, key, value) => {
2288
+ handle = Emval.toValue(handle);
2289
+ key = Emval.toValue(key);
2290
+ value = Emval.toValue(value);
2291
+ handle[key] = value;
2292
+ };
2293
+
2294
+
2295
+
2296
+
2297
+ var requireRegisteredType = (rawType, humanName) => {
2298
+ var impl = registeredTypes[rawType];
2299
+ if (undefined === impl) {
2300
+ throwBindingError(`${humanName} has unknown type ${getTypeName(rawType)}`);
2301
+ }
2302
+ return impl;
2303
+ };
2304
+ var __emval_take_value = (type, arg) => {
2305
+ type = requireRegisteredType(type, '_emval_take_value');
2306
+ var v = type['readValueFromPointer'](arg);
2307
+ return Emval.toHandle(v);
2308
+ };
2309
+
2310
+
2311
+ var __tzset_js = (timezone, daylight, std_name, dst_name) => {
2312
+ // TODO: Use (malleable) environment variables instead of system settings.
2313
+ var currentYear = new Date().getFullYear();
2314
+ var winter = new Date(currentYear, 0, 1);
2315
+ var summer = new Date(currentYear, 6, 1);
2316
+ var winterOffset = winter.getTimezoneOffset();
2317
+ var summerOffset = summer.getTimezoneOffset();
2318
+
2319
+ // Local standard timezone offset. Local standard time is not adjusted for
2320
+ // daylight savings. This code uses the fact that getTimezoneOffset returns
2321
+ // a greater value during Standard Time versus Daylight Saving Time (DST).
2322
+ // Thus it determines the expected output during Standard Time, and it
2323
+ // compares whether the output of the given date the same (Standard) or less
2324
+ // (DST).
2325
+ var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
2326
+
2327
+ // timezone is specified as seconds west of UTC ("The external variable
2328
+ // `timezone` shall be set to the difference, in seconds, between
2329
+ // Coordinated Universal Time (UTC) and local standard time."), the same
2330
+ // as returned by stdTimezoneOffset.
2331
+ // See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
2332
+ HEAPU32[((timezone)>>2)] = stdTimezoneOffset * 60;
2333
+
2334
+ HEAP32[((daylight)>>2)] = Number(winterOffset != summerOffset);
2335
+
2336
+ var extractZone = (timezoneOffset) => {
2337
+ // Why inverse sign?
2338
+ // Read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
2339
+ var sign = timezoneOffset >= 0 ? "-" : "+";
2340
+
2341
+ var absOffset = Math.abs(timezoneOffset)
2342
+ var hours = String(Math.floor(absOffset / 60)).padStart(2, "0");
2343
+ var minutes = String(absOffset % 60).padStart(2, "0");
2344
+
2345
+ return `UTC${sign}${hours}${minutes}`;
2346
+ }
2347
+
2348
+ var winterName = extractZone(winterOffset);
2349
+ var summerName = extractZone(summerOffset);
2350
+ assert(winterName);
2351
+ assert(summerName);
2352
+ assert(lengthBytesUTF8(winterName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${winterName})`);
2353
+ assert(lengthBytesUTF8(summerName) <= 16, `timezone name truncated to fit in TZNAME_MAX (${summerName})`);
2354
+ if (summerOffset < winterOffset) {
2355
+ // Northern hemisphere
2356
+ stringToUTF8(winterName, std_name, 17);
2357
+ stringToUTF8(summerName, dst_name, 17);
2358
+ } else {
2359
+ stringToUTF8(winterName, dst_name, 17);
2360
+ stringToUTF8(summerName, std_name, 17);
2361
+ }
2362
+ };
2363
+
2364
+ var getHeapMax = () =>
2365
+ // Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
2366
+ // full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
2367
+ // for any code that deals with heap sizes, which would require special
2368
+ // casing all heap size related code to treat 0 specially.
2369
+ 2147483648;
2370
+
2371
+ var growMemory = (size) => {
2372
+ var b = wasmMemory.buffer;
2373
+ var pages = (size - b.byteLength + 65535) / 65536;
2374
+ try {
2375
+ // round size grow request up to wasm page size (fixed 64KB per spec)
2376
+ wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size
2377
+ updateMemoryViews();
2378
+ return 1 /*success*/;
2379
+ } catch(e) {
2380
+ err(`growMemory: Attempted to grow heap from ${b.byteLength} bytes to ${size} bytes, but got error: ${e}`);
2381
+ }
2382
+ // implicit 0 return to save code size (caller will cast "undefined" into 0
2383
+ // anyhow)
2384
+ };
2385
+ var _emscripten_resize_heap = (requestedSize) => {
2386
+ var oldSize = HEAPU8.length;
2387
+ // With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
2388
+ requestedSize >>>= 0;
2389
+ // With multithreaded builds, races can happen (another thread might increase the size
2390
+ // in between), so return a failure, and let the caller retry.
2391
+ assert(requestedSize > oldSize);
2392
+
2393
+ // Memory resize rules:
2394
+ // 1. Always increase heap size to at least the requested size, rounded up
2395
+ // to next page multiple.
2396
+ // 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap
2397
+ // geometrically: increase the heap size according to
2398
+ // MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most
2399
+ // overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
2400
+ // 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap
2401
+ // linearly: increase the heap size by at least
2402
+ // MEMORY_GROWTH_LINEAR_STEP bytes.
2403
+ // 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by
2404
+ // MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
2405
+ // 4. If we were unable to allocate as much memory, it may be due to
2406
+ // over-eager decision to excessively reserve due to (3) above.
2407
+ // Hence if an allocation fails, cut down on the amount of excess
2408
+ // growth, in an attempt to succeed to perform a smaller allocation.
2409
+
2410
+ // A limit is set for how much we can grow. We should not exceed that
2411
+ // (the wasm binary specifies it, so if we tried, we'd fail anyhow).
2412
+ var maxHeapSize = getHeapMax();
2413
+ if (requestedSize > maxHeapSize) {
2414
+ err(`Cannot enlarge memory, requested ${requestedSize} bytes, but the limit is ${maxHeapSize} bytes!`);
2415
+ return false;
2416
+ }
2417
+
2418
+ var alignUp = (x, multiple) => x + (multiple - x % multiple) % multiple;
2419
+
2420
+ // Loop through potential heap size increases. If we attempt a too eager
2421
+ // reservation that fails, cut down on the attempted size and reserve a
2422
+ // smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
2423
+ for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
2424
+ var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth
2425
+ // but limit overreserving (default to capping at +96MB overgrowth at most)
2426
+ overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296 );
2427
+
2428
+ var newSize = Math.min(maxHeapSize, alignUp(Math.max(requestedSize, overGrownHeapSize), 65536));
2429
+
2430
+ var replacement = growMemory(newSize);
2431
+ if (replacement) {
2432
+
2433
+ return true;
2434
+ }
2435
+ }
2436
+ err(`Failed to grow the heap from ${oldSize} bytes to ${newSize} bytes, not enough memory!`);
2437
+ return false;
2438
+ };
2439
+
2440
+ var ENV = {
2441
+ };
2442
+
2443
+ var getExecutableName = () => {
2444
+ return thisProgram || './this.program';
2445
+ };
2446
+ var getEnvStrings = () => {
2447
+ if (!getEnvStrings.strings) {
2448
+ // Default values.
2449
+ // Browser language detection #8751
2450
+ var lang = ((typeof navigator == 'object' && navigator.languages && navigator.languages[0]) || 'C').replace('-', '_') + '.UTF-8';
2451
+ var env = {
2452
+ 'USER': 'web_user',
2453
+ 'LOGNAME': 'web_user',
2454
+ 'PATH': '/',
2455
+ 'PWD': '/',
2456
+ 'HOME': '/home/web_user',
2457
+ 'LANG': lang,
2458
+ '_': getExecutableName()
2459
+ };
2460
+ // Apply the user-provided values, if any.
2461
+ for (var x in ENV) {
2462
+ // x is a key in ENV; if ENV[x] is undefined, that means it was
2463
+ // explicitly set to be so. We allow user code to do that to
2464
+ // force variables with default values to remain unset.
2465
+ if (ENV[x] === undefined) delete env[x];
2466
+ else env[x] = ENV[x];
2467
+ }
2468
+ var strings = [];
2469
+ for (var x in env) {
2470
+ strings.push(`${x}=${env[x]}`);
2471
+ }
2472
+ getEnvStrings.strings = strings;
2473
+ }
2474
+ return getEnvStrings.strings;
2475
+ };
2476
+
2477
+ var stringToAscii = (str, buffer) => {
2478
+ for (var i = 0; i < str.length; ++i) {
2479
+ assert(str.charCodeAt(i) === (str.charCodeAt(i) & 0xff));
2480
+ HEAP8[buffer++] = str.charCodeAt(i);
2481
+ }
2482
+ // Null-terminate the string
2483
+ HEAP8[buffer] = 0;
2484
+ };
2485
+ var _environ_get = (__environ, environ_buf) => {
2486
+ var bufSize = 0;
2487
+ getEnvStrings().forEach((string, i) => {
2488
+ var ptr = environ_buf + bufSize;
2489
+ HEAPU32[(((__environ)+(i*4))>>2)] = ptr;
2490
+ stringToAscii(string, ptr);
2491
+ bufSize += string.length + 1;
2492
+ });
2493
+ return 0;
2494
+ };
2495
+
2496
+ var _environ_sizes_get = (penviron_count, penviron_buf_size) => {
2497
+ var strings = getEnvStrings();
2498
+ HEAPU32[((penviron_count)>>2)] = strings.length;
2499
+ var bufSize = 0;
2500
+ strings.forEach((string) => bufSize += string.length + 1);
2501
+ HEAPU32[((penviron_buf_size)>>2)] = bufSize;
2502
+ return 0;
2503
+ };
2504
+
2505
+ var SYSCALLS = {
2506
+ varargs:undefined,
2507
+ getStr(ptr) {
2508
+ var ret = UTF8ToString(ptr);
2509
+ return ret;
2510
+ },
2511
+ };
2512
+ var _fd_close = (fd) => {
2513
+ abort('fd_close called without SYSCALLS_REQUIRE_FILESYSTEM');
2514
+ };
2515
+
2516
+ var convertI32PairToI53Checked = (lo, hi) => {
2517
+ assert(lo == (lo >>> 0) || lo == (lo|0)); // lo should either be a i32 or a u32
2518
+ assert(hi === (hi|0)); // hi should be a i32
2519
+ return ((hi + 0x200000) >>> 0 < 0x400001 - !!lo) ? (lo >>> 0) + hi * 4294967296 : NaN;
2520
+ };
2521
+ function _fd_seek(fd,offset_low, offset_high,whence,newOffset) {
2522
+ var offset = convertI32PairToI53Checked(offset_low, offset_high);
2523
+
2524
+
2525
+ return 70;
2526
+ ;
2527
+ }
2528
+
2529
+ var printCharBuffers = [null,[],[]];
2530
+
2531
+ var printChar = (stream, curr) => {
2532
+ var buffer = printCharBuffers[stream];
2533
+ assert(buffer);
2534
+ if (curr === 0 || curr === 10) {
2535
+ (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0));
2536
+ buffer.length = 0;
2537
+ } else {
2538
+ buffer.push(curr);
2539
+ }
2540
+ };
2541
+
2542
+ var flush_NO_FILESYSTEM = () => {
2543
+ // flush anything remaining in the buffers during shutdown
2544
+ _fflush(0);
2545
+ if (printCharBuffers[1].length) printChar(1, 10);
2546
+ if (printCharBuffers[2].length) printChar(2, 10);
2547
+ };
2548
+
2549
+
2550
+ var _fd_write = (fd, iov, iovcnt, pnum) => {
2551
+ // hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
2552
+ var num = 0;
2553
+ for (var i = 0; i < iovcnt; i++) {
2554
+ var ptr = HEAPU32[((iov)>>2)];
2555
+ var len = HEAPU32[(((iov)+(4))>>2)];
2556
+ iov += 8;
2557
+ for (var j = 0; j < len; j++) {
2558
+ printChar(fd, HEAPU8[ptr+j]);
2559
+ }
2560
+ num += len;
2561
+ }
2562
+ HEAPU32[((pnum)>>2)] = num;
2563
+ return 0;
2564
+ };
2565
+ embind_init_charCodes();
2566
+ BindingError = Module['BindingError'] = class BindingError extends Error { constructor(message) { super(message); this.name = 'BindingError'; }};
2567
+ InternalError = Module['InternalError'] = class InternalError extends Error { constructor(message) { super(message); this.name = 'InternalError'; }};
2568
+ init_emval();;
2569
+ UnboundTypeError = Module['UnboundTypeError'] = extendError(Error, 'UnboundTypeError');;
2570
+ function checkIncomingModuleAPI() {
2571
+ ignoredModuleProp('fetchSettings');
2572
+ }
2573
+ var wasmImports = {
2574
+ /** @export */
2575
+ __assert_fail: ___assert_fail,
2576
+ /** @export */
2577
+ __cxa_throw: ___cxa_throw,
2578
+ /** @export */
2579
+ _abort_js: __abort_js,
2580
+ /** @export */
2581
+ _embind_register_bigint: __embind_register_bigint,
2582
+ /** @export */
2583
+ _embind_register_bool: __embind_register_bool,
2584
+ /** @export */
2585
+ _embind_register_emval: __embind_register_emval,
2586
+ /** @export */
2587
+ _embind_register_float: __embind_register_float,
2588
+ /** @export */
2589
+ _embind_register_function: __embind_register_function,
2590
+ /** @export */
2591
+ _embind_register_integer: __embind_register_integer,
2592
+ /** @export */
2593
+ _embind_register_memory_view: __embind_register_memory_view,
2594
+ /** @export */
2595
+ _embind_register_std_string: __embind_register_std_string,
2596
+ /** @export */
2597
+ _embind_register_std_wstring: __embind_register_std_wstring,
2598
+ /** @export */
2599
+ _embind_register_void: __embind_register_void,
2600
+ /** @export */
2601
+ _emscripten_memcpy_js: __emscripten_memcpy_js,
2602
+ /** @export */
2603
+ _emval_decref: __emval_decref,
2604
+ /** @export */
2605
+ _emval_new_array: __emval_new_array,
2606
+ /** @export */
2607
+ _emval_new_cstring: __emval_new_cstring,
2608
+ /** @export */
2609
+ _emval_new_object: __emval_new_object,
2610
+ /** @export */
2611
+ _emval_set_property: __emval_set_property,
2612
+ /** @export */
2613
+ _emval_take_value: __emval_take_value,
2614
+ /** @export */
2615
+ _tzset_js: __tzset_js,
2616
+ /** @export */
2617
+ emscripten_resize_heap: _emscripten_resize_heap,
2618
+ /** @export */
2619
+ environ_get: _environ_get,
2620
+ /** @export */
2621
+ environ_sizes_get: _environ_sizes_get,
2622
+ /** @export */
2623
+ fd_close: _fd_close,
2624
+ /** @export */
2625
+ fd_seek: _fd_seek,
2626
+ /** @export */
2627
+ fd_write: _fd_write
2628
+ };
2629
+ var wasmExports = createWasm();
2630
+ var ___wasm_call_ctors = createExportWrapper('__wasm_call_ctors', 0);
2631
+ var ___getTypeName = createExportWrapper('__getTypeName', 1);
2632
+ var _malloc = createExportWrapper('malloc', 1);
2633
+ var _fflush = createExportWrapper('fflush', 1);
2634
+ var _strerror = createExportWrapper('strerror', 1);
2635
+ var _free = createExportWrapper('free', 1);
2636
+ var _emscripten_stack_init = () => (_emscripten_stack_init = wasmExports['emscripten_stack_init'])();
2637
+ var _emscripten_stack_get_free = () => (_emscripten_stack_get_free = wasmExports['emscripten_stack_get_free'])();
2638
+ var _emscripten_stack_get_base = () => (_emscripten_stack_get_base = wasmExports['emscripten_stack_get_base'])();
2639
+ var _emscripten_stack_get_end = () => (_emscripten_stack_get_end = wasmExports['emscripten_stack_get_end'])();
2640
+ var __emscripten_stack_restore = (a0) => (__emscripten_stack_restore = wasmExports['_emscripten_stack_restore'])(a0);
2641
+ var __emscripten_stack_alloc = (a0) => (__emscripten_stack_alloc = wasmExports['_emscripten_stack_alloc'])(a0);
2642
+ var _emscripten_stack_get_current = () => (_emscripten_stack_get_current = wasmExports['emscripten_stack_get_current'])();
2643
+ var ___cxa_is_pointer_type = createExportWrapper('__cxa_is_pointer_type', 1);
2644
+ var dynCall_viijii = Module['dynCall_viijii'] = createExportWrapper('dynCall_viijii', 7);
2645
+ var dynCall_iiiiij = Module['dynCall_iiiiij'] = createExportWrapper('dynCall_iiiiij', 7);
2646
+ var dynCall_iiiiijj = Module['dynCall_iiiiijj'] = createExportWrapper('dynCall_iiiiijj', 9);
2647
+ var dynCall_iiiiiijj = Module['dynCall_iiiiiijj'] = createExportWrapper('dynCall_iiiiiijj', 10);
2648
+ var dynCall_jiji = Module['dynCall_jiji'] = createExportWrapper('dynCall_jiji', 5);
2649
+
2650
+
2651
+ // include: postamble.js
2652
+ // === Auto-generated postamble setup entry stuff ===
2653
+
2654
+ var missingLibrarySymbols = [
2655
+ 'writeI53ToI64',
2656
+ 'writeI53ToI64Clamped',
2657
+ 'writeI53ToI64Signaling',
2658
+ 'writeI53ToU64Clamped',
2659
+ 'writeI53ToU64Signaling',
2660
+ 'readI53FromI64',
2661
+ 'readI53FromU64',
2662
+ 'convertI32PairToI53',
2663
+ 'convertU32PairToI53',
2664
+ 'stackAlloc',
2665
+ 'getTempRet0',
2666
+ 'setTempRet0',
2667
+ 'zeroMemory',
2668
+ 'exitJS',
2669
+ 'isLeapYear',
2670
+ 'ydayFromDate',
2671
+ 'arraySum',
2672
+ 'addDays',
2673
+ 'strError',
2674
+ 'inetPton4',
2675
+ 'inetNtop4',
2676
+ 'inetPton6',
2677
+ 'inetNtop6',
2678
+ 'readSockaddr',
2679
+ 'writeSockaddr',
2680
+ 'initRandomFill',
2681
+ 'randomFill',
2682
+ 'emscriptenLog',
2683
+ 'readEmAsmArgs',
2684
+ 'jstoi_q',
2685
+ 'listenOnce',
2686
+ 'autoResumeAudioContext',
2687
+ 'handleException',
2688
+ 'keepRuntimeAlive',
2689
+ 'runtimeKeepalivePush',
2690
+ 'runtimeKeepalivePop',
2691
+ 'callUserCallback',
2692
+ 'maybeExit',
2693
+ 'asmjsMangle',
2694
+ 'asyncLoad',
2695
+ 'alignMemory',
2696
+ 'mmapAlloc',
2697
+ 'HandleAllocator',
2698
+ 'getNativeTypeSize',
2699
+ 'STACK_SIZE',
2700
+ 'STACK_ALIGN',
2701
+ 'POINTER_SIZE',
2702
+ 'ASSERTIONS',
2703
+ 'getCFunc',
2704
+ 'ccall',
2705
+ 'cwrap',
2706
+ 'uleb128Encode',
2707
+ 'sigToWasmTypes',
2708
+ 'generateFuncType',
2709
+ 'convertJsFunctionToWasm',
2710
+ 'getEmptyTableSlot',
2711
+ 'updateTableMap',
2712
+ 'getFunctionAddress',
2713
+ 'addFunction',
2714
+ 'removeFunction',
2715
+ 'reallyNegative',
2716
+ 'unSign',
2717
+ 'strLen',
2718
+ 'reSign',
2719
+ 'formatString',
2720
+ 'intArrayFromString',
2721
+ 'intArrayToString',
2722
+ 'AsciiToString',
2723
+ 'stringToNewUTF8',
2724
+ 'stringToUTF8OnStack',
2725
+ 'writeArrayToMemory',
2726
+ 'registerKeyEventCallback',
2727
+ 'maybeCStringToJsString',
2728
+ 'findEventTarget',
2729
+ 'getBoundingClientRect',
2730
+ 'fillMouseEventData',
2731
+ 'registerMouseEventCallback',
2732
+ 'registerWheelEventCallback',
2733
+ 'registerUiEventCallback',
2734
+ 'registerFocusEventCallback',
2735
+ 'fillDeviceOrientationEventData',
2736
+ 'registerDeviceOrientationEventCallback',
2737
+ 'fillDeviceMotionEventData',
2738
+ 'registerDeviceMotionEventCallback',
2739
+ 'screenOrientation',
2740
+ 'fillOrientationChangeEventData',
2741
+ 'registerOrientationChangeEventCallback',
2742
+ 'fillFullscreenChangeEventData',
2743
+ 'registerFullscreenChangeEventCallback',
2744
+ 'JSEvents_requestFullscreen',
2745
+ 'JSEvents_resizeCanvasForFullscreen',
2746
+ 'registerRestoreOldStyle',
2747
+ 'hideEverythingExceptGivenElement',
2748
+ 'restoreHiddenElements',
2749
+ 'setLetterbox',
2750
+ 'softFullscreenResizeWebGLRenderTarget',
2751
+ 'doRequestFullscreen',
2752
+ 'fillPointerlockChangeEventData',
2753
+ 'registerPointerlockChangeEventCallback',
2754
+ 'registerPointerlockErrorEventCallback',
2755
+ 'requestPointerLock',
2756
+ 'fillVisibilityChangeEventData',
2757
+ 'registerVisibilityChangeEventCallback',
2758
+ 'registerTouchEventCallback',
2759
+ 'fillGamepadEventData',
2760
+ 'registerGamepadEventCallback',
2761
+ 'registerBeforeUnloadEventCallback',
2762
+ 'fillBatteryEventData',
2763
+ 'battery',
2764
+ 'registerBatteryEventCallback',
2765
+ 'setCanvasElementSize',
2766
+ 'getCanvasElementSize',
2767
+ 'jsStackTrace',
2768
+ 'getCallstack',
2769
+ 'convertPCtoSourceLocation',
2770
+ 'checkWasiClock',
2771
+ 'wasiRightsToMuslOFlags',
2772
+ 'wasiOFlagsToMuslOFlags',
2773
+ 'createDyncallWrapper',
2774
+ 'safeSetTimeout',
2775
+ 'setImmediateWrapped',
2776
+ 'clearImmediateWrapped',
2777
+ 'polyfillSetImmediate',
2778
+ 'getPromise',
2779
+ 'makePromise',
2780
+ 'idsToPromises',
2781
+ 'makePromiseCallback',
2782
+ 'findMatchingCatch',
2783
+ 'Browser_asyncPrepareDataCounter',
2784
+ 'setMainLoop',
2785
+ 'getSocketFromFD',
2786
+ 'getSocketAddress',
2787
+ 'FS_createPreloadedFile',
2788
+ 'FS_modeStringToFlags',
2789
+ 'FS_getMode',
2790
+ 'FS_stdin_getChar',
2791
+ 'FS_unlink',
2792
+ 'FS_createDataFile',
2793
+ 'FS_mkdirTree',
2794
+ '_setNetworkCallback',
2795
+ 'heapObjectForWebGLType',
2796
+ 'toTypedArrayIndex',
2797
+ 'webgl_enable_ANGLE_instanced_arrays',
2798
+ 'webgl_enable_OES_vertex_array_object',
2799
+ 'webgl_enable_WEBGL_draw_buffers',
2800
+ 'webgl_enable_WEBGL_multi_draw',
2801
+ 'emscriptenWebGLGet',
2802
+ 'computeUnpackAlignedImageSize',
2803
+ 'colorChannelsInGlTextureFormat',
2804
+ 'emscriptenWebGLGetTexPixelData',
2805
+ 'emscriptenWebGLGetUniform',
2806
+ 'webglGetUniformLocation',
2807
+ 'webglPrepareUniformLocationsBeforeFirstUse',
2808
+ 'webglGetLeftBracePos',
2809
+ 'emscriptenWebGLGetVertexAttrib',
2810
+ '__glGetActiveAttribOrUniform',
2811
+ 'writeGLArray',
2812
+ 'registerWebGlEventCallback',
2813
+ 'runAndAbortIfError',
2814
+ 'ALLOC_NORMAL',
2815
+ 'ALLOC_STACK',
2816
+ 'allocate',
2817
+ 'writeStringToMemory',
2818
+ 'writeAsciiToMemory',
2819
+ 'setErrNo',
2820
+ 'demangle',
2821
+ 'stackTrace',
2822
+ 'getFunctionArgsName',
2823
+ 'createJsInvokerSignature',
2824
+ 'init_embind',
2825
+ 'getBasestPointer',
2826
+ 'registerInheritedInstance',
2827
+ 'unregisterInheritedInstance',
2828
+ 'getInheritedInstance',
2829
+ 'getInheritedInstanceCount',
2830
+ 'getLiveInheritedInstances',
2831
+ 'enumReadValueFromPointer',
2832
+ 'genericPointerToWireType',
2833
+ 'constNoSmartPtrRawPointerToWireType',
2834
+ 'nonConstNoSmartPtrRawPointerToWireType',
2835
+ 'init_RegisteredPointer',
2836
+ 'RegisteredPointer',
2837
+ 'RegisteredPointer_fromWireType',
2838
+ 'runDestructor',
2839
+ 'releaseClassHandle',
2840
+ 'detachFinalizer',
2841
+ 'attachFinalizer',
2842
+ 'makeClassHandle',
2843
+ 'init_ClassHandle',
2844
+ 'ClassHandle',
2845
+ 'throwInstanceAlreadyDeleted',
2846
+ 'flushPendingDeletes',
2847
+ 'setDelayFunction',
2848
+ 'RegisteredClass',
2849
+ 'shallowCopyInternalPointer',
2850
+ 'downcastPointer',
2851
+ 'upcastPointer',
2852
+ 'validateThis',
2853
+ 'char_0',
2854
+ 'char_9',
2855
+ 'makeLegalFunctionName',
2856
+ 'emval_get_global',
2857
+ 'emval_returnValue',
2858
+ 'emval_lookupTypes',
2859
+ 'emval_addMethodCaller',
2860
+ ];
2861
+ missingLibrarySymbols.forEach(missingLibrarySymbol)
2862
+
2863
+ var unexportedSymbols = [
2864
+ 'run',
2865
+ 'addOnPreRun',
2866
+ 'addOnInit',
2867
+ 'addOnPreMain',
2868
+ 'addOnExit',
2869
+ 'addOnPostRun',
2870
+ 'addRunDependency',
2871
+ 'removeRunDependency',
2872
+ 'out',
2873
+ 'err',
2874
+ 'callMain',
2875
+ 'abort',
2876
+ 'wasmMemory',
2877
+ 'wasmExports',
2878
+ 'writeStackCookie',
2879
+ 'checkStackCookie',
2880
+ 'convertI32PairToI53Checked',
2881
+ 'stackSave',
2882
+ 'stackRestore',
2883
+ 'ptrToString',
2884
+ 'getHeapMax',
2885
+ 'growMemory',
2886
+ 'ENV',
2887
+ 'MONTH_DAYS_REGULAR',
2888
+ 'MONTH_DAYS_LEAP',
2889
+ 'MONTH_DAYS_REGULAR_CUMULATIVE',
2890
+ 'MONTH_DAYS_LEAP_CUMULATIVE',
2891
+ 'ERRNO_CODES',
2892
+ 'DNS',
2893
+ 'Protocols',
2894
+ 'Sockets',
2895
+ 'timers',
2896
+ 'warnOnce',
2897
+ 'readEmAsmArgsArray',
2898
+ 'jstoi_s',
2899
+ 'getExecutableName',
2900
+ 'dynCallLegacy',
2901
+ 'getDynCaller',
2902
+ 'dynCall',
2903
+ 'wasmTable',
2904
+ 'noExitRuntime',
2905
+ 'freeTableIndexes',
2906
+ 'functionsInTableMap',
2907
+ 'setValue',
2908
+ 'getValue',
2909
+ 'PATH',
2910
+ 'PATH_FS',
2911
+ 'UTF8Decoder',
2912
+ 'UTF8ArrayToString',
2913
+ 'UTF8ToString',
2914
+ 'stringToUTF8Array',
2915
+ 'stringToUTF8',
2916
+ 'lengthBytesUTF8',
2917
+ 'stringToAscii',
2918
+ 'UTF16Decoder',
2919
+ 'UTF16ToString',
2920
+ 'stringToUTF16',
2921
+ 'lengthBytesUTF16',
2922
+ 'UTF32ToString',
2923
+ 'stringToUTF32',
2924
+ 'lengthBytesUTF32',
2925
+ 'JSEvents',
2926
+ 'specialHTMLTargets',
2927
+ 'findCanvasEventTarget',
2928
+ 'currentFullscreenStrategy',
2929
+ 'restoreOldWindowedStyle',
2930
+ 'UNWIND_CACHE',
2931
+ 'ExitStatus',
2932
+ 'getEnvStrings',
2933
+ 'flush_NO_FILESYSTEM',
2934
+ 'promiseMap',
2935
+ 'uncaughtExceptionCount',
2936
+ 'exceptionLast',
2937
+ 'exceptionCaught',
2938
+ 'ExceptionInfo',
2939
+ 'Browser',
2940
+ 'getPreloadedImageData__data',
2941
+ 'wget',
2942
+ 'SYSCALLS',
2943
+ 'preloadPlugins',
2944
+ 'FS_stdin_getChar_buffer',
2945
+ 'FS_createPath',
2946
+ 'FS_createDevice',
2947
+ 'FS_readFile',
2948
+ 'FS',
2949
+ 'FS_createLazyFile',
2950
+ 'MEMFS',
2951
+ 'TTY',
2952
+ 'PIPEFS',
2953
+ 'SOCKFS',
2954
+ 'tempFixedLengthArray',
2955
+ 'miniTempWebGLFloatBuffers',
2956
+ 'miniTempWebGLIntBuffers',
2957
+ 'GL',
2958
+ 'AL',
2959
+ 'GLUT',
2960
+ 'EGL',
2961
+ 'GLEW',
2962
+ 'IDBStore',
2963
+ 'SDL',
2964
+ 'SDL_gfx',
2965
+ 'allocateUTF8',
2966
+ 'allocateUTF8OnStack',
2967
+ 'print',
2968
+ 'printErr',
2969
+ 'InternalError',
2970
+ 'BindingError',
2971
+ 'throwInternalError',
2972
+ 'throwBindingError',
2973
+ 'registeredTypes',
2974
+ 'awaitingDependencies',
2975
+ 'typeDependencies',
2976
+ 'tupleRegistrations',
2977
+ 'structRegistrations',
2978
+ 'sharedRegisterType',
2979
+ 'whenDependentTypesAreResolved',
2980
+ 'embind_charCodes',
2981
+ 'embind_init_charCodes',
2982
+ 'readLatin1String',
2983
+ 'getTypeName',
2984
+ 'getFunctionName',
2985
+ 'heap32VectorToArray',
2986
+ 'requireRegisteredType',
2987
+ 'usesDestructorStack',
2988
+ 'createJsInvoker',
2989
+ 'UnboundTypeError',
2990
+ 'PureVirtualError',
2991
+ 'GenericWireTypeSize',
2992
+ 'EmValType',
2993
+ 'throwUnboundTypeError',
2994
+ 'ensureOverloadTable',
2995
+ 'exposePublicSymbol',
2996
+ 'replacePublicSymbol',
2997
+ 'extendError',
2998
+ 'createNamedFunction',
2999
+ 'embindRepr',
3000
+ 'registeredInstances',
3001
+ 'registeredPointers',
3002
+ 'registerType',
3003
+ 'integerReadValueFromPointer',
3004
+ 'floatReadValueFromPointer',
3005
+ 'readPointer',
3006
+ 'runDestructors',
3007
+ 'newFunc',
3008
+ 'craftInvokerFunction',
3009
+ 'embind__requireFunction',
3010
+ 'finalizationRegistry',
3011
+ 'detachFinalizer_deps',
3012
+ 'deletionQueue',
3013
+ 'delayFunction',
3014
+ 'emval_freelist',
3015
+ 'emval_handles',
3016
+ 'emval_symbols',
3017
+ 'init_emval',
3018
+ 'count_emval_handles',
3019
+ 'getStringOrSymbol',
3020
+ 'Emval',
3021
+ 'emval_methodCallers',
3022
+ 'reflectConstruct',
3023
+ ];
3024
+ unexportedSymbols.forEach(unexportedRuntimeSymbol);
3025
+
3026
+
3027
+
3028
+ var calledRun;
3029
+
3030
+ dependenciesFulfilled = function runCaller() {
3031
+ // If run has never been called, and we should call run (INVOKE_RUN is true, and Module.noInitialRun is not false)
3032
+ if (!calledRun) run();
3033
+ if (!calledRun) dependenciesFulfilled = runCaller; // try this again later, after new deps are fulfilled
3034
+ };
3035
+
3036
+ function stackCheckInit() {
3037
+ // This is normally called automatically during __wasm_call_ctors but need to
3038
+ // get these values before even running any of the ctors so we call it redundantly
3039
+ // here.
3040
+ _emscripten_stack_init();
3041
+ // TODO(sbc): Move writeStackCookie to native to to avoid this.
3042
+ writeStackCookie();
3043
+ }
3044
+
3045
+ function run() {
3046
+
3047
+ if (runDependencies > 0) {
3048
+ return;
3049
+ }
3050
+
3051
+ stackCheckInit();
3052
+
3053
+ preRun();
3054
+
3055
+ // a preRun added a dependency, run will be called later
3056
+ if (runDependencies > 0) {
3057
+ return;
3058
+ }
3059
+
3060
+ function doRun() {
3061
+ // run may have just been called through dependencies being fulfilled just in this very frame,
3062
+ // or while the async setStatus time below was happening
3063
+ if (calledRun) return;
3064
+ calledRun = true;
3065
+ Module['calledRun'] = true;
3066
+
3067
+ if (ABORT) return;
3068
+
3069
+ initRuntime();
3070
+
3071
+ readyPromiseResolve(Module);
3072
+ Module['onRuntimeInitialized']?.();
3073
+
3074
+ assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]');
3075
+
3076
+ postRun();
3077
+ }
3078
+
3079
+ if (Module['setStatus']) {
3080
+ Module['setStatus']('Running...');
3081
+ setTimeout(function() {
3082
+ setTimeout(function() {
3083
+ Module['setStatus']('');
3084
+ }, 1);
3085
+ doRun();
3086
+ }, 1);
3087
+ } else
3088
+ {
3089
+ doRun();
3090
+ }
3091
+ checkStackCookie();
3092
+ }
3093
+
3094
+ function checkUnflushedContent() {
3095
+ // Compiler settings do not allow exiting the runtime, so flushing
3096
+ // the streams is not possible. but in ASSERTIONS mode we check
3097
+ // if there was something to flush, and if so tell the user they
3098
+ // should request that the runtime be exitable.
3099
+ // Normally we would not even include flush() at all, but in ASSERTIONS
3100
+ // builds we do so just for this check, and here we see if there is any
3101
+ // content to flush, that is, we check if there would have been
3102
+ // something a non-ASSERTIONS build would have not seen.
3103
+ // How we flush the streams depends on whether we are in SYSCALLS_REQUIRE_FILESYSTEM=0
3104
+ // mode (which has its own special function for this; otherwise, all
3105
+ // the code is inside libc)
3106
+ var oldOut = out;
3107
+ var oldErr = err;
3108
+ var has = false;
3109
+ out = err = (x) => {
3110
+ has = true;
3111
+ }
3112
+ try { // it doesn't matter if it fails
3113
+ flush_NO_FILESYSTEM();
3114
+ } catch(e) {}
3115
+ out = oldOut;
3116
+ err = oldErr;
3117
+ if (has) {
3118
+ warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the Emscripten FAQ), or make sure to emit a newline when you printf etc.');
3119
+ warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)');
3120
+ }
3121
+ }
3122
+
3123
+ if (Module['preInit']) {
3124
+ if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']];
3125
+ while (Module['preInit'].length > 0) {
3126
+ Module['preInit'].pop()();
3127
+ }
3128
+ }
3129
+
3130
+ run();
3131
+
3132
+ // end include: postamble.js
3133
+
3134
+ // include: postamble_modularize.js
3135
+ // In MODULARIZE mode we wrap the generated code in a factory function
3136
+ // and return either the Module itself, or a promise of the module.
3137
+ //
3138
+ // We assign to the `moduleRtn` global here and configure closure to see
3139
+ // this as and extern so it won't get minified.
3140
+
3141
+ moduleRtn = readyPromise;
3142
+
3143
+ // Assertion for attempting to access module properties on the incoming
3144
+ // moduleArg. In the past we used this object as the prototype of the module
3145
+ // and assigned properties to it, but now we return a distinct object. This
3146
+ // keeps the instance private until it is ready (i.e the promise has been
3147
+ // resolved).
3148
+ for (const prop of Object.keys(Module)) {
3149
+ if (!(prop in moduleArg)) {
3150
+ Object.defineProperty(moduleArg, prop, {
3151
+ configurable: true,
3152
+ get() {
3153
+ abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`)
3154
+ }
3155
+ });
3156
+ }
3157
+ }
3158
+ // end include: postamble_modularize.js
3159
+
3160
+
3161
+
3162
+ return moduleRtn;
3163
+ }
3164
+ );
3165
+ })();
3166
+ if (typeof exports === 'object' && typeof module === 'object')
3167
+ module.exports = createStatsim;
3168
+ else if (typeof define === 'function' && define['amd'])
3169
+ define([], () => createStatsim);