@cardanowall/poe-standard 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1967 @@
1
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/constants.js
2
+ var f = { POS_INT: 0, NEG_INT: 1, BYTE_STRING: 2, UTF8_STRING: 3, ARRAY: 4, MAP: 5, TAG: 6, SIMPLE_FLOAT: 7 };
3
+ var T = { DATE_STRING: 0, DATE_EPOCH: 1, POS_BIGINT: 2, NEG_BIGINT: 3, CBOR: 24, URI: 32, BASE64URL: 33, BASE64: 34, DATE_EPOCH_DAYS: 100, SET: 258, JSON: 262, WTF8: 273, SYMBOL: 280, DATE_FULL: 1004, REGEXP: 21066, SELF_DESCRIBED: 55799, INVALID_16: 65535, INVALID_32: 4294967295, INVALID_64: 0xffffffffffffffffn };
4
+ var I = { ZERO: 0, ONE: 24, TWO: 25, FOUR: 26, EIGHT: 27, INDEFINITE: 31 };
5
+ var o = { FALSE: 20, TRUE: 21, NULL: 22, UNDEFINED: 23 };
6
+ var A = class {
7
+ static BREAK = /* @__PURE__ */ Symbol.for("github.com/hildjj/cbor2/break");
8
+ static ENCODED = /* @__PURE__ */ Symbol.for("github.com/hildjj/cbor2/cbor-encoded");
9
+ static LENGTH = /* @__PURE__ */ Symbol.for("github.com/hildjj/cbor2/length");
10
+ };
11
+ var S = { MIN: -(2n ** 63n), MAX: 2n ** 64n - 1n };
12
+
13
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/tag.js
14
+ var o2 = class _o {
15
+ static #e = /* @__PURE__ */ new Map();
16
+ tag;
17
+ contents;
18
+ constructor(e2, t3 = void 0) {
19
+ this.tag = e2, this.contents = t3;
20
+ }
21
+ get noChildren() {
22
+ return !!_o.#e.get(this.tag)?.noChildren;
23
+ }
24
+ static registerDecoder(e2, t3, n2) {
25
+ const i = this.#e.get(e2);
26
+ return this.#e.set(e2, t3), i && ("comment" in t3 || (t3.comment = i.comment), "noChildren" in t3 || (t3.noChildren = i.noChildren)), n2 && !t3.comment && (t3.comment = () => `(${n2})`), i;
27
+ }
28
+ static clearDecoder(e2) {
29
+ const t3 = this.#e.get(e2);
30
+ return this.#e.delete(e2), t3;
31
+ }
32
+ static getDecoder(e2) {
33
+ return this.#e.get(e2);
34
+ }
35
+ static getAllDecoders() {
36
+ return new Map(this.#e);
37
+ }
38
+ *[Symbol.iterator]() {
39
+ yield this.contents;
40
+ }
41
+ push(e2) {
42
+ return this.contents = e2, 1;
43
+ }
44
+ decode(e2) {
45
+ const t3 = e2?.tags?.get(this.tag) ?? (e2?.ignoreGlobalTags ? void 0 : _o.#e.get(this.tag));
46
+ return t3 ? t3(this, e2) : this;
47
+ }
48
+ comment(e2, t3) {
49
+ const n2 = e2?.tags?.get(this.tag) ?? (e2?.ignoreGlobalTags ? void 0 : _o.#e.get(this.tag));
50
+ if (n2?.comment) return n2.comment(this, e2, t3);
51
+ }
52
+ toCBOR() {
53
+ return [this.tag, this.contents];
54
+ }
55
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](e2, t3, n2) {
56
+ return `${this.tag}(${n2(this.contents, t3)})`;
57
+ }
58
+ };
59
+
60
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/box.js
61
+ function f2(n2) {
62
+ if (n2 != null && typeof n2 == "object") return n2[A.ENCODED];
63
+ }
64
+ function s(n2) {
65
+ if (n2 != null && typeof n2 == "object") return n2[A.LENGTH];
66
+ }
67
+ function u(n2, e2) {
68
+ Object.defineProperty(n2, A.ENCODED, { configurable: true, enumerable: false, value: e2 });
69
+ }
70
+ function d(n2, e2) {
71
+ const r2 = Object(n2);
72
+ return u(r2, e2), r2;
73
+ }
74
+
75
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/utils.js
76
+ var g = /* @__PURE__ */ Symbol("CBOR_RANGES");
77
+ function c(r2, n2) {
78
+ Object.defineProperty(r2, g, { configurable: false, enumerable: false, writable: false, value: n2 });
79
+ }
80
+ function f3(r2) {
81
+ return r2[g];
82
+ }
83
+ function l(r2) {
84
+ return f3(r2) !== void 0;
85
+ }
86
+ function R(r2, n2 = 0, t3 = r2.length - 1) {
87
+ const o5 = r2.subarray(n2, t3), a4 = f3(r2);
88
+ if (a4) {
89
+ const s3 = [];
90
+ for (const e2 of a4) if (e2[0] >= n2 && e2[0] + e2[1] <= t3) {
91
+ const i = [...e2];
92
+ i[0] -= n2, s3.push(i);
93
+ }
94
+ s3.length && c(o5, s3);
95
+ }
96
+ return o5;
97
+ }
98
+ function b(r2) {
99
+ let n2 = Math.ceil(r2.length / 2);
100
+ const t3 = new Uint8Array(n2);
101
+ n2--;
102
+ for (let o5 = r2.length, a4 = o5 - 2; o5 >= 0; o5 = a4, a4 -= 2, n2--) t3[n2] = parseInt(r2.substring(a4, o5), 16);
103
+ return t3;
104
+ }
105
+ function A2(r2) {
106
+ return r2.reduce((n2, t3) => n2 + t3.toString(16).padStart(2, "0"), "");
107
+ }
108
+ function d2(r2) {
109
+ const n2 = r2.reduce((e2, i) => e2 + i.length, 0), t3 = r2.some((e2) => l(e2)), o5 = [], a4 = new Uint8Array(n2);
110
+ let s3 = 0;
111
+ for (const e2 of r2) {
112
+ if (!(e2 instanceof Uint8Array)) throw new TypeError(`Invalid array: ${e2}`);
113
+ if (a4.set(e2, s3), t3) {
114
+ const i = e2[g] ?? [[0, e2.length]];
115
+ for (const u3 of i) u3[0] += s3;
116
+ o5.push(...i);
117
+ }
118
+ s3 += e2.length;
119
+ }
120
+ return t3 && c(a4, o5), a4;
121
+ }
122
+ function y(r2) {
123
+ const n2 = atob(r2);
124
+ return Uint8Array.from(n2, (t3) => t3.codePointAt(0));
125
+ }
126
+ var p = { "-": "+", _: "/" };
127
+ function x(r2) {
128
+ const n2 = r2.replace(/[_-]/g, (t3) => p[t3]);
129
+ return y(n2.padEnd(Math.ceil(n2.length / 4) * 4, "="));
130
+ }
131
+ function h() {
132
+ const r2 = new Uint8Array(4), n2 = new Uint32Array(r2.buffer);
133
+ return !((n2[0] = 1) & r2[0]);
134
+ }
135
+ function U(r2) {
136
+ let n2 = "";
137
+ for (const t3 of r2) {
138
+ const o5 = t3.codePointAt(0)?.toString(16).padStart(4, "0");
139
+ n2 && (n2 += ", "), n2 += `U+${o5}`;
140
+ }
141
+ return n2;
142
+ }
143
+
144
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/typeEncoderMap.js
145
+ var s2 = class {
146
+ #e = /* @__PURE__ */ new Map();
147
+ registerEncoder(e2, t3) {
148
+ const n2 = this.#e.get(e2);
149
+ return this.#e.set(e2, t3), n2;
150
+ }
151
+ get(e2) {
152
+ return this.#e.get(e2);
153
+ }
154
+ delete(e2) {
155
+ return this.#e.delete(e2);
156
+ }
157
+ clear() {
158
+ this.#e.clear();
159
+ }
160
+ };
161
+
162
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/sorts.js
163
+ function f4(c5, d6) {
164
+ const [u3, a4, n2] = c5, [l6, s3, t3] = d6, r2 = Math.min(n2.length, t3.length);
165
+ for (let o5 = 0; o5 < r2; o5++) {
166
+ const e2 = n2[o5] - t3[o5];
167
+ if (e2 !== 0) return e2;
168
+ }
169
+ return 0;
170
+ }
171
+
172
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/writer.js
173
+ var e = class _e {
174
+ static defaultOptions = { chunkSize: 4096 };
175
+ #r;
176
+ #i = [];
177
+ #s = null;
178
+ #t = 0;
179
+ #a = 0;
180
+ constructor(t3 = {}) {
181
+ if (this.#r = { ..._e.defaultOptions, ...t3 }, this.#r.chunkSize < 8) throw new RangeError(`Expected size >= 8, got ${this.#r.chunkSize}`);
182
+ this.#n();
183
+ }
184
+ get length() {
185
+ return this.#a;
186
+ }
187
+ read() {
188
+ this.#o();
189
+ const t3 = new Uint8Array(this.#a);
190
+ let i = 0;
191
+ for (const s3 of this.#i) t3.set(s3, i), i += s3.length;
192
+ return this.#n(), t3;
193
+ }
194
+ write(t3) {
195
+ const i = t3.length;
196
+ i > this.#l() ? (this.#o(), i > this.#r.chunkSize ? (this.#i.push(t3), this.#n()) : (this.#n(), this.#i[this.#i.length - 1].set(t3), this.#t = i)) : (this.#i[this.#i.length - 1].set(t3, this.#t), this.#t += i), this.#a += i;
197
+ }
198
+ writeUint8(t3) {
199
+ this.#e(1), this.#s.setUint8(this.#t, t3), this.#h(1);
200
+ }
201
+ writeUint16(t3, i = false) {
202
+ this.#e(2), this.#s.setUint16(this.#t, t3, i), this.#h(2);
203
+ }
204
+ writeUint32(t3, i = false) {
205
+ this.#e(4), this.#s.setUint32(this.#t, t3, i), this.#h(4);
206
+ }
207
+ writeBigUint64(t3, i = false) {
208
+ this.#e(8), this.#s.setBigUint64(this.#t, t3, i), this.#h(8);
209
+ }
210
+ writeInt16(t3, i = false) {
211
+ this.#e(2), this.#s.setInt16(this.#t, t3, i), this.#h(2);
212
+ }
213
+ writeInt32(t3, i = false) {
214
+ this.#e(4), this.#s.setInt32(this.#t, t3, i), this.#h(4);
215
+ }
216
+ writeBigInt64(t3, i = false) {
217
+ this.#e(8), this.#s.setBigInt64(this.#t, t3, i), this.#h(8);
218
+ }
219
+ writeFloat32(t3, i = false) {
220
+ this.#e(4), this.#s.setFloat32(this.#t, t3, i), this.#h(4);
221
+ }
222
+ writeFloat64(t3, i = false) {
223
+ this.#e(8), this.#s.setFloat64(this.#t, t3, i), this.#h(8);
224
+ }
225
+ clear() {
226
+ this.#a = 0, this.#i = [], this.#n();
227
+ }
228
+ #n() {
229
+ const t3 = new Uint8Array(this.#r.chunkSize);
230
+ this.#i.push(t3), this.#t = 0, this.#s = new DataView(t3.buffer, t3.byteOffset, t3.byteLength);
231
+ }
232
+ #o() {
233
+ if (this.#t === 0) {
234
+ this.#i.pop();
235
+ return;
236
+ }
237
+ const t3 = this.#i.length - 1;
238
+ this.#i[t3] = this.#i[t3].subarray(0, this.#t), this.#t = 0, this.#s = null;
239
+ }
240
+ #l() {
241
+ const t3 = this.#i.length - 1;
242
+ return this.#i[t3].length - this.#t;
243
+ }
244
+ #e(t3) {
245
+ this.#l() < t3 && (this.#o(), this.#n());
246
+ }
247
+ #h(t3) {
248
+ this.#t += t3, this.#a += t3;
249
+ }
250
+ };
251
+
252
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/float.js
253
+ var w = 1n << 15n;
254
+ var f5 = 0b11111n << 10n;
255
+ var b2 = 1n << 9n;
256
+ var d3 = b2 - 1n;
257
+ var I2 = b2 | d3;
258
+ var g2 = 1n << 31n;
259
+ var l2 = 0b11111111n << 23n;
260
+ var A3 = 1n << 22n;
261
+ var E = A3 - 1n;
262
+ var p2 = A3 | E;
263
+ var N = 1n << 63n;
264
+ var a = 0b11111111111n << 52n;
265
+ var c2 = 1n << 51n;
266
+ var u2 = c2 - 1n;
267
+ var F = c2 | u2;
268
+ var _ = u2 - (d3 << 42n);
269
+ var S2 = u2 - (E << 29n);
270
+ var m = { 2: "0b", 8: "0o", 16: "0x" };
271
+ var x2 = ((t3) => (t3[t3.NATURAL = -2] = "NATURAL", t3[t3.UNKNOWN = -1] = "UNKNOWN", t3[t3.F16 = 2] = "F16", t3[t3.F32 = 4] = "F32", t3[t3.F64 = 8] = "F64", t3))(x2 || {});
272
+ function U2(i, n2, e2, r2) {
273
+ let o5 = "nan'";
274
+ return i.quiet || (o5 += "!"), i.sign === -1 && (o5 += "-"), o5 += r2(Math.abs(i.payload), e2), o5 += "'", o5 += i.encodingIndicator, o5;
275
+ }
276
+ var O = class extends Number {
277
+ #n;
278
+ #t = -1;
279
+ constructor(n2, e2 = true, r2 = -1) {
280
+ super(NaN);
281
+ const o5 = n2;
282
+ if (typeof n2 == "number") {
283
+ if (!Number.isSafeInteger(n2)) throw new Error(`Invalid NAN payload: ${n2}`);
284
+ n2 = BigInt(n2);
285
+ let t3 = 0n;
286
+ if (n2 < 0 && (t3 = N, n2 = -n2), n2 >= c2) throw new Error(`Payload too large: ${o5}`);
287
+ const s3 = e2 ? c2 : 0n;
288
+ switch (this.#n = t3 | a | s3 | n2, r2) {
289
+ case -2:
290
+ throw new Error("NAN_SIZE.NATURAL only valid for bigint constructor");
291
+ case -1:
292
+ r2 = this.preferredSize;
293
+ break;
294
+ case 2:
295
+ if (this.#n & _) throw new Error("Invalid size for payload");
296
+ break;
297
+ case 4:
298
+ if (this.#n & S2) throw new Error("Invalid size for payload");
299
+ break;
300
+ case 8:
301
+ break;
302
+ default:
303
+ throw new Error(`Invalid size: ${r2}`);
304
+ }
305
+ this.#t = r2;
306
+ } else if (typeof n2 == "bigint") {
307
+ let t3 = -1;
308
+ if ((n2 & a) === a) this.#n = n2, t3 = 8;
309
+ else if ((n2 & l2) === l2) {
310
+ const s3 = (n2 & g2) << 32n;
311
+ this.#n = s3 | a | (n2 & p2) << 29n, t3 = 4;
312
+ } else if ((n2 & f5) === f5) {
313
+ const s3 = (n2 & w) << 48n;
314
+ this.#n = s3 | a | (n2 & I2) << 42n, t3 = 2;
315
+ } else throw new Error(`Invalid raw NaN value: ${n2}`);
316
+ if (r2 === -1) this.#t = this.preferredSize;
317
+ else if (r2 === -2) this.#t = t3;
318
+ else {
319
+ if (r2 < t3) throw new Error("Invalid bigint NaN size");
320
+ this.#t = r2;
321
+ }
322
+ } else {
323
+ const t3 = new DataView(n2.buffer, n2.byteOffset, n2.byteLength);
324
+ switch (n2.length) {
325
+ case 3: {
326
+ if (n2[0] !== 249) throw new Error("Invalid CBOR encoding for half float");
327
+ const s3 = BigInt(t3.getUint16(1, false));
328
+ if ((s3 & f5) !== f5) throw new Error("Not a NaN");
329
+ const h4 = (s3 & w) << 48n;
330
+ this.#n = h4 | a | (s3 & I2) << 42n, this.#t = 2;
331
+ break;
332
+ }
333
+ case 5: {
334
+ if (n2[0] !== 250) throw new Error("Invalid CBOR encoding for single float");
335
+ const s3 = BigInt(t3.getUint32(1, false));
336
+ if ((s3 & l2) !== l2) throw new Error("Not a NaN");
337
+ const h4 = (s3 & g2) << 32n;
338
+ this.#n = h4 | a | (s3 & p2) << 29n, this.#t = 4;
339
+ break;
340
+ }
341
+ case 9: {
342
+ if (n2[0] !== 251) throw new Error("Invalid CBOR encoding for double float");
343
+ if (this.#n = t3.getBigUint64(1, false), (this.#n & a) !== a) throw new Error("Not a NaN (NaNaN)");
344
+ this.#t = 8;
345
+ break;
346
+ }
347
+ default:
348
+ throw new RangeError(`Invalid NAN size (should be 2, 4, or 8): ${n2.length - 1}`);
349
+ }
350
+ }
351
+ if (!this.payload && !this.quiet) throw new Error("Signalling NaN with zero payload");
352
+ }
353
+ get bytes() {
354
+ const n2 = new ArrayBuffer(this.#t + 1), e2 = new DataView(n2);
355
+ switch (this.#t) {
356
+ case 2: {
357
+ e2.setUint8(0, 249);
358
+ const o5 = (this.#n & N ? w : 0n) | f5 | (this.#n & F) >> 42n;
359
+ e2.setUint16(1, Number(o5), false);
360
+ break;
361
+ }
362
+ case 4: {
363
+ e2.setUint8(0, 250);
364
+ const o5 = (this.#n & N ? g2 : 0n) | l2 | (this.#n & F) >> 29n;
365
+ e2.setUint32(1, Number(o5), false);
366
+ break;
367
+ }
368
+ case 8:
369
+ e2.setUint8(0, 251), e2.setBigUint64(1, this.#n);
370
+ break;
371
+ }
372
+ return new Uint8Array(n2);
373
+ }
374
+ get quiet() {
375
+ return !!(this.#n & c2);
376
+ }
377
+ get sign() {
378
+ return this.#n & N ? -1 : 1;
379
+ }
380
+ get payload() {
381
+ return Number(this.#n & u2) * this.sign;
382
+ }
383
+ get raw() {
384
+ return this.#n;
385
+ }
386
+ get encodingIndicator() {
387
+ switch (this.#t) {
388
+ case 2:
389
+ return "_1";
390
+ case 4:
391
+ return "_2";
392
+ }
393
+ return "_3";
394
+ }
395
+ get size() {
396
+ return this.#t;
397
+ }
398
+ get preferredSize() {
399
+ return (this.#n & _) === 0n ? 2 : (this.#n & S2) === 0n ? 4 : 8;
400
+ }
401
+ get isShortestEncoding() {
402
+ return this.preferredSize === this.#t;
403
+ }
404
+ toCBOR(n2) {
405
+ n2.write(this.bytes);
406
+ }
407
+ toString(n2 = 10) {
408
+ return U2(this, 1, {}, (e2) => (m[n2] ?? "") + e2.toString(n2));
409
+ }
410
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](n2, e2, r2) {
411
+ return U2(this, n2, e2, r2);
412
+ }
413
+ };
414
+ function v(i, n2 = 0, e2 = false) {
415
+ const r2 = i[n2] & 128 ? -1 : 1, o5 = (i[n2] & 124) >> 2, t3 = (i[n2] & 3) << 8 | i[n2 + 1];
416
+ if (o5 === 0) {
417
+ if (e2 && t3 !== 0) throw new Error(`Unwanted subnormal: ${r2 * 5960464477539063e-23 * t3}`);
418
+ return r2 * 5960464477539063e-23 * t3;
419
+ } else if (o5 === 31) return t3 ? NaN : r2 * (1 / 0);
420
+ return r2 * 2 ** (o5 - 25) * (1024 + t3);
421
+ }
422
+ function Z(i) {
423
+ const n2 = new DataView(new ArrayBuffer(4));
424
+ n2.setFloat32(0, i, false);
425
+ const e2 = n2.getUint32(0, false);
426
+ if ((e2 & 8191) !== 0) return null;
427
+ let r2 = e2 >> 16 & 32768;
428
+ const o5 = e2 >> 23 & 255, t3 = e2 & 8388607;
429
+ if (!(o5 === 0 && t3 === 0)) if (o5 >= 113 && o5 <= 142) r2 += (o5 - 112 << 10) + (t3 >> 13);
430
+ else if (o5 >= 103 && o5 < 113) {
431
+ if (t3 & (1 << 126 - o5) - 1) return null;
432
+ r2 += t3 + 8388608 >> 126 - o5;
433
+ } else if (o5 === 255) r2 |= 31744, r2 |= t3 >> 13;
434
+ else return null;
435
+ return r2;
436
+ }
437
+ function k(i) {
438
+ if (i !== 0) {
439
+ const n2 = new ArrayBuffer(8), e2 = new DataView(n2);
440
+ e2.setFloat64(0, i, false);
441
+ const r2 = e2.getBigUint64(0, false);
442
+ if ((r2 & 0x7ff0000000000000n) === 0n) return r2 & 0x8000000000000000n ? -0 : 0;
443
+ }
444
+ return i;
445
+ }
446
+ function B(i) {
447
+ switch (i.length) {
448
+ case 2:
449
+ v(i, 0, true);
450
+ break;
451
+ case 4: {
452
+ const n2 = new DataView(i.buffer, i.byteOffset, i.byteLength), e2 = n2.getUint32(0, false);
453
+ if ((e2 & 2139095040) === 0 && e2 & 8388607) throw new Error(`Unwanted subnormal: ${n2.getFloat32(0, false)}`);
454
+ break;
455
+ }
456
+ case 8: {
457
+ const n2 = new DataView(i.buffer, i.byteOffset, i.byteLength), e2 = n2.getBigUint64(0, false);
458
+ if ((e2 & 0x7ff0000000000000n) === 0n && e2 & 0x000fffffffffffn) throw new Error(`Unwanted subnormal: ${n2.getFloat64(0, false)}`);
459
+ break;
460
+ }
461
+ default:
462
+ throw new TypeError(`Bad input to isSubnormal: ${i}`);
463
+ }
464
+ }
465
+
466
+ // ../../node_modules/.pnpm/@cto.af+wtf8@0.0.5/node_modules/@cto.af/wtf8/lib/errors.js
467
+ var DecodeError = class extends TypeError {
468
+ code = "ERR_ENCODING_INVALID_ENCODED_DATA";
469
+ constructor() {
470
+ super("The encoded data was not valid for encoding wtf-8");
471
+ }
472
+ };
473
+ var InvalidEncodingError = class extends RangeError {
474
+ code = "ERR_ENCODING_NOT_SUPPORTED";
475
+ constructor(label) {
476
+ super(`Invalid encoding: "${label}"`);
477
+ }
478
+ };
479
+
480
+ // ../../node_modules/.pnpm/@cto.af+wtf8@0.0.5/node_modules/@cto.af/wtf8/lib/const.js
481
+ var BOM = 65279;
482
+ var EMPTY = new Uint8Array(0);
483
+ var MIN_HIGH_SURROGATE = 55296;
484
+ var MIN_LOW_SURROGATE = 56320;
485
+ var REPLACEMENT = 65533;
486
+ var WTF8 = "wtf-8";
487
+
488
+ // ../../node_modules/.pnpm/@cto.af+wtf8@0.0.5/node_modules/@cto.af/wtf8/lib/decode.js
489
+ function isArrayBufferView(input) {
490
+ return input && typeof input === "object" && !(input instanceof ArrayBuffer) && !(input instanceof SharedArrayBuffer) && input.buffer instanceof ArrayBuffer;
491
+ }
492
+ function getUint8(input) {
493
+ if (!input) {
494
+ return EMPTY;
495
+ }
496
+ if (input instanceof Uint8Array) {
497
+ return input;
498
+ }
499
+ if (isArrayBufferView(input)) {
500
+ return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
501
+ }
502
+ return new Uint8Array(input);
503
+ }
504
+ var REMAINDER = [
505
+ 0,
506
+ 0,
507
+ 0,
508
+ 0,
509
+ 0,
510
+ 0,
511
+ 0,
512
+ 0,
513
+ -1,
514
+ -1,
515
+ -1,
516
+ -1,
517
+ 1,
518
+ 1,
519
+ 2,
520
+ 3
521
+ ];
522
+ var Wtf8Decoder = class _Wtf8Decoder {
523
+ static DEFAULT_BUFFERSIZE = 4096;
524
+ encoding = WTF8;
525
+ fatal;
526
+ ignoreBOM;
527
+ bufferSize;
528
+ #left = 0;
529
+ #cur = 0;
530
+ #pending = 0;
531
+ #first = true;
532
+ #buf;
533
+ constructor(label = "wtf8", options = void 0) {
534
+ if (label.toLowerCase().replace("-", "") !== "wtf8") {
535
+ throw new InvalidEncodingError(label);
536
+ }
537
+ this.fatal = Boolean(options?.fatal);
538
+ this.ignoreBOM = Boolean(options?.ignoreBOM);
539
+ this.bufferSize = Math.floor(options?.bufferSize ?? _Wtf8Decoder.DEFAULT_BUFFERSIZE);
540
+ if (isNaN(this.bufferSize) || this.bufferSize < 1) {
541
+ throw new RangeError(`Invalid buffer size: ${options?.bufferSize}`);
542
+ }
543
+ this.#buf = new Uint16Array(this.bufferSize);
544
+ }
545
+ decode(input, options) {
546
+ const streaming = Boolean(options?.stream);
547
+ const bytes = getUint8(input);
548
+ const res = [];
549
+ const out = this.#buf;
550
+ const maxSize = this.bufferSize - 3;
551
+ let pos = 0;
552
+ const fatal = () => {
553
+ this.#cur = 0;
554
+ this.#left = 0;
555
+ this.#pending = 0;
556
+ if (this.fatal) {
557
+ throw new DecodeError();
558
+ }
559
+ out[pos++] = REPLACEMENT;
560
+ };
561
+ const fatals = () => {
562
+ const p5 = this.#pending;
563
+ for (let i = 0; i < p5; i++) {
564
+ fatal();
565
+ }
566
+ };
567
+ const oneByte = (b5) => {
568
+ if (this.#left === 0) {
569
+ const n2 = REMAINDER[b5 >> 4];
570
+ switch (n2) {
571
+ case -1:
572
+ fatal();
573
+ break;
574
+ case 0:
575
+ out[pos++] = b5;
576
+ break;
577
+ case 1:
578
+ this.#cur = b5 & 31;
579
+ if ((this.#cur & 30) === 0) {
580
+ fatal();
581
+ } else {
582
+ this.#left = 1;
583
+ this.#pending = 1;
584
+ }
585
+ break;
586
+ case 2:
587
+ this.#cur = b5 & 15;
588
+ this.#left = 2;
589
+ this.#pending = 1;
590
+ break;
591
+ case 3:
592
+ if (b5 & 8) {
593
+ fatal();
594
+ } else {
595
+ this.#cur = b5 & 7;
596
+ this.#left = 3;
597
+ this.#pending = 1;
598
+ }
599
+ break;
600
+ }
601
+ } else {
602
+ if ((b5 & 192) !== 128) {
603
+ fatals();
604
+ return oneByte(b5);
605
+ }
606
+ if (this.#pending === 1 && this.#left === 2 && this.#cur === 0 && (b5 & 32) === 0) {
607
+ fatals();
608
+ return oneByte(b5);
609
+ }
610
+ if (this.#left === 3 && this.#cur === 0 && (b5 & 48) === 0) {
611
+ fatals();
612
+ return oneByte(b5);
613
+ }
614
+ this.#cur = this.#cur << 6 | b5 & 63;
615
+ this.#pending++;
616
+ if (--this.#left === 0) {
617
+ if (this.ignoreBOM || !this.#first || this.#cur !== BOM) {
618
+ if (this.#cur < 65536) {
619
+ out[pos++] = this.#cur;
620
+ } else {
621
+ const cp = this.#cur - 65536;
622
+ out[pos++] = cp >>> 10 & 1023 | MIN_HIGH_SURROGATE;
623
+ out[pos++] = cp & 1023 | MIN_LOW_SURROGATE;
624
+ }
625
+ }
626
+ this.#cur = 0;
627
+ this.#pending = 0;
628
+ this.#first = false;
629
+ }
630
+ }
631
+ };
632
+ for (const b5 of bytes) {
633
+ if (pos >= maxSize) {
634
+ res.push(String.fromCharCode.apply(null, out.subarray(0, pos)));
635
+ pos = 0;
636
+ }
637
+ oneByte(b5);
638
+ }
639
+ if (!streaming) {
640
+ this.#first = true;
641
+ if (this.#cur || this.#left) {
642
+ fatals();
643
+ }
644
+ }
645
+ if (pos > 0) {
646
+ res.push(String.fromCharCode.apply(null, out.subarray(0, pos)));
647
+ }
648
+ return res.join("");
649
+ }
650
+ };
651
+
652
+ // ../../node_modules/.pnpm/@cto.af+wtf8@0.0.5/node_modules/@cto.af/wtf8/lib/encode.js
653
+ function utf8length(str) {
654
+ let len = 0;
655
+ for (const s3 of str) {
656
+ const cp = s3.codePointAt(0);
657
+ if (cp < 128) {
658
+ len++;
659
+ } else if (cp < 2048) {
660
+ len += 2;
661
+ } else if (cp < 65536) {
662
+ len += 3;
663
+ } else {
664
+ len += 4;
665
+ }
666
+ }
667
+ return len;
668
+ }
669
+ var Wtf8Encoder = class {
670
+ encoding = WTF8;
671
+ encode(input) {
672
+ if (!input) {
673
+ return EMPTY;
674
+ }
675
+ const buf = new Uint8Array(utf8length(String(input)));
676
+ this.encodeInto(input, buf);
677
+ return buf;
678
+ }
679
+ encodeInto(source, destination) {
680
+ const str = String(source);
681
+ const len = str.length;
682
+ const outLen = destination.length;
683
+ let written = 0;
684
+ let read = 0;
685
+ for (read = 0; read < len; read++) {
686
+ const c5 = str.codePointAt(read);
687
+ if (c5 < 128) {
688
+ if (written >= outLen) {
689
+ break;
690
+ }
691
+ destination[written++] = c5;
692
+ } else if (c5 < 2048) {
693
+ if (written >= outLen - 1) {
694
+ break;
695
+ }
696
+ destination[written++] = 192 | c5 >> 6;
697
+ destination[written++] = 128 | c5 & 63;
698
+ } else if (c5 < 65536) {
699
+ if (written >= outLen - 2) {
700
+ break;
701
+ }
702
+ destination[written++] = 224 | c5 >> 12;
703
+ destination[written++] = 128 | c5 >> 6 & 63;
704
+ destination[written++] = 128 | c5 & 63;
705
+ } else {
706
+ if (written >= outLen - 3) {
707
+ break;
708
+ }
709
+ destination[written++] = 240 | c5 >> 18;
710
+ destination[written++] = 128 | c5 >> 12 & 63;
711
+ destination[written++] = 128 | c5 >> 6 & 63;
712
+ destination[written++] = 128 | c5 & 63;
713
+ read++;
714
+ }
715
+ }
716
+ return {
717
+ read,
718
+ written
719
+ };
720
+ }
721
+ };
722
+ var U3 = f.SIMPLE_FLOAT << 5 | I.TWO;
723
+ var h2 = f.SIMPLE_FLOAT << 5 | I.FOUR;
724
+ var B2 = f.SIMPLE_FLOAT << 5 | I.EIGHT;
725
+ var j = f.SIMPLE_FLOAT << 5 | o.TRUE;
726
+ var q = f.SIMPLE_FLOAT << 5 | o.FALSE;
727
+ var $ = f.SIMPLE_FLOAT << 5 | o.UNDEFINED;
728
+ var z = f.SIMPLE_FLOAT << 5 | o.NULL;
729
+ var H = new TextEncoder();
730
+ var K = new Wtf8Encoder();
731
+ var k2 = { ...e.defaultOptions, avoidInts: false, cde: false, collapseBigInts: true, dateTag: T.DATE_EPOCH, dcbor: false, float64: false, flushToZero: false, forceEndian: null, ignoreOriginalEncoding: false, largeNegativeAsBigInt: false, reduceUnsafeNumbers: false, rejectBigInts: false, rejectCustomSimples: false, rejectDuplicateKeys: false, rejectFloats: false, rejectUndefined: false, simplifyNegativeZero: false, sortKeys: null, stringNormalization: null, types: null, wtf8: false, ignoreGlobalTags: false };
732
+ var F2 = { cde: true, ignoreOriginalEncoding: true, sortKeys: f4 };
733
+ var Y = { ...F2, dcbor: true, largeNegativeAsBigInt: true, reduceUnsafeNumbers: true, rejectCustomSimples: true, rejectDuplicateKeys: true, rejectUndefined: true, simplifyNegativeZero: true, stringNormalization: "NFC" };
734
+ function y2(e2) {
735
+ const n2 = e2 < 0;
736
+ return typeof e2 == "bigint" ? [n2 ? -e2 - 1n : e2, n2] : [n2 ? -e2 - 1 : e2, n2];
737
+ }
738
+ function N2(e2, n2, i) {
739
+ if (i.rejectFloats) throw new Error(`Attempt to encode an unwanted floating point number: ${e2}`);
740
+ if (isNaN(e2)) n2.writeUint8(U3), n2.writeUint16(32256);
741
+ else if (!i.float64 && Math.fround(e2) === e2) {
742
+ const r2 = Z(e2);
743
+ r2 === null ? (n2.writeUint8(h2), n2.writeFloat32(e2)) : (n2.writeUint8(U3), n2.writeUint16(r2));
744
+ } else n2.writeUint8(B2), n2.writeFloat64(e2);
745
+ }
746
+ function a2(e2, n2, i) {
747
+ const [r2, t3] = y2(e2);
748
+ if (t3 && i) throw new TypeError(`Negative size: ${e2}`);
749
+ i ??= t3 ? f.NEG_INT : f.POS_INT, i <<= 5, r2 < 24 ? n2.writeUint8(i | r2) : r2 <= 255 ? (n2.writeUint8(i | I.ONE), n2.writeUint8(r2)) : r2 <= 65535 ? (n2.writeUint8(i | I.TWO), n2.writeUint16(r2)) : r2 <= 4294967295 ? (n2.writeUint8(i | I.FOUR), n2.writeUint32(r2)) : (n2.writeUint8(i | I.EIGHT), n2.writeBigUint64(BigInt(r2)));
750
+ }
751
+ function m2(e2, n2, i) {
752
+ typeof e2 == "number" ? a2(e2, n2, f.TAG) : typeof e2 == "object" && !i.ignoreOriginalEncoding && A.ENCODED in e2 ? n2.write(e2[A.ENCODED]) : e2 <= Number.MAX_SAFE_INTEGER ? a2(Number(e2), n2, f.TAG) : (n2.writeUint8(f.TAG << 5 | I.EIGHT), n2.writeBigUint64(BigInt(e2)));
753
+ }
754
+ function O2(e2, n2, i) {
755
+ const [r2, t3] = y2(e2);
756
+ if (i.collapseBigInts && (!i.largeNegativeAsBigInt || e2 >= -0x8000000000000000n)) {
757
+ if (r2 <= 0xffffffffn) {
758
+ a2(Number(e2), n2);
759
+ return;
760
+ }
761
+ if (r2 <= 0xffffffffffffffffn) {
762
+ const l6 = (t3 ? f.NEG_INT : f.POS_INT) << 5;
763
+ n2.writeUint8(l6 | I.EIGHT), n2.writeBigUint64(r2);
764
+ return;
765
+ }
766
+ }
767
+ if (i.rejectBigInts) throw new Error(`Attempt to encode unwanted bigint: ${e2}`);
768
+ const o5 = t3 ? T.NEG_BIGINT : T.POS_BIGINT, c5 = r2.toString(16), s3 = c5.length % 2 ? "0" : "";
769
+ m2(o5, n2, i);
770
+ const u3 = b(s3 + c5);
771
+ a2(u3.length, n2, f.BYTE_STRING), n2.write(u3);
772
+ }
773
+ function Z2(e2, n2, i) {
774
+ i.flushToZero && (e2 = k(e2)), Object.is(e2, -0) ? i.simplifyNegativeZero ? i.avoidInts ? N2(0, n2, i) : a2(0, n2) : N2(e2, n2, i) : !i.avoidInts && Number.isSafeInteger(e2) ? a2(e2, n2) : i.reduceUnsafeNumbers && Math.floor(e2) === e2 && e2 >= S.MIN && e2 <= S.MAX ? O2(BigInt(e2), n2, i) : N2(e2, n2, i);
775
+ }
776
+ function R2(e2, n2, i) {
777
+ const r2 = i.stringNormalization ? e2.normalize(i.stringNormalization) : e2;
778
+ if (i.wtf8 && !e2.isWellFormed()) {
779
+ const t3 = K.encode(r2);
780
+ m2(T.WTF8, n2, i), a2(t3.length, n2, f.BYTE_STRING), n2.write(t3);
781
+ } else {
782
+ const t3 = H.encode(r2);
783
+ a2(t3.length, n2, f.UTF8_STRING), n2.write(t3);
784
+ }
785
+ }
786
+ function J(e2, n2, i) {
787
+ const r2 = e2;
788
+ L(r2, r2.length, f.ARRAY, n2, i);
789
+ for (const t3 of r2) g3(t3, n2, i);
790
+ }
791
+ function V(e2, n2) {
792
+ a2(e2.length, n2, f.BYTE_STRING), n2.write(e2);
793
+ }
794
+ var b3 = new s2();
795
+ b3.registerEncoder(Array, J), b3.registerEncoder(Uint8Array, V);
796
+ function ue(e2, n2) {
797
+ return b3.registerEncoder(e2, n2);
798
+ }
799
+ function L(e2, n2, i, r2, t3) {
800
+ const o5 = s(e2);
801
+ o5 && !t3.ignoreOriginalEncoding ? r2.write(o5) : a2(n2, r2, i);
802
+ }
803
+ function X(e2, n2, i) {
804
+ if (e2 === null) {
805
+ n2.writeUint8(z);
806
+ return;
807
+ }
808
+ if (!i.ignoreOriginalEncoding && A.ENCODED in e2) {
809
+ n2.write(e2[A.ENCODED]);
810
+ return;
811
+ }
812
+ const r2 = e2.constructor;
813
+ if (r2) {
814
+ const o5 = i.types?.get(r2) ?? (i.ignoreGlobalTags ? void 0 : b3.get(r2));
815
+ if (o5) {
816
+ const c5 = o5(e2, n2, i);
817
+ if (c5 !== void 0) {
818
+ if (!Array.isArray(c5) || c5.length !== 2) throw new Error("Invalid encoder return value");
819
+ (typeof c5[0] == "bigint" || isFinite(Number(c5[0]))) && m2(c5[0], n2, i), g3(c5[1], n2, i);
820
+ }
821
+ return;
822
+ }
823
+ }
824
+ if (typeof e2.toCBOR == "function") {
825
+ const o5 = e2.toCBOR(n2, i);
826
+ o5 && ((typeof o5[0] == "bigint" || isFinite(Number(o5[0]))) && m2(o5[0], n2, i), g3(o5[1], n2, i));
827
+ return;
828
+ }
829
+ if (typeof e2.toJSON == "function") {
830
+ g3(e2.toJSON(), n2, i);
831
+ return;
832
+ }
833
+ const t3 = Object.entries(e2).map((o5) => [o5[0], o5[1], v2(o5[0], i)]);
834
+ i.sortKeys && t3.sort(i.sortKeys), L(e2, t3.length, f.MAP, n2, i);
835
+ for (const [o5, c5, s3] of t3) n2.write(s3), g3(c5, n2, i);
836
+ }
837
+ function Q(e2, n2, i) {
838
+ if (!e2.description || e2 !== Symbol.for(e2.description)) throw new TypeError(`Private or empty symbol: ${e2.toString()}`);
839
+ m2(280, n2, i), R2(e2.description, n2, i);
840
+ }
841
+ function g3(e2, n2, i) {
842
+ switch (typeof e2) {
843
+ case "number":
844
+ Z2(e2, n2, i);
845
+ break;
846
+ case "bigint":
847
+ O2(e2, n2, i);
848
+ break;
849
+ case "string":
850
+ R2(e2, n2, i);
851
+ break;
852
+ case "boolean":
853
+ n2.writeUint8(e2 ? j : q);
854
+ break;
855
+ case "undefined":
856
+ if (i.rejectUndefined) throw new Error("Attempt to encode unwanted undefined.");
857
+ n2.writeUint8($);
858
+ break;
859
+ case "object":
860
+ X(e2, n2, i);
861
+ break;
862
+ case "symbol":
863
+ Q(e2, n2, i);
864
+ break;
865
+ default:
866
+ throw new TypeError(`Unknown type: ${typeof e2}, ${String(e2)}`);
867
+ }
868
+ }
869
+ function v2(e2, n2 = {}) {
870
+ const i = { ...k2 };
871
+ n2.dcbor ? Object.assign(i, Y) : n2.cde && Object.assign(i, F2), Object.assign(i, n2);
872
+ const r2 = new e(i);
873
+ return g3(e2, r2, i), r2.read();
874
+ }
875
+
876
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/options.js
877
+ var o3 = ((e2) => (e2[e2.NEVER = -1] = "NEVER", e2[e2.PREFERRED = 0] = "PREFERRED", e2[e2.ALWAYS = 1] = "ALWAYS", e2))(o3 || {});
878
+
879
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/simple.js
880
+ var t = class _t {
881
+ static KnownSimple = /* @__PURE__ */ new Map([[o.FALSE, false], [o.TRUE, true], [o.NULL, null], [o.UNDEFINED, void 0]]);
882
+ value;
883
+ constructor(e2) {
884
+ this.value = e2;
885
+ }
886
+ static create(e2) {
887
+ return _t.KnownSimple.has(e2) ? _t.KnownSimple.get(e2) : new _t(e2);
888
+ }
889
+ toCBOR(e2, i) {
890
+ if (i.rejectCustomSimples) throw new Error(`Cannot encode non-standard Simple value: ${this.value}`);
891
+ a2(this.value, e2, f.SIMPLE_FLOAT);
892
+ }
893
+ toString() {
894
+ return `simple(${this.value})`;
895
+ }
896
+ decode() {
897
+ return _t.KnownSimple.has(this.value) ? _t.KnownSimple.get(this.value) : this;
898
+ }
899
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](e2, i, r2) {
900
+ return `simple(${r2(this.value, i)})`;
901
+ }
902
+ };
903
+
904
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/decodeStream.js
905
+ var p3 = new TextDecoder("utf8", { fatal: true, ignoreBOM: true });
906
+ var y3 = class _y {
907
+ static defaultOptions = { maxDepth: 1024, encoding: "hex", requirePreferred: false };
908
+ #t;
909
+ #r;
910
+ #e = 0;
911
+ #i;
912
+ constructor(t3, r2) {
913
+ if (this.#i = { ..._y.defaultOptions, ...r2 }, typeof t3 == "string") switch (this.#i.encoding) {
914
+ case "hex":
915
+ this.#t = b(t3);
916
+ break;
917
+ case "base64":
918
+ this.#t = y(t3);
919
+ break;
920
+ default:
921
+ throw new TypeError(`Encoding not implemented: "${this.#i.encoding}"`);
922
+ }
923
+ else this.#t = t3;
924
+ this.#r = new DataView(this.#t.buffer, this.#t.byteOffset, this.#t.byteLength);
925
+ }
926
+ toHere(t3) {
927
+ return R(this.#t, t3, this.#e);
928
+ }
929
+ *[Symbol.iterator]() {
930
+ if (yield* this.#n(0), this.#e !== this.#t.length) throw new Error("Extra data in input");
931
+ }
932
+ *seq() {
933
+ for (; this.#e < this.#t.length; ) yield* this.#n(0);
934
+ }
935
+ *#n(t3) {
936
+ if (t3++ > this.#i.maxDepth) throw new Error(`Maximum depth ${this.#i.maxDepth} exceeded`);
937
+ const r2 = this.#e, c5 = this.#r.getUint8(this.#e++), i = c5 >> 5, n2 = c5 & 31;
938
+ let e2 = n2, f7 = false, a4 = 0;
939
+ switch (n2) {
940
+ case I.ONE:
941
+ if (a4 = 1, e2 = this.#r.getUint8(this.#e), i === f.SIMPLE_FLOAT) {
942
+ if (e2 < 32) throw new Error(`Invalid simple encoding in extra byte: ${e2}`);
943
+ f7 = true;
944
+ } else if (this.#i.requirePreferred && e2 < 24) throw new Error(`Unexpectedly long integer encoding (1) for ${e2}`);
945
+ break;
946
+ case I.TWO:
947
+ if (a4 = 2, i === f.SIMPLE_FLOAT) e2 = v(this.#t, this.#e);
948
+ else if (e2 = this.#r.getUint16(this.#e, false), this.#i.requirePreferred && e2 <= 255) throw new Error(`Unexpectedly long integer encoding (2) for ${e2}`);
949
+ break;
950
+ case I.FOUR:
951
+ if (a4 = 4, i === f.SIMPLE_FLOAT) e2 = this.#r.getFloat32(this.#e, false);
952
+ else if (e2 = this.#r.getUint32(this.#e, false), this.#i.requirePreferred && e2 <= 65535) throw new Error(`Unexpectedly long integer encoding (4) for ${e2}`);
953
+ break;
954
+ case I.EIGHT: {
955
+ if (a4 = 8, i === f.SIMPLE_FLOAT) e2 = this.#r.getFloat64(this.#e, false);
956
+ else if (e2 = this.#r.getBigUint64(this.#e, false), e2 <= Number.MAX_SAFE_INTEGER && (e2 = Number(e2)), this.#i.requirePreferred && e2 <= 4294967295) throw new Error(`Unexpectedly long integer encoding (8) for ${e2}`);
957
+ break;
958
+ }
959
+ case 28:
960
+ case 29:
961
+ case 30:
962
+ throw new Error(`Additional info not implemented: ${n2}`);
963
+ case I.INDEFINITE:
964
+ switch (i) {
965
+ case f.POS_INT:
966
+ case f.NEG_INT:
967
+ case f.TAG:
968
+ throw new Error(`Invalid indefinite encoding for MT ${i}`);
969
+ case f.SIMPLE_FLOAT:
970
+ yield [i, n2, A.BREAK, r2, 0];
971
+ return;
972
+ }
973
+ e2 = 1 / 0;
974
+ break;
975
+ default:
976
+ f7 = true;
977
+ }
978
+ switch (this.#e += a4, i) {
979
+ case f.POS_INT:
980
+ yield [i, n2, e2, r2, a4];
981
+ break;
982
+ case f.NEG_INT:
983
+ yield [i, n2, typeof e2 == "bigint" ? -1n - e2 : -1 - Number(e2), r2, a4];
984
+ break;
985
+ case f.BYTE_STRING:
986
+ e2 === 1 / 0 ? yield* this.#s(i, t3, r2) : yield [i, n2, this.#a(e2), r2, e2];
987
+ break;
988
+ case f.UTF8_STRING:
989
+ e2 === 1 / 0 ? yield* this.#s(i, t3, r2) : yield [i, n2, p3.decode(this.#a(e2)), r2, e2];
990
+ break;
991
+ case f.ARRAY:
992
+ if (e2 === 1 / 0) yield* this.#s(i, t3, r2, false);
993
+ else {
994
+ const o5 = Number(e2);
995
+ yield [i, n2, o5, r2, a4];
996
+ for (let h4 = 0; h4 < o5; h4++) yield* this.#n(t3 + 1);
997
+ }
998
+ break;
999
+ case f.MAP:
1000
+ if (e2 === 1 / 0) yield* this.#s(i, t3, r2, false);
1001
+ else {
1002
+ const o5 = Number(e2);
1003
+ yield [i, n2, o5, r2, a4];
1004
+ for (let h4 = 0; h4 < o5; h4++) yield* this.#n(t3), yield* this.#n(t3);
1005
+ }
1006
+ break;
1007
+ case f.TAG:
1008
+ yield [i, n2, e2, r2, a4], yield* this.#n(t3);
1009
+ break;
1010
+ case f.SIMPLE_FLOAT: {
1011
+ const o5 = e2;
1012
+ f7 && (e2 = t.create(Number(e2))), yield [i, n2, e2, r2, o5];
1013
+ break;
1014
+ }
1015
+ }
1016
+ }
1017
+ #a(t3) {
1018
+ const r2 = R(this.#t, this.#e, this.#e += t3);
1019
+ if (r2.length !== t3) throw new Error(`Unexpected end of stream reading ${t3} bytes, got ${r2.length}`);
1020
+ return r2;
1021
+ }
1022
+ *#s(t3, r2, c5, i = true) {
1023
+ for (yield [t3, I.INDEFINITE, 1 / 0, c5, 1 / 0]; ; ) {
1024
+ const n2 = this.#n(r2), e2 = n2.next(), [f7, a4, o5] = e2.value;
1025
+ if (o5 === A.BREAK) {
1026
+ yield e2.value, n2.next();
1027
+ return;
1028
+ }
1029
+ if (i) {
1030
+ if (f7 !== t3) throw new Error(`Unmatched major type. Expected ${t3}, got ${f7}.`);
1031
+ if (a4 === I.INDEFINITE) throw new Error("New stream started in typed stream");
1032
+ }
1033
+ yield e2.value, yield* n2;
1034
+ }
1035
+ }
1036
+ };
1037
+
1038
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/container.js
1039
+ var A4 = /* @__PURE__ */ new Map([[I.ZERO, 1], [I.ONE, 2], [I.TWO, 3], [I.FOUR, 5], [I.EIGHT, 9]]);
1040
+ var R3 = new Uint8Array(0);
1041
+ function F3(h4, r2) {
1042
+ return !r2.boxed && !r2.preferMap && h4.every(([i]) => typeof i == "string") ? Object.fromEntries(h4) : new Map(h4);
1043
+ }
1044
+ var y4 = class _y {
1045
+ static defaultDecodeOptions = { ...y3.defaultOptions, ParentType: _y, boxed: false, cde: false, dcbor: false, diagnosticSizes: o3.PREFERRED, collapseBigInts: false, convertUnsafeIntsToFloat: false, createObject: F3, keepNanPayloads: false, pretty: false, preferBigInt: false, preferMap: false, rejectLargeNegatives: false, rejectBigInts: false, rejectDuplicateKeys: false, rejectFloats: false, rejectInts: false, rejectLongLoundNaN: false, rejectLongFloats: false, rejectNegativeZero: false, rejectSimple: false, rejectStreaming: false, rejectStringsNotNormalizedAs: null, rejectSubnormals: false, rejectUndefined: false, rejectUnsafeFloatInts: false, saveOriginal: false, sortKeys: null, tags: null, ignoreGlobalTags: false };
1046
+ static cdeDecodeOptions = { cde: true, rejectStreaming: true, requirePreferred: true, sortKeys: f4 };
1047
+ static dcborDecodeOptions = { ...this.cdeDecodeOptions, dcbor: true, convertUnsafeIntsToFloat: true, rejectDuplicateKeys: true, rejectLargeNegatives: true, rejectLongLoundNaN: true, rejectLongFloats: true, rejectNegativeZero: true, rejectSimple: true, rejectUndefined: true, rejectUnsafeFloatInts: true, rejectStringsNotNormalizedAs: "NFC" };
1048
+ parent;
1049
+ mt;
1050
+ ai;
1051
+ left;
1052
+ offset;
1053
+ count = 0;
1054
+ children = [];
1055
+ depth = 0;
1056
+ #e;
1057
+ #t = null;
1058
+ constructor(r2, i, e2, t3) {
1059
+ if ([this.mt, this.ai, , this.offset] = r2, this.left = i, this.parent = e2, this.#e = t3, e2 && (this.depth = e2.depth + 1), this.mt === f.MAP && (this.#e.sortKeys || this.#e.rejectDuplicateKeys) && (this.#t = []), this.#e.rejectStreaming && this.ai === I.INDEFINITE) throw new Error("Streaming not supported");
1060
+ }
1061
+ get isStreaming() {
1062
+ return this.left === 1 / 0;
1063
+ }
1064
+ get done() {
1065
+ return this.left === 0;
1066
+ }
1067
+ static create(r2, i, e2, t3) {
1068
+ const [s3, u3, n2, c5] = r2;
1069
+ switch (s3) {
1070
+ case f.POS_INT:
1071
+ case f.NEG_INT: {
1072
+ if (e2.rejectInts) throw new Error(`Unexpected integer: ${n2}`);
1073
+ if (e2.rejectLargeNegatives && n2 < -0x8000000000000000n) throw new Error(`Invalid 65bit negative number: ${n2}`);
1074
+ let o5 = n2;
1075
+ return e2.preferBigInt ? o5 = BigInt(o5) : e2.convertUnsafeIntsToFloat && o5 >= S.MIN && o5 <= S.MAX && (o5 = Number(n2)), e2.boxed ? d(o5, t3.toHere(c5)) : o5;
1076
+ }
1077
+ case f.SIMPLE_FLOAT:
1078
+ if (u3 > I.ONE) {
1079
+ if (typeof n2 == "symbol") return n2;
1080
+ if (e2.rejectFloats) throw new Error(`Decoding unwanted floating point number: ${n2}`);
1081
+ if (e2.rejectNegativeZero && Object.is(n2, -0)) throw new Error("Decoding negative zero");
1082
+ if (isNaN(n2)) {
1083
+ const o5 = t3.toHere(c5), f7 = new O(o5);
1084
+ if (e2.rejectLongLoundNaN) {
1085
+ if (f7.payload || o5.length > 3) throw new Error(`Invalid NaN encoding: "${A2(o5)}"`);
1086
+ } else if (e2.keepNanPayloads && (f7.payload || f7.sign === -1)) {
1087
+ if (e2.rejectLongFloats && !f7.isShortestEncoding) throw new Error(`NaN should have been encoded shorter: ${n2}`);
1088
+ return f7;
1089
+ }
1090
+ }
1091
+ if (e2.rejectSubnormals && B(t3.toHere(c5 + 1)), e2.rejectLongFloats) {
1092
+ const o5 = v2(n2, { chunkSize: 9, reduceUnsafeNumbers: e2.rejectUnsafeFloatInts });
1093
+ if (o5[0] >> 5 !== s3) throw new Error(`Should have been encoded as int, not float: ${n2}`);
1094
+ if (o5.length < A4.get(u3)) throw new Error(`Number should have been encoded shorter: ${n2}`);
1095
+ }
1096
+ if (typeof n2 == "number" && e2.boxed) return d(n2, t3.toHere(c5));
1097
+ } else {
1098
+ if (e2.rejectSimple && n2 instanceof t) throw new Error(`Invalid simple value: ${n2}`);
1099
+ if (e2.rejectUndefined && n2 === void 0) throw new Error("Unexpected undefined");
1100
+ }
1101
+ return n2;
1102
+ case f.BYTE_STRING:
1103
+ case f.UTF8_STRING:
1104
+ if (n2 === 1 / 0) return new e2.ParentType(r2, 1 / 0, i, e2);
1105
+ if (e2.rejectStringsNotNormalizedAs && typeof n2 == "string") {
1106
+ const o5 = n2.normalize(e2.rejectStringsNotNormalizedAs);
1107
+ if (n2 !== o5) throw new Error(`String not normalized as "${e2.rejectStringsNotNormalizedAs}", got [${U(n2)}] instead of [${U(o5)}]`);
1108
+ }
1109
+ return e2.boxed ? d(n2, t3.toHere(c5)) : n2;
1110
+ case f.ARRAY:
1111
+ return new e2.ParentType(r2, n2, i, e2);
1112
+ case f.MAP:
1113
+ return new e2.ParentType(r2, n2 * 2, i, e2);
1114
+ case f.TAG: {
1115
+ const o5 = new e2.ParentType(r2, 1, i, e2);
1116
+ return o5.children = new o2(n2), o5;
1117
+ }
1118
+ }
1119
+ throw new TypeError(`Invalid major type: ${s3}`);
1120
+ }
1121
+ static decodeToEncodeOpts(r2) {
1122
+ return { ...k2, avoidInts: r2.rejectInts, float64: !r2.rejectLongFloats, flushToZero: r2.rejectSubnormals, largeNegativeAsBigInt: r2.rejectLargeNegatives, sortKeys: r2.sortKeys };
1123
+ }
1124
+ push(r2, i, e2) {
1125
+ if (this.children.push(r2), this.#t) {
1126
+ const t3 = f2(r2) || i.toHere(e2);
1127
+ this.#t.push(t3);
1128
+ }
1129
+ return --this.left;
1130
+ }
1131
+ replaceLast(r2, i, e2) {
1132
+ let t3, s3 = -1 / 0;
1133
+ if (this.children instanceof o2 ? (s3 = 0, t3 = this.children.contents, this.children.contents = r2) : (s3 = this.children.length - 1, t3 = this.children[s3], this.children[s3] = r2), this.#t) {
1134
+ const u3 = f2(r2) || e2.toHere(i.offset);
1135
+ this.#t[s3] = u3;
1136
+ }
1137
+ return t3;
1138
+ }
1139
+ convert(r2) {
1140
+ let i;
1141
+ switch (this.mt) {
1142
+ case f.ARRAY:
1143
+ i = this.children;
1144
+ break;
1145
+ case f.MAP: {
1146
+ const e2 = this.#r();
1147
+ if (this.#e.sortKeys) {
1148
+ let t3;
1149
+ for (const s3 of e2) {
1150
+ if (t3 && this.#e.sortKeys(t3, s3) >= 0) throw new Error(`Duplicate or out of order key: "0x${s3[2]}"`);
1151
+ t3 = s3;
1152
+ }
1153
+ } else if (this.#e.rejectDuplicateKeys) {
1154
+ const t3 = /* @__PURE__ */ new Set();
1155
+ for (const [s3, u3, n2] of e2) {
1156
+ const c5 = A2(n2);
1157
+ if (t3.has(c5)) throw new Error(`Duplicate key: "0x${c5}"`);
1158
+ t3.add(c5);
1159
+ }
1160
+ }
1161
+ i = this.#e.createObject(e2, this.#e);
1162
+ break;
1163
+ }
1164
+ case f.BYTE_STRING:
1165
+ return d2(this.children);
1166
+ case f.UTF8_STRING: {
1167
+ const e2 = this.children.join("");
1168
+ i = this.#e.boxed ? d(e2, r2.toHere(this.offset)) : e2;
1169
+ break;
1170
+ }
1171
+ case f.TAG:
1172
+ i = this.children.decode(this.#e);
1173
+ break;
1174
+ default:
1175
+ throw new TypeError(`Invalid mt on convert: ${this.mt}`);
1176
+ }
1177
+ return this.#e.saveOriginal && i && typeof i == "object" && u(i, r2.toHere(this.offset)), i;
1178
+ }
1179
+ #r() {
1180
+ const r2 = this.children, i = r2.length;
1181
+ if (i % 2) throw new Error("Missing map value");
1182
+ const e2 = new Array(i / 2);
1183
+ if (this.#t) for (let t3 = 0; t3 < i; t3 += 2) e2[t3 >> 1] = [r2[t3], r2[t3 + 1], this.#t[t3]];
1184
+ else for (let t3 = 0; t3 < i; t3 += 2) e2[t3 >> 1] = [r2[t3], r2[t3 + 1], R3];
1185
+ return e2;
1186
+ }
1187
+ };
1188
+
1189
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/diagnostic.js
1190
+ var O3 = " ";
1191
+ var y5 = new TextEncoder();
1192
+ var g4 = class extends y4 {
1193
+ close = "";
1194
+ quote = '"';
1195
+ get isEmptyStream() {
1196
+ return (this.mt === f.UTF8_STRING || this.mt === f.BYTE_STRING) && this.count === 0;
1197
+ }
1198
+ };
1199
+ function a3(m4, l6, n2, p5) {
1200
+ let t3 = "";
1201
+ if (l6 === I.INDEFINITE) t3 += "_";
1202
+ else {
1203
+ if (p5.diagnosticSizes === o3.NEVER) return "";
1204
+ {
1205
+ let r2 = p5.diagnosticSizes === o3.ALWAYS;
1206
+ if (!r2) {
1207
+ let e2 = I.ZERO;
1208
+ if (Object.is(n2, -0)) e2 = I.TWO;
1209
+ else if (m4 === f.POS_INT || m4 === f.NEG_INT) {
1210
+ const T2 = n2 < 0, u3 = typeof n2 == "bigint" ? 1n : 1, o5 = T2 ? -n2 - u3 : n2;
1211
+ o5 <= 23 ? e2 = Number(o5) : o5 <= 255 ? e2 = I.ONE : o5 <= 65535 ? e2 = I.TWO : o5 <= 4294967295 ? e2 = I.FOUR : e2 = I.EIGHT;
1212
+ } else isFinite(n2) ? Math.fround(n2) === n2 ? Z(n2) == null ? e2 = I.FOUR : e2 = I.TWO : e2 = I.EIGHT : e2 = I.TWO;
1213
+ r2 = e2 !== l6;
1214
+ }
1215
+ r2 && (t3 += "_", l6 < I.ONE ? t3 += "i" : t3 += String(l6 - 24));
1216
+ }
1217
+ }
1218
+ return t3;
1219
+ }
1220
+ function M(m4, l6) {
1221
+ const n2 = { ...y4.defaultDecodeOptions, ...l6, ParentType: g4 }, p5 = new y3(m4, n2);
1222
+ let t3, r2, e2 = "";
1223
+ for (const T2 of p5) {
1224
+ const [u3, o5, i] = T2;
1225
+ switch (t3 && (t3.count > 0 && i !== A.BREAK && (t3.mt === f.MAP && t3.count % 2 ? e2 += ": " : (e2 += ",", n2.pretty || (e2 += " "))), n2.pretty && (t3.mt !== f.MAP || t3.count % 2 === 0) && (e2 += `
1226
+ ${O3.repeat(t3.depth + 1)}`)), r2 = y4.create(T2, t3, n2, p5), u3) {
1227
+ case f.POS_INT:
1228
+ case f.NEG_INT:
1229
+ e2 += String(i), e2 += a3(u3, o5, i, n2);
1230
+ break;
1231
+ case f.SIMPLE_FLOAT:
1232
+ if (i !== A.BREAK) if (typeof i == "number") {
1233
+ const c5 = Object.is(i, -0) ? "-0.0" : String(i);
1234
+ e2 += c5, isFinite(i) && !/[.e]/.test(c5) && (e2 += ".0"), e2 += a3(u3, o5, i, n2);
1235
+ } else i instanceof t ? (e2 += "simple(", e2 += String(i.value), e2 += a3(f.POS_INT, o5, i.value, n2), e2 += ")") : e2 += String(i);
1236
+ break;
1237
+ case f.BYTE_STRING:
1238
+ i === 1 / 0 ? (e2 += "(_ ", r2.close = ")", r2.quote = "'") : (e2 += "h'", e2 += A2(i), e2 += "'", e2 += a3(f.POS_INT, o5, i.length, n2));
1239
+ break;
1240
+ case f.UTF8_STRING:
1241
+ i === 1 / 0 ? (e2 += "(_ ", r2.close = ")") : (e2 += JSON.stringify(i), e2 += a3(f.POS_INT, o5, y5.encode(i).length, n2));
1242
+ break;
1243
+ case f.ARRAY: {
1244
+ e2 += "[";
1245
+ const c5 = a3(f.POS_INT, o5, i, n2);
1246
+ e2 += c5, c5 && (e2 += " "), n2.pretty && i ? r2.close = `
1247
+ ${O3.repeat(r2.depth)}]` : r2.close = "]";
1248
+ break;
1249
+ }
1250
+ case f.MAP: {
1251
+ e2 += "{";
1252
+ const c5 = a3(f.POS_INT, o5, i, n2);
1253
+ e2 += c5, c5 && (e2 += " "), n2.pretty && i ? r2.close = `
1254
+ ${O3.repeat(r2.depth)}}` : r2.close = "}";
1255
+ break;
1256
+ }
1257
+ case f.TAG:
1258
+ e2 += String(i), e2 += a3(f.POS_INT, o5, i, n2), e2 += "(", r2.close = ")";
1259
+ break;
1260
+ }
1261
+ if (r2 === A.BREAK) if (t3?.isStreaming) t3.left = 0;
1262
+ else throw new Error("Unexpected BREAK");
1263
+ else t3 && (t3.count++, t3.left--);
1264
+ for (r2 instanceof g4 && (t3 = r2); t3?.done; ) {
1265
+ if (t3.isEmptyStream) e2 = e2.slice(0, -3), e2 += `${t3.quote}${t3.quote}_`;
1266
+ else {
1267
+ if (t3.mt === f.MAP && t3.count % 2 !== 0) throw new Error(`Odd streaming map size: ${t3.count}`);
1268
+ e2 += t3.close;
1269
+ }
1270
+ t3 = t3.parent;
1271
+ }
1272
+ }
1273
+ return e2;
1274
+ }
1275
+
1276
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/comment.js
1277
+ var H2 = new TextDecoder();
1278
+ var A5 = class extends y4 {
1279
+ depth = 0;
1280
+ leaf = false;
1281
+ value;
1282
+ length;
1283
+ [A.ENCODED];
1284
+ constructor(a4, f7, e2, n2) {
1285
+ super(a4, f7, e2, n2), this.parent ? this.depth = this.parent.depth + 1 : this.depth = n2.initialDepth, [, , this.value, , this.length] = a4;
1286
+ }
1287
+ numBytes() {
1288
+ switch (this.ai) {
1289
+ case I.ONE:
1290
+ return 1;
1291
+ case I.TWO:
1292
+ return 2;
1293
+ case I.FOUR:
1294
+ return 4;
1295
+ case I.EIGHT:
1296
+ return 8;
1297
+ }
1298
+ return 0;
1299
+ }
1300
+ };
1301
+ function k3(t3) {
1302
+ return t3 instanceof A5;
1303
+ }
1304
+ function O4(t3, a4) {
1305
+ return t3 === 1 / 0 ? "Indefinite" : a4 ? `${t3} ${a4}${t3 !== 1 && t3 !== 1n ? "s" : ""}` : String(t3);
1306
+ }
1307
+ function y6(t3) {
1308
+ return "".padStart(t3, " ");
1309
+ }
1310
+ function x3(t3, a4, f7) {
1311
+ let e2 = "";
1312
+ e2 += y6(t3.depth * 2);
1313
+ const n2 = f2(t3);
1314
+ e2 += A2(n2.subarray(0, 1));
1315
+ const r2 = t3.numBytes();
1316
+ r2 && (e2 += " ", e2 += A2(n2.subarray(1, r2 + 1))), e2 = e2.padEnd(a4.minCol + 1, " "), e2 += "-- ", f7 !== void 0 && (e2 += y6(t3.depth * 2), f7 !== "" && (e2 += `[${f7}] `));
1317
+ let p5 = false;
1318
+ const [s3] = t3.children;
1319
+ switch (t3.mt) {
1320
+ case f.POS_INT:
1321
+ e2 += `Unsigned: ${s3}`, typeof s3 == "bigint" && (e2 += "n");
1322
+ break;
1323
+ case f.NEG_INT:
1324
+ e2 += `Negative: ${s3}`, typeof s3 == "bigint" && (e2 += "n");
1325
+ break;
1326
+ case f.BYTE_STRING:
1327
+ e2 += `Bytes (Length: ${O4(t3.length)})`;
1328
+ break;
1329
+ case f.UTF8_STRING:
1330
+ e2 += `UTF8 (Length: ${O4(t3.length)})`, t3.length !== 1 / 0 && (e2 += `: ${JSON.stringify(s3)}`);
1331
+ break;
1332
+ case f.ARRAY:
1333
+ e2 += `Array (Length: ${O4(t3.value, "item")})`;
1334
+ break;
1335
+ case f.MAP:
1336
+ e2 += `Map (Length: ${O4(t3.value, "pair")})`;
1337
+ break;
1338
+ case f.TAG: {
1339
+ e2 += `Tag #${t3.value}`;
1340
+ const o5 = t3.children, [m4] = o5.contents.children, i = new o2(o5.tag, m4);
1341
+ u(i, n2);
1342
+ const l6 = i.comment(a4, t3.depth);
1343
+ l6 && (e2 += ": ", e2 += l6), p5 ||= i.noChildren;
1344
+ break;
1345
+ }
1346
+ case f.SIMPLE_FLOAT:
1347
+ s3 === A.BREAK ? e2 += "BREAK" : t3.ai > I.ONE ? Object.is(s3, -0) ? e2 += "Float: -0" : e2 += `Float: ${s3}` : (e2 += "Simple: ", s3 instanceof t ? e2 += s3.value : e2 += s3);
1348
+ break;
1349
+ }
1350
+ if (!p5) if (t3.leaf) {
1351
+ if (e2 += `
1352
+ `, n2.length > r2 + 1) {
1353
+ const o5 = y6((t3.depth + 1) * 2), m4 = f3(n2);
1354
+ if (m4?.length) {
1355
+ m4.sort((l6, c5) => {
1356
+ const g5 = l6[0] - c5[0];
1357
+ return g5 || c5[1] - l6[1];
1358
+ });
1359
+ let i = 0;
1360
+ for (const [l6, c5, g5] of m4) if (!(l6 < i)) {
1361
+ if (i = l6 + c5, g5 === "<<") {
1362
+ e2 += y6(a4.minCol + 1), e2 += "--", e2 += o5, e2 += "<< ";
1363
+ const d6 = R(n2, l6, l6 + c5), h4 = f3(d6);
1364
+ if (h4) {
1365
+ const $3 = h4.findIndex(([w3, D, v3]) => w3 === 0 && D === c5 && v3 === "<<");
1366
+ $3 >= 0 && h4.splice($3, 1);
1367
+ }
1368
+ e2 += M(d6), e2 += ` >>
1369
+ `, e2 += L2(d6, { initialDepth: t3.depth + 1, minCol: a4.minCol, noPrefixHex: true });
1370
+ continue;
1371
+ } else g5 === "'" && (e2 += y6(a4.minCol + 1), e2 += "--", e2 += o5, e2 += "'", e2 += H2.decode(n2.subarray(l6, l6 + c5)), e2 += `'
1372
+ `);
1373
+ if (l6 > r2) for (let d6 = l6; d6 < l6 + c5; d6 += 8) {
1374
+ const h4 = Math.min(d6 + 8, l6 + c5);
1375
+ e2 += o5, e2 += A2(n2.subarray(d6, h4)), e2 += `
1376
+ `;
1377
+ }
1378
+ }
1379
+ } else for (let i = r2 + 1; i < n2.length; i += 8) e2 += o5, e2 += A2(n2.subarray(i, i + 8)), e2 += `
1380
+ `;
1381
+ }
1382
+ } else {
1383
+ e2 += `
1384
+ `;
1385
+ let o5 = 0;
1386
+ for (const m4 of t3.children) {
1387
+ if (k3(m4)) {
1388
+ let i = String(o5);
1389
+ t3.mt === f.MAP ? i = o5 % 2 ? `val ${(o5 - 1) / 2}` : `key ${o5 / 2}` : t3.mt === f.TAG && (i = ""), e2 += x3(m4, a4, i);
1390
+ }
1391
+ o5++;
1392
+ }
1393
+ }
1394
+ return e2;
1395
+ }
1396
+ var q2 = { ...y4.defaultDecodeOptions, initialDepth: 0, noPrefixHex: false, minCol: 0 };
1397
+ function L2(t3, a4) {
1398
+ const f7 = { ...q2, ...a4, ParentType: A5, saveOriginal: true }, e2 = new y3(t3, f7);
1399
+ let n2, r2;
1400
+ for (const s3 of e2) {
1401
+ if (r2 = y4.create(s3, n2, f7, e2), s3[2] === A.BREAK) if (n2?.isStreaming) n2.left = 1;
1402
+ else throw new Error("Unexpected BREAK");
1403
+ if (!k3(r2)) {
1404
+ const i = new A5(s3, 0, n2, f7);
1405
+ i.leaf = true, i.children.push(r2), u(i, e2.toHere(s3[3])), r2 = i;
1406
+ }
1407
+ let o5 = (r2.depth + 1) * 2;
1408
+ const m4 = r2.numBytes();
1409
+ for (m4 && (o5 += 1, o5 += m4 * 2), f7.minCol = Math.max(f7.minCol, o5), n2 && n2.push(r2, e2, s3[3]), n2 = r2; n2?.done; ) r2 = n2, r2.leaf || u(r2, e2.toHere(r2.offset)), { parent: n2 } = n2;
1410
+ }
1411
+ a4 && (a4.minCol = f7.minCol);
1412
+ let p5 = f7.noPrefixHex ? "" : `0x${A2(e2.toHere(0))}
1413
+ `;
1414
+ return p5 += x3(r2, f7), p5;
1415
+ }
1416
+
1417
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/types.js
1418
+ var U4 = !h();
1419
+ function I3(e2) {
1420
+ if (typeof e2 == "object" && e2) {
1421
+ if (e2.constructor !== Number) throw new Error(`Expected number: ${e2}`);
1422
+ } else if (typeof e2 != "number") throw new Error(`Expected number: ${e2}`);
1423
+ }
1424
+ function f6(e2) {
1425
+ if (typeof e2 == "object" && e2) {
1426
+ if (e2.constructor !== String) throw new Error(`Expected string: ${e2}`);
1427
+ } else if (typeof e2 != "string") throw new Error(`Expected string: ${e2}`);
1428
+ }
1429
+ function E2(e2) {
1430
+ if (!(e2 instanceof Uint8Array)) throw new Error(`Expected Uint8Array: ${e2}`);
1431
+ }
1432
+ function _2(e2) {
1433
+ if (!Array.isArray(e2)) throw new Error(`Expected Array: ${e2}`);
1434
+ }
1435
+ ue(Map, (e2, r2, n2) => {
1436
+ const i = [...e2.entries()].map((a4) => [a4[0], a4[1], v2(a4[0], n2)]);
1437
+ if (n2.rejectDuplicateKeys) {
1438
+ const a4 = /* @__PURE__ */ new Set();
1439
+ for (const [d6, u3, g5] of i) {
1440
+ const y7 = A2(g5);
1441
+ if (a4.has(y7)) throw new Error(`Duplicate map key: 0x${y7}`);
1442
+ a4.add(y7);
1443
+ }
1444
+ }
1445
+ n2.sortKeys && i.sort(n2.sortKeys), L(e2, e2.size, f.MAP, r2, n2);
1446
+ for (const [a4, d6, u3] of i) r2.write(u3), g3(d6, r2, n2);
1447
+ });
1448
+ function w2(e2) {
1449
+ return f6(e2.contents), new Date(e2.contents);
1450
+ }
1451
+ w2.comment = (e2) => {
1452
+ f6(e2.contents);
1453
+ const r2 = new Date(e2.contents);
1454
+ return `(String ${e2.tag === T.DATE_FULL ? "Full " : ""}Date) ${r2.toISOString()}`;
1455
+ }, o2.registerDecoder(T.DATE_STRING, w2), o2.registerDecoder(T.DATE_FULL, w2);
1456
+ function N3(e2) {
1457
+ return I3(e2.contents), new Date(e2.contents * 1e3);
1458
+ }
1459
+ N3.comment = (e2) => (I3(e2.contents), `(Epoch Date) ${new Date(e2.contents * 1e3).toISOString()}`), o2.registerDecoder(T.DATE_EPOCH, N3);
1460
+ var S3 = 1e3 * 60 * 60 * 24;
1461
+ function $2(e2) {
1462
+ return I3(e2.contents), new Date(e2.contents * S3);
1463
+ }
1464
+ $2.comment = (e2) => (I3(e2.contents), `(Epoch Date) ${new Date(e2.contents * S3).toISOString()}`), o2.registerDecoder(T.DATE_EPOCH_DAYS, $2), ue(Date, (e2, r2, n2) => {
1465
+ switch (n2.dateTag) {
1466
+ case T.DATE_EPOCH:
1467
+ return [n2.dateTag, e2.valueOf() / 1e3];
1468
+ case T.DATE_STRING:
1469
+ return [n2.dateTag, e2.toISOString().replace(/\.000Z$/, "Z")];
1470
+ case T.DATE_EPOCH_DAYS:
1471
+ return [n2.dateTag, Math.floor(e2.valueOf() / S3)];
1472
+ case T.DATE_FULL:
1473
+ return [n2.dateTag, e2.toISOString().split("T")[0]];
1474
+ default:
1475
+ throw new Error(`Unsupported date tag: ${n2.dateTag}`);
1476
+ }
1477
+ });
1478
+ function m3(e2, r2, n2) {
1479
+ if (E2(r2.contents), n2.rejectBigInts) throw new Error(`Decoding unwanted big integer: ${r2}(h'${A2(r2.contents)}')`);
1480
+ if (n2.requirePreferred && r2.contents[0] === 0) throw new Error(`Decoding overly-large bigint: ${r2.tag}(h'${A2(r2.contents)})`);
1481
+ let i = r2.contents.reduce((d6, u3) => d6 << 8n | BigInt(u3), 0n);
1482
+ e2 && (i = -1n - i);
1483
+ const a4 = i >= Number.MIN_SAFE_INTEGER && i <= Number.MAX_SAFE_INTEGER;
1484
+ if (n2.requirePreferred && a4) throw new Error(`Decoding bigint that could have been int: ${i}n`);
1485
+ return n2.collapseBigInts && a4 && (i = Number(i)), n2.boxed ? d(i, r2.contents) : i;
1486
+ }
1487
+ var L3 = m3.bind(null, false);
1488
+ var x4 = m3.bind(null, true);
1489
+ L3.comment = (e2, r2) => `(Positive BigInt) ${m3(false, e2, r2)}n`, x4.comment = (e2, r2) => `(Negative BigInt) ${m3(true, e2, r2)}n`, o2.registerDecoder(T.POS_BIGINT, L3), o2.registerDecoder(T.NEG_BIGINT, x4);
1490
+ function R4(e2, r2) {
1491
+ return E2(e2.contents), e2;
1492
+ }
1493
+ R4.comment = (e2, r2, n2) => {
1494
+ E2(e2.contents);
1495
+ const i = { ...r2, initialDepth: n2 + 2, noPrefixHex: true }, a4 = f2(e2);
1496
+ let u3 = 2 ** ((a4[0] & 31) - 24) + 1;
1497
+ const g5 = a4[u3] & 31;
1498
+ let y7 = A2(a4.subarray(u3, ++u3));
1499
+ g5 >= 24 && (y7 += " ", y7 += A2(a4.subarray(u3, u3 + 2 ** (g5 - 24)))), i.minCol = Math.max(i.minCol, (n2 + 1) * 2 + y7.length);
1500
+ const D = L2(e2.contents, i);
1501
+ let T2 = `Embedded CBOR
1502
+ `;
1503
+ return T2 += `${"".padStart((n2 + 1) * 2, " ")}${y7}`.padEnd(i.minCol + 1, " "), T2 += `-- Bytes (Length: ${e2.contents.length})
1504
+ `, T2 += D, T2;
1505
+ }, R4.noChildren = true, o2.registerDecoder(T.CBOR, R4), o2.registerDecoder(T.URI, (e2) => (f6(e2.contents), new URL(e2.contents)), "URI"), ue(URL, (e2) => [T.URI, e2.toString()]), o2.registerDecoder(T.BASE64URL, (e2) => (f6(e2.contents), x(e2.contents)), "Base64url-encoded"), o2.registerDecoder(T.BASE64, (e2) => (f6(e2.contents), y(e2.contents)), "Base64-encoded"), o2.registerDecoder(35, (e2) => (f6(e2.contents), new RegExp(e2.contents)), "RegExp"), o2.registerDecoder(21065, (e2) => {
1506
+ f6(e2.contents);
1507
+ const r2 = `^(?:${e2.contents})$`;
1508
+ return new RegExp(r2, "u");
1509
+ }, "I-RegExp"), o2.registerDecoder(T.REGEXP, (e2) => {
1510
+ if (_2(e2.contents), e2.contents.length < 1 || e2.contents.length > 2) throw new Error(`Invalid RegExp Array: ${e2.contents}`);
1511
+ return new RegExp(e2.contents[0], e2.contents[1]);
1512
+ }, "RegExp"), ue(RegExp, (e2) => [T.REGEXP, [e2.source, e2.flags]]), o2.registerDecoder(64, (e2) => (E2(e2.contents), e2.contents), "uint8 Typed Array");
1513
+ function c3(e2, r2, n2) {
1514
+ E2(e2.contents);
1515
+ let i = e2.contents.length;
1516
+ if (i % r2.BYTES_PER_ELEMENT !== 0) throw new Error(`Number of bytes must be divisible by ${r2.BYTES_PER_ELEMENT}, got: ${i}`);
1517
+ i /= r2.BYTES_PER_ELEMENT;
1518
+ const a4 = new r2(i), d6 = new DataView(e2.contents.buffer, e2.contents.byteOffset, e2.contents.byteLength), u3 = d6[`get${r2.name.replace(/Array/, "")}`].bind(d6);
1519
+ for (let g5 = 0; g5 < i; g5++) a4[g5] = u3(g5 * r2.BYTES_PER_ELEMENT, n2);
1520
+ return a4;
1521
+ }
1522
+ function l3(e2, r2, n2, i, a4) {
1523
+ const d6 = a4.forceEndian ?? U4;
1524
+ if (m2(d6 ? r2 : n2, e2, a4), a2(i.byteLength, e2, f.BYTE_STRING), U4 === d6) e2.write(new Uint8Array(i.buffer, i.byteOffset, i.byteLength));
1525
+ else {
1526
+ const g5 = `write${i.constructor.name.replace(/Array/, "")}`, y7 = e2[g5].bind(e2);
1527
+ for (const D of i) y7(D, d6);
1528
+ }
1529
+ }
1530
+ o2.registerDecoder(65, (e2) => c3(e2, Uint16Array, false), "uint16, big endian, Typed Array"), o2.registerDecoder(66, (e2) => c3(e2, Uint32Array, false), "uint32, big endian, Typed Array"), o2.registerDecoder(67, (e2) => c3(e2, BigUint64Array, false), "uint64, big endian, Typed Array"), o2.registerDecoder(68, (e2) => (E2(e2.contents), new Uint8ClampedArray(e2.contents)), "uint8 Typed Array, clamped arithmetic"), ue(Uint8ClampedArray, (e2) => [68, new Uint8Array(e2.buffer, e2.byteOffset, e2.byteLength)]), o2.registerDecoder(69, (e2) => c3(e2, Uint16Array, true), "uint16, little endian, Typed Array"), ue(Uint16Array, (e2, r2, n2) => l3(r2, 69, 65, e2, n2)), o2.registerDecoder(70, (e2) => c3(e2, Uint32Array, true), "uint32, little endian, Typed Array"), ue(Uint32Array, (e2, r2, n2) => l3(r2, 70, 66, e2, n2)), o2.registerDecoder(71, (e2) => c3(e2, BigUint64Array, true), "uint64, little endian, Typed Array"), ue(BigUint64Array, (e2, r2, n2) => l3(r2, 71, 67, e2, n2)), o2.registerDecoder(72, (e2) => (E2(e2.contents), new Int8Array(e2.contents)), "sint8 Typed Array"), ue(Int8Array, (e2) => [72, new Uint8Array(e2.buffer, e2.byteOffset, e2.byteLength)]), o2.registerDecoder(73, (e2) => c3(e2, Int16Array, false), "sint16, big endian, Typed Array"), o2.registerDecoder(74, (e2) => c3(e2, Int32Array, false), "sint32, big endian, Typed Array"), o2.registerDecoder(75, (e2) => c3(e2, BigInt64Array, false), "sint64, big endian, Typed Array"), o2.registerDecoder(77, (e2) => c3(e2, Int16Array, true), "sint16, little endian, Typed Array"), ue(Int16Array, (e2, r2, n2) => l3(r2, 77, 73, e2, n2)), o2.registerDecoder(78, (e2) => c3(e2, Int32Array, true), "sint32, little endian, Typed Array"), ue(Int32Array, (e2, r2, n2) => l3(r2, 78, 74, e2, n2)), o2.registerDecoder(79, (e2) => c3(e2, BigInt64Array, true), "sint64, little endian, Typed Array"), ue(BigInt64Array, (e2, r2, n2) => l3(r2, 79, 75, e2, n2)), o2.registerDecoder(81, (e2) => c3(e2, Float32Array, false), "IEEE 754 binary32, big endian, Typed Array"), o2.registerDecoder(82, (e2) => c3(e2, Float64Array, false), "IEEE 754 binary64, big endian, Typed Array"), o2.registerDecoder(85, (e2) => c3(e2, Float32Array, true), "IEEE 754 binary32, little endian, Typed Array"), ue(Float32Array, (e2, r2, n2) => l3(r2, 85, 81, e2, n2)), o2.registerDecoder(86, (e2) => c3(e2, Float64Array, true), "IEEE 754 binary64, big endian, Typed Array"), ue(Float64Array, (e2, r2, n2) => l3(r2, 86, 82, e2, n2)), o2.registerDecoder(T.SET, (e2, r2) => {
1531
+ if (_2(e2.contents), r2.sortKeys) {
1532
+ const n2 = y4.decodeToEncodeOpts(r2);
1533
+ let i = null;
1534
+ for (const a4 of e2.contents) {
1535
+ const d6 = [a4, void 0, v2(a4, n2)];
1536
+ if (i && r2.sortKeys(i, d6) >= 0) throw new Error(`Set items out of order in tag #${T.SET}`);
1537
+ i = d6;
1538
+ }
1539
+ }
1540
+ return new Set(e2.contents);
1541
+ }, "Set"), ue(Set, (e2, r2, n2) => {
1542
+ let i = [...e2];
1543
+ if (n2.sortKeys) {
1544
+ const a4 = i.map((d6) => [d6, void 0, v2(d6, n2)]);
1545
+ a4.sort(n2.sortKeys), i = a4.map(([d6]) => d6);
1546
+ }
1547
+ return [T.SET, i];
1548
+ }), o2.registerDecoder(T.JSON, (e2) => (f6(e2.contents), JSON.parse(e2.contents)), "JSON-encoded");
1549
+ function C(e2) {
1550
+ return E2(e2.contents), new Wtf8Decoder().decode(e2.contents);
1551
+ }
1552
+ C.comment = (e2) => {
1553
+ E2(e2.contents);
1554
+ const r2 = new Wtf8Decoder();
1555
+ return `(WTF8 string): ${JSON.stringify(r2.decode(e2.contents))}`;
1556
+ }, o2.registerDecoder(T.WTF8, C), o2.registerDecoder(T.SELF_DESCRIBED, (e2) => e2.contents, "Self-Described"), o2.registerDecoder(T.INVALID_16, () => {
1557
+ throw new Error(`Tag always invalid: ${T.INVALID_16}`);
1558
+ }, "Invalid"), o2.registerDecoder(T.INVALID_32, () => {
1559
+ throw new Error(`Tag always invalid: ${T.INVALID_32}`);
1560
+ }, "Invalid"), o2.registerDecoder(T.INVALID_64, () => {
1561
+ throw new Error(`Tag always invalid: ${T.INVALID_64}`);
1562
+ }, "Invalid"), o2.registerDecoder(T.SYMBOL, (e2) => {
1563
+ let r2 = e2.contents;
1564
+ if (Array.isArray(e2.contents)) {
1565
+ if (e2.contents.length !== 1) throw new Error(`Expected Array of size 1: ${e2.contents}`);
1566
+ [r2] = e2.contents;
1567
+ }
1568
+ if (f6(r2), !r2.length) throw new Error(`Expected non-empty string: ${e2.contents}`);
1569
+ return Symbol.for(r2);
1570
+ }, "Symbol");
1571
+ function h3(e2) {
1572
+ throw new Error(`Encoding ${e2.constructor.name} intentionally unimplmented. It is not concrete enough to interoperate. Convert to Uint8Array first.`);
1573
+ }
1574
+ ue(ArrayBuffer, h3), ue(DataView, h3), typeof SharedArrayBuffer < "u" && ue(SharedArrayBuffer, h3);
1575
+ function p4(e2) {
1576
+ return [NaN, e2.valueOf()];
1577
+ }
1578
+ ue(Boolean, p4), ue(Number, p4), ue(String, p4), ue(BigInt, p4);
1579
+
1580
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/decoder.js
1581
+ function c4(i) {
1582
+ const e2 = { ...y4.defaultDecodeOptions };
1583
+ if (i.dcbor ? Object.assign(e2, y4.dcborDecodeOptions) : i.cde && Object.assign(e2, y4.cdeDecodeOptions), Object.assign(e2, i), Object.hasOwn(e2, "rejectLongNumbers")) throw new TypeError("rejectLongNumbers has changed to requirePreferred");
1584
+ return e2.boxed && (e2.saveOriginal = true), e2;
1585
+ }
1586
+ var d4 = class {
1587
+ parent = void 0;
1588
+ ret = void 0;
1589
+ step(e2, n2, t3) {
1590
+ if (this.ret = y4.create(e2, this.parent, n2, t3), e2[2] === A.BREAK) if (this.parent?.isStreaming) this.parent.left = 0;
1591
+ else throw new Error("Unexpected BREAK");
1592
+ else this.parent && this.parent.push(this.ret, t3, e2[3]);
1593
+ for (this.ret instanceof y4 && (this.parent = this.ret); this.parent?.done; ) {
1594
+ this.ret = this.parent.convert(t3);
1595
+ const r2 = this.parent.parent;
1596
+ r2?.replaceLast(this.ret, this.parent, t3), this.parent = r2;
1597
+ }
1598
+ }
1599
+ };
1600
+ function l4(i, e2 = {}) {
1601
+ const n2 = c4(e2), t3 = new y3(i, n2), r2 = new d4();
1602
+ for (const o5 of t3) r2.step(o5, n2, t3);
1603
+ return r2.ret;
1604
+ }
1605
+
1606
+ // ../../node_modules/.pnpm/cbor2@2.3.0/node_modules/cbor2/lib/index.js
1607
+ var { cdeDecodeOptions: r, dcborDecodeOptions: n, defaultDecodeOptions: d5 } = y4;
1608
+
1609
+ // ../crypto-core/dist/cbor.js
1610
+ var CanonicalCborError = class extends Error {
1611
+ code;
1612
+ constructor(code, message, options) {
1613
+ super(message, options);
1614
+ this.name = "CanonicalCborError";
1615
+ this.code = code;
1616
+ }
1617
+ };
1618
+ function encodeCanonicalCbor(value) {
1619
+ return v2(value, {
1620
+ cde: true,
1621
+ collapseBigInts: true,
1622
+ rejectDuplicateKeys: true,
1623
+ sortKeys: f4
1624
+ });
1625
+ }
1626
+ function decodeCanonicalCbor(bytes) {
1627
+ try {
1628
+ return l4(bytes, {
1629
+ ...r,
1630
+ rejectStreaming: true,
1631
+ rejectDuplicateKeys: true,
1632
+ // A Label 309 record carries integers, byte/text strings, arrays, maps and
1633
+ // `null` — and nothing else. Without these rejections the major-type-7
1634
+ // surface leaks into the decoder: a float16/32/64 that happens to hold an
1635
+ // integral value (e.g. 1.0) silently decodes to the integer 1 and passes
1636
+ // a `z.literal(1)` / Number.isInteger schema check, so two byte strings
1637
+ // that are NOT byte-identical canonicalise to the same record. That
1638
+ // breaks the cross-implementation parity invariant (the Python twin
1639
+ // already rejects non-integer `v` / `enc.scheme` outright). Reject the
1640
+ // whole non-record surface — floats, negative zero, undefined, and
1641
+ // non-{true,false,null} simple values — so any such input surfaces as
1642
+ // MALFORMED_CBOR via mapDecodeError rather than decoding to a look-alike.
1643
+ rejectFloats: true,
1644
+ rejectNegativeZero: true,
1645
+ rejectUndefined: true,
1646
+ rejectSimple: true
1647
+ });
1648
+ } catch (cause) {
1649
+ throw mapDecodeError(cause);
1650
+ }
1651
+ }
1652
+ function mapDecodeError(cause) {
1653
+ const message = cause instanceof Error ? cause.message : String(cause);
1654
+ const lower = message.toLowerCase();
1655
+ const isIndefinite = lower.includes("streaming") || lower.includes("indefinite");
1656
+ const detail = isIndefinite ? `indefinite-length items are not permitted in canonical CBOR: ${message}` : message;
1657
+ return new CanonicalCborError("MALFORMED_CBOR", `cbor decode failed: ${detail}`, { cause });
1658
+ }
1659
+
1660
+ // src/error-codes.ts
1661
+ var ERROR_CODES = [
1662
+ "MALFORMED_CBOR",
1663
+ "SCHEMA_TYPE_MISMATCH",
1664
+ "SCHEMA_MISSING_REQUIRED",
1665
+ "SCHEMA_UNKNOWN_FIELD",
1666
+ "SCHEMA_INVALID_LITERAL",
1667
+ "SCHEMA_EMPTY_RECORD",
1668
+ "HASH_DIGEST_LENGTH_MISMATCH",
1669
+ "UNSUPPORTED_HASH_ALG",
1670
+ "UNSUPPORTED_MERKLE_COMMIT_ALG",
1671
+ "SCHEMA_MERKLE_LEAF_COUNT_INVALID",
1672
+ "INVALID_URI",
1673
+ "CHUNK_TOO_LARGE",
1674
+ "UNAUTHENTICATED_CIPHER_FORBIDDEN",
1675
+ "UNSUPPORTED_AEAD_ALG",
1676
+ "NONCE_LENGTH_MISMATCH",
1677
+ "UNSUPPORTED_ENVELOPE_SCHEME",
1678
+ "ENC_UNSUPPORTED",
1679
+ "ENC_SLOTS_EMPTY",
1680
+ "ENC_SLOT_INVALID_SHAPE",
1681
+ "UNSUPPORTED_KEM_ALG",
1682
+ "ENC_KEM_REQUIRED",
1683
+ "KEM_EPK_LENGTH_MISMATCH",
1684
+ "KEM_CT_LENGTH_MISMATCH",
1685
+ "WRAP_LENGTH_MISMATCH",
1686
+ "ENC_SLOTS_MAC_INVALID_LENGTH",
1687
+ "ENC_SLOTS_MAC_REQUIRED",
1688
+ "ENC_SLOTS_REQUIRED",
1689
+ "ENC_SLOTS_DUPLICATE_KEM_MATERIAL",
1690
+ "ENC_SLOTS_TOO_MANY",
1691
+ "ENC_ENVELOPE_TOO_LARGE",
1692
+ "ENC_EXCLUSIVITY_VIOLATION",
1693
+ "ENC_NO_KEY_PATH",
1694
+ "ENC_REQUIRES_CONTENT_HASH",
1695
+ "ENC_PASSPHRASE_ALG_UNSUPPORTED",
1696
+ "ENC_PASSPHRASE_SALT_TOO_SHORT",
1697
+ "ENC_PASSPHRASE_SALT_TOO_LONG",
1698
+ "ENC_PASSPHRASE_ARGON2_PARAMS_TOO_LOW",
1699
+ "ENC_PASSPHRASE_PARAMS_EXCEED_POLICY",
1700
+ "MALFORMED_SIG_COSE_SIGN1",
1701
+ "SIGNATURE_UNSUPPORTED",
1702
+ "SIG_ENTRY_INVALID_SHAPE",
1703
+ "SIG_ENTRY_KID_COSE_KEY_CONFLICT",
1704
+ "SIG_PRIVATE_KEY_LEAKED",
1705
+ "SUPERSEDES_TX_INVALID_LENGTH",
1706
+ "EXTENSION_UNSUPPORTED_CRITICAL",
1707
+ "CRIT_SHAPE_INVALID",
1708
+ "TX_NOT_FOUND",
1709
+ "PROVIDER_UNAVAILABLE",
1710
+ "TX_INTEGRITY_MISMATCH",
1711
+ "METADATA_NOT_FOUND",
1712
+ "INSUFFICIENT_CONFIRMATIONS",
1713
+ "SIGNATURE_INVALID",
1714
+ "SIGNER_KEY_UNRESOLVED",
1715
+ "WALLET_ADDRESS_MISMATCH",
1716
+ "URI_TARGET_FORBIDDEN",
1717
+ "URI_INTEGRITY_MISMATCH",
1718
+ "URI_PROVIDER_INTEGRITY_MISMATCH",
1719
+ "URI_FETCH_FAILED",
1720
+ "CONTENT_UNAVAILABLE",
1721
+ "CONTENT_FETCH_LIMIT_EXCEEDED",
1722
+ "CIPHERTEXT_UNAVAILABLE",
1723
+ "SERVICE_INDEPENDENCE_VIOLATION",
1724
+ "WRONG_DECRYPTION_INPUT_SHAPE",
1725
+ "WRONG_RECIPIENT_KEY",
1726
+ "TAMPERED_HEADER",
1727
+ "TAMPERED_CIPHERTEXT",
1728
+ "KDF_DERIVATION_FAILED",
1729
+ "ENC_PASSPHRASE_UNNORMALIZABLE",
1730
+ "ENC_PASSPHRASE_EMPTY",
1731
+ "SCHEMA_MERKLE_LEAF_COUNT_MISMATCH",
1732
+ "SCHEMA_MERKLE_LEAVES_FORMAT_UNSUPPORTED",
1733
+ "SCHEMA_MERKLE_LEAVES_MALFORMED",
1734
+ "MERKLE_ROOT_MISMATCH",
1735
+ "MERKLE_LEAVES_UNAVAILABLE",
1736
+ "MERKLE_UNSUPPORTED",
1737
+ "OUT_OF_PROFILE_SKIPPED"
1738
+ ];
1739
+ var ERROR_CODE_PART = Object.freeze({
1740
+ MALFORMED_CBOR: "A",
1741
+ SCHEMA_TYPE_MISMATCH: "A",
1742
+ SCHEMA_MISSING_REQUIRED: "A",
1743
+ SCHEMA_UNKNOWN_FIELD: "A",
1744
+ SCHEMA_INVALID_LITERAL: "A",
1745
+ SCHEMA_EMPTY_RECORD: "A",
1746
+ HASH_DIGEST_LENGTH_MISMATCH: "A",
1747
+ UNSUPPORTED_HASH_ALG: "A",
1748
+ UNSUPPORTED_MERKLE_COMMIT_ALG: "A",
1749
+ SCHEMA_MERKLE_LEAF_COUNT_INVALID: "A",
1750
+ INVALID_URI: "A",
1751
+ CHUNK_TOO_LARGE: "carriage",
1752
+ UNAUTHENTICATED_CIPHER_FORBIDDEN: "A",
1753
+ UNSUPPORTED_AEAD_ALG: "A",
1754
+ NONCE_LENGTH_MISMATCH: "A",
1755
+ UNSUPPORTED_ENVELOPE_SCHEME: "A",
1756
+ ENC_UNSUPPORTED: "A",
1757
+ ENC_SLOTS_EMPTY: "A",
1758
+ ENC_SLOT_INVALID_SHAPE: "A",
1759
+ UNSUPPORTED_KEM_ALG: "A",
1760
+ ENC_KEM_REQUIRED: "A",
1761
+ KEM_EPK_LENGTH_MISMATCH: "A",
1762
+ KEM_CT_LENGTH_MISMATCH: "A",
1763
+ WRAP_LENGTH_MISMATCH: "A",
1764
+ ENC_SLOTS_MAC_INVALID_LENGTH: "A",
1765
+ ENC_SLOTS_MAC_REQUIRED: "A",
1766
+ ENC_SLOTS_REQUIRED: "A",
1767
+ ENC_SLOTS_DUPLICATE_KEM_MATERIAL: "A",
1768
+ ENC_SLOTS_TOO_MANY: "A",
1769
+ ENC_ENVELOPE_TOO_LARGE: "A",
1770
+ ENC_EXCLUSIVITY_VIOLATION: "A",
1771
+ ENC_NO_KEY_PATH: "A",
1772
+ ENC_REQUIRES_CONTENT_HASH: "A",
1773
+ ENC_PASSPHRASE_ALG_UNSUPPORTED: "A",
1774
+ ENC_PASSPHRASE_SALT_TOO_SHORT: "A",
1775
+ ENC_PASSPHRASE_SALT_TOO_LONG: "A",
1776
+ ENC_PASSPHRASE_ARGON2_PARAMS_TOO_LOW: "A",
1777
+ ENC_PASSPHRASE_PARAMS_EXCEED_POLICY: "A",
1778
+ MALFORMED_SIG_COSE_SIGN1: "A",
1779
+ SIGNATURE_UNSUPPORTED: "A",
1780
+ SIG_ENTRY_INVALID_SHAPE: "A",
1781
+ SIG_ENTRY_KID_COSE_KEY_CONFLICT: "A",
1782
+ SIG_PRIVATE_KEY_LEAKED: "A",
1783
+ SUPERSEDES_TX_INVALID_LENGTH: "A",
1784
+ EXTENSION_UNSUPPORTED_CRITICAL: "A",
1785
+ CRIT_SHAPE_INVALID: "A",
1786
+ TX_NOT_FOUND: "B",
1787
+ PROVIDER_UNAVAILABLE: "B",
1788
+ TX_INTEGRITY_MISMATCH: "B",
1789
+ METADATA_NOT_FOUND: "B",
1790
+ INSUFFICIENT_CONFIRMATIONS: "B",
1791
+ SIGNATURE_INVALID: "B",
1792
+ SIGNER_KEY_UNRESOLVED: "B",
1793
+ WALLET_ADDRESS_MISMATCH: "B",
1794
+ URI_TARGET_FORBIDDEN: "B",
1795
+ URI_INTEGRITY_MISMATCH: "B",
1796
+ URI_PROVIDER_INTEGRITY_MISMATCH: "B",
1797
+ URI_FETCH_FAILED: "B",
1798
+ CONTENT_UNAVAILABLE: "B",
1799
+ CONTENT_FETCH_LIMIT_EXCEEDED: "B",
1800
+ CIPHERTEXT_UNAVAILABLE: "B",
1801
+ SERVICE_INDEPENDENCE_VIOLATION: "B",
1802
+ WRONG_DECRYPTION_INPUT_SHAPE: "B",
1803
+ WRONG_RECIPIENT_KEY: "B",
1804
+ TAMPERED_HEADER: "B",
1805
+ TAMPERED_CIPHERTEXT: "B",
1806
+ KDF_DERIVATION_FAILED: "B",
1807
+ ENC_PASSPHRASE_UNNORMALIZABLE: "B",
1808
+ ENC_PASSPHRASE_EMPTY: "B",
1809
+ SCHEMA_MERKLE_LEAF_COUNT_MISMATCH: "B",
1810
+ SCHEMA_MERKLE_LEAVES_FORMAT_UNSUPPORTED: "B",
1811
+ SCHEMA_MERKLE_LEAVES_MALFORMED: "B",
1812
+ MERKLE_ROOT_MISMATCH: "B",
1813
+ MERKLE_LEAVES_UNAVAILABLE: "B",
1814
+ MERKLE_UNSUPPORTED: "B",
1815
+ OUT_OF_PROFILE_SKIPPED: "B"
1816
+ });
1817
+ Object.freeze(
1818
+ ERROR_CODES.filter((code) => ERROR_CODE_PART[code] === "A")
1819
+ );
1820
+ Object.freeze(
1821
+ ERROR_CODES.filter((code) => ERROR_CODE_PART[code] === "carriage")
1822
+ );
1823
+ Object.freeze(
1824
+ ERROR_CODES.filter((code) => ERROR_CODE_PART[code] === "B")
1825
+ );
1826
+ var SEVERITY = Object.freeze({
1827
+ MALFORMED_CBOR: "error",
1828
+ SCHEMA_TYPE_MISMATCH: "error",
1829
+ SCHEMA_MISSING_REQUIRED: "error",
1830
+ SCHEMA_UNKNOWN_FIELD: "error",
1831
+ SCHEMA_INVALID_LITERAL: "error",
1832
+ SCHEMA_EMPTY_RECORD: "error",
1833
+ HASH_DIGEST_LENGTH_MISMATCH: "error",
1834
+ UNSUPPORTED_HASH_ALG: "error",
1835
+ UNSUPPORTED_MERKLE_COMMIT_ALG: "error",
1836
+ SCHEMA_MERKLE_LEAF_COUNT_INVALID: "error",
1837
+ INVALID_URI: "error",
1838
+ CHUNK_TOO_LARGE: "error",
1839
+ UNAUTHENTICATED_CIPHER_FORBIDDEN: "error",
1840
+ UNSUPPORTED_AEAD_ALG: "error",
1841
+ NONCE_LENGTH_MISMATCH: "error",
1842
+ UNSUPPORTED_ENVELOPE_SCHEME: "error",
1843
+ ENC_UNSUPPORTED: "info",
1844
+ ENC_SLOTS_EMPTY: "error",
1845
+ ENC_SLOT_INVALID_SHAPE: "error",
1846
+ UNSUPPORTED_KEM_ALG: "error",
1847
+ ENC_KEM_REQUIRED: "error",
1848
+ KEM_EPK_LENGTH_MISMATCH: "error",
1849
+ KEM_CT_LENGTH_MISMATCH: "error",
1850
+ WRAP_LENGTH_MISMATCH: "error",
1851
+ ENC_SLOTS_MAC_INVALID_LENGTH: "error",
1852
+ ENC_SLOTS_MAC_REQUIRED: "error",
1853
+ ENC_SLOTS_REQUIRED: "error",
1854
+ ENC_SLOTS_DUPLICATE_KEM_MATERIAL: "error",
1855
+ ENC_SLOTS_TOO_MANY: "error",
1856
+ ENC_ENVELOPE_TOO_LARGE: "error",
1857
+ ENC_EXCLUSIVITY_VIOLATION: "error",
1858
+ ENC_NO_KEY_PATH: "error",
1859
+ ENC_REQUIRES_CONTENT_HASH: "error",
1860
+ ENC_PASSPHRASE_ALG_UNSUPPORTED: "error",
1861
+ ENC_PASSPHRASE_SALT_TOO_SHORT: "error",
1862
+ ENC_PASSPHRASE_SALT_TOO_LONG: "error",
1863
+ ENC_PASSPHRASE_ARGON2_PARAMS_TOO_LOW: "error",
1864
+ ENC_PASSPHRASE_PARAMS_EXCEED_POLICY: "error",
1865
+ MALFORMED_SIG_COSE_SIGN1: "error",
1866
+ SIGNATURE_UNSUPPORTED: "info",
1867
+ SIG_ENTRY_INVALID_SHAPE: "error",
1868
+ SIG_ENTRY_KID_COSE_KEY_CONFLICT: "error",
1869
+ SIG_PRIVATE_KEY_LEAKED: "error",
1870
+ SUPERSEDES_TX_INVALID_LENGTH: "error",
1871
+ EXTENSION_UNSUPPORTED_CRITICAL: "error",
1872
+ CRIT_SHAPE_INVALID: "error",
1873
+ TX_NOT_FOUND: "error",
1874
+ PROVIDER_UNAVAILABLE: "error",
1875
+ TX_INTEGRITY_MISMATCH: "error",
1876
+ METADATA_NOT_FOUND: "error",
1877
+ INSUFFICIENT_CONFIRMATIONS: "info",
1878
+ SIGNATURE_INVALID: "error",
1879
+ SIGNER_KEY_UNRESOLVED: "error",
1880
+ WALLET_ADDRESS_MISMATCH: "error",
1881
+ URI_TARGET_FORBIDDEN: "error",
1882
+ URI_INTEGRITY_MISMATCH: "error",
1883
+ URI_PROVIDER_INTEGRITY_MISMATCH: "warning",
1884
+ URI_FETCH_FAILED: "warning",
1885
+ CONTENT_UNAVAILABLE: "error",
1886
+ CONTENT_FETCH_LIMIT_EXCEEDED: "error",
1887
+ CIPHERTEXT_UNAVAILABLE: "error",
1888
+ SERVICE_INDEPENDENCE_VIOLATION: "error",
1889
+ WRONG_DECRYPTION_INPUT_SHAPE: "error",
1890
+ WRONG_RECIPIENT_KEY: "error",
1891
+ TAMPERED_HEADER: "error",
1892
+ TAMPERED_CIPHERTEXT: "error",
1893
+ KDF_DERIVATION_FAILED: "error",
1894
+ ENC_PASSPHRASE_UNNORMALIZABLE: "error",
1895
+ ENC_PASSPHRASE_EMPTY: "error",
1896
+ SCHEMA_MERKLE_LEAF_COUNT_MISMATCH: "error",
1897
+ SCHEMA_MERKLE_LEAVES_FORMAT_UNSUPPORTED: "error",
1898
+ SCHEMA_MERKLE_LEAVES_MALFORMED: "error",
1899
+ MERKLE_ROOT_MISMATCH: "error",
1900
+ MERKLE_LEAVES_UNAVAILABLE: "warning",
1901
+ MERKLE_UNSUPPORTED: "info",
1902
+ OUT_OF_PROFILE_SKIPPED: "info"
1903
+ });
1904
+ new Map(
1905
+ ERROR_CODES.map((code, index) => [code, index])
1906
+ );
1907
+
1908
+ // src/carriage.ts
1909
+ var TRANSPORT_CHUNK_MAX_BYTES = 64;
1910
+ function chunkRecordBody(body) {
1911
+ if (body.length === 0) {
1912
+ throw new RangeError("record body must be non-empty; a CBOR value is at least one byte");
1913
+ }
1914
+ const chunks = [];
1915
+ for (let offset = 0; offset < body.length; offset += TRANSPORT_CHUNK_MAX_BYTES) {
1916
+ chunks.push(body.slice(offset, Math.min(offset + TRANSPORT_CHUNK_MAX_BYTES, body.length)));
1917
+ }
1918
+ return chunks;
1919
+ }
1920
+ function encodeLabel309Value(body) {
1921
+ return encodeCanonicalCbor(chunkRecordBody(body));
1922
+ }
1923
+ function reassembleLabel309Value(valueBytes) {
1924
+ let decoded;
1925
+ try {
1926
+ decoded = decodeCanonicalCbor(valueBytes);
1927
+ } catch (cause) {
1928
+ return failure(
1929
+ "MALFORMED_CBOR",
1930
+ `label-309 value failed to decode: ${cause instanceof Error ? cause.message : String(cause)}`
1931
+ );
1932
+ }
1933
+ if (!Array.isArray(decoded)) {
1934
+ return failure(
1935
+ "MALFORMED_CBOR",
1936
+ "label-309 value must be the whole-body chunk array (a CBOR array of byte strings), regardless of body length"
1937
+ );
1938
+ }
1939
+ let total = 0;
1940
+ for (let i = 0; i < decoded.length; i++) {
1941
+ const element = decoded[i];
1942
+ if (!(element instanceof Uint8Array)) {
1943
+ return failure("MALFORMED_CBOR", `chunk array element ${i} is not a byte string`);
1944
+ }
1945
+ if (element.length > TRANSPORT_CHUNK_MAX_BYTES) {
1946
+ return failure(
1947
+ "CHUNK_TOO_LARGE",
1948
+ `chunk array element ${i} is ${element.length} bytes; the ledger caps metadata byte strings at ${TRANSPORT_CHUNK_MAX_BYTES}`
1949
+ );
1950
+ }
1951
+ total += element.length;
1952
+ }
1953
+ const body = new Uint8Array(total);
1954
+ let offset = 0;
1955
+ for (const element of decoded) {
1956
+ body.set(element, offset);
1957
+ offset += element.length;
1958
+ }
1959
+ return { ok: true, body };
1960
+ }
1961
+ function failure(code, message) {
1962
+ return { ok: false, issue: { code, path: [], message, severity: SEVERITY[code] } };
1963
+ }
1964
+
1965
+ export { TRANSPORT_CHUNK_MAX_BYTES, chunkRecordBody, encodeLabel309Value, reassembleLabel309Value };
1966
+ //# sourceMappingURL=carriage.js.map
1967
+ //# sourceMappingURL=carriage.js.map