@helia/dnslink 0.0.0
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 +171 -0
- package/dist/index.min.js +18 -0
- package/dist/index.min.js.map +7 -0
- package/dist/src/constants.d.ts +2 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +2 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/dnslink.d.ts +11 -0
- package/dist/src/dnslink.d.ts.map +1 -0
- package/dist/src/dnslink.js +120 -0
- package/dist/src/dnslink.js.map +1 -0
- package/dist/src/errors.d.ts +9 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/errors.js +15 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +219 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +111 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/namespaces/ipfs.d.ts +3 -0
- package/dist/src/namespaces/ipfs.d.ts.map +1 -0
- package/dist/src/namespaces/ipfs.js +18 -0
- package/dist/src/namespaces/ipfs.js.map +1 -0
- package/dist/src/namespaces/ipns.d.ts +3 -0
- package/dist/src/namespaces/ipns.d.ts.map +1 -0
- package/dist/src/namespaces/ipns.js +18 -0
- package/dist/src/namespaces/ipns.js.map +1 -0
- package/dist/typedoc-urls.json +22 -0
- package/package.json +98 -0
- package/src/constants.ts +1 -0
- package/src/dnslink.ts +146 -0
- package/src/errors.ts +17 -0
- package/src/index.ts +241 -0
- package/src/namespaces/ipfs.ts +22 -0
- package/src/namespaces/ipns.ts +22 -0
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://github.com/ipfs/helia" title="Helia">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/ipfs/helia/main/assets/helia.png" alt="Helia logo" width="300" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
# @helia/dnslink
|
|
8
|
+
|
|
9
|
+
[](https://ipfs.tech)
|
|
10
|
+
[](https://discuss.ipfs.tech)
|
|
11
|
+
[](https://codecov.io/gh/ipfs/helia)
|
|
12
|
+
[](https://github.com/ipfs/helia/actions/workflows/main.yml?query=branch%3Amain)
|
|
13
|
+
|
|
14
|
+
> DNSLink operations using Helia
|
|
15
|
+
|
|
16
|
+
# About
|
|
17
|
+
|
|
18
|
+
<!--
|
|
19
|
+
|
|
20
|
+
!IMPORTANT!
|
|
21
|
+
|
|
22
|
+
Everything in this README between "# About" and "# Install" is automatically
|
|
23
|
+
generated and will be overwritten the next time the doc generator is run.
|
|
24
|
+
|
|
25
|
+
To make changes to this section, please update the @packageDocumentation section
|
|
26
|
+
of src/index.js or src/index.ts
|
|
27
|
+
|
|
28
|
+
To experiment with formatting, please run "npm run docs" from the root of this
|
|
29
|
+
repo and examine the changes made.
|
|
30
|
+
|
|
31
|
+
-->
|
|
32
|
+
|
|
33
|
+
[DNSLink](https://dnslink.dev/) operations using a Helia node.
|
|
34
|
+
|
|
35
|
+
## Example - Using custom DNS over HTTPS resolvers
|
|
36
|
+
|
|
37
|
+
To use custom resolvers, configure Helia's `dns` option:
|
|
38
|
+
|
|
39
|
+
```TypeScript
|
|
40
|
+
import { createHelia } from 'helia'
|
|
41
|
+
import { dnsLink } from '@helia/dnslink'
|
|
42
|
+
import { dns } from '@multiformats/dns'
|
|
43
|
+
import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
44
|
+
import type { DefaultLibp2pServices } from 'helia'
|
|
45
|
+
import type { Libp2p } from '@libp2p/interface'
|
|
46
|
+
|
|
47
|
+
const node = await createHelia<Libp2p<DefaultLibp2pServices>>({
|
|
48
|
+
dns: dns({
|
|
49
|
+
resolvers: {
|
|
50
|
+
'.': dnsOverHttps('https://private-dns-server.me/dns-query')
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
const name = dnsLink(node)
|
|
55
|
+
|
|
56
|
+
const result = name.resolve('some-domain-with-dnslink-entry.com')
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Example - Resolving a domain with a dnslink entry
|
|
60
|
+
|
|
61
|
+
Calling `resolve` with the `@helia/dnslink` instance:
|
|
62
|
+
|
|
63
|
+
```TypeScript
|
|
64
|
+
// resolve a CID from a TXT record in a DNS zone file, using the default
|
|
65
|
+
// resolver for the current platform eg:
|
|
66
|
+
// > dig _dnslink.ipfs.tech TXT
|
|
67
|
+
// ;; ANSWER SECTION:
|
|
68
|
+
// _dnslink.ipfs.tech. 60 IN CNAME _dnslink.ipfs-tech.on.fleek.co.
|
|
69
|
+
// _dnslink.ipfs-tech.on.fleek.co. 120 IN TXT "dnslink=/ipfs/bafybe..."
|
|
70
|
+
|
|
71
|
+
import { createHelia } from 'helia'
|
|
72
|
+
import { dnsLink } from '@helia/dnslink'
|
|
73
|
+
|
|
74
|
+
const node = await createHelia()
|
|
75
|
+
const name = dnsLink(node)
|
|
76
|
+
|
|
77
|
+
const { answer } = await name.resolve('blog.ipfs.tech')
|
|
78
|
+
|
|
79
|
+
console.info(answer)
|
|
80
|
+
// { data: '/ipfs/bafybe...' }
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Example - Using DNS-Over-HTTPS
|
|
84
|
+
|
|
85
|
+
This example uses the Mozilla provided RFC 1035 DNS over HTTPS service. This
|
|
86
|
+
uses binary DNS records so requires extra dependencies to process the
|
|
87
|
+
response which can increase browser bundle sizes.
|
|
88
|
+
|
|
89
|
+
If this is a concern, use the DNS-JSON-Over-HTTPS resolver instead.
|
|
90
|
+
|
|
91
|
+
```TypeScript
|
|
92
|
+
import { createHelia } from 'helia'
|
|
93
|
+
import { dnsLink } from '@helia/dnslink'
|
|
94
|
+
import { dns } from '@multiformats/dns'
|
|
95
|
+
import { dnsOverHttps } from '@multiformats/dns/resolvers'
|
|
96
|
+
import type { DefaultLibp2pServices } from 'helia'
|
|
97
|
+
import type { Libp2p } from '@libp2p/interface'
|
|
98
|
+
|
|
99
|
+
const node = await createHelia<Libp2p<DefaultLibp2pServices>>({
|
|
100
|
+
dns: dns({
|
|
101
|
+
resolvers: {
|
|
102
|
+
'.': dnsOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
})
|
|
106
|
+
const name = dnsLink(node)
|
|
107
|
+
|
|
108
|
+
const result = await name.resolve('blog.ipfs.tech')
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Example - Using DNS-JSON-Over-HTTPS
|
|
112
|
+
|
|
113
|
+
DNS-JSON-Over-HTTPS resolvers use the RFC 8427 `application/dns-json` and can
|
|
114
|
+
result in a smaller browser bundle due to the response being plain JSON.
|
|
115
|
+
|
|
116
|
+
```TypeScript
|
|
117
|
+
import { createHelia } from 'helia'
|
|
118
|
+
import { dnsLink } from '@helia/dnslink'
|
|
119
|
+
import { dns } from '@multiformats/dns'
|
|
120
|
+
import { dnsJsonOverHttps } from '@multiformats/dns/resolvers'
|
|
121
|
+
import type { DefaultLibp2pServices } from 'helia'
|
|
122
|
+
import type { Libp2p } from '@libp2p/interface'
|
|
123
|
+
|
|
124
|
+
const node = await createHelia<Libp2p<DefaultLibp2pServices>>({
|
|
125
|
+
dns: dns({
|
|
126
|
+
resolvers: {
|
|
127
|
+
'.': dnsJsonOverHttps('https://mozilla.cloudflare-dns.com/dns-query')
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
const name = dnsLink(node)
|
|
132
|
+
|
|
133
|
+
const result = await name.resolve('blog.ipfs.tech')
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
# Install
|
|
137
|
+
|
|
138
|
+
```console
|
|
139
|
+
$ npm i @helia/dnslink
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Browser `<script>` tag
|
|
143
|
+
|
|
144
|
+
Loading this module through a script tag will make its exports available as `HeliaIpns` in the global namespace.
|
|
145
|
+
|
|
146
|
+
```html
|
|
147
|
+
<script src="https://unpkg.com/@helia/ipns/dist/index.min.js"></script>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
# API Docs
|
|
151
|
+
|
|
152
|
+
- <https://ipfs.github.io/helia/modules/_helia_ipns.html>
|
|
153
|
+
|
|
154
|
+
# License
|
|
155
|
+
|
|
156
|
+
Licensed under either of
|
|
157
|
+
|
|
158
|
+
- Apache 2.0, ([LICENSE-APACHE](https://github.com/ipfs/helia/blob/main/packages/ipns/LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>)
|
|
159
|
+
- MIT ([LICENSE-MIT](https://github.com/ipfs/helia/blob/main/packages/ipns/LICENSE-MIT) / <http://opensource.org/licenses/MIT>)
|
|
160
|
+
|
|
161
|
+
# Contribute
|
|
162
|
+
|
|
163
|
+
Contributions welcome! Please check out [the issues](https://github.com/ipfs/helia/issues).
|
|
164
|
+
|
|
165
|
+
Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general.
|
|
166
|
+
|
|
167
|
+
Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).
|
|
168
|
+
|
|
169
|
+
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
|
|
170
|
+
|
|
171
|
+
[](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDnslink = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
+
"use strict";var HeliaDnslink=(()=>{var zs=Object.create;var Me=Object.defineProperty;var Gs=Object.getOwnPropertyDescriptor;var Ys=Object.getOwnPropertyNames;var Xs=Object.getPrototypeOf,Ws=Object.prototype.hasOwnProperty;var Qs=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),it=(e,t)=>{for(var r in t)Me(e,r,{get:t[r],enumerable:!0})},Fn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ys(t))!Ws.call(e,o)&&o!==r&&Me(e,o,{get:()=>t[o],enumerable:!(n=Gs(t,o))||n.enumerable});return e};var Js=(e,t,r)=>(r=e!=null?zs(Xs(e)):{},Fn(t||!e||!e.__esModule?Me(r,"default",{value:e,enumerable:!0}):r,e)),ti=e=>Fn(Me({},"__esModule",{value:!0}),e);var ho=Qs((Pf,lo)=>{lo.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function o(s,i){r[s]=i,t++,t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(s){return r[s]!==void 0||n[s]!==void 0},remove:function(s){r[s]!==void 0&&(r[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var i=r[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set:function(s,i){r[s]!==void 0?r[s]=i:o(s,i)},clear:function(){r=Object.create(null),n=Object.create(null)}}}});var Da={};it(Da,{dnsLink:()=>La});var Br={};it(Br,{base10:()=>ci});var Ua=new Uint8Array(0);function Zn(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function wt(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function $n(e){return new TextEncoder().encode(e)}function jn(e){return new TextDecoder().decode(e)}function ei(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(r[i]!==255)throw new TypeError(s+" is ambiguous");r[i]=o}var a=e.length,c=e.charAt(0),f=Math.log(a)/Math.log(256),p=Math.log(256)/Math.log(a);function u(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var B=0,A=0,y=0,v=m.length;y!==v&&m[y]===0;)y++,B++;for(var b=(v-y)*p+1>>>0,I=new Uint8Array(b);y!==v;){for(var U=m[y],k=0,P=b-1;(U!==0||k<A)&&P!==-1;P--,k++)U+=256*I[P]>>>0,I[P]=U%a>>>0,U=U/a>>>0;if(U!==0)throw new Error("Non-zero carry");A=k,y++}for(var x=b-A;x!==b&&I[x]===0;)x++;for(var g=c.repeat(B);x<b;++x)g+=e.charAt(I[x]);return g}function w(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var B=0;if(m[B]!==" "){for(var A=0,y=0;m[B]===c;)A++,B++;for(var v=(m.length-B)*f+1>>>0,b=new Uint8Array(v);m[B];){var I=r[m.charCodeAt(B)];if(I===255)return;for(var U=0,k=v-1;(I!==0||U<y)&&k!==-1;k--,U++)I+=a*b[k]>>>0,b[k]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");y=U,B++}if(m[B]!==" "){for(var P=v-y;P!==v&&b[P]===0;)P++;for(var x=new Uint8Array(A+(v-P)),g=A;P!==v;)x[g++]=b[P++];return x}}}function S(m){var B=w(m);if(B)return B;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:w,decode:S}}var ri=ei,ni=ri,Gn=ni;var Er=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Sr=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Yn(this,t)}},Ar=class{decoders;constructor(t){this.decoders=t}or(t){return Yn(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Yn(e,t){return new Ar({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var vr=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Er(t,r,n),this.decoder=new Sr(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Gt({name:e,prefix:t,encode:r,decode:n}){return new vr(e,t,r,n)}function _t({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Gn(r,e);return Gt({prefix:t,name:e,encode:n,decode:s=>wt(o(s))})}function oi(e,t,r,n){let o=e.length;for(;e[o-1]==="=";)--o;let s=new Uint8Array(o*r/8|0),i=0,a=0,c=0;for(let f=0;f<o;++f){let p=t[e[f]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|p,i+=r,i>=8&&(i-=8,s[c++]=255&a>>i)}if(i>=r||(255&a<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function si(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,s="",i=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],i+=8;i>r;)i-=r,s+=t[o&a>>i];if(i!==0&&(s+=t[o&a<<r-i]),n)for(;(s.length*r&7)!==0;)s+="=";return s}function ii(e){let t={};for(let r=0;r<e.length;++r)t[e[r]]=r;return t}function j({name:e,prefix:t,bitsPerChar:r,alphabet:n}){let o=ii(n);return Gt({prefix:t,name:e,encode(s){return si(s,n,r)},decode(s){return oi(s,o,r,e)}})}var ci=_t({prefix:"9",name:"base10",alphabet:"0123456789"});var Ir={};it(Ir,{base16:()=>ai,base16upper:()=>fi});var ai=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fi=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Lr={};it(Lr,{base2:()=>ui});var ui=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Dr={};it(Dr,{base256emoji:()=>mi});var Xn=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}"),li=Xn.reduce((e,t,r)=>(e[r]=t,e),[]),hi=Xn.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function di(e){return e.reduce((t,r)=>(t+=li[r],t),"")}function pi(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=hi[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var mi=Gt({prefix:"\u{1F680}",name:"base256emoji",encode:di,decode:pi});var _r={};it(_r,{base32:()=>Yt,base32hex:()=>xi,base32hexpad:()=>Ei,base32hexpadupper:()=>Si,base32hexupper:()=>wi,base32pad:()=>bi,base32padupper:()=>gi,base32upper:()=>yi,base32z:()=>Ai});var Yt=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yi=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bi=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gi=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xi=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wi=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ei=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Si=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ai=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Tr={};it(Tr,{base36:()=>pe,base36upper:()=>vi});var pe=_t({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vi=_t({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Rr={};it(Rr,{base58btc:()=>G,base58flickr:()=>Bi});var G=_t({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bi=_t({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Cr={};it(Cr,{base64:()=>Ii,base64pad:()=>Li,base64url:()=>Di,base64urlpad:()=>_i});var Ii=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Li=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Di=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_i=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ur={};it(Ur,{base8:()=>Ti});var Ti=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Nr={};it(Nr,{identity:()=>Ri});var Ri=Gt({prefix:"\0",name:"identity",encode:e=>jn(e),decode:e=>$n(e)});var Ya=new TextEncoder,Xa=new TextDecoder;var Or={};it(Or,{identity:()=>lt});var Ni=Jn,Wn=128,Ki=127,Oi=~Ki,ki=Math.pow(2,31);function Jn(e,t,r){t=t||[],r=r||0;for(var n=r;e>=ki;)t[r++]=e&255|Wn,e/=128;for(;e&Oi;)t[r++]=e&255|Wn,e>>>=7;return t[r]=e|0,Jn.bytes=r-n+1,t}var Pi=Kr,Mi=128,Qn=127;function Kr(e,n){var r=0,n=n||0,o=0,s=n,i,a=e.length;do{if(s>=a)throw Kr.bytes=0,new RangeError("Could not decode varint");i=e[s++],r+=o<28?(i&Qn)<<o:(i&Qn)*Math.pow(2,o),o+=7}while(i>=Mi);return Kr.bytes=s-n,r}var Hi=Math.pow(2,7),qi=Math.pow(2,14),Vi=Math.pow(2,21),Fi=Math.pow(2,28),Zi=Math.pow(2,35),$i=Math.pow(2,42),ji=Math.pow(2,49),zi=Math.pow(2,56),Gi=Math.pow(2,63),Yi=function(e){return e<Hi?1:e<qi?2:e<Vi?3:e<Fi?4:e<Zi?5:e<$i?6:e<ji?7:e<zi?8:e<Gi?9:10},Xi={encode:Ni,decode:Pi,encodingLength:Yi},Wi=Xi,me=Wi;function ye(e,t=0){return[me.decode(e,t),me.decode.bytes]}function Xt(e,t,r=0){return me.encode(e,t,r),t}function Wt(e){return me.encodingLength(e)}function Jt(e,t){let r=t.byteLength,n=Wt(e),o=n+Wt(r),s=new Uint8Array(o+r);return Xt(e,s,0),Xt(r,s,n),s.set(t,o),new Qt(e,r,t,s)}function be(e){let t=wt(e),[r,n]=ye(t),[o,s]=ye(t.subarray(n)),i=t.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new Qt(r,o,i,t)}function to(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Zn(e.bytes,r.bytes)}}var Qt=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};var eo=0,Qi="identity",ro=wt;function Ji(e,t){if(t?.truncate!=null&&t.truncate!==e.byteLength){if(t.truncate<0||t.truncate>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,t.truncate)}return Jt(eo,ro(e))}var lt={code:eo,name:Qi,encode:ro,digest:Ji};var Mr={};it(Mr,{sha256:()=>ge,sha512:()=>ec});var tc=20;function Pr({name:e,code:t,encode:r,minDigestLength:n,maxDigestLength:o}){return new kr(e,t,r,n,o)}var kr=class{name;code;encode;minDigestLength;maxDigestLength;constructor(t,r,n,o,s){this.name=t,this.code=r,this.encode=n,this.minDigestLength=o??tc,this.maxDigestLength=s}digest(t,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(t instanceof Uint8Array){let n=this.encode(t);return n instanceof Uint8Array?no(n,this.code,r?.truncate):n.then(o=>no(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function no(e,t,r){if(r!=null&&r!==e.byteLength){if(r>e.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${e.byteLength}`);e=e.subarray(0,r)}return Jt(t,e)}function so(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var ge=Pr({name:"sha2-256",code:18,encode:so("SHA-256")}),ec=Pr({name:"sha2-512",code:19,encode:so("SHA-512")});function io(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return nc(r,Hr(e),t??G.encoder);default:return oc(r,Hr(e),t??Yt.encoder)}}var co=new WeakMap;function Hr(e){let t=co.get(e);if(t==null){let r=new Map;return co.set(e,r),r}return t}var Q=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==xe)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==sc)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Jt(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&to(t.multihash,n.multihash)}toString(t){return io(this,t)}toJSON(){return{"/":io(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:i}=r;return new e(n,o,s,i??ao(n,o,s.bytes))}else if(r[ic]===!0){let{version:n,multihash:o,code:s}=r,i=be(o);return e.create(n,s,i)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==xe)throw new Error(`Version 0 CID must use dag-pb (code: ${xe}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=ao(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,xe,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=wt(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),i=new Qt(r.multihashCode,r.digestSize,s,o);return[r.version===0?e.createV0(i):e.createV1(r.codec,i),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[u,w]=ye(t.subarray(r));return r+=w,u},o=n(),s=xe;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=r,a=n(),c=n(),f=r+c,p=f-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:p,size:f}}static parse(t,r){let[n,o]=rc(t,r),s=e.decode(o);if(s.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Hr(s).set(n,t),s}};function rc(e,t){switch(e[0]){case"Q":{let r=t??G;return[G.prefix,r.decode(`${G.prefix}${e}`)]}case G.prefix:{let r=t??G;return[G.prefix,r.decode(e)]}case Yt.prefix:{let r=t??Yt;return[Yt.prefix,r.decode(e)]}case pe.prefix:{let r=t??pe;return[pe.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function nc(e,t,r){let{prefix:n}=r;if(n!==G.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let s=r.encode(e).slice(1);return t.set(n,s),s}else return o}function oc(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let s=r.encode(e);return t.set(n,s),s}else return o}var xe=112,sc=18;function ao(e,t,r){let n=Wt(e),o=n+Wt(t),s=new Uint8Array(o+r.byteLength);return Xt(e,s,0),Xt(t,s,n),s.set(r,o),s}var ic=Symbol.for("@ipld/js-cid/CID");var qr={...Nr,...Lr,...Ur,...Br,...Ir,..._r,...Tr,...Rr,...Cr,...Dr},xf={...Mr,...Or};function Et(e=0){return new Uint8Array(e)}function ct(e=0){return new Uint8Array(e)}function uo(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var fo=uo("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Vr=uo("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=ct(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),cc={utf8:fo,"utf-8":fo,hex:qr.base16,latin1:Vr,ascii:Vr,binary:Vr,...qr},qe=cc;function ot(e,t="utf8"){let r=qe[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var lc=Js(ho(),1);var xt;(function(e){e[e.A=1]="A",e[e.CNAME=5]="CNAME",e[e.TXT=16]="TXT",e[e.AAAA=28]="AAAA"})(xt||(xt={}));var po=32;var Ve=class extends Error{static name="DNSLinkNotFoundError";constructor(t="DNSLink not found"){super(t),this.name="DNSLinkNotFoundError"}},ee=class extends Error{static name="InvalidNamespaceError";constructor(t="Invalid namespace"){super(t),this.name="InvalidNamespaceError"}};var mo={parse:(e,t)=>{let[,r,n,...o]=e.split("/");if(r!=="ipfs")throw new ee(`Namespace ${r} was not "ipfs"`);return{namespace:"ipfs",cid:Q.parse(n),path:o.length>0?`/${o.join("/")}`:"",answer:t}}};var yt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},Fe=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Ze=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},$e=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var we=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Fr=Symbol.for("@libp2p/peer-id");function ht(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function je(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));let r=ct(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var bo=Symbol.for("@achingbrain/uint8arraylist");function yo(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function ze(e){return!!e?.[bo]}var at=class e{bufs;length;[bo]=!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 r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(ze(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(ze(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=yo(this.bufs,t);return r.buf[r.index]}set(t,r){let n=yo(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(ze(t))for(let n=0;n<t.length;n++)this.set(r+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,r){let{bufs:n,length:o}=this._subList(t,r);return je(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:je(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),s=new e;return s.length=o,s.bufs=[...n],s}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let s=0;s<this.bufs.length;s++){let i=this.bufs[s],a=o,c=a+i.byteLength;if(o=c,t>=c)continue;let f=t>=a&&t<c,p=r>a&&r<=c;if(f&&p){if(t===a&&r===c){n.push(i);break}let u=t-a;n.push(i.subarray(u,u+(r-t)));break}if(f){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(p){if(r===c){n.push(i);break}n.push(i.subarray(0,r-a));break}n.push(i)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!ze(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(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let s=256,i=new Int32Array(s);for(let u=0;u<s;u++)i[u]=-1;for(let u=0;u<o;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,f=n.byteLength-1,p;for(let u=r;u<=c;u+=p){p=0;for(let w=f;w>=0;w--){let S=this.get(u+w);if(n[w]!==S){p=Math.max(1,w-a[S]);break}}if(p===0)return u}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=ct(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=Et(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=Et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=Et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=ct(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=Et(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=Et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=Et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=Et(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=Et(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!ht(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,s)=>o+s.byteLength,0)),n.length=r,n}};function Tt(e,t="utf8"){let r=qe[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}var hc=parseInt("11111",2),Zr=parseInt("10000000",2),dc=parseInt("01111111",2),go={0:Ee,1:Ee,2:pc,3:bc,4:gc,5:yc,6:mc,16:Ee,22:Ee,48:Ee};function $r(e,t={offset:0}){let r=e[t.offset]&hc;if(t.offset++,go[r]!=null)return go[r](e,t);throw new Error("No decoder for tag "+r)}function Se(e,t){let r=0;if((e[t.offset]&Zr)===Zr){let n=e[t.offset]&dc,o="0x";t.offset++;for(let s=0;s<n;s++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function Ee(e,t){Se(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=$r(e,t);if(n===null)break;r.push(n)}return r}function pc(e,t){let r=Se(e,t),n=t.offset,o=t.offset+r,s=[];for(let i=n;i<o;i++)i===n&&e[i]===0||s.push(e[i]);return t.offset+=r,Uint8Array.from(s)}function mc(e,t){let r=Se(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let s=0,i=0;o<40?(s=0,i=o):o<80?(s=1,i=o-40):(s=2,i=o-80);let a=`${s}.${i}`,c=[];for(;t.offset<n;){let f=e[t.offset];if(t.offset++,c.push(f&127),f<128){c.reverse();let p=0;for(let u=0;u<c.length;u++)p+=c[u]<<u*7;a+=`.${p}`,c=[]}}return a}function yc(e,t){return t.offset++,null}function bc(e,t){let r=Se(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function gc(e,t){let r=Se(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function xc(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new at;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function jr(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=xc(e.byteLength);return new at(Uint8Array.from([t.byteLength|Zr]),t)}function xo(e){let t=new at,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new at(Uint8Array.from([2]),jr(t),t)}function wo(e){let t=Uint8Array.from([0]),r=new at(t,e);return new at(Uint8Array.from([3]),jr(r),r)}function Ge(e,t=48){let r=new at;for(let n of e)r.append(n);return new at(Uint8Array.from([t]),jr(r),r)}async function Eo(e,t,r,n){let o=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let s=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,t,r.subarray());return n?.signal?.throwIfAborted(),s}var wc=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Ec=Uint8Array.from([6,5,43,129,4,0,34]),Sc=Uint8Array.from([6,5,43,129,4,0,35]),Ac={ext:!0,kty:"EC",crv:"P-256"},vc={ext:!0,kty:"EC",crv:"P-384"},Bc={ext:!0,kty:"EC",crv:"P-521"},zr=32,Gr=48,Yr=66;function So(e){let t=$r(e);return Ao(t)}function Ao(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===zr*2+1)return n=ot(t.subarray(r,r+zr),"base64url"),o=ot(t.subarray(r+zr),"base64url"),new re({...Ac,key_ops:["verify"],x:n,y:o});if(t.byteLength===Gr*2+1)return n=ot(t.subarray(r,r+Gr),"base64url"),o=ot(t.subarray(r+Gr),"base64url"),new re({...vc,key_ops:["verify"],x:n,y:o});if(t.byteLength===Yr*2+1)return n=ot(t.subarray(r,r+Yr),"base64url"),o=ot(t.subarray(r+Yr),"base64url"),new re({...Bc,key_ops:["verify"],x:n,y:o});throw new yt(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function vo(e){return Ge([xo(Uint8Array.from([1])),Ge([Ic(e.crv)],160),Ge([wo(new at(Uint8Array.from([4]),Tt(e.x??"","base64url"),Tt(e.y??"","base64url")))],161)]).subarray()}function Ic(e){if(e==="P-256")return wc;if(e==="P-384")return Ec;if(e==="P-521")return Sc;throw new yt(`Invalid curve ${e}`)}var re=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=vo(this.jwk)),this._raw}toMultihash(){return lt.digest(ne(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}async verify(t,r,n){return Eo(this.jwk,r,t,n)}};function Mt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function bt(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function O(e,t,r=""){let n=Mt(e),o=e?.length,s=t!==void 0;if(!n||s&&o!==t){let i=r&&`"${r}" `,a=s?` of length ${t}`:"",c=n?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+a+", got "+c)}return e}function Ye(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");bt(e.outputLen),bt(e.blockLen)}function oe(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Io(e,t){O(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function At(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Xe(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function dt(e,t){return e<<32-t|e>>>t}var Lo=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Lc=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function vt(e){if(O(e),Lo)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Lc[e[r]];return t}var St={_0:48,_9:57,A:65,F:70,a:97,f:102};function Bo(e){if(e>=St._0&&e<=St._9)return e-St._0;if(e>=St.A&&e<=St.F)return e-(St.A-10);if(e>=St.a&&e<=St.f)return e-(St.a-10)}function Bt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Lo)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,s=0;o<r;o++,s+=2){let i=Bo(e.charCodeAt(s)),a=Bo(e.charCodeAt(s+1));if(i===void 0||a===void 0){let c=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function st(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];O(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let s=e[n];r.set(s,o),o+=s.length}return r}function Xr(e,t={}){let r=(o,s)=>e(s).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function se(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var Wr=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Do(e,t,r){return e&t^~e&r}function _o(e,t,r){return e&t^e&r^t&r}var Ae=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=Xe(this.buffer)}update(t){oe(this),O(t);let{view:r,buffer:n,blockLen:o}=this,s=t.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=Xe(t);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){oe(this),Io(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;r[i++]=128,At(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let u=i;u<o;u++)r[u]=0;n.setBigUint64(o-8,BigInt(this.length*8),s),this.process(n,0);let a=Xe(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let f=c/4,p=this.get();if(f>p.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<f;u++)a.setUint32(4*u,p[u],s)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:s,destroyed:i,pos:a}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},It=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var J=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var We=BigInt(4294967295),To=BigInt(32);function Dc(e,t=!1){return t?{h:Number(e&We),l:Number(e>>To&We)}:{h:Number(e>>To&We)|0,l:Number(e&We)|0}}function Ro(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let s=0;s<r;s++){let{h:i,l:a}=Dc(e[s],t);[n[s],o[s]]=[i,a]}return[n,o]}var Qr=(e,t,r)=>e>>>r,Jr=(e,t,r)=>e<<32-r|t>>>r,Ht=(e,t,r)=>e>>>r|t<<32-r,qt=(e,t,r)=>e<<32-r|t>>>r,ve=(e,t,r)=>e<<64-r|t>>>r-32,Be=(e,t,r)=>e>>>r-32|t<<64-r;function gt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Co=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Uo=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,No=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),Ko=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Oo=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),ko=(e,t,r,n,o,s)=>t+r+n+o+s+(e/2**32|0)|0;var Tc=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Rt=new Uint32Array(64),tn=class extends Ae{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:s,F:i,G:a,H:c}=this;return[t,r,n,o,s,i,a,c]}set(t,r,n,o,s,i,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,r){for(let u=0;u<16;u++,r+=4)Rt[u]=t.getUint32(r,!1);for(let u=16;u<64;u++){let w=Rt[u-15],S=Rt[u-2],m=dt(w,7)^dt(w,18)^w>>>3,B=dt(S,17)^dt(S,19)^S>>>10;Rt[u]=B+Rt[u-7]+m+Rt[u-16]|0}let{A:n,B:o,C:s,D:i,E:a,F:c,G:f,H:p}=this;for(let u=0;u<64;u++){let w=dt(a,6)^dt(a,11)^dt(a,25),S=p+w+Do(a,c,f)+Tc[u]+Rt[u]|0,B=(dt(n,2)^dt(n,13)^dt(n,22))+_o(n,o,s)|0;p=f,f=c,c=a,a=i+S|0,i=s,s=o,o=n,n=S+B|0}n=n+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,p=p+this.H|0,this.set(n,o,s,i,a,c,f,p)}roundClean(){At(Rt)}destroy(){this.set(0,0,0,0,0,0,0,0),At(this.buffer)}},en=class extends tn{A=It[0]|0;B=It[1]|0;C=It[2]|0;D=It[3]|0;E=It[4]|0;F=It[5]|0;G=It[6]|0;H=It[7]|0;constructor(){super(32)}};var Po=Ro(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Rc=Po[0],Cc=Po[1],Ct=new Uint32Array(80),Ut=new Uint32Array(80),rn=class extends Ae{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:f,El:p,Fh:u,Fl:w,Gh:S,Gl:m,Hh:B,Hl:A}=this;return[t,r,n,o,s,i,a,c,f,p,u,w,S,m,B,A]}set(t,r,n,o,s,i,a,c,f,p,u,w,S,m,B,A){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=p|0,this.Fh=u|0,this.Fl=w|0,this.Gh=S|0,this.Gl=m|0,this.Hh=B|0,this.Hl=A|0}process(t,r){for(let b=0;b<16;b++,r+=4)Ct[b]=t.getUint32(r),Ut[b]=t.getUint32(r+=4);for(let b=16;b<80;b++){let I=Ct[b-15]|0,U=Ut[b-15]|0,k=Ht(I,U,1)^Ht(I,U,8)^Qr(I,U,7),P=qt(I,U,1)^qt(I,U,8)^Jr(I,U,7),x=Ct[b-2]|0,g=Ut[b-2]|0,N=Ht(x,g,19)^ve(x,g,61)^Qr(x,g,6),M=qt(x,g,19)^Be(x,g,61)^Jr(x,g,6),T=No(P,M,Ut[b-7],Ut[b-16]),h=Ko(T,k,N,Ct[b-7],Ct[b-16]);Ct[b]=h|0,Ut[b]=T|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:f,Dl:p,Eh:u,El:w,Fh:S,Fl:m,Gh:B,Gl:A,Hh:y,Hl:v}=this;for(let b=0;b<80;b++){let I=Ht(u,w,14)^Ht(u,w,18)^ve(u,w,41),U=qt(u,w,14)^qt(u,w,18)^Be(u,w,41),k=u&S^~u&B,P=w&m^~w&A,x=Oo(v,U,P,Cc[b],Ut[b]),g=ko(x,y,I,k,Rc[b],Ct[b]),N=x|0,M=Ht(n,o,28)^ve(n,o,34)^ve(n,o,39),T=qt(n,o,28)^Be(n,o,34)^Be(n,o,39),h=n&s^n&a^s&a,d=o&i^o&c^i&c;y=B|0,v=A|0,B=S|0,A=m|0,S=u|0,m=w|0,{h:u,l:w}=gt(f|0,p|0,g|0,N|0),f=a|0,p=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let l=Co(N,T,d);n=Uo(l,g,M,h),o=l|0}({h:n,l:o}=gt(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=gt(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=gt(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:p}=gt(this.Dh|0,this.Dl|0,f|0,p|0),{h:u,l:w}=gt(this.Eh|0,this.El|0,u|0,w|0),{h:S,l:m}=gt(this.Fh|0,this.Fl|0,S|0,m|0),{h:B,l:A}=gt(this.Gh|0,this.Gl|0,B|0,A|0),{h:y,l:v}=gt(this.Hh|0,this.Hl|0,y|0,v|0),this.set(n,o,s,i,a,c,f,p,u,w,S,m,B,A,y,v)}roundClean(){At(Ct,Ut)}destroy(){At(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},nn=class extends rn{Ah=J[0]|0;Al=J[1]|0;Bh=J[2]|0;Bl=J[3]|0;Ch=J[4]|0;Cl=J[5]|0;Dh=J[6]|0;Dl=J[7]|0;Eh=J[8]|0;El=J[9]|0;Fh=J[10]|0;Fl=J[11]|0;Gh=J[12]|0;Gl=J[13]|0;Hh=J[14]|0;Hl=J[15]|0;constructor(){super(64)}};var Mo=Xr(()=>new en,Wr(1));var Ho=Xr(()=>new nn,Wr(3));var sn=BigInt(0),on=BigInt(1);function Lt(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function qo(e){if(typeof e=="bigint"){if(!Qe(e))throw new Error("positive bigint expected, got "+e)}else bt(e);return e}function Ie(e){let t=qo(e).toString(16);return t.length&1?"0"+t:t}function Vo(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?sn:BigInt("0x"+e)}function ie(e){return Vo(vt(e))}function Vt(e){return Vo(vt(tr(O(e)).reverse()))}function Je(e,t){bt(t),e=qo(e);let r=Bt(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function cn(e,t){return Je(e,t).reverse()}function tr(e){return Uint8Array.from(e)}var Qe=e=>typeof e=="bigint"&&sn<=e;function Uc(e,t,r){return Qe(e)&&Qe(t)&&Qe(r)&&t<=e&&e<r}function Le(e,t,r,n){if(!Uc(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function an(e){let t;for(t=0;e>sn;e>>=on,t+=1);return t}var De=e=>(on<<BigInt(e))-on;function Fo(e,t,r){if(bt(e,"hashLen"),bt(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=A=>new Uint8Array(A),o=Uint8Array.of(),s=Uint8Array.of(0),i=Uint8Array.of(1),a=1e3,c=n(e),f=n(e),p=0,u=()=>{c.fill(1),f.fill(0),p=0},w=(...A)=>r(f,st(c,...A)),S=(A=o)=>{f=w(s,A),c=w(),A.length!==0&&(f=w(i,A),c=w())},m=()=>{if(p++>=a)throw new Error("drbg: tried max amount of iterations");let A=0,y=[];for(;A<t;){c=w();let v=c.slice();y.push(v),A+=c.length}return st(...y)};return(A,y)=>{u(),S(A);let v;for(;!(v=y(m()));)S();return u(),v}}function Nt(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(s,i,a){let c=e[s];if(a&&c===void 0)return;let f=typeof c;if(f!==i||c===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${f}`)}let o=(s,i)=>Object.entries(s).forEach(([a,c])=>n(a,c,i));o(t,!1),o(r,!0)}function ce(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let s=e(r,...n);return t.set(r,s),s}}var rt=BigInt(0),Y=BigInt(1),Ft=BigInt(2),jo=BigInt(3),zo=BigInt(4),Go=BigInt(5),Nc=BigInt(7),Yo=BigInt(8),Kc=BigInt(9),Xo=BigInt(16);function z(e,t){let r=e%t;return r>=rt?r:t+r}function V(e,t,r){let n=e;for(;t-- >rt;)n*=n,n%=r;return n}function Zo(e,t){if(e===rt)throw new Error("invert: expected non-zero number");if(t<=rt)throw new Error("invert: expected positive modulus, got "+t);let r=z(e,t),n=t,o=rt,s=Y,i=Y,a=rt;for(;r!==rt;){let f=n/r,p=n%r,u=o-i*f,w=s-a*f;n=r,r=p,o=i,s=a,i=u,a=w}if(n!==Y)throw new Error("invert: does not exist");return z(o,t)}function un(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function Wo(e,t){let r=(e.ORDER+Y)/zo,n=e.pow(t,r);return un(e,n,t),n}function Oc(e,t){let r=(e.ORDER-Go)/Yo,n=e.mul(t,Ft),o=e.pow(n,r),s=e.mul(t,o),i=e.mul(e.mul(s,Ft),o),a=e.mul(s,e.sub(i,e.ONE));return un(e,a,t),a}function kc(e){let t=ae(e),r=Qo(e),n=r(t,t.neg(t.ONE)),o=r(t,n),s=r(t,t.neg(n)),i=(e+Nc)/Xo;return(a,c)=>{let f=a.pow(c,i),p=a.mul(f,n),u=a.mul(f,o),w=a.mul(f,s),S=a.eql(a.sqr(p),c),m=a.eql(a.sqr(u),c);f=a.cmov(f,p,S),p=a.cmov(w,u,m);let B=a.eql(a.sqr(p),c),A=a.cmov(f,p,B);return un(a,A,c),A}}function Qo(e){if(e<jo)throw new Error("sqrt is not defined for small field");let t=e-Y,r=0;for(;t%Ft===rt;)t/=Ft,r++;let n=Ft,o=ae(e);for(;$o(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Wo;let s=o.pow(n,t),i=(t+Y)/Ft;return function(c,f){if(c.is0(f))return f;if($o(c,f)!==1)throw new Error("Cannot find square root");let p=r,u=c.mul(c.ONE,s),w=c.pow(f,t),S=c.pow(f,i);for(;!c.eql(w,c.ONE);){if(c.is0(w))return c.ZERO;let m=1,B=c.sqr(w);for(;!c.eql(B,c.ONE);)if(m++,B=c.sqr(B),m===p)throw new Error("Cannot find square root");let A=Y<<BigInt(p-m-1),y=c.pow(u,A);p=m,u=c.sqr(y),w=c.mul(w,u),S=c.mul(S,y)}return S}}function Pc(e){return e%zo===jo?Wo:e%Yo===Go?Oc:e%Xo===Kc?kc(e):Qo(e)}var Jo=(e,t)=>(z(e,t)&Y)===Y,Mc=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ln(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Mc.reduce((n,o)=>(n[o]="function",n),t);return Nt(e,r),e}function Hc(e,t,r){if(r<rt)throw new Error("invalid exponent, negatives unsupported");if(r===rt)return e.ONE;if(r===Y)return t;let n=e.ONE,o=t;for(;r>rt;)r&Y&&(n=e.mul(n,o)),o=e.sqr(o),r>>=Y;return n}function _e(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((i,a,c)=>e.is0(a)?i:(n[c]=i,e.mul(i,a)),e.ONE),s=e.inv(o);return t.reduceRight((i,a,c)=>e.is0(a)?i:(n[c]=e.mul(i,n[c]),e.mul(i,a)),s),n}function $o(e,t){let r=(e.ORDER-Y)/Ft,n=e.pow(t,r),o=e.eql(n,e.ONE),s=e.eql(n,e.ZERO),i=e.eql(n,e.neg(e.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function qc(e,t){t!==void 0&&bt(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var fn=class{ORDER;BITS;BYTES;isLE;ZERO=rt;ONE=Y;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=rt)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:s}=qc(t,n);if(s>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=s,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return z(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return rt<=t&&t<this.ORDER}is0(t){return t===rt}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&Y)===Y}neg(t){return z(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return z(t*t,this.ORDER)}add(t,r){return z(t+r,this.ORDER)}sub(t,r){return z(t-r,this.ORDER)}mul(t,r){return z(t*r,this.ORDER)}pow(t,r){return Hc(this,t,r)}div(t,r){return z(t*Zo(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return Zo(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=Pc(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?cn(t,this.BYTES):Je(t,this.BYTES)}fromBytes(t,r=!1){O(t);let{_lengths:n,BYTES:o,isLE:s,ORDER:i,_mod:a}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let f=new Uint8Array(o);f.set(t,s?0:f.length-t.length),t=f}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let c=s?Vt(t):ie(t);if(a&&(c=z(c,i)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(t){return _e(this,t)}cmov(t,r,n){return n?r:t}};function ae(e,t={}){return new fn(e,t)}function ts(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function hn(e){let t=ts(e);return t+Math.ceil(t/2)}function dn(e,t,r=!1){O(e);let n=e.length,o=ts(t),s=hn(t);if(n<16||n<s||n>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+n);let i=r?Vt(e):ie(e),a=z(i,t-Y)+Y;return r?cn(a,o):Je(a,o)}var fe=BigInt(0),Zt=BigInt(1);function Te(e,t){let r=t.negate();return e?r:t}function $t(e,t){let r=_e(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function os(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function pn(e,t){os(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,s=De(e),i=BigInt(e);return{windows:r,windowSize:n,mask:s,maxNumber:o,shiftBy:i}}function es(e,t,r){let{windowSize:n,mask:o,maxNumber:s,shiftBy:i}=r,a=Number(e&o),c=e>>i;a>n&&(a-=s,c+=Zt);let f=t*n,p=f+Math.abs(a)-1,u=a===0,w=a<0,S=t%2!==0;return{nextN:c,offset:p,isZero:u,isNeg:w,isNegF:S,offsetF:f}}var mn=new WeakMap,ss=new WeakMap;function yn(e){return ss.get(e)||1}function rs(e){if(e!==fe)throw new Error("invalid wNAF")}var ue=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>fe;)r&Zt&&(n=n.add(o)),o=o.double(),r>>=Zt;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=pn(r,this.bits),s=[],i=t,a=i;for(let c=0;c<n;c++){a=i,s.push(a);for(let f=1;f<o;f++)a=a.add(i),s.push(a);i=a.double()}return s}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE,i=pn(t,this.bits);for(let a=0;a<i.windows;a++){let{nextN:c,offset:f,isZero:p,isNeg:u,isNegF:w,offsetF:S}=es(n,a,i);n=c,p?s=s.add(Te(w,r[S])):o=o.add(Te(u,r[f]))}return rs(n),{p:o,f:s}}wNAFUnsafe(t,r,n,o=this.ZERO){let s=pn(t,this.bits);for(let i=0;i<s.windows&&n!==fe;i++){let{nextN:a,offset:c,isZero:f,isNeg:p}=es(n,i,s);if(n=a,!f){let u=r[c];o=o.add(p?u.negate():u)}}return rs(n),o}getPrecomputes(t,r,n){let o=mn.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),mn.set(r,o))),o}cached(t,r,n){let o=yn(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let s=yn(t);return s===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,n),r,o)}createCache(t,r){os(r,this.bits),ss.set(t,r),mn.delete(t)}hasCache(t){return yn(t)!==1}};function is(e,t,r,n){let o=t,s=e.ZERO,i=e.ZERO;for(;r>fe||n>fe;)r&Zt&&(s=s.add(o)),n&Zt&&(i=i.add(o)),o=o.double(),r>>=Zt,n>>=Zt;return{p1:s,p2:i}}function ns(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ln(t),t}else return ae(e,{isLE:r})}function er(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let c of["p","n","h"]){let f=t[c];if(!(typeof f=="bigint"&&f>fe))throw new Error(`CURVE.${c} must be positive bigint`)}let o=ns(t.p,r.Fp,n),s=ns(t.n,r.Fn,n),a=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(t[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}function rr(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Kt=BigInt(0),X=BigInt(1),bn=BigInt(2),Vc=BigInt(8);function Fc(e,t,r,n){let o=e.sqr(r),s=e.sqr(n),i=e.add(e.mul(t.a,o),s),a=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,a)}function cs(e,t={}){let r=er("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,s=r.CURVE,{h:i}=s;Nt(t,{},{uvRatio:"function"});let a=bn<<BigInt(o.BYTES*8)-X,c=A=>n.create(A),f=t.uvRatio||((A,y)=>{try{return{isValid:!0,value:n.sqrt(n.div(A,y))}}catch{return{isValid:!1,value:Kt}}});if(!Fc(n,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function p(A,y,v=!1){let b=v?X:Kt;return Le("coordinate "+A,y,b,a),y}function u(A){if(!(A instanceof m))throw new Error("EdwardsPoint expected")}let w=ce((A,y)=>{let{X:v,Y:b,Z:I}=A,U=A.is0();y==null&&(y=U?Vc:n.inv(I));let k=c(v*y),P=c(b*y),x=n.mul(I,y);if(U)return{x:Kt,y:X};if(x!==X)throw new Error("invZ was invalid");return{x:k,y:P}}),S=ce(A=>{let{a:y,d:v}=s;if(A.is0())throw new Error("bad point: ZERO");let{X:b,Y:I,Z:U,T:k}=A,P=c(b*b),x=c(I*I),g=c(U*U),N=c(g*g),M=c(P*y),T=c(g*c(M+x)),h=c(N+c(v*c(P*x)));if(T!==h)throw new Error("bad point: equation left != right (1)");let d=c(b*I),l=c(U*k);if(d!==l)throw new Error("bad point: equation left != right (2)");return!0});class m{static BASE=new m(s.Gx,s.Gy,X,c(s.Gx*s.Gy));static ZERO=new m(Kt,X,X,Kt);static Fp=n;static Fn=o;X;Y;Z;T;constructor(y,v,b,I){this.X=p("x",y),this.Y=p("y",v),this.Z=p("z",b,!0),this.T=p("t",I),Object.freeze(this)}static CURVE(){return s}static fromAffine(y){if(y instanceof m)throw new Error("extended point not allowed");let{x:v,y:b}=y||{};return p("x",v),p("y",b),new m(v,b,X,c(v*b))}static fromBytes(y,v=!1){let b=n.BYTES,{a:I,d:U}=s;y=tr(O(y,b,"point")),Lt(v,"zip215");let k=tr(y),P=y[b-1];k[b-1]=P&-129;let x=Vt(k),g=v?a:n.ORDER;Le("point.y",x,Kt,g);let N=c(x*x),M=c(N-X),T=c(U*N-I),{isValid:h,value:d}=f(M,T);if(!h)throw new Error("bad point: invalid y coordinate");let l=(d&X)===X,E=(P&128)!==0;if(!v&&d===Kt&&E)throw new Error("bad point: x=0 and x_0=1");return E!==l&&(d=c(-d)),m.fromAffine({x:d,y:x})}static fromHex(y,v=!1){return m.fromBytes(Bt(y),v)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(y=8,v=!0){return B.createCache(this,y),v||this.multiply(bn),this}assertValidity(){S(this)}equals(y){u(y);let{X:v,Y:b,Z:I}=this,{X:U,Y:k,Z:P}=y,x=c(v*P),g=c(U*I),N=c(b*P),M=c(k*I);return x===g&&N===M}is0(){return this.equals(m.ZERO)}negate(){return new m(c(-this.X),this.Y,this.Z,c(-this.T))}double(){let{a:y}=s,{X:v,Y:b,Z:I}=this,U=c(v*v),k=c(b*b),P=c(bn*c(I*I)),x=c(y*U),g=v+b,N=c(c(g*g)-U-k),M=x+k,T=M-P,h=x-k,d=c(N*T),l=c(M*h),E=c(N*h),L=c(T*M);return new m(d,l,L,E)}add(y){u(y);let{a:v,d:b}=s,{X:I,Y:U,Z:k,T:P}=this,{X:x,Y:g,Z:N,T:M}=y,T=c(I*x),h=c(U*g),d=c(P*b*M),l=c(k*N),E=c((I+U)*(x+g)-T-h),L=l-d,_=l+d,R=c(h-v*T),D=c(E*L),C=c(_*R),K=c(E*R),F=c(L*_);return new m(D,C,F,K)}subtract(y){return this.add(y.negate())}multiply(y){if(!o.isValidNot0(y))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:v,f:b}=B.cached(this,y,I=>$t(m,I));return $t(m,[v,b])[0]}multiplyUnsafe(y,v=m.ZERO){if(!o.isValid(y))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return y===Kt?m.ZERO:this.is0()||y===X?this:B.unsafe(this,y,b=>$t(m,b),v)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return B.unsafe(this,s.n).is0()}toAffine(y){return w(this,y)}clearCofactor(){return i===X?this:this.multiplyUnsafe(i)}toBytes(){let{x:y,y:v}=this.toAffine(),b=n.toBytes(v);return b[b.length-1]|=y&X?128:0,b}toHex(){return vt(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let B=new ue(m,o.BITS);return m.BASE.precompute(8),m}function as(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');Nt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:s,Fn:i}=e,a=r.randomBytes||se,c=r.adjustScalarBytes||(x=>x),f=r.domain||((x,g,N)=>{if(Lt(N,"phflag"),g.length||N)throw new Error("Contexts/pre-hash are not supported");return x});function p(x){return i.create(Vt(x))}function u(x){let g=b.secretKey;O(x,b.secretKey,"secretKey");let N=O(t(x),2*g,"hashedSecretKey"),M=c(N.slice(0,g)),T=N.slice(g,2*g),h=p(M);return{head:M,prefix:T,scalar:h}}function w(x){let{head:g,prefix:N,scalar:M}=u(x),T=o.multiply(M),h=T.toBytes();return{head:g,prefix:N,scalar:M,point:T,pointBytes:h}}function S(x){return w(x).pointBytes}function m(x=Uint8Array.of(),...g){let N=st(...g);return p(t(f(N,O(x,void 0,"context"),!!n)))}function B(x,g,N={}){x=O(x,void 0,"message"),n&&(x=n(x));let{prefix:M,scalar:T,pointBytes:h}=w(g),d=m(N.context,M,x),l=o.multiply(d).toBytes(),E=m(N.context,l,h,x),L=i.create(d+E*T);if(!i.isValid(L))throw new Error("sign failed: invalid s");let _=st(l,i.toBytes(L));return O(_,b.signature,"result")}let A={zip215:!0};function y(x,g,N,M=A){let{context:T,zip215:h}=M,d=b.signature;x=O(x,d,"signature"),g=O(g,void 0,"message"),N=O(N,b.publicKey,"publicKey"),h!==void 0&&Lt(h,"zip215"),n&&(g=n(g));let l=d/2,E=x.subarray(0,l),L=Vt(x.subarray(l,d)),_,R,D;try{_=e.fromBytes(N,h),R=e.fromBytes(E,h),D=o.multiplyUnsafe(L)}catch{return!1}if(!h&&_.isSmallOrder())return!1;let C=m(T,R.toBytes(),_.toBytes(),g);return R.add(_.multiplyUnsafe(C)).subtract(D).clearCofactor().is0()}let v=s.BYTES,b={secretKey:v,publicKey:v,signature:2*v,seed:v};function I(x=a(b.seed)){return O(x,b.seed,"seed")}function U(x){return Mt(x)&&x.length===i.BYTES}function k(x,g){try{return!!e.fromBytes(x,g)}catch{return!1}}let P={getExtendedPublicKey:w,randomSecretKey:I,isValidSecretKey:U,isValidPublicKey:k,toMontgomery(x){let{y:g}=e.fromBytes(x),N=b.publicKey,M=N===32;if(!M&&N!==57)throw new Error("only defined for 25519 and 448");let T=M?s.div(X+g,X-g):s.div(g-X,g+X);return s.toBytes(T)},toMontgomerySecret(x){let g=b.secretKey;O(x,g);let N=t(x.subarray(0,g));return c(N).subarray(0,g)}};return Object.freeze({keygen:rr(I,S),getPublicKey:S,sign:B,verify:y,utils:P,Point:e,lengths:b})}var Zc=BigInt(1),fs=BigInt(2);var $c=BigInt(5),jc=BigInt(8),gn=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),zc={p:gn,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:jc,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Gc(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),s=gn,a=e*e%s*e%s,c=V(a,fs,s)*a%s,f=V(c,Zc,s)*e%s,p=V(f,$c,s)*f%s,u=V(p,t,s)*p%s,w=V(u,r,s)*u%s,S=V(w,n,s)*w%s,m=V(S,o,s)*S%s,B=V(m,o,s)*S%s,A=V(B,t,s)*p%s;return{pow_p_5_8:V(A,fs,s)*e%s,b2:a}}function Yc(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var us=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Xc(e,t){let r=gn,n=z(t*t*t,r),o=z(n*n*t,r),s=Gc(e*o).pow_p_5_8,i=z(e*n*s,r),a=z(t*i*i,r),c=i,f=z(i*us,r),p=a===e,u=a===z(-e,r),w=a===z(-e*us,r);return p&&(i=c),(u||w)&&(i=f),Jo(i,r)&&(i=z(-i,r)),{isValid:p||u,value:i}}var Wc=cs(zc,{uvRatio:Xc});function Qc(e){return as(Wc,Ho,Object.assign({adjustScalarBytes:Yc},e))}var ls=Qc({});var Re=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},nr=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var hs={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new nr("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var or=hs;var sr=32;var xn,Jc=(async()=>{try{return await or.get().subtle.generateKey({name:"Ed25519"},!0,["sign","verify"]),!0}catch{return!1}})();async function ta(e,t,r){if(e.buffer instanceof ArrayBuffer){let n=await or.get().subtle.importKey("raw",e.buffer,{name:"Ed25519"},!1,["verify"]);return await or.get().subtle.verify({name:"Ed25519"},n,t,r instanceof Uint8Array?r:r.subarray())}throw new TypeError("WebCrypto does not support SharedArrayBuffer for Ed25519 keys")}function ea(e,t,r){return ls.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}async function ds(e,t,r){return xn==null&&(xn=await Jc),xn?ta(e,t,r):ea(e,t,r)}function ir(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}var cr=class{type="Ed25519";raw;constructor(t){this.raw=wn(t,sr)}toMultihash(){return lt.digest(ne(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,r,n){n?.signal?.throwIfAborted();let o=ds(this.raw,r,t);return ir(o)?o.then(s=>(n?.signal?.throwIfAborted(),s)):o}};function ms(e){return e=wn(e,sr),new cr(e)}function wn(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new yt(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var na=Math.pow(2,7),oa=Math.pow(2,14),sa=Math.pow(2,21),ys=Math.pow(2,28),bs=Math.pow(2,35),gs=Math.pow(2,42),xs=Math.pow(2,49),nt=128,Ot=127;function Ce(e){if(e<na)return 1;if(e<oa)return 2;if(e<sa)return 3;if(e<ys)return 4;if(e<bs)return 5;if(e<gs)return 6;if(e<xs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ws(e,t,r=0){switch(Ce(e)){case 8:t[r++]=e&255|nt,e/=128;case 7:t[r++]=e&255|nt,e/=128;case 6:t[r++]=e&255|nt,e/=128;case 5:t[r++]=e&255|nt,e/=128;case 4:t[r++]=e&255|nt,e>>>=7;case 3:t[r++]=e&255|nt,e>>>=7;case 2:t[r++]=e&255|nt,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Es(e,t){let r=e[t],n=0;if(n+=r&Ot,r<nt||(r=e[t+1],n+=(r&Ot)<<7,r<nt)||(r=e[t+2],n+=(r&Ot)<<14,r<nt)||(r=e[t+3],n+=(r&Ot)<<21,r<nt)||(r=e[t+4],n+=(r&Ot)*ys,r<nt)||(r=e[t+5],n+=(r&Ot)*bs,r<nt)||(r=e[t+6],n+=(r&Ot)*gs,r<nt)||(r=e[t+7],n+=(r&Ot)*xs,r<nt))return n;throw new RangeError("Could not decode varint")}var En=new Float32Array([-0]),kt=new Uint8Array(En.buffer);function Ss(e,t,r){En[0]=e,t[r]=kt[0],t[r+1]=kt[1],t[r+2]=kt[2],t[r+3]=kt[3]}function As(e,t){return kt[0]=e[t],kt[1]=e[t+1],kt[2]=e[t+2],kt[3]=e[t+3],En[0]}var Sn=new Float64Array([-0]),et=new Uint8Array(Sn.buffer);function vs(e,t,r){Sn[0]=e,t[r]=et[0],t[r+1]=et[1],t[r+2]=et[2],t[r+3]=et[3],t[r+4]=et[4],t[r+5]=et[5],t[r+6]=et[6],t[r+7]=et[7]}function Bs(e,t){return et[0]=e[t],et[1]=e[t+1],et[2]=e[t+2],et[3]=e[t+3],et[4]=e[t+4],et[5]=e[t+5],et[6]=e[t+6],et[7]=e[t+7],Sn[0]}var ia=BigInt(Number.MAX_SAFE_INTEGER),ca=BigInt(Number.MIN_SAFE_INTEGER),ft=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(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,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return jt;if(t<ia&&t>ca)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>Is&&(o=0n,++n>Is&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return jt;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):jt}},jt=new ft(0,0);jt.toBigInt=function(){return 0n};jt.zzEncode=jt.zzDecode=function(){return this};jt.length=function(){return 1};var Is=4294967296n;function Ls(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ds(e,t,r){if(r-t<1)return"";let o,s=[],i=0,a;for(;t<r;)a=e[t++],a<128?s[i++]=a:a>191&&a<224?s[i++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function An(e,t,r){let n=r,o,s;for(let i=0;i<e.length;++i)o=e.charCodeAt(i),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((s=e.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function pt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function ar(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var vn=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,pt(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 pt(this,4);return ar(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw pt(this,4);return ar(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw pt(this,4);let t=As(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw pt(this,4);let t=Bs(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw pt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Ds(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw pt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw pt(this);while((this.buf[this.pos++]&128)!==0);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 ft(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*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;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw pt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw pt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw pt(this,8);let t=ar(this.buf,this.pos+=4),r=ar(this.buf,this.pos+=4);return new ft(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Es(this.buf,this.pos);return this.pos+=Ce(t),t}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 Bn(e){return new vn(e instanceof Uint8Array?e:e.subarray())}function fr(e,t,r){let n=Bn(e);return t.decode(n,void 0,r)}function In(e){let t=e??8192,r=t>>>1,n,o=t;return function(i){if(i<1||i>r)return ct(i);o+i>t&&(n=ct(t),o=0);let a=n.subarray(o,o+=i);return(o&7)!==0&&(o=(o|7)+1),a}}var zt=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Ln(){}var _n=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},aa=In();function fa(e){return globalThis.Buffer!=null?ct(e):aa(e)}var Ne=class{len;head;tail;states;constructor(){this.len=0,this.head=new zt(Ln,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new zt(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Tn((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(ur,10,ft.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=ft.fromBigInt(t);return this._push(ur,r.length(),r)}uint64Number(t){return this._push(ws,Ce(t),t)}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 r=ft.fromBigInt(t).zzEncode();return this._push(ur,r.length(),r)}sint64Number(t){let r=ft.fromNumber(t).zzEncode();return this._push(ur,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Dn,1,t?1:0)}fixed32(t){return this._push(Ue,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=ft.fromBigInt(t);return this._push(Ue,4,r.lo)._push(Ue,4,r.hi)}fixed64Number(t){let r=ft.fromNumber(t);return this._push(Ue,4,r.lo)._push(Ue,4,r.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(Ss,4,t)}double(t){return this._push(vs,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(Dn,1,0):this.uint32(r)._push(la,r,t)}string(t){let r=Ls(t);return r!==0?this.uint32(r)._push(An,r,t):this._push(Dn,1,0)}fork(){return this.states=new _n(this),this.head=this.tail=new zt(Ln,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 zt(Ln,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=fa(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function Dn(e,t,r){t[r]=e&255}function ua(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Tn=class extends zt{next;constructor(t,r){super(ua,t,r),this.next=void 0}};function ur(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Ue(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function la(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Ne.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(ha,t,e),this},Ne.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(da,t,e),this});function ha(e,t,r){t.set(e,r)}function da(e,t,r){e.length<40?An(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(Tt(e),r)}function Rn(){return new Ne}function lr(e,t){let r=Rn();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var le;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(le||(le={}));function hr(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Cn(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(s,i){let a=t(s);i.int32(a)},n=function(s){let i=s.int32();return t(i)};return hr("enum",le.VARINT,r,n)}function dr(e,t){return hr("message",le.LENGTH_DELIMITED,e,t)}var ut;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(ut||(ut={}));var Un;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Un||(Un={}));(function(e){e.codec=()=>Cn(Un)})(ut||(ut={}));var Ke;(function(e){let t;e.codec=()=>(t==null&&(t=dr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ut.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let a=r.uint32();switch(a>>>3){case 1:{s.Type=ut.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return s})),t),e.encode=r=>lr(r,e.codec()),e.decode=(r,n)=>fr(r,e.codec(),n)})(Ke||(Ke={}));var Nn;(function(e){let t;e.codec=()=>(t==null&&(t=dr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),ut.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let s={},i=n==null?r.len:r.pos+n;for(;r.pos<i;){let a=r.uint32();switch(a>>>3){case 1:{s.Type=ut.codec().decode(r);break}case 2:{s.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return s})),t),e.encode=r=>lr(r,e.codec()),e.decode=(r,n)=>fr(r,e.codec(),n)})(Nn||(Nn={}));var pr=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(Ye(t),O(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=t.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),At(o)}update(t){return oe(this),this.iHash.update(t),this}digestInto(t){oe(this),O(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:s,blockLen:i,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Kn=(e,t,r)=>new pr(e,t).update(r).digest();Kn.create=(e,t)=>new pr(e,t);var Ts=(e,t)=>(e+(e>=0?t:-t)/Rs)/t;function ma(e,t,r){let[[n,o],[s,i]]=t,a=Ts(i*e,r),c=Ts(-o*e,r),f=e-a*n-c*s,p=-a*o-c*i,u=f<Dt,w=p<Dt;u&&(f=-f),w&&(p=-p);let S=De(Math.ceil(an(r)/2))+he;if(f<Dt||f>=S||p<Dt||p>=S)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:u,k1:f,k2neg:w,k2:p}}function kn(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function On(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return Lt(r.lowS,"lowS"),Lt(r.prehash,"prehash"),r.format!==void 0&&kn(r.format),r}var Pn=class extends Error{constructor(t=""){super(t)}},Pt={Err:Pn,_tlv:{encode:(e,t)=>{let{Err:r}=Pt;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Ie(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let s=n>127?Ie(o.length/2|128):"";return Ie(e)+s+o+t},decode(e,t){let{Err:r}=Pt,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],s=!!(o&128),i=0;if(!s)i=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new r("tlv.decode: length bytes not complete");if(f[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let p of f)i=i<<8|p;if(n+=c,i<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+i);if(a.length!==i)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=Pt;if(e<Dt)throw new t("integer: negative integers are not allowed");let r=Ie(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=Pt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ie(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=Pt,o=O(e,void 0,"signature"),{v:s,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,s),{v:f,l:p}=n.decode(2,c);if(p.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(f)}},hexFromSig(e){let{_tlv:t,_int:r}=Pt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),s=n+o;return t.encode(48,s)}},Dt=BigInt(0),he=BigInt(1),Rs=BigInt(2),mr=BigInt(3),ya=BigInt(4);function Cs(e,t={}){let r=er("weierstrass",e,t),{Fp:n,Fn:o}=r,s=r.CURVE,{h:i,n:a}=s;Nt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:c}=t;if(c&&(!n.is0(s.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let f=Ns(n,o);function p(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u(T,h,d){let{x:l,y:E}=h.toAffine(),L=n.toBytes(l);if(Lt(d,"isCompressed"),d){p();let _=!n.isOdd(E);return st(Us(_),L)}else return st(Uint8Array.of(4),L,n.toBytes(E))}function w(T){O(T,void 0,"Point");let{publicKey:h,publicKeyUncompressed:d}=f,l=T.length,E=T[0],L=T.subarray(1);if(l===h&&(E===2||E===3)){let _=n.fromBytes(L);if(!n.isValid(_))throw new Error("bad point: is not on curve, wrong x");let R=B(_),D;try{D=n.sqrt(R)}catch(F){let q=F instanceof Error?": "+F.message:"";throw new Error("bad point: is not on curve, sqrt error"+q)}p();let C=n.isOdd(D);return(E&1)===1!==C&&(D=n.neg(D)),{x:_,y:D}}else if(l===d&&E===4){let _=n.BYTES,R=n.fromBytes(L.subarray(0,_)),D=n.fromBytes(L.subarray(_,_*2));if(!A(R,D))throw new Error("bad point: is not on curve");return{x:R,y:D}}else throw new Error(`bad point: got length ${l}, expected compressed=${h} or uncompressed=${d}`)}let S=t.toBytes||u,m=t.fromBytes||w;function B(T){let h=n.sqr(T),d=n.mul(h,T);return n.add(n.add(d,n.mul(T,s.a)),s.b)}function A(T,h){let d=n.sqr(h),l=B(T);return n.eql(d,l)}if(!A(s.Gx,s.Gy))throw new Error("bad curve params: generator point");let y=n.mul(n.pow(s.a,mr),ya),v=n.mul(n.sqr(s.b),BigInt(27));if(n.is0(n.add(y,v)))throw new Error("bad curve params: a or b");function b(T,h,d=!1){if(!n.isValid(h)||d&&n.is0(h))throw new Error(`bad point coordinate ${T}`);return h}function I(T){if(!(T instanceof g))throw new Error("Weierstrass Point expected")}function U(T){if(!c||!c.basises)throw new Error("no endo");return ma(T,c.basises,o.ORDER)}let k=ce((T,h)=>{let{X:d,Y:l,Z:E}=T;if(n.eql(E,n.ONE))return{x:d,y:l};let L=T.is0();h==null&&(h=L?n.ONE:n.inv(E));let _=n.mul(d,h),R=n.mul(l,h),D=n.mul(E,h);if(L)return{x:n.ZERO,y:n.ZERO};if(!n.eql(D,n.ONE))throw new Error("invZ was invalid");return{x:_,y:R}}),P=ce(T=>{if(T.is0()){if(t.allowInfinityPoint&&!n.is0(T.Y))return;throw new Error("bad point: ZERO")}let{x:h,y:d}=T.toAffine();if(!n.isValid(h)||!n.isValid(d))throw new Error("bad point: x or y not field elements");if(!A(h,d))throw new Error("bad point: equation left != right");if(!T.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function x(T,h,d,l,E){return d=new g(n.mul(d.X,T),d.Y,d.Z),h=Te(l,h),d=Te(E,d),h.add(d)}class g{static BASE=new g(s.Gx,s.Gy,n.ONE);static ZERO=new g(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(h,d,l){this.X=b("x",h),this.Y=b("y",d,!0),this.Z=b("z",l),Object.freeze(this)}static CURVE(){return s}static fromAffine(h){let{x:d,y:l}=h||{};if(!h||!n.isValid(d)||!n.isValid(l))throw new Error("invalid affine point");if(h instanceof g)throw new Error("projective point not allowed");return n.is0(d)&&n.is0(l)?g.ZERO:new g(d,l,n.ONE)}static fromBytes(h){let d=g.fromAffine(m(O(h,void 0,"point")));return d.assertValidity(),d}static fromHex(h){return g.fromBytes(Bt(h))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(h=8,d=!0){return M.createCache(this,h),d||this.multiply(mr),this}assertValidity(){P(this)}hasEvenY(){let{y:h}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(h)}equals(h){I(h);let{X:d,Y:l,Z:E}=this,{X:L,Y:_,Z:R}=h,D=n.eql(n.mul(d,R),n.mul(L,E)),C=n.eql(n.mul(l,R),n.mul(_,E));return D&&C}negate(){return new g(this.X,n.neg(this.Y),this.Z)}double(){let{a:h,b:d}=s,l=n.mul(d,mr),{X:E,Y:L,Z:_}=this,R=n.ZERO,D=n.ZERO,C=n.ZERO,K=n.mul(E,E),F=n.mul(L,L),q=n.mul(_,_),H=n.mul(E,L);return H=n.add(H,H),C=n.mul(E,_),C=n.add(C,C),R=n.mul(h,C),D=n.mul(l,q),D=n.add(R,D),R=n.sub(F,D),D=n.add(F,D),D=n.mul(R,D),R=n.mul(H,R),C=n.mul(l,C),q=n.mul(h,q),H=n.sub(K,q),H=n.mul(h,H),H=n.add(H,C),C=n.add(K,K),K=n.add(C,K),K=n.add(K,q),K=n.mul(K,H),D=n.add(D,K),q=n.mul(L,_),q=n.add(q,q),K=n.mul(q,H),R=n.sub(R,K),C=n.mul(q,F),C=n.add(C,C),C=n.add(C,C),new g(R,D,C)}add(h){I(h);let{X:d,Y:l,Z:E}=this,{X:L,Y:_,Z:R}=h,D=n.ZERO,C=n.ZERO,K=n.ZERO,F=s.a,q=n.mul(s.b,mr),H=n.mul(d,L),Z=n.mul(l,_),W=n.mul(E,R),mt=n.add(d,l),$=n.add(L,_);mt=n.mul(mt,$),$=n.add(H,Z),mt=n.sub(mt,$),$=n.add(d,E);let tt=n.add(L,R);return $=n.mul($,tt),tt=n.add(H,W),$=n.sub($,tt),tt=n.add(l,E),D=n.add(_,R),tt=n.mul(tt,D),D=n.add(Z,W),tt=n.sub(tt,D),K=n.mul(F,$),D=n.mul(q,W),K=n.add(D,K),D=n.sub(Z,K),K=n.add(Z,K),C=n.mul(D,K),Z=n.add(H,H),Z=n.add(Z,H),W=n.mul(F,W),$=n.mul(q,$),Z=n.add(Z,W),W=n.sub(H,W),W=n.mul(F,W),$=n.add($,W),H=n.mul(Z,$),C=n.add(C,H),H=n.mul(tt,$),D=n.mul(mt,D),D=n.sub(D,H),H=n.mul(mt,Z),K=n.mul(tt,K),K=n.add(K,H),new g(D,C,K)}subtract(h){return this.add(h.negate())}is0(){return this.equals(g.ZERO)}multiply(h){let{endo:d}=t;if(!o.isValidNot0(h))throw new Error("invalid scalar: out of range");let l,E,L=_=>M.cached(this,_,R=>$t(g,R));if(d){let{k1neg:_,k1:R,k2neg:D,k2:C}=U(h),{p:K,f:F}=L(R),{p:q,f:H}=L(C);E=F.add(H),l=x(d.beta,K,q,_,D)}else{let{p:_,f:R}=L(h);l=_,E=R}return $t(g,[l,E])[0]}multiplyUnsafe(h){let{endo:d}=t,l=this;if(!o.isValid(h))throw new Error("invalid scalar: out of range");if(h===Dt||l.is0())return g.ZERO;if(h===he)return l;if(M.hasCache(this))return this.multiply(h);if(d){let{k1neg:E,k1:L,k2neg:_,k2:R}=U(h),{p1:D,p2:C}=is(g,l,L,R);return x(d.beta,D,C,E,_)}else return M.unsafe(l,h)}toAffine(h){return k(this,h)}isTorsionFree(){let{isTorsionFree:h}=t;return i===he?!0:h?h(g,this):M.unsafe(this,a).is0()}clearCofactor(){let{clearCofactor:h}=t;return i===he?this:h?h(g,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(h=!0){return Lt(h,"isCompressed"),this.assertValidity(),S(g,this,h)}toHex(h=!0){return vt(this.toBytes(h))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let N=o.BITS,M=new ue(g,t.endo?Math.ceil(N/2):N);return g.BASE.precompute(8),g}function Us(e){return Uint8Array.of(e?2:3)}function Ns(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function ba(e,t={}){let{Fn:r}=e,n=t.randomBytes||se,o=Object.assign(Ns(e.Fp,r),{seed:hn(r.ORDER)});function s(S){try{let m=r.fromBytes(S);return r.isValidNot0(m)}catch{return!1}}function i(S,m){let{publicKey:B,publicKeyUncompressed:A}=o;try{let y=S.length;return m===!0&&y!==B||m===!1&&y!==A?!1:!!e.fromBytes(S)}catch{return!1}}function a(S=n(o.seed)){return dn(O(S,o.seed,"seed"),r.ORDER)}function c(S,m=!0){return e.BASE.multiply(r.fromBytes(S)).toBytes(m)}function f(S){let{secretKey:m,publicKey:B,publicKeyUncompressed:A}=o;if(!Mt(S)||"_lengths"in r&&r._lengths||m===B)return;let y=O(S,void 0,"key").length;return y===B||y===A}function p(S,m,B=!0){if(f(S)===!0)throw new Error("first arg must be private key");if(f(m)===!1)throw new Error("second arg must be public key");let A=r.fromBytes(S);return e.fromBytes(m).multiply(A).toBytes(B)}let u={isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:a},w=rr(a,c);return Object.freeze({getPublicKey:c,getSharedSecret:p,keygen:w,Point:e,utils:u,lengths:o})}function Ks(e,t,r={}){Ye(t),Nt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||se,o=r.hmac||((d,l)=>Kn(t,d,l)),{Fp:s,Fn:i}=e,{ORDER:a,BITS:c}=i,{keygen:f,getPublicKey:p,getSharedSecret:u,utils:w,lengths:S}=ba(e,r),m={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},B=a*Rs<s.ORDER;function A(d){let l=a>>he;return d>l}function y(d,l){if(!i.isValidNot0(l))throw new Error(`invalid signature ${d}: out of range 1..Point.Fn.ORDER`);return l}function v(){if(B)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function b(d,l){kn(l);let E=S.signature,L=l==="compact"?E:l==="recovered"?E+1:void 0;return O(d,L)}class I{r;s;recovery;constructor(l,E,L){if(this.r=y("r",l),this.s=y("s",E),L!=null){if(v(),![0,1,2,3].includes(L))throw new Error("invalid recovery id");this.recovery=L}Object.freeze(this)}static fromBytes(l,E=m.format){b(l,E);let L;if(E==="der"){let{r:C,s:K}=Pt.toSig(O(l));return new I(C,K)}E==="recovered"&&(L=l[0],E="compact",l=l.subarray(1));let _=S.signature/2,R=l.subarray(0,_),D=l.subarray(_,_*2);return new I(i.fromBytes(R),i.fromBytes(D),L)}static fromHex(l,E){return this.fromBytes(Bt(l),E)}assertRecovery(){let{recovery:l}=this;if(l==null)throw new Error("invalid recovery id: must be present");return l}addRecoveryBit(l){return new I(this.r,this.s,l)}recoverPublicKey(l){let{r:E,s:L}=this,_=this.assertRecovery(),R=_===2||_===3?E+a:E;if(!s.isValid(R))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let D=s.toBytes(R),C=e.fromBytes(st(Us((_&1)===0),D)),K=i.inv(R),F=k(O(l,void 0,"msgHash")),q=i.create(-F*K),H=i.create(L*K),Z=e.BASE.multiplyUnsafe(q).add(C.multiplyUnsafe(H));if(Z.is0())throw new Error("invalid recovery: point at infinify");return Z.assertValidity(),Z}hasHighS(){return A(this.s)}toBytes(l=m.format){if(kn(l),l==="der")return Bt(Pt.hexFromSig(this));let{r:E,s:L}=this,_=i.toBytes(E),R=i.toBytes(L);return l==="recovered"?(v(),st(Uint8Array.of(this.assertRecovery()),_,R)):st(_,R)}toHex(l){return vt(this.toBytes(l))}}let U=r.bits2int||function(l){if(l.length>8192)throw new Error("input is too large");let E=ie(l),L=l.length*8-c;return L>0?E>>BigInt(L):E},k=r.bits2int_modN||function(l){return i.create(U(l))},P=De(c);function x(d){return Le("num < 2^"+c,d,Dt,P),i.toBytes(d)}function g(d,l){return O(d,void 0,"message"),l?O(t(d),void 0,"prehashed message"):d}function N(d,l,E){let{lowS:L,prehash:_,extraEntropy:R}=On(E,m);d=g(d,_);let D=k(d),C=i.fromBytes(l);if(!i.isValidNot0(C))throw new Error("invalid private key");let K=[x(C),x(D)];if(R!=null&&R!==!1){let Z=R===!0?n(S.secretKey):R;K.push(O(Z,void 0,"extraEntropy"))}let F=st(...K),q=D;function H(Z){let W=U(Z);if(!i.isValidNot0(W))return;let mt=i.inv(W),$=e.BASE.multiply(W).toAffine(),tt=i.create($.x);if(tt===Dt)return;let Pe=i.create(mt*i.create(q+tt*C));if(Pe===Dt)return;let qn=($.x===tt?0:2)|Number($.y&he),Vn=Pe;return L&&A(Pe)&&(Vn=i.neg(Pe),qn^=1),new I(tt,Vn,B?void 0:qn)}return{seed:F,k2sig:H}}function M(d,l,E={}){let{seed:L,k2sig:_}=N(d,l,E);return Fo(t.outputLen,i.BYTES,o)(L,_).toBytes(E.format)}function T(d,l,E,L={}){let{lowS:_,prehash:R,format:D}=On(L,m);if(E=O(E,void 0,"publicKey"),l=g(l,R),!Mt(d)){let C=d instanceof I?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+C)}b(d,D);try{let C=I.fromBytes(d,D),K=e.fromBytes(E);if(_&&C.hasHighS())return!1;let{r:F,s:q}=C,H=k(l),Z=i.inv(q),W=i.create(H*Z),mt=i.create(F*Z),$=e.BASE.multiplyUnsafe(W).add(K.multiplyUnsafe(mt));return $.is0()?!1:i.create($.x)===F}catch{return!1}}function h(d,l,E={}){let{prehash:L}=On(E,m);return l=g(l,L),I.fromBytes(d,"recovered").recoverPublicKey(l).toBytes()}return Object.freeze({keygen:f,getPublicKey:p,getSharedSecret:u,utils:w,lengths:S,Point:e,sign:M,verify:T,recoverPublicKey:h,Signature:I,hash:t})}var Hn={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},ga={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Os=BigInt(2);function xa(e){let t=Hn.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),f=e*e*e%t,p=f*f*e%t,u=V(p,r,t)*p%t,w=V(u,r,t)*p%t,S=V(w,Os,t)*f%t,m=V(S,o,t)*S%t,B=V(m,s,t)*m%t,A=V(B,a,t)*B%t,y=V(A,c,t)*A%t,v=V(y,a,t)*B%t,b=V(v,r,t)*p%t,I=V(b,i,t)*m%t,U=V(I,n,t)*f%t,k=V(U,Os,t);if(!Mn.eql(Mn.sqr(k),e))throw new Error("Cannot find square root");return k}var Mn=ae(Hn.p,{sqrt:xa}),wa=Cs(Hn,{Fp:Mn,endo:ga}),de=Ks(wa,Mo);function ks(e,t,r,n){let o=ge.digest(r instanceof Uint8Array?r:r.subarray());if(ir(o))return o.then(({digest:s})=>(n?.signal?.throwIfAborted(),de.verify(t,s,e,{prehash:!1,format:"der"}))).catch(s=>{throw s.name==="AbortError"?s:new Re(String(s))});try{return n?.signal?.throwIfAborted(),de.verify(t,o.digest,e,{prehash:!1,format:"der"})}catch(s){throw new Re(String(s))}}var yr=class{type="secp256k1";raw;_key;constructor(t){this._key=Ms(t),this.raw=Ps(this._key)}toMultihash(){return lt.digest(ne(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ht(this.raw,t.raw)}verify(t,r,n){return ks(this._key,r,t,n)}};function Hs(e){return new yr(e)}function Ps(e){return de.Point.fromBytes(e).toBytes()}function Ms(e){try{return de.Point.fromBytes(e),e}catch(t){throw new Fe(String(t))}}function qs(e){let{Type:t,Data:r}=Ke.decode(e.digest),n=r??new Uint8Array;switch(t){case ut.Ed25519:return ms(n);case ut.secp256k1:return Hs(n);case ut.ECDSA:return So(n);default:throw new we}}function ne(e){return Ke.encode({Type:ut[e.type],Data:e.raw})}var Vs=Symbol.for("nodejs.util.inspect.custom"),Ea=114,Oe=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Fr]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Q.createV1(Ea,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ht(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ht(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Vs](){return`PeerId(${this.toString()})`}},br=class extends Oe{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},gr=class extends Oe{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},xr=class extends Oe{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Sa=2336,ke=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=lt.digest(Tt(this.url))}[Vs](){return`PeerId(${this.url})`}[Fr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Q.createV1(Sa,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=ot(t)),t.toString()===this.toString())}};var Aa=114,Fs=2336;function Zs(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=be(G.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return va(Q.parse(e));if(t==null)throw new yt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=be(t.decode(e))}return $s(r)}function $s(e){if(Ia(e))return new br({multihash:e});if(Ba(e))try{let t=qs(e);if(t.type==="Ed25519")return new gr({multihash:e,publicKey:t});if(t.type==="secp256k1")return new xr({multihash:e,publicKey:t})}catch{let r=ot(e.digest);return new ke(new URL(r))}throw new $e("Supplied PeerID Multihash is invalid")}function va(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==Aa&&e.code!==Fs)throw new Ze("Supplied PeerID CID is invalid");if(e.code===Fs){let t=ot(e.multihash.digest);return new ke(new URL(t))}return $s(e.multihash)}function Ba(e){return e.code===lt.code}function Ia(e){return e.code===ge.code}var js={parse:(e,t)=>{let[,r,n,...o]=e.split("/");if(r!=="ipns")throw new ee(`Namespace ${r} was not "ipns"`);return{namespace:"ipns",peerId:Zs(n),path:o.length>0?`/${o.join("/")}`:"",answer:t}}};var wr=class{dns;log;namespaces;constructor(t,r={}){this.dns=t.dns,this.log=t.logger.forComponent("helia:dnslink"),this.namespaces={ipfs:mo,ipns:js,...r.namespaces}}async resolve(t,r={}){return this.recursiveResolveDomain(t,r.maxRecursiveDepth??po,r)}async recursiveResolveDomain(t,r,n={}){if(r===0)throw new Error("recursion limit exceeded");t.startsWith("_dnslink.")||(t=`_dnslink.${t}`);try{return await this.recursiveResolveDnslink(t,r,n)}catch(o){if(o.code!=="ENOTFOUND"&&o.code!=="ENODATA"&&o.name!=="DNSLinkNotFoundError"&&o.name!=="NotFoundError")throw o;return t.startsWith("_dnslink.")?t=t.replace("_dnslink.",""):t=`_dnslink.${t}`,this.recursiveResolveDnslink(t,r,n)}}async recursiveResolveDnslink(t,r,n={}){if(r===0)throw new Error("recursion limit exceeded");this.log("query %s for TXT and CNAME records",t);let s=((await this.dns.query(t,{...n,types:[xt.TXT]}))?.Answer??[]).sort((c,f)=>c.data.localeCompare(f.data));this.log("found %d TXT records for %s",s.length,t);for(let c of s)try{let f=c.data;if(f.startsWith('"')&&f.endsWith('"')&&(f=f.substring(1,f.length-1)),!f.startsWith("dnslink="))continue;this.log("%s TXT %s",c.name,f),f=f.replace("dnslink=","");let[,p,u]=f.split("/");if(p==="dnslink")return await this.recursiveResolveDomain(u,r-1,n);let w=this.namespaces[p];if(w==null){this.log('unknown protocol "%s" in DNSLink record for domain: %s',p,t);continue}return w.parse(f,c)}catch(f){this.log.error("could not parse DNS link record for domain %s, %s",t,c.data,f)}this.log("no DNSLink records found for %s, falling back to CNAME",t);let a=((await this.dns.query(t,{...n,types:[xt.CNAME]}))?.Answer??[]).sort((c,f)=>c.data.localeCompare(f.data));this.log("found %d CNAME records for %s",a.length,t);for(let c of a)try{return await this.recursiveResolveDomain(c.data,r-1,n)}catch(f){this.log.error("domain %s cname %s had no DNSLink records - %e",t,c.data,f)}throw new Ve(`No DNSLink records found for domain: ${t}`)}};function La(e,t={}){return new wr(e,t)}return ti(Da);})();
|
|
3
|
+
/*! Bundled license information:
|
|
4
|
+
|
|
5
|
+
@noble/hashes/utils.js:
|
|
6
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
7
|
+
|
|
8
|
+
@noble/curves/utils.js:
|
|
9
|
+
@noble/curves/abstract/modular.js:
|
|
10
|
+
@noble/curves/abstract/curve.js:
|
|
11
|
+
@noble/curves/abstract/edwards.js:
|
|
12
|
+
@noble/curves/ed25519.js:
|
|
13
|
+
@noble/curves/abstract/weierstrass.js:
|
|
14
|
+
@noble/curves/secp256k1.js:
|
|
15
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
16
|
+
*/
|
|
17
|
+
return HeliaDnslink}));
|
|
18
|
+
//# sourceMappingURL=index.min.js.map
|