@cbortech/cbor 0.25.0 → 0.25.1

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.
@@ -92,10 +92,159 @@ var c = class {
92
92
  static get(t) {
93
93
  return t instanceof e ? t.value : void 0;
94
94
  }
95
- }, d = class {
95
+ };
96
+ //#endregion
97
+ //#region src/cdn/serialize-utils.ts
98
+ function d(e) {
99
+ let t = e?.indent;
100
+ return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
101
+ }
102
+ function f(e, t) {
103
+ return e.repeat(t);
104
+ }
105
+ function p(e) {
106
+ return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
107
+ }
108
+ function ee(e) {
109
+ return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
110
+ }
111
+ function m(e, t) {
112
+ if (!t) return e.text;
113
+ let { marker: n, text: r } = e;
114
+ if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
115
+ if (n === "//") return "#" + r.slice(2);
116
+ if (n === "/*") {
117
+ let e = r.slice(2, -2);
118
+ return e.includes("/") ? r : "/" + (e.startsWith("*") || e.startsWith("/") ? " " + e : e) + "/";
119
+ }
120
+ return r;
121
+ }
122
+ function te(e, t, n) {
123
+ return (e.comments?.leading ?? []).map((e) => t + m(e, n));
124
+ }
125
+ function h(e, t) {
126
+ let n = e.comments?.trailing ?? [];
127
+ return n.length === 0 ? "" : " " + n.map((e) => m(e, t)).join(" ");
128
+ }
129
+ function ne(e, t, n) {
130
+ return (e.comments?.dangling ?? []).map((e) => t + m(e, n));
131
+ }
132
+ function re(e, t = !1) {
133
+ let n = e?.commas ?? "comma", r = n !== "none";
134
+ return {
135
+ inlineSep: r ? t ? "," : ", " : " ",
136
+ multilineSep: r ? "," : "",
137
+ trailSep: n === "trailing" ? "," : "",
138
+ colSep: t ? ":" : ": "
139
+ };
140
+ }
141
+ function ie(e) {
142
+ return typeof e.toHex == "function" ? e.toHex() : Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
143
+ }
144
+ var g = typeof new Uint8Array().toBase64 == "function";
145
+ function ae(e) {
146
+ if (g) return e.toBase64({ omitPadding: !0 });
147
+ let t = "";
148
+ for (let n of e) t += String.fromCharCode(n);
149
+ return btoa(t).replace(/=/g, "");
150
+ }
151
+ function oe(e) {
152
+ if (g) return e.toBase64({
153
+ alphabet: "base64url",
154
+ omitPadding: !0
155
+ });
156
+ let t = "";
157
+ for (let n of e) t += String.fromCharCode(n);
158
+ return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
159
+ }
160
+ var se = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", ce = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
161
+ function le(e, t) {
162
+ let n = "", r = 0, i = 0;
163
+ for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
164
+ return i > 0 && (n += t[r << 5 - i & 31]), n;
165
+ }
166
+ function ue(e) {
167
+ for (let t of e) {
168
+ let e = t.codePointAt(0);
169
+ if (e < 32 || e === 127) return !0;
170
+ }
171
+ return !1;
172
+ }
173
+ function de(e, t, n) {
174
+ if (n === "string") {
175
+ let t = fe(e);
176
+ if (t != null) return me(t);
177
+ }
178
+ if (n === "printable-string" || n === void 0) {
179
+ let t = fe(e);
180
+ if (t != null && !ue(t)) return me(t);
181
+ }
182
+ switch (t) {
183
+ case "base64": return `b64'${ae(e)}'`;
184
+ case "base64url": return `b64'${oe(e)}'`;
185
+ case "base32": return `b32'${le(e, se)}'`;
186
+ case "base32hex": return `h32'${le(e, ce)}'`;
187
+ default: return `h'${ie(e)}'`;
188
+ }
189
+ }
190
+ function fe(e) {
191
+ try {
192
+ return new TextDecoder("utf-8", { fatal: !0 }).decode(e);
193
+ } catch {
194
+ return null;
195
+ }
196
+ }
197
+ function pe(e, t) {
198
+ let n = t.codePointAt(0), r = t;
199
+ for (let i of e) {
200
+ let e = i.codePointAt(0);
201
+ switch (e) {
202
+ case n:
203
+ r += `\\${t}`;
204
+ break;
205
+ case 92:
206
+ r += "\\\\";
207
+ break;
208
+ case 10:
209
+ r += "\\n";
210
+ break;
211
+ case 13:
212
+ r += "\\r";
213
+ break;
214
+ case 9:
215
+ r += "\\t";
216
+ break;
217
+ default: e < 32 || e === 127 || e === 8232 || e === 8233 || e === 8203 || e === 8204 || e === 8205 || e === 65279 ? r += `\\u${e.toString(16).padStart(4, "0")}` : r += i;
218
+ }
219
+ }
220
+ return r + t;
221
+ }
222
+ function me(e) {
223
+ return pe(e, "'");
224
+ }
225
+ function he(e) {
226
+ return pe(e, "'");
227
+ }
228
+ function ge(e) {
229
+ return pe(e, "\"");
230
+ }
231
+ function _e(e) {
232
+ if (isNaN(e)) return "NaN";
233
+ if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
234
+ if (Object.is(e, -0)) return "-0.0";
235
+ let t = e.toString();
236
+ return t.includes(".") || t.includes("e") ? t : t + ".0";
237
+ }
238
+ function ve(e, t, n) {
239
+ return t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
240
+ }
241
+ //#endregion
242
+ //#region src/ast/CborItem.ts
243
+ var _ = class {
96
244
  start;
97
245
  end;
98
246
  comments;
247
+ warnings;
99
248
  _defaults;
100
249
  toCBOR(e) {
101
250
  let t = this._defaults ? {
@@ -108,10 +257,10 @@ var c = class {
108
257
  let t = this._defaults ? {
109
258
  ...this._defaults,
110
259
  ...e
111
- } : e, n = this._toCDN(t, 0);
112
- if (!t?.preserveComments) return n;
113
- let r = this.comments?.leading?.map((e) => e.text) ?? [], i = this.comments?.trailing ?? [], a = i.length === 0 ? n : `${n} ${i.map((e) => e.text.trimEnd()).join(" ")}`;
114
- return [...r, a].join("\n");
260
+ } : e, n = this._toCDN(t, 0), r = t?.preserveComments;
261
+ if (!r) return n;
262
+ let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) => m(e, i)) ?? [], o = this.comments?.trailing ?? [], s = o.length === 0 ? n : `${n} ${o.map((e) => m(e, i).trimEnd()).join(" ")}`;
263
+ return [...a, s].join("\n");
115
264
  }
116
265
  toEDN(e) {
117
266
  return this.toCDN(e);
@@ -139,10 +288,10 @@ var c = class {
139
288
  comment: this._toCDN(t, 0)
140
289
  }];
141
290
  }
