UNPKG

ipfs-bitswap

Version:

JavaScript implementation of the Bitswap data exchange protocol used by IPFS

2 lines 98.7 kB
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.IpfsBitswap = factory()}(typeof self !== 'undefined' ? self : this, function () { "use strict";var IpfsBitswap=(()=>{var Ts=Object.create;var Mt=Object.defineProperty;var Cs=Object.getOwnPropertyDescriptor;var As=Object.getOwnPropertyNames;var Ls=Object.getPrototypeOf,Bs=Object.prototype.hasOwnProperty;var E=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),M=(r,t)=>{for(var e in t)Mt(r,e,{get:t[e],enumerable:!0})},gr=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of As(t))!Bs.call(r,s)&&s!==e&&Mt(r,s,{get:()=>t[s],enumerable:!(n=Cs(t,s))||n.enumerable});return r};var q=(r,t,e)=>(e=r!=null?Ts(Ls(r)):{},gr(t||!r||!r.__esModule?Mt(e,"default",{value:r,enumerable:!0}):e,r)),Fs=r=>gr(Mt({},"__esModule",{value:!0}),r);var Hr=E((zc,zr)=>{zr.exports=Ur;var Or=128,wi=127,xi=~wi,_i=Math.pow(2,31);function Ur(r,t,e){t=t||[],e=e||0;for(var n=e;r>=_i;)t[e++]=r&255|Or,r/=128;for(;r&xi;)t[e++]=r&255|Or,r>>>=7;return t[e]=r|0,Ur.bytes=e-n+1,t}});var Vr=E((Hc,qr)=>{qr.exports=Te;var vi=128,Wr=127;function Te(r,n){var e=0,n=n||0,s=0,i=n,o,a=r.length;do{if(i>=a)throw Te.bytes=0,new RangeError("Could not decode varint");o=r[i++],e+=s<28?(o&Wr)<<s:(o&Wr)*Math.pow(2,s),s+=7}while(o>=vi);return Te.bytes=i-n,e}});var Gr=E((Wc,$r)=>{var ki=Math.pow(2,7),Si=Math.pow(2,14),Ei=Math.pow(2,21),Ti=Math.pow(2,28),Ci=Math.pow(2,35),Ai=Math.pow(2,42),Li=Math.pow(2,49),Bi=Math.pow(2,56),Fi=Math.pow(2,63);$r.exports=function(r){return r<ki?1:r<Si?2:r<Ei?3:r<Ti?4:r<Ci?5:r<Ai?6:r<Li?7:r<Bi?8:r<Fi?9:10}});var jr=E((qc,Xr)=>{Xr.exports={encode:Hr(),decode:Vr(),encodingLength:Gr()}});var Kr=E((Vc,Jr)=>{"use strict";var Qr=jr();Jr.exports=r=>{if(!(r instanceof Uint8Array))throw new Error("arg needs to be a Uint8Array");let t=[];for(;r.length>0;){let e=Qr.decode(r);t.push(e),r=r.slice(Qr.decode.bytes)}return t}});var Yr=E(($c,Zr)=>{var mt=1e3,gt=mt*60,bt=gt*60,tt=bt*24,Ni=tt*7,Di=tt*365.25;Zr.exports=function(r,t){t=t||{};var e=typeof r;if(e==="string"&&r.length>0)return Ii(r);if(e==="number"&&isFinite(r))return t.long?Pi(r):Mi(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function Ii(r){if(r=String(r),!(r.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(t){var e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*Di;case"weeks":case"week":case"w":return e*Ni;case"days":case"day":case"d":return e*tt;case"hours":case"hour":case"hrs":case"hr":case"h":return e*bt;case"minutes":case"minute":case"mins":case"min":case"m":return e*gt;case"seconds":case"second":case"secs":case"sec":case"s":return e*mt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:return}}}}function Mi(r){var t=Math.abs(r);return t>=tt?Math.round(r/tt)+"d":t>=bt?Math.round(r/bt)+"h":t>=gt?Math.round(r/gt)+"m":t>=mt?Math.round(r/mt)+"s":r+"ms"}function Pi(r){var t=Math.abs(r);return t>=tt?Ot(r,t,tt,"day"):t>=bt?Ot(r,t,bt,"hour"):t>=gt?Ot(r,t,gt,"minute"):t>=mt?Ot(r,t,mt,"second"):r+" ms"}function Ot(r,t,e,n){var s=t>=e*1.5;return Math.round(r/e)+" "+n+(s?"s":"")}});var en=E((Gc,tn)=>{function Ri(r){e.debug=e,e.default=e,e.coerce=l,e.disable=i,e.enable=s,e.enabled=o,e.humanize=Yr(),e.destroy=c,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let h=0;for(let f=0;f<u.length;f++)h=(h<<5)-h+u.charCodeAt(f),h|=0;return e.colors[Math.abs(h)%e.colors.length]}e.selectColor=t;function e(u){let h,f=null,g,d;function m(...p){if(!m.enabled)return;let w=m,_=Number(new Date),k=_-(h||_);w.diff=k,w.prev=h,w.curr=_,h=_,p[0]=e.coerce(p[0]),typeof p[0]!="string"&&p.unshift("%O");let S=0;p[0]=p[0].replace(/%([a-zA-Z%])/g,(O,I)=>{if(O==="%%")return"%";S++;let U=e.formatters[I];if(typeof U=="function"){let lt=p[S];O=U.call(w,lt),p.splice(S,1),S--}return O}),e.formatArgs.call(w,p),(w.log||e.log).apply(w,p)}return m.namespace=u,m.useColors=e.useColors(),m.color=e.selectColor(u),m.extend=n,m.destroy=e.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(g!==e.namespaces&&(g=e.namespaces,d=e.enabled(u)),d),set:p=>{f=p}}),typeof e.init=="function"&&e.init(m),m}function n(u,h){let f=e(this.namespace+(typeof h>"u"?":":h)+u);return f.log=this.log,f}function s(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let h,f=(typeof u=="string"?u:"").split(/[\s,]+/),g=f.length;for(h=0;h<g;h++)f[h]&&(u=f[h].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.slice(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...e.names.map(a),...e.skips.map(a).map(h=>"-"+h)].join(",");return e.enable(""),u}function o(u){if(u[u.length-1]==="*")return!0;let h,f;for(h=0,f=e.skips.length;h<f;h++)if(e.skips[h].test(u))return!1;for(h=0,f=e.names.length;h<f;h++)if(e.names[h].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function l(u){return u instanceof Error?u.stack||u.message:u}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return e.enable(e.load()),e}tn.exports=Ri});var rn=E((P,Ut)=>{P.formatArgs=Ui;P.save=zi;P.load=Hi;P.useColors=Oi;P.storage=Wi();P.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();P.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Oi(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Ui(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Ut.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;r.splice(1,0,t,"color: inherit");let e=0,n=0;r[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(e++,s==="%c"&&(n=e))}),r.splice(n,0,t)}P.log=console.debug||console.log||(()=>{});function zi(r){try{r?P.storage.setItem("debug",r):P.storage.removeItem("debug")}catch{}}function Hi(){let r;try{r=P.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function Wi(){try{return localStorage}catch{}}Ut.exports=en()(P);var{formatters:qi}=Ut.exports;qi.j=function(r){try{return JSON.stringify(r)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var an=E((hl,on)=>{on.exports=Le;var sn=128,ji=127,Qi=~ji,Ji=Math.pow(2,31);function Le(r,t,e){if(Number.MAX_SAFE_INTEGER&&r>Number.MAX_SAFE_INTEGER)throw Le.bytes=0,new RangeError("Could not encode varint");t=t||[],e=e||0;for(var n=e;r>=Ji;)t[e++]=r&255|sn,r/=128;for(;r&Qi;)t[e++]=r&255|sn,r>>>=7;return t[e]=r|0,Le.bytes=e-n+1,t}});var un=E((fl,ln)=>{ln.exports=Be;var Ki=128,cn=127;function Be(r,n){var e=0,n=n||0,s=0,i=n,o,a=r.length;do{if(i>=a||s>49)throw Be.bytes=0,new RangeError("Could not decode varint");o=r[i++],e+=s<28?(o&cn)<<s:(o&cn)*Math.pow(2,s),s+=7}while(o>=Ki);return Be.bytes=i-n,e}});var fn=E((dl,hn)=>{var Zi=Math.pow(2,7),Yi=Math.pow(2,14),to=Math.pow(2,21),eo=Math.pow(2,28),ro=Math.pow(2,35),no=Math.pow(2,42),so=Math.pow(2,49),io=Math.pow(2,56),oo=Math.pow(2,63);hn.exports=function(r){return r<Zi?1:r<Yi?2:r<to?3:r<eo?4:r<ro?5:r<no?6:r<so?7:r<io?8:r<oo?9:10}});var pn=E((pl,dn)=>{dn.exports={encode:an(),decode:un(),encodingLength:fn()}});var Wn=E((mh,Hn)=>{"use strict";function zn(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Qo(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return zn(r,e)}catch{e.message=r.message,e.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),zn(new s,e)}}Hn.exports=Qo});var Qn=E((Mh,jn)=>{"use strict";jn.exports=function(){return Date.now()}});var Kn=E((Ph,Jn)=>{"use strict";var ne=Qn(),cr=class{constructor(t,e,n){let s=this;this._started=ne(),this._rescheduled=0,this._scheduled=e,this._args=n,this._triggered=!1,this._timerWrapper=()=>{s._rescheduled>0?(s._scheduled=s._rescheduled-(ne()-s._started),s._schedule(s._scheduled)):(s._triggered=!0,t.apply(null,s._args))},this._timer=setTimeout(this._timerWrapper,e)}reschedule(t){t||(t=this._scheduled);let e=ne();e+t-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(t)):this._triggered?this._schedule(t):(this._started=e,this._rescheduled=t)}_schedule(t){this._triggered=!1,this._started=ne(),this._rescheduled=0,this._scheduled=t,this._timer=setTimeout(this._timerWrapper,t)}clear(){clearTimeout(this._timer)}};function ca(){if(typeof arguments[0]!="function")throw new Error("callback needed");if(typeof arguments[1]!="number")throw new Error("timeout needed");let r;if(arguments.length>0){r=new Array(arguments.length-2);for(var t=0;t<r.length;t++)r[t]=arguments[t+2]}return new cr(arguments[0],arguments[1],r)}Jn.exports=ca});var ts=E((Rh,Yn)=>{"use strict";var{AbortController:la}=globalThis,Zn=Kn(),lr=class r extends la{constructor(t){super(),this._ms=t,this._timer=Zn(()=>this.abort(),t),Object.setPrototypeOf(this,r.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=Zn(()=>this.abort(),this._ms)}};Yn.exports={TimeoutController:lr}});var ae=E((jh,dr)=>{"use strict";var vt=typeof Reflect=="object"?Reflect:null,os=vt&&typeof vt.apply=="function"?vt.apply:function(t,e,n){return Function.prototype.apply.call(t,e,n)},ie;vt&&typeof vt.ownKeys=="function"?ie=vt.ownKeys:Object.getOwnPropertySymbols?ie=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ie=function(t){return Object.getOwnPropertyNames(t)};function da(r){console&&console.warn&&console.warn(r)}var cs=Number.isNaN||function(t){return t!==t};function x(){x.init.call(this)}dr.exports=x;dr.exports.once=ba;x.EventEmitter=x;x.prototype._events=void 0;x.prototype._eventsCount=0;x.prototype._maxListeners=void 0;var as=10;function oe(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(x,"defaultMaxListeners",{enumerable:!0,get:function(){return as},set:function(r){if(typeof r!="number"||r<0||cs(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");as=r}});x.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};x.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||cs(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this};function ls(r){return r._maxListeners===void 0?x.defaultMaxListeners:r._maxListeners}x.prototype.getMaxListeners=function(){return ls(this)};x.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e.push(arguments[n]);var s=t==="error",i=this._events;if(i!==void 0)s=s&&i.error===void 0;else if(!s)return!1;if(s){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var l=i[t];if(l===void 0)return!1;if(typeof l=="function")os(l,this,e);else for(var c=l.length,u=ps(l,c),n=0;n<c;++n)os(u[n],this,e);return!0};function us(r,t,e,n){var s,i,o;if(oe(e),i=r._events,i===void 0?(i=r._events=Object.create(null),r._eventsCount=0):(i.newListener!==void 0&&(r.emit("newListener",t,e.listener?e.listener:e),i=r._events),o=i[t]),o===void 0)o=i[t]=e,++r._eventsCount;else if(typeof o=="function"?o=i[t]=n?[e,o]:[o,e]:n?o.unshift(e):o.push(e),s=ls(r),s>0&&o.length>s&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=t,a.count=o.length,da(a)}return r}x.prototype.addListener=function(t,e){return us(this,t,e,!1)};x.prototype.on=x.prototype.addListener;x.prototype.prependListener=function(t,e){return us(this,t,e,!0)};function pa(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function hs(r,t,e){var n={fired:!1,wrapFn:void 0,target:r,type:t,listener:e},s=pa.bind(n);return s.listener=e,n.wrapFn=s,s}x.prototype.once=function(t,e){return oe(e),this.on(t,hs(this,t,e)),this};x.prototype.prependOnceListener=function(t,e){return oe(e),this.prependListener(t,hs(this,t,e)),this};x.prototype.removeListener=function(t,e){var n,s,i,o,a;if(oe(e),s=this._events,s===void 0)return this;if(n=s[t],n===void 0)return this;if(n===e||n.listener===e)--this._eventsCount===0?this._events=Object.create(null):(delete s[t],s.removeListener&&this.emit("removeListener",t,n.listener||e));else if(typeof n!="function"){for(i=-1,o=n.length-1;o>=0;o--)if(n[o]===e||n[o].listener===e){a=n[o].listener,i=o;break}if(i<0)return this;i===0?n.shift():ma(n,i),n.length===1&&(s[t]=n[0]),s.removeListener!==void 0&&this.emit("removeListener",t,a||e)}return this};x.prototype.off=x.prototype.removeListener;x.prototype.removeAllListeners=function(t){var e,n,s;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var i=Object.keys(n),o;for(s=0;s<i.length;++s)o=i[s],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(e=n[t],typeof e=="function")this.removeListener(t,e);else if(e!==void 0)for(s=e.length-1;s>=0;s--)this.removeListener(t,e[s]);return this};function fs(r,t,e){var n=r._events;if(n===void 0)return[];var s=n[t];return s===void 0?[]:typeof s=="function"?e?[s.listener||s]:[s]:e?ga(s):ps(s,s.length)}x.prototype.listeners=function(t){return fs(this,t,!0)};x.prototype.rawListeners=function(t){return fs(this,t,!1)};x.listenerCount=function(r,t){return typeof r.listenerCount=="function"?r.listenerCount(t):ds.call(r,t)};x.prototype.listenerCount=ds;function ds(r){var t=this._events;if(t!==void 0){var e=t[r];if(typeof e=="function")return 1;if(e!==void 0)return e.length}return 0}x.prototype.eventNames=function(){return this._eventsCount>0?ie(this._events):[]};function ps(r,t){for(var e=new Array(t),n=0;n<t;++n)e[n]=r[n];return e}function ma(r,t){for(;t+1<r.length;t++)r[t]=r[t+1];r.pop()}function ga(r){for(var t=new Array(r.length),e=0;e<t.length;++e)t[e]=r[e].listener||r[e];return t}function ba(r,t){return new Promise(function(e,n){function s(o){r.removeListener(t,i),n(o)}function i(){typeof r.removeListener=="function"&&r.removeListener("error",s),e([].slice.call(arguments))}ms(r,t,i,{once:!0}),t!=="error"&&ya(r,s,{once:!0})})}function ya(r,t,e){typeof r.on=="function"&&ms(r,"error",t,e)}function ms(r,t,e,n){if(typeof r.on=="function")n.once?r.once(t,e):r.on(t,e);else if(typeof r.addEventListener=="function")r.addEventListener(t,function s(i){n.once&&r.removeEventListener(t,s),e(i)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof r)}});var _s=E((ws,xs)=>{"use strict";var wa=Math.exp;ws=xs.exports=function(t){if(typeof t!="number")throw new Error("must provide a timespan to the moving average constructor");if(t<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");let e,n=0,s=0,i=0,o,a={};function l(c,u){return 1-wa(-(c-u)/t)}return a.push=function(u,h){if(o){let f=l(u,o),g=h-e,d=f*g;e=f*h+(1-f)*e,n=(1-f)*(n+g*d),s=Math.sqrt(n),i=e+f*g}else e=h;o=u},a.movingAverage=function(){return e},a.variance=function(){return n},a.deviation=function(){return s},a.forecast=function(){return i},a}});var Ea={};M(Ea,{createBitswap:()=>Sa});function br(r){let t=new globalThis.AbortController;function e(){t.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}for(let i of r){if(i?.aborted===!0){e();break}i?.addEventListener!=null&&i.addEventListener("abort",e)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",e)}let s=t.signal;return s.clear=n,s}function Ns(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:s=>{n.push(s)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var Pt=Ns;function Ds(r){return r[Symbol.asyncIterator]!=null}function yr(r){return r?.then!=null}function Is(r,t){if(Ds(r))return async function*(){for await(let a of r){let l=t(a);yr(l)&&await l,yield a}}();let e=Pt(r),{value:n,done:s}=e.next();if(s===!0)return function*(){}();if(typeof t(n)?.then=="function")return async function*(){yield n;for await(let a of e){let l=t(a);yr(l)&&await l,yield a}}();let o=t;return function*(){yield n;for(let a of e)o(a),yield a}()}var wr=Is;var be={};M(be,{base32:()=>X,base32hex:()=>qs,base32hexpad:()=>$s,base32hexpadupper:()=>Gs,base32hexupper:()=>Vs,base32pad:()=>Hs,base32padupper:()=>Ws,base32upper:()=>zs,base32z:()=>Xs});var Fa=new Uint8Array(0);function xr(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function V(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 _r(r){return new TextEncoder().encode(r)}function vr(r){return new TextDecoder().decode(r)}function Ms(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var s=0;s<r.length;s++){var i=r.charAt(s),o=i.charCodeAt(0);if(e[o]!==255)throw new TypeError(i+" is ambiguous");e[o]=s}var a=r.length,l=r.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function h(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var m=0,p=0,w=0,_=d.length;w!==_&&d[w]===0;)w++,m++;for(var k=(_-w)*u+1>>>0,S=new Uint8Array(k);w!==_;){for(var D=d[w],O=0,I=k-1;(D!==0||O<p)&&I!==-1;I--,O++)D+=256*S[I]>>>0,S[I]=D%a>>>0,D=D/a>>>0;if(D!==0)throw new Error("Non-zero carry");p=O,w++}for(var U=k-p;U!==k&&S[U]===0;)U++;for(var lt=l.repeat(m);U<k;++U)lt+=r.charAt(S[U]);return lt}function f(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var m=0;if(d[m]!==" "){for(var p=0,w=0;d[m]===l;)p++,m++;for(var _=(d.length-m)*c+1>>>0,k=new Uint8Array(_);d[m];){var S=e[d.charCodeAt(m)];if(S===255)return;for(var D=0,O=_-1;(S!==0||D<w)&&O!==-1;O--,D++)S+=a*k[O]>>>0,k[O]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=D,m++}if(d[m]!==" "){for(var I=_-w;I!==_&&k[I]===0;)I++;for(var U=new Uint8Array(p+(_-I)),lt=p;I!==_;)U[lt++]=k[I++];return U}}}function g(d){var m=f(d);if(m)return m;throw new Error(`Non-${t} character`)}return{encode:h,decodeUnsafe:f,decode:g}}var Ps=Ms,Rs=Ps,Sr=Rs;var de=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},pe=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Er(this,t)}},me=class{decoders;constructor(t){this.decoders=t}or(t){return Er(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Er(r,t){return new me({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var ge=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new de(t,e,n),this.decoder=new pe(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ut({name:r,prefix:t,encode:e,decode:n}){return new ge(r,t,e,n)}function G({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=Sr(e,r);return ut({prefix:t,name:r,encode:n,decode:i=>V(s(i))})}function Os(r,t,e,n){let s={};for(let u=0;u<t.length;++u)s[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let o=new Uint8Array(i*e/8|0),a=0,l=0,c=0;for(let u=0;u<i;++u){let h=s[r[u]];if(h===void 0)throw new SyntaxError(`Non-${n} character`);l=l<<e|h,a+=e,a>=8&&(a-=8,o[c++]=255&l>>a)}if(a>=e||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return o}function Us(r,t,e){let n=t[t.length-1]==="=",s=(1<<e)-1,i="",o=0,a=0;for(let l=0;l<r.length;++l)for(a=a<<8|r[l],o+=8;o>e;)o-=e,i+=t[s&a>>o];if(o!==0&&(i+=t[s&a<<e-o]),n)for(;i.length*e&7;)i+="=";return i}function v({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ut({prefix:t,name:r,encode(s){return Us(s,n,e)},decode(s){return Os(s,n,e,r)}})}var X=v({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zs=v({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Hs=v({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ws=v({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qs=v({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vs=v({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),$s=v({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Gs=v({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xs=v({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ye={};M(ye,{base58btc:()=>b,base58flickr:()=>js});var b=G({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),js=G({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Qs=Ar,Tr=128,Js=127,Ks=~Js,Zs=Math.pow(2,31);function Ar(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Zs;)t[e++]=r&255|Tr,r/=128;for(;r&Ks;)t[e++]=r&255|Tr,r>>>=7;return t[e]=r|0,Ar.bytes=e-n+1,t}var Ys=we,ti=128,Cr=127;function we(r,n){var e=0,n=n||0,s=0,i=n,o,a=r.length;do{if(i>=a)throw we.bytes=0,new RangeError("Could not decode varint");o=r[i++],e+=s<28?(o&Cr)<<s:(o&Cr)*Math.pow(2,s),s+=7}while(o>=ti);return we.bytes=i-n,e}var ei=Math.pow(2,7),ri=Math.pow(2,14),ni=Math.pow(2,21),si=Math.pow(2,28),ii=Math.pow(2,35),oi=Math.pow(2,42),ai=Math.pow(2,49),ci=Math.pow(2,56),li=Math.pow(2,63),ui=function(r){return r<ei?1:r<ri?2:r<ni?3:r<si?4:r<ii?5:r<oi?6:r<ai?7:r<ci?8:r<li?9:10},hi={encode:Qs,decode:Ys,encodingLength:ui},fi=hi,kt=fi;function St(r,t=0){return[kt.decode(r,t),kt.decode.bytes]}function ht(r,t,e=0){return kt.encode(r,t,e),t}function ft(r){return kt.encodingLength(r)}function Y(r,t){let e=t.byteLength,n=ft(r),s=n+ft(e),i=new Uint8Array(s+e);return ht(r,i,0),ht(e,i,n),i.set(t,s),new dt(r,e,t,i)}function Lr(r){let t=V(r),[e,n]=St(t),[s,i]=St(t.subarray(n)),o=t.subarray(n+i);if(o.byteLength!==s)throw new Error("Incorrect length");return new dt(e,s,o,t)}function Br(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&xr(r.bytes,e.bytes)}}var dt=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};function Fr(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return pi(e,xe(r),t??b.encoder);default:return mi(e,xe(r),t??X.encoder)}}var Nr=new WeakMap;function xe(r){let t=Nr.get(r);if(t==null){let e=new Map;return Nr.set(r,e),e}return t}var T=class r{code;version;multihash;bytes;"/";constructor(t,e,n,s){this.code=e,this.version=t,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:t,multihash:e}=this;if(t!==Tt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==gi)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Y(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Br(t.multihash,n.multihash)}toString(t){return Fr(this,t)}toJSON(){return{"/":Fr(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:s,multihash:i,bytes:o}=e;return new r(n,s,i,o??Dr(n,s,i.bytes))}else if(e[bi]===!0){let{version:n,multihash:s,code:i}=e,o=Lr(s);return r.create(n,i,o)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Tt)throw new Error(`Version 0 CID must use dag-pb (code: ${Tt}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=Dr(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Tt,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,s=V(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=s.subarray(e.multihashSize-e.digestSize),o=new dt(e.multihashCode,e.digestSize,i,s);return[e.version===0?r.createV0(o):r.createV1(e.codec,o),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[h,f]=St(t.subarray(e));return e+=f,h},s=n(),i=Tt;if(s===18?(s=0,e=0):i=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let o=e,a=n(),l=n(),c=e+l,u=c-o;return{version:s,codec:i,multihashCode:a,digestSize:l,multihashSize:u,size:c}}static parse(t,e){let[n,s]=di(t,e),i=r.decode(s);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return xe(i).set(n,t),i}};function di(r,t){switch(r[0]){case"Q":{let e=t??b;return[b.prefix,e.decode(`${b.prefix}${r}`)]}case b.prefix:{let e=t??b;return[b.prefix,e.decode(r)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function pi(r,t,e){let{prefix:n}=e;if(n!==b.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return s}function mi(r,t,e){let{prefix:n}=e,s=t.get(n);if(s==null){let i=e.encode(r);return t.set(n,i),i}else return s}var Tt=112,gi=18;function Dr(r,t,e){let n=ft(r),s=n+ft(t),i=new Uint8Array(s+e.byteLength);return ht(r,i,0),ht(t,i,n),i.set(e,s),i}var bi=Symbol.for("@ipld/js-cid/CID");var _e=class extends Map{metric;constructor(t){super();let{name:e,metrics:n}=t;this.metric=n.registerMetric(e),this.updateComponentMetric()}set(t,e){return super.set(t,e),this.updateComponentMetric(),this}delete(t){let e=super.delete(t);return this.updateComponentMetric(),e}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}};function j(r){let{name:t,metrics:e}=r,n;return e!=null?n=new _e({name:t,metrics:e}):n=new Map,n}var Xa=Symbol.for("@libp2p/connection");var Qa=Symbol.for("@libp2p/content-routing");var Za=Symbol.for("@libp2p/peer-discovery");var tc=Symbol.for("@libp2p/peer-id");var rc=Symbol.for("@libp2p/peer-routing");var Ir;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Ir||(Ir={}));var oc=Symbol.for("@libp2p/transport");var Mr;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Mr||(Mr={}));var pt=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var ve=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},lc=globalThis.CustomEvent??ve;var Ee={};M(Ee,{sha256:()=>Ct,sha512:()=>yi});function Se({name:r,code:t,encode:e}){return new ke(r,t,e)}var ke=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Y(this.code,e):e.then(n=>Y(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Rr(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Ct=Se({name:"sha2-256",code:18,encode:Rr("SHA-256")}),yi=Se({name:"sha2-512",code:19,encode:Rr("SHA-512")});var Bn=q(Kr(),1);var R=q(rn(),1);var Ae={};M(Ae,{base64:()=>Ce,base64pad:()=>Vi,base64url:()=>$i,base64urlpad:()=>Gi});var Ce=v({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Vi=v({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$i=v({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gi=v({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});R.default.formatters.b=r=>r==null?"undefined":b.baseEncode(r);R.default.formatters.t=r=>r==null?"undefined":X.baseEncode(r);R.default.formatters.m=r=>r==null?"undefined":Ce.baseEncode(r);R.default.formatters.p=r=>r==null?"undefined":r.toString();R.default.formatters.c=r=>r==null?"undefined":r.toString();R.default.formatters.k=r=>r==null?"undefined":r.toString();R.default.formatters.a=r=>r==null?"undefined":r.toString();function Xi(r){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=r,t.destroy=()=>!0,t.extend=()=>t,t}function nn(r){let t=Xi(`${r}:trace`);return R.default.enabled(`${r}:trace`)&&R.default.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=(0,R.default)(`${r}:trace`)),Object.assign((0,R.default)(r),{error:(0,R.default)(`${r}:error`),trace:t})}function zt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var et=class{_refCounter;cid;priority;wantType;constructor(t,e,n){this._refCounter=1,this.cid=t,this.priority=e??1,this.wantType=n}inc(){this._refCounter+=1}dec(){this._refCounter=Math.max(0,this._refCounter-1)}hasRefs(){return this._refCounter>0}get[Symbol.toStringTag](){return`WantlistEntry <key: ${this.cid.toString(b)}, priority: ${this.priority}, refs: ${this._refCounter}>`}equals(t){return this._refCounter===t._refCounter&&this.cid.equals(t.cid)&&this.priority===t.priority&&this.wantType===t.wantType}};var Q=class{entry;cancel;sendDontHave;constructor(t,e,n,s,i){this.entry=new et(t,e,n),this.cancel=!!s,this.sendDontHave=!!i}get cid(){return this.entry.cid}set cid(t){this.entry.cid=t}get priority(){return this.entry.priority}set priority(t){this.entry.priority=t}get wantType(){return this.entry.wantType}set wantType(t){this.entry.wantType=t}get[Symbol.toStringTag](){return`BitswapMessageEntry ${this.cid.toString(b)} <cancel: ${this.cancel}, priority: ${this.priority}>`}equals(t){return this.cancel===t.cancel&&this.sendDontHave===t.sendDontHave&&this.wantType===t.wantType&&this.entry.equals(t.entry)}};var z=(r,t)=>{let e=["bitswap"];return t!=null&&e.push(t),r!=null&&e.push(`${r.toString().slice(0,8)}`),nn(e.join(":"))};var Ht=(r,t)=>{if(r.size!==t.size)return!1;for(let[e,n]of r){let s=t.get(e);if(s===void 0||n instanceof Uint8Array&&s instanceof Uint8Array&&!zt(n,s)||n instanceof Q&&s instanceof Q&&!n.equals(s))return!1}return!0};var At=q(pn(),1);function ao(r){let t=new Uint8Array(r.reduce((n,s)=>n+At.default.encodingLength(s),0)),e=0;for(let n of r)t=At.encode(n,t,e),e+=At.default.encodingLength(n);return t}var mn=ao;var Fe=new Float32Array([-0]),J=new Uint8Array(Fe.buffer);function gn(r,t,e){Fe[0]=r,t[e]=J[0],t[e+1]=J[1],t[e+2]=J[2],t[e+3]=J[3]}function bn(r,t){return J[0]=r[t],J[1]=r[t+1],J[2]=r[t+2],J[3]=r[t+3],Fe[0]}var Ne=new Float64Array([-0]),C=new Uint8Array(Ne.buffer);function yn(r,t,e){Ne[0]=r,t[e]=C[0],t[e+1]=C[1],t[e+2]=C[2],t[e+3]=C[3],t[e+4]=C[4],t[e+5]=C[5],t[e+6]=C[6],t[e+7]=C[7]}function wn(r,t){return C[0]=r[t],C[1]=r[t+1],C[2]=r[t+2],C[3]=r[t+3],C[4]=r[t+4],C[5]=r[t+5],C[6]=r[t+6],C[7]=r[t+7],Ne[0]}var co=BigInt(Number.MAX_SAFE_INTEGER),lo=BigInt(Number.MIN_SAFE_INTEGER),F=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return rt;if(t<co&&t>lo)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,s=t-(n<<32n);return e&&(n=~n|0n,s=~s|0n,++s>xn&&(s=0n,++n>xn&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return rt;let e=t<0;e&&(t=-t);let n=t>>>0,s=(t-n)/4294967296>>>0;return e&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):rt}},rt=new F(0,0);rt.toBigInt=function(){return 0n};rt.zzEncode=rt.zzDecode=function(){return this};rt.length=function(){return 1};var xn=4294967296n;function _n(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function vn(r,t,e){if(e-t<1)return"";let s,i=[],o=0,a;for(;t<e;)a=r[t++],a<128?i[o++]=a:a>191&&a<224?i[o++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,i[o++]=55296+(a>>10),i[o++]=56320+(a&1023)):i[o++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&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 De(r,t,e){let n=e,s,i;for(let o=0;o<r.length;++o)s=r.charCodeAt(o),s<128?t[e++]=s:s<2048?(t[e++]=s>>6|192,t[e++]=s&63|128):(s&64512)===55296&&((i=r.charCodeAt(o+1))&64512)===56320?(s=65536+((s&1023)<<10)+(i&1023),++o,t[e++]=s>>18|240,t[e++]=s>>12&63|128,t[e++]=s>>6&63|128,t[e++]=s&63|128):(t[e++]=s>>12|224,t[e++]=s>>6&63|128,t[e++]=s&63|128);return e-n}function H(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Wt(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Ie=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,H(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw H(this,4);return Wt(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw H(this,4);return Wt(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw H(this,4);let t=bn(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw H(this,4);let t=wn(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw H(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return vn(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw H(this,t);this.pos+=t}else do if(this.pos>=this.len)throw H(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new F(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw H(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw H(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw H(this,8);let t=Wt(this.buf,this.pos+=4),e=Wt(this.buf,this.pos+=4);return new F(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Me(r){return new Ie(r instanceof Uint8Array?r:r.subarray())}function nt(r,t){let e=Me(r);return t.decode(e)}function K(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function $(r=0){return globalThis.Buffer?.alloc!=null?K(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function A(r=0){return globalThis.Buffer?.allocUnsafe!=null?K(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}var Pe={};M(Pe,{base10:()=>uo});var uo=G({prefix:"9",name:"base10",alphabet:"0123456789"});var Re={};M(Re,{base16:()=>ho,base16upper:()=>fo});var ho=v({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fo=v({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Oe={};M(Oe,{base2:()=>po});var po=v({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ue={};M(Ue,{base256emoji:()=>wo});var Sn=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}"),mo=Sn.reduce((r,t,e)=>(r[e]=t,r),[]),go=Sn.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function bo(r){return r.reduce((t,e)=>(t+=mo[e],t),"")}function yo(r){let t=[];for(let e of r){let n=go[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var wo=ut({prefix:"\u{1F680}",name:"base256emoji",encode:bo,decode:yo});var ze={};M(ze,{base36:()=>xo,base36upper:()=>_o});var xo=G({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),_o=G({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var He={};M(He,{base8:()=>vo});var vo=v({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var We={};M(We,{identity:()=>ko});var ko=ut({prefix:"\0",name:"identity",encode:r=>vr(r),decode:r=>_r(r)});var Il=new TextEncoder,Ml=new TextDecoder;var qe={};M(qe,{identity:()=>Ao});var En=0,To="identity",Tn=V;function Co(r){return Y(En,Tn(r))}var Ao={code:En,name:To,encode:Tn,digest:Co};var Ve={...We,...Oe,...He,...Pe,...Re,...be,...ze,...ye,...Ae,...Ue},Xl={...Ee,...qe};function An(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Cn=An("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$e=An("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=A(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Lo={utf8:Cn,"utf-8":Cn,hex:Ve.base16,latin1:$e,ascii:$e,binary:$e,...Ve},qt=Lo;function Ln(r,t="utf8"){let e=qt[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?K(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Ge(r){let t=r??8192,e=t>>>1,n,s=t;return function(o){if(o<1||o>e)return A(o);s+o>t&&(n=A(t),s=0);let a=n.subarray(s,s+=o);return s&7&&(s=(s|7)+1),a}}var st=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Xe(){}var Qe=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Bo=Ge();function Fo(r){return globalThis.Buffer!=null?A(r):Bo(r)}var Ft=class{len;head;tail;states;constructor(){this.len=0,this.head=new st(Xe,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new st(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Je((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Lt,10,F.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=F.fromBigInt(t);return this._push(Lt,e.length(),e)}uint64Number(t){let e=F.fromNumber(t);return this._push(Lt,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=F.fromBigInt(t).zzEncode();return this._push(Lt,e.length(),e)}sint64Number(t){let e=F.fromNumber(t).zzEncode();return this._push(Lt,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(je,1,t?1:0)}fixed32(t){return this._push(Bt,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=F.fromBigInt(t);return this._push(Bt,4,e.lo)._push(Bt,4,e.hi)}fixed64Number(t){let e=F.fromNumber(t);return this._push(Bt,4,e.lo)._push(Bt,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(gn,4,t)}double(t){return this._push(yn,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(je,1,0):this.uint32(e)._push(Do,e,t)}string(t){let e=_n(t);return e!==0?this.uint32(e)._push(De,e,t):this._push(je,1,0)}fork(){return this.states=new Qe(this),this.head=this.tail=new st(Xe,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 st(Xe,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=Fo(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function je(r,t,e){t[e]=r&255}function No(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Je=class extends st{next;constructor(t,e){super(No,t,e),this.next=void 0}};function Lt(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Bt(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Do(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Ft.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Io,t,r),this},Ft.prototype.string=function(r){let t=globalThis.Buffer.byteLength