@flemist/simple-utils 2.0.2 → 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.
@@ -1,780 +0,0 @@
1
- import { AbortControllerFast as et, toAbortSignal as ft, AbortError as ct } from "@flemist/abort-controller-fast";
2
- import { isPromiseLike as X } from "@flemist/async-utils";
3
- import { timeControllerDefault as ht } from "@flemist/time-controller";
4
- let L = null;
5
- function mt() {
6
- if (!L) {
7
- L = new Array(256);
8
- for (let t = 0; t < 256; t++)
9
- L[t] = t.toString(16).padStart(2, "0");
10
- }
11
- return L;
12
- }
13
- function pt(t) {
14
- const e = mt(), n = new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
15
- let r = "";
16
- for (let o = 0, s = n.length; o < s; o++)
17
- r += e[n[o]];
18
- return r;
19
- }
20
- let J = null, nt = null, B = null, rt = null;
21
- function gt() {
22
- J || (J = 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
- ]), nt = new Uint32Array(64), rt = new TextEncoder(), B = new Uint8Array(65536));
88
- }
89
- function dt(t) {
90
- if (t == null)
91
- return null;
92
- gt();
93
- const e = J, n = nt, r = rt;
94
- let o = B, s;
95
- if (typeof t == "string") {
96
- const h = t.length * 3;
97
- o.length < h + 128 && (o = B = new Uint8Array(h + 128));
98
- const c = r.encodeInto(t, o);
99
- s = o.subarray(0, c.written);
100
- } else if (t instanceof Uint8Array)
101
- s = t;
102
- else if (ArrayBuffer.isView(t))
103
- s = 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 f = s.length, a = f + 72 >>> 6 << 6;
113
- o.length < a && (o = B = new Uint8Array(a)), s !== o && o.set(s), o[f] = 128;
114
- for (let h = f + 1; h < a; h++)
115
- o[h] = 0;
116
- const T = f * 8, _ = T / 4294967296 | 0, C = T | 0;
117
- o[a - 8] = _ >>> 24, o[a - 7] = _ >>> 16, o[a - 6] = _ >>> 8, o[a - 5] = _, o[a - 4] = C >>> 24, o[a - 3] = C >>> 16, o[a - 2] = C >>> 8, o[a - 1] = C;
118
- let U = 1779033703, $ = -1150833019, u = 1013904242, i = -1521486534, l = 1359893119, d = -1694144372, p = 528734635, y = 1541459225;
119
- for (let h = 0; h < a; h += 64) {
120
- for (let m = 0; m < 16; m++) {
121
- const g = h + (m << 2);
122
- n[m] = o[g] << 24 | o[g + 1] << 16 | o[g + 2] << 8 | o[g + 3];
123
- }
124
- for (let m = 16; m < 64; m++) {
125
- const g = n[m - 15], A = n[m - 2], H = (g >>> 7 | g << 25) ^ (g >>> 18 | g << 14) ^ g >>> 3, D = (A >>> 17 | A << 15) ^ (A >>> 19 | A << 13) ^ A >>> 10;
126
- n[m] = n[m - 16] + H + n[m - 7] + D | 0;
127
- }
128
- let c = U, S = $, N = u, F = i, O = l, P = d, x = p, q = y;
129
- for (let m = 0; m < 64; m += 4)
130
- for (let g = 0; g < 4; g++) {
131
- const A = m + g, H = (O >>> 6 | O << 26) ^ (O >>> 11 | O << 21) ^ (O >>> 25 | O << 7), D = q + H + (x ^ O & (P ^ x)) + e[A] + n[A] | 0, at = ((c >>> 2 | c << 30) ^ (c >>> 13 | c << 19) ^ (c >>> 22 | c << 10)) + (c & S ^ N & (c ^ S)) | 0;
132
- q = x, x = P, P = O, O = F + D | 0, F = N, N = S, S = c, c = D + at | 0;
133
- }
134
- U = U + c | 0, $ = $ + S | 0, u = u + N | 0, i = i + F | 0, l = l + O | 0, d = d + P | 0, p = p + x | 0, y = y + q | 0;
135
- }
136
- const w = new Uint8Array(32), R = [U, $, u, i, l, d, p, y];
137
- for (let h = 0; h < 8; h++) {
138
- const c = R[h], S = h << 2;
139
- w[S] = c >>> 24, w[S + 1] = c >>> 16 & 255, w[S + 2] = c >>> 8 & 255, w[S + 3] = c & 255;
140
- }
141
- return w;
142
- }
143
- function Lt(t) {
144
- const e = dt(t);
145
- return e ? pt(e) : null;
146
- }
147
- function yt(t, e) {
148
- return t == null ? e : e == null ? t : Math.min(t, e);
149
- }
150
- function wt(t, e) {
151
- return t == null ? e : e == null ? t : Math.max(t, e);
152
- }
153
- function Vt(t, e, n) {
154
- return wt(yt(t, e), n);
155
- }
156
- function Bt(t, e) {
157
- return (t % e + e) % e;
158
- }
159
- function St(t) {
160
- return function() {
161
- let n = t += 1831565813;
162
- return n = Math.imul(n ^ n >>> 15, n | 1), n ^= n + Math.imul(n ^ n >>> 7, n | 61), (n ^ n >>> 14) / 4294967296 + 0.5;
163
- };
164
- }
165
- function Ot() {
166
- return Math.random();
167
- }
168
- function zt() {
169
- return Math.random() * 2 ** 32 >>> 0;
170
- }
171
- function _t(t) {
172
- return t != null ? St(t) : Ot;
173
- }
174
- class Y {
175
- _seed;
176
- _rnd;
177
- constructor(e) {
178
- this._seed = e, this._rnd = _t(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 Y(this.nextSeed());
188
- }
189
- next() {
190
- return this._rnd();
191
- }
192
- clone() {
193
- return new Y(this._seed);
194
- }
195
- }
196
- function ot(t, e, n) {
197
- if (n == null && (n = e, e = 0), n <= e)
198
- throw new Error(
199
- `[random][randomFloat] toExclusive (${n}) must be greater than from (${e})`
200
- );
201
- return t.next() * (n - e) + e;
202
- }
203
- function $t(t, e, n) {
204
- return Math.floor(ot(t, e, n));
205
- }
206
- function Ft(t, e) {
207
- return t.next() < (e ?? 0.5);
208
- }
209
- function qt(t, e, n) {
210
- if (Array.isArray(e)) {
211
- const s = e;
212
- e = s.length, n = (f) => s[f];
213
- }
214
- if (!n)
215
- throw new Error("[random][randomIndexWeighted] getWeight is required");
216
- let r = 0;
217
- for (let s = 0; s < e; s++)
218
- r += n(s);
219
- if (r === 0)
220
- return -1;
221
- let o = ot(t, r);
222
- for (let s = 0; s < e; s++)
223
- if (o -= n(s), o < 0)
224
- return s;
225
- return e - 1;
226
- }
227
- function st(t, e) {
228
- if (e.length === 0)
229
- throw new Error("[random][randomItem] items is empty");
230
- const n = $t(t, e.length);
231
- return e[n];
232
- }
233
- function Ht(t, e, n) {
234
- if (e.length === 0)
235
- throw new Error("[random][randomItems] items is empty");
236
- const r = [];
237
- for (let o = 0; o < n; o++)
238
- r.push(st(t, e));
239
- return r;
240
- }
241
- function Wt(t, e, n) {
242
- let r = Object.values(e);
243
- return n && (r = r.filter(n)), st(t, r);
244
- }
245
- const it = 1073741789, W = (it >> 2) - 1;
246
- function Gt(t = W, e) {
247
- if (t <= 0)
248
- throw new Error(`[random][PseudoRandom] count(${t}) must be > 0`);
249
- if (t > W)
250
- throw new Error(
251
- `[random][PseudoRandom] count(${t}) must be <= ${W}`
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 n = e;
258
- return function() {
259
- return n = (n + it) % t, n;
260
- };
261
- }
262
- let k = null;
263
- function Jt() {
264
- const t = Date.now();
265
- return k == null || t > k ? (k = t, t) : (k++, k);
266
- }
267
- async function Yt({
268
- url: t,
269
- timeout: e
270
- } = {}) {
271
- t || (t = typeof window < "u" ? "/" : "https://google.com");
272
- let n;
273
- try {
274
- const r = new et();
275
- n = e ? setTimeout(() => {
276
- r.abort();
277
- }, e) : null;
278
- const o = await fetch(t, {
279
- method: "HEAD",
280
- signal: ft(r.signal)
281
- }), s = o.headers.get("date");
282
- if (!s)
283
- throw new Error(
284
- `[Now][getDateInet] No date header in response: ${o.status} ${t}`
285
- );
286
- return new Date(s).getTime();
287
- } finally {
288
- n && clearTimeout(n);
289
- }
290
- }
291
- function ut(t, e, n) {
292
- const r = e == null ? t : new Date(
293
- t.toLocaleString("en-US", {
294
- timeZone: e
295
- })
296
- ), o = n == null ? t : new Date(
297
- t.toLocaleString("en-US", {
298
- timeZone: n
299
- })
300
- );
301
- return new Date(
302
- t.getTime() + o.getTime() - r.getTime()
303
- );
304
- }
305
- function At(t, e) {
306
- t = ut(t, "UTC", e);
307
- const n = t.getUTCFullYear().toString().padStart(4, "0"), r = (t.getUTCMonth() + 1).toString().padStart(2, "0"), o = t.getUTCDate().toString().padStart(2, "0"), s = t.getUTCHours().toString().padStart(2, "0"), f = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
308
- return `${n}-${r}-${o} ${s}:${f}:${a}`;
309
- }
310
- let Tt = 0;
311
- const G = /* @__PURE__ */ new WeakMap();
312
- function I(t) {
313
- if (G.has(t))
314
- return G.get(t);
315
- const e = Tt++;
316
- return G.set(t, e), e;
317
- }
318
- function V(t, e, n) {
319
- if (t == null)
320
- return null;
321
- if (e == null || t.length <= e)
322
- return t;
323
- const r = n?.appendEllipsis ? "…" : "", o = r.length + (n?.appendTruncatedLength ? String(t.length).length + 2 : 0), s = Math.max(0, e - o), f = n?.appendTruncatedLength ? `(${t.length - s})` : "";
324
- return s <= 0 ? f + r : n?.fromStart ? f + r + t.slice(t.length - s) : t.slice(0, s) + r + f;
325
- }
326
- function K(t, e) {
327
- try {
328
- return t[e];
329
- } catch (n) {
330
- return "Error: " + (n instanceof Error ? n.message : String(n));
331
- }
332
- }
333
- function M(t, e, n, r) {
334
- const {
335
- pretty: o,
336
- filter: s,
337
- maxDepth: f,
338
- maxItems: a,
339
- maxStringLength: T,
340
- showObjectId: _,
341
- showArrayIndex: C,
342
- customToString: U
343
- } = e ?? {};
344
- if (n == null && (n = []), r == null && (r = /* @__PURE__ */ new Set()), U) {
345
- const u = U(
346
- t,
347
- n,
348
- (i) => M(i, e, n, r)
349
- );
350
- if (u != null)
351
- return V(u, T, e?.truncateOptions);
352
- }
353
- const $ = n.length;
354
- if (typeof t == "string")
355
- return t = V(t, T, e?.truncateOptions), r.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 ?? ""}#${I(t)}[${t.byteLength}]`;
360
- if (t instanceof RegExp)
361
- return V(
362
- String(t),
363
- T,
364
- e?.truncateOptions
365
- );
366
- if (t instanceof Date)
367
- return At(t);
368
- if (t instanceof Object) {
369
- if (r.has(t) || f != null && $ >= f)
370
- return `${t.constructor === Object ? "" : t.constructor?.name ?? ""}#${I(t)}`;
371
- r.add(t);
372
- }
373
- if (t instanceof Error)
374
- return V(
375
- t.stack || t.message || String(t),
376
- T,
377
- e?.truncateOptions
378
- );
379
- if (Array.isArray(t)) {
380
- const u = o ? " ".repeat($) : "";
381
- let i = "";
382
- _ && (i += `#${I(t)} `), i += "[";
383
- let l = 0, d = !1;
384
- for (let p = 0; p < t.length; p++) {
385
- if (a != null && l >= a) {
386
- d = !0;
387
- break;
388
- }
389
- const y = [...n, String(p)], w = K(t, p);
390
- if (s != null && !s(y, w))
391
- continue;
392
- const R = M(w, e, y, r);
393
- l > 0 && (i += ","), o && (i += `
394
- `), o && (i += `${u} `), C && (i += `${p}: `), i += `${R}`, l++;
395
- }
396
- return d ? (l > 0 && (i += ","), o ? (i += `
397
- `, i += `${u} ...
398
- `) : i += "...", i += u, i += "]") : (l > 0 && o && (i += `
399
- ${u}`), i += "]"), i;
400
- }
401
- if (t instanceof Map) {
402
- let u = "";
403
- return _ && (u += `#${I(t)} `), u += "Map", u += M(Array.from(t.entries()), e, n, r), u;
404
- }
405
- if (t instanceof Set) {
406
- let u = "";
407
- return _ && (u += `#${I(t)} `), u += "Set", u += M(Array.from(t.values()), e, n, r), u;
408
- }
409
- {
410
- const u = t.constructor === Object ? "" : t.constructor?.name ?? "", i = o ? " ".repeat($) : "";
411
- let l = u ? `${u} ` : "";
412
- _ && (l += `#${I(t)} `), l += "{";
413
- let d = 0, p = !1;
414
- for (const y in t) {
415
- if (a != null && d >= a) {
416
- p = !0;
417
- break;
418
- }
419
- const w = [...n, y], R = K(t, y);
420
- if (s != null && !s(w, R))
421
- continue;
422
- const h = M(R, e, w, r);
423
- d > 0 && (l += ","), o && (l += `
424
- `), o && (l += `${i} `), l += `${y}: ${h}`, d++;
425
- }
426
- return p && (d > 0 && (l += ","), o ? (l += `
427
- `, l += `${i} ...
428
- `) : l += "...", l += i), d > 0 && o && !p && (l += `
429
- ${i}`), l += "}", l;
430
- }
431
- }
432
- function Xt(t, e) {
433
- t = ut(t, "UTC", e);
434
- const n = t.getUTCFullYear().toString().padStart(4, "0"), r = (t.getUTCMonth() + 1).toString().padStart(2, "0"), o = t.getUTCDate().toString().padStart(2, "0"), s = t.getUTCHours().toString().padStart(2, "0"), f = t.getUTCMinutes().toString().padStart(2, "0"), a = t.getUTCSeconds().toString().padStart(2, "0");
435
- return `${n}-${r}-${o}_${s}-${f}-${a}`;
436
- }
437
- function bt(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 Kt(t) {
454
- return t == null ? null : t?.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
455
- }
456
- function Q(t) {
457
- if (t == null)
458
- return null;
459
- if (Array.isArray(t)) {
460
- const e = t.length, n = [];
461
- for (let r = 0; r < e; r++)
462
- n.push(Q(t[r]));
463
- return n;
464
- }
465
- if (typeof t == "object") {
466
- if (t.constructor && t.constructor !== Object)
467
- return t;
468
- const e = {};
469
- for (const n in t)
470
- Object.prototype.hasOwnProperty.call(t, n) && (e[n] = Q(t[n]));
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 n = t.length;
486
- if (n !== e.length)
487
- return !1;
488
- for (let r = 0; r < n; r++)
489
- if (!z(t[r], e[r]))
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 n in t)
497
- if (Object.prototype.hasOwnProperty.call(t, n) && !z(
498
- t[n],
499
- Object.prototype.hasOwnProperty.call(e, n) ? e[n] : null
500
- ))
501
- return !1;
502
- for (const n in e)
503
- if (Object.prototype.hasOwnProperty.call(e, n) && !Object.prototype.hasOwnProperty.call(t, n) && !z(e[n], null))
504
- return !1;
505
- return !0;
506
- }
507
- return !1;
508
- }
509
- function Qt(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 [n, r] of t)
515
- if (!z(r, e.get(n)))
516
- return !1;
517
- return !0;
518
- }
519
- function Zt(t, e) {
520
- const n = t.length;
521
- if (n !== e.length)
522
- return !1;
523
- for (let r = 0; r < n; r++)
524
- if (t[r] !== e[r])
525
- return !1;
526
- return !0;
527
- }
528
- function Z(t) {
529
- return !t || typeof t != "object" ? t : Array.isArray(t) ? t.map(Z) : t && Object.keys(t).sort().reduce((e, n) => {
530
- const r = Z(t[n]);
531
- return r != null && (e[n] = r), e;
532
- }, {});
533
- }
534
- function vt(t, e) {
535
- return Object.defineProperty(t, "name", { value: e, configurable: !0 }), t;
536
- }
537
- function jt(t) {
538
- const e = alert;
539
- return window.alert = (n) => t(e, n), () => {
540
- window.alert = e;
541
- };
542
- }
543
- var lt = /* @__PURE__ */ ((t) => (t.log = "log", t.warn = "warn", t.error = "error", t.info = "info", t.debug = "debug", t.trace = "trace", t.assert = "assert", t))(lt || {});
544
- const v = Object.values(lt);
545
- function E(t) {
546
- return function() {
547
- t.apply(console, arguments);
548
- };
549
- }
550
- const j = {
551
- log: E(console.log),
552
- warn: E(console.warn),
553
- error: E(console.error),
554
- info: E(console.info),
555
- debug: E(console.debug),
556
- trace: E(console.trace),
557
- assert: E(console.assert)
558
- };
559
- function Ut(t) {
560
- return v.forEach((e) => {
561
- console[e] = (...n) => {
562
- t(j, e, n);
563
- };
564
- }), () => {
565
- v.forEach((e) => {
566
- console[e] = j[e];
567
- });
568
- };
569
- }
570
- function te(t) {
571
- return function(n) {
572
- const r = Ut(t);
573
- try {
574
- const o = n();
575
- return X(o) ? o.then(
576
- (s) => (r(), s),
577
- (s) => {
578
- throw r(), s;
579
- }
580
- ) : o;
581
- } finally {
582
- r();
583
- }
584
- };
585
- }
586
- function Et() {
587
- let t = new Error().stack;
588
- if (t != null) {
589
- const e = t.indexOf(`
590
- `);
591
- e != null && e >= 0 && (t = t.substring(e + 1));
592
- }
593
- return t ?? "";
594
- }
595
- function ee(t) {
596
- return function(...e) {
597
- const n = Et();
598
- try {
599
- return t.apply(this, e);
600
- } catch (r) {
601
- throw r instanceof Error || (r = new Error(String(r))), r.stack = r.stack ? r.stack + `
602
- ` + n : n, r;
603
- }
604
- };
605
- }
606
- function Ct(t) {
607
- if (!t || t.timeout == null)
608
- return null;
609
- const e = new et(), n = t.timeController ?? ht;
610
- if (t.timeout) {
611
- const r = n.setTimeout(() => {
612
- e.abort(
613
- new ct(
614
- `[timeoutAbortController] Timeout error: ${t.timeout}ms`
615
- )
616
- );
617
- }, t.timeout);
618
- e.signal.subscribe(() => {
619
- clearTimeout(r);
620
- });
621
- }
622
- return t.abortSignal?.subscribe((r) => {
623
- e.abort(r);
624
- }), e;
625
- }
626
- async function ne(t, e) {
627
- const n = Ct(e);
628
- try {
629
- return await t(n?.signal ?? e?.abortSignal ?? null);
630
- } finally {
631
- n?.abort();
632
- }
633
- }
634
- class re {
635
- _options;
636
- _hasValue = !1;
637
- _promiseOrValue = null;
638
- constructor(e) {
639
- this._options = e;
640
- }
641
- run() {
642
- if (!this._hasValue) {
643
- let e = this._options.func();
644
- const n = (o) => (this._options.persist ? this._promiseOrValue = o : (this._promiseOrValue = null, this._hasValue = !1), o), r = (o) => {
645
- throw this._options.persist || (this._promiseOrValue = null, this._hasValue = !1), o;
646
- };
647
- if (X(e))
648
- e = e.then(n, r);
649
- else if (!this._options.persist)
650
- return e;
651
- this._promiseOrValue = e, this._hasValue = !0;
652
- }
653
- return this._promiseOrValue;
654
- }
655
- set(e) {
656
- if (!this._options.persist)
657
- throw new Error("[Lazy][set] Cannot set value when persist is false");
658
- this._hasValue = !0, this._promiseOrValue = e;
659
- }
660
- }
661
- class oe {
662
- _options;
663
- _promiseOrValues = /* @__PURE__ */ new Map();
664
- constructor(e) {
665
- this._options = e;
666
- }
667
- run(e) {
668
- if (this._promiseOrValues.has(e))
669
- return this._promiseOrValues.get(e);
670
- let n = this._options.func(e);
671
- const r = (s) => (this._options.persist ? this._promiseOrValues.set(e, s) : this._promiseOrValues.delete(e), s), o = (s) => {
672
- throw this._options.persist || this._promiseOrValues.delete(e), s;
673
- };
674
- if (X(n))
675
- n = n.then(r, o);
676
- else if (!this._options.persist)
677
- return n;
678
- return this._promiseOrValues.set(e, n), n;
679
- }
680
- set(e, n) {
681
- if (!this._options.persist)
682
- throw new Error(
683
- "[LazyWithId][set] Cannot set value when persist is false"
684
- );
685
- this._promiseOrValues.set(e, n);
686
- }
687
- }
688
- function tt(t) {
689
- return t.replace(/\W/g, "").toLowerCase();
690
- }
691
- function Rt(t) {
692
- 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();
693
- }
694
- function It(t) {
695
- return t == null ? null : (t = t.toLowerCase().trim(), t === "true" || t === "1" || t === "yes" ? !0 : t === "false" || t === "0" || t === "no" ? !1 : null);
696
- }
697
- function xt(t) {
698
- if (t == null)
699
- return null;
700
- t = t.trim();
701
- const e = parseInt(t, 10);
702
- return isNaN(e) ? null : e;
703
- }
704
- function kt(t) {
705
- if (t == null)
706
- return null;
707
- t = t.trim();
708
- const e = parseFloat(t);
709
- return isNaN(e) ? null : e;
710
- }
711
- function b(t, e) {
712
- const n = Rt(e), r = tt(t);
713
- for (const [o, s] of n.entries())
714
- if (tt(o) === r)
715
- return s;
716
- return null;
717
- }
718
- function se(t, e) {
719
- return It(b(t, e));
720
- }
721
- function ie(t, e) {
722
- return xt(b(t, e));
723
- }
724
- function ue(t, e) {
725
- return kt(b(t, e));
726
- }
727
- export {
728
- Q as A,
729
- z as B,
730
- Qt as C,
731
- Zt as D,
732
- Z as E,
733
- vt as F,
734
- jt as G,
735
- lt as H,
736
- Ut as I,
737
- te as J,
738
- ee as K,
739
- Et as L,
740
- Ct as M,
741
- ne as N,
742
- re as O,
743
- oe as P,
744
- Rt as Q,
745
- Y as R,
746
- It as S,
747
- xt as T,
748
- W as U,
749
- kt as V,
750
- b as W,
751
- se as X,
752
- ie as Y,
753
- ue as Z,
754
- Lt as a,
755
- wt as b,
756
- Vt as c,
757
- _t as d,
758
- $t as e,
759
- Ft as f,
760
- zt as g,
761
- qt as h,
762
- st as i,
763
- Ht as j,
764
- Wt as k,
765
- Gt as l,
766
- yt as m,
767
- Bt as n,
768
- Jt as o,
769
- Yt as p,
770
- ut as q,
771
- ot as r,
772
- dt as s,
773
- pt as t,
774
- M as u,
775
- At as v,
776
- Xt as w,
777
- V as x,
778
- bt as y,
779
- Kt as z
780
- };