@yorozu/utils 0.1.1 → 0.3.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/arrays/index.d.ts +4 -0
  3. package/arrays/typed/compare.d.ts +3 -0
  4. package/arrays/typed/find.d.ts +10 -0
  5. package/arrays/typed/index.d.ts +4 -0
  6. package/arrays/typed/misc.d.ts +10 -0
  7. package/arrays/typed/types.d.ts +2 -0
  8. package/arrays/u8/concat.d.ts +3 -0
  9. package/arrays/u8/index.d.ts +6 -0
  10. package/arrays/u8/misc.d.ts +3 -0
  11. package/arrays/u8/pool.d.ts +11 -0
  12. package/arrays/u8/reverse.d.ts +2 -0
  13. package/arrays/u8/swap.d.ts +4 -0
  14. package/arrays/u8/xor.d.ts +2 -0
  15. package/async/async-interval.d.ts +8 -0
  16. package/async/async-lock.d.ts +6 -0
  17. package/async/async-queue.d.ts +18 -0
  18. package/async/async-resource.d.ts +33 -0
  19. package/async/condition-variable.d.ts +5 -0
  20. package/async/deferred.d.ts +24 -0
  21. package/async/emitter.d.ts +11 -0
  22. package/async/index.d.ts +11 -0
  23. package/async/pool.d.ts +19 -0
  24. package/async/sleep.d.ts +1 -0
  25. package/async/timers.d.ts +8 -0
  26. package/bigint/bytes.d.ts +2 -0
  27. package/bigint/index.d.ts +2 -0
  28. package/bigint/math.d.ts +10 -0
  29. package/encoding/base64.d.ts +6 -0
  30. package/encoding/hex.d.ts +4 -0
  31. package/encoding/index.d.ts +4 -0
  32. package/encoding/utf8.d.ts +3 -0
  33. package/index.d.ts +8 -0
  34. package/index.js +1819 -0
  35. package/iterate/enumerate.d.ts +1 -0
  36. package/iterate/index.d.ts +1 -0
  37. package/misc/assert.d.ts +7 -0
  38. package/misc/composer.d.ts +4 -0
  39. package/misc/guards.d.ts +12 -0
  40. package/misc/index.d.ts +6 -0
  41. package/misc/noop.d.ts +1 -0
  42. package/misc/objects.d.ts +18 -0
  43. package/misc/string.d.ts +4 -0
  44. package/package.json +15 -17
  45. package/structures/_iterator.d.ts +2 -0
  46. package/structures/custom-map.d.ts +19 -0
  47. package/structures/custom-set.d.ts +23 -0
  48. package/structures/deque.d.ts +31 -0
  49. package/structures/index.d.ts +5 -0
  50. package/structures/lru-map.d.ts +14 -0
  51. package/structures/lru-set.d.ts +11 -0
  52. package/types/brand.d.ts +5 -0
  53. package/types/equal.d.ts +1 -0
  54. package/types/error.d.ts +6 -0
  55. package/types/index.d.ts +5 -0
  56. package/types/misc.d.ts +11 -0
  57. package/types/unions.d.ts +3 -0
  58. package/lib/index.cjs +0 -2076
  59. package/lib/index.d.cts +0 -468
  60. package/lib/index.d.ts +0 -468
  61. package/lib/index.js +0 -1990
