@cbortech/cbor 0.26.4 → 0.26.5

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.
package/README.ja.md CHANGED
@@ -324,7 +324,8 @@ syntax を扱う場合のためのものです。
324
324
  デフォルトでは、`CBOR.format()` は `+` による文字列連結を 1 つのリテラルに
325
325
  結合します。`preserveConcatenation` を指定すると、テキスト文字列・バイト文字列とも
326
326
  元の連結の区切りを保持します。`preserveByteString` を併用すると、バイト文字列の
327
- 各パートの元の表記も保持されます。
327
+ 各パートの元の表記も保持されます。分割オプションと同様に `indent` で整形出力が
328
+ 有効な場合のみ効果があり、1 行出力では常に 1 つのリテラルに結合されます。
328
329
 
329
330
  分割オプションとの関係: 文字列の中身が CDN としてパースできる場合は `splitCdn` が
330
331
  `preserveConcatenation` より優先されます。`splitNewline` は共存し、保持した各パートに
@@ -336,14 +337,17 @@ import { CBOR } from '@cbortech/cbor';
336
337
  CBOR.format('"a" + "b"');
337
338
  // '"ab"'
338
339
 
339
- CBOR.format('"a" + "b"', { preserveConcatenation: true });
340
- // '"a" + "b"'
340
+ CBOR.format('"a" + "b"', { indent: 2, preserveConcatenation: true });
341
+ // "a" +
342
+ // "b"
341
343
 
342
344
  CBOR.format("h'68' + b64'aQ'", {
345
+ indent: 2,
343
346
  preserveConcatenation: true,
344
347
  preserveByteString: true,
345
348
  });
346
- // "h'68' + b64'aQ'"
349
+ // h'68' +
350
+ // b64'aQ'
347
351
  ```
348
352
 
349
353
  ### CBOR / CDN / hex dump のバリデーション
package/README.md CHANGED
@@ -328,7 +328,9 @@ handling legacy syntax.
328
328
  By default, `CBOR.format()` joins `+` string concatenation into a single
329
329
  literal. `preserveConcatenation` keeps the original part boundaries for both
330
330
  text strings and byte strings; add `preserveByteString` to also keep the
331
- original spelling of byte string parts.
331
+ original spelling of byte string parts. Like the split options, it only
332
+ takes effect when `indent` enables pretty-printing — single-line output
333
+ always joins the parts.
332
334
 
333
335
  `preserveConcatenation` interacts with the split options: `splitCdn` takes
334
336
  precedence when the string content parses as CDN, while `splitNewline`
@@ -341,14 +343,17 @@ import { CBOR } from '@cbortech/cbor';
341
343
  CBOR.format('"a" + "b"');
342
344
  // '"ab"'
343
345
 
344
- CBOR.format('"a" + "b"', { preserveConcatenation: true });
345
- // '"a" + "b"'
346
+ CBOR.format('"a" + "b"', { indent: 2, preserveConcatenation: true });
347
+ // "a" +
348
+ // "b"
346
349
 
347
350
  CBOR.format("h'68' + b64'aQ'", {
351
+ indent: 2,
348
352
  preserveConcatenation: true,
349
353
  preserveByteString: true,
350
354
  });
351
- // "h'68' + b64'aQ'"
355
+ // h'68' +
356
+ // b64'aQ'
352
357
  ```
353
358
 
354
359
  ### Validate CBOR / CDN / hex dump
@@ -9,6 +9,9 @@ import { CborWriter } from '../cbor/encode';
9
9
  * stored source text verbatim. For `'always'` and `'never'`, it delegates to
10
10
  * the resolved item so the option is applied recursively to every data item;
11
11
  * preserving the source verbatim would leave nested indicators unchanged.
12
+ * In single-line output (no `indent`), a source spelling that spans multiple
13
+ * lines also delegates to the inner item, since it cannot be re-emitted
14
+ * without breaking the single-line guarantee.
12
15
  *
13
16
  * CBOR encoding and JS conversion always delegate to the inner item so the
14
17
  * wrapper is fully transparent for those operations.
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../mapEntries-DDJxbotH.cjs");exports.CborArray=e.C,exports.CborBigNint=e.v,exports.CborBigUint=e.y,exports.CborByteString=e.E,exports.CborEmbeddedCBOR=e.b,exports.CborFloat=e.O,exports.CborIndefiniteByteString=e.T,exports.CborIndefiniteTextString=e.w,exports.CborItem=e.j,exports.CborMap=e.S,exports.CborNint=e.k,exports.CborSimple=e.x,exports.CborTag=e.D,exports.CborTextString=e.g,exports.CborUint=e.A;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../mapEntries-6hy7UgeN.cjs");exports.CborArray=e.C,exports.CborBigNint=e.v,exports.CborBigUint=e.y,exports.CborByteString=e.E,exports.CborEmbeddedCBOR=e.b,exports.CborFloat=e.O,exports.CborIndefiniteByteString=e.T,exports.CborIndefiniteTextString=e.w,exports.CborItem=e.j,exports.CborMap=e.S,exports.CborNint=e.k,exports.CborSimple=e.x,exports.CborTag=e.D,exports.CborTextString=e.g,exports.CborUint=e.A;
package/dist/ast/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, b as s, g as c, j as l, k as u, v as d, w as f, x as p, y as m } from "../mapEntries-hyNVtz5Z.js";
1
+ import { A as e, C as t, D as n, E as r, O as i, S as a, T as o, b as s, g as c, j as l, k as u, v as d, w as f, x as p, y as m } from "../mapEntries-Clr-oNtQ.js";
2
2
  export { t as CborArray, d as CborBigNint, m as CborBigUint, r as CborByteString, s as CborEmbeddedCBOR, i as CborFloat, o as CborIndefiniteByteString, f as CborIndefiniteTextString, l as CborItem, a as CborMap, u as CborNint, p as CborSimple, n as CborTag, c as CborTextString, e as CborUint };
