@cbortech/cbor 0.26.7 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/README.ja.md +120 -47
  2. package/README.md +121 -48
  3. package/dist/ast/CborAppSeqResult.d.ts +22 -0
  4. package/dist/ast/CborByteString.d.ts +27 -0
  5. package/dist/ast/CborEmbeddedCBOR.d.ts +1 -1
  6. package/dist/ast/CborFloat.d.ts +1 -1
  7. package/dist/ast/CborIndefiniteByteString.d.ts +24 -0
  8. package/dist/ast/CborIndefiniteTextString.d.ts +16 -0
  9. package/dist/ast/CborItem.d.ts +44 -4
  10. package/dist/ast/CborTag.d.ts +27 -0
  11. package/dist/ast/CborTextString.d.ts +18 -1
  12. package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
  13. package/dist/ast/index.cjs +1 -1
  14. package/dist/ast/index.d.ts +1 -0
  15. package/dist/ast/index.js +2 -2
  16. package/dist/cddl/index.cjs +1 -1
  17. package/dist/cddl/index.js +1 -1
  18. package/dist/cdn/index.cjs +2 -2
  19. package/dist/cdn/index.cjs.map +1 -1
  20. package/dist/cdn/index.d.ts +2 -0
  21. package/dist/cdn/index.js +15 -15
  22. package/dist/cdn/index.js.map +1 -1
  23. package/dist/cdn/serialize-utils.d.ts +241 -21
  24. package/dist/cdn/tokenizer.d.ts +12 -11
  25. package/dist/extensions/builtins.d.ts +5 -5
  26. package/dist/extensions/cri.d.ts +2 -2
  27. package/dist/extensions/ip.d.ts +1 -1
  28. package/dist/extensions/types.d.ts +4 -4
  29. package/dist/index.cjs +3 -3
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.ts +2 -1
  32. package/dist/index.js +158 -158
  33. package/dist/index.js.map +1 -1
  34. package/dist/mapEntries-C1f7G0AM.cjs +13 -0
  35. package/dist/mapEntries-C1f7G0AM.cjs.map +1 -0
  36. package/dist/{mapEntries-DxrDre2P.js → mapEntries-CvLdiN0h.js} +1479 -1558
  37. package/dist/mapEntries-CvLdiN0h.js.map +1 -0
  38. package/dist/{schema-Bofmsptw.js → schema-CNfrVRYp.js} +294 -294
  39. package/dist/{schema-Bofmsptw.js.map → schema-CNfrVRYp.js.map} +1 -1
  40. package/dist/schema-iXpYtKQl.cjs +63 -0
  41. package/dist/{schema-t_bdPk8_.cjs.map → schema-iXpYtKQl.cjs.map} +1 -1
  42. package/dist/{tokenizer-CeuixxXi.js → serialize-utils-BuIZPaUc.js} +634 -30
  43. package/dist/serialize-utils-BuIZPaUc.js.map +1 -0
  44. package/dist/serialize-utils-CjTqQivB.cjs +37 -0
  45. package/dist/serialize-utils-CjTqQivB.cjs.map +1 -0
  46. package/dist/types.d.ts +248 -64
  47. package/dist/utils/base64.d.ts +1 -1
  48. package/dist/utils/hexfloat.d.ts +1 -1
  49. package/dist/utils/strip-comments.d.ts +1 -1
  50. package/package.json +8 -7
  51. package/dist/mapEntries-D2NyeCX3.cjs +0 -17
  52. package/dist/mapEntries-D2NyeCX3.cjs.map +0 -1
  53. package/dist/mapEntries-DxrDre2P.js.map +0 -1
  54. package/dist/schema-t_bdPk8_.cjs +0 -63
  55. package/dist/tokenizer-CeuixxXi.js.map +0 -1
  56. package/dist/tokenizer-EciPlN0n.cjs +0 -30
  57. package/dist/tokenizer-EciPlN0n.cjs.map +0 -1
@@ -41,8 +41,47 @@ function u(e) {
41
41
  return t;
42
42
  }
43
43
  //#endregion
44
+ //#region src/utils/base64.ts
45
+ function d(e, t) {
46
+ let n = e.indexOf("="), r = n >= 0 ? e.slice(0, n) : e, i = n >= 0 ? e.slice(n) : "";
47
+ if (/[^A-Za-z0-9+/\-_]/.test(r)) {
48
+ let e = [...r].find((e) => !/[A-Za-z0-9+/\-_]/.test(e)) ?? "";
49
+ throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`);
50
+ }
51
+ if (i && !/^=+$/.test(i)) throw SyntaxError("invalid character after base64 '=' padding");
52
+ let a = r.length % 4;
53
+ if (a === 1) throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);
54
+ let o = a === 0 ? 0 : 4 - a;
55
+ if (i.length > o) {
56
+ let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but the data length (${r.length}) requires at most ${o}`;
57
+ if (t) t(e);
58
+ else throw SyntaxError(e);
59
+ }
60
+ if (i.length > 0 && i.length < o) {
61
+ let e = `base64 has ${i.length} '=' character${i.length > 1 ? "s" : ""} but needs exactly ${o} — use full padding or no padding at all`;
62
+ if (t) t(e);
63
+ else throw SyntaxError(e);
64
+ }
65
+ if (a !== 0 && r.length > 0) {
66
+ let e = r[r.length - 1].replace("-", "+").replace("_", "/"), n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e);
67
+ if (n >= 0 && n & (a === 2 ? 15 : 3)) {
68
+ let e = "base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)";
69
+ if (t) t(e);
70
+ else throw SyntaxError(e);
71
+ }
72
+ }
73
+ let s = r.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat(o);
74
+ if (typeof Uint8Array.fromBase64 == "function") return Uint8Array.fromBase64(s, {
75
+ alphabet: "base64",
76
+ lastChunkHandling: "loose"
77
+ });
78
+ let c = atob(s), l = new Uint8Array(c.length);
79
+ for (let e = 0; e < c.length; e++) l[e] = c.charCodeAt(e);
80
+ return l;
81
+ }
82
+ //#endregion
44
83
  //#region src/cdn/tokenizer.ts
