@cbortech/cbor 0.26.8 → 0.27.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.ja.md +193 -28
  2. package/README.md +196 -29
  3. package/dist/ast/CborAppSeqResult.d.ts +58 -3
  4. package/dist/ast/CborArray.d.ts +2 -2
  5. package/dist/ast/CborByteString.d.ts +17 -1
  6. package/dist/ast/CborEmbeddedCBOR.d.ts +2 -2
  7. package/dist/ast/CborFloat.d.ts +2 -2
  8. package/dist/ast/CborIndefiniteByteString.d.ts +25 -1
  9. package/dist/ast/CborIndefiniteTextString.d.ts +17 -1
  10. package/dist/ast/CborItem.d.ts +340 -10
  11. package/dist/ast/CborMap.d.ts +2 -2
  12. package/dist/ast/CborNint.d.ts +1 -1
  13. package/dist/ast/CborTag.d.ts +30 -3
  14. package/dist/ast/CborTextString.d.ts +3 -2
  15. package/dist/ast/CborUint.d.ts +1 -1
  16. package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
  17. package/dist/ast/index.cjs +1 -1
  18. package/dist/ast/index.js +2 -2
  19. package/dist/cddl/index.cjs +1 -1
  20. package/dist/cddl/index.js +1 -1
  21. package/dist/cdn/index.cjs +2 -2
  22. package/dist/cdn/index.cjs.map +1 -1
  23. package/dist/cdn/index.js +18 -18
  24. package/dist/cdn/index.js.map +1 -1
  25. package/dist/cdn/serialize-utils.d.ts +237 -10
  26. package/dist/cdn/tokenizer.d.ts +12 -11
  27. package/dist/extensions/builtins.d.ts +5 -5
  28. package/dist/extensions/cri.d.ts +4 -4
  29. package/dist/extensions/dt.d.ts +4 -4
  30. package/dist/extensions/ip.d.ts +4 -4
  31. package/dist/extensions/types.d.ts +44 -5
  32. package/dist/index.cjs +3 -3
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.ts +1 -1
  35. package/dist/index.js +158 -158
  36. package/dist/index.js.map +1 -1
  37. package/dist/{mapEntries-Ci_dppP6.js → mapEntries-CCLaJSaJ.js} +1599 -1275
  38. package/dist/mapEntries-CCLaJSaJ.js.map +1 -0
  39. package/dist/mapEntries-CZZJScaj.cjs +13 -0
  40. package/dist/mapEntries-CZZJScaj.cjs.map +1 -0
  41. package/dist/{schema-y8G5mDIS.js → schema-DN9inJny.js} +294 -294
  42. package/dist/{schema-y8G5mDIS.js.map → schema-DN9inJny.js.map} +1 -1
  43. package/dist/schema-zsg5yCPK.cjs +63 -0
  44. package/dist/{schema-DgnkH0P6.cjs.map → schema-zsg5yCPK.cjs.map} +1 -1
  45. package/dist/serialize-utils-DhlW61ZX.cjs +37 -0
  46. package/dist/serialize-utils-DhlW61ZX.cjs.map +1 -0
  47. package/dist/{tokenizer-N-vAvRdj.js → serialize-utils-h-CVB9rg.js} +636 -358
  48. package/dist/serialize-utils-h-CVB9rg.js.map +1 -0
  49. package/dist/types.d.ts +508 -58
  50. package/dist/utils/base64.d.ts +1 -1
  51. package/dist/utils/hexfloat.d.ts +11 -3
  52. package/dist/utils/strip-comments.d.ts +1 -1
  53. package/package.json +13 -12
  54. package/dist/mapEntries-BJzyBUH5.cjs +0 -13
  55. package/dist/mapEntries-BJzyBUH5.cjs.map +0 -1
  56. package/dist/mapEntries-Ci_dppP6.js.map +0 -1
  57. package/dist/schema-DgnkH0P6.cjs +0 -63
  58. package/dist/tokenizer-BD08xbyd.cjs +0 -36
  59. package/dist/tokenizer-BD08xbyd.cjs.map +0 -1
  60. package/dist/tokenizer-N-vAvRdj.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { E as e } from "./tokenizer-N-vAvRdj.js";
2
- import { A as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, T as d, _ as f, b as p, g as m, h, j as g, k as ee, u as te, v as ne, w as re, x as ie, y as _ } from "./mapEntries-Ci_dppP6.js";
1
+ import { F as e, j as t } from "./serialize-utils-h-CVB9rg.js";
2
+ import { A as n, C as r, D as i, E as a, F as o, I as s, M as c, N as l, O as u, P as d, T as f, _ as p, b as m, g as h, h as g, j as _, k as ee, u as v, v as te, w as ne, y } from "./mapEntries-CCLaJSaJ.js";
3
3
  //#region src/cddl/errors.ts