package/index.js ADDED
@@ -0,0 +1,1819 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ //#region src/arrays/typed/compare.ts
14
+ function compare(a, b) {
15
+ if (a.length < b.length) return -1;
16
+ if (a.length > b.length) return 1;
17
+ for (let i = 0; i < a.length; i++) {
18
+ if (a[i] < b[i]) return -1;
19
+ if (a[i] > b[i]) return 1;
20
+ }
21
+ return 0;
22
+ }
23
+ function equal(a, b) {
24
+ return compare(a, b) === 0;
25
+ }
26
+ //#endregion
27
+ //#region src/arrays/typed/find.ts
28
+ function indexOf(haystack, needle, start = 0) {
29
+ let length = haystack.length;
30
+ if (start < 0) {
31
+ start += length;
32
+ if (start < 0) start = 0;
33
+ }
34
+ for (let i = start; i < length; i++) if (haystack[i] === needle) return i;
35
+ return -1;
36
+ }
37
+ function lastIndexOf(haystack, needle, start = haystack.length - 1) {
38
+ let length = haystack.length;
39
+ if (start < 0) {
40
+ start += length;
41
+ if (start < 0) return -1;
42
+ } else if (start >= length) start = length - 1;
43
+ for (let i = start; i >= 0; i--) if (haystack[i] === needle) return i;
44
+ return -1;
45
+ }
46
+ function indexOfArray(haystack, needle, start = 0) {
47
+ if (needle.length === 0) return start;
48
+ if (needle.length === 1) return indexOf(haystack, needle[0], start);
49
+ let max = haystack.length - needle.length;
50
+ for (let i = start; i <= max; i++) if (haystack[i] === needle[0]) {
51
+ let j = 1;
52
+ for (; j < needle.length; j++) if (haystack[i + j] !== needle[j]) break;
53
+ if (j === needle.length) return i;
54
+ }
55
+ return -1;
56
+ }
57
+ function lastIndexOfArray(haystack, needle, start = haystack.length - 1) {
58
+ if (needle.length === 0) return start;
59
+ if (needle.length === 1) return lastIndexOf(haystack, needle[0], start);
60
+ let maxStart = haystack.length - needle.length;
61
+ let effectiveStart = start > maxStart ? maxStart : start;
62
+ for (let i = effectiveStart; i >= 0; i--) {
63
+ let j = 0;
64
+ for (; j < needle.length; j++) if (haystack[i + j] !== needle[j]) break;
65
+ if (j === needle.length) return i;
66
+ }
67
+ return -1;
68
+ }
69
+ function includes(haystack, needle) {
70
+ for (let i = 0; i < haystack.length; i++) {
71
+ let value = haystack[i];
72
+ if (value === needle || Number.isNaN(value) && Number.isNaN(needle)) return true;
73
+ }
74
+ return false;
75
+ }
76
+ function includesArray(haystack, needle) {
77
+ return indexOfArray(haystack, needle) !== -1;
78
+ }
79
+ //#endregion
80
+ //#region src/arrays/typed/misc.ts
81
+ function toDataView(buf) {
82
+ return new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
83
+ }
84
+ function view(ctor, buf) {
85
+ let byteLength = buf.byteLength;
86
+ let bytesPerElement = ctor.BYTES_PER_ELEMENT;
87
+ if (byteLength % bytesPerElement !== 0) throw new RangeError(`byteLength (${byteLength}) is not a multiple of ${bytesPerElement} for ${ctor.name}`);
88
+ let length = byteLength / bytesPerElement;
89
+ return new ctor(buf.buffer, buf.byteOffset, length);
90
+ }
91
+ function getPlatformByteOrder() {
92
+ if (getPlatformByteOrder._cachedByteOrder === null) {
93
+ let buffer = /* @__PURE__ */ new ArrayBuffer(2);
94
+ new DataView(buffer).setUint16(0, 4660, true);
95
+ getPlatformByteOrder._cachedByteOrder = new Uint16Array(buffer)[0] === 4660;
96
+ }
97
+ return getPlatformByteOrder._cachedByteOrder ? "little" : "big";
98
+ }
99
+ getPlatformByteOrder._cachedByteOrder = null;
100
+ //#endregion
101
+ //#region src/arrays/typed/index.ts
102
+ var typed_exports = /* @__PURE__ */ __exportAll({
103
+ compare: () => compare,
104
+ equal: () => equal,
105
+ getPlatformByteOrder: () => getPlatformByteOrder,
106
+ includes: () => includes,
107
+ includesArray: () => includesArray,
108
+ indexOf: () => indexOf,
109
+ indexOfArray: () => indexOfArray,
110
+ lastIndexOf: () => lastIndexOf,
111
+ lastIndexOfArray: () => lastIndexOfArray,
112
+ toDataView: () => toDataView,
113
+ view: () => view
114
+ });
115
+ //#endregion
116
+ //#region src/arrays/u8/misc.ts
117
+ var empty = new Uint8Array(0);
118
+ function clone(buf) {
119
+ return new Uint8Array(buf);
120
+ }
121
+ function readNthBit(byte, bit) {
122
+ return (byte & 1 << bit) >> bit;
123
+ }
124
+ //#endregion
125
+ //#region src/arrays/u8/pool.ts
126
+ var BufferPool = class {
127
+ size;
128
+ maxAllocSize;
129
+ #pool;
130
+ #offset = 0;
131
+ constructor(size = 16 * 1024) {
132
+ this.size = size;
133
+ this.maxAllocSize = size >>> 1;
134
+ this.#reallocate();
135
+ }
136
+ get #remaining() {
137
+ return this.size - this.#offset;
138
+ }
139
+ allocate(size) {
140
+ if (!Number.isInteger(size) || size < 0) throw new RangeError(`Invalid allocation size: ${size}.`);
141
+ if (size === 0) return empty;
142
+ if (size > this.maxAllocSize) return new Uint8Array(size);
143
+ if (size > this.#remaining) this.#reallocate();
144
+ let start = this.#offset;
145
+ this.#offset += size;
146
+ this.#align();
147
+ return new Uint8Array(this.#pool, start, size);
148
+ }
149
+ reset() {
150
+ this.#reallocate();
151
+ }
152
+ #reallocate() {
153
+ this.#pool = new ArrayBuffer(this.size);
154
+ this.#offset = 0;
155
+ }
156
+ #align() {
157
+ let misalignment = this.#offset & 7;
158
+ if (misalignment !== 0) this.#offset += 8 - misalignment;
159
+ }
160
+ };
161
+ var defaultPool = new BufferPool(16 * 1024);
162
+ function setDefaultPool(size) {
163
+ defaultPool = new BufferPool(size);
164
+ }
165
+ function allocate(size) {
166
+ return defaultPool.allocate(size);
167
+ }
168
+ function allocateWith(init) {
169
+ let buf = allocate(init.length);
170
+ buf.set(init);
171
+ return buf;
172
+ }
173
+ //#endregion
174
+ //#region src/arrays/u8/concat.ts
175
+ function concat(bufs) {
176
+ if (bufs.length === 0) return allocate(0);
177
+ if (bufs.length === 1) return bufs[0];
178
+ if (typeof Buffer !== "undefined") {
179
+ let buf = Buffer.concat(bufs);
180
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
181
+ }
182
+ let length = 0;
183
+ for (let i = 0; i < bufs.length; i++) length += bufs[i].length;
184
+ let ret = allocate(length);
185
+ let offset = 0;
186
+ for (let i = 0; i < bufs.length; i++) {
187
+ ret.set(bufs[i], offset);
188
+ offset += bufs[i].length;
189
+ }
190
+ return ret;
191
+ }
192
+ function concat2(a, b) {
193
+ let ret = allocate(a.length + b.length);
194
+ ret.set(a);
195
+ ret.set(b, a.length);
196
+ return ret;
197
+ }
198
+ function concat3(a, b, c) {
199
+ let ret = allocate(a.length + b.length + c.length);
200
+ ret.set(a);
201
+ ret.set(b, a.length);
202
+ ret.set(c, a.length + b.length);
203
+ return ret;
204
+ }
205
+ //#endregion
206
+ //#region src/arrays/u8/reverse.ts
207
+ function reverse(buffer) {
208
+ if (buffer.length < 2) return;
209
+ let left = 0;
210
+ let right = buffer.length - 1;
211
+ while (left < right) {
212
+ let tmp = buffer[left];
213
+ buffer[left] = buffer[right];
214
+ buffer[right] = tmp;
215
+ left++;
216
+ right--;
217
+ }
218
+ }
219
+ function toReversed(buffer) {
220
+ let len = buffer.length;
221
+ if (len === 0) return allocate(0);
222
+ if (len === 1) {
223
+ let result = allocate(1);
224
+ result[0] = buffer[0];
225
+ return result;
226
+ }
227
+ let result = allocate(len);
228
+ let last = len - 1;
229
+ for (let i = 0; i < len; i++) result[i] = buffer[last - i];
230
+ return result;
231
+ }
232
+ //#endregion
233
+ //#region src/arrays/u8/swap.ts
234
+ function swap16(buf) {
235
+ if (buf.length % 2 !== 0) throw new RangeError(`Buffer length must be a multiple of 2`);
236
+ for (let i = 0; i < buf.length; i += 2) {
237
+ let tmp = buf[i];
238
+ buf[i] = buf[i + 1];
239
+ buf[i + 1] = tmp;
240
+ }
241
+ }
242
+ function swap32(buf) {
243
+ if (buf.length % 4 !== 0) throw new RangeError(`Buffer length must be a multiple of 4`);
244
+ for (let i = 0; i < buf.length; i += 4) {
245
+ let tmp = buf[i];
246
+ buf[i] = buf[i + 3];
247
+ buf[i + 3] = tmp;
248
+ tmp = buf[i + 1];
249
+ buf[i + 1] = buf[i + 2];
250
+ buf[i + 2] = tmp;
251
+ }
252
+ }
253
+ function swap64(buf) {
254
+ if (buf.length % 8 !== 0) throw new RangeError(`Buffer length must be a multiple of 8`);
255
+ for (let i = 0; i < buf.length; i += 8) {
256
+ let tmp = buf[i];
257
+ buf[i] = buf[i + 7];
258
+ buf[i + 7] = tmp;
259
+ tmp = buf[i + 1];
260
+ buf[i + 1] = buf[i + 6];
261
+ buf[i + 6] = tmp;
262
+ tmp = buf[i + 2];
263
+ buf[i + 2] = buf[i + 5];
264
+ buf[i + 5] = tmp;
265
+ tmp = buf[i + 3];
266
+ buf[i + 3] = buf[i + 4];
267
+ buf[i + 4] = tmp;
268
+ }
269
+ }
270
+ function swapNibbles(buf) {
271
+ for (let i = 0; i < buf.length; i++) buf[i] = (buf[i] & 240) >> 4 | (buf[i] & 15) << 4;
272
+ }
273
+ //#endregion
274
+ //#region src/arrays/u8/xor.ts
275
+ function xor(data, key) {
276
+ if (key.length < data.length) throw new RangeError(`Key must be at least as long as data (key=${key.length}, data=${data.length})`);
277
+ let ret = allocate(data.length);
278
+ for (let i = 0; i < data.length; i++) ret[i] = data[i] ^ key[i];
279
+ return ret;
280
+ }
281
+ function xorInPlace(data, key) {
282
+ if (key.length < data.length) throw new RangeError(`Key must be at least as long as data (key=${key.length}, data=${data.length})`);
283
+ for (let i = 0; i < data.length; i++) data[i] ^= key[i];
284
+ }
285
+ //#endregion
286
+ //#region src/arrays/u8/index.ts
287
+ var u8_exports = /* @__PURE__ */ __exportAll({
288
+ BufferPool: () => BufferPool,
289
+ allocate: () => allocate,
290
+ allocateWith: () => allocateWith,
291
+ clone: () => clone,
292
+ concat: () => concat,
293
+ concat2: () => concat2,
294
+ concat3: () => concat3,
295
+ empty: () => empty,
296
+ readNthBit: () => readNthBit,
297
+ reverse: () => reverse,
298
+ setDefaultPool: () => setDefaultPool,
299
+ swap16: () => swap16,
300
+ swap32: () => swap32,
301
+ swap64: () => swap64,
302
+ swapNibbles: () => swapNibbles,
303
+ toReversed: () => toReversed,
304
+ xor: () => xor,
305
+ xorInPlace: () => xorInPlace
306
+ });
307
+ //#endregion
308
+ //#region src/bigint/math.ts
309
+ function bitLength(n) {
310
+ if (n === 0n) return 0;
311
+ if (n < 0n) n = -n;
312
+ let hex = n.toString(16);
313
+ let len = hex.length;
314
+ let leadingDigit = parseInt(hex[0], 16);
315
+ return (len - 1) * 4 + (32 - Math.clz32(leadingDigit));
316
+ }
317
+ function twoMultiplicity(n) {
318
+ if (n === 0n) return 0n;
319
+ let m = 0n;
320
+ let pow = 1n;
321
+ while (true) {
322
+ if ((n & pow) !== 0n) return m;
323
+ m += 1n;
324
+ pow <<= 1n;
325
+ }
326
+ }
327
+ function min2(a, b) {
328
+ return a < b ? a : b;
329
+ }
330
+ function min(...args) {
331
+ let m = args[0];
332
+ for (let i = 1; i < args.length; i++) if (args[i] < m) m = args[i];
333
+ return m;
334
+ }
335
+ function max2(a, b) {
336
+ return a > b ? a : b;
337
+ }
338
+ function max(...args) {
339
+ let m = args[0];
340
+ for (let i = 1; i < args.length; i++) if (args[i] > m) m = args[i];
341
+ return m;
342
+ }
343
+ function abs(a) {
344
+ return a < 0n ? -a : a;
345
+ }
346
+ function euclideanGcd(a, b) {
347
+ while (b !== 0n) {
348
+ let t = b;
349
+ b = a % b;
350
+ a = t;
351
+ }
352
+ return a < 0n ? -a : a;
353
+ }
354
+ function modPowBinary(base, exp, mod) {
355
+ if (exp < 0n) throw new RangeError("Negative exponent is not supported.");
356
+ if (mod === 1n) return 0n;
357
+ base %= mod;
358
+ if (base < 0n) base += mod;
359
+ let result = 1n;
360
+ while (exp > 0n) {
361
+ if (exp % 2n === 1n) result = result * base % mod;
362
+ exp >>= 1n;
363
+ base = base ** 2n % mod;
364
+ }
365
+ return result;
366
+ }
367
+ function modInv(a, n) {
368
+ let [g, x] = eGcd(toZn(a, n), n);
369
+ if (g !== 1n) throw new RangeError(`${a.toString()} does not have inverse modulo ${n.toString()}`);
370
+ else return toZn(x, n);
371
+ }
372
+ function eGcd(a, b) {
373
+ let x = 0n;
374
+ let y = 1n;
375
+ let u = 1n;
376
+ let v = 0n;
377
+ while (a !== 0n) {
378
+ let q = b / a;
379
+ let r = b % a;
380
+ let m = x - u * q;
381
+ let n = y - v * q;
382
+ b = a;
383
+ a = r;
384
+ x = u;
385
+ y = v;
386
+ u = m;
387
+ v = n;
388
+ }
389
+ return [
390
+ b,
391
+ x,
392
+ y
393
+ ];
394
+ }
395
+ function toZn(a, n) {
396
+ if (typeof a === "number") a = BigInt(a);
397
+ if (typeof n === "number") n = BigInt(n);
398
+ if (n <= 0n) throw new RangeError("n must be greater than 0.");
399
+ let aZn = a % n;
400
+ return aZn < 0n ? aZn + n : aZn;
401
+ }
402
+ //#endregion
403
+ //#region src/bigint/bytes.ts
404
+ function toBytes(value, length = 0, le = false) {
405
+ let bits = bitLength(value < 0n ? ~value : value) + (value < 0n ? 1 : 0);
406
+ let bytes = Math.ceil(bits / 8);
407
+ if (length !== 0 && bytes > length) throw new RangeError(`Value out of bounds: ${bytes.toString()}, ${length.toString()}.`);
408
+ if (length === 0) length = bytes;
409
+ let buf = new ArrayBuffer(length);
410
+ let arr = new Uint8Array(buf);
411
+ let unaligned = length % 8;
412
+ let dv = new DataView(buf, 0, length - unaligned);
413
+ for (let i = 0; i < dv.byteLength; i += 8) {
414
+ dv.setBigUint64(i, value & 18446744073709551615n, true);
415
+ value >>= 64n;
416
+ }
417
+ if (unaligned > 0) for (let i = length - unaligned; i < length; i++) {
418
+ arr[i] = Number(value & 255n);
419
+ value >>= 8n;
420
+ }
421
+ if (!le) arr.reverse();
422
+ return arr;
423
+ }
424
+ function fromBytes(buffer, le = false) {
425
+ if (le) buffer = toReversed(buffer);
426
+ let unaligned = buffer.length % 8;
427
+ let dv = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength - unaligned);
428
+ let res = 0n;
429
+ for (let i = 0; i < dv.byteLength; i += 8) res = res << 64n | BigInt(dv.getBigUint64(i, false));
430
+ if (unaligned > 0) for (let i = buffer.length - unaligned; i < buffer.length; i++) res = res << 8n | BigInt(buffer[i]);
431
+ return res;
432
+ }
433
+ //#endregion
434
+ //#region src/encoding/utf8.ts
435
+ var utf8_exports = /* @__PURE__ */ __exportAll({
436
+ decoder: () => decoder,
437
+ encodedLength: () => encodedLength$2,
438
+ encoder: () => encoder
439
+ });
440
+ var encoder = new TextEncoder();
441
+ var decoder = new TextDecoder();
442
+ function encodedLength$2(data) {
443
+ if (typeof Buffer !== "undefined") return Buffer.byteLength(data, "utf8");
444
+ let length = data.length;
445
+ for (let i = length - 1; i >= 0; i--) {
446
+ let code = data.charCodeAt(i);
447
+ if (code > 127 && code <= 2047) length++;
448
+ else if (code > 2047 && code <= 65535) length += 2;
449
+ if (code >= 56320 && code <= 57343 && i > 0) {
450
+ let prev = data.charCodeAt(i - 1);
451
+ if (prev >= 55296 && prev <= 56319) i--;
452
+ }
453
+ }
454
+ return length;
455
+ }
456
+ //#endregion
457
+ //#region src/encoding/base64.ts
458
+ var base64_exports = /* @__PURE__ */ __exportAll({
459
+ decode: () => decode$1,
460
+ decodedLength: () => decodedLength$1,
461
+ encode: () => encode$1,
462
+ encodeLookup: () => encodeLookup,
463
+ encodedLength: () => encodedLength$1,
464
+ lookup: () => lookup
465
+ });
466
+ var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
467
+ var lookup = /* @__PURE__ */ new Map();
468
+ var encodeLookup = /* @__PURE__ */ new Map();
469
+ for (let i = 0; i < 64; i++) {
470
+ const charCode = alphabet.charCodeAt(i);
471
+ lookup.set(charCode, i);
472
+ encodeLookup.set(i, charCode);
473
+ }
474
+ lookup.set("=".charCodeAt(0), 0);
475
+ lookup.set("-".charCodeAt(0), 62);
476
+ lookup.set("_".charCodeAt(0), 63);
477
+ var HasToBase64 = typeof Uint8Array.prototype.toBase64 === "function";
478
+ function decode$1(data, url = false) {
479
+ if (typeof Uint8Array.fromBase64 === "function") return Uint8Array.fromBase64(data, { alphabet: url ? "base64url" : "base64" });
480
+ data = data.replace(/=+$/g, "");
481
+ let n = data.length;
482
+ let rem = n % 4;
483
+ let k = rem && rem - 1;
484
+ let m = (n >> 2) * 3 + k;
485
+ let encoded = allocate(n + 3);
486
+ encoder.encodeInto(`${data}===`, encoded);
487
+ for (let i = 0, j = 0; i < n; i += 4, j += 3) {
488
+ let a = lookup.get(encoded[i]);
489
+ let b = lookup.get(encoded[i + 1]);
490
+ let c = lookup.get(encoded[i + 2]);
491
+ let d = lookup.get(encoded[i + 3]);
492
+ if (a === void 0 || b === void 0 || c === void 0 || d === void 0) throw new TypeError("Invalid base64 string.", { cause: { data } });
493
+ let x = (a << 18) + (b << 12) + (c << 6) + d;
494
+ encoded[j] = x >> 16;
495
+ encoded[j + 1] = x >> 8 & 255;
496
+ encoded[j + 2] = x & 255;
497
+ }
498
+ return new Uint8Array(encoded.buffer, encoded.byteOffset, m);
499
+ }
500
+ var ToBase64Options = {
501
+ alphabet: "base64",
502
+ omitPadding: false
503
+ };
504
+ var ToBase64UrlOptions = {
505
+ alphabet: "base64url",
506
+ omitPadding: true
507
+ };
508
+ function encode$1(bytes, url = false) {
509
+ if (typeof Buffer !== "undefined") return Buffer.from(bytes).toString(url ? "base64url" : "base64");
510
+ if (HasToBase64) return bytes.toBase64(url ? ToBase64UrlOptions : ToBase64Options);
511
+ let m = bytes.length;
512
+ let k = m % 3;
513
+ let n = Math.floor(m / 3) * 4 + (k && k + 1);
514
+ let encoded = allocate(Math.ceil(m / 3) * 4);
515
+ for (let i = 0, j = 0; j < m; i += 4, j += 3) {
516
+ let y = (bytes[j] << 16) + (bytes[j + 1] << 8) + (bytes[j + 2] | 0);
517
+ encoded[i] = encodeLookup.get(y >> 18);
518
+ encoded[i + 1] = encodeLookup.get(y >> 12 & 63);
519
+ encoded[i + 2] = encodeLookup.get(y >> 6 & 63);
520
+ encoded[i + 3] = encodeLookup.get(y & 63);
521
+ }
522
+ let base64 = decoder.decode(new Uint8Array(encoded.buffer, encoded.byteOffset, n));
523
+ if (url) base64 = base64.replace(/\+/g, "-").replace(/\//g, "_");
524
+ else {
525
+ if (k === 1) base64 += "==";
526
+ if (k === 2) base64 += "=";
527
+ }
528
+ return base64;
529
+ }
530
+ function encodedLength$1(n) {
531
+ return Math.ceil(n / 3) * 4;
532
+ }
533
+ function decodedLength$1(n) {
534
+ let rem = n % 4;
535
+ return (n >> 2) * 3 + (rem && rem - 1);
536
+ }
537
+ //#endregion
538
+ //#region src/encoding/hex.ts
539
+ var hex_exports = /* @__PURE__ */ __exportAll({
540
+ decode: () => decode,
541
+ decodedLength: () => decodedLength,
542
+ encode: () => encode,
543
+ encodedLength: () => encodedLength
544
+ });
545
+ var hexSliceLookupTable = (function() {
546
+ const alphabet = "0123456789abcdef";
547
+ const table = Array.from({ length: 256 });
548
+ for (let i = 0; i < 16; ++i) {
549
+ const i16 = i * 16;
550
+ for (let j = 0; j < 16; ++j) table[i16 + j] = alphabet[i] + alphabet[j];
551
+ }
552
+ return table;
553
+ })();
554
+ var hexCharValueTable = {
555
+ 0: 0,
556
+ 1: 1,
557
+ 2: 2,
558
+ 3: 3,
559
+ 4: 4,
560
+ 5: 5,
561
+ 6: 6,
562
+ 7: 7,
563
+ 8: 8,
564
+ 9: 9,
565
+ a: 10,
566
+ b: 11,
567
+ c: 12,
568
+ d: 13,
569
+ e: 14,
570
+ f: 15,
571
+ A: 10,
572
+ B: 11,
573
+ C: 12,
574
+ D: 13,
575
+ E: 14,
576
+ F: 15
577
+ };
578
+ var HasToHex = typeof Uint8Array.prototype.toHex === "function";
579
+ function encode(buf) {
580
+ if (typeof Buffer !== "undefined") return Buffer.from(buf).toString("hex");
581
+ if (HasToHex) return buf.toHex();
582
+ let out = "";
583
+ for (let i = 0; i < buf.byteLength; ++i) out += hexSliceLookupTable[buf[i]];
584
+ return out;
585
+ }
586
+ function decode(data) {
587
+ if (typeof Uint8Array.fromHex === "function") return Uint8Array.fromHex(data);
588
+ if (data.length % 2 !== 0) throw new TypeError("Invalid hex string.", { cause: { data } });
589
+ let buf = allocate(data.length / 2);
590
+ for (let i = 0; i < buf.length; ++i) {
591
+ let a = hexCharValueTable[data[i * 2]];
592
+ let b = hexCharValueTable[data[i * 2 + 1]];
593
+ if (a === void 0 || b === void 0) throw new TypeError("Invalid hex string.", { cause: { data } });
594
+ buf[i] = a << 4 | b;
595
+ }
596
+ return buf;
597
+ }
598
+ function encodedLength(n) {
599
+ return n * 2;
600
+ }
601
+ function decodedLength(n) {
602
+ return Math.ceil(n / 2);
603
+ }
604
+ //#endregion
605
+ //#region src/iterate/enumerate.ts
606
+ function enumerate(iterable) {
607
+ const iterator = iterable[Symbol.iterator]();
608
+ let idx = 0;
609
+ return {
610
+ [Symbol.iterator]() {
611
+ return this;
612
+ },
613
+ next() {
614
+ let res = iterator.next();
615
+ if (res.done) return res;
616
+ return {
617
+ done: false,
618
+ value: [idx++, res.value]
619
+ };
620
+ }
621
+ };
622
+ }
623
+ //#endregion
624
+ //#region src/misc/assert.ts
625
+ function assert(condition, message) {
626
+ if (!condition) throw new Error(typeof message === "string" ? message : "Assertion failed.", { cause: message });
627
+ }
628
+ function assertHashKey(obj, key) {
629
+ if (!(key in obj)) throw new Error(`Key ${JSON.stringify(key)} not found in object.`, { cause: {
630
+ obj,
631
+ key
632
+ } });
633
+ }
634
+ function unsafeCastType(value) {}
635
+ function assertNotNull(value) {
636
+ if (value == null) throw new Error(`Value is ${value}.`);
637
+ }
638
+ function asNonNull(value) {
639
+ assertNotNull(value);
640
+ return value;
641
+ }
642
+ function assertMatches(str, regex) {
643
+ let match = str.match(regex);
644
+ if (!match) throw new Error(`${JSON.stringify(str)} does not match ${regex}.`, { cause: {
645
+ str,
646
+ regex
647
+ } });
648
+ return match;
649
+ }
650
+ //#endregion
651
+ //#region src/misc/composer.ts
652
+ function composeMiddlewares(middlewares, final) {
653
+ middlewares = middlewares.slice();
654
+ if (final == null) return function(context, next) {
655
+ function dispatch(i, ctx) {
656
+ if (i > middlewares.length) throw new Error("next() called after end");
657
+ return (middlewares[i] ?? next)(ctx, dispatch.bind(null, i + 1));
658
+ }
659
+ return dispatch(0, context);
660
+ };
661
+ middlewares.push(final);
662
+ function dispatch(i, ctx) {
663
+ let fn = middlewares[i];
664
+ return fn(ctx, boundDispatches[i + 1]);
665
+ }
666
+ let boundDispatches = [];
667
+ for (let i = 0; i < middlewares.length; i++) boundDispatches.push(dispatch.bind(null, i));
668
+ return function(context) {
669
+ return boundDispatches[0](context);
670
+ };
671
+ }
672
+ //#endregion
673
+ //#region src/misc/guards.ts
674
+ var isNotUndefined = (val) => val !== void 0;
675
+ var isNotNull = (val) => val !== null;
676
+ var isBoolean = (val) => typeof val === "boolean";
677
+ var isTruthy = (val) => Boolean(val);
678
+ var isFalsy = (val) => !val;
679
+ var isFunction = (val) => typeof val === "function";
680
+ var isNumber = (val) => typeof val === "number";
681
+ var isString = (val) => typeof val === "string";
682
+ var isSymbol = (val) => typeof val === "symbol";
683
+ var isBigInt = (val) => typeof val === "bigint";
684
+ var isObject = (val) => typeof val === "object" && val !== null;
685
+ //#endregion
686
+ //#region src/misc/noop.ts
687
+ function noop() {}
688
+ //#endregion
689
+ //#region src/misc/objects.ts
690
+ function objectKeys(obj) {
691
+ return Object.keys(obj);
692
+ }
693
+ function objectEntries(obj) {
694
+ return Object.entries(obj);
695
+ }
696
+ function clearUndefinedInPlace(obj) {
697
+ for (const key in obj) {
698
+ if (!Object.hasOwn(obj, key)) continue;
699
+ if (obj[key] === void 0) delete obj[key];
700
+ }
701
+ }
702
+ function deepMerge(into, from, options = {}) {
703
+ if (!Array.isArray(from)) from = [from];
704
+ if (from.length === 0) return into;
705
+ const { undefined: undefinedStrategy = "ignore", properties: propertiesStrategy = "replace", arrays: arraysStrategy = "replace", objects: objectsStrategy = "merge" } = options;
706
+ for (let i = 0; i < from.length; i++) {
707
+ const source = from[i];
708
+ for (const key in source) {
709
+ if (!Object.hasOwn(source, key)) continue;
710
+ const value = source[key];
711
+ const existing = into[key];
712
+ if (value === void 0) {
713
+ if (undefinedStrategy === "replace") into[key] = void 0;
714
+ continue;
715
+ }
716
+ if (Array.isArray(value)) {
717
+ if (arraysStrategy === "merge" && Array.isArray(existing)) existing.push(...value);
718
+ else if (arraysStrategy === "ignore" && existing !== void 0) {} else into[key] = [...value];
719
+ continue;
720
+ }
721
+ if (typeof value === "object" && value !== null) {
722
+ if (value instanceof Date || value instanceof Map || value instanceof Set || value instanceof RegExp) {
723
+ if (propertiesStrategy === "ignore" && existing !== void 0) {} else into[key] = value;
724
+ continue;
725
+ }
726
+ if (objectsStrategy === "merge" && typeof existing === "object" && existing !== null) into[key] = deepMerge(existing, value, options);
727
+ else if (objectsStrategy === "ignore" && existing !== void 0) {} else into[key] = { ...value };
728
+ continue;
729
+ }
730
+ if (propertiesStrategy === "ignore" && existing !== void 0) {} else into[key] = value;
731
+ }
732
+ }
733
+ return into;
734
+ }
735
+ //#endregion
736
+ //#region src/misc/string.ts
737
+ function splitOnce(str, separator) {
738
+ let idx = str.indexOf(separator);
739
+ if (idx === -1) throw new RangeError(`Separator not found: ${separator}.`, { cause: {
740
+ str,
741
+ separator
742
+ } });
743
+ return [str.slice(0, idx), str.slice(idx + separator.length)];
744
+ }
745
+ function assertStartsWith(str, prefix) {
746
+ if (!str.startsWith(prefix)) throw new TypeError(`String does not starts with ${prefix}.`, { cause: {
747
+ str,
748
+ prefix
749
+ } });
750
+ }
751
+ function assertEndsWith(str, suffix) {
752
+ if (!str.endsWith(suffix)) throw new TypeError(`String does not ends with ${suffix}.`, { cause: {
753
+ str,
754
+ suffix
755
+ } });
756
+ }
757
+ //#endregion
758
+ //#region src/async/timers.ts
759
+ var timers_exports = /* @__PURE__ */ __exportAll({
760
+ clearInterval: () => clearIntervalWrap,
761
+ clearTimeout: () => clearTimeoutWrap,
762
+ setInterval: () => setIntervalWrap,
763
+ setTimeout: () => setTimeoutWrap
764
+ });
765
+ var setTimeoutWrap = ((...args) => setTimeout(...args));
766
+ var setIntervalWrap = ((...args) => setInterval(...args));
767
+ var clearTimeoutWrap = ((...args) => clearTimeout(...args));
768
+ var clearIntervalWrap = ((...args) => clearInterval(...args));
769
+ //#endregion
770
+ //#region src/async/async-interval.ts
771
+ var AsyncInterval = class {
772
+ #handler;
773
+ #interval;
774
+ #timer;
775
+ #onError = noop;
776
+ #stopped = true;
777
+ #generation = 0;
778
+ #abortController = new AbortController();
779
+ constructor(handler, interval) {
780
+ this.#handler = handler;
781
+ this.#interval = interval;
782
+ }
783
+ start(after = this.#interval) {
784
+ this.stop();
785
+ this.#stopped = false;
786
+ let generation = this.#generation;
787
+ this.#timer = setTimeoutWrap(() => this.#onTimeout(generation), after);
788
+ }
789
+ startNow() {
790
+ this.stop();
791
+ this.#stopped = false;
792
+ this.#onTimeout(this.#generation);
793
+ }
794
+ stop() {
795
+ this.#generation++;
796
+ this.#abortController.abort();
797
+ this.#abortController = new AbortController();
798
+ if (this.#timer != null) {
799
+ clearTimeoutWrap(this.#timer);
800
+ this.#timer = void 0;
801
+ }
802
+ this.#stopped = true;
803
+ }
804
+ onError(handler) {
805
+ this.#onError = handler;
806
+ }
807
+ #onTimeout = (generation) => {
808
+ this.#timer = void 0;
809
+ (async () => {
810
+ try {
811
+ await this.#handler(this.#abortController.signal);
812
+ } catch (err) {
813
+ this.#onError(err);
814
+ }
815
+ if (this.#stopped || generation !== this.#generation) return;
816
+ this.#timer = setTimeoutWrap(() => this.#onTimeout(generation), this.#interval);
817
+ })();
818
+ };
819
+ };
820
+ //#endregion
821
+ //#region src/structures/_iterator.ts
822
+ var _hasIteratorFrom = null;
823
+ function maybeWrapIterator(iter) {
824
+ if (_hasIteratorFrom === null) _hasIteratorFrom = typeof globalThis.Iterator !== "undefined" && "from" in globalThis.Iterator;
825
+ if (_hasIteratorFrom) return globalThis.Iterator.from(iter);
826
+ return iter;
827
+ }
828
+ //#endregion
829
+ //#region src/structures/custom-map.ts
830
+ var CustomMap = class {
831
+ clear;
832
+ #map;
833
+ #mapperTo;
834
+ #mapperFrom;
835
+ constructor(externalToInternal, internalToExternal) {
836
+ this.#mapperTo = externalToInternal;
837
+ this.#mapperFrom = internalToExternal;
838
+ this.clear = (this.#map = /* @__PURE__ */ new Map()).clear.bind(this.#map);
839
+ }
840
+ get size() {
841
+ return this.#map.size;
842
+ }
843
+ get [Symbol.toStringTag]() {
844
+ return this.#map[Symbol.toStringTag];
845
+ }
846
+ getInternalMap() {
847
+ return this.#map;
848
+ }
849
+ delete(key) {
850
+ return this.#map.delete(this.#mapperTo(key));
851
+ }
852
+ forEach(cb, thisArg) {
853
+ return this.#map.forEach((value, key) => {
854
+ cb.call(thisArg, value, this.#mapperFrom(key), this);
855
+ });
856
+ }
857
+ get(key) {
858
+ return this.#map.get(this.#mapperTo(key));
859
+ }
860
+ has(key) {
861
+ return this.#map.has(this.#mapperTo(key));
862
+ }
863
+ set(key, value) {
864
+ this.#map.set(this.#mapperTo(key), value);
865
+ return this;
866
+ }
867
+ getOrInsert(key, value) {
868
+ if (this.#map.getOrInsert) return this.#map.getOrInsert(this.#mapperTo(key), value);
869
+ let k = this.#mapperTo(key);
870
+ if (!this.#map.has(k)) this.#map.set(k, value);
871
+ return this.#map.get(k);
872
+ }
873
+ getOrInsertComputed(key, callback) {
874
+ if (this.#map.getOrInsertComputed) return this.#map.getOrInsertComputed(this.#mapperTo(key), (k) => callback(this.#mapperFrom(k)));
875
+ let k = this.#mapperTo(key);
876
+ if (!this.#map.has(k)) this.#map.set(k, callback(key));
877
+ return this.#map.get(k);
878
+ }
879
+ entries() {
880
+ let inner = this.#map.entries();
881
+ const iterator = {
882
+ [Symbol.iterator]: () => iterator,
883
+ next: () => {
884
+ let { done, value } = inner.next();
885
+ if (done) return {
886
+ done,
887
+ value
888
+ };
889
+ return {
890
+ done,
891
+ value: [this.#mapperFrom(value[0]), value[1]]
892
+ };
893
+ }
894
+ };
895
+ return maybeWrapIterator(iterator);
896
+ }
897
+ keys() {
898
+ let inner = this.#map.keys();
899
+ const iterator = {
900
+ [Symbol.iterator]: () => iterator,
901
+ next: () => {
902
+ let { done, value } = inner.next();
903
+ if (done) return {
904
+ done,
905
+ value
906
+ };
907
+ return {
908
+ done,
909
+ value: this.#mapperFrom(value)
910
+ };
911
+ }
912
+ };
913
+ return maybeWrapIterator(iterator);
914
+ }
915
+ values() {
916
+ let inner = this.#map.values();
917
+ const iterator = {
918
+ [Symbol.iterator]: () => iterator,
919
+ next: () => {
920
+ let { done, value } = inner.next();
921
+ if (done) return {
922
+ done,
923
+ value
924
+ };
925
+ return {
926
+ done,
927
+ value
928
+ };
929
+ }
930
+ };
931
+ return maybeWrapIterator(iterator);
932
+ }
933
+ [Symbol.iterator]() {
934
+ return this.entries();
935
+ }
936
+ };
937
+ //#endregion
938
+ //#region src/structures/custom-set.ts
939
+ var CustomSet = class CustomSet {
940
+ clear;
941
+ #set;
942
+ #mapperTo;
943
+ #mapperFrom;
944
+ constructor(externalToInternal, internalToExternal) {
945
+ this.#mapperTo = externalToInternal;
946
+ this.#mapperFrom = internalToExternal;
947
+ let set = this.#set = /* @__PURE__ */ new Set();
948
+ this.clear = set.clear.bind(set);
949
+ }
950
+ get size() {
951
+ return this.#set.size;
952
+ }
953
+ get [Symbol.toStringTag]() {
954
+ return this.#set[Symbol.toStringTag];
955
+ }
956
+ add(value) {
957
+ this.#set.add(this.#mapperTo(value));
958
+ return this;
959
+ }
960
+ delete(value) {
961
+ return this.#set.delete(this.#mapperTo(value));
962
+ }
963
+ forEach(cb, thisArg) {
964
+ this.#set.forEach((value) => {
965
+ let mapped = this.#mapperFrom(value);
966
+ cb.call(thisArg, mapped, mapped, this);
967
+ });
968
+ }
969
+ has(value) {
970
+ return this.#set.has(this.#mapperTo(value));
971
+ }
972
+ entries() {
973
+ let inner = this.#set.entries();
974
+ const iterator = {
975
+ [Symbol.iterator]: () => iterator,
976
+ next: () => {
977
+ let { done, value } = inner.next();
978
+ if (done) return {
979
+ done,
980
+ value
981
+ };
982
+ let mapped = this.#mapperFrom(value[0]);
983
+ return {
984
+ done,
985
+ value: [mapped, mapped]
986
+ };
987
+ }
988
+ };
989
+ return maybeWrapIterator(iterator);
990
+ }
991
+ keys() {
992
+ let inner = this.#set.keys();
993
+ const iterator = {
994
+ [Symbol.iterator]: () => iterator,
995
+ next: () => {
996
+ let { done, value } = inner.next();
997
+ if (done) return {
998
+ done,
999
+ value
1000
+ };
1001
+ return {
1002
+ done,
1003
+ value: this.#mapperFrom(value)
1004
+ };
1005
+ }
1006
+ };
1007
+ return maybeWrapIterator(iterator);
1008
+ }
1009
+ values() {
1010
+ return this.keys();
1011
+ }
1012
+ union(other) {
1013
+ let newSet = new CustomSet((k) => this.#mapperTo(k), (k) => this.#mapperFrom(k));
1014
+ this.#set.forEach((v) => newSet.add(this.#mapperFrom(v)));
1015
+ other.forEach((v) => newSet.add(v));
1016
+ return newSet;
1017
+ }
1018
+ intersection(other) {
1019
+ let newSet = new CustomSet((k) => this.#mapperTo(k), (k) => this.#mapperFrom(k));
1020
+ this.#set.forEach((v) => {
1021
+ let ext = this.#mapperFrom(v);
1022
+ if (other.has(ext)) newSet.add(ext);
1023
+ });
1024
+ return newSet;
1025
+ }
1026
+ difference(other) {
1027
+ let newSet = new CustomSet(this.#mapperTo, this.#mapperFrom);
1028
+ this.#set.forEach((v) => {
1029
+ let ext = this.#mapperFrom(v);
1030
+ if (!other.has(ext)) newSet.add(ext);
1031
+ });
1032
+ return newSet;
1033
+ }
1034
+ symmetricDifference(other) {
1035
+ let newSet = new CustomSet((k) => this.#mapperTo(k), (k) => this.#mapperFrom(k));
1036
+ this.#set.forEach((v) => {
1037
+ let ext = this.#mapperFrom(v);
1038
+ if (!other.has(ext)) newSet.add(ext);
1039
+ });
1040
+ other.forEach((v) => {
1041
+ if (!this.has(v)) newSet.add(v);
1042
+ });
1043
+ return newSet;
1044
+ }
1045
+ isSubsetOf(other) {
1046
+ for (let v of this.#set) if (!other.has(this.#mapperFrom(v))) return false;
1047
+ return true;
1048
+ }
1049
+ isSupersetOf(other) {
1050
+ for (let v of other) if (!this.has(v)) return false;
1051
+ return true;
1052
+ }
1053
+ isDisjointFrom(other) {
1054
+ for (let v of other) if (this.has(v)) return false;
1055
+ return true;
1056
+ }
1057
+ [Symbol.iterator]() {
1058
+ return this.keys();
1059
+ }
1060
+ getInternalSet() {
1061
+ return this.#set;
1062
+ }
1063
+ };
1064
+ //#endregion
1065
+ //#region src/structures/deque.ts
1066
+ var Log2 = Math.log(2);
1067
+ function _nextPowerOf2(n) {
1068
+ if (n <= 4) return 4;
1069
+ return 1 << Math.ceil(Math.log(n) / Log2);
1070
+ }
1071
+ var Deque = class {
1072
+ _list;
1073
+ _head = 0;
1074
+ _tail = 0;
1075
+ _capacityMask = 3;
1076
+ _capacity;
1077
+ _size = 0;
1078
+ constructor(array, options = {}) {
1079
+ this._capacity = options.capacity;
1080
+ if (array) this.#fromArray(array);
1081
+ else this._list = new Array(4);
1082
+ }
1083
+ get length() {
1084
+ return this._size;
1085
+ }
1086
+ isEmpty() {
1087
+ return this._size === 0;
1088
+ }
1089
+ at(index) {
1090
+ let i = index;
1091
+ if (i !== (i | 0)) return void 0;
1092
+ let len = this._size;
1093
+ if (i >= len || i < -len) return void 0;
1094
+ if (i < 0) i += len;
1095
+ return this._list[this._head + i & this._capacityMask];
1096
+ }
1097
+ peekFront() {
1098
+ return this.isEmpty() ? void 0 : this._list[this._head];
1099
+ }
1100
+ peekBack() {
1101
+ return this.isEmpty() ? void 0 : this._list[this._tail - 1 + this._list.length & this._capacityMask];
1102
+ }
1103
+ pushFront(item) {
1104
+ if (this._size === this._list.length) this.#growArray();
1105
+ this._head = this._head - 1 + this._list.length & this._capacityMask;
1106
+ this._list[this._head] = item;
1107
+ this._size++;
1108
+ if (this._capacity !== void 0 && this._size > this._capacity) this.popBack();
1109
+ return this._size;
1110
+ }
1111
+ pushBack(item) {
1112
+ if (this._size === this._list.length) this.#growArray();
1113
+ this._list[this._tail] = item;
1114
+ this._tail = this._tail + 1 & this._capacityMask;
1115
+ this._size++;
1116
+ if (this._capacity !== void 0 && this._size > this._capacity) this.popFront();
1117
+ return this._size;
1118
+ }
1119
+ popFront() {
1120
+ if (this.isEmpty()) return void 0;
1121
+ let item = this._list[this._head];
1122
+ this._list[this._head] = void 0;
1123
+ this._head = this._head + 1 & this._capacityMask;
1124
+ this._size--;
1125
+ if (this._size <= this._list.length / 4 && this._list.length > 4) this.#shrinkArray();
1126
+ return item;
1127
+ }
1128
+ popBack() {
1129
+ if (this.isEmpty()) return void 0;
1130
+ this._tail = this._tail - 1 + this._list.length & this._capacityMask;
1131
+ let item = this._list[this._tail];
1132
+ this._list[this._tail] = void 0;
1133
+ this._size--;
1134
+ if (this._size <= this._list.length / 4 && this._list.length > 4) this.#shrinkArray();
1135
+ return item;
1136
+ }
1137
+ removeOne(idx) {
1138
+ let len = this._size;
1139
+ if (idx >= len || idx < -len) return void 0;
1140
+ if (idx < 0) idx += len;
1141
+ let realIdx = this._head + idx & this._capacityMask;
1142
+ let item = this._list[realIdx];
1143
+ this.#remove(realIdx);
1144
+ return item;
1145
+ }
1146
+ removeBy(predicate) {
1147
+ for (let pos = 0; pos < this._size; pos++) {
1148
+ let i = this._head + pos & this._capacityMask;
1149
+ let item = this._list[i];
1150
+ if (item !== void 0 && predicate(item)) {
1151
+ this.#remove(i);
1152
+ return;
1153
+ }
1154
+ }
1155
+ }
1156
+ clear() {
1157
+ this._list = new Array(this._list.length);
1158
+ this._head = 0;
1159
+ this._tail = 0;
1160
+ this._size = 0;
1161
+ }
1162
+ indexOf(item) {
1163
+ for (let pos = 0; pos < this._size; pos++) if (this._list[this._head + pos & this._capacityMask] === item) return pos;
1164
+ return -1;
1165
+ }
1166
+ findIndex(predicate) {
1167
+ for (let pos = 0; pos < this._size; pos++) if (predicate(this._list[this._head + pos & this._capacityMask])) return pos;
1168
+ return -1;
1169
+ }
1170
+ find(predicate) {
1171
+ for (let pos = 0; pos < this._size; pos++) {
1172
+ let item = this._list[this._head + pos & this._capacityMask];
1173
+ if (item !== void 0 && predicate(item)) return item;
1174
+ }
1175
+ }
1176
+ includes(item) {
1177
+ return this.indexOf(item) !== -1;
1178
+ }
1179
+ toArray() {
1180
+ let arr = new Array(this._size);
1181
+ for (let k = 0; k < this._size; k++) arr[k] = this._list[this._head + k & this._capacityMask];
1182
+ return arr;
1183
+ }
1184
+ [Symbol.iterator]() {
1185
+ let pos = 0;
1186
+ return { next: () => {
1187
+ if (pos >= this._size) return {
1188
+ done: true,
1189
+ value: void 0
1190
+ };
1191
+ let value = this._list[this._head + pos & this._capacityMask];
1192
+ pos++;
1193
+ return {
1194
+ done: false,
1195
+ value
1196
+ };
1197
+ } };
1198
+ }
1199
+ #fromArray(array) {
1200
+ let start = 0;
1201
+ let length = array.length;
1202
+ if (this._capacity !== void 0 && length > this._capacity) {
1203
+ start = length - this._capacity;
1204
+ length = this._capacity;
1205
+ }
1206
+ let capacity = _nextPowerOf2(length);
1207
+ this._list = new Array(capacity);
1208
+ this._capacityMask = capacity - 1;
1209
+ this._head = 0;
1210
+ this._tail = length & this._capacityMask;
1211
+ this._size = length;
1212
+ for (let i = 0; i < length; i++) this._list[i] = array[start + i];
1213
+ }
1214
+ #growArray() {
1215
+ let oldMask = this._capacityMask;
1216
+ let oldList = this._list;
1217
+ let oldHead = this._head;
1218
+ let size = this._size;
1219
+ let newList = new Array(oldList.length << 1);
1220
+ for (let i = 0; i < size; i++) newList[i] = oldList[oldHead + i & oldMask];
1221
+ this._list = newList;
1222
+ this._head = 0;
1223
+ this._tail = size;
1224
+ this._capacityMask = newList.length - 1;
1225
+ }
1226
+ #shrinkArray() {
1227
+ if (this._list.length <= 4) return;
1228
+ let oldMask = this._capacityMask;
1229
+ let oldList = this._list;
1230
+ let oldHead = this._head;
1231
+ let size = this._size;
1232
+ let newList = new Array(oldList.length >>> 1);
1233
+ for (let i = 0; i < size; i++) newList[i] = oldList[oldHead + i & oldMask];
1234
+ this._list = newList;
1235
+ this._head = 0;
1236
+ this._tail = size;
1237
+ this._capacityMask = newList.length - 1;
1238
+ }
1239
+ #remove(idx) {
1240
+ let mask = this._capacityMask;
1241
+ let len = this._list.length;
1242
+ let distFromHead = idx - this._head & mask;
1243
+ if (distFromHead < this._size - distFromHead) {
1244
+ let i = idx;
1245
+ while (i !== this._head) {
1246
+ let prev = i - 1 + len & mask;
1247
+ this._list[i] = this._list[prev];
1248
+ i = prev;
1249
+ }
1250
+ this._list[this._head] = void 0;
1251
+ this._head = this._head + 1 & mask;
1252
+ } else {
1253
+ let i = idx;
1254
+ let last = this._tail - 1 + len & mask;
1255
+ while (i !== last) {
1256
+ let next = i + 1 & mask;
1257
+ this._list[i] = this._list[next];
1258
+ i = next;
1259
+ }
1260
+ this._list[last] = void 0;
1261
+ this._tail = last;
1262
+ }
1263
+ this._size--;
1264
+ if (this._size <= this._list.length / 4 && this._list.length > 4) this.#shrinkArray();
1265
+ }
1266
+ };
1267
+ //#endregion
1268
+ //#region src/structures/lru-map.ts
1269
+ var LruMap = class {
1270
+ #capacity;
1271
+ #map;
1272
+ constructor(capacity, MapImpl = Map) {
1273
+ this.#capacity = capacity;
1274
+ this.#map = new MapImpl();
1275
+ }
1276
+ get size() {
1277
+ return this.#map.size;
1278
+ }
1279
+ get(key) {
1280
+ if (!this.#map.has(key)) return void 0;
1281
+ let value = this.#map.get(key);
1282
+ this.#map.delete(key);
1283
+ this.#map.set(key, value);
1284
+ return value;
1285
+ }
1286
+ has(key) {
1287
+ return this.#map.has(key);
1288
+ }
1289
+ set(key, value) {
1290
+ if (this.#map.has(key)) this.#map.delete(key);
1291
+ this.#map.set(key, value);
1292
+ if (this.#map.size > this.#capacity) {
1293
+ let oldest = this.#map.keys().next();
1294
+ if (!oldest.done) this.#map.delete(oldest.value);
1295
+ }
1296
+ }
1297
+ delete(key) {
1298
+ this.#map.delete(key);
1299
+ }
1300
+ clear() {
1301
+ this.#map.clear();
1302
+ }
1303
+ *[Symbol.iterator]() {
1304
+ yield* this.#map;
1305
+ }
1306
+ entries() {
1307
+ return this.#map.entries();
1308
+ }
1309
+ keys() {
1310
+ return this.#map.keys();
1311
+ }
1312
+ values() {
1313
+ return this.#map.values();
1314
+ }
1315
+ };
1316
+ //#endregion
1317
+ //#region src/structures/lru-set.ts
1318
+ var LruSet = class {
1319
+ #capacity;
1320
+ #set;
1321
+ constructor(capacity, SetImpl = Set) {
1322
+ this.#capacity = capacity;
1323
+ this.#set = new SetImpl();
1324
+ }
1325
+ get size() {
1326
+ return this.#set.size;
1327
+ }
1328
+ add(value) {
1329
+ if (this.#set.has(value)) this.#set.delete(value);
1330
+ this.#set.add(value);
1331
+ if (this.#set.size > this.#capacity) {
1332
+ let oldest = this.#set.keys().next();
1333
+ if (!oldest.done) this.#set.delete(oldest.value);
1334
+ }
1335
+ }
1336
+ has(value) {
1337
+ return this.#set.has(value);
1338
+ }
1339
+ delete(value) {
1340
+ return this.#set.delete(value);
1341
+ }
1342
+ clear() {
1343
+ this.#set.clear();
1344
+ }
1345
+ *[Symbol.iterator]() {
1346
+ yield* this.#set;
1347
+ }
1348
+ toArray() {
1349
+ return Array.from(this.#set);
1350
+ }
1351
+ };
1352
+ //#endregion
1353
+ //#region src/async/async-lock.ts
1354
+ var AsyncLock = class {
1355
+ _queue = new Deque();
1356
+ async acquire() {
1357
+ let info;
1358
+ while (info = this._queue.peekFront()) await info[0];
1359
+ let unlock;
1360
+ const promise = new Promise((resolve) => {
1361
+ unlock = resolve;
1362
+ });
1363
+ this._queue.pushBack([promise, unlock]);
1364
+ }
1365
+ release() {
1366
+ const front = this._queue.popFront();
1367
+ if (!front) throw new Error("Nothing to release.", { cause: this._queue });
1368
+ front[1]();
1369
+ }
1370
+ with(func) {
1371
+ return (async () => {
1372
+ await this.acquire();
1373
+ try {
1374
+ return await func();
1375
+ } finally {
1376
+ this.release();
1377
+ }
1378
+ })();
1379
+ }
1380
+ };
1381
+ //#endregion
1382
+ //#region src/async/deferred.ts
1383
+ var Deferred = class {
1384
+ resolve;
1385
+ reject;
1386
+ promise;
1387
+ constructor() {
1388
+ this.promise = new Promise((resolve, reject) => {
1389
+ this.resolve = resolve;
1390
+ this.reject = reject;
1391
+ });
1392
+ }
1393
+ };
1394
+ var DeferredTracked = class {
1395
+ promise;
1396
+ status;
1397
+ #resolve;
1398
+ #reject;
1399
+ constructor() {
1400
+ this.status = { type: "pending" };
1401
+ this.promise = new Promise((resolve, reject) => {
1402
+ this.#resolve = resolve;
1403
+ this.#reject = reject;
1404
+ });
1405
+ }
1406
+ get result() {
1407
+ if (this.status.type === "fulfilled") return this.status.value;
1408
+ }
1409
+ get error() {
1410
+ if (this.status.type === "rejected") return this.status.reason;
1411
+ }
1412
+ resolve(value) {
1413
+ if (this.status.type !== "pending") return;
1414
+ this.status = {
1415
+ type: "fulfilled",
1416
+ value
1417
+ };
1418
+ this.#resolve(value);
1419
+ }
1420
+ reject(reason) {
1421
+ if (this.status.type !== "pending") return;
1422
+ this.status = {
1423
+ type: "rejected",
1424
+ reason
1425
+ };
1426
+ this.#reject(reason);
1427
+ }
1428
+ };
1429
+ //#endregion
1430
+ //#region src/async/async-queue.ts
1431
+ var AsyncQueue = class {
1432
+ queue;
1433
+ maxSize;
1434
+ #consumerWaiters = new Deque();
1435
+ #producerWaiters = new Deque();
1436
+ #ended = false;
1437
+ constructor(from, maxSize) {
1438
+ if (maxSize !== void 0 && maxSize < 1) throw new Error("maxSize must be at least 1");
1439
+ this.maxSize = maxSize;
1440
+ if (from) if (from instanceof Deque) this.queue = from;
1441
+ else this.queue = new Deque(from);
1442
+ else this.queue = new Deque();
1443
+ if (maxSize !== void 0 && this.queue.length > maxSize) throw new Error("Initial queue length exceeds maxSize");
1444
+ }
1445
+ get length() {
1446
+ return this.queue.length;
1447
+ }
1448
+ get isFull() {
1449
+ return this.maxSize !== void 0 && this.queue.length >= this.maxSize;
1450
+ }
1451
+ get remainingCapacity() {
1452
+ return this.maxSize !== void 0 ? this.maxSize - this.queue.length : Infinity;
1453
+ }
1454
+ get ended() {
1455
+ return this.#ended;
1456
+ }
1457
+ async enqueue(item) {
1458
+ if (this.#ended) throw new Error("Cannot enqueue after .end() has been called");
1459
+ while (true) {
1460
+ if (this.#consumerWaiters.length > 0) {
1461
+ this.#consumerWaiters.popFront().resolve(item);
1462
+ return;
1463
+ }
1464
+ if (!this.isFull) {
1465
+ this.queue.pushBack(item);
1466
+ return;
1467
+ }
1468
+ let waiter = new Deferred();
1469
+ this.#producerWaiters.pushBack(waiter);
1470
+ await waiter.promise;
1471
+ if (this.#ended) throw new Error("Queue was ended while waiting to enqueue.");
1472
+ }
1473
+ }
1474
+ tryEnqueue(item) {
1475
+ if (this.#ended || this.isFull) return false;
1476
+ if (this.#consumerWaiters.length > 0) {
1477
+ this.#consumerWaiters.popFront().resolve(item);
1478
+ return true;
1479
+ }
1480
+ this.queue.pushBack(item);
1481
+ return true;
1482
+ }
1483
+ end() {
1484
+ if (this.#ended) throw new Error(".end() has already been called.");
1485
+ this.#ended = true;
1486
+ for (let waiter of this.#consumerWaiters) waiter.resolve(void 0);
1487
+ this.#consumerWaiters.clear();
1488
+ let err = /* @__PURE__ */ new Error("Queue has been ended.");
1489
+ for (let waiter of this.#producerWaiters) waiter.reject(err);
1490
+ this.#producerWaiters.clear();
1491
+ }
1492
+ peek() {
1493
+ return this.queue.peekFront();
1494
+ }
1495
+ next() {
1496
+ if (this.queue.length === 0) return void 0;
1497
+ let item = this.queue.popFront();
1498
+ this.#wakeProducerIfNeeded();
1499
+ return item;
1500
+ }
1501
+ async nextOrWait() {
1502
+ if (this.queue.length > 0) {
1503
+ let item = this.queue.popFront();
1504
+ this.#wakeProducerIfNeeded();
1505
+ return item;
1506
+ }
1507
+ if (this.#ended) return;
1508
+ let waiter = new Deferred();
1509
+ this.#consumerWaiters.pushBack(waiter);
1510
+ return waiter.promise;
1511
+ }
1512
+ [Symbol.asyncIterator]() {
1513
+ let iterator = {
1514
+ [Symbol.asyncIterator]: () => iterator,
1515
+ next: async () => {
1516
+ let item = await this.nextOrWait();
1517
+ if (item === void 0) return {
1518
+ done: true,
1519
+ value: void 0
1520
+ };
1521
+ return {
1522
+ value: item,
1523
+ done: false
1524
+ };
1525
+ }
1526
+ };
1527
+ return iterator;
1528
+ }
1529
+ #wakeProducerIfNeeded() {
1530
+ if (this.#producerWaiters.length > 0 && !this.isFull) this.#producerWaiters.popFront().resolve();
1531
+ }
1532
+ };
1533
+ //#endregion
1534
+ //#region src/async/emitter.ts
1535
+ var Emitter = class {
1536
+ #listeners = [];
1537
+ #emit = noop;
1538
+ get length() {
1539
+ return this.#listeners.length;
1540
+ }
1541
+ add(listener) {
1542
+ this.#listeners.push(listener);
1543
+ this.#updateEmit();
1544
+ }
1545
+ forwardTo(emitter) {
1546
+ this.add(emitter.emit.bind(emitter));
1547
+ }
1548
+ remove(listener) {
1549
+ let idx = this.#listeners.indexOf(listener);
1550
+ if (idx === -1) return;
1551
+ this.#listeners.splice(idx, 1);
1552
+ this.#updateEmit();
1553
+ }
1554
+ emit(value) {
1555
+ this.#emit(value);
1556
+ }
1557
+ once(listener) {
1558
+ const once = (value) => {
1559
+ this.remove(once);
1560
+ listener(value);
1561
+ };
1562
+ this.add(once);
1563
+ }
1564
+ listeners() {
1565
+ return this.#listeners;
1566
+ }
1567
+ clear() {
1568
+ this.#listeners.length = 0;
1569
+ this.#emit = noop;
1570
+ }
1571
+ #emitFew = (value) => {
1572
+ let listeners = this.#listeners.slice();
1573
+ let len = listeners.length;
1574
+ listeners[0](value);
1575
+ len > 1 && listeners[1](value);
1576
+ len > 2 && listeners[2](value);
1577
+ len > 3 && listeners[3](value);
1578
+ len > 4 && listeners[4](value);
1579
+ };
1580
+ #emitAll = (value) => {
1581
+ let listeners = this.#listeners.slice();
1582
+ for (let i = 0; i < listeners.length; i++) listeners[i](value);
1583
+ };
1584
+ #updateEmit = () => {
1585
+ let len = this.#listeners.length;
1586
+ if (len === 0) this.#emit = noop;
1587
+ else if (len <= 5) this.#emit = this.#emitFew;
1588
+ else this.#emit = this.#emitAll;
1589
+ };
1590
+ };
1591
+ //#endregion
1592
+ //#region src/async/async-resource.ts
1593
+ var AsyncResource = class {
1594
+ onUpdated = new Emitter();
1595
+ #abort;
1596
+ #ctx;
1597
+ #updating;
1598
+ #timeout;
1599
+ #destroyed = false;
1600
+ constructor(options) {
1601
+ this.options = options;
1602
+ this.#ctx = {
1603
+ current: null,
1604
+ currentFetchedAt: 0,
1605
+ currentExpiresAt: 0,
1606
+ isBackground: false,
1607
+ abort: null
1608
+ };
1609
+ }
1610
+ get isStale() {
1611
+ return this.#ctx.current === null || this.#ctx.currentExpiresAt <= performance.now();
1612
+ }
1613
+ setData(data, expiresIn) {
1614
+ if (this.#destroyed) return;
1615
+ let now = performance.now();
1616
+ this.#ctx.current = data;
1617
+ this.#ctx.currentExpiresAt = now + expiresIn;
1618
+ this.#ctx.currentFetchedAt = now;
1619
+ this.onUpdated.emit(this.#ctx);
1620
+ if (this.options.autoReload) {
1621
+ this.#clearTimer();
1622
+ this.#timeout = setTimeoutWrap(() => {
1623
+ if (this.#destroyed) return;
1624
+ this.#ctx.isBackground = true;
1625
+ this.update(true).catch(noop);
1626
+ }, expiresIn + (this.options.autoReloadAfter ?? this.options.authReloadAfter ?? 0));
1627
+ }
1628
+ }
1629
+ async update(force = false) {
1630
+ if (this.#destroyed) return;
1631
+ if (this.#updating) {
1632
+ await this.#updating.promise;
1633
+ return;
1634
+ }
1635
+ if (!force && !this.isStale) return;
1636
+ this.#abort?.abort();
1637
+ this.#abort = new AbortController();
1638
+ this.#ctx.abort = this.#abort.signal;
1639
+ this.#updating = new Deferred();
1640
+ let result;
1641
+ try {
1642
+ result = await this.options.fetcher(this.#ctx);
1643
+ } catch (err) {
1644
+ if (err instanceof Error && err.name === "AbortError") {
1645
+ this.#updating?.resolve();
1646
+ this.#updating = void 0;
1647
+ this.#ctx.abort = null;
1648
+ return;
1649
+ }
1650
+ if (this.options.onError) this.options.onError(err, this.#ctx);
1651
+ else console.error(err);
1652
+ this.#updating?.resolve();
1653
+ this.#updating = void 0;
1654
+ this.#ctx.abort = null;
1655
+ return;
1656
+ }
1657
+ this.#updating?.resolve();
1658
+ this.#updating = void 0;
1659
+ this.#ctx.abort = null;
1660
+ if (!this.#destroyed) this.setData(result.data, result.expiresIn);
1661
+ }
1662
+ async get() {
1663
+ if (this.#destroyed) return null;
1664
+ if (this.options.swr === true && this.#ctx.current !== null) {
1665
+ let validator = this.options.swrValidator;
1666
+ if (!validator || validator(this.#ctx)) {
1667
+ this.#ctx.isBackground = true;
1668
+ this.update(true).catch(noop);
1669
+ return this.#ctx.current;
1670
+ }
1671
+ }
1672
+ this.#ctx.isBackground = false;
1673
+ await this.update();
1674
+ return this.#ctx.current;
1675
+ }
1676
+ getCached() {
1677
+ return this.#ctx.current;
1678
+ }
1679
+ destroy() {
1680
+ if (this.#destroyed) return;
1681
+ this.#destroyed = true;
1682
+ this.#clearTimer();
1683
+ this.#abort?.abort();
1684
+ this.onUpdated.clear();
1685
+ this.#updating?.resolve();
1686
+ this.#updating = void 0;
1687
+ }
1688
+ #clearTimer() {
1689
+ if (this.#timeout) {
1690
+ clearTimeoutWrap(this.#timeout);
1691
+ this.#timeout = void 0;
1692
+ }
1693
+ }
1694
+ };
1695
+ //#endregion
1696
+ //#region src/async/condition-variable.ts
1697
+ var ConditionVariable = class {
1698
+ #resolvers = [];
1699
+ wait() {
1700
+ return new Promise((resolve) => {
1701
+ this.#resolvers.push(resolve);
1702
+ });
1703
+ }
1704
+ notify() {
1705
+ let resolvers = this.#resolvers;
1706
+ this.#resolvers = [];
1707
+ for (let resolve of resolvers) resolve();
1708
+ }
1709
+ };
1710
+ //#endregion
1711
+ //#region src/async/pool.ts
1712
+ var ErrorInfo = class {
1713
+ constructor(item, index, error) {
1714
+ this.item = item;
1715
+ this.index = index;
1716
+ this.error = error;
1717
+ }
1718
+ };
1719
+ var AggregateError = class extends Error {
1720
+ constructor(errors) {
1721
+ super(`AggregateError: ${errors.length} errors`);
1722
+ this.errors = errors;
1723
+ }
1724
+ };
1725
+ async function asyncPool(iterable, executor, options = {}) {
1726
+ let { limit = 16, signal, onErrorStrategy } = options;
1727
+ if (limit <= 0) throw new RangeError(`Pool limit must be a positive integer.`);
1728
+ if (signal?.aborted) throw signal.reason;
1729
+ let iterator = iterable[Symbol.asyncIterator]?.() ?? iterable[Symbol.iterator]?.();
1730
+ if (!iterator) throw new TypeError(`iterable must be iterable`);
1731
+ let idx = 0;
1732
+ let errors = [];
1733
+ let abortController = new AbortController();
1734
+ let abortSignal = signal ? AbortSignal.any([signal, abortController.signal]) : abortController.signal;
1735
+ async function worker() {
1736
+ while (true) {
1737
+ if (abortSignal.aborted) return;
1738
+ let result;
1739
+ try {
1740
+ result = await iterator.next();
1741
+ } catch (e) {
1742
+ abortController.abort(e);
1743
+ return;
1744
+ }
1745
+ if (result.done) return;
1746
+ if (abortSignal.aborted) return;
1747
+ let item = result.value;
1748
+ let thisIdx = idx++;
1749
+ try {
1750
+ await executor(item, thisIdx);
1751
+ } catch (err) {
1752
+ let action = onErrorStrategy?.(item, thisIdx, err) ?? "throw";
1753
+ if (action instanceof Promise) action = await action;
1754
+ if (action === "ignore") continue;
1755
+ if (action === "collect") {
1756
+ errors.push(new ErrorInfo(item, thisIdx, err));
1757
+ continue;
1758
+ }
1759
+ abortController.abort(err);
1760
+ return;
1761
+ }
1762
+ }
1763
+ }
1764
+ await Promise.all(Array.from({ length: limit }, worker));
1765
+ if (abortSignal.aborted) throw abortSignal.reason;
1766
+ if (errors.length > 0) throw new AggregateError(errors);
1767
+ }
1768
+ async function parallelMap(iterable, executor, options = {}) {
1769
+ let result = [];
1770
+ if (Array.isArray(iterable)) result.length = iterable.length;
1771
+ await asyncPool(iterable, async (item, index) => {
1772
+ result[index] = await executor(item, index);
1773
+ }, options);
1774
+ return result;
1775
+ }
1776
+ //#endregion
1777
+ //#region src/async/sleep.ts
1778
+ function sleep(ms, signal) {
1779
+ if (ms < 0) throw new RangeError("sleep: ms must be a non-negative number");
1780
+ return new Promise((resolve, reject) => {
1781
+ if (signal?.aborted) {
1782
+ reject(signal.reason ?? new DOMException("The operation was aborted.", "AbortError"));
1783
+ return;
1784
+ }
1785
+ let onAbort = () => {
1786
+ clearTimeout(timeoutId);
1787
+ reject(signal.reason ?? new DOMException("The operation was aborted.", "AbortError"));
1788
+ };
1789
+ let timeoutId = setTimeout(() => {
1790
+ signal?.removeEventListener("abort", onAbort);
1791
+ resolve();
1792
+ }, ms);
1793
+ signal?.addEventListener("abort", onAbort, { once: true });
1794
+ });
1795
+ }
1796
+ //#endregion
1797
+ //#region src/types/error.ts
1798
+ function unknownToError(err) {
1799
+ if (err instanceof Error) return err;
1800
+ if (typeof err === "string") return new Error(err);
1801
+ let error = "";
1802
+ try {
1803
+ error = JSON.stringify(err);
1804
+ } catch (_) {}
1805
+ return new Error(error, { cause: err });
1806
+ }
1807
+ var NotImplementedError = class extends Error {
1808
+ constructor(message, options = {}) {
1809
+ super(`Not implemented${message != null ? `: ${message}` : ""}`, options);
1810
+ }
1811
+ };
1812
+ function throwNotImplemented(message, options) {
1813
+ throw new NotImplementedError(message, options);
1814
+ }
1815
+ function throwUnreachable() {
1816
+ throw new Error("Unreachable");
1817
+ }
1818
+ //#endregion
1819
+ export { AggregateError, AsyncInterval, AsyncLock, AsyncQueue, AsyncResource, ConditionVariable, CustomMap, CustomSet, Deferred, DeferredTracked, Deque, Emitter, LruMap, LruSet, NotImplementedError, abs, asNonNull, assert, assertEndsWith, assertEndsWith as assertsEndsWith, assertHashKey, assertMatches, assertNotNull, assertStartsWith, asyncPool, base64_exports as base64, bitLength, clearUndefinedInPlace, composeMiddlewares, deepMerge, enumerate, euclideanGcd, fromBytes, hex_exports as hex, isBigInt, isBoolean, isFalsy, isFunction, isNotNull, isNotUndefined, isNumber, isObject, isString, isSymbol, isTruthy, max, max2, min, min2, modInv, modPowBinary, noop, objectEntries, objectKeys, parallelMap, sleep, splitOnce, throwNotImplemented, throwUnreachable, timers_exports as timers, toBytes, twoMultiplicity, typed_exports as typed, u8_exports as u8, unknownToError, unsafeCastType, utf8_exports as utf8 };