@atrament/web 2.2.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,2540 +1,2208 @@
1
- const J = {};
2
- let ce = "";
3
- function Te(t) {
4
- return `${ce}${t}`;
5
- }
6
- function wn() {
7
- ce = "", Object.keys(J).forEach((t) => delete J[t]);
8
- }
9
- function bn(t) {
10
- ce = `>>${t}<<`;
11
- }
12
- async function An(t) {
13
- return !!J[Te(t)];
14
- }
15
- async function Sn(t) {
16
- return JSON.parse(J[Te(t)]);
17
- }
18
- async function xn(t, n) {
19
- J[Te(t)] = JSON.stringify(n);
20
- }
21
- async function kn(t) {
22
- delete J[Te(t)];
23
- }
24
- async function Tn() {
25
- return Object.keys(J).filter((t) => t.includes(ce)).map((t) => t.replace(ce, ""));
26
- }
27
- const En = {
28
- gameState: J,
29
- reset: wn,
30
- init: bn,
31
- exists: An,
32
- get: Sn,
33
- set: xn,
34
- remove: kn,
35
- keys: Tn
36
- }, In = {
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
- }, I = {
54
- settings: {},
55
- game: {},
56
- metadata: {},
57
- scenes: [],
58
- vars: {}
1
+ // \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
6
+ });
7
+ return e;
8
+ }, c = (n, r, o) => (o = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
9
+ value: n,
10
+ enumerable: !0
11
+ }) : o, n)), l = {}, u = "";
12
+ function d(e) {
13
+ return `${u}${e}`;
14
+ }
15
+ function f() {
16
+ u = "", Object.keys(l).forEach((e) => delete l[e]);
17
+ }
18
+ function p(e) {
19
+ u = `>>${e}<<`;
20
+ }
21
+ async function m(e) {
22
+ return !!l[d(e)];
23
+ }
24
+ async function h(e) {
25
+ return JSON.parse(l[d(e)]);
26
+ }
27
+ async function g(e, t) {
28
+ l[d(e)] = JSON.stringify(t);
29
+ }
30
+ async function _(e) {
31
+ delete l[d(e)];
32
+ }
33
+ async function v() {
34
+ return Object.keys(l).filter((e) => e.includes(u)).map((e) => e.replace(u, ""));
35
+ }
36
+ var y = {
37
+ gameState: l,
38
+ reset: f,
39
+ init: p,
40
+ exists: m,
41
+ get: h,
42
+ set: g,
43
+ remove: _,
44
+ keys: v
45
+ }, ee = {
46
+ init: () => {},
47
+ mute: () => {},
48
+ isMuted: () => {},
49
+ setVolume: () => {},
50
+ getVolume: () => {},
51
+ playSound: () => {},
52
+ stopSound: () => {},
53
+ playMusic: () => {},
54
+ stopMusic: () => {},
55
+ reset: () => {}
56
+ }, b = {
57
+ settings: {},
58
+ game: {},
59
+ metadata: {},
60
+ scenes: [],
61
+ vars: {}
59
62
  };
