@helia/dag-json 5.1.1-6f8165b5 → 5.1.1-73a28eda

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.min.js CHANGED
@@ -1,4 +1,4 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDagJson = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaDagJson=(()=>{var Le=Object.defineProperty;var jr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var Vr=Object.prototype.hasOwnProperty;var qr=(e,t)=>{for(var r in t)Le(e,r,{get:t[r],enumerable:!0})},Pr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rr(t))!Vr.call(e,o)&&o!==r&&Le(e,o,{get:()=>t[o],enumerable:!(n=jr(t,o))||n.enumerable});return e};var Jr=e=>Pr(Le({},"__esModule",{value:!0}),e);var lo={};qr(lo,{dagJson:()=>po});var Ee=class extends Error{static name="InvalidCodecError";constructor(t="Invalid codec"){super(t),this.name="InvalidCodecError"}};var Wr=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function lt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=Gr(e);return r||"Object"}function Gr(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Wr.includes(t))return t}var i=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};i.uint=new i(0,"uint",!0);i.negint=new i(1,"negint",!0);i.bytes=new i(2,"bytes",!0);i.string=new i(3,"string",!0);i.array=new i(4,"array",!1);i.map=new i(5,"map",!1);i.tag=new i(6,"tag",!1);i.float=new i(7,"float",!0);i.false=new i(7,"false",!0);i.true=new i(7,"true",!0);i.null=new i(7,"null",!0);i.undefined=new i(7,"undefined",!0);i.break=new i(7,"break",!0);var c=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var ue=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Hr=new TextEncoder;function ke(e){return ue&&globalThis.Buffer.isBuffer(e)}function K(e){return e instanceof Uint8Array?ke(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Kr=24,Xr=200,fe=ue?e=>e.length>=Kr?globalThis.Buffer.from(e):mt(e):e=>e.length>=Xr?Hr.encode(e):mt(e),F=e=>Uint8Array.from(e),xt=ue?(e,t,r)=>ke(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),gt=ue?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),K(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},wt=ue?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function _e(e,t){if(ke(e)&&ke(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function mt(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var yt=4096;function bt(e){let t=e.length;if(t<=yt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=yt));return r}var Qr=256,de=class{constructor(t=Qr){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=wt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=xt(n,0,this.cursor)}else r=gt(this.chunks,this.cursor);return t&&this.reset(),r}},Ae=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var f="CBOR decode error:",L="CBOR encode error:",he=[];he[23]=1;he[24]=2;he[25]=3;he[26]=5;he[27]=9;function j(e,t,r){if(e.length-t<r)throw new Error(`${f} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function k(e,t,r){j(e,t,1);let n=e[t];if(r.strict===!0&&n<x[0])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function _(e,t,r){j(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<x[1])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){j(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<x[2])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){j(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<x[3])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${f} integers outside of the safe integer range are not supported`)}function Et(e,t,r,n){return new c(i.uint,k(e,t+1,n),2)}function kt(e,t,r,n){return new c(i.uint,_(e,t+1,n),3)}function _t(e,t,r,n){return new c(i.uint,A(e,t+1,n),5)}function At(e,t,r,n){return new c(i.uint,v(e,t+1,n),9)}function S(e,t){return g(e,0,t.value)}function g(e,t,r){if(r<x[0]){let n=Number(r);e.push([t|n])}else if(r<x[1]){let n=Number(r);e.push([t|24,n])}else if(r<x[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<x[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<x[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,e.push(o)}else throw new Error(`${f} encountered BigInt larger than allowable range`)}}S.encodedSize=function(t){return g.encodedSize(t.value)};g.encodedSize=function(t){return t<x[0]?1:t<x[1]?2:t<x[2]?3:t<x[3]?5:9};S.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function vt(e,t,r,n){return new c(i.negint,-1-k(e,t+1,n),2)}function Ut(e,t,r,n){return new c(i.negint,-1-_(e,t+1,n),3)}function St(e,t,r,n){return new c(i.negint,-1-A(e,t+1,n),5)}var je=BigInt(-1),Tt=BigInt(1);function Bt(e,t,r,n){let o=v(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new c(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${f} integers outside of the safe integer range are not supported`);return new c(i.negint,je-BigInt(o),9)}function ve(e,t){let r=t.value,n=typeof r=="bigint"?r*je-Tt:r*-1-1;g(e,t.type.majorEncoded,n)}ve.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*je-Tt:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};ve.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function pe(e,t,r,n){j(e,t,r+n);let o=e.slice(t+r,t+r+n);return new c(i.bytes,o,r+n)}function It(e,t,r,n){return pe(e,t,1,r)}function $t(e,t,r,n){return pe(e,t,2,k(e,t+1,n))}function Ct(e,t,r,n){return pe(e,t,3,_(e,t+1,n))}function Nt(e,t,r,n){return pe(e,t,5,A(e,t+1,n))}function Dt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer bytes lengths not supported`);return pe(e,t,9,o)}function Ue(e){return e.encodedBytes===void 0&&(e.encodedBytes=i.equals(e.type,i.string)?fe(e.value):e.value),e.encodedBytes}function Y(e,t){let r=Ue(t);g(e,t.type.majorEncoded,r.length),e.push(r)}Y.encodedSize=function(t){let r=Ue(t);return g.encodedSize(r.length)+r.length};Y.compareTokens=function(t,r){return Zr(Ue(t),Ue(r))};function Zr(e,t){return e.length<t.length?-1:e.length>t.length?1:_e(e,t)}var Mt=new TextDecoder,tn=32;function rn(e,t,r){if(r-t<tn){let o="";for(let s=t;s<r;s++){let a=e[s];if(a&128)return Mt.decode(e.subarray(t,r));o+=String.fromCharCode(a)}return o}return Mt.decode(e.subarray(t,r))}function le(e,t,r,n,o){let s=r+n;j(e,t,s);let a=new c(i.string,rn(e,t+r,t+s),s);return o.retainStringBytes===!0&&(a.byteValue=e.slice(t+r,t+s)),a}function Ot(e,t,r,n){return le(e,t,1,r,n)}function Ft(e,t,r,n){return le(e,t,2,k(e,t+1,n),n)}function zt(e,t,r,n){return le(e,t,3,_(e,t+1,n),n)}function Lt(e,t,r,n){return le(e,t,5,A(e,t+1,n),n)}function jt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer string lengths not supported`);return le(e,t,9,o,n)}var Rt=Y;function Z(e,t,r,n){return new c(i.array,n,r)}function Vt(e,t,r,n){return Z(e,t,1,r)}function qt(e,t,r,n){return Z(e,t,2,k(e,t+1,n))}function Pt(e,t,r,n){return Z(e,t,3,_(e,t+1,n))}function Jt(e,t,r,n){return Z(e,t,5,A(e,t+1,n))}function Wt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer array lengths not supported`);return Z(e,t,9,o)}function Gt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return Z(e,t,1,1/0)}function Se(e,t){g(e,i.array.majorEncoded,t.value)}Se.compareTokens=S.compareTokens;Se.encodedSize=function(t){return g.encodedSize(t.value)};function ee(e,t,r,n){return new c(i.map,n,r)}function Ht(e,t,r,n){return ee(e,t,1,r)}function Kt(e,t,r,n){return ee(e,t,2,k(e,t+1,n))}function Xt(e,t,r,n){return ee(e,t,3,_(e,t+1,n))}function Qt(e,t,r,n){return ee(e,t,5,A(e,t+1,n))}function Yt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer map lengths not supported`);return ee(e,t,9,o)}function Zt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return ee(e,t,1,1/0)}function Te(e,t){g(e,i.map.majorEncoded,t.value)}Te.compareTokens=S.compareTokens;Te.encodedSize=function(t){return g.encodedSize(t.value)};function er(e,t,r,n){return new c(i.tag,r,1)}function tr(e,t,r,n){return new c(i.tag,k(e,t+1,n),2)}function rr(e,t,r,n){return new c(i.tag,_(e,t+1,n),3)}function nr(e,t,r,n){return new c(i.tag,A(e,t+1,n),5)}function or(e,t,r,n){return new c(i.tag,v(e,t+1,n),9)}function Be(e,t){g(e,i.tag.majorEncoded,t.value)}Be.compareTokens=S.compareTokens;Be.encodedSize=function(t){return g.encodedSize(t.value)};var Re=20,Ve=21,qe=22,Pe=23;function ir(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${f} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new c(i.null,null,1):new c(i.undefined,void 0,1)}function sr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return new c(i.break,void 0,1)}function Je(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${f} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${f} Infinity values are not supported`)}return new c(i.float,e,t)}function ar(e,t,r,n){return Je(We(e,t+1),3,n)}function cr(e,t,r,n){return Je(Ge(e,t+1),5,n)}function ur(e,t,r,n){return Je(pr(e,t+1),9,n)}function Ie(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Re]);else if(n===!0)e.push([i.float.majorEncoded|Ve]);else if(n===null)e.push([i.float.majorEncoded|qe]);else if(n===void 0)e.push([i.float.majorEncoded|Pe]);else{let o,s=!1;(!r||r.float64!==!0)&&(dr(n),o=We($,1),n===o||Number.isNaN(n)?($[0]=249,e.push($.slice(0,3)),s=!0):(hr(n),o=Ge($,1),n===o&&($[0]=250,e.push($.slice(0,5)),s=!0))),s||(cn(n),o=pr($,1),$[0]=251,e.push($.slice(0,9)))}}Ie.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){dr(n);let o=We($,1);if(n===o||Number.isNaN(n))return 3;if(hr(n),o=Ge($,1),n===o)return 5}return 9};var fr=new ArrayBuffer(9),T=new DataView(fr,1),$=new Uint8Array(fr,0);function dr(e){if(e===1/0)T.setUint16(0,31744,!1);else if(e===-1/0)T.setUint16(0,64512,!1);else if(Number.isNaN(e))T.setUint16(0,32256,!1);else{T.setFloat32(0,e);let t=T.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)T.setUint16(0,31744,!1);else if(r===0)T.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?T.setUint16(0,0):o<-14?T.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):T.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function We(e,t){if(e.length-t<2)throw new Error(`${f} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}function hr(e){T.setFloat32(0,e,!1)}function Ge(e,t){if(e.length-t<4)throw new Error(`${f} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function cn(e){T.setFloat64(0,e,!1)}function pr(e,t){if(e.length-t<8)throw new Error(`${f} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Ie.compareTokens=S.compareTokens;function p(e,t,r){throw new Error(`${f} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function $e(e){return()=>{throw new Error(`${f} ${e}`)}}var u=[];for(let e=0;e<=23;e++)u[e]=p;u[24]=Et;u[25]=kt;u[26]=_t;u[27]=At;u[28]=p;u[29]=p;u[30]=p;u[31]=p;for(let e=32;e<=55;e++)u[e]=p;u[56]=vt;u[57]=Ut;u[58]=St;u[59]=Bt;u[60]=p;u[61]=p;u[62]=p;u[63]=p;for(let e=64;e<=87;e++)u[e]=It;u[88]=$t;u[89]=Ct;u[90]=Nt;u[91]=Dt;u[92]=p;u[93]=p;u[94]=p;u[95]=$e("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)u[e]=Ot;u[120]=Ft;u[121]=zt;u[122]=Lt;u[123]=jt;u[124]=p;u[125]=p;u[126]=p;u[127]=$e("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)u[e]=Vt;u[152]=qt;u[153]=Pt;u[154]=Jt;u[155]=Wt;u[156]=p;u[157]=p;u[158]=p;u[159]=Gt;for(let e=160;e<=183;e++)u[e]=Ht;u[184]=Kt;u[185]=Xt;u[186]=Qt;u[187]=Yt;u[188]=p;u[189]=p;u[190]=p;u[191]=Zt;for(let e=192;e<=215;e++)u[e]=er;u[216]=tr;u[217]=rr;u[218]=nr;u[219]=or;u[220]=p;u[221]=p;u[222]=p;u[223]=p;for(let e=224;e<=243;e++)u[e]=$e("simple values are not supported");u[244]=p;u[245]=p;u[246]=p;u[247]=ir;u[248]=$e("simple values are not supported");u[249]=ar;u[250]=cr;u[251]=ur;u[252]=p;u[253]=p;u[254]=p;u[255]=sr;var C=[];for(let e=0;e<24;e++)C[e]=new c(i.uint,e,1);for(let e=-1;e>=-24;e--)C[31-e]=new c(i.negint,e,1);C[64]=new c(i.bytes,new Uint8Array(0),1);C[96]=new c(i.string,"",1);C[128]=new c(i.array,0,1);C[160]=new c(i.map,0,1);C[244]=new c(i.false,!1,1);C[245]=new c(i.true,!0,1);C[246]=new c(i.null,null,1);function lr(e){switch(e.type){case i.false:return F([244]);case i.true:return F([245]);case i.null:return F([246]);case i.bytes:return e.value.length?void 0:F([64]);case i.string:return e.value===""?F([96]):void 0;case i.array:return e.value===0?F([128]):void 0;case i.map:return e.value===0?F([160]):void 0;case i.uint:return e.value<24?F([Number(e.value)]):void 0;case i.negint:if(e.value>=-24)return F([31-Number(e.value)])}}var yr=Object.freeze({float64:!0,mapSorter:ln,quickEncodeToken:lr});function fn(){let e=[];return e[i.uint.major]=S,e[i.negint.major]=ve,e[i.bytes.major]=Y,e[i.string.major]=Rt,e[i.array.major]=Se,e[i.map.major]=Te,e[i.tag.major]=Be,e[i.float.major]=Ie,e}var dn=fn(),hn=new de,Ce=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${L} object contains circular references`);return new e(r,t)}},q={null:new c(i.null,null),undefined:new c(i.undefined,void 0),true:new c(i.true,!0),false:new c(i.false,!1),emptyArray:new c(i.array,0),emptyMap:new c(i.map,0)},P={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new c(i.float,e):e>=0?new c(i.uint,e):new c(i.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new c(i.uint,e):new c(i.negint,e)},Uint8Array(e,t,r,n){return new c(i.bytes,e)},string(e,t,r,n){return new c(i.string,e)},boolean(e,t,r,n){return e?q.true:q.false},null(e,t,r,n){return q.null},undefined(e,t,r,n){return q.undefined},ArrayBuffer(e,t,r,n){return new c(i.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new c(i.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[q.emptyArray,new c(i.break)]:q.emptyArray;n=Ce.createCheck(n,e);let o=[],s=0;for(let a of e)o[s++]=te(a,r,n);return r.addBreakTokens?[new c(i.array,e.length),o,new c(i.break)]:[new c(i.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",s=o?e.keys():Object.keys(e),a=o?e.size:s.length,d;if(a){d=new Array(a),n=Ce.createCheck(n,e);let h=!o&&r.ignoreUndefinedProperties,l=0;for(let b of s){let y=o?e.get(b):e[b];h&&y===void 0||(d[l++]=[te(b,r,n),te(y,r,n)])}l<a&&(d.length=l)}return d?.length?(pn(d,r),r.addBreakTokens?[new c(i.map,d.length),d,new c(i.break)]:[new c(i.map,d.length),d]):r.addBreakTokens===!0?[q.emptyMap,new c(i.break)]:q.emptyMap},Tagged(e,t,r,n){return[new c(i.tag,e.tag),te(e.value,r,n)]}};P.Map=P.Object;P.Buffer=P.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))P[`${e}Array`]=P.DataView;function te(e,t={},r){let n=lt(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||P[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let s=P[n];if(!s)throw new Error(`${L} unsupported type: ${n}`);return s(e,n,t,r)}function pn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function ln(e,t){if(e[0]instanceof c&&t[0]instanceof c){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=mr(r.value)),n._keyBytes||(n._keyBytes=mr(n.value)),_e(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function mr(e){return He(e,dn,yr)}function xr(e,t,r,n){if(Array.isArray(t))for(let o of t)xr(e,o,r,n);else r[t.type.major](e,t,n)}var ii=i.uint.majorEncoded,si=i.negint.majorEncoded,ai=i.bytes.majorEncoded,ci=i.string.majorEncoded,ui=i.array.majorEncoded,fi=i.float.majorEncoded|Re,di=i.float.majorEncoded|Ve,hi=i.float.majorEncoded|qe,pi=i.float.majorEncoded|Pe,li=BigInt(-1),mi=BigInt(1);function He(e,t,r,n){let o=n instanceof Uint8Array,s=o?new Ae(n):hn,a=te(e,r);if(!Array.isArray(a)&&r.quickEncodeToken){let d=r.quickEncodeToken(a);if(d)return o?(s.push(d),s.toBytes()):d;let h=t[a.type.major];if(h.encodedSize){let l=h.encodedSize(a,r);if(o||(s=new de(l)),h(s,a,r),s.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${a} was wrong`);return o?s.toBytes():K(s.chunks[0])}}return s.reset(),xr(s,a,t,r),s.toBytes(!0)}var mn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ne=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=C[t];if(r===void 0){let n=u[t];if(!n)throw new Error(`${f} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},J=Symbol.for("DONE"),re=Symbol.for("BREAK");function yn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=W(t,r);if(s===re){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed array`)}if(s===J)throw new Error(`${f} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function xn(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,s=n?void 0:{},a=n?new Map:void 0;for(let d=0;d<e.value;d++){let h=W(t,r);if(h===re){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(h===J)throw new Error(`${f} found map but not enough entries (got ${d} [no key], expected ${e.value})`);if(!n&&typeof h!="string")throw new Error(`${f} non-string keys not supported (got ${typeof h})`);if(o&&(n&&a.has(h)||!n&&Object.hasOwn(s,h)))throw new Error(`${f} found repeat map key "${h}"`);let l=W(t,r);if(l===J)throw new Error(`${f} found map but not enough entries (got ${d} [no value], expected ${e.value})`);n?a.set(h,l):s[h]=l}return n?a:s}function*gn(e,t,r){for(let n=0;n<e.value;n++){let o=W(t,r);if(o===re){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(o===J)throw new Error(`${f} found map but not enough entries (got ${n} [no key], expected ${e.value})`);let s=W(t,r);if(s===J)throw new Error(`${f} found map but not enough entries (got ${n} [no value], expected ${e.value})`);yield[o,s]}}function wn(e,t){let r=!1,n=function(){if(r)throw new Error(`${f} tag decode() may only be called once`);r=!0;let o=W(e,t);if(o===J)throw new Error(`${f} tag content missing`);if(o===re)throw new Error(`${f} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${f} tag decode() may only be called once`);r=!0;let o=e.next();if(!i.equals(o.type,i.map))throw new Error(`${f} entries() requires map content, got ${o.type.name}`);let s=[];for(let a of gn(o,e,t))s.push(a);return s},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function W(e,t){if(e.done())return J;let r=e.next();if(i.equals(r.type,i.break))return re;if(r.type.terminal)return r.value;if(i.equals(r.type,i.array))return yn(r,e,t);if(i.equals(r.type,i.map))return xn(r,e,t);if(i.equals(r.type,i.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=wn(e,t),o=t.tags[r.value](n);if(!n._called)throw new Error(`${f} tag decoder must call decode() or entries()`);return o}throw new Error(`${f} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ke(e,t){if(!(e instanceof Uint8Array))throw new Error(`${f} data to decode must be a Uint8Array`);t=Object.assign({},mn,t);let r=K(e),n=t.tokenizer||new Ne(r,t),o=W(n,t);if(o===J)throw new Error(`${f} did not find any content to decode`);if(o===re)throw new Error(`${f} got unexpected break`);return[o,e.subarray(n.pos())]}function Xe(e,t){let[r,n]=Ke(e,t);if(n.length>0)throw new Error(`${f} too many terminals, data makes no sense`);return r}var De=class e{constructor(t,r){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=r}static decoder(t){return r=>new e(t,r())}static preserve(...t){let r={};for(let n of t)r[n]=e.decoder(n);return r}};Object.defineProperty(De.prototype,Symbol.toStringTag,{value:"Tagged"});var Qe=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(t){let r=this.inRecursive[this.inRecursive.length-1];r&&(i.equals(r.type,i.array)&&(r.elements++,r.elements!==1&&t.push([44])),i.equals(r.type,i.map)&&(r.elements++,r.elements!==1&&(r.elements%2===1?t.push([44]):t.push([58]))))}[i.uint.major](t,r){this.prefix(t);let n=String(r.value),o=[];for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s);t.push(o)}[i.negint.major](t,r){this[i.uint.major](t,r)}[i.bytes.major](t,r){throw new Error(`${L} unsupported type: Uint8Array`)}[i.string.major](t,r){this.prefix(t);let n=fe(JSON.stringify(r.value));t.push(n.length>32?K(n):n)}[i.array.major](t,r){this.prefix(t),this.inRecursive.push({type:i.array,elements:0}),t.push([91])}[i.map.major](t,r){this.prefix(t),this.inRecursive.push({type:i.map,elements:0}),t.push([123])}[i.tag.major](t,r){}[i.float.major](t,r){if(r.type.name==="break"){let a=this.inRecursive.pop();if(a){if(i.equals(a.type,i.array))t.push([93]);else if(i.equals(a.type,i.map))t.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${L} unsupported type: undefined`);if(this.prefix(t),r.type.name==="true"){t.push([116,114,117,101]);return}else if(r.type.name==="false"){t.push([102,97,108,115,101]);return}else if(r.type.name==="null"){t.push([110,117,108,108]);return}let n=String(r.value),o=[],s=!1;for(let a=0;a<n.length;a++)o[a]=n.charCodeAt(a),!s&&(o[a]===46||o[a]===101||o[a]===69)&&(s=!0);s||(o.push(46),o.push(48)),t.push(o)}};function bn(e,t){if(Array.isArray(e[0])||Array.isArray(t[0]))throw new Error(`${L} complex map keys are not supported`);let r=e[0],n=t[0];if(r.type!==i.string||n.type!==i.string)throw new Error(`${L} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${L} unexpected duplicate map keys, this is not supported`)}var En={addBreakTokens:!0,mapSorter:bn};function Ye(e,t){return t=Object.assign({},En,t),He(e,new Qe,t)}var ne=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r,this.modeStack=["value"],this.lastToken=""}pos(){return this._pos}done(){return this._pos>=this.data.length}ch(){return this.data[this._pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let t=this.ch();for(;t===32||t===9||t===13||t===10;)t=this.data[++this._pos]}expect(t){if(this.data.length-this._pos<t.length)throw new Error(`${f} unexpected end of input at position ${this._pos}`);for(let r=0;r<t.length;r++)if(this.data[this._pos++]!==t[r])throw new Error(`${f} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...t)}'`)}parseNumber(){let t=this._pos,r=!1,n=!1,o=d=>{for(;!this.done();){let h=this.ch();if(d.includes(h))this._pos++;else break}};if(this.ch()===45&&(r=!0,this._pos++),this.ch()===48)if(this._pos++,this.ch()===46)this._pos++,n=!0;else return new c(i.uint,0,this._pos-t);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this._pos===t+1)throw new Error(`${f} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${f} unexpected token at position ${this._pos}`);n=!0,this._pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this._pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this._pos++,o([48,49,50,51,52,53,54,55,56,57]));let s=String.fromCharCode.apply(null,this.data.subarray(t,this._pos)),a=parseFloat(s);return n?new c(i.float,a,this._pos-t):this.options.allowBigInt!==!0||Number.isSafeInteger(a)?new c(a>=0?i.uint:i.negint,a,this._pos-t):new c(a>=0?i.uint:i.negint,BigInt(s),this._pos-t)}parseString(){if(this.ch()!==34)throw new Error(`${f} unexpected character at position ${this._pos}; this shouldn't happen`);this._pos++;for(let s=this._pos,a=0;s<this.data.length&&a<65536;s++,a++){let d=this.data[s];if(d===92||d<32||d>=128)break;if(d===34){let h=String.fromCharCode.apply(null,this.data.subarray(this._pos,s));return this._pos=s+1,new c(i.string,h,a)}}let t=this._pos,r=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${f} unexpected end of unicode escape sequence at position ${this._pos}`);let s=0;for(let a=0;a<4;a++){let d=this.ch();if(d>=48&&d<=57)d-=48;else if(d>=97&&d<=102)d=d-97+10;else if(d>=65&&d<=70)d=d-65+10;else throw new Error(`${f} unexpected unicode escape character at position ${this._pos}`);s=s*16+d,this._pos++}return s},o=()=>{let s=this.ch(),a=null,d=s>239?4:s>223?3:s>191?2:1;if(this._pos+d>this.data.length)throw new Error(`${f} unexpected unicode sequence at position ${this._pos}`);let h,l,b,y;switch(d){case 1:s<128&&(a=s);break;case 2:h=this.data[this._pos+1],(h&192)===128&&(y=(s&31)<<6|h&63,y>127&&(a=y));break;case 3:h=this.data[this._pos+1],l=this.data[this._pos+2],(h&192)===128&&(l&192)===128&&(y=(s&15)<<12|(h&63)<<6|l&63,y>2047&&(y<55296||y>57343)&&(a=y));break;case 4:h=this.data[this._pos+1],l=this.data[this._pos+2],b=this.data[this._pos+3],(h&192)===128&&(l&192)===128&&(b&192)===128&&(y=(s&15)<<18|(h&63)<<12|(l&63)<<6|b&63,y>65535&&y<1114112&&(a=y))}a===null?(a=65533,d=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this._pos+=d};for(;!this.done();){let s=this.ch(),a;switch(s){case 92:if(this._pos++,this.done())throw new Error(`${f} unexpected string termination at position ${this._pos}`);switch(a=this.ch(),this._pos++,a){case 34:case 39:case 92:case 47:r.push(a);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${f} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new c(i.string,bt(r),this._pos-t);default:if(s<32)throw new Error(`${f} invalid control character at position ${this._pos}`);s<128?(r.push(s),this._pos++):o()}}throw new Error(`${f} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new c(i.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new c(i.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new c(i.null,null,4);case 102:return this.expect([102,97,108,115,101]),new c(i.false,!1,5);case 116:return this.expect([116,114,117,101]),new c(i.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${f} unexpected character at position ${this._pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this._pos++,this.skipWhitespace(),new c(i.break,void 0,1);if(this.ch()!==44)throw new Error(`${f} unexpected character at position ${this._pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this._pos++,this.skipWhitespace(),new c(i.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this._pos++,this.skipWhitespace(),new c(i.break,void 0,1);if(this.ch()!==44)throw new Error(`${f} unexpected character at position ${this._pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this._pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this._pos++,this.skipWhitespace(),new c(i.break,void 0,1);let t=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${f} unexpected character at position ${this._pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("obj-value"),t}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${f} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function Ze(e,t){return t=Object.assign({tokenizer:new ne(e,t)},t),Xe(e,t)}var qi=new Uint8Array(0);function gr(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function oe(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return Q(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return Q(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function _n(e){return e?.buffer instanceof ArrayBuffer}function Q(e){return _n(e)?e:e.slice()}function vn(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var d=e.length,h=e.charAt(0),l=Math.log(d)/Math.log(256),b=Math.log(256)/Math.log(d);function y(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var E=0,H=0,B=0,D=m.length;B!==D&&m[B]===0;)B++,E++;for(var M=(D-B)*b+1>>>0,U=new Uint8Array(M);B!==D;){for(var O=m[B],V=0,I=M-1;(O!==0||V<H)&&I!==-1;I--,V++)O+=256*U[I]>>>0,U[I]=O%d>>>0,O=O/d>>>0;if(O!==0)throw new Error("Non-zero carry");H=V,B++}for(var z=M-H;z!==M&&U[z]===0;)z++;for(var be=h.repeat(E);z<M;++z)be+=e.charAt(U[z]);return be}function we(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var E=0;if(m[E]!==" "){for(var H=0,B=0;m[E]===h;)H++,E++;for(var D=(m.length-E)*l+1>>>0,M=new Uint8Array(D);m[E];){var U=r[m.charCodeAt(E)];if(U===255)return;for(var O=0,V=D-1;(U!==0||O<B)&&V!==-1;V--,O++)U+=d*M[V]>>>0,M[V]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");B=O,E++}if(m[E]!==" "){for(var I=D-B;I!==D&&M[I]===0;)I++;for(var z=new Uint8Array(H+(D-I)),be=H;I!==D;)z[be++]=M[I++];return z}}}function Lr(m){var E=we(m);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:y,decodeUnsafe:we,decode:Lr}}var Un=vn,Sn=Un,wr=Sn;var et=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},tt=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return br(this,t)}},rt=class{decoders;constructor(t){this.decoders=t}or(t){return br(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function br(e,t){return new rt({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var nt=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new et(t,r,n),this.decoder=new tt(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Er({name:e,prefix:t,encode:r,decode:n}){return new nt(e,t,r,n)}function ie({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=wr(r,e);return Er({prefix:t,name:e,encode:n,decode:s=>oe(o(s))})}function Tn(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,d=0,h=0;for(let l=0;l<o;++l){let b=t[e[l]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|b,a+=r,a>=8&&(a-=8,s[h++]=255&d>>a)}if(a>=r||(255&d<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function Bn(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",a=0,d=0;for(let h=0;h<e.length;++h)for(d=d<<8|e[h],a+=8;a>r;)a-=r,s+=t[o&d>>a];if(a!==0&&(s+=t[o&d<<r-a]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function In(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function w({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=In(n);return Er({prefix:t,name:e,encode(s){return Bn(s,n,r)},decode(s){return Tn(s,o,r,e)}})}var me=w({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ki=w({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Xi=w({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qi=w({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Yi=w({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Zi=w({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),es=w({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ts=w({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rs=w({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Me=ie({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),is=ie({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var R=ie({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),cs=ie({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var $n=Ar,kr=128,Cn=127,Nn=~Cn,Dn=Math.pow(2,31);function Ar(e,t,r){t=t||[],r=r||0;for(var n=r;e>=Dn;)t[r++]=e&255|kr,e/=128;for(;e&Nn;)t[r++]=e&255|kr,e>>>=7;return t[r]=e|0,Ar.bytes=r-n+1,t}var Mn=ot,On=128,_r=127;function ot(e,n){var r=0,n=n||0,o=0,s=n,a,d=e.length;do{if(s>=d)throw ot.bytes=0,new RangeError("Could not decode varint");a=e[s++],r+=o<28?(a&_r)<<o:(a&_r)*Math.pow(2,o),o+=7}while(a>=On);return ot.bytes=s-n,r}var Fn=Math.pow(2,7),zn=Math.pow(2,14),Ln=Math.pow(2,21),jn=Math.pow(2,28),Rn=Math.pow(2,35),Vn=Math.pow(2,42),qn=Math.pow(2,49),Pn=Math.pow(2,56),Jn=Math.pow(2,63),Wn=function(e){return e<Fn?1:e<zn?2:e<Ln?3:e<jn?4:e<Rn?5:e<Vn?6:e<qn?7:e<Pn?8:e<Jn?9:10},Gn={encode:$n,decode:Mn,encodingLength:Wn},Hn=Gn,ye=Hn;function xe(e,t=0){return[ye.decode(e,t),ye.decode.bytes]}function se(e,t,r=0){return ye.encode(e,t,r),t}function ae(e){return ye.encodingLength(e)}function Oe(e,t){let r=t.byteLength,n=ae(e),o=n+ae(r),s=new Uint8Array(o+r);return se(e,s,0),se(r,s,n),s.set(t,o),new ce(e,r,t,s)}function vr(e){let t=oe(e),[r,n]=xe(t),[o,s]=xe(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new ce(r,o,a,t)}function Ur(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&gr(e.bytes,r.bytes)}}var ce=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=Q(n),this.bytes=Q(o)}};function Sr(e,t){let{bytes:r,version:n}=e;return n===0?Xn(r,at(e),t??R.encoder):Qn(r,at(e),t??me.encoder)}var Tr=new WeakMap;function at(e){let t=Tr.get(e);if(t==null){let r=new Map;return Tr.set(e,r),r}return t}var G=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=Q(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==ge)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Yn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Oe(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Ur(t.multihash,n.multihash)}toString(t){return Sr(this,t)}toJSON(){return{"/":Sr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new e(n,o,s,a??Br(n,o,s.bytes))}else if(r[Zn]===!0){let{version:n,multihash:o,code:s}=r,a=vr(o);return e.create(n,s,a)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==ge)throw new Error(`Version 0 CID must use dag-pb (code: ${ge}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Br(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,ge,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=oe(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new ce(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[y,we]=xe(t.subarray(r));return r+=we,y},o=n(),s=ge;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,d=n(),h=n(),l=r+h,b=l-a;return{version:o,codec:s,multihashCode:d,digestSize:h,multihashSize:b,size:l}}static parse(t,r){let[n,o]=Kn(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return at(s).set(n,t),s}};function Kn(e,t){switch(e[0]){case"Q":{let r=t??R;return[R.prefix,r.decode(`${R.prefix}${e}`)]}case R.prefix:{let r=t??R;return[R.prefix,r.decode(e)]}case me.prefix:{let r=t??me;return[me.prefix,r.decode(e)]}case Me.prefix:{let r=t??Me;return[Me.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Xn(e,t,r){let{prefix:n}=r;if(n!==R.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function Qn(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var ge=112,Yn=18;function Br(e,t,r){let n=ae(e),o=n+ae(t),s=new Uint8Array(o+r.byteLength);return se(e,s,0),se(t,s,n),s.set(r,o),s}var Zn=Symbol.for("@ipld/js-cid/CID");var eo=20;function ut({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new ct(e,t,r,n,o)}var ct=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??eo,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Ir(n,this.code,r?.truncate):n.then(o=>Ir(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ir(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Oe(t,e)}var ft=w({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ts=w({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Bs=w({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Is=w({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function ro(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function no(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=G.asCID(e);if(!t)return null;let r=t.toString();return[new c(i.map,1/0,1),new c(i.string,"/",1),new c(i.string,r,r.length),new c(i.break,void 0,1)]}function Fe(e){let t=ft.encode(e).slice(1);return[new c(i.map,1/0,1),new c(i.string,"/",1),new c(i.map,1/0,1),new c(i.string,"bytes",5),new c(i.string,t,t.length),new c(i.break,void 0,1),new c(i.break,void 0,1)]}function N(e){return Fe(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function oo(e){return Fe(new Uint8Array(e))}function io(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function so(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var ao={typeEncoders:{Object:no,Buffer:Fe,Uint8Array:Fe,Int8Array:N,Uint16Array:N,Int16Array:N,Uint32Array:N,Int32Array:N,Float32Array:N,Float64Array:N,Uint8ClampedArray:N,BigInt64Array:N,BigUint64Array:N,DataView:N,ArrayBuffer:oo,undefined:io,number:so}},dt=class extends ne{constructor(t,r){super(t,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let t=this._next();if(i.equals(t.type,i.map)){let r=this._next();if(i.equals(r.type,i.string)&&r.value==="/"){let n=this._next();if(i.equals(n.type,i.string)){let o=this._next();if(!i.equals(o.type,i.break))throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new c(i.tag,42,0)}if(i.equals(n.type,i.map)){let o=this._next();if(i.equals(o.type,i.string)&&o.value==="bytes"){let s=this._next();if(i.equals(s.type,i.string)){for(let d=0;d<2;d++){let h=this._next();if(!i.equals(h.type,i.break))throw new Error("Invalid encoded Bytes form")}let a=ft.decode(`m${s.value}`);return new c(i.bytes,a,s.value.length)}this.tokenBuffer.push(s)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return t}},$r={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{42:e=>G.parse(e())}};var ht=297,Cr=e=>Ye(e,ao),Nr=e=>{let t=ro(e),r=Object.assign($r,{tokenizer:new dt(t,$r)});return Ze(t,r)};var Ms=new TextDecoder;var Os=new TextEncoder;function Dr(e=0){return new Uint8Array(e)}function uo(e){return e?.buffer instanceof ArrayBuffer}function Mr(e){if(uo(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function pt(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=Dr(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return Mr(r)}function fo(e){return e[Symbol.asyncIterator]!=null}function ho(e){if(fo(e))return(async()=>{let n=new Uint8Array(0);for await(let o of e)n=pt([n,o],n.length+o.length);return n})();let t=[],r=0;for(let n of e)t.push(n),r+=n.byteLength;return pt(t,r)}var Or=ho;function Fr(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var zr=ut({name:"sha2-256",code:18,encode:Fr("SHA-256")}),Js=ut({name:"sha2-512",code:19,encode:Fr("SHA-512")});var ze=class{components;constructor(t){this.components=t}async add(t,r={}){let n=Cr(t),o=await(r.hasher??zr).digest(n),s=G.createV1(ht,o);return await this.components.blockstore.put(s,n,r),s}async get(t,r={}){if(t.code!==ht)throw new Ee("The passed CID had an incorrect codec, it may correspond to a non-DAG-JSON block");let n=await Or(this.components.blockstore.get(t,r));return Nr(n)}};function po(e){return new ze(e)}return Jr(lo);})();
2
+ "use strict";var HeliaDagJson=(()=>{var Le=Object.defineProperty;var jr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var Vr=Object.prototype.hasOwnProperty;var qr=(e,t)=>{for(var r in t)Le(e,r,{get:t[r],enumerable:!0})},Pr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rr(t))!Vr.call(e,o)&&o!==r&&Le(e,o,{get:()=>t[o],enumerable:!(n=jr(t,o))||n.enumerable});return e};var Jr=e=>Pr(Le({},"__esModule",{value:!0}),e);var lo={};qr(lo,{dagJson:()=>po});var yo=new Uint8Array(0);function lt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function Y(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return K(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return K(new Uint8Array(e.buffer,e.byteOffset,e.byteLength));throw new Error("Unknown type, must be binary type")}function Wr(e){return e?.buffer instanceof ArrayBuffer}function K(e){return Wr(e)?e:e.slice()}function Hr(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var d=e.length,h=e.charAt(0),l=Math.log(d)/Math.log(256),b=Math.log(256)/Math.log(d);function y(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var E=0,H=0,B=0,D=m.length;B!==D&&m[B]===0;)B++,E++;for(var M=(D-B)*b+1>>>0,U=new Uint8Array(M);B!==D;){for(var O=m[B],V=0,I=M-1;(O!==0||V<H)&&I!==-1;I--,V++)O+=256*U[I]>>>0,U[I]=O%d>>>0,O=O/d>>>0;if(O!==0)throw new Error("Non-zero carry");H=V,B++}for(var z=M-H;z!==M&&U[z]===0;)z++;for(var be=h.repeat(E);z<M;++z)be+=e.charAt(U[z]);return be}function we(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var E=0;if(m[E]!==" "){for(var H=0,B=0;m[E]===h;)H++,E++;for(var D=(m.length-E)*l+1>>>0,M=new Uint8Array(D);m[E];){var U=r[m.charCodeAt(E)];if(U===255)return;for(var O=0,V=D-1;(U!==0||O<B)&&V!==-1;V--,O++)U+=d*M[V]>>>0,M[V]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");B=O,E++}if(m[E]!==" "){for(var I=D-B;I!==D&&M[I]===0;)I++;for(var z=new Uint8Array(H+(D-I)),be=H;I!==D;)z[be++]=M[I++];return z}}}function Lr(m){var E=we(m);if(E)return E;throw new Error(`Non-${t} character`)}return{encode:y,decodeUnsafe:we,decode:Lr}}var Kr=Hr,Xr=Kr,mt=Xr;var je=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Re=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return yt(this,t)}},Ve=class{decoders;constructor(t){this.decoders=t}or(t){return yt(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function yt(e,t){return new Ve({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var qe=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new je(t,r,n),this.decoder=new Re(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function xt({name:e,prefix:t,encode:r,decode:n}){return new qe(e,t,r,n)}function Z({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=mt(r,e);return xt({prefix:t,name:e,encode:n,decode:s=>Y(o(s))})}function Qr(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,d=0,h=0;for(let l=0;l<o;++l){let b=t[e[l]];if(b===void 0)throw new SyntaxError(`Non-${n} character`);d=d<<r|b,a+=r,a>=8&&(a-=8,s[h++]=255&d>>a)}if(a>=r||(255&d<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function Yr(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",a=0,d=0;for(let h=0;h<e.length;++h)for(d=d<<8|e[h],a+=8;a>r;)a-=r,s+=t[o&d>>a];if(a!==0&&(s+=t[o&d<<r-a]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function Zr(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function w({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=Zr(n);return xt({prefix:t,name:e,encode(s){return Yr(s,n,r)},decode(s){return Qr(s,o,r,e)}})}var ue=w({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ko=w({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_o=w({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ao=w({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vo=w({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Uo=w({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),So=w({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),To=w({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bo=w({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ee=Z({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Co=Z({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var L=Z({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mo=Z({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var en=bt,gt=128,tn=127,rn=~tn,nn=Math.pow(2,31);function bt(e,t,r){t=t||[],r=r||0;for(var n=r;e>=nn;)t[r++]=e&255|gt,e/=128;for(;e&rn;)t[r++]=e&255|gt,e>>>=7;return t[r]=e|0,bt.bytes=r-n+1,t}var on=Pe,sn=128,wt=127;function Pe(e,n){var r=0,n=n||0,o=0,s=n,a,d=e.length;do{if(s>=d)throw Pe.bytes=0,new RangeError("Could not decode varint");a=e[s++],r+=o<28?(a&wt)<<o:(a&wt)*Math.pow(2,o),o+=7}while(a>=sn);return Pe.bytes=s-n,r}var an=Math.pow(2,7),cn=Math.pow(2,14),un=Math.pow(2,21),fn=Math.pow(2,28),dn=Math.pow(2,35),hn=Math.pow(2,42),pn=Math.pow(2,49),ln=Math.pow(2,56),mn=Math.pow(2,63),yn=function(e){return e<an?1:e<cn?2:e<un?3:e<fn?4:e<dn?5:e<hn?6:e<pn?7:e<ln?8:e<mn?9:10},xn={encode:en,decode:on,encodingLength:yn},gn=xn,fe=gn;function de(e,t=0){return[fe.decode(e,t),fe.decode.bytes]}function ee(e,t,r=0){return fe.encode(e,t,r),t}function te(e){return fe.encodingLength(e)}function ke(e,t){let r=t.byteLength,n=te(e),o=n+te(r),s=new Uint8Array(o+r);return ee(e,s,0),ee(r,s,n),s.set(t,o),new re(e,r,t,s)}function Et(e){let t=Y(e),[r,n]=de(t),[o,s]=de(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new re(r,o,a,t)}function kt(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&lt(e.bytes,r.bytes)}}var re=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=K(n),this.bytes=K(o)}};function _t(e,t){let{bytes:r,version:n}=e;return n===0?bn(r,Ge(e),t??L.encoder):En(r,Ge(e),t??ue.encoder)}var At=new WeakMap;function Ge(e){let t=At.get(e);if(t==null){let r=new Map;return At.set(e,r),r}return t}var q=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=K(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==he)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==kn)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=ke(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&kt(t.multihash,n.multihash)}toString(t){return _t(this,t)}toJSON(){return{"/":_t(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new e(n,o,s,a??vt(n,o,s.bytes))}else if(r[_n]===!0){let{version:n,multihash:o,code:s}=r,a=Et(o);return e.create(n,s,a)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==he)throw new Error(`Version 0 CID must use dag-pb (code: ${he}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=vt(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,he,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=Y(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new re(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[y,we]=de(t.subarray(r));return r+=we,y},o=n(),s=he;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,d=n(),h=n(),l=r+h,b=l-a;return{version:o,codec:s,multihashCode:d,digestSize:h,multihashSize:b,size:l}}static parse(t,r){let[n,o]=wn(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ge(s).set(n,t),s}};function wn(e,t){switch(e[0]){case"Q":{let r=t??L;return[L.prefix,r.decode(`${L.prefix}${e}`)]}case L.prefix:{let r=t??L;return[L.prefix,r.decode(e)]}case ue.prefix:{let r=t??ue;return[ue.prefix,r.decode(e)]}case Ee.prefix:{let r=t??Ee;return[Ee.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function bn(e,t,r){let{prefix:n}=r;if(n!==L.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function En(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var he=112,kn=18;function vt(e,t,r){let n=te(e),o=n+te(t),s=new Uint8Array(o+r.byteLength);return ee(e,s,0),ee(t,s,n),s.set(r,o),s}var _n=Symbol.for("@ipld/js-cid/CID");var An=20;function Ke({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new He(e,t,r,n,o)}var He=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??An,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?Ut(n,this.code,r?.truncate):n.then(o=>Ut(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ut(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return ke(t,e)}var Xe=w({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ti=w({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ri=w({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ni=w({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function St(e=0){return new Uint8Array(e)}function Un(e){return e?.buffer instanceof ArrayBuffer}function Tt(e){if(Un(e))return e;let t=e.slice();return new Uint8Array(t.buffer,0,t.byteLength)}function Qe(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=St(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return Tt(r)}function Bt(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var It=Ke({name:"sha2-256",code:18,encode:Bt("SHA-256")}),di=Ke({name:"sha2-512",code:19,encode:Bt("SHA-512")});var _e=class extends Error{static name="InvalidCodecError";constructor(t="Invalid codec"){super(t),this.name="InvalidCodecError"}};var Sn=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function $t(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(t==="string"||t==="number"||t==="bigint"||t==="symbol")return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(e instanceof Uint8Array)return"Uint8Array";if(e.constructor===Object)return"Object";let r=Tn(e);return r||"Object"}function Tn(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Sn.includes(t))return t}var i=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}static equals(t,r){return t===r||t.major===r.major&&t.name===r.name}};i.uint=new i(0,"uint",!0);i.negint=new i(1,"negint",!0);i.bytes=new i(2,"bytes",!0);i.string=new i(3,"string",!0);i.array=new i(4,"array",!1);i.map=new i(5,"map",!1);i.tag=new i(6,"tag",!1);i.float=new i(7,"float",!0);i.false=new i(7,"false",!0);i.true=new i(7,"true",!0);i.null=new i(7,"null",!0);i.undefined=new i(7,"undefined",!0);i.break=new i(7,"break",!0);var c=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var pe=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Bn=new TextEncoder;function Ae(e){return pe&&globalThis.Buffer.isBuffer(e)}function X(e){return e instanceof Uint8Array?Ae(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var In=24,$n=200,le=pe?e=>e.length>=In?globalThis.Buffer.from(e):Ct(e):e=>e.length>=$n?Bn.encode(e):Ct(e),F=e=>Uint8Array.from(e),Dt=pe?(e,t,r)=>Ae(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Mt=pe?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),X(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Ot=pe?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ve(e,t){if(Ae(e)&&Ae(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Ct(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}var Nt=4096;function Ft(e){let t=e.length;if(t<=Nt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Nt));return r}var Cn=256,me=class{constructor(t=Cn){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Ot(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Dt(n,0,this.cursor)}else r=Mt(this.chunks,this.cursor);return t&&this.reset(),r}},Ue=class{constructor(t){this.dest=t,this.cursor=0,this.chunks=[t]}reset(){this.cursor=0}push(t){if(this.cursor+t.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(t,this.cursor),this.cursor+=t.length}toBytes(t=!1){let r=this.dest.subarray(0,this.cursor);return t&&this.reset(),r}};var f="CBOR decode error:",j="CBOR encode error:",ye=[];ye[23]=1;ye[24]=2;ye[25]=3;ye[26]=5;ye[27]=9;function R(e,t,r){if(e.length-t<r)throw new Error(`${f} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function k(e,t,r){R(e,t,1);let n=e[t];if(r.strict===!0&&n<x[0])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function _(e,t,r){R(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<x[1])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){R(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<x[2])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){R(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],s=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&s<x[3])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);if(s<=Number.MAX_SAFE_INTEGER)return Number(s);if(r.allowBigInt===!0)return s;throw new Error(`${f} integers outside of the safe integer range are not supported`)}function zt(e,t,r,n){return new c(i.uint,k(e,t+1,n),2)}function Lt(e,t,r,n){return new c(i.uint,_(e,t+1,n),3)}function jt(e,t,r,n){return new c(i.uint,A(e,t+1,n),5)}function Rt(e,t,r,n){return new c(i.uint,v(e,t+1,n),9)}function S(e,t){return g(e,0,t.value)}function g(e,t,r){if(r<x[0]){let n=Number(r);e.push([t|n])}else if(r<x[1]){let n=Number(r);e.push([t|24,n])}else if(r<x[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<x[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<x[4]){let o=[t|27,0,0,0,0,0,0,0],s=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=s&255,s=s>>8,o[7]=s&255,s=s>>8,o[6]=s&255,s=s>>8,o[5]=s&255,o[4]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,e.push(o)}else throw new Error(`${f} encountered BigInt larger than allowable range`)}}S.encodedSize=function(t){return g.encodedSize(t.value)};g.encodedSize=function(t){return t<x[0]?1:t<x[1]?2:t<x[2]?3:t<x[3]?5:9};S.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Vt(e,t,r,n){return new c(i.negint,-1-k(e,t+1,n),2)}function qt(e,t,r,n){return new c(i.negint,-1-_(e,t+1,n),3)}function Pt(e,t,r,n){return new c(i.negint,-1-A(e,t+1,n),5)}var Ye=BigInt(-1),Jt=BigInt(1);function Wt(e,t,r,n){let o=v(e,t+1,n);if(typeof o!="bigint"){let s=-1-o;if(s>=Number.MIN_SAFE_INTEGER)return new c(i.negint,s,9)}if(n.allowBigInt!==!0)throw new Error(`${f} integers outside of the safe integer range are not supported`);return new c(i.negint,Ye-BigInt(o),9)}function Se(e,t){let r=t.value,n=typeof r=="bigint"?r*Ye-Jt:r*-1-1;g(e,t.type.majorEncoded,n)}Se.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ye-Jt:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};Se.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function xe(e,t,r,n){R(e,t,r+n);let o=e.slice(t+r,t+r+n);return new c(i.bytes,o,r+n)}function Gt(e,t,r,n){return xe(e,t,1,r)}function Ht(e,t,r,n){return xe(e,t,2,k(e,t+1,n))}function Kt(e,t,r,n){return xe(e,t,3,_(e,t+1,n))}function Xt(e,t,r,n){return xe(e,t,5,A(e,t+1,n))}function Qt(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer bytes lengths not supported`);return xe(e,t,9,o)}function Te(e){return e.encodedBytes===void 0&&(e.encodedBytes=i.equals(e.type,i.string)?le(e.value):e.value),e.encodedBytes}function ne(e,t){let r=Te(t);g(e,t.type.majorEncoded,r.length),e.push(r)}ne.encodedSize=function(t){let r=Te(t);return g.encodedSize(r.length)+r.length};ne.compareTokens=function(t,r){return Dn(Te(t),Te(r))};function Dn(e,t){return e.length<t.length?-1:e.length>t.length?1:ve(e,t)}var Yt=new TextDecoder,On=32;function Fn(e,t,r){if(r-t<On){let o="";for(let s=t;s<r;s++){let a=e[s];if(a&128)return Yt.decode(e.subarray(t,r));o+=String.fromCharCode(a)}return o}return Yt.decode(e.subarray(t,r))}function ge(e,t,r,n,o){let s=r+n;R(e,t,s);let a=new c(i.string,Fn(e,t+r,t+s),s);return o.retainStringBytes===!0&&(a.byteValue=e.slice(t+r,t+s)),a}function Zt(e,t,r,n){return ge(e,t,1,r,n)}function er(e,t,r,n){return ge(e,t,2,k(e,t+1,n),n)}function tr(e,t,r,n){return ge(e,t,3,_(e,t+1,n),n)}function rr(e,t,r,n){return ge(e,t,5,A(e,t+1,n),n)}function nr(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer string lengths not supported`);return ge(e,t,9,o,n)}var or=ne;function oe(e,t,r,n){return new c(i.array,n,r)}function ir(e,t,r,n){return oe(e,t,1,r)}function sr(e,t,r,n){return oe(e,t,2,k(e,t+1,n))}function ar(e,t,r,n){return oe(e,t,3,_(e,t+1,n))}function cr(e,t,r,n){return oe(e,t,5,A(e,t+1,n))}function ur(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer array lengths not supported`);return oe(e,t,9,o)}function fr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return oe(e,t,1,1/0)}function Be(e,t){g(e,i.array.majorEncoded,t.value)}Be.compareTokens=S.compareTokens;Be.encodedSize=function(t){return g.encodedSize(t.value)};function ie(e,t,r,n){return new c(i.map,n,r)}function dr(e,t,r,n){return ie(e,t,1,r)}function hr(e,t,r,n){return ie(e,t,2,k(e,t+1,n))}function pr(e,t,r,n){return ie(e,t,3,_(e,t+1,n))}function lr(e,t,r,n){return ie(e,t,5,A(e,t+1,n))}function mr(e,t,r,n){let o=v(e,t+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer map lengths not supported`);return ie(e,t,9,o)}function yr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return ie(e,t,1,1/0)}function Ie(e,t){g(e,i.map.majorEncoded,t.value)}Ie.compareTokens=S.compareTokens;Ie.encodedSize=function(t){return g.encodedSize(t.value)};function xr(e,t,r,n){return new c(i.tag,r,1)}function gr(e,t,r,n){return new c(i.tag,k(e,t+1,n),2)}function wr(e,t,r,n){return new c(i.tag,_(e,t+1,n),3)}function br(e,t,r,n){return new c(i.tag,A(e,t+1,n),5)}function Er(e,t,r,n){return new c(i.tag,v(e,t+1,n),9)}function $e(e,t){g(e,i.tag.majorEncoded,t.value)}$e.compareTokens=S.compareTokens;$e.encodedSize=function(t){return g.encodedSize(t.value)};var Ze=20,et=21,tt=22,rt=23;function kr(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${f} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new c(i.null,null,1):new c(i.undefined,void 0,1)}function _r(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return new c(i.break,void 0,1)}function nt(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${f} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${f} Infinity values are not supported`)}return new c(i.float,e,t)}function Ar(e,t,r,n){return nt(ot(e,t+1),3,n)}function vr(e,t,r,n){return nt(it(e,t+1),5,n)}function Ur(e,t,r,n){return nt(Ir(e,t+1),9,n)}function Ce(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Ze]);else if(n===!0)e.push([i.float.majorEncoded|et]);else if(n===null)e.push([i.float.majorEncoded|tt]);else if(n===void 0)e.push([i.float.majorEncoded|rt]);else{let o,s=!1;(!r||r.float64!==!0)&&(Tr(n),o=ot($,1),n===o||Number.isNaN(n)?($[0]=249,e.push($.slice(0,3)),s=!0):(Br(n),o=it($,1),n===o&&($[0]=250,e.push($.slice(0,5)),s=!0))),s||(Vn(n),o=Ir($,1),$[0]=251,e.push($.slice(0,9)))}}Ce.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Tr(n);let o=ot($,1);if(n===o||Number.isNaN(n))return 3;if(Br(n),o=it($,1),n===o)return 5}return 9};var Sr=new ArrayBuffer(9),T=new DataView(Sr,1),$=new Uint8Array(Sr,0);function Tr(e){if(e===1/0)T.setUint16(0,31744,!1);else if(e===-1/0)T.setUint16(0,64512,!1);else if(Number.isNaN(e))T.setUint16(0,32256,!1);else{T.setFloat32(0,e);let t=T.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)T.setUint16(0,31744,!1);else if(r===0)T.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?T.setUint16(0,0):o<-14?T.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):T.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ot(e,t){if(e.length-t<2)throw new Error(`${f} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,s;return n===0?s=o*2**-24:n!==31?s=(o+1024)*2**(n-25):s=o===0?1/0:NaN,r&32768?-s:s}function Br(e){T.setFloat32(0,e,!1)}function it(e,t){if(e.length-t<4)throw new Error(`${f} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Vn(e){T.setFloat64(0,e,!1)}function Ir(e,t){if(e.length-t<8)throw new Error(`${f} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Ce.compareTokens=S.compareTokens;function p(e,t,r){throw new Error(`${f} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ne(e){return()=>{throw new Error(`${f} ${e}`)}}var u=[];for(let e=0;e<=23;e++)u[e]=p;u[24]=zt;u[25]=Lt;u[26]=jt;u[27]=Rt;u[28]=p;u[29]=p;u[30]=p;u[31]=p;for(let e=32;e<=55;e++)u[e]=p;u[56]=Vt;u[57]=qt;u[58]=Pt;u[59]=Wt;u[60]=p;u[61]=p;u[62]=p;u[63]=p;for(let e=64;e<=87;e++)u[e]=Gt;u[88]=Ht;u[89]=Kt;u[90]=Xt;u[91]=Qt;u[92]=p;u[93]=p;u[94]=p;u[95]=Ne("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)u[e]=Zt;u[120]=er;u[121]=tr;u[122]=rr;u[123]=nr;u[124]=p;u[125]=p;u[126]=p;u[127]=Ne("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)u[e]=ir;u[152]=sr;u[153]=ar;u[154]=cr;u[155]=ur;u[156]=p;u[157]=p;u[158]=p;u[159]=fr;for(let e=160;e<=183;e++)u[e]=dr;u[184]=hr;u[185]=pr;u[186]=lr;u[187]=mr;u[188]=p;u[189]=p;u[190]=p;u[191]=yr;for(let e=192;e<=215;e++)u[e]=xr;u[216]=gr;u[217]=wr;u[218]=br;u[219]=Er;u[220]=p;u[221]=p;u[222]=p;u[223]=p;for(let e=224;e<=243;e++)u[e]=Ne("simple values are not supported");u[244]=p;u[245]=p;u[246]=p;u[247]=kr;u[248]=Ne("simple values are not supported");u[249]=Ar;u[250]=vr;u[251]=Ur;u[252]=p;u[253]=p;u[254]=p;u[255]=_r;var C=[];for(let e=0;e<24;e++)C[e]=new c(i.uint,e,1);for(let e=-1;e>=-24;e--)C[31-e]=new c(i.negint,e,1);C[64]=new c(i.bytes,new Uint8Array(0),1);C[96]=new c(i.string,"",1);C[128]=new c(i.array,0,1);C[160]=new c(i.map,0,1);C[244]=new c(i.false,!1,1);C[245]=new c(i.true,!0,1);C[246]=new c(i.null,null,1);function $r(e){switch(e.type){case i.false:return F([244]);case i.true:return F([245]);case i.null:return F([246]);case i.bytes:return e.value.length?void 0:F([64]);case i.string:return e.value===""?F([96]):void 0;case i.array:return e.value===0?F([128]):void 0;case i.map:return e.value===0?F([160]):void 0;case i.uint:return e.value<24?F([Number(e.value)]):void 0;case i.negint:if(e.value>=-24)return F([31-Number(e.value)])}}var Nr=Object.freeze({float64:!0,mapSorter:Hn,quickEncodeToken:$r});function Pn(){let e=[];return e[i.uint.major]=S,e[i.negint.major]=Se,e[i.bytes.major]=ne,e[i.string.major]=or,e[i.array.major]=Be,e[i.map.major]=Ie,e[i.tag.major]=$e,e[i.float.major]=Ce,e}var Jn=Pn(),Wn=new me,De=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${j} object contains circular references`);return new e(r,t)}},P={null:new c(i.null,null),undefined:new c(i.undefined,void 0),true:new c(i.true,!0),false:new c(i.false,!1),emptyArray:new c(i.array,0),emptyMap:new c(i.map,0)},J={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new c(i.float,e):e>=0?new c(i.uint,e):new c(i.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new c(i.uint,e):new c(i.negint,e)},Uint8Array(e,t,r,n){return new c(i.bytes,e)},string(e,t,r,n){return new c(i.string,e)},boolean(e,t,r,n){return e?P.true:P.false},null(e,t,r,n){return P.null},undefined(e,t,r,n){return P.undefined},ArrayBuffer(e,t,r,n){return new c(i.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new c(i.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[P.emptyArray,new c(i.break)]:P.emptyArray;n=De.createCheck(n,e);let o=[],s=0;for(let a of e)o[s++]=se(a,r,n);return r.addBreakTokens?[new c(i.array,e.length),o,new c(i.break)]:[new c(i.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",s=o?e.keys():Object.keys(e),a=o?e.size:s.length,d;if(a){d=new Array(a),n=De.createCheck(n,e);let h=!o&&r.ignoreUndefinedProperties,l=0;for(let b of s){let y=o?e.get(b):e[b];h&&y===void 0||(d[l++]=[se(b,r,n),se(y,r,n)])}l<a&&(d.length=l)}return d?.length?(Gn(d,r),r.addBreakTokens?[new c(i.map,d.length),d,new c(i.break)]:[new c(i.map,d.length),d]):r.addBreakTokens===!0?[P.emptyMap,new c(i.break)]:P.emptyMap},Tagged(e,t,r,n){return[new c(i.tag,e.tag),se(e.value,r,n)]}};J.Map=J.Object;J.Buffer=J.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))J[`${e}Array`]=J.DataView;function se(e,t={},r){let n=$t(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||J[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let s=J[n];if(!s)throw new Error(`${j} unsupported type: ${n}`);return s(e,n,t,r)}function Gn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Hn(e,t){if(e[0]instanceof c&&t[0]instanceof c){let r=e[0],n=t[0];return r._keyBytes||(r._keyBytes=Cr(r.value)),n._keyBytes||(n._keyBytes=Cr(n.value)),ve(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Cr(e){return st(e,Jn,Nr)}function Dr(e,t,r,n){if(Array.isArray(t))for(let o of t)Dr(e,o,r,n);else r[t.type.major](e,t,n)}var rs=i.uint.majorEncoded,ns=i.negint.majorEncoded,os=i.bytes.majorEncoded,is=i.string.majorEncoded,ss=i.array.majorEncoded,as=i.float.majorEncoded|Ze,cs=i.float.majorEncoded|et,us=i.float.majorEncoded|tt,fs=i.float.majorEncoded|rt,ds=BigInt(-1),hs=BigInt(1);function st(e,t,r,n){let o=n instanceof Uint8Array,s=o?new Ue(n):Wn,a=se(e,r);if(!Array.isArray(a)&&r.quickEncodeToken){let d=r.quickEncodeToken(a);if(d)return o?(s.push(d),s.toBytes()):d;let h=t[a.type.major];if(h.encodedSize){let l=h.encodedSize(a,r);if(o||(s=new me(l)),h(s,a,r),s.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${a} was wrong`);return o?s.toBytes():X(s.chunks[0])}}return s.reset(),Dr(s,a,t,r),s.toBytes(!0)}var Kn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Me=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=C[t];if(r===void 0){let n=u[t];if(!n)throw new Error(`${f} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},W=Symbol.for("DONE"),ae=Symbol.for("BREAK");function Xn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=G(t,r);if(s===ae){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed array`)}if(s===W)throw new Error(`${f} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function Qn(e,t,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,s=n?void 0:{},a=n?new Map:void 0;for(let d=0;d<e.value;d++){let h=G(t,r);if(h===ae){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(h===W)throw new Error(`${f} found map but not enough entries (got ${d} [no key], expected ${e.value})`);if(!n&&typeof h!="string")throw new Error(`${f} non-string keys not supported (got ${typeof h})`);if(o&&(n&&a.has(h)||!n&&Object.hasOwn(s,h)))throw new Error(`${f} found repeat map key "${h}"`);let l=G(t,r);if(l===W)throw new Error(`${f} found map but not enough entries (got ${d} [no value], expected ${e.value})`);n?a.set(h,l):s[h]=l}return n?a:s}function*Yn(e,t,r){for(let n=0;n<e.value;n++){let o=G(t,r);if(o===ae){if(e.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(o===W)throw new Error(`${f} found map but not enough entries (got ${n} [no key], expected ${e.value})`);let s=G(t,r);if(s===W)throw new Error(`${f} found map but not enough entries (got ${n} [no value], expected ${e.value})`);yield[o,s]}}function Zn(e,t){let r=!1,n=function(){if(r)throw new Error(`${f} tag decode() may only be called once`);r=!0;let o=G(e,t);if(o===W)throw new Error(`${f} tag content missing`);if(o===ae)throw new Error(`${f} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${f} tag decode() may only be called once`);r=!0;let o=e.next();if(!i.equals(o.type,i.map))throw new Error(`${f} entries() requires map content, got ${o.type.name}`);let s=[];for(let a of Yn(o,e,t))s.push(a);return s},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function G(e,t){if(e.done())return W;let r=e.next();if(i.equals(r.type,i.break))return ae;if(r.type.terminal)return r.value;if(i.equals(r.type,i.array))return Xn(r,e,t);if(i.equals(r.type,i.map))return Qn(r,e,t);if(i.equals(r.type,i.tag)){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Zn(e,t),o=t.tags[r.value](n);if(!n._called)throw new Error(`${f} tag decoder must call decode() or entries()`);return o}throw new Error(`${f} tag not supported (${r.value})`)}throw new Error("unsupported")}function at(e,t){if(!(e instanceof Uint8Array))throw new Error(`${f} data to decode must be a Uint8Array`);t=Object.assign({},Kn,t);let r=X(e),n=t.tokenizer||new Me(r,t),o=G(n,t);if(o===W)throw new Error(`${f} did not find any content to decode`);if(o===ae)throw new Error(`${f} got unexpected break`);return[o,e.subarray(n.pos())]}function ct(e,t){let[r,n]=at(e,t);if(n.length>0)throw new Error(`${f} too many terminals, data makes no sense`);return r}var Oe=class e{constructor(t,r){if(typeof t!="number"||!Number.isInteger(t)||t<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=t,this.value=r}static decoder(t){return r=>new e(t,r())}static preserve(...t){let r={};for(let n of t)r[n]=e.decoder(n);return r}};Object.defineProperty(Oe.prototype,Symbol.toStringTag,{value:"Tagged"});var ut=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(t){let r=this.inRecursive[this.inRecursive.length-1];r&&(i.equals(r.type,i.array)&&(r.elements++,r.elements!==1&&t.push([44])),i.equals(r.type,i.map)&&(r.elements++,r.elements!==1&&(r.elements%2===1?t.push([44]):t.push([58]))))}[i.uint.major](t,r){this.prefix(t);let n=String(r.value),o=[];for(let s=0;s<n.length;s++)o[s]=n.charCodeAt(s);t.push(o)}[i.negint.major](t,r){this[i.uint.major](t,r)}[i.bytes.major](t,r){throw new Error(`${j} unsupported type: Uint8Array`)}[i.string.major](t,r){this.prefix(t);let n=le(JSON.stringify(r.value));t.push(n.length>32?X(n):n)}[i.array.major](t,r){this.prefix(t),this.inRecursive.push({type:i.array,elements:0}),t.push([91])}[i.map.major](t,r){this.prefix(t),this.inRecursive.push({type:i.map,elements:0}),t.push([123])}[i.tag.major](t,r){}[i.float.major](t,r){if(r.type.name==="break"){let a=this.inRecursive.pop();if(a){if(i.equals(a.type,i.array))t.push([93]);else if(i.equals(a.type,i.map))t.push([125]);else throw new Error("Unexpected recursive type; this should not happen!");return}throw new Error("Unexpected break; this should not happen!")}if(r.value===void 0)throw new Error(`${j} unsupported type: undefined`);if(this.prefix(t),r.type.name==="true"){t.push([116,114,117,101]);return}else if(r.type.name==="false"){t.push([102,97,108,115,101]);return}else if(r.type.name==="null"){t.push([110,117,108,108]);return}let n=String(r.value),o=[],s=!1;for(let a=0;a<n.length;a++)o[a]=n.charCodeAt(a),!s&&(o[a]===46||o[a]===101||o[a]===69)&&(s=!0);s||(o.push(46),o.push(48)),t.push(o)}};function eo(e,t){if(Array.isArray(e[0])||Array.isArray(t[0]))throw new Error(`${j} complex map keys are not supported`);let r=e[0],n=t[0];if(r.type!==i.string||n.type!==i.string)throw new Error(`${j} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${j} unexpected duplicate map keys, this is not supported`)}var to={addBreakTokens:!0,mapSorter:eo};function ft(e,t){return t=Object.assign({},to,t),st(e,new ut,t)}var ce=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r,this.modeStack=["value"],this.lastToken=""}pos(){return this._pos}done(){return this._pos>=this.data.length}ch(){return this.data[this._pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let t=this.ch();for(;t===32||t===9||t===13||t===10;)t=this.data[++this._pos]}expect(t){if(this.data.length-this._pos<t.length)throw new Error(`${f} unexpected end of input at position ${this._pos}`);for(let r=0;r<t.length;r++)if(this.data[this._pos++]!==t[r])throw new Error(`${f} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...t)}'`)}parseNumber(){let t=this._pos,r=!1,n=!1,o=d=>{for(;!this.done();){let h=this.ch();if(d.includes(h))this._pos++;else break}};if(this.ch()===45&&(r=!0,this._pos++),this.ch()===48)if(this._pos++,this.ch()===46)this._pos++,n=!0;else return new c(i.uint,0,this._pos-t);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this._pos===t+1)throw new Error(`${f} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${f} unexpected token at position ${this._pos}`);n=!0,this._pos++,o([48,49,50,51,52,53,54,55,56,57])}!this.done()&&(this.ch()===101||this.ch()===69)&&(n=!0,this._pos++,!this.done()&&(this.ch()===43||this.ch()===45)&&this._pos++,o([48,49,50,51,52,53,54,55,56,57]));let s=String.fromCharCode.apply(null,this.data.subarray(t,this._pos)),a=parseFloat(s);return n?new c(i.float,a,this._pos-t):this.options.allowBigInt!==!0||Number.isSafeInteger(a)?new c(a>=0?i.uint:i.negint,a,this._pos-t):new c(a>=0?i.uint:i.negint,BigInt(s),this._pos-t)}parseString(){if(this.ch()!==34)throw new Error(`${f} unexpected character at position ${this._pos}; this shouldn't happen`);this._pos++;for(let s=this._pos,a=0;s<this.data.length&&a<65536;s++,a++){let d=this.data[s];if(d===92||d<32||d>=128)break;if(d===34){let h=String.fromCharCode.apply(null,this.data.subarray(this._pos,s));return this._pos=s+1,new c(i.string,h,a)}}let t=this._pos,r=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${f} unexpected end of unicode escape sequence at position ${this._pos}`);let s=0;for(let a=0;a<4;a++){let d=this.ch();if(d>=48&&d<=57)d-=48;else if(d>=97&&d<=102)d=d-97+10;else if(d>=65&&d<=70)d=d-65+10;else throw new Error(`${f} unexpected unicode escape character at position ${this._pos}`);s=s*16+d,this._pos++}return s},o=()=>{let s=this.ch(),a=null,d=s>239?4:s>223?3:s>191?2:1;if(this._pos+d>this.data.length)throw new Error(`${f} unexpected unicode sequence at position ${this._pos}`);let h,l,b,y;switch(d){case 1:s<128&&(a=s);break;case 2:h=this.data[this._pos+1],(h&192)===128&&(y=(s&31)<<6|h&63,y>127&&(a=y));break;case 3:h=this.data[this._pos+1],l=this.data[this._pos+2],(h&192)===128&&(l&192)===128&&(y=(s&15)<<12|(h&63)<<6|l&63,y>2047&&(y<55296||y>57343)&&(a=y));break;case 4:h=this.data[this._pos+1],l=this.data[this._pos+2],b=this.data[this._pos+3],(h&192)===128&&(l&192)===128&&(b&192)===128&&(y=(s&15)<<18|(h&63)<<12|(l&63)<<6|b&63,y>65535&&y<1114112&&(a=y))}a===null?(a=65533,d=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this._pos+=d};for(;!this.done();){let s=this.ch(),a;switch(s){case 92:if(this._pos++,this.done())throw new Error(`${f} unexpected string termination at position ${this._pos}`);switch(a=this.ch(),this._pos++,a){case 34:case 39:case 92:case 47:r.push(a);break;case 98:r.push(8);break;case 116:r.push(9);break;case 110:r.push(10);break;case 102:r.push(12);break;case 114:r.push(13);break;case 117:r.push(n());break;default:throw new Error(`${f} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new c(i.string,Ft(r),this._pos-t);default:if(s<32)throw new Error(`${f} invalid control character at position ${this._pos}`);s<128?(r.push(s),this._pos++):o()}}throw new Error(`${f} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new c(i.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new c(i.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new c(i.null,null,4);case 102:return this.expect([102,97,108,115,101]),new c(i.false,!1,5);case 116:return this.expect([116,114,117,101]),new c(i.true,!0,4);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.parseNumber();default:throw new Error(`${f} unexpected character at position ${this._pos}`)}}next(){switch(this.skipWhitespace(),this.currentMode()){case"value":return this.modeStack.pop(),this.parseValue();case"array-value":{if(this.modeStack.pop(),this.ch()===93)return this._pos++,this.skipWhitespace(),new c(i.break,void 0,1);if(this.ch()!==44)throw new Error(`${f} unexpected character at position ${this._pos}, was expecting array delimiter but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue()}case"array-start":return this.modeStack.pop(),this.ch()===93?(this._pos++,this.skipWhitespace(),new c(i.break,void 0,1)):(this.modeStack.push("array-value"),this.skipWhitespace(),this.parseValue());case"obj-key":if(this.ch()===125)return this.modeStack.pop(),this._pos++,this.skipWhitespace(),new c(i.break,void 0,1);if(this.ch()!==44)throw new Error(`${f} unexpected character at position ${this._pos}, was expecting object delimiter but found '${String.fromCharCode(this.ch())}'`);this._pos++,this.skipWhitespace();case"obj-start":{if(this.modeStack.pop(),this.ch()===125)return this._pos++,this.skipWhitespace(),new c(i.break,void 0,1);let t=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${f} unexpected character at position ${this._pos}, was expecting key/value delimiter ':' but found '${String.fromCharCode(this.ch())}'`);return this._pos++,this.modeStack.push("obj-value"),t}case"obj-value":return this.modeStack.pop(),this.modeStack.push("obj-key"),this.skipWhitespace(),this.parseValue();default:throw new Error(`${f} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function dt(e,t){return t=Object.assign({tokenizer:new ce(e,t)},t),ct(e,t)}function no(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function oo(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=q.asCID(e);if(!t)return null;let r=t.toString();return[new c(i.map,1/0,1),new c(i.string,"/",1),new c(i.string,r,r.length),new c(i.break,void 0,1)]}function Fe(e){let t=Xe.encode(e).slice(1);return[new c(i.map,1/0,1),new c(i.string,"/",1),new c(i.map,1/0,1),new c(i.string,"bytes",5),new c(i.string,t,t.length),new c(i.break,void 0,1),new c(i.break,void 0,1)]}function N(e){return Fe(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function io(e){return Fe(new Uint8Array(e))}function so(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function ao(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var co={typeEncoders:{Object:oo,Buffer:Fe,Uint8Array:Fe,Int8Array:N,Uint16Array:N,Int16Array:N,Uint32Array:N,Int32Array:N,Float32Array:N,Float64Array:N,Uint8ClampedArray:N,BigInt64Array:N,BigUint64Array:N,DataView:N,ArrayBuffer:io,undefined:so,number:ao}},ht=class extends ce{constructor(t,r){super(t,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let t=this._next();if(i.equals(t.type,i.map)){let r=this._next();if(i.equals(r.type,i.string)&&r.value==="/"){let n=this._next();if(i.equals(n.type,i.string)){let o=this._next();if(!i.equals(o.type,i.break))throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new c(i.tag,42,0)}if(i.equals(n.type,i.map)){let o=this._next();if(i.equals(o.type,i.string)&&o.value==="bytes"){let s=this._next();if(i.equals(s.type,i.string)){for(let d=0;d<2;d++){let h=this._next();if(!i.equals(h.type,i.break))throw new Error("Invalid encoded Bytes form")}let a=Xe.decode(`m${s.value}`);return new c(i.bytes,a,s.value.length)}this.tokenBuffer.push(s)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return t}},Mr={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{42:e=>q.parse(e())}};var pt=297,Or=e=>ft(e,co),Fr=e=>{let t=no(e),r=Object.assign(Mr,{tokenizer:new ht(t,Mr)});return dt(t,r)};var qs=new TextDecoder;var Ps=new TextEncoder;function fo(e){return e[Symbol.asyncIterator]!=null}function ho(e){if(fo(e))return(async()=>{let n=new Uint8Array(0);for await(let o of e)n=Qe([n,o],n.length+o.length);return n})();let t=[],r=0;for(let n of e)t.push(n),r+=n.byteLength;return Qe(t,r)}var zr=ho;var ze=class{components;constructor(t){this.components=t}async add(t,r={}){let n=Or(t),o=await(r.hasher??It).digest(n),s=q.createV1(pt,o);return await this.components.blockstore.put(s,n,r),s}async get(t,r={}){if(t.code!==pt)throw new _e("The passed CID had an incorrect codec, it may correspond to a non-DAG-JSON block");let n=await zr(this.components.blockstore.get(t,r));return Fr(n)}};function po(e){return new ze(e)}return Jr(lo);})();
3
3
  return HeliaDagJson}));
4
4
  //# sourceMappingURL=index.min.js.map