@@ -54,8 +54,9 @@ export declare function resolveSeparators(options: ToCDNOptions | undefined, com
54
54
  * Shared CDN serialization for bracketed containers (CborArray / CborMap /
55
55
  * indefinite-length string chunks `(_ ...)`):
56
56
  * encoding-indicator / `_` prefix resolution, single-line vs multi-line
57
- * selection (comments force multi-line), separators, and per-entry
58
- * leading/trailing plus container dangling comments.
57
+ * selection, separators, and per-entry leading/trailing plus container
58
+ * dangling comments. Single-line output (no `indent`) always strips
59
+ * comments — line comments can only be terminated by a newline.
59
60
  *
60
61
  * Entries are accessed through per-index callbacks (not materialised entry
61
62
  * objects) so the common no-comments path allocates nothing per entry.
@@ -54,7 +54,9 @@ export interface CborExtension {
54
54
  /**
55
55
  * When `true`, the CDN parser wraps the result of `parseAppSequence` in a
56
56
  * `CborAppSeqResult` so that `toCDN()` round-trips the original
57
- * `prefix<<...>>` notation when `appStrings !== false`.
57
+ * `prefix<<...>>` notation when `appStrings !== false`. In single-line
58
+ * output (no `indent`), a source spelling that spans multiple lines falls
59
+ * back to serializing the resolved item instead.
58
60
  *
59
61
  * Extensions whose result is already a subclass that handles source
60
62
  * preservation itself (e.g. `CborFloat` via its `ednSource` property) should
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./tokenizer-EciPlN0n.cjs"),t=require("./mapEntries-DDJxbotH.cjs");var n=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,r=`0123456789ABCDEFGHIJKLMNOPQRSTUV`;function i(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===61;)t--;return e.slice(0,t)}function a(e,t,n){let r=i(e).toUpperCase(),a=r.length%8;if(a===1||a===3||a===6)throw SyntaxError(`invalid base32 length: ${r.length} characters`);let o=new Uint8Array(128).fill(255);for(let e=0;e<t.length;e++)o[t.charCodeAt(e)]=e;let s=new Uint8Array(Math.floor(r.length*5/8)),c=0,l=0,u=0;for(let e of r){let t=e.charCodeAt(0),n=t<128?o[t]:255;if(n===255)throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);c=c<<5|n,l+=5,l>=8&&(l-=8,s[u++]=c>>l&255)}if(l>0&&c&(1<<l)-1){let e=`non-zero trailing bits in base32 input`;if(n)n(e);else throw SyntaxError(e)}return s}var o={appStringPrefixes:[`b32`],parseAppString(e,r,i){return new t.E(a(t.o(r),n,i),{ednEncoding:`base32`})}},s={appStringPrefixes:[`h32`],parseAppString(e,n,i){return new t.E(a(t.o(n),r,i),{ednEncoding:`base32hex`})}};function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var l={appStringPrefixes:[`same`],preserveAppSeqSource:!0,parseAppSequence(e,t,n){if(t.length===0)throw SyntaxError(`same<<...>> requires at least one item`);let r=t[0],i=r.toCBOR();for(let e=1;e<t.length;e++)if(!c(i,t[e].toCBOR())){let t=`same<<...>>: item ${e} produces different CBOR bytes than item 0`;if(n)n(t);else throw SyntaxError(t)}return r}},u=class n{static OMIT=t.N;static TAG=t.P;static Tag=t.I;static Simple=t.M;static MapEntries=t.t;static dt_as_Date=t.h;#e;constructor(e){this.#e=e??{}}#t(e){return{...this.#e,...e??{}}}fromCBOR(e,t){let r=n.fromCBOR(e,this.#t(t));return r._defaults=this.#e,r}fromCDN(e,t){let r=n.fromCDN(e,this.#t(t));return r._defaults=this.#e,r}fromEDN(e,t){return this.fromCDN(e,t)}fromJS(e,t){let r=n.fromJS(e,this.#t(t));return r._defaults=this.#e,r}fromHexDump(e,t){let r=n.fromHexDump(e,this.#t(t));return r._defaults=this.#e,r}*fromCBORSeq(e,t){for(let r of n.fromCBORSeq(e,this.#t(t)))r._defaults=this.#e,yield r}*fromCDNSeq(e,t){for(let r of n.fromCDNSeq(e,this.#t(t)))r._defaults=this.#e,yield r}*fromHexDumpSeq(e,t){for(let r of n.fromHexDumpSeq(e,this.#t(t)))r._defaults=this.#e,yield r}decode(e,t){return n.decode(e,this.#t(t))}*decodeSeq(e,t){yield*n.decodeSeq(e,this.#t(t))}*parseSeq(e,t){yield*n.parseSeq(e,this.#t(t))}encode(e,t){return n.encode(e,this.#t(t))}compile(e,t){return n.compile(e,this.#t(t))}decompile(e,t){return n.decompile(e,this.#t(t))}toHex(e,t){return n.toHex(e,this.#t(t))}fromHex(e,t){return n.fromHex(e,this.#t(t))}validate(e,t){return n.validate(e,this.#t(t))}cborToCborEdn(e,t){return this.cborToCdn(e,t)}cborToCdn(e,t){let r=this.#t(t),i=n.fromCBOR(e,r);return i._defaults=this.#e,i.toCDN(r)}cborEdnToCbor(e,t){return this.cdnToCbor(e,t)}cdnToCbor(e,t){let r=this.#t(t);return n.fromCDN(e,r).toCBOR(r)}parse(e,t){if(typeof t==`function`){let r=this.#t({reviver:t});return n.fromCDN(e,r).toJS(r)}let r=this.#t(t);return n.fromCDN(e,r).toJS(r)}stringify(e,t,r){if(typeof t==`function`||Array.isArray(t)||t===null||t===void 0&&r!==void 0){let i={...this.#e};return t===null?i.replacer=void 0:(typeof t==`function`||Array.isArray(t))&&(i.replacer=t),r!==void 0&&(i.indent=_(r)),n.stringify(e,i)}return n.stringify(e,this.#t(t??void 0))}format(e,t){return n.format(e,this.#t(t))}static fromCBOR(e,n){return t.d(e,n)}static fromCDN(e,n){return t._(e,n)}static fromEDN(e,t){return n.fromCDN(e,t)}static*fromHexDumpSeq(e,t){let r=[],i=d(e).trim().split(/\s+/).filter(Boolean);for(let e of i)if(/^[0-9A-Fa-f]{2}$/.test(e))r.push(parseInt(e,16));else if(/^[0-9A-Fa-f]+$/.test(e)&&e.length%2==0)for(let t=0;t<e.length;t+=2)r.push(parseInt(e.slice(t,t+2),16));else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);yield*n.fromCBORSeq(new Uint8Array(r),t)}static*fromCBORSeq(e,n){let r=e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=0;for(;i<r.byteLength;){let e=t.d(r,{...n,offset:i,allowTrailing:!0});yield e,i=e.end}}static*fromCDNSeq(n,r){let i=!!r?.preserveComments,a=0,o=!0;for(;;){let{offset:s,hadSeparator:c,commaOffset:l}=g(n,a,r,i?o?`all`:`after-newline`:`none`);if(o&&l>=0){let e=`leading comma in CDN sequence`;if(r?.strict!==!1)throw SyntaxError(e);m(e,l,r)}if(s>=n.length||i&&h(n,s)&&g(n,s,r).offset>=n.length)break;if(!o&&!c){let e=`CDN sequence items must be separated by whitespace, comma, or comment`;if(r?.strict!==!1)throw SyntaxError(e);m(e,s,r)}a=s;let u;try{u=t._(n,{...r,offset:a,allowTrailing:!0,_skipRS:!0})}catch(t){if(r?.strict!==!1)throw t;m(t instanceof Error?t.message:String(t),a,r,!0,t instanceof e.o?t:void 0);break}yield u,a=u.end,o=!1}}static fromJS(e,n){return t.r(e,n)}static fromHexDump(e,n){let r=[],i=d(e).trim().split(/\s+/).filter(Boolean);for(let e of i)if(/^[0-9A-Fa-f]{2}$/.test(e))r.push(parseInt(e,16));else if(/^[0-9A-Fa-f]+$/.test(e)&&e.length%2==0)for(let t=0;t<e.length;t+=2)r.push(parseInt(e.slice(t,t+2),16));else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);return t.d(new Uint8Array(r),n)}static decode(e,t){return n.fromCBOR(e,t).toJS(t)}static*decodeSeq(e,t){for(let r of n.fromCBORSeq(e,t))yield r.toJS(t)}static*parseSeq(e,t){for(let r of n.fromCDNSeq(e,t))yield r.toJS(t)}static encode(e,t){return n.fromJS(e,t).toCBOR(t)}static compile(e,t){let r=[...n.fromCDNSeq(e,t)].map(e=>e.toCBOR(t)),i=r.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}static decompile(e,t){return[...n.fromCBORSeq(e,t)].map(e=>e.toCDN(t)).join(`
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./tokenizer-EciPlN0n.cjs"),t=require("./mapEntries-6hy7UgeN.cjs");var n=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,r=`0123456789ABCDEFGHIJKLMNOPQRSTUV`;function i(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===61;)t--;return e.slice(0,t)}function a(e,t,n){let r=i(e).toUpperCase(),a=r.length%8;if(a===1||a===3||a===6)throw SyntaxError(`invalid base32 length: ${r.length} characters`);let o=new Uint8Array(128).fill(255);for(let e=0;e<t.length;e++)o[t.charCodeAt(e)]=e;let s=new Uint8Array(Math.floor(r.length*5/8)),c=0,l=0,u=0;for(let e of r){let t=e.charCodeAt(0),n=t<128?o[t]:255;if(n===255)throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);c=c<<5|n,l+=5,l>=8&&(l-=8,s[u++]=c>>l&255)}if(l>0&&c&(1<<l)-1){let e=`non-zero trailing bits in base32 input`;if(n)n(e);else throw SyntaxError(e)}return s}var o={appStringPrefixes:[`b32`],parseAppString(e,r,i){return new t.E(a(t.o(r),n,i),{ednEncoding:`base32`})}},s={appStringPrefixes:[`h32`],parseAppString(e,n,i){return new t.E(a(t.o(n),r,i),{ednEncoding:`base32hex`})}};function c(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}var l={appStringPrefixes:[`same`],preserveAppSeqSource:!0,parseAppSequence(e,t,n){if(t.length===0)throw SyntaxError(`same<<...>> requires at least one item`);let r=t[0],i=r.toCBOR();for(let e=1;e<t.length;e++)if(!c(i,t[e].toCBOR())){let t=`same<<...>>: item ${e} produces different CBOR bytes than item 0`;if(n)n(t);else throw SyntaxError(t)}return r}},u=class n{static OMIT=t.N;static TAG=t.P;static Tag=t.I;static Simple=t.M;static MapEntries=t.t;static dt_as_Date=t.h;#e;constructor(e){this.#e=e??{}}#t(e){return{...this.#e,...e??{}}}fromCBOR(e,t){let r=n.fromCBOR(e,this.#t(t));return r._defaults=this.#e,r}fromCDN(e,t){let r=n.fromCDN(e,this.#t(t));return r._defaults=this.#e,r}fromEDN(e,t){return this.fromCDN(e,t)}fromJS(e,t){let r=n.fromJS(e,this.#t(t));return r._defaults=this.#e,r}fromHexDump(e,t){let r=n.fromHexDump(e,this.#t(t));return r._defaults=this.#e,r}*fromCBORSeq(e,t){for(let r of n.fromCBORSeq(e,this.#t(t)))r._defaults=this.#e,yield r}*fromCDNSeq(e,t){for(let r of n.fromCDNSeq(e,this.#t(t)))r._defaults=this.#e,yield r}*fromHexDumpSeq(e,t){for(let r of n.fromHexDumpSeq(e,this.#t(t)))r._defaults=this.#e,yield r}decode(e,t){return n.decode(e,this.#t(t))}*decodeSeq(e,t){yield*n.decodeSeq(e,this.#t(t))}*parseSeq(e,t){yield*n.parseSeq(e,this.#t(t))}encode(e,t){return n.encode(e,this.#t(t))}compile(e,t){return n.compile(e,this.#t(t))}decompile(e,t){return n.decompile(e,this.#t(t))}toHex(e,t){return n.toHex(e,this.#t(t))}fromHex(e,t){return n.fromHex(e,this.#t(t))}validate(e,t){return n.validate(e,this.#t(t))}cborToCborEdn(e,t){return this.cborToCdn(e,t)}cborToCdn(e,t){let r=this.#t(t),i=n.fromCBOR(e,r);return i._defaults=this.#e,i.toCDN(r)}cborEdnToCbor(e,t){return this.cdnToCbor(e,t)}cdnToCbor(e,t){let r=this.#t(t);return n.fromCDN(e,r).toCBOR(r)}parse(e,t){if(typeof t==`function`){let r=this.#t({reviver:t});return n.fromCDN(e,r).toJS(r)}let r=this.#t(t);return n.fromCDN(e,r).toJS(r)}stringify(e,t,r){if(typeof t==`function`||Array.isArray(t)||t===null||t===void 0&&r!==void 0){let i={...this.#e};return t===null?i.replacer=void 0:(typeof t==`function`||Array.isArray(t))&&(i.replacer=t),r!==void 0&&(i.indent=_(r)),n.stringify(e,i)}return n.stringify(e,this.#t(t??void 0))}format(e,t){return n.format(e,this.#t(t))}static fromCBOR(e,n){return t.d(e,n)}static fromCDN(e,n){return t._(e,n)}static fromEDN(e,t){return n.fromCDN(e,t)}static*fromHexDumpSeq(e,t){let r=[],i=d(e).trim().split(/\s+/).filter(Boolean);for(let e of i)if(/^[0-9A-Fa-f]{2}$/.test(e))r.push(parseInt(e,16));else if(/^[0-9A-Fa-f]+$/.test(e)&&e.length%2==0)for(let t=0;t<e.length;t+=2)r.push(parseInt(e.slice(t,t+2),16));else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);yield*n.fromCBORSeq(new Uint8Array(r),t)}static*fromCBORSeq(e,n){let r=e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength),i=0;for(;i<r.byteLength;){let e=t.d(r,{...n,offset:i,allowTrailing:!0});yield e,i=e.end}}static*fromCDNSeq(n,r){let i=!!r?.preserveComments,a=0,o=!0;for(;;){let{offset:s,hadSeparator:c,commaOffset:l}=g(n,a,r,i?o?`all`:`after-newline`:`none`);if(o&&l>=0){let e=`leading comma in CDN sequence`;if(r?.strict!==!1)throw SyntaxError(e);m(e,l,r)}if(s>=n.length||i&&h(n,s)&&g(n,s,r).offset>=n.length)break;if(!o&&!c){let e=`CDN sequence items must be separated by whitespace, comma, or comment`;if(r?.strict!==!1)throw SyntaxError(e);m(e,s,r)}a=s;let u;try{u=t._(n,{...r,offset:a,allowTrailing:!0,_skipRS:!0})}catch(t){if(r?.strict!==!1)throw t;m(t instanceof Error?t.message:String(t),a,r,!0,t instanceof e.o?t:void 0);break}yield u,a=u.end,o=!1}}static fromJS(e,n){return t.r(e,n)}static fromHexDump(e,n){let r=[],i=d(e).trim().split(/\s+/).filter(Boolean);for(let e of i)if(/^[0-9A-Fa-f]{2}$/.test(e))r.push(parseInt(e,16));else if(/^[0-9A-Fa-f]+$/.test(e)&&e.length%2==0)for(let t=0;t<e.length;t+=2)r.push(parseInt(e.slice(t,t+2),16));else throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);return t.d(new Uint8Array(r),n)}static decode(e,t){return n.fromCBOR(e,t).toJS(t)}static*decodeSeq(e,t){for(let r of n.fromCBORSeq(e,t))yield r.toJS(t)}static*parseSeq(e,t){for(let r of n.fromCDNSeq(e,t))yield r.toJS(t)}static encode(e,t){return n.fromJS(e,t).toCBOR(t)}static compile(e,t){let r=[...n.fromCDNSeq(e,t)].map(e=>e.toCBOR(t)),i=r.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}static decompile(e,t){return[...n.fromCBORSeq(e,t)].map(e=>e.toCDN(t)).join(`
2
2
  `)}static toHex(e,t){return[...n.fromCBORSeq(e,t)].map(e=>e.toHexDump(t)).join(`
3
3
  `)}static fromHex(e,t){let r=[...n.fromHexDumpSeq(e,t)].map(e=>e.toCBOR(t)),i=r.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.length;return a}static validate(t,r){let i=[],a=[],o,s={strict:!1,extensions:r?.extensions,builtinExtensions:r?.builtinExtensions,onWarning:e=>{if(`hint`in e&&e.hint){a.push(e);return}if(`fatal`in e&&e.fatal){o=e;return}i.push(e)}},c=0;try{let e=r?.type??`cbor`;if(e===`cdn`){let e={...s,unresolvedExtension:r?.unresolvedExtension};for(let r of n.fromCDNSeq(t,e))c++}else if(e===`hex`)for(let e of n.fromHexDumpSeq(t,s))c++;else for(let e of n.fromCBORSeq(t,s))c++}catch(e){return{valid:!1,count:c,warnings:i,hints:a,error:e instanceof Error?e:Error(String(e))}}if(o){let t=o.cause instanceof Error?o.cause:new e.o(o.message,{offset:o.offset});return{valid:!1,count:c,warnings:i,hints:a,error:t}}return{valid:i.length===0,count:c,warnings:i,hints:a}}static cborToCdn(e,t){return n.fromCBOR(e,t).toCDN(t)}static cborToCborEdn(e,t){return n.fromCBOR(e,t).toCDN(t)}static cdnToCbor(e,t){return n.fromCDN(e,t).toCBOR(t)}static cborEdnToCbor(e,t){return n.fromCDN(e,t).toCBOR(t)}static parse(e,t){return typeof t==`function`?n.fromCDN(e).toJS({reviver:t}):n.fromCDN(e,t).toJS(t)}static stringify(e,n,r){if(typeof n==`function`||Array.isArray(n)||n===null||n===void 0&&r!==void 0){let i=typeof n==`function`||Array.isArray(n)?n:void 0,a=_(r);if(i){let n=t.n(e,i);return n===void 0||n===t.N?void 0:t.r(n).toCDN(a===void 0?void 0:{indent:a})}return t.r(e).toCDN(a===void 0?void 0:{indent:a})}let i=n;if(i?.replacer){let n=t.n(e,i.replacer,i.extensions,i.undefinedOmits,i.builtinExtensions);if(n===void 0||n===t.N)return;let{replacer:r,...a}=i;return t.r(n,Object.keys(a).length>0?a:void 0).toCDN(i)}return t.r(e,i).toCDN(i)}static format(e,t){return n.fromCDN(e,t).toCDN(t)}};function d(e){let t=``,n=0;for(;n<e.length;){let r=e[n],i=e[n+1]??``;if(r===`-`&&i===`-`){n=f(e,n+2),t+=` `;continue}if(r===`—`){n=f(e,n+1),t+=` `;continue}if(r===`#`){n=f(e,n+1),t+=` `;continue}if(r===`/`&&i===`/`){n=f(e,n+2),t+=` `;continue}if(r===`/`&&i===`*`){let r=e.indexOf(`*/`,n+2);if(r<0)throw SyntaxError(`Unterminated comment in hex dump`);t+=p(e.slice(n,r+2)),n=r+2;continue}if(r===`/`){let r=e.indexOf(`/`,n+1);if(r<0)throw SyntaxError(`Unterminated comment in hex dump`);t+=p(e.slice(n,r+1)),n=r+1;continue}t+=r,n++}return t}function f(e,t){let n=e.indexOf(`
4
4
  `,t);return n<0?e.length:n}function p(e){return e.replace(/[^\r\n]/g,` `)}function m(e,t,n,r,i){let a=i?.offset??t,o={message:e,offset:a};r&&(o.fatal=!0),i&&(o.cause=i),i?.offset!==void 0&&(o.line=i.line,o.column=i.column,o.endOffset=i.endOffset),n?.onWarning?n.onWarning(o):n?.silent||console.warn(`CDN sequence warning at offset ${a}: ${e}`)}function h(e,t){let n=e[t];return n===`#`||n===`/`}function g(e,t,n,r=`none`){let i=t,a=!1,o=!1,s=!1,c=-1,l=()=>r===`all`||r===`after-newline`&&s;for(;i<e.length;){let t=e[i];if(t===` `||t===` `||t===`\r`||t===``){a=!0,i++;continue}if(t===`
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { o as e } from "./tokenizer-CeuixxXi.js";
2
- import { E as t, F as n, I as r, L as i, M as a, N as o, P as s, _ as c, a as l, c as u, d, f, h as p, i as m, l as h, m as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./mapEntries-hyNVtz5Z.js";
2
+ import { E as t, F as n, I as r, L as i, M as a, N as o, P as s, _ as c, a as l, c as u, d, f, h as p, i as m, l as h, m as g, n as _, o as v, p as y, r as b, s as x, t as S, u as C } from "./mapEntries-Clr-oNtQ.js";
3
3
  //#region src/extensions/b32.ts
4
4
  var w = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", T = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
5
5
  function E(e) {
@@ -1,10 +1,10 @@
1
- const e=require("./tokenizer-EciPlN0n.cjs");var t=Symbol.for(`cbor.tag`),n=class{valueOf(){return null}toJSON(){return null}},r=class{valueOf(){}toJSON(){}};function i(e){if(!c(e))return;let n=e[t];return typeof n==`bigint`?n:void 0}function a(e,i){let a;switch(typeof e){case`number`:a=new Number(e);break;case`string`:a=new String(e);break;case`boolean`:a=new Boolean(e);break;case`bigint`:a=Object(e);break;case`undefined`:a=new r;break;case`object`:if(e===null){a=new n;break}a=e;break;default:throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`)}return a[t]=i,a}function o(e){if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.prototype.toString.call(e)===`[object BigInt]`)return e.valueOf();if(e instanceof n)return null;if(!(e instanceof r))return typeof e==`object`&&e&&delete e[t],e}function s(e){if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.prototype.toString.call(e)===`[object BigInt]`)return e.valueOf();if(e instanceof n)return null;if(!(e instanceof r))return e}function c(e){return typeof e==`object`&&!!e}var l=class{constructor(){}static symbol=t;static Null=n;static Undefined=r;static get(e){return i(e)}static set(e,t){return a(e,t)}static remove(e){return o(e)}static getValue(e){return s(e)}},u=Symbol(`cbor.omit`),d=class e{value;constructor(e){if(!Number.isInteger(e)||e<0||e>255)throw RangeError(`Simple value must be an integer in 0–255`);this.value=e}valueOf(){return this.value}toJSON(){throw TypeError(`simple(${this.value}) cannot be serialized to JSON`)}static is(t){return t instanceof e}static get(t){return t instanceof e?t.value:void 0}};function f(e){let t=e?.indent;return t===void 0?null:typeof t==`number`?` `.repeat(t):t}function p(e,t){return e.repeat(t)}function m(e,t,n){return t===null?e.join(` + `):e.join(` +\n${p(t,n+1)}`)}function h(e){return!!(e.comments?.leading?.length||e.comments?.trailing?.length||e.comments?.dangling?.length)}function ee(e){return!!(e.comments?.trailing?.length||e.comments?.dangling?.length)}function g(e,t){if(!t)return e.text;let{marker:n,text:r}=e;if(t===`c-style`)return n===`#`?`//`+r.slice(1):n===`/`?`/*`+r.slice(1,-1)+`*/`:r;if(n===`//`)return`#`+r.slice(2);if(n===`/*`){let e=r.slice(2,-2);return e.includes(`/`)?r:`/`+(e.startsWith(`*`)||e.startsWith(`/`)?` `+e:e)+`/`}return r}function te(e,t,n){return(e.comments?.leading??[]).map(e=>t+g(e,n))}function _(e,t){let n=e.comments?.trailing??[];return n.length===0?``:` `+n.map(e=>g(e,t)).join(` `)}function ne(e,t,n){return(e.comments?.dangling??[]).map(e=>t+g(e,n))}function re(e,t=!1){let n=e?.commas??`comma`,r=n!==`none`;return{inlineSep:r?t?`,`:`, `:` `,multilineSep:r?`,`:``,trailSep:n===`trailing`?`,`:``,colSep:t?`:`:`: `}}function v(e){let{options:t,depth:n,openChar:r,closeChar:i,count:a}=e,o=f(t),s=t?.preserveComments,c=typeof s==`string`?s:void 0,l=s&&(ee(e.node)||e.hasEntryComments());o===null&&l&&(o=` `);let{inlineSep:u,multilineSep:d,trailSep:m,colSep:h}=re(t,o===null),g=e.indefiniteLength?``:x(t,e.encodingWidth,()=>b(BigInt(a))),_=g?g+` `:``,v=e.indefiniteLength&&(t?.encodingIndicators??`auto`)!==`never`,ie=t=>e.indefiniteLength?v?a===0?`${r}_ ${i}`:`${r}_ ${t}${i}`:`${r}${t}${i}`:`${r}${_}${t}${i}`;if(o===null||a===0&&!l){let t=``;for(let n=0;n<a;n++)n>0&&(t+=u),t+=e.renderEntry(n,h);return ie(t)}let ae=null;if(t?.inlineLeafContainers&&a>0&&!l){let t=[],n=!0;for(let r=0;r<a;r++){if(e.entryIsLeaf&&!e.entryIsLeaf(r)){n=!1;break}let i=e.renderEntry(r,h);if(t.push(i),i.includes(`
1
+ const e=require("./tokenizer-EciPlN0n.cjs");var t=Symbol.for(`cbor.tag`),n=class{valueOf(){return null}toJSON(){return null}},r=class{valueOf(){}toJSON(){}};function i(e){if(!c(e))return;let n=e[t];return typeof n==`bigint`?n:void 0}function a(e,i){let a;switch(typeof e){case`number`:a=new Number(e);break;case`string`:a=new String(e);break;case`boolean`:a=new Boolean(e);break;case`bigint`:a=Object(e);break;case`undefined`:a=new r;break;case`object`:if(e===null){a=new n;break}a=e;break;default:throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`)}return a[t]=i,a}function o(e){if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.prototype.toString.call(e)===`[object BigInt]`)return e.valueOf();if(e instanceof n)return null;if(!(e instanceof r))return typeof e==`object`&&e&&delete e[t],e}function s(e){if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.prototype.toString.call(e)===`[object BigInt]`)return e.valueOf();if(e instanceof n)return null;if(!(e instanceof r))return e}function c(e){return typeof e==`object`&&!!e}var l=class{constructor(){}static symbol=t;static Null=n;static Undefined=r;static get(e){return i(e)}static set(e,t){return a(e,t)}static remove(e){return o(e)}static getValue(e){return s(e)}},u=Symbol(`cbor.omit`),d=class e{value;constructor(e){if(!Number.isInteger(e)||e<0||e>255)throw RangeError(`Simple value must be an integer in 0–255`);this.value=e}valueOf(){return this.value}toJSON(){throw TypeError(`simple(${this.value}) cannot be serialized to JSON`)}static is(t){return t instanceof e}static get(t){return t instanceof e?t.value:void 0}};function f(e){let t=e?.indent;if(t===void 0)return null;let n=typeof t==`number`?` `.repeat(t):t;return n===``?null:n}function p(e,t){return e.repeat(t)}function m(e,t,n){return t===null?e.join(` + `):e.join(` +\n${p(t,n+1)}`)}function h(e){return!!(e.comments?.leading?.length||e.comments?.trailing?.length||e.comments?.dangling?.length)}function ee(e){return!!(e.comments?.trailing?.length||e.comments?.dangling?.length)}function g(e,t){if(!t)return e.text;let{marker:n,text:r}=e;if(t===`c-style`)return n===`#`?`//`+r.slice(1):n===`/`?`/*`+r.slice(1,-1)+`*/`:r;if(n===`//`)return`#`+r.slice(2);if(n===`/*`){let e=r.slice(2,-2);return e.includes(`/`)?r:`/`+(e.startsWith(`*`)||e.startsWith(`/`)?` `+e:e)+`/`}return r}function te(e,t,n){return(e.comments?.leading??[]).map(e=>t+g(e,n))}function _(e,t){let n=e.comments?.trailing??[];return n.length===0?``:` `+n.map(e=>g(e,t)).join(` `)}function ne(e,t,n){return(e.comments?.dangling??[]).map(e=>t+g(e,n))}function re(e,t=!1){let n=e?.commas??`comma`,r=n!==`none`;return{inlineSep:r?t?`,`:`, `:` `,multilineSep:r?`,`:``,trailSep:n===`trailing`?`,`:``,colSep:t?`:`:`: `}}function v(e){let{options:t,depth:n,openChar:r,closeChar:i,count:a}=e,o=f(t),s=t?.preserveComments,c=typeof s==`string`?s:void 0,l=o!==null&&s&&(ee(e.node)||e.hasEntryComments()),{inlineSep:u,multilineSep:d,trailSep:m,colSep:h}=re(t,o===null),g=e.indefiniteLength?``:x(t,e.encodingWidth,()=>b(BigInt(a))),_=g?g+` `:``,v=e.indefiniteLength&&(t?.encodingIndicators??`auto`)!==`never`,ie=t=>e.indefiniteLength?v?a===0?`${r}_ ${i}`:`${r}_ ${t}${i}`:`${r}${t}${i}`:`${r}${_}${t}${i}`;if(o===null||a===0&&!l){let t=``;for(let n=0;n<a;n++)n>0&&(t+=u),t+=e.renderEntry(n,h);return ie(t)}let ae=null;if(t?.inlineLeafContainers&&a>0&&!l){let t=[],n=!0;for(let r=0;r<a;r++){if(e.entryIsLeaf&&!e.entryIsLeaf(r)){n=!1;break}let i=e.renderEntry(r,h);if(t.push(i),i.includes(`
2
2
  `)){n=!1;break}}if(n)return ie(t.join(u));ae=t}let oe=p(o,n+1),se=p(o,n),ce=e.indefiniteLength?v?`${r}_ `:r:`${r}${_}`,y=[];for(let t=0;t<a;t++){s&&y.push(...te(e.entryLeadingNode(t),oe,c));let n=t<a-1?d:m,r=ae?.[t]??e.renderEntry(t,h);y.push(`${oe}${r}${n}${s?e.entryTrailing(t,c):``}`)}return s&&y.push(...ne(e.node,oe,c)),`${ce}\n${y.join(`
3
- `)}\n${se}${i}`}var ie=typeof new Uint8Array().toBase64==`function`;function ae(e){if(ie)return e.toBase64({omitPadding:!0});let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/=/g,``)}function oe(e){if(ie)return e.toBase64({alphabet:`base64url`,omitPadding:!0});let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}var se=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,ce=`0123456789ABCDEFGHIJKLMNOPQRSTUV`;function y(e,t){let n=``,r=0,i=0;for(let a of e)for(r=r<<8|a,i+=8;i>=5;)i-=5,n+=t[r>>i&31];return i>0&&(n+=t[r<<5-i&31]),n}function le(e){for(let t of e){let e=t.codePointAt(0);if(e<32||e===127)return!0}return!1}function ue(t,n,r){if(r===`string`){let e=fe(t);if(e!=null)return he(e)}if(r===`printable-string`||r===void 0){let e=fe(t);if(e!=null&&!le(e))return he(e)}switch(n){case`base64`:return`b64'${ae(t)}'`;case`base64url`:return`b64'${oe(t)}'`;case`base32`:return`b32'${y(t,se)}'`;case`base32hex`:return`h32'${y(t,ce)}'`;default:return`h'${e.r(t)}'`}}var de=new TextDecoder(`utf-8`,{fatal:!0});function fe(e){try{return de.decode(e)}catch{return null}}function pe(e,t){for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===t||r===92||r<32||r===127||r>=8192&&(r===8232||r===8233||r>=8203&&r<=8205||r===65279))return!0}return!1}function me(e,t){let n=t.codePointAt(0);if(!pe(e,n))return t+e+t;let r=t;for(let i of e){let e=i.codePointAt(0);switch(e){case n:r+=`\\${t}`;break;case 92:r+=`\\\\`;break;case 10:r+=`\\n`;break;case 13:r+=`\\r`;break;case 9:r+=`\\t`;break;default:e<32||e===127||e===8232||e===8233||e===8203||e===8204||e===8205||e===65279?r+=`\\u${e.toString(16).padStart(4,`0`)}`:r+=i}}return r+t}function he(e){return me(e,`'`)}function ge(e){return me(e,`'`)}function _e(e){return me(e,`"`)}function ve(e){if(isNaN(e))return`NaN`;if(!isFinite(e))return e>0?`Infinity`:`-Infinity`;if(Object.is(e,-0))return`-0.0`;let t=e.toString();return t.includes(`.`)||t.includes(`e`)?t:t+`.0`}function ye(e,t,n,r){if(r===`never`)return``;let i=t??n;return r===`always`?i===`half`?`_1`:i===`single`?`_2`:`_3`:t===void 0||t===n?``:t===`half`?`_1`:t===`single`?`_2`:`_3`}function b(e){return e<=23n?`i`:e<=255n?0:e<=65535n?1:e<=4294967295n?2:3}function x(e,t,n){let r=e?.encodingIndicators??`auto`;return r===`never`?``:r===`always`?`_${t??n()}`:t===void 0?``:`_${t}`}var be=`getFloat16`in DataView.prototype&&`setFloat16`in DataView.prototype,xe=new DataView(new ArrayBuffer(8));function S(e){xe.setFloat64(0,e,!1);let t=xe.getUint32(0,!1),n=xe.getUint32(4,!1),r=t>>>31&1,i=t>>>20&2047,a=t&1048575;if(i===2047){if(a===0&&n===0)return r<<15|31744;let e=a>>10|(n===0?0:1)||1;return r<<15|31744|e&1023}let o=i-1023+15;if(o>=31)return r<<15|31744;let s,c,l;if(o<=0){if(o<-10)return r<<15;let e=1<<20|a,t=11-o;t<=20?(s=e>>t&1023,c=e>>t-1&1,l=(e&(1<<t-1)-1)!=0||n!==0):(s=0,c=1,l=a!==0||n!==0)}else s=a>>10,c=a>>9&1,l=(a&511)!=0||n!==0;if(c!==0&&(l||s&1)&&s++,s>=1024){let e=o<=0?1:o+1;return e>=31?r<<15|31744:r<<15|e<<10}let u=o<=0?0:o;return r<<15|u<<10|s}function C(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023;return n===31?r===0?t?-1/0:1/0:NaN:n===0?r===0?t?-0:0:(t?-1:1)*2**-14*(r/1024):(t?-1:1)*2**(n-15)*(1+r/1024)}var Se=be?(e,t,n,r)=>{e.setFloat16(t,n,r)}:(e,t,n,r)=>{e.setUint16(t,S(n),r)},Ce=new DataView(new ArrayBuffer(8)),w=new Uint8Array(Ce.buffer),we=new TextEncoder,Te=typeof we.encodeInto==`function`;function Ee(e){return e<=23?1:e<=255?2:e<=65535?3:e<=4294967295?5:9}function De(e){return e===`i`?1:[2,3,5,9][e]}var Oe=class{buf;len=0;constructor(e=256){this.buf=new Uint8Array(e)}_ensure(e){let t=this.len+e;if(t<=this.buf.length)return;let n=this.buf.length*2;for(;n<t;)n*=2;let r=new Uint8Array(n);r.set(this.buf),this.buf=r}writeByte(e){this._ensure(1),this.buf[this.len++]=e}writeBytes(e){this._ensure(e.length),this.buf.set(e,this.len),this.len+=e.length}writeUint16(e){this._ensure(2);let t=this.buf;t[this.len++]=e>>>8&255,t[this.len++]=e&255}writeUint32(e){this._ensure(4);let t=this.buf;t[this.len++]=e>>>24&255,t[this.len++]=e>>>16&255,t[this.len++]=e>>>8&255,t[this.len++]=e&255}writeBigUint64(e){Ce.setBigUint64(0,e,!1),this._ensure(8),this.buf.set(w,this.len),this.len+=8}writeFloat16(e){Se(Ce,0,e,!1),this._ensure(2);let t=this.buf;t[this.len++]=w[0],t[this.len++]=w[1]}writeFloat32(e){Ce.setFloat32(0,e,!1),this._ensure(4);let t=this.buf;t[this.len++]=w[0],t[this.len++]=w[1],t[this.len++]=w[2],t[this.len++]=w[3]}writeFloat64(e){Ce.setFloat64(0,e,!1),this._ensure(8),this.buf.set(w,this.len),this.len+=8}writeTextString(e,t,n){if(!Te){let r=we.encode(t);T(this,e,r.length,n),this.writeBytes(r);return}let r=n===void 0?Ee(t.length):De(n);this._ensure(9+3*t.length);let{written:i}=we.encodeInto(t,this.buf.subarray(this.len+r)),a=n===void 0?Ee(i):r;a!==r&&this.buf.copyWithin(this.len+a,this.len+r,this.len+r+i),T(this,e,i,n),this.len+=i}finish(){return this.buf.slice(0,this.len)}},ke=[255n,65535n,4294967295n,18446744073709551615n];function Ae(e){return e===`i`?23n:ke[e]}function T(e,t,n,r){if(r===void 0&&typeof n==`number`&&n<4294967296){n<=23?e.writeByte(t<<5|n):n<=255?(e.writeByte(t<<5|24),e.writeByte(n)):n<=65535?(e.writeByte(t<<5|25),e.writeUint16(n)):(e.writeByte(t<<5|26),e.writeUint32(n));return}let i=typeof n==`number`?BigInt(n):n;if(r!==void 0){if(r===`i`){if(i>23n)throw RangeError(`value ${i} does not fit in immediate encoding _i (max 23)`);e.writeByte(t<<5|Number(i));return}if(i>ke[r])throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${ke[r]})`);let n=24+r;e.writeByte(t<<5|n),n===24?e.writeByte(Number(i)):n===25?e.writeUint16(Number(i)):n===26?e.writeUint32(Number(i)):e.writeBigUint64(i);return}i<=23n?e.writeByte(t<<5|Number(i)):i<=255n?(e.writeByte(t<<5|24),e.writeByte(Number(i))):i<=65535n?(e.writeByte(t<<5|25),e.writeUint16(Number(i))):i<=4294967295n?(e.writeByte(t<<5|26),e.writeUint32(Number(i))):(e.writeByte(t<<5|27),e.writeBigUint64(i))}function je(e,t,n){let r=new Oe(9);return T(r,e,t,n),r.finish()}var Me=new DataView(new ArrayBuffer(4));function Ne(e){return Object.is(C(S(e)),e)}function Pe(e){return Me.setFloat32(0,e,!1),Object.is(Me.getFloat32(0,!1),e)}function E(e){return Ne(e)?`half`:Pe(e)?`single`:`double`}var D=class t{start;end;comments;warnings;_defaults;get _containsCdnContainer(){return!1}toCBOR(e){let t=this._defaults?{...this._defaults,...e}:e,n=new Oe;return this._encode(n,t),n.finish()}toCDN(e){let t=this._defaults?{...this._defaults,...e}:e,n=this._toCDN(t,0),r=t?.preserveComments;if(!r)return n;let i=typeof r==`string`?r:void 0,a=this.comments?.leading?.map(e=>g(e,i))??[],o=this.comments?.trailing??[],s=o.length===0?n:`${n} ${o.map(e=>g(e,i).trimEnd()).join(` `)}`;return[...a,s].join(`
3
+ `)}\n${se}${i}`}var ie=typeof new Uint8Array().toBase64==`function`;function ae(e){if(ie)return e.toBase64({omitPadding:!0});let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/=/g,``)}function oe(e){if(ie)return e.toBase64({alphabet:`base64url`,omitPadding:!0});let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}var se=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,ce=`0123456789ABCDEFGHIJKLMNOPQRSTUV`;function y(e,t){let n=``,r=0,i=0;for(let a of e)for(r=r<<8|a,i+=8;i>=5;)i-=5,n+=t[r>>i&31];return i>0&&(n+=t[r<<5-i&31]),n}function le(e){for(let t of e){let e=t.codePointAt(0);if(e<32||e===127)return!0}return!1}function ue(t,n,r){if(r===`string`){let e=fe(t);if(e!=null)return he(e)}if(r===`printable-string`||r===void 0){let e=fe(t);if(e!=null&&!le(e))return he(e)}switch(n){case`base64`:return`b64'${ae(t)}'`;case`base64url`:return`b64'${oe(t)}'`;case`base32`:return`b32'${y(t,se)}'`;case`base32hex`:return`h32'${y(t,ce)}'`;default:return`h'${e.r(t)}'`}}var de=new TextDecoder(`utf-8`,{fatal:!0});function fe(e){try{return de.decode(e)}catch{return null}}function pe(e,t){for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===t||r===92||r<32||r===127||r>=8192&&(r===8232||r===8233||r>=8203&&r<=8205||r===65279))return!0}return!1}function me(e,t){let n=t.codePointAt(0);if(!pe(e,n))return t+e+t;let r=t;for(let i of e){let e=i.codePointAt(0);switch(e){case n:r+=`\\${t}`;break;case 92:r+=`\\\\`;break;case 10:r+=`\\n`;break;case 13:r+=`\\r`;break;case 9:r+=`\\t`;break;default:e<32||e===127||e===8232||e===8233||e===8203||e===8204||e===8205||e===65279?r+=`\\u${e.toString(16).padStart(4,`0`)}`:r+=i}}return r+t}function he(e){return me(e,`'`)}function ge(e){return me(e,`'`)}function _e(e){return me(e,`"`)}function ve(e){if(isNaN(e))return`NaN`;if(!isFinite(e))return e>0?`Infinity`:`-Infinity`;if(Object.is(e,-0))return`-0.0`;let t=e.toString();return t.includes(`.`)||t.includes(`e`)?t:t+`.0`}function ye(e,t,n,r){if(r===`never`)return``;let i=t??n;return r===`always`?i===`half`?`_1`:i===`single`?`_2`:`_3`:t===void 0||t===n?``:t===`half`?`_1`:t===`single`?`_2`:`_3`}function b(e){return e<=23n?`i`:e<=255n?0:e<=65535n?1:e<=4294967295n?2:3}function x(e,t,n){let r=e?.encodingIndicators??`auto`;return r===`never`?``:r===`always`?`_${t??n()}`:t===void 0?``:`_${t}`}var be=`getFloat16`in DataView.prototype&&`setFloat16`in DataView.prototype,xe=new DataView(new ArrayBuffer(8));function S(e){xe.setFloat64(0,e,!1);let t=xe.getUint32(0,!1),n=xe.getUint32(4,!1),r=t>>>31&1,i=t>>>20&2047,a=t&1048575;if(i===2047){if(a===0&&n===0)return r<<15|31744;let e=a>>10|(n===0?0:1)||1;return r<<15|31744|e&1023}let o=i-1023+15;if(o>=31)return r<<15|31744;let s,c,l;if(o<=0){if(o<-10)return r<<15;let e=1<<20|a,t=11-o;t<=20?(s=e>>t&1023,c=e>>t-1&1,l=(e&(1<<t-1)-1)!=0||n!==0):(s=0,c=1,l=a!==0||n!==0)}else s=a>>10,c=a>>9&1,l=(a&511)!=0||n!==0;if(c!==0&&(l||s&1)&&s++,s>=1024){let e=o<=0?1:o+1;return e>=31?r<<15|31744:r<<15|e<<10}let u=o<=0?0:o;return r<<15|u<<10|s}function C(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023;return n===31?r===0?t?-1/0:1/0:NaN:n===0?r===0?t?-0:0:(t?-1:1)*2**-14*(r/1024):(t?-1:1)*2**(n-15)*(1+r/1024)}var Se=be?(e,t,n,r)=>{e.setFloat16(t,n,r)}:(e,t,n,r)=>{e.setUint16(t,S(n),r)},Ce=new DataView(new ArrayBuffer(8)),w=new Uint8Array(Ce.buffer),we=new TextEncoder,Te=typeof we.encodeInto==`function`;function Ee(e){return e<=23?1:e<=255?2:e<=65535?3:e<=4294967295?5:9}function De(e){return e===`i`?1:[2,3,5,9][e]}var Oe=class{buf;len=0;constructor(e=256){this.buf=new Uint8Array(e)}_ensure(e){let t=this.len+e;if(t<=this.buf.length)return;let n=this.buf.length*2;for(;n<t;)n*=2;let r=new Uint8Array(n);r.set(this.buf),this.buf=r}writeByte(e){this._ensure(1),this.buf[this.len++]=e}writeBytes(e){this._ensure(e.length),this.buf.set(e,this.len),this.len+=e.length}writeUint16(e){this._ensure(2);let t=this.buf;t[this.len++]=e>>>8&255,t[this.len++]=e&255}writeUint32(e){this._ensure(4);let t=this.buf;t[this.len++]=e>>>24&255,t[this.len++]=e>>>16&255,t[this.len++]=e>>>8&255,t[this.len++]=e&255}writeBigUint64(e){Ce.setBigUint64(0,e,!1),this._ensure(8),this.buf.set(w,this.len),this.len+=8}writeFloat16(e){Se(Ce,0,e,!1),this._ensure(2);let t=this.buf;t[this.len++]=w[0],t[this.len++]=w[1]}writeFloat32(e){Ce.setFloat32(0,e,!1),this._ensure(4);let t=this.buf;t[this.len++]=w[0],t[this.len++]=w[1],t[this.len++]=w[2],t[this.len++]=w[3]}writeFloat64(e){Ce.setFloat64(0,e,!1),this._ensure(8),this.buf.set(w,this.len),this.len+=8}writeTextString(e,t,n){if(!Te){let r=we.encode(t);T(this,e,r.length,n),this.writeBytes(r);return}let r=n===void 0?Ee(t.length):De(n);this._ensure(9+3*t.length);let{written:i}=we.encodeInto(t,this.buf.subarray(this.len+r)),a=n===void 0?Ee(i):r;a!==r&&this.buf.copyWithin(this.len+a,this.len+r,this.len+r+i),T(this,e,i,n),this.len+=i}finish(){return this.buf.slice(0,this.len)}},ke=[255n,65535n,4294967295n,18446744073709551615n];function Ae(e){return e===`i`?23n:ke[e]}function T(e,t,n,r){if(r===void 0&&typeof n==`number`&&n<4294967296){n<=23?e.writeByte(t<<5|n):n<=255?(e.writeByte(t<<5|24),e.writeByte(n)):n<=65535?(e.writeByte(t<<5|25),e.writeUint16(n)):(e.writeByte(t<<5|26),e.writeUint32(n));return}let i=typeof n==`number`?BigInt(n):n;if(r!==void 0){if(r===`i`){if(i>23n)throw RangeError(`value ${i} does not fit in immediate encoding _i (max 23)`);e.writeByte(t<<5|Number(i));return}if(i>ke[r])throw RangeError(`value ${i} does not fit in encodingWidth _${r} (max ${ke[r]})`);let n=24+r;e.writeByte(t<<5|n),n===24?e.writeByte(Number(i)):n===25?e.writeUint16(Number(i)):n===26?e.writeUint32(Number(i)):e.writeBigUint64(i);return}i<=23n?e.writeByte(t<<5|Number(i)):i<=255n?(e.writeByte(t<<5|24),e.writeByte(Number(i))):i<=65535n?(e.writeByte(t<<5|25),e.writeUint16(Number(i))):i<=4294967295n?(e.writeByte(t<<5|26),e.writeUint32(Number(i))):(e.writeByte(t<<5|27),e.writeBigUint64(i))}function je(e,t,n){let r=new Oe(9);return T(r,e,t,n),r.finish()}var Me=new DataView(new ArrayBuffer(4));function Ne(e){return Object.is(C(S(e)),e)}function Pe(e){return Me.setFloat32(0,e,!1),Object.is(Me.getFloat32(0,!1),e)}function E(e){return Ne(e)?`half`:Pe(e)?`single`:`double`}var D=class t{start;end;comments;warnings;_defaults;get _containsCdnContainer(){return!1}toCBOR(e){let t=this._defaults?{...this._defaults,...e}:e,n=new Oe;return this._encode(n,t),n.finish()}toCDN(e){let t=this._defaults?{...this._defaults,...e}:e,n=this._toCDN(t,0),r=t?.preserveComments;if(!r||f(t)===null)return n;let i=typeof r==`string`?r:void 0,a=this.comments?.leading?.map(e=>g(e,i))??[],o=this.comments?.trailing??[],s=o.length===0?n:`${n} ${o.map(e=>g(e,i).trimEnd()).join(` `)}`;return[...a,s].join(`
4
4
  `)}toEDN(e){return this.toCDN(e)}toJS(e){let t=this._defaults?{...this._defaults,...e}:e,n=this._toJS(t);if(!t?.reviver)return n;let r=t.reviver.call({"":n},``,n);return r===u?void 0:r}toHexDump(e){let t=this._defaults?{...this._defaults,...e}:e,n=t?.indent??3,r=typeof n==`string`?n:` `.repeat(n),i=(t?.commentStyle??`--`)+` `,a=this._toHexDump(0,t),o=0;for(let e of a){let t=e.depth*r.length+e.hex.length;t>o&&(o=t)}let s=o+2;return a.map(e=>(r.repeat(e.depth)+e.hex).padEnd(s)+i+e.comment).join(`
5
- `)}_encode(e,n){if(this._toCBOR!==t.prototype._toCBOR){e.writeBytes(this._toCBOR(n));return}this._encodeTo(e,n)}_encodeTo(e,n){if(this._toCBOR===t.prototype._toCBOR)throw TypeError(`CborItem subclass must implement _encodeTo() or _toCBOR()`);e.writeBytes(this._toCBOR(n))}_toCBOR(e){let t=new Oe;return this._encodeTo(t,e),t.finish()}_toHexDump(t,n){return[{depth:t,hex:e.i(this._toCBOR()),comment:this._toCDN(n,0)}]}},O=class extends D{value;encodingWidth;constructor(e,t){if(super(),this.value=BigInt(e),this.value<0n)throw RangeError(`CborUint value must be non-negative`);if(this.value>18446744073709551615n)throw RangeError(`CborUint value exceeds maximum uint64`);this.encodingWidth=t?.encodingWidth}_encodeTo(e,t){T(e,0,this.value,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.value)),r=this.value;switch(e?.intFormat){case`hex`:return`0x${r.toString(16)}${n}`;case`octal`:return`0o${r.toString(8)}${n}`;case`binary`:return`0b${r.toString(2)}${n}`;default:return r.toString()+n}}_toJS(e){let t=e?.integerAs??`auto`;return t===`bigint`?this.value:t===`number`||this.value<=BigInt(2**53-1)?Number(this.value):this.value}},k=class extends D{argument;encodingWidth;constructor(e,t){super();let n=BigInt(e);if(n>=0n)throw RangeError(`CborNint value must be negative`);if(n<-18446744073709551616n)throw RangeError(`CborNint value exceeds minimum int64`);this.argument=-1n-n,this.encodingWidth=t?.encodingWidth}get value(){return-1n-this.argument}_encodeTo(e,t){T(e,1,this.argument,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.argument)),r=this.argument+1n;switch(e?.intFormat){case`hex`:return`-0x${r.toString(16)}${n}`;case`octal`:return`-0o${r.toString(8)}${n}`;case`binary`:return`-0b${r.toString(2)}${n}`;default:return this.value.toString()+n}}_toJS(e){let t=this.value,n=e?.integerAs??`auto`;return n===`bigint`?t:n===`number`||t>=BigInt(-(2**53-1))?Number(t):t}},Fe=new DataView(new ArrayBuffer(8));function Ie(e){let t=e.startsWith(`-`),n=e.slice(t?3:2),r=n.search(/[pP]/);if(r===-1)throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);let i=n.slice(0,r),a=n.slice(r+1);if(!/^[+-]?\d+$/.test(a))throw SyntaxError(`EDN parse error: hex float has invalid or missing exponent: ${e}`);let o=parseInt(a,10),s=i.indexOf(`.`),c;if(s===-1){if(!/^[0-9a-fA-F]+$/.test(i))throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);c=parseInt(i,16)}else{let t=i.slice(0,s),n=i.slice(s+1);if(t===``&&n===``)throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);if(t!==``&&!/^[0-9a-fA-F]+$/.test(t)||n!==``&&!/^[0-9a-fA-F]+$/.test(n))throw SyntaxError(`EDN parse error: hex float has invalid mantissa: ${e}`);c=(t===``?0:parseInt(t,16))+(n===``?0:parseInt(n,16)/16**n.length)}let l=c*2**o;return t?-l:l}function Le(e){if(isNaN(e))return`NaN`;if(!isFinite(e))return e>0?`Infinity`:`-Infinity`;let t=Object.is(e,-0)||e<0,n=Math.abs(e);if(n===0)return t?`-0x0p+0`:`0x0p+0`;Fe.setFloat64(0,n,!1);let r=Fe.getUint32(0,!1),i=Fe.getUint32(4,!1),a=r>>>20&2047,o=r&1048575,s=i,c=(o.toString(16).padStart(5,`0`)+s.toString(16).padStart(8,`0`)).replace(/0+$/,``),l=c===``?``:`.${c}`,u,d;a===0?(u=`0`,d=-1022):(u=`1`,d=a-1023);let f=d>=0?`+${d}`:`${d}`,p=`0x${u}${l}p${f}`;return t?`-${p}`:p}var A=class extends D{value;precision;ednSource;rawBits;constructor(e,t){super(),this.value=e,this.precision=t?.precision,this.rawBits=t?.rawBits}_encodeTo(e,t){let n=this.precision??E(this.value),r=Number.isNaN(this.value)?this.rawBits:void 0;n===`half`?(e.writeByte(249),r?.length===2?e.writeBytes(r):e.writeFloat16(this.value)):n===`single`?(e.writeByte(250),r?.length===4?e.writeBytes(r):e.writeFloat32(this.value)):(e.writeByte(251),r?.length===8?e.writeBytes(r):e.writeFloat64(this.value))}_toCDN(e,t){let n=e?.encodingIndicators??`auto`;if(e?.appStrings!==!1&&this.ednSource!==void 0){if(n===`never`)return this.ednSource.replace(/_[0-3i]$/,``);if(n===`always`){if(/_[0-3i]$/.test(this.ednSource))return this.ednSource;let e=this.precision??E(this.value),t=e===`half`?`_1`:e===`single`?`_2`:`_3`;return this.ednSource+t}return this.ednSource}let r=E(this.value);return(e?.floatFormat===`hex`?Le(this.value):ve(this.value))+ye(this.value,this.precision,r,n)}_toJS(e){return this.value}},j=class extends D{tag;content;encodingWidth;constructor(e,t,n){if(super(),this.tag=BigInt(e),this.tag<0n)throw RangeError(`CborTag tag number must be non-negative`);this.content=t,this.encodingWidth=n?.encodingWidth}get _containsCdnContainer(){return this.content._containsCdnContainer}_encodeTo(e,t){T(e,6,this.tag,this.encodingWidth),this.content._encode(e,t)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.tag));return`${this.tag}${n}(${this.content._toCDN(e,t)})`}_toHexDump(t,n){let r=[{depth:t,hex:e.i(je(6,this.tag,this.encodingWidth)),comment:`Tag ${this.tag}`}];return r.push(...this.content._toHexDump(t+1,{...n,appStrings:!1})),r}_toJS(e){let t=this.content._toJS(e);return e?.stripTags?t:l.set(t,this.tag)}},M=class extends D{indefiniteLength=!1;value;ednEncoding;encodingWidth;ednSource;ednParts;constructor(e,t){super(),this.value=e,this.ednEncoding=t?.ednEncoding??`hex`,this.encodingWidth=t?.encodingWidth,this.ednSource=t?.ednSource,this.ednParts=t?.ednParts}_encodeTo(e,t){T(e,2,this.value.length,this.encodingWidth),e.writeBytes(this.value)}_toCDN(e,t){if(e?.preserveConcatenation&&this.ednParts!==void 0&&this.ednParts.length>1){let n=x(e,this.encodingWidth,()=>b(BigInt(this.value.length))),r=e?.bstrEncoding??this.ednEncoding;e?.appStrings===!1&&r!==`hex`&&(r=`hex`);let i=this.ednParts.map(t=>e?.preserveByteString&&t.source!==void 0?t.source:ue(t.bytes,r,e?.sqstr));return i[i.length-1]+=n,m(i,f(e),t)}if(e?.preserveByteString&&this.ednSource!==void 0){if(/_[0-3i]$/.test(this.ednSource))return(e?.encodingIndicators??`auto`)===`never`?this.ednSource.replace(/_[0-3i]$/,``):this.ednSource;let t=x(e,this.encodingWidth,()=>b(BigInt(this.value.length)));return this.ednSource+t}let n=x(e,this.encodingWidth,()=>b(BigInt(this.value.length))),r=e?.bstrEncoding??this.ednEncoding;return e?.appStrings===!1&&r!==`hex`&&(r=`hex`),ue(this.value,r,e?.sqstr)+n}_toJS(e){return this.value}},N=class extends D{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_encodeTo(e,t){e.writeByte(95);for(let n of this.chunks)n._encode(e,t);e.writeByte(255)}_toCDN(e,t){if((e?.encodingIndicators??`auto`)===`never`){let n=this.chunks.reduce((e,t)=>e+t.value.length,0),r=new Uint8Array(n),i=0;for(let e of this.chunks)r.set(e.value,i),i+=e.value.length;return new M(r)._toCDN(e,t)}return this.chunks.length===0?`''_`:v({node:this,options:e,depth:t,openChar:`(`,closeChar:`)`,count:this.chunks.length,indefiniteLength:!0,encodingWidth:void 0,hasEntryComments:()=>this.chunks.some(h),renderEntry:n=>this.chunks[n]._toCDN(e,t+1),entryLeadingNode:e=>this.chunks[e],entryTrailing:(e,t)=>_(this.chunks[e],t)})}_toHexDump(t,n){let r=[{depth:t,hex:e.n(95),comment:`Start indefinite-length byte string`}];for(let e of this.chunks)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}_toJS(e){let t=this.chunks.reduce((e,t)=>e+t.value.length,0),n=new Uint8Array(t),r=0;for(let e of this.chunks)n.set(e.value,r),r+=e.value.length;return n}},P=class extends D{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_encodeTo(e,t){e.writeByte(127);for(let n of this.chunks)n._encode(e,t);e.writeByte(255)}_toCDN(e,t){return(e?.encodingIndicators??`auto`)===`never`?new B(this.chunks.map(e=>e.value).join(``))._toCDN(e,t):this.chunks.length===0?`""_`:v({node:this,options:e,depth:t,openChar:`(`,closeChar:`)`,count:this.chunks.length,indefiniteLength:!0,encodingWidth:void 0,hasEntryComments:()=>this.chunks.some(h),renderEntry:n=>this.chunks[n]._toCDN(e,t+1),entryLeadingNode:e=>this.chunks[e],entryTrailing:(e,t)=>_(this.chunks[e],t)})}_toHexDump(t,n){let r=[{depth:t,hex:e.n(127),comment:`Start indefinite-length text string`}];for(let e of this.chunks)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}_toJS(e){return this.chunks.map(e=>e.value).join(``)}},F=class extends D{items;indefiniteLength;encodingWidth;constructor(e,t){super(),this.items=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return!0}_encodeTo(e,t){if(this.indefiniteLength){e.writeByte(159);for(let n of this.items)n._encode(e,t);e.writeByte(255);return}T(e,4,this.items.length,this.encodingWidth);for(let n of this.items)n._encode(e,t)}_toCDN(e,t){return v({node:this,options:e,depth:t,openChar:`[`,closeChar:`]`,count:this.items.length,indefiniteLength:this.indefiniteLength,encodingWidth:this.encodingWidth,hasEntryComments:()=>this.items.some(h),renderEntry:n=>this.items[n]._toCDN(e,t+1),entryIsLeaf:e=>!this.items[e]._containsCdnContainer,entryLeadingNode:e=>this.items[e],entryTrailing:(e,t)=>_(this.items[e],t)})}_toHexDump(t,n){if(this.indefiniteLength){let r=[{depth:t,hex:e.n(159),comment:`Start indefinite-length array`}];for(let e of this.items)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}let r=[{depth:t,hex:e.i(je(4,BigInt(this.items.length),this.encodingWidth)),comment:`Array of length ${this.items.length}`}];for(let e of this.items)r.push(...e._toHexDump(t+1,n));return r}_toJS(e){let t=e?.reviver;if(!t)return this.items.map(t=>t._toJS(e));let n=e?{...e,reviver:void 0}:void 0,r=this.items.map(e=>e._toJS(n)),i=0;for(let n=0;n<this.items.length;n++){let a=n-i,o=this.items[n]._toJS(e),s=t.call(r,String(n),o);s===u||e?.undefinedOmits&&s===void 0?(r.splice(a,1),i++):r[a]=s}return r}},I=class extends D{entries;indefiniteLength;encodingWidth;constructor(e,t){super(),this.entries=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return!0}_encodeTo(e,t){if(this.indefiniteLength){e.writeByte(191);for(let[n,r]of this.entries)n._encode(e,t),r._encode(e,t);e.writeByte(255);return}T(e,5,this.entries.length,this.encodingWidth);for(let[n,r]of this.entries)n._encode(e,t),r._encode(e,t)}_toCDN(e,t){return v({node:this,options:e,depth:t,openChar:`{`,closeChar:`}`,count:this.entries.length,indefiniteLength:this.indefiniteLength,encodingWidth:this.encodingWidth,hasEntryComments:()=>this.entries.some(([e,t])=>h(e)||h(t)),renderEntry:(n,r)=>{let[i,a]=this.entries[n];return`${i._toCDN(e,t+1)}${r}${a._toCDN(e,t+1)}`},entryIsLeaf:e=>{let[t,n]=this.entries[e];return!t._containsCdnContainer&&!n._containsCdnContainer},entryLeadingNode:e=>this.entries[e][0],entryTrailing:(e,t)=>{let[n,r]=this.entries[e];return Re([...n.comments?.trailing??[],...r.comments?.leading??[],...r.comments?.trailing??[]],t)}})}_toHexDump(t,n){if(this.indefiniteLength){let r=[{depth:t,hex:e.n(191),comment:`Start indefinite-length map`}];for(let[e,i]of this.entries)r.push(...e._toHexDump(t+1,n)),r.push(...i._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}let r=[{depth:t,hex:e.i(je(5,BigInt(this.entries.length),this.encodingWidth)),comment:`Map of length ${this.entries.length}`}];for(let[e,i]of this.entries)r.push(...e._toHexDump(t+1,n)),r.push(...i._toHexDump(t+1,n));return r}_toJS(e){let t=e?.reviver,n=()=>{let n=$.from(this.entries,([t,n])=>[t._toJS(e),n._toJS(e)]);if(!t)return n;let r=e?.undefinedOmits;for(let e=0;e<n.length;e++){let[i,a]=n[e],o=t.call(n,i,a);o===u||r&&o===void 0?n.splice(e--,1):n[e]=[i,o]}return n};return e?.mapAs===`entries`?n():e?.mapAs===`object`||this.entries.every(([e])=>e instanceof B)?(()=>{let n=e?{...e,reviver:void 0}:void 0,r={};for(let[e,t]of this.entries){let i=e instanceof B?e.value:e.toCDN(),a=t._toJS(n);i===`__proto__`?Object.defineProperty(r,i,{value:a,writable:!0,enumerable:!0,configurable:!0}):r[i]=a}if(!t)return r;let i=new Map;for(let e=0;e<this.entries.length;e++){let[t]=this.entries[e];i.set(t instanceof B?t.value:t.toCDN(),e)}for(let n=0;n<this.entries.length;n++){let[a,o]=this.entries[n],s=a instanceof B?a.value:a.toCDN();if(i.get(s)!==n)continue;let c=o._toJS(e),l=t.call(r,s,c);l===u||e?.undefinedOmits&&l===void 0?delete r[s]:s===`__proto__`?Object.defineProperty(r,s,{value:l,writable:!0,enumerable:!0,configurable:!0}):r[s]=l}return r})():n()}};function Re(e,t){return e.length===0?``:` `+e.map(e=>g(e,t).trimEnd()).join(` `)}var L=class e extends D{value;constructor(e){if(super(),!Number.isInteger(e)||e<0||e>255)throw RangeError(`CborSimple value must be an integer in 0–255`);this.value=e}static FALSE=new e(20);static TRUE=new e(21);static NULL=new e(22);static UNDEFINED=new e(23);_encodeTo(e,t){if(this.value<=23){e.writeByte(224|this.value);return}e.writeByte(248),e.writeByte(this.value)}_toCDN(e,t){switch(this.value){case 20:return`false`;case 21:return`true`;case 22:return`null`;case 23:return`undefined`;default:return`simple(${this.value})`}}_toJS(e){switch(this.value){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:return new d(this.value)}}},ze=class extends D{items;encodingWidth;constructor(e,t){super(),this.items=e,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return this.items.some(e=>e._containsCdnContainer)}_content(e){let t=new Oe;for(let n of this.items)n._encode(t,e);return t.finish()}_encodeTo(e,t){let n=this._content(t);T(e,2,n.length,this.encodingWidth),e.writeBytes(n)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(BigInt(this._content(e).length)));if(this.items.length===0)return`<<>>${n}`;let r=f(e),{inlineSep:i,multilineSep:a,trailSep:o}=re(e,r===null);if(r===null)return`<<${this.items.map(n=>n._toCDN(e,t+1)).join(i)}>>${n}`;let s=p(r,t+1),c=p(r,t),l=this.items.map(n=>`${s}${n._toCDN(e,t+1)}`),u=l.length-1;return`<<\n${l.map((e,t)=>t<u?`${e}${a}`:`${e}${o}`).join(`
6
- `)}\n${c}>>${n}`}_toHexDump(t,n){let r=this._content().length,i=[{depth:t,hex:e.i(je(2,BigInt(r),this.encodingWidth)),comment:`Embedded CBOR sequence, ${r} byte${r===1?``:`s`}`}];for(let e of this.items)i.push(...e._toHexDump(t+1,n));return i}_toJS(e){return this._content()}},Be=999n,Ve=class extends j{constructor(e,t){let n=t.length===1&&t[0]instanceof B?t[0]:new F(t);super(Be,new F([new B(e),n]))}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.content,r=n.items[0].value,i=n.items[1];return i instanceof B?`${r}${ge(i.value)}`:`${r}<<${i.items.map(n=>n._toCDN(e,t)).join(`, `)}>>`}},He=class extends D{inner;ednSource;constructor(e,t){super(),this.inner=e,this.ednSource=t}get _containsCdnContainer(){return this.inner._containsCdnContainer}_encodeTo(e,t){this.inner._encode(e,t)}_toCDN(e,t){let n=e?.encodingIndicators??`auto`;return e?.appStrings!==!1&&n===`auto`?this.ednSource:this.inner._toCDN(e,t)}_toJS(e){return this.inner._toJS(e)}},Ue=888n,R=class extends j{constructor(e){e===void 0?super(Ue,L.NULL):super(Ue,new F(e))}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);if(this.content instanceof L)return`...`;if(this.content instanceof F){let n=this.content.items.map(n=>n._toCDN(e,t));return n.length===0?``:m(n,f(e),t)}return super._toCDN(e,t)}},We=2n,Ge=3n,Ke=18446744073709551615n,qe=-18446744073709551616n;function Je(e){if(e<0n)throw RangeError(`bigintToBytes requires a non-negative value`);if(e===0n)return new Uint8Array;let t=e.toString(16);t.length%2!=0&&(t=`0`+t);let n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*2,e*2+2),16);return n}function Ye(e){let t=0n;for(let n of e)t=t<<8n|BigInt(n);return t}var Xe=class extends j{bigValue;constructor(e){if(e<=Ke)throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);super(We,new M(Je(e))),this.bigValue=e}_toCDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},Ze=class extends j{bigValue;constructor(e){if(e>=qe)throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);super(Ge,new M(Je(-1n-e))),this.bigValue=e}_toCDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},Qe=new TextEncoder,$e=new TextDecoder(`utf-8`,{fatal:!0}),et=new TextDecoder(`utf-8`,{fatal:!1});function tt(t,n){let r=new e.t(t,{offset:n?.offset,skipRS:n?._skipRS}),i=new pt(r,n??{}).parse();return n?.preserveComments&&ot(i,r.comments,t),i}function nt(e){let t=e,n;return/[_][0-7i]$/.test(e)&&(n=e[e.length-1],t=e.slice(0,-2)),{numStr:t,rawSuffix:n}}function rt(e){return e.startsWith(`-`)?-BigInt(e.slice(1)):BigInt(e)}function it(e,t){if(e.endsWith(`_i`)||e.endsWith(`_0`)){let n=`_0 and _i encoding indicators are not valid for floating-point values`;if(t)t(n),e=e.slice(0,-2);else throw SyntaxError(`EDN parse error: ${n}`)}else if(/[_][4567]$/.test(e)){let n=e[e.length-1],r=n===`7`?`indefinite-length encoding (_7) is not valid for floating-point values`:`encoding indicator _${n} (AI ${Number(n)+24}) is reserved and not valid`;if(t)t(r),e=e.slice(0,-2);else throw SyntaxError(`EDN parse error: ${r}`)}if(e===`NaN`)return{value:NaN,precision:void 0};if(e===`Infinity`)return{value:1/0,precision:void 0};if(e===`-Infinity`)return{value:-1/0,precision:void 0};let n=e,r;return e.endsWith(`_1`)?(r=`half`,n=e.slice(0,-2)):e.endsWith(`_2`)?(r=`single`,n=e.slice(0,-2)):e.endsWith(`_3`)&&(r=`double`,n=e.slice(0,-2)),/^-?0[xX]/.test(n)?{value:Ie(n),precision:r}:{value:parseFloat(n),precision:r}}function at(e,t){let n=e.indexOf(`=`),r=n>=0?e.slice(0,n):e,i=n>=0?e.slice(n):``;if(/[^A-Za-z0-9+/\-_]/.test(r)){let e=[...r].find(e=>!/[A-Za-z0-9+/\-_]/.test(e))??``;throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`)}if(i&&!/^=+$/.test(i))throw SyntaxError(`invalid character after base64 '=' padding`);let a=r.length%4;if(a===1)throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);let o=a===0?0:4-a;if(i.length>o){let e=`base64 has ${i.length} '=' character${i.length>1?`s`:``} but the data length (${r.length}) requires at most ${o}`;if(t)t(e);else throw SyntaxError(e)}if(i.length>0&&i.length<o){let e=`base64 has ${i.length} '=' character${i.length>1?`s`:``} but needs exactly ${o} — use full padding or no padding at all`;if(t)t(e);else throw SyntaxError(e)}if(a!==0&&r.length>0){let e=r[r.length-1].replace(`-`,`+`).replace(`_`,`/`),n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.indexOf(e);if(n>=0&&n&(a===2?15:3)){let e=`base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)`;if(t)t(e);else throw SyntaxError(e)}}let s=r.replace(/-/g,`+`).replace(/_/g,`/`)+`=`.repeat(o);if(typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(s,{alphabet:`base64`,lastChunkHandling:`loose`});let c=atob(s),l=new Uint8Array(c.length);for(let e=0;e<c.length;e++)l[e]=c.charCodeAt(e);return l}function ot(e,t,n){if(t.length===0)return;let r=st(e),i=lt(n),a=[...r].sort((e,t)=>e.start-t.start||t.end-e.end),o=[...r].sort((e,t)=>e.end-t.end||e.start-t.start),s=[...t].sort((e,t)=>e.start-t.start),c=[],l=0;for(let t of s){let r={...t},s=0,u=o.length;for(;s<u;){let e=s+u>>1;o[e].end<=t.start?s=e+1:u=e}let d=s>0?o[s-1]:void 0,f=d?n.slice(d.end,t.start):``;if(d&&i(d.end)===t.line&&!f.includes(`:`)){ct(d.node,`trailing`,r);continue}for(;l<a.length&&a[l].start<t.start;){let e=a[l++];for(;c.length>0&&c[c.length-1].end<=e.start;)c.pop();c.push(e)}for(;c.length>0&&c[c.length-1].end<=t.start;)c.pop();let p=c.length>0?c[c.length-1]:void 0;for(s=0,u=a.length;s<u;){let e=s+u>>1;a[e].start<t.end?s=e+1:u=e}let m=s<a.length?a[s]:void 0;if((!p||m&&m.end<=p.end)&&m){ct(m.node,`leading`,r);continue}ct(p?.node??e,`dangling`,r)}}function st(e){let t=[],n=e=>{if(e.start!==void 0&&e.end!==void 0&&t.push({node:e,start:e.start,end:e.end}),e instanceof F||e instanceof ze){for(let t of e.items)n(t);return}if(e instanceof I){for(let[t,r]of e.entries)n(t),n(r);return}if(e instanceof N||e instanceof P){for(let t of e.chunks)n(t);return}e instanceof j&&n(e.content)};return n(e),t}function ct(e,t,n){e.comments??={},e.comments[t]??=[],e.comments[t].push(n)}function lt(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
7
- `&&t.push(n+1);return n=>{let r=Math.max(0,Math.min(e.length,n));r>0&&r===e.length&&r--;let i=0,a=t.length-1;for(;i<=a;){let e=i+a>>1;t[e]<=r?i=e+1:a=e-1}return a+1}}var ut=e=>`import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`,dt=(e,t)=>`install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`,z=e=>`'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`,ft=new Map([[`b32`,ut(`b32`)],[`h32`,ut(`h32`)],[`same`,ut(`same`)],[`hash`,dt(`hash`,`@cbortech/hash-extension`)],[`uuid`,dt(`uuid`,`@cbortech/uuid-extension`)],[`UUID`,dt(`uuid`,`@cbortech/uuid-extension`)],[`dt`,z(`dt`)],[`DT`,z(`dt`)],[`ip`,z(`ip`)],[`IP`,z(`ip`)],[`cri`,z(`cri`)],[`CRI`,z(`cri`)],[`t1`,z(`t1`)],[`b1`,z(`b1`)],[`ilbs`,z(`ilbs`)],[`ilts`,z(`ilts`)],[`float`,z(`float`)]]),pt=class{t;_options;extByPrefix;extByTag;unresolvedExtension;_pendingWarnings=[];_hintedPrefixes=new Set;constructor(t,n){this.t=t,this._options=n,this.extByPrefix=new Map,this.extByTag=new Map,this.unresolvedExtension=n.unresolvedExtension??`cpa999`;let r=Z(n.builtinExtensions);for(let e of[...r,...n.extensions??[]]){for(let t of e.appStringPrefixes??[])this.extByPrefix.set(t,e);for(let t of e.tagNumbers??[])this.extByTag.set(t,e)}this.t.onEscapeWarning=(t,n,r,i,a)=>{let o={message:t,offset:n,line:r,column:i,endOffset:a};if(this._pendingWarnings.push(o),this._options.onWarning?this._options.onWarning(o):this._options.silent||console.warn(`CDN strict violation at line ${r}, column ${i}: ${t}`),this._options.strict!==!1)throw new e.o(t,{offset:n,line:r,column:i,endOffset:a})}}parse(){let e=this.parseValue();if(this._options.allowTrailing)return e;let t=this.t.peek();if(t.type!==`EOF`)for(this._warnOrFail(`unexpected token after value: ${JSON.stringify(t.value)}`,t),this._pendingWarnings.length>0&&(e.warnings??=[],e.warnings.push(...this._pendingWarnings),this._pendingWarnings=[]);this.t.peek().type!==`EOF`;)this.t.consume();return e}parseValue(){let e=this.t.peek().offset,t=this._parseValueNode();if(this.t.peek().type===`UNDERSCORE`){let e=this.t.consume();this._warnOrFail(`bare _ is not a valid encoding indicator; use _0, _1, _2, _3, or _i`,e)}if(this._pendingWarnings.length>0){t.warnings??=[];for(let e of this._pendingWarnings)t.warnings.push(e);this._pendingWarnings=[]}return t.start=e,t.end=this.t.lastEndOffset,t}_parseValueNode(){let e=this.t.peek();switch(e.type){case`INTEGER`:return this.parseIntegerOrTag();case`FLOAT`:return this.parseFloat();case`TSTR`:case`RAWSTRING`:return this.parseString();case`BYTES_HEX`:case`SQSTR`:case`BYTES_B64`:return this.t.consume(),this._parseBytesConcat(this._decodeBytesToken(e),e.type,e.raw);case`EMPTY_INDEF_BYTES`:return this.t.consume(),new N([]);case`EMPTY_INDEF_TEXT`:return this.t.consume(),new P([]);case`TRUE`:return this.t.consume(),new L(21);case`FALSE`:return this.t.consume(),new L(20);case`NULL`:return this.t.consume(),new L(22);case`UNDEFINED`:return this.t.consume(),new L(23);case`SIMPLE`:return this.parseSimple();case`LBRACKET`:return this.parseArray();case`LBRACE`:return this.parseMap();case`LPAREN`:return this.parseIndefGroup();case`LT_LT`:return this.parseEmbeddedCBOR();case`APP_STRING`:{this.t.consume();let t,n=``;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e),n=e.raw}let r=this.extByPrefix.get(e.appPrefix);if(!r?.parseAppString){if(r||this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new Ve(e.appPrefix,[new B(e.value)]);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}{let i=this._pendingWarnings.length;try{let i=r.parseAppString(e.appPrefix,e.value,this._extOnError(e),t===void 0?void 0:{encodingWidth:t});return t!==void 0&&this._applyEiToResult(i,t,e),i instanceof M&&Object.getPrototypeOf(i)===M.prototype&&i.ednSource===void 0?new M(i.value,{ednEncoding:i.ednEncoding,encodingWidth:i.encodingWidth,ednSource:e.raw+n}):(i instanceof A&&i.ednSource===void 0&&(i.ednSource=e.raw+n),i)}catch(t){if(this._options.strict!==!1)throw t;return this._pendingWarnings.length===i&&this._warn(t instanceof Error?t.message:String(t),e),new Ve(e.appPrefix,[new B(e.value)])}}}case`APP_SEQUENCE`:{this.t.consume();let t=[];for(;this.t.peek().type!==`GT_GT`;){if(this.t.peek().type===`EOF`&&this._fail(`unterminated ${e.appPrefix}<<...>>`,e),t.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());t.push(this.parseValue())}this.expect(`GT_GT`);let n,r;this.t.peek().type===`ENCODING_INDICATOR`&&(r=this.t.consume(),n=this._resolveEncodingWidth(r.value,r));let i=this.extByPrefix.get(e.appPrefix);if(!i){if(this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new Ve(e.appPrefix,t);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}i.parseAppSequence||this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`,e);{let a=this._pendingWarnings.length;try{let a=i.parseAppSequence(e.appPrefix,t,this._extOnError(e));n!==void 0&&this._applyEiToResult(a,n,r??e);let o=this.t.source.slice(e.offset,this.t.lastEndOffset);if(a instanceof A)a.ednSource===void 0&&(a.ednSource=o);else if(i.preserveAppSeqSource)return new He(a,o);return a}catch(n){if(this._options.strict!==!1)throw n;return this._pendingWarnings.length===a&&this._warn(n instanceof Error?n.message:String(n),e),new Ve(e.appPrefix,t)}}}case`ELLIPSIS`:{if(this.t.consume(),this.t.peek().type!==`PLUS`)return new R;let e=[new R];for(;this.t.peek().type===`PLUS`;)this.t.consume(),e.push(this.parseValue());return new R(e)}case`BYTES_HEX_ELIDED`:return this.t.consume(),this._parseHexElidedConcat(e);default:this._fail(`unexpected token: ${JSON.stringify(e.value)}`,e)}}parseIntegerOrTag(){let e=this.t.consume(),{numStr:t,rawSuffix:n}=nt(e.value),r=n===void 0?this.consumeEncodingIndicator():this._resolveEncodingWidth(n,e),i=rt(t);if(i>18446744073709551615n)return this.t.peek().type===`LPAREN`&&this._fail(`tag number exceeds maximum uint64`,e),new Xe(i);if(i<-18446744073709551616n)return new Ze(i);if(r!==void 0){let t=i>=0n?i:-(i+1n);r=this._validateEncodingFit(t,r,e)}let a=i>=0n?new O(i,r===void 0?void 0:{encodingWidth:r}):new k(i,r===void 0?void 0:{encodingWidth:r});if(this.t.peek().type===`LPAREN`){a instanceof O||this._fail(`tag number must be non-negative`,e),this.t.consume();let t=this._pendingWarnings.splice(0),n=this.parseValue();this.expect(`RPAREN`);let i=a.value,o=this.extByTag.get(i);if(o?.parseTag){let e=o.parseTag(i,n);if(e!==void 0)return e instanceof j&&r!==void 0&&e.encodingWidth===void 0&&(e.encodingWidth=r),t.length>0&&(e.warnings??=[],e.warnings.push(...t)),e}let s=new j(i,n,r===void 0?void 0:{encodingWidth:r});return t.length>0&&(s.warnings??=[],s.warnings.push(...t)),s}return a}parseFloat(){let e=this.t.consume(),t=t=>this._warnOrFail(t,e),{value:n,precision:r}=it(e.value,t);if(r===`half`||r===`single`){let e=r===`half`?C(S(n)):Math.fround(n);Object.is(n,e)||isNaN(n)&&isNaN(e)||t(`${n} cannot be exactly represented as ${r===`half`?`f16 (_1)`:`f32 (_2)`}; use _3 or remove the indicator`)}return new A(n,r===void 0?void 0:{precision:r})}parseString(){let e=this.t.consume();if(this.t.peek().type!==`PLUS`){let t=this.consumeEncodingIndicator(()=>BigInt(Qe.encode(e.value).length));return e.type===`RAWSTRING`?new B(e.value,{ednSource:e.raw,...t===void 0?{}:{encodingWidth:t}}):new B(e.value,t===void 0?void 0:{encodingWidth:t})}let t=!1,n=[e.type===`RAWSTRING`?{text:e.value,source:e.raw}:{text:e.value}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();e.type===`ELLIPSIS`?(this.t.consume(),n.push({ellipsis:!0}),t=!0):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),n.push(e.type===`RAWSTRING`?{text:e.value,source:e.raw}:{text:e.value})):this._isBytesToken(e.type)?(this.t.consume(),n.push({text:this._decodeUtf8(this._decodeBytesToken(e),e)})):this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!t){let e=n.map(e=>`text`in e?e.text:``),t=n.map(e=>`text`in e?e.source:void 0),r=e.join(``),i=this.consumeEncodingIndicator(()=>BigInt(Qe.encode(r).length));return new B(r,{ednParts:e,...t.some(e=>e!==void 0)?{ednPartSources:t}:{},...i===void 0?{}:{encodingWidth:i}})}let r=[],i=[],a=()=>{let e=i.map(e=>e.text),t=e.join(``);if(t!==``){let n=i.map(e=>e.source);r.push(new B(t,{ednParts:e,...n.some(e=>e!==void 0)?{ednPartSources:n}:{}}))}i.length=0};for(let e of n)`ellipsis`in e?(a(),r.push(new R)):i.push(e);return a(),new R(r)}_isBytesToken(e){return e===`BYTES_HEX`||e===`SQSTR`||e===`BYTES_B64`}_hexToBytes(t,n){try{return e.a(t)}catch(t){if(t instanceof e.o||!(t instanceof SyntaxError))throw t;this._fail(t.message,n)}}_decodeBytesToken(t){let n=e=>this._warnOrFail(e,t);switch(t.type){case`SQSTR`:{let e=t._sqstrBytes;return e===void 0?this._hexToBytes(t.value,t):e}case`BYTES_HEX`:return this._hexToBytes(t.value,t);case`BYTES_B64`:try{return at(t.value,n)}catch(n){if(n instanceof e.o||!(n instanceof SyntaxError))throw n;this._fail(n.message,t)}default:this._fail(`expected byte string token`,t)}}_decodeUtf8(e,t){if(this._options.allowInvalidUtf8)return et.decode(e);try{return $e.decode(e)}catch{return this._warnOrFail(`byte string in text concatenation is not valid UTF-8`,t),et.decode(e)}}_tokenTypeToCdnEncoding(e){return e===`BYTES_B64`?`base64`:`hex`}_parseBytesConcat(e,t,n){if(this.t.peek().type!==`PLUS`){let r=this.consumeEncodingIndicator(()=>BigInt(e.length));return new M(e,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednSource:n,...r===void 0?{}:{encodingWidth:r}})}let r=!1,i=[{bytes:e,source:n}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),i.push({ellipsis:!0}),r=!0;else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let t=this._buildBytesElidedItems(e.value,e);for(let e of t)e instanceof R?(i.push({ellipsis:!0}),r=!0):e instanceof M&&i.push({bytes:e.value})}else this._isBytesToken(e.type)?(this.t.consume(),i.push({bytes:this._decodeBytesToken(e),source:e.raw})):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),this._warnOrFail(`text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead`,e),i.push({bytes:Qe.encode(e.value)})):this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!r){let e=i.map(e=>`bytes`in e?e:{bytes:new Uint8Array}),n=this._concatBytes(e.map(e=>e.bytes)),r=this.consumeEncodingIndicator(()=>BigInt(n.length));return new M(n,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednParts:e,...r===void 0?{}:{encodingWidth:r}})}let a=[],o=[],s=()=>{o.length>0&&(a.push(new M(this._concatBytes([...o]))),o.length=0)};for(let e of i)`ellipsis`in e?(s(),a.push(new R)):o.push(e.bytes);return s(),new R(a)}_parseHexElidedConcat(e){let t=this._buildBytesElidedItems(e.value,e);for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),t.push(new R);else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let n=this._buildBytesElidedItems(e.value,e);this._mergeFirstBytesItem(t,n)}else if(this._isBytesToken(e.type)){this.t.consume();let n=this._decodeBytesToken(e),r=t[t.length-1];r instanceof M?t[t.length-1]=new M(this._concatBytes([r.value,n])):t.push(new M(n))}else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}return new R(t)}_buildBytesElidedItems(e,t){let n=e.split(`...`),r=[];for(let e=0;e<n.length;e++)e>0&&r.push(new R),n[e].length>0&&r.push(new M(this._hexToBytes(n[e],t)));return r}_mergeFirstBytesItem(e,t){if(t.length===0)return;let n=e[e.length-1],r=t[0];n instanceof M&&r instanceof M?(e[e.length-1]=new M(this._concatBytes([n.value,r.value])),e.push(...t.slice(1))):e.push(...t)}_concatBytes(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}parseSimple(){this.t.consume(),this.expect(`LPAREN`);let e=this.t.peek();e.type!==`INTEGER`&&this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`,e),this.t.consume();let{numStr:t}=nt(e.value),n=Number(rt(t));return this.expect(`RPAREN`),new L(n)}parseEmbeddedCBOR(){this.t.consume();let e=[];for(;this.t.peek().type!==`GT_GT`;){if(e.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());e.push(this.parseValue())}this.expect(`GT_GT`);let t;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e)}return new ze(e,{encodingWidth:t})}parseArray(){this.t.consume();let e=!1,t,n;this.t.peek().type===`UNDERSCORE`?(this.t.consume(),e=!0):this.t.peek().type===`ENCODING_INDICATOR`&&(n=this.t.consume(),n.value===`7`?(e=!0,this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,n),n=void 0):t=this._resolveEncodingWidth(n.value,n));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACKET`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACKET`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`array items must be separated by "," or whitespace`,this.t.peek());i.push(this.parseValue())}this.expect(`RBRACKET`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new F(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseMap(){this.t.consume();let e=!1,t,n;this.t.peek().type===`UNDERSCORE`?(this.t.consume(),e=!0):this.t.peek().type===`ENCODING_INDICATOR`&&(n=this.t.consume(),n.value===`7`?(e=!0,this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,n),n=void 0):t=this._resolveEncodingWidth(n.value,n));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACE`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACE`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`map entries must be separated by "," or whitespace`,this.t.peek());let e=this.parseValue();this.expect(`COLON`);let t=this.parseValue();i.push([e,t])}this.expect(`RBRACE`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new I(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseIndefGroup(){this.t.consume();let e=this.t.peek();if(e.type===`UNDERSCORE`)this.t.consume();else if(e.type===`ENCODING_INDICATOR`&&e.value===`7`)this.t.consume(),this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,e);else if(e.type===`ENCODING_INDICATOR`){let e=this.t.consume(),t=`encoding indicator _${e.value} is not valid in an indefinite string group; use _`;this._warnOrFail(t,e)}else e.type!==`RPAREN`&&this._warnOrFail(`indefinite string group is missing _ after (; interpreting as (_ ...)`,e);let t=this._pendingWarnings.splice(0),n=[];for(;this.t.peek().type!==`RPAREN`;){if(n.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RPAREN`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`indefinite string chunks must be separated by "," or whitespace`,this.t.peek());n.push(this.parseValue())}this.expect(`RPAREN`),n.length===0&&this._fail(`empty indefinite group (_ ) is ambiguous; use ''_ for bytes or ""_ for text`);let r=n[0];if(r instanceof M){let e=new N(n.map((e,t)=>{if(e instanceof M)return e;this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`)}));return t.length>0&&(e.warnings=t),e}if(r instanceof B){let e=new P(n.map((e,t)=>{if(e instanceof B)return e;this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`)}));return t.length>0&&(e.warnings=t),e}this._fail(`indefinite group chunks must be byte strings or text strings`)}consumeEncodingIndicator(e){if(this.t.peek().type===`ENCODING_INDICATOR`){let t=this.t.consume(),n=this._resolveEncodingWidth(t.value,t);return n!==void 0&&e!==void 0&&(n=this._validateEncodingFit(e(),n,t)),n}}expect(e){let t=this.t.consume();return t.type!==e&&this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`,t),t}_applyEiToResult(e,t,n){if(e instanceof A){let r=t===1?`half`:t===2?`single`:t===3?`double`:void 0;if(r===void 0)this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`,n);else if(e.precision!==r){if(r!==`double`){let t=r===`half`?C(S(e.value)):Math.fround(e.value);!Object.is(t,e.value)&&!isNaN(e.value)&&this._warnOrFail(`${e.value} cannot be exactly represented as ${r===`half`?`float16 (_1)`:`float32 (_2)`}`,n)}e.precision=r}}else if(e instanceof O){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.value,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof k){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.argument,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof M){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.value.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof B){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(Qe.encode(e.value).length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof F){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.items.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof I){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.entries.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof j){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.tag,t,n);r!==void 0&&(e.encodingWidth=r)}}else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`,n)}_validateEncodingFit(e,t,n){let r=Ae(t);if(e<=r)return t;let i=`value ${e} does not fit in encoding indicator ${t===`i`?`_i (max 23)`:`_${t} (max ${r})`}`;this._warnOrFail(i,n)}_resolveEncodingWidth(e,t){if(e===`4`||e===`5`||e===`6`){let n=`encoding indicator _${e} (AI ${Number(e)+24}) is reserved and not valid`;this._warnOrFail(n,t);return}if(e===`7`){this._warnOrFail(`indefinite-length encoding (_7) is not valid here; use [_ ...] or {_ ...} for indefinite collections`,t);return}return e===`i`?`i`:Number(e)}_extOnError(e){return t=>this._warnOrFail(t,e)}_warnOrFail(e,t){this._warn(e,t),this._options.strict!==!1&&this._fail(e,t)}_hintMissingExtension(e,t){let n=ft.get(e);if(n===void 0||this._hintedPrefixes.has(e))return;this._hintedPrefixes.add(e);let r=`app-string prefix '${e}' requires an extension that is not enabled; ${n}`;this._options.onWarning?this._options.onWarning({message:r,...mt(t),hint:!0}):this._options.silent||console.warn(`CDN: ${r}`)}_warn(e,t){let n={message:e};if(t!==void 0&&Object.assign(n,mt(t)),this._pendingWarnings.push(n),this._options.onWarning)this._options.onWarning(n);else if(!this._options.silent){let n=t?` at line ${t.line}, column ${t.col}`:``;console.warn(`CDN strict violation${n}: ${e}`)}}_fail(t,n){throw new e.o(t,n?mt(n):void 0)}};function mt(e){return{offset:e.offset,line:e.line,column:e.col,endOffset:e.endOffset}}var ht=new TextEncoder,gt=!1,B=class extends D{indefiniteLength=!1;value;encodingWidth;ednParts;ednSource;ednPartSources;constructor(e,t){super(),this.value=e,this.encodingWidth=t?.encodingWidth,this.ednParts=t?.ednParts,this.ednSource=t?.ednSource,this.ednPartSources=t?.ednPartSources}_encodeTo(e,t){e.writeTextString(3,this.value,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(BigInt(ht.encode(this.value).length)));return _t(this.value,n,e,t,this.ednParts,this.ednSource,this.ednPartSources)}_toJS(e){return this.value}};function _t(e,t,n,r,i,a,o){if(n?.preserveRawString&&a!==void 0)return a+t;let s=n?.preserveRawString?o:void 0,c=s?.some(e=>e!==void 0)??!1,{cdn:l,newline:u}=yt(n),d=f(n),p=n?.preserveConcatenation&&i!==void 0&&(i.length>1||c)?i:void 0;if(d===null)return p===void 0?_e(e)+t:vt(p.map((e,t)=>({text:e,contentDepth:0,source:s?.[t]})),t,null,r);if(!l&&!u&&p===void 0)return _e(e)+t;let m=l?St(e):null;if(p!==void 0&&(m===null||c)){let e=[];for(let[t,n]of p.entries()){let r=s?.[t];if(r!==void 0)e.push({text:n,contentDepth:0,source:r});else if(u){let t=new Map;for(let{point:e,contentDepth:r}of xt(n,0))t.set(e,r);e.push(...At(n,t))}else e.push({text:n,contentDepth:0})}return vt(e,t,d,r)}let h=new Map;if(m!==null)for(let{point:e,contentDepth:t}of m)h.set(e,t);if(u){let t=m===null?xt(e,0):Ct(e);for(let{point:e,contentDepth:n}of t)h.has(e)||h.set(e,n)}let ee=At(e,h);return ee.length<=1?_e(e)+t:vt(ee,t,d,r)}function vt(e,t,n,r){let i=e.map(({text:n,source:r},i)=>{let a=r??_e(n);return i===e.length-1?a+t:a});if(n===null)return i.join(` + `);let a=i[0];for(let t=1;t<i.length;t++){let o=p(n,r+1+e[t].contentDepth);a+=` +\n${o}${i[t]}`}return a}function yt(e){let t=e?.splitCdn===void 0||e?.splitNewline===void 0?bt(e?.textStringFormat??[]):[];return{cdn:e?.splitCdn??t.includes(`cdn`),newline:e?.splitNewline??t.includes(`newline`)}}function bt(e){return e.map(e=>e===`cboredn`?(gt||(gt=!0,console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")),`cdn`):e)}function xt(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];i===`\r`?e[r+1]===`
5
+ `)}_encode(e,n){if(this._toCBOR!==t.prototype._toCBOR){e.writeBytes(this._toCBOR(n));return}this._encodeTo(e,n)}_encodeTo(e,n){if(this._toCBOR===t.prototype._toCBOR)throw TypeError(`CborItem subclass must implement _encodeTo() or _toCBOR()`);e.writeBytes(this._toCBOR(n))}_toCBOR(e){let t=new Oe;return this._encodeTo(t,e),t.finish()}_toHexDump(t,n){return[{depth:t,hex:e.i(this._toCBOR()),comment:this._toCDN(n,0)}]}},O=class extends D{value;encodingWidth;constructor(e,t){if(super(),this.value=BigInt(e),this.value<0n)throw RangeError(`CborUint value must be non-negative`);if(this.value>18446744073709551615n)throw RangeError(`CborUint value exceeds maximum uint64`);this.encodingWidth=t?.encodingWidth}_encodeTo(e,t){T(e,0,this.value,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.value)),r=this.value;switch(e?.intFormat){case`hex`:return`0x${r.toString(16)}${n}`;case`octal`:return`0o${r.toString(8)}${n}`;case`binary`:return`0b${r.toString(2)}${n}`;default:return r.toString()+n}}_toJS(e){let t=e?.integerAs??`auto`;return t===`bigint`?this.value:t===`number`||this.value<=BigInt(2**53-1)?Number(this.value):this.value}},k=class extends D{argument;encodingWidth;constructor(e,t){super();let n=BigInt(e);if(n>=0n)throw RangeError(`CborNint value must be negative`);if(n<-18446744073709551616n)throw RangeError(`CborNint value exceeds minimum int64`);this.argument=-1n-n,this.encodingWidth=t?.encodingWidth}get value(){return-1n-this.argument}_encodeTo(e,t){T(e,1,this.argument,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.argument)),r=this.argument+1n;switch(e?.intFormat){case`hex`:return`-0x${r.toString(16)}${n}`;case`octal`:return`-0o${r.toString(8)}${n}`;case`binary`:return`-0b${r.toString(2)}${n}`;default:return this.value.toString()+n}}_toJS(e){let t=this.value,n=e?.integerAs??`auto`;return n===`bigint`?t:n===`number`||t>=BigInt(-(2**53-1))?Number(t):t}},Fe=new DataView(new ArrayBuffer(8));function Ie(e){let t=e.startsWith(`-`),n=e.slice(t?3:2),r=n.search(/[pP]/);if(r===-1)throw SyntaxError(`EDN parse error: hex float missing 'p' exponent: ${e}`);let i=n.slice(0,r),a=n.slice(r+1);if(!/^[+-]?\d+$/.test(a))throw SyntaxError(`EDN parse error: hex float has invalid or missing exponent: ${e}`);let o=parseInt(a,10),s=i.indexOf(`.`),c;if(s===-1){if(!/^[0-9a-fA-F]+$/.test(i))throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);c=parseInt(i,16)}else{let t=i.slice(0,s),n=i.slice(s+1);if(t===``&&n===``)throw SyntaxError(`EDN parse error: hex float has no mantissa digits: ${e}`);if(t!==``&&!/^[0-9a-fA-F]+$/.test(t)||n!==``&&!/^[0-9a-fA-F]+$/.test(n))throw SyntaxError(`EDN parse error: hex float has invalid mantissa: ${e}`);c=(t===``?0:parseInt(t,16))+(n===``?0:parseInt(n,16)/16**n.length)}let l=c*2**o;return t?-l:l}function Le(e){if(isNaN(e))return`NaN`;if(!isFinite(e))return e>0?`Infinity`:`-Infinity`;let t=Object.is(e,-0)||e<0,n=Math.abs(e);if(n===0)return t?`-0x0p+0`:`0x0p+0`;Fe.setFloat64(0,n,!1);let r=Fe.getUint32(0,!1),i=Fe.getUint32(4,!1),a=r>>>20&2047,o=r&1048575,s=i,c=(o.toString(16).padStart(5,`0`)+s.toString(16).padStart(8,`0`)).replace(/0+$/,``),l=c===``?``:`.${c}`,u,d;a===0?(u=`0`,d=-1022):(u=`1`,d=a-1023);let f=d>=0?`+${d}`:`${d}`,p=`0x${u}${l}p${f}`;return t?`-${p}`:p}var A=class extends D{value;precision;ednSource;rawBits;constructor(e,t){super(),this.value=e,this.precision=t?.precision,this.rawBits=t?.rawBits}_encodeTo(e,t){let n=this.precision??E(this.value),r=Number.isNaN(this.value)?this.rawBits:void 0;n===`half`?(e.writeByte(249),r?.length===2?e.writeBytes(r):e.writeFloat16(this.value)):n===`single`?(e.writeByte(250),r?.length===4?e.writeBytes(r):e.writeFloat32(this.value)):(e.writeByte(251),r?.length===8?e.writeBytes(r):e.writeFloat64(this.value))}_toCDN(e,t){let n=e?.encodingIndicators??`auto`;if(e?.appStrings!==!1&&this.ednSource!==void 0&&(f(e)!==null||!/[\r\n]/.test(this.ednSource))){let e=this.ednSource;if(n===`never`)return e.replace(/_[0-3i]$/,``);if(n===`always`){if(/_[0-3i]$/.test(e))return e;let t=this.precision??E(this.value);return e+(t===`half`?`_1`:t===`single`?`_2`:`_3`)}return e}let r=E(this.value);return(e?.floatFormat===`hex`?Le(this.value):ve(this.value))+ye(this.value,this.precision,r,n)}_toJS(e){return this.value}},j=class extends D{tag;content;encodingWidth;constructor(e,t,n){if(super(),this.tag=BigInt(e),this.tag<0n)throw RangeError(`CborTag tag number must be non-negative`);this.content=t,this.encodingWidth=n?.encodingWidth}get _containsCdnContainer(){return this.content._containsCdnContainer}_encodeTo(e,t){T(e,6,this.tag,this.encodingWidth),this.content._encode(e,t)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(this.tag));return`${this.tag}${n}(${this.content._toCDN(e,t)})`}_toHexDump(t,n){let r=[{depth:t,hex:e.i(je(6,this.tag,this.encodingWidth)),comment:`Tag ${this.tag}`}];return r.push(...this.content._toHexDump(t+1,{...n,appStrings:!1})),r}_toJS(e){let t=this.content._toJS(e);return e?.stripTags?t:l.set(t,this.tag)}},M=class extends D{indefiniteLength=!1;value;ednEncoding;encodingWidth;ednSource;ednParts;constructor(e,t){super(),this.value=e,this.ednEncoding=t?.ednEncoding??`hex`,this.encodingWidth=t?.encodingWidth,this.ednSource=t?.ednSource,this.ednParts=t?.ednParts}_encodeTo(e,t){T(e,2,this.value.length,this.encodingWidth),e.writeBytes(this.value)}_toCDN(e,t){let n=f(e);if(e?.preserveConcatenation&&n!==null&&this.ednParts!==void 0&&this.ednParts.length>1){let r=x(e,this.encodingWidth,()=>b(BigInt(this.value.length))),i=e?.bstrEncoding??this.ednEncoding;e?.appStrings===!1&&i!==`hex`&&(i=`hex`);let a=this.ednParts.map(t=>e?.preserveByteString&&t.source!==void 0?t.source:ue(t.bytes,i,e?.sqstr));return a[a.length-1]+=r,m(a,n,t)}if(e?.preserveByteString&&this.ednSource!==void 0&&(n!==null||!/[\r\n]/.test(this.ednSource))){if(/_[0-3i]$/.test(this.ednSource))return(e?.encodingIndicators??`auto`)===`never`?this.ednSource.replace(/_[0-3i]$/,``):this.ednSource;let t=x(e,this.encodingWidth,()=>b(BigInt(this.value.length)));return this.ednSource+t}let r=x(e,this.encodingWidth,()=>b(BigInt(this.value.length))),i=e?.bstrEncoding??this.ednEncoding;return e?.appStrings===!1&&i!==`hex`&&(i=`hex`),ue(this.value,i,e?.sqstr)+r}_toJS(e){return this.value}},N=class extends D{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_encodeTo(e,t){e.writeByte(95);for(let n of this.chunks)n._encode(e,t);e.writeByte(255)}_toCDN(e,t){if((e?.encodingIndicators??`auto`)===`never`){let n=this.chunks.reduce((e,t)=>e+t.value.length,0),r=new Uint8Array(n),i=0;for(let e of this.chunks)r.set(e.value,i),i+=e.value.length;return new M(r)._toCDN(e,t)}return this.chunks.length===0?`''_`:v({node:this,options:e,depth:t,openChar:`(`,closeChar:`)`,count:this.chunks.length,indefiniteLength:!0,encodingWidth:void 0,hasEntryComments:()=>this.chunks.some(h),renderEntry:n=>this.chunks[n]._toCDN(e,t+1),entryLeadingNode:e=>this.chunks[e],entryTrailing:(e,t)=>_(this.chunks[e],t)})}_toHexDump(t,n){let r=[{depth:t,hex:e.n(95),comment:`Start indefinite-length byte string`}];for(let e of this.chunks)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}_toJS(e){let t=this.chunks.reduce((e,t)=>e+t.value.length,0),n=new Uint8Array(t),r=0;for(let e of this.chunks)n.set(e.value,r),r+=e.value.length;return n}},P=class extends D{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_encodeTo(e,t){e.writeByte(127);for(let n of this.chunks)n._encode(e,t);e.writeByte(255)}_toCDN(e,t){return(e?.encodingIndicators??`auto`)===`never`?new B(this.chunks.map(e=>e.value).join(``))._toCDN(e,t):this.chunks.length===0?`""_`:v({node:this,options:e,depth:t,openChar:`(`,closeChar:`)`,count:this.chunks.length,indefiniteLength:!0,encodingWidth:void 0,hasEntryComments:()=>this.chunks.some(h),renderEntry:n=>this.chunks[n]._toCDN(e,t+1),entryLeadingNode:e=>this.chunks[e],entryTrailing:(e,t)=>_(this.chunks[e],t)})}_toHexDump(t,n){let r=[{depth:t,hex:e.n(127),comment:`Start indefinite-length text string`}];for(let e of this.chunks)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}_toJS(e){return this.chunks.map(e=>e.value).join(``)}},F=class extends D{items;indefiniteLength;encodingWidth;constructor(e,t){super(),this.items=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return!0}_encodeTo(e,t){if(this.indefiniteLength){e.writeByte(159);for(let n of this.items)n._encode(e,t);e.writeByte(255);return}T(e,4,this.items.length,this.encodingWidth);for(let n of this.items)n._encode(e,t)}_toCDN(e,t){return v({node:this,options:e,depth:t,openChar:`[`,closeChar:`]`,count:this.items.length,indefiniteLength:this.indefiniteLength,encodingWidth:this.encodingWidth,hasEntryComments:()=>this.items.some(h),renderEntry:n=>this.items[n]._toCDN(e,t+1),entryIsLeaf:e=>!this.items[e]._containsCdnContainer,entryLeadingNode:e=>this.items[e],entryTrailing:(e,t)=>_(this.items[e],t)})}_toHexDump(t,n){if(this.indefiniteLength){let r=[{depth:t,hex:e.n(159),comment:`Start indefinite-length array`}];for(let e of this.items)r.push(...e._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}let r=[{depth:t,hex:e.i(je(4,BigInt(this.items.length),this.encodingWidth)),comment:`Array of length ${this.items.length}`}];for(let e of this.items)r.push(...e._toHexDump(t+1,n));return r}_toJS(e){let t=e?.reviver;if(!t)return this.items.map(t=>t._toJS(e));let n=e?{...e,reviver:void 0}:void 0,r=this.items.map(e=>e._toJS(n)),i=0;for(let n=0;n<this.items.length;n++){let a=n-i,o=this.items[n]._toJS(e),s=t.call(r,String(n),o);s===u||e?.undefinedOmits&&s===void 0?(r.splice(a,1),i++):r[a]=s}return r}},I=class extends D{entries;indefiniteLength;encodingWidth;constructor(e,t){super(),this.entries=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return!0}_encodeTo(e,t){if(this.indefiniteLength){e.writeByte(191);for(let[n,r]of this.entries)n._encode(e,t),r._encode(e,t);e.writeByte(255);return}T(e,5,this.entries.length,this.encodingWidth);for(let[n,r]of this.entries)n._encode(e,t),r._encode(e,t)}_toCDN(e,t){return v({node:this,options:e,depth:t,openChar:`{`,closeChar:`}`,count:this.entries.length,indefiniteLength:this.indefiniteLength,encodingWidth:this.encodingWidth,hasEntryComments:()=>this.entries.some(([e,t])=>h(e)||h(t)),renderEntry:(n,r)=>{let[i,a]=this.entries[n];return`${i._toCDN(e,t+1)}${r}${a._toCDN(e,t+1)}`},entryIsLeaf:e=>{let[t,n]=this.entries[e];return!t._containsCdnContainer&&!n._containsCdnContainer},entryLeadingNode:e=>this.entries[e][0],entryTrailing:(e,t)=>{let[n,r]=this.entries[e];return Re([...n.comments?.trailing??[],...r.comments?.leading??[],...r.comments?.trailing??[]],t)}})}_toHexDump(t,n){if(this.indefiniteLength){let r=[{depth:t,hex:e.n(191),comment:`Start indefinite-length map`}];for(let[e,i]of this.entries)r.push(...e._toHexDump(t+1,n)),r.push(...i._toHexDump(t+1,n));return r.push({depth:t,hex:e.n(255),comment:`"break"`}),r}let r=[{depth:t,hex:e.i(je(5,BigInt(this.entries.length),this.encodingWidth)),comment:`Map of length ${this.entries.length}`}];for(let[e,i]of this.entries)r.push(...e._toHexDump(t+1,n)),r.push(...i._toHexDump(t+1,n));return r}_toJS(e){let t=e?.reviver,n=()=>{let n=$.from(this.entries,([t,n])=>[t._toJS(e),n._toJS(e)]);if(!t)return n;let r=e?.undefinedOmits;for(let e=0;e<n.length;e++){let[i,a]=n[e],o=t.call(n,i,a);o===u||r&&o===void 0?n.splice(e--,1):n[e]=[i,o]}return n};return e?.mapAs===`entries`?n():e?.mapAs===`object`||this.entries.every(([e])=>e instanceof B)?(()=>{let n=e?{...e,reviver:void 0}:void 0,r={};for(let[e,t]of this.entries){let i=e instanceof B?e.value:e.toCDN(),a=t._toJS(n);i===`__proto__`?Object.defineProperty(r,i,{value:a,writable:!0,enumerable:!0,configurable:!0}):r[i]=a}if(!t)return r;let i=new Map;for(let e=0;e<this.entries.length;e++){let[t]=this.entries[e];i.set(t instanceof B?t.value:t.toCDN(),e)}for(let n=0;n<this.entries.length;n++){let[a,o]=this.entries[n],s=a instanceof B?a.value:a.toCDN();if(i.get(s)!==n)continue;let c=o._toJS(e),l=t.call(r,s,c);l===u||e?.undefinedOmits&&l===void 0?delete r[s]:s===`__proto__`?Object.defineProperty(r,s,{value:l,writable:!0,enumerable:!0,configurable:!0}):r[s]=l}return r})():n()}};function Re(e,t){return e.length===0?``:` `+e.map(e=>g(e,t).trimEnd()).join(` `)}var L=class e extends D{value;constructor(e){if(super(),!Number.isInteger(e)||e<0||e>255)throw RangeError(`CborSimple value must be an integer in 0–255`);this.value=e}static FALSE=new e(20);static TRUE=new e(21);static NULL=new e(22);static UNDEFINED=new e(23);_encodeTo(e,t){if(this.value<=23){e.writeByte(224|this.value);return}e.writeByte(248),e.writeByte(this.value)}_toCDN(e,t){switch(this.value){case 20:return`false`;case 21:return`true`;case 22:return`null`;case 23:return`undefined`;default:return`simple(${this.value})`}}_toJS(e){switch(this.value){case 20:return!1;case 21:return!0;case 22:return null;case 23:return;default:return new d(this.value)}}},ze=class extends D{items;encodingWidth;constructor(e,t){super(),this.items=e,this.encodingWidth=t?.encodingWidth}get _containsCdnContainer(){return this.items.some(e=>e._containsCdnContainer)}_content(e){let t=new Oe;for(let n of this.items)n._encode(t,e);return t.finish()}_encodeTo(e,t){let n=this._content(t);T(e,2,n.length,this.encodingWidth),e.writeBytes(n)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(BigInt(this._content(e).length)));if(this.items.length===0)return`<<>>${n}`;let r=f(e),{inlineSep:i,multilineSep:a,trailSep:o}=re(e,r===null);if(r===null)return`<<${this.items.map(n=>n._toCDN(e,t+1)).join(i)}>>${n}`;let s=p(r,t+1),c=p(r,t),l=this.items.map(n=>`${s}${n._toCDN(e,t+1)}`),u=l.length-1;return`<<\n${l.map((e,t)=>t<u?`${e}${a}`:`${e}${o}`).join(`
6
+ `)}\n${c}>>${n}`}_toHexDump(t,n){let r=this._content().length,i=[{depth:t,hex:e.i(je(2,BigInt(r),this.encodingWidth)),comment:`Embedded CBOR sequence, ${r} byte${r===1?``:`s`}`}];for(let e of this.items)i.push(...e._toHexDump(t+1,n));return i}_toJS(e){return this._content()}},Be=999n,Ve=class extends j{constructor(e,t){let n=t.length===1&&t[0]instanceof B?t[0]:new F(t);super(Be,new F([new B(e),n]))}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);let n=this.content,r=n.items[0].value,i=n.items[1];return i instanceof B?`${r}${ge(i.value)}`:`${r}<<${i.items.map(n=>n._toCDN(e,t)).join(`, `)}>>`}},He=class extends D{inner;ednSource;constructor(e,t){super(),this.inner=e,this.ednSource=t}get _containsCdnContainer(){return this.inner._containsCdnContainer}_encodeTo(e,t){this.inner._encode(e,t)}_toCDN(e,t){let n=e?.encodingIndicators??`auto`;return e?.appStrings!==!1&&n===`auto`&&(f(e)!==null||!/[\r\n]/.test(this.ednSource))?this.ednSource:this.inner._toCDN(e,t)}_toJS(e){return this.inner._toJS(e)}},Ue=888n,R=class extends j{constructor(e){e===void 0?super(Ue,L.NULL):super(Ue,new F(e))}_toCDN(e,t){if(e?.appStrings===!1)return super._toCDN(e,t);if(this.content instanceof L)return`...`;if(this.content instanceof F){let n=this.content.items.map(n=>n._toCDN(e,t));return n.length===0?``:m(n,f(e),t)}return super._toCDN(e,t)}},We=2n,Ge=3n,Ke=18446744073709551615n,qe=-18446744073709551616n;function Je(e){if(e<0n)throw RangeError(`bigintToBytes requires a non-negative value`);if(e===0n)return new Uint8Array;let t=e.toString(16);t.length%2!=0&&(t=`0`+t);let n=new Uint8Array(t.length/2);for(let e=0;e<n.length;e++)n[e]=parseInt(t.slice(e*2,e*2+2),16);return n}function Ye(e){let t=0n;for(let n of e)t=t<<8n|BigInt(n);return t}var Xe=class extends j{bigValue;constructor(e){if(e<=Ke)throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);super(We,new M(Je(e))),this.bigValue=e}_toCDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},Ze=class extends j{bigValue;constructor(e){if(e>=qe)throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);super(Ge,new M(Je(-1n-e))),this.bigValue=e}_toCDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},Qe=new TextEncoder,$e=new TextDecoder(`utf-8`,{fatal:!0}),et=new TextDecoder(`utf-8`,{fatal:!1});function tt(t,n){let r=new e.t(t,{offset:n?.offset,skipRS:n?._skipRS}),i=new pt(r,n??{}).parse();return n?.preserveComments&&ot(i,r.comments,t),i}function nt(e){let t=e,n;return/[_][0-7i]$/.test(e)&&(n=e[e.length-1],t=e.slice(0,-2)),{numStr:t,rawSuffix:n}}function rt(e){return e.startsWith(`-`)?-BigInt(e.slice(1)):BigInt(e)}function it(e,t){if(e.endsWith(`_i`)||e.endsWith(`_0`)){let n=`_0 and _i encoding indicators are not valid for floating-point values`;if(t)t(n),e=e.slice(0,-2);else throw SyntaxError(`EDN parse error: ${n}`)}else if(/[_][4567]$/.test(e)){let n=e[e.length-1],r=n===`7`?`indefinite-length encoding (_7) is not valid for floating-point values`:`encoding indicator _${n} (AI ${Number(n)+24}) is reserved and not valid`;if(t)t(r),e=e.slice(0,-2);else throw SyntaxError(`EDN parse error: ${r}`)}if(e===`NaN`)return{value:NaN,precision:void 0};if(e===`Infinity`)return{value:1/0,precision:void 0};if(e===`-Infinity`)return{value:-1/0,precision:void 0};let n=e,r;return e.endsWith(`_1`)?(r=`half`,n=e.slice(0,-2)):e.endsWith(`_2`)?(r=`single`,n=e.slice(0,-2)):e.endsWith(`_3`)&&(r=`double`,n=e.slice(0,-2)),/^-?0[xX]/.test(n)?{value:Ie(n),precision:r}:{value:parseFloat(n),precision:r}}function at(e,t){let n=e.indexOf(`=`),r=n>=0?e.slice(0,n):e,i=n>=0?e.slice(n):``;if(/[^A-Za-z0-9+/\-_]/.test(r)){let e=[...r].find(e=>!/[A-Za-z0-9+/\-_]/.test(e))??``;throw SyntaxError(`invalid character ${JSON.stringify(e)} in base64 data`)}if(i&&!/^=+$/.test(i))throw SyntaxError(`invalid character after base64 '=' padding`);let a=r.length%4;if(a===1)throw SyntaxError(`invalid base64 length: ${r.length} data characters (length mod 4 = 1 is never valid)`);let o=a===0?0:4-a;if(i.length>o){let e=`base64 has ${i.length} '=' character${i.length>1?`s`:``} but the data length (${r.length}) requires at most ${o}`;if(t)t(e);else throw SyntaxError(e)}if(i.length>0&&i.length<o){let e=`base64 has ${i.length} '=' character${i.length>1?`s`:``} but needs exactly ${o} — use full padding or no padding at all`;if(t)t(e);else throw SyntaxError(e)}if(a!==0&&r.length>0){let e=r[r.length-1].replace(`-`,`+`).replace(`_`,`/`),n=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.indexOf(e);if(n>=0&&n&(a===2?15:3)){let e=`base64 has non-zero trailing bits in the final quantum (RFC 4648 §3.5)`;if(t)t(e);else throw SyntaxError(e)}}let s=r.replace(/-/g,`+`).replace(/_/g,`/`)+`=`.repeat(o);if(typeof Uint8Array.fromBase64==`function`)return Uint8Array.fromBase64(s,{alphabet:`base64`,lastChunkHandling:`loose`});let c=atob(s),l=new Uint8Array(c.length);for(let e=0;e<c.length;e++)l[e]=c.charCodeAt(e);return l}function ot(e,t,n){if(t.length===0)return;let r=st(e),i=lt(n),a=[...r].sort((e,t)=>e.start-t.start||t.end-e.end),o=[...r].sort((e,t)=>e.end-t.end||e.start-t.start),s=[...t].sort((e,t)=>e.start-t.start),c=[],l=0;for(let t of s){let r={...t},s=0,u=o.length;for(;s<u;){let e=s+u>>1;o[e].end<=t.start?s=e+1:u=e}let d=s>0?o[s-1]:void 0,f=d?n.slice(d.end,t.start):``;if(d&&i(d.end)===t.line&&!f.includes(`:`)){ct(d.node,`trailing`,r);continue}for(;l<a.length&&a[l].start<t.start;){let e=a[l++];for(;c.length>0&&c[c.length-1].end<=e.start;)c.pop();c.push(e)}for(;c.length>0&&c[c.length-1].end<=t.start;)c.pop();let p=c.length>0?c[c.length-1]:void 0;for(s=0,u=a.length;s<u;){let e=s+u>>1;a[e].start<t.end?s=e+1:u=e}let m=s<a.length?a[s]:void 0;if((!p||m&&m.end<=p.end)&&m){ct(m.node,`leading`,r);continue}ct(p?.node??e,`dangling`,r)}}function st(e){let t=[],n=e=>{if(e.start!==void 0&&e.end!==void 0&&t.push({node:e,start:e.start,end:e.end}),e instanceof F||e instanceof ze){for(let t of e.items)n(t);return}if(e instanceof I){for(let[t,r]of e.entries)n(t),n(r);return}if(e instanceof N||e instanceof P){for(let t of e.chunks)n(t);return}e instanceof j&&n(e.content)};return n(e),t}function ct(e,t,n){e.comments??={},e.comments[t]??=[],e.comments[t].push(n)}function lt(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
7
+ `&&t.push(n+1);return n=>{let r=Math.max(0,Math.min(e.length,n));r>0&&r===e.length&&r--;let i=0,a=t.length-1;for(;i<=a;){let e=i+a>>1;t[e]<=r?i=e+1:a=e-1}return a+1}}var ut=e=>`import { ${e} } from '@cbortech/cbor' and pass it via the 'extensions' option (extensions: [${e}])`,dt=(e,t)=>`install ${t}, import { ${e} } from '${t}', and pass it via the 'extensions' option (extensions: [${e}])`,z=e=>`'${e}' is a default built-in extension that was excluded via the 'builtinExtensions' option; add it back to that array (or omit 'builtinExtensions' to use the default set)`,ft=new Map([[`b32`,ut(`b32`)],[`h32`,ut(`h32`)],[`same`,ut(`same`)],[`hash`,dt(`hash`,`@cbortech/hash-extension`)],[`uuid`,dt(`uuid`,`@cbortech/uuid-extension`)],[`UUID`,dt(`uuid`,`@cbortech/uuid-extension`)],[`dt`,z(`dt`)],[`DT`,z(`dt`)],[`ip`,z(`ip`)],[`IP`,z(`ip`)],[`cri`,z(`cri`)],[`CRI`,z(`cri`)],[`t1`,z(`t1`)],[`b1`,z(`b1`)],[`ilbs`,z(`ilbs`)],[`ilts`,z(`ilts`)],[`float`,z(`float`)]]),pt=class{t;_options;extByPrefix;extByTag;unresolvedExtension;_pendingWarnings=[];_hintedPrefixes=new Set;constructor(t,n){this.t=t,this._options=n,this.extByPrefix=new Map,this.extByTag=new Map,this.unresolvedExtension=n.unresolvedExtension??`cpa999`;let r=Z(n.builtinExtensions);for(let e of[...r,...n.extensions??[]]){for(let t of e.appStringPrefixes??[])this.extByPrefix.set(t,e);for(let t of e.tagNumbers??[])this.extByTag.set(t,e)}this.t.onEscapeWarning=(t,n,r,i,a)=>{let o={message:t,offset:n,line:r,column:i,endOffset:a};if(this._pendingWarnings.push(o),this._options.onWarning?this._options.onWarning(o):this._options.silent||console.warn(`CDN strict violation at line ${r}, column ${i}: ${t}`),this._options.strict!==!1)throw new e.o(t,{offset:n,line:r,column:i,endOffset:a})}}parse(){let e=this.parseValue();if(this._options.allowTrailing)return e;let t=this.t.peek();if(t.type!==`EOF`)for(this._warnOrFail(`unexpected token after value: ${JSON.stringify(t.value)}`,t),this._pendingWarnings.length>0&&(e.warnings??=[],e.warnings.push(...this._pendingWarnings),this._pendingWarnings=[]);this.t.peek().type!==`EOF`;)this.t.consume();return e}parseValue(){let e=this.t.peek().offset,t=this._parseValueNode();if(this.t.peek().type===`UNDERSCORE`){let e=this.t.consume();this._warnOrFail(`bare _ is not a valid encoding indicator; use _0, _1, _2, _3, or _i`,e)}if(this._pendingWarnings.length>0){t.warnings??=[];for(let e of this._pendingWarnings)t.warnings.push(e);this._pendingWarnings=[]}return t.start=e,t.end=this.t.lastEndOffset,t}_parseValueNode(){let e=this.t.peek();switch(e.type){case`INTEGER`:return this.parseIntegerOrTag();case`FLOAT`:return this.parseFloat();case`TSTR`:case`RAWSTRING`:return this.parseString();case`BYTES_HEX`:case`SQSTR`:case`BYTES_B64`:return this.t.consume(),this._parseBytesConcat(this._decodeBytesToken(e),e.type,e.raw);case`EMPTY_INDEF_BYTES`:return this.t.consume(),new N([]);case`EMPTY_INDEF_TEXT`:return this.t.consume(),new P([]);case`TRUE`:return this.t.consume(),new L(21);case`FALSE`:return this.t.consume(),new L(20);case`NULL`:return this.t.consume(),new L(22);case`UNDEFINED`:return this.t.consume(),new L(23);case`SIMPLE`:return this.parseSimple();case`LBRACKET`:return this.parseArray();case`LBRACE`:return this.parseMap();case`LPAREN`:return this.parseIndefGroup();case`LT_LT`:return this.parseEmbeddedCBOR();case`APP_STRING`:{this.t.consume();let t,n=``;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e),n=e.raw}let r=this.extByPrefix.get(e.appPrefix);if(!r?.parseAppString){if(r||this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new Ve(e.appPrefix,[new B(e.value)]);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}{let i=this._pendingWarnings.length;try{let i=r.parseAppString(e.appPrefix,e.value,this._extOnError(e),t===void 0?void 0:{encodingWidth:t});return t!==void 0&&this._applyEiToResult(i,t,e),i instanceof M&&Object.getPrototypeOf(i)===M.prototype&&i.ednSource===void 0?new M(i.value,{ednEncoding:i.ednEncoding,encodingWidth:i.encodingWidth,ednSource:e.raw+n}):(i instanceof A&&i.ednSource===void 0&&(i.ednSource=e.raw+n),i)}catch(t){if(this._options.strict!==!1)throw t;return this._pendingWarnings.length===i&&this._warn(t instanceof Error?t.message:String(t),e),new Ve(e.appPrefix,[new B(e.value)])}}}case`APP_SEQUENCE`:{this.t.consume();let t=[];for(;this.t.peek().type!==`GT_GT`;){if(this.t.peek().type===`EOF`&&this._fail(`unterminated ${e.appPrefix}<<...>>`,e),t.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());t.push(this.parseValue())}this.expect(`GT_GT`);let n,r;this.t.peek().type===`ENCODING_INDICATOR`&&(r=this.t.consume(),n=this._resolveEncodingWidth(r.value,r));let i=this.extByPrefix.get(e.appPrefix);if(!i){if(this._hintMissingExtension(e.appPrefix,e),this.unresolvedExtension===`cpa999`)return new Ve(e.appPrefix,t);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}i.parseAppSequence||this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`,e);{let a=this._pendingWarnings.length;try{let a=i.parseAppSequence(e.appPrefix,t,this._extOnError(e));n!==void 0&&this._applyEiToResult(a,n,r??e);let o=this.t.source.slice(e.offset,this.t.lastEndOffset);if(a instanceof A)a.ednSource===void 0&&(a.ednSource=o);else if(i.preserveAppSeqSource)return new He(a,o);return a}catch(n){if(this._options.strict!==!1)throw n;return this._pendingWarnings.length===a&&this._warn(n instanceof Error?n.message:String(n),e),new Ve(e.appPrefix,t)}}}case`ELLIPSIS`:{if(this.t.consume(),this.t.peek().type!==`PLUS`)return new R;let e=[new R];for(;this.t.peek().type===`PLUS`;)this.t.consume(),e.push(this.parseValue());return new R(e)}case`BYTES_HEX_ELIDED`:return this.t.consume(),this._parseHexElidedConcat(e);default:this._fail(`unexpected token: ${JSON.stringify(e.value)}`,e)}}parseIntegerOrTag(){let e=this.t.consume(),{numStr:t,rawSuffix:n}=nt(e.value),r=n===void 0?this.consumeEncodingIndicator():this._resolveEncodingWidth(n,e),i=rt(t);if(i>18446744073709551615n)return this.t.peek().type===`LPAREN`&&this._fail(`tag number exceeds maximum uint64`,e),new Xe(i);if(i<-18446744073709551616n)return new Ze(i);if(r!==void 0){let t=i>=0n?i:-(i+1n);r=this._validateEncodingFit(t,r,e)}let a=i>=0n?new O(i,r===void 0?void 0:{encodingWidth:r}):new k(i,r===void 0?void 0:{encodingWidth:r});if(this.t.peek().type===`LPAREN`){a instanceof O||this._fail(`tag number must be non-negative`,e),this.t.consume();let t=this._pendingWarnings.splice(0),n=this.parseValue();this.expect(`RPAREN`);let i=a.value,o=this.extByTag.get(i);if(o?.parseTag){let e=o.parseTag(i,n);if(e!==void 0)return e instanceof j&&r!==void 0&&e.encodingWidth===void 0&&(e.encodingWidth=r),t.length>0&&(e.warnings??=[],e.warnings.push(...t)),e}let s=new j(i,n,r===void 0?void 0:{encodingWidth:r});return t.length>0&&(s.warnings??=[],s.warnings.push(...t)),s}return a}parseFloat(){let e=this.t.consume(),t=t=>this._warnOrFail(t,e),{value:n,precision:r}=it(e.value,t);if(r===`half`||r===`single`){let e=r===`half`?C(S(n)):Math.fround(n);Object.is(n,e)||isNaN(n)&&isNaN(e)||t(`${n} cannot be exactly represented as ${r===`half`?`f16 (_1)`:`f32 (_2)`}; use _3 or remove the indicator`)}return new A(n,r===void 0?void 0:{precision:r})}parseString(){let e=this.t.consume();if(this.t.peek().type!==`PLUS`){let t=this.consumeEncodingIndicator(()=>BigInt(Qe.encode(e.value).length));return e.type===`RAWSTRING`?new B(e.value,{ednSource:e.raw,...t===void 0?{}:{encodingWidth:t}}):new B(e.value,t===void 0?void 0:{encodingWidth:t})}let t=!1,n=[e.type===`RAWSTRING`?{text:e.value,source:e.raw}:{text:e.value}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();e.type===`ELLIPSIS`?(this.t.consume(),n.push({ellipsis:!0}),t=!0):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),n.push(e.type===`RAWSTRING`?{text:e.value,source:e.raw}:{text:e.value})):this._isBytesToken(e.type)?(this.t.consume(),n.push({text:this._decodeUtf8(this._decodeBytesToken(e),e)})):this._fail(`expected string or byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!t){let e=n.map(e=>`text`in e?e.text:``),t=n.map(e=>`text`in e?e.source:void 0),r=e.join(``),i=this.consumeEncodingIndicator(()=>BigInt(Qe.encode(r).length));return new B(r,{ednParts:e,...t.some(e=>e!==void 0)?{ednPartSources:t}:{},...i===void 0?{}:{encodingWidth:i}})}let r=[],i=[],a=()=>{let e=i.map(e=>e.text),t=e.join(``);if(t!==``){let n=i.map(e=>e.source);r.push(new B(t,{ednParts:e,...n.some(e=>e!==void 0)?{ednPartSources:n}:{}}))}i.length=0};for(let e of n)`ellipsis`in e?(a(),r.push(new R)):i.push(e);return a(),new R(r)}_isBytesToken(e){return e===`BYTES_HEX`||e===`SQSTR`||e===`BYTES_B64`}_hexToBytes(t,n){try{return e.a(t)}catch(t){if(t instanceof e.o||!(t instanceof SyntaxError))throw t;this._fail(t.message,n)}}_decodeBytesToken(t){let n=e=>this._warnOrFail(e,t);switch(t.type){case`SQSTR`:{let e=t._sqstrBytes;return e===void 0?this._hexToBytes(t.value,t):e}case`BYTES_HEX`:return this._hexToBytes(t.value,t);case`BYTES_B64`:try{return at(t.value,n)}catch(n){if(n instanceof e.o||!(n instanceof SyntaxError))throw n;this._fail(n.message,t)}default:this._fail(`expected byte string token`,t)}}_decodeUtf8(e,t){if(this._options.allowInvalidUtf8)return et.decode(e);try{return $e.decode(e)}catch{return this._warnOrFail(`byte string in text concatenation is not valid UTF-8`,t),et.decode(e)}}_tokenTypeToCdnEncoding(e){return e===`BYTES_B64`?`base64`:`hex`}_parseBytesConcat(e,t,n){if(this.t.peek().type!==`PLUS`){let r=this.consumeEncodingIndicator(()=>BigInt(e.length));return new M(e,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednSource:n,...r===void 0?{}:{encodingWidth:r}})}let r=!1,i=[{bytes:e,source:n}];for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),i.push({ellipsis:!0}),r=!0;else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let t=this._buildBytesElidedItems(e.value,e);for(let e of t)e instanceof R?(i.push({ellipsis:!0}),r=!0):e instanceof M&&i.push({bytes:e.value})}else this._isBytesToken(e.type)?(this.t.consume(),i.push({bytes:this._decodeBytesToken(e),source:e.raw})):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),this._warnOrFail(`text string in a byte-string concatenation is not allowed; use a byte string literal (h'...', b64'...', or '...') instead`,e),i.push({bytes:Qe.encode(e.value)})):this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!r){let e=i.map(e=>`bytes`in e?e:{bytes:new Uint8Array}),n=this._concatBytes(e.map(e=>e.bytes)),r=this.consumeEncodingIndicator(()=>BigInt(n.length));return new M(n,{ednEncoding:this._tokenTypeToCdnEncoding(t),ednParts:e,...r===void 0?{}:{encodingWidth:r}})}let a=[],o=[],s=()=>{o.length>0&&(a.push(new M(this._concatBytes([...o]))),o.length=0)};for(let e of i)`ellipsis`in e?(s(),a.push(new R)):o.push(e.bytes);return s(),new R(a)}_parseHexElidedConcat(e){let t=this._buildBytesElidedItems(e.value,e);for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),t.push(new R);else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let n=this._buildBytesElidedItems(e.value,e);this._mergeFirstBytesItem(t,n)}else if(this._isBytesToken(e.type)){this.t.consume();let n=this._decodeBytesToken(e),r=t[t.length-1];r instanceof M?t[t.length-1]=new M(this._concatBytes([r.value,n])):t.push(new M(n))}else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}return new R(t)}_buildBytesElidedItems(e,t){let n=e.split(`...`),r=[];for(let e=0;e<n.length;e++)e>0&&r.push(new R),n[e].length>0&&r.push(new M(this._hexToBytes(n[e],t)));return r}_mergeFirstBytesItem(e,t){if(t.length===0)return;let n=e[e.length-1],r=t[0];n instanceof M&&r instanceof M?(e[e.length-1]=new M(this._concatBytes([n.value,r.value])),e.push(...t.slice(1))):e.push(...t)}_concatBytes(e){let t=e.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;return n}parseSimple(){this.t.consume(),this.expect(`LPAREN`);let e=this.t.peek();e.type!==`INTEGER`&&this._fail(`expected integer inside simple(), got ${JSON.stringify(e.value)}`,e),this.t.consume();let{numStr:t}=nt(e.value),n=Number(rt(t));return this.expect(`RPAREN`),new L(n)}parseEmbeddedCBOR(){this.t.consume();let e=[];for(;this.t.peek().type!==`GT_GT`;){if(e.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`GT_GT`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`<<...>> items must be separated by "," or whitespace`,this.t.peek());e.push(this.parseValue())}this.expect(`GT_GT`);let t;if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume();t=this._resolveEncodingWidth(e.value,e)}return new ze(e,{encodingWidth:t})}parseArray(){this.t.consume();let e=!1,t,n;this.t.peek().type===`UNDERSCORE`?(this.t.consume(),e=!0):this.t.peek().type===`ENCODING_INDICATOR`&&(n=this.t.consume(),n.value===`7`?(e=!0,this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,n),n=void 0):t=this._resolveEncodingWidth(n.value,n));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACKET`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACKET`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`array items must be separated by "," or whitespace`,this.t.peek());i.push(this.parseValue())}this.expect(`RBRACKET`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new F(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseMap(){this.t.consume();let e=!1,t,n;this.t.peek().type===`UNDERSCORE`?(this.t.consume(),e=!0):this.t.peek().type===`ENCODING_INDICATOR`&&(n=this.t.consume(),n.value===`7`?(e=!0,this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,n),n=void 0):t=this._resolveEncodingWidth(n.value,n));let r=this._pendingWarnings.splice(0),i=[];for(;this.t.peek().type!==`RBRACE`;){if(i.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RBRACE`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`map entries must be separated by "," or whitespace`,this.t.peek());let e=this.parseValue();this.expect(`COLON`);let t=this.parseValue();i.push([e,t])}this.expect(`RBRACE`),t!==void 0&&n!==void 0&&(t=this._validateEncodingFit(BigInt(i.length),t,n));let a=new I(i,{indefiniteLength:e,encodingWidth:t});return r.length>0&&(a.warnings??=[],a.warnings.push(...r)),a}parseIndefGroup(){this.t.consume();let e=this.t.peek();if(e.type===`UNDERSCORE`)this.t.consume();else if(e.type===`ENCODING_INDICATOR`&&e.value===`7`)this.t.consume(),this._warnOrFail(`encoding indicator _7 is non-standard; use _ to indicate indefinite length`,e);else if(e.type===`ENCODING_INDICATOR`){let e=this.t.consume(),t=`encoding indicator _${e.value} is not valid in an indefinite string group; use _`;this._warnOrFail(t,e)}else e.type!==`RPAREN`&&this._warnOrFail(`indefinite string group is missing _ after (; interpreting as (_ ...)`,e);let t=this._pendingWarnings.splice(0),n=[];for(;this.t.peek().type!==`RPAREN`;){if(n.length>0)if(this.t.peek().type===`COMMA`){if(this.t.consume(),this.t.peek().type===`RPAREN`)break}else this.t.peek().offset===this.t.lastEndOffset&&this._warnOrFail(`indefinite string chunks must be separated by "," or whitespace`,this.t.peek());n.push(this.parseValue())}this.expect(`RPAREN`),n.length===0&&this._fail(`empty indefinite group (_ ) is ambiguous; use ''_ for bytes or ""_ for text`);let r=n[0];if(r instanceof M){let e=new N(n.map((e,t)=>{if(e instanceof M)return e;this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`)}));return t.length>0&&(e.warnings=t),e}if(r instanceof B){let e=new P(n.map((e,t)=>{if(e instanceof B)return e;this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`)}));return t.length>0&&(e.warnings=t),e}this._fail(`indefinite group chunks must be byte strings or text strings`)}consumeEncodingIndicator(e){if(this.t.peek().type===`ENCODING_INDICATOR`){let t=this.t.consume(),n=this._resolveEncodingWidth(t.value,t);return n!==void 0&&e!==void 0&&(n=this._validateEncodingFit(e(),n,t)),n}}expect(e){let t=this.t.consume();return t.type!==e&&this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`,t),t}_applyEiToResult(e,t,n){if(e instanceof A){let r=t===1?`half`:t===2?`single`:t===3?`double`:void 0;if(r===void 0)this._warnOrFail(`encoding indicator _${t} is not valid for a float; use _1, _2, or _3`,n);else if(e.precision!==r){if(r!==`double`){let t=r===`half`?C(S(e.value)):Math.fround(e.value);!Object.is(t,e.value)&&!isNaN(e.value)&&this._warnOrFail(`${e.value} cannot be exactly represented as ${r===`half`?`float16 (_1)`:`float32 (_2)`}`,n)}e.precision=r}}else if(e instanceof O){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.value,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof k){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.argument,t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof M){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.value.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof B){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(Qe.encode(e.value).length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof F){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.items.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof I){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(BigInt(e.entries.length),t,n);r!==void 0&&(e.encodingWidth=r)}}else if(e instanceof j){if(e.encodingWidth===void 0){let r=this._validateEncodingFit(e.tag,t,n);r!==void 0&&(e.encodingWidth=r)}}else this._warnOrFail(`encoding indicator _${t} is not applicable to this app-string result type`,n)}_validateEncodingFit(e,t,n){let r=Ae(t);if(e<=r)return t;let i=`value ${e} does not fit in encoding indicator ${t===`i`?`_i (max 23)`:`_${t} (max ${r})`}`;this._warnOrFail(i,n)}_resolveEncodingWidth(e,t){if(e===`4`||e===`5`||e===`6`){let n=`encoding indicator _${e} (AI ${Number(e)+24}) is reserved and not valid`;this._warnOrFail(n,t);return}if(e===`7`){this._warnOrFail(`indefinite-length encoding (_7) is not valid here; use [_ ...] or {_ ...} for indefinite collections`,t);return}return e===`i`?`i`:Number(e)}_extOnError(e){return t=>this._warnOrFail(t,e)}_warnOrFail(e,t){this._warn(e,t),this._options.strict!==!1&&this._fail(e,t)}_hintMissingExtension(e,t){let n=ft.get(e);if(n===void 0||this._hintedPrefixes.has(e))return;this._hintedPrefixes.add(e);let r=`app-string prefix '${e}' requires an extension that is not enabled; ${n}`;this._options.onWarning?this._options.onWarning({message:r,...mt(t),hint:!0}):this._options.silent||console.warn(`CDN: ${r}`)}_warn(e,t){let n={message:e};if(t!==void 0&&Object.assign(n,mt(t)),this._pendingWarnings.push(n),this._options.onWarning)this._options.onWarning(n);else if(!this._options.silent){let n=t?` at line ${t.line}, column ${t.col}`:``;console.warn(`CDN strict violation${n}: ${e}`)}}_fail(t,n){throw new e.o(t,n?mt(n):void 0)}};function mt(e){return{offset:e.offset,line:e.line,column:e.col,endOffset:e.endOffset}}var ht=new TextEncoder,gt=!1,B=class extends D{indefiniteLength=!1;value;encodingWidth;ednParts;ednSource;ednPartSources;constructor(e,t){super(),this.value=e,this.encodingWidth=t?.encodingWidth,this.ednParts=t?.ednParts,this.ednSource=t?.ednSource,this.ednPartSources=t?.ednPartSources}_encodeTo(e,t){e.writeTextString(3,this.value,this.encodingWidth)}_toCDN(e,t){let n=x(e,this.encodingWidth,()=>b(BigInt(ht.encode(this.value).length)));return _t(this.value,n,e,t,this.ednParts,this.ednSource,this.ednPartSources)}_toJS(e){return this.value}};function _t(e,t,n,r,i,a,o){let s=f(n);if(n?.preserveRawString&&a!==void 0&&(s!==null||!/[\r\n]/.test(a)))return a+t;if(s===null)return _e(e)+t;let c=n?.preserveRawString?o:void 0,l=c?.some(e=>e!==void 0)??!1,{cdn:u,newline:d}=yt(n),p=n?.preserveConcatenation&&i!==void 0&&(i.length>1||l)?i:void 0;if(!u&&!d&&p===void 0)return _e(e)+t;let m=u?St(e):null;if(p!==void 0&&(m===null||l)){let e=[];for(let[t,n]of p.entries()){let r=c?.[t];if(r!==void 0)e.push({text:n,contentDepth:0,source:r});else if(d){let t=new Map;for(let{point:e,contentDepth:r}of xt(n,0))t.set(e,r);e.push(...At(n,t))}else e.push({text:n,contentDepth:0})}return vt(e,t,s,r)}let h=new Map;if(m!==null)for(let{point:e,contentDepth:t}of m)h.set(e,t);if(d){let t=m===null?xt(e,0):Ct(e);for(let{point:e,contentDepth:n}of t)h.has(e)||h.set(e,n)}let ee=At(e,h);return ee.length<=1?_e(e)+t:vt(ee,t,s,r)}function vt(e,t,n,r){let i=e.map(({text:n,source:r},i)=>{let a=r??_e(n);return i===e.length-1?a+t:a}),a=i[0];for(let t=1;t<i.length;t++){let o=p(n,r+1+e[t].contentDepth);a+=` +\n${o}${i[t]}`}return a}function yt(e){let t=e?.splitCdn===void 0||e?.splitNewline===void 0?bt(e?.textStringFormat??[]):[];return{cdn:e?.splitCdn??t.includes(`cdn`),newline:e?.splitNewline??t.includes(`newline`)}}function bt(e){return e.map(e=>e===`cboredn`?(gt||(gt=!0,console.warn("`textStringFormat: ['cboredn']` is deprecated; use `textStringFormat: ['cdn']` instead.")),`cdn`):e)}function xt(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];i===`\r`?e[r+1]===`
8
8
  `?(n.push({point:r+2,contentDepth:t}),r++):n.push({point:r+1,contentDepth:t}):i===`
9
9
  `&&n.push({point:r+1,contentDepth:t})}return n}function St(t){try{tt(t)}catch{return null}let n=[],r=new e.t(t),i=0,a=null,o=!1,s=0;for(;;){let e=r.consume();if(e.type===`EOF`)break;let c=!1;if(o||(o=!0,e.offset>0&&Ot(r.comments,0,e.offset)&&n.push({point:e.offset,contentDepth:i})),a!==null){if(a.kind===`opener`&&Tt.has(e.type)){a.point=e.endOffset,s=e.endOffset;continue}else a.kind===`opener`&&Dt.has(e.type)&&kt(t,a.point,e.offset)?c=!0:n.push({point:e.offset,contentDepth:a.contentDepth});a=null}Et.has(e.type)?(i++,a={point:e.endOffset,contentDepth:i,kind:`opener`}):Dt.has(e.type)?(i=Math.max(0,i-1),c||n.push({point:e.offset,contentDepth:i})):e.type===`COMMA`&&(a={point:e.endOffset,contentDepth:i,kind:`comma`}),s=e.endOffset}let c=r.comments.find(e=>e.start>=s);return c!==void 0&&n.push({point:c.start,contentDepth:i}),n}function Ct(t){let n=[],r=new e.t(t),i=0;for(;;){let e=r.consume();if(e.type===`EOF`)break;if(Et.has(e.type))i++;else if(Dt.has(e.type))i=Math.max(0,i-1);else if(e.type!==`COMMA`){if(e.type===`TSTR`){let r=t.slice(e.offset,e.endOffset);for(let t of wt(r))n.push({point:e.offset+t,contentDepth:i+1})}else if(e.type===`RAWSTRING`){let r=t.slice(e.offset,e.endOffset);for(let{point:t}of xt(r,0))n.push({point:e.offset+t,contentDepth:i+1})}}}return n}function wt(e){let t=[],n=1,r=e.length-1;for(;n<r;){let r=e[n];if(r===`\\`){let r=e[n+1];if(r===`n`||r===`r`)t.push(n+2),n+=2;else if(r===`u`)if(e[n+2]===`{`){let t=e.indexOf(`}`,n+3);n=t>=0?t+1:n+2}else n+=6;else n+=2}else r===`\r`?e[n+1]===`
10
10
  `?(t.push(n+2),n+=2):(t.push(n+1),n++):(r===`
@@ -12,4 +12,4 @@ const e=require("./tokenizer-EciPlN0n.cjs");var t=Symbol.for(`cbor.tag`),n=class
12
12
  `||r===`\r`){n++;continue}if(r===`#`){for(;n<e.length&&e[n]!==`
13
13
  `;)n++;continue}if(r===`/`){let t=e[n+1]??``;if(t===`/`){for(;n<e.length&&e[n]!==`
14
14
  `;)n++;continue}if(t===`*`){for(n+=2;n<e.length&&!(e[n]===`*`&&(e[n+1]??``)===`/`);)n++;if(n>=e.length)throw SyntaxError(`unterminated block comment`);n+=2;continue}for(n++;n<e.length&&e[n]!==`/`;)n++;if(n>=e.length)throw SyntaxError(`unterminated block comment`);n++;continue}t+=r,n++}return t}var Er=class extends A{_bits;constructor(e){super(C(e),{precision:`half`}),this._bits=e&65535}_toCBOR(){return new Uint8Array([249,this._bits>>8&255,this._bits&255])}},Dr=class extends A{_raw;constructor(e){super(new DataView(e.buffer,e.byteOffset).getFloat32(0,!1),{precision:`single`}),this._raw=e.slice()}_toCBOR(){let e=new Uint8Array(5);return e[0]=250,e.set(this._raw,1),e}},Or=class extends A{_raw;constructor(e){super(new DataView(e.buffer,e.byteOffset).getFloat64(0,!1),{precision:`double`}),this._raw=e.slice()}_toCBOR(){let e=new Uint8Array(9);return e[0]=251,e.set(this._raw,1),e}};function kr(e){if(e.length===2)return new Er(e[0]<<8|e[1]);if(e.length===4)return new Dr(e);if(e.length===8)return new Or(e);throw SyntaxError(`float'...' requires 4, 8, or 16 hex digits (2, 4, or 8 bytes); got ${e.length} bytes`)}function Ar(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023,i;if(n===31)i=t<<31|2139095040|r<<13;else if(n===0&&r===0)i=t<<31;else if(n===0){let e=r,n=0;for(;!(e&512);)e<<=1,n++;i=t<<31|112-n<<23|(e&511)<<14}else i=t<<31|n+112<<23|r<<13;let a=new Uint8Array(4);return new DataView(a.buffer).setUint32(0,i>>>0,!1),a}function jr(e){let t=e>>>15&1,n=e>>>10&31,r=e&1023,i=new Uint8Array(8),a=new DataView(i.buffer);if(n===31)a.setUint32(0,(t<<31|2146435072|r<<10)>>>0,!1),a.setUint32(4,0,!1);else if(n===0&&r===0)a.setUint32(0,t<<31>>>0,!1),a.setUint32(4,0,!1);else if(n===0){let e=r,n=0;for(;!(e&512);)e<<=1,n++;a.setUint32(0,(t<<31|1008-n<<20|(e&511)<<11)>>>0,!1),a.setUint32(4,0,!1)}else a.setUint32(0,(t<<31|n+1008<<20|r<<10)>>>0,!1),a.setUint32(4,0,!1);return i}function Mr(e){let t=new DataView(e.buffer,e.byteOffset).getUint32(0,!1),n=t>>>31&1,r=t>>>23&255,i=t&8388607,a=new Uint8Array(8),o=new DataView(a.buffer);if(r===255)o.setUint32(0,(n<<31|2146435072|i>>>3)>>>0,!1),o.setUint32(4,(i&7)<<29,!1);else if(r===0&&i===0)o.setUint32(0,n<<31>>>0,!1),o.setUint32(4,0,!1);else{let t=new DataView(e.buffer,e.byteOffset).getFloat32(0,!1);o.setFloat64(0,t,!1)}return a}function Nr(e,t,n){let r=e.length===2?1:e.length===4?2:3;if(r===1){let n=e[0]<<8|e[1];if(t===2)return new Dr(Ar(n));if(t===3)return new Or(jr(n))}if(r===2){if(t===3)return new Or(Mr(e));if(t===1){let t=new DataView(e.buffer,e.byteOffset).getFloat32(0,!1),r=S(t);return!Object.is(C(r),t)&&!isNaN(t)&&n(`float'...' value cannot be exactly represented as float16 (_1)`),new Er(r)}}if(r===3){let r=new DataView(e.buffer,e.byteOffset).getFloat64(0,!1);if(t===1){let e=S(r);return!Object.is(C(e),r)&&!isNaN(r)&&n(`float'...' value cannot be exactly represented as float16 (_1)`),new Er(e)}if(t===2){let e=Math.fround(r);!Object.is(e,r)&&!isNaN(r)&&n(`float'...' value cannot be exactly represented as float32 (_2)`);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!1),new Dr(t)}}return kr(e)}var Pr={appStringPrefixes:[`float`],parseAppString(t,n,r,i){let a=Tr(n);if(!/^[0-9a-fA-F]*$/.test(a))throw SyntaxError(`float'...' contains non-hex characters`);if(a.length%2!=0)throw SyntaxError(`float'...' hex content has odd length (${a.length} digits)`);let o=e.a(a),s=i?.encodingWidth;if(s===void 0)return kr(o);if(s!==1&&s!==2&&s!==3){let e=`float'...' encoding indicator _${s} is not valid; use _1, _2, or _3`;if(r)return r(e),kr(o);throw SyntaxError(e)}return s===(o.length===2?1:o.length===4?2:3)?kr(o):Nr(o,s,r??(e=>{throw SyntaxError(e)}))},parseAppSequence(e,t,n){if(t.length===0)throw SyntaxError(`float<<...>> requires exactly one byte-string item`);if(t.length>1){let e=`float<<...>> expects 1 item; got ${t.length} — using first`;if(n)n(e);else throw SyntaxError(e)}if(!(t[0]instanceof M))throw SyntaxError(`float<<...>> item must be a byte string`);return kr(t[0].value)}},Fr=[In,nr,ar],Ir=[Ht,sn,Nn,hr,gr,Cr,wr,Pr],Lr;function Z(e){return e===void 0?Lr??=[...Fr,...Ir]:e===!1?Fr:[...Fr,...e]}var Rr;function zr(e){if(e===void 0){if(Rr)return Rr;let e=Z(void 0);return Rr={fromJS:e.filter(e=>e.fromJS!==void 0),parseTag:e.filter(e=>e.parseTag!==void 0)}}let t=Z(e);return{fromJS:t.filter(e=>e.fromJS!==void 0),parseTag:t.filter(e=>e.parseTag!==void 0)}}function Br(e){let t=e?.extensions,n=zr(e?.builtinExtensions);return t?.length?{fromJS:[...t.filter(e=>e.fromJS!==void 0),...n.fromJS],parseTag:[...t.filter(e=>e.parseTag!==void 0),...n.parseTag]}:n}function Vr(e,t){if(t?.replacer){let{replacer:n,...r}=t,i=Ur(e,n,r.extensions,r.undefinedOmits,r.builtinExtensions);return i===u?L.UNDEFINED:Vr(i,Object.keys(r).length>0?r:void 0)}return Q(e,t,!0,Br(t))}function Q(e,t,n,r){for(let n of r.fromJS){let r=n.fromJS(e,t??{});if(r!==void 0)return r}if(n&&typeof e==`object`&&e&&l.symbol in e){let n=e[l.symbol],i=Q(e,t,!1,r);for(let e of r.parseTag){let t=e.parseTag(n,i);if(t!==void 0)return t}return new j(n,i)}if(e instanceof l.Null)return L.NULL;if(e instanceof l.Undefined)return L.UNDEFINED;if(e instanceof d)return new L(e.value);if(e===null)return L.NULL;if(e===void 0)return L.UNDEFINED;if(e===!0)return L.TRUE;if(e===!1)return L.FALSE;if(typeof e==`bigint`)return e>18446744073709551615n?new Xe(e):e<-18446744073709551616n?new Ze(e):e>=0n?new O(e):new k(e);if(typeof e==`number`)return(t?.encodeIntegerAs??`int`)===`int`&&Number.isInteger(e)&&!Object.is(e,-0)?e>=0?new O(BigInt(e)):new k(BigInt(e)):new A(e);if(typeof e==`string`)return new B(e);if(e instanceof Number||e instanceof Boolean||e instanceof String||Object.prototype.toString.call(e)===`[object BigInt]`)return Q(e.valueOf(),t,!1,r);if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return new M(new Uint8Array(e));if(ArrayBuffer.isView(e))return e instanceof Uint8Array&&t?.uint8ArrayAs===`array`?new F(Array.from(e,e=>new O(BigInt(e)))):new M(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));if(e instanceof $)return new I([...e].map(([e,n])=>[Q(e,t,!0,r),Q(n,t,!0,r)]));if(Array.isArray(e))return new F(e.map(e=>Q(e,t,!0,r)));if(typeof e==`object`){let n=[];for(let[i,a]of Object.entries(e))n.push([new B(i),Q(a,t,!0,r)]);return new I(n)}throw TypeError(`fromJS: unsupported value type: ${typeof e}`)}function Hr(e){return ArrayBuffer.isView(e)||e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||e instanceof Number||e instanceof Boolean||e instanceof String||Object.prototype.toString.call(e)===`[object BigInt]`||e instanceof l.Null||e instanceof l.Undefined||e instanceof d}function Ur(e,t,n,r,i){let a=[...n??[],...Z(i)].filter(e=>e.isJSType!==void 0);function o(e){return e===u||r===!0&&e===void 0}if(Array.isArray(t)){let n=t.map(String);function s(e){if(typeof e!=`object`||!e)return e;if(e instanceof $)return $.from(e,([e,t])=>[e,s(t)]);if(Array.isArray(e))return e.map(s);if(l.symbol in e||Hr(e)||a.some(t=>t.isJSType(e)))return e;let t=Object.getPrototypeOf(e);if(t===Object.prototype||t===null){let t=e.toJSON;if(typeof t==`function`)return s(t.call(e))}let r={};for(let t of n)Object.prototype.hasOwnProperty.call(e,t)&&(r[t]=s(e[t]));return r}return s(e)}let c=t;function d(e,t,n){if(typeof e==`object`&&e&&!(e instanceof $)){let n=Object.getPrototypeOf(e);if(n===Object.prototype||n===null){let n=e.toJSON;typeof n==`function`&&(e=n.call(e,t))}}if(e=c.call(n,t,e),typeof e==`object`&&e){if(l.symbol in e)return e;if(e instanceof $){let t=new $;for(let[n,r]of e){let i=d(r,n,e);o(i)||t.push([n,i])}return t}if(Array.isArray(e))return e.map((t,n)=>{let r=d(t,String(n),e);return o(r)?null:r});if(Hr(e)||a.some(t=>t.isJSType(e)))return e;let t={};for(let n of Object.keys(e)){let r=d(e[n],n,e);o(r)||(t[n]=r)}return t}return e}return d(e,``,{"":e})}var $=class extends Array{toJSON(){let e={};for(let[t,n]of this){let r=typeof t==`string`?t:Vr(t).toCDN();r===`__proto__`?Object.defineProperty(e,r,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[r]=n}return e}};Object.defineProperty(exports,"A",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,"D",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"F",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"I",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"L",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"M",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"N",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"O",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"P",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return Pr}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return wr}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return er}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return B}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(exports,"j",{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,"k",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ur}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return Tr}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return sn}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Vr}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return Cr}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return Xe}});
15
- //# sourceMappingURL=mapEntries-DDJxbotH.cjs.map
15
+ //# sourceMappingURL=mapEntries-6hy7UgeN.cjs.map