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