@helia/dag-json 4.0.7 → 4.1.0-34d3ecd7

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 Ne=Object.defineProperty;var Ar=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var Sr=Object.prototype.hasOwnProperty;var Tr=(e,t)=>{for(var r in t)Ne(e,r,{get:t[r],enumerable:!0})},Br=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ur(t))!Sr.call(e,o)&&o!==r&&Ne(e,o,{get:()=>t[o],enumerable:!(n=Ar(t,o))||n.enumerable});return e};var Cr=e=>Br(Ne({},"__esModule",{value:!0}),e);var Wn={};Tr(Wn,{dagJson:()=>qn});var $r=["string","number","bigint","symbol"],Ir=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function it(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if($r.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Nr(e))return"Buffer";let r=Mr(e);return r||"Object"}function Nr(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Mr(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Ir.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}};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 J=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Dr=new TextDecoder,zr=new TextEncoder;function ge(e){return J&&globalThis.Buffer.isBuffer(e)}function ie(e){return e instanceof Uint8Array?ge(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var ut=J?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):at(e,t,r):(e,t,r)=>r-t>64?Dr.decode(e.subarray(t,r)):at(e,t,r),we=J?e=>e.length>64?globalThis.Buffer.from(e):st(e):e=>e.length>64?zr.encode(e):st(e);var K=J?(e,t,r)=>ge(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),ft=J?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),ie(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},dt=J?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function pt(e,t){if(ge(e)&&ge(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 st(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):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function at(e,t,r){let n=[];for(;t<r;){let o=e[t],s=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let f,p,m,x;switch(a){case 1:o<128&&(s=o);break;case 2:f=e[t+1],(f&192)===128&&(x=(o&31)<<6|f&63,x>127&&(s=x));break;case 3:f=e[t+1],p=e[t+2],(f&192)===128&&(p&192)===128&&(x=(o&15)<<12|(f&63)<<6|p&63,x>2047&&(x<55296||x>57343)&&(s=x));break;case 4:f=e[t+1],p=e[t+2],m=e[t+3],(f&192)===128&&(p&192)===128&&(m&192)===128&&(x=(o&15)<<18|(f&63)<<12|(p&63)<<6|m&63,x>65535&&x<1114112&&(s=x))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),t+=a}return Me(n)}var ct=4096;function Me(e){let t=e.length;if(t<=ct)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ct));return r}var Fr=256,se=class{constructor(t=Fr){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=dt(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=K(n,0,this.cursor)}else r=ft(this.chunks,this.cursor);return t&&this.reset(),r}};var d="CBOR decode error:",O="CBOR encode error:",ae=[];ae[23]=1;ae[24]=2;ae[25]=3;ae[26]=5;ae[27]=9;function V(e,t,r){if(e.length-t<r)throw new Error(`${d} not enough data for type`)}var y=[24,256,65536,4294967296,BigInt("18446744073709551616")];function E(e,t,r){V(e,t,1);let n=e[t];if(r.strict===!0&&n<y[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function _(e,t,r){V(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<y[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){V(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<y[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){V(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<y[3])throw new Error(`${d} 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(`${d} integers outside of the safe integer range are not supported`)}function ht(e,t,r,n){return new c(i.uint,E(e,t+1,n),2)}function lt(e,t,r,n){return new c(i.uint,_(e,t+1,n),3)}function mt(e,t,r,n){return new c(i.uint,v(e,t+1,n),5)}function xt(e,t,r,n){return new c(i.uint,A(e,t+1,n),9)}function S(e,t){return g(e,0,t.value)}function g(e,t,r){if(r<y[0]){let n=Number(r);e.push([t|n])}else if(r<y[1]){let n=Number(r);e.push([t|24,n])}else if(r<y[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<y[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<y[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(`${d} encountered BigInt larger than allowable range`)}}S.encodedSize=function(t){return g.encodedSize(t.value)};g.encodedSize=function(t){return t<y[0]?1:t<y[1]?2:t<y[2]?3:t<y[3]?5:9};S.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function yt(e,t,r,n){return new c(i.negint,-1-E(e,t+1,n),2)}function gt(e,t,r,n){return new c(i.negint,-1-_(e,t+1,n),3)}function wt(e,t,r,n){return new c(i.negint,-1-v(e,t+1,n),5)}var De=BigInt(-1),bt=BigInt(1);function kt(e,t,r,n){let o=A(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(`${d} integers outside of the safe integer range are not supported`);return new c(i.negint,De-BigInt(o),9)}function be(e,t){let r=t.value,n=typeof r=="bigint"?r*De-bt:r*-1-1;g(e,t.type.majorEncoded,n)}be.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*De-bt:r*-1-1;return n<y[0]?1:n<y[1]?2:n<y[2]?3:n<y[3]?5:9};be.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function ce(e,t,r,n){V(e,t,r+n);let o=K(e,t+r,t+r+n);return new c(i.bytes,o,r+n)}function Et(e,t,r,n){return ce(e,t,1,r)}function _t(e,t,r,n){return ce(e,t,2,E(e,t+1,n))}function vt(e,t,r,n){return ce(e,t,3,_(e,t+1,n))}function At(e,t,r,n){return ce(e,t,5,v(e,t+1,n))}function Ut(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return ce(e,t,9,o)}function ke(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===i.string?we(e.value):e.value),e.encodedBytes}function X(e,t){let r=ke(t);g(e,t.type.majorEncoded,r.length),e.push(r)}X.encodedSize=function(t){let r=ke(t);return g.encodedSize(r.length)+r.length};X.compareTokens=function(t,r){return Vr(ke(t),ke(r))};function Vr(e,t){return e.length<t.length?-1:e.length>t.length?1:pt(e,t)}function ue(e,t,r,n,o){let s=r+n;V(e,t,s);let a=new c(i.string,ut(e,t+r,t+s),s);return o.retainStringBytes===!0&&(a.byteValue=K(e,t+r,t+s)),a}function St(e,t,r,n){return ue(e,t,1,r,n)}function Tt(e,t,r,n){return ue(e,t,2,E(e,t+1,n),n)}function Bt(e,t,r,n){return ue(e,t,3,_(e,t+1,n),n)}function Ct(e,t,r,n){return ue(e,t,5,v(e,t+1,n),n)}function $t(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return ue(e,t,9,o,n)}var It=X;function H(e,t,r,n){return new c(i.array,n,r)}function Nt(e,t,r,n){return H(e,t,1,r)}function Mt(e,t,r,n){return H(e,t,2,E(e,t+1,n))}function Dt(e,t,r,n){return H(e,t,3,_(e,t+1,n))}function zt(e,t,r,n){return H(e,t,5,v(e,t+1,n))}function Ft(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return H(e,t,9,o)}function Ot(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return H(e,t,1,1/0)}function Ee(e,t){g(e,i.array.majorEncoded,t.value)}Ee.compareTokens=S.compareTokens;Ee.encodedSize=function(t){return g.encodedSize(t.value)};function Q(e,t,r,n){return new c(i.map,n,r)}function Vt(e,t,r,n){return Q(e,t,1,r)}function jt(e,t,r,n){return Q(e,t,2,E(e,t+1,n))}function Pt(e,t,r,n){return Q(e,t,3,_(e,t+1,n))}function Rt(e,t,r,n){return Q(e,t,5,v(e,t+1,n))}function Lt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return Q(e,t,9,o)}function qt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return Q(e,t,1,1/0)}function _e(e,t){g(e,i.map.majorEncoded,t.value)}_e.compareTokens=S.compareTokens;_e.encodedSize=function(t){return g.encodedSize(t.value)};function Wt(e,t,r,n){return new c(i.tag,r,1)}function Gt(e,t,r,n){return new c(i.tag,E(e,t+1,n),2)}function Jt(e,t,r,n){return new c(i.tag,_(e,t+1,n),3)}function Kt(e,t,r,n){return new c(i.tag,v(e,t+1,n),5)}function Xt(e,t,r,n){return new c(i.tag,A(e,t+1,n),9)}function ve(e,t){g(e,i.tag.majorEncoded,t.value)}ve.compareTokens=S.compareTokens;ve.encodedSize=function(t){return g.encodedSize(t.value)};var Wr=20,Gr=21,Jr=22,Kr=23;function Ht(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new c(i.null,null,1):new c(i.undefined,void 0,1)}function Qt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new c(i.break,void 0,1)}function ze(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new c(i.float,e,t)}function Zt(e,t,r,n){return ze(Fe(e,t+1),3,n)}function Yt(e,t,r,n){return ze(Oe(e,t+1),5,n)}function er(e,t,r,n){return ze(or(e,t+1),9,n)}function Ae(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Wr]);else if(n===!0)e.push([i.float.majorEncoded|Gr]);else if(n===null)e.push([i.float.majorEncoded|Jr]);else if(n===void 0)e.push([i.float.majorEncoded|Kr]);else{let o,s=!1;(!r||r.float64!==!0)&&(rr(n),o=Fe($,1),n===o||Number.isNaN(n)?($[0]=249,e.push($.slice(0,3)),s=!0):(nr(n),o=Oe($,1),n===o&&($[0]=250,e.push($.slice(0,5)),s=!0))),s||(Xr(n),o=or($,1),$[0]=251,e.push($.slice(0,9)))}}Ae.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){rr(n);let o=Fe($,1);if(n===o||Number.isNaN(n))return 3;if(nr(n),o=Oe($,1),n===o)return 5}return 9};var tr=new ArrayBuffer(9),T=new DataView(tr,1),$=new Uint8Array(tr,0);function rr(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,(e&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 Fe(e,t){if(e.length-t<2)throw new Error(`${d} 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 nr(e){T.setFloat32(0,e,!1)}function Oe(e,t){if(e.length-t<4)throw new Error(`${d} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Xr(e){T.setFloat64(0,e,!1)}function or(e,t){if(e.length-t<8)throw new Error(`${d} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Ae.compareTokens=S.compareTokens;function h(e,t,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ue(e){return()=>{throw new Error(`${d} ${e}`)}}var u=[];for(let e=0;e<=23;e++)u[e]=h;u[24]=ht;u[25]=lt;u[26]=mt;u[27]=xt;u[28]=h;u[29]=h;u[30]=h;u[31]=h;for(let e=32;e<=55;e++)u[e]=h;u[56]=yt;u[57]=gt;u[58]=wt;u[59]=kt;u[60]=h;u[61]=h;u[62]=h;u[63]=h;for(let e=64;e<=87;e++)u[e]=Et;u[88]=_t;u[89]=vt;u[90]=At;u[91]=Ut;u[92]=h;u[93]=h;u[94]=h;u[95]=Ue("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)u[e]=St;u[120]=Tt;u[121]=Bt;u[122]=Ct;u[123]=$t;u[124]=h;u[125]=h;u[126]=h;u[127]=Ue("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)u[e]=Nt;u[152]=Mt;u[153]=Dt;u[154]=zt;u[155]=Ft;u[156]=h;u[157]=h;u[158]=h;u[159]=Ot;for(let e=160;e<=183;e++)u[e]=Vt;u[184]=jt;u[185]=Pt;u[186]=Rt;u[187]=Lt;u[188]=h;u[189]=h;u[190]=h;u[191]=qt;for(let e=192;e<=215;e++)u[e]=Wt;u[216]=Gt;u[217]=Jt;u[218]=Kt;u[219]=Xt;u[220]=h;u[221]=h;u[222]=h;u[223]=h;for(let e=224;e<=243;e++)u[e]=Ue("simple values are not supported");u[244]=h;u[245]=h;u[246]=h;u[247]=Ht;u[248]=Ue("simple values are not supported");u[249]=Zt;u[250]=Yt;u[251]=er;u[252]=h;u[253]=h;u[254]=h;u[255]=Qt;var I=[];for(let e=0;e<24;e++)I[e]=new c(i.uint,e,1);for(let e=-1;e>=-24;e--)I[31-e]=new c(i.negint,e,1);I[64]=new c(i.bytes,new Uint8Array(0),1);I[96]=new c(i.string,"",1);I[128]=new c(i.array,0,1);I[160]=new c(i.map,0,1);I[244]=new c(i.false,!1,1);I[245]=new c(i.true,!0,1);I[246]=new c(i.null,null,1);function Qr(){let e=[];return e[i.uint.major]=S,e[i.negint.major]=be,e[i.bytes.major]=X,e[i.string.major]=It,e[i.array.major]=Ee,e[i.map.major]=_e,e[i.tag.major]=ve,e[i.float.major]=Ae,e}var Vo=Qr(),Ve=new se,Te=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(`${O} object contains circular references`);return new e(r,t)}},R={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)},L={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?R.true:R.false},null(e,t,r,n){return R.null},undefined(e,t,r,n){return R.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?[R.emptyArray,new c(i.break)]:R.emptyArray;n=Te.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;if(!a)return r.addBreakTokens===!0?[R.emptyMap,new c(i.break)]:R.emptyMap;n=Te.createCheck(n,e);let f=[],p=0;for(let m of s)f[p++]=[Se(m,r,n),Se(o?e.get(m):e[m],r,n)];return Zr(f,r),r.addBreakTokens?[new c(i.map,a),f,new c(i.break)]:[new c(i.map,a),f]}};L.Map=L.Object;L.Buffer=L.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))L[`${e}Array`]=L.DataView;function Se(e,t={},r){let n=it(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||L[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let s=L[n];if(!s)throw new Error(`${O} unsupported type: ${n}`);return s(e,n,t,r)}function Zr(e,t){t.mapSorter&&e.sort(t.mapSorter)}function ir(e,t,r,n){if(Array.isArray(t))for(let o of t)ir(e,o,r,n);else r[t.type.major](e,t,n)}function sr(e,t,r){let n=Se(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let s=t[n.type.major];if(s.encodedSize){let a=s.encodedSize(n,r),f=new se(a);if(s(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ie(f.chunks[0])}}return Ve.reset(),ir(Ve,n,t,r),Ve.toBytes(!0)}var Yr={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Be=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=I[t];if(r===void 0){let n=u[t];if(!n)throw new Error(`${d} 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}},fe=Symbol.for("DONE"),Ce=Symbol.for("BREAK");function en(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=Z(t,r);if(s===Ce){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(s===fe)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function tn(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<e.value;a++){let f=Z(t,r);if(f===Ce){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(f===fe)throw new Error(`${d} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${d} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&s.has(f)||!n&&f in o))throw new Error(`${d} found repeat map key "${f}"`);let p=Z(t,r);if(p===fe)throw new Error(`${d} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?s.set(f,p):o[f]=p}return n?s:o}function Z(e,t){if(e.done())return fe;let r=e.next();if(r.type===i.break)return Ce;if(r.type.terminal)return r.value;if(r.type===i.array)return en(r,e,t);if(r.type===i.map)return tn(r,e,t);if(r.type===i.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Z(e,t);return t.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function je(e,t){if(!(e instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);t=Object.assign({},Yr,t);let r=t.tokenizer||new Be(e,t),n=Z(r,t);if(n===fe)throw new Error(`${d} did not find any content to decode`);if(n===Ce)throw new Error(`${d} got unexpected break`);return[n,e.subarray(r.pos())]}function Pe(e,t){let[r,n]=je(e,t);if(n.length>0)throw new Error(`${d} too many terminals, data makes no sense`);return r}var Re=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(t){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===i.array&&(r.elements++,r.elements!==1&&t.push([44])),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(`${O} unsupported type: Uint8Array`)}[i.string.major](t,r){this.prefix(t);let n=we(JSON.stringify(r.value));t.push(n.length>32?ie(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(a.type===i.array)t.push([93]);else if(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(`${O} 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 rn(e,t){if(Array.isArray(e[0])||Array.isArray(t[0]))throw new Error(`${O} 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(`${O} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${O} unexpected duplicate map keys, this is not supported`)}var nn={addBreakTokens:!0,mapSorter:rn};function Le(e,t){return t=Object.assign({},nn,t),sr(e,new Re,t)}var Y=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(`${d} 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(`${d} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...t)}'`)}parseNumber(){let t=this._pos,r=!1,n=!1,o=f=>{for(;!this.done();){let p=this.ch();if(f.includes(p))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(`${d} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${d} 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(`${d} 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 f=this.data[s];if(f===92||f<32||f>=128)break;if(f===34){let p=String.fromCharCode.apply(null,this.data.subarray(this._pos,s));return this._pos=s+1,new c(i.string,p,a)}}let t=this._pos,r=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${d} unexpected end of unicode escape sequence at position ${this._pos}`);let s=0;for(let a=0;a<4;a++){let f=this.ch();if(f>=48&&f<=57)f-=48;else if(f>=97&&f<=102)f=f-97+10;else if(f>=65&&f<=70)f=f-65+10;else throw new Error(`${d} unexpected unicode escape character at position ${this._pos}`);s=s*16+f,this._pos++}return s},o=()=>{let s=this.ch(),a=null,f=s>239?4:s>223?3:s>191?2:1;if(this._pos+f>this.data.length)throw new Error(`${d} unexpected unicode sequence at position ${this._pos}`);let p,m,x,w;switch(f){case 1:s<128&&(a=s);break;case 2:p=this.data[this._pos+1],(p&192)===128&&(w=(s&31)<<6|p&63,w>127&&(a=w));break;case 3:p=this.data[this._pos+1],m=this.data[this._pos+2],(p&192)===128&&(m&192)===128&&(w=(s&15)<<12|(p&63)<<6|m&63,w>2047&&(w<55296||w>57343)&&(a=w));break;case 4:p=this.data[this._pos+1],m=this.data[this._pos+2],x=this.data[this._pos+3],(p&192)===128&&(m&192)===128&&(x&192)===128&&(w=(s&15)<<18|(p&63)<<12|(m&63)<<6|x&63,w>65535&&w<1114112&&(a=w))}a===null?(a=65533,f=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this._pos+=f};for(;!this.done();){let s=this.ch(),a;switch(s){case 92:if(this._pos++,this.done())throw new Error(`${d} 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(`${d} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new c(i.string,Me(r),this._pos-t);default:if(s<32)throw new Error(`${d} invalid control character at position ${this._pos}`);s<128?(r.push(s),this._pos++):o()}}throw new Error(`${d} 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(`${d} 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(`${d} 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(`${d} 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(`${d} 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(`${d} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function qe(e,t){return t=Object.assign({tokenizer:new Y(e,t)},t),Pe(e,t)}var ui=new Uint8Array(0);function ar(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 ee(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function an(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 f=e.length,p=e.charAt(0),m=Math.log(f)/Math.log(256),x=Math.log(256)/Math.log(f);function w(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var k=0,W=0,B=0,M=l.length;B!==M&&l[B]===0;)B++,k++;for(var D=(M-B)*x+1>>>0,U=new Uint8Array(D);B!==M;){for(var z=l[B],P=0,C=D-1;(z!==0||P<W)&&C!==-1;C--,P++)z+=256*U[C]>>>0,U[C]=z%f>>>0,z=z/f>>>0;if(z!==0)throw new Error("Non-zero carry");W=P,B++}for(var F=D-W;F!==D&&U[F]===0;)F++;for(var ye=p.repeat(k);F<D;++F)ye+=e.charAt(U[F]);return ye}function xe(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var k=0;if(l[k]!==" "){for(var W=0,B=0;l[k]===p;)W++,k++;for(var M=(l.length-k)*m+1>>>0,D=new Uint8Array(M);l[k];){var U=r[l.charCodeAt(k)];if(U===255)return;for(var z=0,P=M-1;(U!==0||z<B)&&P!==-1;P--,z++)U+=f*D[P]>>>0,D[P]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");B=z,k++}if(l[k]!==" "){for(var C=M-B;C!==M&&D[C]===0;)C++;for(var F=new Uint8Array(W+(M-C)),ye=W;C!==M;)F[ye++]=D[C++];return F}}}function vr(l){var k=xe(l);if(k)return k;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:xe,decode:vr}}var cn=an,un=cn,cr=un;var We=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")}},Ge=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 ur(this,t)}},Je=class{decoders;constructor(t){this.decoders=t}or(t){return ur(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 ur(e,t){return new Je({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Ke=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 We(t,r,n),this.decoder=new Ge(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function fr({name:e,prefix:t,encode:r,decode:n}){return new Ke(e,t,r,n)}function te({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=cr(r,e);return fr({prefix:t,name:e,encode:n,decode:s=>ee(o(s))})}function fn(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,f=0,p=0;for(let m=0;m<o;++m){let x=t[e[m]];if(x===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|x,a+=r,a>=8&&(a-=8,s[p++]=255&f>>a)}if(a>=r||(255&f<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function dn(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",a=0,f=0;for(let p=0;p<e.length;++p)for(f=f<<8|e[p],a+=8;a>r;)a-=r,s+=t[o&f>>a];if(a!==0&&(s+=t[o&f<<r-a]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function pn(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function b({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=pn(n);return fr({prefix:t,name:e,encode(s){return dn(s,n,r)},decode(s){return fn(s,o,r,e)}})}var de=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mi=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xi=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yi=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),gi=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wi=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bi=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ki=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ei=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $e=te({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ai=te({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var j=te({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ti=te({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var hn=hr,dr=128,ln=127,mn=~ln,xn=Math.pow(2,31);function hr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=xn;)t[r++]=e&255|dr,e/=128;for(;e&mn;)t[r++]=e&255|dr,e>>>=7;return t[r]=e|0,hr.bytes=r-n+1,t}var yn=Xe,gn=128,pr=127;function Xe(e,n){var r=0,n=n||0,o=0,s=n,a,f=e.length;do{if(s>=f)throw Xe.bytes=0,new RangeError("Could not decode varint");a=e[s++],r+=o<28?(a&pr)<<o:(a&pr)*Math.pow(2,o),o+=7}while(a>=gn);return Xe.bytes=s-n,r}var wn=Math.pow(2,7),bn=Math.pow(2,14),kn=Math.pow(2,21),En=Math.pow(2,28),_n=Math.pow(2,35),vn=Math.pow(2,42),An=Math.pow(2,49),Un=Math.pow(2,56),Sn=Math.pow(2,63),Tn=function(e){return e<wn?1:e<bn?2:e<kn?3:e<En?4:e<_n?5:e<vn?6:e<An?7:e<Un?8:e<Sn?9:10},Bn={encode:hn,decode:yn,encodingLength:Tn},Cn=Bn,pe=Cn;function he(e,t=0){return[pe.decode(e,t),pe.decode.bytes]}function re(e,t,r=0){return pe.encode(e,t,r),t}function ne(e){return pe.encodingLength(e)}function le(e,t){let r=t.byteLength,n=ne(e),o=n+ne(r),s=new Uint8Array(o+r);return re(e,s,0),re(r,s,n),s.set(t,o),new oe(e,r,t,s)}function lr(e){let t=ee(e),[r,n]=he(t),[o,s]=he(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new oe(r,o,a,t)}function mr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&ar(e.bytes,r.bytes)}}var oe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function xr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return In(r,Ze(e),t??j.encoder);default:return Nn(r,Ze(e),t??de.encoder)}}var yr=new WeakMap;function Ze(e){let t=yr.get(e);if(t==null){let r=new Map;return yr.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=o,this["/"]=o}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!==me)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Mn)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=le(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&&mr(t.multihash,n.multihash)}toString(t){return xr(this,t)}toJSON(){return{"/":xr(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??gr(n,o,s.bytes))}else if(r[Dn]===!0){let{version:n,multihash:o,code:s}=r,a=lr(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!==me)throw new Error(`Version 0 CID must use dag-pb (code: ${me}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=gr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,me,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=ee(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 oe(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[w,xe]=he(t.subarray(r));return r+=xe,w},o=n(),s=me;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,f=n(),p=n(),m=r+p,x=m-a;return{version:o,codec:s,multihashCode:f,digestSize:p,multihashSize:x,size:m}}static parse(t,r){let[n,o]=$n(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 Ze(s).set(n,t),s}};function $n(e,t){switch(e[0]){case"Q":{let r=t??j;return[j.prefix,r.decode(`${j.prefix}${e}`)]}case j.prefix:{let r=t??j;return[j.prefix,r.decode(e)]}case de.prefix:{let r=t??de;return[de.prefix,r.decode(e)]}case $e.prefix:{let r=t??$e;return[$e.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 In(e,t,r){let{prefix:n}=r;if(n!==j.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 Nn(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 me=112,Mn=18;function gr(e,t,r){let n=ne(e),o=n+ne(t),s=new Uint8Array(o+r.byteLength);return re(e,s,0),re(t,s,n),s.set(r,o),s}var Dn=Symbol.for("@ipld/js-cid/CID");function et({name:e,code:t,encode:r}){return new Ye(e,t,r)}var Ye=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?le(this.code,r):r.then(n=>le(this.code,n))}else throw Error("Unknown type, must be binary type")}};var tt=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ki=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xi=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Hi=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Fn(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function On(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 Ie(e){let t=tt.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 Ie(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Vn(e){return Ie(new Uint8Array(e))}function jn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Pn(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 Rn={typeEncoders:{Object:On,Buffer:Ie,Uint8Array:Ie,Int8Array:N,Uint16Array:N,Int16Array:N,Uint32Array:N,Int32Array:N,Float32Array:N,Float64Array:N,Uint8ClampedArray:N,BigInt64Array:N,BigUint64Array:N,DataView:N,ArrayBuffer:Vn,undefined:jn,number:Pn}},rt=class extends Y{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(t.type===i.map){let r=this._next();if(r.type===i.string&&r.value==="/"){let n=this._next();if(n.type===i.string){if(this._next().type!==i.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new c(i.tag,42,0)}if(n.type===i.map){let o=this._next();if(o.type===i.string&&o.value==="bytes"){let s=this._next();if(s.type===i.string){for(let f=0;f<2;f++)if(this._next().type!==i.break)throw new Error("Invalid encoded Bytes form");let a=tt.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}},nt={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};nt.tags[42]=q.parse;var wr=297,br=e=>Le(e,Rn),kr=e=>{let t=Fn(e),r=Object.assign(nt,{tokenizer:new rt(t,nt)});return qe(t,r)};var ts=new TextDecoder;var rs=new TextEncoder;function Er(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var _r=et({name:"sha2-256",code:18,encode:Er("SHA-256")}),os=et({name:"sha2-512",code:19,encode:Er("SHA-512")});var ot=class{components;constructor(t){this.components=t}async add(t,r={}){let n=br(t),o=await(r.hasher??_r).digest(n),s=q.createV1(wr,o);return await this.components.blockstore.put(s,n,r),s}async get(t,r={}){let n=await this.components.blockstore.get(t,r);return kr(n)}};function qn(e){return new ot(e)}return Cr(Wn);})();
2
+ "use strict";var HeliaDagJson=(()=>{var Ne=Object.defineProperty;var Br=Object.getOwnPropertyDescriptor;var Ir=Object.getOwnPropertyNames;var Cr=Object.prototype.hasOwnProperty;var $r=(e,t)=>{for(var r in t)Ne(e,r,{get:t[r],enumerable:!0})},Nr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ir(t))!Cr.call(e,o)&&o!==r&&Ne(e,o,{get:()=>t[o],enumerable:!(n=Br(t,o))||n.enumerable});return e};var Dr=e=>Nr(Ne({},"__esModule",{value:!0}),e);var Zn={};$r(Zn,{dagJson:()=>Qn});var Mr=["string","number","bigint","symbol"],zr=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function st(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(Mr.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Fr(e))return"Buffer";let r=Or(e);return r||"Object"}function Fr(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Or(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(zr.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}};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 J=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Lr=new TextDecoder,Vr=new TextEncoder;function ye(e){return J&&globalThis.Buffer.isBuffer(e)}function ie(e){return e instanceof Uint8Array?ye(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var ft=J?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):ct(e,t,r):(e,t,r)=>r-t>64?Lr.decode(e.subarray(t,r)):ct(e,t,r),ge=J?e=>e.length>64?globalThis.Buffer.from(e):at(e):e=>e.length>64?Vr.encode(e):at(e);var K=J?(e,t,r)=>ye(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),dt=J?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),ie(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},ht=J?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function pt(e,t){if(ye(e)&&ye(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 at(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):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function ct(e,t,r){let n=[];for(;t<r;){let o=e[t],s=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let f,h,m,x;switch(a){case 1:o<128&&(s=o);break;case 2:f=e[t+1],(f&192)===128&&(x=(o&31)<<6|f&63,x>127&&(s=x));break;case 3:f=e[t+1],h=e[t+2],(f&192)===128&&(h&192)===128&&(x=(o&15)<<12|(f&63)<<6|h&63,x>2047&&(x<55296||x>57343)&&(s=x));break;case 4:f=e[t+1],h=e[t+2],m=e[t+3],(f&192)===128&&(h&192)===128&&(m&192)===128&&(x=(o&15)<<18|(f&63)<<12|(h&63)<<6|m&63,x>65535&&x<1114112&&(s=x))}}s===null?(s=65533,a=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),t+=a}return De(n)}var ut=4096;function De(e){let t=e.length;if(t<=ut)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=ut));return r}var jr=256,se=class{constructor(t=jr){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=ht(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=K(n,0,this.cursor)}else r=dt(this.chunks,this.cursor);return t&&this.reset(),r}};var d="CBOR decode error:",O="CBOR encode error:",ae=[];ae[23]=1;ae[24]=2;ae[25]=3;ae[26]=5;ae[27]=9;function L(e,t,r){if(e.length-t<r)throw new Error(`${d} not enough data for type`)}var y=[24,256,65536,4294967296,BigInt("18446744073709551616")];function E(e,t,r){L(e,t,1);let n=e[t];if(r.strict===!0&&n<y[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function _(e,t,r){L(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<y[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){L(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<y[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){L(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<y[3])throw new Error(`${d} 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(`${d} integers outside of the safe integer range are not supported`)}function lt(e,t,r,n){return new c(i.uint,E(e,t+1,n),2)}function mt(e,t,r,n){return new c(i.uint,_(e,t+1,n),3)}function xt(e,t,r,n){return new c(i.uint,v(e,t+1,n),5)}function yt(e,t,r,n){return new c(i.uint,A(e,t+1,n),9)}function S(e,t){return g(e,0,t.value)}function g(e,t,r){if(r<y[0]){let n=Number(r);e.push([t|n])}else if(r<y[1]){let n=Number(r);e.push([t|24,n])}else if(r<y[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<y[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<y[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(`${d} encountered BigInt larger than allowable range`)}}S.encodedSize=function(t){return g.encodedSize(t.value)};g.encodedSize=function(t){return t<y[0]?1:t<y[1]?2:t<y[2]?3:t<y[3]?5:9};S.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function gt(e,t,r,n){return new c(i.negint,-1-E(e,t+1,n),2)}function wt(e,t,r,n){return new c(i.negint,-1-_(e,t+1,n),3)}function bt(e,t,r,n){return new c(i.negint,-1-v(e,t+1,n),5)}var Me=BigInt(-1),kt=BigInt(1);function Et(e,t,r,n){let o=A(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(`${d} integers outside of the safe integer range are not supported`);return new c(i.negint,Me-BigInt(o),9)}function we(e,t){let r=t.value,n=typeof r=="bigint"?r*Me-kt:r*-1-1;g(e,t.type.majorEncoded,n)}we.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Me-kt:r*-1-1;return n<y[0]?1:n<y[1]?2:n<y[2]?3:n<y[3]?5:9};we.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function ce(e,t,r,n){L(e,t,r+n);let o=K(e,t+r,t+r+n);return new c(i.bytes,o,r+n)}function _t(e,t,r,n){return ce(e,t,1,r)}function vt(e,t,r,n){return ce(e,t,2,E(e,t+1,n))}function At(e,t,r,n){return ce(e,t,3,_(e,t+1,n))}function Ut(e,t,r,n){return ce(e,t,5,v(e,t+1,n))}function St(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return ce(e,t,9,o)}function be(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===i.string?ge(e.value):e.value),e.encodedBytes}function H(e,t){let r=be(t);g(e,t.type.majorEncoded,r.length),e.push(r)}H.encodedSize=function(t){let r=be(t);return g.encodedSize(r.length)+r.length};H.compareTokens=function(t,r){return Rr(be(t),be(r))};function Rr(e,t){return e.length<t.length?-1:e.length>t.length?1:pt(e,t)}function ue(e,t,r,n,o){let s=r+n;L(e,t,s);let a=new c(i.string,ft(e,t+r,t+s),s);return o.retainStringBytes===!0&&(a.byteValue=K(e,t+r,t+s)),a}function Tt(e,t,r,n){return ue(e,t,1,r,n)}function Bt(e,t,r,n){return ue(e,t,2,E(e,t+1,n),n)}function It(e,t,r,n){return ue(e,t,3,_(e,t+1,n),n)}function Ct(e,t,r,n){return ue(e,t,5,v(e,t+1,n),n)}function $t(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return ue(e,t,9,o,n)}var Nt=H;function X(e,t,r,n){return new c(i.array,n,r)}function Dt(e,t,r,n){return X(e,t,1,r)}function Mt(e,t,r,n){return X(e,t,2,E(e,t+1,n))}function zt(e,t,r,n){return X(e,t,3,_(e,t+1,n))}function Ft(e,t,r,n){return X(e,t,5,v(e,t+1,n))}function Ot(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer array lengths not supported`);return X(e,t,9,o)}function Lt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return X(e,t,1,1/0)}function ke(e,t){g(e,i.array.majorEncoded,t.value)}ke.compareTokens=S.compareTokens;ke.encodedSize=function(t){return g.encodedSize(t.value)};function Q(e,t,r,n){return new c(i.map,n,r)}function Vt(e,t,r,n){return Q(e,t,1,r)}function jt(e,t,r,n){return Q(e,t,2,E(e,t+1,n))}function Pt(e,t,r,n){return Q(e,t,3,_(e,t+1,n))}function Rt(e,t,r,n){return Q(e,t,5,v(e,t+1,n))}function qt(e,t,r,n){let o=A(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer map lengths not supported`);return Q(e,t,9,o)}function Wt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return Q(e,t,1,1/0)}function Ee(e,t){g(e,i.map.majorEncoded,t.value)}Ee.compareTokens=S.compareTokens;Ee.encodedSize=function(t){return g.encodedSize(t.value)};function Gt(e,t,r,n){return new c(i.tag,r,1)}function Jt(e,t,r,n){return new c(i.tag,E(e,t+1,n),2)}function Kt(e,t,r,n){return new c(i.tag,_(e,t+1,n),3)}function Ht(e,t,r,n){return new c(i.tag,v(e,t+1,n),5)}function Xt(e,t,r,n){return new c(i.tag,A(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 Hr=20,Xr=21,Qr=22,Zr=23;function Qt(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new c(i.null,null,1):new c(i.undefined,void 0,1)}function Zt(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new c(i.break,void 0,1)}function ze(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${d} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${d} Infinity values are not supported`)}return new c(i.float,e,t)}function Yt(e,t,r,n){return ze(Fe(e,t+1),3,n)}function er(e,t,r,n){return ze(Oe(e,t+1),5,n)}function tr(e,t,r,n){return ze(ir(e,t+1),9,n)}function ve(e,t,r){let n=t.value;if(n===!1)e.push([i.float.majorEncoded|Hr]);else if(n===!0)e.push([i.float.majorEncoded|Xr]);else if(n===null)e.push([i.float.majorEncoded|Qr]);else if(n===void 0)e.push([i.float.majorEncoded|Zr]);else{let o,s=!1;(!r||r.float64!==!0)&&(nr(n),o=Fe(C,1),n===o||Number.isNaN(n)?(C[0]=249,e.push(C.slice(0,3)),s=!0):(or(n),o=Oe(C,1),n===o&&(C[0]=250,e.push(C.slice(0,5)),s=!0))),s||(Yr(n),o=ir(C,1),C[0]=251,e.push(C.slice(0,9)))}}ve.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){nr(n);let o=Fe(C,1);if(n===o||Number.isNaN(n))return 3;if(or(n),o=Oe(C,1),n===o)return 5}return 9};var rr=new ArrayBuffer(9),T=new DataView(rr,1),C=new Uint8Array(rr,0);function nr(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,(e&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 Fe(e,t){if(e.length-t<2)throw new Error(`${d} 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 or(e){T.setFloat32(0,e,!1)}function Oe(e,t){if(e.length-t<4)throw new Error(`${d} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Yr(e){T.setFloat64(0,e,!1)}function ir(e,t){if(e.length-t<8)throw new Error(`${d} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ve.compareTokens=S.compareTokens;function p(e,t,r){throw new Error(`${d} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function Ae(e){return()=>{throw new Error(`${d} ${e}`)}}var u=[];for(let e=0;e<=23;e++)u[e]=p;u[24]=lt;u[25]=mt;u[26]=xt;u[27]=yt;u[28]=p;u[29]=p;u[30]=p;u[31]=p;for(let e=32;e<=55;e++)u[e]=p;u[56]=gt;u[57]=wt;u[58]=bt;u[59]=Et;u[60]=p;u[61]=p;u[62]=p;u[63]=p;for(let e=64;e<=87;e++)u[e]=_t;u[88]=vt;u[89]=At;u[90]=Ut;u[91]=St;u[92]=p;u[93]=p;u[94]=p;u[95]=Ae("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)u[e]=Tt;u[120]=Bt;u[121]=It;u[122]=Ct;u[123]=$t;u[124]=p;u[125]=p;u[126]=p;u[127]=Ae("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)u[e]=Dt;u[152]=Mt;u[153]=zt;u[154]=Ft;u[155]=Ot;u[156]=p;u[157]=p;u[158]=p;u[159]=Lt;for(let e=160;e<=183;e++)u[e]=Vt;u[184]=jt;u[185]=Pt;u[186]=Rt;u[187]=qt;u[188]=p;u[189]=p;u[190]=p;u[191]=Wt;for(let e=192;e<=215;e++)u[e]=Gt;u[216]=Jt;u[217]=Kt;u[218]=Ht;u[219]=Xt;u[220]=p;u[221]=p;u[222]=p;u[223]=p;for(let e=224;e<=243;e++)u[e]=Ae("simple values are not supported");u[244]=p;u[245]=p;u[246]=p;u[247]=Qt;u[248]=Ae("simple values are not supported");u[249]=Yt;u[250]=er;u[251]=tr;u[252]=p;u[253]=p;u[254]=p;u[255]=Zt;var $=[];for(let e=0;e<24;e++)$[e]=new c(i.uint,e,1);for(let e=-1;e>=-24;e--)$[31-e]=new c(i.negint,e,1);$[64]=new c(i.bytes,new Uint8Array(0),1);$[96]=new c(i.string,"",1);$[128]=new c(i.array,0,1);$[160]=new c(i.map,0,1);$[244]=new c(i.false,!1,1);$[245]=new c(i.true,!0,1);$[246]=new c(i.null,null,1);function tn(){let e=[];return e[i.uint.major]=S,e[i.negint.major]=we,e[i.bytes.major]=H,e[i.string.major]=Nt,e[i.array.major]=ke,e[i.map.major]=Ee,e[i.tag.major]=_e,e[i.float.major]=ve,e}var Go=tn(),Le=new se,Se=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(`${O} 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)},R={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=Se.createCheck(n,e);let o=[],s=0;for(let a of e)o[s++]=Ue(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;if(!a)return r.addBreakTokens===!0?[P.emptyMap,new c(i.break)]:P.emptyMap;n=Se.createCheck(n,e);let f=[],h=0;for(let m of s)f[h++]=[Ue(m,r,n),Ue(o?e.get(m):e[m],r,n)];return rn(f,r),r.addBreakTokens?[new c(i.map,a),f,new c(i.break)]:[new c(i.map,a),f]}};R.Map=R.Object;R.Buffer=R.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))R[`${e}Array`]=R.DataView;function Ue(e,t={},r){let n=st(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||R[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let s=R[n];if(!s)throw new Error(`${O} unsupported type: ${n}`);return s(e,n,t,r)}function rn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function sr(e,t,r,n){if(Array.isArray(t))for(let o of t)sr(e,o,r,n);else r[t.type.major](e,t,n)}function ar(e,t,r){let n=Ue(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let s=t[n.type.major];if(s.encodedSize){let a=s.encodedSize(n,r),f=new se(a);if(s(f,n,r),f.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ie(f.chunks[0])}}return Le.reset(),sr(Le,n,t,r),Le.toBytes(!0)}var nn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Te=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=$[t];if(r===void 0){let n=u[t];if(!n)throw new Error(`${d} 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}},fe=Symbol.for("DONE"),Be=Symbol.for("BREAK");function on(e,t,r){let n=[];for(let o=0;o<e.value;o++){let s=Z(t,r);if(s===Be){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(s===fe)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=s}return n}function sn(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<e.value;a++){let f=Z(t,r);if(f===Be){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(f===fe)throw new Error(`${d} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof f!="string")throw new Error(`${d} non-string keys not supported (got ${typeof f})`);if(r.rejectDuplicateMapKeys===!0&&(n&&s.has(f)||!n&&f in o))throw new Error(`${d} found repeat map key "${f}"`);let h=Z(t,r);if(h===fe)throw new Error(`${d} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?s.set(f,h):o[f]=h}return n?s:o}function Z(e,t){if(e.done())return fe;let r=e.next();if(r.type===i.break)return Be;if(r.type.terminal)return r.value;if(r.type===i.array)return on(r,e,t);if(r.type===i.map)return sn(r,e,t);if(r.type===i.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Z(e,t);return t.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ve(e,t){if(!(e instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);t=Object.assign({},nn,t);let r=t.tokenizer||new Te(e,t),n=Z(r,t);if(n===fe)throw new Error(`${d} did not find any content to decode`);if(n===Be)throw new Error(`${d} got unexpected break`);return[n,e.subarray(r.pos())]}function je(e,t){let[r,n]=Ve(e,t);if(n.length>0)throw new Error(`${d} too many terminals, data makes no sense`);return r}var Pe=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(t){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===i.array&&(r.elements++,r.elements!==1&&t.push([44])),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(`${O} unsupported type: Uint8Array`)}[i.string.major](t,r){this.prefix(t);let n=ge(JSON.stringify(r.value));t.push(n.length>32?ie(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(a.type===i.array)t.push([93]);else if(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(`${O} 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 an(e,t){if(Array.isArray(e[0])||Array.isArray(t[0]))throw new Error(`${O} 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(`${O} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${O} unexpected duplicate map keys, this is not supported`)}var cn={addBreakTokens:!0,mapSorter:an};function Re(e,t){return t=Object.assign({},cn,t),ar(e,new Pe,t)}var Y=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(`${d} 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(`${d} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...t)}'`)}parseNumber(){let t=this._pos,r=!1,n=!1,o=f=>{for(;!this.done();){let h=this.ch();if(f.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(`${d} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${d} 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(`${d} 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 f=this.data[s];if(f===92||f<32||f>=128)break;if(f===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(`${d} unexpected end of unicode escape sequence at position ${this._pos}`);let s=0;for(let a=0;a<4;a++){let f=this.ch();if(f>=48&&f<=57)f-=48;else if(f>=97&&f<=102)f=f-97+10;else if(f>=65&&f<=70)f=f-65+10;else throw new Error(`${d} unexpected unicode escape character at position ${this._pos}`);s=s*16+f,this._pos++}return s},o=()=>{let s=this.ch(),a=null,f=s>239?4:s>223?3:s>191?2:1;if(this._pos+f>this.data.length)throw new Error(`${d} unexpected unicode sequence at position ${this._pos}`);let h,m,x,w;switch(f){case 1:s<128&&(a=s);break;case 2:h=this.data[this._pos+1],(h&192)===128&&(w=(s&31)<<6|h&63,w>127&&(a=w));break;case 3:h=this.data[this._pos+1],m=this.data[this._pos+2],(h&192)===128&&(m&192)===128&&(w=(s&15)<<12|(h&63)<<6|m&63,w>2047&&(w<55296||w>57343)&&(a=w));break;case 4:h=this.data[this._pos+1],m=this.data[this._pos+2],x=this.data[this._pos+3],(h&192)===128&&(m&192)===128&&(x&192)===128&&(w=(s&15)<<18|(h&63)<<12|(m&63)<<6|x&63,w>65535&&w<1114112&&(a=w))}a===null?(a=65533,f=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this._pos+=f};for(;!this.done();){let s=this.ch(),a;switch(s){case 92:if(this._pos++,this.done())throw new Error(`${d} 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(`${d} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new c(i.string,De(r),this._pos-t);default:if(s<32)throw new Error(`${d} invalid control character at position ${this._pos}`);s<128?(r.push(s),this._pos++):o()}}throw new Error(`${d} 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(`${d} 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(`${d} 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(`${d} 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(`${d} 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(`${d} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function qe(e,t){return t=Object.assign({tokenizer:new Y(e,t)},t),je(e,t)}var xi=new Uint8Array(0);function cr(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 ee(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function dn(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 f=e.length,h=e.charAt(0),m=Math.log(f)/Math.log(256),x=Math.log(256)/Math.log(f);function w(l){if(l instanceof Uint8Array||(ArrayBuffer.isView(l)?l=new Uint8Array(l.buffer,l.byteOffset,l.byteLength):Array.isArray(l)&&(l=Uint8Array.from(l))),!(l instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(l.length===0)return"";for(var k=0,W=0,B=0,D=l.length;B!==D&&l[B]===0;)B++,k++;for(var M=(D-B)*x+1>>>0,U=new Uint8Array(M);B!==D;){for(var z=l[B],j=0,I=M-1;(z!==0||j<W)&&I!==-1;I--,j++)z+=256*U[I]>>>0,U[I]=z%f>>>0,z=z/f>>>0;if(z!==0)throw new Error("Non-zero carry");W=j,B++}for(var F=M-W;F!==M&&U[F]===0;)F++;for(var xe=h.repeat(k);F<M;++F)xe+=e.charAt(U[F]);return xe}function me(l){if(typeof l!="string")throw new TypeError("Expected String");if(l.length===0)return new Uint8Array;var k=0;if(l[k]!==" "){for(var W=0,B=0;l[k]===h;)W++,k++;for(var D=(l.length-k)*m+1>>>0,M=new Uint8Array(D);l[k];){var U=r[l.charCodeAt(k)];if(U===255)return;for(var z=0,j=D-1;(U!==0||z<B)&&j!==-1;j--,z++)U+=f*M[j]>>>0,M[j]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");B=z,k++}if(l[k]!==" "){for(var I=D-B;I!==D&&M[I]===0;)I++;for(var F=new Uint8Array(W+(D-I)),xe=W;I!==D;)F[xe++]=M[I++];return F}}}function Tr(l){var k=me(l);if(k)return k;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:me,decode:Tr}}var hn=dn,pn=hn,ur=pn;var We=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")}},Ge=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 fr(this,t)}},Je=class{decoders;constructor(t){this.decoders=t}or(t){return fr(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 fr(e,t){return new Je({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var Ke=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 We(t,r,n),this.decoder=new Ge(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function dr({name:e,prefix:t,encode:r,decode:n}){return new Ke(e,t,r,n)}function te({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=ur(r,e);return dr({prefix:t,name:e,encode:n,decode:s=>ee(o(s))})}function ln(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),a=0,f=0,h=0;for(let m=0;m<o;++m){let x=t[e[m]];if(x===void 0)throw new SyntaxError(`Non-${n} character`);f=f<<r|x,a+=r,a>=8&&(a-=8,s[h++]=255&f>>a)}if(a>=r||(255&f<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function mn(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",a=0,f=0;for(let h=0;h<e.length;++h)for(f=f<<8|e[h],a+=8;a>r;)a-=r,s+=t[o&f>>a];if(a!==0&&(s+=t[o&f<<r-a]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function xn(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function b({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=xn(n);return dr({prefix:t,name:e,encode(s){return mn(s,n,r)},decode(s){return ln(s,o,r,e)}})}var de=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ei=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_i=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vi=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ai=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ui=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Si=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ti=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bi=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ie=te({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$i=te({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var V=te({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mi=te({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yn=lr,hr=128,gn=127,wn=~gn,bn=Math.pow(2,31);function lr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=bn;)t[r++]=e&255|hr,e/=128;for(;e&wn;)t[r++]=e&255|hr,e>>>=7;return t[r]=e|0,lr.bytes=r-n+1,t}var kn=He,En=128,pr=127;function He(e,n){var r=0,n=n||0,o=0,s=n,a,f=e.length;do{if(s>=f)throw He.bytes=0,new RangeError("Could not decode varint");a=e[s++],r+=o<28?(a&pr)<<o:(a&pr)*Math.pow(2,o),o+=7}while(a>=En);return He.bytes=s-n,r}var _n=Math.pow(2,7),vn=Math.pow(2,14),An=Math.pow(2,21),Un=Math.pow(2,28),Sn=Math.pow(2,35),Tn=Math.pow(2,42),Bn=Math.pow(2,49),In=Math.pow(2,56),Cn=Math.pow(2,63),$n=function(e){return e<_n?1:e<vn?2:e<An?3:e<Un?4:e<Sn?5:e<Tn?6:e<Bn?7:e<In?8:e<Cn?9:10},Nn={encode:yn,decode:kn,encodingLength:$n},Dn=Nn,he=Dn;function pe(e,t=0){return[he.decode(e,t),he.decode.bytes]}function re(e,t,r=0){return he.encode(e,t,r),t}function ne(e){return he.encodingLength(e)}function Ce(e,t){let r=t.byteLength,n=ne(e),o=n+ne(r),s=new Uint8Array(o+r);return re(e,s,0),re(r,s,n),s.set(t,o),new oe(e,r,t,s)}function mr(e){let t=ee(e),[r,n]=pe(t),[o,s]=pe(t.subarray(n)),a=t.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new oe(r,o,a,t)}function xr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&cr(e.bytes,r.bytes)}}var oe=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function yr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return zn(r,Ze(e),t??V.encoder);default:return Fn(r,Ze(e),t??de.encoder)}}var gr=new WeakMap;function Ze(e){let t=gr.get(e);if(t==null){let r=new Map;return gr.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=o,this["/"]=o}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!==le)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==On)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=Ce(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&&xr(t.multihash,n.multihash)}toString(t){return yr(this,t)}toJSON(){return{"/":yr(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??wr(n,o,s.bytes))}else if(r[Ln]===!0){let{version:n,multihash:o,code:s}=r,a=mr(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!==le)throw new Error(`Version 0 CID must use dag-pb (code: ${le}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=wr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,le,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=ee(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 oe(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[w,me]=pe(t.subarray(r));return r+=me,w},o=n(),s=le;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,f=n(),h=n(),m=r+h,x=m-a;return{version:o,codec:s,multihashCode:f,digestSize:h,multihashSize:x,size:m}}static parse(t,r){let[n,o]=Mn(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 Ze(s).set(n,t),s}};function Mn(e,t){switch(e[0]){case"Q":{let r=t??V;return[V.prefix,r.decode(`${V.prefix}${e}`)]}case V.prefix:{let r=t??V;return[V.prefix,r.decode(e)]}case de.prefix:{let r=t??de;return[de.prefix,r.decode(e)]}case Ie.prefix:{let r=t??Ie;return[Ie.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 zn(e,t,r){let{prefix:n}=r;if(n!==V.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 Fn(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 le=112,On=18;function wr(e,t,r){let n=ne(e),o=n+ne(t),s=new Uint8Array(o+r.byteLength);return re(e,s,0),re(t,s,n),s.set(r,o),s}var Ln=Symbol.for("@ipld/js-cid/CID");var Vn=20;function et({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new Ye(e,t,r,n,o)}var Ye=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??Vn,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?br(n,this.code,r?.truncate):n.then(o=>br(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function br(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 Ce(t,e)}var tt=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ts=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),rs=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ns=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Pn(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Rn(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 $e(e){let t=tt.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 $e(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function qn(e){return $e(new Uint8Array(e))}function Wn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Gn(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 Jn={typeEncoders:{Object:Rn,Buffer:$e,Uint8Array:$e,Int8Array:N,Uint16Array:N,Int16Array:N,Uint32Array:N,Int32Array:N,Float32Array:N,Float64Array:N,Uint8ClampedArray:N,BigInt64Array:N,BigUint64Array:N,DataView:N,ArrayBuffer:qn,undefined:Wn,number:Gn}},rt=class extends Y{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(t.type===i.map){let r=this._next();if(r.type===i.string&&r.value==="/"){let n=this._next();if(n.type===i.string){if(this._next().type!==i.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new c(i.tag,42,0)}if(n.type===i.map){let o=this._next();if(o.type===i.string&&o.value==="bytes"){let s=this._next();if(s.type===i.string){for(let f=0;f<2;f++)if(this._next().type!==i.break)throw new Error("Invalid encoded Bytes form");let a=tt.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}},nt={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};nt.tags[42]=q.parse;var kr=297,Er=e=>Re(e,Jn),_r=e=>{let t=Pn(e),r=Object.assign(nt,{tokenizer:new rt(t,nt)});return qe(t,r)};var cs=new TextDecoder;var us=new TextEncoder;function vr(e=0){return new Uint8Array(e)}function ot(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=vr(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}function Hn(e){return e[Symbol.asyncIterator]!=null}function Xn(e){if(Hn(e))return(async()=>{let n=new Uint8Array(0);for await(let o of e)n=ot([n,o],n.length+o.length);return n})();let t=[],r=0;for(let n of e)t.push(n),r+=n.byteLength;return ot(t,r)}var Ar=Xn;function Ur(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Sr=et({name:"sha2-256",code:18,encode:Ur("SHA-256")}),ws=et({name:"sha2-512",code:19,encode:Ur("SHA-512")});var it=class{components;constructor(t){this.components=t}async add(t,r={}){let n=Er(t),o=await(r.hasher??Sr).digest(n),s=q.createV1(kr,o);return await this.components.blockstore.put(s,n,r),s}async get(t,r={}){let n=await Ar(this.components.blockstore.get(t,r));return _r(n)}};function Qn(e){return new it(e)}return Dr(Zn);})();
3
3
  return HeliaDagJson}));
4
4
  //# sourceMappingURL=index.min.js.map