@cbortech/cbor 0.26.6 → 0.26.8

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 (49) hide show
  1. package/README.ja.md +125 -0
  2. package/README.md +124 -0
  3. package/dist/ast/CborByteString.d.ts +25 -0
  4. package/dist/ast/CborEllipsis.d.ts +94 -2
  5. package/dist/ast/CborFloat.d.ts +10 -0
  6. package/dist/ast/CborItem.d.ts +93 -4
  7. package/dist/ast/CborNint.d.ts +9 -0
  8. package/dist/ast/CborSimple.d.ts +11 -2
  9. package/dist/ast/CborTag.d.ts +8 -0
  10. package/dist/ast/CborTextString.d.ts +36 -0
  11. package/dist/ast/CborUint.d.ts +8 -0
  12. package/dist/ast/index.cjs +1 -1
  13. package/dist/ast/index.d.ts +1 -0
  14. package/dist/ast/index.js +2 -2
  15. package/dist/cddl/index.cjs +1 -1
  16. package/dist/cddl/index.js +1 -1
  17. package/dist/cdn/index.cjs +2 -2
  18. package/dist/cdn/index.cjs.map +1 -1
  19. package/dist/cdn/index.d.ts +2 -0
  20. package/dist/cdn/index.js +26 -26
  21. package/dist/cdn/index.js.map +1 -1
  22. package/dist/cdn/serialize-utils.d.ts +208 -9
  23. package/dist/extensions/dt.d.ts +3 -0
  24. package/dist/extensions/types.d.ts +31 -9
  25. package/dist/index.cjs +6 -6
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.js +62 -99
  29. package/dist/index.js.map +1 -1
  30. package/dist/mapEntries-BJzyBUH5.cjs +13 -0
  31. package/dist/mapEntries-BJzyBUH5.cjs.map +1 -0
  32. package/dist/{mapEntries-Czxt-cmd.js → mapEntries-Ci_dppP6.js} +1499 -1219
  33. package/dist/mapEntries-Ci_dppP6.js.map +1 -0
  34. package/dist/{schema-BmGsaEaW.cjs → schema-DgnkH0P6.cjs} +5 -5
  35. package/dist/{schema-BmGsaEaW.cjs.map → schema-DgnkH0P6.cjs.map} +1 -1
  36. package/dist/{schema-BxkgvUY6.js → schema-y8G5mDIS.js} +248 -248
  37. package/dist/{schema-BxkgvUY6.js.map → schema-y8G5mDIS.js.map} +1 -1
  38. package/dist/tokenizer-BD08xbyd.cjs +36 -0
  39. package/dist/tokenizer-BD08xbyd.cjs.map +1 -0
  40. package/dist/{tokenizer-CeuixxXi.js → tokenizer-N-vAvRdj.js} +350 -14
  41. package/dist/tokenizer-N-vAvRdj.js.map +1 -0
  42. package/dist/types.d.ts +176 -7
  43. package/package.json +2 -3
  44. package/dist/mapEntries-BhMlCwYo.cjs +0 -15
  45. package/dist/mapEntries-BhMlCwYo.cjs.map +0 -1
  46. package/dist/mapEntries-Czxt-cmd.js.map +0 -1
  47. package/dist/tokenizer-CeuixxXi.js.map +0 -1
  48. package/dist/tokenizer-EciPlN0n.cjs +0 -30
  49. package/dist/tokenizer-EciPlN0n.cjs.map +0 -1
@@ -1,22 +1,22 @@
1
- import { a as e, i as t, n, o as r, r as i, t as a } from "./tokenizer-CeuixxXi.js";
1
+ import { C as e, D as t, E as n, S as r, T as i, _ as a, a as o, b as s, c, d as l, f as u, g as d, h as f, i as p, l as ee, m as te, n as m, o as ne, p as h, r as g, s as _, t as re, u as ie, v, w as y, x as ae, y as oe } from "./tokenizer-N-vAvRdj.js";
2
2
  //#region src/tag.ts
