-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathsql-wasm.js
More file actions
2975 lines (2959 loc) · 86.9 KB
/
Copy pathsql-wasm.js
File metadata and controls
2975 lines (2959 loc) · 86.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// We are modularizing this manually because the current modularize setting in Emscripten has some issues:
// https://github.com/kripken/emscripten/issues/5820
// In addition, When you use emcc's modularization, it still expects to export a global object called `Module`,
// which is able to be used/called before the WASM is loaded.
// The modularization below exports a promise that loads and resolves to the actual sql.js module.
// That way, this module can't be used before the WASM is finished loading.
// We are going to define a function that a user will call to start loading initializing our Sql.js library
// However, that function might be called multiple times, and on subsequent calls, we don't actually want it to instantiate a new instance of the Module
// Instead, we want to return the previously loaded module
// TODO: Make this not declare a global if used in the browser
var initSqlJsPromise = undefined;
var initSqlJs = function (moduleConfig) {
if (initSqlJsPromise) {
return initSqlJsPromise;
}
// If we're here, we've never called this function before
initSqlJsPromise = new Promise(function (resolveModule, reject) {
// We are modularizing this manually because the current modularize setting in Emscripten has some issues:
// https://github.com/kripken/emscripten/issues/5820
// The way to affect the loading of emcc compiled modules is to create a variable called `Module` and add
// properties to it, like `preRun`, `postRun`, etc
// We are using that to get notified when the WASM has finished loading.
// Only then will we return our promise
// If they passed in a moduleConfig object, use that
// Otherwise, initialize Module to the empty object
var Module = typeof moduleConfig !== "undefined" ? moduleConfig : {};
// EMCC only allows for a single onAbort function (not an array of functions)
// So if the user defined their own onAbort function, we remember it and call it
var originalOnAbortFunction = Module["onAbort"];
Module["onAbort"] = function (errorThatCausedAbort) {
reject(new Error(errorThatCausedAbort));
if (originalOnAbortFunction) {
originalOnAbortFunction(errorThatCausedAbort);
}
};
Module["postRun"] = Module["postRun"] || [];
Module["postRun"].push(function () {
// When Emscripted calls postRun, this promise resolves with the built Module
resolveModule(Module);
});
// There is a section of code in the emcc-generated code below that looks like this:
// (Note that this is lowercase `module`)
// if (typeof module !== 'undefined') {
// module['exports'] = Module;
// }
// When that runs, it's going to overwrite our own modularization export efforts in shell-post.js!
// The only way to tell emcc not to emit it is to pass the MODULARIZE=1 or MODULARIZE_INSTANCE=1 flags,
// but that carries with it additional unnecessary baggage/bugs we don't want either.
// So, we have three options:
// 1) We undefine `module`
// 2) We remember what `module['exports']` was at the beginning of this function and we restore it later
// 3) We write a script to remove those lines of code as part of the Make process.
//
// Since those are the only lines of code that care about module, we will undefine it. It's the most straightforward
// of the options, and has the side effect of reducing emcc's efforts to modify the module if its output were to change in the future.
// That's a nice side effect since we're handling the modularization efforts ourselves
module = undefined;
// The emcc-generated code and shell-post.js code goes below,
// meaning that all of it runs inside of this promise. If anything throws an exception, our promise will abort
var e;
e || (e = typeof Module !== "undefined" ? Module : {});
null;
e.onRuntimeInitialized = function () {
function a(g, m) {
switch (typeof m) {
case "boolean":
nc(g, m ? 1 : 0);
break;
case "number":
oc(g, m);
break;
case "string":
pc(g, m, -1, -1);
break;
case "object":
if (null === m) pb(g);
else if (null != m.length) {
var p = ba(m, ca);
qc(g, p, m.length, -1);
da(p);
} else
Aa(
g,
"Wrong API use : tried to return a value of an unknown type (" +
m +
").",
-1
);
break;
default:
pb(g);
}
}
function b(g, m) {
for (var p = [], r = 0; r < g; r += 1) {
var u = k(m + 4 * r, "i32"),
x = rc(u);
if (1 === x || 2 === x) u = sc(u);
else if (3 === x) u = tc(u);
else if (4 === x) {
x = u;
u = uc(x);
x = vc(x);
for (var K = new Uint8Array(u), F = 0; F < u; F += 1)
K[F] = n[x + F];
u = K;
} else u = null;
p.push(u);
}
return p;
}
function c(g, m) {
this.Qa = g;
this.db = m;
this.Oa = 1;
this.kb = [];
}
function d(g, m) {
this.db = m;
m = ea(g) + 1;
this.cb = fa(m);
if (null === this.cb)
throw Error("Unable to allocate memory for the SQL string");
t(g, y, this.cb, m);
this.ib = this.cb;
this.Za = this.ob = null;
}
function f(g) {
this.filename = "dbfile_" + ((4294967295 * Math.random()) >>> 0);
if (null != g) {
var m = this.filename,
p = m ? z("//" + m) : "/";
m = ha(!0, !0);
p = ja(p, ((void 0 !== m ? m : 438) & 4095) | 32768, 0);
if (g) {
if ("string" === typeof g) {
for (var r = Array(g.length), u = 0, x = g.length; u < x; ++u)
r[u] = g.charCodeAt(u);
g = r;
}
ka(p, m | 146);
r = A(p, 577);
la(r, g, 0, g.length, 0, void 0);
ma(r);
ka(p, m);
}
}
this.handleError(q(this.filename, h));
this.db = k(h, "i32");
sb(this.db);
this.eb = {};
this.Sa = {};
}
var h = B(4),
l = e.cwrap,
q = l("sqlite3_open", "number", ["string", "number"]),
w = l("sqlite3_close_v2", "number", ["number"]),
v = l("sqlite3_exec", "number", [
"number",
"string",
"number",
"number",
"number",
]),
C = l("sqlite3_changes", "number", ["number"]),
G = l("sqlite3_prepare_v2", "number", [
"number",
"string",
"number",
"number",
"number",
]),
ia = l("sqlite3_sql", "string", ["number"]),
wc = l("sqlite3_normalized_sql", "string", ["number"]),
tb = l("sqlite3_prepare_v2", "number", [
"number",
"number",
"number",
"number",
"number",
]),
xc = l("sqlite3_bind_text", "number", [
"number",
"number",
"number",
"number",
"number",
]),
ub = l("sqlite3_bind_blob", "number", [
"number",
"number",
"number",
"number",
"number",
]),
yc = l("sqlite3_bind_double", "number", ["number", "number", "number"]),
zc = l("sqlite3_bind_int", "number", ["number", "number", "number"]),
Ac = l("sqlite3_bind_parameter_index", "number", ["number", "string"]),
Bc = l("sqlite3_step", "number", ["number"]),
Cc = l("sqlite3_errmsg", "string", ["number"]),
Dc = l("sqlite3_column_count", "number", ["number"]),
Ec = l("sqlite3_data_count", "number", ["number"]),
Fc = l("sqlite3_column_double", "number", ["number", "number"]),
vb = l("sqlite3_column_text", "string", ["number", "number"]),
Gc = l("sqlite3_column_blob", "number", ["number", "number"]),
Hc = l("sqlite3_column_bytes", "number", ["number", "number"]),
Ic = l("sqlite3_column_type", "number", ["number", "number"]),
Jc = l("sqlite3_column_name", "string", ["number", "number"]),
Kc = l("sqlite3_reset", "number", ["number"]),
Lc = l("sqlite3_clear_bindings", "number", ["number"]),
Mc = l("sqlite3_finalize", "number", ["number"]),
wb = l(
"sqlite3_create_function_v2",
"number",
"number string number number number number number number number".split(
" "
)
),
rc = l("sqlite3_value_type", "number", ["number"]),
uc = l("sqlite3_value_bytes", "number", ["number"]),
tc = l("sqlite3_value_text", "string", ["number"]),
vc = l("sqlite3_value_blob", "number", ["number"]),
sc = l("sqlite3_value_double", "number", ["number"]),
oc = l("sqlite3_result_double", "", ["number", "number"]),
pb = l("sqlite3_result_null", "", ["number"]),
pc = l("sqlite3_result_text", "", [
"number",
"string",
"number",
"number",
]),
qc = l("sqlite3_result_blob", "", [
"number",
"number",
"number",
"number",
]),
nc = l("sqlite3_result_int", "", ["number", "number"]),
Aa = l("sqlite3_result_error", "", ["number", "string", "number"]),
xb = l("sqlite3_aggregate_context", "number", ["number", "number"]),
sb = l("RegisterExtensionFunctions", "number", ["number"]);
c.prototype.bind = function (g) {
if (!this.Qa) throw "Statement closed";
this.reset();
return Array.isArray(g)
? this.Cb(g)
: null != g && "object" === typeof g
? this.Db(g)
: !0;
};
c.prototype.step = function () {
if (!this.Qa) throw "Statement closed";
this.Oa = 1;
var g = Bc(this.Qa);
switch (g) {
case 100:
return !0;
case 101:
return !1;
default:
throw this.db.handleError(g);
}
};
c.prototype.yb = function (g) {
null == g && ((g = this.Oa), (this.Oa += 1));
return Fc(this.Qa, g);
};
c.prototype.Gb = function (g) {
null == g && ((g = this.Oa), (this.Oa += 1));
g = vb(this.Qa, g);
if ("function" !== typeof BigInt)
throw Error("BigInt is not supported");
return BigInt(g);
};
c.prototype.Hb = function (g) {
null == g && ((g = this.Oa), (this.Oa += 1));
return vb(this.Qa, g);
};
c.prototype.getBlob = function (g) {
null == g && ((g = this.Oa), (this.Oa += 1));
var m = Hc(this.Qa, g);
g = Gc(this.Qa, g);
for (var p = new Uint8Array(m), r = 0; r < m; r += 1) p[r] = n[g + r];
return p;
};
c.prototype.get = function (g, m) {
m = m || {};
null != g && this.bind(g) && this.step();
g = [];
for (var p = Ec(this.Qa), r = 0; r < p; r += 1)
switch (Ic(this.Qa, r)) {
case 1:
var u = m.useBigInt ? this.Gb(r) : this.yb(r);
g.push(u);
break;
case 2:
g.push(this.yb(r));
break;
case 3:
g.push(this.Hb(r));
break;
case 4:
g.push(this.getBlob(r));
break;
default:
g.push(null);
}
return g;
};
c.prototype.getColumnNames = function () {
for (var g = [], m = Dc(this.Qa), p = 0; p < m; p += 1)
g.push(Jc(this.Qa, p));
return g;
};
c.prototype.getAsObject = function (g, m) {
g = this.get(g, m);
m = this.getColumnNames();
for (var p = {}, r = 0; r < m.length; r += 1) p[m[r]] = g[r];
return p;
};
c.prototype.getSQL = function () {
return ia(this.Qa);
};
c.prototype.getNormalizedSQL = function () {
return wc(this.Qa);
};
c.prototype.run = function (g) {
null != g && this.bind(g);
this.step();
return this.reset();
};
c.prototype.tb = function (g, m) {
null == m && ((m = this.Oa), (this.Oa += 1));
g = na(g);
var p = ba(g, ca);
this.kb.push(p);
this.db.handleError(xc(this.Qa, m, p, g.length - 1, 0));
};
c.prototype.Bb = function (g, m) {
null == m && ((m = this.Oa), (this.Oa += 1));
var p = ba(g, ca);
this.kb.push(p);
this.db.handleError(ub(this.Qa, m, p, g.length, 0));
};
c.prototype.sb = function (g, m) {
null == m && ((m = this.Oa), (this.Oa += 1));
this.db.handleError((g === (g | 0) ? zc : yc)(this.Qa, m, g));
};
c.prototype.Eb = function (g) {
null == g && ((g = this.Oa), (this.Oa += 1));
ub(this.Qa, g, 0, 0, 0);
};
c.prototype.ub = function (g, m) {
null == m && ((m = this.Oa), (this.Oa += 1));
switch (typeof g) {
case "string":
this.tb(g, m);
return;
case "number":
this.sb(g, m);
return;
case "bigint":
this.tb(g.toString(), m);
return;
case "boolean":
this.sb(g + 0, m);
return;
case "object":
if (null === g) {
this.Eb(m);
return;
}
if (null != g.length) {
this.Bb(g, m);
return;
}
}
throw (
"Wrong API use : tried to bind a value of an unknown type (" +
g +
")."
);
};
c.prototype.Db = function (g) {
var m = this;
Object.keys(g).forEach(function (p) {
var r = Ac(m.Qa, p);
0 !== r && m.ub(g[p], r);
});
return !0;
};
c.prototype.Cb = function (g) {
for (var m = 0; m < g.length; m += 1) this.ub(g[m], m + 1);
return !0;
};
c.prototype.reset = function () {
this.freemem();
return 0 === Lc(this.Qa) && 0 === Kc(this.Qa);
};
c.prototype.freemem = function () {
for (var g; void 0 !== (g = this.kb.pop()); ) da(g);
};
c.prototype.free = function () {
this.freemem();
var g = 0 === Mc(this.Qa);
delete this.db.eb[this.Qa];
this.Qa = 0;
return g;
};
d.prototype.next = function () {
if (null === this.cb) return { done: !0 };
null !== this.Za && (this.Za.free(), (this.Za = null));
if (!this.db.db) throw (this.mb(), Error("Database closed"));
var g = oa(),
m = B(4);
pa(h);
pa(m);
try {
this.db.handleError(tb(this.db.db, this.ib, -1, h, m));
this.ib = k(m, "i32");
var p = k(h, "i32");
if (0 === p) return this.mb(), { done: !0 };
this.Za = new c(p, this.db);
this.db.eb[p] = this.Za;
return { value: this.Za, done: !1 };
} catch (r) {
throw ((this.ob = D(this.ib)), this.mb(), r);
} finally {
qa(g);
}
};
d.prototype.mb = function () {
da(this.cb);
this.cb = null;
};
d.prototype.getRemainingSQL = function () {
return null !== this.ob ? this.ob : D(this.ib);
};
"function" === typeof Symbol &&
"symbol" === typeof Symbol.iterator &&
(d.prototype[Symbol.iterator] = function () {
return this;
});
f.prototype.run = function (g, m) {
if (!this.db) throw "Database closed";
if (m) {
g = this.prepare(g, m);
try {
g.step();
} finally {
g.free();
}
} else this.handleError(v(this.db, g, 0, 0, h));
return this;
};
f.prototype.exec = function (g, m, p) {
if (!this.db) throw "Database closed";
var r = oa(),
u = null;
try {
var x = ra(g),
K = B(4);
for (g = []; 0 !== k(x, "i8"); ) {
pa(h);
pa(K);
this.handleError(tb(this.db, x, -1, h, K));
var F = k(h, "i32");
x = k(K, "i32");
if (0 !== F) {
var E = null;
u = new c(F, this);
for (null != m && u.bind(m); u.step(); )
null === E &&
((E = { columns: u.getColumnNames(), values: [] }),
g.push(E)),
E.values.push(u.get(null, p));
u.free();
}
}
return g;
} catch (M) {
throw (u && u.free(), M);
} finally {
qa(r);
}
};
f.prototype.each = function (g, m, p, r, u) {
"function" === typeof m && ((r = p), (p = m), (m = void 0));
g = this.prepare(g, m);
try {
for (; g.step(); ) p(g.getAsObject(null, u));
} finally {
g.free();
}
if ("function" === typeof r) return r();
};
f.prototype.prepare = function (g, m) {
pa(h);
this.handleError(G(this.db, g, -1, h, 0));
g = k(h, "i32");
if (0 === g) throw "Nothing to prepare";
var p = new c(g, this);
null != m && p.bind(m);
return (this.eb[g] = p);
};
f.prototype.iterateStatements = function (g) {
return new d(g, this);
};
f.prototype["export"] = function () {
Object.values(this.eb).forEach(function (m) {
m.free();
});
Object.values(this.Sa).forEach(sa);
this.Sa = {};
this.handleError(w(this.db));
var g = ta(this.filename);
this.handleError(q(this.filename, h));
this.db = k(h, "i32");
sb(this.db);
return g;
};
f.prototype.close = function () {
null !== this.db &&
(Object.values(this.eb).forEach(function (g) {
g.free();
}),
Object.values(this.Sa).forEach(sa),
(this.Sa = {}),
this.handleError(w(this.db)),
ua("/" + this.filename),
(this.db = null));
};
f.prototype.handleError = function (g) {
if (0 === g) return null;
g = Cc(this.db);
throw Error(g);
};
f.prototype.getRowsModified = function () {
return C(this.db);
};
f.prototype.create_function = function (g, m) {
Object.prototype.hasOwnProperty.call(this.Sa, g) &&
(sa(this.Sa[g]), delete this.Sa[g]);
var p = va(function (r, u, x) {
u = b(u, x);
try {
var K = m.apply(null, u);
} catch (F) {
Aa(r, F, -1);
return;
}
a(r, K);
}, "viii");
this.Sa[g] = p;
this.handleError(wb(this.db, g, m.length, 1, 0, p, 0, 0, 0));
return this;
};
f.prototype.create_aggregate = function (g, m) {
var p =
m.init ||
function () {
return null;
},
r =
m.finalize ||
function (E) {
return E;
},
u = m.step;
if (!u) throw "An aggregate function must have a step function in " + g;
var x = {};
Object.hasOwnProperty.call(this.Sa, g) &&
(sa(this.Sa[g]), delete this.Sa[g]);
m = g + "__finalize";
Object.hasOwnProperty.call(this.Sa, m) &&
(sa(this.Sa[m]), delete this.Sa[m]);
var K = va(function (E, M, Ua) {
var aa = xb(E, 1);
Object.hasOwnProperty.call(x, aa) || (x[aa] = p());
M = b(M, Ua);
M = [x[aa]].concat(M);
try {
x[aa] = u.apply(null, M);
} catch (Oc) {
delete x[aa], Aa(E, Oc, -1);
}
}, "viii"),
F = va(function (E) {
var M = xb(E, 1);
try {
var Ua = r(x[M]);
} catch (aa) {
delete x[M];
Aa(E, aa, -1);
return;
}
a(E, Ua);
delete x[M];
}, "vi");
this.Sa[g] = K;
this.Sa[m] = F;
this.handleError(wb(this.db, g, u.length - 1, 1, 0, 0, K, F, 0));
return this;
};
e.Database = f;
};
var wa = {},
H;
for (H in e) e.hasOwnProperty(H) && (wa[H] = e[H]);
var xa = "./this.program",
ya = "object" === typeof window,
za = "function" === typeof importScripts,
Ba =
"object" === typeof process &&
"object" === typeof process.versions &&
"string" === typeof process.versions.node,
I = "",
Ca,
Da,
Ea,
Fa,
Ga;
if (Ba)
(I = za ? require("path").dirname(I) + "/" : __dirname + "/"),
(Ca = function (a, b) {
Fa || (Fa = require("fs"));
Ga || (Ga = require("path"));
a = Ga.normalize(a);
return Fa.readFileSync(a, b ? null : "utf8");
}),
(Ea = function (a) {
a = Ca(a, !0);
a.buffer || (a = new Uint8Array(a));
a.buffer || J("Assertion failed: undefined");
return a;
}),
(Da = function (a, b, c) {
Fa || (Fa = require("fs"));
Ga || (Ga = require("path"));
a = Ga.normalize(a);
Fa.readFile(a, function (d, f) {
d ? c(d) : b(f.buffer);
});
}),
1 < process.argv.length && (xa = process.argv[1].replace(/\\/g, "/")),
process.argv.slice(2),
"undefined" !== typeof module && (module.exports = e),
(e.inspect = function () {
return "[Emscripten Module object]";
});
else if (ya || za)
za
? (I = self.location.href)
: "undefined" !== typeof document &&
document.currentScript &&
(I = document.currentScript.src),
(I =
0 !== I.indexOf("blob:")
? I.substr(0, I.replace(/[?#].*/, "").lastIndexOf("/") + 1)
: ""),
(Ca = function (a) {
var b = new XMLHttpRequest();
b.open("GET", a, !1);
b.send(null);
return b.responseText;
}),
za &&
(Ea = function (a) {
var b = new XMLHttpRequest();
b.open("GET", a, !1);
b.responseType = "arraybuffer";
b.send(null);
return new Uint8Array(b.response);
}),
(Da = function (a, b, c) {
var d = new XMLHttpRequest();
d.open("GET", a, !0);
d.responseType = "arraybuffer";
d.onload = function () {
200 == d.status || (0 == d.status && d.response)
? b(d.response)
: c();
};
d.onerror = c;
d.send(null);
});
var Ha = e.print || console.log.bind(console),
Ia = e.printErr || console.warn.bind(console);
for (H in wa) wa.hasOwnProperty(H) && (e[H] = wa[H]);
wa = null;
e.thisProgram && (xa = e.thisProgram);
var Ja = [],
Ka;
function va(a, b) {
if (!Ka) {
Ka = new WeakMap();
for (var c = L.length, d = 0; d < 0 + c; d++) {
var f = L.get(d);
f && Ka.set(f, d);
}
}
if (Ka.has(a)) return Ka.get(a);
if (Ja.length) c = Ja.pop();
else {
try {
L.grow(1);
} catch (q) {
if (!(q instanceof RangeError)) throw q;
throw "Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";
}
c = L.length - 1;
}
try {
L.set(c, a);
} catch (q) {
if (!(q instanceof TypeError)) throw q;
if ("function" === typeof WebAssembly.Function) {
f = { i: "i32", j: "i64", f: "f32", d: "f64" };
var h = { parameters: [], results: "v" == b[0] ? [] : [f[b[0]]] };
for (d = 1; d < b.length; ++d) h.parameters.push(f[b[d]]);
b = new WebAssembly.Function(h, a);
} else {
f = [1, 0, 1, 96];
h = b.slice(0, 1);
b = b.slice(1);
var l = { i: 127, j: 126, f: 125, d: 124 };
f.push(b.length);
for (d = 0; d < b.length; ++d) f.push(l[b[d]]);
"v" == h ? f.push(0) : (f = f.concat([1, l[h]]));
f[1] = f.length - 2;
b = new Uint8Array(
[0, 97, 115, 109, 1, 0, 0, 0].concat(
f,
[2, 7, 1, 1, 101, 1, 102, 0, 0, 7, 5, 1, 1, 102, 0, 0]
)
);
b = new WebAssembly.Module(b);
b = new WebAssembly.Instance(b, { e: { f: a } }).exports.f;
}
L.set(c, b);
}
Ka.set(a, c);
return c;
}
function sa(a) {
Ka.delete(L.get(a));
Ja.push(a);
}
var La;
e.wasmBinary && (La = e.wasmBinary);
var noExitRuntime = e.noExitRuntime || !0;
"object" !== typeof WebAssembly && J("no native wasm support detected");
function pa(a) {
var b = "i32";
"*" === b.charAt(b.length - 1) && (b = "i32");
switch (b) {
case "i1":
n[a >> 0] = 0;
break;
case "i8":
n[a >> 0] = 0;
break;
case "i16":
Ma[a >> 1] = 0;
break;
case "i32":
N[a >> 2] = 0;
break;
case "i64":
O = [
0,
((P = 0),
1 <= +Math.abs(P)
? 0 < P
? (Math.min(+Math.floor(P / 4294967296), 4294967295) | 0) >>> 0
: ~~+Math.ceil((P - +(~~P >>> 0)) / 4294967296) >>> 0
: 0),
];
N[a >> 2] = O[0];
N[(a + 4) >> 2] = O[1];
break;
case "float":
Na[a >> 2] = 0;
break;
case "double":
Oa[a >> 3] = 0;
break;
default:
J("invalid type for setValue: " + b);
}
}
function k(a, b) {
b = b || "i8";
"*" === b.charAt(b.length - 1) && (b = "i32");
switch (b) {
case "i1":
return n[a >> 0];
case "i8":
return n[a >> 0];
case "i16":
return Ma[a >> 1];
case "i32":
return N[a >> 2];
case "i64":
return N[a >> 2];
case "float":
return Na[a >> 2];
case "double":
return Number(Oa[a >> 3]);
default:
J("invalid type for getValue: " + b);
}
return null;
}
var Pa,
Qa = !1;
function Ra(a) {
var b = e["_" + a];
b ||
J(
"Assertion failed: Cannot call unknown function " +
(a + ", make sure it is exported")
);
return b;
}
function Sa(a, b, c, d) {
var f = {
string: function (v) {
var C = 0;
if (null !== v && void 0 !== v && 0 !== v) {
var G = (v.length << 2) + 1;
C = B(G);
t(v, y, C, G);
}
return C;
},
array: function (v) {
var C = B(v.length);
n.set(v, C);
return C;
},
};
a = Ra(a);
var h = [],
l = 0;
if (d)
for (var q = 0; q < d.length; q++) {
var w = f[c[q]];
w ? (0 === l && (l = oa()), (h[q] = w(d[q]))) : (h[q] = d[q]);
}
c = a.apply(null, h);
return (c = (function (v) {
0 !== l && qa(l);
return "string" === b ? D(v) : "boolean" === b ? !!v : v;
})(c));
}
var ca = 0,
Ta = 1;
function ba(a, b) {
b = b == Ta ? B(a.length) : fa(a.length);
a.subarray || a.slice ? y.set(a, b) : y.set(new Uint8Array(a), b);
return b;
}
var Va =
"undefined" !== typeof TextDecoder ? new TextDecoder("utf8") : void 0;
function Wa(a, b, c) {
var d = b + c;
for (c = b; a[c] && !(c >= d); ) ++c;
if (16 < c - b && a.subarray && Va) return Va.decode(a.subarray(b, c));
for (d = ""; b < c; ) {
var f = a[b++];
if (f & 128) {
var h = a[b++] & 63;
if (192 == (f & 224)) d += String.fromCharCode(((f & 31) << 6) | h);
else {
var l = a[b++] & 63;
f =
224 == (f & 240)
? ((f & 15) << 12) | (h << 6) | l
: ((f & 7) << 18) | (h << 12) | (l << 6) | (a[b++] & 63);
65536 > f
? (d += String.fromCharCode(f))
: ((f -= 65536),
(d += String.fromCharCode(
55296 | (f >> 10),
56320 | (f & 1023)
)));
}
} else d += String.fromCharCode(f);
}
return d;
}
function D(a, b) {
return a ? Wa(y, a, b) : "";
}
function t(a, b, c, d) {
if (!(0 < d)) return 0;
var f = c;
d = c + d - 1;
for (var h = 0; h < a.length; ++h) {
var l = a.charCodeAt(h);
if (55296 <= l && 57343 >= l) {
var q = a.charCodeAt(++h);
l = (65536 + ((l & 1023) << 10)) | (q & 1023);
}
if (127 >= l) {
if (c >= d) break;
b[c++] = l;
} else {
if (2047 >= l) {
if (c + 1 >= d) break;
b[c++] = 192 | (l >> 6);
} else {
if (65535 >= l) {
if (c + 2 >= d) break;
b[c++] = 224 | (l >> 12);
} else {
if (c + 3 >= d) break;
b[c++] = 240 | (l >> 18);
b[c++] = 128 | ((l >> 12) & 63);
}
b[c++] = 128 | ((l >> 6) & 63);
}
b[c++] = 128 | (l & 63);
}
}
b[c] = 0;
return c - f;
}
function ea(a) {
for (var b = 0, c = 0; c < a.length; ++c) {
var d = a.charCodeAt(c);
55296 <= d &&
57343 >= d &&
(d = (65536 + ((d & 1023) << 10)) | (a.charCodeAt(++c) & 1023));
127 >= d ? ++b : (b = 2047 >= d ? b + 2 : 65535 >= d ? b + 3 : b + 4);
}
return b;
}
function Xa(a) {
var b = ea(a) + 1,
c = fa(b);
c && t(a, n, c, b);
return c;
}
function ra(a) {
var b = ea(a) + 1,
c = B(b);
t(a, n, c, b);
return c;
}
var Ya, n, y, Ma, N, Na, Oa;
function Za() {
var a = Pa.buffer;
Ya = a;
e.HEAP8 = n = new Int8Array(a);
e.HEAP16 = Ma = new Int16Array(a);
e.HEAP32 = N = new Int32Array(a);
e.HEAPU8 = y = new Uint8Array(a);
e.HEAPU16 = new Uint16Array(a);
e.HEAPU32 = new Uint32Array(a);
e.HEAPF32 = Na = new Float32Array(a);
e.HEAPF64 = Oa = new Float64Array(a);
}
var L,
$a = [],
ab = [],
bb = [];
function cb() {
var a = e.preRun.shift();
$a.unshift(a);
}
var db = 0,
eb = null,
fb = null;
e.preloadedImages = {};
e.preloadedAudios = {};
function J(a) {
if (e.onAbort) e.onAbort(a);
a = "Aborted(" + a + ")";
Ia(a);
Qa = !0;
throw new WebAssembly.RuntimeError(
a + ". Build with -s ASSERTIONS=1 for more info."
);
}
function gb() {
return Q.startsWith("data:application/octet-stream;base64,");
}
var Q;