@byloth/core 2.1.3 → 2.1.5

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/core.esm.js CHANGED
@@ -1,13 +1,13 @@
1
- var Ye = Object.defineProperty;
2
- var Le = (i, n, e) => n in i ? Ye(i, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[n] = e;
3
- var a = (i, n, e) => Le(i, typeof n != "symbol" ? n + "" : n, e);
4
- const De = typeof window < "u" && typeof window.document < "u";
5
- var I;
6
- const nt = typeof process < "u" && !!((I = process.versions) != null && I.node);
1
+ var Ke = Object.defineProperty;
2
+ var Qe = (i, n, e) => n in i ? Ke(i, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[n] = e;
3
+ var a = (i, n, e) => Qe(i, typeof n != "symbol" ? n + "" : n, e);
4
+ const Ye = typeof window < "u" && typeof window.document < "u";
7
5
  var A;
8
- const st = typeof self == "object" && ((A = self.constructor) == null ? void 0 : A.name) === "DedicatedWorkerGlobalScope";
9
- var N, O;
10
- class c extends (O = Error, N = Symbol.toStringTag, O) {
6
+ const ot = typeof process < "u" && !!((A = process.versions) != null && A.node);
7
+ var N;
8
+ const at = typeof self == "object" && ((N = self.constructor) == null ? void 0 : N.name) === "DedicatedWorkerGlobalScope";
9
+ var O, q;
10
+ class c extends (q = Error, O = Symbol.toStringTag, q) {
11
11
  /**
12
12
  * Initializes a new instance of the {@link Exception} class.
13
13
  *
@@ -26,7 +26,7 @@ class c extends (O = Error, N = Symbol.toStringTag, O) {
26
26
  */
27
27
  constructor(e, t, s = "Exception") {
28
28
  super(e);
29
- a(this, N, "Exception");
29
+ a(this, O, "Exception");
30
30
  this.cause = t, this.name = s, t && (t instanceof Error ? this.stack += `
31
31
 
32
32
  Caused by ${t.stack}` : this.stack += `
@@ -65,8 +65,8 @@ Caused by ${t}`);
65
65
  return new c(`${e}`);
66
66
  }
67
67
  }
68
- var $, q;
69
- class g extends (q = c, $ = Symbol.toStringTag, q) {
68
+ var $, z;
69
+ class g extends (z = c, $ = Symbol.toStringTag, z) {
70
70
  /**
71
71
  * Initializes a new instance of the {@link FatalErrorException} class.
72
72
  *
@@ -89,8 +89,8 @@ class g extends (q = c, $ = Symbol.toStringTag, q) {
89
89
  a(this, $, "FatalErrorException");
90
90
  }
91
91
  }
92
- var z, D;
93
- class Ve extends (D = g, z = Symbol.toStringTag, D) {
92
+ var D, B;
93
+ class He extends (B = g, D = Symbol.toStringTag, B) {
94
94
  /**
95
95
  * Initializes a new instance of the {@link NotImplementedException} class.
96
96
  *
@@ -110,11 +110,11 @@ class Ve extends (D = g, z = Symbol.toStringTag, D) {
110
110
  constructor(e, t, s = "NotImplementedException") {
111
111
  e === void 0 && (e = "This feature isn't implemented yet. Please, try again later.");
112
112
  super(e, t, s);
113
- a(this, z, "NotImplementedException");
113
+ a(this, D, "NotImplementedException");
114
114
  }
115
115
  }
116
- var B, J;
117
- class Be extends (J = c, B = Symbol.toStringTag, J) {
116
+ var J, Y;
117
+ class Le extends (Y = c, J = Symbol.toStringTag, Y) {
118
118
  /**
119
119
  * Initializes a new instance of the {@link FileException} class.
120
120
  *
@@ -133,11 +133,11 @@ class Be extends (J = c, B = Symbol.toStringTag, J) {
133
133
  */
134
134
  constructor(e, t, s = "FileException") {
135
135
  super(e, t, s);
136
- a(this, B, "FileException");
136
+ a(this, J, "FileException");
137
137
  }
138
138
  }
139
- var Y, L;
140
- class rt extends (L = Be, Y = Symbol.toStringTag, L) {
139
+ var L, V;
140
+ class lt extends (V = Le, L = Symbol.toStringTag, V) {
141
141
  /**
142
142
  * Initializes a new instance of the {@link FileExistsException} class.
143
143
  *
@@ -156,11 +156,11 @@ class rt extends (L = Be, Y = Symbol.toStringTag, L) {
156
156
  */
157
157
  constructor(e, t, s = "FileExistsException") {
158
158
  super(e, t, s);
159
- a(this, Y, "FileExistsException");
159
+ a(this, L, "FileExistsException");
160
160
  }
161
161
  }
162
- var V, G;
163
- class it extends (G = Be, V = Symbol.toStringTag, G) {
162
+ var G, K;
163
+ class ut extends (K = Le, G = Symbol.toStringTag, K) {
164
164
  /**
165
165
  * Initializes a new instance of the {@link FileNotFoundException} class.
166
166
  *
@@ -179,11 +179,11 @@ class it extends (G = Be, V = Symbol.toStringTag, G) {
179
179
  */
180
180
  constructor(e, t, s = "FileNotFoundException") {
181
181
  super(e, t, s);
182
- a(this, V, "FileNotFoundException");
182
+ a(this, G, "FileNotFoundException");
183
183
  }
184
184
  }
185
- var K, H;
186
- class y extends (H = c, K = Symbol.toStringTag, H) {
185
+ var Q, H;
186
+ class _ extends (H = c, Q = Symbol.toStringTag, H) {
187
187
  /**
188
188
  * Initializes a new instance of the {@link KeyException} class.
189
189
  *
@@ -202,11 +202,11 @@ class y extends (H = c, K = Symbol.toStringTag, H) {
202
202
  */
203
203
  constructor(e, t, s = "KeyException") {
204
204
  super(e, t, s);
205
- a(this, K, "KeyException");
205
+ a(this, Q, "KeyException");
206
206
  }
207
207
  }
208
- var Q, X;
209
- class ot extends (X = c, Q = Symbol.toStringTag, X) {
208
+ var X, Z;
209
+ class ct extends (Z = c, X = Symbol.toStringTag, Z) {
210
210
  /**
211
211
  * Initializes a new instance of the {@link NetworkException} class.
212
212
  *
@@ -225,11 +225,11 @@ class ot extends (X = c, Q = Symbol.toStringTag, X) {
225
225
  */
226
226
  constructor(e, t, s = "NetworkException") {
227
227
  super(e, t, s);
228
- a(this, Q, "NetworkException");
228
+ a(this, X, "NetworkException");
229
229
  }
230
230
  }
231
- var Z, U;
232
- class at extends (U = c, Z = Symbol.toStringTag, U) {
231
+ var W, U;
232
+ class ht extends (U = c, W = Symbol.toStringTag, U) {
233
233
  /**
234
234
  * Initializes a new instance of the {@link PermissionException} class.
235
235
  *
@@ -248,11 +248,11 @@ class at extends (U = c, Z = Symbol.toStringTag, U) {
248
248
  */
249
249
  constructor(e, t, s = "PermissionException") {
250
250
  super(e, t, s);
251
- a(this, Z, "PermissionException");
251
+ a(this, W, "PermissionException");
252
252
  }
253
253
  }
254
- var W, ee;
255
- class E extends (ee = c, W = Symbol.toStringTag, ee) {
254
+ var ee, te;
255
+ class E extends (te = c, ee = Symbol.toStringTag, te) {
256
256
  /**
257
257
  * Initializes a new instance of the {@link ReferenceException} class.
258
258
  *
@@ -271,11 +271,11 @@ class E extends (ee = c, W = Symbol.toStringTag, ee) {
271
271
  */
272
272
  constructor(e, t, s = "ReferenceException") {
273
273
  super(e, t, s);
274
- a(this, W, "ReferenceException");
274
+ a(this, ee, "ReferenceException");
275
275
  }
276
276
  }
277
- var te, ne;
278
- class p extends (ne = c, te = Symbol.toStringTag, ne) {
277
+ var ne, se;
278
+ class p extends (se = c, ne = Symbol.toStringTag, se) {
279
279
  /**
280
280
  * Initializes a new instance of the {@link RuntimeException} class.
281
281
  *
@@ -294,11 +294,11 @@ class p extends (ne = c, te = Symbol.toStringTag, ne) {
294
294
  */
295
295
  constructor(e, t, s = "RuntimeException") {
296
296
  super(e, t, s);
297
- a(this, te, "RuntimeException");
297
+ a(this, ne, "RuntimeException");
298
298
  }
299
299
  }
300
- var se, re;
301
- class Ge extends (re = p, se = Symbol.toStringTag, re) {
300
+ var re, ie;
301
+ class Xe extends (ie = p, re = Symbol.toStringTag, ie) {
302
302
  /**
303
303
  * Initializes a new instance of the {@link EnvironmentException} class.
304
304
  *
@@ -317,11 +317,11 @@ class Ge extends (re = p, se = Symbol.toStringTag, re) {
317
317
  */
318
318
  constructor(e, t, s = "EnvironmentException") {
319
319
  super(e, t, s);
320
- a(this, se, "EnvironmentException");
320
+ a(this, re, "EnvironmentException");
321
321
  }
322
322
  }
323
- var ie, oe;
324
- class Ke extends (oe = c, ie = Symbol.toStringTag, oe) {
323
+ var oe, ae;
324
+ class Ze extends (ae = c, oe = Symbol.toStringTag, ae) {
325
325
  /**
326
326
  * Initializes a new instance of the {@link TimeoutException} class.
327
327
  *
@@ -340,11 +340,11 @@ class Ke extends (oe = c, ie = Symbol.toStringTag, oe) {
340
340
  */
341
341
  constructor(e, t, s = "TimeoutException") {
342
342
  super(e, t, s);
343
- a(this, ie, "TimeoutException");
343
+ a(this, oe, "TimeoutException");
344
344
  }
345
345
  }
346
- var ae, le;
347
- class lt extends (le = c, ae = Symbol.toStringTag, le) {
346
+ var le, ue;
347
+ class ft extends (ue = c, le = Symbol.toStringTag, ue) {
348
348
  /**
349
349
  * Initializes a new instance of the {@link TypeException} class.
350
350
  *
@@ -363,11 +363,11 @@ class lt extends (le = c, ae = Symbol.toStringTag, le) {
363
363
  */
364
364
  constructor(e, t, s = "TypeException") {
365
365
  super(e, t, s);
366
- a(this, ae, "TypeException");
366
+ a(this, le, "TypeException");
367
367
  }
368
368
  }
369
- var ue, ce;
370
- class d extends (ce = c, ue = Symbol.toStringTag, ce) {
369
+ var ce, he;
370
+ class f extends (he = c, ce = Symbol.toStringTag, he) {
371
371
  /**
372
372
  * Initializes a new instance of the {@link ValueException} class.
373
373
  *
@@ -386,11 +386,11 @@ class d extends (ce = c, ue = Symbol.toStringTag, ce) {
386
386
  */
387
387
  constructor(e, t, s = "ValueException") {
388
388
  super(e, t, s);
389
- a(this, ue, "ValueException");
389
+ a(this, ce, "ValueException");
390
390
  }
391
391
  }
392
- var he, fe;
393
- class b extends (fe = d, he = Symbol.toStringTag, fe) {
392
+ var fe, de;
393
+ class b extends (de = f, fe = Symbol.toStringTag, de) {
394
394
  /**
395
395
  * Initializes a new instance of the {@link RangeException} class.
396
396
  *
@@ -409,17 +409,17 @@ class b extends (fe = d, he = Symbol.toStringTag, fe) {
409
409
  */
410
410
  constructor(e, t, s = "RangeException") {
411
411
  super(e, t, s);
412
- a(this, he, "RangeException");
412
+ a(this, fe, "RangeException");
413
413
  }
414
414
  }
415
- var de;
415
+ var we;
416
416
  class u {
417
417
  constructor(n) {
418
418
  /**
419
419
  * The native {@link Iterator} object that is being wrapped by this instance.
420
420
  */
421
421
  a(this, "_iterator");
422
- a(this, de, "SmartIterator");
422
+ a(this, we, "SmartIterator");
423
423
  n instanceof Function ? this._iterator = n() : Symbol.iterator in n ? this._iterator = n[Symbol.iterator]() : this._iterator = n;
424
424
  }
425
425
  /**
@@ -562,7 +562,7 @@ class u {
562
562
  if (s === void 0) {
563
563
  const r = this._iterator.next();
564
564
  if (r.done)
565
- throw new d("Cannot reduce an empty iterator without an initial value.");
565
+ throw new f("Cannot reduce an empty iterator without an initial value.");
566
566
  s = r.value, t += 1;
567
567
  }
568
568
  for (; ; ) {
@@ -1020,19 +1020,19 @@ class u {
1020
1020
  toArray() {
1021
1021
  return Array.from(this);
1022
1022
  }
1023
- [(de = Symbol.toStringTag, Symbol.iterator)]() {
1023
+ [(we = Symbol.toStringTag, Symbol.iterator)]() {
1024
1024
  return this;
1025
1025
  }
1026
1026
  }
1027
- var we;
1028
- we = Symbol.toStringTag;
1029
- const _ = class _ {
1027
+ var me;
1028
+ me = Symbol.toStringTag;
1029
+ const y = class y {
1030
1030
  constructor(n) {
1031
1031
  /**
1032
1032
  * The internal {@link SmartIterator} object that holds the reduced elements.
1033
1033
  */
1034
1034
  a(this, "_elements");
1035
- a(this, we, "ReducedIterator");
1035
+ a(this, me, "ReducedIterator");
1036
1036
  this._elements = new u(n);
1037
1037
  }
1038
1038
  /**
@@ -1111,7 +1111,7 @@ const _ = class _ {
1111
1111
  }
1112
1112
  filter(n) {
1113
1113
  const e = this._elements.enumerate();
1114
- return new _(function* () {
1114
+ return new y(function* () {
1115
1115
  for (const [t, [s, r]] of e)
1116
1116
  n(s, r, t) && (yield [s, r]);
1117
1117
  });
@@ -1151,7 +1151,7 @@ const _ = class _ {
1151
1151
  */
1152
1152
  map(n) {
1153
1153
  const e = this._elements.enumerate();
1154
- return new _(function* () {
1154
+ return new y(function* () {
1155
1155
  for (const [t, [s, r]] of e)
1156
1156
  yield [s, n(s, r, t)];
1157
1157
  });
@@ -1161,7 +1161,7 @@ const _ = class _ {
1161
1161
  if (s === void 0) {
1162
1162
  const r = this._elements.next();
1163
1163
  if (r.done)
1164
- throw new d("Cannot reduce an empty iterator without an initial value.");
1164
+ throw new f("Cannot reduce an empty iterator without an initial value.");
1165
1165
  s = r.value[1], t += 1;
1166
1166
  }
1167
1167
  for (const [r, o] of this._elements)
@@ -1249,7 +1249,7 @@ const _ = class _ {
1249
1249
  */
1250
1250
  drop(n) {
1251
1251
  const e = this._elements.enumerate();
1252
- return new _(function* () {
1252
+ return new y(function* () {
1253
1253
  for (const [t, [s, r]] of e)
1254
1254
  t >= n && (yield [s, r]);
1255
1255
  });
@@ -1291,7 +1291,7 @@ const _ = class _ {
1291
1291
  */
1292
1292
  take(n) {
1293
1293
  const e = this._elements.enumerate();
1294
- return new _(function* () {
1294
+ return new y(function* () {
1295
1295
  for (const [t, [s, r]] of e) {
1296
1296
  if (t >= n)
1297
1297
  break;
@@ -1361,7 +1361,7 @@ const _ = class _ {
1361
1361
  */
1362
1362
  unique() {
1363
1363
  const n = this._elements;
1364
- return new _(function* () {
1364
+ return new y(function* () {
1365
1365
  const e = /* @__PURE__ */ new Set();
1366
1366
  for (const [t, s] of n)
1367
1367
  e.has(s) || (e.add(s), yield [t, s]);
@@ -1634,17 +1634,17 @@ const _ = class _ {
1634
1634
  return Object.fromEntries(this.entries());
1635
1635
  }
1636
1636
  };
1637
- let h = _;
1638
- var me;
1639
- me = Symbol.toStringTag;
1637
+ let h = y;
1638
+ var pe;
1639
+ pe = Symbol.toStringTag;
1640
1640
  const w = class w {
1641
1641
  constructor(n) {
1642
1642
  /**
1643
1643
  * The internal {@link SmartAsyncIterator} object that holds the elements to aggregate.
1644
1644
  */
1645
1645
  a(this, "_elements");
1646
- a(this, me, "AggregatedAsyncIterator");
1647
- this._elements = new f(n);
1646
+ a(this, pe, "AggregatedAsyncIterator");
1647
+ this._elements = new d(n);
1648
1648
  }
1649
1649
  /**
1650
1650
  * Determines whether all elements of each group of the iterator satisfy a given condition.
@@ -1844,8 +1844,8 @@ const w = class w {
1844
1844
  for await (const [s, r] of e) {
1845
1845
  const o = t.get(s) ?? 0, l = await n(s, r, o);
1846
1846
  if (l instanceof Array)
1847
- for (const S of l)
1848
- yield [s, S];
1847
+ for (const k of l)
1848
+ yield [s, k];
1849
1849
  else
1850
1850
  yield [s, l];
1851
1851
  t.set(s, o + 1);
@@ -2145,7 +2145,7 @@ const w = class w {
2145
2145
  */
2146
2146
  keys() {
2147
2147
  const n = this._elements;
2148
- return new f(async function* () {
2148
+ return new d(async function* () {
2149
2149
  const e = /* @__PURE__ */ new Set();
2150
2150
  for await (const [t] of n)
2151
2151
  e.has(t) || (e.add(t), yield t);
@@ -2209,7 +2209,7 @@ const w = class w {
2209
2209
  */
2210
2210
  values() {
2211
2211
  const n = this._elements;
2212
- return new f(async function* () {
2212
+ return new d(async function* () {
2213
2213
  for await (const [e, t] of n)
2214
2214
  yield t;
2215
2215
  });
@@ -2296,14 +2296,14 @@ const w = class w {
2296
2296
  }
2297
2297
  };
2298
2298
  let M = w;
2299
- var pe;
2300
- class f {
2299
+ var _e;
2300
+ class d {
2301
2301
  constructor(n) {
2302
2302
  /**
2303
2303
  * The native {@link AsyncIterator} object that is being wrapped by this instance.
2304
2304
  */
2305
2305
  a(this, "_iterator");
2306
- a(this, pe, "SmartAsyncIterator");
2306
+ a(this, _e, "SmartAsyncIterator");
2307
2307
  if (n instanceof Function) {
2308
2308
  const e = n();
2309
2309
  Symbol.asyncIterator in e ? this._iterator = e : this._iterator = async function* () {
@@ -2422,7 +2422,7 @@ class f {
2422
2422
  }
2423
2423
  filter(n) {
2424
2424
  const e = this._iterator;
2425
- return new f(async function* () {
2425
+ return new d(async function* () {
2426
2426
  let t = 0;
2427
2427
  for (; ; ) {
2428
2428
  const s = await e.next();
@@ -2465,7 +2465,7 @@ class f {
2465
2465
  */
2466
2466
  map(n) {
2467
2467
  const e = this._iterator;
2468
- return new f(async function* () {
2468
+ return new d(async function* () {
2469
2469
  let t = 0;
2470
2470
  for (; ; ) {
2471
2471
  const s = await e.next();
@@ -2480,7 +2480,7 @@ class f {
2480
2480
  if (s === void 0) {
2481
2481
  const r = await this._iterator.next();
2482
2482
  if (r.done)
2483
- throw new d("Cannot reduce an empty iterator without an initial value.");
2483
+ throw new f("Cannot reduce an empty iterator without an initial value.");
2484
2484
  s = r.value, t += 1;
2485
2485
  }
2486
2486
  for (; ; ) {
@@ -2523,7 +2523,7 @@ class f {
2523
2523
  */
2524
2524
  flatMap(n) {
2525
2525
  const e = this._iterator;
2526
- return new f(async function* () {
2526
+ return new d(async function* () {
2527
2527
  let t = 0;
2528
2528
  for (; ; ) {
2529
2529
  const s = await e.next();
@@ -2572,7 +2572,7 @@ class f {
2572
2572
  */
2573
2573
  drop(n) {
2574
2574
  const e = this._iterator;
2575
- return new f(async function* () {
2575
+ return new d(async function* () {
2576
2576
  let t = 0;
2577
2577
  for (; t < n; ) {
2578
2578
  if ((await e.next()).done)
@@ -2621,7 +2621,7 @@ class f {
2621
2621
  */
2622
2622
  take(n) {
2623
2623
  const e = this._iterator;
2624
- return new f(async function* () {
2624
+ return new d(async function* () {
2625
2625
  let t = 0;
2626
2626
  for (; t < n; ) {
2627
2627
  const s = await e.next();
@@ -2700,7 +2700,7 @@ class f {
2700
2700
  */
2701
2701
  unique() {
2702
2702
  const n = this._iterator;
2703
- return new f(async function* () {
2703
+ return new d(async function* () {
2704
2704
  const e = /* @__PURE__ */ new Set();
2705
2705
  for (; ; ) {
2706
2706
  const t = await n.next();
@@ -2945,7 +2945,7 @@ class f {
2945
2945
  toArray() {
2946
2946
  return Array.fromAsync(this);
2947
2947
  }
2948
- [(pe = Symbol.toStringTag, Symbol.asyncIterator)]() {
2948
+ [(_e = Symbol.toStringTag, Symbol.asyncIterator)]() {
2949
2949
  return this;
2950
2950
  }
2951
2951
  }
@@ -3156,8 +3156,8 @@ const m = class m {
3156
3156
  for (const [s, r] of e) {
3157
3157
  const o = t.get(s) ?? 0, l = n(s, r, o);
3158
3158
  if (l instanceof Array)
3159
- for (const S of l)
3160
- yield [s, S];
3159
+ for (const k of l)
3160
+ yield [s, k];
3161
3161
  else
3162
3162
  yield [s, l];
3163
3163
  t.set(s, o + 1);
@@ -3605,22 +3605,22 @@ const m = class m {
3605
3605
  }
3606
3606
  };
3607
3607
  let x = m;
3608
- const He = Function;
3609
- var _e, be;
3610
- class Qe extends (be = He, _e = Symbol.toStringTag, be) {
3608
+ const We = Function;
3609
+ var be, ge;
3610
+ class Ue extends (ge = We, be = Symbol.toStringTag, ge) {
3611
3611
  /**
3612
3612
  * Initializes a new instance of the {@link CallableObject} class.
3613
3613
  */
3614
3614
  constructor() {
3615
3615
  super("return this._invoke(...arguments);");
3616
- a(this, _e, "CallableObject");
3616
+ a(this, be, "CallableObject");
3617
3617
  const e = this.bind(this);
3618
3618
  return Object.setPrototypeOf(this, e), e;
3619
3619
  }
3620
3620
  }
3621
- var ge;
3622
- ge = Symbol.toStringTag;
3623
- class v {
3621
+ var xe;
3622
+ xe = Symbol.toStringTag;
3623
+ const F = class F {
3624
3624
  /**
3625
3625
  * Initializes a new instance of the {@link Publisher} class.
3626
3626
  *
@@ -3639,7 +3639,7 @@ class v {
3639
3639
  * The values are the arrays of the subscribers themselves.
3640
3640
  */
3641
3641
  a(this, "_subscribers");
3642
- a(this, ge, "Publisher");
3642
+ a(this, xe, "Publisher");
3643
3643
  this._subscribers = /* @__PURE__ */ new Map();
3644
3644
  }
3645
3645
  /**
@@ -3663,7 +3663,48 @@ class v {
3663
3663
  * ```
3664
3664
  */
3665
3665
  clear() {
3666
- this._subscribers.clear();
3666
+ this.publish("__internals__:clear"), this._subscribers.clear();
3667
+ }
3668
+ /**
3669
+ * Creates a new scoped instance of the {@link Publisher} class,
3670
+ * which can be used to publish and subscribe events within a specific context.
3671
+ *
3672
+ * It can receive all events published to the parent publisher while also allowing
3673
+ * the scoped publisher to handle its own events independently.
3674
+ * In fact, events published to the scoped publisher won't be propagated back to the parent publisher.
3675
+ *
3676
+ * ---
3677
+ *
3678
+ * @example
3679
+ * ```ts
3680
+ * const publisher = new Publisher();
3681
+ * const context = publisher.createScope();
3682
+ *
3683
+ * publisher.subscribe("player:death", () => { console.log(`Player has died.`); });
3684
+ * context.subscribe("player:spawn", () => { console.log(`Player has spawned.`); });
3685
+ *
3686
+ * publisher.publish("player:spawn"); // Player has spawned.
3687
+ * context.publish("player:death"); // * no output *
3688
+ * ```
3689
+ *
3690
+ * ---
3691
+ *
3692
+ * @template U
3693
+ * A map containing the names of the emittable events and the
3694
+ * related callback signatures that can be subscribed to them.
3695
+ * Default is `T`.
3696
+ *
3697
+ * @template X An utility type that extends the `U` map with a wildcard event.
3698
+ *
3699
+ * @return
3700
+ * A new instance of the {@link Publisher} class that can be
3701
+ * used to publish and subscribe events within a specific context.
3702
+ */
3703
+ createScope() {
3704
+ const n = new F(), e = (t, ...s) => {
3705
+ n.publish(t, ...s);
3706
+ };
3707
+ return this.subscribe("__internals__:clear", () => n.clear()), this.subscribe("*", e), n;
3667
3708
  }
3668
3709
  /**
3669
3710
  * Publishes an event to all the subscribers.
@@ -3689,8 +3730,8 @@ class v {
3689
3730
  * @returns An array containing the return values of all the subscribers.
3690
3731
  */
3691
3732
  publish(n, ...e) {
3692
- const t = this._subscribers.get(n);
3693
- return t ? t.slice().map((s) => s(...e)) : [];
3733
+ let t, s = this._subscribers.get(n);
3734
+ return s ? t = s.slice().map((r) => r(...e)) : t = [], n.startsWith("__") || (s = this._subscribers.get("*"), s && s.slice().forEach((r) => r(n, ...e))), t;
3694
3735
  }
3695
3736
  /**
3696
3737
  * Subscribes to an event and adds a subscriber to be executed when the event is published.
@@ -3754,11 +3795,12 @@ class v {
3754
3795
  throw new E("Unable to unsubscribe the required subscriber. The subscription was already unsubscribed or was never subscribed.");
3755
3796
  t.splice(s, 1), t.length === 0 && this._subscribers.delete(n);
3756
3797
  }
3757
- }
3758
- const Xe = () => {
3759
3798
  };
3760
- var xe, ve;
3761
- class ut extends (ve = Qe, xe = Symbol.toStringTag, ve) {
3799
+ let v = F;
3800
+ const et = () => {
3801
+ };
3802
+ var ve, Se;
3803
+ class dt extends (Se = Ue, ve = Symbol.toStringTag, Se) {
3762
3804
  constructor(e, t = "default") {
3763
3805
  super();
3764
3806
  /**
@@ -3791,9 +3833,9 @@ class ut extends (ve = Qe, xe = Symbol.toStringTag, ve) {
3791
3833
  * The function that will be called by the extended class when the object is invoked as a function.
3792
3834
  */
3793
3835
  a(this, "_invoke");
3794
- a(this, xe, "SwitchableCallback");
3836
+ a(this, ve, "SwitchableCallback");
3795
3837
  this._callbacks = /* @__PURE__ */ new Map(), this._isEnabled = !0, e ? this._callbacks.set(t, e) : (t = "", e = () => {
3796
- throw new Ve(
3838
+ throw new He(
3797
3839
  "The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
3798
3840
  );
3799
3841
  }), this._key = t, this._callback = e, this._invoke = (...s) => this._callback(...s);
@@ -3838,14 +3880,14 @@ class ut extends (ve = Qe, xe = Symbol.toStringTag, ve) {
3838
3880
  enable(e) {
3839
3881
  if (e === void 0) {
3840
3882
  if (!this._key)
3841
- throw new y(
3883
+ throw new _(
3842
3884
  "The `SwitchableCallback` has no callback defined yet. Did you forget to call the `register` method?"
3843
3885
  );
3844
3886
  e = this._key;
3845
3887
  } else if (e) {
3846
3888
  if (!this._callbacks.has(e))
3847
- throw new y(`The key '${e}' doesn't yet have any associated callback.`);
3848
- } else throw new y("The key must be a non-empty string.");
3889
+ throw new _(`The key '${e}' doesn't yet have any associated callback.`);
3890
+ } else throw new _("The key must be a non-empty string.");
3849
3891
  if (this._isEnabled)
3850
3892
  throw new p("The `SwitchableCallback` is already enabled.");
3851
3893
  this._callback = this._callbacks.get(e), this._isEnabled = !0;
@@ -3866,7 +3908,7 @@ class ut extends (ve = Qe, xe = Symbol.toStringTag, ve) {
3866
3908
  disable() {
3867
3909
  if (!this._isEnabled)
3868
3910
  throw new p("The `SwitchableCallback` is already disabled.");
3869
- this._callback = Xe, this._isEnabled = !1;
3911
+ this._callback = et, this._isEnabled = !1;
3870
3912
  }
3871
3913
  /**
3872
3914
  * Registers a new implementation for the callback.
@@ -3892,7 +3934,7 @@ class ut extends (ve = Qe, xe = Symbol.toStringTag, ve) {
3892
3934
  if (this._callbacks.size === 0)
3893
3935
  this._key = e, this._callback = t;
3894
3936
  else if (this._callbacks.has(e))
3895
- throw new y(`The key '${e}' has already been used for another callback.`);
3937
+ throw new _(`The key '${e}' has already been used for another callback.`);
3896
3938
  this._callbacks.set(e, t);
3897
3939
  }
3898
3940
  /**
@@ -3915,9 +3957,9 @@ class ut extends (ve = Qe, xe = Symbol.toStringTag, ve) {
3915
3957
  */
3916
3958
  unregister(e) {
3917
3959
  if (this._key === e)
3918
- throw new y("Unable to unregister the currently selected callback.");
3960
+ throw new _("Unable to unregister the currently selected callback.");
3919
3961
  if (!this._callbacks.has(e))
3920
- throw new y(`The key '${e}' doesn't yet have any associated callback.`);
3962
+ throw new _(`The key '${e}' doesn't yet have any associated callback.`);
3921
3963
  this._callbacks.delete(e);
3922
3964
  }
3923
3965
  /**
@@ -3940,12 +3982,12 @@ class ut extends (ve = Qe, xe = Symbol.toStringTag, ve) {
3940
3982
  */
3941
3983
  switch(e) {
3942
3984
  if (!this._callbacks.has(e))
3943
- throw new y(`The key '${e}' doesn't yet have any associated callback.`);
3985
+ throw new _(`The key '${e}' doesn't yet have any associated callback.`);
3944
3986
  this._key !== e && (this._key = e, this._isEnabled && (this._callback = this._callbacks.get(e)));
3945
3987
  }
3946
3988
  }
3947
- var Se, ke;
3948
- class ct extends (ke = Map, Se = Symbol.toStringTag, ke) {
3989
+ var ke, Te;
3990
+ class wt extends (Te = Map, ke = Symbol.toStringTag, Te) {
3949
3991
  /**
3950
3992
  * Initializes a new instance of the {@link MapView} class.
3951
3993
  *
@@ -3966,7 +4008,7 @@ class ct extends (ke = Map, Se = Symbol.toStringTag, ke) {
3966
4008
  * The internal {@link Publisher} instance used to publish events.
3967
4009
  */
3968
4010
  a(this, "_publisher");
3969
- a(this, Se, "MapView");
4011
+ a(this, ke, "MapView");
3970
4012
  if (this._publisher = new v(), e)
3971
4013
  for (const [t, s] of e)
3972
4014
  this.set(t, s);
@@ -4098,8 +4140,8 @@ class ct extends (ke = Map, Se = Symbol.toStringTag, ke) {
4098
4140
  this._publisher.unsubscribe(e, t);
4099
4141
  }
4100
4142
  }
4101
- var Te, Ee;
4102
- class ht extends (Ee = Set, Te = Symbol.toStringTag, Ee) {
4143
+ var Ee, Me;
4144
+ class mt extends (Me = Set, Ee = Symbol.toStringTag, Me) {
4103
4145
  /**
4104
4146
  * Initializes a new instance of the {@link SetView} class.
4105
4147
  *
@@ -4120,7 +4162,7 @@ class ht extends (Ee = Set, Te = Symbol.toStringTag, Ee) {
4120
4162
  * The internal {@link Publisher} instance used to publish events.
4121
4163
  */
4122
4164
  a(this, "_publisher");
4123
- a(this, Te, "SetView");
4165
+ a(this, Ee, "SetView");
4124
4166
  if (this._publisher = new v(), e)
4125
4167
  for (const t of e)
4126
4168
  this.add(t);
@@ -4251,9 +4293,9 @@ class ht extends (Ee = Set, Te = Symbol.toStringTag, Ee) {
4251
4293
  this._publisher.unsubscribe(e, t);
4252
4294
  }
4253
4295
  }
4254
- var Me;
4255
- Me = Symbol.toStringTag;
4256
- class ft {
4296
+ var Re;
4297
+ Re = Symbol.toStringTag;
4298
+ class pt {
4257
4299
  /**
4258
4300
  * Initializes a new instance of the {@link JSONStorage} class.
4259
4301
  * It cannot be instantiated outside of a browser environment or an {@link EnvironmentException} is thrown.
@@ -4287,9 +4329,9 @@ class ft {
4287
4329
  * A reference to the persistent {@link localStorage} storage.
4288
4330
  */
4289
4331
  a(this, "_persistent");
4290
- a(this, Me, "JSONStorage");
4291
- if (!De)
4292
- throw new Ge(
4332
+ a(this, Re, "JSONStorage");
4333
+ if (!Ye)
4334
+ throw new Xe(
4293
4335
  "The `JSONStorage` class can only be instantiated within a browser environment."
4294
4336
  );
4295
4337
  this._preferPersistence = n, this._volatile = window.sessionStorage, this._persistent = window.localStorage;
@@ -4561,9 +4603,9 @@ class ft {
4561
4603
  this._volatile.removeItem(n), this._persistent.removeItem(n);
4562
4604
  }
4563
4605
  }
4564
- var Re;
4565
- Re = Symbol.toStringTag;
4566
- const F = class F {
4606
+ var Fe;
4607
+ Fe = Symbol.toStringTag;
4608
+ const P = class P {
4567
4609
  /**
4568
4610
  * Initializes a new instance of the {@link SmartPromise} class.
4569
4611
  *
@@ -4609,7 +4651,7 @@ const F = class F {
4609
4651
  * The native {@link Promise} object wrapped by this instance.
4610
4652
  */
4611
4653
  a(this, "_promise");
4612
- a(this, Re, "SmartPromise");
4654
+ a(this, Fe, "SmartPromise");
4613
4655
  this._isPending = !0, this._isFulfilled = !1, this._isRejected = !1;
4614
4656
  const e = (s) => (this._isPending = !1, this._isFulfilled = !0, s), t = (s) => {
4615
4657
  throw this._isPending = !1, this._isRejected = !0, s;
@@ -4640,7 +4682,7 @@ const F = class F {
4640
4682
  * @returns A new {@link SmartPromise} object that wraps the provided promise.
4641
4683
  */
4642
4684
  static FromPromise(n) {
4643
- return new F((e, t) => n.then(e, t));
4685
+ return new P((e, t) => n.then(e, t));
4644
4686
  }
4645
4687
  /**
4646
4688
  * A flag indicating whether the promise is still pending or not.
@@ -4696,9 +4738,9 @@ const F = class F {
4696
4738
  return this._promise.finally(n);
4697
4739
  }
4698
4740
  };
4699
- let k = F;
4700
- var Fe, Pe;
4701
- class Ze extends (Pe = k, Fe = Symbol.toStringTag, Pe) {
4741
+ let S = P;
4742
+ var Pe, je;
4743
+ class Ve extends (je = S, Pe = Symbol.toStringTag, je) {
4702
4744
  /**
4703
4745
  * Initializes a new instance of the {@link DeferredPromise} class.
4704
4746
  *
@@ -4733,7 +4775,7 @@ class Ze extends (Pe = k, Fe = Symbol.toStringTag, Pe) {
4733
4775
  * If you're looking for the public and readonly property, use the {@link DeferredPromise.reject} getter instead.
4734
4776
  */
4735
4777
  a(this, "_reject");
4736
- a(this, Fe, "DeferredPromise");
4778
+ a(this, Pe, "DeferredPromise");
4737
4779
  this._promise = this._promise.then(e, t), this._resolve = s, this._reject = r;
4738
4780
  }
4739
4781
  /**
@@ -4772,8 +4814,8 @@ class Ze extends (Pe = k, Fe = Symbol.toStringTag, Pe) {
4772
4814
  return e.then(this.resolve, this.reject), this;
4773
4815
  }
4774
4816
  }
4775
- var Ce, je;
4776
- class dt extends (je = k, Ce = Symbol.toStringTag, je) {
4817
+ var Ce, Ie;
4818
+ class tt extends (Ie = S, Ce = Symbol.toStringTag, Ie) {
4777
4819
  /**
4778
4820
  * Initializes a new instance of the {@link TimedPromise} class.
4779
4821
  *
@@ -4802,18 +4844,68 @@ class dt extends (je = k, Ce = Symbol.toStringTag, je) {
4802
4844
  clearTimeout(C), s(T);
4803
4845
  }, l = (T) => {
4804
4846
  clearTimeout(C), r(T);
4805
- }, C = setTimeout(() => l(new Ke("The operation has timed out.")), t);
4847
+ }, C = setTimeout(() => l(new Ze("The operation has timed out.")), t);
4806
4848
  e(o, l);
4807
4849
  });
4808
4850
  a(this, Ce, "TimedPromise");
4809
4851
  }
4810
4852
  }
4811
- var R = /* @__PURE__ */ ((i) => (i[i.Millisecond = 1] = "Millisecond", i[i.Second = 1e3] = "Second", i[i.Minute = 6e4] = "Minute", i[i.Hour = 36e5] = "Hour", i[i.Day = 864e5] = "Day", i[i.Week = 6048e5] = "Week", i[i.Month = 2592e6] = "Month", i[i.Year = 31536e6] = "Year", i))(R || {}), Ue = /* @__PURE__ */ ((i) => (i[i.Sunday = 0] = "Sunday", i[i.Monday = 1] = "Monday", i[i.Tuesday = 2] = "Tuesday", i[i.Wednesday = 3] = "Wednesday", i[i.Thursday = 4] = "Thursday", i[i.Friday = 5] = "Friday", i[i.Saturday = 6] = "Saturday", i))(Ue || {});
4812
- function wt(i, n, e = 864e5) {
4853
+ var Ae, Ne;
4854
+ class _t extends (Ne = S, Ae = Symbol.toStringTag, Ne) {
4855
+ /**
4856
+ * Initializes a new instance of the {@link PromiseQueue} class.
4857
+ */
4858
+ constructor() {
4859
+ super((e) => e());
4860
+ /**
4861
+ * The number of promises currently in the queue.
4862
+ */
4863
+ a(this, "_count");
4864
+ a(this, Ae, "PromiseQueue");
4865
+ this._count = 0, this._isPending = !1, this._isFulfilled = !1, this._isRejected = !1;
4866
+ }
4867
+ /**
4868
+ * A flag indicating whether the promise is still pending or not.
4869
+ */
4870
+ get isPending() {
4871
+ return this._count > 0;
4872
+ }
4873
+ /**
4874
+ * A flag indicating whether the promise has been fulfilled or not.
4875
+ */
4876
+ get isFulfilled() {
4877
+ return this._count === 0;
4878
+ }
4879
+ /**
4880
+ * A flag indicating whether the promise has been rejected or not.
4881
+ *
4882
+ * Please note the {@link PromiseQueue} doesn't support rejection states.
4883
+ * Accessing this property will always result in a {@link ValueException}.
4884
+ */
4885
+ get isRejected() {
4886
+ throw new f("`PromiseQueue` doesn't support rejection states.");
4887
+ }
4888
+ enqueue(e, t) {
4889
+ if (this._count += 1, e instanceof Ve) {
4890
+ const r = e;
4891
+ e = () => (r.resolve(), r);
4892
+ }
4893
+ const s = (r, o) => {
4894
+ this._promise = this._promise.then(e).then((l) => {
4895
+ this._count -= 1, r(l);
4896
+ }).catch((l) => {
4897
+ this._count -= 1, o(l);
4898
+ });
4899
+ };
4900
+ return t ? new tt(s, t) : new Promise(s);
4901
+ }
4902
+ }
4903
+ var R = /* @__PURE__ */ ((i) => (i[i.Millisecond = 1] = "Millisecond", i[i.Second = 1e3] = "Second", i[i.Minute = 6e4] = "Minute", i[i.Hour = 36e5] = "Hour", i[i.Day = 864e5] = "Day", i[i.Week = 6048e5] = "Week", i[i.Month = 2592e6] = "Month", i[i.Year = 31536e6] = "Year", i))(R || {}), nt = /* @__PURE__ */ ((i) => (i[i.Sunday = 0] = "Sunday", i[i.Monday = 1] = "Monday", i[i.Tuesday = 2] = "Tuesday", i[i.Wednesday = 3] = "Wednesday", i[i.Thursday = 4] = "Thursday", i[i.Friday = 5] = "Friday", i[i.Saturday = 6] = "Saturday", i))(nt || {});
4904
+ function yt(i, n, e = 864e5) {
4813
4905
  let t;
4814
4906
  return i = new Date(i), n = new Date(n), i < n ? t = Math.floor : t = Math.ceil, t((n.getTime() - i.getTime()) / e);
4815
4907
  }
4816
- function mt(i, n, e = 864e5) {
4908
+ function bt(i, n, e = 864e5) {
4817
4909
  if (i = new Date(i), n = new Date(n), i >= n)
4818
4910
  throw new b("The end date must be greater than the start date.");
4819
4911
  return new u(function* () {
@@ -4823,7 +4915,7 @@ function mt(i, n, e = 864e5) {
4823
4915
  yield new Date(s), s += e;
4824
4916
  });
4825
4917
  }
4826
- function We(i, n = 864e5) {
4918
+ function st(i, n = 864e5) {
4827
4919
  if (n <= 1)
4828
4920
  throw new b(
4829
4921
  "Rounding a timestamp by milliseconds or less makes no sense.Use the timestamp value directly instead."
@@ -4834,14 +4926,14 @@ function We(i, n = 864e5) {
4834
4926
  );
4835
4927
  return i = new Date(i), new Date(Math.floor(i.getTime() / n) * n);
4836
4928
  }
4837
- function pt(i, n = 0) {
4929
+ function gt(i, n = 0) {
4838
4930
  i = new Date(i);
4839
4931
  const e = 7 - n, t = (i.getUTCDay() + e) % 7, s = i.getTime() - 864e5 * t;
4840
- return We(new Date(s));
4932
+ return st(new Date(s));
4841
4933
  }
4842
- var Ie;
4843
- Ie = Symbol.toStringTag;
4844
- class Je {
4934
+ var Oe;
4935
+ Oe = Symbol.toStringTag;
4936
+ class Ge {
4845
4937
  /**
4846
4938
  * Initializes a new instance of the {@link GameLoop} class.
4847
4939
  *
@@ -4898,8 +4990,8 @@ class Je {
4898
4990
  * {@link cancelAnimationFrame} or the {@link clearInterval} function.
4899
4991
  */
4900
4992
  a(this, "_stop");
4901
- a(this, Ie, "GameLoop");
4902
- this._startTime = 0, this._isRunning = !1, De ? (this._start = () => {
4993
+ a(this, Oe, "GameLoop");
4994
+ this._startTime = 0, this._isRunning = !1, Ye ? (this._start = () => {
4903
4995
  n(this.elapsedTime), this._handle = window.requestAnimationFrame(this._start);
4904
4996
  }, this._stop = () => window.cancelAnimationFrame(this._handle)) : (console.warn(
4905
4997
  `Not a browser environment detected. Using setInterval@${e}ms instead of requestAnimationFrame...`
@@ -5009,8 +5101,8 @@ class Je {
5009
5101
  return this._publisher.subscribe("stop", n);
5010
5102
  }
5011
5103
  }
5012
- var Ae, Ne;
5013
- class yt extends (Ne = Je, Ae = Symbol.toStringTag, Ne) {
5104
+ var qe, $e;
5105
+ class xt extends ($e = Ge, qe = Symbol.toStringTag, $e) {
5014
5106
  /**
5015
5107
  * Initializes a new instance of the {@link Clock} class.
5016
5108
  *
@@ -5029,12 +5121,7 @@ class yt extends (Ne = Je, Ae = Symbol.toStringTag, Ne) {
5029
5121
  */
5030
5122
  constructor(e = R.Second) {
5031
5123
  super((t) => this._publisher.publish("tick", t), e);
5032
- /**
5033
- * The {@link Publisher} object that will be used to publish the events of the clock.
5034
- */
5035
- a(this, "_publisher");
5036
- a(this, Ae, "Clock");
5037
- this._publisher = new v();
5124
+ a(this, qe, "Clock");
5038
5125
  }
5039
5126
  /**
5040
5127
  * Starts the execution of the clock.
@@ -5113,8 +5200,8 @@ class yt extends (Ne = Je, Ae = Symbol.toStringTag, Ne) {
5113
5200
  });
5114
5201
  }
5115
5202
  }
5116
- var Oe, $e;
5117
- class _t extends ($e = Je, Oe = Symbol.toStringTag, $e) {
5203
+ var ze, De;
5204
+ class vt extends (De = Ge, ze = Symbol.toStringTag, De) {
5118
5205
  /**
5119
5206
  * Initializes a new instance of the {@link Countdown} class.
5120
5207
  *
@@ -5139,10 +5226,6 @@ class _t extends ($e = Je, Oe = Symbol.toStringTag, $e) {
5139
5226
  const r = this.remainingTime;
5140
5227
  r <= 0 ? (this._deferrerStop(), this._publisher.publish("tick", 0), this._publisher.publish("expire")) : this._publisher.publish("tick", r);
5141
5228
  }, t);
5142
- /**
5143
- * The {@link Publisher} object that will be used to publish the events of the countdown.
5144
- */
5145
- a(this, "_publisher");
5146
5229
  /**
5147
5230
  * The total duration of the countdown in milliseconds.
5148
5231
  *
@@ -5154,8 +5237,8 @@ class _t extends ($e = Je, Oe = Symbol.toStringTag, $e) {
5154
5237
  * The {@link DeferredPromise} that will be resolved or rejected when the countdown expires or stops.
5155
5238
  */
5156
5239
  a(this, "_deferrer");
5157
- a(this, Oe, "Countdown");
5158
- this._publisher = new v(), this._duration = e;
5240
+ a(this, ze, "Countdown");
5241
+ this._duration = e;
5159
5242
  }
5160
5243
  /**
5161
5244
  * The total duration of the countdown in milliseconds.
@@ -5215,7 +5298,7 @@ class _t extends ($e = Je, Oe = Symbol.toStringTag, $e) {
5215
5298
  throw new p("The countdown had already stopped or hadn't yet started.");
5216
5299
  if (this._deferrer)
5217
5300
  throw new g();
5218
- return this._deferrer = new Ze(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
5301
+ return this._deferrer = new Ve(), super.start(this.duration - e), this._publisher.publish("start"), this._deferrer;
5219
5302
  }
5220
5303
  /**
5221
5304
  * Stops the execution of the countdown.
@@ -5296,11 +5379,11 @@ class _t extends ($e = Je, Oe = Symbol.toStringTag, $e) {
5296
5379
  });
5297
5380
  }
5298
5381
  }
5299
- var qe;
5300
- qe = Symbol.toStringTag;
5301
- class bt {
5382
+ var Be;
5383
+ Be = Symbol.toStringTag;
5384
+ class St {
5302
5385
  constructor() {
5303
- a(this, qe, "Curve");
5386
+ a(this, Be, "Curve");
5304
5387
  }
5305
5388
  /**
5306
5389
  * Generates a given number of values following a linear curve.
@@ -5359,7 +5442,7 @@ class bt {
5359
5442
  */
5360
5443
  static Exponential(n, e = 2) {
5361
5444
  if (e < 0)
5362
- throw new d("The base of the exponential curve cannot be negative.");
5445
+ throw new f("The base of the exponential curve cannot be negative.");
5363
5446
  const t = n - 1;
5364
5447
  return new u(function* () {
5365
5448
  for (let s = 0; s < n; s += 1)
@@ -5367,11 +5450,11 @@ class bt {
5367
5450
  });
5368
5451
  }
5369
5452
  }
5370
- var ze;
5371
- ze = Symbol.toStringTag;
5372
- const P = class P {
5453
+ var Je;
5454
+ Je = Symbol.toStringTag;
5455
+ const j = class j {
5373
5456
  constructor() {
5374
- a(this, ze, "Random");
5457
+ a(this, Je, "Random");
5375
5458
  }
5376
5459
  /**
5377
5460
  * Generates a random boolean value.
@@ -5420,7 +5503,7 @@ const P = class P {
5420
5503
  */
5421
5504
  static Index(n) {
5422
5505
  if (n.length === 0)
5423
- throw new d("You must provide at least one element.");
5506
+ throw new f("You must provide at least one element.");
5424
5507
  return this.Integer(n.length);
5425
5508
  }
5426
5509
  /**
@@ -5438,33 +5521,33 @@ const P = class P {
5438
5521
  * @returns A random element from the given array.
5439
5522
  */
5440
5523
  static Choice(n) {
5441
- return n[P.Index(n)];
5524
+ return n[j.Index(n)];
5442
5525
  }
5443
5526
  };
5444
- let j = P;
5445
- function gt(i) {
5527
+ let I = j;
5528
+ function kt(i) {
5446
5529
  return new Promise((n) => setTimeout(n, i));
5447
5530
  }
5448
- function xt() {
5531
+ function Tt() {
5449
5532
  return new Promise((i) => requestAnimationFrame(() => i()));
5450
5533
  }
5451
- function vt() {
5534
+ function Et() {
5452
5535
  return new Promise((i) => setTimeout(i));
5453
5536
  }
5454
- function St(i, n = "text/javascript") {
5537
+ function Mt(i, n = "text/javascript") {
5455
5538
  return new Promise((e, t) => {
5456
5539
  const s = document.createElement("script");
5457
5540
  s.async = !0, s.defer = !0, s.src = i, s.type = n, s.onload = (r) => e(), s.onerror = (r) => t(r), document.body.appendChild(s);
5458
5541
  });
5459
5542
  }
5460
- function kt(...i) {
5543
+ function Rt(...i) {
5461
5544
  return new u(function* () {
5462
5545
  for (const n of i)
5463
5546
  for (const e of n)
5464
5547
  yield e;
5465
5548
  });
5466
5549
  }
5467
- function Tt(i) {
5550
+ function Ft(i) {
5468
5551
  if (i instanceof Array)
5469
5552
  return i.length;
5470
5553
  let n = 0;
@@ -5472,14 +5555,14 @@ function Tt(i) {
5472
5555
  n += 1;
5473
5556
  return n;
5474
5557
  }
5475
- function Et(i) {
5558
+ function Pt(i) {
5476
5559
  return new u(function* () {
5477
5560
  let n = 0;
5478
5561
  for (const e of i)
5479
5562
  yield [n, e], n += 1;
5480
5563
  });
5481
5564
  }
5482
- function Mt(i, n, e = 1) {
5565
+ function jt(i, n, e = 1) {
5483
5566
  if (e <= 0)
5484
5567
  throw new b(
5485
5568
  "Step must be always a positive number, even when generating numbers in reverse order."
@@ -5492,7 +5575,7 @@ function Mt(i, n, e = 1) {
5492
5575
  yield t;
5493
5576
  });
5494
5577
  }
5495
- function Rt(i) {
5578
+ function Ct(i) {
5496
5579
  const n = Array.from(i);
5497
5580
  for (let e = n.length - 1; e > 0; e -= 1) {
5498
5581
  const t = Math.floor(Math.random() * (e + 1));
@@ -5500,14 +5583,14 @@ function Rt(i) {
5500
5583
  }
5501
5584
  return n;
5502
5585
  }
5503
- function Ft(i) {
5586
+ function It(i) {
5504
5587
  return new u(function* () {
5505
5588
  const n = /* @__PURE__ */ new Set();
5506
5589
  for (const e of i)
5507
5590
  n.has(e) || (n.add(e), yield e);
5508
5591
  });
5509
5592
  }
5510
- function et(i, n) {
5593
+ function rt(i, n) {
5511
5594
  const e = i[Symbol.iterator](), t = n[Symbol.iterator]();
5512
5595
  return new u(function* () {
5513
5596
  for (; ; ) {
@@ -5518,28 +5601,28 @@ function et(i, n) {
5518
5601
  }
5519
5602
  });
5520
5603
  }
5521
- function Pt(i, n) {
5604
+ function At(i, n) {
5522
5605
  if (n === void 0) {
5523
5606
  let r = 0, o = 0;
5524
5607
  for (const l of i)
5525
5608
  r += l, o += 1;
5526
5609
  if (o === 0)
5527
- throw new d("You must provide at least one value.");
5610
+ throw new f("You must provide at least one value.");
5528
5611
  return r / o;
5529
5612
  }
5530
5613
  let e = 0, t = 0, s = 0;
5531
- for (const [r, o] of et(i, n)) {
5614
+ for (const [r, o] of rt(i, n)) {
5532
5615
  if (o <= 0)
5533
- throw new d(`The weight for the value #${s} must be greater than zero.`);
5616
+ throw new f(`The weight for the value #${s} must be greater than zero.`);
5534
5617
  e += r * o, t += o, s += 1;
5535
5618
  }
5536
5619
  if (s === 0)
5537
- throw new d("You must provide at least one value and weight.");
5620
+ throw new f("You must provide at least one value and weight.");
5538
5621
  if (t <= 0)
5539
- throw new d("The sum of weights must be greater than zero.");
5622
+ throw new f("The sum of weights must be greater than zero.");
5540
5623
  return e / t;
5541
5624
  }
5542
- function Ct(i) {
5625
+ function Nt(i) {
5543
5626
  let n = 0;
5544
5627
  for (let e = 0; e < i.length; e += 1) {
5545
5628
  const t = i.charCodeAt(e);
@@ -5547,76 +5630,77 @@ function Ct(i) {
5547
5630
  }
5548
5631
  return n;
5549
5632
  }
5550
- function jt(i) {
5633
+ function Ot(i) {
5551
5634
  let n = 0;
5552
5635
  for (const e of i)
5553
5636
  n += e;
5554
5637
  return n;
5555
5638
  }
5556
- function It(i) {
5639
+ function qt(i) {
5557
5640
  return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
5558
5641
  }
5559
- const At = "2.1.3";
5642
+ const $t = "2.1.5";
5560
5643
  export {
5561
5644
  M as AggregatedAsyncIterator,
5562
5645
  x as AggregatedIterator,
5563
- Qe as CallableObject,
5564
- yt as Clock,
5565
- _t as Countdown,
5566
- bt as Curve,
5567
- Ze as DeferredPromise,
5568
- Ge as EnvironmentException,
5646
+ Ue as CallableObject,
5647
+ xt as Clock,
5648
+ vt as Countdown,
5649
+ St as Curve,
5650
+ Ve as DeferredPromise,
5651
+ Xe as EnvironmentException,
5569
5652
  c as Exception,
5570
5653
  g as FatalErrorException,
5571
- Be as FileException,
5572
- rt as FileExistsException,
5573
- it as FileNotFoundException,
5574
- Je as GameLoop,
5575
- ft as JSONStorage,
5576
- y as KeyException,
5577
- ct as MapView,
5578
- ot as NetworkException,
5579
- Ve as NotImplementedException,
5580
- at as PermissionException,
5654
+ Le as FileException,
5655
+ lt as FileExistsException,
5656
+ ut as FileNotFoundException,
5657
+ Ge as GameLoop,
5658
+ pt as JSONStorage,
5659
+ _ as KeyException,
5660
+ wt as MapView,
5661
+ ct as NetworkException,
5662
+ He as NotImplementedException,
5663
+ ht as PermissionException,
5664
+ _t as PromiseQueue,
5581
5665
  v as Publisher,
5582
- j as Random,
5666
+ I as Random,
5583
5667
  b as RangeException,
5584
5668
  h as ReducedIterator,
5585
5669
  E as ReferenceException,
5586
5670
  p as RuntimeException,
5587
- ht as SetView,
5588
- f as SmartAsyncIterator,
5671
+ mt as SetView,
5672
+ d as SmartAsyncIterator,
5589
5673
  u as SmartIterator,
5590
- k as SmartPromise,
5591
- ut as SwitchableCallback,
5674
+ S as SmartPromise,
5675
+ dt as SwitchableCallback,
5592
5676
  R as TimeUnit,
5593
- dt as TimedPromise,
5594
- Ke as TimeoutException,
5595
- lt as TypeException,
5596
- At as VERSION,
5597
- d as ValueException,
5598
- Ue as WeekDay,
5599
- Pt as average,
5600
- It as capitalize,
5601
- kt as chain,
5602
- Tt as count,
5603
- wt as dateDifference,
5604
- mt as dateRange,
5605
- We as dateRound,
5606
- gt as delay,
5607
- Et as enumerate,
5608
- pt as getWeek,
5609
- Ct as hash,
5610
- De as isBrowser,
5611
- nt as isNode,
5612
- st as isWorker,
5613
- St as loadScript,
5614
- xt as nextAnimationFrame,
5615
- Mt as range,
5616
- Rt as shuffle,
5617
- jt as sum,
5618
- Ft as unique,
5619
- vt as yieldToEventLoop,
5620
- et as zip
5677
+ tt as TimedPromise,
5678
+ Ze as TimeoutException,
5679
+ ft as TypeException,
5680
+ $t as VERSION,
5681
+ f as ValueException,
5682
+ nt as WeekDay,
5683
+ At as average,
5684
+ qt as capitalize,
5685
+ Rt as chain,
5686
+ Ft as count,
5687
+ yt as dateDifference,
5688
+ bt as dateRange,
5689
+ st as dateRound,
5690
+ kt as delay,
5691
+ Pt as enumerate,
5692
+ gt as getWeek,
5693
+ Nt as hash,
5694
+ Ye as isBrowser,
5695
+ ot as isNode,
5696
+ at as isWorker,
5697
+ Mt as loadScript,
5698
+ Tt as nextAnimationFrame,
5699
+ jt as range,
5700
+ Ct as shuffle,
5701
+ Ot as sum,
5702
+ It as unique,
5703
+ Et as yieldToEventLoop,
5704
+ rt as zip
5621
5705
  };
5622
5706
  //# sourceMappingURL=core.esm.js.map