3
- var o = Symbol.for("cbor.tag"), s = class {
3
+ var se = Symbol.for("cbor.tag"), ce = class {
4
4
  valueOf() {
5
5
  return null;
6
6
  }
7
7
  toJSON() {
8
8
  return null;
9
9
  }
10
- }, c = class {
10
+ }, le = class {
11
11
  valueOf() {}
12
12
  toJSON() {}
13
13
  };
14
- function l(e) {
15
- if (!p(e)) return;
16
- let t = e[o];
14
+ function ue(e) {
15
+ if (!me(e)) return;
16
+ let t = e[se];
17
17
  return typeof t == "bigint" ? t : void 0;
18
18
  }
19
- function u(e, t) {
19
+ function de(e, t) {
20
20
  let n;
21
21
  switch (typeof e) {
22
22
  case "number":
@@ -32,50 +32,50 @@ function u(e, t) {
32
32
  n = Object(e);
33
33
  break;
34
34
  case "undefined":
35
- n = new c();
35
+ n = new le();
36
36
  break;
37
37
  case "object":
38
38
  if (e === null) {
39
- n = new s();
39
+ n = new ce();
40
40
  break;
41
41
  }
42
42
  n = e;
43
43
  break;
44
44
  default: throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`);
45
45
  }
46
- return n[o] = t, n;
46
+ return n[se] = t, n;
47
47
  }
48
- function d(e) {
48
+ function fe(e) {
49
49
  if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
50
- if (e instanceof s) return null;
51
- if (!(e instanceof c)) return typeof e == "object" && e && delete e[o], e;
50
+ if (e instanceof ce) return null;
51
+ if (!(e instanceof le)) return typeof e == "object" && e && delete e[se], e;
52
52
  }
53
- function f(e) {
53
+ function pe(e) {
54
54
  if (e instanceof Number || e instanceof String || e instanceof Boolean || Object.prototype.toString.call(e) === "[object BigInt]") return e.valueOf();
55
- if (e instanceof s) return null;
56
- if (!(e instanceof c)) return e;
55
+ if (e instanceof ce) return null;
56
+ if (!(e instanceof le)) return e;
57
57
  }
58
- function p(e) {
58
+ function me(e) {
59
59
  return typeof e == "object" && !!e;
60
60
  }
61
- var m = class {
61
+ var b = class {
62
62
  constructor() {}
63
- static symbol = o;
64
- static Null = s;
65
- static Undefined = c;
63
+ static symbol = se;
64
+ static Null = ce;
65
+ static Undefined = le;
66
66
  static get(e) {
67
- return l(e);
67
+ return ue(e);
68
68
  }
69
69
  static set(e, t) {
70
- return u(e, t);
70
+ return de(e, t);
71
71
  }
72
72
  static remove(e) {
73
- return d(e);
73
+ return fe(e);
74
74
  }
75
75
  static getValue(e) {
76
- return f(e);
76
+ return pe(e);
77
77
  }
78
- }, h = Symbol("cbor.omit"), g = class e {
78
+ }, x = Symbol("cbor.omit"), he = class e {
79
79
  value;
80
80
  constructor(e) {
81
81
  if (!Number.isInteger(e) || e < 0 || e > 255) throw RangeError("Simple value must be an integer in 0–255");
@@ -93,211 +93,10 @@ var m = class {
93
93
  static get(t) {
94
94
  return t instanceof e ? t.value : void 0;
95
95
  }
96
- };
97
- //#endregion
98
- //#region src/cdn/serialize-utils.ts
99
- function _(e) {
100
- let t = e?.indent;
101
- if (t === void 0) return null;
102
- let n = typeof t == "number" ? " ".repeat(t) : t;
103
- return n === "" ? null : n;
104
- }
105
- function v(e, t) {
106
- return e.repeat(t);
107
- }
108
- function ee(e, t, n) {
109
- return t === null ? e.join(" + ") : e.join(` +\n${v(t, n + 1)}`);
110
- }
111
- function y(e) {
112
- return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
113
- }
114
- function te(e) {
115
- return !!(e.comments?.trailing?.length || e.comments?.dangling?.length);
116
- }
117
- function b(e, t) {
118
- if (!t) return e.text;
119
- let { marker: n, text: r } = e;
120
- if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
121
- if (n === "//") return "#" + r.slice(2);
122
- if (n === "/*") {
123
- let e = r.slice(2, -2);
124
- return e.includes("/") ? r : "/" + (e.startsWith("*") || e.startsWith("/") ? " " + e : e) + "/";
125
- }
126
- return r;
127
- }
128
- function ne(e, t, n) {
129
- return (e.comments?.leading ?? []).map((e) => t + b(e, n));
130
- }
131
- function re(e, t) {
132
- let n = e.comments?.trailing ?? [];
133
- return n.length === 0 ? "" : " " + n.map((e) => b(e, t)).join(" ");
134
- }
135
- function ie(e, t, n) {
136
- return (e.comments?.dangling ?? []).map((e) => t + b(e, n));
137
- }
138
- function ae(e, t = !1) {
139
- let n = e?.commas ?? "comma", r = n !== "none";
140
- return {
141
- inlineSep: r ? t ? "," : ", " : " ",
142
- multilineSep: r ? "," : "",
143
- trailSep: n === "trailing" ? "," : "",
144
- colSep: t ? ":" : ": "
145
- };
146
- }
147
- function x(e) {
148
- let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o = _(t), s = t?.preserveComments, c = typeof s == "string" ? s : void 0, l = o !== null && s && (te(e.node) || e.hasEntryComments()), { inlineSep: u, multilineSep: d, trailSep: f, colSep: p } = ae(t, o === null), m = e.indefiniteLength ? "" : w(t, e.encodingWidth, () => C(BigInt(a))), h = m ? m + " " : "", g = e.indefiniteLength && (t?.encodingIndicators ?? "auto") !== "never", ee = (t) => e.indefiniteLength ? g ? a === 0 ? `${r}_ ${i}` : `${r}_ ${t}${i}` : `${r}${t}${i}` : `${r}${h}${t}${i}`;
149
- if (o === null || a === 0 && !l) {
150
- let t = "";
151
- for (let n = 0; n < a; n++) n > 0 && (t += u), t += e.renderEntry(n, p);
152
- return ee(t);
153
- }
154
- let y = null;
155
- if (t?.inlineLeafContainers && a > 0 && !l) {
156
- let t = [], n = !0;
157
- for (let r = 0; r < a; r++) {
158
- if (e.entryIsLeaf && !e.entryIsLeaf(r)) {
159
- n = !1;
160
- break;
161
- }
162
- let i = e.renderEntry(r, p);
163
- if (t.push(i), i.includes("\n")) {
164
- n = !1;
165
- break;
166
- }
167
- }
168
- if (n) return ee(t.join(u));
169
- y = t;
170
- }
171
- let b = v(o, n + 1), re = v(o, n), x = e.indefiniteLength ? g ? `${r}_ ` : r : `${r}${h}`, S = [];
172
- for (let t = 0; t < a; t++) {
173
- s && S.push(...ne(e.entryLeadingNode(t), b, c));
174
- let n = t < a - 1 ? d : f, r = y?.[t] ?? e.renderEntry(t, p);
175
- S.push(`${b}${r}${n}${s ? e.entryTrailing(t, c) : ""}`);
176
- }
177
- return s && S.push(...ie(e.node, b, c)), `${x}\n${S.join("\n")}\n${re}${i}`;
178
- }
179
- var S = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
180
- function oe(e) {
181
- if (S) return e.toBase64({ omitPadding: !0 });
182
- let t = "";
183
- for (let n of e) t += String.fromCharCode(n);
184
- return btoa(t).replace(/=/g, "");
185
- }
186
- function se(e) {
187
- if (S) return e.toBase64({
188
- alphabet: "base64url",
189
- omitPadding: !0
190
- });
191
- let t = "";
192
- for (let n of e) t += String.fromCharCode(n);
193
- return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
194
- }
195
- var ce = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", le = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
196
- function ue(e, t) {
197
- let n = "", r = 0, i = 0;
198
- for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
199
- return i > 0 && (n += t[r << 5 - i & 31]), n;
200
- }
201
- function de(e) {
202
- for (let t of e) {
203
- let e = t.codePointAt(0);
204
- if (e < 32 || e === 127) return !0;
205
- }
206
- return !1;
207
- }
208
- function fe(e, t, n) {
209
- if (n === "string") {
210
- let t = me(e);
211
- if (t != null) return _e(t);
212
- }
213
- if (n === "printable-string" || n === void 0) {
214
- let t = me(e);
215
- if (t != null && !de(t)) return _e(t);
216
- }
217
- switch (t) {
218
- case "base64": return `b64'${oe(e)}'`;
219
- case "base64url": return `b64'${se(e)}'`;
220
- case "base32": return `b32'${ue(e, ce)}'`;
221
- case "base32hex": return `h32'${ue(e, le)}'`;
222
- default: return `h'${i(e)}'`;
223
- }
224
- }
225
- var pe = new TextDecoder("utf-8", { fatal: !0 });
226
- function me(e) {
227
- try {
228
- return pe.decode(e);
229
- } catch {
230
- return null;
231
- }
232
- }
233
- function he(e, t) {
234
- for (let n = 0; n < e.length; n++) {
235
- let r = e.charCodeAt(n);
236
- if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
237
- }
238
- return !1;
239
- }
240
- function ge(e, t) {
241
- let n = t.codePointAt(0);
242
- if (!he(e, n)) return t + e + t;
243
- let r = t;
244
- for (let i of e) {
245
- let e = i.codePointAt(0);
246
- switch (e) {
247
- case n:
248
- r += `\\${t}`;
249
- break;
250
- case 92:
251
- r += "\\\\";
252
- break;
253
- case 10:
254
- r += "\\n";
255
- break;
256
- case 13:
257
- r += "\\r";
258
- break;
259
- case 9:
260
- r += "\\t";
261
- break;
262
- 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;
263
- }
264
- }
265
- return r + t;
266
- }
267
- function _e(e) {
268
- return ge(e, "'");
269
- }
270
- function ve(e) {
271
- return ge(e, "'");
272
- }
273
- function ye(e) {
274
- return ge(e, "\"");
275
- }
276
- function be(e) {
277
- if (isNaN(e)) return "NaN";
278
- if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
279
- if (Object.is(e, -0)) return "-0.0";
280
- let t = e.toString();
281
- return t.includes(".") || t.includes("e") ? t : t + ".0";
282
- }
283
- function xe(e, t, n, r) {
284
- if (r === "never") return "";
285
- let i = t ?? n;
286
- return r === "always" ? i === "half" ? "_1" : i === "single" ? "_2" : "_3" : t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
287
- }
288
- function C(e) {
289
- return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
290
- }
291
- function w(e, t, n) {
292
- let r = e?.encodingIndicators ?? "auto";
293
- return r === "never" ? "" : r === "always" ? `_${t ?? n()}` : t === void 0 ? "" : `_${t}`;
294
- }
295
- //#endregion
296
- //#region src/utils/float16.ts
297
- var Se = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, Ce = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
298
- function T(e) {
299
- Ce.setFloat64(0, e, !1);
300
- let t = Ce.getUint32(0, !1), n = Ce.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
96
+ }, ge = "getFloat16" in DataView.prototype && "setFloat16" in DataView.prototype, _e = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
97
+ function S(e) {
98
+ _e.setFloat64(0, e, !1);
99
+ let t = _e.getUint32(0, !1), n = _e.getUint32(4, !1), r = t >>> 31 & 1, i = t >>> 20 & 2047, a = t & 1048575;
301
100
  if (i === 2047) {
302
101
  if (a === 0 && n === 0) return r << 15 | 31744;
303
102
  let e = a >> 10 | (n === 0 ? 0 : 1) || 1;
@@ -318,19 +117,19 @@ function T(e) {
318
117
  let u = o <= 0 ? 0 : o;
319
118
  return r << 15 | u << 10 | s;
320
119
  }
321
- function E(e) {
120
+ function C(e) {
322
121
  let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023;
323
122
  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);
324
123
  }
325
- var we = Se ? (e, t, n, r) => {
124
+ var ve = ge ? (e, t, n, r) => {
326
125
  e.setFloat16(t, n, r);
327
126
  } : (e, t, n, r) => {
328
- e.setUint16(t, T(n), r);
329
- }, Te = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), D = new Uint8Array(Te.buffer), Ee = new TextEncoder(), De = typeof Ee.encodeInto == "function";
330
- function Oe(e) {
127
+ e.setUint16(t, S(n), r);
128
+ }, w = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8)), T = new Uint8Array(w.buffer), ye = new TextEncoder(), be = typeof ye.encodeInto == "function";
129
+ function xe(e) {
331
130
  return e <= 23 ? 1 : e <= 255 ? 2 : e <= 65535 ? 3 : e <= 4294967295 ? 5 : 9;
332
131
  }
333
- function ke(e) {
132
+ function Se(e) {
334
133
  return e === "i" ? 1 : [
335
134
  2,
336
135
  3,
@@ -338,7 +137,7 @@ function ke(e) {
338
137
  9
339
138
  ][e];
340
139
  }
341
- var Ae = class {
140
+ var Ce = class {
342
141
  buf;
343
142
  len = 0;
344
143
  constructor(e = 256) {
@@ -369,45 +168,45 @@ var Ae = class {
369
168
  t[this.len++] = e >>> 24 & 255, t[this.len++] = e >>> 16 & 255, t[this.len++] = e >>> 8 & 255, t[this.len++] = e & 255;
370
169
  }
371
170
  writeBigUint64(e) {
372
- Te.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(D, this.len), this.len += 8;
171
+ w.setBigUint64(0, e, !1), this._ensure(8), this.buf.set(T, this.len), this.len += 8;
373
172
  }
374
173
  writeFloat16(e) {
375
- we(Te, 0, e, !1), this._ensure(2);
174
+ ve(w, 0, e, !1), this._ensure(2);
376
175
  let t = this.buf;
377
- t[this.len++] = D[0], t[this.len++] = D[1];
176
+ t[this.len++] = T[0], t[this.len++] = T[1];
378
177
  }
379
178
  writeFloat32(e) {
380
- Te.setFloat32(0, e, !1), this._ensure(4);
179
+ w.setFloat32(0, e, !1), this._ensure(4);
381
180
  let t = this.buf;
382
- t[this.len++] = D[0], t[this.len++] = D[1], t[this.len++] = D[2], t[this.len++] = D[3];
181
+ t[this.len++] = T[0], t[this.len++] = T[1], t[this.len++] = T[2], t[this.len++] = T[3];
383
182
  }
384
183
  writeFloat64(e) {
385
- Te.setFloat64(0, e, !1), this._ensure(8), this.buf.set(D, this.len), this.len += 8;
184
+ w.setFloat64(0, e, !1), this._ensure(8), this.buf.set(T, this.len), this.len += 8;
386
185
  }
387
186
  writeTextString(e, t, n) {
388
- if (!De) {
389
- let r = Ee.encode(t);
390
- O(this, e, r.length, n), this.writeBytes(r);
187
+ if (!be) {
188
+ let r = ye.encode(t);
189
+ E(this, e, r.length, n), this.writeBytes(r);
391
190
  return;
392
191
  }
393
- let r = n === void 0 ? Oe(t.length) : ke(n);
192
+ let r = n === void 0 ? xe(t.length) : Se(n);
394
193
  this._ensure(9 + 3 * t.length);
395
- let { written: i } = Ee.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? Oe(i) : r;
396
- a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), O(this, e, i, n), this.len += i;
194
+ let { written: i } = ye.encodeInto(t, this.buf.subarray(this.len + r)), a = n === void 0 ? xe(i) : r;
195
+ a !== r && this.buf.copyWithin(this.len + a, this.len + r, this.len + r + i), E(this, e, i, n), this.len += i;
397
196
  }
398
197
  finish() {
399
198
  return this.buf.slice(0, this.len);
400
199
  }
401
- }, je = [
200
+ }, we = [
402
201
  255n,
403
202
  65535n,
404
203
  4294967295n,
405
204
  18446744073709551615n
406
205
  ];
407
- function Me(e) {
408
- return e === "i" ? 23n : je[e];
206
+ function Te(e) {
207
+ return e === "i" ? 23n : we[e];
409
208
  }
410
- function O(e, t, n, r) {
209
+ function E(e, t, n, r) {
411
210
  if (r === void 0 && typeof n == "number" && n < 4294967296) {
412
211
  n <= 23 ? e.writeByte(t << 5 | n) : n <= 255 ? (e.writeByte(t << 5 | 24), e.writeByte(n)) : n <= 65535 ? (e.writeByte(t << 5 | 25), e.writeUint16(n)) : (e.writeByte(t << 5 | 26), e.writeUint32(n));
413
212
  return;
@@ -419,33 +218,52 @@ function O(e, t, n, r) {
419
218
  e.writeByte(t << 5 | Number(i));
420
219
  return;
421
220
  }
422
- if (i > je[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${je[r]})`);
221
+ if (i > we[r]) throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${we[r]})`);
423
222
  let n = 24 + r;
424
223
  e.writeByte(t << 5 | n), n === 24 ? e.writeByte(Number(i)) : n === 25 ? e.writeUint16(Number(i)) : n === 26 ? e.writeUint32(Number(i)) : e.writeBigUint64(i);
425
224
  return;
426
225
  }
427
226
  i <= 23n ? e.writeByte(t << 5 | Number(i)) : i <= 255n ? (e.writeByte(t << 5 | 24), e.writeByte(Number(i))) : i <= 65535n ? (e.writeByte(t << 5 | 25), e.writeUint16(Number(i))) : i <= 4294967295n ? (e.writeByte(t << 5 | 26), e.writeUint32(Number(i))) : (e.writeByte(t << 5 | 27), e.writeBigUint64(i));
428
227
  }
429
- function Ne(e, t, n) {
430
- let r = new Ae(9);
431
- return O(r, e, t, n), r.finish();
228
+ function Ee(e, t, n) {
229
+ let r = new Ce(9);
230
+ return E(r, e, t, n), r.finish();
432
231
  }
433
- var Pe = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
434
- function Fe(e) {
435
- return Object.is(E(T(e)), e);
232
+ var De = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4));
233
+ function Oe(e) {
234
+ return Object.is(C(S(e)), e);
436
235
  }
437
- function Ie(e) {
438
- return Pe.setFloat32(0, e, !1), Object.is(Pe.getFloat32(0, !1), e);
236
+ function ke(e) {
237
+ return De.setFloat32(0, e, !1), Object.is(De.getFloat32(0, !1), e);
439
238
  }
440
- function k(e) {
441
- return Fe(e) ? "half" : Ie(e) ? "single" : "double";
239
+ function D(e) {
240
+ return Oe(e) ? "half" : ke(e) ? "single" : "double";
442
241
  }
443
242
  //#endregion
444
243
  //#region src/ast/CborItem.ts
445
- var A = class e {
244
+ function Ae(e) {
245
+ return {
246
+ ...e,
247
+ preserveComments: e.preserveComments ?? !0,
248
+ preserveByteString: e.preserveByteString ?? !0,
249
+ preserveRawString: e.preserveRawString ?? !0,
250
+ preserveConcatenation: e.preserveConcatenation ?? !0,
251
+ preserveNumberFormat: e.preserveNumberFormat ?? !0,
252
+ preserveAppSequence: e.preserveAppSequence ?? !0,
253
+ preserveBlankLines: e.preserveBlankLines ?? !0
254
+ };
255
+ }
256
+ var O = class e {
446
257
  start;
447
258
  end;
448
259
  comments;
260
+ blankLineBefore;
261
+ appSeqSource;
262
+ appSeqComments;
263
+ appSeqEncodingEdits;
264
+ appSeqEncodingEditsComplete;
265
+ appSeqInnerEnd;
266
+ appSeqSourceFeatures;
449
267
  warnings;
450
268
  _defaults;
451
269
  get _containsCdnContainer() {
@@ -455,17 +273,19 @@ var A = class e {
455
273
  let t = this._defaults ? {
456
274
  ...this._defaults,
457
275
  ...e
458
- } : e, n = new Ae();
276
+ } : e, n = new Ce();
459
277
  return this._encode(n, t), n.finish();
460
278
  }
461
279
  toCDN(e) {
462
280
  let t = this._defaults ? {
463
281
  ...this._defaults,
464
282
  ...e
465
- } : e, n = this._toCDN(t, 0), r = t?.preserveComments;
466
- if (!r || _(t) === null) return n;
467
- let i = typeof r == "string" ? r : void 0, a = this.comments?.leading?.map((e) => b(e, i)) ?? [], o = this.comments?.trailing ?? [], s = o.length === 0 ? n : `${n} ${o.map((e) => b(e, i).trimEnd()).join(" ")}`;
468
- return [...a, s].join("\n");
283
+ } : e;
284
+ t?.preserveAll && (t = Ae(t));
285
+ let n = this._toCDN(t, 0), r = t?.preserveComments;
286
+ if (!r || v(t) === null) return n;
287
+ let i = typeof r == "string" ? r : void 0, { ownLines: a, inlinePrefix: s } = ae(this, "", i), c = this.comments?.trailing ?? [], l = c.length === 0 ? n : `${n} ${c.map((e) => o(e, i).trimEnd()).join(" ")}`;
288
+ return [...a, `${s}${l}`].join("\n");
469
289
  }
470
290
  toEDN(e) {
471
291
  return this.toCDN(e);
@@ -477,7 +297,7 @@ var A = class e {
477
297
  } : e, n = this._toJS(t);
478
298
  if (!t?.reviver) return n;
479
299
  let r = t.reviver.call({ "": n }, "", n);
480
- return r === h ? void 0 : r;
300
+ return r === x ? void 0 : r;
481
301
  }
482
302
  toHexDump(e) {
483
303
  let t = this._defaults ? {
@@ -503,29 +323,32 @@ var A = class e {
503
323
  t.writeBytes(this._toCBOR(n));
504
324
  }
505
325
  _toCBOR(e) {
506
- let t = new Ae();
326
+ let t = new Ce();
507
327
  return this._encodeTo(t, e), t.finish();
508
328
  }
509
- _toHexDump(e, n) {
329
+ _toHexDump(e, t) {
510
330
  return [{
511
331
  depth: e,
512
- hex: t(this._toCBOR()),
513
- comment: this._toCDN(n, 0)
332
+ hex: i(this._toCBOR()),
333
+ comment: this._toCDN(t, 0)
514
334
  }];
515
335
  }
516
- }, j = class extends A {
336
+ }, k = class extends O {
517
337
  value;
518
338
  encodingWidth;
339
+ ednSource;
519
340
  constructor(e, t) {
520
341
  if (super(), this.value = BigInt(e), this.value < 0n) throw RangeError("CborUint value must be non-negative");
521
342
  if (this.value > 18446744073709551615n) throw RangeError("CborUint value exceeds maximum uint64");
522
- this.encodingWidth = t?.encodingWidth;
343
+ this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
523
344
  }
524
345
  _encodeTo(e, t) {
525
- O(e, 0, this.value, this.encodingWidth);
346
+ E(e, 0, this.value, this.encodingWidth);
526
347
  }
527
348
  _toCDN(e, t) {
528
- let n = w(e, this.encodingWidth, () => C(this.value)), r = this.value;
349
+ let n = a(e, this.encodingWidth, () => p(this.value));
350
+ if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource + n;
351
+ let r = this.value;
529
352
  switch (e?.intFormat) {
530
353
  case "hex": return `0x${r.toString(16)}${n}`;
531
354
  case "octal": return `0o${r.toString(8)}${n}`;
@@ -537,24 +360,27 @@ var A = class e {
537
360
  let t = e?.integerAs ?? "auto";
538
361
  return t === "bigint" ? this.value : t === "number" || this.value <= BigInt(2 ** 53 - 1) ? Number(this.value) : this.value;
539
362
  }
540
- }, M = class extends A {
363
+ }, A = class extends O {
541
364
  argument;
542
365
  encodingWidth;
366
+ ednSource;
543
367
  constructor(e, t) {
544
368
  super();
545
369
  let n = BigInt(e);
546
370
  if (n >= 0n) throw RangeError("CborNint value must be negative");
547
371
  if (n < -18446744073709551616n) throw RangeError("CborNint value exceeds minimum int64");
548
- this.argument = -1n - n, this.encodingWidth = t?.encodingWidth;
372
+ this.argument = -1n - n, this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource;
549
373
  }
550
374
  get value() {
551
375
  return -1n - this.argument;
552
376
  }
553
377
  _encodeTo(e, t) {
554
- O(e, 1, this.argument, this.encodingWidth);
378
+ E(e, 1, this.argument, this.encodingWidth);
555
379
  }
556
380
  _toCDN(e, t) {
557
- let n = w(e, this.encodingWidth, () => C(this.argument)), r = this.argument + 1n;
381
+ let n = a(e, this.encodingWidth, () => p(this.argument));
382
+ if (e?.preserveNumberFormat && this.ednSource !== void 0) return this.ednSource + n;
383
+ let r = this.argument + 1n;
558
384
  switch (e?.intFormat) {
559
385
  case "hex": return `-0x${r.toString(16)}${n}`;
560
386
  case "octal": return `-0o${r.toString(8)}${n}`;
@@ -566,8 +392,8 @@ var A = class e {
566
392
  let t = this.value, n = e?.integerAs ?? "auto";
567
393
  return n === "bigint" ? t : n === "number" || t >= BigInt(-(2 ** 53 - 1)) ? Number(t) : t;
568
394
  }
569
- }, Le = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
570
- function Re(e) {
395
+ }, je = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(8));
396
+ function Me(e) {
571
397
  let t = e.startsWith("-"), n = e.slice(t ? 3 : 2), r = n.search(/[pP]/);
572
398
  if (r === -1) throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);
573
399
  let i = n.slice(0, r), a = n.slice(r + 1);
@@ -585,115 +411,134 @@ function Re(e) {
585
411
  let l = c * 2 ** o;
586
412
  return t ? -l : l;
587
413
  }
588
- function ze(e) {
414
+ function Ne(e) {
589
415
  if (isNaN(e)) return "NaN";
590
416
  if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
591
417
  let t = Object.is(e, -0) || e < 0, n = Math.abs(e);
592
418
  if (n === 0) return t ? "-0x0p+0" : "0x0p+0";
593
- Le.setFloat64(0, n, !1);
594
- let r = Le.getUint32(0, !1), i = Le.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
419
+ je.setFloat64(0, n, !1);
420
+ let r = je.getUint32(0, !1), i = je.getUint32(4, !1), a = r >>> 20 & 2047, o = r & 1048575, s = i, c = (o.toString(16).padStart(5, "0") + s.toString(16).padStart(8, "0")).replace(/0+$/, ""), l = c === "" ? "" : `.${c}`, u, d;
595
421
  a === 0 ? (u = "0", d = -1022) : (u = "1", d = a - 1023);
596
422
  let f = d >= 0 ? `+${d}` : `${d}`, p = `0x${u}${l}p${f}`;
597
423
  return t ? `-${p}` : p;
598
424
  }
599
425
  //#endregion
600
426
  //#region src/ast/CborFloat.ts
601
- var N = class extends A {
427
+ var j = class extends O {
602
428
  value;
603
429
  precision;
604
430
  ednSource;
431
+ literalSource;
605
432
  rawBits;
606
433
  constructor(e, t) {
607
- super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits;
434
+ super(), this.value = e, this.precision = t?.precision, this.rawBits = t?.rawBits, this.literalSource = t?.literalSource;
608
435
  }
609
436
  _encodeTo(e, t) {
610
- let n = this.precision ?? k(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
437
+ let n = this.precision ?? D(this.value), r = Number.isNaN(this.value) ? this.rawBits : void 0;
611
438
  n === "half" ? (e.writeByte(249), r?.length === 2 ? e.writeBytes(r) : e.writeFloat16(this.value)) : n === "single" ? (e.writeByte(250), r?.length === 4 ? e.writeBytes(r) : e.writeFloat32(this.value)) : (e.writeByte(251), r?.length === 8 ? e.writeBytes(r) : e.writeFloat64(this.value));
612
439
  }
613
440
  _toCDN(e, t) {
614
441
  let n = e?.encodingIndicators ?? "auto";
615
- if (e?.appStrings !== !1 && this.ednSource !== void 0 && (_(e) !== null || !/[\r\n]/.test(this.ednSource))) {
442
+ if (e?.appStrings !== !1 && this.ednSource !== void 0 && (v(e) !== null || !/[\r\n]/.test(this.ednSource))) {
616
443
  let e = this.ednSource;
617
444
  if (n === "never") return e.replace(/_[0-3i]$/, "");
618
445
  if (n === "always") {
619
446
  if (/_[0-3i]$/.test(e)) return e;
620
- let t = this.precision ?? k(this.value);
447
+ let t = this.precision ?? D(this.value);
621
448
  return e + (t === "half" ? "_1" : t === "single" ? "_2" : "_3");
622
449
  }
623
450
  return e;
624
451
  }
625
- let r = k(this.value);
626
- return (e?.floatFormat === "hex" ? ze(this.value) : be(this.value)) + xe(this.value, this.precision, r, n);
452
+ if (e?.preserveNumberFormat && this.literalSource !== void 0) {
453
+ let e = this.literalSource;
454
+ if (n === "never") return e.replace(/_[0-7i]$/, "");
455
+ if (n === "always") {
456
+ if (/_[0-7i]$/.test(e)) return e;
457
+ let t = D(this.value);
458
+ return e + ie(this.value, this.precision, t, "always");
459
+ }
460
+ return e;
461
+ }
462
+ let r = D(this.value);
463
+ return (e?.floatFormat === "hex" ? Ne(this.value) : l(this.value)) + ie(this.value, this.precision, r, n);
627
464
  }
628
465
  _toJS(e) {
629
466
  return this.value;
630
467
  }
631
- }, P = class extends A {
468
+ }, M = class extends O {
632
469
  tag;
633
470
  content;
634
471
  encodingWidth;
472
+ ednSource;
635
473
  constructor(e, t, n) {
636
474
  if (super(), this.tag = BigInt(e), this.tag < 0n) throw RangeError("CborTag tag number must be non-negative");
637
- this.content = t, this.encodingWidth = n?.encodingWidth;
475
+ this.content = t, this.encodingWidth = n?.encodingWidth, this.ednSource = n?.ednSource;
638
476
  }
639
477
  get _containsCdnContainer() {
640
478
  return this.content._containsCdnContainer;
641
479
  }
642
480
  _encodeTo(e, t) {
643
- O(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
481
+ E(e, 6, this.tag, this.encodingWidth), this.content._encode(e, t);
644
482
  }
645
483
  _toCDN(e, t) {
646
- let n = w(e, this.encodingWidth, () => C(this.tag));
647
- return `${this.tag}${n}(${this.content._toCDN(e, t)})`;
484
+ let n = a(e, this.encodingWidth, () => p(this.tag));
485
+ return `${e?.preserveNumberFormat && this.ednSource !== void 0 ? this.ednSource : this.tag.toString()}${n}${d(this.content, this, e, t, (t) => this.content._toCDN(e, t), "(", ")")}`;
648
486
  }
649
- _toHexDump(e, n) {
650
- let r = [{
487
+ _toHexDump(e, t) {
488
+ let n = [{
651
489
  depth: e,
652
- hex: t(Ne(6, this.tag, this.encodingWidth)),
490
+ hex: i(Ee(6, this.tag, this.encodingWidth)),
653
491
  comment: `Tag ${this.tag}`
654
492
  }];
655
- return r.push(...this.content._toHexDump(e + 1, {
656
- ...n,
493
+ return n.push(...this.content._toHexDump(e + 1, {
494
+ ...t,
657
495
  appStrings: !1
658
- })), r;
496
+ })), n;
659
497
  }
660
498
  _toJS(e) {
661
499
  let t = this.content._toJS(e);
662
- return e?.stripTags ? t : m.set(t, this.tag);
500
+ return e?.stripTags ? t : b.set(t, this.tag);
663
501
  }
664
- }, F = class extends A {
502
+ };
503
+ //#endregion
504
+ //#region src/ast/CborByteString.ts
505
+ function Pe(e, t, n) {
506
+ if (e !== void 0) return t?.preserveComments || n === void 0 ? e : r(e, n);
507
+ }
508
+ var N = class extends O {
665
509
  indefiniteLength = !1;
666
510
  value;
667
511
  ednEncoding;
668
512
  encodingWidth;
669
513
  ednSource;
514
+ ednCommentSyntax;
670
515
  ednParts;
671
516
  constructor(e, t) {
672
- super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednParts = t?.ednParts;
517
+ super(), this.value = e, this.ednEncoding = t?.ednEncoding ?? "hex", this.encodingWidth = t?.encodingWidth, this.ednSource = t?.ednSource, this.ednCommentSyntax = t?.ednCommentSyntax, this.ednParts = t?.ednParts;
673
518
  }
674
519
  _encodeTo(e, t) {
675
- O(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
520
+ E(e, 2, this.value.length, this.encodingWidth), e.writeBytes(this.value);
676
521
  }
677
522
  _toCDN(e, t) {
678
- let n = _(e);
523
+ let n = v(e);
679
524
  if (e?.preserveConcatenation && n !== null && this.ednParts !== void 0 && this.ednParts.length > 1) {
680
- let r = w(e, this.encodingWidth, () => C(BigInt(this.value.length))), i = e?.bstrEncoding ?? this.ednEncoding;
525
+ let r = a(e, this.encodingWidth, () => p(BigInt(this.value.length))), i = e?.bstrEncoding ?? this.ednEncoding;
681
526
  e?.appStrings === !1 && i !== "hex" && (i = "hex");
682
- let a = this.ednParts.map((t) => e?.preserveByteString && t.source !== void 0 ? t.source : fe(t.bytes, i, e?.sqstr));
683
- return a[a.length - 1] += r, ee(a, n, t);
684
- }
685
- if (e?.preserveByteString && this.ednSource !== void 0 && (n !== null || !/[\r\n]/.test(this.ednSource))) {
686
- if (/_[0-3i]$/.test(this.ednSource)) return (e?.encodingIndicators ?? "auto") === "never" ? this.ednSource.replace(/_[0-3i]$/, "") : this.ednSource;
687
- let t = w(e, this.encodingWidth, () => C(BigInt(this.value.length)));
688
- return this.ednSource + t;
527
+ let o = this.ednParts.map((t) => {
528
+ let n = e?.preserveByteString ? Pe(t.source, e, t.commentSyntax) : void 0;
529
+ return n === void 0 ? oe(t.bytes, i, e?.sqstr) : n;
530
+ });
531
+ return o[o.length - 1] += r, f(o, n, t, e?.preserveComments ? ne(this.comments?.dangling, this.ednParts, typeof e.preserveComments == "string" ? e.preserveComments : void 0) : void 0);
689
532
  }
690
- let r = w(e, this.encodingWidth, () => C(BigInt(this.value.length))), i = e?.bstrEncoding ?? this.ednEncoding;
691
- return e?.appStrings === !1 && i !== "hex" && (i = "hex"), fe(this.value, i, e?.sqstr) + r;
533
+ let r = e?.preserveByteString ? Pe(this.ednSource, e, this.ednCommentSyntax) : void 0;
534
+ if (r !== void 0 && (n !== null || !/[\r\n]/.test(r))) return /_[0-3i]$/.test(r) ? (e?.encodingIndicators ?? "auto") === "never" ? r.replace(/_[0-3i]$/, "") : r : r + a(e, this.encodingWidth, () => p(BigInt(this.value.length)));
535
+ let i = a(e, this.encodingWidth, () => p(BigInt(this.value.length))), o = e?.bstrEncoding ?? this.ednEncoding;
536
+ return e?.appStrings === !1 && o !== "hex" && (o = "hex"), oe(this.value, o, e?.sqstr) + i;
692
537
  }
693
538
  _toJS(e) {
694
539
  return this.value;
695
540
  }
696
- }, I = class extends A {
541
+ }, P = class extends O {
697
542
  indefiniteLength = !0;
698
543
  chunks;
699
544
  constructor(e) {
@@ -708,9 +553,9 @@ var N = class extends A {
708
553
  if ((e?.encodingIndicators ?? "auto") === "never") {
709
554
  let n = this.chunks.reduce((e, t) => e + t.value.length, 0), r = new Uint8Array(n), i = 0;
710
555
  for (let e of this.chunks) r.set(e.value, i), i += e.value.length;
711
- return new F(r)._toCDN(e, t);
556
+ return new N(r)._toCDN(e, t);
712
557
  }
713
- return this.chunks.length === 0 ? "''_" : x({
558
+ return this.chunks.length === 0 ? "''_" : s({
714
559
  node: this,
715
560
  options: e,
716
561
  depth: t,
@@ -719,22 +564,22 @@ var N = class extends A {
719
564
  count: this.chunks.length,
720
565
  indefiniteLength: !0,
721
566
  encodingWidth: void 0,
722
- hasEntryComments: () => this.chunks.some(y),
567
+ hasEntryComments: () => this.chunks.some(h),
723
568
  renderEntry: (n) => this.chunks[n]._toCDN(e, t + 1),
724
569
  entryLeadingNode: (e) => this.chunks[e],
725
- entryTrailing: (e, t) => re(this.chunks[e], t)
570
+ entryTrailing: (e, t) => u(this.chunks[e], t)
726
571
  });
727
572
  }
728
- _toHexDump(e, t) {
573
+ _toHexDump(t, n) {
729
574
  let r = [{
730
- depth: e,
731
- hex: n(95),
575
+ depth: t,
576
+ hex: e(95),
732
577
  comment: "Start indefinite-length byte string"
733
578
  }];
734
- for (let n of this.chunks) r.push(...n._toHexDump(e + 1, t));
579
+ for (let e of this.chunks) r.push(...e._toHexDump(t + 1, n));
735
580
  return r.push({
736
- depth: e,
737
- hex: n(255),
581
+ depth: t,
582
+ hex: e(255),
738
583
  comment: "\"break\""
739
584
  }), r;
740
585
  }
@@ -743,7 +588,7 @@ var N = class extends A {
743
588
  for (let e of this.chunks) n.set(e.value, r), r += e.value.length;
744
589
  return n;
745
590
  }
746
- }, L = class extends A {
591
+ }, F = class extends O {
747
592
  indefiniteLength = !0;
748
593
  chunks;
749
594
  constructor(e) {
@@ -755,7 +600,7 @@ var N = class extends A {
755
600
  e.writeByte(255);
756
601
  }
757
602
  _toCDN(e, t) {
758
- return (e?.encodingIndicators ?? "auto") === "never" ? new U(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : x({
603
+ return (e?.encodingIndicators ?? "auto") === "never" ? new G(this.chunks.map((e) => e.value).join(""))._toCDN(e, t) : this.chunks.length === 0 ? "\"\"_" : s({
759
604
  node: this,
760
605
  options: e,
761
606
  depth: t,
@@ -764,29 +609,29 @@ var N = class extends A {
764
609
  count: this.chunks.length,
765
610
  indefiniteLength: !0,
766
611
  encodingWidth: void 0,
767
- hasEntryComments: () => this.chunks.some(y),
612
+ hasEntryComments: () => this.chunks.some(h),
768
613
  renderEntry: (n) => this.chunks[n]._toCDN(e, t + 1),
769
614
  entryLeadingNode: (e) => this.chunks[e],
770
- entryTrailing: (e, t) => re(this.chunks[e], t)
615
+ entryTrailing: (e, t) => u(this.chunks[e], t)
771
616
  });
772
617
  }
773
- _toHexDump(e, t) {
618
+ _toHexDump(t, n) {
774
619
  let r = [{
775
- depth: e,
776
- hex: n(127),
620
+ depth: t,
621
+ hex: e(127),
777
622
  comment: "Start indefinite-length text string"
778
623
  }];
779
- for (let n of this.chunks) r.push(...n._toHexDump(e + 1, t));
624
+ for (let e of this.chunks) r.push(...e._toHexDump(t + 1, n));
780
625
  return r.push({
781
- depth: e,
782
- hex: n(255),
626
+ depth: t,
627
+ hex: e(255),
783
628
  comment: "\"break\""
784
629
  }), r;
785
630
  }
786
631
  _toJS(e) {
787
632
  return this.chunks.map((e) => e.value).join("");
788
633
  }
789
- }, R = class extends A {
634
+ }, I = class extends O {
790
635
  items;
791
636
  indefiniteLength;
792
637
  encodingWidth;
@@ -803,11 +648,11 @@ var N = class extends A {
803
648
  e.writeByte(255);
804
649
  return;
805
650
  }
806
- O(e, 4, this.items.length, this.encodingWidth);
651
+ E(e, 4, this.items.length, this.encodingWidth);
807
652
  for (let n of this.items) n._encode(e, t);
808
653
  }
809
654
  _toCDN(e, t) {
810
- return x({
655
+ return s({
811
656
  node: this,
812
657
  options: e,
813
658
  depth: t,
@@ -816,34 +661,34 @@ var N = class extends A {
816
661
  count: this.items.length,
817
662
  indefiniteLength: this.indefiniteLength,
818
663
  encodingWidth: this.encodingWidth,
819
- hasEntryComments: () => this.items.some(y),
664
+ hasEntryComments: () => this.items.some(h),
820
665
  renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
821
666
  entryIsLeaf: (e) => !this.items[e]._containsCdnContainer,
822
667
  entryLeadingNode: (e) => this.items[e],
823
- entryTrailing: (e, t) => re(this.items[e], t)
668
+ entryTrailing: (e, t) => u(this.items[e], t)
824
669
  });
825
670
  }
826
- _toHexDump(e, r) {
671
+ _toHexDump(t, n) {
827
672
  if (this.indefiniteLength) {
828
- let t = [{
829
- depth: e,
830
- hex: n(159),
673
+ let r = [{
674
+ depth: t,
675
+ hex: e(159),
831
676
  comment: "Start indefinite-length array"
832
677
  }];
833
- for (let n of this.items) t.push(...n._toHexDump(e + 1, r));
834
- return t.push({
835
- depth: e,
836
- hex: n(255),
678
+ for (let e of this.items) r.push(...e._toHexDump(t + 1, n));
679
+ return r.push({
680
+ depth: t,
681
+ hex: e(255),
837
682
  comment: "\"break\""
838
- }), t;
683
+ }), r;
839
684
  }
840
- let i = [{
841
- depth: e,
842
- hex: t(Ne(4, BigInt(this.items.length), this.encodingWidth)),
685
+ let r = [{
686
+ depth: t,
687
+ hex: i(Ee(4, BigInt(this.items.length), this.encodingWidth)),
843
688
  comment: `Array of length ${this.items.length}`
844
689
  }];
845
- for (let t of this.items) i.push(...t._toHexDump(e + 1, r));
846
- return i;
690
+ for (let e of this.items) r.push(...e._toHexDump(t + 1, n));
691
+ return r;
847
692
  }
848
693
  _toJS(e) {
849
694
  let t = e?.reviver;
@@ -854,11 +699,11 @@ var N = class extends A {
854
699
  } : void 0, r = this.items.map((e) => e._toJS(n)), i = 0;
855
700
  for (let n = 0; n < this.items.length; n++) {
856
701
  let a = n - i, o = this.items[n]._toJS(e), s = t.call(r, String(n), o);
857
- s === h || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
702
+ s === x || e?.undefinedOmits && s === void 0 ? (r.splice(a, 1), i++) : r[a] = s;
858
703
  }
859
704
  return r;
860
705
  }
861
- }, z = class extends A {
706
+ }, L = class extends O {
862
707
  entries;
863
708
  indefiniteLength;
864
709
  encodingWidth;
@@ -875,11 +720,11 @@ var N = class extends A {
875
720
  e.writeByte(255);
876
721
  return;
877
722
  }
878
- O(e, 5, this.entries.length, this.encodingWidth);
723
+ E(e, 5, this.entries.length, this.encodingWidth);
879
724
  for (let [n, r] of this.entries) n._encode(e, t), r._encode(e, t);
880
725
  }
881
726
  _toCDN(e, t) {
882
- return x({
727
+ return s({
883
728
  node: this,
884
729
  options: e,
885
730
  depth: t,
@@ -888,7 +733,7 @@ var N = class extends A {
888
733
  count: this.entries.length,
889
734
  indefiniteLength: this.indefiniteLength,
890
735
  encodingWidth: this.encodingWidth,
891
- hasEntryComments: () => this.entries.some(([e, t]) => y(e) || y(t)),
736
+ hasEntryComments: () => this.entries.some(([e, t]) => h(e) || h(t)),
892
737
  renderEntry: (n, r) => {
893
738
  let [i, a] = this.entries[n];
894
739
  return `${i._toCDN(e, t + 1)}${r}${a._toCDN(e, t + 1)}`;
@@ -900,7 +745,7 @@ var N = class extends A {
900
745
  entryLeadingNode: (e) => this.entries[e][0],
901
746
  entryTrailing: (e, t) => {
902
747
  let [n, r] = this.entries[e];
903
- return Be([
748
+ return Fe([
904
749
  ...n.comments?.trailing ?? [],
905
750
  ...r.comments?.leading ?? [],
906
751
  ...r.comments?.trailing ?? []
@@ -908,27 +753,27 @@ var N = class extends A {
908
753
  }
909
754
  });
910
755
  }
911
- _toHexDump(e, r) {
756
+ _toHexDump(t, n) {
912
757
  if (this.indefiniteLength) {
913
- let t = [{
914
- depth: e,
915
- hex: n(191),
758
+ let r = [{
759
+ depth: t,
760
+ hex: e(191),
916
761
  comment: "Start indefinite-length map"
917
762
  }];
918
- for (let [n, i] of this.entries) t.push(...n._toHexDump(e + 1, r)), t.push(...i._toHexDump(e + 1, r));
919
- return t.push({
920
- depth: e,
921
- hex: n(255),
763
+ for (let [e, i] of this.entries) r.push(...e._toHexDump(t + 1, n)), r.push(...i._toHexDump(t + 1, n));
764
+ return r.push({
765
+ depth: t,
766
+ hex: e(255),
922
767
  comment: "\"break\""
923
- }), t;
768
+ }), r;
924
769
  }
925
- let i = [{
926
- depth: e,
927
- hex: t(Ne(5, BigInt(this.entries.length), this.encodingWidth)),
770
+ let r = [{
771
+ depth: t,
772
+ hex: i(Ee(5, BigInt(this.entries.length), this.encodingWidth)),
928
773
  comment: `Map of length ${this.entries.length}`
929
774
  }];
930
- for (let [t, n] of this.entries) i.push(...t._toHexDump(e + 1, r)), i.push(...n._toHexDump(e + 1, r));
931
- return i;
775
+ for (let [e, i] of this.entries) r.push(...e._toHexDump(t + 1, n)), r.push(...i._toHexDump(t + 1, n));
776
+ return r;
932
777
  }
933
778
  _toJS(e) {
934
779
  let t = e?.reviver, n = () => {
@@ -937,17 +782,17 @@ var N = class extends A {
937
782
  let r = e?.undefinedOmits;
938
783
  for (let e = 0; e < n.length; e++) {
939
784
  let [i, a] = n[e], o = t.call(n, i, a);
940
- o === h || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
785
+ o === x || r && o === void 0 ? n.splice(e--, 1) : n[e] = [i, o];
941
786
  }
942
787
  return n;
943
788
  };
944
- return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof U) ? (() => {
789
+ return e?.mapAs === "entries" ? n() : e?.mapAs === "object" || this.entries.every(([e]) => e instanceof G) ? (() => {
945
790
  let n = e ? {
946
791
  ...e,
947
792
  reviver: void 0
948
793
  } : void 0, r = {};
949
794
  for (let [e, t] of this.entries) {
950
- let i = e instanceof U ? e.value : e.toCDN(), a = t._toJS(n);
795
+ let i = e instanceof G ? e.value : e.toCDN(), a = t._toJS(n);
951
796
  i === "__proto__" ? Object.defineProperty(r, i, {
952
797
  value: a,
953
798
  writable: !0,
@@ -959,13 +804,13 @@ var N = class extends A {
959
804
  let i = /* @__PURE__ */ new Map();
960
805
  for (let e = 0; e < this.entries.length; e++) {
961
806
  let [t] = this.entries[e];
962
- i.set(t instanceof U ? t.value : t.toCDN(), e);
807
+ i.set(t instanceof G ? t.value : t.toCDN(), e);
963
808
  }
964
809
  for (let n = 0; n < this.entries.length; n++) {
965
- let [a, o] = this.entries[n], s = a instanceof U ? a.value : a.toCDN();
810
+ let [a, o] = this.entries[n], s = a instanceof G ? a.value : a.toCDN();
966
811
  if (i.get(s) !== n) continue;
967
812
  let c = o._toJS(e), l = t.call(r, s, c);
968
- l === h || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
813
+ l === x || e?.undefinedOmits && l === void 0 ? delete r[s] : s === "__proto__" ? Object.defineProperty(r, s, {
969
814
  value: l,
970
815
  writable: !0,
971
816
  enumerable: !0,
@@ -976,16 +821,17 @@ var N = class extends A {
976
821
  })() : n();
977
822
  }
978
823
  };
979
- function Be(e, t) {
980
- return e.length === 0 ? "" : " " + e.map((e) => b(e, t).trimEnd()).join(" ");
824
+ function Fe(e, t) {
825
+ return e.length === 0 ? "" : " " + e.map((e) => o(e, t).trimEnd()).join(" ");
981
826
  }
982
827
  //#endregion
983
828
  //#region src/ast/CborSimple.ts
984
- var B = class e extends A {
829
+ var R = class e extends O {
985
830
  value;
986
- constructor(e) {
831
+ ednSource;
832
+ constructor(e, t) {
987
833
  if (super(), !Number.isInteger(e) || e < 0 || e > 255) throw RangeError("CborSimple value must be an integer in 0–255");
988
- this.value = e;
834
+ this.value = e, this.ednSource = t?.ednSource;
989
835
  }
990
836
  static FALSE = new e(20);
991
837
  static TRUE = new e(21);
@@ -999,6 +845,7 @@ var B = class e extends A {
999
845
  e.writeByte(248), e.writeByte(this.value);
1000
846
  }
1001
847
  _toCDN(e, t) {
848
+ if (e?.preserveNumberFormat && this.ednSource !== void 0) return `simple(${this.ednSource})`;
1002
849
  switch (this.value) {
1003
850
  case 20: return "false";
1004
851
  case 21: return "true";
@@ -1013,10 +860,10 @@ var B = class e extends A {
1013
860
  case 21: return !0;
1014
861
  case 22: return null;
1015
862
  case 23: return;
1016
- default: return new g(this.value);
863
+ default: return new he(this.value);
1017
864
  }
1018
865
  }
1019
- }, Ve = class extends A {
866
+ }, z = class extends O {
1020
867
  items;
1021
868
  encodingWidth;
1022
869
  constructor(e, t) {
@@ -1026,38 +873,120 @@ var B = class e extends A {
1026
873
  return this.items.some((e) => e._containsCdnContainer);
1027
874
  }
1028
875
  _content(e) {
1029
- let t = new Ae();
876
+ let t = new Ce();
1030
877
  for (let n of this.items) n._encode(t, e);
1031
878
  return t.finish();
1032
879
  }
1033
880
  _encodeTo(e, t) {
1034
881
  let n = this._content(t);
1035
- O(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
882
+ E(e, 2, n.length, this.encodingWidth), e.writeBytes(n);
1036
883
  }
1037
884
  _toCDN(e, t) {
1038
- let n = w(e, this.encodingWidth, () => C(BigInt(this._content(e).length)));
1039
- if (this.items.length === 0) return `<<>>${n}`;
1040
- let r = _(e), { inlineSep: i, multilineSep: a, trailSep: o } = ae(e, r === null);
1041
- if (r === null) return `<<${this.items.map((n) => n._toCDN(e, t + 1)).join(i)}>>${n}`;
1042
- let s = v(r, t + 1), c = v(r, t), l = this.items.map((n) => `${s}${n._toCDN(e, t + 1)}`), u = l.length - 1;
1043
- return `<<\n${l.map((e, t) => t < u ? `${e}${a}` : `${e}${o}`).join("\n")}\n${c}>>${n}`;
1044
- }
1045
- _toHexDump(e, n) {
1046
- let r = this._content().length, i = [{
885
+ return s({
886
+ node: this,
887
+ options: e,
888
+ depth: t,
889
+ openChar: "<<",
890
+ closeChar: ">>",
891
+ count: this.items.length,
892
+ indefiniteLength: !1,
893
+ encodingWidth: this.encodingWidth,
894
+ eiPosition: "close",
895
+ canonicalCount: () => BigInt(this._content(e).length),
896
+ hasEntryComments: () => this.items.some(h),
897
+ renderEntry: (n) => this.items[n]._toCDN(e, t + 1),
898
+ entryLeadingNode: (e) => this.items[e],
899
+ entryTrailing: (e, t) => u(this.items[e], t)
900
+ });
901
+ }
902
+ _toHexDump(e, t) {
903
+ let n = this._content().length, r = [{
1047
904
  depth: e,
1048
- hex: t(Ne(2, BigInt(r), this.encodingWidth)),
1049
- comment: `Embedded CBOR sequence, ${r} byte${r === 1 ? "" : "s"}`
905
+ hex: i(Ee(2, BigInt(n), this.encodingWidth)),
906
+ comment: `Embedded CBOR sequence, ${n} byte${n === 1 ? "" : "s"}`
1050
907
  }];
1051
- for (let t of this.items) i.push(...t._toHexDump(e + 1, n));
1052
- return i;
908
+ for (let n of this.items) r.push(...n._toHexDump(e + 1, t));
909
+ return r;
1053
910
  }
1054
911
  _toJS(e) {
1055
912
  return this._content();
1056
913
  }
1057
914
  };
1058
915
  //#endregion
916
+ //#region src/utils/strip-comments.ts
917
+ function Ie(e) {
918
+ let t = "", n = 0;
919
+ for (; n < e.length;) {
920
+ let r = e[n];
921
+ if (r === " " || r === "\n" || r === "\r") {
922
+ n++;
923
+ continue;
924
+ }
925
+ if (r === "#") {
926
+ for (; n < e.length && e[n] !== "\n";) n++;
927
+ continue;
928
+ }
929
+ if (r === "/") {
930
+ let t = e[n + 1] ?? "";
931
+ if (t === "/") {
932
+ for (; n < e.length && e[n] !== "\n";) n++;
933
+ continue;
934
+ }
935
+ if (t === "*") {
936
+ for (n += 2; n < e.length && !(e[n] === "*" && (e[n + 1] ?? "") === "/");) n++;
937
+ if (n >= e.length) throw SyntaxError("unterminated block comment");
938
+ n += 2;
939
+ continue;
940
+ }
941
+ for (n++; n < e.length && e[n] !== "/";) n++;
942
+ if (n >= e.length) throw SyntaxError("unterminated block comment");
943
+ n++;
944
+ continue;
945
+ }
946
+ t += r, n++;
947
+ }
948
+ return t;
949
+ }
950
+ //#endregion
951
+ //#region src/extensions/b32.ts
952
+ var Le = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", Re = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
953
+ function ze(e) {
954
+ let t = e.length;
955
+ for (; t > 0 && e.charCodeAt(t - 1) === 61;) t--;
956
+ return e.slice(0, t);
957
+ }
958
+ function Be(e, t, n) {
959
+ let r = ze(e).toUpperCase(), i = r.length % 8;
960
+ if (i === 1 || i === 3 || i === 6) throw SyntaxError(`invalid base32 length: ${r.length} characters`);
961
+ let a = (/* @__PURE__ */ new Uint8Array(128)).fill(255);
962
+ for (let e = 0; e < t.length; e++) a[t.charCodeAt(e)] = e;
963
+ let o = new Uint8Array(Math.floor(r.length * 5 / 8)), s = 0, c = 0, l = 0;
964
+ for (let e of r) {
965
+ let t = e.charCodeAt(0), n = t < 128 ? a[t] : 255;
966
+ if (n === 255) throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);
967
+ s = s << 5 | n, c += 5, c >= 8 && (c -= 8, o[l++] = s >> c & 255);
968
+ }
969
+ if (c > 0 && s & (1 << c) - 1) {
970
+ let e = "non-zero trailing bits in base32 input";
971
+ if (n) n(e);
972
+ else throw SyntaxError(e);
973
+ }
974
+ return o;
975
+ }
976
+ var Ve = {
977
+ appStringPrefixes: ["b32"],
978
+ parseAppString(e, t, n) {
979
+ return new N(Be(Ie(t), Le, n), { ednEncoding: "base32" });
980
+ }
981
+ }, He = {
982
+ appStringPrefixes: ["h32"],
983
+ parseAppString(e, t, n) {
984
+ return new N(Be(Ie(t), Re, n), { ednEncoding: "base32hex" });
985
+ }
986
+ };
987
+ //#endregion
1059
988
  //#region src/utils/base64.ts
1060
- function He(e, t) {
989
+ function Ue(e, t) {
1061
990
  let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
1062
991
  if (/[^A-Za-z0-9+/\-_]/.test(r)) {
1063
992
  let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
@@ -1096,17 +1025,17 @@ function He(e, t) {
1096
1025
  }
1097
1026
  //#endregion
1098
1027
  //#region src/ast/CborUnresolvedAppExt.ts
1099
- var Ue = 999n, We = class extends P {
1028
+ var We = 999n, Ge = class extends M {
1100
1029
  constructor(e, t) {
1101
- let n = t.length === 1 && t[0] instanceof U ? t[0] : new R(t);
1102
- super(Ue, new R([new U(e), n]));
1030
+ let n = t.length === 1 && t[0] instanceof G ? t[0] : new I(t);
1031
+ super(We, new I([new G(e), n]));
1103
1032
  }
1104
1033
  _toCDN(e, t) {
1105
1034
  if (e?.appStrings === !1) return super._toCDN(e, t);
1106
1035
  let n = this.content, r = n.items[0].value, i = n.items[1];
1107
- return i instanceof U ? `${r}${ve(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
1036
+ return i instanceof G ? `${r}${c(i.value)}` : `${r}<<${i.items.map((n) => n._toCDN(e, t)).join(", ")}>>`;
1108
1037
  }
1109
- }, Ge = class extends A {
1038
+ }, B = class extends O {
1110
1039
  inner;
1111
1040
  ednSource;
1112
1041
  constructor(e, t) {
@@ -1120,26 +1049,135 @@ var Ue = 999n, We = class extends P {
1120
1049
  }
1121
1050
  _toCDN(e, t) {
1122
1051
  let n = e?.encodingIndicators ?? "auto";
1123
- return e?.appStrings !== !1 && n === "auto" && (_(e) !== null || !/[\r\n]/.test(this.ednSource)) ? this.ednSource : this.inner._toCDN(e, t);
1052
+ return e?.appStrings !== !1 && n === "auto" && (v(e) !== null || !/[\r\n]/.test(this.ednSource)) ? this.ednSource : this.inner._toCDN(e, t);
1124
1053
  }
1125
1054
  _toJS(e) {
1126
1055
  return this.inner._toJS(e);
1127
1056
  }
1128
- }, Ke = 888n, V = class extends P {
1129
- constructor(e) {
1130
- e === void 0 ? super(Ke, B.NULL) : super(Ke, new R(e));
1057
+ }, Ke = 888n;
1058
+ function qe(e, t, n, r) {
1059
+ return n ? [...(e.comments?.trailing ?? []).map((e) => o(e, r)), ...(t.comments?.leading ?? []).map((e) => o(e, r))] : [];
1060
+ }
1061
+ function Je(e, t, n, r) {
1062
+ return n === null || !t.some((e) => e.length > 0) ? e.join(" + ") : f(e, n, r, t);
1063
+ }
1064
+ function Ye(e, t, n, i) {
1065
+ if (e === void 0) return;
1066
+ let a = t?.preserveComments || i === void 0 ? e : r(e, i);
1067
+ return Ze(a, n) ? a : void 0;
1068
+ }
1069
+ function Xe(e, t) {
1070
+ return e !== void 0 && Ze(e, t);
1071
+ }
1072
+ function Ze(e, t) {
1073
+ return t !== null || !/[\r\n]/.test(e);
1074
+ }
1075
+ var V = class e extends M {
1076
+ realBoundary;
1077
+ fromByteLiteral;
1078
+ literalSource;
1079
+ constructor(e, t) {
1080
+ Array.isArray(e) ? (super(Ke, new I(e)), this.fromByteLiteral = !1, this.literalSource = void 0, this.realBoundary = t) : (super(Ke, R.NULL), this.fromByteLiteral = e ?? !1, this.literalSource = t, this.realBoundary = void 0);
1131
1081
  }
1132
1082
  _toCDN(e, t) {
1133
1083
  if (e?.appStrings === !1) return super._toCDN(e, t);
1134
- if (this.content instanceof B) return "...";
1135
- if (this.content instanceof R) {
1136
- let n = this.content.items.map((n) => n._toCDN(e, t));
1137
- return n.length === 0 ? "" : ee(n, _(e), t);
1084
+ if (this.content instanceof R) return "...";
1085
+ if (this.content instanceof I) {
1086
+ let n = !!e?.preserveConcatenation;
1087
+ if (n || e?.preserveByteString && !this._hasRealConcatenation()) {
1088
+ let n = this._renderPreservedBytesElision(e, t);
1089
+ if (n !== void 0) return n;
1090
+ }
1091
+ if (!n || this.realBoundary === void 0) {
1092
+ let e = this._compactHexElided();
1093
+ if (e !== void 0) return e;
1094
+ }
1095
+ let r = this.content.items, i = r.map((r) => n ? this._renderFragment(r, e, t) : r._toCDN(e, t)), a = !!e?.preserveComments, o = typeof e?.preserveComments == "string" ? e.preserveComments : void 0;
1096
+ return Je(i, r.slice(1).map((e, t) => qe(r[t], e, a, o)), v(e), t);
1138
1097
  }
1139
1098
  return super._toCDN(e, t);
1140
1099
  }
1141
- }, qe = 2n, Je = 3n, Ye = 18446744073709551615n, Xe = -18446744073709551616n;
1142
- function Ze(e) {
1100
+ _hasRealConcatenation() {
1101
+ return this.realBoundary?.some((e, t) => t > 0 && e) ? !0 : this.content.items.some((e) => e instanceof N && e.ednParts !== void 0 && e.ednParts.length > 1);
1102
+ }
1103
+ _renderFragment(e, t, n) {
1104
+ let r = v(t), i = !!t?.preserveComments, a = typeof t?.preserveComments == "string" ? t.preserveComments : void 0;
1105
+ if (e instanceof N && e.ednParts !== void 0 && e.ednParts.length > 1) {
1106
+ let o = t?.appStrings === !1 ? "hex" : t?.bstrEncoding ?? e.ednEncoding;
1107
+ return Je(e.ednParts.map((e) => {
1108
+ let n = t?.preserveByteString ? Ye(e.source, t, r, e.commentSyntax) : void 0;
1109
+ return n === void 0 ? oe(e.bytes, o, t?.sqstr) : n;
1110
+ }), i ? ne(e.comments?.dangling, e.ednParts, a) ?? [] : [], r, n);
1111
+ }
1112
+ if (e instanceof G && e.ednParts !== void 0 && e.ednParts.length > 1) {
1113
+ let o = t?.preserveRawString ? e.ednPartSources : void 0;
1114
+ return Je(e.ednParts.map((e, t) => {
1115
+ let n = o?.[t];
1116
+ return Xe(n, r) ? n : ee(e);
1117
+ }), i ? ne(e.comments?.dangling, e.ednPartSpans, a) ?? [] : [], r, n);
1118
+ }
1119
+ return e._toCDN(t, n);
1120
+ }
1121
+ _compactHexElided() {
1122
+ let t = this.content.items, n = "", r = !1;
1123
+ for (let i of t) if (i instanceof N) n += y(i.value), r = !0;
1124
+ else if (i instanceof e && i.content instanceof R) n += "...";
1125
+ else return;
1126
+ if (r) return `h'${n}'`;
1127
+ }
1128
+ _renderPreservedBytesElision(t, n) {
1129
+ if (this.realBoundary === void 0) return;
1130
+ let r = this.realBoundary, i = this.content.items, a = [], o = [], s = [], c = (e) => {
1131
+ s.length > 0 && (a.push(s), o.push(e ?? []), s = []);
1132
+ }, l = !!t?.preserveComments, u = typeof t?.preserveComments == "string" ? t.preserveComments : void 0;
1133
+ for (let t = 0; t < i.length; t++) {
1134
+ let n = i[t];
1135
+ if (t > 0 && r[t] && c(qe(i[t - 1], n, l, u)), n instanceof e && n.content instanceof R) s.push({
1136
+ ellipsis: !0,
1137
+ fromByteLiteral: n.fromByteLiteral,
1138
+ literalSource: n.literalSource
1139
+ });
1140
+ else if (n instanceof N) if (n.ednParts !== void 0 && n.ednParts.length > 1) {
1141
+ let [e, ...t] = n.ednParts;
1142
+ s.push({
1143
+ bytes: e.bytes,
1144
+ source: e.source,
1145
+ commentSyntax: e.commentSyntax
1146
+ });
1147
+ let r = l ? ne(n.comments?.dangling, n.ednParts, u) : void 0;
1148
+ t.forEach((e, t) => {
1149
+ c(r?.[t]), s.push({
1150
+ bytes: e.bytes,
1151
+ source: e.source,
1152
+ commentSyntax: e.commentSyntax
1153
+ });
1154
+ });
1155
+ } else s.push({
1156
+ bytes: n.value,
1157
+ source: n.ednSource,
1158
+ commentSyntax: n.ednCommentSyntax
1159
+ });
1160
+ else return;
1161
+ }
1162
+ if (s.length > 0 && a.push(s), a.length === 0) return;
1163
+ let d = t?.appStrings === !1 ? "hex" : t?.bstrEncoding ?? "hex", f = v(t);
1164
+ return Je(a.map((e) => {
1165
+ if (t?.preserveByteString) for (let n of e) {
1166
+ if (!("ellipsis" in n)) continue;
1167
+ let e = Ye(n.literalSource, t, f, "full");
1168
+ if (e !== void 0) return e;
1169
+ }
1170
+ let n = e.filter((e) => !("ellipsis" in e));
1171
+ if (n.length === 0) return e.some((e) => "ellipsis" in e && e.fromByteLiteral) ? "h'...'" : "...";
1172
+ if (e.length === 1) {
1173
+ let e = n[0], r = t?.preserveByteString ? Ye(e.source, t, f, e.commentSyntax) : void 0;
1174
+ return r === void 0 ? oe(e.bytes, d, t?.sqstr) : r;
1175
+ }
1176
+ return `h'${e.map((e) => "ellipsis" in e ? "..." : y(e.bytes)).join("")}'`;
1177
+ }), o, f, n);
1178
+ }
1179
+ }, Qe = 2n, $e = 3n, et = 18446744073709551615n, tt = -18446744073709551616n;
1180
+ function nt(e) {
1143
1181
  if (e < 0n) throw RangeError("bigintToBytes requires a non-negative value");
1144
1182
  if (e === 0n) return /* @__PURE__ */ new Uint8Array();
1145
1183
  let t = e.toString(16);
@@ -1148,16 +1186,16 @@ function Ze(e) {
1148
1186
  for (let e = 0; e < n.length; e++) n[e] = parseInt(t.slice(e * 2, e * 2 + 2), 16);
1149
1187
  return n;
1150
1188
  }
1151
- function Qe(e) {
1189
+ function rt(e) {
1152
1190
  let t = 0n;
1153
1191
  for (let n of e) t = t << 8n | BigInt(n);
1154
1192
  return t;
1155
1193
  }
1156
- var $e = class extends P {
1194
+ var it = class extends M {
1157
1195
  bigValue;
1158
1196
  constructor(e) {
1159
- if (e <= Ye) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
1160
- super(qe, new F(Ze(e))), this.bigValue = e;
1197
+ if (e <= et) throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);
1198
+ super(Qe, new N(nt(e))), this.bigValue = e;
1161
1199
  }
1162
1200
  _toCDN(e, t) {
1163
1201
  return this.bigValue.toString();
@@ -1165,11 +1203,11 @@ var $e = class extends P {
1165
1203
  _toJS(e) {
1166
1204
  return this.bigValue;
1167
1205
  }
1168
- }, et = class extends P {
1206
+ }, at = class extends M {
1169
1207
  bigValue;
1170
1208
  constructor(e) {
1171
- if (e >= Xe) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
1172
- super(Je, new F(Ze(-1n - e))), this.bigValue = e;
1209
+ if (e >= tt) throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);
1210
+ super($e, new N(nt(-1n - e))), this.bigValue = e;
1173
1211
  }
1174
1212
  _toCDN(e, t) {
1175
1213
  return this.bigValue.toString();
@@ -1177,25 +1215,59 @@ var $e = class extends P {
1177
1215
  _toJS(e) {
1178
1216
  return this.bigValue;
1179
1217
  }
1180
- }, tt = new TextEncoder(), nt = new TextDecoder("utf-8", { fatal: !0 }), rt = new TextDecoder("utf-8", { fatal: !1 });
1181
- function it(e, t) {
1182
- let n = new a(e, {
1218
+ }, ot = new TextEncoder(), st = new TextDecoder("utf-8", { fatal: !0 }), ct = new TextDecoder("utf-8", { fatal: !1 });
1219
+ function lt(e, t) {
1220
+ let n = new re(e, {
1183
1221
  offset: t?.offset,
1184
1222
  skipRS: t?._skipRS
1185
- }), r = new ht(n, t ?? {}).parse();
1186
- return t?.preserveComments && ct(r, n.comments, e), r;
1223
+ }), r = new Dt(n, t ?? {}).parse();
1224
+ return (t?.preserveComments || t?.preserveAll) && (bt(r, n.comments, e), U(r)), r;
1187
1225
  }
1188
- function at(e) {
1226
+ function ut(e) {
1189
1227
  let t = e, n;
1190
1228
  return /[_][0-7i]$/.test(e) && (n = e[e.length - 1], t = e.slice(0, -2)), {
1191
1229
  numStr: t,
1192
1230
  rawSuffix: n
1193
1231
  };
1194
1232
  }
1195
- function ot(e) {
1233
+ function dt(e) {
1196
1234
  return e.startsWith("-") ? -BigInt(e.slice(1)) : BigInt(e);
1197
1235
  }
1198
- function st(e, t) {
1236
+ function H(e) {
1237
+ if (e !== void 0) return pt([e.appSeqSourceFeatures, ft(e)]);
1238
+ }
1239
+ function ft(e) {
1240
+ if (e instanceof N) return {
1241
+ byteString: !0,
1242
+ concatenation: e.ednParts !== void 0 && e.ednParts.length > 1
1243
+ };
1244
+ if (e instanceof G) {
1245
+ let t = e.ednParts !== void 0, n = e.ednPartSources?.filter((e) => e !== void 0).length ?? 0, r = t ? e.ednParts.reduce((t, n, r) => {
1246
+ let i = e.ednPartSources?.[r] !== void 0, a = e.ednPartIsByteString?.[r] ?? !1;
1247
+ return i || !a ? t : t + 1;
1248
+ }, 0) : 0, i = (t ? e.ednParts.length : 0) - n - r;
1249
+ return {
1250
+ byteString: r > 0,
1251
+ textString: e.quotedEdnSource !== void 0 || i > 0,
1252
+ rawString: e.ednSource !== void 0 || n > 0,
1253
+ concatenation: t && e.ednParts.length > 1
1254
+ };
1255
+ }
1256
+ if (e instanceof I) return pt(e.items.map(H));
1257
+ if (e instanceof L) return pt(e.entries.flatMap(([e, t]) => [H(e), H(t)]));
1258
+ if (e instanceof M) return H(e.content);
1259
+ if (e instanceof P || e instanceof F || e instanceof z) return pt((e instanceof z ? e.items : e.chunks).map(H));
1260
+ }
1261
+ function pt(e) {
1262
+ let t = e.filter((e) => e !== void 0);
1263
+ if (t.length !== 0) return {
1264
+ byteString: t.some((e) => e.byteString),
1265
+ textString: t.some((e) => e.textString),
1266
+ rawString: t.some((e) => e.rawString),
1267
+ concatenation: t.some((e) => e.concatenation)
1268
+ };
1269
+ }
1270
+ function mt(e, t) {
1199
1271
  if (e.endsWith("_i") || e.endsWith("_0")) {
1200
1272
  let n = "_0 and _i encoding indicators are not valid for floating-point values";
1201
1273
  if (t) t(n), e = e.slice(0, -2);
@@ -1219,72 +1291,162 @@ function st(e, t) {
1219
1291
  };
1220
1292
  let n = e, r;
1221
1293
  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) ? {
1222
- value: Re(n),
1294
+ value: Me(n),
1223
1295
  precision: r
1224
1296
  } : {
1225
1297
  value: parseFloat(n),
1226
1298
  precision: r
1227
1299
  };
1228
1300
  }
1229
- function ct(e, t, n) {
1301
+ var ht = /\r?\n[ \t]*\r?\n/;
1302
+ function gt(e, t, n) {
1303
+ return ht.test(e.slice(t, n));
1304
+ }
1305
+ function _t(e, t, n, r) {
1306
+ let i = [];
1307
+ for (let a = t; a < e.length; a++) {
1308
+ let t = e[a];
1309
+ if (t.start >= r) break;
1310
+ t.start >= n && t.end <= r && i.push({
1311
+ ...t,
1312
+ start: t.start - n,
1313
+ end: t.end - n
1314
+ });
1315
+ }
1316
+ return i;
1317
+ }
1318
+ function vt(e, t, n, r) {
1319
+ if (n.end !== void 0) return {
1320
+ start: (/_[0-7i]$/.test(e.slice(Math.max(0, n.end - 2), n.end)) ? n.end - 2 : n.end) - t,
1321
+ end: n.end - t,
1322
+ always: r,
1323
+ never: ""
1324
+ };
1325
+ }
1326
+ function yt(e, t, n) {
1327
+ if (n instanceof k) {
1328
+ let r = vt(e, t, n, `_${n.encodingWidth ?? p(n.value)}`);
1329
+ return r ? [r] : [];
1330
+ }
1331
+ if (n instanceof A) {
1332
+ let r = vt(e, t, n, `_${n.encodingWidth ?? p(n.argument)}`);
1333
+ return r ? [r] : [];
1334
+ }
1335
+ if (n instanceof j) {
1336
+ let r = n.precision ?? D(n.value), i = vt(e, t, n, r === "half" ? "_1" : r === "single" ? "_2" : "_3");
1337
+ return i ? [i] : [];
1338
+ }
1339
+ if (n instanceof N) {
1340
+ let r = vt(e, t, n, `_${n.encodingWidth ?? p(BigInt(n.value.length))}`);
1341
+ return r ? [r] : [];
1342
+ }
1343
+ if (n instanceof G) {
1344
+ let r = vt(e, t, n, `_${n.encodingWidth ?? p(BigInt(ot.encode(n.value).length))}`);
1345
+ return r ? [r] : [];
1346
+ }
1347
+ if (n instanceof I) {
1348
+ let r = [];
1349
+ if (n.indefiniteLength) return;
1350
+ if (n.start !== void 0) {
1351
+ let i = new re(e, { offset: n.start }), a = i.consume(), o = i.peek(), s = o.type === "ENCODING_INDICATOR", c = `_${n.encodingWidth ?? p(BigInt(n.items.length))}`, l = e[a.endOffset] ?? "", u = !s && /[+\-.0-9A-Z_a-z]/.test(l) ? " " : "";
1352
+ r.push({
1353
+ start: (s ? o.offset : a.endOffset) - t,
1354
+ end: (s ? o.endOffset : a.endOffset) - t,
1355
+ always: c + u,
1356
+ never: ""
1357
+ });
1358
+ }
1359
+ for (let i of n.items) {
1360
+ let n = yt(e, t, i);
1361
+ if (n === void 0) return;
1362
+ r.push(...n);
1363
+ }
1364
+ return r;
1365
+ }
1366
+ }
1367
+ function bt(e, t, n) {
1230
1368
  if (t.length === 0) return;
1231
- let r = lt(e), i = dt(n), a = [...r].sort((e, t) => e.start - t.start || t.end - e.end), o = [...r].sort((e, t) => e.end - t.end || e.start - t.start), s = [...t].sort((e, t) => e.start - t.start), c = [], l = 0;
1232
- for (let t of s) {
1233
- let r = { ...t }, s = 0, u = o.length;
1234
- for (; s < u;) {
1235
- let e = s + u >> 1;
1236
- o[e].end <= t.start ? s = e + 1 : u = e;
1237
- }
1238
- let d = s > 0 ? o[s - 1] : void 0, f = d ? n.slice(d.end, t.start) : "";
1239
- if (d && i(d.end) === t.line && !f.includes(":")) {
1240
- ut(d.node, "trailing", r);
1369
+ let r = xt(e), i = Ct(n), a = [...r].sort((e, t) => e.start - t.start || t.end - e.end), o = [...r].sort((e, t) => e.end - t.end || e.start - t.start), s = [...t].sort((e, t) => e.start - t.start), c = [], l = 0;
1370
+ for (let e of s) {
1371
+ let t = { ...e }, r = 0, s = o.length;
1372
+ for (; r < s;) {
1373
+ let t = r + s >> 1;
1374
+ o[t].end <= e.start ? r = t + 1 : s = t;
1375
+ }
1376
+ let u = r > 0 ? o[r - 1] : void 0, d = u ? n.slice(u.end, e.start) : "";
1377
+ if (u && i(u.end) === e.line && !d.includes(":")) {
1378
+ St(u.node, "trailing", t);
1241
1379
  continue;
1242
1380
  }
1243
- for (; l < a.length && a[l].start < t.start;) {
1381
+ for (; l < a.length && a[l].start < e.start;) {
1244
1382
  let e = a[l++];
1245
1383
  for (; c.length > 0 && c[c.length - 1].end <= e.start;) c.pop();
1246
1384
  c.push(e);
1247
1385
  }
1248
- for (; c.length > 0 && c[c.length - 1].end <= t.start;) c.pop();
1249
- let p = c.length > 0 ? c[c.length - 1] : void 0;
1250
- for (s = 0, u = a.length; s < u;) {
1251
- let e = s + u >> 1;
1252
- a[e].start < t.end ? s = e + 1 : u = e;
1386
+ for (; c.length > 0 && c[c.length - 1].end <= e.start;) c.pop();
1387
+ let f = c.length > 0 ? c[c.length - 1] : void 0;
1388
+ for (r = 0, s = a.length; r < s;) {
1389
+ let t = r + s >> 1;
1390
+ a[t].start < e.end ? r = t + 1 : s = t;
1253
1391
  }
1254
- let m = s < a.length ? a[s] : void 0;
1255
- if ((!p || m && m.end <= p.end) && m) {
1256
- ut(m.node, "leading", r);
1392
+ let p = r < a.length ? a[r] : void 0;
1393
+ if ((!f || p && p.end <= f.end) && p) {
1394
+ t.sameLine = i(e.end) === i(p.start), St(p.node, "leading", t);
1257
1395
  continue;
1258
1396
  }
1259
- ut(p?.node ?? e, "dangling", r);
1397
+ f && St(f.node, "dangling", t);
1260
1398
  }
1261
1399
  }
1262
- function lt(e) {
1400
+ function xt(e) {
1263
1401
  let t = [], n = (e) => {
1264
1402
  if (e.start !== void 0 && e.end !== void 0 && t.push({
1265
1403
  node: e,
1266
1404
  start: e.start,
1267
1405
  end: e.end
1268
- }), e instanceof R || e instanceof Ve) {
1406
+ }), e instanceof I || e instanceof z) {
1269
1407
  for (let t of e.items) n(t);
1270
1408
  return;
1271
1409
  }
1272
- if (e instanceof z) {
1410
+ if (e instanceof L) {
1273
1411
  for (let [t, r] of e.entries) n(t), n(r);
1274
1412
  return;
1275
1413
  }
1276
- if (e instanceof I || e instanceof L) {
1414
+ if (e instanceof P || e instanceof F) {
1277
1415
  for (let t of e.chunks) n(t);
1278
1416
  return;
1279
1417
  }
1280
- e instanceof P && n(e.content);
1418
+ e instanceof M && n(e.content);
1281
1419
  };
1282
1420
  return n(e), t;
1283
1421
  }
1284
- function ut(e, t, n) {
1422
+ function St(e, t, n) {
1285
1423
  e.comments ??= {}, e.comments[t] ??= [], e.comments[t].push(n);
1286
1424
  }
1287
- function dt(e) {
1425
+ function U(e) {
1426
+ if (e instanceof V) {
1427
+ if (e.content instanceof I) {
1428
+ let t = e.content.items;
1429
+ for (let e of t) U(e);
1430
+ let n = t[t.length - 1], r = n?.comments?.trailing;
1431
+ r !== void 0 && r.length > 0 && !e.comments?.trailing?.length && (e.comments ??= {}, e.comments.trailing = r, n.comments.trailing = void 0);
1432
+ }
1433
+ return;
1434
+ }
1435
+ if (e instanceof I || e instanceof z) {
1436
+ for (let t of e.items) U(t);
1437
+ return;
1438
+ }
1439
+ if (e instanceof L) {
1440
+ for (let [t, n] of e.entries) U(t), U(n);
1441
+ return;
1442
+ }
1443
+ if (e instanceof P || e instanceof F) {
1444
+ for (let t of e.chunks) U(t);
1445
+ return;
1446
+ }
1447
+ e instanceof M && U(e.content);
1448
+ }
1449
+ function Ct(e) {
1288
1450
  let t = [0];
1289
1451
  for (let n = 0; n < e.length; n++) e[n] === "\n" && t.push(n + 1);
1290
1452
  return (n) => {
@@ -1298,25 +1460,25 @@ function dt(e) {
1298
1460
  return a + 1;
1299
1461
  };
1300
1462
  }
1301
- var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, pt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, H = (e) => `'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`, mt = /* @__PURE__ */ new Map([
1302
- ["b32", ft("b32")],
1303
- ["h32", ft("h32")],
1304
- ["same", ft("same")],
1305
- ["hash", pt("hash", "@cbortech/hash-extension")],
1306
- ["uuid", pt("uuid", "@cbortech/uuid-extension")],
1307
- ["UUID", pt("uuid", "@cbortech/uuid-extension")],
1308
- ["dt", H("dt")],
1309
- ["DT", H("dt")],
1310
- ["ip", H("ip")],
1311
- ["IP", H("ip")],
1312
- ["cri", H("cri")],
1313
- ["CRI", H("cri")],
1314
- ["t1", H("t1")],
1315
- ["b1", H("b1")],
1316
- ["ilbs", H("ilbs")],
1317
- ["ilts", H("ilts")],
1318
- ["float", H("float")]
1319
- ]), ht = class {
1463
+ var wt = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`, Tt = (e, t) => `install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`, W = (e) => `'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`, Et = /* @__PURE__ */ new Map([
1464
+ ["b32", wt("b32")],
1465
+ ["h32", wt("h32")],
1466
+ ["same", wt("same")],
1467
+ ["hash", Tt("hash", "@cbortech/hash-extension")],
1468
+ ["uuid", Tt("uuid", "@cbortech/uuid-extension")],
1469
+ ["UUID", Tt("uuid", "@cbortech/uuid-extension")],
1470
+ ["dt", W("dt")],
1471
+ ["DT", W("dt")],
1472
+ ["ip", W("ip")],
1473
+ ["IP", W("ip")],
1474
+ ["cri", W("cri")],
1475
+ ["CRI", W("cri")],
1476
+ ["t1", W("t1")],
1477
+ ["b1", W("b1")],
1478
+ ["ilbs", W("ilbs")],
1479
+ ["ilts", W("ilts")],
1480
+ ["float", W("float")]
1481
+ ]), Dt = class {
1320
1482
  t;
1321
1483
  _options;
1322
1484
  extByPrefix;
@@ -1324,24 +1486,24 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1324
1486
  unresolvedExtension;
1325
1487
  _pendingWarnings = [];
1326
1488
  _hintedPrefixes = /* @__PURE__ */ new Set();
1327
- constructor(e, t) {
1328
- this.t = e, this._options = t, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = t.unresolvedExtension ?? "cpa999";
1329
- let n = Z(t.builtinExtensions);
1330
- for (let e of [...n, ...t.extensions ?? []]) {
1489
+ constructor(e, n) {
1490
+ this.t = e, this._options = n, this.extByPrefix = /* @__PURE__ */ new Map(), this.extByTag = /* @__PURE__ */ new Map(), this.unresolvedExtension = n.unresolvedExtension ?? "cpa999";
1491
+ let r = Z(n.builtinExtensions);
1492
+ for (let e of [...r, ...n.extensions ?? []]) {
1331
1493
  for (let t of e.appStringPrefixes ?? []) this.extByPrefix.set(t, e);
1332
1494
  for (let t of e.tagNumbers ?? []) this.extByTag.set(t, e);
1333
1495
  }
1334
- this.t.onEscapeWarning = (e, t, n, i, a) => {
1496
+ this.t.onEscapeWarning = (e, n, r, i, a) => {
1335
1497
  let o = {
1336
1498
  message: e,
1337
- offset: t,
1338
- line: n,
1499
+ offset: n,
1500
+ line: r,
1339
1501
  column: i,
1340
1502
  endOffset: a
1341
1503
  };
1342
- if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${n}, column ${i}: ${e}`), this._options.strict !== !1) throw new r(e, {
1343
- offset: t,
1344
- line: n,
1504
+ if (this._pendingWarnings.push(o), this._options.onWarning ? this._options.onWarning(o) : this._options.silent || console.warn(`CDN strict violation at line ${r}, column ${i}: ${e}`), this._options.strict !== !1) throw new t(e, {
1505
+ offset: n,
1506
+ line: r,
1345
1507
  column: i,
1346
1508
  endOffset: a
1347
1509
  });
@@ -1376,13 +1538,13 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1376
1538
  case "RAWSTRING": return this.parseString();
1377
1539
  case "BYTES_HEX":
1378
1540
  case "SQSTR":
1379
- case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw);
1380
- case "EMPTY_INDEF_BYTES": return this.t.consume(), new I([]);
1381
- case "EMPTY_INDEF_TEXT": return this.t.consume(), new L([]);
1382
- case "TRUE": return this.t.consume(), new B(21);
1383
- case "FALSE": return this.t.consume(), new B(20);
1384
- case "NULL": return this.t.consume(), new B(22);
1385
- case "UNDEFINED": return this.t.consume(), new B(23);
1541
+ case "BYTES_B64": return this.t.consume(), this._parseBytesConcat(this._decodeBytesToken(e), e.type, e.raw, e.offset, e.endOffset);
1542
+ case "EMPTY_INDEF_BYTES": return this.t.consume(), new P([]);
1543
+ case "EMPTY_INDEF_TEXT": return this.t.consume(), new F([]);
1544
+ case "TRUE": return this.t.consume(), new R(21);
1545
+ case "FALSE": return this.t.consume(), new R(20);
1546
+ case "NULL": return this.t.consume(), new R(22);
1547
+ case "UNDEFINED": return this.t.consume(), new R(23);
1386
1548
  case "SIMPLE": return this.parseSimple();
1387
1549
  case "LBRACKET": return this.parseArray();
1388
1550
  case "LBRACE": return this.parseMap();
@@ -1397,54 +1559,57 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1397
1559
  }
1398
1560
  let r = this.extByPrefix.get(e.appPrefix);
1399
1561
  if (!r?.parseAppString) {
1400
- if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new We(e.appPrefix, [new U(e.value)]);
1562
+ if (r || this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, [new G(e.value)]);
1401
1563
  this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
1402
1564
  }
1403
1565
  {
1404
1566
  let i = this._pendingWarnings.length;
1405
1567
  try {
1406
1568
  let i = r.parseAppString(e.appPrefix, e.value, this._extOnError(e), t === void 0 ? void 0 : { encodingWidth: t });
1407
- return t !== void 0 && this._applyEiToResult(i, t, e), i instanceof F && Object.getPrototypeOf(i) === F.prototype && i.ednSource === void 0 ? new F(i.value, {
1569
+ return t !== void 0 && this._applyEiToResult(i, t, e), r.preserveAppSeqSource === "optional" ? (i.appSeqSource = e.raw + n, i) : i instanceof N && Object.getPrototypeOf(i) === N.prototype && i.ednSource === void 0 ? new N(i.value, {
1408
1570
  ednEncoding: i.ednEncoding,
1409
1571
  encodingWidth: i.encodingWidth,
1410
- ednSource: e.raw + n
1411
- }) : (i instanceof N && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
1572
+ ednSource: e.raw + n,
1573
+ ednCommentSyntax: r === Ve || r === He ? "full" : void 0
1574
+ }) : (i instanceof j && i.ednSource === void 0 && (i.ednSource = e.raw + n), i);
1412
1575
  } catch (t) {
1413
1576
  if (this._options.strict !== !1) throw t;
1414
- return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new We(e.appPrefix, [new U(e.value)]);
1577
+ return this._pendingWarnings.length === i && this._warn(t instanceof Error ? t.message : String(t), e), new Ge(e.appPrefix, [new G(e.value)]);
1415
1578
  }
1416
1579
  }
1417
1580
  }
1418
1581
  case "APP_SEQUENCE": {
1582
+ let t = this.t.comments.length;
1419
1583
  this.t.consume();
1420
- let t = [];
1584
+ let n = [];
1421
1585
  for (; this.t.peek().type !== "GT_GT";) {
1422
- if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), t.length > 0) if (this.t.peek().type === "COMMA") {
1586
+ if (this.t.peek().type === "EOF" && this._fail(`unterminated ${e.appPrefix}<<...>>`, e), n.length > 0) if (this.t.peek().type === "COMMA") {
1423
1587
  if (this.t.consume(), this.t.peek().type === "GT_GT") break;
1424
1588
  } else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("<<...>> items must be separated by \",\" or whitespace", this.t.peek());
1425
- t.push(this.parseValue());
1589
+ n.push(this.parseValue());
1426
1590
  }
1427
1591
  this.expect("GT_GT");
1428
- let n, r;
1429
- this.t.peek().type === "ENCODING_INDICATOR" && (r = this.t.consume(), n = this._resolveEncodingWidth(r.value, r));
1430
- let i = this.extByPrefix.get(e.appPrefix);
1431
- if (!i) {
1432
- if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new We(e.appPrefix, t);
1592
+ let r, i;
1593
+ this.t.peek().type === "ENCODING_INDICATOR" && (i = this.t.consume(), r = this._resolveEncodingWidth(i.value, i));
1594
+ let a = this.extByPrefix.get(e.appPrefix);
1595
+ if (!a) {
1596
+ if (this._hintMissingExtension(e.appPrefix, e), this.unresolvedExtension === "cpa999") return new Ge(e.appPrefix, n);
1433
1597
  this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`, e);
1434
1598
  }
1435
- i.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
1599
+ a.parseAppSequence || this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`, e);
1436
1600
  {
1437
- let a = this._pendingWarnings.length;
1601
+ let o = this._pendingWarnings.length;
1438
1602
  try {
1439
- let a = i.parseAppSequence(e.appPrefix, t, this._extOnError(e));
1440
- n !== void 0 && this._applyEiToResult(a, n, r ?? e);
1441
- let o = this.t.source.slice(e.offset, this.t.lastEndOffset);
1442
- if (a instanceof N) a.ednSource === void 0 && (a.ednSource = o);
1443
- else if (i.preserveAppSeqSource) return new Ge(a, o);
1444
- return a;
1445
- } catch (n) {
1446
- if (this._options.strict !== !1) throw n;
1447
- return this._pendingWarnings.length === a && this._warn(n instanceof Error ? n.message : String(n), e), new We(e.appPrefix, t);
1603
+ let o = a.parseAppSequence(e.appPrefix, n, this._extOnError(e));
1604
+ r !== void 0 && this._applyEiToResult(o, r, i ?? e);
1605
+ let s = this.t.source.slice(e.offset, this.t.lastEndOffset);
1606
+ if (a.preserveAppSeqSource === "optional") o.appSeqSource = s, o.appSeqComments = _t(this.t.comments, t, e.offset, this.t.lastEndOffset), n.length === 1 && (n[0].end !== void 0 && (o.appSeqInnerEnd = n[0].end - e.offset), o.appSeqSourceFeatures = H(n[0]));
1607
+ else if (o instanceof j) o.ednSource === void 0 && (o.ednSource = s);
1608
+ else if (a.preserveAppSeqSource) return new B(o, s);
1609
+ return o;
1610
+ } catch (t) {
1611
+ if (this._options.strict !== !1) throw t;
1612
+ return this._pendingWarnings.length === o && this._warn(t instanceof Error ? t.message : String(t), e), new Ge(e.appPrefix, n);
1448
1613
  }
1449
1614
  }
1450
1615
  }
@@ -1452,99 +1617,163 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1452
1617
  if (this.t.consume(), this.t.peek().type !== "PLUS") return new V();
1453
1618
  let e = [new V()];
1454
1619
  for (; this.t.peek().type === "PLUS";) this.t.consume(), e.push(this.parseValue());
1455
- return new V(e);
1620
+ return new V(e, e.map(() => !0));
1456
1621
  }
1457
1622
  case "BYTES_HEX_ELIDED": return this.t.consume(), this._parseHexElidedConcat(e);
1458
1623
  default: this._fail(`unexpected token: ${JSON.stringify(e.value)}`, e);
1459
1624
  }
1460
1625
  }
1461
1626
  parseIntegerOrTag() {
1462
- let e = this.t.consume(), { numStr: t, rawSuffix: n } = at(e.value), r = n === void 0 ? this.consumeEncodingIndicator() : this._resolveEncodingWidth(n, e), i = ot(t);
1463
- if (i > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", e), new $e(i);
1464
- if (i < -18446744073709551616n) return new et(i);
1465
- if (r !== void 0) {
1466
- let t = i >= 0n ? i : -(i + 1n);
1467
- r = this._validateEncodingFit(t, r, e);
1468
- }
1469
- let a = i >= 0n ? new j(i, r === void 0 ? void 0 : { encodingWidth: r }) : new M(i, r === void 0 ? void 0 : { encodingWidth: r });
1627
+ let e = this.t.comments.length, t = this.t.consume(), { numStr: n, rawSuffix: r } = ut(t.value), i = r === void 0 ? t.endOffset : t.endOffset - 2, a = t.endOffset, o = r === void 0 ? this.consumeEncodingIndicator(void 0, (e) => {
1628
+ i = e.offset, a = e.endOffset;
1629
+ }) : this._resolveEncodingWidth(r, t), s = dt(n), c = r === void 0 ? t.raw : t.raw.slice(0, -2);
1630
+ if (s > 18446744073709551615n) return this.t.peek().type === "LPAREN" && this._fail("tag number exceeds maximum uint64", t), new it(s);
1631
+ if (s < -18446744073709551616n) return new at(s);
1632
+ if (o !== void 0) {
1633
+ let e = s >= 0n ? s : -(s + 1n);
1634
+ o = this._validateEncodingFit(e, o, t);
1635
+ }
1636
+ let l = s >= 0n ? new k(s, {
1637
+ encodingWidth: o,
1638
+ ednSource: c
1639
+ }) : new A(s, {
1640
+ encodingWidth: o,
1641
+ ednSource: c
1642
+ });
1470
1643
  if (this.t.peek().type === "LPAREN") {
1471
- a instanceof j || this._fail("tag number must be non-negative", e), this.t.consume();
1472
- let t = this._pendingWarnings.splice(0), n = this.parseValue();
1644
+ l instanceof k || this._fail("tag number must be non-negative", t), this.t.consume();
1645
+ let n = this._pendingWarnings.splice(0), r = this.parseValue();
1473
1646
  this.expect("RPAREN");
1474
- let i = a.value, o = this.extByTag.get(i);
1475
- if (o?.parseTag) {
1476
- let e = o.parseTag(i, n);
1477
- if (e !== void 0) return e instanceof P && r !== void 0 && e.encodingWidth === void 0 && (e.encodingWidth = r), t.length > 0 && (e.warnings ??= [], e.warnings.push(...t)), e;
1647
+ let s = l.value, u = this.extByTag.get(s);
1648
+ if (u?.parseTag) {
1649
+ let l = u.parseTag(s, r);
1650
+ if (l !== void 0) {
1651
+ if (l instanceof M && (o !== void 0 && l.encodingWidth === void 0 && (l.encodingWidth = o), l.ednSource === void 0 && (l.ednSource = c), u.preserveAppSeqSource === "optional" && l.appSeqSource === void 0)) {
1652
+ l.appSeqSource = this.t.source.slice(t.offset, this.t.lastEndOffset), l.appSeqComments = _t(this.t.comments, e, t.offset, this.t.lastEndOffset);
1653
+ let n = l.encodingWidth ?? p(l.tag), o = yt(this.t.source, t.offset, l.content);
1654
+ l.appSeqEncodingEdits = [{
1655
+ start: i - t.offset,
1656
+ end: a - t.offset,
1657
+ always: `_${n}`,
1658
+ never: ""
1659
+ }, ...o ?? []], o === void 0 && (l.appSeqEncodingEditsComplete = !1), l.appSeqSourceFeatures = H(r);
1660
+ }
1661
+ return n.length > 0 && (l.warnings ??= [], l.warnings.push(...n)), l;
1662
+ }
1478
1663
  }
1479
- let s = new P(i, n, r === void 0 ? void 0 : { encodingWidth: r });
1480
- return t.length > 0 && (s.warnings ??= [], s.warnings.push(...t)), s;
1664
+ let d = new M(s, r, {
1665
+ encodingWidth: o,
1666
+ ednSource: c
1667
+ });
1668
+ return n.length > 0 && (d.warnings ??= [], d.warnings.push(...n)), d;
1481
1669
  }
1482
- return a;
1670
+ return l;
1483
1671
  }
1484
1672
  parseFloat() {
1485
- let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = st(e.value, t);
1673
+ let e = this.t.consume(), t = (t) => this._warnOrFail(t, e), { value: n, precision: r } = mt(e.value, t);
1486
1674
  if (r === "half" || r === "single") {
1487
- let e = r === "half" ? E(T(n)) : Math.fround(n);
1675
+ let e = r === "half" ? C(S(n)) : Math.fround(n);
1488
1676
  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`);
1489
1677
  }
1490
- return new N(n, r === void 0 ? void 0 : { precision: r });
1678
+ return new j(n, {
1679
+ precision: r,
1680
+ literalSource: e.raw
1681
+ });
1491
1682
  }
1492
1683
  parseString() {
1493
1684
  let e = this.t.consume();
1494
1685
  if (this.t.peek().type !== "PLUS") {
1495
- let t = this.consumeEncodingIndicator(() => BigInt(tt.encode(e.value).length));
1496
- return e.type === "RAWSTRING" ? new U(e.value, {
1686
+ let t = this.consumeEncodingIndicator(() => BigInt(ot.encode(e.value).length));
1687
+ return e.type === "RAWSTRING" ? new G(e.value, {
1497
1688
  ednSource: e.raw,
1498
1689
  ...t === void 0 ? {} : { encodingWidth: t }
1499
- }) : new U(e.value, t === void 0 ? void 0 : { encodingWidth: t });
1690
+ }) : new G(e.value, {
1691
+ quotedEdnSource: e.raw,
1692
+ ...t === void 0 ? {} : { encodingWidth: t }
1693
+ });
1500
1694
  }
1501
1695
  let t = !1, n = [e.type === "RAWSTRING" ? {
1502
1696
  text: e.value,
1503
- source: e.raw
1504
- } : { text: e.value }];
1697
+ source: e.raw,
1698
+ start: e.offset,
1699
+ end: e.endOffset
1700
+ } : {
1701
+ text: e.value,
1702
+ start: e.offset,
1703
+ end: e.endOffset
1704
+ }];
1505
1705
  for (; this.t.peek().type === "PLUS";) {
1506
1706
  this.t.consume();
1507
1707
  let e = this.t.peek();
1508
- e.type === "ELLIPSIS" ? (this.t.consume(), n.push({ ellipsis: !0 }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push(e.type === "RAWSTRING" ? {
1708
+ e.type === "ELLIPSIS" ? (this.t.consume(), n.push({
1709
+ ellipsis: !0,
1710
+ start: e.offset,
1711
+ end: e.endOffset
1712
+ }), t = !0) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), n.push(e.type === "RAWSTRING" ? {
1509
1713
  text: e.value,
1510
- source: e.raw
1511
- } : { 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);
1714
+ source: e.raw,
1715
+ start: e.offset,
1716
+ end: e.endOffset
1717
+ } : {
1718
+ text: e.value,
1719
+ start: e.offset,
1720
+ end: e.endOffset
1721
+ })) : this._isBytesToken(e.type) ? (this.t.consume(), n.push({
1722
+ text: this._decodeUtf8(this._decodeBytesToken(e), e),
1723
+ isByteString: !0,
1724
+ start: e.offset,
1725
+ end: e.endOffset
1726
+ })) : this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`, e);
1512
1727
  }
1513
1728
  if (!t) {
1514
- let e = n.map((e) => "text" in e ? e.text : ""), t = n.map((e) => "text" in e ? e.source : void 0), r = e.join(""), i = this.consumeEncodingIndicator(() => BigInt(tt.encode(r).length));
1515
- return new U(r, {
1729
+ let e = n.map((e) => "text" in e ? e.text : ""), t = n.map((e) => "text" in e ? e.source : void 0), r = n.map((e) => "text" in e ? e.isByteString ?? !1 : !1), i = n.map((e) => ({
1730
+ start: e.start,
1731
+ end: e.end
1732
+ })), a = e.join(""), o = this.consumeEncodingIndicator(() => BigInt(ot.encode(a).length));
1733
+ return new G(a, {
1516
1734
  ednParts: e,
1735
+ ednPartSpans: i,
1517
1736
  ...t.some((e) => e !== void 0) ? { ednPartSources: t } : {},
1518
- ...i === void 0 ? {} : { encodingWidth: i }
1737
+ ...r.some((e) => e) ? { ednPartIsByteString: r } : {},
1738
+ ...o === void 0 ? {} : { encodingWidth: o }
1519
1739
  });
1520
1740
  }
1521
1741
  let r = [], i = [], a = () => {
1522
1742
  let e = i.map((e) => e.text), t = e.join("");
1523
1743
  if (t !== "") {
1524
- let n = i.map((e) => e.source);
1525
- r.push(new U(t, {
1744
+ let n = i.map((e) => e.source), a = i.map((e) => e.isByteString ?? !1), o = new G(t, {
1526
1745
  ednParts: e,
1527
- ...n.some((e) => e !== void 0) ? { ednPartSources: n } : {}
1528
- }));
1746
+ ednPartSpans: i.map((e) => ({
1747
+ start: e.start,
1748
+ end: e.end
1749
+ })),
1750
+ ...n.some((e) => e !== void 0) ? { ednPartSources: n } : {},
1751
+ ...a.some((e) => e) ? { ednPartIsByteString: a } : {}
1752
+ });
1753
+ o.start = i[0].start, o.end = i[i.length - 1].end, r.push(o);
1529
1754
  }
1530
1755
  i.length = 0;
1531
1756
  };
1532
- for (let e of n) "ellipsis" in e ? (a(), r.push(new V())) : i.push(e);
1757
+ for (let e of n) if ("ellipsis" in e) {
1758
+ a();
1759
+ let t = new V();
1760
+ t.start = e.start, t.end = e.end, r.push(t);
1761
+ } else i.push(e);
1533
1762
  return a(), new V(r);
1534
1763
  }
1535
1764
  _isBytesToken(e) {
1536
1765
  return e === "BYTES_HEX" || e === "SQSTR" || e === "BYTES_B64";
1537
1766
  }
1538
- _hexToBytes(t, n) {
1767
+ _hexToBytes(e, r) {
1539
1768
  try {
1540
- return e(t);
1769
+ return n(e);
1541
1770
  } catch (e) {
1542
- if (e instanceof r || !(e instanceof SyntaxError)) throw e;
1543
- this._fail(e.message, n);
1771
+ if (e instanceof t || !(e instanceof SyntaxError)) throw e;
1772
+ this._fail(e.message, r);
1544
1773
  }
1545
1774
  }
1546
1775
  _decodeBytesToken(e) {
1547
- let t = (t) => this._warnOrFail(t, e);
1776
+ let n = (t) => this._warnOrFail(t, e);
1548
1777
  switch (e.type) {
1549
1778
  case "SQSTR": {
1550
1779
  let t = e._sqstrBytes;
@@ -1552,92 +1781,133 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1552
1781
  }
1553
1782
  case "BYTES_HEX": return this._hexToBytes(e.value, e);
1554
1783
  case "BYTES_B64": try {
1555
- return He(e.value, t);
1556
- } catch (t) {
1557
- if (t instanceof r || !(t instanceof SyntaxError)) throw t;
1558
- this._fail(t.message, e);
1784
+ return Ue(e.value, n);
1785
+ } catch (n) {
1786
+ if (n instanceof t || !(n instanceof SyntaxError)) throw n;
1787
+ this._fail(n.message, e);
1559
1788
  }
1560
1789
  default: this._fail("expected byte string token", e);
1561
1790
  }
1562
1791
  }
1563
1792
  _decodeUtf8(e, t) {
1564
- if (this._options.allowInvalidUtf8) return rt.decode(e);
1793
+ if (this._options.allowInvalidUtf8) return ct.decode(e);
1565
1794
  try {
1566
- return nt.decode(e);
1795
+ return st.decode(e);
1567
1796
  } catch {
1568
- return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), rt.decode(e);
1797
+ return this._warnOrFail("byte string in text concatenation is not valid UTF-8", t), ct.decode(e);
1569
1798
  }
1570
1799
  }
1571
1800
  _tokenTypeToCdnEncoding(e) {
1572
1801
  return e === "BYTES_B64" ? "base64" : "hex";
1573
1802
  }
1574
- _parseBytesConcat(e, t, n) {
1803
+ _tokenTypeToCommentSyntax(e) {
1804
+ if (e === "BYTES_HEX") return "full";
1805
+ if (e === "BYTES_B64") return "hash-only";
1806
+ }
1807
+ _parseBytesConcat(e, t, n, r, i) {
1575
1808
  if (this.t.peek().type !== "PLUS") {
1576
1809
  let r = this.consumeEncodingIndicator(() => BigInt(e.length));
1577
- return new F(e, {
1810
+ return new N(e, {
1578
1811
  ednEncoding: this._tokenTypeToCdnEncoding(t),
1579
1812
  ednSource: n,
1813
+ ednCommentSyntax: this._tokenTypeToCommentSyntax(t),
1580
1814
  ...r === void 0 ? {} : { encodingWidth: r }
1581
1815
  });
1582
1816
  }
1583
- let r = !1, i = [{
1817
+ let a = [{
1584
1818
  bytes: e,
1585
- source: n
1586
- }];
1587
- for (; this.t.peek().type === "PLUS";) {
1588
- this.t.consume();
1589
- let e = this.t.peek();
1590
- if (e.type === "ELLIPSIS") this.t.consume(), i.push({ ellipsis: !0 }), r = !0;
1591
- else if (e.type === "BYTES_HEX_ELIDED") {
1592
- this.t.consume();
1593
- let t = this._buildBytesElidedItems(e.value, e);
1594
- for (let e of t) e instanceof V ? (i.push({ ellipsis: !0 }), r = !0) : e instanceof F && i.push({ bytes: e.value });
1595
- } else this._isBytesToken(e.type) ? (this.t.consume(), i.push({
1596
- bytes: this._decodeBytesToken(e),
1597
- source: e.raw
1598
- })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), i.push({ bytes: tt.encode(e.value) })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
1599
- }
1600
- if (!r) {
1601
- let e = i.map((e) => "bytes" in e ? e : { bytes: /* @__PURE__ */ new Uint8Array() }), n = this._concatBytes(e.map((e) => e.bytes)), r = this.consumeEncodingIndicator(() => BigInt(n.length));
1602
- return new F(n, {
1603
- ednEncoding: this._tokenTypeToCdnEncoding(t),
1604
- ednParts: e,
1605
- ...r === void 0 ? {} : { encodingWidth: r }
1606
- });
1607
- }
1608
- let a = [], o = [], s = () => {
1609
- o.length > 0 && (a.push(new F(this._concatBytes([...o]))), o.length = 0);
1610
- };
1611
- for (let e of i) "ellipsis" in e ? (s(), a.push(new V())) : o.push(e.bytes);
1612
- return s(), new V(a);
1819
+ source: n,
1820
+ commentSyntax: this._tokenTypeToCommentSyntax(t),
1821
+ real: !1,
1822
+ start: r,
1823
+ end: i
1824
+ }], o = this._consumeByteEllipsisChain(a);
1825
+ return this._buildFromByteAtoms(o, this._tokenTypeToCdnEncoding(t));
1613
1826
  }
1614
1827
  _parseHexElidedConcat(e) {
1615
- let t = this._buildBytesElidedItems(e.value, e);
1828
+ let t = this._consumeByteEllipsisChain(this._elidedHexAtoms(e.value, e));
1829
+ return this._buildFromByteAtoms(t, "hex");
1830
+ }
1831
+ _consumeByteEllipsisChain(e) {
1832
+ let t = e;
1616
1833
  for (; this.t.peek().type === "PLUS";) {
1617
1834
  this.t.consume();
1618
1835
  let e = this.t.peek();
1619
- if (e.type === "ELLIPSIS") this.t.consume(), t.push(new V());
1836
+ if (e.type === "ELLIPSIS") this.t.consume(), t.push({
1837
+ ellipsis: !0,
1838
+ real: !0,
1839
+ fromByteLiteral: !1,
1840
+ start: e.offset,
1841
+ end: e.endOffset
1842
+ });
1620
1843
  else if (e.type === "BYTES_HEX_ELIDED") {
1621
1844
  this.t.consume();
1622
- let n = this._buildBytesElidedItems(e.value, e);
1623
- this._mergeFirstBytesItem(t, n);
1624
- } else if (this._isBytesToken(e.type)) {
1625
- this.t.consume();
1626
- let n = this._decodeBytesToken(e), r = t[t.length - 1];
1627
- r instanceof F ? t[t.length - 1] = new F(this._concatBytes([r.value, n])) : t.push(new F(n));
1628
- } else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
1845
+ let n = this._elidedHexAtoms(e.value, e);
1846
+ n.length > 0 && (n[0].real = !0), t.push(...n);
1847
+ } else this._isBytesToken(e.type) ? (this.t.consume(), t.push({
1848
+ bytes: this._decodeBytesToken(e),
1849
+ source: e.raw,
1850
+ commentSyntax: this._tokenTypeToCommentSyntax(e.type),
1851
+ real: !0,
1852
+ start: e.offset,
1853
+ end: e.endOffset
1854
+ })) : e.type === "TSTR" || e.type === "RAWSTRING" ? (this.t.consume(), this._warnOrFail("text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead", e), t.push({
1855
+ bytes: ot.encode(e.value),
1856
+ real: !0,
1857
+ start: e.offset,
1858
+ end: e.endOffset
1859
+ })) : this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`, e);
1629
1860
  }
1630
- return new V(t);
1861
+ return t;
1631
1862
  }
1632
- _buildBytesElidedItems(e, t) {
1863
+ _elidedHexAtoms(e, t) {
1633
1864
  let n = e.split("..."), r = [];
1634
- for (let e = 0; e < n.length; e++) e > 0 && r.push(new V()), n[e].length > 0 && r.push(new F(this._hexToBytes(n[e], t)));
1865
+ for (let e = 0; e < n.length; e++) e > 0 && r.push({
1866
+ ellipsis: !0,
1867
+ real: !1,
1868
+ fromByteLiteral: !0,
1869
+ literalSource: t.raw,
1870
+ start: t.offset,
1871
+ end: t.endOffset
1872
+ }), n[e].length > 0 && r.push({
1873
+ bytes: this._hexToBytes(n[e], t),
1874
+ commentSyntax: "full",
1875
+ real: !1,
1876
+ start: t.offset,
1877
+ end: t.endOffset
1878
+ });
1635
1879
  return r;
1636
1880
  }
1637
- _mergeFirstBytesItem(e, t) {
1638
- if (t.length === 0) return;
1639
- let n = e[e.length - 1], r = t[0];
1640
- n instanceof F && r instanceof F ? (e[e.length - 1] = new F(this._concatBytes([n.value, r.value])), e.push(...t.slice(1))) : e.push(...t);
1881
+ _buildFromByteAtoms(e, t) {
1882
+ if (!e.some((e) => "ellipsis" in e)) {
1883
+ let n = e, r = this._concatBytes(n.map((e) => e.bytes)), i = this.consumeEncodingIndicator(() => BigInt(r.length));
1884
+ return new N(r, {
1885
+ ednEncoding: t,
1886
+ ednParts: n,
1887
+ ...i === void 0 ? {} : { encodingWidth: i }
1888
+ });
1889
+ }
1890
+ let n = [], r = [], i = [], a = () => {
1891
+ if (i.length > 0) {
1892
+ let e = new N(this._concatBytes(i.map((e) => e.bytes)), { ...i.length > 1 ? { ednParts: i.map(({ bytes: e, source: t, commentSyntax: n, start: r, end: i }) => ({
1893
+ bytes: e,
1894
+ source: t,
1895
+ commentSyntax: n,
1896
+ start: r,
1897
+ end: i
1898
+ })) } : {
1899
+ ednSource: i[0].source,
1900
+ ednCommentSyntax: i[0].commentSyntax
1901
+ } });
1902
+ e.start = i[0].start, e.end = i[i.length - 1].end, n.push(e), r.push(i[0].real), i.length = 0;
1903
+ }
1904
+ };
1905
+ for (let t of e) if ("ellipsis" in t) {
1906
+ a();
1907
+ let e = new V(t.fromByteLiteral, t.literalSource);
1908
+ e.start = t.start, e.end = t.end, n.push(e), r.push(t.real);
1909
+ } else i.push(t);
1910
+ return a(), new V(n, r);
1641
1911
  }
1642
1912
  _concatBytes(e) {
1643
1913
  let t = e.reduce((e, t) => e + t.byteLength, 0), n = new Uint8Array(t), r = 0;
@@ -1648,8 +1918,8 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1648
1918
  this.t.consume(), this.expect("LPAREN");
1649
1919
  let e = this.t.peek();
1650
1920
  e.type !== "INTEGER" && this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`, e), this.t.consume();
1651
- let { numStr: t } = at(e.value), n = Number(ot(t));
1652
- return this.expect("RPAREN"), new B(n);
1921
+ let { numStr: t } = ut(e.value), n = Number(dt(t));
1922
+ return this.expect("RPAREN"), new R(n, { ednSource: e.raw });
1653
1923
  }
1654
1924
  parseEmbeddedCBOR() {
1655
1925
  this.t.consume();
@@ -1666,46 +1936,47 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1666
1936
  let e = this.t.consume();
1667
1937
  t = this._resolveEncodingWidth(e.value, e);
1668
1938
  }
1669
- return new Ve(e, { encodingWidth: t });
1939
+ return new z(e, { encodingWidth: t });
1670
1940
  }
1671
1941
  parseArray() {
1672
1942
  this.t.consume();
1673
1943
  let e = !1, t, n;
1674
1944
  this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
1675
- let r = this._pendingWarnings.splice(0), i = [];
1945
+ let r = this._pendingWarnings.splice(0), i = [], a = this.t.lastEndOffset;
1676
1946
  for (; this.t.peek().type !== "RBRACKET";) {
1677
1947
  if (i.length > 0) if (this.t.peek().type === "COMMA") {
1678
1948
  if (this.t.consume(), this.t.peek().type === "RBRACKET") break;
1679
1949
  } else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("array items must be separated by \",\" or whitespace", this.t.peek());
1680
- i.push(this.parseValue());
1950
+ let e = this.parseValue();
1951
+ gt(this.t.source, a, e.start) && (e.blankLineBefore = !0), a = e.end, i.push(e);
1681
1952
  }
1682
1953
  this.expect("RBRACKET"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
1683
- let a = new R(i, {
1954
+ let o = new I(i, {
1684
1955
  indefiniteLength: e,
1685
1956
  encodingWidth: t
1686
1957
  });
1687
- return r.length > 0 && (a.warnings ??= [], a.warnings.push(...r)), a;
1958
+ return r.length > 0 && (o.warnings ??= [], o.warnings.push(...r)), o;
1688
1959
  }
1689
1960
  parseMap() {
1690
1961
  this.t.consume();
1691
1962
  let e = !1, t, n;
1692
1963
  this.t.peek().type === "UNDERSCORE" ? (this.t.consume(), e = !0) : this.t.peek().type === "ENCODING_INDICATOR" && (n = this.t.consume(), n.value === "7" ? (e = !0, this._warnOrFail("encoding indicator _7 is non-standard; use _ to indicate indefinite length", n), n = void 0) : t = this._resolveEncodingWidth(n.value, n));
1693
- let r = this._pendingWarnings.splice(0), i = [];
1964
+ let r = this._pendingWarnings.splice(0), i = [], a = this.t.lastEndOffset;
1694
1965
  for (; this.t.peek().type !== "RBRACE";) {
1695
1966
  if (i.length > 0) if (this.t.peek().type === "COMMA") {
1696
1967
  if (this.t.consume(), this.t.peek().type === "RBRACE") break;
1697
1968
  } else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("map entries must be separated by \",\" or whitespace", this.t.peek());
1698
1969
  let e = this.parseValue();
1699
- this.expect("COLON");
1970
+ gt(this.t.source, a, e.start) && (e.blankLineBefore = !0), this.expect("COLON");
1700
1971
  let t = this.parseValue();
1701
- i.push([e, t]);
1972
+ a = t.end, i.push([e, t]);
1702
1973
  }
1703
1974
  this.expect("RBRACE"), t !== void 0 && n !== void 0 && (t = this._validateEncodingFit(BigInt(i.length), t, n));
1704
- let a = new z(i, {
1975
+ let o = new L(i, {
1705
1976
  indefiniteLength: e,
1706
1977
  encodingWidth: t
1707
1978
  });
1708
- return r.length > 0 && (a.warnings ??= [], a.warnings.push(...r)), a;
1979
+ return r.length > 0 && (o.warnings ??= [], o.warnings.push(...r)), o;
1709
1980
  }
1710
1981
  parseIndefGroup() {
1711
1982
  this.t.consume();
@@ -1716,35 +1987,38 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1716
1987
  let e = this.t.consume(), t = `encoding indicator _${e.value} is not valid in an indefinite string group; use _`;
1717
1988
  this._warnOrFail(t, e);
1718
1989
  } else e.type !== "RPAREN" && this._warnOrFail("indefinite string group is missing _ after (; interpreting as (_ ...)", e);
1719
- let t = this._pendingWarnings.splice(0), n = [];
1990
+ let t = this._pendingWarnings.splice(0), n = [], r = this.t.lastEndOffset;
1720
1991
  for (; this.t.peek().type !== "RPAREN";) {
1721
1992
  if (n.length > 0) if (this.t.peek().type === "COMMA") {
1722
1993
  if (this.t.consume(), this.t.peek().type === "RPAREN") break;
1723
1994
  } else this.t.peek().offset === this.t.lastEndOffset && this._warnOrFail("indefinite string chunks must be separated by \",\" or whitespace", this.t.peek());
1724
- n.push(this.parseValue());
1995
+ let e = this.parseValue();
1996
+ gt(this.t.source, r, e.start) && (e.blankLineBefore = !0), r = e.end, n.push(e);
1725
1997
  }
1726
1998
  this.expect("RPAREN"), n.length === 0 && this._fail("empty indefinite group (_ ) is ambiguous; use ''_ for bytes or \"\"_ for text");
1727
- let r = n[0];
1728
- if (r instanceof F) {
1729
- let e = new I(n.map((e, t) => {
1730
- if (e instanceof F) return e;
1999
+ let i = n[0];
2000
+ if (i instanceof N) {
2001
+ let e = new P(n.map((e, t) => {
2002
+ if (e instanceof N) return e;
1731
2003
  this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`);
1732
2004
  }));
1733
2005
  return t.length > 0 && (e.warnings = t), e;
1734
2006
  }
1735
- if (r instanceof U) {
1736
- let e = new L(n.map((e, t) => {
1737
- if (e instanceof U) return e;
2007
+ if (i instanceof G) {
2008
+ let e = new F(n.map((e, t) => {
2009
+ if (e instanceof G) return e;
1738
2010
  this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`);
1739
2011
  }));
1740
2012
  return t.length > 0 && (e.warnings = t), e;
1741
2013
  }
1742
2014
  this._fail("indefinite group chunks must be byte strings or text strings");
1743
2015
  }
1744
- consumeEncodingIndicator(e) {
2016
+ consumeEncodingIndicator(e, t) {
1745
2017
  if (this.t.peek().type === "ENCODING_INDICATOR") {
1746
- let t = this.t.consume(), n = this._resolveEncodingWidth(t.value, t);
1747
- return n !== void 0 && e !== void 0 && (n = this._validateEncodingFit(e(), n, t)), n;
2018
+ let n = this.t.consume();
2019
+ t?.(n);
2020
+ let r = this._resolveEncodingWidth(n.value, n);
2021
+ return r !== void 0 && e !== void 0 && (r = this._validateEncodingFit(e(), r, n)), r;
1748
2022
  }
1749
2023
  }
1750
2024
  expect(e) {
@@ -1752,47 +2026,47 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1752
2026
  return t.type !== e && this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`, t), t;
1753
2027
  }
1754
2028
  _applyEiToResult(e, t, n) {
1755
- if (e instanceof N) {
2029
+ if (e instanceof j) {
1756
2030
  let r = t === 1 ? "half" : t === 2 ? "single" : t === 3 ? "double" : void 0;
1757
2031
  if (r === void 0) this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`, n);
1758
2032
  else if (e.precision !== r) {
1759
2033
  if (r !== "double") {
1760
- let t = r === "half" ? E(T(e.value)) : Math.fround(e.value);
2034
+ let t = r === "half" ? C(S(e.value)) : Math.fround(e.value);
1761
2035
  !Object.is(t, e.value) && !isNaN(e.value) && this._warnOrFail(`${e.value} cannot be exactly represented as ${r === "half" ? "float16 (_1)" : "float32 (_2)"}`, n);
1762
2036
  }
1763
2037
  e.precision = r;
1764
2038
  }
1765
- } else if (e instanceof j) {
2039
+ } else if (e instanceof k) {
1766
2040
  if (e.encodingWidth === void 0) {
1767
2041
  let r = this._validateEncodingFit(e.value, t, n);
1768
2042
  r !== void 0 && (e.encodingWidth = r);
1769
2043
  }
1770
- } else if (e instanceof M) {
2044
+ } else if (e instanceof A) {
1771
2045
  if (e.encodingWidth === void 0) {
1772
2046
  let r = this._validateEncodingFit(e.argument, t, n);
1773
2047
  r !== void 0 && (e.encodingWidth = r);
1774
2048
  }
1775
- } else if (e instanceof F) {
2049
+ } else if (e instanceof N) {
1776
2050
  if (e.encodingWidth === void 0) {
1777
2051
  let r = this._validateEncodingFit(BigInt(e.value.length), t, n);
1778
2052
  r !== void 0 && (e.encodingWidth = r);
1779
2053
  }
1780
- } else if (e instanceof U) {
2054
+ } else if (e instanceof G) {
1781
2055
  if (e.encodingWidth === void 0) {
1782
- let r = this._validateEncodingFit(BigInt(tt.encode(e.value).length), t, n);
2056
+ let r = this._validateEncodingFit(BigInt(ot.encode(e.value).length), t, n);
1783
2057
  r !== void 0 && (e.encodingWidth = r);
1784
2058
  }
1785
- } else if (e instanceof R) {
2059
+ } else if (e instanceof I) {
1786
2060
  if (e.encodingWidth === void 0) {
1787
2061
  let r = this._validateEncodingFit(BigInt(e.items.length), t, n);
1788
2062
  r !== void 0 && (e.encodingWidth = r);
1789
2063
  }
1790
- } else if (e instanceof z) {
2064
+ } else if (e instanceof L) {
1791
2065
  if (e.encodingWidth === void 0) {
1792
2066
  let r = this._validateEncodingFit(BigInt(e.entries.length), t, n);
1793
2067
  r !== void 0 && (e.encodingWidth = r);
1794
2068
  }
1795
- } else if (e instanceof P) {
2069
+ } else if (e instanceof M) {
1796
2070
  if (e.encodingWidth === void 0) {
1797
2071
  let r = this._validateEncodingFit(e.tag, t, n);
1798
2072
  r !== void 0 && (e.encodingWidth = r);
@@ -1800,7 +2074,7 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1800
2074
  } else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`, n);
1801
2075
  }
1802
2076
  _validateEncodingFit(e, t, n) {
1803
- let r = Me(t);
2077
+ let r = Te(t);
1804
2078
  if (e <= r) return t;
1805
2079
  let i = `value ${e} does not fit in encoding indicator ${t === "i" ? "_i (max 23)" : `_${t} (max ${r})`}`;
1806
2080
  this._warnOrFail(i, n);
@@ -1824,29 +2098,29 @@ var ft = (e) => `import { ${e} } from '@cbortech/cbor' and pass it via the 'exte
1824
2098
  this._warn(e, t), this._options.strict !== !1 && this._fail(e, t);
1825
2099
  }
1826
2100
  _hintMissingExtension(e, t) {
1827
- let n = mt.get(e);
2101
+ let n = Et.get(e);
1828
2102
  if (n === void 0 || this._hintedPrefixes.has(e)) return;
1829
2103
  this._hintedPrefixes.add(e);
1830
2104
  let r = `app-string prefix '${e}' requires an extension that is not enabled; ${n}`;
1831
2105
  this._options.onWarning ? this._options.onWarning({
1832
2106
  message: r,
1833
- ...gt(t),
2107
+ ...Ot(t),
1834
2108
  hint: !0
1835
2109
  }) : this._options.silent || console.warn(`CDN: ${r}`);
1836
2110
  }
1837
2111
  _warn(e, t) {
1838
2112
  let n = { message: e };
1839
- if (t !== void 0 && Object.assign(n, gt(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
2113
+ if (t !== void 0 && Object.assign(n, Ot(t)), this._pendingWarnings.push(n), this._options.onWarning) this._options.onWarning(n);
1840
2114
  else if (!this._options.silent) {
1841
2115
  let n = t ? ` at line ${t.line}, column ${t.col}` : "";
1842
2116
  console.warn(`CDN strict violation${n}: ${e}`);
1843
2117
  }
1844
2118
  }
1845
- _fail(e, t) {
1846
- throw new r(e, t ? gt(t) : void 0);
2119
+ _fail(e, n) {
2120
+ throw new t(e, n ? Ot(n) : void 0);
1847
2121
  }
1848
2122
  };
1849
- function gt(e) {
2123
+ function Ot(e) {
1850
2124
  return {
1851
2125
  offset: e.offset,
1852
2126
  line: e.line,
@@ -1856,85 +2130,93 @@ function gt(e) {
1856
2130
  }
1857
2131
  //#endregion
1858
2132
  //#region src/ast/CborTextString.ts
1859
- var _t = new TextEncoder(), vt = !1, U = class extends A {
2133
+ var kt = new TextEncoder(), At = !1, G = class extends O {
1860
2134
  indefiniteLength = !1;
1861
2135
  value;
1862
2136
  encodingWidth;
1863
2137
  ednParts;
1864
2138
  ednSource;
2139
+ quotedEdnSource;
1865
2140
  ednPartSources;
2141
+ ednPartIsByteString;
2142
+ ednPartSpans;
1866
2143
  constructor(e, t) {
1867
- super(), this.value = e, this.encodingWidth = t?.encodingWidth, this.ednParts = t?.ednParts, this.ednSource = t?.ednSource, this.ednPartSources = t?.ednPartSources;
2144
+ super(), this.value = e, this.encodingWidth = t?.encodingWidth, this.ednParts = t?.ednParts, this.ednSource = t?.ednSource, this.quotedEdnSource = t?.quotedEdnSource, this.ednPartSources = t?.ednPartSources, this.ednPartIsByteString = t?.ednPartIsByteString, this.ednPartSpans = t?.ednPartSpans;
1868
2145
  }
1869
2146
  _encodeTo(e, t) {
1870
2147
  e.writeTextString(3, this.value, this.encodingWidth);
1871
2148
  }
1872
2149
  _toCDN(e, t) {
1873
- let n = w(e, this.encodingWidth, () => C(BigInt(_t.encode(this.value).length)));
1874
- return yt(this.value, n, e, t, this.ednParts, this.ednSource, this.ednPartSources);
2150
+ let n = a(e, this.encodingWidth, () => p(BigInt(kt.encode(this.value).length)));
2151
+ return jt(this.value, n, e, t, this.ednParts, this.ednSource, this.quotedEdnSource, this.ednPartSources, this.ednPartSpans, this.comments?.dangling);
1875
2152
  }
1876
2153
  _toJS(e) {
1877
2154
  return this.value;
1878
2155
  }
1879
2156
  };
1880
- function yt(e, t, n, r, i, a, o) {
1881
- let s = _(n);
1882
- if (n?.preserveRawString && a !== void 0 && (s !== null || !/[\r\n]/.test(a))) return a + t;
1883
- if (s === null) return ye(e) + t;
1884
- let c = n?.preserveRawString ? o : void 0, l = c?.some((e) => e !== void 0) ?? !1, { cdn: u, newline: d } = xt(n), f = n?.preserveConcatenation && i !== void 0 && (i.length > 1 || l) ? i : void 0;
1885
- if (!u && !d && f === void 0) return ye(e) + t;
1886
- let p = u ? wt(e) : null;
1887
- if (f !== void 0 && (p === null || l)) {
1888
- let e = [];
1889
- for (let [t, n] of f.entries()) {
1890
- let r = c?.[t];
1891
- if (r !== void 0) e.push({
2157
+ function jt(e, t, n, r, i, a, o, s, c, l) {
2158
+ let u = v(n);
2159
+ if (n?.preserveRawString && a !== void 0 && (u !== null || !/[\r\n]/.test(a))) return a + t;
2160
+ if (n?.preserveTextString && o !== void 0 && (u !== null || !/[\r\n]/.test(o))) return o + t;
2161
+ if (u === null) return ee(e) + t;
2162
+ let d = n?.preserveRawString ? s : void 0, f = d?.some((e) => e !== void 0) ?? !1, { cdn: p, newline: te } = Nt(n), m = n?.preserveConcatenation && i !== void 0 && (i.length > 1 || f) ? i : void 0;
2163
+ if (!p && !te && m === void 0) return ee(e) + t;
2164
+ let h = p ? It(e) : null;
2165
+ if (m !== void 0 && (h === null || f)) {
2166
+ let e = n?.preserveComments ? ne(l, c, typeof n.preserveComments == "string" ? n.preserveComments : void 0) : void 0, i = [];
2167
+ for (let [t, n] of m.entries()) {
2168
+ let r = d?.[t];
2169
+ if (r !== void 0) i.push({
1892
2170
  text: n,
1893
2171
  contentDepth: 0,
1894
2172
  source: r
1895
2173
  });
1896
- else if (d) {
1897
- let t = /* @__PURE__ */ new Map();
1898
- for (let { point: e, contentDepth: r } of Ct(n, 0)) t.set(e, r);
1899
- e.push(...Mt(n, t));
1900
- } else e.push({
2174
+ else if (te) {
2175
+ let e = /* @__PURE__ */ new Map();
2176
+ for (let { point: t, contentDepth: r } of Ft(n, 0)) e.set(t, r);
2177
+ i.push(...Wt(n, e));
2178
+ } else i.push({
1901
2179
  text: n,
1902
2180
  contentDepth: 0
1903
2181
  });
2182
+ let a = e?.[t];
2183
+ a && a.length > 0 && (i[i.length - 1].commentsAfter = a);
1904
2184
  }
1905
- return bt(e, t, s, r);
2185
+ return Mt(i, t, u, r);
1906
2186
  }
1907
- let m = /* @__PURE__ */ new Map();
1908
- if (p !== null) for (let { point: e, contentDepth: t } of p) m.set(e, t);
1909
- if (d) {
1910
- let t = p === null ? Ct(e, 0) : Tt(e);
1911
- for (let { point: e, contentDepth: n } of t) m.has(e) || m.set(e, n);
2187
+ let g = /* @__PURE__ */ new Map();
2188
+ if (h !== null) for (let { point: e, contentDepth: t } of h) g.set(e, t);
2189
+ if (te) {
2190
+ let t = h === null ? Ft(e, 0) : Lt(e);
2191
+ for (let { point: e, contentDepth: n } of t) g.has(e) || g.set(e, n);
1912
2192
  }
1913
- let h = Mt(e, m);
1914
- return h.length <= 1 ? ye(e) + t : bt(h, t, s, r);
2193
+ let _ = Wt(e, g);
2194
+ return _.length <= 1 ? ee(e) + t : Mt(_, t, u, r);
1915
2195
  }
1916
- function bt(e, t, n, r) {
2196
+ function Mt(e, t, n, r) {
1917
2197
  let i = e.map(({ text: n, source: r }, i) => {
1918
- let a = r ?? ye(n);
2198
+ let a = r ?? ee(n);
1919
2199
  return i === e.length - 1 ? a + t : a;
1920
2200
  }), a = i[0];
1921
2201
  for (let t = 1; t < i.length; t++) {
1922
- let o = v(n, r + 1 + e[t].contentDepth);
1923
- a += ` +\n${o}${i[t]}`;
2202
+ let o = te(n, r + 1 + e[t].contentDepth);
2203
+ a += " +\n";
2204
+ for (let n of e[t - 1].commentsAfter ?? []) a += `${o}${n}\n`;
2205
+ a += `${o}${i[t]}`;
1924
2206
  }
1925
2207
  return a;
1926
2208
  }
1927
- function xt(e) {
1928
- let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? St(e?.textStringFormat ?? []) : [];
2209
+ function Nt(e) {
2210
+ let t = e?.splitCdn === void 0 || e?.splitNewline === void 0 ? Pt(e?.textStringFormat ?? []) : [];
1929
2211
  return {
1930
2212
  cdn: e?.splitCdn ?? t.includes("cdn"),
1931
2213
  newline: e?.splitNewline ?? t.includes("newline")
1932
2214
  };
1933
2215
  }
1934
- function St(e) {
1935
- return e.map((e) => e === "cboredn" ? (vt || (vt = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
2216
+ function Pt(e) {
2217
+ return e.map((e) => e === "cboredn" ? (At || (At = !0, console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")), "cdn") : e);
1936
2218
  }
1937
- function Ct(e, t) {
2219
+ function Ft(e, t) {
1938
2220
  let n = [];
1939
2221
  for (let r = 0; r < e.length; r++) {
1940
2222
  let i = e[r];
@@ -1951,66 +2233,66 @@ function Ct(e, t) {
1951
2233
  }
1952
2234
  return n;
1953
2235
  }
1954
- function wt(e) {
2236
+ function It(e) {
1955
2237
  try {
1956
- it(e);
2238
+ lt(e);
1957
2239
  } catch {
1958
2240
  return null;
1959
2241
  }
1960
- let t = [], n = new a(e), r = 0, i = null, o = !1, s = 0;
2242
+ let t = [], n = new re(e), r = 0, i = null, a = !1, o = 0;
1961
2243
  for (;;) {
1962
- let a = n.consume();
1963
- if (a.type === "EOF") break;
2244
+ let s = n.consume();
2245
+ if (s.type === "EOF") break;
1964
2246
  let c = !1;
1965
- if (o || (o = !0, a.offset > 0 && At(n.comments, 0, a.offset) && t.push({
1966
- point: a.offset,
2247
+ if (a || (a = !0, s.offset > 0 && Ht(n.comments, 0, s.offset) && t.push({
2248
+ point: s.offset,
1967
2249
  contentDepth: r
1968
2250
  })), i !== null) {
1969
- if (i.kind === "opener" && Dt.has(a.type)) {
1970
- i.point = a.endOffset, s = a.endOffset;
2251
+ if (i.kind === "opener" && zt.has(s.type)) {
2252
+ i.point = s.endOffset, o = s.endOffset;
1971
2253
  continue;
1972
- } else i.kind === "opener" && kt.has(a.type) && jt(e, i.point, a.offset) ? c = !0 : t.push({
1973
- point: a.offset,
2254
+ } else i.kind === "opener" && Vt.has(s.type) && Ut(e, i.point, s.offset) ? c = !0 : t.push({
2255
+ point: s.offset,
1974
2256
  contentDepth: i.contentDepth
1975
2257
  });
1976
2258
  i = null;
1977
2259
  }
1978
- Ot.has(a.type) ? (r++, i = {
1979
- point: a.endOffset,
2260
+ Bt.has(s.type) ? (r++, i = {
2261
+ point: s.endOffset,
1980
2262
  contentDepth: r,
1981
2263
  kind: "opener"
1982
- }) : kt.has(a.type) ? (r = Math.max(0, r - 1), c || t.push({
1983
- point: a.offset,
2264
+ }) : Vt.has(s.type) ? (r = Math.max(0, r - 1), c || t.push({
2265
+ point: s.offset,
1984
2266
  contentDepth: r
1985
- })) : a.type === "COMMA" && (i = {
1986
- point: a.endOffset,
2267
+ })) : s.type === "COMMA" && (i = {
2268
+ point: s.endOffset,
1987
2269
  contentDepth: r,
1988
2270
  kind: "comma"
1989
- }), s = a.endOffset;
2271
+ }), o = s.endOffset;
1990
2272
  }
1991
- let c = n.comments.find((e) => e.start >= s);
1992
- return c !== void 0 && t.push({
1993
- point: c.start,
2273
+ let s = n.comments.find((e) => e.start >= o);
2274
+ return s !== void 0 && t.push({
2275
+ point: s.start,
1994
2276
  contentDepth: r
1995
2277
  }), t;
1996
2278
  }
1997
- function Tt(e) {
1998
- let t = [], n = new a(e), r = 0;
2279
+ function Lt(e) {
2280
+ let t = [], n = new re(e), r = 0;
1999
2281
  for (;;) {
2000
2282
  let i = n.consume();
2001
2283
  if (i.type === "EOF") break;
2002
- if (Ot.has(i.type)) r++;
2003
- else if (kt.has(i.type)) r = Math.max(0, r - 1);
2284
+ if (Bt.has(i.type)) r++;
2285
+ else if (Vt.has(i.type)) r = Math.max(0, r - 1);
2004
2286
  else if (i.type !== "COMMA") {
2005
2287
  if (i.type === "TSTR") {
2006
2288
  let n = e.slice(i.offset, i.endOffset);
2007
- for (let e of Et(n)) t.push({
2289
+ for (let e of Rt(n)) t.push({
2008
2290
  point: i.offset + e,
2009
2291
  contentDepth: r + 1
2010
2292
  });
2011
2293
  } else if (i.type === "RAWSTRING") {
2012
2294
  let n = e.slice(i.offset, i.endOffset);
2013
- for (let { point: e } of Ct(n, 0)) t.push({
2295
+ for (let { point: e } of Ft(n, 0)) t.push({
2014
2296
  point: i.offset + e,
2015
2297
  contentDepth: r + 1
2016
2298
  });
@@ -2019,7 +2301,7 @@ function Tt(e) {
2019
2301
  }
2020
2302
  return t;
2021
2303
  }
2022
- function Et(e) {
2304
+ function Rt(e) {
2023
2305
  let t = [], n = 1, r = e.length - 1;
2024
2306
  for (; n < r;) {
2025
2307
  let r = e[n];
@@ -2035,24 +2317,24 @@ function Et(e) {
2035
2317
  }
2036
2318
  return t;
2037
2319
  }
2038
- var Dt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Ot = /* @__PURE__ */ new Set([
2320
+ var zt = /* @__PURE__ */ new Set(["ENCODING_INDICATOR", "UNDERSCORE"]), Bt = /* @__PURE__ */ new Set([
2039
2321
  "LBRACKET",
2040
2322
  "LBRACE",
2041
2323
  "LPAREN",
2042
2324
  "LT_LT"
2043
- ]), kt = /* @__PURE__ */ new Set([
2325
+ ]), Vt = /* @__PURE__ */ new Set([
2044
2326
  "RBRACKET",
2045
2327
  "RBRACE",
2046
2328
  "RPAREN",
2047
2329
  "GT_GT"
2048
2330
  ]);
2049
- function At(e, t, n) {
2331
+ function Ht(e, t, n) {
2050
2332
  return e.some((e) => e.start >= t && e.end <= n);
2051
2333
  }
2052
- function jt(e, t, n) {
2334
+ function Ut(e, t, n) {
2053
2335
  return /^[\t\n\r ]*$/.test(e.slice(t, n));
2054
2336
  }
2055
- function Mt(e, t) {
2337
+ function Wt(e, t) {
2056
2338
  let n = [...t].filter(([t]) => t > 0 && t < e.length).sort(([e], [t]) => e - t);
2057
2339
  if (n.length === 0) return [{
2058
2340
  text: e,
@@ -2070,7 +2352,7 @@ function Mt(e, t) {
2070
2352
  }
2071
2353
  //#endregion
2072
2354
  //#region src/extensions/dt.ts
2073
- function W(e) {
2355
+ function Gt(e) {
2074
2356
  if (Number.isInteger(e)) return (/* @__PURE__ */ new Date(e * 1e3)).toISOString().replace(/\.000Z$/, "Z");
2075
2357
  let t = Math.round(e * 1e3);
2076
2358
  if (t / 1e3 === e) return new Date(t).toISOString().replace(/\.000Z$/, "Z");
@@ -2078,17 +2360,17 @@ function W(e) {
2078
2360
  for (; s.length < 3;) s += "0";
2079
2361
  return `${i}.${s}Z`;
2080
2362
  }
2081
- var Nt = new TextDecoder("utf-8", { fatal: !0 });
2082
- function Pt(e) {
2363
+ var Kt = new TextDecoder("utf-8", { fatal: !0 });
2364
+ function qt(e) {
2083
2365
  if (e.length !== 1) throw SyntaxError("dt<<...>>: expected exactly one item");
2084
2366
  let t = e[0];
2085
- if (t instanceof U) return t.value;
2086
- if (t instanceof F) return Nt.decode(t.value);
2367
+ if (t instanceof G) return t.value;
2368
+ if (t instanceof N) return Kt.decode(t.value);
2087
2369
  throw SyntaxError("dt<<...>>: expected a text string or byte string");
2088
2370
  }
2089
- var Ft = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
2090
- function It(e, t) {
2091
- if (!Ft.test(e)) {
2371
+ var Jt = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/i;
2372
+ function Yt(e, t) {
2373
+ if (!Jt.test(e)) {
2092
2374
  let n = `dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`;
2093
2375
  if (t) t(n);
2094
2376
  else throw SyntaxError(n);
@@ -2099,93 +2381,110 @@ function It(e, t) {
2099
2381
  if (isNaN(a)) throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);
2100
2382
  if (i === void 0) {
2101
2383
  let e = a / 1e3;
2102
- return e >= 0 ? new Rt(BigInt(e)) : new zt(BigInt(e));
2384
+ return e >= 0 ? new Zt(BigInt(e)) : new Qt(BigInt(e));
2103
2385
  }
2104
- return new Bt(a / 1e3 + i);
2386
+ return new $t(a / 1e3 + i);
2105
2387
  }
2106
- var Lt = 1n, Rt = class extends j {
2388
+ var Xt = 1n, Zt = class extends k {
2107
2389
  constructor(e, t) {
2108
2390
  super(e, t);
2109
2391
  }
2110
2392
  _toCDN(e, t) {
2111
2393
  if (e?.appStrings === !1) return super._toCDN(e, t);
2112
- let n = w(e, this.encodingWidth, () => C(this.value));
2113
- return `dt'${W(Number(this.value))}'${n}`;
2394
+ let n = a(e, this.encodingWidth, () => p(this.value));
2395
+ return _(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? m(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Gt(Number(this.value))}'${n}`;
2114
2396
  }
2115
- }, zt = class extends M {
2397
+ }, Qt = class extends A {
2116
2398
  constructor(e, t) {
2117
2399
  super(e, t);
2118
2400
  }
2119
2401
  _toCDN(e, t) {
2120
2402
  if (e?.appStrings === !1) return super._toCDN(e, t);
2121
- let n = w(e, this.encodingWidth, () => C(this.argument));
2122
- return `dt'${W(Number(this.value))}'${n}`;
2403
+ let n = a(e, this.encodingWidth, () => p(this.argument));
2404
+ return _(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? m(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Gt(Number(this.value))}'${n}`;
2123
2405
  }
2124
- }, Bt = class extends N {
2406
+ }, $t = class extends j {
2125
2407
  constructor(e, t) {
2126
2408
  super(e, t);
2127
2409
  }
2128
2410
  _toCDN(e, t) {
2129
2411
  if (e?.appStrings === !1) return super._toCDN(e, t);
2130
- let n = k(this.value), r = xe(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
2131
- return `dt'${W(this.value)}'${r}`;
2412
+ let n = D(this.value), r = ie(this.value, this.precision, n, e?.encodingIndicators ?? "auto");
2413
+ return _(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? m(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments) : `dt'${Gt(this.value)}'${r}`;
2132
2414
  }
2133
- }, Vt = class extends P {
2415
+ }, en = class extends M {
2134
2416
  constructor(e, t) {
2135
- super(Lt, typeof e == "string" ? It(e) : e, t);
2417
+ super(Xt, typeof e == "string" ? Yt(e) : e, t);
2136
2418
  }
2137
2419
  _toCDN(e, t) {
2138
2420
  if (e?.appStrings === !1) return super._toCDN(e, t);
2139
- let n = this.content;
2140
- if (n instanceof N ? n.precision !== void 0 && n.precision !== k(n.value) : n.encodingWidth !== void 0) return super._toCDN({
2421
+ let n = _(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
2422
+ if (n === "verbatim") return this.appSeqSource;
2423
+ if (n === "source") return g(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
2424
+ if (n === "structural") return super._toCDN({
2141
2425
  ...e,
2142
2426
  appStrings: !1
2143
2427
  }, t);
2144
- let r = n instanceof N ? n.value : Number(n.value), i = w(e, this.encodingWidth, () => C(Lt));
2145
- return `DT'${W(r)}'${i}`;
2428
+ let r = a(e, this.encodingWidth, () => p(Xt));
2429
+ if (n === "adjusted") return m(this.appSeqSource, r, e, this.appSeqInnerEnd, this.appSeqComments);
2430
+ let i = this.content;
2431
+ return (i instanceof j ? i.precision !== void 0 && i.precision !== D(i.value) : i.encodingWidth !== void 0) ? super._toCDN({
2432
+ ...e,
2433
+ appStrings: !1
2434
+ }, t) : `DT'${Gt(i instanceof j ? i.value : Number(i.value))}'${r}`;
2146
2435
  }
2147
- }, Ht = class extends Vt {
2436
+ }, tn = class extends en {
2148
2437
  constructor(e, t) {
2149
2438
  super(e, t);
2150
2439
  }
2151
2440
  _toJS(e) {
2152
- let t = this.content, n = t instanceof N ? t.value * 1e3 : Number(t.value) * 1e3;
2441
+ let t = this.content, n = t instanceof j ? t.value * 1e3 : Number(t.value) * 1e3;
2153
2442
  return new Date(n);
2154
2443
  }
2155
2444
  };
2156
- function Ut(e) {
2445
+ function nn(e) {
2157
2446
  let t = e?.jsDate ?? !1;
2158
2447
  function n(e) {
2159
- return t ? new Ht(e) : new Vt(e);
2448
+ return t ? new tn(e) : new en(e);
2160
2449
  }
2161
2450
  let r = {
2162
2451
  appStringPrefixes: ["dt", "DT"],
2163
- tagNumbers: [Lt],
2452
+ tagNumbers: [Xt],
2453
+ preserveAppSeqSource: "optional",
2164
2454
  parseAppString(e, t, r) {
2165
- return e === "DT" ? n(t) : It(t, r);
2455
+ return e === "DT" ? n(t) : Yt(t, r);
2166
2456
  },
2167
2457
  parseAppSequence(e, t, r) {
2168
- let i = Pt(t);
2169
- return e === "DT" ? n(i) : It(i, r);
2458
+ let i = qt(t);
2459
+ return e === "DT" ? n(i) : Yt(i, r);
2170
2460
  },
2171
2461
  parseTag(e, n) {
2172
2462
  if (e !== 1n) return;
2173
2463
  let r;
2174
- if (n instanceof j) r = new Rt(n.value, { encodingWidth: n.encodingWidth });
2175
- else if (n instanceof M) r = new zt(n.value, { encodingWidth: n.encodingWidth });
2176
- else if (n instanceof N) r = new Bt(n.value), n.precision !== void 0 && (r.precision = n.precision);
2464
+ if (n instanceof k) r = new Zt(n.value, {
2465
+ encodingWidth: n.encodingWidth,
2466
+ ednSource: n.ednSource
2467
+ });
2468
+ else if (n instanceof A) r = new Qt(n.value, {
2469
+ encodingWidth: n.encodingWidth,
2470
+ ednSource: n.ednSource
2471
+ });
2472
+ else if (n instanceof j) r = new $t(n.value, {
2473
+ precision: n.precision,
2474
+ literalSource: n.literalSource
2475
+ });
2177
2476
  else return;
2178
- return r.start = n.start, r.end = n.end, t ? new Ht(r) : new Vt(r);
2477
+ return r.start = n.start, r.end = n.end, t ? new tn(r) : new en(r);
2179
2478
  }
2180
2479
  };
2181
2480
  return t && (r.fromJS = (e, t) => {
2182
- if (e instanceof Date) return new Ht(W(e.getTime() / 1e3));
2481
+ if (e instanceof Date) return new tn(Gt(e.getTime() / 1e3));
2183
2482
  }, r.isJSType = (e) => e instanceof Date), r;
2184
2483
  }
2185
- var Wt = Ut(), Gt = Ut({ jsDate: !0 });
2484
+ var rn = nn(), an = nn({ jsDate: !0 });
2186
2485
  //#endregion
2187
2486
  //#region src/utils/ip.ts
2188
- function Kt(e) {
2487
+ function on(e) {
2189
2488
  let t = e.split(".");
2190
2489
  if (t.length !== 4) throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);
2191
2490
  let n = /* @__PURE__ */ new Uint8Array(4);
@@ -2198,11 +2497,11 @@ function Kt(e) {
2198
2497
  }
2199
2498
  return n;
2200
2499
  }
2201
- function qt(e) {
2500
+ function sn(e) {
2202
2501
  let t = /* @__PURE__ */ new Uint8Array(16);
2203
2502
  if (e === "::") return t;
2204
2503
  let n = e, r = null, i = e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);
2205
- i && (n = i[1], n.endsWith(":") && (n += ":"), r = Kt(i[2]));
2504
+ i && (n = i[1], n.endsWith(":") && (n += ":"), r = on(i[2]));
2206
2505
  let a = n.split("::");
2207
2506
  if (a.length > 2) throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);
2208
2507
  let o = a.length === 2, s = a[0] ? a[0].split(":") : [], c = o && a[1] ? a[1].split(":") : [], l = r ? 6 : 8;
@@ -2219,11 +2518,11 @@ function qt(e) {
2219
2518
  }
2220
2519
  return r && t.set(r, 12), t;
2221
2520
  }
2222
- function Jt(e) {
2521
+ function cn(e) {
2223
2522
  return Array.from(e).join(".");
2224
2523
  }
2225
- function Yt(e) {
2226
- let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? Jt(e.slice(12)) : null, n = t ? 6 : 8, r = [];
2524
+ function ln(e) {
2525
+ let t = e.slice(0, 10).every((e) => e === 0) && e[10] === 255 && e[11] === 255 ? cn(e.slice(12)) : null, n = t ? 6 : 8, r = [];
2227
2526
  for (let t = 0; t < n * 2; t += 2) r.push(e[t] << 8 | e[t + 1]);
2228
2527
  let i = -1, a = 0, o = 0;
2229
2528
  for (; o < n;) if (r[o] === 0) {
@@ -2237,29 +2536,29 @@ function Yt(e) {
2237
2536
  }
2238
2537
  //#endregion
2239
2538
  //#region src/extensions/ip.ts
2240
- var Xt = "ip", G = "IP", Zt = 52n, Qt = 54n, $t = new TextDecoder("utf-8", { fatal: !0 });
2241
- function en(e) {
2539
+ var un = "ip", dn = "IP", fn = 52n, pn = 54n, mn = new TextDecoder("utf-8", { fatal: !0 });
2540
+ function hn(e) {
2242
2541
  if (e.length !== 1) throw SyntaxError("ip<<...>>: expected exactly one item");
2243
2542
  let t = e[0];
2244
- if (t instanceof U) return t.value;
2245
- if (t instanceof F) return $t.decode(t.value);
2543
+ if (t instanceof G) return t.value;
2544
+ if (t instanceof N) return mn.decode(t.value);
2246
2545
  throw SyntaxError("ip<<...>>: expected a text string or byte string");
2247
2546
  }
2248
- function tn(e) {
2547
+ function gn(e) {
2249
2548
  return /^\d/.test(e) && e.includes(".") && !e.includes(":") ? {
2250
- bytes: Kt(e),
2549
+ bytes: on(e),
2251
2550
  isV4: !0
2252
2551
  } : {
2253
- bytes: qt(e),
2552
+ bytes: sn(e),
2254
2553
  isV4: !1
2255
2554
  };
2256
2555
  }
2257
- function nn(e) {
2258
- if (e.length === 4) return Jt(e);
2259
- if (e.length === 16) return Yt(e);
2556
+ function _n(e) {
2557
+ if (e.length === 4) return cn(e);
2558
+ if (e.length === 16) return ln(e);
2260
2559
  throw SyntaxError(`ip: unexpected byte length: ${e.length}`);
2261
2560
  }
2262
- function rn(e, t) {
2561
+ function vn(e, t) {
2263
2562
  let n = new Uint8Array(e.length);
2264
2563
  n.set(e);
2265
2564
  let r = Math.floor(t / 8), i = t % 8;
@@ -2269,72 +2568,82 @@ function rn(e, t) {
2269
2568
  for (; a > 0 && n[a - 1] === 0;) a--;
2270
2569
  return n.slice(0, a);
2271
2570
  }
2272
- function an(e, t) {
2571
+ function yn(e, t) {
2273
2572
  let n = new Uint8Array(t);
2274
2573
  return n.set(e), n;
2275
2574
  }
2276
- var on = class extends F {
2575
+ var bn = class extends N {
2277
2576
  _toCDN(e, t) {
2278
2577
  if (e?.appStrings === !1) return super._toCDN(e, t);
2279
- let n = w(e, this.encodingWidth, () => C(BigInt(this.value.length)));
2280
- return `${Xt}'${nn(this.value)}'${n}`;
2578
+ let n = a(e, this.encodingWidth, () => p(BigInt(this.value.length)));
2579
+ return _(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted" ? m(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments) : `${un}'${_n(this.value)}'${n}`;
2281
2580
  }
2282
- }, sn = class extends R {
2581
+ }, xn = class extends I {
2283
2582
  _isV4;
2284
2583
  constructor(e, t, n) {
2285
- super([new j(BigInt(e)), new F(t)]), this._isV4 = n;
2584
+ super([new k(BigInt(e)), new N(t)]), this._isV4 = n;
2286
2585
  }
2287
2586
  _toCDN(e, t) {
2288
2587
  if (e?.appStrings === !1) return super._toCDN(e, t);
2588
+ if (_(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted") return m(this.appSeqSource, "", e, this.appSeqInnerEnd, this.appSeqComments);
2289
2589
  let n = Number(this.items[0].value), r = this.items[1].value;
2290
- return `${Xt}'${nn(an(r, this._isV4 ? 4 : 16))}/${n}'`;
2590
+ return `${un}'${_n(yn(r, this._isV4 ? 4 : 16))}/${n}'`;
2291
2591
  }
2292
- }, cn = class extends P {
2592
+ }, Sn = class extends M {
2293
2593
  constructor(e, t) {
2294
2594
  super(e, t);
2295
2595
  }
2296
2596
  _toCDN(e, t) {
2297
2597
  if (e?.appStrings === !1) return super._toCDN(e, t);
2298
- let n = this.tag === Zt ? 4 : 16, r = this.content;
2299
- if (r instanceof F) {
2300
- if (r.encodingWidth !== void 0) return super._toCDN(e, t);
2301
- let n = w(e, this.encodingWidth, () => C(this.tag));
2302
- return `${G}'${nn(r.value)}'${n}`;
2303
- }
2304
- if (r instanceof R && r.items.length === 2 && r.items[0] instanceof j && r.items[1] instanceof F) {
2305
- if (r.encodingWidth !== void 0 || r.items[0].encodingWidth !== void 0 || r.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
2306
- let i = Number(r.items[0].value), a = an(r.items[1].value, n), o = w(e, this.encodingWidth, () => C(this.tag));
2307
- return `${G}'${nn(a)}/${i}'${o}`;
2598
+ let n = _(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
2599
+ if (n === "verbatim") return this.appSeqSource;
2600
+ if (n === "source") return g(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
2601
+ if (n === "structural") return super._toCDN(e, t);
2602
+ if (n === "adjusted") {
2603
+ let t = a(e, this.encodingWidth, () => p(this.tag));
2604
+ return m(this.appSeqSource, t, e, this.appSeqInnerEnd, this.appSeqComments);
2605
+ }
2606
+ let r = this.tag === fn ? 4 : 16, i = this.content;
2607
+ if (i instanceof N) {
2608
+ if (i.encodingWidth !== void 0) return super._toCDN(e, t);
2609
+ let n = a(e, this.encodingWidth, () => p(this.tag));
2610
+ return `${dn}'${_n(i.value)}'${n}`;
2611
+ }
2612
+ if (i instanceof I && i.items.length === 2 && i.items[0] instanceof k && i.items[1] instanceof N) {
2613
+ if (i.encodingWidth !== void 0 || i.items[0].encodingWidth !== void 0 || i.items[1].encodingWidth !== void 0) return super._toCDN(e, t);
2614
+ let n = Number(i.items[0].value), o = yn(i.items[1].value, r), s = a(e, this.encodingWidth, () => p(this.tag));
2615
+ return `${dn}'${_n(o)}/${n}'${s}`;
2308
2616
  }
2309
2617
  return super._toCDN(e, t);
2310
2618
  }
2311
2619
  };
2312
- function ln(e, t) {
2620
+ function Cn(e, t) {
2313
2621
  let n = t.indexOf("/");
2314
2622
  if (n === -1) {
2315
- let { bytes: n, isV4: r } = tn(t);
2316
- return e === G ? new cn(r ? Zt : Qt, new F(n)) : new on(n);
2623
+ let { bytes: n, isV4: r } = gn(t);
2624
+ return e === dn ? new Sn(r ? fn : pn, new N(n)) : new bn(n);
2317
2625
  }
2318
2626
  let r = t.slice(0, n), i = t.slice(n + 1);
2319
2627
  if (!/^\d+$/.test(i)) throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);
2320
- let a = parseInt(i, 10), { bytes: o, isV4: s } = tn(r), c = s ? 32 : 128;
2628
+ let a = parseInt(i, 10), { bytes: o, isV4: s } = gn(r), c = s ? 32 : 128;
2321
2629
  if (a > c) throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s ? "IPv4" : "IPv6"}`);
2322
- let l = rn(o, a);
2323
- return e === G ? new cn(s ? Zt : Qt, new R([new j(BigInt(a)), new F(l)])) : new sn(a, l, s);
2630
+ let l = vn(o, a);
2631
+ return e === dn ? new Sn(s ? fn : pn, new I([new k(BigInt(a)), new N(l)])) : new xn(a, l, s);
2324
2632
  }
2325
- var un = {
2326
- appStringPrefixes: [Xt, G],
2327
- tagNumbers: [Zt, Qt],
2633
+ var wn = {
2634
+ appStringPrefixes: [un, dn],
2635
+ tagNumbers: [fn, pn],
2636
+ preserveAppSeqSource: "optional",
2328
2637
  parseAppString(e, t) {
2329
- return ln(e, t);
2638
+ return Cn(e, t);
2330
2639
  },
2331
2640
  parseAppSequence(e, t) {
2332
- return ln(e, en(t));
2641
+ return Cn(e, hn(t));
2333
2642
  },
2334
2643
  parseTag(e, t) {
2335
- if (!(e !== Zt && e !== Qt) && (t instanceof F || t instanceof R)) return new cn(e, t);
2644
+ if (!(e !== fn && e !== pn) && (t instanceof N || t instanceof I)) return new Sn(e, t);
2336
2645
  }
2337
- }, dn = "cri", fn = "CRI", pn = 99n, mn = /* @__PURE__ */ new Map([
2646
+ }, Tn = "cri", En = "CRI", Dn = 99n, On = /* @__PURE__ */ new Map([
2338
2647
  ["coap", -1n],
2339
2648
  ["coaps", -2n],
2340
2649
  ["http", -3n],
@@ -2345,7 +2654,7 @@ var un = {
2345
2654
  ["coaps+tcp", -8n],
2346
2655
  ["coap+ws", -25n],
2347
2656
  ["coaps+ws", -26n]
2348
- ]), hn = new Map([...mn.entries()].map(([e, t]) => [t, e]));
2657
+ ]), kn = new Map([...On.entries()].map(([e, t]) => [t, e]));
2349
2658
  function K(e) {
2350
2659
  try {
2351
2660
  return decodeURIComponent(e);
@@ -2353,39 +2662,39 @@ function K(e) {
2353
2662
  return e;
2354
2663
  }
2355
2664
  }
2356
- var gn = new TextEncoder(), _n = new TextDecoder("utf-8", { fatal: !0 });
2357
- function vn(e) {
2358
- return Array.from(gn.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
2665
+ var An = new TextEncoder(), jn = new TextDecoder("utf-8", { fatal: !0 });
2666
+ function Mn(e) {
2667
+ return Array.from(An.encode(e), (e) => `%${e.toString(16).toUpperCase().padStart(2, "0")}`).join("");
2359
2668
  }
2360
2669
  function q(e, t) {
2361
2670
  let n = "";
2362
- for (let r of e) n += t(r) ? r : vn(r);
2671
+ for (let r of e) n += t(r) ? r : Mn(r);
2363
2672
  return n;
2364
2673
  }
2365
- function yn(e) {
2674
+ function Nn(e) {
2366
2675
  return /[A-Za-z0-9\-._~]/.test(e);
2367
2676
  }
2368
- function bn(e) {
2677
+ function Pn(e) {
2369
2678
  return /[!$&'()*+,;=]/.test(e);
2370
2679
  }
2371
- function xn(e) {
2372
- return yn(e) || bn(e) || e === ":" || e === "@";
2680
+ function Fn(e) {
2681
+ return Nn(e) || Pn(e) || e === ":" || e === "@";
2373
2682
  }
2374
- function Sn(e) {
2375
- return (xn(e) || e === "/" || e === "?") && e !== "&";
2683
+ function In(e) {
2684
+ return (Fn(e) || e === "/" || e === "?") && e !== "&";
2376
2685
  }
2377
- function Cn(e) {
2378
- return xn(e) || e === "/" || e === "?";
2686
+ function Ln(e) {
2687
+ return Fn(e) || e === "/" || e === "?";
2379
2688
  }
2380
- function wn(e) {
2381
- return yn(e) || bn(e) || e === ":";
2689
+ function Rn(e) {
2690
+ return Nn(e) || Pn(e) || e === ":";
2382
2691
  }
2383
- function Tn(e) {
2384
- return yn(e) || bn(e);
2692
+ function zn(e) {
2693
+ return Nn(e) || Pn(e);
2385
2694
  }
2386
- function En(e) {
2695
+ function Bn(e) {
2387
2696
  let t = [], n = e, r = n.indexOf("@");
2388
- r >= 0 && (t.push(B.FALSE), t.push(new U(K(n.slice(0, r)))), n = n.slice(r + 1));
2697
+ r >= 0 && (t.push(R.FALSE), t.push(new G(K(n.slice(0, r)))), n = n.slice(r + 1));
2389
2698
  let i, a = null;
2390
2699
  if (n.startsWith("[")) {
2391
2700
  let e = n.indexOf("]");
@@ -2394,263 +2703,272 @@ function En(e) {
2394
2703
  let r = n.slice(e + 1);
2395
2704
  if (r.startsWith(":")) a = r.slice(1);
2396
2705
  else if (r.length > 0) throw SyntaxError("cri: unexpected characters after ']' in authority");
2397
- t.push(new F(qt(i)));
2706
+ t.push(new N(sn(i)));
2398
2707
  } else {
2399
2708
  let e = n.lastIndexOf(":");
2400
- 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 F(Kt(i)));
2401
- else for (let e of i.toLowerCase().split(".")) t.push(new U(e));
2709
+ 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 N(on(i)));
2710
+ else for (let e of i.toLowerCase().split(".")) t.push(new G(e));
2402
2711
  }
2403
2712
  if (a !== null && a !== "") {
2404
2713
  if (!/^\d+$/.test(a)) throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);
2405
2714
  let e = parseInt(a, 10);
2406
2715
  if (e > 65535) throw SyntaxError(`cri: port ${e} out of range`);
2407
- t.push(new j(BigInt(e)));
2716
+ t.push(new k(BigInt(e)));
2408
2717
  }
2409
- return new R(t);
2718
+ return new I(t);
2410
2719
  }
2411
- function Dn(e) {
2720
+ function Vn(e) {
2412
2721
  let t = e.items, n = 0, r = "";
2413
- if (n < t.length && t[n] instanceof B && t[n].value === 20) {
2722
+ if (n < t.length && t[n] instanceof R && t[n].value === 20) {
2414
2723
  n++;
2415
2724
  let e = t[n++];
2416
- r += q(e.value, wn) + "@";
2725
+ r += q(e.value, Rn) + "@";
2417
2726
  }
2418
2727
  if (n >= t.length) return r;
2419
2728
  let i = t[n];
2420
- if (i instanceof F) {
2729
+ if (i instanceof N) {
2421
2730
  n++;
2422
2731
  let { length: e } = i.value;
2423
- if (e === 4) r += Jt(i.value);
2424
- else if (e === 16) r += "[" + Yt(i.value) + "]";
2732
+ if (e === 4) r += cn(i.value);
2733
+ else if (e === 16) r += "[" + ln(i.value) + "]";
2425
2734
  else throw Error(`cri: unexpected host-ip byte length: ${e}`);
2426
- n < t.length && t[n] instanceof U && (r += `%25${q(t[n++].value, Tn)}`);
2735
+ n < t.length && t[n] instanceof G && (r += `%25${q(t[n++].value, zn)}`);
2427
2736
  } else {
2428
2737
  let e = [];
2429
- for (; n < t.length && t[n] instanceof U;) e.push(q(t[n++].value, Tn));
2738
+ for (; n < t.length && t[n] instanceof G;) e.push(q(t[n++].value, zn));
2430
2739
  r += e.join(".");
2431
2740
  }
2432
- return n < t.length && t[n] instanceof j && (r += ":" + t[n].value.toString()), r;
2741
+ return n < t.length && t[n] instanceof k && (r += ":" + t[n].value.toString()), r;
2433
2742
  }
2434
- function On(e) {
2743
+ function Hn(e) {
2435
2744
  let t = e.slice(2), n = t.indexOf("/"), r, i;
2436
- return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new U(K(e)))) : (r = t, i = []), {
2437
- authority: En(r),
2745
+ return n >= 0 ? (r = t.slice(0, n), i = t.slice(n + 1).split("/").map((e) => new G(K(e)))) : (r = t, i = []), {
2746
+ authority: Bn(r),
2438
2747
  pathSegments: i
2439
2748
  };
2440
2749
  }
2441
- function kn(e) {
2750
+ function Un(e) {
2442
2751
  let t = e, n = null, r = t.indexOf("#");
2443
2752
  r >= 0 && (n = K(t.slice(r + 1)), t = t.slice(0, r));
2444
2753
  let i = null, a = t.indexOf("?");
2445
2754
  if (a >= 0) {
2446
2755
  let e = t.slice(a + 1);
2447
- t = t.slice(0, a), i = e.split("&").map((e) => new U(K(e)));
2756
+ t = t.slice(0, a), i = e.split("&").map((e) => new G(K(e)));
2448
2757
  }
2449
2758
  let o = [], s = /^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);
2450
2759
  if (s) {
2451
- let e = s[1].toLowerCase(), t = s[2], n = mn.get(e);
2452
- if (o.push(n === void 0 ? new U(e) : new M(n)), t.startsWith("//")) {
2453
- let { authority: e, pathSegments: n } = On(t);
2454
- o.push(e, new R(n));
2760
+ let e = s[1].toLowerCase(), t = s[2], n = On.get(e);
2761
+ if (o.push(n === void 0 ? new G(e) : new A(n)), t.startsWith("//")) {
2762
+ let { authority: e, pathSegments: n } = Hn(t);
2763
+ o.push(e, new I(n));
2455
2764
  } else if (t.startsWith("/")) {
2456
- let e = t.slice(1).split("/").map((e) => new U(K(e)));
2457
- o.push(B.NULL, new R(e));
2765
+ let e = t.slice(1).split("/").map((e) => new G(K(e)));
2766
+ o.push(R.NULL, new I(e));
2458
2767
  } else {
2459
- let e = t.split("/").map((e) => new U(K(e)));
2460
- o.push(B.TRUE, new R(e));
2768
+ let e = t.split("/").map((e) => new G(K(e)));
2769
+ o.push(R.TRUE, new I(e));
2461
2770
  }
2462
2771
  } else if (t.startsWith("//")) {
2463
- let { authority: e, pathSegments: n } = On(t);
2464
- o.push(B.FALSE, e, new R(n));
2772
+ let { authority: e, pathSegments: n } = Hn(t);
2773
+ o.push(R.FALSE, e, new I(n));
2465
2774
  } else if (t.startsWith("/")) {
2466
- let e = t.slice(1).split("/").map((e) => new U(K(e)));
2467
- o.push(B.TRUE, new R(e));
2468
- } else if (t === "") o.push(new j(0n));
2775
+ let e = t.slice(1).split("/").map((e) => new G(K(e)));
2776
+ o.push(R.TRUE, new I(e));
2777
+ } else if (t === "") o.push(new k(0n));
2469
2778
  else {
2470
2779
  let n = 1n, r = t, i = !1;
2471
2780
  for (r.startsWith("./") && (i = !0, r = r.slice(2)); r.startsWith("../");) n++, r = r.slice(3);
2472
2781
  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)}`);
2473
- let a = r === "" ? [] : r.split("/").map((e) => new U(K(e)));
2474
- o.push(new j(n), new R(a));
2782
+ let a = r === "" ? [] : r.split("/").map((e) => new G(K(e)));
2783
+ o.push(new k(n), new I(a));
2475
2784
  }
2476
- if (i !== null && o.push(new R(i)), n !== null && (i === null && o.push(B.NULL), o.push(new U(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
2785
+ if (i !== null && o.push(new I(i)), n !== null && (i === null && o.push(R.NULL), o.push(new G(n))), n !== null && i === null && o.splice(o.length - 2, 1), i === null && n === null) {
2477
2786
  let e = o[o.length - 1];
2478
- e instanceof R && e.items.length === 0 && o.pop();
2787
+ e instanceof I && e.items.length === 0 && o.pop();
2479
2788
  }
2480
- return o.length === 1 && o[0] instanceof j && o[0].value === 0n ? [] : o;
2789
+ return o.length === 1 && o[0] instanceof k && o[0].value === 0n ? [] : o;
2481
2790
  }
2482
- function An(e, t) {
2791
+ function Wn(e, t) {
2483
2792
  let n = t, r = "";
2484
2793
  if (n < e.length) {
2485
2794
  let t = e[n];
2486
- if (t instanceof R) {
2795
+ if (t instanceof I) {
2487
2796
  if (n++, t.items.length > 0) {
2488
2797
  let e = t.items.map((e) => {
2489
- if (!(e instanceof U)) throw Error("cri: query item must be a text string");
2490
- return q(e.value, Sn);
2798
+ if (!(e instanceof G)) throw Error("cri: query item must be a text string");
2799
+ return q(e.value, In);
2491
2800
  });
2492
2801
  r += "?" + e.join("&");
2493
2802
  }
2494
- } else t instanceof B && t.value === 22 && n++;
2803
+ } else t instanceof R && t.value === 22 && n++;
2495
2804
  }
2496
- return n < e.length && e[n] instanceof U && (r += "#" + q(e[n].value, Cn)), r;
2805
+ return n < e.length && e[n] instanceof G && (r += "#" + q(e[n].value, Ln)), r;
2497
2806
  }
2498
- function jn(e) {
2807
+ function Gn(e) {
2499
2808
  return e.items.map((e) => {
2500
- if (!(e instanceof U)) throw Error("cri: path segment must be a text string");
2501
- return q(e.value, xn);
2809
+ if (!(e instanceof G)) throw Error("cri: path segment must be a text string");
2810
+ return q(e.value, Fn);
2502
2811
  });
2503
2812
  }
2504
- function Mn(e) {
2813
+ function Kn(e) {
2505
2814
  if (e.length === 0) return "";
2506
2815
  let t = 0, n = e[t++];
2507
- if (n instanceof M || n instanceof U) {
2816
+ if (n instanceof A || n instanceof G) {
2508
2817
  let r;
2509
- if (n instanceof M) {
2510
- let e = hn.get(n.value);
2818
+ if (n instanceof A) {
2819
+ let e = kn.get(n.value);
2511
2820
  if (e === void 0) throw Error(`cri: unrecognised scheme-id ${n.value}`);
2512
2821
  r = e + ":";
2513
2822
  } else r = n.value + ":";
2514
2823
  if (t >= e.length) return r;
2515
2824
  let i = e[t++], a = "", o = !1;
2516
- if (i instanceof R) a = "//" + Dn(i), o = !0;
2517
- else if (i instanceof B) if (i.value === 22) o = !0;
2825
+ if (i instanceof I) a = "//" + Vn(i), o = !0;
2826
+ else if (i instanceof R) if (i.value === 22) o = !0;
2518
2827
  else if (i.value === 21) o = !1;
2519
2828
  else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);
2520
2829
  else throw Error("cri: unexpected type for authority element");
2521
2830
  let s = "";
2522
- if (t < e.length && e[t] instanceof R) {
2831
+ if (t < e.length && e[t] instanceof I) {
2523
2832
  let n = e[t++];
2524
- n.items.length > 0 && (s = (o ? "/" : "") + jn(n).join("/"));
2833
+ n.items.length > 0 && (s = (o ? "/" : "") + Gn(n).join("/"));
2525
2834
  }
2526
- return r + a + s + An(e, t);
2835
+ return r + a + s + Wn(e, t);
2527
2836
  }
2528
- if (n instanceof B && n.value === 20) {
2529
- if (t >= e.length || !(e[t] instanceof R)) throw Error("cri: network-path reference requires an authority array");
2530
- let n = Dn(e[t++]), r = "";
2531
- if (t < e.length && e[t] instanceof R) {
2837
+ if (n instanceof R && n.value === 20) {
2838
+ if (t >= e.length || !(e[t] instanceof I)) throw Error("cri: network-path reference requires an authority array");
2839
+ let n = Vn(e[t++]), r = "";
2840
+ if (t < e.length && e[t] instanceof I) {
2532
2841
  let n = e[t++];
2533
- n.items.length > 0 && (r = "/" + jn(n).join("/"));
2842
+ n.items.length > 0 && (r = "/" + Gn(n).join("/"));
2534
2843
  }
2535
- return "//" + n + r + An(e, t);
2844
+ return "//" + n + r + Wn(e, t);
2536
2845
  }
2537
- if (n instanceof B && n.value === 21) {
2846
+ if (n instanceof R && n.value === 21) {
2538
2847
  let n = "/";
2539
- if (t < e.length && e[t] instanceof R) {
2848
+ if (t < e.length && e[t] instanceof I) {
2540
2849
  let r = e[t++];
2541
- n = "/" + jn(r).join("/");
2850
+ n = "/" + Gn(r).join("/");
2542
2851
  }
2543
- return n + An(e, t);
2852
+ return n + Wn(e, t);
2544
2853
  }
2545
- if (n instanceof j) {
2854
+ if (n instanceof k) {
2546
2855
  let r = n.value;
2547
- if (r === 0n) return An(e, t);
2856
+ if (r === 0n) return Wn(e, t);
2548
2857
  let i = r === 1n ? "" : "../".repeat(Number(r) - 1), a;
2549
- if (t < e.length && e[t] instanceof R) {
2858
+ if (t < e.length && e[t] instanceof I) {
2550
2859
  let n = e[t++];
2551
2860
  if (n.items.length > 0) {
2552
- let e = jn(n);
2861
+ let e = Gn(n);
2553
2862
  a = (r === 1n && e[0].includes(":") ? "./" : i) + e.join("/");
2554
2863
  } else a = i === "" ? "./" : i;
2555
2864
  } else a = i === "" ? "./" : i;
2556
- return a + An(e, t);
2865
+ return a + Wn(e, t);
2557
2866
  }
2558
2867
  throw Error("cri: unrecognised first element type in CRI array");
2559
2868
  }
2560
- var Nn = class extends R {
2869
+ var qn = class extends I {
2561
2870
  _toCDN(e, t) {
2562
2871
  if (e?.appStrings === !1) return super._toCDN(e, t);
2872
+ let n = a(e, this.encodingWidth, () => p(BigInt(this.items.length)));
2873
+ if (_(e, this.appSeqSource, void 0, this.appSeqSourceFeatures) === "adjusted") return m(this.appSeqSource, n, e, this.appSeqInnerEnd, this.appSeqComments);
2563
2874
  try {
2564
- let t = w(e, this.encodingWidth, () => C(BigInt(this.items.length)));
2565
- return `${dn}'${Mn(this.items)}'${t}`;
2875
+ return `${Tn}'${Kn(this.items)}'${n}`;
2566
2876
  } catch {
2567
2877
  return super._toCDN(e, t);
2568
2878
  }
2569
2879
  }
2570
- }, Pn = class extends P {
2880
+ }, Jn = class extends M {
2571
2881
  constructor(e) {
2572
- super(pn, e);
2882
+ super(Dn, e);
2573
2883
  }
2574
2884
  _toCDN(e, t) {
2575
2885
  if (e?.appStrings === !1) return super._toCDN(e, t);
2886
+ let n = _(e, this.appSeqSource, this.ednSource, this.appSeqSourceFeatures, this.appSeqEncodingEditsComplete);
2887
+ if (n === "verbatim") return this.appSeqSource;
2888
+ if (n === "source") return g(this.appSeqSource, e, this.appSeqComments, this.appSeqEncodingEdits);
2889
+ if (n === "structural") return super._toCDN({
2890
+ ...e,
2891
+ appStrings: !1
2892
+ }, t);
2576
2893
  try {
2577
- let n = this.content;
2578
- if (n.encodingWidth !== void 0) return super._toCDN(e, t);
2579
- let r = w(e, this.encodingWidth, () => C(pn));
2580
- return `${fn}'${Mn(n.items)}'${r}`;
2894
+ let r = this.content;
2895
+ if (r.encodingWidth !== void 0) return super._toCDN(e, t);
2896
+ let i = a(e, this.encodingWidth, () => p(Dn));
2897
+ return n === "adjusted" ? m(this.appSeqSource, i, e, this.appSeqInnerEnd, this.appSeqComments) : `${En}'${Kn(r.items)}'${i}`;
2581
2898
  } catch {
2582
2899
  return super._toCDN(e, t);
2583
2900
  }
2584
2901
  }
2585
2902
  };
2586
- function Fn(e) {
2903
+ function Yn(e) {
2587
2904
  if (e.length !== 1) throw SyntaxError("cri<<...>>: expected exactly one item");
2588
2905
  let t = e[0];
2589
- if (t instanceof U) return t.value;
2590
- if (t instanceof F) return _n.decode(t.value);
2906
+ if (t instanceof G) return t.value;
2907
+ if (t instanceof N) return jn.decode(t.value);
2591
2908
  throw SyntaxError("cri<<...>>: expected a text string or byte string");
2592
2909
  }
2593
- function In(e, t) {
2594
- let n = new Nn(kn(t));
2595
- return e === fn ? new Pn(n) : n;
2910
+ function Xn(e, t) {
2911
+ let n = new qn(Un(t));
2912
+ return e === En ? new Jn(n) : n;
2596
2913
  }
2597
- var Ln = {
2598
- appStringPrefixes: [dn, fn],
2599
- tagNumbers: [pn],
2914
+ var Zn = {
2915
+ appStringPrefixes: [Tn, En],
2916
+ tagNumbers: [Dn],
2917
+ preserveAppSeqSource: "optional",
2600
2918
  parseAppString(e, t) {
2601
- return In(e, t);
2919
+ return Xn(e, t);
2602
2920
  },
2603
2921
  parseAppSequence(e, t) {
2604
- return In(e, Fn(t));
2922
+ return Xn(e, Yn(t));
2605
2923
  },
2606
2924
  parseTag(e, t) {
2607
- if (e !== 99n || !(t instanceof R)) return;
2608
- let n = new Nn(t.items, {
2925
+ if (e !== 99n || !(t instanceof I)) return;
2926
+ let n = new qn(t.items, {
2609
2927
  indefiniteLength: t.indefiniteLength,
2610
2928
  encodingWidth: t.encodingWidth
2611
2929
  });
2612
- return n.start = t.start, n.end = t.end, new Pn(n);
2930
+ return n.start = t.start, n.end = t.end, new Jn(n);
2613
2931
  }
2614
- }, Rn = 18446744073709551615n, zn = -18446744073709551616n, Bn = {
2615
- tagNumbers: [qe, Je],
2932
+ }, Qn = 18446744073709551615n, $n = -18446744073709551616n, er = {
2933
+ tagNumbers: [Qe, $e],
2616
2934
  parseTag(e, t) {
2617
- if (t instanceof F) {
2935
+ if (t instanceof N) {
2618
2936
  if (e === 2n) {
2619
- let e = Qe(t.value);
2620
- return e > Rn ? new $e(e) : void 0;
2937
+ let e = rt(t.value);
2938
+ return e > Qn ? new it(e) : void 0;
2621
2939
  }
2622
2940
  if (e === 3n) {
2623
- let e = -1n - Qe(t.value);
2624
- return e < zn ? new et(e) : void 0;
2941
+ let e = -1n - rt(t.value);
2942
+ return e < $n ? new at(e) : void 0;
2625
2943
  }
2626
2944
  }
2627
2945
  }
2628
2946
  };
2629
2947
  //#endregion
2630
2948
  //#region src/cbor/decoder.ts
2631
- function Vn(e, t) {
2949
+ function tr(e, t) {
2632
2950
  if (e === 24 && t <= 23n) return 0;
2633
2951
  if (e === 25 && t <= 255n) return 1;
2634
2952
  if (e === 26 && t <= 65535n) return 2;
2635
2953
  if (e === 27 && t <= 4294967295n) return 3;
2636
2954
  }
2637
- function Hn(e, t) {
2955
+ function nr(e, t) {
2638
2956
  if (e === 24 && t <= 23) return 0;
2639
2957
  if (e === 25 && t <= 255) return 1;
2640
2958
  if (e === 26 && t <= 65535) return 2;
2641
2959
  if (e === 27 && t <= 4294967295) return 3;
2642
2960
  }
2643
- var Un = new TextDecoder("utf-8", {
2961
+ var rr = new TextDecoder("utf-8", {
2644
2962
  fatal: !0,
2645
2963
  ignoreBOM: !0
2646
- }), Wn = new TextDecoder("utf-8", {
2964
+ }), ir = new TextDecoder("utf-8", {
2647
2965
  fatal: !1,
2648
2966
  ignoreBOM: !0
2649
2967
  });
2650
2968
  function J(e) {
2651
2969
  throw Error(`CBOR decode error: ${e}`);
2652
2970
  }
2653
- function Gn(e, t, n) {
2971
+ function ar(e, t, n) {
2654
2972
  let r = {
2655
2973
  message: e,
2656
2974
  offset: t
@@ -2658,63 +2976,63 @@ function Gn(e, t, n) {
2658
2976
  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}`);
2659
2977
  return r;
2660
2978
  }
2661
- function Y(e, t) {
2979
+ function or(e, t) {
2662
2980
  e.warnings ??= [], e.warnings.push(t);
2663
2981
  }
2664
- function Kn(e) {
2665
- if (e instanceof j) return ["u", String(e.value)];
2666
- if (e instanceof M) return ["n", String(e.value)];
2667
- if (e instanceof U) return ["t", e.value];
2668
- if (e instanceof L) return ["t", e.chunks.map((e) => e.value).join("")];
2669
- if (e instanceof F) return ["b", i(e.value)];
2670
- if (e instanceof I) {
2982
+ function Y(e) {
2983
+ if (e instanceof k) return ["u", String(e.value)];
2984
+ if (e instanceof A) return ["n", String(e.value)];
2985
+ if (e instanceof G) return ["t", e.value];
2986
+ if (e instanceof F) return ["t", e.chunks.map((e) => e.value).join("")];
2987
+ if (e instanceof N) return ["b", y(e.value)];
2988
+ if (e instanceof P) {
2671
2989
  let t = "";
2672
- for (let n of e.chunks) t += i(n.value);
2990
+ for (let n of e.chunks) t += y(n.value);
2673
2991
  return ["b", t];
2674
2992
  }
2675
- if (e instanceof N) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
2676
- if (e instanceof B) return ["s", e.value];
2677
- if (e instanceof R) return ["A", e.items.map(Kn)];
2678
- if (e instanceof z) {
2679
- let t = e.entries.map(([e, t]) => [Kn(e), Kn(t)]);
2993
+ if (e instanceof j) return isNaN(e.value) ? ["f", "NaN"] : Object.is(e.value, -0) ? ["f", "-0"] : ["f", String(e.value)];
2994
+ if (e instanceof R) return ["s", e.value];
2995
+ if (e instanceof I) return ["A", e.items.map(Y)];
2996
+ if (e instanceof L) {
2997
+ let t = e.entries.map(([e, t]) => [Y(e), Y(t)]);
2680
2998
  if (t.length <= 1) return ["M", t];
2681
2999
  let n = t.map((e) => [JSON.stringify(e[0]), e]);
2682
3000
  return n.sort((e, t) => e[0] < t[0] ? -1 : +(e[0] > t[0])), ["M", n.map((e) => e[1])];
2683
3001
  }
2684
- return e instanceof P ? [
3002
+ return e instanceof M ? [
2685
3003
  "G",
2686
3004
  String(e.tag),
2687
- Kn(e.content)
2688
- ] : ["c", i(e.toCBOR())];
2689
- }
2690
- function qn(e) {
2691
- if (e instanceof j) return "u" + e.value;
2692
- if (e instanceof M) return "n" + e.value;
2693
- if (e instanceof U) return "t" + e.value;
2694
- if (e instanceof L) {
3005
+ Y(e.content)
3006
+ ] : ["c", y(e.toCBOR())];
3007
+ }
3008
+ function sr(e) {
3009
+ if (e instanceof k) return "u" + e.value;
3010
+ if (e instanceof A) return "n" + e.value;
3011
+ if (e instanceof G) return "t" + e.value;
3012
+ if (e instanceof F) {
2695
3013
  let t = "t";
2696
3014
  for (let n of e.chunks) t += n.value;
2697
3015
  return t;
2698
3016
  }
2699
- if (e instanceof F) return "b" + i(e.value);
2700
- if (e instanceof I) {
3017
+ if (e instanceof N) return "b" + y(e.value);
3018
+ if (e instanceof P) {
2701
3019
  let t = "b";
2702
- for (let n of e.chunks) t += i(n.value);
3020
+ for (let n of e.chunks) t += y(n.value);
2703
3021
  return t;
2704
3022
  }
2705
- return e instanceof N ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof B ? "s" + e.value : JSON.stringify(Kn(e));
3023
+ return e instanceof j ? isNaN(e.value) ? "fNaN" : Object.is(e.value, -0) ? "f-0" : "f" + e.value : e instanceof R ? "s" + e.value : JSON.stringify(Y(e));
2706
3024
  }
2707
- var Jn = Array.from({ length: 24 }, (e, t) => BigInt(t)), Yn;
2708
- function Xn(e) {
2709
- return e === void 0 ? Yn ??= Z(void 0).filter((e) => e.parseTag !== void 0) : Z(e).filter((e) => e.parseTag !== void 0);
3025
+ var cr = Array.from({ length: 24 }, (e, t) => BigInt(t)), lr;
3026
+ function ur(e) {
3027
+ return e === void 0 ? lr ??= Z(void 0).filter((e) => e.parseTag !== void 0) : Z(e).filter((e) => e.parseTag !== void 0);
2710
3028
  }
2711
- function Zn(e, t) {
3029
+ function dr(e, t) {
2712
3030
  for (let n = 0; n < t; n++) if (e[n] >= 128) return;
2713
3031
  return String.fromCharCode.apply(null, e);
2714
3032
  }
2715
- function Qn(e, t, n) {
3033
+ function fr(e, t, n) {
2716
3034
  if (n <= 23) return {
2717
- value: Jn[n],
3035
+ value: cr[n],
2718
3036
  nextOffset: t
2719
3037
  };
2720
3038
  switch (n) {
@@ -2737,7 +3055,7 @@ function Qn(e, t, n) {
2737
3055
  default: J(`reserved additional info value: ${n}`);
2738
3056
  }
2739
3057
  }
2740
- function $n(e, t, n) {
3058
+ function pr(e, t, n) {
2741
3059
  if (n <= 23) return {
2742
3060
  value: n,
2743
3061
  nextOffset: t
@@ -2766,7 +3084,7 @@ function $n(e, t, n) {
2766
3084
  default: J(`reserved additional info value: ${n}`);
2767
3085
  }
2768
3086
  }
2769
- function er(e, t, n, r, i, a) {
3087
+ function mr(e, t, n, r, i, a) {
2770
3088
  let o = [], s = t;
2771
3089
  for (;;) {
2772
3090
  if (s >= e.byteLength && J(`unexpected end of indefinite ${i}`), e.getUint8(s) === 255) {
@@ -2781,68 +3099,68 @@ function er(e, t, n, r, i, a) {
2781
3099
  nextOffset: s
2782
3100
  };
2783
3101
  }
2784
- function tr(e, t, n, r) {
2785
- let i = qn(e);
2786
- t.has(i) && n.push(Gn(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
3102
+ function hr(e, t, n, r) {
3103
+ let i = sr(e);
3104
+ t.has(i) && n.push(ar(`duplicate map key at offset ${e.start}`, e.start, r)), t.add(i);
2787
3105
  }
2788
3106
  function X(e, t, n, r) {
2789
- let i = t, a = rr(e, t, n, r);
3107
+ let i = t, a = _r(e, t, n, r);
2790
3108
  return a.value.start = i, a.value.end = a.nextOffset, a;
2791
3109
  }
2792
- function nr(e, t, n) {
3110
+ function gr(e, t, n) {
2793
3111
  return new Uint8Array(e.buffer, e.byteOffset + t, n).slice();
2794
3112
  }
2795
- function rr(e, t, n, r) {
3113
+ function _r(e, t, n, r) {
2796
3114
  t >= e.byteLength && J("unexpected end of input");
2797
3115
  let i = e.getUint8(t++), a = i >> 5, o = i & 31;
2798
3116
  switch (a) {
2799
3117
  case 0: {
2800
- let { value: n, nextOffset: r } = Qn(e, t, o);
3118
+ let { value: n, nextOffset: r } = fr(e, t, o);
2801
3119
  return {
2802
- value: new j(n, { encodingWidth: Vn(o, n) }),
3120
+ value: new k(n, { encodingWidth: tr(o, n) }),
2803
3121
  nextOffset: r
2804
3122
  };
2805
3123
  }
2806
3124
  case 1: {
2807
- let { value: n, nextOffset: r } = Qn(e, t, o), i = Vn(o, n);
3125
+ let { value: n, nextOffset: r } = fr(e, t, o), i = tr(o, n);
2808
3126
  return {
2809
- value: new M(-1n - n, { encodingWidth: i }),
3127
+ value: new A(-1n - n, { encodingWidth: i }),
2810
3128
  nextOffset: r
2811
3129
  };
2812
3130
  }
2813
3131
  case 2: {
2814
3132
  if (o === 31) {
2815
- let { chunks: i, nextOffset: a } = er(e, t, n, r, "byte string", (e) => e instanceof F);
3133
+ let { chunks: i, nextOffset: a } = mr(e, t, n, r, "byte string", (e) => e instanceof N);
2816
3134
  return {
2817
- value: new I(i),
3135
+ value: new P(i),
2818
3136
  nextOffset: a
2819
3137
  };
2820
3138
  }
2821
- let { value: i, nextOffset: a } = $n(e, t, o), s = Hn(o, i);
3139
+ let { value: i, nextOffset: a } = pr(e, t, o), s = nr(o, i);
2822
3140
  return a + i > e.byteLength && J("byte string extends beyond input"), {
2823
- value: new F(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
3141
+ value: new N(new Uint8Array(e.buffer, e.byteOffset + a, i).slice(), { encodingWidth: s }),
2824
3142
  nextOffset: a + i
2825
3143
  };
2826
3144
  }
2827
3145
  case 3: {
2828
3146
  if (o === 31) {
2829
- let { chunks: i, nextOffset: a } = er(e, t, n, r, "text string", (e) => e instanceof U);
3147
+ let { chunks: i, nextOffset: a } = mr(e, t, n, r, "text string", (e) => e instanceof G);
2830
3148
  return {
2831
- value: new L(i),
3149
+ value: new F(i),
2832
3150
  nextOffset: a
2833
3151
  };
2834
3152
  }
2835
- let { value: i, nextOffset: a } = $n(e, t, o), s = Hn(o, i);
3153
+ let { value: i, nextOffset: a } = pr(e, t, o), s = nr(o, i);
2836
3154
  a + i > e.byteLength && J("text string extends beyond input");
2837
- let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? Zn(c, i) : void 0;
3155
+ let c = new Uint8Array(e.buffer, e.byteOffset + a, i), l, u, d = i < 64 ? dr(c, i) : void 0;
2838
3156
  if (d !== void 0) l = d;
2839
3157
  else try {
2840
- l = Un.decode(c);
3158
+ l = rr.decode(c);
2841
3159
  } catch {
2842
- u = Gn("invalid UTF-8 sequence in text string", a, n), l = Wn.decode(c);
3160
+ u = ar("invalid UTF-8 sequence in text string", a, n), l = ir.decode(c);
2843
3161
  }
2844
- let f = new U(l, { encodingWidth: s });
2845
- return u && Y(f, u), {
3162
+ let f = new G(l, { encodingWidth: s });
3163
+ return u && or(f, u), {
2846
3164
  value: f,
2847
3165
  nextOffset: a + i
2848
3166
  };
@@ -2859,17 +3177,17 @@ function rr(e, t, n, r) {
2859
3177
  i.push(t.value), a = t.nextOffset;
2860
3178
  }
2861
3179
  return {
2862
- value: new R(i, { indefiniteLength: !0 }),
3180
+ value: new I(i, { indefiniteLength: !0 }),
2863
3181
  nextOffset: a
2864
3182
  };
2865
3183
  }
2866
- let { value: i, nextOffset: a } = $n(e, t, o), s = Hn(o, i), c = [], l = a;
3184
+ let { value: i, nextOffset: a } = pr(e, t, o), s = nr(o, i), c = [], l = a;
2867
3185
  for (let t = 0; t < i; t++) {
2868
3186
  let t = X(e, l, n, r);
2869
3187
  c.push(t.value), l = t.nextOffset;
2870
3188
  }
2871
3189
  return {
2872
- value: new R(c, { encodingWidth: s }),
3190
+ value: new I(c, { encodingWidth: s }),
2873
3191
  nextOffset: l
2874
3192
  };
2875
3193
  }
@@ -2882,26 +3200,26 @@ function rr(e, t, n, r) {
2882
3200
  break;
2883
3201
  }
2884
3202
  let t = X(e, s, n, r);
2885
- tr(t.value, a, o, n), s = t.nextOffset;
3203
+ hr(t.value, a, o, n), s = t.nextOffset;
2886
3204
  let c = X(e, s, n, r);
2887
3205
  s = c.nextOffset, i.push([t.value, c.value]);
2888
3206
  }
2889
- let c = new z(i, { indefiniteLength: !0 });
2890
- for (let e of o) Y(c, e);
3207
+ let c = new L(i, { indefiniteLength: !0 });
3208
+ for (let e of o) or(c, e);
2891
3209
  return {
2892
3210
  value: c,
2893
3211
  nextOffset: s
2894
3212
  };
2895
3213
  }
2896
- let { value: i, nextOffset: a } = $n(e, t, o), s = Hn(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
3214
+ let { value: i, nextOffset: a } = pr(e, t, o), s = nr(o, i), c = [], l = /* @__PURE__ */ new Set(), u = [], d = a;
2897
3215
  for (let t = 0; t < i; t++) {
2898
3216
  let t = X(e, d, n, r);
2899
- tr(t.value, l, u, n), d = t.nextOffset;
3217
+ hr(t.value, l, u, n), d = t.nextOffset;
2900
3218
  let i = X(e, d, n, r);
2901
3219
  d = i.nextOffset, c.push([t.value, i.value]);
2902
3220
  }
2903
- let f = new z(c, { encodingWidth: s });
2904
- for (let e of u) Y(f, e);
3221
+ let f = new L(c, { encodingWidth: s });
3222
+ for (let e of u) or(f, e);
2905
3223
  return {
2906
3224
  value: f,
2907
3225
  nextOffset: d
@@ -2909,62 +3227,62 @@ function rr(e, t, n, r) {
2909
3227
  }
2910
3228
  case 6: {
2911
3229
  o === 31 && J("tags cannot use indefinite-length encoding");
2912
- let { value: i, nextOffset: a } = Qn(e, t, o), s = Vn(o, i), c = X(e, a, n, r);
3230
+ let { value: i, nextOffset: a } = fr(e, t, o), s = tr(o, i), c = X(e, a, n, r);
2913
3231
  for (let e of r) {
2914
3232
  let t = e.parseTag(i, c.value, n);
2915
- if (t !== void 0) return t instanceof P && s !== void 0 && (t.encodingWidth = s), {
3233
+ if (t !== void 0) return t instanceof M && s !== void 0 && (t.encodingWidth = s), {
2916
3234
  value: t,
2917
3235
  nextOffset: c.nextOffset
2918
3236
  };
2919
3237
  }
2920
3238
  return {
2921
- value: new P(i, c.value, { encodingWidth: s }),
3239
+ value: new M(i, c.value, { encodingWidth: s }),
2922
3240
  nextOffset: c.nextOffset
2923
3241
  };
2924
3242
  }
2925
3243
  case 7:
2926
3244
  if (o <= 19) return {
2927
- value: new B(o),
3245
+ value: new R(o),
2928
3246
  nextOffset: t
2929
3247
  };
2930
3248
  if (o === 20) return {
2931
- value: new B(20),
3249
+ value: new R(20),
2932
3250
  nextOffset: t
2933
3251
  };
2934
3252
  if (o === 21) return {
2935
- value: new B(21),
3253
+ value: new R(21),
2936
3254
  nextOffset: t
2937
3255
  };
2938
3256
  if (o === 22) return {
2939
- value: new B(22),
3257
+ value: new R(22),
2940
3258
  nextOffset: t
2941
3259
  };
2942
3260
  if (o === 23) return {
2943
- value: new B(23),
3261
+ value: new R(23),
2944
3262
  nextOffset: t
2945
3263
  };
2946
3264
  if (o === 24) {
2947
3265
  t + 1 > e.byteLength && J("unexpected end of input");
2948
3266
  let r = e.getUint8(t);
2949
3267
  if (r < 32) {
2950
- let e = Gn(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new B(r);
2951
- return Y(i, e), {
3268
+ let e = ar(`simple value ${r} must be encoded in initial byte (0–31 reserved for extended encoding)`, t - 1, n), i = new R(r);
3269
+ return or(i, e), {
2952
3270
  value: i,
2953
3271
  nextOffset: t + 1
2954
3272
  };
2955
3273
  }
2956
3274
  return {
2957
- value: new B(r),
3275
+ value: new R(r),
2958
3276
  nextOffset: t + 1
2959
3277
  };
2960
3278
  }
2961
3279
  if (o === 25) {
2962
3280
  t + 2 > e.byteLength && J("unexpected end of input");
2963
- let n = E(e.getUint16(t, !1));
3281
+ let n = C(e.getUint16(t, !1));
2964
3282
  return {
2965
- value: new N(n, {
3283
+ value: new j(n, {
2966
3284
  precision: "half",
2967
- rawBits: Number.isNaN(n) ? nr(e, t, 2) : void 0
3285
+ rawBits: Number.isNaN(n) ? gr(e, t, 2) : void 0
2968
3286
  }),
2969
3287
  nextOffset: t + 2
2970
3288
  };
@@ -2973,9 +3291,9 @@ function rr(e, t, n, r) {
2973
3291
  t + 4 > e.byteLength && J("unexpected end of input");
2974
3292
  let n = e.getFloat32(t, !1);
2975
3293
  return {
2976
- value: new N(n, {
3294
+ value: new j(n, {
2977
3295
  precision: "single",
2978
- rawBits: Number.isNaN(n) ? nr(e, t, 4) : void 0
3296
+ rawBits: Number.isNaN(n) ? gr(e, t, 4) : void 0
2979
3297
  }),
2980
3298
  nextOffset: t + 4
2981
3299
  };
@@ -2984,9 +3302,9 @@ function rr(e, t, n, r) {
2984
3302
  t + 8 > e.byteLength && J("unexpected end of input");
2985
3303
  let n = e.getFloat64(t, !1);
2986
3304
  return {
2987
- value: new N(n, {
3305
+ value: new j(n, {
2988
3306
  precision: "double",
2989
- rawBits: Number.isNaN(n) ? nr(e, t, 8) : void 0
3307
+ rawBits: Number.isNaN(n) ? gr(e, t, 8) : void 0
2990
3308
  }),
2991
3309
  nextOffset: t + 8
2992
3310
  };
@@ -2995,17 +3313,17 @@ function rr(e, t, n, r) {
2995
3313
  }
2996
3314
  return J(`unknown major type: ${a}`);
2997
3315
  }
2998
- function ir(e) {
3316
+ function vr(e) {
2999
3317
  if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new Uint8Array(e);
3000
3318
  if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
3001
3319
  throw TypeError("expected ArrayBufferView or ArrayBufferLike");
3002
3320
  }
3003
- function ar(e, t) {
3004
- let n = ir(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
3321
+ function yr(e, t) {
3322
+ let n = vr(e), r = new DataView(n.buffer, n.byteOffset, n.byteLength), i = t?.offset ?? 0;
3005
3323
  if (!Number.isInteger(i) || i < 0 || i > r.byteLength) throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);
3006
- let a = Xn(t?.builtinExtensions), o = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...a] : a, { value: s, nextOffset: c } = X(r, i, t, o);
3324
+ let a = ur(t?.builtinExtensions), o = t?.extensions?.length ? [...t.extensions.filter((e) => e.parseTag !== void 0), ...a] : a, { value: s, nextOffset: c } = X(r, i, t, o);
3007
3325
  if (!t?.allowTrailing && c !== r.byteLength) {
3008
- Y(s, Gn(`${r.byteLength - c} trailing byte(s) after end of CBOR item`, c, t));
3326
+ or(s, ar(`${r.byteLength - c} trailing byte(s) after end of CBOR item`, c, t));
3009
3327
  let e = {
3010
3328
  strict: !1,
3011
3329
  silent: !0
@@ -3016,10 +3334,10 @@ function ar(e, t) {
3016
3334
  }
3017
3335
  //#endregion
3018
3336
  //#region src/extensions/cbordata.ts
3019
- var or = 24n, sr = {
3020
- tagNumbers: [or],
3337
+ var br = 24n, xr = {
3338
+ tagNumbers: [br],
3021
3339
  parseTag(e, t, n) {
3022
- if (e !== 24n || !(t instanceof F)) return;
3340
+ if (e !== 24n || !(t instanceof N)) return;
3023
3341
  let r = (t.end ?? t.value.length) - t.value.length, i = n ? {
3024
3342
  extensions: n.extensions,
3025
3343
  builtinExtensions: n.builtinExtensions,
@@ -3031,7 +3349,7 @@ var or = 24n, sr = {
3031
3349
  silent: n.silent
3032
3350
  } : void 0;
3033
3351
  try {
3034
- return new P(or, new Ve([ar(t.value, i)], { encodingWidth: t.encodingWidth }));
3352
+ return new M(br, new z([yr(t.value, i)], { encodingWidth: t.encodingWidth }));
3035
3353
  } catch (e) {
3036
3354
  if (i?.strict !== !1) throw e;
3037
3355
  let t = `tag 24 content is not valid CBOR: ${e instanceof Error ? e.message : String(e)}`, a = {
@@ -3045,194 +3363,156 @@ var or = 24n, sr = {
3045
3363
  };
3046
3364
  //#endregion
3047
3365
  //#region src/extensions/ellipsis.ts
3048
- function cr(e) {
3049
- return e instanceof V && !(e.content instanceof R);
3366
+ function Sr(e) {
3367
+ return e instanceof V && !(e.content instanceof I);
3050
3368
  }
3051
- function lr(e) {
3369
+ function Cr(e) {
3052
3370
  let t = !1, n = !1, r = !1, i;
3053
3371
  for (let a of e) {
3054
3372
  let e;
3055
- if (cr(a)) e = !0, r = !0;
3056
- else if (a instanceof U) e = !1, t = !0;
3057
- else if (a instanceof F) e = !1, n = !0;
3373
+ if (Sr(a)) e = !0, r = !0;
3374
+ else if (a instanceof G) e = !1, t = !0;
3375
+ else if (a instanceof N) e = !1, n = !0;
3058
3376
  else return !1;
3059
3377
  if (e === i) return !1;
3060
3378
  i = e;
3061
3379
  }
3062
3380
  return r && !(t && n);
3063
3381
  }
3064
- var ur = {
3382
+ var wr = {
3065
3383
  tagNumbers: [Ke],
3066
3384
  parseTag(e, t) {
3067
3385
  if (e === 888n) {
3068
- if (t instanceof B && t.value === 22) return new V();
3069
- if (t instanceof R && lr(t.items)) return new V(t.items);
3386
+ if (t instanceof R && t.value === 22) return new V();
3387
+ if (t instanceof I && Cr(t.items)) return new V(t.items);
3070
3388
  }
3071
3389
  }
3072
- }, dr = new TextEncoder(), fr = new TextDecoder("utf-8", { fatal: !0 }), pr = new TextDecoder("utf-8", { fatal: !1 }), mr = Symbol("ellipsis");
3073
- function hr(e) {
3390
+ }, Tr = new TextEncoder(), Er = new TextDecoder("utf-8", { fatal: !0 }), Dr = new TextDecoder("utf-8", { fatal: !1 }), Or = Symbol("ellipsis");
3391
+ function kr(e) {
3074
3392
  let t = 0;
3075
3393
  for (let n of e) t += n.length;
3076
3394
  let n = new Uint8Array(t), r = 0;
3077
3395
  for (let t of e) n.set(t, r), r += t.length;
3078
3396
  return n;
3079
3397
  }
3080
- function gr(e, t, n) {
3081
- if (t instanceof Ge) {
3082
- gr(e, t.inner, n);
3398
+ function Ar(e, t, n) {
3399
+ if (t instanceof B) {
3400
+ Ar(e, t.inner, n);
3083
3401
  return;
3084
3402
  }
3085
3403
  if (t instanceof V) {
3086
- if (t.content instanceof R) for (let r of t.content.items) gr(e, r, n);
3087
- else n.push(mr);
3404
+ if (t.content instanceof I) for (let r of t.content.items) Ar(e, r, n);
3405
+ else n.push(Or);
3088
3406
  return;
3089
3407
  }
3090
- if (t instanceof U) {
3091
- n.push(dr.encode(t.value));
3408
+ if (t instanceof G) {
3409
+ n.push(Tr.encode(t.value));
3092
3410
  return;
3093
3411
  }
3094
- if (t instanceof F) {
3412
+ if (t instanceof N) {
3095
3413
  n.push(t.value);
3096
3414
  return;
3097
3415
  }
3098
- if (t instanceof L) {
3099
- n.push(dr.encode(t.chunks.map((e) => e.value).join("")));
3416
+ if (t instanceof F) {
3417
+ n.push(Tr.encode(t.chunks.map((e) => e.value).join("")));
3100
3418
  return;
3101
3419
  }
3102
- if (t instanceof I) {
3103
- n.push(hr(t.chunks.map((e) => e.value)));
3420
+ if (t instanceof P) {
3421
+ n.push(kr(t.chunks.map((e) => e.value)));
3104
3422
  return;
3105
3423
  }
3106
3424
  throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings or ellipses`);
3107
3425
  }
3108
- function _r(e, t) {
3426
+ function jr(e, t) {
3109
3427
  try {
3110
- return fr.decode(e);
3428
+ return Er.decode(e);
3111
3429
  } catch {
3112
3430
  let n = "t1 concatenation result is not valid UTF-8";
3113
3431
  if (t) t(n);
3114
3432
  else throw SyntaxError(n);
3115
- return pr.decode(e);
3433
+ return Dr.decode(e);
3116
3434
  }
3117
3435
  }
3118
- function vr(e, t, n) {
3436
+ function Mr(e, t, n) {
3119
3437
  let r = [];
3120
- for (let n of t) gr(e, n, r);
3438
+ for (let n of t) Ar(e, n, r);
3121
3439
  let i = e === "t1", a = [], o = !1, s = [], c = () => {
3122
3440
  if (s.length === 0) return;
3123
- let e = hr(s);
3124
- s.length = 0, e.length !== 0 && a.push(i ? new U(_r(e, n)) : new F(e));
3441
+ let e = kr(s);
3442
+ s.length = 0, e.length !== 0 && a.push(i ? new G(jr(e, n)) : new N(e));
3125
3443
  };
3126
- for (let e of r) e === mr ? (c(), a[a.length - 1] instanceof V || (a.push(new V()), o = !0)) : s.push(e);
3444
+ for (let e of r) e === Or ? (c(), a[a.length - 1] instanceof V || (a.push(new V()), o = !0)) : s.push(e);
3127
3445
  if (!o) {
3128
- let e = hr(s);
3129
- return i ? new U(_r(e, n)) : new F(e);
3446
+ let e = kr(s);
3447
+ return i ? new G(jr(e, n)) : new N(e);
3130
3448
  }
3131
3449
  return c(), a.length === 1 ? new V() : new V(a);
3132
3450
  }
3133
- function yr(e) {
3451
+ function Nr(e) {
3134
3452
  return {
3135
3453
  appStringPrefixes: [e],
3136
3454
  preserveAppSeqSource: !0,
3137
3455
  parseAppString(t, n, r) {
3138
- return vr(e, [new U(n)], r);
3456
+ return Mr(e, [new G(n)], r);
3139
3457
  },
3140
3458
  parseAppSequence(t, n, r) {
3141
- return vr(e, n, r);
3459
+ return Mr(e, n, r);
3142
3460
  }
3143
3461
  };
3144
3462
  }
3145
- var br = yr("t1"), xr = yr("b1"), Sr = new TextEncoder(), Cr = new TextDecoder("utf-8", { fatal: !0 }), wr = new TextDecoder("utf-8", { fatal: !1 });
3146
- function Tr(e) {
3463
+ var Pr = Nr("t1"), Fr = Nr("b1"), Ir = new TextEncoder(), Lr = new TextDecoder("utf-8", { fatal: !0 }), Rr = new TextDecoder("utf-8", { fatal: !1 });
3464
+ function zr(e) {
3147
3465
  let t = 0;
3148
3466
  for (let n of e) t += n.length;
3149
3467
  let n = new Uint8Array(t), r = 0;
3150
3468
  for (let t of e) n.set(t, r), r += t.length;
3151
3469
  return n;
3152
3470
  }
3153
- function Er(e, t, n) {
3471
+ function Br(e, t, n) {
3154
3472
  let r = e === "ilts", i = [], a = [];
3155
3473
  for (let o of t) {
3156
- if (o instanceof Ge && (o = o.inner), o instanceof V) throw SyntaxError(`${e}<<...>> cannot contain ellipses; there is no way to include an elision in an indefinite-length string`);
3474
+ if (o instanceof B && (o = o.inner), o instanceof V) throw SyntaxError(`${e}<<...>> cannot contain ellipses; there is no way to include an elision in an indefinite-length string`);
3157
3475
  let t, s, c;
3158
- if (o instanceof U) t = o.value, c = o.encodingWidth;
3159
- else if (o instanceof F) s = o.value, c = o.encodingWidth;
3160
- else if (o instanceof L) t = o.chunks.map((e) => e.value).join("");
3161
- else if (o instanceof I) s = Tr(o.chunks.map((e) => e.value));
3476
+ if (o instanceof G) t = o.value, c = o.encodingWidth;
3477
+ else if (o instanceof N) s = o.value, c = o.encodingWidth;
3478
+ else if (o instanceof F) t = o.chunks.map((e) => e.value).join("");
3479
+ else if (o instanceof P) s = zr(o.chunks.map((e) => e.value));
3162
3480
  else throw SyntaxError(`${e}<<...>> arguments must be (text or byte) strings`);
3163
3481
  if (r) {
3164
3482
  let e;
3165
3483
  if (t !== void 0) e = t;
3166
3484
  else try {
3167
- e = Cr.decode(s);
3485
+ e = Lr.decode(s);
3168
3486
  } catch {
3169
3487
  let t = "ilts chunk is not valid UTF-8";
3170
3488
  if (n) n(t);
3171
3489
  else throw SyntaxError(t);
3172
- e = wr.decode(s);
3490
+ e = Rr.decode(s);
3173
3491
  }
3174
- a.push(new U(e, c === void 0 ? void 0 : { encodingWidth: c }));
3492
+ a.push(new G(e, c === void 0 ? void 0 : { encodingWidth: c }));
3175
3493
  } else {
3176
- let e = s ?? Sr.encode(t);
3177
- i.push(new F(e, c === void 0 ? void 0 : { encodingWidth: c }));
3494
+ let e = s ?? Ir.encode(t);
3495
+ i.push(new N(e, c === void 0 ? void 0 : { encodingWidth: c }));
3178
3496
  }
3179
3497
  }
3180
- return r ? new L(a) : new I(i);
3498
+ return r ? new F(a) : new P(i);
3181
3499
  }
3182
- function Dr(e) {
3500
+ function Vr(e) {
3183
3501
  return {
3184
3502
  appStringPrefixes: [e],
3185
3503
  preserveAppSeqSource: !0,
3186
3504
  parseAppString(t, n, r) {
3187
- return new Ge(Er(e, [new U(n)], r), `${e}${ve(n)}`);
3505
+ return new B(Br(e, [new G(n)], r), `${e}${c(n)}`);
3188
3506
  },
3189
3507
  parseAppSequence(t, n, r) {
3190
- return Er(e, n, r);
3508
+ return Br(e, n, r);
3191
3509
  }
3192
3510
  };
3193
3511
  }
3194
- var Or = Dr("ilbs"), kr = Dr("ilts");
3195
- //#endregion
3196
- //#region src/utils/strip-comments.ts
3197
- function Ar(e) {
3198
- let t = "", n = 0;
3199
- for (; n < e.length;) {
3200
- let r = e[n];
3201
- if (r === " " || r === "\n" || r === "\r") {
3202
- n++;
3203
- continue;
3204
- }
3205
- if (r === "#") {
3206
- for (; n < e.length && e[n] !== "\n";) n++;
3207
- continue;
3208
- }
3209
- if (r === "/") {
3210
- let t = e[n + 1] ?? "";
3211
- if (t === "/") {
3212
- for (; n < e.length && e[n] !== "\n";) n++;
3213
- continue;
3214
- }
3215
- if (t === "*") {
3216
- for (n += 2; n < e.length && !(e[n] === "*" && (e[n + 1] ?? "") === "/");) n++;
3217
- if (n >= e.length) throw SyntaxError("unterminated block comment");
3218
- n += 2;
3219
- continue;
3220
- }
3221
- for (n++; n < e.length && e[n] !== "/";) n++;
3222
- if (n >= e.length) throw SyntaxError("unterminated block comment");
3223
- n++;
3224
- continue;
3225
- }
3226
- t += r, n++;
3227
- }
3228
- return t;
3229
- }
3230
- //#endregion
3231
- //#region src/extensions/float.ts
3232
- var jr = class extends N {
3512
+ var Hr = Vr("ilbs"), Ur = Vr("ilts"), Wr = class extends j {
3233
3513
  _bits;
3234
3514
  constructor(e) {
3235
- super(E(e), { precision: "half" }), this._bits = e & 65535;
3515
+ super(C(e), { precision: "half" }), this._bits = e & 65535;
3236
3516
  }
3237
3517
  _toCBOR() {
3238
3518
  return new Uint8Array([
@@ -3241,7 +3521,7 @@ var jr = class extends N {
3241
3521
  this._bits & 255
3242
3522
  ]);
3243
3523
  }
3244
- }, Mr = class extends N {
3524
+ }, Gr = class extends j {
3245
3525
  _raw;
3246
3526
  constructor(e) {
3247
3527
  super(new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), { precision: "single" }), this._raw = e.slice();
@@ -3250,7 +3530,7 @@ var jr = class extends N {
3250
3530
  let e = /* @__PURE__ */ new Uint8Array(5);
3251
3531
  return e[0] = 250, e.set(this._raw, 1), e;
3252
3532
  }
3253
- }, Nr = class extends N {
3533
+ }, Kr = class extends j {
3254
3534
  _raw;
3255
3535
  constructor(e) {
3256
3536
  super(new DataView(e.buffer, e.byteOffset).getFloat64(0, !1), { precision: "double" }), this._raw = e.slice();
@@ -3260,13 +3540,13 @@ var jr = class extends N {
3260
3540
  return e[0] = 251, e.set(this._raw, 1), e;
3261
3541
  }
3262
3542
  };
3263
- function Pr(e) {
3264
- if (e.length === 2) return new jr(e[0] << 8 | e[1]);
3265
- if (e.length === 4) return new Mr(e);
3266
- if (e.length === 8) return new Nr(e);
3543
+ function qr(e) {
3544
+ if (e.length === 2) return new Wr(e[0] << 8 | e[1]);
3545
+ if (e.length === 4) return new Gr(e);
3546
+ if (e.length === 8) return new Kr(e);
3267
3547
  throw SyntaxError(`float'...' requires 4, 8, or 16 hex digits (2, 4, or 8 bytes); got ${e.length} bytes`);
3268
3548
  }
3269
- function Fr(e) {
3549
+ function Jr(e) {
3270
3550
  let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i;
3271
3551
  if (n === 31) i = t << 31 | 2139095040 | r << 13;
3272
3552
  else if (n === 0 && r === 0) i = t << 31;
@@ -3278,7 +3558,7 @@ function Fr(e) {
3278
3558
  let a = /* @__PURE__ */ new Uint8Array(4);
3279
3559
  return new DataView(a.buffer).setUint32(0, i >>> 0, !1), a;
3280
3560
  }
3281
- function Ir(e) {
3561
+ function Yr(e) {
3282
3562
  let t = e >>> 15 & 1, n = e >>> 10 & 31, r = e & 1023, i = /* @__PURE__ */ new Uint8Array(8), a = new DataView(i.buffer);
3283
3563
  if (n === 31) a.setUint32(0, (t << 31 | 2146435072 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
3284
3564
  else if (n === 0 && r === 0) a.setUint32(0, t << 31 >>> 0, !1), a.setUint32(4, 0, !1);
@@ -3289,7 +3569,7 @@ function Ir(e) {
3289
3569
  } else a.setUint32(0, (t << 31 | n + 1008 << 20 | r << 10) >>> 0, !1), a.setUint32(4, 0, !1);
3290
3570
  return i;
3291
3571
  }
3292
- function Lr(e) {
3572
+ function Xr(e) {
3293
3573
  let t = new DataView(e.buffer, e.byteOffset).getUint32(0, !1), n = t >>> 31 & 1, r = t >>> 23 & 255, i = t & 8388607, a = /* @__PURE__ */ new Uint8Array(8), o = new DataView(a.buffer);
3294
3574
  if (r === 255) o.setUint32(0, (n << 31 | 2146435072 | i >>> 3) >>> 0, !1), o.setUint32(4, (i & 7) << 29, !1);
3295
3575
  else if (r === 0 && i === 0) o.setUint32(0, n << 31 >>> 0, !1), o.setUint32(4, 0, !1);
@@ -3299,49 +3579,49 @@ function Lr(e) {
3299
3579
  }
3300
3580
  return a;
3301
3581
  }
3302
- function Rr(e, t, n) {
3582
+ function Zr(e, t, n) {
3303
3583
  let r = e.length === 2 ? 1 : e.length === 4 ? 2 : 3;
3304
3584
  if (r === 1) {
3305
3585
  let n = e[0] << 8 | e[1];
3306
- if (t === 2) return new Mr(Fr(n));
3307
- if (t === 3) return new Nr(Ir(n));
3586
+ if (t === 2) return new Gr(Jr(n));
3587
+ if (t === 3) return new Kr(Yr(n));
3308
3588
  }
3309
3589
  if (r === 2) {
3310
- if (t === 3) return new Nr(Lr(e));
3590
+ if (t === 3) return new Kr(Xr(e));
3311
3591
  if (t === 1) {
3312
- let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), r = T(t);
3313
- return !Object.is(E(r), t) && !isNaN(t) && n("float'...' value cannot be exactly represented as float16 (_1)"), new jr(r);
3592
+ let t = new DataView(e.buffer, e.byteOffset).getFloat32(0, !1), r = S(t);
3593
+ return !Object.is(C(r), t) && !isNaN(t) && n("float'...' value cannot be exactly represented as float16 (_1)"), new Wr(r);
3314
3594
  }
3315
3595
  }
3316
3596
  if (r === 3) {
3317
3597
  let r = new DataView(e.buffer, e.byteOffset).getFloat64(0, !1);
3318
3598
  if (t === 1) {
3319
- let e = T(r);
3320
- return !Object.is(E(e), r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float16 (_1)"), new jr(e);
3599
+ let e = S(r);
3600
+ return !Object.is(C(e), r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float16 (_1)"), new Wr(e);
3321
3601
  }
3322
3602
  if (t === 2) {
3323
3603
  let e = Math.fround(r);
3324
3604
  !Object.is(e, r) && !isNaN(r) && n("float'...' value cannot be exactly represented as float32 (_2)");
3325
3605
  let t = /* @__PURE__ */ new Uint8Array(4);
3326
- return new DataView(t.buffer).setFloat32(0, e, !1), new Mr(t);
3606
+ return new DataView(t.buffer).setFloat32(0, e, !1), new Gr(t);
3327
3607
  }
3328
3608
  }
3329
- return Pr(e);
3609
+ return qr(e);
3330
3610
  }
3331
- var zr = {
3611
+ var Qr = {
3332
3612
  appStringPrefixes: ["float"],
3333
- parseAppString(t, n, r, i) {
3334
- let a = Ar(n);
3613
+ parseAppString(e, t, r, i) {
3614
+ let a = Ie(t);
3335
3615
  if (!/^[0-9a-fA-F]*$/.test(a)) throw SyntaxError("float'...' contains non-hex characters");
3336
3616
  if (a.length % 2 != 0) throw SyntaxError(`float'...' hex content has odd length (${a.length} digits)`);
3337
- let o = e(a), s = i?.encodingWidth;
3338
- if (s === void 0) return Pr(o);
3617
+ let o = n(a), s = i?.encodingWidth;
3618
+ if (s === void 0) return qr(o);
3339
3619
  if (s !== 1 && s !== 2 && s !== 3) {
3340
3620
  let e = `float'...' encoding indicator _${s} is not valid; use _1, _2, or _3`;
3341
- if (r) return r(e), Pr(o);
3621
+ if (r) return r(e), qr(o);
3342
3622
  throw SyntaxError(e);
3343
3623
  }
3344
- return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ? Pr(o) : Rr(o, s, r ?? ((e) => {
3624
+ return s === (o.length === 2 ? 1 : o.length === 4 ? 2 : 3) ? qr(o) : Zr(o, s, r ?? ((e) => {
3345
3625
  throw SyntaxError(e);
3346
3626
  }));
3347
3627
  },
@@ -3352,34 +3632,34 @@ var zr = {
3352
3632
  if (n) n(e);
3353
3633
  else throw SyntaxError(e);
3354
3634
  }
3355
- if (!(t[0] instanceof F)) throw SyntaxError("float<<...>> item must be a byte string");
3356
- return Pr(t[0].value);
3357
- }
3358
- }, Br = [
3359
- Bn,
3360
- sr,
3361
- ur
3362
- ], Vr = [
3363
- Wt,
3364
- un,
3365
- Ln,
3366
- br,
3635
+ if (!(t[0] instanceof N)) throw SyntaxError("float<<...>> item must be a byte string");
3636
+ return qr(t[0].value);
3637
+ }
3638
+ }, $r = [
3639
+ er,
3367
3640
  xr,
3368
- Or,
3369
- kr,
3370
- zr
3371
- ], Hr;
3641
+ wr
3642
+ ], ei = [
3643
+ rn,
3644
+ wn,
3645
+ Zn,
3646
+ Pr,
3647
+ Fr,
3648
+ Hr,
3649
+ Ur,
3650
+ Qr
3651
+ ], ti;
3372
3652
  function Z(e) {
3373
- return e === void 0 ? Hr ??= [...Br, ...Vr] : e === !1 ? Br : [...Br, ...e];
3653
+ return e === void 0 ? ti ??= [...$r, ...ei] : e === !1 ? $r : [...$r, ...e];
3374
3654
  }
3375
3655
  //#endregion
3376
3656
  //#region src/js/fromJS.ts
3377
- var Ur;
3378
- function Wr(e) {
3657
+ var ni;
3658
+ function ri(e) {
3379
3659
  if (e === void 0) {
3380
- if (Ur) return Ur;
3660
+ if (ni) return ni;
3381
3661
  let e = Z(void 0);
3382
- return Ur = {
3662
+ return ni = {
3383
3663
  fromJS: e.filter((e) => e.fromJS !== void 0),
3384
3664
  parseTag: e.filter((e) => e.parseTag !== void 0)
3385
3665
  };
@@ -3390,62 +3670,62 @@ function Wr(e) {
3390
3670
  parseTag: t.filter((e) => e.parseTag !== void 0)
3391
3671
  };
3392
3672
  }
3393
- function Gr(e) {
3394
- let t = e?.extensions, n = Wr(e?.builtinExtensions);
3673
+ function ii(e) {
3674
+ let t = e?.extensions, n = ri(e?.builtinExtensions);
3395
3675
  return t?.length ? {
3396
3676
  fromJS: [...t.filter((e) => e.fromJS !== void 0), ...n.fromJS],
3397
3677
  parseTag: [...t.filter((e) => e.parseTag !== void 0), ...n.parseTag]
3398
3678
  } : n;
3399
3679
  }
3400
- function Kr(e, t) {
3680
+ function ai(e, t) {
3401
3681
  if (t?.replacer) {
3402
- let { replacer: n, ...r } = t, i = Jr(e, n, r.extensions, r.undefinedOmits, r.builtinExtensions);
3403
- return i === h ? B.UNDEFINED : Kr(i, Object.keys(r).length > 0 ? r : void 0);
3682
+ let { replacer: n, ...r } = t, i = si(e, n, r.extensions, r.undefinedOmits, r.builtinExtensions);
3683
+ return i === x ? R.UNDEFINED : ai(i, Object.keys(r).length > 0 ? r : void 0);
3404
3684
  }
3405
- return Q(e, t, !0, Gr(t));
3685
+ return Q(e, t, !0, ii(t));
3406
3686
  }
3407
3687
  function Q(e, t, n, r) {
3408
3688
  for (let n of r.fromJS) {
3409
3689
  let r = n.fromJS(e, t ?? {});
3410
3690
  if (r !== void 0) return r;
3411
3691
  }
3412
- if (n && typeof e == "object" && e && m.symbol in e) {
3413
- let n = e[m.symbol], i = Q(e, t, !1, r);
3692
+ if (n && typeof e == "object" && e && b.symbol in e) {
3693
+ let n = e[b.symbol], i = Q(e, t, !1, r);
3414
3694
  for (let e of r.parseTag) {
3415
3695
  let t = e.parseTag(n, i);
3416
3696
  if (t !== void 0) return t;
3417
3697
  }
3418
- return new P(n, i);
3419
- }
3420
- if (e instanceof m.Null) return B.NULL;
3421
- if (e instanceof m.Undefined) return B.UNDEFINED;
3422
- if (e instanceof g) return new B(e.value);
3423
- if (e === null) return B.NULL;
3424
- if (e === void 0) return B.UNDEFINED;
3425
- if (e === !0) return B.TRUE;
3426
- if (e === !1) return B.FALSE;
3427
- if (typeof e == "bigint") return e > 18446744073709551615n ? new $e(e) : e < -18446744073709551616n ? new et(e) : e >= 0n ? new j(e) : new M(e);
3428
- if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new j(BigInt(e)) : new M(BigInt(e)) : new N(e);
3429
- if (typeof e == "string") return new U(e);
3698
+ return new M(n, i);
3699
+ }
3700
+ if (e instanceof b.Null) return R.NULL;
3701
+ if (e instanceof b.Undefined) return R.UNDEFINED;
3702
+ if (e instanceof he) return new R(e.value);
3703
+ if (e === null) return R.NULL;
3704
+ if (e === void 0) return R.UNDEFINED;
3705
+ if (e === !0) return R.TRUE;
3706
+ if (e === !1) return R.FALSE;
3707
+ if (typeof e == "bigint") return e > 18446744073709551615n ? new it(e) : e < -18446744073709551616n ? new at(e) : e >= 0n ? new k(e) : new A(e);
3708
+ if (typeof e == "number") return (t?.encodeIntegerAs ?? "int") === "int" && Number.isInteger(e) && !Object.is(e, -0) ? e >= 0 ? new k(BigInt(e)) : new A(BigInt(e)) : new j(e);
3709
+ if (typeof e == "string") return new G(e);
3430
3710
  if (e instanceof Number || e instanceof Boolean || e instanceof String || Object.prototype.toString.call(e) === "[object BigInt]") return Q(e.valueOf(), t, !1, r);
3431
- if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new F(new Uint8Array(e));
3432
- if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new R(Array.from(e, (e) => new j(BigInt(e)))) : new F(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
3433
- if (e instanceof $) return new z([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
3434
- if (Array.isArray(e)) return new R(e.map((e) => Q(e, t, !0, r)));
3711
+ if (e instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && e instanceof SharedArrayBuffer) return new N(new Uint8Array(e));
3712
+ if (ArrayBuffer.isView(e)) return e instanceof Uint8Array && t?.uint8ArrayAs === "array" ? new I(Array.from(e, (e) => new k(BigInt(e)))) : new N(new Uint8Array(e.buffer, e.byteOffset, e.byteLength));
3713
+ if (e instanceof $) return new L([...e].map(([e, n]) => [Q(e, t, !0, r), Q(n, t, !0, r)]));
3714
+ if (Array.isArray(e)) return new I(e.map((e) => Q(e, t, !0, r)));
3435
3715
  if (typeof e == "object") {
3436
3716
  let n = [];
3437
- for (let [i, a] of Object.entries(e)) n.push([new U(i), Q(a, t, !0, r)]);
3438
- return new z(n);
3717
+ for (let [i, a] of Object.entries(e)) n.push([new G(i), Q(a, t, !0, r)]);
3718
+ return new L(n);
3439
3719
  }
3440
3720
  throw TypeError(`fromJS: unsupported value type: ${typeof e}`);
3441
3721
  }
3442
- function qr(e) {
3443
- 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 m.Null || e instanceof m.Undefined || e instanceof g;
3722
+ function oi(e) {
3723
+ 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 b.Null || e instanceof b.Undefined || e instanceof he;
3444
3724
  }
3445
- function Jr(e, t, n, r, i) {
3725
+ function si(e, t, n, r, i) {
3446
3726
  let a = [...n ?? [], ...Z(i)].filter((e) => e.isJSType !== void 0);
3447
3727
  function o(e) {
3448
- return e === h || r === !0 && e === void 0;
3728
+ return e === x || r === !0 && e === void 0;
3449
3729
  }
3450
3730
  if (Array.isArray(t)) {
3451
3731
  let n = t.map(String);
@@ -3453,7 +3733,7 @@ function Jr(e, t, n, r, i) {
3453
3733
  if (typeof e != "object" || !e) return e;
3454
3734
  if (e instanceof $) return $.from(e, ([e, t]) => [e, r(t)]);
3455
3735
  if (Array.isArray(e)) return e.map(r);
3456
- if (m.symbol in e || qr(e) || a.some((t) => t.isJSType(e))) return e;
3736
+ if (b.symbol in e || oi(e) || a.some((t) => t.isJSType(e))) return e;
3457
3737
  let t = Object.getPrototypeOf(e);
3458
3738
  if (t === Object.prototype || t === null) {
3459
3739
  let t = e.toJSON;
@@ -3475,7 +3755,7 @@ function Jr(e, t, n, r, i) {
3475
3755
  }
3476
3756
  }
3477
3757
  if (e = s.call(n, t, e), typeof e == "object" && e) {
3478
- if (m.symbol in e) return e;
3758
+ if (b.symbol in e) return e;
3479
3759
  if (e instanceof $) {
3480
3760
  let t = new $();
3481
3761
  for (let [n, r] of e) {
@@ -3488,7 +3768,7 @@ function Jr(e, t, n, r, i) {
3488
3768
  let r = c(t, String(n), e);
3489
3769
  return o(r) ? null : r;
3490
3770
  });
3491
- if (qr(e) || a.some((t) => t.isJSType(e))) return e;
3771
+ if (oi(e) || a.some((t) => t.isJSType(e))) return e;
3492
3772
  let t = {};
3493
3773
  for (let n of Object.keys(e)) {
3494
3774
  let r = c(e[n], n, e);
@@ -3506,7 +3786,7 @@ var $ = class extends Array {
3506
3786
  toJSON() {
3507
3787
  let e = {};
3508
3788
  for (let [t, n] of this) {
3509
- let r = typeof t == "string" ? t : Kr(t).toCDN();
3789
+ let r = typeof t == "string" ? t : ai(t).toCDN();
3510
3790
  r === "__proto__" ? Object.defineProperty(e, r, {
3511
3791
  value: n,
3512
3792
  writable: !0,
@@ -3518,6 +3798,6 @@ var $ = class extends Array {
3518
3798
  }
3519
3799
  };
3520
3800
  //#endregion
3521
- export { P as A, s as B, Ve as C, L as D, R as E, A as F, c as H, k as I, g as L, Re as M, M as N, I as O, j as P, h as R, He as S, z as T, m as V, it as _, zr as a, V as b, kr as c, ar as d, Ln as f, U as g, Gt as h, Vr as i, N as j, F as k, xr as l, Wt as m, Jr as n, Ar as o, un as p, Kr as r, Or as s, $ as t, br as u, et as v, B as w, Ge as x, $e as y, o as z };
3801
+ export { N as A, se as B, He as C, I as D, L as E, k as F, b as H, O as I, D as L, j as M, Me as N, F as O, A as P, he as R, Ve as S, R as T, le as U, ce as V, at as _, Qr as a, B as b, Fr as c, Zn as d, wn as f, lt as g, G as h, ei as i, M as j, P as k, Pr as l, an as m, si as n, Hr as o, rn as p, ai as r, Ur as s, $ as t, yr as u, it as v, z as w, Ue as x, V as y, x as z };
3522
3802
 
3523
- //# sourceMappingURL=mapEntries-Czxt-cmd.js.map
3803
+ //# sourceMappingURL=mapEntries-Ci_dppP6.js.map