@wovin/connect-nftstorage 0.0.1-RC21 → 0.0.1-RC22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1520 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
+ }) : x)(function(x) {
11
+ if (typeof require !== "undefined")
12
+ return require.apply(this, arguments);
13
+ throw Error('Dynamic require of "' + x + '" is not supported');
14
+ });
15
+ var __commonJS = (cb, mod) => function __require2() {
16
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
17
+ };
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, { get: all[name], enumerable: true });
21
+ };
22
+ var __copyProps = (to, from2, except, desc) => {
23
+ if (from2 && typeof from2 === "object" || typeof from2 === "function") {
24
+ for (let key of __getOwnPropNames(from2))
25
+ if (!__hasOwnProp.call(to, key) && key !== except)
26
+ __defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
27
+ }
28
+ return to;
29
+ };
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
+ // If the importer is in node compatibility mode or this is not an ESM
32
+ // file that has been converted to a CommonJS file using a Babel-
33
+ // compatible transform (i.e. "__esModule" has not been set), then set
34
+ // "default" to the CommonJS "module.exports" for node compatibility.
35
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
+ mod
37
+ ));
38
+ var __publicField = (obj, key, value) => {
39
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
40
+ return value;
41
+ };
42
+
43
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/bases/base32.js
44
+ var base32_exports = {};
45
+ __export(base32_exports, {
46
+ base32: () => base32,
47
+ base32hex: () => base32hex,
48
+ base32hexpad: () => base32hexpad,
49
+ base32hexpadupper: () => base32hexpadupper,
50
+ base32hexupper: () => base32hexupper,
51
+ base32pad: () => base32pad,
52
+ base32padupper: () => base32padupper,
53
+ base32upper: () => base32upper,
54
+ base32z: () => base32z
55
+ });
56
+
57
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/vendor/base-x.js
58
+ function base(ALPHABET, name) {
59
+ if (ALPHABET.length >= 255) {
60
+ throw new TypeError("Alphabet too long");
61
+ }
62
+ var BASE_MAP = new Uint8Array(256);
63
+ for (var j = 0; j < BASE_MAP.length; j++) {
64
+ BASE_MAP[j] = 255;
65
+ }
66
+ for (var i = 0; i < ALPHABET.length; i++) {
67
+ var x = ALPHABET.charAt(i);
68
+ var xc = x.charCodeAt(0);
69
+ if (BASE_MAP[xc] !== 255) {
70
+ throw new TypeError(x + " is ambiguous");
71
+ }
72
+ BASE_MAP[xc] = i;
73
+ }
74
+ var BASE = ALPHABET.length;
75
+ var LEADER = ALPHABET.charAt(0);
76
+ var FACTOR = Math.log(BASE) / Math.log(256);
77
+ var iFACTOR = Math.log(256) / Math.log(BASE);
78
+ function encode3(source) {
79
+ if (source instanceof Uint8Array)
80
+ ;
81
+ else if (ArrayBuffer.isView(source)) {
82
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
83
+ } else if (Array.isArray(source)) {
84
+ source = Uint8Array.from(source);
85
+ }
86
+ if (!(source instanceof Uint8Array)) {
87
+ throw new TypeError("Expected Uint8Array");
88
+ }
89
+ if (source.length === 0) {
90
+ return "";
91
+ }
92
+ var zeroes = 0;
93
+ var length2 = 0;
94
+ var pbegin = 0;
95
+ var pend = source.length;
96
+ while (pbegin !== pend && source[pbegin] === 0) {
97
+ pbegin++;
98
+ zeroes++;
99
+ }
100
+ var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
101
+ var b58 = new Uint8Array(size);
102
+ while (pbegin !== pend) {
103
+ var carry = source[pbegin];
104
+ var i2 = 0;
105
+ for (var it1 = size - 1; (carry !== 0 || i2 < length2) && it1 !== -1; it1--, i2++) {
106
+ carry += 256 * b58[it1] >>> 0;
107
+ b58[it1] = carry % BASE >>> 0;
108
+ carry = carry / BASE >>> 0;
109
+ }
110
+ if (carry !== 0) {
111
+ throw new Error("Non-zero carry");
112
+ }
113
+ length2 = i2;
114
+ pbegin++;
115
+ }
116
+ var it2 = size - length2;
117
+ while (it2 !== size && b58[it2] === 0) {
118
+ it2++;
119
+ }
120
+ var str = LEADER.repeat(zeroes);
121
+ for (; it2 < size; ++it2) {
122
+ str += ALPHABET.charAt(b58[it2]);
123
+ }
124
+ return str;
125
+ }
126
+ function decodeUnsafe(source) {
127
+ if (typeof source !== "string") {
128
+ throw new TypeError("Expected String");
129
+ }
130
+ if (source.length === 0) {
131
+ return new Uint8Array();
132
+ }
133
+ var psz = 0;
134
+ if (source[psz] === " ") {
135
+ return;
136
+ }
137
+ var zeroes = 0;
138
+ var length2 = 0;
139
+ while (source[psz] === LEADER) {
140
+ zeroes++;
141
+ psz++;
142
+ }
143
+ var size = (source.length - psz) * FACTOR + 1 >>> 0;
144
+ var b256 = new Uint8Array(size);
145
+ while (source[psz]) {
146
+ var carry = BASE_MAP[source.charCodeAt(psz)];
147
+ if (carry === 255) {
148
+ return;
149
+ }
150
+ var i2 = 0;
151
+ for (var it3 = size - 1; (carry !== 0 || i2 < length2) && it3 !== -1; it3--, i2++) {
152
+ carry += BASE * b256[it3] >>> 0;
153
+ b256[it3] = carry % 256 >>> 0;
154
+ carry = carry / 256 >>> 0;
155
+ }
156
+ if (carry !== 0) {
157
+ throw new Error("Non-zero carry");
158
+ }
159
+ length2 = i2;
160
+ psz++;
161
+ }
162
+ if (source[psz] === " ") {
163
+ return;
164
+ }
165
+ var it4 = size - length2;
166
+ while (it4 !== size && b256[it4] === 0) {
167
+ it4++;
168
+ }
169
+ var vch = new Uint8Array(zeroes + (size - it4));
170
+ var j2 = zeroes;
171
+ while (it4 !== size) {
172
+ vch[j2++] = b256[it4++];
173
+ }
174
+ return vch;
175
+ }
176
+ function decode5(string) {
177
+ var buffer = decodeUnsafe(string);
178
+ if (buffer) {
179
+ return buffer;
180
+ }
181
+ throw new Error(`Non-${name} character`);
182
+ }
183
+ return {
184
+ encode: encode3,
185
+ decodeUnsafe,
186
+ decode: decode5
187
+ };
188
+ }
189
+ var src = base;
190
+ var _brrp__multiformats_scope_baseX = src;
191
+ var base_x_default = _brrp__multiformats_scope_baseX;
192
+
193
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/bytes.js
194
+ var empty = new Uint8Array(0);
195
+ var equals = (aa, bb) => {
196
+ if (aa === bb)
197
+ return true;
198
+ if (aa.byteLength !== bb.byteLength) {
199
+ return false;
200
+ }
201
+ for (let ii = 0; ii < aa.byteLength; ii++) {
202
+ if (aa[ii] !== bb[ii]) {
203
+ return false;
204
+ }
205
+ }
206
+ return true;
207
+ };
208
+ var coerce = (o) => {
209
+ if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
210
+ return o;
211
+ if (o instanceof ArrayBuffer)
212
+ return new Uint8Array(o);
213
+ if (ArrayBuffer.isView(o)) {
214
+ return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
215
+ }
216
+ throw new Error("Unknown type, must be binary type");
217
+ };
218
+ var fromString = (str) => new TextEncoder().encode(str);
219
+ var toString = (b) => new TextDecoder().decode(b);
220
+
221
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/bases/base.js
222
+ var Encoder = class {
223
+ /**
224
+ * @param {Base} name
225
+ * @param {Prefix} prefix
226
+ * @param {(bytes:Uint8Array) => string} baseEncode
227
+ */
228
+ constructor(name, prefix, baseEncode) {
229
+ this.name = name;
230
+ this.prefix = prefix;
231
+ this.baseEncode = baseEncode;
232
+ }
233
+ /**
234
+ * @param {Uint8Array} bytes
235
+ * @returns {API.Multibase<Prefix>}
236
+ */
237
+ encode(bytes) {
238
+ if (bytes instanceof Uint8Array) {
239
+ return `${this.prefix}${this.baseEncode(bytes)}`;
240
+ } else {
241
+ throw Error("Unknown type, must be binary type");
242
+ }
243
+ }
244
+ };
245
+ var Decoder = class {
246
+ /**
247
+ * @param {Base} name
248
+ * @param {Prefix} prefix
249
+ * @param {(text:string) => Uint8Array} baseDecode
250
+ */
251
+ constructor(name, prefix, baseDecode) {
252
+ this.name = name;
253
+ this.prefix = prefix;
254
+ if (prefix.codePointAt(0) === void 0) {
255
+ throw new Error("Invalid prefix character");
256
+ }
257
+ this.prefixCodePoint = /** @type {number} */
258
+ prefix.codePointAt(0);
259
+ this.baseDecode = baseDecode;
260
+ }
261
+ /**
262
+ * @param {string} text
263
+ */
264
+ decode(text) {
265
+ if (typeof text === "string") {
266
+ if (text.codePointAt(0) !== this.prefixCodePoint) {
267
+ throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
268
+ }
269
+ return this.baseDecode(text.slice(this.prefix.length));
270
+ } else {
271
+ throw Error("Can only multibase decode strings");
272
+ }
273
+ }
274
+ /**
275
+ * @template {string} OtherPrefix
276
+ * @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder
277
+ * @returns {ComposedDecoder<Prefix|OtherPrefix>}
278
+ */
279
+ or(decoder) {
280
+ return or(this, decoder);
281
+ }
282
+ };
283
+ var ComposedDecoder = class {
284
+ /**
285
+ * @param {Decoders<Prefix>} decoders
286
+ */
287
+ constructor(decoders) {
288
+ this.decoders = decoders;
289
+ }
290
+ /**
291
+ * @template {string} OtherPrefix
292
+ * @param {API.UnibaseDecoder<OtherPrefix>|ComposedDecoder<OtherPrefix>} decoder
293
+ * @returns {ComposedDecoder<Prefix|OtherPrefix>}
294
+ */
295
+ or(decoder) {
296
+ return or(this, decoder);
297
+ }
298
+ /**
299
+ * @param {string} input
300
+ * @returns {Uint8Array}
301
+ */
302
+ decode(input) {
303
+ const prefix = (
304
+ /** @type {Prefix} */
305
+ input[0]
306
+ );
307
+ const decoder = this.decoders[prefix];
308
+ if (decoder) {
309
+ return decoder.decode(input);
310
+ } else {
311
+ throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
312
+ }
313
+ }
314
+ };
315
+ var or = (left, right) => new ComposedDecoder(
316
+ /** @type {Decoders<L|R>} */
317
+ {
318
+ ...left.decoders || { [
319
+ /** @type API.UnibaseDecoder<L> */
320
+ left.prefix
321
+ ]: left },
322
+ ...right.decoders || { [
323
+ /** @type API.UnibaseDecoder<R> */
324
+ right.prefix
325
+ ]: right }
326
+ }
327
+ );
328
+ var Codec = class {
329
+ /**
330
+ * @param {Base} name
331
+ * @param {Prefix} prefix
332
+ * @param {(bytes:Uint8Array) => string} baseEncode
333
+ * @param {(text:string) => Uint8Array} baseDecode
334
+ */
335
+ constructor(name, prefix, baseEncode, baseDecode) {
336
+ this.name = name;
337
+ this.prefix = prefix;
338
+ this.baseEncode = baseEncode;
339
+ this.baseDecode = baseDecode;
340
+ this.encoder = new Encoder(name, prefix, baseEncode);
341
+ this.decoder = new Decoder(name, prefix, baseDecode);
342
+ }
343
+ /**
344
+ * @param {Uint8Array} input
345
+ */
346
+ encode(input) {
347
+ return this.encoder.encode(input);
348
+ }
349
+ /**
350
+ * @param {string} input
351
+ */
352
+ decode(input) {
353
+ return this.decoder.decode(input);
354
+ }
355
+ };
356
+ var from = ({ name, prefix, encode: encode3, decode: decode5 }) => new Codec(name, prefix, encode3, decode5);
357
+ var baseX = ({ prefix, name, alphabet }) => {
358
+ const { encode: encode3, decode: decode5 } = base_x_default(alphabet, name);
359
+ return from({
360
+ prefix,
361
+ name,
362
+ encode: encode3,
363
+ /**
364
+ * @param {string} text
365
+ */
366
+ decode: (text) => coerce(decode5(text))
367
+ });
368
+ };
369
+ var decode = (string, alphabet, bitsPerChar, name) => {
370
+ const codes = {};
371
+ for (let i = 0; i < alphabet.length; ++i) {
372
+ codes[alphabet[i]] = i;
373
+ }
374
+ let end = string.length;
375
+ while (string[end - 1] === "=") {
376
+ --end;
377
+ }
378
+ const out = new Uint8Array(end * bitsPerChar / 8 | 0);
379
+ let bits = 0;
380
+ let buffer = 0;
381
+ let written = 0;
382
+ for (let i = 0; i < end; ++i) {
383
+ const value = codes[string[i]];
384
+ if (value === void 0) {
385
+ throw new SyntaxError(`Non-${name} character`);
386
+ }
387
+ buffer = buffer << bitsPerChar | value;
388
+ bits += bitsPerChar;
389
+ if (bits >= 8) {
390
+ bits -= 8;
391
+ out[written++] = 255 & buffer >> bits;
392
+ }
393
+ }
394
+ if (bits >= bitsPerChar || 255 & buffer << 8 - bits) {
395
+ throw new SyntaxError("Unexpected end of data");
396
+ }
397
+ return out;
398
+ };
399
+ var encode = (data, alphabet, bitsPerChar) => {
400
+ const pad = alphabet[alphabet.length - 1] === "=";
401
+ const mask = (1 << bitsPerChar) - 1;
402
+ let out = "";
403
+ let bits = 0;
404
+ let buffer = 0;
405
+ for (let i = 0; i < data.length; ++i) {
406
+ buffer = buffer << 8 | data[i];
407
+ bits += 8;
408
+ while (bits > bitsPerChar) {
409
+ bits -= bitsPerChar;
410
+ out += alphabet[mask & buffer >> bits];
411
+ }
412
+ }
413
+ if (bits) {
414
+ out += alphabet[mask & buffer << bitsPerChar - bits];
415
+ }
416
+ if (pad) {
417
+ while (out.length * bitsPerChar & 7) {
418
+ out += "=";
419
+ }
420
+ }
421
+ return out;
422
+ };
423
+ var rfc4648 = ({ name, prefix, bitsPerChar, alphabet }) => {
424
+ return from({
425
+ prefix,
426
+ name,
427
+ encode(input) {
428
+ return encode(input, alphabet, bitsPerChar);
429
+ },
430
+ decode(input) {
431
+ return decode(input, alphabet, bitsPerChar, name);
432
+ }
433
+ });
434
+ };
435
+
436
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/bases/base32.js
437
+ var base32 = rfc4648({
438
+ prefix: "b",
439
+ name: "base32",
440
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567",
441
+ bitsPerChar: 5
442
+ });
443
+ var base32upper = rfc4648({
444
+ prefix: "B",
445
+ name: "base32upper",
446
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
447
+ bitsPerChar: 5
448
+ });
449
+ var base32pad = rfc4648({
450
+ prefix: "c",
451
+ name: "base32pad",
452
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
453
+ bitsPerChar: 5
454
+ });
455
+ var base32padupper = rfc4648({
456
+ prefix: "C",
457
+ name: "base32padupper",
458
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
459
+ bitsPerChar: 5
460
+ });
461
+ var base32hex = rfc4648({
462
+ prefix: "v",
463
+ name: "base32hex",
464
+ alphabet: "0123456789abcdefghijklmnopqrstuv",
465
+ bitsPerChar: 5
466
+ });
467
+ var base32hexupper = rfc4648({
468
+ prefix: "V",
469
+ name: "base32hexupper",
470
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
471
+ bitsPerChar: 5
472
+ });
473
+ var base32hexpad = rfc4648({
474
+ prefix: "t",
475
+ name: "base32hexpad",
476
+ alphabet: "0123456789abcdefghijklmnopqrstuv=",
477
+ bitsPerChar: 5
478
+ });
479
+ var base32hexpadupper = rfc4648({
480
+ prefix: "T",
481
+ name: "base32hexpadupper",
482
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
483
+ bitsPerChar: 5
484
+ });
485
+ var base32z = rfc4648({
486
+ prefix: "h",
487
+ name: "base32z",
488
+ alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
489
+ bitsPerChar: 5
490
+ });
491
+
492
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/bases/base58.js
493
+ var base58_exports = {};
494
+ __export(base58_exports, {
495
+ base58btc: () => base58btc,
496
+ base58flickr: () => base58flickr
497
+ });
498
+ var base58btc = baseX({
499
+ name: "base58btc",
500
+ prefix: "z",
501
+ alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
502
+ });
503
+ var base58flickr = baseX({
504
+ name: "base58flickr",
505
+ prefix: "Z",
506
+ alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
507
+ });
508
+
509
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/vendor/varint.js
510
+ var encode_1 = encode2;
511
+ var MSB = 128;
512
+ var REST = 127;
513
+ var MSBALL = ~REST;
514
+ var INT = Math.pow(2, 31);
515
+ function encode2(num, out, offset) {
516
+ out = out || [];
517
+ offset = offset || 0;
518
+ var oldOffset = offset;
519
+ while (num >= INT) {
520
+ out[offset++] = num & 255 | MSB;
521
+ num /= 128;
522
+ }
523
+ while (num & MSBALL) {
524
+ out[offset++] = num & 255 | MSB;
525
+ num >>>= 7;
526
+ }
527
+ out[offset] = num | 0;
528
+ encode2.bytes = offset - oldOffset + 1;
529
+ return out;
530
+ }
531
+ var decode2 = read;
532
+ var MSB$1 = 128;
533
+ var REST$1 = 127;
534
+ function read(buf, offset) {
535
+ var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
536
+ do {
537
+ if (counter >= l) {
538
+ read.bytes = 0;
539
+ throw new RangeError("Could not decode varint");
540
+ }
541
+ b = buf[counter++];
542
+ res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
543
+ shift += 7;
544
+ } while (b >= MSB$1);
545
+ read.bytes = counter - offset;
546
+ return res;
547
+ }
548
+ var N1 = Math.pow(2, 7);
549
+ var N2 = Math.pow(2, 14);
550
+ var N3 = Math.pow(2, 21);
551
+ var N4 = Math.pow(2, 28);
552
+ var N5 = Math.pow(2, 35);
553
+ var N6 = Math.pow(2, 42);
554
+ var N7 = Math.pow(2, 49);
555
+ var N8 = Math.pow(2, 56);
556
+ var N9 = Math.pow(2, 63);
557
+ var length = function(value) {
558
+ return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
559
+ };
560
+ var varint = {
561
+ encode: encode_1,
562
+ decode: decode2,
563
+ encodingLength: length
564
+ };
565
+ var _brrp_varint = varint;
566
+ var varint_default = _brrp_varint;
567
+
568
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/varint.js
569
+ var decode3 = (data, offset = 0) => {
570
+ const code = varint_default.decode(data, offset);
571
+ return [code, varint_default.decode.bytes];
572
+ };
573
+ var encodeTo = (int, target, offset = 0) => {
574
+ varint_default.encode(int, target, offset);
575
+ return target;
576
+ };
577
+ var encodingLength = (int) => {
578
+ return varint_default.encodingLength(int);
579
+ };
580
+
581
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/hashes/digest.js
582
+ var create = (code, digest) => {
583
+ const size = digest.byteLength;
584
+ const sizeOffset = encodingLength(code);
585
+ const digestOffset = sizeOffset + encodingLength(size);
586
+ const bytes = new Uint8Array(digestOffset + size);
587
+ encodeTo(code, bytes, 0);
588
+ encodeTo(size, bytes, sizeOffset);
589
+ bytes.set(digest, digestOffset);
590
+ return new Digest(code, size, digest, bytes);
591
+ };
592
+ var decode4 = (multihash) => {
593
+ const bytes = coerce(multihash);
594
+ const [code, sizeOffset] = decode3(bytes);
595
+ const [size, digestOffset] = decode3(bytes.subarray(sizeOffset));
596
+ const digest = bytes.subarray(sizeOffset + digestOffset);
597
+ if (digest.byteLength !== size) {
598
+ throw new Error("Incorrect length");
599
+ }
600
+ return new Digest(code, size, digest, bytes);
601
+ };
602
+ var equals2 = (a, b) => {
603
+ if (a === b) {
604
+ return true;
605
+ } else {
606
+ const data = (
607
+ /** @type {{code?:unknown, size?:unknown, bytes?:unknown}} */
608
+ b
609
+ );
610
+ return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equals(a.bytes, data.bytes);
611
+ }
612
+ };
613
+ var Digest = class {
614
+ /**
615
+ * Creates a multihash digest.
616
+ *
617
+ * @param {Code} code
618
+ * @param {Size} size
619
+ * @param {Uint8Array} digest
620
+ * @param {Uint8Array} bytes
621
+ */
622
+ constructor(code, size, digest, bytes) {
623
+ this.code = code;
624
+ this.size = size;
625
+ this.digest = digest;
626
+ this.bytes = bytes;
627
+ }
628
+ };
629
+
630
+ // ../../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/cid.js
631
+ var format = (link, base2) => {
632
+ const { bytes, version } = link;
633
+ switch (version) {
634
+ case 0:
635
+ return toStringV0(
636
+ bytes,
637
+ baseCache(link),
638
+ /** @type {API.MultibaseEncoder<"z">} */
639
+ base2 || base58btc.encoder
640
+ );
641
+ default:
642
+ return toStringV1(
643
+ bytes,
644
+ baseCache(link),
645
+ /** @type {API.MultibaseEncoder<Prefix>} */
646
+ base2 || base32.encoder
647
+ );
648
+ }
649
+ };
650
+ var cache = /* @__PURE__ */ new WeakMap();
651
+ var baseCache = (cid) => {
652
+ const baseCache2 = cache.get(cid);
653
+ if (baseCache2 == null) {
654
+ const baseCache3 = /* @__PURE__ */ new Map();
655
+ cache.set(cid, baseCache3);
656
+ return baseCache3;
657
+ }
658
+ return baseCache2;
659
+ };
660
+ var CID = class _CID {
661
+ /**
662
+ * @param {Version} version - Version of the CID
663
+ * @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
664
+ * @param {API.MultihashDigest<Alg>} multihash - (Multi)hash of the of the content.
665
+ * @param {Uint8Array} bytes
666
+ */
667
+ constructor(version, code, multihash, bytes) {
668
+ this.code = code;
669
+ this.version = version;
670
+ this.multihash = multihash;
671
+ this.bytes = bytes;
672
+ this["/"] = bytes;
673
+ }
674
+ /**
675
+ * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
676
+ * please either use `CID.asCID(cid)` or switch to new signalling mechanism
677
+ *
678
+ * @deprecated
679
+ */
680
+ get asCID() {
681
+ return this;
682
+ }
683
+ // ArrayBufferView
684
+ get byteOffset() {
685
+ return this.bytes.byteOffset;
686
+ }
687
+ // ArrayBufferView
688
+ get byteLength() {
689
+ return this.bytes.byteLength;
690
+ }
691
+ /**
692
+ * @returns {CID<Data, API.DAG_PB, API.SHA_256, 0>}
693
+ */
694
+ toV0() {
695
+ switch (this.version) {
696
+ case 0: {
697
+ return (
698
+ /** @type {CID<Data, API.DAG_PB, API.SHA_256, 0>} */
699
+ this
700
+ );
701
+ }
702
+ case 1: {
703
+ const { code, multihash } = this;
704
+ if (code !== DAG_PB_CODE) {
705
+ throw new Error("Cannot convert a non dag-pb CID to CIDv0");
706
+ }
707
+ if (multihash.code !== SHA_256_CODE) {
708
+ throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
709
+ }
710
+ return (
711
+ /** @type {CID<Data, API.DAG_PB, API.SHA_256, 0>} */
712
+ _CID.createV0(
713
+ /** @type {API.MultihashDigest<API.SHA_256>} */
714
+ multihash
715
+ )
716
+ );
717
+ }
718
+ default: {
719
+ throw Error(
720
+ `Can not convert CID version ${this.version} to version 0. This is a bug please report`
721
+ );
722
+ }
723
+ }
724
+ }
725
+ /**
726
+ * @returns {CID<Data, Format, Alg, 1>}
727
+ */
728
+ toV1() {
729
+ switch (this.version) {
730
+ case 0: {
731
+ const { code, digest } = this.multihash;
732
+ const multihash = create(code, digest);
733
+ return (
734
+ /** @type {CID<Data, Format, Alg, 1>} */
735
+ _CID.createV1(this.code, multihash)
736
+ );
737
+ }
738
+ case 1: {
739
+ return (
740
+ /** @type {CID<Data, Format, Alg, 1>} */
741
+ this
742
+ );
743
+ }
744
+ default: {
745
+ throw Error(
746
+ `Can not convert CID version ${this.version} to version 1. This is a bug please report`
747
+ );
748
+ }
749
+ }
750
+ }
751
+ /**
752
+ * @param {unknown} other
753
+ * @returns {other is CID<Data, Format, Alg, Version>}
754
+ */
755
+ equals(other) {
756
+ return _CID.equals(this, other);
757
+ }
758
+ /**
759
+ * @template {unknown} Data
760
+ * @template {number} Format
761
+ * @template {number} Alg
762
+ * @template {API.Version} Version
763
+ * @param {API.Link<Data, Format, Alg, Version>} self
764
+ * @param {unknown} other
765
+ * @returns {other is CID}
766
+ */
767
+ static equals(self2, other) {
768
+ const unknown = (
769
+ /** @type {{code?:unknown, version?:unknown, multihash?:unknown}} */
770
+ other
771
+ );
772
+ return unknown && self2.code === unknown.code && self2.version === unknown.version && equals2(self2.multihash, unknown.multihash);
773
+ }
774
+ /**
775
+ * @param {API.MultibaseEncoder<string>} [base]
776
+ * @returns {string}
777
+ */
778
+ toString(base2) {
779
+ return format(this, base2);
780
+ }
781
+ /**
782
+ * @returns {API.LinkJSON<this>}
783
+ */
784
+ toJSON() {
785
+ return { "/": format(this) };
786
+ }
787
+ link() {
788
+ return this;
789
+ }
790
+ get [Symbol.toStringTag]() {
791
+ return "CID";
792
+ }
793
+ // Legacy
794
+ [Symbol.for("nodejs.util.inspect.custom")]() {
795
+ return `CID(${this.toString()})`;
796
+ }
797
+ /**
798
+ * Takes any input `value` and returns a `CID` instance if it was
799
+ * a `CID` otherwise returns `null`. If `value` is instanceof `CID`
800
+ * it will return value back. If `value` is not instance of this CID
801
+ * class, but is compatible CID it will return new instance of this
802
+ * `CID` class. Otherwise returns null.
803
+ *
804
+ * This allows two different incompatible versions of CID library to
805
+ * co-exist and interop as long as binary interface is compatible.
806
+ *
807
+ * @template {unknown} Data
808
+ * @template {number} Format
809
+ * @template {number} Alg
810
+ * @template {API.Version} Version
811
+ * @template {unknown} U
812
+ * @param {API.Link<Data, Format, Alg, Version>|U} input
813
+ * @returns {CID<Data, Format, Alg, Version>|null}
814
+ */
815
+ static asCID(input) {
816
+ if (input == null) {
817
+ return null;
818
+ }
819
+ const value = (
820
+ /** @type {any} */
821
+ input
822
+ );
823
+ if (value instanceof _CID) {
824
+ return value;
825
+ } else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
826
+ const { version, code, multihash, bytes } = value;
827
+ return new _CID(
828
+ version,
829
+ code,
830
+ /** @type {API.MultihashDigest<Alg>} */
831
+ multihash,
832
+ bytes || encodeCID(version, code, multihash.bytes)
833
+ );
834
+ } else if (value[cidSymbol] === true) {
835
+ const { version, multihash, code } = value;
836
+ const digest = (
837
+ /** @type {API.MultihashDigest<Alg>} */
838
+ decode4(multihash)
839
+ );
840
+ return _CID.create(version, code, digest);
841
+ } else {
842
+ return null;
843
+ }
844
+ }
845
+ /**
846
+ *
847
+ * @template {unknown} Data
848
+ * @template {number} Format
849
+ * @template {number} Alg
850
+ * @template {API.Version} Version
851
+ * @param {Version} version - Version of the CID
852
+ * @param {Format} code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
853
+ * @param {API.MultihashDigest<Alg>} digest - (Multi)hash of the of the content.
854
+ * @returns {CID<Data, Format, Alg, Version>}
855
+ */
856
+ static create(version, code, digest) {
857
+ if (typeof code !== "number") {
858
+ throw new Error("String codecs are no longer supported");
859
+ }
860
+ if (!(digest.bytes instanceof Uint8Array)) {
861
+ throw new Error("Invalid digest");
862
+ }
863
+ switch (version) {
864
+ case 0: {
865
+ if (code !== DAG_PB_CODE) {
866
+ throw new Error(
867
+ `Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`
868
+ );
869
+ } else {
870
+ return new _CID(version, code, digest, digest.bytes);
871
+ }
872
+ }
873
+ case 1: {
874
+ const bytes = encodeCID(version, code, digest.bytes);
875
+ return new _CID(version, code, digest, bytes);
876
+ }
877
+ default: {
878
+ throw new Error("Invalid version");
879
+ }
880
+ }
881
+ }
882
+ /**
883
+ * Simplified version of `create` for CIDv0.
884
+ *
885
+ * @template {unknown} [T=unknown]
886
+ * @param {API.MultihashDigest<typeof SHA_256_CODE>} digest - Multihash.
887
+ * @returns {CID<T, typeof DAG_PB_CODE, typeof SHA_256_CODE, 0>}
888
+ */
889
+ static createV0(digest) {
890
+ return _CID.create(0, DAG_PB_CODE, digest);
891
+ }
892
+ /**
893
+ * Simplified version of `create` for CIDv1.
894
+ *
895
+ * @template {unknown} Data
896
+ * @template {number} Code
897
+ * @template {number} Alg
898
+ * @param {Code} code - Content encoding format code.
899
+ * @param {API.MultihashDigest<Alg>} digest - Miltihash of the content.
900
+ * @returns {CID<Data, Code, Alg, 1>}
901
+ */
902
+ static createV1(code, digest) {
903
+ return _CID.create(1, code, digest);
904
+ }
905
+ /**
906
+ * Decoded a CID from its binary representation. The byte array must contain
907
+ * only the CID with no additional bytes.
908
+ *
909
+ * An error will be thrown if the bytes provided do not contain a valid
910
+ * binary representation of a CID.
911
+ *
912
+ * @template {unknown} Data
913
+ * @template {number} Code
914
+ * @template {number} Alg
915
+ * @template {API.Version} Ver
916
+ * @param {API.ByteView<API.Link<Data, Code, Alg, Ver>>} bytes
917
+ * @returns {CID<Data, Code, Alg, Ver>}
918
+ */
919
+ static decode(bytes) {
920
+ const [cid, remainder] = _CID.decodeFirst(bytes);
921
+ if (remainder.length) {
922
+ throw new Error("Incorrect length");
923
+ }
924
+ return cid;
925
+ }
926
+ /**
927
+ * Decoded a CID from its binary representation at the beginning of a byte
928
+ * array.
929
+ *
930
+ * Returns an array with the first element containing the CID and the second
931
+ * element containing the remainder of the original byte array. The remainder
932
+ * will be a zero-length byte array if the provided bytes only contained a
933
+ * binary CID representation.
934
+ *
935
+ * @template {unknown} T
936
+ * @template {number} C
937
+ * @template {number} A
938
+ * @template {API.Version} V
939
+ * @param {API.ByteView<API.Link<T, C, A, V>>} bytes
940
+ * @returns {[CID<T, C, A, V>, Uint8Array]}
941
+ */
942
+ static decodeFirst(bytes) {
943
+ const specs = _CID.inspectBytes(bytes);
944
+ const prefixSize = specs.size - specs.multihashSize;
945
+ const multihashBytes = coerce(
946
+ bytes.subarray(prefixSize, prefixSize + specs.multihashSize)
947
+ );
948
+ if (multihashBytes.byteLength !== specs.multihashSize) {
949
+ throw new Error("Incorrect length");
950
+ }
951
+ const digestBytes = multihashBytes.subarray(
952
+ specs.multihashSize - specs.digestSize
953
+ );
954
+ const digest = new Digest(
955
+ specs.multihashCode,
956
+ specs.digestSize,
957
+ digestBytes,
958
+ multihashBytes
959
+ );
960
+ const cid = specs.version === 0 ? _CID.createV0(
961
+ /** @type {API.MultihashDigest<API.SHA_256>} */
962
+ digest
963
+ ) : _CID.createV1(specs.codec, digest);
964
+ return [
965
+ /** @type {CID<T, C, A, V>} */
966
+ cid,
967
+ bytes.subarray(specs.size)
968
+ ];
969
+ }
970
+ /**
971
+ * Inspect the initial bytes of a CID to determine its properties.
972
+ *
973
+ * Involves decoding up to 4 varints. Typically this will require only 4 to 6
974
+ * bytes but for larger multicodec code values and larger multihash digest
975
+ * lengths these varints can be quite large. It is recommended that at least
976
+ * 10 bytes be made available in the `initialBytes` argument for a complete
977
+ * inspection.
978
+ *
979
+ * @template {unknown} T
980
+ * @template {number} C
981
+ * @template {number} A
982
+ * @template {API.Version} V
983
+ * @param {API.ByteView<API.Link<T, C, A, V>>} initialBytes
984
+ * @returns {{ version:V, codec:C, multihashCode:A, digestSize:number, multihashSize:number, size:number }}
985
+ */
986
+ static inspectBytes(initialBytes) {
987
+ let offset = 0;
988
+ const next = () => {
989
+ const [i, length2] = decode3(initialBytes.subarray(offset));
990
+ offset += length2;
991
+ return i;
992
+ };
993
+ let version = (
994
+ /** @type {V} */
995
+ next()
996
+ );
997
+ let codec = (
998
+ /** @type {C} */
999
+ DAG_PB_CODE
1000
+ );
1001
+ if (
1002
+ /** @type {number} */
1003
+ version === 18
1004
+ ) {
1005
+ version = /** @type {V} */
1006
+ 0;
1007
+ offset = 0;
1008
+ } else {
1009
+ codec = /** @type {C} */
1010
+ next();
1011
+ }
1012
+ if (version !== 0 && version !== 1) {
1013
+ throw new RangeError(`Invalid CID version ${version}`);
1014
+ }
1015
+ const prefixSize = offset;
1016
+ const multihashCode = (
1017
+ /** @type {A} */
1018
+ next()
1019
+ );
1020
+ const digestSize = next();
1021
+ const size = offset + digestSize;
1022
+ const multihashSize = size - prefixSize;
1023
+ return { version, codec, multihashCode, digestSize, multihashSize, size };
1024
+ }
1025
+ /**
1026
+ * Takes cid in a string representation and creates an instance. If `base`
1027
+ * decoder is not provided will use a default from the configuration. It will
1028
+ * throw an error if encoding of the CID is not compatible with supplied (or
1029
+ * a default decoder).
1030
+ *
1031
+ * @template {string} Prefix
1032
+ * @template {unknown} Data
1033
+ * @template {number} Code
1034
+ * @template {number} Alg
1035
+ * @template {API.Version} Ver
1036
+ * @param {API.ToString<API.Link<Data, Code, Alg, Ver>, Prefix>} source
1037
+ * @param {API.MultibaseDecoder<Prefix>} [base]
1038
+ * @returns {CID<Data, Code, Alg, Ver>}
1039
+ */
1040
+ static parse(source, base2) {
1041
+ const [prefix, bytes] = parseCIDtoBytes(source, base2);
1042
+ const cid = _CID.decode(bytes);
1043
+ if (cid.version === 0 && source[0] !== "Q") {
1044
+ throw Error("Version 0 CID string must not include multibase prefix");
1045
+ }
1046
+ baseCache(cid).set(prefix, source);
1047
+ return cid;
1048
+ }
1049
+ };
1050
+ var parseCIDtoBytes = (source, base2) => {
1051
+ switch (source[0]) {
1052
+ case "Q": {
1053
+ const decoder = base2 || base58btc;
1054
+ return [
1055
+ /** @type {Prefix} */
1056
+ base58btc.prefix,
1057
+ decoder.decode(`${base58btc.prefix}${source}`)
1058
+ ];
1059
+ }
1060
+ case base58btc.prefix: {
1061
+ const decoder = base2 || base58btc;
1062
+ return [
1063
+ /** @type {Prefix} */
1064
+ base58btc.prefix,
1065
+ decoder.decode(source)
1066
+ ];
1067
+ }
1068
+ case base32.prefix: {
1069
+ const decoder = base2 || base32;
1070
+ return [
1071
+ /** @type {Prefix} */
1072
+ base32.prefix,
1073
+ decoder.decode(source)
1074
+ ];
1075
+ }
1076
+ default: {
1077
+ if (base2 == null) {
1078
+ throw Error(
1079
+ "To parse non base32 or base58btc encoded CID multibase decoder must be provided"
1080
+ );
1081
+ }
1082
+ return [
1083
+ /** @type {Prefix} */
1084
+ source[0],
1085
+ base2.decode(source)
1086
+ ];
1087
+ }
1088
+ }
1089
+ };
1090
+ var toStringV0 = (bytes, cache2, base2) => {
1091
+ const { prefix } = base2;
1092
+ if (prefix !== base58btc.prefix) {
1093
+ throw Error(`Cannot string encode V0 in ${base2.name} encoding`);
1094
+ }
1095
+ const cid = cache2.get(prefix);
1096
+ if (cid == null) {
1097
+ const cid2 = base2.encode(bytes).slice(1);
1098
+ cache2.set(prefix, cid2);
1099
+ return cid2;
1100
+ } else {
1101
+ return cid;
1102
+ }
1103
+ };
1104
+ var toStringV1 = (bytes, cache2, base2) => {
1105
+ const { prefix } = base2;
1106
+ const cid = cache2.get(prefix);
1107
+ if (cid == null) {
1108
+ const cid2 = base2.encode(bytes);
1109
+ cache2.set(prefix, cid2);
1110
+ return cid2;
1111
+ } else {
1112
+ return cid;
1113
+ }
1114
+ };
1115
+ var DAG_PB_CODE = 112;
1116
+ var SHA_256_CODE = 18;
1117
+ var encodeCID = (version, code, multihash) => {
1118
+ const codeOffset = encodingLength(version);
1119
+ const hashOffset = codeOffset + encodingLength(code);
1120
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
1121
+ encodeTo(version, bytes, 0);
1122
+ encodeTo(code, bytes, codeOffset);
1123
+ bytes.set(multihash, hashOffset);
1124
+ return bytes;
1125
+ };
1126
+ var cidSymbol = Symbol.for("@ipld/js-cid/CID");
1127
+
1128
+ // ../../../node_modules/.pnpm/besonders-logger@1.0.0-RC11_3myifxmc6j23mthq5k5h6wvx4a/node_modules/besonders-logger/dist/src/index.mjs
1129
+ var __create2 = Object.create;
1130
+ var __defProp2 = Object.defineProperty;
1131
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
1132
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
1133
+ var __getProtoOf2 = Object.getPrototypeOf;
1134
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
1135
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1136
+ var __commonJS2 = (cb, mod) => function __require2() {
1137
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
1138
+ };
1139
+ var __copyProps2 = (to, from2, except, desc) => {
1140
+ if (from2 && typeof from2 === "object" || typeof from2 === "function") {
1141
+ for (let key of __getOwnPropNames2(from2))
1142
+ if (!__hasOwnProp2.call(to, key) && key !== except)
1143
+ __defProp2(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc2(from2, key)) || desc.enumerable });
1144
+ }
1145
+ return to;
1146
+ };
1147
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
1148
+ // If the importer is in node compatibility mode or this is not an ESM
1149
+ // file that has been converted to a CommonJS file using a Babel-
1150
+ // compatible transform (i.e. "__esModule" has not been set), then set
1151
+ // "default" to the CommonJS "module.exports" for node compatibility.
1152
+ isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
1153
+ mod
1154
+ ));
1155
+ var __publicField2 = (obj, key, value) => {
1156
+ __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
1157
+ return value;
1158
+ };
1159
+ var require_lib = __commonJS2({
1160
+ "../../node_modules/.pnpm/browser-or-node@2.1.1/node_modules/browser-or-node/lib/index.js"(exports) {
1161
+ "use strict";
1162
+ Object.defineProperty(exports, "__esModule", {
1163
+ value: true
1164
+ });
1165
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function(obj) {
1166
+ return typeof obj;
1167
+ } : function(obj) {
1168
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
1169
+ };
1170
+ var isBrowser2 = typeof window !== "undefined" && typeof window.document !== "undefined";
1171
+ var isNode2 = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
1172
+ var isWebWorker = (typeof self === "undefined" ? "undefined" : _typeof(self)) === "object" && self.constructor && self.constructor.name === "DedicatedWorkerGlobalScope";
1173
+ var isJsDom = typeof window !== "undefined" && window.name === "nodejs" || typeof navigator !== "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
1174
+ var isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
1175
+ exports.isBrowser = isBrowser2;
1176
+ exports.isWebWorker = isWebWorker;
1177
+ exports.isNode = isNode2;
1178
+ exports.isJsDom = isJsDom;
1179
+ exports.isDeno = isDeno;
1180
+ }
1181
+ });
1182
+ var require_fast_json_stable_stringify = __commonJS2({
1183
+ "../../node_modules/.pnpm/fast-json-stable-stringify@2.1.0/node_modules/fast-json-stable-stringify/index.js"(exports, module) {
1184
+ "use strict";
1185
+ module.exports = function(data, opts) {
1186
+ if (!opts)
1187
+ opts = {};
1188
+ if (typeof opts === "function")
1189
+ opts = { cmp: opts };
1190
+ var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
1191
+ var cmp = opts.cmp && /* @__PURE__ */ function(f) {
1192
+ return function(node) {
1193
+ return function(a, b) {
1194
+ var aobj = { key: a, value: node[a] };
1195
+ var bobj = { key: b, value: node[b] };
1196
+ return f(aobj, bobj);
1197
+ };
1198
+ };
1199
+ }(opts.cmp);
1200
+ var seen = [];
1201
+ return function stringify2(node) {
1202
+ if (node && node.toJSON && typeof node.toJSON === "function") {
1203
+ node = node.toJSON();
1204
+ }
1205
+ if (node === void 0)
1206
+ return;
1207
+ if (typeof node == "number")
1208
+ return isFinite(node) ? "" + node : "null";
1209
+ if (typeof node !== "object")
1210
+ return JSON.stringify(node);
1211
+ var i, out;
1212
+ if (Array.isArray(node)) {
1213
+ out = "[";
1214
+ for (i = 0; i < node.length; i++) {
1215
+ if (i)
1216
+ out += ",";
1217
+ out += stringify2(node[i]) || "null";
1218
+ }
1219
+ return out + "]";
1220
+ }
1221
+ if (node === null)
1222
+ return "null";
1223
+ if (seen.indexOf(node) !== -1) {
1224
+ if (cycles)
1225
+ return JSON.stringify("__cycle__");
1226
+ throw new TypeError("Converting circular structure to JSON");
1227
+ }
1228
+ var seenIndex = seen.push(node) - 1;
1229
+ var keys = Object.keys(node).sort(cmp && cmp(node));
1230
+ out = "";
1231
+ for (i = 0; i < keys.length; i++) {
1232
+ var key = keys[i];
1233
+ var value = stringify2(node[key]);
1234
+ if (!value)
1235
+ continue;
1236
+ if (out)
1237
+ out += ",";
1238
+ out += JSON.stringify(key) + ":" + value;
1239
+ }
1240
+ seen.splice(seenIndex, 1);
1241
+ return "{" + out + "}";
1242
+ }(data);
1243
+ };
1244
+ }
1245
+ });
1246
+ var import_browser_or_node = __toESM2(require_lib(), 1);
1247
+ var import_fast_json_stable_stringify = __toESM2(require_fast_json_stable_stringify(), 1);
1248
+ var TIME_PREFIX_ENABLED = false;
1249
+ var PERFORMANCE_PREFIX_ENABLED = false;
1250
+ if (import_browser_or_node.isNode) {
1251
+ if (process?.env?.LOGGER_TIME_PREFIX)
1252
+ TIME_PREFIX_ENABLED = process?.env?.LOGGER_TIME_PREFIX === "true";
1253
+ if (process?.env?.LOGGER_PERF_PREFIX)
1254
+ PERFORMANCE_PREFIX_ENABLED = process?.env?.LOGGER_PERF_PREFIX === "true";
1255
+ }
1256
+ var DEFAULT_CONFIG = Object.freeze({
1257
+ prefix: void 0,
1258
+ time: TIME_PREFIX_ENABLED,
1259
+ delta: PERFORMANCE_PREFIX_ENABLED,
1260
+ dimDebugOnServer: true,
1261
+ printOriginOnServer: true,
1262
+ serverInspectOptions: {},
1263
+ customFormattersOnServer: true,
1264
+ // Depth of stacktrace to show on server
1265
+ // - integer saying how many lines
1266
+ // - false to disable, true for all
1267
+ printStackLinesOnServer: false,
1268
+ dim: true
1269
+ });
1270
+ var StringFormatters = [
1271
+ // Format to string (Client console - currently not on server)
1272
+ // {
1273
+ // match: obj => obj instanceof Model,
1274
+ // format: m => {
1275
+ // const { displayName } = m
1276
+ // return `${m.constructor.name}#${m.ID}${displayName ? `{${displayName}}` : ''}`
1277
+ // },
1278
+ // },
1279
+ ];
1280
+ var LoggerTime = class {
1281
+ constructor(sinceFirst, sinceLast, time, delta) {
1282
+ __publicField(this, "sinceFirst", 0);
1283
+ __publicField(this, "sinceLast", 0);
1284
+ __publicField(this, "time", false);
1285
+ __publicField(this, "delta", false);
1286
+ Object.assign(this, { sinceFirst, sinceLast, time, delta });
1287
+ }
1288
+ toString() {
1289
+ const sinceFirstNum = this.sinceFirst * 1e-3;
1290
+ const sinceFirst = sinceFirstNum.toFixed(sinceFirstNum < 5 ? 2 : 1);
1291
+ const sinceLast = this.sinceLast < 1e3 ? `${this.sinceLast.toFixed(0)}`.padStart(5, " ") : `${`${(this.sinceLast * 1e-3).toFixed(this.sinceLast < 1e4 ? 1 : 0)}`.padStart(4, " ")}s`;
1292
+ return `[${[this.time ? sinceFirst : null, this.delta ? sinceLast : null].join(",")}]`;
1293
+ }
1294
+ };
1295
+ var Style = class {
1296
+ constructor(style, string) {
1297
+ Object.assign(this, { style, string });
1298
+ }
1299
+ };
1300
+ var formattersEnabled = false;
1301
+ var _Logger = class {
1302
+ /**
1303
+ * This is a clever way to log without the extra check on each log line.
1304
+ * Use it like this:
1305
+ * ```
1306
+ * const { WARN, LOG, DEBUG, VERBOSE } = Logger.setup(Logger.INFO); // eslint-disable-line no-unused-vars
1307
+ * LOG('message', data);
1308
+ * DEBUG(this.collectionName, '...')
1309
+ * if (!VERBOSE.isDisabled) {
1310
+ * const verboseStuff = generateVerboseStuff(); // computationally intensive
1311
+ * VERBOSE('Here it is:', verboseStuff)
1312
+ * }
1313
+ * ```
1314
+ *
1315
+ * @ param {number} level See {@link LVs}
1316
+ * @ param {object} config see DEFAULT_CONFIG
1317
+ * @ typedef {Function & {isDisabled: boolean, isEnabled: boolean, ...}} LogFunc
1318
+ * @ returns {{LOG: LogFunc, VERBOSE: LogFunc, DEBUG: LogFunc, WARN: LogFunc, ERROR: LogFunc}}
1319
+ */
1320
+ static setup(level = _Logger.INFO, config = {}) {
1321
+ config = Object.assign({}, DEFAULT_CONFIG, config);
1322
+ if (level > 10)
1323
+ console.debug("setup logger", { config });
1324
+ const debugLogForStub = this.wrapLog(console.debug, { ...config, dim: config.dimDebugOnServer });
1325
+ const stub = (...args) => {
1326
+ if (window?.FORCE_DISABLE_LOGLEVEL)
1327
+ debugLogForStub(...args);
1328
+ };
1329
+ stub.isDisabled = true;
1330
+ stub.isEnabled = false;
1331
+ const groupCollapsed = this.wrapLog(console.groupCollapsed, config);
1332
+ const addExtraFxs = (enabled, func) => {
1333
+ function group(...args) {
1334
+ const functionToWrap = args[args.length - 1];
1335
+ if (functionToWrap === stub)
1336
+ return functionToWrap();
1337
+ groupCollapsed(...args.slice(0, -1));
1338
+ const asyncWrapper = async () => {
1339
+ try {
1340
+ const result = functionToWrap();
1341
+ return result instanceof Promise ? await result : result;
1342
+ } finally {
1343
+ console.groupEnd();
1344
+ }
1345
+ };
1346
+ return asyncWrapper();
1347
+ }
1348
+ const realFunc = Object.assign(
1349
+ func.bind({}),
1350
+ // clone function - https://stackoverflow.com/a/6772648
1351
+ {
1352
+ isEnabled: enabled,
1353
+ isDisabled: !enabled,
1354
+ group,
1355
+ force: func
1356
+ }
1357
+ );
1358
+ if (enabled) {
1359
+ return realFunc;
1360
+ } else {
1361
+ return Object.assign(
1362
+ stub.bind({}),
1363
+ // clone stub function - https://stackoverflow.com/a/6772648
1364
+ {
1365
+ isEnabled: enabled,
1366
+ isDisabled: !enabled,
1367
+ group,
1368
+ force: realFunc
1369
+ }
1370
+ );
1371
+ }
1372
+ };
1373
+ const ERRFX = addExtraFxs(level >= _Logger.ERROR, this.wrapLog(console.error, config));
1374
+ const ERROR = (...params) => {
1375
+ ERRFX(...params);
1376
+ return new Error((0, import_fast_json_stable_stringify.default)(params));
1377
+ };
1378
+ return {
1379
+ ERROR,
1380
+ WARN: addExtraFxs(level >= _Logger.WARN, this.wrapLog(console.warn, config)),
1381
+ LOG: addExtraFxs(level >= _Logger.INFO, this.wrapLog(console.log, config)),
1382
+ DEBUG: addExtraFxs(level >= _Logger.DEBUG, this.wrapLog(console.log, { ...config, dim: config.dimDebugOnServer })),
1383
+ // not using console.debug as that requires dev tools verbose to be enabled
1384
+ VERBOSE: addExtraFxs(level >= _Logger.VERBOSE, this.wrapLog(console.debug, { ...config, dim: config.dimDebugOnServer }))
1385
+ };
1386
+ }
1387
+ static wrapLog(logFunc, config) {
1388
+ if (!import_browser_or_node.isNode) {
1389
+ const fixedArgs = [];
1390
+ if (config.time || config.delta) {
1391
+ const isChrome = import_browser_or_node.isBrowser && navigator.userAgent.includes("Chrome");
1392
+ const p = isChrome ? ["", _Logger.timeStr(!!config.time, !!config.delta)] : [];
1393
+ fixedArgs.push(...p);
1394
+ }
1395
+ if (config.prefix) {
1396
+ if (formattersEnabled)
1397
+ fixedArgs.push(new Style("dim", config.prefix));
1398
+ else
1399
+ fixedArgs.push(config.prefix);
1400
+ }
1401
+ return logFunc.bind(console, ...fixedArgs);
1402
+ } else {
1403
+ return logFunc.bind(console);
1404
+ }
1405
+ }
1406
+ // static log(msg, logPerformance = true) {
1407
+ // const p = this.perf();
1408
+ // return logPerformance ? `${p} ${msg}` : msg;
1409
+ // }
1410
+ static timeStr(time, delta, returnAsString = 0) {
1411
+ if (!performance.now)
1412
+ return void 0;
1413
+ const now = performance.now();
1414
+ if (!_Logger.firstLog) {
1415
+ _Logger.firstLog = now;
1416
+ _Logger.lastLog = now;
1417
+ }
1418
+ const p = new LoggerTime(now - _Logger.firstLog, now - _Logger.lastLog, time, delta);
1419
+ _Logger.lastLog = now;
1420
+ return returnAsString ? p.toString() : p;
1421
+ }
1422
+ // (for nodejs) ~ https://stackoverflow.com/a/47296370/1633985
1423
+ static getOriginFromStack(stack) {
1424
+ let skippedFirst = false;
1425
+ for (const line of stack.split("\n")) {
1426
+ const matches = line.match(/^\s+at\s+(.*)/);
1427
+ if (matches) {
1428
+ if (skippedFirst) {
1429
+ return matches[1].trim().replace(__dirname, "");
1430
+ }
1431
+ skippedFirst = true;
1432
+ }
1433
+ }
1434
+ }
1435
+ };
1436
+ var Logger = _Logger;
1437
+ __publicField2(Logger, "ERROR", 2);
1438
+ __publicField2(Logger, "WARN", 4);
1439
+ __publicField2(Logger, "INFO", 6);
1440
+ __publicField2(Logger, "LOG", 6);
1441
+ __publicField2(Logger, "DEBUG", 8);
1442
+ __publicField2(Logger, "VERBOSE", 10);
1443
+ __publicField2(Logger, "firstLog", 0);
1444
+ __publicField2(Logger, "lastLog", 0);
1445
+ if (import_browser_or_node.isBrowser) {
1446
+ window.devtoolsFormatters = window.devtoolsFormatters ?? [];
1447
+ window.devtoolsFormatters.push(
1448
+ {
1449
+ // Custom formatters
1450
+ header: (obj) => {
1451
+ if (StringFormatters && StringFormatters.length) {
1452
+ for (const formatter of StringFormatters) {
1453
+ if (formatter.match(obj))
1454
+ return ["span", {}, formatter.format(obj)];
1455
+ }
1456
+ }
1457
+ return null;
1458
+ },
1459
+ hasBody: () => true
1460
+ },
1461
+ {
1462
+ // Performance object //
1463
+ // This is a sneaky way to show performance info withouth any extra calls when logging:
1464
+ // LOG(`...`)
1465
+ // it would work without this if we would have some way to intercept the call:
1466
+ // L.INFO('...') - a getter on L that adds the current time as prefix
1467
+ // LOG('...')() - returns the log function with all argumends bound
1468
+ // But instead we are adding a custom formatter that replaced the placeholder object of class P with the performance info
1469
+ header: (obj) => {
1470
+ if (!(obj instanceof LoggerTime))
1471
+ return null;
1472
+ if (!formattersEnabled)
1473
+ formattersEnabled = true;
1474
+ const p = Logger.timeStr(obj.time, obj.delta);
1475
+ return [
1476
+ "span",
1477
+ { style: "font-weight: light; color: grey" },
1478
+ p?.toString()
1479
+ // ['a', { href: 'vscodium://file/home/manu/dev/tamera/bookr/imports/lib/utils/Logger.js' }, 'WOW'],
1480
+ ];
1481
+ },
1482
+ hasBody: () => false
1483
+ },
1484
+ {
1485
+ // Style object
1486
+ header: (obj) => {
1487
+ if (!(obj instanceof Style))
1488
+ return null;
1489
+ if (!formattersEnabled)
1490
+ formattersEnabled = true;
1491
+ return ["span", {
1492
+ style: "font-weight: light; color: grey; "
1493
+ /* font-style: italic; */
1494
+ }, obj.string];
1495
+ },
1496
+ hasBody: () => false
1497
+ }
1498
+ );
1499
+ } else if (import_browser_or_node.isNode) {
1500
+ }
1501
+
1502
+ export {
1503
+ __require,
1504
+ __commonJS,
1505
+ __export,
1506
+ __toESM,
1507
+ coerce,
1508
+ fromString,
1509
+ toString,
1510
+ from,
1511
+ baseX,
1512
+ rfc4648,
1513
+ base32_exports,
1514
+ base58_exports,
1515
+ create,
1516
+ decode4 as decode,
1517
+ CID,
1518
+ Logger
1519
+ };
1520
+ //# sourceMappingURL=chunk-R6GDUZUI.js.map