@libp2p/kad-dht 12.0.5-e1db332a4 → 12.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/typedoc-urls.json +56 -0
- package/package.json +38 -38
package/dist/index.min.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PKadDht = factory()}(typeof self !== 'undefined' ? self : this, function () {
|
|
2
|
-
"use strict";var Libp2PKadDht=(()=>{var J4=Object.create;var Hn=Object.defineProperty;var e5=Object.getOwnPropertyDescriptor;var t5=Object.getOwnPropertyNames;var r5=Object.getPrototypeOf,n5=Object.prototype.hasOwnProperty;var sn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ue=(r,e)=>{for(var t in e)Hn(r,t,{get:e[t],enumerable:!0})},p2=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of t5(e))!n5.call(r,s)&&s!==t&&Hn(r,s,{get:()=>e[s],enumerable:!(n=e5(e,s))||n.enumerable});return r};var on=(r,e,t)=>(t=r!=null?J4(r5(r)):{},p2(e||!r||!r.__esModule?Hn(t,"default",{value:r,enumerable:!0}):t,r)),s5=r=>p2(Hn({},"__esModule",{value:!0}),r);var c0=sn(wn=>{(function(){var r,e,t,n,s,i,o,a;a=function(c){var l,f,u,h;return l=(c&255<<24)>>>24,f=(c&255<<16)>>>16,u=(c&65280)>>>8,h=c&255,[l,f,u,h].join(".")},o=function(c){var l,f,u,h,m,p;for(l=[],u=h=0;h<=3&&c.length!==0;u=++h){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}p=e(c),m=p[0],f=p[1],c=c.substring(f),l.push(m)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),i=t("a"),s=t("A"),e=function(c){var l,f,u,h,m;for(h=0,l=10,f="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,l=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,l=8,f="7")),m=u;u<c.length;){if("0"<=c[u]&&c[u]<=f)h=h*l+(t(c[u])-n)>>>0;else if(l===16)if("a"<=c[u]&&c[u]<="f")h=h*l+(10+t(c[u])-i)>>>0;else if("A"<=c[u]&&c[u]<="F")h=h*l+(10+t(c[u])-s)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");u++}if(u===m)throw new Error("empty octet");return[h,u]},r=function(){function c(l,f){var u,h,m,p;if(typeof l!="string")throw new Error("Missing `net' parameter");if(f||(p=l.split("/",2),l=p[0],f=p[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=o(f)}catch(d){throw u=d,new Error("Invalid mask: "+f)}for(h=m=32;m>=0;h=--m)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(o(l)&this.maskLong)>>>0}catch(d){throw u=d,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(o(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var f,u,h;for(h=o(this.first),u=o(this.last),f=0;h<=u;)l(a(h),h,f),f++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),wn.ip2long=o,wn.long2ip=a,wn.Netmask=r}).call(wn)});var w3=sn(Zr=>{"use strict";var Ua="[object ArrayBuffer]",Rt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Ua}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),s=r.toUint8Array(t);if(n.length!==s.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==s[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let o of t)n+=o.byteLength;let s=new Uint8Array(n),i=0;for(let o of t){let a=this.toUint8Array(o);s.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}},Lo="string",Oa=/^[0-9a-f]+$/i,Va=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Fa=/^[a-zA-Z0-9-_]+$/,_1=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){let t=Rt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},qe=class{static toString(e,t=!1){let n=Rt.toArrayBuffer(e),s=new DataView(n),i="";for(let o=0;o<n.byteLength;o+=2){let a=s.getUint16(o,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let i=0;i<e.length;i++)s.setUint16(i*2,e.charCodeAt(i),t);return n}},T1=class r{static isHex(e){return typeof e===Lo&&Oa.test(e)}static isBase64(e){return typeof e===Lo&&Va.test(e)}static isBase64Url(e){return typeof e===Lo&&Fa.test(e)}static ToString(e,t="utf8"){let n=Rt.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return qe.toString(n,!0);case"utf16":case"utf16be":return qe.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return qe.fromString(e,!0);case"utf16":case"utf16be":return qe.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Rt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return _1.fromString(e);case"utf16":case"utf16be":return qe.fromString(e);case"utf16le":case"usc2":return qe.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return _1.toString(e);case"utf16":case"utf16be":return qe.toString(e);case"utf16le":case"usc2":return qe.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){let t=Rt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=Rt.toUint8Array(e),n="",s=t.length;for(let i=0;i<s;i++){let o=t[i];o<16&&(n+="0"),n+=o.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let i=t.slice(s,s+2);n[s/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return qe.toString(e,t)}static FromUtf16String(e,t=!1){return qe.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};T1.DEFAULT_UTF8_ENCODING="utf8";function Ma(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let i in s)t[i]=s[i]}return t}function Ha(...r){let e=r.map(s=>s.byteLength).reduce((s,i)=>s+i),t=new Uint8Array(e),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let i of s)t[n++]=i}),t.buffer}function Ka(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}Zr.BufferSourceConverter=Rt;Zr.Convert=T1;Zr.assign=Ma;Zr.combine=Ha;Zr.isEqual=Ka});var S4=sn((pg,I4)=>{I4.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function s(i,o){t[i]=o,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(i){return t[i]!==void 0||n[i]!==void 0},remove:function(i){t[i]!==void 0&&(t[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var o=t[i];if(o!==void 0)return o;if((o=n[i])!==void 0)return s(i,o),o},set:function(i,o){t[i]!==void 0?t[i]=o:s(i,o)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var k4=sn((gg,Wo)=>{"use strict";var k7=Object.prototype.hasOwnProperty,Le="~";function Dn(){}Object.create&&(Dn.prototype=Object.create(null),new Dn().__proto__||(Le=!1));function N7(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function R4(r,e,t,n,s){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new N7(t,n||r,s),o=Le?Le+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],i]:r._events[o].push(i):(r._events[o]=i,r._eventsCount++),r}function As(r,e){--r._eventsCount===0?r._events=new Dn:delete r._events[e]}function ke(){this._events=new Dn,this._eventsCount=0}ke.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)k7.call(t,n)&&e.push(Le?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};ke.prototype.listeners=function(e){var t=Le?Le+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var s=0,i=n.length,o=new Array(i);s<i;s++)o[s]=n[s].fn;return o};ke.prototype.listenerCount=function(e){var t=Le?Le+e:e,n=this._events[t];return n?n.fn?1:n.length:0};ke.prototype.emit=function(e,t,n,s,i,o){var a=Le?Le+e:e;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,f,u;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,s),!0;case 5:return c.fn.call(c.context,t,n,s,i),!0;case 6:return c.fn.call(c.context,t,n,s,i,o),!0}for(u=1,f=new Array(l-1);u<l;u++)f[u-1]=arguments[u];c.fn.apply(c.context,f)}else{var h=c.length,m;for(u=0;u<h;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),l){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;case 4:c[u].fn.call(c[u].context,t,n,s);break;default:if(!f)for(m=1,f=new Array(l-1);m<l;m++)f[m-1]=arguments[m];c[u].fn.apply(c[u].context,f)}}return!0};ke.prototype.on=function(e,t,n){return R4(this,e,t,n,!1)};ke.prototype.once=function(e,t,n){return R4(this,e,t,n,!0)};ke.prototype.removeListener=function(e,t,n,s){var i=Le?Le+e:e;if(!this._events[i])return this;if(!t)return As(this,i),this;var o=this._events[i];if(o.fn)o.fn===t&&(!s||o.once)&&(!n||o.context===n)&&As(this,i);else{for(var a=0,c=[],l=o.length;a<l;a++)(o[a].fn!==t||s&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[i]=c.length===1?c[0]:c:As(this,i)}return this};ke.prototype.removeAllListeners=function(e){var t;return e?(t=Le?Le+e:e,this._events[t]&&As(this,t)):(this._events=new Dn,this._eventsCount=0),this};ke.prototype.off=ke.prototype.removeListener;ke.prototype.addListener=ke.prototype.on;ke.prefixed=Le;ke.EventEmitter=ke;typeof Wo<"u"&&(Wo.exports=ke)});var $4=sn((ey,q4)=>{"use strict";function K4(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Y7(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return K4(r,t)}catch{t.message=r.message,t.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),K4(new s,t)}}q4.exports=Y7});var tc={};ue(tc,{EventTypes:()=>s2,MessageType:()=>i2,Record:()=>me,kadDHT:()=>ec,passthroughMapper:()=>h0,removePrivateAddressesMapper:()=>o1,removePublicAddressesMapper:()=>f0});var g2=Symbol.for("@libp2p/content-routing");var m2=Symbol.for("@libp2p/peer-discovery");var y2=Symbol.for("@libp2p/peer-id");var b2=Symbol.for("@libp2p/peer-routing");var Ut=class r extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},E=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Be=class extends EventTarget{#e=new Map;listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let s=this.#e.get(e);s==null&&(s=[],this.#e.set(e,s)),s.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let s=this.#e.get(e);s!=null&&(s=s.filter(({callback:i})=>i!==t),this.#e.set(e,s))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:s})=>!s),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new Ne(e,t))}},Zs=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},Ne=globalThis.CustomEvent??Zs;var pt=(r,...e)=>{try{[...e]}catch{}};function i5(r){return r[Symbol.asyncIterator]!=null}function o5(r){if(i5(r))return(async()=>{for await(let e of r);})();for(let e of r);}var Qs=o5;function fe(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var w2="/ipfs/kad/1.0.0",v2="/dht/record",Xs="/dht/provider";function a5(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:s=>{n.push(s)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var E2=a5;function c5(r){return r[Symbol.asyncIterator]!=null}function l5(r,e){if(c5(r))return async function*(){for await(let a of r)yield e(a)}();let t=E2(r),{value:n,done:s}=t.next();if(s===!0)return function*(){}();let i=e(n);if(typeof i.then=="function")return async function*(){yield await i;for await(let a of t)yield e(a)}();let o=e;return function*(){yield i;for(let a of t)yield o(a)}()}var Kn=l5;var qn=globalThis.CustomEvent??Event;async function*an(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,s=new EventTarget,i=[],o=fe(),a=fe(),c=!1,l,f=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let p of r){if(i.length===t&&(o=fe(),await o.promise),f)break;let d={done:!1};i.push(d),p().then(g=>{d.done=!0,d.ok=!0,d.value=g,s.dispatchEvent(new qn("task-complete"))},g=>{d.done=!0,d.err=g,s.dispatchEvent(new qn("task-complete"))})}c=!0,s.dispatchEvent(new qn("task-complete"))}catch(p){l=p,s.dispatchEvent(new qn("task-complete"))}});function u(){return n?i[0]?.done:!!i.find(p=>p.done)}function*h(){for(;i.length>0&&i[0].done;){let p=i[0];if(i.shift(),p.ok)yield p.value;else throw f=!0,o.resolve(),p.err;o.resolve()}}function*m(){for(;u();)for(let p=0;p<i.length;p++)if(i[p].done){let d=i[p];if(i.splice(p,1),p--,d.ok)yield d.value;else throw f=!0,o.resolve(),d.err;o.resolve()}}for(;;){if(u()||(a=fe(),await a.promise),l!=null)throw l;if(n?yield*h():yield*m(),c&&i.length===0)break}}var $n=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},vr=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new $n(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new $n(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Js=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Ot(r={}){return u5(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function u5(r,e){e=e??{};let t=e.onEnd,n=new vr,s,i,o,a=fe(),c=async()=>{try{return n.isEmpty()?o?{done:!0}:await new Promise((g,y)=>{i=v=>{i=null,n.push(v);try{g(r(n))}catch(b){y(b)}return s}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=fe()})}},l=g=>i!=null?i(g):(n.push(g),s),f=g=>(n=new vr,i!=null?i({error:g}):(n.push({error:g}),s)),u=g=>{if(o)return s;if(e?.objectMode!==!0&&g?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:g})},h=g=>o?s:(o=!0,g!=null?f(g):l({done:!0})),m=()=>(n=new vr,h(),{done:!0}),p=g=>(h(g),{done:!0});if(s={[Symbol.asyncIterator](){return this},next:c,return:m,throw:p,push:u,end:h,get readableLength(){return n.size},onEmpty:async g=>{let y=g?.signal;if(y?.throwIfAborted(),n.isEmpty())return;let v,b;y!=null&&(v=new Promise((S,x)=>{b=()=>{x(new Js)},y.addEventListener("abort",b)}));try{await Promise.race([a.promise,v])}finally{b!=null&&y!=null&&y?.removeEventListener("abort",b)}}},t==null)return s;let d=s;return s={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(g){return d.throw(g),t!=null&&(t(g),t=void 0),{done:!0}},return(){return d.return(),t!=null&&(t(),t=void 0),{done:!0}},push:u,end(g){return d.end(g),t!=null&&(t(g),t=void 0),s},get readableLength(){return d.readableLength},onEmpty:g=>d.onEmpty(g)},s}function f5(r){return r[Symbol.asyncIterator]!=null}function h5(...r){let e=[];for(let t of r)f5(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=Ot({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let s of n)t.push(s)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var zn=h5;function Vt(r,...e){if(r==null)throw new Error("Empty pipeline");if(ei(r)){let n=r;r=()=>n.source}else if(A2(r)||x2(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&ei(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)ei(t[n])&&(t[n]=p5(t[n]));return d5(...t)}var d5=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},x2=r=>r?.[Symbol.asyncIterator]!=null,A2=r=>r?.[Symbol.iterator]!=null,ei=r=>r==null?!1:r.sink!=null&&r.source!=null,p5=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=Ot({objectMode:!0});t.then(()=>{n.end()},o=>{n.end(o)});let s,i=r.source;if(x2(i))s=async function*(){yield*i,n.end()};else if(A2(i))s=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return zn(n,s())}return r.source};function Q(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function rt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ze(r=0){return globalThis.Buffer?.alloc!=null?rt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function be(r=0){return globalThis.Buffer?.allocUnsafe!=null?rt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var g5=Math.pow(2,7),m5=Math.pow(2,14),y5=Math.pow(2,21),ti=Math.pow(2,28),ri=Math.pow(2,35),ni=Math.pow(2,42),si=Math.pow(2,49),j=128,Ie=127;function he(r){if(r<g5)return 1;if(r<m5)return 2;if(r<y5)return 3;if(r<ti)return 4;if(r<ri)return 5;if(r<ni)return 6;if(r<si)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ii(r,e,t=0){switch(he(r)){case 8:e[t++]=r&255|j,r/=128;case 7:e[t++]=r&255|j,r/=128;case 6:e[t++]=r&255|j,r/=128;case 5:e[t++]=r&255|j,r/=128;case 4:e[t++]=r&255|j,r>>>=7;case 3:e[t++]=r&255|j,r>>>=7;case 2:e[t++]=r&255|j,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function b5(r,e,t=0){switch(he(r)){case 8:e.set(t++,r&255|j),r/=128;case 7:e.set(t++,r&255|j),r/=128;case 6:e.set(t++,r&255|j),r/=128;case 5:e.set(t++,r&255|j),r/=128;case 4:e.set(t++,r&255|j),r>>>=7;case 3:e.set(t++,r&255|j),r>>>=7;case 2:e.set(t++,r&255|j),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function oi(r,e){let t=r[e],n=0;if(n+=t&Ie,t<j||(t=r[e+1],n+=(t&Ie)<<7,t<j)||(t=r[e+2],n+=(t&Ie)<<14,t<j)||(t=r[e+3],n+=(t&Ie)<<21,t<j)||(t=r[e+4],n+=(t&Ie)*ti,t<j)||(t=r[e+5],n+=(t&Ie)*ri,t<j)||(t=r[e+6],n+=(t&Ie)*ni,t<j)||(t=r[e+7],n+=(t&Ie)*si,t<j))return n;throw new RangeError("Could not decode varint")}function w5(r,e){let t=r.get(e),n=0;if(n+=t&Ie,t<j||(t=r.get(e+1),n+=(t&Ie)<<7,t<j)||(t=r.get(e+2),n+=(t&Ie)<<14,t<j)||(t=r.get(e+3),n+=(t&Ie)<<21,t<j)||(t=r.get(e+4),n+=(t&Ie)*ti,t<j)||(t=r.get(e+5),n+=(t&Ie)*ri,t<j)||(t=r.get(e+6),n+=(t&Ie)*ni,t<j)||(t=r.get(e+7),n+=(t&Ie)*si,t<j))return n;throw new RangeError("Could not decode varint")}function Me(r,e,t=0){return e==null&&(e=be(he(r))),e instanceof Uint8Array?ii(r,e,t):b5(r,e,t)}function Ce(r,e=0){return r instanceof Uint8Array?oi(r,e):w5(r,e)}var ai=new Float32Array([-0]),Ft=new Uint8Array(ai.buffer);function B2(r,e,t){ai[0]=r,e[t]=Ft[0],e[t+1]=Ft[1],e[t+2]=Ft[2],e[t+3]=Ft[3]}function I2(r,e){return Ft[0]=r[e],Ft[1]=r[e+1],Ft[2]=r[e+2],Ft[3]=r[e+3],ai[0]}var ci=new Float64Array([-0]),Se=new Uint8Array(ci.buffer);function S2(r,e,t){ci[0]=r,e[t]=Se[0],e[t+1]=Se[1],e[t+2]=Se[2],e[t+3]=Se[3],e[t+4]=Se[4],e[t+5]=Se[5],e[t+6]=Se[6],e[t+7]=Se[7]}function R2(r,e){return Se[0]=r[e],Se[1]=r[e+1],Se[2]=r[e+2],Se[3]=r[e+3],Se[4]=r[e+4],Se[5]=r[e+5],Se[6]=r[e+6],Se[7]=r[e+7],ci[0]}var v5=BigInt(Number.MAX_SAFE_INTEGER),E5=BigInt(Number.MIN_SAFE_INTEGER),De=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return nr;if(e<v5&&e>E5)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,s=e-(n<<32n);return t&&(n=~n|0n,s=~s|0n,++s>k2&&(s=0n,++n>k2&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(e){if(e===0)return nr;let t=e<0;t&&(e=-e);let n=e>>>0,s=(e-n)/4294967296>>>0;return t&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):nr}},nr=new De(0,0);nr.toBigInt=function(){return 0n};nr.zzEncode=nr.zzDecode=function(){return this};nr.length=function(){return 1};var k2=4294967296n;function N2(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function _2(r,e,t){if(t-e<1)return"";let s,i=[],o=0,a;for(;e<t;)a=r[e++],a<128?i[o++]=a:a>191&&a<224?i[o++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[o++]=55296+(a>>10),i[o++]=56320+(a&1023)):i[o++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,o>8191&&((s??(s=[])).push(String.fromCharCode.apply(String,i)),o=0);return s!=null?(o>0&&s.push(String.fromCharCode.apply(String,i.slice(0,o))),s.join("")):String.fromCharCode.apply(String,i.slice(0,o))}function li(r,e,t){let n=t,s,i;for(let o=0;o<r.length;++o)s=r.charCodeAt(o),s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&((i=r.charCodeAt(o+1))&64512)===56320?(s=65536+((s&1023)<<10)+(i&1023),++o,e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128);return t-n}function Ge(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Gn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ui=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Ge(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Ge(this,4);return Gn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ge(this,4);return Gn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ge(this,4);let e=I2(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ge(this,4);let e=R2(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Ge(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return _2(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ge(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ge(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new De(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Ge(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Ge(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ge(this,8);let e=Gn(this.buf,this.pos+=4),t=Gn(this.buf,this.pos+=4);return new De(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=oi(this.buf,this.pos);return this.pos+=he(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function fi(r){return new ui(r instanceof Uint8Array?r:r.subarray())}function nt(r,e,t){let n=fi(r);return e.decode(n,void 0,t)}var mi={};ue(mi,{base10:()=>R5});var Mc=new Uint8Array(0);function L2(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function gt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function P2(r){return new TextEncoder().encode(r)}function C2(r){return new TextDecoder().decode(r)}function x5(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var s=0;s<r.length;s++){var i=r.charAt(s),o=i.charCodeAt(0);if(t[o]!==255)throw new TypeError(i+" is ambiguous");t[o]=s}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var d=0,g=0,y=0,v=p.length;y!==v&&p[y]===0;)y++,d++;for(var b=(v-y)*f+1>>>0,S=new Uint8Array(b);y!==v;){for(var x=p[y],I=0,N=b-1;(x!==0||I<g)&&N!==-1;N--,I++)x+=256*S[N]>>>0,S[N]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");g=I,y++}for(var T=b-g;T!==b&&S[T]===0;)T++;for(var G=c.repeat(d);T<b;++T)G+=r.charAt(S[T]);return G}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var d=0;if(p[d]!==" "){for(var g=0,y=0;p[d]===c;)g++,d++;for(var v=(p.length-d)*l+1>>>0,b=new Uint8Array(v);p[d];){var S=t[p.charCodeAt(d)];if(S===255)return;for(var x=0,I=v-1;(S!==0||x<y)&&I!==-1;I--,x++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");y=x,d++}if(p[d]!==" "){for(var N=v-y;N!==v&&b[N]===0;)N++;for(var T=new Uint8Array(g+(v-N)),G=g;N!==v;)T[G++]=b[N++];return T}}}function m(p){var d=h(p);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:h,decode:m}}var A5=x5,B5=A5,U2=B5;var hi=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},di=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return O2(this,e)}},pi=class{decoders;constructor(e){this.decoders=e}or(e){return O2(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function O2(r,e){return new pi({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var gi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,s){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=s,this.encoder=new hi(e,t,n),this.decoder=new di(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function xr({name:r,prefix:e,encode:t,decode:n}){return new gi(r,e,t,n)}function Mt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:s}=U2(t,r);return xr({prefix:e,name:r,encode:n,decode:i=>gt(s(i))})}function I5(r,e,t,n){let s={};for(let f=0;f<e.length;++f)s[e[f]]=f;let i=r.length;for(;r[i-1]==="=";)--i;let o=new Uint8Array(i*t/8|0),a=0,c=0,l=0;for(let f=0;f<i;++f){let u=s[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|u,a+=t,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o}function S5(r,e,t){let n=e[e.length-1]==="=",s=(1<<t)-1,i="",o=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],o+=8;o>t;)o-=t,i+=e[s&a>>o];if(o!==0&&(i+=e[s&a<<t-o]),n)for(;i.length*t&7;)i+="=";return i}function ie({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return xr({prefix:e,name:r,encode(s){return S5(s,n,t)},decode(s){return I5(s,n,t,r)}})}var R5=Mt({prefix:"9",name:"base10",alphabet:"0123456789"});var yi={};ue(yi,{base16:()=>k5,base16upper:()=>N5});var k5=ie({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),N5=ie({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bi={};ue(bi,{base2:()=>_5});var _5=ie({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wi={};ue(wi,{base256emoji:()=>D5});var V2=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}"),T5=V2.reduce((r,e,t)=>(r[t]=e,r),[]),L5=V2.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function P5(r){return r.reduce((e,t)=>(e+=T5[t],e),"")}function C5(r){let e=[];for(let t of r){let n=L5[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var D5=xr({prefix:"\u{1F680}",name:"base256emoji",encode:P5,decode:C5});var vi={};ue(vi,{base32:()=>mt,base32hex:()=>F5,base32hexpad:()=>H5,base32hexpadupper:()=>K5,base32hexupper:()=>M5,base32pad:()=>O5,base32padupper:()=>V5,base32upper:()=>U5,base32z:()=>q5});var mt=ie({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),U5=ie({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),O5=ie({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),V5=ie({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),F5=ie({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),M5=ie({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),H5=ie({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),K5=ie({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),q5=ie({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ei={};ue(Ei,{base36:()=>$5,base36upper:()=>z5});var $5=Mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),z5=Mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xi={};ue(xi,{base58btc:()=>ge,base58flickr:()=>G5});var ge=Mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),G5=Mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ai={};ue(Ai,{base64:()=>cn,base64pad:()=>j5,base64url:()=>Y5,base64urlpad:()=>W5});var cn=ie({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j5=ie({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Y5=ie({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),W5=ie({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Bi={};ue(Bi,{base8:()=>Z5});var Z5=ie({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ii={};ue(Ii,{identity:()=>Q5});var Q5=xr({prefix:"\0",name:"identity",encode:r=>C2(r),decode:r=>P2(r)});var r9=new TextEncoder,n9=new TextDecoder;var Ri={};ue(Ri,{identity:()=>Ht});var e6=H2,F2=128,t6=127,r6=~t6,n6=Math.pow(2,31);function H2(r,e,t){e=e||[],t=t||0;for(var n=t;r>=n6;)e[t++]=r&255|F2,r/=128;for(;r&r6;)e[t++]=r&255|F2,r>>>=7;return e[t]=r|0,H2.bytes=t-n+1,e}var s6=Si,i6=128,M2=127;function Si(r,n){var t=0,n=n||0,s=0,i=n,o,a=r.length;do{if(i>=a)throw Si.bytes=0,new RangeError("Could not decode varint");o=r[i++],t+=s<28?(o&M2)<<s:(o&M2)*Math.pow(2,s),s+=7}while(o>=i6);return Si.bytes=i-n,t}var o6=Math.pow(2,7),a6=Math.pow(2,14),c6=Math.pow(2,21),l6=Math.pow(2,28),u6=Math.pow(2,35),f6=Math.pow(2,42),h6=Math.pow(2,49),d6=Math.pow(2,56),p6=Math.pow(2,63),g6=function(r){return r<o6?1:r<a6?2:r<c6?3:r<l6?4:r<u6?5:r<f6?6:r<h6?7:r<d6?8:r<p6?9:10},m6={encode:e6,decode:s6,encodingLength:g6},y6=m6,ln=y6;function un(r,e=0){return[ln.decode(r,e),ln.decode.bytes]}function Ar(r,e,t=0){return ln.encode(r,e,t),e}function Br(r){return ln.encodingLength(r)}function st(r,e){let t=e.byteLength,n=Br(r),s=n+Br(t),i=new Uint8Array(s+t);return Ar(r,i,0),Ar(t,i,n),i.set(e,s),new Ir(r,t,e,i)}function sr(r){let e=gt(r),[t,n]=un(e),[s,i]=un(e.subarray(n)),o=e.subarray(n+i);if(o.byteLength!==s)throw new Error("Incorrect length");return new Ir(t,s,o,e)}function K2(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&L2(r.bytes,t.bytes)}}var Ir=class{code;size;digest;bytes;constructor(e,t,n,s){this.code=e,this.size=t,this.digest=n,this.bytes=s}};var q2=0,b6="identity",$2=gt;function w6(r){return st(q2,$2(r))}var Ht={code:q2,name:b6,encode:$2,digest:w6};var _i={};ue(_i,{sha256:()=>ne,sha512:()=>v6});function Ni({name:r,code:e,encode:t}){return new ki(r,e,t)}var ki=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?st(this.code,t):t.then(n=>st(this.code,n))}else throw Error("Unknown type, must be binary type")}};function G2(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ne=Ni({name:"sha2-256",code:18,encode:G2("SHA-256")}),v6=Ni({name:"sha2-512",code:19,encode:G2("SHA-512")});function j2(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return x6(t,Ti(r),e??ge.encoder);default:return A6(t,Ti(r),e??mt.encoder)}}var Y2=new WeakMap;function Ti(r){let e=Y2.get(r);if(e==null){let t=new Map;return Y2.set(r,t),t}return e}var _e=class r{code;version;multihash;bytes;"/";constructor(e,t,n,s){this.code=t,this.version=e,this.multihash=n,this.bytes=s,this["/"]=s}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==fn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==B6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=st(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&K2(e.multihash,n.multihash)}toString(e){return j2(this,e)}toJSON(){return{"/":j2(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:s,multihash:i,bytes:o}=t;return new r(n,s,i,o??W2(n,s,i.bytes))}else if(t[I6]===!0){let{version:n,multihash:s,code:i}=t,o=sr(s);return r.create(n,i,o)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==fn)throw new Error(`Version 0 CID must use dag-pb (code: ${fn}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let s=W2(e,t,n.bytes);return new r(e,t,n,s)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,fn,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,s=gt(e.subarray(n,n+t.multihashSize));if(s.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=s.subarray(t.multihashSize-t.digestSize),o=new Ir(t.multihashCode,t.digestSize,i,s);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[u,h]=un(e.subarray(t));return t+=h,u},s=n(),i=fn;if(s===18?(s=0,t=0):i=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let o=t,a=n(),c=n(),l=t+c,f=l-o;return{version:s,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(e,t){let[n,s]=E6(e,t),i=r.decode(s);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ti(i).set(n,e),i}};function E6(r,e){switch(r[0]){case"Q":{let t=e??ge;return[ge.prefix,t.decode(`${ge.prefix}${r}`)]}case ge.prefix:{let t=e??ge;return[ge.prefix,t.decode(r)]}case mt.prefix:{let t=e??mt;return[mt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function x6(r,e,t){let{prefix:n}=t;if(n!==ge.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let s=e.get(n);if(s==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return s}function A6(r,e,t){let{prefix:n}=t,s=e.get(n);if(s==null){let i=t.encode(r);return e.set(n,i),i}else return s}var fn=112,B6=18;function W2(r,e,t){let n=Br(r),s=n+Br(e),i=new Uint8Array(s+t.byteLength);return Ar(r,i,0),Ar(e,i,n),i.set(t,s),i}var I6=Symbol.for("@ipld/js-cid/CID");var Kt={...Ii,...bi,...Bi,...mi,...yi,...vi,...Ei,...xi,...Ai,...wi},B9={..._i,...Ri};function Q2(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Z2=Q2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Li=Q2("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=be(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),S6={utf8:Z2,"utf-8":Z2,hex:Kt.base16,latin1:Li,ascii:Li,binary:Li,...Kt},Yn=S6;function z(r,e="utf8"){let t=Yn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?rt(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function Pi(r){let e=r??8192,t=e>>>1,n,s=e;return function(o){if(o<1||o>t)return be(o);s+o>e&&(n=be(e),s=0);let a=n.subarray(s,s+=o);return s&7&&(s=(s|7)+1),a}}var or=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ci(){}var Ui=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},R6=Pi();function k6(r){return globalThis.Buffer!=null?be(r):R6(r)}var dn=class{len;head;tail;states;constructor(){this.len=0,this.head=new or(Ci,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new or(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Oi((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Wn,10,De.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=De.fromBigInt(e);return this._push(Wn,t.length(),t)}uint64Number(e){return this._push(ii,he(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=De.fromBigInt(e).zzEncode();return this._push(Wn,t.length(),t)}sint64Number(e){let t=De.fromNumber(e).zzEncode();return this._push(Wn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Di,1,e?1:0)}fixed32(e){return this._push(hn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=De.fromBigInt(e);return this._push(hn,4,t.lo)._push(hn,4,t.hi)}fixed64Number(e){let t=De.fromNumber(e);return this._push(hn,4,t.lo)._push(hn,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(B2,4,e)}double(e){return this._push(S2,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Di,1,0):this.uint32(t)._push(_6,t,e)}string(e){let t=N2(e);return t!==0?this.uint32(t)._push(li,t,e):this._push(Di,1,0)}fork(){return this.states=new Ui(this),this.head=this.tail=new or(Ci,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 or(Ci,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=k6(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Di(r,e,t){e[t]=r&255}function N6(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Oi=class extends or{next;constructor(e,t){super(N6,e,t),this.next=void 0}};function Wn(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function hn(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function _6(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(dn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(T6,e,r),this},dn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(L6,e,r),this});function T6(r,e,t){e.set(r,t)}function L6(r,e,t){r.length<40?li(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(z(r),t)}function Vi(){return new dn}function it(r,e){let t=Vi();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Sr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Sr||(Sr={}));function Zn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Rr(r){function e(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let t=function(i,o){let a=e(i);o.int32(a)},n=function(i){let o=i.int32();return e(o)};return Zn("enum",Sr.VARINT,t,n)}function ot(r,e){return Zn("message",Sr.LENGTH_DELIMITED,r,e)}var pn=class extends Error{code;constructor(e,t,n){super(e,n),this.code=t}};var X2;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.key!=null&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&(n.uint32(18),n.bytes(t.value)),t.author!=null&&(n.uint32(26),n.bytes(t.author)),t.signature!=null&&(n.uint32(34),n.bytes(t.signature)),t.timeReceived!=null&&(n.uint32(42),n.string(t.timeReceived)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:{s.key=t.bytes();break}case 2:{s.value=t.bytes();break}case 3:{s.author=t.bytes();break}case 4:{s.signature=t.bytes();break}case 5:{s.timeReceived=t.string();break}default:{t.skipType(o&7);break}}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(X2||(X2={}));var F;(function(r){r.PUT_VALUE="PUT_VALUE",r.GET_VALUE="GET_VALUE",r.ADD_PROVIDER="ADD_PROVIDER",r.GET_PROVIDERS="GET_PROVIDERS",r.FIND_NODE="FIND_NODE",r.PING="PING"})(F||(F={}));var Qn;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(Qn||(Qn={}));(function(r){r.codec=()=>Rr(Qn)})(F||(F={}));var Nr;(function(r){r.NOT_CONNECTED="NOT_CONNECTED",r.CONNECTED="CONNECTED",r.CAN_CONNECT="CAN_CONNECT",r.CANNOT_CONNECT="CANNOT_CONNECT"})(Nr||(Nr={}));var Fi;(function(r){r[r.NOT_CONNECTED=0]="NOT_CONNECTED",r[r.CONNECTED=1]="CONNECTED",r[r.CAN_CONNECT=2]="CAN_CONNECT",r[r.CANNOT_CONNECT=3]="CANNOT_CONNECT"})(Fi||(Fi={}));(function(r){r.codec=()=>Rr(Fi)})(Nr||(Nr={}));var kr;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),t.id!=null&&t.id.byteLength>0&&(n.uint32(10),n.bytes(t.id)),t.multiaddrs!=null)for(let i of t.multiaddrs)n.uint32(18),n.bytes(i);t.connection!=null&&(n.uint32(24),Nr.codec().encode(t.connection,n)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={id:ze(0),multiaddrs:[]},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:{s.id=t.bytes();break}case 2:{s.multiaddrs.push(t.bytes());break}case 3:{s.connection=Nr.codec().decode(t);break}default:{t.skipType(o&7);break}}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(kr||(kr={}));var He;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),t.type!=null&&Qn[t.type]!==0&&(n.uint32(8),F.codec().encode(t.type,n)),t.clusterLevel!=null&&(n.uint32(80),n.int32(t.clusterLevel)),t.key!=null&&(n.uint32(18),n.bytes(t.key)),t.record!=null&&(n.uint32(26),n.bytes(t.record)),t.closer!=null)for(let i of t.closer)n.uint32(66),kr.codec().encode(i,n);if(t.providers!=null)for(let i of t.providers)n.uint32(74),kr.codec().encode(i,n);s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={type:F.PUT_VALUE,closer:[],providers:[]},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:{s.type=F.codec().decode(t);break}case 10:{s.clusterLevel=t.int32();break}case 2:{s.key=t.bytes();break}case 3:{s.record=t.bytes();break}case 8:{s.closer.push(kr.codec().decode(t,t.uint32()));break}case 9:{s.providers.push(kr.codec().decode(t,t.uint32()));break}default:{t.skipType(o&7);break}}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(He||(He={}));function Mi(r,e={}){let t={...r,name:"SEND_QUERY",type:0,messageName:r.type,messageType:F[r.type]};return e.onProgress?.(new Ne("kad-dht:query:send-query",{detail:t})),t}function gn(r,e={}){let t={...r,name:"PEER_RESPONSE",type:1,messageName:r.messageType,closer:r.closer!=null?r.closer:[],providers:r.providers!=null?r.providers:[]};return e.onProgress?.(new Ne("kad-dht:query:peer-response",{detail:t})),t}function Xn(r,e={}){let t={...r,name:"FINAL_PEER",type:2};return e.onProgress?.(new Ne("kad-dht:query:final-peer",{detail:t})),t}function Ue(r,e={}){let t={...r,name:"QUERY_ERROR",type:3};return e.onProgress?.(new Ne("kad-dht:query:query-error",{detail:t})),t}function Hi(r,e={}){let t={...r,name:"PROVIDER",type:4};return e.onProgress?.(new Ne("kad-dht:query:provider",{detail:t})),t}function mn(r,e={}){let t={...r,name:"VALUE",type:5};return e.onProgress?.(new Ne("kad-dht:query:value",{detail:t})),t}function Ki(r,e={}){let t={...r,name:"DIAL_PEER",type:7};return e.onProgress?.(new Ne("kad-dht:query:dial-peer",{detail:t})),t}var yn;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.key!=null&&t.key.byteLength>0&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&t.value.byteLength>0&&(n.uint32(18),n.bytes(t.value)),t.timeReceived!=null&&t.timeReceived!==""&&(n.uint32(42),n.string(t.timeReceived)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={key:new Uint8Array(0),value:new Uint8Array(0),timeReceived:""},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:s.key=t.bytes();break;case 2:s.value=t.bytes();break;case 5:s.timeReceived=t.string();break;default:t.skipType(o&7);break}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(yn||(yn={}));function J2(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0"),s=String(r.getUTCHours()).padStart(2,"0"),i=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${s}:${i}:${o}.${c}Z`}function e0(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),s=parseInt(t[2],10)-1,i=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),l=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,s,i,o,a,c,l))}var me=class r{key;value;timeReceived;constructor(e,t,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=n}serialize(){return yn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:J2(this.timeReceived)}}static deserialize(e){let t=yn.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=e0(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new r(e.key,e.value,t)}};function L(r,e="utf8"){let t=Yn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function t0(r,e,t){if(t.length===0){let o="No records given";throw new E(o,"ERR_NO_RECORDS_RECEIVED")}let s=L(e).split("/");if(s.length<3){let o="Record key does not have a selector function";throw new E(o,"ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY")}let i=r[s[1].toString()];if(i==null){let o=`No selector function configured for key type "${s[1]}"`;throw new E(o,"ERR_UNRECOGNIZED_KEY_PREFIX")}return t.length===1?0:i(e,t)}function C6(r,e){return 0}var r0={pk:C6};async function _r(r,e){let t=e.key,s=L(t).split("/");if(s.length<3)return;let i=r[s[1].toString()];if(i==null){let o=`No validator available for key type "${s[1]}"`;throw new E(o,"ERR_INVALID_RECORD_KEY_TYPE")}await i(t,e.value)}var D6=async(r,e)=>{if(!(r instanceof Uint8Array))throw new E('"key" must be a Uint8Array',"ERR_INVALID_RECORD_KEY_NOT_BUFFER");if(r.byteLength<5)throw new E("invalid public key record","ERR_INVALID_RECORD_KEY_TOO_SHORT");if(L(r.subarray(0,4))!=="/pk/")throw new E("key was not prefixed with /pk/","ERR_INVALID_RECORD_KEY_BAD_PREFIX");let n=r.slice(4),s=await ne.digest(e);if(!Q(n,s.bytes))throw new E("public key does not match passed in key","ERR_INVALID_RECORD_HASH_MISMATCH")},n0={pk:D6};var U6=Symbol.for("nodejs.util.inspect.custom"),s0=Object.values(Kt).map(r=>r.decoder).reduce((r,e)=>r.or(e),Kt.identity.decoder),i0=114,qi=36,$i=37,bn=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[y2]=!0;toString(){return this.string==null&&(this.string=ge.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return _e.createV1(i0,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Q(this.multihash.bytes,e);if(typeof e=="string")return ar(e).equals(this);if(e?.multihash?.bytes!=null)return Q(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[U6](){return`PeerId(${this.toString()})`}},Tr=class extends bn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Lr=class extends bn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Pr=class extends bn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function ar(r,e){if(e=e??s0,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=sr(ge.decode(`z${r}`));return r.startsWith("12D")?new Lr({multihash:t}):r.startsWith("16U")?new Pr({multihash:t}):new Tr({multihash:t})}return yt(s0.decode(r))}function yt(r){try{let e=sr(r);if(e.code===Ht.code){if(e.digest.length===qi)return new Lr({multihash:e});if(e.digest.length===$i)return new Pr({multihash:e})}if(e.code===ne.code)return new Tr({multihash:e})}catch{return O6(_e.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function O6(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==i0)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===ne.code)return new Tr({multihash:r.multihash});if(e.code===Ht.code){if(e.digest.length===qi)return new Lr({multihash:r.multihash});if(e.digest.length===$i)return new Pr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function o0(r,e){return r.length===qi?new Lr({multihash:st(Ht.code,r),privateKey:e}):r.length===$i?new Pr({multihash:st(Ht.code,r),privateKey:e}):new Tr({multihash:await ne.digest(r),publicKey:r,privateKey:e})}var Jn=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,s){return this.readAtomically(()=>{let i=0,o=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*s)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let h=Number.parseInt(u,e);if(!Number.isNaN(h))return h});if(f===void 0)break;if(i*=e,i+=f,i>l||(o+=1,t!==void 0&&o>t))return}if(o!==0)return!n&&c&&o>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let s=n*2;if(n<t.length-3){let o=this.readSeparator(":",n,()=>this.readIPv4Addr());if(o!==void 0)return t[s]=o[0],t[s+1]=o[1],t[s+2]=o[2],t[s+3]=o[3],[s+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[s,!1];t[s]=i>>8,t[s+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,s]=e(t);if(n===16)return t;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),o=16-(n+2),[a]=e(i.subarray(0,o));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var a0=45,V6=15,Cr=new Jn;function zi(r){if(!(r.length>V6))return Cr.new(r).parseWith(()=>Cr.readIPv4Addr())}function Gi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>a0))return Cr.new(r).parseWith(()=>Cr.readIPv6Addr())}function e1(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>a0))return Cr.new(r).parseWith(()=>Cr.readIPAddr())}function t1(r){return!!zi(r)}function r1(r){return!!Gi(r)}function n1(r){return!!e1(r)}var l0=on(c0(),1),F6=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],M6=F6.map(r=>new l0.Netmask(r));function H6(r){for(let e of M6)if(e.contains(r))return!0;return!1}function K6(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function s1(r){return t1(r)?H6(r):r1(r)?K6(r):void 0}var bt="/",u0=new TextEncoder().encode(bt),i1=u0[0],Dr=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=z(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==i1)throw new Error("Invalid key")}toString(e="utf8"){return L(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(bt))}static random(){return new r(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new r(e):typeof e.uint8Array=="function"?new r(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=u0),this._buf[0]!==i1){let e=new Uint8Array(this._buf.byteLength+1);e.fill(i1,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===i1;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let s=0;s<t.length;s++){if(n.length<s+1)return!1;let i=t[s],o=n[s];if(i<o)return!0;if(i>o)return!1}return t.length<n.length}reverse(){return r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(bt).slice(1)}type(){return q6(this.baseNamespace())}name(){return $6(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(bt)||(e+=bt),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(bt):new r(e.slice(0,-1).join(bt))}child(e){return this.toString()===bt?e:e.toString()===bt?this:new r(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return r.withNamespaces([...this.namespaces(),...z6(e.map(t=>t.namespaces()))])}};function q6(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function $6(r){let e=r.split(":");return e[e.length-1]}function z6(r){return[].concat(...r)}function J(r,e){if(globalThis.Buffer!=null)return rt(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((s,i)=>s+i.length,0));let t=be(e),n=0;for(let s of r)t.set(s,n),n+=s.length;return rt(t)}var G6=z("/pk/");function o1(r){return{...r,multiaddrs:r.multiaddrs.filter(e=>{let[[t,n]]=e.stringTuples();if(t===53||t===54||t===55)return n!=="localhost";if(t!==4&&t!==6||n==null)return!1;let s=s1(n);return s==null?!0:!s})}}function f0(r){return{...r,multiaddrs:r.multiaddrs.filter(e=>{let[[t,n]]=e.stringTuples();if(n==="localhost")return!0;if(t!==4&&t!==6||n==null)return!1;let s=s1(n);return s??!1})}}function h0(r){return r}async function qt(r){return(await ne.digest(r)).digest}async function je(r){return qt(r.toBytes())}function wt(r){return new Dr(`${v2}/${L(r,"base32")}`,!1)}function d0(r){return J([G6,r.toBytes()])}function p0(r){return L(r.subarray(0,4))==="/pk/"}function g0(r){return yt(r.subarray(4))}function ji(r,e){let t=new Date;return new me(r,e,t).serialize()}function m0(r,e=100){let t;return()=>{clearTimeout(t),t=setTimeout(()=>{r()},e)}}var j6=290,Y6=54,W6=55,Z6=56,Q6=4,X6=41;function y0(r){let e=r.stringTuples();for(let t of e)if(t[0]===j6)return!1;if(e[0][0]===Y6||e[0][0]===W6||e[0][0]===Z6)return!0;if(e[0][0]===Q6||e[0][0]===X6){let t=s1(`${e[0][1]}`);return t==null||!t}return!1}var a1=class{log;components;validators;selectors;peerRouting;queryManager;network;constructor(e,t){let{validators:n,selectors:s,peerRouting:i,queryManager:o,network:a,logPrefix:c}=t;this.components=e,this.log=e.logger.forComponent(`${c}:content-fetching`),this.validators=n,this.selectors=s,this.peerRouting=i,this.queryManager=o,this.network=a}async putLocal(e,t){let n=wt(e);await this.components.datastore.put(n,t)}async getLocal(e){this.log("getLocal %b",e);let t=wt(e);this.log("fetching record for key %k",t);let n=await this.components.datastore.get(t);this.log("found %k in local datastore",t);let s=me.deserialize(n);return await _r(this.validators,s),s}async*sendCorrectionRecord(e,t,n,s={}){this.log("sendCorrection for %b",e);let i=ji(e,n);for(let{value:o,from:a}of t){if(Q(o,n)){this.log("record was ok");continue}if(this.components.peerId.equals(a)){try{let f=wt(e);this.log(`Storing corrected record for key ${f.toString()}`),await this.components.datastore.put(f,i.subarray())}catch(f){this.log.error("Failed error correcting self",f)}continue}let c=!1,l={type:F.PUT_VALUE,key:e,record:i};for await(let f of this.network.sendRequest(a,l,s))f.name==="PEER_RESPONSE"&&f.record!=null&&Q(f.record.value,me.deserialize(i).value)&&(c=!0),yield f;c||(yield Ue({from:a,error:new E("value not put correctly","ERR_PUT_VALUE_INVALID")},s)),this.log.error("Failed error correcting entry")}}async*put(e,t,n={}){this.log("put key %b value %b",e,t);let s=ji(e,t),i=wt(e);this.log(`storing record for key ${i.toString()}`),await this.components.datastore.put(i,s.subarray()),yield*Vt(this.peerRouting.getClosestPeers(e,{signal:n.signal}),o=>Kn(o,a=>async()=>{if(a.name!=="FINAL_PEER")return[a];let c=[],l={type:F.PUT_VALUE,key:e,record:s};this.log("send put to %p",a.peer.id);for await(let f of this.network.sendRequest(a.peer.id,l,n))c.push(f),f.name==="PEER_RESPONSE"&&(f.record!=null&&Q(f.record.value,me.deserialize(s).value)||c.push(Ue({from:a.peer.id,error:new E("value not put correctly","ERR_PUT_VALUE_INVALID")},n)));return c}),o=>an(o,{ordered:!1,concurrency:3}),async function*(o){for await(let a of o)yield*a})}async*get(e,t={}){this.log("get %b",e);let n=[];for await(let a of this.getMany(e,t))a.name==="VALUE"&&n.push(a),yield a;if(n.length===0)return;let s=n.map(a=>a.value),i=0;try{i=t0(this.selectors,e,s)}catch(a){if(a.code!=="ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY")throw a}let o=s[i];if(this.log("GetValue %b %b",e,o),o==null)throw new E("best value was not found","ERR_NOT_FOUND");yield*this.sendCorrectionRecord(e,n,o,t),yield n[i]}async*getMany(e,t={}){this.log("getMany values for %b",e);try{let i=await this.getLocal(e);yield mn({value:i.value,from:this.components.peerId},t)}catch(i){this.log("error getting local value for %b",e,i)}let n=this,s=async function*({peer:i,signal:o}){for await(let a of n.peerRouting.getValueOrPeers(i,e,{signal:o}))yield a,a.name==="PEER_RESPONSE"&&a.record!=null&&(yield mn({from:i,value:a.record.value},t))};yield*this.queryManager.run(e,s,t)}};function Zi(r,e){let t={[Symbol.iterator]:()=>t,next:()=>{let n=r.next(),s=n.value;return n.done===!0||s==null?{done:!0,value:void 0}:{done:!1,value:e(s)}}};return t}var at=class r{set;constructor(e){if(this.set=new Set,e!=null)for(let t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return Zi(this.set.entries(),e=>{let t=ar(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let n=ar(t);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return Zi(this.set.values(),e=>ar(e))}intersection(e){let t=new r;for(let n of e)this.has(n)&&t.add(n);return t}difference(e){let t=new r;for(let n of this)e.has(n)||t.add(n);return t}union(e){let t=new r;for(let n of e)t.add(n);for(let n of this)t.add(n);return t}};var Au=parseInt("0xFFFF",16),Bu=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var v0=t1,n8=r1,Qi=function(r){let e=0;if(r=r.toString().trim(),v0(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(n8(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=v0(t[n]),o;i&&(o=Qi(t[n]),t[n]=L(o.slice(0,2),"base16")),o!=null&&++n<8&&t.splice(n,0,L(o.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let s=new Uint8Array(e+16);for(n=0;n<t.length;n++){let i=parseInt(t[n],16);s[e++]=i>>8&255,s[e++]=i&255}return s}throw new Error("invalid ip address")},E0=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let s=[];for(let i=0;i<t;i++)s.push(r[e+i]);return s.join(".")}if(t===16){let s=[];for(let i=0;i<t;i+=2)s.push(n.getUint16(e+i).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ur={},Xi={},i8=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];i8.forEach(r=>{let e=o8(...r);Xi[e.code]=e,Ur[e.name]=e});function o8(r,e,t,n,s){return{code:r,size:e,name:t,resolvable:!!n,path:!!s}}function W(r){if(typeof r=="number"){if(Xi[r]!=null)return Xi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ur[r]!=null)return Ur[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var of=W("ip4"),af=W("ip6"),cf=W("ipcidr");function eo(r,e){switch(W(r).code){case 4:case 41:return c8(e);case 42:return B0(e);case 6:case 273:case 33:case 132:return S0(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return B0(e);case 421:return h8(e);case 444:return I0(e);case 445:return I0(e);case 466:return f8(e);default:return L(e,"base16")}}function to(r,e){switch(W(r).code){case 4:return x0(e);case 41:return x0(e);case 42:return A0(e);case 6:case 273:case 33:case 132:return ro(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return A0(e);case 421:return l8(e);case 444:return d8(e);case 445:return p8(e);case 466:return u8(e);default:return z(e,"base16")}}var Ji=Object.values(Kt).map(r=>r.decoder),a8=function(){let r=Ji[0].or(Ji[1]);return Ji.slice(2).forEach(e=>r=r.or(e)),r}();function x0(r){if(!n1(r))throw new Error("invalid ip address");return Qi(r)}function c8(r){let e=E0(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!n1(e))throw new Error("invalid ip address");return e}function ro(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function S0(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function A0(r){let e=z(r),t=Uint8Array.from(Me(e.length));return J([t,e],t.length+e.length)}function B0(r){let e=Ce(r);if(r=r.slice(he(e)),r.length!==e)throw new Error("inconsistent lengths");return L(r)}function l8(r){let e;r[0]==="Q"||r[0]==="1"?e=sr(ge.decode(`z${r}`)).bytes:e=_e.parse(r).multihash.bytes;let t=Uint8Array.from(Me(e.length));return J([t,e],t.length+e.length)}function u8(r){let e=a8.decode(r),t=Uint8Array.from(Me(e.length));return J([t,e],t.length+e.length)}function f8(r){let e=Ce(r),t=r.slice(he(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+L(t,"base64url")}function h8(r){let e=Ce(r),t=r.slice(he(e));if(t.length!==e)throw new Error("inconsistent lengths");return L(t,"base58btc")}function d8(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=mt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ro(n);return J([t,s],t.length+s.length)}function p8(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=mt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ro(n);return J([t,s],t.length+s.length)}function I0(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=L(e,"base32"),s=S0(t);return`${n}:${s}`}function R0(r){r=no(r);let e=[],t=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<s.length;i++){let o=s[i],a=W(o);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=s.length)throw N0("invalid address: "+r);if(a.path===!0){n=no(s.slice(i).join("/")),e.push([a.code,to(a.code,n)]),t.push([a.code,n]);break}let c=to(a.code,s[i]);e.push([a.code,c]),t.push([a.code,eo(a.code,c)])}return{string:k0(t),bytes:io(e),tuples:e,stringTuples:t,path:n}}function so(r){let e=[],t=[],n=null,s=0;for(;s<r.length;){let i=Ce(r,s),o=he(i),a=W(i),c=g8(a,r.slice(s+o));if(c===0){e.push([i]),t.push([i]),s+=o;continue}let l=r.slice(s+o,s+o+c);if(s+=c+o,s>r.length)throw N0("Invalid address Uint8Array: "+L(r,"base16"));e.push([i,l]);let f=eo(i,l);if(t.push([i,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:k0(t),tuples:e,stringTuples:t,path:n}}function k0(r){let e=[];return r.map(t=>{let n=W(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),no(e.join("/"))}function io(r){return J(r.map(e=>{let t=W(e[0]),n=Uint8Array.from(Me(t.code));return e.length>1&&e[1]!=null&&(n=J([n,e[1]])),n}))}function g8(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Ce(e instanceof Uint8Array?e:Uint8Array.from(e));return t+he(t)}}function no(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function N0(r){return new Error("Error parsing address: "+r)}var m8=Symbol.for("nodejs.util.inspect.custom"),oo=Symbol.for("@multiformats/js-multiaddr/multiaddr"),y8=[W("dns").code,W("dns4").code,W("dns6").code,W("dnsaddr").code],c1=class r{bytes;#e;#r;#i;#a;[oo]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=so(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=R0(e)}else if(T0(e))t=so(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#i=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,s,i="",o=W("tcp"),a=W("udp"),c=W("ip4"),l=W("ip6"),f=W("dns6"),u=W("ip6zone");for(let[m,p]of this.stringTuples())m===u.code&&(i=`%${p??""}`),y8.includes(m)&&(t=o.name,s=443,n=`${p??""}${i}`,e=m===f.code?6:4),(m===o.code||m===a.code)&&(t=W(m).name,s=parseInt(p??"")),(m===c.code||m===l.code)&&(t=W(m).name,n=`${p??""}${i}`,e=m===l.code?6:4);if(e==null||t==null||n==null||s==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:s}}protos(){return this.#r.map(([e])=>Object.assign({},W(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>W(e).name)}tuples(){return this.#r}stringTuples(){return this.#i}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),s=n.lastIndexOf(t);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,s))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(io(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,s])=>{n===Ur.p2p.code&&e.push([n,s]),n===Ur["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?L(ge.decode(`z${n}`),"base58btc"):L(_e.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return Q(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=_0.get(t.name);if(n==null)throw new E(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(i=>new r(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[m8](){return`Multiaddr(${this.#e})`}};var _0=new Map;function T0(r){return!!r?.[oo]}function vn(r){return new c1(r)}function L0(r,e){return{id:r.id.toBytes(),multiaddrs:(r.multiaddrs??[]).map(n=>n.bytes),connection:e}}function En(r){if(r.id==null)throw new Error("Invalid peer in message");return{id:yt(r.id),multiaddrs:(r.multiaddrs??[]).map(e=>vn(e))}}var l1=class{log;components;network;peerRouting;queryManager;routingTable;providers;constructor(e,t){let{network:n,peerRouting:s,queryManager:i,routingTable:o,providers:a,logPrefix:c}=t;this.components=e,this.log=e.logger.forComponent(`${c}:content-routing`),this.network=n,this.peerRouting=s,this.queryManager=i,this.routingTable=o,this.providers=a}async*provide(e,t,n={}){this.log("provide %s",e),await this.providers.addProvider(e,this.components.peerId);let s={type:F.ADD_PROVIDER,key:e.multihash.bytes,providers:[L0({id:this.components.peerId,multiaddrs:t})]},i=0,o=a=>async()=>{if(a.name!=="FINAL_PEER")return[a];let c=[];this.log("putProvider %s to %p",e,a.peer.id);try{this.log("sending provider record for %s to %p",e,a.peer.id);for await(let l of this.network.sendMessage(a.peer.id,s,n))l.name==="PEER_RESPONSE"&&(this.log("sent provider record for %s to %p",e,a.peer.id),i++),c.push(l)}catch(l){this.log.error("error sending provide record to peer %p",a.peer.id,l),c.push(Ue({from:a.peer.id,error:l},n))}return c};yield*Vt(this.peerRouting.getClosestPeers(e.multihash.bytes,n),a=>Kn(a,c=>o(c)),a=>an(a,{ordered:!1,concurrency:3}),async function*(a){for await(let c of a)yield*c}),this.log("sent provider records to %d peers",i)}async*findProviders(e,t){let n=this.routingTable.kBucketSize,s=e.multihash.bytes,i=this;this.log("findProviders %c",e);let o=await this.providers.getProviders(e);if(o.length>0){let l=[];for(let f of o.slice(0,n))try{let u=await this.components.peerStore.get(f);l.push({id:f,multiaddrs:u.addresses.map(({multiaddr:h})=>h)})}catch(u){if(u.code!=="ERR_NOT_FOUND")throw u;this.log("no peer store entry for %p",f)}yield gn({from:this.components.peerId,messageType:F.GET_PROVIDERS,providers:l},t),yield Hi({from:this.components.peerId,providers:l},t)}if(o.length>=n)return;let a=async function*({peer:l,signal:f}){let u={type:F.GET_PROVIDERS,key:s};yield*i.network.sendRequest(l,u,{...t,signal:f})},c=new at(o);for await(let l of this.queryManager.run(s,a,t))if(yield l,l.name==="PEER_RESPONSE"){this.log("Found %d provider entries for %c and %d closer peers",l.providers.length,e,l.closer.length);let f=[];for(let u of l.providers)c.has(u.id)||(c.add(u.id),f.push(u));if(f.length>0&&(yield Hi({from:l.from,providers:f},t)),c.size===n)return}}};var C0=Symbol.for("@achingbrain/uint8arraylist");function P0(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let s=t+n.byteLength;if(e<s)return{buf:n,index:e-t};t=s}throw new RangeError("index is out of bounds")}function u1(r){return!!r?.[C0]}var Oe=class r{bufs;length;[C0]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(u1(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(u1(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=P0(this.bufs,e);return t.buf[t.index]}set(e,t){let n=P0(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(u1(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:s}=this._subList(e,t);return J(n,s)}subarray(e,t){let{bufs:n,length:s}=this._subList(e,t);return n.length===1?n[0]:J(n,s)}sublist(e,t){let{bufs:n,length:s}=this._subList(e,t),i=new r;return i.length=s,i.bufs=[...n],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let i=0;i<this.bufs.length;i++){let o=this.bufs[i],a=s,c=a+o.byteLength;if(s=c,e>=c)continue;let l=e>=a&&e<c,f=t>a&&t<=c;if(l&&f){if(e===a&&t===c){n.push(o);break}let u=e-a;n.push(o.subarray(u,u+(t-e)));break}if(l){if(e===0){n.push(o);continue}n.push(o.subarray(e-a));continue}if(f){if(t===c){n.push(o);break}n.push(o.subarray(0,t-a));break}n.push(o)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!u1(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let s=n.byteLength;if(s===0)throw new TypeError("search must be at least 1 byte long");let i=256,o=new Int32Array(i);for(let u=0;u<i;u++)o[u]=-1;for(let u=0;u<s;u++)o[n[u]]=u;let a=o,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let u=t;u<=c;u+=f){f=0;for(let h=l;h>=0;h--){let m=this.get(u+h);if(n[h]!==m){f=Math.max(1,h-a[m]);break}}if(f===0)return u}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=be(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let s=ze(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,t,n),this.write(s,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let s=ze(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,t,n),this.write(s,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let s=ze(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,t,n),this.write(s,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=be(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let s=ze(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,t,n),this.write(s,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let s=ze(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,t,n),this.write(s,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let s=ze(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,t,n),this.write(s,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let s=ze(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,t,n),this.write(s,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let s=ze(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,t,n),this.write(s,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Q(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((s,i)=>s+i.byteLength,0)),n.length=t,n}};var f1=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.name="AbortError",this.code=t??"ABORT_ERR"}};async function Or(r,e,t){if(e==null)return r;if(e.aborted)return Promise.reject(new f1(t?.errorMessage,t?.errorCode));let n,s=new f1(t?.errorMessage,t?.errorCode);try{return await Promise.race([r,new Promise((i,o)=>{n=()=>{o(s)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var ao=class{needNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.needNext=fe(),this.haveNext=fe()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("Have next but next was undefined");let e=this.nextResult;return this.nextResult=void 0,this.needNext.resolve(),this.needNext=fe(),e}async throw(e){return this.ended=!0,e!=null&&this.haveNext.reject(e),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return await this._push(void 0),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");this.nextResult!=null&&await this.needNext.promise,e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=fe(),await Or(this.needNext.promise,t?.signal,t)}};function D0(){return new ao}var h1=class extends Error{code;constructor(e,t){super(e),this.code=t}},co=class extends h1{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted"}};function U0(r,e){let t=D0();r.sink(t).catch(async o=>{await t.end(o)}),r.sink=async o=>{for await(let a of o)await t.push(a);await t.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let s=new Oe;return{read:async(o,a)=>{a?.signal?.throwIfAborted();let c,l=new Promise((f,u)=>{c=()=>{u(new co("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(o==null){let{done:u,value:h}=await Promise.race([n.next(),l]);return u===!0?new Oe:h}for(;s.byteLength<o;){let{value:u,done:h}=await Promise.race([n.next(),l]);if(h===!0)throw new h1("unexpected end of input","ERR_UNEXPECTED_EOF");s.append(u)}let f=s.sublist(0,o);return s.consume(o),f}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(o,a)=>{a?.signal?.throwIfAborted(),o instanceof Uint8Array?await t.push(o,a):await t.push(o.subarray(),a)},unwrap:()=>{if(s.byteLength>0){let o=r.source;r.source=async function*(){e?.yieldBytes===!1?yield s:yield*s,yield*o}()}return r}}}var d1=class extends Error{code;constructor(e,t){super(e),this.code=t}};function O0(r,e={}){let t=U0(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=he(e.maxDataLength));let n=e?.lengthDecoder??Ce,s=e?.lengthEncoder??Me;return{read:async o=>{let a=-1,c=new Oe;for(;;){c.append(await t.read(1,o));try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new d1("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new d1("message length too long","ERR_MSG_DATA_TOO_LONG");return t.read(a,o)},write:async(o,a)=>{await t.write(new Oe(s(o.byteLength),o),a)},writeV:async(o,a)=>{let c=new Oe(...o.flatMap(l=>[s(l.byteLength),l]));await t.write(c,a)},unwrap:()=>t.unwrap()}}function xn(r,e){let t=O0(r,e),n={read:async(s,i)=>{let o=await t.read(i);return s.decode(o)},write:async(s,i,o)=>{await t.write(i.encode(s),o)},writeV:async(s,i,o)=>{await t.writeV(s.map(a=>i.encode(a)),o)},pb:s=>({read:async i=>n.read(s,i),write:async(i,o)=>n.write(i,s,o),writeV:async(i,o)=>n.writeV(i,s,o),unwrap:()=>n}),unwrap:()=>t.unwrap()};return n}var p1=class extends Be{log;protocol;running;components;constructor(e,t){super();let{protocol:n}=t;this.components=e,this.log=e.logger.forComponent(`${t.logPrefix}:network`),this.running=!1,this.protocol=n}async start(){this.running||(this.running=!0)}async stop(){this.running=!1}isStarted(){return this.running}async*sendRequest(e,t,n={}){if(!this.running)return;let s=t.type;if(s==null)throw new pn("Message type was missing","ERR_INVALID_PARAMETERS");this.log("sending %s to %p",t.type,e),yield Ki({peer:e},n),yield Mi({to:e,type:s},n);let i;try{let a=await(await this.components.connectionManager.openConnection(e,n)).newStream(this.protocol,n),c=await this._writeReadMessage(a,t,n);yield gn({from:e,messageType:c.type,closer:c.closer.map(En),providers:c.providers.map(En),record:c.record==null?void 0:me.deserialize(c.record)},n)}catch(o){this.log.error("could not send %s to %p",t.type,e,o),yield Ue({from:e,error:o},n)}finally{i!=null&&await i.close()}}async*sendMessage(e,t,n={}){if(!this.running)return;let s=t.type;if(s==null)throw new pn("Message type was missing","ERR_INVALID_PARAMETERS");this.log("sending %s to %p",t.type,e),yield Ki({peer:e},n),yield Mi({to:e,type:s},n);let i;try{let a=await(await this.components.connectionManager.openConnection(e,n)).newStream(this.protocol,n);await this._writeMessage(a,t,n),yield gn({from:e,messageType:s},n)}catch(o){yield Ue({from:e,error:o},n)}finally{i!=null&&await i.close()}}async _writeMessage(e,t,n){let s=xn(e);await s.write(t,He,n),await s.unwrap().close(n)}async _writeReadMessage(e,t,n){let s=xn(e);await s.write(t,He,n);let i=await s.read(He,n);return await s.unwrap().close(n),i.closer.forEach(o=>{this.safeDispatchEvent("peer",{detail:En(o)})}),i.providers.forEach(o=>{this.safeDispatchEvent("peer",{detail:En(o)})}),i}};var ee={get(r=globalThis){let e=r.crypto;if(e==null||e.subtle==null)throw Object.assign(new Error("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"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var V0={SHA1:20,SHA256:32,SHA512:64};var b8={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},w8=async(r,e)=>{let t=await ee.get().subtle.sign({name:"HMAC"},r,e);return new Uint8Array(t,0,t.byteLength)};async function F0(r,e){let t=b8[r],n=await ee.get().subtle.importKey("raw",e,{name:"HMAC",hash:{name:t}},!1,["sign"]);return{async digest(s){return w8(n,s)},length:V0[r]}}var ws={};ue(ws,{Ed25519PrivateKey:()=>St,Ed25519PublicKey:()=>fr,MAX_RSA_KEY_SIZE:()=>pr,RsaPrivateKey:()=>Jt,RsaPublicKey:()=>dr,Secp256k1PrivateKey:()=>yr,Secp256k1PublicKey:()=>mr,generateEphemeralKeyPair:()=>g3,generateKeyPair:()=>x7,generateKeyPairFromSeed:()=>A7,importKey:()=>R7,keyStretcher:()=>b3,keysPBM:()=>Yr,marshalPrivateKey:()=>S7,marshalPublicKey:()=>I7,supportedKeys:()=>Ct,unmarshalPrivateKey:()=>B4,unmarshalPublicKey:()=>B7});var No={};ue(No,{Ed25519PrivateKey:()=>St,Ed25519PublicKey:()=>fr,generateKeyPair:()=>_a,generateKeyPairFromSeed:()=>ko,unmarshalEd25519PrivateKey:()=>ka,unmarshalEd25519PublicKey:()=>Na});function lo(r,e){let t=z(r,"base64urlpad");if(e!=null){if(t.length>e)throw new Error("byte array longer than desired length");t=J([new Uint8Array(e-t.length),t])}return t}function Ke(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Vr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function E8(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function uo(r,...e){if(!E8(r))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function g1(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Vr(r.outputLen),Vr(r.blockLen)}function Fr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function M0(r,e){uo(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var m1=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function H0(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Hr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ye=(r,e)=>r<<32-e|r>>>e,x8=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!x8)throw new Error("Non little-endian hardware is not supported");var A8=async()=>{};async function K0(r,e,t){let n=Date.now();for(let s=0;s<r;s++){t(s);let i=Date.now()-n;i>=0&&i<e||(await A8(),n+=i)}}function fo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function $t(r){if(typeof r=="string"&&(r=fo(r)),!H0(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function y1(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];if(!H0(s))throw new Error("Uint8Array expected");e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let i=r[n];t.set(i,s),s+=i.length}return t}var Mr=class{clone(){return this._cloneInto()}},B8={}.toString;function q0(r,e){if(e!==void 0&&B8.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function b1(r){let e=n=>r().update($t(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Kr(r=32){if(m1&&typeof m1.getRandomValues=="function")return m1.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function I8(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),c=n?4:0,l=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+l,a,n)}var qr=class extends Mr{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Hr(this.buffer)}update(e){Fr(this);let{view:t,buffer:n,blockLen:s}=this;e=$t(e);let i=e.length;for(let o=0;o<i;){let a=Math.min(s-this.pos,i-o);if(a===s){let c=Hr(e);for(;s<=i-o;o+=s)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Fr(this),M0(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:s,isLE:i}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(n,0),o=0);for(let u=o;u<s;u++)t[u]=0;I8(n,s-8,BigInt(this.length*8),i),this.process(n,0);let a=Hr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(n),e}};var w1=BigInt(4294967295),ho=BigInt(32);function $0(r,e=!1){return e?{h:Number(r&w1),l:Number(r>>ho&w1)}:{h:Number(r>>ho&w1)|0,l:Number(r&w1)|0}}function S8(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:i,l:o}=$0(r[s],e);[t[s],n[s]]=[i,o]}return[t,n]}var R8=(r,e)=>BigInt(r>>>0)<<ho|BigInt(e>>>0),k8=(r,e,t)=>r>>>t,N8=(r,e,t)=>r<<32-t|e>>>t,_8=(r,e,t)=>r>>>t|e<<32-t,T8=(r,e,t)=>r<<32-t|e>>>t,L8=(r,e,t)=>r<<64-t|e>>>t-32,P8=(r,e,t)=>r>>>t-32|e<<64-t,C8=(r,e)=>e,D8=(r,e)=>r,U8=(r,e,t)=>r<<t|e>>>32-t,O8=(r,e,t)=>e<<t|r>>>32-t,V8=(r,e,t)=>e<<t-32|r>>>64-t,F8=(r,e,t)=>r<<t-32|e>>>64-t;function M8(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var H8=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),K8=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,q8=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),$8=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,z8=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),G8=(r,e,t,n,s,i)=>e+t+n+s+i+(r/2**32|0)|0;var j8={fromBig:$0,split:S8,toBig:R8,shrSH:k8,shrSL:N8,rotrSH:_8,rotrSL:T8,rotrBH:L8,rotrBL:P8,rotr32H:C8,rotr32L:D8,rotlSH:U8,rotlSL:O8,rotlBH:V8,rotlBL:F8,add:M8,add3L:H8,add3H:K8,add4L:q8,add4H:$8,add5H:G8,add5L:z8},D=j8;var[Y8,W8]=D.split(["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(r=>BigInt(r))),zt=new Uint32Array(80),Gt=new Uint32Array(80),po=class extends qr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:s,Ch:i,Cl:o,Dh:a,Dl:c,Eh:l,El:f,Fh:u,Fl:h,Gh:m,Gl:p,Hh:d,Hl:g}=this;return[e,t,n,s,i,o,a,c,l,f,u,h,m,p,d,g]}set(e,t,n,s,i,o,a,c,l,f,u,h,m,p,d,g){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=f|0,this.Fh=u|0,this.Fl=h|0,this.Gh=m|0,this.Gl=p|0,this.Hh=d|0,this.Hl=g|0}process(e,t){for(let b=0;b<16;b++,t+=4)zt[b]=e.getUint32(t),Gt[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){let S=zt[b-15]|0,x=Gt[b-15]|0,I=D.rotrSH(S,x,1)^D.rotrSH(S,x,8)^D.shrSH(S,x,7),N=D.rotrSL(S,x,1)^D.rotrSL(S,x,8)^D.shrSL(S,x,7),T=zt[b-2]|0,G=Gt[b-2]|0,q=D.rotrSH(T,G,19)^D.rotrBH(T,G,61)^D.shrSH(T,G,6),U=D.rotrSL(T,G,19)^D.rotrBL(T,G,61)^D.shrSL(T,G,6),ce=D.add4L(N,U,Gt[b-7],Gt[b-16]),ae=D.add4H(ce,I,q,zt[b-7],zt[b-16]);zt[b]=ae|0,Gt[b]=ce|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:a,Cl:c,Dh:l,Dl:f,Eh:u,El:h,Fh:m,Fl:p,Gh:d,Gl:g,Hh:y,Hl:v}=this;for(let b=0;b<80;b++){let S=D.rotrSH(u,h,14)^D.rotrSH(u,h,18)^D.rotrBH(u,h,41),x=D.rotrSL(u,h,14)^D.rotrSL(u,h,18)^D.rotrBL(u,h,41),I=u&m^~u&d,N=h&p^~h&g,T=D.add5L(v,x,N,W8[b],Gt[b]),G=D.add5H(T,y,S,I,Y8[b],zt[b]),q=T|0,U=D.rotrSH(n,s,28)^D.rotrBH(n,s,34)^D.rotrBH(n,s,39),ce=D.rotrSL(n,s,28)^D.rotrBL(n,s,34)^D.rotrBL(n,s,39),ae=n&i^n&a^i&a,Fe=s&o^s&c^o&c;y=d|0,v=g|0,d=m|0,g=p|0,m=u|0,p=h|0,{h:u,l:h}=D.add(l|0,f|0,G|0,q|0),l=a|0,f=c|0,a=i|0,c=o|0,i=n|0,o=s|0;let A=D.add3L(q,ce,Fe);n=D.add3H(A,G,U,ae),s=A|0}({h:n,l:s}=D.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=D.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=D.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=D.add(this.Dh|0,this.Dl|0,l|0,f|0),{h:u,l:h}=D.add(this.Eh|0,this.El|0,u|0,h|0),{h:m,l:p}=D.add(this.Fh|0,this.Fl|0,m|0,p|0),{h:d,l:g}=D.add(this.Gh|0,this.Gl|0,d|0,g|0),{h:y,l:v}=D.add(this.Hh|0,this.Hl|0,y|0,v|0),this.set(n,s,i,o,a,c,l,f,u,h,m,p,d,g,y,v)}roundClean(){zt.fill(0),Gt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var $r=b1(()=>new po);var E1={};ue(E1,{bitGet:()=>ra,bitLen:()=>ta,bitMask:()=>An,bitSet:()=>na,bytesToHex:()=>Et,bytesToNumberBE:()=>xt,bytesToNumberLE:()=>jt,concatBytes:()=>At,createHmacDrbg:()=>yo,ensureBytes:()=>oe,equalBytes:()=>J8,hexToBytes:()=>cr,hexToNumber:()=>mo,isBytes:()=>We,numberToBytesBE:()=>Yt,numberToBytesLE:()=>lr,numberToHexUnpadded:()=>Y0,numberToVarBytesBE:()=>X8,utf8ToBytes:()=>ea,validateObject:()=>ct});var j0=BigInt(0),v1=BigInt(1),Z8=BigInt(2);function We(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Q8=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Et(r){if(!We(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Q8[r[t]];return e}function Y0(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function mo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var vt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function z0(r){if(r>=vt._0&&r<=vt._9)return r-vt._0;if(r>=vt._A&&r<=vt._F)return r-(vt._A-10);if(r>=vt._a&&r<=vt._f)return r-(vt._a-10)}function cr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){let o=z0(r.charCodeAt(i)),a=z0(r.charCodeAt(i+1));if(o===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[s]=o*16+a}return n}function xt(r){return mo(Et(r))}function jt(r){if(!We(r))throw new Error("Uint8Array expected");return mo(Et(Uint8Array.from(r).reverse()))}function Yt(r,e){return cr(r.toString(16).padStart(e*2,"0"))}function lr(r,e){return Yt(r,e).reverse()}function X8(r){return cr(Y0(r))}function oe(r,e,t){let n;if(typeof e=="string")try{n=cr(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(We(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function At(...r){let e=0;for(let s=0;s<r.length;s++){let i=r[s];if(!We(i))throw new Error("Uint8Array expected");e+=i.length}let t=new Uint8Array(e),n=0;for(let s=0;s<r.length;s++){let i=r[s];t.set(i,n),n+=i.length}return t}function J8(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function ea(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ta(r){let e;for(e=0;r>j0;r>>=v1,e+=1);return e}function ra(r,e){return r>>BigInt(e)&v1}var na=(r,e,t)=>r|(t?v1:j0)<<BigInt(e),An=r=>(Z8<<BigInt(r-1))-v1,go=r=>new Uint8Array(r),G0=r=>Uint8Array.from(r);function yo(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=go(r),s=go(r),i=0,o=()=>{n.fill(1),s.fill(0),i=0},a=(...u)=>t(s,n,...u),c=(u=go())=>{s=a(G0([0]),u),n=a(),u.length!==0&&(s=a(G0([1]),u),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,h=[];for(;u<e;){n=a();let m=n.slice();h.push(m),u+=n.length}return At(...h)};return(u,h)=>{o(),c(u);let m;for(;!(m=h(l()));)c();return o(),m}}var sa={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||We(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ct(r,e,t={}){let n=(s,i,o)=>{let a=sa[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=r[s];if(!(o&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${i}`)};for(let[s,i]of Object.entries(e))n(s,i,!1);for(let[s,i]of Object.entries(t))n(s,i,!0);return r}var ye=BigInt(0),te=BigInt(1),ur=BigInt(2),ia=BigInt(3),bo=BigInt(4),W0=BigInt(5),Z0=BigInt(8),oa=BigInt(9),aa=BigInt(16);function Z(r,e){let t=r%e;return t>=ye?t:e+t}function ca(r,e,t){if(t<=ye||e<ye)throw new Error("Expected power/modulo > 0");if(t===te)return ye;let n=te;for(;e>ye;)e&te&&(n=n*r%t),r=r*r%t,e>>=te;return n}function re(r,e,t){let n=r;for(;e-- >ye;)n*=n,n%=t;return n}function x1(r,e){if(r===ye||e<=ye)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Z(r,e),n=e,s=ye,i=te,o=te,a=ye;for(;t!==ye;){let l=n/t,f=n%t,u=s-o*l,h=i-a*l;n=t,t=f,s=o,i=a,o=u,a=h}if(n!==te)throw new Error("invert: does not exist");return Z(s,e)}function la(r){let e=(r-te)/ur,t,n,s;for(t=r-te,n=0;t%ur===ye;t/=ur,n++);for(s=ur;s<r&&ca(s,e,r)!==r-te;s++);if(n===1){let o=(r+te)/bo;return function(c,l){let f=c.pow(l,o);if(!c.eql(c.sqr(f),l))throw new Error("Cannot find square root");return f}}let i=(t+te)/ur;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,f=a.pow(a.mul(a.ONE,s),t),u=a.pow(c,i),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let m=1;for(let d=a.sqr(h);m<l&&!a.eql(d,a.ONE);m++)d=a.sqr(d);let p=a.pow(f,te<<BigInt(l-m-1));f=a.sqr(p),u=a.mul(u,p),h=a.mul(h,f),l=m}return u}}function ua(r){if(r%bo===ia){let e=(r+te)/bo;return function(n,s){let i=n.pow(s,e);if(!n.eql(n.sqr(i),s))throw new Error("Cannot find square root");return i}}if(r%Z0===W0){let e=(r-W0)/Z0;return function(n,s){let i=n.mul(s,ur),o=n.pow(i,e),a=n.mul(s,o),c=n.mul(n.mul(a,ur),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%aa,la(r)}var Q0=(r,e)=>(Z(r,e)&te)===te,fa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wo(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=fa.reduce((n,s)=>(n[s]="function",n),e);return ct(r,t)}function ha(r,e,t){if(t<ye)throw new Error("Expected power > 0");if(t===ye)return r.ONE;if(t===te)return e;let n=r.ONE,s=e;for(;t>ye;)t&te&&(n=r.mul(n,s)),s=r.sqr(s),t>>=te;return n}function da(r,e){let t=new Array(e.length),n=e.reduce((i,o,a)=>r.is0(o)?i:(t[a]=i,r.mul(i,o)),r.ONE),s=r.inv(n);return e.reduceRight((i,o,a)=>r.is0(o)?i:(t[a]=r.mul(i,t[a]),r.mul(i,o)),s),t}function vo(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function A1(r,e,t=!1,n={}){if(r<=ye)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:i}=vo(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=ua(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:i,MASK:An(s),ZERO:ye,ONE:te,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ye<=c&&c<r},is0:c=>c===ye,isOdd:c=>(c&te)===te,neg:c=>Z(-c,r),eql:(c,l)=>c===l,sqr:c=>Z(c*c,r),add:(c,l)=>Z(c+l,r),sub:(c,l)=>Z(c-l,r),mul:(c,l)=>Z(c*l,r),pow:(c,l)=>ha(a,c,l),div:(c,l)=>Z(c*x1(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>x1(c,r),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>da(a,c),cmov:(c,l,f)=>f?l:c,toBytes:c=>t?lr(c,i):Yt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?jt(c):xt(c)}});return Object.freeze(a)}function X0(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function J0(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Eo(r){let e=J0(r);return e+Math.ceil(e/2)}function e3(r,e,t=!1){let n=r.length,s=J0(e),i=Eo(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let o=t?xt(r):jt(r),a=Z(o,e-te)+te;return t?lr(a,s):Yt(a,s)}var ga=BigInt(0),xo=BigInt(1);function B1(r,e){let t=(s,i)=>{let o=i.negate();return s?o:i},n=s=>{let i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=r.ZERO,a=s;for(;i>ga;)i&xo&&(o=o.add(a)),a=a.double(),i>>=xo;return o},precomputeWindow(s,i){let{windows:o,windowSize:a}=n(i),c=[],l=s,f=l;for(let u=0;u<o;u++){f=l,c.push(f);for(let h=1;h<a;h++)f=f.add(l),c.push(f);l=f.double()}return c},wNAF(s,i,o){let{windows:a,windowSize:c}=n(s),l=r.ZERO,f=r.BASE,u=BigInt(2**s-1),h=2**s,m=BigInt(s);for(let p=0;p<a;p++){let d=p*c,g=Number(o&u);o>>=m,g>c&&(g-=h,o+=xo);let y=d,v=d+Math.abs(g)-1,b=p%2!==0,S=g<0;g===0?f=f.add(t(b,i[y])):l=l.add(t(S,i[v]))}return{p:l,f}},wNAFCached(s,i,o,a){let c=s._WINDOW_SIZE||1,l=i.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&i.set(s,a(l))),this.wNAF(c,l,o)}}}function Bn(r){return wo(r.Fp),ct(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...vo(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ze=BigInt(0),Ve=BigInt(1),I1=BigInt(2),ma=BigInt(8),ya={zip215:!0};function ba(r){let e=Bn(r);return ct(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function S1(r){let e=ba(r),{Fp:t,n,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:c}=e,l=I1<<BigInt(a*8)-Ve,f=t.create,u=e.uvRatio||((B,w)=>{try{return{isValid:!0,value:t.sqrt(B*t.inv(w))}}catch{return{isValid:!1,value:Ze}}}),h=e.adjustScalarBytes||(B=>B),m=e.domain||((B,w,k)=>{if(w.length||k)throw new Error("Contexts/pre-hash are not supported");return B}),p=B=>typeof B=="bigint"&&Ze<B,d=(B,w)=>p(B)&&p(w)&&B<w,g=B=>B===Ze||d(B,l);function y(B,w){if(d(B,w))return B;throw new Error(`Expected valid scalar < ${w}, got ${typeof B} ${B}`)}function v(B){return B===Ze?B:y(B,n)}let b=new Map;function S(B){if(!(B instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(w,k,P,C){if(this.ex=w,this.ey=k,this.ez=P,this.et=C,!g(w))throw new Error("x required");if(!g(k))throw new Error("y required");if(!g(P))throw new Error("z required");if(!g(C))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof x)throw new Error("extended point not allowed");let{x:k,y:P}=w||{};if(!g(k)||!g(P))throw new Error("invalid affine point");return new x(k,P,Ve,f(k*P))}static normalizeZ(w){let k=t.invertBatch(w.map(P=>P.ez));return w.map((P,C)=>P.toAffine(k[C])).map(x.fromAffine)}_setWindowSize(w){this._WINDOW_SIZE=w,b.delete(this)}assertValidity(){let{a:w,d:k}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:P,ey:C,ez:V,et:M}=this,Y=f(P*P),K=f(C*C),$=f(V*V),le=f($*$),se=f(Y*w),ve=f($*f(se+K)),Ee=f(le+f(k*f(Y*K)));if(ve!==Ee)throw new Error("bad point: equation left != right (1)");let pe=f(P*C),Ae=f(V*M);if(pe!==Ae)throw new Error("bad point: equation left != right (2)")}equals(w){S(w);let{ex:k,ey:P,ez:C}=this,{ex:V,ey:M,ez:Y}=w,K=f(k*Y),$=f(V*C),le=f(P*Y),se=f(M*C);return K===$&&le===se}is0(){return this.equals(x.ZERO)}negate(){return new x(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:w}=e,{ex:k,ey:P,ez:C}=this,V=f(k*k),M=f(P*P),Y=f(I1*f(C*C)),K=f(w*V),$=k+P,le=f(f($*$)-V-M),se=K+M,ve=se-Y,Ee=K-M,pe=f(le*ve),Ae=f(se*Ee),dt=f(le*Ee),rr=f(ve*se);return new x(pe,Ae,rr,dt)}add(w){S(w);let{a:k,d:P}=e,{ex:C,ey:V,ez:M,et:Y}=this,{ex:K,ey:$,ez:le,et:se}=w;if(k===BigInt(-1)){let a2=f((V-C)*($+K)),c2=f((V+C)*($-K)),Ws=f(c2-a2);if(Ws===Ze)return this.double();let l2=f(M*I1*se),u2=f(Y*I1*le),f2=u2+l2,h2=c2+a2,d2=u2-l2,W4=f(f2*Ws),Z4=f(h2*d2),Q4=f(f2*d2),X4=f(Ws*h2);return new x(W4,Z4,X4,Q4)}let ve=f(C*K),Ee=f(V*$),pe=f(Y*P*se),Ae=f(M*le),dt=f((C+V)*(K+$)-ve-Ee),rr=Ae-pe,nn=Ae+pe,o2=f(Ee-k*ve),z4=f(dt*rr),G4=f(nn*o2),j4=f(dt*o2),Y4=f(rr*nn);return new x(z4,G4,Y4,j4)}subtract(w){return this.add(w.negate())}wNAF(w){return T.wNAFCached(this,b,w,x.normalizeZ)}multiply(w){let{p:k,f:P}=this.wNAF(y(w,n));return x.normalizeZ([k,P])[0]}multiplyUnsafe(w){let k=v(w);return k===Ze?N:this.equals(N)||k===Ve?this:this.equals(I)?this.wNAF(k).p:T.unsafeLadder(this,k)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(w){let{ex:k,ey:P,ez:C}=this,V=this.is0();w==null&&(w=V?ma:t.inv(C));let M=f(k*w),Y=f(P*w),K=f(C*w);if(V)return{x:Ze,y:Ve};if(K!==Ve)throw new Error("invZ was invalid");return{x:M,y:Y}}clearCofactor(){let{h:w}=e;return w===Ve?this:this.multiplyUnsafe(w)}static fromHex(w,k=!1){let{d:P,a:C}=e,V=t.BYTES;w=oe("pointHex",w,V);let M=w.slice(),Y=w[V-1];M[V-1]=Y&-129;let K=jt(M);K===Ze||(k?y(K,l):y(K,t.ORDER));let $=f(K*K),le=f($-Ve),se=f(P*$-C),{isValid:ve,value:Ee}=u(le,se);if(!ve)throw new Error("Point.fromHex: invalid y coordinate");let pe=(Ee&Ve)===Ve,Ae=(Y&128)!==0;if(!k&&Ee===Ze&&Ae)throw new Error("Point.fromHex: x=0 and x_0=1");return Ae!==pe&&(Ee=f(-Ee)),x.fromAffine({x:Ee,y:K})}static fromPrivateKey(w){return U(w).point}toRawBytes(){let{x:w,y:k}=this.toAffine(),P=lr(k,t.BYTES);return P[P.length-1]|=w&Ve?128:0,P}toHex(){return Et(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,Ve,f(e.Gx*e.Gy)),x.ZERO=new x(Ze,Ve,Ve,Ze);let{BASE:I,ZERO:N}=x,T=B1(x,a*8);function G(B){return Z(B,n)}function q(B){return G(jt(B))}function U(B){let w=a;B=oe("private key",B,w);let k=oe("hashed private key",i(B),2*w),P=h(k.slice(0,w)),C=k.slice(w,2*w),V=q(P),M=I.multiply(V),Y=M.toRawBytes();return{head:P,prefix:C,scalar:V,point:M,pointBytes:Y}}function ce(B){return U(B).pointBytes}function ae(B=new Uint8Array,...w){let k=At(...w);return q(i(m(k,oe("context",B),!!s)))}function Fe(B,w,k={}){B=oe("message",B),s&&(B=s(B));let{prefix:P,scalar:C,pointBytes:V}=U(w),M=ae(k.context,P,B),Y=I.multiply(M).toRawBytes(),K=ae(k.context,Y,V,B),$=G(M+K*C);v($);let le=At(Y,lr($,t.BYTES));return oe("result",le,a*2)}let A=ya;function _(B,w,k,P=A){let{context:C,zip215:V}=P,M=t.BYTES;B=oe("signature",B,2*M),w=oe("message",w),s&&(w=s(w));let Y=jt(B.slice(M,2*M)),K,$,le;try{K=x.fromHex(k,V),$=x.fromHex(B.slice(0,M),V),le=I.multiplyUnsafe(Y)}catch{return!1}if(!V&&K.isSmallOrder())return!1;let se=ae(C,$.toRawBytes(),K.toRawBytes(),w);return $.add(K.multiplyUnsafe(se)).subtract(le).clearCofactor().equals(x.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:ce,sign:Fe,verify:_,ExtendedPoint:x,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>o(t.BYTES),precompute(B=8,w=x.BASE){return w._setWindowSize(B),w.multiply(BigInt(3)),w}}}}var Bo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),t3=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Gh=BigInt(0),wa=BigInt(1),Ao=BigInt(2),va=BigInt(5),r3=BigInt(10),Ea=BigInt(20),xa=BigInt(40),n3=BigInt(80);function Aa(r){let e=Bo,n=r*r%e*r%e,s=re(n,Ao,e)*n%e,i=re(s,wa,e)*r%e,o=re(i,va,e)*i%e,a=re(o,r3,e)*o%e,c=re(a,Ea,e)*a%e,l=re(c,xa,e)*c%e,f=re(l,n3,e)*l%e,u=re(f,n3,e)*l%e,h=re(u,r3,e)*o%e;return{pow_p_5_8:re(h,Ao,e)*r%e,b2:n}}function Ba(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Ia(r,e){let t=Bo,n=Z(e*e*e,t),s=Z(n*n*e,t),i=Aa(r*s).pow_p_5_8,o=Z(r*n*i,t),a=Z(e*o*o,t),c=o,l=Z(o*t3,t),f=a===r,u=a===Z(-r,t),h=a===Z(-r*t3,t);return f&&(o=c),(u||h)&&(o=l),Q0(o,t)&&(o=Z(-o,t)),{isValid:f||u,value:o}}var Bt=A1(Bo,void 0,!0),Io={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Bt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:$r,randomBytes:Kr,adjustScalarBytes:Ba,uvRatio:Ia},zr=S1(Io);function s3(r,e,t){if(e.length>255)throw new Error("Context is too big");return y1(fo("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var jh=S1({...Io,domain:s3}),Yh=S1({...Io,domain:s3,prehash:$r});var Sa=(Bt.ORDER+BigInt(3))/BigInt(8),Wh=Bt.pow(Ao,Sa),Zh=Bt.sqrt(Bt.neg(Bt.ONE)),Qh=(Bt.ORDER-BigInt(5))/BigInt(8),Xh=BigInt(486662);var Jh=X0(Bt,Bt.neg(BigInt(486664)));var ed=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),td=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),rd=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),nd=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var sd=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Gr=32,It=64,R1=32;function i3(){let r=zr.utils.randomPrivateKey(),e=zr.getPublicKey(r);return{privateKey:l3(r,e),publicKey:e}}function o3(r){if(r.length!==R1)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=zr.getPublicKey(e);return{privateKey:l3(e,t),publicKey:t}}function a3(r,e){let t=r.subarray(0,R1);return zr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function c3(r,e,t){return zr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function l3(r,e){let t=new Uint8Array(It);for(let n=0;n<R1;n++)t[n]=r[n],t[R1+n]=e[n];return t}var So={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function k1(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,s=r?.digest??"SHA-256",i=r?.saltLength??16,o=r?.iterations??32767,a=ee.get();t*=8;async function c(u,h){let m=a.getRandomValues(new Uint8Array(i)),p=a.getRandomValues(new Uint8Array(n)),d={name:e,iv:p};typeof h=="string"&&(h=z(h));let g;if(h.length===0){g=await a.subtle.importKey("jwk",So,{name:"AES-GCM"},!0,["encrypt"]);try{let v={name:"PBKDF2",salt:m,iterations:o,hash:{name:s}},b=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(v,b,{name:e,length:t},!0,["encrypt"])}catch{g=await a.subtle.importKey("jwk",So,{name:"AES-GCM"},!0,["encrypt"])}}else{let v={name:"PBKDF2",salt:m,iterations:o,hash:{name:s}},b=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(v,b,{name:e,length:t},!0,["encrypt"])}let y=await a.subtle.encrypt(d,g,u);return J([m,d.iv,new Uint8Array(y)])}async function l(u,h){let m=u.subarray(0,i),p=u.subarray(i,i+n),d=u.subarray(i+n),g={name:e,iv:p};typeof h=="string"&&(h=z(h));let y;if(h.length===0)try{let b={name:"PBKDF2",salt:m,iterations:o,hash:{name:s}},S=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(b,S,{name:e,length:t},!0,["decrypt"])}catch{y=await a.subtle.importKey("jwk",So,{name:"AES-GCM"},!0,["decrypt"])}else{let b={name:"PBKDF2",salt:m,iterations:o,hash:{name:s}},S=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(b,S,{name:e,length:t},!0,["decrypt"])}let v=await a.subtle.decrypt(g,y,d);return new Uint8Array(v)}return{encrypt:c,decrypt:l}}async function jr(r,e){let n=await k1().encrypt(r,e);return cn.encode(n)}var Yr={};ue(Yr,{KeyType:()=>X,PrivateKey:()=>Xe,PublicKey:()=>Qe});var X;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(X||(X={}));var Ro;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Ro||(Ro={}));(function(r){r.codec=()=>Rr(Ro)})(X||(X={}));var Qe;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),X.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:s.Type=X.codec().decode(t);break;case 2:s.Data=t.bytes();break;default:t.skipType(o&7);break}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(Qe||(Qe={}));var Xe;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),X.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:s.Type=X.codec().decode(t);break;case 2:s.Data=t.bytes();break;default:t.skipType(o&7);break}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(Xe||(Xe={}));var fr=class{_key;constructor(e){this._key=Wr(e,Gr)}verify(e,t){return c3(this._key,t,e)}marshal(){return this._key}get bytes(){return Qe.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Q(this.bytes,e.bytes)}hash(){let e=ne.digest(this.bytes);return Ke(e)?e.then(({bytes:t})=>t):e.bytes}},St=class{_key;_publicKey;constructor(e,t){this._key=Wr(e,It),this._publicKey=Wr(t,Gr)}sign(e){return a3(this._key,e)}get public(){return new fr(this._publicKey)}marshal(){return this._key}get bytes(){return Xe.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Q(this.bytes,e.bytes)}async hash(){let e=ne.digest(this.bytes),t;return Ke(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Ht.digest(this.public.bytes);return ge.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return jr(this.bytes,e);throw new E(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function ka(r){if(r.length>It){r=Wr(r,It+Gr);let n=r.subarray(0,It),s=r.subarray(It,r.length);return new St(n,s)}r=Wr(r,It);let e=r.subarray(0,It),t=r.subarray(Gr);return new St(e,t)}function Na(r){return r=Wr(r,Gr),new fr(r)}async function _a(){let{privateKey:r,publicKey:e}=i3();return new St(r,e)}async function ko(r){let{privateKey:e,publicKey:t}=o3(r);return new St(e,t)}function Wr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new E(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}var f3={"P-256":256,"P-384":384,"P-521":521},Ta=Object.keys(f3),_o=Ta.join(" / ");async function h3(r){if(r!=="P-256"&&r!=="P-384"&&r!=="P-521")throw new E(`Unknown curve: ${r}. Must be ${_o}`,"ERR_INVALID_CURVE");let e=await ee.get().subtle.generateKey({name:"ECDH",namedCurve:r},!0,["deriveBits"]),t=async(i,o)=>{let a;o!=null?a=await ee.get().subtle.importKey("jwk",Pa(r,o),{name:"ECDH",namedCurve:r},!1,["deriveBits"]):a=e.privateKey;let c=await ee.get().subtle.importKey("jwk",p3(r,i),{name:"ECDH",namedCurve:r},!1,[]),l=await ee.get().subtle.deriveBits({name:"ECDH",namedCurve:r,public:c},a,f3[r]);return new Uint8Array(l,0,l.byteLength)},n=await ee.get().subtle.exportKey("jwk",e.publicKey);return{key:La(n),genSharedKey:t}}var d3={"P-256":32,"P-384":48,"P-521":66};function La(r){if(r.crv==null||r.x==null||r.y==null)throw new E("JWK was missing components","ERR_INVALID_PARAMETERS");if(r.crv!=="P-256"&&r.crv!=="P-384"&&r.crv!=="P-521")throw new E(`Unknown curve: ${r.crv}. Must be ${_o}`,"ERR_INVALID_CURVE");let e=d3[r.crv];return J([Uint8Array.from([4]),lo(r.x,e),lo(r.y,e)],1+e*2)}function p3(r,e){if(r!=="P-256"&&r!=="P-384"&&r!=="P-521")throw new E(`Unknown curve: ${r}. Must be ${_o}`,"ERR_INVALID_CURVE");let t=d3[r];if(!Q(e.subarray(0,1),Uint8Array.from([4])))throw new E("Cannot unmarshal public key - invalid key format","ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:r,x:L(e.subarray(1,t+1),"base64url"),y:L(e.subarray(1+t),"base64url"),ext:!0}}var Pa=(r,e)=>({...p3(r,e.public),d:L(e.private,"base64url")});var g3=h3;async function m3(r,e){let t=cn.decode(r);return k1().decrypt(t,e)}var y3={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,keySize:32}};async function b3(r,e,t){let n=y3[r];if(n==null){let v=Object.keys(y3).join(" / ");throw new E(`unknown cipher type '${r}'. Must be ${v}`,"ERR_INVALID_CIPHER_TYPE")}if(e==null)throw new E("missing hash type","ERR_MISSING_HASH_TYPE");let s=n.keySize,i=n.ivSize,o=20,a=z("key expansion"),c=2*(i+s+o),l=await F0(e,t),f=await l.digest(a),u=[],h=0;for(;h<c;){let v=await l.digest(J([f,a])),b=v.length;h+b>c&&(b=c-h),u.push(v),h+=b,f=await l.digest(f)}let m=c/2,p=J(u),d=p.subarray(0,m),g=p.subarray(m,c),y=v=>({iv:v.subarray(0,i),cipherKey:v.subarray(i,i+s),macKey:v.subarray(i+s)});return{k1:y(d),k2:y(g)}}var Ho={};ue(Ho,{MAX_RSA_KEY_SIZE:()=>pr,RsaPrivateKey:()=>Jt,RsaPublicKey:()=>dr,fromJwk:()=>i7,generateKeyPair:()=>o7,unmarshalRsaPrivateKey:()=>Fo,unmarshalRsaPublicKey:()=>s7});function lt(r){if(isNaN(r)||r<=0)throw new E("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Kr(r)}var Xt={};ue(Xt,{exportToPem:()=>e7,importFromPem:()=>Vo,jwkToPkcs1:()=>Za,jwkToPkix:()=>Xa,pkcs1ToJwk:()=>Wa,pkixToJwk:()=>Qa});var N1=class extends Mr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,g1(e);let n=$t(t);if(this.iHash=e.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 s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Fr(this),this.iHash.update(e),this}digestInto(e){Fr(this),uo(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},In=(r,e,t)=>new N1(r,e).update(t).digest();In.create=(r,e)=>new N1(r,e);function Ca(r,e,t,n){g1(r);let s=q0({dkLen:32,asyncTick:10},n),{c:i,dkLen:o,asyncTick:a}=s;if(Vr(i),Vr(o),Vr(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=$t(e),l=$t(t),f=new Uint8Array(o),u=In.create(r,c),h=u._cloneInto().update(l);return{c:i,dkLen:o,asyncTick:a,DK:f,PRF:u,PRFSalt:h}}function Da(r,e,t,n,s){return r.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),t}async function To(r,e,t,n){let{c:s,dkLen:i,asyncTick:o,DK:a,PRF:c,PRFSalt:l}=Ca(r,e,t,n),f,u=new Uint8Array(4),h=Hr(u),m=new Uint8Array(c.outputLen);for(let p=1,d=0;d<i;p++,d+=c.outputLen){let g=a.subarray(d,d+c.outputLen);h.setInt32(0,p,!1),(f=l._cloneInto(f)).update(u).digestInto(m),g.set(m.subarray(0,g.length)),await K0(s-1,o,()=>{c._cloneInto(f).update(m).digestInto(m);for(let y=0;y<g.length;y++)g[y]^=m[y]})}return Da(c,l,a,f,m)}var H=on(w3());function hr(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Wt(r,e,t=-1){let n=t,s=r,i=0,o=Math.pow(2,e);for(let a=1;a<8;a++){if(r<o){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let l=new Uint8Array(c);for(let f=a-1;f>=0;f--){let u=Math.pow(2,f*e);l[i-f-1]=Math.floor(s/u),s-=l[i-f-1]*u}return c}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function L1(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let i of r)s.set(i,t),t+=i.length;return s}function Po(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=hr(t,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,hr(i,8)-n}function v3(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let o=t-e,a=Wt(o,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Wt(e,8,n),i=new Uint8Array(s);if(i[0]&128){let o=s.slice(0),a=new Uint8Array(o);s=new ArrayBuffer(s.byteLength+1),i=new Uint8Array(s);for(let c=0;c<o.byteLength;c++)i[c+1]=a[c];i[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function E3(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function Pe(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,s=new Array(n);for(let o=0;o<n;o++)s[o]="0";return s.join("").concat(t)}var Gd=Math.log(2);function P1(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Co(r){let e=0,t=0;for(let s=0;s<r.length;s++){let i=r[s];e+=i.byteLength}let n=new Uint8Array(e);for(let s=0;s<r.length;s++){let i=r[s];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function Tt(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Rn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Co(this.items)}},Sn=[new Uint8Array([1])],x3="0123456789";var Xr="",et=new ArrayBuffer(0),Do=new Uint8Array(0),kn="EndOfContent",B3="OCTET STRING",I3="BIT STRING";function Lt(r){var e;return e=class extends r{constructor(...n){var s;super(...n);let i=n[0]||{};this.isHexOnly=(s=i.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=i.valueHex?H.BufferSourceConverter.toUint8Array(i.valueHex):Do}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,i){let o=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Tt(this,o,s,i))return-1;let a=s+i;return this.valueHexView=o.subarray(s,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",et)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var kt=class{constructor({blockLength:e=0,error:t=Xr,warnings:n=[],valueBeforeDecode:s=Do}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=H.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:H.Convert.ToHex(this.valueBeforeDecodeView)}}};kt.NAME="baseBlock";var Re=class extends kt{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Re.NAME="valueBlock";var C1=class extends Lt(kt){constructor({idBlock:e={}}={}){var t,n,s,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?H.BufferSourceConverter.toUint8Array(e.valueHex):Do,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",et}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=Wt(this.tagNumber,7),i=new Uint8Array(s),o=s.byteLength,a=new Uint8Array(o+1);if(a[0]=t|31,!e){for(let c=0;c<o-1;c++)a[c+1]=i[c]|128;a[o]=i[o-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let s=this.valueHexView;for(let i=0;i<s.length-1;i++)n[i+1]=s[i]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(e,t,n){let s=H.BufferSourceConverter.toUint8Array(e);if(!Tt(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),f=255;for(;i[c]&128;){if(l[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;let h=new Uint8Array(f);for(let m=0;m<l.length;m++)h[m]=l[m];l=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,l[c-1]=i[c]&127;let u=new Uint8Array(c);for(let h=0;h<c;h++)u[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(u),this.blockLength<=9?this.tagNumber=hr(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};C1.NAME="identificationBlock";var D1=class extends kt{constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){let s=H.BufferSourceConverter.toUint8Array(e);if(!Tt(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let o=i[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=s.subarray(a,a+o);return c[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=hr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let s=Wt(this.length,8);if(s.byteLength>127)return this.error="Too big length",et;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let i=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let o=0;o<s.byteLength;o++)n[o+1]=i[o];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};D1.NAME="lengthBlock";var R={},xe=class extends kt{constructor({name:e=Xr,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new C1(s),this.lenBlock=new D1(s),this.valueBlock=i?new i(s):new Re(s)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(e,t){let n=t||new Rn;t||S3(this);let s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let o=this.lenBlock.toBER(e);n.write(o),n.write(i)}return t?et:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return E3(t,n)}};xe.NAME="BaseBlock";function S3(r){if(r instanceof R.Constructed)for(let e of r.valueBlock.value)S3(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var U1=class extends xe{constructor({value:e=Xr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};U1.NAME="BaseStringBlock";var O1=class extends Lt(Re){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};O1.NAME="PrimitiveValueBlock";var R3,V1=class extends xe{constructor(e={}){super(e,O1),this.idBlock.isConstructed=!1}};R3=V1;R.Primitive=R3;V1.NAME="PRIMITIVE";function $a(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function ys(r,e=0,t=r.length){let n=e,s=new xe({},Re),i=new kt;if(!Tt(i,r,e,t))return s.error=i.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=a,t-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=a,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=xe;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=R.EndOfContent;break;case 1:c=R.Boolean;break;case 2:c=R.Integer;break;case 3:c=R.BitString;break;case 4:c=R.OctetString;break;case 5:c=R.Null;break;case 6:c=R.ObjectIdentifier;break;case 10:c=R.Enumerated;break;case 12:c=R.Utf8String;break;case 13:c=R.RelativeObjectIdentifier;break;case 14:c=R.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=R.Sequence;break;case 17:c=R.Set;break;case 18:c=R.NumericString;break;case 19:c=R.PrintableString;break;case 20:c=R.TeletexString;break;case 21:c=R.VideotexString;break;case 22:c=R.IA5String;break;case 23:c=R.UTCTime;break;case 24:c=R.GeneralizedTime;break;case 25:c=R.GraphicString;break;case 26:c=R.VisibleString;break;case 27:c=R.GeneralString;break;case 28:c=R.UniversalString;break;case 29:c=R.CharacterString;break;case 30:c=R.BmpString;break;case 31:c=R.DATE;break;case 32:c=R.TimeOfDay;break;case 33:c=R.DateTime;break;case 34:c=R.Duration;break;default:{let l=s.idBlock.isConstructed?new R.Constructed:new R.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?R.Constructed:R.Primitive}return s=$a(s,c),a=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function Jr(r){if(!r.byteLength){let e=new xe({},Re);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ys(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function za(r,e){return r?1:e}var ut=class extends Re{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=H.BufferSourceConverter.toUint8Array(e);if(!Tt(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;za(this.isIndefiniteForm,n)>0;){let o=ys(s,i,n);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(i=o.offset,this.blockLength+=o.result.blockLength,n-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===kn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===kn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new Rn;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?et:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ut.NAME="ConstructedValueBlock";var k3,Zt=class extends xe{constructor(e={}){super(e,ut),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
2
|
+
"use strict";var Libp2PKadDht=(()=>{var J4=Object.create;var Hn=Object.defineProperty;var e5=Object.getOwnPropertyDescriptor;var t5=Object.getOwnPropertyNames;var r5=Object.getPrototypeOf,n5=Object.prototype.hasOwnProperty;var sn=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ue=(r,e)=>{for(var t in e)Hn(r,t,{get:e[t],enumerable:!0})},p2=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of t5(e))!n5.call(r,s)&&s!==t&&Hn(r,s,{get:()=>e[s],enumerable:!(n=e5(e,s))||n.enumerable});return r};var on=(r,e,t)=>(t=r!=null?J4(r5(r)):{},p2(e||!r||!r.__esModule?Hn(t,"default",{value:r,enumerable:!0}):t,r)),s5=r=>p2(Hn({},"__esModule",{value:!0}),r);var c0=sn(wn=>{(function(){var r,e,t,n,s,i,o,a;a=function(c){var l,f,u,h;return l=(c&255<<24)>>>24,f=(c&255<<16)>>>16,u=(c&65280)>>>8,h=c&255,[l,f,u,h].join(".")},o=function(c){var l,f,u,h,m,p;for(l=[],u=h=0;h<=3&&c.length!==0;u=++h){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}p=e(c),m=p[0],f=p[1],c=c.substring(f),l.push(m)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),i=t("a"),s=t("A"),e=function(c){var l,f,u,h,m;for(h=0,l=10,f="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,l=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,l=8,f="7")),m=u;u<c.length;){if("0"<=c[u]&&c[u]<=f)h=h*l+(t(c[u])-n)>>>0;else if(l===16)if("a"<=c[u]&&c[u]<="f")h=h*l+(10+t(c[u])-i)>>>0;else if("A"<=c[u]&&c[u]<="F")h=h*l+(10+t(c[u])-s)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");u++}if(u===m)throw new Error("empty octet");return[h,u]},r=function(){function c(l,f){var u,h,m,p;if(typeof l!="string")throw new Error("Missing `net' parameter");if(f||(p=l.split("/",2),l=p[0],f=p[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=o(f)}catch(d){throw u=d,new Error("Invalid mask: "+f)}for(h=m=32;m>=0;h=--m)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(o(l)&this.maskLong)>>>0}catch(d){throw u=d,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(o(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var f,u,h;for(h=o(this.first),u=o(this.last),f=0;h<=u;)l(a(h),h,f),f++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),wn.ip2long=o,wn.long2ip=a,wn.Netmask=r}).call(wn)});var w3=sn(Zr=>{"use strict";var Ua="[object ArrayBuffer]",Rt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Ua}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),s=r.toUint8Array(t);if(n.length!==s.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==s[i])return!1;return!0}static concat(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let o of t)n+=o.byteLength;let s=new Uint8Array(n),i=0;for(let o of t){let a=this.toUint8Array(o);s.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}},Lo="string",Oa=/^[0-9a-f]+$/i,Va=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Fa=/^[a-zA-Z0-9-_]+$/,_1=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){let t=Rt.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},qe=class{static toString(e,t=!1){let n=Rt.toArrayBuffer(e),s=new DataView(n),i="";for(let o=0;o<n.byteLength;o+=2){let a=s.getUint16(o,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let i=0;i<e.length;i++)s.setUint16(i*2,e.charCodeAt(i),t);return n}},T1=class r{static isHex(e){return typeof e===Lo&&Oa.test(e)}static isBase64(e){return typeof e===Lo&&Va.test(e)}static isBase64Url(e){return typeof e===Lo&&Fa.test(e)}static ToString(e,t="utf8"){let n=Rt.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return qe.toString(n,!0);case"utf16":case"utf16be":return qe.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return qe.fromString(e,!0);case"utf16":case"utf16be":return qe.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Rt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return _1.fromString(e);case"utf16":case"utf16be":return qe.fromString(e);case"utf16le":case"usc2":return qe.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return _1.toString(e);case"utf16":case"utf16be":return qe.toString(e);case"utf16le":case"usc2":return qe.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){let t=Rt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=Rt.toUint8Array(e),n="",s=t.length;for(let i=0;i<s;i++){let o=t[i];o<16&&(n+="0"),n+=o.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let i=t.slice(s,s+2);n[s/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return qe.toString(e,t)}static FromUtf16String(e,t=!1){return qe.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};T1.DEFAULT_UTF8_ENCODING="utf8";function Ma(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let i in s)t[i]=s[i]}return t}function Ha(...r){let e=r.map(s=>s.byteLength).reduce((s,i)=>s+i),t=new Uint8Array(e),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let i of s)t[n++]=i}),t.buffer}function Ka(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}Zr.BufferSourceConverter=Rt;Zr.Convert=T1;Zr.assign=Ma;Zr.combine=Ha;Zr.isEqual=Ka});var S4=sn((pg,I4)=>{I4.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function s(i,o){t[i]=o,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(i){return t[i]!==void 0||n[i]!==void 0},remove:function(i){t[i]!==void 0&&(t[i]=void 0),n[i]!==void 0&&(n[i]=void 0)},get:function(i){var o=t[i];if(o!==void 0)return o;if((o=n[i])!==void 0)return s(i,o),o},set:function(i,o){t[i]!==void 0?t[i]=o:s(i,o)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var k4=sn((gg,Wo)=>{"use strict";var k7=Object.prototype.hasOwnProperty,Le="~";function Dn(){}Object.create&&(Dn.prototype=Object.create(null),new Dn().__proto__||(Le=!1));function N7(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function R4(r,e,t,n,s){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new N7(t,n||r,s),o=Le?Le+e:e;return r._events[o]?r._events[o].fn?r._events[o]=[r._events[o],i]:r._events[o].push(i):(r._events[o]=i,r._eventsCount++),r}function As(r,e){--r._eventsCount===0?r._events=new Dn:delete r._events[e]}function ke(){this._events=new Dn,this._eventsCount=0}ke.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)k7.call(t,n)&&e.push(Le?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};ke.prototype.listeners=function(e){var t=Le?Le+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var s=0,i=n.length,o=new Array(i);s<i;s++)o[s]=n[s].fn;return o};ke.prototype.listenerCount=function(e){var t=Le?Le+e:e,n=this._events[t];return n?n.fn?1:n.length:0};ke.prototype.emit=function(e,t,n,s,i,o){var a=Le?Le+e:e;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,f,u;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,s),!0;case 5:return c.fn.call(c.context,t,n,s,i),!0;case 6:return c.fn.call(c.context,t,n,s,i,o),!0}for(u=1,f=new Array(l-1);u<l;u++)f[u-1]=arguments[u];c.fn.apply(c.context,f)}else{var h=c.length,m;for(u=0;u<h;u++)switch(c[u].once&&this.removeListener(e,c[u].fn,void 0,!0),l){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,t);break;case 3:c[u].fn.call(c[u].context,t,n);break;case 4:c[u].fn.call(c[u].context,t,n,s);break;default:if(!f)for(m=1,f=new Array(l-1);m<l;m++)f[m-1]=arguments[m];c[u].fn.apply(c[u].context,f)}}return!0};ke.prototype.on=function(e,t,n){return R4(this,e,t,n,!1)};ke.prototype.once=function(e,t,n){return R4(this,e,t,n,!0)};ke.prototype.removeListener=function(e,t,n,s){var i=Le?Le+e:e;if(!this._events[i])return this;if(!t)return As(this,i),this;var o=this._events[i];if(o.fn)o.fn===t&&(!s||o.once)&&(!n||o.context===n)&&As(this,i);else{for(var a=0,c=[],l=o.length;a<l;a++)(o[a].fn!==t||s&&!o[a].once||n&&o[a].context!==n)&&c.push(o[a]);c.length?this._events[i]=c.length===1?c[0]:c:As(this,i)}return this};ke.prototype.removeAllListeners=function(e){var t;return e?(t=Le?Le+e:e,this._events[t]&&As(this,t)):(this._events=new Dn,this._eventsCount=0),this};ke.prototype.off=ke.prototype.removeListener;ke.prototype.addListener=ke.prototype.on;ke.prefixed=Le;ke.EventEmitter=ke;typeof Wo<"u"&&(Wo.exports=ke)});var $4=sn((ey,q4)=>{"use strict";function K4(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Y7(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return K4(r,t)}catch{t.message=r.message,t.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),K4(new s,t)}}q4.exports=Y7});var tc={};ue(tc,{EventTypes:()=>s2,MessageType:()=>i2,Record:()=>me,kadDHT:()=>ec,passthroughMapper:()=>h0,removePrivateAddressesMapper:()=>o1,removePublicAddressesMapper:()=>f0});var g2=Symbol.for("@libp2p/content-routing");var m2=Symbol.for("@libp2p/peer-discovery");var y2=Symbol.for("@libp2p/peer-id");var b2=Symbol.for("@libp2p/peer-routing");var Ut=class r extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},E=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Be=class extends EventTarget{#e=new Map;listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let s=this.#e.get(e);s==null&&(s=[],this.#e.set(e,s)),s.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let s=this.#e.get(e);s!=null&&(s=s.filter(({callback:i})=>i!==t),this.#e.set(e,s))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:s})=>!s),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new Ne(e,t))}},Zs=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},Ne=globalThis.CustomEvent??Zs;var pt=(r,...e)=>{try{[...e]}catch{}};function i5(r){return r[Symbol.asyncIterator]!=null}function o5(r){if(i5(r))return(async()=>{for await(let e of r);})();for(let e of r);}var Qs=o5;function fe(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var w2="/ipfs/kad/1.0.0",v2="/dht/record",Xs="/dht/provider";function a5(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:s=>{n.push(s)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var E2=a5;function c5(r){return r[Symbol.asyncIterator]!=null}function l5(r,e){if(c5(r))return async function*(){for await(let a of r)yield e(a)}();let t=E2(r),{value:n,done:s}=t.next();if(s===!0)return function*(){}();let i=e(n);if(typeof i.then=="function")return async function*(){yield await i;for await(let a of t)yield e(a)}();let o=e;return function*(){yield i;for(let a of t)yield o(a)}()}var Kn=l5;var qn=globalThis.CustomEvent??Event;async function*an(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,s=new EventTarget,i=[],o=fe(),a=fe(),c=!1,l,f=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let p of r){if(i.length===t&&(o=fe(),await o.promise),f)break;let d={done:!1};i.push(d),p().then(g=>{d.done=!0,d.ok=!0,d.value=g,s.dispatchEvent(new qn("task-complete"))},g=>{d.done=!0,d.err=g,s.dispatchEvent(new qn("task-complete"))})}c=!0,s.dispatchEvent(new qn("task-complete"))}catch(p){l=p,s.dispatchEvent(new qn("task-complete"))}});function u(){return n?i[0]?.done:!!i.find(p=>p.done)}function*h(){for(;i.length>0&&i[0].done;){let p=i[0];if(i.shift(),p.ok)yield p.value;else throw f=!0,o.resolve(),p.err;o.resolve()}}function*m(){for(;u();)for(let p=0;p<i.length;p++)if(i[p].done){let d=i[p];if(i.splice(p,1),p--,d.ok)yield d.value;else throw f=!0,o.resolve(),d.err;o.resolve()}}for(;;){if(u()||(a=fe(),await a.promise),l!=null)throw l;if(n?yield*h():yield*m(),c&&i.length===0)break}}var $n=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},vr=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new $n(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let t=this.head;this.head=t.next=new $n(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var Js=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}};function Ot(r={}){return u5(t=>{let n=t.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function u5(r,e){e=e??{};let t=e.onEnd,n=new vr,s,i,o,a=fe(),c=async()=>{try{return n.isEmpty()?o?{done:!0}:await new Promise((g,y)=>{i=v=>{i=null,n.push(v);try{g(r(n))}catch(b){y(b)}return s}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=fe()})}},l=g=>i!=null?i(g):(n.push(g),s),f=g=>(n=new vr,i!=null?i({error:g}):(n.push({error:g}),s)),u=g=>{if(o)return s;if(e?.objectMode!==!0&&g?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:g})},h=g=>o?s:(o=!0,g!=null?f(g):l({done:!0})),m=()=>(n=new vr,h(),{done:!0}),p=g=>(h(g),{done:!0});if(s={[Symbol.asyncIterator](){return this},next:c,return:m,throw:p,push:u,end:h,get readableLength(){return n.size},onEmpty:async g=>{let y=g?.signal;if(y?.throwIfAborted(),n.isEmpty())return;let v,b;y!=null&&(v=new Promise((S,x)=>{b=()=>{x(new Js)},y.addEventListener("abort",b)}));try{await Promise.race([a.promise,v])}finally{b!=null&&y!=null&&y?.removeEventListener("abort",b)}}},t==null)return s;let d=s;return s={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(g){return d.throw(g),t!=null&&(t(g),t=void 0),{done:!0}},return(){return d.return(),t!=null&&(t(),t=void 0),{done:!0}},push:u,end(g){return d.end(g),t!=null&&(t(g),t=void 0),s},get readableLength(){return d.readableLength},onEmpty:g=>d.onEmpty(g)},s}function f5(r){return r[Symbol.asyncIterator]!=null}function h5(...r){let e=[];for(let t of r)f5(t)||e.push(t);return e.length===r.length?function*(){for(let t of e)yield*t}():async function*(){let t=Ot({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let s of n)t.push(s)})),t.end()}catch(n){t.end(n)}}),yield*t}()}var zn=h5;function Vt(r,...e){if(r==null)throw new Error("Empty pipeline");if(ei(r)){let n=r;r=()=>n.source}else if(A2(r)||x2(r)){let n=r;r=()=>n}let t=[r,...e];if(t.length>1&&ei(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let n=1;n<t.length-1;n++)ei(t[n])&&(t[n]=p5(t[n]));return d5(...t)}var d5=(...r)=>{let e;for(;r.length>0;)e=r.shift()(e);return e},x2=r=>r?.[Symbol.asyncIterator]!=null,A2=r=>r?.[Symbol.iterator]!=null,ei=r=>r==null?!1:r.sink!=null&&r.source!=null,p5=r=>e=>{let t=r.sink(e);if(t?.then!=null){let n=Ot({objectMode:!0});t.then(()=>{n.end()},o=>{n.end(o)});let s,i=r.source;if(x2(i))s=async function*(){yield*i,n.end()};else if(A2(i))s=function*(){yield*i,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return zn(n,s())}return r.source};function Q(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function rt(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function ze(r=0){return globalThis.Buffer?.alloc!=null?rt(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function be(r=0){return globalThis.Buffer?.allocUnsafe!=null?rt(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var g5=Math.pow(2,7),m5=Math.pow(2,14),y5=Math.pow(2,21),ti=Math.pow(2,28),ri=Math.pow(2,35),ni=Math.pow(2,42),si=Math.pow(2,49),j=128,Ie=127;function he(r){if(r<g5)return 1;if(r<m5)return 2;if(r<y5)return 3;if(r<ti)return 4;if(r<ri)return 5;if(r<ni)return 6;if(r<si)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ii(r,e,t=0){switch(he(r)){case 8:e[t++]=r&255|j,r/=128;case 7:e[t++]=r&255|j,r/=128;case 6:e[t++]=r&255|j,r/=128;case 5:e[t++]=r&255|j,r/=128;case 4:e[t++]=r&255|j,r>>>=7;case 3:e[t++]=r&255|j,r>>>=7;case 2:e[t++]=r&255|j,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function b5(r,e,t=0){switch(he(r)){case 8:e.set(t++,r&255|j),r/=128;case 7:e.set(t++,r&255|j),r/=128;case 6:e.set(t++,r&255|j),r/=128;case 5:e.set(t++,r&255|j),r/=128;case 4:e.set(t++,r&255|j),r>>>=7;case 3:e.set(t++,r&255|j),r>>>=7;case 2:e.set(t++,r&255|j),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function oi(r,e){let t=r[e],n=0;if(n+=t&Ie,t<j||(t=r[e+1],n+=(t&Ie)<<7,t<j)||(t=r[e+2],n+=(t&Ie)<<14,t<j)||(t=r[e+3],n+=(t&Ie)<<21,t<j)||(t=r[e+4],n+=(t&Ie)*ti,t<j)||(t=r[e+5],n+=(t&Ie)*ri,t<j)||(t=r[e+6],n+=(t&Ie)*ni,t<j)||(t=r[e+7],n+=(t&Ie)*si,t<j))return n;throw new RangeError("Could not decode varint")}function w5(r,e){let t=r.get(e),n=0;if(n+=t&Ie,t<j||(t=r.get(e+1),n+=(t&Ie)<<7,t<j)||(t=r.get(e+2),n+=(t&Ie)<<14,t<j)||(t=r.get(e+3),n+=(t&Ie)<<21,t<j)||(t=r.get(e+4),n+=(t&Ie)*ti,t<j)||(t=r.get(e+5),n+=(t&Ie)*ri,t<j)||(t=r.get(e+6),n+=(t&Ie)*ni,t<j)||(t=r.get(e+7),n+=(t&Ie)*si,t<j))return n;throw new RangeError("Could not decode varint")}function Me(r,e,t=0){return e==null&&(e=be(he(r))),e instanceof Uint8Array?ii(r,e,t):b5(r,e,t)}function Ce(r,e=0){return r instanceof Uint8Array?oi(r,e):w5(r,e)}var ai=new Float32Array([-0]),Ft=new Uint8Array(ai.buffer);function B2(r,e,t){ai[0]=r,e[t]=Ft[0],e[t+1]=Ft[1],e[t+2]=Ft[2],e[t+3]=Ft[3]}function I2(r,e){return Ft[0]=r[e],Ft[1]=r[e+1],Ft[2]=r[e+2],Ft[3]=r[e+3],ai[0]}var ci=new Float64Array([-0]),Se=new Uint8Array(ci.buffer);function S2(r,e,t){ci[0]=r,e[t]=Se[0],e[t+1]=Se[1],e[t+2]=Se[2],e[t+3]=Se[3],e[t+4]=Se[4],e[t+5]=Se[5],e[t+6]=Se[6],e[t+7]=Se[7]}function R2(r,e){return Se[0]=r[e],Se[1]=r[e+1],Se[2]=r[e+2],Se[3]=r[e+3],Se[4]=r[e+4],Se[5]=r[e+5],Se[6]=r[e+6],Se[7]=r[e+7],ci[0]}var v5=BigInt(Number.MAX_SAFE_INTEGER),E5=BigInt(Number.MIN_SAFE_INTEGER),De=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return nr;if(e<v5&&e>E5)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,s=e-(n<<32n);return t&&(n=~n|0n,s=~s|0n,++s>k2&&(s=0n,++n>k2&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(e){if(e===0)return nr;let t=e<0;t&&(e=-e);let n=e>>>0,s=(e-n)/4294967296>>>0;return t&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):nr}},nr=new De(0,0);nr.toBigInt=function(){return 0n};nr.zzEncode=nr.zzDecode=function(){return this};nr.length=function(){return 1};var k2=4294967296n;function N2(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function _2(r,e,t){if(t-e<1)return"";let s,i=[],o=0,a;for(;e<t;)a=r[e++],a<128?i[o++]=a:a>191&&a<224?i[o++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[o++]=55296+(a>>10),i[o++]=56320+(a&1023)):i[o++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,o>8191&&((s??(s=[])).push(String.fromCharCode.apply(String,i)),o=0);return s!=null?(o>0&&s.push(String.fromCharCode.apply(String,i.slice(0,o))),s.join("")):String.fromCharCode.apply(String,i.slice(0,o))}function li(r,e,t){let n=t,s,i;for(let o=0;o<r.length;++o)s=r.charCodeAt(o),s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&((i=r.charCodeAt(o+1))&64512)===56320?(s=65536+((s&1023)<<10)+(i&1023),++o,e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128);return t-n}function Ge(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Gn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var ui=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Ge(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Ge(this,4);return Gn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ge(this,4);return Gn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ge(this,4);let e=I2(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ge(this,4);let e=R2(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw Ge(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return _2(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Ge(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Ge(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new De(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw Ge(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Ge(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ge(this,8);let e=Gn(this.buf,this.pos+=4),t=Gn(this.buf,this.pos+=4);return new De(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=oi(this.buf,this.pos);return this.pos+=he(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function fi(r){return new ui(r instanceof Uint8Array?r:r.subarray())}function nt(r,e,t){let n=fi(r);return e.decode(n,void 0,t)}var mi={};ue(mi,{base10:()=>R5});var Mc=new Uint8Array(0);function L2(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function gt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function P2(r){return new TextEncoder().encode(r)}function C2(r){return new TextDecoder().decode(r)}function x5(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var s=0;s<r.length;s++){var i=r.charAt(s),o=i.charCodeAt(0);if(t[o]!==255)throw new TypeError(i+" is ambiguous");t[o]=s}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var d=0,g=0,y=0,v=p.length;y!==v&&p[y]===0;)y++,d++;for(var b=(v-y)*f+1>>>0,S=new Uint8Array(b);y!==v;){for(var x=p[y],I=0,N=b-1;(x!==0||I<g)&&N!==-1;N--,I++)x+=256*S[N]>>>0,S[N]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");g=I,y++}for(var T=b-g;T!==b&&S[T]===0;)T++;for(var G=c.repeat(d);T<b;++T)G+=r.charAt(S[T]);return G}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var d=0;if(p[d]!==" "){for(var g=0,y=0;p[d]===c;)g++,d++;for(var v=(p.length-d)*l+1>>>0,b=new Uint8Array(v);p[d];){var S=t[p.charCodeAt(d)];if(S===255)return;for(var x=0,I=v-1;(S!==0||x<y)&&I!==-1;I--,x++)S+=a*b[I]>>>0,b[I]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");y=x,d++}if(p[d]!==" "){for(var N=v-y;N!==v&&b[N]===0;)N++;for(var T=new Uint8Array(g+(v-N)),G=g;N!==v;)T[G++]=b[N++];return T}}}function m(p){var d=h(p);if(d)return d;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:h,decode:m}}var A5=x5,B5=A5,U2=B5;var hi=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},di=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return O2(this,e)}},pi=class{decoders;constructor(e){this.decoders=e}or(e){return O2(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function O2(r,e){return new pi({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var gi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,s){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=s,this.encoder=new hi(e,t,n),this.decoder=new di(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function xr({name:r,prefix:e,encode:t,decode:n}){return new gi(r,e,t,n)}function Mt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:s}=U2(t,r);return xr({prefix:e,name:r,encode:n,decode:i=>gt(s(i))})}function I5(r,e,t,n){let s={};for(let f=0;f<e.length;++f)s[e[f]]=f;let i=r.length;for(;r[i-1]==="=";)--i;let o=new Uint8Array(i*t/8|0),a=0,c=0,l=0;for(let f=0;f<i;++f){let u=s[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|u,a+=t,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o}function S5(r,e,t){let n=e[e.length-1]==="=",s=(1<<t)-1,i="",o=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],o+=8;o>t;)o-=t,i+=e[s&a>>o];if(o!==0&&(i+=e[s&a<<t-o]),n)for(;i.length*t&7;)i+="=";return i}function ie({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return xr({prefix:e,name:r,encode(s){return S5(s,n,t)},decode(s){return I5(s,n,t,r)}})}var R5=Mt({prefix:"9",name:"base10",alphabet:"0123456789"});var yi={};ue(yi,{base16:()=>k5,base16upper:()=>N5});var k5=ie({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),N5=ie({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var bi={};ue(bi,{base2:()=>_5});var _5=ie({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wi={};ue(wi,{base256emoji:()=>D5});var V2=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}"),T5=V2.reduce((r,e,t)=>(r[t]=e,r),[]),L5=V2.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function P5(r){return r.reduce((e,t)=>(e+=T5[t],e),"")}function C5(r){let e=[];for(let t of r){let n=L5[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var D5=xr({prefix:"\u{1F680}",name:"base256emoji",encode:P5,decode:C5});var vi={};ue(vi,{base32:()=>mt,base32hex:()=>F5,base32hexpad:()=>H5,base32hexpadupper:()=>K5,base32hexupper:()=>M5,base32pad:()=>O5,base32padupper:()=>V5,base32upper:()=>U5,base32z:()=>q5});var mt=ie({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),U5=ie({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),O5=ie({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),V5=ie({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),F5=ie({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),M5=ie({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),H5=ie({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),K5=ie({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),q5=ie({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ei={};ue(Ei,{base36:()=>$5,base36upper:()=>z5});var $5=Mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),z5=Mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xi={};ue(xi,{base58btc:()=>ge,base58flickr:()=>G5});var ge=Mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),G5=Mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ai={};ue(Ai,{base64:()=>cn,base64pad:()=>j5,base64url:()=>Y5,base64urlpad:()=>W5});var cn=ie({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j5=ie({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Y5=ie({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),W5=ie({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Bi={};ue(Bi,{base8:()=>Z5});var Z5=ie({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ii={};ue(Ii,{identity:()=>Q5});var Q5=xr({prefix:"\0",name:"identity",encode:r=>C2(r),decode:r=>P2(r)});var r9=new TextEncoder,n9=new TextDecoder;var Ri={};ue(Ri,{identity:()=>Ht});var e6=H2,F2=128,t6=127,r6=~t6,n6=Math.pow(2,31);function H2(r,e,t){e=e||[],t=t||0;for(var n=t;r>=n6;)e[t++]=r&255|F2,r/=128;for(;r&r6;)e[t++]=r&255|F2,r>>>=7;return e[t]=r|0,H2.bytes=t-n+1,e}var s6=Si,i6=128,M2=127;function Si(r,n){var t=0,n=n||0,s=0,i=n,o,a=r.length;do{if(i>=a)throw Si.bytes=0,new RangeError("Could not decode varint");o=r[i++],t+=s<28?(o&M2)<<s:(o&M2)*Math.pow(2,s),s+=7}while(o>=i6);return Si.bytes=i-n,t}var o6=Math.pow(2,7),a6=Math.pow(2,14),c6=Math.pow(2,21),l6=Math.pow(2,28),u6=Math.pow(2,35),f6=Math.pow(2,42),h6=Math.pow(2,49),d6=Math.pow(2,56),p6=Math.pow(2,63),g6=function(r){return r<o6?1:r<a6?2:r<c6?3:r<l6?4:r<u6?5:r<f6?6:r<h6?7:r<d6?8:r<p6?9:10},m6={encode:e6,decode:s6,encodingLength:g6},y6=m6,ln=y6;function un(r,e=0){return[ln.decode(r,e),ln.decode.bytes]}function Ar(r,e,t=0){return ln.encode(r,e,t),e}function Br(r){return ln.encodingLength(r)}function st(r,e){let t=e.byteLength,n=Br(r),s=n+Br(t),i=new Uint8Array(s+t);return Ar(r,i,0),Ar(t,i,n),i.set(e,s),new Ir(r,t,e,i)}function sr(r){let e=gt(r),[t,n]=un(e),[s,i]=un(e.subarray(n)),o=e.subarray(n+i);if(o.byteLength!==s)throw new Error("Incorrect length");return new Ir(t,s,o,e)}function K2(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&L2(r.bytes,t.bytes)}}var Ir=class{code;size;digest;bytes;constructor(e,t,n,s){this.code=e,this.size=t,this.digest=n,this.bytes=s}};var q2=0,b6="identity",$2=gt;function w6(r){return st(q2,$2(r))}var Ht={code:q2,name:b6,encode:$2,digest:w6};var _i={};ue(_i,{sha256:()=>ne,sha512:()=>v6});function Ni({name:r,code:e,encode:t}){return new ki(r,e,t)}var ki=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?st(this.code,t):t.then(n=>st(this.code,n))}else throw Error("Unknown type, must be binary type")}};function G2(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var ne=Ni({name:"sha2-256",code:18,encode:G2("SHA-256")}),v6=Ni({name:"sha2-512",code:19,encode:G2("SHA-512")});function j2(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return x6(t,Ti(r),e??ge.encoder);default:return A6(t,Ti(r),e??mt.encoder)}}var Y2=new WeakMap;function Ti(r){let e=Y2.get(r);if(e==null){let t=new Map;return Y2.set(r,t),t}return e}var _e=class r{code;version;multihash;bytes;"/";constructor(e,t,n,s){this.code=t,this.version=e,this.multihash=n,this.bytes=s,this["/"]=s}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==fn)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==B6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=st(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&K2(e.multihash,n.multihash)}toString(e){return j2(this,e)}toJSON(){return{"/":j2(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:s,multihash:i,bytes:o}=t;return new r(n,s,i,o??W2(n,s,i.bytes))}else if(t[I6]===!0){let{version:n,multihash:s,code:i}=t,o=sr(s);return r.create(n,i,o)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==fn)throw new Error(`Version 0 CID must use dag-pb (code: ${fn}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let s=W2(e,t,n.bytes);return new r(e,t,n,s)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,fn,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,s=gt(e.subarray(n,n+t.multihashSize));if(s.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=s.subarray(t.multihashSize-t.digestSize),o=new Ir(t.multihashCode,t.digestSize,i,s);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[u,h]=un(e.subarray(t));return t+=h,u},s=n(),i=fn;if(s===18?(s=0,t=0):i=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let o=t,a=n(),c=n(),l=t+c,f=l-o;return{version:s,codec:i,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(e,t){let[n,s]=E6(e,t),i=r.decode(s);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ti(i).set(n,e),i}};function E6(r,e){switch(r[0]){case"Q":{let t=e??ge;return[ge.prefix,t.decode(`${ge.prefix}${r}`)]}case ge.prefix:{let t=e??ge;return[ge.prefix,t.decode(r)]}case mt.prefix:{let t=e??mt;return[mt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function x6(r,e,t){let{prefix:n}=t;if(n!==ge.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let s=e.get(n);if(s==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return s}function A6(r,e,t){let{prefix:n}=t,s=e.get(n);if(s==null){let i=t.encode(r);return e.set(n,i),i}else return s}var fn=112,B6=18;function W2(r,e,t){let n=Br(r),s=n+Br(e),i=new Uint8Array(s+t.byteLength);return Ar(r,i,0),Ar(e,i,n),i.set(t,s),i}var I6=Symbol.for("@ipld/js-cid/CID");var Kt={...Ii,...bi,...Bi,...mi,...yi,...vi,...Ei,...xi,...Ai,...wi},B9={..._i,...Ri};function Q2(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Z2=Q2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Li=Q2("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=be(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),S6={utf8:Z2,"utf-8":Z2,hex:Kt.base16,latin1:Li,ascii:Li,binary:Li,...Kt},Yn=S6;function z(r,e="utf8"){let t=Yn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?rt(globalThis.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}function Pi(r){let e=r??8192,t=e>>>1,n,s=e;return function(o){if(o<1||o>t)return be(o);s+o>e&&(n=be(e),s=0);let a=n.subarray(s,s+=o);return s&7&&(s=(s|7)+1),a}}var or=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ci(){}var Ui=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},R6=Pi();function k6(r){return globalThis.Buffer!=null?be(r):R6(r)}var dn=class{len;head;tail;states;constructor(){this.len=0,this.head=new or(Ci,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new or(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Oi((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Wn,10,De.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=De.fromBigInt(e);return this._push(Wn,t.length(),t)}uint64Number(e){return this._push(ii,he(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=De.fromBigInt(e).zzEncode();return this._push(Wn,t.length(),t)}sint64Number(e){let t=De.fromNumber(e).zzEncode();return this._push(Wn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Di,1,e?1:0)}fixed32(e){return this._push(hn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=De.fromBigInt(e);return this._push(hn,4,t.lo)._push(hn,4,t.hi)}fixed64Number(e){let t=De.fromNumber(e);return this._push(hn,4,t.lo)._push(hn,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(B2,4,e)}double(e){return this._push(S2,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Di,1,0):this.uint32(t)._push(_6,t,e)}string(e){let t=N2(e);return t!==0?this.uint32(t)._push(li,t,e):this._push(Di,1,0)}fork(){return this.states=new Ui(this),this.head=this.tail=new or(Ci,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 or(Ci,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=k6(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Di(r,e,t){e[t]=r&255}function N6(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Oi=class extends or{next;constructor(e,t){super(N6,e,t),this.next=void 0}};function Wn(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function hn(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function _6(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(dn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(T6,e,r),this},dn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(L6,e,r),this});function T6(r,e,t){e.set(r,t)}function L6(r,e,t){r.length<40?li(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(z(r),t)}function Vi(){return new dn}function it(r,e){let t=Vi();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var Sr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(Sr||(Sr={}));function Zn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Rr(r){function e(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let t=function(i,o){let a=e(i);o.int32(a)},n=function(i){let o=i.int32();return e(o)};return Zn("enum",Sr.VARINT,t,n)}function ot(r,e){return Zn("message",Sr.LENGTH_DELIMITED,r,e)}var pn=class extends Error{code;constructor(e,t,n){super(e,n),this.code=t}};var X2;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.key!=null&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&(n.uint32(18),n.bytes(t.value)),t.author!=null&&(n.uint32(26),n.bytes(t.author)),t.signature!=null&&(n.uint32(34),n.bytes(t.signature)),t.timeReceived!=null&&(n.uint32(42),n.string(t.timeReceived)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:{s.key=t.bytes();break}case 2:{s.value=t.bytes();break}case 3:{s.author=t.bytes();break}case 4:{s.signature=t.bytes();break}case 5:{s.timeReceived=t.string();break}default:{t.skipType(o&7);break}}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(X2||(X2={}));var F;(function(r){r.PUT_VALUE="PUT_VALUE",r.GET_VALUE="GET_VALUE",r.ADD_PROVIDER="ADD_PROVIDER",r.GET_PROVIDERS="GET_PROVIDERS",r.FIND_NODE="FIND_NODE",r.PING="PING"})(F||(F={}));var Qn;(function(r){r[r.PUT_VALUE=0]="PUT_VALUE",r[r.GET_VALUE=1]="GET_VALUE",r[r.ADD_PROVIDER=2]="ADD_PROVIDER",r[r.GET_PROVIDERS=3]="GET_PROVIDERS",r[r.FIND_NODE=4]="FIND_NODE",r[r.PING=5]="PING"})(Qn||(Qn={}));(function(r){r.codec=()=>Rr(Qn)})(F||(F={}));var Nr;(function(r){r.NOT_CONNECTED="NOT_CONNECTED",r.CONNECTED="CONNECTED",r.CAN_CONNECT="CAN_CONNECT",r.CANNOT_CONNECT="CANNOT_CONNECT"})(Nr||(Nr={}));var Fi;(function(r){r[r.NOT_CONNECTED=0]="NOT_CONNECTED",r[r.CONNECTED=1]="CONNECTED",r[r.CAN_CONNECT=2]="CAN_CONNECT",r[r.CANNOT_CONNECT=3]="CANNOT_CONNECT"})(Fi||(Fi={}));(function(r){r.codec=()=>Rr(Fi)})(Nr||(Nr={}));var kr;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),t.id!=null&&t.id.byteLength>0&&(n.uint32(10),n.bytes(t.id)),t.multiaddrs!=null)for(let i of t.multiaddrs)n.uint32(18),n.bytes(i);t.connection!=null&&(n.uint32(24),Nr.codec().encode(t.connection,n)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={id:ze(0),multiaddrs:[]},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:{s.id=t.bytes();break}case 2:{s.multiaddrs.push(t.bytes());break}case 3:{s.connection=Nr.codec().decode(t);break}default:{t.skipType(o&7);break}}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(kr||(kr={}));var He;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),t.type!=null&&Qn[t.type]!==0&&(n.uint32(8),F.codec().encode(t.type,n)),t.clusterLevel!=null&&(n.uint32(80),n.int32(t.clusterLevel)),t.key!=null&&(n.uint32(18),n.bytes(t.key)),t.record!=null&&(n.uint32(26),n.bytes(t.record)),t.closer!=null)for(let i of t.closer)n.uint32(66),kr.codec().encode(i,n);if(t.providers!=null)for(let i of t.providers)n.uint32(74),kr.codec().encode(i,n);s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={type:F.PUT_VALUE,closer:[],providers:[]},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:{s.type=F.codec().decode(t);break}case 10:{s.clusterLevel=t.int32();break}case 2:{s.key=t.bytes();break}case 3:{s.record=t.bytes();break}case 8:{s.closer.push(kr.codec().decode(t,t.uint32()));break}case 9:{s.providers.push(kr.codec().decode(t,t.uint32()));break}default:{t.skipType(o&7);break}}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(He||(He={}));function Mi(r,e={}){let t={...r,name:"SEND_QUERY",type:0,messageName:r.type,messageType:F[r.type]};return e.onProgress?.(new Ne("kad-dht:query:send-query",{detail:t})),t}function gn(r,e={}){let t={...r,name:"PEER_RESPONSE",type:1,messageName:r.messageType,closer:r.closer!=null?r.closer:[],providers:r.providers!=null?r.providers:[]};return e.onProgress?.(new Ne("kad-dht:query:peer-response",{detail:t})),t}function Xn(r,e={}){let t={...r,name:"FINAL_PEER",type:2};return e.onProgress?.(new Ne("kad-dht:query:final-peer",{detail:t})),t}function Ue(r,e={}){let t={...r,name:"QUERY_ERROR",type:3};return e.onProgress?.(new Ne("kad-dht:query:query-error",{detail:t})),t}function Hi(r,e={}){let t={...r,name:"PROVIDER",type:4};return e.onProgress?.(new Ne("kad-dht:query:provider",{detail:t})),t}function mn(r,e={}){let t={...r,name:"VALUE",type:5};return e.onProgress?.(new Ne("kad-dht:query:value",{detail:t})),t}function Ki(r,e={}){let t={...r,name:"DIAL_PEER",type:7};return e.onProgress?.(new Ne("kad-dht:query:dial-peer",{detail:t})),t}var yn;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.key!=null&&t.key.byteLength>0&&(n.uint32(10),n.bytes(t.key)),t.value!=null&&t.value.byteLength>0&&(n.uint32(18),n.bytes(t.value)),t.timeReceived!=null&&t.timeReceived!==""&&(n.uint32(42),n.string(t.timeReceived)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={key:new Uint8Array(0),value:new Uint8Array(0),timeReceived:""},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:s.key=t.bytes();break;case 2:s.value=t.bytes();break;case 5:s.timeReceived=t.string();break;default:t.skipType(o&7);break}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(yn||(yn={}));function J2(r){let e=r.getUTCFullYear(),t=String(r.getUTCMonth()+1).padStart(2,"0"),n=String(r.getUTCDate()).padStart(2,"0"),s=String(r.getUTCHours()).padStart(2,"0"),i=String(r.getUTCMinutes()).padStart(2,"0"),o=String(r.getUTCSeconds()).padStart(2,"0"),a=r.getUTCMilliseconds(),c=String(a*1e3*1e3).padStart(9,"0");return`${e}-${t}-${n}T${s}:${i}:${o}.${c}Z`}function e0(r){let e=new RegExp("(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})\\.(\\d+)Z"),t=String(r).trim().match(e);if(t==null)throw new Error("Invalid format");let n=parseInt(t[1],10),s=parseInt(t[2],10)-1,i=parseInt(t[3],10),o=parseInt(t[4],10),a=parseInt(t[5],10),c=parseInt(t[6],10),l=parseInt(t[7].slice(0,-6),10);return new Date(Date.UTC(n,s,i,o,a,c,l))}var me=class r{key;value;timeReceived;constructor(e,t,n){if(!(e instanceof Uint8Array))throw new Error("key must be a Uint8Array");if(!(t instanceof Uint8Array))throw new Error("value must be a Uint8Array");this.key=e,this.value=t,this.timeReceived=n}serialize(){return yn.encode(this.prepareSerialize())}prepareSerialize(){return{key:this.key,value:this.value,timeReceived:J2(this.timeReceived)}}static deserialize(e){let t=yn.decode(e);return new r(t.key,t.value,new Date(t.timeReceived))}static fromDeserialized(e){let t=e0(e.timeReceived);if(e.key==null)throw new Error("key missing from deserialized object");if(e.value==null)throw new Error("value missing from deserialized object");return new r(e.key,e.value,t)}};function L(r,e="utf8"){let t=Yn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}function t0(r,e,t){if(t.length===0){let o="No records given";throw new E(o,"ERR_NO_RECORDS_RECEIVED")}let s=L(e).split("/");if(s.length<3){let o="Record key does not have a selector function";throw new E(o,"ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY")}let i=r[s[1].toString()];if(i==null){let o=`No selector function configured for key type "${s[1]}"`;throw new E(o,"ERR_UNRECOGNIZED_KEY_PREFIX")}return t.length===1?0:i(e,t)}function C6(r,e){return 0}var r0={pk:C6};async function _r(r,e){let t=e.key,s=L(t).split("/");if(s.length<3)return;let i=r[s[1].toString()];if(i==null){let o=`No validator available for key type "${s[1]}"`;throw new E(o,"ERR_INVALID_RECORD_KEY_TYPE")}await i(t,e.value)}var D6=async(r,e)=>{if(!(r instanceof Uint8Array))throw new E('"key" must be a Uint8Array',"ERR_INVALID_RECORD_KEY_NOT_BUFFER");if(r.byteLength<5)throw new E("invalid public key record","ERR_INVALID_RECORD_KEY_TOO_SHORT");if(L(r.subarray(0,4))!=="/pk/")throw new E("key was not prefixed with /pk/","ERR_INVALID_RECORD_KEY_BAD_PREFIX");let n=r.slice(4),s=await ne.digest(e);if(!Q(n,s.bytes))throw new E("public key does not match passed in key","ERR_INVALID_RECORD_HASH_MISMATCH")},n0={pk:D6};var U6=Symbol.for("nodejs.util.inspect.custom"),s0=Object.values(Kt).map(r=>r.decoder).reduce((r,e)=>r.or(e),Kt.identity.decoder),i0=114,qi=36,$i=37,bn=class{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[y2]=!0;toString(){return this.string==null&&(this.string=ge.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return _e.createV1(i0,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Q(this.multihash.bytes,e);if(typeof e=="string")return ar(e).equals(this);if(e?.multihash?.bytes!=null)return Q(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[U6](){return`PeerId(${this.toString()})`}},Tr=class extends bn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Lr=class extends bn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}},Pr=class extends bn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}};function ar(r,e){if(e=e??s0,r.charAt(0)==="1"||r.charAt(0)==="Q"){let t=sr(ge.decode(`z${r}`));return r.startsWith("12D")?new Lr({multihash:t}):r.startsWith("16U")?new Pr({multihash:t}):new Tr({multihash:t})}return yt(s0.decode(r))}function yt(r){try{let e=sr(r);if(e.code===Ht.code){if(e.digest.length===qi)return new Lr({multihash:e});if(e.digest.length===$i)return new Pr({multihash:e})}if(e.code===ne.code)return new Tr({multihash:e})}catch{return O6(_e.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function O6(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==i0)throw new Error("Supplied PeerID CID is invalid");let e=r.multihash;if(e.code===ne.code)return new Tr({multihash:r.multihash});if(e.code===Ht.code){if(e.digest.length===qi)return new Lr({multihash:r.multihash});if(e.digest.length===$i)return new Pr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function o0(r,e){return r.length===qi?new Lr({multihash:st(Ht.code,r),privateKey:e}):r.length===$i?new Pr({multihash:st(Ht.code,r),privateKey:e}):new Tr({multihash:await ne.digest(r),publicKey:r,privateKey:e})}var Jn=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,s){return this.readAtomically(()=>{let i=0,o=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*s)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let h=Number.parseInt(u,e);if(!Number.isNaN(h))return h});if(f===void 0)break;if(i*=e,i+=f,i>l||(o+=1,t!==void 0&&o>t))return}if(o!==0)return!n&&c&&o>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let s=n*2;if(n<t.length-3){let o=this.readSeparator(":",n,()=>this.readIPv4Addr());if(o!==void 0)return t[s]=o[0],t[s+1]=o[1],t[s+2]=o[2],t[s+3]=o[3],[s+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[s,!1];t[s]=i>>8,t[s+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,s]=e(t);if(n===16)return t;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),o=16-(n+2),[a]=e(i.subarray(0,o));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var a0=45,V6=15,Cr=new Jn;function zi(r){if(!(r.length>V6))return Cr.new(r).parseWith(()=>Cr.readIPv4Addr())}function Gi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>a0))return Cr.new(r).parseWith(()=>Cr.readIPv6Addr())}function e1(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>a0))return Cr.new(r).parseWith(()=>Cr.readIPAddr())}function t1(r){return!!zi(r)}function r1(r){return!!Gi(r)}function n1(r){return!!e1(r)}var l0=on(c0(),1),F6=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],M6=F6.map(r=>new l0.Netmask(r));function H6(r){for(let e of M6)if(e.contains(r))return!0;return!1}function K6(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function s1(r){return t1(r)?H6(r):r1(r)?K6(r):void 0}var bt="/",u0=new TextEncoder().encode(bt),i1=u0[0],Dr=class r{_buf;constructor(e,t){if(typeof e=="string")this._buf=z(e);else if(e instanceof Uint8Array)this._buf=e;else throw new Error("Invalid key, should be String of Uint8Array");if(t==null&&(t=!0),t&&this.clean(),this._buf.byteLength===0||this._buf[0]!==i1)throw new Error("Invalid key")}toString(e="utf8"){return L(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new r(e.join(bt))}static random(){return new r(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||typeof e=="string"?new r(e):typeof e.uint8Array=="function"?new r(e.uint8Array()):null}clean(){if((this._buf==null||this._buf.byteLength===0)&&(this._buf=u0),this._buf[0]!==i1){let e=new Uint8Array(this._buf.byteLength+1);e.fill(i1,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===i1;)this._buf=this._buf.subarray(0,-1)}less(e){let t=this.list(),n=e.list();for(let s=0;s<t.length;s++){if(n.length<s+1)return!1;let i=t[s],o=n[s];if(i<o)return!0;if(i>o)return!1}return t.length<n.length}reverse(){return r.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){let e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(bt).slice(1)}type(){return q6(this.baseNamespace())}name(){return $6(this.baseNamespace())}instance(e){return new r(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(bt)||(e+=bt),e+=this.type(),new r(e)}parent(){let e=this.list();return e.length===1?new r(bt):new r(e.slice(0,-1).join(bt))}child(e){return this.toString()===bt?e:e.toString()===bt?this:new r(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()===this.toString()?!1:e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()===this.toString()?!1:this.toString().startsWith(e.toString())}isTopLevel(){return this.list().length===1}concat(...e){return r.withNamespaces([...this.namespaces(),...z6(e.map(t=>t.namespaces()))])}};function q6(r){let e=r.split(":");return e.length<2?"":e.slice(0,-1).join(":")}function $6(r){let e=r.split(":");return e[e.length-1]}function z6(r){return[].concat(...r)}function J(r,e){if(globalThis.Buffer!=null)return rt(globalThis.Buffer.concat(r,e));e==null&&(e=r.reduce((s,i)=>s+i.length,0));let t=be(e),n=0;for(let s of r)t.set(s,n),n+=s.length;return rt(t)}var G6=z("/pk/");function o1(r){return{...r,multiaddrs:r.multiaddrs.filter(e=>{let[[t,n]]=e.stringTuples();if(t===53||t===54||t===55)return n!=="localhost";if(t!==4&&t!==6||n==null)return!1;let s=s1(n);return s==null?!0:!s})}}function f0(r){return{...r,multiaddrs:r.multiaddrs.filter(e=>{let[[t,n]]=e.stringTuples();if(n==="localhost")return!0;if(t!==4&&t!==6||n==null)return!1;let s=s1(n);return s??!1})}}function h0(r){return r}async function qt(r){return(await ne.digest(r)).digest}async function je(r){return qt(r.toBytes())}function wt(r){return new Dr(`${v2}/${L(r,"base32")}`,!1)}function d0(r){return J([G6,r.toBytes()])}function p0(r){return L(r.subarray(0,4))==="/pk/"}function g0(r){return yt(r.subarray(4))}function ji(r,e){let t=new Date;return new me(r,e,t).serialize()}function m0(r,e=100){let t;return()=>{clearTimeout(t),t=setTimeout(()=>{r()},e)}}var j6=290,Y6=54,W6=55,Z6=56,Q6=4,X6=41;function y0(r){let e=r.stringTuples();for(let t of e)if(t[0]===j6)return!1;if(e[0][0]===Y6||e[0][0]===W6||e[0][0]===Z6)return!0;if(e[0][0]===Q6||e[0][0]===X6){let t=s1(`${e[0][1]}`);return t==null||!t}return!1}var a1=class{log;components;validators;selectors;peerRouting;queryManager;network;constructor(e,t){let{validators:n,selectors:s,peerRouting:i,queryManager:o,network:a,logPrefix:c}=t;this.components=e,this.log=e.logger.forComponent(`${c}:content-fetching`),this.validators=n,this.selectors=s,this.peerRouting=i,this.queryManager=o,this.network=a}async putLocal(e,t){let n=wt(e);await this.components.datastore.put(n,t)}async getLocal(e){this.log("getLocal %b",e);let t=wt(e);this.log("fetching record for key %k",t);let n=await this.components.datastore.get(t);this.log("found %k in local datastore",t);let s=me.deserialize(n);return await _r(this.validators,s),s}async*sendCorrectionRecord(e,t,n,s={}){this.log("sendCorrection for %b",e);let i=ji(e,n);for(let{value:o,from:a}of t){if(Q(o,n)){this.log("record was ok");continue}if(this.components.peerId.equals(a)){try{let f=wt(e);this.log(`Storing corrected record for key ${f.toString()}`),await this.components.datastore.put(f,i.subarray())}catch(f){this.log.error("Failed error correcting self",f)}continue}let c=!1,l={type:F.PUT_VALUE,key:e,record:i};for await(let f of this.network.sendRequest(a,l,s))f.name==="PEER_RESPONSE"&&f.record!=null&&Q(f.record.value,me.deserialize(i).value)&&(c=!0),yield f;c||(yield Ue({from:a,error:new E("value not put correctly","ERR_PUT_VALUE_INVALID")},s)),this.log.error("Failed error correcting entry")}}async*put(e,t,n={}){this.log("put key %b value %b",e,t);let s=ji(e,t),i=wt(e);this.log(`storing record for key ${i.toString()}`),await this.components.datastore.put(i,s.subarray()),yield*Vt(this.peerRouting.getClosestPeers(e,{signal:n.signal}),o=>Kn(o,a=>async()=>{if(a.name!=="FINAL_PEER")return[a];let c=[],l={type:F.PUT_VALUE,key:e,record:s};this.log("send put to %p",a.peer.id);for await(let f of this.network.sendRequest(a.peer.id,l,n))c.push(f),f.name==="PEER_RESPONSE"&&(f.record!=null&&Q(f.record.value,me.deserialize(s).value)||c.push(Ue({from:a.peer.id,error:new E("value not put correctly","ERR_PUT_VALUE_INVALID")},n)));return c}),o=>an(o,{ordered:!1,concurrency:3}),async function*(o){for await(let a of o)yield*a})}async*get(e,t={}){this.log("get %b",e);let n=[];for await(let a of this.getMany(e,t))a.name==="VALUE"&&n.push(a),yield a;if(n.length===0)return;let s=n.map(a=>a.value),i=0;try{i=t0(this.selectors,e,s)}catch(a){if(a.code!=="ERR_NO_SELECTOR_FUNCTION_FOR_RECORD_KEY")throw a}let o=s[i];if(this.log("GetValue %b %b",e,o),o==null)throw new E("best value was not found","ERR_NOT_FOUND");yield*this.sendCorrectionRecord(e,n,o,t),yield n[i]}async*getMany(e,t={}){this.log("getMany values for %b",e);try{let i=await this.getLocal(e);yield mn({value:i.value,from:this.components.peerId},t)}catch(i){this.log("error getting local value for %b",e,i)}let n=this,s=async function*({peer:i,signal:o}){for await(let a of n.peerRouting.getValueOrPeers(i,e,{signal:o}))yield a,a.name==="PEER_RESPONSE"&&a.record!=null&&(yield mn({from:i,value:a.record.value},t))};yield*this.queryManager.run(e,s,t)}};function Zi(r,e){let t={[Symbol.iterator]:()=>t,next:()=>{let n=r.next(),s=n.value;return n.done===!0||s==null?{done:!0,value:void 0}:{done:!1,value:e(s)}}};return t}var at=class r{set;constructor(e){if(this.set=new Set,e!=null)for(let t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return Zi(this.set.entries(),e=>{let t=ar(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{let n=ar(t);e(n,n,this)})}has(e){return this.set.has(e.toString())}values(){return Zi(this.set.values(),e=>ar(e))}intersection(e){let t=new r;for(let n of e)this.has(n)&&t.add(n);return t}difference(e){let t=new r;for(let n of this)e.has(n)||t.add(n);return t}union(e){let t=new r;for(let n of e)t.add(n);for(let n of this)t.add(n);return t}};var Au=parseInt("0xFFFF",16),Bu=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var v0=t1,n8=r1,Qi=function(r){let e=0;if(r=r.toString().trim(),v0(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(n8(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=v0(t[n]),o;i&&(o=Qi(t[n]),t[n]=L(o.slice(0,2),"base16")),o!=null&&++n<8&&t.splice(n,0,L(o.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let s=new Uint8Array(e+16);for(n=0;n<t.length;n++){let i=parseInt(t[n],16);s[e++]=i>>8&255,s[e++]=i&255}return s}throw new Error("invalid ip address")},E0=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let s=[];for(let i=0;i<t;i++)s.push(r[e+i]);return s.join(".")}if(t===16){let s=[];for(let i=0;i<t;i+=2)s.push(n.getUint16(e+i).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Ur={},Xi={},i8=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];i8.forEach(r=>{let e=o8(...r);Xi[e.code]=e,Ur[e.name]=e});function o8(r,e,t,n,s){return{code:r,size:e,name:t,resolvable:!!n,path:!!s}}function W(r){if(typeof r=="number"){if(Xi[r]!=null)return Xi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Ur[r]!=null)return Ur[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var of=W("ip4"),af=W("ip6"),cf=W("ipcidr");function eo(r,e){switch(W(r).code){case 4:case 41:return c8(e);case 42:return B0(e);case 6:case 273:case 33:case 132:return S0(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return B0(e);case 421:return h8(e);case 444:return I0(e);case 445:return I0(e);case 466:return f8(e);default:return L(e,"base16")}}function to(r,e){switch(W(r).code){case 4:return x0(e);case 41:return x0(e);case 42:return A0(e);case 6:case 273:case 33:case 132:return ro(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return A0(e);case 421:return l8(e);case 444:return d8(e);case 445:return p8(e);case 466:return u8(e);default:return z(e,"base16")}}var Ji=Object.values(Kt).map(r=>r.decoder),a8=function(){let r=Ji[0].or(Ji[1]);return Ji.slice(2).forEach(e=>r=r.or(e)),r}();function x0(r){if(!n1(r))throw new Error("invalid ip address");return Qi(r)}function c8(r){let e=E0(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!n1(e))throw new Error("invalid ip address");return e}function ro(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function S0(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function A0(r){let e=z(r),t=Uint8Array.from(Me(e.length));return J([t,e],t.length+e.length)}function B0(r){let e=Ce(r);if(r=r.slice(he(e)),r.length!==e)throw new Error("inconsistent lengths");return L(r)}function l8(r){let e;r[0]==="Q"||r[0]==="1"?e=sr(ge.decode(`z${r}`)).bytes:e=_e.parse(r).multihash.bytes;let t=Uint8Array.from(Me(e.length));return J([t,e],t.length+e.length)}function u8(r){let e=a8.decode(r),t=Uint8Array.from(Me(e.length));return J([t,e],t.length+e.length)}function f8(r){let e=Ce(r),t=r.slice(he(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+L(t,"base64url")}function h8(r){let e=Ce(r),t=r.slice(he(e));if(t.length!==e)throw new Error("inconsistent lengths");return L(t,"base58btc")}function d8(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=mt.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ro(n);return J([t,s],t.length+s.length)}function p8(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=mt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ro(n);return J([t,s],t.length+s.length)}function I0(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=L(e,"base32"),s=S0(t);return`${n}:${s}`}function R0(r){r=no(r);let e=[],t=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<s.length;i++){let o=s[i],a=W(o);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=s.length)throw N0("invalid address: "+r);if(a.path===!0){n=no(s.slice(i).join("/")),e.push([a.code,to(a.code,n)]),t.push([a.code,n]);break}let c=to(a.code,s[i]);e.push([a.code,c]),t.push([a.code,eo(a.code,c)])}return{string:k0(t),bytes:io(e),tuples:e,stringTuples:t,path:n}}function so(r){let e=[],t=[],n=null,s=0;for(;s<r.length;){let i=Ce(r,s),o=he(i),a=W(i),c=g8(a,r.slice(s+o));if(c===0){e.push([i]),t.push([i]),s+=o;continue}let l=r.slice(s+o,s+o+c);if(s+=c+o,s>r.length)throw N0("Invalid address Uint8Array: "+L(r,"base16"));e.push([i,l]);let f=eo(i,l);if(t.push([i,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:k0(t),tuples:e,stringTuples:t,path:n}}function k0(r){let e=[];return r.map(t=>{let n=W(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),no(e.join("/"))}function io(r){return J(r.map(e=>{let t=W(e[0]),n=Uint8Array.from(Me(t.code));return e.length>1&&e[1]!=null&&(n=J([n,e[1]])),n}))}function g8(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=Ce(e instanceof Uint8Array?e:Uint8Array.from(e));return t+he(t)}}function no(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function N0(r){return new Error("Error parsing address: "+r)}var m8=Symbol.for("nodejs.util.inspect.custom"),oo=Symbol.for("@multiformats/js-multiaddr/multiaddr"),y8=[W("dns").code,W("dns4").code,W("dns6").code,W("dnsaddr").code],c1=class r{bytes;#e;#r;#i;#a;[oo]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=so(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=R0(e)}else if(T0(e))t=so(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#i=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,s,i="",o=W("tcp"),a=W("udp"),c=W("ip4"),l=W("ip6"),f=W("dns6"),u=W("ip6zone");for(let[m,p]of this.stringTuples())m===u.code&&(i=`%${p??""}`),y8.includes(m)&&(t=o.name,s=443,n=`${p??""}${i}`,e=m===f.code?6:4),(m===o.code||m===a.code)&&(t=W(m).name,s=parseInt(p??"")),(m===c.code||m===l.code)&&(t=W(m).name,n=`${p??""}${i}`,e=m===l.code?6:4);if(e==null||t==null||n==null||s==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:s}}protos(){return this.#r.map(([e])=>Object.assign({},W(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>W(e).name)}tuples(){return this.#r}stringTuples(){return this.#i}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),s=n.lastIndexOf(t);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,s))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(io(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,s])=>{n===Ur.p2p.code&&e.push([n,s]),n===Ur["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?L(ge.decode(`z${n}`),"base58btc"):L(_e.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return Q(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=_0.get(t.name);if(n==null)throw new E(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(i=>new r(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[m8](){return`Multiaddr(${this.#e})`}};var _0=new Map;function T0(r){return!!r?.[oo]}function vn(r){return new c1(r)}function L0(r,e){return{id:r.id.toBytes(),multiaddrs:(r.multiaddrs??[]).map(n=>n.bytes),connection:e}}function En(r){if(r.id==null)throw new Error("Invalid peer in message");return{id:yt(r.id),multiaddrs:(r.multiaddrs??[]).map(e=>vn(e))}}var l1=class{log;components;network;peerRouting;queryManager;routingTable;providers;constructor(e,t){let{network:n,peerRouting:s,queryManager:i,routingTable:o,providers:a,logPrefix:c}=t;this.components=e,this.log=e.logger.forComponent(`${c}:content-routing`),this.network=n,this.peerRouting=s,this.queryManager=i,this.routingTable=o,this.providers=a}async*provide(e,t,n={}){this.log("provide %s",e),await this.providers.addProvider(e,this.components.peerId);let s={type:F.ADD_PROVIDER,key:e.multihash.bytes,providers:[L0({id:this.components.peerId,multiaddrs:t})]},i=0,o=a=>async()=>{if(a.name!=="FINAL_PEER")return[a];let c=[];this.log("putProvider %s to %p",e,a.peer.id);try{this.log("sending provider record for %s to %p",e,a.peer.id);for await(let l of this.network.sendMessage(a.peer.id,s,n))l.name==="PEER_RESPONSE"&&(this.log("sent provider record for %s to %p",e,a.peer.id),i++),c.push(l)}catch(l){this.log.error("error sending provide record to peer %p",a.peer.id,l),c.push(Ue({from:a.peer.id,error:l},n))}return c};yield*Vt(this.peerRouting.getClosestPeers(e.multihash.bytes,n),a=>Kn(a,c=>o(c)),a=>an(a,{ordered:!1,concurrency:3}),async function*(a){for await(let c of a)yield*c}),this.log("sent provider records to %d peers",i)}async*findProviders(e,t){let n=this.routingTable.kBucketSize,s=e.multihash.bytes,i=this;this.log("findProviders %c",e);let o=await this.providers.getProviders(e);if(o.length>0){let l=[];for(let f of o.slice(0,n))try{let u=await this.components.peerStore.get(f);l.push({id:f,multiaddrs:u.addresses.map(({multiaddr:h})=>h)})}catch(u){if(u.code!=="ERR_NOT_FOUND")throw u;this.log("no peer store entry for %p",f)}yield gn({from:this.components.peerId,messageType:F.GET_PROVIDERS,providers:l},t),yield Hi({from:this.components.peerId,providers:l},t)}if(o.length>=n)return;let a=async function*({peer:l,signal:f}){let u={type:F.GET_PROVIDERS,key:s};yield*i.network.sendRequest(l,u,{...t,signal:f})},c=new at(o);for await(let l of this.queryManager.run(s,a,t))if(yield l,l.name==="PEER_RESPONSE"){this.log("Found %d provider entries for %c and %d closer peers",l.providers.length,e,l.closer.length);let f=[];for(let u of l.providers)c.has(u.id)||(c.add(u.id),f.push(u));if(f.length>0&&(yield Hi({from:l.from,providers:f},t)),c.size===n)return}}};var C0=Symbol.for("@achingbrain/uint8arraylist");function P0(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let s=t+n.byteLength;if(e<s)return{buf:n,index:e-t};t=s}throw new RangeError("index is out of bounds")}function u1(r){return!!r?.[C0]}var Oe=class r{bufs;length;[C0]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(u1(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(u1(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=P0(this.bufs,e);return t.buf[t.index]}set(e,t){let n=P0(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(u1(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:s}=this._subList(e,t);return J(n,s)}subarray(e,t){let{bufs:n,length:s}=this._subList(e,t);return n.length===1?n[0]:J(n,s)}sublist(e,t){let{bufs:n,length:s}=this._subList(e,t),i=new r;return i.length=s,i.bufs=[...n],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let i=0;i<this.bufs.length;i++){let o=this.bufs[i],a=s,c=a+o.byteLength;if(s=c,e>=c)continue;let l=e>=a&&e<c,f=t>a&&t<=c;if(l&&f){if(e===a&&t===c){n.push(o);break}let u=e-a;n.push(o.subarray(u,u+(t-e)));break}if(l){if(e===0){n.push(o);continue}n.push(o.subarray(e-a));continue}if(f){if(t===c){n.push(o);break}n.push(o.subarray(0,t-a));break}n.push(o)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!u1(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;let s=n.byteLength;if(s===0)throw new TypeError("search must be at least 1 byte long");let i=256,o=new Int32Array(i);for(let u=0;u<i;u++)o[u]=-1;for(let u=0;u<s;u++)o[n[u]]=u;let a=o,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let u=t;u<=c;u+=f){f=0;for(let h=l;h>=0;h--){let m=this.get(u+h);if(n[h]!==m){f=Math.max(1,h-a[m]);break}}if(f===0)return u}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=be(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let s=ze(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,t,n),this.write(s,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let s=ze(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,t,n),this.write(s,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let s=ze(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,t,n),this.write(s,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=be(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let s=ze(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,t,n),this.write(s,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let s=ze(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,t,n),this.write(s,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let s=ze(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,t,n),this.write(s,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let s=ze(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,t,n),this.write(s,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let s=ze(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,t,n),this.write(s,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Q(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((s,i)=>s+i.byteLength,0)),n.length=t,n}};var f1=class extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.name="AbortError",this.code=t??"ABORT_ERR"}};async function Or(r,e,t){if(e==null)return r;if(e.aborted)return Promise.reject(new f1(t?.errorMessage,t?.errorCode));let n,s=new f1(t?.errorMessage,t?.errorCode);try{return await Promise.race([r,new Promise((i,o)=>{n=()=>{o(s)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var ao=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=fe(),this.haveNext=fe()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=fe(),e}async throw(e){return this.ended=!0,e!=null&&this.haveNext.reject(e),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return await this._push(void 0),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");if(this.nextResult!=null&&(await this.readNext.promise,this.nextResult!=null))throw new Error("NeedNext promise resolved but nextResult was not consumed");e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=fe(),await Or(this.readNext.promise,t?.signal,t)}};function D0(){return new ao}var h1=class extends Error{code;constructor(e,t){super(e),this.code=t}},co=class extends h1{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted"}};function U0(r,e){let t=D0();r.sink(t).catch(async o=>{await t.end(o)}),r.sink=async o=>{for await(let a of o)await t.push(a);await t.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let s=new Oe;return{read:async(o,a)=>{a?.signal?.throwIfAborted();let c,l=new Promise((f,u)=>{c=()=>{u(new co("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(o==null){let{done:u,value:h}=await Promise.race([n.next(),l]);return u===!0?new Oe:h}for(;s.byteLength<o;){let{value:u,done:h}=await Promise.race([n.next(),l]);if(h===!0)throw new h1("unexpected end of input","ERR_UNEXPECTED_EOF");s.append(u)}let f=s.sublist(0,o);return s.consume(o),f}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(o,a)=>{a?.signal?.throwIfAborted(),o instanceof Uint8Array?await t.push(o,a):await t.push(o.subarray(),a)},unwrap:()=>{if(s.byteLength>0){let o=r.source;r.source=async function*(){e?.yieldBytes===!1?yield s:yield*s,yield*o}()}return r}}}var d1=class extends Error{code;constructor(e,t){super(e),this.code=t}};function O0(r,e={}){let t=U0(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=he(e.maxDataLength));let n=e?.lengthDecoder??Ce,s=e?.lengthEncoder??Me;return{read:async o=>{let a=-1,c=new Oe;for(;;){c.append(await t.read(1,o));try{a=n(c)}catch(l){if(l instanceof RangeError)continue;throw l}if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new d1("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new d1("message length too long","ERR_MSG_DATA_TOO_LONG");return t.read(a,o)},write:async(o,a)=>{await t.write(new Oe(s(o.byteLength),o),a)},writeV:async(o,a)=>{let c=new Oe(...o.flatMap(l=>[s(l.byteLength),l]));await t.write(c,a)},unwrap:()=>t.unwrap()}}function xn(r,e){let t=O0(r,e),n={read:async(s,i)=>{let o=await t.read(i);return s.decode(o)},write:async(s,i,o)=>{await t.write(i.encode(s),o)},writeV:async(s,i,o)=>{await t.writeV(s.map(a=>i.encode(a)),o)},pb:s=>({read:async i=>n.read(s,i),write:async(i,o)=>n.write(i,s,o),writeV:async(i,o)=>n.writeV(i,s,o),unwrap:()=>n}),unwrap:()=>t.unwrap()};return n}var p1=class extends Be{log;protocol;running;components;constructor(e,t){super();let{protocol:n}=t;this.components=e,this.log=e.logger.forComponent(`${t.logPrefix}:network`),this.running=!1,this.protocol=n}async start(){this.running||(this.running=!0)}async stop(){this.running=!1}isStarted(){return this.running}async*sendRequest(e,t,n={}){if(!this.running)return;let s=t.type;if(s==null)throw new pn("Message type was missing","ERR_INVALID_PARAMETERS");this.log("sending %s to %p",t.type,e),yield Ki({peer:e},n),yield Mi({to:e,type:s},n);let i;try{let a=await(await this.components.connectionManager.openConnection(e,n)).newStream(this.protocol,n),c=await this._writeReadMessage(a,t,n);yield gn({from:e,messageType:c.type,closer:c.closer.map(En),providers:c.providers.map(En),record:c.record==null?void 0:me.deserialize(c.record)},n)}catch(o){this.log.error("could not send %s to %p",t.type,e,o),yield Ue({from:e,error:o},n)}finally{i!=null&&await i.close()}}async*sendMessage(e,t,n={}){if(!this.running)return;let s=t.type;if(s==null)throw new pn("Message type was missing","ERR_INVALID_PARAMETERS");this.log("sending %s to %p",t.type,e),yield Ki({peer:e},n),yield Mi({to:e,type:s},n);let i;try{let a=await(await this.components.connectionManager.openConnection(e,n)).newStream(this.protocol,n);await this._writeMessage(a,t,n),yield gn({from:e,messageType:s},n)}catch(o){yield Ue({from:e,error:o},n)}finally{i!=null&&await i.close()}}async _writeMessage(e,t,n){let s=xn(e);await s.write(t,He,n),await s.unwrap().close(n)}async _writeReadMessage(e,t,n){let s=xn(e);await s.write(t,He,n);let i=await s.read(He,n);return await s.unwrap().close(n),i.closer.forEach(o=>{this.safeDispatchEvent("peer",{detail:En(o)})}),i.providers.forEach(o=>{this.safeDispatchEvent("peer",{detail:En(o)})}),i}};var ee={get(r=globalThis){let e=r.crypto;if(e==null||e.subtle==null)throw Object.assign(new Error("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"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var V0={SHA1:20,SHA256:32,SHA512:64};var b8={SHA1:"SHA-1",SHA256:"SHA-256",SHA512:"SHA-512"},w8=async(r,e)=>{let t=await ee.get().subtle.sign({name:"HMAC"},r,e);return new Uint8Array(t,0,t.byteLength)};async function F0(r,e){let t=b8[r],n=await ee.get().subtle.importKey("raw",e,{name:"HMAC",hash:{name:t}},!1,["sign"]);return{async digest(s){return w8(n,s)},length:V0[r]}}var ws={};ue(ws,{Ed25519PrivateKey:()=>St,Ed25519PublicKey:()=>fr,MAX_RSA_KEY_SIZE:()=>pr,RsaPrivateKey:()=>Jt,RsaPublicKey:()=>dr,Secp256k1PrivateKey:()=>yr,Secp256k1PublicKey:()=>mr,generateEphemeralKeyPair:()=>g3,generateKeyPair:()=>x7,generateKeyPairFromSeed:()=>A7,importKey:()=>R7,keyStretcher:()=>b3,keysPBM:()=>Yr,marshalPrivateKey:()=>S7,marshalPublicKey:()=>I7,supportedKeys:()=>Ct,unmarshalPrivateKey:()=>B4,unmarshalPublicKey:()=>B7});var No={};ue(No,{Ed25519PrivateKey:()=>St,Ed25519PublicKey:()=>fr,generateKeyPair:()=>_a,generateKeyPairFromSeed:()=>ko,unmarshalEd25519PrivateKey:()=>ka,unmarshalEd25519PublicKey:()=>Na});function lo(r,e){let t=z(r,"base64urlpad");if(e!=null){if(t.length>e)throw new Error("byte array longer than desired length");t=J([new Uint8Array(e-t.length),t])}return t}function Ke(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Vr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function E8(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function uo(r,...e){if(!E8(r))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(r.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${r.length}`)}function g1(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Vr(r.outputLen),Vr(r.blockLen)}function Fr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function M0(r,e){uo(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var m1=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function H0(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Hr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ye=(r,e)=>r<<32-e|r>>>e,x8=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!x8)throw new Error("Non little-endian hardware is not supported");var A8=async()=>{};async function K0(r,e,t){let n=Date.now();for(let s=0;s<r;s++){t(s);let i=Date.now()-n;i>=0&&i<e||(await A8(),n+=i)}}function fo(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function $t(r){if(typeof r=="string"&&(r=fo(r)),!H0(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function y1(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];if(!H0(s))throw new Error("Uint8Array expected");e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let i=r[n];t.set(i,s),s+=i.length}return t}var Mr=class{clone(){return this._cloneInto()}},B8={}.toString;function q0(r,e){if(e!==void 0&&B8.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function b1(r){let e=n=>r().update($t(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Kr(r=32){if(m1&&typeof m1.getRandomValues=="function")return m1.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function I8(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),c=n?4:0,l=n?0:4;r.setUint32(e+c,o,n),r.setUint32(e+l,a,n)}var qr=class extends Mr{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Hr(this.buffer)}update(e){Fr(this);let{view:t,buffer:n,blockLen:s}=this;e=$t(e);let i=e.length;for(let o=0;o<i;){let a=Math.min(s-this.pos,i-o);if(a===s){let c=Hr(e);for(;s<=i-o;o+=s)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Fr(this),M0(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:s,isLE:i}=this,{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(n,0),o=0);for(let u=o;u<s;u++)t[u]=0;I8(n,s-8,BigInt(this.length*8),i),this.process(n,0);let a=Hr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(n),e}};var w1=BigInt(4294967295),ho=BigInt(32);function $0(r,e=!1){return e?{h:Number(r&w1),l:Number(r>>ho&w1)}:{h:Number(r>>ho&w1)|0,l:Number(r&w1)|0}}function S8(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:i,l:o}=$0(r[s],e);[t[s],n[s]]=[i,o]}return[t,n]}var R8=(r,e)=>BigInt(r>>>0)<<ho|BigInt(e>>>0),k8=(r,e,t)=>r>>>t,N8=(r,e,t)=>r<<32-t|e>>>t,_8=(r,e,t)=>r>>>t|e<<32-t,T8=(r,e,t)=>r<<32-t|e>>>t,L8=(r,e,t)=>r<<64-t|e>>>t-32,P8=(r,e,t)=>r>>>t-32|e<<64-t,C8=(r,e)=>e,D8=(r,e)=>r,U8=(r,e,t)=>r<<t|e>>>32-t,O8=(r,e,t)=>e<<t|r>>>32-t,V8=(r,e,t)=>e<<t-32|r>>>64-t,F8=(r,e,t)=>r<<t-32|e>>>64-t;function M8(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var H8=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),K8=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,q8=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),$8=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,z8=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),G8=(r,e,t,n,s,i)=>e+t+n+s+i+(r/2**32|0)|0;var j8={fromBig:$0,split:S8,toBig:R8,shrSH:k8,shrSL:N8,rotrSH:_8,rotrSL:T8,rotrBH:L8,rotrBL:P8,rotr32H:C8,rotr32L:D8,rotlSH:U8,rotlSL:O8,rotlBH:V8,rotlBL:F8,add:M8,add3L:H8,add3H:K8,add4L:q8,add4H:$8,add5H:G8,add5L:z8},D=j8;var[Y8,W8]=D.split(["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(r=>BigInt(r))),zt=new Uint32Array(80),Gt=new Uint32Array(80),po=class extends qr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:s,Ch:i,Cl:o,Dh:a,Dl:c,Eh:l,El:f,Fh:u,Fl:h,Gh:m,Gl:p,Hh:d,Hl:g}=this;return[e,t,n,s,i,o,a,c,l,f,u,h,m,p,d,g]}set(e,t,n,s,i,o,a,c,l,f,u,h,m,p,d,g){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=f|0,this.Fh=u|0,this.Fl=h|0,this.Gh=m|0,this.Gl=p|0,this.Hh=d|0,this.Hl=g|0}process(e,t){for(let b=0;b<16;b++,t+=4)zt[b]=e.getUint32(t),Gt[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){let S=zt[b-15]|0,x=Gt[b-15]|0,I=D.rotrSH(S,x,1)^D.rotrSH(S,x,8)^D.shrSH(S,x,7),N=D.rotrSL(S,x,1)^D.rotrSL(S,x,8)^D.shrSL(S,x,7),T=zt[b-2]|0,G=Gt[b-2]|0,q=D.rotrSH(T,G,19)^D.rotrBH(T,G,61)^D.shrSH(T,G,6),U=D.rotrSL(T,G,19)^D.rotrBL(T,G,61)^D.shrSL(T,G,6),ce=D.add4L(N,U,Gt[b-7],Gt[b-16]),ae=D.add4H(ce,I,q,zt[b-7],zt[b-16]);zt[b]=ae|0,Gt[b]=ce|0}let{Ah:n,Al:s,Bh:i,Bl:o,Ch:a,Cl:c,Dh:l,Dl:f,Eh:u,El:h,Fh:m,Fl:p,Gh:d,Gl:g,Hh:y,Hl:v}=this;for(let b=0;b<80;b++){let S=D.rotrSH(u,h,14)^D.rotrSH(u,h,18)^D.rotrBH(u,h,41),x=D.rotrSL(u,h,14)^D.rotrSL(u,h,18)^D.rotrBL(u,h,41),I=u&m^~u&d,N=h&p^~h&g,T=D.add5L(v,x,N,W8[b],Gt[b]),G=D.add5H(T,y,S,I,Y8[b],zt[b]),q=T|0,U=D.rotrSH(n,s,28)^D.rotrBH(n,s,34)^D.rotrBH(n,s,39),ce=D.rotrSL(n,s,28)^D.rotrBL(n,s,34)^D.rotrBL(n,s,39),ae=n&i^n&a^i&a,Fe=s&o^s&c^o&c;y=d|0,v=g|0,d=m|0,g=p|0,m=u|0,p=h|0,{h:u,l:h}=D.add(l|0,f|0,G|0,q|0),l=a|0,f=c|0,a=i|0,c=o|0,i=n|0,o=s|0;let A=D.add3L(q,ce,Fe);n=D.add3H(A,G,U,ae),s=A|0}({h:n,l:s}=D.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:i,l:o}=D.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=D.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=D.add(this.Dh|0,this.Dl|0,l|0,f|0),{h:u,l:h}=D.add(this.Eh|0,this.El|0,u|0,h|0),{h:m,l:p}=D.add(this.Fh|0,this.Fl|0,m|0,p|0),{h:d,l:g}=D.add(this.Gh|0,this.Gl|0,d|0,g|0),{h:y,l:v}=D.add(this.Hh|0,this.Hl|0,y|0,v|0),this.set(n,s,i,o,a,c,l,f,u,h,m,p,d,g,y,v)}roundClean(){zt.fill(0),Gt.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var $r=b1(()=>new po);var E1={};ue(E1,{bitGet:()=>ra,bitLen:()=>ta,bitMask:()=>An,bitSet:()=>na,bytesToHex:()=>Et,bytesToNumberBE:()=>xt,bytesToNumberLE:()=>jt,concatBytes:()=>At,createHmacDrbg:()=>yo,ensureBytes:()=>oe,equalBytes:()=>J8,hexToBytes:()=>cr,hexToNumber:()=>mo,isBytes:()=>We,numberToBytesBE:()=>Yt,numberToBytesLE:()=>lr,numberToHexUnpadded:()=>Y0,numberToVarBytesBE:()=>X8,utf8ToBytes:()=>ea,validateObject:()=>ct});var j0=BigInt(0),v1=BigInt(1),Z8=BigInt(2);function We(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Q8=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Et(r){if(!We(r))throw new Error("Uint8Array expected");let e="";for(let t=0;t<r.length;t++)e+=Q8[r[t]];return e}function Y0(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function mo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var vt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function z0(r){if(r>=vt._0&&r<=vt._9)return r-vt._0;if(r>=vt._A&&r<=vt._F)return r-(vt._A-10);if(r>=vt._a&&r<=vt._f)return r-(vt._a-10)}function cr(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let s=0,i=0;s<t;s++,i+=2){let o=z0(r.charCodeAt(i)),a=z0(r.charCodeAt(i+1));if(o===void 0||a===void 0){let c=r[i]+r[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[s]=o*16+a}return n}function xt(r){return mo(Et(r))}function jt(r){if(!We(r))throw new Error("Uint8Array expected");return mo(Et(Uint8Array.from(r).reverse()))}function Yt(r,e){return cr(r.toString(16).padStart(e*2,"0"))}function lr(r,e){return Yt(r,e).reverse()}function X8(r){return cr(Y0(r))}function oe(r,e,t){let n;if(typeof e=="string")try{n=cr(e)}catch(i){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${i}`)}else if(We(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function At(...r){let e=0;for(let s=0;s<r.length;s++){let i=r[s];if(!We(i))throw new Error("Uint8Array expected");e+=i.length}let t=new Uint8Array(e),n=0;for(let s=0;s<r.length;s++){let i=r[s];t.set(i,n),n+=i.length}return t}function J8(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function ea(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function ta(r){let e;for(e=0;r>j0;r>>=v1,e+=1);return e}function ra(r,e){return r>>BigInt(e)&v1}var na=(r,e,t)=>r|(t?v1:j0)<<BigInt(e),An=r=>(Z8<<BigInt(r-1))-v1,go=r=>new Uint8Array(r),G0=r=>Uint8Array.from(r);function yo(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=go(r),s=go(r),i=0,o=()=>{n.fill(1),s.fill(0),i=0},a=(...u)=>t(s,n,...u),c=(u=go())=>{s=a(G0([0]),u),n=a(),u.length!==0&&(s=a(G0([1]),u),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,h=[];for(;u<e;){n=a();let m=n.slice();h.push(m),u+=n.length}return At(...h)};return(u,h)=>{o(),c(u);let m;for(;!(m=h(l()));)c();return o(),m}}var sa={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||We(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ct(r,e,t={}){let n=(s,i,o)=>{let a=sa[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);let c=r[s];if(!(o&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${i}`)};for(let[s,i]of Object.entries(e))n(s,i,!1);for(let[s,i]of Object.entries(t))n(s,i,!0);return r}var ye=BigInt(0),te=BigInt(1),ur=BigInt(2),ia=BigInt(3),bo=BigInt(4),W0=BigInt(5),Z0=BigInt(8),oa=BigInt(9),aa=BigInt(16);function Z(r,e){let t=r%e;return t>=ye?t:e+t}function ca(r,e,t){if(t<=ye||e<ye)throw new Error("Expected power/modulo > 0");if(t===te)return ye;let n=te;for(;e>ye;)e&te&&(n=n*r%t),r=r*r%t,e>>=te;return n}function re(r,e,t){let n=r;for(;e-- >ye;)n*=n,n%=t;return n}function x1(r,e){if(r===ye||e<=ye)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Z(r,e),n=e,s=ye,i=te,o=te,a=ye;for(;t!==ye;){let l=n/t,f=n%t,u=s-o*l,h=i-a*l;n=t,t=f,s=o,i=a,o=u,a=h}if(n!==te)throw new Error("invert: does not exist");return Z(s,e)}function la(r){let e=(r-te)/ur,t,n,s;for(t=r-te,n=0;t%ur===ye;t/=ur,n++);for(s=ur;s<r&&ca(s,e,r)!==r-te;s++);if(n===1){let o=(r+te)/bo;return function(c,l){let f=c.pow(l,o);if(!c.eql(c.sqr(f),l))throw new Error("Cannot find square root");return f}}let i=(t+te)/ur;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,f=a.pow(a.mul(a.ONE,s),t),u=a.pow(c,i),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let m=1;for(let d=a.sqr(h);m<l&&!a.eql(d,a.ONE);m++)d=a.sqr(d);let p=a.pow(f,te<<BigInt(l-m-1));f=a.sqr(p),u=a.mul(u,p),h=a.mul(h,f),l=m}return u}}function ua(r){if(r%bo===ia){let e=(r+te)/bo;return function(n,s){let i=n.pow(s,e);if(!n.eql(n.sqr(i),s))throw new Error("Cannot find square root");return i}}if(r%Z0===W0){let e=(r-W0)/Z0;return function(n,s){let i=n.mul(s,ur),o=n.pow(i,e),a=n.mul(s,o),c=n.mul(n.mul(a,ur),o),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%aa,la(r)}var Q0=(r,e)=>(Z(r,e)&te)===te,fa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function wo(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=fa.reduce((n,s)=>(n[s]="function",n),e);return ct(r,t)}function ha(r,e,t){if(t<ye)throw new Error("Expected power > 0");if(t===ye)return r.ONE;if(t===te)return e;let n=r.ONE,s=e;for(;t>ye;)t&te&&(n=r.mul(n,s)),s=r.sqr(s),t>>=te;return n}function da(r,e){let t=new Array(e.length),n=e.reduce((i,o,a)=>r.is0(o)?i:(t[a]=i,r.mul(i,o)),r.ONE),s=r.inv(n);return e.reduceRight((i,o,a)=>r.is0(o)?i:(t[a]=r.mul(i,t[a]),r.mul(i,o)),s),t}function vo(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function A1(r,e,t=!1,n={}){if(r<=ye)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:i}=vo(r,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");let o=ua(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:i,MASK:An(s),ZERO:ye,ONE:te,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ye<=c&&c<r},is0:c=>c===ye,isOdd:c=>(c&te)===te,neg:c=>Z(-c,r),eql:(c,l)=>c===l,sqr:c=>Z(c*c,r),add:(c,l)=>Z(c+l,r),sub:(c,l)=>Z(c-l,r),mul:(c,l)=>Z(c*l,r),pow:(c,l)=>ha(a,c,l),div:(c,l)=>Z(c*x1(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>x1(c,r),sqrt:n.sqrt||(c=>o(a,c)),invertBatch:c=>da(a,c),cmov:(c,l,f)=>f?l:c,toBytes:c=>t?lr(c,i):Yt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${c.length}`);return t?jt(c):xt(c)}});return Object.freeze(a)}function X0(r,e){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let t=r.sqrt(e);return r.isOdd(t)?r.neg(t):t}function J0(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function Eo(r){let e=J0(r);return e+Math.ceil(e/2)}function e3(r,e,t=!1){let n=r.length,s=J0(e),i=Eo(e);if(n<16||n<i||n>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${n}`);let o=t?xt(r):jt(r),a=Z(o,e-te)+te;return t?lr(a,s):Yt(a,s)}var ga=BigInt(0),xo=BigInt(1);function B1(r,e){let t=(s,i)=>{let o=i.negate();return s?o:i},n=s=>{let i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=r.ZERO,a=s;for(;i>ga;)i&xo&&(o=o.add(a)),a=a.double(),i>>=xo;return o},precomputeWindow(s,i){let{windows:o,windowSize:a}=n(i),c=[],l=s,f=l;for(let u=0;u<o;u++){f=l,c.push(f);for(let h=1;h<a;h++)f=f.add(l),c.push(f);l=f.double()}return c},wNAF(s,i,o){let{windows:a,windowSize:c}=n(s),l=r.ZERO,f=r.BASE,u=BigInt(2**s-1),h=2**s,m=BigInt(s);for(let p=0;p<a;p++){let d=p*c,g=Number(o&u);o>>=m,g>c&&(g-=h,o+=xo);let y=d,v=d+Math.abs(g)-1,b=p%2!==0,S=g<0;g===0?f=f.add(t(b,i[y])):l=l.add(t(S,i[v]))}return{p:l,f}},wNAFCached(s,i,o,a){let c=s._WINDOW_SIZE||1,l=i.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&i.set(s,a(l))),this.wNAF(c,l,o)}}}function Bn(r){return wo(r.Fp),ct(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...vo(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ze=BigInt(0),Ve=BigInt(1),I1=BigInt(2),ma=BigInt(8),ya={zip215:!0};function ba(r){let e=Bn(r);return ct(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function S1(r){let e=ba(r),{Fp:t,n,prehash:s,hash:i,randomBytes:o,nByteLength:a,h:c}=e,l=I1<<BigInt(a*8)-Ve,f=t.create,u=e.uvRatio||((B,w)=>{try{return{isValid:!0,value:t.sqrt(B*t.inv(w))}}catch{return{isValid:!1,value:Ze}}}),h=e.adjustScalarBytes||(B=>B),m=e.domain||((B,w,k)=>{if(w.length||k)throw new Error("Contexts/pre-hash are not supported");return B}),p=B=>typeof B=="bigint"&&Ze<B,d=(B,w)=>p(B)&&p(w)&&B<w,g=B=>B===Ze||d(B,l);function y(B,w){if(d(B,w))return B;throw new Error(`Expected valid scalar < ${w}, got ${typeof B} ${B}`)}function v(B){return B===Ze?B:y(B,n)}let b=new Map;function S(B){if(!(B instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(w,k,P,C){if(this.ex=w,this.ey=k,this.ez=P,this.et=C,!g(w))throw new Error("x required");if(!g(k))throw new Error("y required");if(!g(P))throw new Error("z required");if(!g(C))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(w){if(w instanceof x)throw new Error("extended point not allowed");let{x:k,y:P}=w||{};if(!g(k)||!g(P))throw new Error("invalid affine point");return new x(k,P,Ve,f(k*P))}static normalizeZ(w){let k=t.invertBatch(w.map(P=>P.ez));return w.map((P,C)=>P.toAffine(k[C])).map(x.fromAffine)}_setWindowSize(w){this._WINDOW_SIZE=w,b.delete(this)}assertValidity(){let{a:w,d:k}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:P,ey:C,ez:V,et:M}=this,Y=f(P*P),K=f(C*C),$=f(V*V),le=f($*$),se=f(Y*w),ve=f($*f(se+K)),Ee=f(le+f(k*f(Y*K)));if(ve!==Ee)throw new Error("bad point: equation left != right (1)");let pe=f(P*C),Ae=f(V*M);if(pe!==Ae)throw new Error("bad point: equation left != right (2)")}equals(w){S(w);let{ex:k,ey:P,ez:C}=this,{ex:V,ey:M,ez:Y}=w,K=f(k*Y),$=f(V*C),le=f(P*Y),se=f(M*C);return K===$&&le===se}is0(){return this.equals(x.ZERO)}negate(){return new x(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:w}=e,{ex:k,ey:P,ez:C}=this,V=f(k*k),M=f(P*P),Y=f(I1*f(C*C)),K=f(w*V),$=k+P,le=f(f($*$)-V-M),se=K+M,ve=se-Y,Ee=K-M,pe=f(le*ve),Ae=f(se*Ee),dt=f(le*Ee),rr=f(ve*se);return new x(pe,Ae,rr,dt)}add(w){S(w);let{a:k,d:P}=e,{ex:C,ey:V,ez:M,et:Y}=this,{ex:K,ey:$,ez:le,et:se}=w;if(k===BigInt(-1)){let a2=f((V-C)*($+K)),c2=f((V+C)*($-K)),Ws=f(c2-a2);if(Ws===Ze)return this.double();let l2=f(M*I1*se),u2=f(Y*I1*le),f2=u2+l2,h2=c2+a2,d2=u2-l2,W4=f(f2*Ws),Z4=f(h2*d2),Q4=f(f2*d2),X4=f(Ws*h2);return new x(W4,Z4,X4,Q4)}let ve=f(C*K),Ee=f(V*$),pe=f(Y*P*se),Ae=f(M*le),dt=f((C+V)*(K+$)-ve-Ee),rr=Ae-pe,nn=Ae+pe,o2=f(Ee-k*ve),z4=f(dt*rr),G4=f(nn*o2),j4=f(dt*o2),Y4=f(rr*nn);return new x(z4,G4,Y4,j4)}subtract(w){return this.add(w.negate())}wNAF(w){return T.wNAFCached(this,b,w,x.normalizeZ)}multiply(w){let{p:k,f:P}=this.wNAF(y(w,n));return x.normalizeZ([k,P])[0]}multiplyUnsafe(w){let k=v(w);return k===Ze?N:this.equals(N)||k===Ve?this:this.equals(I)?this.wNAF(k).p:T.unsafeLadder(this,k)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(w){let{ex:k,ey:P,ez:C}=this,V=this.is0();w==null&&(w=V?ma:t.inv(C));let M=f(k*w),Y=f(P*w),K=f(C*w);if(V)return{x:Ze,y:Ve};if(K!==Ve)throw new Error("invZ was invalid");return{x:M,y:Y}}clearCofactor(){let{h:w}=e;return w===Ve?this:this.multiplyUnsafe(w)}static fromHex(w,k=!1){let{d:P,a:C}=e,V=t.BYTES;w=oe("pointHex",w,V);let M=w.slice(),Y=w[V-1];M[V-1]=Y&-129;let K=jt(M);K===Ze||(k?y(K,l):y(K,t.ORDER));let $=f(K*K),le=f($-Ve),se=f(P*$-C),{isValid:ve,value:Ee}=u(le,se);if(!ve)throw new Error("Point.fromHex: invalid y coordinate");let pe=(Ee&Ve)===Ve,Ae=(Y&128)!==0;if(!k&&Ee===Ze&&Ae)throw new Error("Point.fromHex: x=0 and x_0=1");return Ae!==pe&&(Ee=f(-Ee)),x.fromAffine({x:Ee,y:K})}static fromPrivateKey(w){return U(w).point}toRawBytes(){let{x:w,y:k}=this.toAffine(),P=lr(k,t.BYTES);return P[P.length-1]|=w&Ve?128:0,P}toHex(){return Et(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,Ve,f(e.Gx*e.Gy)),x.ZERO=new x(Ze,Ve,Ve,Ze);let{BASE:I,ZERO:N}=x,T=B1(x,a*8);function G(B){return Z(B,n)}function q(B){return G(jt(B))}function U(B){let w=a;B=oe("private key",B,w);let k=oe("hashed private key",i(B),2*w),P=h(k.slice(0,w)),C=k.slice(w,2*w),V=q(P),M=I.multiply(V),Y=M.toRawBytes();return{head:P,prefix:C,scalar:V,point:M,pointBytes:Y}}function ce(B){return U(B).pointBytes}function ae(B=new Uint8Array,...w){let k=At(...w);return q(i(m(k,oe("context",B),!!s)))}function Fe(B,w,k={}){B=oe("message",B),s&&(B=s(B));let{prefix:P,scalar:C,pointBytes:V}=U(w),M=ae(k.context,P,B),Y=I.multiply(M).toRawBytes(),K=ae(k.context,Y,V,B),$=G(M+K*C);v($);let le=At(Y,lr($,t.BYTES));return oe("result",le,a*2)}let A=ya;function _(B,w,k,P=A){let{context:C,zip215:V}=P,M=t.BYTES;B=oe("signature",B,2*M),w=oe("message",w),s&&(w=s(w));let Y=jt(B.slice(M,2*M)),K,$,le;try{K=x.fromHex(k,V),$=x.fromHex(B.slice(0,M),V),le=I.multiplyUnsafe(Y)}catch{return!1}if(!V&&K.isSmallOrder())return!1;let se=ae(C,$.toRawBytes(),K.toRawBytes(),w);return $.add(K.multiplyUnsafe(se)).subtract(le).clearCofactor().equals(x.ZERO)}return I._setWindowSize(8),{CURVE:e,getPublicKey:ce,sign:Fe,verify:_,ExtendedPoint:x,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>o(t.BYTES),precompute(B=8,w=x.BASE){return w._setWindowSize(B),w.multiply(BigInt(3)),w}}}}var Bo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),t3=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Gh=BigInt(0),wa=BigInt(1),Ao=BigInt(2),va=BigInt(5),r3=BigInt(10),Ea=BigInt(20),xa=BigInt(40),n3=BigInt(80);function Aa(r){let e=Bo,n=r*r%e*r%e,s=re(n,Ao,e)*n%e,i=re(s,wa,e)*r%e,o=re(i,va,e)*i%e,a=re(o,r3,e)*o%e,c=re(a,Ea,e)*a%e,l=re(c,xa,e)*c%e,f=re(l,n3,e)*l%e,u=re(f,n3,e)*l%e,h=re(u,r3,e)*o%e;return{pow_p_5_8:re(h,Ao,e)*r%e,b2:n}}function Ba(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Ia(r,e){let t=Bo,n=Z(e*e*e,t),s=Z(n*n*e,t),i=Aa(r*s).pow_p_5_8,o=Z(r*n*i,t),a=Z(e*o*o,t),c=o,l=Z(o*t3,t),f=a===r,u=a===Z(-r,t),h=a===Z(-r*t3,t);return f&&(o=c),(u||h)&&(o=l),Q0(o,t)&&(o=Z(-o,t)),{isValid:f||u,value:o}}var Bt=A1(Bo,void 0,!0),Io={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Bt,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:$r,randomBytes:Kr,adjustScalarBytes:Ba,uvRatio:Ia},zr=S1(Io);function s3(r,e,t){if(e.length>255)throw new Error("Context is too big");return y1(fo("SigEd25519 no Ed25519 collisions"),new Uint8Array([t?1:0,e.length]),e,r)}var jh=S1({...Io,domain:s3}),Yh=S1({...Io,domain:s3,prehash:$r});var Sa=(Bt.ORDER+BigInt(3))/BigInt(8),Wh=Bt.pow(Ao,Sa),Zh=Bt.sqrt(Bt.neg(Bt.ONE)),Qh=(Bt.ORDER-BigInt(5))/BigInt(8),Xh=BigInt(486662);var Jh=X0(Bt,Bt.neg(BigInt(486664)));var ed=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),td=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),rd=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),nd=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var sd=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Gr=32,It=64,R1=32;function i3(){let r=zr.utils.randomPrivateKey(),e=zr.getPublicKey(r);return{privateKey:l3(r,e),publicKey:e}}function o3(r){if(r.length!==R1)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=zr.getPublicKey(e);return{privateKey:l3(e,t),publicKey:t}}function a3(r,e){let t=r.subarray(0,R1);return zr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function c3(r,e,t){return zr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function l3(r,e){let t=new Uint8Array(It);for(let n=0;n<R1;n++)t[n]=r[n],t[R1+n]=e[n];return t}var So={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function k1(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,s=r?.digest??"SHA-256",i=r?.saltLength??16,o=r?.iterations??32767,a=ee.get();t*=8;async function c(u,h){let m=a.getRandomValues(new Uint8Array(i)),p=a.getRandomValues(new Uint8Array(n)),d={name:e,iv:p};typeof h=="string"&&(h=z(h));let g;if(h.length===0){g=await a.subtle.importKey("jwk",So,{name:"AES-GCM"},!0,["encrypt"]);try{let v={name:"PBKDF2",salt:m,iterations:o,hash:{name:s}},b=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(v,b,{name:e,length:t},!0,["encrypt"])}catch{g=await a.subtle.importKey("jwk",So,{name:"AES-GCM"},!0,["encrypt"])}}else{let v={name:"PBKDF2",salt:m,iterations:o,hash:{name:s}},b=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(v,b,{name:e,length:t},!0,["encrypt"])}let y=await a.subtle.encrypt(d,g,u);return J([m,d.iv,new Uint8Array(y)])}async function l(u,h){let m=u.subarray(0,i),p=u.subarray(i,i+n),d=u.subarray(i+n),g={name:e,iv:p};typeof h=="string"&&(h=z(h));let y;if(h.length===0)try{let b={name:"PBKDF2",salt:m,iterations:o,hash:{name:s}},S=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(b,S,{name:e,length:t},!0,["decrypt"])}catch{y=await a.subtle.importKey("jwk",So,{name:"AES-GCM"},!0,["decrypt"])}else{let b={name:"PBKDF2",salt:m,iterations:o,hash:{name:s}},S=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(b,S,{name:e,length:t},!0,["decrypt"])}let v=await a.subtle.decrypt(g,y,d);return new Uint8Array(v)}return{encrypt:c,decrypt:l}}async function jr(r,e){let n=await k1().encrypt(r,e);return cn.encode(n)}var Yr={};ue(Yr,{KeyType:()=>X,PrivateKey:()=>Xe,PublicKey:()=>Qe});var X;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(X||(X={}));var Ro;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Ro||(Ro={}));(function(r){r.codec=()=>Rr(Ro)})(X||(X={}));var Qe;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),X.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:s.Type=X.codec().decode(t);break;case 2:s.Data=t.bytes();break;default:t.skipType(o&7);break}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(Qe||(Qe={}));var Xe;(function(r){let e;r.codec=()=>(e==null&&(e=ot((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),X.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let s={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let o=t.uint32();switch(o>>>3){case 1:s.Type=X.codec().decode(t);break;case 2:s.Data=t.bytes();break;default:t.skipType(o&7);break}}return s})),e),r.encode=t=>it(t,r.codec()),r.decode=t=>nt(t,r.codec())})(Xe||(Xe={}));var fr=class{_key;constructor(e){this._key=Wr(e,Gr)}verify(e,t){return c3(this._key,t,e)}marshal(){return this._key}get bytes(){return Qe.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Q(this.bytes,e.bytes)}hash(){let e=ne.digest(this.bytes);return Ke(e)?e.then(({bytes:t})=>t):e.bytes}},St=class{_key;_publicKey;constructor(e,t){this._key=Wr(e,It),this._publicKey=Wr(t,Gr)}sign(e){return a3(this._key,e)}get public(){return new fr(this._publicKey)}marshal(){return this._key}get bytes(){return Xe.encode({Type:X.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Q(this.bytes,e.bytes)}async hash(){let e=ne.digest(this.bytes),t;return Ke(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Ht.digest(this.public.bytes);return ge.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return jr(this.bytes,e);throw new E(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function ka(r){if(r.length>It){r=Wr(r,It+Gr);let n=r.subarray(0,It),s=r.subarray(It,r.length);return new St(n,s)}r=Wr(r,It);let e=r.subarray(0,It),t=r.subarray(Gr);return new St(e,t)}function Na(r){return r=Wr(r,Gr),new fr(r)}async function _a(){let{privateKey:r,publicKey:e}=i3();return new St(r,e)}async function ko(r){let{privateKey:e,publicKey:t}=o3(r);return new St(e,t)}function Wr(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new E(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}var f3={"P-256":256,"P-384":384,"P-521":521},Ta=Object.keys(f3),_o=Ta.join(" / ");async function h3(r){if(r!=="P-256"&&r!=="P-384"&&r!=="P-521")throw new E(`Unknown curve: ${r}. Must be ${_o}`,"ERR_INVALID_CURVE");let e=await ee.get().subtle.generateKey({name:"ECDH",namedCurve:r},!0,["deriveBits"]),t=async(i,o)=>{let a;o!=null?a=await ee.get().subtle.importKey("jwk",Pa(r,o),{name:"ECDH",namedCurve:r},!1,["deriveBits"]):a=e.privateKey;let c=await ee.get().subtle.importKey("jwk",p3(r,i),{name:"ECDH",namedCurve:r},!1,[]),l=await ee.get().subtle.deriveBits({name:"ECDH",namedCurve:r,public:c},a,f3[r]);return new Uint8Array(l,0,l.byteLength)},n=await ee.get().subtle.exportKey("jwk",e.publicKey);return{key:La(n),genSharedKey:t}}var d3={"P-256":32,"P-384":48,"P-521":66};function La(r){if(r.crv==null||r.x==null||r.y==null)throw new E("JWK was missing components","ERR_INVALID_PARAMETERS");if(r.crv!=="P-256"&&r.crv!=="P-384"&&r.crv!=="P-521")throw new E(`Unknown curve: ${r.crv}. Must be ${_o}`,"ERR_INVALID_CURVE");let e=d3[r.crv];return J([Uint8Array.from([4]),lo(r.x,e),lo(r.y,e)],1+e*2)}function p3(r,e){if(r!=="P-256"&&r!=="P-384"&&r!=="P-521")throw new E(`Unknown curve: ${r}. Must be ${_o}`,"ERR_INVALID_CURVE");let t=d3[r];if(!Q(e.subarray(0,1),Uint8Array.from([4])))throw new E("Cannot unmarshal public key - invalid key format","ERR_INVALID_KEY_FORMAT");return{kty:"EC",crv:r,x:L(e.subarray(1,t+1),"base64url"),y:L(e.subarray(1+t),"base64url"),ext:!0}}var Pa=(r,e)=>({...p3(r,e.public),d:L(e.private,"base64url")});var g3=h3;async function m3(r,e){let t=cn.decode(r);return k1().decrypt(t,e)}var y3={"AES-128":{ivSize:16,keySize:16},"AES-256":{ivSize:16,keySize:32},Blowfish:{ivSize:8,keySize:32}};async function b3(r,e,t){let n=y3[r];if(n==null){let v=Object.keys(y3).join(" / ");throw new E(`unknown cipher type '${r}'. Must be ${v}`,"ERR_INVALID_CIPHER_TYPE")}if(e==null)throw new E("missing hash type","ERR_MISSING_HASH_TYPE");let s=n.keySize,i=n.ivSize,o=20,a=z("key expansion"),c=2*(i+s+o),l=await F0(e,t),f=await l.digest(a),u=[],h=0;for(;h<c;){let v=await l.digest(J([f,a])),b=v.length;h+b>c&&(b=c-h),u.push(v),h+=b,f=await l.digest(f)}let m=c/2,p=J(u),d=p.subarray(0,m),g=p.subarray(m,c),y=v=>({iv:v.subarray(0,i),cipherKey:v.subarray(i,i+s),macKey:v.subarray(i+s)});return{k1:y(d),k2:y(g)}}var Ho={};ue(Ho,{MAX_RSA_KEY_SIZE:()=>pr,RsaPrivateKey:()=>Jt,RsaPublicKey:()=>dr,fromJwk:()=>i7,generateKeyPair:()=>o7,unmarshalRsaPrivateKey:()=>Fo,unmarshalRsaPublicKey:()=>s7});function lt(r){if(isNaN(r)||r<=0)throw new E("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Kr(r)}var Xt={};ue(Xt,{exportToPem:()=>e7,importFromPem:()=>Vo,jwkToPkcs1:()=>Za,jwkToPkix:()=>Xa,pkcs1ToJwk:()=>Wa,pkixToJwk:()=>Qa});var N1=class extends Mr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,g1(e);let n=$t(t);if(this.iHash=e.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 s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?e.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return Fr(this),this.iHash.update(e),this}digestInto(e){Fr(this),uo(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},In=(r,e,t)=>new N1(r,e).update(t).digest();In.create=(r,e)=>new N1(r,e);function Ca(r,e,t,n){g1(r);let s=q0({dkLen:32,asyncTick:10},n),{c:i,dkLen:o,asyncTick:a}=s;if(Vr(i),Vr(o),Vr(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=$t(e),l=$t(t),f=new Uint8Array(o),u=In.create(r,c),h=u._cloneInto().update(l);return{c:i,dkLen:o,asyncTick:a,DK:f,PRF:u,PRFSalt:h}}function Da(r,e,t,n,s){return r.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),t}async function To(r,e,t,n){let{c:s,dkLen:i,asyncTick:o,DK:a,PRF:c,PRFSalt:l}=Ca(r,e,t,n),f,u=new Uint8Array(4),h=Hr(u),m=new Uint8Array(c.outputLen);for(let p=1,d=0;d<i;p++,d+=c.outputLen){let g=a.subarray(d,d+c.outputLen);h.setInt32(0,p,!1),(f=l._cloneInto(f)).update(u).digestInto(m),g.set(m.subarray(0,g.length)),await K0(s-1,o,()=>{c._cloneInto(f).update(m).digestInto(m);for(let y=0;y<g.length;y++)g[y]^=m[y]})}return Da(c,l,a,f,m)}var H=on(w3());function hr(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function Wt(r,e,t=-1){let n=t,s=r,i=0,o=Math.pow(2,e);for(let a=1;a<8;a++){if(r<o){let c;if(n<0)c=new ArrayBuffer(a),i=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),i=n}let l=new Uint8Array(c);for(let f=a-1;f>=0;f--){let u=Math.pow(2,f*e);l[i-f-1]=Math.floor(s/u),s-=l[i-f-1]*u}return c}o*=Math.pow(2,e)}return new ArrayBuffer(0)}function L1(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let i of r)s.set(i,t),t+=i.length;return s}function Po(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=hr(t,8),s=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,hr(i,8)-n}function v3(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let o=t-e,a=Wt(o,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Wt(e,8,n),i=new Uint8Array(s);if(i[0]&128){let o=s.slice(0),a=new Uint8Array(o);s=new ArrayBuffer(s.byteLength+1),i=new Uint8Array(s);for(let c=0;c<o.byteLength;c++)i[c+1]=a[c];i[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function E3(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function Pe(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,s=new Array(n);for(let o=0;o<n;o++)s[o]="0";return s.join("").concat(t)}var Gd=Math.log(2);function P1(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Co(r){let e=0,t=0;for(let s=0;s<r.length;s++){let i=r[s];e+=i.byteLength}let n=new Uint8Array(e);for(let s=0;s<r.length;s++){let i=r[s];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function Tt(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Rn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Co(this.items)}},Sn=[new Uint8Array([1])],x3="0123456789";var Xr="",et=new ArrayBuffer(0),Do=new Uint8Array(0),kn="EndOfContent",B3="OCTET STRING",I3="BIT STRING";function Lt(r){var e;return e=class extends r{constructor(...n){var s;super(...n);let i=n[0]||{};this.isHexOnly=(s=i.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=i.valueHex?H.BufferSourceConverter.toUint8Array(i.valueHex):Do}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,i){let o=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Tt(this,o,s,i))return-1;let a=s+i;return this.valueHexView=o.subarray(s,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",et)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var kt=class{constructor({blockLength:e=0,error:t=Xr,warnings:n=[],valueBeforeDecode:s=Do}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=H.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:H.Convert.ToHex(this.valueBeforeDecodeView)}}};kt.NAME="baseBlock";var Re=class extends kt{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Re.NAME="valueBlock";var C1=class extends Lt(kt){constructor({idBlock:e={}}={}){var t,n,s,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?H.BufferSourceConverter.toUint8Array(e.valueHex):Do,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",et}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=Wt(this.tagNumber,7),i=new Uint8Array(s),o=s.byteLength,a=new Uint8Array(o+1);if(a[0]=t|31,!e){for(let c=0;c<o-1;c++)a[c+1]=i[c]|128;a[o]=i[o-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let s=this.valueHexView;for(let i=0;i<s.length-1;i++)n[i+1]=s[i]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(e,t,n){let s=H.BufferSourceConverter.toUint8Array(e);if(!Tt(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),f=255;for(;i[c]&128;){if(l[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;let h=new Uint8Array(f);for(let m=0;m<l.length;m++)h[m]=l[m];l=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,l[c-1]=i[c]&127;let u=new Uint8Array(c);for(let h=0;h<c;h++)u[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(u),this.blockLength<=9?this.tagNumber=hr(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};C1.NAME="identificationBlock";var D1=class extends kt{constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){let s=H.BufferSourceConverter.toUint8Array(e);if(!Tt(this,s,t,n))return-1;let i=s.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let o=i[0]&127;if(o>8)return this.error="Too big integer",-1;if(o+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=s.subarray(a,a+o);return c[o-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=hr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=o+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let s=Wt(this.length,8);if(s.byteLength>127)return this.error="Too big length",et;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let i=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let o=0;o<s.byteLength;o++)n[o+1]=i[o];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};D1.NAME="lengthBlock";var R={},xe=class extends kt{constructor({name:e=Xr,optional:t=!1,primitiveSchema:n,...s}={},i){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new C1(s),this.lenBlock=new D1(s),this.valueBlock=i?new i(s):new Re(s)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(e,t){let n=t||new Rn;t||S3(this);let s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let o=this.lenBlock.toBER(e);n.write(o),n.write(i)}return t?et:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return E3(t,n)}};xe.NAME="BaseBlock";function S3(r){if(r instanceof R.Constructed)for(let e of r.valueBlock.value)S3(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var U1=class extends xe{constructor({value:e=Xr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};U1.NAME="BaseStringBlock";var O1=class extends Lt(Re){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};O1.NAME="PrimitiveValueBlock";var R3,V1=class extends xe{constructor(e={}){super(e,O1),this.idBlock.isConstructed=!1}};R3=V1;R.Primitive=R3;V1.NAME="PRIMITIVE";function $a(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function ys(r,e=0,t=r.length){let n=e,s=new xe({},Re),i=new kt;if(!Tt(i,r,e,t))return s.error=i.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=a,t-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=a,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=xe;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=R.EndOfContent;break;case 1:c=R.Boolean;break;case 2:c=R.Integer;break;case 3:c=R.BitString;break;case 4:c=R.OctetString;break;case 5:c=R.Null;break;case 6:c=R.ObjectIdentifier;break;case 10:c=R.Enumerated;break;case 12:c=R.Utf8String;break;case 13:c=R.RelativeObjectIdentifier;break;case 14:c=R.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=R.Sequence;break;case 17:c=R.Set;break;case 18:c=R.NumericString;break;case 19:c=R.PrintableString;break;case 20:c=R.TeletexString;break;case 21:c=R.VideotexString;break;case 22:c=R.IA5String;break;case 23:c=R.UTCTime;break;case 24:c=R.GeneralizedTime;break;case 25:c=R.GraphicString;break;case 26:c=R.VisibleString;break;case 27:c=R.GeneralString;break;case 28:c=R.UniversalString;break;case 29:c=R.CharacterString;break;case 30:c=R.BmpString;break;case 31:c=R.DATE;break;case 32:c=R.TimeOfDay;break;case 33:c=R.DateTime;break;case 34:c=R.Duration;break;default:{let l=s.idBlock.isConstructed?new R.Constructed:new R.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?R.Constructed:R.Primitive}return s=$a(s,c),a=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function Jr(r){if(!r.byteLength){let e=new xe({},Re);return e.error="Input buffer has zero length",{offset:-1,result:e}}return ys(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function za(r,e){return r?1:e}var ut=class extends Re{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=H.BufferSourceConverter.toUint8Array(e);if(!Tt(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;za(this.isIndefiniteForm,n)>0;){let o=ys(s,i,n);if(o.offset===-1)return this.error=o.result.error,this.warnings.concat(o.result.warnings),-1;if(i=o.offset,this.blockLength+=o.result.blockLength,n-=o.result.blockLength,this.value.push(o.result),this.isIndefiniteForm&&o.result.constructor.NAME===kn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===kn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new Rn;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?et:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};ut.NAME="ConstructedValueBlock";var k3,Zt=class extends xe{constructor(e={}){super(e,ut),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
3
3
|
`).map(s=>` ${s}`).join(`
|
|
4
4
|
`));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
|
|
5
5
|
${e.join(`
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"EventTypes": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.EventTypes.html",
|
|
3
|
+
".:EventTypes": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.EventTypes.html",
|
|
4
|
+
"MessageType": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.MessageType.html",
|
|
5
|
+
".:MessageType": "https://libp2p.github.io/js-libp2p/enums/_libp2p_kad_dht.MessageType.html",
|
|
6
|
+
"Record": "https://libp2p.github.io/js-libp2p/classes/_libp2p_kad_dht.Record.html",
|
|
7
|
+
"AddPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.AddPeerEvent.html",
|
|
8
|
+
".:AddPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.AddPeerEvent.html",
|
|
9
|
+
"DHTRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DHTRecord.html",
|
|
10
|
+
".:DHTRecord": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DHTRecord.html",
|
|
11
|
+
"DialPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DialPeerEvent.html",
|
|
12
|
+
".:DialPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.DialPeerEvent.html",
|
|
13
|
+
"FinalPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.FinalPeerEvent.html",
|
|
14
|
+
".:FinalPeerEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.FinalPeerEvent.html",
|
|
15
|
+
"KadDHT": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHT.html",
|
|
16
|
+
".:KadDHT": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHT.html",
|
|
17
|
+
"KadDHTComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHTComponents.html",
|
|
18
|
+
".:KadDHTComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHTComponents.html",
|
|
19
|
+
"KadDHTInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHTInit.html",
|
|
20
|
+
".:KadDHTInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.KadDHTInit.html",
|
|
21
|
+
"PeerInfoMapper": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.PeerInfoMapper.html",
|
|
22
|
+
".:PeerInfoMapper": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.PeerInfoMapper.html",
|
|
23
|
+
"PeerResponseEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.PeerResponseEvent.html",
|
|
24
|
+
".:PeerResponseEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.PeerResponseEvent.html",
|
|
25
|
+
"ProviderEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ProviderEvent.html",
|
|
26
|
+
".:ProviderEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ProviderEvent.html",
|
|
27
|
+
"QueryErrorEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.QueryErrorEvent.html",
|
|
28
|
+
".:QueryErrorEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.QueryErrorEvent.html",
|
|
29
|
+
"RoutingTable": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.RoutingTable.html",
|
|
30
|
+
".:RoutingTable": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.RoutingTable.html",
|
|
31
|
+
"SelectFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SelectFn.html",
|
|
32
|
+
".:SelectFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SelectFn.html",
|
|
33
|
+
"SendQueryEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SendQueryEvent.html",
|
|
34
|
+
".:SendQueryEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SendQueryEvent.html",
|
|
35
|
+
"SingleKadDHT": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SingleKadDHT.html",
|
|
36
|
+
".:SingleKadDHT": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.SingleKadDHT.html",
|
|
37
|
+
"ValidateFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ValidateFn.html",
|
|
38
|
+
".:ValidateFn": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ValidateFn.html",
|
|
39
|
+
"ValueEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ValueEvent.html",
|
|
40
|
+
".:ValueEvent": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_kad_dht.ValueEvent.html",
|
|
41
|
+
"DHTProgressEvents": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.DHTProgressEvents.html",
|
|
42
|
+
".:DHTProgressEvents": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.DHTProgressEvents.html",
|
|
43
|
+
"MessageName": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.MessageName.html",
|
|
44
|
+
".:MessageName": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.MessageName.html",
|
|
45
|
+
"QueryEvent": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.QueryEvent.html",
|
|
46
|
+
".:QueryEvent": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.QueryEvent.html",
|
|
47
|
+
"Selectors": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.Selectors.html",
|
|
48
|
+
".:Selectors": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.Selectors.html",
|
|
49
|
+
"Validators": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.Validators.html",
|
|
50
|
+
".:Validators": "https://libp2p.github.io/js-libp2p/types/_libp2p_kad_dht.Validators.html",
|
|
51
|
+
"kadDHT": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.kadDHT-1.html",
|
|
52
|
+
".:kadDHT": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.kadDHT-1.html",
|
|
53
|
+
"passthroughMapper": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.passthroughMapper.html",
|
|
54
|
+
"removePrivateAddressesMapper": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.removePrivateAddressesMapper.html",
|
|
55
|
+
"removePublicAddressesMapper": "https://libp2p.github.io/js-libp2p/functions/_libp2p_kad_dht.removePublicAddressesMapper.html"
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/kad-dht",
|
|
3
|
-
"version": "12.0.
|
|
3
|
+
"version": "12.0.6",
|
|
4
4
|
"description": "JavaScript implementation of the Kad-DHT for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/kad-dht#readme",
|
|
@@ -56,61 +56,61 @@
|
|
|
56
56
|
"dep-check": "aegir dep-check"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@libp2p/crypto": "4.0.
|
|
60
|
-
"@libp2p/interface": "1.1.
|
|
61
|
-
"@libp2p/interface-internal": "1.0.
|
|
62
|
-
"@libp2p/peer-collections": "5.1.
|
|
63
|
-
"@libp2p/peer-id": "4.0.
|
|
64
|
-
"@libp2p/utils": "5.2.
|
|
65
|
-
"@multiformats/multiaddr": "^12.1.
|
|
66
|
-
"@types/sinon": "^17.0.
|
|
59
|
+
"@libp2p/crypto": "^4.0.2",
|
|
60
|
+
"@libp2p/interface": "^1.1.3",
|
|
61
|
+
"@libp2p/interface-internal": "^1.0.8",
|
|
62
|
+
"@libp2p/peer-collections": "^5.1.6",
|
|
63
|
+
"@libp2p/peer-id": "^4.0.6",
|
|
64
|
+
"@libp2p/utils": "^5.2.4",
|
|
65
|
+
"@multiformats/multiaddr": "^12.1.14",
|
|
66
|
+
"@types/sinon": "^17.0.3",
|
|
67
67
|
"any-signal": "^4.1.1",
|
|
68
68
|
"hashlru": "^2.3.0",
|
|
69
|
-
"interface-datastore": "^8.2.
|
|
70
|
-
"it-drain": "^3.0.
|
|
71
|
-
"it-length": "^3.0.
|
|
72
|
-
"it-length-prefixed": "^9.0.
|
|
73
|
-
"it-map": "^3.0.
|
|
74
|
-
"it-merge": "^3.0.
|
|
69
|
+
"interface-datastore": "^8.2.10",
|
|
70
|
+
"it-drain": "^3.0.5",
|
|
71
|
+
"it-length": "^3.0.4",
|
|
72
|
+
"it-length-prefixed": "^9.0.4",
|
|
73
|
+
"it-map": "^3.0.5",
|
|
74
|
+
"it-merge": "^3.0.3",
|
|
75
75
|
"it-parallel": "^3.0.6",
|
|
76
76
|
"it-pipe": "^3.0.1",
|
|
77
|
-
"it-protobuf-stream": "^1.1.
|
|
77
|
+
"it-protobuf-stream": "^1.1.2",
|
|
78
78
|
"it-pushable": "^3.2.3",
|
|
79
|
-
"it-take": "^3.0.
|
|
80
|
-
"multiformats": "^13.0.
|
|
79
|
+
"it-take": "^3.0.4",
|
|
80
|
+
"multiformats": "^13.0.1",
|
|
81
81
|
"p-defer": "^4.0.0",
|
|
82
82
|
"p-event": "^6.0.0",
|
|
83
|
-
"p-queue": "^8.0.
|
|
83
|
+
"p-queue": "^8.0.1",
|
|
84
84
|
"progress-events": "^1.0.0",
|
|
85
|
-
"protons-runtime": "^5.
|
|
85
|
+
"protons-runtime": "^5.4.0",
|
|
86
86
|
"race-signal": "^1.0.2",
|
|
87
|
-
"uint8-varint": "^2.0.
|
|
88
|
-
"uint8arraylist": "^2.4.
|
|
89
|
-
"uint8arrays": "^5.0.
|
|
87
|
+
"uint8-varint": "^2.0.4",
|
|
88
|
+
"uint8arraylist": "^2.4.8",
|
|
89
|
+
"uint8arrays": "^5.0.1"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@libp2p/interface-compliance-tests": "5.
|
|
93
|
-
"@libp2p/logger": "4.0.
|
|
94
|
-
"@libp2p/peer-id-factory": "4.0.
|
|
95
|
-
"@libp2p/peer-store": "10.0.
|
|
96
|
-
"@types/lodash.random": "^3.2.
|
|
97
|
-
"@types/lodash.range": "^3.2.
|
|
98
|
-
"@types/which": "^3.0.
|
|
99
|
-
"aegir": "^42.
|
|
100
|
-
"datastore-core": "^9.
|
|
101
|
-
"datastore-level": "^10.
|
|
92
|
+
"@libp2p/interface-compliance-tests": "^5.3.0",
|
|
93
|
+
"@libp2p/logger": "^4.0.6",
|
|
94
|
+
"@libp2p/peer-id-factory": "^4.0.6",
|
|
95
|
+
"@libp2p/peer-store": "^10.0.9",
|
|
96
|
+
"@types/lodash.random": "^3.2.9",
|
|
97
|
+
"@types/lodash.range": "^3.2.9",
|
|
98
|
+
"@types/which": "^3.0.3",
|
|
99
|
+
"aegir": "^42.2.3",
|
|
100
|
+
"datastore-core": "^9.2.7",
|
|
101
|
+
"datastore-level": "^10.1.6",
|
|
102
102
|
"delay": "^6.0.0",
|
|
103
103
|
"execa": "^8.0.1",
|
|
104
|
-
"it-all": "^3.0.
|
|
105
|
-
"it-filter": "^3.0.
|
|
106
|
-
"it-last": "^3.0.
|
|
104
|
+
"it-all": "^3.0.4",
|
|
105
|
+
"it-filter": "^3.0.4",
|
|
106
|
+
"it-last": "^3.0.4",
|
|
107
107
|
"it-pair": "^2.0.6",
|
|
108
108
|
"it-stream-types": "^2.0.1",
|
|
109
109
|
"lodash.random": "^3.2.0",
|
|
110
110
|
"lodash.range": "^3.2.0",
|
|
111
|
-
"p-retry": "^6.
|
|
111
|
+
"p-retry": "^6.2.0",
|
|
112
112
|
"p-wait-for": "^5.0.2",
|
|
113
|
-
"protons": "^7.
|
|
113
|
+
"protons": "^7.5.0",
|
|
114
114
|
"sinon": "^17.0.1",
|
|
115
115
|
"sinon-ts": "^2.0.0",
|
|
116
116
|
"wherearewe": "^2.0.1",
|