45
- function d(e, t, n) {
84
+ function f(e, t, n) {
46
85
  let r = 1, i = 1;
47
86
  for (let a = 0; a < e.length; a++) {
48
87
  if (r === t && i === n) return a;
@@ -50,7 +89,7 @@ function d(e, t, n) {
50
89
  }
51
90
  return e.length;
52
91
  }
53
- function f(e, t) {
92
+ function p(e, t) {
54
93
  let n = 1, r = 1;
55
94
  for (let i = 0; i < t; i++) e[i] === "\n" ? (n++, r = 1) : r++;
56
95
  return {
@@ -58,10 +97,10 @@ function f(e, t) {
58
97
  col: r
59
98
  };
60
99
  }
61
- function p(e) {
100
+ function m(e) {
62
101
  return e >= 48 && e <= 57 || e >= 97 && e <= 102 || e >= 65 && e <= 70;
63
102
  }
64
- var m = new TextEncoder(), h = class {
103
+ var h = new TextEncoder(), g = class {
65
104
  input;
66
105
  pos;
67
106
  line;
@@ -75,7 +114,7 @@ var m = new TextEncoder(), h = class {
75
114
  this.input = e;
76
115
  let n = t?.offset ?? 0;
77
116
  if (this.skipRS = t?.skipRS ?? !1, !Number.isInteger(n) || n < 0 || n > e.length) throw RangeError(`EDN parse offset must be an integer between 0 and ${e.length}`);
78
- let r = f(e, n);
117
+ let r = p(e, n);
79
118
  this.pos = n, this.line = r.line, this.col = r.col, this._lastConsumedEndOffset = n;
80
119
  }
81
120
  peek() {
@@ -102,7 +141,7 @@ var m = new TextEncoder(), h = class {
102
141
  return e === "\n" ? (this.line++, this.col = 1) : this.col++, e;
103
142
  }
104
143
  _fail(t, n = this.line, r = this.col) {
105
- let i = n === this.line && r === this.col ? this.pos : d(this.input, n, r);
144
+ let i = n === this.line && r === this.col ? this.pos : f(this.input, n, r);
106
145
  throw new e(t, {
107
146
  offset: i,
108
147
  line: n,
@@ -343,7 +382,7 @@ var m = new TextEncoder(), h = class {
343
382
  break;
344
383
  }
345
384
  if (a === "/") {
346
- e === "'" && this._fail("\\/ is not a valid escape in single-quoted byte strings (§5.1)", n, i), r += "/";
385
+ e === "'" && this._fail("\\/ is not a valid escape in single-quoted byte strings (§6.1)", n, i), r += "/";
347
386
  break;
348
387
  }
349
388
  if (this.onEscapeWarning) {
@@ -382,7 +421,7 @@ var m = new TextEncoder(), h = class {
382
421
  _readUnicodeEscape(e, t, n, r) {
383
422
  let i = this.line, a = this.col, o = (o) => {
384
423
  if (e === "'" && o >= 32 && o <= 126) {
385
- let e = `\\u escape for printable ASCII U+${o.toString(16).padStart(4, "0").toUpperCase()} is not allowed in single-quoted strings (§5.1 hexchar-s)`;
424
+ let e = `\\u escape for printable ASCII U+${o.toString(16).padStart(4, "0").toUpperCase()} is not allowed in single-quoted strings (§6.1 hexchar-s)`;
386
425
  if (this.onEscapeWarning) {
387
426
  this.onEscapeWarning(e, t ?? this.pos, n ?? i, r ?? a, this.pos);
388
427
  return;
@@ -446,11 +485,11 @@ var m = new TextEncoder(), h = class {
446
485
  if (l === "`") {
447
486
  let i = 0, o = this.line, s = this.col;
448
487
  for (; !this._eof() && this._ch() === "`";) this._advance(), i++;
449
- if (i === n) return !r && a.length >= 2 && a.startsWith(" ") && a.endsWith(" ") && (a = a.slice(1, -1)), a === "" && this._fail("raw string must not be empty (§2.5.4)", e, t), a;
488
+ if (i === n) return !r && a.length >= 2 && a.startsWith(" ") && a.endsWith(" ") && (a = a.slice(1, -1)), a === "" && this._fail("raw string must not be empty (§2.3.3)", e, t), a;
450
489
  i > n && this._fail(`raw string contains a run of ${i} backquotes, longer than the ${n}-backquote delimiter; use longer delimiters`, o, s), a += "`".repeat(i);
451
490
  } else {
452
491
  let e = l.codePointAt(0);
453
- e < 32 && e !== 10 && e !== 13 && this._fail(`raw string content must not contain control character U+${e.toString(16).toUpperCase().padStart(4, "0")} (§2.5.4)`, this.line, this.col), e === 127 && this._fail("raw string content must not contain DEL (U+007F) (§2.5.4)", this.line, this.col), a += this._advance();
492
+ e < 32 && e !== 10 && e !== 13 && this._fail(`raw string content must not contain control character U+${e.toString(16).toUpperCase().padStart(4, "0")} (§2.3.3)`, this.line, this.col), e === 127 && this._fail("raw string content must not contain DEL (U+007F) (§2.3.3)", this.line, this.col), a += this._advance();
454
493
  }
455
494
  }
456
495
  this._fail("unterminated raw string literal", e, t);
@@ -463,7 +502,7 @@ var m = new TextEncoder(), h = class {
463
502
  a++;
464
503
  continue;
465
504
  }
466
- o === " " && this._fail("horizontal tab (HT) is not allowed inside h`` raw byte string literals (§5.3.3)", t, n);
505
+ o === " " && this._fail("horizontal tab (HT) is not allowed inside h`` raw byte string literals (§6.3.3)", t, n);
467
506
  let s = this._skipRawComment(e, a, "h`` raw byte string", t, n);
468
507
  if (s !== -1) {
469
508
  a = s;
@@ -474,9 +513,9 @@ var m = new TextEncoder(), h = class {
474
513
  r += "...", i = !0;
475
514
  continue;
476
515
  }
477
- if (p(e.charCodeAt(a))) {
516
+ if (m(e.charCodeAt(a))) {
478
517
  let t = a;
479
- for (; a < e.length && p(e.charCodeAt(a));) a++;
518
+ for (; a < e.length && m(e.charCodeAt(a));) a++;
480
519
  r += e.slice(t, a);
481
520
  continue;
482
521
  }
@@ -495,7 +534,7 @@ var m = new TextEncoder(), h = class {
495
534
  i++;
496
535
  continue;
497
536
  }
498
- if (a === " " && this._fail("horizontal tab (HT) is not allowed inside b64`` raw byte string literals (§5.3.4)", t, n), a === "#") {
537
+ if (a === " " && this._fail("horizontal tab (HT) is not allowed inside b64`` raw byte string literals (§6.3.4)", t, n), a === "#") {
499
538
  for (; i < e.length && e[i] !== "\n";) i++;
500
539
  continue;
501
540
  }
@@ -522,7 +561,7 @@ var m = new TextEncoder(), h = class {
522
561
  this._advance();
523
562
  continue;
524
563
  }
525
- if (n === " " && this._fail("horizontal tab (HT) is not allowed inside byte string literals (§5.2.2)", this.line, this.col), n === "#") {
564
+ if (n === " " && this._fail("horizontal tab (HT) is not allowed inside byte string literals (§6.2.2)", this.line, this.col), n === "#") {
526
565
  for (; !this._eof() && this._ch() !== "\n";) {
527
566
  if (this._ch() === "\\") {
528
567
  this._advance(), !this._eof() && this._ch() !== "\n" && this._advance();
@@ -545,26 +584,26 @@ var m = new TextEncoder(), h = class {
545
584
  }
546
585
  _readHexByteContentElisionAware(e) {
547
586
  this._advance();
548
- let t = "", n = !1;
587
+ let t = "", n = !1, r = !1;
549
588
  for (; !this._eof() && this._ch() !== e;) {
550
- let r = this._ch();
551
- if (r === "\n" || r === " " || r === "\r") {
589
+ let i = this._ch();
590
+ if (i === "\n" || i === " " || i === "\r") {
552
591
  this._advance();
553
592
  continue;
554
593
  }
555
- if (r === " " && this._fail("horizontal tab (HT) is not allowed inside hex byte string literals (§5.2.1)", this.line, this.col), !this._skipByteStringComment(e)) {
556
- if (r === "." && (this.input[this.pos + 1] ?? "") === "." && (this.input[this.pos + 2] ?? "") === ".") {
594
+ if (i === " " && this._fail("horizontal tab (HT) is not allowed inside hex byte string literals (§6.2.1)", this.line, this.col), !this._skipByteStringComment(e)) {
595
+ if (i === "." && (this.input[this.pos + 1] ?? "") === "." && (this.input[this.pos + 2] ?? "") === ".") {
557
596
  for (this._advance(), this._advance(), this._advance(); !this._eof() && this._ch() === ".";) this._advance();
558
- t.endsWith("...") || (t += "..."), n = !0;
597
+ r || (t += "..."), n = !0, r = !0;
559
598
  continue;
560
599
  }
561
- if (p(r.charCodeAt(0))) {
562
- let e = this.pos, n = this.pos, r = this.input.length;
563
- for (; n < r && p(this.input.charCodeAt(n));) n++;
564
- this.col += n - e, this.pos = n, t += this.input.slice(e, n);
600
+ if (m(i.charCodeAt(0))) {
601
+ let e = this.pos, n = this.pos, i = this.input.length;
602
+ for (; n < i && m(this.input.charCodeAt(n));) n++;
603
+ this.col += n - e, this.pos = n, t += this.input.slice(e, n), r = !1;
565
604
  continue;
566
605
  }
567
- this._fail(`unexpected character ${JSON.stringify(r)} in hex byte string`);
606
+ this._fail(`unexpected character ${JSON.stringify(i)} in hex byte string`);
568
607
  }
569
608
  }
570
609
  return this._eof() && this._fail("unterminated hex byte string literal"), this._advance(), {
@@ -631,7 +670,7 @@ var m = new TextEncoder(), h = class {
631
670
  }
632
671
  case "'": {
633
672
  if ((this.input[this.pos + 1] ?? "") === "'" && (this.input[this.pos + 2] ?? "") === "_" && !/[0-7i]/.test(this.input[this.pos + 3] ?? "")) return this._advance(), this._advance(), this._advance(), this._tok("EMPTY_INDEF_BYTES", "", e, t);
634
- let n = this._readStringContent("'"), r = m.encode(n), i = this._tok("SQSTR", o(r), e, t);
673
+ let n = this._readStringContent("'"), r = h.encode(n), i = this._tok("SQSTR", o(r), e, t);
635
674
  return Object.defineProperty(i, "_sqstrBytes", { value: r }), i;
636
675
  }
637
676
  }
@@ -661,7 +700,7 @@ var m = new TextEncoder(), h = class {
661
700
  }
662
701
  _skipHexDigits() {
663
702
  let e = this.pos, t = this.input.length;
664
- for (; e < t && p(this.input.charCodeAt(e));) e++;
703
+ for (; e < t && m(this.input.charCodeAt(e));) e++;
665
704
  this.col += e - this.pos, this.pos = e;
666
705
  }
667
706
  _skipDecimalDigits() {
@@ -804,6 +843,571 @@ var m = new TextEncoder(), h = class {
804
843
  }
805
844
  };
806
845
  //#endregion
807
- export { u as a, l as i, c as n, e as o, o as r, h as t };
846
+ //#region src/cdn/serialize-utils.ts
847
+ function _(e, t) {
848
+ for (let n of t) e.push(n);
849
+ }
850
+ function v(e) {
851
+ let t = e?.indent;
852
+ if (t === void 0) return null;
853
+ let n = typeof t == "number" ? " ".repeat(t) : t;
854
+ return n === "" ? null : n;
855
+ }
856
+ function y(e, t) {
857
+ return e.repeat(t);
858
+ }
859
+ function b(e, t, n, r) {
860
+ if (t === null) return e.join(" + ");
861
+ let i = y(t, n + 1), a = e[0];
862
+ for (let t = 1; t < e.length; t++) {
863
+ a += " +\n";
864
+ for (let e of r?.[t - 1] ?? []) a += `${i}${e}\n`;
865
+ a += i + e[t];
866
+ }
867
+ return a;
868
+ }
869
+ function x(e, t, n, r, i, a) {
870
+ let o = a?.some((e) => e.length > 0) ?? !1;
871
+ if (r === null || !o) return `${e}<<${t.join(", ")}>>${n}`;
872
+ let s = y(r, i + 1), c = y(r, i), l = [];
873
+ for (let e = 0; e < t.length; e++) {
874
+ let n = e < t.length - 1 ? "," : "";
875
+ l.push(`${s}${t[e]}${n}`);
876
+ for (let t of a?.[e] ?? []) l.push(`${s}${t}`);
877
+ }
878
+ return `${e}<<\n${l.join("\n")}\n${c}>>${n}`;
879
+ }
880
+ function S(e) {
881
+ return !!(e.comments?.leading?.length || e.comments?.trailing?.length || e.comments?.dangling?.length);
882
+ }
883
+ function C(e) {
884
+ return !!e.comments?.dangling?.length;
885
+ }
886
+ function w(e) {
887
+ return e?.preserveComments === !0 || typeof e?.preserveComments == "string" || e?.comments !== void 0 && e.comments !== "strip";
888
+ }
889
+ function T(e) {
890
+ if (e?.preserveComments === !0) return;
891
+ if (typeof e?.preserveComments == "string") return e.preserveComments;
892
+ let t = e?.comments;
893
+ return t === "strip" ? void 0 : t;
894
+ }
895
+ function E(e, t) {
896
+ if (!t) return e.text;
897
+ let { marker: n, text: r } = e;
898
+ if (t === "c-style") return n === "#" ? "//" + r.slice(1) : n === "/" ? "/*" + r.slice(1, -1) + "*/" : r;
899
+ if (n === "//") return "#" + r.slice(2);
900
+ if (n === "/*") {
901
+ let e = r.slice(2, -2);
902
+ return e.includes("/") ? r : "/" + (e.startsWith("*") || e.startsWith("/") ? " " + e : e) + "/";
903
+ }
904
+ return r;
905
+ }
906
+ function D(e, t, n) {
907
+ if (!e || e.length === 0 || !t || t.length < 2) return;
908
+ let r = t.slice(1).map(() => []), i = !1;
909
+ for (let a of e) for (let e = 0; e < t.length - 1; e++) {
910
+ let o = t[e].end, s = t[e + 1].start;
911
+ if (o !== void 0 && s !== void 0 && a.start >= o && a.end <= s) {
912
+ r[e].push(E(a, n)), i = !0;
913
+ break;
914
+ }
915
+ }
916
+ return i ? r : void 0;
917
+ }
918
+ function O(e, t, n) {
919
+ let r = e.comments?.leading ?? [], i = r.length;
920
+ for (; i > 0 && r[i - 1].sameLine;) i--;
921
+ return {
922
+ ownLines: r.slice(0, i).map((e) => t + E(e, n)),
923
+ inlinePrefix: r.slice(i).map((e) => E(e, n) + " ").join("")
924
+ };
925
+ }
926
+ function k(e, t) {
927
+ let n = e.comments?.trailing ?? [];
928
+ return n.length === 0 ? "" : " " + n.map((e) => E(e, t)).join(" ");
929
+ }
930
+ function A(e, t, n) {
931
+ return (e.comments?.dangling ?? []).map((e) => t + E(e, n));
932
+ }
933
+ function ee(e, t = !1) {
934
+ let n = e?.commas ?? "comma", r = n !== "none";
935
+ return {
936
+ inlineSep: r ? t ? "," : ", " : " ",
937
+ multilineSep: r ? "," : "",
938
+ trailSep: n === "trailing" ? "," : "",
939
+ colSep: t ? ":" : ": "
940
+ };
941
+ }
942
+ function j(e) {
943
+ let { options: t, depth: n, openChar: r, closeChar: i, count: a } = e, o = v(t), s = w(t), c = T(t), l = o !== null && s && (C(e.node) || e.hasEntryComments()), u = o !== null && !!t?.preserveBlankLines, d = !1;
944
+ if (u) {
945
+ for (let t = 0; t < a; t++) if (e.entryLeadingNode(t).blankLineBefore) {
946
+ d = !0;
947
+ break;
948
+ }
949
+ }
950
+ let { inlineSep: f, multilineSep: p, trailSep: m, colSep: h } = ee(t, o === null), g = e.eiPosition ?? "open", b = e.indefiniteLength ? "" : Y(t, e.encodingWidth, () => J(e.canonicalCount ? e.canonicalCount() : BigInt(a))), x = g === "open" && b ? b + " " : "", S = g === "close" ? b : "", E = e.indefiniteLength && (e.indefiniteMarker ?? !0) && (t?.encodingIndicators ?? "auto") !== "never", D = (t) => e.indefiniteLength ? E ? a === 0 ? `${r}_ ${i}` : `${r}_ ${t}${i}` : `${r}${t}${i}` : `${r}${x}${t}${i}${S}`;
951
+ if (o === null || a === 0 && !l) {
952
+ let t = "";
953
+ for (let n = 0; n < a; n++) n > 0 && (t += f), t += e.renderEntry(n, h);
954
+ return D(t);
955
+ }
956
+ let k = null;
957
+ if ((t?.inlineLeafContainers || e.alwaysInlineLeaf) && a > 0 && !l && !d) {
958
+ let t = !!e.entryIsLeaf, n = [], r = !0;
959
+ for (let i = 0; i < a; i++) {
960
+ if (e.entryIsLeaf && !e.entryIsLeaf(i)) {
961
+ r = !1;
962
+ break;
963
+ }
964
+ if (e.entryIsMultiWordText?.(i)) {
965
+ r = !1;
966
+ break;
967
+ }
968
+ let a = e.renderEntry(i, h);
969
+ if (n.push(a), a.includes("\n")) {
970
+ r = !1;
971
+ break;
972
+ }
973
+ if (t && R(a)) {
974
+ r = !1;
975
+ break;
976
+ }
977
+ }
978
+ if (r) return D(n.join(f));
979
+ k = n;
980
+ }
981
+ let j = y(o, n + 1), M = y(o, n), N = e.indefiniteLength ? E ? `${r}_ ` : r : `${r}${x}`, P = [];
982
+ for (let t = 0; t < a; t++) {
983
+ u && e.entryLeadingNode(t).blankLineBefore && P.push("");
984
+ let n = "";
985
+ if (s) {
986
+ let { ownLines: r, inlinePrefix: i } = O(e.entryLeadingNode(t), j, c);
987
+ _(P, r), n = i;
988
+ }
989
+ let r = t < a - 1 ? p : m, i = k?.[t] ?? e.renderEntry(t, h);
990
+ P.push(`${j}${n}${i}${r}${s ? e.entryTrailing(t, c) : ""}`);
991
+ }
992
+ return s && _(P, A(e.node, j, c)), `${N}\n${P.join("\n")}\n${M}${i}${S}`;
993
+ }
994
+ function M(e, t, n, r, i, a, o) {
995
+ let s = v(n);
996
+ if (!(s !== null && w(n) && (S(e) || C(t)))) return `${a}${i(r)}${o}`;
997
+ let c = T(n), l = y(s, r + 1), u = y(s, r), { ownLines: d, inlinePrefix: f } = O(e, l, c);
998
+ return `${a}\n${[
999
+ ...d,
1000
+ `${l}${f}${i(r + 1)}${k(e, c)}`,
1001
+ ...A(t, l, c)
1002
+ ].join("\n")}\n${u}${o}`;
1003
+ }
1004
+ var N = typeof (/* @__PURE__ */ new Uint8Array()).toBase64 == "function";
1005
+ function P(e) {
1006
+ if (N) return e.toBase64({ omitPadding: !0 });
1007
+ let t = "";
1008
+ for (let n of e) t += String.fromCharCode(n);
1009
+ return btoa(t).replace(/=/g, "");
1010
+ }
1011
+ function te(e) {
1012
+ if (N) return e.toBase64({
1013
+ alphabet: "base64url",
1014
+ omitPadding: !0
1015
+ });
1016
+ let t = "";
1017
+ for (let n of e) t += String.fromCharCode(n);
1018
+ return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
1019
+ }
1020
+ var ne = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", re = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
1021
+ function F(e, t) {
1022
+ let n = "", r = 0, i = 0;
1023
+ for (let a of e) for (r = r << 8 | a, i += 8; i >= 5;) i -= 5, n += t[r >> i & 31];
1024
+ return i > 0 && (n += t[r << 5 - i & 31]), n;
1025
+ }
1026
+ function ie(e) {
1027
+ for (let t of e) {
1028
+ let e = t.codePointAt(0);
1029
+ if (e < 32 || e === 127) return !0;
1030
+ }
1031
+ return !1;
1032
+ }
1033
+ function I(e, t) {
1034
+ if (t === "string") {
1035
+ let t = G(e);
1036
+ if (t != null) return t;
1037
+ }
1038
+ if (t === "printable-string" || t === void 0) {
1039
+ let t = G(e);
1040
+ if (t != null && !ie(t)) return t;
1041
+ }
1042
+ return null;
1043
+ }
1044
+ function ae(e, t, n) {
1045
+ let r = I(e, n);
1046
+ if (r !== null) return ye(r);
1047
+ switch (t) {
1048
+ case "base64": return `b64'${P(e)}'`;
1049
+ case "base64url": return `b64'${te(e)}'`;
1050
+ case "base32": return `b32'${F(e, ne)}'`;
1051
+ case "base32hex": return `h32'${F(e, re)}'`;
1052
+ default: return `h'${o(e)}'`;
1053
+ }
1054
+ }
1055
+ function L(e, t) {
1056
+ let n = I(e, t);
1057
+ return n !== null && q(n);
1058
+ }
1059
+ var oe = /^[A-Za-z][A-Za-z0-9-]*['`]/;
1060
+ function R(e) {
1061
+ return oe.test(e);
1062
+ }
1063
+ var z = new TextDecoder();
1064
+ function se(e, t) {
1065
+ let n;
1066
+ try {
1067
+ n = ce(e);
1068
+ } catch {
1069
+ return !1;
1070
+ }
1071
+ return W(n, 0, n.length, t);
1072
+ }
1073
+ function ce(e) {
1074
+ let t = new g(e), n = [];
1075
+ for (;;) {
1076
+ let e = t.consume();
1077
+ if (e.type === "EOF") return n;
1078
+ n.push(e);
1079
+ }
1080
+ }
1081
+ var B = /* @__PURE__ */ new Set([
1082
+ "LPAREN",
1083
+ "LBRACKET",
1084
+ "LBRACE",
1085
+ "LT_LT",
1086
+ "APP_SEQUENCE"
1087
+ ]), le = /* @__PURE__ */ new Set([
1088
+ "RPAREN",
1089
+ "RBRACKET",
1090
+ "RBRACE",
1091
+ "GT_GT"
1092
+ ]), V = /* @__PURE__ */ new Set([
1093
+ "TSTR",
1094
+ "RAWSTRING",
1095
+ "SQSTR",
1096
+ "BYTES_HEX",
1097
+ "BYTES_HEX_ELIDED",
1098
+ "BYTES_B64",
1099
+ "ELLIPSIS"
1100
+ ]);
1101
+ function H(e, t, n) {
1102
+ let r = 1;
1103
+ for (let i = t + 1; i < n; i++) {
1104
+ let t = e[i].type;
1105
+ if (B.has(t)) r++;
1106
+ else if (le.has(t) && (r--, r === 0)) return i;
1107
+ }
1108
+ return null;
1109
+ }
1110
+ function U(e, t, n) {
1111
+ if (t >= n) return null;
1112
+ if (e[t].type === "INTEGER") {
1113
+ let r = t + 1;
1114
+ if (r < n && e[r].type === "ENCODING_INDICATOR" && r++, r < n && e[r].type === "LPAREN") {
1115
+ let t = H(e, r, n);
1116
+ return t === null ? null : t + 1;
1117
+ }
1118
+ return r;
1119
+ }
1120
+ if (B.has(e[t].type)) {
1121
+ let r = H(e, t, n);
1122
+ if (r === null) return null;
1123
+ let i = r + 1;
1124
+ return i < n && e[i].type === "ENCODING_INDICATOR" && i++, i;
1125
+ }
1126
+ let r = t + 1;
1127
+ if (r < n && e[r].type === "ENCODING_INDICATOR" && r++, e[t].type === "ELLIPSIS") {
1128
+ for (; r < n && e[r].type === "PLUS";) {
1129
+ let t = U(e, r + 1, n);
1130
+ if (t === null) return null;
1131
+ r = t;
1132
+ }
1133
+ return r;
1134
+ }
1135
+ let i = V.has(e[t].type);
1136
+ for (; i && r < n && e[r].type === "PLUS";) {
1137
+ let t = r + 1;
1138
+ if (t >= n || !V.has(e[t].type)) return null;
1139
+ r = t + 1, r < n && e[r].type === "ENCODING_INDICATOR" && r++;
1140
+ }
1141
+ return r;
1142
+ }
1143
+ function ue(e, t, n) {
1144
+ let r = [], i = t;
1145
+ for (; i < n;) {
1146
+ let t = U(e, i, n);
1147
+ if (t === null) return [];
1148
+ r.push([i, t]), i = t, i < n && e[i].type === "COMMA" && i++;
1149
+ }
1150
+ return r;
1151
+ }
1152
+ function W(e, t, n, r) {
1153
+ if (n <= t) return !1;
1154
+ let i = n;
1155
+ if (e[i - 1].type === "ENCODING_INDICATOR" && i--, e[t].type === "INTEGER") {
1156
+ let n = t + 1;
1157
+ if (n < i && e[n].type === "ENCODING_INDICATOR" && n++, n < i && e[n].type === "LPAREN") {
1158
+ let t = H(e, n, i);
1159
+ if (t !== null && t + 1 === i) return W(e, n + 1, t, r);
1160
+ }
1161
+ }
1162
+ if (e[t].type === "APP_SEQUENCE") {
1163
+ let n = H(e, t, i);
1164
+ if (n !== null && n + 1 === i) {
1165
+ for (let [r, i] of ue(e, t + 1, n)) if (W(e, r, i, !1)) return !0;
1166
+ return !1;
1167
+ }
1168
+ }
1169
+ if (i - t > 1 && de(e, t, i)) {
1170
+ if (e[t].type === "TSTR" || e[t].type === "RAWSTRING" || e[t].type === "SQSTR" || e[t].type === "ELLIPSIS") {
1171
+ let n = fe(e, t, i);
1172
+ return n !== null && q(n);
1173
+ }
1174
+ return r;
1175
+ }
1176
+ if (i - t !== 1) return !1;
1177
+ let a = e[t];
1178
+ switch (a.type) {
1179
+ case "TSTR":
1180
+ case "RAWSTRING": return q(a.value);
1181
+ case "SQSTR": {
1182
+ let e = a._sqstrBytes;
1183
+ return e !== void 0 && q(z.decode(e));
1184
+ }
1185
+ case "BYTES_HEX":
1186
+ case "BYTES_HEX_ELIDED":
1187
+ case "BYTES_B64":
1188
+ case "APP_STRING": return r;
1189
+ default: return !1;
1190
+ }
1191
+ }
1192
+ function de(e, t, n) {
1193
+ return V.has(e[t].type) && U(e, t, n) === n;
1194
+ }
1195
+ function fe(e, t, n) {
1196
+ let r = "", i = t;
1197
+ for (;;) {
1198
+ let t = pe(e[i]);
1199
+ if (t === null) return null;
1200
+ if (r += t, i++, i < n && e[i].type === "ENCODING_INDICATOR" && i++, i < n && e[i].type === "PLUS") {
1201
+ i++;
1202
+ continue;
1203
+ }
1204
+ break;
1205
+ }
1206
+ return i === n ? r : null;
1207
+ }
1208
+ function pe(e) {
1209
+ switch (e.type) {
1210
+ case "TSTR":
1211
+ case "RAWSTRING": return e.value;
1212
+ case "SQSTR": {
1213
+ let t = e._sqstrBytes;
1214
+ return t === void 0 ? null : z.decode(t);
1215
+ }
1216
+ case "BYTES_HEX": try {
1217
+ return z.decode(u(e.value));
1218
+ } catch {
1219
+ return null;
1220
+ }
1221
+ case "BYTES_B64": try {
1222
+ return z.decode(d(e.value));
1223
+ } catch {
1224
+ return null;
1225
+ }
1226
+ case "BYTES_HEX_ELIDED": return null;
1227
+ case "ELLIPSIS": return null;
1228
+ default: return null;
1229
+ }
1230
+ }
1231
+ function me(e, t) {
1232
+ let n = 0;
1233
+ for (; n < e.length && e[n] !== "'" && e[n] !== "`";) n++;
1234
+ if (n >= e.length) return e;
1235
+ let r = e[n], i = e.lastIndexOf(r);
1236
+ if (i <= n) return e;
1237
+ let a = e.slice(n + 1, i), o = t === "hash-only" ? he(a) : ge(a);
1238
+ return e.slice(0, n + 1) + o + e.slice(i);
1239
+ }
1240
+ function he(e) {
1241
+ let t = "", n = 0;
1242
+ for (; n < e.length;) {
1243
+ if (e[n] === "#") {
1244
+ for (; n < e.length && e[n] !== "\n";) n += e[n] === "\\" && n + 1 < e.length ? 2 : 1;
1245
+ continue;
1246
+ }
1247
+ t += e[n], n++;
1248
+ }
1249
+ return t;
1250
+ }
1251
+ function ge(e) {
1252
+ let t = "", n = 0;
1253
+ for (; n < e.length;) {
1254
+ let r = e[n], i = e[n + 1];
1255
+ if (r === "#" || r === "/" && i === "/") {
1256
+ for (n += r === "#" ? 1 : 2; n < e.length && e[n] !== "\n";) n += e[n] === "\\" && n + 1 < e.length ? 2 : 1;
1257
+ continue;
1258
+ }
1259
+ if (r === "/" && i === "*") {
1260
+ let t = e.indexOf("*/", n + 2);
1261
+ n = t === -1 ? e.length : t + 2;
1262
+ continue;
1263
+ }
1264
+ if (r === "/") {
1265
+ let t = n + 1;
1266
+ for (; t < e.length && e[t] !== "/";) t += e[t] === "\\" && t + 1 < e.length ? 2 : 1;
1267
+ n = t < e.length ? t + 1 : e.length;
1268
+ continue;
1269
+ }
1270
+ t += r, n++;
1271
+ }
1272
+ return t;
1273
+ }
1274
+ var _e = new TextDecoder("utf-8", { fatal: !0 });
1275
+ function G(e) {
1276
+ try {
1277
+ return _e.decode(e);
1278
+ } catch {
1279
+ return null;
1280
+ }
1281
+ }
1282
+ function ve(e, t) {
1283
+ for (let n = 0; n < e.length; n++) {
1284
+ let r = e.charCodeAt(n);
1285
+ if (r === t || r === 92 || r < 32 || r === 127 || r >= 8192 && (r === 8232 || r === 8233 || r >= 8203 && r <= 8205 || r === 65279)) return !0;
1286
+ }
1287
+ return !1;
1288
+ }
1289
+ function K(e, t) {
1290
+ let n = t.codePointAt(0);
1291
+ if (!ve(e, n)) return t + e + t;
1292
+ let r = t;
1293
+ for (let i of e) {
1294
+ let e = i.codePointAt(0);
1295
+ switch (e) {
1296
+ case n:
1297
+ r += `\\${t}`;
1298
+ break;
1299
+ case 92:
1300
+ r += "\\\\";
1301
+ break;
1302
+ case 10:
1303
+ r += "\\n";
1304
+ break;
1305
+ case 13:
1306
+ r += "\\r";
1307
+ break;
1308
+ case 9:
1309
+ r += "\\t";
1310
+ break;
1311
+ default: r += e < 32 || e === 127 || e === 8232 || e === 8233 || e === 8203 || e === 8204 || e === 8205 || e === 65279 ? `\\u${e.toString(16).padStart(4, "0")}` : i;
1312
+ }
1313
+ }
1314
+ return r + t;
1315
+ }
1316
+ function ye(e) {
1317
+ return K(e, "'");
1318
+ }
1319
+ function be(e) {
1320
+ return K(e, "'");
1321
+ }
1322
+ function xe(e) {
1323
+ return K(e, "\"");
1324
+ }
1325
+ var Se = new Intl.Segmenter("en", { granularity: "word" });
1326
+ function q(e) {
1327
+ let t = 0;
1328
+ for (let { isWordLike: n } of Se.segment(e)) if (n && (t++, t >= 2)) return !0;
1329
+ return !1;
1330
+ }
1331
+ function Ce(e) {
1332
+ if (isNaN(e)) return "NaN";
1333
+ if (!isFinite(e)) return e > 0 ? "Infinity" : "-Infinity";
1334
+ if (Object.is(e, -0)) return "-0.0";
1335
+ let t = e.toString();
1336
+ return t.includes(".") || t.includes("e") ? t : t + ".0";
1337
+ }
1338
+ function we(e, t, n, r) {
1339
+ if (r === "never") return "";
1340
+ let i = t ?? n;
1341
+ return r === "always" ? i === "half" ? "_1" : i === "single" ? "_2" : "_3" : t === void 0 || t === n ? "" : t === "half" ? "_1" : t === "single" ? "_2" : "_3";
1342
+ }
1343
+ function J(e) {
1344
+ return e <= 23n ? "i" : e <= 255n ? 0 : e <= 65535n ? 1 : e <= 4294967295n ? 2 : 3;
1345
+ }
1346
+ function Y(e, t, n) {
1347
+ let r = e?.encodingIndicators ?? "auto";
1348
+ return r === "never" ? "" : r === "always" ? `_${t ?? n()}` : t === void 0 ? "" : `_${t}`;
1349
+ }
1350
+ function X(e) {
1351
+ return e?.preserveComments !== void 0 || e?.comments !== void 0;
1352
+ }
1353
+ function Z(e) {
1354
+ return !X(e) || e?.preserveComments === !0 ? !1 : Q(e) === void 0;
1355
+ }
1356
+ function Q(e) {
1357
+ if (e?.preserveComments === !0) return;
1358
+ if (typeof e?.preserveComments == "string") return e.preserveComments;
1359
+ let t = e?.comments;
1360
+ return t === "strip" ? void 0 : t;
1361
+ }
1362
+ function Te(e, t, n, r, i) {
1363
+ if (!e?.preserveAppPrefix || t === void 0 || v(e) === null && /[\r\n]/.test(t)) return "normal";
1364
+ if (n === void 0) return r?.byteString && e?.preserveByteString === !1 || r?.textString && e?.preserveTextString === !1 || r?.rawString && e?.preserveRawString === !1 || r?.concatenation && e?.preserveConcatenation === !1 ? "normal" : "adjusted";
1365
+ let a = Z(e) || Q(e) !== void 0 || e?.preserveComments === !0 && v(e) === null, o = e?.encodingIndicators ?? "auto";
1366
+ return e?.preserveNumberFormat === !1 || r?.byteString && e?.preserveByteString === !1 || r?.textString && e?.preserveTextString === !1 || r?.rawString && e?.preserveRawString === !1 || r?.concatenation && e?.preserveConcatenation === !1 || o !== "auto" && i === !1 ? "structural" : o !== "auto" || a ? "source" : "verbatim";
1367
+ }
1368
+ function $(e, t, n) {
1369
+ let r = t > 0 ? e[t - 1] : "", i = n < e.length ? e[n] : "", a = (e) => e !== "" && !/[\s,]/.test(e);
1370
+ return a(r) && a(i) ? " " : "";
1371
+ }
1372
+ function Ee(e, t, n, r) {
1373
+ if (!X(t) || !n?.length) return e;
1374
+ let i = Z(t) || v(t) === null, a = Q(t), o = e, s = [...n].sort((e, t) => t.start - e.start);
1375
+ for (let e of s) {
1376
+ let t = r !== void 0 && e.start >= r ? -2 : 0, n = e.start + t, s = e.end + t, c = i ? $(o, n, s) : E(e, a);
1377
+ o = o.slice(0, n) + c + o.slice(s);
1378
+ }
1379
+ return o;
1380
+ }
1381
+ function De(e, t, n, r) {
1382
+ let i = [];
1383
+ if (X(t) && n?.length) {
1384
+ let r = Z(t) || v(t) === null, a = Q(t);
1385
+ for (let t of n) i.push({
1386
+ start: t.start,
1387
+ end: t.end,
1388
+ replacement: r ? $(e, t.start, t.end) : E(t, a)
1389
+ });
1390
+ }
1391
+ let a = t?.encodingIndicators ?? "auto";
1392
+ if (a !== "auto" && r) for (let e of r) i.push({
1393
+ start: e.start,
1394
+ end: e.end,
1395
+ replacement: a === "always" ? e.always : e.never
1396
+ });
1397
+ i.sort((e, t) => t.start - e.start || t.end - e.end);
1398
+ let o = e;
1399
+ for (let e of i) o = o.slice(0, e.start) + e.replacement + o.slice(e.end);
1400
+ return o;
1401
+ }
1402
+ function Oe(e, t, n, r, i) {
1403
+ let a = e, o;
1404
+ if ((n?.encodingIndicators ?? "auto") === "never" && r !== void 0) {
1405
+ let e = a.slice(0, r);
1406
+ /_[0-3i]$/.test(e) && (o = r - 2, a = e.slice(0, -2) + a.slice(r));
1407
+ }
1408
+ return a = Ee(a, n, i, o), a.replace(/_[0-3i]$/, "") + t;
1409
+ }
1410
+ //#endregion
1411
+ export { g as A, Y as C, w as D, j as E, u as F, e as I, c as M, o as N, O, l as P, T as S, ae as T, R as _, D as a, _ as b, xe as c, k as d, S as f, q as g, se as h, E as i, d as j, me as k, we as l, L as m, De as n, Te as o, y as p, J as r, be as s, Oe as t, Ce as u, x as v, v as w, M as x, b as y };
808
1412
 
809
- //# sourceMappingURL=tokenizer-CeuixxXi.js.map
1413
+ //# sourceMappingURL=serialize-utils-BuIZPaUc.js.map