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