@helia/car 5.4.2-6f8165b5 → 5.4.2-73a28eda
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/package.json +5 -5
package/dist/index.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaCar = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var HeliaCar=(()=>{var nu=Object.create;var Er=Object.defineProperty;var ou=Object.getOwnPropertyDescriptor;var iu=Object.getOwnPropertyNames;var su=Object.getPrototypeOf,au=Object.prototype.hasOwnProperty;var Ce=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),D=(t,e)=>{for(var r in e)Er(t,r,{get:e[r],enumerable:!0})},Ii=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of iu(e))!au.call(t,o)&&o!==r&&Er(t,o,{get:()=>e[o],enumerable:!(n=ou(e,o))||n.enumerable});return t};var qe=(t,e,r)=>(r=t!=null?nu(su(t)):{},Ii(e||!t||!t.__esModule?Er(r,"default",{value:t,enumerable:!0}):r,t)),cu=t=>Ii(Er({},"__esModule",{value:!0}),t);var Ws=Ce((zm,Gs)=>{Gs.exports=Wn;var js=128,zf=127,Mf=~zf,Of=Math.pow(2,31);function Wn(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw Wn.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=Of;)e[r++]=t&255|js,t/=128;for(;t&Mf;)e[r++]=t&255|js,t>>>=7;return e[r]=t|0,Wn.bytes=r-n+1,e}});var Ys=Ce((Mm,Qs)=>{Qs.exports=Jn;var $f=128,Js=127;function Jn(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a||o>49)throw Jn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Js)<<o:(s&Js)*Math.pow(2,o),o+=7}while(s>=$f);return Jn.bytes=i-n,r}});var Ks=Ce((Om,Xs)=>{var Hf=Math.pow(2,7),Vf=Math.pow(2,14),qf=Math.pow(2,21),jf=Math.pow(2,28),Gf=Math.pow(2,35),Wf=Math.pow(2,42),Jf=Math.pow(2,49),Qf=Math.pow(2,56),Yf=Math.pow(2,63);Xs.exports=function(t){return t<Hf?1:t<Vf?2:t<qf?3:t<jf?4:t<Gf?5:t<Wf?6:t<Jf?7:t<Qf?8:t<Yf?9:10}});var Fr=Ce(($m,Zs)=>{Zs.exports={encode:Ws(),decode:Ys(),encodingLength:Ks()}});var aa=Ce((Jy,oo)=>{"use strict";var dl=Object.prototype.hasOwnProperty,j="~";function jt(){}Object.create&&(jt.prototype=Object.create(null),new jt().__proto__||(j=!1));function pl(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function sa(t,e,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new pl(r,n||t,o),s=j?j+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],i]:t._events[s].push(i):(t._events[s]=i,t._eventsCount++),t}function Hr(t,e){--t._eventsCount===0?t._events=new jt:delete t._events[e]}function $(){this._events=new jt,this._eventsCount=0}$.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)dl.call(r,n)&&e.push(j?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};$.prototype.listeners=function(e){var r=j?j+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};$.prototype.listenerCount=function(e){var r=j?j+e:e,n=this._events[r];return n?n.fn?1:n.length:0};$.prototype.emit=function(e,r,n,o,i,s){var a=j?j+e:e;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,l,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(d=1,l=new Array(u-1);d<u;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var g=c.length,w;for(d=0;d<g;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),u){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,r);break;case 3:c[d].fn.call(c[d].context,r,n);break;case 4:c[d].fn.call(c[d].context,r,n,o);break;default:if(!l)for(w=1,l=new Array(u-1);w<u;w++)l[w-1]=arguments[w];c[d].fn.apply(c[d].context,l)}}return!0};$.prototype.on=function(e,r,n){return sa(this,e,r,n,!1)};$.prototype.once=function(e,r,n){return sa(this,e,r,n,!0)};$.prototype.removeListener=function(e,r,n,o){var i=j?j+e:e;if(!this._events[i])return this;if(!r)return Hr(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&Hr(this,i);else{for(var a=0,c=[],u=s.length;a<u;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Hr(this,i)}return this};$.prototype.removeAllListeners=function(e){var r;return e?(r=j?j+e:e,this._events[r]&&Hr(this,r)):(this._events=new jt,this._eventsCount=0),this};$.prototype.off=$.prototype.removeListener;$.prototype.addListener=$.prototype.on;$.prefixed=j;$.EventEmitter=$;typeof oo<"u"&&(oo.exports=$)});var La=Ce((dw,Na)=>{Na.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var Rc=Ce((_1,Pc)=>{"use strict";Pc.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,r){let n=this._internalPositionFor(e,!1);if(r===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let o=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):o=!0,this._setInternalPos(n,e,r,o),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let r=this._internalPositionFor(e,!0);if(r!==-1)return this._data[r][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let r=0;for(;r<this.length;)e(this.get(r),r,this),r++}map(e){let r=0,n=new Array(this.length);for(;r<this.length;)n[r]=e(this.get(r),r,this),r++;return n}reduce(e,r){let n=0,o=r;for(;n<this.length;){let i=this.get(n);o=e(o,i,n),n++}return o}find(e){let r=0,n,o;for(;r<this.length&&!n;)o=this.get(r),n=e(o),r++;return n?o:void 0}_internalPositionFor(e,r){let n=this._bytePosFor(e,r);if(n>=this._bitArrays.length)return-1;let o=this._bitArrays[n],i=e-n*7;if(!((o&1<<i)>0))return-1;let a=this._bitArrays.slice(0,n).reduce(Yd,0),c=~(4294967295<<i+1),u=Uc(o&c);return a+u-1}_bytePosFor(e,r){let n=Math.floor(e/7),o=n+1;for(;!r&&this._bitArrays.length<o;)this._bitArrays.push(0);return n}_setBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]|=1<<e-r*7}_unsetBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]&=~(1<<e-r*7)}_setInternalPos(e,r,n,o){let i=this._data,s=[r,n];if(o)this._sortData(),i[e]=s;else{if(i.length)if(i[i.length-1][0]>=r)i.push(s);else if(i[0][0]<=r)i.unshift(s);else{let a=Math.round(i.length/2);this._data=i.slice(0,a).concat(s).concat(i.slice(a))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(Xd),this._changedData=!1}bitField(){let e=[],r=8,n=0,o=0,i,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(i=s.shift(),n=7);let c=Math.min(n,r),u=~(255<<c),l=i&u;o|=l<<8-r,i=i>>>c,n-=c,r-=c,(!r||!n&&!s.length)&&(e.push(o),o=0,r=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(Kd)}};function Yd(t,e){return t+Uc(e)}function Uc(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function Xd(t,e){return t[0]-e[0]}function Kd(t){return t[1]}});var yp={};D(yp,{BlockExporter:()=>oi,CIDPath:()=>gi,GraphSearch:()=>yi,SubgraphExporter:()=>sr,UnixFSExporter:()=>ar,UnixFSPath:()=>Ai,breadthFirstWalker:()=>Me,car:()=>mp,depthFirstWalker:()=>ze,naturalOrderWalker:()=>ni});var uu=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function En(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(t instanceof Uint8Array)return"Uint8Array";if(t.constructor===Object)return"Object";let r=fu(t);return r||"Object"}function fu(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(uu.includes(e))return e}var f=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}static equals(e,r){return e===r||e.major===r.major&&e.name===r.name}};f.uint=new f(0,"uint",!0);f.negint=new f(1,"negint",!0);f.bytes=new f(2,"bytes",!0);f.string=new f(3,"string",!0);f.array=new f(4,"array",!1);f.map=new f(5,"map",!1);f.tag=new f(6,"tag",!1);f.float=new f(7,"float",!0);f.false=new f(7,"false",!0);f.true=new f(7,"true",!0);f.null=new f(7,"null",!0);f.undefined=new f(7,"undefined",!0);f.break=new f(7,"break",!0);var p=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 Tt=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",lu=new TextEncoder;function vr(t){return Tt&&globalThis.Buffer.isBuffer(t)}function Be(t){return t instanceof Uint8Array?vr(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var hu=24,du=200,je=Tt?t=>t.length>=hu?globalThis.Buffer.from(t):Ti(t):t=>t.length>=du?lu.encode(t):Ti(t),se=t=>Uint8Array.from(t),Ci=Tt?(t,e,r)=>vr(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Bi=Tt?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Be(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},Di=Tt?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function kr(t,e){if(vr(t)&&vr(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 Ti(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}var Si=4096;function Ni(t){let e=t.length;if(e<=Si)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Si));return r}var pu=256,St=class{constructor(e=pu){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=Di(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=Ci(n,0,this.cursor)}else r=Bi(this.chunks,this.cursor);return e&&this.reset(),r}},_r=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let r=this.dest.subarray(0,this.cursor);return e&&this.reset(),r}};var y="CBOR decode error:",De="CBOR encode error:",Ct=[];Ct[23]=1;Ct[24]=2;Ct[25]=3;Ct[26]=5;Ct[27]=9;function pe(t,e,r){if(t.length-e<r)throw new Error(`${y} not enough data for type`)}var M=[24,256,65536,4294967296,BigInt("18446744073709551616")];function W(t,e,r){pe(t,e,1);let n=t[e];if(r.strict===!0&&n<M[0])throw new Error(`${y} integer encoded in more bytes than necessary (strict decode)`);return n}function J(t,e,r){pe(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<M[1])throw new Error(`${y} integer encoded in more bytes than necessary (strict decode)`);return n}function Q(t,e,r){pe(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<M[2])throw new Error(`${y} integer encoded in more bytes than necessary (strict decode)`);return n}function Y(t,e,r){pe(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<M[3])throw new Error(`${y} 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(`${y} integers outside of the safe integer range are not supported`)}function Li(t,e,r,n){return new p(f.uint,W(t,e+1,n),2)}function Ui(t,e,r,n){return new p(f.uint,J(t,e+1,n),3)}function Pi(t,e,r,n){return new p(f.uint,Q(t,e+1,n),5)}function Ri(t,e,r,n){return new p(f.uint,Y(t,e+1,n),9)}function Z(t,e){return N(t,0,e.value)}function N(t,e,r){if(r<M[0]){let n=Number(r);t.push([e|n])}else if(r<M[1]){let n=Number(r);t.push([e|24,n])}else if(r<M[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<M[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<M[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=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]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,t.push(o)}else throw new Error(`${y} encountered BigInt larger than allowable range`)}}Z.encodedSize=function(e){return N.encodedSize(e.value)};N.encodedSize=function(e){return e<M[0]?1:e<M[1]?2:e<M[2]?3:e<M[3]?5:9};Z.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Fi(t,e,r,n){return new p(f.negint,-1-W(t,e+1,n),2)}function zi(t,e,r,n){return new p(f.negint,-1-J(t,e+1,n),3)}function Mi(t,e,r,n){return new p(f.negint,-1-Q(t,e+1,n),5)}var vn=BigInt(-1),Oi=BigInt(1);function $i(t,e,r,n){let o=Y(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new p(f.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${y} integers outside of the safe integer range are not supported`);return new p(f.negint,vn-BigInt(o),9)}function Ar(t,e){let r=e.value,n=typeof r=="bigint"?r*vn-Oi:r*-1-1;N(t,e.type.majorEncoded,n)}Ar.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*vn-Oi:r*-1-1;return n<M[0]?1:n<M[1]?2:n<M[2]?3:n<M[3]?5:9};Ar.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function Bt(t,e,r,n){pe(t,e,r+n);let o=t.slice(e+r,e+r+n);return new p(f.bytes,o,r+n)}function Hi(t,e,r,n){return Bt(t,e,1,r)}function Vi(t,e,r,n){return Bt(t,e,2,W(t,e+1,n))}function qi(t,e,r,n){return Bt(t,e,3,J(t,e+1,n))}function ji(t,e,r,n){return Bt(t,e,5,Q(t,e+1,n))}function Gi(t,e,r,n){let o=Y(t,e+1,n);if(typeof o=="bigint")throw new Error(`${y} 64-bit integer bytes lengths not supported`);return Bt(t,e,9,o)}function Ir(t){return t.encodedBytes===void 0&&(t.encodedBytes=f.equals(t.type,f.string)?je(t.value):t.value),t.encodedBytes}function Ge(t,e){let r=Ir(e);N(t,e.type.majorEncoded,r.length),t.push(r)}Ge.encodedSize=function(e){let r=Ir(e);return N.encodedSize(r.length)+r.length};Ge.compareTokens=function(e,r){return yu(Ir(e),Ir(r))};function yu(t,e){return t.length<e.length?-1:t.length>e.length?1:kr(t,e)}var Wi=new TextDecoder,wu=32;function xu(t,e,r){if(r-e<wu){let o="";for(let i=e;i<r;i++){let s=t[i];if(s&128)return Wi.decode(t.subarray(e,r));o+=String.fromCharCode(s)}return o}return Wi.decode(t.subarray(e,r))}function Dt(t,e,r,n,o){let i=r+n;pe(t,e,i);let s=new p(f.string,xu(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=t.slice(e+r,e+i)),s}function Ji(t,e,r,n){return Dt(t,e,1,r,n)}function Qi(t,e,r,n){return Dt(t,e,2,W(t,e+1,n),n)}function Yi(t,e,r,n){return Dt(t,e,3,J(t,e+1,n),n)}function Xi(t,e,r,n){return Dt(t,e,5,Q(t,e+1,n),n)}function Ki(t,e,r,n){let o=Y(t,e+1,n);if(typeof o=="bigint")throw new Error(`${y} 64-bit integer string lengths not supported`);return Dt(t,e,9,o,n)}var Zi=Ge;function We(t,e,r,n){return new p(f.array,n,r)}function es(t,e,r,n){return We(t,e,1,r)}function ts(t,e,r,n){return We(t,e,2,W(t,e+1,n))}function rs(t,e,r,n){return We(t,e,3,J(t,e+1,n))}function ns(t,e,r,n){return We(t,e,5,Q(t,e+1,n))}function os(t,e,r,n){let o=Y(t,e+1,n);if(typeof o=="bigint")throw new Error(`${y} 64-bit integer array lengths not supported`);return We(t,e,9,o)}function is(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${y} indefinite length items not allowed`);return We(t,e,1,1/0)}function Tr(t,e){N(t,f.array.majorEncoded,e.value)}Tr.compareTokens=Z.compareTokens;Tr.encodedSize=function(e){return N.encodedSize(e.value)};function Je(t,e,r,n){return new p(f.map,n,r)}function ss(t,e,r,n){return Je(t,e,1,r)}function as(t,e,r,n){return Je(t,e,2,W(t,e+1,n))}function cs(t,e,r,n){return Je(t,e,3,J(t,e+1,n))}function us(t,e,r,n){return Je(t,e,5,Q(t,e+1,n))}function fs(t,e,r,n){let o=Y(t,e+1,n);if(typeof o=="bigint")throw new Error(`${y} 64-bit integer map lengths not supported`);return Je(t,e,9,o)}function ls(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${y} indefinite length items not allowed`);return Je(t,e,1,1/0)}function Sr(t,e){N(t,f.map.majorEncoded,e.value)}Sr.compareTokens=Z.compareTokens;Sr.encodedSize=function(e){return N.encodedSize(e.value)};function hs(t,e,r,n){return new p(f.tag,r,1)}function ds(t,e,r,n){return new p(f.tag,W(t,e+1,n),2)}function ps(t,e,r,n){return new p(f.tag,J(t,e+1,n),3)}function ms(t,e,r,n){return new p(f.tag,Q(t,e+1,n),5)}function ys(t,e,r,n){return new p(f.tag,Y(t,e+1,n),9)}function Cr(t,e){N(t,f.tag.majorEncoded,e.value)}Cr.compareTokens=Z.compareTokens;Cr.encodedSize=function(e){return N.encodedSize(e.value)};var kn=20,_n=21,An=22,In=23;function gs(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${y} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new p(f.null,null,1):new p(f.undefined,void 0,1)}function ws(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${y} indefinite length items not allowed`);return new p(f.break,void 0,1)}function Tn(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${y} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${y} Infinity values are not supported`)}return new p(f.float,t,e)}function xs(t,e,r,n){return Tn(Sn(t,e+1),3,n)}function bs(t,e,r,n){return Tn(Cn(t,e+1),5,n)}function Es(t,e,r,n){return Tn(As(t,e+1),9,n)}function Nt(t,e,r){let n=e.value;if(n===!1)t.push([f.float.majorEncoded|kn]);else if(n===!0)t.push([f.float.majorEncoded|_n]);else if(n===null)t.push([f.float.majorEncoded|An]);else if(n===void 0)t.push([f.float.majorEncoded|In]);else{let o,i=!1;(!r||r.float64!==!0)&&(ks(n),o=Sn(re,1),n===o||Number.isNaN(n)?(re[0]=249,t.push(re.slice(0,3)),i=!0):(_s(n),o=Cn(re,1),n===o&&(re[0]=250,t.push(re.slice(0,5)),i=!0))),i||(_u(n),o=As(re,1),re[0]=251,t.push(re.slice(0,9)))}}Nt.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){ks(n);let o=Sn(re,1);if(n===o||Number.isNaN(n))return 3;if(_s(n),o=Cn(re,1),n===o)return 5}return 9};var vs=new ArrayBuffer(9),ee=new DataView(vs,1),re=new Uint8Array(vs,0);function ks(t){if(t===1/0)ee.setUint16(0,31744,!1);else if(t===-1/0)ee.setUint16(0,64512,!1);else if(Number.isNaN(t))ee.setUint16(0,32256,!1);else{ee.setFloat32(0,t);let e=ee.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)ee.setUint16(0,31744,!1);else if(r===0)ee.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?ee.setUint16(0,0):o<-14?ee.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):ee.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Sn(t,e){if(t.length-e<2)throw new Error(`${y} 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 _s(t){ee.setFloat32(0,t,!1)}function Cn(t,e){if(t.length-e<4)throw new Error(`${y} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function _u(t){ee.setFloat64(0,t,!1)}function As(t,e){if(t.length-e<8)throw new Error(`${y} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Nt.compareTokens=Z.compareTokens;function _(t,e,r){throw new Error(`${y} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function Br(t){return()=>{throw new Error(`${y} ${t}`)}}var m=[];for(let t=0;t<=23;t++)m[t]=_;m[24]=Li;m[25]=Ui;m[26]=Pi;m[27]=Ri;m[28]=_;m[29]=_;m[30]=_;m[31]=_;for(let t=32;t<=55;t++)m[t]=_;m[56]=Fi;m[57]=zi;m[58]=Mi;m[59]=$i;m[60]=_;m[61]=_;m[62]=_;m[63]=_;for(let t=64;t<=87;t++)m[t]=Hi;m[88]=Vi;m[89]=qi;m[90]=ji;m[91]=Gi;m[92]=_;m[93]=_;m[94]=_;m[95]=Br("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)m[t]=Ji;m[120]=Qi;m[121]=Yi;m[122]=Xi;m[123]=Ki;m[124]=_;m[125]=_;m[126]=_;m[127]=Br("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)m[t]=es;m[152]=ts;m[153]=rs;m[154]=ns;m[155]=os;m[156]=_;m[157]=_;m[158]=_;m[159]=is;for(let t=160;t<=183;t++)m[t]=ss;m[184]=as;m[185]=cs;m[186]=us;m[187]=fs;m[188]=_;m[189]=_;m[190]=_;m[191]=ls;for(let t=192;t<=215;t++)m[t]=hs;m[216]=ds;m[217]=ps;m[218]=ms;m[219]=ys;m[220]=_;m[221]=_;m[222]=_;m[223]=_;for(let t=224;t<=243;t++)m[t]=Br("simple values are not supported");m[244]=_;m[245]=_;m[246]=_;m[247]=gs;m[248]=Br("simple values are not supported");m[249]=xs;m[250]=bs;m[251]=Es;m[252]=_;m[253]=_;m[254]=_;m[255]=ws;var ne=[];for(let t=0;t<24;t++)ne[t]=new p(f.uint,t,1);for(let t=-1;t>=-24;t--)ne[31-t]=new p(f.negint,t,1);ne[64]=new p(f.bytes,new Uint8Array(0),1);ne[96]=new p(f.string,"",1);ne[128]=new p(f.array,0,1);ne[160]=new p(f.map,0,1);ne[244]=new p(f.false,!1,1);ne[245]=new p(f.true,!0,1);ne[246]=new p(f.null,null,1);function Dr(t){switch(t.type){case f.false:return se([244]);case f.true:return se([245]);case f.null:return se([246]);case f.bytes:return t.value.length?void 0:se([64]);case f.string:return t.value===""?se([96]):void 0;case f.array:return t.value===0?se([128]):void 0;case f.map:return t.value===0?se([160]):void 0;case f.uint:return t.value<24?se([Number(t.value)]):void 0;case f.negint:if(t.value>=-24)return se([31-Number(t.value)])}}var Iu={float64:!1,mapSorter:Su,quickEncodeToken:Dr},Bs=Object.freeze({float64:!0,mapSorter:Cu,quickEncodeToken:Dr});function Bn(){let t=[];return t[f.uint.major]=Z,t[f.negint.major]=Ar,t[f.bytes.major]=Ge,t[f.string.major]=Zi,t[f.array.major]=Tr,t[f.map.major]=Sr,t[f.tag.major]=Cr,t[f.float.major]=Nt,t}var Qe=Bn(),Nr=new St,Ut=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(`${De} object contains circular references`);return new t(r,e)}},xe={null:new p(f.null,null),undefined:new p(f.undefined,void 0),true:new p(f.true,!0),false:new p(f.false,!1),emptyArray:new p(f.array,0),emptyMap:new p(f.map,0)},ae={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new p(f.float,t):t>=0?new p(f.uint,t):new p(f.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new p(f.uint,t):new p(f.negint,t)},Uint8Array(t,e,r,n){return new p(f.bytes,t)},string(t,e,r,n){return new p(f.string,t)},boolean(t,e,r,n){return t?xe.true:xe.false},null(t,e,r,n){return xe.null},undefined(t,e,r,n){return xe.undefined},ArrayBuffer(t,e,r,n){return new p(f.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new p(f.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[xe.emptyArray,new p(f.break)]:xe.emptyArray;n=Ut.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=Le(s,r,n);return r.addBreakTokens?[new p(f.array,t.length),o,new p(f.break)]:[new p(f.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length,a;if(s){a=new Array(s),n=Ut.createCheck(n,t);let c=!o&&r.ignoreUndefinedProperties,u=0;for(let l of i){let d=o?t.get(l):t[l];c&&d===void 0||(a[u++]=[Le(l,r,n),Le(d,r,n)])}u<s&&(a.length=u)}return a?.length?(Tu(a,r),r.addBreakTokens?[new p(f.map,a.length),a,new p(f.break)]:[new p(f.map,a.length),a]):r.addBreakTokens===!0?[xe.emptyMap,new p(f.break)]:xe.emptyMap},Tagged(t,e,r,n){return[new p(f.tag,t.tag),Le(t.value,r,n)]}};ae.Map=ae.Object;ae.Buffer=ae.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))ae[`${t}Array`]=ae.DataView;function Le(t,e={},r){let n=En(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||ae[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=ae[n];if(!i)throw new Error(`${De} unsupported type: ${n}`);return i(t,n,e,r)}function Tu(t,e){e.mapSorter&&t.sort(e.mapSorter)}function Su(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Qe[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Cu(t,e){if(t[0]instanceof p&&e[0]instanceof p){let r=t[0],n=e[0];return r._keyBytes||(r._keyBytes=Is(r.value)),n._keyBytes||(n._keyBytes=Is(n.value)),kr(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Is(t){return Dn(t,Qe,Bs)}function Lt(t,e,r,n){if(Array.isArray(e))for(let o of e)Lt(t,o,r,n);else r[e.type.major](t,e,n)}var Ts=f.uint.majorEncoded,Ss=f.negint.majorEncoded,Bu=f.bytes.majorEncoded,Du=f.string.majorEncoded,Cs=f.array.majorEncoded,Nu=f.float.majorEncoded|kn,Lu=f.float.majorEncoded|_n,Uu=f.float.majorEncoded|An,Pu=f.float.majorEncoded|In,Ru=BigInt(-1),Fu=BigInt(1);function zu(t){return t.addBreakTokens!==!0}function Ds(t,e,r,n){let o=En(e),i=r.typeEncoders&&r.typeEncoders[o];if(i){let s=i(e,o,r,n);if(s!=null){Lt(t,s,Qe,r);return}}switch(o){case"null":t.push([Uu]);return;case"undefined":t.push([Pu]);return;case"boolean":t.push([e?Lu:Nu]);return;case"number":!Number.isInteger(e)||!Number.isSafeInteger(e)?Nt(t,new p(f.float,e),r):e>=0?N(t,Ts,e):N(t,Ss,e*-1-1);return;case"bigint":e>=BigInt(0)?N(t,Ts,e):N(t,Ss,e*Ru-Fu);return;case"string":{let s=je(e);N(t,Du,s.length),t.push(s);return}case"Uint8Array":N(t,Bu,e.length),t.push(e);return;case"Array":if(!e.length){t.push([Cs]);return}n=Ut.createCheck(n,e),N(t,Cs,e.length);for(let s of e)Ds(t,s,r,n);return;case"Object":case"Map":{let s=ae.Object(e,o,r,n);Lt(t,s,Qe,r)}return;default:{let s=ae[o];if(!s)throw new Error(`${De} unsupported type: ${o}`);let a=s(e,o,r,n);Lt(t,a,Qe,r)}}}function Dn(t,e,r,n){let o=n instanceof Uint8Array,i=o?new _r(n):Nr,s=Le(t,r);if(!Array.isArray(s)&&r.quickEncodeToken){let a=r.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=e[s.type.major];if(c.encodedSize){let u=c.encodedSize(s,r);if(o||(i=new St(u)),c(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Be(i.chunks[0])}}return i.reset(),Lt(i,s,e,r),i.toBytes(!0)}function Nn(t,e){return e=Object.assign({},Iu,e),zu(e)?(Nr.reset(),Ds(Nr,t,e,void 0),Nr.toBytes(!0)):Dn(t,Qe,e)}var Mu={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Lr=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=ne[e];if(r===void 0){let n=m[e];if(!n)throw new Error(`${y} 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}},be=Symbol.for("DONE"),Ye=Symbol.for("BREAK");function Ou(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=Ee(e,r);if(i===Ye){if(t.value===1/0)break;throw new Error(`${y} got unexpected break to lengthed array`)}if(i===be)throw new Error(`${y} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function $u(t,e,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<t.value;a++){let c=Ee(e,r);if(c===Ye){if(t.value===1/0)break;throw new Error(`${y} got unexpected break to lengthed map`)}if(c===be)throw new Error(`${y} found map but not enough entries (got ${a} [no key], expected ${t.value})`);if(!n&&typeof c!="string")throw new Error(`${y} non-string keys not supported (got ${typeof c})`);if(o&&(n&&s.has(c)||!n&&Object.hasOwn(i,c)))throw new Error(`${y} found repeat map key "${c}"`);let u=Ee(e,r);if(u===be)throw new Error(`${y} found map but not enough entries (got ${a} [no value], expected ${t.value})`);n?s.set(c,u):i[c]=u}return n?s:i}function*Hu(t,e,r){for(let n=0;n<t.value;n++){let o=Ee(e,r);if(o===Ye){if(t.value===1/0)break;throw new Error(`${y} got unexpected break to lengthed map`)}if(o===be)throw new Error(`${y} found map but not enough entries (got ${n} [no key], expected ${t.value})`);let i=Ee(e,r);if(i===be)throw new Error(`${y} found map but not enough entries (got ${n} [no value], expected ${t.value})`);yield[o,i]}}function Vu(t,e){let r=!1,n=function(){if(r)throw new Error(`${y} tag decode() may only be called once`);r=!0;let o=Ee(t,e);if(o===be)throw new Error(`${y} tag content missing`);if(o===Ye)throw new Error(`${y} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${y} tag decode() may only be called once`);r=!0;let o=t.next();if(!f.equals(o.type,f.map))throw new Error(`${y} entries() requires map content, got ${o.type.name}`);let i=[];for(let s of Hu(o,t,e))i.push(s);return i},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function Ee(t,e){if(t.done())return be;let r=t.next();if(f.equals(r.type,f.break))return Ye;if(r.type.terminal)return r.value;if(f.equals(r.type,f.array))return Ou(r,t,e);if(f.equals(r.type,f.map))return $u(r,t,e);if(f.equals(r.type,f.tag)){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Vu(t,e),o=e.tags[r.value](n);if(!n._called)throw new Error(`${y} tag decoder must call decode() or entries()`);return o}throw new Error(`${y} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ln(t,e){if(!(t instanceof Uint8Array))throw new Error(`${y} data to decode must be a Uint8Array`);e=Object.assign({},Mu,e);let r=Be(t),n=e.tokenizer||new Lr(r,e),o=Ee(n,e);if(o===be)throw new Error(`${y} did not find any content to decode`);if(o===Ye)throw new Error(`${y} got unexpected break`);return[o,t.subarray(n.pos())]}function Pt(t,e){let[r,n]=Ln(t,e);if(n.length>0)throw new Error(`${y} too many terminals, data makes no sense`);return r}var Ur=class t{constructor(e,r){if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=e,this.value=r}static decoder(e){return r=>new t(e,r())}static preserve(...e){let r={};for(let n of e)r[n]=t.decoder(n);return r}};Object.defineProperty(Ur.prototype,Symbol.toStringTag,{value:"Tagged"});var Mn={};D(Mn,{base32:()=>Ke,base32hex:()=>tf,base32hexpad:()=>nf,base32hexpadupper:()=>of,base32hexupper:()=>rf,base32pad:()=>Zu,base32padupper:()=>ef,base32upper:()=>Ku,base32z:()=>sf});var wm=new Uint8Array(0);function Ns(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}function me(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return Ue(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return Ue(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function Ls(t){return new TextEncoder().encode(t)}function Us(t){return new TextDecoder().decode(t)}function ju(t){return t?.buffer instanceof ArrayBuffer}function Ue(t){return ju(t)?t:t.slice()}function Gu(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),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function d(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,b=0,E=0,I=h.length;E!==I&&h[E]===0;)E++,x++;for(var v=(I-E)*l+1>>>0,T=new Uint8Array(v);E!==I;){for(var S=h[E],P=0,B=v-1;(S!==0||P<b)&&B!==-1;B--,P++)S+=256*T[B]>>>0,T[B]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");b=P,E++}for(var z=v-b;z!==v&&T[z]===0;)z++;for(var de=c.repeat(x);z<v;++z)de+=t.charAt(T[z]);return de}function g(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 b=0,E=0;h[x]===c;)b++,x++;for(var I=(h.length-x)*u+1>>>0,v=new Uint8Array(I);h[x];){var T=r[h.charCodeAt(x)];if(T===255)return;for(var S=0,P=I-1;(T!==0||S<E)&&P!==-1;P--,S++)T+=a*v[P]>>>0,v[P]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");E=S,x++}if(h[x]!==" "){for(var B=I-E;B!==I&&v[B]===0;)B++;for(var z=new Uint8Array(b+(I-B)),de=b;B!==I;)z[de++]=v[B++];return z}}}function w(h){var x=g(h);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:g,decode:w}}var Wu=Gu,Ju=Wu,Ps=Ju;var Pn=class{name;prefix;baseEncode;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")}},Rn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,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(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 Rs(this,e)}},Fn=class{decoders;constructor(e){this.decoders=e}or(e){return Rs(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Rs(t,e){return new Fn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var zn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Pn(e,r,n),this.decoder=new Rn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Xe({name:t,prefix:e,encode:r,decode:n}){return new zn(t,e,r,n)}function ve({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ps(r,t);return Xe({prefix:e,name:t,encode:n,decode:i=>me(o(i))})}function Qu(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let l=e[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|l,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Yu(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Xu(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function R({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Xu(n);return Xe({prefix:e,name:t,encode(i){return Yu(i,n,r)},decode(i){return Qu(i,o,r,t)}})}var Ke=R({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ku=R({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zu=R({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ef=R({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tf=R({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rf=R({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),nf=R({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),of=R({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sf=R({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var On={};D(On,{base36:()=>Rt,base36upper:()=>af});var Rt=ve({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),af=ve({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var $n={};D($n,{base58btc:()=>ce,base58flickr:()=>cf});var ce=ve({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),cf=ve({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var uf=Ms,Fs=128,ff=127,lf=~ff,hf=Math.pow(2,31);function Ms(t,e,r){e=e||[],r=r||0;for(var n=r;t>=hf;)e[r++]=t&255|Fs,t/=128;for(;t&lf;)e[r++]=t&255|Fs,t>>>=7;return e[r]=t|0,Ms.bytes=r-n+1,e}var df=Hn,pf=128,zs=127;function Hn(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw Hn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&zs)<<o:(s&zs)*Math.pow(2,o),o+=7}while(s>=pf);return Hn.bytes=i-n,r}var mf=Math.pow(2,7),yf=Math.pow(2,14),gf=Math.pow(2,21),wf=Math.pow(2,28),xf=Math.pow(2,35),bf=Math.pow(2,42),Ef=Math.pow(2,49),vf=Math.pow(2,56),kf=Math.pow(2,63),_f=function(t){return t<mf?1:t<yf?2:t<gf?3:t<wf?4:t<xf?5:t<bf?6:t<Ef?7:t<vf?8:t<kf?9:10},Af={encode:uf,decode:df,encodingLength:_f},If=Af,Ft=If;function zt(t,e=0){return[Ft.decode(t,e),Ft.decode.bytes]}function Ze(t,e,r=0){return Ft.encode(t,e,r),e}function et(t){return Ft.encodingLength(t)}function rt(t,e){let r=e.byteLength,n=et(t),o=n+et(r),i=new Uint8Array(o+r);return Ze(t,i,0),Ze(r,i,n),i.set(e,o),new tt(t,r,e,i)}function nt(t){let e=me(t),[r,n]=zt(e),[o,i]=zt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new tt(r,o,s,e)}function Os(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ns(t.bytes,r.bytes)}}var tt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=Ue(n),this.bytes=Ue(o)}};function $s(t,e){let{bytes:r,version:n}=t;return n===0?Sf(r,Vn(t),e??ce.encoder):Cf(r,Vn(t),e??Ke.encoder)}var Hs=new WeakMap;function Vn(t){let e=Hs.get(t);if(e==null){let r=new Map;return Hs.set(t,r),r}return e}var k=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=Ue(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==Mt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Bf)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!=null&&e.code===n.code&&e.version===n.version&&Os(e.multihash,n.multihash)}toString(e){return $s(this,e)}toJSON(){return{"/":$s(this)}}link(){return this}[Symbol.toStringTag]="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:s}=r;return new t(n,o,i,s??Vs(n,o,i.bytes))}else if(r[Df]===!0){let{version:n,multihash:o,code:i}=r,s=nt(o);return t.create(n,i,s)}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!==Mt)throw new Error(`Version 0 CID must use dag-pb (code: ${Mt}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Vs(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Mt,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=me(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new tt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[d,g]=zt(e.subarray(r));return r+=g,d},o=n(),i=Mt;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,l=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,r){let[n,o]=Tf(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 Vn(i).set(n,e),i}};function Tf(t,e){switch(t[0]){case"Q":{let r=e??ce;return[ce.prefix,r.decode(`${ce.prefix}${t}`)]}case ce.prefix:{let r=e??ce;return[ce.prefix,r.decode(t)]}case Ke.prefix:{let r=e??Ke;return[Ke.prefix,r.decode(t)]}case Rt.prefix:{let r=e??Rt;return[Rt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Sf(t,e,r){let{prefix:n}=r;if(n!==ce.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}function Cf(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}var Mt=112,Bf=18;function Vs(t,e,r){let n=et(t),o=n+et(e),i=new Uint8Array(o+r.byteLength);return Ze(t,i,0),Ze(e,i,n),i.set(r,o),i}var Df=Symbol.for("@ipld/js-cid/CID");var qs=42;function Nf(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}function Lf(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=k.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new p(f.tag,qs),new p(f.bytes,r)]}function Uf(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Pf(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}function Rf(t){for(let e of t.keys())if(typeof e!="string"||e.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var qn={float64:!0,typeEncoders:{Map:Rf,Object:Lf,undefined:Uf,number:Pf}},Rm={...qn,typeEncoders:{...qn.typeEncoders}};function Ff(t){let e=t();if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return k.decode(e.subarray(1))}var jn={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{[qs]:Ff}},Fm={...jn,tags:{...jn.tags}};var Rr=113,Gn=t=>Nn(t,qn),Pe=t=>Pt(Nf(t),jn);var Qn=qe(Fr(),1);var Yn=40;function Xn(t,e){if(!t.length)throw new Error("Unexpected end of data");let r=Qn.default.decode(t);return e.seek(Qn.default.decode.bytes),r}function Kn(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=0;return{version:2,characteristics:[e.getBigUint64(r,!0),e.getBigUint64(r+=8,!0)],dataOffset:Number(e.getBigUint64(r+=8,!0)),dataSize:Number(e.getBigUint64(r+=8,!0)),indexOffset:Number(e.getBigUint64(r+=8,!0))}}var _e={Null:t=>t===null?t:void 0,Int:t=>Number.isInteger(t)?t:void 0,Float:t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,String:t=>typeof t=="string"?t:void 0,Bool:t=>typeof t=="boolean"?t:void 0,Bytes:t=>t instanceof Uint8Array?t:void 0,Link:t=>t!==null&&typeof t=="object"&&t.asCID===t?t:void 0,List:t=>Array.isArray(t)?t:void 0,Map:t=>t!==null&&typeof t=="object"&&t.asCID!==t&&!Array.isArray(t)&&!(t instanceof Uint8Array)?t:void 0},$t={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":_e.Link,"CarV1HeaderOrV2Pragma > roots (anon)":t=>{if(_e.List(t)!==void 0){for(let e=0;e<t.length;e++){let r=t[e];if(r=$t["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==t[e]){let n=t.slice(0,e);for(let o=e;o<t.length;o++){let i=t[o];if(i=$t["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return t}},Int:_e.Int,CarV1HeaderOrV2Pragma:t=>{if(_e.Map(t)===void 0)return;let e=Object.entries(t),r=t,n=1;for(let o=0;o<e.length;o++){let[i,s]=e[o];switch(i){case"roots":{let a=$t["CarV1HeaderOrV2Pragma > roots (anon)"](t[i]);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.roots=a}}break;case"version":{n--;let a=$t.Int(t[i]);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},Ht={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":_e.Link,"CarV1HeaderOrV2Pragma > roots (anon)":t=>{if(_e.List(t)!==void 0){for(let e=0;e<t.length;e++){let r=t[e];if(r=Ht["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==t[e]){let n=t.slice(0,e);for(let o=e;o<t.length;o++){let i=t[o];if(i=Ht["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return t}},Int:_e.Int,CarV1HeaderOrV2Pragma:t=>{if(_e.Map(t)===void 0)return;let e=Object.entries(t),r=t,n=1;for(let o=0;o<e.length;o++){let[i,s]=e[o];switch(i){case"roots":{let a=Ht["CarV1HeaderOrV2Pragma > roots (anon)"](s);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.roots=a}}break;case"version":{n--;let a=Ht.Int(s);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},Zn={toTyped:$t.CarV1HeaderOrV2Pragma,toRepresentation:Ht.CarV1HeaderOrV2Pragma};var Km=Bn();var el=qe(Fr(),1);var ny=[new p(f.map,2),new p(f.string,"version"),new p(f.uint,1),new p(f.string,"roots")],oy=new p(f.tag,42);async function eo(t,e){let r=Xn(await t.upTo(8),t);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await t.exactly(r,!0),o=Pe(n);if(Zn.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||e!==void 0&&o.version!==e)throw new Error(`Invalid CAR version: ${o.version}${e!==void 0?` (expected ${e})`:""}`);if(o.version===1){if(!Array.isArray(o.roots))throw new Error("Invalid CAR header format");return o}if(o.roots!==void 0)throw new Error("Invalid CAR header format");let i=Kn(await t.exactly(Yn,!0));t.seek(i.dataOffset-t.pos);let s=await eo(t,1);return Object.assign(s,i)}function Vt(t){let e=0;return{async upTo(r){return t.subarray(e,e+Math.min(r,t.length-e))},async exactly(r,n=!1){if(r>t.length-e)throw new Error("Unexpected end of data");let o=t.subarray(e,e+r);return n&&(e+=r),o},seek(r){e+=r},get pos(){return e}}}var to=qe(Fr(),1),ra=1;function ro(t){let e=Gn({version:ra,roots:t}),r=to.default.encode(e.length),n=new Uint8Array(r.length+e.length);return n.set(r,0),n.set(e,r.length),n}function na(t){return{async setRoots(e){let r=ro(e);await t.write(r)},async writeBlock(e){let{cid:r,bytes:n}=e;await t.write(new Uint8Array(to.default.encode(r.bytes.length+n.length))),await t.write(r.bytes),n.length&&await t.write(n)},async close(){await t.end()},version(){return ra}}}function zr(){}function oa(){let t=[],e=null,r=zr,n=!1,o=null,i=zr,s=()=>(e||(e=new Promise(u=>{r=()=>{e=null,r=zr,u()}})),e),a={write(u){t.push(u);let l=s();return i(),l},async end(){n=!0;let u=s();i(),await u}},c={async next(){let u=t.shift();return u?(t.length===0&&r(),{done:!1,value:u}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(l=>{i=()=>(o=null,i=zr,l(c.next()))})),o)}};return{writer:a,iterator:c}}var qt=class t{constructor(e,r){this._encoder=r,this._mutex=r.setRoots(e),this._ended=!1}async put(e){if(!(e.bytes instanceof Uint8Array)||!e.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=k.asCID(e.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:e.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}version(){return this._encoder.version()}static create(e){e=ol(e);let{encoder:r,iterator:n}=ia(),o=new t(e,r),i=new Mr(n);return{writer:o,out:i}}static createAppender(){let{encoder:e,iterator:r}=ia();e.setRoots=()=>Promise.resolve();let n=new t([],e),o=new Mr(r);return{writer:n,out:o}}static async updateRootsInBytes(e,r){let n=Vt(e);await eo(n);let o=ro(r);if(Number(n.pos)!==o.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${o.length} bytes)`);return e.set(o,0),e}},Mr=class{constructor(e){this._iterator=e}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function ia(){let t=oa(),{writer:e,iterator:r}=t;return{encoder:na(e),iterator:r}}function ol(t){if(t===void 0)return[];if(!Array.isArray(t)){let r=k.asCID(t);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let e=[];for(let r of t){let n=k.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");e.push(n)}return e}function il(t){return t[Symbol.asyncIterator]!=null}function sl(t){if(il(t))return(async()=>{for await(let e of t);})();for(let e of t);}var no=sl;function al(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var Or=al;function cl(t){return t[Symbol.asyncIterator]!=null}function ul(t,e){let r=0;if(cl(t))return(async function*(){for await(let c of t)yield e(c,r++)})();let n=Or(t),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=e(o,r++);if(typeof s.then=="function")return(async function*(){yield await s;for(let c of n)yield e(c,r++)})();let a=e;return(function*(){yield s;for(let c of n)yield a(c,r++)})()}var ot=ul;function fl(t){return t.reason}async function it(t,e,r){if(e==null)return t;let n=r?.translateError??fl;if(e.aborted)return t.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([t,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}var ye=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var Re=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};function ll(t){return typeof t?.handleEvent=="function"}function hl(t){return(t!==!0&&t!==!1&&t?.once)??!1}var $r=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){let o=hl(n);super.addEventListener(e,s=>{if(o){let a=this.#e.get(s.type);a!=null&&(a=a.filter(({callback:c})=>c!==r),this.#e.set(s.type,a))}ll(r)?r.handleEvent(s):r(s)},n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:r,once:o})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var O=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var io=qe(aa(),1);var so=class t extends Error{name="TimeoutError";constructor(e,r){super(e,r),Error.captureStackTrace?.(this,t)}},ca=t=>t.reason??new DOMException("This operation was aborted.","AbortError");function Gt(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=e,a,c,l=new Promise((d,g)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){g(ca(s));return}if(s&&(c=()=>{g(ca(s))},s.addEventListener("abort",c,{once:!0})),t.then(d,g),r===Number.POSITIVE_INFINITY)return;let w=new so;a=i.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(h){g(h)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?d():o instanceof Error?g(o):(w.message=o??`Promise timed out after ${r} milliseconds`,g(w))},r)}).finally(()=>{l.clear(),c&&s&&s.removeEventListener("abort",c)});return l.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},l}function ao(t,e,r){let n=0,o=t.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(t[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var ml=100,st=class{#e=[];#t=0;enqueue(e,r){let{priority:n=0,id:o}=r??{},{size:i}=this,s={priority:n,id:o,run:e};if(i===0){this.#e.length=0,this.#t=0,this.#e.push(s);return}if(this.#e.at(-1).priority>=n){this.#e.push(s);return}this.#i();let a=ao(this.#e,s,(c,u)=>u.priority-c.priority);this.#e.splice(a,0,s)}setPriority(e,r){let n=this.#e.findIndex((i,s)=>s>=this.#t&&i.id===e);if(n===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[o]=this.#e.splice(n,1);this.enqueue(o.run,{priority:r,id:e})}remove(e){let r=this.#e.findIndex((n,o)=>o<this.#t?!1:typeof e=="string"?n.id===e:n.run===e);r!==-1&&this.#e.splice(r,1)}dequeue(){if(this.#t===this.#e.length)return;let e=this.#e[this.#t];return this.#t++,this.#t===this.#e.length?(this.#e.length=0,this.#t=0):this.#t>ml&&this.#t>this.#e.length/2&&this.#i(),e?.run}filter(e){let r=[];for(let n=this.#t;n<this.#e.length;n++){let o=this.#e[n];o.priority===e.priority&&r.push(o.run)}return r}get size(){return this.#e.length-this.#t}#i(){this.#t!==0&&(this.#e.splice(0,this.#t),this.#t=0)}};var Wt=class extends io.default{#e;#t;#i=0;#d;#m=!1;#x=!1;#c;#T=0;#b=0;#u;#f;#a;#s=[];#o=0;#r;#S;#n=0;#y;#l;#L=1n;#g=new Map;#E=new Set;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:st,strict:!1,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);if(e.strict&&e.interval===0)throw new TypeError("The `strict` option requires a non-zero `interval`");if(e.strict&&e.intervalCap===Number.POSITIVE_INFINITY)throw new TypeError("The `strict` option requires a finite `intervalCap`");if(this.#e=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#t=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#c=e.interval,this.#a=e.strict,this.#r=new e.queueClass,this.#S=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#l=e.autoStart===!1,this.#$()}#v(e){for(;this.#o<this.#s.length;){let n=this.#s[this.#o];if(n!==void 0&&e-n>=this.#c)this.#o++;else break}(this.#o>100&&this.#o>this.#s.length/2||this.#o===this.#s.length)&&(this.#s=this.#s.slice(this.#o),this.#o=0)}#U(e){this.#a?this.#s.push(e):this.#i++}#P(){this.#a?this.#s.length>this.#o&&this.#s.pop():this.#i>0&&this.#i--}#k(){return this.#s.length-this.#o}get#R(){return this.#t?!0:this.#a?this.#k()<this.#d:this.#i<this.#d}get#F(){return this.#n<this.#y}#z(){this.#n--,this.#n===0&&this.emit("pendingZero"),this.#w(),this.emit("next")}#M(){this.#f=void 0,this.#D(),this.#B()}#O(e){if(this.#a){if(this.#v(e),this.#k()>=this.#d){let n=this.#s[this.#o],o=this.#c-(e-n);return this.#_(o),!0}return!1}if(this.#u===void 0){let r=this.#T-e;if(r<0){if(this.#b>0){let n=e-this.#b;if(n<this.#c)return this.#_(this.#c-n),!0}this.#i=this.#e?this.#n:0}else return this.#_(r),!0}return!1}#_(e){this.#f===void 0&&(this.#f=setTimeout(()=>{this.#M()},e))}#A(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}#C(){this.#f&&(clearTimeout(this.#f),this.#f=void 0)}#w(){if(this.#r.size===0){if(this.#A(),this.emit("empty"),this.#n===0){if(this.#C(),this.#a&&this.#o>0){let r=Date.now();this.#v(r)}this.emit("idle")}return!1}let e=!1;if(!this.#l){let r=Date.now(),n=!this.#O(r);if(this.#R&&this.#F){let o=this.#r.dequeue();this.#t||(this.#U(r),this.#p()),this.emit("active"),o(),n&&this.#B(),e=!0}}return e}#B(){this.#t||this.#u!==void 0||this.#a||(this.#u=setInterval(()=>{this.#D()},this.#c),this.#T=Date.now()+this.#c)}#D(){this.#a||(this.#i===0&&this.#n===0&&this.#u&&this.#A(),this.#i=this.#e?this.#n:0),this.#I(),this.#p()}#I(){for(;this.#w(););}get concurrency(){return this.#y}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#y=e,this.#I()}setPriority(e,r){if(typeof r!="number"||!Number.isFinite(r))throw new TypeError(`Expected \`priority\` to be a finite number, got \`${r}\` (${typeof r})`);this.#r.setPriority(e,r)}async add(e,r={}){return r={timeout:this.timeout,...r,id:r.id??(this.#L++).toString()},new Promise((n,o)=>{let i=Symbol(`task-${r.id}`),s=()=>{},a=async()=>{s(),this.#n++,this.#g.set(i,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});let u;try{try{r.signal?.throwIfAborted()}catch(g){throw this.#H(),this.#g.delete(i),g}this.#b=Date.now();let l=e({signal:r.signal});if(r.timeout&&(l=Gt(Promise.resolve(l),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#n} running, ${this.#r.size} waiting)`})),r.signal){let{signal:g}=r;l=Promise.race([l,new Promise((w,h)=>{u=()=>{h(g.reason)},g.addEventListener("abort",u,{once:!0})})])}let d=await l;n(d),this.emit("completed",d)}catch(l){o(l),this.emit("error",l)}finally{u&&r.signal?.removeEventListener("abort",u),this.#g.delete(i),queueMicrotask(()=>{this.#z()})}};this.#r.enqueue(a,r);let c=()=>{if(this.#r instanceof st){this.#r.remove(a);return}this.#r.remove?.(r.id)};if(r.signal){let{signal:u}=r,l=()=>{s(),c(),o(u.reason),this.#w(),this.emit("next")};if(s=()=>{u.removeEventListener("abort",l),this.#E.delete(s)},u.aborted){l();return}u.addEventListener("abort",l,{once:!0}),this.#E.add(s)}this.emit("add"),this.#w()})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return this.#l?(this.#l=!1,this.#I(),this):this}pause(){this.#l=!0}clear(){for(let e of this.#E)e();this.#r=new this.#S,this.#A(),this.#N(),this.emit("empty"),this.#n===0&&(this.#C(),this.emit("idle")),this.emit("next")}async onEmpty(){this.#r.size!==0&&await this.#h("empty")}async onSizeLessThan(e){this.#r.size<e||await this.#h("next",()=>this.#r.size<e)}async onIdle(){this.#n===0&&this.#r.size===0||await this.#h("idle")}async onPendingZero(){this.#n!==0&&await this.#h("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#h("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#h("rateLimitCleared")}onError(){return new Promise((e,r)=>{let n=o=>{this.off("error",n),r(o)};this.on("error",n)})}async#h(e,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#r.size}sizeBy(e){return this.#r.filter(e).length}get pending(){return this.#n}get isPaused(){return this.#l}#$(){this.#t||(this.on("add",()=>{this.#r.size>0&&this.#p()}),this.on("next",()=>{this.#p()}))}#p(){this.#t||this.#x||(this.#x=!0,queueMicrotask(()=>{this.#x=!1,this.#N()}))}#H(){this.#t||(this.#P(),this.#p())}#N(){let e=this.#m;if(this.#t||this.#r.size===0){e&&(this.#m=!1,this.emit("rateLimitCleared"));return}let r;if(this.#a){let o=Date.now();this.#v(o),r=this.#k()}else r=this.#i;let n=r>=this.#d;n!==e&&(this.#m=n,this.emit(n?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#m}get isSaturated(){return this.#n===this.#y&&this.#r.size>0||this.isRateLimited&&this.#r.size>0}get runningTasks(){return[...this.#g.values()].map(e=>({...e,timeoutRemaining:e.timeout?Math.max(0,e.startTime+e.timeout-Date.now()):void 0}))}};var ho={};D(ho,{base10:()=>vl});var sg=new Uint8Array(0);function ua(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}function ge(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")}function fa(t){return new TextEncoder().encode(t)}function la(t){return new TextDecoder().decode(t)}function yl(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),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function d(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,b=0,E=0,I=h.length;E!==I&&h[E]===0;)E++,x++;for(var v=(I-E)*l+1>>>0,T=new Uint8Array(v);E!==I;){for(var S=h[E],P=0,B=v-1;(S!==0||P<b)&&B!==-1;B--,P++)S+=256*T[B]>>>0,T[B]=S%a>>>0,S=S/a>>>0;if(S!==0)throw new Error("Non-zero carry");b=P,E++}for(var z=v-b;z!==v&&T[z]===0;)z++;for(var de=c.repeat(x);z<v;++z)de+=t.charAt(T[z]);return de}function g(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 b=0,E=0;h[x]===c;)b++,x++;for(var I=(h.length-x)*u+1>>>0,v=new Uint8Array(I);h[x];){var T=r[h.charCodeAt(x)];if(T===255)return;for(var S=0,P=I-1;(T!==0||S<E)&&P!==-1;P--,S++)T+=a*v[P]>>>0,v[P]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");E=S,x++}if(h[x]!==" "){for(var B=I-E;B!==I&&v[B]===0;)B++;for(var z=new Uint8Array(b+(I-B)),de=b;B!==I;)z[de++]=v[B++];return z}}}function w(h){var x=g(h);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:g,decode:w}}var gl=yl,wl=gl,da=wl;var co=class{name;prefix;baseEncode;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")}},uo=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,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(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 pa(this,e)}},fo=class{decoders;constructor(e){this.decoders=e}or(e){return pa(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function pa(t,e){return new fo({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var lo=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new co(e,r,n),this.decoder=new uo(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function ct({name:t,prefix:e,encode:r,decode:n}){return new lo(t,e,r,n)}function Ae({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=da(r,t);return ct({prefix:e,name:t,encode:n,decode:i=>ge(o(i))})}function xl(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let l=e[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|l,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function bl(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function El(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function F({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=El(n);return ct({prefix:e,name:t,encode(i){return bl(i,n,r)},decode(i){return xl(i,o,r,t)}})}var vl=Ae({prefix:"9",name:"base10",alphabet:"0123456789"});var po={};D(po,{base16:()=>kl,base16upper:()=>_l});var kl=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_l=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var mo={};D(mo,{base2:()=>Al});var Al=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var yo={};D(yo,{base256emoji:()=>Bl});var ma=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Il=ma.reduce((t,e,r)=>(t[r]=e,t),[]),Tl=ma.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Sl(t){return t.reduce((e,r)=>(e+=Il[r],e),"")}function Cl(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Tl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Bl=ct({prefix:"\u{1F680}",name:"base256emoji",encode:Sl,decode:Cl});var go={};D(go,{base32:()=>ut,base32hex:()=>Ul,base32hexpad:()=>Rl,base32hexpadupper:()=>Fl,base32hexupper:()=>Pl,base32pad:()=>Nl,base32padupper:()=>Ll,base32upper:()=>Dl,base32z:()=>zl});var ut=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Dl=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Nl=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ll=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ul=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pl=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Rl=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Fl=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zl=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var wo={};D(wo,{base36:()=>Jt,base36upper:()=>Ml});var Jt=Ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ml=Ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xo={};D(xo,{base58btc:()=>ue,base58flickr:()=>Ol});var ue=Ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ol=Ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var bo={};D(bo,{base64:()=>$l,base64pad:()=>Hl,base64url:()=>Vl,base64urlpad:()=>ql});var $l=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Hl=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Vl=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ql=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Eo={};D(Eo,{base8:()=>jl});var jl=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var vo={};D(vo,{identity:()=>Gl});var Gl=ct({prefix:"\0",name:"identity",encode:t=>la(t),decode:t=>fa(t)});var vg=new TextEncoder,kg=new TextDecoder;var _o={};D(_o,{identity:()=>mh});var Ql=wa,ya=128,Yl=127,Xl=~Yl,Kl=Math.pow(2,31);function wa(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Kl;)e[r++]=t&255|ya,t/=128;for(;t&Xl;)e[r++]=t&255|ya,t>>>=7;return e[r]=t|0,wa.bytes=r-n+1,e}var Zl=ko,eh=128,ga=127;function ko(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw ko.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&ga)<<o:(s&ga)*Math.pow(2,o),o+=7}while(s>=eh);return ko.bytes=i-n,r}var th=Math.pow(2,7),rh=Math.pow(2,14),nh=Math.pow(2,21),oh=Math.pow(2,28),ih=Math.pow(2,35),sh=Math.pow(2,42),ah=Math.pow(2,49),ch=Math.pow(2,56),uh=Math.pow(2,63),fh=function(t){return t<th?1:t<rh?2:t<nh?3:t<oh?4:t<ih?5:t<sh?6:t<ah?7:t<ch?8:t<uh?9:10},lh={encode:Ql,decode:Zl,encodingLength:fh},hh=lh,Qt=hh;function Yt(t,e=0){return[Qt.decode(t,e),Qt.decode.bytes]}function ft(t,e,r=0){return Qt.encode(t,e,r),e}function lt(t){return Qt.encodingLength(t)}function dt(t,e){let r=e.byteLength,n=lt(t),o=n+lt(r),i=new Uint8Array(o+r);return ft(t,i,0),ft(r,i,n),i.set(e,o),new ht(t,r,e,i)}function xa(t){let e=ge(t),[r,n]=Yt(e),[o,i]=Yt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new ht(r,o,s,e)}function ba(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&ua(t.bytes,r.bytes)}}var ht=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var Ea=0,dh="identity",va=ge;function ph(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return dt(Ea,va(t))}var mh={code:Ea,name:dh,encode:va,digest:ph};var To={};D(To,{sha256:()=>gh,sha512:()=>wh});var yh=20;function Io({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Ao(t,e,r,n,o)}var Ao=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??yh,this.maxDigestLength=i}digest(e,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(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?ka(n,this.code,r?.truncate):n.then(o=>ka(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ka(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return dt(e,t)}function Aa(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var gh=Io({name:"sha2-256",code:18,encode:Aa("SHA-256")}),wh=Io({name:"sha2-512",code:19,encode:Aa("SHA-512")});function Ia(t,e){let{bytes:r,version:n}=t;return n===0?bh(r,So(t),e??ue.encoder):Eh(r,So(t),e??ut.encoder)}var Ta=new WeakMap;function So(t){let e=Ta.get(t);if(e==null){let r=new Map;return Ta.set(t,r),r}return e}var qr=class t{code;version;multihash;bytes;"/";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!==Kt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==vh)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=dt(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!=null&&e.code===n.code&&e.version===n.version&&ba(e.multihash,n.multihash)}toString(e){return Ia(this,e)}toJSON(){return{"/":Ia(this)}}link(){return this}[Symbol.toStringTag]="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:s}=r;return new t(n,o,i,s??Sa(n,o,i.bytes))}else if(r[kh]===!0){let{version:n,multihash:o,code:i}=r,s=xa(o);return t.create(n,i,s)}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!==Kt)throw new Error(`Version 0 CID must use dag-pb (code: ${Kt}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Sa(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,Kt,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=ge(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new ht(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[d,g]=Yt(e.subarray(r));return r+=g,d},o=n(),i=Kt;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,l=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,r){let[n,o]=xh(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 So(i).set(n,e),i}};function xh(t,e){switch(t[0]){case"Q":{let r=e??ue;return[ue.prefix,r.decode(`${ue.prefix}${t}`)]}case ue.prefix:{let r=e??ue;return[ue.prefix,r.decode(t)]}case ut.prefix:{let r=e??ut;return[ut.prefix,r.decode(t)]}case Jt.prefix:{let r=e??Jt;return[Jt.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function bh(t,e,r){let{prefix:n}=r;if(n!==ue.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}function Eh(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}var Kt=112,vh=18;function Sa(t,e,r){let n=lt(t),o=n+lt(e),i=new Uint8Array(o+r.byteLength);return ft(t,i,0),ft(e,i,n),i.set(r,o),i}var kh=Symbol.for("@ipld/js-cid/CID");var Co={...vo,...mo,...Eo,...ho,...po,...go,...wo,...xo,...bo,...yo},jg={...To,..._o};function Ca(t=0){return new Uint8Array(t)}function Da(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Ba=Da("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Bo=Da("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Ca(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Yg={utf8:Ba,"utf-8":Ba,hex:Co.base16,latin1:Bo,ascii:Bo,binary:Bo,...Co};var Ih=qe(La(),1);var at;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(at||(at={}));function fe(t=0){return new Uint8Array(t)}var Th=Math.pow(2,7),Sh=Math.pow(2,14),Ch=Math.pow(2,21),Ua=Math.pow(2,28),Pa=Math.pow(2,35),Ra=Math.pow(2,42),Fa=Math.pow(2,49),G=128,Ie=127;function Zt(t){if(t<Th)return 1;if(t<Sh)return 2;if(t<Ch)return 3;if(t<Ua)return 4;if(t<Pa)return 5;if(t<Ra)return 6;if(t<Fa)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function za(t,e,r=0){switch(Zt(t)){case 8:e[r++]=t&255|G,t/=128;case 7:e[r++]=t&255|G,t/=128;case 6:e[r++]=t&255|G,t/=128;case 5:e[r++]=t&255|G,t/=128;case 4:e[r++]=t&255|G,t>>>=7;case 3:e[r++]=t&255|G,t>>>=7;case 2:e[r++]=t&255|G,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Ma(t,e){let r=t[e],n=0;if(n+=r&Ie,r<G||(r=t[e+1],n+=(r&Ie)<<7,r<G)||(r=t[e+2],n+=(r&Ie)<<14,r<G)||(r=t[e+3],n+=(r&Ie)<<21,r<G)||(r=t[e+4],n+=(r&Ie)*Ua,r<G)||(r=t[e+5],n+=(r&Ie)*Pa,r<G)||(r=t[e+6],n+=(r&Ie)*Ra,r<G)||(r=t[e+7],n+=(r&Ie)*Fa,r<G))return n;throw new RangeError("Could not decode varint")}function Bh(t){return t.buffer instanceof ArrayBuffer}function Oa(t){return Bh(t)?t:t.slice()}function Dh(t){return t?.buffer instanceof ArrayBuffer}function $a(t){if(Dh(t))return t;let e=t.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function er(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=fe(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return $a(r)}var Do={};D(Do,{base10:()=>Nh});var Nh=ve({prefix:"9",name:"base10",alphabet:"0123456789"});var No={};D(No,{base16:()=>Lh,base16upper:()=>Uh});var Lh=R({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Uh=R({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Lo={};D(Lo,{base2:()=>Ph});var Ph=R({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Uo={};D(Uo,{base256emoji:()=>Oh});var Ha=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Rh=Ha.reduce((t,e,r)=>(t[r]=e,t),[]),Fh=Ha.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function zh(t){return t.reduce((e,r)=>(e+=Rh[r],e),"")}function Mh(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Fh[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Oh=Xe({prefix:"\u{1F680}",name:"base256emoji",encode:zh,decode:Mh});var Ro={};D(Ro,{base64:()=>Po,base64pad:()=>$h,base64url:()=>Hh,base64urlpad:()=>Vh});var Po=R({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$h=R({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Hh=R({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vh=R({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fo={};D(Fo,{base8:()=>qh});var qh=R({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zo={};D(zo,{identity:()=>jh});var jh=Xe({prefix:"\0",name:"identity",encode:t=>Us(t),decode:t=>Ls(t)});var Gw=new TextEncoder,Gh=new TextDecoder;var jr=512;function Gr(t){return JSON.parse(Gh.decode(t))}var pt=85;var Mo={};D(Mo,{identity:()=>rr});var Va=0,Wh="identity",qa=me;function Jh(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return rt(Va,qa(t))}var rr={code:Va,name:Wh,encode:qa,digest:Jh};var $o={};D($o,{sha256:()=>Yh,sha512:()=>Xh});var Qh=20;function Fe({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Oo(t,e,r,n,o)}var Oo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Qh,this.maxDigestLength=i}digest(e,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(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?ja(n,this.code,r?.truncate):n.then(o=>ja(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ja(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return rt(e,t)}function Wa(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Yh=Fe({name:"sha2-256",code:18,encode:Wa("SHA-256")}),Xh=Fe({name:"sha2-512",code:19,encode:Wa("SHA-512")});var Ho={...zo,...Lo,...Fo,...Do,...No,...Mn,...On,...$n,...Ro,...Uo},ix={...$o,...Mo};function Qa(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Ja=Qa("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Vo=Qa("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=fe(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Kh={utf8:Ja,"utf-8":Ja,hex:Ho.base16,latin1:Vo,ascii:Vo,binary:Vo,...Ho},Ya=Kh;function Jr(t,e="utf8"){let r=Ya[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function H(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var Qr=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},mt=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Qr(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new Qr(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var qo=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function yt(t={}){return Zh(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function Zh(t,e){e=e??{};let r=e.onEnd,n=new mt,o,i,s,a=H(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((b,E)=>{i=I=>{i=null,n.push(I);try{b(t(n))}catch(v){E(v)}return o}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=H()})}},u=b=>i!=null?i(b):(n.push(b),o),l=b=>(n=new mt,i!=null?i({error:b}):(n.push({error:b}),o)),d=b=>{if(s)return o;if(e?.objectMode!==!0&&b?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:b})},g=b=>s?o:(s=!0,b!=null?l(b):u({done:!0})),w=()=>(n=new mt,g(),{done:!0}),h=b=>(g(b),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:w,throw:h,push:d,end:g,get readableLength(){return n.size},onEmpty:async b=>{let E=b?.signal;if(E?.throwIfAborted(),n.isEmpty())return;let I,v;E!=null&&(I=new Promise((T,S)=>{v=()=>{S(new qo)},E.addEventListener("abort",v)}));try{await Promise.race([a.promise,I])}finally{v!=null&&E!=null&&E?.removeEventListener("abort",v)}}},r==null)return o;let x=o;return o={[Symbol.asyncIterator](){return this},next(){return x.next()},throw(b){return x.throw(b),r!=null&&(r(b),r=void 0),{done:!0}},return(){return x.return(),r!=null&&(r(),r=void 0),{done:!0}},push:d,end(b){return x.end(b),r!=null&&(r(b),r=void 0),o},get readableLength(){return x.readableLength},onEmpty:b=>x.onEmpty(b)},o}var ed=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function td(t,e,r){let n,o=new Promise((i,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:u,removeListener:l}=ed(t),d=async(...w)=>{let h=r.multiArgs?w:w[0];if(r.filter)try{if(!await r.filter(h))return}catch(x){n(),s(x);return}c.push(h),r.count===c.length&&(n(),i(c))},g=(...w)=>{n(),s(r.rejectionMultiArgs?w:w[0])};n=()=>{for(let w of a)l(w,d);for(let w of r.rejectionEvents)a.includes(w)||l(w,g)};for(let w of a)u(w,d);for(let w of r.rejectionEvents)a.includes(w)||u(w,g);r.signal&&r.signal.addEventListener("abort",()=>{g(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(c)});if(o.cancel=n,typeof r.timeout=="number"){let i=Gt(o,{milliseconds:r.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function Yr(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=td(t,e,r),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function jo(t,e){let r,n=function(){let o=function(){r=void 0,t()};clearTimeout(r),r=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(r)},n}var Xr=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}};var Kr=class{deferred;signal;onProgress;constructor(e){this.signal=e?.signal,this.onProgress=e?.onProgress,this.deferred=H(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new ye)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function rd(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var Zr=class{id;fn;options;recipients;status;timeline;controller;dispatchingProgress;constructor(e,r){this.id=rd(),this.status="queued",this.fn=e,this.options=r,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.dispatchingProgress=!1,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((r,n)=>r&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new ye),this.cleanup())}async join(e){let r=new Kr(e);return this.recipients.push(r),e?.signal?.addEventListener("abort",this.onAbort),r.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await it(this.fn({...this.options??{},signal:this.controller.signal,onProgress:r=>{if(!this.dispatchingProgress){this.dispatchingProgress=!0;try{this.recipients.forEach(n=>{n.onProgress?.(r)})}finally{this.dispatchingProgress=!1}}}}),this.controller.signal);this.recipients.forEach(r=>{r.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(r=>{r.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var gt=class extends $r{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=jo(this.emitEmpty.bind(this),1),this.emitIdle=jo(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let r of this.queue)if(r.status==="queued"){e=r;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let r=0;r<this.queue.length;r++)if(this.queue[r]===e){this.queue.splice(r,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,r){if(r?.signal?.throwIfAborted(),this.size===this.maxSize)throw new Xr;let n=new Zr(e,r);this.enqueue(n),this.safeDispatchEvent("add");let o=n.join(r).then(i=>(this.safeDispatchEvent("completed",{detail:i}),this.safeDispatchEvent("success",{detail:{job:n,result:i}}),i)).catch(i=>{if(n.status==="queued"){for(let s=0;s<this.queue.length;s++)if(this.queue[s]===n){this.queue.splice(s,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:i}}),i});return this.tryToStartAnother(),o}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new ye)}),this.clear()}async onEmpty(e){this.size!==0&&await Yr(this,"empty",e)}async onSizeLessThan(e,r){this.size<e||await Yr(this,"next",{...r,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await Yr(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let r=yt({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),r.end(c)},o=c=>{c.detail!=null&&r.push(c.detail)},i=c=>{n(c.detail.error)},s=()=>{n()},a=()=>{n(new ye("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",a);try{yield*r}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",a),n()}}};function Xa(t){let e=new globalThis.AbortController;function r(){let i=t.filter(s=>s?.aborted===!0).map(s=>s?.reason).pop();e.abort(i);for(let s of t)s?.removeEventListener!=null&&s.removeEventListener("abort",r)}for(let i of t){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of t)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=e.signal;return o.clear=n,o}var Go=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=H(),this.haveNext=H()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=H(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,r){await this._push(e,r)}async end(e,r){e!=null?await this.throw(e):await this._push(void 0,r)}async _push(e,r){if(e!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=H(),await it(this.readNext.promise,r?.signal,r)}};function Ka(){return new Go}function nd(t){return t[Symbol.asyncIterator]!=null}async function od(t,e,r){try{await Promise.all(t.map(async n=>{for await(let o of n)await e.push(o,{signal:r}),r.throwIfAborted()})),await e.end(void 0,{signal:r})}catch(n){await e.end(n,{signal:r}).catch(()=>{})}}async function*id(t){let e=new AbortController,r=Ka();od(t,r,e.signal).catch(()=>{});try{yield*r}finally{e.abort()}}function*sd(t){for(let e of t)yield*e}function ad(...t){let e=[];for(let r of t)nd(r)||e.push(r);return e.length===t.length?sd(e):id(t)}var Za=ad;function en(t,...e){if(t==null)throw new Error("Empty pipeline");if(Wo(t)){let n=t;t=()=>n.source}else if(tc(t)||ec(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&Wo(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)Wo(r[n])&&(r[n]=ud(r[n]));return cd(...r)}var cd=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},ec=t=>t?.[Symbol.asyncIterator]!=null,tc=t=>t?.[Symbol.iterator]!=null,Wo=t=>t==null?!1:t.sink!=null&&t.source!=null,ud=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=yt({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let o,i=t.source;if(ec(i))o=async function*(){yield*i,n.end()};else if(tc(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Za(n,o())}return t.source};function fd(t){return t[Symbol.asyncIterator]!=null}function ld(t){if(fd(t))return(async()=>{let n=new Uint8Array(0);for await(let o of t)n=er([n,o],n.length+o.length);return n})();let e=[],r=0;for(let n of t)e.push(n),r+=n.byteLength;return er(e,r)}var A=ld;function tn({enumerable:t=!0,configurable:e=!1}={}){return{enumerable:t,configurable:e,writable:!1}}function*hd(t,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[r,n]of e.entries()){let o=[...t,r],i=k.asCID(n);i!=null?yield[o.join("/"),i]:typeof n=="object"&&(yield*Jo(n,o))}else{let r=k.asCID(e);r!=null?yield[t.join("/"),r]:yield*Jo(e,t)}}function*Jo(t,e){if(t==null||t instanceof Uint8Array)return;let r=k.asCID(t);r!=null&&(yield[e.join("/"),r]);for(let[n,o]of Object.entries(t)){let i=[...e,n];yield*hd(i,o)}}function*dd(t,e){if(Array.isArray(e))for(let[r,n]of e.entries()){let o=[...t,r];yield o.join("/"),typeof n=="object"&&k.asCID(n)==null&&(yield*Qo(n,o))}else yield*Qo(e,t)}function*Qo(t,e){if(!(t==null||typeof t!="object"))for(let[r,n]of Object.entries(t)){let o=[...e,r];yield o.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&k.asCID(n)==null&&(yield*dd(o,n))}}function pd(t,e){let r=t;for(let[n,o]of e.entries()){if(r=r[o],r==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(s=>`[${JSON.stringify(s)}]`).join("")}`);let i=k.asCID(r);if(i!=null)return{value:i,remaining:e.slice(n+1).join("/")}}return{value:r}}var Yo=class{cid;bytes;value;asBlock;constructor({cid:e,bytes:r,value:n}){if(e==null||r==null||typeof n>"u")throw new Error("Missing required argument");this.cid=e,this.bytes=r,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:tn(),bytes:tn(),value:tn(),asBlock:tn()})}links(){return Jo(this.value,[])}tree(){return Qo(this.value,[])}get(e="/"){return pd(this.value,e.split("/").filter(Boolean))}};function le({bytes:t,cid:e,value:r,codec:n}){let o=r!==void 0?r:n?.decode(t);if(o===void 0)throw new Error('Missing required argument, must either provide "value" or "codec"');return new Yo({cid:e,bytes:t,value:o})}var rc=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(f.equals(r.type,f.array)&&(r.elements++,r.elements!==1&&e.push([44])),f.equals(r.type,f.map)&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[f.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)}[f.negint.major](e,r){this[f.uint.major](e,r)}[f.bytes.major](e,r){throw new Error(`${De} unsupported type: Uint8Array`)}[f.string.major](e,r){this.prefix(e);let n=je(JSON.stringify(r.value));e.push(n.length>32?Be(n):n)}[f.array.major](e,r){this.prefix(e),this.inRecursive.push({type:f.array,elements:0}),e.push([91])}[f.map.major](e,r){this.prefix(e),this.inRecursive.push({type:f.map,elements:0}),e.push([123])}[f.tag.major](e,r){}[f.float.major](e,r){if(r.type.name==="break"){let s=this.inRecursive.pop();if(s){if(f.equals(s.type,f.array))e.push([93]);else if(f.equals(s.type,f.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(`${De} 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 s=0;s<n.length;s++)o[s]=n.charCodeAt(s),!i&&(o[s]===46||o[s]===101||o[s]===69)&&(i=!0);i||(o.push(46),o.push(48)),e.push(o)}};var wt=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}pos(){return this._pos}done(){return this._pos>=this.data.length}ch(){return this.data[this._pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let 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(`${y} 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(`${y} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this._pos,r=!1,n=!1,o=a=>{for(;!this.done();){let c=this.ch();if(a.includes(c))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 p(f.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(`${y} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${y} 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)),s=parseFloat(i);return n?new p(f.float,s,this._pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(s)?new p(s>=0?f.uint:f.negint,s,this._pos-e):new p(s>=0?f.uint:f.negint,BigInt(i),this._pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${y} unexpected character at position ${this._pos}; this shouldn't happen`);this._pos++;for(let i=this._pos,s=0;i<this.data.length&&s<65536;i++,s++){let a=this.data[i];if(a===92||a<32||a>=128)break;if(a===34){let c=String.fromCharCode.apply(null,this.data.subarray(this._pos,i));return this._pos=i+1,new p(f.string,c,s)}}let e=this._pos,r=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${y} unexpected end of unicode escape sequence at position ${this._pos}`);let i=0;for(let s=0;s<4;s++){let a=this.ch();if(a>=48&&a<=57)a-=48;else if(a>=97&&a<=102)a=a-97+10;else if(a>=65&&a<=70)a=a-65+10;else throw new Error(`${y} unexpected unicode escape character at position ${this._pos}`);i=i*16+a,this._pos++}return i},o=()=>{let i=this.ch(),s=null,a=i>239?4:i>223?3:i>191?2:1;if(this._pos+a>this.data.length)throw new Error(`${y} unexpected unicode sequence at position ${this._pos}`);let c,u,l,d;switch(a){case 1:i<128&&(s=i);break;case 2:c=this.data[this._pos+1],(c&192)===128&&(d=(i&31)<<6|c&63,d>127&&(s=d));break;case 3:c=this.data[this._pos+1],u=this.data[this._pos+2],(c&192)===128&&(u&192)===128&&(d=(i&15)<<12|(c&63)<<6|u&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=this.data[this._pos+1],u=this.data[this._pos+2],l=this.data[this._pos+3],(c&192)===128&&(u&192)===128&&(l&192)===128&&(d=(i&15)<<18|(c&63)<<12|(u&63)<<6|l&63,d>65535&&d<1114112&&(s=d))}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),this._pos+=a};for(;!this.done();){let i=this.ch(),s;switch(i){case 92:if(this._pos++,this.done())throw new Error(`${y} unexpected string termination at position ${this._pos}`);switch(s=this.ch(),this._pos++,s){case 34:case 39:case 92:case 47:r.push(s);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(`${y} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new p(f.string,Ni(r),this._pos-e);default:if(i<32)throw new Error(`${y} invalid control character at position ${this._pos}`);i<128?(r.push(i),this._pos++):o()}}throw new Error(`${y} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new p(f.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new p(f.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new p(f.null,null,4);case 102:return this.expect([102,97,108,115,101]),new p(f.false,!1,5);case 116:return this.expect([116,114,117,101]),new p(f.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(`${y} 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 p(f.break,void 0,1);if(this.ch()!==44)throw new Error(`${y} 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 p(f.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 p(f.break,void 0,1);if(this.ch()!==44)throw new Error(`${y} 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 p(f.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${y} 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(`${y} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function Xo(t,e){return e=Object.assign({tokenizer:new wt(t,e)},e),Pt(t,e)}function gd(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var Ko=class extends wt{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(f.equals(e.type,f.map)){let r=this._next();if(f.equals(r.type,f.string)&&r.value==="/"){let n=this._next();if(f.equals(n.type,f.string)){let o=this._next();if(!f.equals(o.type,f.break))throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new p(f.tag,42,0)}if(f.equals(n.type,f.map)){let o=this._next();if(f.equals(o.type,f.string)&&o.value==="bytes"){let i=this._next();if(f.equals(i.type,f.string)){for(let a=0;a<2;a++){let c=this._next();if(!f.equals(c.type,f.break))throw new Error("Invalid encoded Bytes form")}let s=Po.decode(`m${i.value}`);return new p(f.bytes,s,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},nc={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{42:t=>k.parse(t())}};var rn=297;var nn=t=>{let e=gd(t),r=Object.assign(nc,{tokenizer:new Ko(e,nc)});return Xo(e,r)};var l0=new TextDecoder;var h0=new TextEncoder;var wd=new TextDecoder;function Zo(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let o=t[e++];if(r+=n<28?(o&127)<<n:(o&127)*2**n,o<128)break}return[r,e]}function sn(t,e){let r;[r,e]=Zo(t,e);let n=e+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function oc(t,e){let r;return[r,e]=Zo(t,e),[r&7,r>>3,e]}function xd(t){let e={},r=t.length,n=0;for(;n<r;){let o,i;if([o,i,n]=oc(t,n),i===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=sn(t,n)}else if(i===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=sn(t,n),e.Name=wd.decode(s)}else if(i===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(o!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Tsize`);[e.Tsize,n]=Zo(t,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${i}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function ic(t){let e=t.length,r=0,n,o=!1,i;for(;r<e;){let a,c;if([a,c,r]=oc(t,r),a!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${a}`);if(c===1){if(i)throw new Error("protobuf: (PBNode) duplicate Data section");[i,r]=sn(t,r),n&&(o=!0)}else if(c===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let u;[u,r]=sn(t,r),n.push(xd(u))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${c}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return i&&(s.Data=i),s.Links=n||[],s}var ac=new TextEncoder,sc=2**32,bd=2**31;function Ed(t,e){let r=e.length;if(typeof t.Tsize=="number"){if(t.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(t.Tsize))throw new Error("Tsize too large for encoding");r=nr(e,r,t.Tsize)-1,e[r]=24}if(typeof t.Name=="string"){let n=ac.encode(t.Name);r-=n.length,e.set(n,r),r=nr(e,r,n.length)-1,e[r]=18}return t.Hash&&(r-=t.Hash.length,e.set(t.Hash,r),r=nr(e,r,t.Hash.length)-1,e[r]=10),e.length-r}function cc(t){let e=kd(t),r=new Uint8Array(e),n=e;if(t.Data&&(n-=t.Data.length,r.set(t.Data,n),n=nr(r,n,t.Data.length)-1,r[n]=10),t.Links)for(let o=t.Links.length-1;o>=0;o--){let i=Ed(t.Links[o],r.subarray(0,n));n-=i,n=nr(r,n,i)-1,r[n]=18}return r}function vd(t){let e=0;if(t.Hash){let r=t.Hash.length;e+=1+r+xt(r)}if(typeof t.Name=="string"){let r=ac.encode(t.Name).length;e+=1+r+xt(r)}return typeof t.Tsize=="number"&&(e+=1+xt(t.Tsize)),e}function kd(t){let e=0;if(t.Data){let r=t.Data.length;e+=1+r+xt(r)}if(t.Links)for(let r of t.Links){let n=vd(r);e+=1+n+xt(n)}return e}function nr(t,e,r){e-=xt(r);let n=e;for(;r>=bd;)t[e++]=r&127|128,r/=128;for(;r>=128;)t[e++]=r&127|128,r>>>=7;return t[e]=r,n}function xt(t){return t%2===0&&t++,Math.floor((_d(t)+6)/7)}function _d(t){let e=0;return t>=sc&&(t=Math.floor(t/sc),e=32),t>=65536&&(t>>>=16,e+=16),t>=256&&(t>>>=8,e+=8),e+Ad[t]}var Ad=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];var Id=["Data","Links"],Td=["Hash","Name","Tsize"],uc=new TextEncoder;function Sd(t,e){if(t===e)return 0;let r=t.Name?uc.encode(t.Name):[],n=e.Name?uc.encode(e.Name):[],o=r.length,i=n.length;for(let s=0,a=Math.min(o,i);s<a;++s)if(r[s]!==n[s]){o=r[s],i=n[s];break}return o<i?-1:i<o?1:0}function fc(t,e){return!Object.keys(t).some(r=>!e.includes(r))}function lc(t){if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form");if(!fc(t,Id))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(t.Data!==void 0&&!(t.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(t.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let e=0;e<t.Links.length;e++){let r=t.Links[e];if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!fc(r,Td))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(r.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(r.Hash==null||!r.Hash["/"]||r.Hash["/"]!==r.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(r.Name!==void 0&&typeof r.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(r.Tsize!==void 0){if(typeof r.Tsize!="number"||r.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(r.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(e>0&&Sd(r,t.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function hc(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var bt=112;function dc(t){lc(t);let e={};return t.Links&&(e.Links=t.Links.map(r=>{let n={};return r.Hash&&(n.Hash=r.Hash.bytes),r.Name!==void 0&&(n.Name=r.Name),r.Tsize!==void 0&&(n.Tsize=r.Tsize),n})),t.Data&&(e.Data=t.Data),cc(e)}function he(t){let e=hc(t),r=ic(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(o=>{let i={};try{i.Hash=k.decode(o.Hash)}catch{}if(!i.Hash)throw new Error("Invalid Hash field found in link, expected CID");return o.Name!==void 0&&(i.Name=o.Name),o.Tsize!==void 0&&(i.Tsize=o.Tsize),i})),n}function Cd(t){return t[Symbol.asyncIterator]!=null}function Bd(t,e){let r=0;if(Cd(t))return(async function*(){for await(let c of t)await e(c,r++)&&(yield c)})();let n=Or(t),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=e(o,r++);if(typeof s.then=="function")return(async function*(){await s&&(yield o);for(let c of n)await e(c,r++)&&(yield c)})();let a=e;return(function*(){s===!0&&(yield o);for(let c of n)a(c,r++)&&(yield c)})()}var pc=Bd;function ze(t){return e=>new ei(e,t)}function Me(t){return e=>new ti(e,t)}function ni(t){return e=>new ri(e,t)}var ir=class{components;constructor(e,r={}){this.components=e}async*walk(e,r){let n=this.getQueue(),o=pc(n.toGenerator(r),a=>a!=null),i=!1,s=async a=>{let c=a.cid,u=await A(this.components.blockstore.get(c,a)),l=le({cid:c,bytes:u,codec:await this.components.getCodec(c.code)});for(let[,d]of l.links())r?.includeChild?.(d,l)!==!1&&n.add(s,{...a,cid:d,depth:a.depth+1,path:[...a.path,d]}).catch(g=>{i||o.throw(g)});return{block:l,depth:a.depth,path:a.path}};n.add(s,{...r,cid:e,depth:0,path:[e]}).catch(a=>{i||o.throw(a)});try{yield*o}finally{i=!0,n.abort()}}},ei=class extends ir{getQueue(){return new gt({concurrency:1,sort:(e,r)=>e.options.depth===r.options.depth?0:e.options.depth<r.options.depth?1:-1})}},ti=class extends ir{getQueue(){return new gt({concurrency:1,sort:(e,r)=>e.options.depth===r.options.depth?0:e.options.depth<r.options.depth?-1:1})}},ri=class extends ir{getQueue(){return new gt({concurrency:1})}};var sr=class{walker;constructor(e){this.walker=e?.walker}async*export(e,r,n,o){let i,s={blockstore:r,getCodec:n};this.walker!=null?i=this.walker(s):i=Me()(s);for await(let a of i.walk(e,o))yield a.block}};var an=class{components;log;constructor(e){this.components=e,this.log=e.logger.forComponent("helia:car")}async import(e,r){await no(this.components.blockstore.putMany(ot(e.blocks(),({cid:n,bytes:o})=>({cid:n,bytes:o})),r))}async*export(e,r){let n=Array.isArray(e)?e:[e],{writer:o,out:i}=qt.create(n),s=i[Symbol.asyncIterator](),a=new AbortController;for(this._export(n,o,r).catch(c=>{this.log.error("error during streaming export - %e",c),a.abort(c)});;){let{done:c,value:u}=await it(s.next(),a.signal);if(a.signal.aborted)throw a.signal.reason;if(u!=null&&(yield u),c===!0)break}}async _export(e,r,n){let o=n?.traversal;for(let i of e){if(i.multihash.code===0)continue;let s=n?.exporter??(i.code===112?new ar:new sr),a=i,c=!1;if(o!=null){for await(let{cid:u,bytes:l}of o.traverse(a,this.components.blockstore,this.components.getCodec,n))if(this.log.trace("next CID on path to %c is %c",i,u),a=u,i.equals(u)&&(c=!0),c||n?.includeTraversalBlocks===!0){if(n?.blockFilter?.has(u.multihash.bytes)===!0)continue;n?.blockFilter?.add(u.multihash.bytes),await r.put({cid:u,bytes:l})}}for await(let{cid:u,bytes:l}of s.export(a,this.components.blockstore,this.components.getCodec,n))n?.blockFilter?.has(u.multihash.bytes)!==!0&&u.multihash.code!==0&&(c&&u.equals(a)||(n?.blockFilter?.add(u.multihash.bytes),await r.put({cid:u,bytes:l})))}await r.close()}};var oi=class{async*export(e,r,n,o){let i=await A(r.get(e,o));yield le({cid:e,bytes:i,codec:await n(e.code)})}};var cr=class t extends Error{static name="InvalidTypeError";static code="ERR_INVALID_TYPE";name=t.name;code=t.code;constructor(e="Invalid type"){super(e)}};var ii=new Float32Array([-0]),Te=new Uint8Array(ii.buffer);function yc(t,e,r){ii[0]=t,e[r]=Te[0],e[r+1]=Te[1],e[r+2]=Te[2],e[r+3]=Te[3]}function gc(t,e){return Te[0]=t[e],Te[1]=t[e+1],Te[2]=t[e+2],Te[3]=t[e+3],ii[0]}var si=new Float64Array([-0]),V=new Uint8Array(si.buffer);function wc(t,e,r){si[0]=t,e[r]=V[0],e[r+1]=V[1],e[r+2]=V[2],e[r+3]=V[3],e[r+4]=V[4],e[r+5]=V[5],e[r+6]=V[6],e[r+7]=V[7]}function xc(t,e){return V[0]=t[e],V[1]=t[e+1],V[2]=t[e+2],V[3]=t[e+3],V[4]=t[e+4],V[5]=t[e+5],V[6]=t[e+6],V[7]=t[e+7],si[0]}var Nd=BigInt(Number.MAX_SAFE_INTEGER),Ld=BigInt(Number.MIN_SAFE_INTEGER),X=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Oe;if(e<Nd&&e>Ld)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>bc&&(o=0n,++n>bc&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Oe;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Oe}},Oe=new X(0,0);Oe.toBigInt=function(){return 0n};Oe.zzEncode=Oe.zzDecode=function(){return this};Oe.length=function(){return 1};var bc=4294967296n;function Ec(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function vc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function ai(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function oe(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function cn(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var ci=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=Oa(e),this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,oe(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw oe(this,4);return cn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw oe(this,4);return cn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw oe(this,4);let e=gc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw oe(this,4);let e=xc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw oe(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return vc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw oe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw oe(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new X(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw oe(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw oe(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw oe(this,8);let e=cn(this.buf,this.pos+=4),r=cn(this.buf,this.pos+=4);return new X(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Ma(this.buf,this.pos);return this.pos+=Zt(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ur(t){return new ci(t instanceof Uint8Array?t:t.subarray())}function fr(t,e,r){let n=ur(t);return e.decode(n,void 0,r)}function ui(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return fe(s);o+s>e&&(n=fe(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var $e=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function fi(){}var hi=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Ud=ui();function Pd(t){return globalThis.Buffer!=null?fe(t):Ud(t)}var hr=class{len;head;tail;states;constructor(){this.len=0,this.head=new $e(fi,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new $e(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new di((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(un,10,X.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=X.fromBigInt(e);return this._push(un,r.length(),r)}uint64Number(e){return this._push(za,Zt(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=X.fromBigInt(e).zzEncode();return this._push(un,r.length(),r)}sint64Number(e){let r=X.fromNumber(e).zzEncode();return this._push(un,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(li,1,e?1:0)}fixed32(e){return this._push(lr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=X.fromBigInt(e);return this._push(lr,4,r.lo)._push(lr,4,r.hi)}fixed64Number(e){let r=X.fromNumber(e);return this._push(lr,4,r.lo)._push(lr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(yc,4,e)}double(e){return this._push(wc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(li,1,0):this.uint32(r)._push(Fd,r,e)}string(e){let r=Ec(e);return r!==0?this.uint32(r)._push(ai,r,e):this._push(li,1,0)}fork(){return this.states=new hi(this),this.head=this.tail=new $e(fi,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new $e(fi,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=Pd(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function li(t,e,r){e[r]=t&255}function Rd(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var di=class extends $e{next;constructor(e,r){super(Rd,e,r),this.next=void 0}};function un(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function lr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Fd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(hr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(zd,e,t),this},hr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Md,e,t),this});function zd(t,e,r){e.set(t,r)}function Md(t,e,r){t.length<40?ai(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Jr(t),r)}function pi(){return new hr}function dr(t,e){let r=pi();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*pr(t,e,r){let n=ur(t);yield*e.stream(n,void 0,"$",r)}var fn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function ln(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function mi(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(s,a){let c=e(s);a.int32(c)},n=function(s){let a=s.int32();return e(a)},o=function*(s){let a=s.int32();yield e(a)};return ln("enum",fn.VARINT,r,n,o)}function mr(t,e,r){return ln("message",fn.LENGTH_DELIMITED,t,e,r)}var yr=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var ie;(function(t){let e;(function(a){a.Raw="Raw",a.Directory="Directory",a.File="File",a.Metadata="Metadata",a.Symlink="Symlink",a.HAMTShard="HAMTShard"})(e=t.DataType||(t.DataType={}));let r;(function(a){a[a.Raw=0]="Raw",a[a.Directory=1]="Directory",a[a.File=2]="File",a[a.Metadata=3]="Metadata",a[a.Symlink=4]="Symlink",a[a.HAMTShard=5]="HAMTShard"})(r||(r={})),(function(a){a.codec=()=>mi(r)})(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=mr((a,c,u={})=>{if(u.lengthDelimited!==!1&&c.fork(),a.Type!=null&&(c.uint32(8),t.DataType.codec().encode(a.Type,c)),a.Data!=null&&(c.uint32(18),c.bytes(a.Data)),a.filesize!=null&&(c.uint32(24),c.uint64(a.filesize)),a.blocksizes!=null&&a.blocksizes.length>0)for(let l of a.blocksizes)c.uint32(32),c.uint64(l);a.hashType!=null&&(c.uint32(40),c.uint64(a.hashType)),a.fanout!=null&&(c.uint32(48),c.uint64(a.fanout)),a.mode!=null&&(c.uint32(56),c.uint32(a.mode)),a.mtime!=null&&(c.uint32(66),gr.codec().encode(a.mtime,c)),u.lengthDelimited!==!1&&c.ldelim()},(a,c,u={})=>{let l={blocksizes:[]},d=c==null?a.len:a.pos+c;for(;a.pos<d;){let g=a.uint32();switch(g>>>3){case 1:{l.Type=t.DataType.codec().decode(a);break}case 2:{l.Data=a.bytes();break}case 3:{l.filesize=a.uint64();break}case 4:{if(u.limits?.blocksizes!=null&&l.blocksizes.length===u.limits.blocksizes)throw new yr('Decode error - repeated field "blocksizes" had too many elements');l.blocksizes.push(a.uint64());break}case 5:{l.hashType=a.uint64();break}case 6:{l.fanout=a.uint64();break}case 7:{l.mode=a.uint32();break}case 8:{l.mtime=gr.codec().decode(a,a.uint32(),{limits:u.limits?.mtime});break}default:{a.skipType(g&7);break}}}return l},function*(a,c,u,l={}){let d={blocksizes:0},g=c==null?a.len:a.pos+c;for(;a.pos<g;){let w=a.uint32();switch(w>>>3){case 1:{yield{field:`${u}.Type`,value:t.DataType.codec().decode(a)};break}case 2:{yield{field:`${u}.Data`,value:a.bytes()};break}case 3:{yield{field:`${u}.filesize`,value:a.uint64()};break}case 4:{if(l.limits?.blocksizes!=null&&d.blocksizes===l.limits.blocksizes)throw new yr('Streaming decode error - repeated field "blocksizes" had too many elements');yield{field:`${u}.blocksizes[]`,index:d.blocksizes,value:a.uint64()},d.blocksizes++;break}case 5:{yield{field:`${u}.hashType`,value:a.uint64()};break}case 6:{yield{field:`${u}.fanout`,value:a.uint64()};break}case 7:{yield{field:`${u}.mode`,value:a.uint32()};break}case 8:{yield*gr.codec().stream(a,a.uint32(),`${u}.mtime`,{limits:l.limits?.mtime});break}default:{a.skipType(w&7);break}}}})),n);function o(a){return dr(a,t.codec())}t.encode=o;function i(a,c){return fr(a,t.codec(),c)}t.decode=i;function s(a,c){return pr(a,t.codec(),c)}t.stream=s})(ie||(ie={}));var gr;(function(t){let e;t.codec=()=>(e==null&&(e=mr((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Seconds!=null&&(s.uint32(8),s.int64(i.Seconds)),i.FractionalNanoseconds!=null&&(s.uint32(21),s.fixed32(i.FractionalNanoseconds)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{c.Seconds=i.int64();break}case 2:{c.FractionalNanoseconds=i.fixed32();break}default:{i.skipType(l&7);break}}}return c},function*(i,s,a,c={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{yield{field:`${a}.Seconds`,value:i.int64()};break}case 2:{yield{field:`${a}.FractionalNanoseconds`,value:i.fixed32()};break}default:{i.skipType(l&7);break}}}})),e);function r(i){return dr(i,t.codec())}t.encode=r;function n(i,s){return fr(i,t.codec(),s)}t.decode=n;function o(i,s){return pr(i,t.codec(),s)}t.stream=o})(gr||(gr={}));var _c;(function(t){let e;t.codec=()=>(e==null&&(e=mr((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.MimeType!=null&&(s.uint32(10),s.string(i.MimeType)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();l>>>3===1?c.MimeType=i.string():i.skipType(l&7)}return c},function*(i,s,a,c={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();l>>>3===1?yield{field:`${a}.MimeType`,value:i.string()}:i.skipType(l&7)}})),e);function r(i){return dr(i,t.codec())}t.encode=r;function n(i,s){return fr(i,t.codec(),s)}t.decode=n;function o(i,s){return pr(i,t.codec(),s)}t.stream=o})(_c||(_c={}));var Ac={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},Od=["directory","hamt-sharded-directory"],Ic=parseInt("0644",8),Tc=parseInt("0755",8),q=class t{static unmarshal(e){let r=ie.decode(e),n=new t({type:Ac[r.Type!=null?r.Type.toString():"File"],data:r.Data,blockSizes:r.blocksizes,mode:r.mode,mtime:r.mtime!=null?{secs:r.mtime.Seconds??0n,nsecs:r.mtime.FractionalNanoseconds}:void 0,fanout:r.fanout});return n._originalMode=r.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){let{type:r,data:n,blockSizes:o,hashType:i,fanout:s,mtime:a,mode:c}=e;if(r!=null&&!Object.values(Ac).includes(r))throw new cr("Type: "+r+" is not valid");this.type=r??"file",this.data=n,this.hashType=i,this.fanout=s,this.blockSizes=o??[],this._originalMode=0,this.mode=c,this.mtime=a}set mode(e){e==null?this._mode=this.isDirectory()?Tc:Ic:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return Od.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach(r=>{e+=r}),this.data!=null&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=ie.DataType.Raw;break;case"directory":e=ie.DataType.Directory;break;case"file":e=ie.DataType.File;break;case"metadata":e=ie.DataType.Metadata;break;case"symlink":e=ie.DataType.Symlink;break;case"hamt-sharded-directory":e=ie.DataType.HAMTShard;break;default:throw new cr(`Type: ${e} is not valid`)}let r=this.data;(this.data==null||this.data.length===0)&&(r=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===Ic&&!this.isDirectory()&&(n=void 0),n===Tc&&this.isDirectory()&&(n=void 0));let o;return this.mtime!=null&&(o={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),ie.encode({Type:e,Data:r,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:o})}};var wr=class extends Error{static code="ERR_NOT_UNIXFS";static message="Not a UnixFS node";static name="NotUnixFSError";code="ERR_NOT_UNIXFS";message="Not a UnixFS node";name="NotUnixFSError"},hn=class extends Error{static name="NotDescendantError";name="NotDescendantError"},Et=class extends Error{static name="InvalidTraversalError";name="InvalidTraversalError"};function Hd(t){return t.cid.code===85}function Vd(t){return t.cid.code===112}function qd(t){if(Hd(t))return!0;if(Vd(t)&&t.value.Data!=null){let e=q.unmarshal(t.value.Data);return e.type==="file"||e.type==="raw"}else throw new wr("Encountered non raw/dag-pb CID in UnixFS DAG")}var ar=class{options;constructor(e){this.options=e}async*export(e,r,n,o){if(e.code!==112&&e.code!==85)throw new wr("Target CID was not UnixFS - use the SubGraphExporter to export arbitrary graphs");let i=ze()({blockstore:r,getCodec:n}),s=this.options?.offset??0,a=this.options?.length??1/0,c=this.options?.listingOnly??!1;if(s<0)throw new Re("Offset cannot be negative");if(a<0)throw new Re("Length cannot be negative");let u,l=new AbortController,d=Xa([l.signal,o?.signal]);l.signal;function g(w,h){if(u==null&&(u=qd(h)),!u){let S=h.value.Links.find(B=>B.Hash.equals(w)),P=q.unmarshal(h.value.Data??new Uint8Array);return P.type==="directory"?!c:P.type==="hamt-sharded-directory"&&c?S?.Name?.length===2:!0}let x=h.value.Links.findIndex(S=>S.Hash.equals(w)),b=q.unmarshal(h.value.Data??new Uint8Array),E=s,I=E+a,v=Number([...b.blockSizes].slice(0,x).reduce((S,P)=>S+P,0n)),T=v+Number(b.blockSizes[x]);return E>=v&&E<T||I>=v&&I<T||E<=v&&I>=T}try{for await(let w of i.walk(e,{...o,includeChild:g,signal:d}))yield w.block}finally{l.abort(),d.clear()}}};function Sc(t){return t!=null&&t?.asCID===t}var yi=class{haystack;needle;options;walker;constructor(...e){if(Sc(e[0]))Sc(e[1])?(this.haystack=e[0],this.needle=e[1],this.options=e[2]):(this.needle=e[0],this.options=e[1]);else throw new Re("needle must be specified");this.walker=this.options?.walker}async*traverse(e,r,n,o){let i=this.haystack??e,s,a={blockstore:r,getCodec:n};this.walker!=null?s=this.walker(a):this.options?.strategy==="breadth-first"?s=Me()(a):s=ze()(a);for await(let c of s.walk(i,o))if(c.block.cid.equals(this.needle)){for(let u of c.path){let l=await A(r.get(u,o));yield le({cid:u,bytes:l,codec:await n(u.code)})}return}throw new Et(`${this.needle} was not a child of ${i}`)}};var gi=class{path;constructor(e){this.path=e}async*traverse(e,r,n,o){if(!this.path.some(s=>s.equals(e)))throw new Et(`CIDPath traversal must include ${e}`);let i;for(let s of this.path){if(i!=null){let u=!1;for(let[,l]of i.links())if(l.equals(s)){u=!0;break}if(!u)throw new hn(`${s} is not a child of ${i.cid}`)}let a=await A(r.get(s,o)),c=le({cid:s,bytes:a,codec:await n(s.code)});i=c,yield c}}};var vt=class t extends Error{static name="BadPathError";static code="ERR_BAD_PATH";name=t.name;code=t.code;constructor(e="Bad path"){super(e)}},K=class t extends Error{static name="NotFoundError";static code="ERR_NOT_FOUND";name=t.name;code=t.code;constructor(e="Not found"){super(e)}},kt=class t extends Error{static name="NoResolverError";static code="ERR_NO_RESOLVER";name=t.name;code=t.code;constructor(e="No resolver"){super(e)}},L=class t extends Error{static name="NotUnixFSError";static code="ERR_NOT_UNIXFS";name=t.name;code=t.code;constructor(e="Not UnixFS"){super(e)}},dn=class t extends Error{static name="OverReadError";static code="ERR_OVER_READ";name=t.name;code=t.code;constructor(e="Over read"){super(e)}},pn=class t extends Error{static name="UnderReadError";static code="ERR_UNDER_READ";name=t.name;code=t.code;constructor(e="Under read"){super(e)}},we=class t extends Error{static name="InvalidParametersError";static code="ERR_INVALID_PARAMS";name=t.name;code=t.code;constructor(e="Invalid parameters"){super(e)}};function _t(t){return t==null?!1:k.asCID(t)===t}function At(t,e){let r,n=0,o="";for(;n<e.length;){let i=e[n];if(n++,!Object.hasOwnProperty.call(t,i))throw new vt(`Object did not have key "${i}"`);if(o+=`/${i}`,r=t[i],t=r,_t(r))break}return{value:r,rest:e.slice(n),path:o.substring(1)}}async function*wi(t,e,r,n){let o=await A(r.get(t,n)),i=Pe(o),s=At(i,e);yield{cid:_t(s.value)?s.value:t,name:s.path,rest:s.rest}}async function*Cc(t,e,r,n){let o=await A(r.get(t,n)),i=nn(o),s=At(i,e);yield{cid:_t(s.value)?s.value:t,name:s.path,rest:s.rest}}function Se(t,e){let r=t.lo+e.lo>>>0,n=t.hi+e.hi+(r<t.lo?1:0)>>>0;return{lo:r,hi:n}}function jd(t,e){return t+e>>>0}function te(t,e){let r=t.lo&65535,n=t.lo>>>16,o=e.lo&65535,i=e.lo>>>16,s=r*o,a=r*i,c=n*o,u=n*i,l=(s>>>16)+(a&65535)+(c&65535)>>>0,d=(l<<16|s&65535)>>>0,g=u+(a>>>16)+(c>>>16)+(l>>>16),w=Math.imul(t.lo,e.hi),h=Math.imul(t.hi,e.lo),x=g+w+h>>>0;return{lo:d,hi:x}}function He(t,e){return Math.imul(t,e)>>>0}function It(t,e){if(e===0)return t;if(e===32)return{lo:t.hi,hi:t.lo};if(e<32){let o=(t.lo<<e|t.hi>>>32-e)>>>0,i=(t.hi<<e|t.lo>>>32-e)>>>0;return{lo:o,hi:i}}e-=32;let r=(t.hi<<e|t.lo>>>32-e)>>>0,n=(t.lo<<e|t.hi>>>32-e)>>>0;return{lo:r,hi:n}}function U(t,e){return{lo:(t.lo^e.lo)>>>0,hi:(t.hi^e.hi)>>>0}}function xi(t,e){if(e===0)return t;if(e<32){let r=(t.lo>>>e|t.hi<<32-e)>>>0,n=t.hi>>>e;return{lo:r,hi:n}}return{lo:t.hi>>>e-32,hi:0}}function C(t,e){return{lo:t>>>0,hi:e>>>0}}function bi(t,e){return(t<<e|t>>>32-e)>>>0}function Bc(t,e){let r=e*8,n=t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24,o=t[r+4]|t[r+5]<<8|t[r+6]<<16|t[r+7]<<24;return{lo:n>>>0,hi:o>>>0}}function Gd(t,e){let r=e*4;return(t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24)>>>0}function Dc(t){return t=U(t,xi(t,33)),t=te(t,C(3981806797,4283543511)),t=U(t,xi(t,33)),t=te(t,C(444984403,3301882366)),t=U(t,xi(t,33)),t}function Wd(t){return t^=t>>>16,t=He(t,2246822507),t^=t>>>13,t=He(t,3266489909),t^=t>>>16,t}function Ei(t,e=0){let r=C(e,0),n=C(e,0),o=t.length,i=Math.floor(o/16),s=C(289559509,2277735313),a=C(658871167,1291169091);for(let g=0;g<i;g++){let w=Bc(t,g*2),h=Bc(t,g*2+1);w=te(w,s),w=It(w,31),w=te(w,a),r=U(r,w),r=It(r,27),r=Se(r,n),r=Se(te(r,C(5,0)),C(1390208809,0)),h=te(h,a),h=It(h,33),h=te(h,s),n=U(n,h),n=It(n,31),n=Se(n,r),n=Se(te(n,C(5,0)),C(944331445,0))}let c=C(0,0),u=C(0,0),l=t.slice(i*16);switch(l.length){case 15:u=U(u,C(0,l[14]<<16));case 14:u=U(u,C(0,l[13]<<8));case 13:u=U(u,C(0,l[12]));case 12:u=U(u,C(l[11]<<24,0));case 11:u=U(u,C(l[10]<<16,0));case 10:u=U(u,C(l[9]<<8,0));case 9:u=U(u,C(l[8],0)),u=te(u,a),u=It(u,33),u=te(u,s),n=U(n,u);case 8:c=U(c,C(0,l[7]<<24));case 7:c=U(c,C(0,l[6]<<16));case 6:c=U(c,C(0,l[5]<<8));case 5:c=U(c,C(0,l[4]));case 4:c=U(c,C(l[3]<<24,0));case 3:c=U(c,C(l[2]<<16,0));case 2:c=U(c,C(l[1]<<8,0));case 1:c=U(c,C(l[0],0)),c=te(c,s),c=It(c,31),c=te(c,a),r=U(r,c)}let d=C(o,0);return r=U(r,d),n=U(n,d),r=Se(r,n),n=Se(n,r),r=Dc(r),n=Dc(n),r=Se(r,n),n=Se(n,r),new Uint8Array([r.hi>>>24&255,r.hi>>>16&255,r.hi>>>8&255,r.hi&255,r.lo>>>24&255,r.lo>>>16&255,r.lo>>>8&255,r.lo&255,n.hi>>>24&255,n.hi>>>16&255,n.hi>>>8&255,n.hi&255,n.lo>>>24&255,n.lo>>>16&255,n.lo>>>8&255,n.lo&255])}function Nc(t,e=0){let r=e>>>0,n=t.length,o=Math.floor(n/4),i=3432918353,s=461845907;for(let u=0;u<o;u++){let l=Gd(t,u);l=He(l,i),l=bi(l,15),l=He(l,s),r^=l,r=bi(r,13),r=jd(He(r,5),3864292196)}let a=t.slice(o*4),c=0;switch(a.length){case 3:c^=a[2]<<16;case 2:c^=a[1]<<8;case 1:c^=a[0],c=He(c,i),c=bi(c,15),c=He(c,s),r^=c}return r^=n,r=Wd(r),r}function Qd(t){let e=new Array(4);for(let r=0;r<4;r++)e[r]=t&255,t=t>>8;return new Uint8Array(e)}var b1=Fe({name:"murmur3-32",code:35,encode:t=>Qd(Nc(t))}),Lc=Fe({name:"murmur3-128",code:34,encode:t=>Ei(t)}),E1=Fe({name:"murmur3-x64-64",code:34,encode:t=>Ei(t).subarray(0,8)});var Fc=qe(Rc(),1);var Ve=class t{_options;_popCount;_parent;_posAtParent;_children;key;constructor(e,r,n=0){this._options=e,this._popCount=0,this._parent=r,this._posAtParent=n,this._children=new Fc.default,this.key=null}async put(e,r){let n=await this._findNewBucketAndPos(e);n.bucket._putAt(n,e,r)}async get(e){let r=await this._findChild(e);if(r!=null)return r.value}async del(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);n!=null&&n.key===e&&r.bucket._delAt(r.pos)}leafCount(){return this._children.compactArray().reduce((r,n)=>n instanceof t?r+n.leafCount():r+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let r of e)r instanceof t?yield*r.eachLeafSeries():yield r}serialize(e,r){let n=[];return r(this._children.reduce((o,i,s)=>(i!=null&&(i instanceof t?o.push(i.serialize(e,r)):o.push(e(i,s))),o),n))}async asyncTransform(e,r){return zc(this,e,r)}toJSON(){return this.serialize(ep,tp)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);if(!(n instanceof t)&&n!=null&&n.key===e)return n}async _findPlace(e){let r=this._options.hash(typeof e=="string"?Jr(e):e),n=await r.take(this._options.bits),o=this._children.get(n);return o instanceof t?o._findPlace(r):{bucket:this,pos:n,hash:r,existingChild:o}}async _findNewBucketAndPos(e){let r=await this._findPlace(e);if(r.existingChild!=null&&r.existingChild.key!==e){let n=new t(this._options,r.bucket,r.pos);r.bucket._putObjectAt(r.pos,n);let o=await n._findPlace(r.existingChild.hash);return o.bucket._putAt(o,r.existingChild.key,r.existingChild.value),n._findNewBucketAndPos(r.hash)}return r}_putAt(e,r,n){this._putObjectAt(e.pos,{key:r,value:n,hash:e.hash})}_putObjectAt(e,r){this._children.get(e)==null&&this._popCount++,this._children.set(e,r)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(Zd);if(e!=null&&!(e instanceof t)){let r=e.hash;r.untake(this._options.bits);let n={pos:this._posAtParent,hash:r,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function Zd(t){return!!t}function ep(t,e){return t.key}function tp(t){return t}async function zc(t,e,r){let n=[];for(let o of t._children.compactArray())if(o instanceof Ve)await zc(o,e,r);else{let i=await e(o);n.push({bitField:t._children.bitField(),children:i})}return r(n)}var rp=[255,254,252,248,240,224,192,128],np=[1,3,7,15,31,63,127,255],mn=class{_value;_currentBytePos;_currentBitPos;constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let r=e,n=0;for(;r>0&&this._haveBits();){let o=this._value[this._currentBytePos],i=this._currentBitPos+1,s=Math.min(i,r),a=op(o,i-s,s);n=(n<<s)+a,r-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(e){for(this._currentBitPos+=e;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function op(t,e,r){let n=ip(e,r);return(t&n)>>>e}function ip(t,e){return rp[t]&np[Math.min(e+t-1,7)]}function Mc(t){function e(r){return r instanceof yn?r:new yn(r,t)}return e}var yn=class{_value;_hashFn;_depth;_availableBits;_currentBufferIndex;_buffers;constructor(e,r){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let r=e;for(;this._availableBits<r;)await this._produceMoreBits();let n=0;for(;r>0;){let o=this._buffers[this._currentBufferIndex],i=Math.min(o.availableBits(),r),s=o.take(i);n=(n<<i)+s,r-=i,this._availableBits-=i,o.availableBits()===0&&this._currentBufferIndex++}return n}untake(e){let r=e;for(;r>0;){let n=this._buffers[this._currentBufferIndex],o=Math.min(n.totalBits()-n.availableBits(),r);n.untake(o),r-=o,this._availableBits+=o,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?er([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new mn(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function Oc(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:Mc(t.hashFn)};return new Ve(e)}var sp=async function(t){return(await Lc.encode(t)).slice(0,8).reverse()},ap=async(t,e,r)=>{let n=(e.tableSize()-1).toString(16).length;await Promise.all(t.map(async o=>{if(o.Name==null)throw new Error("Unexpected Link without a Name");if(o.Name.length===n){let i=parseInt(o.Name,16);e._putObjectAt(i,new Ve({hash:r._options.hash,bits:r._options.bits},e,i));return}await r.put(o.Name.substring(2),!0)}))},$c=(t,e)=>t.toString(16).toUpperCase().padStart(e,"0").substring(0,e),cp=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()};async function*vi(t,e,r,n,o,i){if(o==null){if(t.Data==null)throw new L("No data in PBNode");let g;try{g=q.unmarshal(t.Data)}catch(h){throw new L(h.message)}if(g.type!=="hamt-sharded-directory")throw new L("Not a HAMT");if(g.fanout==null)throw new L("Missing fanout");let w=Oc({hashFn:sp,bits:Math.log2(Number(g.fanout))});o={rootBucket:w,hamtDepth:1,lastBucket:w}}let s=(o.lastBucket.tableSize()-1).toString(16).length;await ap(t.Links,o.lastBucket,o.rootBucket);let a=await o.rootBucket._findNewBucketAndPos(e),c=$c(a.pos,s),u=cp(a);u.length>o.hamtDepth&&(o.lastBucket=u[o.hamtDepth],c=$c(o.lastBucket._posAtParent,s));let l=t.Links.find(g=>{if(g.Name==null)return!1;let w=g.Name.substring(0,s),h=g.Name.substring(s);return!(w!==c||h!==""&&h!==e)});if(l==null)return;if(l.Name!=null&&l.Name.substring(s)===e){yield{cid:l.Hash,name:l.Name.substring(s),rest:r};return}o.hamtDepth++;let d=await A(n.get(l.Hash,i));t=he(d),i?.yieldSubShards===!0&&(yield{cid:l.Hash,name:l.Name??"",rest:[e,...r]}),yield*vi(t,e,r,n,o,i)}async function*Hc(t,e,r,n){let o=await A(r.get(t,n)),i;try{i=he(o)}catch(a){throw new L(a.message)}if(i.Data==null)throw new L("no data in PBNode");let s;try{s=q.unmarshal(i.Data)}catch(a){throw new L(a.message)}if(s.type==="directory"||s.type==="hamt-sharded-directory"&&n?.translateHAMTPath===!1){let a=i.Links.find(c=>c.Name===e[0]);if(a==null)throw new K(`No link "${e[0]}" found under ${t}`);yield{cid:a.Hash,name:e[0],rest:e.slice(1)}}else if(s.type==="hamt-sharded-directory"){let a=!1;for await(let c of vi(i,e[0],e.slice(1),r,void 0,n))c.name===e[0]&&(a=!0),yield c;if(!a)throw new K(`No link "${e[0]}" found under ${t}`)}}async function*Vc(t,e,r,n){if(e.length!==0)throw new vt(`Cannot load path /${e.join("/")} from identity block`)}async function*qc(t,e,r,n){let o=await A(r.get(t,n)),i=Gr(o),s=At(i,e);yield{cid:t,name:s.path,rest:s.rest}}async function*jc(t,e,r,n){if(e.length!==0)throw new K(`Cannot load path /${e.join("/")} from raw block`)}var fp={[bt]:Hc,[pt]:jc,[Rr]:wi,81:wi,[rn]:Cc,[rr.code]:Vc,[jr]:qc};async function*gn(t,e,r={}){for(t=t.toString(),t.startsWith("/ipfs/")&&(t=t.substring(6));t.endsWith("/");)t=t.substring(0,t.length-1);let[n,...o]=t.split(/(?<!\\)\//g).filter(Boolean),i=k.parse(n),s=[i],a=`${i}`;for(yield{cid:i,name:a,path:a,roots:s,remainder:o};o.length>0;){let c=fp[i.code];if(c==null)throw new kt(`No resolver for code ${i.code}`);let u=!1;for await(let l of c(i,o,e,r)){if(i=l.cid,u=!s[s.length-1].equals(i),o=l.rest,!u)break;s=[...s,l.cid],a=`${a}/${l.name}`,yield{cid:l.cid,name:l.name,path:a,roots:s,remainder:l.rest}}if(!u)break}if(r?.signal?.throwIfAborted(),o.length!==0)throw new K(`Could not resolve path /${o.join("/")} under ${t}`)}function lp(t){return t[Symbol.asyncIterator]!=null}function hp(t){if(lp(t))return(async()=>{let r;for await(let n of t)r=n;return r})();let e;for(let r of t)e=r;return e}var Gc=hp;async function ki(t,e,r,n,o){let i=await A(n.get(t,o)),s=Pe(i);return{type:"object",cid:t,name:e,path:r,object:s,node:i,size:BigInt(i.byteLength)}}async function Wc(t,e,r,n,o){let i=await A(n.get(t,o)),s=nn(i);return{type:"object",cid:t,name:e,path:r,object:s,node:i,size:BigInt(i.byteLength)}}function xr(t,e,r,n){let o=BigInt(t.length),i=BigInt(e+o);return r>=i||n<e?new Uint8Array(0):(n>=e&&n<i&&(t=t.subarray(0,Number(n-e))),r>=e&&r<i&&(t=t.subarray(Number(r-e))),t)}var wn=(t,e=0,r=t)=>{let n=BigInt(t),o=BigInt(e??0),i=BigInt(r);if(i!==n&&(i=o+i),i>n&&(i=n),o<0n)throw new we("Offset must be greater than or equal to 0");if(o>n)throw new we("Offset must be less than the file size");if(i<0n)throw new we("Length must be greater than or equal to 0");if(i>n)throw new we("Length must be less than the file size");return{start:o,end:i}};function xn(t,e){async function*r(n={}){let{start:o,end:i}=wn(t.length,n.offset,n.length),s=xr(t,0n,o,i);n.onProgress?.(new O(e,{bytesRead:BigInt(s.byteLength),totalBytes:i-o,fileSize:BigInt(t.byteLength)})),yield s}return r}async function Jc(t,e,r,n,o){let i=nt(t.multihash.bytes);return{type:"identity",cid:t,name:e,path:r,content:xn(i.digest,"unixfs:exporter:progress:identity"),size:BigInt(i.bytes.byteLength),node:i.bytes}}async function Qc(t,e,r,n,o){let i=await A(n.get(t,o)),s=Gr(i);return{type:"object",cid:t,name:e,path:r,object:s,size:BigInt(i.byteLength),node:i}}async function Yc(t,e,r,n,o){let i=await A(n.get(t,o));return{type:"raw",cid:t,name:e,path:r,content:xn(i,"unixfs:exporter:progress:raw"),size:BigInt(i.length),node:i}}function Xc(t,e,r,n){async function*o(i={}){let s=i.offset??0,a=i.length??e.Links.length,c=e.Links.slice(s,a);i.onProgress?.(new O("unixfs:exporter:walk:directory",{cid:t})),yield*c.map(u=>({cid:u.Hash,name:u.Name??"",path:`${n}/${u.Name??""}`,size:BigInt(u.Tsize??0)}))}return o}var bn=globalThis.CustomEvent??Event;async function*br(t,e={}){let r=e.concurrency??1/0;r<1&&(r=1/0);let n=e.ordered??!1,o=new EventTarget,i=[],s=H(),a=H(),c=!1,u,l=!1;o.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let h of t){if(i.length===r&&(s=H(),await s.promise),l)break;let x={done:!1};i.push(x),h().then(b=>{x.done=!0,x.ok=!0,x.value=b,o.dispatchEvent(new bn("task-complete"))},b=>{x.done=!0,x.err=b,o.dispatchEvent(new bn("task-complete"))})}c=!0,o.dispatchEvent(new bn("task-complete"))}catch(h){u=h,o.dispatchEvent(new bn("task-complete"))}});function d(){return n?i[0]?.done:!!i.find(h=>h.done)}function*g(){for(;i.length>0&&i[0].done;){let h=i[0];if(i.shift(),h.ok)yield h.value;else throw l=!0,s.resolve(),h.err;s.resolve()}}function*w(){for(;d();)for(let h=0;h<i.length;h++)if(i[h].done){let x=i[h];if(i.splice(h,1),h--,x.ok)yield x.value;else throw l=!0,s.resolve(),x.err;s.resolve()}}for(;;){if(d()||(a=H(),await a.promise),u!=null||(n?yield*g():yield*w(),u!=null))throw u;if(c&&i.length===0)break}}async function Kc(t,e,r,n,o,i,s){if(e instanceof Uint8Array){let u=xr(e,n,o,i);r.push(u);return}if(e.Data==null)throw new L("no data in PBNode");let a;try{a=q.unmarshal(e.Data)}catch(u){throw new L(u.message)}if(a.data!=null){let u=a.data,l=xr(u,n,o,i);r.push(l),n+=BigInt(l.byteLength)}let c=[];if(e.Links.length!==a.blockSizes.length)throw new L("Inconsistent block sizes and dag links");for(let u=0;u<e.Links.length;u++){let l=e.Links[u],d=n,g=d+a.blockSizes[u];if((o>=d&&o<g||i>=d&&i<=g||o<d&&i>g)&&c.push({link:l,blockStart:n}),n=g,n>i)break}await en(c,u=>ot(u,l=>async()=>{let d=await A(t.get(l.link.Hash,s));return{...l,block:d}}),u=>br(u,{ordered:!0,concurrency:s.blockReadConcurrency}),async u=>{for await(let{link:l,block:d,blockStart:g}of u){let w;switch(l.Hash.code){case bt:w=he(d);break;case pt:w=d;break;default:r.end(new L(`Unsupported codec: ${l.Hash.code}`));return}let h=new Wt({concurrency:1});h.on("error",x=>{r.end(x)}),h.add(async()=>{s.onProgress?.(new O("unixfs:exporter:walk:file",{cid:l.Hash})),await Kc(t,w,r,g,o,i,s)}),await h.onIdle()}}),n>=i&&r.end()}function _i(t,e,r,n,o){async function*i(s={}){let a=r.fileSize();if(a===void 0)throw new Error("File was a directory");let{start:c,end:u}=wn(a,s.offset,s.length);if(u===0n)return;let l=0n,d=u-c,g=yt();s.onProgress?.(new O("unixfs:exporter:walk:file",{cid:t})),Kc(o,e,g,0n,c,u,s).catch(w=>{g.end(w)});for await(let w of g)if(w!=null){if(l+=BigInt(w.byteLength),l>d)throw g.end(),new dn("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect");l===d&&g.end(),s.onProgress?.(new O("unixfs:exporter:progress:unixfs:file",{bytesRead:l,totalBytes:d,fileSize:a})),yield w}if(l<d)throw new pn("Traversed entire DAG but did not read enough bytes")}return i}async function*Zc(t,e,r,n){let o=t.Links;if(t.Data==null)throw new L("no data in PBNode");let i;try{i=q.unmarshal(t.Data)}catch(c){throw new L(c.message)}if(i.fanout==null)throw new L("missing fanout");let s=(i.fanout-1n).toString(16).length,a=en(o,c=>ot(c,u=>async()=>{let l=u.Name!=null?u.Name.substring(s):null;if(l!=null&&l!=="")return{entries:[{cid:u.Hash,name:l,path:`${e}/${l}`,size:BigInt(u.Tsize??0)}]};{let d=await A(r.get(u.Hash,n));return t=he(d),n.onProgress?.(new O("unixfs:exporter:walk:hamt-sharded-directory",{cid:u.Hash})),{entries:Zc(t,e,r,n)}}}),c=>br(c,{ordered:!0,concurrency:n.blockReadConcurrency}));for await(let{entries:c}of a)yield*c}function eu(t,e,r,n,o){function i(s={}){return s.onProgress?.(new O("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),Zc(e,n,o,s)}return i}var dp={raw:_i,file:_i,directory:Xc,"hamt-sharded-directory":eu,metadata:(t,e,r,n)=>()=>[],symlink:(t,e,r,n)=>()=>[]};async function tu(t,e,r,n,o){let i=await A(n.get(t,o)),s;try{s=he(i)}catch(u){throw new L(u.message)}if(s.Data==null)throw new L("no data in PBNode");let a;try{a=q.unmarshal(s.Data)}catch(u){throw new L(u.message)}let c=dp[a.type](t,s,a,r,n);if(c==null)throw new K("could not find content exporter");return a.isDirectory()?{type:"directory",cid:t,name:e,path:r,entries:c,unixfs:a,node:s,size:BigInt(i.byteLength)}:{type:"file",cid:t,name:e,path:r,content:c,unixfs:a,node:s,size:a.fileSize()}}var pp={[bt]:tu,[pt]:Yc,[Rr]:ki,81:ki,[rn]:Wc,[rr.code]:Jc,[jr]:Qc};async function ru(t,e,r={}){let n,o;if(t instanceof String||typeof t=="string"){let s=await Gc(gn(t,e,r));if(s==null)throw new K(`Could not walk path to ${t}`);n=s.cid,o=s.name,t=s.path}else if(k.asCID(t)===t||t instanceof k)n=t,o=t=n.toString();else throw new we("Path must be string or CID");let i=pp[n.code];if(i==null)throw new kt(`No resolver for code ${n.code}`);return i(n,o,t,e,r)}var Ai=class{root;path;constructor(...e){let r=e[0],n=e[1];if(typeof r=="string")n=r,r=void 0;else if(e.length<2)throw new Error("path or CID and path must be specified");n.startsWith("/")||(n=`/${n}`),this.root=r,this.path=n}async*traverse(e,r,n,o){for await(let i of gn(`${this.root??e}${this.path}`,r,o)){let s=await ru(i.cid,r,o);yield le({cid:s.cid,bytes:s.node instanceof Uint8Array?s.node:dc(s.node),codec:await n(i.cid.code)})}}};function mp(t){return new an(t)}return cu(yp);})();
|
|
2
|
+
"use strict";var HeliaCar=(()=>{var Ya=Object.create;var sr=Object.defineProperty;var Qa=Object.getOwnPropertyDescriptor;var Xa=Object.getOwnPropertyNames;var Ka=Object.getPrototypeOf,Za=Object.prototype.hasOwnProperty;var _e=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),V=(t,e)=>{for(var r in e)sr(t,r,{get:e[r],enumerable:!0})},Ho=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Xa(e))!Za.call(t,o)&&o!==r&&sr(t,o,{get:()=>e[o],enumerable:!(n=Qa(e,o))||n.enumerable});return t};var $e=(t,e,r)=>(r=t!=null?Ya(Ka(t)):{},Ho(e||!t||!t.__esModule?sr(r,"default",{value:t,enumerable:!0}):r,t)),ec=t=>Ho(sr({},"__esModule",{value:!0}),t);var us=_e((vd,cs)=>{cs.exports=Bn;var as=128,Cu=127,Bu=~Cu,Nu=Math.pow(2,31);function Bn(t,e,r){if(Number.MAX_SAFE_INTEGER&&t>Number.MAX_SAFE_INTEGER)throw Bn.bytes=0,new RangeError("Could not encode varint");e=e||[],r=r||0;for(var n=r;t>=Nu;)e[r++]=t&255|as,t/=128;for(;t&Bu;)e[r++]=t&255|as,t>>>=7;return e[r]=t|0,Bn.bytes=r-n+1,e}});var hs=_e((kd,ls)=>{ls.exports=Nn;var Du=128,fs=127;function Nn(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a||o>49)throw Nn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&fs)<<o:(s&fs)*Math.pow(2,o),o+=7}while(s>=Du);return Nn.bytes=i-n,r}});var ps=_e((_d,ds)=>{var Lu=Math.pow(2,7),Pu=Math.pow(2,14),Uu=Math.pow(2,21),Ru=Math.pow(2,28),Fu=Math.pow(2,35),zu=Math.pow(2,42),$u=Math.pow(2,49),Mu=Math.pow(2,56),Ou=Math.pow(2,63);ds.exports=function(t){return t<Lu?1:t<Pu?2:t<Uu?3:t<Ru?4:t<Fu?5:t<zu?6:t<$u?7:t<Mu?8:t<Ou?9:10}});var vr=_e((Id,ms)=>{ms.exports={encode:us(),decode:hs(),encodingLength:ps()}});var Ws=_e((Xm,ho)=>{"use strict";var $f=Object.prototype.hasOwnProperty,O="~";function Gt(){}Object.create&&(Gt.prototype=Object.create(null),new Gt().__proto__||(O=!1));function Mf(t,e,r){this.fn=t,this.context=e,this.once=r||!1}function Gs(t,e,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new Mf(r,n||t,o),s=O?O+e:e;return t._events[s]?t._events[s].fn?t._events[s]=[t._events[s],i]:t._events[s].push(i):(t._events[s]=i,t._eventsCount++),t}function Ur(t,e){--t._eventsCount===0?t._events=new Gt:delete t._events[e]}function F(){this._events=new Gt,this._eventsCount=0}F.prototype.eventNames=function(){var e=[],r,n;if(this._eventsCount===0)return e;for(n in r=this._events)$f.call(r,n)&&e.push(O?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(r)):e};F.prototype.listeners=function(e){var r=O?O+e:e,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};F.prototype.listenerCount=function(e){var r=O?O+e:e,n=this._events[r];return n?n.fn?1:n.length:0};F.prototype.emit=function(e,r,n,o,i,s){var a=O?O+e:e;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,l,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(d=1,l=new Array(f-1);d<f;d++)l[d-1]=arguments[d];c.fn.apply(c.context,l)}else{var g=c.length,w;for(d=0;d<g;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),f){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,r);break;case 3:c[d].fn.call(c[d].context,r,n);break;case 4:c[d].fn.call(c[d].context,r,n,o);break;default:if(!l)for(w=1,l=new Array(f-1);w<f;w++)l[w-1]=arguments[w];c[d].fn.apply(c[d].context,l)}}return!0};F.prototype.on=function(e,r,n){return Gs(this,e,r,n,!1)};F.prototype.once=function(e,r,n){return Gs(this,e,r,n,!0)};F.prototype.removeListener=function(e,r,n,o){var i=O?O+e:e;if(!this._events[i])return this;if(!r)return Ur(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&Ur(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Ur(this,i)}return this};F.prototype.removeAllListeners=function(e){var r;return e?(r=O?O+e:e,this._events[r]&&Ur(this,r)):(this._events=new Gt,this._eventsCount=0),this};F.prototype.off=F.prototype.removeListener;F.prototype.addListener=F.prototype.on;F.prefixed=O;F.EventEmitter=F;typeof ho<"u"&&(ho.exports=F)});var Qs=_e((Ey,Ys)=>{Ys.exports=function(t){if(!t)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,r=Object.create(null),n=Object.create(null);function o(i,s){r[i]=s,e++,e>=t&&(e=0,n=r,r=Object.create(null))}return{has:function(i){return r[i]!==void 0||n[i]!==void 0},remove:function(i){r[i]!==void 0&&(r[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var s=r[i];if(s!==void 0)return s;if((s=n[i])!==void 0)return o(i,s),s},set:function(i,s){r[i]!==void 0?r[i]=s:o(i,s)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var Sa=_e((m0,Ta)=>{"use strict";Ta.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(e,r){let n=this._internalPositionFor(e,!1);if(r===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(e),this._changedLength=!0,this._changedData=!0);else{let o=!1;n===-1?(n=this._data.length,this._setBit(e),this._changedData=!0):o=!0,this._setInternalPos(n,e,r,o),this._changedLength=!0}}unset(e){this.set(e,void 0)}get(e){this._sortData();let r=this._internalPositionFor(e,!0);if(r!==-1)return this._data[r][1]}push(e){return this.set(this.length,e),this.length}get length(){if(this._sortData(),this._changedLength){let e=this._data[this._data.length-1];this._length=e?e[0]+1:0,this._changedLength=!1}return this._length}forEach(e){let r=0;for(;r<this.length;)e(this.get(r),r,this),r++}map(e){let r=0,n=new Array(this.length);for(;r<this.length;)n[r]=e(this.get(r),r,this),r++;return n}reduce(e,r){let n=0,o=r;for(;n<this.length;){let i=this.get(n);o=e(o,i,n),n++}return o}find(e){let r=0,n,o;for(;r<this.length&&!n;)o=this.get(r),n=e(o),r++;return n?o:void 0}_internalPositionFor(e,r){let n=this._bytePosFor(e,r);if(n>=this._bitArrays.length)return-1;let o=this._bitArrays[n],i=e-n*7;if(!((o&1<<i)>0))return-1;let a=this._bitArrays.slice(0,n).reduce(Pl,0),c=~(4294967295<<i+1),f=Aa(o&c);return a+f-1}_bytePosFor(e,r){let n=Math.floor(e/7),o=n+1;for(;!r&&this._bitArrays.length<o;)this._bitArrays.push(0);return n}_setBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]|=1<<e-r*7}_unsetBit(e){let r=this._bytePosFor(e,!1);this._bitArrays[r]&=~(1<<e-r*7)}_setInternalPos(e,r,n,o){let i=this._data,s=[r,n];if(o)this._sortData(),i[e]=s;else{if(i.length)if(i[i.length-1][0]>=r)i.push(s);else if(i[0][0]<=r)i.unshift(s);else{let a=Math.round(i.length/2);this._data=i.slice(0,a).concat(s).concat(i.slice(a))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(e){this._data.splice(e,1)}_sortData(){this._changedData&&this._data.sort(Ul),this._changedData=!1}bitField(){let e=[],r=8,n=0,o=0,i,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(i=s.shift(),n=7);let c=Math.min(n,r),f=~(255<<c),l=i&f;o|=l<<8-r,i=i>>>c,n-=c,r-=c,(!r||!n&&!s.length)&&(e.push(o),o=0,r=8)}for(var a=e.length-1;a>0&&e[a]===0;a--)e.pop();return e}compactArray(){return this._sortData(),this._data.map(Rl)}};function Pl(t,e){return t+Aa(e)}function Aa(t){let e=t;return e=e-(e>>1&1431655765),e=(e&858993459)+(e>>2&858993459),(e+(e>>4)&252645135)*16843009>>24}function Ul(t,e){return t[0]-e[0]}function Rl(t){return t[1]}});var eh={};V(eh,{BlockExporter:()=>No,CIDPath:()=>Lo,GraphSearch:()=>Do,SubgraphExporter:()=>Kt,UnixFSExporter:()=>Zt,UnixFSPath:()=>Oo,breadthFirstWalker:()=>Re,car:()=>Zl,depthFirstWalker:()=>Ue,naturalOrderWalker:()=>Bo});var tc=["Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array","Tagged"];function nn(t){if(t===null)return"null";if(t===void 0)return"undefined";if(t===!0||t===!1)return"boolean";let e=typeof t;if(e==="string"||e==="number"||e==="bigint"||e==="symbol")return e;if(e==="function")return"Function";if(Array.isArray(t))return"Array";if(t instanceof Uint8Array)return"Uint8Array";if(t.constructor===Object)return"Object";let r=rc(t);return r||"Object"}function rc(t){let e=Object.prototype.toString.call(t).slice(8,-1);if(tc.includes(e))return e}var u=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}static equals(e,r){return e===r||e.major===r.major&&e.name===r.name}};u.uint=new u(0,"uint",!0);u.negint=new u(1,"negint",!0);u.bytes=new u(2,"bytes",!0);u.string=new u(3,"string",!0);u.array=new u(4,"array",!1);u.map=new u(5,"map",!1);u.tag=new u(6,"tag",!1);u.float=new u(7,"float",!0);u.false=new u(7,"false",!0);u.true=new u(7,"true",!0);u.null=new u(7,"null",!0);u.undefined=new u(7,"undefined",!0);u.break=new u(7,"break",!0);var h=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 yt=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",nc=new TextEncoder;function ar(t){return yt&&globalThis.Buffer.isBuffer(t)}function Ie(t){return t instanceof Uint8Array?ar(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t:Uint8Array.from(t)}var oc=24,ic=200,Me=yt?t=>t.length>=oc?globalThis.Buffer.from(t):qo(t):t=>t.length>=ic?nc.encode(t):qo(t),oe=t=>Uint8Array.from(t),jo=yt?(t,e,r)=>ar(t)?new Uint8Array(t.subarray(e,r)):t.slice(e,r):(t,e,r)=>t.slice(e,r),Go=yt?(t,e)=>(t=t.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Ie(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},Wo=yt?t=>globalThis.Buffer.allocUnsafe(t):t=>new Uint8Array(t);function cr(t,e){if(ar(t)&&ar(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 qo(t){let e=[],r=0;for(let n=0;n<t.length;n++){let o=t.charCodeAt(n);o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&n+1<t.length&&(t.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(t.charCodeAt(++n)&1023),e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(o>=55296&&o<=57343&&(o=65533),e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128)}return e}var Vo=4096;function Jo(t){let e=t.length;if(e<=Vo)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Vo));return r}var sc=256,gt=class{constructor(e=sc){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=Wo(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=jo(n,0,this.cursor)}else r=Go(this.chunks,this.cursor);return e&&this.reset(),r}},ur=class{constructor(e){this.dest=e,this.cursor=0,this.chunks=[e]}reset(){this.cursor=0}push(e){if(this.cursor+e.length>this.dest.length)throw new Error("write out of bounds, destination buffer is too small");this.dest.set(e,this.cursor),this.cursor+=e.length}toBytes(e=!1){let r=this.dest.subarray(0,this.cursor);return e&&this.reset(),r}};var y="CBOR decode error:",Ae="CBOR encode error:",wt=[];wt[23]=1;wt[24]=2;wt[25]=3;wt[26]=5;wt[27]=9;function le(t,e,r){if(t.length-e<r)throw new Error(`${y} not enough data for type`)}var L=[24,256,65536,4294967296,BigInt("18446744073709551616")];function j(t,e,r){le(t,e,1);let n=t[e];if(r.strict===!0&&n<L[0])throw new Error(`${y} integer encoded in more bytes than necessary (strict decode)`);return n}function G(t,e,r){le(t,e,2);let n=t[e]<<8|t[e+1];if(r.strict===!0&&n<L[1])throw new Error(`${y} integer encoded in more bytes than necessary (strict decode)`);return n}function W(t,e,r){le(t,e,4);let n=t[e]*16777216+(t[e+1]<<16)+(t[e+2]<<8)+t[e+3];if(r.strict===!0&&n<L[2])throw new Error(`${y} integer encoded in more bytes than necessary (strict decode)`);return n}function J(t,e,r){le(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<L[3])throw new Error(`${y} 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(`${y} integers outside of the safe integer range are not supported`)}function Yo(t,e,r,n){return new h(u.uint,j(t,e+1,n),2)}function Qo(t,e,r,n){return new h(u.uint,G(t,e+1,n),3)}function Xo(t,e,r,n){return new h(u.uint,W(t,e+1,n),5)}function Ko(t,e,r,n){return new h(u.uint,J(t,e+1,n),9)}function X(t,e){return I(t,0,e.value)}function I(t,e,r){if(r<L[0]){let n=Number(r);t.push([e|n])}else if(r<L[1]){let n=Number(r);t.push([e|24,n])}else if(r<L[2]){let n=Number(r);t.push([e|25,n>>>8,n&255])}else if(r<L[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<L[4]){let o=[e|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=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]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,t.push(o)}else throw new Error(`${y} encountered BigInt larger than allowable range`)}}X.encodedSize=function(e){return I.encodedSize(e.value)};I.encodedSize=function(e){return e<L[0]?1:e<L[1]?2:e<L[2]?3:e<L[3]?5:9};X.compareTokens=function(e,r){return e.value<r.value?-1:e.value>r.value?1:0};function Zo(t,e,r,n){return new h(u.negint,-1-j(t,e+1,n),2)}function ei(t,e,r,n){return new h(u.negint,-1-G(t,e+1,n),3)}function ti(t,e,r,n){return new h(u.negint,-1-W(t,e+1,n),5)}var on=BigInt(-1),ri=BigInt(1);function ni(t,e,r,n){let o=J(t,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new h(u.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${y} integers outside of the safe integer range are not supported`);return new h(u.negint,on-BigInt(o),9)}function fr(t,e){let r=e.value,n=typeof r=="bigint"?r*on-ri:r*-1-1;I(t,e.type.majorEncoded,n)}fr.encodedSize=function(e){let r=e.value,n=typeof r=="bigint"?r*on-ri:r*-1-1;return n<L[0]?1:n<L[1]?2:n<L[2]?3:n<L[3]?5:9};fr.compareTokens=function(e,r){return e.value<r.value?1:e.value>r.value?-1:0};function xt(t,e,r,n){le(t,e,r+n);let o=t.slice(e+r,e+r+n);return new h(u.bytes,o,r+n)}function oi(t,e,r,n){return xt(t,e,1,r)}function ii(t,e,r,n){return xt(t,e,2,j(t,e+1,n))}function si(t,e,r,n){return xt(t,e,3,G(t,e+1,n))}function ai(t,e,r,n){return xt(t,e,5,W(t,e+1,n))}function ci(t,e,r,n){let o=J(t,e+1,n);if(typeof o=="bigint")throw new Error(`${y} 64-bit integer bytes lengths not supported`);return xt(t,e,9,o)}function lr(t){return t.encodedBytes===void 0&&(t.encodedBytes=u.equals(t.type,u.string)?Me(t.value):t.value),t.encodedBytes}function Oe(t,e){let r=lr(e);I(t,e.type.majorEncoded,r.length),t.push(r)}Oe.encodedSize=function(e){let r=lr(e);return I.encodedSize(r.length)+r.length};Oe.compareTokens=function(e,r){return cc(lr(e),lr(r))};function cc(t,e){return t.length<e.length?-1:t.length>e.length?1:cr(t,e)}var ui=new TextDecoder,fc=32;function lc(t,e,r){if(r-e<fc){let o="";for(let i=e;i<r;i++){let s=t[i];if(s&128)return ui.decode(t.subarray(e,r));o+=String.fromCharCode(s)}return o}return ui.decode(t.subarray(e,r))}function bt(t,e,r,n,o){let i=r+n;le(t,e,i);let s=new h(u.string,lc(t,e+r,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=t.slice(e+r,e+i)),s}function fi(t,e,r,n){return bt(t,e,1,r,n)}function li(t,e,r,n){return bt(t,e,2,j(t,e+1,n),n)}function hi(t,e,r,n){return bt(t,e,3,G(t,e+1,n),n)}function di(t,e,r,n){return bt(t,e,5,W(t,e+1,n),n)}function pi(t,e,r,n){let o=J(t,e+1,n);if(typeof o=="bigint")throw new Error(`${y} 64-bit integer string lengths not supported`);return bt(t,e,9,o,n)}var mi=Oe;function He(t,e,r,n){return new h(u.array,n,r)}function yi(t,e,r,n){return He(t,e,1,r)}function gi(t,e,r,n){return He(t,e,2,j(t,e+1,n))}function wi(t,e,r,n){return He(t,e,3,G(t,e+1,n))}function xi(t,e,r,n){return He(t,e,5,W(t,e+1,n))}function bi(t,e,r,n){let o=J(t,e+1,n);if(typeof o=="bigint")throw new Error(`${y} 64-bit integer array lengths not supported`);return He(t,e,9,o)}function Ei(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${y} indefinite length items not allowed`);return He(t,e,1,1/0)}function hr(t,e){I(t,u.array.majorEncoded,e.value)}hr.compareTokens=X.compareTokens;hr.encodedSize=function(e){return I.encodedSize(e.value)};function qe(t,e,r,n){return new h(u.map,n,r)}function vi(t,e,r,n){return qe(t,e,1,r)}function ki(t,e,r,n){return qe(t,e,2,j(t,e+1,n))}function _i(t,e,r,n){return qe(t,e,3,G(t,e+1,n))}function Ii(t,e,r,n){return qe(t,e,5,W(t,e+1,n))}function Ai(t,e,r,n){let o=J(t,e+1,n);if(typeof o=="bigint")throw new Error(`${y} 64-bit integer map lengths not supported`);return qe(t,e,9,o)}function Ti(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${y} indefinite length items not allowed`);return qe(t,e,1,1/0)}function dr(t,e){I(t,u.map.majorEncoded,e.value)}dr.compareTokens=X.compareTokens;dr.encodedSize=function(e){return I.encodedSize(e.value)};function Si(t,e,r,n){return new h(u.tag,r,1)}function Ci(t,e,r,n){return new h(u.tag,j(t,e+1,n),2)}function Bi(t,e,r,n){return new h(u.tag,G(t,e+1,n),3)}function Ni(t,e,r,n){return new h(u.tag,W(t,e+1,n),5)}function Di(t,e,r,n){return new h(u.tag,J(t,e+1,n),9)}function pr(t,e){I(t,u.tag.majorEncoded,e.value)}pr.compareTokens=X.compareTokens;pr.encodedSize=function(e){return I.encodedSize(e.value)};var sn=20,an=21,cn=22,un=23;function Li(t,e,r,n){if(n.allowUndefined===!1)throw new Error(`${y} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new h(u.null,null,1):new h(u.undefined,void 0,1)}function Pi(t,e,r,n){if(n.allowIndefinite===!1)throw new Error(`${y} indefinite length items not allowed`);return new h(u.break,void 0,1)}function fn(t,e,r){if(r){if(r.allowNaN===!1&&Number.isNaN(t))throw new Error(`${y} NaN values are not supported`);if(r.allowInfinity===!1&&(t===1/0||t===-1/0))throw new Error(`${y} Infinity values are not supported`)}return new h(u.float,t,e)}function Ui(t,e,r,n){return fn(ln(t,e+1),3,n)}function Ri(t,e,r,n){return fn(hn(t,e+1),5,n)}function Fi(t,e,r,n){return fn(Oi(t,e+1),9,n)}function Et(t,e,r){let n=e.value;if(n===!1)t.push([u.float.majorEncoded|sn]);else if(n===!0)t.push([u.float.majorEncoded|an]);else if(n===null)t.push([u.float.majorEncoded|cn]);else if(n===void 0)t.push([u.float.majorEncoded|un]);else{let o,i=!1;(!r||r.float64!==!0)&&($i(n),o=ln(ee,1),n===o||Number.isNaN(n)?(ee[0]=249,t.push(ee.slice(0,3)),i=!0):(Mi(n),o=hn(ee,1),n===o&&(ee[0]=250,t.push(ee.slice(0,5)),i=!0))),i||(yc(n),o=Oi(ee,1),ee[0]=251,t.push(ee.slice(0,9)))}}Et.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){$i(n);let o=ln(ee,1);if(n===o||Number.isNaN(n))return 3;if(Mi(n),o=hn(ee,1),n===o)return 5}return 9};var zi=new ArrayBuffer(9),K=new DataView(zi,1),ee=new Uint8Array(zi,0);function $i(t){if(t===1/0)K.setUint16(0,31744,!1);else if(t===-1/0)K.setUint16(0,64512,!1);else if(Number.isNaN(t))K.setUint16(0,32256,!1);else{K.setFloat32(0,t);let e=K.getUint32(0),r=(e&2139095040)>>23,n=e&8388607;if(r===255)K.setUint16(0,31744,!1);else if(r===0)K.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?K.setUint16(0,0):o<-14?K.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):K.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ln(t,e){if(t.length-e<2)throw new Error(`${y} 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 Mi(t){K.setFloat32(0,t,!1)}function hn(t,e){if(t.length-e<4)throw new Error(`${y} not enough data for float32`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,4).getFloat32(0,!1)}function yc(t){K.setFloat64(0,t,!1)}function Oi(t,e){if(t.length-e<8)throw new Error(`${y} not enough data for float64`);let r=(t.byteOffset||0)+e;return new DataView(t.buffer,r,8).getFloat64(0,!1)}Et.compareTokens=X.compareTokens;function v(t,e,r){throw new Error(`${y} encountered invalid minor (${r}) for major ${t[e]>>>5}`)}function mr(t){return()=>{throw new Error(`${y} ${t}`)}}var p=[];for(let t=0;t<=23;t++)p[t]=v;p[24]=Yo;p[25]=Qo;p[26]=Xo;p[27]=Ko;p[28]=v;p[29]=v;p[30]=v;p[31]=v;for(let t=32;t<=55;t++)p[t]=v;p[56]=Zo;p[57]=ei;p[58]=ti;p[59]=ni;p[60]=v;p[61]=v;p[62]=v;p[63]=v;for(let t=64;t<=87;t++)p[t]=oi;p[88]=ii;p[89]=si;p[90]=ai;p[91]=ci;p[92]=v;p[93]=v;p[94]=v;p[95]=mr("indefinite length bytes/strings are not supported");for(let t=96;t<=119;t++)p[t]=fi;p[120]=li;p[121]=hi;p[122]=di;p[123]=pi;p[124]=v;p[125]=v;p[126]=v;p[127]=mr("indefinite length bytes/strings are not supported");for(let t=128;t<=151;t++)p[t]=yi;p[152]=gi;p[153]=wi;p[154]=xi;p[155]=bi;p[156]=v;p[157]=v;p[158]=v;p[159]=Ei;for(let t=160;t<=183;t++)p[t]=vi;p[184]=ki;p[185]=_i;p[186]=Ii;p[187]=Ai;p[188]=v;p[189]=v;p[190]=v;p[191]=Ti;for(let t=192;t<=215;t++)p[t]=Si;p[216]=Ci;p[217]=Bi;p[218]=Ni;p[219]=Di;p[220]=v;p[221]=v;p[222]=v;p[223]=v;for(let t=224;t<=243;t++)p[t]=mr("simple values are not supported");p[244]=v;p[245]=v;p[246]=v;p[247]=Li;p[248]=mr("simple values are not supported");p[249]=Ui;p[250]=Ri;p[251]=Fi;p[252]=v;p[253]=v;p[254]=v;p[255]=Pi;var te=[];for(let t=0;t<24;t++)te[t]=new h(u.uint,t,1);for(let t=-1;t>=-24;t--)te[31-t]=new h(u.negint,t,1);te[64]=new h(u.bytes,new Uint8Array(0),1);te[96]=new h(u.string,"",1);te[128]=new h(u.array,0,1);te[160]=new h(u.map,0,1);te[244]=new h(u.false,!1,1);te[245]=new h(u.true,!0,1);te[246]=new h(u.null,null,1);function yr(t){switch(t.type){case u.false:return oe([244]);case u.true:return oe([245]);case u.null:return oe([246]);case u.bytes:return t.value.length?void 0:oe([64]);case u.string:return t.value===""?oe([96]):void 0;case u.array:return t.value===0?oe([128]):void 0;case u.map:return t.value===0?oe([160]):void 0;case u.uint:return t.value<24?oe([Number(t.value)]):void 0;case u.negint:if(t.value>=-24)return oe([31-Number(t.value)])}}var wc={float64:!1,mapSorter:bc,quickEncodeToken:yr},Gi=Object.freeze({float64:!0,mapSorter:Ec,quickEncodeToken:yr});function dn(){let t=[];return t[u.uint.major]=X,t[u.negint.major]=fr,t[u.bytes.major]=Oe,t[u.string.major]=mi,t[u.array.major]=hr,t[u.map.major]=dr,t[u.tag.major]=pr,t[u.float.major]=Et,t}var Ve=dn(),gr=new gt,kt=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(`${Ae} object contains circular references`);return new t(r,e)}},me={null:new h(u.null,null),undefined:new h(u.undefined,void 0),true:new h(u.true,!0),false:new h(u.false,!1),emptyArray:new h(u.array,0),emptyMap:new h(u.map,0)},ie={number(t,e,r,n){return!Number.isInteger(t)||!Number.isSafeInteger(t)?new h(u.float,t):t>=0?new h(u.uint,t):new h(u.negint,t)},bigint(t,e,r,n){return t>=BigInt(0)?new h(u.uint,t):new h(u.negint,t)},Uint8Array(t,e,r,n){return new h(u.bytes,t)},string(t,e,r,n){return new h(u.string,t)},boolean(t,e,r,n){return t?me.true:me.false},null(t,e,r,n){return me.null},undefined(t,e,r,n){return me.undefined},ArrayBuffer(t,e,r,n){return new h(u.bytes,new Uint8Array(t))},DataView(t,e,r,n){return new h(u.bytes,new Uint8Array(t.buffer,t.byteOffset,t.byteLength))},Array(t,e,r,n){if(!t.length)return r.addBreakTokens===!0?[me.emptyArray,new h(u.break)]:me.emptyArray;n=kt.createCheck(n,t);let o=[],i=0;for(let s of t)o[i++]=Se(s,r,n);return r.addBreakTokens?[new h(u.array,t.length),o,new h(u.break)]:[new h(u.array,t.length),o]},Object(t,e,r,n){let o=e!=="Object",i=o?t.keys():Object.keys(t),s=o?t.size:i.length,a;if(s){a=new Array(s),n=kt.createCheck(n,t);let c=!o&&r.ignoreUndefinedProperties,f=0;for(let l of i){let d=o?t.get(l):t[l];c&&d===void 0||(a[f++]=[Se(l,r,n),Se(d,r,n)])}f<s&&(a.length=f)}return a?.length?(xc(a,r),r.addBreakTokens?[new h(u.map,a.length),a,new h(u.break)]:[new h(u.map,a.length),a]):r.addBreakTokens===!0?[me.emptyMap,new h(u.break)]:me.emptyMap},Tagged(t,e,r,n){return[new h(u.tag,t.tag),Se(t.value,r,n)]}};ie.Map=ie.Object;ie.Buffer=ie.Uint8Array;for(let t of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))ie[`${t}Array`]=ie.DataView;function Se(t,e={},r){let n=nn(t),o=e&&e.typeEncoders&&e.typeEncoders[n]||ie[n];if(typeof o=="function"){let s=o(t,n,e,r);if(s!=null)return s}let i=ie[n];if(!i)throw new Error(`${Ae} unsupported type: ${n}`);return i(t,n,e,r)}function xc(t,e){e.mapSorter&&t.sort(e.mapSorter)}function bc(t,e){let r=Array.isArray(t[0])?t[0][0]:t[0],n=Array.isArray(e[0])?e[0][0]:e[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Ve[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Ec(t,e){if(t[0]instanceof h&&e[0]instanceof h){let r=t[0],n=e[0];return r._keyBytes||(r._keyBytes=Hi(r.value)),n._keyBytes||(n._keyBytes=Hi(n.value)),cr(r._keyBytes,n._keyBytes)}throw new Error("rfc8949MapSorter: complex key types are not supported yet")}function Hi(t){return pn(t,Ve,Gi)}function vt(t,e,r,n){if(Array.isArray(e))for(let o of e)vt(t,o,r,n);else r[e.type.major](t,e,n)}var qi=u.uint.majorEncoded,Vi=u.negint.majorEncoded,vc=u.bytes.majorEncoded,kc=u.string.majorEncoded,ji=u.array.majorEncoded,_c=u.float.majorEncoded|sn,Ic=u.float.majorEncoded|an,Ac=u.float.majorEncoded|cn,Tc=u.float.majorEncoded|un,Sc=BigInt(-1),Cc=BigInt(1);function Bc(t){return t.addBreakTokens!==!0}function Wi(t,e,r,n){let o=nn(e),i=r.typeEncoders&&r.typeEncoders[o];if(i){let s=i(e,o,r,n);if(s!=null){vt(t,s,Ve,r);return}}switch(o){case"null":t.push([Ac]);return;case"undefined":t.push([Tc]);return;case"boolean":t.push([e?Ic:_c]);return;case"number":!Number.isInteger(e)||!Number.isSafeInteger(e)?Et(t,new h(u.float,e),r):e>=0?I(t,qi,e):I(t,Vi,e*-1-1);return;case"bigint":e>=BigInt(0)?I(t,qi,e):I(t,Vi,e*Sc-Cc);return;case"string":{let s=Me(e);I(t,kc,s.length),t.push(s);return}case"Uint8Array":I(t,vc,e.length),t.push(e);return;case"Array":if(!e.length){t.push([ji]);return}n=kt.createCheck(n,e),I(t,ji,e.length);for(let s of e)Wi(t,s,r,n);return;case"Object":case"Map":{let s=ie.Object(e,o,r,n);vt(t,s,Ve,r)}return;default:{let s=ie[o];if(!s)throw new Error(`${Ae} unsupported type: ${o}`);let a=s(e,o,r,n);vt(t,a,Ve,r)}}}function pn(t,e,r,n){let o=n instanceof Uint8Array,i=o?new ur(n):gr,s=Se(t,r);if(!Array.isArray(s)&&r.quickEncodeToken){let a=r.quickEncodeToken(s);if(a)return o?(i.push(a),i.toBytes()):a;let c=e[s.type.major];if(c.encodedSize){let f=c.encodedSize(s,r);if(o||(i=new gt(f)),c(i,s,r),i.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${s} was wrong`);return o?i.toBytes():Ie(i.chunks[0])}}return i.reset(),vt(i,s,e,r),i.toBytes(!0)}function mn(t,e){return e=Object.assign({},wc,e),Bc(e)?(gr.reset(),Wi(gr,t,e,void 0),gr.toBytes(!0)):pn(t,Ve,e)}var Nc={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},wr=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],r=te[e];if(r===void 0){let n=p[e];if(!n)throw new Error(`${y} 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"),je=Symbol.for("BREAK");function Dc(t,e,r){let n=[];for(let o=0;o<t.value;o++){let i=ge(e,r);if(i===je){if(t.value===1/0)break;throw new Error(`${y} got unexpected break to lengthed array`)}if(i===ye)throw new Error(`${y} found array but not enough entries (got ${o}, expected ${t.value})`);n[o]=i}return n}function Lc(t,e,r){let n=r.useMaps===!0,o=r.rejectDuplicateMapKeys===!0,i=n?void 0:{},s=n?new Map:void 0;for(let a=0;a<t.value;a++){let c=ge(e,r);if(c===je){if(t.value===1/0)break;throw new Error(`${y} got unexpected break to lengthed map`)}if(c===ye)throw new Error(`${y} found map but not enough entries (got ${a} [no key], expected ${t.value})`);if(!n&&typeof c!="string")throw new Error(`${y} non-string keys not supported (got ${typeof c})`);if(o&&(n&&s.has(c)||!n&&Object.hasOwn(i,c)))throw new Error(`${y} found repeat map key "${c}"`);let f=ge(e,r);if(f===ye)throw new Error(`${y} found map but not enough entries (got ${a} [no value], expected ${t.value})`);n?s.set(c,f):i[c]=f}return n?s:i}function*Pc(t,e,r){for(let n=0;n<t.value;n++){let o=ge(e,r);if(o===je){if(t.value===1/0)break;throw new Error(`${y} got unexpected break to lengthed map`)}if(o===ye)throw new Error(`${y} found map but not enough entries (got ${n} [no key], expected ${t.value})`);let i=ge(e,r);if(i===ye)throw new Error(`${y} found map but not enough entries (got ${n} [no value], expected ${t.value})`);yield[o,i]}}function Uc(t,e){let r=!1,n=function(){if(r)throw new Error(`${y} tag decode() may only be called once`);r=!0;let o=ge(t,e);if(o===ye)throw new Error(`${y} tag content missing`);if(o===je)throw new Error(`${y} got unexpected break in tag content`);return o};return n.entries=function(){if(r)throw new Error(`${y} tag decode() may only be called once`);r=!0;let o=t.next();if(!u.equals(o.type,u.map))throw new Error(`${y} entries() requires map content, got ${o.type.name}`);let i=[];for(let s of Pc(o,t,e))i.push(s);return i},Object.defineProperty(n,"_called",{get(){return r},enumerable:!1}),n}function ge(t,e){if(t.done())return ye;let r=t.next();if(u.equals(r.type,u.break))return je;if(r.type.terminal)return r.value;if(u.equals(r.type,u.array))return Dc(r,t,e);if(u.equals(r.type,u.map))return Lc(r,t,e);if(u.equals(r.type,u.tag)){if(e.tags&&typeof e.tags[r.value]=="function"){let n=Uc(t,e),o=e.tags[r.value](n);if(!n._called)throw new Error(`${y} tag decoder must call decode() or entries()`);return o}throw new Error(`${y} tag not supported (${r.value})`)}throw new Error("unsupported")}function yn(t,e){if(!(t instanceof Uint8Array))throw new Error(`${y} data to decode must be a Uint8Array`);e=Object.assign({},Nc,e);let r=Ie(t),n=e.tokenizer||new wr(r,e),o=ge(n,e);if(o===ye)throw new Error(`${y} did not find any content to decode`);if(o===je)throw new Error(`${y} got unexpected break`);return[o,t.subarray(n.pos())]}function _t(t,e){let[r,n]=yn(t,e);if(n.length>0)throw new Error(`${y} too many terminals, data makes no sense`);return r}var xr=class t{constructor(e,r){if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new TypeError("Tagged: tag must be a non-negative integer");this.tag=e,this.value=r}static decoder(e){return r=>new t(e,r())}static preserve(...e){let r={};for(let n of e)r[n]=t.decoder(n);return r}};Object.defineProperty(xr.prototype,Symbol.toStringTag,{value:"Tagged"});var vn={};V(vn,{base32:()=>We,base32hex:()=>Wc,base32hexpad:()=>Yc,base32hexpadupper:()=>Qc,base32hexupper:()=>Jc,base32pad:()=>jc,base32padupper:()=>Gc,base32upper:()=>Vc,base32z:()=>Xc});var rd=new Uint8Array(0);function Ji(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}function he(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return Ce(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return Ce(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function Yi(t){return new TextEncoder().encode(t)}function Qi(t){return new TextDecoder().decode(t)}function Fc(t){return t?.buffer instanceof ArrayBuffer}function Ce(t){return Fc(t)?t:t.slice()}function zc(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),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=t.length,c=t.charAt(0),f=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function d(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 x=0,b=0,A=0,N=m.length;A!==N&&m[A]===0;)A++,x++;for(var C=(N-A)*l+1>>>0,P=new Uint8Array(C);A!==N;){for(var D=m[A],H=0,q=C-1;(D!==0||H<b)&&q!==-1;q--,H++)D+=256*P[q]>>>0,P[q]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");b=H,A++}for(var fe=C-b;fe!==C&&P[fe]===0;)fe++;for(var ir=c.repeat(x);fe<C;++fe)ir+=t.charAt(P[fe]);return ir}function g(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var x=0;if(m[x]!==" "){for(var b=0,A=0;m[x]===c;)b++,x++;for(var N=(m.length-x)*f+1>>>0,C=new Uint8Array(N);m[x];){var P=r[m.charCodeAt(x)];if(P===255)return;for(var D=0,H=N-1;(P!==0||D<A)&&H!==-1;H--,D++)P+=a*C[H]>>>0,C[H]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");A=D,x++}if(m[x]!==" "){for(var q=N-A;q!==N&&C[q]===0;)q++;for(var fe=new Uint8Array(b+(N-q)),ir=b;q!==N;)fe[ir++]=C[q++];return fe}}}function w(m){var x=g(m);if(x)return x;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:g,decode:w}}var $c=zc,Mc=$c,Xi=Mc;var wn=class{name;prefix;baseEncode;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")}},xn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,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(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 Ki(this,e)}},bn=class{decoders;constructor(e){this.decoders=e}or(e){return Ki(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ki(t,e){return new bn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var En=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new wn(e,r,n),this.decoder=new xn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ge({name:t,prefix:e,encode:r,decode:n}){return new En(t,e,r,n)}function we({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Xi(r,t);return Ge({prefix:e,name:t,encode:n,decode:i=>he(o(i))})}function Oc(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let f=0;f<o;++f){let l=e[t[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|l,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Hc(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function qc(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function B({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=qc(n);return Ge({prefix:e,name:t,encode(i){return Hc(i,n,r)},decode(i){return Oc(i,o,r,t)}})}var We=B({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Vc=B({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),jc=B({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gc=B({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wc=B({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jc=B({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Yc=B({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qc=B({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xc=B({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var kn={};V(kn,{base36:()=>It,base36upper:()=>Kc});var It=we({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Kc=we({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var _n={};V(_n,{base58btc:()=>se,base58flickr:()=>Zc});var se=we({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Zc=we({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var eu=ts,Zi=128,tu=127,ru=~tu,nu=Math.pow(2,31);function ts(t,e,r){e=e||[],r=r||0;for(var n=r;t>=nu;)e[r++]=t&255|Zi,t/=128;for(;t&ru;)e[r++]=t&255|Zi,t>>>=7;return e[r]=t|0,ts.bytes=r-n+1,e}var ou=In,iu=128,es=127;function In(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw In.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&es)<<o:(s&es)*Math.pow(2,o),o+=7}while(s>=iu);return In.bytes=i-n,r}var su=Math.pow(2,7),au=Math.pow(2,14),cu=Math.pow(2,21),uu=Math.pow(2,28),fu=Math.pow(2,35),lu=Math.pow(2,42),hu=Math.pow(2,49),du=Math.pow(2,56),pu=Math.pow(2,63),mu=function(t){return t<su?1:t<au?2:t<cu?3:t<uu?4:t<fu?5:t<lu?6:t<hu?7:t<du?8:t<pu?9:10},yu={encode:eu,decode:ou,encodingLength:mu},gu=yu,At=gu;function Tt(t,e=0){return[At.decode(t,e),At.decode.bytes]}function Je(t,e,r=0){return At.encode(t,e,r),e}function Ye(t){return At.encodingLength(t)}function Xe(t,e){let r=e.byteLength,n=Ye(t),o=n+Ye(r),i=new Uint8Array(o+r);return Je(t,i,0),Je(r,i,n),i.set(e,o),new Qe(t,r,e,i)}function Ke(t){let e=he(t),[r,n]=Tt(e),[o,i]=Tt(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Qe(r,o,s,e)}function rs(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ji(t.bytes,r.bytes)}}var Qe=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=Ce(n),this.bytes=Ce(o)}};function ns(t,e){let{bytes:r,version:n}=t;return n===0?xu(r,An(t),e??se.encoder):bu(r,An(t),e??We.encoder)}var os=new WeakMap;function An(t){let e=os.get(t);if(e==null){let r=new Map;return os.set(t,r),r}return e}var E=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=Ce(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==St)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Eu)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=Xe(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!=null&&e.code===n.code&&e.version===n.version&&rs(e.multihash,n.multihash)}toString(e){return ns(this,e)}toJSON(){return{"/":ns(this)}}link(){return this}[Symbol.toStringTag]="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:s}=r;return new t(n,o,i,s??is(n,o,i.bytes))}else if(r[vu]===!0){let{version:n,multihash:o,code:i}=r,s=Ke(o);return t.create(n,i,s)}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!==St)throw new Error(`Version 0 CID must use dag-pb (code: ${St}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=is(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,St,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=he(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Qe(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[d,g]=Tt(e.subarray(r));return r+=g,d},o=n(),i=St;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),f=r+c,l=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:l,size:f}}static parse(e,r){let[n,o]=wu(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 An(i).set(n,e),i}};function wu(t,e){switch(t[0]){case"Q":{let r=e??se;return[se.prefix,r.decode(`${se.prefix}${t}`)]}case se.prefix:{let r=e??se;return[se.prefix,r.decode(t)]}case We.prefix:{let r=e??We;return[We.prefix,r.decode(t)]}case It.prefix:{let r=e??It;return[It.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function xu(t,e,r){let{prefix:n}=r;if(n!==se.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}function bu(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}var St=112,Eu=18;function is(t,e,r){let n=Ye(t),o=n+Ye(e),i=new Uint8Array(o+r.byteLength);return Je(t,i,0),Je(e,i,n),i.set(r,o),i}var vu=Symbol.for("@ipld/js-cid/CID");var ss=42;function ku(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}function _u(t){if(t.asCID!==t&&t["/"]!==t.bytes)return null;let e=E.asCID(t);if(!e)return null;let r=new Uint8Array(e.bytes.byteLength+1);return r.set(e.bytes,1),[new h(u.tag,ss),new h(u.bytes,r)]}function Iu(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Au(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}function Tu(t){for(let e of t.keys())if(typeof e!="string"||e.length===0)throw new Error("Non-string Map keys are not supported by the IPLD Data Model and cannot be encoded");return null}var Tn={float64:!0,typeEncoders:{Map:Tu,Object:_u,undefined:Iu,number:Au}},bd={...Tn,typeEncoders:{...Tn.typeEncoders}};function Su(t){let e=t();if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return E.decode(e.subarray(1))}var Sn={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{[ss]:Su}},Ed={...Sn,tags:{...Sn.tags}};var Er=113,Cn=t=>mn(t,Tn),Be=t=>_t(ku(t),Sn);var Dn=$e(vr(),1);var Ln=40;function Pn(t,e){if(!t.length)throw new Error("Unexpected end of data");let r=Dn.default.decode(t);return e.seek(Dn.default.decode.bytes),r}function Un(t){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),r=0;return{version:2,characteristics:[e.getBigUint64(r,!0),e.getBigUint64(r+=8,!0)],dataOffset:Number(e.getBigUint64(r+=8,!0)),dataSize:Number(e.getBigUint64(r+=8,!0)),indexOffset:Number(e.getBigUint64(r+=8,!0))}}var be={Null:t=>t===null?t:void 0,Int:t=>Number.isInteger(t)?t:void 0,Float:t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,String:t=>typeof t=="string"?t:void 0,Bool:t=>typeof t=="boolean"?t:void 0,Bytes:t=>t instanceof Uint8Array?t:void 0,Link:t=>t!==null&&typeof t=="object"&&t.asCID===t?t:void 0,List:t=>Array.isArray(t)?t:void 0,Map:t=>t!==null&&typeof t=="object"&&t.asCID!==t&&!Array.isArray(t)&&!(t instanceof Uint8Array)?t:void 0},Bt={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":be.Link,"CarV1HeaderOrV2Pragma > roots (anon)":t=>{if(be.List(t)!==void 0){for(let e=0;e<t.length;e++){let r=t[e];if(r=Bt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==t[e]){let n=t.slice(0,e);for(let o=e;o<t.length;o++){let i=t[o];if(i=Bt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return t}},Int:be.Int,CarV1HeaderOrV2Pragma:t=>{if(be.Map(t)===void 0)return;let e=Object.entries(t),r=t,n=1;for(let o=0;o<e.length;o++){let[i,s]=e[o];switch(i){case"roots":{let a=Bt["CarV1HeaderOrV2Pragma > roots (anon)"](t[i]);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.roots=a}}break;case"version":{n--;let a=Bt.Int(t[i]);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},Nt={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":be.Link,"CarV1HeaderOrV2Pragma > roots (anon)":t=>{if(be.List(t)!==void 0){for(let e=0;e<t.length;e++){let r=t[e];if(r=Nt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==t[e]){let n=t.slice(0,e);for(let o=e;o<t.length;o++){let i=t[o];if(i=Nt["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return t}},Int:be.Int,CarV1HeaderOrV2Pragma:t=>{if(be.Map(t)===void 0)return;let e=Object.entries(t),r=t,n=1;for(let o=0;o<e.length;o++){let[i,s]=e[o];switch(i){case"roots":{let a=Nt["CarV1HeaderOrV2Pragma > roots (anon)"](s);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.roots=a}}break;case"version":{n--;let a=Nt.Int(s);if(a===void 0)return;if(a!==s||r!==t){if(r===t){r={};for(let c=0;c<o;c++)r[e[c][0]]=e[c][1]}r.version=a}}break;default:return}}if(!(n>0))return r}},Rn={toTyped:Bt.CarV1HeaderOrV2Pragma,toRepresentation:Nt.CarV1HeaderOrV2Pragma};var Rd=dn();var ju=$e(vr(),1);var Od=[new h(u.map,2),new h(u.string,"version"),new h(u.uint,1),new h(u.string,"roots")],Hd=new h(u.tag,42);async function Fn(t,e){let r=Pn(await t.upTo(8),t);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await t.exactly(r,!0),o=Be(n);if(Rn.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||e!==void 0&&o.version!==e)throw new Error(`Invalid CAR version: ${o.version}${e!==void 0?` (expected ${e})`:""}`);if(o.version===1){if(!Array.isArray(o.roots))throw new Error("Invalid CAR header format");return o}if(o.roots!==void 0)throw new Error("Invalid CAR header format");let i=Un(await t.exactly(Ln,!0));t.seek(i.dataOffset-t.pos);let s=await Fn(t,1);return Object.assign(s,i)}function Dt(t){let e=0;return{async upTo(r){return t.subarray(e,e+Math.min(r,t.length-e))},async exactly(r,n=!1){if(r>t.length-e)throw new Error("Unexpected end of data");let o=t.subarray(e,e+r);return n&&(e+=r),o},seek(r){e+=r},get pos(){return e}}}var zn=$e(vr(),1),ws=1;function $n(t){let e=Cn({version:ws,roots:t}),r=zn.default.encode(e.length),n=new Uint8Array(r.length+e.length);return n.set(r,0),n.set(e,r.length),n}function xs(t){return{async setRoots(e){let r=$n(e);await t.write(r)},async writeBlock(e){let{cid:r,bytes:n}=e;await t.write(new Uint8Array(zn.default.encode(r.bytes.length+n.length))),await t.write(r.bytes),n.length&&await t.write(n)},async close(){await t.end()},version(){return ws}}}function kr(){}function bs(){let t=[],e=null,r=kr,n=!1,o=null,i=kr,s=()=>(e||(e=new Promise(f=>{r=()=>{e=null,r=kr,f()}})),e),a={write(f){t.push(f);let l=s();return i(),l},async end(){n=!0;let f=s();i(),await f}},c={async next(){let f=t.shift();return f?(t.length===0&&r(),{done:!1,value:f}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(l=>{i=()=>(o=null,i=kr,l(c.next()))})),o)}};return{writer:a,iterator:c}}var Lt=class t{constructor(e,r){this._encoder=r,this._mutex=r.setRoots(e),this._ended=!1}async put(e){if(!(e.bytes instanceof Uint8Array)||!e.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=E.asCID(e.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:e.bytes})),this._mutex}async close(){if(this._ended)throw new Error("Already closed");return await this._mutex,this._ended=!0,this._encoder.close()}version(){return this._encoder.version()}static create(e){e=Yu(e);let{encoder:r,iterator:n}=Es(),o=new t(e,r),i=new _r(n);return{writer:o,out:i}}static createAppender(){let{encoder:e,iterator:r}=Es();e.setRoots=()=>Promise.resolve();let n=new t([],e),o=new _r(r);return{writer:n,out:o}}static async updateRootsInBytes(e,r){let n=Dt(e);await Fn(n);let o=$n(r);if(Number(n.pos)!==o.length)throw new Error(`updateRoots() can only overwrite a header of the same length (old header is ${n.pos} bytes, new header is ${o.length} bytes)`);return e.set(o,0),e}},_r=class{constructor(e){this._iterator=e}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function Es(){let t=bs(),{writer:e,iterator:r}=t;return{encoder:xs(e),iterator:r}}function Yu(t){if(t===void 0)return[];if(!Array.isArray(t)){let r=E.asCID(t);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let e=[];for(let r of t){let n=E.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");e.push(n)}return e}function Qu(t){return t[Symbol.asyncIterator]!=null}function Xu(t){if(Qu(t))return(async()=>{for await(let e of t);})();for(let e of t);}var Mn=Xu;function Ku(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var Ir=Ku;function Zu(t){return t[Symbol.asyncIterator]!=null}function ef(t,e){let r=0;if(Zu(t))return(async function*(){for await(let c of t)yield e(c,r++)})();let n=Ir(t),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=e(o,r++);if(typeof s.then=="function")return(async function*(){yield await s;for(let c of n)yield e(c,r++)})();let a=e;return(function*(){yield s;for(let c of n)yield a(c,r++)})()}var Ze=ef;function tf(t){return t.reason}async function et(t,e,r){if(e==null)return t;let n=r?.translateError??tf;if(e.aborted)return t.catch(()=>{}),Promise.reject(n(e));let o;try{return await Promise.race([t,new Promise((i,s)=>{o=()=>{s(n(e))},e.addEventListener("abort",o)})])}finally{o!=null&&e.removeEventListener("abort",o)}}function ae(t=0){return new Uint8Array(t)}var rf=Math.pow(2,7),nf=Math.pow(2,14),of=Math.pow(2,21),vs=Math.pow(2,28),ks=Math.pow(2,35),_s=Math.pow(2,42),Is=Math.pow(2,49),M=128,Ee=127;function Pt(t){if(t<rf)return 1;if(t<nf)return 2;if(t<of)return 3;if(t<vs)return 4;if(t<ks)return 5;if(t<_s)return 6;if(t<Is)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function As(t,e,r=0){switch(Pt(t)){case 8:e[r++]=t&255|M,t/=128;case 7:e[r++]=t&255|M,t/=128;case 6:e[r++]=t&255|M,t/=128;case 5:e[r++]=t&255|M,t/=128;case 4:e[r++]=t&255|M,t>>>=7;case 3:e[r++]=t&255|M,t>>>=7;case 2:e[r++]=t&255|M,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Ts(t,e){let r=t[e],n=0;if(n+=r&Ee,r<M||(r=t[e+1],n+=(r&Ee)<<7,r<M)||(r=t[e+2],n+=(r&Ee)<<14,r<M)||(r=t[e+3],n+=(r&Ee)<<21,r<M)||(r=t[e+4],n+=(r&Ee)*vs,r<M)||(r=t[e+5],n+=(r&Ee)*ks,r<M)||(r=t[e+6],n+=(r&Ee)*_s,r<M)||(r=t[e+7],n+=(r&Ee)*Is,r<M))return n;throw new RangeError("Could not decode varint")}function sf(t){return t.buffer instanceof ArrayBuffer}function Ss(t){return sf(t)?t:t.slice()}var On=new Float32Array([-0]),ve=new Uint8Array(On.buffer);function Cs(t,e,r){On[0]=t,e[r]=ve[0],e[r+1]=ve[1],e[r+2]=ve[2],e[r+3]=ve[3]}function Bs(t,e){return ve[0]=t[e],ve[1]=t[e+1],ve[2]=t[e+2],ve[3]=t[e+3],On[0]}var Hn=new Float64Array([-0]),U=new Uint8Array(Hn.buffer);function Ns(t,e,r){Hn[0]=t,e[r]=U[0],e[r+1]=U[1],e[r+2]=U[2],e[r+3]=U[3],e[r+4]=U[4],e[r+5]=U[5],e[r+6]=U[6],e[r+7]=U[7]}function Ds(t,e){return U[0]=t[e],U[1]=t[e+1],U[2]=t[e+2],U[3]=t[e+3],U[4]=t[e+4],U[5]=t[e+5],U[6]=t[e+6],U[7]=t[e+7],Hn[0]}var af=BigInt(Number.MAX_SAFE_INTEGER),cf=BigInt(Number.MIN_SAFE_INTEGER),Y=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Ne;if(e<af&&e>cf)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Ls&&(o=0n,++n>Ls&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ne;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Ne}},Ne=new Y(0,0);Ne.toBigInt=function(){return 0n};Ne.zzEncode=Ne.zzDecode=function(){return this};Ne.length=function(){return 1};var Ls=4294967296n;function Ps(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Us(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function qn(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function re(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function Ar(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Vn=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=Ss(e),this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,re(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw re(this,4);return Ar(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw re(this,4);return Ar(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw re(this,4);let e=Bs(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw re(this,4);let e=Ds(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw re(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return Us(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw re(this,e);this.pos+=e}else do if(this.pos>=this.len)throw re(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Y(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw re(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw re(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw re(this,8);let e=Ar(this.buf,this.pos+=4),r=Ar(this.buf,this.pos+=4);return new Y(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Ts(this.buf,this.pos);return this.pos+=Pt(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ut(t){return new Vn(t instanceof Uint8Array?t:t.subarray())}function Rt(t,e,r){let n=Ut(t);return e.decode(n,void 0,r)}var jn={};V(jn,{base10:()=>uf});var uf=we({prefix:"9",name:"base10",alphabet:"0123456789"});var Gn={};V(Gn,{base16:()=>ff,base16upper:()=>lf});var ff=B({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),lf=B({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wn={};V(Wn,{base2:()=>hf});var hf=B({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Jn={};V(Jn,{base256emoji:()=>gf});var Fs=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),df=Fs.reduce((t,e,r)=>(t[r]=e,t),[]),pf=Fs.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function mf(t){return t.reduce((e,r)=>(e+=df[r],e),"")}function yf(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=pf[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var gf=Ge({prefix:"\u{1F680}",name:"base256emoji",encode:mf,decode:yf});var Qn={};V(Qn,{base64:()=>Yn,base64pad:()=>wf,base64url:()=>xf,base64urlpad:()=>bf});var Yn=B({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wf=B({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),xf=B({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bf=B({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Xn={};V(Xn,{base8:()=>Ef});var Ef=B({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Kn={};V(Kn,{identity:()=>vf});var vf=Ge({prefix:"\0",name:"identity",encode:t=>Qi(t),decode:t=>Yi(t)});var Yp=new TextEncoder,kf=new TextDecoder;var Tr=512;function Sr(t){return JSON.parse(kf.decode(t))}var tt=85;var Zn={};V(Zn,{identity:()=>zt});var zs=0,_f="identity",$s=he;function If(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Xe(zs,$s(t))}var zt={code:zs,name:_f,encode:$s,digest:If};var to={};V(to,{sha256:()=>Tf,sha512:()=>Sf});var Af=20;function De({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new eo(t,e,r,n,o)}var eo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Af,this.maxDigestLength=i}digest(e,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(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?Ms(n,this.code,r?.truncate):n.then(o=>Ms(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Ms(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Xe(e,t)}function Hs(t){return async e=>new Uint8Array(await crypto.subtle.digest(t,e))}var Tf=De({name:"sha2-256",code:18,encode:Hs("SHA-256")}),Sf=De({name:"sha2-512",code:19,encode:Hs("SHA-512")});var ro={...Kn,...Wn,...Xn,...jn,...Gn,...vn,...kn,..._n,...Qn,...Jn},cm={...to,...Zn};function Vs(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var qs=Vs("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),no=Vs("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=ae(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Cf={utf8:qs,"utf-8":qs,hex:ro.base16,latin1:no,ascii:no,binary:no,...ro},oo=Cf;function Br(t,e="utf8"){let r=oo[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function io(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return ae(s);o+s>e&&(n=ae(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Le=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function so(){}var co=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Bf=io();function Nf(t){return globalThis.Buffer!=null?ae(t):Bf(t)}var Mt=class{len;head;tail;states;constructor(){this.len=0,this.head=new Le(so,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Le(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new uo((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Nr,10,Y.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Y.fromBigInt(e);return this._push(Nr,r.length(),r)}uint64Number(e){return this._push(As,Pt(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Y.fromBigInt(e).zzEncode();return this._push(Nr,r.length(),r)}sint64Number(e){let r=Y.fromNumber(e).zzEncode();return this._push(Nr,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ao,1,e?1:0)}fixed32(e){return this._push($t,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Y.fromBigInt(e);return this._push($t,4,r.lo)._push($t,4,r.hi)}fixed64Number(e){let r=Y.fromNumber(e);return this._push($t,4,r.lo)._push($t,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Cs,4,e)}double(e){return this._push(Ns,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(ao,1,0):this.uint32(r)._push(Lf,r,e)}string(e){let r=Ps(e);return r!==0?this.uint32(r)._push(qn,r,e):this._push(ao,1,0)}fork(){return this.states=new co(this),this.head=this.tail=new Le(so,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Le(so,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=Nf(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function ao(t,e,r){e[r]=t&255}function Df(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var uo=class extends Le{next;constructor(e,r){super(Df,e,r),this.next=void 0}};function Nr(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function $t(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Lf(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Mt.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Pf,e,t),this},Mt.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Uf,e,t),this});function Pf(t,e,r){e.set(t,r)}function Uf(t,e,r){t.length<40?qn(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Br(t),r)}function fo(){return new Mt}function Ot(t,e){let r=fo();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*Ht(t,e,r){let n=Ut(t);yield*e.stream(n,void 0,"$",r)}var Dr={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function Lr(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function lo(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(s,a){let c=e(s);a.int32(c)},n=function(s){let a=s.int32();return e(a)},o=function*(s){let a=s.int32();yield e(a)};return Lr("enum",Dr.VARINT,r,n,o)}function qt(t,e,r){return Lr("message",Dr.LENGTH_DELIMITED,t,e,r)}var Vt=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};function Rf(t){return t?.buffer instanceof ArrayBuffer}function js(t){if(Rf(t))return t;let e=t.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function jt(t,e){e==null&&(e=t.reduce((o,i)=>o+i.length,0));let r=ae(e),n=0;for(let o of t)r.set(o,n),n+=o.length;return js(r)}var de=class extends Error{static name="AbortError";constructor(e="The operation was aborted"){super(e),this.name="AbortError"}};var Pe=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}};function Ff(t){return typeof t?.handleEvent=="function"}function zf(t){return(t!==!0&&t!==!1&&t?.once)??!1}var Pr=class extends EventTarget{#e=new Map;constructor(){super()}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){let o=zf(n);super.addEventListener(e,s=>{if(o){let a=this.#e.get(s.type);a!=null&&(a=a.filter(({callback:c})=>c!==r),this.#e.set(s.type,a))}Ff(r)?r.handleEvent(s):r(s)},n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:r,once:o})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var R=class extends Event{type;detail;constructor(e,r){super(e),this.type=e,this.detail=r}};var po=$e(Ws(),1);var mo=class t extends Error{name="TimeoutError";constructor(e,r){super(e,r),Error.captureStackTrace?.(this,t)}},Js=t=>t.reason??new DOMException("This operation was aborted.","AbortError");function Wt(t,e){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout},signal:s}=e,a,c,l=new Promise((d,g)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(s?.aborted){g(Js(s));return}if(s&&(c=()=>{g(Js(s))},s.addEventListener("abort",c,{once:!0})),t.then(d,g),r===Number.POSITIVE_INFINITY)return;let w=new mo;a=i.setTimeout.call(void 0,()=>{if(n){try{d(n())}catch(m){g(m)}return}typeof t.cancel=="function"&&t.cancel(),o===!1?d():o instanceof Error?g(o):(w.message=o??`Promise timed out after ${r} milliseconds`,g(w))},r)}).finally(()=>{l.clear(),c&&s&&s.removeEventListener("abort",c)});return l.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},l}function yo(t,e,r){let n=0,o=t.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(t[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var Of=100,rt=class{#e=[];#t=0;enqueue(e,r){let{priority:n=0,id:o}=r??{},{size:i}=this,s={priority:n,id:o,run:e};if(i===0){this.#e.length=0,this.#t=0,this.#e.push(s);return}if(this.#e.at(-1).priority>=n){this.#e.push(s);return}this.#i();let a=yo(this.#e,s,(c,f)=>f.priority-c.priority);this.#e.splice(a,0,s)}setPriority(e,r){let n=this.#e.findIndex((i,s)=>s>=this.#t&&i.id===e);if(n===-1)throw new ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[o]=this.#e.splice(n,1);this.enqueue(o.run,{priority:r,id:e})}remove(e){let r=this.#e.findIndex((n,o)=>o<this.#t?!1:typeof e=="string"?n.id===e:n.run===e);r!==-1&&this.#e.splice(r,1)}dequeue(){if(this.#t===this.#e.length)return;let e=this.#e[this.#t];return this.#t++,this.#t===this.#e.length?(this.#e.length=0,this.#t=0):this.#t>Of&&this.#t>this.#e.length/2&&this.#i(),e?.run}filter(e){let r=[];for(let n=this.#t;n<this.#e.length;n++){let o=this.#e[n];o.priority===e.priority&&r.push(o.run)}return r}get size(){return this.#e.length-this.#t}#i(){this.#t!==0&&(this.#e.splice(0,this.#t),this.#t=0)}};var Jt=class extends po.default{#e;#t;#i=0;#d;#m=!1;#x=!1;#c;#T=0;#b=0;#u;#f;#a;#s=[];#o=0;#r;#S;#n=0;#y;#l;#L=1n;#g=new Map;#E=new Set;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:rt,strict:!1,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);if(e.strict&&e.interval===0)throw new TypeError("The `strict` option requires a non-zero `interval`");if(e.strict&&e.intervalCap===Number.POSITIVE_INFINITY)throw new TypeError("The `strict` option requires a finite `intervalCap`");if(this.#e=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#t=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#d=e.intervalCap,this.#c=e.interval,this.#a=e.strict,this.#r=new e.queueClass,this.#S=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#l=e.autoStart===!1,this.#O()}#v(e){for(;this.#o<this.#s.length;){let n=this.#s[this.#o];if(n!==void 0&&e-n>=this.#c)this.#o++;else break}(this.#o>100&&this.#o>this.#s.length/2||this.#o===this.#s.length)&&(this.#s=this.#s.slice(this.#o),this.#o=0)}#P(e){this.#a?this.#s.push(e):this.#i++}#U(){this.#a?this.#s.length>this.#o&&this.#s.pop():this.#i>0&&this.#i--}#k(){return this.#s.length-this.#o}get#R(){return this.#t?!0:this.#a?this.#k()<this.#d:this.#i<this.#d}get#F(){return this.#n<this.#y}#z(){this.#n--,this.#n===0&&this.emit("pendingZero"),this.#w(),this.emit("next")}#$(){this.#f=void 0,this.#N(),this.#B()}#M(e){if(this.#a){if(this.#v(e),this.#k()>=this.#d){let n=this.#s[this.#o],o=this.#c-(e-n);return this.#_(o),!0}return!1}if(this.#u===void 0){let r=this.#T-e;if(r<0){if(this.#b>0){let n=e-this.#b;if(n<this.#c)return this.#_(this.#c-n),!0}this.#i=this.#e?this.#n:0}else return this.#_(r),!0}return!1}#_(e){this.#f===void 0&&(this.#f=setTimeout(()=>{this.#$()},e))}#I(){this.#u&&(clearInterval(this.#u),this.#u=void 0)}#C(){this.#f&&(clearTimeout(this.#f),this.#f=void 0)}#w(){if(this.#r.size===0){if(this.#I(),this.emit("empty"),this.#n===0){if(this.#C(),this.#a&&this.#o>0){let r=Date.now();this.#v(r)}this.emit("idle")}return!1}let e=!1;if(!this.#l){let r=Date.now(),n=!this.#M(r);if(this.#R&&this.#F){let o=this.#r.dequeue();this.#t||(this.#P(r),this.#p()),this.emit("active"),o(),n&&this.#B(),e=!0}}return e}#B(){this.#t||this.#u!==void 0||this.#a||(this.#u=setInterval(()=>{this.#N()},this.#c),this.#T=Date.now()+this.#c)}#N(){this.#a||(this.#i===0&&this.#n===0&&this.#u&&this.#I(),this.#i=this.#e?this.#n:0),this.#A(),this.#p()}#A(){for(;this.#w(););}get concurrency(){return this.#y}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#y=e,this.#A()}setPriority(e,r){if(typeof r!="number"||!Number.isFinite(r))throw new TypeError(`Expected \`priority\` to be a finite number, got \`${r}\` (${typeof r})`);this.#r.setPriority(e,r)}async add(e,r={}){return r={timeout:this.timeout,...r,id:r.id??(this.#L++).toString()},new Promise((n,o)=>{let i=Symbol(`task-${r.id}`),s=()=>{},a=async()=>{s(),this.#n++,this.#g.set(i,{id:r.id,priority:r.priority??0,startTime:Date.now(),timeout:r.timeout});let f;try{try{r.signal?.throwIfAborted()}catch(g){throw this.#H(),this.#g.delete(i),g}this.#b=Date.now();let l=e({signal:r.signal});if(r.timeout&&(l=Wt(Promise.resolve(l),{milliseconds:r.timeout,message:`Task timed out after ${r.timeout}ms (queue has ${this.#n} running, ${this.#r.size} waiting)`})),r.signal){let{signal:g}=r;l=Promise.race([l,new Promise((w,m)=>{f=()=>{m(g.reason)},g.addEventListener("abort",f,{once:!0})})])}let d=await l;n(d),this.emit("completed",d)}catch(l){o(l),this.emit("error",l)}finally{f&&r.signal?.removeEventListener("abort",f),this.#g.delete(i),queueMicrotask(()=>{this.#z()})}};this.#r.enqueue(a,r);let c=()=>{if(this.#r instanceof rt){this.#r.remove(a);return}this.#r.remove?.(r.id)};if(r.signal){let{signal:f}=r,l=()=>{s(),c(),o(f.reason),this.#w(),this.emit("next")};if(s=()=>{f.removeEventListener("abort",l),this.#E.delete(s)},f.aborted){l();return}f.addEventListener("abort",l,{once:!0}),this.#E.add(s)}this.emit("add"),this.#w()})}async addAll(e,r){return Promise.all(e.map(async n=>this.add(n,r)))}start(){return this.#l?(this.#l=!1,this.#A(),this):this}pause(){this.#l=!0}clear(){for(let e of this.#E)e();this.#r=new this.#S,this.#I(),this.#D(),this.emit("empty"),this.#n===0&&(this.#C(),this.emit("idle")),this.emit("next")}async onEmpty(){this.#r.size!==0&&await this.#h("empty")}async onSizeLessThan(e){this.#r.size<e||await this.#h("next",()=>this.#r.size<e)}async onIdle(){this.#n===0&&this.#r.size===0||await this.#h("idle")}async onPendingZero(){this.#n!==0&&await this.#h("pendingZero")}async onRateLimit(){this.isRateLimited||await this.#h("rateLimit")}async onRateLimitCleared(){this.isRateLimited&&await this.#h("rateLimitCleared")}onError(){return new Promise((e,r)=>{let n=o=>{this.off("error",n),r(o)};this.on("error",n)})}async#h(e,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#r.size}sizeBy(e){return this.#r.filter(e).length}get pending(){return this.#n}get isPaused(){return this.#l}#O(){this.#t||(this.on("add",()=>{this.#r.size>0&&this.#p()}),this.on("next",()=>{this.#p()}))}#p(){this.#t||this.#x||(this.#x=!0,queueMicrotask(()=>{this.#x=!1,this.#D()}))}#H(){this.#t||(this.#U(),this.#p())}#D(){let e=this.#m;if(this.#t||this.#r.size===0){e&&(this.#m=!1,this.emit("rateLimitCleared"));return}let r;if(this.#a){let o=Date.now();this.#v(o),r=this.#k()}else r=this.#i;let n=r>=this.#d;n!==e&&(this.#m=n,this.emit(n?"rateLimit":"rateLimitCleared"))}get isRateLimited(){return this.#m}get isSaturated(){return this.#n===this.#y&&this.#r.size>0||this.isRateLimited&&this.#r.size>0}get runningTasks(){return[...this.#g.values()].map(e=>({...e,timeoutRemaining:e.timeout?Math.max(0,e.startTime+e.timeout-Date.now()):void 0}))}};var Vf=$e(Qs(),1);var nt;(function(t){t[t.A=1]="A",t[t.CNAME=5]="CNAME",t[t.TXT=16]="TXT",t[t.AAAA=28]="AAAA"})(nt||(nt={}));function z(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var Rr=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||(e-1&e)!==0)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},ot=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new Rr(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new Rr(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var go=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function it(t={}){return jf(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function jf(t,e){e=e??{};let r=e.onEnd,n=new ot,o,i,s,a=z(),c=async()=>{try{return n.isEmpty()?s?{done:!0}:await new Promise((b,A)=>{i=N=>{i=null,n.push(N);try{b(t(n))}catch(C){A(C)}return o}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=z()})}},f=b=>i!=null?i(b):(n.push(b),o),l=b=>(n=new ot,i!=null?i({error:b}):(n.push({error:b}),o)),d=b=>{if(s)return o;if(e?.objectMode!==!0&&b?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return f({done:!1,value:b})},g=b=>s?o:(s=!0,b!=null?l(b):f({done:!0})),w=()=>(n=new ot,g(),{done:!0}),m=b=>(g(b),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:c,return:w,throw:m,push:d,end:g,get readableLength(){return n.size},onEmpty:async b=>{let A=b?.signal;if(A?.throwIfAborted(),n.isEmpty())return;let N,C;A!=null&&(N=new Promise((P,D)=>{C=()=>{D(new go)},A.addEventListener("abort",C)}));try{await Promise.race([a.promise,N])}finally{C!=null&&A!=null&&A?.removeEventListener("abort",C)}}},r==null)return o;let x=o;return o={[Symbol.asyncIterator](){return this},next(){return x.next()},throw(b){return x.throw(b),r!=null&&(r(b),r=void 0),{done:!0}},return(){return x.return(),r!=null&&(r(),r=void 0),{done:!0}},push:d,end(b){return x.end(b),r!=null&&(r(b),r=void 0),o},get readableLength(){return x.readableLength},onEmpty:b=>x.onEmpty(b)},o}var Gf=t=>{let e=t.addEventListener||t.on||t.addListener,r=t.removeEventListener||t.off||t.removeListener;if(!e||!r)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(t),removeListener:r.bind(t)}};function Wf(t,e,r){let n,o=new Promise((i,s)=>{if(r={rejectionEvents:["error"],multiArgs:!1,rejectionMultiArgs:!1,resolveImmediately:!1,...r},!(r.count>=0&&(r.count===Number.POSITIVE_INFINITY||Number.isInteger(r.count))))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();let a=[e].flat(),c=[],{addListener:f,removeListener:l}=Gf(t),d=async(...w)=>{let m=r.multiArgs?w:w[0];if(r.filter)try{if(!await r.filter(m))return}catch(x){n(),s(x);return}c.push(m),r.count===c.length&&(n(),i(c))},g=(...w)=>{n(),s(r.rejectionMultiArgs?w:w[0])};n=()=>{for(let w of a)l(w,d);for(let w of r.rejectionEvents)a.includes(w)||l(w,g)};for(let w of a)f(w,d);for(let w of r.rejectionEvents)a.includes(w)||f(w,g);r.signal&&r.signal.addEventListener("abort",()=>{g(r.signal.reason)},{once:!0}),r.resolveImmediately&&i(c)});if(o.cancel=n,typeof r.timeout=="number"){let i=Wt(o,{milliseconds:r.timeout});return i.cancel=()=>{n(),i.clear()},i}return o}function Fr(t,e,r){typeof r=="function"&&(r={filter:r}),r={...r,count:1,resolveImmediately:!1};let n=Wf(t,e,r),o=n.then(i=>i[0]);return o.cancel=n.cancel,o}function wo(t,e){let r,n=function(){let o=function(){r=void 0,t()};clearTimeout(r),r=setTimeout(o,e)};return n.start=()=>{},n.stop=()=>{clearTimeout(r)},n}var zr=class extends Error{static name="QueueFullError";constructor(e="The queue was full"){super(e),this.name="QueueFullError"}};var $r=class{deferred;signal;onProgress;constructor(e){this.signal=e?.signal,this.onProgress=e?.onProgress,this.deferred=z(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new de)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}};function Jf(){return`${parseInt(String(Math.random()*1e9),10).toString()}${Date.now()}`}var Mr=class{id;fn;options;recipients;status;timeline;controller;dispatchingProgress;constructor(e,r){this.id=Jf(),this.status="queued",this.fn=e,this.options=r,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,this.controller.signal,this.dispatchingProgress=!1,this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce((r,n)=>r&&n.signal?.aborted===!0,!0)&&(this.controller.abort(new de),this.cleanup())}async join(e){let r=new $r(e);return this.recipients.push(r),e?.signal?.addEventListener("abort",this.onAbort),r.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();let e=await et(this.fn({...this.options??{},signal:this.controller.signal,onProgress:r=>{if(!this.dispatchingProgress){this.dispatchingProgress=!0;try{this.recipients.forEach(n=>{n.onProgress?.(r)})}finally{this.dispatchingProgress=!1}}}}),this.controller.signal);this.recipients.forEach(r=>{r.deferred.resolve(e)}),this.status="complete"}catch(e){this.recipients.forEach(r=>{r.deferred.reject(e)}),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach(e=>{e.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)})}};var st=class extends Pr{concurrency;maxSize;queue;pending;sort;paused;constructor(e={}){super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.maxSize=e.maxSize??Number.POSITIVE_INFINITY,this.pending=0,this.paused=!1,e.metricName!=null&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.sort=e.sort,this.queue=[],this.emitEmpty=wo(this.emitEmpty.bind(this),1),this.emitIdle=wo(this.emitIdle.bind(this),1)}emitEmpty(){this.size===0&&this.safeDispatchEvent("empty")}emitIdle(){this.running===0&&this.safeDispatchEvent("idle")}pause(){this.paused=!0}resume(){this.paused&&(this.paused=!1,this.tryToStartAnother())}tryToStartAnother(){if(this.paused)return!1;if(this.size===0)return this.emitEmpty(),this.running===0&&this.emitIdle(),!1;if(this.pending<this.concurrency){let e;for(let r of this.queue)if(r.status==="queued"){e=r;break}return e==null?!1:(this.safeDispatchEvent("active"),this.pending++,e.run().finally(()=>{for(let r=0;r<this.queue.length;r++)if(this.queue[r]===e){this.queue.splice(r,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")}),!0)}return!1}enqueue(e){this.queue.push(e),this.sort!=null&&this.queue.sort(this.sort)}async add(e,r){if(r?.signal?.throwIfAborted(),this.size===this.maxSize)throw new zr;let n=new Mr(e,r);this.enqueue(n),this.safeDispatchEvent("add");let o=n.join(r).then(i=>(this.safeDispatchEvent("completed",{detail:i}),this.safeDispatchEvent("success",{detail:{job:n,result:i}}),i)).catch(i=>{if(n.status==="queued"){for(let s=0;s<this.queue.length;s++)if(this.queue[s]===n){this.queue.splice(s,1);break}}throw this.safeDispatchEvent("failure",{detail:{job:n,error:i}}),i});return this.tryToStartAnother(),o}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach(e=>{e.abort(new de)}),this.clear()}async onEmpty(e){this.size!==0&&await Fr(this,"empty",e)}async onSizeLessThan(e,r){this.size<e||await Fr(this,"next",{...r,filter:()=>this.size<e})}async onIdle(e){this.pending===0&&this.size===0||await Fr(this,"idle",e)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();let r=it({objectMode:!0}),n=c=>{c!=null?this.abort():this.clear(),r.end(c)},o=c=>{c.detail!=null&&r.push(c.detail)},i=c=>{n(c.detail.error)},s=()=>{n()},a=()=>{n(new de("Queue aborted"))};this.addEventListener("completed",o),this.addEventListener("failure",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",a);try{yield*r}finally{this.removeEventListener("completed",o),this.removeEventListener("failure",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",a),n()}}};function Xs(t){let e=new globalThis.AbortController;function r(){let i=t.filter(s=>s?.aborted===!0).map(s=>s?.reason).pop();e.abort(i);for(let s of t)s?.removeEventListener!=null&&s.removeEventListener("abort",r)}for(let i of t){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of t)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=e.signal;return o.clear=n,o}var xo=class{readNext;haveNext;ended;nextResult;error;constructor(){this.ended=!1,this.readNext=z(),this.haveNext=z()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=z(),e}async throw(e){return this.ended=!0,this.error=e,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return this.ended=!0,this.nextResult=e,this.haveNext.resolve(),e}async push(e,r){await this._push(e,r)}async end(e,r){e!=null?await this.throw(e):await this._push(void 0,r)}async _push(e,r){if(e!=null&&this.ended)throw this.error??new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=z(),await et(this.readNext.promise,r?.signal,r)}};function Ks(){return new xo}function Yf(t){return t[Symbol.asyncIterator]!=null}async function Qf(t,e,r){try{await Promise.all(t.map(async n=>{for await(let o of n)await e.push(o,{signal:r}),r.throwIfAborted()})),await e.end(void 0,{signal:r})}catch(n){await e.end(n,{signal:r}).catch(()=>{})}}async function*Xf(t){let e=new AbortController,r=Ks();Qf(t,r,e.signal).catch(()=>{});try{yield*r}finally{e.abort()}}function*Kf(t){for(let e of t)yield*e}function Zf(...t){let e=[];for(let r of t)Yf(r)||e.push(r);return e.length===t.length?Kf(e):Xf(t)}var Zs=Zf;function Or(t,...e){if(t==null)throw new Error("Empty pipeline");if(bo(t)){let n=t;t=()=>n.source}else if(ta(t)||ea(t)){let n=t;t=()=>n}let r=[t,...e];if(r.length>1&&bo(r[r.length-1])&&(r[r.length-1]=r[r.length-1].sink),r.length>2)for(let n=1;n<r.length-1;n++)bo(r[n])&&(r[n]=tl(r[n]));return el(...r)}var el=(...t)=>{let e;for(;t.length>0;)e=t.shift()(e);return e},ea=t=>t?.[Symbol.asyncIterator]!=null,ta=t=>t?.[Symbol.iterator]!=null,bo=t=>t==null?!1:t.sink!=null&&t.source!=null,tl=t=>e=>{let r=t.sink(e);if(r?.then!=null){let n=it({objectMode:!0});r.then(()=>{n.end()},s=>{n.end(s)});let o,i=t.source;if(ea(i))o=async function*(){yield*i,n.end()};else if(ta(i))o=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return Zs(n,o())}return t.source};function rl(t){return t[Symbol.asyncIterator]!=null}function nl(t){if(rl(t))return(async()=>{let n=new Uint8Array(0);for await(let o of t)n=jt([n,o],n.length+o.length);return n})();let e=[],r=0;for(let n of t)e.push(n),r+=n.byteLength;return jt(e,r)}var k=nl;function Hr({enumerable:t=!0,configurable:e=!1}={}){return{enumerable:t,configurable:e,writable:!1}}function*ol(t,e){if(e!=null&&typeof e=="object")if(Array.isArray(e))for(let[r,n]of e.entries()){let o=[...t,r],i=E.asCID(n);i!=null?yield[o.join("/"),i]:typeof n=="object"&&(yield*Eo(n,o))}else{let r=E.asCID(e);r!=null?yield[t.join("/"),r]:yield*Eo(e,t)}}function*Eo(t,e){if(t==null||t instanceof Uint8Array)return;let r=E.asCID(t);r!=null&&(yield[e.join("/"),r]);for(let[n,o]of Object.entries(t)){let i=[...e,n];yield*ol(i,o)}}function*il(t,e){if(Array.isArray(e))for(let[r,n]of e.entries()){let o=[...t,r];yield o.join("/"),typeof n=="object"&&E.asCID(n)==null&&(yield*vo(n,o))}else yield*vo(e,t)}function*vo(t,e){if(!(t==null||typeof t!="object"))for(let[r,n]of Object.entries(t)){let o=[...e,r];yield o.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&E.asCID(n)==null&&(yield*il(o,n))}}function sl(t,e){let r=t;for(let[n,o]of e.entries()){if(r=r[o],r==null)throw new Error(`Object has no property at ${e.slice(0,n+1).map(s=>`[${JSON.stringify(s)}]`).join("")}`);let i=E.asCID(r);if(i!=null)return{value:i,remaining:e.slice(n+1).join("/")}}return{value:r}}var ko=class{cid;bytes;value;asBlock;constructor({cid:e,bytes:r,value:n}){if(e==null||r==null||typeof n>"u")throw new Error("Missing required argument");this.cid=e,this.bytes=r,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:Hr(),bytes:Hr(),value:Hr(),asBlock:Hr()})}links(){return Eo(this.value,[])}tree(){return vo(this.value,[])}get(e="/"){return sl(this.value,e.split("/").filter(Boolean))}};function ce({bytes:t,cid:e,value:r,codec:n}){let o=r!==void 0?r:n?.decode(t);if(o===void 0)throw new Error('Missing required argument, must either provide "value" or "codec"');return new ko({cid:e,bytes:t,value:o})}var ra=class extends Array{constructor(){super(),this.inRecursive=[]}prefix(e){let r=this.inRecursive[this.inRecursive.length-1];r&&(u.equals(r.type,u.array)&&(r.elements++,r.elements!==1&&e.push([44])),u.equals(r.type,u.map)&&(r.elements++,r.elements!==1&&(r.elements%2===1?e.push([44]):e.push([58]))))}[u.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)}[u.negint.major](e,r){this[u.uint.major](e,r)}[u.bytes.major](e,r){throw new Error(`${Ae} unsupported type: Uint8Array`)}[u.string.major](e,r){this.prefix(e);let n=Me(JSON.stringify(r.value));e.push(n.length>32?Ie(n):n)}[u.array.major](e,r){this.prefix(e),this.inRecursive.push({type:u.array,elements:0}),e.push([91])}[u.map.major](e,r){this.prefix(e),this.inRecursive.push({type:u.map,elements:0}),e.push([123])}[u.tag.major](e,r){}[u.float.major](e,r){if(r.type.name==="break"){let s=this.inRecursive.pop();if(s){if(u.equals(s.type,u.array))e.push([93]);else if(u.equals(s.type,u.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(`${Ae} 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 s=0;s<n.length;s++)o[s]=n.charCodeAt(s),!i&&(o[s]===46||o[s]===101||o[s]===69)&&(i=!0);i||(o.push(46),o.push(48)),e.push(o)}};var at=class{constructor(e,r={}){this._pos=0,this.data=e,this.options=r,this.modeStack=["value"],this.lastToken=""}pos(){return this._pos}done(){return this._pos>=this.data.length}ch(){return this.data[this._pos]}currentMode(){return this.modeStack[this.modeStack.length-1]}skipWhitespace(){let 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(`${y} 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(`${y} unexpected token at position ${this._pos}, expected to find '${String.fromCharCode(...e)}'`)}parseNumber(){let e=this._pos,r=!1,n=!1,o=a=>{for(;!this.done();){let c=this.ch();if(a.includes(c))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 h(u.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(`${y} unexpected token at position ${this._pos}`);if(!this.done()&&this.ch()===46){if(n)throw new Error(`${y} 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)),s=parseFloat(i);return n?new h(u.float,s,this._pos-e):this.options.allowBigInt!==!0||Number.isSafeInteger(s)?new h(s>=0?u.uint:u.negint,s,this._pos-e):new h(s>=0?u.uint:u.negint,BigInt(i),this._pos-e)}parseString(){if(this.ch()!==34)throw new Error(`${y} unexpected character at position ${this._pos}; this shouldn't happen`);this._pos++;for(let i=this._pos,s=0;i<this.data.length&&s<65536;i++,s++){let a=this.data[i];if(a===92||a<32||a>=128)break;if(a===34){let c=String.fromCharCode.apply(null,this.data.subarray(this._pos,i));return this._pos=i+1,new h(u.string,c,s)}}let e=this._pos,r=[],n=()=>{if(this._pos+4>=this.data.length)throw new Error(`${y} unexpected end of unicode escape sequence at position ${this._pos}`);let i=0;for(let s=0;s<4;s++){let a=this.ch();if(a>=48&&a<=57)a-=48;else if(a>=97&&a<=102)a=a-97+10;else if(a>=65&&a<=70)a=a-65+10;else throw new Error(`${y} unexpected unicode escape character at position ${this._pos}`);i=i*16+a,this._pos++}return i},o=()=>{let i=this.ch(),s=null,a=i>239?4:i>223?3:i>191?2:1;if(this._pos+a>this.data.length)throw new Error(`${y} unexpected unicode sequence at position ${this._pos}`);let c,f,l,d;switch(a){case 1:i<128&&(s=i);break;case 2:c=this.data[this._pos+1],(c&192)===128&&(d=(i&31)<<6|c&63,d>127&&(s=d));break;case 3:c=this.data[this._pos+1],f=this.data[this._pos+2],(c&192)===128&&(f&192)===128&&(d=(i&15)<<12|(c&63)<<6|f&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:c=this.data[this._pos+1],f=this.data[this._pos+2],l=this.data[this._pos+3],(c&192)===128&&(f&192)===128&&(l&192)===128&&(d=(i&15)<<18|(c&63)<<12|(f&63)<<6|l&63,d>65535&&d<1114112&&(s=d))}s===null?(s=65533,a=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),this._pos+=a};for(;!this.done();){let i=this.ch(),s;switch(i){case 92:if(this._pos++,this.done())throw new Error(`${y} unexpected string termination at position ${this._pos}`);switch(s=this.ch(),this._pos++,s){case 34:case 39:case 92:case 47:r.push(s);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(`${y} unexpected string escape character at position ${this._pos}`)}break;case 34:return this._pos++,new h(u.string,Jo(r),this._pos-e);default:if(i<32)throw new Error(`${y} invalid control character at position ${this._pos}`);i<128?(r.push(i),this._pos++):o()}}throw new Error(`${y} unexpected end of string at position ${this._pos}`)}parseValue(){switch(this.ch()){case 123:return this.modeStack.push("obj-start"),this._pos++,new h(u.map,1/0,1);case 91:return this.modeStack.push("array-start"),this._pos++,new h(u.array,1/0,1);case 34:return this.parseString();case 110:return this.expect([110,117,108,108]),new h(u.null,null,4);case 102:return this.expect([102,97,108,115,101]),new h(u.false,!1,5);case 116:return this.expect([116,114,117,101]),new h(u.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(`${y} 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 h(u.break,void 0,1);if(this.ch()!==44)throw new Error(`${y} 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 h(u.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 h(u.break,void 0,1);if(this.ch()!==44)throw new Error(`${y} 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 h(u.break,void 0,1);let e=this.parseString();if(this.skipWhitespace(),this.ch()!==58)throw new Error(`${y} 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(`${y} unexpected parse state at position ${this._pos}; this shouldn't happen`)}}};function _o(t,e){return e=Object.assign({tokenizer:new at(t,e)},e),_t(t,e)}function ul(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var Io=class extends at{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(u.equals(e.type,u.map)){let r=this._next();if(u.equals(r.type,u.string)&&r.value==="/"){let n=this._next();if(u.equals(n.type,u.string)){let o=this._next();if(!u.equals(o.type,u.break))throw new Error("Invalid encoded CID form");return this.tokenBuffer.push(n),new h(u.tag,42,0)}if(u.equals(n.type,u.map)){let o=this._next();if(u.equals(o.type,u.string)&&o.value==="bytes"){let i=this._next();if(u.equals(i.type,u.string)){for(let a=0;a<2;a++){let c=this._next();if(!u.equals(c.type,u.break))throw new Error("Invalid encoded Bytes form")}let s=Yn.decode(`m${i.value}`);return new h(u.bytes,s,i.value.length)}this.tokenBuffer.push(i)}this.tokenBuffer.push(o)}this.tokenBuffer.push(n)}this.tokenBuffer.push(r)}return e}},na={allowIndefinite:!1,allowUndefined:!1,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:{42:t=>E.parse(t())}};var qr=297;var Vr=t=>{let e=ul(t),r=Object.assign(na,{tokenizer:new Io(e,na)});return _o(e,r)};var Fg=new TextDecoder;var zg=new TextEncoder;var fl=new TextDecoder;function Ao(t,e){let r=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(e>=t.length)throw new Error("protobuf: unexpected end of data");let o=t[e++];if(r+=n<28?(o&127)<<n:(o&127)*2**n,o<128)break}return[r,e]}function Gr(t,e){let r;[r,e]=Ao(t,e);let n=e+r;if(r<0||n<0)throw new Error("protobuf: invalid length");if(n>t.length)throw new Error("protobuf: unexpected end of data");return[t.subarray(e,n),n]}function oa(t,e){let r;return[r,e]=Ao(t,e),[r&7,r>>3,e]}function ll(t){let e={},r=t.length,n=0;for(;n<r;){let o,i;if([o,i,n]=oa(t,n),i===1){if(e.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Hash`);if(e.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[e.Hash,n]=Gr(t,n)}else if(i===2){if(e.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(o!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Name`);if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=Gr(t,n),e.Name=fl.decode(s)}else if(i===3){if(e.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(o!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${o}) for Tsize`);[e.Tsize,n]=Ao(t,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${i}`)}if(n>r)throw new Error("protobuf: (PBLink) unexpected end of data");return e}function ia(t){let e=t.length,r=0,n,o=!1,i;for(;r<e;){let a,c;if([a,c,r]=oa(t,r),a!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${a}`);if(c===1){if(i)throw new Error("protobuf: (PBNode) duplicate Data section");[i,r]=Gr(t,r),n&&(o=!0)}else if(c===2){if(o)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let f;[f,r]=Gr(t,r),n.push(ll(f))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${c}`)}if(r>e)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return i&&(s.Data=i),s.Links=n||[],s}var aa=new TextEncoder,sa=2**32,hl=2**31;function dl(t,e){let r=e.length;if(typeof t.Tsize=="number"){if(t.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(t.Tsize))throw new Error("Tsize too large for encoding");r=Yt(e,r,t.Tsize)-1,e[r]=24}if(typeof t.Name=="string"){let n=aa.encode(t.Name);r-=n.length,e.set(n,r),r=Yt(e,r,n.length)-1,e[r]=18}return t.Hash&&(r-=t.Hash.length,e.set(t.Hash,r),r=Yt(e,r,t.Hash.length)-1,e[r]=10),e.length-r}function ca(t){let e=ml(t),r=new Uint8Array(e),n=e;if(t.Data&&(n-=t.Data.length,r.set(t.Data,n),n=Yt(r,n,t.Data.length)-1,r[n]=10),t.Links)for(let o=t.Links.length-1;o>=0;o--){let i=dl(t.Links[o],r.subarray(0,n));n-=i,n=Yt(r,n,i)-1,r[n]=18}return r}function pl(t){let e=0;if(t.Hash){let r=t.Hash.length;e+=1+r+ct(r)}if(typeof t.Name=="string"){let r=aa.encode(t.Name).length;e+=1+r+ct(r)}return typeof t.Tsize=="number"&&(e+=1+ct(t.Tsize)),e}function ml(t){let e=0;if(t.Data){let r=t.Data.length;e+=1+r+ct(r)}if(t.Links)for(let r of t.Links){let n=pl(r);e+=1+n+ct(n)}return e}function Yt(t,e,r){e-=ct(r);let n=e;for(;r>=hl;)t[e++]=r&127|128,r/=128;for(;r>=128;)t[e++]=r&127|128,r>>>=7;return t[e]=r,n}function ct(t){return t%2===0&&t++,Math.floor((yl(t)+6)/7)}function yl(t){let e=0;return t>=sa&&(t=Math.floor(t/sa),e=32),t>=65536&&(t>>>=16,e+=16),t>=256&&(t>>>=8,e+=8),e+gl[t]}var gl=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];var wl=["Data","Links"],xl=["Hash","Name","Tsize"],ua=new TextEncoder;function bl(t,e){if(t===e)return 0;let r=t.Name?ua.encode(t.Name):[],n=e.Name?ua.encode(e.Name):[],o=r.length,i=n.length;for(let s=0,a=Math.min(o,i);s<a;++s)if(r[s]!==n[s]){o=r[s],i=n[s];break}return o<i?-1:i<o?1:0}function fa(t,e){return!Object.keys(t).some(r=>!e.includes(r))}function la(t){if(!t||typeof t!="object"||Array.isArray(t)||t instanceof Uint8Array||t["/"]&&t["/"]===t.bytes)throw new TypeError("Invalid DAG-PB form");if(!fa(t,wl))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(t.Data!==void 0&&!(t.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(t.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let e=0;e<t.Links.length;e++){let r=t.Links[e];if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!fa(r,xl))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(r.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(r.Hash==null||!r.Hash["/"]||r.Hash["/"]!==r.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(r.Name!==void 0&&typeof r.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(r.Tsize!==void 0){if(typeof r.Tsize!="number"||r.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(r.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(e>0&&bl(r,t.Links[e-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function ha(t){return t instanceof ArrayBuffer?new Uint8Array(t,0,t.byteLength):t}var ut=112;function da(t){la(t);let e={};return t.Links&&(e.Links=t.Links.map(r=>{let n={};return r.Hash&&(n.Hash=r.Hash.bytes),r.Name!==void 0&&(n.Name=r.Name),r.Tsize!==void 0&&(n.Tsize=r.Tsize),n})),t.Data&&(e.Data=t.Data),ca(e)}function ue(t){let e=ha(t),r=ia(e),n={};return r.Data&&(n.Data=r.Data),r.Links&&(n.Links=r.Links.map(o=>{let i={};try{i.Hash=E.decode(o.Hash)}catch{}if(!i.Hash)throw new Error("Invalid Hash field found in link, expected CID");return o.Name!==void 0&&(i.Name=o.Name),o.Tsize!==void 0&&(i.Tsize=o.Tsize),i})),n}function El(t){return t[Symbol.asyncIterator]!=null}function vl(t,e){let r=0;if(El(t))return(async function*(){for await(let c of t)await e(c,r++)&&(yield c)})();let n=Ir(t),{value:o,done:i}=n.next();if(i===!0)return(function*(){})();let s=e(o,r++);if(typeof s.then=="function")return(async function*(){await s&&(yield o);for(let c of n)await e(c,r++)&&(yield c)})();let a=e;return(function*(){s===!0&&(yield o);for(let c of n)a(c,r++)&&(yield c)})()}var pa=vl;function Ue(t){return e=>new To(e,t)}function Re(t){return e=>new So(e,t)}function Bo(t){return e=>new Co(e,t)}var Xt=class{components;constructor(e,r={}){this.components=e}async*walk(e,r){let n=this.getQueue(),o=pa(n.toGenerator(r),a=>a!=null),i=!1,s=async a=>{let c=a.cid,f=await k(this.components.blockstore.get(c,a)),l=ce({cid:c,bytes:f,codec:await this.components.getCodec(c.code)});for(let[,d]of l.links())r?.includeChild?.(d,l)!==!1&&n.add(s,{...a,cid:d,depth:a.depth+1,path:[...a.path,d]}).catch(g=>{i||o.throw(g)});return{block:l,depth:a.depth,path:a.path}};n.add(s,{...r,cid:e,depth:0,path:[e]}).catch(a=>{i||o.throw(a)});try{yield*o}finally{i=!0,n.abort()}}},To=class extends Xt{getQueue(){return new st({concurrency:1,sort:(e,r)=>e.options.depth===r.options.depth?0:e.options.depth<r.options.depth?1:-1})}},So=class extends Xt{getQueue(){return new st({concurrency:1,sort:(e,r)=>e.options.depth===r.options.depth?0:e.options.depth<r.options.depth?-1:1})}},Co=class extends Xt{getQueue(){return new st({concurrency:1})}};var Kt=class{walker;constructor(e){this.walker=e?.walker}async*export(e,r,n,o){let i,s={blockstore:r,getCodec:n};this.walker!=null?i=this.walker(s):i=Re()(s);for await(let a of i.walk(e,o))yield a.block}};var Wr=class{components;log;constructor(e){this.components=e,this.log=e.logger.forComponent("helia:car")}async import(e,r){await Mn(this.components.blockstore.putMany(Ze(e.blocks(),({cid:n,bytes:o})=>({cid:n,bytes:o})),r))}async*export(e,r){let n=Array.isArray(e)?e:[e],{writer:o,out:i}=Lt.create(n),s=i[Symbol.asyncIterator](),a=new AbortController;for(this._export(n,o,r).catch(c=>{this.log.error("error during streaming export - %e",c),a.abort(c)});;){let{done:c,value:f}=await et(s.next(),a.signal);if(a.signal.aborted)throw a.signal.reason;if(f!=null&&(yield f),c===!0)break}}async _export(e,r,n){let o=n?.traversal;for(let i of e){if(i.multihash.code===0)continue;let s=n?.exporter??(i.code===112?new Zt:new Kt),a=i,c=!1;if(o!=null){for await(let{cid:f,bytes:l}of o.traverse(a,this.components.blockstore,this.components.getCodec,n))if(this.log.trace("next CID on path to %c is %c",i,f),a=f,i.equals(f)&&(c=!0),c||n?.includeTraversalBlocks===!0){if(n?.blockFilter?.has(f.multihash.bytes)===!0)continue;n?.blockFilter?.add(f.multihash.bytes),await r.put({cid:f,bytes:l})}}for await(let{cid:f,bytes:l}of s.export(a,this.components.blockstore,this.components.getCodec,n))n?.blockFilter?.has(f.multihash.bytes)!==!0&&f.multihash.code!==0&&(c&&f.equals(a)||(n?.blockFilter?.add(f.multihash.bytes),await r.put({cid:f,bytes:l})))}await r.close()}};var No=class{async*export(e,r,n,o){let i=await k(r.get(e,o));yield ce({cid:e,bytes:i,codec:await n(e.code)})}};var er=class t extends Error{static name="InvalidTypeError";static code="ERR_INVALID_TYPE";name=t.name;code=t.code;constructor(e="Invalid type"){super(e)}};var ne;(function(t){let e;(function(a){a.Raw="Raw",a.Directory="Directory",a.File="File",a.Metadata="Metadata",a.Symlink="Symlink",a.HAMTShard="HAMTShard"})(e=t.DataType||(t.DataType={}));let r;(function(a){a[a.Raw=0]="Raw",a[a.Directory=1]="Directory",a[a.File=2]="File",a[a.Metadata=3]="Metadata",a[a.Symlink=4]="Symlink",a[a.HAMTShard=5]="HAMTShard"})(r||(r={})),(function(a){a.codec=()=>lo(r)})(e=t.DataType||(t.DataType={}));let n;t.codec=()=>(n==null&&(n=qt((a,c,f={})=>{if(f.lengthDelimited!==!1&&c.fork(),a.Type!=null&&(c.uint32(8),t.DataType.codec().encode(a.Type,c)),a.Data!=null&&(c.uint32(18),c.bytes(a.Data)),a.filesize!=null&&(c.uint32(24),c.uint64(a.filesize)),a.blocksizes!=null&&a.blocksizes.length>0)for(let l of a.blocksizes)c.uint32(32),c.uint64(l);a.hashType!=null&&(c.uint32(40),c.uint64(a.hashType)),a.fanout!=null&&(c.uint32(48),c.uint64(a.fanout)),a.mode!=null&&(c.uint32(56),c.uint32(a.mode)),a.mtime!=null&&(c.uint32(66),tr.codec().encode(a.mtime,c)),f.lengthDelimited!==!1&&c.ldelim()},(a,c,f={})=>{let l={blocksizes:[]},d=c==null?a.len:a.pos+c;for(;a.pos<d;){let g=a.uint32();switch(g>>>3){case 1:{l.Type=t.DataType.codec().decode(a);break}case 2:{l.Data=a.bytes();break}case 3:{l.filesize=a.uint64();break}case 4:{if(f.limits?.blocksizes!=null&&l.blocksizes.length===f.limits.blocksizes)throw new Vt('Decode error - repeated field "blocksizes" had too many elements');l.blocksizes.push(a.uint64());break}case 5:{l.hashType=a.uint64();break}case 6:{l.fanout=a.uint64();break}case 7:{l.mode=a.uint32();break}case 8:{l.mtime=tr.codec().decode(a,a.uint32(),{limits:f.limits?.mtime});break}default:{a.skipType(g&7);break}}}return l},function*(a,c,f,l={}){let d={blocksizes:0},g=c==null?a.len:a.pos+c;for(;a.pos<g;){let w=a.uint32();switch(w>>>3){case 1:{yield{field:`${f}.Type`,value:t.DataType.codec().decode(a)};break}case 2:{yield{field:`${f}.Data`,value:a.bytes()};break}case 3:{yield{field:`${f}.filesize`,value:a.uint64()};break}case 4:{if(l.limits?.blocksizes!=null&&d.blocksizes===l.limits.blocksizes)throw new Vt('Streaming decode error - repeated field "blocksizes" had too many elements');yield{field:`${f}.blocksizes[]`,index:d.blocksizes,value:a.uint64()},d.blocksizes++;break}case 5:{yield{field:`${f}.hashType`,value:a.uint64()};break}case 6:{yield{field:`${f}.fanout`,value:a.uint64()};break}case 7:{yield{field:`${f}.mode`,value:a.uint32()};break}case 8:{yield*tr.codec().stream(a,a.uint32(),`${f}.mtime`,{limits:l.limits?.mtime});break}default:{a.skipType(w&7);break}}}})),n);function o(a){return Ot(a,t.codec())}t.encode=o;function i(a,c){return Rt(a,t.codec(),c)}t.decode=i;function s(a,c){return Ht(a,t.codec(),c)}t.stream=s})(ne||(ne={}));var tr;(function(t){let e;t.codec=()=>(e==null&&(e=qt((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Seconds!=null&&(s.uint32(8),s.int64(i.Seconds)),i.FractionalNanoseconds!=null&&(s.uint32(21),s.fixed32(i.FractionalNanoseconds)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:{c.Seconds=i.int64();break}case 2:{c.FractionalNanoseconds=i.fixed32();break}default:{i.skipType(l&7);break}}}return c},function*(i,s,a,c={}){let f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();switch(l>>>3){case 1:{yield{field:`${a}.Seconds`,value:i.int64()};break}case 2:{yield{field:`${a}.FractionalNanoseconds`,value:i.fixed32()};break}default:{i.skipType(l&7);break}}}})),e);function r(i){return Ot(i,t.codec())}t.encode=r;function n(i,s){return Rt(i,t.codec(),s)}t.decode=n;function o(i,s){return Ht(i,t.codec(),s)}t.stream=o})(tr||(tr={}));var ya;(function(t){let e;t.codec=()=>(e==null&&(e=qt((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.MimeType!=null&&(s.uint32(10),s.string(i.MimeType)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();l>>>3===1?c.MimeType=i.string():i.skipType(l&7)}return c},function*(i,s,a,c={}){let f=s==null?i.len:i.pos+s;for(;i.pos<f;){let l=i.uint32();l>>>3===1?yield{field:`${a}.MimeType`,value:i.string()}:i.skipType(l&7)}})),e);function r(i){return Ot(i,t.codec())}t.encode=r;function n(i,s){return Rt(i,t.codec(),s)}t.decode=n;function o(i,s){return Ht(i,t.codec(),s)}t.stream=o})(ya||(ya={}));var ga={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},_l=["directory","hamt-sharded-directory"],wa=parseInt("0644",8),xa=parseInt("0755",8),$=class t{static unmarshal(e){let r=ne.decode(e),n=new t({type:ga[r.Type!=null?r.Type.toString():"File"],data:r.Data,blockSizes:r.blocksizes,mode:r.mode,mtime:r.mtime!=null?{secs:r.mtime.Seconds??0n,nsecs:r.mtime.FractionalNanoseconds}:void 0,fanout:r.fanout});return n._originalMode=r.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(e={type:"file"}){let{type:r,data:n,blockSizes:o,hashType:i,fanout:s,mtime:a,mode:c}=e;if(r!=null&&!Object.values(ga).includes(r))throw new er("Type: "+r+" is not valid");this.type=r??"file",this.data=n,this.hashType=i,this.fanout=s,this.blockSizes=o??[],this._originalMode=0,this.mode=c,this.mtime=a}set mode(e){e==null?this._mode=this.isDirectory()?xa:wa:this._mode=e&4095}get mode(){return this._mode}isDirectory(){return _l.includes(this.type)}addBlockSize(e){this.blockSizes.push(e)}removeBlockSize(e){this.blockSizes.splice(e,1)}fileSize(){if(this.isDirectory())return 0n;let e=0n;return this.blockSizes.forEach(r=>{e+=r}),this.data!=null&&(e+=BigInt(this.data.length)),e}marshal(){let e;switch(this.type){case"raw":e=ne.DataType.Raw;break;case"directory":e=ne.DataType.Directory;break;case"file":e=ne.DataType.File;break;case"metadata":e=ne.DataType.Metadata;break;case"symlink":e=ne.DataType.Symlink;break;case"hamt-sharded-directory":e=ne.DataType.HAMTShard;break;default:throw new er(`Type: ${e} is not valid`)}let r=this.data;(this.data==null||this.data.length===0)&&(r=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===wa&&!this.isDirectory()&&(n=void 0),n===xa&&this.isDirectory()&&(n=void 0));let o;return this.mtime!=null&&(o={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),ne.encode({Type:e,Data:r,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:o})}};var rr=class extends Error{static code="ERR_NOT_UNIXFS";static message="Not a UnixFS node";static name="NotUnixFSError";code="ERR_NOT_UNIXFS";message="Not a UnixFS node";name="NotUnixFSError"},Jr=class extends Error{static name="NotDescendantError";name="NotDescendantError"},ft=class extends Error{static name="InvalidTraversalError";name="InvalidTraversalError"};function Al(t){return t.cid.code===85}function Tl(t){return t.cid.code===112}function Sl(t){if(Al(t))return!0;if(Tl(t)&&t.value.Data!=null){let e=$.unmarshal(t.value.Data);return e.type==="file"||e.type==="raw"}else throw new rr("Encountered non raw/dag-pb CID in UnixFS DAG")}var Zt=class{options;constructor(e){this.options=e}async*export(e,r,n,o){if(e.code!==112&&e.code!==85)throw new rr("Target CID was not UnixFS - use the SubGraphExporter to export arbitrary graphs");let i=Ue()({blockstore:r,getCodec:n}),s=this.options?.offset??0,a=this.options?.length??1/0,c=this.options?.listingOnly??!1;if(s<0)throw new Pe("Offset cannot be negative");if(a<0)throw new Pe("Length cannot be negative");let f,l=new AbortController,d=Xs([l.signal,o?.signal]);l.signal;function g(w,m){if(f==null&&(f=Sl(m)),!f){let D=m.value.Links.find(q=>q.Hash.equals(w)),H=$.unmarshal(m.value.Data??new Uint8Array);return H.type==="directory"?!c:H.type==="hamt-sharded-directory"&&c?D?.Name?.length===2:!0}let x=m.value.Links.findIndex(D=>D.Hash.equals(w)),b=$.unmarshal(m.value.Data??new Uint8Array),A=s,N=A+a,C=Number([...b.blockSizes].slice(0,x).reduce((D,H)=>D+H,0n)),P=C+Number(b.blockSizes[x]);return A>=C&&A<P||N>=C&&N<P||A<=C&&N>=P}try{for await(let w of i.walk(e,{...o,includeChild:g,signal:d}))yield w.block}finally{l.abort(),d.clear()}}};function ba(t){return t!=null&&t?.asCID===t}var Do=class{haystack;needle;options;walker;constructor(...e){if(ba(e[0]))ba(e[1])?(this.haystack=e[0],this.needle=e[1],this.options=e[2]):(this.needle=e[0],this.options=e[1]);else throw new Pe("needle must be specified");this.walker=this.options?.walker}async*traverse(e,r,n,o){let i=this.haystack??e,s,a={blockstore:r,getCodec:n};this.walker!=null?s=this.walker(a):this.options?.strategy==="breadth-first"?s=Re()(a):s=Ue()(a);for await(let c of s.walk(i,o))if(c.block.cid.equals(this.needle)){for(let f of c.path){let l=await k(r.get(f,o));yield ce({cid:f,bytes:l,codec:await n(f.code)})}return}throw new ft(`${this.needle} was not a child of ${i}`)}};var Lo=class{path;constructor(e){this.path=e}async*traverse(e,r,n,o){if(!this.path.some(s=>s.equals(e)))throw new ft(`CIDPath traversal must include ${e}`);let i;for(let s of this.path){if(i!=null){let f=!1;for(let[,l]of i.links())if(l.equals(s)){f=!0;break}if(!f)throw new Jr(`${s} is not a child of ${i.cid}`)}let a=await k(r.get(s,o)),c=ce({cid:s,bytes:a,codec:await n(s.code)});i=c,yield c}}};var lt=class t extends Error{static name="BadPathError";static code="ERR_BAD_PATH";name=t.name;code=t.code;constructor(e="Bad path"){super(e)}},Q=class t extends Error{static name="NotFoundError";static code="ERR_NOT_FOUND";name=t.name;code=t.code;constructor(e="Not found"){super(e)}},ht=class t extends Error{static name="NoResolverError";static code="ERR_NO_RESOLVER";name=t.name;code=t.code;constructor(e="No resolver"){super(e)}},T=class t extends Error{static name="NotUnixFSError";static code="ERR_NOT_UNIXFS";name=t.name;code=t.code;constructor(e="Not UnixFS"){super(e)}},Yr=class t extends Error{static name="OverReadError";static code="ERR_OVER_READ";name=t.name;code=t.code;constructor(e="Over read"){super(e)}},Qr=class t extends Error{static name="UnderReadError";static code="ERR_UNDER_READ";name=t.name;code=t.code;constructor(e="Under read"){super(e)}},pe=class t extends Error{static name="InvalidParametersError";static code="ERR_INVALID_PARAMS";name=t.name;code=t.code;constructor(e="Invalid parameters"){super(e)}};function dt(t){return t==null?!1:E.asCID(t)===t}function pt(t,e){let r,n=0,o="";for(;n<e.length;){let i=e[n];if(n++,!Object.hasOwnProperty.call(t,i))throw new lt(`Object did not have key "${i}"`);if(o+=`/${i}`,r=t[i],t=r,dt(r))break}return{value:r,rest:e.slice(n),path:o.substring(1)}}async function*Po(t,e,r,n){let o=await k(r.get(t,n)),i=Be(o),s=pt(i,e);yield{cid:dt(s.value)?s.value:t,name:s.path,rest:s.rest}}async function*Ea(t,e,r,n){let o=await k(r.get(t,n)),i=Vr(o),s=pt(i,e);yield{cid:dt(s.value)?s.value:t,name:s.path,rest:s.rest}}function ke(t,e){let r=t.lo+e.lo>>>0,n=t.hi+e.hi+(r<t.lo?1:0)>>>0;return{lo:r,hi:n}}function Cl(t,e){return t+e>>>0}function Z(t,e){let r=t.lo&65535,n=t.lo>>>16,o=e.lo&65535,i=e.lo>>>16,s=r*o,a=r*i,c=n*o,f=n*i,l=(s>>>16)+(a&65535)+(c&65535)>>>0,d=(l<<16|s&65535)>>>0,g=f+(a>>>16)+(c>>>16)+(l>>>16),w=Math.imul(t.lo,e.hi),m=Math.imul(t.hi,e.lo),x=g+w+m>>>0;return{lo:d,hi:x}}function Fe(t,e){return Math.imul(t,e)>>>0}function mt(t,e){if(e===0)return t;if(e===32)return{lo:t.hi,hi:t.lo};if(e<32){let o=(t.lo<<e|t.hi>>>32-e)>>>0,i=(t.hi<<e|t.lo>>>32-e)>>>0;return{lo:o,hi:i}}e-=32;let r=(t.hi<<e|t.lo>>>32-e)>>>0,n=(t.lo<<e|t.hi>>>32-e)>>>0;return{lo:r,hi:n}}function S(t,e){return{lo:(t.lo^e.lo)>>>0,hi:(t.hi^e.hi)>>>0}}function Uo(t,e){if(e===0)return t;if(e<32){let r=(t.lo>>>e|t.hi<<32-e)>>>0,n=t.hi>>>e;return{lo:r,hi:n}}return{lo:t.hi>>>e-32,hi:0}}function _(t,e){return{lo:t>>>0,hi:e>>>0}}function Ro(t,e){return(t<<e|t>>>32-e)>>>0}function va(t,e){let r=e*8,n=t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24,o=t[r+4]|t[r+5]<<8|t[r+6]<<16|t[r+7]<<24;return{lo:n>>>0,hi:o>>>0}}function Bl(t,e){let r=e*4;return(t[r]|t[r+1]<<8|t[r+2]<<16|t[r+3]<<24)>>>0}function ka(t){return t=S(t,Uo(t,33)),t=Z(t,_(3981806797,4283543511)),t=S(t,Uo(t,33)),t=Z(t,_(444984403,3301882366)),t=S(t,Uo(t,33)),t}function Nl(t){return t^=t>>>16,t=Fe(t,2246822507),t^=t>>>13,t=Fe(t,3266489909),t^=t>>>16,t}function Fo(t,e=0){let r=_(e,0),n=_(e,0),o=t.length,i=Math.floor(o/16),s=_(289559509,2277735313),a=_(658871167,1291169091);for(let g=0;g<i;g++){let w=va(t,g*2),m=va(t,g*2+1);w=Z(w,s),w=mt(w,31),w=Z(w,a),r=S(r,w),r=mt(r,27),r=ke(r,n),r=ke(Z(r,_(5,0)),_(1390208809,0)),m=Z(m,a),m=mt(m,33),m=Z(m,s),n=S(n,m),n=mt(n,31),n=ke(n,r),n=ke(Z(n,_(5,0)),_(944331445,0))}let c=_(0,0),f=_(0,0),l=t.slice(i*16);switch(l.length){case 15:f=S(f,_(0,l[14]<<16));case 14:f=S(f,_(0,l[13]<<8));case 13:f=S(f,_(0,l[12]));case 12:f=S(f,_(l[11]<<24,0));case 11:f=S(f,_(l[10]<<16,0));case 10:f=S(f,_(l[9]<<8,0));case 9:f=S(f,_(l[8],0)),f=Z(f,a),f=mt(f,33),f=Z(f,s),n=S(n,f);case 8:c=S(c,_(0,l[7]<<24));case 7:c=S(c,_(0,l[6]<<16));case 6:c=S(c,_(0,l[5]<<8));case 5:c=S(c,_(0,l[4]));case 4:c=S(c,_(l[3]<<24,0));case 3:c=S(c,_(l[2]<<16,0));case 2:c=S(c,_(l[1]<<8,0));case 1:c=S(c,_(l[0],0)),c=Z(c,s),c=mt(c,31),c=Z(c,a),r=S(r,c)}let d=_(o,0);return r=S(r,d),n=S(n,d),r=ke(r,n),n=ke(n,r),r=ka(r),n=ka(n),r=ke(r,n),n=ke(n,r),new Uint8Array([r.hi>>>24&255,r.hi>>>16&255,r.hi>>>8&255,r.hi&255,r.lo>>>24&255,r.lo>>>16&255,r.lo>>>8&255,r.lo&255,n.hi>>>24&255,n.hi>>>16&255,n.hi>>>8&255,n.hi&255,n.lo>>>24&255,n.lo>>>16&255,n.lo>>>8&255,n.lo&255])}function _a(t,e=0){let r=e>>>0,n=t.length,o=Math.floor(n/4),i=3432918353,s=461845907;for(let f=0;f<o;f++){let l=Bl(t,f);l=Fe(l,i),l=Ro(l,15),l=Fe(l,s),r^=l,r=Ro(r,13),r=Cl(Fe(r,5),3864292196)}let a=t.slice(o*4),c=0;switch(a.length){case 3:c^=a[2]<<16;case 2:c^=a[1]<<8;case 1:c^=a[0],c=Fe(c,i),c=Ro(c,15),c=Fe(c,s),r^=c}return r^=n,r=Nl(r),r}function Ll(t){let e=new Array(4);for(let r=0;r<4;r++)e[r]=t&255,t=t>>8;return new Uint8Array(e)}var l0=De({name:"murmur3-32",code:35,encode:t=>Ll(_a(t))}),Ia=De({name:"murmur3-128",code:34,encode:t=>Fo(t)}),h0=De({name:"murmur3-x64-64",code:34,encode:t=>Fo(t).subarray(0,8)});var Ca=$e(Sa(),1);var ze=class t{_options;_popCount;_parent;_posAtParent;_children;key;constructor(e,r,n=0){this._options=e,this._popCount=0,this._parent=r,this._posAtParent=n,this._children=new Ca.default,this.key=null}async put(e,r){let n=await this._findNewBucketAndPos(e);n.bucket._putAt(n,e,r)}async get(e){let r=await this._findChild(e);if(r!=null)return r.value}async del(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);n!=null&&n.key===e&&r.bucket._delAt(r.pos)}leafCount(){return this._children.compactArray().reduce((r,n)=>n instanceof t?r+n.leafCount():r+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let e=this._children.compactArray();for(let r of e)r instanceof t?yield*r.eachLeafSeries():yield r}serialize(e,r){let n=[];return r(this._children.reduce((o,i,s)=>(i!=null&&(i instanceof t?o.push(i.serialize(e,r)):o.push(e(i,s))),o),n))}async asyncTransform(e,r){return Ba(this,e,r)}toJSON(){return this.serialize(zl,$l)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(e){let r=await this._findPlace(e),n=r.bucket._at(r.pos);if(!(n instanceof t)&&n!=null&&n.key===e)return n}async _findPlace(e){let r=this._options.hash(typeof e=="string"?Br(e):e),n=await r.take(this._options.bits),o=this._children.get(n);return o instanceof t?o._findPlace(r):{bucket:this,pos:n,hash:r,existingChild:o}}async _findNewBucketAndPos(e){let r=await this._findPlace(e);if(r.existingChild!=null&&r.existingChild.key!==e){let n=new t(this._options,r.bucket,r.pos);r.bucket._putObjectAt(r.pos,n);let o=await n._findPlace(r.existingChild.hash);return o.bucket._putAt(o,r.existingChild.key,r.existingChild.value),n._findNewBucketAndPos(r.hash)}return r}_putAt(e,r,n){this._putObjectAt(e.pos,{key:r,value:n,hash:e.hash})}_putObjectAt(e,r){this._children.get(e)==null&&this._popCount++,this._children.set(e,r)}_delAt(e){if(e===-1)throw new Error("Invalid position");this._children.get(e)!=null&&this._popCount--,this._children.unset(e),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let e=this._children.find(Fl);if(e!=null&&!(e instanceof t)){let r=e.hash;r.untake(this._options.bits);let n={pos:this._posAtParent,hash:r,bucket:this._parent};this._parent._putAt(n,e.key,e.value)}}else this._parent._delAt(this._posAtParent)}_at(e){return this._children.get(e)}};function Fl(t){return!!t}function zl(t,e){return t.key}function $l(t){return t}async function Ba(t,e,r){let n=[];for(let o of t._children.compactArray())if(o instanceof ze)await Ba(o,e,r);else{let i=await e(o);n.push({bitField:t._children.bitField(),children:i})}return r(n)}var Ml=[255,254,252,248,240,224,192,128],Ol=[1,3,7,15,31,63,127,255],Xr=class{_value;_currentBytePos;_currentBitPos;constructor(e){this._value=e,this._currentBytePos=e.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(e){let r=e,n=0;for(;r>0&&this._haveBits();){let o=this._value[this._currentBytePos],i=this._currentBitPos+1,s=Math.min(i,r),a=Hl(o,i-s,s);n=(n<<s)+a,r-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(e){for(this._currentBitPos+=e;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function Hl(t,e,r){let n=ql(e,r);return(t&n)>>>e}function ql(t,e){return Ml[t]&Ol[Math.min(e+t-1,7)]}function Na(t){function e(r){return r instanceof Kr?r:new Kr(r,t)}return e}var Kr=class{_value;_hashFn;_depth;_availableBits;_currentBufferIndex;_buffers;constructor(e,r){if(!(e instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=e,this._hashFn=r,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(e){let r=e;for(;this._availableBits<r;)await this._produceMoreBits();let n=0;for(;r>0;){let o=this._buffers[this._currentBufferIndex],i=Math.min(o.availableBits(),r),s=o.take(i);n=(n<<i)+s,r-=i,this._availableBits-=i,o.availableBits()===0&&this._currentBufferIndex++}return n}untake(e){let r=e;for(;r>0;){let n=this._buffers[this._currentBufferIndex],o=Math.min(n.totalBits()-n.availableBits(),r);n.untake(o),r-=o,this._availableBits+=o,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let e=this._depth>0?jt([this._value,Uint8Array.from([this._depth])]):this._value,r=await this._hashFn(e),n=new Xr(r);this._buffers.push(n),this._availableBits+=n.availableBits()}};function Da(t){if(t==null||t.hashFn==null)throw new Error("please define an options.hashFn");let e={bits:t.bits??8,hash:Na(t.hashFn)};return new ze(e)}var Vl=async function(t){return(await Ia.encode(t)).slice(0,8).reverse()},jl=async(t,e,r)=>{let n=(e.tableSize()-1).toString(16).length;await Promise.all(t.map(async o=>{if(o.Name==null)throw new Error("Unexpected Link without a Name");if(o.Name.length===n){let i=parseInt(o.Name,16);e._putObjectAt(i,new ze({hash:r._options.hash,bits:r._options.bits},e,i));return}await r.put(o.Name.substring(2),!0)}))},La=(t,e)=>t.toString(16).toUpperCase().padStart(e,"0").substring(0,e),Gl=t=>{let e=t.bucket,r=[];for(;e._parent!=null;)r.push(e),e=e._parent;return r.push(e),r.reverse()};async function*zo(t,e,r,n,o,i){if(o==null){if(t.Data==null)throw new T("No data in PBNode");let g;try{g=$.unmarshal(t.Data)}catch(m){throw new T(m.message)}if(g.type!=="hamt-sharded-directory")throw new T("Not a HAMT");if(g.fanout==null)throw new T("Missing fanout");let w=Da({hashFn:Vl,bits:Math.log2(Number(g.fanout))});o={rootBucket:w,hamtDepth:1,lastBucket:w}}let s=(o.lastBucket.tableSize()-1).toString(16).length;await jl(t.Links,o.lastBucket,o.rootBucket);let a=await o.rootBucket._findNewBucketAndPos(e),c=La(a.pos,s),f=Gl(a);f.length>o.hamtDepth&&(o.lastBucket=f[o.hamtDepth],c=La(o.lastBucket._posAtParent,s));let l=t.Links.find(g=>{if(g.Name==null)return!1;let w=g.Name.substring(0,s),m=g.Name.substring(s);return!(w!==c||m!==""&&m!==e)});if(l==null)return;if(l.Name!=null&&l.Name.substring(s)===e){yield{cid:l.Hash,name:l.Name.substring(s),rest:r};return}o.hamtDepth++;let d=await k(n.get(l.Hash,i));t=ue(d),i?.yieldSubShards===!0&&(yield{cid:l.Hash,name:l.Name??"",rest:[e,...r]}),yield*zo(t,e,r,n,o,i)}async function*Pa(t,e,r,n){let o=await k(r.get(t,n)),i;try{i=ue(o)}catch(a){throw new T(a.message)}if(i.Data==null)throw new T("no data in PBNode");let s;try{s=$.unmarshal(i.Data)}catch(a){throw new T(a.message)}if(s.type==="directory"||s.type==="hamt-sharded-directory"&&n?.translateHAMTPath===!1){let a=i.Links.find(c=>c.Name===e[0]);if(a==null)throw new Q(`No link "${e[0]}" found under ${t}`);yield{cid:a.Hash,name:e[0],rest:e.slice(1)}}else if(s.type==="hamt-sharded-directory"){let a=!1;for await(let c of zo(i,e[0],e.slice(1),r,void 0,n))c.name===e[0]&&(a=!0),yield c;if(!a)throw new Q(`No link "${e[0]}" found under ${t}`)}}async function*Ua(t,e,r,n){if(e.length!==0)throw new lt(`Cannot load path /${e.join("/")} from identity block`)}async function*Ra(t,e,r,n){let o=await k(r.get(t,n)),i=Sr(o),s=pt(i,e);yield{cid:t,name:s.path,rest:s.rest}}async function*Fa(t,e,r,n){if(e.length!==0)throw new Q(`Cannot load path /${e.join("/")} from raw block`)}var Jl={[ut]:Pa,[tt]:Fa,[Er]:Po,81:Po,[qr]:Ea,[zt.code]:Ua,[Tr]:Ra};async function*Zr(t,e,r={}){for(t=t.toString(),t.startsWith("/ipfs/")&&(t=t.substring(6));t.endsWith("/");)t=t.substring(0,t.length-1);let[n,...o]=t.split(/(?<!\\)\//g).filter(Boolean),i=E.parse(n),s=[i],a=`${i}`;for(yield{cid:i,name:a,path:a,roots:s,remainder:o};o.length>0;){let c=Jl[i.code];if(c==null)throw new ht(`No resolver for code ${i.code}`);let f=!1;for await(let l of c(i,o,e,r)){if(i=l.cid,f=!s[s.length-1].equals(i),o=l.rest,!f)break;s=[...s,l.cid],a=`${a}/${l.name}`,yield{cid:l.cid,name:l.name,path:a,roots:s,remainder:l.rest}}if(!f)break}if(r?.signal?.throwIfAborted(),o.length!==0)throw new Q(`Could not resolve path /${o.join("/")} under ${t}`)}function Yl(t){return t[Symbol.asyncIterator]!=null}function Ql(t){if(Yl(t))return(async()=>{let r;for await(let n of t)r=n;return r})();let e;for(let r of t)e=r;return e}var za=Ql;async function $o(t,e,r,n,o){let i=await k(n.get(t,o)),s=Be(i);return{type:"object",cid:t,name:e,path:r,object:s,node:i,size:BigInt(i.byteLength)}}async function $a(t,e,r,n,o){let i=await k(n.get(t,o)),s=Vr(i);return{type:"object",cid:t,name:e,path:r,object:s,node:i,size:BigInt(i.byteLength)}}function nr(t,e,r,n){let o=BigInt(t.length),i=BigInt(e+o);return r>=i||n<e?new Uint8Array(0):(n>=e&&n<i&&(t=t.subarray(0,Number(n-e))),r>=e&&r<i&&(t=t.subarray(Number(r-e))),t)}var en=(t,e=0,r=t)=>{let n=BigInt(t),o=BigInt(e??0),i=BigInt(r);if(i!==n&&(i=o+i),i>n&&(i=n),o<0n)throw new pe("Offset must be greater than or equal to 0");if(o>n)throw new pe("Offset must be less than the file size");if(i<0n)throw new pe("Length must be greater than or equal to 0");if(i>n)throw new pe("Length must be less than the file size");return{start:o,end:i}};function tn(t,e){async function*r(n={}){let{start:o,end:i}=en(t.length,n.offset,n.length),s=nr(t,0n,o,i);n.onProgress?.(new R(e,{bytesRead:BigInt(s.byteLength),totalBytes:i-o,fileSize:BigInt(t.byteLength)})),yield s}return r}async function Ma(t,e,r,n,o){let i=Ke(t.multihash.bytes);return{type:"identity",cid:t,name:e,path:r,content:tn(i.digest,"unixfs:exporter:progress:identity"),size:BigInt(i.bytes.byteLength),node:i.bytes}}async function Oa(t,e,r,n,o){let i=await k(n.get(t,o)),s=Sr(i);return{type:"object",cid:t,name:e,path:r,object:s,size:BigInt(i.byteLength),node:i}}async function Ha(t,e,r,n,o){let i=await k(n.get(t,o));return{type:"raw",cid:t,name:e,path:r,content:tn(i,"unixfs:exporter:progress:raw"),size:BigInt(i.length),node:i}}function qa(t,e,r,n){async function*o(i={}){let s=i.offset??0,a=i.length??e.Links.length,c=e.Links.slice(s,a);i.onProgress?.(new R("unixfs:exporter:walk:directory",{cid:t})),yield*c.map(f=>({cid:f.Hash,name:f.Name??"",path:`${n}/${f.Name??""}`,size:BigInt(f.Tsize??0)}))}return o}var rn=globalThis.CustomEvent??Event;async function*or(t,e={}){let r=e.concurrency??1/0;r<1&&(r=1/0);let n=e.ordered??!1,o=new EventTarget,i=[],s=z(),a=z(),c=!1,f,l=!1;o.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of t){if(i.length===r&&(s=z(),await s.promise),l)break;let x={done:!1};i.push(x),m().then(b=>{x.done=!0,x.ok=!0,x.value=b,o.dispatchEvent(new rn("task-complete"))},b=>{x.done=!0,x.err=b,o.dispatchEvent(new rn("task-complete"))})}c=!0,o.dispatchEvent(new rn("task-complete"))}catch(m){f=m,o.dispatchEvent(new rn("task-complete"))}});function d(){return n?i[0]?.done:!!i.find(m=>m.done)}function*g(){for(;i.length>0&&i[0].done;){let m=i[0];if(i.shift(),m.ok)yield m.value;else throw l=!0,s.resolve(),m.err;s.resolve()}}function*w(){for(;d();)for(let m=0;m<i.length;m++)if(i[m].done){let x=i[m];if(i.splice(m,1),m--,x.ok)yield x.value;else throw l=!0,s.resolve(),x.err;s.resolve()}}for(;;){if(d()||(a=z(),await a.promise),f!=null||(n?yield*g():yield*w(),f!=null))throw f;if(c&&i.length===0)break}}async function Va(t,e,r,n,o,i,s){if(e instanceof Uint8Array){let f=nr(e,n,o,i);r.push(f);return}if(e.Data==null)throw new T("no data in PBNode");let a;try{a=$.unmarshal(e.Data)}catch(f){throw new T(f.message)}if(a.data!=null){let f=a.data,l=nr(f,n,o,i);r.push(l),n+=BigInt(l.byteLength)}let c=[];if(e.Links.length!==a.blockSizes.length)throw new T("Inconsistent block sizes and dag links");for(let f=0;f<e.Links.length;f++){let l=e.Links[f],d=n,g=d+a.blockSizes[f];if((o>=d&&o<g||i>=d&&i<=g||o<d&&i>g)&&c.push({link:l,blockStart:n}),n=g,n>i)break}await Or(c,f=>Ze(f,l=>async()=>{let d=await k(t.get(l.link.Hash,s));return{...l,block:d}}),f=>or(f,{ordered:!0,concurrency:s.blockReadConcurrency}),async f=>{for await(let{link:l,block:d,blockStart:g}of f){let w;switch(l.Hash.code){case ut:w=ue(d);break;case tt:w=d;break;default:r.end(new T(`Unsupported codec: ${l.Hash.code}`));return}let m=new Jt({concurrency:1});m.on("error",x=>{r.end(x)}),m.add(async()=>{s.onProgress?.(new R("unixfs:exporter:walk:file",{cid:l.Hash})),await Va(t,w,r,g,o,i,s)}),await m.onIdle()}}),n>=i&&r.end()}function Mo(t,e,r,n,o){async function*i(s={}){let a=r.fileSize();if(a===void 0)throw new Error("File was a directory");let{start:c,end:f}=en(a,s.offset,s.length);if(f===0n)return;let l=0n,d=f-c,g=it();s.onProgress?.(new R("unixfs:exporter:walk:file",{cid:t})),Va(o,e,g,0n,c,f,s).catch(w=>{g.end(w)});for await(let w of g)if(w!=null){if(l+=BigInt(w.byteLength),l>d)throw g.end(),new Yr("Read too many bytes - the file size reported by the UnixFS data in the root node may be incorrect");l===d&&g.end(),s.onProgress?.(new R("unixfs:exporter:progress:unixfs:file",{bytesRead:l,totalBytes:d,fileSize:a})),yield w}if(l<d)throw new Qr("Traversed entire DAG but did not read enough bytes")}return i}async function*ja(t,e,r,n){let o=t.Links;if(t.Data==null)throw new T("no data in PBNode");let i;try{i=$.unmarshal(t.Data)}catch(c){throw new T(c.message)}if(i.fanout==null)throw new T("missing fanout");let s=(i.fanout-1n).toString(16).length,a=Or(o,c=>Ze(c,f=>async()=>{let l=f.Name!=null?f.Name.substring(s):null;if(l!=null&&l!=="")return{entries:[{cid:f.Hash,name:l,path:`${e}/${l}`,size:BigInt(f.Tsize??0)}]};{let d=await k(r.get(f.Hash,n));return t=ue(d),n.onProgress?.(new R("unixfs:exporter:walk:hamt-sharded-directory",{cid:f.Hash})),{entries:ja(t,e,r,n)}}}),c=>or(c,{ordered:!0,concurrency:n.blockReadConcurrency}));for await(let{entries:c}of a)yield*c}function Ga(t,e,r,n,o){function i(s={}){return s.onProgress?.(new R("unixfs:exporter:walk:hamt-sharded-directory",{cid:t})),ja(e,n,o,s)}return i}var Xl={raw:Mo,file:Mo,directory:qa,"hamt-sharded-directory":Ga,metadata:(t,e,r,n)=>()=>[],symlink:(t,e,r,n)=>()=>[]};async function Wa(t,e,r,n,o){let i=await k(n.get(t,o)),s;try{s=ue(i)}catch(f){throw new T(f.message)}if(s.Data==null)throw new T("no data in PBNode");let a;try{a=$.unmarshal(s.Data)}catch(f){throw new T(f.message)}let c=Xl[a.type](t,s,a,r,n);if(c==null)throw new Q("could not find content exporter");return a.isDirectory()?{type:"directory",cid:t,name:e,path:r,entries:c,unixfs:a,node:s,size:BigInt(i.byteLength)}:{type:"file",cid:t,name:e,path:r,content:c,unixfs:a,node:s,size:a.fileSize()}}var Kl={[ut]:Wa,[tt]:Ha,[Er]:$o,81:$o,[qr]:$a,[zt.code]:Ma,[Tr]:Oa};async function Ja(t,e,r={}){let n,o;if(t instanceof String||typeof t=="string"){let s=await za(Zr(t,e,r));if(s==null)throw new Q(`Could not walk path to ${t}`);n=s.cid,o=s.name,t=s.path}else if(E.asCID(t)===t||t instanceof E)n=t,o=t=n.toString();else throw new pe("Path must be string or CID");let i=Kl[n.code];if(i==null)throw new ht(`No resolver for code ${n.code}`);return i(n,o,t,e,r)}var Oo=class{root;path;constructor(...e){let r=e[0],n=e[1];if(typeof r=="string")n=r,r=void 0;else if(e.length<2)throw new Error("path or CID and path must be specified");n.startsWith("/")||(n=`/${n}`),this.root=r,this.path=n}async*traverse(e,r,n,o){for await(let i of Zr(`${this.root??e}${this.path}`,r,o)){let s=await Ja(i.cid,r,o);yield ce({cid:s.cid,bytes:s.node instanceof Uint8Array?s.node:da(s.node),codec:await n(i.cid.code)})}}};function Zl(t){return new Wr(t)}return ec(eh);})();
|
|
3
3
|
return HeliaCar}));
|
|
4
4
|
//# sourceMappingURL=index.min.js.map
|