ipfs-unixfs-importer 15.2.3 → 15.2.4
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 +12 -66
- package/dist/index.min.js +1 -1
- package/dist/src/chunker/index.d.ts +8 -0
- package/dist/src/chunker/index.d.ts.map +1 -1
- package/dist/src/chunker/index.js +8 -0
- package/dist/src/chunker/index.js.map +1 -1
- package/dist/src/index.d.ts +63 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +63 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/layout/index.d.ts +7 -0
- package/dist/src/layout/index.d.ts.map +1 -1
- package/dist/src/layout/index.js +7 -0
- package/dist/src/layout/index.js.map +1 -1
- package/dist/typedoc-urls.json +61 -0
- package/package.json +8 -96
- package/src/chunker/index.ts +9 -0
- package/src/index.ts +64 -0
- package/src/layout/index.ts +8 -0
package/README.md
CHANGED
|
@@ -7,40 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
> JavaScript implementation of the UnixFs importer used by IPFS
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- [Install](#install)
|
|
13
|
-
- [Browser `<script>` tag](#browser-script-tag)
|
|
14
|
-
- [Example](#example)
|
|
15
|
-
- [API](#api)
|
|
16
|
-
- [const stream = importer(source, blockstore \[, options\])](#const-stream--importersource-blockstore--options)
|
|
17
|
-
- [const result = await importFile(content, blockstore \[, options\])](#const-result--await-importfilecontent-blockstore--options)
|
|
18
|
-
- [const result = await importDirectory(content, blockstore \[, options\])](#const-result--await-importdirectorycontent-blockstore--options)
|
|
19
|
-
- [const result = await importBytes(buf, blockstore \[, options\])](#const-result--await-importbytesbuf-blockstore--options)
|
|
20
|
-
- [const result = await importByteStream(source, blockstore \[, options\])](#const-result--await-importbytestreamsource-blockstore--options)
|
|
21
|
-
- [API Docs](#api-docs)
|
|
22
|
-
- [License](#license)
|
|
23
|
-
- [Contribute](#contribute)
|
|
24
|
-
|
|
25
|
-
## Install
|
|
26
|
-
|
|
27
|
-
```console
|
|
28
|
-
$ npm i ipfs-unixfs-importer
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Browser `<script>` tag
|
|
32
|
-
|
|
33
|
-
Loading this module through a script tag will make it's exports available as `IpfsUnixfsImporter` in the global namespace.
|
|
34
|
-
|
|
35
|
-
```html
|
|
36
|
-
<script src="https://unpkg.com/ipfs-unixfs-importer/dist/index.min.js"></script>
|
|
37
|
-
```
|
|
10
|
+
# About
|
|
38
11
|
|
|
39
12
|
## Example
|
|
40
13
|
|
|
41
14
|
Let's create a little directory to import:
|
|
42
15
|
|
|
43
|
-
```
|
|
16
|
+
```console
|
|
44
17
|
> cd /tmp
|
|
45
18
|
> mkdir foo
|
|
46
19
|
> echo 'hello' > foo/bar
|
|
@@ -96,59 +69,32 @@ When run, metadata about DAGNodes in the created tree is printed until the root:
|
|
|
96
69
|
}
|
|
97
70
|
```
|
|
98
71
|
|
|
99
|
-
|
|
72
|
+
# Install
|
|
100
73
|
|
|
101
|
-
```
|
|
102
|
-
|
|
74
|
+
```console
|
|
75
|
+
$ npm i ipfs-unixfs-importer
|
|
103
76
|
```
|
|
104
77
|
|
|
105
|
-
|
|
78
|
+
## Browser `<script>` tag
|
|
106
79
|
|
|
107
|
-
|
|
80
|
+
Loading this module through a script tag will make it's exports available as `IpfsUnixfsImporter` in the global namespace.
|
|
108
81
|
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
path: 'a name',
|
|
112
|
-
content: (Buffer or iterator emitting Buffers),
|
|
113
|
-
mtime: (Number representing seconds since (positive) or before (negative) the Unix Epoch),
|
|
114
|
-
mode: (Number representing ugo-rwx, setuid, setguid and sticky bit)
|
|
115
|
-
}
|
|
82
|
+
```html
|
|
83
|
+
<script src="https://unpkg.com/ipfs-unixfs-importer/dist/index.min.js"></script>
|
|
116
84
|
```
|
|
117
85
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
`blockstore` is an instance of a [blockstore][]
|
|
121
|
-
|
|
122
|
-
The input's file paths and directory structure will be preserved in the [`dag-pb`](https://github.com/ipld/js-dag-pb) created nodes.
|
|
123
|
-
|
|
124
|
-
### const result = await importFile(content, blockstore \[, options])
|
|
125
|
-
|
|
126
|
-
A convenience function for importing a single file or directory.
|
|
127
|
-
|
|
128
|
-
### const result = await importDirectory(content, blockstore \[, options])
|
|
129
|
-
|
|
130
|
-
A convenience function for importing a directory - note this is non-recursive, to import recursively use the [importer](#const-stream--importersource-blockstore--options) function.
|
|
131
|
-
|
|
132
|
-
### const result = await importBytes(buf, blockstore \[, options])
|
|
133
|
-
|
|
134
|
-
A convenience function for importing a single Uint8Array.
|
|
135
|
-
|
|
136
|
-
### const result = await importByteStream(source, blockstore \[, options])
|
|
137
|
-
|
|
138
|
-
A convenience function for importing a single stream of Uint8Arrays.
|
|
139
|
-
|
|
140
|
-
## API Docs
|
|
86
|
+
# API Docs
|
|
141
87
|
|
|
142
88
|
- <https://ipfs.github.io/js-ipfs-unixfs/modules/ipfs_unixfs_importer.html>
|
|
143
89
|
|
|
144
|
-
|
|
90
|
+
# License
|
|
145
91
|
|
|
146
92
|
Licensed under either of
|
|
147
93
|
|
|
148
94
|
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
149
95
|
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
150
96
|
|
|
151
|
-
|
|
97
|
+
# Contribute
|
|
152
98
|
|
|
153
99
|
Contributions welcome! Please check out [the issues](https://github.com/ipfs/js-ipfs-unixfs/issues).
|
|
154
100
|
|
package/dist/index.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpfsUnixfsImporter = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var IpfsUnixfsImporter=(()=>{var Zi=Object.create;var re=Object.defineProperty;var Yi=Object.getOwnPropertyDescriptor;var to=Object.getOwnPropertyNames;var eo=Object.getPrototypeOf,ro=Object.prototype.hasOwnProperty;var ne=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),E=(r,t)=>{for(var e in t)re(r,e,{get:t[e],enumerable:!0})},Xr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of to(t))!ro.call(r,i)&&i!==e&&re(r,i,{get:()=>t[i],enumerable:!(n=Yi(t,i))||n.enumerable});return r};var st=(r,t,e)=>(e=r!=null?Zi(eo(r)):{},Xr(t||!r||!r.__esModule?re(e,"default",{value:r,enumerable:!0}):e,r)),no=r=>Xr(re({},"__esModule",{value:!0}),r);var St=ne((ih,Wr)=>{"use strict";function Kr(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function io(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return Kr(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),Kr(new i,e)}}Wr.exports=io});var zi=ne((Zt,be)=>{(function(r,t){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(a){if(!Array.isArray(a)&&!ArrayBuffer.isView(a))return!1;for(var h=0;h<a.length;h++)if(!Number.isInteger(a[h])||a[h]<0||a[h]>255)return!1;return!0}function i(a,h){return(a&65535)*h+(((a>>>16)*h&65535)<<16)}function o(a,h){return a<<h|a>>>32-h}function s(a){return a^=a>>>16,a=i(a,2246822507),a^=a>>>13,a=i(a,3266489909),a^=a>>>16,a}function c(a,h){a=[a[0]>>>16,a[0]&65535,a[1]>>>16,a[1]&65535],h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535];var l=[0,0,0,0];return l[3]+=a[3]+h[3],l[2]+=l[3]>>>16,l[3]&=65535,l[2]+=a[2]+h[2],l[1]+=l[2]>>>16,l[2]&=65535,l[1]+=a[1]+h[1],l[0]+=l[1]>>>16,l[1]&=65535,l[0]+=a[0]+h[0],l[0]&=65535,[l[0]<<16|l[1],l[2]<<16|l[3]]}function u(a,h){a=[a[0]>>>16,a[0]&65535,a[1]>>>16,a[1]&65535],h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535];var l=[0,0,0,0];return l[3]+=a[3]*h[3],l[2]+=l[3]>>>16,l[3]&=65535,l[2]+=a[2]*h[3],l[1]+=l[2]>>>16,l[2]&=65535,l[2]+=a[3]*h[2],l[1]+=l[2]>>>16,l[2]&=65535,l[1]+=a[1]*h[3],l[0]+=l[1]>>>16,l[1]&=65535,l[1]+=a[2]*h[2],l[0]+=l[1]>>>16,l[1]&=65535,l[1]+=a[3]*h[1],l[0]+=l[1]>>>16,l[1]&=65535,l[0]+=a[0]*h[3]+a[1]*h[2]+a[2]*h[1]+a[3]*h[0],l[0]&=65535,[l[0]<<16|l[1],l[2]<<16|l[3]]}function x(a,h){return h%=64,h===32?[a[1],a[0]]:h<32?[a[0]<<h|a[1]>>>32-h,a[1]<<h|a[0]>>>32-h]:(h-=32,[a[1]<<h|a[0]>>>32-h,a[0]<<h|a[1]>>>32-h])}function f(a,h){return h%=64,h===0?a:h<32?[a[0]<<h|a[1]>>>32-h,a[1]<<h]:[a[1]<<h-32,0]}function w(a,h){return[a[0]^h[0],a[1]^h[1]]}function D(a){return a=w(a,[0,a[0]>>>1]),a=u(a,[4283543511,3981806797]),a=w(a,[0,a[0]>>>1]),a=u(a,[3301882366,444984403]),a=w(a,[0,a[0]>>>1]),a}e.x86.hash32=function(a,h){if(e.inputValidation&&!n(a))return t;h=h||0;for(var l=a.length%4,S=a.length-l,d=h,p=0,g=3432918353,m=461845907,y=0;y<S;y=y+4)p=a[y]|a[y+1]<<8|a[y+2]<<16|a[y+3]<<24,p=i(p,g),p=o(p,15),p=i(p,m),d^=p,d=o(d,13),d=i(d,5)+3864292196;switch(p=0,l){case 3:p^=a[y+2]<<16;case 2:p^=a[y+1]<<8;case 1:p^=a[y],p=i(p,g),p=o(p,15),p=i(p,m),d^=p}return d^=a.length,d=s(d),d>>>0},e.x86.hash128=function(a,h){if(e.inputValidation&&!n(a))return t;h=h||0;for(var l=a.length%16,S=a.length-l,d=h,p=h,g=h,m=h,y=0,v=0,b=0,A=0,I=597399067,Yt=2869860233,te=951274213,ee=2716044179,B=0;B<S;B=B+16)y=a[B]|a[B+1]<<8|a[B+2]<<16|a[B+3]<<24,v=a[B+4]|a[B+5]<<8|a[B+6]<<16|a[B+7]<<24,b=a[B+8]|a[B+9]<<8|a[B+10]<<16|a[B+11]<<24,A=a[B+12]|a[B+13]<<8|a[B+14]<<16|a[B+15]<<24,y=i(y,I),y=o(y,15),y=i(y,Yt),d^=y,d=o(d,19),d+=p,d=i(d,5)+1444728091,v=i(v,Yt),v=o(v,16),v=i(v,te),p^=v,p=o(p,17),p+=g,p=i(p,5)+197830471,b=i(b,te),b=o(b,17),b=i(b,ee),g^=b,g=o(g,15),g+=m,g=i(g,5)+2530024501,A=i(A,ee),A=o(A,18),A=i(A,I),m^=A,m=o(m,13),m+=d,m=i(m,5)+850148119;switch(y=0,v=0,b=0,A=0,l){case 15:A^=a[B+14]<<16;case 14:A^=a[B+13]<<8;case 13:A^=a[B+12],A=i(A,ee),A=o(A,18),A=i(A,I),m^=A;case 12:b^=a[B+11]<<24;case 11:b^=a[B+10]<<16;case 10:b^=a[B+9]<<8;case 9:b^=a[B+8],b=i(b,te),b=o(b,17),b=i(b,ee),g^=b;case 8:v^=a[B+7]<<24;case 7:v^=a[B+6]<<16;case 6:v^=a[B+5]<<8;case 5:v^=a[B+4],v=i(v,Yt),v=o(v,16),v=i(v,te),p^=v;case 4:y^=a[B+3]<<24;case 3:y^=a[B+2]<<16;case 2:y^=a[B+1]<<8;case 1:y^=a[B],y=i(y,I),y=o(y,15),y=i(y,Yt),d^=y}return d^=a.length,p^=a.length,g^=a.length,m^=a.length,d+=p,d+=g,d+=m,p+=d,g+=d,m+=d,d=s(d),p=s(p),g=s(g),m=s(m),d+=p,d+=g,d+=m,p+=d,g+=d,m+=d,("00000000"+(d>>>0).toString(16)).slice(-8)+("00000000"+(p>>>0).toString(16)).slice(-8)+("00000000"+(g>>>0).toString(16)).slice(-8)+("00000000"+(m>>>0).toString(16)).slice(-8)},e.x64.hash128=function(a,h){if(e.inputValidation&&!n(a))return t;h=h||0;for(var l=a.length%16,S=a.length-l,d=[0,h],p=[0,h],g=[0,0],m=[0,0],y=[2277735313,289559509],v=[1291169091,658871167],b=0;b<S;b=b+16)g=[a[b+4]|a[b+5]<<8|a[b+6]<<16|a[b+7]<<24,a[b]|a[b+1]<<8|a[b+2]<<16|a[b+3]<<24],m=[a[b+12]|a[b+13]<<8|a[b+14]<<16|a[b+15]<<24,a[b+8]|a[b+9]<<8|a[b+10]<<16|a[b+11]<<24],g=u(g,y),g=x(g,31),g=u(g,v),d=w(d,g),d=x(d,27),d=c(d,p),d=c(u(d,[0,5]),[0,1390208809]),m=u(m,v),m=x(m,33),m=u(m,y),p=w(p,m),p=x(p,31),p=c(p,d),p=c(u(p,[0,5]),[0,944331445]);switch(g=[0,0],m=[0,0],l){case 15:m=w(m,f([0,a[b+14]],48));case 14:m=w(m,f([0,a[b+13]],40));case 13:m=w(m,f([0,a[b+12]],32));case 12:m=w(m,f([0,a[b+11]],24));case 11:m=w(m,f([0,a[b+10]],16));case 10:m=w(m,f([0,a[b+9]],8));case 9:m=w(m,[0,a[b+8]]),m=u(m,v),m=x(m,33),m=u(m,y),p=w(p,m);case 8:g=w(g,f([0,a[b+7]],56));case 7:g=w(g,f([0,a[b+6]],48));case 6:g=w(g,f([0,a[b+5]],40));case 5:g=w(g,f([0,a[b+4]],32));case 4:g=w(g,f([0,a[b+3]],24));case 3:g=w(g,f([0,a[b+2]],16));case 2:g=w(g,f([0,a[b+1]],8));case 1:g=w(g,[0,a[b]]),g=u(g,y),g=x(g,31),g=u(g,v),d=w(d,g)}return d=w(d,[0,a.length]),p=w(p,[0,a.length]),d=c(d,p),p=c(p,d),d=D(d),p=D(p),d=c(d,p),p=c(p,d),("00000000"+(d[0]>>>0).toString(16)).slice(-8)+("00000000"+(d[1]>>>0).toString(16)).slice(-8)+("00000000"+(p[0]>>>0).toString(16)).slice(-8)+("00000000"+(p[1]>>>0).toString(16)).slice(-8)},typeof Zt<"u"?(typeof be<"u"&&be.exports&&(Zt=be.exports=e),Zt.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=r.murmurHash3,e.noConflict=function(){return r.murmurHash3=e._murmurHash3,e._murmurHash3=t,e.noConflict=t,e},r.murmurHash3=e)})(Zt)});var Pi=ne((ud,Ui)=>{Ui.exports=zi()});var Oi=ne((wd,Vi)=>{"use strict";Vi.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(t,e){let n=this._internalPositionFor(t,!1);if(e===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(t),this._changedLength=!0,this._changedData=!0);else{let i=!1;n===-1?(n=this._data.length,this._setBit(t),this._changedData=!0):i=!0,this._setInternalPos(n,t,e,i),this._changedLength=!0}}unset(t){this.set(t,void 0)}get(t){this._sortData();let e=this._internalPositionFor(t,!0);if(e!==-1)return this._data[e][1]}push(t){return this.set(this.length,t),this.length}get length(){if(this._sortData(),this._changedLength){let t=this._data[this._data.length-1];this._length=t?t[0]+1:0,this._changedLength=!1}return this._length}forEach(t){let e=0;for(;e<this.length;)t(this.get(e),e,this),e++}map(t){let e=0,n=new Array(this.length);for(;e<this.length;)n[e]=t(this.get(e),e,this),e++;return n}reduce(t,e){let n=0,i=e;for(;n<this.length;){let o=this.get(n);i=t(i,o,n),n++}return i}find(t){let e=0,n,i;for(;e<this.length&&!n;)i=this.get(e),n=t(i),e++;return n?i:void 0}_internalPositionFor(t,e){let n=this._bytePosFor(t,e);if(n>=this._bitArrays.length)return-1;let i=this._bitArrays[n],o=t-n*7;if(!((i&1<<o)>0))return-1;let c=this._bitArrays.slice(0,n).reduce(Mc,0),u=~(4294967295<<o+1),x=Mi(i&u);return c+x-1}_bytePosFor(t,e){let n=Math.floor(t/7),i=n+1;for(;!e&&this._bitArrays.length<i;)this._bitArrays.push(0);return n}_setBit(t){let e=this._bytePosFor(t,!1);this._bitArrays[e]|=1<<t-e*7}_unsetBit(t){let e=this._bytePosFor(t,!1);this._bitArrays[e]&=~(1<<t-e*7)}_setInternalPos(t,e,n,i){let o=this._data,s=[e,n];if(i)this._sortData(),o[t]=s;else{if(o.length)if(o[o.length-1][0]>=e)o.push(s);else if(o[0][0]<=e)o.unshift(s);else{let c=Math.round(o.length/2);this._data=o.slice(0,c).concat(s).concat(o.slice(c))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(t){this._data.splice(t,1)}_sortData(){this._changedData&&this._data.sort(Vc),this._changedData=!1}bitField(){let t=[],e=8,n=0,i=0,o,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(o=s.shift(),n=7);let u=Math.min(n,e),x=~(255<<u),f=o&x;i|=f<<8-e,o=o>>>u,n-=u,e-=u,(!e||!n&&!s.length)&&(t.push(i),i=0,e=8)}for(var c=t.length-1;c>0&&t[c]===0;c--)t.pop();return t}compactArray(){return this._sortData(),this._data.map(Oc)}};function Mc(r,t){return r+Mi(t)}function Mi(r){let t=r;return t=t-(t>>1&1431655765),t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}function Vc(r,t){return r[0]-t[0]}function Oc(r){return r[1]}});var rh={};E(rh,{importByteStream:()=>eh,importBytes:()=>th,importDirectory:()=>Yc,importFile:()=>Jr,importer:()=>jr});var Gr=st(St(),1);function oo(r){return r[Symbol.asyncIterator]!=null}function so(r){if(oo(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var xe=so;function ao(r){return r[Symbol.asyncIterator]!=null}function co(r,t=1){return t=Number(t),ao(r)?async function*(){let e=[];if(t<1&&(t=1),t!==Math.round(t))throw new Error("Batch size must be an integer");for await(let n of r)for(e.push(n);e.length>=t;)yield e.slice(0,t),e=e.slice(t);for(;e.length>0;)yield e.slice(0,t),e=e.slice(t)}():function*(){let e=[];if(t<1&&(t=1),t!==Math.round(t))throw new Error("Batch size must be an integer");for(let n of r)for(e.push(n);e.length>=t;)yield e.slice(0,t),e=e.slice(t);for(;e.length>0;)yield e.slice(0,t),e=e.slice(t)}()}var Dt=co;async function*Bt(r,t=1){for await(let e of Dt(r,t)){let n=e.map(async i=>i().then(o=>({ok:!0,value:o}),o=>({ok:!1,err:o})));for(let i=0;i<n.length;i++){let o=await n[i];if(o.ok)yield o.value;else throw o.err}}}function Y(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function G(r=0){return globalThis.Buffer?.alloc!=null?Y(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function P(r=0){return globalThis.Buffer?.allocUnsafe!=null?Y(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Et(r,t){t==null&&(t=r.reduce((i,o)=>i+o.length,0));let e=P(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return Y(e)}function Qr(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Yr=Symbol.for("@achingbrain/uint8arraylist");function Zr(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let i=e+n.byteLength;if(t<i)return{buf:n,index:t-e};e=i}throw new RangeError("index is out of bounds")}function ie(r){return!!r?.[Yr]}var at=class r{bufs;length;[Yr]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ie(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ie(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Zr(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Zr(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ie(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:i}=this._subList(t,e);return Et(n,i)}subarray(t,e){let{bufs:n,length:i}=this._subList(t,e);return n.length===1?n[0]:Et(n,i)}sublist(t,e){let{bufs:n,length:i}=this._subList(t,e),o=new r;return o.length=i,o.bufs=[...n],o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],i=0;for(let o=0;o<this.bufs.length;o++){let s=this.bufs[o],c=i,u=c+s.byteLength;if(i=u,t>=u)continue;let x=t>=c&&t<u,f=e>c&&e<=u;if(x&&f){if(t===c&&e===u){n.push(s);break}let w=t-c;n.push(s.subarray(w,w+(e-t)));break}if(x){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(f){if(e===u){n.push(s);break}n.push(s.subarray(0,e-c));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ie(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let o=256,s=new Int32Array(o);for(let w=0;w<o;w++)s[w]=-1;for(let w=0;w<i;w++)s[n[w]]=w;let c=s,u=this.byteLength-n.byteLength,x=n.byteLength-1,f;for(let w=e;w<=u;w+=f){f=0;for(let D=x;D>=0;D--){let a=this.get(w+D);if(n[D]!==a){f=Math.max(1,D-c[a]);break}}if(f===0)return w}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=P(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let i=G(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,e,n),this.write(i,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let i=G(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,e,n),this.write(i,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let i=G(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,e,n),this.write(i,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=P(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let i=G(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,e,n),this.write(i,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let i=G(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,e,n),this.write(i,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let i=G(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,e,n),this.write(i,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let i=G(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,e,n),this.write(i,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let i=G(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,e,n),this.write(i,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Qr(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((i,o)=>i+o.byteLength,0)),n.length=e,n}};var ho=262144,tn=(r={})=>{let t=r.chunkSize??ho;return async function*(n){let i=new at,o=0,s=!1;for await(let c of n)for(i.append(c),o+=c.length;o>=t;)if(yield i.slice(0,t),s=!0,t===i.length)i=new at,o=0;else{let u=new at;u.append(i.sublist(t)),i=u,o-=t}(!s||o>0)&&(yield i.subarray(0,o))}};var Nt={};E(Nt,{code:()=>os,createLink:()=>Bn,createNode:()=>Dn,decode:()=>ss,encode:()=>U,name:()=>is,prepare:()=>z,validate:()=>_e});var Be={};E(Be,{base32:()=>ht,base32hex:()=>yo,base32hexpad:()=>vo,base32hexpadupper:()=>Ao,base32hexupper:()=>xo,base32pad:()=>go,base32padupper:()=>wo,base32upper:()=>bo,base32z:()=>So});var Ah=new Uint8Array(0);function en(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function F(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function rn(r){return new TextEncoder().encode(r)}function nn(r){return new TextDecoder().decode(r)}function fo(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=r.length,u=r.charAt(0),x=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var l=0,S=0,d=0,p=h.length;d!==p&&h[d]===0;)d++,l++;for(var g=(p-d)*f+1>>>0,m=new Uint8Array(g);d!==p;){for(var y=h[d],v=0,b=g-1;(y!==0||v<S)&&b!==-1;b--,v++)y+=256*m[b]>>>0,m[b]=y%c>>>0,y=y/c>>>0;if(y!==0)throw new Error("Non-zero carry");S=v,d++}for(var A=g-S;A!==g&&m[A]===0;)A++;for(var I=u.repeat(l);A<g;++A)I+=r.charAt(m[A]);return I}function D(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var l=0;if(h[l]!==" "){for(var S=0,d=0;h[l]===u;)S++,l++;for(var p=(h.length-l)*x+1>>>0,g=new Uint8Array(p);h[l];){var m=e[h.charCodeAt(l)];if(m===255)return;for(var y=0,v=p-1;(m!==0||y<d)&&v!==-1;v--,y++)m+=c*g[v]>>>0,g[v]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");d=y,l++}if(h[l]!==" "){for(var b=p-d;b!==p&&g[b]===0;)b++;for(var A=new Uint8Array(S+(p-b)),I=S;b!==p;)A[I++]=g[b++];return A}}}function a(h){var l=D(h);if(l)return l;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:D,decode:a}}var uo=fo,lo=uo,sn=lo;var ve=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Ae=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.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 an(this,t)}},Se=class{decoders;constructor(t){this.decoders=t}or(t){return an(this,t)}decode(t){let e=t[0],n=this.decoders[e];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 an(r,t){return new Se({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var De=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new ve(t,e,n),this.decoder=new Ae(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ct({name:r,prefix:t,encode:e,decode:n}){return new De(r,t,e,n)}function K({name:r,prefix:t,alphabet:e}){let{encode:n,decode:i}=sn(e,r);return ct({prefix:t,name:r,encode:n,decode:o=>F(i(o))})}function po(r,t,e,n){let i={};for(let f=0;f<t.length;++f)i[t[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,u=0,x=0;for(let f=0;f<o;++f){let w=i[r[f]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<e|w,c+=e,c>=8&&(c-=8,s[x++]=255&u>>c)}if(c>=e||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function mo(r,t,e){let n=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s!==0&&(o+=t[i&c<<e-s]),n)for(;o.length*e&7;)o+="=";return o}function C({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ct({prefix:t,name:r,encode(i){return mo(i,n,e)},decode(i){return po(i,n,e,r)}})}var ht=C({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),bo=C({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),go=C({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wo=C({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yo=C({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xo=C({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),vo=C({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ao=C({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),So=C({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ee={};E(Ee,{base58btc:()=>R,base58flickr:()=>Do});var R=K({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Do=K({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bo=fn,cn=128,Eo=127,Co=~Eo,To=Math.pow(2,31);function fn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=To;)t[e++]=r&255|cn,r/=128;for(;r&Co;)t[e++]=r&255|cn,r>>>=7;return t[e]=r|0,fn.bytes=e-n+1,t}var Io=Ce,ko=128,hn=127;function Ce(r,n){var e=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw Ce.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&hn)<<i:(s&hn)*Math.pow(2,i),i+=7}while(s>=ko);return Ce.bytes=o-n,e}var _o=Math.pow(2,7),No=Math.pow(2,14),Lo=Math.pow(2,21),zo=Math.pow(2,28),Uo=Math.pow(2,35),Po=Math.pow(2,42),Fo=Math.pow(2,49),Mo=Math.pow(2,56),Vo=Math.pow(2,63),Oo=function(r){return r<_o?1:r<No?2:r<Lo?3:r<zo?4:r<Uo?5:r<Po?6:r<Fo?7:r<Mo?8:r<Vo?9:10},Ro={encode:Bo,decode:Io,encodingLength:Oo},Ho=Ro,Ct=Ho;function Tt(r,t=0){return[Ct.decode(r,t),Ct.decode.bytes]}function ft(r,t,e=0){return Ct.encode(r,t,e),t}function ut(r){return Ct.encodingLength(r)}function tt(r,t){let e=t.byteLength,n=ut(r),i=n+ut(e),o=new Uint8Array(i+e);return ft(r,o,0),ft(e,o,n),o.set(t,i),new lt(r,e,t,o)}function un(r){let t=F(r),[e,n]=Tt(t),[i,o]=Tt(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new lt(e,i,s,t)}function ln(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&en(r.bytes,e.bytes)}}var lt=class{code;size;digest;bytes;constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};function dn(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return qo(e,Te(r),t??R.encoder);default:return Go(e,Te(r),t??ht.encoder)}}var pn=new WeakMap;function Te(r){let t=pn.get(r);if(t==null){let e=new Map;return pn.set(r,e),e}return t}var k=class r{code;version;multihash;bytes;"/";constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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:e}=this;if(t!==kt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==jo)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=tt(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&ln(t.multihash,n.multihash)}toString(t){return dn(this,t)}toJSON(){return{"/":dn(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 e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:s}=e;return new r(n,i,o,s??mn(n,i,o.bytes))}else if(e[Jo]===!0){let{version:n,multihash:i,code:o}=e,s=un(i);return r.create(n,o,s)}else return null}static create(t,e,n){if(typeof e!="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(e!==kt)throw new Error(`Version 0 CID must use dag-pb (code: ${kt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=mn(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,kt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=F(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new lt(e.multihashCode,e.digestSize,o,i);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[w,D]=Tt(t.subarray(e));return e+=D,w},i=n(),o=kt;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=n(),u=n(),x=e+u,f=x-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:f,size:x}}static parse(t,e){let[n,i]=$o(t,e),o=r.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Te(o).set(n,t),o}};function $o(r,t){switch(r[0]){case"Q":{let e=t??R;return[R.prefix,e.decode(`${R.prefix}${r}`)]}case R.prefix:{let e=t??R;return[R.prefix,e.decode(r)]}case ht.prefix:{let e=t??ht;return[ht.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function qo(r,t,e){let{prefix:n}=e;if(n!==R.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i}function Go(r,t,e){let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i}var kt=112,jo=18;function mn(r,t,e){let n=ut(r),i=n+ut(t),o=new Uint8Array(i+e.byteLength);return ft(r,o,0),ft(t,o,n),o.set(e,i),o}var Jo=Symbol.for("@ipld/js-cid/CID");var Xo=new TextDecoder;function Ie(r,t){let e=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(t>=r.length)throw new Error("protobuf: unexpected end of data");let i=r[t++];if(e+=n<28?(i&127)<<n:(i&127)*2**n,i<128)break}return[e,t]}function se(r,t){let e;[e,t]=Ie(r,t);let n=t+e;if(e<0||n<0)throw new Error("protobuf: invalid length");if(n>r.length)throw new Error("protobuf: unexpected end of data");return[r.subarray(t,n),n]}function bn(r,t){let e;return[e,t]=Ie(r,t),[e&7,e>>3,t]}function Ko(r){let t={},e=r.length,n=0;for(;n<e;){let i,o;if([i,o,n]=bn(r,n),o===1){if(t.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Hash`);if(t.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[t.Hash,n]=se(r,n)}else if(o===2){if(t.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Name`);if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=se(r,n),t.Name=Xo.decode(s)}else if(o===3){if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(i!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Tsize`);[t.Tsize,n]=Ie(r,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${o}`)}if(n>e)throw new Error("protobuf: (PBLink) unexpected end of data");return t}function gn(r){let t=r.length,e=0,n,i=!1,o;for(;e<t;){let c,u;if([c,u,e]=bn(r,e),c!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${c}`);if(u===1){if(o)throw new Error("protobuf: (PBNode) duplicate Data section");[o,e]=se(r,e),n&&(i=!0)}else if(u===2){if(i)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let x;[x,e]=se(r,e),n.push(Ko(x))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${u}`)}if(e>t)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return o&&(s.Data=o),s.Links=n||[],s}var yn=new TextEncoder,wn=2**32,Wo=2**31;function Qo(r,t){let e=t.length;if(typeof r.Tsize=="number"){if(r.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(r.Tsize))throw new Error("Tsize too large for encoding");e=_t(t,e,r.Tsize)-1,t[e]=24}if(typeof r.Name=="string"){let n=yn.encode(r.Name);e-=n.length,t.set(n,e),e=_t(t,e,n.length)-1,t[e]=18}return r.Hash&&(e-=r.Hash.length,t.set(r.Hash,e),e=_t(t,e,r.Hash.length)-1,t[e]=10),t.length-e}function xn(r){let t=Yo(r),e=new Uint8Array(t),n=t;if(r.Data&&(n-=r.Data.length,e.set(r.Data,n),n=_t(e,n,r.Data.length)-1,e[n]=10),r.Links)for(let i=r.Links.length-1;i>=0;i--){let o=Qo(r.Links[i],e.subarray(0,n));n-=o,n=_t(e,n,o)-1,e[n]=18}return e}function Zo(r){let t=0;if(r.Hash){let e=r.Hash.length;t+=1+e+dt(e)}if(typeof r.Name=="string"){let e=yn.encode(r.Name).length;t+=1+e+dt(e)}return typeof r.Tsize=="number"&&(t+=1+dt(r.Tsize)),t}function Yo(r){let t=0;if(r.Data){let e=r.Data.length;t+=1+e+dt(e)}if(r.Links)for(let e of r.Links){let n=Zo(e);t+=1+n+dt(n)}return t}function _t(r,t,e){t-=dt(e);let n=t;for(;e>=Wo;)r[t++]=e&127|128,e/=128;for(;e>=128;)r[t++]=e&127|128,e>>>=7;return r[t]=e,n}function dt(r){return r%2===0&&r++,Math.floor((ts(r)+6)/7)}function ts(r){let t=0;return r>=wn&&(r=Math.floor(r/wn),t=32),r>=65536&&(r>>>=16,t+=16),r>=256&&(r>>>=8,t+=8),t+es[r]}var es=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];var rs=["Data","Links"],ns=["Hash","Name","Tsize"],ke=new TextEncoder;function An(r,t){if(r===t)return 0;let e=r.Name?ke.encode(r.Name):[],n=t.Name?ke.encode(t.Name):[],i=e.length,o=n.length;for(let s=0,c=Math.min(i,o);s<c;++s)if(e[s]!==n[s]){i=e[s],o=n[s];break}return i<o?-1:o<i?1:0}function vn(r,t){return!Object.keys(r).some(e=>!t.includes(e))}function Sn(r){if(typeof r.asCID=="object"){let e=k.asCID(r);if(!e)throw new TypeError("Invalid DAG-PB form");return{Hash:e}}if(typeof r!="object"||Array.isArray(r))throw new TypeError("Invalid DAG-PB form");let t={};if(r.Hash){let e=k.asCID(r.Hash);try{e||(typeof r.Hash=="string"?e=k.parse(r.Hash):r.Hash instanceof Uint8Array&&(e=k.decode(r.Hash)))}catch(n){throw new TypeError(`Invalid DAG-PB form: ${n.message}`)}e&&(t.Hash=e)}if(!t.Hash)throw new TypeError("Invalid DAG-PB form");return typeof r.Name=="string"&&(t.Name=r.Name),typeof r.Tsize=="number"&&(t.Tsize=r.Tsize),t}function z(r){if((r instanceof Uint8Array||typeof r=="string")&&(r={Data:r}),typeof r!="object"||Array.isArray(r))throw new TypeError("Invalid DAG-PB form");let t={};if(r.Data!==void 0)if(typeof r.Data=="string")t.Data=ke.encode(r.Data);else if(r.Data instanceof Uint8Array)t.Data=r.Data;else throw new TypeError("Invalid DAG-PB form");if(r.Links!==void 0)if(Array.isArray(r.Links))t.Links=r.Links.map(Sn),t.Links.sort(An);else throw new TypeError("Invalid DAG-PB form");else t.Links=[];return t}function _e(r){if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form");if(!vn(r,rs))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(r.Data!==void 0&&!(r.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(r.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let t=0;t<r.Links.length;t++){let e=r.Links[t];if(!e||typeof e!="object"||Array.isArray(e)||e instanceof Uint8Array||e["/"]&&e["/"]===e.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!vn(e,ns))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(e.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(e.Hash==null||!e.Hash["/"]||e.Hash["/"]!==e.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(e.Name!==void 0&&typeof e.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(e.Tsize!==void 0){if(typeof e.Tsize!="number"||e.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(e.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(t>0&&An(e,r.Links[t-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function Dn(r,t=[]){return z({Data:r,Links:t})}function Bn(r,t,e){return Sn({Hash:e,Name:r,Tsize:t})}var is="dag-pb",os=112;function U(r){_e(r);let t={};return r.Links&&(t.Links=r.Links.map(e=>{let n={};return e.Hash&&(n.Hash=e.Hash.bytes),e.Name!==void 0&&(n.Name=e.Name),e.Tsize!==void 0&&(n.Tsize=e.Tsize),n})),r.Data&&(t.Data=r.Data),xn(t)}function ss(r){let t=gn(r),e={};return t.Data&&(e.Data=t.Data),t.Links&&(e.Links=t.Links.map(n=>{let i={};try{i.Hash=k.decode(n.Hash)}catch{}if(!i.Hash)throw new Error("Invalid Hash field found in link, expected CID");return n.Name!==void 0&&(i.Name=n.Name),n.Tsize!==void 0&&(i.Tsize=n.Tsize),i})),e}var lr=st(St(),1);var Ne=new Float32Array([-0]),W=new Uint8Array(Ne.buffer);function En(r,t,e){Ne[0]=r,t[e]=W[0],t[e+1]=W[1],t[e+2]=W[2],t[e+3]=W[3]}function Cn(r,t){return W[0]=r[t],W[1]=r[t+1],W[2]=r[t+2],W[3]=r[t+3],Ne[0]}var Le=new Float64Array([-0]),_=new Uint8Array(Le.buffer);function Tn(r,t,e){Le[0]=r,t[e]=_[0],t[e+1]=_[1],t[e+2]=_[2],t[e+3]=_[3],t[e+4]=_[4],t[e+5]=_[5],t[e+6]=_[6],t[e+7]=_[7]}function In(r,t){return _[0]=r[t],_[1]=r[t+1],_[2]=r[t+2],_[3]=r[t+3],_[4]=r[t+4],_[5]=r[t+5],_[6]=r[t+6],_[7]=r[t+7],Le[0]}var as=BigInt(Number.MAX_SAFE_INTEGER),cs=BigInt(Number.MIN_SAFE_INTEGER),N=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return et;if(t<as&&t>cs)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,i=t-(n<<32n);return e&&(n=~n|0n,i=~i|0n,++i>kn&&(i=0n,++n>kn&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(t){if(t===0)return et;let e=t<0;e&&(t=-t);let n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):et}},et=new N(0,0);et.toBigInt=function(){return 0n};et.zzEncode=et.zzDecode=function(){return this};et.length=function(){return 1};var kn=4294967296n;function _n(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Nn(r,t,e){if(e-t<1)return"";let i,o=[],s=0,c;for(;t<e;)c=r[t++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function ze(r,t,e){let n=e,i,o;for(let s=0;s<r.length;++s)i=r.charCodeAt(s),i<128?t[e++]=i:i<2048?(t[e++]=i>>6|192,t[e++]=i&63|128):(i&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,t[e++]=i>>18|240,t[e++]=i>>12&63|128,t[e++]=i>>6&63|128,t[e++]=i&63|128):(t[e++]=i>>12|224,t[e++]=i>>6&63|128,t[e++]=i&63|128);return e-n}function M(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ae(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Ue=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,M(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw M(this,4);return ae(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw M(this,4);return ae(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw M(this,4);let t=Cn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw M(this,4);let t=In(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw M(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Nn(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw M(this,t);this.pos+=t}else do if(this.pos>=this.len)throw M(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new N(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw M(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw M(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw M(this,8);let t=ae(this.buf,this.pos+=4),e=ae(this.buf,this.pos+=4);return new N(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Pe(r){return new Ue(r instanceof Uint8Array?r:r.subarray())}function Lt(r,t){let e=Pe(r);return t.decode(e)}var Re={};E(Re,{base10:()=>ps});function hs(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=r.length,u=r.charAt(0),x=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var l=0,S=0,d=0,p=h.length;d!==p&&h[d]===0;)d++,l++;for(var g=(p-d)*f+1>>>0,m=new Uint8Array(g);d!==p;){for(var y=h[d],v=0,b=g-1;(y!==0||v<S)&&b!==-1;b--,v++)y+=256*m[b]>>>0,m[b]=y%c>>>0,y=y/c>>>0;if(y!==0)throw new Error("Non-zero carry");S=v,d++}for(var A=g-S;A!==g&&m[A]===0;)A++;for(var I=u.repeat(l);A<g;++A)I+=r.charAt(m[A]);return I}function D(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var l=0;if(h[l]!==" "){for(var S=0,d=0;h[l]===u;)S++,l++;for(var p=(h.length-l)*x+1>>>0,g=new Uint8Array(p);h[l];){var m=e[h.charCodeAt(l)];if(m===255)return;for(var y=0,v=p-1;(m!==0||y<d)&&v!==-1;v--,y++)m+=c*g[v]>>>0,g[v]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");d=y,l++}if(h[l]!==" "){for(var b=p-d;b!==p&&g[b]===0;)b++;for(var A=new Uint8Array(S+(p-b)),I=S;b!==p;)A[I++]=g[b++];return A}}}function a(h){var l=D(h);if(l)return l;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:D,decode:a}}var fs=hs,us=fs,zn=us;var Yh=new Uint8Array(0);var Un=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},j=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Pn=r=>new TextEncoder().encode(r),Fn=r=>new TextDecoder().decode(r);var Fe=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Me=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.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 Vn(this,t)}},Ve=class{constructor(t){this.decoders=t}or(t){return Vn(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Vn=(r,t)=>new Ve({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Oe=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new Fe(t,e,n),this.decoder=new Me(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},pt=({name:r,prefix:t,encode:e,decode:n})=>new Oe(r,t,e,n),Q=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=zn(e,t);return pt({prefix:r,name:t,encode:n,decode:o=>j(i(o))})},ls=(r,t,e,n)=>{let i={};for(let f=0;f<t.length;++f)i[t[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,u=0,x=0;for(let f=0;f<o;++f){let w=i[r[f]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<e|w,c+=e,c>=8&&(c-=8,s[x++]=255&u>>c)}if(c>=e||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s},ds=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s&&(o+=t[i&c<<e-s]),n)for(;o.length*e&7;)o+="=";return o},T=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>pt({prefix:t,name:r,encode(i){return ds(i,n,e)},decode(i){return ls(i,n,e,r)}});var ps=Q({prefix:"9",name:"base10",alphabet:"0123456789"});var He={};E(He,{base16:()=>ms,base16upper:()=>bs});var ms=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bs=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $e={};E($e,{base2:()=>gs});var gs=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var qe={};E(qe,{base256emoji:()=>As});var On=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),ws=On.reduce((r,t,e)=>(r[e]=t,r),[]),ys=On.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function xs(r){return r.reduce((t,e)=>(t+=ws[e],t),"")}function vs(r){let t=[];for(let e of r){let n=ys[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var As=pt({prefix:"\u{1F680}",name:"base256emoji",encode:xs,decode:vs});var Ge={};E(Ge,{base32:()=>mt,base32hex:()=>Es,base32hexpad:()=>Ts,base32hexpadupper:()=>Is,base32hexupper:()=>Cs,base32pad:()=>Ds,base32padupper:()=>Bs,base32upper:()=>Ss,base32z:()=>ks});var mt=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ss=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ds=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bs=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Es=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Cs=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ts=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Is=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ks=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var je={};E(je,{base36:()=>_s,base36upper:()=>Ns});var _s=Q({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ns=Q({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Je={};E(Je,{base58btc:()=>H,base58flickr:()=>Ls});var H=Q({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ls=Q({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Xe={};E(Xe,{base64:()=>zs,base64pad:()=>Us,base64url:()=>Ps,base64urlpad:()=>Fs});var zs=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Us=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ps=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Fs=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ke={};E(Ke,{base8:()=>Ms});var Ms=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var We={};E(We,{identity:()=>Vs});var Vs=pt({prefix:"\0",name:"identity",encode:r=>Fn(r),decode:r=>Pn(r)});var mf=new TextEncoder,bf=new TextDecoder;var Ze={};E(Ze,{identity:()=>ca});var Hs=$n,Rn=128,$s=127,qs=~$s,Gs=Math.pow(2,31);function $n(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Gs;)t[e++]=r&255|Rn,r/=128;for(;r&qs;)t[e++]=r&255|Rn,r>>>=7;return t[e]=r|0,$n.bytes=e-n+1,t}var js=Qe,Js=128,Hn=127;function Qe(r,n){var e=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw Qe.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&Hn)<<i:(s&Hn)*Math.pow(2,i),i+=7}while(s>=Js);return Qe.bytes=o-n,e}var Xs=Math.pow(2,7),Ks=Math.pow(2,14),Ws=Math.pow(2,21),Qs=Math.pow(2,28),Zs=Math.pow(2,35),Ys=Math.pow(2,42),ta=Math.pow(2,49),ea=Math.pow(2,56),ra=Math.pow(2,63),na=function(r){return r<Xs?1:r<Ks?2:r<Ws?3:r<Qs?4:r<Zs?5:r<Ys?6:r<ta?7:r<ea?8:r<ra?9:10},ia={encode:Hs,decode:js,encodingLength:na},oa=ia,zt=oa;var Ut=(r,t=0)=>[zt.decode(r,t),zt.decode.bytes],bt=(r,t,e=0)=>(zt.encode(r,t,e),t),gt=r=>zt.encodingLength(r);var rt=(r,t)=>{let e=t.byteLength,n=gt(r),i=n+gt(e),o=new Uint8Array(i+e);return bt(r,o,0),bt(e,o,n),o.set(t,i),new wt(r,e,t,o)},qn=r=>{let t=j(r),[e,n]=Ut(t),[i,o]=Ut(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new wt(e,i,s,t)},Gn=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Un(r.bytes,e.bytes)}},wt=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var jn=0,sa="identity",Jn=j,aa=r=>rt(jn,Jn(r)),ca={code:jn,name:sa,encode:Jn,digest:aa};var er={};E(er,{sha256:()=>ha,sha512:()=>fa});var tr=({name:r,code:t,encode:e})=>new Ye(r,t,e),Ye=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?rt(this.code,e):e.then(n=>rt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Kn=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),ha=tr({name:"sha2-256",code:18,encode:Kn("SHA-256")}),fa=tr({name:"sha2-512",code:19,encode:Kn("SHA-512")});var Wn=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return la(e,rr(r),t||H.encoder);default:return da(e,rr(r),t||mt.encoder)}};var Qn=new WeakMap,rr=r=>{let t=Qn.get(r);if(t==null){let e=new Map;return Qn.set(r,e),e}return t},he=class r{constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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:e}=this;if(t!==Ft)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==pa)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=rt(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Gn(t.multihash,n.multihash)}toString(t){return Wn(this,t)}toJSON(){return{"/":Wn(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:s}=e;return new r(n,i,o,s||Zn(n,i,o.bytes))}else if(e[ma]===!0){let{version:n,multihash:i,code:o}=e,s=qn(i);return r.create(n,o,s)}else return null}static create(t,e,n){if(typeof e!="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(e!==Ft)throw new Error(`Version 0 CID must use dag-pb (code: ${Ft}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=Zn(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ft,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=j(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new wt(e.multihashCode,e.digestSize,o,i);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[w,D]=Ut(t.subarray(e));return e+=D,w},i=n(),o=Ft;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=n(),u=n(),x=e+u,f=x-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:f,size:x}}static parse(t,e){let[n,i]=ua(t,e),o=r.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return rr(o).set(n,t),o}},ua=(r,t)=>{switch(r[0]){case"Q":{let e=t||H;return[H.prefix,e.decode(`${H.prefix}${r}`)]}case H.prefix:{let e=t||H;return[H.prefix,e.decode(r)]}case mt.prefix:{let e=t||mt;return[mt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},la=(r,t,e)=>{let{prefix:n}=e;if(n!==H.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i},da=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i},Ft=112,pa=18,Zn=(r,t,e)=>{let n=gt(r),i=n+gt(t),o=new Uint8Array(i+e.byteLength);return bt(r,o,0),bt(t,o,n),o.set(e,i),o},ma=Symbol.for("@ipld/js-cid/CID");var nr={...We,...$e,...Ke,...Re,...He,...Ge,...je,...Je,...Xe,...qe},Nf={...er,...Ze};function ti(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Yn=ti("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ir=ti("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=P(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ba={utf8:Yn,"utf-8":Yn,hex:nr.base16,latin1:ir,ascii:ir,binary:ir,...nr},ei=ba;function fe(r,t="utf8"){let e=ei[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Y(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function or(r){let t=r??8192,e=t>>>1,n,i=t;return function(s){if(s<1||s>e)return P(s);i+s>t&&(n=P(t),i=0);let c=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),c}}var nt=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function sr(){}var cr=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ga=or();function wa(r){return globalThis.Buffer!=null?P(r):ga(r)}var Ot=class{len;head;tail;states;constructor(){this.len=0,this.head=new nt(sr,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new nt(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new hr((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Mt,10,N.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=N.fromBigInt(t);return this._push(Mt,e.length(),e)}uint64Number(t){let e=N.fromNumber(t);return this._push(Mt,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=N.fromBigInt(t).zzEncode();return this._push(Mt,e.length(),e)}sint64Number(t){let e=N.fromNumber(t).zzEncode();return this._push(Mt,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ar,1,t?1:0)}fixed32(t){return this._push(Vt,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=N.fromBigInt(t);return this._push(Vt,4,e.lo)._push(Vt,4,e.hi)}fixed64Number(t){let e=N.fromNumber(t);return this._push(Vt,4,e.lo)._push(Vt,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(En,4,t)}double(t){return this._push(Tn,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(ar,1,0):this.uint32(e)._push(xa,e,t)}string(t){let e=_n(t);return e!==0?this.uint32(e)._push(ze,e,t):this._push(ar,1,0)}fork(){return this.states=new cr(this),this.head=this.tail=new nt(sr,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new nt(sr,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=wa(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function ar(r,t,e){t[e]=r&255}function ya(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var hr=class extends nt{next;constructor(t,e){super(ya,t,e),this.next=void 0}};function Mt(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Vt(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function xa(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ot.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(va,t,r),this},Ot.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Aa,t,r),this});function va(r,t,e){t.set(r,e)}function Aa(r,t,e){r.length<40?ze(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(fe(r),e)}function fr(){return new Ot}function Rt(r,t){let e=fr();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var yt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(yt||(yt={}));function ue(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function ur(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(o,s){let c=t(o);s.int32(c)},n=function(o){let s=o.int32();return t(s)};return ue("enum",yt.VARINT,e,n)}function Ht(r,t){return ue("message",yt.LENGTH_DELIMITED,r,t)}var V;(function(r){let t;(function(i){i.Raw="Raw",i.Directory="Directory",i.File="File",i.Metadata="Metadata",i.Symlink="Symlink",i.HAMTShard="HAMTShard"})(t=r.DataType||(r.DataType={}));let e;(function(i){i[i.Raw=0]="Raw",i[i.Directory=1]="Directory",i[i.File=2]="File",i[i.Metadata=3]="Metadata",i[i.Symlink=4]="Symlink",i[i.HAMTShard=5]="HAMTShard"})(e||(e={})),function(i){i.codec=()=>ur(e)}(t=r.DataType||(r.DataType={}));let n;r.codec=()=>(n==null&&(n=Ht((i,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),i.Type!=null&&(o.uint32(8),r.DataType.codec().encode(i.Type,o)),i.Data!=null&&(o.uint32(18),o.bytes(i.Data)),i.filesize!=null&&(o.uint32(24),o.uint64(i.filesize)),i.blocksizes!=null)for(let c of i.blocksizes)o.uint32(32),o.uint64(c);i.hashType!=null&&(o.uint32(40),o.uint64(i.hashType)),i.fanout!=null&&(o.uint32(48),o.uint64(i.fanout)),i.mode!=null&&(o.uint32(56),o.uint32(i.mode)),i.mtime!=null&&(o.uint32(66),le.codec().encode(i.mtime,o)),s.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let s={blocksizes:[]},c=o==null?i.len:i.pos+o;for(;i.pos<c;){let u=i.uint32();switch(u>>>3){case 1:s.Type=r.DataType.codec().decode(i);break;case 2:s.Data=i.bytes();break;case 3:s.filesize=i.uint64();break;case 4:s.blocksizes.push(i.uint64());break;case 5:s.hashType=i.uint64();break;case 6:s.fanout=i.uint64();break;case 7:s.mode=i.uint32();break;case 8:s.mtime=le.codec().decode(i,i.uint32());break;default:i.skipType(u&7);break}}return s})),n),r.encode=i=>Rt(i,r.codec()),r.decode=i=>Lt(i,r.codec())})(V||(V={}));var le;(function(r){let t;r.codec=()=>(t==null&&(t=Ht((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.Seconds!=null&&(n.uint32(8),n.int64(e.Seconds)),e.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(e.FractionalNanoseconds)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:i.Seconds=e.int64();break;case 2:i.FractionalNanoseconds=e.fixed32();break;default:e.skipType(s&7);break}}return i})),t),r.encode=e=>Rt(e,r.codec()),r.decode=e=>Lt(e,r.codec())})(le||(le={}));var ri;(function(r){let t;r.codec=()=>(t==null&&(t=Ht((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.MimeType!=null&&(n.uint32(10),n.string(e.MimeType)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:i.MimeType=e.string();break;default:e.skipType(s&7);break}}return i})),t),r.encode=e=>Rt(e,r.codec()),r.decode=e=>Lt(e,r.codec())})(ri||(ri={}));var ni={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},Sa=["directory","hamt-sharded-directory"],ii=parseInt("0644",8),oi=parseInt("0755",8),L=class r{static unmarshal(t){let e=V.decode(t),n=new r({type:ni[e.Type!=null?e.Type.toString():"File"],data:e.Data,blockSizes:e.blocksizes,mode:e.mode,mtime:e.mtime!=null?{secs:e.mtime.Seconds??0n,nsecs:e.mtime.FractionalNanoseconds}:void 0,fanout:e.fanout});return n._originalMode=e.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(t={type:"file"}){let{type:e,data:n,blockSizes:i,hashType:o,fanout:s,mtime:c,mode:u}=t;if(e!=null&&!Object.values(ni).includes(e))throw(0,lr.default)(new Error("Type: "+e+" is not valid"),"ERR_INVALID_TYPE");this.type=e??"file",this.data=n,this.hashType=o,this.fanout=s,this.blockSizes=i??[],this._originalMode=0,this.mode=u,this.mtime=c}set mode(t){t==null?this._mode=this.isDirectory()?oi:ii:this._mode=t&4095}get mode(){return this._mode}isDirectory(){return Sa.includes(this.type)}addBlockSize(t){this.blockSizes.push(t)}removeBlockSize(t){this.blockSizes.splice(t,1)}fileSize(){if(this.isDirectory())return 0n;let t=0n;return this.blockSizes.forEach(e=>{t+=e}),this.data!=null&&(t+=BigInt(this.data.length)),t}marshal(){let t;switch(this.type){case"raw":t=V.DataType.Raw;break;case"directory":t=V.DataType.Directory;break;case"file":t=V.DataType.File;break;case"metadata":t=V.DataType.Metadata;break;case"symlink":t=V.DataType.Symlink;break;case"hamt-sharded-directory":t=V.DataType.HAMTShard;break;default:throw(0,lr.default)(new Error(`Type: ${t} is not valid`),"ERR_INVALID_TYPE")}let e=this.data;(this.data==null||this.data.length===0)&&(e=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===ii&&!this.isDirectory()&&(n=void 0),n===oi&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),V.encode({Type:t,Data:e,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:i})}};var $t={};E($t,{code:()=>de,decode:()=>Ea,encode:()=>Ba,name:()=>Da});var Da="raw",de=85;function Ba(r){return F(r)}function Ea(r){return F(r)}var J=class extends Event{constructor(t,e){super(t),this.detail=e}};var br={};E(br,{sha256:()=>mr,sha512:()=>Ca});function pr({name:r,code:t,encode:e}){return new dr(r,t,e)}var dr=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?tt(this.code,e):e.then(n=>tt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ai(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var mr=pr({name:"sha2-256",code:18,encode:ai("SHA-256")}),Ca=pr({name:"sha2-512",code:19,encode:ai("SHA-512")});var O=async(r,t,e)=>{e.codec==null&&(e.codec=Nt);let n=await mr.digest(r),i=k.create(e.cidVersion,e.codec.code,n);return await t.put(i,r,e),i};function ci(r){return async function*(e,n){let i=0n;for await(let o of e.content)yield async()=>{let s,c={codec:Nt,cidVersion:r.cidVersion,onProgress:r.onProgress};r.rawLeaves?(c.codec=$t,c.cidVersion=1):(s=new L({type:r.leafType,data:o}),o=U({Data:s.marshal(),Links:[]}));let u=await O(o,n,c);return i+=BigInt(o.byteLength),r.onProgress?.(new J("unixfs:importer:progress:file:write",{bytesWritten:i,cid:u,path:e.path})),{cid:u,unixfs:s,size:BigInt(o.length),block:o}}}}var gr=st(St(),1);var hi=async(r,t,e)=>{let n=new L({type:"directory",mtime:r.mtime,mode:r.mode}),i=U(z({Data:n.marshal()})),o=await O(i,t,e),s=r.path;return{cid:o,path:s,unixfs:n,size:BigInt(i.length),originalPath:r.originalPath,block:i}};async function*Ta(r,t,e){let n=-1,i;for await(let o of Bt(e.bufferImporter(r,t),e.blockWriteConcurrency)){if(n++,n===0){i={...o,single:!0};continue}else n===1&&i!=null&&(yield{...i,block:void 0,single:void 0},i=void 0);yield{...o,block:void 0}}i!=null&&(yield i)}function fi(r){return r.single===!0}var Ia=(r,t,e)=>async function(i){if(i.length===1&&fi(i[0])&&e.reduceSingleLeafToSelf){let f=i[0],w=f.block;return fi(f)&&(r.mtime!==void 0||r.mode!==void 0)&&(f.unixfs=new L({type:"file",mtime:r.mtime,mode:r.mode,data:f.block}),w={Data:f.unixfs.marshal(),Links:[]},f.block=U(z(w)),f.cid=await O(f.block,t,{...e,cidVersion:e.cidVersion}),f.size=BigInt(f.block.length)),e.onProgress?.(new J("unixfs:importer:progress:file:layout",{cid:f.cid,path:f.originalPath})),{cid:f.cid,path:r.path,unixfs:f.unixfs,size:f.size,originalPath:f.originalPath}}let o=new L({type:"file",mtime:r.mtime,mode:r.mode}),s=i.filter(f=>f.cid.code===de&&f.size>0||f.unixfs!=null&&f.unixfs.data==null&&f.unixfs.fileSize()>0n?!0:!!f.unixfs?.data?.length).map(f=>f.cid.code===de?(o.addBlockSize(f.size),{Name:"",Tsize:Number(f.size),Hash:f.cid}):(f.unixfs==null||f.unixfs.data==null?o.addBlockSize(f.unixfs?.fileSize()??0n):o.addBlockSize(BigInt(f.unixfs.data.length)),{Name:"",Tsize:Number(f.size),Hash:f.cid})),c={Data:o.marshal(),Links:s},u=U(z(c)),x=await O(u,t,e);return e.onProgress?.(new J("unixfs:importer:progress:file:layout",{cid:x,path:r.originalPath})),{cid:x,path:r.path,unixfs:o,size:BigInt(u.length+c.Links.reduce((f,w)=>f+(w.Tsize??0),0)),originalPath:r.originalPath,block:u}},ui=async(r,t,e)=>e.layout(Ta(r,t,e),Ia(r,t,e));function ka(r){return Symbol.iterator in r}function _a(r){return Symbol.asyncIterator in r}function Na(r){try{if(r instanceof Uint8Array)return async function*(){yield r}();if(ka(r))return async function*(){yield*r}();if(_a(r))return r}catch{throw(0,gr.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,gr.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}function li(r){return async function*(e,n){for await(let i of e){let o;if(i.path!=null&&(o=i.path,i.path=i.path.split("/").filter(s=>s!=null&&s!==".").join("/")),La(i)){let s={path:i.path,mtime:i.mtime,mode:i.mode,content:async function*(){let c=0n;for await(let u of r.chunker(r.chunkValidator(Na(i.content)))){let x=BigInt(u.byteLength);c+=x,r.onProgress?.(new J("unixfs:importer:progress:file:read",{bytesRead:c,chunkSize:x,path:i.path})),yield u}}(),originalPath:o};yield async()=>ui(s,n,r)}else if(i.path!=null){let s={path:i.path,mtime:i.mtime,mode:i.mode,originalPath:o};yield async()=>hi(s,n,r)}else throw new Error("Import candidate must have content or path or both")}}}function La(r){return r.content!=null}var Ir=st(St(),1);function pe(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}var wr={};E(wr,{base10:()=>za});var za=K({prefix:"9",name:"base10",alphabet:"0123456789"});var yr={};E(yr,{base16:()=>Ua,base16upper:()=>Pa});var Ua=C({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Pa=C({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var xr={};E(xr,{base2:()=>Fa});var Fa=C({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var vr={};E(vr,{base256emoji:()=>Ha});var di=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ma=di.reduce((r,t,e)=>(r[e]=t,r),[]),Va=di.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Oa(r){return r.reduce((t,e)=>(t+=Ma[e],t),"")}function Ra(r){let t=[];for(let e of r){let n=Va[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Ha=ct({prefix:"\u{1F680}",name:"base256emoji",encode:Oa,decode:Ra});var Ar={};E(Ar,{base36:()=>$a,base36upper:()=>qa});var $a=K({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qa=K({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Sr={};E(Sr,{base64:()=>Ga,base64pad:()=>ja,base64url:()=>Ja,base64urlpad:()=>Xa});var Ga=C({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ja=C({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ja=C({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Xa=C({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Dr={};E(Dr,{base8:()=>Ka});var Ka=C({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Br={};E(Br,{identity:()=>Wa});var Wa=ct({prefix:"\0",name:"identity",encode:r=>nn(r),decode:r=>rn(r)});var ju=new TextEncoder,Ju=new TextDecoder;var Er={};E(Er,{identity:()=>tc});var pi=0,Za="identity",mi=F;function Ya(r){return tt(pi,mi(r))}var tc={code:pi,name:Za,encode:mi,digest:Ya};var Cr={...Br,...xr,...Dr,...wr,...yr,...Be,...Ar,...Ee,...Sr,...vr},il={...br,...Er};function bi(r=0){return globalThis.Buffer?.allocUnsafe!=null?pe(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function wi(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var gi=wi("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Tr=wi("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=bi(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ec={utf8:gi,"utf-8":gi,hex:Cr.base16,latin1:Tr,ascii:Tr,binary:Tr,...Cr},yi=ec;function xi(r,t="utf8"){let e=yi[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?pe(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var vi=()=>async function*(t){for await(let e of t){if(e.length===void 0)throw(0,Ir.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if(typeof e=="string"||e instanceof String)yield xi(e.toString());else if(Array.isArray(e))yield Uint8Array.from(e);else if(e instanceof Uint8Array)yield e;else throw(0,Ir.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}};var rc=174;function kr(r){let t=r?.maxChildrenPerNode??rc;return async function e(n,i){let o=[];for await(let s of Dt(n,t))o.push(await i(s));return o.length>1?e(o,i):o[0]}}var $=class{options;root;dir;path;dirty;flat;parent;parentKey;unixfs;mode;mtime;cid;size;nodeSize;constructor(t,e){this.options=e??{},this.root=t.root,this.dir=t.dir,this.path=t.path,this.dirty=t.dirty,this.flat=t.flat,this.parent=t.parent,this.parentKey=t.parentKey,this.unixfs=t.unixfs,this.mode=t.mode,this.mtime=t.mtime}},qt=k.parse("QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"),Gt=k.parse("zdj7WbTaiJT1fgatdet9Ei9iDB5hdCxkbVyhyh8YTUnXMiwYi");var it=class extends ${_children;constructor(t,e){super(t,e),this._children=new Map}async put(t,e){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,this._children.set(t,e)}async get(t){return Promise.resolve(this._children.get(t))}childCount(){return this._children.size}directChildrenCount(){return this.childCount()}onlyChild(){return this._children.values().next().value}async*eachChildSeries(){for(let[t,e]of this._children.entries())yield{key:t,child:e}}estimateNodeSize(){if(this.nodeSize!==void 0)return this.nodeSize;this.nodeSize=0;for(let[t,e]of this._children.entries())e.size!=null&&e.cid!=null&&(this.nodeSize+=t.length+(this.options.cidVersion===1?Gt.bytes.byteLength:qt.bytes.byteLength));return this.nodeSize}async*flush(t){let e=[];for(let[u,x]of this._children.entries()){let f=x;if(x instanceof $)for await(let w of x.flush(t))f=w,yield w;f.size!=null&&f.cid!=null&&e.push({Name:u,Tsize:Number(f.size),Hash:f.cid})}let n=new L({type:"directory",mtime:this.mtime,mode:this.mode}),i={Data:n.marshal(),Links:e},o=U(z(i)),s=await O(o,t,this.options),c=o.length+i.Links.reduce((u,x)=>u+(x.Tsize==null?0:x.Tsize),0);this.cid=s,this.size=c,yield{cid:s,unixfs:n,path:this.path,size:BigInt(c)}}};var jt={};E(jt,{coerce:()=>ot,empty:()=>Ai,equals:()=>_r,fromHex:()=>ic,fromString:()=>sc,isBinary:()=>oc,toHex:()=>nc,toString:()=>ac});var Ai=new Uint8Array(0),nc=r=>r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),""),ic=r=>{let t=r.match(/../g);return t?new Uint8Array(t.map(e=>parseInt(e,16))):Ai},_r=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},ot=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},oc=r=>r instanceof ArrayBuffer||ArrayBuffer.isView(r),sc=r=>new TextEncoder().encode(r),ac=r=>new TextDecoder().decode(r);function cc(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=r.length,u=r.charAt(0),x=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var l=0,S=0,d=0,p=h.length;d!==p&&h[d]===0;)d++,l++;for(var g=(p-d)*f+1>>>0,m=new Uint8Array(g);d!==p;){for(var y=h[d],v=0,b=g-1;(y!==0||v<S)&&b!==-1;b--,v++)y+=256*m[b]>>>0,m[b]=y%c>>>0,y=y/c>>>0;if(y!==0)throw new Error("Non-zero carry");S=v,d++}for(var A=g-S;A!==g&&m[A]===0;)A++;for(var I=u.repeat(l);A<g;++A)I+=r.charAt(m[A]);return I}function D(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var l=0;if(h[l]!==" "){for(var S=0,d=0;h[l]===u;)S++,l++;for(var p=(h.length-l)*x+1>>>0,g=new Uint8Array(p);h[l];){var m=e[h.charCodeAt(l)];if(m===255)return;for(var y=0,v=p-1;(m!==0||y<d)&&v!==-1;v--,y++)m+=c*g[v]>>>0,g[v]=m%256>>>0,m=m/256>>>0;if(m!==0)throw new Error("Non-zero carry");d=y,l++}if(h[l]!==" "){for(var b=p-d;b!==p&&g[b]===0;)b++;for(var A=new Uint8Array(S+(p-b)),I=S;b!==p;)A[I++]=g[b++];return A}}}function a(h){var l=D(h);if(l)return l;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:D,decode:a}}var hc=cc,fc=hc,Si=fc;var Nr=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Lr=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.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 Di(this,t)}},zr=class{constructor(t){this.decoders=t}or(t){return Di(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},Di=(r,t)=>new zr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),Ur=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new Nr(t,e,n),this.decoder=new Lr(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},Bi=({name:r,prefix:t,encode:e,decode:n})=>new Ur(r,t,e,n),Pr=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=Si(e,t);return Bi({prefix:r,name:t,encode:n,decode:o=>ot(i(o))})},uc=(r,t,e,n)=>{let i={};for(let f=0;f<t.length;++f)i[t[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,u=0,x=0;for(let f=0;f<o;++f){let w=i[r[f]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<e|w,c+=e,c>=8&&(c-=8,s[x++]=255&u>>c)}if(c>=e||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s},lc=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s&&(o+=t[i&c<<e-s]),n)for(;o.length*e&7;)o+="=";return o},q=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>Bi({prefix:t,name:r,encode(i){return lc(i,n,e)},decode(i){return uc(i,n,e,r)}});var Jt=q({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Hl=q({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$l=q({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ql=q({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Gl=q({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jl=q({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Jl=q({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Xl=q({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Kl=q({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var X=Pr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Zl=Pr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dc=Ti,Ei=128,pc=127,mc=~pc,bc=Math.pow(2,31);function Ti(r,t,e){t=t||[],e=e||0;for(var n=e;r>=bc;)t[e++]=r&255|Ei,r/=128;for(;r&mc;)t[e++]=r&255|Ei,r>>>=7;return t[e]=r|0,Ti.bytes=e-n+1,t}var gc=Fr,wc=128,Ci=127;function Fr(r,n){var e=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw Fr.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&Ci)<<i:(s&Ci)*Math.pow(2,i),i+=7}while(s>=wc);return Fr.bytes=o-n,e}var yc=Math.pow(2,7),xc=Math.pow(2,14),vc=Math.pow(2,21),Ac=Math.pow(2,28),Sc=Math.pow(2,35),Dc=Math.pow(2,42),Bc=Math.pow(2,49),Ec=Math.pow(2,56),Cc=Math.pow(2,63),Tc=function(r){return r<yc?1:r<xc?2:r<vc?3:r<Ac?4:r<Sc?5:r<Dc?6:r<Bc?7:r<Ec?8:r<Cc?9:10},Ic={encode:dc,decode:gc,encodingLength:Tc},kc=Ic,Xt=kc;var Kt=(r,t=0)=>[Xt.decode(r,t),Xt.decode.bytes],xt=(r,t,e=0)=>(Xt.encode(r,t,e),t),vt=r=>Xt.encodingLength(r);var Wt=(r,t)=>{let e=t.byteLength,n=vt(r),i=n+vt(e),o=new Uint8Array(i+e);return xt(r,o,0),xt(e,o,n),o.set(t,i),new At(r,e,t,o)},Ii=r=>{let t=ot(r),[e,n]=Kt(t),[i,o]=Kt(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new At(e,i,s,t)},ki=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&_r(r.bytes,e.bytes)}},At=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var _i=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Nc(e,Or(r),t||X.encoder);default:return Lc(e,Or(r),t||Jt.encoder)}};var Ni=new WeakMap,Or=r=>{let t=Ni.get(r);if(t==null){let e=new Map;return Ni.set(r,e),e}return t},Rr=class r{constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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:e}=this;if(t!==Qt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==zc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=Wt(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&ki(t.multihash,n.multihash)}toString(t){return _i(this,t)}toJSON(){return{"/":_i(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:s}=e;return new r(n,i,o,s||Li(n,i,o.bytes))}else if(e[Uc]===!0){let{version:n,multihash:i,code:o}=e,s=Ii(i);return r.create(n,o,s)}else return null}static create(t,e,n){if(typeof e!="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(e!==Qt)throw new Error(`Version 0 CID must use dag-pb (code: ${Qt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=Li(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Qt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=ot(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new At(e.multihashCode,e.digestSize,o,i);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[w,D]=Kt(t.subarray(e));return e+=D,w},i=n(),o=Qt;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=n(),u=n(),x=e+u,f=x-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:f,size:x}}static parse(t,e){let[n,i]=_c(t,e),o=r.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Or(o).set(n,t),o}},_c=(r,t)=>{switch(r[0]){case"Q":{let e=t||X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t||X;return[X.prefix,e.decode(r)]}case Jt.prefix:{let e=t||Jt;return[Jt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},Nc=(r,t,e)=>{let{prefix:n}=e;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i},Lc=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i},Qt=112,zc=18,Li=(r,t,e)=>{let n=vt(r),i=n+vt(t),o=new Uint8Array(i+e.byteLength);return xt(r,o,0),xt(t,o,n),o.set(e,i),o},Uc=Symbol.for("@ipld/js-cid/CID");var me=({name:r,code:t,encode:e})=>new Hr(r,t,e),Hr=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Wt(this.code,e):e.then(n=>Wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var ge=st(Pi(),1);function Fc(r){let t=new Array(4);for(let e=0;e<4;e++)t[e]=r&255,r=r>>8;return new Uint8Array(t)}var pd=me({name:"murmur3-32",code:35,encode:r=>Fc(ge.default.x86.hash32(r))}),Fi=me({name:"murmur3-128",code:34,encode:r=>jt.fromHex(ge.default.x64.hash128(r))}),md=me({name:"murmur3-x64-64",code:34,encode:r=>jt.fromHex(ge.default.x64.hash128(r)).subarray(0,8)});var Ri=st(Oi(),1);var Z=class r{constructor(t,e,n=0){this._options=t,this._popCount=0,this._parent=e,this._posAtParent=n,this._children=new Ri.default,this.key=null}async put(t,e){let n=await this._findNewBucketAndPos(t);await n.bucket._putAt(n,t,e)}async get(t){let e=await this._findChild(t);if(e!=null)return e.value}async del(t){let e=await this._findPlace(t),n=e.bucket._at(e.pos);n!=null&&n.key===t&&e.bucket._delAt(e.pos)}leafCount(){return this._children.compactArray().reduce((e,n)=>n instanceof r?e+n.leafCount():e+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let t=this._children.compactArray();for(let e of t)e instanceof r?yield*e.eachLeafSeries():yield e}serialize(t,e){let n=[];return e(this._children.reduce((i,o,s)=>(o!=null&&(o instanceof r?i.push(o.serialize(t,e)):i.push(t(o,s))),i),n))}async asyncTransform(t,e){return await Hi(this,t,e)}toJSON(){return this.serialize(Hc,$c)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(t){let e=await this._findPlace(t),n=e.bucket._at(e.pos);if(!(n instanceof r)&&n!=null&&n.key===t)return n}async _findPlace(t){let e=this._options.hash(typeof t=="string"?fe(t):t),n=await e.take(this._options.bits),i=this._children.get(n);return i instanceof r?await i._findPlace(e):{bucket:this,pos:n,hash:e,existingChild:i}}async _findNewBucketAndPos(t){let e=await this._findPlace(t);if(e.existingChild!=null&&e.existingChild.key!==t){let n=new r(this._options,e.bucket,e.pos);e.bucket._putObjectAt(e.pos,n);let i=await n._findPlace(e.existingChild.hash);return i.bucket._putAt(i,e.existingChild.key,e.existingChild.value),await n._findNewBucketAndPos(e.hash)}return e}_putAt(t,e,n){this._putObjectAt(t.pos,{key:e,value:n,hash:t.hash})}_putObjectAt(t,e){this._children.get(t)==null&&this._popCount++,this._children.set(t,e)}_delAt(t){if(t===-1)throw new Error("Invalid position");this._children.get(t)!=null&&this._popCount--,this._children.unset(t),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let t=this._children.find(Rc);if(t!=null&&!(t instanceof r)){let e=t.hash;e.untake(this._options.bits);let n={pos:this._posAtParent,hash:e,bucket:this._parent};this._parent._putAt(n,t.key,t.value)}}else this._parent._delAt(this._posAtParent)}_at(t){return this._children.get(t)}};function Rc(r){return!!r}function Hc(r,t){return r.key}function $c(r){return r}async function Hi(r,t,e){let n=[];for(let i of r._children.compactArray())if(i instanceof Z)await Hi(i,t,e);else{let o=await t(i);n.push({bitField:r._children.bitField(),children:o})}return await e(n)}var qc=[255,254,252,248,240,224,192,128],Gc=[1,3,7,15,31,63,127,255],we=class{constructor(t){this._value=t,this._currentBytePos=t.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(t){let e=t,n=0;for(;e>0&&this._haveBits();){let i=this._value[this._currentBytePos],o=this._currentBitPos+1,s=Math.min(o,e),c=jc(i,o-s,s);n=(n<<s)+c,e-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(t){for(this._currentBitPos+=t;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function jc(r,t,e){let n=Jc(t,e);return(r&n)>>>t}function Jc(r,t){return qc[r]&Gc[Math.min(t+r-1,7)]}function $i(r){function t(e){return e instanceof ye?e:new ye(e,r)}return t}var ye=class{constructor(t,e){if(!(t instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=t,this._hashFn=e,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(t){let e=t;for(;this._availableBits<e;)await this._produceMoreBits();let n=0;for(;e>0;){let i=this._buffers[this._currentBufferIndex],o=Math.min(i.availableBits(),e),s=i.take(o);n=(n<<o)+s,e-=o,this._availableBits-=o,i.availableBits()===0&&this._currentBufferIndex++}return n}untake(t){let e=t;for(;e>0;){let n=this._buffers[this._currentBufferIndex],i=Math.min(n.totalBits()-n.availableBits(),e);n.untake(i),e-=i,this._availableBits+=i,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let t=this._depth>0?Et([this._value,Uint8Array.from([this._depth])]):this._value,e=await this._hashFn(t),n=new we(e);this._buffers.push(n),this._availableBits+=n.availableBits()}};function qi(r){if(r==null||r.hashFn==null)throw new Error("please define an options.hashFn");let t={bits:r.bits??8,hash:$i(r.hashFn)};return new Z(t)}async function Xc(r){return(await Fi.encode(r)).slice(0,8).reverse()}var Gi=BigInt(34),Kc=8,$r=class extends ${_bucket;constructor(t,e){super(t,e),this._bucket=qi({hashFn:Xc,bits:e.shardFanoutBits??Kc})}async put(t,e){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,await this._bucket.put(t,e)}async get(t){return this._bucket.get(t)}childCount(){return this._bucket.leafCount()}directChildrenCount(){return this._bucket.childrenCount()}onlyChild(){return this._bucket.onlyChild()}async*eachChildSeries(){for await(let{key:t,value:e}of this._bucket.eachLeafSeries())yield{key:t,child:e}}estimateNodeSize(){return this.nodeSize!==void 0?this.nodeSize:(this.nodeSize=Xi(this._bucket,this,this.options),this.nodeSize)}async*flush(t){for await(let e of Ji(this._bucket,t,this,this.options))yield{...e,path:this.path}}},ji=$r;async function*Ji(r,t,e,n){let i=r._children,o=(r.tableSize()-1).toString(16).length,s=[],c=0n;for(let h=0;h<i.length;h++){let l=i.get(h);if(l==null)continue;let S=h.toString(16).toUpperCase().padStart(o,"0");if(l instanceof Z){let d;for await(let p of Ji(l,t,null,n))d=p;if(d==null)throw new Error("Could not flush sharded directory, no subshard found");s.push({Name:S,Tsize:Number(d.size),Hash:d.cid}),c+=d.size}else if(Wc(l.value)){let d=l.value,p;for await(let m of d.flush(t))p=m,yield p;if(p==null)throw new Error("Did not flush dir");let g=S+l.key;s.push({Name:g,Tsize:Number(p.size),Hash:p.cid}),c+=p.size}else{let d=l.value;if(d.cid==null)continue;let p=S+l.key,g=d.size;s.push({Name:p,Tsize:Number(g),Hash:d.cid}),c+=BigInt(g??0)}}let u=Uint8Array.from(i.bitField().reverse()),x=new L({type:"hamt-sharded-directory",data:u,fanout:BigInt(r.tableSize()),hashType:Gi,mtime:e?.mtime,mode:e?.mode}),f={Data:x.marshal(),Links:s},w=U(z(f)),D=await O(w,t,n),a=BigInt(w.byteLength)+c;yield{cid:D,unixfs:x,size:a}}function Wc(r){return typeof r.flush=="function"}function Xi(r,t,e){let n=r._children,i=(r.tableSize()-1).toString(16).length,o=[];for(let x=0;x<n.length;x++){let f=n.get(x);if(f==null)continue;let w=x.toString(16).toUpperCase().padStart(i,"0");if(f instanceof Z){let D=Xi(f,null,e);o.push({Name:w,Tsize:Number(D),Hash:e.cidVersion===0?qt:Gt})}else if(typeof f.value.flush=="function"){let a=f.value.nodeSize();o.push({Name:w+f.key,Tsize:Number(a),Hash:e.cidVersion===0?qt:Gt})}else{let D=f.value;if(D.cid==null)continue;let a=w+f.key,h=D.size;o.push({Name:a,Tsize:Number(h),Hash:D.cid})}}let s=Uint8Array.from(n.bitField().reverse()),c=new L({type:"hamt-sharded-directory",data:s,fanout:BigInt(r.tableSize()),hashType:Gi,mtime:t?.mtime,mode:t?.mode});return U(z({Data:c.marshal(),Links:o})).length}async function qr(r,t,e,n){let i=t;t instanceof it&&t.estimateNodeSize()>e&&(i=await Qc(t,n));let o=i.parent;if(o!=null){if(i!==t){if(r!=null&&(r.parent=i),i.parentKey==null)throw new Error("No parent key found");await o.put(i.parentKey,i)}return qr(i,o,e,n)}return i}async function Qc(r,t){let e=new ji({root:r.root,dir:!0,parent:r.parent,parentKey:r.parentKey,path:r.path,dirty:r.dirty,flat:!1,mtime:r.mtime,mode:r.mode},t);for await(let{key:n,child:i}of r.eachChildSeries())await e.put(n,i);return e}var Ki=(r="")=>r.split(/(?<!\\)\//).filter(Boolean);async function Zc(r,t,e){let n=Ki(r.path??""),i=n.length-1,o=t,s="";for(let c=0;c<n.length;c++){let u=n[c];s+=`${s!==""?"/":""}${u}`;let x=c===i;if(o.dirty=!0,o.cid=void 0,o.size=void 0,x)await o.put(u,r),t=await qr(null,o,e.shardSplitThresholdBytes,e);else{let f=await o.get(u);(f==null||!(f instanceof $))&&(f=new it({root:!1,dir:!0,parent:o,parentKey:u,path:s,dirty:!0,flat:!0,mtime:f?.unixfs?.mtime,mode:f?.unixfs?.mode},e)),await o.put(u,f),o=f}}return t}async function*Wi(r,t){if(!(r instanceof $)){r.unixfs?.isDirectory()===!0&&(yield r);return}yield*r.flush(t)}function Qi(r){return async function*(e,n){let i=new it({root:!0,dir:!0,path:"",dirty:!0,flat:!0},r),o,s=!1;for await(let c of e){if(c==null)continue;let u=`${c.originalPath??""}`.split("/")[0];u!=null&&u!==""&&(o==null?(o=u,s=!0):o!==u&&(s=!1)),i=await Zc(c,i,r),(c.unixfs==null||!c.unixfs.isDirectory())&&(yield c)}if(r.wrapWithDirectory||s&&i.childCount()>1)yield*Wi(i,n);else for await(let c of i.eachChildSeries())c!=null&&(yield*Wi(c.child,n))}}async function*jr(r,t,e={}){let n;Symbol.asyncIterator in r||Symbol.iterator in r?n=r:n=[r];let i=e.wrapWithDirectory??!1,o=e.shardSplitThresholdBytes??262144,s=e.shardFanoutBits??8,c=e.cidVersion??1,u=e.rawLeaves??!0,x=e.leafType??"file",f=e.fileImportConcurrency??50,w=e.blockWriteConcurrency??10,D=e.reduceSingleLeafToSelf??!0,a=e.chunker??tn(),h=e.chunkValidator??vi(),l=e.dagBuilder??li({chunker:a,chunkValidator:h,wrapWithDirectory:i,layout:e.layout??kr(),bufferImporter:e.bufferImporter??ci({cidVersion:c,rawLeaves:u,leafType:x,onProgress:e.onProgress}),blockWriteConcurrency:w,reduceSingleLeafToSelf:D,cidVersion:c,onProgress:e.onProgress}),S=e.treeBuilder??Qi({wrapWithDirectory:i,shardSplitThresholdBytes:o,shardFanoutBits:s,cidVersion:c,onProgress:e.onProgress});for await(let d of S(Bt(l(n,t),f),t))yield{cid:d.cid,path:d.path,unixfs:d.unixfs,size:d.size}}async function Jr(r,t,e={}){let n=await xe(jr([r],t,e));if(n==null)throw(0,Gr.default)(new Error("Nothing imported"),"ERR_INVALID_PARAMS");return n}async function Yc(r,t,e={}){let n=await xe(jr([r],t,e));if(n==null)throw(0,Gr.default)(new Error("Nothing imported"),"ERR_INVALID_PARAMS");return n}async function th(r,t,e={}){return Jr({content:r},t,e)}async function eh(r,t,e={}){return Jr({content:r},t,e)}return no(rh);})();
|
|
2
|
+
"use strict";var IpfsUnixfsImporter=(()=>{var gi=Object.create;var jt=Object.defineProperty;var wi=Object.getOwnPropertyDescriptor;var yi=Object.getOwnPropertyNames;var xi=Object.getPrototypeOf,vi=Object.prototype.hasOwnProperty;var Jt=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),D=(r,t)=>{for(var e in t)jt(r,e,{get:t[e],enumerable:!0})},Er=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of yi(t))!vi.call(r,i)&&i!==e&&jt(r,i,{get:()=>t[i],enumerable:!(n=wi(t,i))||n.enumerable});return r};var it=(r,t,e)=>(e=r!=null?gi(xi(r)):{},Er(t||!r||!r.__esModule?jt(e,"default",{value:r,enumerable:!0}):e,r)),Ai=r=>Er(jt({},"__esModule",{value:!0}),r);var xt=Jt((ja,Cr)=>{"use strict";function kr(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Bi(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return kr(r,e)}catch{e.message=r.message,e.stack=r.stack;let i=function(){};return i.prototype=Object.create(Object.getPrototypeOf(r)),kr(new i,e)}}Cr.exports=Bi});var kn=Jt((Mt,re)=>{(function(r,t){"use strict";var e={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(a){if(!Array.isArray(a)&&!ArrayBuffer.isView(a))return!1;for(var h=0;h<a.length;h++)if(!Number.isInteger(a[h])||a[h]<0||a[h]>255)return!1;return!0}function i(a,h){return(a&65535)*h+(((a>>>16)*h&65535)<<16)}function o(a,h){return a<<h|a>>>32-h}function s(a){return a^=a>>>16,a=i(a,2246822507),a^=a>>>13,a=i(a,3266489909),a^=a>>>16,a}function c(a,h){a=[a[0]>>>16,a[0]&65535,a[1]>>>16,a[1]&65535],h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535];var d=[0,0,0,0];return d[3]+=a[3]+h[3],d[2]+=d[3]>>>16,d[3]&=65535,d[2]+=a[2]+h[2],d[1]+=d[2]>>>16,d[2]&=65535,d[1]+=a[1]+h[1],d[0]+=d[1]>>>16,d[1]&=65535,d[0]+=a[0]+h[0],d[0]&=65535,[d[0]<<16|d[1],d[2]<<16|d[3]]}function u(a,h){a=[a[0]>>>16,a[0]&65535,a[1]>>>16,a[1]&65535],h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535];var d=[0,0,0,0];return d[3]+=a[3]*h[3],d[2]+=d[3]>>>16,d[3]&=65535,d[2]+=a[2]*h[3],d[1]+=d[2]>>>16,d[2]&=65535,d[2]+=a[3]*h[2],d[1]+=d[2]>>>16,d[2]&=65535,d[1]+=a[1]*h[3],d[0]+=d[1]>>>16,d[1]&=65535,d[1]+=a[2]*h[2],d[0]+=d[1]>>>16,d[1]&=65535,d[1]+=a[3]*h[1],d[0]+=d[1]>>>16,d[1]&=65535,d[0]+=a[0]*h[3]+a[1]*h[2]+a[2]*h[1]+a[3]*h[0],d[0]&=65535,[d[0]<<16|d[1],d[2]<<16|d[3]]}function x(a,h){return h%=64,h===32?[a[1],a[0]]:h<32?[a[0]<<h|a[1]>>>32-h,a[1]<<h|a[0]>>>32-h]:(h-=32,[a[1]<<h|a[0]>>>32-h,a[0]<<h|a[1]>>>32-h])}function f(a,h){return h%=64,h===0?a:h<32?[a[0]<<h|a[1]>>>32-h,a[1]<<h]:[a[1]<<h-32,0]}function w(a,h){return[a[0]^h[0],a[1]^h[1]]}function S(a){return a=w(a,[0,a[0]>>>1]),a=u(a,[4283543511,3981806797]),a=w(a,[0,a[0]>>>1]),a=u(a,[3301882366,444984403]),a=w(a,[0,a[0]>>>1]),a}e.x86.hash32=function(a,h){if(e.inputValidation&&!n(a))return t;h=h||0;for(var d=a.length%4,_=a.length-d,l=h,p=0,m=3432918353,g=461845907,y=0;y<_;y=y+4)p=a[y]|a[y+1]<<8|a[y+2]<<16|a[y+3]<<24,p=i(p,m),p=o(p,15),p=i(p,g),l^=p,l=o(l,13),l=i(l,5)+3864292196;switch(p=0,d){case 3:p^=a[y+2]<<16;case 2:p^=a[y+1]<<8;case 1:p^=a[y],p=i(p,m),p=o(p,15),p=i(p,g),l^=p}return l^=a.length,l=s(l),l>>>0},e.x86.hash128=function(a,h){if(e.inputValidation&&!n(a))return t;h=h||0;for(var d=a.length%16,_=a.length-d,l=h,p=h,m=h,g=h,y=0,v=0,b=0,A=0,I=597399067,$t=2869860233,Gt=951274213,qt=2716044179,B=0;B<_;B=B+16)y=a[B]|a[B+1]<<8|a[B+2]<<16|a[B+3]<<24,v=a[B+4]|a[B+5]<<8|a[B+6]<<16|a[B+7]<<24,b=a[B+8]|a[B+9]<<8|a[B+10]<<16|a[B+11]<<24,A=a[B+12]|a[B+13]<<8|a[B+14]<<16|a[B+15]<<24,y=i(y,I),y=o(y,15),y=i(y,$t),l^=y,l=o(l,19),l+=p,l=i(l,5)+1444728091,v=i(v,$t),v=o(v,16),v=i(v,Gt),p^=v,p=o(p,17),p+=m,p=i(p,5)+197830471,b=i(b,Gt),b=o(b,17),b=i(b,qt),m^=b,m=o(m,15),m+=g,m=i(m,5)+2530024501,A=i(A,qt),A=o(A,18),A=i(A,I),g^=A,g=o(g,13),g+=l,g=i(g,5)+850148119;switch(y=0,v=0,b=0,A=0,d){case 15:A^=a[B+14]<<16;case 14:A^=a[B+13]<<8;case 13:A^=a[B+12],A=i(A,qt),A=o(A,18),A=i(A,I),g^=A;case 12:b^=a[B+11]<<24;case 11:b^=a[B+10]<<16;case 10:b^=a[B+9]<<8;case 9:b^=a[B+8],b=i(b,Gt),b=o(b,17),b=i(b,qt),m^=b;case 8:v^=a[B+7]<<24;case 7:v^=a[B+6]<<16;case 6:v^=a[B+5]<<8;case 5:v^=a[B+4],v=i(v,$t),v=o(v,16),v=i(v,Gt),p^=v;case 4:y^=a[B+3]<<24;case 3:y^=a[B+2]<<16;case 2:y^=a[B+1]<<8;case 1:y^=a[B],y=i(y,I),y=o(y,15),y=i(y,$t),l^=y}return l^=a.length,p^=a.length,m^=a.length,g^=a.length,l+=p,l+=m,l+=g,p+=l,m+=l,g+=l,l=s(l),p=s(p),m=s(m),g=s(g),l+=p,l+=m,l+=g,p+=l,m+=l,g+=l,("00000000"+(l>>>0).toString(16)).slice(-8)+("00000000"+(p>>>0).toString(16)).slice(-8)+("00000000"+(m>>>0).toString(16)).slice(-8)+("00000000"+(g>>>0).toString(16)).slice(-8)},e.x64.hash128=function(a,h){if(e.inputValidation&&!n(a))return t;h=h||0;for(var d=a.length%16,_=a.length-d,l=[0,h],p=[0,h],m=[0,0],g=[0,0],y=[2277735313,289559509],v=[1291169091,658871167],b=0;b<_;b=b+16)m=[a[b+4]|a[b+5]<<8|a[b+6]<<16|a[b+7]<<24,a[b]|a[b+1]<<8|a[b+2]<<16|a[b+3]<<24],g=[a[b+12]|a[b+13]<<8|a[b+14]<<16|a[b+15]<<24,a[b+8]|a[b+9]<<8|a[b+10]<<16|a[b+11]<<24],m=u(m,y),m=x(m,31),m=u(m,v),l=w(l,m),l=x(l,27),l=c(l,p),l=c(u(l,[0,5]),[0,1390208809]),g=u(g,v),g=x(g,33),g=u(g,y),p=w(p,g),p=x(p,31),p=c(p,l),p=c(u(p,[0,5]),[0,944331445]);switch(m=[0,0],g=[0,0],d){case 15:g=w(g,f([0,a[b+14]],48));case 14:g=w(g,f([0,a[b+13]],40));case 13:g=w(g,f([0,a[b+12]],32));case 12:g=w(g,f([0,a[b+11]],24));case 11:g=w(g,f([0,a[b+10]],16));case 10:g=w(g,f([0,a[b+9]],8));case 9:g=w(g,[0,a[b+8]]),g=u(g,v),g=x(g,33),g=u(g,y),p=w(p,g);case 8:m=w(m,f([0,a[b+7]],56));case 7:m=w(m,f([0,a[b+6]],48));case 6:m=w(m,f([0,a[b+5]],40));case 5:m=w(m,f([0,a[b+4]],32));case 4:m=w(m,f([0,a[b+3]],24));case 3:m=w(m,f([0,a[b+2]],16));case 2:m=w(m,f([0,a[b+1]],8));case 1:m=w(m,[0,a[b]]),m=u(m,y),m=x(m,31),m=u(m,v),l=w(l,m)}return l=w(l,[0,a.length]),p=w(p,[0,a.length]),l=c(l,p),p=c(p,l),l=S(l),p=S(p),l=c(l,p),p=c(p,l),("00000000"+(l[0]>>>0).toString(16)).slice(-8)+("00000000"+(l[1]>>>0).toString(16)).slice(-8)+("00000000"+(p[0]>>>0).toString(16)).slice(-8)+("00000000"+(p[1]>>>0).toString(16)).slice(-8)},typeof Mt<"u"?(typeof re<"u"&&re.exports&&(Mt=re.exports=e),Mt.murmurHash3=e):typeof define=="function"&&define.amd?define([],function(){return e}):(e._murmurHash3=r.murmurHash3,e.noConflict=function(){return r.murmurHash3=e._murmurHash3,e._murmurHash3=t,e.noConflict=t,e},r.murmurHash3=e)})(Mt)});var In=Jt((zf,Cn)=>{Cn.exports=kn()});var Pn=Jt((Of,zn)=>{"use strict";zn.exports=class{constructor(){this._bitArrays=[],this._data=[],this._length=0,this._changedLength=!1,this._changedData=!1}set(t,e){let n=this._internalPositionFor(t,!1);if(e===void 0)n!==-1&&(this._unsetInternalPos(n),this._unsetBit(t),this._changedLength=!0,this._changedData=!0);else{let i=!1;n===-1?(n=this._data.length,this._setBit(t),this._changedData=!0):i=!0,this._setInternalPos(n,t,e,i),this._changedLength=!0}}unset(t){this.set(t,void 0)}get(t){this._sortData();let e=this._internalPositionFor(t,!0);if(e!==-1)return this._data[e][1]}push(t){return this.set(this.length,t),this.length}get length(){if(this._sortData(),this._changedLength){let t=this._data[this._data.length-1];this._length=t?t[0]+1:0,this._changedLength=!1}return this._length}forEach(t){let e=0;for(;e<this.length;)t(this.get(e),e,this),e++}map(t){let e=0,n=new Array(this.length);for(;e<this.length;)n[e]=t(this.get(e),e,this),e++;return n}reduce(t,e){let n=0,i=e;for(;n<this.length;){let o=this.get(n);i=t(i,o,n),n++}return i}find(t){let e=0,n,i;for(;e<this.length&&!n;)i=this.get(e),n=t(i),e++;return n?i:void 0}_internalPositionFor(t,e){let n=this._bytePosFor(t,e);if(n>=this._bitArrays.length)return-1;let i=this._bitArrays[n],o=t-n*7;if(!((i&1<<o)>0))return-1;let c=this._bitArrays.slice(0,n).reduce(ws,0),u=~(4294967295<<o+1),x=Ln(i&u);return c+x-1}_bytePosFor(t,e){let n=Math.floor(t/7),i=n+1;for(;!e&&this._bitArrays.length<i;)this._bitArrays.push(0);return n}_setBit(t){let e=this._bytePosFor(t,!1);this._bitArrays[e]|=1<<t-e*7}_unsetBit(t){let e=this._bytePosFor(t,!1);this._bitArrays[e]&=~(1<<t-e*7)}_setInternalPos(t,e,n,i){let o=this._data,s=[e,n];if(i)this._sortData(),o[t]=s;else{if(o.length)if(o[o.length-1][0]>=e)o.push(s);else if(o[0][0]<=e)o.unshift(s);else{let c=Math.round(o.length/2);this._data=o.slice(0,c).concat(s).concat(o.slice(c))}else this._data.push(s);this._changedData=!0,this._changedLength=!0}}_unsetInternalPos(t){this._data.splice(t,1)}_sortData(){this._changedData&&this._data.sort(ys),this._changedData=!1}bitField(){let t=[],e=8,n=0,i=0,o,s=this._bitArrays.slice();for(;s.length||n;){n===0&&(o=s.shift(),n=7);let u=Math.min(n,e),x=~(255<<u),f=o&x;i|=f<<8-e,o=o>>>u,n-=u,e-=u,(!e||!n&&!s.length)&&(t.push(i),i=0,e=8)}for(var c=t.length-1;c>0&&t[c]===0;c--)t.pop();return t}compactArray(){return this._sortData(),this._data.map(xs)}};function ws(r,t){return r+Ln(t)}function Ln(r){let t=r;return t=t-(t>>1&1431655765),t=(t&858993459)+(t>>2&858993459),(t+(t>>4)&252645135)*16843009>>24}function ys(r,t){return r[0]-t[0]}function xs(r){return r[1]}});var Ga={};D(Ga,{importByteStream:()=>$a,importBytes:()=>Ha,importDirectory:()=>Oa,importFile:()=>Tr,importer:()=>_r});var Dr=it(xt(),1);function Si(r){return r[Symbol.asyncIterator]!=null}function Di(r){if(Si(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var he=Di;function _i(r){return r[Symbol.asyncIterator]!=null}function Ti(r,t=1){return t=Number(t),_i(r)?async function*(){let e=[];if(t<1&&(t=1),t!==Math.round(t))throw new Error("Batch size must be an integer");for await(let n of r)for(e.push(n);e.length>=t;)yield e.slice(0,t),e=e.slice(t);for(;e.length>0;)yield e.slice(0,t),e=e.slice(t)}():function*(){let e=[];if(t<1&&(t=1),t!==Math.round(t))throw new Error("Batch size must be an integer");for(let n of r)for(e.push(n);e.length>=t;)yield e.slice(0,t),e=e.slice(t);for(;e.length>0;)yield e.slice(0,t),e=e.slice(t)}()}var vt=Ti;async function*At(r,t=1){for await(let e of vt(r,t)){let n=e.map(async i=>i().then(o=>({ok:!0,value:o}),o=>({ok:!1,err:o})));for(let i=0;i<n.length;i++){let o=await n[i];if(o.ok)yield o.value;else throw o.err}}}function J(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function G(r=0){return globalThis.Buffer?.alloc!=null?J(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function U(r=0){return globalThis.Buffer?.allocUnsafe!=null?J(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function fe(r,t){if(globalThis.Buffer!=null)return J(globalThis.Buffer.concat(r,t));t==null&&(t=r.reduce((i,o)=>i+o.length,0));let e=U(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return J(e)}function Ir(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Lr=Symbol.for("@achingbrain/uint8arraylist");function Nr(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let i=e+n.byteLength;if(t<i)return{buf:n,index:t-e};e=i}throw new RangeError("index is out of bounds")}function Xt(r){return!!r?.[Lr]}var ot=class r{bufs;length;[Lr]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Xt(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Xt(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Nr(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Nr(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Xt(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:i}=this._subList(t,e);return fe(n,i)}subarray(t,e){let{bufs:n,length:i}=this._subList(t,e);return n.length===1?n[0]:fe(n,i)}sublist(t,e){let{bufs:n,length:i}=this._subList(t,e),o=new r;return o.length=i,o.bufs=[...n],o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],i=0;for(let o=0;o<this.bufs.length;o++){let s=this.bufs[o],c=i,u=c+s.byteLength;if(i=u,t>=u)continue;let x=t>=c&&t<u,f=e>c&&e<=u;if(x&&f){if(t===c&&e===u){n.push(s);break}let w=t-c;n.push(s.subarray(w,w+(e-t)));break}if(x){if(t===0){n.push(s);continue}n.push(s.subarray(t-c));continue}if(f){if(e===u){n.push(s);break}n.push(s.subarray(0,e-c));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Xt(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let i=n.byteLength;if(i===0)throw new TypeError("search must be at least 1 byte long");let o=256,s=new Int32Array(o);for(let w=0;w<o;w++)s[w]=-1;for(let w=0;w<i;w++)s[n[w]]=w;let c=s,u=this.byteLength-n.byteLength,x=n.byteLength-1,f;for(let w=e;w<=u;w+=f){f=0;for(let S=x;S>=0;S--){let a=this.get(w+S);if(n[S]!==a){f=Math.max(1,S-c[a]);break}}if(f===0)return w}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=U(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let i=G(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,e,n),this.write(i,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let i=G(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,e,n),this.write(i,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let i=G(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,e,n),this.write(i,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=U(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let i=G(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,e,n),this.write(i,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let i=G(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,e,n),this.write(i,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let i=G(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,e,n),this.write(i,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let i=G(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,e,n),this.write(i,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let i=G(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,e,n),this.write(i,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!Ir(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((i,o)=>i+o.byteLength,0)),n.length=e,n}};var Ei=262144,zr=(r={})=>{let t=r.chunkSize??Ei;return async function*(n){let i=new ot,o=0,s=!1;for await(let c of n)for(i.append(c),o+=c.length;o>=t;)if(yield i.slice(0,t),s=!0,t===i.length)i=new ot,o=0;else{let u=new ot;u.append(i.sublist(t)),i=u,o-=t}(!s||o>0)&&(yield i.subarray(0,o))}};var Et={};D(Et,{code:()=>To,createLink:()=>en,createNode:()=>tn,decode:()=>Eo,encode:()=>P,name:()=>_o,prepare:()=>z,validate:()=>Se});var we={};D(we,{base32:()=>ct,base32hex:()=>Ri,base32hexpad:()=>Hi,base32hexpadupper:()=>$i,base32hexupper:()=>Oi,base32pad:()=>Mi,base32padupper:()=>Vi,base32upper:()=>Fi,base32z:()=>Gi});var st={};D(st,{coerce:()=>F,empty:()=>Pr,equals:()=>ue,fromHex:()=>Ci,fromString:()=>le,isBinary:()=>Ii,toHex:()=>ki,toString:()=>de});var Pr=new Uint8Array(0);function ki(r){return r.reduce((t,e)=>t+e.toString(16).padStart(2,"0"),"")}function Ci(r){let t=r.match(/../g);return t!=null?new Uint8Array(t.map(e=>parseInt(e,16))):Pr}function ue(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function F(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Ii(r){return r instanceof ArrayBuffer||ArrayBuffer.isView(r)}function le(r){return new TextEncoder().encode(r)}function de(r){return new TextDecoder().decode(r)}function Ni(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=r.length,u=r.charAt(0),x=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var d=0,_=0,l=0,p=h.length;l!==p&&h[l]===0;)l++,d++;for(var m=(p-l)*f+1>>>0,g=new Uint8Array(m);l!==p;){for(var y=h[l],v=0,b=m-1;(y!==0||v<_)&&b!==-1;b--,v++)y+=256*g[b]>>>0,g[b]=y%c>>>0,y=y/c>>>0;if(y!==0)throw new Error("Non-zero carry");_=v,l++}for(var A=m-_;A!==m&&g[A]===0;)A++;for(var I=u.repeat(d);A<m;++A)I+=r.charAt(g[A]);return I}function S(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var d=0;if(h[d]!==" "){for(var _=0,l=0;h[d]===u;)_++,d++;for(var p=(h.length-d)*x+1>>>0,m=new Uint8Array(p);h[d];){var g=e[h.charCodeAt(d)];if(g===255)return;for(var y=0,v=p-1;(g!==0||y<l)&&v!==-1;v--,y++)g+=c*m[v]>>>0,m[v]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");l=y,d++}if(h[d]!==" "){for(var b=p-l;b!==p&&m[b]===0;)b++;for(var A=new Uint8Array(_+(p-b)),I=_;b!==p;)A[I++]=m[b++];return A}}}function a(h){var d=S(h);if(d)return d;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:S,decode:a}}var Li=Ni,zi=Li,Ur=zi;var pe=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},me=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.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 Fr(this,t)}},be=class{decoders;constructor(t){this.decoders=t}or(t){return Fr(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Fr(r,t){return new be({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var ge=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new pe(t,e,n),this.decoder=new me(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function at({name:r,prefix:t,encode:e,decode:n}){return new ge(r,t,e,n)}function X({name:r,prefix:t,alphabet:e}){let{encode:n,decode:i}=Ur(e,r);return at({prefix:t,name:r,encode:n,decode:o=>F(i(o))})}function Pi(r,t,e,n){let i={};for(let f=0;f<t.length;++f)i[t[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,u=0,x=0;for(let f=0;f<o;++f){let w=i[r[f]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<e|w,c+=e,c>=8&&(c-=8,s[x++]=255&u>>c)}if(c>=e||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s}function Ui(r,t,e){let n=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s!==0&&(o+=t[i&c<<e-s]),n)for(;o.length*e&7;)o+="=";return o}function T({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return at({prefix:t,name:r,encode(i){return Ui(i,n,e)},decode(i){return Pi(i,n,e,r)}})}var ct=T({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Fi=T({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mi=T({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Vi=T({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ri=T({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Oi=T({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hi=T({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$i=T({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Gi=T({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ye={};D(ye,{base58btc:()=>O,base58flickr:()=>qi});var O=X({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qi=X({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ji=Rr,Mr=128,Ji=127,Xi=~Ji,Ki=Math.pow(2,31);function Rr(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Ki;)t[e++]=r&255|Mr,r/=128;for(;rΞ)t[e++]=r&255|Mr,r>>>=7;return t[e]=r|0,Rr.bytes=e-n+1,t}var Wi=xe,Qi=128,Vr=127;function xe(r,n){var e=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw xe.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&Vr)<<i:(s&Vr)*Math.pow(2,i),i+=7}while(s>=Qi);return xe.bytes=o-n,e}var Yi=Math.pow(2,7),Zi=Math.pow(2,14),to=Math.pow(2,21),eo=Math.pow(2,28),ro=Math.pow(2,35),no=Math.pow(2,42),io=Math.pow(2,49),oo=Math.pow(2,56),so=Math.pow(2,63),ao=function(r){return r<Yi?1:r<Zi?2:r<to?3:r<eo?4:r<ro?5:r<no?6:r<io?7:r<oo?8:r<so?9:10},co={encode:ji,decode:Wi,encodingLength:ao},ho=co,Bt=ho;function St(r,t=0){return[Bt.decode(r,t),Bt.decode.bytes]}function ht(r,t,e=0){return Bt.encode(r,t,e),t}function ft(r){return Bt.encodingLength(r)}function Y(r,t){let e=t.byteLength,n=ft(r),i=n+ft(e),o=new Uint8Array(i+e);return ht(r,o,0),ht(e,o,n),o.set(t,i),new ut(r,e,t,o)}function Or(r){let t=F(r),[e,n]=St(t),[i,o]=St(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new ut(e,i,s,t)}function Hr(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ue(r.bytes,e.bytes)}}var ut=class{code;size;digest;bytes;constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};function $r(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return uo(e,ve(r),t??O.encoder);default:return lo(e,ve(r),t??ct.encoder)}}var Gr=new WeakMap;function ve(r){let t=Gr.get(r);if(t==null){let e=new Map;return Gr.set(r,e),e}return t}var k=class r{code;version;multihash;bytes;"/";constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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:e}=this;if(t!==_t)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==po)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=Y(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Hr(t.multihash,n.multihash)}toString(t){return $r(this,t)}toJSON(){return{"/":$r(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 e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:s}=e;return new r(n,i,o,s??qr(n,i,o.bytes))}else if(e[mo]===!0){let{version:n,multihash:i,code:o}=e,s=Or(i);return r.create(n,o,s)}else return null}static create(t,e,n){if(typeof e!="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(e!==_t)throw new Error(`Version 0 CID must use dag-pb (code: ${_t}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=qr(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,_t,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=F(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new ut(e.multihashCode,e.digestSize,o,i);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[w,S]=St(t.subarray(e));return e+=S,w},i=n(),o=_t;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=n(),u=n(),x=e+u,f=x-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:f,size:x}}static parse(t,e){let[n,i]=fo(t,e),o=r.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return ve(o).set(n,t),o}};function fo(r,t){switch(r[0]){case"Q":{let e=t??O;return[O.prefix,e.decode(`${O.prefix}${r}`)]}case O.prefix:{let e=t??O;return[O.prefix,e.decode(r)]}case ct.prefix:{let e=t??ct;return[ct.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function uo(r,t,e){let{prefix:n}=e;if(n!==O.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i}function lo(r,t,e){let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i}var _t=112,po=18;function qr(r,t,e){let n=ft(r),i=n+ft(t),o=new Uint8Array(i+e.byteLength);return ht(r,o,0),ht(t,o,n),o.set(e,i),o}var mo=Symbol.for("@ipld/js-cid/CID");var bo=new TextDecoder;function Ae(r,t){let e=0;for(let n=0;;n+=7){if(n>=64)throw new Error("protobuf: varint overflow");if(t>=r.length)throw new Error("protobuf: unexpected end of data");let i=r[t++];if(e+=n<28?(i&127)<<n:(i&127)*2**n,i<128)break}return[e,t]}function Wt(r,t){let e;[e,t]=Ae(r,t);let n=t+e;if(e<0||n<0)throw new Error("protobuf: invalid length");if(n>r.length)throw new Error("protobuf: unexpected end of data");return[r.subarray(t,n),n]}function jr(r,t){let e;return[e,t]=Ae(r,t),[e&7,e>>3,t]}function go(r){let t={},e=r.length,n=0;for(;n<e;){let i,o;if([i,o,n]=jr(r,n),o===1){if(t.Hash)throw new Error("protobuf: (PBLink) duplicate Hash section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Hash`);if(t.Name!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Name before Hash");if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Hash");[t.Hash,n]=Wt(r,n)}else if(o===2){if(t.Name!==void 0)throw new Error("protobuf: (PBLink) duplicate Name section");if(i!==2)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Name`);if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) invalid order, found Tsize before Name");let s;[s,n]=Wt(r,n),t.Name=bo.decode(s)}else if(o===3){if(t.Tsize!==void 0)throw new Error("protobuf: (PBLink) duplicate Tsize section");if(i!==0)throw new Error(`protobuf: (PBLink) wrong wireType (${i}) for Tsize`);[t.Tsize,n]=Ae(r,n)}else throw new Error(`protobuf: (PBLink) invalid fieldNumber, expected 1, 2 or 3, got ${o}`)}if(n>e)throw new Error("protobuf: (PBLink) unexpected end of data");return t}function Jr(r){let t=r.length,e=0,n,i=!1,o;for(;e<t;){let c,u;if([c,u,e]=jr(r,e),c!==2)throw new Error(`protobuf: (PBNode) invalid wireType, expected 2, got ${c}`);if(u===1){if(o)throw new Error("protobuf: (PBNode) duplicate Data section");[o,e]=Wt(r,e),n&&(i=!0)}else if(u===2){if(i)throw new Error("protobuf: (PBNode) duplicate Links section");n||(n=[]);let x;[x,e]=Wt(r,e),n.push(go(x))}else throw new Error(`protobuf: (PBNode) invalid fieldNumber, expected 1 or 2, got ${u}`)}if(e>t)throw new Error("protobuf: (PBNode) unexpected end of data");let s={};return o&&(s.Data=o),s.Links=n||[],s}var Kr=new TextEncoder,Xr=2**32,wo=2**31;function yo(r,t){let e=t.length;if(typeof r.Tsize=="number"){if(r.Tsize<0)throw new Error("Tsize cannot be negative");if(!Number.isSafeInteger(r.Tsize))throw new Error("Tsize too large for encoding");e=Tt(t,e,r.Tsize)-1,t[e]=24}if(typeof r.Name=="string"){let n=Kr.encode(r.Name);e-=n.length,t.set(n,e),e=Tt(t,e,n.length)-1,t[e]=18}return r.Hash&&(e-=r.Hash.length,t.set(r.Hash,e),e=Tt(t,e,r.Hash.length)-1,t[e]=10),t.length-e}function Wr(r){let t=vo(r),e=new Uint8Array(t),n=t;if(r.Data&&(n-=r.Data.length,e.set(r.Data,n),n=Tt(e,n,r.Data.length)-1,e[n]=10),r.Links)for(let i=r.Links.length-1;i>=0;i--){let o=yo(r.Links[i],e.subarray(0,n));n-=o,n=Tt(e,n,o)-1,e[n]=18}return e}function xo(r){let t=0;if(r.Hash){let e=r.Hash.length;t+=1+e+lt(e)}if(typeof r.Name=="string"){let e=Kr.encode(r.Name).length;t+=1+e+lt(e)}return typeof r.Tsize=="number"&&(t+=1+lt(r.Tsize)),t}function vo(r){let t=0;if(r.Data){let e=r.Data.length;t+=1+e+lt(e)}if(r.Links)for(let e of r.Links){let n=xo(e);t+=1+n+lt(n)}return t}function Tt(r,t,e){t-=lt(e);let n=t;for(;e>=wo;)r[t++]=e&127|128,e/=128;for(;e>=128;)r[t++]=e&127|128,e>>>=7;return r[t]=e,n}function lt(r){return r%2===0&&r++,Math.floor((Ao(r)+6)/7)}function Ao(r){let t=0;return r>=Xr&&(r=Math.floor(r/Xr),t=32),r>=65536&&(r>>>=16,t+=16),r>=256&&(r>>>=8,t+=8),t+Bo[r]}var Bo=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8];var So=["Data","Links"],Do=["Hash","Name","Tsize"],Be=new TextEncoder;function Yr(r,t){if(r===t)return 0;let e=r.Name?Be.encode(r.Name):[],n=t.Name?Be.encode(t.Name):[],i=e.length,o=n.length;for(let s=0,c=Math.min(i,o);s<c;++s)if(e[s]!==n[s]){i=e[s],o=n[s];break}return i<o?-1:o<i?1:0}function Qr(r,t){return!Object.keys(r).some(e=>!t.includes(e))}function Zr(r){if(typeof r.asCID=="object"){let e=k.asCID(r);if(!e)throw new TypeError("Invalid DAG-PB form");return{Hash:e}}if(typeof r!="object"||Array.isArray(r))throw new TypeError("Invalid DAG-PB form");let t={};if(r.Hash){let e=k.asCID(r.Hash);try{e||(typeof r.Hash=="string"?e=k.parse(r.Hash):r.Hash instanceof Uint8Array&&(e=k.decode(r.Hash)))}catch(n){throw new TypeError(`Invalid DAG-PB form: ${n.message}`)}e&&(t.Hash=e)}if(!t.Hash)throw new TypeError("Invalid DAG-PB form");return typeof r.Name=="string"&&(t.Name=r.Name),typeof r.Tsize=="number"&&(t.Tsize=r.Tsize),t}function z(r){if((r instanceof Uint8Array||typeof r=="string")&&(r={Data:r}),typeof r!="object"||Array.isArray(r))throw new TypeError("Invalid DAG-PB form");let t={};if(r.Data!==void 0)if(typeof r.Data=="string")t.Data=Be.encode(r.Data);else if(r.Data instanceof Uint8Array)t.Data=r.Data;else throw new TypeError("Invalid DAG-PB form");if(r.Links!==void 0)if(Array.isArray(r.Links))t.Links=r.Links.map(Zr),t.Links.sort(Yr);else throw new TypeError("Invalid DAG-PB form");else t.Links=[];return t}function Se(r){if(!r||typeof r!="object"||Array.isArray(r)||r instanceof Uint8Array||r["/"]&&r["/"]===r.bytes)throw new TypeError("Invalid DAG-PB form");if(!Qr(r,So))throw new TypeError("Invalid DAG-PB form (extraneous properties)");if(r.Data!==void 0&&!(r.Data instanceof Uint8Array))throw new TypeError("Invalid DAG-PB form (Data must be bytes)");if(!Array.isArray(r.Links))throw new TypeError("Invalid DAG-PB form (Links must be a list)");for(let t=0;t<r.Links.length;t++){let e=r.Links[t];if(!e||typeof e!="object"||Array.isArray(e)||e instanceof Uint8Array||e["/"]&&e["/"]===e.bytes)throw new TypeError("Invalid DAG-PB form (bad link)");if(!Qr(e,Do))throw new TypeError("Invalid DAG-PB form (extraneous properties on link)");if(e.Hash===void 0)throw new TypeError("Invalid DAG-PB form (link must have a Hash)");if(e.Hash==null||!e.Hash["/"]||e.Hash["/"]!==e.Hash.bytes)throw new TypeError("Invalid DAG-PB form (link Hash must be a CID)");if(e.Name!==void 0&&typeof e.Name!="string")throw new TypeError("Invalid DAG-PB form (link Name must be a string)");if(e.Tsize!==void 0){if(typeof e.Tsize!="number"||e.Tsize%1!==0)throw new TypeError("Invalid DAG-PB form (link Tsize must be an integer)");if(e.Tsize<0)throw new TypeError("Invalid DAG-PB form (link Tsize cannot be negative)")}if(t>0&&Yr(e,r.Links[t-1])===-1)throw new TypeError("Invalid DAG-PB form (links must be sorted by Name bytes)")}}function tn(r,t=[]){return z({Data:r,Links:t})}function en(r,t,e){return Zr({Hash:e,Name:r,Tsize:t})}var _o="dag-pb",To=112;function P(r){Se(r);let t={};return r.Links&&(t.Links=r.Links.map(e=>{let n={};return e.Hash&&(n.Hash=e.Hash.bytes),e.Name!==void 0&&(n.Name=e.Name),e.Tsize!==void 0&&(n.Tsize=e.Tsize),n})),r.Data&&(t.Data=r.Data),Wr(t)}function Eo(r){let t=Jr(r),e={};return t.Data&&(e.Data=t.Data),t.Links&&(e.Links=t.Links.map(n=>{let i={};try{i.Hash=k.decode(n.Hash)}catch{}if(!i.Hash)throw new Error("Invalid Hash field found in link, expected CID");return n.Name!==void 0&&(i.Name=n.Name),n.Tsize!==void 0&&(i.Tsize=n.Tsize),i})),e}var Qe=it(xt(),1);var De=new Float32Array([-0]),K=new Uint8Array(De.buffer);function rn(r,t,e){De[0]=r,t[e]=K[0],t[e+1]=K[1],t[e+2]=K[2],t[e+3]=K[3]}function nn(r,t){return K[0]=r[t],K[1]=r[t+1],K[2]=r[t+2],K[3]=r[t+3],De[0]}var _e=new Float64Array([-0]),C=new Uint8Array(_e.buffer);function on(r,t,e){_e[0]=r,t[e]=C[0],t[e+1]=C[1],t[e+2]=C[2],t[e+3]=C[3],t[e+4]=C[4],t[e+5]=C[5],t[e+6]=C[6],t[e+7]=C[7]}function sn(r,t){return C[0]=r[t],C[1]=r[t+1],C[2]=r[t+2],C[3]=r[t+3],C[4]=r[t+4],C[5]=r[t+5],C[6]=r[t+6],C[7]=r[t+7],_e[0]}var ko=BigInt(Number.MAX_SAFE_INTEGER),Co=BigInt(Number.MIN_SAFE_INTEGER),N=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Z;if(t<ko&&t>Co)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,i=t-(n<<32n);return e&&(n=~n|0n,i=~i|0n,++i>an&&(i=0n,++n>an&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(t){if(t===0)return Z;let e=t<0;e&&(t=-t);let n=t>>>0,i=(t-n)/4294967296>>>0;return e&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Z}},Z=new N(0,0);Z.toBigInt=function(){return 0n};Z.zzEncode=Z.zzDecode=function(){return this};Z.length=function(){return 1};var an=4294967296n;function cn(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function hn(r,t,e){if(e-t<1)return"";let i,o=[],s=0,c;for(;t<e;)c=r[t++],c<128?o[s++]=c:c>191&&c<224?o[s++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[s++]=55296+(c>>10),o[s++]=56320+(c&1023)):o[s++]=(c&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function Te(r,t,e){let n=e,i,o;for(let s=0;s<r.length;++s)i=r.charCodeAt(s),i<128?t[e++]=i:i<2048?(t[e++]=i>>6|192,t[e++]=i&63|128):(i&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,t[e++]=i>>18|240,t[e++]=i>>12&63|128,t[e++]=i>>6&63|128,t[e++]=i&63|128):(t[e++]=i>>12|224,t[e++]=i>>6&63|128,t[e++]=i&63|128);return e-n}function M(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Qt(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Ee=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,M(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw M(this,4);return Qt(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw M(this,4);return Qt(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw M(this,4);let t=nn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw M(this,4);let t=sn(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw M(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return hn(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw M(this,t);this.pos+=t}else do if(this.pos>=this.len)throw M(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new N(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw M(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw M(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw M(this,8);let t=Qt(this.buf,this.pos+=4),e=Qt(this.buf,this.pos+=4);return new N(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ke(r){return new Ee(r instanceof Uint8Array?r:r.subarray())}function kt(r,t){let e=ke(r);return t.decode(e)}var Ce={};D(Ce,{base10:()=>Io});var Io=X({prefix:"9",name:"base10",alphabet:"0123456789"});var Ie={};D(Ie,{base16:()=>No,base16upper:()=>Lo});var No=T({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lo=T({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ne={};D(Ne,{base2:()=>zo});var zo=T({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Le={};D(Le,{base256emoji:()=>Vo});var un=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Po=un.reduce((r,t,e)=>(r[e]=t,r),[]),Uo=un.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Fo(r){return r.reduce((t,e)=>(t+=Po[e],t),"")}function Mo(r){let t=[];for(let e of r){let n=Uo[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Vo=at({prefix:"\u{1F680}",name:"base256emoji",encode:Fo,decode:Mo});var ze={};D(ze,{base36:()=>Ro,base36upper:()=>Oo});var Ro=X({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Oo=X({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Pe={};D(Pe,{base64:()=>Ho,base64pad:()=>$o,base64url:()=>Go,base64urlpad:()=>qo});var Ho=T({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$o=T({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Go=T({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),qo=T({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ue={};D(Ue,{base8:()=>jo});var jo=T({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Fe={};D(Fe,{identity:()=>Jo});var Jo=at({prefix:"\0",name:"identity",encode:r=>de(r),decode:r=>le(r)});var Xc=new TextEncoder,Kc=new TextDecoder;var Ct={};D(Ct,{code:()=>Yt,decode:()=>Qo,encode:()=>Wo,name:()=>Ko});var Ko="raw",Yt=85;function Wo(r){return F(r)}function Qo(r){return F(r)}var Me={};D(Me,{identity:()=>ts});var ln=0,Yo="identity",dn=F;function Zo(r){return Y(ln,dn(r))}var ts={code:ln,name:Yo,encode:dn,digest:Zo};var Oe={};D(Oe,{sha256:()=>Re,sha512:()=>es});function tt({name:r,code:t,encode:e}){return new Ve(r,t,e)}var Ve=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Y(this.code,e):e.then(n=>Y(this.code,n))}else throw Error("Unknown type, must be binary type")}};function mn(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Re=tt({name:"sha2-256",code:18,encode:mn("SHA-256")}),es=tt({name:"sha2-512",code:19,encode:mn("SHA-512")});var He={...Fe,...Ne,...Ue,...Ce,...Ie,...we,...ze,...ye,...Pe,...Le},ch={...Oe,...Me};function gn(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var bn=gn("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$e=gn("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=U(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),rs={utf8:bn,"utf-8":bn,hex:He.base16,latin1:$e,ascii:$e,binary:$e,...He},wn=rs;function Zt(r,t="utf8"){let e=wn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?J(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Ge(r){let t=r??8192,e=t>>>1,n,i=t;return function(s){if(s<1||s>e)return U(s);i+s>t&&(n=U(t),i=0);let c=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),c}}var et=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function qe(){}var Je=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},ns=Ge();function is(r){return globalThis.Buffer!=null?U(r):ns(r)}var Lt=class{len;head;tail;states;constructor(){this.len=0,this.head=new et(qe,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new et(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Xe((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(It,10,N.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=N.fromBigInt(t);return this._push(It,e.length(),e)}uint64Number(t){let e=N.fromNumber(t);return this._push(It,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=N.fromBigInt(t).zzEncode();return this._push(It,e.length(),e)}sint64Number(t){let e=N.fromNumber(t).zzEncode();return this._push(It,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(je,1,t?1:0)}fixed32(t){return this._push(Nt,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=N.fromBigInt(t);return this._push(Nt,4,e.lo)._push(Nt,4,e.hi)}fixed64Number(t){let e=N.fromNumber(t);return this._push(Nt,4,e.lo)._push(Nt,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(rn,4,t)}double(t){return this._push(on,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(je,1,0):this.uint32(e)._push(ss,e,t)}string(t){let e=cn(t);return e!==0?this.uint32(e)._push(Te,e,t):this._push(je,1,0)}fork(){return this.states=new Je(this),this.head=this.tail=new et(qe,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new et(qe,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=is(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function je(r,t,e){t[e]=r&255}function os(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Xe=class extends et{next;constructor(t,e){super(os,t,e),this.next=void 0}};function It(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Nt(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function ss(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Lt.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(as,t,r),this},Lt.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(cs,t,r),this});function as(r,t,e){t.set(r,e)}function cs(r,t,e){r.length<40?Te(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Zt(r),e)}function Ke(){return new Lt}function zt(r,t){let e=Ke();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var dt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(dt||(dt={}));function te(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function We(r){function t(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let e=function(o,s){let c=t(o);s.int32(c)},n=function(o){let s=o.int32();return t(s)};return te("enum",dt.VARINT,e,n)}function Pt(r,t){return te("message",dt.LENGTH_DELIMITED,r,t)}var V;(function(r){let t;(function(i){i.Raw="Raw",i.Directory="Directory",i.File="File",i.Metadata="Metadata",i.Symlink="Symlink",i.HAMTShard="HAMTShard"})(t=r.DataType||(r.DataType={}));let e;(function(i){i[i.Raw=0]="Raw",i[i.Directory=1]="Directory",i[i.File=2]="File",i[i.Metadata=3]="Metadata",i[i.Symlink=4]="Symlink",i[i.HAMTShard=5]="HAMTShard"})(e||(e={})),function(i){i.codec=()=>We(e)}(t=r.DataType||(r.DataType={}));let n;r.codec=()=>(n==null&&(n=Pt((i,o,s={})=>{if(s.lengthDelimited!==!1&&o.fork(),i.Type!=null&&(o.uint32(8),r.DataType.codec().encode(i.Type,o)),i.Data!=null&&(o.uint32(18),o.bytes(i.Data)),i.filesize!=null&&(o.uint32(24),o.uint64(i.filesize)),i.blocksizes!=null)for(let c of i.blocksizes)o.uint32(32),o.uint64(c);i.hashType!=null&&(o.uint32(40),o.uint64(i.hashType)),i.fanout!=null&&(o.uint32(48),o.uint64(i.fanout)),i.mode!=null&&(o.uint32(56),o.uint32(i.mode)),i.mtime!=null&&(o.uint32(66),ee.codec().encode(i.mtime,o)),s.lengthDelimited!==!1&&o.ldelim()},(i,o)=>{let s={blocksizes:[]},c=o==null?i.len:i.pos+o;for(;i.pos<c;){let u=i.uint32();switch(u>>>3){case 1:s.Type=r.DataType.codec().decode(i);break;case 2:s.Data=i.bytes();break;case 3:s.filesize=i.uint64();break;case 4:s.blocksizes.push(i.uint64());break;case 5:s.hashType=i.uint64();break;case 6:s.fanout=i.uint64();break;case 7:s.mode=i.uint32();break;case 8:s.mtime=ee.codec().decode(i,i.uint32());break;default:i.skipType(u&7);break}}return s})),n),r.encode=i=>zt(i,r.codec()),r.decode=i=>kt(i,r.codec())})(V||(V={}));var ee;(function(r){let t;r.codec=()=>(t==null&&(t=Pt((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.Seconds!=null&&(n.uint32(8),n.int64(e.Seconds)),e.FractionalNanoseconds!=null&&(n.uint32(21),n.fixed32(e.FractionalNanoseconds)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:i.Seconds=e.int64();break;case 2:i.FractionalNanoseconds=e.fixed32();break;default:e.skipType(s&7);break}}return i})),t),r.encode=e=>zt(e,r.codec()),r.decode=e=>kt(e,r.codec())})(ee||(ee={}));var yn;(function(r){let t;r.codec=()=>(t==null&&(t=Pt((e,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),e.MimeType!=null&&(n.uint32(10),n.string(e.MimeType)),i.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let i={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let s=e.uint32();switch(s>>>3){case 1:i.MimeType=e.string();break;default:e.skipType(s&7);break}}return i})),t),r.encode=e=>zt(e,r.codec()),r.decode=e=>kt(e,r.codec())})(yn||(yn={}));var xn={Raw:"raw",Directory:"directory",File:"file",Metadata:"metadata",Symlink:"symlink",HAMTShard:"hamt-sharded-directory"},hs=["directory","hamt-sharded-directory"],vn=parseInt("0644",8),An=parseInt("0755",8),L=class r{static unmarshal(t){let e=V.decode(t),n=new r({type:xn[e.Type!=null?e.Type.toString():"File"],data:e.Data,blockSizes:e.blocksizes,mode:e.mode,mtime:e.mtime!=null?{secs:e.mtime.Seconds??0n,nsecs:e.mtime.FractionalNanoseconds}:void 0,fanout:e.fanout});return n._originalMode=e.mode??0,n}type;data;blockSizes;hashType;fanout;mtime;_mode;_originalMode;constructor(t={type:"file"}){let{type:e,data:n,blockSizes:i,hashType:o,fanout:s,mtime:c,mode:u}=t;if(e!=null&&!Object.values(xn).includes(e))throw(0,Qe.default)(new Error("Type: "+e+" is not valid"),"ERR_INVALID_TYPE");this.type=e??"file",this.data=n,this.hashType=o,this.fanout=s,this.blockSizes=i??[],this._originalMode=0,this.mode=u,this.mtime=c}set mode(t){t==null?this._mode=this.isDirectory()?An:vn:this._mode=t&4095}get mode(){return this._mode}isDirectory(){return hs.includes(this.type)}addBlockSize(t){this.blockSizes.push(t)}removeBlockSize(t){this.blockSizes.splice(t,1)}fileSize(){if(this.isDirectory())return 0n;let t=0n;return this.blockSizes.forEach(e=>{t+=e}),this.data!=null&&(t+=BigInt(this.data.length)),t}marshal(){let t;switch(this.type){case"raw":t=V.DataType.Raw;break;case"directory":t=V.DataType.Directory;break;case"file":t=V.DataType.File;break;case"metadata":t=V.DataType.Metadata;break;case"symlink":t=V.DataType.Symlink;break;case"hamt-sharded-directory":t=V.DataType.HAMTShard;break;default:throw(0,Qe.default)(new Error(`Type: ${t} is not valid`),"ERR_INVALID_TYPE")}let e=this.data;(this.data==null||this.data.length===0)&&(e=void 0);let n;this.mode!=null&&(n=this._originalMode&4294963200|(this.mode??0),n===vn&&!this.isDirectory()&&(n=void 0),n===An&&this.isDirectory()&&(n=void 0));let i;return this.mtime!=null&&(i={Seconds:this.mtime.secs,FractionalNanoseconds:this.mtime.nsecs}),V.encode({Type:t,Data:e,filesize:this.isDirectory()?void 0:this.fileSize(),blocksizes:this.blockSizes,hashType:this.hashType,fanout:this.fanout,mode:n,mtime:i})}};var q=class extends Event{constructor(t,e){super(t),this.detail=e}};var R=async(r,t,e)=>{e.codec==null&&(e.codec=Et);let n=await Re.digest(r),i=k.create(e.cidVersion,e.codec.code,n);return await t.put(i,r,e),i};function Bn(r){return async function*(e,n){let i=0n;for await(let o of e.content)yield async()=>{let s,c={codec:Et,cidVersion:r.cidVersion,onProgress:r.onProgress};r.rawLeaves?(c.codec=Ct,c.cidVersion=1):(s=new L({type:r.leafType,data:o}),o=P({Data:s.marshal(),Links:[]}));let u=await R(o,n,c);return i+=BigInt(o.byteLength),r.onProgress?.(new q("unixfs:importer:progress:file:write",{bytesWritten:i,cid:u,path:e.path})),{cid:u,unixfs:s,size:BigInt(o.length),block:o}}}}var Ye=it(xt(),1);var Sn=async(r,t,e)=>{let n=new L({type:"directory",mtime:r.mtime,mode:r.mode}),i=P(z({Data:n.marshal()})),o=await R(i,t,e),s=r.path;return{cid:o,path:s,unixfs:n,size:BigInt(i.length),originalPath:r.originalPath,block:i}};async function*fs(r,t,e){let n=-1,i;for await(let o of At(e.bufferImporter(r,t),e.blockWriteConcurrency)){if(n++,n===0){i={...o,single:!0};continue}else n===1&&i!=null&&(yield{...i,block:void 0,single:void 0},i=void 0);yield{...o,block:void 0}}i!=null&&(yield i)}function Dn(r){return r.single===!0}var us=(r,t,e)=>async function(i){if(i.length===1&&Dn(i[0])&&e.reduceSingleLeafToSelf){let f=i[0],w=f.block;return Dn(f)&&(r.mtime!==void 0||r.mode!==void 0)&&(f.unixfs=new L({type:"file",mtime:r.mtime,mode:r.mode,data:f.block}),w={Data:f.unixfs.marshal(),Links:[]},f.block=P(z(w)),f.cid=await R(f.block,t,{...e,cidVersion:e.cidVersion}),f.size=BigInt(f.block.length)),e.onProgress?.(new q("unixfs:importer:progress:file:layout",{cid:f.cid,path:f.originalPath})),{cid:f.cid,path:r.path,unixfs:f.unixfs,size:f.size,originalPath:f.originalPath}}let o=new L({type:"file",mtime:r.mtime,mode:r.mode}),s=i.filter(f=>f.cid.code===Yt&&f.size>0||f.unixfs!=null&&f.unixfs.data==null&&f.unixfs.fileSize()>0n?!0:!!f.unixfs?.data?.length).map(f=>f.cid.code===Yt?(o.addBlockSize(f.size),{Name:"",Tsize:Number(f.size),Hash:f.cid}):(f.unixfs==null||f.unixfs.data==null?o.addBlockSize(f.unixfs?.fileSize()??0n):o.addBlockSize(BigInt(f.unixfs.data.length)),{Name:"",Tsize:Number(f.size),Hash:f.cid})),c={Data:o.marshal(),Links:s},u=P(z(c)),x=await R(u,t,e);return e.onProgress?.(new q("unixfs:importer:progress:file:layout",{cid:x,path:r.originalPath})),{cid:x,path:r.path,unixfs:o,size:BigInt(u.length+c.Links.reduce((f,w)=>f+(w.Tsize??0),0)),originalPath:r.originalPath,block:u}},_n=async(r,t,e)=>e.layout(fs(r,t,e),us(r,t,e));function ls(r){return Symbol.iterator in r}function ds(r){return Symbol.asyncIterator in r}function ps(r){try{if(r instanceof Uint8Array)return async function*(){yield r}();if(ls(r))return async function*(){yield*r}();if(ds(r))return r}catch{throw(0,Ye.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}throw(0,Ye.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}function Tn(r){return async function*(e,n){for await(let i of e){let o;if(i.path!=null&&(o=i.path,i.path=i.path.split("/").filter(s=>s!=null&&s!==".").join("/")),ms(i)){let s={path:i.path,mtime:i.mtime,mode:i.mode,content:async function*(){let c=0n;for await(let u of r.chunker(r.chunkValidator(ps(i.content)))){let x=BigInt(u.byteLength);c+=x,r.onProgress?.(new q("unixfs:importer:progress:file:read",{bytesRead:c,chunkSize:x,path:i.path})),yield u}}(),originalPath:o};yield async()=>_n(s,n,r)}else if(i.path!=null){let s={path:i.path,mtime:i.mtime,mode:i.mode,originalPath:o};yield async()=>Sn(s,n,r)}else throw new Error("Import candidate must have content or path or both")}}}function ms(r){return r.content!=null}var Ze=it(xt(),1);var En=()=>async function*(t){for await(let e of t){if(e.length===void 0)throw(0,Ze.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT");if(typeof e=="string"||e instanceof String)yield Zt(e.toString());else if(Array.isArray(e))yield Uint8Array.from(e);else if(e instanceof Uint8Array)yield e;else throw(0,Ze.default)(new Error("Content was invalid"),"ERR_INVALID_CONTENT")}};var bs=174;function tr(r){let t=r?.maxChildrenPerNode??bs;return async function e(n,i){let o=[];for await(let s of vt(n,t))o.push(await i(s));return o.length>1?e(o,i):o[0]}}var H=class{options;root;dir;path;dirty;flat;parent;parentKey;unixfs;mode;mtime;cid;size;nodeSize;constructor(t,e){this.options=e??{},this.root=t.root,this.dir=t.dir,this.path=t.path,this.dirty=t.dirty,this.flat=t.flat,this.parent=t.parent,this.parentKey=t.parentKey,this.unixfs=t.unixfs,this.mode=t.mode,this.mtime=t.mtime}},Ut=k.parse("QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn"),Ft=k.parse("zdj7WbTaiJT1fgatdet9Ei9iDB5hdCxkbVyhyh8YTUnXMiwYi");var rt=class extends H{_children;constructor(t,e){super(t,e),this._children=new Map}async put(t,e){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,this._children.set(t,e)}async get(t){return Promise.resolve(this._children.get(t))}childCount(){return this._children.size}directChildrenCount(){return this.childCount()}onlyChild(){return this._children.values().next().value}async*eachChildSeries(){for(let[t,e]of this._children.entries())yield{key:t,child:e}}estimateNodeSize(){if(this.nodeSize!==void 0)return this.nodeSize;this.nodeSize=0;for(let[t,e]of this._children.entries())e.size!=null&&e.cid!=null&&(this.nodeSize+=t.length+(this.options.cidVersion===1?Ft.bytes.byteLength:Ut.bytes.byteLength));return this.nodeSize}async*flush(t){let e=[];for(let[u,x]of this._children.entries()){let f=x;if(x instanceof H)for await(let w of x.flush(t))f=w,yield w;f.size!=null&&f.cid!=null&&e.push({Name:u,Tsize:Number(f.size),Hash:f.cid})}let n=new L({type:"directory",mtime:this.mtime,mode:this.mode}),i={Data:n.marshal(),Links:e},o=P(z(i)),s=await R(o,t,this.options),c=o.length+i.Links.reduce((u,x)=>u+(x.Tsize==null?0:x.Tsize),0);this.cid=s,this.size=c,yield{cid:s,unixfs:n,path:this.path,size:BigInt(c)}}};var ne=it(In(),1);function gs(r){let t=new Array(4);for(let e=0;e<4;e++)t[e]=r&255,r=r>>8;return new Uint8Array(t)}var Ff=tt({name:"murmur3-32",code:35,encode:r=>gs(ne.default.x86.hash32(r))}),Nn=tt({name:"murmur3-128",code:34,encode:r=>st.fromHex(ne.default.x64.hash128(r))}),Mf=tt({name:"murmur3-x64-64",code:34,encode:r=>st.fromHex(ne.default.x64.hash128(r)).subarray(0,8)});var oi=it(Pn(),1);function pt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}var or={};D(or,{base10:()=>_s});function vs(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(e[s]!==255)throw new TypeError(o+" is ambiguous");e[s]=i}var c=r.length,u=r.charAt(0),x=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function w(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var d=0,_=0,l=0,p=h.length;l!==p&&h[l]===0;)l++,d++;for(var m=(p-l)*f+1>>>0,g=new Uint8Array(m);l!==p;){for(var y=h[l],v=0,b=m-1;(y!==0||v<_)&&b!==-1;b--,v++)y+=256*g[b]>>>0,g[b]=y%c>>>0,y=y/c>>>0;if(y!==0)throw new Error("Non-zero carry");_=v,l++}for(var A=m-_;A!==m&&g[A]===0;)A++;for(var I=u.repeat(d);A<m;++A)I+=r.charAt(g[A]);return I}function S(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var d=0;if(h[d]!==" "){for(var _=0,l=0;h[d]===u;)_++,d++;for(var p=(h.length-d)*x+1>>>0,m=new Uint8Array(p);h[d];){var g=e[h.charCodeAt(d)];if(g===255)return;for(var y=0,v=p-1;(g!==0||y<l)&&v!==-1;v--,y++)g+=c*m[v]>>>0,m[v]=g%256>>>0,g=g/256>>>0;if(g!==0)throw new Error("Non-zero carry");l=y,d++}if(h[d]!==" "){for(var b=p-l;b!==p&&m[b]===0;)b++;for(var A=new Uint8Array(_+(p-b)),I=_;b!==p;)A[I++]=m[b++];return A}}}function a(h){var d=S(h);if(d)return d;throw new Error(`Non-${t} character`)}return{encode:w,decodeUnsafe:S,decode:a}}var As=vs,Bs=As,Un=Bs;var Gf=new Uint8Array(0);var Fn=(r,t)=>{if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0},j=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var Mn=r=>new TextEncoder().encode(r),Vn=r=>new TextDecoder().decode(r);var er=class{constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},rr=class{constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.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 On(this,t)}},nr=class{constructor(t){this.decoders=t}or(t){return On(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},On=(r,t)=>new nr({...r.decoders||{[r.prefix]:r},...t.decoders||{[t.prefix]:t}}),ir=class{constructor(t,e,n,i){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=i,this.encoder=new er(t,e,n),this.decoder=new rr(t,e,i)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},mt=({name:r,prefix:t,encode:e,decode:n})=>new ir(r,t,e,n),W=({prefix:r,name:t,alphabet:e})=>{let{encode:n,decode:i}=Un(e,t);return mt({prefix:r,name:t,encode:n,decode:o=>j(i(o))})},Ss=(r,t,e,n)=>{let i={};for(let f=0;f<t.length;++f)i[t[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*e/8|0),c=0,u=0,x=0;for(let f=0;f<o;++f){let w=i[r[f]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);u=u<<e|w,c+=e,c>=8&&(c-=8,s[x++]=255&u>>c)}if(c>=e||255&u<<8-c)throw new SyntaxError("Unexpected end of data");return s},Ds=(r,t,e)=>{let n=t[t.length-1]==="=",i=(1<<e)-1,o="",s=0,c=0;for(let u=0;u<r.length;++u)for(c=c<<8|r[u],s+=8;s>e;)s-=e,o+=t[i&c>>s];if(s&&(o+=t[i&c<<e-s]),n)for(;o.length*e&7;)o+="=";return o},E=({name:r,prefix:t,bitsPerChar:e,alphabet:n})=>mt({prefix:t,name:r,encode(i){return Ds(i,n,e)},decode(i){return Ss(i,n,e,r)}});var _s=W({prefix:"9",name:"base10",alphabet:"0123456789"});var sr={};D(sr,{base16:()=>Ts,base16upper:()=>Es});var Ts=E({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Es=E({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ar={};D(ar,{base2:()=>ks});var ks=E({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var cr={};D(cr,{base256emoji:()=>zs});var Hn=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Cs=Hn.reduce((r,t,e)=>(r[e]=t,r),[]),Is=Hn.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Ns(r){return r.reduce((t,e)=>(t+=Cs[e],t),"")}function Ls(r){let t=[];for(let e of r){let n=Is[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var zs=mt({prefix:"\u{1F680}",name:"base256emoji",encode:Ns,decode:Ls});var hr={};D(hr,{base32:()=>bt,base32hex:()=>Ms,base32hexpad:()=>Rs,base32hexpadupper:()=>Os,base32hexupper:()=>Vs,base32pad:()=>Us,base32padupper:()=>Fs,base32upper:()=>Ps,base32z:()=>Hs});var bt=E({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ps=E({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Us=E({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Fs=E({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ms=E({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vs=E({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Rs=E({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Os=E({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Hs=E({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fr={};D(fr,{base36:()=>$s,base36upper:()=>Gs});var $s=W({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Gs=W({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ur={};D(ur,{base58btc:()=>$,base58flickr:()=>qs});var $=W({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qs=W({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var lr={};D(lr,{base64:()=>js,base64pad:()=>Js,base64url:()=>Xs,base64urlpad:()=>Ks});var js=E({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Js=E({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xs=E({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ks=E({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var dr={};D(dr,{base8:()=>Ws});var Ws=E({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var pr={};D(pr,{identity:()=>Qs});var Qs=mt({prefix:"\0",name:"identity",encode:r=>Vn(r),decode:r=>Mn(r)});var ou=new TextEncoder,su=new TextDecoder;var br={};D(br,{identity:()=>xa});var ta=qn,$n=128,ea=127,ra=~ea,na=Math.pow(2,31);function qn(r,t,e){t=t||[],e=e||0;for(var n=e;r>=na;)t[e++]=r&255|$n,r/=128;for(;r&ra;)t[e++]=r&255|$n,r>>>=7;return t[e]=r|0,qn.bytes=e-n+1,t}var ia=mr,oa=128,Gn=127;function mr(r,n){var e=0,n=n||0,i=0,o=n,s,c=r.length;do{if(o>=c)throw mr.bytes=0,new RangeError("Could not decode varint");s=r[o++],e+=i<28?(s&Gn)<<i:(s&Gn)*Math.pow(2,i),i+=7}while(s>=oa);return mr.bytes=o-n,e}var sa=Math.pow(2,7),aa=Math.pow(2,14),ca=Math.pow(2,21),ha=Math.pow(2,28),fa=Math.pow(2,35),ua=Math.pow(2,42),la=Math.pow(2,49),da=Math.pow(2,56),pa=Math.pow(2,63),ma=function(r){return r<sa?1:r<aa?2:r<ca?3:r<ha?4:r<fa?5:r<ua?6:r<la?7:r<da?8:r<pa?9:10},ba={encode:ta,decode:ia,encodingLength:ma},ga=ba,Vt=ga;var Rt=(r,t=0)=>[Vt.decode(r,t),Vt.decode.bytes],gt=(r,t,e=0)=>(Vt.encode(r,t,e),t),wt=r=>Vt.encodingLength(r);var nt=(r,t)=>{let e=t.byteLength,n=wt(r),i=n+wt(e),o=new Uint8Array(i+e);return gt(r,o,0),gt(e,o,n),o.set(t,i),new yt(r,e,t,o)},jn=r=>{let t=j(r),[e,n]=Rt(t),[i,o]=Rt(t.subarray(n)),s=t.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new yt(e,i,s,t)},Jn=(r,t)=>{if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Fn(r.bytes,e.bytes)}},yt=class{constructor(t,e,n,i){this.code=t,this.size=e,this.digest=n,this.bytes=i}};var Xn=0,wa="identity",Kn=j,ya=r=>nt(Xn,Kn(r)),xa={code:Xn,name:wa,encode:Kn,digest:ya};var yr={};D(yr,{sha256:()=>va,sha512:()=>Aa});var wr=({name:r,code:t,encode:e})=>new gr(r,t,e),gr=class{constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?nt(this.code,e):e.then(n=>nt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Qn=r=>async t=>new Uint8Array(await crypto.subtle.digest(r,t)),va=wr({name:"sha2-256",code:18,encode:Qn("SHA-256")}),Aa=wr({name:"sha2-512",code:19,encode:Qn("SHA-512")});var Yn=(r,t)=>{let{bytes:e,version:n}=r;switch(n){case 0:return Sa(e,xr(r),t||$.encoder);default:return Da(e,xr(r),t||bt.encoder)}};var Zn=new WeakMap,xr=r=>{let t=Zn.get(r);if(t==null){let e=new Map;return Zn.set(r,e),e}return t},oe=class r{constructor(t,e,n,i){this.code=e,this.version=t,this.multihash=n,this.bytes=i,this["/"]=i}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:e}=this;if(t!==Ht)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==_a)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:e}=this.multihash,n=nt(t,e);return r.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 r.equals(this,t)}static equals(t,e){let n=e;return n&&t.code===n.code&&t.version===n.version&&Jn(t.multihash,n.multihash)}toString(t){return Yn(this,t)}toJSON(){return{"/":Yn(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:i,multihash:o,bytes:s}=e;return new r(n,i,o,s||ti(n,i,o.bytes))}else if(e[Ta]===!0){let{version:n,multihash:i,code:o}=e,s=jn(i);return r.create(n,o,s)}else return null}static create(t,e,n){if(typeof e!="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(e!==Ht)throw new Error(`Version 0 CID must use dag-pb (code: ${Ht}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let i=ti(t,e,n.bytes);return new r(t,e,n,i)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Ht,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,i=j(t.subarray(n,n+e.multihashSize));if(i.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=i.subarray(e.multihashSize-e.digestSize),s=new yt(e.multihashCode,e.digestSize,o,i);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[w,S]=Rt(t.subarray(e));return e+=S,w},i=n(),o=Ht;if(i===18?(i=0,e=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=e,c=n(),u=n(),x=e+u,f=x-s;return{version:i,codec:o,multihashCode:c,digestSize:u,multihashSize:f,size:x}}static parse(t,e){let[n,i]=Ba(t,e),o=r.decode(i);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return xr(o).set(n,t),o}},Ba=(r,t)=>{switch(r[0]){case"Q":{let e=t||$;return[$.prefix,e.decode(`${$.prefix}${r}`)]}case $.prefix:{let e=t||$;return[$.prefix,e.decode(r)]}case bt.prefix:{let e=t||bt;return[bt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}},Sa=(r,t,e)=>{let{prefix:n}=e;if(n!==$.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let i=t.get(n);if(i==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return i},Da=(r,t,e)=>{let{prefix:n}=e,i=t.get(n);if(i==null){let o=e.encode(r);return t.set(n,o),o}else return i},Ht=112,_a=18,ti=(r,t,e)=>{let n=wt(r),i=n+wt(t),o=new Uint8Array(i+e.byteLength);return gt(r,o,0),gt(t,o,n),o.set(e,i),o},Ta=Symbol.for("@ipld/js-cid/CID");var vr={...pr,...ar,...dr,...or,...sr,...hr,...fr,...ur,...lr,...cr},Au={...yr,...br};function se(r=0){return globalThis.Buffer?.allocUnsafe!=null?pt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function ri(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ei=ri("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ar=ri("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=se(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Ea={utf8:ei,"utf-8":ei,hex:vr.base16,latin1:Ar,ascii:Ar,binary:Ar,...vr},ni=Ea;function ii(r,t="utf8"){let e=ni[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?pt(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}var Q=class r{constructor(t,e,n=0){this._options=t,this._popCount=0,this._parent=e,this._posAtParent=n,this._children=new oi.default,this.key=null}async put(t,e){let n=await this._findNewBucketAndPos(t);await n.bucket._putAt(n,t,e)}async get(t){let e=await this._findChild(t);if(e!=null)return e.value}async del(t){let e=await this._findPlace(t),n=e.bucket._at(e.pos);n!=null&&n.key===t&&e.bucket._delAt(e.pos)}leafCount(){return this._children.compactArray().reduce((e,n)=>n instanceof r?e+n.leafCount():e+1,0)}childrenCount(){return this._children.length}onlyChild(){return this._children.get(0)}*eachLeafSeries(){let t=this._children.compactArray();for(let e of t)e instanceof r?yield*e.eachLeafSeries():yield e}serialize(t,e){let n=[];return e(this._children.reduce((i,o,s)=>(o!=null&&(o instanceof r?i.push(o.serialize(t,e)):i.push(t(o,s))),i),n))}async asyncTransform(t,e){return await si(this,t,e)}toJSON(){return this.serialize(Ca,Ia)}prettyPrint(){return JSON.stringify(this.toJSON(),null," ")}tableSize(){return Math.pow(2,this._options.bits)}async _findChild(t){let e=await this._findPlace(t),n=e.bucket._at(e.pos);if(!(n instanceof r)&&n!=null&&n.key===t)return n}async _findPlace(t){let e=this._options.hash(typeof t=="string"?ii(t):t),n=await e.take(this._options.bits),i=this._children.get(n);return i instanceof r?await i._findPlace(e):{bucket:this,pos:n,hash:e,existingChild:i}}async _findNewBucketAndPos(t){let e=await this._findPlace(t);if(e.existingChild!=null&&e.existingChild.key!==t){let n=new r(this._options,e.bucket,e.pos);e.bucket._putObjectAt(e.pos,n);let i=await n._findPlace(e.existingChild.hash);return i.bucket._putAt(i,e.existingChild.key,e.existingChild.value),await n._findNewBucketAndPos(e.hash)}return e}_putAt(t,e,n){this._putObjectAt(t.pos,{key:e,value:n,hash:t.hash})}_putObjectAt(t,e){this._children.get(t)==null&&this._popCount++,this._children.set(t,e)}_delAt(t){if(t===-1)throw new Error("Invalid position");this._children.get(t)!=null&&this._popCount--,this._children.unset(t),this._level()}_level(){if(this._parent!=null&&this._popCount<=1)if(this._popCount===1){let t=this._children.find(ka);if(t!=null&&!(t instanceof r)){let e=t.hash;e.untake(this._options.bits);let n={pos:this._posAtParent,hash:e,bucket:this._parent};this._parent._putAt(n,t.key,t.value)}}else this._parent._delAt(this._posAtParent)}_at(t){return this._children.get(t)}};function ka(r){return!!r}function Ca(r,t){return r.key}function Ia(r){return r}async function si(r,t,e){let n=[];for(let i of r._children.compactArray())if(i instanceof Q)await si(i,t,e);else{let o=await t(i);n.push({bitField:r._children.bitField(),children:o})}return await e(n)}var Na=[255,254,252,248,240,224,192,128],La=[1,3,7,15,31,63,127,255],ae=class{constructor(t){this._value=t,this._currentBytePos=t.length-1,this._currentBitPos=7}availableBits(){return this._currentBitPos+1+this._currentBytePos*8}totalBits(){return this._value.length*8}take(t){let e=t,n=0;for(;e>0&&this._haveBits();){let i=this._value[this._currentBytePos],o=this._currentBitPos+1,s=Math.min(o,e),c=za(i,o-s,s);n=(n<<s)+c,e-=s,this._currentBitPos-=s,this._currentBitPos<0&&(this._currentBitPos=7,this._currentBytePos--)}return n}untake(t){for(this._currentBitPos+=t;this._currentBitPos>7;)this._currentBitPos-=8,this._currentBytePos+=1}_haveBits(){return this._currentBytePos>=0}};function za(r,t,e){let n=Pa(t,e);return(r&n)>>>t}function Pa(r,t){return Na[r]&La[Math.min(t+r-1,7)]}function ai(r,t){t==null&&(t=r.reduce((i,o)=>i+o.length,0));let e=se(t),n=0;for(let i of r)e.set(i,n),n+=i.length;return pt(e)}function ci(r){function t(e){return e instanceof ce?e:new ce(e,r)}return t}var ce=class{constructor(t,e){if(!(t instanceof Uint8Array))throw new Error("can only hash Uint8Arrays");this._value=t,this._hashFn=e,this._depth=-1,this._availableBits=0,this._currentBufferIndex=0,this._buffers=[]}async take(t){let e=t;for(;this._availableBits<e;)await this._produceMoreBits();let n=0;for(;e>0;){let i=this._buffers[this._currentBufferIndex],o=Math.min(i.availableBits(),e),s=i.take(o);n=(n<<o)+s,e-=o,this._availableBits-=o,i.availableBits()===0&&this._currentBufferIndex++}return n}untake(t){let e=t;for(;e>0;){let n=this._buffers[this._currentBufferIndex],i=Math.min(n.totalBits()-n.availableBits(),e);n.untake(i),e-=i,this._availableBits+=i,this._currentBufferIndex>0&&n.totalBits()===n.availableBits()&&(this._depth--,this._currentBufferIndex--)}}async _produceMoreBits(){this._depth++;let t=this._depth>0?ai([this._value,Uint8Array.from([this._depth])]):this._value,e=await this._hashFn(t),n=new ae(e);this._buffers.push(n),this._availableBits+=n.availableBits()}};function hi(r){if(r==null||r.hashFn==null)throw new Error("please define an options.hashFn");let t={bits:r.bits??8,hash:ci(r.hashFn)};return new Q(t)}async function Ua(r){return(await Nn.encode(r)).slice(0,8).reverse()}var fi=BigInt(34),Fa=8,Br=class extends H{_bucket;constructor(t,e){super(t,e),this._bucket=hi({hashFn:Ua,bits:e.shardFanoutBits??Fa})}async put(t,e){this.cid=void 0,this.size=void 0,this.nodeSize=void 0,await this._bucket.put(t,e)}async get(t){return this._bucket.get(t)}childCount(){return this._bucket.leafCount()}directChildrenCount(){return this._bucket.childrenCount()}onlyChild(){return this._bucket.onlyChild()}async*eachChildSeries(){for await(let{key:t,value:e}of this._bucket.eachLeafSeries())yield{key:t,child:e}}estimateNodeSize(){return this.nodeSize!==void 0?this.nodeSize:(this.nodeSize=di(this._bucket,this,this.options),this.nodeSize)}async*flush(t){for await(let e of li(this._bucket,t,this,this.options))yield{...e,path:this.path}}},ui=Br;async function*li(r,t,e,n){let i=r._children,o=(r.tableSize()-1).toString(16).length,s=[],c=0n;for(let h=0;h<i.length;h++){let d=i.get(h);if(d==null)continue;let _=h.toString(16).toUpperCase().padStart(o,"0");if(d instanceof Q){let l;for await(let p of li(d,t,null,n))l=p;if(l==null)throw new Error("Could not flush sharded directory, no subshard found");s.push({Name:_,Tsize:Number(l.size),Hash:l.cid}),c+=l.size}else if(Ma(d.value)){let l=d.value,p;for await(let g of l.flush(t))p=g,yield p;if(p==null)throw new Error("Did not flush dir");let m=_+d.key;s.push({Name:m,Tsize:Number(p.size),Hash:p.cid}),c+=p.size}else{let l=d.value;if(l.cid==null)continue;let p=_+d.key,m=l.size;s.push({Name:p,Tsize:Number(m),Hash:l.cid}),c+=BigInt(m??0)}}let u=Uint8Array.from(i.bitField().reverse()),x=new L({type:"hamt-sharded-directory",data:u,fanout:BigInt(r.tableSize()),hashType:fi,mtime:e?.mtime,mode:e?.mode}),f={Data:x.marshal(),Links:s},w=P(z(f)),S=await R(w,t,n),a=BigInt(w.byteLength)+c;yield{cid:S,unixfs:x,size:a}}function Ma(r){return typeof r.flush=="function"}function di(r,t,e){let n=r._children,i=(r.tableSize()-1).toString(16).length,o=[];for(let x=0;x<n.length;x++){let f=n.get(x);if(f==null)continue;let w=x.toString(16).toUpperCase().padStart(i,"0");if(f instanceof Q){let S=di(f,null,e);o.push({Name:w,Tsize:Number(S),Hash:e.cidVersion===0?Ut:Ft})}else if(typeof f.value.flush=="function"){let a=f.value.nodeSize();o.push({Name:w+f.key,Tsize:Number(a),Hash:e.cidVersion===0?Ut:Ft})}else{let S=f.value;if(S.cid==null)continue;let a=w+f.key,h=S.size;o.push({Name:a,Tsize:Number(h),Hash:S.cid})}}let s=Uint8Array.from(n.bitField().reverse()),c=new L({type:"hamt-sharded-directory",data:s,fanout:BigInt(r.tableSize()),hashType:fi,mtime:t?.mtime,mode:t?.mode});return P(z({Data:c.marshal(),Links:o})).length}async function Sr(r,t,e,n){let i=t;t instanceof rt&&t.estimateNodeSize()>e&&(i=await Va(t,n));let o=i.parent;if(o!=null){if(i!==t){if(r!=null&&(r.parent=i),i.parentKey==null)throw new Error("No parent key found");await o.put(i.parentKey,i)}return Sr(i,o,e,n)}return i}async function Va(r,t){let e=new ui({root:r.root,dir:!0,parent:r.parent,parentKey:r.parentKey,path:r.path,dirty:r.dirty,flat:!1,mtime:r.mtime,mode:r.mode},t);for await(let{key:n,child:i}of r.eachChildSeries())await e.put(n,i);return e}var pi=(r="")=>r.split(/(?<!\\)\//).filter(Boolean);async function Ra(r,t,e){let n=pi(r.path??""),i=n.length-1,o=t,s="";for(let c=0;c<n.length;c++){let u=n[c];s+=`${s!==""?"/":""}${u}`;let x=c===i;if(o.dirty=!0,o.cid=void 0,o.size=void 0,x)await o.put(u,r),t=await Sr(null,o,e.shardSplitThresholdBytes,e);else{let f=await o.get(u);(f==null||!(f instanceof H))&&(f=new rt({root:!1,dir:!0,parent:o,parentKey:u,path:s,dirty:!0,flat:!0,mtime:f?.unixfs?.mtime,mode:f?.unixfs?.mode},e)),await o.put(u,f),o=f}}return t}async function*mi(r,t){if(!(r instanceof H)){r.unixfs?.isDirectory()===!0&&(yield r);return}yield*r.flush(t)}function bi(r){return async function*(e,n){let i=new rt({root:!0,dir:!0,path:"",dirty:!0,flat:!0},r),o,s=!1;for await(let c of e){if(c==null)continue;let u=`${c.originalPath??""}`.split("/")[0];u!=null&&u!==""&&(o==null?(o=u,s=!0):o!==u&&(s=!1)),i=await Ra(c,i,r),(c.unixfs==null||!c.unixfs.isDirectory())&&(yield c)}if(r.wrapWithDirectory||s&&i.childCount()>1)yield*mi(i,n);else for await(let c of i.eachChildSeries())c!=null&&(yield*mi(c.child,n))}}async function*_r(r,t,e={}){let n;Symbol.asyncIterator in r||Symbol.iterator in r?n=r:n=[r];let i=e.wrapWithDirectory??!1,o=e.shardSplitThresholdBytes??262144,s=e.shardFanoutBits??8,c=e.cidVersion??1,u=e.rawLeaves??!0,x=e.leafType??"file",f=e.fileImportConcurrency??50,w=e.blockWriteConcurrency??10,S=e.reduceSingleLeafToSelf??!0,a=e.chunker??zr(),h=e.chunkValidator??En(),d=e.dagBuilder??Tn({chunker:a,chunkValidator:h,wrapWithDirectory:i,layout:e.layout??tr(),bufferImporter:e.bufferImporter??Bn({cidVersion:c,rawLeaves:u,leafType:x,onProgress:e.onProgress}),blockWriteConcurrency:w,reduceSingleLeafToSelf:S,cidVersion:c,onProgress:e.onProgress}),_=e.treeBuilder??bi({wrapWithDirectory:i,shardSplitThresholdBytes:o,shardFanoutBits:s,cidVersion:c,onProgress:e.onProgress});for await(let l of _(At(d(n,t),f),t))yield{cid:l.cid,path:l.path,unixfs:l.unixfs,size:l.size}}async function Tr(r,t,e={}){let n=await he(_r([r],t,e));if(n==null)throw(0,Dr.default)(new Error("Nothing imported"),"ERR_INVALID_PARAMS");return n}async function Oa(r,t,e={}){let n=await he(_r([r],t,e));if(n==null)throw(0,Dr.default)(new Error("Nothing imported"),"ERR_INVALID_PARAMS");return n}async function Ha(r,t,e={}){return Tr({content:r},t,e)}async function $a(r,t,e={}){return Tr({content:r},t,e)}return Ai(Ga);})();
|
|
3
3
|
return IpfsUnixfsImporter}));
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Chunker functions split an incoming stream of bytes into chunks.
|
|
5
|
+
*
|
|
6
|
+
* The default is a fixed-size chunker which splits them into equally sized
|
|
7
|
+
* chunks though other strategies are available such as Rabin chunking.
|
|
8
|
+
*/
|
|
1
9
|
export interface Chunker {
|
|
2
10
|
(source: AsyncIterable<Uint8Array>): AsyncIterable<Uint8Array>;
|
|
3
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chunker/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IAAG,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;CAAE;AAE3F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/chunker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,OAAO;IAAG,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,aAAa,CAAC,UAAU,CAAC,CAAA;CAAE;AAE3F,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Chunker functions split an incoming stream of bytes into chunks.
|
|
5
|
+
*
|
|
6
|
+
* The default is a fixed-size chunker which splits them into equally sized
|
|
7
|
+
* chunks though other strategies are available such as Rabin chunking.
|
|
8
|
+
*/
|
|
1
9
|
export { rabin } from './rabin.js';
|
|
2
10
|
export { fixedSize } from './fixed-size.js';
|
|
3
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chunker/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/chunker/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* Let's create a little directory to import:
|
|
7
|
+
*
|
|
8
|
+
* ```console
|
|
9
|
+
* > cd /tmp
|
|
10
|
+
* > mkdir foo
|
|
11
|
+
* > echo 'hello' > foo/bar
|
|
12
|
+
* > echo 'world' > foo/quux
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* And write the importing logic:
|
|
16
|
+
*
|
|
17
|
+
* ```js
|
|
18
|
+
* import { importer } from 'ipfs-unixfs-importer'
|
|
19
|
+
* import { MemoryBlockstore } from 'blockstore-core/memory'
|
|
20
|
+
* import * as fs from 'node:fs'
|
|
21
|
+
*
|
|
22
|
+
* // Where the blocks will be stored
|
|
23
|
+
* const blockstore = new MemoryBlockstore()
|
|
24
|
+
*
|
|
25
|
+
* // Import path /tmp/foo/
|
|
26
|
+
* const source = [{
|
|
27
|
+
* path: '/tmp/foo/bar',
|
|
28
|
+
* content: fs.createReadStream('/tmp/foo/bar')
|
|
29
|
+
* }, {
|
|
30
|
+
* path: '/tmp/foo/quxx',
|
|
31
|
+
* content: fs.createReadStream('/tmp/foo/quux')
|
|
32
|
+
* }]
|
|
33
|
+
*
|
|
34
|
+
* for await (const entry of importer(source, blockstore)) {
|
|
35
|
+
* console.info(entry)
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* When run, metadata about DAGNodes in the created tree is printed until the root:
|
|
40
|
+
*
|
|
41
|
+
* ```js
|
|
42
|
+
* {
|
|
43
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
44
|
+
* path: 'tmp/foo/bar',
|
|
45
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
46
|
+
* }
|
|
47
|
+
* {
|
|
48
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
49
|
+
* path: 'tmp/foo/quxx',
|
|
50
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
51
|
+
* }
|
|
52
|
+
* {
|
|
53
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
54
|
+
* path: 'tmp/foo',
|
|
55
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
56
|
+
* }
|
|
57
|
+
* {
|
|
58
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
59
|
+
* path: 'tmp',
|
|
60
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
1
64
|
import { type BufferImportProgressEvents } from './dag-builder/buffer-importer.js';
|
|
2
65
|
import { type DAGBuilder, type DagBuilderProgressEvents } from './dag-builder/index.js';
|
|
3
66
|
import { type ChunkValidator } from './dag-builder/validate-chunks.js';
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,3 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* Let's create a little directory to import:
|
|
7
|
+
*
|
|
8
|
+
* ```console
|
|
9
|
+
* > cd /tmp
|
|
10
|
+
* > mkdir foo
|
|
11
|
+
* > echo 'hello' > foo/bar
|
|
12
|
+
* > echo 'world' > foo/quux
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* And write the importing logic:
|
|
16
|
+
*
|
|
17
|
+
* ```js
|
|
18
|
+
* import { importer } from 'ipfs-unixfs-importer'
|
|
19
|
+
* import { MemoryBlockstore } from 'blockstore-core/memory'
|
|
20
|
+
* import * as fs from 'node:fs'
|
|
21
|
+
*
|
|
22
|
+
* // Where the blocks will be stored
|
|
23
|
+
* const blockstore = new MemoryBlockstore()
|
|
24
|
+
*
|
|
25
|
+
* // Import path /tmp/foo/
|
|
26
|
+
* const source = [{
|
|
27
|
+
* path: '/tmp/foo/bar',
|
|
28
|
+
* content: fs.createReadStream('/tmp/foo/bar')
|
|
29
|
+
* }, {
|
|
30
|
+
* path: '/tmp/foo/quxx',
|
|
31
|
+
* content: fs.createReadStream('/tmp/foo/quux')
|
|
32
|
+
* }]
|
|
33
|
+
*
|
|
34
|
+
* for await (const entry of importer(source, blockstore)) {
|
|
35
|
+
* console.info(entry)
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* When run, metadata about DAGNodes in the created tree is printed until the root:
|
|
40
|
+
*
|
|
41
|
+
* ```js
|
|
42
|
+
* {
|
|
43
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
44
|
+
* path: 'tmp/foo/bar',
|
|
45
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
46
|
+
* }
|
|
47
|
+
* {
|
|
48
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
49
|
+
* path: 'tmp/foo/quxx',
|
|
50
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
51
|
+
* }
|
|
52
|
+
* {
|
|
53
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
54
|
+
* path: 'tmp/foo',
|
|
55
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
56
|
+
* }
|
|
57
|
+
* {
|
|
58
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
59
|
+
* path: 'tmp',
|
|
60
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
1
64
|
import errcode from 'err-code';
|
|
2
65
|
import first from 'it-first';
|
|
3
66
|
import parallelBatch from 'it-parallel-batch';
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Layout functions allow customising the shape of final DAGs
|
|
5
|
+
*
|
|
6
|
+
* {@link https://dag.ipfs.tech} can be used to explore different conigurations.
|
|
7
|
+
*/
|
|
1
8
|
import type { InProgressImportResult } from '../index.js';
|
|
2
9
|
export interface Reducer {
|
|
3
10
|
(leaves: InProgressImportResult[]): Promise<InProgressImportResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,MAAM,WAAW,OAAO;IAAG,CAAC,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;CAAE;AAChG,MAAM,WAAW,UAAU;IAAG,CAAC,MAAM,EAAE,aAAa,CAAC,sBAAsB,CAAC,GAAG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;CAAE;AAErK,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/layout/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAEzD,MAAM,WAAW,OAAO;IAAG,CAAC,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;CAAE;AAChG,MAAM,WAAW,UAAU;IAAG,CAAC,MAAM,EAAE,aAAa,CAAC,sBAAsB,CAAC,GAAG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAA;CAAE;AAErK,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/src/layout/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Layout functions allow customising the shape of final DAGs
|
|
5
|
+
*
|
|
6
|
+
* {@link https://dag.ipfs.tech} can be used to explore different conigurations.
|
|
7
|
+
*/
|
|
1
8
|
export { balanced } from './balanced.js';
|
|
2
9
|
export { flat } from './flat.js';
|
|
3
10
|
export { trickle } from './trickle.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layout/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/layout/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Chunker": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.chunker.Chunker.html",
|
|
3
|
+
"./chunker:Chunker": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.chunker.Chunker.html",
|
|
4
|
+
"fixedSize": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.chunker.fixedSize.html",
|
|
5
|
+
"rabin": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.chunker.rabin.html",
|
|
6
|
+
"BufferImporter": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.BufferImporter.html",
|
|
7
|
+
".:BufferImporter": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.BufferImporter.html",
|
|
8
|
+
"BufferImporterResult": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.BufferImporterResult.html",
|
|
9
|
+
".:BufferImporterResult": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.BufferImporterResult.html",
|
|
10
|
+
"Directory": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.Directory.html",
|
|
11
|
+
".:Directory": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.Directory.html",
|
|
12
|
+
"DirectoryCandidate": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.DirectoryCandidate.html",
|
|
13
|
+
".:DirectoryCandidate": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.DirectoryCandidate.html",
|
|
14
|
+
"File": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.File.html",
|
|
15
|
+
".:File": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.File.html",
|
|
16
|
+
"FileCandidate": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.FileCandidate.html",
|
|
17
|
+
".:FileCandidate": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.FileCandidate.html",
|
|
18
|
+
"HamtHashFn": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.HamtHashFn.html",
|
|
19
|
+
".:HamtHashFn": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.HamtHashFn.html",
|
|
20
|
+
"ImportResult": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.ImportResult.html",
|
|
21
|
+
".:ImportResult": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.ImportResult.html",
|
|
22
|
+
"ImporterOptions": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.ImporterOptions.html",
|
|
23
|
+
".:ImporterOptions": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.ImporterOptions.html",
|
|
24
|
+
"MultipleBlockImportResult": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.MultipleBlockImportResult.html",
|
|
25
|
+
".:MultipleBlockImportResult": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.MultipleBlockImportResult.html",
|
|
26
|
+
"SingleBlockImportResult": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.SingleBlockImportResult.html",
|
|
27
|
+
".:SingleBlockImportResult": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.SingleBlockImportResult.html",
|
|
28
|
+
"TreeBuilder": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.TreeBuilder.html",
|
|
29
|
+
".:TreeBuilder": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.index.TreeBuilder.html",
|
|
30
|
+
"ByteStream": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ByteStream.html",
|
|
31
|
+
".:ByteStream": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ByteStream.html",
|
|
32
|
+
"ImportCandidate": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ImportCandidate.html",
|
|
33
|
+
".:ImportCandidate": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ImportCandidate.html",
|
|
34
|
+
"ImportCandidateStream": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ImportCandidateStream.html",
|
|
35
|
+
".:ImportCandidateStream": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ImportCandidateStream.html",
|
|
36
|
+
"ImportContent": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ImportContent.html",
|
|
37
|
+
".:ImportContent": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ImportContent.html",
|
|
38
|
+
"ImporterProgressEvents": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ImporterProgressEvents.html",
|
|
39
|
+
".:ImporterProgressEvents": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.ImporterProgressEvents.html",
|
|
40
|
+
"InProgressImportResult": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.InProgressImportResult.html",
|
|
41
|
+
".:InProgressImportResult": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.InProgressImportResult.html",
|
|
42
|
+
"WritableStorage": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.WritableStorage.html",
|
|
43
|
+
".:WritableStorage": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_importer.index.WritableStorage.html",
|
|
44
|
+
"importByteStream": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importByteStream.html",
|
|
45
|
+
".:importByteStream": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importByteStream.html",
|
|
46
|
+
"importBytes": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importBytes.html",
|
|
47
|
+
".:importBytes": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importBytes.html",
|
|
48
|
+
"importDirectory": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importDirectory.html",
|
|
49
|
+
".:importDirectory": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importDirectory.html",
|
|
50
|
+
"importFile": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importFile.html",
|
|
51
|
+
".:importFile": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importFile.html",
|
|
52
|
+
"importer": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importer.html",
|
|
53
|
+
".:importer": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.index.importer.html",
|
|
54
|
+
"FileLayout": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.layout.FileLayout.html",
|
|
55
|
+
"./layout:FileLayout": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.layout.FileLayout.html",
|
|
56
|
+
"Reducer": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.layout.Reducer.html",
|
|
57
|
+
"./layout:Reducer": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_importer.layout.Reducer.html",
|
|
58
|
+
"balanced": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.layout.balanced.html",
|
|
59
|
+
"flat": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.layout.flat.html",
|
|
60
|
+
"trickle": "https://ipfs.github.io/js-ipfs-unixfs/functions/ipfs_unixfs_importer.layout.trickle.html"
|
|
61
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ipfs-unixfs-importer",
|
|
3
|
-
"version": "15.2.
|
|
3
|
+
"version": "15.2.4",
|
|
4
4
|
"description": "JavaScript implementation of the UnixFs importer used by IPFS",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/ipfs/js-ipfs-unixfs/tree/master/packages/ipfs-unixfs-importer#readme",
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ipfs/js-ipfs-unixfs/issues"
|
|
13
13
|
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
14
18
|
"keywords": [
|
|
15
19
|
"IPFS"
|
|
16
20
|
],
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=16.0.0",
|
|
19
|
-
"npm": ">=7.0.0"
|
|
20
|
-
},
|
|
21
21
|
"type": "module",
|
|
22
22
|
"types": "./dist/src/index.d.ts",
|
|
23
23
|
"typesVersions": {
|
|
@@ -59,94 +59,10 @@
|
|
|
59
59
|
"eslintConfig": {
|
|
60
60
|
"extends": "ipfs",
|
|
61
61
|
"parserOptions": {
|
|
62
|
+
"project": true,
|
|
62
63
|
"sourceType": "module"
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
|
-
"release": {
|
|
66
|
-
"branches": [
|
|
67
|
-
"master"
|
|
68
|
-
],
|
|
69
|
-
"plugins": [
|
|
70
|
-
[
|
|
71
|
-
"@semantic-release/commit-analyzer",
|
|
72
|
-
{
|
|
73
|
-
"preset": "conventionalcommits",
|
|
74
|
-
"releaseRules": [
|
|
75
|
-
{
|
|
76
|
-
"breaking": true,
|
|
77
|
-
"release": "major"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"revert": true,
|
|
81
|
-
"release": "patch"
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"type": "feat",
|
|
85
|
-
"release": "minor"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
"type": "fix",
|
|
89
|
-
"release": "patch"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"type": "docs",
|
|
93
|
-
"release": "patch"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
"type": "test",
|
|
97
|
-
"release": "patch"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"type": "deps",
|
|
101
|
-
"release": "patch"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
"scope": "no-release",
|
|
105
|
-
"release": false
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
[
|
|
111
|
-
"@semantic-release/release-notes-generator",
|
|
112
|
-
{
|
|
113
|
-
"preset": "conventionalcommits",
|
|
114
|
-
"presetConfig": {
|
|
115
|
-
"types": [
|
|
116
|
-
{
|
|
117
|
-
"type": "feat",
|
|
118
|
-
"section": "Features"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"type": "fix",
|
|
122
|
-
"section": "Bug Fixes"
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
"type": "chore",
|
|
126
|
-
"section": "Trivial Changes"
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
"type": "docs",
|
|
130
|
-
"section": "Documentation"
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
"type": "deps",
|
|
134
|
-
"section": "Dependencies"
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"type": "test",
|
|
138
|
-
"section": "Tests"
|
|
139
|
-
}
|
|
140
|
-
]
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
],
|
|
144
|
-
"@semantic-release/changelog",
|
|
145
|
-
"@semantic-release/npm",
|
|
146
|
-
"@semantic-release/github",
|
|
147
|
-
"@semantic-release/git"
|
|
148
|
-
]
|
|
149
|
-
},
|
|
150
66
|
"scripts": {
|
|
151
67
|
"test": "aegir test",
|
|
152
68
|
"test:node": "aegir test -t node --cov",
|
|
@@ -155,8 +71,7 @@
|
|
|
155
71
|
"build": "aegir build",
|
|
156
72
|
"clean": "aegir clean",
|
|
157
73
|
"lint": "aegir lint",
|
|
158
|
-
"dep-check": "aegir dep-check"
|
|
159
|
-
"release": "aegir release"
|
|
74
|
+
"dep-check": "aegir dep-check"
|
|
160
75
|
},
|
|
161
76
|
"dependencies": {
|
|
162
77
|
"@ipld/dag-pb": "^4.0.0",
|
|
@@ -177,15 +92,12 @@
|
|
|
177
92
|
"uint8arrays": "^5.0.0"
|
|
178
93
|
},
|
|
179
94
|
"devDependencies": {
|
|
180
|
-
"aegir": "^
|
|
95
|
+
"aegir": "^42.2.2",
|
|
181
96
|
"blockstore-core": "^4.0.1",
|
|
182
97
|
"it-last": "^3.0.2",
|
|
183
98
|
"wherearewe": "^2.0.1"
|
|
184
99
|
},
|
|
185
100
|
"browser": {
|
|
186
101
|
"fs": false
|
|
187
|
-
},
|
|
188
|
-
"typedoc": {
|
|
189
|
-
"entryPoint": "./src/index.ts"
|
|
190
102
|
}
|
|
191
103
|
}
|
package/src/chunker/index.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Chunker functions split an incoming stream of bytes into chunks.
|
|
5
|
+
*
|
|
6
|
+
* The default is a fixed-size chunker which splits them into equally sized
|
|
7
|
+
* chunks though other strategies are available such as Rabin chunking.
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
export interface Chunker { (source: AsyncIterable<Uint8Array>): AsyncIterable<Uint8Array> }
|
|
2
11
|
|
|
3
12
|
export { rabin } from './rabin.js'
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* Let's create a little directory to import:
|
|
7
|
+
*
|
|
8
|
+
* ```console
|
|
9
|
+
* > cd /tmp
|
|
10
|
+
* > mkdir foo
|
|
11
|
+
* > echo 'hello' > foo/bar
|
|
12
|
+
* > echo 'world' > foo/quux
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* And write the importing logic:
|
|
16
|
+
*
|
|
17
|
+
* ```js
|
|
18
|
+
* import { importer } from 'ipfs-unixfs-importer'
|
|
19
|
+
* import { MemoryBlockstore } from 'blockstore-core/memory'
|
|
20
|
+
* import * as fs from 'node:fs'
|
|
21
|
+
*
|
|
22
|
+
* // Where the blocks will be stored
|
|
23
|
+
* const blockstore = new MemoryBlockstore()
|
|
24
|
+
*
|
|
25
|
+
* // Import path /tmp/foo/
|
|
26
|
+
* const source = [{
|
|
27
|
+
* path: '/tmp/foo/bar',
|
|
28
|
+
* content: fs.createReadStream('/tmp/foo/bar')
|
|
29
|
+
* }, {
|
|
30
|
+
* path: '/tmp/foo/quxx',
|
|
31
|
+
* content: fs.createReadStream('/tmp/foo/quux')
|
|
32
|
+
* }]
|
|
33
|
+
*
|
|
34
|
+
* for await (const entry of importer(source, blockstore)) {
|
|
35
|
+
* console.info(entry)
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* When run, metadata about DAGNodes in the created tree is printed until the root:
|
|
40
|
+
*
|
|
41
|
+
* ```js
|
|
42
|
+
* {
|
|
43
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
44
|
+
* path: 'tmp/foo/bar',
|
|
45
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
46
|
+
* }
|
|
47
|
+
* {
|
|
48
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
49
|
+
* path: 'tmp/foo/quxx',
|
|
50
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
51
|
+
* }
|
|
52
|
+
* {
|
|
53
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
54
|
+
* path: 'tmp/foo',
|
|
55
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
56
|
+
* }
|
|
57
|
+
* {
|
|
58
|
+
* cid: CID, // see https://github.com/multiformats/js-cid
|
|
59
|
+
* path: 'tmp',
|
|
60
|
+
* unixfs: UnixFS // see https://github.com/ipfs/js-ipfs-unixfs
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
|
|
1
65
|
import errcode from 'err-code'
|
|
2
66
|
import first from 'it-first'
|
|
3
67
|
import parallelBatch from 'it-parallel-batch'
|
package/src/layout/index.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
*
|
|
4
|
+
* Layout functions allow customising the shape of final DAGs
|
|
5
|
+
*
|
|
6
|
+
* {@link https://dag.ipfs.tech} can be used to explore different conigurations.
|
|
7
|
+
*/
|
|
8
|
+
|
|
1
9
|
import type { InProgressImportResult } from '../index.js'
|
|
2
10
|
|
|
3
11
|
export interface Reducer { (leaves: InProgressImportResult[]): Promise<InProgressImportResult> }
|