@helia/car 3.2.0 → 3.2.1-2f88fc8
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/README.md +4 -3
- package/dist/index.min.js +1 -1
- package/dist/src/index.d.ts +9 -12
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -10
- package/dist/src/index.js.map +1 -1
- package/package.json +9 -8
- package/src/index.ts +15 -16
- package/dist/typedoc-urls.json +0 -8
package/README.md
CHANGED
|
@@ -46,13 +46,13 @@ import { CarWriter } from '@ipld/car'
|
|
|
46
46
|
import { Readable } from 'node:stream'
|
|
47
47
|
import nodeFs from 'node:fs'
|
|
48
48
|
|
|
49
|
-
const helia = createHelia({
|
|
49
|
+
const helia = await createHelia({
|
|
50
50
|
// ... helia config
|
|
51
51
|
})
|
|
52
52
|
const fs = unixfs(helia)
|
|
53
53
|
|
|
54
54
|
// add some UnixFS data
|
|
55
|
-
const cid = await fs.addBytes(
|
|
55
|
+
const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
56
56
|
|
|
57
57
|
// export it as a Car
|
|
58
58
|
const c = car(helia)
|
|
@@ -75,7 +75,7 @@ import { CarReader } from '@ipld/car'
|
|
|
75
75
|
import { Readable } from 'node:stream'
|
|
76
76
|
import nodeFs from 'node:fs'
|
|
77
77
|
|
|
78
|
-
const helia = createHelia({
|
|
78
|
+
const helia = await createHelia({
|
|
79
79
|
// ... helia config
|
|
80
80
|
})
|
|
81
81
|
|
|
@@ -83,6 +83,7 @@ const helia = createHelia({
|
|
|
83
83
|
const inStream = nodeFs.createReadStream('example.car')
|
|
84
84
|
const reader = await CarReader.fromIterable(inStream)
|
|
85
85
|
|
|
86
|
+
const c = car(helia)
|
|
86
87
|
await c.import(reader)
|
|
87
88
|
```
|
|
88
89
|
|
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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 xn=Object.create;var Ie=Object.defineProperty;var bn=Object.getOwnPropertyDescriptor;var vn=Object.getOwnPropertyNames;var En=Object.getPrototypeOf,_n=Object.prototype.hasOwnProperty;var ae=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tn=(e,t)=>{for(var r in t)Ie(e,r,{get:t[r],enumerable:!0})},Bt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of vn(t))!_n.call(e,o)&&o!==r&&Ie(e,o,{get:()=>t[o],enumerable:!(n=bn(t,o))||n.enumerable});return e};var Ce=(e,t,r)=>(r=e!=null?xn(En(e)):{},Bt(t||!e||!e.__esModule?Ie(r,"default",{value:e,enumerable:!0}):r,e)),kn=e=>Bt(Ie({},"__esModule",{value:!0}),e);var Zr=ae((Ps,Xr)=>{Xr.exports=pt;var Qr=128,zo=127,$o=~zo,Mo=Math.pow(2,31);function pt(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw pt.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=Mo;)t[r++]=e&255|Qr,e/=128;for(;e&$o;)t[r++]=e&255|Qr,e>>>=7;return t[r]=e|0,pt.bytes=r-n+1,t}});var tn=ae((Fs,en)=>{en.exports=yt;var Lo=128,jr=127;function yt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u||o>49)throw yt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&jr)<<o:(a&jr)*Math.pow(2,o),o+=7}while(a>=Lo);return yt.bytes=i-n,r}});var nn=ae((Hs,rn)=>{var Vo=Math.pow(2,7),Po=Math.pow(2,14),Fo=Math.pow(2,21),Ho=Math.pow(2,28),qo=Math.pow(2,35),Go=Math.pow(2,42),Wo=Math.pow(2,49),Yo=Math.pow(2,56),Ko=Math.pow(2,63);rn.exports=function(e){return e<Vo?1:e<Po?2:e<Fo?3:e<Ho?4:e<qo?5:e<Go?6:e<Wo?7:e<Yo?8:e<Ko?9:10}});var Fe=ae((qs,on)=>{on.exports={encode:Zr(),decode:tn(),encodingLength:nn()}});var mn=ae((Ya,kt)=>{"use strict";var ci=Object.prototype.hasOwnProperty,E="~";function Ee(){}Object.create&&(Ee.prototype=Object.create(null),new Ee().__proto__||(E=!1));function ui(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function yn(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new ui(r,n||e,o),a=E?E+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],i]:e._events[a].push(i):(e._events[a]=i,e._eventsCount++),e}function Ge(e,t){--e._eventsCount===0?e._events=new Ee:delete e._events[t]}function b(){this._events=new Ee,this._eventsCount=0}b.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)ci.call(r,n)&&t.push(E?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};b.prototype.listeners=function(t){var r=E?E+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,a=new Array(i);o<i;o++)a[o]=n[o].fn;return a};b.prototype.listenerCount=function(t){var r=E?E+t:t,n=this._events[r];return n?n.fn?1:n.length:0};b.prototype.emit=function(t,r,n,o,i,a){var u=E?E+t:t;if(!this._events[u])return!1;var c=this._events[u],p=arguments.length,l,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),p){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,a),!0}for(m=1,l=new Array(p-1);m<p;m++)l[m-1]=arguments[m];c.fn.apply(c.context,l)}else{var v=c.length,K;for(m=0;m<v;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),p){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,r);break;case 3:c[m].fn.call(c[m].context,r,n);break;case 4:c[m].fn.call(c[m].context,r,n,o);break;default:if(!l)for(K=1,l=new Array(p-1);K<p;K++)l[K-1]=arguments[K];c[m].fn.apply(c[m].context,l)}}return!0};b.prototype.on=function(t,r,n){return yn(this,t,r,n,!1)};b.prototype.once=function(t,r,n){return yn(this,t,r,n,!0)};b.prototype.removeListener=function(t,r,n,o){var i=E?E+t:t;if(!this._events[i])return this;if(!r)return Ge(this,i),this;var a=this._events[i];if(a.fn)a.fn===r&&(!o||a.once)&&(!n||a.context===n)&&Ge(this,i);else{for(var u=0,c=[],p=a.length;u<p;u++)(a[u].fn!==r||o&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[i]=c.length===1?c[0]:c:Ge(this,i)}return this};b.prototype.removeAllListeners=function(t){var r;return t?(r=E?E+t:t,this._events[r]&&Ge(this,r)):(this._events=new Ee,this._eventsCount=0),this};b.prototype.off=b.prototype.removeListener;b.prototype.addListener=b.prototype.on;b.prefixed=E;b.EventEmitter=b;typeof kt<"u"&&(kt.exports=b)});var li={};Tn(li,{car:()=>di});var An=["string","number","bigint","symbol"],In=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Nt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(An.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Cn(e))return"Buffer";let r=Sn(e);return r||"Object"}function Cn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Sn(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(In.includes(t))return t}var s=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var d=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var X=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Un=new TextDecoder,Bn=new TextEncoder;function Se(e){return X&&globalThis.Buffer.isBuffer(e)}function We(e){return e instanceof Uint8Array?Se(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var zt=X?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Dt(e,t,r):(e,t,r)=>r-t>64?Un.decode(e.subarray(t,r)):Dt(e,t,r),$t=X?e=>e.length>64?globalThis.Buffer.from(e):Ot(e):e=>e.length>64?Bn.encode(e):Ot(e),L=e=>Uint8Array.from(e),Z=X?(e,t,r)=>Se(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Mt=X?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),We(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Lt=X?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function Vt(e,t){if(Se(e)&&Se(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Ot(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Dt(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let u,c,p,l;switch(a){case 1:o<128&&(i=o);break;case 2:u=e[t+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(i=l));break;case 3:u=e[t+1],c=e[t+2],(u&192)===128&&(c&192)===128&&(l=(o&15)<<12|(u&63)<<6|c&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:u=e[t+1],c=e[t+2],p=e[t+3],(u&192)===128&&(c&192)===128&&(p&192)===128&&(l=(o&15)<<18|(u&63)<<12|(c&63)<<6|p&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=a}return Nn(n)}var Rt=4096;function Nn(e){let t=e.length;if(t<=Rt)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Rt));return r}var On=256,ce=class{constructor(t=On){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Lt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Z(n,0,this.cursor)}else r=Mt(this.chunks,this.cursor);return t&&this.reset(),r}};var h="CBOR decode error:",Ye="CBOR encode error:",ue=[];ue[23]=1;ue[24]=2;ue[25]=3;ue[26]=5;ue[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${h} not enough data for type`)}var g=[24,256,65536,4294967296,BigInt("18446744073709551616")];function T(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<g[0])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function k(e,t,r){F(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<g[1])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function A(e,t,r){F(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<g[2])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function I(e,t,r){F(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<g[3])throw new Error(`${h} 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(`${h} integers outside of the safe integer range are not supported`)}function Pt(e,t,r,n){return new d(s.uint,T(e,t+1,n),2)}function Ft(e,t,r,n){return new d(s.uint,k(e,t+1,n),3)}function Ht(e,t,r,n){return new d(s.uint,A(e,t+1,n),5)}function qt(e,t,r,n){return new d(s.uint,I(e,t+1,n),9)}function S(e,t){return x(e,0,t.value)}function x(e,t,r){if(r<g[0]){let n=Number(r);e.push([t|n])}else if(r<g[1]){let n=Number(r);e.push([t|24,n])}else if(r<g[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<g[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<g[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,e.push(o)}else throw new Error(`${h} encountered BigInt larger than allowable range`)}}S.encodedSize=function(t){return x.encodedSize(t.value)};x.encodedSize=function(t){return t<g[0]?1:t<g[1]?2:t<g[2]?3:t<g[3]?5:9};S.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Gt(e,t,r,n){return new d(s.negint,-1-T(e,t+1,n),2)}function Wt(e,t,r,n){return new d(s.negint,-1-k(e,t+1,n),3)}function Yt(e,t,r,n){return new d(s.negint,-1-A(e,t+1,n),5)}var Ke=BigInt(-1),Kt=BigInt(1);function Jt(e,t,r,n){let o=I(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new d(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${h} integers outside of the safe integer range are not supported`);return new d(s.negint,Ke-BigInt(o),9)}function Ue(e,t){let r=t.value,n=typeof r=="bigint"?r*Ke-Kt:r*-1-1;x(e,t.type.majorEncoded,n)}Ue.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Ke-Kt:r*-1-1;return n<g[0]?1:n<g[1]?2:n<g[2]?3:n<g[3]?5:9};Ue.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function fe(e,t,r,n){F(e,t,r+n);let o=Z(e,t+r,t+r+n);return new d(s.bytes,o,r+n)}function Qt(e,t,r,n){return fe(e,t,1,r)}function Xt(e,t,r,n){return fe(e,t,2,T(e,t+1,n))}function Zt(e,t,r,n){return fe(e,t,3,k(e,t+1,n))}function jt(e,t,r,n){return fe(e,t,5,A(e,t+1,n))}function er(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer bytes lengths not supported`);return fe(e,t,9,o)}function Be(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?$t(e.value):e.value),e.encodedBytes}function j(e,t){let r=Be(t);x(e,t.type.majorEncoded,r.length),e.push(r)}j.encodedSize=function(t){let r=Be(t);return x.encodedSize(r.length)+r.length};j.compareTokens=function(t,r){return Rn(Be(t),Be(r))};function Rn(e,t){return e.length<t.length?-1:e.length>t.length?1:Vt(e,t)}function de(e,t,r,n,o){let i=r+n;F(e,t,i);let a=new d(s.string,zt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=Z(e,t+r,t+i)),a}function tr(e,t,r,n){return de(e,t,1,r,n)}function rr(e,t,r,n){return de(e,t,2,T(e,t+1,n),n)}function nr(e,t,r,n){return de(e,t,3,k(e,t+1,n),n)}function or(e,t,r,n){return de(e,t,5,A(e,t+1,n),n)}function ir(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer string lengths not supported`);return de(e,t,9,o,n)}var sr=j;function ee(e,t,r,n){return new d(s.array,n,r)}function ar(e,t,r,n){return ee(e,t,1,r)}function cr(e,t,r,n){return ee(e,t,2,T(e,t+1,n))}function ur(e,t,r,n){return ee(e,t,3,k(e,t+1,n))}function fr(e,t,r,n){return ee(e,t,5,A(e,t+1,n))}function dr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer array lengths not supported`);return ee(e,t,9,o)}function lr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return ee(e,t,1,1/0)}function Ne(e,t){x(e,s.array.majorEncoded,t.value)}Ne.compareTokens=S.compareTokens;Ne.encodedSize=function(t){return x.encodedSize(t.value)};function te(e,t,r,n){return new d(s.map,n,r)}function hr(e,t,r,n){return te(e,t,1,r)}function pr(e,t,r,n){return te(e,t,2,T(e,t+1,n))}function yr(e,t,r,n){return te(e,t,3,k(e,t+1,n))}function mr(e,t,r,n){return te(e,t,5,A(e,t+1,n))}function wr(e,t,r,n){let o=I(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer map lengths not supported`);return te(e,t,9,o)}function gr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return te(e,t,1,1/0)}function Oe(e,t){x(e,s.map.majorEncoded,t.value)}Oe.compareTokens=S.compareTokens;Oe.encodedSize=function(t){return x.encodedSize(t.value)};function xr(e,t,r,n){return new d(s.tag,r,1)}function br(e,t,r,n){return new d(s.tag,T(e,t+1,n),2)}function vr(e,t,r,n){return new d(s.tag,k(e,t+1,n),3)}function Er(e,t,r,n){return new d(s.tag,A(e,t+1,n),5)}function _r(e,t,r,n){return new d(s.tag,I(e,t+1,n),9)}function De(e,t){x(e,s.tag.majorEncoded,t.value)}De.compareTokens=S.compareTokens;De.encodedSize=function(t){return x.encodedSize(t.value)};var Pn=20,Fn=21,Hn=22,qn=23;function Tr(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${h} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new d(s.null,null,1):new d(s.undefined,void 0,1)}function kr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return new d(s.break,void 0,1)}function Je(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${h} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${h} Infinity values are not supported`)}return new d(s.float,e,t)}function Ar(e,t,r,n){return Je(Qe(e,t+1),3,n)}function Ir(e,t,r,n){return Je(Xe(e,t+1),5,n)}function Cr(e,t,r,n){return Je(Nr(e,t+1),9,n)}function Re(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Pn]);else if(n===!0)e.push([s.float.majorEncoded|Fn]);else if(n===null)e.push([s.float.majorEncoded|Hn]);else if(n===void 0)e.push([s.float.majorEncoded|qn]);else{let o,i=!1;(!r||r.float64!==!0)&&(Ur(n),o=Qe(D,1),n===o||Number.isNaN(n)?(D[0]=249,e.push(D.slice(0,3)),i=!0):(Br(n),o=Xe(D,1),n===o&&(D[0]=250,e.push(D.slice(0,5)),i=!0))),i||(Gn(n),o=Nr(D,1),D[0]=251,e.push(D.slice(0,9)))}}Re.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){Ur(n);let o=Qe(D,1);if(n===o||Number.isNaN(n))return 3;if(Br(n),o=Xe(D,1),n===o)return 5}return 9};var Sr=new ArrayBuffer(9),U=new DataView(Sr,1),D=new Uint8Array(Sr,0);function Ur(e){if(e===1/0)U.setUint16(0,31744,!1);else if(e===-1/0)U.setUint16(0,64512,!1);else if(Number.isNaN(e))U.setUint16(0,32256,!1);else{U.setFloat32(0,e);let t=U.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)U.setUint16(0,31744,!1);else if(r===0)U.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?U.setUint16(0,0):o<-14?U.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):U.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Qe(e,t){if(e.length-t<2)throw new Error(`${h} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Br(e){U.setFloat32(0,e,!1)}function Xe(e,t){if(e.length-t<4)throw new Error(`${h} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Gn(e){U.setFloat64(0,e,!1)}function Nr(e,t){if(e.length-t<8)throw new Error(`${h} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}Re.compareTokens=S.compareTokens;function y(e,t,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function ze(e){return()=>{throw new Error(`${h} ${e}`)}}var f=[];for(let e=0;e<=23;e++)f[e]=y;f[24]=Pt;f[25]=Ft;f[26]=Ht;f[27]=qt;f[28]=y;f[29]=y;f[30]=y;f[31]=y;for(let e=32;e<=55;e++)f[e]=y;f[56]=Gt;f[57]=Wt;f[58]=Yt;f[59]=Jt;f[60]=y;f[61]=y;f[62]=y;f[63]=y;for(let e=64;e<=87;e++)f[e]=Qt;f[88]=Xt;f[89]=Zt;f[90]=jt;f[91]=er;f[92]=y;f[93]=y;f[94]=y;f[95]=ze("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=tr;f[120]=rr;f[121]=nr;f[122]=or;f[123]=ir;f[124]=y;f[125]=y;f[126]=y;f[127]=ze("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=ar;f[152]=cr;f[153]=ur;f[154]=fr;f[155]=dr;f[156]=y;f[157]=y;f[158]=y;f[159]=lr;for(let e=160;e<=183;e++)f[e]=hr;f[184]=pr;f[185]=yr;f[186]=mr;f[187]=wr;f[188]=y;f[189]=y;f[190]=y;f[191]=gr;for(let e=192;e<=215;e++)f[e]=xr;f[216]=br;f[217]=vr;f[218]=Er;f[219]=_r;f[220]=y;f[221]=y;f[222]=y;f[223]=y;for(let e=224;e<=243;e++)f[e]=ze("simple values are not supported");f[244]=y;f[245]=y;f[246]=y;f[247]=Tr;f[248]=ze("simple values are not supported");f[249]=Ar;f[250]=Ir;f[251]=Cr;f[252]=y;f[253]=y;f[254]=y;f[255]=kr;var R=[];for(let e=0;e<24;e++)R[e]=new d(s.uint,e,1);for(let e=-1;e>=-24;e--)R[31-e]=new d(s.negint,e,1);R[64]=new d(s.bytes,new Uint8Array(0),1);R[96]=new d(s.string,"",1);R[128]=new d(s.array,0,1);R[160]=new d(s.map,0,1);R[244]=new d(s.false,!1,1);R[245]=new d(s.true,!0,1);R[246]=new d(s.null,null,1);function Ze(e){switch(e.type){case s.false:return L([244]);case s.true:return L([245]);case s.null:return L([246]);case s.bytes:return e.value.length?void 0:L([64]);case s.string:return e.value===""?L([96]):void 0;case s.array:return e.value===0?L([128]):void 0;case s.map:return e.value===0?L([160]):void 0;case s.uint:return e.value<24?L([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return L([31-Number(e.value)])}}var Yn={float64:!1,mapSorter:Jn,quickEncodeToken:Ze};function et(){let e=[];return e[s.uint.major]=S,e[s.negint.major]=Ue,e[s.bytes.major]=j,e[s.string.major]=sr,e[s.array.major]=Ne,e[s.map.major]=Oe,e[s.tag.major]=De,e[s.float.major]=Re,e}var Or=et(),je=new ce,$e=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Ye} object contains circular references`);return new e(r,t)}},G={null:new d(s.null,null),undefined:new d(s.undefined,void 0),true:new d(s.true,!0),false:new d(s.false,!1),emptyArray:new d(s.array,0),emptyMap:new d(s.map,0)},W={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new d(s.float,e):e>=0?new d(s.uint,e):new d(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new d(s.uint,e):new d(s.negint,e)},Uint8Array(e,t,r,n){return new d(s.bytes,e)},string(e,t,r,n){return new d(s.string,e)},boolean(e,t,r,n){return e?G.true:G.false},null(e,t,r,n){return G.null},undefined(e,t,r,n){return G.undefined},ArrayBuffer(e,t,r,n){return new d(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new d(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[G.emptyArray,new d(s.break)]:G.emptyArray;n=$e.createCheck(n,e);let o=[],i=0;for(let a of e)o[i++]=le(a,r,n);return r.addBreakTokens?[new d(s.array,e.length),o,new d(s.break)]:[new d(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return r.addBreakTokens===!0?[G.emptyMap,new d(s.break)]:G.emptyMap;n=$e.createCheck(n,e);let u=[],c=0;for(let p of i)u[c++]=[le(p,r,n),le(o?e.get(p):e[p],r,n)];return Kn(u,r),r.addBreakTokens?[new d(s.map,a),u,new d(s.break)]:[new d(s.map,a),u]}};W.Map=W.Object;W.Buffer=W.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))W[`${e}Array`]=W.DataView;function le(e,t={},r){let n=Nt(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||W[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let i=W[n];if(!i)throw new Error(`${Ye} unsupported type: ${n}`);return i(e,n,t,r)}function Kn(e,t){t.mapSorter&&e.sort(t.mapSorter)}function Jn(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Or[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Dr(e,t,r,n){if(Array.isArray(t))for(let o of t)Dr(e,o,r,n);else r[t.type.major](e,t,n)}function Qn(e,t,r){let n=le(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let a=i.encodedSize(n,r),u=new ce(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return We(u.chunks[0])}}return je.reset(),Dr(je,n,t,r),je.toBytes(!0)}function tt(e,t){return t=Object.assign({},Yn,t),Qn(e,Or,t)}var Xn={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Me=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=R[t];if(r===void 0){let n=f[t];if(!n)throw new Error(`${h} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},he=Symbol.for("DONE"),Le=Symbol.for("BREAK");function Zn(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=re(t,r);if(i===Le){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===he)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function jn(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<e.value;a++){let u=re(t,r);if(u===Le){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(u===he)throw new Error(`${h} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof u!="string")throw new Error(`${h} non-string keys not supported (got ${typeof u})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(u)||!n&&u in o))throw new Error(`${h} found repeat map key "${u}"`);let c=re(t,r);if(c===he)throw new Error(`${h} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?i.set(u,c):o[u]=c}return n?i:o}function re(e,t){if(e.done())return he;let r=e.next();if(r.type===s.break)return Le;if(r.type.terminal)return r.value;if(r.type===s.array)return Zn(r,e,t);if(r.type===s.map)return jn(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=re(e,t);return t.tags[r.value](n)}throw new Error(`${h} tag not supported (${r.value})`)}throw new Error("unsupported")}function Rr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);t=Object.assign({},Xn,t);let r=t.tokenizer||new Me(e,t),n=re(r,t);if(n===he)throw new Error(`${h} did not find any content to decode`);if(n===Le)throw new Error(`${h} got unexpected break`);return[n,e.subarray(r.pos())]}function rt(e,t){let[r,n]=Rr(e,t);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var ds=new Uint8Array(0);function zr(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ne(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function to(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=e.length,c=e.charAt(0),p=Math.log(u)/Math.log(256),l=Math.log(256)/Math.log(u);function m(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var _=0,J=0,N=0,z=w.length;N!==z&&w[N]===0;)N++,_++;for(var $=(z-N)*l+1>>>0,C=new Uint8Array($);N!==z;){for(var M=w[N],q=0,O=$-1;(M!==0||q<J)&&O!==-1;O--,q++)M+=256*C[O]>>>0,C[O]=M%u>>>0,M=M/u>>>0;if(M!==0)throw new Error("Non-zero carry");J=q,N++}for(var P=$-J;P!==$&&C[P]===0;)P++;for(var Ae=c.repeat(_);P<$;++P)Ae+=e.charAt(C[P]);return Ae}function v(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var _=0;if(w[_]!==" "){for(var J=0,N=0;w[_]===c;)J++,_++;for(var z=(w.length-_)*p+1>>>0,$=new Uint8Array(z);w[_];){var C=r[w.charCodeAt(_)];if(C===255)return;for(var M=0,q=z-1;(C!==0||M<N)&&q!==-1;q--,M++)C+=u*$[q]>>>0,$[q]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");N=M,_++}if(w[_]!==" "){for(var O=z-N;O!==z&&$[O]===0;)O++;for(var P=new Uint8Array(J+(z-O)),Ae=J;O!==z;)P[Ae++]=$[O++];return P}}}function K(w){var _=v(w);if(_)return _;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:v,decode:K}}var ro=to,no=ro,$r=no;var nt=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ot=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Mr(this,t)}},it=class{decoders;constructor(t){this.decoders=t}or(t){return Mr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Mr(e,t){return new it({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var st=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new nt(t,r,n),this.decoder=new ot(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Lr({name:e,prefix:t,encode:r,decode:n}){return new st(e,t,r,n)}function at({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=$r(r,e);return Lr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function oo(e,t,r,n){let o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,c=0,p=0;for(let l=0;l<i;++l){let m=o[e[l]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|m,u+=r,u>=8&&(u-=8,a[p++]=255&c>>u)}if(u>=r||255&c<<8-u)throw new SyntaxError("Unexpected end of data");return a}function io(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let c=0;c<e.length;++c)for(u=u<<8|e[c],a+=8;a>r;)a-=r,i+=t[o&u>>a];if(a!==0&&(i+=t[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function V({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Lr({prefix:t,name:e,encode(o){return io(o,n,r)},decode(o){return oo(o,n,r,e)}})}var pe=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gs=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xs=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),bs=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),vs=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Es=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),_s=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ts=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ks=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var H=at({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cs=at({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var so=Fr,Vr=128,ao=127,co=~ao,uo=Math.pow(2,31);function Fr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=uo;)t[r++]=e&255|Vr,e/=128;for(;e&co;)t[r++]=e&255|Vr,e>>>=7;return t[r]=e|0,Fr.bytes=r-n+1,t}var fo=ct,lo=128,Pr=127;function ct(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw ct.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Pr)<<o:(a&Pr)*Math.pow(2,o),o+=7}while(a>=lo);return ct.bytes=i-n,r}var ho=Math.pow(2,7),po=Math.pow(2,14),yo=Math.pow(2,21),mo=Math.pow(2,28),wo=Math.pow(2,35),go=Math.pow(2,42),xo=Math.pow(2,49),bo=Math.pow(2,56),vo=Math.pow(2,63),Eo=function(e){return e<ho?1:e<po?2:e<yo?3:e<mo?4:e<wo?5:e<go?6:e<xo?7:e<bo?8:e<vo?9:10},_o={encode:so,decode:fo,encodingLength:Eo},To=_o,ye=To;function me(e,t=0){return[ye.decode(e,t),ye.decode.bytes]}function oe(e,t,r=0){return ye.encode(e,t,r),t}function ie(e){return ye.encodingLength(e)}function qr(e,t){let r=t.byteLength,n=ie(e),o=n+ie(r),i=new Uint8Array(o+r);return oe(e,i,0),oe(r,i,n),i.set(t,o),new se(e,r,t,i)}function Ve(e){let t=ne(e),[r,n]=me(t),[o,i]=me(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new se(r,o,a,t)}function Gr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&zr(e.bytes,r.bytes)}}var se=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Wr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Ao(r,ft(e),t??H.encoder);default:return Io(r,ft(e),t??pe.encoder)}}var Yr=new WeakMap;function ft(e){let t=Yr.get(e);if(t==null){let r=new Map;return Yr.set(e,r),r}return t}var B=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==we)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Co)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=qr(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Gr(t.multihash,n.multihash)}toString(t){return Wr(this,t)}toJSON(){return{"/":Wr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new e(n,o,i,a??Kr(n,o,i.bytes))}else if(r[So]===!0){let{version:n,multihash:o,code:i}=r,a=Ve(o);return e.create(n,i,a)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==we)throw new Error(`Version 0 CID must use dag-pb (code: ${we}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=Kr(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,we,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=ne(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new se(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[m,v]=me(t.subarray(r));return r+=v,m},o=n(),i=we;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),c=n(),p=r+c,l=p-a;return{version:o,codec:i,multihashCode:u,digestSize:c,multihashSize:l,size:p}}static parse(t,r){let[n,o]=ko(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ft(i).set(n,t),i}};function ko(e,t){switch(e[0]){case"Q":{let r=t??H;return[H.prefix,r.decode(`${H.prefix}${e}`)]}case H.prefix:{let r=t??H;return[H.prefix,r.decode(e)]}case pe.prefix:{let r=t??pe;return[pe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Ao(e,t,r){let{prefix:n}=r;if(n!==H.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Io(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var we=112,Co=18;function Kr(e,t,r){let n=ie(e),o=n+ie(t),i=new Uint8Array(o+r.byteLength);return oe(e,i,0),oe(t,i,n),i.set(r,o),i}var So=Symbol.for("@ipld/js-cid/CID");var Jr=42;function Uo(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function Bo(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=B.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new d(s.tag,Jr),new d(s.bytes,r)]}function No(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Oo(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var dt={float64:!0,typeEncoders:{Object:Bo,undefined:No,number:Oo}},Ls={...dt,typeEncoders:{...dt.typeEncoders}};function Do(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return B.decode(e.subarray(1))}var Pe={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};Pe.tags[Jr]=Do;var Vs={...Pe,tags:Pe.tags.slice()};var lt=e=>tt(e,dt),ht=e=>rt(Uo(e),Pe);var mt=Ce(Fe(),1);var wt=40;function gt(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=mt.default.decode(e);return t.seek(mt.default.decode.bytes),r}function xt(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),r=0;return{version:2,characteristics:[t.getBigUint64(r,!0),t.getBigUint64(r+=8,!0)],dataOffset:Number(t.getBigUint64(r+=8,!0)),dataSize:Number(t.getBigUint64(r+=8,!0)),indexOffset:Number(t.getBigUint64(r+=8,!0))}}var Y={Null:e=>e===null?e:void 0,Int:e=>Number.isInteger(e)?e:void 0,Float:e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,String:e=>typeof e=="string"?e:void 0,Bool:e=>typeof e=="boolean"?e:void 0,Bytes:e=>e instanceof Uint8Array?e:void 0,Link:e=>e!==null&&typeof e=="object"&&e.asCID===e?e:void 0,List:e=>Array.isArray(e)?e:void 0,Map:e=>e!==null&&typeof e=="object"&&e.asCID!==e&&!Array.isArray(e)&&!(e instanceof Uint8Array)?e:void 0},ge={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Y.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Y.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=ge["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=ge["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:Y.Int,CarV1HeaderOrV2Pragma:e=>{if(Y.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=ge["CarV1HeaderOrV2Pragma > roots (anon)"](e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=ge.Int(e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},xe={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":Y.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(Y.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=xe["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=xe["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:Y.Int,CarV1HeaderOrV2Pragma:e=>{if(Y.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=xe["CarV1HeaderOrV2Pragma > roots (anon)"](a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=xe.Int(a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},bt={toTyped:ge.CarV1HeaderOrV2Pragma,toRepresentation:xe.CarV1HeaderOrV2Pragma};var ta=et();var Zo=Ce(Fe(),1);var sa=[new d(s.map,2),new d(s.string,"version"),new d(s.uint,1),new d(s.string,"roots")],aa=new d(s.tag,42);async function vt(e,t){let r=gt(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),o=ht(n);if(bt.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||t!==void 0&&o.version!==t)throw new Error(`Invalid CAR version: ${o.version}${t!==void 0?` (expected ${t})`:""}`);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=xt(await e.exactly(wt,!0));e.seek(i.dataOffset-e.pos);let a=await vt(e,1);return Object.assign(a,i)}function be(e){let t=0;return{async upTo(r){return e.subarray(t,t+Math.min(r,e.length-t))},async exactly(r,n=!1){if(r>e.length-t)throw new Error("Unexpected end of data");let o=e.subarray(t,t+r);return n&&(t+=r),o},seek(r){t+=r},get pos(){return t}}}var Et=Ce(Fe(),1),cn=1;function _t(e){let t=lt({version:cn,roots:e}),r=Et.default.encode(t.length),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n}function un(e){return{async setRoots(t){let r=_t(t);await e.write(r)},async writeBlock(t){let{cid:r,bytes:n}=t;await e.write(new Uint8Array(Et.default.encode(r.bytes.length+n.length))),await e.write(r.bytes),n.length&&await e.write(n)},async close(){await e.end()},version(){return cn}}}function He(){}function fn(){let e=[],t=null,r=He,n=!1,o=null,i=He,a=()=>(t||(t=new Promise(p=>{r=()=>{t=null,r=He,p()}})),t),u={write(p){e.push(p);let l=a();return i(),l},async end(){n=!0;let p=a();i(),await p}},c={async next(){let p=e.shift();return p?(e.length===0&&r(),{done:!1,value:p}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(l=>{i=()=>(o=null,i=He,l(c.next()))})),o)}};return{writer:u,iterator:c}}var ve=class e{constructor(t,r){this._encoder=r,this._mutex=r.setRoots(t),this._ended=!1}async put(t){if(!(t.bytes instanceof Uint8Array)||!t.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=B.asCID(t.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:t.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(t){t=ri(t);let{encoder:r,iterator:n}=dn(),o=new e(t,r),i=new qe(n);return{writer:o,out:i}}static createAppender(){let{encoder:t,iterator:r}=dn();t.setRoots=()=>Promise.resolve();let n=new e([],t),o=new qe(r);return{writer:n,out:o}}static async updateRootsInBytes(t,r){let n=be(t);await vt(n);let o=_t(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 t.set(o,0),t}},qe=class{constructor(t){this._iterator=t}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function dn(){let e=fn(),{writer:t,iterator:r}=e;return{encoder:un(t),iterator:r}}function ri(e){if(e===void 0)return[];if(!Array.isArray(e)){let r=B.asCID(e);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let t=[];for(let r of e){let n=B.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");t.push(n)}return t}function ni(e){return e[Symbol.asyncIterator]!=null}function oi(e){if(ni(e))return(async()=>{for await(let t of e);})();for(let t of e);}var ln=oi;function ii(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var hn=ii;function si(e){return e[Symbol.asyncIterator]!=null}function ai(e,t){let r=0;if(si(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=hn(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let a=t(o,r++);if(typeof a.then=="function")return async function*(){yield await a;for await(let c of n)yield t(c,r++)}();let u=t;return function*(){yield a;for(let c of n)yield u(c,r++)}()}var pn=ai;function Tt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var At=Ce(mn(),1);var _e=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},It=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},wn=e=>globalThis.DOMException===void 0?new It(e):new DOMException(e),gn=e=>{let t=e.reason===void 0?wn("This operation was aborted."):e.reason;return t instanceof Error?t:wn(t)};function Ct(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,a,c=new Promise((p,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:v}=t;v.aborted&&l(gn(v)),v.addEventListener("abort",()=>{l(gn(v))})}if(r===Number.POSITIVE_INFINITY){e.then(p,l);return}let m=new _e;a=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(v){l(v)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?p():o instanceof Error?l(o):(m.message=o??`Promise timed out after ${r} milliseconds`,l(m))},r),(async()=>{try{p(await e)}catch(v){l(v)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},c}function St(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),a=n+i;r(e[a],t)<=0?(n=++a,o-=i+1):o=i}return n}var Te=class{#e=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,run:t};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let o=St(this.#e,n,(i,a)=>a.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#e.length}};var ke=class extends At.default{#e;#s;#i=0;#h;#a;#p=0;#r;#c;#t;#y;#n=0;#u;#o;#m;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Te,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#s=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#a=t.interval,this.#t=new t.queueClass,this.#y=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#m=t.throwOnTimeout===!0,this.#o=t.autoStart===!1}get#x(){return this.#s||this.#i<this.#h}get#b(){return this.#n<this.#u}#v(){this.#n--,this.#f(),this.emit("next")}#E(){this.#g(),this.#w(),this.#c=void 0}get#_(){let t=Date.now();if(this.#r===void 0){let r=this.#p-t;if(r<0)this.#i=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#E()},r)),!0}return!1}#f(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#o){let t=!this.#_;if(this.#x&&this.#b){let r=this.#t.dequeue();return r?(this.emit("active"),r(),t&&this.#w(),!0):!1}}return!1}#w(){this.#s||this.#r!==void 0||(this.#r=setInterval(()=>{this.#g()},this.#a),this.#p=Date.now()+this.#a)}#g(){this.#i===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#i=this.#e?this.#n:0,this.#d()}#d(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#u=t,this.#d()}async#T(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#m,...r},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#n++,this.#i++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=Ct(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#T(r.signal)]));let a=await i;n(a),this.emit("completed",a)}catch(i){if(i instanceof _e&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},r),this.emit("add"),this.#f()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#o?(this.#o=!1,this.#d(),this):this}pause(){this.#o=!0}clear(){this.#t=new this.#y}async onEmpty(){this.#t.size!==0&&await this.#l("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#l("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#l("idle")}async#l(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#o}};var fi=1,Ut=class{components;constructor(t,r){this.components=t}async import(t,r){await ln(this.components.blockstore.putMany(pn(t.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(t,r,n){let o=Tt(),i=Array.isArray(t)?t:[t],a=new ke({concurrency:fi});a.on("idle",()=>{o.resolve()}),a.on("error",u=>{a.clear(),o.reject(u)});for(let u of i)a.add(async()=>{await this.#e(u,a,async(c,p)=>{n?.blockFilter?.has(c.multihash.bytes)!==!0&&(n?.blockFilter?.add(c.multihash.bytes),await r.put({cid:c,bytes:p}))},n)}).catch(()=>{});try{await o.promise}finally{await r.close()}}async*stream(t,r){let{writer:n,out:o}=ve.create(t);this.export(t,n,r).catch(()=>{});for await(let i of o)yield i}async#e(t,r,n,o){let i=this.components.dagWalkers[t.code];if(i==null)throw new Error(`No dag walker found for cid codec ${t.code}`);let a=await this.components.blockstore.get(t,o);await n(t,a);for await(let u of i.walk(a))r.add(async()=>{await this.#e(u,r,n,o)})}};function di(e,t={}){return new Ut(e,t)}return kn(li);})();
|
|
2
|
+
"use strict";var HeliaCar=(()=>{var Tn=Object.create;var Se=Object.defineProperty;var In=Object.getOwnPropertyDescriptor;var Cn=Object.getOwnPropertyNames;var Sn=Object.getPrototypeOf,Un=Object.prototype.hasOwnProperty;var ce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Bn=(e,t)=>{for(var r in t)Se(e,r,{get:t[r],enumerable:!0})},$t=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Cn(t))!Un.call(e,o)&&o!==r&&Se(e,o,{get:()=>t[o],enumerable:!(n=In(t,o))||n.enumerable});return e};var Ue=(e,t,r)=>(r=e!=null?Tn(Sn(e)):{},$t(t||!e||!e.__esModule?Se(r,"default",{value:e,enumerable:!0}):r,e)),Nn=e=>$t(Se({},"__esModule",{value:!0}),e);var on=ce((ta,nn)=>{nn.exports=gt;var rn=128,qo=127,Ho=~qo,Go=Math.pow(2,31);function gt(e,t,r){if(Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw gt.bytes=0,new RangeError("Could not encode varint");t=t||[],r=r||0;for(var n=r;e>=Go;)t[r++]=e&255|rn,e/=128;for(;e&Ho;)t[r++]=e&255|rn,e>>>=7;return t[r]=e|0,gt.bytes=r-n+1,t}});var cn=ce((ra,an)=>{an.exports=xt;var Wo=128,sn=127;function xt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u||o>49)throw xt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&sn)<<o:(a&sn)*Math.pow(2,o),o+=7}while(a>=Wo);return xt.bytes=i-n,r}});var fn=ce((na,un)=>{var jo=Math.pow(2,7),Ko=Math.pow(2,14),Yo=Math.pow(2,21),Jo=Math.pow(2,28),Xo=Math.pow(2,35),Qo=Math.pow(2,42),Zo=Math.pow(2,49),ei=Math.pow(2,56),ti=Math.pow(2,63);un.exports=function(e){return e<jo?1:e<Ko?2:e<Yo?3:e<Jo?4:e<Xo?5:e<Qo?6:e<Zo?7:e<ei?8:e<ti?9:10}});var Ge=ce((oa,dn)=>{dn.exports={encode:on(),decode:cn(),encodingLength:fn()}});var _n=ce((wc,Nt)=>{"use strict";var xi=Object.prototype.hasOwnProperty,_="~";function ke(){}Object.create&&(ke.prototype=Object.create(null),new ke().__proto__||(_=!1));function bi(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function En(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new bi(r,n||e,o),a=_?_+t:t;return e._events[a]?e._events[a].fn?e._events[a]=[e._events[a],i]:e._events[a].push(i):(e._events[a]=i,e._eventsCount++),e}function Ye(e,t){--e._eventsCount===0?e._events=new ke:delete e._events[t]}function v(){this._events=new ke,this._eventsCount=0}v.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)xi.call(r,n)&&t.push(_?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};v.prototype.listeners=function(t){var r=_?_+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,a=new Array(i);o<i;o++)a[o]=n[o].fn;return a};v.prototype.listenerCount=function(t){var r=_?_+t:t,n=this._events[r];return n?n.fn?1:n.length:0};v.prototype.emit=function(t,r,n,o,i,a){var u=_?_+t:t;if(!this._events[u])return!1;var c=this._events[u],p=arguments.length,l,m;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),p){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,a),!0}for(m=1,l=new Array(p-1);m<p;m++)l[m-1]=arguments[m];c.fn.apply(c.context,l)}else{var E=c.length,K;for(m=0;m<E;m++)switch(c[m].once&&this.removeListener(t,c[m].fn,void 0,!0),p){case 1:c[m].fn.call(c[m].context);break;case 2:c[m].fn.call(c[m].context,r);break;case 3:c[m].fn.call(c[m].context,r,n);break;case 4:c[m].fn.call(c[m].context,r,n,o);break;default:if(!l)for(K=1,l=new Array(p-1);K<p;K++)l[K-1]=arguments[K];c[m].fn.apply(c[m].context,l)}}return!0};v.prototype.on=function(t,r,n){return En(this,t,r,n,!1)};v.prototype.once=function(t,r,n){return En(this,t,r,n,!0)};v.prototype.removeListener=function(t,r,n,o){var i=_?_+t:t;if(!this._events[i])return this;if(!r)return Ye(this,i),this;var a=this._events[i];if(a.fn)a.fn===r&&(!o||a.once)&&(!n||a.context===n)&&Ye(this,i);else{for(var u=0,c=[],p=a.length;u<p;u++)(a[u].fn!==r||o&&!a[u].once||n&&a[u].context!==n)&&c.push(a[u]);c.length?this._events[i]=c.length===1?c[0]:c:Ye(this,i)}return this};v.prototype.removeAllListeners=function(t){var r;return t?(r=_?_+t:t,this._events[r]&&Ye(this,r)):(this._events=new ke,this._eventsCount=0),this};v.prototype.off=v.prototype.removeListener;v.prototype.addListener=v.prototype.on;v.prefixed=_;v.EventEmitter=v;typeof Nt<"u"&&(Nt.exports=v)});var _i={};Bn(_i,{car:()=>Ei});var On=["string","number","bigint","symbol"],Dn=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Lt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(On.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(Mn(e))return"Buffer";let r=Rn(e);return r||"Object"}function Mn(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Rn(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(Dn.includes(t))return t}var s=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};s.uint=new s(0,"uint",!0);s.negint=new s(1,"negint",!0);s.bytes=new s(2,"bytes",!0);s.string=new s(3,"string",!0);s.array=new s(4,"array",!1);s.map=new s(5,"map",!1);s.tag=new s(6,"tag",!1);s.float=new s(7,"float",!0);s.false=new s(7,"false",!0);s.true=new s(7,"true",!0);s.null=new s(7,"null",!0);s.undefined=new s(7,"undefined",!0);s.break=new s(7,"break",!0);var d=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var X=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",zn=new TextDecoder,$n=new TextEncoder;function Be(e){return X&&globalThis.Buffer.isBuffer(e)}function Je(e){return e instanceof Uint8Array?Be(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var qt=X?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Pt(e,t,r):(e,t,r)=>r-t>64?zn.decode(e.subarray(t,r)):Pt(e,t,r),Ht=X?e=>e.length>64?globalThis.Buffer.from(e):Vt(e):e=>e.length>64?$n.encode(e):Vt(e),L=e=>Uint8Array.from(e),Q=X?(e,t,r)=>Be(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),Gt=X?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Je(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Wt=X?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function jt(e,t){if(Be(e)&&Be(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Vt(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Pt(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=r){let u,c,p,l;switch(a){case 1:o<128&&(i=o);break;case 2:u=e[t+1],(u&192)===128&&(l=(o&31)<<6|u&63,l>127&&(i=l));break;case 3:u=e[t+1],c=e[t+2],(u&192)===128&&(c&192)===128&&(l=(o&15)<<12|(u&63)<<6|c&63,l>2047&&(l<55296||l>57343)&&(i=l));break;case 4:u=e[t+1],c=e[t+2],p=e[t+3],(u&192)===128&&(c&192)===128&&(p&192)===128&&(l=(o&15)<<18|(u&63)<<12|(c&63)<<6|p&63,l>65535&&l<1114112&&(i=l))}}i===null?(i=65533,a=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=a}return Ln(n)}var Ft=4096;function Ln(e){let t=e.length;if(t<=Ft)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Ft));return r}var Vn=256,ue=class{constructor(t=Vn){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Wt(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=Q(n,0,this.cursor)}else r=Gt(this.chunks,this.cursor);return t&&this.reset(),r}};var h="CBOR decode error:",Xe="CBOR encode error:",fe=[];fe[23]=1;fe[24]=2;fe[25]=3;fe[26]=5;fe[27]=9;function F(e,t,r){if(e.length-t<r)throw new Error(`${h} not enough data for type`)}var x=[24,256,65536,4294967296,BigInt("18446744073709551616")];function A(e,t,r){F(e,t,1);let n=e[t];if(r.strict===!0&&n<x[0])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function T(e,t,r){F(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<x[1])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function I(e,t,r){F(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<x[2])throw new Error(`${h} integer encoded in more bytes than necessary (strict decode)`);return n}function C(e,t,r){F(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<x[3])throw new Error(`${h} 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(`${h} integers outside of the safe integer range are not supported`)}function Kt(e,t,r,n){return new d(s.uint,A(e,t+1,n),2)}function Yt(e,t,r,n){return new d(s.uint,T(e,t+1,n),3)}function Jt(e,t,r,n){return new d(s.uint,I(e,t+1,n),5)}function Xt(e,t,r,n){return new d(s.uint,C(e,t+1,n),9)}function U(e,t){return b(e,0,t.value)}function b(e,t,r){if(r<x[0]){let n=Number(r);e.push([t|n])}else if(r<x[1]){let n=Number(r);e.push([t|24,n])}else if(r<x[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<x[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<x[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),a=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=a&255,a=a>>8,o[3]=a&255,a=a>>8,o[2]=a&255,a=a>>8,o[1]=a&255,e.push(o)}else throw new Error(`${h} encountered BigInt larger than allowable range`)}}U.encodedSize=function(t){return b.encodedSize(t.value)};b.encodedSize=function(t){return t<x[0]?1:t<x[1]?2:t<x[2]?3:t<x[3]?5:9};U.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Qt(e,t,r,n){return new d(s.negint,-1-A(e,t+1,n),2)}function Zt(e,t,r,n){return new d(s.negint,-1-T(e,t+1,n),3)}function er(e,t,r,n){return new d(s.negint,-1-I(e,t+1,n),5)}var Qe=BigInt(-1),tr=BigInt(1);function rr(e,t,r,n){let o=C(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new d(s.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${h} integers outside of the safe integer range are not supported`);return new d(s.negint,Qe-BigInt(o),9)}function Ne(e,t){let r=t.value,n=typeof r=="bigint"?r*Qe-tr:r*-1-1;b(e,t.type.majorEncoded,n)}Ne.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*Qe-tr:r*-1-1;return n<x[0]?1:n<x[1]?2:n<x[2]?3:n<x[3]?5:9};Ne.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function de(e,t,r,n){F(e,t,r+n);let o=Q(e,t+r,t+r+n);return new d(s.bytes,o,r+n)}function nr(e,t,r,n){return de(e,t,1,r)}function or(e,t,r,n){return de(e,t,2,A(e,t+1,n))}function ir(e,t,r,n){return de(e,t,3,T(e,t+1,n))}function sr(e,t,r,n){return de(e,t,5,I(e,t+1,n))}function ar(e,t,r,n){let o=C(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer bytes lengths not supported`);return de(e,t,9,o)}function Oe(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===s.string?Ht(e.value):e.value),e.encodedBytes}function Z(e,t){let r=Oe(t);b(e,t.type.majorEncoded,r.length),e.push(r)}Z.encodedSize=function(t){let r=Oe(t);return b.encodedSize(r.length)+r.length};Z.compareTokens=function(t,r){return Fn(Oe(t),Oe(r))};function Fn(e,t){return e.length<t.length?-1:e.length>t.length?1:jt(e,t)}function le(e,t,r,n,o){let i=r+n;F(e,t,i);let a=new d(s.string,qt(e,t+r,t+i),i);return o.retainStringBytes===!0&&(a.byteValue=Q(e,t+r,t+i)),a}function cr(e,t,r,n){return le(e,t,1,r,n)}function ur(e,t,r,n){return le(e,t,2,A(e,t+1,n),n)}function fr(e,t,r,n){return le(e,t,3,T(e,t+1,n),n)}function dr(e,t,r,n){return le(e,t,5,I(e,t+1,n),n)}function lr(e,t,r,n){let o=C(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer string lengths not supported`);return le(e,t,9,o,n)}var hr=Z;function ee(e,t,r,n){return new d(s.array,n,r)}function pr(e,t,r,n){return ee(e,t,1,r)}function yr(e,t,r,n){return ee(e,t,2,A(e,t+1,n))}function mr(e,t,r,n){return ee(e,t,3,T(e,t+1,n))}function wr(e,t,r,n){return ee(e,t,5,I(e,t+1,n))}function gr(e,t,r,n){let o=C(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer array lengths not supported`);return ee(e,t,9,o)}function xr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return ee(e,t,1,1/0)}function De(e,t){b(e,s.array.majorEncoded,t.value)}De.compareTokens=U.compareTokens;De.encodedSize=function(t){return b.encodedSize(t.value)};function te(e,t,r,n){return new d(s.map,n,r)}function br(e,t,r,n){return te(e,t,1,r)}function vr(e,t,r,n){return te(e,t,2,A(e,t+1,n))}function Er(e,t,r,n){return te(e,t,3,T(e,t+1,n))}function _r(e,t,r,n){return te(e,t,5,I(e,t+1,n))}function kr(e,t,r,n){let o=C(e,t+1,n);if(typeof o=="bigint")throw new Error(`${h} 64-bit integer map lengths not supported`);return te(e,t,9,o)}function Ar(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return te(e,t,1,1/0)}function Me(e,t){b(e,s.map.majorEncoded,t.value)}Me.compareTokens=U.compareTokens;Me.encodedSize=function(t){return b.encodedSize(t.value)};function Tr(e,t,r,n){return new d(s.tag,r,1)}function Ir(e,t,r,n){return new d(s.tag,A(e,t+1,n),2)}function Cr(e,t,r,n){return new d(s.tag,T(e,t+1,n),3)}function Sr(e,t,r,n){return new d(s.tag,I(e,t+1,n),5)}function Ur(e,t,r,n){return new d(s.tag,C(e,t+1,n),9)}function Re(e,t){b(e,s.tag.majorEncoded,t.value)}Re.compareTokens=U.compareTokens;Re.encodedSize=function(t){return b.encodedSize(t.value)};var Kn=20,Yn=21,Jn=22,Xn=23;function Br(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${h} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new d(s.null,null,1):new d(s.undefined,void 0,1)}function Nr(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${h} indefinite length items not allowed`);return new d(s.break,void 0,1)}function Ze(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${h} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${h} Infinity values are not supported`)}return new d(s.float,e,t)}function Or(e,t,r,n){return Ze(et(e,t+1),3,n)}function Dr(e,t,r,n){return Ze(tt(e,t+1),5,n)}function Mr(e,t,r,n){return Ze(Lr(e,t+1),9,n)}function ze(e,t,r){let n=t.value;if(n===!1)e.push([s.float.majorEncoded|Kn]);else if(n===!0)e.push([s.float.majorEncoded|Yn]);else if(n===null)e.push([s.float.majorEncoded|Jn]);else if(n===void 0)e.push([s.float.majorEncoded|Xn]);else{let o,i=!1;(!r||r.float64!==!0)&&(zr(n),o=et(D,1),n===o||Number.isNaN(n)?(D[0]=249,e.push(D.slice(0,3)),i=!0):($r(n),o=tt(D,1),n===o&&(D[0]=250,e.push(D.slice(0,5)),i=!0))),i||(Qn(n),o=Lr(D,1),D[0]=251,e.push(D.slice(0,9)))}}ze.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){zr(n);let o=et(D,1);if(n===o||Number.isNaN(n))return 3;if($r(n),o=tt(D,1),n===o)return 5}return 9};var Rr=new ArrayBuffer(9),B=new DataView(Rr,1),D=new Uint8Array(Rr,0);function zr(e){if(e===1/0)B.setUint16(0,31744,!1);else if(e===-1/0)B.setUint16(0,64512,!1);else if(Number.isNaN(e))B.setUint16(0,32256,!1);else{B.setFloat32(0,e);let t=B.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)B.setUint16(0,31744,!1);else if(r===0)B.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?B.setUint16(0,0):o<-14?B.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):B.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function et(e,t){if(e.length-t<2)throw new Error(`${h} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function $r(e){B.setFloat32(0,e,!1)}function tt(e,t){if(e.length-t<4)throw new Error(`${h} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Qn(e){B.setFloat64(0,e,!1)}function Lr(e,t){if(e.length-t<8)throw new Error(`${h} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}ze.compareTokens=U.compareTokens;function y(e,t,r){throw new Error(`${h} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function $e(e){return()=>{throw new Error(`${h} ${e}`)}}var f=[];for(let e=0;e<=23;e++)f[e]=y;f[24]=Kt;f[25]=Yt;f[26]=Jt;f[27]=Xt;f[28]=y;f[29]=y;f[30]=y;f[31]=y;for(let e=32;e<=55;e++)f[e]=y;f[56]=Qt;f[57]=Zt;f[58]=er;f[59]=rr;f[60]=y;f[61]=y;f[62]=y;f[63]=y;for(let e=64;e<=87;e++)f[e]=nr;f[88]=or;f[89]=ir;f[90]=sr;f[91]=ar;f[92]=y;f[93]=y;f[94]=y;f[95]=$e("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)f[e]=cr;f[120]=ur;f[121]=fr;f[122]=dr;f[123]=lr;f[124]=y;f[125]=y;f[126]=y;f[127]=$e("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)f[e]=pr;f[152]=yr;f[153]=mr;f[154]=wr;f[155]=gr;f[156]=y;f[157]=y;f[158]=y;f[159]=xr;for(let e=160;e<=183;e++)f[e]=br;f[184]=vr;f[185]=Er;f[186]=_r;f[187]=kr;f[188]=y;f[189]=y;f[190]=y;f[191]=Ar;for(let e=192;e<=215;e++)f[e]=Tr;f[216]=Ir;f[217]=Cr;f[218]=Sr;f[219]=Ur;f[220]=y;f[221]=y;f[222]=y;f[223]=y;for(let e=224;e<=243;e++)f[e]=$e("simple values are not supported");f[244]=y;f[245]=y;f[246]=y;f[247]=Br;f[248]=$e("simple values are not supported");f[249]=Or;f[250]=Dr;f[251]=Mr;f[252]=y;f[253]=y;f[254]=y;f[255]=Nr;var M=[];for(let e=0;e<24;e++)M[e]=new d(s.uint,e,1);for(let e=-1;e>=-24;e--)M[31-e]=new d(s.negint,e,1);M[64]=new d(s.bytes,new Uint8Array(0),1);M[96]=new d(s.string,"",1);M[128]=new d(s.array,0,1);M[160]=new d(s.map,0,1);M[244]=new d(s.false,!1,1);M[245]=new d(s.true,!0,1);M[246]=new d(s.null,null,1);function rt(e){switch(e.type){case s.false:return L([244]);case s.true:return L([245]);case s.null:return L([246]);case s.bytes:return e.value.length?void 0:L([64]);case s.string:return e.value===""?L([96]):void 0;case s.array:return e.value===0?L([128]):void 0;case s.map:return e.value===0?L([160]):void 0;case s.uint:return e.value<24?L([Number(e.value)]):void 0;case s.negint:if(e.value>=-24)return L([31-Number(e.value)])}}var eo={float64:!1,mapSorter:ro,quickEncodeToken:rt};function ot(){let e=[];return e[s.uint.major]=U,e[s.negint.major]=Ne,e[s.bytes.major]=Z,e[s.string.major]=hr,e[s.array.major]=De,e[s.map.major]=Me,e[s.tag.major]=Re,e[s.float.major]=ze,e}var Vr=ot(),nt=new ue,Le=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${Xe} object contains circular references`);return new e(r,t)}},G={null:new d(s.null,null),undefined:new d(s.undefined,void 0),true:new d(s.true,!0),false:new d(s.false,!1),emptyArray:new d(s.array,0),emptyMap:new d(s.map,0)},W={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new d(s.float,e):e>=0?new d(s.uint,e):new d(s.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new d(s.uint,e):new d(s.negint,e)},Uint8Array(e,t,r,n){return new d(s.bytes,e)},string(e,t,r,n){return new d(s.string,e)},boolean(e,t,r,n){return e?G.true:G.false},null(e,t,r,n){return G.null},undefined(e,t,r,n){return G.undefined},ArrayBuffer(e,t,r,n){return new d(s.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new d(s.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[G.emptyArray,new d(s.break)]:G.emptyArray;n=Le.createCheck(n,e);let o=[],i=0;for(let a of e)o[i++]=he(a,r,n);return r.addBreakTokens?[new d(s.array,e.length),o,new d(s.break)]:[new d(s.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return r.addBreakTokens===!0?[G.emptyMap,new d(s.break)]:G.emptyMap;n=Le.createCheck(n,e);let u=[],c=0;for(let p of i)u[c++]=[he(p,r,n),he(o?e.get(p):e[p],r,n)];return to(u,r),r.addBreakTokens?[new d(s.map,a),u,new d(s.break)]:[new d(s.map,a),u]}};W.Map=W.Object;W.Buffer=W.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))W[`${e}Array`]=W.DataView;function he(e,t={},r){let n=Lt(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||W[n];if(typeof o=="function"){let a=o(e,n,t,r);if(a!=null)return a}let i=W[n];if(!i)throw new Error(`${Xe} unsupported type: ${n}`);return i(e,n,t,r)}function to(e,t){t.mapSorter&&e.sort(t.mapSorter)}function ro(e,t){let r=Array.isArray(e[0])?e[0][0]:e[0],n=Array.isArray(t[0])?t[0][0]:t[0];if(r.type!==n.type)return r.type.compare(n.type);let o=r.type.major,i=Vr[o].compareTokens(r,n);return i===0&&console.warn("WARNING: complex key types used, CBOR key sorting guarantees are gone"),i}function Pr(e,t,r,n){if(Array.isArray(t))for(let o of t)Pr(e,o,r,n);else r[t.type.major](e,t,n)}function no(e,t,r){let n=he(e,r);if(!Array.isArray(n)&&r.quickEncodeToken){let o=r.quickEncodeToken(n);if(o)return o;let i=t[n.type.major];if(i.encodedSize){let a=i.encodedSize(n,r),u=new ue(a);if(i(u,n,r),u.chunks.length!==1)throw new Error(`Unexpected error: pre-calculated length for ${n} was wrong`);return Je(u.chunks[0])}}return nt.reset(),Pr(nt,n,t,r),nt.toBytes(!0)}function it(e,t){return t=Object.assign({},eo,t),no(e,Vr,t)}var oo={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Ve=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=M[t];if(r===void 0){let n=f[t];if(!n)throw new Error(`${h} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},pe=Symbol.for("DONE"),Pe=Symbol.for("BREAK");function io(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=re(t,r);if(i===Pe){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed array`)}if(i===pe)throw new Error(`${h} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function so(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let a=0;a<e.value;a++){let u=re(t,r);if(u===Pe){if(e.value===1/0)break;throw new Error(`${h} got unexpected break to lengthed map`)}if(u===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(n!==!0&&typeof u!="string")throw new Error(`${h} non-string keys not supported (got ${typeof u})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(u)||!n&&u in o))throw new Error(`${h} found repeat map key "${u}"`);let c=re(t,r);if(c===pe)throw new Error(`${h} found map but not enough entries (got ${a} [no value], expected ${e.value})`);n?i.set(u,c):o[u]=c}return n?i:o}function re(e,t){if(e.done())return pe;let r=e.next();if(r.type===s.break)return Pe;if(r.type.terminal)return r.value;if(r.type===s.array)return io(r,e,t);if(r.type===s.map)return so(r,e,t);if(r.type===s.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=re(e,t);return t.tags[r.value](n)}throw new Error(`${h} tag not supported (${r.value})`)}throw new Error("unsupported")}function Fr(e,t){if(!(e instanceof Uint8Array))throw new Error(`${h} data to decode must be a Uint8Array`);t=Object.assign({},oo,t);let r=t.tokenizer||new Ve(e,t),n=re(r,t);if(n===pe)throw new Error(`${h} did not find any content to decode`);if(n===Pe)throw new Error(`${h} got unexpected break`);return[n,e.subarray(r.pos())]}function st(e,t){let[r,n]=Fr(e,t);if(n.length>0)throw new Error(`${h} too many terminals, data makes no sense`);return r}var Es=new Uint8Array(0);function qr(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function ne(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function co(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),a=i.charCodeAt(0);if(r[a]!==255)throw new TypeError(i+" is ambiguous");r[a]=o}var u=e.length,c=e.charAt(0),p=Math.log(u)/Math.log(256),l=Math.log(256)/Math.log(u);function m(w){if(w instanceof Uint8Array||(ArrayBuffer.isView(w)?w=new Uint8Array(w.buffer,w.byteOffset,w.byteLength):Array.isArray(w)&&(w=Uint8Array.from(w))),!(w instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(w.length===0)return"";for(var k=0,Y=0,N=0,R=w.length;N!==R&&w[N]===0;)N++,k++;for(var z=(R-N)*l+1>>>0,S=new Uint8Array(z);N!==R;){for(var $=w[N],H=0,O=z-1;($!==0||H<Y)&&O!==-1;O--,H++)$+=256*S[O]>>>0,S[O]=$%u>>>0,$=$/u>>>0;if($!==0)throw new Error("Non-zero carry");Y=H,N++}for(var P=z-Y;P!==z&&S[P]===0;)P++;for(var Ce=c.repeat(k);P<z;++P)Ce+=e.charAt(S[P]);return Ce}function E(w){if(typeof w!="string")throw new TypeError("Expected String");if(w.length===0)return new Uint8Array;var k=0;if(w[k]!==" "){for(var Y=0,N=0;w[k]===c;)Y++,k++;for(var R=(w.length-k)*p+1>>>0,z=new Uint8Array(R);w[k];){var S=r[w.charCodeAt(k)];if(S===255)return;for(var $=0,H=R-1;(S!==0||$<N)&&H!==-1;H--,$++)S+=u*z[H]>>>0,z[H]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");N=$,k++}if(w[k]!==" "){for(var O=R-N;O!==R&&z[O]===0;)O++;for(var P=new Uint8Array(Y+(R-O)),Ce=Y;O!==R;)P[Ce++]=z[O++];return P}}}function K(w){var k=E(w);if(k)return k;throw new Error(`Non-${t} character`)}return{encode:m,decodeUnsafe:E,decode:K}}var uo=co,fo=uo,Gr=fo;var at=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},ct=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Wr(this,t)}},ut=class{decoders;constructor(t){this.decoders=t}or(t){return Wr(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Wr(e,t){return new ut({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var ft=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new at(t,r,n),this.decoder=new ct(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function jr({name:e,prefix:t,encode:r,decode:n}){return new ft(e,t,r,n)}function oe({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Gr(r,e);return jr({prefix:t,name:e,encode:n,decode:i=>ne(o(i))})}function lo(e,t,r,n){let o={};for(let l=0;l<t.length;++l)o[t[l]]=l;let i=e.length;for(;e[i-1]==="=";)--i;let a=new Uint8Array(i*r/8|0),u=0,c=0,p=0;for(let l=0;l<i;++l){let m=o[e[l]];if(m===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|m,u+=r,u>=8&&(u-=8,a[p++]=255&c>>u)}if(u>=r||255&c<<8-u)throw new SyntaxError("Unexpected end of data");return a}function ho(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",a=0,u=0;for(let c=0;c<e.length;++c)for(u=u<<8|e[c],a+=8;a>r;)a-=r,i+=t[o&u>>a];if(a!==0&&(i+=t[o&u<<r-a]),n)for(;i.length*r&7;)i+="=";return i}function V({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return jr({prefix:t,name:e,encode(o){return ho(o,n,r)},decode(o){return lo(o,n,r,e)}})}var ye=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cs=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ss=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Us=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Bs=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ns=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Os=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ds=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ms=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fe=oe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$s=oe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var q=oe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ps=oe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var po=Jr,Kr=128,yo=127,mo=~yo,wo=Math.pow(2,31);function Jr(e,t,r){t=t||[],r=r||0;for(var n=r;e>=wo;)t[r++]=e&255|Kr,e/=128;for(;e&mo;)t[r++]=e&255|Kr,e>>>=7;return t[r]=e|0,Jr.bytes=r-n+1,t}var go=dt,xo=128,Yr=127;function dt(e,n){var r=0,n=n||0,o=0,i=n,a,u=e.length;do{if(i>=u)throw dt.bytes=0,new RangeError("Could not decode varint");a=e[i++],r+=o<28?(a&Yr)<<o:(a&Yr)*Math.pow(2,o),o+=7}while(a>=xo);return dt.bytes=i-n,r}var bo=Math.pow(2,7),vo=Math.pow(2,14),Eo=Math.pow(2,21),_o=Math.pow(2,28),ko=Math.pow(2,35),Ao=Math.pow(2,42),To=Math.pow(2,49),Io=Math.pow(2,56),Co=Math.pow(2,63),So=function(e){return e<bo?1:e<vo?2:e<Eo?3:e<_o?4:e<ko?5:e<Ao?6:e<To?7:e<Io?8:e<Co?9:10},Uo={encode:po,decode:go,encodingLength:So},Bo=Uo,me=Bo;function we(e,t=0){return[me.decode(e,t),me.decode.bytes]}function ie(e,t,r=0){return me.encode(e,t,r),t}function se(e){return me.encodingLength(e)}function ht(e,t){let r=t.byteLength,n=se(e),o=n+se(r),i=new Uint8Array(o+r);return ie(e,i,0),ie(r,i,n),i.set(t,o),new ae(e,r,t,i)}function qe(e){let t=ne(e),[r,n]=we(t),[o,i]=we(t.subarray(n)),a=t.subarray(n+i);if(a.byteLength!==o)throw new Error("Incorrect length");return new ae(r,o,a,t)}function Xr(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&qr(e.bytes,r.bytes)}}var ae=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Qr(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return Oo(r,pt(e),t??q.encoder);default:return Do(r,pt(e),t??ye.encoder)}}var Zr=new WeakMap;function pt(e){let t=Zr.get(e);if(t==null){let r=new Map;return Zr.set(e,r),r}return t}var g=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Mo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=ht(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Xr(t.multihash,n.multihash)}toString(t){return Qr(this,t)}toJSON(){return{"/":Qr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:a}=r;return new e(n,o,i,a??en(n,o,i.bytes))}else if(r[Ro]===!0){let{version:n,multihash:o,code:i}=r,a=qe(o);return e.create(n,i,a)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==xe)throw new Error(`Version 0 CID must use dag-pb (code: ${xe}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=en(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,xe,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=ne(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),a=new ae(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(a):e.createV1(r.codec,a),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[m,E]=we(t.subarray(r));return r+=E,m},o=n(),i=xe;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),c=n(),p=r+c,l=p-a;return{version:o,codec:i,multihashCode:u,digestSize:c,multihashSize:l,size:p}}static parse(t,r){let[n,o]=No(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return pt(i).set(n,t),i}};function No(e,t){switch(e[0]){case"Q":{let r=t??q;return[q.prefix,r.decode(`${q.prefix}${e}`)]}case q.prefix:{let r=t??q;return[q.prefix,r.decode(e)]}case ye.prefix:{let r=t??ye;return[ye.prefix,r.decode(e)]}case Fe.prefix:{let r=t??Fe;return[Fe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function Oo(e,t,r){let{prefix:n}=r;if(n!==q.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function Do(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var xe=112,Mo=18;function en(e,t,r){let n=se(e),o=n+se(t),i=new Uint8Array(o+r.byteLength);return ie(e,i,0),ie(t,i,n),i.set(r,o),i}var Ro=Symbol.for("@ipld/js-cid/CID");var tn=42;function zo(e){return e instanceof ArrayBuffer?new Uint8Array(e,0,e.byteLength):e}function $o(e){if(e.asCID!==e&&e["/"]!==e.bytes)return null;let t=g.asCID(e);if(!t)return null;let r=new Uint8Array(t.bytes.byteLength+1);return r.set(t.bytes,1),[new d(s.tag,tn),new d(s.bytes,r)]}function Lo(){throw new Error("`undefined` is not supported by the IPLD Data Model and cannot be encoded")}function Vo(e){if(Number.isNaN(e))throw new Error("`NaN` is not supported by the IPLD Data Model and cannot be encoded");if(e===1/0||e===-1/0)throw new Error("`Infinity` and `-Infinity` is not supported by the IPLD Data Model and cannot be encoded");return null}var yt={float64:!0,typeEncoders:{Object:$o,undefined:Lo,number:Vo}},Zs={...yt,typeEncoders:{...yt.typeEncoders}};function Po(e){if(e[0]!==0)throw new Error("Invalid CID for CBOR tag 42; expected leading 0x00");return g.decode(e.subarray(1))}var He={allowIndefinite:!1,coerceUndefinedToNull:!0,allowNaN:!1,allowInfinity:!1,allowBigInt:!0,strict:!0,useMaps:!1,rejectDuplicateMapKeys:!0,tags:[]};He.tags[tn]=Po;var ea={...He,tags:He.tags.slice()};var mt=e=>it(e,yt),wt=e=>st(zo(e),He);var bt=Ue(Ge(),1);var vt=40;function Et(e,t){if(!e.length)throw new Error("Unexpected end of data");let r=bt.default.decode(e);return t.seek(bt.default.decode.bytes),r}function _t(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),r=0;return{version:2,characteristics:[t.getBigUint64(r,!0),t.getBigUint64(r+=8,!0)],dataOffset:Number(t.getBigUint64(r+=8,!0)),dataSize:Number(t.getBigUint64(r+=8,!0)),indexOffset:Number(t.getBigUint64(r+=8,!0))}}var j={Null:e=>e===null?e:void 0,Int:e=>Number.isInteger(e)?e:void 0,Float:e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,String:e=>typeof e=="string"?e:void 0,Bool:e=>typeof e=="boolean"?e:void 0,Bytes:e=>e instanceof Uint8Array?e:void 0,Link:e=>e!==null&&typeof e=="object"&&e.asCID===e?e:void 0,List:e=>Array.isArray(e)?e:void 0,Map:e=>e!==null&&typeof e=="object"&&e.asCID!==e&&!Array.isArray(e)&&!(e instanceof Uint8Array)?e:void 0},be={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":j.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(j.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=be["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:j.Int,CarV1HeaderOrV2Pragma:e=>{if(j.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=be["CarV1HeaderOrV2Pragma > roots (anon)"](e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=be.Int(e[i]);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},ve={"CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)":j.Link,"CarV1HeaderOrV2Pragma > roots (anon)":e=>{if(j.List(e)!==void 0){for(let t=0;t<e.length;t++){let r=e[t];if(r=ve["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](r),r===void 0)return;if(r!==e[t]){let n=e.slice(0,t);for(let o=t;o<e.length;o++){let i=e[o];if(i=ve["CarV1HeaderOrV2Pragma > roots (anon) > valueType (anon)"](i),i===void 0)return;n.push(i)}return n}}return e}},Int:j.Int,CarV1HeaderOrV2Pragma:e=>{if(j.Map(e)===void 0)return;let t=Object.entries(e),r=e,n=1;for(let o=0;o<t.length;o++){let[i,a]=t[o];switch(i){case"roots":{let u=ve["CarV1HeaderOrV2Pragma > roots (anon)"](a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.roots=u}}break;case"version":{n--;let u=ve.Int(a);if(u===void 0)return;if(u!==a||r!==e){if(r===e){r={};for(let c=0;c<o;c++)r[t[c][0]]=t[c][1]}r.version=u}}break;default:return}}if(!(n>0))return r}},kt={toTyped:be.CarV1HeaderOrV2Pragma,toRepresentation:ve.CarV1HeaderOrV2Pragma};var ya=ot();var ii=Ue(Ge(),1);var ba=[new d(s.map,2),new d(s.string,"version"),new d(s.uint,1),new d(s.string,"roots")],va=new d(s.tag,42);async function At(e,t){let r=Et(await e.upTo(8),e);if(r===0)throw new Error("Invalid CAR header (zero length)");let n=await e.exactly(r,!0),o=wt(n);if(kt.toTyped(o)===void 0)throw new Error("Invalid CAR header format");if(o.version!==1&&o.version!==2||t!==void 0&&o.version!==t)throw new Error(`Invalid CAR version: ${o.version}${t!==void 0?` (expected ${t})`:""}`);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=_t(await e.exactly(vt,!0));e.seek(i.dataOffset-e.pos);let a=await At(e,1);return Object.assign(a,i)}function Ee(e){let t=0;return{async upTo(r){return e.subarray(t,t+Math.min(r,e.length-t))},async exactly(r,n=!1){if(r>e.length-t)throw new Error("Unexpected end of data");let o=e.subarray(t,t+r);return n&&(t+=r),o},seek(r){t+=r},get pos(){return t}}}var Tt=Ue(Ge(),1),pn=1;function It(e){let t=mt({version:pn,roots:e}),r=Tt.default.encode(t.length),n=new Uint8Array(r.length+t.length);return n.set(r,0),n.set(t,r.length),n}function yn(e){return{async setRoots(t){let r=It(t);await e.write(r)},async writeBlock(t){let{cid:r,bytes:n}=t;await e.write(new Uint8Array(Tt.default.encode(r.bytes.length+n.length))),await e.write(r.bytes),n.length&&await e.write(n)},async close(){await e.end()},version(){return pn}}}function We(){}function mn(){let e=[],t=null,r=We,n=!1,o=null,i=We,a=()=>(t||(t=new Promise(p=>{r=()=>{t=null,r=We,p()}})),t),u={write(p){e.push(p);let l=a();return i(),l},async end(){n=!0;let p=a();i(),await p}},c={async next(){let p=e.shift();return p?(e.length===0&&r(),{done:!1,value:p}):n?(r(),{done:!0,value:void 0}):(o||(o=new Promise(l=>{i=()=>(o=null,i=We,l(c.next()))})),o)}};return{writer:u,iterator:c}}var _e=class e{constructor(t,r){this._encoder=r,this._mutex=r.setRoots(t),this._ended=!1}async put(t){if(!(t.bytes instanceof Uint8Array)||!t.cid)throw new TypeError("Can only write {cid, bytes} objects");if(this._ended)throw new Error("Already closed");let r=g.asCID(t.cid);if(!r)throw new TypeError("Can only write {cid, bytes} objects");return this._mutex=this._mutex.then(()=>this._encoder.writeBlock({cid:r,bytes:t.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(t){t=ui(t);let{encoder:r,iterator:n}=wn(),o=new e(t,r),i=new je(n);return{writer:o,out:i}}static createAppender(){let{encoder:t,iterator:r}=wn();t.setRoots=()=>Promise.resolve();let n=new e([],t),o=new je(r);return{writer:n,out:o}}static async updateRootsInBytes(t,r){let n=Ee(t);await At(n);let o=It(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 t.set(o,0),t}},je=class{constructor(t){this._iterator=t}[Symbol.asyncIterator](){if(this._iterating)throw new Error("Multiple iterator not supported");return this._iterating=!0,this._iterator}};function wn(){let e=mn(),{writer:t,iterator:r}=e;return{encoder:yn(t),iterator:r}}function ui(e){if(e===void 0)return[];if(!Array.isArray(e)){let r=g.asCID(e);if(!r)throw new TypeError("roots must be a single CID or an array of CIDs");return[r]}let t=[];for(let r of e){let n=g.asCID(r);if(!n)throw new TypeError("roots must be a single CID or an array of CIDs");t.push(n)}return t}function fi(e){return e[Symbol.asyncIterator]!=null}function di(e){if(fi(e))return(async()=>{for await(let t of e);})();for(let t of e);}var gn=di;function li(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var xn=li;function hi(e){return e[Symbol.asyncIterator]!=null}function pi(e,t){let r=0;if(hi(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=xn(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let a=t(o,r++);if(typeof a.then=="function")return async function*(){yield await a;for await(let c of n)yield t(c,r++)}();let u=t;return function*(){yield a;for(let c of n)yield u(c,r++)}()}var bn=pi;function Ke({enumerable:e=!0,configurable:t=!1}={}){return{enumerable:e,configurable:t,writable:!1}}function*mi(e,t){if(t!=null&&typeof t=="object")if(Array.isArray(t))for(let[r,n]of t.entries()){let o=[...e,r],i=g.asCID(n);i!=null?yield[o.join("/"),i]:typeof n=="object"&&(yield*Ct(n,o))}else{let r=g.asCID(t);r!=null?yield[e.join("/"),r]:yield*Ct(t,e)}}function*Ct(e,t){if(e==null||e instanceof Uint8Array)return;let r=g.asCID(e);r!=null&&(yield[t.join("/"),r]);for(let[n,o]of Object.entries(e)){let i=[...t,n];yield*mi(i,o)}}function*wi(e,t){if(Array.isArray(t))for(let[r,n]of t.entries()){let o=[...e,r];yield o.join("/"),typeof n=="object"&&g.asCID(n)==null&&(yield*St(n,o))}else yield*St(t,e)}function*St(e,t){if(!(e==null||typeof e!="object"))for(let[r,n]of Object.entries(e)){let o=[...t,r];yield o.join("/"),n!=null&&!(n instanceof Uint8Array)&&typeof n=="object"&&g.asCID(n)==null&&(yield*wi(o,n))}}function gi(e,t){let r=e;for(let[n,o]of t.entries()){if(r=r[o],r==null)throw new Error(`Object has no property at ${t.slice(0,n+1).map(a=>`[${JSON.stringify(a)}]`).join("")}`);let i=g.asCID(r);if(i!=null)return{value:i,remaining:t.slice(n+1).join("/")}}return{value:r}}var Ut=class{cid;bytes;value;asBlock;constructor({cid:t,bytes:r,value:n}){if(t==null||r==null||typeof n>"u")throw new Error("Missing required argument");this.cid=t,this.bytes=r,this.value=n,this.asBlock=this,Object.defineProperties(this,{cid:Ke(),bytes:Ke(),value:Ke(),asBlock:Ke()})}links(){return Ct(this.value,[])}tree(){return St(this.value,[])}get(t="/"){return gi(this.value,t.split("/").filter(Boolean))}};function vn({bytes:e,cid:t,value:r,codec:n}){let o=r!==void 0?r:n?.decode(e);if(o===void 0)throw new Error('Missing required argument, must either provide "value" or "codec"');return new Ut({cid:t,bytes:e,value:o})}function Bt(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var Ot=Ue(_n(),1);var Ae=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Dt=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},kn=e=>globalThis.DOMException===void 0?new Dt(e):new DOMException(e),An=e=>{let t=e.reason===void 0?kn("This operation was aborted."):e.reason;return t instanceof Error?t:kn(t)};function Mt(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,a,c=new Promise((p,l)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:E}=t;E.aborted&&l(An(E)),E.addEventListener("abort",()=>{l(An(E))})}if(r===Number.POSITIVE_INFINITY){e.then(p,l);return}let m=new Ae;a=i.setTimeout.call(void 0,()=>{if(n){try{p(n())}catch(E){l(E)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?p():o instanceof Error?l(o):(m.message=o??`Promise timed out after ${r} milliseconds`,l(m))},r),(async()=>{try{p(await e)}catch(E){l(E)}})()}).finally(()=>{c.clear()});return c.clear=()=>{i.clearTimeout.call(void 0,a),a=void 0},c}function Rt(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),a=n+i;r(e[a],t)<=0?(n=++a,o-=i+1):o=i}return n}var Te=class{#e=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,run:t};if(this.size&&this.#e[this.size-1].priority>=r.priority){this.#e.push(n);return}let o=Rt(this.#e,n,(i,a)=>a.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(t){return this.#e.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#e.length}};var Ie=class extends Ot.default{#e;#s;#i=0;#h;#a;#p=0;#r;#c;#t;#y;#n=0;#u;#o;#m;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Te,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#e=t.carryoverConcurrencyCount,this.#s=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#h=t.intervalCap,this.#a=t.interval,this.#t=new t.queueClass,this.#y=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#m=t.throwOnTimeout===!0,this.#o=t.autoStart===!1}get#x(){return this.#s||this.#i<this.#h}get#b(){return this.#n<this.#u}#v(){this.#n--,this.#f(),this.emit("next")}#E(){this.#g(),this.#w(),this.#c=void 0}get#_(){let t=Date.now();if(this.#r===void 0){let r=this.#p-t;if(r<0)this.#i=this.#e?this.#n:0;else return this.#c===void 0&&(this.#c=setTimeout(()=>{this.#E()},r)),!0}return!1}#f(){if(this.#t.size===0)return this.#r&&clearInterval(this.#r),this.#r=void 0,this.emit("empty"),this.#n===0&&this.emit("idle"),!1;if(!this.#o){let t=!this.#_;if(this.#x&&this.#b){let r=this.#t.dequeue();return r?(this.emit("active"),r(),t&&this.#w(),!0):!1}}return!1}#w(){this.#s||this.#r!==void 0||(this.#r=setInterval(()=>{this.#g()},this.#a),this.#p=Date.now()+this.#a)}#g(){this.#i===0&&this.#n===0&&this.#r&&(clearInterval(this.#r),this.#r=void 0),this.#i=this.#e?this.#n:0,this.#d()}#d(){for(;this.#f(););}get concurrency(){return this.#u}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#u=t,this.#d()}async#k(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,r={}){return r={timeout:this.timeout,throwOnTimeout:this.#m,...r},new Promise((n,o)=>{this.#t.enqueue(async()=>{this.#n++,this.#i++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=Mt(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#k(r.signal)]));let a=await i;n(a),this.emit("completed",a)}catch(i){if(i instanceof Ae&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},r),this.emit("add"),this.#f()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#o?(this.#o=!1,this.#d(),this):this}pause(){this.#o=!0}clear(){this.#t=new this.#y}async onEmpty(){this.#t.size!==0&&await this.#l("empty")}async onSizeLessThan(t){this.#t.size<t||await this.#l("next",()=>this.#t.size<t)}async onIdle(){this.#n===0&&this.#t.size===0||await this.#l("idle")}async#l(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#t.size}sizeBy(t){return this.#t.filter(t).length}get pending(){return this.#n}get isPaused(){return this.#o}};var vi=1,zt=class{components;constructor(t,r){this.components=t}async import(t,r){await gn(this.components.blockstore.putMany(bn(t.blocks(),({cid:n,bytes:o})=>({cid:n,block:o})),r))}async export(t,r,n){let o=Bt(),i=Array.isArray(t)?t:[t],a=new Ie({concurrency:vi});a.on("idle",()=>{o.resolve()}),a.on("error",u=>{a.clear(),o.reject(u)});for(let u of i)a.add(async()=>{await this.#e(u,a,async(c,p)=>{n?.blockFilter?.has(c.multihash.bytes)!==!0&&(n?.blockFilter?.add(c.multihash.bytes),await r.put({cid:c,bytes:p}))},n)}).catch(()=>{});try{await o.promise}finally{await r.close()}}async*stream(t,r){let{writer:n,out:o}=_e.create(t);this.export(t,n,r).catch(()=>{});for await(let i of o)yield i}async#e(t,r,n,o){let i=await this.components.getCodec(t.code),a=await this.components.blockstore.get(t,o);await n(t,a);let u=vn({bytes:a,cid:t,codec:i});for await(let[,c]of u.links())r.add(async()=>{await this.#e(c,r,n,o)})}};function Ei(e,t={}){return new zt(e,t)}return Nn(_i);})();
|
|
3
3
|
return HeliaCar}));
|
package/dist/src/index.d.ts
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
* import { Readable } from 'node:stream'
|
|
18
18
|
* import nodeFs from 'node:fs'
|
|
19
19
|
*
|
|
20
|
-
* const helia = createHelia({
|
|
20
|
+
* const helia = await createHelia({
|
|
21
21
|
* // ... helia config
|
|
22
22
|
* })
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
24
|
*
|
|
25
25
|
* // add some UnixFS data
|
|
26
|
-
* const cid = await fs.addBytes(
|
|
26
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
27
27
|
*
|
|
28
28
|
* // export it as a Car
|
|
29
29
|
* const c = car(helia)
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* import { Readable } from 'node:stream'
|
|
47
47
|
* import nodeFs from 'node:fs'
|
|
48
48
|
*
|
|
49
|
-
* const helia = createHelia({
|
|
49
|
+
* const helia = await createHelia({
|
|
50
50
|
* // ... helia config
|
|
51
51
|
* })
|
|
52
52
|
*
|
|
@@ -54,23 +54,24 @@
|
|
|
54
54
|
* const inStream = nodeFs.createReadStream('example.car')
|
|
55
55
|
* const reader = await CarReader.fromIterable(inStream)
|
|
56
56
|
*
|
|
57
|
+
* const c = car(helia)
|
|
57
58
|
* await c.import(reader)
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
60
61
|
import { CarWriter } from '@ipld/car';
|
|
61
|
-
import type {
|
|
62
|
+
import type { CodecLoader } from '@helia/interface';
|
|
62
63
|
import type { GetBlockProgressEvents, PutManyBlocksProgressEvents } from '@helia/interface/blocks';
|
|
63
64
|
import type { CarReader } from '@ipld/car';
|
|
64
|
-
import type { AbortOptions } from '@libp2p/
|
|
65
|
+
import type { AbortOptions } from '@libp2p/interface';
|
|
65
66
|
import type { Filter } from '@libp2p/utils/filters';
|
|
66
67
|
import type { Blockstore } from 'interface-blockstore';
|
|
67
68
|
import type { CID } from 'multiformats/cid';
|
|
68
69
|
import type { ProgressOptions } from 'progress-events';
|
|
69
70
|
export interface CarComponents {
|
|
70
71
|
blockstore: Blockstore;
|
|
71
|
-
|
|
72
|
+
getCodec: CodecLoader;
|
|
72
73
|
}
|
|
73
|
-
interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
74
|
+
export interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
74
75
|
/**
|
|
75
76
|
* If a filter is passed it will be used to deduplicate blocks exported in the car file
|
|
76
77
|
*/
|
|
@@ -154,9 +155,5 @@ export interface Car {
|
|
|
154
155
|
/**
|
|
155
156
|
* Create a {@link Car} instance for use with {@link https://github.com/ipfs/helia Helia}
|
|
156
157
|
*/
|
|
157
|
-
export declare function car(helia:
|
|
158
|
-
blockstore: Blockstore;
|
|
159
|
-
dagWalkers: Record<number, DAGWalker>;
|
|
160
|
-
}, init?: any): Car;
|
|
161
|
-
export {};
|
|
158
|
+
export declare function car(helia: CarComponents, init?: any): Car;
|
|
162
159
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAMrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAClG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AACrD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,WAAW,CAAA;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,YAAY,EAAE,eAAe,CAAC,sBAAsB,CAAC;IAC7F;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,2BAA2B,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE/H;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE9G;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,eAAe,CAAC,sBAAsB,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAAA;CACxH;AA2FD;;GAEG;AACH,wBAAgB,GAAG,CAAE,KAAK,EAAE,aAAa,EAAE,IAAI,GAAE,GAAQ,GAAG,GAAG,CAE9D"}
|
package/dist/src/index.js
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
* import { Readable } from 'node:stream'
|
|
18
18
|
* import nodeFs from 'node:fs'
|
|
19
19
|
*
|
|
20
|
-
* const helia = createHelia({
|
|
20
|
+
* const helia = await createHelia({
|
|
21
21
|
* // ... helia config
|
|
22
22
|
* })
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
24
|
*
|
|
25
25
|
* // add some UnixFS data
|
|
26
|
-
* const cid = await fs.addBytes(
|
|
26
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
27
27
|
*
|
|
28
28
|
* // export it as a Car
|
|
29
29
|
* const c = car(helia)
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* import { Readable } from 'node:stream'
|
|
47
47
|
* import nodeFs from 'node:fs'
|
|
48
48
|
*
|
|
49
|
-
* const helia = createHelia({
|
|
49
|
+
* const helia = await createHelia({
|
|
50
50
|
* // ... helia config
|
|
51
51
|
* })
|
|
52
52
|
*
|
|
@@ -54,12 +54,14 @@
|
|
|
54
54
|
* const inStream = nodeFs.createReadStream('example.car')
|
|
55
55
|
* const reader = await CarReader.fromIterable(inStream)
|
|
56
56
|
*
|
|
57
|
+
* const c = car(helia)
|
|
57
58
|
* await c.import(reader)
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
60
61
|
import { CarWriter } from '@ipld/car';
|
|
61
62
|
import drain from 'it-drain';
|
|
62
63
|
import map from 'it-map';
|
|
64
|
+
import { createUnsafe } from 'multiformats/block';
|
|
63
65
|
import defer from 'p-defer';
|
|
64
66
|
import PQueue from 'p-queue';
|
|
65
67
|
const DAG_WALK_QUEUE_CONCURRENCY = 1;
|
|
@@ -121,14 +123,12 @@ class DefaultCar {
|
|
|
121
123
|
* and update the pin count for them
|
|
122
124
|
*/
|
|
123
125
|
async #walkDag(cid, queue, withBlock, options) {
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
const block = await this.components.blockstore.get(cid, options);
|
|
129
|
-
await withBlock(cid, block);
|
|
126
|
+
const codec = await this.components.getCodec(cid.code);
|
|
127
|
+
const bytes = await this.components.blockstore.get(cid, options);
|
|
128
|
+
await withBlock(cid, bytes);
|
|
129
|
+
const block = createUnsafe({ bytes, cid, codec });
|
|
130
130
|
// walk dag, ensure all blocks are present
|
|
131
|
-
for await (const cid of
|
|
131
|
+
for await (const [, cid] of block.links()) {
|
|
132
132
|
void queue.add(async () => {
|
|
133
133
|
await this.#walkDag(cid, queue, withBlock, options);
|
|
134
134
|
});
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,MAAM,SAAS,CAAA;AAC3B,OAAO,MAAM,MAAM,SAAS,CAAA;AAoG5B,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAEpC,MAAM,UAAU;IACG,UAAU,CAAe;IAE1C,YAAa,UAAyB,EAAE,IAAS;QAC/C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,MAAiC,EAAE,OAAqE;QACpH,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAC5C,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,EACjE,OAAO,CACR,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,MAAM,CAAE,IAAiB,EAAE,MAAwC,EAAE,OAA0B;QACnG,MAAM,QAAQ,GAAG,KAAK,EAAqB,CAAA;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QAEjD,sFAAsF;QACtF,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC;YACvB,WAAW,EAAE,0BAA0B;SACxC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;YACpB,QAAQ,CAAC,OAAO,EAAE,CAAA;QACpB,CAAC,CAAC,CAAA;QACF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,KAAK,CAAC,KAAK,EAAE,CAAA;YACb,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACtB,CAAC,CAAC,CAAA;QAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;gBACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;oBACpD,0EAA0E;oBAC1E,IAAI,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;wBAC5D,OAAM;oBACR,CAAC;oBAED,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;oBAC9C,MAAM,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;gBAClC,CAAC,EAAE,OAAO,CAAC,CAAA;YACb,CAAC,CAAC;iBACC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QACpB,CAAC;QAED,6BAA6B;QAC7B,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,OAAO,CAAA;QACxB,CAAC;gBAAS,CAAC;YACT,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAE,MAAM,CAAE,IAAiB,EAAE,OAA0B;QAC3D,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAE9C,0EAA0E;QAC1E,YAAY;QACZ,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC;aAC/B,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAElB,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;YAC5B,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAE,GAAQ,EAAE,KAAa,EAAE,SAAyD,EAAE,OAAgE;QAClK,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACtD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAEhE,MAAM,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAE3B,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;QAEjD,0CAA0C;QAC1C,IAAI,KAAK,EAAE,MAAM,CAAC,EAAC,GAAG,CAAC,IAAI,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;YACzC,KAAK,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;gBACxB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;YACrD,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CAAE,KAAoB,EAAE,OAAY,EAAE;IACvD,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AACpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helia/car",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.1-2f88fc8",
|
|
4
4
|
"description": "Import/export car files from Helia",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/helia/tree/main/packages/car#readme",
|
|
@@ -128,6 +128,7 @@
|
|
|
128
128
|
"clean": "aegir clean",
|
|
129
129
|
"lint": "aegir lint",
|
|
130
130
|
"dep-check": "aegir dep-check",
|
|
131
|
+
"doc-check": "aegir doc-check",
|
|
131
132
|
"build": "aegir build",
|
|
132
133
|
"test": "aegir test",
|
|
133
134
|
"test:chrome": "aegir test -t browser --cov",
|
|
@@ -139,10 +140,10 @@
|
|
|
139
140
|
"release": "aegir release"
|
|
140
141
|
},
|
|
141
142
|
"dependencies": {
|
|
142
|
-
"@helia/interface": "
|
|
143
|
+
"@helia/interface": "4.3.1-2f88fc8",
|
|
143
144
|
"@ipld/car": "^5.3.0",
|
|
144
|
-
"@libp2p/
|
|
145
|
-
"@libp2p/utils": "^
|
|
145
|
+
"@libp2p/interface": "^2.0.0",
|
|
146
|
+
"@libp2p/utils": "^6.0.0",
|
|
146
147
|
"interface-blockstore": "^5.2.10",
|
|
147
148
|
"it-drain": "^3.0.5",
|
|
148
149
|
"it-map": "^3.0.5",
|
|
@@ -152,12 +153,12 @@
|
|
|
152
153
|
"progress-events": "^1.0.0"
|
|
153
154
|
},
|
|
154
155
|
"devDependencies": {
|
|
155
|
-
"@helia/mfs": "
|
|
156
|
-
"@helia/unixfs": "
|
|
156
|
+
"@helia/mfs": "3.0.8-2f88fc8",
|
|
157
|
+
"@helia/unixfs": "3.0.7-2f88fc8",
|
|
157
158
|
"@ipld/dag-pb": "^4.1.0",
|
|
158
159
|
"aegir": "^44.0.1",
|
|
159
|
-
"blockstore-core": "^
|
|
160
|
-
"datastore-core": "^
|
|
160
|
+
"blockstore-core": "^5.0.0",
|
|
161
|
+
"datastore-core": "^10.0.0",
|
|
161
162
|
"ipfs-unixfs-importer": "^15.2.4",
|
|
162
163
|
"it-to-buffer": "^4.0.5"
|
|
163
164
|
},
|
package/src/index.ts
CHANGED
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
* import { Readable } from 'node:stream'
|
|
18
18
|
* import nodeFs from 'node:fs'
|
|
19
19
|
*
|
|
20
|
-
* const helia = createHelia({
|
|
20
|
+
* const helia = await createHelia({
|
|
21
21
|
* // ... helia config
|
|
22
22
|
* })
|
|
23
23
|
* const fs = unixfs(helia)
|
|
24
24
|
*
|
|
25
25
|
* // add some UnixFS data
|
|
26
|
-
* const cid = await fs.addBytes(
|
|
26
|
+
* const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))
|
|
27
27
|
*
|
|
28
28
|
* // export it as a Car
|
|
29
29
|
* const c = car(helia)
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
* import { Readable } from 'node:stream'
|
|
47
47
|
* import nodeFs from 'node:fs'
|
|
48
48
|
*
|
|
49
|
-
* const helia = createHelia({
|
|
49
|
+
* const helia = await createHelia({
|
|
50
50
|
* // ... helia config
|
|
51
51
|
* })
|
|
52
52
|
*
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
* const inStream = nodeFs.createReadStream('example.car')
|
|
55
55
|
* const reader = await CarReader.fromIterable(inStream)
|
|
56
56
|
*
|
|
57
|
+
* const c = car(helia)
|
|
57
58
|
* await c.import(reader)
|
|
58
59
|
* ```
|
|
59
60
|
*/
|
|
@@ -61,12 +62,13 @@
|
|
|
61
62
|
import { CarWriter } from '@ipld/car'
|
|
62
63
|
import drain from 'it-drain'
|
|
63
64
|
import map from 'it-map'
|
|
65
|
+
import { createUnsafe } from 'multiformats/block'
|
|
64
66
|
import defer from 'p-defer'
|
|
65
67
|
import PQueue from 'p-queue'
|
|
66
|
-
import type {
|
|
68
|
+
import type { CodecLoader } from '@helia/interface'
|
|
67
69
|
import type { GetBlockProgressEvents, PutManyBlocksProgressEvents } from '@helia/interface/blocks'
|
|
68
70
|
import type { CarReader } from '@ipld/car'
|
|
69
|
-
import type { AbortOptions } from '@libp2p/
|
|
71
|
+
import type { AbortOptions } from '@libp2p/interface'
|
|
70
72
|
import type { Filter } from '@libp2p/utils/filters'
|
|
71
73
|
import type { Blockstore } from 'interface-blockstore'
|
|
72
74
|
import type { CID } from 'multiformats/cid'
|
|
@@ -74,10 +76,10 @@ import type { ProgressOptions } from 'progress-events'
|
|
|
74
76
|
|
|
75
77
|
export interface CarComponents {
|
|
76
78
|
blockstore: Blockstore
|
|
77
|
-
|
|
79
|
+
getCodec: CodecLoader
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
82
|
+
export interface ExportCarOptions extends AbortOptions, ProgressOptions<GetBlockProgressEvents> {
|
|
81
83
|
/**
|
|
82
84
|
* If a filter is passed it will be used to deduplicate blocks exported in the car file
|
|
83
85
|
*/
|
|
@@ -235,18 +237,15 @@ class DefaultCar implements Car {
|
|
|
235
237
|
* and update the pin count for them
|
|
236
238
|
*/
|
|
237
239
|
async #walkDag (cid: CID, queue: PQueue, withBlock: (cid: CID, block: Uint8Array) => Promise<void>, options?: AbortOptions & ProgressOptions<GetBlockProgressEvents>): Promise<void> {
|
|
238
|
-
const
|
|
239
|
-
|
|
240
|
-
if (dagWalker == null) {
|
|
241
|
-
throw new Error(`No dag walker found for cid codec ${cid.code}`)
|
|
242
|
-
}
|
|
240
|
+
const codec = await this.components.getCodec(cid.code)
|
|
241
|
+
const bytes = await this.components.blockstore.get(cid, options)
|
|
243
242
|
|
|
244
|
-
|
|
243
|
+
await withBlock(cid, bytes)
|
|
245
244
|
|
|
246
|
-
|
|
245
|
+
const block = createUnsafe({ bytes, cid, codec })
|
|
247
246
|
|
|
248
247
|
// walk dag, ensure all blocks are present
|
|
249
|
-
for await (const cid of
|
|
248
|
+
for await (const [,cid] of block.links()) {
|
|
250
249
|
void queue.add(async () => {
|
|
251
250
|
await this.#walkDag(cid, queue, withBlock, options)
|
|
252
251
|
})
|
|
@@ -257,6 +256,6 @@ class DefaultCar implements Car {
|
|
|
257
256
|
/**
|
|
258
257
|
* Create a {@link Car} instance for use with {@link https://github.com/ipfs/helia Helia}
|
|
259
258
|
*/
|
|
260
|
-
export function car (helia:
|
|
259
|
+
export function car (helia: CarComponents, init: any = {}): Car {
|
|
261
260
|
return new DefaultCar(helia, init)
|
|
262
261
|
}
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Car": "https://ipfs.github.io/helia/interfaces/_helia_car.Car.html",
|
|
3
|
-
".:Car": "https://ipfs.github.io/helia/interfaces/_helia_car.Car.html",
|
|
4
|
-
"CarComponents": "https://ipfs.github.io/helia/interfaces/_helia_car.CarComponents.html",
|
|
5
|
-
".:CarComponents": "https://ipfs.github.io/helia/interfaces/_helia_car.CarComponents.html",
|
|
6
|
-
"car": "https://ipfs.github.io/helia/functions/_helia_car.car-1.html",
|
|
7
|
-
".:car": "https://ipfs.github.io/helia/functions/_helia_car.car-1.html"
|
|
8
|
-
}
|