@flemist/simple-utils 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1947 @@
1
+ import { AbortControllerFast as Et, toAbortSignal as Gt, AbortError as Jt } from "@flemist/abort-controller-fast";
2
+ import { isPromiseLike as et, EMPTY_FUNC as Xt, delay as Yt, ValueState as Qt } from "@flemist/async-utils";
3
+ import { timeControllerDefault as At } from "@flemist/time-controller";
4
+ let H = null;
5
+ function Zt() {
6
+ if (!H) {
7
+ H = new Array(256);
8
+ for (let t = 0; t < 256; t++)
9
+ H[t] = t.toString(16).padStart(2, "0");
10
+ }
11
+ return H;
12
+ }
13
+ function te(t) {
14
+ const e = Zt(), r = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
15
+ let n = "";
16
+ for (let s = 0, i = r.length; s < i; s++)
17
+ n += e[r[s]];
18
+ return n;
19
+ }
20
+ let pt = null, Mt = null, X = null, Tt = null;
21
+ function ee() {
22
+ pt || (pt = new Uint32Array([
23
+ 1116352408,
24
+ 1899447441,
25
+ 3049323471,
26
+ 3921009573,
27
+ 961987163,
28
+ 1508970993,
29
+ 2453635748,
30
+ 2870763221,
31
+ 3624381080,
32
+ 310598401,
33
+ 607225278,
34
+ 1426881987,
35
+ 1925078388,
36
+ 2162078206,
37
+ 2614888103,
38
+ 3248222580,
39
+ 3835390401,
40
+ 4022224774,
41
+ 264347078,
42
+ 604807628,
43
+ 770255983,
44
+ 1249150122,
45
+ 1555081692,
46
+ 1996064986,
47
+ 2554220882,
48
+ 2821834349,
49
+ 2952996808,
50
+ 3210313671,
51
+ 3336571891,
52
+ 3584528711,
53
+ 113926993,
54
+ 338241895,
55
+ 666307205,
56
+ 773529912,
57
+ 1294757372,
58
+ 1396182291,
59
+ 1695183700,
60
+ 1986661051,
61
+ 2177026350,
62
+ 2456956037,
63
+ 2730485921,
64
+ 2820302411,
65
+ 3259730800,
66
+ 3345764771,
67
+ 3516065817,
68
+ 3600352804,
69
+ 4094571909,
70
+ 275423344,
71
+ 430227734,
72
+ 506948616,
73
+ 659060556,
74
+ 883997877,
75
+ 958139571,
76
+ 1322822218,
77
+ 1537002063,
78
+ 1747873779,
79
+ 1955562222,
80
+ 2024104815,
81
+ 2227730452,
82
+ 2361852424,
83
+ 2428436474,
84
+ 2756734187,
85
+ 3204031479,
86
+ 3329325298
87
+ ]), Mt = new Uint32Array(64), Tt = new TextEncoder(), X = new Uint8Array(65536));
88
+ }
89
+ function re(t) {
90
+ if (t == null)
91
+ return null;
92
+ ee();
93
+ const e = pt, r = Mt, n = Tt;
94
+ let s = X, i;
95
+ if (typeof t == "string") {
96
+ const g = t.length * 3;
97
+ s.length < g + 128 && (s = X = new Uint8Array(g + 128));
98
+ const d = n.encodeInto(t, s);
99
+ i = s.subarray(0, d.written);
100
+ } else if (t instanceof Uint8Array)
101
+ i = t;
102
+ else if (ArrayBuffer.isView(t))
103
+ i = new Uint8Array(
104
+ t.buffer,
105
+ t.byteOffset,
106
+ t.byteLength
107
+ );
108
+ else
109
+ throw new Error(
110
+ `[sha256Buffer] Unsupported content type: ${typeof t}`
111
+ );
112
+ const o = i.length, u = o + 72 >>> 6 << 6;
113
+ s.length < u && (s = X = new Uint8Array(u)), i !== s && s.set(i), s[o] = 128;
114
+ for (let g = o + 1; g < u; g++)
115
+ s[g] = 0;
116
+ const a = o * 8, l = a / 4294967296 | 0, f = a | 0;
117
+ s[u - 8] = l >>> 24, s[u - 7] = l >>> 16, s[u - 6] = l >>> 8, s[u - 5] = l, s[u - 4] = f >>> 24, s[u - 3] = f >>> 16, s[u - 2] = f >>> 8, s[u - 1] = f;
118
+ let w = 1779033703, y = -1150833019, h = 1013904242, c = -1521486534, m = 1359893119, $ = -1694144372, b = 528734635, O = 1541459225;
119
+ for (let g = 0; g < u; g += 64) {
120
+ for (let _ = 0; _ < 16; _++) {
121
+ const x = g + (_ << 2);
122
+ r[_] = s[x] << 24 | s[x + 1] << 16 | s[x + 2] << 8 | s[x + 3];
123
+ }
124
+ for (let _ = 16; _ < 64; _++) {
125
+ const x = r[_ - 15], C = r[_ - 2], at = (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3, W = (C >>> 17 | C << 15) ^ (C >>> 19 | C << 13) ^ C >>> 10;
126
+ r[_] = r[_ - 16] + at + r[_ - 7] + W | 0;
127
+ }
128
+ let d = w, E = y, B = h, ut = c, A = m, q = $, V = b, ot = O;
129
+ for (let _ = 0; _ < 64; _ += 4)
130
+ for (let x = 0; x < 4; x++) {
131
+ const C = _ + x, at = (A >>> 6 | A << 26) ^ (A >>> 11 | A << 21) ^ (A >>> 25 | A << 7), W = ot + at + (V ^ A & (q ^ V)) + e[C] + r[C] | 0, Ht = ((d >>> 2 | d << 30) ^ (d >>> 13 | d << 19) ^ (d >>> 22 | d << 10)) + (d & E ^ B & (d ^ E)) | 0;
132
+ ot = V, V = q, q = A, A = ut + W | 0, ut = B, B = E, E = d, d = W + Ht | 0;
133
+ }
134
+ w = w + d | 0, y = y + E | 0, h = h + B | 0, c = c + ut | 0, m = m + A | 0, $ = $ + q | 0, b = b + V | 0, O = O + ot | 0;
135
+ }
136
+ const S = new Uint8Array(32), K = [w, y, h, c, m, $, b, O];
137
+ for (let g = 0; g < 8; g++) {
138
+ const d = K[g], E = g << 2;
139
+ S[E] = d >>> 24, S[E + 1] = d >>> 16 & 255, S[E + 2] = d >>> 8 & 255, S[E + 3] = d & 255;
140
+ }
141
+ return S;
142
+ }
143
+ function Qe(t) {
144
+ const e = re(t);
145
+ return e ? te(e) : null;
146
+ }
147
+ function ne(t, e) {
148
+ return t == null ? e : e == null ? t : Math.min(t, e);
149
+ }
150
+ function se(t, e) {
151
+ return t == null ? e : e == null ? t : Math.max(t, e);
152
+ }
153
+ function Ze(t, e, r) {
154
+ return se(ne(t, e), r);
155
+ }
156
+ function tr(t, e) {
157
+ return (t % e + e) % e;
158
+ }
159
+ function ie(t) {
160
+ return function() {
161
+ let r = t += 1831565813;
162
+ return r = Math.imul(r ^ r >>> 15, r | 1), r ^= r + Math.imul(r ^ r >>> 7, r | 61), (r ^ r >>> 14) / 4294967296 + 0.5;
163
+ };
164
+ }
165
+ function ue() {
166
+ return Math.random();
167
+ }
168
+ function er() {
169
+ return Math.random() * 2 ** 32 >>> 0;
170
+ }
171
+ function oe(t) {
172
+ return t != null ? ie(t) : ue;
173
+ }
174
+ class dt {
175
+ _seed;
176
+ _rnd;
177
+ constructor(e) {
178
+ this._seed = e, this._rnd = oe(e);
179
+ }
180
+ get seed() {
181
+ return this._seed;
182
+ }
183
+ nextSeed() {
184
+ return this.next() * 2 ** 32 >>> 0;
185
+ }
186
+ nextRandom() {
187
+ return new dt(this.nextSeed());
188
+ }
189
+ next() {
190
+ return this._rnd();
191
+ }
192
+ clone() {
193
+ return new dt(this._seed);
194
+ }
195
+ }
196
+ function Ct(t, e, r) {
197
+ if (r == null && (r = e, e = 0), r <= e)
198
+ throw new Error(
199
+ `[random][randomFloat] toExclusive (${r}) must be greater than from (${e})`
200
+ );
201
+ return t.next() * (r - e) + e;
202
+ }
203
+ function ae(t, e, r) {
204
+ return Math.floor(Ct(t, e, r));
205
+ }
206
+ function rr(t, e) {
207
+ return t.next() < (e ?? 0.5);
208
+ }
209
+ function nr(t, e, r) {
210
+ if (Array.isArray(e)) {
211
+ const i = e;
212
+ e = i.length, r = (o) => i[o];
213
+ }
214
+ if (!r)
215
+ throw new Error("[random][randomIndexWeighted] getWeight is required");
216
+ let n = 0;
217
+ for (let i = 0; i < e; i++)
218
+ n += r(i);
219
+ if (n === 0)
220
+ return -1;
221
+ let s = Ct(t, n);
222
+ for (let i = 0; i < e; i++)
223
+ if (s -= r(i), s < 0)
224
+ return i;
225
+ return e - 1;
226
+ }
227
+ function It(t, e) {
228
+ if (e.length === 0)
229
+ throw new Error("[random][randomItem] items is empty");
230
+ const r = ae(t, e.length);
231
+ return e[r];
232
+ }
233
+ function sr(t, e, r) {
234
+ if (e.length === 0)
235
+ throw new Error("[random][randomItems] items is empty");
236
+ const n = [];
237
+ for (let s = 0; s < r; s++)
238
+ n.push(It(t, e));
239
+ return n;
240
+ }
241
+ function ir(t, e, r) {
242
+ let n = Object.values(e);
243
+ return r && (n = n.filter(r)), It(t, n);
244
+ }
245
+ const Nt = 1073741789, lt = (Nt >> 2) - 1;
246
+ function ur(t = lt, e) {
247
+ if (t <= 0)
248
+ throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);
249
+ if (t > lt)
250
+ throw new Error(
251
+ `[random][PseudoRandom] count(${t}) must be <= ${lt}`
252
+ );
253
+ if (e == null && (e = Math.floor(Math.random() * t)), e >= t)
254
+ throw new Error(
255
+ `[random][PseudoRandom] startFrom(${e}) must be < count(${t})`
256
+ );
257
+ let r = e;
258
+ return function() {
259
+ return r = (r + Nt) % t, r;
260
+ };
261
+ }
262
+ let F = null;
263
+ function or() {
264
+ const t = Date.now();
265
+ return F == null || t > F ? (F = t, t) : (F++, F);
266
+ }
267
+ async function ar({
268
+ url: t,
269
+ timeout: e
270
+ } = {}) {
271
+ t || (t = typeof window < "u" ? "/" : "https://google.com");
272
+ let r;
273
+ try {
274
+ const n = new Et();
275
+ r = e ? setTimeout(() => {
276
+ n.abort();
277
+ }, e) : null;
278
+ const s = await fetch(t, {
279
+ method: "HEAD",
280
+ signal: Gt(n.signal)
281
+ }), i = s.headers.get("date");
282
+ if (!i)
283
+ throw new Error(
284
+ `[Now][getDateInet] No date header in response: ${s.status} ${t}`
285
+ );
286
+ return new Date(i).getTime();
287
+ } finally {
288
+ r && clearTimeout(r);
289
+ }
290
+ }
291
+ function Dt(t, e, r) {
292
+ const n = e == null ? t : new Date(
293
+ t.toLocaleString("en-US", {
294
+ timeZone: e
295
+ })
296
+ ), s = r == null ? t : new Date(
297
+ t.toLocaleString("en-US", {
298
+ timeZone: r
299
+ })
300
+ );
301
+ return new Date(
302
+ t.getTime() + s.getTime() - n.getTime()
303
+ );
304
+ }
305
+ function le(t, e) {
306
+ t = Dt(t, "UTC", e);
307
+ const r = t.getUTCFullYear().toString().padStart(4, "0"), n = (t.getUTCMonth() + 1).toString().padStart(2, "0"), s = t.getUTCDate().toString().padStart(2, "0"), i = t.getUTCHours().toString().padStart(2, "0"), o = t.getUTCMinutes().toString().padStart(2, "0"), u = t.getUTCSeconds().toString().padStart(2, "0");
308
+ return `${r}-${n}-${s} ${i}:${o}:${u}`;
309
+ }
310
+ let ce = 0;
311
+ const ct = /* @__PURE__ */ new WeakMap();
312
+ function P(t) {
313
+ if (ct.has(t))
314
+ return ct.get(t);
315
+ const e = ce++;
316
+ return ct.set(t, e), e;
317
+ }
318
+ function G(t, e, r) {
319
+ if (t == null)
320
+ return null;
321
+ if (e == null || t.length <= e)
322
+ return t;
323
+ const n = r?.appendEllipsis ? "…" : "", s = n.length + (r?.appendTruncatedLength ? String(t.length).length + 2 : 0), i = Math.max(0, e - s), o = r?.appendTruncatedLength ? `(${t.length - i})` : "";
324
+ return i <= 0 ? o + n : r?.fromStart ? o + n + t.slice(t.length - i) : t.slice(0, i) + n + o;
325
+ }
326
+ function _t(t, e) {
327
+ try {
328
+ return t[e];
329
+ } catch (r) {
330
+ return "Error: " + (r instanceof Error ? r.message : String(r));
331
+ }
332
+ }
333
+ function U(t, e, r, n) {
334
+ const {
335
+ pretty: s,
336
+ filter: i,
337
+ maxDepth: o,
338
+ maxItems: u,
339
+ maxStringLength: a,
340
+ showObjectId: l,
341
+ showArrayIndex: f,
342
+ customToString: w
343
+ } = e ?? {};
344
+ if (r == null && (r = []), n == null && (n = /* @__PURE__ */ new Set()), w) {
345
+ const h = w(
346
+ t,
347
+ r,
348
+ (c) => U(c, e, r, n)
349
+ );
350
+ if (h != null)
351
+ return G(h, a, e?.truncateOptions);
352
+ }
353
+ const y = r.length;
354
+ if (typeof t == "string")
355
+ return t = G(t, a, e?.truncateOptions), n.size > 0 && (t = JSON.stringify(t)), t;
356
+ if (t == null || typeof t != "object")
357
+ return String(t);
358
+ if (t instanceof ArrayBuffer || ArrayBuffer.isView(t))
359
+ return `${t.constructor?.name ?? ""}#${P(t)}[${t.byteLength}]`;
360
+ if (t instanceof RegExp)
361
+ return G(
362
+ String(t),
363
+ a,
364
+ e?.truncateOptions
365
+ );
366
+ if (t instanceof Date)
367
+ return le(t);
368
+ if (t instanceof Object) {
369
+ if (n.has(t) || o != null && y >= o)
370
+ return `${t.constructor === Object ? "" : t.constructor?.name ?? ""}#${P(t)}`;
371
+ n.add(t);
372
+ }
373
+ if (t instanceof Error)
374
+ return G(
375
+ t.stack || t.message || String(t),
376
+ a,
377
+ e?.truncateOptions
378
+ );
379
+ if (Array.isArray(t)) {
380
+ const h = s ? " ".repeat(y) : "";
381
+ let c = "";
382
+ l && (c += `#${P(t)} `), c += "[";
383
+ let m = 0, $ = !1;
384
+ for (let b = 0; b < t.length; b++) {
385
+ if (u != null && m >= u) {
386
+ $ = !0;
387
+ break;
388
+ }
389
+ const O = [...r, String(b)], S = _t(t, b);
390
+ if (i != null && !i(O, S))
391
+ continue;
392
+ const K = U(S, e, O, n);
393
+ m > 0 && (c += ","), s && (c += `
394
+ `), s && (c += `${h} `), f && (c += `${b}: `), c += `${K}`, m++;
395
+ }
396
+ return $ ? (m > 0 && (c += ","), s ? (c += `
397
+ `, c += `${h} ...
398
+ `) : c += "...", c += h, c += "]") : (m > 0 && s && (c += `
399
+ ${h}`), c += "]"), c;
400
+ }
401
+ if (t instanceof Map) {
402
+ let h = "";
403
+ return l && (h += `#${P(t)} `), h += "Map", h += U(Array.from(t.entries()), e, r, n), h;
404
+ }
405
+ if (t instanceof Set) {
406
+ let h = "";
407
+ return l && (h += `#${P(t)} `), h += "Set", h += U(Array.from(t.values()), e, r, n), h;
408
+ }
409
+ {
410
+ const h = t.constructor === Object ? "" : t.constructor?.name ?? "", c = s ? " ".repeat(y) : "";
411
+ let m = h ? `${h} ` : "";
412
+ l && (m += `#${P(t)} `), m += "{";
413
+ let $ = 0, b = !1;
414
+ for (const O in t) {
415
+ if (u != null && $ >= u) {
416
+ b = !0;
417
+ break;
418
+ }
419
+ const S = [...r, O], K = _t(t, O);
420
+ if (i != null && !i(S, K))
421
+ continue;
422
+ const g = U(K, e, S, n);
423
+ $ > 0 && (m += ","), s && (m += `
424
+ `), s && (m += `${c} `), m += `${O}: ${g}`, $++;
425
+ }
426
+ return b && ($ > 0 && (m += ","), s ? (m += `
427
+ `, m += `${c} ...
428
+ `) : m += "...", m += c), $ > 0 && s && !b && (m += `
429
+ ${c}`), m += "}", m;
430
+ }
431
+ }
432
+ function fe(t, e) {
433
+ t = Dt(t, "UTC", e);
434
+ const r = t.getUTCFullYear().toString().padStart(4, "0"), n = (t.getUTCMonth() + 1).toString().padStart(2, "0"), s = t.getUTCDate().toString().padStart(2, "0"), i = t.getUTCHours().toString().padStart(2, "0"), o = t.getUTCMinutes().toString().padStart(2, "0"), u = t.getUTCSeconds().toString().padStart(2, "0");
435
+ return `${r}-${n}-${s}_${i}-${o}-${u}`;
436
+ }
437
+ function lr(t) {
438
+ return t == null ? null : t.replace(/[&<>"']/g, (e) => {
439
+ switch (e) {
440
+ case "&":
441
+ return "&amp;";
442
+ case "<":
443
+ return "&lt;";
444
+ case ">":
445
+ return "&rt;";
446
+ case '"':
447
+ return "&quot;";
448
+ default:
449
+ return "&#039;";
450
+ }
451
+ });
452
+ }
453
+ function cr(t) {
454
+ return t == null ? null : t?.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
455
+ }
456
+ function bt(t) {
457
+ if (t == null)
458
+ return null;
459
+ if (Array.isArray(t)) {
460
+ const e = t.length, r = [];
461
+ for (let n = 0; n < e; n++)
462
+ r.push(bt(t[n]));
463
+ return r;
464
+ }
465
+ if (typeof t == "object") {
466
+ if (t.constructor && t.constructor !== Object)
467
+ return t;
468
+ const e = {};
469
+ for (const r in t)
470
+ Object.prototype.hasOwnProperty.call(t, r) && (e[r] = bt(t[r]));
471
+ return e;
472
+ }
473
+ return t;
474
+ }
475
+ function Y(t, e) {
476
+ if (t === e)
477
+ return !0;
478
+ if (t == null)
479
+ return e == null;
480
+ if (e == null)
481
+ return !1;
482
+ if (Array.isArray(t)) {
483
+ if (!Array.isArray(e))
484
+ return !1;
485
+ const r = t.length;
486
+ if (r !== e.length)
487
+ return !1;
488
+ for (let n = 0; n < r; n++)
489
+ if (!Y(t[n], e[n]))
490
+ return !1;
491
+ return !0;
492
+ }
493
+ if (typeof t == "object") {
494
+ if (typeof e != "object" || t.constructor && t.constructor !== Object || e.constructor && e.constructor !== Object)
495
+ return !1;
496
+ for (const r in t)
497
+ if (Object.prototype.hasOwnProperty.call(t, r) && !Y(
498
+ t[r],
499
+ Object.prototype.hasOwnProperty.call(e, r) ? e[r] : null
500
+ ))
501
+ return !1;
502
+ for (const r in e)
503
+ if (Object.prototype.hasOwnProperty.call(e, r) && !Object.prototype.hasOwnProperty.call(t, r) && !Y(e[r], null))
504
+ return !1;
505
+ return !0;
506
+ }
507
+ return !1;
508
+ }
509
+ function fr(t, e) {
510
+ if (t == null || e == null)
511
+ return t == null == (e == null);
512
+ if (t.size !== e.size)
513
+ return !1;
514
+ for (const [r, n] of t)
515
+ if (!Y(n, e.get(r)))
516
+ return !1;
517
+ return !0;
518
+ }
519
+ function hr(t, e) {
520
+ const r = t.length;
521
+ if (r !== e.length)
522
+ return !1;
523
+ for (let n = 0; n < r; n++)
524
+ if (t[n] !== e[n])
525
+ return !1;
526
+ return !0;
527
+ }
528
+ function xt(t) {
529
+ return !t || typeof t != "object" ? t : Array.isArray(t) ? t.map(xt) : t && Object.keys(t).sort().reduce((e, r) => {
530
+ const n = xt(t[r]);
531
+ return n != null && (e[r] = n), e;
532
+ }, {});
533
+ }
534
+ function mr(t, e) {
535
+ return Object.defineProperty(t, "name", { value: e, configurable: !0 }), t;
536
+ }
537
+ function pr(t) {
538
+ const e = alert;
539
+ return window.alert = (r) => t(e, r), () => {
540
+ window.alert = e;
541
+ };
542
+ }
543
+ var v = /* @__PURE__ */ ((t) => (t.log = "log", t.warn = "warn", t.error = "error", t.info = "info", t.debug = "debug", t.trace = "trace", t.assert = "assert", t))(v || {});
544
+ const $t = Object.values(v);
545
+ function D(t) {
546
+ return function() {
547
+ t.apply(console, arguments);
548
+ };
549
+ }
550
+ const Ot = {
551
+ log: D(console.log),
552
+ warn: D(console.warn),
553
+ error: D(console.error),
554
+ info: D(console.info),
555
+ debug: D(console.debug),
556
+ trace: D(console.trace),
557
+ assert: D(console.assert)
558
+ };
559
+ function kt(t) {
560
+ return $t.forEach((e) => {
561
+ console[e] = (...r) => {
562
+ t(Ot, e, r);
563
+ };
564
+ }), () => {
565
+ $t.forEach((e) => {
566
+ console[e] = Ot[e];
567
+ });
568
+ };
569
+ }
570
+ function dr(t) {
571
+ return function(r) {
572
+ let n = null;
573
+ const i = kt((u, a, l) => {
574
+ try {
575
+ t(u, a, l);
576
+ } catch (f) {
577
+ throw n || (n = f), f;
578
+ }
579
+ }), o = () => {
580
+ if (i(), n)
581
+ throw n;
582
+ };
583
+ try {
584
+ const u = r();
585
+ return et(u) ? u.then(
586
+ (a) => (o(), a),
587
+ (a) => {
588
+ throw o(), a;
589
+ }
590
+ ) : (o(), u);
591
+ } catch (u) {
592
+ throw o(), u;
593
+ }
594
+ };
595
+ }
596
+ class Ut {
597
+ _listeners = /* @__PURE__ */ new Map();
598
+ _listenersAdd = /* @__PURE__ */ new Map();
599
+ _startStopNotifier;
600
+ _emit;
601
+ _update;
602
+ _unsubscribeNotifier = null;
603
+ _emitLast;
604
+ _hasLast;
605
+ _last = void 0;
606
+ _emitting = !1;
607
+ _subscribing = !1;
608
+ _actionOnCycle;
609
+ constructor({
610
+ emitLastEvent: e,
611
+ startStopNotifier: r,
612
+ hasLast: n,
613
+ last: s,
614
+ actionOnCycle: i
615
+ } = {}) {
616
+ this._startStopNotifier = r ?? null, this._emit = r ? (o) => this.emit(o) : null, this._update = r ? (o) => this.update(o) : null, this._emitLast = e ?? !1, this._hasLast = n ?? !1, this._last = s, this._actionOnCycle = i ?? !1;
617
+ }
618
+ get hasLast() {
619
+ return this._hasLast;
620
+ }
621
+ get last() {
622
+ return this._last;
623
+ }
624
+ get hasListeners() {
625
+ return this._listeners.size > 0;
626
+ }
627
+ subscribe(e) {
628
+ const r = {};
629
+ if (this._emitting ? this._listenersAdd.set(r, e) : this._listeners.set(r, e), this._subscribing && this._actionOnCycle === "throw")
630
+ throw new Error("[Rx][Subject] Circular subscription detected");
631
+ if ((this._hasLast || this._subscribing && this._actionOnCycle === "emitLast") && e(this._last), this._startStopNotifier && this._listeners.size + this._listenersAdd.size === 1)
632
+ try {
633
+ this._subscribing = !0, this._unsubscribeNotifier = this._startStopNotifier(this._emit, this._update) ?? null;
634
+ } finally {
635
+ this._subscribing = !1;
636
+ }
637
+ return () => {
638
+ if (this._listeners.delete(r), this._listenersAdd.delete(r), this._startStopNotifier && this._listeners.size === 0 && this._listenersAdd.size === 0) {
639
+ const n = this._unsubscribeNotifier;
640
+ this._unsubscribeNotifier = null, n?.();
641
+ }
642
+ };
643
+ }
644
+ emit(e) {
645
+ if (this._emitting) {
646
+ if (this._actionOnCycle === "throw")
647
+ throw new Error("[Rx][Subject] Circular emit detected");
648
+ this._actionOnCycle === "emitLast" && (this._last = e, this._hasLast = !0);
649
+ return;
650
+ }
651
+ const r = () => {
652
+ this._listenersAdd.size > 0 && (this._listenersAdd.forEach((n, s) => {
653
+ this._listeners.set(s, n);
654
+ }), this._listenersAdd.clear()), this._emitting = !1;
655
+ };
656
+ try {
657
+ this._emitting = !0, this._emitLast && (this._last = e, this._hasLast = !0);
658
+ let n;
659
+ if (this._listeners.forEach((s) => {
660
+ const i = s(e);
661
+ et(i) && (n || (n = []), n.push(i));
662
+ }), n)
663
+ return Promise.all(n).then(r, (s) => {
664
+ throw r(), s;
665
+ });
666
+ r();
667
+ } catch (n) {
668
+ throw r(), n;
669
+ }
670
+ }
671
+ update(e) {
672
+ if (!this._emitLast)
673
+ throw new Error(
674
+ "[Rx][Subject] update available only for subjects with emitLastEvent"
675
+ );
676
+ const r = e(this._last);
677
+ return this.emit(r);
678
+ }
679
+ }
680
+ function he(t, e) {
681
+ return U(t, {
682
+ maxDepth: 5,
683
+ maxItems: 10,
684
+ ...e
685
+ });
686
+ }
687
+ function me(t) {
688
+ return t.map(
689
+ (e) => e && typeof e == "object" ? he(e) : e
690
+ );
691
+ }
692
+ function yr(t) {
693
+ return `${fe(/* @__PURE__ */ new Date())} [${t.level.toUpperCase()}] ${me(
694
+ t.args
695
+ ).join(" ")}`;
696
+ }
697
+ let Q = null, ft = null;
698
+ function pe() {
699
+ return ft || (ft = new Ut({
700
+ startStopNotifier: (t) => (Q = t, () => {
701
+ Q = null;
702
+ })
703
+ })), ft;
704
+ }
705
+ function gr() {
706
+ return kt((t, e, r) => {
707
+ e === "assert" && r[0] === !0 || (e === v.error || e === v.warn || e === v.assert) && (Q && Q({
708
+ date: Date.now(),
709
+ level: e,
710
+ args: r
711
+ }), t[e](...r));
712
+ });
713
+ }
714
+ function wr(t) {
715
+ if (typeof window > "u")
716
+ return Xt;
717
+ const { levels: e, predicate: r } = t;
718
+ return pe().subscribe((n) => {
719
+ if (e && !e.includes(n.level))
720
+ return;
721
+ const s = n.args.join(`
722
+ `);
723
+ r && !r({ text: s, message: n }) || alert(s);
724
+ });
725
+ }
726
+ var Rt = /* @__PURE__ */ ((t) => (t[t.none = 0] = "none", t[t.error = 1] = "error", t[t.warn = 2] = "warn", t[t.debug = 3] = "debug", t))(Rt || {});
727
+ function de() {
728
+ let t = new Error().stack;
729
+ if (t != null) {
730
+ const e = t.indexOf(`
731
+ `);
732
+ e != null && e >= 0 && (t = t.substring(e + 1));
733
+ }
734
+ return t ?? "";
735
+ }
736
+ function _r(t) {
737
+ return function(...e) {
738
+ const r = de();
739
+ try {
740
+ return t.apply(this, e);
741
+ } catch (n) {
742
+ throw n instanceof Error || (n = new Error(String(n))), n.stack = n.stack ? n.stack + `
743
+ ` + r : r, n;
744
+ }
745
+ };
746
+ }
747
+ function ye(t) {
748
+ if (!t || t.timeout == null)
749
+ return null;
750
+ const e = new Et(), r = t.timeController ?? At;
751
+ if (t.timeout) {
752
+ const n = r.setTimeout(() => {
753
+ e.abort(
754
+ new Jt(
755
+ `[timeoutAbortController] Timeout error: ${t.timeout}ms`
756
+ )
757
+ );
758
+ }, t.timeout);
759
+ e.signal.subscribe(() => {
760
+ clearTimeout(n);
761
+ });
762
+ }
763
+ return t.abortSignal?.subscribe((n) => {
764
+ e.abort(n);
765
+ }), e;
766
+ }
767
+ async function br(t, e) {
768
+ const r = ye(e);
769
+ try {
770
+ return await t(r?.signal ?? e?.abortSignal ?? null);
771
+ } finally {
772
+ r?.abort();
773
+ }
774
+ }
775
+ class xr {
776
+ _options;
777
+ _hasValue = !1;
778
+ _promiseOrValue = null;
779
+ constructor(e) {
780
+ this._options = e;
781
+ }
782
+ run() {
783
+ if (!this._hasValue) {
784
+ let e = this._options.func();
785
+ const r = (s) => (this._options.persist ? this._promiseOrValue = s : (this._promiseOrValue = null, this._hasValue = !1), s), n = (s) => {
786
+ throw this._options.persist || (this._promiseOrValue = null, this._hasValue = !1), s;
787
+ };
788
+ if (et(e))
789
+ e = e.then(r, n);
790
+ else if (!this._options.persist)
791
+ return e;
792
+ this._promiseOrValue = e, this._hasValue = !0;
793
+ }
794
+ return this._promiseOrValue;
795
+ }
796
+ set(e) {
797
+ if (!this._options.persist)
798
+ throw new Error("[Lazy][set] Cannot set value when persist is false");
799
+ this._hasValue = !0, this._promiseOrValue = e;
800
+ }
801
+ }
802
+ class $r {
803
+ _options;
804
+ _promiseOrValues = /* @__PURE__ */ new Map();
805
+ constructor(e) {
806
+ this._options = e;
807
+ }
808
+ run(e) {
809
+ if (this._promiseOrValues.has(e))
810
+ return this._promiseOrValues.get(e);
811
+ let r = this._options.func(e);
812
+ const n = (i) => (this._options.persist ? this._promiseOrValues.set(e, i) : this._promiseOrValues.delete(e), i), s = (i) => {
813
+ throw this._options.persist || this._promiseOrValues.delete(e), i;
814
+ };
815
+ if (et(r))
816
+ r = r.then(n, s);
817
+ else if (!this._options.persist)
818
+ return r;
819
+ return this._promiseOrValues.set(e, r), r;
820
+ }
821
+ set(e, r) {
822
+ if (!this._options.persist)
823
+ throw new Error(
824
+ "[LazyWithId][set] Cannot set value when persist is false"
825
+ );
826
+ this._promiseOrValues.set(e, r);
827
+ }
828
+ }
829
+ async function Or(t) {
830
+ const e = t.abortSignal ?? null, r = t.timeController ?? At;
831
+ let n = 0;
832
+ for (; ; )
833
+ try {
834
+ return await t.func({ abortSignal: e });
835
+ } catch (s) {
836
+ if ((t.logLevel == null || t.logLevel >= Rt.error) && console.error("[withRetry] error", s), e?.aborted)
837
+ throw s;
838
+ const i = t.delay({
839
+ error: s,
840
+ retryCount: n++,
841
+ abortSignal: e
842
+ });
843
+ if (i == null || (typeof i == "number" ? await Yt(i, e ?? void 0, r) : await i(), e?.aborted))
844
+ throw s;
845
+ }
846
+ }
847
+ function Sr({
848
+ maxRetries: t,
849
+ delays: e,
850
+ isRetriableError: r
851
+ }) {
852
+ return function({ retryCount: s, error: i }) {
853
+ if (s == null || t != null && s >= t)
854
+ return null;
855
+ if (r == null || r(i)) {
856
+ if (Array.isArray(e))
857
+ return e[Math.min(s, e.length - 1)];
858
+ {
859
+ const o = e.mult ?? 2;
860
+ return Math.min(e.min * o ** s, e.max);
861
+ }
862
+ }
863
+ return null;
864
+ };
865
+ }
866
+ function Er(t) {
867
+ return t != null && typeof t == "object" && typeof t.subscribe == "function";
868
+ }
869
+ class Ar {
870
+ _subjects = /* @__PURE__ */ new Map();
871
+ _getLastEvent;
872
+ constructor({
873
+ getLastEvent: e
874
+ } = {}) {
875
+ this._getLastEvent = e;
876
+ }
877
+ subscribe(e, r) {
878
+ let n = this._subjects.get(e);
879
+ n || (n = new Ut(), this._subjects.set(e, n));
880
+ const s = n.subscribe(r);
881
+ if (this._getLastEvent) {
882
+ const i = this._getLastEvent(e);
883
+ r(i);
884
+ }
885
+ return () => {
886
+ s(), n?.hasListeners || this._subjects.delete(e);
887
+ };
888
+ }
889
+ emit(e, r) {
890
+ const n = this._subjects.get(e);
891
+ if (n)
892
+ return n.emit(r);
893
+ }
894
+ forEach(e) {
895
+ this._subjects.forEach(e);
896
+ }
897
+ observable(e) {
898
+ return {
899
+ subscribe: (r) => this.subscribe(e, r)
900
+ };
901
+ }
902
+ emitter(e) {
903
+ return {
904
+ emit: (r) => this.emit(e, r)
905
+ };
906
+ }
907
+ subject(e) {
908
+ return {
909
+ subscribe: (r) => this.subscribe(e, r),
910
+ emit: (r) => this.emit(e, r)
911
+ };
912
+ }
913
+ }
914
+ function Mr(t, e, r) {
915
+ return new Promise((n) => {
916
+ let s = !1, i;
917
+ function o(f) {
918
+ a?.(), i?.(), s = !0, n(f);
919
+ }
920
+ function u(f) {
921
+ a?.(), i?.(), s = !0, n(Promise.reject(f));
922
+ }
923
+ const a = r?.subscribe(u);
924
+ let l = !0;
925
+ i = t.subscribe((f) => {
926
+ (!e || e(f, l)) && o(f), l = !1;
927
+ }), s && i?.();
928
+ });
929
+ }
930
+ class k extends Error {
931
+ constructor(e) {
932
+ super(e);
933
+ }
934
+ }
935
+ class p {
936
+ _args;
937
+ constructor(e) {
938
+ this._args = e && { ...e };
939
+ }
940
+ set(e) {
941
+ return this._args = {
942
+ ...this._args ?? {},
943
+ ...e
944
+ }, this;
945
+ }
946
+ name(e) {
947
+ return this.set({ name: e });
948
+ }
949
+ toString(e) {
950
+ const r = this._args?.name;
951
+ return r ? typeof r == "string" ? r : r(e) : this.nameDefault(e);
952
+ }
953
+ }
954
+ function jt(t, e) {
955
+ return U(t, {
956
+ maxDepth: 1,
957
+ maxItems: 5,
958
+ ...e
959
+ });
960
+ }
961
+ function R(t) {
962
+ return t instanceof p;
963
+ }
964
+ function rt(t) {
965
+ return jt(t);
966
+ }
967
+ function yt(t, ...e) {
968
+ if (t == null)
969
+ return "";
970
+ const r = jt(t, {
971
+ filter: (n, s) => {
972
+ if (n.length === 0)
973
+ return !0;
974
+ if (n.length !== 1)
975
+ return !1;
976
+ const i = n[0];
977
+ return !(i === "name" || i === "expected" || s == null || s === !1 || e.includes(i));
978
+ }
979
+ });
980
+ return /^(#\d+\s*)\{}$/.test(r) ? "" : `(${r})`;
981
+ }
982
+ function Z(t) {
983
+ const { result: e, cause: r, nested: n, error: s } = t;
984
+ if (s) {
985
+ if (!(s instanceof Error))
986
+ throw new k(
987
+ `[test][validateMatchResult] error must be an instance of Error, but it is: ${s}`
988
+ );
989
+ if (e != null)
990
+ throw new k(
991
+ `[test][validateMatchResult] result must be null if error is set, but it is: ${e}`
992
+ );
993
+ if (r != null)
994
+ throw new k(
995
+ `[test][validateMatchResult] cause must be null if error is set, but it is: ${r}`
996
+ );
997
+ if (n != null)
998
+ throw new k(
999
+ `[test][validateMatchResult] nested must be null if error is set, but it is: ${n}`
1000
+ );
1001
+ return t;
1002
+ }
1003
+ if (typeof e != "boolean")
1004
+ throw new k(
1005
+ `[test][validateMatchResult] result must be a boolean, but it is: ${e}`
1006
+ );
1007
+ if (typeof r != "string" && r != null)
1008
+ throw new k(
1009
+ `[test][validateMatchResult] cause must be a string or null, but it is: ${r}`
1010
+ );
1011
+ if (n != null && !(n instanceof Array))
1012
+ throw new k(
1013
+ `[test][validateMatchResult] nested must be an array or null, but it is: ${n}`
1014
+ );
1015
+ return t;
1016
+ }
1017
+ function ge(t, e, r) {
1018
+ return Z({
1019
+ actual: t,
1020
+ expected: e,
1021
+ result: null,
1022
+ cause: null,
1023
+ nested: null,
1024
+ error: r
1025
+ });
1026
+ }
1027
+ function Kt(t, e, r) {
1028
+ return Z({
1029
+ actual: t,
1030
+ expected: e,
1031
+ result: r,
1032
+ cause: null,
1033
+ nested: null,
1034
+ error: null
1035
+ });
1036
+ }
1037
+ function Pt(t, e, r) {
1038
+ return typeof r == "boolean" ? Kt(t, e, r) : Z(typeof r == "string" ? {
1039
+ actual: t,
1040
+ expected: e,
1041
+ result: !1,
1042
+ cause: r,
1043
+ nested: null,
1044
+ error: null
1045
+ } : {
1046
+ actual: t,
1047
+ expected: e,
1048
+ result: r.result,
1049
+ cause: r.cause ?? null,
1050
+ nested: r.nested ?? null,
1051
+ error: null
1052
+ });
1053
+ }
1054
+ function M(t, e) {
1055
+ try {
1056
+ if (R(e)) {
1057
+ const r = e.match(t);
1058
+ return Pt(t, e, r);
1059
+ }
1060
+ return Kt(t, e, t === e);
1061
+ } catch (r) {
1062
+ return ge(t, e, r);
1063
+ }
1064
+ }
1065
+ const nt = 10;
1066
+ class Lt extends p {
1067
+ match(e) {
1068
+ if (e == null)
1069
+ return `Expected array, got "${e}"`;
1070
+ if (typeof e != "object")
1071
+ return `Expected array, got "${typeof e}"`;
1072
+ if (!(e instanceof Array))
1073
+ return "Expected array";
1074
+ const r = this._args?.expected;
1075
+ if (r == null)
1076
+ return !0;
1077
+ const n = this._args?.maxReportItems ?? nt, s = this._args?.matchType || "equals";
1078
+ if (s === "equals") {
1079
+ if (e.length !== r.length)
1080
+ return `Expected array length to be ${r.length}, got ${e.length}`;
1081
+ let i = !0, o = 0, u = 0;
1082
+ const a = [];
1083
+ for (let l = 0; l < r.length; l++) {
1084
+ const f = e[l], w = r[l], y = M(f, w);
1085
+ if (y.result ? (o < n && a.push({
1086
+ actualKey: l,
1087
+ expectedKey: l,
1088
+ result: y
1089
+ }), o++) : (u < n && a.push({
1090
+ actualKey: l,
1091
+ expectedKey: l,
1092
+ result: y
1093
+ }), u++, i = !1), !i && o >= n && u >= n)
1094
+ break;
1095
+ }
1096
+ return {
1097
+ result: i,
1098
+ nested: a
1099
+ };
1100
+ }
1101
+ if (s === "includes") {
1102
+ let i = !0;
1103
+ const o = [];
1104
+ let u = 0, a = 0;
1105
+ for (let l = 0; l < r.length; l++) {
1106
+ const f = r[l];
1107
+ let w = !1;
1108
+ for (let y = 0; y < e.length; y++) {
1109
+ const h = e[y], c = M(h, f);
1110
+ if (c.result) {
1111
+ w = !0, u < n && o.push({
1112
+ actualKey: y,
1113
+ expectedKey: l,
1114
+ result: c
1115
+ }), u++;
1116
+ break;
1117
+ }
1118
+ }
1119
+ if (w || (i = !1, a < n && o.push({
1120
+ expectedKey: l,
1121
+ result: {
1122
+ result: !1,
1123
+ actual: void 0,
1124
+ expected: f
1125
+ }
1126
+ }), a++), !i && u >= n && a >= n)
1127
+ break;
1128
+ }
1129
+ return {
1130
+ result: i,
1131
+ nested: o
1132
+ };
1133
+ }
1134
+ return `Unknown matchType "${s}"`;
1135
+ }
1136
+ nameDefault() {
1137
+ return `array ${this._args?.matchType || "equals"} ${rt(this._args?.expected)}`;
1138
+ }
1139
+ }
1140
+ class we extends p {
1141
+ match() {
1142
+ return !0;
1143
+ }
1144
+ nameDefault() {
1145
+ return "any";
1146
+ }
1147
+ }
1148
+ class _e extends p {
1149
+ match(e) {
1150
+ if (typeof e != "object")
1151
+ return `Expected array, got "${typeof e}"`;
1152
+ if (!(e instanceof Array))
1153
+ return "Expected array";
1154
+ const r = this._args.expected;
1155
+ let n = !0;
1156
+ const s = [], i = this._args?.maxReportItems ?? nt;
1157
+ let o = 0, u = 0;
1158
+ for (let a = 0; a < e.length; a++) {
1159
+ const l = e[a], f = M(l, r);
1160
+ if (f.result ? (o < i && s.push({
1161
+ actualKey: a,
1162
+ expectedKey: a,
1163
+ result: f
1164
+ }), o++) : (u < i && s.push({
1165
+ actualKey: a,
1166
+ expectedKey: a,
1167
+ result: f
1168
+ }), u++, n = !1), !n && o >= i && u >= i)
1169
+ break;
1170
+ }
1171
+ return {
1172
+ result: n,
1173
+ nested: s
1174
+ };
1175
+ }
1176
+ nameDefault() {
1177
+ return "array item";
1178
+ }
1179
+ }
1180
+ class be extends p {
1181
+ match(e) {
1182
+ const { expected: r, convert: n } = this._args, s = M(n(e), r), i = [
1183
+ {
1184
+ result: s
1185
+ }
1186
+ ];
1187
+ return {
1188
+ result: s.result,
1189
+ nested: i
1190
+ };
1191
+ }
1192
+ nameDefault() {
1193
+ return "convert";
1194
+ }
1195
+ }
1196
+ class Vt extends p {
1197
+ match(e) {
1198
+ const { expected: r, nonStrict: n } = this._args;
1199
+ return n ? e == r : e === r;
1200
+ }
1201
+ nameDefault() {
1202
+ return `is(${rt(this._args.expected)})`;
1203
+ }
1204
+ }
1205
+ class xe extends p {
1206
+ match(e) {
1207
+ if (e == null)
1208
+ return `Expected number, got "${e}"`;
1209
+ if (typeof e != "number")
1210
+ return `Expected number, got "${typeof e}"`;
1211
+ if (this._args == null)
1212
+ return Number.isFinite(e) ? !0 : "Expected finite number";
1213
+ if (!this._args.allowNaN && Number.isNaN(e))
1214
+ return "Expected not NaN";
1215
+ if (!this._args.allowInfinity && !Number.isFinite(e))
1216
+ return "Expected not Infinity";
1217
+ const { min: r, max: n, float: s } = this._args;
1218
+ return !s && !Number.isInteger(e) ? `Expected integer, got "${e}"` : r != null && e < r ? `Expected number to be >= ${r}, got ${e}` : n != null && e > n ? `Expected number to be <= ${n}, got ${e}` : !0;
1219
+ }
1220
+ nameDefault() {
1221
+ return `number(${yt(this._args)})`;
1222
+ }
1223
+ }
1224
+ class $e extends p {
1225
+ match(e) {
1226
+ if (e == null)
1227
+ return `Expected object, got "${e}"`;
1228
+ if (Array.isArray(e))
1229
+ return "Expected object, got array";
1230
+ if (typeof e != "object")
1231
+ return `Expected object, got "${typeof e}"`;
1232
+ const r = this._args?.expected;
1233
+ if (r == null)
1234
+ return !0;
1235
+ let n = !0;
1236
+ const s = [], i = this._args?.maxReportItems ?? nt;
1237
+ let o = 0, u = 0;
1238
+ for (const a in r) {
1239
+ if (!Object.prototype.hasOwnProperty.call(r, a))
1240
+ continue;
1241
+ const l = e[a], f = r[a], w = M(l, f);
1242
+ if (w.result ? (o < i && s.push({
1243
+ actualKey: a,
1244
+ expectedKey: a,
1245
+ result: w
1246
+ }), o++) : (u < i && s.push({
1247
+ actualKey: a,
1248
+ expectedKey: a,
1249
+ result: w
1250
+ }), u++, n = !1), !n && o >= i && u >= i)
1251
+ break;
1252
+ }
1253
+ if (!this._args?.ignoreExtraKeys)
1254
+ for (const a in e) {
1255
+ if (!Object.prototype.hasOwnProperty.call(e, a) || Object.prototype.hasOwnProperty.call(r, a))
1256
+ continue;
1257
+ const l = e[a];
1258
+ if (u < i && s.push({
1259
+ actualKey: a,
1260
+ expectedKey: a,
1261
+ result: Pt(l, void 0, "Unexpected key")
1262
+ }), u++, n = !1, u >= i)
1263
+ break;
1264
+ }
1265
+ return {
1266
+ result: n,
1267
+ nested: s
1268
+ };
1269
+ }
1270
+ nameDefault() {
1271
+ return "object" + yt(this._args);
1272
+ }
1273
+ }
1274
+ class Oe extends p {
1275
+ match(e) {
1276
+ if (e == null)
1277
+ return `Expected string, got ${e}`;
1278
+ if (typeof e != "string")
1279
+ return `Expected string, got "${typeof e}"`;
1280
+ if (this._args == null)
1281
+ return !0;
1282
+ const { pattern: r } = this._args;
1283
+ if (r != null) {
1284
+ if (typeof r == "function")
1285
+ return r(e);
1286
+ if (!r.test(e))
1287
+ return !1;
1288
+ }
1289
+ return !0;
1290
+ }
1291
+ nameDefault() {
1292
+ return this._args?.pattern ? `string(${this._args.pattern})` : "string";
1293
+ }
1294
+ }
1295
+ class Se extends p {
1296
+ match(e) {
1297
+ const r = this._args.expected;
1298
+ return e instanceof r ? !0 : `Expected instance of "${r}", got "${e}"`;
1299
+ }
1300
+ nameDefault() {
1301
+ return `instanceOf(${this._args.expected.name})`;
1302
+ }
1303
+ }
1304
+ class Ee extends p {
1305
+ constructor(e) {
1306
+ super({
1307
+ ...e,
1308
+ expected: e.expected instanceof Set ? e.expected : new Set(e.expected)
1309
+ });
1310
+ }
1311
+ match(e) {
1312
+ return !!this._args.expected.has(e);
1313
+ }
1314
+ nameDefault() {
1315
+ return `in(${rt(this._args.expected)})`;
1316
+ }
1317
+ }
1318
+ class st extends p {
1319
+ match(e) {
1320
+ const { type: r, expecteds: n, pipe: s } = this._args;
1321
+ let i = r === "and";
1322
+ const o = [];
1323
+ for (let u = 0; u < n.length; u++) {
1324
+ const a = n[u], l = M(e, a);
1325
+ if (o.push({
1326
+ actualKey: `<${r} ${u}>`,
1327
+ expectedKey: `<${r} ${u}>`,
1328
+ result: l
1329
+ }), r === "or") {
1330
+ if (l.result && (i = !0, s))
1331
+ break;
1332
+ } else if (r === "and") {
1333
+ if (!l.result && (i = !1, s))
1334
+ break;
1335
+ } else
1336
+ throw new Error(`[test][MatcherFew] Unknown type "${r}"`);
1337
+ }
1338
+ return {
1339
+ result: n.length === 0 || i,
1340
+ nested: o
1341
+ };
1342
+ }
1343
+ nameDefault() {
1344
+ return this._args.type;
1345
+ }
1346
+ }
1347
+ class Ae extends p {
1348
+ match(e) {
1349
+ const r = this._args.matcher;
1350
+ return R(r) ? r.match(e) : r(e);
1351
+ }
1352
+ nameDefault(e) {
1353
+ const r = this._args.name;
1354
+ return typeof r == "string" ? r : r ? r(e) : "custom";
1355
+ }
1356
+ }
1357
+ class Ft extends p {
1358
+ match(e) {
1359
+ const r = this._args.expected, n = M(e, r);
1360
+ return {
1361
+ result: !n.result,
1362
+ nested: [
1363
+ {
1364
+ actualKey: null,
1365
+ result: n
1366
+ }
1367
+ ]
1368
+ };
1369
+ }
1370
+ nameDefault() {
1371
+ return "not";
1372
+ }
1373
+ }
1374
+ class Me extends p {
1375
+ match() {
1376
+ return !1;
1377
+ }
1378
+ nameDefault() {
1379
+ return "never";
1380
+ }
1381
+ }
1382
+ class Te extends p {
1383
+ match(e) {
1384
+ if (e == null)
1385
+ return `Expected object, got "${e}"`;
1386
+ if (Array.isArray(e))
1387
+ return "Expected object, got array";
1388
+ if (typeof e != "object")
1389
+ return `Expected object, got "${typeof e}"`;
1390
+ const r = this._args?.expected;
1391
+ if (r == null)
1392
+ return !0;
1393
+ let n = !0;
1394
+ const s = [], i = this._args?.maxReportItems ?? nt;
1395
+ let o = 0, u = 0;
1396
+ for (const a in e) {
1397
+ if (!Object.prototype.hasOwnProperty.call(e, a))
1398
+ continue;
1399
+ const l = [a, e[a]], f = M(l, r);
1400
+ if (f.result ? (o < i && s.push({
1401
+ actualKey: a,
1402
+ expectedKey: a,
1403
+ result: f
1404
+ }), o++) : (u < i && s.push({
1405
+ actualKey: a,
1406
+ expectedKey: a,
1407
+ result: f
1408
+ }), u++, n = !1), !n && o >= i && u >= i)
1409
+ break;
1410
+ }
1411
+ return {
1412
+ result: n,
1413
+ nested: s
1414
+ };
1415
+ }
1416
+ nameDefault() {
1417
+ return "object entries" + yt(this._args);
1418
+ }
1419
+ }
1420
+ class Ce extends p {
1421
+ _hasExpected = !1;
1422
+ _expected = void 0;
1423
+ get expected() {
1424
+ return this._expected;
1425
+ }
1426
+ set expected(e) {
1427
+ this._expected = e, this._hasExpected = !0;
1428
+ }
1429
+ match(e) {
1430
+ const r = M(e, this._expected), n = [
1431
+ {
1432
+ result: r
1433
+ }
1434
+ ];
1435
+ return {
1436
+ result: r.result,
1437
+ nested: n
1438
+ };
1439
+ }
1440
+ nameDefault() {
1441
+ return "ref";
1442
+ }
1443
+ }
1444
+ function j(t) {
1445
+ return new Lt({ expected: t });
1446
+ }
1447
+ function Tr(t) {
1448
+ return new Lt({ expected: t, matchType: "includes" });
1449
+ }
1450
+ function z() {
1451
+ return new we();
1452
+ }
1453
+ function Cr() {
1454
+ return new Ce();
1455
+ }
1456
+ function Ir(t) {
1457
+ return new Me({ name: t });
1458
+ }
1459
+ function Nr(t, e) {
1460
+ const r = new _e({ expected: e });
1461
+ return t == null ? r : T(
1462
+ Ue(
1463
+ R(t) || typeof t == "number" ? t : it(t)
1464
+ ),
1465
+ r
1466
+ ).name("array item");
1467
+ }
1468
+ function I(t, e, r) {
1469
+ return new be({ name: t, convert: e, expected: r });
1470
+ }
1471
+ function Ie(t) {
1472
+ return new Vt({ expected: t, nonStrict: !0 });
1473
+ }
1474
+ function Ne(t) {
1475
+ return new Vt({ expected: t, nonStrict: !1 });
1476
+ }
1477
+ function vt(t) {
1478
+ return new xe(t);
1479
+ }
1480
+ function it(t) {
1481
+ return vt({
1482
+ ...t,
1483
+ float: !1
1484
+ });
1485
+ }
1486
+ function Dr(t) {
1487
+ return vt({
1488
+ ...t,
1489
+ float: !0
1490
+ });
1491
+ }
1492
+ function N(t) {
1493
+ return new $e({ expected: t });
1494
+ }
1495
+ function ht(t, e, r = null) {
1496
+ if (t instanceof p || e && (t = e(t, r), t instanceof p))
1497
+ return t;
1498
+ if (t == null)
1499
+ return tt();
1500
+ if (Array.isArray(t)) {
1501
+ const n = t.map((s, i) => ht(s, e, i));
1502
+ return j(n);
1503
+ }
1504
+ if (t.constructor === Object) {
1505
+ const n = {};
1506
+ for (const s in t)
1507
+ Object.prototype.hasOwnProperty.call(t, s) && (n[s] = ht(t[s], e, s));
1508
+ return N(n);
1509
+ }
1510
+ return t instanceof Qt ? Ve({
1511
+ ...t,
1512
+ value: ht(t.value, e, "value")
1513
+ }) : Ne(t);
1514
+ }
1515
+ function kr(t) {
1516
+ return N(t).set({
1517
+ ignoreExtraKeys: !0
1518
+ });
1519
+ }
1520
+ function zt(t) {
1521
+ return new Oe({
1522
+ pattern: t
1523
+ });
1524
+ }
1525
+ function Ur(t) {
1526
+ return new Se({ expected: t });
1527
+ }
1528
+ function De(t) {
1529
+ return I(
1530
+ "typeof",
1531
+ (e) => e === null ? "null" : typeof e,
1532
+ t
1533
+ );
1534
+ }
1535
+ function Rr(t) {
1536
+ return I(
1537
+ "constructor",
1538
+ (e) => e.constructor,
1539
+ t
1540
+ );
1541
+ }
1542
+ function mt() {
1543
+ return De("boolean");
1544
+ }
1545
+ function tt() {
1546
+ return Ie(null);
1547
+ }
1548
+ function jr() {
1549
+ return Le(tt());
1550
+ }
1551
+ function Kr(...t) {
1552
+ return new st({
1553
+ expecteds: t,
1554
+ type: "or",
1555
+ pipe: !1
1556
+ });
1557
+ }
1558
+ function Pr(...t) {
1559
+ return new st({
1560
+ expecteds: t,
1561
+ type: "and",
1562
+ pipe: !1
1563
+ });
1564
+ }
1565
+ function ke(...t) {
1566
+ return new st({
1567
+ expecteds: t,
1568
+ type: "or",
1569
+ pipe: !0
1570
+ });
1571
+ }
1572
+ function T(...t) {
1573
+ return new st({
1574
+ expecteds: t,
1575
+ type: "and",
1576
+ pipe: !0
1577
+ });
1578
+ }
1579
+ function L(t, e) {
1580
+ return e == null ? ke(tt(), t) : e ? t : tt();
1581
+ }
1582
+ function Ue(t) {
1583
+ const e = typeof t == "number" || R(t) ? t : it(t ?? { min: 1 });
1584
+ return T(
1585
+ j(),
1586
+ I("length", (r) => r.length, e)
1587
+ ).name("array length");
1588
+ }
1589
+ function Lr(t) {
1590
+ const e = typeof t == "number" || R(t) ? t : it(t ?? { min: 1 });
1591
+ return T(
1592
+ zt(),
1593
+ I("length", (r) => r.length, e)
1594
+ ).name("string length");
1595
+ }
1596
+ function Vr(t) {
1597
+ return T(N(), t);
1598
+ }
1599
+ function Fr(t) {
1600
+ return T(j(), t);
1601
+ }
1602
+ function vr(t) {
1603
+ return T(
1604
+ N(),
1605
+ I(
1606
+ "keys",
1607
+ (e) => Object.keys(e),
1608
+ t
1609
+ )
1610
+ );
1611
+ }
1612
+ function zr(t) {
1613
+ return T(
1614
+ N(),
1615
+ I(
1616
+ "values",
1617
+ (e) => Object.values(e),
1618
+ t
1619
+ )
1620
+ );
1621
+ }
1622
+ function Br(t) {
1623
+ return T(
1624
+ N(),
1625
+ I(
1626
+ "entries",
1627
+ (e) => Object.entries(e),
1628
+ t
1629
+ )
1630
+ );
1631
+ }
1632
+ function gt(t) {
1633
+ return new Te({ expected: t });
1634
+ }
1635
+ function qr(t) {
1636
+ return gt(j([t, z()]));
1637
+ }
1638
+ function Wr(t) {
1639
+ return gt(j([z(), t]));
1640
+ }
1641
+ function Hr(t, e) {
1642
+ return gt(j([t, e]));
1643
+ }
1644
+ function Gr(t) {
1645
+ return T(
1646
+ N(),
1647
+ I(
1648
+ "keys not null",
1649
+ (e) => Object.keys(e).filter((r) => e[r] != null),
1650
+ t
1651
+ )
1652
+ );
1653
+ }
1654
+ function Re(t) {
1655
+ return new Ee({ expected: t });
1656
+ }
1657
+ function Jr(t) {
1658
+ return Re(Object.values(t));
1659
+ }
1660
+ function Bt(t, e) {
1661
+ return new Ae({ matcher: e, name: t });
1662
+ }
1663
+ const je = Math.ceil(Date.now() - 10 * 365.25 * 24 * 60 * 60 * 1e3), Ke = Math.ceil(Date.now() + 10 * 365.25 * 24 * 60 * 60 * 1e3);
1664
+ function J(t) {
1665
+ return it({
1666
+ ...t,
1667
+ min: t?.min ?? je,
1668
+ max: t?.max ?? Ke
1669
+ }).name("int date");
1670
+ }
1671
+ function Pe(t) {
1672
+ const e = {
1673
+ min: t?.from?.min ?? t?.common?.min,
1674
+ max: t?.from?.max ?? t?.common?.max,
1675
+ float: t?.from?.float ?? t?.common?.float,
1676
+ optional: t?.from?.optional ?? t?.common?.optional
1677
+ }, r = {
1678
+ min: t?.to?.min ?? t?.common?.min,
1679
+ max: t?.to?.max ?? t?.common?.max,
1680
+ float: t?.to?.float ?? t?.common?.float,
1681
+ optional: t?.to?.optional ?? t?.common?.optional
1682
+ };
1683
+ return T(
1684
+ j([
1685
+ e.optional ? L(J()) : J(),
1686
+ r.optional ? L(J()) : J()
1687
+ ]),
1688
+ Bt("min <= max", (n) => n[0] != null && n[1] != null && n[0] > n[1] ? `Expected range to be [min, max], got [${n.join(", ")}]` : !0)
1689
+ ).name("range");
1690
+ }
1691
+ function Xr(t) {
1692
+ return Pe({
1693
+ ...t,
1694
+ common: {
1695
+ min: new Date(2020, 0, 1).getTime(),
1696
+ max: Date.now() + 900 * 1e3,
1697
+ ...t?.common
1698
+ }
1699
+ }).name("range date");
1700
+ }
1701
+ function Le(t) {
1702
+ return new Ft({ expected: t });
1703
+ }
1704
+ function Yr() {
1705
+ return zt(/^[\da-f-]{36}|[\da-f]{32}$/i).name("uuid");
1706
+ }
1707
+ function Ve(t) {
1708
+ return N({
1709
+ [Symbol.toStringTag]: L(z()),
1710
+ loading: L(mt()),
1711
+ hasValue: L(mt()),
1712
+ value: z(),
1713
+ hasError: L(mt()),
1714
+ error: z(),
1715
+ ...t
1716
+ });
1717
+ }
1718
+ function Qr(t) {
1719
+ return t != null && typeof t == "string" && (t = new TextEncoder().encode(t).buffer), Bt("array buffer", (e) => {
1720
+ if (e == null || typeof e != "object" || typeof e.byteLength != "number")
1721
+ return `Expected array buffer, got "${e}"`;
1722
+ if (t == null)
1723
+ return !0;
1724
+ if (e.byteLength !== t.byteLength)
1725
+ return `Expected array buffer length to be ${t.byteLength}, got ${e.byteLength}`;
1726
+ for (let r = 0, n = t.byteLength; r < n; r++)
1727
+ if (e[r] !== t[r])
1728
+ return `Expected array buffer[${r}] to be ${t[r]}, got ${e[r]}`;
1729
+ return !0;
1730
+ });
1731
+ }
1732
+ function Fe(t, e) {
1733
+ const r = qt(t.result, e);
1734
+ return r ? {
1735
+ actualKey: t.actualKey,
1736
+ expectedKey: t.expectedKey,
1737
+ result: r
1738
+ } : null;
1739
+ }
1740
+ function qt(t, e) {
1741
+ if (e ? !t.result : t.result)
1742
+ return null;
1743
+ t.expected instanceof Ft && (e = !e);
1744
+ let r = null;
1745
+ return t.nested && t.nested.forEach((n) => {
1746
+ const s = Fe(n, e);
1747
+ s && (r || (r = []), r.push(s));
1748
+ }), {
1749
+ actual: t.actual,
1750
+ expected: t.expected,
1751
+ result: t.result,
1752
+ cause: t.cause,
1753
+ nested: r,
1754
+ error: t.error
1755
+ };
1756
+ }
1757
+ function ve(t, e) {
1758
+ const r = Wt(t.result, e + " ");
1759
+ return `${e}${t.actualKey == null ? "| " : t.actualKey + ": "}${r}`;
1760
+ }
1761
+ function Wt(t, e) {
1762
+ if (t.result)
1763
+ return t.expected.toString();
1764
+ let r = "";
1765
+ t.nested && (r = t.nested.map((s) => ve(s, e)).join(`
1766
+ `));
1767
+ let n = t.cause || "";
1768
+ return r ? (n || (n = R(t.expected) ? t.expected.toString(t.actual) : ""), `${n}
1769
+ ${r}`) : `${n}
1770
+ ${e}expected: ${R(t.expected) ? t.expected.toString(t.actual) : t.expected}
1771
+ ${e}actual: ${rt(t.actual)}`;
1772
+ }
1773
+ class ze extends Error {
1774
+ constructor(e) {
1775
+ super(e);
1776
+ }
1777
+ }
1778
+ function Zr(t) {
1779
+ return function(r, n) {
1780
+ const s = M(t, r);
1781
+ if (s.error)
1782
+ throw s.error;
1783
+ const i = qt(s, !1);
1784
+ if (!i)
1785
+ return;
1786
+ const o = Wt(i, "");
1787
+ console.log(`[test][check] CheckError:
1788
+ ` + o);
1789
+ const u = new ze(o);
1790
+ throw n?.(u), u;
1791
+ };
1792
+ }
1793
+ function St(t) {
1794
+ return t.replace(/\W/g, "").toLowerCase();
1795
+ }
1796
+ function Be(t) {
1797
+ return t instanceof URL ? t.searchParams : t instanceof URLSearchParams ? t : typeof t == "string" ? new URL(t).searchParams : typeof window < "u" ? new URL(window.location.href).searchParams : new URLSearchParams();
1798
+ }
1799
+ function qe(t) {
1800
+ return t == null ? null : (t = t.toLowerCase().trim(), t === "true" || t === "1" || t === "yes" ? !0 : t === "false" || t === "0" || t === "no" ? !1 : null);
1801
+ }
1802
+ function We(t) {
1803
+ if (t == null)
1804
+ return null;
1805
+ t = t.trim();
1806
+ const e = parseInt(t, 10);
1807
+ return isNaN(e) ? null : e;
1808
+ }
1809
+ function He(t) {
1810
+ if (t == null)
1811
+ return null;
1812
+ t = t.trim();
1813
+ const e = parseFloat(t);
1814
+ return isNaN(e) ? null : e;
1815
+ }
1816
+ function wt(t, e) {
1817
+ const r = Be(e), n = St(t);
1818
+ for (const [s, i] of r.entries())
1819
+ if (St(s) === n)
1820
+ return i;
1821
+ return null;
1822
+ }
1823
+ function tn(t, e) {
1824
+ return qe(wt(t, e));
1825
+ }
1826
+ function en(t, e) {
1827
+ return We(wt(t, e));
1828
+ }
1829
+ function rn(t, e) {
1830
+ return He(wt(t, e));
1831
+ }
1832
+ export {
1833
+ Ar as $,
1834
+ bt as A,
1835
+ Y as B,
1836
+ fr as C,
1837
+ hr as D,
1838
+ xt as E,
1839
+ mr as F,
1840
+ pr as G,
1841
+ yr as H,
1842
+ pe as I,
1843
+ gr as J,
1844
+ wr as K,
1845
+ v as L,
1846
+ kt as M,
1847
+ dr as N,
1848
+ Rt as O,
1849
+ _r as P,
1850
+ de as Q,
1851
+ dt as R,
1852
+ ye as S,
1853
+ br as T,
1854
+ lt as U,
1855
+ xr as V,
1856
+ $r as W,
1857
+ Or as X,
1858
+ Sr as Y,
1859
+ Er as Z,
1860
+ Ut as _,
1861
+ Qe as a,
1862
+ Mr as a0,
1863
+ M as a1,
1864
+ Zr as a2,
1865
+ j as a3,
1866
+ Tr as a4,
1867
+ z as a5,
1868
+ Cr as a6,
1869
+ Ir as a7,
1870
+ Nr as a8,
1871
+ I as a9,
1872
+ Br as aA,
1873
+ gt as aB,
1874
+ qr as aC,
1875
+ Wr as aD,
1876
+ Hr as aE,
1877
+ Gr as aF,
1878
+ Re as aG,
1879
+ Jr as aH,
1880
+ Bt as aI,
1881
+ J as aJ,
1882
+ Pe as aK,
1883
+ Xr as aL,
1884
+ Le as aM,
1885
+ Yr as aN,
1886
+ Ve as aO,
1887
+ Qr as aP,
1888
+ Be as aQ,
1889
+ qe as aR,
1890
+ We as aS,
1891
+ He as aT,
1892
+ wt as aU,
1893
+ tn as aV,
1894
+ en as aW,
1895
+ rn as aX,
1896
+ Ie as aa,
1897
+ Ne as ab,
1898
+ vt as ac,
1899
+ it as ad,
1900
+ Dr as ae,
1901
+ N as af,
1902
+ ht as ag,
1903
+ kr as ah,
1904
+ zt as ai,
1905
+ Ur as aj,
1906
+ De as ak,
1907
+ Rr as al,
1908
+ mt as am,
1909
+ tt as an,
1910
+ jr as ao,
1911
+ Kr as ap,
1912
+ Pr as aq,
1913
+ ke as ar,
1914
+ T as as,
1915
+ L as at,
1916
+ Ue as au,
1917
+ Lr as av,
1918
+ Vr as aw,
1919
+ Fr as ax,
1920
+ vr as ay,
1921
+ zr as az,
1922
+ se as b,
1923
+ Ze as c,
1924
+ oe as d,
1925
+ ae as e,
1926
+ rr as f,
1927
+ er as g,
1928
+ nr as h,
1929
+ It as i,
1930
+ sr as j,
1931
+ ir as k,
1932
+ ur as l,
1933
+ ne as m,
1934
+ tr as n,
1935
+ or as o,
1936
+ ar as p,
1937
+ Dt as q,
1938
+ Ct as r,
1939
+ re as s,
1940
+ te as t,
1941
+ U as u,
1942
+ le as v,
1943
+ fe as w,
1944
+ G as x,
1945
+ lr as y,
1946
+ cr as z
1947
+ };