60
- function Cn() {
61
- I.settings = {}, I.game = {}, I.metadata = {}, I.scenes = [], I.vars = {};
62
- }
63
- function On() {
64
- return I;
65
- }
66
- function Pn() {
67
- return JSON.parse(JSON.stringify(I));
68
- }
69
- function $n(t, n) {
70
- I[t] = n;
71
- }
72
- function Ln(t) {
73
- I[t] = !I[t];
74
- }
75
- function Fn(t, n) {
76
- I[t] = [...I[t], n];
77
- }
78
- function Mn(t, n, r) {
79
- I[t] = { ...I[t], [n]: r };
80
- }
81
- function Bn(t, n) {
82
- I[t] = { ...I[t], [n]: !I[t][n] };
83
- }
84
- function Nn(t, n, r) {
85
- I[t] = { ...I[t], [n]: [...I[t][n], r] };
86
- }
87
- const Dn = {
88
- reset: Cn,
89
- store: On,
90
- get: Pn,
91
- setKey: $n,
92
- toggleKey: Ln,
93
- appendKey: Fn,
94
- setSubkey: Mn,
95
- toggleSubkey: Bn,
96
- appendSubkey: Nn
97
- };
98
- let Re = {
99
- loader: null,
100
- persistent: En,
101
- sound: In,
102
- state: Dn
103
- };
104
- const y = () => Re;
105
- function Kn(t) {
106
- Re = { ...Re, ...t };
107
- }
108
- const Ve = {
109
- settings: {
110
- volume: 0,
111
- mute: !0
112
- }
113
- };
114
- function Ee() {
115
- return Ve;
116
- }
117
- function Un(t, n = {}) {
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 (!n.applicationID)
123
- throw new Error("atrament.init: config.applicationID is not set!");
124
- Ve.InkStory = t, Object.entries(n).forEach(([r, i]) => {
125
- Ve[r] = JSON.parse(JSON.stringify(i));
126
- });
127
- }
128
- function Rn(t) {
129
- return { all: t = t || /* @__PURE__ */ new Map(), on: function(n, r) {
130
- var i = t.get(n);
131
- i ? i.push(r) : t.set(n, [r]);
132
- }, off: function(n, r) {
133
- var i = t.get(n);
134
- i && (r ? i.splice(i.indexOf(r) >>> 0, 1) : t.set(n, []));
135
- }, emit: function(n, r) {
136
- var i = t.get(n);
137
- i && i.slice().map(function(u) {
138
- u(r);
139
- }), (i = t.get("*")) && i.slice().map(function(u) {
140
- u(n, r);
141
- });
142
- } };
143
- }
144
- const Ge = Rn(), w = (...t) => Ge.emit(...t);
145
- function q(t) {
146
- return Array.isArray(t) ? t : [t];
147
- }
148
- function Vn(t) {
149
- return [...t].reduce((n, r) => Math.imul(31, n) + r.charCodeAt(0) | 0, 0);
150
- }
151
- async function kt(t) {
152
- const { persistent: n } = y(), r = await n.keys();
153
- await Promise.all(
154
- r.map(
155
- async (i) => {
156
- if (!i.includes("save"))
157
- return;
158
- const u = await n.get(i);
159
- await t(i, u);
160
- }
161
- )
162
- );
163
- }
164
- function ee(t) {
165
- return typeof t == "number" || typeof t == "string" ? t : "";
166
- }
167
- function Gn() {
168
- const { state: t } = y();
169
- return ee(t.get().game.$sessionID);
170
- }
171
- function Hn(t) {
172
- const { state: n } = y(), r = ee(t);
173
- n.setSubkey("game", "$sessionID", r), w("game/setSession", r);
174
- }
175
- async function Jn() {
176
- const t = {};
177
- return await kt(async (n, r) => {
178
- const i = ee(r.game.$sessionID);
179
- t[i] ? t[i] += 1 : t[i] = 1;
180
- }), w("game/getSessions", t), t;
181
- }
182
- async function qn(t) {
183
- const { persistent: n } = y(), r = ee(t);
184
- await kt(async (i, u) => {
185
- ee(u.game.$sessionID) === r && await n.remove(i);
186
- }), w("game/deleteSession", r);
187
- }
188
- function je(t) {
189
- if (!t)
190
- return {};
191
- const n = {};
192
- return t.forEach((r) => {
193
- let i, u;
194
- const d = r.match(/\s*(\w+)\s*:\s*(.+?)\s*$/);
195
- if (d) {
196
- const [, _, p] = d;
197
- i = _;
198
- try {
199
- u = JSON.parse(p);
200
- } catch {
201
- const h = p.substr(0, 1);
202
- h === "{" || h === "[" ? console.warn("Malformed JSON tag, ignored.", _, p) : u = p;
203
- }
204
- } else
205
- i = r, u = !0;
206
- Array.isArray(n[i]) ? n[i].push(u) : n[i] ? n[i] = [n[i], u] : n[i] = u;
207
- }), n;
208
- }
209
- let k = null;
210
- function Wn(t, n) {
211
- const { InkStory: r } = Ee();
212
- try {
213
- k = new r(t);
214
- } catch (i) {
215
- throw console.log(i), Error(`Failed to parse Ink script: ${n}`);
216
- }
217
- w("ink/initStory");
218
- }
219
- function jn() {
220
- let t = !1;
221
- k && (k.ResetState(), t = !0), w("ink/resetStory", t);
222
- }
223
- function He(t, n) {
224
- if (!t.canContinue)
225
- return;
226
- t.Continue();
227
- const r = t.currentText;
228
- r && r !== `
229
- ` && (n.isEmpty = !1), n.text.push(r);
230
- const i = je(t.currentTags);
231
- n.tags = { ...n.tags, ...i }, n.content.push({ text: r, tags: i }), r === `
232
- ` && He(t, n);
233
- }
234
- function zn(t) {
235
- const n = {
236
- content: [],
237
- text: [],
238
- tags: {},
239
- choices: [],
240
- isEmpty: !0,
241
- uuid: Date.now()
242
- };
243
- if (t)
244
- for (; k.canContinue; )
245
- He(k, n);
246
- else
247
- He(k, n), n.canContinue = k.canContinue;
248
- return k.currentChoices.forEach((r, i) => {
249
- n.choices.push({
250
- id: i,
251
- choice: r.text,
252
- tags: je(r.tags)
253
- });
254
- }), w("ink/getScene", n), n;
255
- }
256
- const $ = {
257
- initStory: Wn,
258
- resetStory: jn,
259
- story: () => k,
260
- loadState: (t) => k.state.LoadJson(t),
261
- getState: () => k.state.toJson(),
262
- makeChoice: (t) => {
263
- k.ChooseChoiceIndex(t), w("ink/makeChoice", t);
264
- },
265
- getVisitCount: (t) => {
266
- const n = k.VisitCountAtPathString(t);
267
- return w("ink/getVisitCount", { ref: t, visitCount: n }), n;
268
- },
269
- evaluateFunction: (t, n, r) => {
270
- const i = k.EvaluateFunction(t, n, r);
271
- return w("ink/evaluateFunction", { function: t, args: n, result: i }), i;
272
- },
273
- getGlobalTags: () => {
274
- const t = je(k.globalTags);
275
- return w("ink/getGlobalTags", t), t;
276
- },
277
- getVariable: (t) => {
278
- const n = k.variablesState[t];
279
- return w("ink/getVariable", { name: t, value: n }), n;
280
- },
281
- getVariables: () => {
282
- const t = k.variablesState, n = {};
283
- return t._globalVariables.forEach(
284
- /* eslint-disable-line no-underscore-dangle */
285
- (r, i) => {
286
- n[i] = t[i];
287
- }
288
- ), w("ink/getVariables", n), n;
289
- },
290
- setVariable: (t, n) => {
291
- k.variablesState[t] = n, w("ink/setVariable", { name: t, value: n });
292
- },
293
- observeVariable: (t, n) => k.ObserveVariable(t, n),
294
- goTo: (t) => {
295
- k.ChoosePathString(t), w("ink/goTo", t);
296
- },
297
- onError: (t) => {
298
- k.onError = (n) => {
299
- w("ink/onError", n), t(n);
300
- };
301
- },
302
- getScene: zn
63
+ function te() {
64
+ b.settings = {}, b.game = {}, b.metadata = {}, b.scenes = [], b.vars = {};
65
+ }
66
+ function ne() {
67
+ return b;
68
+ }
69
+ function re() {
70
+ return JSON.parse(JSON.stringify(b));
71
+ }
72
+ function x(e, t) {
73
+ b[e] = t;
74
+ }
75
+ function ie(e) {
76
+ b[e] = !b[e];
77
+ }
78
+ function S(e, t) {
79
+ b[e] = [...b[e], t];
80
+ }
81
+ function ae(e, t, n) {
82
+ b[e] = {
83
+ ...b[e],
84
+ [t]: n
85
+ };
86
+ }
87
+ function oe(e, t) {
88
+ b[e] = {
89
+ ...b[e],
90
+ [t]: !b[e][t]
91
+ };
92
+ }
93
+ function se(e, t, n) {
94
+ b[e] = {
95
+ ...b[e],
96
+ [t]: [...b[e][t], n]
97
+ };
98
+ }
99
+ var ce = {
100
+ loader: null,
101
+ persistent: y,
102
+ sound: ee,
103
+ state: {
104
+ reset: te,
105
+ store: ne,
106
+ get: re,
107
+ setKey: x,
108
+ toggleKey: ie,
109
+ appendKey: S,
110
+ setSubkey: ae,
111
+ toggleSubkey: oe,
112
+ appendSubkey: se
113
+ }
114
+ }, C = () => ce;
115
+ function w(e) {
116
+ ce = {
117
+ ...ce,
118
+ ...e
119
+ };
120
+ }
121
+ var T = { settings: {
122
+ volume: 0,
123
+ mute: !0
124
+ } };
125
+ function E() {
126
+ return T;
127
+ }
128
+ function le(e, t = {}) {
129
+ if (!e) throw Error("atrament.init: provide ink Story constructor as a first argument!");
130
+ if (typeof e != "function") throw Error("atrament.init: Story is not a constructor!");
131
+ if (!t.applicationID) throw Error("atrament.init: config.applicationID is not set!");
132
+ T.InkStory = e, Object.entries(t).forEach(([e, t]) => {
133
+ T[e] = JSON.parse(JSON.stringify(t));
134
+ });
135
+ }
136
+ function ue(e) {
137
+ return {
138
+ all: e ||= /* @__PURE__ */ new Map(),
139
+ on: function(t, n) {
140
+ var r = e.get(t);
141
+ r ? r.push(n) : e.set(t, [n]);
142
+ },
143
+ off: function(t, n) {
144
+ var r = e.get(t);
145
+ r && (n ? r.splice(r.indexOf(n) >>> 0, 1) : e.set(t, []));
146
+ },
147
+ emit: function(t, n) {
148
+ var r = e.get(t);
149
+ r && r.slice().map(function(e) {
150
+ e(n);
151
+ }), (r = e.get("*")) && r.slice().map(function(e) {
152
+ e(t, n);
153
+ });
154
+ }
155
+ };
156
+ }
157
+ var D = ue(), O = (...e) => D.emit(...e);
158
+ function k(e) {
159
+ return Array.isArray(e) ? e : [e];
160
+ }
161
+ function de(e) {
162
+ return [...e].reduce((e, t) => Math.imul(31, e) + t.charCodeAt(0) | 0, 0);
163
+ }
164
+ function A(e) {
165
+ if (!e) return {};
166
+ let t = {};
167
+ return e.forEach((e) => {
168
+ let n, r, i = e.match(/\s*(\w+)\s*:\s*(.+?)\s*$/);
169
+ if (i) {
170
+ let [, e, t] = i;
171
+ n = e;
172
+ try {
173
+ r = JSON.parse(t);
174
+ } catch {
175
+ let n = t.substr(0, 1);
176
+ n === "{" || n === "[" ? console.warn("Malformed JSON tag, ignored.", e, t) : r = t;
177
+ }
178
+ } else n = e, r = !0;
179
+ Array.isArray(t[n]) ? t[n].push(r) : t[n] ? t[n] = [t[n], r] : t[n] = r;
180
+ }), t;
181
+ }
182
+ var j = null;
183
+ function fe(e, t) {
184
+ let { InkStory: n } = E();
185
+ try {
186
+ j = new n(e);
187
+ } catch (e) {
188
+ throw console.log(e), Error(`Failed to parse Ink script: ${t}`);
189
+ }
190
+ O("ink/initStory");
191
+ }
192
+ function pe() {
193
+ let e = !1;
194
+ j && (j.ResetState(), e = !0), O("ink/resetStory", e);
195
+ }
196
+ function me(e, t) {
197
+ if (!e.canContinue) return;
198
+ e.Continue();
199
+ let n = e.currentText;
200
+ n && n !== "\n" && (t.isEmpty = !1), t.text.push(n);
201
+ let r = A(e.currentTags);
202
+ t.tags = {
203
+ ...t.tags,
204
+ ...r
205
+ }, t.content.push({
206
+ text: n,
207
+ tags: r
208
+ }), n === "\n" && me(e, t);
209
+ }
210
+ function he(e) {
211
+ let t = {
212
+ content: [],
213
+ text: [],
214
+ tags: {},
215
+ choices: [],
216
+ isEmpty: !0,
217
+ uuid: Date.now()
218
+ };
219
+ if (e) for (; j.canContinue;) me(j, t);
220
+ else me(j, t), t.canContinue = j.canContinue;
221
+ return j.currentChoices.forEach((e, n) => {
222
+ t.choices.push({
223
+ id: n,
224
+ choice: e.text,
225
+ tags: A(e.tags)
226
+ });
227
+ }), O("ink/getScene", t), t;
228
+ }
229
+ var M = {
230
+ initStory: fe,
231
+ resetStory: pe,
232
+ story: () => j,
233
+ loadState: (e) => j.state.LoadJson(e),
234
+ getState: () => j.state.toJson(),
235
+ makeChoice: (e) => {
236
+ j.ChooseChoiceIndex(e), O("ink/makeChoice", e);
237
+ },
238
+ getVisitCount: (e) => {
239
+ let t = j.VisitCountAtPathString(e);
240
+ return O("ink/getVisitCount", {
241
+ ref: e,
242
+ visitCount: t
243
+ }), t;
244
+ },
245
+ evaluateFunction: (e, t, n) => {
246
+ let r = j.EvaluateFunction(e, t, n);
247
+ return O("ink/evaluateFunction", {
248
+ function: e,
249
+ args: t,
250
+ result: r
251
+ }), r;
252
+ },
253
+ getGlobalTags: () => {
254
+ let e = A(j.globalTags);
255
+ return O("ink/getGlobalTags", e), e;
256
+ },
257
+ getVariable: (e) => {
258
+ let t = j.variablesState[e];
259
+ return O("ink/getVariable", {
260
+ name: e,
261
+ value: t
262
+ }), t;
263
+ },
264
+ getVariables: () => {
265
+ let e = j.variablesState, t = {};
266
+ return e._globalVariables.forEach((n, r) => {
267
+ t[r] = e[r];
268
+ }), O("ink/getVariables", t), t;
269
+ },
270
+ setVariable: (e, t) => {
271
+ j.variablesState[e] = t, O("ink/setVariable", {
272
+ name: e,
273
+ value: t
274
+ });
275
+ },
276
+ observeVariable: (e, t) => j.ObserveVariable(e, t),
277
+ goTo: (e) => {
278
+ j.ChoosePathString(e), O("ink/goTo", e);
279
+ },
280
+ onError: (e) => {
281
+ j.onError = (t) => {
282
+ O("ink/onError", t), e(t);
283
+ };
284
+ },
285
+ getScene: he
303
286
  };
304
- function vt(t) {
305
- const { sound: n, loader: r } = y();
306
- q(t).forEach(
307
- (i) => n.playSound(r.getAssetPath(i))
308
- );
309
- }
310
- function Me(t) {
311
- const { sound: n, loader: r } = y();
312
- q(t).forEach(
313
- (i) => n.stopSound(i ? r.getAssetPath(i) : null)
314
- );
315
- }
316
- function Tt(t) {
317
- const { sound: n, state: r, loader: i } = y(), u = r.get().game.$currentMusic || [];
318
- q(t).forEach((d) => {
319
- n.playMusic(i.getAssetPath(d)), u.push(d);
320
- }), r.setSubkey("game", "$currentMusic", u);
321
- }
322
- function Qn(t) {
323
- const { sound: n, state: r, loader: i } = y();
324
- n.stopMusic();
325
- const u = q(t).pop();
326
- n.playMusic(i.getAssetPath(u)), r.setSubkey("game", "$currentMusic", [u]);
327
- }
328
- function fe(t) {
329
- const { sound: n, state: r, loader: i } = y();
330
- let u = r.get().game.$currentMusic || [];
331
- q(t).forEach((d) => {
332
- d ? (n.stopMusic(i.getAssetPath(d)), u = u.filter((_) => _ !== d)) : (n.stopMusic(), u = []);
333
- }), r.setSubkey("game", "$currentMusic", u);
334
- }
335
- const xe = "game", Ie = "autosave", Ce = "checkpoint";
336
- function ze(t) {
337
- const { $gameUUID: n, $sessionID: r } = y().state.get().game;
338
- return [
339
- n,
340
- ee(r),
341
- t
342
- ].join("/");
343
- }
344
- function _e({ name: t, type: n }) {
345
- return [
346
- ze("save"),
347
- [xe, Ie, Ce].includes(n) ? n : xe,
348
- typeof t == "string" || typeof t == "number" ? t : ""
349
- ].join("/");
350
- }
351
- function Et(t) {
352
- const { state: n } = y();
353
- n.setKey("scenes", t.scenes), n.setKey("game", t.game), $.loadState(t.state);
354
- }
355
- async function It(t) {
356
- let n = t;
357
- typeof t == "object" && (n = _e(t));
358
- const { persistent: r } = y(), i = await r.get(n);
359
- Et(i), w("game/load", n);
360
- }
361
- function Ct() {
362
- const { state: t } = y(), n = t.get();
363
- return {
364
- date: Date.now(),
365
- state: $.getState(),
366
- game: n.game,
367
- scenes: n.scenes
368
- };
369
- }
370
- async function Qe({ name: t, description: n, type: r }) {
371
- const { persistent: i } = y(), u = Ct(), d = {
372
- name: t,
373
- description: n,
374
- type: r,
375
- ...u
376
- }, _ = _e({ name: t, type: r });
377
- await i.set(_, d), w("game/save", _, n);
378
- }
379
- async function Ye(t) {
380
- return await y().persistent.exists(t);
381
- }
382
- async function Yn(t) {
383
- await y().persistent.remove(t), w("game/removeSave", t);
384
- }
385
- async function Ot() {
386
- const { persistent: t } = y(), n = (await t.keys()).filter((i) => i.includes(ze("save"))), r = await Promise.all(
387
- n.map(
388
- async (i) => {
389
- const u = await t.get(i);
390
- return u.id = i, delete u.state, delete u.scenes, u;
391
- }
392
- )
393
- );
394
- return w("game/listSaves", r), r;
395
- }
396
- function ie(t, n, r) {
397
- t[r] || (t[r] = []), t.content = t.content.map((i) => {
398
- i[r] || (i[r] = []);
399
- const u = i.tags?.[n];
400
- if (u) {
401
- const d = q(u);
402
- t[r] = [...t[r], ...d], i[r] = [...i[r], ...d];
403
- }
404
- return i;
405
- });
406
- }
407
- function Xn(t) {
408
- t.choices = t.choices.map((n) => ((n.tags.UNCLICKABLE || n.tags.DISABLED || n.tags.INACTIVE) && (n.disabled = !0), n));
409
- }
410
- const Zn = [
411
- (t) => ie(t, "IMAGE", "images"),
412
- (t) => ie(t, "AUDIO", "sounds"),
413
- (t) => ie(t, "PLAY_SOUND", "sounds"),
414
- (t) => ie(t, "AUDIOLOOP", "music"),
415
- (t) => ie(t, "PLAY_MUSIC", "music"),
416
- Xn
417
- ];
418
- let Xe = null, Pt = null;
419
- const $t = [], Y = {};
420
- function Lt() {
421
- const { state: t } = y();
422
- t.setKey("scenes", []), t.setKey("vars", {});
423
- }
424
- function Ft(t) {
425
- const { state: n } = y(), r = n.get().metadata.observe;
426
- r && q(r).forEach(t);
427
- }
428
- async function er() {
429
- const { state: t, persistent: n } = y(), { game: r, metadata: i } = t.get(), u = i.persist;
430
- if (!u)
431
- return;
432
- const d = r.$gameUUID, _ = ze("persist");
433
- await n.exists(_) ? (Y[d] = await n.get(_), Object.entries(Y[d]).forEach(
434
- ([p, h]) => $.setVariable(p, h)
435
- )) : Y[d] || (Y[d] = {}), q(u).forEach((p) => {
436
- $.observeVariable(p, async (h, A) => {
437
- Y[d][h] = A, await n.set(_, Y[d]);
438
- });
439
- });
440
- }
441
- async function tr(t, n, r) {
442
- await y().loader.init(t);
443
- const i = {
444
- $path: t,
445
- $file: n,
446
- $gameUUID: r || Vn(`${t}|${n}`)
447
- };
448
- y().state.setKey("game", i), Xe = i.$gameUUID, w("game/init", { pathToInkFile: t, inkFile: n });
449
- }
450
- async function Mt() {
451
- const { game: t } = y().state.get();
452
- let n = await y().loader.loadInk(t.$file);
453
- return typeof n == "string" && (n = n.replace("\uFEFF", "")), w("game/loadInkFile", t.$file), n;
454
- }
455
- async function Bt() {
456
- const { state: t } = y(), n = await Mt(), { game: r } = t.get();
457
- $.initStory(n, `${r.$path}/${r.$file}`);
458
- const i = $.getGlobalTags();
459
- t.setKey("metadata", i), Ft((u) => {
460
- $.observeVariable(u, (d, _) => {
461
- t.setSubkey("vars", d, _), w("ink/variableObserver", { name: d, value: _ });
462
- });
463
- }), Pt = Xe, w("game/initInkStory");
464
- }
465
- async function Ze(t) {
466
- const { state: n } = y();
467
- fe(), Lt(), Pt !== Xe && await Bt();
468
- let r = !0;
469
- if (t && await Ye(t)) {
470
- await It(t);
471
- const { game: i } = n.get();
472
- i.$currentMusic && Tt(i.$currentMusic), r = !1;
473
- }
474
- await er(), Ft((i) => {
475
- n.setSubkey("vars", i, $.getVariable(i));
476
- }), w("game/start", { saveSlot: t }), (r || !r && n.get().metadata.continue_maximally !== !1) && Gt();
477
- }
478
- async function Nt() {
479
- let t = null;
480
- const n = _e({ type: Ie });
481
- if (await Ye(n))
482
- t = n;
483
- else {
484
- const r = (await Ot()).filter((i) => i.type === Ce);
485
- r.length && (t = r.sort((i, u) => u.date - i.date)[0].id);
486
- }
487
- return w("game/canResume", t), t;
488
- }
489
- async function nr() {
490
- const t = await Nt();
491
- w("game/resume", { saveSlot: t }), $.resetStory(), await Ze(t);
492
- }
493
- async function et(t) {
494
- w("game/restart", { saveSlot: t }), $.resetStory(), await Ze(t);
495
- }
496
- async function Dt(t) {
497
- await et(_e({ type: "checkpoint", name: t }));
498
- }
499
- function Kt() {
500
- fe(), Lt(), $.resetStory(), w("game/clear");
501
- }
502
- function rr() {
503
- const { state: t } = y();
504
- Kt(), t.setKey("metadata", {}), t.setKey("game", {}), w("game/reset");
505
- }
506
- async function Ut(t, n = "") {
507
- await Qe({ type: xe, name: t, description: n });
508
- }
509
- async function Rt(t) {
510
- await Qe({ type: Ce, name: t });
511
- }
512
- async function Vt() {
513
- await Qe({ type: Ie });
514
- }
515
- const mt = {
516
- CLEAR: () => y().state.setKey("scenes", []),
517
- AUDIO: (t) => t ? vt(t) : Me(),
518
- AUDIOLOOP: (t) => t ? Qn(t) : fe(),
519
- PLAY_SOUND: vt,
520
- STOP_SOUND: (t) => t === !0 ? Me() : Me(t),
521
- PLAY_MUSIC: Tt,
522
- STOP_MUSIC: (t) => t === !0 ? fe() : fe(t),
523
- CHECKPOINT: (t) => Rt(t),
524
- SAVEGAME: (t) => Ut(t)
525
- };
526
- function ht(t, n) {
527
- t.forEach((r) => {
528
- r in n && r in mt && (mt[r](n[r]), w("game/handletag", { [r]: n[r] }));
529
- });
530
- }
531
- function ar(t) {
532
- $t.push(t);
533
- }
534
- function Gt() {
535
- const { state: t } = y(), { metadata: n } = t.get(), r = n.continue_maximally !== !1, i = $.getScene(r);
536
- if (!i.content || i.content.length === 0)
537
- return;
538
- Zn.forEach((d) => d(i)), $t.forEach((d) => d(i));
539
- const { tags: u } = i;
540
- if (u.RESTART) {
541
- et();
542
- return;
543
- }
544
- if (u.RESTART_FROM_CHECKPOINT) {
545
- Dt(u.RESTART_FROM_CHECKPOINT);
546
- return;
547
- }
548
- ht(
549
- ["CLEAR", "STOP_SOUND", "STOP_MUSIC", "PLAY_SOUND", "PLAY_MUSIC", "AUDIO", "AUDIOLOOP"],
550
- u
551
- ), n.single_scene ? t.setKey("scenes", [i]) : t.appendKey("scenes", i), ht(
552
- ["CHECKPOINT", "SAVEGAME"],
553
- u
554
- ), n.autosave !== !1 && Vt(), w("game/continueStory");
555
- }
556
- const or = {
557
- // game-control
558
- init: tr,
559
- loadInkFile: Mt,
560
- initInkStory: Bt,
561
- start: Ze,
562
- clear: Kt,
563
- reset: rr,
564
- // game
565
- resume: nr,
566
- canResume: Nt,
567
- restart: et,
568
- restartFromCheckpoint: Dt,
569
- continueStory: Gt,
570
- makeChoice: (t) => $.makeChoice(t),
571
- getAssetPath: (t) => y().loader.getAssetPath(t),
572
- defineSceneProcessor: ar,
573
- // saves
574
- SAVE_GAME: xe,
575
- SAVE_AUTOSAVE: Ie,
576
- SAVE_CHECKPOINT: Ce,
577
- getSaveSlotKey: _e,
578
- saveGame: Ut,
579
- saveCheckpoint: Rt,
580
- saveAutosave: Vt,
581
- load: It,
582
- getState: Ct,
583
- setState: Et,
584
- listSaves: Ot,
585
- removeSave: Yn,
586
- existSave: Ye,
587
- // sessions
588
- getSession: Gn,
589
- setSession: Hn,
590
- getSessions: Jn,
591
- removeSession: qn
592
- }, le = {
593
- mute: (t, n) => y().sound.mute(n),
594
- volume: (t, n) => y().sound.setVolume(n)
595
- };
596
- async function ir() {
597
- const { state: t, persistent: n } = y(), r = JSON.parse(JSON.stringify(Ee().settings));
598
- let i = {};
599
- await n.exists("settings") && (i = await n.get("settings"));
600
- const u = { ...r, ...i };
601
- t.setKey("settings", u), tt(), w("settings/load", u);
602
- }
603
- async function sr() {
604
- const { state: t, persistent: n } = y(), r = t.get();
605
- await n.set("settings", r.settings), w("settings/save", r.settings);
606
- }
607
- function Ht(t) {
608
- const n = y().state.get().settings[t];
609
- return w("settings/get", { name: t, value: n }), n;
610
- }
611
- function Jt(t, n) {
612
- const { state: r } = y(), i = r.get().settings[t];
613
- r.setSubkey("settings", t, n), le[t] && le[t](i, n), w("settings/set", { name: t, value: n });
614
- }
615
- function ur(t) {
616
- const n = Ht(t);
617
- Jt(t, !n);
618
- }
619
- function fr(t, n) {
620
- le[t] = n;
287
+ async function ge(e) {
288
+ let { persistent: t } = C(), n = await t.keys();
289
+ await Promise.all(n.map(async (n) => {
290
+ n.includes("save") && await e(n, await t.get(n));
291
+ }));
292
+ }
293
+ function N(e) {
294
+ return typeof e == "number" || typeof e == "string" ? e : "";
295
+ }
296
+ function _e() {
297
+ let { state: e } = C();
298
+ return N(e.get().game.$sessionID);
299
+ }
300
+ function ve(e) {
301
+ let { state: t } = C(), n = N(e);
302
+ t.setSubkey("game", "$sessionID", n), O("game/setSession", n);
303
+ }
304
+ async function ye() {
305
+ let e = {};
306
+ return await ge(async (t, n) => {
307
+ let r = N(n.game.$sessionID);
308
+ e[r] ? e[r] += 1 : e[r] = 1;
309
+ }), O("game/getSessions", e), e;
310
+ }
311
+ async function be(e) {
312
+ let { persistent: t } = C(), n = N(e);
313
+ await ge(async (e, r) => {
314
+ N(r.game.$sessionID) === n && await t.remove(e);
315
+ }), O("game/deleteSession", n);
316
+ }
317
+ function xe(e) {
318
+ let { sound: t, loader: n } = C();
319
+ k(e).forEach((e) => t.playSound(n.getAssetPath(e)));
320
+ }
321
+ function Se(e) {
322
+ let { sound: t, loader: n } = C();
323
+ k(e).forEach((e) => t.stopSound(e ? n.getAssetPath(e) : null));
324
+ }
325
+ function Ce(e) {
326
+ let { sound: t, state: n, loader: r } = C(), i = n.get().game.$currentMusic || [];
327
+ k(e).forEach((e) => {
328
+ t.playMusic(r.getAssetPath(e)), i.includes(e) || i.push(e);
329
+ }), n.setSubkey("game", "$currentMusic", i);
330
+ }
331
+ function we(e) {
332
+ let { sound: t, state: n, loader: r } = C();
333
+ t.stopMusic();
334
+ let i = k(e).pop();
335
+ t.playMusic(r.getAssetPath(i)), n.setSubkey("game", "$currentMusic", [i]);
336
+ }
337
+ function P(e) {
338
+ let { sound: t, state: n, loader: r } = C(), i = n.get().game.$currentMusic || [];
339
+ k(e).forEach((e) => {
340
+ e ? (t.stopMusic(r.getAssetPath(e)), i = i.filter((t) => t !== e)) : (t.stopMusic(), i = []);
341
+ }), n.setSubkey("game", "$currentMusic", i);
342
+ }
343
+ var Te = "game", Ee = "autosave", De = "checkpoint";
344
+ function Oe(e) {
345
+ let { $gameUUID: t, $sessionID: n } = C().state.get().game;
346
+ return [
347
+ t,
348
+ N(n),
349
+ e
350
+ ].join("/");
351
+ }
352
+ function F({ name: e, type: t }) {
353
+ return [
354
+ Oe("save"),
355
+ [
356
+ "game",
357
+ "autosave",
358
+ "checkpoint"
359
+ ].includes(t) ? t : Te,
360
+ typeof e == "string" || typeof e == "number" ? e : ""
361
+ ].join("/");
362
+ }
363
+ function ke(e) {
364
+ let { state: t } = C();
365
+ t.setKey("scenes", e.scenes), t.setKey("game", e.game), M.loadState(e.state);
366
+ }
367
+ async function Ae(e) {
368
+ let t = e;
369
+ typeof e == "object" && (t = F(e));
370
+ let { persistent: n } = C();
371
+ ke(await n.get(t)), O("game/load", t);
372
+ }
373
+ function je() {
374
+ let { state: e } = C(), t = e.get();
375
+ return {
376
+ date: Date.now(),
377
+ state: M.getState(),
378
+ game: t.game,
379
+ scenes: t.scenes
380
+ };
381
+ }
382
+ async function Me({ name: e, description: t, type: n }) {
383
+ let { persistent: r } = C(), i = {
384
+ name: e,
385
+ description: t,
386
+ type: n,
387
+ ...je()
388
+ }, a = F({
389
+ name: e,
390
+ type: n
391
+ });
392
+ await r.set(a, i), O("game/save", a, t);
393
+ }
394
+ async function Ne(e) {
395
+ return await C().persistent.exists(e);
396
+ }
397
+ async function Pe(e) {
398
+ await C().persistent.remove(e), O("game/removeSave", e);
399
+ }
400
+ async function Fe() {
401
+ let { persistent: e } = C(), t = (await e.keys()).filter((e) => e.includes(Oe("save"))), n = await Promise.all(t.map(async (t) => {
402
+ let n = await e.get(t);
403
+ return n.id = t, delete n.state, delete n.scenes, n;
404
+ }));
405
+ return O("game/listSaves", n), n;
406
+ }
407
+ function I(e, t, n) {
408
+ e[n] ||= [], e.content = e.content.map((r) => {
409
+ r[n] ||= [];
410
+ let i = r.tags?.[t];
411
+ if (i) {
412
+ let t = k(i);
413
+ e[n] = [...e[n], ...t], r[n] = [...r[n], ...t];
414
+ }
415
+ return r;
416
+ });
417
+ }
418
+ function Ie(e) {
419
+ e.choices = e.choices.map((e) => ((e.tags.UNCLICKABLE || e.tags.DISABLED || e.tags.INACTIVE) && (e.disabled = !0), e));
420
+ }
421
+ var Le = [
422
+ (e) => I(e, "IMAGE", "images"),
423
+ (e) => I(e, "AUDIO", "sounds"),
424
+ (e) => I(e, "PLAY_SOUND", "sounds"),
425
+ (e) => I(e, "AUDIOLOOP", "music"),
426
+ (e) => I(e, "PLAY_MUSIC", "music"),
427
+ Ie
428
+ ], Re = null, ze = null, Be = !1, Ve = [], L = {};
429
+ function He() {
430
+ let { state: e } = C();
431
+ e.setKey("scenes", []), e.setKey("vars", {});
432
+ }
433
+ function Ue(e) {
434
+ let { state: t } = C(), n = t.get().metadata.observe;
435
+ n && k(n).forEach(e);
436
+ }
437
+ function We() {
438
+ C().state.setKey("metadata", M.getGlobalTags()), Be = !1;
439
+ }
440
+ async function Ge() {
441
+ let { state: e, persistent: t } = C();
442
+ if (!e.get().metadata.persist) return;
443
+ let n = Oe("persist");
444
+ await t.exists(n) ? (L[n] = await t.get(n), Object.entries(L[n]).forEach(([e, t]) => M.setVariable(e, t))) : L[n] = {};
445
+ }
446
+ function Ke() {
447
+ let { state: e, persistent: t } = C(), n = e.get().metadata.persist;
448
+ n && k(n).forEach((e) => {
449
+ M.observeVariable(e, async (e, n) => {
450
+ let r = Oe("persist");
451
+ L[r] ||= {}, L[r][e] = n, await t.set(r, L[r]);
452
+ });
453
+ });
454
+ }
455
+ async function qe(e, t, n) {
456
+ C().sound?.reset?.(), await C().loader.init(e);
457
+ let r = {
458
+ $path: e,
459
+ $file: t,
460
+ $gameUUID: n || de(`${e}|${t}`)
461
+ };
462
+ C().state.setKey("game", r), Re = r.$gameUUID, O("game/init", {
463
+ pathToInkFile: e,
464
+ inkFile: t
465
+ });
466
+ }
467
+ async function Je() {
468
+ let { game: e } = C().state.get(), t = await C().loader.loadInk(e.$file);
469
+ return typeof t == "string" && (t = t.replace("", "")), O("game/loadInkFile", e.$file), t;
470
+ }
471
+ async function Ye() {
472
+ let { state: e } = C(), t = await Je(), { game: n } = e.get();
473
+ M.initStory(t, `${n.$path}/${n.$file}`), We(), Ue((t) => {
474
+ M.observeVariable(t, (t, n) => {
475
+ e.setSubkey("vars", t, n), O("ink/variableObserver", {
476
+ name: t,
477
+ value: n
478
+ });
479
+ });
480
+ }), Ke(), ze = Re, O("game/initInkStory");
481
+ }
482
+ async function Xe(e) {
483
+ let { state: t } = C();
484
+ P(), He(), ze === Re ? Be && We() : await Ye();
485
+ let n = !0;
486
+ if (e && await Ne(e)) {
487
+ await Ae(e);
488
+ let { game: r } = t.get();
489
+ r.$currentMusic && Ce(r.$currentMusic), n = !1;
490
+ }
491
+ await Ge(), Ue((e) => {
492
+ t.setSubkey("vars", e, M.getVariable(e));
493
+ }), O("game/start", { saveSlot: e }), (n || !n && t.get().metadata.continue_maximally !== !1) && lt();
494
+ }
495
+ async function Ze() {
496
+ let e = null, t = F({ type: Ee });
497
+ if (await Ne(t)) e = t;
498
+ else {
499
+ let t = (await Fe()).filter((e) => e.type === De);
500
+ t.length && (e = t.sort((e, t) => t.date - e.date)[0].id);
501
+ }
502
+ return O("game/canResume", e), e;
503
+ }
504
+ async function Qe() {
505
+ let e = await Ze();
506
+ O("game/resume", { saveSlot: e }), M.resetStory(), await Xe(e);
507
+ }
508
+ async function $e(e) {
509
+ O("game/restart", { saveSlot: e }), M.resetStory(), await Xe(e);
510
+ }
511
+ async function et(e) {
512
+ await $e(F({
513
+ type: "checkpoint",
514
+ name: e
515
+ }));
621
516
  }
622
517
  function tt() {
623
- const t = y().state.get().settings;
624
- Object.entries(t).forEach(([n, r]) => {
625
- le[n] && le[n](null, r);
626
- });
627
- }
628
- function cr() {
629
- const { state: t } = y(), n = JSON.parse(JSON.stringify(Ee().settings));
630
- t.setKey("settings", n), tt(), w("settings/reset", n);
631
- }
632
- const qt = {
633
- load: ir,
634
- save: sr,
635
- get: Ht,
636
- set: Jt,
637
- toggle: ur,
638
- defineHandler: fr,
639
- runHandlers: tt,
640
- reset: cr
641
- }, lr = "2.1.5";
642
- async function dr(t, n) {
643
- w("atrament/init");
644
- const { persistent: r } = y();
645
- Un(t, n), r.init(Ee().applicationID), await qt.load();
646
- }
647
- const _r = {
648
- get interfaces() {
649
- return y();
650
- },
651
- defineInterfaces: Kn,
652
- init: dr,
653
- get state() {
654
- return y().state;
655
- },
656
- get store() {
657
- return y().state.store();
658
- },
659
- on: (t, n) => Ge.on(t, n),
660
- off: (t, n) => Ge.off(t, n),
661
- emit: w,
662
- // sub-objects
663
- game: or,
664
- ink: $,
665
- settings: qt,
666
- version: lr
518
+ P(), He(), M.resetStory(), O("game/clear");
519
+ }
520
+ function nt() {
521
+ let { state: e } = C();
522
+ tt(), e.setKey("metadata", {}), e.setKey("game", {}), Be = !0, O("game/reset");
523
+ }
524
+ async function rt(e, t = "") {
525
+ await Me({
526
+ type: Te,
527
+ name: e,
528
+ description: t
529
+ });
530
+ }
531
+ async function it(e) {
532
+ await Me({
533
+ type: De,
534
+ name: e
535
+ });
536
+ }
537
+ async function at() {
538
+ await Me({ type: Ee });
539
+ }
540
+ var ot = {
541
+ CLEAR: () => C().state.setKey("scenes", []),
542
+ AUDIO: (e) => e ? xe(e) : Se(),
543
+ AUDIOLOOP: (e) => e ? we(e) : P(),
544
+ PLAY_SOUND: xe,
545
+ STOP_SOUND: (e) => e === !0 ? Se() : Se(e),
546
+ PLAY_MUSIC: Ce,
547
+ STOP_MUSIC: (e) => e === !0 ? P() : P(e),
548
+ CHECKPOINT: (e) => it(e),
549
+ SAVEGAME: (e) => rt(e)
667
550
  };
668
- var gt = {}, pr = (function(t, n, r, i, u) {
669
- var d = new Worker(gt[n] || (gt[n] = URL.createObjectURL(new Blob([
670
- t + ';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'
671
- ], { type: "text/javascript" }))));
672
- return d.onmessage = function(_) {
673
- var p = _.data, h = p.$e$;
674
- if (h) {
675
- var A = new Error(h[0]);
676
- A.code = h[1], A.stack = h[2], u(A, null);
677
- } else
678
- u(null, p);
679
- }, d.postMessage(r, i), d;
680
- }), P = Uint8Array, j = Uint16Array, Wt = Int32Array, nt = new P([
681
- 0,
682
- 0,
683
- 0,
684
- 0,
685
- 0,
686
- 0,
687
- 0,
688
- 0,
689
- 1,
690
- 1,
691
- 1,
692
- 1,
693
- 2,
694
- 2,
695
- 2,
696
- 2,
697
- 3,
698
- 3,
699
- 3,
700
- 3,
701
- 4,
702
- 4,
703
- 4,
704
- 4,
705
- 5,
706
- 5,
707
- 5,
708
- 5,
709
- 0,
710
- /* unused */
711
- 0,
712
- 0,
713
- /* impossible */
714
- 0
715
- ]), rt = new P([
716
- 0,
717
- 0,
718
- 0,
719
- 0,
720
- 1,
721
- 1,
722
- 2,
723
- 2,
724
- 3,
725
- 3,
726
- 4,
727
- 4,
728
- 5,
729
- 5,
730
- 6,
731
- 6,
732
- 7,
733
- 7,
734
- 8,
735
- 8,
736
- 9,
737
- 9,
738
- 10,
739
- 10,
740
- 11,
741
- 11,
742
- 12,
743
- 12,
744
- 13,
745
- 13,
746
- /* unused */
747
- 0,
748
- 0
749
- ]), jt = new P([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]), zt = function(t, n) {
750
- for (var r = new j(31), i = 0; i < 31; ++i)
751
- r[i] = n += 1 << t[i - 1];
752
- for (var u = new Wt(r[30]), i = 1; i < 30; ++i)
753
- for (var d = r[i]; d < r[i + 1]; ++d)
754
- u[d] = d - r[i] << 5 | i;
755
- return { b: r, r: u };
756
- }, Qt = zt(nt, 2), at = Qt.b, vr = Qt.r;
757
- at[28] = 258, vr[258] = 28;
758
- var mr = zt(rt, 0), Yt = mr.b, ke = new j(32768);
759
- for (var x = 0; x < 32768; ++x) {
760
- var G = (x & 43690) >> 1 | (x & 21845) << 1;
761
- G = (G & 52428) >> 2 | (G & 13107) << 2, G = (G & 61680) >> 4 | (G & 3855) << 4, ke[x] = ((G & 65280) >> 8 | (G & 255) << 8) >> 1;
762
- }
763
- var X = (function(t, n, r) {
764
- for (var i = t.length, u = 0, d = new j(n); u < i; ++u)
765
- t[u] && ++d[t[u] - 1];
766
- var _ = new j(n);
767
- for (u = 1; u < n; ++u)
768
- _[u] = _[u - 1] + d[u - 1] << 1;
769
- var p;
770
- if (r) {
771
- p = new j(1 << n);
772
- var h = 15 - n;
773
- for (u = 0; u < i; ++u)
774
- if (t[u])
775
- for (var A = u << 4 | t[u], m = n - t[u], e = _[t[u] - 1]++ << m, a = e | (1 << m) - 1; e <= a; ++e)
776
- p[ke[e] >> h] = A;
777
- } else
778
- for (p = new j(i), u = 0; u < i; ++u)
779
- t[u] && (p[u] = ke[_[t[u] - 1]++] >> 15 - t[u]);
780
- return p;
781
- }), pe = new P(288);
782
- for (var x = 0; x < 144; ++x)
783
- pe[x] = 8;
784
- for (var x = 144; x < 256; ++x)
785
- pe[x] = 9;
786
- for (var x = 256; x < 280; ++x)
787
- pe[x] = 7;
788
- for (var x = 280; x < 288; ++x)
789
- pe[x] = 8;
790
- var Xt = new P(32);
791
- for (var x = 0; x < 32; ++x)
792
- Xt[x] = 5;
793
- var Zt = /* @__PURE__ */ X(pe, 9, 1), en = /* @__PURE__ */ X(Xt, 5, 1), we = function(t) {
794
- for (var n = t[0], r = 1; r < t.length; ++r)
795
- t[r] > n && (n = t[r]);
796
- return n;
797
- }, F = function(t, n, r) {
798
- var i = n / 8 | 0;
799
- return (t[i] | t[i + 1] << 8) >> (n & 7) & r;
800
- }, be = function(t, n) {
801
- var r = n / 8 | 0;
802
- return (t[r] | t[r + 1] << 8 | t[r + 2] << 16) >> (n & 7);
803
- }, tn = function(t) {
804
- return (t + 7) / 8 | 0;
805
- }, Oe = function(t, n, r) {
806
- return (n == null || n < 0) && (n = 0), (r == null || r > t.length) && (r = t.length), new P(t.subarray(n, r));
807
- }, nn = [
808
- "unexpected EOF",
809
- "invalid block type",
810
- "invalid length/literal",
811
- "invalid distance",
812
- "stream finished",
813
- "no stream handler",
814
- ,
815
- "no callback",
816
- "invalid UTF-8 data",
817
- "extra field too long",
818
- "date not in range 1980-2099",
819
- "filename too long",
820
- "stream finishing",
821
- "invalid zip data"
822
- // determined by unknown compression method
823
- ], O = function(t, n, r) {
824
- var i = new Error(n || nn[t]);
825
- if (i.code = t, Error.captureStackTrace && Error.captureStackTrace(i, O), !r)
826
- throw i;
827
- return i;
828
- }, rn = function(t, n, r, i) {
829
- var u = t.length, d = i ? i.length : 0;
830
- if (!u || n.f && !n.l)
831
- return r || new P(0);
832
- var _ = !r, p = _ || n.i != 2, h = n.i;
833
- _ && (r = new P(u * 3));
834
- var A = function(dt) {
835
- var _t = r.length;
836
- if (dt > _t) {
837
- var pt = new P(Math.max(_t * 2, dt));
838
- pt.set(r), r = pt;
839
- }
840
- }, m = n.f || 0, e = n.p || 0, a = n.b || 0, o = n.l, s = n.d, c = n.m, l = n.n, f = u * 8;
841
- do {
842
- if (!o) {
843
- m = F(t, e, 1);
844
- var v = F(t, e + 1, 3);
845
- if (e += 3, v)
846
- if (v == 1)
847
- o = Zt, s = en, c = 9, l = 5;
848
- else if (v == 2) {
849
- var L = F(t, e, 31) + 257, K = F(t, e + 10, 15) + 4, M = L + F(t, e + 5, 31) + 1;
850
- e += 14;
851
- for (var b = new P(M), U = new P(19), E = 0; E < K; ++E)
852
- U[jt[E]] = F(t, e + E * 3, 7);
853
- e += K * 3;
854
- for (var W = we(U), ve = (1 << W) - 1, R = X(U, W, 1), E = 0; E < M; ) {
855
- var me = R[F(t, e, ve)];
856
- e += me & 15;
857
- var g = me >> 4;
858
- if (g < 16)
859
- b[E++] = g;
860
- else {
861
- var z = 0, he = 0;
862
- for (g == 16 ? (he = 3 + F(t, e, 3), e += 2, z = b[E - 1]) : g == 17 ? (he = 3 + F(t, e, 7), e += 3) : g == 18 && (he = 11 + F(t, e, 127), e += 7); he--; )
863
- b[E++] = z;
864
- }
865
- }
866
- var ut = b.subarray(0, L), V = b.subarray(L);
867
- c = we(ut), l = we(V), o = X(ut, c, 1), s = X(V, l, 1);
868
- } else
869
- O(1);
870
- else {
871
- var g = tn(e) + 4, S = t[g - 4] | t[g - 3] << 8, C = g + S;
872
- if (C > u) {
873
- h && O(0);
874
- break;
875
- }
876
- p && A(a + S), r.set(t.subarray(g, C), a), n.b = a += S, n.p = e = C * 8, n.f = m;
877
- continue;
878
- }
879
- if (e > f) {
880
- h && O(0);
881
- break;
882
- }
883
- }
884
- p && A(a + 131072);
885
- for (var hn = (1 << c) - 1, gn = (1 << l) - 1, $e = e; ; $e = e) {
886
- var z = o[be(t, e) & hn], Q = z >> 4;
887
- if (e += z & 15, e > f) {
888
- h && O(0);
889
- break;
890
- }
891
- if (z || O(2), Q < 256)
892
- r[a++] = Q;
893
- else if (Q == 256) {
894
- $e = e, o = null;
895
- break;
896
- } else {
897
- var ft = Q - 254;
898
- if (Q > 264) {
899
- var E = Q - 257, oe = nt[E];
900
- ft = F(t, e, (1 << oe) - 1) + at[E], e += oe;
901
- }
902
- var Le = s[be(t, e) & gn], Fe = Le >> 4;
903
- Le || O(3), e += Le & 15;
904
- var V = Yt[Fe];
905
- if (Fe > 3) {
906
- var oe = rt[Fe];
907
- V += be(t, e) & (1 << oe) - 1, e += oe;
908
- }
909
- if (e > f) {
910
- h && O(0);
911
- break;
912
- }
913
- p && A(a + 131072);
914
- var ct = a + ft;
915
- if (a < V) {
916
- var lt = d - V, yn = Math.min(V, ct);
917
- for (lt + a < 0 && O(3); a < yn; ++a)
918
- r[a] = i[lt + a];
919
- }
920
- for (; a < ct; ++a)
921
- r[a] = r[a - V];
922
- }
923
- }
924
- n.l = o, n.p = $e, n.b = a, n.f = m, o && (m = 1, n.m = c, n.d = s, n.n = l);
925
- } while (!m);
926
- return a != r.length && _ ? Oe(r, 0, a) : r.subarray(0, a);
927
- }, hr = /* @__PURE__ */ new P(0), gr = function(t, n) {
928
- var r = {};
929
- for (var i in t)
930
- r[i] = t[i];
931
- for (var i in n)
932
- r[i] = n[i];
933
- return r;
934
- }, yt = function(t, n, r) {
935
- for (var i = t(), u = t.toString(), d = u.slice(u.indexOf("[") + 1, u.lastIndexOf("]")).replace(/\s+/g, "").split(","), _ = 0; _ < i.length; ++_) {
936
- var p = i[_], h = d[_];
937
- if (typeof p == "function") {
938
- n += ";" + h + "=";
939
- var A = p.toString();
940
- if (p.prototype)
941
- if (A.indexOf("[native code]") != -1) {
942
- var m = A.indexOf(" ", 8) + 1;
943
- n += A.slice(m, A.indexOf("(", m));
944
- } else {
945
- n += A;
946
- for (var e in p.prototype)
947
- n += ";" + h + ".prototype." + e + "=" + p.prototype[e].toString();
948
- }
949
- else
950
- n += A;
951
- } else
952
- r[h] = p;
953
- }
954
- return n;
955
- }, ge = [], yr = function(t) {
956
- var n = [];
957
- for (var r in t)
958
- t[r].buffer && n.push((t[r] = new t[r].constructor(t[r])).buffer);
959
- return n;
960
- }, wr = function(t, n, r, i) {
961
- if (!ge[r]) {
962
- for (var u = "", d = {}, _ = t.length - 1, p = 0; p < _; ++p)
963
- u = yt(t[p], u, d);
964
- ge[r] = { c: yt(t[_], u, d), e: d };
965
- }
966
- var h = gr({}, ge[r].e);
967
- return pr(ge[r].c + ";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=" + n.toString() + "}", r, h, yr(h), i);
968
- }, br = function() {
969
- return [P, j, Wt, nt, rt, jt, at, Yt, Zt, en, ke, nn, X, we, F, be, tn, Oe, O, rn, ot, an, on];
970
- }, an = function(t) {
971
- return postMessage(t, [t.buffer]);
972
- }, on = function(t) {
973
- return t && {
974
- out: t.size && new P(t.size),
975
- dictionary: t.dictionary
976
- };
977
- }, Ar = function(t, n, r, i, u, d) {
978
- var _ = wr(r, i, u, function(p, h) {
979
- _.terminate(), d(p, h);
980
- });
981
- return _.postMessage([t, n], n.consume ? [t.buffer] : []), function() {
982
- _.terminate();
983
- };
984
- }, D = function(t, n) {
985
- return t[n] | t[n + 1] << 8;
986
- }, N = function(t, n) {
987
- return (t[n] | t[n + 1] << 8 | t[n + 2] << 16 | t[n + 3] << 24) >>> 0;
988
- }, Be = function(t, n) {
989
- return N(t, n) + N(t, n + 4) * 4294967296;
551
+ function st(e, t) {
552
+ e.forEach((e) => {
553
+ e in t && e in ot && (ot[e](t[e]), O("game/handletag", { [e]: t[e] }));
554
+ });
555
+ }
556
+ function ct(e) {
557
+ Ve.push(e);
558
+ }
559
+ function lt() {
560
+ let { state: e } = C(), { metadata: t } = e.get(), n = t.continue_maximally !== !1, r = M.getScene(n);
561
+ if (!r.content || r.content.length === 0) return;
562
+ Le.forEach((e) => e(r)), Ve.forEach((e) => e(r));
563
+ let { tags: i } = r;
564
+ i.RESTART ? $e() : i.RESTART_FROM_CHECKPOINT ? et(i.RESTART_FROM_CHECKPOINT) : (st([
565
+ "CLEAR",
566
+ "STOP_SOUND",
567
+ "STOP_MUSIC",
568
+ "PLAY_SOUND",
569
+ "PLAY_MUSIC",
570
+ "AUDIO",
571
+ "AUDIOLOOP"
572
+ ], i), t.single_scene ? e.setKey("scenes", [r]) : e.appendKey("scenes", r), st(["CHECKPOINT", "SAVEGAME"], i), t.autosave !== !1 && at(), O("game/continueStory"));
573
+ }
574
+ var ut = {
575
+ init: qe,
576
+ loadInkFile: Je,
577
+ initInkStory: Ye,
578
+ start: Xe,
579
+ clear: tt,
580
+ reset: nt,
581
+ resume: Qe,
582
+ canResume: Ze,
583
+ restart: $e,
584
+ restartFromCheckpoint: et,
585
+ continueStory: lt,
586
+ makeChoice: (e) => M.makeChoice(e),
587
+ getAssetPath: (e) => C().loader.getAssetPath(e),
588
+ defineSceneProcessor: ct,
589
+ SAVE_GAME: Te,
590
+ SAVE_AUTOSAVE: Ee,
591
+ SAVE_CHECKPOINT: De,
592
+ getSaveSlotKey: F,
593
+ saveGame: rt,
594
+ saveCheckpoint: it,
595
+ saveAutosave: at,
596
+ load: Ae,
597
+ getState: je,
598
+ setState: ke,
599
+ listSaves: Fe,
600
+ removeSave: Pe,
601
+ existSave: Ne,
602
+ getSession: _e,
603
+ setSession: ve,
604
+ getSessions: ye,
605
+ removeSession: be
606
+ }, R = {
607
+ mute: (e, t) => C().sound.mute(t),
608
+ volume: (e, t) => C().sound.setVolume(t)
990
609
  };
991
- function Sr(t, n, r) {
992
- return r || (r = n, n = {}), typeof r != "function" && O(7), Ar(t, n, [
993
- br
994
- ], function(i) {
995
- return an(ot(i.data[0], on(i.data[1])));
996
- }, 1, r);
997
- }
998
- function ot(t, n) {
999
- return rn(t, { i: 2 }, n && n.out, n && n.dictionary);
610
+ function dt() {
611
+ let e = C().state.get().settings;
612
+ Object.entries(e).forEach(([e, t]) => {
613
+ R[e] && R[e](null, t);
614
+ });
615
+ }
616
+ async function ft() {
617
+ let { state: e, persistent: t } = C(), n = JSON.parse(JSON.stringify(E().settings)), r = {};
618
+ await t.exists("settings") && (r = await t.get("settings"));
619
+ let i = {
620
+ ...n,
621
+ ...r
622
+ };
623
+ e.setKey("settings", i), dt(), O("settings/load", i);
624
+ }
625
+ async function pt() {
626
+ let { state: e, persistent: t } = C(), n = e.get();
627
+ await t.set("settings", n.settings), O("settings/save", n.settings);
628
+ }
629
+ function mt(e) {
630
+ let t = C().state.get().settings[e];
631
+ return O("settings/get", {
632
+ name: e,
633
+ value: t
634
+ }), t;
635
+ }
636
+ function ht(e, t) {
637
+ let { state: n } = C(), r = n.get().settings[e];
638
+ n.setSubkey("settings", e, t), R[e] && R[e](r, t), O("settings/set", {
639
+ name: e,
640
+ value: t
641
+ });
642
+ }
643
+ function gt(e) {
644
+ ht(e, !mt(e));
645
+ }
646
+ function _t(e, t) {
647
+ R[e] = t;
648
+ }
649
+ function vt() {
650
+ let { state: e } = C(), t = JSON.parse(JSON.stringify(E().settings));
651
+ e.setKey("settings", t), dt(), O("settings/reset", t);
652
+ }
653
+ var yt = {
654
+ load: ft,
655
+ save: pt,
656
+ get: mt,
657
+ set: ht,
658
+ toggle: gt,
659
+ defineHandler: _t,
660
+ runHandlers: dt,
661
+ reset: vt
662
+ }, bt = "2.1.6";
663
+ async function xt(e, t) {
664
+ O("atrament/init");
665
+ let { persistent: n } = C();
666
+ le(e, t), n.init(E().applicationID), await yt.load();
667
+ }
668
+ var St = {
669
+ get interfaces() {
670
+ return C();
671
+ },
672
+ defineInterfaces: w,
673
+ init: xt,
674
+ get state() {
675
+ return C().state;
676
+ },
677
+ get store() {
678
+ return C().state.store();
679
+ },
680
+ on: (e, t) => D.on(e, t),
681
+ off: (e, t) => D.off(e, t),
682
+ emit: O,
683
+ game: ut,
684
+ ink: M,
685
+ settings: yt,
686
+ version: bt
687
+ }, z = Uint8Array, B = Uint16Array, Ct = Int32Array, wt = new z([
688
+ 0,
689
+ 0,
690
+ 0,
691
+ 0,
692
+ 0,
693
+ 0,
694
+ 0,
695
+ 0,
696
+ 1,
697
+ 1,
698
+ 1,
699
+ 1,
700
+ 2,
701
+ 2,
702
+ 2,
703
+ 2,
704
+ 3,
705
+ 3,
706
+ 3,
707
+ 3,
708
+ 4,
709
+ 4,
710
+ 4,
711
+ 4,
712
+ 5,
713
+ 5,
714
+ 5,
715
+ 5,
716
+ 0,
717
+ 0,
718
+ 0,
719
+ 0
720
+ ]), Tt = new z([
721
+ 0,
722
+ 0,
723
+ 0,
724
+ 0,
725
+ 1,
726
+ 1,
727
+ 2,
728
+ 2,
729
+ 3,
730
+ 3,
731
+ 4,
732
+ 4,
733
+ 5,
734
+ 5,
735
+ 6,
736
+ 6,
737
+ 7,
738
+ 7,
739
+ 8,
740
+ 8,
741
+ 9,
742
+ 9,
743
+ 10,
744
+ 10,
745
+ 11,
746
+ 11,
747
+ 12,
748
+ 12,
749
+ 13,
750
+ 13,
751
+ 0,
752
+ 0
753
+ ]), Et = new z([
754
+ 16,
755
+ 17,
756
+ 18,
757
+ 0,
758
+ 8,
759
+ 7,
760
+ 9,
761
+ 6,
762
+ 10,
763
+ 5,
764
+ 11,
765
+ 4,
766
+ 12,
767
+ 3,
768
+ 13,
769
+ 2,
770
+ 14,
771
+ 1,
772
+ 15
773
+ ]), Dt = function(e, t) {
774
+ for (var n = new B(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
775
+ for (var i = new Ct(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
776
+ return {
777
+ b: n,
778
+ r: i
779
+ };
780
+ }, Ot = Dt(wt, 2), kt = Ot.b, At = Ot.r;
781
+ kt[28] = 258, At[258] = 28;
782
+ var jt = Dt(Tt, 0), Mt = jt.b;
783
+ jt.r;
784
+ for (var Nt = new B(32768), V = 0; V < 32768; ++V) {
785
+ var H = (V & 43690) >> 1 | (V & 21845) << 1;
786
+ H = (H & 52428) >> 2 | (H & 13107) << 2, H = (H & 61680) >> 4 | (H & 3855) << 4, Nt[V] = ((H & 65280) >> 8 | (H & 255) << 8) >> 1;
787
+ }
788
+ for (var U = (function(e, t, n) {
789
+ for (var r = e.length, i = 0, a = new B(t); i < r; ++i) e[i] && ++a[e[i] - 1];
790
+ var o = new B(t);
791
+ for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
792
+ var s;
793
+ if (n) {
794
+ s = new B(1 << t);
795
+ var c = 15 - t;
796
+ for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i], u = t - e[i], d = o[e[i] - 1]++ << u, f = d | (1 << u) - 1; d <= f; ++d) s[Nt[d] >> c] = l;
797
+ } else for (s = new B(r), i = 0; i < r; ++i) e[i] && (s[i] = Nt[o[e[i] - 1]++] >> 15 - e[i]);
798
+ return s;
799
+ }), Pt = new z(288), V = 0; V < 144; ++V) Pt[V] = 8;
800
+ for (var V = 144; V < 256; ++V) Pt[V] = 9;
801
+ for (var V = 256; V < 280; ++V) Pt[V] = 7;
802
+ for (var V = 280; V < 288; ++V) Pt[V] = 8;
803
+ for (var Ft = new z(32), V = 0; V < 32; ++V) Ft[V] = 5;
804
+ var It = /*#__PURE__*/ U(Pt, 9, 1), Lt = /*#__PURE__*/ U(Ft, 5, 1), Rt = function(e) {
805
+ for (var t = e[0], n = 1; n < e.length; ++n) e[n] > t && (t = e[n]);
806
+ return t;
807
+ }, W = function(e, t, n) {
808
+ var r = t / 8 | 0;
809
+ return (e[r] | e[r + 1] << 8) >> (t & 7) & n;
810
+ }, zt = function(e, t) {
811
+ var n = t / 8 | 0;
812
+ return (e[n] | e[n + 1] << 8 | e[n + 2] << 16) >> (t & 7);
813
+ }, Bt = function(e) {
814
+ return (e + 7) / 8 | 0;
815
+ }, Vt = function(e, t, n) {
816
+ return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new z(e.subarray(t, n));
817
+ }, Ht = [
818
+ "unexpected EOF",
819
+ "invalid block type",
820
+ "invalid length/literal",
821
+ "invalid distance",
822
+ "stream finished",
823
+ "no stream handler",
824
+ ,
825
+ "no callback",
826
+ "invalid UTF-8 data",
827
+ "extra field too long",
828
+ "date not in range 1980-2099",
829
+ "filename too long",
830
+ "stream finishing",
831
+ "invalid zip data"
832
+ ], G = function(e, t, n) {
833
+ var r = Error(t || Ht[e]);
834
+ if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, G), !n) throw r;
835
+ return r;
836
+ }, Ut = function(e, t, n, r) {
837
+ var i = e.length, a = r ? r.length : 0;
838
+ if (!i || t.f && !t.l) return n || new z(0);
839
+ var o = !n, s = o || t.i != 2, c = t.i;
840
+ o && (n = new z(i * 3));
841
+ var l = function(e) {
842
+ var t = n.length;
843
+ if (e > t) {
844
+ var r = new z(Math.max(t * 2, e));
845
+ r.set(n), n = r;
846
+ }
847
+ }, u = t.f || 0, d = t.p || 0, f = t.b || 0, p = t.l, m = t.d, h = t.m, g = t.n, _ = i * 8;
848
+ do {
849
+ if (!p) {
850
+ u = W(e, d, 1);
851
+ var v = W(e, d + 1, 3);
852
+ if (d += 3, !v) {
853
+ var y = Bt(d) + 4, ee = e[y - 4] | e[y - 3] << 8, b = y + ee;
854
+ if (b > i) {
855
+ c && G(0);
856
+ break;
857
+ }
858
+ s && l(f + ee), n.set(e.subarray(y, b), f), t.b = f += ee, t.p = d = b * 8, t.f = u;
859
+ continue;
860
+ }
861
+ if (v == 1) p = It, m = Lt, h = 9, g = 5;
862
+ else if (v == 2) {
863
+ var te = W(e, d, 31) + 257, ne = W(e, d + 10, 15) + 4, re = te + W(e, d + 5, 31) + 1;
864
+ d += 14;
865
+ for (var x = new z(re), ie = new z(19), S = 0; S < ne; ++S) ie[Et[S]] = W(e, d + S * 3, 7);
866
+ d += ne * 3;
867
+ for (var ae = Rt(ie), oe = (1 << ae) - 1, se = U(ie, ae, 1), S = 0; S < re;) {
868
+ var ce = se[W(e, d, oe)];
869
+ d += ce & 15;
870
+ var y = ce >> 4;
871
+ if (y < 16) x[S++] = y;
872
+ else {
873
+ var C = 0, w = 0;
874
+ for (y == 16 ? (w = 3 + W(e, d, 3), d += 2, C = x[S - 1]) : y == 17 ? (w = 3 + W(e, d, 7), d += 3) : y == 18 && (w = 11 + W(e, d, 127), d += 7); w--;) x[S++] = C;
875
+ }
876
+ }
877
+ var T = x.subarray(0, te), E = x.subarray(te);
878
+ h = Rt(T), g = Rt(E), p = U(T, h, 1), m = U(E, g, 1);
879
+ } else G(1);
880
+ if (d > _) {
881
+ c && G(0);
882
+ break;
883
+ }
884
+ }
885
+ s && l(f + 131072);
886
+ for (var le = (1 << h) - 1, ue = (1 << g) - 1, D = d;; D = d) {
887
+ var C = p[zt(e, d) & le], O = C >> 4;
888
+ if (d += C & 15, d > _) {
889
+ c && G(0);
890
+ break;
891
+ }
892
+ if (C || G(2), O < 256) n[f++] = O;
893
+ else if (O == 256) {
894
+ D = d, p = null;
895
+ break;
896
+ } else {
897
+ var k = O - 254;
898
+ if (O > 264) {
899
+ var S = O - 257, de = wt[S];
900
+ k = W(e, d, (1 << de) - 1) + kt[S], d += de;
901
+ }
902
+ var A = m[zt(e, d) & ue], j = A >> 4;
903
+ A || G(3), d += A & 15;
904
+ var E = Mt[j];
905
+ if (j > 3) {
906
+ var de = Tt[j];
907
+ E += zt(e, d) & (1 << de) - 1, d += de;
908
+ }
909
+ if (d > _) {
910
+ c && G(0);
911
+ break;
912
+ }
913
+ s && l(f + 131072);
914
+ var fe = f + k;
915
+ if (f < E) {
916
+ var pe = a - E, me = Math.min(E, fe);
917
+ for (pe + f < 0 && G(3); f < me; ++f) n[f] = r[pe + f];
918
+ }
919
+ for (; f < fe; ++f) n[f] = n[f - E];
920
+ }
921
+ }
922
+ t.l = p, t.p = D, t.b = f, t.f = u, p && (u = 1, t.m = h, t.d = m, t.n = g);
923
+ } while (!u);
924
+ return f != n.length && o ? Vt(n, 0, f) : n.subarray(0, f);
925
+ }, Wt = /*#__PURE__*/ new z(0), K = function(e, t) {
926
+ return e[t] | e[t + 1] << 8;
927
+ }, q = function(e, t) {
928
+ return (e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24) >>> 0;
929
+ }, Gt = function(e, t) {
930
+ return q(e, t) + q(e, t + 4) * 4294967296;
931
+ };
932
+ function Kt(e, t) {
933
+ return Ut(e, { i: 2 }, t && t.out, t && t.dictionary);
1000
934
  }
1001
- var Je = typeof TextDecoder < "u" && /* @__PURE__ */ new TextDecoder(), xr = 0;
935
+ var qt = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
1002
936
  try {
1003
- Je.decode(hr, { stream: !0 }), xr = 1;
1004
- } catch {
1005
- }
1006
- var kr = function(t) {
1007
- for (var n = "", r = 0; ; ) {
1008
- var i = t[r++], u = (i > 127) + (i > 223) + (i > 239);
1009
- if (r + u > t.length)
1010
- return { s: n, r: Oe(t, r - 1) };
1011
- u ? u == 3 ? (i = ((i & 15) << 18 | (t[r++] & 63) << 12 | (t[r++] & 63) << 6 | t[r++] & 63) - 65536, n += String.fromCharCode(55296 | i >> 10, 56320 | i & 1023)) : u & 1 ? n += String.fromCharCode((i & 31) << 6 | t[r++] & 63) : n += String.fromCharCode((i & 15) << 12 | (t[r++] & 63) << 6 | t[r++] & 63) : n += String.fromCharCode(i);
1012
- }
1013
- };
1014
- function Tr(t, n) {
1015
- if (n) {
1016
- for (var r = "", i = 0; i < t.length; i += 16384)
1017
- r += String.fromCharCode.apply(null, t.subarray(i, i + 16384));
1018
- return r;
1019
- } else {
1020
- if (Je)
1021
- return Je.decode(t);
1022
- var u = kr(t), d = u.s, r = u.r;
1023
- return r.length && O(8), d;
1024
- }
1025
- }
1026
- var Er = function(t, n) {
1027
- return n + 30 + D(t, n + 26) + D(t, n + 28);
1028
- }, Ir = function(t, n, r) {
1029
- var i = D(t, n + 28), u = Tr(t.subarray(n + 46, n + 46 + i), !(D(t, n + 8) & 2048)), d = n + 46 + i, _ = N(t, n + 20), p = r && _ == 4294967295 ? Cr(t, d) : [_, N(t, n + 24), N(t, n + 42)], h = p[0], A = p[1], m = p[2];
1030
- return [D(t, n + 10), h, A, u, d + D(t, n + 30) + D(t, n + 32), m];
1031
- }, Cr = function(t, n) {
1032
- for (; D(t, n) != 1; n += 4 + D(t, n + 2))
1033
- ;
1034
- return [Be(t, n + 12), Be(t, n + 4), Be(t, n + 20)];
1035
- }, wt = typeof queueMicrotask == "function" ? queueMicrotask : typeof setTimeout == "function" ? setTimeout : function(t) {
1036
- t();
1037
- };
1038
- function Or(t, n, r) {
1039
- r || (r = n, n = {}), typeof r != "function" && O(7);
1040
- var i = [], u = function() {
1041
- for (var l = 0; l < i.length; ++l)
1042
- i[l]();
1043
- }, d = {}, _ = function(l, f) {
1044
- wt(function() {
1045
- r(l, f);
1046
- });
1047
- };
1048
- wt(function() {
1049
- _ = r;
1050
- });
1051
- for (var p = t.length - 22; N(t, p) != 101010256; --p)
1052
- if (!p || t.length - p > 65558)
1053
- return _(O(13, 0, 1), null), u;
1054
- var h = D(t, p + 8);
1055
- if (h) {
1056
- var A = h, m = N(t, p + 16), e = m == 4294967295 || A == 65535;
1057
- if (e) {
1058
- var a = N(t, p - 12);
1059
- e = N(t, a) == 101075792, e && (A = h = N(t, a + 32), m = N(t, a + 48));
1060
- }
1061
- for (var o = n && n.filter, s = function(l) {
1062
- var f = Ir(t, m, e), v = f[0], g = f[1], S = f[2], C = f[3], L = f[4], K = f[5], M = Er(t, K);
1063
- m = L;
1064
- var b = function(E, W) {
1065
- E ? (u(), _(E, null)) : (W && (d[C] = W), --h || _(null, d));
1066
- };
1067
- if (!o || o({
1068
- name: C,
1069
- size: g,
1070
- originalSize: S,
1071
- compression: v
1072
- }))
1073
- if (!v)
1074
- b(null, Oe(t, M, M + g));
1075
- else if (v == 8) {
1076
- var U = t.subarray(M, M + g);
1077
- if (S < 524288 || g > 0.8 * S)
1078
- try {
1079
- b(null, ot(U, { out: new P(S) }));
1080
- } catch (E) {
1081
- b(E, null);
1082
- }
1083
- else
1084
- i.push(Sr(U, { size: S }, b));
1085
- } else
1086
- b(O(14, "unknown compression type " + v, 1), null);
1087
- else
1088
- b(null, null);
1089
- }, c = 0; c < A; ++c)
1090
- s(c);
1091
- } else
1092
- _(null, {});
1093
- return u;
1094
- }
1095
- let sn = () => {
937
+ qt.decode(Wt, { stream: !0 });
938
+ } catch {}
939
+ var Jt = function(e) {
940
+ for (var t = "", n = 0;;) {
941
+ var r = e[n++], i = (r > 127) + (r > 223) + (r > 239);
942
+ if (n + i > e.length) return {
943
+ s: t,
944
+ r: Vt(e, n - 1)
945
+ };
946
+ i ? i == 3 ? (r = ((r & 15) << 18 | (e[n++] & 63) << 12 | (e[n++] & 63) << 6 | e[n++] & 63) - 65536, t += String.fromCharCode(55296 | r >> 10, 56320 | r & 1023)) : i & 1 ? t += String.fromCharCode((r & 31) << 6 | e[n++] & 63) : t += String.fromCharCode((r & 15) << 12 | (e[n++] & 63) << 6 | e[n++] & 63) : t += String.fromCharCode(r);
947
+ }
1096
948
  };
1097
- async function Pr(t) {
1098
- const n = await un(t);
1099
- return new TextDecoder("utf-8").decode(n);
1100
- }
1101
- async function $r(t) {
1102
- return new Promise((n, r) => {
1103
- const i = document.createElement("script");
1104
- i.src = t, i.addEventListener("load", n), i.addEventListener("error", r), document.body.append(i);
1105
- });
1106
- }
1107
- async function Lr(t) {
1108
- let n = "";
1109
- try {
1110
- await $r(t);
1111
- } catch (r) {
1112
- throw console.error(r), Error(`Failed to fetch file: ${t}`);
1113
- }
1114
- try {
1115
- n = JSON.stringify(window.storyContent);
1116
- } catch (r) {
1117
- throw console.error(r), Error(`Failed to parse Ink script: ${t}`);
1118
- }
1119
- return n;
1120
- }
1121
- async function un(t) {
1122
- const n = await fetch(t, { responseType: "arraybuffer" });
1123
- if (!n.ok) {
1124
- const h = await n.text();
1125
- throw new Error(`Failed to fetch file: ${t}. Error ${n.status} ${h}`);
1126
- }
1127
- const r = n.body.getReader(), i = +n.headers.get("Content-Length"), u = [];
1128
- let d = 0;
1129
- for (; ; ) {
1130
- const { done: h, value: A } = await r.read();
1131
- if (h)
1132
- break;
1133
- u.push(A), d += A.length;
1134
- const m = Math.round(d * 100 / i);
1135
- sn({ percent: m, receivedLength: d, contentLength: i });
1136
- }
1137
- const _ = new Uint8Array(d);
1138
- let p = 0;
1139
- return u.forEach((h) => {
1140
- _.set(h, p), p += h.length;
1141
- }), _;
1142
- }
1143
- function Fr(t) {
1144
- sn = t;
1145
- }
1146
- let qe = "plain", fn = "", We = {};
1147
- async function Mr(t) {
1148
- if (t.endsWith(".zip") && (qe = "zip"), qe === "zip") {
1149
- We = {};
1150
- const n = await un(t);
1151
- await Or(
1152
- n,
1153
- (r, i) => Object.entries(i).forEach(([u, d]) => {
1154
- We[u] = URL.createObjectURL(new Blob([d]));
1155
- })
1156
- );
1157
- } else
1158
- fn = t;
1159
- }
1160
- function cn(t) {
1161
- if (!t)
1162
- return null;
1163
- const n = `${t}`;
1164
- return n.startsWith("http://") || n.startsWith("https://") ? n : qe === "zip" ? We[n] : `${fn}/${n}`;
1165
- }
1166
- async function Br(t) {
1167
- const n = cn(t);
1168
- return await (n.endsWith("js") ? Lr(n) : Pr(n));
1169
- }
1170
- const Nr = {
1171
- init: Mr,
1172
- getAssetPath: cn,
1173
- loadInk: Br,
1174
- onProgress: Fr
949
+ function Yt(e, t) {
950
+ if (t) {
951
+ for (var n = "", r = 0; r < e.length; r += 16384) n += String.fromCharCode.apply(null, e.subarray(r, r + 16384));
952
+ return n;
953
+ }
954
+ if (qt) return qt.decode(e);
955
+ var i = Jt(e), a = i.s, n = i.r;
956
+ return n.length && G(8), a;
957
+ }
958
+ var Xt = function(e, t) {
959
+ return t + 30 + K(e, t + 26) + K(e, t + 28);
960
+ }, Zt = function(e, t, n) {
961
+ var r = K(e, t + 28), i = K(e, t + 30), a = Yt(e.subarray(t + 46, t + 46 + r), !(K(e, t + 8) & 2048)), o = t + 46 + r, s = Qt(e, o, i, n, q(e, t + 20), q(e, t + 24), q(e, t + 42)), c = s[0], l = s[1], u = s[2];
962
+ return [
963
+ K(e, t + 10),
964
+ c,
965
+ l,
966
+ a,
967
+ o + i + K(e, t + 32),
968
+ u
969
+ ];
970
+ }, Qt = function(e, t, n, r, i, a, o) {
971
+ var s = i == 4294967295, c = a == 4294967295, l = o == 4294967295, u = t + n, d = s + c + l;
972
+ if (r && d) {
973
+ for (; t + 4 < u; t += 4 + K(e, t + 2)) if (K(e, t) == 1) return [
974
+ s ? Gt(e, t + 4 + 8 * c) : i,
975
+ c ? Gt(e, t + 4) : a,
976
+ l ? Gt(e, t + 4 + 8 * (c + s)) : o,
977
+ 1
978
+ ];
979
+ r < 2 && G(13);
980
+ }
981
+ return [
982
+ i,
983
+ a,
984
+ o,
985
+ 0
986
+ ];
1175
987
  };
1176
- function ne(t) {
1177
- return new Promise((n, r) => {
1178
- t.oncomplete = t.onsuccess = () => n(t.result), t.onabort = t.onerror = () => r(t.error);
1179
- });
1180
- }
1181
- function ln(t, n) {
1182
- let r;
1183
- const i = () => {
1184
- if (r)
1185
- return r;
1186
- const u = indexedDB.open(t);
1187
- return u.onupgradeneeded = () => u.result.createObjectStore(n), r = ne(u), r.then((d) => {
1188
- d.onclose = () => r = void 0;
1189
- }, () => {
1190
- }), r;
1191
- };
1192
- return (u, d) => i().then((_) => d(_.transaction(n, u).objectStore(n)));
1193
- }
1194
- let Ne;
1195
- function Pe() {
1196
- return Ne || (Ne = ln("keyval-store", "keyval")), Ne;
1197
- }
1198
- function dn(t, n = Pe()) {
1199
- return n("readonly", (r) => ne(r.get(t)));
1200
- }
1201
- function Dr(t, n, r = Pe()) {
1202
- return r("readwrite", (i) => (i.put(n, t), ne(i.transaction)));
1203
- }
1204
- function Kr(t, n = Pe()) {
1205
- return n("readwrite", (r) => (r.delete(t), ne(r.transaction)));
1206
- }
1207
- function Ur(t, n) {
1208
- return t.openCursor().onsuccess = function() {
1209
- this.result && (n(this.result), this.result.continue());
1210
- }, ne(t.transaction);
1211
- }
1212
- function Rr(t = Pe()) {
1213
- return t("readonly", (n) => {
1214
- if (n.getAllKeys)
1215
- return ne(n.getAllKeys());
1216
- const r = [];
1217
- return Ur(n, (i) => r.push(i.key)).then(() => r);
1218
- });
1219
- }
1220
- let re;
1221
- function Vr(t) {
1222
- re = ln(t, "keyvaluepairs");
1223
- }
1224
- async function Gr(t) {
1225
- return await dn(t, re) !== void 0;
1226
- }
1227
- async function Hr(t) {
1228
- return await dn(t, re);
1229
- }
1230
- async function Jr(t, n) {
1231
- await Dr(t, n, re);
1232
- }
1233
- async function qr(t) {
1234
- await Kr(t, re);
1235
- }
1236
- async function Wr() {
1237
- return await Rr(re);
1238
- }
1239
- const jr = {
1240
- init: Vr,
1241
- exists: Gr,
1242
- get: Hr,
1243
- set: Jr,
1244
- remove: qr,
1245
- keys: Wr
988
+ function $t(e, t) {
989
+ for (var n = {}, r = e.length - 22; q(e, r) != 101010256; --r) (!r || e.length - r > 65558) && G(13);
990
+ var i = K(e, r + 8);
991
+ if (!i) return {};
992
+ var a = q(e, r + 16), o = q(e, r - 20) == 117853008;
993
+ if (o) {
994
+ var s = q(e, r - 12);
995
+ o = q(e, s) == 101075792, o && (i = q(e, s + 32), a = q(e, s + 48));
996
+ }
997
+ for (var c = t && t.filter, l = 0; l < i; ++l) {
998
+ var u = Zt(e, a, o), d = u[0], f = u[1], p = u[2], m = u[3], h = u[4], g = u[5], _ = Xt(e, g);
999
+ a = h, (!c || c({
1000
+ name: m,
1001
+ size: f,
1002
+ originalSize: p,
1003
+ compression: d
1004
+ })) && (d ? d == 8 ? n[m] = Kt(e.subarray(_, _ + f), { out: new z(p) }) : G(14, "unknown compression type " + d) : n[m] = Vt(e, _, _ + f));
1005
+ }
1006
+ return n;
1007
+ }
1008
+ // src/interfaces/loader-common.js
1009
+ var en = () => {};
1010
+ async function tn(e) {
1011
+ let t = await an(e);
1012
+ return new TextDecoder("utf-8").decode(t);
1013
+ }
1014
+ async function nn(e) {
1015
+ return new Promise((t, n) => {
1016
+ let r = document.createElement("script");
1017
+ r.src = e, r.addEventListener("load", () => t(r)), r.addEventListener("error", (e) => {
1018
+ r.remove(), n(e);
1019
+ }), document.body.append(r);
1020
+ });
1021
+ }
1022
+ async function rn(e) {
1023
+ delete window.storyContent;
1024
+ let t;
1025
+ try {
1026
+ t = await nn(e);
1027
+ } catch (t) {
1028
+ throw console.error(t), Error(`Failed to fetch file: ${e}`);
1029
+ }
1030
+ t.remove();
1031
+ let { storyContent: n } = window;
1032
+ if (delete window.storyContent, n === void 0) throw Error(`Ink script does not define storyContent: ${e}`);
1033
+ try {
1034
+ return JSON.stringify(n);
1035
+ } catch (t) {
1036
+ throw console.error(t), Error(`Failed to parse Ink script: ${e}`);
1037
+ }
1038
+ }
1039
+ async function an(e) {
1040
+ let t = await fetch(e, { responseType: "arraybuffer" });
1041
+ if (!t.ok) {
1042
+ let n = await t.text();
1043
+ throw Error(`Failed to fetch file: ${e}. Error ${t.status} ${n}`);
1044
+ }
1045
+ let n = t.body.getReader(), r = Number(t.headers.get("Content-Length")), i = Number.isFinite(r) && r > 0 ? r : null, a = [], o = 0;
1046
+ for (;;) {
1047
+ let { done: e, value: t } = await n.read();
1048
+ if (e) break;
1049
+ a.push(t), o += t.length;
1050
+ let r = i === null ? null : Math.min(100, Math.round(o * 100 / i));
1051
+ en({
1052
+ percent: r,
1053
+ receivedLength: o,
1054
+ contentLength: i
1055
+ });
1056
+ }
1057
+ let s = new Uint8Array(o), c = 0;
1058
+ return a.forEach((e) => {
1059
+ s.set(e, c), c += e.length;
1060
+ }), s;
1061
+ }
1062
+ function on(e) {
1063
+ en = e;
1064
+ }
1065
+ // src/interfaces/loader-web-fflate.js
1066
+ var sn = "plain", cn = "", ln = {}, un = [], dn = {
1067
+ svg: "image/svg+xml",
1068
+ css: "text/css"
1246
1069
  };
1247
- var se = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
1248
- function zr(t) {
1249
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
1250
- }
1251
- var ue = { exports: {} }, De = { exports: {} }, bt;
1252
- function Qr() {
1253
- return bt || (bt = 1, (function(t) {
1254
- function n(r, i) {
1255
- var u, d, _, p, h, A, m, e;
1256
- for (u = r.length & 3, d = r.length - u, _ = i, h = 3432918353, A = 461845907, e = 0; e < d; )
1257
- m = r.charCodeAt(e) & 255 | (r.charCodeAt(++e) & 255) << 8 | (r.charCodeAt(++e) & 255) << 16 | (r.charCodeAt(++e) & 255) << 24, ++e, m = (m & 65535) * h + (((m >>> 16) * h & 65535) << 16) & 4294967295, m = m << 15 | m >>> 17, m = (m & 65535) * A + (((m >>> 16) * A & 65535) << 16) & 4294967295, _ ^= m, _ = _ << 13 | _ >>> 19, p = (_ & 65535) * 5 + (((_ >>> 16) * 5 & 65535) << 16) & 4294967295, _ = (p & 65535) + 27492 + (((p >>> 16) + 58964 & 65535) << 16);
1258
- switch (m = 0, u) {
1259
- case 3:
1260
- m ^= (r.charCodeAt(e + 2) & 255) << 16;
1261
- case 2:
1262
- m ^= (r.charCodeAt(e + 1) & 255) << 8;
1263
- case 1:
1264
- m ^= r.charCodeAt(e) & 255, m = (m & 65535) * h + (((m >>> 16) * h & 65535) << 16) & 4294967295, m = m << 15 | m >>> 17, m = (m & 65535) * A + (((m >>> 16) * A & 65535) << 16) & 4294967295, _ ^= m;
1265
- }
1266
- return _ ^= r.length, _ ^= _ >>> 16, _ = (_ & 65535) * 2246822507 + (((_ >>> 16) * 2246822507 & 65535) << 16) & 4294967295, _ ^= _ >>> 13, _ = (_ & 65535) * 3266489909 + (((_ >>> 16) * 3266489909 & 65535) << 16) & 4294967295, _ ^= _ >>> 16, _ >>> 0;
1267
- }
1268
- t.exports = n;
1269
- })(De)), De.exports;
1270
- }
1271
- var Ke = { exports: {} }, At;
1272
- function Yr() {
1273
- return At || (At = 1, (function(t) {
1274
- function n(r, i) {
1275
- for (var u = r.length, d = i ^ u, _ = 0, p; u >= 4; )
1276
- p = r.charCodeAt(_) & 255 | (r.charCodeAt(++_) & 255) << 8 | (r.charCodeAt(++_) & 255) << 16 | (r.charCodeAt(++_) & 255) << 24, p = (p & 65535) * 1540483477 + (((p >>> 16) * 1540483477 & 65535) << 16), p ^= p >>> 24, p = (p & 65535) * 1540483477 + (((p >>> 16) * 1540483477 & 65535) << 16), d = (d & 65535) * 1540483477 + (((d >>> 16) * 1540483477 & 65535) << 16) ^ p, u -= 4, ++_;
1277
- switch (u) {
1278
- case 3:
1279
- d ^= (r.charCodeAt(_ + 2) & 255) << 16;
1280
- case 2:
1281
- d ^= (r.charCodeAt(_ + 1) & 255) << 8;
1282
- case 1:
1283
- d ^= r.charCodeAt(_) & 255, d = (d & 65535) * 1540483477 + (((d >>> 16) * 1540483477 & 65535) << 16);
1284
- }
1285
- return d ^= d >>> 13, d = (d & 65535) * 1540483477 + (((d >>> 16) * 1540483477 & 65535) << 16), d ^= d >>> 15, d >>> 0;
1286
- }
1287
- t.exports = n;
1288
- })(Ke)), Ke.exports;
1289
- }
1290
- var St;
1291
- function Xr() {
1292
- if (St) return ue.exports;
1293
- St = 1;
1294
- var t = Qr(), n = Yr();
1295
- return ue.exports = t, ue.exports.murmur3 = t, ue.exports.murmur2 = n, ue.exports;
1296
- }
1297
- var Zr = Xr();
1298
- const ea = /* @__PURE__ */ zr(Zr), te = "__atrament_storage";
1299
- let Z = Promise.resolve();
1300
- async function de(t) {
1301
- try {
1302
- const n = await window.Neutralino.storage.getData(t);
1303
- return JSON.parse(n);
1304
- } catch (n) {
1305
- return console.warn(n.message), null;
1306
- }
1307
- }
1308
- async function it(t, n) {
1309
- const r = JSON.stringify(n);
1310
- return await window.Neutralino.storage.setData(t, r), r;
1311
- }
1312
- async function ta(t) {
1313
- return await window.Neutralino.storage.setData(t, null), !0;
1314
- }
1315
- function st(t) {
1316
- return `storage_${ea(t)}`;
1317
- }
1318
- async function na(t, n) {
1319
- return Z = Z.then(async () => {
1320
- let r = await de(te);
1321
- r === null && (r = {}), r[n] = t, await it(te, r);
1322
- }).catch((r) => console.error(r.message)), Z;
1323
- }
1324
- async function ra(t) {
1325
- return Z = Z.then(async () => {
1326
- let n = await de(te);
1327
- n === null && (n = {}), delete n[t], await it(te, n);
1328
- }).catch((n) => console.error(n.message)), Z;
1329
- }
1330
- function aa() {
1331
- }
1332
- async function oa(t) {
1333
- return (await _n()).includes(t);
1334
- }
1335
- async function ia(t) {
1336
- const n = await de(te), r = n === null ? st(t) : n[t];
1337
- return await de(r);
1338
- }
1339
- async function sa(t, n) {
1340
- const r = st(t);
1341
- try {
1342
- await it(r, n), await na(r, t);
1343
- } catch (i) {
1344
- console.error(i.message);
1345
- }
1346
- }
1347
- async function ua(t) {
1348
- const n = st(t);
1349
- try {
1350
- await ta(n), await ra(t);
1351
- } catch (r) {
1352
- console.error(r.message);
1353
- }
1354
- }
1355
- async function _n() {
1356
- const t = await de(te);
1357
- return t === null ? [] : Object.keys(t);
1358
- }
1359
- const fa = {
1360
- init: aa,
1361
- exists: oa,
1362
- get: ia,
1363
- set: sa,
1364
- remove: ua,
1365
- keys: _n
1070
+ function fn(e) {
1071
+ let t = /\.([^./]+)$/.exec(e);
1072
+ return t ? t[1].toLowerCase() : "";
1073
+ }
1074
+ function pn(e) {
1075
+ return `${e}`.replace(/\\/g, "/").replace(/^(\.?\/)+/, "");
1076
+ }
1077
+ function mn() {
1078
+ un.forEach((e) => URL.revokeObjectURL(e)), un = [];
1079
+ }
1080
+ async function hn(e) {
1081
+ if (sn = e.endsWith(".zip") ? "zip" : "plain", cn = "", mn(), ln = {}, sn === "zip") {
1082
+ let t = $t(await an(e));
1083
+ Object.entries(t).forEach(([e, t]) => {
1084
+ let n = pn(e);
1085
+ if (!n || n.endsWith("/")) return;
1086
+ let r = fn(n), i = dn[r] || "", a = URL.createObjectURL(new Blob([t], { type: i }));
1087
+ un.push(a), ln[n] = r ? `${a}#file.${r}` : a;
1088
+ });
1089
+ } else cn = e;
1090
+ }
1091
+ function gn(e) {
1092
+ if (!e) return null;
1093
+ let t = `${e}`;
1094
+ return t.startsWith("http://") || t.startsWith("https://") ? t : sn === "zip" ? ln[pn(t)] ?? null : `${cn}/${t}`;
1095
+ }
1096
+ async function _n(e) {
1097
+ let t = gn(e);
1098
+ if (!t) throw Error(`Ink story file not found: ${e}`);
1099
+ return await (e.endsWith(".js") ? rn(t) : tn(t));
1100
+ }
1101
+ var vn = {
1102
+ init: hn,
1103
+ getAssetPath: gn,
1104
+ loadInk: _n,
1105
+ onProgress: on
1106
+ }, yn;
1107
+ function bn(e) {
1108
+ yn = e;
1109
+ }
1110
+ function xn(e) {
1111
+ return `${yn}:${e}`;
1112
+ }
1113
+ async function Sn(e) {
1114
+ return localStorage.getItem(xn(e)) !== null;
1115
+ }
1116
+ async function Cn(e) {
1117
+ let t = localStorage.getItem(xn(e));
1118
+ return t === null ? void 0 : JSON.parse(t);
1119
+ }
1120
+ async function wn(e, t) {
1121
+ localStorage.setItem(xn(e), JSON.stringify(t));
1122
+ }
1123
+ async function Tn(e) {
1124
+ localStorage.removeItem(xn(e));
1125
+ }
1126
+ async function En() {
1127
+ let e = `${yn}:`, t = [];
1128
+ for (let n = 0; n < localStorage.length; n += 1) {
1129
+ let r = localStorage.key(n);
1130
+ r.startsWith(e) && t.push(r.slice(e.length));
1131
+ }
1132
+ return t;
1133
+ }
1134
+ var Dn = {
1135
+ driver: "localstorage",
1136
+ init: bn,
1137
+ exists: Sn,
1138
+ get: Cn,
1139
+ set: wn,
1140
+ remove: Tn,
1141
+ keys: En
1366
1142
  };
1367
- var Ue = {};
1368
- var xt;
1369
- function ca() {
1370
- return xt || (xt = 1, (function(t) {
1371
- (function() {
1372
- var n = function() {
1373
- this.init();
1374
- };
1375
- n.prototype = {
1376
- /**
1377
- * Initialize the global Howler object.
1378
- * @return {Howler}
1379
- */
1380
- init: function() {
1381
- var e = this || r;
1382
- 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;
1383
- },
1384
- /**
1385
- * Get/set the global volume for all sounds.
1386
- * @param {Float} vol Volume from 0.0 to 1.0.
1387
- * @return {Howler/Float} Returns self or current volume.
1388
- */
1389
- volume: function(e) {
1390
- var a = this || r;
1391
- if (e = parseFloat(e), a.ctx || m(), typeof e < "u" && e >= 0 && e <= 1) {
1392
- if (a._volume = e, a._muted)
1393
- return a;
1394
- a.usingWebAudio && a.masterGain.gain.setValueAtTime(e, r.ctx.currentTime);
1395
- for (var o = 0; o < a._howls.length; o++)
1396
- if (!a._howls[o]._webAudio)
1397
- for (var s = a._howls[o]._getSoundIds(), c = 0; c < s.length; c++) {
1398
- var l = a._howls[o]._soundById(s[c]);
1399
- l && l._node && (l._node.volume = l._volume * e);
1400
- }
1401
- return a;
1402
- }
1403
- return a._volume;
1404
- },
1405
- /**
1406
- * Handle muting and unmuting globally.
1407
- * @param {Boolean} muted Is muted or not.
1408
- */
1409
- mute: function(e) {
1410
- var a = this || r;
1411
- a.ctx || m(), a._muted = e, a.usingWebAudio && a.masterGain.gain.setValueAtTime(e ? 0 : a._volume, r.ctx.currentTime);
1412
- for (var o = 0; o < a._howls.length; o++)
1413
- if (!a._howls[o]._webAudio)
1414
- for (var s = a._howls[o]._getSoundIds(), c = 0; c < s.length; c++) {
1415
- var l = a._howls[o]._soundById(s[c]);
1416
- l && l._node && (l._node.muted = e ? !0 : l._muted);
1417
- }
1418
- return a;
1419
- },
1420
- /**
1421
- * Handle stopping all sounds globally.
1422
- */
1423
- stop: function() {
1424
- for (var e = this || r, a = 0; a < e._howls.length; a++)
1425
- e._howls[a].stop();
1426
- return e;
1427
- },
1428
- /**
1429
- * Unload and destroy all currently loaded Howl objects.
1430
- * @return {Howler}
1431
- */
1432
- unload: function() {
1433
- for (var e = this || r, a = e._howls.length - 1; a >= 0; a--)
1434
- e._howls[a].unload();
1435
- return e.usingWebAudio && e.ctx && typeof e.ctx.close < "u" && (e.ctx.close(), e.ctx = null, m()), e;
1436
- },
1437
- /**
1438
- * Check for codec support of specific extension.
1439
- * @param {String} ext Audio file extention.
1440
- * @return {Boolean}
1441
- */
1442
- codecs: function(e) {
1443
- return (this || r)._codecs[e.replace(/^x-/, "")];
1444
- },
1445
- /**
1446
- * Setup various state values for global tracking.
1447
- * @return {Howler}
1448
- */
1449
- _setup: function() {
1450
- var e = this || r;
1451
- if (e.state = e.ctx && e.ctx.state || "suspended", e._autoSuspend(), !e.usingWebAudio)
1452
- if (typeof Audio < "u")
1453
- try {
1454
- var a = new Audio();
1455
- typeof a.oncanplaythrough > "u" && (e._canPlayEvent = "canplay");
1456
- } catch {
1457
- e.noAudio = !0;
1458
- }
1459
- else
1460
- e.noAudio = !0;
1461
- try {
1462
- var a = new Audio();
1463
- a.muted && (e.noAudio = !0);
1464
- } catch {
1465
- }
1466
- return e.noAudio || e._setupCodecs(), e;
1467
- },
1468
- /**
1469
- * Check for browser support for various codecs and cache the results.
1470
- * @return {Howler}
1471
- */
1472
- _setupCodecs: function() {
1473
- var e = this || r, a = null;
1474
- try {
1475
- a = typeof Audio < "u" ? new Audio() : null;
1476
- } catch {
1477
- return e;
1478
- }
1479
- if (!a || typeof a.canPlayType != "function")
1480
- return e;
1481
- var o = a.canPlayType("audio/mpeg;").replace(/^no$/, ""), s = e._navigator ? e._navigator.userAgent : "", c = s.match(/OPR\/(\d+)/g), l = c && parseInt(c[0].split("/")[1], 10) < 33, f = s.indexOf("Safari") !== -1 && s.indexOf("Chrome") === -1, v = s.match(/Version\/(.*?) /), g = f && v && parseInt(v[1], 10) < 15;
1482
- return e._codecs = {
1483
- mp3: !!(!l && (o || a.canPlayType("audio/mp3;").replace(/^no$/, ""))),
1484
- mpeg: !!o,
1485
- opus: !!a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/, ""),
1486
- ogg: !!a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""),
1487
- oga: !!a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""),
1488
- wav: !!(a.canPlayType('audio/wav; codecs="1"') || a.canPlayType("audio/wav")).replace(/^no$/, ""),
1489
- aac: !!a.canPlayType("audio/aac;").replace(/^no$/, ""),
1490
- caf: !!a.canPlayType("audio/x-caf;").replace(/^no$/, ""),
1491
- m4a: !!(a.canPlayType("audio/x-m4a;") || a.canPlayType("audio/m4a;") || a.canPlayType("audio/aac;")).replace(/^no$/, ""),
1492
- m4b: !!(a.canPlayType("audio/x-m4b;") || a.canPlayType("audio/m4b;") || a.canPlayType("audio/aac;")).replace(/^no$/, ""),
1493
- mp4: !!(a.canPlayType("audio/x-mp4;") || a.canPlayType("audio/mp4;") || a.canPlayType("audio/aac;")).replace(/^no$/, ""),
1494
- weba: !!(!g && a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "")),
1495
- webm: !!(!g && a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/, "")),
1496
- dolby: !!a.canPlayType('audio/mp4; codecs="ec-3"').replace(/^no$/, ""),
1497
- flac: !!(a.canPlayType("audio/x-flac;") || a.canPlayType("audio/flac;")).replace(/^no$/, "")
1498
- }, e;
1499
- },
1500
- /**
1501
- * Some browsers/devices will only allow audio to be played after a user interaction.
1502
- * Attempt to automatically unlock audio on the first user interaction.
1503
- * Concept from: http://paulbakaus.com/tutorials/html5/web-audio-on-ios/
1504
- * @return {Howler}
1505
- */
1506
- _unlockAudio: function() {
1507
- var e = this || r;
1508
- if (!(e._audioUnlocked || !e.ctx)) {
1509
- 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);
1510
- var a = function(o) {
1511
- for (; e._html5AudioPool.length < e.html5PoolSize; )
1512
- try {
1513
- var s = new Audio();
1514
- s._unlocked = !0, e._releaseHtml5Audio(s);
1515
- } catch {
1516
- e.noAudio = !0;
1517
- break;
1518
- }
1519
- for (var c = 0; c < e._howls.length; c++)
1520
- if (!e._howls[c]._webAudio)
1521
- for (var l = e._howls[c]._getSoundIds(), f = 0; f < l.length; f++) {
1522
- var v = e._howls[c]._soundById(l[f]);
1523
- v && v._node && !v._node._unlocked && (v._node._unlocked = !0, v._node.load());
1524
- }
1525
- e._autoResume();
1526
- var g = e.ctx.createBufferSource();
1527
- g.buffer = e._scratchBuffer, g.connect(e.ctx.destination), typeof g.start > "u" ? g.noteOn(0) : g.start(0), typeof e.ctx.resume == "function" && e.ctx.resume(), g.onended = function() {
1528
- g.disconnect(0), e._audioUnlocked = !0, document.removeEventListener("touchstart", a, !0), document.removeEventListener("touchend", a, !0), document.removeEventListener("click", a, !0), document.removeEventListener("keydown", a, !0);
1529
- for (var S = 0; S < e._howls.length; S++)
1530
- e._howls[S]._emit("unlock");
1531
- };
1532
- };
1533
- return document.addEventListener("touchstart", a, !0), document.addEventListener("touchend", a, !0), document.addEventListener("click", a, !0), document.addEventListener("keydown", a, !0), e;
1534
- }
1535
- },
1536
- /**
1537
- * Get an unlocked HTML5 Audio object from the pool. If none are left,
1538
- * return a new Audio object and throw a warning.
1539
- * @return {Audio} HTML5 Audio object.
1540
- */
1541
- _obtainHtml5Audio: function() {
1542
- var e = this || r;
1543
- if (e._html5AudioPool.length)
1544
- return e._html5AudioPool.pop();
1545
- var a = new Audio().play();
1546
- return a && typeof Promise < "u" && (a instanceof Promise || typeof a.then == "function") && a.catch(function() {
1547
- console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.");
1548
- }), new Audio();
1549
- },
1550
- /**
1551
- * Return an activated HTML5 Audio object to the pool.
1552
- * @return {Howler}
1553
- */
1554
- _releaseHtml5Audio: function(e) {
1555
- var a = this || r;
1556
- return e._unlocked && a._html5AudioPool.push(e), a;
1557
- },
1558
- /**
1559
- * Automatically suspend the Web Audio AudioContext after no sound has played for 30 seconds.
1560
- * This saves processing/energy and fixes various browser-specific bugs with audio getting stuck.
1561
- * @return {Howler}
1562
- */
1563
- _autoSuspend: function() {
1564
- var e = this;
1565
- if (!(!e.autoSuspend || !e.ctx || typeof e.ctx.suspend > "u" || !r.usingWebAudio)) {
1566
- for (var a = 0; a < e._howls.length; a++)
1567
- if (e._howls[a]._webAudio) {
1568
- for (var o = 0; o < e._howls[a]._sounds.length; o++)
1569
- if (!e._howls[a]._sounds[o]._paused)
1570
- return e;
1571
- }
1572
- return e._suspendTimer && clearTimeout(e._suspendTimer), e._suspendTimer = setTimeout(function() {
1573
- if (e.autoSuspend) {
1574
- e._suspendTimer = null, e.state = "suspending";
1575
- var s = function() {
1576
- e.state = "suspended", e._resumeAfterSuspend && (delete e._resumeAfterSuspend, e._autoResume());
1577
- };
1578
- e.ctx.suspend().then(s, s);
1579
- }
1580
- }, 3e4), e;
1581
- }
1582
- },
1583
- /**
1584
- * Automatically resume the Web Audio AudioContext when a new sound is played.
1585
- * @return {Howler}
1586
- */
1587
- _autoResume: function() {
1588
- var e = this;
1589
- if (!(!e.ctx || typeof e.ctx.resume > "u" || !r.usingWebAudio))
1590
- 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() {
1591
- e.state = "running";
1592
- for (var a = 0; a < e._howls.length; a++)
1593
- e._howls[a]._emit("resume");
1594
- }), e._suspendTimer && (clearTimeout(e._suspendTimer), e._suspendTimer = null)) : e.state === "suspending" && (e._resumeAfterSuspend = !0), e;
1595
- }
1596
- };
1597
- var r = new n(), i = function(e) {
1598
- var a = this;
1599
- if (!e.src || e.src.length === 0) {
1600
- console.error("An array of source files must be passed with any new Howl.");
1601
- return;
1602
- }
1603
- a.init(e);
1604
- };
1605
- i.prototype = {
1606
- /**
1607
- * Initialize a new Howl group object.
1608
- * @param {Object} o Passed in properties for this group.
1609
- * @return {Howl}
1610
- */
1611
- init: function(e) {
1612
- var a = this;
1613
- return r.ctx || m(), a._autoplay = e.autoplay || !1, a._format = typeof e.format != "string" ? e.format : [e.format], a._html5 = e.html5 || !1, a._muted = e.mute || !1, a._loop = e.loop || !1, a._pool = e.pool || 5, a._preload = typeof e.preload == "boolean" || e.preload === "metadata" ? e.preload : !0, a._rate = e.rate || 1, a._sprite = e.sprite || {}, a._src = typeof e.src != "string" ? e.src : [e.src], a._volume = e.volume !== void 0 ? e.volume : 1, a._xhr = {
1614
- method: e.xhr && e.xhr.method ? e.xhr.method : "GET",
1615
- headers: e.xhr && e.xhr.headers ? e.xhr.headers : null,
1616
- withCredentials: e.xhr && e.xhr.withCredentials ? e.xhr.withCredentials : !1
1617
- }, a._duration = 0, a._state = "unloaded", a._sounds = [], a._endTimers = {}, a._queue = [], a._playLock = !1, a._onend = e.onend ? [{ fn: e.onend }] : [], a._onfade = e.onfade ? [{ fn: e.onfade }] : [], a._onload = e.onload ? [{ fn: e.onload }] : [], a._onloaderror = e.onloaderror ? [{ fn: e.onloaderror }] : [], a._onplayerror = e.onplayerror ? [{ fn: e.onplayerror }] : [], a._onpause = e.onpause ? [{ fn: e.onpause }] : [], a._onplay = e.onplay ? [{ fn: e.onplay }] : [], a._onstop = e.onstop ? [{ fn: e.onstop }] : [], a._onmute = e.onmute ? [{ fn: e.onmute }] : [], a._onvolume = e.onvolume ? [{ fn: e.onvolume }] : [], a._onrate = e.onrate ? [{ fn: e.onrate }] : [], a._onseek = e.onseek ? [{ fn: e.onseek }] : [], a._onunlock = e.onunlock ? [{ fn: e.onunlock }] : [], a._onresume = [], a._webAudio = r.usingWebAudio && !a._html5, typeof r.ctx < "u" && r.ctx && r.autoUnlock && r._unlockAudio(), r._howls.push(a), a._autoplay && a._queue.push({
1618
- event: "play",
1619
- action: function() {
1620
- a.play();
1621
- }
1622
- }), a._preload && a._preload !== "none" && a.load(), a;
1623
- },
1624
- /**
1625
- * Load the audio file.
1626
- * @return {Howler}
1627
- */
1628
- load: function() {
1629
- var e = this, a = null;
1630
- if (r.noAudio) {
1631
- e._emit("loaderror", null, "No audio support.");
1632
- return;
1633
- }
1634
- typeof e._src == "string" && (e._src = [e._src]);
1635
- for (var o = 0; o < e._src.length; o++) {
1636
- var s, c;
1637
- if (e._format && e._format[o])
1638
- s = e._format[o];
1639
- else {
1640
- if (c = e._src[o], typeof c != "string") {
1641
- e._emit("loaderror", null, "Non-string found in selected audio sources - ignoring.");
1642
- continue;
1643
- }
1644
- s = /^data:audio\/([^;,]+);/i.exec(c), s || (s = /\.([^.]+)$/.exec(c.split("?", 1)[0])), s && (s = s[1].toLowerCase());
1645
- }
1646
- if (s || console.warn('No file extension was found. Consider using the "format" property or specify an extension.'), s && r.codecs(s)) {
1647
- a = e._src[o];
1648
- break;
1649
- }
1650
- }
1651
- if (!a) {
1652
- e._emit("loaderror", null, "No codec support for selected audio sources.");
1653
- return;
1654
- }
1655
- return e._src = a, e._state = "loading", window.location.protocol === "https:" && a.slice(0, 5) === "http:" && (e._html5 = !0, e._webAudio = !1), new u(e), e._webAudio && _(e), e;
1656
- },
1657
- /**
1658
- * Play a sound or resume previous playback.
1659
- * @param {String/Number} sprite Sprite name for sprite playback or sound id to continue previous.
1660
- * @param {Boolean} internal Internal Use: true prevents event firing.
1661
- * @return {Number} Sound ID.
1662
- */
1663
- play: function(e, a) {
1664
- var o = this, s = null;
1665
- if (typeof e == "number")
1666
- s = e, e = null;
1667
- else {
1668
- if (typeof e == "string" && o._state === "loaded" && !o._sprite[e])
1669
- return null;
1670
- if (typeof e > "u" && (e = "__default", !o._playLock)) {
1671
- for (var c = 0, l = 0; l < o._sounds.length; l++)
1672
- o._sounds[l]._paused && !o._sounds[l]._ended && (c++, s = o._sounds[l]._id);
1673
- c === 1 ? e = null : s = null;
1674
- }
1675
- }
1676
- var f = s ? o._soundById(s) : o._inactiveSound();
1677
- if (!f)
1678
- return null;
1679
- if (s && !e && (e = f._sprite || "__default"), o._state !== "loaded") {
1680
- f._sprite = e, f._ended = !1;
1681
- var v = f._id;
1682
- return o._queue.push({
1683
- event: "play",
1684
- action: function() {
1685
- o.play(v);
1686
- }
1687
- }), v;
1688
- }
1689
- if (s && !f._paused)
1690
- return a || o._loadQueue("play"), f._id;
1691
- o._webAudio && r._autoResume();
1692
- var g = Math.max(0, f._seek > 0 ? f._seek : o._sprite[e][0] / 1e3), S = Math.max(0, (o._sprite[e][0] + o._sprite[e][1]) / 1e3 - g), C = S * 1e3 / Math.abs(f._rate), L = o._sprite[e][0] / 1e3, K = (o._sprite[e][0] + o._sprite[e][1]) / 1e3;
1693
- f._sprite = e, f._ended = !1;
1694
- var M = function() {
1695
- f._paused = !1, f._seek = g, f._start = L, f._stop = K, f._loop = !!(f._loop || o._sprite[e][2]);
1696
- };
1697
- if (g >= K) {
1698
- o._ended(f);
1699
- return;
1700
- }
1701
- var b = f._node;
1702
- if (o._webAudio) {
1703
- var U = function() {
1704
- o._playLock = !1, M(), o._refreshBuffer(f);
1705
- var R = f._muted || o._muted ? 0 : f._volume;
1706
- b.gain.setValueAtTime(R, r.ctx.currentTime), f._playStart = r.ctx.currentTime, typeof b.bufferSource.start > "u" ? f._loop ? b.bufferSource.noteGrainOn(0, g, 86400) : b.bufferSource.noteGrainOn(0, g, S) : f._loop ? b.bufferSource.start(0, g, 86400) : b.bufferSource.start(0, g, S), C !== 1 / 0 && (o._endTimers[f._id] = setTimeout(o._ended.bind(o, f), C)), a || setTimeout(function() {
1707
- o._emit("play", f._id), o._loadQueue();
1708
- }, 0);
1709
- };
1710
- r.state === "running" && r.ctx.state !== "interrupted" ? U() : (o._playLock = !0, o.once("resume", U), o._clearTimer(f._id));
1711
- } else {
1712
- var E = function() {
1713
- b.currentTime = g, b.muted = f._muted || o._muted || r._muted || b.muted, b.volume = f._volume * r.volume(), b.playbackRate = f._rate;
1714
- try {
1715
- var R = b.play();
1716
- if (R && typeof Promise < "u" && (R instanceof Promise || typeof R.then == "function") ? (o._playLock = !0, M(), R.then(function() {
1717
- o._playLock = !1, b._unlocked = !0, a ? o._loadQueue() : o._emit("play", f._id);
1718
- }).catch(function() {
1719
- o._playLock = !1, o._emit("playerror", f._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."), f._ended = !0, f._paused = !0;
1720
- })) : a || (o._playLock = !1, M(), o._emit("play", f._id)), b.playbackRate = f._rate, b.paused) {
1721
- o._emit("playerror", f._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.");
1722
- return;
1723
- }
1724
- e !== "__default" || f._loop ? o._endTimers[f._id] = setTimeout(o._ended.bind(o, f), C) : (o._endTimers[f._id] = function() {
1725
- o._ended(f), b.removeEventListener("ended", o._endTimers[f._id], !1);
1726
- }, b.addEventListener("ended", o._endTimers[f._id], !1));
1727
- } catch (me) {
1728
- o._emit("playerror", f._id, me);
1729
- }
1730
- };
1731
- b.src === "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA" && (b.src = o._src, b.load());
1732
- var W = window && window.ejecta || !b.readyState && r._navigator.isCocoonJS;
1733
- if (b.readyState >= 3 || W)
1734
- E();
1735
- else {
1736
- o._playLock = !0, o._state = "loading";
1737
- var ve = function() {
1738
- o._state = "loaded", E(), b.removeEventListener(r._canPlayEvent, ve, !1);
1739
- };
1740
- b.addEventListener(r._canPlayEvent, ve, !1), o._clearTimer(f._id);
1741
- }
1742
- }
1743
- return f._id;
1744
- },
1745
- /**
1746
- * Pause playback and save current position.
1747
- * @param {Number} id The sound ID (empty to pause all in group).
1748
- * @return {Howl}
1749
- */
1750
- pause: function(e) {
1751
- var a = this;
1752
- if (a._state !== "loaded" || a._playLock)
1753
- return a._queue.push({
1754
- event: "pause",
1755
- action: function() {
1756
- a.pause(e);
1757
- }
1758
- }), a;
1759
- for (var o = a._getSoundIds(e), s = 0; s < o.length; s++) {
1760
- a._clearTimer(o[s]);
1761
- var c = a._soundById(o[s]);
1762
- if (c && !c._paused && (c._seek = a.seek(o[s]), c._rateSeek = 0, c._paused = !0, a._stopFade(o[s]), c._node))
1763
- if (a._webAudio) {
1764
- if (!c._node.bufferSource)
1765
- continue;
1766
- typeof c._node.bufferSource.stop > "u" ? c._node.bufferSource.noteOff(0) : c._node.bufferSource.stop(0), a._cleanBuffer(c._node);
1767
- } else (!isNaN(c._node.duration) || c._node.duration === 1 / 0) && c._node.pause();
1768
- arguments[1] || a._emit("pause", c ? c._id : null);
1769
- }
1770
- return a;
1771
- },
1772
- /**
1773
- * Stop playback and reset to start.
1774
- * @param {Number} id The sound ID (empty to stop all in group).
1775
- * @param {Boolean} internal Internal Use: true prevents event firing.
1776
- * @return {Howl}
1777
- */
1778
- stop: function(e, a) {
1779
- var o = this;
1780
- if (o._state !== "loaded" || o._playLock)
1781
- return o._queue.push({
1782
- event: "stop",
1783
- action: function() {
1784
- o.stop(e);
1785
- }
1786
- }), o;
1787
- for (var s = o._getSoundIds(e), c = 0; c < s.length; c++) {
1788
- o._clearTimer(s[c]);
1789
- var l = o._soundById(s[c]);
1790
- l && (l._seek = l._start || 0, l._rateSeek = 0, l._paused = !0, l._ended = !0, o._stopFade(s[c]), l._node && (o._webAudio ? l._node.bufferSource && (typeof l._node.bufferSource.stop > "u" ? l._node.bufferSource.noteOff(0) : l._node.bufferSource.stop(0), o._cleanBuffer(l._node)) : (!isNaN(l._node.duration) || l._node.duration === 1 / 0) && (l._node.currentTime = l._start || 0, l._node.pause(), l._node.duration === 1 / 0 && o._clearSound(l._node))), a || o._emit("stop", l._id));
1791
- }
1792
- return o;
1793
- },
1794
- /**
1795
- * Mute/unmute a single sound or all sounds in this Howl group.
1796
- * @param {Boolean} muted Set to true to mute and false to unmute.
1797
- * @param {Number} id The sound ID to update (omit to mute/unmute all).
1798
- * @return {Howl}
1799
- */
1800
- mute: function(e, a) {
1801
- var o = this;
1802
- if (o._state !== "loaded" || o._playLock)
1803
- return o._queue.push({
1804
- event: "mute",
1805
- action: function() {
1806
- o.mute(e, a);
1807
- }
1808
- }), o;
1809
- if (typeof a > "u")
1810
- if (typeof e == "boolean")
1811
- o._muted = e;
1812
- else
1813
- return o._muted;
1814
- for (var s = o._getSoundIds(a), c = 0; c < s.length; c++) {
1815
- var l = o._soundById(s[c]);
1816
- l && (l._muted = e, l._interval && o._stopFade(l._id), o._webAudio && l._node ? l._node.gain.setValueAtTime(e ? 0 : l._volume, r.ctx.currentTime) : l._node && (l._node.muted = r._muted ? !0 : e), o._emit("mute", l._id));
1817
- }
1818
- return o;
1819
- },
1820
- /**
1821
- * Get/set the volume of this sound or of the Howl group. This method can optionally take 0, 1 or 2 arguments.
1822
- * volume() -> Returns the group's volume value.
1823
- * volume(id) -> Returns the sound id's current volume.
1824
- * volume(vol) -> Sets the volume of all sounds in this Howl group.
1825
- * volume(vol, id) -> Sets the volume of passed sound id.
1826
- * @return {Howl/Number} Returns self or current volume.
1827
- */
1828
- volume: function() {
1829
- var e = this, a = arguments, o, s;
1830
- if (a.length === 0)
1831
- return e._volume;
1832
- if (a.length === 1 || a.length === 2 && typeof a[1] > "u") {
1833
- var c = e._getSoundIds(), l = c.indexOf(a[0]);
1834
- l >= 0 ? s = parseInt(a[0], 10) : o = parseFloat(a[0]);
1835
- } else a.length >= 2 && (o = parseFloat(a[0]), s = parseInt(a[1], 10));
1836
- var f;
1837
- if (typeof o < "u" && o >= 0 && o <= 1) {
1838
- if (e._state !== "loaded" || e._playLock)
1839
- return e._queue.push({
1840
- event: "volume",
1841
- action: function() {
1842
- e.volume.apply(e, a);
1843
- }
1844
- }), e;
1845
- typeof s > "u" && (e._volume = o), s = e._getSoundIds(s);
1846
- for (var v = 0; v < s.length; v++)
1847
- f = e._soundById(s[v]), f && (f._volume = o, a[2] || e._stopFade(s[v]), e._webAudio && f._node && !f._muted ? f._node.gain.setValueAtTime(o, r.ctx.currentTime) : f._node && !f._muted && (f._node.volume = o * r.volume()), e._emit("volume", f._id));
1848
- } else
1849
- return f = s ? e._soundById(s) : e._sounds[0], f ? f._volume : 0;
1850
- return e;
1851
- },
1852
- /**
1853
- * Fade a currently playing sound between two volumes (if no id is passed, all sounds will fade).
1854
- * @param {Number} from The value to fade from (0.0 to 1.0).
1855
- * @param {Number} to The volume to fade to (0.0 to 1.0).
1856
- * @param {Number} len Time in milliseconds to fade.
1857
- * @param {Number} id The sound id (omit to fade all sounds).
1858
- * @return {Howl}
1859
- */
1860
- fade: function(e, a, o, s) {
1861
- var c = this;
1862
- if (c._state !== "loaded" || c._playLock)
1863
- return c._queue.push({
1864
- event: "fade",
1865
- action: function() {
1866
- c.fade(e, a, o, s);
1867
- }
1868
- }), c;
1869
- e = Math.min(Math.max(0, parseFloat(e)), 1), a = Math.min(Math.max(0, parseFloat(a)), 1), o = parseFloat(o), c.volume(e, s);
1870
- for (var l = c._getSoundIds(s), f = 0; f < l.length; f++) {
1871
- var v = c._soundById(l[f]);
1872
- if (v) {
1873
- if (s || c._stopFade(l[f]), c._webAudio && !v._muted) {
1874
- var g = r.ctx.currentTime, S = g + o / 1e3;
1875
- v._volume = e, v._node.gain.setValueAtTime(e, g), v._node.gain.linearRampToValueAtTime(a, S);
1876
- }
1877
- c._startFadeInterval(v, e, a, o, l[f], typeof s > "u");
1878
- }
1879
- }
1880
- return c;
1881
- },
1882
- /**
1883
- * Starts the internal interval to fade a sound.
1884
- * @param {Object} sound Reference to sound to fade.
1885
- * @param {Number} from The value to fade from (0.0 to 1.0).
1886
- * @param {Number} to The volume to fade to (0.0 to 1.0).
1887
- * @param {Number} len Time in milliseconds to fade.
1888
- * @param {Number} id The sound id to fade.
1889
- * @param {Boolean} isGroup If true, set the volume on the group.
1890
- */
1891
- _startFadeInterval: function(e, a, o, s, c, l) {
1892
- var f = this, v = a, g = o - a, S = Math.abs(g / 0.01), C = Math.max(4, S > 0 ? s / S : s), L = Date.now();
1893
- e._fadeTo = o, e._interval = setInterval(function() {
1894
- var K = (Date.now() - L) / s;
1895
- L = Date.now(), v += g * K, v = Math.round(v * 100) / 100, g < 0 ? v = Math.max(o, v) : v = Math.min(o, v), f._webAudio ? e._volume = v : f.volume(v, e._id, !0), l && (f._volume = v), (o < a && v <= o || o > a && v >= o) && (clearInterval(e._interval), e._interval = null, e._fadeTo = null, f.volume(o, e._id), f._emit("fade", e._id));
1896
- }, C);
1897
- },
1898
- /**
1899
- * Internal method that stops the currently playing fade when
1900
- * a new fade starts, volume is changed or the sound is stopped.
1901
- * @param {Number} id The sound id.
1902
- * @return {Howl}
1903
- */
1904
- _stopFade: function(e) {
1905
- var a = this, o = a._soundById(e);
1906
- return o && o._interval && (a._webAudio && o._node.gain.cancelScheduledValues(r.ctx.currentTime), clearInterval(o._interval), o._interval = null, a.volume(o._fadeTo, e), o._fadeTo = null, a._emit("fade", e)), a;
1907
- },
1908
- /**
1909
- * Get/set the loop parameter on a sound. This method can optionally take 0, 1 or 2 arguments.
1910
- * loop() -> Returns the group's loop value.
1911
- * loop(id) -> Returns the sound id's loop value.
1912
- * loop(loop) -> Sets the loop value for all sounds in this Howl group.
1913
- * loop(loop, id) -> Sets the loop value of passed sound id.
1914
- * @return {Howl/Boolean} Returns self or current loop value.
1915
- */
1916
- loop: function() {
1917
- var e = this, a = arguments, o, s, c;
1918
- if (a.length === 0)
1919
- return e._loop;
1920
- if (a.length === 1)
1921
- if (typeof a[0] == "boolean")
1922
- o = a[0], e._loop = o;
1923
- else
1924
- return c = e._soundById(parseInt(a[0], 10)), c ? c._loop : !1;
1925
- else a.length === 2 && (o = a[0], s = parseInt(a[1], 10));
1926
- for (var l = e._getSoundIds(s), f = 0; f < l.length; f++)
1927
- c = e._soundById(l[f]), c && (c._loop = o, e._webAudio && c._node && c._node.bufferSource && (c._node.bufferSource.loop = o, o && (c._node.bufferSource.loopStart = c._start || 0, c._node.bufferSource.loopEnd = c._stop, e.playing(l[f]) && (e.pause(l[f], !0), e.play(l[f], !0)))));
1928
- return e;
1929
- },
1930
- /**
1931
- * Get/set the playback rate of a sound. This method can optionally take 0, 1 or 2 arguments.
1932
- * rate() -> Returns the first sound node's current playback rate.
1933
- * rate(id) -> Returns the sound id's current playback rate.
1934
- * rate(rate) -> Sets the playback rate of all sounds in this Howl group.
1935
- * rate(rate, id) -> Sets the playback rate of passed sound id.
1936
- * @return {Howl/Number} Returns self or the current playback rate.
1937
- */
1938
- rate: function() {
1939
- var e = this, a = arguments, o, s;
1940
- if (a.length === 0)
1941
- s = e._sounds[0]._id;
1942
- else if (a.length === 1) {
1943
- var c = e._getSoundIds(), l = c.indexOf(a[0]);
1944
- l >= 0 ? s = parseInt(a[0], 10) : o = parseFloat(a[0]);
1945
- } else a.length === 2 && (o = parseFloat(a[0]), s = parseInt(a[1], 10));
1946
- var f;
1947
- if (typeof o == "number") {
1948
- if (e._state !== "loaded" || e._playLock)
1949
- return e._queue.push({
1950
- event: "rate",
1951
- action: function() {
1952
- e.rate.apply(e, a);
1953
- }
1954
- }), e;
1955
- typeof s > "u" && (e._rate = o), s = e._getSoundIds(s);
1956
- for (var v = 0; v < s.length; v++)
1957
- if (f = e._soundById(s[v]), f) {
1958
- e.playing(s[v]) && (f._rateSeek = e.seek(s[v]), f._playStart = e._webAudio ? r.ctx.currentTime : f._playStart), f._rate = o, e._webAudio && f._node && f._node.bufferSource ? f._node.bufferSource.playbackRate.setValueAtTime(o, r.ctx.currentTime) : f._node && (f._node.playbackRate = o);
1959
- var g = e.seek(s[v]), S = (e._sprite[f._sprite][0] + e._sprite[f._sprite][1]) / 1e3 - g, C = S * 1e3 / Math.abs(f._rate);
1960
- (e._endTimers[s[v]] || !f._paused) && (e._clearTimer(s[v]), e._endTimers[s[v]] = setTimeout(e._ended.bind(e, f), C)), e._emit("rate", f._id);
1961
- }
1962
- } else
1963
- return f = e._soundById(s), f ? f._rate : e._rate;
1964
- return e;
1965
- },
1966
- /**
1967
- * Get/set the seek position of a sound. This method can optionally take 0, 1 or 2 arguments.
1968
- * seek() -> Returns the first sound node's current seek position.
1969
- * seek(id) -> Returns the sound id's current seek position.
1970
- * seek(seek) -> Sets the seek position of the first sound node.
1971
- * seek(seek, id) -> Sets the seek position of passed sound id.
1972
- * @return {Howl/Number} Returns self or the current seek position.
1973
- */
1974
- seek: function() {
1975
- var e = this, a = arguments, o, s;
1976
- if (a.length === 0)
1977
- e._sounds.length && (s = e._sounds[0]._id);
1978
- else if (a.length === 1) {
1979
- var c = e._getSoundIds(), l = c.indexOf(a[0]);
1980
- l >= 0 ? s = parseInt(a[0], 10) : e._sounds.length && (s = e._sounds[0]._id, o = parseFloat(a[0]));
1981
- } else a.length === 2 && (o = parseFloat(a[0]), s = parseInt(a[1], 10));
1982
- if (typeof s > "u")
1983
- return 0;
1984
- if (typeof o == "number" && (e._state !== "loaded" || e._playLock))
1985
- return e._queue.push({
1986
- event: "seek",
1987
- action: function() {
1988
- e.seek.apply(e, a);
1989
- }
1990
- }), e;
1991
- var f = e._soundById(s);
1992
- if (f)
1993
- if (typeof o == "number" && o >= 0) {
1994
- var v = e.playing(s);
1995
- v && e.pause(s, !0), f._seek = o, f._ended = !1, e._clearTimer(s), !e._webAudio && f._node && !isNaN(f._node.duration) && (f._node.currentTime = o);
1996
- var g = function() {
1997
- v && e.play(s, !0), e._emit("seek", s);
1998
- };
1999
- if (v && !e._webAudio) {
2000
- var S = function() {
2001
- e._playLock ? setTimeout(S, 0) : g();
2002
- };
2003
- setTimeout(S, 0);
2004
- } else
2005
- g();
2006
- } else if (e._webAudio) {
2007
- var C = e.playing(s) ? r.ctx.currentTime - f._playStart : 0, L = f._rateSeek ? f._rateSeek - f._seek : 0;
2008
- return f._seek + (L + C * Math.abs(f._rate));
2009
- } else
2010
- return f._node.currentTime;
2011
- return e;
2012
- },
2013
- /**
2014
- * 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.
2015
- * @param {Number} id The sound id to check. If none is passed, the whole sound group is checked.
2016
- * @return {Boolean} True if playing and false if not.
2017
- */
2018
- playing: function(e) {
2019
- var a = this;
2020
- if (typeof e == "number") {
2021
- var o = a._soundById(e);
2022
- return o ? !o._paused : !1;
2023
- }
2024
- for (var s = 0; s < a._sounds.length; s++)
2025
- if (!a._sounds[s]._paused)
2026
- return !0;
2027
- return !1;
2028
- },
2029
- /**
2030
- * Get the duration of this sound. Passing a sound id will return the sprite duration.
2031
- * @param {Number} id The sound id to check. If none is passed, return full source duration.
2032
- * @return {Number} Audio duration in seconds.
2033
- */
2034
- duration: function(e) {
2035
- var a = this, o = a._duration, s = a._soundById(e);
2036
- return s && (o = a._sprite[s._sprite][1] / 1e3), o;
2037
- },
2038
- /**
2039
- * Returns the current loaded state of this Howl.
2040
- * @return {String} 'unloaded', 'loading', 'loaded'
2041
- */
2042
- state: function() {
2043
- return this._state;
2044
- },
2045
- /**
2046
- * Unload and destroy the current Howl object.
2047
- * This will immediately stop all sound instances attached to this group.
2048
- */
2049
- unload: function() {
2050
- for (var e = this, a = e._sounds, o = 0; o < a.length; o++)
2051
- a[o]._paused || e.stop(a[o]._id), e._webAudio || (e._clearSound(a[o]._node), a[o]._node.removeEventListener("error", a[o]._errorFn, !1), a[o]._node.removeEventListener(r._canPlayEvent, a[o]._loadFn, !1), a[o]._node.removeEventListener("ended", a[o]._endFn, !1), r._releaseHtml5Audio(a[o]._node)), delete a[o]._node, e._clearTimer(a[o]._id);
2052
- var s = r._howls.indexOf(e);
2053
- s >= 0 && r._howls.splice(s, 1);
2054
- var c = !0;
2055
- for (o = 0; o < r._howls.length; o++)
2056
- if (r._howls[o]._src === e._src || e._src.indexOf(r._howls[o]._src) >= 0) {
2057
- c = !1;
2058
- break;
2059
- }
2060
- return d && c && delete d[e._src], r.noAudio = !1, e._state = "unloaded", e._sounds = [], e = null, null;
2061
- },
2062
- /**
2063
- * Listen to a custom event.
2064
- * @param {String} event Event name.
2065
- * @param {Function} fn Listener to call.
2066
- * @param {Number} id (optional) Only listen to events for this sound.
2067
- * @param {Number} once (INTERNAL) Marks event to fire only once.
2068
- * @return {Howl}
2069
- */
2070
- on: function(e, a, o, s) {
2071
- var c = this, l = c["_on" + e];
2072
- return typeof a == "function" && l.push(s ? { id: o, fn: a, once: s } : { id: o, fn: a }), c;
2073
- },
2074
- /**
2075
- * Remove a custom event. Call without parameters to remove all events.
2076
- * @param {String} event Event name.
2077
- * @param {Function} fn Listener to remove. Leave empty to remove all.
2078
- * @param {Number} id (optional) Only remove events for this sound.
2079
- * @return {Howl}
2080
- */
2081
- off: function(e, a, o) {
2082
- var s = this, c = s["_on" + e], l = 0;
2083
- if (typeof a == "number" && (o = a, a = null), a || o)
2084
- for (l = 0; l < c.length; l++) {
2085
- var f = o === c[l].id;
2086
- if (a === c[l].fn && f || !a && f) {
2087
- c.splice(l, 1);
2088
- break;
2089
- }
2090
- }
2091
- else if (e)
2092
- s["_on" + e] = [];
2093
- else {
2094
- var v = Object.keys(s);
2095
- for (l = 0; l < v.length; l++)
2096
- v[l].indexOf("_on") === 0 && Array.isArray(s[v[l]]) && (s[v[l]] = []);
2097
- }
2098
- return s;
2099
- },
2100
- /**
2101
- * Listen to a custom event and remove it once fired.
2102
- * @param {String} event Event name.
2103
- * @param {Function} fn Listener to call.
2104
- * @param {Number} id (optional) Only listen to events for this sound.
2105
- * @return {Howl}
2106
- */
2107
- once: function(e, a, o) {
2108
- var s = this;
2109
- return s.on(e, a, o, 1), s;
2110
- },
2111
- /**
2112
- * Emit all events of a specific type and pass the sound id.
2113
- * @param {String} event Event name.
2114
- * @param {Number} id Sound ID.
2115
- * @param {Number} msg Message to go with event.
2116
- * @return {Howl}
2117
- */
2118
- _emit: function(e, a, o) {
2119
- for (var s = this, c = s["_on" + e], l = c.length - 1; l >= 0; l--)
2120
- (!c[l].id || c[l].id === a || e === "load") && (setTimeout((function(f) {
2121
- f.call(this, a, o);
2122
- }).bind(s, c[l].fn), 0), c[l].once && s.off(e, c[l].fn, c[l].id));
2123
- return s._loadQueue(e), s;
2124
- },
2125
- /**
2126
- * Queue of actions initiated before the sound has loaded.
2127
- * These will be called in sequence, with the next only firing
2128
- * after the previous has finished executing (even if async like play).
2129
- * @return {Howl}
2130
- */
2131
- _loadQueue: function(e) {
2132
- var a = this;
2133
- if (a._queue.length > 0) {
2134
- var o = a._queue[0];
2135
- o.event === e && (a._queue.shift(), a._loadQueue()), e || o.action();
2136
- }
2137
- return a;
2138
- },
2139
- /**
2140
- * Fired when playback ends at the end of the duration.
2141
- * @param {Sound} sound The sound object to work with.
2142
- * @return {Howl}
2143
- */
2144
- _ended: function(e) {
2145
- var a = this, o = e._sprite;
2146
- if (!a._webAudio && e._node && !e._node.paused && !e._node.ended && e._node.currentTime < e._stop)
2147
- return setTimeout(a._ended.bind(a, e), 100), a;
2148
- var s = !!(e._loop || a._sprite[o][2]);
2149
- if (a._emit("end", e._id), !a._webAudio && s && a.stop(e._id, !0).play(e._id), a._webAudio && s) {
2150
- a._emit("play", e._id), e._seek = e._start || 0, e._rateSeek = 0, e._playStart = r.ctx.currentTime;
2151
- var c = (e._stop - e._start) * 1e3 / Math.abs(e._rate);
2152
- a._endTimers[e._id] = setTimeout(a._ended.bind(a, e), c);
2153
- }
2154
- return a._webAudio && !s && (e._paused = !0, e._ended = !0, e._seek = e._start || 0, e._rateSeek = 0, a._clearTimer(e._id), a._cleanBuffer(e._node), r._autoSuspend()), !a._webAudio && !s && a.stop(e._id, !0), a;
2155
- },
2156
- /**
2157
- * Clear the end timer for a sound playback.
2158
- * @param {Number} id The sound ID.
2159
- * @return {Howl}
2160
- */
2161
- _clearTimer: function(e) {
2162
- var a = this;
2163
- if (a._endTimers[e]) {
2164
- if (typeof a._endTimers[e] != "function")
2165
- clearTimeout(a._endTimers[e]);
2166
- else {
2167
- var o = a._soundById(e);
2168
- o && o._node && o._node.removeEventListener("ended", a._endTimers[e], !1);
2169
- }
2170
- delete a._endTimers[e];
2171
- }
2172
- return a;
2173
- },
2174
- /**
2175
- * Return the sound identified by this ID, or return null.
2176
- * @param {Number} id Sound ID
2177
- * @return {Object} Sound object or null.
2178
- */
2179
- _soundById: function(e) {
2180
- for (var a = this, o = 0; o < a._sounds.length; o++)
2181
- if (e === a._sounds[o]._id)
2182
- return a._sounds[o];
2183
- return null;
2184
- },
2185
- /**
2186
- * Return an inactive sound from the pool or create a new one.
2187
- * @return {Sound} Sound playback object.
2188
- */
2189
- _inactiveSound: function() {
2190
- var e = this;
2191
- e._drain();
2192
- for (var a = 0; a < e._sounds.length; a++)
2193
- if (e._sounds[a]._ended)
2194
- return e._sounds[a].reset();
2195
- return new u(e);
2196
- },
2197
- /**
2198
- * Drain excess inactive sounds from the pool.
2199
- */
2200
- _drain: function() {
2201
- var e = this, a = e._pool, o = 0, s = 0;
2202
- if (!(e._sounds.length < a)) {
2203
- for (s = 0; s < e._sounds.length; s++)
2204
- e._sounds[s]._ended && o++;
2205
- for (s = e._sounds.length - 1; s >= 0; s--) {
2206
- if (o <= a)
2207
- return;
2208
- e._sounds[s]._ended && (e._webAudio && e._sounds[s]._node && e._sounds[s]._node.disconnect(0), e._sounds.splice(s, 1), o--);
2209
- }
2210
- }
2211
- },
2212
- /**
2213
- * Get all ID's from the sounds pool.
2214
- * @param {Number} id Only return one ID if one is passed.
2215
- * @return {Array} Array of IDs.
2216
- */
2217
- _getSoundIds: function(e) {
2218
- var a = this;
2219
- if (typeof e > "u") {
2220
- for (var o = [], s = 0; s < a._sounds.length; s++)
2221
- o.push(a._sounds[s]._id);
2222
- return o;
2223
- } else
2224
- return [e];
2225
- },
2226
- /**
2227
- * Load the sound back into the buffer source.
2228
- * @param {Sound} sound The sound object to work with.
2229
- * @return {Howl}
2230
- */
2231
- _refreshBuffer: function(e) {
2232
- var a = this;
2233
- return e._node.bufferSource = r.ctx.createBufferSource(), e._node.bufferSource.buffer = d[a._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, r.ctx.currentTime), a;
2234
- },
2235
- /**
2236
- * Prevent memory leaks by cleaning up the buffer source after playback.
2237
- * @param {Object} node Sound's audio node containing the buffer source.
2238
- * @return {Howl}
2239
- */
2240
- _cleanBuffer: function(e) {
2241
- var a = this, o = r._navigator && r._navigator.vendor.indexOf("Apple") >= 0;
2242
- if (!e.bufferSource)
2243
- return a;
2244
- if (r._scratchBuffer && e.bufferSource && (e.bufferSource.onended = null, e.bufferSource.disconnect(0), o))
2245
- try {
2246
- e.bufferSource.buffer = r._scratchBuffer;
2247
- } catch {
2248
- }
2249
- return e.bufferSource = null, a;
2250
- },
2251
- /**
2252
- * Set the source to a 0-second silence to stop any downloading (except in IE).
2253
- * @param {Object} node Audio node to clear.
2254
- */
2255
- _clearSound: function(e) {
2256
- var a = /MSIE |Trident\//.test(r._navigator && r._navigator.userAgent);
2257
- a || (e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA");
2258
- }
2259
- };
2260
- var u = function(e) {
2261
- this._parent = e, this.init();
2262
- };
2263
- u.prototype = {
2264
- /**
2265
- * Initialize a new Sound object.
2266
- * @return {Sound}
2267
- */
2268
- init: function() {
2269
- var e = this, a = e._parent;
2270
- return e._muted = a._muted, e._loop = a._loop, e._volume = a._volume, e._rate = a._rate, e._seek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++r._counter, a._sounds.push(e), e.create(), e;
2271
- },
2272
- /**
2273
- * Create and setup a new sound object, whether HTML5 Audio or Web Audio.
2274
- * @return {Sound}
2275
- */
2276
- create: function() {
2277
- var e = this, a = e._parent, o = r._muted || e._muted || e._parent._muted ? 0 : e._volume;
2278
- return a._webAudio ? (e._node = typeof r.ctx.createGain > "u" ? r.ctx.createGainNode() : r.ctx.createGain(), e._node.gain.setValueAtTime(o, r.ctx.currentTime), e._node.paused = !0, e._node.connect(r.masterGain)) : r.noAudio || (e._node = r._obtainHtml5Audio(), e._errorFn = e._errorListener.bind(e), e._node.addEventListener("error", e._errorFn, !1), e._loadFn = e._loadListener.bind(e), e._node.addEventListener(r._canPlayEvent, e._loadFn, !1), e._endFn = e._endListener.bind(e), e._node.addEventListener("ended", e._endFn, !1), e._node.src = a._src, e._node.preload = a._preload === !0 ? "auto" : a._preload, e._node.volume = o * r.volume(), e._node.load()), e;
2279
- },
2280
- /**
2281
- * Reset the parameters of this sound to the original state (for recycle).
2282
- * @return {Sound}
2283
- */
2284
- reset: function() {
2285
- var e = this, a = e._parent;
2286
- return e._muted = a._muted, e._loop = a._loop, e._volume = a._volume, e._rate = a._rate, e._seek = 0, e._rateSeek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++r._counter, e;
2287
- },
2288
- /**
2289
- * HTML5 Audio error listener callback.
2290
- */
2291
- _errorListener: function() {
2292
- var e = this;
2293
- e._parent._emit("loaderror", e._id, e._node.error ? e._node.error.code : 0), e._node.removeEventListener("error", e._errorFn, !1);
2294
- },
2295
- /**
2296
- * HTML5 Audio canplaythrough listener callback.
2297
- */
2298
- _loadListener: function() {
2299
- var e = this, a = e._parent;
2300
- a._duration = Math.ceil(e._node.duration * 10) / 10, Object.keys(a._sprite).length === 0 && (a._sprite = { __default: [0, a._duration * 1e3] }), a._state !== "loaded" && (a._state = "loaded", a._emit("load"), a._loadQueue()), e._node.removeEventListener(r._canPlayEvent, e._loadFn, !1);
2301
- },
2302
- /**
2303
- * HTML5 Audio ended listener callback.
2304
- */
2305
- _endListener: function() {
2306
- var e = this, a = e._parent;
2307
- a._duration === 1 / 0 && (a._duration = Math.ceil(e._node.duration * 10) / 10, a._sprite.__default[1] === 1 / 0 && (a._sprite.__default[1] = a._duration * 1e3), a._ended(e)), e._node.removeEventListener("ended", e._endFn, !1);
2308
- }
2309
- };
2310
- var d = {}, _ = function(e) {
2311
- var a = e._src;
2312
- if (d[a]) {
2313
- e._duration = d[a].duration, A(e);
2314
- return;
2315
- }
2316
- if (/^data:[^;]+;base64,/.test(a)) {
2317
- for (var o = atob(a.split(",")[1]), s = new Uint8Array(o.length), c = 0; c < o.length; ++c)
2318
- s[c] = o.charCodeAt(c);
2319
- h(s.buffer, e);
2320
- } else {
2321
- var l = new XMLHttpRequest();
2322
- l.open(e._xhr.method, a, !0), l.withCredentials = e._xhr.withCredentials, l.responseType = "arraybuffer", e._xhr.headers && Object.keys(e._xhr.headers).forEach(function(f) {
2323
- l.setRequestHeader(f, e._xhr.headers[f]);
2324
- }), l.onload = function() {
2325
- var f = (l.status + "")[0];
2326
- if (f !== "0" && f !== "2" && f !== "3") {
2327
- e._emit("loaderror", null, "Failed loading audio file with status: " + l.status + ".");
2328
- return;
2329
- }
2330
- h(l.response, e);
2331
- }, l.onerror = function() {
2332
- e._webAudio && (e._html5 = !0, e._webAudio = !1, e._sounds = [], delete d[a], e.load());
2333
- }, p(l);
2334
- }
2335
- }, p = function(e) {
2336
- try {
2337
- e.send();
2338
- } catch {
2339
- e.onerror();
2340
- }
2341
- }, h = function(e, a) {
2342
- var o = function() {
2343
- a._emit("loaderror", null, "Decoding audio data failed.");
2344
- }, s = function(c) {
2345
- c && a._sounds.length > 0 ? (d[a._src] = c, A(a, c)) : o();
2346
- };
2347
- typeof Promise < "u" && r.ctx.decodeAudioData.length === 1 ? r.ctx.decodeAudioData(e).then(s).catch(o) : r.ctx.decodeAudioData(e, s, o);
2348
- }, A = function(e, a) {
2349
- a && !e._duration && (e._duration = a.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());
2350
- }, m = function() {
2351
- if (r.usingWebAudio) {
2352
- try {
2353
- typeof AudioContext < "u" ? r.ctx = new AudioContext() : typeof webkitAudioContext < "u" ? r.ctx = new webkitAudioContext() : r.usingWebAudio = !1;
2354
- } catch {
2355
- r.usingWebAudio = !1;
2356
- }
2357
- r.ctx || (r.usingWebAudio = !1);
2358
- var e = /iP(hone|od|ad)/.test(r._navigator && r._navigator.platform), a = r._navigator && r._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/), o = a ? parseInt(a[1], 10) : null;
2359
- if (e && o && o < 9) {
2360
- var s = /safari/.test(r._navigator && r._navigator.userAgent.toLowerCase());
2361
- r._navigator && !s && (r.usingWebAudio = !1);
2362
- }
2363
- r.usingWebAudio && (r.masterGain = typeof r.ctx.createGain > "u" ? r.ctx.createGainNode() : r.ctx.createGain(), r.masterGain.gain.setValueAtTime(r._muted ? 0 : r._volume, r.ctx.currentTime), r.masterGain.connect(r.ctx.destination)), r._setup();
2364
- }
2365
- };
2366
- t.Howler = r, t.Howl = i, typeof se < "u" ? (se.HowlerGlobal = n, se.Howler = r, se.Howl = i, se.Sound = u) : typeof window < "u" && (window.HowlerGlobal = n, window.Howler = r, window.Howl = i, window.Sound = u);
2367
- })();
2368
- })(Ue)), Ue;
2369
- }
2370
- var ae = ca();
2371
- const Ae = {}, Se = {};
2372
- function pn(t, n) {
2373
- t ? n[t] && n[t].stop() : Object.keys(n).forEach((r) => {
2374
- r && r.fade && r.fade(void 0, 0, 1), n[r].stop();
2375
- });
2376
- }
2377
- function la(t) {
2378
- vn(t.mute), mn(t.volume);
2379
- }
2380
- function vn(t = !0) {
2381
- ae.Howler.mute(t);
2382
- }
2383
- function da() {
2384
- return ae.Howler.muted;
2385
- }
2386
- function mn(t) {
2387
- ae.Howler.volume(t / 100);
2388
- }
2389
- function _a() {
2390
- return ae.Howler.volume * 100;
2391
- }
2392
- function pa(t) {
2393
- Ae[t] || (Ae[t] = new ae.Howl({
2394
- src: [t]
2395
- })), Ae[t].play();
2396
- }
2397
- function va(t) {
2398
- pn(t, Ae);
2399
- }
2400
- function ma(t, n = !0) {
2401
- Se[t] || (Se[t] = new ae.Howl({
2402
- src: [t],
2403
- html5: !0,
2404
- // streaming
2405
- loop: n
2406
- })), Se[t].play();
2407
- }
2408
- function ha(t) {
2409
- pn(t, Se);
2410
- }
2411
- const ga = {
2412
- init: la,
2413
- mute: vn,
2414
- isMuted: da,
2415
- setVolume: mn,
2416
- getVolume: _a,
2417
- playSound: pa,
2418
- stopSound: va,
2419
- playMusic: ma,
2420
- stopMusic: ha
2421
- };
2422
- let ya = /* @__PURE__ */ Symbol("clean"), B = [], H = 0;
2423
- const ye = 4, wa = /* @__NO_SIDE_EFFECTS__ */ (t) => {
2424
- let n = [], r = {
2425
- get() {
2426
- return r.lc || r.listen(() => {
2427
- })(), r.value;
2428
- },
2429
- lc: 0,
2430
- listen(i) {
2431
- return r.lc = n.push(i), () => {
2432
- for (let d = H + ye; d < B.length; )
2433
- B[d] === i ? B.splice(d, ye) : d += ye;
2434
- let u = n.indexOf(i);
2435
- ~u && (n.splice(u, 1), --r.lc || r.off());
2436
- };
2437
- },
2438
- notify(i, u) {
2439
- let d = !B.length;
2440
- for (let _ of n)
2441
- B.push(_, r.value, i, u);
2442
- if (d) {
2443
- for (H = 0; H < B.length; H += ye)
2444
- B[H](
2445
- B[H + 1],
2446
- B[H + 2],
2447
- B[H + 3]
2448
- );
2449
- B.length = 0;
2450
- }
2451
- },
2452
- /* It will be called on last listener unsubscribing.
2453
- We will redefine it in onMount and onStop. */
2454
- off() {
2455
- },
2456
- set(i) {
2457
- let u = r.value;
2458
- u !== i && (r.value = i, r.notify(u));
2459
- },
2460
- subscribe(i) {
2461
- let u = r.listen(i);
2462
- return i(r.value), u;
2463
- },
2464
- value: t
2465
- };
2466
- return process.env.NODE_ENV !== "production" && (r[ya] = () => {
2467
- n = [], r.lc = 0, r.off();
2468
- }), r;
2469
- }, ba = /* @__NO_SIDE_EFFECTS__ */ (t = {}) => {
2470
- let n = /* @__PURE__ */ wa(t);
2471
- return n.setKey = function(r, i) {
2472
- let u = n.value;
2473
- typeof i > "u" && r in n.value ? (n.value = { ...n.value }, delete n.value[r], n.notify(u, r)) : n.value[r] !== i && (n.value = {
2474
- ...n.value,
2475
- [r]: i
2476
- }, n.notify(u, r));
2477
- }, n;
2478
- }, T = /* @__PURE__ */ ba({
2479
- settings: {},
2480
- game: {},
2481
- metadata: {},
2482
- scenes: [],
2483
- vars: {}
1143
+ // node_modules/idb-keyval/dist/index.js
1144
+ function J(e) {
1145
+ return new Promise((t, n) => {
1146
+ e.oncomplete = e.onsuccess = () => t(e.result), e.onabort = e.onerror = () => n(e.error);
1147
+ });
1148
+ }
1149
+ function On(e, t) {
1150
+ let n, r = () => {
1151
+ if (n) return n;
1152
+ let r = indexedDB.open(e);
1153
+ return r.onupgradeneeded = () => r.result.createObjectStore(t), n = J(r), n.then((e) => {
1154
+ e.onclose = () => n = void 0;
1155
+ }, () => {
1156
+ n = void 0;
1157
+ }), n;
1158
+ };
1159
+ return (e, n) => r().then((r) => n(r.transaction(t, e).objectStore(t)));
1160
+ }
1161
+ var kn;
1162
+ function An() {
1163
+ return kn ||= On("keyval-store", "keyval"), kn;
1164
+ }
1165
+ function jn(e, t = An()) {
1166
+ return t("readonly", (t) => J(t.get(e)));
1167
+ }
1168
+ function Mn(e, t, n = An()) {
1169
+ return n("readwrite", (n) => (n.put(t, e), J(n.transaction)));
1170
+ }
1171
+ function Nn(e, t = An()) {
1172
+ return t("readwrite", (t) => (t.delete(e), J(t.transaction)));
1173
+ }
1174
+ function Pn(e, t) {
1175
+ return e.openCursor().onsuccess = function() {
1176
+ this.result && (t(this.result), this.result.continue());
1177
+ }, J(e.transaction);
1178
+ }
1179
+ function Fn(e = An()) {
1180
+ return e("readonly", (e) => {
1181
+ if (e.getAllKeys) return J(e.getAllKeys());
1182
+ let t = [];
1183
+ return Pn(e, (e) => t.push(e.key)).then(() => t);
1184
+ });
1185
+ }
1186
+ // src/interfaces/persistent-idb.js
1187
+ var Y;
1188
+ function In(e) {
1189
+ Y = On(e, "keyvaluepairs");
1190
+ }
1191
+ async function Ln(e) {
1192
+ return await jn(e, Y) !== void 0;
1193
+ }
1194
+ async function Rn(e) {
1195
+ return await jn(e, Y);
1196
+ }
1197
+ async function zn(e, t) {
1198
+ await Mn(e, t, Y);
1199
+ }
1200
+ async function Bn(e) {
1201
+ await Nn(e, Y);
1202
+ }
1203
+ async function Vn() {
1204
+ return await Fn(Y);
1205
+ }
1206
+ var Hn = {
1207
+ driver: "idb",
1208
+ init: In,
1209
+ exists: Ln,
1210
+ get: Rn,
1211
+ set: zn,
1212
+ remove: Bn,
1213
+ keys: Vn
1214
+ }, Un = /* @__PURE__ */ o(((e, t) => {
1215
+ function n(e, t) {
1216
+ for (var n = e.length & 3, r = e.length - n, i = t, a, o = 3432918353, s = 461845907, c, l = 0; l < r;) c = e.charCodeAt(l) & 255 | (e.charCodeAt(++l) & 255) << 8 | (e.charCodeAt(++l) & 255) << 16 | (e.charCodeAt(++l) & 255) << 24, ++l, c = (c & 65535) * o + (((c >>> 16) * o & 65535) << 16) | 0, c = c << 15 | c >>> 17, c = (c & 65535) * s + (((c >>> 16) * s & 65535) << 16) | 0, i ^= c, i = i << 13 | i >>> 19, a = (i & 65535) * 5 + (((i >>> 16) * 5 & 65535) << 16) | 0, i = (a & 65535) + 27492 + (((a >>> 16) + 58964 & 65535) << 16);
1217
+ switch (c = 0, n) {
1218
+ case 3: c ^= (e.charCodeAt(l + 2) & 255) << 16;
1219
+ case 2: c ^= (e.charCodeAt(l + 1) & 255) << 8;
1220
+ case 1: c ^= e.charCodeAt(l) & 255, c = (c & 65535) * o + (((c >>> 16) * o & 65535) << 16) | 0, c = c << 15 | c >>> 17, c = (c & 65535) * s + (((c >>> 16) * s & 65535) << 16) | 0, i ^= c;
1221
+ }
1222
+ return i ^= e.length, i ^= i >>> 16, i = (i & 65535) * 2246822507 + (((i >>> 16) * 2246822507 & 65535) << 16) | 0, i ^= i >>> 13, i = (i & 65535) * 3266489909 + (((i >>> 16) * 3266489909 & 65535) << 16) | 0, i ^= i >>> 16, i >>> 0;
1223
+ }
1224
+ t !== void 0 && (t.exports = n);
1225
+ })), Wn = /* @__PURE__ */ o(((e, t) => {
1226
+ function n(e, t) {
1227
+ for (var n = e.length, r = t ^ n, i = 0, a; n >= 4;) a = e.charCodeAt(i) & 255 | (e.charCodeAt(++i) & 255) << 8 | (e.charCodeAt(++i) & 255) << 16 | (e.charCodeAt(++i) & 255) << 24, a = (a & 65535) * 1540483477 + (((a >>> 16) * 1540483477 & 65535) << 16), a ^= a >>> 24, a = (a & 65535) * 1540483477 + (((a >>> 16) * 1540483477 & 65535) << 16), r = (r & 65535) * 1540483477 + (((r >>> 16) * 1540483477 & 65535) << 16) ^ a, n -= 4, ++i;
1228
+ switch (n) {
1229
+ case 3: r ^= (e.charCodeAt(i + 2) & 255) << 16;
1230
+ case 2: r ^= (e.charCodeAt(i + 1) & 255) << 8;
1231
+ case 1: r ^= e.charCodeAt(i) & 255, r = (r & 65535) * 1540483477 + (((r >>> 16) * 1540483477 & 65535) << 16);
1232
+ }
1233
+ return r ^= r >>> 13, r = (r & 65535) * 1540483477 + (((r >>> 16) * 1540483477 & 65535) << 16), r ^= r >>> 15, r >>> 0;
1234
+ }
1235
+ t.exports = n;
1236
+ })), Gn = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
1237
+ var n = Un(), r = Wn();
1238
+ t.exports = n, t.exports.murmur3 = n, t.exports.murmur2 = r;
1239
+ })))(), 1), Kn = "__atrament_storage", qn = "NE_ST_NOSTKEX", Jn, Yn = Promise.resolve();
1240
+ async function Xn(e) {
1241
+ let t;
1242
+ try {
1243
+ t = await window.Neutralino.storage.getData(e);
1244
+ } catch (e) {
1245
+ if (e?.code === qn) return;
1246
+ throw e;
1247
+ }
1248
+ return JSON.parse(t);
1249
+ }
1250
+ async function Zn(e, t) {
1251
+ let n = JSON.stringify(t);
1252
+ return await window.Neutralino.storage.setData(e, n), n;
1253
+ }
1254
+ async function Qn(e) {
1255
+ return await window.Neutralino.storage.setData(e, null), !0;
1256
+ }
1257
+ function $n(e) {
1258
+ return `storage_${Jn}_${(0, Gn.default)(e)}`;
1259
+ }
1260
+ function er() {
1261
+ return `${Kn}_${Jn}`;
1262
+ }
1263
+ function tr(e) {
1264
+ let t = Yn.then(async () => {
1265
+ let t = await Xn(er()) ?? {};
1266
+ e(t), await Zn(er(), t);
1267
+ });
1268
+ return Yn = t.catch(() => {}), t;
1269
+ }
1270
+ async function nr(e, t) {
1271
+ return tr((n) => {
1272
+ n[t] = e;
1273
+ });
1274
+ }
1275
+ async function rr(e) {
1276
+ return tr((t) => {
1277
+ delete t[e];
1278
+ });
1279
+ }
1280
+ function ir(e) {
1281
+ Jn = (0, Gn.default)(String(e));
1282
+ }
1283
+ async function ar(e) {
1284
+ return (await lr()).includes(e);
1285
+ }
1286
+ async function or(e) {
1287
+ return Xn($n(e));
1288
+ }
1289
+ async function sr(e, t) {
1290
+ let n = $n(e);
1291
+ await Zn(n, t), await nr(n, e);
1292
+ }
1293
+ async function cr(e) {
1294
+ await Qn($n(e)), await rr(e);
1295
+ }
1296
+ async function lr() {
1297
+ let e = await Xn(er());
1298
+ return Object.keys(e ?? {});
1299
+ }
1300
+ var ur = {
1301
+ driver: "neutralino",
1302
+ init: ir,
1303
+ exists: ar,
1304
+ get: or,
1305
+ set: sr,
1306
+ remove: cr,
1307
+ keys: lr
1308
+ }, dr = !!window.Neutralino, fr = (() => {
1309
+ try {
1310
+ return typeof indexedDB < "u" && indexedDB !== null;
1311
+ } catch {
1312
+ return !1;
1313
+ }
1314
+ })(), pr = (() => {
1315
+ try {
1316
+ let e = window.localStorage, t = "__probe__";
1317
+ return e.setItem(t, t), e.removeItem(t), !0;
1318
+ } catch {
1319
+ return !1;
1320
+ }
1321
+ })();
1322
+ function mr() {
1323
+ return dr ? ur : fr ? Hn : pr ? Dn : null;
1324
+ }
1325
+ // src/interfaces/sound-howler.js
1326
+ var X = (/* @__PURE__ */ o(((e) => {
1327
+ (function() {
1328
+ var t = function() {
1329
+ this.init();
1330
+ };
1331
+ t.prototype = {
1332
+ init: function() {
1333
+ var e = this || n;
1334
+ 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;
1335
+ },
1336
+ volume: function(e) {
1337
+ var t = this || n;
1338
+ if (e = parseFloat(e), t.ctx || u(), e !== void 0 && e >= 0 && e <= 1) {
1339
+ if (t._volume = e, t._muted) return t;
1340
+ t.usingWebAudio && t.masterGain.gain.setValueAtTime(e, n.ctx.currentTime);
1341
+ for (var r = 0; r < t._howls.length; r++) if (!t._howls[r]._webAudio) for (var i = t._howls[r]._getSoundIds(), a = 0; a < i.length; a++) {
1342
+ var o = t._howls[r]._soundById(i[a]);
1343
+ o && o._node && (o._node.volume = o._volume * e);
1344
+ }
1345
+ return t;
1346
+ }
1347
+ return t._volume;
1348
+ },
1349
+ mute: function(e) {
1350
+ var t = this || n;
1351
+ t.ctx || u(), t._muted = e, t.usingWebAudio && t.masterGain.gain.setValueAtTime(e ? 0 : t._volume, n.ctx.currentTime);
1352
+ for (var r = 0; r < t._howls.length; r++) if (!t._howls[r]._webAudio) for (var i = t._howls[r]._getSoundIds(), a = 0; a < i.length; a++) {
1353
+ var o = t._howls[r]._soundById(i[a]);
1354
+ o && o._node && (o._node.muted = e ? !0 : o._muted);
1355
+ }
1356
+ return t;
1357
+ },
1358
+ stop: function() {
1359
+ for (var e = this || n, t = 0; t < e._howls.length; t++) e._howls[t].stop();
1360
+ return e;
1361
+ },
1362
+ unload: function() {
1363
+ for (var e = this || n, t = e._howls.length - 1; t >= 0; t--) e._howls[t].unload();
1364
+ return e.usingWebAudio && e.ctx && e.ctx.close !== void 0 && (e.ctx.close(), e.ctx = null, u()), e;
1365
+ },
1366
+ codecs: function(e) {
1367
+ return (this || n)._codecs[e.replace(/^x-/, "")];
1368
+ },
1369
+ _setup: function() {
1370
+ var e = this || n;
1371
+ if (e.state = e.ctx && e.ctx.state || "suspended", e._autoSuspend(), !e.usingWebAudio) {
1372
+ if (typeof Audio < "u") try {
1373
+ var t = new Audio();
1374
+ t.oncanplaythrough === void 0 && (e._canPlayEvent = "canplay");
1375
+ } catch {
1376
+ e.noAudio = !0;
1377
+ }
1378
+ else e.noAudio = !0;
1379
+ }
1380
+ try {
1381
+ var t = new Audio();
1382
+ t.muted && (e.noAudio = !0);
1383
+ } catch {}
1384
+ return e.noAudio || e._setupCodecs(), e;
1385
+ },
1386
+ _setupCodecs: function() {
1387
+ var e = this || n, t = null;
1388
+ try {
1389
+ t = typeof Audio < "u" ? new Audio() : null;
1390
+ } catch {
1391
+ return e;
1392
+ }
1393
+ if (!t || typeof t.canPlayType != "function") return e;
1394
+ var r = t.canPlayType("audio/mpeg;").replace(/^no$/, ""), i = e._navigator ? e._navigator.userAgent : "", a = i.match(/OPR\/(\d+)/g), o = a && parseInt(a[0].split("/")[1], 10) < 33, s = i.indexOf("Safari") !== -1 && i.indexOf("Chrome") === -1, c = i.match(/Version\/(.*?) /), l = s && c && parseInt(c[1], 10) < 15;
1395
+ return e._codecs = {
1396
+ mp3: !(o || !r && !t.canPlayType("audio/mp3;").replace(/^no$/, "")),
1397
+ mpeg: !!r,
1398
+ opus: !!t.canPlayType("audio/ogg; codecs=\"opus\"").replace(/^no$/, ""),
1399
+ ogg: !!t.canPlayType("audio/ogg; codecs=\"vorbis\"").replace(/^no$/, ""),
1400
+ oga: !!t.canPlayType("audio/ogg; codecs=\"vorbis\"").replace(/^no$/, ""),
1401
+ wav: !!(t.canPlayType("audio/wav; codecs=\"1\"") || t.canPlayType("audio/wav")).replace(/^no$/, ""),
1402
+ aac: !!t.canPlayType("audio/aac;").replace(/^no$/, ""),
1403
+ caf: !!t.canPlayType("audio/x-caf;").replace(/^no$/, ""),
1404
+ m4a: !!(t.canPlayType("audio/x-m4a;") || t.canPlayType("audio/m4a;") || t.canPlayType("audio/aac;")).replace(/^no$/, ""),
1405
+ m4b: !!(t.canPlayType("audio/x-m4b;") || t.canPlayType("audio/m4b;") || t.canPlayType("audio/aac;")).replace(/^no$/, ""),
1406
+ mp4: !!(t.canPlayType("audio/x-mp4;") || t.canPlayType("audio/mp4;") || t.canPlayType("audio/aac;")).replace(/^no$/, ""),
1407
+ weba: !(l || !t.canPlayType("audio/webm; codecs=\"vorbis\"").replace(/^no$/, "")),
1408
+ webm: !(l || !t.canPlayType("audio/webm; codecs=\"vorbis\"").replace(/^no$/, "")),
1409
+ dolby: !!t.canPlayType("audio/mp4; codecs=\"ec-3\"").replace(/^no$/, ""),
1410
+ flac: !!(t.canPlayType("audio/x-flac;") || t.canPlayType("audio/flac;")).replace(/^no$/, "")
1411
+ }, e;
1412
+ },
1413
+ _unlockAudio: function() {
1414
+ var e = this || n;
1415
+ if (!e._audioUnlocked && e.ctx) {
1416
+ 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);
1417
+ var t = function(n) {
1418
+ for (; e._html5AudioPool.length < e.html5PoolSize;) try {
1419
+ var r = new Audio();
1420
+ r._unlocked = !0, e._releaseHtml5Audio(r);
1421
+ } catch {
1422
+ e.noAudio = !0;
1423
+ break;
1424
+ }
1425
+ for (var i = 0; i < e._howls.length; i++) if (!e._howls[i]._webAudio) for (var a = e._howls[i]._getSoundIds(), o = 0; o < a.length; o++) {
1426
+ var s = e._howls[i]._soundById(a[o]);
1427
+ s && s._node && !s._node._unlocked && (s._node._unlocked = !0, s._node.load());
1428
+ }
1429
+ e._autoResume();
1430
+ var c = e.ctx.createBufferSource();
1431
+ c.buffer = e._scratchBuffer, c.connect(e.ctx.destination), c.start === void 0 ? c.noteOn(0) : c.start(0), typeof e.ctx.resume == "function" && e.ctx.resume(), c.onended = function() {
1432
+ c.disconnect(0), e._audioUnlocked = !0, document.removeEventListener("touchstart", t, !0), document.removeEventListener("touchend", t, !0), document.removeEventListener("click", t, !0), document.removeEventListener("keydown", t, !0);
1433
+ for (var n = 0; n < e._howls.length; n++) e._howls[n]._emit("unlock");
1434
+ };
1435
+ };
1436
+ return document.addEventListener("touchstart", t, !0), document.addEventListener("touchend", t, !0), document.addEventListener("click", t, !0), document.addEventListener("keydown", t, !0), e;
1437
+ }
1438
+ },
1439
+ _obtainHtml5Audio: function() {
1440
+ var e = this || n;
1441
+ if (e._html5AudioPool.length) return e._html5AudioPool.pop();
1442
+ var t = new Audio().play();
1443
+ return t && typeof Promise < "u" && (t instanceof Promise || typeof t.then == "function") && t.catch(function() {
1444
+ console.warn("HTML5 Audio pool exhausted, returning potentially locked audio object.");
1445
+ }), new Audio();
1446
+ },
1447
+ _releaseHtml5Audio: function(e) {
1448
+ var t = this || n;
1449
+ return e._unlocked && t._html5AudioPool.push(e), t;
1450
+ },
1451
+ _autoSuspend: function() {
1452
+ var e = this;
1453
+ if (e.autoSuspend && e.ctx && e.ctx.suspend !== void 0 && n.usingWebAudio) {
1454
+ for (var t = 0; t < e._howls.length; t++) if (e._howls[t]._webAudio) {
1455
+ for (var r = 0; r < e._howls[t]._sounds.length; r++) if (!e._howls[t]._sounds[r]._paused) return e;
1456
+ }
1457
+ return e._suspendTimer && clearTimeout(e._suspendTimer), e._suspendTimer = setTimeout(function() {
1458
+ if (e.autoSuspend) {
1459
+ e._suspendTimer = null, e.state = "suspending";
1460
+ var t = function() {
1461
+ e.state = "suspended", e._resumeAfterSuspend && (delete e._resumeAfterSuspend, e._autoResume());
1462
+ };
1463
+ e.ctx.suspend().then(t, t);
1464
+ }
1465
+ }, 3e4), e;
1466
+ }
1467
+ },
1468
+ _autoResume: function() {
1469
+ var e = this;
1470
+ if (e.ctx && e.ctx.resume !== void 0 && n.usingWebAudio) 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() {
1471
+ e.state = "running";
1472
+ for (var t = 0; t < e._howls.length; t++) e._howls[t]._emit("resume");
1473
+ }), e._suspendTimer &&= (clearTimeout(e._suspendTimer), null)) : e.state === "suspending" && (e._resumeAfterSuspend = !0), e;
1474
+ }
1475
+ };
1476
+ var n = new t(), r = function(e) {
1477
+ var t = this;
1478
+ !e.src || e.src.length === 0 ? console.error("An array of source files must be passed with any new Howl.") : t.init(e);
1479
+ };
1480
+ r.prototype = {
1481
+ init: function(e) {
1482
+ var t = this;
1483
+ return n.ctx || u(), t._autoplay = e.autoplay || !1, t._format = typeof e.format == "string" ? [e.format] : e.format, t._html5 = e.html5 || !1, t._muted = e.mute || !1, t._loop = e.loop || !1, t._pool = e.pool || 5, t._preload = typeof e.preload == "boolean" || e.preload === "metadata" ? e.preload : !0, t._rate = e.rate || 1, t._sprite = e.sprite || {}, t._src = typeof e.src == "string" ? [e.src] : e.src, t._volume = e.volume === void 0 ? 1 : e.volume, t._xhr = {
1484
+ method: e.xhr && e.xhr.method ? e.xhr.method : "GET",
1485
+ headers: e.xhr && e.xhr.headers ? e.xhr.headers : null,
1486
+ withCredentials: e.xhr && e.xhr.withCredentials ? e.xhr.withCredentials : !1
1487
+ }, t._duration = 0, t._state = "unloaded", t._sounds = [], t._endTimers = {}, t._queue = [], t._playLock = !1, t._onend = e.onend ? [{ fn: e.onend }] : [], t._onfade = e.onfade ? [{ fn: e.onfade }] : [], t._onload = e.onload ? [{ fn: e.onload }] : [], t._onloaderror = e.onloaderror ? [{ fn: e.onloaderror }] : [], t._onplayerror = e.onplayerror ? [{ fn: e.onplayerror }] : [], t._onpause = e.onpause ? [{ fn: e.onpause }] : [], t._onplay = e.onplay ? [{ fn: e.onplay }] : [], t._onstop = e.onstop ? [{ fn: e.onstop }] : [], t._onmute = e.onmute ? [{ fn: e.onmute }] : [], t._onvolume = e.onvolume ? [{ fn: e.onvolume }] : [], t._onrate = e.onrate ? [{ fn: e.onrate }] : [], t._onseek = e.onseek ? [{ fn: e.onseek }] : [], t._onunlock = e.onunlock ? [{ fn: e.onunlock }] : [], t._onresume = [], t._webAudio = n.usingWebAudio && !t._html5, n.ctx !== void 0 && n.ctx && n.autoUnlock && n._unlockAudio(), n._howls.push(t), t._autoplay && t._queue.push({
1488
+ event: "play",
1489
+ action: function() {
1490
+ t.play();
1491
+ }
1492
+ }), t._preload && t._preload !== "none" && t.load(), t;
1493
+ },
1494
+ load: function() {
1495
+ var e = this, t = null;
1496
+ if (n.noAudio) e._emit("loaderror", null, "No audio support.");
1497
+ else {
1498
+ typeof e._src == "string" && (e._src = [e._src]);
1499
+ for (var r = 0; r < e._src.length; r++) {
1500
+ var a, s;
1501
+ if (e._format && e._format[r]) a = e._format[r];
1502
+ else {
1503
+ if (s = e._src[r], typeof s != "string") {
1504
+ e._emit("loaderror", null, "Non-string found in selected audio sources - ignoring.");
1505
+ continue;
1506
+ }
1507
+ a = /^data:audio\/([^;,]+);/i.exec(s), a ||= /\.([^.]+)$/.exec(s.split("?", 1)[0]), a &&= a[1].toLowerCase();
1508
+ }
1509
+ if (a || console.warn("No file extension was found. Consider using the \"format\" property or specify an extension."), a && n.codecs(a)) {
1510
+ t = e._src[r];
1511
+ break;
1512
+ }
1513
+ }
1514
+ if (!t) e._emit("loaderror", null, "No codec support for selected audio sources.");
1515
+ else return e._src = t, e._state = "loading", window.location.protocol === "https:" && t.slice(0, 5) === "http:" && (e._html5 = !0, e._webAudio = !1), new i(e), e._webAudio && o(e), e;
1516
+ }
1517
+ },
1518
+ play: function(e, t) {
1519
+ var r = this, i = null;
1520
+ if (typeof e == "number") i = e, e = null;
1521
+ else if (typeof e == "string" && r._state === "loaded" && !r._sprite[e]) return null;
1522
+ else if (e === void 0 && (e = "__default", !r._playLock)) {
1523
+ for (var a = 0, o = 0; o < r._sounds.length; o++) r._sounds[o]._paused && !r._sounds[o]._ended && (a++, i = r._sounds[o]._id);
1524
+ a === 1 ? e = null : i = null;
1525
+ }
1526
+ var s = i ? r._soundById(i) : r._inactiveSound();
1527
+ if (!s) return null;
1528
+ if (i && !e && (e = s._sprite || "__default"), r._state !== "loaded") {
1529
+ s._sprite = e, s._ended = !1;
1530
+ var c = s._id;
1531
+ return r._queue.push({
1532
+ event: "play",
1533
+ action: function() {
1534
+ r.play(c);
1535
+ }
1536
+ }), c;
1537
+ }
1538
+ if (i && !s._paused) return t || r._loadQueue("play"), s._id;
1539
+ r._webAudio && n._autoResume();
1540
+ var l = Math.max(0, s._seek > 0 ? s._seek : r._sprite[e][0] / 1e3), u = Math.max(0, (r._sprite[e][0] + r._sprite[e][1]) / 1e3 - l), d = u * 1e3 / Math.abs(s._rate), f = r._sprite[e][0] / 1e3, p = (r._sprite[e][0] + r._sprite[e][1]) / 1e3;
1541
+ s._sprite = e, s._ended = !1;
1542
+ var m = function() {
1543
+ s._paused = !1, s._seek = l, s._start = f, s._stop = p, s._loop = !!(s._loop || r._sprite[e][2]);
1544
+ };
1545
+ if (l >= p) r._ended(s);
1546
+ else {
1547
+ var h = s._node;
1548
+ if (r._webAudio) {
1549
+ var g = function() {
1550
+ r._playLock = !1, m(), r._refreshBuffer(s);
1551
+ var e = s._muted || r._muted ? 0 : s._volume;
1552
+ h.gain.setValueAtTime(e, n.ctx.currentTime), s._playStart = n.ctx.currentTime, h.bufferSource.start === void 0 ? s._loop ? h.bufferSource.noteGrainOn(0, l, 86400) : h.bufferSource.noteGrainOn(0, l, u) : s._loop ? h.bufferSource.start(0, l, 86400) : h.bufferSource.start(0, l, u), d !== Infinity && (r._endTimers[s._id] = setTimeout(r._ended.bind(r, s), d)), t || setTimeout(function() {
1553
+ r._emit("play", s._id), r._loadQueue();
1554
+ }, 0);
1555
+ };
1556
+ n.state === "running" && n.ctx.state !== "interrupted" ? g() : (r._playLock = !0, r.once("resume", g), r._clearTimer(s._id));
1557
+ } else {
1558
+ var _ = function() {
1559
+ h.currentTime = l, h.muted = s._muted || r._muted || n._muted || h.muted, h.volume = s._volume * n.volume(), h.playbackRate = s._rate;
1560
+ try {
1561
+ var i = h.play();
1562
+ if (i && typeof Promise < "u" && (i instanceof Promise || typeof i.then == "function") ? (r._playLock = !0, m(), i.then(function() {
1563
+ r._playLock = !1, h._unlocked = !0, t ? r._loadQueue() : r._emit("play", s._id);
1564
+ }).catch(function() {
1565
+ r._playLock = !1, r._emit("playerror", s._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."), s._ended = !0, s._paused = !0;
1566
+ })) : t || (r._playLock = !1, m(), r._emit("play", s._id)), h.playbackRate = s._rate, h.paused) {
1567
+ r._emit("playerror", s._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.");
1568
+ return;
1569
+ }
1570
+ e !== "__default" || s._loop ? r._endTimers[s._id] = setTimeout(r._ended.bind(r, s), d) : (r._endTimers[s._id] = function() {
1571
+ r._ended(s), h.removeEventListener("ended", r._endTimers[s._id], !1);
1572
+ }, h.addEventListener("ended", r._endTimers[s._id], !1));
1573
+ } catch (e) {
1574
+ r._emit("playerror", s._id, e);
1575
+ }
1576
+ };
1577
+ h.src === "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA" && (h.src = r._src, h.load());
1578
+ var v = window && window.ejecta || !h.readyState && n._navigator.isCocoonJS;
1579
+ if (h.readyState >= 3 || v) _();
1580
+ else {
1581
+ r._playLock = !0, r._state = "loading";
1582
+ var y = function() {
1583
+ r._state = "loaded", _(), h.removeEventListener(n._canPlayEvent, y, !1);
1584
+ };
1585
+ h.addEventListener(n._canPlayEvent, y, !1), r._clearTimer(s._id);
1586
+ }
1587
+ }
1588
+ return s._id;
1589
+ }
1590
+ },
1591
+ pause: function(e) {
1592
+ var t = this;
1593
+ if (t._state !== "loaded" || t._playLock) return t._queue.push({
1594
+ event: "pause",
1595
+ action: function() {
1596
+ t.pause(e);
1597
+ }
1598
+ }), t;
1599
+ for (var n = t._getSoundIds(e), r = 0; r < n.length; r++) {
1600
+ t._clearTimer(n[r]);
1601
+ var i = t._soundById(n[r]);
1602
+ if (i && !i._paused && (i._seek = t.seek(n[r]), i._rateSeek = 0, i._paused = !0, t._stopFade(n[r]), i._node)) {
1603
+ if (t._webAudio) {
1604
+ if (!i._node.bufferSource) continue;
1605
+ i._node.bufferSource.stop === void 0 ? i._node.bufferSource.noteOff(0) : i._node.bufferSource.stop(0), t._cleanBuffer(i._node);
1606
+ } else isNaN(i._node.duration) && i._node.duration !== Infinity || i._node.pause();
1607
+ }
1608
+ arguments[1] || t._emit("pause", i ? i._id : null);
1609
+ }
1610
+ return t;
1611
+ },
1612
+ stop: function(e, t) {
1613
+ var n = this;
1614
+ if (n._state !== "loaded" || n._playLock) return n._queue.push({
1615
+ event: "stop",
1616
+ action: function() {
1617
+ n.stop(e);
1618
+ }
1619
+ }), n;
1620
+ for (var r = n._getSoundIds(e), i = 0; i < r.length; i++) {
1621
+ n._clearTimer(r[i]);
1622
+ var a = n._soundById(r[i]);
1623
+ a && (a._seek = a._start || 0, a._rateSeek = 0, a._paused = !0, a._ended = !0, n._stopFade(r[i]), a._node && (n._webAudio ? a._node.bufferSource && (a._node.bufferSource.stop === void 0 ? a._node.bufferSource.noteOff(0) : a._node.bufferSource.stop(0), n._cleanBuffer(a._node)) : isNaN(a._node.duration) && a._node.duration !== Infinity || (a._node.currentTime = a._start || 0, a._node.pause(), a._node.duration === Infinity && n._clearSound(a._node))), t || n._emit("stop", a._id));
1624
+ }
1625
+ return n;
1626
+ },
1627
+ mute: function(e, t) {
1628
+ var r = this;
1629
+ if (r._state !== "loaded" || r._playLock) return r._queue.push({
1630
+ event: "mute",
1631
+ action: function() {
1632
+ r.mute(e, t);
1633
+ }
1634
+ }), r;
1635
+ if (t === void 0) {
1636
+ if (typeof e == "boolean") r._muted = e;
1637
+ else return r._muted;
1638
+ }
1639
+ for (var i = r._getSoundIds(t), a = 0; a < i.length; a++) {
1640
+ var o = r._soundById(i[a]);
1641
+ o && (o._muted = e, o._interval && r._stopFade(o._id), r._webAudio && o._node ? o._node.gain.setValueAtTime(e ? 0 : o._volume, n.ctx.currentTime) : o._node && (o._node.muted = n._muted ? !0 : e), r._emit("mute", o._id));
1642
+ }
1643
+ return r;
1644
+ },
1645
+ volume: function() {
1646
+ var e = this, t = arguments, r, i;
1647
+ if (t.length === 0) return e._volume;
1648
+ t.length === 1 || t.length === 2 && t[1] === void 0 ? e._getSoundIds().indexOf(t[0]) >= 0 ? i = parseInt(t[0], 10) : r = parseFloat(t[0]) : t.length >= 2 && (r = parseFloat(t[0]), i = parseInt(t[1], 10));
1649
+ var a;
1650
+ if (r !== void 0 && r >= 0 && r <= 1) {
1651
+ if (e._state !== "loaded" || e._playLock) return e._queue.push({
1652
+ event: "volume",
1653
+ action: function() {
1654
+ e.volume.apply(e, t);
1655
+ }
1656
+ }), e;
1657
+ i === void 0 && (e._volume = r), i = e._getSoundIds(i);
1658
+ for (var o = 0; o < i.length; o++) a = e._soundById(i[o]), a && (a._volume = r, t[2] || e._stopFade(i[o]), e._webAudio && a._node && !a._muted ? a._node.gain.setValueAtTime(r, n.ctx.currentTime) : a._node && !a._muted && (a._node.volume = r * n.volume()), e._emit("volume", a._id));
1659
+ } else return a = i ? e._soundById(i) : e._sounds[0], a ? a._volume : 0;
1660
+ return e;
1661
+ },
1662
+ fade: function(e, t, r, i) {
1663
+ var a = this;
1664
+ if (a._state !== "loaded" || a._playLock) return a._queue.push({
1665
+ event: "fade",
1666
+ action: function() {
1667
+ a.fade(e, t, r, i);
1668
+ }
1669
+ }), a;
1670
+ e = Math.min(Math.max(0, parseFloat(e)), 1), t = Math.min(Math.max(0, parseFloat(t)), 1), r = parseFloat(r), a.volume(e, i);
1671
+ for (var o = a._getSoundIds(i), s = 0; s < o.length; s++) {
1672
+ var c = a._soundById(o[s]);
1673
+ if (c) {
1674
+ if (i || a._stopFade(o[s]), a._webAudio && !c._muted) {
1675
+ var l = n.ctx.currentTime, u = l + r / 1e3;
1676
+ c._volume = e, c._node.gain.setValueAtTime(e, l), c._node.gain.linearRampToValueAtTime(t, u);
1677
+ }
1678
+ a._startFadeInterval(c, e, t, r, o[s], i === void 0);
1679
+ }
1680
+ }
1681
+ return a;
1682
+ },
1683
+ _startFadeInterval: function(e, t, n, r, i, a) {
1684
+ var o = this, s = t, c = n - t, l = Math.abs(c / .01), u = Math.max(4, l > 0 ? r / l : r), d = Date.now();
1685
+ e._fadeTo = n, e._interval = setInterval(function() {
1686
+ var i = (Date.now() - d) / r;
1687
+ d = Date.now(), s += c * i, s = Math.round(s * 100) / 100, s = c < 0 ? Math.max(n, s) : Math.min(n, s), o._webAudio ? e._volume = s : o.volume(s, e._id, !0), a && (o._volume = s), (n < t && s <= n || n > t && s >= n) && (clearInterval(e._interval), e._interval = null, e._fadeTo = null, o.volume(n, e._id), o._emit("fade", e._id));
1688
+ }, u);
1689
+ },
1690
+ _stopFade: function(e) {
1691
+ var t = this, r = t._soundById(e);
1692
+ return r && r._interval && (t._webAudio && r._node.gain.cancelScheduledValues(n.ctx.currentTime), clearInterval(r._interval), r._interval = null, t.volume(r._fadeTo, e), r._fadeTo = null, t._emit("fade", e)), t;
1693
+ },
1694
+ loop: function() {
1695
+ var e = this, t = arguments, n, r, i;
1696
+ if (t.length === 0) return e._loop;
1697
+ if (t.length === 1) {
1698
+ if (typeof t[0] == "boolean") n = t[0], e._loop = n;
1699
+ else return i = e._soundById(parseInt(t[0], 10)), i ? i._loop : !1;
1700
+ } else t.length === 2 && (n = t[0], r = parseInt(t[1], 10));
1701
+ for (var a = e._getSoundIds(r), o = 0; o < a.length; o++) i = e._soundById(a[o]), i && (i._loop = n, e._webAudio && i._node && i._node.bufferSource && (i._node.bufferSource.loop = n, n && (i._node.bufferSource.loopStart = i._start || 0, i._node.bufferSource.loopEnd = i._stop, e.playing(a[o]) && (e.pause(a[o], !0), e.play(a[o], !0)))));
1702
+ return e;
1703
+ },
1704
+ rate: function() {
1705
+ var e = this, t = arguments, r, i;
1706
+ t.length === 0 ? i = e._sounds[0]._id : t.length === 1 ? e._getSoundIds().indexOf(t[0]) >= 0 ? i = parseInt(t[0], 10) : r = parseFloat(t[0]) : t.length === 2 && (r = parseFloat(t[0]), i = parseInt(t[1], 10));
1707
+ var a;
1708
+ if (typeof r == "number") {
1709
+ if (e._state !== "loaded" || e._playLock) return e._queue.push({
1710
+ event: "rate",
1711
+ action: function() {
1712
+ e.rate.apply(e, t);
1713
+ }
1714
+ }), e;
1715
+ i === void 0 && (e._rate = r), i = e._getSoundIds(i);
1716
+ for (var o = 0; o < i.length; o++) if (a = e._soundById(i[o]), a) {
1717
+ e.playing(i[o]) && (a._rateSeek = e.seek(i[o]), a._playStart = e._webAudio ? n.ctx.currentTime : a._playStart), a._rate = r, e._webAudio && a._node && a._node.bufferSource ? a._node.bufferSource.playbackRate.setValueAtTime(r, n.ctx.currentTime) : a._node && (a._node.playbackRate = r);
1718
+ var s = e.seek(i[o]), c = ((e._sprite[a._sprite][0] + e._sprite[a._sprite][1]) / 1e3 - s) * 1e3 / Math.abs(a._rate);
1719
+ (e._endTimers[i[o]] || !a._paused) && (e._clearTimer(i[o]), e._endTimers[i[o]] = setTimeout(e._ended.bind(e, a), c)), e._emit("rate", a._id);
1720
+ }
1721
+ } else return a = e._soundById(i), a ? a._rate : e._rate;
1722
+ return e;
1723
+ },
1724
+ seek: function() {
1725
+ var e = this, t = arguments, r, i;
1726
+ if (t.length === 0 ? e._sounds.length && (i = e._sounds[0]._id) : t.length === 1 ? e._getSoundIds().indexOf(t[0]) >= 0 ? i = parseInt(t[0], 10) : e._sounds.length && (i = e._sounds[0]._id, r = parseFloat(t[0])) : t.length === 2 && (r = parseFloat(t[0]), i = parseInt(t[1], 10)), i === void 0) return 0;
1727
+ if (typeof r == "number" && (e._state !== "loaded" || e._playLock)) return e._queue.push({
1728
+ event: "seek",
1729
+ action: function() {
1730
+ e.seek.apply(e, t);
1731
+ }
1732
+ }), e;
1733
+ var a = e._soundById(i);
1734
+ if (a) {
1735
+ if (typeof r == "number" && r >= 0) {
1736
+ var o = e.playing(i);
1737
+ o && e.pause(i, !0), a._seek = r, a._ended = !1, e._clearTimer(i), !e._webAudio && a._node && !isNaN(a._node.duration) && (a._node.currentTime = r);
1738
+ var s = function() {
1739
+ o && e.play(i, !0), e._emit("seek", i);
1740
+ };
1741
+ if (o && !e._webAudio) {
1742
+ var c = function() {
1743
+ e._playLock ? setTimeout(c, 0) : s();
1744
+ };
1745
+ setTimeout(c, 0);
1746
+ } else s();
1747
+ } else if (e._webAudio) {
1748
+ var l = e.playing(i) ? n.ctx.currentTime - a._playStart : 0, u = a._rateSeek ? a._rateSeek - a._seek : 0;
1749
+ return a._seek + (u + l * Math.abs(a._rate));
1750
+ } else return a._node.currentTime;
1751
+ }
1752
+ return e;
1753
+ },
1754
+ playing: function(e) {
1755
+ var t = this;
1756
+ if (typeof e == "number") {
1757
+ var n = t._soundById(e);
1758
+ return n ? !n._paused : !1;
1759
+ }
1760
+ for (var r = 0; r < t._sounds.length; r++) if (!t._sounds[r]._paused) return !0;
1761
+ return !1;
1762
+ },
1763
+ duration: function(e) {
1764
+ var t = this, n = t._duration, r = t._soundById(e);
1765
+ return r && (n = t._sprite[r._sprite][1] / 1e3), n;
1766
+ },
1767
+ state: function() {
1768
+ return this._state;
1769
+ },
1770
+ unload: function() {
1771
+ for (var e = this, t = e._sounds, r = 0; r < t.length; r++) t[r]._paused || e.stop(t[r]._id), e._webAudio || (e._clearSound(t[r]._node), t[r]._node.removeEventListener("error", t[r]._errorFn, !1), t[r]._node.removeEventListener(n._canPlayEvent, t[r]._loadFn, !1), t[r]._node.removeEventListener("ended", t[r]._endFn, !1), n._releaseHtml5Audio(t[r]._node)), delete t[r]._node, e._clearTimer(t[r]._id);
1772
+ var i = n._howls.indexOf(e);
1773
+ i >= 0 && n._howls.splice(i, 1);
1774
+ var o = !0;
1775
+ for (r = 0; r < n._howls.length; r++) if (n._howls[r]._src === e._src || e._src.indexOf(n._howls[r]._src) >= 0) {
1776
+ o = !1;
1777
+ break;
1778
+ }
1779
+ return a && o && delete a[e._src], n.noAudio = !1, e._state = "unloaded", e._sounds = [], e = null, null;
1780
+ },
1781
+ on: function(e, t, n, r) {
1782
+ var i = this, a = i["_on" + e];
1783
+ return typeof t == "function" && a.push(r ? {
1784
+ id: n,
1785
+ fn: t,
1786
+ once: r
1787
+ } : {
1788
+ id: n,
1789
+ fn: t
1790
+ }), i;
1791
+ },
1792
+ off: function(e, t, n) {
1793
+ var r = this, i = r["_on" + e], a = 0;
1794
+ if (typeof t == "number" && (n = t, t = null), t || n) for (a = 0; a < i.length; a++) {
1795
+ var o = n === i[a].id;
1796
+ if (t === i[a].fn && o || !t && o) {
1797
+ i.splice(a, 1);
1798
+ break;
1799
+ }
1800
+ }
1801
+ else if (e) r["_on" + e] = [];
1802
+ else {
1803
+ var s = Object.keys(r);
1804
+ for (a = 0; a < s.length; a++) s[a].indexOf("_on") === 0 && Array.isArray(r[s[a]]) && (r[s[a]] = []);
1805
+ }
1806
+ return r;
1807
+ },
1808
+ once: function(e, t, n) {
1809
+ var r = this;
1810
+ return r.on(e, t, n, 1), r;
1811
+ },
1812
+ _emit: function(e, t, n) {
1813
+ for (var r = this, i = r["_on" + e], a = i.length - 1; a >= 0; a--) i[a].id && i[a].id !== t && e !== "load" || (setTimeout(function(e) {
1814
+ e.call(this, t, n);
1815
+ }.bind(r, i[a].fn), 0), i[a].once && r.off(e, i[a].fn, i[a].id));
1816
+ return r._loadQueue(e), r;
1817
+ },
1818
+ _loadQueue: function(e) {
1819
+ var t = this;
1820
+ if (t._queue.length > 0) {
1821
+ var n = t._queue[0];
1822
+ n.event === e && (t._queue.shift(), t._loadQueue()), e || n.action();
1823
+ }
1824
+ return t;
1825
+ },
1826
+ _ended: function(e) {
1827
+ var t = this, r = e._sprite;
1828
+ if (!t._webAudio && e._node && !e._node.paused && !e._node.ended && e._node.currentTime < e._stop) return setTimeout(t._ended.bind(t, e), 100), t;
1829
+ var i = !!(e._loop || t._sprite[r][2]);
1830
+ if (t._emit("end", e._id), !t._webAudio && i && t.stop(e._id, !0).play(e._id), t._webAudio && i) {
1831
+ t._emit("play", e._id), e._seek = e._start || 0, e._rateSeek = 0, e._playStart = n.ctx.currentTime;
1832
+ var a = (e._stop - e._start) * 1e3 / Math.abs(e._rate);
1833
+ t._endTimers[e._id] = setTimeout(t._ended.bind(t, e), a);
1834
+ }
1835
+ return t._webAudio && !i && (e._paused = !0, e._ended = !0, e._seek = e._start || 0, e._rateSeek = 0, t._clearTimer(e._id), t._cleanBuffer(e._node), n._autoSuspend()), !t._webAudio && !i && t.stop(e._id, !0), t;
1836
+ },
1837
+ _clearTimer: function(e) {
1838
+ var t = this;
1839
+ if (t._endTimers[e]) {
1840
+ if (typeof t._endTimers[e] != "function") clearTimeout(t._endTimers[e]);
1841
+ else {
1842
+ var n = t._soundById(e);
1843
+ n && n._node && n._node.removeEventListener("ended", t._endTimers[e], !1);
1844
+ }
1845
+ delete t._endTimers[e];
1846
+ }
1847
+ return t;
1848
+ },
1849
+ _soundById: function(e) {
1850
+ for (var t = this, n = 0; n < t._sounds.length; n++) if (e === t._sounds[n]._id) return t._sounds[n];
1851
+ return null;
1852
+ },
1853
+ _inactiveSound: function() {
1854
+ var e = this;
1855
+ e._drain();
1856
+ for (var t = 0; t < e._sounds.length; t++) if (e._sounds[t]._ended) return e._sounds[t].reset();
1857
+ return new i(e);
1858
+ },
1859
+ _drain: function() {
1860
+ var e = this, t = e._pool, n = 0, r = 0;
1861
+ if (!(e._sounds.length < t)) {
1862
+ for (r = 0; r < e._sounds.length; r++) e._sounds[r]._ended && n++;
1863
+ for (r = e._sounds.length - 1; r >= 0; r--) {
1864
+ if (n <= t) return;
1865
+ e._sounds[r]._ended && (e._webAudio && e._sounds[r]._node && e._sounds[r]._node.disconnect(0), e._sounds.splice(r, 1), n--);
1866
+ }
1867
+ }
1868
+ },
1869
+ _getSoundIds: function(e) {
1870
+ var t = this;
1871
+ if (e === void 0) {
1872
+ for (var n = [], r = 0; r < t._sounds.length; r++) n.push(t._sounds[r]._id);
1873
+ return n;
1874
+ }
1875
+ return [e];
1876
+ },
1877
+ _refreshBuffer: function(e) {
1878
+ var t = this;
1879
+ return e._node.bufferSource = n.ctx.createBufferSource(), e._node.bufferSource.buffer = a[t._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), t;
1880
+ },
1881
+ _cleanBuffer: function(e) {
1882
+ var t = this, r = n._navigator && n._navigator.vendor.indexOf("Apple") >= 0;
1883
+ if (!e.bufferSource) return t;
1884
+ if (n._scratchBuffer && e.bufferSource && (e.bufferSource.onended = null, e.bufferSource.disconnect(0), r)) try {
1885
+ e.bufferSource.buffer = n._scratchBuffer;
1886
+ } catch {}
1887
+ return e.bufferSource = null, t;
1888
+ },
1889
+ _clearSound: function(e) {
1890
+ /MSIE |Trident\//.test(n._navigator && n._navigator.userAgent) || (e.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA");
1891
+ }
1892
+ };
1893
+ var i = function(e) {
1894
+ this._parent = e, this.init();
1895
+ };
1896
+ i.prototype = {
1897
+ init: function() {
1898
+ var e = this, t = e._parent;
1899
+ return e._muted = t._muted, e._loop = t._loop, e._volume = t._volume, e._rate = t._rate, e._seek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++n._counter, t._sounds.push(e), e.create(), e;
1900
+ },
1901
+ create: function() {
1902
+ var e = this, t = e._parent, r = n._muted || e._muted || e._parent._muted ? 0 : e._volume;
1903
+ return t._webAudio ? (e._node = n.ctx.createGain === void 0 ? n.ctx.createGainNode() : n.ctx.createGain(), e._node.gain.setValueAtTime(r, 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 = t._src, e._node.preload = t._preload === !0 ? "auto" : t._preload, e._node.volume = r * n.volume(), e._node.load()), e;
1904
+ },
1905
+ reset: function() {
1906
+ var e = this, t = e._parent;
1907
+ return e._muted = t._muted, e._loop = t._loop, e._volume = t._volume, e._rate = t._rate, e._seek = 0, e._rateSeek = 0, e._paused = !0, e._ended = !0, e._sprite = "__default", e._id = ++n._counter, e;
1908
+ },
1909
+ _errorListener: function() {
1910
+ var e = this;
1911
+ e._parent._emit("loaderror", e._id, e._node.error ? e._node.error.code : 0), e._node.removeEventListener("error", e._errorFn, !1);
1912
+ },
1913
+ _loadListener: function() {
1914
+ var e = this, t = e._parent;
1915
+ t._duration = Math.ceil(e._node.duration * 10) / 10, Object.keys(t._sprite).length === 0 && (t._sprite = { __default: [0, t._duration * 1e3] }), t._state !== "loaded" && (t._state = "loaded", t._emit("load"), t._loadQueue()), e._node.removeEventListener(n._canPlayEvent, e._loadFn, !1);
1916
+ },
1917
+ _endListener: function() {
1918
+ var e = this, t = e._parent;
1919
+ t._duration === Infinity && (t._duration = Math.ceil(e._node.duration * 10) / 10, t._sprite.__default[1] === Infinity && (t._sprite.__default[1] = t._duration * 1e3), t._ended(e)), e._node.removeEventListener("ended", e._endFn, !1);
1920
+ }
1921
+ };
1922
+ var a = {}, o = function(e) {
1923
+ var t = e._src;
1924
+ if (a[t]) e._duration = a[t].duration, l(e);
1925
+ else if (/^data:[^;]+;base64,/.test(t)) {
1926
+ for (var n = atob(t.split(",")[1]), r = new Uint8Array(n.length), i = 0; i < n.length; ++i) r[i] = n.charCodeAt(i);
1927
+ c(r.buffer, e);
1928
+ } else {
1929
+ var o = new XMLHttpRequest();
1930
+ o.open(e._xhr.method, t, !0), o.withCredentials = e._xhr.withCredentials, o.responseType = "arraybuffer", e._xhr.headers && Object.keys(e._xhr.headers).forEach(function(t) {
1931
+ o.setRequestHeader(t, e._xhr.headers[t]);
1932
+ }), o.onload = function() {
1933
+ var t = (o.status + "")[0];
1934
+ t !== "0" && t !== "2" && t !== "3" ? e._emit("loaderror", null, "Failed loading audio file with status: " + o.status + ".") : c(o.response, e);
1935
+ }, o.onerror = function() {
1936
+ e._webAudio && (e._html5 = !0, e._webAudio = !1, e._sounds = [], delete a[t], e.load());
1937
+ }, s(o);
1938
+ }
1939
+ }, s = function(e) {
1940
+ try {
1941
+ e.send();
1942
+ } catch {
1943
+ e.onerror();
1944
+ }
1945
+ }, c = function(e, t) {
1946
+ var r = function() {
1947
+ t._emit("loaderror", null, "Decoding audio data failed.");
1948
+ }, i = function(e) {
1949
+ e && t._sounds.length > 0 ? (a[t._src] = e, l(t, e)) : r();
1950
+ };
1951
+ typeof Promise < "u" && n.ctx.decodeAudioData.length === 1 ? n.ctx.decodeAudioData(e).then(i).catch(r) : n.ctx.decodeAudioData(e, i, r);
1952
+ }, l = function(e, t) {
1953
+ t && !e._duration && (e._duration = t.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());
1954
+ }, u = function() {
1955
+ if (n.usingWebAudio) {
1956
+ try {
1957
+ typeof AudioContext < "u" ? n.ctx = new AudioContext() : typeof webkitAudioContext < "u" ? n.ctx = new webkitAudioContext() : n.usingWebAudio = !1;
1958
+ } catch {
1959
+ n.usingWebAudio = !1;
1960
+ }
1961
+ n.ctx || (n.usingWebAudio = !1);
1962
+ var e = /iP(hone|od|ad)/.test(n._navigator && n._navigator.platform), t = n._navigator && n._navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/), r = t ? parseInt(t[1], 10) : null;
1963
+ if (e && r && r < 9) {
1964
+ var i = /safari/.test(n._navigator && n._navigator.userAgent.toLowerCase());
1965
+ n._navigator && !i && (n.usingWebAudio = !1);
1966
+ }
1967
+ n.usingWebAudio && (n.masterGain = n.ctx.createGain === void 0 ? 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();
1968
+ }
1969
+ };
1970
+ typeof define == "function" && define.amd && define([], function() {
1971
+ return {
1972
+ Howler: n,
1973
+ Howl: r
1974
+ };
1975
+ }), e !== void 0 && (e.Howler = n, e.Howl = r), typeof global < "u" ? (global.HowlerGlobal = t, global.Howler = n, global.Howl = r, global.Sound = i) : typeof window < "u" && (window.HowlerGlobal = t, window.Howler = n, window.Howl = r, window.Sound = i);
1976
+ })();
1977
+ })))(), hr = {}, Z = {};
1978
+ function gr(e) {
1979
+ if (e.fade && e.playing()) {
1980
+ let t = e.volume();
1981
+ e.fade(t, 0, 1), e.stop(), e.volume(t);
1982
+ }
1983
+ e.stop();
1984
+ }
1985
+ function _r(e, t) {
1986
+ let n = e ? [e] : Object.keys(t);
1987
+ return n.forEach((e) => {
1988
+ t[e] && gr(t[e]);
1989
+ }), n;
1990
+ }
1991
+ function vr(e) {
1992
+ yr(e.mute === !0), xr(e.volume);
1993
+ }
1994
+ function yr(e = !0) {
1995
+ X.Howler.mute(e);
1996
+ }
1997
+ function br() {
1998
+ return X.Howler._muted;
1999
+ }
2000
+ function xr(e) {
2001
+ X.Howler.volume(e / 100);
2002
+ }
2003
+ function Sr() {
2004
+ return X.Howler.volume() * 100;
2005
+ }
2006
+ function Cr(e) {
2007
+ hr[e] ||= new X.Howl({ src: [e] }), hr[e].play();
2008
+ }
2009
+ function wr(e) {
2010
+ _r(e, hr);
2011
+ }
2012
+ function Tr(e, t = !0) {
2013
+ Z[e] ||= new X.Howl({
2014
+ src: [e],
2015
+ html5: !0,
2016
+ loop: t
2017
+ });
2018
+ let n = Z[e];
2019
+ n.loop(t), n.playing() || n.state() === "loading" || n.play();
2020
+ }
2021
+ function Er(e) {
2022
+ _r(e, Z).forEach((e) => {
2023
+ Z[e] && (Z[e].unload(), delete Z[e]);
2024
+ });
2025
+ }
2026
+ function Dr() {
2027
+ [hr, Z].forEach((e) => {
2028
+ Object.keys(e).forEach((t) => {
2029
+ e[t].unload(), delete e[t];
2030
+ });
2031
+ });
2032
+ }
2033
+ var Or = {
2034
+ init: vr,
2035
+ reset: Dr,
2036
+ mute: yr,
2037
+ isMuted: br,
2038
+ setVolume: xr,
2039
+ getVolume: Sr,
2040
+ playSound: Cr,
2041
+ stopSound: wr,
2042
+ playMusic: Tr,
2043
+ stopMusic: Er
2044
+ }, kr = Symbol("clean"), Q = [], Ar = 0, jr = null, Mr = 4, Nr = globalThis.nanostoresGlobal ||= { epoch: 0 }, Pr = () => {
2045
+ let e, t;
2046
+ for (; Ar < Q.length;) {
2047
+ t = Ar, Ar += Mr;
2048
+ let n = jr?.get(Q[t]);
2049
+ if (n) {
2050
+ if (!n.has(Q[t + 1])) continue;
2051
+ n.clear();
2052
+ }
2053
+ try {
2054
+ Q[t](Q[t + 1].value, Q[t + 2], Q[t + 3]);
2055
+ } catch (t) {
2056
+ e = t;
2057
+ }
2058
+ }
2059
+ if (Q.length = Ar = 0, e) throw e;
2060
+ }, Fr = /* @__NO_SIDE_EFFECTS__ */ (e) => {
2061
+ let t = [], n = {
2062
+ eq: Object.is,
2063
+ get() {
2064
+ return n.lc || n.listen(() => {})(), n.value;
2065
+ },
2066
+ init: e,
2067
+ lc: 0,
2068
+ listen(e) {
2069
+ return n.lc = t.push(e), () => {
2070
+ jr?.get(e)?.delete(n);
2071
+ for (let t = Ar; t < Q.length;) Q[t] === e && Q[t + 1] === n ? Q.splice(t, Mr) : t += Mr;
2072
+ let r = t.indexOf(e);
2073
+ ~r && (t.splice(r, 1), --n.lc || n.off());
2074
+ };
2075
+ },
2076
+ notify(e, r) {
2077
+ Nr.epoch++;
2078
+ let i = !Q.length && !0;
2079
+ for (let i of t) Q.push(i, n, e, r);
2080
+ i && Pr();
2081
+ },
2082
+ off() {},
2083
+ set(e) {
2084
+ let t = n.value;
2085
+ n.eq(t, e) || (n.value = e, n.notify(t));
2086
+ },
2087
+ subscribe(e) {
2088
+ let t = n.listen(e);
2089
+ return e(n.value), t;
2090
+ },
2091
+ value: e
2092
+ };
2093
+ return process.env.NODE_ENV !== "production" && (n[kr] = () => {
2094
+ t = [], n.lc = 0, n.off();
2095
+ }), n;
2096
+ }, $ = /* @__PURE__ */ /* @__NO_SIDE_EFFECTS__ */ ((e = {}) => {
2097
+ let t = /* @__PURE__ */ Fr(e);
2098
+ return t.eqKey = Object.is, t.setKey = function(e, n) {
2099
+ let r = t.value;
2100
+ n === void 0 && e in t.value ? (t.value = { ...t.value }, delete t.value[e], t.notify(r, e)) : t.eqKey(t.value[e], n, e) || (t.value = {
2101
+ ...t.value,
2102
+ [e]: n
2103
+ }, t.notify(r, e));
2104
+ }, t;
2105
+ })({
2106
+ settings: {},
2107
+ game: {},
2108
+ metadata: {},
2109
+ scenes: [],
2110
+ vars: {}
2484
2111
  });
