@helia/dag-json 1.0.1 → 1.0.2
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 +1 -1
- package/package.json +2 -2
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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 Re=Object.defineProperty;var rn=Object.getOwnPropertyDescriptor;var nn=Object.getOwnPropertyNames;var on=Object.prototype.hasOwnProperty;var sn=(t,e)=>{for(var r in e)Re(t,r,{get:e[r],enumerable:!0})},an=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of nn(e))!on.call(t,o)&&o!==r&&Re(t,o,{get:()=>e[o],enumerable:!(n=rn(e,o))||n.enumerable});return t};var cn=t=>an(Re({},"__esModule",{value:!0}),t);var Qo={};sn(Qo,{dagJson:()=>Ko});var un=["string","number","bigint","symbol"],dn=["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 kt(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(un.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(fn(t))return"Buffer";let r=hn(t);return r||"Object"}function fn(t){return t&&t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer.call(null,t)}function hn(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(dn.includes(e))return e}var s=class{constructor(e,r,n){this.major=e,this.majorEncoded=e<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var u=class{constructor(e,r,n){this.type=e,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var X=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",pn=new TextDecoder,ln=new TextEncoder;function Te(t){return X&&globalThis.Buffer.isBuffer(t)}function fe(t){return t instanceof Uint8Array?Te(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var Tt=X?(t,e,r)=>r-e>64?globalThis.Buffer.from(t.subarray(e,r)).toString("utf8"):St(t,e,r):(t,e,r)=>r-e>64?pn.decode(t.subarray(e,r)):St(t,e,r),Ce=X?t=>t.length>64?globalThis.Buffer.from(t):At(t):t=>t.length>64?ln.encode(t):At(t);var H=X?(t,e,r)=>Te(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Ct=X?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),fe(globalThis.Buffer.concat(t,e))):(t,e)=>{let r=new Uint8Array(e),n=0;for(let o of t)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Bt=X?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function It(t,e){if(Te(t)&&Te(e))return t.compare(e);for(let r=0;r<t.length;r++)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function At(t,e=1/0){let r,n=t.length,o=null,i=[];for(let a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(e-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(e-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(e-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(e-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((e-=1)<0)break;i.push(r)}else if(r<2048){if((e-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((e-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((e-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function St(t,e,r){let n=[];for(;e<r;){let o=t[e],i=null,a=o>239?4:o>223?3:o>191?2:1;if(e+a<=r){let c,h,w,l;switch(a){case 1:o<128&&(i=o);break;case 2:c=t[e+1],(c&192)===128&&(l=(o&31)<<6|c&63,l>127&&(i=l));break;case 3:c=t[e+1],h=t[e+2],(c&192)===128&&(h&192)===128&&(l=(o&15)<<12|(c&63)<<6|h&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:c=t[e+1],h=t[e+2],w=t[e+3],(c&192)===128&&(h&192)===128&&(w&192)===128&&(l=(o&15)<<18|(c&63)<<12|(h&63)<<6|w&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),e+=a}return je(n)}var Ut=4096;function je(t){let e=t.length;if(e<=Ut)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Ut));return r}var mn=256,he=class{constructor(e=mn){this.chunkSize=e,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(e){let r=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(e,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)}e.length<64&&e.length<this.chunkSize?(r=Bt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=H(n,0,this.cursor)}else r=Ct(this.chunks,this.cursor);return e&&this.reset(),r}};var f="CBOR decode error:",j="CBOR encode error:",pe=[];pe[23]=1;pe[24]=2;pe[25]=3;pe[26]=5;pe[27]=9;function q(t,e,r){if(t.length-e<r)throw new Error(`${f} not enough data for type`)}var U=[24,256,65536,4294967296,BigInt("18446744073709551616")];function $(t,e,r){q(t,e,1);let n=t[e];if(r.strict===!0&&n<U[0])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function N(t,e,r){q(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<U[1])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function D(t,e,r){q(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<U[2])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);return n}function _(t,e,r){q(t,e,8);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3],o=t[e+4]*16777216+(t[e+5]<<16)+(t[e+6]<<8)+t[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<U[3])throw new Error(`${f} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${f} integers outside of the safe integer range are not supported`)}function $t(t,e,r,n){return new u(s.uint,$(t,e+1,n),2)}function Nt(t,e,r,n){return new u(s.uint,N(t,e+1,n),3)}function Dt(t,e,r,n){return new u(s.uint,D(t,e+1,n),5)}function _t(t,e,r,n){return new u(s.uint,_(t,e+1,n),9)}function z(t,e){return C(t,0,e.value)}function C(t,e,r){if(r<U[0]){let n=Number(r);t.push([e|n])}else if(r<U[1]){let n=Number(r);t.push([e|24,n])}else if(r<U[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<U[3]){let n=Number(r);t.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<U[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&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,t.push(o)}else throw new Error(`${f} encountered BigInt larger than allowable range`)}}z.encodedSize=function(e){return C.encodedSize(e.value)};C.encodedSize=function(e){return e<U[0]?1:e<U[1]?2:e<U[2]?3:e<U[3]?5:9};z.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function zt(t,e,r,n){return new u(s.negint,-1-$(t,e+1,n),2)}function Mt(t,e,r,n){return new u(s.negint,-1-N(t,e+1,n),3)}function Ot(t,e,r,n){return new u(s.negint,-1-D(t,e+1,n),5)}var qe=BigInt(-1),Vt=BigInt(1);function Ft(t,e,r,n){let o=_(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new u(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${f} integers outside of the safe integer range are not supported`);return new u(s.negint,qe-BigInt(o),9)}function Be(t,e){let r=e.value,n=typeof r=="bigint"?r*qe-Vt:r*-1-1;C(t,e.type.majorEncoded,n)}Be.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*qe-Vt:r*-1-1;return n<U[0]?1:n<U[1]?2:n<U[2]?3:n<U[3]?5:9};Be.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function le(t,e,r,n){q(t,e,r+n);let o=H(t,e+r,e+r+n);return new u(s.bytes,o,r+n)}function Lt(t,e,r,n){return le(t,e,1,r)}function Pt(t,e,r,n){return le(t,e,2,$(t,e+1,n))}function Rt(t,e,r,n){return le(t,e,3,N(t,e+1,n))}function jt(t,e,r,n){return le(t,e,5,D(t,e+1,n))}function qt(t,e,r,n){let o=_(t,e+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer bytes lengths not supported`);return le(t,e,9,o)}function Ie(t){return t.encodedBytes===void 0&&(t.encodedBytes=t.type===s.string?Ce(t.value):t.value),t.encodedBytes}function Z(t,e){let r=Ie(e);C(t,e.type.majorEncoded,r.length),t.push(r)}Z.encodedSize=function(e){let r=Ie(e);return C.encodedSize(r.length)+r.length};Z.compareTokens=function(e,r){return wn(Ie(e),Ie(r))};function wn(t,e){return t.length<e.length?-1:t.length>e.length?1:It(t,e)}function me(t,e,r,n,o){let i=r+n;q(t,e,i);let a=new u(s.string,Tt(t,e+r,e+i),i);return o.retainStringBytes===!0&&(a.byteValue=H(t,e+r,e+i)),a}function Jt(t,e,r,n){return me(t,e,1,r,n)}function Wt(t,e,r,n){return me(t,e,2,$(t,e+1,n),n)}function Gt(t,e,r,n){return me(t,e,3,N(t,e+1,n),n)}function Kt(t,e,r,n){return me(t,e,5,D(t,e+1,n),n)}function Qt(t,e,r,n){let o=_(t,e+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer string lengths not supported`);return me(t,e,9,o,n)}var Xt=Z;function Y(t,e,r,n){return new u(s.array,n,r)}function Ht(t,e,r,n){return Y(t,e,1,r)}function Zt(t,e,r,n){return Y(t,e,2,$(t,e+1,n))}function Yt(t,e,r,n){return Y(t,e,3,N(t,e+1,n))}function er(t,e,r,n){return Y(t,e,5,D(t,e+1,n))}function tr(t,e,r,n){let o=_(t,e+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer array lengths not supported`);return Y(t,e,9,o)}function rr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return Y(t,e,1,1/0)}function $e(t,e){C(t,s.array.majorEncoded,e.value)}$e.compareTokens=z.compareTokens;$e.encodedSize=function(e){return C.encodedSize(e.value)};function ee(t,e,r,n){return new u(s.map,n,r)}function nr(t,e,r,n){return ee(t,e,1,r)}function or(t,e,r,n){return ee(t,e,2,$(t,e+1,n))}function ir(t,e,r,n){return ee(t,e,3,N(t,e+1,n))}function sr(t,e,r,n){return ee(t,e,5,D(t,e+1,n))}function ar(t,e,r,n){let o=_(t,e+1,n);if(typeof o=="bigint")throw new Error(`${f} 64-bit integer map lengths not supported`);return ee(t,e,9,o)}function cr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return ee(t,e,1,1/0)}function Ne(t,e){C(t,s.map.majorEncoded,e.value)}Ne.compareTokens=z.compareTokens;Ne.encodedSize=function(e){return C.encodedSize(e.value)};function ur(t,e,r,n){return new u(s.tag,r,1)}function dr(t,e,r,n){return new u(s.tag,$(t,e+1,n),2)}function fr(t,e,r,n){return new u(s.tag,N(t,e+1,n),3)}function hr(t,e,r,n){return new u(s.tag,D(t,e+1,n),5)}function pr(t,e,r,n){return new u(s.tag,_(t,e+1,n),9)}function De(t,e){C(t,s.tag.majorEncoded,e.value)}De.compareTokens=z.compareTokens;De.encodedSize=function(e){return C.encodedSize(e.value)};var kn=20,An=21,Sn=22,Un=23;function lr(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${f} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new u(s.null,null,1):new u(s.undefined,void 0,1)}function mr(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${f} indefinite length items not allowed`);return new u(s.break,void 0,1)}function Je(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${f} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${f} Infinity values are not supported`)}return new u(s.float,t,e)}function yr(t,e,r,n){return Je(We(t,e+1),3,n)}function wr(t,e,r,n){return Je(Ge(t,e+1),5,n)}function gr(t,e,r,n){return Je(Er(t,e+1),9,n)}function _e(t,e,r){let n=e.value;if(n===!1)t.push([s.float.majorEncoded|kn]);else if(n===!0)t.push([s.float.majorEncoded|An]);else if(n===null)t.push([s.float.majorEncoded|Sn]);else if(n===void 0)t.push([s.float.majorEncoded|Un]);else{let o,i=!1;(!r||r.float64!==!0)&&(xr(n),o=We(O,1),n===o||Number.isNaN(n)?(O[0]=249,t.push(O.slice(0,3)),i=!0):(vr(n),o=Ge(O,1),n===o&&(O[0]=250,t.push(O.slice(0,5)),i=!0))),i||(Tn(n),o=Er(O,1),O[0]=251,t.push(O.slice(0,9)))}}_e.encodedSize=function(e,r){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){xr(n);let o=We(O,1);if(n===o||Number.isNaN(n))return 3;if(vr(n),o=Ge(O,1),n===o)return 5}return 9};var br=new ArrayBuffer(9),M=new DataView(br,1),O=new Uint8Array(br,0);function xr(t){if(t===1/0)M.setUint16(0,31744,!1);else if(t===-1/0)M.setUint16(0,64512,!1);else if(Number.isNaN(t))M.setUint16(0,32256,!1);else{M.setFloat32(0,t);let e=M.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)M.setUint16(0,31744,!1);else if(r===0)M.setUint16(0,(t&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?M.setUint16(0,0):o<-14?M.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):M.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function We(t,e){if(t.length-e<2)throw new Error(`${f} not enough data for float16`);let r=(t[e]<<8)+t[e+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,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function vr(t){M.setFloat32(0,t,!1)}function Ge(t,e){if(t.length-e<4)throw new Error(`${f} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function Tn(t){M.setFloat64(0,t,!1)}function Er(t,e){if(t.length-e<8)throw new Error(`${f} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}_e.compareTokens=z.compareTokens;function m(t,e,r){throw new Error(`${f} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function ze(t){return()=>{throw new Error(`${f} ${t}`)}}var d=[];for(let t=0;t<=23;t++)d[t]=m;d[24]=$t;d[25]=Nt;d[26]=Dt;d[27]=_t;d[28]=m;d[29]=m;d[30]=m;d[31]=m;for(let t=32;t<=55;t++)d[t]=m;d[56]=zt;d[57]=Mt;d[58]=Ot;d[59]=Ft;d[60]=m;d[61]=m;d[62]=m;d[63]=m;for(let t=64;t<=87;t++)d[t]=Lt;d[88]=Pt;d[89]=Rt;d[90]=jt;d[91]=qt;d[92]=m;d[93]=m;d[94]=m;d[95]=ze("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)d[t]=Jt;d[120]=Wt;d[121]=Gt;d[122]=Kt;d[123]=Qt;d[124]=m;d[125]=m;d[126]=m;d[127]=ze("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)d[t]=Ht;d[152]=Zt;d[153]=Yt;d[154]=er;d[155]=tr;d[156]=m;d[157]=m;d[158]=m;d[159]=rr;for(let t=160;t<=183;t++)d[t]=nr;d[184]=or;d[185]=ir;d[186]=sr;d[187]=ar;d[188]=m;d[189]=m;d[190]=m;d[191]=cr;for(let t=192;t<=215;t++)d[t]=ur;d[216]=dr;d[217]=fr;d[218]=hr;d[219]=pr;d[220]=m;d[221]=m;d[222]=m;d[223]=m;for(let t=224;t<=243;t++)d[t]=ze("simple values are not supported");d[244]=m;d[245]=m;d[246]=m;d[247]=lr;d[248]=ze("simple values are not supported");d[249]=yr;d[250]=wr;d[251]=gr;d[252]=m;d[253]=m;d[254]=m;d[255]=mr;var V=[];for(let t=0;t<24;t++)V[t]=new u(s.uint,t,1);for(let t=-1;t>=-24;t--)V[31-t]=new u(s.negint,t,1);V[64]=new u(s.bytes,new Uint8Array(0),1);V[96]=new u(s.string,"",1);V[128]=new u(s.array,0,1);V[160]=new u(s.map,0,1);V[244]=new u(s.false,!1,1);V[245]=new u(s.true,!0,1);V[246]=new u(s.null,null,1);function Bn(){let t=[];return t[s.uint.major]=z,t[s.negint.major]=Be,t[s.bytes.major]=Z,t[s.string.major]=Xt,t[s.array.major]=$e,t[s.map.major]=Ne,t[s.tag.major]=De,t[s.float.major]=_e,t}var Ri=Bn(),Ke=new he,Oe=class t{constructor(e,r){this.obj=e,this.parent=r}includes(e){let r=this;do if(r.obj===e)return!0;while(r=r.parent);return!1}static createCheck(e,r){if(e&&e.includes(r))throw new Error(`${j} object contains circular references`);return new t(r,e)}},G={null:new u(s.null,null),undefined:new u(s.undefined,void 0),true:new u(s.true,!0),false:new u(s.false,!1),emptyArray:new u(s.array,0),emptyMap:new u(s.map,0)},K={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new u(s.float,t):t>=0?new u(s.uint,t):new u(s.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new u(s.uint,t):new u(s.negint,t)},Uint8Array(t,e,r,n){return new u(s.bytes,t)},string(t,e,r,n){return new u(s.string,t)},boolean(t,e,r,n){return t?G.true:G.false},null(t,e,r,n){return G.null},undefined(t,e,r,n){return G.undefined},ArrayBuffer(t,e,r,n){return new u(s.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new u(s.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[G.emptyArray,new u(s.break)]:G.emptyArray;n=Oe.createCheck(n,t);let o=[],i=0;for(let a of t)o[i++]=Me(a,r,n);return r.addBreakTokens?[new u(s.array,t.length),o,new u(s.break)]:[new u(s.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),a=o?t.size:i.length;if(!a)return r.addBreakTokens===!0?[G.emptyMap,new u(s.break)]:G.emptyMap;n=Oe.createCheck(n,t);let c=[],h=0;for(let w of i)c[h++]=[Me(w,r,n),Me(o?t.get(w):t[w],r,n)];return In(c,r),r.addBreakTokens?[new u(s.map,a),c,new u(s.break)]:[new u(s.map,a),c]}};K.Map=K.Object;K.Buffer=K.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))K[`${t}Array`]=K.DataView;function Me(t,e={},r){let n=kt(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||K[n];if(typeof o=="function"){let a=o(t,n,e,r);if(a!=null)return a}let i=K[n];if(!i)throw new Error(`${j} unsupported type: ${n}`);return i(t,n,e,r)}function In(t,e){e.mapSorter&&t.sort(e.mapSorter)}function kr(t,e,r,n){if(Array.isArray(e))for(let o of e)kr(t,o,r,n);else r[e.type.major](t,e,n)}function Ar(t,e,r){let n=Me(t,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=e[n.type.major];if(i.encodedSize){let a=i.encodedSize(n,r),c=new he(a);if(i(c,n,r),c.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return fe(c.chunks[0])}}return Ke.reset(),kr(Ke,n,e,r),Ke.toBytes(!0)}var $n={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Qe=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r}done(){return this.pos>=this.data.length}next(){let e=this.data[this.pos],r=V[e];if(r===void 0){let n=d[e];if(!n)throw new Error(`${f} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;r=n(this.data,this.pos,o,this.options)}return this.pos+=r.encodedLength,r}},ye=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function Nn(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=we(e,r);if(i===Ve){if(t.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed array`)}if(i===ye)throw new Error(`${f} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function Dn(t,e,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<t.value;a++){let c=we(e,r);if(c===Ve){if(t.value===1/0)break;throw new Error(`${f} got unexpected break to lengthed map`)}if(c===ye)throw new Error(`${f} found map but not enough entries (got ${a} [no key], expected ${t.value})`);if(n!==!0&&typeof c!="string")throw new Error(`${f} non-string keys not supported (got ${typeof c})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(c)||!n&&c in o))throw new Error(`${f} found repeat map key "${c}"`);let h=we(e,r);if(h===ye)throw new Error(`${f} found map but not enough entries (got ${a} [no value], expected ${t.value})`);n?i.set(c,h):o[c]=h}return n?i:o}function we(t,e){if(t.done())return ye;let r=t.next();if(r.type===s.break)return Ve;if(r.type.terminal)return r.value;if(r.type===s.array)return Nn(r,t,e);if(r.type===s.map)return Dn(r,t,e);if(r.type===s.tag){if(e.tags&&typeof e.tags[r.value]=="function"){let n=we(t,e);return e.tags[r.value](n)}throw new Error(`${f} tag not supported (${r.value})`)}throw new Error("unsupported")}function Xe(t,e){if(!(t instanceof Uint8Array))throw new Error(`${f} data to decode must be a Uint8Array`);e=Object.assign({},$n,e);let r=e.tokenizer||new Qe(t,e),n=we(r,e);if(n===ye)throw new Error(`${f} did not find any content to decode`);if(n===Ve)throw new Error(`${f} got unexpected break`);if(!r.done())throw new Error(`${f} too many terminals, data makes no sense`);return n}var He=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===s.array&&(r.elements++,r.elements!==1&&e.push([44])),r.type===s.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[s.uint.major](e,r){this.prefix(e);let n=String(r.value),o=[];for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);e.push(o)}[s.negint.major](e,r){this[s.uint.major](e,r)}[s.bytes.major](e,r){throw new Error(`${j} unsupported type: Uint8Array`)}[s.string.major](e,r){this.prefix(e);let n=Ce(JSON.stringify(r.value));e.push(n.length>32?fe(n):n)}[s.array.major](e,r){this.prefix(e),this.inRecursive.push({type:s.array,elements:0}),e.push([91])}[s.map.major](e,r){this.prefix(e),this.inRecursive.push({type:s.map,elements:0}),e.push([123])}[s.tag.major](e,r){}[s.float.major](e,r){if(r.type.name==="break"){let a=this.inRecursive.pop();if(a){if(a.type===s.array)e.push([93]);else if(a.type===s.map)e.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(e),r.type.name==="true"){e.push([116,114,117,101]);return}else if(r.type.name==="false"){e.push([102,97,108,115,101]);return}else if(r.type.name==="null"){e.push([110,117,108,108]);return}let n=String(r.value),o=[],i=!1;for(let a=0;a<n.length;a++)o[a]=n.charCodeAt(a),!i&&(o[a]===46||o[a]===101||o[a]===69)&&(i=!0);i||(o.push(46),o.push(48)),e.push(o)}};function _n(t,e){if(Array.isArray(t[0])||Array.isArray(e[0]))throw new Error(`${j} complex map keys are not supported`);let r=t[0],n=e[0];if(r.type!==s.string||n.type!==s.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 zn={addBreakTokens:!0,mapSorter:_n};function Ze(t,e){return e=Object.assign({},zn,e),Ar(t,new He,e)}var te=class{constructor(e,r={}){this.pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}done(){return this.pos>=this.data.length}ch(){return this.data[this.pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let e=this.ch();for(;e===32||e===9||e===13||e===10;)e=this.data[++this.pos]}expect(e){if(this.data.length-this.pos<e.length)throw new Error(`${f} unexpected end of input at position ${this.pos}`);for(let r=0;r<e.length;r++)if(this.data[this.pos++]!==e[r])throw new Error(`${f} unexpected token at position ${this.pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this.pos,r=!1,n=!1,o=c=>{for(;!this.done();){let h=this.ch();if(c.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 u(s.uint,0,this.pos-e);if(o([48,49,50,51,52,53,54,55,56,57]),r&&this.pos===e+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 i=String.fromCharCode.apply(null,this.data.subarray(e,this.pos)),a=parseFloat(i);return n?new u(s.float,a,this.pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(a)?new u(a>=0?s.uint:s.negint,a,this.pos-e):new u(a>=0?s.uint:s.negint,BigInt(i),this.pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${f} unexpected character at position ${this.pos}; this shouldn't happen`);this.pos++;for(let i=this.pos,a=0;i<this.data.length&&a<65536;i++,a++){let c=this.data[i];if(c===92||c<32||c>=128)break;if(c===34){let h=String.fromCharCode.apply(null,this.data.subarray(this.pos,i));return this.pos=i+1,new u(s.string,h,a)}}let e=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 i=0;for(let a=0;a<4;a++){let c=this.ch();if(c>=48&&c<=57)c-=48;else if(c>=97&&c<=102)c=c-97+10;else if(c>=65&&c<=70)c=c-65+10;else throw new Error(`${f} unexpected unicode escape character at position ${this.pos}`);i=i*16+c,this.pos++}return i},o=()=>{let i=this.ch(),a=null,c=i>239?4:i>223?3:i>191?2:1;if(this.pos+c>this.data.length)throw new Error(`${f} unexpected unicode sequence at position ${this.pos}`);let h,w,l,g;switch(c){case 1:i<128&&(a=i);break;case 2:h=this.data[this.pos+1],(h&192)===128&&(g=(i&31)<<6|h&63,g>127&&(a=g));break;case 3:h=this.data[this.pos+1],w=this.data[this.pos+2],(h&192)===128&&(w&192)===128&&(g=(i&15)<<12|(h&63)<<6|w&63,g>2047&&(g<55296||g>57343)&&(a=g));break;case 4:h=this.data[this.pos+1],w=this.data[this.pos+2],l=this.data[this.pos+3],(h&192)===128&&(w&192)===128&&(l&192)===128&&(g=(i&15)<<18|(h&63)<<12|(w&63)<<6|l&63,g>65535&&g<1114112&&(a=g))}a===null?(a=65533,c=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this.pos+=c};for(;!this.done();){let i=this.ch(),a;switch(i){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 u(s.string,je(r),this.pos-e);default:if(i<32)throw new Error(`${f} invalid control character at position ${this.pos}`);i<128?(r.push(i),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 u(s.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new u(s.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new u(s.null,null,4);case 102:return this.expect([102,97,108,115,101]),new u(s.false,!1,5);case 116:return this.expect([116,114,117,101]),new u(s.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 u(s.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 u(s.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 u(s.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 u(s.break,void 0,1);let e=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"),e}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 Ye(t,e){return e=Object.assign({tokenizer:new te(t,e)},e),Xe(t,e)}var On=Tr,Sr=128,Vn=127,Fn=~Vn,Ln=Math.pow(2,31);function Tr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Ln;)e[r++]=t&255|Sr,t/=128;for(;t&Fn;)e[r++]=t&255|Sr,t>>>=7;return e[r]=t|0,Tr.bytes=r-n+1,e}var Pn=et,Rn=128,Ur=127;function et(t,n){var r=0,n=n||0,o=0,i=n,a,c=t.length;do{if(i>=c)throw et.bytes=0,new RangeError("Could not decode varint");a=t[i++],r+=o<28?(a&Ur)<<o:(a&Ur)*Math.pow(2,o),o+=7}while(a>=Rn);return et.bytes=i-n,r}var jn=Math.pow(2,7),qn=Math.pow(2,14),Jn=Math.pow(2,21),Wn=Math.pow(2,28),Gn=Math.pow(2,35),Kn=Math.pow(2,42),Qn=Math.pow(2,49),Xn=Math.pow(2,56),Hn=Math.pow(2,63),Zn=function(t){return t<jn?1:t<qn?2:t<Jn?3:t<Wn?4:t<Gn?5:t<Kn?6:t<Qn?7:t<Xn?8:t<Hn?9:10},Yn={encode:On,decode:Pn,encodingLength:Zn},eo=Yn,ge=eo;var be=(t,e=0)=>[ge.decode(t,e),ge.decode.bytes],re=(t,e,r=0)=>(ge.encode(t,e,r),e),ne=t=>ge.encodingLength(t);var ps=new Uint8Array(0);var Cr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},oe=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var rt=(t,e)=>{let r=e.byteLength,n=ne(t),o=n+ne(r),i=new Uint8Array(o+r);return re(t,i,0),re(r,i,n),i.set(e,o),new ie(t,r,e,i)},Br=t=>{let e=oe(t),[r,n]=be(e),[o,i]=be(e.subarray(n)),a=e.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new ie(r,o,a,e)},Ir=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Cr(t.bytes,r.bytes)}},ie=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function ro(t,e){if(t.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<t.length;o++){var i=t.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var c=t.length,h=t.charAt(0),w=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function g(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,B=0,x=0,E=p.length;x!==E&&p[x]===0;)x++,y++;for(var k=(E-x)*l+1>>>0,b=new Uint8Array(k);x!==E;){for(var A=p[x],T=0,v=k-1;(A!==0||T<B)&&v!==-1;v--,T++)A+=256*b[v]>>>0,b[v]=A%c>>>0,A=A/c>>>0;if(A!==0)throw new Error("Non-zero carry");B=T,x++}for(var S=k-B;S!==k&&b[S]===0;)S++;for(var R=h.repeat(y);S<k;++S)R+=t.charAt(b[S]);return R}function P(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var B=0,x=0;p[y]===h;)B++,y++;for(var E=(p.length-y)*w+1>>>0,k=new Uint8Array(E);p[y];){var b=r[p.charCodeAt(y)];if(b===255)return;for(var A=0,T=E-1;(b!==0||A<x)&&T!==-1;T--,A++)b+=c*k[T]>>>0,k[T]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=A,y++}if(p[y]!==" "){for(var v=E-x;v!==E&&k[v]===0;)v++;for(var S=new Uint8Array(B+(E-v)),R=B;v!==E;)S[R++]=k[v++];return S}}}function Pe(p){var y=P(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:g,decodeUnsafe:P,decode:Pe}}var no=ro,oo=no,$r=oo;var ot=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},it=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Nr(this,e)}},st=class{constructor(e){this.decoders=e}or(e){return Nr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Nr=(t,e)=>new st({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),at=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ot(e,r,n),this.decoder=new it(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Dr=({name:t,prefix:e,encode:r,decode:n})=>new at(t,e,r,n),ct=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=$r(r,e);return Dr({prefix:t,name:e,encode:n,decode:i=>oe(o(i))})},io=(t,e,r,n)=>{let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let i=t.length;for(;t[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),c=0,h=0,w=0;for(let l=0;l<i;++l){let g=o[t[l]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|g,c+=r,c>=8&&(c-=8,a[w++]=255&h>>c)}if(c>=r||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return a},so=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,i="",a=0,c=0;for(let h=0;h<t.length;++h)for(c=c<<8|t[h],a+=8;a>r;)a-=r,i+=e[o&c>>a];if(a&&(i+=e[o&c<<r-a]),n)for(;i.length*r&7;)i+="=";return i},I=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Dr({prefix:e,name:t,encode(o){return so(o,n,r)},decode(o){return io(o,n,r,t)}});var J=ct({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),xs=ct({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var xe=I({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ks=I({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),As=I({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ss=I({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Us=I({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ts=I({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Cs=I({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Bs=I({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Is=I({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var _r=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return co(r,ut(t),e||J.encoder);default:return uo(r,ut(t),e||xe.encoder)}};var zr=new WeakMap,ut=t=>{let e=zr.get(t);if(e==null){let r=new Map;return zr.set(t,r),r}return e},se=class t{constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==ve)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==fo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.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:e,digest:r}=this.multihash,n=rt(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Ir(e.multihash,n.multihash)}toString(e){return _r(this,e)}toJSON(){return{"/":_r(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new t(n,o,i,a||Mr(n,o,i.bytes))}else if(r[ho]===!0){let{version:n,multihash:o,code:i}=r,a=Br(o);return t.create(n,i,a)}else return null}static create(e,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(e){case 0:{if(r!==ve)throw new Error(`Version 0 CID must use dag-pb (code: ${ve}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Mr(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,ve,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=oe(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new ie(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[g,P]=be(e.subarray(r));return r+=P,g},o=n(),i=ve;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,c=n(),h=n(),w=r+h,l=w-a;return{version:o,codec:i,multihashCode:c,digestSize:h,multihashSize:l,size:w}}static parse(e,r){let[n,o]=ao(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ut(i).set(n,e),i}},ao=(t,e)=>{switch(t[0]){case"Q":{let r=e||J;return[J.prefix,r.decode(`${J.prefix}${t}`)]}case J.prefix:{let r=e||J;return[J.prefix,r.decode(t)]}case xe.prefix:{let r=e||xe;return[xe.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},co=(t,e,r)=>{let{prefix:n}=r;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o},uo=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o},ve=112,fo=18,Mr=(t,e,r)=>{let n=ne(t),o=n+ne(e),i=new Uint8Array(o+r.byteLength);return re(t,i,0),re(e,i,n),i.set(r,o),i},ho=Symbol.for("@ipld/js-cid/CID");var dt=I({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ps=I({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Rs=I({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),js=I({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function lo(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=se.asCID(t);if(!e)return null;let r=e.toString();return[new u(s.map,1/0,1),new u(s.string,"/",1),new u(s.string,r,r.length),new u(s.break,void 0,1)]}function Fe(t){let e=dt.encode(t).slice(1);return[new u(s.map,1/0,1),new u(s.string,"/",1),new u(s.map,1/0,1),new u(s.string,"bytes",5),new u(s.string,e,e.length),new u(s.break,void 0,1),new u(s.break,void 0,1)]}function F(t){return Fe(new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}function mo(t){return Fe(new Uint8Array(t))}function yo(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function wo(t){if(Number.isNaN(t))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(t===1/0||t===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var go={typeEncoders:{Object:lo,Buffer:Fe,Uint8Array:Fe,Int8Array:F,Uint16Array:F,Int16Array:F,Uint32Array:F,Int32Array:F,Float32Array:F,Float64Array:F,Uint8ClampedArray:F,BigInt64Array:F,BigUint64Array:F,DataView:F,ArrayBuffer:mo,undefined:yo,number:wo}},ft=class extends te{constructor(e,r){super(e,r),this.tokenBuffer=[]}done(){return this.tokenBuffer.length===0&&super.done()}_next(){return this.tokenBuffer.length>0?this.tokenBuffer.pop():super.next()}next(){let e=this._next();if(e.type===s.map){let r=this._next();if(r.type===s.string&&r.value==="/"){let n=this._next();if(n.type===s.string){if(this._next().type!==s.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new u(s.tag,42,0)}if(n.type===s.map){let o=this._next();if(o.type===s.string&&o.value==="bytes"){let i=this._next();if(i.type===s.string){for(let c=0;c<2;c++)if(this._next().type!==s.break)throw new Error("Invalid encoded Bytes form");let a=dt.decode(`m${i.value}`);return new u(s.bytes,a,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},ht={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};ht.tags[42]=se.parse;var Or=297,Vr=t=>Ze(t,go),Fr=t=>{let e=Object.assign(ht,{tokenizer:new ft(t,ht)});return Ye(t,e)};var Ks=new TextDecoder;var Qs=new TextEncoder;var xo=Rr,Lr=128,vo=127,Eo=~vo,ko=Math.pow(2,31);function Rr(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ko;)e[r++]=t&255|Lr,t/=128;for(;t&Eo;)e[r++]=t&255|Lr,t>>>=7;return e[r]=t|0,Rr.bytes=r-n+1,e}var Ao=pt,So=128,Pr=127;function pt(t,n){var r=0,n=n||0,o=0,i=n,a,c=t.length;do{if(i>=c)throw pt.bytes=0,new RangeError("Could not decode varint");a=t[i++],r+=o<28?(a&Pr)<<o:(a&Pr)*Math.pow(2,o),o+=7}while(a>=So);return pt.bytes=i-n,r}var Uo=Math.pow(2,7),To=Math.pow(2,14),Co=Math.pow(2,21),Bo=Math.pow(2,28),Io=Math.pow(2,35),$o=Math.pow(2,42),No=Math.pow(2,49),Do=Math.pow(2,56),_o=Math.pow(2,63),zo=function(t){return t<Uo?1:t<To?2:t<Co?3:t<Bo?4:t<Io?5:t<$o?6:t<No?7:t<Do?8:t<_o?9:10},Mo={encode:xo,decode:Ao,encodingLength:zo},Oo=Mo,Ee=Oo;var ke=(t,e=0)=>[Ee.decode(t,e),Ee.decode.bytes],ae=(t,e,r=0)=>(Ee.encode(t,e,r),e),ce=t=>Ee.encodingLength(t);var Zs=new Uint8Array(0);var qr=(t,e)=>{if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0},ue=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};var Ae=(t,e)=>{let r=e.byteLength,n=ce(t),o=n+ce(r),i=new Uint8Array(o+r);return ae(t,i,0),ae(r,i,n),i.set(e,o),new de(t,r,e,i)},Jr=t=>{let e=ue(t),[r,n]=ke(e),[o,i]=ke(e.subarray(n)),a=e.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new de(r,o,a,e)},Wr=(t,e)=>{if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&qr(t.bytes,r.bytes)}},de=class{constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Vo(t,e){if(t.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<t.length;o++){var i=t.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var c=t.length,h=t.charAt(0),w=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function g(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,B=0,x=0,E=p.length;x!==E&&p[x]===0;)x++,y++;for(var k=(E-x)*l+1>>>0,b=new Uint8Array(k);x!==E;){for(var A=p[x],T=0,v=k-1;(A!==0||T<B)&&v!==-1;v--,T++)A+=256*b[v]>>>0,b[v]=A%c>>>0,A=A/c>>>0;if(A!==0)throw new Error("Non-zero carry");B=T,x++}for(var S=k-B;S!==k&&b[S]===0;)S++;for(var R=h.repeat(y);S<k;++S)R+=t.charAt(b[S]);return R}function P(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var y=0;if(p[y]!==" "){for(var B=0,x=0;p[y]===h;)B++,y++;for(var E=(p.length-y)*w+1>>>0,k=new Uint8Array(E);p[y];){var b=r[p.charCodeAt(y)];if(b===255)return;for(var A=0,T=E-1;(b!==0||A<x)&&T!==-1;T--,A++)b+=c*k[T]>>>0,k[T]=b%256>>>0,b=b/256>>>0;if(b!==0)throw new Error("Non-zero carry");x=A,y++}if(p[y]!==" "){for(var v=E-x;v!==E&&k[v]===0;)v++;for(var S=new Uint8Array(B+(E-v)),R=B;v!==E;)S[R++]=k[v++];return S}}}function Pe(p){var y=P(p);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:g,decodeUnsafe:P,decode:Pe}}var Fo=Vo,Lo=Fo,Kr=Lo;var lt=class{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},mt=class{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Qr(this,e)}},yt=class{constructor(e){this.decoders=e}or(e){return Qr(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Qr=(t,e)=>new yt({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}}),wt=class{constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new lt(e,r,n),this.decoder=new mt(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Xr=({name:t,prefix:e,encode:r,decode:n})=>new wt(t,e,r,n),gt=({prefix:t,name:e,alphabet:r})=>{let{encode:n,decode:o}=Kr(r,e);return Xr({prefix:t,name:e,encode:n,decode:i=>ue(o(i))})},Po=(t,e,r,n)=>{let o={};for(let l=0;l<e.length;++l)o[e[l]]=l;let i=t.length;for(;t[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),c=0,h=0,w=0;for(let l=0;l<i;++l){let g=o[t[l]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|g,c+=r,c>=8&&(c-=8,a[w++]=255&h>>c)}if(c>=r||255&h<<8-c)throw new SyntaxError("Unexpected end of data");return a},Ro=(t,e,r)=>{let n=e[e.length-1]==="=",o=(1<<r)-1,i="",a=0,c=0;for(let h=0;h<t.length;++h)for(c=c<<8|t[h],a+=8;a>r;)a-=r,i+=e[o&c>>a];if(a&&(i+=e[o&c<<r-a]),n)for(;i.length*r&7;)i+="=";return i},L=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Xr({prefix:e,name:t,encode(o){return Ro(o,n,r)},decode(o){return Po(o,n,r,t)}});var W=gt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),sa=gt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Se=L({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ua=L({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),da=L({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),fa=L({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ha=L({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pa=L({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),la=L({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ma=L({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ya=L({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Hr=(t,e)=>{let{bytes:r,version:n}=t;switch(n){case 0:return qo(r,bt(t),e||W.encoder);default:return Jo(r,bt(t),e||Se.encoder)}};var Zr=new WeakMap,bt=t=>{let e=Zr.get(t);if(e==null){let r=new Map;return Zr.set(t,r),r}return e},Le=class t{constructor(e,r,n,o){this.code=r,this.version=e,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:e,multihash:r}=this;if(e!==Ue)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Wo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.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:e,digest:r}=this.multihash,n=Ae(e,r);return t.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(e){return t.equals(this,e)}static equals(e,r){let n=r;return n&&e.code===n.code&&e.version===n.version&&Wr(e.multihash,n.multihash)}toString(e){return Hr(this,e)}toJSON(){return{"/":Hr(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new t(n,o,i,a||Yr(n,o,i.bytes))}else if(r[Go]===!0){let{version:n,multihash:o,code:i}=r,a=Jr(o);return t.create(n,i,a)}else return null}static create(e,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(e){case 0:{if(r!==Ue)throw new Error(`Version 0 CID must use dag-pb (code: ${Ue}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Yr(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Ue,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=ue(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new de(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[g,P]=ke(e.subarray(r));return r+=P,g},o=n(),i=Ue;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,c=n(),h=n(),w=r+h,l=w-a;return{version:o,codec:i,multihashCode:c,digestSize:h,multihashSize:l,size:w}}static parse(e,r){let[n,o]=jo(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return bt(i).set(n,e),i}},jo=(t,e)=>{switch(t[0]){case"Q":{let r=e||W;return[W.prefix,r.decode(`${W.prefix}${t}`)]}case W.prefix:{let r=e||W;return[W.prefix,r.decode(t)]}case Se.prefix:{let r=e||Se;return[Se.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}},qo=(t,e,r)=>{let{prefix:n}=r;if(n!==W.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o},Jo=(t,e,r)=>{let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o},Ue=112,Wo=18,Yr=(t,e,r)=>{let n=ce(t),o=n+ce(e),i=new Uint8Array(o+r.byteLength);return ae(t,i,0),ae(e,i,n),i.set(r,o),i},Go=Symbol.for("@ipld/js-cid/CID");var vt=({name:t,code:e,encode:r})=>new xt(t,e,r),xt=class{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){let r=this.encode(e);return r instanceof Uint8Array?Ae(this.code,r):r.then(n=>Ae(this.code,n))}else throw Error("Unknown type, must be binary type")}};var en=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),tn=vt({name:"sha2-256",code:18,encode:en("SHA-256")}),Sa=vt({name:"sha2-512",code:19,encode:en("SHA-512")});var Et=class{components;constructor(e){this.components=e}async add(e,r={}){let n=Vr(e),o=await(r.hasher??tn).digest(n),i=Le.createV1(Or,o);return await this.components.blockstore.put(i,n,r),i}async get(e,r={}){let n=await this.components.blockstore.get(e,r);return Fr(n)}};function Ko(t){return new Et(t)}return cn(Qo);})();
|
|
2
|
+
"use strict";var HeliaDagJson=(()=>{var Ie=Object.defineProperty;var vr=Object.getOwnPropertyDescriptor;var Ar=Object.getOwnPropertyNames;var Ur=Object.prototype.hasOwnProperty;var Sr=(e,t)=>{for(var r in t)Ie(e,r,{get:t[r],enumerable:!0})},Tr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ar(t))!Ur.call(e,o)&&o!==r&&Ie(e,o,{get:()=>t[o],enumerable:!(n=vr(t,o))||n.enumerable});return e};var Br=e=>Tr(Ie({},"__esModule",{value:!0}),e);var Pn={};Sr(Pn,{dagJson:()=>jn});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 nt(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(Cr(e))return"Buffer";let r=_r(e);return r||"Object"}function Cr(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function _r(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Ir.includes(t))return t}var s=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}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(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",Nr=new TextDecoder,Mr=new TextEncoder;function ge(e){return J&&globalThis.Buffer.isBuffer(e)}function ne(e){return e instanceof Uint8Array?ge(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var at=J?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):it(e,t,r):(e,t,r)=>r-t>64?Nr.decode(e.subarray(t,r)):it(e,t,r),we=J?e=>e.length>64?globalThis.Buffer.from(e):ot(e):e=>e.length>64?Mr.encode(e):ot(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),ct=J?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),ne(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},ut=J?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function ft(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 ot(e,t=1/0){let r,n=e.length,o=null,i=[];for(let a=0;a<n;++a){if(r=e.charCodeAt(a),r>55295&&r<57344){if(!o){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}else if(a+1===n){(t-=3)>-1&&i.push(239,191,189);continue}o=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),o=r;continue}r=(o-55296<<10|r-56320)+65536}else o&&(t-=3)>-1&&i.push(239,191,189);if(o=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return i}function it(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let u,h,y,l;switch(a){case 1:o<128&&(i=o);break;case 2:u=e[t+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(i=l));break;case 3:u=e[t+1],h=e[t+2],(u&192)===128&&(h&192)===128&&(l=(o&15)<<12|(u&63)<<6|h&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:u=e[t+1],h=e[t+2],y=e[t+3],(u&192)===128&&(h&192)===128&&(y&192)===128&&(l=(o&15)<<18|(u&63)<<12|(h&63)<<6|y&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=a}return Ce(n)}var st=4096;function Ce(e){let t=e.length;if(t<=st)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=st));return r}var Dr=256,oe=class{constructor(t=Dr){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=ut(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=ct(this.chunks,this.cursor);return t&&this.reset(),r}};var d="CBOR decode error:",F="CBOR encode error:",ie=[];ie[23]=1;ie[24]=2;ie[25]=3;ie[26]=5;ie[27]=9;function V(e,t,r){if(e.length-t<r)throw new Error(`${d} not enough data for type`)}var w=[24,256,65536,4294967296,BigInt("18446744073709551616")];function E(e,t,r){V(e,t,1);let n=e[t];if(r.strict===!0&&n<w[0])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function v(e,t,r){V(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<w[1])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function A(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<w[2])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);return n}function U(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],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<w[3])throw new Error(`${d} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${d} integers outside of the safe integer range are not supported`)}function dt(e,t,r,n){return new c(s.uint,E(e,t+1,n),2)}function ht(e,t,r,n){return new c(s.uint,v(e,t+1,n),3)}function pt(e,t,r,n){return new c(s.uint,A(e,t+1,n),5)}function lt(e,t,r,n){return new c(s.uint,U(e,t+1,n),9)}function T(e,t){return x(e,0,t.value)}function x(e,t,r){if(r<w[0]){let n=Number(r);e.push([t|n])}else if(r<w[1]){let n=Number(r);e.push([t|24,n])}else if(r<w[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<w[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<w[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&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`)}}T.encodedSize=function(t){return x.encodedSize(t.value)};x.encodedSize=function(t){return t<w[0]?1:t<w[1]?2:t<w[2]?3:t<w[3]?5:9};T.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function mt(e,t,r,n){return new c(s.negint,-1-E(e,t+1,n),2)}function yt(e,t,r,n){return new c(s.negint,-1-v(e,t+1,n),3)}function gt(e,t,r,n){return new c(s.negint,-1-A(e,t+1,n),5)}var _e=BigInt(-1),wt=BigInt(1);function xt(e,t,r,n){let o=U(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new c(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${d} integers outside of the safe integer range are not supported`);return new c(s.negint,_e-BigInt(o),9)}function xe(e,t){let r=t.value,n=typeof r=="bigint"?r*_e-wt:r*-1-1;x(e,t.type.majorEncoded,n)}xe.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*_e-wt:r*-1-1;return n<w[0]?1:n<w[1]?2:n<w[2]?3:n<w[3]?5:9};xe.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function se(e,t,r,n){V(e,t,r+n);let o=K(e,t+r,t+r+n);return new c(s.bytes,o,r+n)}function bt(e,t,r,n){return se(e,t,1,r)}function kt(e,t,r,n){return se(e,t,2,E(e,t+1,n))}function Et(e,t,r,n){return se(e,t,3,v(e,t+1,n))}function vt(e,t,r,n){return se(e,t,5,A(e,t+1,n))}function At(e,t,r,n){let o=U(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer bytes lengths not supported`);return se(e,t,9,o)}function be(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?we(e.value):e.value),e.encodedBytes}function H(e,t){let r=be(t);x(e,t.type.majorEncoded,r.length),e.push(r)}H.encodedSize=function(t){let r=be(t);return x.encodedSize(r.length)+r.length};H.compareTokens=function(t,r){return Or(be(t),be(r))};function Or(e,t){return e.length<t.length?-1:e.length>t.length?1:ft(e,t)}function ae(e,t,r,n,o){let i=r+n;V(e,t,i);let a=new c(s.string,at(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=K(e,t+r,t+i)),a}function Ut(e,t,r,n){return ae(e,t,1,r,n)}function St(e,t,r,n){return ae(e,t,2,E(e,t+1,n),n)}function Tt(e,t,r,n){return ae(e,t,3,v(e,t+1,n),n)}function Bt(e,t,r,n){return ae(e,t,5,A(e,t+1,n),n)}function $t(e,t,r,n){let o=U(e,t+1,n);if(typeof o=="bigint")throw new Error(`${d} 64-bit integer string lengths not supported`);return ae(e,t,9,o,n)}var It=H;function X(e,t,r,n){return new c(s.array,n,r)}function Ct(e,t,r,n){return X(e,t,1,r)}function _t(e,t,r,n){return X(e,t,2,E(e,t+1,n))}function Nt(e,t,r,n){return X(e,t,3,v(e,t+1,n))}function Mt(e,t,r,n){return X(e,t,5,A(e,t+1,n))}function Dt(e,t,r,n){let o=U(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 zt(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){x(e,s.array.majorEncoded,t.value)}ke.compareTokens=T.compareTokens;ke.encodedSize=function(t){return x.encodedSize(t.value)};function Q(e,t,r,n){return new c(s.map,n,r)}function Ot(e,t,r,n){return Q(e,t,1,r)}function Ft(e,t,r,n){return Q(e,t,2,E(e,t+1,n))}function Vt(e,t,r,n){return Q(e,t,3,v(e,t+1,n))}function jt(e,t,r,n){return Q(e,t,5,A(e,t+1,n))}function Pt(e,t,r,n){let o=U(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 Rt(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){x(e,s.map.majorEncoded,t.value)}Ee.compareTokens=T.compareTokens;Ee.encodedSize=function(t){return x.encodedSize(t.value)};function Lt(e,t,r,n){return new c(s.tag,r,1)}function qt(e,t,r,n){return new c(s.tag,E(e,t+1,n),2)}function Wt(e,t,r,n){return new c(s.tag,v(e,t+1,n),3)}function Gt(e,t,r,n){return new c(s.tag,A(e,t+1,n),5)}function Jt(e,t,r,n){return new c(s.tag,U(e,t+1,n),9)}function ve(e,t){x(e,s.tag.majorEncoded,t.value)}ve.compareTokens=T.compareTokens;ve.encodedSize=function(t){return x.encodedSize(t.value)};var Lr=20,qr=21,Wr=22,Gr=23;function Kt(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${d} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new c(s.null,null,1):new c(s.undefined,void 0,1)}function Ht(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${d} indefinite length items not allowed`);return new c(s.break,void 0,1)}function Ne(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(s.float,e,t)}function Xt(e,t,r,n){return Ne(Me(e,t+1),3,n)}function Qt(e,t,r,n){return Ne(De(e,t+1),5,n)}function Zt(e,t,r,n){return Ne(rr(e,t+1),9,n)}function Ae(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Lr]);else if(n===!0)e.push([s.float.majorEncoded|qr]);else if(n===null)e.push([s.float.majorEncoded|Wr]);else if(n===void 0)e.push([s.float.majorEncoded|Gr]);else{let o,i=!1;(!r||r.float64!==!0)&&(er(n),o=Me(C,1),n===o||Number.isNaN(n)?(C[0]=249,e.push(C.slice(0,3)),i=!0):(tr(n),o=De(C,1),n===o&&(C[0]=250,e.push(C.slice(0,5)),i=!0))),i||(Jr(n),o=rr(C,1),C[0]=251,e.push(C.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){er(n);let o=Me(C,1);if(n===o||Number.isNaN(n))return 3;if(tr(n),o=De(C,1),n===o)return 5}return 9};var Yt=new ArrayBuffer(9),B=new DataView(Yt,1),C=new Uint8Array(Yt,0);function er(e){if(e===1/0)B.setUint16(0,31744,!1);else if(e===-1/0)B.setUint16(0,64512,!1);else if(Number.isNaN(e))B.setUint16(0,32256,!1);else{B.setFloat32(0,e);let t=B.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)B.setUint16(0,31744,!1);else if(r===0)B.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?B.setUint16(0,0):o<-14?B.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):B.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Me(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,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function tr(e){B.setFloat32(0,e,!1)}function De(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 Jr(e){B.setFloat64(0,e,!1)}function rr(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=T.compareTokens;function p(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 f=[];for(let e=0;e<=23;e++)f[e]=p;f[24]=dt;f[25]=ht;f[26]=pt;f[27]=lt;f[28]=p;f[29]=p;f[30]=p;f[31]=p;for(let e=32;e<=55;e++)f[e]=p;f[56]=mt;f[57]=yt;f[58]=gt;f[59]=xt;f[60]=p;f[61]=p;f[62]=p;f[63]=p;for(let e=64;e<=87;e++)f[e]=bt;f[88]=kt;f[89]=Et;f[90]=vt;f[91]=At;f[92]=p;f[93]=p;f[94]=p;f[95]=Ue("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=Ut;f[120]=St;f[121]=Tt;f[122]=Bt;f[123]=$t;f[124]=p;f[125]=p;f[126]=p;f[127]=Ue("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=Ct;f[152]=_t;f[153]=Nt;f[154]=Mt;f[155]=Dt;f[156]=p;f[157]=p;f[158]=p;f[159]=zt;for(let e=160;e<=183;e++)f[e]=Ot;f[184]=Ft;f[185]=Vt;f[186]=jt;f[187]=Pt;f[188]=p;f[189]=p;f[190]=p;f[191]=Rt;for(let e=192;e<=215;e++)f[e]=Lt;f[216]=qt;f[217]=Wt;f[218]=Gt;f[219]=Jt;f[220]=p;f[221]=p;f[222]=p;f[223]=p;for(let e=224;e<=243;e++)f[e]=Ue("simple values are not supported");f[244]=p;f[245]=p;f[246]=p;f[247]=Kt;f[248]=Ue("simple values are not supported");f[249]=Xt;f[250]=Qt;f[251]=Zt;f[252]=p;f[253]=p;f[254]=p;f[255]=Ht;var _=[];for(let e=0;e<24;e++)_[e]=new c(s.uint,e,1);for(let e=-1;e>=-24;e--)_[31-e]=new c(s.negint,e,1);_[64]=new c(s.bytes,new Uint8Array(0),1);_[96]=new c(s.string,"",1);_[128]=new c(s.array,0,1);_[160]=new c(s.map,0,1);_[244]=new c(s.false,!1,1);_[245]=new c(s.true,!0,1);_[246]=new c(s.null,null,1);function Hr(){let e=[];return e[s.uint.major]=T,e[s.negint.major]=xe,e[s.bytes.major]=H,e[s.string.major]=It,e[s.array.major]=ke,e[s.map.major]=Ee,e[s.tag.major]=ve,e[s.float.major]=Ae,e}var Do=Hr(),ze=new oe,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(`${F} object contains circular references`);return new e(r,t)}},R={null:new c(s.null,null),undefined:new c(s.undefined,void 0),true:new c(s.true,!0),false:new c(s.false,!1),emptyArray:new c(s.array,0),emptyMap:new c(s.map,0)},L={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new c(s.float,e):e>=0?new c(s.uint,e):new c(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new c(s.uint,e):new c(s.negint,e)},Uint8Array(e,t,r,n){return new c(s.bytes,e)},string(e,t,r,n){return new c(s.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(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new c(s.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(s.break)]:R.emptyArray;n=Te.createCheck(n,e);let o=[],i=0;for(let a of e)o[i++]=Se(a,r,n);return r.addBreakTokens?[new c(s.array,e.length),o,new c(s.break)]:[new c(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return r.addBreakTokens===!0?[R.emptyMap,new c(s.break)]:R.emptyMap;n=Te.createCheck(n,e);let u=[],h=0;for(let y of i)u[h++]=[Se(y,r,n),Se(o?e.get(y):e[y],r,n)];return Xr(u,r),r.addBreakTokens?[new c(s.map,a),u,new c(s.break)]:[new c(s.map,a),u]}};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=nt(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 i=L[n];if(!i)throw new Error(`${F} unsupported type: ${n}`);return i(e,n,t,r)}function Xr(e,t){t.mapSorter&&e.sort(t.mapSorter)}function nr(e,t,r,n){if(Array.isArray(t))for(let o of t)nr(e,o,r,n);else r[t.type.major](e,t,n)}function or(e,t,r){let n=Se(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let a=i.encodedSize(n,r),u=new oe(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return ne(u.chunks[0])}}return ze.reset(),nr(ze,n,t,r),ze.toBytes(!0)}var Qr={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Oe=class{constructor(t,r={}){this.pos=0,this.data=t,this.options=r}done(){return this.pos>=this.data.length}next(){let t=this.data[this.pos],r=_[t];if(r===void 0){let n=f[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}},ce=Symbol.for("DONE"),Be=Symbol.for("BREAK");function Zr(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=ue(t,r);if(i===Be){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed array`)}if(i===ce)throw new Error(`${d} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Yr(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<e.value;a++){let u=ue(t,r);if(u===Be){if(e.value===1/0)break;throw new Error(`${d} got unexpected break to lengthed map`)}if(u===ce)throw new Error(`${d} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof u!="string")throw new Error(`${d} non-string keys not supported (got ${typeof u})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(u)||!n&&u in o))throw new Error(`${d} found repeat map key "${u}"`);let h=ue(t,r);if(h===ce)throw new Error(`${d} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?i.set(u,h):o[u]=h}return n?i:o}function ue(e,t){if(e.done())return ce;let r=e.next();if(r.type===s.break)return Be;if(r.type.terminal)return r.value;if(r.type===s.array)return Zr(r,e,t);if(r.type===s.map)return Yr(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=ue(e,t);return t.tags[r.value](n)}throw new Error(`${d} tag not supported (${r.value})`)}throw new Error("unsupported")}function Fe(e,t){if(!(e instanceof Uint8Array))throw new Error(`${d} data to decode must be a Uint8Array`);t=Object.assign({},Qr,t);let r=t.tokenizer||new Oe(e,t),n=ue(r,t);if(n===ce)throw new Error(`${d} did not find any content to decode`);if(n===Be)throw new Error(`${d} got unexpected break`);if(!r.done())throw new Error(`${d} too many terminals, data makes no sense`);return n}var Ve=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(t){let r=this.inRecursive[this.inRecursive.length-1];r&&(r.type===s.array&&(r.elements++,r.elements!==1&&t.push([44])),r.type===s.map&&(r.elements++,r.elements!==1&&(r.elements%2===1?t.push([44]):t.push([58]))))}[s.uint.major](t,r){this.prefix(t);let n=String(r.value),o=[];for(let i=0;i<n.length;i++)o[i]=n.charCodeAt(i);t.push(o)}[s.negint.major](t,r){this[s.uint.major](t,r)}[s.bytes.major](t,r){throw new Error(`${F} unsupported type: Uint8Array`)}[s.string.major](t,r){this.prefix(t);let n=we(JSON.stringify(r.value));t.push(n.length>32?ne(n):n)}[s.array.major](t,r){this.prefix(t),this.inRecursive.push({type:s.array,elements:0}),t.push([91])}[s.map.major](t,r){this.prefix(t),this.inRecursive.push({type:s.map,elements:0}),t.push([123])}[s.tag.major](t,r){}[s.float.major](t,r){if(r.type.name==="break"){let a=this.inRecursive.pop();if(a){if(a.type===s.array)t.push([93]);else if(a.type===s.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(`${F} 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=[],i=!1;for(let a=0;a<n.length;a++)o[a]=n.charCodeAt(a),!i&&(o[a]===46||o[a]===101||o[a]===69)&&(i=!0);i||(o.push(46),o.push(48)),t.push(o)}};function en(e,t){if(Array.isArray(e[0])||Array.isArray(t[0]))throw new Error(`${F} complex map keys are not supported`);let r=e[0],n=t[0];if(r.type!==s.string||n.type!==s.string)throw new Error(`${F} non-string map keys are not supported`);if(r<n)return-1;if(r>n)return 1;throw new Error(`${F} unexpected duplicate map keys, this is not supported`)}var tn={addBreakTokens:!0,mapSorter:en};function je(e,t){return t=Object.assign({},tn,t),or(e,new Ve,t)}var Z=class{constructor(t,r={}){this.pos=0,this.data=t,this.options=r,this.modeStack=["value"],this.lastToken=""}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=u=>{for(;!this.done();){let h=this.ch();if(u.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(s.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 i=String.fromCharCode.apply(null,this.data.subarray(t,this.pos)),a=parseFloat(i);return n?new c(s.float,a,this.pos-t):this.options.allowBigInt!==!0||Number.isSafeInteger(a)?new c(a>=0?s.uint:s.negint,a,this.pos-t):new c(a>=0?s.uint:s.negint,BigInt(i),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 i=this.pos,a=0;i<this.data.length&&a<65536;i++,a++){let u=this.data[i];if(u===92||u<32||u>=128)break;if(u===34){let h=String.fromCharCode.apply(null,this.data.subarray(this.pos,i));return this.pos=i+1,new c(s.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 i=0;for(let a=0;a<4;a++){let u=this.ch();if(u>=48&&u<=57)u-=48;else if(u>=97&&u<=102)u=u-97+10;else if(u>=65&&u<=70)u=u-65+10;else throw new Error(`${d} unexpected unicode escape character at position ${this.pos}`);i=i*16+u,this.pos++}return i},o=()=>{let i=this.ch(),a=null,u=i>239?4:i>223?3:i>191?2:1;if(this.pos+u>this.data.length)throw new Error(`${d} unexpected unicode sequence at position ${this.pos}`);let h,y,l,g;switch(u){case 1:i<128&&(a=i);break;case 2:h=this.data[this.pos+1],(h&192)===128&&(g=(i&31)<<6|h&63,g>127&&(a=g));break;case 3:h=this.data[this.pos+1],y=this.data[this.pos+2],(h&192)===128&&(y&192)===128&&(g=(i&15)<<12|(h&63)<<6|y&63,g>2047&&(g<55296||g>57343)&&(a=g));break;case 4:h=this.data[this.pos+1],y=this.data[this.pos+2],l=this.data[this.pos+3],(h&192)===128&&(y&192)===128&&(l&192)===128&&(g=(i&15)<<18|(h&63)<<12|(y&63)<<6|l&63,g>65535&&g<1114112&&(a=g))}a===null?(a=65533,u=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|a&1023),r.push(a),this.pos+=u};for(;!this.done();){let i=this.ch(),a;switch(i){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(s.string,Ce(r),this.pos-t);default:if(i<32)throw new Error(`${d} invalid control character at position ${this.pos}`);i<128?(r.push(i),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(s.map,1/0,1);case 91:return this.modeStack.push("array-start"),this.pos++,new c(s.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new c(s.null,null,4);case 102:return this.expect([102,97,108,115,101]),new c(s.false,!1,5);case 116:return this.expect([116,114,117,101]),new c(s.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(s.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(s.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(s.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(s.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 Pe(e,t){return t=Object.assign({tokenizer:new Z(e,t)},t),Fe(e,t)}var nn=ar,ir=128,on=127,sn=~on,an=Math.pow(2,31);function ar(e,t,r){t=t||[],r=r||0;for(var n=r;e>=an;)t[r++]=e&255|ir,e/=128;for(;e&sn;)t[r++]=e&255|ir,e>>>=7;return t[r]=e|0,ar.bytes=r-n+1,t}var cn=Re,un=128,sr=127;function Re(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw Re.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&sr)<<o:(a&sr)*Math.pow(2,o),o+=7}while(a>=un);return Re.bytes=i-n,r}var fn=Math.pow(2,7),dn=Math.pow(2,14),hn=Math.pow(2,21),pn=Math.pow(2,28),ln=Math.pow(2,35),mn=Math.pow(2,42),yn=Math.pow(2,49),gn=Math.pow(2,56),wn=Math.pow(2,63),xn=function(e){return e<fn?1:e<dn?2:e<hn?3:e<pn?4:e<ln?5:e<mn?6:e<yn?7:e<gn?8:e<wn?9:10},bn={encode:nn,decode:cn,encodingLength:xn},kn=bn,fe=kn;var de=(e,t=0)=>[fe.decode(e,t),fe.decode.bytes],Y=(e,t,r=0)=>(fe.encode(e,t,r),t),ee=e=>fe.encodingLength(e);var si=new Uint8Array(0);var 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},te=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")};var he=(e,t)=>{let r=t.byteLength,n=ee(e),o=n+ee(r),i=new Uint8Array(o+r);return Y(e,i,0),Y(r,i,n),i.set(t,o),new re(e,r,t,i)},ur=e=>{let t=te(e),[r,n]=de(t),[o,i]=de(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new re(r,o,a,t)},fr=(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)}},re=class{constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};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 i=e.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=e.length,h=e.charAt(0),y=Math.log(u)/Math.log(256),l=Math.log(256)/Math.log(u);function g(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 k=0,W=0,$=0,M=m.length;$!==M&&m[$]===0;)$++,k++;for(var D=(M-$)*l+1>>>0,S=new Uint8Array(D);$!==M;){for(var z=m[$],P=0,I=D-1;(z!==0||P<W)&&I!==-1;I--,P++)z+=256*S[I]>>>0,S[I]=z%u>>>0,z=z/u>>>0;if(z!==0)throw new Error("Non-zero carry");W=P,$++}for(var O=D-W;O!==D&&S[O]===0;)O++;for(var ye=h.repeat(k);O<D;++O)ye+=e.charAt(S[O]);return ye}function me(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var k=0;if(m[k]!==" "){for(var W=0,$=0;m[k]===h;)W++,k++;for(var M=(m.length-k)*y+1>>>0,D=new Uint8Array(M);m[k];){var S=r[m.charCodeAt(k)];if(S===255)return;for(var z=0,P=M-1;(S!==0||z<$)&&P!==-1;P--,z++)S+=u*D[P]>>>0,D[P]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");$=z,k++}if(m[k]!==" "){for(var I=M-$;I!==M&&D[I]===0;)I++;for(var O=new Uint8Array(W+(M-I)),ye=W;I!==M;)O[ye++]=D[I++];return O}}}function Er(m){var k=me(m);if(k)return k;throw new Error(`Non-${t} character`)}return{encode:g,decodeUnsafe:me,decode:Er}}var An=vn,Un=An,dr=Un;var We=class{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{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),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 hr(this,t)}},Je=class{constructor(t){this.decoders=t}or(t){return hr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},hr=(e,t)=>new Je({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}}),Ke=class{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)}},pr=({name:e,prefix:t,encode:r,decode:n})=>new Ke(e,t,r,n),He=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:o}=dr(r,t);return pr({prefix:e,name:t,encode:n,decode:i=>te(o(i))})},Sn=(e,t,r,n)=>{let o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,h=0,y=0;for(let l=0;l<i;++l){let g=o[e[l]];if(g===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|g,u+=r,u>=8&&(u-=8,a[y++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return a},Tn=(e,t,r)=>{let n=t[t.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let h=0;h<e.length;++h)for(u=u<<8|e[h],a+=8;a>r;)a-=r,i+=t[o&u>>a];if(a&&(i+=t[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i},b=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>pr({prefix:t,name:e,encode(o){return Tn(o,n,r)},decode(o){return Sn(o,n,r,e)}});var j=He({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pi=He({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var pe=b({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yi=b({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gi=b({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wi=b({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xi=b({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),bi=b({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ki=b({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ei=b({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vi=b({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var lr=(e,t)=>{let{bytes:r,version:n}=e;switch(n){case 0:return $n(r,Xe(e),t||j.encoder);default:return In(r,Xe(e),t||pe.encoder)}};var mr=new WeakMap,Xe=e=>{let t=mr.get(e);if(t==null){let r=new Map;return mr.set(e,r),r}return t},q=class e{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!==Cn)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=he(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&&t.code===n.code&&t.version===n.version&&fr(t.multihash,n.multihash)}toString(t){return lr(this,t)}toJSON(){return{"/":lr(this)}}link(){return this}get[Symbol.toStringTag](){return"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:i,bytes:a}=r;return new e(n,o,i,a||yr(n,o,i.bytes))}else if(r[_n]===!0){let{version:n,multihash:o,code:i}=r,a=ur(o);return e.create(n,i,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=yr(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)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=te(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new re(r.multihashCode,r.digestSize,i,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[g,me]=de(t.subarray(r));return r+=me,g},o=n(),i=le;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),h=n(),y=r+h,l=y-a;return{version:o,codec:i,multihashCode:u,digestSize:h,multihashSize:l,size:y}}static parse(t,r){let[n,o]=Bn(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Xe(i).set(n,t),i}},Bn=(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 pe.prefix:{let r=t||pe;return[pe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},$n=(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 i=r.encode(e).slice(1);return t.set(n,i),i}else return o},In=(e,t,r)=>{let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o},le=112,Cn=18,yr=(e,t,r)=>{let n=ee(e),o=n+ee(t),i=new Uint8Array(o+r.byteLength);return Y(e,i,0),Y(t,i,n),i.set(r,o),i},_n=Symbol.for("@ipld/js-cid/CID");var Ze=({name:e,code:t,encode:r})=>new Qe(e,t,r),Qe=class{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?he(this.code,r):r.then(n=>he(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ye=b({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Mi=b({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Di=b({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),zi=b({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Mn(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(s.map,1/0,1),new c(s.string,"/",1),new c(s.string,r,r.length),new c(s.break,void 0,1)]}function $e(e){let t=Ye.encode(e).slice(1);return[new c(s.map,1/0,1),new c(s.string,"/",1),new c(s.map,1/0,1),new c(s.string,"bytes",5),new c(s.string,t,t.length),new c(s.break,void 0,1),new c(s.break,void 0,1)]}function N(e){return $e(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function Dn(e){return $e(new Uint8Array(e))}function zn(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function On(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 Fn={typeEncoders:{Object:Mn,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:Dn,undefined:zn,number:On}},et=class extends Z{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===s.map){let r=this._next();if(r.type===s.string&&r.value==="/"){let n=this._next();if(n.type===s.string){if(this._next().type!==s.break)throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new c(s.tag,42,0)}if(n.type===s.map){let o=this._next();if(o.type===s.string&&o.value==="bytes"){let i=this._next();if(i.type===s.string){for(let u=0;u<2;u++)if(this._next().type!==s.break)throw new Error("Invalid encoded Bytes form");let a=Ye.decode(`m${i.value}`);return new c(s.bytes,a,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return t}},tt={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};tt.tags[42]=q.parse;var gr=297,wr=e=>je(e,Fn),xr=e=>{let t=Object.assign(tt,{tokenizer:new et(e,tt)});return Pe(e,t)};var Pi=new TextDecoder;var Ri=new TextEncoder;var br=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),kr=Ze({name:"sha2-256",code:18,encode:br("SHA-256")}),qi=Ze({name:"sha2-512",code:19,encode:br("SHA-512")});var rt=class{components;constructor(t){this.components=t}async add(t,r={}){let n=wr(t),o=await(r.hasher??kr).digest(n),i=q.createV1(gr,o);return await this.components.blockstore.put(i,n,r),i}async get(t,r={}){let n=await this.components.blockstore.get(t,r);return xr(n)}};function jn(e){return new rt(e)}return Br(Pn);})();
|
|
3
3
|
return HeliaDagJson}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/dag-json",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Add/get IPLD blocks containing dag-json with your Helia node",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia-dag-json/tree/master/packages/dag-json#readme",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"@ipld/dag-json": "^10.0.1",
|
|
139
139
|
"@libp2p/interfaces": "^3.3.1",
|
|
140
140
|
"interface-blockstore": "^5.0.0",
|
|
141
|
-
"multiformats": "^
|
|
141
|
+
"multiformats": "^12.0.1",
|
|
142
142
|
"progress-events": "^1.0.0"
|
|
143
143
|
},
|
|
144
144
|
"devDependencies": {
|