@flemist/simple-utils 2.1.5 → 2.1.7

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.
Files changed (49) hide show
  1. package/build/browser/index.cjs +1 -1
  2. package/build/browser/index.mjs +178 -146
  3. package/build/common/async/Locker.d.ts +28 -0
  4. package/build/common/async/index.d.ts +2 -0
  5. package/build/common/async/promise.d.ts +7 -0
  6. package/build/common/cache/Cache.d.ts +46 -0
  7. package/build/common/cache/CacheStats.d.ts +20 -0
  8. package/build/common/cache/MemoryStorage.d.ts +11 -0
  9. package/build/common/cache/getHashKey.d.ts +1 -0
  10. package/build/common/cache/getJsonKey.d.ts +1 -0
  11. package/build/common/cache/index.d.ts +6 -0
  12. package/build/common/cache/types.d.ts +28 -0
  13. package/build/common/converter/converterBufferToGzip.d.ts +4 -0
  14. package/build/common/converter/converterErrorToBuffer.d.ts +2 -0
  15. package/build/common/converter/converterErrorToGzip.d.ts +4 -0
  16. package/build/common/converter/converterJson.d.ts +2 -0
  17. package/build/common/converter/converterJsonBuffer.d.ts +2 -0
  18. package/build/common/converter/converterJsonGzip.d.ts +4 -0
  19. package/build/common/converter/converterStringToBuffer.d.ts +2 -0
  20. package/build/common/converter/helpers.d.ts +13 -0
  21. package/build/common/converter/index.d.ts +11 -0
  22. package/build/common/converter/mapObjectConverter.d.ts +2 -0
  23. package/build/common/converter/setArrayConverter.d.ts +2 -0
  24. package/build/common/converter/types.d.ts +41 -0
  25. package/build/common/gzip/compressGzip.d.ts +35 -0
  26. package/build/common/gzip/decompressGzip.d.ts +2 -0
  27. package/build/common/gzip/index.d.ts +2 -0
  28. package/build/common/index.cjs +1 -1
  29. package/build/common/index.d.ts +3 -0
  30. package/build/common/index.mjs +178 -146
  31. package/build/common/string/index.d.ts +1 -1
  32. package/build/node/cache/FileStatStorage.d.ts +23 -0
  33. package/build/node/cache/FileStorage.d.ts +29 -0
  34. package/build/node/cache/createConverterSubPath.d.ts +12 -0
  35. package/build/node/cache/createFileCacheOptions.d.ts +17 -0
  36. package/build/node/cache/generateTempFileName.d.ts +1 -0
  37. package/build/node/cache/index.d.ts +6 -0
  38. package/build/node/cache/writeFileThroughTmp.d.ts +2 -0
  39. package/build/node/fs/index.d.ts +1 -0
  40. package/build/node/fs/readDirRecursive.d.ts +6 -0
  41. package/build/node/index.cjs +8 -8
  42. package/build/node/index.d.ts +1 -0
  43. package/build/node/index.mjs +1000 -701
  44. package/build/urlGet-BtyqjC2r.mjs +2452 -0
  45. package/build/urlGet-BukRa7Gq.js +17 -0
  46. package/package.json +37 -38
  47. package/build/common/time/dateToString.d.ts +0 -2
  48. package/build/urlGet-CerQ1cKh.js +0 -17
  49. package/build/urlGet-DZEwtNXt.mjs +0 -2000
