@cbortech/cbor 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,32 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Symbol(`cbor.omit`),t=class{start;end;comments;_defaults;toCBOR(e){let t=this._defaults?{...this._defaults,...e}:e;return this._toCBOR(t)}toEDN(e){let t=this._defaults?{...this._defaults,...e}:e,n=this._toEDN(t,0);if(!t?.preserveComments)return n;let r=this.comments?.leading?.map(e=>e.text)??[],i=this.comments?.trailing??[],a=i.length===0?n:`${n} ${i.map(e=>e.text.trimEnd()).join(` `)}`;return[...r,a].join(`
2
+ `)}toJS(t){let n=this._defaults?{...this._defaults,...t}:t,r=this._toJS(n);if(!n?.reviver)return r;let i=n.reviver.call({"":r},``,r);return i===e?void 0:i}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=Math.max(...a.map(e=>e.depth*r.length+e.hex.length))+2;return a.map(e=>(r.repeat(e.depth)+e.hex).padEnd(o)+i+e.comment).join(`
3
+ `)}_toHexDump(e,t){return[{depth:e,hex:Array.from(this._toCBOR(),e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `),comment:this._toEDN(t,0)}]}},n=`getFloat16`in DataView.prototype&&`setFloat16`in DataView.prototype,r=new DataView(new ArrayBuffer(8));function i(e){r.setFloat64(0,e,!1);let t=r.getUint32(0,!1),n=r.getUint32(4,!1),i=t>>>31&1,a=t>>>20&2047,o=t&1048575;if(a===2047){if(o===0&&n===0)return i<<15|31744;let e=o>>10|(n===0?0:1)||1;return i<<15|31744|e&1023}let s=a-1023+15;if(s>=31)return i<<15|31744;let c,l,u;if(s<=0){if(s<-10)return i<<15;let e=1<<20|o,t=11-s;t<=20?(c=e>>t&1023,l=e>>t-1&1,u=(e&(1<<t-1)-1)!=0||n!==0):(c=0,l=1,u=o!==0||n!==0)}else c=o>>10,l=o>>9&1,u=(o&511)!=0||n!==0;if(l!==0&&(u||c&1)&&c++,c>=1024){let e=s<=0?1:s+1;return e>=31?i<<15|31744:i<<15|e<<10}let d=s<=0?0:s;return i<<15|d<<10|c}function a(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 o=n?(e,t,n,r)=>{e.setFloat16(t,n,r)}:(e,t,n,r)=>{e.setUint16(t,i(n),r)};function s(e,t,n){if(n!==void 0){if(n===`i`){if(t>23n)throw RangeError(`value ${t} does not fit in immediate encoding _i (max 23)`);return new Uint8Array([e<<5|Number(t)])}let r=[255n,65535n,4294967295n,18446744073709551615n];if(t>r[n])throw RangeError(`value ${t} does not fit in encodingWidth _${n} (max ${r[n]})`);let i=24+n;if(i===24)return new Uint8Array([e<<5|24,Number(t)]);if(i===25){let n=new Uint8Array(3);return n[0]=e<<5|25,n[1]=Number(t>>8n),n[2]=Number(t&255n),n}if(i===26){let n=new Uint8Array(5);return n[0]=e<<5|26,new DataView(n.buffer).setUint32(1,Number(t),!1),n}let a=new Uint8Array(9);return a[0]=e<<5|27,new DataView(a.buffer).setBigUint64(1,t,!1),a}if(t<=23n)return new Uint8Array([e<<5|Number(t)]);if(t<=255n)return new Uint8Array([e<<5|24,Number(t)]);if(t<=65535n){let n=new Uint8Array(3);return n[0]=e<<5|25,n[1]=Number(t>>8n),n[2]=Number(t&255n),n}if(t<=4294967295n){let n=new Uint8Array(5);return n[0]=e<<5|26,new DataView(n.buffer).setUint32(1,Number(t),!1),n}let r=new Uint8Array(9);return r[0]=e<<5|27,new DataView(r.buffer).setBigUint64(1,t,!1),r}function c(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var l=new DataView(new ArrayBuffer(4));function u(e){return Object.is(a(i(e)),e)}function d(e){return l.setFloat32(0,e,!1),Object.is(l.getFloat32(0,!1),e)}function f(e){return u(e)?`half`:d(e)?`single`:`double`}var p=class extends t{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}_toCBOR(e){return s(0,this.value,this.encodingWidth)}_toEDN(e,t){let n=this.encodingWidth===void 0?``:`_${this.encodingWidth}`,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}},m=Symbol.for(`cbor.tag`),h=class{valueOf(){return null}toJSON(){return null}},g=class{valueOf(){}toJSON(){}};function _(e){if(!re(e))return;let t=e[m];return typeof t==`bigint`?t:void 0}function ee(e,t){let n;switch(typeof e){case`number`:n=new Number(e);break;case`string`:n=new String(e);break;case`boolean`:n=new Boolean(e);break;case`bigint`:n=Object(e);break;case`undefined`:n=new g;break;case`object`:if(e===null){n=new h;break}n=e;break;default:throw TypeError(`setCborTag: cannot tag value of type ${typeof e}`)}return n[m]=t,n}function te(e){if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.prototype.toString.call(e)===`[object BigInt]`)return e.valueOf();if(e instanceof h)return null;if(!(e instanceof g))return typeof e==`object`&&e&&delete e[m],e}function ne(e){if(e instanceof Number||e instanceof String||e instanceof Boolean||Object.prototype.toString.call(e)===`[object BigInt]`)return e.valueOf();if(e instanceof h)return null;if(!(e instanceof g))return e}function re(e){return typeof e==`object`&&!!e}var v=class{constructor(){}static symbol=m;static Null=h;static Undefined=g;static get(e){return _(e)}static set(e,t){return ee(e,t)}static remove(e){return te(e)}static getValue(e){return ne(e)}},y=class extends t{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}_toCBOR(e){return c([s(6,this.tag,this.encodingWidth),this.content._toCBOR(e)])}_toEDN(e,t){let n=this.encodingWidth===void 0?``:`_${this.encodingWidth}`;return`${this.tag}${n}(${this.content._toEDN(e,t)})`}_toHexDump(e,t){let n=[{depth:e,hex:(e=>Array.from(e,e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `))(s(6,this.tag,this.encodingWidth)),comment:`Tag ${this.tag}`}];return n.push(...this.content._toHexDump(e+1,t)),n}_toJS(e){return v.set(this.content._toJS(e),this.tag)}};function ie(e){let t=e?.indent;return t===void 0?null:typeof t==`number`?` `.repeat(t):t}function b(e,t){return e.repeat(t)}function ae(e){return!!(e.comments?.leading?.length||e.comments?.trailing?.length||e.comments?.dangling?.length)}function oe(e){return!!(e.comments?.trailing?.length||e.comments?.dangling?.length)}function se(e,t){return(e.comments?.leading??[]).map(e=>t+e.text)}function ce(e){let t=e.comments?.trailing??[];return t.length===0?``:` `+t.map(e=>e.text).join(` `)}function le(e,t){return(e.comments?.dangling??[]).map(e=>t+e.text)}function ue(e,t=!1){let n=e?.commas??`comma`,r=n!==`none`;return{inlineSep:r?t?`,`:`, `:` `,multilineSep:r?`,`:``,trailSep:n===`trailing`?`,`:``,colSep:t?`:`:`: `}}function de(e){return typeof e.toHex==`function`?e.toHex():Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}var fe=typeof new Uint8Array().toBase64==`function`;function pe(e){if(fe)return e.toBase64({omitPadding:!0});let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t).replace(/=/g,``)}function me(e){if(fe)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 he=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,ge=`0123456789ABCDEFGHIJKLMNOPQRSTUV`;function _e(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 ve(e){for(let t of e){let e=t.codePointAt(0);if(e<32||e===127)return!0}return!1}function ye(e,t,n){if(n===`string`){let t=be(e);if(t!=null)return Se(t)}if(n===`printable-string`||n===void 0){let t=be(e);if(t!=null&&!ve(t))return Se(t)}switch(t){case`base64`:return`b64'${pe(e)}'`;case`base64url`:return`b64'${me(e)}'`;case`base32`:return`b32'${_e(e,he)}'`;case`base32hex`:return`h32'${_e(e,ge)}'`;default:return`h'${de(e)}'`}}function be(e){try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{return null}}function xe(e,t){let n=t.codePointAt(0),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 Se(e){return xe(e,`'`)}function Ce(e){return xe(e,`'`)}function we(e){return xe(e,`"`)}function Te(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 Ee(e,t,n){return t===void 0||t===n?``:t===`half`?`_1`:t===`single`?`_2`:`_3`}var x=class extends t{indefiniteLength=!1;value;ednEncoding;encodingWidth;ednSource;constructor(e,t){super(),this.value=e,this.ednEncoding=t?.ednEncoding??`hex`,this.encodingWidth=t?.encodingWidth,this.ednSource=t?.ednSource}_toCBOR(e){return c([s(2,BigInt(this.value.length),this.encodingWidth),this.value])}_toEDN(e,t){let n=this.encodingWidth===void 0?``:`_${this.encodingWidth}`;if(e?.preserveByteString&&this.ednSource!==void 0)return this.ednSource+n;let r=e?.bstrEncoding??this.ednEncoding;return ye(this.value,r,e?.sqstr)+n}_toJS(e){return this.value}},De=2n,Oe=3n,ke=18446744073709551615n,Ae=-(ke+1n);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 Me(e){let t=0n;for(let n of e)t=t<<8n|BigInt(n);return t}var Ne=class extends y{bigValue;constructor(e){if(e<=ke)throw RangeError(`CborBigUint value ${e} fits in CborUint; use CborUint instead`);super(De,new x(je(e))),this.bigValue=e}_toEDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},Pe=class extends y{bigValue;constructor(e){if(e>=Ae)throw RangeError(`CborBigNint value ${e} fits in CborNint; use CborNint instead`);super(Oe,new x(je(-1n-e))),this.bigValue=e}_toEDN(e,t){return this.bigValue.toString()}_toJS(e){return this.bigValue}},S=class extends t{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}_toCBOR(e){return s(1,this.argument,this.encodingWidth)}_toEDN(e,t){let n=this.encodingWidth===void 0?``:`_${this.encodingWidth}`,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=class extends t{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_toCBOR(e){let t=[new Uint8Array([95])];for(let n of this.chunks)t.push(n._toCBOR(e));return t.push(new Uint8Array([255])),c(t)}_toEDN(e,t){return this.chunks.length===0?`''_`:`(_ ${this.chunks.map(t=>t._toEDN(e,0)).join(`, `)})`}_toHexDump(e,t){let n=e=>e.toString(16).toUpperCase().padStart(2,`0`),r=[{depth:e,hex:n(95),comment:`Start indefinite-length byte string`}];for(let n of this.chunks)r.push(...n._toHexDump(e+1,t));return r.push({depth:e,hex: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}};function Ie(e,t){let n=1,r=1;for(let i=0;i<t;i++)e[i]===`
4
+ `?(n++,r=1):r++;return{line:n,col:r}}var Le=class{pos;line;col;_peeked=null;_lastConsumedEndOffset;comments=[];constructor(e,t){this.input=e;let n=t?.offset??0;if(!Number.isInteger(n)||n<0||n>e.length)throw RangeError(`EDN parse offset must be an integer between 0 and ${e.length}`);let r=Ie(e,n);this.pos=n,this.line=r.line,this.col=r.col,this._lastConsumedEndOffset=n}peek(){return this._peeked===null&&(this._peeked=this._readNext()),this._peeked}consume(){let e=this._peeked===null?this._readNext():this._peeked;return this._peeked=null,this._lastConsumedEndOffset=e.endOffset,e}get lastEndOffset(){return this._lastConsumedEndOffset}_ch(){return this.input[this.pos]??``}_eof(){return this.pos>=this.input.length}_advance(){let e=this.input[this.pos++]??``;return e===`
5
+ `?(this.line++,this.col=1):this.col++,e}_fail(e,t=this.line,n=this.col){throw SyntaxError(`EDN parse error at line ${t}, column ${n}: ${e}`)}_skipWS(){for(;;){for(;!this._eof()&&/\s/.test(this._ch());)this._advance();if(this._eof())return;let e=this._ch();if(e===`#`){let e=this.pos,t=this.line,n=this.col;for(;!this._eof()&&this._ch()!==`
6
+ `;)this._advance();this.comments.push({kind:`line`,marker:`#`,text:this.input.slice(e,this.pos),start:e,end:this.pos,line:t,col:n});continue}if(e===`/`){let e=this.input[this.pos+1]??``;if(e===`/`){let e=this.pos,t=this.line,n=this.col;for(this._advance(),this._advance();!this._eof()&&this._ch()!==`
7
+ `;)this._advance();this.comments.push({kind:`line`,marker:`//`,text:this.input.slice(e,this.pos),start:e,end:this.pos,line:t,col:n});continue}if(e===`*`){let e=this.pos,t=this.line,n=this.col;this._advance(),this._advance(),this._skipBlockCommentStar(),this.comments.push({kind:`block`,marker:`/*`,text:this.input.slice(e,this.pos),start:e,end:this.pos,line:t,col:n});continue}let t=this.pos,n=this.line,r=this.col;this._advance(),this._skipBlockCommentSlash(),this.comments.push({kind:`block`,marker:`/`,text:this.input.slice(t,this.pos),start:t,end:this.pos,line:n,col:r});continue}return}}_skipByteStringComment(e){let t=this._ch();if(t===`/`){let t=this.input[this.pos+1]??``;if(t===`/`){for(this._advance(),this._advance();!this._eof()&&this._ch()!==`
8
+ `;){if(this._ch()===`\\`){this._advance(),!this._eof()&&this._ch()!==`
9
+ `&&this._advance();continue}if(this._ch()===e)break;this._advance()}return!0}return t===`*`?(this._advance(),this._advance(),this._skipBlockCommentStar(),!0):(this._advance(),this._skipBlockCommentSlash(),!0)}if(t===`#`){for(;!this._eof()&&this._ch()!==`
10
+ `;){if(this._ch()===`\\`){this._advance(),!this._eof()&&this._ch()!==`
11
+ `&&this._advance();continue}if(this._ch()===e)break;this._advance()}return!0}return!1}_skipRawComment(e,t,n,r,i){let a=e[t];if(a===`/`){if(t++,e[t]===`/`){for(t++;t<e.length&&e[t]!==`
12
+ `;)t++;return t}if(e[t]===`*`){for(t++;t<e.length;){if(e[t]===`*`&&e[t+1]===`/`)return t+2;t++}return t}for(;t<e.length&&e[t]!==`/`;)t++;if(t>=e.length)throw SyntaxError(`EDN parse error at line ${r}, column ${i}: unterminated block comment in ${n}`);return t+1}if(a===`#`){for(;t<e.length&&e[t]!==`
13
+ `;)t++;return t}return-1}_skipBlockCommentSlash(){let e=this.line,t=this.col;for(;!this._eof();){if(this._ch()===`\\`){this._advance(),this._eof()||this._advance();continue}if(this._ch()===`/`)break;this._advance()}this._eof()&&this._fail(`unterminated block comment`,e,t),this._advance()}_skipBlockCommentStar(){let e=this.line,t=this.col;for(;!this._eof();){if(this._ch()===`*`&&(this.input[this.pos+1]??``)===`/`){this._advance(),this._advance();return}this._advance()}this._fail(`unterminated block comment`,e,t)}_readStringContent(e){this._advance();let t=``;for(;!this._eof()&&this._ch()!==e;){let n=this._ch();if(n===`\r`){this._advance();continue}let r=n.codePointAt(0);if((r<32&&r!==10||r===127)&&this._fail(`unescaped control character U+${r.toString(16).padStart(4,`0`)} is not allowed in string literals`),n===`\\`){this._advance();let n=this.line,r=this.col,i=this._advance();switch(i){case`n`:t+=`
14
+ `;break;case`r`:t+=`\r`;break;case`t`:t+=` `;break;case`b`:t+=`\b`;break;case`f`:t+=`\f`;break;case`\\`:t+=`\\`;break;case`u`:t+=this._readUnicodeEscape(e);break;default:if(i===e){t+=i;break}if(i===`/`){t+=`/`;break}this._fail(`invalid escape sequence \\${i} in ${e===`"`?`double`:`single`}-quoted string`,n,r)}}else t+=this._advance()}return this._eof()&&this._fail(`unterminated string literal`),this._advance(),t}_readUnicodeEscape(e){let t=this.line,n=this.col,r=r=>{e===`'`&&r>=32&&r<=126&&r!==92&&r!==39&&this._fail(`\\u escape for printable ASCII U+${r.toString(16).padStart(4,`0`)} is not allowed in single-quoted strings; write the character literally`,t,n)};if(!this._eof()&&this._ch()===`{`){this._advance();let e=``;for(;!this._eof()&&this._ch()!==`}`;){let r=this._ch();/[0-9a-fA-F]/.test(r)||this._fail(`invalid character in \\u{} escape: ${JSON.stringify(r)}`,t,n),e+=this._advance()}this._eof()&&this._fail(`unterminated \\u{} escape`,t,n),this._advance(),e.length===0&&this._fail(`empty \\u{} escape`,t,n);let i=parseInt(e,16);return i>1114111&&this._fail(`\\u{${e}} exceeds maximum Unicode code point U+10FFFF`,t,n),i>=55296&&i<=57343&&this._fail(`\\u{${e}} is a surrogate code point, which is not a valid Unicode scalar value`,t,n),r(i),String.fromCodePoint(i)}let i=``;for(let e=0;e<4;e++){this._eof()&&this._fail(`truncated \\uXXXX escape`,t,n);let e=this._ch();/[0-9a-fA-F]/.test(e)||this._fail(`invalid hex digit in \\uXXXX escape: ${JSON.stringify(e)}`,t,n),i+=this._advance()}let a=parseInt(i,16);if(a>=55296&&a<=56319){(this._ch()!==`\\`||(this.input[this.pos+1]??``)!==`u`)&&this._fail(`lone high surrogate \\u${i} must be followed by \\uDC00–\\uDFFF`,t,n),this._advance(),this._advance();let e=this.line,r=this.col,o=``;for(let t=0;t<4;t++)this._eof()&&this._fail(`truncated low-surrogate escape`,e,r),o+=this._advance();let s=parseInt(o,16);return(s<56320||s>57343)&&this._fail(`\\u${i} (high surrogate) not followed by a valid low surrogate (got \\u${o})`,t,n),String.fromCodePoint(65536+(a-55296)*1024+(s-56320))}return a>=56320&&a<=57343&&this._fail(`lone low surrogate \\u${i} is not valid`,t,n),r(a),String.fromCharCode(a)}_readRawStringContent(){let e=this.line,t=this.col,n=0;for(;!this._eof()&&this._ch()==="`";)this._advance(),n++;!this._eof()&&this._ch()===`\r`&&this._advance(),!this._eof()&&this._ch()===`
15
+ `&&this._advance();let r=``;for(;!this._eof();){let i=this._ch();if(i===`\r`){this._advance();continue}if(i==="`"){let i=0;for(;!this._eof()&&this._ch()==="`";)this._advance(),i++;if(i>=n)return r+="`".repeat(i-n),r===``&&this._fail(`raw string must not be empty (§2.5.3)`,e,t),r;r+="`".repeat(i)}else{let e=i.codePointAt(0);e<32&&e!==10&&e!==13&&this._fail(`raw string content must not contain control character U+${e.toString(16).toUpperCase().padStart(4,`0`)} (§2.5.3)`,this.line,this.col),e===127&&this._fail(`raw string content must not contain DEL (U+007F) (§2.5.3)`,this.line,this.col),r+=this._advance()}}this._fail(`unterminated raw string literal`,e,t)}_processRawHexContent(e,t,n){let r=``,i=!1,a=0;for(;a<e.length;){let o=e[a];if(o===`
16
+ `||o===` `||o===`\r`){a++;continue}if(o===` `)throw SyntaxError(`EDN parse error at line ${t}, column ${n}: horizontal tab (HT) is not allowed inside h\`\` raw byte string literals (§5.3.3)`);let s=this._skipRawComment(e,a,"h`` raw byte string",t,n);if(s!==-1){a=s;continue}if(o===`.`&&e[a+1]===`.`&&e[a+2]===`.`){for(a+=3;a<e.length&&e[a]===`.`;)a++;r+=`...`,i=!0;continue}if(/[0-9a-fA-F]/.test(o)){r+=o,a++;continue}throw SyntaxError(`EDN parse error at line ${t}, column ${n}: unexpected character ${JSON.stringify(o)} in h\`\` raw byte string`)}return{value:r,elided:i}}_processRawB64Content(e,t,n){let r=``,i=0;for(;i<e.length;){let a=e[i];if(a===`
17
+ `||a===` `||a===`\r`){i++;continue}if(a===` `)throw SyntaxError(`EDN parse error at line ${t}, column ${n}: horizontal tab (HT) is not allowed inside b64\`\` raw byte string literals (§5.3.4)`);if(a===`#`){for(;i<e.length&&e[i]!==`
18
+ `;)i++;continue}r+=a,i++}return r}_processRawB32Content(e,t,n){let r=``,i=0;for(;i<e.length;){let a=e[i];if(a===`
19
+ `||a===` `||a===`\r`){i++;continue}if(a===` `)throw SyntaxError(`EDN parse error at line ${t}, column ${n}: horizontal tab (HT) is not allowed inside b32\`\`/h32\`\` raw byte string literals (§5.2)`);let o=this._skipRawComment(e,i,"b32``/h32`` raw byte string",t,n);if(o!==-1){i=o;continue}r+=a,i++}return r}_readByteContent(e){this._advance();let t=``;for(;!this._eof()&&this._ch()!==e;){let n=this._ch();if(n===`
20
+ `||n===` `){this._advance();continue}if(n===`\r`){this._advance();continue}if(n===` `&&this._fail(`horizontal tab (HT) is not allowed inside byte string literals (§5.2.2)`,this.line,this.col),n===`#`){for(;!this._eof()&&this._ch()!==`
21
+ `;){if(this._ch()===`\\`){this._advance(),!this._eof()&&this._ch()!==`
22
+ `&&this._advance();continue}if(this._ch()===e)break;this._advance()}continue}t+=this._advance()}return this._eof()&&this._fail(`unterminated byte string literal`),this._advance(),t}_readB32Content(e){this._advance();let t=``;for(;!this._eof()&&this._ch()!==e;){let n=this._ch();if(n===`
23
+ `||n===` `||n===`\r`){this._advance();continue}n===` `&&this._fail(`horizontal tab (HT) is not allowed inside byte string literals (§5.2)`,this.line,this.col),!this._skipByteStringComment(e)&&(t+=this._advance())}return this._eof()&&this._fail(`unterminated byte string literal`),this._advance(),t}_readHexByteContentElisionAware(e){this._advance();let t=``,n=!1;for(;!this._eof()&&this._ch()!==e;){let r=this._ch();if(r===`
24
+ `||r===` `||r===`\r`){this._advance();continue}if(r===` `&&this._fail(`horizontal tab (HT) is not allowed inside hex byte string literals (§5.2.1)`,this.line,this.col),!this._skipByteStringComment(e)){if(r===`.`&&(this.input[this.pos+1]??``)===`.`&&(this.input[this.pos+2]??``)===`.`){for(this._advance(),this._advance(),this._advance();!this._eof()&&this._ch()===`.`;)this._advance();t.endsWith(`...`)||(t+=`...`),n=!0;continue}if(/[0-9a-fA-F]/.test(r)){t+=this._advance();continue}this._fail(`unexpected character ${JSON.stringify(r)} in hex byte string`)}}return this._eof()&&this._fail(`unterminated hex byte string literal`),this._advance(),{value:t,elided:n}}_readNext(){this._skipWS();let e=this.pos;return{...this._readNextCore(),raw:this.input.slice(e,this.pos),offset:e,endOffset:this.pos}}_readNextCore(){let e=this.line,t=this.col;if(this._eof())return{type:`EOF`,value:``,line:e,col:t};let n=this._ch();switch(n){case`[`:return this._advance(),{type:`LBRACKET`,value:`[`,line:e,col:t};case`]`:return this._advance(),{type:`RBRACKET`,value:`]`,line:e,col:t};case`{`:return this._advance(),{type:`LBRACE`,value:`{`,line:e,col:t};case`}`:return this._advance(),{type:`RBRACE`,value:`}`,line:e,col:t};case`(`:return this._advance(),{type:`LPAREN`,value:`(`,line:e,col:t};case`)`:return this._advance(),{type:`RPAREN`,value:`)`,line:e,col:t};case`:`:return this._advance(),{type:`COLON`,value:`:`,line:e,col:t};case`,`:return this._advance(),{type:`COMMA`,value:`,`,line:e,col:t};case`<`:if((this.input[this.pos+1]??``)===`<`)return this._advance(),this._advance(),{type:`LT_LT`,value:`<<`,line:e,col:t};this._fail(`unexpected character '<'`,e,t);case`>`:if((this.input[this.pos+1]??``)===`>`)return this._advance(),this._advance(),{type:`GT_GT`,value:`>>`,line:e,col:t};this._fail(`unexpected character '>'`,e,t);case`+`:{let n=this.input.slice(this.pos+1);if(n.startsWith(`Infinity`)){let r=n[8]??``,i=r===`_`&&/[0-3i]/.test(n[9]??``)&&!/[a-zA-Z0-9_]/.test(n[10]??``);if(!/[a-zA-Z0-9_]/.test(r)||i){this._advance();for(let e=0;e<8;e++)this._advance();let n=`Infinity`;return i&&(n+=this._advance()+this._advance()),{type:`FLOAT`,value:n,line:e,col:t}}}let r=n[0]??``;return r>=`0`&&r<=`9`||r===`.`?(this._advance(),this._readNumber(e,t)):(this._advance(),{type:`PLUS`,value:`+`,line:e,col:t})}case"`":return{type:`RAWSTRING`,value:this._readRawStringContent(),line:e,col:t};case`"`:{let n=this._readStringContent(`"`);return n===``&&this._ch()===`_`?(this._advance(),{type:`EMPTY_INDEF_TEXT`,value:``,line:e,col:t}):{type:`TSTR`,value:n,line:e,col:t}}case`'`:{if((this.input[this.pos+1]??``)===`'`&&(this.input[this.pos+2]??``)===`_`)return this._advance(),this._advance(),this._advance(),{type:`EMPTY_INDEF_BYTES`,value:``,line:e,col:t};let n=this._readStringContent(`'`),r=new TextEncoder().encode(n);return{type:`SQSTR`,value:Array.from(r,e=>e.toString(16).padStart(2,`0`)).join(``),line:e,col:t}}}if(n===`-`){let n=this.input.slice(this.pos+1);if(n.startsWith(`Infinity`)){let r=n[8]??``,i=r===`_`&&/[0-3i]/.test(n[9]??``)&&!/[a-zA-Z0-9_]/.test(n[10]??``);if(!/[a-zA-Z0-9_]/.test(r)||i){this._advance();for(let e=0;e<8;e++)this._advance();let n=`-Infinity`;return i&&(n+=this._advance()+this._advance()),{type:`FLOAT`,value:n,line:e,col:t}}}return this._readNumber(e,t)}if(n===`+`){let n=this.input.slice(this.pos+1);if(n.startsWith(`Infinity`)){let r=n[8]??``,i=r===`_`&&/[0-3i]/.test(n[9]??``)&&!/[a-zA-Z0-9_]/.test(n[10]??``);if(!/[a-zA-Z0-9_]/.test(r)||i){this._advance();for(let e=0;e<8;e++)this._advance();let n=`Infinity`;return i&&(n+=this._advance()+this._advance()),{type:`FLOAT`,value:n,line:e,col:t}}}return this._advance(),this._readNumber(e,t)}if(n>=`0`&&n<=`9`||n===`.`&&/[0-9]/.test(this.input[this.pos+1]??``))return this._readNumber(e,t);if(/[a-zA-Z_]/.test(n))return this._readIdent(e,t);if(n===`.`){if((this.input[this.pos+1]??``)===`.`&&(this.input[this.pos+2]??``)===`.`){for(this._advance(),this._advance(),this._advance();!this._eof()&&this._ch()===`.`;)this._advance();return{type:`ELLIPSIS`,value:`...`,line:e,col:t}}this._fail(`unexpected character '.'`,e,t)}this._fail(`unexpected character ${JSON.stringify(n)}`,e,t)}_readNumber(e,t){let n=``;if(this._ch()===`-`&&(n+=this._advance()),this._ch()===`0`){let r=this.input[this.pos+1]??``;if(r===`x`||r===`X`){n+=this._advance()+this._advance();let r=n.length;for(;!this._eof()&&/[0-9a-fA-F]/.test(this._ch());)n+=this._advance();let i=n.length>r,a=!1,o=!1;if(!this._eof()&&this._ch()===`.`){a=!0,n+=this._advance();let e=n.length;for(;!this._eof()&&/[0-9a-fA-F]/.test(this._ch());)n+=this._advance();o=n.length>e}if(!this._eof()&&(this._ch()===`p`||this._ch()===`P`)){a=!0,!i&&!o&&this._fail(`hex float has no mantissa digits: ${n}`,e,t),n+=this._advance(),!this._eof()&&(this._ch()===`+`||this._ch()===`-`)&&(n+=this._advance());let r=n.length;for(;!this._eof()&&this._ch()>=`0`&&this._ch()<=`9`;)n+=this._advance();n.length===r&&this._fail(`hex float missing exponent digits: ${n}`,e,t)}else a&&this._fail(`hex float missing 'p' exponent: ${n}`,e,t);if(a){if(this._ch()===`_`){let e=this.input[this.pos+1]??``,t=this.input[this.pos+2]??``;(e===`0`||e===`1`||e===`2`||e===`3`||e===`i`)&&!/[0-9a-zA-Z_]/.test(t)&&(n+=this._advance()+this._advance())}return{type:`FLOAT`,value:n,line:e,col:t}}return{type:`INTEGER`,value:n,line:e,col:t}}if(r===`o`||r===`O`){for(n+=this._advance()+this._advance();!this._eof()&&this._ch()>=`0`&&this._ch()<=`7`;)n+=this._advance();return{type:`INTEGER`,value:n,line:e,col:t}}if(r===`b`||r===`B`){for(n+=this._advance()+this._advance();!this._eof()&&(this._ch()===`0`||this._ch()===`1`);)n+=this._advance();return{type:`INTEGER`,value:n,line:e,col:t}}}for(;!this._eof()&&this._ch()>=`0`&&this._ch()<=`9`;)n+=this._advance();let r=!1;if(!this._eof()&&this._ch()===`.`)for(r=!0,n+=this._advance();!this._eof()&&this._ch()>=`0`&&this._ch()<=`9`;)n+=this._advance();if(!this._eof()&&(this._ch()===`e`||this._ch()===`E`)){r=!0,n+=this._advance(),!this._eof()&&(this._ch()===`+`||this._ch()===`-`)&&(n+=this._advance());let i=n.length;for(;!this._eof()&&this._ch()>=`0`&&this._ch()<=`9`;)n+=this._advance();n.length===i&&this._fail(`float exponent has no digits: ${JSON.stringify(n)}`,e,t)}if(this._ch()===`_`){let e=this.input[this.pos+1]??``,t=this.input[this.pos+2]??``;(e===`0`||e===`1`||e===`2`||e===`3`||e===`i`)&&!/[0-9a-zA-Z_]/.test(t)&&(n+=this._advance()+this._advance())}return{type:r?`FLOAT`:`INTEGER`,value:n,line:e,col:t}}_readIdent(e,t){let n=``;for(;!this._eof()&&/[a-zA-Z0-9_]/.test(this._ch());)n+=this._advance();switch(n){case`true`:return{type:`TRUE`,value:n,line:e,col:t};case`false`:return{type:`FALSE`,value:n,line:e,col:t};case`null`:return{type:`NULL`,value:n,line:e,col:t};case`undefined`:return{type:`UNDEFINED`,value:n,line:e,col:t};case`NaN`:case`NaN_0`:case`NaN_1`:case`NaN_2`:case`NaN_3`:case`NaN_i`:case`Infinity`:case`Infinity_0`:case`Infinity_1`:case`Infinity_2`:case`Infinity_3`:case`Infinity_i`:return{type:`FLOAT`,value:n,line:e,col:t};case`simple`:return{type:`SIMPLE`,value:n,line:e,col:t};case`_`:return{type:`UNDERSCORE`,value:`_`,line:e,col:t};case`_0`:return{type:`ENCODING_INDICATOR`,value:`0`,line:e,col:t};case`_1`:return{type:`ENCODING_INDICATOR`,value:`1`,line:e,col:t};case`_2`:return{type:`ENCODING_INDICATOR`,value:`2`,line:e,col:t};case`_3`:return{type:`ENCODING_INDICATOR`,value:`3`,line:e,col:t};case`_i`:return{type:`ENCODING_INDICATOR`,value:`i`,line:e,col:t}}let r=n[0]??``,i=r>=`a`&&r<=`z`;if(i||r>=`A`&&r<=`Z`){let r=n.slice(1);if(i?/^[a-z0-9]*$/.test(r):/^[A-Z0-9]*$/.test(r)){for(;!this._eof();){let e=this._ch();if(!(i?e>=`a`&&e<=`z`||e>=`0`&&e<=`9`||e===`-`:e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`-`))break;n+=this._advance()}let r=this._ch();if(r===`"`&&this._fail(`"${n}" prefix requires single quotes or backticks, not double quotes`,e,t),r===`'`)switch(n){case`h`:{let{value:n,elided:i}=this._readHexByteContentElisionAware(r);return{type:i?`BYTES_HEX_ELIDED`:`BYTES_HEX`,value:n,line:e,col:t}}case`b64`:return{type:`BYTES_B64`,value:this._readByteContent(r),line:e,col:t};case`b32`:return{type:`BYTES_B32`,value:this._readB32Content(r),line:e,col:t};case`h32`:return{type:`BYTES_H32`,value:this._readB32Content(r),line:e,col:t};default:return{type:`APP_STRING`,appPrefix:n,value:this._readStringContent(r),line:e,col:t}}if(r==="`"){let r=this._readRawStringContent();switch(n){case`h`:{let{value:n,elided:i}=this._processRawHexContent(r,e,t);return{type:i?`BYTES_HEX_ELIDED`:`BYTES_HEX`,value:n,line:e,col:t}}case`b64`:return{type:`BYTES_B64`,value:this._processRawB64Content(r,e,t),line:e,col:t};case`b32`:return{type:`BYTES_B32`,value:this._processRawB32Content(r,e,t),line:e,col:t};case`h32`:return{type:`BYTES_H32`,value:this._processRawB32Content(r,e,t),line:e,col:t};default:return{type:`APP_STRING`,appPrefix:n,value:r,line:e,col:t}}}if(r===`<`&&(this.input[this.pos+1]??``)===`<`)return this._advance(),this._advance(),{type:`APP_SEQUENCE`,appPrefix:n,value:``,line:e,col:t}}}this._fail(`unknown identifier ${JSON.stringify(n)}`,e,t)}},Re=class extends t{indefiniteLength=!0;chunks;constructor(e){super(),this.chunks=e}_toCBOR(e){let t=[new Uint8Array([127])];for(let n of this.chunks)t.push(n._toCBOR(e));return t.push(new Uint8Array([255])),c(t)}_toEDN(e,t){return this.chunks.length===0?`""_`:`(_ ${this.chunks.map(t=>t._toEDN(e,0)).join(`, `)})`}_toHexDump(e,t){let n=e=>e.toString(16).toUpperCase().padStart(2,`0`),r=[{depth:e,hex:n(127),comment:`Start indefinite-length text string`}];for(let n of this.chunks)r.push(...n._toHexDump(e+1,t));return r.push({depth:e,hex:n(255),comment:`"break"`}),r}_toJS(e){return this.chunks.map(e=>e.value).join(``)}},C=class extends t{items;indefiniteLength;encodingWidth;constructor(e,t){super(),this.items=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}_toCBOR(e){if(this.indefiniteLength){let t=[new Uint8Array([159])];for(let n of this.items)t.push(n._toCBOR(e));return t.push(new Uint8Array([255])),c(t)}let t=[s(4,BigInt(this.items.length),this.encodingWidth)];for(let n of this.items)t.push(n._toCBOR(e));return c(t)}_toEDN(e,t){let n=ie(e),r=e?.preserveComments,i=r&&(oe(this)||this.items.some(ae));n===null&&i&&(n=` `);let{inlineSep:a,multilineSep:o,trailSep:s}=ue(e,n===null),c=!this.indefiniteLength&&this.encodingWidth!==void 0?`_${this.encodingWidth} `:``;if(n===null||this.items.length===0&&!i){let n=this.items.map(n=>n._toEDN(e,t+1)).join(a);return this.indefiniteLength?this.items.length===0?`[_ ]`:`[_ ${n}]`:`[${c}${n}]`}let l=b(n,t+1),u=b(n,t),d=this.indefiniteLength?`[_ `:`[${c}`,f=[];for(let n=0;n<this.items.length;n++){let i=this.items[n];r&&f.push(...se(i,l));let a=n<this.items.length-1?o:s;f.push(`${l}${i._toEDN(e,t+1)}${a}${r?ce(i):``}`)}return r&&f.push(...le(this,l)),`${d}\n${f.join(`
25
+ `)}\n${u}]`}_toHexDump(e,t){let n=e=>e.toString(16).toUpperCase().padStart(2,`0`),r=e=>Array.from(e,e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `);if(this.indefiniteLength){let r=[{depth:e,hex:n(159),comment:`Start indefinite-length array`}];for(let n of this.items)r.push(...n._toHexDump(e+1,t));return r.push({depth:e,hex:n(255),comment:`"break"`}),r}let i=[{depth:e,hex:r(s(4,BigInt(this.items.length),this.encodingWidth)),comment:`Array of length ${this.items.length}`}];for(let n of this.items)i.push(...n._toHexDump(e+1,t));return i}_toJS(t){let n=t?.reviver;if(!n)return this.items.map(e=>e._toJS(t));let r=t?{...t,reviver:void 0}:void 0,i=this.items.map(e=>e._toJS(r)),a=0;for(let r=0;r<this.items.length;r++){let o=r-a,s=this.items[r]._toJS(t),c=n.call(i,String(r),s);c===e||t?.undefinedOmits&&c===void 0?(i.splice(o,1),a++):i[o]=c}return i}},ze=new DataView(new ArrayBuffer(8));function Be(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 Ve(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`;ze.setFloat64(0,n,!1);let r=ze.getUint32(0,!1),i=ze.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 w=class extends t{value;precision;constructor(e,t){super(),this.value=e,this.precision=t?.precision}_toCBOR(e){let t=this.precision??f(this.value);if(t===`half`){let e=new Uint8Array(3);return e[0]=249,o(new DataView(e.buffer),1,this.value,!1),e}if(t===`single`){let e=new Uint8Array(5);return e[0]=250,new DataView(e.buffer).setFloat32(1,this.value,!1),e}let n=new Uint8Array(9);return n[0]=251,new DataView(n.buffer).setFloat64(1,this.value,!1),n}_toEDN(e,t){let n=f(this.value);return(e?.floatFormat===`hex`?Ve(this.value):Te(this.value))+Ee(this.value,this.precision,n)}_toJS(e){return this.value}};function T(e){if(Number.isInteger(e))return new Date(e*1e3).toISOString().replace(/\.000Z$/,`Z`);let t=Math.round(e*1e3);if(t/1e3===e)return new Date(t).toISOString().replace(/\.000Z$/,`Z`);let n=Math.floor(e),r=e-n,i=new Date(n*1e3).toISOString().replace(/\.\d+Z$/,``),a=r.toString(),o=a.indexOf(`.`),s=o>=0?a.slice(o+1):`0`;for(;s.length<3;)s+=`0`;return`${i}.${s}Z`}function He(e){if(e.length!==1)throw SyntaxError(`dt<<...>>: expected exactly one item`);let t=e[0];if(t instanceof $)return t.value;if(t instanceof x)return new TextDecoder(`utf-8`,{fatal:!0}).decode(t.value);throw SyntaxError(`dt<<...>>: expected a text string or byte string`)}function Ue(e){let t=e.match(/^(.+T\d{2}:\d{2}:\d{2})(\.\d+)(Z|[+-]\d{2}:\d{2})$/i),n,r;t?(n=t[1]+t[3],r=parseFloat(`0`+t[2])):(n=e,r=void 0);let i=Date.parse(n);if(isNaN(i))throw SyntaxError(`dt: invalid RFC 3339 date-time: ${JSON.stringify(e)}`);if(r===void 0){let e=i/1e3;return e>=0?new Ge(BigInt(e)):new Ke(BigInt(e))}return new qe(i/1e3+r)}var We=1n,Ge=class extends p{constructor(e,t){super(e,t)}_toEDN(e,t){return e?.appStrings===!1?super._toEDN(e,t):`dt'${T(Number(this.value))}'`}},Ke=class extends S{constructor(e,t){super(e,t)}_toEDN(e,t){return e?.appStrings===!1?super._toEDN(e,t):`dt'${T(Number(this.value))}'`}},qe=class extends w{constructor(e,t){super(e,t)}_toEDN(e,t){return e?.appStrings===!1?super._toEDN(e,t):`dt'${T(this.value)}'`}},Je=class extends y{constructor(e,t){super(We,Ue(e),t)}_toEDN(e,t){if(e?.appStrings===!1)return super._toEDN(e,t);let n=this.content;return`DT'${T(n instanceof w?n.value:Number(n.value))}'`}},Ye=class extends Je{constructor(e,t){super(e,t)}_toJS(e){let t=this.content,n=t instanceof w?t.value*1e3:Number(t.value)*1e3;return new Date(n)}};function Xe(e){let t=e?.jsDate??!1;function n(e){return t?new Ye(e):new Je(e)}let r={appStringPrefixes:[`dt`,`DT`],tagNumbers:[We],parseAppString(e,t){return e===`DT`?n(t):Ue(t)},parseAppSequence(e,t){let r=He(t);return e===`DT`?n(r):Ue(r)},parseTag(e,t){if(e!==1n)return;let r;if(t instanceof p)r=Number(t.value);else if(t instanceof S)r=Number(t.value);else if(t instanceof w)r=t.value;else return;return n(T(r))}};return t&&(r.fromJS=(e,t)=>{if(e instanceof Date)return new Ye(T(e.getTime()/1e3))},r.isJSType=e=>e instanceof Date),r}var Ze=Xe(),Qe=Xe({jsDate:!0});function $e(e){let t=e.split(`.`);if(t.length!==4)throw SyntaxError(`ip: invalid IPv4 address: ${JSON.stringify(e)}`);let n=new Uint8Array(4);for(let e=0;e<4;e++){let r=t[e];if(!/^\d+$/.test(r)||r.length>1&&r[0]===`0`)throw SyntaxError(`ip: invalid IPv4 octet: ${JSON.stringify(r)}`);let i=parseInt(r,10);if(i>255)throw SyntaxError(`ip: IPv4 octet out of range: ${i}`);n[e]=i}return n}function et(e){let t=new Uint8Array(16);if(e===`::`)return t;let n=e,r=null,i=e.match(/^(.*):(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/);i&&(n=i[1],n.endsWith(`:`)&&(n+=`:`),r=$e(i[2]));let a=n.split(`::`);if(a.length>2)throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);let o=a.length===2,s=a[0]?a[0].split(`:`):[],c=o&&a[1]?a[1].split(`:`):[],l=r?6:8;if(!o&&s.length!==l||o&&s.length+c.length>=l)throw SyntaxError(`ip: invalid IPv6 address: ${JSON.stringify(e)}`);let u=l-s.length-c.length,d=[...s,...Array(u).fill(`0`),...c],f=0;for(let e of d){if(!/^[0-9a-fA-F]{1,4}$/.test(e))throw SyntaxError(`ip: invalid IPv6 group: ${JSON.stringify(e)}`);let n=parseInt(e,16);t[f++]=n>>8&255,t[f++]=n&255}return r&&t.set(r,12),t}function tt(e){return Array.from(e).join(`.`)}function nt(e){let t=e.slice(0,10).every(e=>e===0)&&e[10]===255&&e[11]===255?tt(e.slice(12)):null,n=t?6:8,r=[];for(let t=0;t<n*2;t+=2)r.push(e[t]<<8|e[t+1]);let i=-1,a=0,o=0;for(;o<n;)if(r[o]===0){let e=o+1;for(;e<n&&r[e]===0;)e++;e-o>a&&(i=o,a=e-o),o=e}else o++;a<2&&(i=-1);let s=e=>e.toString(16),c;return c=i===-1?r.map(s).join(`:`):`${r.slice(0,i).map(s).join(`:`)}::${r.slice(i+a).map(s).join(`:`)}`,t?`${c}:${t}`:c}var rt=`ip`,it=`IP`,at=52n,ot=54n;function st(e){if(e.length!==1)throw SyntaxError(`ip<<...>>: expected exactly one item`);let t=e[0];if(t instanceof $)return t.value;if(t instanceof x)return new TextDecoder(`utf-8`,{fatal:!0}).decode(t.value);throw SyntaxError(`ip<<...>>: expected a text string or byte string`)}function ct(e){return/^\d/.test(e)&&e.includes(`.`)&&!e.includes(`:`)?{bytes:$e(e),isV4:!0}:{bytes:et(e),isV4:!1}}function lt(e){if(e.length===4)return tt(e);if(e.length===16)return nt(e);throw SyntaxError(`ip: unexpected byte length: ${e.length}`)}function ut(e,t){let n=new Uint8Array(e.length);n.set(e);let r=Math.floor(t/8),i=t%8;i>0&&r<e.length&&(n[r]&=255<<8-i&255);for(let t=r+ +(i>0);t<e.length;t++)n[t]=0;let a=Math.ceil(t/8);for(;a>0&&n[a-1]===0;)a--;return n.slice(0,a)}function dt(e,t){let n=new Uint8Array(t);return n.set(e),n}var ft=class extends x{_toEDN(e,t){return e?.appStrings===!1?super._toEDN(e,t):`${rt}'${lt(this.value)}'`}},pt=class extends C{_isV4;constructor(e,t,n){super([new p(BigInt(e)),new x(t)]),this._isV4=n}_toEDN(e,t){if(e?.appStrings===!1)return super._toEDN(e,t);let n=Number(this.items[0].value),r=this.items[1].value;return`${rt}'${lt(dt(r,this._isV4?4:16))}/${n}'`}},mt=class extends y{constructor(e,t){super(e,t)}_toEDN(e,t){if(e?.appStrings===!1)return super._toEDN(e,t);let n=this.tag===at?4:16,r=this.content;if(r instanceof x)return`${it}'${lt(r.value)}'`;if(r instanceof C&&r.items.length===2&&r.items[0]instanceof p&&r.items[1]instanceof x){let e=Number(r.items[0].value);return`${it}'${lt(dt(r.items[1].value,n))}/${e}'`}return super._toEDN(e,t)}};function ht(e,t){let n=t.indexOf(`/`);if(n===-1){let{bytes:n,isV4:r}=ct(t);return e===it?new mt(r?at:ot,new x(n)):new ft(n)}let r=t.slice(0,n),i=t.slice(n+1);if(!/^\d+$/.test(i))throw SyntaxError(`ip: invalid prefix length: ${JSON.stringify(i)}`);let a=parseInt(i,10),{bytes:o,isV4:s}=ct(r),c=s?32:128;if(a>c)throw SyntaxError(`ip: prefix length ${a} exceeds maximum ${c} for ${s?`IPv4`:`IPv6`}`);let l=ut(o,a);return e===it?new mt(s?at:ot,new C([new p(BigInt(a)),new x(l)])):new pt(a,l,s)}var gt={appStringPrefixes:[rt,it],tagNumbers:[at,ot],parseAppString(e,t){return ht(e,t)},parseAppSequence(e,t){return ht(e,st(t))},parseTag(e,t){if(!(e!==at&&e!==ot)&&(t instanceof x||t instanceof C))return new mt(e,t)}},_t=18446744073709551615n,vt=-(_t+1n),yt={tagNumbers:[De,Oe],parseTag(e,t){if(t instanceof x){if(e===2n){let e=Me(t.value);return e>_t?new Ne(e):void 0}if(e===3n){let e=-1n-Me(t.value);return e<vt?new Pe(e):void 0}}}},E=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}},D=class e extends t{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);_toCBOR(e){return this.value<=23?new Uint8Array([224|this.value]):new Uint8Array([248,this.value])}_toEDN(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 E(this.value)}}},bt=`cri`,xt=`CRI`,St=99n,Ct=new Map([[`coap`,-1n],[`coaps`,-2n],[`http`,-3n],[`https`,-4n],[`urn`,-5n],[`did`,-6n],[`coap+tcp`,-7n],[`coaps+tcp`,-8n],[`coap+ws`,-25n],[`coaps+ws`,-26n]]),wt=new Map([...Ct.entries()].map(([e,t])=>[t,e]));function O(e){try{return decodeURIComponent(e)}catch{return e}}function Tt(e){return Array.from(new TextEncoder().encode(e),e=>`%${e.toString(16).toUpperCase().padStart(2,`0`)}`).join(``)}function k(e,t){let n=``;for(let r of e)n+=t(r)?r:Tt(r);return n}function Et(e){return/[A-Za-z0-9\-._~]/.test(e)}function Dt(e){return/[!$&'()*+,;=]/.test(e)}function Ot(e){return Et(e)||Dt(e)||e===`:`||e===`@`}function kt(e){return(Ot(e)||e===`/`||e===`?`)&&e!==`&`}function At(e){return Ot(e)||e===`/`||e===`?`}function jt(e){return Et(e)||Dt(e)||e===`:`}function Mt(e){return Et(e)||Dt(e)}function Nt(e){let t=[],n=e,r=n.indexOf(`@`);r>=0&&(t.push(D.FALSE),t.push(new $(O(n.slice(0,r)))),n=n.slice(r+1));let i,a=null;if(n.startsWith(`[`)){let e=n.indexOf(`]`);if(e<0)throw SyntaxError(`cri: unterminated IPv6 bracket in authority`);i=n.slice(1,e);let r=n.slice(e+1);if(r.startsWith(`:`))a=r.slice(1);else if(r.length>0)throw SyntaxError(`cri: unexpected characters after ']' in authority`);t.push(new x(et(i)))}else{let e=n.lastIndexOf(`:`);if(e>=0?(i=n.slice(0,e),a=n.slice(e+1)):i=n,i!==``)if(/^\d{1,3}(\.\d{1,3}){3}$/.test(i))t.push(new x($e(i)));else for(let e of i.toLowerCase().split(`.`))t.push(new $(e))}if(a!==null&&a!==``){if(!/^\d+$/.test(a))throw SyntaxError(`cri: invalid port: ${JSON.stringify(a)}`);let e=parseInt(a,10);if(e>65535)throw SyntaxError(`cri: port ${e} out of range`);t.push(new p(BigInt(e)))}return new C(t)}function Pt(e){let t=e.items,n=0,r=``;if(n<t.length&&t[n]instanceof D&&t[n].value===20){n++;let e=t[n++];r+=k(e.value,jt)+`@`}if(n>=t.length)return r;let i=t[n];if(i instanceof x){n++;let{length:e}=i.value;if(e===4)r+=tt(i.value);else if(e===16)r+=`[`+nt(i.value)+`]`;else throw Error(`cri: unexpected host-ip byte length: ${e}`);n<t.length&&t[n]instanceof $&&(r+=`%25${k(t[n++].value,Mt)}`)}else{let e=[];for(;n<t.length&&t[n]instanceof $;)e.push(k(t[n++].value,Mt));r+=e.join(`.`)}return n<t.length&&t[n]instanceof p&&(r+=`:`+t[n].value.toString()),r}function Ft(e){let t=e.slice(2),n=t.indexOf(`/`),r,i;return n>=0?(r=t.slice(0,n),i=t.slice(n+1).split(`/`).map(e=>new $(O(e)))):(r=t,i=[]),{authority:Nt(r),pathSegments:i}}function It(e){let t=e,n=null,r=t.indexOf(`#`);r>=0&&(n=O(t.slice(r+1)),t=t.slice(0,r));let i=null,a=t.indexOf(`?`);if(a>=0){let e=t.slice(a+1);t=t.slice(0,a),i=e.split(`&`).map(e=>new $(O(e)))}let o=[],s=/^([a-zA-Z][a-zA-Z0-9+.\-]*):([\s\S]*)$/.exec(t);if(s){let e=s[1].toLowerCase(),t=s[2],n=Ct.get(e);if(o.push(n===void 0?new $(e):new S(n)),t.startsWith(`//`)){let{authority:e,pathSegments:n}=Ft(t);o.push(e,new C(n))}else if(t.startsWith(`/`)){let e=t.slice(1).split(`/`).map(e=>new $(O(e)));o.push(D.NULL,new C(e))}else{let e=t.split(`/`).map(e=>new $(O(e)));o.push(D.TRUE,new C(e))}}else if(t.startsWith(`//`)){let{authority:e,pathSegments:n}=Ft(t);o.push(D.FALSE,e,new C(n))}else if(t.startsWith(`/`)){let e=t.slice(1).split(`/`).map(e=>new $(O(e)));o.push(D.TRUE,new C(e))}else if(t===``)o.push(new p(0n));else{let n=1n,r=t,i=!1;for(r.startsWith(`./`)&&(i=!0,r=r.slice(2));r.startsWith(`../`);)n++,r=r.slice(3);if(r===`..`?(n++,r=``):r===`.`&&(r=``),n===1n&&!i&&r!==``&&r.split(`/`)[0].includes(`:`))throw SyntaxError(`cri: invalid relative-path reference — first segment must not contain ':' without a './' prefix (RFC 3986 §3.3): ${JSON.stringify(e)}`);let a=r===``?[]:r.split(`/`).map(e=>new $(O(e)));o.push(new p(n),new C(a))}if(i!==null&&o.push(new C(i)),n!==null&&(i===null&&o.push(D.NULL),o.push(new $(n))),n!==null&&i===null&&o.splice(o.length-2,1),i===null&&n===null){let e=o[o.length-1];e instanceof C&&e.items.length===0&&o.pop()}return o.length===1&&o[0]instanceof p&&o[0].value===0n?[]:o}function Lt(e,t){let n=t,r=``;if(n<e.length){let t=e[n];if(t instanceof C){if(n++,t.items.length>0){let e=t.items.map(e=>{if(!(e instanceof $))throw Error(`cri: query item must be a text string`);return k(e.value,kt)});r+=`?`+e.join(`&`)}}else t instanceof D&&t.value===22&&n++}return n<e.length&&e[n]instanceof $&&(r+=`#`+k(e[n].value,At)),r}function Rt(e){return e.items.map(e=>{if(!(e instanceof $))throw Error(`cri: path segment must be a text string`);return k(e.value,Ot)})}function zt(e){if(e.length===0)return``;let t=0,n=e[t++];if(n instanceof S||n instanceof $){let r;if(n instanceof S){let e=wt.get(n.value);if(e===void 0)throw Error(`cri: unrecognised scheme-id ${n.value}`);r=e+`:`}else r=n.value+`:`;if(t>=e.length)return r;let i=e[t++],a=``,o=!1;if(i instanceof C)a=`//`+Pt(i),o=!0;else if(i instanceof D)if(i.value===22)o=!0;else if(i.value===21)o=!1;else throw Error(`cri: unexpected no-authority value: simple(${i.value})`);else throw Error(`cri: unexpected type for authority element`);let s=``;if(t<e.length&&e[t]instanceof C){let n=e[t++];n.items.length>0&&(s=(o?`/`:``)+Rt(n).join(`/`))}return r+a+s+Lt(e,t)}if(n instanceof D&&n.value===20){if(t>=e.length||!(e[t]instanceof C))throw Error(`cri: network-path reference requires an authority array`);let n=Pt(e[t++]),r=``;if(t<e.length&&e[t]instanceof C){let n=e[t++];n.items.length>0&&(r=`/`+Rt(n).join(`/`))}return`//`+n+r+Lt(e,t)}if(n instanceof D&&n.value===21){let n=`/`;if(t<e.length&&e[t]instanceof C){let r=e[t++];n=`/`+Rt(r).join(`/`)}return n+Lt(e,t)}if(n instanceof p){let r=n.value;if(r===0n)return Lt(e,t);let i=r===1n?``:`../`.repeat(Number(r)-1),a;if(t<e.length&&e[t]instanceof C){let n=e[t++];if(n.items.length>0){let e=Rt(n);a=(r===1n&&e[0].includes(`:`)?`./`:i)+e.join(`/`)}else a=i===``?`./`:i}else a=i===``?`./`:i;return a+Lt(e,t)}throw Error(`cri: unrecognised first element type in CRI array`)}var Bt=class extends C{_toEDN(e,t){if(e?.appStrings===!1)return super._toEDN(e,t);try{return`${bt}'${zt(this.items)}'`}catch{return super._toEDN(e,t)}}},Vt=class extends y{constructor(e){super(St,e)}_toEDN(e,t){if(e?.appStrings===!1)return super._toEDN(e,t);try{return`${xt}'${zt(this.content.items)}'`}catch{return super._toEDN(e,t)}}};function Ht(e){if(e.length!==1)throw SyntaxError(`cri<<...>>: expected exactly one item`);let t=e[0];if(t instanceof $)return t.value;if(t instanceof x)return new TextDecoder(`utf-8`,{fatal:!0}).decode(t.value);throw SyntaxError(`cri<<...>>: expected a text string or byte string`)}function Ut(e,t){let n=new Bt(It(t));return e===xt?new Vt(n):n}var Wt={appStringPrefixes:[bt,xt],tagNumbers:[St],parseAppString(e,t){return Ut(e,t)},parseAppSequence(e,t){return Ut(e,Ht(t))},parseTag(e,t){if(e===99n&&t instanceof C)return new Vt(new Bt(t.items,{indefiniteLength:t.indefiniteLength,encodingWidth:t.encodingWidth}))}};function Gt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function Kt(e,t=``){if(typeof e!=`number`){let n=t&&`"${t}" `;throw TypeError(`${n}expected number, got ${typeof e}`)}if(!Number.isSafeInteger(e)||e<0){let n=t&&`"${t}" `;throw RangeError(`${n}expected integer >= 0, got ${e}`)}}function qt(e,t,n=``){let r=Gt(e),i=e?.length,a=t!==void 0;if(!r||a&&i!==t){let o=n&&`"${n}" `,s=a?` of length ${t}`:``,c=r?`length=${i}`:`type=${typeof e}`,l=o+`expected Uint8Array`+s+`, got `+c;throw r?RangeError(l):TypeError(l)}return e}function Jt(e,t=!0){if(e.destroyed)throw Error(`Hash instance has been destroyed`);if(t&&e.finished)throw Error(`Hash#digest() has already been called`)}function Yt(e,t){qt(e,void 0,`digestInto() output`);let n=t.outputLen;if(e.length<n)throw RangeError(`"digestInto() output" expected to be of length >=`+n)}function Xt(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function A(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Zt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function j(e,t){return e<<32-t|e>>>t}function Qt(e,t){return e<<t|e>>>32-t>>>0}var $t=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function en(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function tn(e){for(let t=0;t<e.length;t++)e[t]=en(e[t]);return e}var nn=$t?e=>e:tn;typeof Uint8Array.from([]).toHex==`function`&&Uint8Array.fromHex;function M(e,t={}){let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}var N=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function rn(e,t,n){return e&t^~e&n}function an(e,t,n){return e&t^e&n^t&n}var on=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Zt(this.buffer)}update(e){Jt(this),qt(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length;for(let a=0;a<i;){let o=Math.min(r-this.pos,i-a);if(o===r){let t=Zt(e);for(;r<=i-a;a+=r)this.process(t,a);continue}n.set(e.subarray(a,a+o),this.pos),this.pos+=o,a+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Jt(this),Yt(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,A(this.buffer.subarray(a)),this.padOffset>r-a&&(this.process(n,0),a=0);for(let e=a;e<r;e++)t[e]=0;n.setBigUint64(r-8,BigInt(this.length*8),i),this.process(n,0);let o=Zt(e),s=this.outputLen;if(s%4)throw Error(`_sha2: outputLen must be aligned to 32bit`);let c=s/4,l=this.get();if(c>l.length)throw Error(`_sha2: outputLen bigger than state`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:t,buffer:n,length:r,finished:i,destroyed:a,pos:o}=this;return e.destroyed=a,e.finished=i,e.length=r,e.pos=o,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}},P=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),F=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),I=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),sn=BigInt(2**32-1),cn=BigInt(32);function ln(e,t=!1){return t?{h:Number(e&sn),l:Number(e>>cn&sn)}:{h:Number(e>>cn&sn)|0,l:Number(e&sn)|0}}function un(e,t=!1){let n=e.length,r=new Uint32Array(n),i=new Uint32Array(n);for(let a=0;a<n;a++){let{h:n,l:o}=ln(e[a],t);[r[a],i[a]]=[n,o]}return[r,i]}var dn=(e,t,n)=>e>>>n,fn=(e,t,n)=>e<<32-n|t>>>n,L=(e,t,n)=>e>>>n|t<<32-n,R=(e,t,n)=>e<<32-n|t>>>n,pn=(e,t,n)=>e<<64-n|t>>>n-32,mn=(e,t,n)=>e>>>n-32|t<<64-n,hn=(e,t,n)=>e<<n|t>>>32-n,gn=(e,t,n)=>t<<n|e>>>32-n,_n=(e,t,n)=>t<<n-32|e>>>64-n,vn=(e,t,n)=>e<<n-32|t>>>64-n;function z(e,t,n,r){let i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:i|0}}var yn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),bn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,xn=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Sn=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0,Cn=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0),wn=(e,t,n,r,i,a)=>t+n+r+i+a+(e/2**32|0)|0,Tn=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),B=new Uint32Array(64),En=class extends on{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}process(e,t){for(let n=0;n<16;n++,t+=4)B[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=B[e-15],n=B[e-2],r=j(t,7)^j(t,18)^t>>>3;B[e]=(j(n,17)^j(n,19)^n>>>10)+B[e-7]+r+B[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=j(o,6)^j(o,11)^j(o,25),u=l+t+rn(o,s,c)+Tn[e]+B[e]|0,d=(j(n,2)^j(n,13)^j(n,22))+an(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){A(B)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),A(this.buffer)}},Dn=class extends En{A=P[0]|0;B=P[1]|0;C=P[2]|0;D=P[3]|0;E=P[4]|0;F=P[5]|0;G=P[6]|0;H=P[7]|0;constructor(){super(32)}},On=un(`0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817`.split(`.`).map(e=>BigInt(e))),kn=On[0],An=On[1],V=new Uint32Array(80),H=new Uint32Array(80),jn=class extends on{constructor(e){super(128,e,16,!1)}get(){let{Ah:e,Al:t,Bh:n,Bl:r,Ch:i,Cl:a,Dh:o,Dl:s,Eh:c,El:l,Fh:u,Fl:d,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h]}set(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=a|0,this.Dh=o|0,this.Dl=s|0,this.Eh=c|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=f|0,this.Gl=p|0,this.Hh=m|0,this.Hl=h|0}process(e,t){for(let n=0;n<16;n++,t+=4)V[n]=e.getUint32(t),H[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=V[e-15]|0,n=H[e-15]|0,r=L(t,n,1)^L(t,n,8)^dn(t,n,7),i=R(t,n,1)^R(t,n,8)^fn(t,n,7),a=V[e-2]|0,o=H[e-2]|0,s=L(a,o,19)^pn(a,o,61)^dn(a,o,6),c=xn(i,R(a,o,19)^mn(a,o,61)^fn(a,o,6),H[e-7],H[e-16]);V[e]=Sn(c,r,s,V[e-7],V[e-16])|0,H[e]=c|0}let{Ah:n,Al:r,Bh:i,Bl:a,Ch:o,Cl:s,Dh:c,Dl:l,Eh:u,El:d,Fh:f,Fl:p,Gh:m,Gl:h,Hh:g,Hl:_}=this;for(let e=0;e<80;e++){let t=L(u,d,14)^L(u,d,18)^pn(u,d,41),ee=R(u,d,14)^R(u,d,18)^mn(u,d,41),te=u&f^~u&m,ne=d&p^~d&h,re=Cn(_,ee,ne,An[e],H[e]),v=wn(re,g,t,te,kn[e],V[e]),y=re|0,ie=L(n,r,28)^pn(n,r,34)^pn(n,r,39),b=R(n,r,28)^mn(n,r,34)^mn(n,r,39),ae=n&i^n&o^i&o,oe=r&a^r&s^a&s;g=m|0,_=h|0,m=f|0,h=p|0,f=u|0,p=d|0,{h:u,l:d}=z(c|0,l|0,v|0,y|0),c=o|0,l=s|0,o=i|0,s=a|0,i=n|0,a=r|0;let se=yn(y,b,oe);n=bn(se,v,ie,ae),r=se|0}({h:n,l:r}=z(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:a}=z(this.Bh|0,this.Bl|0,i|0,a|0),{h:o,l:s}=z(this.Ch|0,this.Cl|0,o|0,s|0),{h:c,l}=z(this.Dh|0,this.Dl|0,c|0,l|0),{h:u,l:d}=z(this.Eh|0,this.El|0,u|0,d|0),{h:f,l:p}=z(this.Fh|0,this.Fl|0,f|0,p|0),{h:m,l:h}=z(this.Gh|0,this.Gl|0,m|0,h|0),{h:g,l:_}=z(this.Hh|0,this.Hl|0,g|0,_|0),this.set(n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_)}roundClean(){A(V,H)}destroy(){this.destroyed=!0,A(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},Mn=class extends jn{Ah=I[0]|0;Al=I[1]|0;Bh=I[2]|0;Bl=I[3]|0;Ch=I[4]|0;Cl=I[5]|0;Dh=I[6]|0;Dl=I[7]|0;Eh=I[8]|0;El=I[9]|0;Fh=I[10]|0;Fl=I[11]|0;Gh=I[12]|0;Gl=I[13]|0;Hh=I[14]|0;Hl=I[15]|0;constructor(){super(64)}},Nn=class extends jn{Ah=F[0]|0;Al=F[1]|0;Bh=F[2]|0;Bl=F[3]|0;Ch=F[4]|0;Cl=F[5]|0;Dh=F[6]|0;Dl=F[7]|0;Eh=F[8]|0;El=F[9]|0;Fh=F[10]|0;Fl=F[11]|0;Gh=F[12]|0;Gl=F[13]|0;Hh=F[14]|0;Hl=F[15]|0;constructor(){super(48)}},U=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]),Pn=class extends jn{Ah=U[0]|0;Al=U[1]|0;Bh=U[2]|0;Bl=U[3]|0;Ch=U[4]|0;Cl=U[5]|0;Dh=U[6]|0;Dl=U[7]|0;Eh=U[8]|0;El=U[9]|0;Fh=U[10]|0;Fl=U[11]|0;Gh=U[12]|0;Gl=U[13]|0;Hh=U[14]|0;Hl=U[15]|0;constructor(){super(32)}},Fn=M(()=>new Dn,N(1)),In=M(()=>new Mn,N(3)),Ln=M(()=>new Nn,N(2)),Rn=M(()=>new Pn,N(6)),zn=BigInt(0),Bn=BigInt(1),Vn=BigInt(2),Hn=BigInt(7),Un=BigInt(256),Wn=BigInt(113),Gn=[],Kn=[],qn=[];for(let e=0,t=Bn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Gn.push(2*(5*r+n)),Kn.push((e+1)*(e+2)/2%64);let i=zn;for(let e=0;e<7;e++)t=(t<<Bn^(t>>Hn)*Wn)%Un,t&Vn&&(i^=Bn<<(Bn<<BigInt(e))-Bn);qn.push(i)}var Jn=un(qn,!0),Yn=Jn[0],Xn=Jn[1],Zn=(e,t,n)=>n>32?_n(e,t,n):hn(e,t,n),Qn=(e,t,n)=>n>32?vn(e,t,n):gn(e,t,n);function $n(e,t=24){if(Kt(t,`rounds`),t<1||t>24)throw Error(`"rounds" expected integer 1..24`);let n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,i=(t+2)%10,a=n[i],o=n[i+1],s=Zn(a,o,1)^n[r],c=Qn(a,o,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=s,e[t+n+1]^=c}let t=e[2],i=e[3];for(let n=0;n<24;n++){let r=Kn[n],a=Zn(t,i,r),o=Qn(t,i,r),s=Gn[n];t=e[s],i=e[s+1],e[s]=a,e[s+1]=o}for(let t=0;t<50;t+=10){let n=e[t],r=e[t+1],i=e[t+2],a=e[t+3];e[t]^=~e[t+2]&e[t+4],e[t+1]^=~e[t+3]&e[t+5],e[t+2]^=~e[t+4]&e[t+6],e[t+3]^=~e[t+5]&e[t+7],e[t+4]^=~e[t+6]&e[t+8],e[t+5]^=~e[t+7]&e[t+9],e[t+6]^=~e[t+8]&n,e[t+7]^=~e[t+9]&r,e[t+8]^=~n&i,e[t+9]^=~r&a}e[0]^=Yn[r],e[1]^=Xn[r]}A(n)}var er=class e{state;pos=0;posOut=0;finished=!1;state32;destroyed=!1;blockLen;suffix;outputLen;canXOF;enableXOF=!1;rounds;constructor(e,t,n,r=!1,i=24){if(this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.canXOF=r,this.rounds=i,Kt(n,`outputLen`),!(0<e&&e<200))throw Error(`only keccak-f1600 function is supported`);this.state=new Uint8Array(200),this.state32=Xt(this.state)}clone(){return this._cloneInto()}keccak(){nn(this.state32),$n(this.state32,this.rounds),nn(this.state32),this.posOut=0,this.pos=0}update(e){Jt(this),qt(e);let{blockLen:t,state:n}=this,r=e.length;for(let i=0;i<r;){let a=Math.min(t-this.pos,r-i);for(let t=0;t<a;t++)n[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,t&128&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Jt(this,!1),qt(e),this.finish();let t=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();let a=Math.min(n-this.posOut,i-r);e.set(t.subarray(this.posOut,this.posOut+a),r),this.posOut+=a,r+=a}return e}xofInto(e){if(!this.enableXOF)throw Error(`XOF is not possible for this instance`);return this.writeInto(e)}xof(e){return Kt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Yt(e,this),this.finished)throw Error(`digest() was already called`);this.writeInto(e.subarray(0,this.outputLen)),this.destroy()}digest(){let e=new Uint8Array(this.outputLen);return this.digestInto(e),e}destroy(){this.destroyed=!0,A(this.state)}_cloneInto(t){let{blockLen:n,suffix:r,outputLen:i,rounds:a,enableXOF:o}=this;return t||=new e(n,r,i,o,a),t.blockLen=n,t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=r,t.outputLen=i,t.enableXOF=o,t.canXOF=this.canXOF,t.destroyed=this.destroyed,t}},tr=(e,t,n,r={})=>M((r={})=>new er(t,e,r.dkLen===void 0?n:r.dkLen,!0),r),nr=tr(31,168,32,N(11)),rr=tr(31,136,64,N(12)),ir=Uint32Array.from([1732584193,4023233417,2562383102,271733878,3285377520]),W=new Uint32Array(80),ar=class extends on{A=ir[0]|0;B=ir[1]|0;C=ir[2]|0;D=ir[3]|0;E=ir[4]|0;constructor(){super(64,20,8,!1)}get(){let{A:e,B:t,C:n,D:r,E:i}=this;return[e,t,n,r,i]}set(e,t,n,r,i){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0}process(e,t){for(let n=0;n<16;n++,t+=4)W[n]=e.getUint32(t,!1);for(let e=16;e<80;e++)W[e]=Qt(W[e-3]^W[e-8]^W[e-14]^W[e-16],1);let{A:n,B:r,C:i,D:a,E:o}=this;for(let e=0;e<80;e++){let t,s;e<20?(t=rn(r,i,a),s=1518500249):e<40?(t=r^i^a,s=1859775393):e<60?(t=an(r,i,a),s=2400959708):(t=r^i^a,s=3395469782);let c=Qt(n,5)+t+o+s+W[e]|0;o=a,a=i,i=Qt(r,30),r=n,n=c}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,this.set(n,r,i,a,o)}roundClean(){A(W)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0),A(this.buffer)}},or=M(()=>new ar),sr=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),cr=Uint8Array.from(Array(16).fill(0).map((e,t)=>t)),lr=cr.map(e=>(9*e+5)%16),ur=(()=>{let e=[[cr],[lr]];for(let t=0;t<4;t++)for(let n of e)n.push(n[t].map(e=>sr[e]));return e})();ur[0],ur[1];var dr=new Map([[-14,or],[-15,e=>Fn(e).slice(0,8)],[-16,Fn],[-17,Rn],[-18,nr],[-43,Ln],[-44,In],[-45,rr]]),fr=new Map([[`SHA-1`,-14],[`SHA-256/64`,-15],[`SHA-256`,-16],[`SHA-512/256`,-17],[`SHAKE128`,-18],[`SHA-384`,-43],[`SHA-512`,-44],[`SHAKE256`,-45]]),pr=new Map([...fr.entries()].map(([e,t])=>[t,e])),mr=class extends x{_input;_algorithmId;constructor(e,t,n){super(e),this._input=t,this._algorithmId=n}_toEDN(e,t){if(e?.appStrings===!1)return super._toEDN(e,t);let n=this._algorithmId===-16;if(this._input instanceof $&&n)return`hash${Ce(this._input.value)}`;let r=this._input instanceof $?Ce(this._input.value):ye(this._input.value,e?.bstrEncoding??`hex`,e?.sqstr);return n?`hash<<${r}>>`:`hash<<${r}, ${pr.has(this._algorithmId)?`"${pr.get(this._algorithmId)}"`:String(this._algorithmId)}>>`}};function hr(e){if(e instanceof p||e instanceof S)return Number(e.value);if(e instanceof $){let t=fr.get(e.value);if(t===void 0)throw SyntaxError(`hash: unknown algorithm name: ${JSON.stringify(e.value)}`);return t}throw SyntaxError(`hash: algorithm must be an integer or text string`)}function gr(e,t){let n=e instanceof $?new TextEncoder().encode(e.value):e.value,r=dr.get(t);if(!r)throw SyntaxError(`hash: unsupported COSE algorithm ID ${t}`);return new mr(r(n),e,t)}var _r={appStringPrefixes:[`hash`],parseAppString(e,t){return gr(new $(t),-16)},parseAppSequence(e,t){if(t.length===0||t.length>2)throw SyntaxError(`hash<<...>>: expected 1 or 2 items, got ${t.length}`);let n=t[0];if(!(n instanceof $)&&!(n instanceof x))throw SyntaxError(`hash: first argument must be a text or byte string`);return gr(n,t.length===2?hr(t[1]):-16)}},vr=class extends t{items;constructor(e){super(),this.items=e}_content(e){return c(this.items.map(t=>t._toCBOR(e)))}_toCBOR(e){let t=this._content(e);return c([s(2,BigInt(t.length)),t])}_toEDN(e,t){if(this.items.length===0)return`<<>>`;let n=ie(e),{inlineSep:r,multilineSep:i,trailSep:a}=ue(e,n===null);if(n===null)return`<<${this.items.map(n=>n._toEDN(e,t+1)).join(r)}>>`;let o=b(n,t+1),s=b(n,t),c=this.items.map(n=>`${o}${n._toEDN(e,t+1)}`),l=c.length-1;return`<<\n${c.map((e,t)=>t<l?`${e}${i}`:`${e}${a}`).join(`
26
+ `)}\n${s}>>`}_toHexDump(e,t){let n=e=>Array.from(e,e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `),r=this._content().length,i=[{depth:e,hex:n(s(2,BigInt(r))),comment:`Embedded CBOR sequence, ${r} byte${r===1?``:`s`}`}];for(let n of this.items)i.push(...n._toHexDump(e+1,t));return i}_toJS(e){return this._content()}},yr=new TextDecoder(`utf-8`,{fatal:!0});function G(e){throw Error(`CBOR decode error: ${e}`)}function K(e,t,n){if(n<=23)return{value:BigInt(n),nextOffset:t};switch(n){case 24:return t+1>e.byteLength&&G(`unexpected end of input`),{value:BigInt(e.getUint8(t)),nextOffset:t+1};case 25:return t+2>e.byteLength&&G(`unexpected end of input`),{value:BigInt(e.getUint16(t,!1)),nextOffset:t+2};case 26:return t+4>e.byteLength&&G(`unexpected end of input`),{value:BigInt(e.getUint32(t,!1)),nextOffset:t+4};case 27:return t+8>e.byteLength&&G(`unexpected end of input`),{value:e.getBigUint64(t,!1),nextOffset:t+8};default:G(`reserved additional info value: ${n}`)}}function q(e,t,n){let r=t,i=br(e,t,n);return i.value.start=r,i.value.end=i.nextOffset,i}function br(e,t,n){t>=e.byteLength&&G(`unexpected end of input`);let r=e.getUint8(t++),i=r>>5,o=r&31;switch(i){case 0:{let{value:n,nextOffset:r}=K(e,t,o);return{value:new p(n),nextOffset:r}}case 1:{let{value:n,nextOffset:r}=K(e,t,o);return{value:new S(-1n-n),nextOffset:r}}case 2:{if(o===31){let r=[],i=t;for(;;){if(i>=e.byteLength&&G(`unexpected end of indefinite byte string`),e.getUint8(i)===255){i++;break}let t=q(e,i,n);t.value instanceof x||G(`indefinite-length byte string chunk must be a definite byte string`),r.push(t.value),i=t.nextOffset}return{value:new Fe(r),nextOffset:i}}let{value:r,nextOffset:i}=K(e,t,o),a=Number(r);return i+a>e.byteLength&&G(`byte string extends beyond input`),{value:new x(new Uint8Array(e.buffer,e.byteOffset+i,a).slice()),nextOffset:i+a}}case 3:{if(o===31){let r=[],i=t;for(;;){if(i>=e.byteLength&&G(`unexpected end of indefinite text string`),e.getUint8(i)===255){i++;break}let t=q(e,i,n);t.value instanceof $||G(`indefinite-length text string chunk must be a definite text string`),r.push(t.value),i=t.nextOffset}return{value:new Re(r),nextOffset:i}}let{value:r,nextOffset:i}=K(e,t,o),a=Number(r);i+a>e.byteLength&&G(`text string extends beyond input`);let s=new Uint8Array(e.buffer,e.byteOffset+i,a),c;try{c=yr.decode(s)}catch{G(`invalid UTF-8 sequence in text string`)}return{value:new $(c),nextOffset:i+a}}case 4:{if(o===31){let r=[],i=t;for(;;){if(i>=e.byteLength&&G(`unexpected end of indefinite array`),e.getUint8(i)===255){i++;break}let t=q(e,i,n);r.push(t.value),i=t.nextOffset}return{value:new C(r,{indefiniteLength:!0}),nextOffset:i}}let{value:r,nextOffset:i}=K(e,t,o),a=Number(r),s=[],c=i;for(let t=0;t<a;t++){let t=q(e,c,n);s.push(t.value),c=t.nextOffset}return{value:new C(s),nextOffset:c}}case 5:{if(o===31){let r=[],i=t;for(;;){if(i>=e.byteLength&&G(`unexpected end of indefinite map`),e.getUint8(i)===255){i++;break}let t=q(e,i,n);i=t.nextOffset;let a=q(e,i,n);i=a.nextOffset,r.push([t.value,a.value])}return{value:new Z(r,{indefiniteLength:!0}),nextOffset:i}}let{value:r,nextOffset:i}=K(e,t,o),a=Number(r),s=[],c=i;for(let t=0;t<a;t++){let t=q(e,c,n);c=t.nextOffset;let r=q(e,c,n);c=r.nextOffset,s.push([t.value,r.value])}return{value:new Z(s),nextOffset:c}}case 6:{o===31&&G(`tags cannot use indefinite-length encoding`);let{value:r,nextOffset:i}=K(e,t,o),a=q(e,i,n);for(let e of[...n?.extensions??[],...J])if(e.parseTag){let t=e.parseTag(r,a.value);if(t!==void 0)return{value:t,nextOffset:a.nextOffset}}return{value:new y(r,a.value),nextOffset:a.nextOffset}}case 7:if(o<=19)return{value:new D(o),nextOffset:t};if(o===20)return{value:D.FALSE,nextOffset:t};if(o===21)return{value:D.TRUE,nextOffset:t};if(o===22)return{value:D.NULL,nextOffset:t};if(o===23)return{value:D.UNDEFINED,nextOffset:t};if(o===24){t+1>e.byteLength&&G(`unexpected end of input`);let n=e.getUint8(t);return n<32&&G(`simple value ${n} must be encoded in initial byte (0–31 reserved for extended encoding)`),{value:new D(n),nextOffset:t+1}}return o===25?(t+2>e.byteLength&&G(`unexpected end of input`),{value:new w(a(e.getUint16(t,!1)),{precision:`half`}),nextOffset:t+2}):o===26?(t+4>e.byteLength&&G(`unexpected end of input`),{value:new w(e.getFloat32(t,!1),{precision:`single`}),nextOffset:t+4}):o===27?(t+8>e.byteLength&&G(`unexpected end of input`),{value:new w(e.getFloat64(t,!1),{precision:`double`}),nextOffset:t+8}):(o<31&&G(`reserved additional info value in major type 7: ${o}`),G(`unexpected break code outside indefinite-length item`))}return G(`unknown major type: ${i}`)}function xr(e){if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw TypeError(`expected ArrayBufferView or ArrayBufferLike`)}function Sr(e,t){let n=xr(e),r=new DataView(n.buffer,n.byteOffset,n.byteLength),i=t?.offset??0;if(!Number.isInteger(i)||i<0||i>r.byteLength)throw RangeError(`CBOR decode offset must be an integer between 0 and ${r.byteLength}`);let{value:a,nextOffset:o}=q(r,i,t);return!t?.allowTrailing&&o!==r.byteLength&&G(`${r.byteLength-o} trailing byte(s) after end of CBOR item`),a}var Cr=24n,J=[Ze,gt,yt,Wt,_r,{tagNumbers:[Cr],parseTag(e,t){if(e===24n&&t instanceof x)try{return new y(Cr,new vr([Sr(t.value)]))}catch{return}}}];function Y(t,n){if(n?.replacer){let{replacer:r,...i}=n,a=Er(t,r,i.extensions,i.undefinedOmits);return a===e?D.UNDEFINED:Y(a,Object.keys(i).length>0?i:void 0)}return wr(t,n,!0)}function wr(e,t,n){for(let n of[...t?.extensions??[],...J])if(n.fromJS){let r=n.fromJS(e,t??{});if(r!==void 0)return r}if(n&&typeof e==`object`&&e&&v.symbol in e){let n=e[v.symbol],r=wr(e,t,!1);for(let e of[...t?.extensions??[],...J])if(e.parseTag){let t=e.parseTag(n,r);if(t!==void 0)return t}return new y(n,r)}if(e instanceof v.Null)return D.NULL;if(e instanceof v.Undefined)return D.UNDEFINED;if(e instanceof E)return new D(e.value);if(e===null)return D.NULL;if(e===void 0)return D.UNDEFINED;if(e===!0)return D.TRUE;if(e===!1)return D.FALSE;if(typeof e==`bigint`)return e>18446744073709551615n?new Ne(e):e<-18446744073709551616n?new Pe(e):e>=0n?new p(e):new S(e);if(typeof e==`number`)return(t?.encodeIntegerAs??`int`)===`int`&&Number.isInteger(e)&&!Object.is(e,-0)?e>=0?new p(BigInt(e)):new S(BigInt(e)):new w(e);if(typeof e==`string`)return new $(e);if(e instanceof Number||e instanceof Boolean||e instanceof String||Object.prototype.toString.call(e)===`[object BigInt]`)return wr(e.valueOf(),t,!1);if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)return new x(new Uint8Array(e));if(ArrayBuffer.isView(e))return e instanceof Uint8Array&&t?.uint8ArrayAs===`array`?new C(Array.from(e,e=>new p(BigInt(e)))):new x(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));if(e instanceof X)return new Z([...e].map(([e,n])=>[Y(e,t),Y(n,t)]));if(Array.isArray(e))return new C(e.map(e=>Y(e,t)));if(typeof e==`object`){let n=[];for(let[r,i]of Object.entries(e))n.push([new $(r),Y(i,t)]);return new Z(n)}throw TypeError(`fromJS: unsupported value type: ${typeof e}`)}function Tr(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 v.Null||e instanceof v.Undefined||e instanceof E}function Er(t,n,r,i){let a=[...r??[],...J];function o(t){return t===e||i===!0&&t===void 0}if(Array.isArray(n)){let e=n.map(String);function s(t){if(typeof t!=`object`||!t)return t;if(t instanceof X)return X.from(t,([e,t])=>[e,s(t)]);if(Array.isArray(t))return t.map(s);if(v.symbol in t||Tr(t)||a.some(e=>e.isJSType?.(t)))return t;let n=Object.getPrototypeOf(t);if(n===Object.prototype||n===null){let e=t.toJSON;if(typeof e==`function`)return s(e.call(t))}let r={};for(let n of e)Object.prototype.hasOwnProperty.call(t,n)&&(r[n]=s(t[n]));return r}return s(t)}let c=n;function l(e,t,n){if(typeof e==`object`&&e&&!(e instanceof X)){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(v.symbol in e)return e;if(e instanceof X){let t=new X;for(let[n,r]of e){let i=l(r,n,e);o(i)||t.push([n,i])}return t}if(Array.isArray(e))return e.map((t,n)=>{let r=l(t,String(n),e);return o(r)?null:r});if(Tr(e)||a.some(t=>t.isJSType?.(e)))return e;let t={};for(let n of Object.keys(e)){let r=l(e[n],n,e);o(r)||(t[n]=r)}return t}return e}return l(t,``,{"":t})}var X=class extends Array{toJSON(){let e={};for(let[t,n]of this){let r=typeof t==`string`?t:Y(t).toEDN();r===`__proto__`?Object.defineProperty(e,r,{value:n,writable:!0,enumerable:!0,configurable:!0}):e[r]=n}return e}},Z=class extends t{entries;indefiniteLength;encodingWidth;constructor(e,t){super(),this.entries=e,this.indefiniteLength=t?.indefiniteLength??!1,this.encodingWidth=t?.encodingWidth}_toCBOR(e){if(this.indefiniteLength){let t=[new Uint8Array([191])];for(let[n,r]of this.entries)t.push(n._toCBOR(e),r._toCBOR(e));return t.push(new Uint8Array([255])),c(t)}let t=[s(5,BigInt(this.entries.length),this.encodingWidth)];for(let[n,r]of this.entries)t.push(n._toCBOR(e),r._toCBOR(e));return c(t)}_toEDN(e,t){let n=ie(e),r=e?.preserveComments,i=r&&(oe(this)||this.entries.some(([e,t])=>ae(e)||ae(t)));n===null&&i&&(n=` `);let{inlineSep:a,multilineSep:o,trailSep:s,colSep:c}=ue(e,n===null),l=!this.indefiniteLength&&this.encodingWidth!==void 0?`_${this.encodingWidth} `:``,u=this.indefiniteLength?`{_ `:`{${l}`;if(n===null||this.entries.length===0&&!i){let n=this.entries.map(([n,r])=>`${n._toEDN(e,t+1)}${c}${r._toEDN(e,t+1)}`).join(a);return this.indefiniteLength?this.entries.length===0?`{_ }`:`{_ ${n}}`:`{${l}${n}}`}let d=b(n,t+1),f=b(n,t),p=[];for(let n=0;n<this.entries.length;n++){let[i,a]=this.entries[n];r&&p.push(...se(i,d));let l=n<this.entries.length-1?o:s,u=r?Dr([...i.comments?.trailing??[],...a.comments?.leading??[],...a.comments?.trailing??[]]):``;p.push(`${d}${i._toEDN(e,t+1)}${c}${a._toEDN(e,t+1)}${l}${u}`)}return r&&p.push(...le(this,d)),`${u}\n${p.join(`
27
+ `)}\n${f}}`}_toHexDump(e,t){let n=e=>e.toString(16).toUpperCase().padStart(2,`0`),r=e=>Array.from(e,e=>e.toString(16).toUpperCase().padStart(2,`0`)).join(` `);if(this.indefiniteLength){let r=[{depth:e,hex:n(191),comment:`Start indefinite-length map`}];for(let[n,i]of this.entries)r.push(...n._toHexDump(e+1,t)),r.push(...i._toHexDump(e+1,t));return r.push({depth:e,hex:n(255),comment:`"break"`}),r}let i=[{depth:e,hex:r(s(5,BigInt(this.entries.length),this.encodingWidth)),comment:`Map of length ${this.entries.length}`}];for(let[n,r]of this.entries)i.push(...n._toHexDump(e+1,t)),i.push(...r._toHexDump(e+1,t));return i}_toJS(t){let n=t?.reviver,r=()=>{let r=X.from(this.entries,([e,n])=>[e._toJS(t),n._toJS(t)]);if(!n)return r;let i=t?.undefinedOmits;for(let t=0;t<r.length;t++){let[a,o]=r[t],s=n.call(r,a,o);s===e||i&&s===void 0?r.splice(t--,1):r[t]=[a,s]}return r};return t?.mapAs===`entries`?r():t?.mapAs===`object`||this.entries.every(([e])=>e instanceof $)?(()=>{let r=t?{...t,reviver:void 0}:void 0,i={};for(let[e,t]of this.entries){let n=e instanceof $?e.value:e.toEDN(),a=t._toJS(r);n===`__proto__`?Object.defineProperty(i,n,{value:a,writable:!0,enumerable:!0,configurable:!0}):i[n]=a}if(!n)return i;let a=new Map;for(let e=0;e<this.entries.length;e++){let[t]=this.entries[e];a.set(t instanceof $?t.value:t.toEDN(),e)}for(let r=0;r<this.entries.length;r++){let[o,s]=this.entries[r],c=o instanceof $?o.value:o.toEDN();if(a.get(c)!==r)continue;let l=s._toJS(t),u=n.call(i,c,l);u===e||t?.undefinedOmits&&u===void 0?delete i[c]:c===`__proto__`?Object.defineProperty(i,c,{value:u,writable:!0,enumerable:!0,configurable:!0}):i[c]=u}return i})():r()}};function Dr(e){return e.length===0?``:` `+e.map(e=>e.text.trimEnd()).join(` `)}var Or=999n,kr=class extends y{constructor(e,t){let n=t.length===1&&t[0]instanceof $?t[0]:new C(t);super(Or,new C([new $(e),n]))}_toEDN(e,t){let n=this.content,r=n.items[0].value,i=n.items[1];return i instanceof $?`${r}${Ce(i.value)}`:`${r}<<${i.items.map(n=>n._toEDN(e,t)).join(`, `)}>>`}},Ar=888n,Q=class extends y{constructor(e){e===void 0?super(Ar,D.NULL):super(Ar,new C(e))}_toEDN(e,t){return this.content instanceof D?`...`:this.content instanceof C?this.content.items.map(n=>n._toEDN(e,t)).join(` + `):super._toEDN(e,t)}};function jr(e,t){let n=new Le(e,{offset:t?.offset}),r=new Wr(n,t?.extensions,t?.unresolvedExtension,t?.allowInvalidUtf8,t?.allowTrailing).parse();return t?.preserveComments&&Br(r,n.comments,e),r}function Mr(e){let t=e,n;if(/[_][0-3i]$/.test(e)){let r=e[e.length-1];n=r===`i`?`i`:Number(r),t=e.slice(0,-2)}return{numStr:t,encodingWidth:n}}function Nr(e){return e.startsWith(`-`)?-BigInt(e.slice(1)):BigInt(e)}function Pr(e){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};if(e.endsWith(`_i`)||e.endsWith(`_0`))throw SyntaxError(`EDN parse error: _0 and _i encoding indicators are not valid for floating-point values`);let t=e,n;return e.endsWith(`_1`)?(n=`half`,t=e.slice(0,-2)):e.endsWith(`_2`)?(n=`single`,t=e.slice(0,-2)):e.endsWith(`_3`)&&(n=`double`,t=e.slice(0,-2)),/^-?0[xX]/.test(t)?{value:Be(t),precision:n}:{value:parseFloat(t),precision:n}}function Fr(e){if(typeof Uint8Array.fromHex==`function`)return Uint8Array.fromHex(e);if(e.length%2!=0)throw SyntaxError(`hex string has odd length: ${e.length}`);let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t}var Ir=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,Lr=`0123456789ABCDEFGHIJKLMNOPQRSTUV`;function Rr(e,t){let n=e.replace(/=+$/,``).toUpperCase(),r=n.length%8;if(r===1||r===3||r===6)throw SyntaxError(`invalid base32 length: ${n.length} characters`);let i=new Uint8Array(128).fill(255);for(let e=0;e<t.length;e++)i[t.charCodeAt(e)]=e;let a=new Uint8Array(Math.floor(n.length*5/8)),o=0,s=0,c=0;for(let e of n){let t=e.charCodeAt(0),n=t<128?i[t]:255;if(n===255)throw SyntaxError(`invalid character in byte string: ${JSON.stringify(e)}`);o=o<<5|n,s+=5,s>=8&&(s-=8,a[c++]=o>>s&255)}if(s>0&&o&(1<<s)-1)throw SyntaxError(`non-zero trailing bits in base32 input`);return a}function zr(e){if(typeof Uint8Array.fromBase64==`function`){let t=/[-_]/.test(e)?`base64url`:`base64`;return Uint8Array.fromBase64(e,{alphabet:t,lastChunkHandling:`loose`})}let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i}function Br(e,t,n){if(t.length===0)return;let r=Vr(e),i=Ur(n);for(let a of t){let t={...a},o=[...r].filter(e=>e.end<=a.start).sort((e,t)=>t.end-e.end||t.start-e.start)[0],s=o?n.slice(o.end,a.start):``;if(o&&i(o.end)===a.line&&!s.includes(`:`)){Hr(o.node,`trailing`,t);continue}let c=[...r].filter(e=>e.start<a.start&&a.end<e.end).sort((e,t)=>t.start-e.start||e.end-t.end)[0],l=[...r].filter(e=>e.start>=a.end).sort((e,t)=>e.start-t.start||t.end-e.end)[0];if((!c||l&&l.end<=c.end)&&l){Hr(l.node,`leading`,t);continue}Hr(c?.node??e,`dangling`,t)}}function Vr(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 C||e instanceof vr){for(let t of e.items)n(t);return}if(e instanceof Z){for(let[t,r]of e.entries)n(t),n(r);return}if(e instanceof Fe||e instanceof Re){for(let t of e.chunks)n(t);return}e instanceof y&&n(e.content)};return n(e),t}function Hr(e,t,n){e.comments??={},e.comments[t]??=[],e.comments[t].push(n)}function Ur(e){let t=[0];for(let n=0;n<e.length;n++)e[n]===`
28
+ `&&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 Wr=class{extByPrefix;extByTag;unresolvedExtension;constructor(e,t,n,r,i){this.t=e,this.allowInvalidUtf8=r,this.allowTrailing=i,this.extByPrefix=new Map,this.extByTag=new Map,this.unresolvedExtension=n??`cpa999`;for(let e of[...J,...t??[]]){for(let t of e.appStringPrefixes??[])this.extByPrefix.set(t,e);for(let t of e.tagNumbers??[])this.extByTag.set(t,e)}}parse(){let e=this.parseValue();if(this.allowTrailing)return e;let t=this.t.peek();return t.type!==`EOF`&&this._fail(`unexpected token after value: ${JSON.stringify(t.value)}`,t),e}parseValue(){let e=this.t.peek().offset,t=this._parseValueNode();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`:case`BYTES_B32`:case`BYTES_H32`:return this.t.consume(),this._parseBytesConcat(this._decodeBytesToken(e),e.type,e.raw);case`EMPTY_INDEF_BYTES`:return this.t.consume(),new Fe([]);case`EMPTY_INDEF_TEXT`:return this.t.consume(),new Re([]);case`TRUE`:return this.t.consume(),D.TRUE;case`FALSE`:return this.t.consume(),D.FALSE;case`NULL`:return this.t.consume(),D.NULL;case`UNDEFINED`:return this.t.consume(),D.UNDEFINED;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=this.extByPrefix.get(e.appPrefix);if(!t?.parseAppString){if(this.unresolvedExtension===`cpa999`)return new kr(e.appPrefix,[new $(e.value)]);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}return t.parseAppString(e.appPrefix,e.value)}case`APP_SEQUENCE`:{this.t.consume();let t=[];for(;this.t.peek().type!==`GT_GT`&&(this.t.peek().type===`EOF`&&this._fail(`unterminated ${e.appPrefix}<<...>>`,e),!(t.length>0&&this.t.peek().type===`COMMA`&&(this.t.consume(),this.t.peek().type===`GT_GT`)));)t.push(this.parseValue());this.expect(`GT_GT`);let n=this.extByPrefix.get(e.appPrefix);if(!n){if(this.unresolvedExtension===`cpa999`)return new kr(e.appPrefix,t);this._fail(`unknown app-string extension: ${JSON.stringify(e.appPrefix)}`,e)}return n.parseAppSequence||this._fail(`app-string extension ${JSON.stringify(e.appPrefix)} does not support <<...>> form`,e),n.parseAppSequence(e.appPrefix,t)}case`ELLIPSIS`:{if(this.t.consume(),this.t.peek().type!==`PLUS`)return new Q;let e=[new Q];for(;this.t.peek().type===`PLUS`;)this.t.consume(),e.push(this.parseValue());return new Q(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,encodingWidth:n}=Mr(e.value),r=n===void 0?this.consumeEncodingIndicator():n,i=Nr(t);if(i>18446744073709551615n)return this.t.peek().type===`LPAREN`&&this._fail(`tag number exceeds maximum uint64`,e),new Ne(i);if(i<-18446744073709551616n)return new Pe(i);let a=i>=0n?new p(i,r===void 0?void 0:{encodingWidth:r}):new S(i,r===void 0?void 0:{encodingWidth:r});if(this.t.peek().type===`LPAREN`){a instanceof p||this._fail(`tag number must be non-negative`,e),this.t.consume();let t=this.parseValue();this.expect(`RPAREN`);let n=a.value,i=this.extByTag.get(n);if(i?.parseTag){let e=i.parseTag(n,t);if(e!==void 0)return e}return new y(n,t,r===void 0?void 0:{encodingWidth:r})}return a}parseFloat(){let{value:e,precision:t}=Pr(this.t.consume().value);return new w(e,t===void 0?void 0:{precision:t})}parseString(){let e=this.t.consume();if(this.t.peek().type!==`PLUS`){let t=this.consumeEncodingIndicator();return new $(e.value,t===void 0?void 0:{encodingWidth:t})}let t=!1,n=[{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({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=this.consumeEncodingIndicator();return new $(n.map(e=>`text`in e?e.text:``).join(``),e===void 0?void 0:{encodingWidth:e})}let r=[],i=``;for(let e of n)`ellipsis`in e?(i!==``&&(r.push(new $(i)),i=``),r.push(new Q)):i+=e.text;return i!==``&&r.push(new $(i)),new Q(r)}_isBytesToken(e){return e===`BYTES_HEX`||e===`SQSTR`||e===`BYTES_B64`||e===`BYTES_B32`||e===`BYTES_H32`}_decodeBytesToken(e){switch(e.type){case`BYTES_HEX`:case`SQSTR`:return Fr(e.value);case`BYTES_B64`:return zr(e.value);case`BYTES_B32`:return Rr(e.value,Ir);case`BYTES_H32`:return Rr(e.value,Lr);default:this._fail(`expected byte string token`,e)}}_decodeUtf8(e,t){if(this.allowInvalidUtf8)return new TextDecoder(`utf-8`,{fatal:!1}).decode(e);try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(e)}catch{this._fail(`byte string in text concatenation is not valid UTF-8`,t)}}_tokenTypeToEdnEncoding(e){switch(e){case`BYTES_B64`:return`base64`;case`BYTES_B32`:return`base32`;case`BYTES_H32`:return`base32hex`;default:return`hex`}}_parseBytesConcat(e,t,n){if(this.t.peek().type!==`PLUS`){let r=this.consumeEncodingIndicator();return new x(e,{ednEncoding:this._tokenTypeToEdnEncoding(t),ednSource:n,...r===void 0?{}:{encodingWidth:r}})}let r=!1,i=[{bytes:e}];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);for(let e of t)e instanceof Q?(i.push({ellipsis:!0}),r=!0):e instanceof x&&i.push({bytes:e.value})}else this._isBytesToken(e.type)?(this.t.consume(),i.push({bytes:this._decodeBytesToken(e)})):e.type===`TSTR`||e.type===`RAWSTRING`?(this.t.consume(),i.push({bytes:new TextEncoder().encode(e.value)})):this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}if(!r){let e=this.consumeEncodingIndicator(),t=i.map(e=>`bytes`in e?e.bytes:new Uint8Array);return new x(this._concatBytes(t),e===void 0?void 0:{encodingWidth:e})}let a=[],o=[],s=()=>{o.length>0&&(a.push(new x(this._concatBytes([...o]))),o.length=0)};for(let e of i)`ellipsis`in e?(s(),a.push(new Q)):o.push(e.bytes);return s(),new Q(a)}_parseHexElidedConcat(e){let t=this._buildBytesElidedItems(e.value);for(;this.t.peek().type===`PLUS`;){this.t.consume();let e=this.t.peek();if(e.type===`ELLIPSIS`)this.t.consume(),t.push(new Q);else if(e.type===`BYTES_HEX_ELIDED`){this.t.consume();let n=this._buildBytesElidedItems(e.value);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 x?t[t.length-1]=new x(this._concatBytes([r.value,n])):t.push(new x(n))}else this._fail(`expected byte string after +, got ${JSON.stringify(e.value)}`,e)}return new Q(t)}_buildBytesElidedItems(e){let t=e.split(`...`),n=[];for(let e=0;e<t.length;e++)e>0&&n.push(new Q),t[e].length>0&&n.push(new x(Fr(t[e])));return n}_mergeFirstBytesItem(e,t){if(t.length===0)return;let n=e[e.length-1],r=t[0];n instanceof x&&r instanceof x?(e[e.length-1]=new x(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}=Mr(e.value),n=Number(Nr(t));return this.expect(`RPAREN`),new D(n)}parseEmbeddedCBOR(){this.t.consume();let e=[];for(;this.t.peek().type!==`GT_GT`&&!(e.length>0&&this.t.peek().type===`COMMA`&&(this.t.consume(),this.t.peek().type===`GT_GT`));)e.push(this.parseValue());return this.expect(`GT_GT`),new vr(e)}parseArray(){this.t.consume();let e=!1,t;if(this.t.peek().type===`UNDERSCORE`)this.t.consume(),e=!0;else if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume().value;t=e===`i`?`i`:Number(e)}let n=[];for(;this.t.peek().type!==`RBRACKET`&&!(n.length>0&&this.t.peek().type===`COMMA`&&(this.t.consume(),this.t.peek().type===`RBRACKET`));)n.push(this.parseValue());return this.expect(`RBRACKET`),new C(n,{indefiniteLength:e,encodingWidth:t})}parseMap(){this.t.consume();let e=!1,t;if(this.t.peek().type===`UNDERSCORE`)this.t.consume(),e=!0;else if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume().value;t=e===`i`?`i`:Number(e)}let n=[];for(;this.t.peek().type!==`RBRACE`&&!(n.length>0&&this.t.peek().type===`COMMA`&&(this.t.consume(),this.t.peek().type===`RBRACE`));){let e=this.parseValue();this.expect(`COLON`);let t=this.parseValue();n.push([e,t])}return this.expect(`RBRACE`),new Z(n,{indefiniteLength:e,encodingWidth:t})}parseIndefGroup(){this.t.consume();let e=this.t.peek();e.type!==`UNDERSCORE`&&this._fail(`expected _ after (, got ${JSON.stringify(e.value)}`,e),this.t.consume();let t=[];for(;this.t.peek().type!==`RPAREN`&&!(t.length>0&&this.t.peek().type===`COMMA`&&(this.t.consume(),this.t.peek().type===`RPAREN`));)t.push(this.parseValue());this.expect(`RPAREN`),t.length===0&&this._fail(`empty indefinite group (_ ) is ambiguous; use ''_ for bytes or ""_ for text`);let n=t[0];if(n instanceof x)return new Fe(t.map((e,t)=>{if(e instanceof x)return e;this._fail(`indefinite byte string chunk ${t} must be a byte string, not a text string`)}));if(n instanceof $)return new Re(t.map((e,t)=>{if(e instanceof $)return e;this._fail(`indefinite text string chunk ${t} must be a text string, not a byte string`)}));this._fail(`indefinite group chunks must be byte strings or text strings`)}consumeEncodingIndicator(){if(this.t.peek().type===`ENCODING_INDICATOR`){let e=this.t.consume().value;return e===`i`?`i`:Number(e)}}expect(e){let t=this.t.consume();return t.type!==e&&this._fail(`expected ${e}, got ${t.type} (${JSON.stringify(t.value)})`,t),t}_fail(e,t){let n=t?` at line ${t.line}, column ${t.col}`:``;throw SyntaxError(`EDN parse error${n}: ${e}`)}},Gr=new TextEncoder,$=class extends t{indefiniteLength=!1;value;encodingWidth;constructor(e,t){super(),this.value=e,this.encodingWidth=t?.encodingWidth}_toCBOR(e){let t=Gr.encode(this.value);return c([s(3,BigInt(t.length),this.encodingWidth),t])}_toEDN(e,t){let n=this.encodingWidth===void 0?``:`_${this.encodingWidth}`;return Kr(this.value,n,e,t)}_toJS(e){return this.value}};function Kr(e,t,n,r){let i=n?.textStringFormat??[],a=ie(n);if(i.length===0||a===null)return we(e)+t;let o=new Map;if(i.includes(`cboredn`)){let t=Jr(e);if(t!==null)for(let{point:e,contentDepth:n}of t)o.set(e,n)}if(i.includes(`newline`)&&o.size===0)for(let{point:t,contentDepth:n}of qr(e,0))o.set(t,n);let s=Qr(e,o);if(s.length<=1)return we(e)+t;let c=s.map(({text:e},n)=>{let r=we(e);return n===s.length-1?r+t:r}),l=c[0];for(let e=1;e<c.length;e++){let t=b(a,r+1+s[e].contentDepth);l+=` +\n${t}${c[e]}`}return l}function qr(e,t){let n=[];for(let r=0;r<e.length;r++){let i=e[r];i===`\r`?e[r+1]===`
29
+ `?(n.push({point:r+2,contentDepth:t}),r++):n.push({point:r+1,contentDepth:t}):i===`
30
+ `&&n.push({point:r+1,contentDepth:t})}return n}function Jr(e){try{jr(e)}catch{return null}let t=[],n=new Le(e),r=0,i=null,a=!1,o=0;for(;;){let e=n.consume();if(e.type===`EOF`)break;let s=!1;a||(a=!0,e.offset>0&&Zr(n.comments,0,e.offset)&&t.push({point:e.offset,contentDepth:r})),i!==null&&(Xr.has(e.type)&&e.offset===i.point?s=!0:t.push({point:e.offset,contentDepth:i.contentDepth}),i=null),Yr.has(e.type)?(r++,i={point:e.endOffset,contentDepth:r}):Xr.has(e.type)?(r=Math.max(0,r-1),s||t.push({point:e.offset,contentDepth:r})):e.type===`COMMA`&&(i={point:e.endOffset,contentDepth:r}),o=e.endOffset}let s=n.comments.find(e=>e.start>=o);return s!==void 0&&t.push({point:s.start,contentDepth:r}),t}var Yr=new Set([`LBRACKET`,`LBRACE`,`LPAREN`,`LT_LT`]),Xr=new Set([`RBRACKET`,`RBRACE`,`RPAREN`,`GT_GT`]);function Zr(e,t,n){return e.some(e=>e.start>=t&&e.end<=n)}function Qr(e,t){let n=[...t].filter(([t])=>t>0&&t<e.length).sort(([e],[t])=>e-t);if(n.length===0)return[{text:e,contentDepth:0}];let r=[],i=0,a=0;for(let[t,o]of n)t!==i&&(r.push({text:e.slice(i,t),contentDepth:a}),i=t,a=o);return i<e.length&&r.push({text:e.slice(i),contentDepth:a}),r}var $r=class t{static OMIT=e;static TAG=m;static Tag=v;static Simple=E;static MapEntries=X;static dt_as_Date=Qe;#e;constructor(e){this.#e=e??{}}#t(e){return{...this.#e,...e??{}}}fromCBOR(e,n){let r=t.fromCBOR(e,this.#t(n));return r._defaults=this.#e,r}fromEDN(e,n){let r=t.fromEDN(e,this.#t(n));return r._defaults=this.#e,r}fromJS(e,n){let r=t.fromJS(e,this.#t(n));return r._defaults=this.#e,r}fromHexDump(e,n){let r=t.fromHexDump(e,this.#t(n));return r._defaults=this.#e,r}decode(e,n){return t.decode(e,this.#t(n))}encode(e,n){return t.encode(e,this.#t(n))}cborToCborEdn(e,n){return t.cborToCborEdn(e,this.#t(n))}cborEdnToCbor(e,n){return t.cborEdnToCbor(e,this.#t(n))}parse(e,n){if(typeof n==`function`){let r=this.#t({reviver:n});return t.fromEDN(e,r).toJS(r)}let r=this.#t(n);return t.fromEDN(e,r).toJS(r)}stringify(e,n,r){if(typeof n==`function`||Array.isArray(n)||n===null||n===void 0&&r!==void 0){let i={...this.#e};return n===null?i.replacer=void 0:(typeof n==`function`||Array.isArray(n))&&(i.replacer=n),r!==void 0&&(i.indent=ri(r)),t.stringify(e,i)}return t.stringify(e,this.#t(n??void 0))}format(e,n){return t.format(e,this.#t(n))}static fromCBOR(e,t){return Sr(e,t)}static fromEDN(e,t){return jr(e,t)}static fromJS(e,t){return Y(e,t)}static fromHexDump(e,t){let n=[],r=ei(e).trim().split(/\s+/).filter(Boolean);for(let e of r){if(!/^[0-9A-Fa-f]{2}$/.test(e))throw SyntaxError(`Invalid hex token in dump: ${JSON.stringify(e)}`);n.push(parseInt(e,16))}return Sr(new Uint8Array(n),t)}static decode(e,n){return t.fromCBOR(e,n).toJS(n)}static encode(e,n){return t.fromJS(e,n).toCBOR(n)}static cborToCborEdn(e,n){return t.fromCBOR(e,n).toEDN(n)}static cborEdnToCbor(e,n){return t.fromEDN(e,n).toCBOR(n)}static parse(e,n){return typeof n==`function`?t.fromEDN(e).toJS({reviver:n}):t.fromEDN(e,n).toJS(n)}static stringify(t,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=ri(r);if(i){let n=Er(t,i);return n===void 0||n===e?void 0:Y(n).toEDN(a===void 0?void 0:{indent:a})}return Y(t).toEDN(a===void 0?void 0:{indent:a})}let i=n;if(i?.replacer){let n=Er(t,i.replacer,i.extensions,i.undefinedOmits);if(n===void 0||n===e)return;let{replacer:r,...a}=i;return Y(n,Object.keys(a).length>0?a:void 0).toEDN(i)}return Y(t,i).toEDN(i)}static format(e,n){return t.fromEDN(e,n).toEDN(n)}};function ei(e){let t=``,n=0;for(;n<e.length;){let r=e[n],i=e[n+1]??``;if(r===`-`&&i===`-`){n=ti(e,n+2),t+=` `;continue}if(r===`#`){n=ti(e,n+1),t+=` `;continue}if(r===`/`&&i===`/`){n=ti(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+=ni(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+=ni(e.slice(n,r+1)),n=r+1;continue}t+=r,n++}return t}function ti(e,t){let n=e.indexOf(`
31
+ `,t);return n<0?e.length:n}function ni(e){return e.replace(/[^\r\n]/g,` `)}function ri(e){if(typeof e==`number`){let t=Math.floor(Math.min(10,Math.max(0,e)));return t===0?void 0:t}if(typeof e==`string`)return e.slice(0,10)||void 0}exports.CBOR=$r,exports.default=$r,exports.CBOR_OMIT=e,exports.CBOR_TAG=m,exports.CborItem=t,exports.MapEntries=X,exports.Null=h,exports.Simple=E,exports.Tag=v,exports.Undefined=g,exports.dt_as_Date=Qe;
32
+ //# sourceMappingURL=index.cjs.map