142
- }, f = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, p = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
143
- function ee(e) {
144
- p.setFloat64(0, e, !1);
145
- let t = p.getUint32(0, !1), n = p.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
291
+ }, ye = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, be = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
292
+ function xe(e) {
293
+ be.setFloat64(0, e, !1);
294
+ let t = be.getUint32(0, !1), n = be.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
146
295
  if (i === 2047) {
147
296
  if (a === 0 && n === 0) return r << 15 | 31744;
148
297
  let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
@@ -163,18 +312,18 @@ function ee(e) {
163
312
  let u = o <= 0 ? 0 : o;
164
313
  return r << 15 | u << 10 | s;
165
314
  }
166
- function te(e) {
315
+ function v(e) {
167
316
  let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
168
317
  return n === 31 ? r === 0 ? t ? -Infinity : Infinity : NaN : n === 0 ? r === 0 ? t ? -0 : 0 : (t ? -1 : 1) * 2 ** -14 * (r / 1024) : (t ? -1 : 1) * 2 ** (n - 15) * (1 + r / 1024);
169
318
  }
170
- var ne = f ? (e, t, n, r) => {
319
+ var Se = ye ? (e, t, n, r) => {
171
320
  e.setFloat16(t, n, r);
172
321
  } : (e, t, n, r) => {
173
- e.setUint16(t, ee(n), r);
322
+ e.setUint16(t, xe(n), r);
174
323
  };
175
324
  //#endregion
176
325
  //#region src/cbor/encode.ts
177
- function m(e, t, n) {
326
+ function y(e, t, n) {
178
327
  if (n !== void 0) {
179
328
  if (n === "i") {
180
329
  if (t > 23n) throw RangeError(`value ${t} does not fit in immediate encoding _i (max 23)`);
@@ -213,24 +362,24 @@ function m(e, t, n) {
213
362
  let r = new Uint8Array(9);
214
363
  return r[0] = e << 5 | 27, new DataView(r.buffer).setBigUint64(1, t, !1), r;
215
364
  }
216
- function h(e) {
365
+ function b(e) {
217
366
  let t = e.reduce((e, t) => e + t.length, 0), n = new Uint8Array(t), r = 0;
218
367
  for (let t of e) n.set(t, r), r += t.length;
219
368
  return n;
220
369
  }
221
- var re = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
222
- function ie(e) {
223
- return Object.is(te(ee(e)), e);
370
+ var Ce = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
371
+ function we(e) {
372
+ return Object.is(v(xe(e)), e);
224
373
  }
225
- function ae(e) {
226
- return re.setFloat32(0, e, !1), Object.is(re.getFloat32(0, !1), e);
374
+ function Te(e) {
375
+ return Ce.setFloat32(0, e, !1), Object.is(Ce.getFloat32(0, !1), e);
227
376
  }
228
- function oe(e) {
229
- return ie(e) ? "half" : ae(e) ? "single" : "double";
377
+ function Ee(e) {
378
+ return we(e) ? "half" : Te(e) ? "single" : "double";
230
379
  }
231
380
  //#endregion
232
381
  //#region src/ast/CborUint.ts
233
- var g = class extends d {
382
+ var x = class extends _ {
234
383
  value;
235
384
  encodingWidth;
236
385
  constructor(e, t) {
@@ -239,7 +388,7 @@ var g = class extends d {
239
388
  this.encodingWidth = t?.encodingWidth;
240
389
  }
241
390
  _toCBOR(e) {
242
- return m(0, this.value, this.encodingWidth);
391
+ return y(0, this.value, this.encodingWidth);
243
392
  }
244
393
  _toCDN(e, t) {
245
394
  let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.value;
@@ -254,7 +403,7 @@ var g = class extends d {
254
403
  let t = e?.integerAs ?? "auto";
255
404
  return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
256
405
  }
257
- }, _ = class extends d {
406
+ }, S = class extends _ {
258
407
  argument;
259
408
  encodingWidth;
260
409
  constructor(e, t) {
@@ -268,7 +417,7 @@ var g = class extends d {
268
417
  return -1n - this.argument;
269
418
  }
270
419
  _toCBOR(e) {
271
- return m(1, this.argument, this.encodingWidth);
420
+ return y(1, this.argument, this.encodingWidth);
272
421
  }
273
422
  _toCDN(e, t) {
274
423
  let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`, r = this.argument + 1n;
@@ -283,145 +432,8 @@ var g = class extends d {
283
432
  let t = this.value, n = e?.integerAs ?? "auto";
284
433
  return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
285
434
  }
286
- };
287
- //#endregion
288
- //#region src/cdn/serialize-utils.ts
289
- function v(e) {
290
- let t = e?.indent;
291
- return t === void 0 ? null : typeof t == "number" ? " ".repeat(t) : t;
292
- }
293
- function y(e, t) {
294
- return e.repeat(t);
295
- }
296
- function se(e) {
297
- return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
298
- }
299
- function ce(e) {
300
- return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
301
- }
302
- function le(e, t) {
303
- return (e.comments?.leading ?? []).map((e) => t + e.text);
304
- }
305
- function ue(e) {
306
- let t = e.comments?.trailing ?? [];
307
- return t.length === 0 ? "" : " " + t.map((e) => e.text).join(" ");
308
- }
309
- function de(e, t) {
310
- return (e.comments?.dangling ?? []).map((e) => t + e.text);
311
- }
312
- function fe(e, t = !1) {
313
- let n = e?.commas ?? "comma", r = n !== "none";
314
- return {
315
- inlineSep: r ? t ? "," : ", " : " ",
316
- multilineSep: r ? "," : "",
317
- trailSep: n === "trailing" ? "," : "",
318
- colSep: t ? ":" : ": "
319
- };
320
- }
321
- function pe(e) {
322
- return typeof e.toHex == "function" ? e.toHex() : Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
323
- }
324
- var me = typeof new Uint8Array().toBase64 == "function";
325
- function he(e) {
326
- if (me) return e.toBase64({ omitPadding: !0 });
327
- let t = "";
328
- for (let n of e) t += String.fromCharCode(n);
329
- return btoa(t).replace(/=/g, "");
330
- }
331
- function ge(e) {
332
- if (me) return e.toBase64({
333
- alphabet: "base64url",
334
- omitPadding: !0
335
- });
336
- let t = "";
337
- for (let n of e) t += String.fromCharCode(n);
338
- return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
339
- }
340
- var _e = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", ve = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
341
- function ye(e, t) {
342
- let n = "", r = 0, i = 0;
343
- for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
344
- return i > 0 && (n += t[r << 5 - i & 31]), n;
345
- }
346
- function be(e) {
347
- for (let t of e) {
348
- let e = t.codePointAt(0);
349
- if (e < 32 || e === 127) return !0;
350
- }
351
- return !1;
352
- }
353
- function xe(e, t, n) {
354
- if (n === "string") {
355
- let t = Se(e);
356
- if (t != null) return we(t);
357
- }
358
- if (n === "printable-string" || n === void 0) {
359
- let t = Se(e);
360
- if (t != null && !be(t)) return we(t);
361
- }
362
- switch (t) {
363
- case "base64": return `b64'${he(e)}'`;
364
- case "base64url": return `b64'${ge(e)}'`;
365
- case "base32": return `b32'${ye(e, _e)}'`;
366
- case "base32hex": return `h32'${ye(e, ve)}'`;
367
- default: return `h'${pe(e)}'`;
368
- }
369
- }
370
- function Se(e) {
371
- try {
372
- return new TextDecoder("utf-8", { fatal: !0 }).decode(e);
373
- } catch {
374
- return null;
375
- }
376
- }
377
- function Ce(e, t) {
378
- let n = t.codePointAt(0), r = t;
379
- for (let i of e) {
380
- let e = i.codePointAt(0);
381
- switch (e) {
382
- case n:
383
- r += `\\${t}`;
384
- break;
385
- case 92:
386
- r += "\\\\";
387
- break;
388
- case 10:
389
- r += "\\n";
390
- break;
391
- case 13:
392
- r += "\\r";
393
- break;
394
- case 9:
395
- r += "\\t";
396
- break;
397
- default: e < 32 || e === 127 || e === 8232 || e === 8233 || e === 8203 || e === 8204 || e === 8205 || e === 65279 ? r += `\\u${e.toString(16).padStart(4, "0")}` : r += i;
398
- }
399
- }
400
- return r + t;
401
- }
402
- function we(e) {
403
- return Ce(e, "'");
404
- }
405
- function Te(e) {
406
- return Ce(e, "'");
407
- }
408
- function b(e) {
409
- return Ce(e, "\"");
410
- }
411
- function Ee(e) {
412
- if (isNaN(e)) return "NaN";
413
- if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
414
- if (Object.is(e, -0)) return "-0.0";
415
- let t = e.toString();
416
- return t.includes(".") || t.includes("e") ? t : t + ".0";
417
- }
418
- function De(e, t, n) {
419
- return t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
420
- }
421
- //#endregion
422
- //#region src/utils/hexfloat.ts
423
- var Oe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
424
- function ke(e) {
435
+ }, De = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
436
+ function Oe(e) {
425
437
  let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
426
438
  if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
427
439
  let i = n.slice(0, r), a = n.slice(r + 1);
@@ -439,30 +451,31 @@ function ke(e) {
439
451
  let l = c * 2 ** o;
440
452
  return t ? -l : l;
441
453
  }
442
- function Ae(e) {
454
+ function ke(e) {
443
455
  if (isNaN(e)) return "NaN";
444
456
  if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
445
457
  let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
446
458
  if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
447
- Oe.setFloat64(0, n, !1);
448
- let r = Oe.getUint32(0, !1), i = Oe.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
459
+ De.setFloat64(0, n, !1);
460
+ let r = De.getUint32(0, !1), i = De.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
449
461
  a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
450
462
  let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
451
463
  return t ? `-${p}` : p;
452
464
  }
453
465
  //#endregion
454
466
  //#region src/ast/CborFloat.ts
455
- var x = class extends d {
467
+ var C = class extends _ {
456
468
  value;
457
469
  precision;
470
+ ednSource;
458
471
  constructor(e, t) {
459
472
  super(), this.value = e, this.precision = t?.precision;
460
473
  }
461
474
  _toCBOR(e) {
462
- let t = this.precision ?? oe(this.value);
475
+ let t = this.precision ?? Ee(this.value);
463
476
  if (t === "half") {
464
477
  let e = new Uint8Array(3);
465
- return e[0] = 249, ne(new DataView(e.buffer), 1, this.value, !1), e;
478
+ return e[0] = 249, Se(new DataView(e.buffer), 1, this.value, !1), e;
466
479
  }
467
480
  if (t === "single") {
468
481
  let e = new Uint8Array(5);
@@ -472,13 +485,14 @@ var x = class extends d {
472
485
  return n[0] = 251, new DataView(n.buffer).setFloat64(1, this.value, !1), n;
473
486
  }
474
487
  _toCDN(e, t) {
475
- let n = oe(this.value);
476
- return (e?.floatFormat === "hex" ? Ae(this.value) : Ee(this.value)) + De(this.value, this.precision, n);
488
+ if (e?.appStrings !== !1 && this.ednSource !== void 0) return this.ednSource;
489
+ let n = Ee(this.value);
490
+ return (e?.floatFormat === "hex" ? ke(this.value) : _e(this.value)) + ve(this.value, this.precision, n);
477
491
  }
478
492
  _toJS(e) {
479
493
  return this.value;
480
494
  }
481
- }, S = class extends d {
495
+ }, w = class extends _ {
482
496
  tag;
483
497
  content;
484
498
  encodingWidth;
@@ -487,7 +501,7 @@ var x = class extends d {
487
501
  this.content = t, this.encodingWidth = n?.encodingWidth;
488
502
  }
489
503
  _toCBOR(e) {
490
- return h([m(6, this.tag, this.encodingWidth), this.content._toCBOR(e)]);
504
+ return b([y(6, this.tag, this.encodingWidth), this.content._toCBOR(e)]);
491
505
  }
492
506
  _toCDN(e, t) {
493
507
  let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
@@ -496,7 +510,7 @@ var x = class extends d {
496
510
  _toHexDump(e, t) {
497
511
  let n = [{
498
512
  depth: e,
499
- hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(m(6, this.tag, this.encodingWidth)),
513
+ hex: ((e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "))(y(6, this.tag, this.encodingWidth)),
500
514
  comment: `Tag ${this.tag}`
501
515
  }];
502
516
  return n.push(...this.content._toHexDump(e + 1, t)), n;
@@ -508,7 +522,7 @@ var x = class extends d {
508
522
  };
509
523
  //#endregion
510
524
  //#region src/cdn/tokenizer.ts
511
- function je(e, t) {
525
+ function Ae(e, t) {
512
526
  let n = 1, r = 1;
513
527
  for (let i = 0; i < t; i++) e[i] === "\n" ? (n++, r = 1) : r++;
514
528
  return {
@@ -516,7 +530,7 @@ function je(e, t) {
516
530
  col: r
517
531
  };
518
532
  }
519
- var Me = class {
533
+ var je = class {
520
534
  input;
521
535
  pos;
522
536
  line;
@@ -524,11 +538,12 @@ var Me = class {
524
538
  _peeked = null;
525
539
  _lastConsumedEndOffset;
526
540
  comments = [];
541
+ onEscapeWarning;
527
542
  constructor(e, t) {
528
543
  this.input = e;
529
544
  let n = t?.offset ?? 0;
530
545
  if (!Number.isInteger(n) || n < 0 || n > e.length) throw RangeError(`EDN parse offset must be an integer between 0 and ${e.length}`);
531
- let r = je(e, n);
546
+ let r = Ae(e, n);
532
547
  this.pos = n, this.line = r.line, this.col = r.col, this._lastConsumedEndOffset = n;
533
548
  }
534
549
  peek() {
@@ -541,6 +556,9 @@ var Me = class {
541
556
  get lastEndOffset() {
542
557
  return this._lastConsumedEndOffset;
543
558
  }
559
+ get source() {
560
+ return this.input;
561
+ }
544
562
  _ch() {
545
563
  return this.input[this.pos] ?? "";
546
564
  }
@@ -637,7 +655,8 @@ var Me = class {
637
655
  if (t === "#") {
638
656
  for (; !this._eof() && this._ch() !== "\n";) {
639
657
  if (this._ch() === "\\") {
640
- this._advance(), !this._eof() && this._ch() !== "\n" && this._advance();
658
+ if (this._advance(), this._eof() || this._ch() === "\n") continue;
659
+ this._advance() === "u" && this._validateHexCommentUnicodeEscape();
641
660
  continue;
642
661
  }
643
662
  if (this._ch() === e) break;
@@ -647,6 +666,31 @@ var Me = class {
647
666
  }
648
667
  return !1;
649
668
  }
669
+ _validateHexCommentUnicodeEscape() {
670
+ let e = this.line, t = this.col;
671
+ if (!this._eof() && this._ch() === "{") {
672
+ this._advance();
673
+ let n = "";
674
+ for (; !this._eof() && this._ch() !== "}" && this._ch() !== "\n";) n += this._advance();
675
+ !this._eof() && this._ch() === "}" && this._advance();
676
+ let r = parseInt(n || "0", 16);
677
+ r >= 55296 && r <= 57343 && this._fail(`\\u{${n}} is a surrogate code point, not allowed in hex string comments`, e, t);
678
+ return;
679
+ }
680
+ let n = "";
681
+ for (let e = 0; e < 4 && !(this._eof() || this._ch() === "\n" || !/[0-9a-fA-F]/.test(this._ch())); e++) n += this._advance();
682
+ if (n.length < 4) return;
683
+ let r = parseInt(n, 16);
684
+ if (r >= 55296 && r <= 56319) {
685
+ (this._ch() !== "\\" || (this.input[this.pos + 1] ?? "") !== "u") && this._fail(`lone high surrogate \\u${n} in hex string comment`, e, t), this._advance(), this._advance();
686
+ let r = "";
687
+ for (let e = 0; e < 4 && !(this._eof() || this._ch() === "\n" || !/[0-9a-fA-F]/.test(this._ch())); e++) r += this._advance();
688
+ let i = parseInt(r || "0", 16);
689
+ (i < 56320 || i > 57343) && this._fail(`\\u${n} (high surrogate) not followed by valid low surrogate in hex string comment`, e, t);
690
+ return;
691
+ }
692
+ r >= 56320 && r <= 57343 && this._fail(`lone low surrogate \\u${n} in hex string comment`, e, t);
693
+ }
650
694
  _skipRawComment(e, t, n, r, i) {
651
695
  let a = e[t];
652
696
  if (a === "/") {
@@ -705,9 +749,10 @@ var Me = class {
705
749
  }
706
750
  let r = n.codePointAt(0);
707
751
  if ((r < 32 && r !== 10 || r === 127) && this._fail(`unescaped control character U+${r.toString(16).padStart(4, "0")} is not allowed in string literals`), n === "\\") {
752
+ let n = this.pos, r = this.line, i = this.col;
708
753
  this._advance();
709
- let n = this.line, r = this.col, i = this._advance();
710
- switch (i) {
754
+ let a = this._advance();
755
+ switch (a) {
711
756
  case "n":
712
757
  t += "\n";
713
758
  break;
@@ -727,53 +772,87 @@ var Me = class {
727
772
  t += "\\";
728
773
  break;
729
774
  case "u":
730
- t += this._readUnicodeEscape(e);
775
+ t += this._readUnicodeEscape(e, n, r, i);
731
776
  break;
732
777
  default:
733
- if (i === e) {
734
- t += i;
778
+ if (a === e) {
779
+ t += a;
735
780
  break;
736
781
  }
737
- if (i === "/") {
738
- t += "/";
782
+ if (a === "/") {
783
+ e === "'" && this._fail("\\/ is not a valid escape in single-quoted byte strings (§5.1)", r, i), t += "/";
739
784
  break;
740
785
  }
741
- this._fail(`invalid escape sequence \\${i} in ${e === "\"" ? "double" : "single"}-quoted string`, n, r);
786
+ if (this.onEscapeWarning) {
787
+ if (a === "0") {
788
+ this.onEscapeWarning("\\0 is a non-standard escape sequence; use \\u0000 instead", n, r, i), t += "\0";
789
+ break;
790
+ }
791
+ if (a === "v") {
792
+ this.onEscapeWarning("\\v is a non-standard escape sequence; use \\u000b instead", n, r, i), t += "\v";
793
+ break;
794
+ }
795
+ if (a === "x") {
796
+ let e = this._ch(), a = this.input[this.pos + 1] ?? "";
797
+ (!/[0-9a-fA-F]/.test(e) || !/[0-9a-fA-F]/.test(a)) && this._fail("\\x escape requires exactly two hex digits", r, i), this._advance(), this._advance();
798
+ let o = parseInt(e + a, 16);
799
+ this.onEscapeWarning(`\\x${e}${a} is a non-standard escape sequence; use \\u00${e}${a} instead`, n, r, i), t += String.fromCharCode(o);
800
+ break;
801
+ }
802
+ if (a === "\"" || a === "'") {
803
+ this.onEscapeWarning(`\\${a} inside ${e === "\"" ? "double" : "single"}-quoted string is non-standard`, n, r, i), t += a;
804
+ break;
805
+ }
806
+ if (a === "\n" || a === "\r") {
807
+ a === "\r" && this._ch() === "\n" && this._advance(), this.onEscapeWarning("line continuation (\\<newline>) is non-standard; the newline is ignored", n, r, i);
808
+ break;
809
+ }
810
+ this.onEscapeWarning(`\\${a} is an unknown escape sequence; interpreted as '${a}'`, n, r, i), t += a;
811
+ break;
812
+ }
813
+ this._fail(`invalid escape sequence \\${a} in ${e === "\"" ? "double" : "single"}-quoted string`, r, i);
742
814
  }
743
815
  } else t += this._advance();
744
816
  }
745
817
  return this._eof() && this._fail("unterminated string literal"), this._advance(), t;
746
818
  }
747
- _readUnicodeEscape(e) {
748
- let t = this.line, n = this.col, r = (r) => {
749
- e === "'" && r >= 32 && r <= 126 && r !== 92 && r !== 39 && this._fail(`\\u escape for printable ASCII U+${r.toString(16).padStart(4, "0")} is not allowed in single-quoted strings; write the character literally`, t, n);
819
+ _readUnicodeEscape(e, t, n, r) {
820
+ let i = this.line, a = this.col, o = (o) => {
821
+ if (e === "'" && o >= 32 && o <= 126) {
822
+ let e = `\\u escape for printable ASCII U+${o.toString(16).padStart(4, "0").toUpperCase()} is not allowed in single-quoted strings (§5.1 hexchar-s)`;
823
+ if (this.onEscapeWarning) {
824
+ this.onEscapeWarning(e, t ?? this.pos, n ?? i, r ?? a);
825
+ return;
826
+ }
827
+ this._fail(e, i, a);
828
+ }
750
829
  };
751
830
  if (!this._eof() && this._ch() === "{") {
752
831
  this._advance();
753
832
  let e = "";
754
833
  for (; !this._eof() && this._ch() !== "}";) {
755
- let r = this._ch();
756
- /[0-9a-fA-F]/.test(r) || this._fail(`invalid character in \\u{} escape: ${JSON.stringify(r)}`, t, n), e += this._advance();
834
+ let t = this._ch();
835
+ /[0-9a-fA-F]/.test(t) || this._fail(`invalid character in \\u{} escape: ${JSON.stringify(t)}`, i, a), e += this._advance();
757
836
  }
758
- this._eof() && this._fail("unterminated \\u{} escape", t, n), this._advance(), e.length === 0 && this._fail("empty \\u{} escape", t, n);
759
- let i = parseInt(e, 16);
760
- return i > 1114111 && this._fail(`\\u{${e}} exceeds maximum Unicode code point U+10FFFF`, t, n), i >= 55296 && i <= 57343 && this._fail(`\\u{${e}} is a surrogate code point, which is not a valid Unicode scalar value`, t, n), r(i), String.fromCodePoint(i);
837
+ this._eof() && this._fail("unterminated \\u{} escape", i, a), this._advance(), e.length === 0 && this._fail("empty \\u{} escape", i, a);
838
+ let t = parseInt(e, 16);
839
+ return t > 1114111 && this._fail(`\\u{${e}} exceeds maximum Unicode code point U+10FFFF`, i, a), t >= 55296 && t <= 57343 && this._fail(`\\u{${e}} is a surrogate code point, which is not a valid Unicode scalar value`, i, a), o(t), String.fromCodePoint(t);
761
840
  }
762
- let i = "";
841
+ let s = "";
763
842
  for (let e = 0; e < 4; e++) {
764
- this._eof() && this._fail("truncated \\uXXXX escape", t, n);
843
+ this._eof() && this._fail("truncated \\uXXXX escape", i, a);
765
844
  let e = this._ch();
766
- /[0-9a-fA-F]/.test(e) || this._fail(`invalid hex digit in \\uXXXX escape: ${JSON.stringify(e)}`, t, n), i += this._advance();
845
+ /[0-9a-fA-F]/.test(e) || this._fail(`invalid hex digit in \\uXXXX escape: ${JSON.stringify(e)}`, i, a), s += this._advance();
767
846
  }
768
- let a = parseInt(i, 16);
769
- if (a >= 55296 && a <= 56319) {
770
- (this._ch() !== "\\" || (this.input[this.pos + 1] ?? "") !== "u") && this._fail(`lone high surrogate \\u${i} must be followed by \\uDC00–\\uDFFF`, t, n), this._advance(), this._advance();
771
- let e = this.line, r = this.col, o = "";
772
- for (let t = 0; t < 4; t++) this._eof() && this._fail("truncated low-surrogate escape", e, r), o += this._advance();
773
- let s = parseInt(o, 16);
774
- return (s < 56320 || s > 57343) && this._fail(`\\u${i} (high surrogate) not followed by a valid low surrogate (got \\u${o})`, t, n), String.fromCodePoint(65536 + (a - 55296) * 1024 + (s - 56320));
847
+ let c = parseInt(s, 16);
848
+ if (c >= 55296 && c <= 56319) {
849
+ (this._ch() !== "\\" || (this.input[this.pos + 1] ?? "") !== "u") && this._fail(`lone high surrogate \\u${s} must be followed by \\uDC00–\\uDFFF`, i, a), this._advance(), this._advance();
850
+ let e = this.line, t = this.col, n = "";
851
+ for (let r = 0; r < 4; r++) this._eof() && this._fail("truncated low-surrogate escape", e, t), n += this._advance();
852
+ let r = parseInt(n, 16);
853
+ return (r < 56320 || r > 57343) && this._fail(`\\u${s} (high surrogate) not followed by a valid low surrogate (got \\u${n})`, i, a), String.fromCodePoint(65536 + (c - 55296) * 1024 + (r - 56320));
775
854
  }
776
- return a >= 56320 && a <= 57343 && this._fail(`lone low surrogate \\u${i} is not valid`, t, n), r(a), String.fromCharCode(a);
855
+ return c >= 56320 && c <= 57343 && this._fail(`lone low surrogate \\u${s} is not valid`, i, a), o(c), String.fromCharCode(c);
777
856
  }
778
857
  _readRawStringContent() {
779
858
  let e = this.line, t = this.col, n = 0;
@@ -845,24 +924,6 @@ var Me = class {
845
924
  }
846
925
  return r;
847
926
  }
848
- _processRawB32Content(e, t, n) {
849
- let r = "", i = 0;
850
- for (; i < e.length;) {
851
- let a = e[i];
852
- if (a === "\n" || a === " " || a === "\r") {
853
- i++;
854
- continue;
855
- }
856
- if (a === " ") throw SyntaxError(`EDN parse error at line ${t}, column ${n}: horizontal tab (HT) is not allowed inside b32\`\`/h32\`\` raw byte string literals (§5.2)`);
857
- let o = this._skipRawComment(e, i, "b32``/h32`` raw byte string", t, n);
858
- if (o !== -1) {
859
- i = o;
860
- continue;
861
- }
862
- r += a, i++;
863
- }
864
- return r;
865
- }
866
927
  _readByteContent(e) {
867
928
  this._advance();
868
929
  let t = "";
@@ -891,19 +952,6 @@ var Me = class {
891
952
  }
892
953
  return this._eof() && this._fail("unterminated byte string literal"), this._advance(), t;
893
954
  }
894
- _readB32Content(e) {
895
- this._advance();
896
- let t = "";
897
- for (; !this._eof() && this._ch() !== e;) {
898
- let n = this._ch();
899
- if (n === "\n" || n === " " || n === "\r") {
900
- this._advance();
901
- continue;
902
- }
903
- n === " " && this._fail("horizontal tab (HT) is not allowed inside byte string literals (§5.2)", this.line, this.col), !this._skipByteStringComment(e) && (t += this._advance());
904
- }
905
- return this._eof() && this._fail("unterminated byte string literal"), this._advance(), t;
906
- }
907
955
  _readHexByteContentElisionAware(e) {
908
956
  this._advance();
909
957
  let t = "", n = !1;
@@ -1078,7 +1126,7 @@ var Me = class {
1078
1126
  if (n === "-") {
1079
1127
  let n = this.input.slice(this.pos + 1);
1080
1128
  if (n.startsWith("Infinity")) {
1081
- let r = n[8] ?? "", i = r === "_" && /[0-3i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
1129
+ let r = n[8] ?? "", i = r === "_" && /[0-7i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
1082
1130
  if (!/[a-zA-Z0-9_]/.test(r) || i) {
1083
1131
  this._advance();
1084
1132
  for (let e = 0; e < 8; e++) this._advance();
@@ -1096,7 +1144,7 @@ var Me = class {
1096
1144
  if (n === "+") {
1097
1145
  let n = this.input.slice(this.pos + 1);
1098
1146
  if (n.startsWith("Infinity")) {
1099
- let r = n[8] ?? "", i = r === "_" && /[0-3i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
1147
+ let r = n[8] ?? "", i = r === "_" && /[0-7i]/.test(n[9] ?? "") && !/[a-zA-Z0-9_]/.test(n[10] ?? "");
1100
1148
  if (!/[a-zA-Z0-9_]/.test(r) || i) {
1101
1149
  this._advance();
1102
1150
  for (let e = 0; e < 8; e++) this._advance();
@@ -1151,7 +1199,7 @@ var Me = class {
1151
1199
  if (a) {
1152
1200
  if (this._ch() === "_") {
1153
1201
  let e = this.input[this.pos + 1] ?? "", t = this.input[this.pos + 2] ?? "";
1154
- (e === "0" || e === "1" || e === "2" || e === "3" || e === "i") && !/[0-9a-zA-Z_]/.test(t) && (n += this._advance() + this._advance());
1202
+ (e === "0" || e === "1" || e === "2" || e === "3" || e === "4" || e === "5" || e === "6" || e === "7" || e === "i") && !/[0-9a-zA-Z_]/.test(t) && (n += this._advance() + this._advance());
1155
1203
  }
1156
1204
  return {
1157
1205
  type: "FLOAT",
@@ -1197,7 +1245,7 @@ var Me = class {
1197
1245
  }
1198
1246
  if (this._ch() === "_") {
1199
1247
  let e = this.input[this.pos + 1] ?? "", t = this.input[this.pos + 2] ?? "";
1200
- (e === "0" || e === "1" || e === "2" || e === "3" || e === "i") && !/[0-9a-zA-Z_]/.test(t) && (n += this._advance() + this._advance());
1248
+ (e === "0" || e === "1" || e === "2" || e === "3" || e === "4" || e === "5" || e === "6" || e === "7" || e === "i") && !/[0-9a-zA-Z_]/.test(t) && (n += this._advance() + this._advance());
1201
1249
  }
1202
1250
  return {
1203
1251
  type: r ? "FLOAT" : "INTEGER",
@@ -1239,12 +1287,20 @@ var Me = class {
1239
1287
  case "NaN_1":
1240
1288
  case "NaN_2":
1241
1289
  case "NaN_3":
1290
+ case "NaN_4":
1291
+ case "NaN_5":
1292
+ case "NaN_6":
1293
+ case "NaN_7":
1242
1294
  case "NaN_i":
1243
1295
  case "Infinity":
1244
1296
  case "Infinity_0":
1245
1297
  case "Infinity_1":
1246
1298
  case "Infinity_2":
1247
1299
  case "Infinity_3":
1300
+ case "Infinity_4":
1301
+ case "Infinity_5":
1302
+ case "Infinity_6":
1303
+ case "Infinity_7":
1248
1304
  case "Infinity_i": return {
1249
1305
  type: "FLOAT",
1250
1306
  value: n,
@@ -1287,6 +1343,30 @@ var Me = class {
1287
1343
  line: e,
1288
1344
  col: t
1289
1345
  };
1346
+ case "_4": return {
1347
+ type: "ENCODING_INDICATOR",
1348
+ value: "4",
1349
+ line: e,
1350
+ col: t
1351
+ };
1352
+ case "_5": return {
1353
+ type: "ENCODING_INDICATOR",
1354
+ value: "5",
1355
+ line: e,
1356
+ col: t
1357
+ };
1358
+ case "_6": return {
1359
+ type: "ENCODING_INDICATOR",
1360
+ value: "6",
1361
+ line: e,
1362
+ col: t
1363
+ };
1364
+ case "_7": return {
1365
+ type: "ENCODING_INDICATOR",
1366
+ value: "7",
1367
+ line: e,
1368
+ col: t
1369
+ };
1290
1370
  case "_i": return {
1291
1371
  type: "ENCODING_INDICATOR",
1292
1372
  value: "i",
@@ -1320,18 +1400,6 @@ var Me = class {
1320
1400
  line: e,
1321
1401
  col: t
1322
1402
  };
1323
- case "b32": return {
1324
- type: "BYTES_B32",
1325
- value: this._readB32Content(r),
1326
- line: e,
1327
- col: t
1328
- };
1329
- case "h32": return {
1330
- type: "BYTES_H32",
1331
- value: this._readB32Content(r),
1332
- line: e,
1333
- col: t
1334
- };
1335
1403
  default: return {
1336
1404
  type: "APP_STRING",
1337
1405
  appPrefix: n,
@@ -1358,18 +1426,6 @@ var Me = class {
1358
1426
  line: e,
1359
1427
  col: t
1360
1428
  };
1361
- case "b32": return {
1362
- type: "BYTES_B32",
1363
- value: this._processRawB32Content(r, e, t),
1364
- line: e,
1365
- col: t
1366
- };
1367
- case "h32": return {
1368
- type: "BYTES_H32",
1369
- value: this._processRawB32Content(r, e, t),
1370
- line: e,
1371
- col: t
1372
- };
1373
1429
  default: return {
1374
1430
  type: "APP_STRING",
1375
1431
  appPrefix: n,
@@ -1390,7 +1446,7 @@ var Me = class {
1390
1446
  }
1391
1447
  this._fail(`unknown identifier ${JSON.stringify(n)}`, e, t);
1392
1448
  }
1393
- }, C = class extends d {
1449
+ }, T = class extends _ {
1394
1450
  indefiniteLength = !1;
1395
1451
  value;
1396
1452
  ednEncoding;
@@ -1400,18 +1456,18 @@ var Me = class {
1400
1456
  super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
1401
1457
  }
1402
1458
  _toCBOR(e) {
1403
- return h([m(2, BigInt(this.value.length), this.encodingWidth), this.value]);
1459
+ return b([y(2, BigInt(this.value.length), this.encodingWidth), this.value]);
1404
1460
  }
1405
1461
  _toCDN(e, t) {
1406
1462
  let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
1407
1463
  if (e?.preserveByteString && this.ednSource !== void 0) return this.ednSource + n;
1408
1464
  let r = e?.bstrEncoding ?? this.ednEncoding;
1409
- return xe(this.value, r, e?.sqstr) + n;
1465
+ return e?.appStrings === !1 && r !== "hex" && (r = "hex"), de(this.value, r, e?.sqstr) + n;
1410
1466
  }
1411
1467
  _toJS(e) {
1412
1468
  return this.value;
1413
1469
  }
1414
- }, w = class extends d {
1470
+ }, E = class extends _ {
1415
1471
  indefiniteLength = !0;
1416
1472
  chunks;
1417
1473
  constructor(e) {
@@ -1420,7 +1476,7 @@ var Me = class {
1420
1476
  _toCBOR(e) {
1421
1477
  let t = [new Uint8Array([95])];
1422
1478
  for (let n of this.chunks) t.push(n._toCBOR(e));
1423
- return t.push(new Uint8Array([255])), h(t);
1479
+ return t.push(new Uint8Array([255])), b(t);
1424
1480
  }
1425
1481
  _toCDN(e, t) {
1426
1482
  return this.chunks.length === 0 ? "''_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
@@ -1443,7 +1499,7 @@ var Me = class {
1443
1499
  for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
1444
1500
  return n;
1445
1501
  }
1446
- }, T = class extends d {
1502
+ }, D = class extends _ {
1447
1503
  indefiniteLength = !0;
1448
1504
  chunks;
1449
1505
  constructor(e) {
@@ -1452,7 +1508,7 @@ var Me = class {
1452
1508
  _toCBOR(e) {
1453
1509
  let t = [new Uint8Array([127])];
1454
1510
  for (let n of this.chunks) t.push(n._toCBOR(e));
1455
- return t.push(new Uint8Array([255])), h(t);
1511
+ return t.push(new Uint8Array([255])), b(t);
1456
1512
  }
1457
1513
  _toCDN(e, t) {
1458
1514
  return this.chunks.length === 0 ? "\"\"_" : `(_ ${this.chunks.map((t) => t._toCDN(e, 0)).join(", ")})`;
@@ -1473,7 +1529,7 @@ var Me = class {
1473
1529
  _toJS(e) {
1474
1530
  return this.chunks.map((e) => e.value).join("");
1475
1531
  }
1476
- }, E = class extends d {
1532
+ }, O = class extends _ {
1477
1533
  items;
1478
1534
  indefiniteLength;
1479
1535
  encodingWidth;
@@ -1484,28 +1540,28 @@ var Me = class {
1484
1540
  if (this.indefiniteLength) {
1485
1541
  let t = [new Uint8Array([159])];
1486
1542
  for (let n of this.items) t.push(n._toCBOR(e));
1487
- return t.push(new Uint8Array([255])), h(t);
1543
+ return t.push(new Uint8Array([255])), b(t);
1488
1544
  }
1489
- let t = [m(4, BigInt(this.items.length), this.encodingWidth)];
1545
+ let t = [y(4, BigInt(this.items.length), this.encodingWidth)];
1490
1546
  for (let n of this.items) t.push(n._toCBOR(e));
1491
- return h(t);
1547
+ return b(t);
1492
1548
  }
1493
1549
  _toCDN(e, t) {
1494
- let n = v(e), r = e?.preserveComments, i = r && (ce(this) || this.items.some(se));
1495
- n === null && i && (n = " ");
1496
- let { inlineSep: a, multilineSep: o, trailSep: s } = fe(e, n === null), c = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "";
1497
- if (n === null || this.items.length === 0 && !i) {
1498
- let n = this.items.map((n) => n._toCDN(e, t + 1)).join(a);
1499
- return this.indefiniteLength ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${c}${n}]`;
1500
- }
1501
- let l = y(n, t + 1), u = y(n, t), d = this.indefiniteLength ? "[_ " : `[${c}`, f = [];
1550
+ let n = d(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ee(this) || this.items.some(p));
1551
+ n === null && a && (n = " ");
1552
+ let { inlineSep: o, multilineSep: s, trailSep: c } = re(e, n === null), l = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "";
1553
+ if (n === null || this.items.length === 0 && !a) {
1554
+ let n = this.items.map((n) => n._toCDN(e, t + 1)).join(o);
1555
+ return this.indefiniteLength ? this.items.length === 0 ? "[_ ]" : `[_ ${n}]` : `[${l}${n}]`;
1556
+ }
1557
+ let u = f(n, t + 1), m = f(n, t), ie = this.indefiniteLength ? "[_ " : `[${l}`, g = [];
1502
1558
  for (let n = 0; n < this.items.length; n++) {
1503
- let i = this.items[n];
1504
- r && f.push(...le(i, l));
1505
- let a = n < this.items.length - 1 ? o : s;
1506
- f.push(`${l}${i._toCDN(e, t + 1)}${a}${r ? ue(i) : ""}`);
1559
+ let a = this.items[n];
1560
+ r && g.push(...te(a, u, i));
1561
+ let o = n < this.items.length - 1 ? s : c;
1562
+ g.push(`${u}${a._toCDN(e, t + 1)}${o}${r ? h(a, i) : ""}`);
1507
1563
  }
1508
- return r && f.push(...de(this, l)), `${d}\n${f.join("\n")}\n${u}]`;
1564
+ return r && g.push(...ne(this, u, i)), `${ie}\n${g.join("\n")}\n${m}]`;
1509
1565
  }
1510
1566
  _toHexDump(e, t) {
1511
1567
  let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
@@ -1524,7 +1580,7 @@ var Me = class {
1524
1580
  }
1525
1581
  let i = [{
1526
1582
  depth: e,
1527
- hex: r(m(4, BigInt(this.items.length), this.encodingWidth)),
1583
+ hex: r(y(4, BigInt(this.items.length), this.encodingWidth)),
1528
1584
  comment: `Array of length ${this.items.length}`
1529
1585
  }];
1530
1586
  for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
@@ -1543,7 +1599,7 @@ var Me = class {
1543
1599
  }
1544
1600
  return r;
1545
1601
  }
1546
- }, D = class extends d {
1602
+ }, k = class extends _ {
1547
1603
  entries;
1548
1604
  indefiniteLength;
1549
1605
  encodingWidth;
@@ -1554,32 +1610,32 @@ var Me = class {
1554
1610
  if (this.indefiniteLength) {
1555
1611
  let t = [new Uint8Array([191])];
1556
1612
  for (let [n, r] of this.entries) t.push(n._toCBOR(e), r._toCBOR(e));
1557
- return t.push(new Uint8Array([255])), h(t);
1613
+ return t.push(new Uint8Array([255])), b(t);
1558
1614
  }
1559
- let t = [m(5, BigInt(this.entries.length), this.encodingWidth)];
1615
+ let t = [y(5, BigInt(this.entries.length), this.encodingWidth)];
1560
1616
  for (let [n, r] of this.entries) t.push(n._toCBOR(e), r._toCBOR(e));
1561
- return h(t);
1617
+ return b(t);
1562
1618
  }
1563
1619
  _toCDN(e, t) {
1564
- let n = v(e), r = e?.preserveComments, i = r && (ce(this) || this.entries.some(([e, t]) => se(e) || se(t)));
1565
- n === null && i && (n = " ");
1566
- let { inlineSep: a, multilineSep: o, trailSep: s, colSep: c } = fe(e, n === null), l = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "", u = this.indefiniteLength ? "{_ " : `{${l}`;
1567
- if (n === null || this.entries.length === 0 && !i) {
1568
- let n = this.entries.map(([n, r]) => `${n._toCDN(e, t + 1)}${c}${r._toCDN(e, t + 1)}`).join(a);
1569
- return this.indefiniteLength ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${l}${n}}`;
1570
- }
1571
- let d = y(n, t + 1), f = y(n, t), p = [];
1620
+ let n = d(e), r = e?.preserveComments, i = typeof r == "string" ? r : void 0, a = r && (ee(this) || this.entries.some(([e, t]) => p(e) || p(t)));
1621
+ n === null && a && (n = " ");
1622
+ let { inlineSep: o, multilineSep: s, trailSep: c, colSep: l } = re(e, n === null), u = !this.indefiniteLength && this.encodingWidth !== void 0 ? `_${this.encodingWidth} ` : "", m = this.indefiniteLength ? "{_ " : `{${u}`;
1623
+ if (n === null || this.entries.length === 0 && !a) {
1624
+ let n = this.entries.map(([n, r]) => `${n._toCDN(e, t + 1)}${l}${r._toCDN(e, t + 1)}`).join(o);
1625
+ return this.indefiniteLength ? this.entries.length === 0 ? "{_ }" : `{_ ${n}}` : `{${u}${n}}`;
1626
+ }
1627
+ let h = f(n, t + 1), ie = f(n, t), g = [];
1572
1628
  for (let n = 0; n < this.entries.length; n++) {
1573
- let [i, a] = this.entries[n];
1574
- r && p.push(...le(i, d));
1575
- let l = n < this.entries.length - 1 ? o : s, u = r ? Ne([
1576
- ...i.comments?.trailing ?? [],
1577
- ...a.comments?.leading ?? [],
1578
- ...a.comments?.trailing ?? []
1579
- ]) : "";
1580
- p.push(`${d}${i._toCDN(e, t + 1)}${c}${a._toCDN(e, t + 1)}${l}${u}`);
1629
+ let [a, o] = this.entries[n];
1630
+ r && g.push(...te(a, h, i));
1631
+ let u = n < this.entries.length - 1 ? s : c, d = r ? Me([
1632
+ ...a.comments?.trailing ?? [],
1633
+ ...o.comments?.leading ?? [],
1634
+ ...o.comments?.trailing ?? []
1635
+ ], i) : "";
1636
+ g.push(`${h}${a._toCDN(e, t + 1)}${l}${o._toCDN(e, t + 1)}${u}${d}`);
1581
1637
  }
1582
- return r && p.push(...de(this, d)), `${u}\n${p.join("\n")}\n${f}}`;
1638
+ return r && g.push(...ne(this, h, i)), `${m}\n${g.join("\n")}\n${ie}}`;
1583
1639
  }
1584
1640
  _toHexDump(e, t) {
1585
1641
  let n = (e) => e.toString(16).toUpperCase().padStart(2, "0"), r = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" ");
@@ -1598,7 +1654,7 @@ var Me = class {
1598
1654
  }
1599
1655
  let i = [{
1600
1656
  depth: e,
1601
- hex: r(m(5, BigInt(this.entries.length), this.encodingWidth)),
1657
+ hex: r(y(5, BigInt(this.entries.length), this.encodingWidth)),
1602
1658
  comment: `Map of length ${this.entries.length}`
1603
1659
  }];
1604
1660
  for (let [n, r] of this.entries) i.push(...n._toHexDump(e + 1, t)), i.push(...r._toHexDump(e + 1, t));
@@ -1615,13 +1671,13 @@ var Me = class {
1615
1671
  }
1616
1672
  return n;
1617
1673
  };
1618
- return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof N) ? (() => {
1674
+ return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof I) ? (() => {
1619
1675
  let n = e ? {
1620
1676
  ...e,
1621
1677
  reviver: void 0
1622
1678
  } : void 0, r = {};
1623
1679
  for (let [e, t] of this.entries) {
1624
- let i = e instanceof N ? e.value : e.toCDN(), a = t._toJS(n);
1680
+ let i = e instanceof I ? e.value : e.toCDN(), a = t._toJS(n);
1625
1681
  i === "__proto__" ? Object.defineProperty(r, i, {
1626
1682
  value: a,
1627
1683
  writable: !0,
@@ -1633,10 +1689,10 @@ var Me = class {
1633
1689
  let i = /* @__PURE__ */ new Map();
1634
1690
  for (let e = 0; e < this.entries.length; e++) {
1635
1691
  let [t] = this.entries[e];
1636
- i.set(t instanceof N ? t.value : t.toCDN(), e);
1692
+ i.set(t instanceof I ? t.value : t.toCDN(), e);
1637
1693
  }
1638
1694
  for (let n = 0; n < this.entries.length; n++) {
1639
- let [a, o] = this.entries[n], s = a instanceof N ? a.value : a.toCDN();
1695
+ let [a, o] = this.entries[n], s = a instanceof I ? a.value : a.toCDN();
1640
1696
  if (i.get(s) !== n) continue;
1641
1697
  let c = o._toJS(e), u = t.call(r, s, c);
1642
1698
  u === l || e?.undefinedOmits && u === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
@@ -1650,12 +1706,12 @@ var Me = class {
1650
1706
  })() : n();
1651
1707
  }
1652
1708
  };
1653
- function Ne(e) {
1654
- return e.length === 0 ? "" : " " + e.map((e) => e.text.trimEnd()).join(" ");
1709
+ function Me(e, t) {
1710
+ return e.length === 0 ? "" : " " + e.map((e) => m(e, t).trimEnd()).join(" ");
1655
1711
  }
1656
1712
  //#endregion
1657
1713
  //#region src/ast/CborSimple.ts
1658
- var O = class e extends d {
1714
+ var A = class e extends _ {
1659
1715
  value;
1660
1716
  constructor(e) {
1661
1717
  if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
@@ -1686,29 +1742,29 @@ var O = class e extends d {
1686
1742
  default: return new u(this.value);
1687
1743
  }
1688
1744
  }
1689
- }, k = class extends d {
1745
+ }, j = class extends _ {
1690
1746
  items;
1691
1747
  constructor(e) {
1692
1748
  super(), this.items = e;
1693
1749
  }
1694
1750
  _content(e) {
1695
- return h(this.items.map((t) => t._toCBOR(e)));
1751
+ return b(this.items.map((t) => t._toCBOR(e)));
1696
1752
  }
1697
1753
  _toCBOR(e) {
1698
1754
  let t = this._content(e);
1699
- return h([m(2, BigInt(t.length)), t]);
1755
+ return b([y(2, BigInt(t.length)), t]);
1700
1756
  }
1701
1757
  _toCDN(e, t) {
1702
1758
  if (this.items.length === 0) return "<<>>";
1703
- let n = v(e), { inlineSep: r, multilineSep: i, trailSep: a } = fe(e, n === null);
1759
+ let n = d(e), { inlineSep: r, multilineSep: i, trailSep: a } = re(e, n === null);
1704
1760
  if (n === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(r)}>>`;
1705
- let o = y(n, t + 1), s = y(n, t), c = this.items.map((n) => `${o}${n._toCDN(e, t + 1)}`), l = c.length - 1;
1761
+ let o = f(n, t + 1), s = f(n, t), c = this.items.map((n) => `${o}${n._toCDN(e, t + 1)}`), l = c.length - 1;
1706
1762
  return `<<\n${c.map((e, t) => t < l ? `${e}${i}` : `${e}${a}`).join("\n")}\n${s}>>`;
1707
1763
  }
1708
1764
  _toHexDump(e, t) {
1709
1765
  let n = (e) => Array.from(e, (e) => e.toString(16).toUpperCase().padStart(2, "0")).join(" "), r = this._content().length, i = [{
1710
1766
  depth: e,
1711
- hex: n(m(2, BigInt(r))),
1767
+ hex: n(y(2, BigInt(r))),
1712
1768
  comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
1713
1769
  }];
1714
1770
  for (let n of this.items) i.push(...n._toHexDump(e + 1, t));
@@ -1717,24 +1773,40 @@ var O = class e extends d {
1717
1773
  _toJS(e) {
1718
1774
  return this._content();
1719
1775
  }
1720
- }, Pe = 999n, Fe = class extends S {
1776
+ }, Ne = 999n, M = class extends w {
1721
1777
  constructor(e, t) {
1722
- let n = t.length === 1 && t[0] instanceof N ? t[0] : new E(t);
1723
- super(Pe, new E([new N(e), n]));
1778
+ let n = t.length === 1 && t[0] instanceof I ? t[0] : new O(t);
1779
+ super(Ne, new O([new I(e), n]));
1724
1780
  }
1725
1781
  _toCDN(e, t) {
1782
+ if (e?.appStrings === !1) return super._toCDN(e, t);
1726
1783
  let n = this.content, r = n.items[0].value, i = n.items[1];
1727
- return i instanceof N ? `${r}${Te(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
1784
+ return i instanceof I ? `${r}${he(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
1728
1785
  }
1729
- }, Ie = 888n, A = class extends S {
1786
+ }, Pe = class extends _ {
1787
+ inner;
1788
+ ednSource;
1789
+ constructor(e, t) {
1790
+ super(), this.inner = e, this.ednSource = t;
1791
+ }
1792
+ _toCBOR(e) {
1793
+ return this.inner._toCBOR(e);
1794
+ }
1795
+ _toCDN(e, t) {
1796
+ return e?.appStrings === !1 ? this.inner._toCDN(e, t) : this.ednSource;
1797
+ }
1798
+ _toJS(e) {
1799
+ return this.inner._toJS(e);
1800
+ }
1801
+ }, Fe = 888n, N = class extends w {
1730
1802
  constructor(e) {
1731
- e === void 0 ? super(Ie, O.NULL) : super(Ie, new E(e));
1803
+ e === void 0 ? super(Fe, A.NULL) : super(Fe, new O(e));
1732
1804
  }
1733
1805
  _toCDN(e, t) {
1734
- return this.content instanceof O ? "..." : this.content instanceof E ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
1806
+ return this.content instanceof A ? "..." : this.content instanceof O ? this.content.items.map((n) => n._toCDN(e, t)).join(" + ") : super._toCDN(e, t);
1735
1807
  }
1736
- }, Le = 2n, Re = 3n, ze = 18446744073709551615n, Be = -(ze + 1n);
1737
- function Ve(e) {
1808
+ }, Ie = 2n, Le = 3n, Re = 18446744073709551615n, ze = -18446744073709551616n;
1809
+ function Be(e) {
1738
1810
  if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
1739
1811
  if (e === 0n) return new Uint8Array();
1740
1812
  let t = e.toString(16);
@@ -1743,16 +1815,16 @@ function Ve(e) {
1743
1815
  for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
1744
1816
  return n;
1745
1817
  }
1746
- function He(e) {
1818
+ function Ve(e) {
1747
1819
  let t = 0n;
1748
1820
  for (let n of e) t = t << 8n | BigInt(n);
1749
1821
  return t;
1750
1822
  }
1751
- var j = class extends S {
1823
+ var P = class extends w {
1752
1824
  bigValue;
1753
1825
  constructor(e) {
1754
- if (e <= ze) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
1755
- super(Le, new C(Ve(e))), this.bigValue = e;
1826
+ if (e <= Re) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
1827
+ super(Ie, new T(Be(e))), this.bigValue = e;
1756
1828
  }
1757
1829
  _toCDN(e, t) {
1758
1830
  return this.bigValue.toString();
@@ -1760,11 +1832,11 @@ var j = class extends S {
1760
1832
  _toJS(e) {
1761
1833
  return this.bigValue;
1762
1834
  }
1763
- }, M = class extends S {
1835
+ }, F = class extends w {
1764
1836
  bigValue;
1765
1837
  constructor(e) {
1766
- if (e >= Be) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
1767
- super(Re, new C(Ve(-1n - e))), this.bigValue = e;
1838
+ if (e >= ze) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
1839
+ super(Le, new T(Be(-1n - e))), this.bigValue = e;
1768
1840
  }
1769
1841
  _toCDN(e, t) {
1770
1842
  return this.bigValue.toString();
@@ -1775,25 +1847,30 @@ var j = class extends S {
1775
1847
  };
1776
1848
  //#endregion
1777
1849
  //#region src/cdn/parser.ts
1778
- function Ue(e, t) {
1779
- let n = new Me(e, { offset: t?.offset }), r = new nt(n, t?.extensions, t?.unresolvedExtension, t?.allowInvalidUtf8, t?.allowTrailing).parse();
1780
- return t?.preserveComments && Qe(r, n.comments, e), r;
1850
+ function He(e, t) {
1851
+ let n = new je(e, { offset: t?.offset }), r = new Qe(n, t ?? {}).parse();
1852
+ return t?.preserveComments && Je(r, n.comments, e), r;
1781
1853
  }
1782
- function We(e) {
1854
+ function Ue(e) {
1783
1855
  let t = e, n;
1784
- if (/[_][0-3i]$/.test(e)) {
1785
- let r = e[e.length - 1];
1786
- n = r === "i" ? "i" : Number(r), t = e.slice(0, -2);
1787
- }
1788
- return {
1856
+ return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
1789
1857
  numStr: t,
1790
- encodingWidth: n
1858
+ rawSuffix: n
1791
1859
  };
1792
1860
  }
1793
- function Ge(e) {
1861
+ function We(e) {
1794
1862
  return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
1795
1863
  }
1796
- function Ke(e) {
1864
+ function Ge(e, t) {
1865
+ if (e.endsWith("_i") || e.endsWith("_0")) {
1866
+ let n = "_0 and _i encoding indicators are not valid for floating-point values";
1867
+ if (t) t(n), e = e.slice(0, -2);
1868
+ else throw SyntaxError(`EDN parse error: ${n}`);
1869
+ } else if (/[_][4567]$/.test(e)) {
1870
+ let n = e[e.length - 1], r = n === "7" ? "indefinite-length encoding (_7) is not valid for floating-point values" : `encoding indicator _${n} (AI ${Number(n) + 24}) is reserved and not valid`;
1871
+ if (t) t(r), e = e.slice(0, -2);
1872
+ else throw SyntaxError(`EDN parse error: ${r}`);
1873
+ }
1797
1874
  if (e === "NaN") return {
1798
1875
  value: NaN,
1799
1876
  precision: void 0
@@ -1806,93 +1883,102 @@ function Ke(e) {
1806
1883
  value: -Infinity,
1807
1884
  precision: void 0
1808
1885
  };
1809
- if (e.endsWith("_i") || e.endsWith("_0")) throw SyntaxError("EDN parse error: _0 and _i encoding indicators are not valid for floating-point values");
1810
- let t = e, n;
1811
- return e.endsWith("_1") ? (n = "half", t = e.slice(0, -2)) : e.endsWith("_2") ? (n = "single", t = e.slice(0, -2)) : e.endsWith("_3") && (n = "double", t = e.slice(0, -2)), /^-?0[xX]/.test(t) ? {
1812
- value: ke(t),
1813
- precision: n
1886
+ let n = e, r;
1887
+ return e.endsWith("_1") ? (r = "half", n = e.slice(0, -2)) : e.endsWith("_2") ? (r = "single", n = e.slice(0, -2)) : e.endsWith("_3") && (r = "double", n = e.slice(0, -2)), /^-?0[xX]/.test(n) ? {
1888
+ value: Oe(n),
1889
+ precision: r
1814
1890
  } : {
1815
- value: parseFloat(t),
1816
- precision: n
1891
+ value: parseFloat(n),
1892
+ precision: r
1817
1893
  };
1818
1894
  }
1819
- function qe(e) {
1895
+ function Ke(e) {
1820
1896
  if (typeof Uint8Array.fromHex == "function") return Uint8Array.fromHex(e);
1821
1897
  if (e.length % 2 != 0) throw SyntaxError(`hex string has odd length: ${e.length}`);
1822
1898
  let t = new Uint8Array(e.length / 2);
1823
1899
  for (let n = 0; n < e.length; n += 2) t[n / 2] = parseInt(e.slice(n, n + 2), 16);
1824
1900
  return t;
1825
1901
  }
1826
- var Je = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", Ye = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
1827
- function Xe(e, t) {
1828
- let n = e.replace(/=+$/, "").toUpperCase(), r = n.length % 8;
1829
- if (r === 1 || r === 3 || r === 6) throw SyntaxError(`invalid base32 length: ${n.length} characters`);
1830
- let i = new Uint8Array(128).fill(255);
1831
- for (let e = 0; e < t.length; e++) i[t.charCodeAt(e)] = e;
1832
- let a = new Uint8Array(Math.floor(n.length * 5 / 8)), o = 0, s = 0, c = 0;
1833
- for (let e of n) {
1834
- let t = e.charCodeAt(0), n = t < 128 ? i[t] : 255;
1835
- if (n === 255) throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);
1836
- o = o << 5 | n, s += 5, s >= 8 && (s -= 8, a[c++] = o >> s & 255);
1837
- }
1838
- if (s > 0 && o & (1 << s) - 1) throw SyntaxError("non-zero trailing bits in base32 input");
1839
- return a;
1840
- }
1841
- function Ze(e) {
1842
- if (typeof Uint8Array.fromBase64 == "function") {
1843
- let t = /[-_]/.test(e) ? "base64url" : "base64";
1844
- return Uint8Array.fromBase64(e, {
1845
- alphabet: t,
1846
- lastChunkHandling: "loose"
1847
- });
1848
- }
1849
- let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = new Uint8Array(r.length);
1850
- for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
1851
- return i;
1902
+ function qe(e, t) {
1903
+ let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
1904
+ if (/[^A-Za-z0-9+/\-_]/.test(r)) {
1905
+ let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
1906
+ throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`);
1907
+ }
1908
+ if (i && !/^=+$/.test(i)) throw SyntaxError("invalid character after base64 '=' padding");
1909
+ let a = r.length % 4;
1910
+ if (a === 1) throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);
1911
+ let o = a === 0 ? 0 : 4 - a;
1912
+ if (i.length > o) {
1913
+ let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but the data length (${r.length}) requires at most ${o}`;
1914
+ if (t) t(e);
1915
+ else throw SyntaxError(e);
1916
+ }
1917
+ if (i.length > 0 && i.length < o) {
1918
+ let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but needs exactly ${o} — use full padding or no padding at all`;
1919
+ if (t) t(e);
1920
+ else throw SyntaxError(e);
1921
+ }
1922
+ if (a !== 0 && r.length > 0) {
1923
+ let e = r[r.length - 1].replace("-", "+").replace("_", "/"), n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e);
1924
+ if (n >= 0 && n & (a === 2 ? 15 : 3)) {
1925
+ let e = "base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)";
1926
+ if (t) t(e);
1927
+ else throw SyntaxError(e);
1928
+ }
1929
+ }
1930
+ let s = r.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat(o);
1931
+ if (typeof Uint8Array.fromBase64 == "function") return Uint8Array.fromBase64(s, {
1932
+ alphabet: "base64",
1933
+ lastChunkHandling: "loose"
1934
+ });
1935
+ let c = atob(s), l = new Uint8Array(c.length);
1936
+ for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
1937
+ return l;
1852
1938
  }
1853
- function Qe(e, t, n) {
1939
+ function Je(e, t, n) {
1854
1940
  if (t.length === 0) return;
1855
- let r = $e(e), i = tt(n);
1941
+ let r = Ye(e), i = Ze(n);
1856
1942
  for (let a of t) {
1857
1943
  let t = { ...a }, o = [...r].filter((e) => e.end <= a.start).sort((e, t) => t.end - e.end || t.start - e.start)[0], s = o ? n.slice(o.end, a.start) : "";
1858
1944
  if (o && i(o.end) === a.line && !s.includes(":")) {
1859
- et(o.node, "trailing", t);
1945
+ Xe(o.node, "trailing", t);
1860
1946
  continue;
1861
1947
  }
1862
1948
  let c = [...r].filter((e) => e.start < a.start && a.end < e.end).sort((e, t) => t.start - e.start || e.end - t.end)[0], l = [...r].filter((e) => e.start >= a.end).sort((e, t) => e.start - t.start || t.end - e.end)[0];
1863
1949
  if ((!c || l && l.end <= c.end) && l) {
1864
- et(l.node, "leading", t);
1950
+ Xe(l.node, "leading", t);
1865
1951
  continue;
1866
1952
  }
1867
- et(c?.node ?? e, "dangling", t);
1953
+ Xe(c?.node ?? e, "dangling", t);
1868
1954
  }
1869
1955
  }
1870
- function $e(e) {
1956
+ function Ye(e) {
1871
1957
  let t = [], n = (e) => {
1872
1958
  if (e.start !== void 0 && e.end !== void 0 && t.push({
1873
1959
  node: e,
1874
1960
  start: e.start,
1875
1961
  end: e.end
1876
- }), e instanceof E || e instanceof k) {
1962
+ }), e instanceof O || e instanceof j) {
1877
1963
  for (let t of e.items) n(t);
1878
1964
  return;
1879
1965
  }
1880
- if (e instanceof D) {
1966
+ if (e instanceof k) {
1881
1967
  for (let [t, r] of e.entries) n(t), n(r);
1882
1968
  return;
1883
1969
  }
1884
- if (e instanceof w || e instanceof T) {
1970
+ if (e instanceof E || e instanceof D) {
1885
1971
  for (let t of e.chunks) n(t);
1886
1972
  return;
1887
1973
  }
1888
- e instanceof S && n(e.content);
1974
+ e instanceof w && n(e.content);
1889
1975
  };
1890
1976
  return n(e), t;
1891
1977
  }
1892
- function et(e, t, n) {
1978
+ function Xe(e, t, n) {
1893
1979
  e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
1894
1980
  }
1895
- function tt(e) {
1981
+ function Ze(e) {
1896
1982
  let t = [0];
1897
1983
  for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
1898
1984
  return (n) => {
@@ -1906,28 +1992,42 @@ function tt(e) {
1906
1992
  return a + 1;
1907
1993
  };
1908
1994
  }
1909
- var nt = class {
1995
+ var Qe = class {
1910
1996
  t;
1911
- allowInvalidUtf8;
1912
- allowTrailing;
1997
+ _options;
1913
1998
  extByPrefix;
1914
1999
  extByTag;
1915
2000
  unresolvedExtension;
1916
- constructor(e, t, n, r, i) {
1917
- this.t = e, this.allowInvalidUtf8 = r, this.allowTrailing = i, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = n ?? "cpa999";
1918
- for (let e of [...Z, ...t ?? []]) {
2001
+ _pendingWarnings = [];
2002
+ constructor(e, t) {
2003
+ this.t = e, this._options = t, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = t.unresolvedExtension ?? "cpa999";
2004
+ for (let e of [...Z, ...t.extensions ?? []]) {
1919
2005
  for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
1920
2006
  for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
1921
2007
  }
2008
+ this.t.onEscapeWarning = (e, t, n, r) => {
2009
+ let i = {
2010
+ message: e,
2011
+ offset: t,
2012
+ line: n,
2013
+ column: r
2014
+ };
2015
+ if (this._pendingWarnings.push(i), this._options.onWarning ? this._options.onWarning(i) : this._options.silent || console.warn(`CDN strict violation at line ${n}, column ${r}: ${e}`), this._options.strict !== !1) throw SyntaxError(`EDN parse error at line ${n}, column ${r}: ${e}`);
2016
+ };
1922
2017
  }
1923
2018
  parse() {
1924
2019
  let e = this.parseValue();
1925
- if (this.allowTrailing) return e;
2020
+ if (this._options.allowTrailing) return e;
1926
2021
  let t = this.t.peek();
1927
2022
  return t.type !== "EOF" && this._fail(`unexpected token after value: ${JSON.stringify(t.value)}`, t), e;
1928
2023
  }
1929
2024
  parseValue() {
1930
2025
  let e = this.t.peek().offset, t = this._parseValueNode();
2026
+ if (this._pendingWarnings.length > 0) {
2027
+ t.warnings ??= [];
2028
+ for (let e of this._pendingWarnings) t.warnings.push(e);
2029
+ this._pendingWarnings = [];
2030
+ }
1931
2031
  return t.start = e, t.end = this.t.lastEndOffset, t;
1932
2032
  }
1933
2033
  _parseValueNode() {
@@ -1939,15 +2039,13 @@ var nt = class {
1939
2039
  case "RAWSTRING": return this.parseString();
1940
2040
  case "BYTES_HEX":
1941
2041
  case "SQSTR":
1942
- case "BYTES_B64":
1943
- case "BYTES_B32":
1944
- case "BYTES_H32": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
1945
- case "EMPTY_INDEF_BYTES": return this.t.consume(), new w([]);
1946
- case "EMPTY_INDEF_TEXT": return this.t.consume(), new T([]);
1947
- case "TRUE": return this.t.consume(), O.TRUE;
1948
- case "FALSE": return this.t.consume(), O.FALSE;
1949
- case "NULL": return this.t.consume(), O.NULL;
1950
- case "UNDEFINED": return this.t.consume(), O.UNDEFINED;
2042
+ case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
2043
+ case "EMPTY_INDEF_BYTES": return this.t.consume(), new E([]);
2044
+ case "EMPTY_INDEF_TEXT": return this.t.consume(), new D([]);
2045
+ case "TRUE": return this.t.consume(), A.TRUE;
2046
+ case "FALSE": return this.t.consume(), A.FALSE;
2047
+ case "NULL": return this.t.consume(), A.NULL;
2048
+ case "UNDEFINED": return this.t.consume(), A.UNDEFINED;
1951
2049
  case "SIMPLE": return this.parseSimple();
1952
2050
  case "LBRACKET": return this.parseArray();
1953
2051
  case "LBRACE": return this.parseMap();
@@ -1957,10 +2055,23 @@ var nt = class {
1957
2055
  this.t.consume();
1958
2056
  let t = this.extByPrefix.get(e.appPrefix);
1959
2057
  if (!t?.parseAppString) {
1960
- if (this.unresolvedExtension === "cpa999") return new Fe(e.appPrefix, [new N(e.value)]);
2058
+ if (this.unresolvedExtension === "cpa999") return new M(e.appPrefix, [new I(e.value)]);
1961
2059
  this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
1962
2060
  }
1963
- return t.parseAppString(e.appPrefix, e.value);
2061
+ {
2062
+ let n = this._pendingWarnings.length;
2063
+ try {
2064
+ let n = t.parseAppString(e.appPrefix, e.value, this._extOnError(e));
2065
+ return n instanceof T && Object.getPrototypeOf(n) === T.prototype && n.ednSource === void 0 ? new T(n.value, {
2066
+ ednEncoding: n.ednEncoding,
2067
+ encodingWidth: n.encodingWidth,
2068
+ ednSource: e.raw
2069
+ }) : (n instanceof C && n.ednSource === void 0 && (n.ednSource = e.raw), n);
2070
+ } catch (t) {
2071
+ if (this._options.strict !== !1) throw t;
2072
+ return this._pendingWarnings.length === n && this._warn(t instanceof Error ? t.message : String(t), e), new M(e.appPrefix, [new I(e.value)]);
2073
+ }
2074
+ }
1964
2075
  }
1965
2076
  case "APP_SEQUENCE": {
1966
2077
  this.t.consume();
@@ -1969,48 +2080,71 @@ var nt = class {
1969
2080
  this.expect("GT_GT");
1970
2081
  let n = this.extByPrefix.get(e.appPrefix);
1971
2082
  if (!n) {
1972
- if (this.unresolvedExtension === "cpa999") return new Fe(e.appPrefix, t);
2083
+ if (this.unresolvedExtension === "cpa999") return new M(e.appPrefix, t);
1973
2084
  this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
1974
2085
  }
1975
- return n.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e), n.parseAppSequence(e.appPrefix, t);
2086
+ n.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
2087
+ {
2088
+ let r = this._pendingWarnings.length;
2089
+ try {
2090
+ let r = n.parseAppSequence(e.appPrefix, t, this._extOnError(e)), i = this.t.source.slice(e.offset, this.t.lastEndOffset);
2091
+ if (r instanceof C) r.ednSource === void 0 && (r.ednSource = i);
2092
+ else if (n.preserveAppSeqSource) return new Pe(r, i);
2093
+ return r;
2094
+ } catch (n) {
2095
+ if (this._options.strict !== !1) throw n;
2096
+ return this._pendingWarnings.length === r && this._warn(n instanceof Error ? n.message : String(n), e), new M(e.appPrefix, t);
2097
+ }
2098
+ }
1976
2099
  }
1977
2100
  case "ELLIPSIS": {
1978
- if (this.t.consume(), this.t.peek().type !== "PLUS") return new A();
1979
- let e = [new A()];
2101
+ if (this.t.consume(), this.t.peek().type !== "PLUS") return new N();
2102
+ let e = [new N()];
1980
2103
  for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
1981
- return new A(e);
2104
+ return new N(e);
1982
2105
  }
1983
2106
  case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
1984
2107
  default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
1985
2108
  }
1986
2109
  }
1987
2110
  parseIntegerOrTag() {
1988
- let e = this.t.consume(), { numStr: t, encodingWidth: n } = We(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : n, i = Ge(t);
1989
- if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new j(i);
1990
- if (i < -18446744073709551616n) return new M(i);
1991
- let a = i >= 0n ? new g(i, r === void 0 ? void 0 : { encodingWidth: r }) : new _(i, r === void 0 ? void 0 : { encodingWidth: r });
2111
+ let e = this.t.consume(), { numStr: t, rawSuffix: n } = Ue(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = We(t);
2112
+ if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new P(i);
2113
+ if (i < -18446744073709551616n) return new F(i);
2114
+ if (r !== void 0) {
2115
+ let t = i >= 0n ? i : -(i + 1n);
2116
+ r = this._validateEncodingFit(t, r, e);
2117
+ }
2118
+ let a = i >= 0n ? new x(i, r === void 0 ? void 0 : { encodingWidth: r }) : new S(i, r === void 0 ? void 0 : { encodingWidth: r });
1992
2119
  if (this.t.peek().type === "LPAREN") {
1993
- a instanceof g || this._fail("tag number must be non-negative", e), this.t.consume();
1994
- let t = this.parseValue();
2120
+ a instanceof x || this._fail("tag number must be non-negative", e), this.t.consume();
2121
+ let t = this._pendingWarnings.splice(0), n = this.parseValue();
1995
2122
  this.expect("RPAREN");
1996
- let n = a.value, i = this.extByTag.get(n);
1997
- if (i?.parseTag) {
1998
- let e = i.parseTag(n, t);
1999
- if (e !== void 0) return e;
2123
+ let i = a.value, o = this.extByTag.get(i);
2124
+ if (o?.parseTag) {
2125
+ let e = o.parseTag(i, n);
2126
+ if (e !== void 0) return t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
2000
2127
  }
2001
- return new S(n, t, r === void 0 ? void 0 : { encodingWidth: r });
2128
+ let s = new w(i, n, r === void 0 ? void 0 : { encodingWidth: r });
2129
+ return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
2002
2130
  }
2003
2131
  return a;
2004
2132
  }
2005
2133
  parseFloat() {
2006
- let { value: e, precision: t } = Ke(this.t.consume().value);
2007
- return new x(e, t === void 0 ? void 0 : { precision: t });
2134
+ let e = this.t.consume(), t = (t) => {
2135
+ this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
2136
+ }, { value: n, precision: r } = Ge(e.value, t);
2137
+ if (r === "half" || r === "single") {
2138
+ let e = r === "half" ? v(xe(n)) : Math.fround(n);
2139
+ Object.is(n, e) || isNaN(n) && isNaN(e) || t(`${n} cannot be exactly represented as ${r === "half" ? "f16 (_1)" : "f32 (_2)"}; use _3 or remove the indicator`);
2140
+ }
2141
+ return new C(n, r === void 0 ? void 0 : { precision: r });
2008
2142
  }
2009
2143
  parseString() {
2010
2144
  let e = this.t.consume();
2011
2145
  if (this.t.peek().type !== "PLUS") {
2012
- let t = this.consumeEncodingIndicator();
2013
- return new N(e.value, t === void 0 ? void 0 : { encodingWidth: t });
2146
+ let t = BigInt(new TextEncoder().encode(e.value).length), n = this.consumeEncodingIndicator(t);
2147
+ return new I(e.value, n === void 0 ? void 0 : { encodingWidth: n });
2014
2148
  }
2015
2149
  let t = !1, n = [{ text: e.value }];
2016
2150
  for (; this.t.peek().type === "PLUS";) {
@@ -2019,46 +2153,43 @@ var nt = class {
2019
2153
  e.type === "ELLIPSIS" ? (this.t.consume(), n.push({ ellipsis: !0 }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push({ text: e.value })) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({ text: this._decodeUtf8(this._decodeBytesToken(e), e) })) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
2020
2154
  }
2021
2155
  if (!t) {
2022
- let e = this.consumeEncodingIndicator();
2023
- return new N(n.map((e) => "text" in e ? e.text : "").join(""), e === void 0 ? void 0 : { encodingWidth: e });
2156
+ let e = n.map((e) => "text" in e ? e.text : "").join(""), t = BigInt(new TextEncoder().encode(e).length), r = this.consumeEncodingIndicator(t);
2157
+ return new I(e, r === void 0 ? void 0 : { encodingWidth: r });
2024
2158
  }
2025
2159
  let r = [], i = "";
2026
- for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new N(i)), i = ""), r.push(new A())) : i += e.text;
2027
- return i !== "" && r.push(new N(i)), new A(r);
2160
+ for (let e of n) "ellipsis" in e ? (i !== "" && (r.push(new I(i)), i = ""), r.push(new N())) : i += e.text;
2161
+ return i !== "" && r.push(new I(i)), new N(r);
2028
2162
  }
2029
2163
  _isBytesToken(e) {
2030
- return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64" || e === "BYTES_B32" || e === "BYTES_H32";
2164
+ return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
2031
2165
  }
2032
2166
  _decodeBytesToken(e) {
2167
+ let t = (t) => {
2168
+ this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
2169
+ };
2033
2170
  switch (e.type) {
2034
2171
  case "BYTES_HEX":
2035
- case "SQSTR": return qe(e.value);
2036
- case "BYTES_B64": return Ze(e.value);
2037
- case "BYTES_B32": return Xe(e.value, Je);
2038
- case "BYTES_H32": return Xe(e.value, Ye);
2172
+ case "SQSTR": return Ke(e.value);
2173
+ case "BYTES_B64": return qe(e.value, t);
2039
2174
  default: this._fail("expected byte string token", e);
2040
2175
  }
2041
2176
  }
2042
2177
  _decodeUtf8(e, t) {
2043
- if (this.allowInvalidUtf8) return new TextDecoder("utf-8", { fatal: !1 }).decode(e);
2178
+ if (this._options.allowInvalidUtf8) return new TextDecoder("utf-8", { fatal: !1 }).decode(e);
2044
2179
  try {
2045
2180
  return new TextDecoder("utf-8", { fatal: !0 }).decode(e);
2046
2181
  } catch {
2047
- this._fail("byte string in text concatenation is not valid UTF-8", t);
2182
+ let n = "byte string in text concatenation is not valid UTF-8";
2183
+ return this._warn(n, t), this._options.strict !== !1 && this._fail(n, t), new TextDecoder("utf-8", { fatal: !1 }).decode(e);
2048
2184
  }
2049
2185
  }
2050
2186
  _tokenTypeToCdnEncoding(e) {
2051
- switch (e) {
2052
- case "BYTES_B64": return "base64";
2053
- case "BYTES_B32": return "base32";
2054
- case "BYTES_H32": return "base32hex";
2055
- default: return "hex";
2056
- }
2187
+ return e === "BYTES_B64" ? "base64" : "hex";
2057
2188
  }
2058
2189
  _parseBytesConcat(e, t, n) {
2059
2190
  if (this.t.peek().type !== "PLUS") {
2060
- let r = this.consumeEncodingIndicator();
2061
- return new C(e, {
2191
+ let r = this.consumeEncodingIndicator(BigInt(e.length));
2192
+ return new T(e, {
2062
2193
  ednEncoding: this._tokenTypeToCdnEncoding(t),
2063
2194
  ednSource: n,
2064
2195
  ...r === void 0 ? {} : { encodingWidth: r }
@@ -2072,25 +2203,30 @@ var nt = class {
2072
2203
  else if (e.type === "BYTES_HEX_ELIDED") {
2073
2204
  this.t.consume();
2074
2205
  let t = this._buildBytesElidedItems(e.value);
2075
- for (let e of t) e instanceof A ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof C && i.push({ bytes: e.value });
2076
- } else this._isBytesToken(e.type) ? (this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), i.push({ bytes: new TextEncoder().encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
2206
+ for (let e of t) e instanceof N ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof T && i.push({ bytes: e.value });
2207
+ } else if (this._isBytesToken(e.type)) this.t.consume(), i.push({ bytes: this._decodeBytesToken(e) });
2208
+ else if (e.type === "TSTR" || e.type === "RAWSTRING") {
2209
+ this.t.consume();
2210
+ let t = "text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead";
2211
+ this._warn(t, e), this._options.strict !== !1 && this._fail(t, e), i.push({ bytes: new TextEncoder().encode(e.value) });
2212
+ } else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
2077
2213
  }
2078
2214
  if (!r) {
2079
- let e = this.consumeEncodingIndicator(), t = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array());
2080
- return new C(this._concatBytes(t), e === void 0 ? void 0 : { encodingWidth: e });
2215
+ let e = i.map((e) => "bytes" in e ? e.bytes : new Uint8Array()), t = this._concatBytes(e), n = this.consumeEncodingIndicator(BigInt(t.length));
2216
+ return new T(t, n === void 0 ? void 0 : { encodingWidth: n });
2081
2217
  }
2082
2218
  let a = [], o = [], s = () => {
2083
- o.length > 0 && (a.push(new C(this._concatBytes([...o]))), o.length = 0);
2219
+ o.length > 0 && (a.push(new T(this._concatBytes([...o]))), o.length = 0);
2084
2220
  };
2085
- for (let e of i) "ellipsis" in e ? (s(), a.push(new A())) : o.push(e.bytes);
2086
- return s(), new A(a);
2221
+ for (let e of i) "ellipsis" in e ? (s(), a.push(new N())) : o.push(e.bytes);
2222
+ return s(), new N(a);
2087
2223
  }
2088
2224
  _parseHexElidedConcat(e) {
2089
2225
  let t = this._buildBytesElidedItems(e.value);
2090
2226
  for (; this.t.peek().type === "PLUS";) {
2091
2227
  this.t.consume();
2092
2228
  let e = this.t.peek();
2093
- if (e.type === "ELLIPSIS") this.t.consume(), t.push(new A());
2229
+ if (e.type === "ELLIPSIS") this.t.consume(), t.push(new N());
2094
2230
  else if (e.type === "BYTES_HEX_ELIDED") {
2095
2231
  this.t.consume();
2096
2232
  let n = this._buildBytesElidedItems(e.value);
@@ -2098,20 +2234,20 @@ var nt = class {
2098
2234
  } else if (this._isBytesToken(e.type)) {
2099
2235
  this.t.consume();
2100
2236
  let n = this._decodeBytesToken(e), r = t[t.length - 1];
2101
- r instanceof C ? t[t.length - 1] = new C(this._concatBytes([r.value, n])) : t.push(new C(n));
2237
+ r instanceof T ? t[t.length - 1] = new T(this._concatBytes([r.value, n])) : t.push(new T(n));
2102
2238
  } else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
2103
2239
  }
2104
- return new A(t);
2240
+ return new N(t);
2105
2241
  }
2106
2242
  _buildBytesElidedItems(e) {
2107
2243
  let t = e.split("..."), n = [];
2108
- for (let e = 0; e < t.length; e++) e > 0 && n.push(new A()), t[e].length > 0 && n.push(new C(qe(t[e])));
2244
+ for (let e = 0; e < t.length; e++) e > 0 && n.push(new N()), t[e].length > 0 && n.push(new T(Ke(t[e])));
2109
2245
  return n;
2110
2246
  }
2111
2247
  _mergeFirstBytesItem(e, t) {
2112
2248
  if (t.length === 0) return;
2113
2249
  let n = e[e.length - 1], r = t[0];
2114
- n instanceof C && r instanceof C ? (e[e.length - 1] = new C(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
2250
+ n instanceof T && r instanceof T ? (e[e.length - 1] = new T(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
2115
2251
  }
2116
2252
  _concatBytes(e) {
2117
2253
  let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
@@ -2122,83 +2258,144 @@ var nt = class {
2122
2258
  this.t.consume(), this.expect("LPAREN");
2123
2259
  let e = this.t.peek();
2124
2260
  e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
2125
- let { numStr: t } = We(e.value), n = Number(Ge(t));
2126
- return this.expect("RPAREN"), new O(n);
2261
+ let { numStr: t } = Ue(e.value), n = Number(We(t));
2262
+ return this.expect("RPAREN"), new A(n);
2127
2263
  }
2128
2264
  parseEmbeddedCBOR() {
2129
2265
  this.t.consume();
2130
2266
  let e = [];
2131
2267
  for (; this.t.peek().type !== "GT_GT" && !(e.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "GT_GT"));) e.push(this.parseValue());
2132
- return this.expect("GT_GT"), new k(e);
2268
+ return this.expect("GT_GT"), new j(e);
2133
2269
  }
2134
2270
  parseArray() {
2135
2271
  this.t.consume();
2136
- let e = !1, t;
2272
+ let e = !1, t, n;
2137
2273
  if (this.t.peek().type === "UNDERSCORE") this.t.consume(), e = !0;
2138
- else if (this.t.peek().type === "ENCODING_INDICATOR") {
2139
- let e = this.t.consume().value;
2140
- t = e === "i" ? "i" : Number(e);
2141
- }
2142
- let n = [];
2143
- for (; this.t.peek().type !== "RBRACKET" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACKET"));) n.push(this.parseValue());
2144
- return this.expect("RBRACKET"), new E(n, {
2274
+ else if (this.t.peek().type === "ENCODING_INDICATOR") if (n = this.t.consume(), n.value === "7") {
2275
+ e = !0;
2276
+ let t = "encoding indicator _7 is non-standard; use _ to indicate indefinite length";
2277
+ this._warn(t, n), this._options.strict !== !1 && this._fail(t, n), n = void 0;
2278
+ } else t = this._resolveEncodingWidth(n.value, n);
2279
+ let r = this._pendingWarnings.splice(0), i = [];
2280
+ for (; this.t.peek().type !== "RBRACKET" && !(i.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACKET"));) i.push(this.parseValue());
2281
+ this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
2282
+ let a = new O(i, {
2145
2283
  indefiniteLength: e,
2146
2284
  encodingWidth: t
2147
2285
  });
2286
+ return r.length > 0 && (a.warnings ??= [], a.warnings.push(...r)), a;
2148
2287
  }
2149
2288
  parseMap() {
2150
2289
  this.t.consume();
2151
- let e = !1, t;
2290
+ let e = !1, t, n;
2152
2291
  if (this.t.peek().type === "UNDERSCORE") this.t.consume(), e = !0;
2153
- else if (this.t.peek().type === "ENCODING_INDICATOR") {
2154
- let e = this.t.consume().value;
2155
- t = e === "i" ? "i" : Number(e);
2156
- }
2157
- let n = [];
2158
- for (; this.t.peek().type !== "RBRACE" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACE"));) {
2292
+ else if (this.t.peek().type === "ENCODING_INDICATOR") if (n = this.t.consume(), n.value === "7") {
2293
+ e = !0;
2294
+ let t = "encoding indicator _7 is non-standard; use _ to indicate indefinite length";
2295
+ this._warn(t, n), this._options.strict !== !1 && this._fail(t, n), n = void 0;
2296
+ } else t = this._resolveEncodingWidth(n.value, n);
2297
+ let r = this._pendingWarnings.splice(0), i = [];
2298
+ for (; this.t.peek().type !== "RBRACE" && !(i.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RBRACE"));) {
2159
2299
  let e = this.parseValue();
2160
2300
  this.expect("COLON");
2161
2301
  let t = this.parseValue();
2162
- n.push([e, t]);
2302
+ i.push([e, t]);
2163
2303
  }
2164
- return this.expect("RBRACE"), new D(n, {
2304
+ this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
2305
+ let a = new k(i, {
2165
2306
  indefiniteLength: e,
2166
2307
  encodingWidth: t
2167
2308
  });
2309
+ return r.length > 0 && (a.warnings ??= [], a.warnings.push(...r)), a;
2168
2310
  }
2169
2311
  parseIndefGroup() {
2170
2312
  this.t.consume();
2171
2313
  let e = this.t.peek();
2172
- e.type !== "UNDERSCORE" && this._fail(`expected _ after (, got ${JSON.stringify(e.value)}`, e), this.t.consume();
2173
- let t = [];
2174
- for (; this.t.peek().type !== "RPAREN" && !(t.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RPAREN"));) t.push(this.parseValue());
2175
- this.expect("RPAREN"), t.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
2176
- let n = t[0];
2177
- if (n instanceof C) return new w(t.map((e, t) => {
2178
- if (e instanceof C) return e;
2179
- this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
2180
- }));
2181
- if (n instanceof N) return new T(t.map((e, t) => {
2182
- if (e instanceof N) return e;
2183
- this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
2184
- }));
2314
+ if (e.type === "UNDERSCORE") this.t.consume();
2315
+ else if (e.type === "ENCODING_INDICATOR" && e.value === "7") {
2316
+ this.t.consume();
2317
+ let t = "encoding indicator _7 is non-standard; use _ to indicate indefinite length";
2318
+ this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
2319
+ } else if (e.type === "ENCODING_INDICATOR") {
2320
+ let e = this.t.consume(), t = `encoding indicator _${e.value} is not valid in an indefinite string group; use _`;
2321
+ this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
2322
+ } else if (e.type !== "RPAREN") {
2323
+ let t = "indefinite string group is missing _ after (; interpreting as (_ ...)";
2324
+ this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
2325
+ }
2326
+ let t = this._pendingWarnings.splice(0), n = [];
2327
+ for (; this.t.peek().type !== "RPAREN" && !(n.length > 0 && this.t.peek().type === "COMMA" && (this.t.consume(), this.t.peek().type === "RPAREN"));) n.push(this.parseValue());
2328
+ this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
2329
+ let r = n[0];
2330
+ if (r instanceof T) {
2331
+ let e = new E(n.map((e, t) => {
2332
+ if (e instanceof T) return e;
2333
+ this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
2334
+ }));
2335
+ return t.length > 0 && (e.warnings = t), e;
2336
+ }
2337
+ if (r instanceof I) {
2338
+ let e = new D(n.map((e, t) => {
2339
+ if (e instanceof I) return e;
2340
+ this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
2341
+ }));
2342
+ return t.length > 0 && (e.warnings = t), e;
2343
+ }
2185
2344
  this._fail("indefinite group chunks must be byte strings or text strings");
2186
2345
  }
2187
- consumeEncodingIndicator() {
2346
+ consumeEncodingIndicator(e) {
2188
2347
  if (this.t.peek().type === "ENCODING_INDICATOR") {
2189
- let e = this.t.consume().value;
2190
- return e === "i" ? "i" : Number(e);
2348
+ let t = this.t.consume(), n = this._resolveEncodingWidth(t.value, t);
2349
+ return n !== void 0 && e !== void 0 && (n = this._validateEncodingFit(e, n, t)), n;
2191
2350
  }
2192
2351
  }
2193
2352
  expect(e) {
2194
2353
  let t = this.t.consume();
2195
2354
  return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
2196
2355
  }
2356
+ _validateEncodingFit(e, t, n) {
2357
+ let r = {
2358
+ i: 23n,
2359
+ 0: 255n,
2360
+ 1: 65535n,
2361
+ 2: 4294967295n,
2362
+ 3: 18446744073709551615n
2363
+ };
2364
+ if (e <= r[t]) return t;
2365
+ let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r[t]})`}`;
2366
+ this._warn(i, n), this._options.strict !== !1 && this._fail(i, n);
2367
+ }
2368
+ _resolveEncodingWidth(e, t) {
2369
+ if (e === "4" || e === "5" || e === "6") {
2370
+ let n = `encoding indicator _${e} (AI ${Number(e) + 24}) is reserved and not valid`;
2371
+ this._warn(n, t), this._options.strict !== !1 && this._fail(n, t);
2372
+ return;
2373
+ }
2374
+ if (e === "7") {
2375
+ let e = "indefinite-length encoding (_7) is not valid here; use [_ ...] or {_ ...} for indefinite collections";
2376
+ this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
2377
+ return;
2378
+ }
2379
+ return e === "i" ? "i" : Number(e);
2380
+ }
2381
+ _extOnError(e) {
2382
+ return (t) => {
2383
+ this._warn(t, e), this._options.strict !== !1 && this._fail(t, e);
2384
+ };
2385
+ }
2386
+ _warn(e, t) {
2387
+ let n = { message: e };
2388
+ if (t !== void 0 && (n.offset = t.offset, n.line = t.line, n.column = t.col), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
2389
+ else if (!this._options.silent) {
2390
+ let n = t ? ` at line ${t.line}, column ${t.col}` : "";
2391
+ console.warn(`CDN strict violation${n}: ${e}`);
2392
+ }
2393
+ }
2197
2394
  _fail(e, t) {
2198
2395
  let n = t ? ` at line ${t.line}, column ${t.col}` : "";
2199
2396
  throw SyntaxError(`EDN parse error${n}: ${e}`);
2200
2397
  }
2201
- }, rt = new TextEncoder(), it = !1, N = class extends d {
2398
+ }, $e = new TextEncoder(), et = !1, I = class extends _ {
2202
2399
  indefiniteLength = !1;
2203
2400
  value;
2204
2401
  encodingWidth;
@@ -2206,42 +2403,42 @@ var nt = class {
2206
2403
  super(), this.value = e, this.encodingWidth = t?.encodingWidth;
2207
2404
  }
2208
2405
  _toCBOR(e) {
2209
- let t = rt.encode(this.value);
2210
- return h([m(3, BigInt(t.length), this.encodingWidth), t]);
2406
+ let t = $e.encode(this.value);
2407
+ return b([y(3, BigInt(t.length), this.encodingWidth), t]);
2211
2408
  }
2212
2409
  _toCDN(e, t) {
2213
2410
  let n = this.encodingWidth === void 0 ? "" : `_${this.encodingWidth}`;
2214
- return at(this.value, n, e, t);
2411
+ return tt(this.value, n, e, t);
2215
2412
  }
2216
2413
  _toJS(e) {
2217
2414
  return this.value;
2218
2415
  }
2219
2416
  };
2220
- function at(e, t, n, r) {
2221
- let i = ot(n?.textStringFormat ?? []), a = v(n);
2222
- if (i.length === 0 || a === null) return b(e) + t;
2417
+ function tt(e, t, n, r) {
2418
+ let i = nt(n?.textStringFormat ?? []), a = d(n);
2419
+ if (i.length === 0 || a === null) return ge(e) + t;
2223
2420
  let o = /* @__PURE__ */ new Map(), s = null;
2224
- if (i.includes("cdn") && (s = ct(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
2421
+ if (i.includes("cdn") && (s = it(e), s !== null)) for (let { point: e, contentDepth: t } of s) o.set(e, t);
2225
2422
  if (i.includes("newline")) {
2226
- let t = s === null ? st(e, 0) : lt(e);
2423
+ let t = s === null ? rt(e, 0) : at(e);
2227
2424
  for (let { point: e, contentDepth: n } of t) o.has(e) || o.set(e, n);
2228
2425
  }
2229
- let c = gt(e, o);
2230
- if (c.length <= 1) return b(e) + t;
2426
+ let c = ft(e, o);
2427
+ if (c.length <= 1) return ge(e) + t;
2231
2428
  let l = c.map(({ text: e }, n) => {
2232
- let r = b(e);
2429
+ let r = ge(e);
2233
2430
  return n === c.length - 1 ? r + t : r;
2234
2431
  }), u = l[0];
2235
2432
  for (let e = 1; e < l.length; e++) {
2236
- let t = y(a, r + 1 + c[e].contentDepth);
2433
+ let t = f(a, r + 1 + c[e].contentDepth);
2237
2434
  u += ` +\n${t}${l[e]}`;
2238
2435
  }
2239
2436
  return u;
2240
2437
  }
2241
- function ot(e) {
2242
- return e.map((e) => e === "cboredn" ? (it || (it = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
2438
+ function nt(e) {
2439
+ return e.map((e) => e === "cboredn" ? (et || (et = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
2243
2440
  }
2244
- function st(e, t) {
2441
+ function rt(e, t) {
2245
2442
  let n = [];
2246
2443
  for (let r = 0; r < e.length; r++) {
2247
2444
  let i = e[r];
@@ -2258,35 +2455,35 @@ function st(e, t) {
2258
2455
  }
2259
2456
  return n;
2260
2457
  }
2261
- function ct(e) {
2458
+ function it(e) {
2262
2459
  try {
2263
- Ue(e);
2460
+ He(e);
2264
2461
  } catch {
2265
2462
  return null;
2266
2463
  }
2267
- let t = [], n = new Me(e), r = 0, i = null, a = !1, o = 0;
2464
+ let t = [], n = new je(e), r = 0, i = null, a = !1, o = 0;
2268
2465
  for (;;) {
2269
2466
  let s = n.consume();
2270
2467
  if (s.type === "EOF") break;
2271
2468
  let c = !1;
2272
- if (a || (a = !0, s.offset > 0 && mt(n.comments, 0, s.offset) && t.push({
2469
+ if (a || (a = !0, s.offset > 0 && ut(n.comments, 0, s.offset) && t.push({
2273
2470
  point: s.offset,
2274
2471
  contentDepth: r
2275
2472
  })), i !== null) {
2276
- if (i.kind === "opener" && dt.has(s.type)) {
2473
+ if (i.kind === "opener" && st.has(s.type)) {
2277
2474
  i.point = s.endOffset, o = s.endOffset;
2278
2475
  continue;
2279
- } else i.kind === "opener" && pt.has(s.type) && ht(e, i.point, s.offset) ? c = !0 : t.push({
2476
+ } else i.kind === "opener" && lt.has(s.type) && dt(e, i.point, s.offset) ? c = !0 : t.push({
2280
2477
  point: s.offset,
2281
2478
  contentDepth: i.contentDepth
2282
2479
  });
2283
2480
  i = null;
2284
2481
  }
2285
- ft.has(s.type) ? (r++, i = {
2482
+ ct.has(s.type) ? (r++, i = {
2286
2483
  point: s.endOffset,
2287
2484
  contentDepth: r,
2288
2485
  kind: "opener"
2289
- }) : pt.has(s.type) ? (r = Math.max(0, r - 1), c || t.push({
2486
+ }) : lt.has(s.type) ? (r = Math.max(0, r - 1), c || t.push({
2290
2487
  point: s.offset,
2291
2488
  contentDepth: r
2292
2489
  })) : s.type === "COMMA" && (i = {
@@ -2301,41 +2498,65 @@ function ct(e) {
2301
2498
  contentDepth: r
2302
2499
  }), t;
2303
2500
  }
2304
- function lt(e) {
2305
- let t = [], n = new Me(e), r = 0;
2501
+ function at(e) {
2502
+ let t = [], n = new je(e), r = 0;
2306
2503
  for (;;) {
2307
2504
  let i = n.consume();
2308
2505
  if (i.type === "EOF") break;
2309
- if (ft.has(i.type)) r++;
2310
- else if (pt.has(i.type)) r = Math.max(0, r - 1);
2311
- else if (i.type !== "COMMA" && ut.has(i.type)) {
2312
- let n = e.slice(i.offset, i.endOffset);
2313
- for (let { point: e } of st(n, 0)) t.push({
2314
- point: i.offset + e,
2315
- contentDepth: r + 1
2316
- });
2506
+ if (ct.has(i.type)) r++;
2507
+ else if (lt.has(i.type)) r = Math.max(0, r - 1);
2508
+ else if (i.type !== "COMMA") {
2509
+ if (i.type === "TSTR") {
2510
+ let n = e.slice(i.offset, i.endOffset);
2511
+ for (let e of ot(n)) t.push({
2512
+ point: i.offset + e,
2513
+ contentDepth: r + 1
2514
+ });
2515
+ } else if (i.type === "RAWSTRING") {
2516
+ let n = e.slice(i.offset, i.endOffset);
2517
+ for (let { point: e } of rt(n, 0)) t.push({
2518
+ point: i.offset + e,
2519
+ contentDepth: r + 1
2520
+ });
2521
+ }
2317
2522
  }
2318
2523
  }
2319
2524
  return t;
2320
2525
  }
2321
- var ut = new Set(["TSTR", "RAWSTRING"]), dt = new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), ft = new Set([
2526
+ function ot(e) {
2527
+ let t = [], n = 1, r = e.length - 1;
2528
+ for (; n < r;) {
2529
+ let r = e[n];
2530
+ if (r === "\\") {
2531
+ let r = e[n + 1];
2532
+ if (r === "n" || r === "r") t.push(n + 2), n += 2;
2533
+ else if (r === "u") if (e[n + 2] === "{") {
2534
+ let t = e.indexOf("}", n + 3);
2535
+ n = t >= 0 ? t + 1 : n + 2;
2536
+ } else n += 6;
2537
+ else n += 2;
2538
+ } else r === "\r" ? e[n + 1] === "\n" ? (t.push(n + 2), n += 2) : (t.push(n + 1), n++) : (r === "\n" && t.push(n + 1), n++);
2539
+ }
2540
+ return t;
2541
+ }
2542
+ var st = new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), ct = new Set([
2322
2543
  "LBRACKET",
2323
2544
  "LBRACE",
2324
2545
  "LPAREN",
2325
2546
  "LT_LT"
2326
- ]), pt = new Set([
2547
+ ]), lt = new Set([
2327
2548
  "RBRACKET",
2328
2549
  "RBRACE",
2329
2550
  "RPAREN",
2330
2551
  "GT_GT"
2331
2552
  ]);
2332
- function mt(e, t, n) {
2553
+ function ut(e, t, n) {
2333
2554
  return e.some((e) => e.start >= t && e.end <= n);
2334
2555
  }
2335
- function ht(e, t, n) {
2556
+ function dt(e, t, n) {
2336
2557
  return /^[\t\n\r ]*$/.test(e.slice(t, n));
2337
2558
  }
2338
- function gt(e, t) {
2559
+ function ft(e, t) {
2339
2560
  let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
2340
2561
  if (n.length === 0) return [{
2341
2562
  text: e,
@@ -2353,7 +2574,7 @@ function gt(e, t) {
2353
2574
  }
2354
2575
  //#endregion
2355
2576
  //#region src/extensions/dt.ts
2356
- function P(e) {
2577
+ function L(e) {
2357
2578
  if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
2358
2579
  let t = Math.round(e * 1e3);
2359
2580
  if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
@@ -2361,96 +2582,102 @@ function P(e) {
2361
2582
  for (; s.length < 3;) s += "0";
2362
2583
  return `${i}.${s}Z`;
2363
2584
  }
2364
- function _t(e) {
2585
+ function pt(e) {
2365
2586
  if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
2366
2587
  let t = e[0];
2367
- if (t instanceof N) return t.value;
2368
- if (t instanceof C) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
2588
+ if (t instanceof I) return t.value;
2589
+ if (t instanceof T) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
2369
2590
  throw SyntaxError("dt<<...>>: expected a text string or byte string");
2370
2591
  }
2371
- function vt(e) {
2372
- let t = e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i), n, r;
2373
- t ? (n = t[1] + t[3], r = parseFloat("0" + t[2])) : (n = e, r = void 0);
2374
- let i = Date.parse(n);
2375
- if (isNaN(i)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
2376
- if (r === void 0) {
2377
- let e = i / 1e3;
2378
- return e >= 0 ? new bt(BigInt(e)) : new xt(BigInt(e));
2592
+ var mt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
2593
+ function ht(e, t) {
2594
+ if (!mt.test(e)) {
2595
+ let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
2596
+ if (t) t(n);
2597
+ else throw SyntaxError(n);
2379
2598
  }
2380
- return new St(i / 1e3 + r);
2599
+ let n = e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i), r, i;
2600
+ n ? (r = n[1] + n[3], i = parseFloat("0" + n[2])) : (r = e, i = void 0);
2601
+ let a = Date.parse(r);
2602
+ if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
2603
+ if (i === void 0) {
2604
+ let e = a / 1e3;
2605
+ return e >= 0 ? new _t(BigInt(e)) : new vt(BigInt(e));
2606
+ }
2607
+ return new yt(a / 1e3 + i);
2381
2608
  }
2382
- var yt = 1n, bt = class extends g {
2609
+ var gt = 1n, _t = class extends x {
2383
2610
  constructor(e, t) {
2384
2611
  super(e, t);
2385
2612
  }
2386
2613
  _toCDN(e, t) {
2387
- return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${P(Number(this.value))}'`;
2614
+ return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${L(Number(this.value))}'`;
2388
2615
  }
2389
- }, xt = class extends _ {
2616
+ }, vt = class extends S {
2390
2617
  constructor(e, t) {
2391
2618
  super(e, t);
2392
2619
  }
2393
2620
  _toCDN(e, t) {
2394
- return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${P(Number(this.value))}'`;
2621
+ return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${L(Number(this.value))}'`;
2395
2622
  }
2396
- }, St = class extends x {
2623
+ }, yt = class extends C {
2397
2624
  constructor(e, t) {
2398
2625
  super(e, t);
2399
2626
  }
2400
2627
  _toCDN(e, t) {
2401
- return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${P(this.value)}'`;
2628
+ return e?.appStrings === !1 ? super._toCDN(e, t) : `dt'${L(this.value)}'`;
2402
2629
  }
2403
- }, Ct = class extends S {
2630
+ }, bt = class extends w {
2404
2631
  constructor(e, t) {
2405
- super(yt, vt(e), t);
2632
+ super(gt, ht(e), t);
2406
2633
  }
2407
2634
  _toCDN(e, t) {
2408
2635
  if (e?.appStrings === !1) return super._toCDN(e, t);
2409
2636
  let n = this.content;
2410
- return `DT'${P(n instanceof x ? n.value : Number(n.value))}'`;
2637
+ return `DT'${L(n instanceof C ? n.value : Number(n.value))}'`;
2411
2638
  }
2412
- }, wt = class extends Ct {
2639
+ }, xt = class extends bt {
2413
2640
  constructor(e, t) {
2414
2641
  super(e, t);
2415
2642
  }
2416
2643
  _toJS(e) {
2417
- let t = this.content, n = t instanceof x ? t.value * 1e3 : Number(t.value) * 1e3;
2644
+ let t = this.content, n = t instanceof C ? t.value * 1e3 : Number(t.value) * 1e3;
2418
2645
  return new Date(n);
2419
2646
  }
2420
2647
  };
2421
- function Tt(e) {
2648
+ function St(e) {
2422
2649
  let t = e?.jsDate ?? !1;
2423
2650
  function n(e) {
2424
- return t ? new wt(e) : new Ct(e);
2651
+ return t ? new xt(e) : new bt(e);
2425
2652
  }
2426
2653
  let r = {
2427
2654
  appStringPrefixes: ["dt", "DT"],
2428
- tagNumbers: [yt],
2429
- parseAppString(e, t) {
2430
- return e === "DT" ? n(t) : vt(t);
2655
+ tagNumbers: [gt],
2656
+ parseAppString(e, t, r) {
2657
+ return e === "DT" ? n(t) : ht(t, r);
2431
2658
  },
2432
- parseAppSequence(e, t) {
2433
- let r = _t(t);
2434
- return e === "DT" ? n(r) : vt(r);
2659
+ parseAppSequence(e, t, r) {
2660
+ let i = pt(t);
2661
+ return e === "DT" ? n(i) : ht(i, r);
2435
2662
  },
2436
2663
  parseTag(e, t) {
2437
2664
  if (e !== 1n) return;
2438
2665
  let r;
2439
- if (t instanceof g) r = Number(t.value);
2440
- else if (t instanceof _) r = Number(t.value);
2441
- else if (t instanceof x) r = t.value;
2666
+ if (t instanceof x) r = Number(t.value);
2667
+ else if (t instanceof S) r = Number(t.value);
2668
+ else if (t instanceof C) r = t.value;
2442
2669
  else return;
2443
- return n(P(r));
2670
+ return n(L(r));
2444
2671
  }
2445
2672
  };
2446
2673
  return t && (r.fromJS = (e, t) => {
2447
- if (e instanceof Date) return new wt(P(e.getTime() / 1e3));
2674
+ if (e instanceof Date) return new xt(L(e.getTime() / 1e3));
2448
2675
  }, r.isJSType = (e) => e instanceof Date), r;
2449
2676
  }
2450
- var Et = Tt(), Dt = Tt({ jsDate: !0 });
2677
+ var Ct = St(), wt = St({ jsDate: !0 });
2451
2678
  //#endregion
2452
2679
  //#region src/utils/ip.ts
2453
- function F(e) {
2680
+ function Tt(e) {
2454
2681
  let t = e.split(".");
2455
2682
  if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
2456
2683
  let n = new Uint8Array(4);
@@ -2463,11 +2690,11 @@ function F(e) {
2463
2690
  }
2464
2691
  return n;
2465
2692
  }
2466
- function Ot(e) {
2693
+ function Et(e) {
2467
2694
  let t = new Uint8Array(16);
2468
2695
  if (e === "::") return t;
2469
2696
  let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
2470
- i && (n = i[1], n.endsWith(":") && (n += ":"), r = F(i[2]));
2697
+ i && (n = i[1], n.endsWith(":") && (n += ":"), r = Tt(i[2]));
2471
2698
  let a = n.split("::");
2472
2699
  if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
2473
2700
  let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
@@ -2484,11 +2711,11 @@ function Ot(e) {
2484
2711
  }
2485
2712
  return r && t.set(r, 12), t;
2486
2713
  }
2487
- function I(e) {
2714
+ function Dt(e) {
2488
2715
  return Array.from(e).join(".");
2489
2716
  }
2490
- function kt(e) {
2491
- let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? I(e.slice(12)) : null, n = t ? 6 : 8, r = [];
2717
+ function Ot(e) {
2718
+ let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Dt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
2492
2719
  for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
2493
2720
  let i = -1, a = 0, o = 0;
2494
2721
  for (; o < n;) if (r[o] === 0) {
@@ -2502,26 +2729,26 @@ function kt(e) {
2502
2729
  }
2503
2730
  //#endregion
2504
2731
  //#region src/extensions/ip.ts
2505
- var L = "ip", R = "IP", z = 52n, B = 54n;
2732
+ var kt = "ip", R = "IP", z = 52n, B = 54n;
2506
2733
  function At(e) {
2507
2734
  if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
2508
2735
  let t = e[0];
2509
- if (t instanceof N) return t.value;
2510
- if (t instanceof C) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
2736
+ if (t instanceof I) return t.value;
2737
+ if (t instanceof T) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
2511
2738
  throw SyntaxError("ip<<...>>: expected a text string or byte string");
2512
2739
  }
2513
2740
  function jt(e) {
2514
2741
  return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
2515
- bytes: F(e),
2742
+ bytes: Tt(e),
2516
2743
  isV4: !0
2517
2744
  } : {
2518
- bytes: Ot(e),
2745
+ bytes: Et(e),
2519
2746
  isV4: !1
2520
2747
  };
2521
2748
  }
2522
2749
  function V(e) {
2523
- if (e.length === 4) return I(e);
2524
- if (e.length === 16) return kt(e);
2750
+ if (e.length === 4) return Dt(e);
2751
+ if (e.length === 16) return Ot(e);
2525
2752
  throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
2526
2753
  }
2527
2754
  function Mt(e, t) {
@@ -2538,75 +2765,75 @@ function Nt(e, t) {
2538
2765
  let n = new Uint8Array(t);
2539
2766
  return n.set(e), n;
2540
2767
  }
2541
- var Pt = class extends C {
2768
+ var Pt = class extends T {
2542
2769
  _toCDN(e, t) {
2543
- return e?.appStrings === !1 ? super._toCDN(e, t) : `${L}'${V(this.value)}'`;
2770
+ return e?.appStrings === !1 ? super._toCDN(e, t) : `${kt}'${V(this.value)}'`;
2544
2771
  }
2545
- }, Ft = class extends E {
2772
+ }, Ft = class extends O {
2546
2773
  _isV4;
2547
2774
  constructor(e, t, n) {
2548
- super([new g(BigInt(e)), new C(t)]), this._isV4 = n;
2775
+ super([new x(BigInt(e)), new T(t)]), this._isV4 = n;
2549
2776
  }
2550
2777
  _toCDN(e, t) {
2551
2778
  if (e?.appStrings === !1) return super._toCDN(e, t);
2552
2779
  let n = Number(this.items[0].value), r = this.items[1].value;
2553
- return `${L}'${V(Nt(r, this._isV4 ? 4 : 16))}/${n}'`;
2780
+ return `${kt}'${V(Nt(r, this._isV4 ? 4 : 16))}/${n}'`;
2554
2781
  }
2555
- }, H = class extends S {
2782
+ }, It = class extends w {
2556
2783
  constructor(e, t) {
2557
2784
  super(e, t);
2558
2785
  }
2559
2786
  _toCDN(e, t) {
2560
2787
  if (e?.appStrings === !1) return super._toCDN(e, t);
2561
2788
  let n = this.tag === z ? 4 : 16, r = this.content;
2562
- if (r instanceof C) return `${R}'${V(r.value)}'`;
2563
- if (r instanceof E && r.items.length === 2 && r.items[0] instanceof g && r.items[1] instanceof C) {
2789
+ if (r instanceof T) return `${R}'${V(r.value)}'`;
2790
+ if (r instanceof O && r.items.length === 2 && r.items[0] instanceof x && r.items[1] instanceof T) {
2564
2791
  let e = Number(r.items[0].value);
2565
2792
  return `${R}'${V(Nt(r.items[1].value, n))}/${e}'`;
2566
2793
  }
2567
2794
  return super._toCDN(e, t);
2568
2795
  }
2569
2796
  };
2570
- function It(e, t) {
2797
+ function Lt(e, t) {
2571
2798
  let n = t.indexOf("/");
2572
2799
  if (n === -1) {
2573
2800
  let { bytes: n, isV4: r } = jt(t);
2574
- return e === R ? new H(r ? z : B, new C(n)) : new Pt(n);
2801
+ return e === R ? new It(r ? z : B, new T(n)) : new Pt(n);
2575
2802
  }
2576
2803
  let r = t.slice(0, n), i = t.slice(n + 1);
2577
2804
  if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
2578
2805
  let a = parseInt(i, 10), { bytes: o, isV4: s } = jt(r), c = s ? 32 : 128;
2579
2806
  if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
2580
2807
  let l = Mt(o, a);
2581
- return e === R ? new H(s ? z : B, new E([new g(BigInt(a)), new C(l)])) : new Ft(a, l, s);
2808
+ return e === R ? new It(s ? z : B, new O([new x(BigInt(a)), new T(l)])) : new Ft(a, l, s);
2582
2809
  }
2583
- var Lt = {
2584
- appStringPrefixes: [L, R],
2810
+ var Rt = {
2811
+ appStringPrefixes: [kt, R],
2585
2812
  tagNumbers: [z, B],
2586
2813
  parseAppString(e, t) {
2587
- return It(e, t);
2814
+ return Lt(e, t);
2588
2815
  },
2589
2816
  parseAppSequence(e, t) {
2590
- return It(e, At(t));
2817
+ return Lt(e, At(t));
2591
2818
  },
2592
2819
  parseTag(e, t) {
2593
- if (!(e !== z && e !== B) && (t instanceof C || t instanceof E)) return new H(e, t);
2820
+ if (!(e !== z && e !== B) && (t instanceof T || t instanceof O)) return new It(e, t);
2594
2821
  }
2595
- }, Rt = 18446744073709551615n, zt = -(Rt + 1n), Bt = {
2596
- tagNumbers: [Le, Re],
2822
+ }, zt = 18446744073709551615n, Bt = -18446744073709551616n, Vt = {
2823
+ tagNumbers: [Ie, Le],
2597
2824
  parseTag(e, t) {
2598
- if (t instanceof C) {
2825
+ if (t instanceof T) {
2599
2826
  if (e === 2n) {
2600
- let e = He(t.value);
2601
- return e > Rt ? new j(e) : void 0;
2827
+ let e = Ve(t.value);
2828
+ return e > zt ? new P(e) : void 0;
2602
2829
  }
2603
2830
  if (e === 3n) {
2604
- let e = -1n - He(t.value);
2605
- return e < zt ? new M(e) : void 0;
2831
+ let e = -1n - Ve(t.value);
2832
+ return e < Bt ? new F(e) : void 0;
2606
2833
  }
2607
2834
  }
2608
2835
  }
2609
- }, Vt = "cri", U = "CRI", Ht = 99n, Ut = new Map([
2836
+ }, Ht = "cri", Ut = "CRI", Wt = 99n, Gt = new Map([
2610
2837
  ["coap", -1n],
2611
2838
  ["coaps", -2n],
2612
2839
  ["http", -3n],
@@ -2617,46 +2844,46 @@ var Lt = {
2617
2844
  ["coaps+tcp", -8n],
2618
2845
  ["coap+ws", -25n],
2619
2846
  ["coaps+ws", -26n]
2620
- ]), Wt = new Map([...Ut.entries()].map(([e, t]) => [t, e]));
2621
- function W(e) {
2847
+ ]), Kt = new Map([...Gt.entries()].map(([e, t]) => [t, e]));
2848
+ function H(e) {
2622
2849
  try {
2623
2850
  return decodeURIComponent(e);
2624
2851
  } catch {
2625
2852
  return e;
2626
2853
  }
2627
2854
  }
2628
- function Gt(e) {
2855
+ function qt(e) {
2629
2856
  return Array.from(new TextEncoder().encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
2630
2857
  }
2631
- function G(e, t) {
2858
+ function U(e, t) {
2632
2859
  let n = "";
2633
- for (let r of e) n += t(r) ? r : Gt(r);
2860
+ for (let r of e) n += t(r) ? r : qt(r);
2634
2861
  return n;
2635
2862
  }
2636
- function Kt(e) {
2637
- return /[A-Za-z0-9\-._~]/.test(e);
2638
- }
2639
- function qt(e) {
2640
- return /[!$&'()*+,;=]/.test(e);
2641
- }
2642
2863
  function Jt(e) {
2643
- return Kt(e) || qt(e) || e === ":" || e === "@";
2864
+ return /[A-Za-z0-9\-._~]/.test(e);
2644
2865
  }
2645
2866
  function Yt(e) {
2646
- return (Jt(e) || e === "/" || e === "?") && e !== "&";
2867
+ return /[!$&'()*+,;=]/.test(e);
2647
2868
  }
2648
2869
  function Xt(e) {
2649
- return Jt(e) || e === "/" || e === "?";
2870
+ return Jt(e) || Yt(e) || e === ":" || e === "@";
2650
2871
  }
2651
2872
  function Zt(e) {
2652
- return Kt(e) || qt(e) || e === ":";
2873
+ return (Xt(e) || e === "/" || e === "?") && e !== "&";
2653
2874
  }
2654
2875
  function Qt(e) {
2655
- return Kt(e) || qt(e);
2876
+ return Xt(e) || e === "/" || e === "?";
2656
2877
  }
2657
2878
  function $t(e) {
2879
+ return Jt(e) || Yt(e) || e === ":";
2880
+ }
2881
+ function en(e) {
2882
+ return Jt(e) || Yt(e);
2883
+ }
2884
+ function tn(e) {
2658
2885
  let t = [], n = e, r = n.indexOf("@");
2659
- r >= 0 && (t.push(O.FALSE), t.push(new N(W(n.slice(0, r)))), n = n.slice(r + 1));
2886
+ r >= 0 && (t.push(A.FALSE), t.push(new I(H(n.slice(0, r)))), n = n.slice(r + 1));
2660
2887
  let i, a = null;
2661
2888
  if (n.startsWith("[")) {
2662
2889
  let e = n.indexOf("]");
@@ -2665,268 +2892,319 @@ function $t(e) {
2665
2892
  let r = n.slice(e + 1);
2666
2893
  if (r.startsWith(":")) a = r.slice(1);
2667
2894
  else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
2668
- t.push(new C(Ot(i)));
2895
+ t.push(new T(Et(i)));
2669
2896
  } else {
2670
2897
  let e = n.lastIndexOf(":");
2671
- if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new C(F(i)));
2672
- else for (let e of i.toLowerCase().split(".")) t.push(new N(e));
2898
+ if (e >= 0 ? (i = n.slice(0, e), a = n.slice(e + 1)) : i = n, i !== "") if (/^\d{1,3}(\.\d{1,3}){3}$/.test(i)) t.push(new T(Tt(i)));
2899
+ else for (let e of i.toLowerCase().split(".")) t.push(new I(e));
2673
2900
  }
2674
2901
  if (a !== null && a !== "") {
2675
2902
  if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
2676
2903
  let e = parseInt(a, 10);
2677
2904
  if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
2678
- t.push(new g(BigInt(e)));
2905
+ t.push(new x(BigInt(e)));
2679
2906
  }
2680
- return new E(t);
2907
+ return new O(t);
2681
2908
  }
2682
- function en(e) {
2909
+ function nn(e) {
2683
2910
  let t = e.items, n = 0, r = "";
2684
- if (n < t.length && t[n] instanceof O && t[n].value === 20) {
2911
+ if (n < t.length && t[n] instanceof A && t[n].value === 20) {
2685
2912
  n++;
2686
2913
  let e = t[n++];
2687
- r += G(e.value, Zt) + "@";
2914
+ r += U(e.value, $t) + "@";
2688
2915
  }
2689
2916
  if (n >= t.length) return r;
2690
2917
  let i = t[n];
2691
- if (i instanceof C) {
2918
+ if (i instanceof T) {
2692
2919
  n++;
2693
2920
  let { length: e } = i.value;
2694
- if (e === 4) r += I(i.value);
2695
- else if (e === 16) r += "[" + kt(i.value) + "]";
2921
+ if (e === 4) r += Dt(i.value);
2922
+ else if (e === 16) r += "[" + Ot(i.value) + "]";
2696
2923
  else throw Error(`cri: unexpected host-ip byte length: ${e}`);
2697
- n < t.length && t[n] instanceof N && (r += `%25${G(t[n++].value, Qt)}`);
2924
+ n < t.length && t[n] instanceof I && (r += `%25${U(t[n++].value, en)}`);
2698
2925
  } else {
2699
2926
  let e = [];
2700
- for (; n < t.length && t[n] instanceof N;) e.push(G(t[n++].value, Qt));
2927
+ for (; n < t.length && t[n] instanceof I;) e.push(U(t[n++].value, en));
2701
2928
  r += e.join(".");
2702
2929
  }
2703
- return n < t.length && t[n] instanceof g && (r += ":" + t[n].value.toString()), r;
2930
+ return n < t.length && t[n] instanceof x && (r += ":" + t[n].value.toString()), r;
2704
2931
  }
2705
- function tn(e) {
2932
+ function rn(e) {
2706
2933
  let t = e.slice(2), n = t.indexOf("/"), r, i;
2707
- return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new N(W(e)))) : (r = t, i = []), {
2708
- authority: $t(r),
2934
+ return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new I(H(e)))) : (r = t, i = []), {
2935
+ authority: tn(r),
2709
2936
  pathSegments: i
2710
2937
  };
2711
2938
  }
2712
- function nn(e) {
2939
+ function an(e) {
2713
2940
  let t = e, n = null, r = t.indexOf("#");
2714
- r >= 0 && (n = W(t.slice(r + 1)), t = t.slice(0, r));
2941
+ r >= 0 && (n = H(t.slice(r + 1)), t = t.slice(0, r));
2715
2942
  let i = null, a = t.indexOf("?");
2716
2943
  if (a >= 0) {
2717
2944
  let e = t.slice(a + 1);
2718
- t = t.slice(0, a), i = e.split("&").map((e) => new N(W(e)));
2945
+ t = t.slice(0, a), i = e.split("&").map((e) => new I(H(e)));
2719
2946
  }
2720
2947
  let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
2721
2948
  if (s) {
2722
- let e = s[1].toLowerCase(), t = s[2], n = Ut.get(e);
2723
- if (o.push(n === void 0 ? new N(e) : new _(n)), t.startsWith("//")) {
2724
- let { authority: e, pathSegments: n } = tn(t);
2725
- o.push(e, new E(n));
2949
+ let e = s[1].toLowerCase(), t = s[2], n = Gt.get(e);
2950
+ if (o.push(n === void 0 ? new I(e) : new S(n)), t.startsWith("//")) {
2951
+ let { authority: e, pathSegments: n } = rn(t);
2952
+ o.push(e, new O(n));
2726
2953
  } else if (t.startsWith("/")) {
2727
- let e = t.slice(1).split("/").map((e) => new N(W(e)));
2728
- o.push(O.NULL, new E(e));
2954
+ let e = t.slice(1).split("/").map((e) => new I(H(e)));
2955
+ o.push(A.NULL, new O(e));
2729
2956
  } else {
2730
- let e = t.split("/").map((e) => new N(W(e)));
2731
- o.push(O.TRUE, new E(e));
2957
+ let e = t.split("/").map((e) => new I(H(e)));
2958
+ o.push(A.TRUE, new O(e));
2732
2959
  }
2733
2960
  } else if (t.startsWith("//")) {
2734
- let { authority: e, pathSegments: n } = tn(t);
2735
- o.push(O.FALSE, e, new E(n));
2961
+ let { authority: e, pathSegments: n } = rn(t);
2962
+ o.push(A.FALSE, e, new O(n));
2736
2963
  } else if (t.startsWith("/")) {
2737
- let e = t.slice(1).split("/").map((e) => new N(W(e)));
2738
- o.push(O.TRUE, new E(e));
2739
- } else if (t === "") o.push(new g(0n));
2964
+ let e = t.slice(1).split("/").map((e) => new I(H(e)));
2965
+ o.push(A.TRUE, new O(e));
2966
+ } else if (t === "") o.push(new x(0n));
2740
2967
  else {
2741
2968
  let n = 1n, r = t, i = !1;
2742
2969
  for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
2743
2970
  if (r === ".." ? (n++, r = "") : r === "." && (r = ""), n === 1n && !i && r !== "" && r.split("/")[0].includes(":")) throw SyntaxError(`cri: invalid relative-path reference — first segment must not contain ':' without a './' prefix (RFC 3986 §3.3): ${JSON.stringify(e)}`);
2744
- let a = r === "" ? [] : r.split("/").map((e) => new N(W(e)));
2745
- o.push(new g(n), new E(a));
2971
+ let a = r === "" ? [] : r.split("/").map((e) => new I(H(e)));
2972
+ o.push(new x(n), new O(a));
2746
2973
  }
2747
- if (i !== null && o.push(new E(i)), n !== null && (i === null && o.push(O.NULL), o.push(new N(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
2974
+ if (i !== null && o.push(new O(i)), n !== null && (i === null && o.push(A.NULL), o.push(new I(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
2748
2975
  let e = o[o.length - 1];
2749
- e instanceof E && e.items.length === 0 && o.pop();
2976
+ e instanceof O && e.items.length === 0 && o.pop();
2750
2977
  }
2751
- return o.length === 1 && o[0] instanceof g && o[0].value === 0n ? [] : o;
2978
+ return o.length === 1 && o[0] instanceof x && o[0].value === 0n ? [] : o;
2752
2979
  }
2753
- function K(e, t) {
2980
+ function W(e, t) {
2754
2981
  let n = t, r = "";
2755
2982
  if (n < e.length) {
2756
2983
  let t = e[n];
2757
- if (t instanceof E) {
2984
+ if (t instanceof O) {
2758
2985
  if (n++, t.items.length > 0) {
2759
2986
  let e = t.items.map((e) => {
2760
- if (!(e instanceof N)) throw Error("cri: query item must be a text string");
2761
- return G(e.value, Yt);
2987
+ if (!(e instanceof I)) throw Error("cri: query item must be a text string");
2988
+ return U(e.value, Zt);
2762
2989
  });
2763
2990
  r += "?" + e.join("&");
2764
2991
  }
2765
- } else t instanceof O && t.value === 22 && n++;
2992
+ } else t instanceof A && t.value === 22 && n++;
2766
2993
  }
2767
- return n < e.length && e[n] instanceof N && (r += "#" + G(e[n].value, Xt)), r;
2994
+ return n < e.length && e[n] instanceof I && (r += "#" + U(e[n].value, Qt)), r;
2768
2995
  }
2769
- function q(e) {
2996
+ function G(e) {
2770
2997
  return e.items.map((e) => {
2771
- if (!(e instanceof N)) throw Error("cri: path segment must be a text string");
2772
- return G(e.value, Jt);
2998
+ if (!(e instanceof I)) throw Error("cri: path segment must be a text string");
2999
+ return U(e.value, Xt);
2773
3000
  });
2774
3001
  }
2775
- function rn(e) {
3002
+ function on(e) {
2776
3003
  if (e.length === 0) return "";
2777
3004
  let t = 0, n = e[t++];
2778
- if (n instanceof _ || n instanceof N) {
3005
+ if (n instanceof S || n instanceof I) {
2779
3006
  let r;
2780
- if (n instanceof _) {
2781
- let e = Wt.get(n.value);
3007
+ if (n instanceof S) {
3008
+ let e = Kt.get(n.value);
2782
3009
  if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
2783
3010
  r = e + ":";
2784
3011
  } else r = n.value + ":";
2785
3012
  if (t >= e.length) return r;
2786
3013
  let i = e[t++], a = "", o = !1;
2787
- if (i instanceof E) a = "//" + en(i), o = !0;
2788
- else if (i instanceof O) if (i.value === 22) o = !0;
3014
+ if (i instanceof O) a = "//" + nn(i), o = !0;
3015
+ else if (i instanceof A) if (i.value === 22) o = !0;
2789
3016
  else if (i.value === 21) o = !1;
2790
3017
  else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
2791
3018
  else throw Error("cri: unexpected type for authority element");
2792
3019
  let s = "";
2793
- if (t < e.length && e[t] instanceof E) {
3020
+ if (t < e.length && e[t] instanceof O) {
2794
3021
  let n = e[t++];
2795
- n.items.length > 0 && (s = (o ? "/" : "") + q(n).join("/"));
3022
+ n.items.length > 0 && (s = (o ? "/" : "") + G(n).join("/"));
2796
3023
  }
2797
- return r + a + s + K(e, t);
3024
+ return r + a + s + W(e, t);
2798
3025
  }
2799
- if (n instanceof O && n.value === 20) {
2800
- if (t >= e.length || !(e[t] instanceof E)) throw Error("cri: network-path reference requires an authority array");
2801
- let n = en(e[t++]), r = "";
2802
- if (t < e.length && e[t] instanceof E) {
3026
+ if (n instanceof A && n.value === 20) {
3027
+ if (t >= e.length || !(e[t] instanceof O)) throw Error("cri: network-path reference requires an authority array");
3028
+ let n = nn(e[t++]), r = "";
3029
+ if (t < e.length && e[t] instanceof O) {
2803
3030
  let n = e[t++];
2804
- n.items.length > 0 && (r = "/" + q(n).join("/"));
3031
+ n.items.length > 0 && (r = "/" + G(n).join("/"));
2805
3032
  }
2806
- return "//" + n + r + K(e, t);
3033
+ return "//" + n + r + W(e, t);
2807
3034
  }
2808
- if (n instanceof O && n.value === 21) {
3035
+ if (n instanceof A && n.value === 21) {
2809
3036
  let n = "/";
2810
- if (t < e.length && e[t] instanceof E) {
3037
+ if (t < e.length && e[t] instanceof O) {
2811
3038
  let r = e[t++];
2812
- n = "/" + q(r).join("/");
3039
+ n = "/" + G(r).join("/");
2813
3040
  }
2814
- return n + K(e, t);
3041
+ return n + W(e, t);
2815
3042
  }
2816
- if (n instanceof g) {
3043
+ if (n instanceof x) {
2817
3044
  let r = n.value;
2818
- if (r === 0n) return K(e, t);
3045
+ if (r === 0n) return W(e, t);
2819
3046
  let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
2820
- if (t < e.length && e[t] instanceof E) {
3047
+ if (t < e.length && e[t] instanceof O) {
2821
3048
  let n = e[t++];
2822
3049
  if (n.items.length > 0) {
2823
- let e = q(n);
3050
+ let e = G(n);
2824
3051
  a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
2825
3052
  } else a = i === "" ? "./" : i;
2826
3053
  } else a = i === "" ? "./" : i;
2827
- return a + K(e, t);
3054
+ return a + W(e, t);
2828
3055
  }
2829
3056
  throw Error("cri: unrecognised first element type in CRI array");
2830
3057
  }
2831
- var an = class extends E {
3058
+ var sn = class extends O {
2832
3059
  _toCDN(e, t) {
2833
3060
  if (e?.appStrings === !1) return super._toCDN(e, t);
2834
3061
  try {
2835
- return `${Vt}'${rn(this.items)}'`;
3062
+ return `${Ht}'${on(this.items)}'`;
2836
3063
  } catch {
2837
3064
  return super._toCDN(e, t);
2838
3065
  }
2839
3066
  }
2840
- }, on = class extends S {
3067
+ }, cn = class extends w {
2841
3068
  constructor(e) {
2842
- super(Ht, e);
3069
+ super(Wt, e);
2843
3070
  }
2844
3071
  _toCDN(e, t) {
2845
3072
  if (e?.appStrings === !1) return super._toCDN(e, t);
2846
3073
  try {
2847
- return `${U}'${rn(this.content.items)}'`;
3074
+ return `${Ut}'${on(this.content.items)}'`;
2848
3075
  } catch {
2849
3076
  return super._toCDN(e, t);
2850
3077
  }
2851
3078
  }
2852
3079
  };
2853
- function sn(e) {
3080
+ function ln(e) {
2854
3081
  if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
2855
3082
  let t = e[0];
2856
- if (t instanceof N) return t.value;
2857
- if (t instanceof C) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
3083
+ if (t instanceof I) return t.value;
3084
+ if (t instanceof T) return new TextDecoder("utf-8", { fatal: !0 }).decode(t.value);
2858
3085
  throw SyntaxError("cri<<...>>: expected a text string or byte string");
2859
3086
  }
2860
- function cn(e, t) {
2861
- let n = new an(nn(t));
2862
- return e === U ? new on(n) : n;
3087
+ function un(e, t) {
3088
+ let n = new sn(an(t));
3089
+ return e === Ut ? new cn(n) : n;
2863
3090
  }
2864
- var ln = {
2865
- appStringPrefixes: [Vt, U],
2866
- tagNumbers: [Ht],
3091
+ var dn = {
3092
+ appStringPrefixes: [Ht, Ut],
3093
+ tagNumbers: [Wt],
2867
3094
  parseAppString(e, t) {
2868
- return cn(e, t);
3095
+ return un(e, t);
2869
3096
  },
2870
3097
  parseAppSequence(e, t) {
2871
- return cn(e, sn(t));
3098
+ return un(e, ln(t));
2872
3099
  },
2873
3100
  parseTag(e, t) {
2874
- if (e === 99n && t instanceof E) return new on(new an(t.items, {
3101
+ if (e === 99n && t instanceof O) return new cn(new sn(t.items, {
2875
3102
  indefiniteLength: t.indefiniteLength,
2876
3103
  encodingWidth: t.encodingWidth
2877
3104
  }));
2878
3105
  }
2879
- }, un = new TextDecoder("utf-8", {
3106
+ }, fn = new TextDecoder("utf-8", {
2880
3107
  fatal: !0,
2881
3108
  ignoreBOM: !0
3109
+ }), pn = new TextDecoder("utf-8", {
3110
+ fatal: !1,
3111
+ ignoreBOM: !0
2882
3112
  });
2883
- function J(e) {
3113
+ function K(e) {
2884
3114
  throw Error(`CBOR decode error: ${e}`);
2885
3115
  }
3116
+ function q(e, t, n) {
3117
+ let r = {
3118
+ message: e,
3119
+ offset: t
3120
+ };
3121
+ if (n?.onWarning ? n.onWarning(r) : n?.silent || console.warn(`CBOR strict violation at offset ${t}: ${e}`), n?.strict !== !1) throw Error(`CBOR decode error: ${e}`);
3122
+ return r;
3123
+ }
3124
+ function mn(e, t) {
3125
+ e.warnings ??= [], e.warnings.push(t);
3126
+ }
3127
+ function J(e) {
3128
+ if (e instanceof x) return ["u", String(e.value)];
3129
+ if (e instanceof S) return ["n", String(e.value)];
3130
+ if (e instanceof I) return ["t", e.value];
3131
+ if (e instanceof D) return ["t", e.chunks.map((e) => e.value).join("")];
3132
+ if (e instanceof T) {
3133
+ let t = "";
3134
+ for (let n of e.value) t += n.toString(16).padStart(2, "0");
3135
+ return ["b", t];
3136
+ }
3137
+ if (e instanceof E) {
3138
+ let t = "";
3139
+ for (let n of e.chunks) for (let e of n.value) t += e.toString(16).padStart(2, "0");
3140
+ return ["b", t];
3141
+ }
3142
+ if (e instanceof C) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
3143
+ if (e instanceof A) return ["s", e.value];
3144
+ if (e instanceof O) return ["A", e.items.map(J)];
3145
+ if (e instanceof k) {
3146
+ let t = e.entries.map(([e, t]) => [J(e), J(t)]);
3147
+ return t.sort((e, t) => {
3148
+ let n = JSON.stringify(e[0]), r = JSON.stringify(t[0]);
3149
+ return n < r ? -1 : +(n > r);
3150
+ }), ["M", t];
3151
+ }
3152
+ if (e instanceof w) return [
3153
+ "G",
3154
+ String(e.tag),
3155
+ J(e.content)
3156
+ ];
3157
+ let t = e.toCBOR(), n = "";
3158
+ for (let e of t) n += e.toString(16).padStart(2, "0");
3159
+ return ["c", n];
3160
+ }
3161
+ function hn(e) {
3162
+ return JSON.stringify(J(e));
3163
+ }
2886
3164
  function Y(e, t, n) {
2887
3165
  if (n <= 23) return {
2888
3166
  value: BigInt(n),
2889
3167
  nextOffset: t
2890
3168
  };
2891
3169
  switch (n) {
2892
- case 24: return t + 1 > e.byteLength && J("unexpected end of input"), {
3170
+ case 24: return t + 1 > e.byteLength && K("unexpected end of input"), {
2893
3171
  value: BigInt(e.getUint8(t)),
2894
3172
  nextOffset: t + 1
2895
3173
  };
2896
- case 25: return t + 2 > e.byteLength && J("unexpected end of input"), {
3174
+ case 25: return t + 2 > e.byteLength && K("unexpected end of input"), {
2897
3175
  value: BigInt(e.getUint16(t, !1)),
2898
3176
  nextOffset: t + 2
2899
3177
  };
2900
- case 26: return t + 4 > e.byteLength && J("unexpected end of input"), {
3178
+ case 26: return t + 4 > e.byteLength && K("unexpected end of input"), {
2901
3179
  value: BigInt(e.getUint32(t, !1)),
2902
3180
  nextOffset: t + 4
2903
3181
  };
2904
- case 27: return t + 8 > e.byteLength && J("unexpected end of input"), {
3182
+ case 27: return t + 8 > e.byteLength && K("unexpected end of input"), {
2905
3183
  value: e.getBigUint64(t, !1),
2906
3184
  nextOffset: t + 8
2907
3185
  };
2908
- default: J(`reserved additional info value: ${n}`);
3186
+ default: K(`reserved additional info value: ${n}`);
2909
3187
  }
2910
3188
  }
2911
3189
  function X(e, t, n) {
2912
- let r = t, i = dn(e, t, n);
3190
+ let r = t, i = gn(e, t, n);
2913
3191
  return i.value.start = r, i.value.end = i.nextOffset, i;
2914
3192
  }
2915
- function dn(e, t, n) {
2916
- t >= e.byteLength && J("unexpected end of input");
3193
+ function gn(e, t, n) {
3194
+ t >= e.byteLength && K("unexpected end of input");
2917
3195
  let r = e.getUint8(t++), i = r >> 5, a = r & 31;
2918
3196
  switch (i) {
2919
3197
  case 0: {
2920
3198
  let { value: n, nextOffset: r } = Y(e, t, a);
2921
3199
  return {
2922
- value: new g(n),
3200
+ value: new x(n),
2923
3201
  nextOffset: r
2924
3202
  };
2925
3203
  }
2926
3204
  case 1: {
2927
3205
  let { value: n, nextOffset: r } = Y(e, t, a);
2928
3206
  return {
2929
- value: new _(-1n - n),
3207
+ value: new S(-1n - n),
2930
3208
  nextOffset: r
2931
3209
  };
2932
3210
  }
@@ -2934,21 +3212,21 @@ function dn(e, t, n) {
2934
3212
  if (a === 31) {
2935
3213
  let r = [], i = t;
2936
3214
  for (;;) {
2937
- if (i >= e.byteLength && J("unexpected end of indefinite byte string"), e.getUint8(i) === 255) {
3215
+ if (i >= e.byteLength && K("unexpected end of indefinite byte string"), e.getUint8(i) === 255) {
2938
3216
  i++;
2939
3217
  break;
2940
3218
  }
2941
3219
  let t = X(e, i, n);
2942
- t.value instanceof C || J("indefinite-length byte string chunk must be a definite byte string"), r.push(t.value), i = t.nextOffset;
3220
+ t.value instanceof T || K("indefinite-length byte string chunk must be a definite byte string"), r.push(t.value), i = t.nextOffset;
2943
3221
  }
2944
3222
  return {
2945
- value: new w(r),
3223
+ value: new E(r),
2946
3224
  nextOffset: i
2947
3225
  };
2948
3226
  }
2949
3227
  let { value: r, nextOffset: i } = Y(e, t, a), o = Number(r);
2950
- return i + o > e.byteLength && J("byte string extends beyond input"), {
2951
- value: new C(new Uint8Array(e.buffer, e.byteOffset + i, o).slice()),
3228
+ return i + o > e.byteLength && K("byte string extends beyond input"), {
3229
+ value: new T(new Uint8Array(e.buffer, e.byteOffset + i, o).slice()),
2952
3230
  nextOffset: i + o
2953
3231
  };
2954
3232
  }
@@ -2956,28 +3234,29 @@ function dn(e, t, n) {
2956
3234
  if (a === 31) {
2957
3235
  let r = [], i = t;
2958
3236
  for (;;) {
2959
- if (i >= e.byteLength && J("unexpected end of indefinite text string"), e.getUint8(i) === 255) {
3237
+ if (i >= e.byteLength && K("unexpected end of indefinite text string"), e.getUint8(i) === 255) {
2960
3238
  i++;
2961
3239
  break;
2962
3240
  }
2963
3241
  let t = X(e, i, n);
2964
- t.value instanceof N || J("indefinite-length text string chunk must be a definite text string"), r.push(t.value), i = t.nextOffset;
3242
+ t.value instanceof I || K("indefinite-length text string chunk must be a definite text string"), r.push(t.value), i = t.nextOffset;
2965
3243
  }
2966
3244
  return {
2967
- value: new T(r),
3245
+ value: new D(r),
2968
3246
  nextOffset: i
2969
3247
  };
2970
3248
  }
2971
3249
  let { value: r, nextOffset: i } = Y(e, t, a), o = Number(r);
2972
- i + o > e.byteLength && J("text string extends beyond input");
2973
- let s = new Uint8Array(e.buffer, e.byteOffset + i, o), c;
3250
+ i + o > e.byteLength && K("text string extends beyond input");
3251
+ let s = new Uint8Array(e.buffer, e.byteOffset + i, o), c, l;
2974
3252
  try {
2975
- c = un.decode(s);
3253
+ c = fn.decode(s);
2976
3254
  } catch {
2977
- J("invalid UTF-8 sequence in text string");
3255
+ l = q("invalid UTF-8 sequence in text string", i, n), c = pn.decode(s);
2978
3256
  }
2979
- return {
2980
- value: new N(c),
3257
+ let u = new I(c);
3258
+ return l && mn(u, l), {
3259
+ value: u,
2981
3260
  nextOffset: i + o
2982
3261
  };
2983
3262
  }
@@ -2985,7 +3264,7 @@ function dn(e, t, n) {
2985
3264
  if (a === 31) {
2986
3265
  let r = [], i = t;
2987
3266
  for (;;) {
2988
- if (i >= e.byteLength && J("unexpected end of indefinite array"), e.getUint8(i) === 255) {
3267
+ if (i >= e.byteLength && K("unexpected end of indefinite array"), e.getUint8(i) === 255) {
2989
3268
  i++;
2990
3269
  break;
2991
3270
  }
@@ -2993,7 +3272,7 @@ function dn(e, t, n) {
2993
3272
  r.push(t.value), i = t.nextOffset;
2994
3273
  }
2995
3274
  return {
2996
- value: new E(r, { indefiniteLength: !0 }),
3275
+ value: new O(r, { indefiniteLength: !0 }),
2997
3276
  nextOffset: i
2998
3277
  };
2999
3278
  }
@@ -3003,121 +3282,140 @@ function dn(e, t, n) {
3003
3282
  s.push(t.value), c = t.nextOffset;
3004
3283
  }
3005
3284
  return {
3006
- value: new E(s),
3285
+ value: new O(s),
3007
3286
  nextOffset: c
3008
3287
  };
3009
3288
  }
3010
3289
  case 5: {
3011
3290
  if (a === 31) {
3012
- let r = [], i = t;
3291
+ let r = [], i = /* @__PURE__ */ new Set(), a = [], o = t;
3013
3292
  for (;;) {
3014
- if (i >= e.byteLength && J("unexpected end of indefinite map"), e.getUint8(i) === 255) {
3015
- i++;
3293
+ if (o >= e.byteLength && K("unexpected end of indefinite map"), e.getUint8(o) === 255) {
3294
+ o++;
3016
3295
  break;
3017
3296
  }
3018
- let t = X(e, i, n);
3019
- i = t.nextOffset;
3020
- let a = X(e, i, n);
3021
- i = a.nextOffset, r.push([t.value, a.value]);
3297
+ let t = X(e, o, n), s = hn(t.value);
3298
+ i.has(s) && a.push(q(`duplicate map key at offset ${t.value.start}`, t.value.start, n)), i.add(s), o = t.nextOffset;
3299
+ let c = X(e, o, n);
3300
+ o = c.nextOffset, r.push([t.value, c.value]);
3022
3301
  }
3302
+ let s = new k(r, { indefiniteLength: !0 });
3303
+ for (let e of a) mn(s, e);
3023
3304
  return {
3024
- value: new D(r, { indefiniteLength: !0 }),
3025
- nextOffset: i
3305
+ value: s,
3306
+ nextOffset: o
3026
3307
  };
3027
3308
  }
3028
- let { value: r, nextOffset: i } = Y(e, t, a), o = Number(r), s = [], c = i;
3309
+ let { value: r, nextOffset: i } = Y(e, t, a), o = Number(r), s = [], c = /* @__PURE__ */ new Set(), l = [], u = i;
3029
3310
  for (let t = 0; t < o; t++) {
3030
- let t = X(e, c, n);
3031
- c = t.nextOffset;
3032
- let r = X(e, c, n);
3033
- c = r.nextOffset, s.push([t.value, r.value]);
3311
+ let t = X(e, u, n), r = hn(t.value);
3312
+ c.has(r) && l.push(q(`duplicate map key at offset ${t.value.start}`, t.value.start, n)), c.add(r), u = t.nextOffset;
3313
+ let i = X(e, u, n);
3314
+ u = i.nextOffset, s.push([t.value, i.value]);
3034
3315
  }
3316
+ let d = new k(s);
3317
+ for (let e of l) mn(d, e);
3035
3318
  return {
3036
- value: new D(s),
3037
- nextOffset: c
3319
+ value: d,
3320
+ nextOffset: u
3038
3321
  };
3039
3322
  }
3040
3323
  case 6: {
3041
- a === 31 && J("tags cannot use indefinite-length encoding");
3324
+ a === 31 && K("tags cannot use indefinite-length encoding");
3042
3325
  let { value: r, nextOffset: i } = Y(e, t, a), o = X(e, i, n);
3043
3326
  for (let e of [...n?.extensions ?? [], ...Z]) if (e.parseTag) {
3044
- let t = e.parseTag(r, o.value);
3327
+ let t = e.parseTag(r, o.value, n);
3045
3328
  if (t !== void 0) return {
3046
3329
  value: t,
3047
3330
  nextOffset: o.nextOffset
3048
3331
  };
3049
3332
  }
3050
3333
  return {
3051
- value: new S(r, o.value),
3334
+ value: new w(r, o.value),
3052
3335
  nextOffset: o.nextOffset
3053
3336
  };
3054
3337
  }
3055
3338
  case 7:
3056
3339
  if (a <= 19) return {
3057
- value: new O(a),
3340
+ value: new A(a),
3058
3341
  nextOffset: t
3059
3342
  };
3060
3343
  if (a === 20) return {
3061
- value: O.FALSE,
3344
+ value: A.FALSE,
3062
3345
  nextOffset: t
3063
3346
  };
3064
3347
  if (a === 21) return {
3065
- value: O.TRUE,
3348
+ value: A.TRUE,
3066
3349
  nextOffset: t
3067
3350
  };
3068
3351
  if (a === 22) return {
3069
- value: O.NULL,
3352
+ value: A.NULL,
3070
3353
  nextOffset: t
3071
3354
  };
3072
3355
  if (a === 23) return {
3073
- value: O.UNDEFINED,
3356
+ value: A.UNDEFINED,
3074
3357
  nextOffset: t
3075
3358
  };
3076
3359
  if (a === 24) {
3077
- t + 1 > e.byteLength && J("unexpected end of input");
3078
- let n = e.getUint8(t);
3079
- return n < 32 && J(`simple value ${n} must be encoded in initial byte (0–31 reserved for extended encoding)`), {
3080
- value: new O(n),
3360
+ t + 1 > e.byteLength && K("unexpected end of input");
3361
+ let r = e.getUint8(t);
3362
+ if (r < 32) {
3363
+ let e = q(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new A(r);
3364
+ return mn(i, e), {
3365
+ value: i,
3366
+ nextOffset: t + 1
3367
+ };
3368
+ }
3369
+ return {
3370
+ value: new A(r),
3081
3371
  nextOffset: t + 1
3082
3372
  };
3083
3373
  }
3084
- return a === 25 ? (t + 2 > e.byteLength && J("unexpected end of input"), {
3085
- value: new x(te(e.getUint16(t, !1)), { precision: "half" }),
3374
+ return a === 25 ? (t + 2 > e.byteLength && K("unexpected end of input"), {
3375
+ value: new C(v(e.getUint16(t, !1)), { precision: "half" }),
3086
3376
  nextOffset: t + 2
3087
- }) : a === 26 ? (t + 4 > e.byteLength && J("unexpected end of input"), {
3088
- value: new x(e.getFloat32(t, !1), { precision: "single" }),
3377
+ }) : a === 26 ? (t + 4 > e.byteLength && K("unexpected end of input"), {
3378
+ value: new C(e.getFloat32(t, !1), { precision: "single" }),
3089
3379
  nextOffset: t + 4
3090
- }) : a === 27 ? (t + 8 > e.byteLength && J("unexpected end of input"), {
3091
- value: new x(e.getFloat64(t, !1), { precision: "double" }),
3380
+ }) : a === 27 ? (t + 8 > e.byteLength && K("unexpected end of input"), {
3381
+ value: new C(e.getFloat64(t, !1), { precision: "double" }),
3092
3382
  nextOffset: t + 8
3093
- }) : (a < 31 && J(`reserved additional info value in major type 7: ${a}`), J("unexpected break code outside indefinite-length item"));
3383
+ }) : (a < 31 && K(`reserved additional info value in major type 7: ${a}`), K("unexpected break code outside indefinite-length item"));
3094
3384
  }
3095
- return J(`unknown major type: ${i}`);
3385
+ return K(`unknown major type: ${i}`);
3096
3386
  }
3097
- function fn(e) {
3387
+ function _n(e) {
3098
3388
  if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
3099
3389
  if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
3100
3390
  throw TypeError("expected ArrayBufferView or ArrayBufferLike");
3101
3391
  }
3102
- function pn(e, t) {
3103
- let n = fn(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
3392
+ function vn(e, t) {
3393
+ let n = _n(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
3104
3394
  if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
3105
3395
  let { value: a, nextOffset: o } = X(r, i, t);
3106
- return !t?.allowTrailing && o !== r.byteLength && J(`${r.byteLength - o} trailing byte(s) after end of CBOR item`), a;
3396
+ return !t?.allowTrailing && o !== r.byteLength && K(`${r.byteLength - o} trailing byte(s) after end of CBOR item`), a;
3107
3397
  }
3108
3398
  //#endregion
3109
3399
  //#region src/extensions/cbordata.ts
3110
- var mn = 24n, Z = [
3111
- Et,
3112
- Lt,
3113
- Bt,
3114
- ln,
3400
+ var yn = 24n, Z = [
3401
+ Ct,
3402
+ Rt,
3403
+ Vt,
3404
+ dn,
3115
3405
  {
3116
- tagNumbers: [mn],
3117
- parseTag(e, t) {
3118
- if (e === 24n && t instanceof C) try {
3119
- return new S(mn, new k([pn(t.value)]));
3120
- } catch {
3406
+ tagNumbers: [yn],
3407
+ parseTag(e, t, n) {
3408
+ if (e !== 24n || !(t instanceof T)) return;
3409
+ let r = n ? {
3410
+ extensions: n.extensions,
3411
+ strict: n.strict,
3412
+ onWarning: n.onWarning,
3413
+ silent: n.silent
3414
+ } : void 0;
3415
+ try {
3416
+ return new w(yn, new j([vn(t.value, r)]));
3417
+ } catch (e) {
3418
+ if (r?.strict !== !1) throw e;
3121
3419
  return;
3122
3420
  }
3123
3421
  }
@@ -3127,50 +3425,50 @@ var mn = 24n, Z = [
3127
3425
  //#region src/js/fromJS.ts
3128
3426
  function Q(e, t) {
3129
3427
  if (t?.replacer) {
3130
- let { replacer: n, ...r } = t, i = _n(e, n, r.extensions, r.undefinedOmits);
3131
- return i === l ? O.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
3428
+ let { replacer: n, ...r } = t, i = Sn(e, n, r.extensions, r.undefinedOmits);
3429
+ return i === l ? A.UNDEFINED : Q(i, Object.keys(r).length > 0 ? r : void 0);
3132
3430
  }
3133
- return hn(e, t, !0);
3431
+ return bn(e, t, !0);
3134
3432
  }
3135
- function hn(e, t, n) {
3433
+ function bn(e, t, n) {
3136
3434
  for (let n of [...t?.extensions ?? [], ...Z]) if (n.fromJS) {
3137
3435
  let r = n.fromJS(e, t ?? {});
3138
3436
  if (r !== void 0) return r;
3139
3437
  }
3140
3438
  if (n && typeof e == "object" && e && c.symbol in e) {
3141
- let n = e[c.symbol], r = hn(e, t, !1);
3439
+ let n = e[c.symbol], r = bn(e, t, !1);
3142
3440
  for (let e of [...t?.extensions ?? [], ...Z]) if (e.parseTag) {
3143
3441
  let t = e.parseTag(n, r);
3144
3442
  if (t !== void 0) return t;
3145
3443
  }
3146
- return new S(n, r);
3147
- }
3148
- if (e instanceof c.Null) return O.NULL;
3149
- if (e instanceof c.Undefined) return O.UNDEFINED;
3150
- if (e instanceof u) return new O(e.value);
3151
- if (e === null) return O.NULL;
3152
- if (e === void 0) return O.UNDEFINED;
3153
- if (e === !0) return O.TRUE;
3154
- if (e === !1) return O.FALSE;
3155
- if (typeof e == "bigint") return e > 18446744073709551615n ? new j(e) : e < -18446744073709551616n ? new M(e) : e >= 0n ? new g(e) : new _(e);
3156
- if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new g(BigInt(e)) : new _(BigInt(e)) : new x(e);
3157
- if (typeof e == "string") return new N(e);
3158
- if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return hn(e.valueOf(), t, !1);
3159
- if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new C(new Uint8Array(e));
3160
- if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new E(Array.from(e, (e) => new g(BigInt(e)))) : new C(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
3161
- if (e instanceof $) return new D([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
3162
- if (Array.isArray(e)) return new E(e.map((e) => Q(e, t)));
3444
+ return new w(n, r);
3445
+ }
3446
+ if (e instanceof c.Null) return A.NULL;
3447
+ if (e instanceof c.Undefined) return A.UNDEFINED;
3448
+ if (e instanceof u) return new A(e.value);
3449
+ if (e === null) return A.NULL;
3450
+ if (e === void 0) return A.UNDEFINED;
3451
+ if (e === !0) return A.TRUE;
3452
+ if (e === !1) return A.FALSE;
3453
+ if (typeof e == "bigint") return e > 18446744073709551615n ? new P(e) : e < -18446744073709551616n ? new F(e) : e >= 0n ? new x(e) : new S(e);
3454
+ if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new x(BigInt(e)) : new S(BigInt(e)) : new C(e);
3455
+ if (typeof e == "string") return new I(e);
3456
+ if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return bn(e.valueOf(), t, !1);
3457
+ if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new T(new Uint8Array(e));
3458
+ if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new O(Array.from(e, (e) => new x(BigInt(e)))) : new T(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
3459
+ if (e instanceof $) return new k([...e].map(([e, n]) => [Q(e, t), Q(n, t)]));
3460
+ if (Array.isArray(e)) return new O(e.map((e) => Q(e, t)));
3163
3461
  if (typeof e == "object") {
3164
3462
  let n = [];
3165
- for (let [r, i] of Object.entries(e)) n.push([new N(r), Q(i, t)]);
3166
- return new D(n);
3463
+ for (let [r, i] of Object.entries(e)) n.push([new I(r), Q(i, t)]);
3464
+ return new k(n);
3167
3465
  }
3168
3466
  throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
3169
3467
  }
3170
- function gn(e) {
3468
+ function xn(e) {
3171
3469
  return ArrayBuffer.isView(e) || e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer || e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]" || e instanceof c.Null || e instanceof c.Undefined || e instanceof u;
3172
3470
  }
3173
- function _n(e, t, n, r) {
3471
+ function Sn(e, t, n, r) {
3174
3472
  let i = [...n ?? [], ...Z];
3175
3473
  function a(e) {
3176
3474
  return e === l || r === !0 && e === void 0;
@@ -3181,7 +3479,7 @@ function _n(e, t, n, r) {
3181
3479
  if (typeof e != "object" || !e) return e;
3182
3480
  if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
3183
3481
  if (Array.isArray(e)) return e.map(r);
3184
- if (c.symbol in e || gn(e) || i.some((t) => t.isJSType?.(e))) return e;
3482
+ if (c.symbol in e || xn(e) || i.some((t) => t.isJSType?.(e))) return e;
3185
3483
  let t = Object.getPrototypeOf(e);
3186
3484
  if (t === Object.prototype || t === null) {
3187
3485
  let t = e.toJSON;
@@ -3216,7 +3514,7 @@ function _n(e, t, n, r) {
3216
3514
  let r = s(t, String(n), e);
3217
3515
  return a(r) ? null : r;
3218
3516
  });
3219
- if (gn(e) || i.some((t) => t.isJSType?.(e))) return e;
3517
+ if (xn(e) || i.some((t) => t.isJSType?.(e))) return e;
3220
3518
  let t = {};
3221
3519
  for (let n of Object.keys(e)) {
3222
3520
  let r = s(e[n], n, e);
@@ -3246,6 +3544,6 @@ var $ = class extends Array {
3246
3544
  }
3247
3545
  };
3248
3546
  //#endregion
3249
- export { l as C, n as D, c as E, u as S, t as T, S as _, Dt as a, g as b, M as c, O as d, D as f, C as g, w as h, pn as i, j as l, T as m, _n as n, N as o, E as p, Q as r, Ue as s, $ as t, k as u, x as v, e as w, d as x, _ as y };
3547
+ export { u as C, c as D, t as E, n as O, _ as S, e as T, w as _, wt as a, x as b, F as c, A as d, k as f, T as g, E as h, vn as i, P as l, D as m, Sn as n, I as o, O as p, Q as r, He as s, $ as t, j as u, C as v, l as w, v as x, S as y };
3250
3548
 
3251
- //# sourceMappingURL=mapEntries-Da-2HMRf.js.map
3549
+ //# sourceMappingURL=mapEntries-ZR8QJ0Yj.js.map