@@ -1,2000 +0,0 @@
1
- import { AbortControllerFast as At, toAbortSignal as Xt, AbortError as Yt } from "@flemist/abort-controller-fast";
2
- import { isPromiseLike as B, EMPTY_FUNC as Qt, delay as Zt, ValueState as te } from "@flemist/async-utils";
3
- import { timeControllerDefault as Mt } from "@flemist/time-controller";
4
- let G = null;
5
- function ee() {
6
- if (!G) {
7
- G = new Array(256);
8
- for (let t = 0; t < 256; t++)
9
- G[t] = t.toString(16).padStart(2, "0");
10
- }
11
- return G;
12
- }
13
- function re(t) {
14
- const e = ee(), 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 dt = null, Tt = null, Q = null, Ct = null;
21
- function ne() {
22
- dt || (dt = 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
- ]), Tt = new Uint32Array(64), Ct = new TextEncoder(), Q = new Uint8Array(65536));
88
- }
89
- function se(t) {
90
- if (t == null)
91
- return null;
92
- ne();
93
- const e = dt, r = Tt, n = Ct;
94
- let s = Q, i;
95
- if (typeof t == "string") {
96
- const g = t.length * 3;
97
- s.length < g + 128 && (s = Q = 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 = Q = 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, c = a / 4294967296 | 0, f = a | 0;
117
- s[u - 8] = c >>> 24, s[u - 7] = c >>> 16, s[u - 6] = c >>> 8, s[u - 5] = c, s[u - 4] = f >>> 24, s[u - 3] = f >>> 16, s[u - 2] = f >>> 8, s[u - 1] = f;
118
- let b = 1779033703, y = -1150833019, h = 1013904242, l = -1521486534, m = 1359893119, $ = -1694144372, _ = 528734635, O = 1541459225;
119
- for (let g = 0; g < u; g += 64) {
120
- for (let w = 0; w < 16; w++) {
121
- const x = g + (w << 2);
122
- r[w] = s[x] << 24 | s[x + 1] << 16 | s[x + 2] << 8 | s[x + 3];
123
- }
124
- for (let w = 16; w < 64; w++) {
125
- const x = r[w - 15], C = r[w - 2], ct = (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3, H = (C >>> 17 | C << 15) ^ (C >>> 19 | C << 13) ^ C >>> 10;
126
- r[w] = r[w - 16] + ct + r[w - 7] + H | 0;
127
- }
128
- let d = b, E = y, q = h, ot = l, A = m, W = $, V = _, at = O;
129
- for (let w = 0; w < 64; w += 4)
130
- for (let x = 0; x < 4; x++) {
131
- const C = w + x, ct = (A >>> 6 | A << 26) ^ (A >>> 11 | A << 21) ^ (A >>> 25 | A << 7), H = at + ct + (V ^ A & (W ^ V)) + e[C] + r[C] | 0, Jt = ((d >>> 2 | d << 30) ^ (d >>> 13 | d << 19) ^ (d >>> 22 | d << 10)) + (d & E ^ q & (d ^ E)) | 0;
132
- at = V, V = W, W = A, A = ot + H | 0, ot = q, q = E, E = d, d = H + Jt | 0;
133
- }
134
- b = b + d | 0, y = y + E | 0, h = h + q | 0, l = l + ot | 0, m = m + A | 0, $ = $ + W | 0, _ = _ + V | 0, O = O + at | 0;
135
- }
136
- const S = new Uint8Array(32), K = [b, y, h, l, m, $, _, 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 Ze(t) {
144
- const e = se(t);
145
- return e ? re(e) : null;
146
- }
147
- function ie(t, e) {
148
- return t == null ? e : e == null ? t : Math.min(t, e);
149
- }
150
- function ue(t, e) {
151
- return t == null ? e : e == null ? t : Math.max(t, e);
152
- }
153
- function tr(t, e, r) {
154
- return ue(ie(t, e), r);
155
- }
156
- function er(t, e) {
157
- return (t % e + e) % e;
158
- }
159
- function oe(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 ae() {
166
- return Math.random();
167
- }
168
- function rr() {
169
- return Math.random() * 2 ** 32 >>> 0;
170
- }
171
- function ce(t) {
172
- return t != null ? oe(t) : ae;
173
- }
174
- class yt {
175
- _seed;
176
- _rnd;
177
- constructor(e) {
178
- this._seed = e, this._rnd = ce(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 yt(this.nextSeed());
188
- }
189
- next() {
190
- return this._rnd();
191
- }
192
- clone() {
193
- return new yt(this._seed);
194
- }
195
- }
196
- function It(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 le(t, e, r) {
204
- return Math.floor(It(t, e, r));
205
- }
206
- function nr(t, e) {
207
- return t.next() < (e ?? 0.5);
208
- }
209
- function sr(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 = It(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 kt(t, e) {
228
- if (e.length === 0)
229
- throw new Error("[random][randomItem] items is empty");
230
- const r = le(t, e.length);
231
- return e[r];
232
- }
233
- function ir(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(kt(t, e));
239
- return n;
240
- }
241
- function ur(t, e, r) {
242
- let n = Object.values(e);
243
- return r && (n = n.filter(r)), kt(t, n);
244
- }
245
- const Nt = 1073741789, lt = (Nt >> 2) - 1;
246
- function or(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 ar() {
264
- const t = Date.now();
265
- return F == null || t > F ? (F = t, t) : (F++, F);
266
- }
267
- async function cr({
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 At();
275
- r = e ? setTimeout(() => {
276
- n.abort();
277
- }, e) : null;
278
- const s = await fetch(t, {
279
- method: "HEAD",
280
- signal: Xt(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 fe(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 he = 0;
311
- const ft = /* @__PURE__ */ new WeakMap();
312
- function P(t) {
313
- if (ft.has(t))
314
- return ft.get(t);
315
- const e = he++;
316
- return ft.set(t, e), e;
317
- }
318
- function J(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: c,
341
- showArrayIndex: f,
342
- customToString: b
343
- } = e ?? {};
344
- if (r == null && (r = []), n == null && (n = /* @__PURE__ */ new Set()), b) {
345
- const h = b(
346
- t,
347
- r,
348
- (l) => U(l, e, r, n)
349
- );
350
- if (h != null)
351
- return J(h, a, e?.truncateOptions);
352
- }
353
- const y = r.length;
354
- if (typeof t == "string")
355
- return t = J(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 J(
362
- String(t),
363
- a,
364
- e?.truncateOptions
365
- );
366
- if (t instanceof Date)
367
- return fe(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 J(
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 l = "";
382
- c && (l += `#${P(t)} `), l += "[";
383
- let m = 0, $ = !1;
384
- for (let _ = 0; _ < t.length; _++) {
385
- if (u != null && m >= u) {
386
- $ = !0;
387
- break;
388
- }
389
- const O = [...r, String(_)], S = _t(t, _);
390
- if (i != null && !i(O, S))
391
- continue;
392
- const K = U(S, e, O, n);
393
- m > 0 && (l += ","), s && (l += `
394
- `), s && (l += `${h} `), f && (l += `${_}: `), l += `${K}`, m++;
395
- }
396
- return $ ? (m > 0 && (l += ","), s ? (l += `
397
- `, l += `${h} ...
398
- `) : l += "...", l += h, l += "]") : (m > 0 && s && (l += `
399
- ${h}`), l += "]"), l;
400
- }
401
- if (t instanceof Map) {
402
- let h = "";
403
- return c && (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 c && (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 ?? "", l = s ? " ".repeat(y) : "";
411
- let m = h ? `${h} ` : "";
412
- c && (m += `#${P(t)} `), m += "{";
413
- let $ = 0, _ = !1;
414
- for (const O in t) {
415
- if (u != null && $ >= u) {
416
- _ = !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 += `${l} `), m += `${O}: ${g}`, $++;
425
- }
426
- return _ && ($ > 0 && (m += ","), s ? (m += `
427
- `, m += `${l} ...
428
- `) : m += "...", m += l), $ > 0 && s && !_ && (m += `
429
- ${l}`), m += "}", m;
430
- }
431
- }
432
- function me(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 fr(t) {
454
- return t == null ? null : t?.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
455
- }
456
- function xt(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(xt(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] = xt(t[r]));
471
- return e;
472
- }
473
- return t;
474
- }
475
- function Z(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 (!Z(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) && !Z(
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) && !Z(e[r], null))
504
- return !1;
505
- return !0;
506
- }
507
- return !1;
508
- }
509
- function hr(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 (!Z(n, e.get(r)))
516
- return !1;
517
- return !0;
518
- }
519
- function mr(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 $t(t) {
529
- return !t || typeof t != "object" ? t : Array.isArray(t) ? t.map($t) : t && Object.keys(t).sort().reduce((e, r) => {
530
- const n = $t(t[r]);
531
- return n != null && (e[r] = n), e;
532
- }, {});
533
- }
534
- function pr(t, e) {
535
- return Object.defineProperty(t, "name", { value: e, configurable: !0 }), t;
536
- }
537
- function dr(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 Ot = Object.values(v);
545
- function N(t) {
546
- return function() {
547
- t.apply(console, arguments);
548
- };
549
- }
550
- const St = {
551
- log: N(console.log),
552
- warn: N(console.warn),
553
- error: N(console.error),
554
- info: N(console.info),
555
- debug: N(console.debug),
556
- trace: N(console.trace),
557
- assert: N(console.assert)
558
- };
559
- function Ut(t) {
560
- return Ot.forEach((e) => {
561
- console[e] = (...r) => {
562
- t(St, e, r);
563
- };
564
- }), () => {
565
- Ot.forEach((e) => {
566
- console[e] = St[e];
567
- });
568
- };
569
- }
570
- function yr(t) {
571
- return function(r) {
572
- let n = null;
573
- const i = Ut((u, a, c) => {
574
- try {
575
- t(u, a, c);
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 B(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 Rt {
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
- B(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 pe(t, e) {
681
- return U(t, {
682
- maxDepth: 5,
683
- maxItems: 10,
684
- ...e
685
- });
686
- }
687
- function de(t) {
688
- return t.map(
689
- (e) => e && typeof e == "object" ? pe(e) : e
690
- );
691
- }
692
- function gr(t) {
693
- return `${me(/* @__PURE__ */ new Date())} [${t.level.toUpperCase()}] ${de(
694
- t.args
695
- ).join(" ")}`;
696
- }
697
- let tt = null, ht = null;
698
- function ye() {
699
- return ht || (ht = new Rt({
700
- startStopNotifier: (t) => (tt = t, () => {
701
- tt = null;
702
- })
703
- })), ht;
704
- }
705
- function br() {
706
- return Ut((t, e, r) => {
707
- e === "assert" && r[0] === !0 || (e === v.error || e === v.warn || e === v.assert) && (tt && tt({
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 Qt;
717
- const { levels: e, predicate: r } = t;
718
- return ye().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 jt = /* @__PURE__ */ ((t) => (t[t.none = 0] = "none", t[t.error = 1] = "error", t[t.warn = 2] = "warn", t[t.debug = 3] = "debug", t))(jt || {});
727
- function ge() {
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 = ge();
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 be(t) {
748
- if (!t || t.timeout == null)
749
- return null;
750
- const e = new At(), r = t.timeController ?? Mt;
751
- if (t.timeout) {
752
- const n = r.setTimeout(() => {
753
- e.abort(
754
- new Yt(
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 xr(t, e) {
768
- const r = be(e);
769
- try {
770
- return await t(r?.signal ?? e?.abortSignal ?? null);
771
- } finally {
772
- r?.abort();
773
- }
774
- }
775
- class $r {
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 (B(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 Or {
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 (B(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 Sr(t) {
830
- const e = t.abortSignal ?? null, r = t.timeController ?? Mt;
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 >= jt.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 Zt(i, e ?? void 0, r) : await i(), e?.aborted))
844
- throw s;
845
- }
846
- }
847
- function Er({
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 Ar(t) {
867
- return t != null && typeof t == "object" && typeof t.subscribe == "function";
868
- }
869
- class Mr {
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 Rt(), 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 Tr(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 c = !0;
925
- i = t.subscribe((f) => {
926
- (!e || e(f, c)) && o(f), c = !1;
927
- }), s && i?.();
928
- });
929
- }
930
- class D 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 Kt(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 nt(t) {
965
- return Kt(t);
966
- }
967
- function gt(t, ...e) {
968
- if (t == null)
969
- return "";
970
- const r = Kt(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 et(t) {
983
- const { result: e, cause: r, nested: n, error: s } = t;
984
- if (s) {
985
- if (!(s instanceof Error))
986
- throw new D(
987
- `[test][validateMatchResult] error must be an instance of Error, but it is: ${s}`
988
- );
989
- if (e != null)
990
- throw new D(
991
- `[test][validateMatchResult] result must be null if error is set, but it is: ${e}`
992
- );
993
- if (r != null)
994
- throw new D(
995
- `[test][validateMatchResult] cause must be null if error is set, but it is: ${r}`
996
- );
997
- if (n != null)
998
- throw new D(
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 D(
1005
- `[test][validateMatchResult] result must be a boolean, but it is: ${e}`
1006
- );
1007
- if (typeof r != "string" && r != null)
1008
- throw new D(
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 D(
1013
- `[test][validateMatchResult] nested must be an array or null, but it is: ${n}`
1014
- );
1015
- return t;
1016
- }
1017
- function we(t, e, r) {
1018
- return et({
1019
- actual: t,
1020
- expected: e,
1021
- result: null,
1022
- cause: null,
1023
- nested: null,
1024
- error: r
1025
- });
1026
- }
1027
- function Pt(t, e, r) {
1028
- return et({
1029
- actual: t,
1030
- expected: e,
1031
- result: r,
1032
- cause: null,
1033
- nested: null,
1034
- error: null
1035
- });
1036
- }
1037
- function Lt(t, e, r) {
1038
- return typeof r == "boolean" ? Pt(t, e, r) : et(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 Lt(t, e, r);
1059
- }
1060
- return Pt(t, e, t === e);
1061
- } catch (r) {
1062
- return we(t, e, r);
1063
- }
1064
- }
1065
- class Vt extends p {
1066
- match(e) {
1067
- const r = this._args.expected, n = M(e, r);
1068
- return {
1069
- result: !n.result,
1070
- nested: [
1071
- {
1072
- actualKey: null,
1073
- result: n
1074
- }
1075
- ]
1076
- };
1077
- }
1078
- nameDefault() {
1079
- return "not";
1080
- }
1081
- }
1082
- function _e(t, e) {
1083
- const r = Ft(t.result, e);
1084
- return r ? {
1085
- actualKey: t.actualKey,
1086
- expectedKey: t.expectedKey,
1087
- result: r
1088
- } : null;
1089
- }
1090
- function Ft(t, e) {
1091
- if (e ? !t.result : t.result)
1092
- return null;
1093
- t.expected instanceof Vt && (e = !e);
1094
- let r = null;
1095
- return t.nested && t.nested.forEach((n) => {
1096
- const s = _e(n, e);
1097
- s && (r || (r = []), r.push(s));
1098
- }), {
1099
- actual: t.actual,
1100
- expected: t.expected,
1101
- result: t.result,
1102
- cause: t.cause,
1103
- nested: r,
1104
- error: t.error
1105
- };
1106
- }
1107
- function xe(t, e) {
1108
- const r = vt(t.result, e + " ");
1109
- return `${e}${t.actualKey == null ? "| " : t.actualKey + ": "}${r}`;
1110
- }
1111
- function vt(t, e) {
1112
- if (t.result)
1113
- return t.expected.toString();
1114
- let r = "";
1115
- t.nested && (r = t.nested.map((s) => xe(s, e)).join(`
1116
- `));
1117
- let n = t.cause || "";
1118
- return r ? (n || (n = R(t.expected) ? t.expected.toString(t.actual) : ""), `${n}
1119
- ${r}`) : `${n}
1120
- ${e}expected: ${R(t.expected) ? t.expected.toString(t.actual) : t.expected}
1121
- ${e}actual: ${nt(t.actual)}`;
1122
- }
1123
- class zt extends Error {
1124
- constructor(e) {
1125
- super(e);
1126
- }
1127
- }
1128
- function X(t) {
1129
- return function(r, n) {
1130
- const s = M(t, r);
1131
- if (s.error)
1132
- throw s.error;
1133
- const i = Ft(s, !1);
1134
- if (!i)
1135
- return;
1136
- const o = vt(i, "");
1137
- console.log(`[test][check] CheckError:
1138
- ` + o);
1139
- const u = new zt(o);
1140
- throw n?.(u), u;
1141
- };
1142
- }
1143
- function Cr(t) {
1144
- return function(r, n) {
1145
- let s;
1146
- try {
1147
- s = t();
1148
- } catch (i) {
1149
- X(i)(n);
1150
- return;
1151
- }
1152
- return B(s) ? s.then((i) => (X(i)(r), i)).catch((i) => {
1153
- if (i instanceof zt)
1154
- throw i;
1155
- try {
1156
- X(i)(n);
1157
- } catch (o) {
1158
- throw console.error("[test][check] error", o), i;
1159
- }
1160
- }) : (X(s)(r), s);
1161
- };
1162
- }
1163
- const st = 10;
1164
- class Bt extends p {
1165
- match(e) {
1166
- if (e == null)
1167
- return `Expected array, got "${e}"`;
1168
- if (typeof e != "object")
1169
- return `Expected array, got "${typeof e}"`;
1170
- if (!(e instanceof Array))
1171
- return "Expected array";
1172
- const r = this._args?.expected;
1173
- if (r == null)
1174
- return !0;
1175
- const n = this._args?.maxReportItems ?? st, s = this._args?.matchType || "equals";
1176
- if (s === "equals") {
1177
- if (e.length !== r.length)
1178
- return `Expected array length to be ${r.length}, got ${e.length}`;
1179
- let i = !0, o = 0, u = 0;
1180
- const a = [];
1181
- for (let c = 0; c < r.length; c++) {
1182
- const f = e[c], b = r[c], y = M(f, b);
1183
- if (y.result ? (o < n && a.push({
1184
- actualKey: c,
1185
- expectedKey: c,
1186
- result: y
1187
- }), o++) : (u < n && a.push({
1188
- actualKey: c,
1189
- expectedKey: c,
1190
- result: y
1191
- }), u++, i = !1), !i && o >= n && u >= n)
1192
- break;
1193
- }
1194
- return {
1195
- result: i,
1196
- nested: a
1197
- };
1198
- }
1199
- if (s === "includes") {
1200
- let i = !0;
1201
- const o = [];
1202
- let u = 0, a = 0;
1203
- for (let c = 0; c < r.length; c++) {
1204
- const f = r[c];
1205
- let b = !1;
1206
- for (let y = 0; y < e.length; y++) {
1207
- const h = e[y], l = M(h, f);
1208
- if (l.result) {
1209
- b = !0, u < n && o.push({
1210
- actualKey: y,
1211
- expectedKey: c,
1212
- result: l
1213
- }), u++;
1214
- break;
1215
- }
1216
- }
1217
- if (b || (i = !1, a < n && o.push({
1218
- expectedKey: c,
1219
- result: {
1220
- result: !1,
1221
- actual: void 0,
1222
- expected: f
1223
- }
1224
- }), a++), !i && u >= n && a >= n)
1225
- break;
1226
- }
1227
- return {
1228
- result: i,
1229
- nested: o
1230
- };
1231
- }
1232
- return `Unknown matchType "${s}"`;
1233
- }
1234
- nameDefault() {
1235
- return `array ${this._args?.matchType || "equals"} ${nt(this._args?.expected)}`;
1236
- }
1237
- }
1238
- class $e extends p {
1239
- match() {
1240
- return !0;
1241
- }
1242
- nameDefault() {
1243
- return "any";
1244
- }
1245
- }
1246
- class Oe extends p {
1247
- match(e) {
1248
- if (typeof e != "object")
1249
- return `Expected array, got "${typeof e}"`;
1250
- if (!(e instanceof Array))
1251
- return "Expected array";
1252
- const r = this._args.expected;
1253
- let n = !0;
1254
- const s = [], i = this._args?.maxReportItems ?? st;
1255
- let o = 0, u = 0;
1256
- for (let a = 0; a < e.length; a++) {
1257
- const c = e[a], f = M(c, r);
1258
- if (f.result ? (o < i && s.push({
1259
- actualKey: a,
1260
- expectedKey: a,
1261
- result: f
1262
- }), o++) : (u < i && s.push({
1263
- actualKey: a,
1264
- expectedKey: a,
1265
- result: f
1266
- }), u++, n = !1), !n && o >= i && u >= i)
1267
- break;
1268
- }
1269
- return {
1270
- result: n,
1271
- nested: s
1272
- };
1273
- }
1274
- nameDefault() {
1275
- return "array item";
1276
- }
1277
- }
1278
- class Se extends p {
1279
- match(e) {
1280
- const { expected: r, convert: n } = this._args, s = M(n(e), r), i = [
1281
- {
1282
- result: s
1283
- }
1284
- ];
1285
- return {
1286
- result: s.result,
1287
- nested: i
1288
- };
1289
- }
1290
- nameDefault() {
1291
- return "convert";
1292
- }
1293
- }
1294
- class qt extends p {
1295
- match(e) {
1296
- const { expected: r, nonStrict: n } = this._args;
1297
- return n ? e == r : e === r;
1298
- }
1299
- nameDefault() {
1300
- return `is(${nt(this._args.expected)})`;
1301
- }
1302
- }
1303
- class Ee extends p {
1304
- match(e) {
1305
- if (e == null)
1306
- return `Expected number, got "${e}"`;
1307
- if (typeof e != "number")
1308
- return `Expected number, got "${typeof e}"`;
1309
- if (this._args == null)
1310
- return Number.isFinite(e) ? !0 : "Expected finite number";
1311
- if (!this._args.allowNaN && Number.isNaN(e))
1312
- return "Expected not NaN";
1313
- if (!this._args.allowInfinity && !Number.isFinite(e))
1314
- return "Expected not Infinity";
1315
- const { min: r, max: n, float: s } = this._args;
1316
- 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;
1317
- }
1318
- nameDefault() {
1319
- return `number(${gt(this._args)})`;
1320
- }
1321
- }
1322
- class Ae extends p {
1323
- match(e) {
1324
- if (e == null)
1325
- return `Expected object, got "${e}"`;
1326
- if (Array.isArray(e))
1327
- return "Expected object, got array";
1328
- if (typeof e != "object")
1329
- return `Expected object, got "${typeof e}"`;
1330
- const r = this._args?.expected;
1331
- if (r == null)
1332
- return !0;
1333
- let n = !0;
1334
- const s = [], i = this._args?.maxReportItems ?? st;
1335
- let o = 0, u = 0;
1336
- for (const a in r) {
1337
- if (!Object.prototype.hasOwnProperty.call(r, a))
1338
- continue;
1339
- const c = e[a], f = r[a], b = M(c, f);
1340
- if (b.result ? (o < i && s.push({
1341
- actualKey: a,
1342
- expectedKey: a,
1343
- result: b
1344
- }), o++) : (u < i && s.push({
1345
- actualKey: a,
1346
- expectedKey: a,
1347
- result: b
1348
- }), u++, n = !1), !n && o >= i && u >= i)
1349
- break;
1350
- }
1351
- if (!this._args?.ignoreExtraKeys)
1352
- for (const a in e) {
1353
- if (!Object.prototype.hasOwnProperty.call(e, a) || Object.prototype.hasOwnProperty.call(r, a))
1354
- continue;
1355
- const c = e[a];
1356
- if (u < i && s.push({
1357
- actualKey: a,
1358
- expectedKey: a,
1359
- result: Lt(c, void 0, "Unexpected key")
1360
- }), u++, n = !1, u >= i)
1361
- break;
1362
- }
1363
- return {
1364
- result: n,
1365
- nested: s
1366
- };
1367
- }
1368
- nameDefault() {
1369
- return "object" + gt(this._args);
1370
- }
1371
- }
1372
- class Me extends p {
1373
- match(e) {
1374
- if (e == null)
1375
- return `Expected string, got ${e}`;
1376
- if (typeof e != "string")
1377
- return `Expected string, got "${typeof e}"`;
1378
- if (this._args == null)
1379
- return !0;
1380
- const { pattern: r } = this._args;
1381
- if (r != null) {
1382
- if (typeof r == "function")
1383
- return r(e);
1384
- if (!r.test(e))
1385
- return !1;
1386
- }
1387
- return !0;
1388
- }
1389
- nameDefault() {
1390
- return this._args?.pattern ? `string(${this._args.pattern})` : "string";
1391
- }
1392
- }
1393
- class Te extends p {
1394
- match(e) {
1395
- const r = this._args.expected;
1396
- return e instanceof r ? !0 : `Expected instance of "${r}", got "${e}"`;
1397
- }
1398
- nameDefault() {
1399
- return `instanceOf(${this._args.expected.name})`;
1400
- }
1401
- }
1402
- class Ce extends p {
1403
- constructor(e) {
1404
- super({
1405
- ...e,
1406
- expected: e.expected instanceof Set ? e.expected : new Set(e.expected)
1407
- });
1408
- }
1409
- match(e) {
1410
- return !!this._args.expected.has(e);
1411
- }
1412
- nameDefault() {
1413
- return `in(${nt(this._args.expected)})`;
1414
- }
1415
- }
1416
- class it extends p {
1417
- match(e) {
1418
- const { type: r, expecteds: n, pipe: s } = this._args;
1419
- let i = r === "and";
1420
- const o = [];
1421
- for (let u = 0; u < n.length; u++) {
1422
- const a = n[u], c = M(e, a);
1423
- if (o.push({
1424
- actualKey: `<${r} ${u}>`,
1425
- expectedKey: `<${r} ${u}>`,
1426
- result: c
1427
- }), r === "or") {
1428
- if (c.result && (i = !0, s))
1429
- break;
1430
- } else if (r === "and") {
1431
- if (!c.result && (i = !1, s))
1432
- break;
1433
- } else
1434
- throw new Error(`[test][MatcherFew] Unknown type "${r}"`);
1435
- }
1436
- return {
1437
- result: n.length === 0 || i,
1438
- nested: o
1439
- };
1440
- }
1441
- nameDefault() {
1442
- return this._args.type;
1443
- }
1444
- }
1445
- class Ie extends p {
1446
- match(e) {
1447
- const r = this._args.matcher;
1448
- return R(r) ? r.match(e) : r(e);
1449
- }
1450
- nameDefault(e) {
1451
- const r = this._args.name;
1452
- return typeof r == "string" ? r : r ? r(e) : "custom";
1453
- }
1454
- }
1455
- class ke extends p {
1456
- match() {
1457
- return !1;
1458
- }
1459
- nameDefault() {
1460
- return "never";
1461
- }
1462
- }
1463
- class Ne extends p {
1464
- match(e) {
1465
- if (e == null)
1466
- return `Expected object, got "${e}"`;
1467
- if (Array.isArray(e))
1468
- return "Expected object, got array";
1469
- if (typeof e != "object")
1470
- return `Expected object, got "${typeof e}"`;
1471
- const r = this._args?.expected;
1472
- if (r == null)
1473
- return !0;
1474
- let n = !0;
1475
- const s = [], i = this._args?.maxReportItems ?? st;
1476
- let o = 0, u = 0;
1477
- for (const a in e) {
1478
- if (!Object.prototype.hasOwnProperty.call(e, a))
1479
- continue;
1480
- const c = [a, e[a]], f = M(c, r);
1481
- if (f.result ? (o < i && s.push({
1482
- actualKey: a,
1483
- expectedKey: a,
1484
- result: f
1485
- }), o++) : (u < i && s.push({
1486
- actualKey: a,
1487
- expectedKey: a,
1488
- result: f
1489
- }), u++, n = !1), !n && o >= i && u >= i)
1490
- break;
1491
- }
1492
- return {
1493
- result: n,
1494
- nested: s
1495
- };
1496
- }
1497
- nameDefault() {
1498
- return "object entries" + gt(this._args);
1499
- }
1500
- }
1501
- class De extends p {
1502
- _hasExpected = !1;
1503
- _expected = void 0;
1504
- get expected() {
1505
- return this._expected;
1506
- }
1507
- set expected(e) {
1508
- this._expected = e, this._hasExpected = !0;
1509
- }
1510
- match(e) {
1511
- const r = M(e, this._expected), n = [
1512
- {
1513
- result: r
1514
- }
1515
- ];
1516
- return {
1517
- result: r.result,
1518
- nested: n
1519
- };
1520
- }
1521
- nameDefault() {
1522
- return "ref";
1523
- }
1524
- }
1525
- function j(t) {
1526
- return new Bt({ expected: t });
1527
- }
1528
- function Ir(t) {
1529
- return new Bt({ expected: t, matchType: "includes" });
1530
- }
1531
- function z() {
1532
- return new $e();
1533
- }
1534
- function kr() {
1535
- return new De();
1536
- }
1537
- function Nr(t) {
1538
- return new ke({ name: t });
1539
- }
1540
- function Dr(t, e) {
1541
- const r = new Oe({ expected: e });
1542
- return t == null ? r : T(
1543
- Pe(
1544
- R(t) || typeof t == "number" ? t : ut(t)
1545
- ),
1546
- r
1547
- ).name("array item");
1548
- }
1549
- function I(t, e, r) {
1550
- return new Se({ name: t, convert: e, expected: r });
1551
- }
1552
- function Ue(t) {
1553
- return new qt({ expected: t, nonStrict: !0 });
1554
- }
1555
- function Re(t) {
1556
- return new qt({ expected: t, nonStrict: !1 });
1557
- }
1558
- function Wt(t) {
1559
- return new Ee(t);
1560
- }
1561
- function ut(t) {
1562
- return Wt({
1563
- ...t,
1564
- float: !1
1565
- });
1566
- }
1567
- function Ur(t) {
1568
- return Wt({
1569
- ...t,
1570
- float: !0
1571
- });
1572
- }
1573
- function k(t) {
1574
- return new Ae({ expected: t });
1575
- }
1576
- function mt(t, e, r = null) {
1577
- if (t instanceof p || e && (t = e(t, r), t instanceof p))
1578
- return t;
1579
- if (t == null)
1580
- return rt();
1581
- if (Array.isArray(t)) {
1582
- const n = t.map((s, i) => mt(s, e, i));
1583
- return j(n);
1584
- }
1585
- if (t.constructor === Object) {
1586
- const n = {};
1587
- for (const s in t)
1588
- Object.prototype.hasOwnProperty.call(t, s) && (n[s] = mt(t[s], e, s));
1589
- return k(n);
1590
- }
1591
- return t instanceof te ? Be({
1592
- ...t,
1593
- value: mt(t.value, e, "value")
1594
- }) : Re(t);
1595
- }
1596
- function Rr(t) {
1597
- return k(t).set({
1598
- ignoreExtraKeys: !0
1599
- });
1600
- }
1601
- function Ht(t) {
1602
- return new Me({
1603
- pattern: t
1604
- });
1605
- }
1606
- function jr(t) {
1607
- return new Te({ expected: t });
1608
- }
1609
- function je(t) {
1610
- return I(
1611
- "typeof",
1612
- (e) => e === null ? "null" : typeof e,
1613
- t
1614
- );
1615
- }
1616
- function Kr(t) {
1617
- return I(
1618
- "constructor",
1619
- (e) => e.constructor,
1620
- t
1621
- );
1622
- }
1623
- function pt() {
1624
- return je("boolean");
1625
- }
1626
- function rt() {
1627
- return Ue(null);
1628
- }
1629
- function Pr() {
1630
- return ze(rt());
1631
- }
1632
- function Lr(...t) {
1633
- return new it({
1634
- expecteds: t,
1635
- type: "or",
1636
- pipe: !1
1637
- });
1638
- }
1639
- function Vr(...t) {
1640
- return new it({
1641
- expecteds: t,
1642
- type: "and",
1643
- pipe: !1
1644
- });
1645
- }
1646
- function Ke(...t) {
1647
- return new it({
1648
- expecteds: t,
1649
- type: "or",
1650
- pipe: !0
1651
- });
1652
- }
1653
- function T(...t) {
1654
- return new it({
1655
- expecteds: t,
1656
- type: "and",
1657
- pipe: !0
1658
- });
1659
- }
1660
- function L(t, e) {
1661
- return e == null ? Ke(rt(), t) : e ? t : rt();
1662
- }
1663
- function Pe(t) {
1664
- const e = typeof t == "number" || R(t) ? t : ut(t ?? { min: 1 });
1665
- return T(
1666
- j(),
1667
- I("length", (r) => r.length, e)
1668
- ).name("array length");
1669
- }
1670
- function Fr(t) {
1671
- const e = typeof t == "number" || R(t) ? t : ut(t ?? { min: 1 });
1672
- return T(
1673
- Ht(),
1674
- I("length", (r) => r.length, e)
1675
- ).name("string length");
1676
- }
1677
- function vr(t) {
1678
- return T(k(), t);
1679
- }
1680
- function zr(t) {
1681
- return T(j(), t);
1682
- }
1683
- function Br(t) {
1684
- return T(
1685
- k(),
1686
- I(
1687
- "keys",
1688
- (e) => Object.keys(e),
1689
- t
1690
- )
1691
- );
1692
- }
1693
- function qr(t) {
1694
- return T(
1695
- k(),
1696
- I(
1697
- "values",
1698
- (e) => Object.values(e),
1699
- t
1700
- )
1701
- );
1702
- }
1703
- function Wr(t) {
1704
- return T(
1705
- k(),
1706
- I(
1707
- "entries",
1708
- (e) => Object.entries(e),
1709
- t
1710
- )
1711
- );
1712
- }
1713
- function bt(t) {
1714
- return new Ne({ expected: t });
1715
- }
1716
- function Hr(t) {
1717
- return bt(j([t, z()]));
1718
- }
1719
- function Gr(t) {
1720
- return bt(j([z(), t]));
1721
- }
1722
- function Jr(t, e) {
1723
- return bt(j([t, e]));
1724
- }
1725
- function Xr(t) {
1726
- return T(
1727
- k(),
1728
- I(
1729
- "keys not null",
1730
- (e) => Object.keys(e).filter((r) => e[r] != null),
1731
- t
1732
- )
1733
- );
1734
- }
1735
- function Le(t) {
1736
- return new Ce({ expected: t });
1737
- }
1738
- function Yr(t) {
1739
- return Le(Object.values(t));
1740
- }
1741
- function Gt(t, e) {
1742
- return new Ie({ matcher: e, name: t });
1743
- }
1744
- const Ve = Math.ceil(Date.now() - 10 * 365.25 * 24 * 60 * 60 * 1e3), Fe = Math.ceil(Date.now() + 10 * 365.25 * 24 * 60 * 60 * 1e3);
1745
- function Y(t) {
1746
- return ut({
1747
- ...t,
1748
- min: t?.min ?? Ve,
1749
- max: t?.max ?? Fe
1750
- }).name("int date");
1751
- }
1752
- function ve(t) {
1753
- const e = {
1754
- min: t?.from?.min ?? t?.common?.min,
1755
- max: t?.from?.max ?? t?.common?.max,
1756
- float: t?.from?.float ?? t?.common?.float,
1757
- optional: t?.from?.optional ?? t?.common?.optional
1758
- }, r = {
1759
- min: t?.to?.min ?? t?.common?.min,
1760
- max: t?.to?.max ?? t?.common?.max,
1761
- float: t?.to?.float ?? t?.common?.float,
1762
- optional: t?.to?.optional ?? t?.common?.optional
1763
- };
1764
- return T(
1765
- j([
1766
- e.optional ? L(Y()) : Y(),
1767
- r.optional ? L(Y()) : Y()
1768
- ]),
1769
- Gt("min <= max", (n) => n[0] != null && n[1] != null && n[0] > n[1] ? `Expected range to be [min, max], got [${n.join(", ")}]` : !0)
1770
- ).name("range");
1771
- }
1772
- function Qr(t) {
1773
- return ve({
1774
- ...t,
1775
- common: {
1776
- min: new Date(2020, 0, 1).getTime(),
1777
- max: Date.now() + 900 * 1e3,
1778
- ...t?.common
1779
- }
1780
- }).name("range date");
1781
- }
1782
- function ze(t) {
1783
- return new Vt({ expected: t });
1784
- }
1785
- function Zr() {
1786
- return Ht(/^[\da-f-]{36}|[\da-f]{32}$/i).name("uuid");
1787
- }
1788
- function Be(t) {
1789
- return k({
1790
- [Symbol.toStringTag]: L(z()),
1791
- loading: L(pt()),
1792
- hasValue: L(pt()),
1793
- value: z(),
1794
- hasError: L(pt()),
1795
- error: z(),
1796
- ...t
1797
- });
1798
- }
1799
- function tn(t) {
1800
- return t != null && typeof t == "string" && (t = new TextEncoder().encode(t).buffer), Gt("array buffer", (e) => {
1801
- if (e == null || typeof e != "object" || typeof e.byteLength != "number")
1802
- return `Expected array buffer, got "${e}"`;
1803
- if (t == null)
1804
- return !0;
1805
- if (e.byteLength !== t.byteLength)
1806
- return `Expected array buffer length to be ${t.byteLength}, got ${e.byteLength}`;
1807
- for (let r = 0, n = t.byteLength; r < n; r++)
1808
- if (e[r] !== t[r])
1809
- return `Expected array buffer[${r}] to be ${t[r]}, got ${e[r]}`;
1810
- return !0;
1811
- });
1812
- }
1813
- function Et(t) {
1814
- return t.replace(/\W/g, "").toLowerCase();
1815
- }
1816
- function qe(t) {
1817
- 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();
1818
- }
1819
- function We(t) {
1820
- return t == null ? null : (t = t.toLowerCase().trim(), t === "true" || t === "1" || t === "yes" ? !0 : t === "false" || t === "0" || t === "no" ? !1 : null);
1821
- }
1822
- function He(t) {
1823
- if (t == null)
1824
- return null;
1825
- t = t.trim();
1826
- const e = parseInt(t, 10);
1827
- return isNaN(e) ? null : e;
1828
- }
1829
- function Ge(t) {
1830
- if (t == null)
1831
- return null;
1832
- t = t.trim();
1833
- const e = parseFloat(t);
1834
- return isNaN(e) ? null : e;
1835
- }
1836
- function wt(t, e) {
1837
- const r = qe(e), n = Et(t);
1838
- for (const [s, i] of r.entries())
1839
- if (Et(s) === n)
1840
- return i;
1841
- return null;
1842
- }
1843
- function en(t, e) {
1844
- return We(wt(t, e));
1845
- }
1846
- function rn(t, e) {
1847
- return He(wt(t, e));
1848
- }
1849
- function nn(t, e) {
1850
- return Ge(wt(t, e));
1851
- }
1852
- export {
1853
- Rt as $,
1854
- fr as A,
1855
- xt as B,
1856
- Z as C,
1857
- hr as D,
1858
- mr as E,
1859
- $t as F,
1860
- pr as G,
1861
- dr as H,
1862
- gr as I,
1863
- ye as J,
1864
- br as K,
1865
- wr as L,
1866
- v as M,
1867
- Ut as N,
1868
- yr as O,
1869
- jt as P,
1870
- _r as Q,
1871
- yt as R,
1872
- ge as S,
1873
- be as T,
1874
- lt as U,
1875
- xr as V,
1876
- $r as W,
1877
- Or as X,
1878
- Sr as Y,
1879
- Er as Z,
1880
- Ar as _,
1881
- Ze as a,
1882
- ve as a$,
1883
- Mr as a0,
1884
- Tr as a1,
1885
- D as a2,
1886
- p as a3,
1887
- R as a4,
1888
- nt as a5,
1889
- gt as a6,
1890
- et as a7,
1891
- we as a8,
1892
- Pt as a9,
1893
- jr as aA,
1894
- je as aB,
1895
- Kr as aC,
1896
- pt as aD,
1897
- rt as aE,
1898
- Pr as aF,
1899
- Lr as aG,
1900
- Vr as aH,
1901
- Ke as aI,
1902
- T as aJ,
1903
- L as aK,
1904
- Pe as aL,
1905
- Fr as aM,
1906
- vr as aN,
1907
- zr as aO,
1908
- Br as aP,
1909
- qr as aQ,
1910
- Wr as aR,
1911
- bt as aS,
1912
- Hr as aT,
1913
- Gr as aU,
1914
- Jr as aV,
1915
- Xr as aW,
1916
- Le as aX,
1917
- Yr as aY,
1918
- Gt as aZ,
1919
- Y as a_,
1920
- Lt as aa,
1921
- M as ab,
1922
- zt as ac,
1923
- X as ad,
1924
- Cr as ae,
1925
- _e as af,
1926
- Ft as ag,
1927
- xe as ah,
1928
- vt as ai,
1929
- st as aj,
1930
- j as ak,
1931
- Ir as al,
1932
- z as am,
1933
- kr as an,
1934
- Nr as ao,
1935
- Dr as ap,
1936
- I as aq,
1937
- Ue as ar,
1938
- Re as as,
1939
- Wt as at,
1940
- ut as au,
1941
- Ur as av,
1942
- k as aw,
1943
- mt as ax,
1944
- Rr as ay,
1945
- Ht as az,
1946
- ue as b,
1947
- Qr as b0,
1948
- ze as b1,
1949
- Zr as b2,
1950
- Be as b3,
1951
- tn as b4,
1952
- $e as b5,
1953
- Bt as b6,
1954
- Oe as b7,
1955
- Se as b8,
1956
- Ie as b9,
1957
- it as ba,
1958
- Ce as bb,
1959
- qt as bc,
1960
- ke as bd,
1961
- Vt as be,
1962
- Ee as bf,
1963
- Ae as bg,
1964
- Ne as bh,
1965
- De as bi,
1966
- Me as bj,
1967
- Te as bk,
1968
- qe as bl,
1969
- We as bm,
1970
- He as bn,
1971
- Ge as bo,
1972
- wt as bp,
1973
- en as bq,
1974
- rn as br,
1975
- nn as bs,
1976
- tr as c,
1977
- ce as d,
1978
- le as e,
1979
- nr as f,
1980
- rr as g,
1981
- sr as h,
1982
- kt as i,
1983
- ir as j,
1984
- ur as k,
1985
- or as l,
1986
- ie as m,
1987
- er as n,
1988
- ar as o,
1989
- cr as p,
1990
- Dt as q,
1991
- It as r,
1992
- se as s,
1993
- re as t,
1994
- U as u,
1995
- fe as v,
1996
- me as w,
1997
- P as x,
1998
- J as y,
1999
- lr as z
2000
- };