@atrament/web 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,4117 @@
1
+ const we = {};
2
+ let He = "";
3
+ function ut(t) {
4
+ return `${He}${t}`;
5
+ }
6
+ function ao() {
7
+ He = "", Object.keys(we).forEach((t) => delete we[t]);
8
+ }
9
+ function io(t) {
10
+ He = `>>${t}<<`;
11
+ }
12
+ async function so(t) {
13
+ return !!we[ut(t)];
14
+ }
15
+ async function uo(t) {
16
+ return JSON.parse(we[ut(t)]);
17
+ }
18
+ async function fo(t, o) {
19
+ we[ut(t)] = JSON.stringify(o);
20
+ }
21
+ async function co(t) {
22
+ delete we[ut(t)];
23
+ }
24
+ async function lo() {
25
+ return Object.keys(we).filter((t) => t.includes(He)).map((t) => t.replace(He, ""));
26
+ }
27
+ const _o = {
28
+ gameState: we,
29
+ reset: ao,
30
+ init: io,
31
+ exists: so,
32
+ get: uo,
33
+ set: fo,
34
+ remove: co,
35
+ keys: lo
36
+ }, po = {
37
+ init: () => {
38
+ },
39
+ mute: () => {
40
+ },
41
+ isMuted: () => {
42
+ },
43
+ setVolume: () => {
44
+ },
45
+ getVolume: () => {
46
+ },
47
+ playSound: () => {
48
+ },
49
+ playMusic: () => {
50
+ },
51
+ stopMusic: () => {
52
+ }
53
+ }, j = {
54
+ settings: {},
55
+ game: {},
56
+ metadata: {},
57
+ scenes: [],
58
+ vars: {}
59
+ };
60
+ function vo() {
61
+ j.settings = {}, j.game = {}, j.metadata = {}, j.scenes = [], j.vars = {};
62
+ }
63
+ function mo() {
64
+ return j;
65
+ }
66
+ function ho() {
67
+ return JSON.parse(JSON.stringify(j));
68
+ }
69
+ function go(t, o) {
70
+ j[t] = o;
71
+ }
72
+ function yo(t) {
73
+ j[t] = !j[t];
74
+ }
75
+ function wo(t, o) {
76
+ j[t] = [...j[t], o];
77
+ }
78
+ function bo(t, o, n) {
79
+ j[t] = { ...j[t], [o]: n };
80
+ }
81
+ function Ao(t, o) {
82
+ j[t] = { ...j[t], [o]: !j[t][o] };
83
+ }
84
+ function So(t, o, n) {
85
+ j[t] = { ...j[t], [o]: [...j[t][o], n] };
86
+ }
87
+ const xo = {
88
+ reset: vo,
89
+ store: mo,
90
+ get: ho,
91
+ setKey: go,
92
+ toggleKey: yo,
93
+ appendKey: wo,
94
+ setSubkey: bo,
95
+ toggleSubkey: Ao,
96
+ appendSubkey: So
97
+ };
98
+ let kt = {
99
+ loader: null,
100
+ persistent: _o,
101
+ sound: po,
102
+ state: xo
103
+ };
104
+ const M = () => kt;
105
+ function To(t) {
106
+ kt = { ...kt, ...t };
107
+ }
108
+ const Rt = {
109
+ settings: {
110
+ volume: 0,
111
+ mute: !0
112
+ }
113
+ };
114
+ function ft() {
115
+ return Rt;
116
+ }
117
+ function Io(t, o = {}) {
118
+ if (!t)
119
+ throw new Error("atrament.init: provide ink Story constructor as a first argument!");
120
+ if (typeof t != "function")
121
+ throw new Error("atrament.init: Story is not a constructor!");
122
+ if (!o.applicationID)
123
+ throw new Error("atrament.init: config.applicationID is not set!");
124
+ Rt.InkStory = t, Object.entries(o).forEach(([n, a]) => {
125
+ Rt[n] = JSON.parse(JSON.stringify(a));
126
+ });
127
+ }
128
+ function Eo(t) {
129
+ return { all: t = t || /* @__PURE__ */ new Map(), on: function(o, n) {
130
+ var a = t.get(o);
131
+ a ? a.push(n) : t.set(o, [n]);
132
+ }, off: function(o, n) {
133
+ var a = t.get(o);
134
+ a && (n ? a.splice(a.indexOf(n) >>> 0, 1) : t.set(o, []));
135
+ }, emit: function(o, n) {
136
+ var a = t.get(o);
137
+ a && a.slice().map(function(f) {
138
+ f(n);
139
+ }), (a = t.get("*")) && a.slice().map(function(f) {
140
+ f(o, n);
141
+ });
142
+ } };
143
+ }
144
+ const Pt = Eo(), H = (...t) => Pt.emit(...t);
145
+ function be(t) {
146
+ return Array.isArray(t) ? t : [t];
147
+ }
148
+ function Oo(t) {
149
+ return [...t].reduce((o, n) => Math.imul(31, o) + n.charCodeAt(0) | 0, 0);
150
+ }
151
+ async function Dn(t) {
152
+ const { persistent: o } = M(), n = await o.keys();
153
+ await Promise.all(
154
+ n.map(
155
+ async (a) => {
156
+ if (!a.includes("save"))
157
+ return;
158
+ const f = await o.get(a);
159
+ await t(a, f);
160
+ }
161
+ )
162
+ );
163
+ }
164
+ function De(t) {
165
+ return typeof t == "number" || typeof t == "string" ? t : "";
166
+ }
167
+ function Do() {
168
+ const { state: t } = M();
169
+ return De(t.get().game.$sessionID);
170
+ }
171
+ function Co(t) {
172
+ const { state: o } = M(), n = De(t);
173
+ o.setSubkey("game", "$sessionID", n), H("game/setSession", n);
174
+ }
175
+ async function ko() {
176
+ const t = {};
177
+ return await Dn(async (o, n) => {
178
+ const a = De(n.game.$sessionID);
179
+ t[a] ? t[a] += 1 : t[a] = 1;
180
+ }), H("game/getSessions", t), t;
181
+ }
182
+ async function Ro(t) {
183
+ const { persistent: o } = M(), n = De(t);
184
+ await Dn(async (a, f) => {
185
+ De(f.game.$sessionID) === n && await o.remove(a);
186
+ }), H("game/deleteSession", n);
187
+ }
188
+ function Bt(t) {
189
+ if (!t)
190
+ return {};
191
+ const o = {};
192
+ return t.forEach((n) => {
193
+ let a, f;
194
+ const v = n.match(/\s*(\w+)\s*:\s*(.+?)\s*$/);
195
+ if (v) {
196
+ const [, h, b] = v;
197
+ a = h;
198
+ try {
199
+ f = JSON.parse(b);
200
+ } catch {
201
+ const A = b.substr(0, 1);
202
+ A === "{" || A === "[" ? console.warn("Malformed JSON tag, ignored.", h, b) : f = b;
203
+ }
204
+ } else
205
+ a = n, f = !0;
206
+ Array.isArray(o[a]) ? o[a].push(f) : o[a] ? o[a] = [o[a], f] : o[a] = f;
207
+ }), o;
208
+ }
209
+ let q = null;
210
+ function Po(t) {
211
+ const { InkStory: o } = ft();
212
+ q = new o(t), H("ink/initStory");
213
+ }
214
+ function No() {
215
+ let t = !1;
216
+ q && (q.ResetState(), t = !0), H("ink/resetStory", t);
217
+ }
218
+ function Nt(t, o) {
219
+ if (!t.canContinue)
220
+ return;
221
+ t.Continue();
222
+ const n = t.currentText;
223
+ n && n !== `
224
+ ` && (o.isEmpty = !1), o.text.push(n);
225
+ const a = Bt(t.currentTags);
226
+ o.tags = { ...o.tags, ...a }, o.content.push({ text: n, tags: a }), n === `
227
+ ` && Nt(t, o);
228
+ }
229
+ function Lo(t) {
230
+ const o = {
231
+ content: [],
232
+ text: [],
233
+ tags: {},
234
+ choices: [],
235
+ isEmpty: !0,
236
+ uuid: Date.now()
237
+ };
238
+ if (t)
239
+ for (; q.canContinue; )
240
+ Nt(q, o);
241
+ else
242
+ Nt(q, o), o.canContinue = q.canContinue;
243
+ return q.currentChoices.forEach((n, a) => {
244
+ o.choices.push({
245
+ id: a,
246
+ choice: n.text,
247
+ tags: Bt(n.tags)
248
+ });
249
+ }), H("ink/getScene", o), o;
250
+ }
251
+ const ne = {
252
+ initStory: Po,
253
+ resetStory: No,
254
+ story: () => q,
255
+ loadState: (t) => q.state.LoadJson(t),
256
+ getState: () => q.state.toJson(),
257
+ makeChoice: (t) => {
258
+ q.ChooseChoiceIndex(t), H("ink/makeChoice", t);
259
+ },
260
+ getVisitCount: (t) => {
261
+ const o = q.VisitCountAtPathString(t);
262
+ return H("ink/getVisitCount", { ref: t, visitCount: o }), o;
263
+ },
264
+ evaluateFunction: (t, o, n) => {
265
+ const a = q.EvaluateFunction(t, o, n);
266
+ return H("ink/evaluateFunction", { function: t, args: o, result: a }), a;
267
+ },
268
+ getGlobalTags: () => {
269
+ const t = Bt(q.globalTags);
270
+ return H("ink/getGlobalTags", t), t;
271
+ },
272
+ getVariable: (t) => {
273
+ const o = q.variablesState[t];
274
+ return H("ink/getVariable", { name: t, value: o }), o;
275
+ },
276
+ getVariables: () => {
277
+ const t = q.variablesState, o = {};
278
+ return t._globalVariables.forEach(
279
+ /* eslint-disable-line no-underscore-dangle */
280
+ (n, a) => {
281
+ o[a] = t[a];
282
+ }
283
+ ), H("ink/getVariables", o), o;
284
+ },
285
+ setVariable: (t, o) => {
286
+ q.variablesState[t] = o, H("ink/setVariable", { name: t, value: o });
287
+ },
288
+ observeVariable: (t, o) => q.ObserveVariable(t, o),
289
+ goTo: (t) => {
290
+ q.ChoosePathString(t), H("ink/goTo", t);
291
+ },
292
+ onError: (t) => {
293
+ q.onError = (o) => {
294
+ H("ink/onError", o), t(o);
295
+ };
296
+ },
297
+ getScene: Lo
298
+ };
299
+ function gn(t) {
300
+ const { sound: o, loader: n } = M();
301
+ be(t).forEach(
302
+ (a) => o.playSound(n.getAssetPath(a))
303
+ );
304
+ }
305
+ function xt(t) {
306
+ const { sound: o, loader: n } = M();
307
+ be(t).forEach(
308
+ (a) => o.stopSound(a ? n.getAssetPath(a) : null)
309
+ );
310
+ }
311
+ function Cn(t) {
312
+ const { sound: o, state: n, loader: a } = M(), f = n.get().game.$currentMusic || [];
313
+ be(t).forEach((v) => {
314
+ o.playMusic(a.getAssetPath(v)), f.push(v);
315
+ }), n.setSubkey("game", "$currentMusic", f);
316
+ }
317
+ function Mo(t) {
318
+ const { sound: o, state: n, loader: a } = M();
319
+ o.stopMusic();
320
+ const f = be(t).pop();
321
+ o.playMusic(a.getAssetPath(f)), n.setSubkey("game", "$currentMusic", [f]);
322
+ }
323
+ function $e(t) {
324
+ const { sound: o, state: n, loader: a } = M();
325
+ let f = n.get().game.$currentMusic || [];
326
+ be(t).forEach((v) => {
327
+ v ? (o.stopMusic(a.getAssetPath(v)), f = f.filter((h) => h !== v)) : (o.stopMusic(), f = []);
328
+ }), n.setSubkey("game", "$currentMusic", f);
329
+ }
330
+ const it = "game", ct = "autosave", lt = "checkpoint";
331
+ function $t(t) {
332
+ const { $gameUUID: o, $sessionID: n } = M().state.get().game;
333
+ return [
334
+ o,
335
+ De(n),
336
+ t
337
+ ].join("/");
338
+ }
339
+ function Ge({ name: t, type: o }) {
340
+ return [
341
+ $t("save"),
342
+ [it, ct, lt].includes(o) ? o : it,
343
+ typeof t == "string" || typeof t == "number" ? t : ""
344
+ ].join("/");
345
+ }
346
+ function kn(t) {
347
+ const { state: o } = M();
348
+ o.setKey("scenes", t.scenes), o.setKey("game", t.game), ne.loadState(t.state);
349
+ }
350
+ async function Rn(t) {
351
+ let o = t;
352
+ typeof t == "object" && (o = Ge(t));
353
+ const { persistent: n } = M(), a = await n.get(o);
354
+ kn(a), H("game/load", o);
355
+ }
356
+ function Pn() {
357
+ const { state: t } = M(), o = t.get();
358
+ return {
359
+ date: Date.now(),
360
+ state: ne.getState(),
361
+ game: o.game,
362
+ scenes: o.scenes
363
+ };
364
+ }
365
+ async function Ht({ name: t, type: o }) {
366
+ const { persistent: n } = M(), a = Pn(), f = {
367
+ name: t,
368
+ type: o,
369
+ ...a
370
+ }, v = Ge({ name: t, type: o });
371
+ await n.set(v, f), H("game/save", v);
372
+ }
373
+ async function Vt(t) {
374
+ return await M().persistent.exists(t);
375
+ }
376
+ async function Fo(t) {
377
+ await M().persistent.remove(t), H("game/removeSave", t);
378
+ }
379
+ async function Nn() {
380
+ const { persistent: t } = M(), o = (await t.keys()).filter((a) => a.includes($t("save"))), n = await Promise.all(
381
+ o.map(
382
+ async (a) => {
383
+ const f = await t.get(a);
384
+ return f.id = a, delete f.state, delete f.scenes, f;
385
+ }
386
+ )
387
+ );
388
+ return H("game/listSaves", n), n;
389
+ }
390
+ function Fe(t, o, n) {
391
+ t[n] || (t[n] = []), t.content = t.content.map((a) => {
392
+ a[n] || (a[n] = []);
393
+ const f = a.tags?.[o];
394
+ if (f) {
395
+ const v = be(f);
396
+ t[n] = [...t[n], ...v], a[n] = [...a[n], ...v];
397
+ }
398
+ return a;
399
+ });
400
+ }
401
+ function Bo(t) {
402
+ t.choices = t.choices.map((o) => ((o.tags.UNCLICKABLE || o.tags.DISABLED || o.tags.INACTIVE) && (o.disabled = !0), o));
403
+ }
404
+ const $o = [
405
+ (t) => Fe(t, "IMAGE", "images"),
406
+ (t) => Fe(t, "AUDIO", "sounds"),
407
+ (t) => Fe(t, "PLAY_SOUND", "sounds"),
408
+ (t) => Fe(t, "AUDIOLOOP", "music"),
409
+ (t) => Fe(t, "PLAY_MUSIC", "music"),
410
+ Bo
411
+ ];
412
+ let Ut = null, Ln = null;
413
+ const Mn = [], Ie = {};
414
+ function Fn() {
415
+ const { state: t } = M();
416
+ t.setKey("scenes", []), t.setKey("vars", {});
417
+ }
418
+ function Bn(t) {
419
+ const { state: o } = M(), n = o.get().metadata.observe;
420
+ n && be(n).forEach(t);
421
+ }
422
+ async function Ho() {
423
+ const { state: t, persistent: o } = M(), { game: n, metadata: a } = t.get(), f = a.persist;
424
+ if (f) {
425
+ const v = $t("persist");
426
+ await o.exists(v) ? (Ie[n.$gameUUID] = await o.get(v), Object.entries(Ie[n.$gameUUID]).forEach(
427
+ ([h, b]) => ne.setVariable(h, b)
428
+ )) : Ie[n.$gameUUID] || (Ie[n.$gameUUID] = {}), be(f).forEach((h) => {
429
+ ne.observeVariable(h, async (b, A) => {
430
+ Ie[n.$gameUUID][b] = A, await o.set(v, Ie[n.$gameUUID]);
431
+ });
432
+ });
433
+ }
434
+ }
435
+ async function Vo(t, o, n) {
436
+ await M().loader.init(t);
437
+ const a = {
438
+ $path: t,
439
+ $file: o,
440
+ $gameUUID: n || Oo(`${t}|${o}`)
441
+ };
442
+ M().state.setKey("game", a), Ut = a.$gameUUID, H("game/init", { pathToInkFile: t, inkFile: o });
443
+ }
444
+ async function $n() {
445
+ const { game: t } = M().state.get();
446
+ let o = await M().loader.loadInk(t.$file);
447
+ if (typeof o == "string")
448
+ try {
449
+ o = JSON.parse(o.replace("\uFEFF", ""));
450
+ } catch (n) {
451
+ throw console.error(n), Error(`Failed to parse Ink script: ${t.$path}/${t.$file}`);
452
+ }
453
+ return H("game/loadInkFile", t.$file), o;
454
+ }
455
+ async function Hn() {
456
+ const { state: t } = M(), o = await $n();
457
+ ne.initStory(o);
458
+ const n = ne.getGlobalTags();
459
+ t.setKey("metadata", n), Bn((a) => {
460
+ ne.observeVariable(a, (f, v) => {
461
+ t.setSubkey("vars", f, v), H("ink/variableObserver", { name: f, value: v });
462
+ });
463
+ }), Ln = Ut, H("game/initInkStory");
464
+ }
465
+ async function Gt(t) {
466
+ const { state: o } = M();
467
+ $e(), Fn(), Ln !== Ut && await Hn();
468
+ let n = !0;
469
+ if (t && await Vt(t)) {
470
+ await Rn(t);
471
+ const { game: a } = o.get();
472
+ a.$currentMusic && Cn(a.$currentMusic), n = !1;
473
+ }
474
+ await Ho(), Bn((a) => {
475
+ o.setSubkey("vars", a, ne.getVariable(a));
476
+ }), H("game/start", { saveSlot: t }), (n || !n && o.get().metadata.continue_maximally !== !1) && qn();
477
+ }
478
+ async function Vn() {
479
+ let t = null;
480
+ const o = Ge({ type: ct });
481
+ if (await Vt(o))
482
+ t = o;
483
+ else {
484
+ const n = (await Nn()).filter((a) => a.type === lt);
485
+ n.length && (t = n.sort((a, f) => f.date - a.date)[0].id);
486
+ }
487
+ return H("game/canResume", t), t;
488
+ }
489
+ async function Uo() {
490
+ const t = await Vn();
491
+ H("game/resume", { saveSlot: t }), ne.resetStory(), await Gt(t);
492
+ }
493
+ async function Kt(t) {
494
+ H("game/restart", { saveSlot: t }), ne.resetStory(), await Gt(t);
495
+ }
496
+ async function Un(t) {
497
+ await Kt(Ge({ type: "checkpoint", name: t }));
498
+ }
499
+ function Gn() {
500
+ $e(), Fn(), ne.resetStory(), H("game/clear");
501
+ }
502
+ function Go() {
503
+ const { state: t } = M();
504
+ Gn(), t.setKey("metadata", {}), t.setKey("game", {}), H("game/reset");
505
+ }
506
+ async function Kn(t) {
507
+ await Ht({ type: it, name: t });
508
+ }
509
+ async function Yn(t) {
510
+ await Ht({ type: lt, name: t });
511
+ }
512
+ async function Wn() {
513
+ await Ht({ type: ct });
514
+ }
515
+ const yn = {
516
+ CLEAR: () => M().state.setKey("scenes", []),
517
+ AUDIO: (t) => t ? gn(t) : xt(),
518
+ AUDIOLOOP: (t) => t ? Mo(t) : $e(),
519
+ PLAY_SOUND: gn,
520
+ STOP_SOUND: (t) => t === !0 ? xt() : xt(t),
521
+ PLAY_MUSIC: Cn,
522
+ STOP_MUSIC: (t) => t === !0 ? $e() : $e(t),
523
+ CHECKPOINT: (t) => Yn(t),
524
+ SAVEGAME: (t) => Kn(t)
525
+ };
526
+ function wn(t, o) {
527
+ t.forEach((n) => {
528
+ n in o && n in yn && (yn[n](o[n]), H("game/handletag", { [n]: o[n] }));
529
+ });
530
+ }
531
+ function Ko(t) {
532
+ Mn.push(t);
533
+ }
534
+ function qn() {
535
+ const { state: t } = M(), { metadata: o } = t.get(), n = o.continue_maximally !== !1, a = ne.getScene(n);
536
+ if (!a.content || a.content.length === 0)
537
+ return;
538
+ $o.forEach((v) => v(a)), Mn.forEach((v) => v(a));
539
+ const { tags: f } = a;
540
+ if (f.RESTART) {
541
+ Kt();
542
+ return;
543
+ }
544
+ if (f.RESTART_FROM_CHECKPOINT) {
545
+ Un(f.RESTART_FROM_CHECKPOINT);
546
+ return;
547
+ }
548
+ wn(
549
+ ["CLEAR", "STOP_SOUND", "STOP_MUSIC", "PLAY_SOUND", "PLAY_MUSIC", "AUDIO", "AUDIOLOOP"],
550
+ f
551
+ ), o.single_scene ? t.setKey("scenes", [a]) : t.appendKey("scenes", a), wn(
552
+ ["CHECKPOINT", "SAVEGAME"],
553
+ f
554
+ ), o.autosave !== !1 && Wn(), H("game/continueStory");
555
+ }
556
+ const Yo = {
557
+ // game-control
558
+ init: Vo,
559
+ loadInkFile: $n,
560
+ initInkStory: Hn,
561
+ start: Gt,
562
+ clear: Gn,
563
+ reset: Go,
564
+ // game
565
+ resume: Uo,
566
+ canResume: Vn,
567
+ restart: Kt,
568
+ restartFromCheckpoint: Un,
569
+ continueStory: qn,
570
+ makeChoice: (t) => ne.makeChoice(t),
571
+ getAssetPath: (t) => M().loader.getAssetPath(t),
572
+ defineSceneProcessor: Ko,
573
+ // saves
574
+ SAVE_GAME: it,
575
+ SAVE_AUTOSAVE: ct,
576
+ SAVE_CHECKPOINT: lt,
577
+ getSaveSlotKey: Ge,
578
+ saveGame: Kn,
579
+ saveCheckpoint: Yn,
580
+ saveAutosave: Wn,
581
+ load: Rn,
582
+ getState: Pn,
583
+ setState: kn,
584
+ listSaves: Nn,
585
+ removeSave: Fo,
586
+ existSave: Vt,
587
+ // sessions
588
+ getSession: Do,
589
+ setSession: Co,
590
+ getSessions: ko,
591
+ removeSession: Ro
592
+ }, Ve = {
593
+ mute: (t, o) => M().sound.mute(o),
594
+ volume: (t, o) => M().sound.setVolume(o)
595
+ };
596
+ async function Wo() {
597
+ const { state: t, persistent: o } = M(), n = JSON.parse(JSON.stringify(ft().settings));
598
+ let a = {};
599
+ await o.exists("settings") && (a = await o.get("settings"));
600
+ const f = { ...n, ...a };
601
+ t.setKey("settings", f), Yt(), H("settings/load", f);
602
+ }
603
+ async function qo() {
604
+ const { state: t, persistent: o } = M(), n = t.get();
605
+ await o.set("settings", n.settings), H("settings/save", n.settings);
606
+ }
607
+ function Jn(t) {
608
+ const o = M().state.get().settings[t];
609
+ return H("settings/get", { name: t, value: o }), o;
610
+ }
611
+ function Xn(t, o) {
612
+ const { state: n } = M(), a = n.get().settings[t];
613
+ n.setSubkey("settings", t, o), Ve[t] && Ve[t](a, o), H("settings/set", { name: t, value: o });
614
+ }
615
+ function Jo(t) {
616
+ const o = Jn(t);
617
+ Xn(t, !o);
618
+ }
619
+ function Xo(t, o) {
620
+ Ve[t] = o;
621
+ }
622
+ function Yt() {
623
+ const t = M().state.get().settings;
624
+ Object.entries(t).forEach(([o, n]) => {
625
+ Ve[o] && Ve[o](null, n);
626
+ });
627
+ }
628
+ function Qo() {
629
+ const { state: t } = M(), o = JSON.parse(JSON.stringify(ft().settings));
630
+ t.setKey("settings", o), Yt(), H("settings/reset", o);
631
+ }
632
+ const Qn = {
633
+ load: Wo,
634
+ save: qo,
635
+ get: Jn,
636
+ set: Xn,
637
+ toggle: Jo,
638
+ defineHandler: Xo,
639
+ runHandlers: Yt,
640
+ reset: Qo
641
+ }, jo = "2.1.4";
642
+ async function Zo(t, o) {
643
+ H("atrament/init");
644
+ const { persistent: n } = M();
645
+ Io(t, o), n.init(ft().applicationID), await Qn.load();
646
+ }
647
+ const zo = {
648
+ get interfaces() {
649
+ return M();
650
+ },
651
+ defineInterfaces: To,
652
+ init: Zo,
653
+ get state() {
654
+ return M().state;
655
+ },
656
+ get store() {
657
+ return M().state.store();
658
+ },
659
+ on: (t, o) => Pt.on(t, o),
660
+ off: (t, o) => Pt.off(t, o),
661
+ // sub-objects
662
+ game: Yo,
663
+ ink: ne,
664
+ settings: Qn,
665
+ version: jo
666
+ };
667
+ var bn = {}, ea = (function(t, o, n, a, f) {
668
+ var v = new Worker(bn[o] || (bn[o] = URL.createObjectURL(new Blob([
669
+ t + ';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'
670
+ ], { type: "text/javascript" }))));
671
+ return v.onmessage = function(h) {
672
+ var b = h.data, A = b.$e$;
673
+ if (A) {
674
+ var S = new Error(A[0]);
675
+ S.code = A[1], S.stack = A[2], f(S, null);
676
+ } else
677
+ f(null, b);
678
+ }, v.postMessage(n, a), v;
679
+ }), z = Uint8Array, Se = Uint16Array, jn = Int32Array, Wt = new z([
680
+ 0,
681
+ 0,
682
+ 0,
683
+ 0,
684
+ 0,
685
+ 0,
686
+ 0,
687
+ 0,
688
+ 1,
689
+ 1,
690
+ 1,
691
+ 1,
692
+ 2,
693
+ 2,
694
+ 2,
695
+ 2,
696
+ 3,
697
+ 3,
698
+ 3,
699
+ 3,
700
+ 4,
701
+ 4,
702
+ 4,
703
+ 4,
704
+ 5,
705
+ 5,
706
+ 5,
707
+ 5,
708
+ 0,
709
+ /* unused */
710
+ 0,
711
+ 0,
712
+ /* impossible */
713
+ 0
714
+ ]), qt = new z([
715
+ 0,
716
+ 0,
717
+ 0,
718
+ 0,
719
+ 1,
720
+ 1,
721
+ 2,
722
+ 2,
723
+ 3,
724
+ 3,
725
+ 4,
726
+ 4,
727
+ 5,
728
+ 5,
729
+ 6,
730
+ 6,
731
+ 7,
732
+ 7,
733
+ 8,
734
+ 8,
735
+ 9,
736
+ 9,
737
+ 10,
738
+ 10,
739
+ 11,
740
+ 11,
741
+ 12,
742
+ 12,
743
+ 13,
744
+ 13,
745
+ /* unused */
746
+ 0,
747
+ 0
748
+ ]), Zn = new z([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), zn = function(t, o) {
749
+ for (var n = new Se(31), a = 0; a < 31; ++a)
750
+ n[a] = o += 1 << t[a - 1];
751
+ for (var f = new jn(n[30]), a = 1; a < 30; ++a)
752
+ for (var v = n[a]; v < n[a + 1]; ++v)
753
+ f[v] = v - n[a] << 5 | a;
754
+ return { b: n, r: f };
755
+ }, er = zn(Wt, 2), Jt = er.b, ta = er.r;
756
+ Jt[28] = 258, ta[258] = 28;
757
+ var na = zn(qt, 0), tr = na.b, st = new Se(32768);
758
+ for (var K = 0; K < 32768; ++K) {
759
+ var he = (K & 43690) >> 1 | (K & 21845) << 1;
760
+ he = (he & 52428) >> 2 | (he & 13107) << 2, he = (he & 61680) >> 4 | (he & 3855) << 4, st[K] = ((he & 65280) >> 8 | (he & 255) << 8) >> 1;
761
+ }
762
+ var Ee = (function(t, o, n) {
763
+ for (var a = t.length, f = 0, v = new Se(o); f < a; ++f)
764
+ t[f] && ++v[t[f] - 1];
765
+ var h = new Se(o);
766
+ for (f = 1; f < o; ++f)
767
+ h[f] = h[f - 1] + v[f - 1] << 1;
768
+ var b;
769
+ if (n) {
770
+ b = new Se(1 << o);
771
+ var A = 15 - o;
772
+ for (f = 0; f < a; ++f)
773
+ if (t[f])
774
+ for (var S = f << 4 | t[f], C = o - t[f], e = h[t[f] - 1]++ << C, r = e | (1 << C) - 1; e <= r; ++e)
775
+ b[st[e] >> A] = S;
776
+ } else
777
+ for (b = new Se(a), f = 0; f < a; ++f)
778
+ t[f] && (b[f] = st[h[t[f] - 1]++] >> 15 - t[f]);
779
+ return b;
780
+ }), Ke = new z(288);
781
+ for (var K = 0; K < 144; ++K)
782
+ Ke[K] = 8;
783
+ for (var K = 144; K < 256; ++K)
784
+ Ke[K] = 9;
785
+ for (var K = 256; K < 280; ++K)
786
+ Ke[K] = 7;
787
+ for (var K = 280; K < 288; ++K)
788
+ Ke[K] = 8;
789
+ var nr = new z(32);
790
+ for (var K = 0; K < 32; ++K)
791
+ nr[K] = 5;
792
+ var rr = /* @__PURE__ */ Ee(Ke, 9, 1), or = /* @__PURE__ */ Ee(nr, 5, 1), nt = function(t) {
793
+ for (var o = t[0], n = 1; n < t.length; ++n)
794
+ t[n] > o && (o = t[n]);
795
+ return o;
796
+ }, oe = function(t, o, n) {
797
+ var a = o / 8 | 0;
798
+ return (t[a] | t[a + 1] << 8) >> (o & 7) & n;
799
+ }, rt = function(t, o) {
800
+ var n = o / 8 | 0;
801
+ return (t[n] | t[n + 1] << 8 | t[n + 2] << 16) >> (o & 7);
802
+ }, ar = function(t) {
803
+ return (t + 7) / 8 | 0;
804
+ }, dt = function(t, o, n) {
805
+ return (o == null || o < 0) && (o = 0), (n == null || n > t.length) && (n = t.length), new z(t.subarray(o, n));
806
+ }, ir = [
807
+ "unexpected EOF",
808
+ "invalid block type",
809
+ "invalid length/literal",
810
+ "invalid distance",
811
+ "stream finished",
812
+ "no stream handler",
813
+ ,
814
+ "no callback",
815
+ "invalid UTF-8 data",
816
+ "extra field too long",
817
+ "date not in range 1980-2099",
818
+ "filename too long",
819
+ "stream finishing",
820
+ "invalid zip data"
821
+ // determined by unknown compression method
822
+ ], Z = function(t, o, n) {
823
+ var a = new Error(o || ir[t]);
824
+ if (a.code = t, Error.captureStackTrace && Error.captureStackTrace(a, Z), !n)
825
+ throw a;
826
+ return a;
827
+ }, sr = function(t, o, n, a) {
828
+ var f = t.length, v = a ? a.length : 0;
829
+ if (!f || o.f && !o.l)
830
+ return n || new z(0);
831
+ var h = !n, b = h || o.i != 2, A = o.i;
832
+ h && (n = new z(f * 3));
833
+ var S = function(Je) {
834
+ var Xe = n.length;
835
+ if (Je > Xe) {
836
+ var Qe = new z(Math.max(Xe * 2, Je));
837
+ Qe.set(n), n = Qe;
838
+ }
839
+ }, C = o.f || 0, e = o.p || 0, r = o.b || 0, s = o.l, d = o.d, y = o.m, g = o.n, m = f * 8;
840
+ do {
841
+ if (!s) {
842
+ C = oe(t, e, 1);
843
+ var O = oe(t, e + 1, 3);
844
+ if (e += 3, O)
845
+ if (O == 1)
846
+ s = rr, d = or, y = 9, g = 5;
847
+ else if (O == 2) {
848
+ var L = oe(t, e, 31) + 257, N = oe(t, e + 10, 15) + 4, F = L + oe(t, e + 5, 31) + 1;
849
+ e += 14;
850
+ for (var R = new z(F), Y = new z(19), V = 0; V < N; ++V)
851
+ Y[Zn[V]] = oe(t, e + V * 3, 7);
852
+ e += N * 3;
853
+ for (var X = nt(Y), ee = (1 << X) - 1, te = Ee(Y, X, 1), V = 0; V < F; ) {
854
+ var de = te[oe(t, e, ee)];
855
+ e += de & 15;
856
+ var P = de >> 4;
857
+ if (P < 16)
858
+ R[V++] = P;
859
+ else {
860
+ var fe = 0, ae = 0;
861
+ for (P == 16 ? (ae = 3 + oe(t, e, 3), e += 2, fe = R[V - 1]) : P == 17 ? (ae = 3 + oe(t, e, 7), e += 3) : P == 18 && (ae = 11 + oe(t, e, 127), e += 7); ae--; )
862
+ R[V++] = fe;
863
+ }
864
+ }
865
+ var Re = R.subarray(0, L), ce = R.subarray(L);
866
+ y = nt(Re), g = nt(ce), s = Ee(Re, y, 1), d = Ee(ce, g, 1);
867
+ } else
868
+ Z(1);
869
+ else {
870
+ var P = ar(e) + 4, $ = t[P - 4] | t[P - 3] << 8, E = P + $;
871
+ if (E > f) {
872
+ A && Z(0);
873
+ break;
874
+ }
875
+ b && S(r + $), n.set(t.subarray(P, E), r), o.b = r += $, o.p = e = E * 8, o.f = C;
876
+ continue;
877
+ }
878
+ if (e > m) {
879
+ A && Z(0);
880
+ break;
881
+ }
882
+ }
883
+ b && S(r + 131072);
884
+ for (var _t = (1 << y) - 1, ie = (1 << g) - 1, xe = e; ; xe = e) {
885
+ var fe = s[rt(t, e) & _t], pe = fe >> 4;
886
+ if (e += fe & 15, e > m) {
887
+ A && Z(0);
888
+ break;
889
+ }
890
+ if (fe || Z(2), pe < 256)
891
+ n[r++] = pe;
892
+ else if (pe == 256) {
893
+ xe = e, s = null;
894
+ break;
895
+ } else {
896
+ var Ye = pe - 254;
897
+ if (pe > 264) {
898
+ var V = pe - 257, Ae = Wt[V];
899
+ Ye = oe(t, e, (1 << Ae) - 1) + Jt[V], e += Ae;
900
+ }
901
+ var Pe = d[rt(t, e) & ie], Ne = Pe >> 4;
902
+ Pe || Z(3), e += Pe & 15;
903
+ var ce = tr[Ne];
904
+ if (Ne > 3) {
905
+ var Ae = qt[Ne];
906
+ ce += rt(t, e) & (1 << Ae) - 1, e += Ae;
907
+ }
908
+ if (e > m) {
909
+ A && Z(0);
910
+ break;
911
+ }
912
+ b && S(r + 131072);
913
+ var We = r + Ye;
914
+ if (r < ce) {
915
+ var qe = v - ce, pt = Math.min(ce, We);
916
+ for (qe + r < 0 && Z(3); r < pt; ++r)
917
+ n[r] = a[qe + r];
918
+ }
919
+ for (; r < We; ++r)
920
+ n[r] = n[r - ce];
921
+ }
922
+ }
923
+ o.l = s, o.p = xe, o.b = r, o.f = C, s && (C = 1, o.m = y, o.d = d, o.n = g);
924
+ } while (!C);
925
+ return r != n.length && h ? dt(n, 0, r) : n.subarray(0, r);
926
+ }, ra = /* @__PURE__ */ new z(0), oa = function(t, o) {
927
+ var n = {};
928
+ for (var a in t)
929
+ n[a] = t[a];
930
+ for (var a in o)
931
+ n[a] = o[a];
932
+ return n;
933
+ }, An = function(t, o, n) {
934
+ for (var a = t(), f = t.toString(), v = f.slice(f.indexOf("[") + 1, f.lastIndexOf("]")).replace(/\s+/g, "").split(","), h = 0; h < a.length; ++h) {
935
+ var b = a[h], A = v[h];
936
+ if (typeof b == "function") {
937
+ o += ";" + A + "=";
938
+ var S = b.toString();
939
+ if (b.prototype)
940
+ if (S.indexOf("[native code]") != -1) {
941
+ var C = S.indexOf(" ", 8) + 1;
942
+ o += S.slice(C, S.indexOf("(", C));
943
+ } else {
944
+ o += S;
945
+ for (var e in b.prototype)
946
+ o += ";" + A + ".prototype." + e + "=" + b.prototype[e].toString();
947
+ }
948
+ else
949
+ o += S;
950
+ } else
951
+ n[A] = b;
952
+ }
953
+ return o;
954
+ }, ze = [], aa = function(t) {
955
+ var o = [];
956
+ for (var n in t)
957
+ t[n].buffer && o.push((t[n] = new t[n].constructor(t[n])).buffer);
958
+ return o;
959
+ }, ia = function(t, o, n, a) {
960
+ if (!ze[n]) {
961
+ for (var f = "", v = {}, h = t.length - 1, b = 0; b < h; ++b)
962
+ f = An(t[b], f, v);
963
+ ze[n] = { c: An(t[h], f, v), e: v };
964
+ }
965
+ var A = oa({}, ze[n].e);
966
+ return ea(ze[n].c + ";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=" + o.toString() + "}", n, A, aa(A), a);
967
+ }, sa = function() {
968
+ return [z, Se, jn, Wt, qt, Zn, Jt, tr, rr, or, st, ir, Ee, nt, oe, rt, ar, dt, Z, sr, Xt, ur, fr];
969
+ }, ur = function(t) {
970
+ return postMessage(t, [t.buffer]);
971
+ }, fr = function(t) {
972
+ return t && {
973
+ out: t.size && new z(t.size),
974
+ dictionary: t.dictionary
975
+ };
976
+ }, ua = function(t, o, n, a, f, v) {
977
+ var h = ia(n, a, f, function(b, A) {
978
+ h.terminate(), v(b, A);
979
+ });
980
+ return h.postMessage([t, o], o.consume ? [t.buffer] : []), function() {
981
+ h.terminate();
982
+ };
983
+ }, le = function(t, o) {
984
+ return t[o] | t[o + 1] << 8;
985
+ }, ue = function(t, o) {
986
+ return (t[o] | t[o + 1] << 8 | t[o + 2] << 16 | t[o + 3] << 24) >>> 0;
987
+ }, Tt = function(t, o) {
988
+ return ue(t, o) + ue(t, o + 4) * 4294967296;
989
+ };
990
+ function fa(t, o, n) {
991
+ return n || (n = o, o = {}), typeof n != "function" && Z(7), ua(t, o, [
992
+ sa
993
+ ], function(a) {
994
+ return ur(Xt(a.data[0], fr(a.data[1])));
995
+ }, 1, n);
996
+ }
997
+ function Xt(t, o) {
998
+ return sr(t, { i: 2 }, o && o.out, o && o.dictionary);
999
+ }
1000
+ var Lt = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), ca = 0;
1001
+ try {
1002
+ Lt.decode(ra, { stream: !0 }), ca = 1;
1003
+ } catch {
1004
+ }
1005
+ var la = function(t) {
1006
+ for (var o = "", n = 0; ; ) {
1007
+ var a = t[n++], f = (a > 127) + (a > 223) + (a > 239);
1008
+ if (n + f > t.length)
1009
+ return { s: o, r: dt(t, n - 1) };
1010
+ f ? f == 3 ? (a = ((a & 15) << 18 | (t[n++] & 63) << 12 | (t[n++] & 63) << 6 | t[n++] & 63) - 65536, o += String.fromCharCode(55296 | a >> 10, 56320 | a & 1023)) : f & 1 ? o += String.fromCharCode((a & 31) << 6 | t[n++] & 63) : o += String.fromCharCode((a & 15) << 12 | (t[n++] & 63) << 6 | t[n++] & 63) : o += String.fromCharCode(a);
1011
+ }
1012
+ };
1013
+ function da(t, o) {
1014
+ if (o) {
1015
+ for (var n = "", a = 0; a < t.length; a += 16384)
1016
+ n += String.fromCharCode.apply(null, t.subarray(a, a + 16384));
1017
+ return n;
1018
+ } else {
1019
+ if (Lt)
1020
+ return Lt.decode(t);
1021
+ var f = la(t), v = f.s, n = f.r;
1022
+ return n.length && Z(8), v;
1023
+ }
1024
+ }
1025
+ var _a = function(t, o) {
1026
+ return o + 30 + le(t, o + 26) + le(t, o + 28);
1027
+ }, pa = function(t, o, n) {
1028
+ var a = le(t, o + 28), f = da(t.subarray(o + 46, o + 46 + a), !(le(t, o + 8) & 2048)), v = o + 46 + a, h = ue(t, o + 20), b = n && h == 4294967295 ? va(t, v) : [h, ue(t, o + 24), ue(t, o + 42)], A = b[0], S = b[1], C = b[2];
1029
+ return [le(t, o + 10), A, S, f, v + le(t, o + 30) + le(t, o + 32), C];
1030
+ }, va = function(t, o) {
1031
+ for (; le(t, o) != 1; o += 4 + le(t, o + 2))
1032
+ ;
1033
+ return [Tt(t, o + 12), Tt(t, o + 4), Tt(t, o + 20)];
1034
+ }, Sn = typeof queueMicrotask == "function" ? queueMicrotask : typeof setTimeout == "function" ? setTimeout : function(t) {
1035
+ t();
1036
+ };
1037
+ function ma(t, o, n) {
1038
+ n || (n = o, o = {}), typeof n != "function" && Z(7);
1039
+ var a = [], f = function() {
1040
+ for (var g = 0; g < a.length; ++g)
1041
+ a[g]();
1042
+ }, v = {}, h = function(g, m) {
1043
+ Sn(function() {
1044
+ n(g, m);
1045
+ });
1046
+ };
1047
+ Sn(function() {
1048
+ h = n;
1049
+ });
1050
+ for (var b = t.length - 22; ue(t, b) != 101010256; --b)
1051
+ if (!b || t.length - b > 65558)
1052
+ return h(Z(13, 0, 1), null), f;
1053
+ var A = le(t, b + 8);
1054
+ if (A) {
1055
+ var S = A, C = ue(t, b + 16), e = C == 4294967295 || S == 65535;
1056
+ if (e) {
1057
+ var r = ue(t, b - 12);
1058
+ e = ue(t, r) == 101075792, e && (S = A = ue(t, r + 32), C = ue(t, r + 48));
1059
+ }
1060
+ for (var s = o && o.filter, d = function(g) {
1061
+ var m = pa(t, C, e), O = m[0], P = m[1], $ = m[2], E = m[3], L = m[4], N = m[5], F = _a(t, N);
1062
+ C = L;
1063
+ var R = function(V, X) {
1064
+ V ? (f(), h(V, null)) : (X && (v[E] = X), --A || h(null, v));
1065
+ };
1066
+ if (!s || s({
1067
+ name: E,
1068
+ size: P,
1069
+ originalSize: $,
1070
+ compression: O
1071
+ }))
1072
+ if (!O)
1073
+ R(null, dt(t, F, F + P));
1074
+ else if (O == 8) {
1075
+ var Y = t.subarray(F, F + P);
1076
+ if ($ < 524288 || P > 0.8 * $)
1077
+ try {
1078
+ R(null, Xt(Y, { out: new z($) }));
1079
+ } catch (V) {
1080
+ R(V, null);
1081
+ }
1082
+ else
1083
+ a.push(fa(Y, { size: $ }, R));
1084
+ } else
1085
+ R(Z(14, "unknown compression type " + O, 1), null);
1086
+ else
1087
+ R(null, null);
1088
+ }, y = 0; y < S; ++y)
1089
+ d(y);
1090
+ } else
1091
+ h(null, {});
1092
+ return f;
1093
+ }
1094
+ let cr = () => {
1095
+ };
1096
+ async function ha(t) {
1097
+ const o = await lr(t);
1098
+ return new TextDecoder("utf-8").decode(o);
1099
+ }
1100
+ async function ga(t) {
1101
+ return new Promise((o, n) => {
1102
+ const a = document.createElement("script");
1103
+ a.src = t, a.addEventListener("load", o), a.addEventListener("error", n), document.body.append(a);
1104
+ });
1105
+ }
1106
+ async function ya(t) {
1107
+ let o = "";
1108
+ try {
1109
+ await ga(t);
1110
+ } catch (n) {
1111
+ throw console.error(n), Error(`Failed to fetch file: ${t}`);
1112
+ }
1113
+ try {
1114
+ o = JSON.stringify(window.storyContent);
1115
+ } catch (n) {
1116
+ throw console.error(n), Error(`Failed to parse Ink script: ${t}`);
1117
+ }
1118
+ return o;
1119
+ }
1120
+ async function lr(t) {
1121
+ const o = await fetch(t, { responseType: "arraybuffer" });
1122
+ if (!o.ok) {
1123
+ const A = await o.text();
1124
+ throw new Error(`Failed to fetch file: ${t}. Error ${o.status} ${A}`);
1125
+ }
1126
+ const n = o.body.getReader(), a = +o.headers.get("Content-Length"), f = [];
1127
+ let v = 0;
1128
+ for (; ; ) {
1129
+ const { done: A, value: S } = await n.read();
1130
+ if (A)
1131
+ break;
1132
+ f.push(S), v += S.length;
1133
+ const C = Math.round(v * 100 / a);
1134
+ cr({ percent: C, receivedLength: v, contentLength: a });
1135
+ }
1136
+ const h = new Uint8Array(v);
1137
+ let b = 0;
1138
+ return f.forEach((A) => {
1139
+ h.set(A, b), b += A.length;
1140
+ }), h;
1141
+ }
1142
+ function wa(t) {
1143
+ cr = t;
1144
+ }
1145
+ let Mt = "plain", dr = "", Ft = {};
1146
+ async function ba(t) {
1147
+ if (t.endsWith(".zip") && (Mt = "zip"), Mt === "zip") {
1148
+ Ft = {};
1149
+ const o = await lr(t);
1150
+ await ma(
1151
+ o,
1152
+ (n, a) => Object.entries(a).forEach(([f, v]) => {
1153
+ Ft[f] = URL.createObjectURL(new Blob([v]));
1154
+ })
1155
+ );
1156
+ } else
1157
+ dr = t;
1158
+ }
1159
+ function _r(t) {
1160
+ return Mt === "zip" ? Ft[t] : `${dr}/${t}`;
1161
+ }
1162
+ async function Aa(t) {
1163
+ const o = _r(t);
1164
+ return await (o.endsWith("js") ? ya(o) : ha(o));
1165
+ }
1166
+ const Sa = {
1167
+ init: ba,
1168
+ getAssetPath: _r,
1169
+ loadInk: Aa,
1170
+ onProgress: wa
1171
+ };
1172
+ var _e = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
1173
+ function pr(t) {
1174
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
1175
+ }
1176
+ function et(t) {
1177
+ throw new Error('Could not dynamically require "' + t + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
1178
+ }
1179
+ var It = { exports: {} };
1180
+ var xn;
1181
+ function xa() {
1182
+ return xn || (xn = 1, (function(t, o) {
1183
+ (function(n) {
1184
+ t.exports = n();
1185
+ })(function() {
1186
+ return (function n(a, f, v) {
1187
+ function h(S, C) {
1188
+ if (!f[S]) {
1189
+ if (!a[S]) {
1190
+ var e = typeof et == "function" && et;
1191
+ if (!C && e) return e(S, !0);
1192
+ if (b) return b(S, !0);
1193
+ var r = new Error("Cannot find module '" + S + "'");
1194
+ throw r.code = "MODULE_NOT_FOUND", r;
1195
+ }
1196
+ var s = f[S] = { exports: {} };
1197
+ a[S][0].call(s.exports, function(d) {
1198
+ var y = a[S][1][d];
1199
+ return h(y || d);
1200
+ }, s, s.exports, n, a, f, v);
1201
+ }
1202
+ return f[S].exports;
1203
+ }
1204
+ for (var b = typeof et == "function" && et, A = 0; A < v.length; A++) h(v[A]);
1205
+ return h;
1206
+ })({ 1: [function(n, a, f) {
1207
+ (function(v) {
1208
+ var h = v.MutationObserver || v.WebKitMutationObserver, b;
1209
+ if (h) {
1210
+ var A = 0, S = new h(d), C = v.document.createTextNode("");
1211
+ S.observe(C, {
1212
+ characterData: !0
1213
+ }), b = function() {
1214
+ C.data = A = ++A % 2;
1215
+ };
1216
+ } else if (!v.setImmediate && typeof v.MessageChannel < "u") {
1217
+ var e = new v.MessageChannel();
1218
+ e.port1.onmessage = d, b = function() {
1219
+ e.port2.postMessage(0);
1220
+ };
1221
+ } else "document" in v && "onreadystatechange" in v.document.createElement("script") ? b = function() {
1222
+ var g = v.document.createElement("script");
1223
+ g.onreadystatechange = function() {
1224
+ d(), g.onreadystatechange = null, g.parentNode.removeChild(g), g = null;
1225
+ }, v.document.documentElement.appendChild(g);
1226
+ } : b = function() {
1227
+ setTimeout(d, 0);
1228
+ };
1229
+ var r, s = [];
1230
+ function d() {
1231
+ r = !0;
1232
+ for (var g, m, O = s.length; O; ) {
1233
+ for (m = s, s = [], g = -1; ++g < O; )
1234
+ m[g]();
1235
+ O = s.length;
1236
+ }
1237
+ r = !1;
1238
+ }
1239
+ a.exports = y;
1240
+ function y(g) {
1241
+ s.push(g) === 1 && !r && b();
1242
+ }
1243
+ }).call(this, typeof _e < "u" ? _e : typeof self < "u" ? self : typeof window < "u" ? window : {});
1244
+ }, {}], 2: [function(n, a, f) {
1245
+ var v = n(1);
1246
+ function h() {
1247
+ }
1248
+ var b = {}, A = ["REJECTED"], S = ["FULFILLED"], C = ["PENDING"];
1249
+ a.exports = e;
1250
+ function e(E) {
1251
+ if (typeof E != "function")
1252
+ throw new TypeError("resolver must be a function");
1253
+ this.state = C, this.queue = [], this.outcome = void 0, E !== h && y(this, E);
1254
+ }
1255
+ e.prototype.catch = function(E) {
1256
+ return this.then(null, E);
1257
+ }, e.prototype.then = function(E, L) {
1258
+ if (typeof E != "function" && this.state === S || typeof L != "function" && this.state === A)
1259
+ return this;
1260
+ var N = new this.constructor(h);
1261
+ if (this.state !== C) {
1262
+ var F = this.state === S ? E : L;
1263
+ s(N, F, this.outcome);
1264
+ } else
1265
+ this.queue.push(new r(N, E, L));
1266
+ return N;
1267
+ };
1268
+ function r(E, L, N) {
1269
+ this.promise = E, typeof L == "function" && (this.onFulfilled = L, this.callFulfilled = this.otherCallFulfilled), typeof N == "function" && (this.onRejected = N, this.callRejected = this.otherCallRejected);
1270
+ }
1271
+ r.prototype.callFulfilled = function(E) {
1272
+ b.resolve(this.promise, E);
1273
+ }, r.prototype.otherCallFulfilled = function(E) {
1274
+ s(this.promise, this.onFulfilled, E);
1275
+ }, r.prototype.callRejected = function(E) {
1276
+ b.reject(this.promise, E);
1277
+ }, r.prototype.otherCallRejected = function(E) {
1278
+ s(this.promise, this.onRejected, E);
1279
+ };
1280
+ function s(E, L, N) {
1281
+ v(function() {
1282
+ var F;
1283
+ try {
1284
+ F = L(N);
1285
+ } catch (R) {
1286
+ return b.reject(E, R);
1287
+ }
1288
+ F === E ? b.reject(E, new TypeError("Cannot resolve promise with itself")) : b.resolve(E, F);
1289
+ });
1290
+ }
1291
+ b.resolve = function(E, L) {
1292
+ var N = g(d, L);
1293
+ if (N.status === "error")
1294
+ return b.reject(E, N.value);
1295
+ var F = N.value;
1296
+ if (F)
1297
+ y(E, F);
1298
+ else {
1299
+ E.state = S, E.outcome = L;
1300
+ for (var R = -1, Y = E.queue.length; ++R < Y; )
1301
+ E.queue[R].callFulfilled(L);
1302
+ }
1303
+ return E;
1304
+ }, b.reject = function(E, L) {
1305
+ E.state = A, E.outcome = L;
1306
+ for (var N = -1, F = E.queue.length; ++N < F; )
1307
+ E.queue[N].callRejected(L);
1308
+ return E;
1309
+ };
1310
+ function d(E) {
1311
+ var L = E && E.then;
1312
+ if (E && (typeof E == "object" || typeof E == "function") && typeof L == "function")
1313
+ return function() {
1314
+ L.apply(E, arguments);
1315
+ };
1316
+ }
1317
+ function y(E, L) {
1318
+ var N = !1;
1319
+ function F(X) {
1320
+ N || (N = !0, b.reject(E, X));
1321
+ }
1322
+ function R(X) {
1323
+ N || (N = !0, b.resolve(E, X));
1324
+ }
1325
+ function Y() {
1326
+ L(R, F);
1327
+ }
1328
+ var V = g(Y);
1329
+ V.status === "error" && F(V.value);
1330
+ }
1331
+ function g(E, L) {
1332
+ var N = {};
1333
+ try {
1334
+ N.value = E(L), N.status = "success";
1335
+ } catch (F) {
1336
+ N.status = "error", N.value = F;
1337
+ }
1338
+ return N;
1339
+ }
1340
+ e.resolve = m;
1341
+ function m(E) {
1342
+ return E instanceof this ? E : b.resolve(new this(h), E);
1343
+ }
1344
+ e.reject = O;
1345
+ function O(E) {
1346
+ var L = new this(h);
1347
+ return b.reject(L, E);
1348
+ }
1349
+ e.all = P;
1350
+ function P(E) {
1351
+ var L = this;
1352
+ if (Object.prototype.toString.call(E) !== "[object Array]")
1353
+ return this.reject(new TypeError("must be an array"));
1354
+ var N = E.length, F = !1;
1355
+ if (!N)
1356
+ return this.resolve([]);
1357
+ for (var R = new Array(N), Y = 0, V = -1, X = new this(h); ++V < N; )
1358
+ ee(E[V], V);
1359
+ return X;
1360
+ function ee(te, de) {
1361
+ L.resolve(te).then(fe, function(ae) {
1362
+ F || (F = !0, b.reject(X, ae));
1363
+ });
1364
+ function fe(ae) {
1365
+ R[de] = ae, ++Y === N && !F && (F = !0, b.resolve(X, R));
1366
+ }
1367
+ }
1368
+ }
1369
+ e.race = $;
1370
+ function $(E) {
1371
+ var L = this;
1372
+ if (Object.prototype.toString.call(E) !== "[object Array]")
1373
+ return this.reject(new TypeError("must be an array"));
1374
+ var N = E.length, F = !1;
1375
+ if (!N)
1376
+ return this.resolve([]);
1377
+ for (var R = -1, Y = new this(h); ++R < N; )
1378
+ V(E[R]);
1379
+ return Y;
1380
+ function V(X) {
1381
+ L.resolve(X).then(function(ee) {
1382
+ F || (F = !0, b.resolve(Y, ee));
1383
+ }, function(ee) {
1384
+ F || (F = !0, b.reject(Y, ee));
1385
+ });
1386
+ }
1387
+ }
1388
+ }, { 1: 1 }], 3: [function(n, a, f) {
1389
+ (function(v) {
1390
+ typeof v.Promise != "function" && (v.Promise = n(2));
1391
+ }).call(this, typeof _e < "u" ? _e : typeof self < "u" ? self : typeof window < "u" ? window : {});
1392
+ }, { 2: 2 }], 4: [function(n, a, f) {
1393
+ var v = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(i) {
1394
+ return typeof i;
1395
+ } : function(i) {
1396
+ return i && typeof Symbol == "function" && i.constructor === Symbol && i !== Symbol.prototype ? "symbol" : typeof i;
1397
+ };
1398
+ function h(i, c) {
1399
+ if (!(i instanceof c))
1400
+ throw new TypeError("Cannot call a class as a function");
1401
+ }
1402
+ function b() {
1403
+ try {
1404
+ if (typeof indexedDB < "u")
1405
+ return indexedDB;
1406
+ if (typeof webkitIndexedDB < "u")
1407
+ return webkitIndexedDB;
1408
+ if (typeof mozIndexedDB < "u")
1409
+ return mozIndexedDB;
1410
+ if (typeof OIndexedDB < "u")
1411
+ return OIndexedDB;
1412
+ if (typeof msIndexedDB < "u")
1413
+ return msIndexedDB;
1414
+ } catch {
1415
+ return;
1416
+ }
1417
+ }
1418
+ var A = b();
1419
+ function S() {
1420
+ try {
1421
+ if (!A || !A.open)
1422
+ return !1;
1423
+ var i = typeof openDatabase < "u" && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform), c = typeof fetch == "function" && fetch.toString().indexOf("[native code") !== -1;
1424
+ return (!i || c) && typeof indexedDB < "u" && // some outdated implementations of IDB that appear on Samsung
1425
+ // and HTC Android devices <4.4 are missing IDBKeyRange
1426
+ // See: https://github.com/mozilla/localForage/issues/128
1427
+ // See: https://github.com/mozilla/localForage/issues/272
1428
+ typeof IDBKeyRange < "u";
1429
+ } catch {
1430
+ return !1;
1431
+ }
1432
+ }
1433
+ function C(i, c) {
1434
+ i = i || [], c = c || {};
1435
+ try {
1436
+ return new Blob(i, c);
1437
+ } catch (l) {
1438
+ if (l.name !== "TypeError")
1439
+ throw l;
1440
+ for (var u = typeof BlobBuilder < "u" ? BlobBuilder : typeof MSBlobBuilder < "u" ? MSBlobBuilder : typeof MozBlobBuilder < "u" ? MozBlobBuilder : WebKitBlobBuilder, _ = new u(), p = 0; p < i.length; p += 1)
1441
+ _.append(i[p]);
1442
+ return _.getBlob(c.type);
1443
+ }
1444
+ }
1445
+ typeof Promise > "u" && n(3);
1446
+ var e = Promise;
1447
+ function r(i, c) {
1448
+ c && i.then(function(u) {
1449
+ c(null, u);
1450
+ }, function(u) {
1451
+ c(u);
1452
+ });
1453
+ }
1454
+ function s(i, c, u) {
1455
+ typeof c == "function" && i.then(c), typeof u == "function" && i.catch(u);
1456
+ }
1457
+ function d(i) {
1458
+ return typeof i != "string" && (console.warn(i + " used as a key, but it is not a string."), i = String(i)), i;
1459
+ }
1460
+ function y() {
1461
+ if (arguments.length && typeof arguments[arguments.length - 1] == "function")
1462
+ return arguments[arguments.length - 1];
1463
+ }
1464
+ var g = "local-forage-detect-blob-support", m = void 0, O = {}, P = Object.prototype.toString, $ = "readonly", E = "readwrite";
1465
+ function L(i) {
1466
+ for (var c = i.length, u = new ArrayBuffer(c), _ = new Uint8Array(u), p = 0; p < c; p++)
1467
+ _[p] = i.charCodeAt(p);
1468
+ return u;
1469
+ }
1470
+ function N(i) {
1471
+ return new e(function(c) {
1472
+ var u = i.transaction(g, E), _ = C([""]);
1473
+ u.objectStore(g).put(_, "key"), u.onabort = function(p) {
1474
+ p.preventDefault(), p.stopPropagation(), c(!1);
1475
+ }, u.oncomplete = function() {
1476
+ var p = navigator.userAgent.match(/Chrome\/(\d+)/), l = navigator.userAgent.match(/Edge\//);
1477
+ c(l || !p || parseInt(p[1], 10) >= 43);
1478
+ };
1479
+ }).catch(function() {
1480
+ return !1;
1481
+ });
1482
+ }
1483
+ function F(i) {
1484
+ return typeof m == "boolean" ? e.resolve(m) : N(i).then(function(c) {
1485
+ return m = c, m;
1486
+ });
1487
+ }
1488
+ function R(i) {
1489
+ var c = O[i.name], u = {};
1490
+ u.promise = new e(function(_, p) {
1491
+ u.resolve = _, u.reject = p;
1492
+ }), c.deferredOperations.push(u), c.dbReady ? c.dbReady = c.dbReady.then(function() {
1493
+ return u.promise;
1494
+ }) : c.dbReady = u.promise;
1495
+ }
1496
+ function Y(i) {
1497
+ var c = O[i.name], u = c.deferredOperations.pop();
1498
+ if (u)
1499
+ return u.resolve(), u.promise;
1500
+ }
1501
+ function V(i, c) {
1502
+ var u = O[i.name], _ = u.deferredOperations.pop();
1503
+ if (_)
1504
+ return _.reject(c), _.promise;
1505
+ }
1506
+ function X(i, c) {
1507
+ return new e(function(u, _) {
1508
+ if (O[i.name] = O[i.name] || xe(), i.db)
1509
+ if (c)
1510
+ R(i), i.db.close();
1511
+ else
1512
+ return u(i.db);
1513
+ var p = [i.name];
1514
+ c && p.push(i.version);
1515
+ var l = A.open.apply(A, p);
1516
+ c && (l.onupgradeneeded = function(w) {
1517
+ var x = l.result;
1518
+ try {
1519
+ x.createObjectStore(i.storeName), w.oldVersion <= 1 && x.createObjectStore(g);
1520
+ } catch (T) {
1521
+ if (T.name === "ConstraintError")
1522
+ console.warn('The database "' + i.name + '" has been upgraded from version ' + w.oldVersion + " to version " + w.newVersion + ', but the storage "' + i.storeName + '" already exists.');
1523
+ else
1524
+ throw T;
1525
+ }
1526
+ }), l.onerror = function(w) {
1527
+ w.preventDefault(), _(l.error);
1528
+ }, l.onsuccess = function() {
1529
+ var w = l.result;
1530
+ w.onversionchange = function(x) {
1531
+ x.target.close();
1532
+ }, u(w), Y(i);
1533
+ };
1534
+ });
1535
+ }
1536
+ function ee(i) {
1537
+ return X(i, !1);
1538
+ }
1539
+ function te(i) {
1540
+ return X(i, !0);
1541
+ }
1542
+ function de(i, c) {
1543
+ if (!i.db)
1544
+ return !0;
1545
+ var u = !i.db.objectStoreNames.contains(i.storeName), _ = i.version < i.db.version, p = i.version > i.db.version;
1546
+ if (_ && (i.version !== c && console.warn('The database "' + i.name + `" can't be downgraded from version ` + i.db.version + " to version " + i.version + "."), i.version = i.db.version), p || u) {
1547
+ if (u) {
1548
+ var l = i.db.version + 1;
1549
+ l > i.version && (i.version = l);
1550
+ }
1551
+ return !0;
1552
+ }
1553
+ return !1;
1554
+ }
1555
+ function fe(i) {
1556
+ return new e(function(c, u) {
1557
+ var _ = new FileReader();
1558
+ _.onerror = u, _.onloadend = function(p) {
1559
+ var l = btoa(p.target.result || "");
1560
+ c({
1561
+ __local_forage_encoded_blob: !0,
1562
+ data: l,
1563
+ type: i.type
1564
+ });
1565
+ }, _.readAsBinaryString(i);
1566
+ });
1567
+ }
1568
+ function ae(i) {
1569
+ var c = L(atob(i.data));
1570
+ return C([c], { type: i.type });
1571
+ }
1572
+ function Re(i) {
1573
+ return i && i.__local_forage_encoded_blob;
1574
+ }
1575
+ function ce(i) {
1576
+ var c = this, u = c._initReady().then(function() {
1577
+ var _ = O[c._dbInfo.name];
1578
+ if (_ && _.dbReady)
1579
+ return _.dbReady;
1580
+ });
1581
+ return s(u, i, i), u;
1582
+ }
1583
+ function _t(i) {
1584
+ R(i);
1585
+ for (var c = O[i.name], u = c.forages, _ = 0; _ < u.length; _++) {
1586
+ var p = u[_];
1587
+ p._dbInfo.db && (p._dbInfo.db.close(), p._dbInfo.db = null);
1588
+ }
1589
+ return i.db = null, ee(i).then(function(l) {
1590
+ return i.db = l, de(i) ? te(i) : l;
1591
+ }).then(function(l) {
1592
+ i.db = c.db = l;
1593
+ for (var w = 0; w < u.length; w++)
1594
+ u[w]._dbInfo.db = l;
1595
+ }).catch(function(l) {
1596
+ throw V(i, l), l;
1597
+ });
1598
+ }
1599
+ function ie(i, c, u, _) {
1600
+ _ === void 0 && (_ = 1);
1601
+ try {
1602
+ var p = i.db.transaction(i.storeName, c);
1603
+ u(null, p);
1604
+ } catch (l) {
1605
+ if (_ > 0 && (!i.db || l.name === "InvalidStateError" || l.name === "NotFoundError"))
1606
+ return e.resolve().then(function() {
1607
+ if (!i.db || l.name === "NotFoundError" && !i.db.objectStoreNames.contains(i.storeName) && i.version <= i.db.version)
1608
+ return i.db && (i.version = i.db.version + 1), te(i);
1609
+ }).then(function() {
1610
+ return _t(i).then(function() {
1611
+ ie(i, c, u, _ - 1);
1612
+ });
1613
+ }).catch(u);
1614
+ u(l);
1615
+ }
1616
+ }
1617
+ function xe() {
1618
+ return {
1619
+ // Running localForages sharing a database.
1620
+ forages: [],
1621
+ // Shared database.
1622
+ db: null,
1623
+ // Database readiness (promise).
1624
+ dbReady: null,
1625
+ // Deferred operations on the database.
1626
+ deferredOperations: []
1627
+ };
1628
+ }
1629
+ function pe(i) {
1630
+ var c = this, u = {
1631
+ db: null
1632
+ };
1633
+ if (i)
1634
+ for (var _ in i)
1635
+ u[_] = i[_];
1636
+ var p = O[u.name];
1637
+ p || (p = xe(), O[u.name] = p), p.forages.push(c), c._initReady || (c._initReady = c.ready, c.ready = ce);
1638
+ var l = [];
1639
+ function w() {
1640
+ return e.resolve();
1641
+ }
1642
+ for (var x = 0; x < p.forages.length; x++) {
1643
+ var T = p.forages[x];
1644
+ T !== c && l.push(T._initReady().catch(w));
1645
+ }
1646
+ var I = p.forages.slice(0);
1647
+ return e.all(l).then(function() {
1648
+ return u.db = p.db, ee(u);
1649
+ }).then(function(D) {
1650
+ return u.db = D, de(u, c._defaultConfig.version) ? te(u) : D;
1651
+ }).then(function(D) {
1652
+ u.db = p.db = D, c._dbInfo = u;
1653
+ for (var k = 0; k < I.length; k++) {
1654
+ var B = I[k];
1655
+ B !== c && (B._dbInfo.db = u.db, B._dbInfo.version = u.version);
1656
+ }
1657
+ });
1658
+ }
1659
+ function Ye(i, c) {
1660
+ var u = this;
1661
+ i = d(i);
1662
+ var _ = new e(function(p, l) {
1663
+ u.ready().then(function() {
1664
+ ie(u._dbInfo, $, function(w, x) {
1665
+ if (w)
1666
+ return l(w);
1667
+ try {
1668
+ var T = x.objectStore(u._dbInfo.storeName), I = T.get(i);
1669
+ I.onsuccess = function() {
1670
+ var D = I.result;
1671
+ D === void 0 && (D = null), Re(D) && (D = ae(D)), p(D);
1672
+ }, I.onerror = function() {
1673
+ l(I.error);
1674
+ };
1675
+ } catch (D) {
1676
+ l(D);
1677
+ }
1678
+ });
1679
+ }).catch(l);
1680
+ });
1681
+ return r(_, c), _;
1682
+ }
1683
+ function Ae(i, c) {
1684
+ var u = this, _ = new e(function(p, l) {
1685
+ u.ready().then(function() {
1686
+ ie(u._dbInfo, $, function(w, x) {
1687
+ if (w)
1688
+ return l(w);
1689
+ try {
1690
+ var T = x.objectStore(u._dbInfo.storeName), I = T.openCursor(), D = 1;
1691
+ I.onsuccess = function() {
1692
+ var k = I.result;
1693
+ if (k) {
1694
+ var B = k.value;
1695
+ Re(B) && (B = ae(B));
1696
+ var U = i(B, k.key, D++);
1697
+ U !== void 0 ? p(U) : k.continue();
1698
+ } else
1699
+ p();
1700
+ }, I.onerror = function() {
1701
+ l(I.error);
1702
+ };
1703
+ } catch (k) {
1704
+ l(k);
1705
+ }
1706
+ });
1707
+ }).catch(l);
1708
+ });
1709
+ return r(_, c), _;
1710
+ }
1711
+ function Pe(i, c, u) {
1712
+ var _ = this;
1713
+ i = d(i);
1714
+ var p = new e(function(l, w) {
1715
+ var x;
1716
+ _.ready().then(function() {
1717
+ return x = _._dbInfo, P.call(c) === "[object Blob]" ? F(x.db).then(function(T) {
1718
+ return T ? c : fe(c);
1719
+ }) : c;
1720
+ }).then(function(T) {
1721
+ ie(_._dbInfo, E, function(I, D) {
1722
+ if (I)
1723
+ return w(I);
1724
+ try {
1725
+ var k = D.objectStore(_._dbInfo.storeName);
1726
+ T === null && (T = void 0);
1727
+ var B = k.put(T, i);
1728
+ D.oncomplete = function() {
1729
+ T === void 0 && (T = null), l(T);
1730
+ }, D.onabort = D.onerror = function() {
1731
+ var U = B.error ? B.error : B.transaction.error;
1732
+ w(U);
1733
+ };
1734
+ } catch (U) {
1735
+ w(U);
1736
+ }
1737
+ });
1738
+ }).catch(w);
1739
+ });
1740
+ return r(p, u), p;
1741
+ }
1742
+ function Ne(i, c) {
1743
+ var u = this;
1744
+ i = d(i);
1745
+ var _ = new e(function(p, l) {
1746
+ u.ready().then(function() {
1747
+ ie(u._dbInfo, E, function(w, x) {
1748
+ if (w)
1749
+ return l(w);
1750
+ try {
1751
+ var T = x.objectStore(u._dbInfo.storeName), I = T.delete(i);
1752
+ x.oncomplete = function() {
1753
+ p();
1754
+ }, x.onerror = function() {
1755
+ l(I.error);
1756
+ }, x.onabort = function() {
1757
+ var D = I.error ? I.error : I.transaction.error;
1758
+ l(D);
1759
+ };
1760
+ } catch (D) {
1761
+ l(D);
1762
+ }
1763
+ });
1764
+ }).catch(l);
1765
+ });
1766
+ return r(_, c), _;
1767
+ }
1768
+ function We(i) {
1769
+ var c = this, u = new e(function(_, p) {
1770
+ c.ready().then(function() {
1771
+ ie(c._dbInfo, E, function(l, w) {
1772
+ if (l)
1773
+ return p(l);
1774
+ try {
1775
+ var x = w.objectStore(c._dbInfo.storeName), T = x.clear();
1776
+ w.oncomplete = function() {
1777
+ _();
1778
+ }, w.onabort = w.onerror = function() {
1779
+ var I = T.error ? T.error : T.transaction.error;
1780
+ p(I);
1781
+ };
1782
+ } catch (I) {
1783
+ p(I);
1784
+ }
1785
+ });
1786
+ }).catch(p);
1787
+ });
1788
+ return r(u, i), u;
1789
+ }
1790
+ function qe(i) {
1791
+ var c = this, u = new e(function(_, p) {
1792
+ c.ready().then(function() {
1793
+ ie(c._dbInfo, $, function(l, w) {
1794
+ if (l)
1795
+ return p(l);
1796
+ try {
1797
+ var x = w.objectStore(c._dbInfo.storeName), T = x.count();
1798
+ T.onsuccess = function() {
1799
+ _(T.result);
1800
+ }, T.onerror = function() {
1801
+ p(T.error);
1802
+ };
1803
+ } catch (I) {
1804
+ p(I);
1805
+ }
1806
+ });
1807
+ }).catch(p);
1808
+ });
1809
+ return r(u, i), u;
1810
+ }
1811
+ function pt(i, c) {
1812
+ var u = this, _ = new e(function(p, l) {
1813
+ if (i < 0) {
1814
+ p(null);
1815
+ return;
1816
+ }
1817
+ u.ready().then(function() {
1818
+ ie(u._dbInfo, $, function(w, x) {
1819
+ if (w)
1820
+ return l(w);
1821
+ try {
1822
+ var T = x.objectStore(u._dbInfo.storeName), I = !1, D = T.openKeyCursor();
1823
+ D.onsuccess = function() {
1824
+ var k = D.result;
1825
+ if (!k) {
1826
+ p(null);
1827
+ return;
1828
+ }
1829
+ i === 0 || I ? p(k.key) : (I = !0, k.advance(i));
1830
+ }, D.onerror = function() {
1831
+ l(D.error);
1832
+ };
1833
+ } catch (k) {
1834
+ l(k);
1835
+ }
1836
+ });
1837
+ }).catch(l);
1838
+ });
1839
+ return r(_, c), _;
1840
+ }
1841
+ function Je(i) {
1842
+ var c = this, u = new e(function(_, p) {
1843
+ c.ready().then(function() {
1844
+ ie(c._dbInfo, $, function(l, w) {
1845
+ if (l)
1846
+ return p(l);
1847
+ try {
1848
+ var x = w.objectStore(c._dbInfo.storeName), T = x.openKeyCursor(), I = [];
1849
+ T.onsuccess = function() {
1850
+ var D = T.result;
1851
+ if (!D) {
1852
+ _(I);
1853
+ return;
1854
+ }
1855
+ I.push(D.key), D.continue();
1856
+ }, T.onerror = function() {
1857
+ p(T.error);
1858
+ };
1859
+ } catch (D) {
1860
+ p(D);
1861
+ }
1862
+ });
1863
+ }).catch(p);
1864
+ });
1865
+ return r(u, i), u;
1866
+ }
1867
+ function Xe(i, c) {
1868
+ c = y.apply(this, arguments);
1869
+ var u = this.config();
1870
+ i = typeof i != "function" && i || {}, i.name || (i.name = i.name || u.name, i.storeName = i.storeName || u.storeName);
1871
+ var _ = this, p;
1872
+ if (!i.name)
1873
+ p = e.reject("Invalid arguments");
1874
+ else {
1875
+ var l = i.name === u.name && _._dbInfo.db, w = l ? e.resolve(_._dbInfo.db) : ee(i).then(function(x) {
1876
+ var T = O[i.name], I = T.forages;
1877
+ T.db = x;
1878
+ for (var D = 0; D < I.length; D++)
1879
+ I[D]._dbInfo.db = x;
1880
+ return x;
1881
+ });
1882
+ i.storeName ? p = w.then(function(x) {
1883
+ if (x.objectStoreNames.contains(i.storeName)) {
1884
+ var T = x.version + 1;
1885
+ R(i);
1886
+ var I = O[i.name], D = I.forages;
1887
+ x.close();
1888
+ for (var k = 0; k < D.length; k++) {
1889
+ var B = D[k];
1890
+ B._dbInfo.db = null, B._dbInfo.version = T;
1891
+ }
1892
+ var U = new e(function(G, Q) {
1893
+ var W = A.open(i.name, T);
1894
+ W.onerror = function(re) {
1895
+ var Me = W.result;
1896
+ Me.close(), Q(re);
1897
+ }, W.onupgradeneeded = function() {
1898
+ var re = W.result;
1899
+ re.deleteObjectStore(i.storeName);
1900
+ }, W.onsuccess = function() {
1901
+ var re = W.result;
1902
+ re.close(), G(re);
1903
+ };
1904
+ });
1905
+ return U.then(function(G) {
1906
+ I.db = G;
1907
+ for (var Q = 0; Q < D.length; Q++) {
1908
+ var W = D[Q];
1909
+ W._dbInfo.db = G, Y(W._dbInfo);
1910
+ }
1911
+ }).catch(function(G) {
1912
+ throw (V(i, G) || e.resolve()).catch(function() {
1913
+ }), G;
1914
+ });
1915
+ }
1916
+ }) : p = w.then(function(x) {
1917
+ R(i);
1918
+ var T = O[i.name], I = T.forages;
1919
+ x.close();
1920
+ for (var D = 0; D < I.length; D++) {
1921
+ var k = I[D];
1922
+ k._dbInfo.db = null;
1923
+ }
1924
+ var B = new e(function(U, G) {
1925
+ var Q = A.deleteDatabase(i.name);
1926
+ Q.onerror = function() {
1927
+ var W = Q.result;
1928
+ W && W.close(), G(Q.error);
1929
+ }, Q.onblocked = function() {
1930
+ console.warn('dropInstance blocked for database "' + i.name + '" until all open connections are closed');
1931
+ }, Q.onsuccess = function() {
1932
+ var W = Q.result;
1933
+ W && W.close(), U(W);
1934
+ };
1935
+ });
1936
+ return B.then(function(U) {
1937
+ T.db = U;
1938
+ for (var G = 0; G < I.length; G++) {
1939
+ var Q = I[G];
1940
+ Y(Q._dbInfo);
1941
+ }
1942
+ }).catch(function(U) {
1943
+ throw (V(i, U) || e.resolve()).catch(function() {
1944
+ }), U;
1945
+ });
1946
+ });
1947
+ }
1948
+ return r(p, c), p;
1949
+ }
1950
+ var Qe = {
1951
+ _driver: "asyncStorage",
1952
+ _initStorage: pe,
1953
+ _support: S(),
1954
+ iterate: Ae,
1955
+ getItem: Ye,
1956
+ setItem: Pe,
1957
+ removeItem: Ne,
1958
+ clear: We,
1959
+ length: qe,
1960
+ key: pt,
1961
+ keys: Je,
1962
+ dropInstance: Xe
1963
+ };
1964
+ function yr() {
1965
+ return typeof openDatabase == "function";
1966
+ }
1967
+ var ve = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", wr = "~~local_forage_type~", Zt = /^~~local_forage_type~([^~]+)~/, je = "__lfsc__:", vt = je.length, mt = "arbf", ht = "blob", zt = "si08", en = "ui08", tn = "uic8", nn = "si16", rn = "si32", on = "ur16", an = "ui32", sn = "fl32", un = "fl64", fn = vt + mt.length, cn = Object.prototype.toString;
1968
+ function ln(i) {
1969
+ var c = i.length * 0.75, u = i.length, _, p = 0, l, w, x, T;
1970
+ i[i.length - 1] === "=" && (c--, i[i.length - 2] === "=" && c--);
1971
+ var I = new ArrayBuffer(c), D = new Uint8Array(I);
1972
+ for (_ = 0; _ < u; _ += 4)
1973
+ l = ve.indexOf(i[_]), w = ve.indexOf(i[_ + 1]), x = ve.indexOf(i[_ + 2]), T = ve.indexOf(i[_ + 3]), D[p++] = l << 2 | w >> 4, D[p++] = (w & 15) << 4 | x >> 2, D[p++] = (x & 3) << 6 | T & 63;
1974
+ return I;
1975
+ }
1976
+ function gt(i) {
1977
+ var c = new Uint8Array(i), u = "", _;
1978
+ for (_ = 0; _ < c.length; _ += 3)
1979
+ u += ve[c[_] >> 2], u += ve[(c[_] & 3) << 4 | c[_ + 1] >> 4], u += ve[(c[_ + 1] & 15) << 2 | c[_ + 2] >> 6], u += ve[c[_ + 2] & 63];
1980
+ return c.length % 3 === 2 ? u = u.substring(0, u.length - 1) + "=" : c.length % 3 === 1 && (u = u.substring(0, u.length - 2) + "=="), u;
1981
+ }
1982
+ function br(i, c) {
1983
+ var u = "";
1984
+ if (i && (u = cn.call(i)), i && (u === "[object ArrayBuffer]" || i.buffer && cn.call(i.buffer) === "[object ArrayBuffer]")) {
1985
+ var _, p = je;
1986
+ i instanceof ArrayBuffer ? (_ = i, p += mt) : (_ = i.buffer, u === "[object Int8Array]" ? p += zt : u === "[object Uint8Array]" ? p += en : u === "[object Uint8ClampedArray]" ? p += tn : u === "[object Int16Array]" ? p += nn : u === "[object Uint16Array]" ? p += on : u === "[object Int32Array]" ? p += rn : u === "[object Uint32Array]" ? p += an : u === "[object Float32Array]" ? p += sn : u === "[object Float64Array]" ? p += un : c(new Error("Failed to get type for BinaryArray"))), c(p + gt(_));
1987
+ } else if (u === "[object Blob]") {
1988
+ var l = new FileReader();
1989
+ l.onload = function() {
1990
+ var w = wr + i.type + "~" + gt(this.result);
1991
+ c(je + ht + w);
1992
+ }, l.readAsArrayBuffer(i);
1993
+ } else
1994
+ try {
1995
+ c(JSON.stringify(i));
1996
+ } catch (w) {
1997
+ console.error("Couldn't convert value into a JSON string: ", i), c(null, w);
1998
+ }
1999
+ }
2000
+ function Ar(i) {
2001
+ if (i.substring(0, vt) !== je)
2002
+ return JSON.parse(i);
2003
+ var c = i.substring(fn), u = i.substring(vt, fn), _;
2004
+ if (u === ht && Zt.test(c)) {
2005
+ var p = c.match(Zt);
2006
+ _ = p[1], c = c.substring(p[0].length);
2007
+ }
2008
+ var l = ln(c);
2009
+ switch (u) {
2010
+ case mt:
2011
+ return l;
2012
+ case ht:
2013
+ return C([l], { type: _ });
2014
+ case zt:
2015
+ return new Int8Array(l);
2016
+ case en:
2017
+ return new Uint8Array(l);
2018
+ case tn:
2019
+ return new Uint8ClampedArray(l);
2020
+ case nn:
2021
+ return new Int16Array(l);
2022
+ case on:
2023
+ return new Uint16Array(l);
2024
+ case rn:
2025
+ return new Int32Array(l);
2026
+ case an:
2027
+ return new Uint32Array(l);
2028
+ case sn:
2029
+ return new Float32Array(l);
2030
+ case un:
2031
+ return new Float64Array(l);
2032
+ default:
2033
+ throw new Error("Unkown type: " + u);
2034
+ }
2035
+ }
2036
+ var yt = {
2037
+ serialize: br,
2038
+ deserialize: Ar,
2039
+ stringToBuffer: ln,
2040
+ bufferToString: gt
2041
+ };
2042
+ function dn(i, c, u, _) {
2043
+ i.executeSql("CREATE TABLE IF NOT EXISTS " + c.storeName + " (id INTEGER PRIMARY KEY, key unique, value)", [], u, _);
2044
+ }
2045
+ function Sr(i) {
2046
+ var c = this, u = {
2047
+ db: null
2048
+ };
2049
+ if (i)
2050
+ for (var _ in i)
2051
+ u[_] = typeof i[_] != "string" ? i[_].toString() : i[_];
2052
+ var p = new e(function(l, w) {
2053
+ try {
2054
+ u.db = openDatabase(u.name, String(u.version), u.description, u.size);
2055
+ } catch (x) {
2056
+ return w(x);
2057
+ }
2058
+ u.db.transaction(function(x) {
2059
+ dn(x, u, function() {
2060
+ c._dbInfo = u, l();
2061
+ }, function(T, I) {
2062
+ w(I);
2063
+ });
2064
+ }, w);
2065
+ });
2066
+ return u.serializer = yt, p;
2067
+ }
2068
+ function me(i, c, u, _, p, l) {
2069
+ i.executeSql(u, _, p, function(w, x) {
2070
+ x.code === x.SYNTAX_ERR ? w.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?", [c.storeName], function(T, I) {
2071
+ I.rows.length ? l(T, x) : dn(T, c, function() {
2072
+ T.executeSql(u, _, p, l);
2073
+ }, l);
2074
+ }, l) : l(w, x);
2075
+ }, l);
2076
+ }
2077
+ function xr(i, c) {
2078
+ var u = this;
2079
+ i = d(i);
2080
+ var _ = new e(function(p, l) {
2081
+ u.ready().then(function() {
2082
+ var w = u._dbInfo;
2083
+ w.db.transaction(function(x) {
2084
+ me(x, w, "SELECT * FROM " + w.storeName + " WHERE key = ? LIMIT 1", [i], function(T, I) {
2085
+ var D = I.rows.length ? I.rows.item(0).value : null;
2086
+ D && (D = w.serializer.deserialize(D)), p(D);
2087
+ }, function(T, I) {
2088
+ l(I);
2089
+ });
2090
+ });
2091
+ }).catch(l);
2092
+ });
2093
+ return r(_, c), _;
2094
+ }
2095
+ function Tr(i, c) {
2096
+ var u = this, _ = new e(function(p, l) {
2097
+ u.ready().then(function() {
2098
+ var w = u._dbInfo;
2099
+ w.db.transaction(function(x) {
2100
+ me(x, w, "SELECT * FROM " + w.storeName, [], function(T, I) {
2101
+ for (var D = I.rows, k = D.length, B = 0; B < k; B++) {
2102
+ var U = D.item(B), G = U.value;
2103
+ if (G && (G = w.serializer.deserialize(G)), G = i(G, U.key, B + 1), G !== void 0) {
2104
+ p(G);
2105
+ return;
2106
+ }
2107
+ }
2108
+ p();
2109
+ }, function(T, I) {
2110
+ l(I);
2111
+ });
2112
+ });
2113
+ }).catch(l);
2114
+ });
2115
+ return r(_, c), _;
2116
+ }
2117
+ function _n(i, c, u, _) {
2118
+ var p = this;
2119
+ i = d(i);
2120
+ var l = new e(function(w, x) {
2121
+ p.ready().then(function() {
2122
+ c === void 0 && (c = null);
2123
+ var T = c, I = p._dbInfo;
2124
+ I.serializer.serialize(c, function(D, k) {
2125
+ k ? x(k) : I.db.transaction(function(B) {
2126
+ me(B, I, "INSERT OR REPLACE INTO " + I.storeName + " (key, value) VALUES (?, ?)", [i, D], function() {
2127
+ w(T);
2128
+ }, function(U, G) {
2129
+ x(G);
2130
+ });
2131
+ }, function(B) {
2132
+ if (B.code === B.QUOTA_ERR) {
2133
+ if (_ > 0) {
2134
+ w(_n.apply(p, [i, T, u, _ - 1]));
2135
+ return;
2136
+ }
2137
+ x(B);
2138
+ }
2139
+ });
2140
+ });
2141
+ }).catch(x);
2142
+ });
2143
+ return r(l, u), l;
2144
+ }
2145
+ function Ir(i, c, u) {
2146
+ return _n.apply(this, [i, c, u, 1]);
2147
+ }
2148
+ function Er(i, c) {
2149
+ var u = this;
2150
+ i = d(i);
2151
+ var _ = new e(function(p, l) {
2152
+ u.ready().then(function() {
2153
+ var w = u._dbInfo;
2154
+ w.db.transaction(function(x) {
2155
+ me(x, w, "DELETE FROM " + w.storeName + " WHERE key = ?", [i], function() {
2156
+ p();
2157
+ }, function(T, I) {
2158
+ l(I);
2159
+ });
2160
+ });
2161
+ }).catch(l);
2162
+ });
2163
+ return r(_, c), _;
2164
+ }
2165
+ function Or(i) {
2166
+ var c = this, u = new e(function(_, p) {
2167
+ c.ready().then(function() {
2168
+ var l = c._dbInfo;
2169
+ l.db.transaction(function(w) {
2170
+ me(w, l, "DELETE FROM " + l.storeName, [], function() {
2171
+ _();
2172
+ }, function(x, T) {
2173
+ p(T);
2174
+ });
2175
+ });
2176
+ }).catch(p);
2177
+ });
2178
+ return r(u, i), u;
2179
+ }
2180
+ function Dr(i) {
2181
+ var c = this, u = new e(function(_, p) {
2182
+ c.ready().then(function() {
2183
+ var l = c._dbInfo;
2184
+ l.db.transaction(function(w) {
2185
+ me(w, l, "SELECT COUNT(key) as c FROM " + l.storeName, [], function(x, T) {
2186
+ var I = T.rows.item(0).c;
2187
+ _(I);
2188
+ }, function(x, T) {
2189
+ p(T);
2190
+ });
2191
+ });
2192
+ }).catch(p);
2193
+ });
2194
+ return r(u, i), u;
2195
+ }
2196
+ function Cr(i, c) {
2197
+ var u = this, _ = new e(function(p, l) {
2198
+ u.ready().then(function() {
2199
+ var w = u._dbInfo;
2200
+ w.db.transaction(function(x) {
2201
+ me(x, w, "SELECT key FROM " + w.storeName + " WHERE id = ? LIMIT 1", [i + 1], function(T, I) {
2202
+ var D = I.rows.length ? I.rows.item(0).key : null;
2203
+ p(D);
2204
+ }, function(T, I) {
2205
+ l(I);
2206
+ });
2207
+ });
2208
+ }).catch(l);
2209
+ });
2210
+ return r(_, c), _;
2211
+ }
2212
+ function kr(i) {
2213
+ var c = this, u = new e(function(_, p) {
2214
+ c.ready().then(function() {
2215
+ var l = c._dbInfo;
2216
+ l.db.transaction(function(w) {
2217
+ me(w, l, "SELECT key FROM " + l.storeName, [], function(x, T) {
2218
+ for (var I = [], D = 0; D < T.rows.length; D++)
2219
+ I.push(T.rows.item(D).key);
2220
+ _(I);
2221
+ }, function(x, T) {
2222
+ p(T);
2223
+ });
2224
+ });
2225
+ }).catch(p);
2226
+ });
2227
+ return r(u, i), u;
2228
+ }
2229
+ function Rr(i) {
2230
+ return new e(function(c, u) {
2231
+ i.transaction(function(_) {
2232
+ _.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function(p, l) {
2233
+ for (var w = [], x = 0; x < l.rows.length; x++)
2234
+ w.push(l.rows.item(x).name);
2235
+ c({
2236
+ db: i,
2237
+ storeNames: w
2238
+ });
2239
+ }, function(p, l) {
2240
+ u(l);
2241
+ });
2242
+ }, function(_) {
2243
+ u(_);
2244
+ });
2245
+ });
2246
+ }
2247
+ function Pr(i, c) {
2248
+ c = y.apply(this, arguments);
2249
+ var u = this.config();
2250
+ i = typeof i != "function" && i || {}, i.name || (i.name = i.name || u.name, i.storeName = i.storeName || u.storeName);
2251
+ var _ = this, p;
2252
+ return i.name ? p = new e(function(l) {
2253
+ var w;
2254
+ i.name === u.name ? w = _._dbInfo.db : w = openDatabase(i.name, "", "", 0), i.storeName ? l({
2255
+ db: w,
2256
+ storeNames: [i.storeName]
2257
+ }) : l(Rr(w));
2258
+ }).then(function(l) {
2259
+ return new e(function(w, x) {
2260
+ l.db.transaction(function(T) {
2261
+ function I(U) {
2262
+ return new e(function(G, Q) {
2263
+ T.executeSql("DROP TABLE IF EXISTS " + U, [], function() {
2264
+ G();
2265
+ }, function(W, re) {
2266
+ Q(re);
2267
+ });
2268
+ });
2269
+ }
2270
+ for (var D = [], k = 0, B = l.storeNames.length; k < B; k++)
2271
+ D.push(I(l.storeNames[k]));
2272
+ e.all(D).then(function() {
2273
+ w();
2274
+ }).catch(function(U) {
2275
+ x(U);
2276
+ });
2277
+ }, function(T) {
2278
+ x(T);
2279
+ });
2280
+ });
2281
+ }) : p = e.reject("Invalid arguments"), r(p, c), p;
2282
+ }
2283
+ var Nr = {
2284
+ _driver: "webSQLStorage",
2285
+ _initStorage: Sr,
2286
+ _support: yr(),
2287
+ iterate: Tr,
2288
+ getItem: xr,
2289
+ setItem: Ir,
2290
+ removeItem: Er,
2291
+ clear: Or,
2292
+ length: Dr,
2293
+ key: Cr,
2294
+ keys: kr,
2295
+ dropInstance: Pr
2296
+ };
2297
+ function Lr() {
2298
+ try {
2299
+ return typeof localStorage < "u" && "setItem" in localStorage && // in IE8 typeof localStorage.setItem === 'object'
2300
+ !!localStorage.setItem;
2301
+ } catch {
2302
+ return !1;
2303
+ }
2304
+ }
2305
+ function pn(i, c) {
2306
+ var u = i.name + "/";
2307
+ return i.storeName !== c.storeName && (u += i.storeName + "/"), u;
2308
+ }
2309
+ function Mr() {
2310
+ var i = "_localforage_support_test";
2311
+ try {
2312
+ return localStorage.setItem(i, !0), localStorage.removeItem(i), !1;
2313
+ } catch {
2314
+ return !0;
2315
+ }
2316
+ }
2317
+ function Fr() {
2318
+ return !Mr() || localStorage.length > 0;
2319
+ }
2320
+ function Br(i) {
2321
+ var c = this, u = {};
2322
+ if (i)
2323
+ for (var _ in i)
2324
+ u[_] = i[_];
2325
+ return u.keyPrefix = pn(i, c._defaultConfig), Fr() ? (c._dbInfo = u, u.serializer = yt, e.resolve()) : e.reject();
2326
+ }
2327
+ function $r(i) {
2328
+ var c = this, u = c.ready().then(function() {
2329
+ for (var _ = c._dbInfo.keyPrefix, p = localStorage.length - 1; p >= 0; p--) {
2330
+ var l = localStorage.key(p);
2331
+ l.indexOf(_) === 0 && localStorage.removeItem(l);
2332
+ }
2333
+ });
2334
+ return r(u, i), u;
2335
+ }
2336
+ function Hr(i, c) {
2337
+ var u = this;
2338
+ i = d(i);
2339
+ var _ = u.ready().then(function() {
2340
+ var p = u._dbInfo, l = localStorage.getItem(p.keyPrefix + i);
2341
+ return l && (l = p.serializer.deserialize(l)), l;
2342
+ });
2343
+ return r(_, c), _;
2344
+ }
2345
+ function Vr(i, c) {
2346
+ var u = this, _ = u.ready().then(function() {
2347
+ for (var p = u._dbInfo, l = p.keyPrefix, w = l.length, x = localStorage.length, T = 1, I = 0; I < x; I++) {
2348
+ var D = localStorage.key(I);
2349
+ if (D.indexOf(l) === 0) {
2350
+ var k = localStorage.getItem(D);
2351
+ if (k && (k = p.serializer.deserialize(k)), k = i(k, D.substring(w), T++), k !== void 0)
2352
+ return k;
2353
+ }
2354
+ }
2355
+ });
2356
+ return r(_, c), _;
2357
+ }
2358
+ function Ur(i, c) {
2359
+ var u = this, _ = u.ready().then(function() {
2360
+ var p = u._dbInfo, l;
2361
+ try {
2362
+ l = localStorage.key(i);
2363
+ } catch {
2364
+ l = null;
2365
+ }
2366
+ return l && (l = l.substring(p.keyPrefix.length)), l;
2367
+ });
2368
+ return r(_, c), _;
2369
+ }
2370
+ function Gr(i) {
2371
+ var c = this, u = c.ready().then(function() {
2372
+ for (var _ = c._dbInfo, p = localStorage.length, l = [], w = 0; w < p; w++) {
2373
+ var x = localStorage.key(w);
2374
+ x.indexOf(_.keyPrefix) === 0 && l.push(x.substring(_.keyPrefix.length));
2375
+ }
2376
+ return l;
2377
+ });
2378
+ return r(u, i), u;
2379
+ }
2380
+ function Kr(i) {
2381
+ var c = this, u = c.keys().then(function(_) {
2382
+ return _.length;
2383
+ });
2384
+ return r(u, i), u;
2385
+ }
2386
+ function Yr(i, c) {
2387
+ var u = this;
2388
+ i = d(i);
2389
+ var _ = u.ready().then(function() {
2390
+ var p = u._dbInfo;
2391
+ localStorage.removeItem(p.keyPrefix + i);
2392
+ });
2393
+ return r(_, c), _;
2394
+ }
2395
+ function Wr(i, c, u) {
2396
+ var _ = this;
2397
+ i = d(i);
2398
+ var p = _.ready().then(function() {
2399
+ c === void 0 && (c = null);
2400
+ var l = c;
2401
+ return new e(function(w, x) {
2402
+ var T = _._dbInfo;
2403
+ T.serializer.serialize(c, function(I, D) {
2404
+ if (D)
2405
+ x(D);
2406
+ else
2407
+ try {
2408
+ localStorage.setItem(T.keyPrefix + i, I), w(l);
2409
+ } catch (k) {
2410
+ (k.name === "QuotaExceededError" || k.name === "NS_ERROR_DOM_QUOTA_REACHED") && x(k), x(k);
2411
+ }
2412
+ });
2413
+ });
2414
+ });
2415
+ return r(p, u), p;
2416
+ }
2417
+ function qr(i, c) {
2418
+ if (c = y.apply(this, arguments), i = typeof i != "function" && i || {}, !i.name) {
2419
+ var u = this.config();
2420
+ i.name = i.name || u.name, i.storeName = i.storeName || u.storeName;
2421
+ }
2422
+ var _ = this, p;
2423
+ return i.name ? p = new e(function(l) {
2424
+ i.storeName ? l(pn(i, _._defaultConfig)) : l(i.name + "/");
2425
+ }).then(function(l) {
2426
+ for (var w = localStorage.length - 1; w >= 0; w--) {
2427
+ var x = localStorage.key(w);
2428
+ x.indexOf(l) === 0 && localStorage.removeItem(x);
2429
+ }
2430
+ }) : p = e.reject("Invalid arguments"), r(p, c), p;
2431
+ }
2432
+ var Jr = {
2433
+ _driver: "localStorageWrapper",
2434
+ _initStorage: Br,
2435
+ _support: Lr(),
2436
+ iterate: Vr,
2437
+ getItem: Hr,
2438
+ setItem: Wr,
2439
+ removeItem: Yr,
2440
+ clear: $r,
2441
+ length: Kr,
2442
+ key: Ur,
2443
+ keys: Gr,
2444
+ dropInstance: qr
2445
+ }, Xr = function(c, u) {
2446
+ return c === u || typeof c == "number" && typeof u == "number" && isNaN(c) && isNaN(u);
2447
+ }, Qr = function(c, u) {
2448
+ for (var _ = c.length, p = 0; p < _; ) {
2449
+ if (Xr(c[p], u))
2450
+ return !0;
2451
+ p++;
2452
+ }
2453
+ return !1;
2454
+ }, vn = Array.isArray || function(i) {
2455
+ return Object.prototype.toString.call(i) === "[object Array]";
2456
+ }, Le = {}, mn = {}, Te = {
2457
+ INDEXEDDB: Qe,
2458
+ WEBSQL: Nr,
2459
+ LOCALSTORAGE: Jr
2460
+ }, jr = [Te.INDEXEDDB._driver, Te.WEBSQL._driver, Te.LOCALSTORAGE._driver], Ze = ["dropInstance"], wt = ["clear", "getItem", "iterate", "key", "keys", "length", "removeItem", "setItem"].concat(Ze), Zr = {
2461
+ description: "",
2462
+ driver: jr.slice(),
2463
+ name: "localforage",
2464
+ // Default DB size is _JUST UNDER_ 5MB, as it's the highest size
2465
+ // we can use without a prompt.
2466
+ size: 4980736,
2467
+ storeName: "keyvaluepairs",
2468
+ version: 1
2469
+ };
2470
+ function zr(i, c) {
2471
+ i[c] = function() {
2472
+ var u = arguments;
2473
+ return i.ready().then(function() {
2474
+ return i[c].apply(i, u);
2475
+ });
2476
+ };
2477
+ }
2478
+ function bt() {
2479
+ for (var i = 1; i < arguments.length; i++) {
2480
+ var c = arguments[i];
2481
+ if (c)
2482
+ for (var u in c)
2483
+ c.hasOwnProperty(u) && (vn(c[u]) ? arguments[0][u] = c[u].slice() : arguments[0][u] = c[u]);
2484
+ }
2485
+ return arguments[0];
2486
+ }
2487
+ var eo = (function() {
2488
+ function i(c) {
2489
+ h(this, i);
2490
+ for (var u in Te)
2491
+ if (Te.hasOwnProperty(u)) {
2492
+ var _ = Te[u], p = _._driver;
2493
+ this[u] = p, Le[p] || this.defineDriver(_);
2494
+ }
2495
+ this._defaultConfig = bt({}, Zr), this._config = bt({}, this._defaultConfig, c), this._driverSet = null, this._initDriver = null, this._ready = !1, this._dbInfo = null, this._wrapLibraryMethodsWithReady(), this.setDriver(this._config.driver).catch(function() {
2496
+ });
2497
+ }
2498
+ return i.prototype.config = function(u) {
2499
+ if ((typeof u > "u" ? "undefined" : v(u)) === "object") {
2500
+ if (this._ready)
2501
+ return new Error("Can't call config() after localforage has been used.");
2502
+ for (var _ in u) {
2503
+ if (_ === "storeName" && (u[_] = u[_].replace(/\W/g, "_")), _ === "version" && typeof u[_] != "number")
2504
+ return new Error("Database version must be a number.");
2505
+ this._config[_] = u[_];
2506
+ }
2507
+ return "driver" in u && u.driver ? this.setDriver(this._config.driver) : !0;
2508
+ } else return typeof u == "string" ? this._config[u] : this._config;
2509
+ }, i.prototype.defineDriver = function(u, _, p) {
2510
+ var l = new e(function(w, x) {
2511
+ try {
2512
+ var T = u._driver, I = new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");
2513
+ if (!u._driver) {
2514
+ x(I);
2515
+ return;
2516
+ }
2517
+ for (var D = wt.concat("_initStorage"), k = 0, B = D.length; k < B; k++) {
2518
+ var U = D[k], G = !Qr(Ze, U);
2519
+ if ((G || u[U]) && typeof u[U] != "function") {
2520
+ x(I);
2521
+ return;
2522
+ }
2523
+ }
2524
+ var Q = function() {
2525
+ for (var Me = function(ro) {
2526
+ return function() {
2527
+ var oo = new Error("Method " + ro + " is not implemented by the current driver"), hn = e.reject(oo);
2528
+ return r(hn, arguments[arguments.length - 1]), hn;
2529
+ };
2530
+ }, At = 0, no = Ze.length; At < no; At++) {
2531
+ var St = Ze[At];
2532
+ u[St] || (u[St] = Me(St));
2533
+ }
2534
+ };
2535
+ Q();
2536
+ var W = function(Me) {
2537
+ Le[T] && console.info("Redefining LocalForage driver: " + T), Le[T] = u, mn[T] = Me, w();
2538
+ };
2539
+ "_support" in u ? u._support && typeof u._support == "function" ? u._support().then(W, x) : W(!!u._support) : W(!0);
2540
+ } catch (re) {
2541
+ x(re);
2542
+ }
2543
+ });
2544
+ return s(l, _, p), l;
2545
+ }, i.prototype.driver = function() {
2546
+ return this._driver || null;
2547
+ }, i.prototype.getDriver = function(u, _, p) {
2548
+ var l = Le[u] ? e.resolve(Le[u]) : e.reject(new Error("Driver not found."));
2549
+ return s(l, _, p), l;
2550
+ }, i.prototype.getSerializer = function(u) {
2551
+ var _ = e.resolve(yt);
2552
+ return s(_, u), _;
2553
+ }, i.prototype.ready = function(u) {
2554
+ var _ = this, p = _._driverSet.then(function() {
2555
+ return _._ready === null && (_._ready = _._initDriver()), _._ready;
2556
+ });
2557
+ return s(p, u, u), p;
2558
+ }, i.prototype.setDriver = function(u, _, p) {
2559
+ var l = this;
2560
+ vn(u) || (u = [u]);
2561
+ var w = this._getSupportedDrivers(u);
2562
+ function x() {
2563
+ l._config.driver = l.driver();
2564
+ }
2565
+ function T(k) {
2566
+ return l._extend(k), x(), l._ready = l._initStorage(l._config), l._ready;
2567
+ }
2568
+ function I(k) {
2569
+ return function() {
2570
+ var B = 0;
2571
+ function U() {
2572
+ for (; B < k.length; ) {
2573
+ var G = k[B];
2574
+ return B++, l._dbInfo = null, l._ready = null, l.getDriver(G).then(T).catch(U);
2575
+ }
2576
+ x();
2577
+ var Q = new Error("No available storage method found.");
2578
+ return l._driverSet = e.reject(Q), l._driverSet;
2579
+ }
2580
+ return U();
2581
+ };
2582
+ }
2583
+ var D = this._driverSet !== null ? this._driverSet.catch(function() {
2584
+ return e.resolve();
2585
+ }) : e.resolve();
2586
+ return this._driverSet = D.then(function() {
2587
+ var k = w[0];
2588
+ return l._dbInfo = null, l._ready = null, l.getDriver(k).then(function(B) {
2589
+ l._driver = B._driver, x(), l._wrapLibraryMethodsWithReady(), l._initDriver = I(w);
2590
+ });
2591
+ }).catch(function() {
2592
+ x();
2593
+ var k = new Error("No available storage method found.");
2594
+ return l._driverSet = e.reject(k), l._driverSet;
2595
+ }), s(this._driverSet, _, p), this._driverSet;
2596
+ }, i.prototype.supports = function(u) {
2597
+ return !!mn[u];
2598
+ }, i.prototype._extend = function(u) {
2599
+ bt(this, u);
2600
+ }, i.prototype._getSupportedDrivers = function(u) {
2601
+ for (var _ = [], p = 0, l = u.length; p < l; p++) {
2602
+ var w = u[p];
2603
+ this.supports(w) && _.push(w);
2604
+ }
2605
+ return _;
2606
+ }, i.prototype._wrapLibraryMethodsWithReady = function() {
2607
+ for (var u = 0, _ = wt.length; u < _; u++)
2608
+ zr(this, wt[u]);
2609
+ }, i.prototype.createInstance = function(u) {
2610
+ return new i(u);
2611
+ }, i;
2612
+ })(), to = new eo();
2613
+ a.exports = to;
2614
+ }, { 3: 3 }] }, {}, [4])(4);
2615
+ });
2616
+ })(It)), It.exports;
2617
+ }
2618
+ var Ta = xa();
2619
+ const Et = /* @__PURE__ */ pr(Ta);
2620
+ let ye;
2621
+ function Ia(t) {
2622
+ ye = Et.createInstance(`${t}-atrament`), ye.config({
2623
+ name: t
2624
+ }), ye.setDriver([Et.INDEXEDDB, Et.LOCALSTORAGE]);
2625
+ }
2626
+ async function Ea(t) {
2627
+ return await ye.getItem(t) !== null;
2628
+ }
2629
+ async function Oa(t) {
2630
+ return await ye.getItem(t);
2631
+ }
2632
+ async function Da(t, o) {
2633
+ await ye.setItem(t, o);
2634
+ }
2635
+ async function Ca(t) {
2636
+ await ye.removeItem(t);
2637
+ }
2638
+ async function ka() {
2639
+ return await ye.keys();
2640
+ }
2641
+ const Ra = {
2642
+ init: Ia,
2643
+ exists: Ea,
2644
+ get: Oa,
2645
+ set: Da,
2646
+ remove: Ca,
2647
+ keys: ka
2648
+ };
2649
+ var Be = { exports: {} }, Ot = { exports: {} }, Tn;
2650
+ function Pa() {
2651
+ return Tn || (Tn = 1, (function(t) {
2652
+ function o(n, a) {
2653
+ var f, v, h, b, A, S, C, e;
2654
+ for (f = n.length & 3, v = n.length - f, h = a, A = 3432918353, S = 461845907, e = 0; e < v; )
2655
+ C = n.charCodeAt(e) & 255 | (n.charCodeAt(++e) & 255) << 8 | (n.charCodeAt(++e) & 255) << 16 | (n.charCodeAt(++e) & 255) << 24, ++e, C = (C & 65535) * A + (((C >>> 16) * A & 65535) << 16) & 4294967295, C = C << 15 | C >>> 17, C = (C & 65535) * S + (((C >>> 16) * S & 65535) << 16) & 4294967295, h ^= C, h = h << 13 | h >>> 19, b = (h & 65535) * 5 + (((h >>> 16) * 5 & 65535) << 16) & 4294967295, h = (b & 65535) + 27492 + (((b >>> 16) + 58964 & 65535) << 16);
2656
+ switch (C = 0, f) {
2657
+ case 3:
2658
+ C ^= (n.charCodeAt(e + 2) & 255) << 16;
2659
+ case 2:
2660
+ C ^= (n.charCodeAt(e + 1) & 255) << 8;
2661
+ case 1:
2662
+ C ^= n.charCodeAt(e) & 255, C = (C & 65535) * A + (((C >>> 16) * A & 65535) << 16) & 4294967295, C = C << 15 | C >>> 17, C = (C & 65535) * S + (((C >>> 16) * S & 65535) << 16) & 4294967295, h ^= C;
2663
+ }
2664
+ return h ^= n.length, h ^= h >>> 16, h = (h & 65535) * 2246822507 + (((h >>> 16) * 2246822507 & 65535) << 16) & 4294967295, h ^= h >>> 13, h = (h & 65535) * 3266489909 + (((h >>> 16) * 3266489909 & 65535) << 16) & 4294967295, h ^= h >>> 16, h >>> 0;
2665
+ }
2666
+ t.exports = o;
2667
+ })(Ot)), Ot.exports;
2668
+ }
2669
+ var Dt = { exports: {} }, In;
2670
+ function Na() {
2671
+ return In || (In = 1, (function(t) {
2672
+ function o(n, a) {
2673
+ for (var f = n.length, v = a ^ f, h = 0, b; f >= 4; )
2674
+ b = n.charCodeAt(h) & 255 | (n.charCodeAt(++h) & 255) << 8 | (n.charCodeAt(++h) & 255) << 16 | (n.charCodeAt(++h) & 255) << 24, b = (b & 65535) * 1540483477 + (((b >>> 16) * 1540483477 & 65535) << 16), b ^= b >>> 24, b = (b & 65535) * 1540483477 + (((b >>> 16) * 1540483477 & 65535) << 16), v = (v & 65535) * 1540483477 + (((v >>> 16) * 1540483477 & 65535) << 16) ^ b, f -= 4, ++h;
2675
+ switch (f) {
2676
+ case 3:
2677
+ v ^= (n.charCodeAt(h + 2) & 255) << 16;
2678
+ case 2:
2679
+ v ^= (n.charCodeAt(h + 1) & 255) << 8;
2680
+ case 1:
2681
+ v ^= n.charCodeAt(h) & 255, v = (v & 65535) * 1540483477 + (((v >>> 16) * 1540483477 & 65535) << 16);
2682
+ }
2683
+ return v ^= v >>> 13, v = (v & 65535) * 1540483477 + (((v >>> 16) * 1540483477 & 65535) << 16), v ^= v >>> 15, v >>> 0;
2684
+ }
2685
+ t.exports = o;
2686
+ })(Dt)), Dt.exports;
2687
+ }
2688
+ var En;
2689
+ function La() {
2690
+ if (En) return Be.exports;
2691
+ En = 1;
2692
+ var t = Pa(), o = Na();
2693
+ return Be.exports = t, Be.exports.murmur3 = t, Be.exports.murmur2 = o, Be.exports;
2694
+ }
2695
+ var Ma = La();
2696
+ const Fa = /* @__PURE__ */ pr(Ma), Ce = "__atrament_storage";
2697
+ let Oe = Promise.resolve();
2698
+ async function Ue(t) {
2699
+ try {
2700
+ const o = await window.Neutralino.storage.getData(t);
2701
+ return JSON.parse(o);
2702
+ } catch (o) {
2703
+ return console.warn(o.message), null;
2704
+ }
2705
+ }
2706
+ async function Qt(t, o) {
2707
+ const n = JSON.stringify(o);
2708
+ return await window.Neutralino.storage.setData(t, n), n;
2709
+ }
2710
+ async function Ba(t) {
2711
+ return await window.Neutralino.storage.setData(t, null), !0;
2712
+ }
2713
+ function jt(t) {
2714
+ return `storage_${Fa(t)}`;
2715
+ }
2716
+ async function $a(t, o) {
2717
+ return Oe = Oe.then(async () => {
2718
+ let n = await Ue(Ce);
2719
+ n === null && (n = {}), n[o] = t, await Qt(Ce, n);
2720
+ }).catch((n) => console.error(n.message)), Oe;
2721
+ }
2722
+ async function Ha(t) {
2723
+ return Oe = Oe.then(async () => {
2724
+ let o = await Ue(Ce);
2725
+ o === null && (o = {}), delete o[t], await Qt(Ce, o);
2726
+ }).catch((o) => console.error(o.message)), Oe;
2727
+ }
2728
+ function Va() {
2729
+ }
2730
+ async function Ua(t) {
2731
+ return (await vr()).includes(t);
2732
+ }
2733
+ async function Ga(t) {
2734
+ const o = await Ue(Ce), n = o === null ? jt(t) : o[t];
2735
+ return await Ue(n);
2736
+ }
2737
+ async function Ka(t, o) {
2738
+ const n = jt(t);
2739
+ try {
2740
+ await Qt(n, o), await $a(n, t);
2741
+ } catch (a) {
2742
+ console.error(a.message);
2743
+ }
2744
+ }
2745
+ async function Ya(t) {
2746
+ const o = jt(t);
2747
+ try {
2748
+ await Ba(o), await Ha(t);
2749
+ } catch (n) {
2750
+ console.error(n.message);
2751
+ }
2752
+ }
2753
+ async function vr() {
2754
+ const t = await Ue(Ce);
2755
+ return t === null ? [] : Object.keys(t);
2756
+ }
2757
+ const Wa = {
2758
+ init: Va,
2759
+ exists: Ua,
2760
+ get: Ga,
2761
+ set: Ka,
2762
+ remove: Ya,
2763
+ keys: vr
2764
+ };
2765
+ var Ct = {};
2766
+ var On;
2767
+ function qa() {
2768
+ return On || (On = 1, (function(t) {
2769
+ (function() {
2770
+ var o = function() {
2771
+ this.init();
2772
+ };
2773
+ o.prototype = {
2774
+ /**
2775
+ * Initialize the global Howler object.
2776
+ * @return {Howler}
2777
+ */
2778
+ init: function() {
2779
+ var e = this || n;
2780
+ return e._counter = 1e3, e._html5AudioPool = [], e.html5PoolSize = 10, e._codecs = {}, e._howls = [], e._muted = !1, e._volume = 1, e._canPlayEvent = "canplaythrough", e._navigator = typeof window < "u" && window.navigator ? window.navigator : null, e.masterGain = null, e.noAudio = !1, e.usingWebAudio = !0, e.autoSuspend = !0, e.ctx = null, e.autoUnlock = !0, e._setup(), e;
2781
+ },
2782
+ /**
2783
+ * Get/set the global volume for all sounds.
2784
+ * @param {Float} vol Volume from 0.0 to 1.0.
2785
+ * @return {Howler/Float} Returns self or current volume.
2786
+ */
2787
+ volume: function(e) {
2788
+ var r = this || n;
2789
+ if (e = parseFloat(e), r.ctx || C(), typeof e < "u" && e >= 0 && e <= 1) {
2790
+ if (r._volume = e, r._muted)
2791
+ return r;
2792
+ r.usingWebAudio && r.masterGain.gain.setValueAtTime(e, n.ctx.currentTime);
2793
+ for (var s = 0; s < r._howls.length; s++)
2794
+ if (!r._howls[s]._webAudio)
2795
+ for (var d = r._howls[s]._getSoundIds(), y = 0; y < d.length; y++) {
2796
+ var g = r._howls[s]._soundById(d[y]);
2797
+ g && g._node && (g._node.volume = g._volume * e);
2798
+ }
2799
+ return r;
2800
+ }
2801
+ return r._volume;
2802
+ },
2803
+ /**
2804
+ * Handle muting and unmuting globally.
2805
+ * @param {Boolean} muted Is muted or not.
2806
+ */
2807
+ mute: function(e) {
2808
+ var r = this || n;
2809
+ r.ctx || C(), r._muted = e, r.usingWebAudio && r.masterGain.gain.setValueAtTime(e ? 0 : r._volume, n.ctx.currentTime);
2810
+ for (var s = 0; s < r._howls.length; s++)
2811
+ if (!r._howls[s]._webAudio)
2812
+ for (var d = r._howls[s]._getSoundIds(), y = 0; y < d.length; y++) {
2813
+ var g = r._howls[s]._soundById(d[y]);
2814
+ g && g._node && (g._node.muted = e ? !0 : g._muted);
2815
+ }
2816
+ return r;
2817
+ },
2818
+ /**
2819
+ * Handle stopping all sounds globally.
2820
+ */
2821
+ stop: function() {
2822
+ for (var e = this || n, r = 0; r < e._howls.length; r++)
2823
+ e._howls[r].stop();
2824
+ return e;
2825
+ },
2826
+ /**
2827
+ * Unload and destroy all currently loaded Howl objects.
2828
+ * @return {Howler}
2829
+ */
2830
+ unload: function() {
2831
+ for (var e = this || n, r = e._howls.length - 1; r >= 0; r--)
2832
+ e._howls[r].unload();
2833
+ return e.usingWebAudio && e.ctx && typeof e.ctx.close < "u" && (e.ctx.close(), e.ctx = null, C()), e;
2834
+ },
2835
+ /**
2836
+ * Check for codec support of specific extension.
2837
+ * @param {String} ext Audio file extention.
2838
+ * @return {Boolean}
2839
+ */
2840
+ codecs: function(e) {
2841
+ return (this || n)._codecs[e.replace(/^x-/, "")];
2842
+ },
2843
+ /**
2844
+ * Setup various state values for global tracking.
2845
+ * @return {Howler}
2846
+ */
2847
+ _setup: function() {
2848
+ var e = this || n;
2849
+ if (e.state = e.ctx && e.ctx.state || "suspended", e._autoSuspend(), !e.usingWebAudio)
2850
+ if (typeof Audio < "u")
2851
+ try {
2852
+ var r = new Audio();
2853
+ typeof r.oncanplaythrough > "u" && (e._canPlayEvent = "canplay");
2854
+ } catch {
2855
+ e.noAudio = !0;
2856
+ }
2857
+ else
2858
+ e.noAudio = !0;
2859
+ try {
2860
+ var r = new Audio();
2861
+ r.muted && (e.noAudio = !0);
2862
+ } catch {
2863
+ }
2864
+ return e.noAudio || e._setupCodecs(), e;
2865
+ },
2866
+ /**
2867
+ * Check for browser support for various codecs and cache the results.
2868
+ * @return {Howler}
2869
+ */
2870
+ _setupCodecs: function() {
2871
+ var e = this || n, r = null;
2872
+ try {
2873
+ r = typeof Audio < "u" ? new Audio() : null;
2874
+ } catch {
2875
+ return e;
2876
+ }
2877
+ if (!r || typeof r.canPlayType != "function")
2878
+ return e;
2879
+ var s = r.canPlayType("audio/mpeg;").replace(/^no$/, ""), d = e._navigator ? e._navigator.userAgent : "", y = d.match(/OPR\/(\d+)/g), g = y && parseInt(y[0].split("/")[1], 10) < 33, m = d.indexOf("Safari") !== -1 && d.indexOf("Chrome") === -1, O = d.match(/Version\/(.*?) /), P = m && O && parseInt(O[1], 10) < 15;
2880
+ return e._codecs = {
2881
+ mp3: !!(!g && (s || r.canPlayType("audio/mp3;").replace(/^no$/, ""))),
2882
+ mpeg: !!s,
2883
+ opus: !!r.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ""),
2884
+ ogg: !!r.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""),
2885
+ oga: !!r.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""),
2886
+ wav: !!(r.canPlayType('audio/wav; codecs="1"') || r.canPlayType("audio/wav")).replace(/^no$/, ""),
2887
+ aac: !!r.canPlayType("audio/aac;").replace(/^no$/, ""),
2888
+ caf: !!r.canPlayType("audio/x-caf;").replace(/^no$/, ""),
2889
+ m4a: !!(r.canPlayType("audio/x-m4a;") || r.canPlayType("audio/m4a;") || r.canPlayType("audio/aac;")).replace(/^no$/, ""),
2890
+ m4b: !!(r.canPlayType("audio/x-m4b;") || r.canPlayType("audio/m4b;") || r.canPlayType("audio/aac;")).replace(/^no$/, ""),
2891
+ mp4: !!(r.canPlayType("audio/x-mp4;") || r.canPlayType("audio/mp4;") || r.canPlayType("audio/aac;")).replace(/^no$/, ""),
2892
+ weba: !!(!P && r.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "")),
2893
+ webm: !!(!P && r.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "")),
2894
+ dolby: !!r.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, ""),
2895
+ flac: !!(r.canPlayType("audio/x-flac;") || r.canPlayType("audio/flac;")).replace(/^no$/, "")
2896
+ }, e;
2897
+ },
2898
+ /**
2899
+ * Some browsers/devices will only allow audio to be played after a user interaction.
2900
+ * Attempt to automatically unlock audio on the first user interaction.
2901
+ * Concept from: http://paulbakaus.com/tutorials/html5/web-audio-on-ios/
2902
+ * @return {Howler}
2903
+ */
2904
+ _unlockAudio: function() {
2905
+ var e = this || n;
2906
+ if (!(e._audioUnlocked || !e.ctx)) {
2907
+ e._audioUnlocked = !1, e.autoUnlock = !1, !e._mobileUnloaded && e.ctx.sampleRate !== 44100 && (e._mobileUnloaded = !0, e.unload()), e._scratchBuffer = e.ctx.createBuffer(1, 1, 22050);
2908
+ var r = function(s) {
2909
+ for (; e._html5AudioPool.length < e.html5PoolSize; )
2910
+ try {
2911
+ var d = new Audio();
2912
+ d._unlocked = !0, e._releaseHtml5Audio(d);
2913
+ } catch {
2914
+ e.noAudio = !0;
2915
+ break;
2916
+ }
2917
+ for (var y = 0; y < e._howls.length; y++)
2918
+ if (!e._howls[y]._webAudio)
2919
+ for (var g = e._howls[y]._getSoundIds(), m = 0; m < g.length; m++) {
2920
+ var O = e._howls[y]._soundById(g[m]);
2921
+ O && O._node && !O._node._unlocked && (O._node._unlocked = !0, O._node.load());
2922
+ }
2923
+ e._autoResume();
2924
+ var P = e.ctx.createBufferSource();
2925
+ P.buffer = e._scratchBuffer, P.connect(e.ctx.destination), typeof P.start > "u" ? P.noteOn(0) : P.start(0), typeof e.ctx.resume == "function" && e.ctx.resume(), P.onended = function() {
2926
+ P.disconnect(0), e._audioUnlocked = !0, document.removeEventListener("touchstart", r, !0), document.removeEventListener("touchend", r, !0), document.removeEventListener("click", r, !0), document.removeEventListener("keydown", r, !0);
2927
+ for (var $ = 0; $ < e._howls.length; $++)
2928
+ e._howls[$]._emit("unlock");
2929
+ };
2930
+ };
2931
+ return document.addEventListener("touchstart", r, !0), document.addEventListener("touchend", r, !0), document.addEventListener("click", r, !0), document.addEventListener("keydown", r, !0), e;
2932
+ }
2933
+ },
2934
+ /**
2935
+ * Get an unlocked HTML5 Audio object from the pool. If none are left,
2936
+ * return a new Audio object and throw a warning.
2937
+ * @return {Audio} HTML5 Audio object.
2938
+ */
2939
+ _obtainHtml5Audio: function() {
2940
+ var e = this || n;
2941
+ if (e._html5AudioPool.length)
2942
+ return e._html5AudioPool.pop();
2943
+ var r = new Audio().play();
2944
+ return r && typeof Promise < "u" && (r instanceof Promise || typeof r.then == "function") && r.catch(function() {
2945
+ console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.");
2946
+ }), new Audio();
2947
+ },
2948
+ /**
2949
+ * Return an activated HTML5 Audio object to the pool.
2950
+ * @return {Howler}
2951
+ */
2952
+ _releaseHtml5Audio: function(e) {
2953
+ var r = this || n;
2954
+ return e._unlocked && r._html5AudioPool.push(e), r;
2955
+ },
2956
+ /**
2957
+ * Automatically suspend the Web Audio AudioContext after no sound has played for 30 seconds.
2958
+ * This saves processing/energy and fixes various browser-specific bugs with audio getting stuck.
2959
+ * @return {Howler}
2960
+ */
2961
+ _autoSuspend: function() {
2962
+ var e = this;
2963
+ if (!(!e.autoSuspend || !e.ctx || typeof e.ctx.suspend > "u" || !n.usingWebAudio)) {
2964
+ for (var r = 0; r < e._howls.length; r++)
2965
+ if (e._howls[r]._webAudio) {
2966
+ for (var s = 0; s < e._howls[r]._sounds.length; s++)
2967
+ if (!e._howls[r]._sounds[s]._paused)
2968
+ return e;
2969
+ }
2970
+ return e._suspendTimer && clearTimeout(e._suspendTimer), e._suspendTimer = setTimeout(function() {
2971
+ if (e.autoSuspend) {
2972
+ e._suspendTimer = null, e.state = "suspending";
2973
+ var d = function() {
2974
+ e.state = "suspended", e._resumeAfterSuspend && (delete e._resumeAfterSuspend, e._autoResume());
2975
+ };
2976
+ e.ctx.suspend().then(d, d);
2977
+ }
2978
+ }, 3e4), e;
2979
+ }
2980
+ },
2981
+ /**
2982
+ * Automatically resume the Web Audio AudioContext when a new sound is played.
2983
+ * @return {Howler}
2984
+ */
2985
+ _autoResume: function() {
2986
+ var e = this;
2987
+ if (!(!e.ctx || typeof e.ctx.resume > "u" || !n.usingWebAudio))
2988
+ return e.state === "running" && e.ctx.state !== "interrupted" && e._suspendTimer ? (clearTimeout(e._suspendTimer), e._suspendTimer = null) : e.state === "suspended" || e.state === "running" && e.ctx.state === "interrupted" ? (e.ctx.resume().then(function() {
2989
+ e.state = "running";
2990
+ for (var r = 0; r < e._howls.length; r++)
2991
+ e._howls[r]._emit("resume");
2992
+ }), e._suspendTimer && (clearTimeout(e._suspendTimer), e._suspendTimer = null)) : e.state === "suspending" && (e._resumeAfterSuspend = !0), e;
2993
+ }
2994
+ };
2995
+ var n = new o(), a = function(e) {
2996
+ var r = this;
2997
+ if (!e.src || e.src.length === 0) {
2998
+ console.error("An array of source files must be passed with any new Howl.");
2999
+ return;
3000
+ }
3001
+ r.init(e);
3002
+ };
3003
+ a.prototype = {
3004
+ /**
3005
+ * Initialize a new Howl group object.
3006
+ * @param {Object} o Passed in properties for this group.
3007
+ * @return {Howl}
3008
+ */
3009
+ init: function(e) {
3010
+ var r = this;
3011
+ return n.ctx || C(), r._autoplay = e.autoplay || !1, r._format = typeof e.format != "string" ? e.format : [e.format], r._html5 = e.html5 || !1, r._muted = e.mute || !1, r._loop = e.loop || !1, r._pool = e.pool || 5, r._preload = typeof e.preload == "boolean" || e.preload === "metadata" ? e.preload : !0, r._rate = e.rate || 1, r._sprite = e.sprite || {}, r._src = typeof e.src != "string" ? e.src : [e.src], r._volume = e.volume !== void 0 ? e.volume : 1, r._xhr = {
3012
+ method: e.xhr && e.xhr.method ? e.xhr.method : "GET",
3013
+ headers: e.xhr && e.xhr.headers ? e.xhr.headers : null,
3014
+ withCredentials: e.xhr && e.xhr.withCredentials ? e.xhr.withCredentials : !1
3015
+ }, r._duration = 0, r._state = "unloaded", r._sounds = [], r._endTimers = {}, r._queue = [], r._playLock = !1, r._onend = e.onend ? [{ fn: e.onend }] : [], r._onfade = e.onfade ? [{ fn: e.onfade }] : [], r._onload = e.onload ? [{ fn: e.onload }] : [], r._onloaderror = e.onloaderror ? [{ fn: e.onloaderror }] : [], r._onplayerror = e.onplayerror ? [{ fn: e.onplayerror }] : [], r._onpause = e.onpause ? [{ fn: e.onpause }] : [], r._onplay = e.onplay ? [{ fn: e.onplay }] : [], r._onstop = e.onstop ? [{ fn: e.onstop }] : [], r._onmute = e.onmute ? [{ fn: e.onmute }] : [], r._onvolume = e.onvolume ? [{ fn: e.onvolume }] : [], r._onrate = e.onrate ? [{ fn: e.onrate }] : [], r._onseek = e.onseek ? [{ fn: e.onseek }] : [], r._onunlock = e.onunlock ? [{ fn: e.onunlock }] : [], r._onresume = [], r._webAudio = n.usingWebAudio && !r._html5, typeof n.ctx < "u" && n.ctx && n.autoUnlock && n._unlockAudio(), n._howls.push(r), r._autoplay && r._queue.push({
3016
+ event: "play",
3017
+ action: function() {
3018
+ r.play();
3019
+ }
3020
+ }), r._preload && r._preload !== "none" && r.load(), r;
3021
+ },
3022
+ /**
3023
+ * Load the audio file.
3024
+ * @return {Howler}
3025
+ */
3026
+ load: function() {
3027
+ var e = this, r = null;
3028
+ if (n.noAudio) {
3029
+ e._emit("loaderror", null, "No audio support.");
3030
+ return;
3031
+ }
3032
+ typeof e._src == "string" && (e._src = [e._src]);
3033
+ for (var s = 0; s < e._src.length; s++) {
3034
+ var d, y;
3035
+ if (e._format && e._format[s])
3036
+ d = e._format[s];
3037
+ else {
3038
+ if (y = e._src[s], typeof y != "string") {
3039
+ e._emit("loaderror", null, "Non-string found in selected audio sources - ignoring.");
3040
+ continue;
3041
+ }
3042
+ d = /^data:audio\/([^;,]+);/i.exec(y), d || (d = /\.([^.]+)$/.exec(y.split("?", 1)[0])), d && (d = d[1].toLowerCase());
3043
+ }
3044
+ if (d || console.warn('No file extension was found. Consider using the "format" property or specify an extension.'), d && n.codecs(d)) {
3045
+ r = e._src[s];
3046
+ break;
3047
+ }
3048
+ }
3049
+ if (!r) {
3050
+ e._emit("loaderror", null, "No codec support for selected audio sources.");
3051
+ return;
3052
+ }
3053
+ return e._src = r, e._state = "loading", window.location.protocol === "https:" && r.slice(0, 5) === "http:" && (e._html5 = !0, e._webAudio = !1), new f(e), e._webAudio && h(e), e;
3054
+ },
3055
+ /**
3056
+ * Play a sound or resume previous playback.
3057
+ * @param {String/Number} sprite Sprite name for sprite playback or sound id to continue previous.
3058
+ * @param {Boolean} internal Internal Use: true prevents event firing.
3059
+ * @return {Number} Sound ID.
3060
+ */
3061
+ play: function(e, r) {
3062
+ var s = this, d = null;
3063
+ if (typeof e == "number")
3064
+ d = e, e = null;
3065
+ else {
3066
+ if (typeof e == "string" && s._state === "loaded" && !s._sprite[e])
3067
+ return null;
3068
+ if (typeof e > "u" && (e = "__default", !s._playLock)) {
3069
+ for (var y = 0, g = 0; g < s._sounds.length; g++)
3070
+ s._sounds[g]._paused && !s._sounds[g]._ended && (y++, d = s._sounds[g]._id);
3071
+ y === 1 ? e = null : d = null;
3072
+ }
3073
+ }
3074
+ var m = d ? s._soundById(d) : s._inactiveSound();
3075
+ if (!m)
3076
+ return null;
3077
+ if (d && !e && (e = m._sprite || "__default"), s._state !== "loaded") {
3078
+ m._sprite = e, m._ended = !1;
3079
+ var O = m._id;
3080
+ return s._queue.push({
3081
+ event: "play",
3082
+ action: function() {
3083
+ s.play(O);
3084
+ }
3085
+ }), O;
3086
+ }
3087
+ if (d && !m._paused)
3088
+ return r || s._loadQueue("play"), m._id;
3089
+ s._webAudio && n._autoResume();
3090
+ var P = Math.max(0, m._seek > 0 ? m._seek : s._sprite[e][0] / 1e3), $ = Math.max(0, (s._sprite[e][0] + s._sprite[e][1]) / 1e3 - P), E = $ * 1e3 / Math.abs(m._rate), L = s._sprite[e][0] / 1e3, N = (s._sprite[e][0] + s._sprite[e][1]) / 1e3;
3091
+ m._sprite = e, m._ended = !1;
3092
+ var F = function() {
3093
+ m._paused = !1, m._seek = P, m._start = L, m._stop = N, m._loop = !!(m._loop || s._sprite[e][2]);
3094
+ };
3095
+ if (P >= N) {
3096
+ s._ended(m);
3097
+ return;
3098
+ }
3099
+ var R = m._node;
3100
+ if (s._webAudio) {
3101
+ var Y = function() {
3102
+ s._playLock = !1, F(), s._refreshBuffer(m);
3103
+ var te = m._muted || s._muted ? 0 : m._volume;
3104
+ R.gain.setValueAtTime(te, n.ctx.currentTime), m._playStart = n.ctx.currentTime, typeof R.bufferSource.start > "u" ? m._loop ? R.bufferSource.noteGrainOn(0, P, 86400) : R.bufferSource.noteGrainOn(0, P, $) : m._loop ? R.bufferSource.start(0, P, 86400) : R.bufferSource.start(0, P, $), E !== 1 / 0 && (s._endTimers[m._id] = setTimeout(s._ended.bind(s, m), E)), r || setTimeout(function() {
3105
+ s._emit("play", m._id), s._loadQueue();
3106
+ }, 0);
3107
+ };
3108
+ n.state === "running" && n.ctx.state !== "interrupted" ? Y() : (s._playLock = !0, s.once("resume", Y), s._clearTimer(m._id));
3109
+ } else {
3110
+ var V = function() {
3111
+ R.currentTime = P, R.muted = m._muted || s._muted || n._muted || R.muted, R.volume = m._volume * n.volume(), R.playbackRate = m._rate;
3112
+ try {
3113
+ var te = R.play();
3114
+ if (te && typeof Promise < "u" && (te instanceof Promise || typeof te.then == "function") ? (s._playLock = !0, F(), te.then(function() {
3115
+ s._playLock = !1, R._unlocked = !0, r ? s._loadQueue() : s._emit("play", m._id);
3116
+ }).catch(function() {
3117
+ s._playLock = !1, s._emit("playerror", m._id, "Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction."), m._ended = !0, m._paused = !0;
3118
+ })) : r || (s._playLock = !1, F(), s._emit("play", m._id)), R.playbackRate = m._rate, R.paused) {
3119
+ s._emit("playerror", m._id, "Playback was unable to start. This is most commonly an issue on mobile devices and Chrome where playback was not within a user interaction.");
3120
+ return;
3121
+ }
3122
+ e !== "__default" || m._loop ? s._endTimers[m._id] = setTimeout(s._ended.bind(s, m), E) : (s._endTimers[m._id] = function() {
3123
+ s._ended(m), R.removeEventListener("ended", s._endTimers[m._id], !1);
3124
+ }, R.addEventListener("ended", s._endTimers[m._id], !1));
3125
+ } catch (de) {
3126
+ s._emit("playerror", m._id, de);
3127
+ }
3128
+ };
3129
+ R.src === "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA" && (R.src = s._src, R.load());
3130
+ var X = window && window.ejecta || !R.readyState && n._navigator.isCocoonJS;
3131
+ if (R.readyState >= 3 || X)
3132
+ V();
3133
+ else {
3134
+ s._playLock = !0, s._state = "loading";
3135
+ var ee = function() {
3136
+ s._state = "loaded", V(), R.removeEventListener(n._canPlayEvent, ee, !1);
3137
+ };
3138
+ R.addEventListener(n._canPlayEvent, ee, !1), s._clearTimer(m._id);
3139
+ }
3140
+ }
3141
+ return m._id;
3142
+ },
3143
+ /**
3144
+ * Pause playback and save current position.
3145
+ * @param {Number} id The sound ID (empty to pause all in group).
3146
+ * @return {Howl}
3147
+ */
3148
+ pause: function(e) {
3149
+ var r = this;
3150
+ if (r._state !== "loaded" || r._playLock)
3151
+ return r._queue.push({
3152
+ event: "pause",
3153
+ action: function() {
3154
+ r.pause(e);
3155
+ }
3156
+ }), r;
3157
+ for (var s = r._getSoundIds(e), d = 0; d < s.length; d++) {
3158
+ r._clearTimer(s[d]);
3159
+ var y = r._soundById(s[d]);
3160
+ if (y && !y._paused && (y._seek = r.seek(s[d]), y._rateSeek = 0, y._paused = !0, r._stopFade(s[d]), y._node))
3161
+ if (r._webAudio) {
3162
+ if (!y._node.bufferSource)
3163
+ continue;
3164
+ typeof y._node.bufferSource.stop > "u" ? y._node.bufferSource.noteOff(0) : y._node.bufferSource.stop(0), r._cleanBuffer(y._node);
3165
+ } else (!isNaN(y._node.duration) || y._node.duration === 1 / 0) && y._node.pause();
3166
+ arguments[1] || r._emit("pause", y ? y._id : null);
3167
+ }
3168
+ return r;
3169
+ },
3170
+ /**
3171
+ * Stop playback and reset to start.
3172
+ * @param {Number} id The sound ID (empty to stop all in group).
3173
+ * @param {Boolean} internal Internal Use: true prevents event firing.
3174
+ * @return {Howl}
3175
+ */
3176
+ stop: function(e, r) {
3177
+ var s = this;
3178
+ if (s._state !== "loaded" || s._playLock)
3179
+ return s._queue.push({
3180
+ event: "stop",
3181
+ action: function() {
3182
+ s.stop(e);
3183
+ }
3184
+ }), s;
3185
+ for (var d = s._getSoundIds(e), y = 0; y < d.length; y++) {
3186
+ s._clearTimer(d[y]);
3187
+ var g = s._soundById(d[y]);
3188
+ g && (g._seek = g._start || 0, g._rateSeek = 0, g._paused = !0, g._ended = !0, s._stopFade(d[y]), g._node && (s._webAudio ? g._node.bufferSource && (typeof g._node.bufferSource.stop > "u" ? g._node.bufferSource.noteOff(0) : g._node.bufferSource.stop(0), s._cleanBuffer(g._node)) : (!isNaN(g._node.duration) || g._node.duration === 1 / 0) && (g._node.currentTime = g._start || 0, g._node.pause(), g._node.duration === 1 / 0 && s._clearSound(g._node))), r || s._emit("stop", g._id));
3189
+ }
3190
+ return s;
3191
+ },
3192
+ /**
3193
+ * Mute/unmute a single sound or all sounds in this Howl group.
3194
+ * @param {Boolean} muted Set to true to mute and false to unmute.
3195
+ * @param {Number} id The sound ID to update (omit to mute/unmute all).
3196
+ * @return {Howl}
3197
+ */
3198
+ mute: function(e, r) {
3199
+ var s = this;
3200
+ if (s._state !== "loaded" || s._playLock)
3201
+ return s._queue.push({
3202
+ event: "mute",
3203
+ action: function() {
3204
+ s.mute(e, r);
3205
+ }
3206
+ }), s;
3207
+ if (typeof r > "u")
3208
+ if (typeof e == "boolean")
3209
+ s._muted = e;
3210
+ else
3211
+ return s._muted;
3212
+ for (var d = s._getSoundIds(r), y = 0; y < d.length; y++) {
3213
+ var g = s._soundById(d[y]);
3214
+ g && (g._muted = e, g._interval && s._stopFade(g._id), s._webAudio && g._node ? g._node.gain.setValueAtTime(e ? 0 : g._volume, n.ctx.currentTime) : g._node && (g._node.muted = n._muted ? !0 : e), s._emit("mute", g._id));
3215
+ }
3216
+ return s;
3217
+ },
3218
+ /**
3219
+ * Get/set the volume of this sound or of the Howl group. This method can optionally take 0, 1 or 2 arguments.
3220
+ * volume() -> Returns the group's volume value.
3221
+ * volume(id) -> Returns the sound id's current volume.
3222
+ * volume(vol) -> Sets the volume of all sounds in this Howl group.
3223
+ * volume(vol, id) -> Sets the volume of passed sound id.
3224
+ * @return {Howl/Number} Returns self or current volume.
3225
+ */
3226
+ volume: function() {
3227
+ var e = this, r = arguments, s, d;
3228
+ if (r.length === 0)
3229
+ return e._volume;
3230
+ if (r.length === 1 || r.length === 2 && typeof r[1] > "u") {
3231
+ var y = e._getSoundIds(), g = y.indexOf(r[0]);
3232
+ g >= 0 ? d = parseInt(r[0], 10) : s = parseFloat(r[0]);
3233
+ } else r.length >= 2 && (s = parseFloat(r[0]), d = parseInt(r[1], 10));
3234
+ var m;
3235
+ if (typeof s < "u" && s >= 0 && s <= 1) {
3236
+ if (e._state !== "loaded" || e._playLock)
3237
+ return e._queue.push({
3238
+ event: "volume",
3239
+ action: function() {
3240
+ e.volume.apply(e, r);
3241
+ }
3242
+ }), e;
3243
+ typeof d > "u" && (e._volume = s), d = e._getSoundIds(d);
3244
+ for (var O = 0; O < d.length; O++)
3245
+ m = e._soundById(d[O]), m && (m._volume = s, r[2] || e._stopFade(d[O]), e._webAudio && m._node && !m._muted ? m._node.gain.setValueAtTime(s, n.ctx.currentTime) : m._node && !m._muted && (m._node.volume = s * n.volume()), e._emit("volume", m._id));
3246
+ } else
3247
+ return m = d ? e._soundById(d) : e._sounds[0], m ? m._volume : 0;
3248
+ return e;
3249
+ },
3250
+ /**
3251
+ * Fade a currently playing sound between two volumes (if no id is passed, all sounds will fade).
3252
+ * @param {Number} from The value to fade from (0.0 to 1.0).
3253
+ * @param {Number} to The volume to fade to (0.0 to 1.0).
3254
+ * @param {Number} len Time in milliseconds to fade.
3255
+ * @param {Number} id The sound id (omit to fade all sounds).
3256
+ * @return {Howl}
3257
+ */
3258
+ fade: function(e, r, s, d) {
3259
+ var y = this;
3260
+ if (y._state !== "loaded" || y._playLock)
3261
+ return y._queue.push({
3262
+ event: "fade",
3263
+ action: function() {
3264
+ y.fade(e, r, s, d);
3265
+ }
3266
+ }), y;
3267
+ e = Math.min(Math.max(0, parseFloat(e)), 1), r = Math.min(Math.max(0, parseFloat(r)), 1), s = parseFloat(s), y.volume(e, d);
3268
+ for (var g = y._getSoundIds(d), m = 0; m < g.length; m++) {
3269
+ var O = y._soundById(g[m]);
3270
+ if (O) {
3271
+ if (d || y._stopFade(g[m]), y._webAudio && !O._muted) {
3272
+ var P = n.ctx.currentTime, $ = P + s / 1e3;
3273
+ O._volume = e, O._node.gain.setValueAtTime(e, P), O._node.gain.linearRampToValueAtTime(r, $);
3274
+ }
3275
+ y._startFadeInterval(O, e, r, s, g[m], typeof d > "u");
3276
+ }
3277
+ }
3278
+ return y;
3279
+ },
3280
+ /**
3281
+ * Starts the internal interval to fade a sound.
3282
+ * @param {Object} sound Reference to sound to fade.
3283
+ * @param {Number} from The value to fade from (0.0 to 1.0).
3284
+ * @param {Number} to The volume to fade to (0.0 to 1.0).
3285
+ * @param {Number} len Time in milliseconds to fade.
3286
+ * @param {Number} id The sound id to fade.
3287
+ * @param {Boolean} isGroup If true, set the volume on the group.
3288
+ */
3289
+ _startFadeInterval: function(e, r, s, d, y, g) {
3290
+ var m = this, O = r, P = s - r, $ = Math.abs(P / 0.01), E = Math.max(4, $ > 0 ? d / $ : d), L = Date.now();
3291
+ e._fadeTo = s, e._interval = setInterval(function() {
3292
+ var N = (Date.now() - L) / d;
3293
+ L = Date.now(), O += P * N, O = Math.round(O * 100) / 100, P < 0 ? O = Math.max(s, O) : O = Math.min(s, O), m._webAudio ? e._volume = O : m.volume(O, e._id, !0), g && (m._volume = O), (s < r && O <= s || s > r && O >= s) && (clearInterval(e._interval), e._interval = null, e._fadeTo = null, m.volume(s, e._id), m._emit("fade", e._id));
3294
+ }, E);
3295
+ },
3296
+ /**
3297
+ * Internal method that stops the currently playing fade when
3298
+ * a new fade starts, volume is changed or the sound is stopped.
3299
+ * @param {Number} id The sound id.
3300
+ * @return {Howl}
3301
+ */
3302
+ _stopFade: function(e) {
3303
+ var r = this, s = r._soundById(e);
3304
+ return s && s._interval && (r._webAudio && s._node.gain.cancelScheduledValues(n.ctx.currentTime), clearInterval(s._interval), s._interval = null, r.volume(s._fadeTo, e), s._fadeTo = null, r._emit("fade", e)), r;
3305
+ },
3306
+ /**
3307
+ * Get/set the loop parameter on a sound. This method can optionally take 0, 1 or 2 arguments.
3308
+ * loop() -> Returns the group's loop value.
3309
+ * loop(id) -> Returns the sound id's loop value.
3310
+ * loop(loop) -> Sets the loop value for all sounds in this Howl group.
3311
+ * loop(loop, id) -> Sets the loop value of passed sound id.
3312
+ * @return {Howl/Boolean} Returns self or current loop value.
3313
+ */
3314
+ loop: function() {
3315
+ var e = this, r = arguments, s, d, y;
3316
+ if (r.length === 0)
3317
+ return e._loop;
3318
+ if (r.length === 1)
3319
+ if (typeof r[0] == "boolean")
3320
+ s = r[0], e._loop = s;
3321
+ else
3322
+ return y = e._soundById(parseInt(r[0], 10)), y ? y._loop : !1;
3323
+ else r.length === 2 && (s = r[0], d = parseInt(r[1], 10));
3324
+ for (var g = e._getSoundIds(d), m = 0; m < g.length; m++)
3325
+ y = e._soundById(g[m]), y && (y._loop = s, e._webAudio && y._node && y._node.bufferSource && (y._node.bufferSource.loop = s, s && (y._node.bufferSource.loopStart = y._start || 0, y._node.bufferSource.loopEnd = y._stop, e.playing(g[m]) && (e.pause(g[m], !0), e.play(g[m], !0)))));
3326
+ return e;
3327
+ },
3328
+ /**
3329
+ * Get/set the playback rate of a sound. This method can optionally take 0, 1 or 2 arguments.
3330
+ * rate() -> Returns the first sound node's current playback rate.
3331
+ * rate(id) -> Returns the sound id's current playback rate.
3332
+ * rate(rate) -> Sets the playback rate of all sounds in this Howl group.
3333
+ * rate(rate, id) -> Sets the playback rate of passed sound id.
3334
+ * @return {Howl/Number} Returns self or the current playback rate.
3335
+ */
3336
+ rate: function() {
3337
+ var e = this, r = arguments, s, d;
3338
+ if (r.length === 0)
3339
+ d = e._sounds[0]._id;
3340
+ else if (r.length === 1) {
3341
+ var y = e._getSoundIds(), g = y.indexOf(r[0]);
3342
+ g >= 0 ? d = parseInt(r[0], 10) : s = parseFloat(r[0]);
3343
+ } else r.length === 2 && (s = parseFloat(r[0]), d = parseInt(r[1], 10));
3344
+ var m;
3345
+ if (typeof s == "number") {
3346
+ if (e._state !== "loaded" || e._playLock)
3347
+ return e._queue.push({
3348
+ event: "rate",
3349
+ action: function() {
3350
+ e.rate.apply(e, r);
3351
+ }
3352
+ }), e;
3353
+ typeof d > "u" && (e._rate = s), d = e._getSoundIds(d);
3354
+ for (var O = 0; O < d.length; O++)
3355
+ if (m = e._soundById(d[O]), m) {
3356
+ e.playing(d[O]) && (m._rateSeek = e.seek(d[O]), m._playStart = e._webAudio ? n.ctx.currentTime : m._playStart), m._rate = s, e._webAudio && m._node && m._node.bufferSource ? m._node.bufferSource.playbackRate.setValueAtTime(s, n.ctx.currentTime) : m._node && (m._node.playbackRate = s);
3357
+ var P = e.seek(d[O]), $ = (e._sprite[m._sprite][0] + e._sprite[m._sprite][1]) / 1e3 - P, E = $ * 1e3 / Math.abs(m._rate);
3358
+ (e._endTimers[d[O]] || !m._paused) && (e._clearTimer(d[O]), e._endTimers[d[O]] = setTimeout(e._ended.bind(e, m), E)), e._emit("rate", m._id);
3359
+ }
3360
+ } else
3361
+ return m = e._soundById(d), m ? m._rate : e._rate;
3362
+ return e;
3363
+ },
3364
+ /**
3365
+ * Get/set the seek position of a sound. This method can optionally take 0, 1 or 2 arguments.
3366
+ * seek() -> Returns the first sound node's current seek position.
3367
+ * seek(id) -> Returns the sound id's current seek position.
3368
+ * seek(seek) -> Sets the seek position of the first sound node.
3369
+ * seek(seek, id) -> Sets the seek position of passed sound id.
3370
+ * @return {Howl/Number} Returns self or the current seek position.
3371
+ */
3372
+ seek: function() {
3373
+ var e = this, r = arguments, s, d;
3374
+ if (r.length === 0)
3375
+ e._sounds.length && (d = e._sounds[0]._id);
3376
+ else if (r.length === 1) {
3377
+ var y = e._getSoundIds(), g = y.indexOf(r[0]);
3378
+ g >= 0 ? d = parseInt(r[0], 10) : e._sounds.length && (d = e._sounds[0]._id, s = parseFloat(r[0]));
3379
+ } else r.length === 2 && (s = parseFloat(r[0]), d = parseInt(r[1], 10));
3380
+ if (typeof d > "u")
3381
+ return 0;
3382
+ if (typeof s == "number" && (e._state !== "loaded" || e._playLock))
3383
+ return e._queue.push({
3384
+ event: "seek",
3385
+ action: function() {
3386
+ e.seek.apply(e, r);
3387
+ }
3388
+ }), e;
3389
+ var m = e._soundById(d);
3390
+ if (m)
3391
+ if (typeof s == "number" && s >= 0) {
3392
+ var O = e.playing(d);
3393
+ O && e.pause(d, !0), m._seek = s, m._ended = !1, e._clearTimer(d), !e._webAudio && m._node && !isNaN(m._node.duration) && (m._node.currentTime = s);
3394
+ var P = function() {
3395
+ O && e.play(d, !0), e._emit("seek", d);
3396
+ };
3397
+ if (O && !e._webAudio) {
3398
+ var $ = function() {
3399
+ e._playLock ? setTimeout($, 0) : P();
3400
+ };
3401
+ setTimeout($, 0);
3402
+ } else
3403
+ P();
3404
+ } else if (e._webAudio) {
3405
+ var E = e.playing(d) ? n.ctx.currentTime - m._playStart : 0, L = m._rateSeek ? m._rateSeek - m._seek : 0;
3406
+ return m._seek + (L + E * Math.abs(m._rate));
3407
+ } else
3408
+ return m._node.currentTime;
3409
+ return e;
3410
+ },
3411
+ /**
3412
+ * Check if a specific sound is currently playing or not (if id is provided), or check if at least one of the sounds in the group is playing or not.
3413
+ * @param {Number} id The sound id to check. If none is passed, the whole sound group is checked.
3414
+ * @return {Boolean} True if playing and false if not.
3415
+ */
3416
+ playing: function(e) {
3417
+ var r = this;
3418
+ if (typeof e == "number") {
3419
+ var s = r._soundById(e);
3420
+ return s ? !s._paused : !1;
3421
+ }
3422
+ for (var d = 0; d < r._sounds.length; d++)
3423
+ if (!r._sounds[d]._paused)
3424
+ return !0;
3425
+ return !1;
3426
+ },
3427
+ /**
3428
+ * Get the duration of this sound. Passing a sound id will return the sprite duration.
3429
+ * @param {Number} id The sound id to check. If none is passed, return full source duration.
3430
+ * @return {Number} Audio duration in seconds.
3431
+ */
3432
+ duration: function(e) {
3433
+ var r = this, s = r._duration, d = r._soundById(e);
3434
+ return d && (s = r._sprite[d._sprite][1] / 1e3), s;
3435
+ },
3436
+ /**
3437
+ * Returns the current loaded state of this Howl.
3438
+ * @return {String} 'unloaded', 'loading', 'loaded'
3439
+ */
3440
+ state: function() {
3441
+ return this._state;
3442
+ },
3443
+ /**
3444
+ * Unload and destroy the current Howl object.
3445
+ * This will immediately stop all sound instances attached to this group.
3446
+ */
3447
+ unload: function() {
3448
+ for (var e = this, r = e._sounds, s = 0; s < r.length; s++)
3449
+ r[s]._paused || e.stop(r[s]._id), e._webAudio || (e._clearSound(r[s]._node), r[s]._node.removeEventListener("error", r[s]._errorFn, !1), r[s]._node.removeEventListener(n._canPlayEvent, r[s]._loadFn, !1), r[s]._node.removeEventListener("ended", r[s]._endFn, !1), n._releaseHtml5Audio(r[s]._node)), delete r[s]._node, e._clearTimer(r[s]._id);
3450
+ var d = n._howls.indexOf(e);
3451
+ d >= 0 && n._howls.splice(d, 1);
3452
+ var y = !0;
3453
+ for (s = 0; s < n._howls.length; s++)
3454
+ if (n._howls[s]._src === e._src || e._src.indexOf(n._howls[s]._src) >= 0) {
3455
+ y = !1;
3456
+ break;
3457
+ }
3458
+ return v && y && delete v[e._src], n.noAudio = !1, e._state = "unloaded", e._sounds = [], e = null, null;
3459
+ },
3460
+ /**
3461
+ * Listen to a custom event.
3462
+ * @param {String} event Event name.
3463
+ * @param {Function} fn Listener to call.
3464
+ * @param {Number} id (optional) Only listen to events for this sound.
3465
+ * @param {Number} once (INTERNAL) Marks event to fire only once.
3466
+ * @return {Howl}
3467
+ */
3468
+ on: function(e, r, s, d) {
3469
+ var y = this, g = y["_on" + e];
3470
+ return typeof r == "function" && g.push(d ? { id: s, fn: r, once: d } : { id: s, fn: r }), y;
3471
+ },
3472
+ /**
3473
+ * Remove a custom event. Call without parameters to remove all events.
3474
+ * @param {String} event Event name.
3475
+ * @param {Function} fn Listener to remove. Leave empty to remove all.
3476
+ * @param {Number} id (optional) Only remove events for this sound.
3477
+ * @return {Howl}
3478
+ */
3479
+ off: function(e, r, s) {
3480
+ var d = this, y = d["_on" + e], g = 0;
3481
+ if (typeof r == "number" && (s = r, r = null), r || s)
3482
+ for (g = 0; g < y.length; g++) {
3483
+ var m = s === y[g].id;
3484
+ if (r === y[g].fn && m || !r && m) {
3485
+ y.splice(g, 1);
3486
+ break;
3487
+ }
3488
+ }
3489
+ else if (e)
3490
+ d["_on" + e] = [];
3491
+ else {
3492
+ var O = Object.keys(d);
3493
+ for (g = 0; g < O.length; g++)
3494
+ O[g].indexOf("_on") === 0 && Array.isArray(d[O[g]]) && (d[O[g]] = []);
3495
+ }
3496
+ return d;
3497
+ },
3498
+ /**
3499
+ * Listen to a custom event and remove it once fired.
3500
+ * @param {String} event Event name.
3501
+ * @param {Function} fn Listener to call.
3502
+ * @param {Number} id (optional) Only listen to events for this sound.
3503
+ * @return {Howl}
3504
+ */
3505
+ once: function(e, r, s) {
3506
+ var d = this;
3507
+ return d.on(e, r, s, 1), d;
3508
+ },
3509
+ /**
3510
+ * Emit all events of a specific type and pass the sound id.
3511
+ * @param {String} event Event name.
3512
+ * @param {Number} id Sound ID.
3513
+ * @param {Number} msg Message to go with event.
3514
+ * @return {Howl}
3515
+ */
3516
+ _emit: function(e, r, s) {
3517
+ for (var d = this, y = d["_on" + e], g = y.length - 1; g >= 0; g--)
3518
+ (!y[g].id || y[g].id === r || e === "load") && (setTimeout((function(m) {
3519
+ m.call(this, r, s);
3520
+ }).bind(d, y[g].fn), 0), y[g].once && d.off(e, y[g].fn, y[g].id));
3521
+ return d._loadQueue(e), d;
3522
+ },
3523
+ /**
3524
+ * Queue of actions initiated before the sound has loaded.
3525
+ * These will be called in sequence, with the next only firing
3526
+ * after the previous has finished executing (even if async like play).
3527
+ * @return {Howl}
3528
+ */
3529
+ _loadQueue: function(e) {
3530
+ var r = this;
3531
+ if (r._queue.length > 0) {
3532
+ var s = r._queue[0];
3533
+ s.event === e && (r._queue.shift(), r._loadQueue()), e || s.action();
3534
+ }
3535
+ return r;
3536
+ },
3537
+ /**
3538
+ * Fired when playback ends at the end of the duration.
3539
+ * @param {Sound} sound The sound object to work with.
3540
+ * @return {Howl}
3541
+ */
3542
+ _ended: function(e) {
3543
+ var r = this, s = e._sprite;
3544
+ if (!r._webAudio && e._node && !e._node.paused && !e._node.ended && e._node.currentTime < e._stop)
3545
+ return setTimeout(r._ended.bind(r, e), 100), r;
3546
+ var d = !!(e._loop || r._sprite[s][2]);
3547
+ if (r._emit("end", e._id), !r._webAudio && d && r.stop(e._id, !0).play(e._id), r._webAudio && d) {
3548
+ r._emit("play", e._id), e._seek = e._start || 0, e._rateSeek = 0, e._playStart = n.ctx.currentTime;
3549
+ var y = (e._stop - e._start) * 1e3 / Math.abs(e._rate);
3550
+ r._endTimers[e._id] = setTimeout(r._ended.bind(r, e), y);
3551
+ }
3552
+ return r._webAudio && !d && (e._paused = !0, e._ended = !0, e._seek = e._start || 0, e._rateSeek = 0, r._clearTimer(e._id), r._cleanBuffer(e._node), n._autoSuspend()), !r._webAudio && !d && r.stop(e._id, !0), r;
3553
+ },
3554
+ /**
3555
+ * Clear the end timer for a sound playback.
3556
+ * @param {Number} id The sound ID.
3557
+ * @return {Howl}
3558
+ */
3559
+ _clearTimer: function(e) {
3560
+ var r = this;
3561
+ if (r._endTimers[e]) {
3562
+ if (typeof r._endTimers[e] != "function")
3563
+ clearTimeout(r._endTimers[e]);
3564
+ else {
3565
+ var s = r._soundById(e);
3566
+ s && s._node && s._node.removeEventListener("ended", r._endTimers[e], !1);
3567
+ }
3568
+ delete r._endTimers[e];
3569
+ }
3570
+ return r;
3571
+ },
3572
+ /**
3573
+ * Return the sound identified by this ID, or return null.
3574
+ * @param {Number} id Sound ID
3575
+ * @return {Object} Sound object or null.
3576
+ */
3577
+ _soundById: function(e) {
3578
+ for (var r = this, s = 0; s < r._sounds.length; s++)
3579
+ if (e === r._sounds[s]._id)
3580
+ return r._sounds[s];
3581
+ return null;
3582
+ },
3583
+ /**
3584
+ * Return an inactive sound from the pool or create a new one.
3585
+ * @return {Sound} Sound playback object.
3586
+ */
3587
+ _inactiveSound: function() {
3588
+ var e = this;
3589
+ e._drain();
3590
+ for (var r = 0; r < e._sounds.length; r++)
3591
+ if (e._sounds[r]._ended)
3592
+ return e._sounds[r].reset();
3593
+ return new f(e);
3594
+ },
3595
+ /**
3596
+ * Drain excess inactive sounds from the pool.
3597
+ */
3598
+ _drain: function() {
3599
+ var e = this, r = e._pool, s = 0, d = 0;
3600
+ if (!(e._sounds.length < r)) {
3601
+ for (d = 0; d < e._sounds.length; d++)
3602
+ e._sounds[d]._ended && s++;
3603
+ for (d = e._sounds.length - 1; d >= 0; d--) {
3604
+ if (s <= r)
3605
+ return;
3606
+ e._sounds[d]._ended && (e._webAudio && e._sounds[d]._node && e._sounds[d]._node.disconnect(0), e._sounds.splice(d, 1), s--);
3607
+ }
3608
+ }
3609
+ },
3610
+ /**
3611
+ * Get all ID's from the sounds pool.
3612
+ * @param {Number} id Only return one ID if one is passed.
3613
+ * @return {Array} Array of IDs.
3614
+ */
3615
+ _getSoundIds: function(e) {
3616
+ var r = this;
3617
+ if (typeof e > "u") {
3618
+ for (var s = [], d = 0; d < r._sounds.length; d++)
3619
+ s.push(r._sounds[d]._id);
3620
+ return s;
3621
+ } else
3622
+ return [e];
3623
+ },
3624
+ /**
3625
+ * Load the sound back into the buffer source.
3626
+ * @param {Sound} sound The sound object to work with.
3627
+ * @return {Howl}
3628
+ */
3629
+ _refreshBuffer: function(e) {
3630
+ var r = this;
3631
+ return e._node.bufferSource = n.ctx.createBufferSource(), e._node.bufferSource.buffer = v[r._src], e._panner ? e._node.bufferSource.connect(e._panner) : e._node.bufferSource.connect(e._node), e._node.bufferSource.loop = e._loop, e._loop && (e._node.bufferSource.loopStart = e._start || 0, e._node.bufferSource.loopEnd = e._stop || 0), e._node.bufferSource.playbackRate.setValueAtTime(e._rate, n.ctx.currentTime), r;
3632
+ },
3633
+ /**
3634
+ * Prevent memory leaks by cleaning up the buffer source after playback.
3635
+ * @param {Object} node Sound's audio node containing the buffer source.
3636
+ * @return {Howl}
3637
+ */
3638
+ _cleanBuffer: function(e) {
3639
+ var r = this, s = n._navigator && n._navigator.vendor.indexOf("Apple") >= 0;
3640
+ if (!e.bufferSource)
3641
+ return r;
3642
+ if (n._scratchBuffer && e.bufferSource && (e.bufferSource.onended = null, e.bufferSource.disconnect(0), s))
3643
+ try {
3644
+ e.bufferSource.buffer = n._scratchBuffer;
3645
+ } catch {
3646
+ }
3647
+ return e.bufferSource = null, r;
3648
+ },
3649
+ /**
3650
+ * Set the source to a 0-second silence to stop any downloading (except in IE).
3651
+ * @param {Object} node Audio node to clear.
3652
+ */
3653
+ _clearSound: function(e) {
3654
+ var r = /MSIE |Trident\//.test(n._navigator && n._navigator.userAgent);
3655
+ r || (e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA");
3656
+ }
3657
+ };
3658
+ var f = function(e) {
3659
+ this._parent = e, this.init();
3660
+ };
3661
+ f.prototype = {
3662
+ /**
3663
+ * Initialize a new Sound object.
3664
+ * @return {Sound}
3665
+ */
3666
+ init: function() {
3667
+ var e = this, r = e._parent;
3668
+ return e._muted = r._muted, e._loop = r._loop, e._volume = r._volume, e._rate = r._rate, e._seek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++n._counter, r._sounds.push(e), e.create(), e;
3669
+ },
3670
+ /**
3671
+ * Create and setup a new sound object, whether HTML5 Audio or Web Audio.
3672
+ * @return {Sound}
3673
+ */
3674
+ create: function() {
3675
+ var e = this, r = e._parent, s = n._muted || e._muted || e._parent._muted ? 0 : e._volume;
3676
+ return r._webAudio ? (e._node = typeof n.ctx.createGain > "u" ? n.ctx.createGainNode() : n.ctx.createGain(), e._node.gain.setValueAtTime(s, n.ctx.currentTime), e._node.paused = !0, e._node.connect(n.masterGain)) : n.noAudio || (e._node = n._obtainHtml5Audio(), e._errorFn = e._errorListener.bind(e), e._node.addEventListener("error", e._errorFn, !1), e._loadFn = e._loadListener.bind(e), e._node.addEventListener(n._canPlayEvent, e._loadFn, !1), e._endFn = e._endListener.bind(e), e._node.addEventListener("ended", e._endFn, !1), e._node.src = r._src, e._node.preload = r._preload === !0 ? "auto" : r._preload, e._node.volume = s * n.volume(), e._node.load()), e;
3677
+ },
3678
+ /**
3679
+ * Reset the parameters of this sound to the original state (for recycle).
3680
+ * @return {Sound}
3681
+ */
3682
+ reset: function() {
3683
+ var e = this, r = e._parent;
3684
+ return e._muted = r._muted, e._loop = r._loop, e._volume = r._volume, e._rate = r._rate, e._seek = 0, e._rateSeek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++n._counter, e;
3685
+ },
3686
+ /**
3687
+ * HTML5 Audio error listener callback.
3688
+ */
3689
+ _errorListener: function() {
3690
+ var e = this;
3691
+ e._parent._emit("loaderror", e._id, e._node.error ? e._node.error.code : 0), e._node.removeEventListener("error", e._errorFn, !1);
3692
+ },
3693
+ /**
3694
+ * HTML5 Audio canplaythrough listener callback.
3695
+ */
3696
+ _loadListener: function() {
3697
+ var e = this, r = e._parent;
3698
+ r._duration = Math.ceil(e._node.duration * 10) / 10, Object.keys(r._sprite).length === 0 && (r._sprite = { __default: [0, r._duration * 1e3] }), r._state !== "loaded" && (r._state = "loaded", r._emit("load"), r._loadQueue()), e._node.removeEventListener(n._canPlayEvent, e._loadFn, !1);
3699
+ },
3700
+ /**
3701
+ * HTML5 Audio ended listener callback.
3702
+ */
3703
+ _endListener: function() {
3704
+ var e = this, r = e._parent;
3705
+ r._duration === 1 / 0 && (r._duration = Math.ceil(e._node.duration * 10) / 10, r._sprite.__default[1] === 1 / 0 && (r._sprite.__default[1] = r._duration * 1e3), r._ended(e)), e._node.removeEventListener("ended", e._endFn, !1);
3706
+ }
3707
+ };
3708
+ var v = {}, h = function(e) {
3709
+ var r = e._src;
3710
+ if (v[r]) {
3711
+ e._duration = v[r].duration, S(e);
3712
+ return;
3713
+ }
3714
+ if (/^data:[^;]+;base64,/.test(r)) {
3715
+ for (var s = atob(r.split(",")[1]), d = new Uint8Array(s.length), y = 0; y < s.length; ++y)
3716
+ d[y] = s.charCodeAt(y);
3717
+ A(d.buffer, e);
3718
+ } else {
3719
+ var g = new XMLHttpRequest();
3720
+ g.open(e._xhr.method, r, !0), g.withCredentials = e._xhr.withCredentials, g.responseType = "arraybuffer", e._xhr.headers && Object.keys(e._xhr.headers).forEach(function(m) {
3721
+ g.setRequestHeader(m, e._xhr.headers[m]);
3722
+ }), g.onload = function() {
3723
+ var m = (g.status + "")[0];
3724
+ if (m !== "0" && m !== "2" && m !== "3") {
3725
+ e._emit("loaderror", null, "Failed loading audio file with status: " + g.status + ".");
3726
+ return;
3727
+ }
3728
+ A(g.response, e);
3729
+ }, g.onerror = function() {
3730
+ e._webAudio && (e._html5 = !0, e._webAudio = !1, e._sounds = [], delete v[r], e.load());
3731
+ }, b(g);
3732
+ }
3733
+ }, b = function(e) {
3734
+ try {
3735
+ e.send();
3736
+ } catch {
3737
+ e.onerror();
3738
+ }
3739
+ }, A = function(e, r) {
3740
+ var s = function() {
3741
+ r._emit("loaderror", null, "Decoding audio data failed.");
3742
+ }, d = function(y) {
3743
+ y && r._sounds.length > 0 ? (v[r._src] = y, S(r, y)) : s();
3744
+ };
3745
+ typeof Promise < "u" && n.ctx.decodeAudioData.length === 1 ? n.ctx.decodeAudioData(e).then(d).catch(s) : n.ctx.decodeAudioData(e, d, s);
3746
+ }, S = function(e, r) {
3747
+ r && !e._duration && (e._duration = r.duration), Object.keys(e._sprite).length === 0 && (e._sprite = { __default: [0, e._duration * 1e3] }), e._state !== "loaded" && (e._state = "loaded", e._emit("load"), e._loadQueue());
3748
+ }, C = function() {
3749
+ if (n.usingWebAudio) {
3750
+ try {
3751
+ typeof AudioContext < "u" ? n.ctx = new AudioContext() : typeof webkitAudioContext < "u" ? n.ctx = new webkitAudioContext() : n.usingWebAudio = !1;
3752
+ } catch {
3753
+ n.usingWebAudio = !1;
3754
+ }
3755
+ n.ctx || (n.usingWebAudio = !1);
3756
+ var e = /iP(hone|od|ad)/.test(n._navigator && n._navigator.platform), r = n._navigator && n._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/), s = r ? parseInt(r[1], 10) : null;
3757
+ if (e && s && s < 9) {
3758
+ var d = /safari/.test(n._navigator && n._navigator.userAgent.toLowerCase());
3759
+ n._navigator && !d && (n.usingWebAudio = !1);
3760
+ }
3761
+ n.usingWebAudio && (n.masterGain = typeof n.ctx.createGain > "u" ? n.ctx.createGainNode() : n.ctx.createGain(), n.masterGain.gain.setValueAtTime(n._muted ? 0 : n._volume, n.ctx.currentTime), n.masterGain.connect(n.ctx.destination)), n._setup();
3762
+ }
3763
+ };
3764
+ t.Howler = n, t.Howl = a, typeof _e < "u" ? (_e.HowlerGlobal = o, _e.Howler = n, _e.Howl = a, _e.Sound = f) : typeof window < "u" && (window.HowlerGlobal = o, window.Howler = n, window.Howl = a, window.Sound = f);
3765
+ })();
3766
+ (function() {
3767
+ HowlerGlobal.prototype._pos = [0, 0, 0], HowlerGlobal.prototype._orientation = [0, 0, -1, 0, 1, 0], HowlerGlobal.prototype.stereo = function(n) {
3768
+ var a = this;
3769
+ if (!a.ctx || !a.ctx.listener)
3770
+ return a;
3771
+ for (var f = a._howls.length - 1; f >= 0; f--)
3772
+ a._howls[f].stereo(n);
3773
+ return a;
3774
+ }, HowlerGlobal.prototype.pos = function(n, a, f) {
3775
+ var v = this;
3776
+ if (!v.ctx || !v.ctx.listener)
3777
+ return v;
3778
+ if (a = typeof a != "number" ? v._pos[1] : a, f = typeof f != "number" ? v._pos[2] : f, typeof n == "number")
3779
+ v._pos = [n, a, f], typeof v.ctx.listener.positionX < "u" ? (v.ctx.listener.positionX.setTargetAtTime(v._pos[0], Howler.ctx.currentTime, 0.1), v.ctx.listener.positionY.setTargetAtTime(v._pos[1], Howler.ctx.currentTime, 0.1), v.ctx.listener.positionZ.setTargetAtTime(v._pos[2], Howler.ctx.currentTime, 0.1)) : v.ctx.listener.setPosition(v._pos[0], v._pos[1], v._pos[2]);
3780
+ else
3781
+ return v._pos;
3782
+ return v;
3783
+ }, HowlerGlobal.prototype.orientation = function(n, a, f, v, h, b) {
3784
+ var A = this;
3785
+ if (!A.ctx || !A.ctx.listener)
3786
+ return A;
3787
+ var S = A._orientation;
3788
+ if (a = typeof a != "number" ? S[1] : a, f = typeof f != "number" ? S[2] : f, v = typeof v != "number" ? S[3] : v, h = typeof h != "number" ? S[4] : h, b = typeof b != "number" ? S[5] : b, typeof n == "number")
3789
+ A._orientation = [n, a, f, v, h, b], typeof A.ctx.listener.forwardX < "u" ? (A.ctx.listener.forwardX.setTargetAtTime(n, Howler.ctx.currentTime, 0.1), A.ctx.listener.forwardY.setTargetAtTime(a, Howler.ctx.currentTime, 0.1), A.ctx.listener.forwardZ.setTargetAtTime(f, Howler.ctx.currentTime, 0.1), A.ctx.listener.upX.setTargetAtTime(v, Howler.ctx.currentTime, 0.1), A.ctx.listener.upY.setTargetAtTime(h, Howler.ctx.currentTime, 0.1), A.ctx.listener.upZ.setTargetAtTime(b, Howler.ctx.currentTime, 0.1)) : A.ctx.listener.setOrientation(n, a, f, v, h, b);
3790
+ else
3791
+ return S;
3792
+ return A;
3793
+ }, Howl.prototype.init = /* @__PURE__ */ (function(n) {
3794
+ return function(a) {
3795
+ var f = this;
3796
+ return f._orientation = a.orientation || [1, 0, 0], f._stereo = a.stereo || null, f._pos = a.pos || null, f._pannerAttr = {
3797
+ coneInnerAngle: typeof a.coneInnerAngle < "u" ? a.coneInnerAngle : 360,
3798
+ coneOuterAngle: typeof a.coneOuterAngle < "u" ? a.coneOuterAngle : 360,
3799
+ coneOuterGain: typeof a.coneOuterGain < "u" ? a.coneOuterGain : 0,
3800
+ distanceModel: typeof a.distanceModel < "u" ? a.distanceModel : "inverse",
3801
+ maxDistance: typeof a.maxDistance < "u" ? a.maxDistance : 1e4,
3802
+ panningModel: typeof a.panningModel < "u" ? a.panningModel : "HRTF",
3803
+ refDistance: typeof a.refDistance < "u" ? a.refDistance : 1,
3804
+ rolloffFactor: typeof a.rolloffFactor < "u" ? a.rolloffFactor : 1
3805
+ }, f._onstereo = a.onstereo ? [{ fn: a.onstereo }] : [], f._onpos = a.onpos ? [{ fn: a.onpos }] : [], f._onorientation = a.onorientation ? [{ fn: a.onorientation }] : [], n.call(this, a);
3806
+ };
3807
+ })(Howl.prototype.init), Howl.prototype.stereo = function(n, a) {
3808
+ var f = this;
3809
+ if (!f._webAudio)
3810
+ return f;
3811
+ if (f._state !== "loaded")
3812
+ return f._queue.push({
3813
+ event: "stereo",
3814
+ action: function() {
3815
+ f.stereo(n, a);
3816
+ }
3817
+ }), f;
3818
+ var v = typeof Howler.ctx.createStereoPanner > "u" ? "spatial" : "stereo";
3819
+ if (typeof a > "u")
3820
+ if (typeof n == "number")
3821
+ f._stereo = n, f._pos = [n, 0, 0];
3822
+ else
3823
+ return f._stereo;
3824
+ for (var h = f._getSoundIds(a), b = 0; b < h.length; b++) {
3825
+ var A = f._soundById(h[b]);
3826
+ if (A)
3827
+ if (typeof n == "number")
3828
+ A._stereo = n, A._pos = [n, 0, 0], A._node && (A._pannerAttr.panningModel = "equalpower", (!A._panner || !A._panner.pan) && o(A, v), v === "spatial" ? typeof A._panner.positionX < "u" ? (A._panner.positionX.setValueAtTime(n, Howler.ctx.currentTime), A._panner.positionY.setValueAtTime(0, Howler.ctx.currentTime), A._panner.positionZ.setValueAtTime(0, Howler.ctx.currentTime)) : A._panner.setPosition(n, 0, 0) : A._panner.pan.setValueAtTime(n, Howler.ctx.currentTime)), f._emit("stereo", A._id);
3829
+ else
3830
+ return A._stereo;
3831
+ }
3832
+ return f;
3833
+ }, Howl.prototype.pos = function(n, a, f, v) {
3834
+ var h = this;
3835
+ if (!h._webAudio)
3836
+ return h;
3837
+ if (h._state !== "loaded")
3838
+ return h._queue.push({
3839
+ event: "pos",
3840
+ action: function() {
3841
+ h.pos(n, a, f, v);
3842
+ }
3843
+ }), h;
3844
+ if (a = typeof a != "number" ? 0 : a, f = typeof f != "number" ? -0.5 : f, typeof v > "u")
3845
+ if (typeof n == "number")
3846
+ h._pos = [n, a, f];
3847
+ else
3848
+ return h._pos;
3849
+ for (var b = h._getSoundIds(v), A = 0; A < b.length; A++) {
3850
+ var S = h._soundById(b[A]);
3851
+ if (S)
3852
+ if (typeof n == "number")
3853
+ S._pos = [n, a, f], S._node && ((!S._panner || S._panner.pan) && o(S, "spatial"), typeof S._panner.positionX < "u" ? (S._panner.positionX.setValueAtTime(n, Howler.ctx.currentTime), S._panner.positionY.setValueAtTime(a, Howler.ctx.currentTime), S._panner.positionZ.setValueAtTime(f, Howler.ctx.currentTime)) : S._panner.setPosition(n, a, f)), h._emit("pos", S._id);
3854
+ else
3855
+ return S._pos;
3856
+ }
3857
+ return h;
3858
+ }, Howl.prototype.orientation = function(n, a, f, v) {
3859
+ var h = this;
3860
+ if (!h._webAudio)
3861
+ return h;
3862
+ if (h._state !== "loaded")
3863
+ return h._queue.push({
3864
+ event: "orientation",
3865
+ action: function() {
3866
+ h.orientation(n, a, f, v);
3867
+ }
3868
+ }), h;
3869
+ if (a = typeof a != "number" ? h._orientation[1] : a, f = typeof f != "number" ? h._orientation[2] : f, typeof v > "u")
3870
+ if (typeof n == "number")
3871
+ h._orientation = [n, a, f];
3872
+ else
3873
+ return h._orientation;
3874
+ for (var b = h._getSoundIds(v), A = 0; A < b.length; A++) {
3875
+ var S = h._soundById(b[A]);
3876
+ if (S)
3877
+ if (typeof n == "number")
3878
+ S._orientation = [n, a, f], S._node && (S._panner || (S._pos || (S._pos = h._pos || [0, 0, -0.5]), o(S, "spatial")), typeof S._panner.orientationX < "u" ? (S._panner.orientationX.setValueAtTime(n, Howler.ctx.currentTime), S._panner.orientationY.setValueAtTime(a, Howler.ctx.currentTime), S._panner.orientationZ.setValueAtTime(f, Howler.ctx.currentTime)) : S._panner.setOrientation(n, a, f)), h._emit("orientation", S._id);
3879
+ else
3880
+ return S._orientation;
3881
+ }
3882
+ return h;
3883
+ }, Howl.prototype.pannerAttr = function() {
3884
+ var n = this, a = arguments, f, v, h;
3885
+ if (!n._webAudio)
3886
+ return n;
3887
+ if (a.length === 0)
3888
+ return n._pannerAttr;
3889
+ if (a.length === 1)
3890
+ if (typeof a[0] == "object")
3891
+ f = a[0], typeof v > "u" && (f.pannerAttr || (f.pannerAttr = {
3892
+ coneInnerAngle: f.coneInnerAngle,
3893
+ coneOuterAngle: f.coneOuterAngle,
3894
+ coneOuterGain: f.coneOuterGain,
3895
+ distanceModel: f.distanceModel,
3896
+ maxDistance: f.maxDistance,
3897
+ refDistance: f.refDistance,
3898
+ rolloffFactor: f.rolloffFactor,
3899
+ panningModel: f.panningModel
3900
+ }), n._pannerAttr = {
3901
+ coneInnerAngle: typeof f.pannerAttr.coneInnerAngle < "u" ? f.pannerAttr.coneInnerAngle : n._coneInnerAngle,
3902
+ coneOuterAngle: typeof f.pannerAttr.coneOuterAngle < "u" ? f.pannerAttr.coneOuterAngle : n._coneOuterAngle,
3903
+ coneOuterGain: typeof f.pannerAttr.coneOuterGain < "u" ? f.pannerAttr.coneOuterGain : n._coneOuterGain,
3904
+ distanceModel: typeof f.pannerAttr.distanceModel < "u" ? f.pannerAttr.distanceModel : n._distanceModel,
3905
+ maxDistance: typeof f.pannerAttr.maxDistance < "u" ? f.pannerAttr.maxDistance : n._maxDistance,
3906
+ refDistance: typeof f.pannerAttr.refDistance < "u" ? f.pannerAttr.refDistance : n._refDistance,
3907
+ rolloffFactor: typeof f.pannerAttr.rolloffFactor < "u" ? f.pannerAttr.rolloffFactor : n._rolloffFactor,
3908
+ panningModel: typeof f.pannerAttr.panningModel < "u" ? f.pannerAttr.panningModel : n._panningModel
3909
+ });
3910
+ else
3911
+ return h = n._soundById(parseInt(a[0], 10)), h ? h._pannerAttr : n._pannerAttr;
3912
+ else a.length === 2 && (f = a[0], v = parseInt(a[1], 10));
3913
+ for (var b = n._getSoundIds(v), A = 0; A < b.length; A++)
3914
+ if (h = n._soundById(b[A]), h) {
3915
+ var S = h._pannerAttr;
3916
+ S = {
3917
+ coneInnerAngle: typeof f.coneInnerAngle < "u" ? f.coneInnerAngle : S.coneInnerAngle,
3918
+ coneOuterAngle: typeof f.coneOuterAngle < "u" ? f.coneOuterAngle : S.coneOuterAngle,
3919
+ coneOuterGain: typeof f.coneOuterGain < "u" ? f.coneOuterGain : S.coneOuterGain,
3920
+ distanceModel: typeof f.distanceModel < "u" ? f.distanceModel : S.distanceModel,
3921
+ maxDistance: typeof f.maxDistance < "u" ? f.maxDistance : S.maxDistance,
3922
+ refDistance: typeof f.refDistance < "u" ? f.refDistance : S.refDistance,
3923
+ rolloffFactor: typeof f.rolloffFactor < "u" ? f.rolloffFactor : S.rolloffFactor,
3924
+ panningModel: typeof f.panningModel < "u" ? f.panningModel : S.panningModel
3925
+ };
3926
+ var C = h._panner;
3927
+ C || (h._pos || (h._pos = n._pos || [0, 0, -0.5]), o(h, "spatial"), C = h._panner), C.coneInnerAngle = S.coneInnerAngle, C.coneOuterAngle = S.coneOuterAngle, C.coneOuterGain = S.coneOuterGain, C.distanceModel = S.distanceModel, C.maxDistance = S.maxDistance, C.refDistance = S.refDistance, C.rolloffFactor = S.rolloffFactor, C.panningModel = S.panningModel;
3928
+ }
3929
+ return n;
3930
+ }, Sound.prototype.init = /* @__PURE__ */ (function(n) {
3931
+ return function() {
3932
+ var a = this, f = a._parent;
3933
+ a._orientation = f._orientation, a._stereo = f._stereo, a._pos = f._pos, a._pannerAttr = f._pannerAttr, n.call(this), a._stereo ? f.stereo(a._stereo) : a._pos && f.pos(a._pos[0], a._pos[1], a._pos[2], a._id);
3934
+ };
3935
+ })(Sound.prototype.init), Sound.prototype.reset = /* @__PURE__ */ (function(n) {
3936
+ return function() {
3937
+ var a = this, f = a._parent;
3938
+ return a._orientation = f._orientation, a._stereo = f._stereo, a._pos = f._pos, a._pannerAttr = f._pannerAttr, a._stereo ? f.stereo(a._stereo) : a._pos ? f.pos(a._pos[0], a._pos[1], a._pos[2], a._id) : a._panner && (a._panner.disconnect(0), a._panner = void 0, f._refreshBuffer(a)), n.call(this);
3939
+ };
3940
+ })(Sound.prototype.reset);
3941
+ var o = function(n, a) {
3942
+ a = a || "spatial", a === "spatial" ? (n._panner = Howler.ctx.createPanner(), n._panner.coneInnerAngle = n._pannerAttr.coneInnerAngle, n._panner.coneOuterAngle = n._pannerAttr.coneOuterAngle, n._panner.coneOuterGain = n._pannerAttr.coneOuterGain, n._panner.distanceModel = n._pannerAttr.distanceModel, n._panner.maxDistance = n._pannerAttr.maxDistance, n._panner.refDistance = n._pannerAttr.refDistance, n._panner.rolloffFactor = n._pannerAttr.rolloffFactor, n._panner.panningModel = n._pannerAttr.panningModel, typeof n._panner.positionX < "u" ? (n._panner.positionX.setValueAtTime(n._pos[0], Howler.ctx.currentTime), n._panner.positionY.setValueAtTime(n._pos[1], Howler.ctx.currentTime), n._panner.positionZ.setValueAtTime(n._pos[2], Howler.ctx.currentTime)) : n._panner.setPosition(n._pos[0], n._pos[1], n._pos[2]), typeof n._panner.orientationX < "u" ? (n._panner.orientationX.setValueAtTime(n._orientation[0], Howler.ctx.currentTime), n._panner.orientationY.setValueAtTime(n._orientation[1], Howler.ctx.currentTime), n._panner.orientationZ.setValueAtTime(n._orientation[2], Howler.ctx.currentTime)) : n._panner.setOrientation(n._orientation[0], n._orientation[1], n._orientation[2])) : (n._panner = Howler.ctx.createStereoPanner(), n._panner.pan.setValueAtTime(n._stereo, Howler.ctx.currentTime)), n._panner.connect(n._node), n._paused || n._parent.pause(n._id, !0).play(n._id, !0);
3943
+ };
3944
+ })();
3945
+ })(Ct)), Ct;
3946
+ }
3947
+ var ke = qa();
3948
+ const ot = {}, at = {};
3949
+ function mr(t, o) {
3950
+ t ? o[t] && o[t].stop() : Object.keys(o).forEach((n) => {
3951
+ n && n.fade && n.fade(void 0, 0, 1), o[n].stop();
3952
+ });
3953
+ }
3954
+ function Ja(t) {
3955
+ hr(t.mute), gr(t.volume);
3956
+ }
3957
+ function hr(t = !0) {
3958
+ ke.Howler.mute(t);
3959
+ }
3960
+ function Xa() {
3961
+ return ke.Howler.muted;
3962
+ }
3963
+ function gr(t) {
3964
+ ke.Howler.volume(t / 100);
3965
+ }
3966
+ function Qa() {
3967
+ return ke.Howler.volume * 100;
3968
+ }
3969
+ function ja(t) {
3970
+ ot[t] || (ot[t] = new ke.Howl({
3971
+ src: [t]
3972
+ })), ot[t].play();
3973
+ }
3974
+ function Za(t) {
3975
+ mr(t, ot);
3976
+ }
3977
+ function za(t, o = !0) {
3978
+ at[t] || (at[t] = new ke.Howl({
3979
+ src: [t],
3980
+ html5: !0,
3981
+ // streaming
3982
+ loop: o
3983
+ })), at[t].play();
3984
+ }
3985
+ function ei(t) {
3986
+ mr(t, at);
3987
+ }
3988
+ const ti = {
3989
+ init: Ja,
3990
+ mute: hr,
3991
+ isMuted: Xa,
3992
+ setVolume: gr,
3993
+ getVolume: Qa,
3994
+ playSound: ja,
3995
+ stopSound: Za,
3996
+ playMusic: za,
3997
+ stopMusic: ei
3998
+ };
3999
+ let ni = /* @__PURE__ */ Symbol("clean"), se = [], ge = 0;
4000
+ const tt = 4, ri = /* @__NO_SIDE_EFFECTS__ */ (t) => {
4001
+ let o = [], n = {
4002
+ get() {
4003
+ return n.lc || n.listen(() => {
4004
+ })(), n.value;
4005
+ },
4006
+ lc: 0,
4007
+ listen(a) {
4008
+ return n.lc = o.push(a), () => {
4009
+ for (let v = ge + tt; v < se.length; )
4010
+ se[v] === a ? se.splice(v, tt) : v += tt;
4011
+ let f = o.indexOf(a);
4012
+ ~f && (o.splice(f, 1), --n.lc || n.off());
4013
+ };
4014
+ },
4015
+ notify(a, f) {
4016
+ let v = !se.length;
4017
+ for (let h of o)
4018
+ se.push(h, n.value, a, f);
4019
+ if (v) {
4020
+ for (ge = 0; ge < se.length; ge += tt)
4021
+ se[ge](
4022
+ se[ge + 1],
4023
+ se[ge + 2],
4024
+ se[ge + 3]
4025
+ );
4026
+ se.length = 0;
4027
+ }
4028
+ },
4029
+ /* It will be called on last listener unsubscribing.
4030
+ We will redefine it in onMount and onStop. */
4031
+ off() {
4032
+ },
4033
+ set(a) {
4034
+ let f = n.value;
4035
+ f !== a && (n.value = a, n.notify(f));
4036
+ },
4037
+ subscribe(a) {
4038
+ let f = n.listen(a);
4039
+ return a(n.value), f;
4040
+ },
4041
+ value: t
4042
+ };
4043
+ return process.env.NODE_ENV !== "production" && (n[ni] = () => {
4044
+ o = [], n.lc = 0, n.off();
4045
+ }), n;
4046
+ }, oi = /* @__NO_SIDE_EFFECTS__ */ (t = {}) => {
4047
+ let o = /* @__PURE__ */ ri(t);
4048
+ return o.setKey = function(n, a) {
4049
+ let f = o.value;
4050
+ typeof a > "u" && n in o.value ? (o.value = { ...o.value }, delete o.value[n], o.notify(f, n)) : o.value[n] !== a && (o.value = {
4051
+ ...o.value,
4052
+ [n]: a
4053
+ }, o.notify(f, n));
4054
+ }, o;
4055
+ }, J = /* @__PURE__ */ oi({
4056
+ settings: {},
4057
+ game: {},
4058
+ metadata: {},
4059
+ scenes: [],
4060
+ vars: {}
4061
+ });
4062
+ function ai() {
4063
+ return J;
4064
+ }
4065
+ function ii() {
4066
+ return J.get();
4067
+ }
4068
+ const si = (t, o) => (J.setKey(t, o), J.get()), ui = (t) => (J.setKey(t, !J.get()[t]), J.get()), fi = (t, o) => (J.setKey(t, [...J.get()[t], o]), J.get()), ci = (t, o, n) => (J.setKey(t, { ...J.get()[t], [o]: n }), J.get()), li = (t, o) => (J.setKey(t, { ...J.get()[t], [o]: !J.get()[t][o] }), J.get()), di = (t, o, n) => (J.setKey(t, { ...J.get()[t], [o]: [...J.get()[t][o], n] }), J.get()), _i = {
4069
+ store: ai,
4070
+ get: ii,
4071
+ setKey: si,
4072
+ toggleKey: ui,
4073
+ appendKey: fi,
4074
+ setSubkey: ci,
4075
+ toggleSubkey: li,
4076
+ appendSubkey: di
4077
+ };
4078
+ async function pi(t, o) {
4079
+ if (t && !document.fullscreenElement)
4080
+ try {
4081
+ await document.documentElement.requestFullscreen();
4082
+ } catch {
4083
+ o(!1);
4084
+ }
4085
+ else document.fullscreenElement && document.exitFullscreen && document.exitFullscreen();
4086
+ }
4087
+ function vi(t) {
4088
+ document.title = t;
4089
+ }
4090
+ const mi = {
4091
+ setFullscreen: pi,
4092
+ setTitle: vi
4093
+ };
4094
+ async function hi(t) {
4095
+ t ? await window.Neutralino.window.setFullScreen() : await window.Neutralino.window.exitFullScreen();
4096
+ }
4097
+ async function gi(t) {
4098
+ await window.Neutralino.window.setTitle(t);
4099
+ }
4100
+ async function yi() {
4101
+ await window.Neutralino.app.exit();
4102
+ }
4103
+ const wi = {
4104
+ setFullscreen: hi,
4105
+ setTitle: gi,
4106
+ exitApp: yi
4107
+ };
4108
+ zo.defineInterfaces({
4109
+ loader: Sa,
4110
+ persistent: window.Neutralino ? Wa : Ra,
4111
+ sound: ti,
4112
+ state: _i,
4113
+ platform: window.Neutralino ? wi : mi
4114
+ });
4115
+ export {
4116
+ zo as default
4117
+ };