4
- var v = class extends SyntaxError {
4
+ var b = class extends SyntaxError {
5
5
  offset;
6
6
  line;
7
7
  column;
@@ -10,20 +10,20 @@ var v = class extends SyntaxError {
10
10
  let n = t?.line === void 0 ? "" : ` at line ${t.line}, column ${t.column}`;
11
11
  super(`CDDL parse error${n}: ${e}`), this.name = "CddlSyntaxError", this.offset = t?.offset, this.line = t?.line, this.column = t?.column, this.endOffset = t?.endOffset;
12
12
  }
13
- }, ae = class extends Error {
13
+ }, re = class extends Error {
14
14
  errors;
15
15
  warnings;
16
16
  constructor(e, t = []) {
17
17
  let n = e[0], r = n?.path ? ` at ${n.path}` : "", i = e.length > 1 ? ` (and ${e.length - 1} more)` : "";
18
18
  super(`CDDL validation failed${r}: ${n?.message ?? "unknown"}${i}`), this.name = "CddlMismatchError", this.errors = e, this.warnings = t;
19
19
  }
20
- }, oe = class extends Error {
20
+ }, ie = class extends Error {
21
21
  warnings;
22
22
  constructor(e) {
23
23
  let t = e[0], n = e.length > 1 ? ` (and ${e.length - 1} more)` : "";
24
24
  super(`CDDL semantic error: ${t?.message ?? "unknown"}${n}`), this.name = "CddlSemanticError", this.warnings = e;
25
25
  }
26
- }, se = new TextEncoder(), y = (e) => e >= "0" && e <= "9", b = (e) => y(e) || e >= "a" && e <= "f" || e >= "A" && e <= "F", x = (e) => e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "@" || e === "_" || e === "$", ce = (e) => e >= 160 && e <= 55295 || e >= 57344 && e <= 1114109, le = class {
26
+ }, ae = new TextEncoder(), x = (e) => e >= "0" && e <= "9", S = (e) => x(e) || e >= "a" && e <= "f" || e >= "A" && e <= "F", C = (e) => e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "@" || e === "_" || e === "$", oe = (e) => e >= 160 && e <= 55295 || e >= 57344 && e <= 1114109, se = class {
27
27
  input;
28
28
  pos = 0;
29
29
  line = 1;
@@ -44,7 +44,7 @@ var v = class extends SyntaxError {
44
44
  return this.pos++, e === "\n" ? (this.line++, this.col = 1) : this.col++, e;
45
45
  }
46
46
  _fail(e, t, n) {
47
- throw new v(e, {
47
+ throw new b(e, {
48
48
  offset: this.pos,
49
49
  line: t ?? this.line,
50
50
  column: n ?? this.col
@@ -100,11 +100,11 @@ var v = class extends SyntaxError {
100
100
  let e = this.pos, t = this.line, n = this.col;
101
101
  if (this._eof()) return this._make("EOF", "", e, t, n);
102
102
  let r = this._ch();
103
- if (x(r)) {
103
+ if (C(r)) {
104
104
  let r = this._scanIdText();
105
105
  return (r === "h" || r === "b64") && this._ch() === "'" ? this._scanBytes(r, e, t, n) : this._make("ID", r, e, t, n);
106
106
  }
107
- if (y(r) || r === "-") return this._scanNumber(e, t, n);
107
+ if (x(r) || r === "-") return this._scanNumber(e, t, n);
108
108
  if (r === "\"") return this._scanText(e, t, n);
109
109
  if (r === "'") return this._scanBytes("", e, t, n);
110
110
  if (r === "#") return this._scanHash(e, t, n);
@@ -113,7 +113,7 @@ var v = class extends SyntaxError {
113
113
  case "/": return this._advance(), this._ch() === "/" ? (this._advance(), this._ch() === "=" ? (this._advance(), this._make("DSLASH_EQ", "//=", e, t, n)) : this._make("DSLASH", "//", e, t, n)) : this._ch() === "=" ? (this._advance(), this._make("SLASH_EQ", "/=", e, t, n)) : this._make("SLASH", "/", e, t, n);
114
114
  case ".": {
115
115
  if (this._advance(), this._ch() === ".") return this._advance(), this._ch() === "." ? (this._advance(), this._make("RANGE_EXCL", "...", e, t, n)) : this._make("RANGE_INCL", "..", e, t, n);
116
- x(this._ch()) || this._fail(`expected a control operator name after '.' (e.g. .size), got ${this._eof() ? "end of input" : JSON.stringify(this._ch())}`, t, n);
116
+ C(this._ch()) || this._fail(`expected a control operator name after '.' (e.g. .size), got ${this._eof() ? "end of input" : JSON.stringify(this._ch())}`, t, n);
117
117
  let r = this._scanIdText();
118
118
  return this._make("CTLOP", r, e, t, n);
119
119
  }
@@ -140,7 +140,7 @@ var v = class extends SyntaxError {
140
140
  let e = this.pos;
141
141
  for (this._advance();;) {
142
142
  let e = this._ch();
143
- if (x(e) || y(e)) {
143
+ if (C(e) || x(e)) {
144
144
  this._advance();
145
145
  continue;
146
146
  }
@@ -148,7 +148,7 @@ var v = class extends SyntaxError {
148
148
  let e = this.pos;
149
149
  for (; this.input[e] === "-" || this.input[e] === ".";) e++;
150
150
  let t = this.input[e] ?? "";
151
- if (!(x(t) || y(t))) break;
151
+ if (!(C(t) || x(t))) break;
152
152
  for (; this.pos <= e;) this._advance();
153
153
  continue;
154
154
  }
@@ -157,27 +157,27 @@ var v = class extends SyntaxError {
157
157
  return this.input.slice(e, this.pos);
158
158
  }
159
159
  _scanNumber(e, t, n) {
160
- this._ch() === "-" && this._advance(), y(this._ch()) || this._fail("expected a digit after '-'", t, n);
160
+ this._ch() === "-" && this._advance(), x(this._ch()) || this._fail("expected a digit after '-'", t, n);
161
161
  let r = !1;
162
162
  if (this._ch() === "0" && /[xX]/.test(this.input[this.pos + 1] ?? "")) {
163
- for (this._advance(), this._advance(), b(this._ch()) || this._fail("expected hex digits after 0x", t, n); b(this._ch());) this._advance();
164
- if (this._ch() === "." && b(this.input[this.pos + 1] ?? "") && this.input[this.pos + 1] !== void 0) {
165
- for (this._advance(); b(this._ch());) this._advance();
163
+ for (this._advance(), this._advance(), S(this._ch()) || this._fail("expected hex digits after 0x", t, n); S(this._ch());) this._advance();
164
+ if (this._ch() === "." && S(this.input[this.pos + 1] ?? "") && this.input[this.pos + 1] !== void 0) {
165
+ for (this._advance(); S(this._ch());) this._advance();
166
166
  /[pP]/.test(this._ch()) || this._fail("hexadecimal fraction requires a 'p' exponent (hexfloat)", t, n);
167
167
  }
168
168
  if (/[pP]/.test(this._ch())) {
169
- for (this._advance(), (this._ch() === "+" || this._ch() === "-") && this._advance(), y(this._ch()) || this._fail("expected exponent digits after 'p'", t, n); y(this._ch());) this._advance();
169
+ for (this._advance(), (this._ch() === "+" || this._ch() === "-") && this._advance(), x(this._ch()) || this._fail("expected exponent digits after 'p'", t, n); x(this._ch());) this._advance();
170
170
  r = !0;
171
171
  }
172
172
  } else if (this._ch() === "0" && /[bB]/.test(this.input[this.pos + 1] ?? "")) for (this._advance(), this._advance(), /[01]/.test(this._ch()) || this._fail("expected binary digits after 0b", t, n); /[01]/.test(this._ch());) this._advance();
173
173
  else {
174
- for (this._ch() === "0" && y(this.input[this.pos + 1] ?? "") && this._fail("leading zeros are not allowed in CDDL numbers", t, n); y(this._ch());) this._advance();
175
- if (this._ch() === "." && y(this.input[this.pos + 1] ?? "")) {
176
- for (this._advance(); y(this._ch());) this._advance();
174
+ for (this._ch() === "0" && x(this.input[this.pos + 1] ?? "") && this._fail("leading zeros are not allowed in CDDL numbers", t, n); x(this._ch());) this._advance();
175
+ if (this._ch() === "." && x(this.input[this.pos + 1] ?? "")) {
176
+ for (this._advance(); x(this._ch());) this._advance();
177
177
  r = !0;
178
178
  }
179
179
  if (/[eE]/.test(this._ch())) {
180
- for (this._advance(), (this._ch() === "+" || this._ch() === "-") && this._advance(), y(this._ch()) || this._fail("expected exponent digits after 'e'", t, n); y(this._ch());) this._advance();
180
+ for (this._advance(), (this._ch() === "+" || this._ch() === "-") && this._advance(), x(this._ch()) || this._fail("expected exponent digits after 'e'", t, n); x(this._ch());) this._advance();
181
181
  r = !0;
182
182
  }
183
183
  }
@@ -186,39 +186,39 @@ var v = class extends SyntaxError {
186
186
  }
187
187
  _scanUintRaw() {
188
188
  let e = this.pos;
189
- if (y(this._ch()) || this._fail("expected an unsigned integer head-number"), this._ch() === "0" && /[xX]/.test(this.input[this.pos + 1] ?? "")) for (this._advance(), this._advance(), b(this._ch()) || this._fail("expected hex digits after 0x"); b(this._ch());) this._advance();
189
+ if (x(this._ch()) || this._fail("expected an unsigned integer head-number"), this._ch() === "0" && /[xX]/.test(this.input[this.pos + 1] ?? "")) for (this._advance(), this._advance(), S(this._ch()) || this._fail("expected hex digits after 0x"); S(this._ch());) this._advance();
190
190
  else if (this._ch() === "0" && /[bB]/.test(this.input[this.pos + 1] ?? "")) for (this._advance(), this._advance(), /[01]/.test(this._ch()) || this._fail("expected binary digits after 0b"); /[01]/.test(this._ch());) this._advance();
191
- else for (this._ch() === "0" && y(this.input[this.pos + 1] ?? "") && this._fail("leading zeros are not allowed in CDDL numbers"); y(this._ch());) this._advance();
191
+ else for (this._ch() === "0" && x(this.input[this.pos + 1] ?? "") && this._fail("leading zeros are not allowed in CDDL numbers"); x(this._ch());) this._advance();
192
192
  return this.input.slice(e, this.pos);
193
193
  }
194
194
  _scanHash(e, t, n) {
195
195
  this._advance();
196
196
  let r = {};
197
- return y(this._ch()) && (r.hashMajor = this._advance().charCodeAt(0) - 48, this._ch() === "." && (this.input[this.pos + 1] === "<" ? (this._advance(), r.hashAIExpr = !0) : (this._advance(), r.hashAI = BigInt(this._scanUintRaw())))), this._make("HASH", this.input.slice(e, this.pos), e, t, n, r);
197
+ return x(this._ch()) && (r.hashMajor = this._advance().charCodeAt(0) - 48, this._ch() === "." && (this.input[this.pos + 1] === "<" ? (this._advance(), r.hashAIExpr = !0) : (this._advance(), r.hashAI = BigInt(this._scanUintRaw())))), this._make("HASH", this.input.slice(e, this.pos), e, t, n, r);
198
198
  }
199
199
  _scanText(e, t, n) {
200
200
  let r = this._readStringBody("\"");
201
201
  return this._make("TSTR", r, e, t, n);
202
202
  }
203
- _scanBytes(t, n, r, i) {
204
- let a = this._readStringBody("'"), o;
205
- if (t === "") o = se.encode(a);
203
+ _scanBytes(n, r, i, a) {
204
+ let o = this._readStringBody("'"), s;
205
+ if (n === "") s = ae.encode(o);
206
206
  else {
207
- let s = ue(a);
207
+ let c = ce(o);
208
208
  try {
209
- o = t === "h" ? e(s) : ie(s);
209
+ s = n === "h" ? e(c) : t(c);
210
210
  } catch (e) {
211
- throw !(e instanceof SyntaxError) || e instanceof v ? e : new v(e.message, {
212
- offset: n,
213
- line: r,
214
- column: i,
211
+ throw !(e instanceof SyntaxError) || e instanceof b ? e : new b(e.message, {
212
+ offset: r,
213
+ line: i,
214
+ column: a,
215
215
  endOffset: this.pos
216
216
  });
217
217
  }
218
218
  }
219
- return this._make("BYTES", a, n, r, i, {
220
- qualifier: t,
221
- bytes: o
219
+ return this._make("BYTES", o, r, i, a, {
220
+ qualifier: n,
221
+ bytes: s
222
222
  });
223
223
  }
224
224
  _readStringBody(e) {
@@ -273,21 +273,21 @@ var v = class extends SyntaxError {
273
273
  continue;
274
274
  }
275
275
  let i = this.input.codePointAt(this.pos);
276
- (i < 32 || i >= 127 && i <= 159) && this._fail(`unescaped control character U+${i.toString(16).padStart(4, "0").toUpperCase()} is not allowed in string literals`), i > 126 && !ce(i) && this._fail(`code point U+${i.toString(16).toUpperCase()} is not allowed in CDDL source`), this._advance(), i > 65535 && this._advance(), n += String.fromCodePoint(i);
276
+ (i < 32 || i >= 127 && i <= 159) && this._fail(`unescaped control character U+${i.toString(16).padStart(4, "0").toUpperCase()} is not allowed in string literals`), i > 126 && !oe(i) && this._fail(`code point U+${i.toString(16).toUpperCase()} is not allowed in CDDL source`), this._advance(), i > 65535 && this._advance(), n += String.fromCodePoint(i);
277
277
  }
278
278
  }
279
279
  _readUnicodeEscape(e, t) {
280
280
  if (this._ch() === "{") {
281
281
  this._advance();
282
282
  let n = "";
283
- for (; b(this._ch());) n += this._advance();
283
+ for (; S(this._ch());) n += this._advance();
284
284
  n.length === 0 && this._fail("\\u{} escape requires at least one hex digit", e, t), this._ch() !== "}" && this._fail("expected '}' to close \\u{...} escape", e, t), this._advance();
285
285
  let r = parseInt(n, 16);
286
286
  return r > 1114111 && this._fail(`\\u{${n}} is above the Unicode code point maximum U+10FFFF`, e, t), r >= 55296 && r <= 57343 && this._fail(`\\u{${n}} is a surrogate code point, not a Unicode scalar value`, e, t), String.fromCodePoint(r);
287
287
  }
288
288
  let n = () => {
289
289
  let n = "";
290
- for (let r = 0; r < 4; r++) b(this._ch()) || this._fail("\\u escape requires four hex digits", e, t), n += this._advance();
290
+ for (let r = 0; r < 4; r++) S(this._ch()) || this._fail("\\u escape requires four hex digits", e, t), n += this._advance();
291
291
  return parseInt(n, 16);
292
292
  }, r = n();
293
293
  if (r >= 55296 && r <= 56319) {
@@ -298,7 +298,7 @@ var v = class extends SyntaxError {
298
298
  return r >= 56320 && r <= 57343 && this._fail("lone low surrogate \\u escape", e, t), String.fromCodePoint(r);
299
299
  }
300
300
  };
301
- function ue(e) {
301
+ function ce(e) {
302
302
  let t = "", n = 0;
303
303
  for (; n < e.length;) {
304
304
  let r = e[n];
@@ -316,21 +316,21 @@ function ue(e) {
316
316
  }
317
317
  //#endregion
318
318
  //#region src/cddl/parser.ts
319
- function S(e) {
320
- let t = new le(e);
319
+ function w(e) {
320
+ let t = new se(e);
321
321
  return {
322
- rules: new fe(t).parse(),
322
+ rules: new ue(t).parse(),
323
323
  comments: t.comments
324
324
  };
325
325
  }
326
- var de = /* @__PURE__ */ new Set([
326
+ var le = /* @__PURE__ */ new Set([
327
327
  "SLASH",
328
328
  "RANGE_INCL",
329
329
  "RANGE_EXCL",
330
330
  "CTLOP",
331
331
  "ARROW",
332
332
  "CARET"
333
- ]), fe = class {
333
+ ]), ue = class {
334
334
  t;
335
335
  buf = [];
336
336
  constructor(e) {
@@ -348,7 +348,7 @@ var de = /* @__PURE__ */ new Set([
348
348
  return n.type !== e && this._fail(`expected ${t}`, n), this.consume();
349
349
  }
350
350
  _fail(e, t) {
351
- throw new v(`${e}, got ${t.type === "EOF" ? "end of input" : `${JSON.stringify(t.raw)}`}`, {
351
+ throw new b(`${e}, got ${t.type === "EOF" ? "end of input" : `${JSON.stringify(t.raw)}`}`, {
352
352
  offset: t.offset,
353
353
  endOffset: t.endOffset,
354
354
  line: t.line,
@@ -412,7 +412,7 @@ var de = /* @__PURE__ */ new Set([
412
412
  let e = this.peek().offset, t = this.tryParseOccur();
413
413
  if (this.peek().type === "LPAREN") {
414
414
  let n = this.consume(), r = this.parseGroup("RPAREN"), i = this.consume();
415
- if (de.has(this.peek().type)) {
415
+ if (le.has(this.peek().type)) {
416
416
  let a = this.groupAsParenType(r, n, i), o = this.continueType1(a);
417
417
  return this.finishEntryFromType1(e, t, o);
418
418
  }
@@ -734,21 +734,21 @@ var de = /* @__PURE__ */ new Set([
734
734
  end: n.endOffset
735
735
  };
736
736
  }
737
- }, pe = "any = #\n\nuint = #0\nnint = #1\nint = uint / nint\n\nbstr = #2\nbytes = bstr\ntstr = #3\ntext = tstr\n\ntdate = #6.0(tstr)\ntime = #6.1(number)\nnumber = int / float\nbiguint = #6.2(bstr)\nbignint = #6.3(bstr)\nbigint = biguint / bignint\ninteger = int / bigint\nunsigned = uint / biguint\ndecfrac = #6.4([e10: int, m: integer])\nbigfloat = #6.5([e2: int, m: integer])\neb64url = #6.21(any)\neb64legacy = #6.22(any)\neb16 = #6.23(any)\nencoded-cbor = #6.24(bstr)\nuri = #6.32(tstr)\nb64url = #6.33(tstr)\nb64legacy = #6.34(tstr)\nregexp = #6.35(tstr)\nmime-message = #6.36(tstr)\ncbor-any = #6.55799(any)\n\nfloat16 = #7.25\nfloat32 = #7.26\nfloat64 = #7.27\nfloat16-32 = float16 / float32\nfloat32-64 = float32 / float64\nfloat = float16-32 / float64\n\nfalse = #7.20\ntrue = #7.21\nbool = false / true\nnil = #7.22\nnull = nil\nundefined = #7.23\n", C;
738
- function w() {
739
- if (!C) {
740
- C = /* @__PURE__ */ new Map();
741
- for (let e of S(pe).rules) C.set(e.name, e);
737
+ }, de = "any = #\n\nuint = #0\nnint = #1\nint = uint / nint\n\nbstr = #2\nbytes = bstr\ntstr = #3\ntext = tstr\n\ntdate = #6.0(tstr)\ntime = #6.1(number)\nnumber = int / float\nbiguint = #6.2(bstr)\nbignint = #6.3(bstr)\nbigint = biguint / bignint\ninteger = int / bigint\nunsigned = uint / biguint\ndecfrac = #6.4([e10: int, m: integer])\nbigfloat = #6.5([e2: int, m: integer])\neb64url = #6.21(any)\neb64legacy = #6.22(any)\neb16 = #6.23(any)\nencoded-cbor = #6.24(bstr)\nuri = #6.32(tstr)\nb64url = #6.33(tstr)\nb64legacy = #6.34(tstr)\nregexp = #6.35(tstr)\nmime-message = #6.36(tstr)\ncbor-any = #6.55799(any)\n\nfloat16 = #7.25\nfloat32 = #7.26\nfloat64 = #7.27\nfloat16-32 = float16 / float32\nfloat32-64 = float32 / float64\nfloat = float16-32 / float64\n\nfalse = #7.20\ntrue = #7.21\nbool = false / true\nnil = #7.22\nnull = nil\nundefined = #7.23\n", T;
738
+ function E() {
739
+ if (!T) {
740
+ T = /* @__PURE__ */ new Map();
741
+ for (let e of w(de).rules) T.set(e.name, e);
742
742
  }
743
- return C;
743
+ return T;
744
744
  }
745
745
  //#endregion
746
746
  //#region src/cddl/writer.ts
747
- var me = {
747
+ var fe = {
748
748
  leading: [],
749
749
  trailing: []
750
750
  };
751
- function he(e, t) {
751
+ function pe(e, t) {
752
752
  let n = {
753
753
  unit: t?.indent === void 0 ? null : typeof t.indent == "string" ? t.indent : " ".repeat(t.indent),
754
754
  notes: null,
@@ -756,18 +756,18 @@ function he(e, t) {
756
756
  tail: []
757
757
  };
758
758
  if (t?.preserveComments && t.comments !== void 0 && t.comments.length > 0 && t.source !== void 0) {
759
- let r = ge(e, t.comments, t.source);
759
+ let r = me(e, t.comments, t.source);
760
760
  n.notes = r.notes, n.endNotes = r.endNotes, n.tail = r.tail;
761
761
  }
762
762
  let r = [], i = !1;
763
763
  e.forEach((e, t) => {
764
- let { text: a, multiline: o } = ve(e, n);
764
+ let { text: a, multiline: o } = _e(e, n);
765
765
  t > 0 && n.unit !== null && (o || i) && r.push(""), r.push(a), i = o;
766
766
  });
767
767
  for (let e of n.tail) r.push(`;${e}`);
768
768
  return r.length === 0 ? "" : r.join("\n") + "\n";
769
769
  }
770
- function ge(e, t, n) {
770
+ function me(e, t, n) {
771
771
  let r = [0];
772
772
  for (let e = 0; e < n.length; e++) n.charCodeAt(e) === 10 && r.push(e + 1);
773
773
  let i = (e) => {
@@ -857,9 +857,9 @@ function ge(e, t, n) {
857
857
  tail: h
858
858
  };
859
859
  }
860
- var T = (e, t) => e.notes?.get(t) ?? me, _e = (e) => e.trailing.length === 0 ? "" : " " + e.trailing.map((e) => `;${e}`).join(" ");
861
- function ve(e, t) {
862
- let n = T(t, e), r = T(t, e.body), i = e.generics ? `<${e.generics.join(", ")}>` : "", a = `${e.name}${i} ${e.assign}`, o = _e({
860
+ var he = (e, t) => e.notes?.get(t) ?? fe, ge = (e) => e.trailing.length === 0 ? "" : " " + e.trailing.map((e) => `;${e}`).join(" ");
861
+ function _e(e, t) {
862
+ let n = he(t, e), r = he(t, e.body), i = e.generics ? `<${e.generics.join(", ")}>` : "", a = `${e.name}${i} ${e.assign}`, o = ge({
863
863
  leading: [],
864
864
  trailing: [...r.trailing, ...n.trailing]
865
865
  }), s, c = n.leading;
@@ -868,9 +868,9 @@ function ve(e, t) {
868
868
  s = [
869
869
  a,
870
870
  ...r.leading.map((e) => `${n};${e}`),
871
- `${n}${E(e.body, t, 1)}${o}`
871
+ `${n}${D(e.body, t, 1)}${o}`
872
872
  ].join("\n");
873
- } else r.leading.length > 0 && (c = [...c, ...r.leading]), s = `${a} ${E(e.body, t, 0)}${o}`;
873
+ } else r.leading.length > 0 && (c = [...c, ...r.leading]), s = `${a} ${D(e.body, t, 0)}${o}`;
874
874
  let l = s.includes("\n");
875
875
  return c.length === 0 ? {
876
876
  text: s,
@@ -880,80 +880,80 @@ function ve(e, t) {
880
880
  multiline: l
881
881
  };
882
882
  }
883
- function E(e, t, n) {
884
- let r = e.occur ? `${ye(e.occur)} ` : "";
885
- return e.kind === "entry-group" ? `${r}${D(e.group, t, n, "(", ")")}` : `${r}${e.memberKey ? `${be(e.memberKey, t, n)} ` : ""}${O(e.value, t, n)}`;
883
+ function D(e, t, n) {
884
+ let r = e.occur ? `${ve(e.occur)} ` : "";
885
+ return e.kind === "entry-group" ? `${r}${O(e.group, t, n, "(", ")")}` : `${r}${e.memberKey ? `${ye(e.memberKey, t, n)} ` : ""}${k(e.value, t, n)}`;
886
886
  }
887
- function ye(e) {
887
+ function ve(e) {
888
888
  return e.marker === "*" ? `${e.min ?? ""}*${e.max ?? ""}` : e.marker;
889
889
  }
890
- function be(e, t, n) {
890
+ function ye(e, t, n) {
891
891
  switch (e.kind) {
892
892
  case "bareword": return `${e.key}:`;
893
893
  case "value": return `${e.key.raw}:`;
894
- case "type1": return `${xe(e.key, t, n)} ${e.cut ? "^ " : ""}=>`;
894
+ case "type1": return `${be(e.key, t, n)} ${e.cut ? "^ " : ""}=>`;
895
895
  }
896
896
  }
897
- function D(e, t, n, r, i) {
897
+ function O(e, t, n, r, i) {
898
898
  let a = e.choices.reduce((e, t) => e + t.length, 0), o = t.endNotes?.get(e) ?? [], s = o.length > 0 || t.notes !== null && e.choices.some((e) => e.some((e) => t.notes.has(e)));
899
- if (!(t.unit !== null && (a > 1 || e.choices.length > 1 || s))) return `${r}${e.choices.map((e) => e.map((e) => E(e, t, n)).join(", ")).join(" // ") + (e.trailingComma ? "," : "")}${i}`;
899
+ if (!(t.unit !== null && (a > 1 || e.choices.length > 1 || s))) return `${r}${e.choices.map((e) => e.map((e) => D(e, t, n)).join(", ")).join(" // ") + (e.trailingComma ? "," : "")}${i}`;
900
900
  let c = t.unit, l = c.repeat(n + 1), u = [r];
901
901
  e.choices.forEach((r, i) => {
902
902
  i > 0 && u.push(`${l}//`), r.forEach((a, o) => {
903
- let s = T(t, a);
903
+ let s = he(t, a);
904
904
  for (let e of s.leading) u.push(`${l};${e}`);
905
- let c = !(i === e.choices.length - 1 && o === r.length - 1) || e.trailingComma ? "," : "";
906
- u.push(`${l}${E(a, t, n + 1)}${c}${_e(s)}`);
905
+ let c = i !== e.choices.length - 1 || o !== r.length - 1 || e.trailingComma ? "," : "";
906
+ u.push(`${l}${D(a, t, n + 1)}${c}${ge(s)}`);
907
907
  });
908
908
  });
909
909
  for (let e of o) u.push(`${l};${e}`);
910
910
  return u.push(`${c.repeat(n)}${i}`), u.join("\n");
911
911
  }
912
- function O(e, t, n) {
913
- return e.alternatives.map((e) => xe(e, t, n)).join(" / ");
912
+ function k(e, t, n) {
913
+ return e.alternatives.map((e) => be(e, t, n)).join(" / ");
914
914
  }
915
- function xe(e, t, n) {
916
- let r = Ce(e.target, t, n);
915
+ function be(e, t, n) {
916
+ let r = Se(e.target, t, n);
917
917
  if (!e.op || !e.controller) return r;
918
- let i = Ce(e.controller, t, n);
918
+ let i = Se(e.controller, t, n);
919
919
  return e.op.kind === "range" ? `${r}${e.op.inclusive ? ".." : "..."}${i}` : `${r} .${e.op.name} ${i}`;
920
920
  }
921
- function Se(e, t, n) {
922
- let r = e.genericArgs ? `<${e.genericArgs.map((e) => xe(e, t, n)).join(", ")}>` : "";
921
+ function xe(e, t, n) {
922
+ let r = e.genericArgs ? `<${e.genericArgs.map((e) => be(e, t, n)).join(", ")}>` : "";
923
923
  return `${e.name}${r}`;
924
924
  }
925
- function Ce(e, t, n) {
925
+ function Se(e, t, n) {
926
926
  switch (e.kind) {
927
927
  case "value": return e.raw;
928
- case "ref": return Se(e, t, n);
929
- case "paren": return `(${O(e.type, t, n)})`;
930
- case "map": return D(e.group, t, n, "{", "}");
931
- case "array": return D(e.group, t, n, "[", "]");
932
- case "unwrap": return `~${Se(e.ref, t, n)}`;
933
- case "enum": return e.group.kind === "ref" ? `&${Se(e.group, t, n)}` : `&${D(e.group, t, n, "(", ")")}`;
934
- case "tagged": return `${e.raw ?? (typeof e.tag == "object" ? `#6.<${O(e.tag, t, n)}>` : `#6${e.tag === void 0 ? "" : `.${e.tag}`}`)}(${O(e.item, t, n)})`;
935
- case "major": return e.raw === void 0 ? typeof e.ai == "object" ? `#${e.major}.<${O(e.ai, t, n)}>` : `#${e.major}${e.ai === void 0 ? "" : `.${e.ai}`}` : e.raw;
928
+ case "ref": return xe(e, t, n);
929
+ case "paren": return `(${k(e.type, t, n)})`;
930
+ case "map": return O(e.group, t, n, "{", "}");
931
+ case "array": return O(e.group, t, n, "[", "]");
932
+ case "unwrap": return `~${xe(e.ref, t, n)}`;
933
+ case "enum": return e.group.kind === "ref" ? `&${xe(e.group, t, n)}` : `&${O(e.group, t, n, "(", ")")}`;
934
+ case "tagged": return `${e.raw ?? (typeof e.tag == "object" ? `#6.<${k(e.tag, t, n)}>` : `#6${e.tag === void 0 ? "" : `.${e.tag}`}`)}(${k(e.item, t, n)})`;
935
+ case "major": return e.raw === void 0 ? typeof e.ai == "object" ? `#${e.major}.<${k(e.ai, t, n)}>` : `#${e.major}${e.ai === void 0 ? "" : `.${e.ai}`}` : e.raw;
936
936
  case "any": return "#";
937
937
  }
938
938
  }
939
939
  //#endregion
940
940
  //#region src/cddl/equal.ts
941
- function k(e) {
942
- if (e instanceof i || e instanceof u) return e.value;
943
- if (e instanceof ne || e instanceof f) return e.bigValue;
941
+ function Ce(e) {
942
+ if (e instanceof d || e instanceof l) return e.value;
943
+ if (e instanceof te || e instanceof p) return e.bigValue;
944
944
  }
945
945
  function A(e) {
946
- if (e instanceof h) return e.value;
947
- if (e instanceof l) return e.chunks.map((e) => e.value).join("");
946
+ if (e instanceof g) return e.value;
947
+ if (e instanceof i) return e.chunks.map((e) => e.value).join("");
948
948
  }
949
949
  function j(e) {
950
- if (e instanceof t) return e.value;
951
- if (e instanceof ee) {
950
+ if (e instanceof ee) return e.value;
951
+ if (e instanceof u) {
952
952
  let t = e.chunks.map((e) => e.value), n = t.reduce((e, t) => e + t.length, 0), r = new Uint8Array(n), i = 0;
953
953
  for (let e of t) r.set(e, i), i += e.length;
954
954
  return r;
955
955
  }
956
- if (e instanceof re) {
956
+ if (e instanceof r) {
957
957
  let t = e.items.map((e) => e.toCBOR()), n = t.reduce((e, t) => e + t.length, 0), r = new Uint8Array(n), i = 0;
958
958
  for (let e of t) r.set(e, i), i += e.length;
959
959
  return r;
@@ -973,38 +973,38 @@ var Te = new TextEncoder(), Ee = new TextDecoder("utf-8", { fatal: !0 }), M = (e
973
973
  end: 0,
974
974
  ...e
975
975
  }), De = (e) => {
976
- let t = k(e);
976
+ let t = Ce(e);
977
977
  if (t !== void 0) return t;
978
- if (e instanceof s) return e.value;
978
+ if (e instanceof _) return e.value;
979
979
  }, N = (e) => e.type === "int" || e.type === "float" ? e.value : void 0, Oe = (e, t) => {
980
980
  if (typeof e == "bigint" && typeof t == "bigint") return e < t ? -1 : +(e > t);
981
981
  let n = Number(e), r = Number(t);
982
982
  return n < r ? -1 : n > r ? 1 : n === r ? 0 : NaN;
983
- }, ke = (e, t, n, r, a, o) => {
984
- if (!e.matchType2(t, n, a)) return !1;
985
- let s = (n) => e.matchType2(e.uint(n), r, a) ? !0 : e.fail(a, t, o, `size ${n} does not match the .size constraint`), c = A(t);
986
- if (c !== void 0) return s(Te.encode(c).length);
987
- let l = j(t);
988
- if (l !== void 0) return s(l.length);
989
- if (t instanceof i) {
983
+ }, ke = (e, t, n, r, i, a) => {
984
+ if (!e.matchType2(t, n, i)) return !1;
985
+ let o = (n) => e.matchType2(e.uint(n), r, i) ? !0 : e.fail(i, t, a, `size ${n} does not match the .size constraint`), s = A(t);
986
+ if (s !== void 0) return o(Te.encode(s).length);
987
+ let c = j(t);
988
+ if (c !== void 0) return o(c.length);
989
+ if (t instanceof d) {
990
990
  let n = 0;
991
991
  for (let e = t.value; e > 0n; e >>= 8n) n++;
992
- let i = e.existsIntGE(r, BigInt(n));
993
- if (i !== void 0) return i ? !0 : e.fail(a, t, o, `${t.value} does not fit the .size constraint`);
994
- e.warnOnce(".size controller could not be analyzed; searching a bounded window of byte counts", o);
995
- for (let t = n; t <= n + 64; t++) if (e.matchType2(e.uint(t), r, a)) return !0;
996
- return e.fail(a, t, o, `${t.value} does not fit the .size constraint`);
997
- }
998
- return e.fail(a, t, o, ".size applies to strings and unsigned integers");
999
- }, Ae = (e, t, n, r, a, o) => {
1000
- if (!e.matchType2(t, n, a)) return !1;
1001
- let s = [], c = j(t);
1002
- if (c !== void 0) for (let e = 0; e < c.length; e++) for (let t = 0; t < 8; t++) c[e] & 1 << t && s.push(e * 8 + t);
1003
- else if (t instanceof i) {
992
+ let o = e.existsIntGE(r, BigInt(n));
993
+ if (o !== void 0) return o ? !0 : e.fail(i, t, a, `${t.value} does not fit the .size constraint`);
994
+ e.warnOnce(".size controller could not be analyzed; searching a bounded window of byte counts", a);
995
+ for (let t = n; t <= n + 64; t++) if (e.matchType2(e.uint(t), r, i)) return !0;
996
+ return e.fail(i, t, a, `${t.value} does not fit the .size constraint`);
997
+ }
998
+ return e.fail(i, t, a, ".size applies to strings and unsigned integers");
999
+ }, Ae = (e, t, n, r, i, a) => {
1000
+ if (!e.matchType2(t, n, i)) return !1;
1001
+ let o = [], s = j(t);
1002
+ if (s !== void 0) for (let e = 0; e < s.length; e++) for (let t = 0; t < 8; t++) s[e] & 1 << t && o.push(e * 8 + t);
1003
+ else if (t instanceof d) {
1004
1004
  let e = t.value;
1005
- for (let t = 0; e > 0n; t++, e >>= 1n) e & 1n && s.push(t);
1006
- } else return e.fail(a, t, o, ".bits applies to byte strings and unsigned integers");
1007
- for (let n of s) if (!e.matchType2(e.uint(n), r, a)) return e.fail(a, t, o, `bit ${n} is set but not allowed by .bits`);
1005
+ for (let t = 0; e > 0n; t++, e >>= 1n) e & 1n && o.push(t);
1006
+ } else return e.fail(i, t, a, ".bits applies to byte strings and unsigned integers");
1007
+ for (let n of o) if (!e.matchType2(e.uint(n), r, i)) return e.fail(i, t, a, `bit ${n} is set but not allowed by .bits`);
1008
1008
  return !0;
1009
1009
  }, je = /* @__PURE__ */ new Map(), Me = (e, t, n, r, i, a) => {
1010
1010
  if (!e.matchType2(t, n, i)) return !1;
@@ -1030,8 +1030,8 @@ var Te = new TextEncoder(), Ee = new TextDecoder("utf-8", { fatal: !0 }), M = (e
1030
1030
  try {
1031
1031
  if (e) {
1032
1032
  let e = new Uint8Array(s.length + 2);
1033
- e[0] = 159, e.set(s, 1), e[e.length - 1] = 255, c = te(e);
1034
- } else c = te(s);
1033
+ e[0] = 159, e.set(s, 1), e[e.length - 1] = 255, c = v(e);
1034
+ } else c = v(s);
1035
1035
  } catch (e) {
1036
1036
  return t.fail(a, n, o, `byte string does not contain valid CBOR: ${e instanceof Error ? e.message : String(e)}`);
1037
1037
  }
@@ -1043,7 +1043,7 @@ var Te = new TextEncoder(), Ee = new TextDecoder("utf-8", { fatal: !0 }), M = (e
1043
1043
  let l = De(n);
1044
1044
  if (l === void 0) return t.fail(a, n, o, `.${e} applies to numbers`);
1045
1045
  let u = Oe(l, c);
1046
- return (e === "lt" ? u < 0 : e === "le" ? u <= 0 : e === "gt" ? u > 0 : u >= 0) ? !0 : t.fail(a, n, o, `${l} does not satisfy .${e} ${c}`);
1046
+ return (e === "lt" ? u < 0 : e === "le" ? u <= 0 : e === "gt" ? u > 0 : u >= 0) || t.fail(a, n, o, `${l} does not satisfy .${e} ${c}`);
1047
1047
  }, Fe = (e, t, n, r, i, a) => {
1048
1048
  if (!e.matchType2(t, n, i)) return !1;
1049
1049
  let o = e.resolveValue(r);
@@ -1132,7 +1132,7 @@ function Ue(e) {
1132
1132
  }
1133
1133
  //#endregion
1134
1134
  //#region src/cddl/validator.ts
1135
- var We = class extends Error {}, Ge = class {
1135
+ var F = class extends Error {}, We = class {
1136
1136
  schema;
1137
1137
  maxDepth;
1138
1138
  maxSteps;
@@ -1149,10 +1149,10 @@ var We = class extends Error {}, Ge = class {
1149
1149
  this.schema = e, this.maxDepth = t, this.maxSteps = n, this.features = r;
1150
1150
  }
1151
1151
  step() {
1152
- if (++this.steps > this.maxSteps) throw new We(`validation aborted: step budget of ${this.maxSteps} exceeded (pathological backtracking?)`);
1152
+ if (++this.steps > this.maxSteps) throw new F(`validation aborted: step budget of ${this.maxSteps} exceeded (pathological backtracking?)`);
1153
1153
  }
1154
1154
  checkDepth(e) {
1155
- if (e > this.maxDepth) throw new We(`validation aborted: recursion depth ${this.maxDepth} exceeded (cyclic rules without progress?)`);
1155
+ if (e > this.maxDepth) throw new F(`validation aborted: recursion depth ${this.maxDepth} exceeded (cyclic rules without progress?)`);
1156
1156
  }
1157
1157
  warnOnce(e, t) {
1158
1158
  let n = `${e}@${t?.start ?? -1}`;
@@ -1187,7 +1187,7 @@ var We = class extends Error {}, Ge = class {
1187
1187
  return !1;
1188
1188
  }
1189
1189
  };
1190
- function Ke(e, t, n) {
1190
+ function Ge(e, t, n) {
1191
1191
  let r = n?.rule ?? e.root?.name;
1192
1192
  if (r === void 0) return {
1193
1193
  valid: !1,
@@ -1196,7 +1196,7 @@ function Ke(e, t, n) {
1196
1196
  path: "/"
1197
1197
  }]
1198
1198
  };
1199
- let i = new Ge(e, n?.maxDepth ?? 256, n?.maxSteps ?? 1e6, new Set(n?.features ?? [])), a = F(i, r)?.[0]?.generics?.length ?? 0;
1199
+ let i = new We(e, n?.maxDepth ?? 256, n?.maxSteps ?? 1e6, new Set(n?.features ?? [])), a = I(i, r)?.[0]?.generics?.length ?? 0;
1200
1200
  if (a > 0) return {
1201
1201
  valid: !1,
1202
1202
  errors: [{
@@ -1206,9 +1206,9 @@ function Ke(e, t, n) {
1206
1206
  };
1207
1207
  let o;
1208
1208
  try {
1209
- o = Ye(t, r, void 0, [], i, 0);
1209
+ o = Je(t, r, void 0, [], i, 0);
1210
1210
  } catch (e) {
1211
- if (!(e instanceof We)) throw e;
1211
+ if (!(e instanceof F)) throw e;
1212
1212
  return {
1213
1213
  valid: !1,
1214
1214
  errors: [{
@@ -1235,22 +1235,22 @@ function Ke(e, t, n) {
1235
1235
  ...i.warnings.length ? { warnings: i.warnings } : {}
1236
1236
  };
1237
1237
  }
1238
- function F(e, t) {
1238
+ function I(e, t) {
1239
1239
  let n = e.schema.rules.get(t);
1240
1240
  if (n) return n;
1241
- let r = w().get(t);
1241
+ let r = E().get(t);
1242
1242
  return r ? [r] : void 0;
1243
1243
  }
1244
- function I(e) {
1244
+ function L(e) {
1245
1245
  return e.kind === "entry" && !e.occur && !e.memberKey;
1246
1246
  }
1247
- function qe(e) {
1247
+ function Ke(e) {
1248
1248
  return e.kind === "entry-group" && !e.occur ? e.group.choices : [[e]];
1249
1249
  }
1250
- function Je(e) {
1251
- return e.some((e) => !I(e.body));
1250
+ function qe(e) {
1251
+ return e.some((e) => !L(e.body));
1252
1252
  }
1253
- function L(e, t, n) {
1253
+ function R(e, t, n) {
1254
1254
  let r = e.generics;
1255
1255
  if (!r || !t) return;
1256
1256
  let i = /* @__PURE__ */ new Map();
@@ -1260,8 +1260,8 @@ function L(e, t, n) {
1260
1260
  });
1261
1261
  return i;
1262
1262
  }
1263
- function Ye(e, t, n, r, i, a, o, s) {
1264
- let c = F(i, t);
1263
+ function Je(e, t, n, r, i, a, o, s) {
1264
+ let c = I(i, t);
1265
1265
  if (!c) return i.fail(r, e, o, t.startsWith("$") ? `socket '${t}' has no definitions, so nothing matches it` : `'${t}' is not defined`);
1266
1266
  i.checkDepth(a);
1267
1267
  let l = i.ruleName;
@@ -1270,13 +1270,13 @@ function Ye(e, t, n, r, i, a, o, s) {
1270
1270
  u && ++i.preludeDepth === 1 && (i.preludeRef = o);
1271
1271
  try {
1272
1272
  for (let o of c) {
1273
- let c = L(o, s, n);
1274
- if (I(o.body)) {
1275
- if (R(e, o.body.value, c, r, i, a + 1)) return !0;
1273
+ let c = R(o, s, n);
1274
+ if (L(o.body)) {
1275
+ if (z(e, o.body.value, c, r, i, a + 1)) return !0;
1276
1276
  continue;
1277
1277
  }
1278
- let l = qe(o.body), u = !0;
1279
- for (let e of l) if (!(e.length === 1 && I(e[0]))) {
1278
+ let l = Ke(o.body), u = !0;
1279
+ for (let e of l) if (!(e.length === 1 && L(e[0]))) {
1280
1280
  u = !1;
1281
1281
  break;
1282
1282
  }
@@ -1286,7 +1286,7 @@ function Ye(e, t, n, r, i, a, o, s) {
1286
1286
  }
1287
1287
  for (let t of l) {
1288
1288
  let n = t[0];
1289
- if (R(e, n.value, c, r, i, a + 1)) return !0;
1289
+ if (z(e, n.value, c, r, i, a + 1)) return !0;
1290
1290
  }
1291
1291
  }
1292
1292
  return !1;
@@ -1294,68 +1294,68 @@ function Ye(e, t, n, r, i, a, o, s) {
1294
1294
  i.ruleName = l, u && --i.preludeDepth === 0 && (i.preludeRef = void 0);
1295
1295
  }
1296
1296
  }
1297
- function Xe(e) {
1298
- for (; e instanceof p;) e = e.inner;
1297
+ function Ye(e) {
1298
+ for (; e instanceof m;) e = e.inner;
1299
1299
  return e;
1300
1300
  }
1301
- function R(e, t, n, r, i, a) {
1302
- for (let o of t.alternatives) if (z(e, o, n, r, i, a)) return !0;
1301
+ function z(e, t, n, r, i, a) {
1302
+ for (let o of t.alternatives) if (B(e, o, n, r, i, a)) return !0;
1303
1303
  return !1;
1304
1304
  }
1305
- function z(e, t, n, r, i, a) {
1306
- if (i.step(), e = Xe(e), !t.op || !t.controller) return B(e, t.target, n, r, i, a);
1307
- if (t.op.kind === "range") return it(e, t, n, r, i, a);
1305
+ function B(e, t, n, r, i, a) {
1306
+ if (i.step(), e = Ye(e), !t.op || !t.controller) return V(e, t.target, n, r, i, a);
1307
+ if (t.op.kind === "range") return rt(e, t, n, r, i, a);
1308
1308
  let o = Ue(t.op.name), s = Ct(n, i, a);
1309
- return o ? o(s, e, t.target, t.controller, r, t) : (i.warnOnce(`control operator .${t.op.name} is not supported; matching the target only`, t), B(e, t.target, n, r, i, a));
1309
+ return o ? o(s, e, t.target, t.controller, r, t) : (i.warnOnce(`control operator .${t.op.name} is not supported; matching the target only`, t), V(e, t.target, n, r, i, a));
1310
1310
  }
1311
- function B(e, t, a, o, s, c) {
1312
- if (e = Xe(e), e instanceof _) return !0;
1311
+ function V(e, t, r, i, o, s) {
1312
+ if (e = Ye(e), e instanceof y) return !0;
1313
1313
  switch (t.kind) {
1314
1314
  case "any": return !0;
1315
- case "value": return H(e, t) ? !0 : s.fail(o, e, t, `expected the value ${t.raw}`);
1315
+ case "value": return U(e, t) ? !0 : o.fail(i, e, t, `expected the value ${t.raw}`);
1316
1316
  case "ref": {
1317
- let n = a?.get(t.name);
1318
- return n && !t.genericArgs ? z(e, n.type1, n.env, o, s, c + 1) : Ye(e, t.name, a, o, s, c + 1, t, t.genericArgs);
1317
+ let n = r?.get(t.name);
1318
+ return n && !t.genericArgs ? B(e, n.type1, n.env, i, o, s + 1) : Je(e, t.name, r, i, o, s + 1, t, t.genericArgs);
1319
1319
  }
1320
- case "paren": return R(e, t.type, a, o, s, c);
1321
- case "map": return e instanceof r ? _t(e, t.group, a, o, s, c + 1) : s.fail(o, e, t, "expected a map");
1322
- case "array": return e instanceof n ? pt(e, t.group, a, o, s, c + 1) : s.fail(o, e, t, "expected an array");
1320
+ case "paren": return z(e, t.type, r, i, o, s);
1321
+ case "map": return e instanceof f ? _t(e, t.group, r, i, o, s + 1) : o.fail(i, e, t, "expected a map");
1322
+ case "array": return e instanceof a ? pt(e, t.group, r, i, o, s + 1) : o.fail(i, e, t, "expected an array");
1323
1323
  case "tagged":
1324
- if (!(e instanceof g)) return s.fail(o, e, t, "expected a tagged item");
1324
+ if (!(e instanceof n)) return o.fail(i, e, t, "expected a tagged item");
1325
1325
  if (typeof t.tag == "bigint") {
1326
- if (e.tag !== t.tag) return s.fail(o, e, t, `expected tag ${t.tag}, got ${e.tag}`);
1327
- } else if (t.tag !== void 0 && !R(new i(e.tag), t.tag, a, o, s, c + 1)) return s.fail(o, e, t, `tag number ${e.tag} does not match the head type`);
1328
- return R(e.content, t.item, a, o, s, c + 1);
1329
- case "major": return ot(e, t, a, o, s, c);
1326
+ if (e.tag !== t.tag) return o.fail(i, e, t, `expected tag ${t.tag}, got ${e.tag}`);
1327
+ } else if (t.tag !== void 0 && !z(new d(e.tag), t.tag, r, i, o, s + 1)) return o.fail(i, e, t, `tag number ${e.tag} does not match the head type`);
1328
+ return z(e.content, t.item, r, i, o, s + 1);
1329
+ case "major": return at(e, t, r, i, o, s);
1330
1330
  case "unwrap": {
1331
- let n = dt(t.ref, a, s, 0);
1332
- return n ? R(e, n.type, n.env, o, s, c + 1) : (s.warnOnce(`~${t.ref.name} is used outside of an array/map group context`, t), s.fail(o, e, t, `~${t.ref.name} cannot match here`));
1331
+ let n = dt(t.ref, r, o, 0);
1332
+ return n ? z(e, n.type, n.env, i, o, s + 1) : (o.warnOnce(`~${t.ref.name} is used outside of an array/map group context`, t), o.fail(i, e, t, `~${t.ref.name} cannot match here`));
1333
1333
  }
1334
1334
  case "enum": {
1335
- let n = t.group.kind === "ref" ? X(t.group, a, s) : Y(t.group, a);
1336
- return n ? (s.checkDepth(c), V(e, n, o, s, c + 1) ? !0 : s.fail(o, e, t, "no enumeration value matches")) : s.fail(o, e, t, "'&' target does not resolve to a group");
1335
+ let n = t.group.kind === "ref" ? ct(t.group, r, o) : X(t.group, r);
1336
+ return n ? (o.checkDepth(s), H(e, n, i, o, s + 1) ? !0 : o.fail(i, e, t, "no enumeration value matches")) : o.fail(i, e, t, "'&' target does not resolve to a group");
1337
1337
  }
1338
1338
  }
1339
1339
  }
1340
- function V(e, t, n, r, i) {
1340
+ function H(e, t, n, r, i) {
1341
1341
  for (let { entries: a, env: o } of t) for (let t of a) {
1342
1342
  if (r.step(), t.kind === "entry-group") {
1343
- if (V(e, Y(t.group, o), n, r, i + 1)) return !0;
1343
+ if (H(e, X(t.group, o), n, r, i + 1)) return !0;
1344
1344
  continue;
1345
1345
  }
1346
1346
  let a = lt(t, o, r);
1347
1347
  if (a) {
1348
- if (r.checkDepth(i), V(e, a, n, r, i + 1)) return !0;
1348
+ if (r.checkDepth(i), H(e, a, n, r, i + 1)) return !0;
1349
1349
  continue;
1350
1350
  }
1351
- if (R(e, t.value, o, n, r, i + 1)) return !0;
1351
+ if (z(e, t.value, o, n, r, i + 1)) return !0;
1352
1352
  }
1353
1353
  return !1;
1354
1354
  }
1355
- function H(e, t) {
1355
+ function U(e, t) {
1356
1356
  switch (t.type) {
1357
- case "int": return k(e) === BigInt(t.value);
1358
- case "float": return e instanceof s && (e.value === t.value || Number.isNaN(e.value) && Number.isNaN(t.value));
1357
+ case "int": return Ce(e) === BigInt(t.value);
1358
+ case "float": return e instanceof _ && (e.value === t.value || Number.isNaN(e.value) && Number.isNaN(t.value));
1359
1359
  case "text": return A(e) === t.value;
1360
1360
  case "bytes": {
1361
1361
  let n = j(e);
@@ -1363,33 +1363,33 @@ function H(e, t) {
1363
1363
  }
1364
1364
  }
1365
1365
  }
1366
- function U(e, t, n, r = 0) {
1366
+ function W(e, t, n, r = 0) {
1367
1367
  if (r > 32) return;
1368
1368
  if (e.kind === "value") return e;
1369
1369
  if (e.kind === "paren") {
1370
1370
  let i = e.type.alternatives.length === 1 ? e.type.alternatives[0] : void 0;
1371
- return !i || i.op ? void 0 : U(i.target, t, n, r + 1);
1371
+ return !i || i.op ? void 0 : W(i.target, t, n, r + 1);
1372
1372
  }
1373
1373
  if (e.kind !== "ref") return;
1374
1374
  let i = t?.get(e.name);
1375
- if (i && !e.genericArgs) return i.type1.op ? void 0 : U(i.type1.target, i.env, n, r + 1);
1376
- let a = F(n, e.name);
1375
+ if (i && !e.genericArgs) return i.type1.op ? void 0 : W(i.type1.target, i.env, n, r + 1);
1376
+ let a = I(n, e.name);
1377
1377
  if (!a || a.length !== 1) return;
1378
1378
  let o = a[0].body;
1379
- if (!I(o) || o.value.alternatives.length !== 1) return;
1379
+ if (!L(o) || o.value.alternatives.length !== 1) return;
1380
1380
  let s = o.value.alternatives[0];
1381
1381
  if (s.op) return;
1382
- let c = L(a[0], e.genericArgs, t);
1383
- return U(s.target, c, n, r + 1);
1382
+ let c = R(a[0], e.genericArgs, t);
1383
+ return W(s.target, c, n, r + 1);
1384
1384
  }
1385
- function Ze(e, t, n, r, i = 0) {
1386
- return Qe(e, t, void 0, n, r, i);
1385
+ function Xe(e, t, n, r, i = 0) {
1386
+ return Ze(e, t, void 0, n, r, i);
1387
1387
  }
1388
- function Qe(e, t, n, r, i, a = 0) {
1389
- let o = W(e, t, n, r, i, a);
1388
+ function Ze(e, t, n, r, i, a = 0) {
1389
+ let o = G(e, t, n, r, i, a);
1390
1390
  return o === void 0 ? void 0 : o !== null;
1391
1391
  }
1392
- function W(e, t, n, r, i, a = 0) {
1392
+ function G(e, t, n, r, i, a = 0) {
1393
1393
  if (n !== void 0 && t > n) return null;
1394
1394
  if (!(a > 32)) switch (e.kind) {
1395
1395
  case "value":
@@ -1413,25 +1413,25 @@ function W(e, t, n, r, i, a = 0) {
1413
1413
  return e <= -1n && (n === void 0 || e <= n) ? e : null;
1414
1414
  }
1415
1415
  return null;
1416
- case "paren": return G(e.type, t, n, r, i, a + 1);
1416
+ case "paren": return K(e.type, t, n, r, i, a + 1);
1417
1417
  case "ref": {
1418
1418
  let o = r?.get(e.name);
1419
- if (o && !e.genericArgs) return $e(o.type1, t, n, o.env, i, a + 1);
1420
- let s = F(i, e.name);
1419
+ if (o && !e.genericArgs) return Qe(o.type1, t, n, o.env, i, a + 1);
1420
+ let s = I(i, e.name);
1421
1421
  if (!s) return;
1422
1422
  let c = !1, l = null;
1423
1423
  for (let o of s) {
1424
- if (!I(o.body)) {
1424
+ if (!L(o.body)) {
1425
1425
  c = !0;
1426
1426
  continue;
1427
1427
  }
1428
- let s = L(o, e.genericArgs, r), u = G(o.body.value, t, n, s, i, a + 1);
1428
+ let s = R(o, e.genericArgs, r), u = K(o.body.value, t, n, s, i, a + 1);
1429
1429
  typeof u == "bigint" && (l === null || u < l) && (l = u), u === void 0 && (c = !0);
1430
1430
  }
1431
1431
  return l ?? (c ? void 0 : null);
1432
1432
  }
1433
1433
  case "enum": {
1434
- let o = e.group.kind === "ref" ? X(e.group, r, i) : Y(e.group, r);
1434
+ let o = e.group.kind === "ref" ? ct(e.group, r, i) : X(e.group, r);
1435
1435
  if (!o) return;
1436
1436
  let s = !1, c = null;
1437
1437
  for (let { entries: e, env: r } of o) for (let o of e) {
@@ -1439,7 +1439,7 @@ function W(e, t, n, r, i, a = 0) {
1439
1439
  s = !0;
1440
1440
  continue;
1441
1441
  }
1442
- let e = G(o.value, t, n, r, i, a + 1);
1442
+ let e = K(o.value, t, n, r, i, a + 1);
1443
1443
  typeof e == "bigint" && (c === null || e < c) && (c = e), e === void 0 && (s = !0);
1444
1444
  }
1445
1445
  return c ?? (s ? void 0 : null);
@@ -1447,93 +1447,93 @@ function W(e, t, n, r, i, a = 0) {
1447
1447
  default: return;
1448
1448
  }
1449
1449
  }
1450
- function G(e, t, n, r, i, a) {
1450
+ function K(e, t, n, r, i, a) {
1451
1451
  let o = !1, s = null;
1452
1452
  for (let c of e.alternatives) {
1453
- let e = $e(c, t, n, r, i, a);
1453
+ let e = Qe(c, t, n, r, i, a);
1454
1454
  typeof e == "bigint" && (s === null || e < s) && (s = e), e === void 0 && (o = !0);
1455
1455
  }
1456
1456
  return s ?? (o ? void 0 : null);
1457
1457
  }
1458
- function $e(e, t, n, r, i, a) {
1459
- if (!e.op) return W(e.target, t, n, r, i, a);
1458
+ function Qe(e, t, n, r, i, a) {
1459
+ if (!e.op) return G(e.target, t, n, r, i, a);
1460
1460
  if (e.op.kind === "ctl") {
1461
- if (e.op.name === "bits") return tt(e.target, e.controller, t, n, r, i, a + 1);
1461
+ if (e.op.name === "bits") return et(e.target, e.controller, t, n, r, i, a + 1);
1462
1462
  if (e.op.name === "size") {
1463
- let o = W(e.target, t > 0n ? t : 0n, n, r, i, a + 1);
1463
+ let o = G(e.target, t > 0n ? t : 0n, n, r, i, a + 1);
1464
1464
  if (o == null) return o;
1465
- let s = Ze(e.controller, BigInt(rt(o)), r, i, a + 1);
1465
+ let s = Xe(e.controller, BigInt(nt(o)), r, i, a + 1);
1466
1466
  return s === void 0 ? void 0 : s ? o : null;
1467
1467
  }
1468
1468
  if (e.op.name === "feature") {
1469
1469
  let o = Ve(Ct(r, i, a), e.controller);
1470
- return o === void 0 ? void 0 : i.features.has(o) ? W(e.target, t, n, r, i, a + 1) : (i.warnOnce(`feature "${o}" is not enabled (pass it in options.features to accept it)`, e), null);
1470
+ return o === void 0 ? void 0 : i.features.has(o) ? G(e.target, t, n, r, i, a + 1) : (i.warnOnce(`feature "${o}" is not enabled (pass it in options.features to accept it)`, e), null);
1471
1471
  }
1472
- if (e.op.name === "and" || e.op.name === "within") return et(e.target, e.controller, t, n, r, i, a + 1);
1472
+ if (e.op.name === "and" || e.op.name === "within") return $e(e.target, e.controller, t, n, r, i, a + 1);
1473
1473
  if (e.op.name === "plus") {
1474
- let a = U(e.target, r, i), o = U(e.controller, r, i);
1474
+ let a = W(e.target, r, i), o = W(e.controller, r, i);
1475
1475
  if (!a || !o || a.type === "text" || a.type === "bytes" || o.type === "text" || o.type === "bytes") return;
1476
1476
  if (a.type === "float") return null;
1477
1477
  let s = o.type === "int" ? BigInt(a.value) + BigInt(o.value) : BigInt(Math.floor(Number(a.value) + o.value));
1478
1478
  return s >= t && (n === void 0 || s <= n) ? s : null;
1479
1479
  }
1480
- let o = U(e.controller, r, i);
1480
+ let o = W(e.controller, r, i);
1481
1481
  if (!o || o.type !== "int") return;
1482
1482
  let s = BigInt(o.value);
1483
1483
  switch (e.op.name) {
1484
- case "eq": return W(e.target, s > t ? s : t, n === void 0 || s < n ? s : n, r, i, a + 1);
1484
+ case "eq": return G(e.target, s > t ? s : t, n === void 0 || s < n ? s : n, r, i, a + 1);
1485
1485
  case "ne":
1486
1486
  case "default": {
1487
- let o = W(e.target, t, n === void 0 || s - 1n < n ? s - 1n : n, r, i, a + 1);
1487
+ let o = G(e.target, t, n === void 0 || s - 1n < n ? s - 1n : n, r, i, a + 1);
1488
1488
  if (typeof o == "bigint") return o;
1489
- let c = W(e.target, s + 1n > t ? s + 1n : t, n, r, i, a + 1);
1489
+ let c = G(e.target, s + 1n > t ? s + 1n : t, n, r, i, a + 1);
1490
1490
  return typeof c == "bigint" ? c : o === void 0 || c === void 0 ? void 0 : null;
1491
1491
  }
1492
1492
  case "lt":
1493
1493
  case "le": {
1494
1494
  let o = s - (e.op.name === "lt" ? 1n : 0n);
1495
- return W(e.target, t, n === void 0 || o < n ? o : n, r, i, a + 1);
1495
+ return G(e.target, t, n === void 0 || o < n ? o : n, r, i, a + 1);
1496
1496
  }
1497
1497
  case "gt":
1498
1498
  case "ge": {
1499
1499
  let o = s + (e.op.name === "gt" ? 1n : 0n);
1500
- return W(e.target, o > t ? o : t, n, r, i, a + 1);
1500
+ return G(e.target, o > t ? o : t, n, r, i, a + 1);
1501
1501
  }
1502
1502
  default: return;
1503
1503
  }
1504
1504
  }
1505
- let o = U(e.target, r, i), s = U(e.controller, r, i);
1505
+ let o = W(e.target, r, i), s = W(e.controller, r, i);
1506
1506
  if (!o || !s || o.type !== "int" || s.type !== "int") return;
1507
1507
  let c = BigInt(o.value), l = BigInt(s.value) - (e.op.inclusive ? 0n : 1n), u = c > t ? c : t;
1508
1508
  return u <= (n === void 0 || l < n ? l : n) ? u : null;
1509
1509
  }
1510
- function et(e, t, n, r, i, a, o) {
1510
+ function $e(e, t, n, r, i, a, o) {
1511
1511
  let s = n;
1512
1512
  for (let n = 0; n < 256; n++) {
1513
- let n = W(e, s, r, i, a, o + 1), c = W(t, s, r, i, a, o + 1);
1513
+ let n = G(e, s, r, i, a, o + 1), c = G(t, s, r, i, a, o + 1);
1514
1514
  if (n === null || c === null) return null;
1515
1515
  if (n === void 0 || c === void 0) return;
1516
1516
  if (n === c) return n;
1517
1517
  s = n > c ? n : c;
1518
1518
  }
1519
1519
  }
1520
- function tt(e, t, n, r, i, a, o) {
1520
+ function et(e, t, n, r, i, a, o) {
1521
1521
  let s = 0n;
1522
1522
  for (let e = 0; e < 64; e++) {
1523
- let n = W(t, BigInt(e), BigInt(e), i, a, o + 1);
1523
+ let n = G(t, BigInt(e), BigInt(e), i, a, o + 1);
1524
1524
  if (n === void 0) return;
1525
1525
  n !== null && (s |= 1n << BigInt(e));
1526
1526
  }
1527
1527
  let c = n > 0n ? n : 0n, l = r === void 0 || r > 18446744073709551615n ? 18446744073709551615n : r;
1528
1528
  for (let t = 0; t < 256; t++) {
1529
- let t = W(e, c, l, i, a, o + 1), n = nt(c, l, s);
1529
+ let t = G(e, c, l, i, a, o + 1), n = tt(c, l, s);
1530
1530
  if (t === void 0) return;
1531
1531
  if (t === null || n === null) return null;
1532
1532
  if (t === n) return t;
1533
1533
  c = t > n ? t : n;
1534
1534
  }
1535
1535
  }
1536
- function nt(e, t, n) {
1536
+ function tt(e, t, n) {
1537
1537
  if (e < 0n && (e = 0n), e > t) return null;
1538
1538
  let r = (i, a, o) => {
1539
1539
  if (i < 0) return o <= t ? o : null;
@@ -1547,77 +1547,77 @@ function nt(e, t, n) {
1547
1547
  };
1548
1548
  return r(63, !1, 0n);
1549
1549
  }
1550
- function rt(e) {
1550
+ function nt(e) {
1551
1551
  let t = 0;
1552
1552
  for (let n = e; n > 0n; n >>= 8n) t++;
1553
1553
  return t;
1554
1554
  }
1555
- function it(e, t, n, r, i, a) {
1556
- let o = t.op, c = U(t.target, n, i), l = U(t.controller, n, i);
1557
- if (!c || !l) return i.warnOnce("range endpoints do not resolve to literal values", t), i.fail(r, e, t, "unresolvable range");
1558
- if (c.type === "int" && l.type === "int") {
1559
- let n = k(e);
1560
- if (n === void 0) return i.fail(r, e, t, `expected an integer in ${K(t)}`);
1561
- let a = BigInt(c.value), s = BigInt(l.value);
1562
- return n >= a && (o.inclusive ? n <= s : n < s) || i.fail(r, e, t, `${n} is outside ${K(t)}`);
1563
- }
1564
- if (c.type === "float" && l.type === "float") {
1565
- if (!(e instanceof s)) return i.fail(r, e, t, `expected a float in ${K(t)}`);
1555
+ function rt(e, t, n, r, i, a) {
1556
+ let o = t.op, s = W(t.target, n, i), c = W(t.controller, n, i);
1557
+ if (!s || !c) return i.warnOnce("range endpoints do not resolve to literal values", t), i.fail(r, e, t, "unresolvable range");
1558
+ if (s.type === "int" && c.type === "int") {
1559
+ let n = Ce(e);
1560
+ if (n === void 0) return i.fail(r, e, t, `expected an integer in ${q(t)}`);
1561
+ let a = BigInt(s.value), l = BigInt(c.value);
1562
+ return n >= a && (o.inclusive ? n <= l : n < l) || i.fail(r, e, t, `${n} is outside ${q(t)}`);
1563
+ }
1564
+ if (s.type === "float" && c.type === "float") {
1565
+ if (!(e instanceof _)) return i.fail(r, e, t, `expected a float in ${q(t)}`);
1566
1566
  let n = e.value;
1567
- return n >= c.value && (o.inclusive ? n <= l.value : n < l.value) || i.fail(r, e, t, `${n} is outside ${K(t)}`);
1567
+ return n >= s.value && (o.inclusive ? n <= c.value : n < c.value) || i.fail(r, e, t, `${n} is outside ${q(t)}`);
1568
1568
  }
1569
1569
  return i.warnOnce("range endpoints mix integer and float types", t), i.fail(r, e, t, "invalid range");
1570
1570
  }
1571
- function K(e) {
1571
+ function q(e) {
1572
1572
  let t = e.op;
1573
- return `${q(e.target)}${t.inclusive ? ".." : "..."}${q(e.controller)}`;
1573
+ return `${J(e.target)}${t.inclusive ? ".." : "..."}${J(e.controller)}`;
1574
1574
  }
1575
- function q(e) {
1575
+ function J(e) {
1576
1576
  return e.kind === "value" ? e.raw : e.kind === "ref" ? e.name : "…";
1577
1577
  }
1578
- var at = {
1578
+ var it = {
1579
1579
  half: 25n,
1580
1580
  single: 26n,
1581
1581
  double: 27n
1582
1582
  };
1583
- function ot(e, t, a, c, l, f) {
1584
- let p = (e) => t.ai === void 0 ? !0 : typeof t.ai == "bigint" ? t.ai === e : R(new i(e), t.ai, a, c, l, f + 1), m = (n) => l.fail(c, e, t, `expected ${n} (#${t.major})`);
1583
+ function at(e, t, r, i, o, c) {
1584
+ let u = (e) => t.ai === void 0 ? !0 : typeof t.ai == "bigint" ? t.ai === e : z(new d(e), t.ai, r, i, o, c + 1), p = (n) => o.fail(i, e, t, `expected ${n} (#${t.major})`);
1585
1585
  switch (t.major) {
1586
1586
  case 0:
1587
- if (!(e instanceof i)) return m("an unsigned integer");
1587
+ if (!(e instanceof d)) return p("an unsigned integer");
1588
1588
  break;
1589
1589
  case 1:
1590
- if (!(e instanceof u)) return m("a negative integer");
1590
+ if (!(e instanceof l)) return p("a negative integer");
1591
1591
  break;
1592
1592
  case 2:
1593
- if (j(e) === void 0) return m("a byte string");
1593
+ if (j(e) === void 0) return p("a byte string");
1594
1594
  break;
1595
1595
  case 3:
1596
- if (A(e) === void 0) return m("a text string");
1596
+ if (A(e) === void 0) return p("a text string");
1597
1597
  break;
1598
1598
  case 4:
1599
- if (!(e instanceof n)) return m("an array");
1599
+ if (!(e instanceof a)) return p("an array");
1600
1600
  break;
1601
1601
  case 5:
1602
- if (!(e instanceof r)) return m("a map");
1602
+ if (!(e instanceof f)) return p("a map");
1603
1603
  break;
1604
- case 6: return e instanceof g ? p(e.tag) ? !0 : l.fail(c, e, t, `tag ${e.tag} does not match ${J(t)}`) : m("a tagged item");
1605
- case 7: return e instanceof d ? p(BigInt(e.value)) ? !0 : l.fail(c, e, t, `simple(${e.value}) does not match ${J(t)}`) : e instanceof s ? t.ai === void 0 || p(at[e.precision ?? o(e.value)]) ? !0 : l.fail(c, e, t, `float does not match ${J(t)}`) : m("a simple value or float");
1606
- default: return l.fail(c, e, t, `#${t.major} is not a valid major type`);
1604
+ case 6: return e instanceof n ? u(e.tag) ? !0 : o.fail(i, e, t, `tag ${e.tag} does not match ${Y(t)}`) : p("a tagged item");
1605
+ case 7: return e instanceof ne ? u(BigInt(e.value)) ? !0 : o.fail(i, e, t, `simple(${e.value}) does not match ${Y(t)}`) : e instanceof _ ? t.ai === void 0 || u(it[e.precision ?? s(e.value)]) ? !0 : o.fail(i, e, t, `float does not match ${Y(t)}`) : p("a simple value or float");
1606
+ default: return o.fail(i, e, t, `#${t.major} is not a valid major type`);
1607
1607
  }
1608
- return t.ai !== void 0 && t.major <= 5 && l.warnOnce(`the additional-information constraint ${J(t)} is not checked (encoding-level)`, t), !0;
1608
+ return t.ai !== void 0 && t.major <= 5 && o.warnOnce(`the additional-information constraint ${Y(t)} is not checked (encoding-level)`, t), !0;
1609
1609
  }
1610
- function J(e) {
1610
+ function Y(e) {
1611
1611
  return e.raw ?? `#${e.major}`;
1612
1612
  }
1613
- var Y = (e, t) => e.choices.map((e) => ({
1613
+ var X = (e, t) => e.choices.map((e) => ({
1614
1614
  entries: e,
1615
1615
  env: t
1616
- })), st = {
1616
+ })), ot = {
1617
1617
  min: 1,
1618
1618
  max: 1
1619
1619
  };
1620
- function ct(e) {
1620
+ function st(e) {
1621
1621
  let t = e.occur;
1622
1622
  return t ? t.marker === "?" ? {
1623
1623
  min: 0,
@@ -1628,15 +1628,15 @@ function ct(e) {
1628
1628
  } : {
1629
1629
  min: t.min ?? 0,
1630
1630
  max: t.max ?? Infinity
1631
- } : st;
1631
+ } : ot;
1632
1632
  }
1633
- function X(e, t, n) {
1634
- let r = F(n, e.name);
1635
- if (!r || !Je(r)) return;
1633
+ function ct(e, t, n) {
1634
+ let r = I(n, e.name);
1635
+ if (!r || !qe(r)) return;
1636
1636
  let i = [];
1637
1637
  for (let n of r) {
1638
- let r = L(n, e.genericArgs, t);
1639
- for (let e of qe(n.body)) i.push({
1638
+ let r = R(n, e.genericArgs, t);
1639
+ for (let e of Ke(n.body)) i.push({
1640
1640
  entries: e,
1641
1641
  env: r
1642
1642
  });
@@ -1648,34 +1648,34 @@ function lt(e, t, n) {
1648
1648
  let r = e.value.alternatives[0];
1649
1649
  if (r.op) return;
1650
1650
  let i = r.target;
1651
- if (i.kind === "ref") return t?.has(i.name) && !i.genericArgs ? void 0 : X(i, t, n) || (i.name.startsWith("$$") && !F(n, i.name) ? [] : void 0);
1651
+ if (i.kind === "ref") return t?.has(i.name) && !i.genericArgs ? void 0 : ct(i, t, n) || (i.name.startsWith("$$") && !I(n, i.name) ? [] : void 0);
1652
1652
  if (i.kind === "unwrap") return ut(i.ref, t, n, 0);
1653
1653
  }
1654
1654
  function ut(e, t, n, r) {
1655
1655
  if (r > 32) return;
1656
- let i = F(n, e.name);
1656
+ let i = I(n, e.name);
1657
1657
  if (!i || i.length !== 1) return;
1658
- let a = i[0].body, o = L(i[0], e.genericArgs, t);
1659
- if (!I(a)) return qe(a).map((e) => ({
1658
+ let a = i[0].body, o = R(i[0], e.genericArgs, t);
1659
+ if (!L(a)) return Ke(a).map((e) => ({
1660
1660
  entries: e,
1661
1661
  env: o
1662
1662
  }));
1663
1663
  if (a.value.alternatives.length !== 1) return;
1664
1664
  let s = a.value.alternatives[0];
1665
1665
  if (!s.op) {
1666
- if (s.target.kind === "map" || s.target.kind === "array") return Y(s.target.group, o);
1666
+ if (s.target.kind === "map" || s.target.kind === "array") return X(s.target.group, o);
1667
1667
  if (s.target.kind === "ref") return ut(s.target, o, n, r + 1);
1668
1668
  }
1669
1669
  }
1670
1670
  function dt(e, t, n, r) {
1671
1671
  if (r > 32) return;
1672
- let i = F(n, e.name);
1672
+ let i = I(n, e.name);
1673
1673
  if (!i || i.length !== 1) return;
1674
1674
  let a = i[0].body;
1675
- if (!I(a) || a.value.alternatives.length !== 1) return;
1675
+ if (!L(a) || a.value.alternatives.length !== 1) return;
1676
1676
  let o = a.value.alternatives[0];
1677
1677
  if (o.op) return;
1678
- let s = L(i[0], e.genericArgs, t);
1678
+ let s = R(i[0], e.genericArgs, t);
1679
1679
  if (o.target.kind === "tagged") return {
1680
1680
  type: o.target.item,
1681
1681
  env: s
@@ -1683,11 +1683,11 @@ function dt(e, t, n, r) {
1683
1683
  if (o.target.kind === "ref") return dt(o.target, s, n, r + 1);
1684
1684
  }
1685
1685
  function ft(e, t, n) {
1686
- let r = ct(e);
1686
+ let r = st(e);
1687
1687
  if (e.kind === "entry-group") return {
1688
1688
  kind: "group",
1689
1689
  occur: r,
1690
- choices: Y(e.group, t),
1690
+ choices: X(e.group, t),
1691
1691
  node: e
1692
1692
  };
1693
1693
  let i = lt(e, t, n);
@@ -1706,7 +1706,7 @@ function ft(e, t, n) {
1706
1706
  };
1707
1707
  }
1708
1708
  function pt(e, t, n, r, i, a) {
1709
- return i.checkDepth(a), mt(e.items, 0, Y(t, n), r, i, a).has(e.items.length) ? !0 : i.fail(r, e, t, `array of ${e.items.length} item(s) does not match the group`);
1709
+ return i.checkDepth(a), mt(e.items, 0, X(t, n), r, i, a).has(e.items.length) ? !0 : i.fail(r, e, t, `array of ${e.items.length} item(s) does not match the group`);
1710
1710
  }
1711
1711
  function mt(e, t, n, r, i, a) {
1712
1712
  let o = /* @__PURE__ */ new Set();
@@ -1724,19 +1724,19 @@ function ht(e, t, n, r, i, a, o, s) {
1724
1724
  l(0, t);
1725
1725
  }
1726
1726
  function gt(e, t, n, r, i, a) {
1727
- return n.kind === "type" ? R(e[t], n.type, n.env, [...r, t], i, a) ? [t + 1] : [] : (i.checkDepth(a), [...mt(e, t, n.choices, r, i, a + 1)].sort((e, t) => t - e));
1727
+ return n.kind === "type" ? z(e[t], n.type, n.env, [...r, t], i, a) ? [t + 1] : [] : (i.checkDepth(a), [...mt(e, t, n.choices, r, i, a + 1)].sort((e, t) => t - e));
1728
1728
  }
1729
1729
  function _t(e, t, n, r, i, a) {
1730
1730
  i.checkDepth(a);
1731
1731
  let o = Array(e.entries.length).fill(!1);
1732
- for (let s of Y(t, n)) if (o.fill(!1), Z(e, s.entries, 0, o, s.env, r, i, a, () => vt(e, o, r, i, t))) return !0;
1732
+ for (let s of X(t, n)) if (o.fill(!1), Z(e, s.entries, 0, o, s.env, r, i, a, () => vt(e, o, r, i, t))) return !0;
1733
1733
  return !1;
1734
1734
  }
1735
1735
  function vt(e, t, n, r, i) {
1736
1736
  for (let a = 0; a < t.length; a++) {
1737
1737
  if (t[a]) continue;
1738
1738
  let [o, s] = e.entries[a];
1739
- if (!(o instanceof _)) return r.fail([...n, xt(o, a)], s, i, `entry ${St(o)} is not allowed by the group`), !1;
1739
+ if (!(o instanceof y)) return r.fail([...n, xt(o, a)], s, i, `entry ${St(o)} is not allowed by the group`), !1;
1740
1740
  }
1741
1741
  return !0;
1742
1742
  }
@@ -1751,7 +1751,7 @@ function Z(e, t, n, r, i, a, o, s, c) {
1751
1751
  let [n, i] = e.entries[t];
1752
1752
  if (!yt(l.memberKey, n, l.env, a, o, s)) continue;
1753
1753
  let c = [...a, xt(n, t)];
1754
- if (R(i, l.type, l.env, c, o, s + 1)) {
1754
+ if (z(i, l.type, l.env, c, o, s + 1)) {
1755
1755
  r[t] = !0, u++;
1756
1756
  continue;
1757
1757
  }
@@ -1777,24 +1777,24 @@ function Z(e, t, n, r, i, a, o, s, c) {
1777
1777
  return d(0);
1778
1778
  }
1779
1779
  function yt(e, t, n, r, i, a) {
1780
- if (t = Xe(t), t instanceof _) return !0;
1780
+ if (t = Ye(t), t instanceof y) return !0;
1781
1781
  switch (e.kind) {
1782
1782
  case "bareword": return A(t) === e.key;
1783
- case "value": return H(t, e.key);
1784
- case "type1": return z(t, e.key, n, r, i, a + 1);
1783
+ case "value": return U(t, e.key);
1784
+ case "type1": return B(t, e.key, n, r, i, a + 1);
1785
1785
  }
1786
1786
  }
1787
1787
  function bt(e) {
1788
1788
  switch (e.kind) {
1789
1789
  case "bareword": return `'${e.key}'`;
1790
1790
  case "value": return e.key.raw;
1791
- case "type1": return q(e.key.target);
1791
+ case "type1": return J(e.key.target);
1792
1792
  }
1793
1793
  }
1794
1794
  function xt(e, t) {
1795
1795
  let n = A(e);
1796
1796
  if (n !== void 0) return n;
1797
- if (e instanceof i || e instanceof u) {
1797
+ if (e instanceof d || e instanceof l) {
1798
1798
  let t = e.value;
1799
1799
  if (t >= BigInt(-(2 ** 53 - 1)) && t <= BigInt(2 ** 53 - 1)) return Number(t);
1800
1800
  }
@@ -1802,26 +1802,26 @@ function xt(e, t) {
1802
1802
  }
1803
1803
  function St(e) {
1804
1804
  let t = A(e);
1805
- return t === void 0 ? e instanceof i || e instanceof u ? e.value.toString() : e.constructor.name.replace(/^Cbor/, "").toLowerCase() : JSON.stringify(t);
1805
+ return t === void 0 ? e instanceof d || e instanceof l ? e.value.toString() : e.constructor.name.replace(/^Cbor/, "").toLowerCase() : JSON.stringify(t);
1806
1806
  }
1807
1807
  function Ct(e, t, n) {
1808
1808
  return {
1809
- matchType2: (r, i, a) => B(r, i, e, a, t, n + 1),
1809
+ matchType2: (r, i, a) => V(r, i, e, a, t, n + 1),
1810
1810
  matchEmbedded: (r, i, a) => {
1811
1811
  t.embeddedDepth++;
1812
1812
  try {
1813
- return B(r, i, e, a, t, n + 1);
1813
+ return V(r, i, e, a, t, n + 1);
1814
1814
  } finally {
1815
1815
  t.embeddedDepth--;
1816
1816
  }
1817
1817
  },
1818
- resolveValue: (n) => U(n, e, t),
1819
- existsIntGE: (n, r) => Ze(n, r, e, t),
1820
- matchesLiteral: H,
1818
+ resolveValue: (n) => W(n, e, t),
1819
+ existsIntGE: (n, r) => Xe(n, r, e, t),
1820
+ matchesLiteral: U,
1821
1821
  fail: (e, n, r, i) => t.fail(e, n, r, i),
1822
1822
  warnOnce: (e, n) => t.warnOnce(e, n),
1823
1823
  features: t.features,
1824
- uint: (e) => new i(e)
1824
+ uint: (e) => new d(e)
1825
1825
  };
1826
1826
  }
1827
1827
  //#endregion
@@ -1837,19 +1837,19 @@ var wt = class {
1837
1837
  this.source = e, this.comments = t, this.ast = n, this.rules = r, i && (this.root = i), a.length > 0 && (this.warnings = a);
1838
1838
  }
1839
1839
  format(e) {
1840
- return he(this.ast, {
1840
+ return pe(this.ast, {
1841
1841
  ...e,
1842
1842
  source: this.source,
1843
1843
  comments: this.comments
1844
1844
  });
1845
1845
  }
1846
1846
  validate(e, t) {
1847
- let n = e instanceof a ? e : typeof e == "string" ? m(e) : te(e);
1848
- return Ke(this, n, t);
1847
+ let n = e instanceof o ? e : typeof e == "string" ? h(e) : v(e);
1848
+ return Ge(this, n, t);
1849
1849
  }
1850
1850
  };
1851
1851
  function Tt(e, t) {
1852
- let { rules: n, comments: r } = S(e), i = [], a = w();
1852
+ let { rules: n, comments: r } = w(e), i = [], a = E();
1853
1853
  n.length === 0 && i.push({
1854
1854
  code: "no-rules",
1855
1855
  message: "a CDDL data model needs at least one rule to provide the root of the definition"
@@ -1913,7 +1913,7 @@ function Tt(e, t) {
1913
1913
  message: `the first rule '${c.name}' is the root of the data model and must define a type, not a group (RFC 8610 §2.2.4)`,
1914
1914
  start: c.start,
1915
1915
  end: c.end
1916
- }), (t?.strict ?? !0) && i.length > 0) throw new oe(i);
1916
+ }), (t?.strict ?? !0) && i.length > 0) throw new ie(i);
1917
1917
  return new wt(e, r, n, o, c, i);
1918
1918
  }
1919
1919
  function Et(e) {
@@ -1972,6 +1972,6 @@ function kt(e, t) {
1972
1972
  }
1973
1973
  }
1974
1974
  //#endregion
1975
- export { S as a, oe as c, w as i, v as l, Tt as n, le as o, pe as r, ae as s, wt as t };
1975
+ export { w as a, ie as c, E as i, b as l, Tt as n, se as o, de as r, re as s, wt as t };
1976
1976
 
1977
- //# sourceMappingURL=schema-y8G5mDIS.js.map
1977
+ //# sourceMappingURL=schema-DN9inJny.js.map