2485
- function Aa() {
2486
- return T;
2487
- }
2488
- function Sa() {
2489
- return T.get();
2490
- }
2491
- const xa = (t, n) => (T.setKey(t, n), T.get()), ka = (t) => (T.setKey(t, !T.get()[t]), T.get()), Ta = (t, n) => (T.setKey(t, [...T.get()[t], n]), T.get()), Ea = (t, n, r) => (T.setKey(t, { ...T.get()[t], [n]: r }), T.get()), Ia = (t, n) => (T.setKey(t, { ...T.get()[t], [n]: !T.get()[t][n] }), T.get()), Ca = (t, n, r) => (T.setKey(t, { ...T.get()[t], [n]: [...T.get()[t][n], r] }), T.get()), Oa = {
2492
- store: Aa,
2493
- get: Sa,
2494
- setKey: xa,
2495
- toggleKey: ka,
2496
- appendKey: Ta,
2497
- setSubkey: Ea,
2498
- toggleSubkey: Ia,
2499
- appendSubkey: Ca
2500
- };
2501
- async function Pa(t, n) {
2502
- if (t && !document.fullscreenElement)
2503
- try {
2504
- await document.documentElement.requestFullscreen();
2505
- } catch {
2506
- n(!1);
2507
- }
2508
- else document.fullscreenElement && document.exitFullscreen && document.exitFullscreen();
2509
- }
2510
- function $a(t) {
2511
- document.title = t;
2512
- }
2513
- const La = {
2514
- setFullscreen: Pa,
2515
- setTitle: $a
2112
+ function Ir() {
2113
+ return $;
2114
+ }
2115
+ function Lr() {
2116
+ return $.get();
2117
+ }
2118
+ var Rr = {
2119
+ store: Ir,
2120
+ get: Lr,
2121
+ setKey: (e, t) => ($.setKey(e, t), $.get()),
2122
+ toggleKey: (e) => ($.setKey(e, !$.get()[e]), $.get()),
2123
+ appendKey: (e, t) => ($.setKey(e, [...$.get()[e], t]), $.get()),
2124
+ setSubkey: (e, t, n) => ($.setKey(e, {
2125
+ ...$.get()[e],
2126
+ [t]: n
2127
+ }), $.get()),
2128
+ toggleSubkey: (e, t) => ($.setKey(e, {
2129
+ ...$.get()[e],
2130
+ [t]: !$.get()[e][t]
2131
+ }), $.get()),
2132
+ appendSubkey: (e, t, n) => ($.setKey(e, {
2133
+ ...$.get()[e],
2134
+ [t]: [...$.get()[e][t], n]
2135
+ }), $.get())
2516
2136
  };
2517
- async function Fa(t) {
2518
- t ? await window.Neutralino.window.setFullScreen() : await window.Neutralino.window.exitFullScreen();
2519
- }
2520
- async function Ma(t) {
2521
- await window.Neutralino.window.setTitle(t);
2522
- }
2523
- async function Ba() {
2524
- await window.Neutralino.app.exit();
2525
- }
2526
- const Na = {
2527
- setFullscreen: Fa,
2528
- setTitle: Ma,
2529
- exitApp: Ba
2530
- };
2531
- _r.defineInterfaces({
2532
- loader: Nr,
2533
- persistent: window.Neutralino ? fa : jr,
2534
- sound: ga,
2535
- state: Oa,
2536
- platform: window.Neutralino ? Na : La
2537
- });
2538
- export {
2539
- _r as default
2137
+ // src/interfaces/platform-web.js
2138
+ function zr() {
2139
+ return document.fullscreenElement ?? document.webkitFullscreenElement ?? null;
2140
+ }
2141
+ async function Br(e) {
2142
+ if (e.requestFullscreen) await e.requestFullscreen();
2143
+ else if (e.webkitRequestFullscreen) await e.webkitRequestFullscreen();
2144
+ else throw Error("Fullscreen API is not supported");
2145
+ }
2146
+ async function Vr() {
2147
+ document.exitFullscreen ? await document.exitFullscreen() : document.webkitExitFullscreen && await document.webkitExitFullscreen();
2148
+ }
2149
+ var Hr = null, Ur = null;
2150
+ function Wr() {
2151
+ let e = !!zr();
2152
+ Hr && e !== Ur && (Ur = e, Hr(e));
2153
+ }
2154
+ document.addEventListener("fullscreenchange", Wr), document.addEventListener("webkitfullscreenchange", Wr);
2155
+ async function Gr(e, t) {
2156
+ t && (Hr = t), Ur = e;
2157
+ let n = !!zr();
2158
+ try {
2159
+ e ? n || await Br(document.documentElement) : n && await Vr();
2160
+ } catch {}
2161
+ t && (Ur = !!zr(), t(Ur));
2162
+ }
2163
+ function Kr(e) {
2164
+ document.title = e;
2165
+ }
2166
+ function qr() {
2167
+ return typeof window.matchMedia == "function" && [
2168
+ "standalone",
2169
+ "minimal-ui",
2170
+ "window-controls-overlay"
2171
+ ].some((e) => window.matchMedia(`(display-mode: ${e})`).matches);
2172
+ }
2173
+ function Jr() {
2174
+ window.close();
2175
+ }
2176
+ var Yr = {
2177
+ setFullscreen: Gr,
2178
+ setTitle: Kr,
2179
+ ...qr() && !navigator.standalone ? { exitApp: Jr } : {}
2540
2180
  };
2181
+ // src/interfaces/platform-neutralino.js
2182
+ async function Xr(e, t) {
2183
+ try {
2184
+ e ? await window.Neutralino.window.setFullScreen() : await window.Neutralino.window.exitFullScreen();
2185
+ } catch {
2186
+ return;
2187
+ }
2188
+ t?.(e);
2189
+ }
2190
+ async function Zr(e) {
2191
+ await window.Neutralino.window.setTitle(e);
2192
+ }
2193
+ async function Qr() {
2194
+ await window.Neutralino.app.exit();
2195
+ }
2196
+ var $r = {
2197
+ setFullscreen: Xr,
2198
+ setTitle: Zr,
2199
+ exitApp: Qr
2200
+ }, ei = {
2201
+ loader: vn,
2202
+ sound: Or,
2203
+ state: Rr,
2204
+ platform: window.Neutralino ? $r : Yr
2205
+ }, ti = mr();
2206
+ ti && (ei.persistent = ti), St.defineInterfaces(ei), console.log(`Atrament persistent driver: ${St.interfaces.persistent.driver || "memory"}`);
2207
+ var ni = St;
2208
+ export { ni as default };