@helia/delegated-routing-v1-http-api-client 4.2.2 → 4.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,103 +1,20 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaDelegatedRoutingV1HttpApiClient = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var $f=Object.create;var Tn=Object.defineProperty;var Kf=Object.getOwnPropertyDescriptor;var qf=Object.getOwnPropertyNames;var zf=Object.getPrototypeOf,jf=Object.prototype.hasOwnProperty;var Ni=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Ct=(r,t)=>{for(var e in t)Tn(r,e,{get:t[e],enumerable:!0})},Pa=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qf(t))!jf.call(r,o)&&o!==e&&Tn(r,o,{get:()=>t[o],enumerable:!(n=Kf(t,o))||n.enumerable});return r};var Nn=(r,t,e)=>(e=r!=null?$f(zf(r)):{},Pa(t||!r||!r.__esModule?Tn(e,"default",{value:r,enumerable:!0}):e,r)),Gf=r=>Pa(Tn({},"__esModule",{value:!0}),r);var Hc=Ni(Sr=>{"use strict";var N0="[object ArrayBuffer]",ve=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===N0}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){let n=r.toUint8Array(t),o=r.toUint8Array(e);if(n.length!==o.byteLength)return!1;for(let i=0;i<n.length;i++)if(n[i]!==o[i])return!1;return!0}static concat(...t){let e;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?e=t[0]:t[t.length-1]instanceof Function?e=t.slice(0,t.length-1):e=t;let n=0;for(let s of e)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of e){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return t[t.length-1]instanceof Function?this.toView(o,t[t.length-1]):o.buffer}},Ms="string",U0=/^[0-9a-f\s]+$/i,R0=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,L0=/^[a-zA-Z0-9-_]+$/,to=class{static fromString(t){let e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n.buffer}static toString(t){let e=ve.toUint8Array(t),n="";for(let i=0;i<e.length;i++)n+=String.fromCharCode(e[i]);return decodeURIComponent(escape(n))}},Kt=class{static toString(t,e=!1){let n=ve.toArrayBuffer(t),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,e);i+=String.fromCharCode(a)}return i}static fromString(t,e=!1){let n=new ArrayBuffer(t.length*2),o=new DataView(n);for(let i=0;i<t.length;i++)o.setUint16(i*2,t.charCodeAt(i),e);return n}},eo=class r{static isHex(t){return typeof t===Ms&&U0.test(t)}static isBase64(t){return typeof t===Ms&&R0.test(t)}static isBase64Url(t){return typeof t===Ms&&L0.test(t)}static ToString(t,e="utf8"){let n=ve.toUint8Array(t);switch(e.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 Kt.toString(n,!0);case"utf16":case"utf16be":return Kt.toString(n);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return Kt.fromString(t,!0);case"utf16":case"utf16be":return Kt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=ve.toUint8Array(t);if(typeof btoa<"u"){let n=this.ToString(e,"binary");return btoa(n)}else return Buffer.from(e).toString("base64")}static FromBase64(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return to.fromString(t);case"utf16":case"utf16be":return Kt.fromString(t);case"utf16le":case"usc2":return Kt.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return to.toString(t);case"utf16":case"utf16be":return Kt.toString(t);case"utf16le":case"usc2":return Kt.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){let e=t.length,n=new Uint8Array(e);for(let o=0;o<e;o++)n[o]=t.charCodeAt(o);return n.buffer}static ToBinary(t){let e=ve.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return n}static ToHex(t){let e=ve.toUint8Array(t),n="",o=e.length;for(let i=0;i<o;i++){let s=e[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);let n=new Uint8Array(e.length/2);for(let o=0;o<e.length;o=o+2){let i=e.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(t,e=!1){return Kt.toString(t,e)}static FromUtf16String(t,e=!1){return Kt.fromString(t,e)}static Base64Padding(t){let e=4-t.length%4;if(e<4)for(let n=0;n<e;n++)t+="=";return t}static formatString(t){return t?.replace(/[\n\r\t ]/g,"")||""}};eo.DEFAULT_UTF8_ENCODING="utf8";function V0(r,...t){let e=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)e[i]=o[i]}return e}function _0(...r){let t=r.map(o=>o.byteLength).reduce((o,i)=>o+i),e=new Uint8Array(t),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)e[n++]=i}),e.buffer}function P0(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let o=0;o<r.byteLength;o++)if(e[o]!==n[o])return!1;return!0}Sr.BufferSourceConverter=ve;Sr.Convert=eo;Sr.assign=V0;Sr.combine=_0;Sr.isEqual=P0});var ma=Ni((k1,ga)=>{var I1=function(){typeof ga<"u"&&(ga.exports=w);var r=86400,t=3200,e=146097*t/400,n=r*e,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",f=Math.trunc||function(b){var v=b-b%1;return v==0&&(b<0||b===0&&1/b!=1/0)?-0:v},u=w.prototype,l=(w.fromDate=function(b){return new w(+b)},w.fromInt64BE=U(0,1,2,3,0,4),w.fromInt64LE=U(3,2,1,0,4,0),w.fromString=function(L){var v,D=new w,L=(L+="").replace(/^\s*[+\-]?\d+/,function($){var $=+$,S=1970+($-1970)%400;return D.year=$-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(T,$,S){return $<0&&(S*=-1),v=6e4*(60*+$+ +S),""}).replace(/\.\d+$/,function(T){return D.nano=+(T+c).substr(1,9),""}).split(/\D+/);if(1<L.length?L[1]--:L[1]=0,D.time=v=Date.UTC.apply(Date,L)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return d(D)},w.fromTimeT=function(b){return C(b,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(b){return this.nano+=+b||0,this},u.getNano=function(){var b=d(this);return(b.time%1e3*a+ +b.nano+1e9)%1e9},u.getTimeT=function(){var v=d(this),b=Math.floor(v.time/1e3),v=v.year;return v&&(b+=v*e*r/t),b},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return A(d(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(b){var v=this,D=v.toDate(),L={H:function(){return P(D.getUTCHours())},L:function(){return R(D.getUTCMilliseconds(),3)},M:function(){return P(D.getUTCMinutes())},N:function(){return R(v.getNano(),9)},S:function(){return P(D.getUTCSeconds())},Y:function(){var T=v.getYear();return 999999<T?"+"+T:9999<T?"+"+R(T,6):0<=T?R(T,4):-999999<=T?"-"+R(-T,6):T},a:function(){return m[D.getUTCDay()]},b:function(){return h[D.getUTCMonth()]},d:function(){return P(D.getUTCDate())},e:function(){return function(T){return(9<T?"":" ")+(0|T)}(D.getUTCDate())},m:function(){return P(D.getUTCMonth()+1)}};return function T($){return $.replace(/%./g,function(S){var g=S[1],I=B[g],g=L[g];return I?T(I):g?g():S})}(b||l)},u.writeInt64BE=x(0,1,2,3,0,4),u.writeInt64LE=x(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],B={"%":"%",F:"%Y-%m-%d",n:`
3
- `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return w;function w(b,v,D){var L=this;if(!(L instanceof w))return new w(b,v,D);L.time=+b||0,L.nano=+v||0,L.year=+D||0,d(L)}function d(b){var v,D,L,T=b.year,$=b.time,S=b.nano,I=((S<0||a<=S)&&(S-=(D=Math.floor(S/a))*a,$+=D,D=1),T%t);return($<-i||i<$||I)&&((v=f($/o))&&(T+=v*t,$-=v*o),(L=A($)).setUTCFullYear(I+L.getUTCFullYear()),L=($=+L)+(v=f((T-=I)/t))*o,v&&-i<=L&&L<=i&&(T-=v*t,$=L),D=1),D&&(b.year=T,b.time=$,b.nano=S),b}function A(b){var v=new Date(0);return v.setTime(b),v}function C(T,L){T=+T||0;var D=f((L=(L|0)*s)/n)+f(T/n),L=L%n+T%n,T=f(L/n);return T&&(D+=T,L-=T*n),new w(1e3*L,0,D*t)}function x(b,v,D,L,T,$){return function(I,g){var E=d(this);I=I||new Array(8),F(I,g|=0);var N=Math.floor(E.time/1e3),E=E.year*(e*r/t),p=f(E/s)+f(N/s),E=E%s+N%s,N=Math.floor(E/s);return N&&(p+=N,E-=N*s),S(I,g+T,p),S(I,g+$,E),I};function S(I,g,p){I[g+b]=p>>24&255,I[g+v]=p>>16&255,I[g+D]=p>>8&255,I[g+L]=255&p}}function U(b,v,D,L,T,$){return function(I,g){F(I,g|=0);var p=S(I,g+T);return C(S(I,g+$),p)};function S(I,g){return 16777216*I[g+b]+(I[g+v]<<16|I[g+D]<<8|I[g+L])}}function F(b,v){if(b=b&&b.length,b==null)throw new TypeError("Invalid Buffer");if(b<v+8)throw new RangeError("Out of range")}function P(b){return(9<b?"":"0")+(0|b)}function R(b,v){return(c+(0|b)).substr(-v)}}()});var If=Ni((Ev,Aa)=>{"use strict";var ug=Object.prototype.hasOwnProperty,Nt="~";function Sn(){}Object.create&&(Sn.prototype=Object.create(null),new Sn().__proto__||(Nt=!1));function lg(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function Sf(r,t,e,n,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var i=new lg(e,n||r,o),s=Nt?Nt+t:t;return r._events[s]?r._events[s].fn?r._events[s]=[r._events[s],i]:r._events[s].push(i):(r._events[s]=i,r._eventsCount++),r}function Ai(r,t){--r._eventsCount===0?r._events=new Sn:delete r._events[t]}function It(){this._events=new Sn,this._eventsCount=0}It.prototype.eventNames=function(){var t=[],e,n;if(this._eventsCount===0)return t;for(n in e=this._events)ug.call(e,n)&&t.push(Nt?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};It.prototype.listeners=function(t){var e=Nt?Nt+t:t,n=this._events[e];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};It.prototype.listenerCount=function(t){var e=Nt?Nt+t:t,n=this._events[e];return n?n.fn?1:n.length:0};It.prototype.emit=function(t,e,n,o,i,s){var a=Nt?Nt+t:t;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,o),!0;case 5:return c.fn.call(c.context,e,n,o,i),!0;case 6:return c.fn.call(c.context,e,n,o,i,s),!0}for(l=1,u=new Array(f-1);l<f;l++)u[l-1]=arguments[l];c.fn.apply(c.context,u)}else{var h=c.length,m;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,n);break;case 4:c[l].fn.call(c[l].context,e,n,o);break;default:if(!u)for(m=1,u=new Array(f-1);m<f;m++)u[m-1]=arguments[m];c[l].fn.apply(c[l].context,u)}}return!0};It.prototype.on=function(t,e,n){return Sf(this,t,e,n,!1)};It.prototype.once=function(t,e,n){return Sf(this,t,e,n,!0)};It.prototype.removeListener=function(t,e,n,o){var i=Nt?Nt+t:t;if(!this._events[i])return this;if(!e)return Ai(this,i),this;var s=this._events[i];if(s.fn)s.fn===e&&(!o||s.once)&&(!n||s.context===n)&&Ai(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==e||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Ai(this,i)}return this};It.prototype.removeAllListeners=function(t){var e;return t?(e=Nt?Nt+t:t,this._events[e]&&Ai(this,e)):(this._events=new Sn,this._eventsCount=0),this};It.prototype.off=It.prototype.removeListener;It.prototype.addListener=It.prototype.on;It.prefixed=Nt;It.EventEmitter=It;typeof Aa<"u"&&(Aa.exports=It)});var yg={};Ct(yg,{createDelegatedRoutingV1HttpApiClient:()=>mg});var Fa=Symbol.for("@libp2p/content-routing");var Ui=Symbol.for("@libp2p/peer-id");var Da=Symbol.for("@libp2p/peer-routing");var vt=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},sr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var ie=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var ar=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var cr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Pi={};Ct(Pi,{base32:()=>jt,base32hex:()=>rh,base32hexpad:()=>oh,base32hexpadupper:()=>ih,base32hexupper:()=>nh,base32pad:()=>th,base32padupper:()=>eh,base32upper:()=>Qf,base32z:()=>sh});var Bg=new Uint8Array(0);function Oa(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 de(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 Ma(r){return new TextEncoder().encode(r)}function Ha(r){return new TextDecoder().decode(r)}function Zf(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 o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(e[s]!==255)throw new TypeError(i+" is ambiguous");e[s]=o}var a=r.length,c=r.charAt(0),f=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(B){if(B instanceof Uint8Array||(ArrayBuffer.isView(B)?B=new Uint8Array(B.buffer,B.byteOffset,B.byteLength):Array.isArray(B)&&(B=Uint8Array.from(B))),!(B instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(B.length===0)return"";for(var w=0,d=0,A=0,C=B.length;A!==C&&B[A]===0;)A++,w++;for(var x=(C-A)*u+1>>>0,U=new Uint8Array(x);A!==C;){for(var F=B[A],P=0,R=x-1;(F!==0||P<d)&&R!==-1;R--,P++)F+=256*U[R]>>>0,U[R]=F%a>>>0,F=F/a>>>0;if(F!==0)throw new Error("Non-zero carry");d=P,A++}for(var b=x-d;b!==x&&U[b]===0;)b++;for(var v=c.repeat(w);b<x;++b)v+=r.charAt(U[b]);return v}function h(B){if(typeof B!="string")throw new TypeError("Expected String");if(B.length===0)return new Uint8Array;var w=0;if(B[w]!==" "){for(var d=0,A=0;B[w]===c;)d++,w++;for(var C=(B.length-w)*f+1>>>0,x=new Uint8Array(C);B[w];){var U=e[B.charCodeAt(w)];if(U===255)return;for(var F=0,P=C-1;(U!==0||F<A)&&P!==-1;P--,F++)U+=a*x[P]>>>0,x[P]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");A=F,w++}if(B[w]!==" "){for(var R=C-A;R!==C&&x[R]===0;)R++;for(var b=new Uint8Array(d+(C-R)),v=d;R!==C;)b[v++]=x[R++];return b}}}function m(B){var w=h(B);if(w)return w;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:h,decode:m}}var Wf=Zf,Jf=Wf,Ka=Jf;var Ri=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")}},Li=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let o=e.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return qa(this,t)}},Vi=class{decoders;constructor(t){this.decoders=t}or(t){return qa(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 qa(r,t){return new Vi({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var _i=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,o){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=o,this.encoder=new Ri(t,e,n),this.decoder=new Li(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ur({name:r,prefix:t,encode:e,decode:n}){return new _i(r,t,e,n)}function Ne({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=Ka(e,r);return ur({prefix:t,name:r,encode:n,decode:i=>de(o(i))})}function Yf(r,t,e,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*e/8|0),a=0,c=0,f=0;for(let u=0;u<i;++u){let l=o[r[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|l,a+=e,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Xf(r,t,e){let n=t[t.length-1]==="=",o=(1<<e)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>e;)s-=e,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<e-s]),n)for(;i.length*e&7;)i+="=";return i}function at({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ur({prefix:t,name:r,encode(o){return Xf(o,n,e)},decode(o){return Yf(o,n,e,r)}})}var jt=at({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qf=at({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),th=at({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),eh=at({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rh=at({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nh=at({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),oh=at({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ih=at({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sh=at({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fi={};Ct(Fi,{base58btc:()=>et,base58flickr:()=>ah});var et=Ne({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ah=Ne({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Oi={};Ct(Oi,{base64:()=>Di,base64pad:()=>ch,base64url:()=>uh,base64urlpad:()=>lh});var Di=at({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ch=at({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),uh=at({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),lh=at({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function fh(r,t){try{if(typeof r=="string"&&r.length>0)return hh(r);if(typeof r=="number"&&isFinite(r))return t?.long?ph(r):dh(r);throw new Error("Value is not a string or number.")}catch(e){let n=gh(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function hh(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let 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)return NaN;let e=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return e*315576e5;case"weeks":case"week":case"w":return e*6048e5;case"days":case"day":case"d":return e*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return e*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return e*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return e*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return e;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Rn=fh;function dh(r){let t=Math.abs(r);return t>=864e5?`${Math.round(r/864e5)}d`:t>=36e5?`${Math.round(r/36e5)}h`:t>=6e4?`${Math.round(r/6e4)}m`:t>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function ph(r){let t=Math.abs(r);return t>=864e5?Un(r,t,864e5,"day"):t>=36e5?Un(r,t,36e5,"hour"):t>=6e4?Un(r,t,6e4,"minute"):t>=1e3?Un(r,t,1e3,"second"):`${r} ms`}function Un(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function gh(r){return typeof r=="object"&&r!==null&&"message"in r}function Mi(r){e.debug=e,e.default=e,e.coerce=c,e.disable=i,e.enable=o,e.enabled=s,e.humanize=Rn,e.destroy=f,Object.keys(r).forEach(u=>{e[u]=r[u]}),e.names=[],e.skips=[],e.formatters={};function t(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return e.colors[Math.abs(l)%e.colors.length]}e.selectColor=t;function e(u){let l,h=null,m,B;function w(...d){if(!w.enabled)return;let A=w,C=Number(new Date),x=C-(l||C);A.diff=x,A.prev=l,A.curr=C,l=C,d[0]=e.coerce(d[0]),typeof d[0]!="string"&&d.unshift("%O");let U=0;d[0]=d[0].replace(/%([a-zA-Z%])/g,(P,R)=>{if(P==="%%")return"%";U++;let b=e.formatters[R];if(typeof b=="function"){let v=d[U];P=b.call(A,v),d.splice(U,1),U--}return P}),e.formatArgs.call(A,d),(A.log||e.log).apply(A,d)}return w.namespace=u,w.useColors=e.useColors(),w.color=e.selectColor(u),w.extend=n,w.destroy=e.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(m!==e.namespaces&&(m=e.namespaces,B=e.enabled(u)),B),set:d=>{h=d}}),typeof e.init=="function"&&e.init(w),w}function n(u,l){let h=e(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){e.save(u),e.namespaces=u,e.names=[],e.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),m=h.length;for(l=0;l<m;l++)h[l]&&(u=h[l].replace(/\*/g,".*?"),u[0]==="-"?e.skips.push(new RegExp("^"+u.substr(1)+"$")):e.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...e.names.map(a),...e.skips.map(a).map(l=>"-"+l)].join(",");return e.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=e.skips.length;l<h;l++)if(e.skips[l].test(u))return!1;for(l=0,h=e.names.length;l<h;l++)if(e.names[l].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function f(){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.setupFormatters(e.formatters),e.enable(e.load()),e}var Ln=Eh(),mh=["#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 yh(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function wh(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Rn(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,o=>{o!=="%%"&&(e++,o==="%c"&&(n=e))}),r.splice(n,0,t)}var xh=console.debug??console.log??(()=>{});function bh(r){try{r?Ln?.setItem("debug",r):Ln?.removeItem("debug")}catch{}}function vh(){let r;try{r=Ln?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function Eh(){try{return localStorage}catch{}}function Bh(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var za=Mi({formatArgs:wh,save:bh,load:vh,useColors:yh,setupFormatters:Bh,colors:mh,storage:Ln,log:xh});var Rt=za;Rt.formatters.b=r=>r==null?"undefined":et.baseEncode(r);Rt.formatters.t=r=>r==null?"undefined":jt.baseEncode(r);Rt.formatters.m=r=>r==null?"undefined":Di.baseEncode(r);Rt.formatters.p=r=>r==null?"undefined":r.toString();Rt.formatters.c=r=>r==null?"undefined":r.toString();Rt.formatters.k=r=>r==null?"undefined":r.toString();Rt.formatters.a=r=>r==null?"undefined":r.toString();Rt.formatters.e=r=>r==null?"undefined":ja(r.stack)??ja(r.message)??r.toString();function Ah(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 Ue(r){let t=Ah(`${r}:trace`);return Rt.enabled(`${r}:trace`)&&Rt.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=Rt(`${r}:trace`)),Object.assign(Rt(r),{error:Rt(`${r}:error`),trace:t})}function ja(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}var Hi={};Ct(Hi,{base36:()=>lr,base36upper:()=>Sh});var lr=Ne({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sh=Ne({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ih=Wa,Ga=128,kh=127,Ch=~kh,Th=Math.pow(2,31);function Wa(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Th;)t[e++]=r&255|Ga,r/=128;for(;r&Ch;)t[e++]=r&255|Ga,r>>>=7;return t[e]=r|0,Wa.bytes=e-n+1,t}var Nh=$i,Uh=128,Za=127;function $i(r,n){var e=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw $i.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&Za)<<o:(s&Za)*Math.pow(2,o),o+=7}while(s>=Uh);return $i.bytes=i-n,e}var Rh=Math.pow(2,7),Lh=Math.pow(2,14),Vh=Math.pow(2,21),_h=Math.pow(2,28),Ph=Math.pow(2,35),Fh=Math.pow(2,42),Dh=Math.pow(2,49),Oh=Math.pow(2,56),Mh=Math.pow(2,63),Hh=function(r){return r<Rh?1:r<Lh?2:r<Vh?3:r<_h?4:r<Ph?5:r<Fh?6:r<Dh?7:r<Oh?8:r<Mh?9:10},$h={encode:Ih,decode:Nh,encodingLength:Hh},Kh=$h,qr=Kh;function zr(r,t=0){return[qr.decode(r,t),qr.decode.bytes]}function fr(r,t,e=0){return qr.encode(r,t,e),t}function hr(r){return qr.encodingLength(r)}function Gt(r,t){let e=t.byteLength,n=hr(r),o=n+hr(e),i=new Uint8Array(o+e);return fr(r,i,0),fr(e,i,n),i.set(t,o),new dr(r,e,t,i)}function pe(r){let t=de(r),[e,n]=zr(t),[o,i]=zr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new dr(e,o,s,t)}function Ja(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Oa(r.bytes,e.bytes)}}var dr=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function Ya(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return zh(e,Ki(r),t??et.encoder);default:return jh(e,Ki(r),t??jt.encoder)}}var Xa=new WeakMap;function Ki(r){let t=Xa.get(r);if(t==null){let e=new Map;return Xa.set(r,e),e}return t}var it=class r{code;version;multihash;bytes;"/";constructor(t,e,n,o){this.code=e,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:e}=this;if(t!==jr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Gh)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=Gt(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&&Ja(t.multihash,n.multihash)}toString(t){return Ya(this,t)}toJSON(){return{"/":Ya(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:o,multihash:i,bytes:s}=e;return new r(n,o,i,s??Qa(n,o,i.bytes))}else if(e[Zh]===!0){let{version:n,multihash:o,code:i}=e,s=pe(o);return r.create(n,i,s)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==jr)throw new Error(`Version 0 CID must use dag-pb (code: ${jr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=Qa(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,jr,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,o=de(t.subarray(n,n+e.multihashSize));if(o.byteLength!==e.multihashSize)throw new Error("Incorrect length");let i=o.subarray(e.multihashSize-e.digestSize),s=new dr(e.multihashCode,e.digestSize,i,o);return[e.version===0?r.createV0(s):r.createV1(e.codec,s),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[l,h]=zr(t.subarray(e));return e+=h,l},o=n(),i=jr;if(o===18?(o=0,e=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=e,a=n(),c=n(),f=e+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(t,e){let[n,o]=qh(t,e),i=r.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ki(i).set(n,t),i}};function qh(r,t){switch(r[0]){case"Q":{let e=t??et;return[et.prefix,e.decode(`${et.prefix}${r}`)]}case et.prefix:{let e=t??et;return[et.prefix,e.decode(r)]}case jt.prefix:{let e=t??jt;return[jt.prefix,e.decode(r)]}case lr.prefix:{let e=t??lr;return[lr.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function zh(r,t,e){let{prefix:n}=e;if(n!==et.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let o=t.get(n);if(o==null){let i=e.encode(r).slice(1);return t.set(n,i),i}else return o}function jh(r,t,e){let{prefix:n}=e,o=t.get(n);if(o==null){let i=e.encode(r);return t.set(n,i),i}else return o}var jr=112,Gh=18;function Qa(r,t,e){let n=hr(r),o=n+hr(t),i=new Uint8Array(o+e.byteLength);return fr(r,i,0),fr(t,i,n),i.set(e,o),i}var Zh=Symbol.for("@ipld/js-cid/CID");var qi={};Ct(qi,{identity:()=>ge});var tc=0,Wh="identity",ec=de;function Jh(r){return Gt(tc,ec(r))}var ge={code:tc,name:Wh,encode:ec,digest:Jh};function ct(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 rc(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Yh(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function pr(r,...t){if(!Yh(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function nc(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rc(r.outputLen),rc(r.blockLen)}function gr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function oc(r,t){pr(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Ze=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function _n(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Zt(r,t){return r<<32-t|r>>>t}function ic(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Gr(r){return typeof r=="string"&&(r=ic(r)),pr(r),r}function zi(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];pr(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}var mr=class{clone(){return this._cloneInto()}};function Pn(r){let t=n=>r().update(Gr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Fn(r=32){if(Ze&&typeof Ze.getRandomValues=="function")return Ze.getRandomValues(new Uint8Array(r));if(Ze&&typeof Ze.randomBytes=="function")return Ze.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Xh(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(e>>o&i),a=Number(e&i),c=n?4:0,f=n?0:4;r.setUint32(t+c,s,n),r.setUint32(t+f,a,n)}function sc(r,t,e){return r&t^~r&e}function ac(r,t,e){return r&t^r&e^t&e}var yr=class extends mr{constructor(t,e,n,o){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=_n(this.buffer)}update(t){gr(this);let{view:e,buffer:n,blockLen:o}=this;t=Gr(t);let i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=_n(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){gr(this),oc(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)e[l]=0;Xh(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=_n(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let f=c/4,u=this.get();if(f>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<f;l++)a.setUint32(4*l,u[l],i)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.length=o,t.pos=a,t.finished=i,t.destroyed=s,o%e&&t.buffer.set(n),t}};var Dn=BigInt(4294967295),ji=BigInt(32);function cc(r,t=!1){return t?{h:Number(r&Dn),l:Number(r>>ji&Dn)}:{h:Number(r>>ji&Dn)|0,l:Number(r&Dn)|0}}function Qh(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=cc(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var td=(r,t)=>BigInt(r>>>0)<<ji|BigInt(t>>>0),ed=(r,t,e)=>r>>>e,rd=(r,t,e)=>r<<32-e|t>>>e,nd=(r,t,e)=>r>>>e|t<<32-e,od=(r,t,e)=>r<<32-e|t>>>e,id=(r,t,e)=>r<<64-e|t>>>e-32,sd=(r,t,e)=>r>>>e-32|t<<64-e,ad=(r,t)=>t,cd=(r,t)=>r,ud=(r,t,e)=>r<<e|t>>>32-e,ld=(r,t,e)=>t<<e|r>>>32-e,fd=(r,t,e)=>t<<e-32|r>>>64-e,hd=(r,t,e)=>r<<e-32|t>>>64-e;function dd(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var pd=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),gd=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,md=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),yd=(r,t,e,n,o)=>t+e+n+o+(r/2**32|0)|0,wd=(r,t,e,n,o)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(o>>>0),xd=(r,t,e,n,o,i)=>t+e+n+o+i+(r/2**32|0)|0;var bd={fromBig:cc,split:Qh,toBig:td,shrSH:ed,shrSL:rd,rotrSH:nd,rotrSL:od,rotrBH:id,rotrBL:sd,rotr32H:ad,rotr32L:cd,rotlSH:ud,rotlSL:ld,rotlBH:fd,rotlBL:hd,add:dd,add3L:pd,add3H:gd,add4L:md,add4H:yd,add5H:xd,add5L:wd},q=bd;var[vd,Ed]=q.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))),Le=new Uint32Array(80),Ve=new Uint32Array(80),Gi=class extends yr{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:t,Al:e,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:m,Gl:B,Hh:w,Hl:d}=this;return[t,e,n,o,i,s,a,c,f,u,l,h,m,B,w,d]}set(t,e,n,o,i,s,a,c,f,u,l,h,m,B,w,d){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=u|0,this.Fh=l|0,this.Fl=h|0,this.Gh=m|0,this.Gl=B|0,this.Hh=w|0,this.Hl=d|0}process(t,e){for(let x=0;x<16;x++,e+=4)Le[x]=t.getUint32(e),Ve[x]=t.getUint32(e+=4);for(let x=16;x<80;x++){let U=Le[x-15]|0,F=Ve[x-15]|0,P=q.rotrSH(U,F,1)^q.rotrSH(U,F,8)^q.shrSH(U,F,7),R=q.rotrSL(U,F,1)^q.rotrSL(U,F,8)^q.shrSL(U,F,7),b=Le[x-2]|0,v=Ve[x-2]|0,D=q.rotrSH(b,v,19)^q.rotrBH(b,v,61)^q.shrSH(b,v,6),L=q.rotrSL(b,v,19)^q.rotrBL(b,v,61)^q.shrSL(b,v,6),T=q.add4L(R,L,Ve[x-7],Ve[x-16]),$=q.add4H(T,P,D,Le[x-7],Le[x-16]);Le[x]=$|0,Ve[x]=T|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:m,Fl:B,Gh:w,Gl:d,Hh:A,Hl:C}=this;for(let x=0;x<80;x++){let U=q.rotrSH(l,h,14)^q.rotrSH(l,h,18)^q.rotrBH(l,h,41),F=q.rotrSL(l,h,14)^q.rotrSL(l,h,18)^q.rotrBL(l,h,41),P=l&m^~l&w,R=h&B^~h&d,b=q.add5L(C,F,R,Ed[x],Ve[x]),v=q.add5H(b,A,U,P,vd[x],Le[x]),D=b|0,L=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),T=q.rotrSL(n,o,28)^q.rotrBL(n,o,34)^q.rotrBL(n,o,39),$=n&i^n&a^i&a,S=o&s^o&c^s&c;A=w|0,C=d|0,w=m|0,d=B|0,m=l|0,B=h|0,{h:l,l:h}=q.add(f|0,u|0,v|0,D|0),f=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let I=q.add3L(D,T,S);n=q.add3H(I,v,L,$),o=I|0}({h:n,l:o}=q.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=q.add(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=q.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l:u}=q.add(this.Dh|0,this.Dl|0,f|0,u|0),{h:l,l:h}=q.add(this.Eh|0,this.El|0,l|0,h|0),{h:m,l:B}=q.add(this.Fh|0,this.Fl|0,m|0,B|0),{h:w,l:d}=q.add(this.Gh|0,this.Gl|0,w|0,d|0),{h:A,l:C}=q.add(this.Hh|0,this.Hl|0,A|0,C|0),this.set(n,o,i,s,a,c,f,u,l,h,m,B,w,d,A,C)}roundClean(){Le.fill(0),Ve.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 uc=Pn(()=>new Gi);var Hn={};Ct(Hn,{aInRange:()=>Lt,abool:()=>Wt,abytes:()=>wr,bitGet:()=>Cd,bitLen:()=>Yi,bitMask:()=>Wr,bitSet:()=>Td,bytesToHex:()=>ye,bytesToNumberBE:()=>we,bytesToNumberLE:()=>Pe,concatBytes:()=>xe,createHmacDrbg:()=>Xi,ensureBytes:()=>st,equalBytes:()=>Id,hexToBytes:()=>Je,hexToNumber:()=>Ji,inRange:()=>Zr,isBytes:()=>_e,memoized:()=>Xe,notImplemented:()=>Ud,numberToBytesBE:()=>Fe,numberToBytesLE:()=>Ye,numberToHexUnpadded:()=>We,numberToVarBytesBE:()=>Sd,utf8ToBytes:()=>kd,validateObject:()=>se});var On=BigInt(0),Mn=BigInt(1),Bd=BigInt(2);function _e(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function wr(r){if(!_e(r))throw new Error("Uint8Array expected")}function Wt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Ad=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function ye(r){wr(r);let t="";for(let e=0;e<r.length;e++)t+=Ad[r[e]];return t}function We(r){let t=r.toString(16);return t.length&1?"0"+t:t}function Ji(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?On:BigInt("0x"+r)}var me={_0:48,_9:57,A:65,F:70,a:97,f:102};function lc(r){if(r>=me._0&&r<=me._9)return r-me._0;if(r>=me.A&&r<=me.F)return r-(me.A-10);if(r>=me.a&&r<=me.f)return r-(me.a-10)}function Je(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let o=0,i=0;o<e;o++,i+=2){let s=lc(r.charCodeAt(i)),a=lc(r.charCodeAt(i+1));if(s===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[o]=s*16+a}return n}function we(r){return Ji(ye(r))}function Pe(r){return wr(r),Ji(ye(Uint8Array.from(r).reverse()))}function Fe(r,t){return Je(r.toString(16).padStart(t*2,"0"))}function Ye(r,t){return Fe(r,t).reverse()}function Sd(r){return Je(We(r))}function st(r,t,e){let n;if(typeof t=="string")try{n=Je(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(_e(t))n=Uint8Array.from(t);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof e=="number"&&o!==e)throw new Error(r+" of length "+e+" expected, got "+o);return n}function xe(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];wr(o),t+=o.length}let e=new Uint8Array(t);for(let n=0,o=0;n<r.length;n++){let i=r[n];e.set(i,o),o+=i.length}return e}function Id(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function kd(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var Zi=r=>typeof r=="bigint"&&On<=r;function Zr(r,t,e){return Zi(r)&&Zi(t)&&Zi(e)&&t<=r&&r<e}function Lt(r,t,e,n){if(!Zr(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function Yi(r){let t;for(t=0;r>On;r>>=Mn,t+=1);return t}function Cd(r,t){return r>>BigInt(t)&Mn}function Td(r,t,e){return r|(e?Mn:On)<<BigInt(t)}var Wr=r=>(Bd<<BigInt(r-1))-Mn,Wi=r=>new Uint8Array(r),fc=r=>Uint8Array.from(r);function Xi(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=Wi(r),o=Wi(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>e(o,n,...l),c=(l=Wi())=>{o=a(fc([0]),l),n=a(),l.length!==0&&(o=a(fc([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<t;){n=a();let m=n.slice();h.push(m),l+=n.length}return xe(...h)};return(l,h)=>{s(),c(l);let m;for(;!(m=h(f()));)c();return s(),m}}var Nd={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"||_e(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function se(r,t,e={}){let n=(o,i,s)=>{let a=Nd[i];if(typeof a!="function")throw new Error("invalid validator function");let c=r[o];if(!(s&&c===void 0)&&!a(c,r))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(e))n(o,i,!0);return r}var Ud=()=>{throw new Error("not implemented")};function Xe(r){let t=new WeakMap;return(e,...n)=>{let o=t.get(e);if(o!==void 0)return o;let i=r(e,...n);return t.set(e,i),i}}var ut=BigInt(0),nt=BigInt(1),Qe=BigInt(2),Rd=BigInt(3),Qi=BigInt(4),hc=BigInt(5),dc=BigInt(8),Ld=BigInt(9),Vd=BigInt(16);function X(r,t){let e=r%t;return e>=ut?e:t+e}function _d(r,t,e){if(t<ut)throw new Error("invalid exponent, negatives unsupported");if(e<=ut)throw new Error("invalid modulus");if(e===nt)return ut;let n=nt;for(;t>ut;)t&nt&&(n=n*r%e),r=r*r%e,t>>=nt;return n}function ot(r,t,e){let n=r;for(;t-- >ut;)n*=n,n%=e;return n}function $n(r,t){if(r===ut)throw new Error("invert: expected non-zero number");if(t<=ut)throw new Error("invert: expected positive modulus, got "+t);let e=X(r,t),n=t,o=ut,i=nt,s=nt,a=ut;for(;e!==ut;){let f=n/e,u=n%e,l=o-s*f,h=i-a*f;n=e,e=u,o=s,i=a,s=l,a=h}if(n!==nt)throw new Error("invert: does not exist");return X(o,t)}function Pd(r){let t=(r-nt)/Qe,e,n,o;for(e=r-nt,n=0;e%Qe===ut;e/=Qe,n++);for(o=Qe;o<r&&_d(o,t,r)!==r-nt;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+nt)/Qi;return function(c,f){let u=c.pow(f,s);if(!c.eql(c.sqr(u),f))throw new Error("Cannot find square root");return u}}let i=(e+nt)/Qe;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),e),l=a.pow(c,i),h=a.pow(c,e);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let m=1;for(let w=a.sqr(h);m<f&&!a.eql(w,a.ONE);m++)w=a.sqr(w);let B=a.pow(u,nt<<BigInt(f-m-1));u=a.sqr(B),l=a.mul(l,B),h=a.mul(h,u),f=m}return l}}function Fd(r){if(r%Qi===Rd){let t=(r+nt)/Qi;return function(n,o){let i=n.pow(o,t);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%dc===hc){let t=(r-hc)/dc;return function(n,o){let i=n.mul(o,Qe),s=n.pow(i,t),a=n.mul(o,s),c=n.mul(n.mul(a,Qe),s),f=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(f),o))throw new Error("Cannot find square root");return f}}return r%Vd,Pd(r)}var pc=(r,t)=>(X(r,t)&nt)===nt,Dd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ts(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Dd.reduce((n,o)=>(n[o]="function",n),t);return se(r,e)}function Od(r,t,e){if(e<ut)throw new Error("invalid exponent, negatives unsupported");if(e===ut)return r.ONE;if(e===nt)return t;let n=r.ONE,o=t;for(;e>ut;)e&nt&&(n=r.mul(n,o)),o=r.sqr(o),e>>=nt;return n}function Md(r,t){let e=new Array(t.length),n=t.reduce((i,s,a)=>r.is0(s)?i:(e[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return t.reduceRight((i,s,a)=>r.is0(s)?i:(e[a]=r.mul(i,e[a]),r.mul(i,s)),o),e}function es(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function De(r,t,e=!1,n={}){if(r<=ut)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=es(r,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:r,isLE:e,BITS:o,BYTES:i,MASK:Wr(o),ZERO:ut,ONE:nt,create:c=>X(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return ut<=c&&c<r},is0:c=>c===ut,isOdd:c=>(c&nt)===nt,neg:c=>X(-c,r),eql:(c,f)=>c===f,sqr:c=>X(c*c,r),add:(c,f)=>X(c+f,r),sub:(c,f)=>X(c-f,r),mul:(c,f)=>X(c*f,r),pow:(c,f)=>Od(a,c,f),div:(c,f)=>X(c*$n(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>$n(c,r),sqrt:n.sqrt||(c=>(s||(s=Fd(r)),s(a,c))),invertBatch:c=>Md(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>e?Ye(c,i):Fe(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return e?Pe(c):we(c)}});return Object.freeze(a)}function gc(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function rs(r){let t=gc(r);return t+Math.ceil(t/2)}function mc(r,t,e=!1){let n=r.length,o=gc(t),i=rs(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=e?Pe(r):we(r),a=X(s,t-nt)+nt;return e?Ye(a,o):Fe(a,o)}var yc=BigInt(0),Kn=BigInt(1);function ns(r,t){let e=t.negate();return r?e:t}function wc(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function os(r,t){wc(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function Hd(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function $d(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var is=new WeakMap,xc=new WeakMap;function ss(r){return xc.get(r)||1}function qn(r,t){return{constTimeNegate:ns,hasPrecomputes(e){return ss(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>yc;)n&Kn&&(o=o.add(i)),i=i.double(),n>>=Kn;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=os(n,t),s=[],a=e,c=a;for(let f=0;f<o;f++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(e,n,o){let{windows:i,windowSize:s}=os(e,t),a=r.ZERO,c=r.BASE,f=BigInt(2**e-1),u=2**e,l=BigInt(e);for(let h=0;h<i;h++){let m=h*s,B=Number(o&f);o>>=l,B>s&&(B-=u,o+=Kn);let w=m,d=m+Math.abs(B)-1,A=h%2!==0,C=B<0;B===0?c=c.add(ns(A,n[w])):a=a.add(ns(C,n[d]))}return{p:a,f:c}},wNAFUnsafe(e,n,o,i=r.ZERO){let{windows:s,windowSize:a}=os(e,t),c=BigInt(2**e-1),f=2**e,u=BigInt(e);for(let l=0;l<s;l++){let h=l*a;if(o===yc)break;let m=Number(o&c);if(o>>=u,m>a&&(m-=f,o+=Kn),m===0)continue;let B=n[h+Math.abs(m)-1];m<0&&(B=B.negate()),i=i.add(B)}return i},getPrecomputes(e,n,o){let i=is.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&is.set(n,o(i))),i},wNAFCached(e,n,o){let i=ss(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=ss(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){wc(n,t),xc.set(e,n),is.delete(e)}}}function zn(r,t,e,n){if(Hd(e,r),$d(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,i=Yi(BigInt(e.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=(1<<s)-1,c=new Array(a+1).fill(o),f=Math.floor((t.BITS-1)/s)*s,u=o;for(let l=f;l>=0;l-=s){c.fill(o);for(let m=0;m<n.length;m++){let B=n[m],w=Number(B>>BigInt(l)&BigInt(a));c[w]=c[w].add(e[m])}let h=o;for(let m=c.length-1,B=o;m>0;m--)B=B.add(c[m]),h=h.add(B);if(u=u.add(h),l!==0)for(let m=0;m<s;m++)u=u.double()}return u}function Jr(r){return ts(r.Fp),se(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...es(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Jt=BigInt(0),Vt=BigInt(1),jn=BigInt(2),Kd=BigInt(8),qd={zip215:!0};function zd(r){let t=Jr(r);return se(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function bc(r){let t=zd(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,f=jn<<BigInt(a*8)-Vt,u=e.create,l=De(t.n,t.nBitLength),h=t.uvRatio||((g,p)=>{try{return{isValid:!0,value:e.sqrt(g*e.inv(p))}}catch{return{isValid:!1,value:Jt}}}),m=t.adjustScalarBytes||(g=>g),B=t.domain||((g,p,E)=>{if(Wt("phflag",E),p.length||E)throw new Error("Contexts/pre-hash are not supported");return g});function w(g,p){Lt("coordinate "+g,p,Jt,f)}function d(g){if(!(g instanceof x))throw new Error("ExtendedPoint expected")}let A=Xe((g,p)=>{let{ex:E,ey:N,ez:O}=g,M=g.is0();p==null&&(p=M?Kd:e.inv(O));let z=u(E*p),G=u(N*p),K=u(O*p);if(M)return{x:Jt,y:Vt};if(K!==Vt)throw new Error("invZ was invalid");return{x:z,y:G}}),C=Xe(g=>{let{a:p,d:E}=t;if(g.is0())throw new Error("bad point: ZERO");let{ex:N,ey:O,ez:M,et:z}=g,G=u(N*N),K=u(O*O),Y=u(M*M),tt=u(Y*Y),ft=u(G*p),ht=u(Y*u(ft+K)),mt=u(tt+u(E*u(G*K)));if(ht!==mt)throw new Error("bad point: equation left != right (1)");let bt=u(N*O),Ut=u(M*z);if(bt!==Ut)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,E,N,O){this.ex=p,this.ey=E,this.ez=N,this.et=O,w("x",p),w("y",E),w("z",N),w("t",O),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof x)throw new Error("extended point not allowed");let{x:E,y:N}=p||{};return w("x",E),w("y",N),new x(E,N,Vt,u(E*N))}static normalizeZ(p){let E=e.invertBatch(p.map(N=>N.ez));return p.map((N,O)=>N.toAffine(E[O])).map(x.fromAffine)}static msm(p,E){return zn(x,l,p,E)}_setWindowSize(p){P.setWindowSize(this,p)}assertValidity(){C(this)}equals(p){d(p);let{ex:E,ey:N,ez:O}=this,{ex:M,ey:z,ez:G}=p,K=u(E*G),Y=u(M*O),tt=u(N*G),ft=u(z*O);return K===Y&&tt===ft}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:E,ey:N,ez:O}=this,M=u(E*E),z=u(N*N),G=u(jn*u(O*O)),K=u(p*M),Y=E+N,tt=u(u(Y*Y)-M-z),ft=K+z,ht=ft-G,mt=K-z,bt=u(tt*ht),Ut=u(ft*mt),kt=u(tt*mt),oe=u(ht*ft);return new x(bt,Ut,oe,kt)}add(p){d(p);let{a:E,d:N}=t,{ex:O,ey:M,ez:z,et:G}=this,{ex:K,ey:Y,ez:tt,et:ft}=p;if(E===BigInt(-1)){let Ta=u((M-O)*(Y+K)),Na=u((M+O)*(Y-K)),Ti=u(Na-Ta);if(Ti===Jt)return this.double();let Ua=u(z*jn*ft),Ra=u(G*jn*tt),La=Ra+Ua,Va=Na+Ta,_a=Ra-Ua,Df=u(La*Ti),Of=u(Va*_a),Mf=u(La*_a),Hf=u(Ti*Va);return new x(Df,Of,Hf,Mf)}let ht=u(O*K),mt=u(M*Y),bt=u(G*N*ft),Ut=u(z*tt),kt=u((O+M)*(K+Y)-ht-mt),oe=Ut-bt,he=Ut+bt,Kr=u(mt-E*ht),Vf=u(kt*oe),_f=u(he*Kr),Pf=u(kt*Kr),Ff=u(oe*he);return new x(Vf,_f,Ff,Pf)}subtract(p){return this.add(p.negate())}wNAF(p){return P.wNAFCached(this,p,x.normalizeZ)}multiply(p){let E=p;Lt("scalar",E,Vt,n);let{p:N,f:O}=this.wNAF(E);return x.normalizeZ([N,O])[0]}multiplyUnsafe(p,E=x.ZERO){let N=p;return Lt("scalar",N,Jt,n),N===Jt?F:this.is0()||N===Vt?this:P.wNAFCachedUnsafe(this,N,x.normalizeZ,E)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return P.unsafeLadder(this,n).is0()}toAffine(p){return A(this,p)}clearCofactor(){let{h:p}=t;return p===Vt?this:this.multiplyUnsafe(p)}static fromHex(p,E=!1){let{d:N,a:O}=t,M=e.BYTES;p=st("pointHex",p,M),Wt("zip215",E);let z=p.slice(),G=p[M-1];z[M-1]=G&-129;let K=Pe(z),Y=E?f:e.ORDER;Lt("pointHex.y",K,Jt,Y);let tt=u(K*K),ft=u(tt-Vt),ht=u(N*tt-O),{isValid:mt,value:bt}=h(ft,ht);if(!mt)throw new Error("Point.fromHex: invalid y coordinate");let Ut=(bt&Vt)===Vt,kt=(G&128)!==0;if(!E&&bt===Jt&&kt)throw new Error("Point.fromHex: x=0 and x_0=1");return kt!==Ut&&(bt=u(-bt)),x.fromAffine({x:bt,y:K})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:E}=this.toAffine(),N=Ye(E,e.BYTES);return N[N.length-1]|=p&Vt?128:0,N}toHex(){return ye(this.toRawBytes())}}x.BASE=new x(t.Gx,t.Gy,Vt,u(t.Gx*t.Gy)),x.ZERO=new x(Jt,Vt,Vt,Jt);let{BASE:U,ZERO:F}=x,P=qn(x,a*8);function R(g){return X(g,n)}function b(g){return R(Pe(g))}function v(g){let p=e.BYTES;g=st("private key",g,p);let E=st("hashed private key",i(g),2*p),N=m(E.slice(0,p)),O=E.slice(p,2*p),M=b(N),z=U.multiply(M),G=z.toRawBytes();return{head:N,prefix:O,scalar:M,point:z,pointBytes:G}}function D(g){return v(g).pointBytes}function L(g=new Uint8Array,...p){let E=xe(...p);return b(i(B(E,st("context",g),!!o)))}function T(g,p,E={}){g=st("message",g),o&&(g=o(g));let{prefix:N,scalar:O,pointBytes:M}=v(p),z=L(E.context,N,g),G=U.multiply(z).toRawBytes(),K=L(E.context,G,M,g),Y=R(z+K*O);Lt("signature.s",Y,Jt,n);let tt=xe(G,Ye(Y,e.BYTES));return st("result",tt,e.BYTES*2)}let $=qd;function S(g,p,E,N=$){let{context:O,zip215:M}=N,z=e.BYTES;g=st("signature",g,2*z),p=st("message",p),E=st("publicKey",E,z),M!==void 0&&Wt("zip215",M),o&&(p=o(p));let G=Pe(g.slice(z,2*z)),K,Y,tt;try{K=x.fromHex(E,M),Y=x.fromHex(g.slice(0,z),M),tt=U.multiplyUnsafe(G)}catch{return!1}if(!M&&K.isSmallOrder())return!1;let ft=L(O,Y.toRawBytes(),K.toRawBytes(),p);return Y.add(K.multiplyUnsafe(ft)).subtract(tt).clearCofactor().equals(x.ZERO)}return U._setWindowSize(8),{CURVE:t,getPublicKey:D,sign:T,verify:S,ExtendedPoint:x,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(e.BYTES),precompute(g=8,p=x.BASE){return p._setWindowSize(g),p.multiply(BigInt(3)),p}}}}var as=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),vc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Tm=BigInt(0),jd=BigInt(1),Ec=BigInt(2),Nm=BigInt(3),Gd=BigInt(5),Zd=BigInt(8);function Wd(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=as,a=r*r%i*r%i,c=ot(a,Ec,i)*a%i,f=ot(c,jd,i)*r%i,u=ot(f,Gd,i)*f%i,l=ot(u,t,i)*u%i,h=ot(l,e,i)*l%i,m=ot(h,n,i)*h%i,B=ot(m,o,i)*m%i,w=ot(B,o,i)*m%i,d=ot(w,t,i)*u%i;return{pow_p_5_8:ot(d,Ec,i)*r%i,b2:a}}function Jd(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Yd(r,t){let e=as,n=X(t*t*t,e),o=X(n*n*t,e),i=Wd(r*o).pow_p_5_8,s=X(r*n*i,e),a=X(t*s*s,e),c=s,f=X(s*vc,e),u=a===r,l=a===X(-r,e),h=a===X(-r*vc,e);return u&&(s=c),(l||h)&&(s=f),pc(s,e)&&(s=X(-s,e)),{isValid:u||l,value:s}}var Xd=De(as,void 0,!0),Qd={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Xd,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Zd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:uc,randomBytes:Fn,adjustScalarBytes:Jd,uvRatio:Yd},Bc=bc(Qd);var Gn=32;function Ac(r,t,e){return Bc.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Zn=class{type="Ed25519";raw;constructor(t){this.raw=cs(t,Gn)}toMultihash(){return ge.digest(Wn(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return Ac(this.raw,e,t)}};function us(r){return r=cs(r,Gn),new Zn(r)}function cs(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new vt(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function be(r=0){return new Uint8Array(r)}function _t(r=0){return new Uint8Array(r)}var e0=Math.pow(2,7),r0=Math.pow(2,14),n0=Math.pow(2,21),ls=Math.pow(2,28),fs=Math.pow(2,35),hs=Math.pow(2,42),ds=Math.pow(2,49),J=128,Et=127;function Pt(r){if(r<e0)return 1;if(r<r0)return 2;if(r<n0)return 3;if(r<ls)return 4;if(r<fs)return 5;if(r<hs)return 6;if(r<ds)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ps(r,t,e=0){switch(Pt(r)){case 8:t[e++]=r&255|J,r/=128;case 7:t[e++]=r&255|J,r/=128;case 6:t[e++]=r&255|J,r/=128;case 5:t[e++]=r&255|J,r/=128;case 4:t[e++]=r&255|J,r>>>=7;case 3:t[e++]=r&255|J,r>>>=7;case 2:t[e++]=r&255|J,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function o0(r,t,e=0){switch(Pt(r)){case 8:t.set(e++,r&255|J),r/=128;case 7:t.set(e++,r&255|J),r/=128;case 6:t.set(e++,r&255|J),r/=128;case 5:t.set(e++,r&255|J),r/=128;case 4:t.set(e++,r&255|J),r>>>=7;case 3:t.set(e++,r&255|J),r>>>=7;case 2:t.set(e++,r&255|J),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function gs(r,t){let e=r[t],n=0;if(n+=e&Et,e<J||(e=r[t+1],n+=(e&Et)<<7,e<J)||(e=r[t+2],n+=(e&Et)<<14,e<J)||(e=r[t+3],n+=(e&Et)<<21,e<J)||(e=r[t+4],n+=(e&Et)*ls,e<J)||(e=r[t+5],n+=(e&Et)*fs,e<J)||(e=r[t+6],n+=(e&Et)*hs,e<J)||(e=r[t+7],n+=(e&Et)*ds,e<J))return n;throw new RangeError("Could not decode varint")}function i0(r,t){let e=r.get(t),n=0;if(n+=e&Et,e<J||(e=r.get(t+1),n+=(e&Et)<<7,e<J)||(e=r.get(t+2),n+=(e&Et)<<14,e<J)||(e=r.get(t+3),n+=(e&Et)<<21,e<J)||(e=r.get(t+4),n+=(e&Et)*ls,e<J)||(e=r.get(t+5),n+=(e&Et)*fs,e<J)||(e=r.get(t+6),n+=(e&Et)*hs,e<J)||(e=r.get(t+7),n+=(e&Et)*ds,e<J))return n;throw new RangeError("Could not decode varint")}function xr(r,t,e=0){return t==null&&(t=_t(Pt(r))),t instanceof Uint8Array?ps(r,t,e):o0(r,t,e)}function tr(r,t=0){return r instanceof Uint8Array?gs(r,t):i0(r,t)}var ms=new Float32Array([-0]),Oe=new Uint8Array(ms.buffer);function kc(r,t,e){ms[0]=r,t[e]=Oe[0],t[e+1]=Oe[1],t[e+2]=Oe[2],t[e+3]=Oe[3]}function Cc(r,t){return Oe[0]=r[t],Oe[1]=r[t+1],Oe[2]=r[t+2],Oe[3]=r[t+3],ms[0]}var ys=new Float64Array([-0]),Bt=new Uint8Array(ys.buffer);function Tc(r,t,e){ys[0]=r,t[e]=Bt[0],t[e+1]=Bt[1],t[e+2]=Bt[2],t[e+3]=Bt[3],t[e+4]=Bt[4],t[e+5]=Bt[5],t[e+6]=Bt[6],t[e+7]=Bt[7]}function Nc(r,t){return Bt[0]=r[t],Bt[1]=r[t+1],Bt[2]=r[t+2],Bt[3]=r[t+3],Bt[4]=r[t+4],Bt[5]=r[t+5],Bt[6]=r[t+6],Bt[7]=r[t+7],ys[0]}var s0=BigInt(Number.MAX_SAFE_INTEGER),a0=BigInt(Number.MIN_SAFE_INTEGER),Dt=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 er;if(t<s0&&t>a0)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,o=t-(n<<32n);return e&&(n=~n|0n,o=~o|0n,++o>Uc&&(o=0n,++n>Uc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return er;let e=t<0;e&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return e&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}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):er}},er=new Dt(0,0);er.toBigInt=function(){return 0n};er.zzEncode=er.zzDecode=function(){return this};er.length=function(){return 1};var Uc=4294967296n;function Rc(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 Lc(r,t,e){if(e-t<1)return"";let o,i=[],s=0,a;for(;t<e;)a=r[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(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[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function ws(r,t,e){let n=e,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128);return e-n}function Yt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function Jn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var xs=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,Yt(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 Yt(this,4);return Jn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Yt(this,4);return Jn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Yt(this,4);let t=Cc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Yt(this,4);let t=Nc(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 Yt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Lc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Yt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Yt(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 Dt(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 Yt(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 Yt(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 Yt(this,8);let t=Jn(this.buf,this.pos+=4),e=Jn(this.buf,this.pos+=4);return new Dt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=gs(this.buf,this.pos);return this.pos+=Pt(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function bs(r){return new xs(r instanceof Uint8Array?r:r.subarray())}function br(r,t,e){let n=bs(r);return t.decode(n,void 0,e)}var vs={};Ct(vs,{base10:()=>c0});var c0=Ne({prefix:"9",name:"base10",alphabet:"0123456789"});var Es={};Ct(Es,{base16:()=>u0,base16upper:()=>l0});var u0=at({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),l0=at({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Bs={};Ct(Bs,{base2:()=>f0});var f0=at({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var As={};Ct(As,{base256emoji:()=>m0});var _c=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}"),h0=_c.reduce((r,t,e)=>(r[e]=t,r),[]),d0=_c.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function p0(r){return r.reduce((t,e)=>(t+=h0[e],t),"")}function g0(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=d0[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var m0=ur({prefix:"\u{1F680}",name:"base256emoji",encode:p0,decode:g0});var Ss={};Ct(Ss,{base8:()=>y0});var y0=at({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Is={};Ct(Is,{identity:()=>w0});var w0=ur({prefix:"\0",name:"identity",encode:r=>Ha(r),decode:r=>Ma(r)});var fy=new TextEncoder,hy=new TextDecoder;var Ts={};Ct(Ts,{sha256:()=>Yr,sha512:()=>v0});function Cs({name:r,code:t,encode:e}){return new ks(r,t,e)}var ks=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?Gt(this.code,e):e.then(n=>Gt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Fc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Yr=Cs({name:"sha2-256",code:18,encode:Fc("SHA-256")}),v0=Cs({name:"sha2-512",code:19,encode:Fc("SHA-512")});var Xr={...Is,...Bs,...Ss,...vs,...Es,...Pi,...Hi,...Fi,...Oi,...As},Ay={...Ts,...qi};function Oc(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Dc=Oc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ns=Oc("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=_t(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),E0={utf8:Dc,"utf-8":Dc,hex:Xr.base16,latin1:Ns,ascii:Ns,binary:Ns,...Xr},Yn=E0;function W(r,t="utf8"){let e=Yn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Us(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return _t(s);o+s>t&&(n=_t(t),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var rr=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Rs(){}var Vs=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},B0=Us();function A0(r){return globalThis.Buffer!=null?_t(r):B0(r)}var tn=class{len;head;tail;states;constructor(){this.len=0,this.head=new rr(Rs,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new rr(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new _s((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(Xn,10,Dt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Dt.fromBigInt(t);return this._push(Xn,e.length(),e)}uint64Number(t){return this._push(ps,Pt(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=Dt.fromBigInt(t).zzEncode();return this._push(Xn,e.length(),e)}sint64Number(t){let e=Dt.fromNumber(t).zzEncode();return this._push(Xn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Ls,1,t?1:0)}fixed32(t){return this._push(Qr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Dt.fromBigInt(t);return this._push(Qr,4,e.lo)._push(Qr,4,e.hi)}fixed64Number(t){let e=Dt.fromNumber(t);return this._push(Qr,4,e.lo)._push(Qr,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(kc,4,t)}double(t){return this._push(Tc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Ls,1,0):this.uint32(e)._push(I0,e,t)}string(t){let e=Rc(t);return e!==0?this.uint32(e)._push(ws,e,t):this._push(Ls,1,0)}fork(){return this.states=new Vs(this),this.head=this.tail=new rr(Rs,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 rr(Rs,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=A0(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Ls(r,t,e){t[e]=r&255}function S0(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var _s=class extends rr{next;constructor(t,e){super(S0,t,e),this.next=void 0}};function Xn(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 Qr(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 I0(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(tn.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(k0,t,r),this},tn.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(C0,t,r),this});function k0(r,t,e){t.set(r,e)}function C0(r,t,e){r.length<40?ws(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(W(r),e)}function Ps(){return new tn}function vr(r,t){let e=Ps();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Er;(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"})(Er||(Er={}));function Qn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function en(r){function t(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let e=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Qn("enum",Er.VARINT,e,n)}function Br(r,t){return Qn("message",Er.LENGTH_DELIMITED,r,t)}var lt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(lt||(lt={}));var Fs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Fs||(Fs={}));(function(r){r.codec=()=>en(Fs)})(lt||(lt={}));var ae;(function(r){let t;r.codec=()=>(t==null&&(t=Br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),lt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:{i.Type=lt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return i})),t),r.encode=e=>vr(e,r.codec()),r.decode=(e,n)=>br(e,r.codec(),n)})(ae||(ae={}));var Ds;(function(r){let t;r.codec=()=>(t==null&&(t=Br((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),lt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),o.lengthDelimited!==!1&&n.ldelim()},(e,n,o={})=>{let i={},s=n==null?e.len:e.pos+n;for(;e.pos<s;){let a=e.uint32();switch(a>>>3){case 1:{i.Type=lt.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return i})),t),r.encode=e=>vr(e,r.codec()),r.decode=(e,n)=>br(e,r.codec(),n)})(Ds||(Ds={}));var hn={};Ct(hn,{MAX_RSA_KEY_SIZE:()=>zo,generateRSAKeyPair:()=>Pu,jwkToJWKKeyPair:()=>Fu,jwkToPkcs1:()=>q0,jwkToPkix:()=>Gs,jwkToRSAPrivateKey:()=>_u,pkcs1ToJwk:()=>Ru,pkcs1ToRSAPrivateKey:()=>Vu,pkixToJwk:()=>Lu,pkixToRSAPublicKey:()=>Zs});var T0=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Me=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),He=new Uint32Array(64),Os=class extends yr{constructor(){super(64,32,8,!1),this.A=Me[0]|0,this.B=Me[1]|0,this.C=Me[2]|0,this.D=Me[3]|0,this.E=Me[4]|0,this.F=Me[5]|0,this.G=Me[6]|0,this.H=Me[7]|0}get(){let{A:t,B:e,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,e,n,o,i,s,a,c]}set(t,e,n,o,i,s,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,e){for(let l=0;l<16;l++,e+=4)He[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let h=He[l-15],m=He[l-2],B=Zt(h,7)^Zt(h,18)^h>>>3,w=Zt(m,17)^Zt(m,19)^m>>>10;He[l]=w+He[l-7]+B+He[l-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:f,H:u}=this;for(let l=0;l<64;l++){let h=Zt(a,6)^Zt(a,11)^Zt(a,25),m=u+h+sc(a,c,f)+T0[l]+He[l]|0,w=(Zt(n,2)^Zt(n,13)^Zt(n,22))+ac(n,o,i)|0;u=f,f=c,c=a,a=s+m|0,s=i,i=o,o=n,n=m+w|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,f=f+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,f,u)}roundClean(){He.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ar=Pn(()=>new Os);var j=Nn(Hc());function nr(r,t){let e=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)e+=r[r.length-1-n]*Math.pow(2,t*n);return e}function $e(r,t,e=-1){let n=e,o=r,i=0,s=Math.pow(2,t);for(let a=1;a<8;a++){if(r<s){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 f=new Uint8Array(c);for(let u=a-1;u>=0;u--){let l=Math.pow(2,u*t);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,t)}return new ArrayBuffer(0)}function ro(...r){let t=0,e=0;for(let i of r)t+=i.length;let n=new ArrayBuffer(t),o=new Uint8Array(n);for(let i of r)o.set(i,e),e+=i.length;return o}function Hs(){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 t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let a=0;a<this.valueHex.byteLength;a++)e[a]=0;e[0]=r[0]&128;let n=nr(e,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)i[a]=r[a];return i[0]&=127,nr(i,8)-n}function $c(r){let t=r<0?r*-1:r,e=128;for(let n=1;n<8;n++){if(t<=e){if(r<0){let s=e-t,a=$e(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=$e(t,8,n),i=new Uint8Array(o);if(i[0]&128){let s=o.slice(0),a=new Uint8Array(s);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let c=0;c<s.byteLength;c++)i[c+1]=a[c];i[0]=0}return o}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function Kc(r,t){if(r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let o=0;o<e.length;o++)if(e[o]!==n[o])return!1;return!0}function Ft(r,t){let e=r.toString(10);if(t<e.length)return"";let n=t-e.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(e)}var iw=Math.log(2);function no(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function $s(r){let t=0,e=0;for(let o=0;o<r.length;o++){let i=r[o];t+=i.byteLength}let n=new Uint8Array(t);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),e),e+=i.byteLength}return n.buffer}function Se(r,t,e,n){return t instanceof Uint8Array?t.byteLength?e<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-e-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 nn=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return $s(this.items)}},rn=[new Uint8Array([1])],qc="0123456789";var Tr="",Xt=new ArrayBuffer(0),Ks=new Uint8Array(0),on="EndOfContent",jc="OCTET STRING",Gc="BIT STRING";function Ie(r){var t;return t=class extends r{constructor(...n){var o;super(...n);let i=n[0]||{};this.isHexOnly=(o=i.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=i.valueHex?j.BufferSourceConverter.toUint8Array(i.valueHex):Ks}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,i){let s=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Se(this,s,o,i))return-1;let a=o+i;return this.valueHexView=s.subarray(o,a),this.valueHexView.length?(this.blockLength=i,a):(this.warnings.push("Zero buffer length"),o)}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",Xt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:j.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var Ee=class{constructor({blockLength:t=0,error:e=Tr,warnings:n=[],valueBeforeDecode:o=Ks}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=j.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:j.Convert.ToHex(this.valueBeforeDecodeView)}}};Ee.NAME="baseBlock";var At=class extends Ee{fromBER(t,e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,e){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};At.NAME="valueBlock";var oo=class extends Ie(Ee){constructor({idBlock:t={}}={}){var e,n,o,i;super(),t?(this.isHexOnly=(e=t.isHexOnly)!==null&&e!==void 0?e:!1,this.valueHexView=t.valueHex?j.BufferSourceConverter.toUint8Array(t.valueHex):Ks,this.tagClass=(n=t.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=t.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=t.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let e=0;switch(this.tagClass){case 1:e|=0;break;case 2:e|=64;break;case 3:e|=128;break;case 4:e|=192;break;default:return this.error="Unknown tag class",Xt}if(this.isConstructed&&(e|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!t){let i=this.tagNumber;i&=31,e|=i,o[0]=e}return o.buffer}if(!this.isHexOnly){let o=$e(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=e|31,!t){for(let c=0;c<s-1;c++)a[c+1]=i[c]|128;a[s]=i[s-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=e|31,!t){let o=this.valueHexView;for(let i=0;i<o.length-1;i++)n[i+1]=o[i]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;let i=o.subarray(e,e+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,f=this.valueHexView=new Uint8Array(255),u=255;for(;i[c]&128;){if(f[c-1]=i[c]&127,c++,c>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(c===u){u+=255;let h=new Uint8Array(u);for(let m=0;m<f.length;m++)h[m]=f[m];f=this.valueHexView=new Uint8Array(u)}}this.blockLength=c+1,f[c-1]=i[c]&127;let l=new Uint8Array(c);for(let h=0;h<c;h++)l[h]=f[h];f=this.valueHexView=new Uint8Array(c),f.set(l),this.blockLength<=9?this.tagNumber=nr(f,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 e+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};oo.NAME="identificationBlock";var io=class extends Ee{constructor({lenBlock:t={}}={}){var e,n,o;super(),this.isIndefiniteForm=(e=t.isIndefiniteForm)!==null&&e!==void 0?e:!1,this.longFormUsed=(n=t.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=t.length)!==null&&o!==void 0?o:0}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;let i=o.subarray(e,e+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,e+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,e+this.blockLength;let s=i[0]&127;if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;let a=e+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=nr(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,e+this.blockLength}toBER(t=!1){let e,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=128),e;if(this.longFormUsed){let o=$e(this.length,8);if(o.byteLength>127)return this.error="Too big length",Xt;if(e=new ArrayBuffer(o.byteLength+1),t)return e;let i=new Uint8Array(o);n=new Uint8Array(e),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return e}return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};io.NAME="lengthBlock";var V={},yt=class extends Ee{constructor({name:t=Tr,optional:e=!1,primitiveSchema:n,...o}={},i){super(o),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new oo(o),this.lenBlock=new io(o),this.valueBlock=i?new i(o):new At(o)}fromBER(t,e,n){let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}toBER(t,e){let n=e||new nn;e||Zc(this);let o=this.idBlock.toBER(t);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(t);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(t);n.write(s),n.write(i)}return e?Xt:n.final()}toJSON(){let t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():j.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;let e=this.toBER(),n=t.toBER();return Kc(e,n)}};yt.NAME="BaseBlock";function Zc(r){if(r instanceof V.Constructed)for(let t of r.valueBlock.value)Zc(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var so=class extends yt{constructor({value:t=Tr,...e}={},n){super(e,n),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,e,n){let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};so.NAME="BaseStringBlock";var ao=class extends Ie(At){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};ao.NAME="PrimitiveValueBlock";var Wc,co=class extends yt{constructor(t={}){super(t,ao),this.idBlock.isConstructed=!1}};Wc=co;V.Primitive=Wc;co.NAME="PRIMITIVE";function D0(r,t){if(r instanceof t)return r;let e=new t;return e.idBlock=r.idBlock,e.lenBlock=r.lenBlock,e.warnings=r.warnings,e.valueBeforeDecodeView=r.valueBeforeDecodeView,e}function Ko(r,t=0,e=r.length){let n=t,o=new yt({},At),i=new Ee;if(!Se(i,r,t,e))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(t,t+e).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,t,e);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(t=a,e-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,t,e),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(t=a,e-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=yt;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=V.EndOfContent;break;case 1:c=V.Boolean;break;case 2:c=V.Integer;break;case 3:c=V.BitString;break;case 4:c=V.OctetString;break;case 5:c=V.Null;break;case 6:c=V.ObjectIdentifier;break;case 10:c=V.Enumerated;break;case 12:c=V.Utf8String;break;case 13:c=V.RelativeObjectIdentifier;break;case 14:c=V.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=V.Sequence;break;case 17:c=V.Set;break;case 18:c=V.NumericString;break;case 19:c=V.PrintableString;break;case 20:c=V.TeletexString;break;case 21:c=V.VideotexString;break;case 22:c=V.IA5String;break;case 23:c=V.UTCTime;break;case 24:c=V.GeneralizedTime;break;case 25:c=V.GraphicString;break;case 26:c=V.VisibleString;break;case 27:c=V.GeneralString;break;case 28:c=V.UniversalString;break;case 29:c=V.CharacterString;break;case 30:c=V.BmpString;break;case 31:c=V.DATE;break;case 32:c=V.TimeOfDay;break;case 33:c=V.DateTime;break;case 34:c=V.Duration;break;default:{let f=o.idBlock.isConstructed?new V.Constructed:new V.Primitive;f.idBlock=o.idBlock,f.lenBlock=o.lenBlock,f.warnings=o.warnings,o=f}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?V.Constructed:V.Primitive}return o=D0(o,c),a=o.fromBER(r,t,o.lenBlock.isIndefiniteForm?e:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function qs(r){if(!r.byteLength){let t=new yt({},At);return t.error="Input buffer has zero length",{offset:-1,result:t}}return Ko(j.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function O0(r,t){return r?1:t}var ce=class extends At{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;if(this.valueBeforeDecodeView=o.subarray(e,e+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),e;let i=e;for(;O0(this.isIndefiniteForm,n)>0;){let s=Ko(o,i,n);if(s.offset===-1)return this.error=s.result.error,this.warnings.concat(s.result.warnings),-1;if(i=s.offset,this.blockLength+=s.result.blockLength,n-=s.result.blockLength,this.value.push(s.result),this.isIndefiniteForm&&s.result.constructor.NAME===on)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===on?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(t,e){let n=e||new nn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(t,n);return e?Xt:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};ce.NAME="ConstructedValueBlock";var Jc,Ke=class extends yt{constructor(t={}){super(t,ce),this.idBlock.isConstructed=!0}fromBER(t,e,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}onAsciiEncoding(){let t=[];for(let n of this.valueBlock.value)t.push(n.toString("ascii").split(`
4
- `).map(o=>` ${o}`).join(`
5
- `));let e=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return t.length?`${e} :
6
- ${t.join(`
7
- `)}`:`${e} :`}};Jc=Ke;V.Constructed=Jc;Ke.NAME="CONSTRUCTED";var uo=class extends At{fromBER(t,e,n){return e}toBER(t){return Xt}};uo.override="EndOfContentValueBlock";var Yc,lo=class extends yt{constructor(t={}){super(t,uo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Yc=lo;V.EndOfContent=Yc;lo.NAME=on;var Xc,Ir=class extends yt{constructor(t={}){super(t,At),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,e,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,e+n>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):e+n}toBER(t,e){let n=new ArrayBuffer(2);if(!t){let o=new Uint8Array(n);o[0]=5,o[1]=0}return e&&e.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Xc=Ir;V.Null=Xc;Ir.NAME="NULL";var fo=class extends Ie(At){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=j.BufferSourceConverter.toUint8Array(e.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(let t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,e,n){let o=j.BufferSourceConverter.toUint8Array(t);return Se(this,o,e,n)?(this.valueHexView=o.subarray(e,e+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Hs.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};fo.NAME="BooleanValueBlock";var Qc,ho=class extends yt{constructor(t={}){super(t,fo),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Qc=ho;V.Boolean=Qc;ho.NAME="BOOLEAN";var po=class extends Ie(ce){constructor({isConstructed:t=!1,...e}={}){super(e),this.isConstructed=t}fromBER(t,e,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=ce.prototype.fromBER.call(this,t,e,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===on){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==jc)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(t,e,n),this.blockLength=n;return o}toBER(t,e){return this.isConstructed?ce.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};po.NAME="OctetStringValueBlock";var tu,go=class r extends yt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},po),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,e,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),e;if(!this.valueBlock.isConstructed){let i=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(e,e+n);try{if(i.byteLength){let s=Ko(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(t,e,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ke.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${j.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let t=[];for(let e of this.valueBlock.value)e instanceof r&&t.push(e.valueBlock.valueHexView);return j.BufferSourceConverter.concat(t)}};tu=go;V.OctetString=tu;go.NAME=jc;var mo=class extends Ie(ce){constructor({unusedBits:t=0,isConstructed:e=!1,...n}={}){super(n),this.unusedBits=t,this.isConstructed=e,this.blockLength=this.valueHexView.byteLength}fromBER(t,e,n){if(!n)return e;let o=-1;if(this.isConstructed){if(o=ce.prototype.fromBER.call(this,t,e,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===on){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Gc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let f=a.valueBlock;if(this.unusedBits>0&&f.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=f.unusedBits}return o}let i=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,i,e,n))return-1;let s=i.subarray(e,e+n);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=s.subarray(1);try{if(a.byteLength){let c=Ko(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,e+n}toBER(t,e){if(this.isConstructed)return ce.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Xt;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};mo.NAME="BitStringValueBlock";var eu,kr=class extends yt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var o,i;(o=n.isConstructed)!==null&&o!==void 0||(n.isConstructed=!!(!((i=n.value)===null||i===void 0)&&i.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},mo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,e,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,e,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ke.prototype.onAsciiEncoding.call(this);{let t=[],e=this.valueBlock.valueHexView;for(let o of e)t.push(o.toString(2).padStart(8,"0"));let n=t.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};eu=kr;V.BitString=eu;kr.NAME=Gc;var ru;function M0(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(t),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f=0,u=c<s?s:c,l=0;for(let h=u;h>=0;h--,l++){switch(!0){case l<a.length:f=i[s-l]+a[c-l]+e[0];break;default:f=i[s-l]+e[0]}switch(e[0]=f/10,!0){case l>=i.length:i=ro(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return e[0]>0&&(i=ro(e,i)),i}function zc(r){if(r>=rn.length)for(let t=rn.length;t<=r;t++){let e=new Uint8Array([0]),n=rn[t-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+e[0]]);e[0]=i[0]/10,n[o]=i[0]%10}e[0]>0&&(n=ro(e,n)),rn.push(n)}return rn[r]}function H0(r,t){let e=0,n=new Uint8Array(r),o=new Uint8Array(t),i=n.slice(0),s=i.length-1,a=o.slice(0),c=a.length-1,f,u=0;for(let l=c;l>=0;l--,u++)switch(f=i[s-u]-a[c-u]-e,!0){case f<0:e=1,i[s-u]=f+10;break;default:e=0,i[s-u]=f}if(e>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-e,f<0)e=1,i[s-u]=f+10;else{e=0,i[s-u]=f;break}return i.slice()}var sn=class extends Ie(At){constructor({value:t,...e}={}){super(e),this._valueDec=0,e.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Hs.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array($c(t))}get valueDec(){return this._valueDec}fromDER(t,e,n,o=0){let i=this.fromBER(t,e,n);if(i===-1)return i;let s=this.valueHexView;return s[0]===0&&s[1]&128?this.valueHexView=s.subarray(1):o!==0&&s.length<o&&(o-s.length>1&&(o=s.length+1),this.valueHexView=s.subarray(o-s.length)),i}toDER(t=!1){let e=this.valueHexView;switch(!0){case(e[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(e,1),this.valueHexView=n}break;case(e[0]===0&&(e[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,e,n){let o=super.fromBER(t,e,n);return o===-1||this.setValueHex(),o}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let t=this.valueHexView.length*8-1,e=new Uint8Array(this.valueHexView.length*8/3),n=0,o,i=this.valueHexView,s="",a=!1;for(let c=i.byteLength-1;c>=0;c--){o=i[c];for(let f=0;f<8;f++){if((o&1)===1)switch(n){case t:e=H0(zc(n),e),s="-";break;default:e=M0(e,zc(n))}n++,o>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(s+=qc.charAt(e[c]));return a===!1&&(s+=qc.charAt(0)),s}};ru=sn;sn.NAME="IntegerValueBlock";Object.defineProperty(ru.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var nu,wt=class r extends yt{constructor(t={}){super(t,sn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return no(),BigInt(this.valueBlock.toString())}static fromBigInt(t){no();let e=BigInt(t),n=new nn,o=e.toString(16).replace(/^-/,""),i=new Uint8Array(j.Convert.FromHex(o));if(e<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${j.Convert.ToHex(a)}`)+e,u=j.BufferSourceConverter.toUint8Array(j.Convert.FromHex(f.toString(16)));u[0]|=128,n.write(u)}else i[0]&128&&n.write(new Uint8Array([0])),n.write(i);return new r({valueHex:n.final()})}convertToDER(){let t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};nu=wt;V.Integer=nu;wt.NAME="INTEGER";var ou,yo=class extends wt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};ou=yo;V.Enumerated=ou;yo.NAME="ENUMERATED";var an=class extends Ie(At){constructor({valueDec:t=-1,isFirstSid:e=!1,...n}={}){super(n),this.valueDec=t,this.isFirstSid=e}fromBER(t,e,n){if(!n)return e;let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;let i=o.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=nr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){no();let e=BigInt(t).toString(2);for(;e.length%7;)e="0"+e;let n=new Uint8Array(e.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(e.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let e=$e(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Xt;let n=new Uint8Array(e.byteLength);if(!t){let o=new Uint8Array(e),i=e.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let t="";if(this.isHexOnly)t=j.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let e=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",e-=40):(t="2.",e-=80),t+=e.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};an.NAME="sidBlock";var wo=class extends At{constructor({value:t=Tr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let o=e;for(;n>0;){let i=new an;if(o=i.fromBER(t,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.value.length===0&&(i.isFirstSid=!0),this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(t){let e=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(t);if(o.byteLength===0)return this.error=this.value[n].error,Xt;e.push(o)}return $s(e)}fromString(t){this.value=[];let e=0,n=0,o="",i=!1;do if(n=t.indexOf(".",e),n===-1?o=t.substring(e):o=t.substring(e,n),e=n+1,i){let s=this.value[0],a=0;switch(s.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(o,10);if(isNaN(c))return;s.valueDec=c+a,i=!1}else{let s=new an;if(o>Number.MAX_SAFE_INTEGER){no();let a=BigInt(o);s.valueBigInt=a}else if(s.valueDec=parseInt(o,10),isNaN(s.valueDec))return;this.value.length||(s.isFirstSid=!0,i=!0),this.value.push(s)}while(n!==-1)}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(t=`${t}.`),e?(o=`{${o}}`,this.value[n].isFirstSid?t=`2.{${o} - 80}`:t+=o):t+=o}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};wo.NAME="ObjectIdentifierValueBlock";var iu,Cr=class extends yt{constructor(t={}){super(t,wo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};iu=Cr;V.ObjectIdentifier=iu;Cr.NAME="OBJECT IDENTIFIER";var cn=class extends Ie(Ee){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let o=j.BufferSourceConverter.toUint8Array(t);if(!Se(this,o,e,n))return-1;let i=o.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=i[a]&127,this.blockLength++,!!(i[a]&128));a++);let s=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)s[a]=this.valueHexView[a];return this.valueHexView=s,i[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=nr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let o=this.valueHexView,i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength-1;s++)i[s]=o[s]|128;return i[this.blockLength-1]=o[this.blockLength-1],i.buffer}let e=$e(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Xt;let n=new Uint8Array(e.byteLength);if(!t){let o=new Uint8Array(e),i=e.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let t="";return this.isHexOnly?t=j.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};cn.NAME="relativeSidBlock";var xo=class extends At{constructor({value:t=Tr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let o=e;for(;n>0;){let i=new cn;if(o=i.fromBER(t,o,n),o===-1)return this.blockLength=0,this.error=i.error,o;this.blockLength+=i.blockLength,n-=i.blockLength,this.value.push(i)}return o}toBER(t,e){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(t);if(i.byteLength===0)return this.error=this.value[o].error,Xt;n.push(i)}return $s(n)}fromString(t){this.value=[];let e=0,n=0,o="";do{n=t.indexOf(".",e),n===-1?o=t.substring(e):o=t.substring(e,n),e=n+1;let i=new cn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(t=`${t}.`),e&&(o=`{${o}}`),t+=o}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};xo.NAME="RelativeObjectIdentifierValueBlock";var su,bo=class extends yt{constructor(t={}){super(t,xo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};su=bo;V.RelativeObjectIdentifier=su;bo.NAME="RelativeObjectIdentifier";var au,Be=class extends Ke{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};au=Be;V.Sequence=au;Be.NAME="SEQUENCE";var cu,vo=class extends Ke{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};cu=vo;V.Set=cu;vo.NAME="SET";var Eo=class extends Ie(At){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=Tr}toJSON(){return{...super.toJSON(),value:this.value}}};Eo.NAME="StringValueBlock";var Bo=class extends Eo{};Bo.NAME="SimpleStringValueBlock";var Tt=class extends so{constructor({...t}={}){super(t,Bo)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(t))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e);for(let o=0;o<e;o++)n[o]=t.charCodeAt(o);this.valueBlock.value=t}};Tt.NAME="SIMPLE STRING";var Ao=class extends Tt{fromBuffer(t){this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=j.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=j.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf8String(t)),this.valueBlock.value=t}};Ao.NAME="Utf8StringValueBlock";var uu,Ae=class extends Ao{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};uu=Ae;V.Utf8String=uu;Ae.NAME="UTF8String";var So=class extends Tt{fromBuffer(t){this.valueBlock.value=j.Convert.ToUtf16String(t),this.valueBlock.valueHexView=j.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(j.Convert.FromUtf16String(t))}};So.NAME="BmpStringValueBlock";var lu,Io=class extends So{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};lu=Io;V.BmpString=lu;Io.NAME="BMPString";var ko=class extends Tt{fromBuffer(t){let e=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),n=new Uint8Array(e);for(let o=0;o<n.length;o+=4)n[o]=n[o+3],n[o+1]=n[o+2],n[o+2]=0,n[o+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(e))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e*4);for(let o=0;o<e;o++){let i=$e(t.charCodeAt(o),8),s=new Uint8Array(i);if(s.length>4)continue;let a=4-s.length;for(let c=s.length-1;c>=0;c--)n[o*4+c+a]=s[c]}this.valueBlock.value=t}};ko.NAME="UniversalStringValueBlock";var fu,Co=class extends ko{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};fu=Co;V.UniversalString=fu;Co.NAME="UniversalString";var hu,To=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};hu=To;V.NumericString=hu;To.NAME="NumericString";var du,No=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};du=No;V.PrintableString=du;No.NAME="PrintableString";var pu,Uo=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};pu=Uo;V.TeletexString=pu;Uo.NAME="TeletexString";var gu,Ro=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};gu=Ro;V.VideotexString=gu;Ro.NAME="VideotexString";var mu,Lo=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};mu=Lo;V.IA5String=mu;Lo.NAME="IA5String";var yu,Vo=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};yu=Vo;V.GraphicString=yu;Vo.NAME="GraphicString";var wu,un=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};wu=un;V.VisibleString=wu;un.NAME="VisibleString";var xu,_o=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};xu=_o;V.GeneralString=xu;_o.NAME="GeneralString";var bu,Po=class extends Tt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};bu=Po;V.CharacterString=bu;Po.NAME="CharacterString";var vu,ln=class extends un{constructor({value:t,valueDate:e,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let o=0;o<t.length;o++)this.valueBlock.valueHexView[o]=t.charCodeAt(o)}e&&(this.fromDate(e),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,j.BufferSourceConverter.toUint8Array(t)))}toBuffer(){let t=this.toString(),e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return e}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);if(n===null){this.error="Wrong input string for conversion";return}let o=parseInt(n[1],10);o>=50?this.year=1900+o:this.year=2e3+o,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(t="iso"){if(t==="iso"){let e=new Array(7);return e[0]=Ft(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Ft(this.month,2),e[2]=Ft(this.day,2),e[3]=Ft(this.hour,2),e[4]=Ft(this.minute,2),e[5]=Ft(this.second,2),e[6]="Z",e.join("")}return super.toString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};vu=ln;V.UTCTime=vu;ln.NAME="UTCTime";var Eu,Fo=class extends ln{constructor(t={}){var e;super(t),(e=this.millisecond)!==null&&e!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let e=!1,n="",o="",i=0,s,a=0,c=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let l=new Number(t[t.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=t}if(e){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let l=1,h=n.indexOf("+"),m="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(m=n.substring(h+1),n=n.substring(0,h),m.length!==2&&m.length!==4)throw new Error("Wrong input string for conversion");let B=parseInt(m.substring(0,2),10);if(isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*B,m.length===4){if(B=parseInt(m.substring(2,4),10),isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");c=l*B}}}let f=n.indexOf(".");if(f===-1&&(f=n.indexOf(",")),f!==-1){let l=new Number(`0${n.substring(f)}`);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");i=l.valueOf(),o=n.substring(0,f)}else o=n;switch(!0){case o.length===8:if(s=/(\d{4})(\d{2})(\d{2})/ig,f!==-1)throw new Error("Wrong input string for conversion");break;case o.length===10:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.minute=Math.floor(l),l=60*(l-this.minute),this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===12:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=60*i;this.second=Math.floor(l),l=1e3*(l-this.second),this.millisecond=Math.floor(l)}break;case o.length===14:if(s=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,f!==-1){let l=1e3*i;this.millisecond=Math.floor(l)}break;default:throw new Error("Wrong input string for conversion")}let u=s.exec(o);if(u===null)throw new Error("Wrong input string for conversion");for(let l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+a;break;case 5:this.minute=parseInt(u[l],10)+c;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let l=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=l.getUTCFullYear(),this.month=l.getUTCMonth(),this.day=l.getUTCDay(),this.hour=l.getUTCHours(),this.minute=l.getUTCMinutes(),this.second=l.getUTCSeconds(),this.millisecond=l.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(Ft(this.year,4)),e.push(Ft(this.month,2)),e.push(Ft(this.day,2)),e.push(Ft(this.hour,2)),e.push(Ft(this.minute,2)),e.push(Ft(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(Ft(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Eu=Fo;V.GeneralizedTime=Eu;Fo.NAME="GeneralizedTime";var Bu,Do=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Bu=Do;V.DATE=Bu;Do.NAME="DATE";var Au,Oo=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Au=Oo;V.TimeOfDay=Au;Oo.NAME="TimeOfDay";var Su,Mo=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Su=Mo;V.DateTime=Su;Mo.NAME="DateTime";var Iu,Ho=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Iu=Ho;V.Duration=Iu;Ho.NAME="Duration";var ku,$o=class extends Ae{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};ku=$o;V.TIME=ku;$o.NAME="TIME";function rt(r,t="utf8"){let e=Yn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var fn=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},qo=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Cu={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new qo("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var qe=Cu;async function Tu(r){let t=await qe.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await K0(t);return{privateKey:e[0],publicKey:e[1]}}async function Nu(r,t){let e=await qe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await qe.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Uu(r,t,e){let n=await qe.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return qe.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function K0(r){if(r.privateKey==null||r.publicKey==null)throw new vt("Private and public key are required");return Promise.all([qe.get().subtle.exportKey("jwk",r.privateKey),qe.get().subtle.exportKey("jwk",r.publicKey)])}function zs(r){if(r.kty!=="RSA")throw new vt("invalid key type");if(r.n==null)throw new vt("invalid key modulus");return W(r.n,"base64url").length*8}var Nr=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=hn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return it.createV1(114,this._multihash)}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return Uu(this._key,e,t)}},dn=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=hn.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}sign(t){return Nu(this._key,t)}};var zo=8192,js=18;function Ru(r){let{result:t}=qs(r),e=t.valueBlock.value;return{n:ue(e[1]),e:ue(e[2]),d:ue(e[3]),p:ue(e[4]),q:ue(e[5]),dp:ue(e[6]),dq:ue(e[7]),qi:ue(e[8]),kty:"RSA",alg:"RS256"}}function q0(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new vt("JWK was missing components");let e=new Be({value:[new wt({value:0}),wt.fromBigInt(le(W(r.n,"base64url"))),wt.fromBigInt(le(W(r.e,"base64url"))),wt.fromBigInt(le(W(r.d,"base64url"))),wt.fromBigInt(le(W(r.p,"base64url"))),wt.fromBigInt(le(W(r.q,"base64url"))),wt.fromBigInt(le(W(r.dp,"base64url"))),wt.fromBigInt(le(W(r.dq,"base64url"))),wt.fromBigInt(le(W(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Lu(r){let{result:t}=qs(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:ue(e[0]),e:ue(e[1])}}function Gs(r){if(r.n==null||r.e==null)throw new vt("JWK was missing components");let e=new Be({value:[new Be({value:[new Cr({value:"1.2.840.113549.1.1.1"}),new Ir]}),new kr({valueHex:new Be({value:[wt.fromBigInt(le(W(r.n,"base64url"))),wt.fromBigInt(le(W(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function ue(r){let t=r.valueBlock.valueHexView;for(;t[0]===0;)t=t.subarray(1);return rt(t,"base64url")}function le(r){let t=[];return r.forEach(function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)}),BigInt("0x"+t.join(""))}function Vu(r){let t=Ru(r);return _u(t)}function Zs(r){let t=Lu(r);if(zs(t)>zo)throw new sr("Key size is too large");let e=Ar(ae.encode({Type:lt.RSA,Data:r})),n=Gt(js,e);return new Nr(t,n)}function _u(r){if(zs(r)>zo)throw new vt("Key size is too large");let t=Fu(r),e=Ar(ae.encode({Type:lt.RSA,Data:Gs(t.publicKey)})),n=Gt(js,e);return new dn(t.privateKey,new Nr(t.publicKey,n))}async function Pu(r){if(r>zo)throw new vt("Key size is too large");let t=await Tu(r),e=Ar(ae.encode({Type:lt.RSA,Data:Gs(t.publicKey)})),n=Gt(js,e);return new dn(t.privateKey,new Nr(t.publicKey,n))}function Fu(r){if(r==null)throw new vt("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var jo=class extends mr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,nc(t);let n=Gr(e);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(t){return gr(this),this.iHash.update(t),this}digestInto(t){gr(this),pr(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ws=(r,t,e)=>new jo(r,t).update(e).digest();Ws.create=(r,t)=>new jo(r,t);function Du(r){r.lowS!==void 0&&Wt("lowS",r.lowS),r.prehash!==void 0&&Wt("prehash",r.prehash)}function z0(r){let t=Jr(r);se(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:o}=t;if(e){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:j0,hexToBytes:G0}=Hn,Js=class extends Error{constructor(t=""){super(t)}},ke={Err:Js,_tlv:{encode:(r,t)=>{let{Err:e}=ke;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,o=We(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?We(o.length/2|128):"";return We(r)+i+o+t},decode(r,t){let{Err:e}=ke,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new e("tlv.decode(long): indefinite length not supported");if(c>4)throw new e("tlv.decode(long): byte length is too big");let f=t.subarray(n,n+c);if(f.length!==c)throw new e("tlv.decode: length bytes not complete");if(f[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new e("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new e("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(r){let{Err:t}=ke;if(r<Ce)throw new t("integer: negative integers are not allowed");let e=We(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=ke;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return j0(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=ke,o=typeof r=="string"?G0(r):r;wr(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:f,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(a),s:e.decode(f)}},hexFromSig(r){let{_tlv:t,_int:e}=ke,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}},Ce=BigInt(0),dt=BigInt(1),Fw=BigInt(2),Ou=BigInt(3),Dw=BigInt(4);function Z0(r){let t=z0(r),{Fp:e}=t,n=De(t.n,t.nBitLength),o=t.toBytes||((w,d,A)=>{let C=d.toAffine();return xe(Uint8Array.from([4]),e.toBytes(C.x),e.toBytes(C.y))}),i=t.fromBytes||(w=>{let d=w.subarray(1),A=e.fromBytes(d.subarray(0,e.BYTES)),C=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:A,y:C}});function s(w){let{a:d,b:A}=t,C=e.sqr(w),x=e.mul(C,w);return e.add(e.add(x,e.mul(w,d)),A)}if(!e.eql(e.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(w){return Zr(w,dt,t.n)}function c(w){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:C,n:x}=t;if(d&&typeof w!="bigint"){if(_e(w)&&(w=ye(w)),typeof w!="string"||!d.includes(w.length))throw new Error("invalid private key");w=w.padStart(A*2,"0")}let U;try{U=typeof w=="bigint"?w:we(st("private key",w,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof w)}return C&&(U=X(U,x)),Lt("private key",U,dt,x),U}function f(w){if(!(w instanceof h))throw new Error("ProjectivePoint expected")}let u=Xe((w,d)=>{let{px:A,py:C,pz:x}=w;if(e.eql(x,e.ONE))return{x:A,y:C};let U=w.is0();d==null&&(d=U?e.ONE:e.inv(x));let F=e.mul(A,d),P=e.mul(C,d),R=e.mul(x,d);if(U)return{x:e.ZERO,y:e.ZERO};if(!e.eql(R,e.ONE))throw new Error("invZ was invalid");return{x:F,y:P}}),l=Xe(w=>{if(w.is0()){if(t.allowInfinityPoint&&!e.is0(w.py))return;throw new Error("bad point: ZERO")}let{x:d,y:A}=w.toAffine();if(!e.isValid(d)||!e.isValid(A))throw new Error("bad point: x or y not FE");let C=e.sqr(A),x=s(d);if(!e.eql(C,x))throw new Error("bad point: equation left != right");if(!w.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,A,C){if(this.px=d,this.py=A,this.pz=C,d==null||!e.isValid(d))throw new Error("x required");if(A==null||!e.isValid(A))throw new Error("y required");if(C==null||!e.isValid(C))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:C}=d||{};if(!d||!e.isValid(A)||!e.isValid(C))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=U=>e.eql(U,e.ZERO);return x(A)&&x(C)?h.ZERO:new h(A,C,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=e.invertBatch(d.map(C=>C.pz));return d.map((C,x)=>C.toAffine(A[x])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(st("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return zn(h,n,d,A)}_setWindowSize(d){B.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:A,py:C,pz:x}=this,{px:U,py:F,pz:P}=d,R=e.eql(e.mul(A,P),e.mul(U,x)),b=e.eql(e.mul(C,P),e.mul(F,x));return R&&b}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:A}=t,C=e.mul(A,Ou),{px:x,py:U,pz:F}=this,P=e.ZERO,R=e.ZERO,b=e.ZERO,v=e.mul(x,x),D=e.mul(U,U),L=e.mul(F,F),T=e.mul(x,U);return T=e.add(T,T),b=e.mul(x,F),b=e.add(b,b),P=e.mul(d,b),R=e.mul(C,L),R=e.add(P,R),P=e.sub(D,R),R=e.add(D,R),R=e.mul(P,R),P=e.mul(T,P),b=e.mul(C,b),L=e.mul(d,L),T=e.sub(v,L),T=e.mul(d,T),T=e.add(T,b),b=e.add(v,v),v=e.add(b,v),v=e.add(v,L),v=e.mul(v,T),R=e.add(R,v),L=e.mul(U,F),L=e.add(L,L),v=e.mul(L,T),P=e.sub(P,v),b=e.mul(L,D),b=e.add(b,b),b=e.add(b,b),new h(P,R,b)}add(d){f(d);let{px:A,py:C,pz:x}=this,{px:U,py:F,pz:P}=d,R=e.ZERO,b=e.ZERO,v=e.ZERO,D=t.a,L=e.mul(t.b,Ou),T=e.mul(A,U),$=e.mul(C,F),S=e.mul(x,P),I=e.add(A,C),g=e.add(U,F);I=e.mul(I,g),g=e.add(T,$),I=e.sub(I,g),g=e.add(A,x);let p=e.add(U,P);return g=e.mul(g,p),p=e.add(T,S),g=e.sub(g,p),p=e.add(C,x),R=e.add(F,P),p=e.mul(p,R),R=e.add($,S),p=e.sub(p,R),v=e.mul(D,g),R=e.mul(L,S),v=e.add(R,v),R=e.sub($,v),v=e.add($,v),b=e.mul(R,v),$=e.add(T,T),$=e.add($,T),S=e.mul(D,S),g=e.mul(L,g),$=e.add($,S),S=e.sub(T,S),S=e.mul(D,S),g=e.add(g,S),T=e.mul($,g),b=e.add(b,T),T=e.mul(p,g),R=e.mul(I,R),R=e.sub(R,T),T=e.mul(I,$),v=e.mul(p,v),v=e.add(v,T),new h(R,b,v)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return B.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:A,n:C}=t;Lt("scalar",d,Ce,C);let x=h.ZERO;if(d===Ce)return x;if(this.is0()||d===dt)return this;if(!A||B.hasPrecomputes(this))return B.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:U,k1:F,k2neg:P,k2:R}=A.splitScalar(d),b=x,v=x,D=this;for(;F>Ce||R>Ce;)F&dt&&(b=b.add(D)),R&dt&&(v=v.add(D)),D=D.double(),F>>=dt,R>>=dt;return U&&(b=b.negate()),P&&(v=v.negate()),v=new h(e.mul(v.px,A.beta),v.py,v.pz),b.add(v)}multiply(d){let{endo:A,n:C}=t;Lt("scalar",d,dt,C);let x,U;if(A){let{k1neg:F,k1:P,k2neg:R,k2:b}=A.splitScalar(d),{p:v,f:D}=this.wNAF(P),{p:L,f:T}=this.wNAF(b);v=B.constTimeNegate(F,v),L=B.constTimeNegate(R,L),L=new h(e.mul(L.px,A.beta),L.py,L.pz),x=v.add(L),U=D.add(T)}else{let{p:F,f:P}=this.wNAF(d);x=F,U=P}return h.normalizeZ([x,U])[0]}multiplyAndAddUnsafe(d,A,C){let x=h.BASE,U=(P,R)=>R===Ce||R===dt||!P.equals(x)?P.multiplyUnsafe(R):P.multiply(R),F=U(this,A).add(U(d,C));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:A}=t;if(d===dt)return!0;if(A)return A(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:A}=t;return d===dt?this:A?A(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Wt("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Wt("isCompressed",d),ye(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let m=t.nBitLength,B=qn(h,t.endo?Math.ceil(m/2):m);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function W0(r){let t=Jr(r);return se(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Mu(r){let t=W0(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(S){return X(S,n)}function a(S){return $n(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=Z0({...t,toBytes(S,I,g){let p=I.toAffine(),E=e.toBytes(p.x),N=xe;return Wt("isCompressed",g),g?N(Uint8Array.from([I.hasEvenY()?2:3]),E):N(Uint8Array.from([4]),E,e.toBytes(p.y))},fromBytes(S){let I=S.length,g=S[0],p=S.subarray(1);if(I===o&&(g===2||g===3)){let E=we(p);if(!Zr(E,dt,e.ORDER))throw new Error("Point is not on curve");let N=u(E),O;try{O=e.sqrt(N)}catch(G){let K=G instanceof Error?": "+G.message:"";throw new Error("Point is not on curve"+K)}let M=(O&dt)===dt;return(g&1)===1!==M&&(O=e.neg(O)),{x:E,y:O}}else if(I===i&&g===4){let E=e.fromBytes(p.subarray(0,e.BYTES)),N=e.fromBytes(p.subarray(e.BYTES,2*e.BYTES));return{x:E,y:N}}else{let E=o,N=i;throw new Error("invalid Point, expected length of "+E+", or uncompressed "+N+", got "+I)}}}),h=S=>ye(Fe(S,t.nByteLength));function m(S){let I=n>>dt;return S>I}function B(S){return m(S)?s(-S):S}let w=(S,I,g)=>we(S.slice(I,g));class d{constructor(I,g,p){this.r=I,this.s=g,this.recovery=p,this.assertValidity()}static fromCompact(I){let g=t.nByteLength;return I=st("compactSignature",I,g*2),new d(w(I,0,g),w(I,g,2*g))}static fromDER(I){let{r:g,s:p}=ke.toSig(st("DER",I));return new d(g,p)}assertValidity(){Lt("r",this.r,dt,n),Lt("s",this.s,dt,n)}addRecoveryBit(I){return new d(this.r,this.s,I)}recoverPublicKey(I){let{r:g,s:p,recovery:E}=this,N=P(st("msgHash",I));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");let O=E===2||E===3?g+t.n:g;if(O>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let M=E&1?"03":"02",z=c.fromHex(M+h(O)),G=a(O),K=s(-N*G),Y=s(p*G),tt=c.BASE.multiplyAndAddUnsafe(z,K,Y);if(!tt)throw new Error("point at infinify");return tt.assertValidity(),tt}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Je(this.toDERHex())}toDERHex(){return ke.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Je(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let A={isValidPrivateKey(S){try{return f(S),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let S=rs(t.n);return mc(t.randomBytes(S),t.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function C(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function x(S){let I=_e(S),g=typeof S=="string",p=(I||g)&&S.length;return I?p===o||p===i:g?p===2*o||p===2*i:S instanceof c}function U(S,I,g=!0){if(x(S))throw new Error("first arg must be private key");if(!x(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(f(S)).toRawBytes(g)}let F=t.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let I=we(S),g=S.length*8-t.nBitLength;return g>0?I>>BigInt(g):I},P=t.bits2int_modN||function(S){return s(F(S))},R=Wr(t.nBitLength);function b(S){return Lt("num < 2^"+t.nBitLength,S,Ce,R),Fe(S,t.nByteLength)}function v(S,I,g=D){if(["recovered","canonical"].some(ht=>ht in g))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:E}=t,{lowS:N,prehash:O,extraEntropy:M}=g;N==null&&(N=!0),S=st("msgHash",S),Du(g),O&&(S=st("prehashed msgHash",p(S)));let z=P(S),G=f(I),K=[b(G),b(z)];if(M!=null&&M!==!1){let ht=M===!0?E(e.BYTES):M;K.push(st("extraEntropy",ht))}let Y=xe(...K),tt=z;function ft(ht){let mt=F(ht);if(!l(mt))return;let bt=a(mt),Ut=c.BASE.multiply(mt).toAffine(),kt=s(Ut.x);if(kt===Ce)return;let oe=s(bt*s(tt+kt*G));if(oe===Ce)return;let he=(Ut.x===kt?0:2)|Number(Ut.y&dt),Kr=oe;return N&&m(oe)&&(Kr=B(oe),he^=1),new d(kt,Kr,he)}return{seed:Y,k2sig:ft}}let D={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function T(S,I,g=D){let{seed:p,k2sig:E}=v(S,I,g),N=t;return Xi(N.hash.outputLen,N.nByteLength,N.hmac)(p,E)}c.BASE._setWindowSize(8);function $(S,I,g,p=L){let E=S;I=st("msgHash",I),g=st("publicKey",g);let{lowS:N,prehash:O,format:M}=p;if(Du(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(M!==void 0&&M!=="compact"&&M!=="der")throw new Error("format must be compact or der");let z=typeof E=="string"||_e(E),G=!z&&!M&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!z&&!G)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,Y;try{if(G&&(K=new d(E.r,E.s)),z){try{M!=="compact"&&(K=d.fromDER(E))}catch(he){if(!(he instanceof ke.Err))throw he}!K&&M!=="der"&&(K=d.fromCompact(E))}Y=c.fromHex(g)}catch{return!1}if(!K||N&&K.hasHighS())return!1;O&&(I=t.hash(I));let{r:tt,s:ft}=K,ht=P(I),mt=a(ft),bt=s(ht*mt),Ut=s(tt*mt),kt=c.BASE.multiplyAndAddUnsafe(Y,bt,Ut)?.toAffine();return kt?s(kt.x)===tt:!1}return{CURVE:t,getPublicKey:C,getSharedSecret:U,sign:T,verify:$,ProjectivePoint:c,Signature:d,utils:A}}function J0(r){return{hash:r,hmac:(t,...e)=>Ws(r,t,zi(...e)),randomBytes:Fn}}function Hu(r,t){let e=n=>Mu({...r,...J0(n)});return{...e(t),create:e}}var qu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$u=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Y0=BigInt(1),Ys=BigInt(2),Ku=(r,t)=>(r+t/Ys)/t;function X0(r){let t=qu,e=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%t,u=f*f*r%t,l=ot(u,e,t)*u%t,h=ot(l,e,t)*u%t,m=ot(h,Ys,t)*f%t,B=ot(m,o,t)*m%t,w=ot(B,i,t)*B%t,d=ot(w,a,t)*w%t,A=ot(d,c,t)*d%t,C=ot(A,a,t)*w%t,x=ot(C,e,t)*u%t,U=ot(x,s,t)*B%t,F=ot(U,n,t)*f%t,P=ot(F,Ys,t);if(!Xs.eql(Xs.sqr(P),r))throw new Error("Cannot find square root");return P}var Xs=De(qu,void 0,void 0,{sqrt:X0}),or=Hu({a:BigInt(0),b:BigInt(7),Fp:Xs,n:$u,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=$u,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Y0*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),a=Ku(i*r,t),c=Ku(-n*r,t),f=X(r-a*e-c*o,t),u=X(-a*n-c*i,t),l=f>s,h=u>s;if(l&&(f=t-f),h&&(u=t-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},Ar),Gw=BigInt(0);var Zw=or.ProjectivePoint;function St(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=_t(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function zu(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ju(r,t,e){let n=Yr.digest(e instanceof Uint8Array?e:e.subarray());if(zu(n))return n.then(({digest:o})=>or.verify(t,o,r)).catch(o=>{throw new fn(String(o))});try{return or.verify(t,n.digest,r)}catch(o){throw new fn(String(o))}}var Go=class{type="secp256k1";raw;_key;constructor(t){this._key=Zu(t),this.raw=Gu(this._key)}toMultihash(){return ge.digest(Wn(this))}toCID(){return it.createV1(114,this.toMultihash())}toString(){return et.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:ct(this.raw,t.raw)}verify(t,e){return ju(this._key,e,t)}};function Qs(r){return new Go(r)}function Gu(r){return or.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Zu(r){try{return or.ProjectivePoint.fromHex(r),r}catch(t){throw new sr(String(t))}}function Wu(r){let{Type:t,Data:e}=ae.decode(r),n=e??new Uint8Array;switch(t){case lt.RSA:return Zs(n);case lt.Ed25519:return us(n);case lt.secp256k1:return Qs(n);default:throw new cr}}function Zo(r){let{Type:t,Data:e}=ae.decode(r.digest),n=e??new Uint8Array;switch(t){case lt.Ed25519:return us(n);case lt.secp256k1:return Qs(n);default:throw new cr}}function Wn(r){return ae.encode({Type:lt[r.type],Data:r.raw})}var Ju=Symbol.for("nodejs.util.inspect.custom"),Q0=114,pn=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ui]=!0;toString(){return this.string==null&&(this.string=et.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return it.createV1(Q0,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return ct(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return ct(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[Ju](){return`PeerId(${this.toString()})`}},Wo=class extends pn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Jo=class extends pn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},Yo=class extends pn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},tp=2336,Xo=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=ge.digest(W(this.url))}[Ju](){return`PeerId(${this.url})`}[Ui]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return it.createV1(tp,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=rt(t)),t.toString()===this.toString())}};function Yu(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=pe(et.decode(`z${r}`));else{if(t==null)throw new vt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=pe(t.decode(r))}return ep(e)}function ep(r){if(np(r))return new Wo({multihash:r});if(rp(r))try{let t=Zo(r);if(t.type==="Ed25519")return new Jo({multihash:r,publicKey:t});if(t.type==="secp256k1")return new Yo({multihash:r,publicKey:t})}catch{let e=rt(r.digest);return new Xo(new URL(e))}throw new ar("Supplied PeerID Multihash is invalid")}function rp(r){return r.code===ge.code}function np(r){return r.code===Yr.code}var Qo=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}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(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",f=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let h=Number.parseInt(l,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=t,i+=u,i>f||(s+=1,e!==void 0&&s>e))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let o=n*2;if(n<e.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return e[o]=s[0],e[o+1]=s[1],e[o+2]=s[2],e[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];e[o]=i>>8,e[o+1]=i&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,o]=t(e);if(n===16)return e;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return e.set(i.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Xu=45,op=15,Ur=new Qo;function ta(r){if(!(r.length>op))return Ur.new(r).parseWith(()=>Ur.readIPv4Addr())}function ea(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Xu))return Ur.new(r).parseWith(()=>Ur.readIPv6Addr())}function ti(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Xu)return;let e=Ur.new(r).parseWith(()=>Ur.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}var lb=parseInt("0xFFFF",16),fb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function el(r){return!!ta(r)}function rl(r){return!!ea(r)}function ei(r){return!!ti(r)}var nl=el,up=rl,ra=function(r){let t=0;if(r=r.toString().trim(),nl(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(up(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=nl(e[n]),s;i&&(s=ra(e[n]),e[n]=rt(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,rt(s.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let i=[n,1];for(n=9-e.length;n>0;n--)i.push("0");e.splice.apply(e,i)}let o=new Uint8Array(t+16);for(n=0;n<e.length;n++){let i=parseInt(e[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},ol=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let o=[];for(let i=0;i<e;i++)o.push(r[t+i]);return o.join(".")}if(e===16){let o=[];for(let i=0;i<e;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Rr={},na={},fp=[[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"],[481,-1,"http-path"],[777,-1,"memory"]];fp.forEach(r=>{let t=hp(...r);na[t.code]=t,Rr[t.name]=t});function hp(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function Q(r){if(typeof r=="number"){if(na[r]!=null)return na[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Rr[r]!=null)return Rr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Zb=Q("ip4"),Wb=Q("ip6"),Jb=Q("ipcidr");function aa(r,t){switch(Q(r).code){case 4:case 41:return pp(t);case 42:return sa(t);case 43:return rt(t,"base10");case 6:case 273:case 33:case 132:return al(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return sa(t);case 421:return wp(t);case 444:return sl(t);case 445:return sl(t);case 466:return yp(t);case 481:return globalThis.encodeURIComponent(sa(t));default:return rt(t,"base16")}}function ca(r,t){switch(Q(r).code){case 4:return il(t);case 41:return il(t);case 42:return ia(t);case 43:return W(t,"base10");case 6:case 273:case 33:case 132:return ua(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ia(t);case 421:return gp(t);case 444:return xp(t);case 445:return bp(t);case 466:return mp(t);case 481:return ia(globalThis.decodeURIComponent(t));default:return W(t,"base16")}}var oa=Object.values(Xr).map(r=>r.decoder),dp=function(){let r=oa[0].or(oa[1]);return oa.slice(2).forEach(t=>r=r.or(t)),r}();function il(r){if(!ei(r))throw new Error("invalid ip address");return ra(r)}function pp(r){let t=ol(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!ei(t))throw new Error("invalid ip address");return t}function ua(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function al(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function ia(r){let t=W(r),e=Uint8Array.from(xr(t.length));return St([e,t],e.length+t.length)}function sa(r){let t=tr(r);if(r=r.slice(Pt(t)),r.length!==t)throw new Error("inconsistent lengths");return rt(r)}function gp(r){let t;r[0]==="Q"||r[0]==="1"?t=pe(et.decode(`z${r}`)).bytes:t=it.parse(r).multihash.bytes;let e=Uint8Array.from(xr(t.length));return St([e,t],e.length+t.length)}function mp(r){let t=dp.decode(r),e=Uint8Array.from(xr(t.length));return St([e,t],e.length+t.length)}function yp(r){let t=tr(r),e=r.slice(Pt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+rt(e,"base64url")}function wp(r){let t=tr(r),e=r.slice(Pt(t));if(e.length!==t)throw new Error("inconsistent lengths");return rt(e,"base58btc")}function xp(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=jt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ua(n);return St([e,o],e.length+o.length)}function bp(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=jt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ua(n);return St([e,o],e.length+o.length)}function sl(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=rt(t,"base32"),o=al(e);return`${n}:${o}`}function cl(r){r=la(r);let t=[],e=[],n=null,o=r.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=Q(s);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(i++,i>=o.length)throw new ri("invalid address: "+r);if(a.path===!0){n=la(o.slice(i).join("/")),t.push([a.code,ca(a.code,n)]),e.push([a.code,n]);break}let c=ca(a.code,o[i]);t.push([a.code,c]),e.push([a.code,aa(a.code,c)])}return{string:ul(e),bytes:ha(t),tuples:t,stringTuples:e,path:n}}function fa(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=tr(r,o),s=Pt(i),a=Q(i),c=vp(a,r.slice(o+s));if(c===0){t.push([i]),e.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+c);if(o+=c+s,o>r.length)throw new ri("Invalid address Uint8Array: "+rt(r,"base16"));t.push([i,f]);let u=aa(i,f);if(e.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:ul(e),tuples:t,stringTuples:e,path:n}}function ul(r){let t=[];return r.map(e=>{let n=Q(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),la(t.join("/"))}function ha(r){return St(r.map(t=>{let e=Q(t[0]),n=Uint8Array.from(xr(e.code));return t.length>1&&t[1]!=null&&(n=St([n,t[1]])),n}))}function vp(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=tr(t instanceof Uint8Array?t:Uint8Array.from(t));return e+Pt(e)}}function la(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var ri=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Ep=Symbol.for("nodejs.util.inspect.custom"),pa=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Bp=[Q("dns").code,Q("dns4").code,Q("dns6").code,Q("dnsaddr").code],da=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},ni=class r{bytes;#t;#r;#e;#a;[pa]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=fa(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=cl(t)}else if(fl(t))e=fa(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#t=e.string,this.#r=e.tuples,this.#e=e.stringTuples,this.#a=e.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,e,n,o,i="",s=Q("tcp"),a=Q("udp"),c=Q("ip4"),f=Q("ip6"),u=Q("dns6"),l=Q("ip6zone");for(let[m,B]of this.stringTuples())m===l.code&&(i=`%${B??""}`),Bp.includes(m)&&(e=s.name==="tcp"?"tcp":"udp",o=443,n=`${B??""}${i}`,t=m===u.code?6:4),(m===s.code||m===a.code)&&(e=Q(m).name==="tcp"?"tcp":"udp",o=parseInt(B??"")),(m===c.code||m===f.code)&&(e=Q(m).name==="tcp"?"tcp":"udp",n=`${B??""}${i}`,t=m===f.code?6:4);if(t==null||e==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:o}}protos(){return this.#r.map(([t])=>Object.assign({},Q(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>Q(t).name)}tuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#e.map(([t,e])=>e==null?[t]:[t,e])}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),o=n.lastIndexOf(e);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,o))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(ha(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Rr.p2p.code&&t.push([n,o]),n===Rr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?rt(et.decode(`z${n}`),"base58btc"):rt(it.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return ct(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=ll.get(e.name);if(n==null)throw new da(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>gn(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Ep](){return`Multiaddr(${this.#t})`}};var ll=new Map;function fl(r){return!!r?.[pa]}function gn(r){return new ni(r)}function mn(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 o=t.signal;return o.clear=n,o}async function*oi(r,t={}){let e=r.getReader();try{for(;;){let n=await e.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await e.cancel(),e.releaseLock()}}var Ap="/",Sp=new TextEncoder().encode(Ap),A1=Sp[0];var ig=Nn(ma(),1);var Qt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},ii=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},Lr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},si=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},ai=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},ci=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},yn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var te;(function(r){let t;(function(o){o.EOL="EOL"})(t=r.ValidityType||(r.ValidityType={}));let e;(function(o){o[o.EOL=0]="EOL"})(e||(e={})),function(o){o.codec=()=>en(e)}(t=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Br((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),r.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let f=o.uint32();switch(f>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=r.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(f&7);break}}}return a})),n),r.encode=o=>vr(o,r.codec()),r.decode=(o,i)=>br(o,r.codec(),i)})(te||(te={}));var Ip=["string","number","bigint","symbol"],kp=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function hl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(Ip.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(Cp(r))return"Buffer";let e=Tp(r);return e||"Object"}function Cp(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function Tp(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(kp.includes(t))return t}var y=class{constructor(t,e,n){this.major=t,this.majorEncoded=t<<5,this.name=e,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};y.uint=new y(0,"uint",!0);y.negint=new y(1,"negint",!0);y.bytes=new y(2,"bytes",!0);y.string=new y(3,"string",!0);y.array=new y(4,"array",!1);y.map=new y(5,"map",!1);y.tag=new y(6,"tag",!1);y.float=new y(7,"float",!0);y.false=new y(7,"false",!0);y.true=new y(7,"true",!0);y.null=new y(7,"null",!0);y.undefined=new y(7,"undefined",!0);y.break=new y(7,"break",!0);var _=class{constructor(t,e,n){this.type=t,this.value=e,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Vr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Np=new TextDecoder,Up=new TextEncoder;function ui(r){return Vr&&globalThis.Buffer.isBuffer(r)}function ml(r){return r instanceof Uint8Array?ui(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var yl=Vr?(r,t,e)=>e-t>64?globalThis.Buffer.from(r.subarray(t,e)).toString("utf8"):pl(r,t,e):(r,t,e)=>e-t>64?Np.decode(r.subarray(t,e)):pl(r,t,e),wl=Vr?r=>r.length>64?globalThis.Buffer.from(r):dl(r):r=>r.length>64?Up.encode(r):dl(r);var _r=Vr?(r,t,e)=>ui(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),xl=Vr?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),ml(globalThis.Buffer.concat(r,t))):(r,t)=>{let e=new Uint8Array(t),n=0;for(let o of r)n+o.length>e.length&&(o=o.subarray(0,e.length-n)),e.set(o,n),n+=o.length;return e},bl=Vr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function vl(r,t){if(ui(r)&&ui(t))return r.compare(t);for(let e=0;e<r.length;e++)if(r[e]!==t[e])return r[e]<t[e]?-1:1;return 0}function dl(r){let t=[],e=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?t[e++]=o:o<2048?(t[e++]=o>>6|192,t[e++]=o&63|128):(o&64512)===55296&&n+1<r.length&&(r.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(r.charCodeAt(++n)&1023),t[e++]=o>>18|240,t[e++]=o>>12&63|128,t[e++]=o>>6&63|128,t[e++]=o&63|128):(t[e++]=o>>12|224,t[e++]=o>>6&63|128,t[e++]=o&63|128)}return t}function pl(r,t,e){let n=[];for(;t<e;){let o=r[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=e){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[t+1],c=r[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=r[t+1],c=r[t+2],f=r[t+3],(a&192)===128&&(c&192)===128&&(f&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|f&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return Rp(n)}var gl=4096;function Rp(r){let t=r.length;if(t<=gl)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=gl));return e}var Lp=256,li=class{constructor(t=Lp){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let e=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=e.length-(this.maxCursor-this.cursor)-1;e.set(t,o)}else{if(e){let o=e.length-(this.maxCursor-this.cursor)-1;o<e.length&&(this.chunks[this.chunks.length-1]=e.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(e=bl(this.chunkSize),this.chunks.push(e),this.maxCursor+=e.length,this._initReuseChunk===null&&(this._initReuseChunk=e),e.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let e;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(e=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):e=_r(n,0,this.cursor)}else e=xl(this.chunks,this.cursor);return t&&this.reset(),e}};var H="CBOR decode error:",ya="CBOR encode error:",wn=[];wn[23]=1;wn[24]=2;wn[25]=3;wn[26]=5;wn[27]=9;function Te(r,t,e){if(r.length-t<e)throw new Error(`${H} not enough data for type`)}var pt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ot(r,t,e){Te(r,t,1);let n=r[t];if(e.strict===!0&&n<pt[0])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Mt(r,t,e){Te(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<pt[1])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Ht(r,t,e){Te(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<pt[2])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function $t(r,t,e){Te(r,t,8);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3],o=r[t+4]*16777216+(r[t+5]<<16)+(r[t+6]<<8)+r[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(e.strict===!0&&i<pt[3])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(e.allowBigInt===!0)return i;throw new Error(`${H} integers outside of the safe integer range are not supported`)}function El(r,t,e,n){return new _(y.uint,Ot(r,t+1,n),2)}function Bl(r,t,e,n){return new _(y.uint,Mt(r,t+1,n),3)}function Al(r,t,e,n){return new _(y.uint,Ht(r,t+1,n),5)}function Sl(r,t,e,n){return new _(y.uint,$t(r,t+1,n),9)}function qt(r,t){return xt(r,0,t.value)}function xt(r,t,e){if(e<pt[0]){let n=Number(e);r.push([t|n])}else if(e<pt[1]){let n=Number(e);r.push([t|24,n])}else if(e<pt[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<pt[3]){let n=Number(e);r.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(e);if(n<pt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,r.push(o)}else throw new Error(`${H} encountered BigInt larger than allowable range`)}}qt.encodedSize=function(t){return xt.encodedSize(t.value)};xt.encodedSize=function(t){return t<pt[0]?1:t<pt[1]?2:t<pt[2]?3:t<pt[3]?5:9};qt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function Il(r,t,e,n){return new _(y.negint,-1-Ot(r,t+1,n),2)}function kl(r,t,e,n){return new _(y.negint,-1-Mt(r,t+1,n),3)}function Cl(r,t,e,n){return new _(y.negint,-1-Ht(r,t+1,n),5)}var wa=BigInt(-1),Tl=BigInt(1);function Nl(r,t,e,n){let o=$t(r,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new _(y.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${H} integers outside of the safe integer range are not supported`);return new _(y.negint,wa-BigInt(o),9)}function fi(r,t){let e=t.value,n=typeof e=="bigint"?e*wa-Tl:e*-1-1;xt(r,t.type.majorEncoded,n)}fi.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*wa-Tl:e*-1-1;return n<pt[0]?1:n<pt[1]?2:n<pt[2]?3:n<pt[3]?5:9};fi.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function xn(r,t,e,n){Te(r,t,e+n);let o=_r(r,t+e,t+e+n);return new _(y.bytes,o,e+n)}function Ul(r,t,e,n){return xn(r,t,1,e)}function Rl(r,t,e,n){return xn(r,t,2,Ot(r,t+1,n))}function Ll(r,t,e,n){return xn(r,t,3,Mt(r,t+1,n))}function Vl(r,t,e,n){return xn(r,t,5,Ht(r,t+1,n))}function _l(r,t,e,n){let o=$t(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer bytes lengths not supported`);return xn(r,t,9,o)}function hi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?wl(r.value):r.value),r.encodedBytes}function Pr(r,t){let e=hi(t);xt(r,t.type.majorEncoded,e.length),r.push(e)}Pr.encodedSize=function(t){let e=hi(t);return xt.encodedSize(e.length)+e.length};Pr.compareTokens=function(t,e){return _p(hi(t),hi(e))};function _p(r,t){return r.length<t.length?-1:r.length>t.length?1:vl(r,t)}function bn(r,t,e,n,o){let i=e+n;Te(r,t,i);let s=new _(y.string,yl(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=_r(r,t+e,t+i)),s}function Pl(r,t,e,n){return bn(r,t,1,e,n)}function Fl(r,t,e,n){return bn(r,t,2,Ot(r,t+1,n),n)}function Dl(r,t,e,n){return bn(r,t,3,Mt(r,t+1,n),n)}function Ol(r,t,e,n){return bn(r,t,5,Ht(r,t+1,n),n)}function Ml(r,t,e,n){let o=$t(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer string lengths not supported`);return bn(r,t,9,o,n)}var Hl=Pr;function Fr(r,t,e,n){return new _(y.array,n,e)}function $l(r,t,e,n){return Fr(r,t,1,e)}function Kl(r,t,e,n){return Fr(r,t,2,Ot(r,t+1,n))}function ql(r,t,e,n){return Fr(r,t,3,Mt(r,t+1,n))}function zl(r,t,e,n){return Fr(r,t,5,Ht(r,t+1,n))}function jl(r,t,e,n){let o=$t(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer array lengths not supported`);return Fr(r,t,9,o)}function Gl(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Fr(r,t,1,1/0)}function di(r,t){xt(r,y.array.majorEncoded,t.value)}di.compareTokens=qt.compareTokens;di.encodedSize=function(t){return xt.encodedSize(t.value)};function Dr(r,t,e,n){return new _(y.map,n,e)}function Zl(r,t,e,n){return Dr(r,t,1,e)}function Wl(r,t,e,n){return Dr(r,t,2,Ot(r,t+1,n))}function Jl(r,t,e,n){return Dr(r,t,3,Mt(r,t+1,n))}function Yl(r,t,e,n){return Dr(r,t,5,Ht(r,t+1,n))}function Xl(r,t,e,n){let o=$t(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer map lengths not supported`);return Dr(r,t,9,o)}function Ql(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Dr(r,t,1,1/0)}function pi(r,t){xt(r,y.map.majorEncoded,t.value)}pi.compareTokens=qt.compareTokens;pi.encodedSize=function(t){return xt.encodedSize(t.value)};function tf(r,t,e,n){return new _(y.tag,e,1)}function ef(r,t,e,n){return new _(y.tag,Ot(r,t+1,n),2)}function rf(r,t,e,n){return new _(y.tag,Mt(r,t+1,n),3)}function nf(r,t,e,n){return new _(y.tag,Ht(r,t+1,n),5)}function of(r,t,e,n){return new _(y.tag,$t(r,t+1,n),9)}function gi(r,t){xt(r,y.tag.majorEncoded,t.value)}gi.compareTokens=qt.compareTokens;gi.encodedSize=function(t){return xt.encodedSize(t.value)};var Hp=20,$p=21,Kp=22,qp=23;function sf(r,t,e,n){if(n.allowUndefined===!1)throw new Error(`${H} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new _(y.null,null,1):new _(y.undefined,void 0,1)}function af(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return new _(y.break,void 0,1)}function xa(r,t,e){if(e){if(e.allowNaN===!1&&Number.isNaN(r))throw new Error(`${H} NaN values are not supported`);if(e.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${H} Infinity values are not supported`)}return new _(y.float,r,t)}function cf(r,t,e,n){return xa(ba(r,t+1),3,n)}function uf(r,t,e,n){return xa(va(r,t+1),5,n)}function lf(r,t,e,n){return xa(pf(r,t+1),9,n)}function mi(r,t,e){let n=t.value;if(n===!1)r.push([y.float.majorEncoded|Hp]);else if(n===!0)r.push([y.float.majorEncoded|$p]);else if(n===null)r.push([y.float.majorEncoded|Kp]);else if(n===void 0)r.push([y.float.majorEncoded|qp]);else{let o,i=!1;(!e||e.float64!==!0)&&(hf(n),o=ba(ee,1),n===o||Number.isNaN(n)?(ee[0]=249,r.push(ee.slice(0,3)),i=!0):(df(n),o=va(ee,1),n===o&&(ee[0]=250,r.push(ee.slice(0,5)),i=!0))),i||(zp(n),o=pf(ee,1),ee[0]=251,r.push(ee.slice(0,9)))}}mi.encodedSize=function(t,e){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!e||e.float64!==!0){hf(n);let o=ba(ee,1);if(n===o||Number.isNaN(n))return 3;if(df(n),o=va(ee,1),n===o)return 5}return 9};var ff=new ArrayBuffer(9),zt=new DataView(ff,1),ee=new Uint8Array(ff,0);function hf(r){if(r===1/0)zt.setUint16(0,31744,!1);else if(r===-1/0)zt.setUint16(0,64512,!1);else if(Number.isNaN(r))zt.setUint16(0,32256,!1);else{zt.setFloat32(0,r);let t=zt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)zt.setUint16(0,31744,!1);else if(e===0)zt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?zt.setUint16(0,0):o<-14?zt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):zt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ba(r,t){if(r.length-t<2)throw new Error(`${H} not enough data for float16`);let e=(r[t]<<8)+r[t+1];if(e===31744)return 1/0;if(e===64512)return-1/0;if(e===32256)return NaN;let n=e>>10&31,o=e&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,e&32768?-i:i}function df(r){zt.setFloat32(0,r,!1)}function va(r,t){if(r.length-t<4)throw new Error(`${H} not enough data for float32`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,4).getFloat32(0,!1)}function zp(r){zt.setFloat64(0,r,!1)}function pf(r,t){if(r.length-t<8)throw new Error(`${H} not enough data for float64`);let e=(r.byteOffset||0)+t;return new DataView(r.buffer,e,8).getFloat64(0,!1)}mi.compareTokens=qt.compareTokens;function Z(r,t,e){throw new Error(`${H} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function yi(r){return()=>{throw new Error(`${H} ${r}`)}}var k=[];for(let r=0;r<=23;r++)k[r]=Z;k[24]=El;k[25]=Bl;k[26]=Al;k[27]=Sl;k[28]=Z;k[29]=Z;k[30]=Z;k[31]=Z;for(let r=32;r<=55;r++)k[r]=Z;k[56]=Il;k[57]=kl;k[58]=Cl;k[59]=Nl;k[60]=Z;k[61]=Z;k[62]=Z;k[63]=Z;for(let r=64;r<=87;r++)k[r]=Ul;k[88]=Rl;k[89]=Ll;k[90]=Vl;k[91]=_l;k[92]=Z;k[93]=Z;k[94]=Z;k[95]=yi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)k[r]=Pl;k[120]=Fl;k[121]=Dl;k[122]=Ol;k[123]=Ml;k[124]=Z;k[125]=Z;k[126]=Z;k[127]=yi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)k[r]=$l;k[152]=Kl;k[153]=ql;k[154]=zl;k[155]=jl;k[156]=Z;k[157]=Z;k[158]=Z;k[159]=Gl;for(let r=160;r<=183;r++)k[r]=Zl;k[184]=Wl;k[185]=Jl;k[186]=Yl;k[187]=Xl;k[188]=Z;k[189]=Z;k[190]=Z;k[191]=Ql;for(let r=192;r<=215;r++)k[r]=tf;k[216]=ef;k[217]=rf;k[218]=nf;k[219]=of;k[220]=Z;k[221]=Z;k[222]=Z;k[223]=Z;for(let r=224;r<=243;r++)k[r]=yi("simple values are not supported");k[244]=Z;k[245]=Z;k[246]=Z;k[247]=sf;k[248]=yi("simple values are not supported");k[249]=cf;k[250]=uf;k[251]=lf;k[252]=Z;k[253]=Z;k[254]=Z;k[255]=af;var re=[];for(let r=0;r<24;r++)re[r]=new _(y.uint,r,1);for(let r=-1;r>=-24;r--)re[31-r]=new _(y.negint,r,1);re[64]=new _(y.bytes,new Uint8Array(0),1);re[96]=new _(y.string,"",1);re[128]=new _(y.array,0,1);re[160]=new _(y.map,0,1);re[244]=new _(y.false,!1,1);re[245]=new _(y.true,!0,1);re[246]=new _(y.null,null,1);function Gp(){let r=[];return r[y.uint.major]=qt,r[y.negint.major]=fi,r[y.bytes.major]=Pr,r[y.string.major]=Hl,r[y.array.major]=di,r[y.map.major]=pi,r[y.tag.major]=gi,r[y.float.major]=mi,r}var E2=Gp(),B2=new li,wi=class r{constructor(t,e){this.obj=t,this.parent=e}includes(t){let e=this;do if(e.obj===t)return!0;while(e=e.parent);return!1}static createCheck(t,e){if(t&&t.includes(e))throw new Error(`${ya} object contains circular references`);return new r(e,t)}},ze={null:new _(y.null,null),undefined:new _(y.undefined,void 0),true:new _(y.true,!0),false:new _(y.false,!1),emptyArray:new _(y.array,0),emptyMap:new _(y.map,0)},je={number(r,t,e,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new _(y.float,r):r>=0?new _(y.uint,r):new _(y.negint,r)},bigint(r,t,e,n){return r>=BigInt(0)?new _(y.uint,r):new _(y.negint,r)},Uint8Array(r,t,e,n){return new _(y.bytes,r)},string(r,t,e,n){return new _(y.string,r)},boolean(r,t,e,n){return r?ze.true:ze.false},null(r,t,e,n){return ze.null},undefined(r,t,e,n){return ze.undefined},ArrayBuffer(r,t,e,n){return new _(y.bytes,new Uint8Array(r))},DataView(r,t,e,n){return new _(y.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,t,e,n){if(!r.length)return e.addBreakTokens===!0?[ze.emptyArray,new _(y.break)]:ze.emptyArray;n=wi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Ea(s,e,n);return e.addBreakTokens?[new _(y.array,r.length),o,new _(y.break)]:[new _(y.array,r.length),o]},Object(r,t,e,n){let o=t!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return e.addBreakTokens===!0?[ze.emptyMap,new _(y.break)]:ze.emptyMap;n=wi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[Ea(f,e,n),Ea(o?r.get(f):r[f],e,n)];return Zp(a,e),e.addBreakTokens?[new _(y.map,s),a,new _(y.break)]:[new _(y.map,s),a]}};je.Map=je.Object;je.Buffer=je.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))je[`${r}Array`]=je.DataView;function Ea(r,t={},e){let n=hl(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||je[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=je[n];if(!i)throw new Error(`${ya} unsupported type: ${n}`);return i(r,n,t,e)}function Zp(r,t){t.mapSorter&&r.sort(t.mapSorter)}var Wp={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},xi=class{constructor(t,e={}){this._pos=0,this.data=t,this.options=e}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],e=re[t];if(e===void 0){let n=k[t];if(!n)throw new Error(`${H} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;e=n(this.data,this._pos,o,this.options)}return this._pos+=e.encodedLength,e}},vn=Symbol.for("DONE"),bi=Symbol.for("BREAK");function Jp(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=Or(t,e);if(i===bi){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed array`)}if(i===vn)throw new Error(`${H} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Yp(r,t,e){let n=e.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=Or(t,e);if(a===bi){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed map`)}if(a===vn)throw new Error(`${H} found map but not enough entries (got ${s} [no key], expected ${r.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${H} non-string keys not supported (got ${typeof a})`);if(e.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${H} found repeat map key "${a}"`);let c=Or(t,e);if(c===vn)throw new Error(`${H} found map but not enough entries (got ${s} [no value], expected ${r.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Or(r,t){if(r.done())return vn;let e=r.next();if(e.type===y.break)return bi;if(e.type.terminal)return e.value;if(e.type===y.array)return Jp(e,r,t);if(e.type===y.map)return Yp(e,r,t);if(e.type===y.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=Or(r,t);return t.tags[e.value](n)}throw new Error(`${H} tag not supported (${e.value})`)}throw new Error("unsupported")}function gf(r,t){if(!(r instanceof Uint8Array))throw new Error(`${H} data to decode must be a Uint8Array`);t=Object.assign({},Wp,t);let e=t.tokenizer||new xi(r,t),n=Or(e,t);if(n===vn)throw new Error(`${H} did not find any content to decode`);if(n===bi)throw new Error(`${H} got unexpected break`);return[n,r.subarray(e.pos())]}function Ba(r,t){let[e,n]=gf(r,t);if(n.length>0)throw new Error(`${H} too many terminals, data makes no sense`);return e}var tg=Ue("ipns:utils"),mf=W("/ipns/");var eg=0,rg=18;function yf(r){let t;if(r.pubKey!=null)try{t=Wu(r.pubKey)}catch(e){throw tg.error(e),e}if(t!=null)return t}function wf(r){let t=W("ipns-signature:");return St([t,r])}function En(r){return"signatureV1"in r?te.encode({value:W(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:W(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):te.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function Ge(r){let t=te.decode(r);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Qt("Missing data or signatureV2");let e=xf(t.data),n=ng(e.Value),o=rt(e.Validity);if(t.value!=null&&t.signatureV1!=null)return og(t),{value:n,validityType:te.ValidityType.EOL,validity:o,sequence:e.Sequence,ttl:e.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:te.ValidityType.EOL,validity:o,sequence:e.Sequence,ttl:e.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function Bn(r){return St([mf,r.bytes])}function Mr(r){let t=pe(r.slice(mf.length));if(!vi(t,eg)&&!vi(t,rg))throw new ar("Multihash in IPNS key was not identity or sha2-256");return t}function xf(r){let t=Ba(r);if(t.ValidityType===0)t.ValidityType=te.ValidityType.EOL;else throw new Lr("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function ng(r){let t=rt(r).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${it.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${it.parse(t).toV1().toString()}`}catch{}throw new ai("Value must be a valid content path starting with /")}function og(r){if(r.data==null)throw new ci("Record data is missing");let t=xf(r.data);if(!ct(t.Value,r.value??new Uint8Array(0)))throw new Qt('Field "value" did not match between protobuf and CBOR');if(!ct(t.Validity,r.validity??new Uint8Array(0)))throw new Qt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==r.validityType)throw new Qt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==r.sequence)throw new Qt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==r.ttl)throw new Qt('Field "ttl" did not match between protobuf and CBOR')}function vi(r,t){return r.code===t}var G2=Ue("ipns"),Z2=60*60*1e9,sg="/ipns/",W2=sg.length;var bf=Nn(ma(),1);var Ei=Ue("ipns:validator"),ag=1024*10,cg=async(r,t)=>{let e=Ge(t),n;try{let o=wf(e.data);n=await r.verify(o,e.signatureV2)}catch{n=!1}if(!n)throw Ei.error("record signature verification failed"),new Qt("Record signature verification failed");if(e.validityType===te.ValidityType.EOL){if(bf.default.fromString(e.validity).toDate().getTime()<Date.now())throw Ei.error("record has expired"),new ii("record has expired")}else if(e.validityType!=null)throw Ei.error("the validity type is unsupported"),new Lr("The validity type is unsupported");Ei("ipns record for %s is valid",e.value)};async function vf(r,t){if(t.byteLength>ag)throw new si("The record is too large");let e=Mr(r),n;vi(e,0)&&(n=Zo(e));let o=Ge(t),i=yf(o)??n;if(i==null)throw new yn("Could not extract public key from IPNS record or routing key");let s=Bn(i.toMultihash());if(!ct(s,r))throw new yn("Embedded public key did not match routing key");await cg(i,t)}var Af=Symbol.for("@achingbrain/uint8arraylist");function Ef(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let o=e+n.byteLength;if(t<o)return{buf:n,index:t-e};e=o}throw new RangeError("index is out of bounds")}function Hr(r){return!!r?.[Af]}var Bf=class r{bufs;length;[Af]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(Hr(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(Hr(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Ef(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Ef(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(Hr(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:o}=this._subList(t,e);return St(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:St(n,o)}sublist(t,e){let{bufs:n,length:o}=this._subList(t,e),i=new r;return i.length=o,i.bufs=[...n],i}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let f=t>=a&&t<c,u=e>a&&e<=c;if(f&&u){if(t===a&&e===c){n.push(s);break}let l=t-a;n.push(s.subarray(l,l+(e-t)));break}if(f){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(e===c){n.push(s);break}n.push(s.subarray(0,e-a));break}n.push(s)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Hr(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let a=s,c=this.byteLength-n.byteLength,f=n.byteLength-1,u;for(let l=e;l<=c;l+=u){u=0;for(let h=f;h>=0;h--){let m=this.get(l+h);if(n[h]!==m){u=Math.max(1,h-a[m]);break}}if(u===0)return l}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=_t(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let o=be(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,e,n),this.write(o,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let o=be(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,e,n),this.write(o,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let o=be(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,e,n),this.write(o,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=_t(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let o=be(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,e,n),this.write(o,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let o=be(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,e,n),this.write(o,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let o=be(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,e,n),this.write(o,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let o=be(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,e,n),this.write(o,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let o=be(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,e,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!ct(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((o,i)=>o+i.byteLength,0)),n.length=e,n}};var Bi=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*An(r,t={}){let e=/\r?\n/,n=new TextDecoder("utf8"),o="";for await(let i of r){if(typeof i=="string"&&(i=new TextEncoder().encode(i)),Hr(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new Bi("Incoming message too long");let s=o.split(e);o=s.pop()??"";for(let a=0;a<s.length;a++)yield JSON.parse(s[a])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function fe(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Sa=Nn(If(),1);var In=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Ia=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},kf=r=>globalThis.DOMException===void 0?new Ia(r):new DOMException(r),Cf=r=>{let t=r.reason===void 0?kf("This operation was aborted."):r.reason;return t instanceof Error?t:kf(t)};function ka(r,t){let{milliseconds:e,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,f=new Promise((u,l)=>{if(typeof e!="number"||Math.sign(e)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(t.signal){let{signal:m}=t;m.aborted&&l(Cf(m)),a=()=>{l(Cf(m))},m.addEventListener("abort",a,{once:!0})}if(e===Number.POSITIVE_INFINITY){r.then(u,l);return}let h=new In;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(m){l(m)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?u():o instanceof Error?l(o):(h.message=o??`Promise timed out after ${e} milliseconds`,l(h))},e),(async()=>{try{u(await r)}catch(m){l(m)}})()}).finally(()=>{f.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return f.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},f}function Ca(r,t,e){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;e(r[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var kn=class{#t=[];enqueue(t,e){e={priority:0,...e};let n={priority:e.priority,id:e.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=e.priority){this.#t.push(n);return}let o=Ca(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}setPriority(t,e){let n=this.#t.findIndex(i=>i.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[o]=this.#t.splice(n,1);this.enqueue(o.run,{priority:e,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return this.#t.length}};var Cn=class extends Sa.default{#t;#r;#e=0;#a;#c;#p=0;#o;#u;#n;#g;#i=0;#l;#s;#m;#x=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:kn,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#r=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#c=t.interval,this.#n=new t.queueClass,this.#g=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#m=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#b(){return this.#r||this.#e<this.#a}get#v(){return this.#i<this.#l}#E(){this.#i--,this.#f(),this.emit("next")}#B(){this.#w(),this.#y(),this.#u=void 0}get#A(){let t=Date.now();if(this.#o===void 0){let e=this.#p-t;if(e<0)this.#e=this.#t?this.#i:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#B()},e)),!0}return!1}#f(){if(this.#n.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#i===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#A;if(this.#b&&this.#v){let e=this.#n.dequeue();return e?(this.emit("active"),e(),t&&this.#y(),!0):!1}}return!1}#y(){this.#r||this.#o!==void 0||(this.#o=setInterval(()=>{this.#w()},this.#c),this.#p=Date.now()+this.#c)}#w(){this.#e===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#e=this.#t?this.#i:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#l=t,this.#h()}async#S(t){return new Promise((e,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,e){this.#n.setPriority(t,e)}async add(t,e={}){return e.id??=(this.#x++).toString(),e={timeout:this.timeout,throwOnTimeout:this.#m,...e},new Promise((n,o)=>{this.#n.enqueue(async()=>{this.#i++,this.#e++;try{e.signal?.throwIfAborted();let i=t({signal:e.signal});e.timeout&&(i=ka(Promise.resolve(i),{milliseconds:e.timeout})),e.signal&&(i=Promise.race([i,this.#S(e.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof In&&!e.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#E()}},e),this.emit("add"),this.#f()})}async addAll(t,e){return Promise.all(t.map(async n=>this.add(n,e)))}start(){return this.#s?(this.#s=!1,this.#h(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#g}async onEmpty(){this.#n.size!==0&&await this.#d("empty")}async onSizeLessThan(t){this.#n.size<t||await this.#d("next",()=>this.#n.size<t)}async onIdle(){this.#i===0&&this.#n.size===0||await this.#d("idle")}async#d(t,e){return new Promise(n=>{let o=()=>{e&&!e()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#n.size}sizeBy(t){return this.#n.filter(t).length}get pending(){return this.#i}get isPaused(){return this.#s}};var $r=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},ne=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function fg(r){return r[Symbol.asyncIterator]!=null}function hg(r){if(fg(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var Tf=hg;function dg(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var Nf=dg;function pg(r){return r[Symbol.asyncIterator]!=null}function gg(r,t){let e=0;if(pg(r))return async function*(){for await(let c of r)yield t(c,e++)}();let n=Nf(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=t(o,e++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield t(c,e++)}();let a=t;return function*(){yield s;for(let c of n)yield a(c,e++)}()}var Uf=gg;var Rf=W("/ipns/");function Lf(r){return ct(r.subarray(0,Rf.byteLength),Rf)}var Si=class{client;constructor(t){this.client=t}async*findProviders(t,e={}){yield*Uf(this.client.getProviders(t,e),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,e,n){if(!Lf(t))return;let o=Mr(t),i=it.createV1(114,o),s=Ge(e);await this.client.putIPNS(i,s,n)}async get(t,e){if(!Lf(t))throw new ie("Not found");let n=Mr(t),o=it.createV1(114,n);try{let i=await this.client.getIPNS(o,e);return En(i)}catch(i){throw i.name==="BadResponseError"?new ie("Not found"):i}}},Ii=class{client;constructor(t){this.client=t}async findPeer(t,e={}){let n=await Tf(this.client.getPeers(t,e));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new ie("Not found")}async*getClosestPeers(t,e={}){}};var gt=Ue("delegated-routing-v1-http-api-client"),ki={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},Ci=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,e={}){this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new Cn({concurrency:e.concurrentRequests??ki.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=e.timeout??ki.timeout,this.filterAddrs=e.filterAddrs,this.filterProtocols=e.filterProtocols,this.contentRouting=new Si(this),this.peerRouting=new Ii(this),this.cacheName=e.cacheName??ki.cacheName,this.cacheTTL=e.cacheTTL??ki.cacheTTL}get[Fa](){return this.contentRouting}get[Da](){return this.peerRouting}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cacheTTL>0&&(this.cache=await globalThis.caches?.open(this.cacheName),this.cache!=null&&gt("cache enabled with ttl %d",this.cacheTTL)))}async stop(){this.httpQueue.clear(),this.shutDownController.abort(),await globalThis.caches?.delete(this.cacheName),this.started=!1}async*getProviders(t,e={}){gt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,e.signal]);let i=fe(),s=fe();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(a,e.filterAddrs,e.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#e(a.toString(),c);if(f==null)throw new ne("No response received");if(!f.ok)throw f.status===404?new ie("No matching records found"):f.status===422?new $r("Request does not conform to schema or semantic constraints"):new ne(`Unexpected status code: ${f.status}`);if(f.body==null)throw new ne("Routing response had no body");let u=f.headers.get("Content-Type");if(u==null)throw new ne("No Content-Type header received");if(u?.startsWith("application/json")){let l=await f.json();for(let h of l.Providers){let m=this.#t(h);m!=null&&(yield m)}}else if(u.includes("application/x-ndjson"))for await(let l of An(oi(f.body))){let h=this.#t(l);h!=null&&(yield h)}else throw new ne(`Unsupported Content-Type: ${u}`)}catch(a){gt.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),gt("getProviders finished: %c",t)}}async*getPeers(t,e={}){gt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,e.signal]);let i=fe(),s=fe();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(a,e.filterAddrs,e.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#e(a.toString(),c);if(f.status===404)throw new ie("No matching records found");if(f.status===422)throw new $r("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ne("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Peers){let m=this.#t(h);m!=null&&(yield m)}}else for await(let l of An(oi(f.body))){let h=this.#t(l);h!=null&&(yield h)}}catch(a){gt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),gt("getPeers finished: %c",t)}}async getIPNS(t,e={}){gt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=mn([this.shutDownController.signal,n,e.signal]);let i=fe(),s=fe();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},f=await this.#e(a,c);if(gt("getIPNS GET %s %d",a,f.status),f.status===404)throw new ie("No matching records found");if(f.status===422)throw new $r("Request does not conform to schema or semantic constraints");if(f.body==null)throw new ne("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return e.validate!==!1&&await vf(Bn(t.multihash),l),Ge(l)}catch(c){throw gt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),gt("getIPNS finished: %s",t)}}async putIPNS(t,e,n={}){gt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=mn([this.shutDownController.signal,o,n.signal]);let s=fe(),a=fe();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let f=En(e),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#e(c,u);if(gt("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new ne("PUT ipns response had status other than 200")}catch(f){throw gt.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),gt("putIPNS finished: %c",t)}}#t(t){try{let e=[],n=t.Addrs?.map(gn)??[];return t.Protocols!=null&&e.push(...t.Protocols),t.Protocol!=null&&(e.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:Yu(t.ID),Addrs:n,Protocols:e}}catch(e){gt.error("could not conform record to peer schema",e)}}#r(t,e,n){if(e!=null||this.filterAddrs!=null){let o=e?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,e){let n=e.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return gt("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return gt("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,e).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let f=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",f.toString());let l=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(t,l)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function mg(r,t={}){return new Ci(new URL(r),t)}return Gf(yg);})();
2
+ "use strict";var HeliaDelegatedRoutingV1HttpApiClient=(()=>{var nf=Object.create;var cn=Object.defineProperty;var of=Object.getOwnPropertyDescriptor;var sf=Object.getOwnPropertyNames;var af=Object.getPrototypeOf,cf=Object.prototype.hasOwnProperty;var As=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tt=(e,t)=>{for(var r in t)cn(e,r,{get:t[r],enumerable:!0})},Is=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of sf(t))!cf.call(e,o)&&o!==r&&cn(e,o,{get:()=>t[o],enumerable:!(n=of(t,o))||n.enumerable});return e};var go=(e,t,r)=>(r=e!=null?nf(af(e)):{},Is(t||!e||!e.__esModule?cn(r,"default",{value:e,enumerable:!0}):r,e)),uf=e=>Is(cn({},"__esModule",{value:!0}),e);var fs=As((Gw,us)=>{var jw=function(){typeof us<"u"&&(us.exports=x);var e=86400,t=3200,r=146097*t/400,n=e*r,o=1e3*n,i=864e13,s=4294967296,a=1e6,c="000000000",l=Math.trunc||function(g){var b=g-g%1;return b==0&&(g<0||g===0&&1/g!=1/0)?-0:b},u=x.prototype,f=(x.fromDate=function(g){return new x(+g)},x.fromInt64BE=P(0,1,2,3,0,4),x.fromInt64LE=P(3,2,1,0,4,0),x.fromString=function(k){var b,K=new x,k=(k+="").replace(/^\s*[+\-]?\d+/,function(V){var V=+V,v=1970+(V-1970)%400;return K.year=V-v,v}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(_,V,v){return V<0&&(v*=-1),b=6e4*(60*+V+ +v),""}).replace(/\.\d+$/,function(_){return K.nano=+(_+c).substr(1,9),""}).split(/\D+/);if(1<k.length?k[1]--:k[1]=0,K.time=b=Date.UTC.apply(Date,k)-(b||0),isNaN(b))throw new TypeError("Invalid Date");return h(K)},x.fromTimeT=function(g){return U(g,0)},u.year=0,u.time=0,u.nano=0,u.addNano=function(g){return this.nano+=+g||0,this},u.getNano=function(){var g=h(this);return(g.time%1e3*a+ +g.nano+1e9)%1e9},u.getTimeT=function(){var b=h(this),g=Math.floor(b.time/1e3),b=b.year;return b&&(g+=b*r*e/t),g},u.getYear=function(){return this.toDate().getUTCFullYear()+this.year},u.toDate=function(){return S(h(this).time)},u.toJSON=function(){return this.toString().replace(/0{1,6}Z$/,"Z")},u.toString=function(g){var b=this,K=b.toDate(),k={H:function(){return D(K.getUTCHours())},L:function(){return N(K.getUTCMilliseconds(),3)},M:function(){return D(K.getUTCMinutes())},N:function(){return N(b.getNano(),9)},S:function(){return D(K.getUTCSeconds())},Y:function(){var _=b.getYear();return 999999<_?"+"+_:9999<_?"+"+N(_,6):0<=_?N(_,4):-999999<=_?"-"+N(-_,6):_},a:function(){return w[K.getUTCDay()]},b:function(){return d[K.getUTCMonth()]},d:function(){return D(K.getUTCDate())},e:function(){return function(_){return(9<_?"":" ")+(0|_)}(K.getUTCDate())},m:function(){return D(K.getUTCMonth()+1)}};return function _(V){return V.replace(/%./g,function(v){var T=v[1],A=B[T],T=k[T];return A?_(A):T?T():v})}(g||f)},u.writeInt64BE=y(0,1,2,3,0,4),u.writeInt64LE=y(3,2,1,0,4,0),"%Y-%m-%dT%H:%M:%S.%NZ"),d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],w=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],B={"%":"%",F:"%Y-%m-%d",n:`
3
+ `,R:"%H:%M",T:"%H:%M:%S",t:" ",X:"%T",Z:"GMT",z:"+0000"};return x;function x(g,b,K){var k=this;if(!(k instanceof x))return new x(g,b,K);k.time=+g||0,k.nano=+b||0,k.year=+K||0,h(k)}function h(g){var b,K,k,_=g.year,V=g.time,v=g.nano,A=((v<0||a<=v)&&(v-=(K=Math.floor(v/a))*a,V+=K,K=1),_%t);return(V<-i||i<V||A)&&((b=l(V/o))&&(_+=b*t,V-=b*o),(k=S(V)).setUTCFullYear(A+k.getUTCFullYear()),k=(V=+k)+(b=l((_-=A)/t))*o,b&&-i<=k&&k<=i&&(_-=b*t,V=k),K=1),K&&(g.year=_,g.time=V,g.nano=v),g}function S(g){var b=new Date(0);return b.setTime(g),b}function U(_,k){_=+_||0;var K=l((k=(k|0)*s)/n)+l(_/n),k=k%n+_%n,_=l(k/n);return _&&(K+=_,k-=_*n),new x(1e3*k,0,K*t)}function y(g,b,K,k,_,V){return function(A,T){var p=h(this);A=A||new Array(8),O(A,T|=0);var I=Math.floor(p.time/1e3),p=p.year*(r*e/t),E=l(p/s)+l(I/s),p=p%s+I%s,I=Math.floor(p/s);return I&&(E+=I,p-=I*s),v(A,T+_,E),v(A,T+V,p),A};function v(A,T,E){A[T+g]=E>>24&255,A[T+b]=E>>16&255,A[T+K]=E>>8&255,A[T+k]=255&E}}function P(g,b,K,k,_,V){return function(A,T){O(A,T|=0);var E=v(A,T+_);return U(v(A,T+V),E)};function v(A,T){return 16777216*A[T+g]+(A[T+b]<<16|A[T+K]<<8|A[T+k])}}function O(g,b){if(g=g&&g.length,g==null)throw new TypeError("Invalid Buffer");if(g<b+8)throw new RangeError("Out of range")}function D(g){return(9<g?"":"0")+(0|g)}function N(g,b){return(c+(0|g)).substr(-b)}}()});var $u=As((O1,xs)=>{"use strict";var ep=Object.prototype.hasOwnProperty,At="~";function nn(){}Object.create&&(nn.prototype=Object.create(null),new nn().__proto__||(At=!1));function rp(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function zu(e,t,r,n,o){if(typeof r!="function")throw new TypeError("The listener must be a function");var i=new rp(r,n||e,o),s=At?At+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],i]:e._events[s].push(i):(e._events[s]=i,e._eventsCount++),e}function lo(e,t){--e._eventsCount===0?e._events=new nn:delete e._events[t]}function Et(){this._events=new nn,this._eventsCount=0}Et.prototype.eventNames=function(){var t=[],r,n;if(this._eventsCount===0)return t;for(n in r=this._events)ep.call(r,n)&&t.push(At?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(r)):t};Et.prototype.listeners=function(t){var r=At?At+t:t,n=this._events[r];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,i=n.length,s=new Array(i);o<i;o++)s[o]=n[o].fn;return s};Et.prototype.listenerCount=function(t){var r=At?At+t:t,n=this._events[r];return n?n.fn?1:n.length:0};Et.prototype.emit=function(t,r,n,o,i,s){var a=At?At+t:t;if(!this._events[a])return!1;var c=this._events[a],l=arguments.length,u,f;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,r),!0;case 3:return c.fn.call(c.context,r,n),!0;case 4:return c.fn.call(c.context,r,n,o),!0;case 5:return c.fn.call(c.context,r,n,o,i),!0;case 6:return c.fn.call(c.context,r,n,o,i,s),!0}for(f=1,u=new Array(l-1);f<l;f++)u[f-1]=arguments[f];c.fn.apply(c.context,u)}else{var d=c.length,w;for(f=0;f<d;f++)switch(c[f].once&&this.removeListener(t,c[f].fn,void 0,!0),l){case 1:c[f].fn.call(c[f].context);break;case 2:c[f].fn.call(c[f].context,r);break;case 3:c[f].fn.call(c[f].context,r,n);break;case 4:c[f].fn.call(c[f].context,r,n,o);break;default:if(!u)for(w=1,u=new Array(l-1);w<l;w++)u[w-1]=arguments[w];c[f].fn.apply(c[f].context,u)}}return!0};Et.prototype.on=function(t,r,n){return zu(this,t,r,n,!1)};Et.prototype.once=function(t,r,n){return zu(this,t,r,n,!0)};Et.prototype.removeListener=function(t,r,n,o){var i=At?At+t:t;if(!this._events[i])return this;if(!r)return lo(this,i),this;var s=this._events[i];if(s.fn)s.fn===r&&(!o||s.once)&&(!n||s.context===n)&&lo(this,i);else{for(var a=0,c=[],l=s.length;a<l;a++)(s[a].fn!==r||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:lo(this,i)}return this};Et.prototype.removeAllListeners=function(t){var r;return t?(r=At?At+t:t,this._events[r]&&lo(this,r)):(this._events=new nn,this._eventsCount=0),this};Et.prototype.off=Et.prototype.removeListener;Et.prototype.addListener=Et.prototype.on;Et.prefixed=At;Et.EventEmitter=Et;typeof xs<"u"&&(xs.exports=Et)});var up={};Tt(up,{createDelegatedRoutingV1HttpApiClient:()=>cp});var Ts=Symbol.for("@libp2p/content-routing");var xo=Symbol.for("@libp2p/peer-id");var Bs=Symbol.for("@libp2p/peer-routing");var ct=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},$e=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Jt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var un=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},je=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var Ge=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var vo={};Tt(vo,{base32:()=>qt,base32hex:()=>xf,base32hexpad:()=>bf,base32hexpadupper:()=>Ef,base32hexupper:()=>wf,base32pad:()=>yf,base32padupper:()=>gf,base32upper:()=>mf,base32z:()=>Sf});var mp=new Uint8Array(0);function Cs(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function oe(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function _s(e){return new TextEncoder().encode(e)}function Us(e){return new TextDecoder().decode(e)}function ff(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function f(B){if(B instanceof Uint8Array||(ArrayBuffer.isView(B)?B=new Uint8Array(B.buffer,B.byteOffset,B.byteLength):Array.isArray(B)&&(B=Uint8Array.from(B))),!(B instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(B.length===0)return"";for(var x=0,h=0,S=0,U=B.length;S!==U&&B[S]===0;)S++,x++;for(var y=(U-S)*u+1>>>0,P=new Uint8Array(y);S!==U;){for(var O=B[S],D=0,N=y-1;(O!==0||D<h)&&N!==-1;N--,D++)O+=256*P[N]>>>0,P[N]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");h=D,S++}for(var g=y-h;g!==y&&P[g]===0;)g++;for(var b=c.repeat(x);g<y;++g)b+=e.charAt(P[g]);return b}function d(B){if(typeof B!="string")throw new TypeError("Expected String");if(B.length===0)return new Uint8Array;var x=0;if(B[x]!==" "){for(var h=0,S=0;B[x]===c;)h++,x++;for(var U=(B.length-x)*l+1>>>0,y=new Uint8Array(U);B[x];){var P=r[B.charCodeAt(x)];if(P===255)return;for(var O=0,D=U-1;(P!==0||O<S)&&D!==-1;D--,O++)P+=a*y[D]>>>0,y[D]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");S=O,x++}if(B[x]!==" "){for(var N=U-S;N!==U&&y[N]===0;)N++;for(var g=new Uint8Array(h+(U-N)),b=h;N!==U;)g[b++]=y[N++];return g}}}function w(B){var x=d(B);if(x)return x;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:d,decode:w}}var lf=ff,df=lf,Ns=df;var wo=class{name;prefix;baseEncode;constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},bo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,r,n){this.name=t,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Ls(this,t)}},Eo=class{decoders;constructor(t){this.decoders=t}or(t){return Ls(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ls(e,t){return new Eo({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}var So=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,r,n,o){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new wo(t,r,n),this.decoder=new bo(t,r,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ze({name:e,prefix:t,encode:r,decode:n}){return new So(e,t,r,n)}function ge({name:e,prefix:t,alphabet:r}){let{encode:n,decode:o}=Ns(r,e);return Ze({prefix:t,name:e,encode:n,decode:i=>oe(o(i))})}function hf(e,t,r,n){let o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=e.length;for(;e[i-1]==="=";)--i;let s=new Uint8Array(i*r/8|0),a=0,c=0,l=0;for(let u=0;u<i;++u){let f=o[e[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,s[l++]=255&c>>a)}if(a>=r||(255&c<<8-a)!==0)throw new SyntaxError("Unexpected end of data");return s}function pf(e,t,r){let n=t[t.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],s+=8;s>r;)s-=r,i+=t[o&a>>s];if(s!==0&&(i+=t[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function ot({name:e,prefix:t,bitsPerChar:r,alphabet:n}){return Ze({prefix:t,name:e,encode(o){return pf(o,n,r)},decode(o){return hf(o,n,r,e)}})}var qt=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mf=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yf=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),gf=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xf=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wf=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bf=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ef=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Sf=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ao={};Tt(Ao,{base58btc:()=>X,base58flickr:()=>vf});var X=ge({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),vf=ge({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var To={};Tt(To,{base64:()=>Io,base64pad:()=>Af,base64url:()=>If,base64urlpad:()=>Tf});var Io=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Af=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),If=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Tf=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Bf(e,t){try{if(typeof e=="string"&&e.length>0)return Cf(e);if(typeof e=="number"&&isFinite(e))return t?.long?Uf(e):_f(e);throw new Error("Value is not a string or number.")}catch(r){let n=Pf(r)?`${r.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(n)}}function Cf(e){if(e=String(e),e.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return NaN;let r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*315576e5;case"weeks":case"week":case"w":return r*6048e5;case"days":case"day":case"d":return r*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return r*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return r*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return r*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var ln=Bf;function _f(e){let t=Math.abs(e);return t>=864e5?`${Math.round(e/864e5)}d`:t>=36e5?`${Math.round(e/36e5)}h`:t>=6e4?`${Math.round(e/6e4)}m`:t>=1e3?`${Math.round(e/1e3)}s`:`${e}ms`}function Uf(e){let t=Math.abs(e);return t>=864e5?fn(e,t,864e5,"day"):t>=36e5?fn(e,t,36e5,"hour"):t>=6e4?fn(e,t,6e4,"minute"):t>=1e3?fn(e,t,1e3,"second"):`${e} ms`}function fn(e,t,r,n){let o=t>=r*1.5;return`${Math.round(e/r)} ${n}${o?"s":""}`}function Pf(e){return typeof e=="object"&&e!==null&&"message"in e}function Bo(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=ln,r.destroy=l,Object.keys(e).forEach(u=>{r[u]=e[u]}),r.names=[],r.skips=[],r.formatters={};function t(u){let f=0;for(let d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=t;function r(u){let f,d=null,w,B;function x(...h){if(!x.enabled)return;let S=x,U=Number(new Date),y=U-(f||U);S.diff=y,S.prev=f,S.curr=U,f=U,h[0]=r.coerce(h[0]),typeof h[0]!="string"&&h.unshift("%O");let P=0;h[0]=h[0].replace(/%([a-zA-Z%])/g,(D,N)=>{if(D==="%%")return"%";P++;let g=r.formatters[N];if(typeof g=="function"){let b=h[P];D=g.call(S,b),h.splice(P,1),P--}return D}),r.formatArgs.call(S,h),(S.log||r.log).apply(S,h)}return x.namespace=u,x.useColors=r.useColors(),x.color=r.selectColor(u),x.extend=n,x.destroy=r.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(w!==r.namespaces&&(w=r.namespaces,B=r.enabled(u)),B),set:h=>{d=h}}),typeof r.init=="function"&&r.init(x),x}function n(u,f){let d=r(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f,d=(typeof u=="string"?u:"").split(/[\s,]+/),w=d.length;for(f=0;f<w;f++)d[f]&&(u=d[f].replace(/\*/g,".*?"),u[0]==="-"?r.skips.push(new RegExp("^"+u.substr(1)+"$")):r.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...r.names.map(a),...r.skips.map(a).map(f=>"-"+f)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let f,d;for(f=0,d=r.skips.length;f<d;f++)if(r.skips[f].test(u))return!1;for(f=0,d=r.names.length;f<d;f++)if(r.names[f].test(u))return!0;return!1}function a(u){return u.toString().substring(2,u.toString().length-2).replace(/\.\*\?$/,"*")}function c(u){return u instanceof Error?u.stack??u.message:u}function l(){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 r.setupFormatters(r.formatters),r.enable(r.load()),r}var dn=Of(),Nf=["#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 Lf(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/)!=null?!1:typeof document<"u"&&document.documentElement?.style?.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)!=null&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/)}function kf(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+ln(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}var Rf=console.debug??console.log??(()=>{});function Df(e){try{e?dn?.setItem("debug",e):dn?.removeItem("debug")}catch{}}function Kf(){let e;try{e=dn?.getItem("debug")}catch{}return!e&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(e=globalThis.process.env.DEBUG),e}function Of(){try{return localStorage}catch{}}function Ff(e){e.j=function(t){try{return JSON.stringify(t)}catch(r){return"[UnexpectedJSONParseError]: "+r.message}}}var ks=Bo({formatArgs:kf,save:Df,load:Kf,useColors:Lf,setupFormatters:Ff,colors:Nf,storage:dn,log:Rf});var Bt=ks;Bt.formatters.b=e=>e==null?"undefined":X.baseEncode(e);Bt.formatters.t=e=>e==null?"undefined":qt.baseEncode(e);Bt.formatters.m=e=>e==null?"undefined":Io.baseEncode(e);Bt.formatters.p=e=>e==null?"undefined":e.toString();Bt.formatters.c=e=>e==null?"undefined":e.toString();Bt.formatters.k=e=>e==null?"undefined":e.toString();Bt.formatters.a=e=>e==null?"undefined":e.toString();Bt.formatters.e=e=>e==null?"undefined":Rs(e.stack)??Rs(e.message)??e.toString();function Mf(e){let t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}function xe(e){let t=Mf(`${e}:trace`);return Bt.enabled(`${e}:trace`)&&Bt.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(t=Bt(`${e}:trace`)),Object.assign(Bt(e),{error:Bt(`${e}:error`),trace:t})}function Rs(e){if(e!=null&&(e=e.trim(),e.length!==0))return e}var Co={};Tt(Co,{base36:()=>We,base36upper:()=>Vf});var We=ge({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Vf=ge({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var qf=Os,Ds=128,Hf=127,zf=~Hf,$f=Math.pow(2,31);function Os(e,t,r){t=t||[],r=r||0;for(var n=r;e>=$f;)t[r++]=e&255|Ds,e/=128;for(;e&zf;)t[r++]=e&255|Ds,e>>>=7;return t[r]=e|0,Os.bytes=r-n+1,t}var jf=_o,Gf=128,Ks=127;function _o(e,n){var r=0,n=n||0,o=0,i=n,s,a=e.length;do{if(i>=a)throw _o.bytes=0,new RangeError("Could not decode varint");s=e[i++],r+=o<28?(s&Ks)<<o:(s&Ks)*Math.pow(2,o),o+=7}while(s>=Gf);return _o.bytes=i-n,r}var Zf=Math.pow(2,7),Wf=Math.pow(2,14),Yf=Math.pow(2,21),Xf=Math.pow(2,28),Jf=Math.pow(2,35),Qf=Math.pow(2,42),tl=Math.pow(2,49),el=Math.pow(2,56),rl=Math.pow(2,63),nl=function(e){return e<Zf?1:e<Wf?2:e<Yf?3:e<Xf?4:e<Jf?5:e<Qf?6:e<tl?7:e<el?8:e<rl?9:10},ol={encode:qf,decode:jf,encodingLength:nl},il=ol,Ir=il;function Tr(e,t=0){return[Ir.decode(e,t),Ir.decode.bytes]}function Ye(e,t,r=0){return Ir.encode(e,t,r),t}function Xe(e){return Ir.encodingLength(e)}function Ht(e,t){let r=t.byteLength,n=Xe(e),o=n+Xe(r),i=new Uint8Array(o+r);return Ye(e,i,0),Ye(r,i,n),i.set(t,o),new Je(e,r,t,i)}function ie(e){let t=oe(e),[r,n]=Tr(t),[o,i]=Tr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Je(r,o,s,t)}function Fs(e,t){if(e===t)return!0;{let r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&Cs(e.bytes,r.bytes)}}var Je=class{code;size;digest;bytes;constructor(t,r,n,o){this.code=t,this.size=r,this.digest=n,this.bytes=o}};function Ms(e,t){let{bytes:r,version:n}=e;switch(n){case 0:return al(r,Uo(e),t??X.encoder);default:return cl(r,Uo(e),t??qt.encoder)}}var Vs=new WeakMap;function Uo(e){let t=Vs.get(e);if(t==null){let r=new Map;return Vs.set(e,r),r}return t}var Q=class e{code;version;multihash;bytes;"/";constructor(t,r,n,o){this.code=r,this.version=t,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:t,multihash:r}=this;if(t!==Br)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==ul)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return e.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:r}=this.multihash,n=Ht(t,r);return e.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return e.equals(this,t)}static equals(t,r){let n=r;return n!=null&&t.code===n.code&&t.version===n.version&&Fs(t.multihash,n.multihash)}toString(t){return Ms(this,t)}toJSON(){return{"/":Ms(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let r=t;if(r instanceof e)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new e(n,o,i,s??qs(n,o,i.bytes))}else if(r[fl]===!0){let{version:n,multihash:o,code:i}=r,s=ie(o);return e.create(n,i,s)}else return null}static create(t,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(r!==Br)throw new Error(`Version 0 CID must use dag-pb (code: ${Br}) block encoding`);return new e(t,r,n,n.bytes)}case 1:{let o=qs(t,r,n.bytes);return new e(t,r,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return e.create(0,Br,t)}static createV1(t,r){return e.create(1,t,r)}static decode(t){let[r,n]=e.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(t){let r=e.inspectBytes(t),n=r.size-r.multihashSize,o=oe(t.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Je(r.multihashCode,r.digestSize,i,o);return[r.version===0?e.createV0(s):e.createV1(r.codec,s),t.subarray(r.size)]}static inspectBytes(t){let r=0,n=()=>{let[f,d]=Tr(t.subarray(r));return r+=d,f},o=n(),i=Br;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),l=r+c,u=l-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:l}}static parse(t,r){let[n,o]=sl(t,r),i=e.decode(o);if(i.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Uo(i).set(n,t),i}};function sl(e,t){switch(e[0]){case"Q":{let r=t??X;return[X.prefix,r.decode(`${X.prefix}${e}`)]}case X.prefix:{let r=t??X;return[X.prefix,r.decode(e)]}case qt.prefix:{let r=t??qt;return[qt.prefix,r.decode(e)]}case We.prefix:{let r=t??We;return[We.prefix,r.decode(e)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}}function al(e,t,r){let{prefix:n}=r;if(n!==X.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=t.get(n);if(o==null){let i=r.encode(e).slice(1);return t.set(n,i),i}else return o}function cl(e,t,r){let{prefix:n}=r,o=t.get(n);if(o==null){let i=r.encode(e);return t.set(n,i),i}else return o}var Br=112,ul=18;function qs(e,t,r){let n=Xe(e),o=n+Xe(t),i=new Uint8Array(o+r.byteLength);return Ye(e,i,0),Ye(t,i,n),i.set(r,o),i}var fl=Symbol.for("@ipld/js-cid/CID");var Po={};Tt(Po,{identity:()=>zt});var Hs=0,ll="identity",zs=oe;function dl(e){return Ht(Hs,zs(e))}var zt={code:Hs,name:ll,encode:zs,digest:dl};function rt(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}function se(e=0){return new Uint8Array(e)}function Ct(e=0){return new Uint8Array(e)}function xt(e,t){t==null&&(t=e.reduce((o,i)=>o+i.length,0));let r=Ct(t),n=0;for(let o of e)r.set(o,n),n+=o.length;return r}var js=Symbol.for("@achingbrain/uint8arraylist");function $s(e,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let r=0;for(let n of e){let o=r+n.byteLength;if(t<o)return{buf:n,index:t-r};r=o}throw new RangeError("index is out of bounds")}function Qe(e){return!!e?.[js]}var Nt=class e{bufs;length;[js]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let r=0;for(let n of t)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Qe(n))r+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...t){this.prependAll(t)}prependAll(t){let r=0;for(let n of t.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Qe(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(t){let r=$s(this.bufs,t);return r.buf[r.index]}set(t,r){let n=$s(this.bufs,t);n.buf[n.index]=r}write(t,r=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(r+n,t[n]);else if(Qe(t))for(let n=0;n<t.length;n++)this.set(r+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,r){let{bufs:n,length:o}=this._subList(t,r);return xt(n,o)}subarray(t,r){let{bufs:n,length:o}=this._subList(t,r);return n.length===1?n[0]:xt(n,o)}sublist(t,r){let{bufs:n,length:o}=this._subList(t,r),i=new e;return i.length=o,i.bufs=[...n],i}_subList(t,r){if(t=t??0,r=r??this.length,t<0&&(t=this.length+t),r<0&&(r=this.length+r),t<0||r>this.length)throw new RangeError("index is out of bounds");if(t===r)return{bufs:[],length:0};if(t===0&&r===this.length)return{bufs:this.bufs,length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,t>=c)continue;let l=t>=a&&t<c,u=r>a&&r<=c;if(l&&u){if(t===a&&r===c){n.push(s);break}let f=t-a;n.push(s.subarray(f,f+(r-t)));break}if(l){if(t===0){n.push(s);continue}n.push(s.subarray(t-a));continue}if(u){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-t}}indexOf(t,r=0){if(!Qe(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),t.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let f=0;f<i;f++)s[f]=-1;for(let f=0;f<o;f++)s[n[f]]=f;let a=s,c=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=r;f<=c;f+=u){u=0;for(let d=l;d>=0;d--){let w=this.get(f+d);if(n[d]!==w){u=Math.max(1,d-a[w]);break}}if(u===0)return f}return-1}getInt8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(t,r){let n=Ct(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,t)}getInt16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(t,r,n){let o=se(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,t)}getInt32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(t,r,n){let o=se(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,t)}getBigInt64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(t,r,n){let o=se(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,t)}getUint8(t){let r=this.subarray(t,t+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(t,r){let n=Ct(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,t)}getUint16(t,r){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(t,r,n){let o=se(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,t)}getUint32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(t,r,n){let o=se(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,t)}getBigUint64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(t,r,n){let o=se(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,t)}getFloat32(t,r){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(t,r,n){let o=se(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,t)}getFloat64(t,r){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(t,r,n){let o=se(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,t)}equals(t){if(t==null||!(t instanceof e)||t.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!rt(this.bufs[r],t.bufs[r]))return!1;return!0}static fromUint8Arrays(t,r){let n=new e;return n.bufs=t,r==null&&(r=t.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var No={};Tt(No,{base10:()=>hl});var hl=ge({prefix:"9",name:"base10",alphabet:"0123456789"});var Lo={};Tt(Lo,{base16:()=>pl,base16upper:()=>ml});var pl=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ml=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ko={};Tt(ko,{base2:()=>yl});var yl=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ro={};Tt(Ro,{base256emoji:()=>El});var Gs=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}"),gl=Gs.reduce((e,t,r)=>(e[r]=t,e),[]),xl=Gs.reduce((e,t,r)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return e[n]=r,e},[]);function wl(e){return e.reduce((t,r)=>(t+=gl[r],t),"")}function bl(e){let t=[];for(let r of e){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=xl[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);t.push(o)}return new Uint8Array(t)}var El=Ze({prefix:"\u{1F680}",name:"base256emoji",encode:wl,decode:bl});var Do={};Tt(Do,{base8:()=>Sl});var Sl=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ko={};Tt(Ko,{identity:()=>vl});var vl=Ze({prefix:"\0",name:"identity",encode:e=>Us(e),decode:e=>_s(e)});var l0=new TextEncoder,d0=new TextDecoder;var Mo={};Tt(Mo,{sha256:()=>Cr,sha512:()=>Tl});function Fo({name:e,code:t,encode:r}){return new Oo(e,t,r)}var Oo=class{name;code;encode;constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Ht(this.code,r):r.then(n=>Ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ws(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}var Cr=Fo({name:"sha2-256",code:18,encode:Ws("SHA-256")}),Tl=Fo({name:"sha2-512",code:19,encode:Ws("SHA-512")});var _r={...Ko,...ko,...Do,...No,...Lo,...vo,...Co,...Ao,...To,...Ro},A0={...Mo,...Po};function Xs(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var Ys=Xs("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Vo=Xs("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=Ct(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Bl={utf8:Ys,"utf-8":Ys,hex:_r.base16,latin1:Vo,ascii:Vo,binary:Vo,..._r},pn=Bl;function j(e,t="utf8"){let r=pn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function q(e,t="utf8"){let r=pn[t];if(r==null)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var Cl=parseInt("11111",2),qo=parseInt("10000000",2),_l=parseInt("01111111",2),Js={0:Ur,1:Ur,2:Ul,3:Ll,4:kl,5:Nl,6:Pl,16:Ur,22:Ur,48:Ur};function ae(e,t={offset:0}){let r=e[t.offset]&Cl;if(t.offset++,Js[r]!=null)return Js[r](e,t);throw new Error("No decoder for tag "+r)}function Pr(e,t){let r=0;if((e[t.offset]&qo)===qo){let n=e[t.offset]&_l,o="0x";t.offset++;for(let i=0;i<n;i++,t.offset++)o+=e[t.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=e[t.offset],t.offset++;return r}function Ur(e,t){Pr(e,t);let r=[];for(;!(t.offset>=e.byteLength);){let n=ae(e,t);if(n===null)break;r.push(n)}return r}function Ul(e,t){let r=Pr(e,t),n=t.offset,o=t.offset+r,i=[];for(let s=n;s<o;s++)s===n&&e[s]===0||i.push(e[s]);return t.offset+=r,Uint8Array.from(i)}function Pl(e,t){let r=Pr(e,t),n=t.offset+r,o=e[t.offset];t.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;t.offset<n;){let l=e[t.offset];if(t.offset++,c.push(l&127),l<128){c.reverse();let u=0;for(let f=0;f<c.length;f++)u+=c[f]<<f*7;a+=`.${u}`,c=[]}}return a}function Nl(e,t){return t.offset++,null}function Ll(e,t){let r=Pr(e,t),n=e[t.offset];t.offset++;let o=e.subarray(t.offset,t.offset+r-1);if(t.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function kl(e,t){let r=Pr(e,t),n=e.subarray(t.offset,t.offset+r);return t.offset+=r,n}function Rl(e){let t=e.toString(16);t.length%2===1&&(t="0"+t);let r=new Nt;for(let n=0;n<t.length;n+=2)r.append(Uint8Array.from([parseInt(`${t[n]}${t[n+1]}`,16)]));return r}function Ho(e){if(e.byteLength<128)return Uint8Array.from([e.byteLength]);let t=Rl(e.byteLength);return new Nt(Uint8Array.from([t.byteLength|qo]),t)}function _t(e){let t=new Nt,r=128;return(e.subarray()[0]&r)===r&&t.append(Uint8Array.from([0])),t.append(e),new Nt(Uint8Array.from([2]),Ho(t),t)}function mn(e){let t=Uint8Array.from([0]),r=new Nt(t,e);return new Nt(Uint8Array.from([3]),Ho(r),r)}function be(e,t=48){let r=new Nt;for(let n of e)r.append(n);return new Nt(Uint8Array.from([t]),Ho(r),r)}async function Qs(e,t,r){let n=await crypto.subtle.importKey("jwk",e,{name:"ECDSA",namedCurve:e.crv??"P-256"},!1,["verify"]);return crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},n,t,r.subarray())}var Dl=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),Kl=Uint8Array.from([6,5,43,129,4,0,34]),Ol=Uint8Array.from([6,5,43,129,4,0,35]),Fl={ext:!0,kty:"EC",crv:"P-256"},Ml={ext:!0,kty:"EC",crv:"P-384"},Vl={ext:!0,kty:"EC",crv:"P-521"},zo=32,$o=48,jo=66;function Go(e){let t=ae(e);return ta(t)}function ta(e){let t=e[1][1][0],r=1,n,o;if(t.byteLength===zo*2+1)return n=q(t.subarray(r,r+zo),"base64url"),o=q(t.subarray(r+zo),"base64url"),new tr({...Fl,key_ops:["verify"],x:n,y:o});if(t.byteLength===$o*2+1)return n=q(t.subarray(r,r+$o),"base64url"),o=q(t.subarray(r+$o),"base64url"),new tr({...Ml,key_ops:["verify"],x:n,y:o});if(t.byteLength===jo*2+1)return n=q(t.subarray(r,r+jo),"base64url"),o=q(t.subarray(r+jo),"base64url"),new tr({...Vl,key_ops:["verify"],x:n,y:o});throw new ct(`coordinates were wrong length, got ${t.byteLength}, expected 65, 97 or 133`)}function ea(e){return be([_t(Uint8Array.from([1])),be([ql(e.crv)],160),be([mn(new Nt(Uint8Array.from([4]),j(e.x??"","base64url"),j(e.y??"","base64url")))],161)]).subarray()}function ql(e){if(e==="P-256")return Dl;if(e==="P-384")return Kl;if(e==="P-521")return Ol;throw new ct(`Invalid curve ${e}`)}var tr=class{type="ECDSA";jwk;_raw;constructor(t){this.jwk=t}get raw(){return this._raw==null&&(this._raw=ea(this.jwk)),this._raw}toMultihash(){return zt.digest(er(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}async verify(t,r){return Qs(this.jwk,r,t)}};var Pe=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Hl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function yn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ne(e,...t){if(!Hl(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function ra(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");yn(e.outputLen),yn(e.blockLen)}function nr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function na(e,t){Ne(e);let r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}function ce(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function gn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function $t(e,t){return e<<32-t|e>>>t}function oa(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Nr(e){return typeof e=="string"&&(e=oa(e)),Ne(e),e}function Zo(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];Ne(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var rr=class{};function Wo(e){let t=n=>e().update(Nr(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function xn(e=32){if(Pe&&typeof Pe.getRandomValues=="function")return Pe.getRandomValues(new Uint8Array(e));if(Pe&&typeof Pe.randomBytes=="function")return Uint8Array.from(Pe.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function zl(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(r>>o&i),a=Number(r&i),c=n?4:0,l=n?0:4;e.setUint32(t+c,s,n),e.setUint32(t+l,a,n)}function ia(e,t,r){return e&t^~e&r}function sa(e,t,r){return e&t^e&r^t&r}var Lr=class extends rr{constructor(t,r,n,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=gn(this.buffer)}update(t){nr(this),t=Nr(t),Ne(t);let{view:r,buffer:n,blockLen:o}=this,i=t.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=gn(t);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(t.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){nr(this),na(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,ce(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let f=s;f<o;f++)r[f]=0;zl(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=gn(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return t.destroyed=s,t.finished=i,t.length=o,t.pos=a,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},ue=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var pt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var wn=BigInt(4294967295),aa=BigInt(32);function $l(e,t=!1){return t?{h:Number(e&wn),l:Number(e>>aa&wn)}:{h:Number(e>>aa&wn)|0,l:Number(e&wn)|0}}function ca(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let i=0;i<r;i++){let{h:s,l:a}=$l(e[i],t);[n[i],o[i]]=[s,a]}return[n,o]}var Yo=(e,t,r)=>e>>>r,Xo=(e,t,r)=>e<<32-r|t>>>r,Le=(e,t,r)=>e>>>r|t<<32-r,ke=(e,t,r)=>e<<32-r|t>>>r,kr=(e,t,r)=>e<<64-r|t>>>r-32,Rr=(e,t,r)=>e>>>r-32|t<<64-r;function Qt(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var ua=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),fa=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,la=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),da=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,ha=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),pa=(e,t,r,n,o,i)=>t+r+n+o+i+(e/2**32|0)|0;var Gl=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ee=new Uint32Array(64),bn=class extends Lr{constructor(t=32){super(64,t,8,!1),this.A=ue[0]|0,this.B=ue[1]|0,this.C=ue[2]|0,this.D=ue[3]|0,this.E=ue[4]|0,this.F=ue[5]|0,this.G=ue[6]|0,this.H=ue[7]|0}get(){let{A:t,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[t,r,n,o,i,s,a,c]}set(t,r,n,o,i,s,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}process(t,r){for(let f=0;f<16;f++,r+=4)Ee[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){let d=Ee[f-15],w=Ee[f-2],B=$t(d,7)^$t(d,18)^d>>>3,x=$t(w,17)^$t(w,19)^w>>>10;Ee[f]=x+Ee[f-7]+B+Ee[f-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){let d=$t(a,6)^$t(a,11)^$t(a,25),w=u+d+ia(a,c,l)+Gl[f]+Ee[f]|0,x=($t(n,2)^$t(n,13)^$t(n,22))+sa(n,o,i)|0;u=l,l=c,c=a,a=s+w|0,s=i,i=o,o=n,n=w+x|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,o,i,s,a,c,l,u)}roundClean(){ce(Ee)}destroy(){this.set(0,0,0,0,0,0,0,0),ce(this.buffer)}};var ma=ca(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Zl=ma[0],Wl=ma[1],Se=new Uint32Array(80),ve=new Uint32Array(80),Jo=class extends Lr{constructor(t=64){super(128,t,16,!1),this.Ah=pt[0]|0,this.Al=pt[1]|0,this.Bh=pt[2]|0,this.Bl=pt[3]|0,this.Ch=pt[4]|0,this.Cl=pt[5]|0,this.Dh=pt[6]|0,this.Dl=pt[7]|0,this.Eh=pt[8]|0,this.El=pt[9]|0,this.Fh=pt[10]|0,this.Fl=pt[11]|0,this.Gh=pt[12]|0,this.Gl=pt[13]|0,this.Hh=pt[14]|0,this.Hl=pt[15]|0}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:l,El:u,Fh:f,Fl:d,Gh:w,Gl:B,Hh:x,Hl:h}=this;return[t,r,n,o,i,s,a,c,l,u,f,d,w,B,x,h]}set(t,r,n,o,i,s,a,c,l,u,f,d,w,B,x,h){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=i|0,this.Cl=s|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=w|0,this.Gl=B|0,this.Hh=x|0,this.Hl=h|0}process(t,r){for(let y=0;y<16;y++,r+=4)Se[y]=t.getUint32(r),ve[y]=t.getUint32(r+=4);for(let y=16;y<80;y++){let P=Se[y-15]|0,O=ve[y-15]|0,D=Le(P,O,1)^Le(P,O,8)^Yo(P,O,7),N=ke(P,O,1)^ke(P,O,8)^Xo(P,O,7),g=Se[y-2]|0,b=ve[y-2]|0,K=Le(g,b,19)^kr(g,b,61)^Yo(g,b,6),k=ke(g,b,19)^Rr(g,b,61)^Xo(g,b,6),_=la(N,k,ve[y-7],ve[y-16]),V=da(_,D,K,Se[y-7],Se[y-16]);Se[y]=V|0,ve[y]=_|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:l,Dl:u,Eh:f,El:d,Fh:w,Fl:B,Gh:x,Gl:h,Hh:S,Hl:U}=this;for(let y=0;y<80;y++){let P=Le(f,d,14)^Le(f,d,18)^kr(f,d,41),O=ke(f,d,14)^ke(f,d,18)^Rr(f,d,41),D=f&w^~f&x,N=d&B^~d&h,g=ha(U,O,N,Wl[y],ve[y]),b=pa(g,S,P,D,Zl[y],Se[y]),K=g|0,k=Le(n,o,28)^kr(n,o,34)^kr(n,o,39),_=ke(n,o,28)^Rr(n,o,34)^Rr(n,o,39),V=n&i^n&a^i&a,v=o&s^o&c^s&c;S=x|0,U=h|0,x=w|0,h=B|0,w=f|0,B=d|0,{h:f,l:d}=Qt(l|0,u|0,b|0,K|0),l=a|0,u=c|0,a=i|0,c=s|0,i=n|0,s=o|0;let A=ua(K,_,v);n=fa(A,b,k,V),o=A|0}({h:n,l:o}=Qt(this.Ah|0,this.Al|0,n|0,o|0)),{h:i,l:s}=Qt(this.Bh|0,this.Bl|0,i|0,s|0),{h:a,l:c}=Qt(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=Qt(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:d}=Qt(this.Eh|0,this.El|0,f|0,d|0),{h:w,l:B}=Qt(this.Fh|0,this.Fl|0,w|0,B|0),{h:x,l:h}=Qt(this.Gh|0,this.Gl|0,x|0,h|0),{h:S,l:U}=Qt(this.Hh|0,this.Hl|0,S|0,U|0),this.set(n,o,i,s,a,c,l,u,f,d,w,B,x,h,S,U)}roundClean(){ce(Se,ve)}destroy(){ce(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var En=Wo(()=>new bn);var ya=Wo(()=>new Jo);var ri=BigInt(0),ei=BigInt(1);function Re(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ni(e){if(!Re(e))throw new Error("Uint8Array expected")}function te(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function Dr(e){let t=e.toString(16);return t.length&1?"0"+t:t}function wa(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ri:BigInt("0x"+e)}var ba=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Yl=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ae(e){if(ni(e),ba)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Yl[e[r]];return t}var fe={_0:48,_9:57,A:65,F:70,a:97,f:102};function ga(e){if(e>=fe._0&&e<=fe._9)return e-fe._0;if(e>=fe.A&&e<=fe.F)return e-(fe.A-10);if(e>=fe.a&&e<=fe.f)return e-(fe.a-10)}function Kr(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(ba)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=ga(e.charCodeAt(i)),a=ga(e.charCodeAt(i+1));if(s===void 0||a===void 0){let c=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function le(e){return wa(Ae(e))}function De(e){return ni(e),wa(Ae(Uint8Array.from(e).reverse()))}function Ke(e,t){return Kr(e.toString(16).padStart(t*2,"0"))}function or(e,t){return Ke(e,t).reverse()}function nt(e,t,r){let n;if(typeof t=="string")try{n=Kr(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(Re(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");let o=n.length;if(typeof r=="number"&&o!==r)throw new Error(e+" of length "+r+" expected, got "+o);return n}function Ie(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];ni(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}var Qo=e=>typeof e=="bigint"&&ri<=e;function Sn(e,t,r){return Qo(e)&&Qo(t)&&Qo(r)&&t<=e&&e<r}function Lt(e,t,r,n){if(!Sn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Ea(e){let t;for(t=0;e>ri;e>>=ei,t+=1);return t}var Oe=e=>(ei<<BigInt(e))-ei,ti=e=>new Uint8Array(e),xa=e=>Uint8Array.from(e);function Sa(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");let n=ti(e),o=ti(e),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...f)=>r(o,n,...f),c=(f=ti(0))=>{o=a(xa([0]),f),n=a(),f.length!==0&&(o=a(xa([1]),f),n=a())},l=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,d=[];for(;f<t;){n=a();let w=n.slice();d.push(w),f+=n.length}return Ie(...d)};return(f,d)=>{s(),c(f);let w;for(;!(w=d(l()));)c();return s(),w}}var Xl={bigint:e=>typeof e=="bigint",function:e=>typeof e=="function",boolean:e=>typeof e=="boolean",string:e=>typeof e=="string",stringOrUint8Array:e=>typeof e=="string"||Re(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>typeof e=="function"&&Number.isSafeInteger(e.outputLen)};function de(e,t,r={}){let n=(o,i,s)=>{let a=Xl[i];if(typeof a!="function")throw new Error("invalid validator function");let c=e[o];if(!(s&&c===void 0)&&!a(c,e))throw new Error("param "+String(o)+" is invalid. Expected "+i+", got "+c)};for(let[o,i]of Object.entries(t))n(o,i,!1);for(let[o,i]of Object.entries(r))n(o,i,!0);return e}function ir(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let i=e(r,...n);return t.set(r,i),i}}var St=BigInt(0),ut=BigInt(1),Fe=BigInt(2),Jl=BigInt(3),oi=BigInt(4),va=BigInt(5),Aa=BigInt(8),Ql=BigInt(9),td=BigInt(16);function J(e,t){let r=e%t;return r>=St?r:t+r}function et(e,t,r){let n=e;for(;t-- >St;)n*=n,n%=r;return n}function vn(e,t){if(e===St)throw new Error("invert: expected non-zero number");if(t<=St)throw new Error("invert: expected positive modulus, got "+t);let r=J(e,t),n=t,o=St,i=ut,s=ut,a=St;for(;r!==St;){let l=n/r,u=n%r,f=o-s*l,d=i-a*l;n=r,r=u,o=s,i=a,s=f,a=d}if(n!==ut)throw new Error("invert: does not exist");return J(o,t)}function ed(e){let t=e-ut,r=0;for(;t%Fe===St;)t/=Fe,r++;let n=Fe,o=he(e);for(;n<e&&Ia(o,n);)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1){let s=(e+ut)/oi;return function(c,l){let u=c.pow(l,s);if(!c.eql(c.sqr(u),l))throw new Error("Cannot find square root");return u}}let i=(t+ut)/Fe;return function(a,c){if(!Ia(a,c))throw new Error("Cannot find square root");let l=r,u=a.pow(a.mul(a.ONE,n),t),f=a.pow(c,i),d=a.pow(c,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let w=1;for(let x=a.sqr(d);w<l&&!a.eql(x,a.ONE);w++)x=a.sqr(x);let B=a.pow(u,ut<<BigInt(l-w-1));u=a.sqr(B),f=a.mul(f,B),d=a.mul(d,u),l=w}return f}}function rd(e){return e%oi===Jl?function(r,n){let o=(e+ut)/oi,i=r.pow(n,o);if(!r.eql(r.sqr(i),n))throw new Error("Cannot find square root");return i}:e%Aa===va?function(r,n){let o=r.mul(n,Fe),i=(e-va)/Aa,s=r.pow(o,i),a=r.mul(n,s),c=r.mul(r.mul(a,Fe),s),l=r.mul(a,r.sub(c,r.ONE));if(!r.eql(r.sqr(l),n))throw new Error("Cannot find square root");return l}:(e%td,ed(e))}var Ta=(e,t)=>(J(e,t)&ut)===ut,nd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ii(e){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},r=nd.reduce((n,o)=>(n[o]="function",n),t);return de(e,r)}function od(e,t,r){if(r<St)throw new Error("invalid exponent, negatives unsupported");if(r===St)return e.ONE;if(r===ut)return t;let n=e.ONE,o=t;for(;r>St;)r&ut&&(n=e.mul(n,o)),o=e.sqr(o),r>>=ut;return n}function sr(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((s,a,c)=>e.is0(a)?s:(n[c]=s,e.mul(s,a)),e.ONE),i=e.inv(o);return t.reduceRight((s,a,c)=>e.is0(a)?s:(n[c]=e.mul(s,n[c]),e.mul(s,a)),i),n}function id(e,t){let r=(e.ORDER-ut)/Fe,n=e.pow(t,r),o=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),s=e.eql(n,e.neg(e.ONE));if(!o&&!i&&!s)throw new Error("Cannot find square root: probably non-prime P");return o?1:i?0:-1}function Ia(e,t){let r=id(e,t);return r===0||r===1}function si(e,t){t!==void 0&&yn(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function he(e,t,r=!1,n={}){if(e<=St)throw new Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:o,nByteLength:i}=si(e,t);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:i,MASK:Oe(o),ZERO:St,ONE:ut,create:c=>J(c,e),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return St<=c&&c<e},is0:c=>c===St,isOdd:c=>(c&ut)===ut,neg:c=>J(-c,e),eql:(c,l)=>c===l,sqr:c=>J(c*c,e),add:(c,l)=>J(c+l,e),sub:(c,l)=>J(c-l,e),mul:(c,l)=>J(c*l,e),pow:(c,l)=>od(a,c,l),div:(c,l)=>J(c*vn(l,e),e),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>vn(c,e),sqrt:n.sqrt||(c=>(s||(s=rd(e)),s(a,c))),toBytes:c=>r?or(c,i):Ke(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return r?De(c):le(c)},invertBatch:c=>sr(a,c),cmov:(c,l,u)=>u?l:c});return Object.freeze(a)}function Ba(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function ai(e){let t=Ba(e);return t+Math.ceil(t/2)}function Ca(e,t,r=!1){let n=e.length,o=Ba(t),i=ai(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?De(e):le(e),a=J(s,t-ut)+ut;return r?or(a,o):Ke(a,o)}var _a=BigInt(0),di=BigInt(1);function ci(e,t){let r=t.negate();return e?r:t}function Pa(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ui(e,t){Pa(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,i=Oe(e),s=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Ua(e,t,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,a=Number(e&o),c=e>>s;a>n&&(a-=i,c+=di);let l=t*n,u=l+Math.abs(a)-1,f=a===0,d=a<0,w=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:d,isNegF:w,offsetF:l}}function sd(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function ad(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}var fi=new WeakMap,Na=new WeakMap;function li(e){return Na.get(e)||1}function An(e,t){return{constTimeNegate:ci,hasPrecomputes(r){return li(r)!==1},unsafeLadder(r,n,o=e.ZERO){let i=r;for(;n>_a;)n&di&&(o=o.add(i)),i=i.double(),n>>=di;return o},precomputeWindow(r,n){let{windows:o,windowSize:i}=ui(n,t),s=[],a=r,c=a;for(let l=0;l<o;l++){c=a,s.push(c);for(let u=1;u<i;u++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(r,n,o){let i=e.ZERO,s=e.BASE,a=ui(r,t);for(let c=0;c<a.windows;c++){let{nextN:l,offset:u,isZero:f,isNeg:d,isNegF:w,offsetF:B}=Ua(o,c,a);o=l,f?s=s.add(ci(w,n[B])):i=i.add(ci(d,n[u]))}return{p:i,f:s}},wNAFUnsafe(r,n,o,i=e.ZERO){let s=ui(r,t);for(let a=0;a<s.windows&&o!==_a;a++){let{nextN:c,offset:l,isZero:u,isNeg:f}=Ua(o,a,s);if(o=c,!u){let d=n[l];i=i.add(f?d.negate():d)}}return i},getPrecomputes(r,n,o){let i=fi.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&fi.set(n,o(i))),i},wNAFCached(r,n,o){let i=li(r);return this.wNAF(i,this.getPrecomputes(i,r,o),n)},wNAFCachedUnsafe(r,n,o,i){let s=li(r);return s===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,r,o),n,i)},setWindowSize(r,n){Pa(n,t),Na.set(r,n),fi.delete(r)}}}function In(e,t,r,n){if(sd(r,e),ad(n,t),r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=e.ZERO,i=Ea(BigInt(r.length)),s=i>12?i-3:i>4?i-2:i?2:1,a=Oe(s),c=new Array(Number(a)+1).fill(o),l=Math.floor((t.BITS-1)/s)*s,u=o;for(let f=l;f>=0;f-=s){c.fill(o);for(let w=0;w<n.length;w++){let B=n[w],x=Number(B>>BigInt(f)&a);c[x]=c[x].add(r[w])}let d=o;for(let w=c.length-1,B=o;w>0;w--)B=B.add(c[w]),d=d.add(B);if(u=u.add(d),f!==0)for(let w=0;w<s;w++)u=u.double()}return u}function Or(e){return ii(e.Fp),de(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...si(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}var ee=BigInt(0),vt=BigInt(1),La=BigInt(2),cd=BigInt(8),ud={zip215:!0};function fd(e){let t=Or(e);return de(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function ka(e){let t=fd(e),{Fp:r,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,l=La<<BigInt(a*8)-vt,u=r.create,f=he(t.n,t.nBitLength),d=t.uvRatio||((E,p)=>{try{return{isValid:!0,value:r.sqrt(E*r.inv(p))}}catch{return{isValid:!1,value:ee}}}),w=t.adjustScalarBytes||(E=>E),B=t.domain||((E,p,I)=>{if(te("phflag",I),p.length||I)throw new Error("Contexts/pre-hash are not supported");return E});function x(E,p,I=!1){let R=I?vt:ee;Lt("coordinate "+E,p,R,l)}function h(E){if(!(E instanceof y))throw new Error("ExtendedPoint expected")}let S=ir((E,p)=>{let{ex:I,ey:R,ez:F}=E,H=E.is0();p==null&&(p=H?cd:r.inv(F));let z=u(I*p),$=u(R*p),Z=u(F*p);if(H)return{x:ee,y:vt};if(Z!==vt)throw new Error("invZ was invalid");return{x:z,y:$}}),U=ir(E=>{let{a:p,d:I}=t;if(E.is0())throw new Error("bad point: ZERO");let{ex:R,ey:F,ez:H,et:z}=E,$=u(R*R),Z=u(F*F),Y=u(H*H),at=u(Y*Y),it=u($*p),ht=u(Y*u(it+Z)),It=u(at+u(I*u($*Z)));if(ht!==It)throw new Error("bad point: equation left != right (1)");let ft=u(R*F),gt=u(H*z);if(ft!==gt)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(p,I,R,F){x("x",p),x("y",I),x("z",R,!0),x("t",F),this.ex=p,this.ey=I,this.ez=R,this.et=F,Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof y)throw new Error("extended point not allowed");let{x:I,y:R}=p||{};return x("x",I),x("y",R),new y(I,R,vt,u(I*R))}static normalizeZ(p){let I=sr(r,p.map(R=>R.ez));return p.map((R,F)=>R.toAffine(I[F])).map(y.fromAffine)}static msm(p,I){return In(y,f,p,I)}_setWindowSize(p){D.setWindowSize(this,p)}assertValidity(){U(this)}equals(p){h(p);let{ex:I,ey:R,ez:F}=this,{ex:H,ey:z,ez:$}=p,Z=u(I*$),Y=u(H*F),at=u(R*$),it=u(z*F);return Z===Y&&at===it}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=t,{ex:I,ey:R,ez:F}=this,H=u(I*I),z=u(R*R),$=u(La*u(F*F)),Z=u(p*H),Y=I+R,at=u(u(Y*Y)-H-z),it=Z+z,ht=it-$,It=Z-z,ft=u(at*ht),gt=u(it*It),Pt=u(at*It),Vt=u(ht*it);return new y(ft,gt,Vt,Pt)}add(p){h(p);let{a:I,d:R}=t,{ex:F,ey:H,ez:z,et:$}=this,{ex:Z,ey:Y,ez:at,et:it}=p,ht=u(F*Z),It=u(H*Y),ft=u($*R*it),gt=u(z*at),Pt=u((F+H)*(Z+Y)-ht-It),Vt=gt-ft,Ar=gt+ft,vs=u(It-I*ht),Qu=u(Pt*Vt),tf=u(Ar*vs),ef=u(Pt*vs),rf=u(Vt*Ar);return new y(Qu,tf,rf,ef)}subtract(p){return this.add(p.negate())}wNAF(p){return D.wNAFCached(this,p,y.normalizeZ)}multiply(p){let I=p;Lt("scalar",I,vt,n);let{p:R,f:F}=this.wNAF(I);return y.normalizeZ([R,F])[0]}multiplyUnsafe(p,I=y.ZERO){let R=p;return Lt("scalar",R,ee,n),R===ee?O:this.is0()||R===vt?this:D.wNAFCachedUnsafe(this,R,y.normalizeZ,I)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return D.unsafeLadder(this,n).is0()}toAffine(p){return S(this,p)}clearCofactor(){let{h:p}=t;return p===vt?this:this.multiplyUnsafe(p)}static fromHex(p,I=!1){let{d:R,a:F}=t,H=r.BYTES;p=nt("pointHex",p,H),te("zip215",I);let z=p.slice(),$=p[H-1];z[H-1]=$&-129;let Z=De(z),Y=I?l:r.ORDER;Lt("pointHex.y",Z,ee,Y);let at=u(Z*Z),it=u(at-vt),ht=u(R*at-F),{isValid:It,value:ft}=d(it,ht);if(!It)throw new Error("Point.fromHex: invalid y coordinate");let gt=(ft&vt)===vt,Pt=($&128)!==0;if(!I&&ft===ee&&Pt)throw new Error("Point.fromHex: x=0 and x_0=1");return Pt!==gt&&(ft=u(-ft)),y.fromAffine({x:ft,y:Z})}static fromPrivateKey(p){let{scalar:I}=b(p);return P.multiply(I)}toRawBytes(){let{x:p,y:I}=this.toAffine(),R=or(I,r.BYTES);return R[R.length-1]|=p&vt?128:0,R}toHex(){return Ae(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,vt,u(t.Gx*t.Gy)),y.ZERO=new y(ee,vt,vt,ee);let{BASE:P,ZERO:O}=y,D=An(y,a*8);function N(E){return J(E,n)}function g(E){return N(De(E))}function b(E){let p=r.BYTES;E=nt("private key",E,p);let I=nt("hashed private key",i(E),2*p),R=w(I.slice(0,p)),F=I.slice(p,2*p),H=g(R);return{head:R,prefix:F,scalar:H}}function K(E){let{head:p,prefix:I,scalar:R}=b(E),F=P.multiply(R),H=F.toRawBytes();return{head:p,prefix:I,scalar:R,point:F,pointBytes:H}}function k(E){return K(E).pointBytes}function _(E=Uint8Array.of(),...p){let I=Ie(...p);return g(i(B(I,nt("context",E),!!o)))}function V(E,p,I={}){E=nt("message",E),o&&(E=o(E));let{prefix:R,scalar:F,pointBytes:H}=K(p),z=_(I.context,R,E),$=P.multiply(z).toRawBytes(),Z=_(I.context,$,H,E),Y=N(z+Z*F);Lt("signature.s",Y,ee,n);let at=Ie($,or(Y,r.BYTES));return nt("result",at,r.BYTES*2)}let v=ud;function A(E,p,I,R=v){let{context:F,zip215:H}=R,z=r.BYTES;E=nt("signature",E,2*z),p=nt("message",p),I=nt("publicKey",I,z),H!==void 0&&te("zip215",H),o&&(p=o(p));let $=De(E.slice(z,2*z)),Z,Y,at;try{Z=y.fromHex(I,H),Y=y.fromHex(E.slice(0,z),H),at=P.multiplyUnsafe($)}catch{return!1}if(!H&&Z.isSmallOrder())return!1;let it=_(F,Y.toRawBytes(),Z.toRawBytes(),p);return Y.add(Z.multiplyUnsafe(it)).subtract(at).clearCofactor().equals(y.ZERO)}return P._setWindowSize(8),{CURVE:t,getPublicKey:k,sign:V,verify:A,ExtendedPoint:y,utils:{getExtendedPublicKey:K,randomPrivateKey:()=>s(r.BYTES),precompute(E=8,p=y.BASE){return p._setWindowSize(E),p.multiply(BigInt(3)),p}}}}var hi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ra=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Bm=BigInt(0),ld=BigInt(1),Da=BigInt(2),Cm=BigInt(3),dd=BigInt(5),hd=BigInt(8);function pd(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),i=hi,a=e*e%i*e%i,c=et(a,Da,i)*a%i,l=et(c,ld,i)*e%i,u=et(l,dd,i)*l%i,f=et(u,t,i)*u%i,d=et(f,r,i)*f%i,w=et(d,n,i)*d%i,B=et(w,o,i)*w%i,x=et(B,o,i)*w%i,h=et(x,t,i)*u%i;return{pow_p_5_8:et(h,Da,i)*e%i,b2:a}}function md(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function yd(e,t){let r=hi,n=J(t*t*t,r),o=J(n*n*t,r),i=pd(e*o).pow_p_5_8,s=J(e*n*i,r),a=J(t*s*s,r),c=s,l=J(s*Ra,r),u=a===e,f=a===J(-e,r),d=a===J(-e*Ra,r);return u&&(s=c),(f||d)&&(s=l),Ta(s,r)&&(s=J(-s,r)),{isValid:u||f,value:s}}var Ka=he(hi,void 0,!0),gd={a:Ka.create(BigInt(-1)),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ka,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:hd,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:ya,randomBytes:xn,adjustScalarBytes:md,uvRatio:yd},Oa=ka(gd);var Tn=32;function Fa(e,t,r){return Oa.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}var Bn=class{type="Ed25519";raw;constructor(t){this.raw=pi(t,Tn)}toMultihash(){return zt.digest(er(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return Fa(this.raw,r,t)}};function mi(e){return e=pi(e,Tn),new Bn(e)}function pi(e,t){if(e=Uint8Array.from(e??[]),e.length!==t)throw new ct(`Key must be a Uint8Array of length ${t}, got ${e.length}`);return e}var wd=Math.pow(2,7),bd=Math.pow(2,14),Ed=Math.pow(2,21),yi=Math.pow(2,28),gi=Math.pow(2,35),xi=Math.pow(2,42),wi=Math.pow(2,49),W=128,wt=127;function Ut(e){if(e<wd)return 1;if(e<bd)return 2;if(e<Ed)return 3;if(e<yi)return 4;if(e<gi)return 5;if(e<xi)return 6;if(e<wi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function bi(e,t,r=0){switch(Ut(e)){case 8:t[r++]=e&255|W,e/=128;case 7:t[r++]=e&255|W,e/=128;case 6:t[r++]=e&255|W,e/=128;case 5:t[r++]=e&255|W,e/=128;case 4:t[r++]=e&255|W,e>>>=7;case 3:t[r++]=e&255|W,e>>>=7;case 2:t[r++]=e&255|W,e>>>=7;case 1:{t[r++]=e&255,e>>>=7;break}default:throw new Error("unreachable")}return t}function Sd(e,t,r=0){switch(Ut(e)){case 8:t.set(r++,e&255|W),e/=128;case 7:t.set(r++,e&255|W),e/=128;case 6:t.set(r++,e&255|W),e/=128;case 5:t.set(r++,e&255|W),e/=128;case 4:t.set(r++,e&255|W),e>>>=7;case 3:t.set(r++,e&255|W),e>>>=7;case 2:t.set(r++,e&255|W),e>>>=7;case 1:{t.set(r++,e&255),e>>>=7;break}default:throw new Error("unreachable")}return t}function Ei(e,t){let r=e[t],n=0;if(n+=r&wt,r<W||(r=e[t+1],n+=(r&wt)<<7,r<W)||(r=e[t+2],n+=(r&wt)<<14,r<W)||(r=e[t+3],n+=(r&wt)<<21,r<W)||(r=e[t+4],n+=(r&wt)*yi,r<W)||(r=e[t+5],n+=(r&wt)*gi,r<W)||(r=e[t+6],n+=(r&wt)*xi,r<W)||(r=e[t+7],n+=(r&wt)*wi,r<W))return n;throw new RangeError("Could not decode varint")}function vd(e,t){let r=e.get(t),n=0;if(n+=r&wt,r<W||(r=e.get(t+1),n+=(r&wt)<<7,r<W)||(r=e.get(t+2),n+=(r&wt)<<14,r<W)||(r=e.get(t+3),n+=(r&wt)<<21,r<W)||(r=e.get(t+4),n+=(r&wt)*yi,r<W)||(r=e.get(t+5),n+=(r&wt)*gi,r<W)||(r=e.get(t+6),n+=(r&wt)*xi,r<W)||(r=e.get(t+7),n+=(r&wt)*wi,r<W))return n;throw new RangeError("Could not decode varint")}function ar(e,t,r=0){return t==null&&(t=Ct(Ut(e))),t instanceof Uint8Array?bi(e,t,r):Sd(e,t,r)}function Me(e,t=0){return e instanceof Uint8Array?Ei(e,t):vd(e,t)}var Si=new Float32Array([-0]),Te=new Uint8Array(Si.buffer);function qa(e,t,r){Si[0]=e,t[r]=Te[0],t[r+1]=Te[1],t[r+2]=Te[2],t[r+3]=Te[3]}function Ha(e,t){return Te[0]=e[t],Te[1]=e[t+1],Te[2]=e[t+2],Te[3]=e[t+3],Si[0]}var vi=new Float64Array([-0]),bt=new Uint8Array(vi.buffer);function za(e,t,r){vi[0]=e,t[r]=bt[0],t[r+1]=bt[1],t[r+2]=bt[2],t[r+3]=bt[3],t[r+4]=bt[4],t[r+5]=bt[5],t[r+6]=bt[6],t[r+7]=bt[7]}function $a(e,t){return bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2],bt[3]=e[t+3],bt[4]=e[t+4],bt[5]=e[t+5],bt[6]=e[t+6],bt[7]=e[t+7],vi[0]}var Ad=BigInt(Number.MAX_SAFE_INTEGER),Id=BigInt(Number.MIN_SAFE_INTEGER),kt=class e{lo;hi;constructor(t,r){this.lo=t|0,this.hi=r|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?t<16384?t<128?1:2:t<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ve;if(t<Ad&&t>Id)return this.fromNumber(Number(t));let r=t<0n;r&&(t=-t);let n=t>>32n,o=t-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>ja&&(o=0n,++n>ja&&(n=0n))),new e(Number(o),Number(n))}static fromNumber(t){if(t===0)return Ve;let r=t<0;r&&(t=-t);let n=t>>>0,o=(t-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new e(n,o)}static from(t){return typeof t=="number"?e.fromNumber(t):typeof t=="bigint"?e.fromBigInt(t):typeof t=="string"?e.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new e(t.low>>>0,t.high>>>0):Ve}},Ve=new kt(0,0);Ve.toBigInt=function(){return 0n};Ve.zzEncode=Ve.zzDecode=function(){return this};Ve.length=function(){return 1};var ja=4294967296n;function Ga(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:(r&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Za(e,t,r){if(r-t<1)return"";let o,i=[],s=0,a;for(;t<r;)a=e[t++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|e[t++]&63:a>239&&a<365?(a=((a&7)<<18|(e[t++]&63)<<12|(e[t++]&63)<<6|e[t++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(e[t++]&63)<<6|e[t++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Ai(e,t,r){let n=r,o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&((i=e.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128);return r-n}function jt(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Cn(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}var Ii=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,jt(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 jt(this,4);return Cn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw jt(this,4);return Cn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw jt(this,4);let t=Ha(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw jt(this,4);let t=$a(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),r=this.pos,n=this.pos+t;if(n>this.len)throw jt(this,t);return this.pos+=t,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let t=this.bytes();return Za(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw jt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw jt(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new kt(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw jt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,t}if(this.len-this.pos>4){for(;r<5;++r)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;r<5;++r){if(this.pos>=this.len)throw jt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw jt(this,8);let t=Cn(this.buf,this.pos+=4),r=Cn(this.buf,this.pos+=4);return new kt(t,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=Ei(this.buf,this.pos);return this.pos+=Ut(t),t}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ti(e){return new Ii(e instanceof Uint8Array?e:e.subarray())}function cr(e,t,r){let n=Ti(e);return t.decode(n,void 0,r)}function Bi(e){let t=e??8192,r=t>>>1,n,o=t;return function(s){if(s<1||s>r)return Ct(s);o+s>t&&(n=Ct(t),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var qe=class{fn;len;next;val;constructor(t,r,n){this.fn=t,this.len=r,this.next=void 0,this.val=n}};function Ci(){}var Ui=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Td=Bi();function Bd(e){return globalThis.Buffer!=null?Ct(e):Td(e)}var Mr=class{len;head;tail;states;constructor(){this.len=0,this.head=new qe(Ci,0,0),this.tail=this.head,this.states=null}_push(t,r,n){return this.tail=this.tail.next=new qe(t,r,n),this.len+=r,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Pi((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(_n,10,kt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let r=kt.fromBigInt(t);return this._push(_n,r.length(),r)}uint64Number(t){return this._push(bi,Ut(t),t)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let r=kt.fromBigInt(t).zzEncode();return this._push(_n,r.length(),r)}sint64Number(t){let r=kt.fromNumber(t).zzEncode();return this._push(_n,r.length(),r)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(_i,1,t?1:0)}fixed32(t){return this._push(Fr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let r=kt.fromBigInt(t);return this._push(Fr,4,r.lo)._push(Fr,4,r.hi)}fixed64Number(t){let r=kt.fromNumber(t);return this._push(Fr,4,r.lo)._push(Fr,4,r.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(qa,4,t)}double(t){return this._push(za,8,t)}bytes(t){let r=t.length>>>0;return r===0?this._push(_i,1,0):this.uint32(r)._push(_d,r,t)}string(t){let r=Ga(t);return r!==0?this.uint32(r)._push(Ai,r,t):this._push(_i,1,0)}fork(){return this.states=new Ui(this),this.head=this.tail=new qe(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 qe(Ci,0,0),this.len=0),this}ldelim(){let t=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=r,this.len+=n),this}finish(){let t=this.head.next,r=Bd(this.len),n=0;for(;t!=null;)t.fn(t.val,r,n),n+=t.len,t=t.next;return r}};function _i(e,t,r){t[r]=e&255}function Cd(e,t,r){for(;e>127;)t[r++]=e&127|128,e>>>=7;t[r]=e}var Pi=class extends qe{next;constructor(t,r){super(Cd,t,r),this.next=void 0}};function _n(e,t,r){for(;e.hi!==0;)t[r++]=e.lo&127|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=e.lo&127|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Fr(e,t,r){t[r]=e&255,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function _d(e,t,r){t.set(e,r)}globalThis.Buffer!=null&&(Mr.prototype.bytes=function(e){let t=e.length>>>0;return this.uint32(t),t>0&&this._push(Ud,t,e),this},Mr.prototype.string=function(e){let t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Pd,t,e),this});function Ud(e,t,r){t.set(e,r)}function Pd(e,t,r){e.length<40?Ai(e,t,r):t.utf8Write!=null?t.utf8Write(e,r):t.set(j(e),r)}function Ni(){return new Mr}function ur(e,t){let r=Ni();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var fr;(function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"})(fr||(fr={}));function Un(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Vr(e){function t(o){if(e[o.toString()]==null)throw new Error("Invalid enum value");return e[o]}let r=function(i,s){let a=t(i);s.int32(a)},n=function(i){let s=i.int32();return t(s)};return Un("enum",fr.VARINT,r,n)}function lr(e,t){return Un("message",fr.LENGTH_DELIMITED,e,t)}var st;(function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.secp256k1="secp256k1",e.ECDSA="ECDSA"})(st||(st={}));var Li;(function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.secp256k1=2]="secp256k1",e[e.ECDSA=3]="ECDSA"})(Li||(Li={}));(function(e){e.codec=()=>Vr(Li)})(st||(st={}));var re;(function(e){let t;e.codec=()=>(t==null&&(t=lr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),st.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=st.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>ur(r,e.codec()),e.decode=(r,n)=>cr(r,e.codec(),n)})(re||(re={}));var ki;(function(e){let t;e.codec=()=>(t==null&&(t=lr((r,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),r.Type!=null&&(n.uint32(8),st.codec().encode(r.Type,n)),r.Data!=null&&(n.uint32(18),n.bytes(r.Data)),o.lengthDelimited!==!1&&n.ldelim()},(r,n,o={})=>{let i={},s=n==null?r.len:r.pos+n;for(;r.pos<s;){let a=r.uint32();switch(a>>>3){case 1:{i.Type=st.codec().decode(r);break}case 2:{i.Data=r.bytes();break}default:{r.skipType(a&7);break}}}return i})),t),e.encode=r=>ur(r,e.codec()),e.decode=(r,n)=>cr(r,e.codec(),n)})(ki||(ki={}));var qr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Pn=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Xa={get(e=globalThis){let t=e.crypto;if(t?.subtle==null)throw new Pn("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api");return t}};var Be=Xa;var zr={};Tt(zr,{MAX_RSA_KEY_SIZE:()=>Ri,generateRSAKeyPair:()=>ec,jwkToJWKKeyPair:()=>rc,jwkToPkcs1:()=>Rd,jwkToPkix:()=>Fi,jwkToRSAPrivateKey:()=>Hi,pkcs1MessageToJwk:()=>Ki,pkcs1MessageToRSAPrivateKey:()=>Mi,pkcs1ToJwk:()=>kd,pkcs1ToRSAPrivateKey:()=>tc,pkixMessageToJwk:()=>Oi,pkixMessageToRSAPublicKey:()=>qi,pkixToJwk:()=>Dd,pkixToRSAPublicKey:()=>Vi});var Nn=En;var dr=class{type="RSA";jwk;_raw;_multihash;constructor(t,r){this.jwk=t,this._multihash=r}get raw(){return this._raw==null&&(this._raw=zr.jwkToPkix(this.jwk)),this._raw}toMultihash(){return this._multihash}toCID(){return Q.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return Qa(this.jwk,r,t)}},Hr=class{type="RSA";jwk;_raw;publicKey;constructor(t,r){this.jwk=t,this.publicKey=r}get raw(){return this._raw==null&&(this._raw=zr.jwkToPkcs1(this.jwk)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}sign(t){return Ja(this.jwk,t)}};var Ri=8192,Di=18,Nd=1062,Ld=Uint8Array.from([48,13,6,9,42,134,72,134,247,13,1,1,1,5,0]);function kd(e){let t=ae(e);return Ki(t)}function Ki(e){return{n:q(e[1],"base64url"),e:q(e[2],"base64url"),d:q(e[3],"base64url"),p:q(e[4],"base64url"),q:q(e[5],"base64url"),dp:q(e[6],"base64url"),dq:q(e[7],"base64url"),qi:q(e[8],"base64url"),kty:"RSA"}}function Rd(e){if(e.n==null||e.e==null||e.d==null||e.p==null||e.q==null||e.dp==null||e.dq==null||e.qi==null)throw new ct("JWK was missing components");return be([_t(Uint8Array.from([0])),_t(j(e.n,"base64url")),_t(j(e.e,"base64url")),_t(j(e.d,"base64url")),_t(j(e.p,"base64url")),_t(j(e.q,"base64url")),_t(j(e.dp,"base64url")),_t(j(e.dq,"base64url")),_t(j(e.qi,"base64url"))]).subarray()}function Dd(e){let t=ae(e,{offset:0});return Oi(t)}function Oi(e){let t=ae(e[1],{offset:0});return{kty:"RSA",n:q(t[0],"base64url"),e:q(t[1],"base64url")}}function Fi(e){if(e.n==null||e.e==null)throw new ct("JWK was missing components");return be([Ld,mn(be([_t(j(e.n,"base64url")),_t(j(e.e,"base64url"))]))]).subarray()}function tc(e){let t=ae(e);return Mi(t)}function Mi(e){let t=Ki(e);return Hi(t)}function Vi(e,t){if(e.byteLength>=Nd)throw new $e("Key size is too large");let r=ae(e,{offset:0});return qi(r,e,t)}function qi(e,t,r){let n=Oi(e);if(r==null){let o=Nn(re.encode({Type:st.RSA,Data:t}));r=Ht(Di,o)}return new dr(n,r)}function Hi(e){if(oc(e)>Ri)throw new ct("Key size is too large");let t=rc(e),r=Nn(re.encode({Type:st.RSA,Data:Fi(t.publicKey)})),n=Ht(Di,r);return new Hr(t.privateKey,new dr(t.publicKey,n))}async function ec(e){if(e>Ri)throw new ct("Key size is too large");let t=await nc(e),r=Nn(re.encode({Type:st.RSA,Data:Fi(t.publicKey)})),n=Ht(Di,r);return new Hr(t.privateKey,new dr(t.publicKey,n))}function rc(e){if(e==null)throw new ct("Missing key parameter");return{privateKey:e,publicKey:{kty:e.kty,n:e.n,e:e.e}}}async function nc(e){let t=await Be.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await Kd(t);return{privateKey:r[0],publicKey:r[1]}}async function Ja(e,t){let r=await Be.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Be.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Qa(e,t,r){let n=await Be.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Be.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}async function Kd(e){if(e.privateKey==null||e.publicKey==null)throw new ct("Private and public key are required");return Promise.all([Be.get().subtle.exportKey("jwk",e.privateKey),Be.get().subtle.exportKey("jwk",e.publicKey)])}function oc(e){if(e.kty!=="RSA")throw new ct("invalid key type");if(e.n==null)throw new ct("invalid key modulus");return j(e.n,"base64url").length*8}var Ln=class extends rr{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,ra(t);let n=Nr(r);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?t.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=t.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),ce(i)}update(t){return nr(this),this.iHash.update(t),this}digestInto(t){nr(this),Ne(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return t=t,t.finished=o,t.destroyed=i,t.blockLen=s,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},zi=(e,t,r)=>new Ln(e,t).update(r).digest();zi.create=(e,t)=>new Ln(e,t);function ic(e){e.lowS!==void 0&&te("lowS",e.lowS),e.prehash!==void 0&&te("prehash",e.prehash)}function Od(e){let t=Or(e);de(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:r,Fp:n,a:o}=t;if(r){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof r!="object"||typeof r.beta!="bigint"||typeof r.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var $i=class extends Error{constructor(t=""){super(t)}},pe={Err:$i,_tlv:{encode:(e,t)=>{let{Err:r}=pe;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Dr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Dr(o.length/2|128):"";return Dr(e)+i+o+t},decode(e,t){let{Err:r}=pe,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let u of l)s=s<<8|u;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=t.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+s)}}},_int:{encode(e){let{Err:t}=pe;if(e<me)throw new t("integer: negative integers are not allowed");let r=Dr(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=pe;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return le(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=pe,o=nt("signature",e),{v:i,l:s}=n.decode(48,o);if(s.length)throw new t("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=pe,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),i=n+o;return t.encode(48,i)}},me=BigInt(0),lt=BigInt(1),ng=BigInt(2),sc=BigInt(3),og=BigInt(4);function Fd(e){let t=Od(e),{Fp:r}=t,n=he(t.n,t.nBitLength),o=t.toBytes||((x,h,S)=>{let U=h.toAffine();return Ie(Uint8Array.from([4]),r.toBytes(U.x),r.toBytes(U.y))}),i=t.fromBytes||(x=>{let h=x.subarray(1),S=r.fromBytes(h.subarray(0,r.BYTES)),U=r.fromBytes(h.subarray(r.BYTES,2*r.BYTES));return{x:S,y:U}});function s(x){let{a:h,b:S}=t,U=r.sqr(x),y=r.mul(U,x);return r.add(r.add(y,r.mul(x,h)),S)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(x){return Sn(x,lt,t.n)}function c(x){let{allowedPrivateKeyLengths:h,nByteLength:S,wrapPrivateKey:U,n:y}=t;if(h&&typeof x!="bigint"){if(Re(x)&&(x=Ae(x)),typeof x!="string"||!h.includes(x.length))throw new Error("invalid private key");x=x.padStart(S*2,"0")}let P;try{P=typeof x=="bigint"?x:le(nt("private key",x,S))}catch{throw new Error("invalid private key, expected hex or "+S+" bytes, got "+typeof x)}return U&&(P=J(P,y)),Lt("private key",P,lt,y),P}function l(x){if(!(x instanceof d))throw new Error("ProjectivePoint expected")}let u=ir((x,h)=>{let{px:S,py:U,pz:y}=x;if(r.eql(y,r.ONE))return{x:S,y:U};let P=x.is0();h==null&&(h=P?r.ONE:r.inv(y));let O=r.mul(S,h),D=r.mul(U,h),N=r.mul(y,h);if(P)return{x:r.ZERO,y:r.ZERO};if(!r.eql(N,r.ONE))throw new Error("invZ was invalid");return{x:O,y:D}}),f=ir(x=>{if(x.is0()){if(t.allowInfinityPoint&&!r.is0(x.py))return;throw new Error("bad point: ZERO")}let{x:h,y:S}=x.toAffine();if(!r.isValid(h)||!r.isValid(S))throw new Error("bad point: x or y not FE");let U=r.sqr(S),y=s(h);if(!r.eql(U,y))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class d{constructor(h,S,U){if(h==null||!r.isValid(h))throw new Error("x required");if(S==null||!r.isValid(S)||r.is0(S))throw new Error("y required");if(U==null||!r.isValid(U))throw new Error("z required");this.px=h,this.py=S,this.pz=U,Object.freeze(this)}static fromAffine(h){let{x:S,y:U}=h||{};if(!h||!r.isValid(S)||!r.isValid(U))throw new Error("invalid affine point");if(h instanceof d)throw new Error("projective point not allowed");let y=P=>r.eql(P,r.ZERO);return y(S)&&y(U)?d.ZERO:new d(S,U,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(h){let S=sr(r,h.map(U=>U.pz));return h.map((U,y)=>U.toAffine(S[y])).map(d.fromAffine)}static fromHex(h){let S=d.fromAffine(i(nt("pointHex",h)));return S.assertValidity(),S}static fromPrivateKey(h){return d.BASE.multiply(c(h))}static msm(h,S){return In(d,n,h,S)}_setWindowSize(h){B.setWindowSize(this,h)}assertValidity(){f(this)}hasEvenY(){let{y:h}=this.toAffine();if(r.isOdd)return!r.isOdd(h);throw new Error("Field doesn't support isOdd")}equals(h){l(h);let{px:S,py:U,pz:y}=this,{px:P,py:O,pz:D}=h,N=r.eql(r.mul(S,D),r.mul(P,y)),g=r.eql(r.mul(U,D),r.mul(O,y));return N&&g}negate(){return new d(this.px,r.neg(this.py),this.pz)}double(){let{a:h,b:S}=t,U=r.mul(S,sc),{px:y,py:P,pz:O}=this,D=r.ZERO,N=r.ZERO,g=r.ZERO,b=r.mul(y,y),K=r.mul(P,P),k=r.mul(O,O),_=r.mul(y,P);return _=r.add(_,_),g=r.mul(y,O),g=r.add(g,g),D=r.mul(h,g),N=r.mul(U,k),N=r.add(D,N),D=r.sub(K,N),N=r.add(K,N),N=r.mul(D,N),D=r.mul(_,D),g=r.mul(U,g),k=r.mul(h,k),_=r.sub(b,k),_=r.mul(h,_),_=r.add(_,g),g=r.add(b,b),b=r.add(g,b),b=r.add(b,k),b=r.mul(b,_),N=r.add(N,b),k=r.mul(P,O),k=r.add(k,k),b=r.mul(k,_),D=r.sub(D,b),g=r.mul(k,K),g=r.add(g,g),g=r.add(g,g),new d(D,N,g)}add(h){l(h);let{px:S,py:U,pz:y}=this,{px:P,py:O,pz:D}=h,N=r.ZERO,g=r.ZERO,b=r.ZERO,K=t.a,k=r.mul(t.b,sc),_=r.mul(S,P),V=r.mul(U,O),v=r.mul(y,D),A=r.add(S,U),T=r.add(P,O);A=r.mul(A,T),T=r.add(_,V),A=r.sub(A,T),T=r.add(S,y);let E=r.add(P,D);return T=r.mul(T,E),E=r.add(_,v),T=r.sub(T,E),E=r.add(U,y),N=r.add(O,D),E=r.mul(E,N),N=r.add(V,v),E=r.sub(E,N),b=r.mul(K,T),N=r.mul(k,v),b=r.add(N,b),N=r.sub(V,b),b=r.add(V,b),g=r.mul(N,b),V=r.add(_,_),V=r.add(V,_),v=r.mul(K,v),T=r.mul(k,T),V=r.add(V,v),v=r.sub(_,v),v=r.mul(K,v),T=r.add(T,v),_=r.mul(V,T),g=r.add(g,_),_=r.mul(E,T),N=r.mul(A,N),N=r.sub(N,_),_=r.mul(A,V),b=r.mul(E,b),b=r.add(b,_),new d(N,g,b)}subtract(h){return this.add(h.negate())}is0(){return this.equals(d.ZERO)}wNAF(h){return B.wNAFCached(this,h,d.normalizeZ)}multiplyUnsafe(h){let{endo:S,n:U}=t;Lt("scalar",h,me,U);let y=d.ZERO;if(h===me)return y;if(this.is0()||h===lt)return this;if(!S||B.hasPrecomputes(this))return B.wNAFCachedUnsafe(this,h,d.normalizeZ);let{k1neg:P,k1:O,k2neg:D,k2:N}=S.splitScalar(h),g=y,b=y,K=this;for(;O>me||N>me;)O&lt&&(g=g.add(K)),N&lt&&(b=b.add(K)),K=K.double(),O>>=lt,N>>=lt;return P&&(g=g.negate()),D&&(b=b.negate()),b=new d(r.mul(b.px,S.beta),b.py,b.pz),g.add(b)}multiply(h){let{endo:S,n:U}=t;Lt("scalar",h,lt,U);let y,P;if(S){let{k1neg:O,k1:D,k2neg:N,k2:g}=S.splitScalar(h),{p:b,f:K}=this.wNAF(D),{p:k,f:_}=this.wNAF(g);b=B.constTimeNegate(O,b),k=B.constTimeNegate(N,k),k=new d(r.mul(k.px,S.beta),k.py,k.pz),y=b.add(k),P=K.add(_)}else{let{p:O,f:D}=this.wNAF(h);y=O,P=D}return d.normalizeZ([y,P])[0]}multiplyAndAddUnsafe(h,S,U){let y=d.BASE,P=(D,N)=>N===me||N===lt||!D.equals(y)?D.multiplyUnsafe(N):D.multiply(N),O=P(this,S).add(P(h,U));return O.is0()?void 0:O}toAffine(h){return u(this,h)}isTorsionFree(){let{h,isTorsionFree:S}=t;if(h===lt)return!0;if(S)return S(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h,clearCofactor:S}=t;return h===lt?this:S?S(d,this):this.multiplyUnsafe(t.h)}toRawBytes(h=!0){return te("isCompressed",h),this.assertValidity(),o(d,this,h)}toHex(h=!0){return te("isCompressed",h),Ae(this.toRawBytes(h))}}d.BASE=new d(t.Gx,t.Gy,r.ONE),d.ZERO=new d(r.ZERO,r.ONE,r.ZERO);let w=t.nBitLength,B=An(d,t.endo?Math.ceil(w/2):w);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function Md(e){let t=Or(e);return de(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ac(e){let t=Md(e),{Fp:r,n}=t,o=r.BYTES+1,i=2*r.BYTES+1;function s(v){return J(v,n)}function a(v){return vn(v,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=Fd({...t,toBytes(v,A,T){let E=A.toAffine(),p=r.toBytes(E.x),I=Ie;return te("isCompressed",T),T?I(Uint8Array.from([A.hasEvenY()?2:3]),p):I(Uint8Array.from([4]),p,r.toBytes(E.y))},fromBytes(v){let A=v.length,T=v[0],E=v.subarray(1);if(A===o&&(T===2||T===3)){let p=le(E);if(!Sn(p,lt,r.ORDER))throw new Error("Point is not on curve");let I=u(p),R;try{R=r.sqrt(I)}catch(z){let $=z instanceof Error?": "+z.message:"";throw new Error("Point is not on curve"+$)}let F=(R&lt)===lt;return(T&1)===1!==F&&(R=r.neg(R)),{x:p,y:R}}else if(A===i&&T===4){let p=r.fromBytes(E.subarray(0,r.BYTES)),I=r.fromBytes(E.subarray(r.BYTES,2*r.BYTES));return{x:p,y:I}}else{let p=o,I=i;throw new Error("invalid Point, expected length of "+p+", or uncompressed "+I+", got "+A)}}}),d=v=>Ae(Ke(v,t.nByteLength));function w(v){let A=n>>lt;return v>A}function B(v){return w(v)?s(-v):v}let x=(v,A,T)=>le(v.slice(A,T));class h{constructor(A,T,E){Lt("r",A,lt,n),Lt("s",T,lt,n),this.r=A,this.s=T,E!=null&&(this.recovery=E),Object.freeze(this)}static fromCompact(A){let T=t.nByteLength;return A=nt("compactSignature",A,T*2),new h(x(A,0,T),x(A,T,2*T))}static fromDER(A){let{r:T,s:E}=pe.toSig(nt("DER",A));return new h(T,E)}assertValidity(){}addRecoveryBit(A){return new h(this.r,this.s,A)}recoverPublicKey(A){let{r:T,s:E,recovery:p}=this,I=D(nt("msgHash",A));if(p==null||![0,1,2,3].includes(p))throw new Error("recovery id invalid");let R=p===2||p===3?T+t.n:T;if(R>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");let F=(p&1)===0?"02":"03",H=c.fromHex(F+d(R)),z=a(R),$=s(-I*z),Z=s(E*z),Y=c.BASE.multiplyAndAddUnsafe(H,$,Z);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new h(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Kr(this.toDERHex())}toDERHex(){return pe.hexFromSig(this)}toCompactRawBytes(){return Kr(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}let S={isValidPrivateKey(v){try{return l(v),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let v=ai(t.n);return Ca(t.randomBytes(v),t.n)},precompute(v=8,A=c.BASE){return A._setWindowSize(v),A.multiply(BigInt(3)),A}};function U(v,A=!0){return c.fromPrivateKey(v).toRawBytes(A)}function y(v){let A=Re(v),T=typeof v=="string",E=(A||T)&&v.length;return A?E===o||E===i:T?E===2*o||E===2*i:v instanceof c}function P(v,A,T=!0){if(y(v))throw new Error("first arg must be private key");if(!y(A))throw new Error("second arg must be public key");return c.fromHex(A).multiply(l(v)).toRawBytes(T)}let O=t.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");let A=le(v),T=v.length*8-t.nBitLength;return T>0?A>>BigInt(T):A},D=t.bits2int_modN||function(v){return s(O(v))},N=Oe(t.nBitLength);function g(v){return Lt("num < 2^"+t.nBitLength,v,me,N),Ke(v,t.nByteLength)}function b(v,A,T=K){if(["recovered","canonical"].some(it=>it in T))throw new Error("sign() legacy options not supported");let{hash:E,randomBytes:p}=t,{lowS:I,prehash:R,extraEntropy:F}=T;I==null&&(I=!0),v=nt("msgHash",v),ic(T),R&&(v=nt("prehashed msgHash",E(v)));let H=D(v),z=l(A),$=[g(z),g(H)];if(F!=null&&F!==!1){let it=F===!0?p(r.BYTES):F;$.push(nt("extraEntropy",it))}let Z=Ie(...$),Y=H;function at(it){let ht=O(it);if(!f(ht))return;let It=a(ht),ft=c.BASE.multiply(ht).toAffine(),gt=s(ft.x);if(gt===me)return;let Pt=s(It*s(Y+gt*z));if(Pt===me)return;let Vt=(ft.x===gt?0:2)|Number(ft.y&lt),Ar=Pt;return I&&w(Pt)&&(Ar=B(Pt),Vt^=1),new h(gt,Ar,Vt)}return{seed:Z,k2sig:at}}let K={lowS:t.lowS,prehash:!1},k={lowS:t.lowS,prehash:!1};function _(v,A,T=K){let{seed:E,k2sig:p}=b(v,A,T),I=t;return Sa(I.hash.outputLen,I.nByteLength,I.hmac)(E,p)}c.BASE._setWindowSize(8);function V(v,A,T,E=k){let p=v;A=nt("msgHash",A),T=nt("publicKey",T);let{lowS:I,prehash:R,format:F}=E;if(ic(E),"strict"in E)throw new Error("options.strict was renamed to lowS");if(F!==void 0&&F!=="compact"&&F!=="der")throw new Error("format must be compact or der");let H=typeof p=="string"||Re(p),z=!H&&!F&&typeof p=="object"&&p!==null&&typeof p.r=="bigint"&&typeof p.s=="bigint";if(!H&&!z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let $,Z;try{if(z&&($=new h(p.r,p.s)),H){try{F!=="compact"&&($=h.fromDER(p))}catch(Vt){if(!(Vt instanceof pe.Err))throw Vt}!$&&F!=="der"&&($=h.fromCompact(p))}Z=c.fromHex(T)}catch{return!1}if(!$||I&&$.hasHighS())return!1;R&&(A=t.hash(A));let{r:Y,s:at}=$,it=D(A),ht=a(at),It=s(it*ht),ft=s(Y*ht),gt=c.BASE.multiplyAndAddUnsafe(Z,It,ft)?.toAffine();return gt?s(gt.x)===Y:!1}return{CURVE:t,getPublicKey:U,getSharedSecret:P,sign:_,verify:V,ProjectivePoint:c,Signature:h,utils:S}}function Vd(e){return{hash:e,hmac:(t,...r)=>zi(e,t,Zo(...r)),randomBytes:xn}}function cc(e,t){let r=n=>ac({...e,...Vd(n)});return{...r(t),create:r}}var lc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),uc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),qd=BigInt(1),ji=BigInt(2),fc=(e,t)=>(e+t/ji)/t;function Hd(e){let t=lc,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=et(u,r,t)*u%t,d=et(f,r,t)*u%t,w=et(d,ji,t)*l%t,B=et(w,o,t)*w%t,x=et(B,i,t)*B%t,h=et(x,a,t)*x%t,S=et(h,c,t)*h%t,U=et(S,a,t)*x%t,y=et(U,r,t)*u%t,P=et(y,s,t)*B%t,O=et(P,n,t)*l%t,D=et(O,ji,t);if(!Gi.eql(Gi.sqr(D),e))throw new Error("Cannot find square root");return D}var Gi=he(lc,void 0,void 0,{sqrt:Hd}),He=cc({a:BigInt(0),b:BigInt(7),Fp:Gi,n:uc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{let t=uc,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-qd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,s=BigInt("0x100000000000000000000000000000000"),a=fc(i*e,t),c=fc(-n*e,t),l=J(e-a*r-c*o,t),u=J(-a*n-c*i,t),f=l>s,d=u>s;if(f&&(l=t-l),d&&(u=t-u),l>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:d,k2:u}}}},En),hg=BigInt(0);var pg=He.ProjectivePoint;function dc(e){return e==null?!1:typeof e.then=="function"&&typeof e.catch=="function"&&typeof e.finally=="function"}function hc(e,t,r){let n=Cr.digest(r instanceof Uint8Array?r:r.subarray());if(dc(n))return n.then(({digest:o})=>He.verify(t,o,e)).catch(o=>{throw new qr(String(o))});try{return He.verify(t,n.digest,e)}catch(o){throw new qr(String(o))}}var kn=class{type="secp256k1";raw;_key;constructor(t){this._key=mc(t),this.raw=pc(this._key)}toMultihash(){return zt.digest(er(this))}toCID(){return Q.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:rt(this.raw,t.raw)}verify(t,r){return hc(this._key,r,t)}};function Zi(e){return new kn(e)}function pc(e){return He.ProjectivePoint.fromHex(e).toRawBytes(!0)}function mc(e){try{return He.ProjectivePoint.fromHex(e),e}catch(t){throw new $e(String(t))}}function yc(e,t){let{Type:r,Data:n}=re.decode(e),o=n??new Uint8Array;switch(r){case st.RSA:return Vi(o,t);case st.Ed25519:return mi(o);case st.secp256k1:return Zi(o);case st.ECDSA:return Go(o);default:throw new Ge}}function Rn(e){let{Type:t,Data:r}=re.decode(e.digest),n=r??new Uint8Array;switch(t){case st.Ed25519:return mi(n);case st.secp256k1:return Zi(n);case st.ECDSA:return Go(n);default:throw new Ge}}function er(e){return re.encode({Type:st[e.type],Data:e.raw})}var gc=Symbol.for("nodejs.util.inspect.custom"),zd=114,$r=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[xo]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return Q.createV1(zd,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return rt(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return rt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[gc](){return`PeerId(${this.toString()})`}},Dn=class extends $r{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Kn=class extends $r{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},On=class extends $r{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},$d=2336,jr=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=zt.digest(j(this.url))}[gc](){return`PeerId(${this.url})`}[xo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return Q.createV1($d,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=q(t)),t.toString()===this.toString())}};var jd=114,xc=2336;function wc(e,t){let r;if(e.charAt(0)==="1"||e.charAt(0)==="Q")r=ie(X.decode(`z${e}`));else{if(e.startsWith("k51qzi5uqu5")||e.startsWith("kzwfwjn5ji4")||e.startsWith("k2k4r8")||e.startsWith("bafz"))return Gd(Q.parse(e));if(t==null)throw new ct('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=ie(t.decode(e))}return bc(r)}function bc(e){if(Wd(e))return new Dn({multihash:e});if(Zd(e))try{let t=Rn(e);if(t.type==="Ed25519")return new Kn({multihash:e,publicKey:t});if(t.type==="secp256k1")return new On({multihash:e,publicKey:t})}catch{let r=q(e.digest);return new jr(new URL(r))}throw new je("Supplied PeerID Multihash is invalid")}function Gd(e){if(e?.multihash==null||e.version==null||e.version===1&&e.code!==jd&&e.code!==xc)throw new un("Supplied PeerID CID is invalid");if(e.code===xc){let t=q(e.multihash.digest);return new jr(new URL(t))}return bc(e.multihash)}function Zd(e){return e.code===zt.code}function Wd(e){return e.code===Cr.code}var Fn=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let r=this.index,n=t();return n===void 0&&(this.index=r),n}parseWith(t){let r=t();if(this.index===this.input.length)return r}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(t){return this.readAtomically(()=>{let r=this.readChar();if(r===t)return r})}readSeparator(t,r,n){return this.readAtomically(()=>{if(!(r>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,r,n,o){return this.readAtomically(()=>{let i=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*o)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let d=Number.parseInt(f,t);if(!Number.isNaN(d))return d});if(u===void 0)break;if(i*=t,i+=u,i>l||(s+=1,r!==void 0&&s>r))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let r=0;r<t.length;r++){let n=this.readSeparator(".",r,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[r]=n}return t})}readIPv6Addr(){let t=r=>{for(let n=0;n<r.length/2;n++){let o=n*2;if(n<r.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return r[o]=s[0],r[o+1]=s[1],r[o+2]=s[2],r[o+3]=s[3],[o+4,!0]}let i=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(i===void 0)return[o,!1];r[o]=i>>8,r[o+1]=i&255}return[r.length,!1]};return this.readAtomically(()=>{let r=new Uint8Array(16),[n,o]=t(r);if(n===16)return r;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=t(i.subarray(0,s));return r.set(i.subarray(0,a),16-a),r})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Ec=45,Yd=15,hr=new Fn;function Wi(e){if(!(e.length>Yd))return hr.new(e).parseWith(()=>hr.readIPv4Addr())}function Yi(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Ec))return hr.new(e).parseWith(()=>hr.readIPv6Addr())}function Mn(e,t=!1){if(e.includes("%")&&(e=e.split("%")[0]),e.length>Ec)return;let r=hr.new(e).parseWith(()=>hr.readIPAddr());if(r)return t&&r.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,r[0],r[1],r[2],r[3]]):r}var Cx=parseInt("0xFFFF",16),_x=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Ac(e){return!!Wi(e)}function Ic(e){return!!Yi(e)}function Vn(e){return!!Mn(e)}var Tc=Ac,eh=Ic,Xi=function(e){let t=0;if(e=e.toString().trim(),Tc(e)){let r=new Uint8Array(t+4);return e.split(/\./g).forEach(n=>{r[t++]=parseInt(n,10)&255}),r}if(eh(e)){let r=e.split(":",8),n;for(n=0;n<r.length;n++){let i=Tc(r[n]),s;i&&(s=Xi(r[n]),r[n]=q(s.slice(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,q(s.slice(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(t+16);for(n=0;n<r.length;n++){let i=parseInt(r[n],16);o[t++]=i>>8&255,o[t++]=i&255}return o}throw new Error("invalid ip address")},Bc=function(e,t=0,r){t=~~t,r=r??e.length-t;let n=new DataView(e.buffer);if(r===4){let o=[];for(let i=0;i<r;i++)o.push(e[t+i]);return o.join(".")}if(r===16){let o=[];for(let i=0;i<r;i+=2)o.push(n.getUint16(t+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var pr={},Ji={},nh=[[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"],[481,-1,"http-path"],[777,-1,"memory"]];nh.forEach(e=>{let t=oh(...e);Ji[t.code]=t,pr[t.name]=t});function oh(e,t,r,n,o){return{code:e,size:t,name:r,resolvable:!!n,path:!!o}}function tt(e){if(typeof e=="number"){if(Ji[e]!=null)return Ji[e];throw new Error(`no protocol with code: ${e}`)}else if(typeof e=="string"){if(pr[e]!=null)return pr[e];throw new Error(`no protocol with name: ${e}`)}throw new Error(`invalid protocol id type: ${typeof e}`)}var dw=tt("ip4"),hw=tt("ip6"),pw=tt("ipcidr");function rs(e,t){switch(tt(e).code){case 4:case 41:return sh(t);case 42:return es(t);case 43:return q(t,"base10");case 6:case 273:case 33:case 132:return Uc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return es(t);case 421:return fh(t);case 444:return _c(t);case 445:return _c(t);case 466:return uh(t);case 481:return globalThis.encodeURIComponent(es(t));default:return q(t,"base16")}}function ns(e,t){switch(tt(e).code){case 4:return Cc(t);case 41:return Cc(t);case 42:return ts(t);case 43:return j(t,"base10");case 6:case 273:case 33:case 132:return os(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ts(t);case 421:return ah(t);case 444:return lh(t);case 445:return dh(t);case 466:return ch(t);case 481:return ts(globalThis.decodeURIComponent(t));default:return j(t,"base16")}}var Qi=Object.values(_r).map(e=>e.decoder),ih=function(){let e=Qi[0].or(Qi[1]);return Qi.slice(2).forEach(t=>e=e.or(t)),e}();function Cc(e){if(!Vn(e))throw new Error("invalid ip address");return Xi(e)}function sh(e){let t=Bc(e,0,e.length);if(t==null)throw new Error("ipBuff is required");if(!Vn(t))throw new Error("invalid ip address");return t}function os(e){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function Uc(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function ts(e){let t=j(e),r=Uint8Array.from(ar(t.length));return xt([r,t],r.length+t.length)}function es(e){let t=Me(e);if(e=e.slice(Ut(t)),e.length!==t)throw new Error("inconsistent lengths");return q(e)}function ah(e){let t;e[0]==="Q"||e[0]==="1"?t=ie(X.decode(`z${e}`)).bytes:t=Q.parse(e).multihash.bytes;let r=Uint8Array.from(ar(t.length));return xt([r,t],r.length+t.length)}function ch(e){let t=ih.decode(e),r=Uint8Array.from(ar(t.length));return xt([r,t],r.length+t.length)}function uh(e){let t=Me(e),r=e.slice(Ut(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+q(r,"base64url")}function fh(e){let t=Me(e),r=e.slice(Ut(t));if(r.length!==t)throw new Error("inconsistent lengths");return q(r,"base58btc")}function lh(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let r=qt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=os(n);return xt([r,o],r.length+o.length)}function dh(e){let t=e.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let r=qt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=os(n);return xt([r,o],r.length+o.length)}function _c(e){let t=e.slice(0,e.length-2),r=e.slice(e.length-2),n=q(t,"base32"),o=Uc(r);return`${n}:${o}`}function Pc(e){e=is(e);let t=[],r=[],n=null,o=e.split("/").slice(1);if(o.length===1&&o[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){let s=o[i],a=tt(s);if(a.size===0){t.push([a.code]),r.push([a.code]);continue}if(i++,i>=o.length)throw new qn("invalid address: "+e);if(a.path===!0){n=is(o.slice(i).join("/")),t.push([a.code,ns(a.code,n)]),r.push([a.code,n]);break}let c=ns(a.code,o[i]);t.push([a.code,c]),r.push([a.code,rs(a.code,c)])}return{string:Nc(r),bytes:Hn(t),tuples:t,stringTuples:r,path:n}}function ss(e){let t=[],r=[],n=null,o=0;for(;o<e.length;){let i=Me(e,o),s=Ut(i),a=tt(i),c=hh(a,e.slice(o+s));if(c===0){t.push([i]),r.push([i]),o+=s;continue}let l=e.slice(o+s,o+s+c);if(o+=c+s,o>e.length)throw new qn("Invalid address Uint8Array: "+q(e,"base16"));t.push([i,l]);let u=rs(i,l);if(r.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(e),string:Nc(r),tuples:t,stringTuples:r,path:n}}function Nc(e){let t=[];return e.map(r=>{let n=tt(r[0]);return t.push(n.name),r.length>1&&r[1]!=null&&t.push(r[1]),null}),is(t.join("/"))}function Hn(e){return xt(e.map(t=>{let r=tt(t[0]),n=Uint8Array.from(ar(r.code));return t.length>1&&t[1]!=null&&(n=xt([n,t[1]])),n}))}function hh(e,t){if(e.size>0)return e.size/8;if(e.size===0)return 0;{let r=Me(t instanceof Uint8Array?t:Uint8Array.from(t));return r+Ut(r)}}function is(e){return"/"+e.trim().split("/").filter(t=>t).join("/")}var qn=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var ph=Symbol.for("nodejs.util.inspect.custom"),cs=Symbol.for("@multiformats/js-multiaddr/multiaddr"),mh=[tt("dns").code,tt("dns4").code,tt("dns6").code,tt("dnsaddr").code],as=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},zn=class e{bytes;#t;#r;#e;#a;[cs]=!0;constructor(t){t==null&&(t="");let r;if(t instanceof Uint8Array)r=ss(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);r=Pc(t)}else if(kc(t))r=ss(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=r.bytes,this.#t=r.string,this.#r=r.tuples,this.#e=r.stringTuples,this.#a=r.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let t,r,n,o,i="",s=tt("tcp"),a=tt("udp"),c=tt("ip4"),l=tt("ip6"),u=tt("dns6"),f=tt("ip6zone");for(let[w,B]of this.stringTuples())w===f.code&&(i=`%${B??""}`),mh.includes(w)&&(r=s.name==="tcp"?"tcp":"udp",o=443,n=`${B??""}${i}`,t=w===u.code?6:4),(w===s.code||w===a.code)&&(r=tt(w).name==="tcp"?"tcp":"udp",o=parseInt(B??"")),(w===c.code||w===l.code)&&(r=tt(w).name==="tcp"?"tcp":"udp",n=`${B??""}${i}`,t=w===l.code?6:4);if(t==null||r==null||n==null||o==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:r,port:o}}protos(){return this.#r.map(([t])=>Object.assign({},tt(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>tt(t).name)}tuples(){return this.#r.map(([t,r])=>r==null?[t]:[t,r])}stringTuples(){return this.#e.map(([t,r])=>r==null?[t]:[t,r])}encapsulate(t){return t=new e(t),new e(this.toString()+t.toString())}decapsulate(t){let r=t.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new e(n.slice(0,o))}decapsulateCode(t){let r=this.tuples();for(let n=r.length-1;n>=0;n--)if(r[n][0]===t)return new e(Hn(r.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===pr.p2p.code&&t.push([n,o]),n===pr["p2p-circuit"].code&&(t=[])});let r=t.pop();if(r?.[1]!=null){let n=r[1];return n[0]==="Q"||n[0]==="1"?q(X.decode(`z${n}`),"base58btc"):q(Q.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return rt(this.bytes,t.bytes)}async resolve(t){let r=this.protos().find(i=>i.resolvable);if(r==null)return[this];let n=Lc.get(r.name);if(n==null)throw new as(`no available resolver for ${r.name}`);return(await n(this,t)).map(i=>Gr(i))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let r=(t??this).protos();return!(r.length!==2||r[0].code!==4&&r[0].code!==41||r[1].code!==6&&r[1].code!==273)}[ph](){return`Multiaddr(${this.#t})`}};var Lc=new Map;function kc(e){return!!e?.[cs]}function Gr(e){return new zn(e)}function Zr(e){let t=new globalThis.AbortController;function r(){t.abort();for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}for(let i of e){if(i?.aborted===!0){r();break}i?.addEventListener!=null&&i.addEventListener("abort",r)}function n(){for(let i of e)i?.removeEventListener!=null&&i.removeEventListener("abort",r)}let o=t.signal;return o.clear=n,o}async function*$n(e,t={}){let r=e.getReader();try{for(;;){let n=await r.read();if(n.done)return;yield n.value}}finally{t.preventCancel!==!0&&await r.cancel(),r.releaseLock()}}var yh="/",gh=new TextEncoder().encode(yh),zw=gh[0];var Xh=go(fs(),1);var Gt=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},jn=class extends Error{static name="RecordExpiredError";constructor(t="Record has expired"){super(t),this.name="RecordExpiredError"}},mr=class extends Error{static name="UnsupportedValidityError";constructor(t="The validity type is unsupported"){super(t),this.name="UnsupportedValidityError"}},Gn=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},Zn=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},Wn=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Wr=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var Zt;(function(e){let t;(function(o){o.EOL="EOL"})(t=e.ValidityType||(e.ValidityType={}));let r;(function(o){o[o.EOL=0]="EOL"})(r||(r={})),function(o){o.codec=()=>Vr(r)}(t=e.ValidityType||(e.ValidityType={}));let n;e.codec=()=>(n==null&&(n=lr((o,i,s={})=>{s.lengthDelimited!==!1&&i.fork(),o.value!=null&&(i.uint32(10),i.bytes(o.value)),o.signatureV1!=null&&(i.uint32(18),i.bytes(o.signatureV1)),o.validityType!=null&&(i.uint32(24),e.ValidityType.codec().encode(o.validityType,i)),o.validity!=null&&(i.uint32(34),i.bytes(o.validity)),o.sequence!=null&&(i.uint32(40),i.uint64(o.sequence)),o.ttl!=null&&(i.uint32(48),i.uint64(o.ttl)),o.pubKey!=null&&(i.uint32(58),i.bytes(o.pubKey)),o.signatureV2!=null&&(i.uint32(66),i.bytes(o.signatureV2)),o.data!=null&&(i.uint32(74),i.bytes(o.data)),s.lengthDelimited!==!1&&i.ldelim()},(o,i,s={})=>{let a={},c=i==null?o.len:o.pos+i;for(;o.pos<c;){let l=o.uint32();switch(l>>>3){case 1:{a.value=o.bytes();break}case 2:{a.signatureV1=o.bytes();break}case 3:{a.validityType=e.ValidityType.codec().decode(o);break}case 4:{a.validity=o.bytes();break}case 5:{a.sequence=o.uint64();break}case 6:{a.ttl=o.uint64();break}case 7:{a.pubKey=o.bytes();break}case 8:{a.signatureV2=o.bytes();break}case 9:{a.data=o.bytes();break}default:{o.skipType(l&7);break}}}return a})),n),e.encode=o=>ur(o,e.codec()),e.decode=(o,i)=>cr(o,e.codec(),i)})(Zt||(Zt={}));var xh=["string","number","bigint","symbol"],wh=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function Rc(e){if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0||e===!1)return"boolean";let t=typeof e;if(xh.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(e))return"Array";if(bh(e))return"Buffer";let r=Eh(e);return r||"Object"}function bh(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}function Eh(e){let t=Object.prototype.toString.call(e).slice(8,-1);if(wh.includes(t))return t}var m=class{constructor(t,r,n){this.major=t,this.majorEncoded=t<<5,this.name=r,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(t){return this.major<t.major?-1:this.major>t.major?1:0}};m.uint=new m(0,"uint",!0);m.negint=new m(1,"negint",!0);m.bytes=new m(2,"bytes",!0);m.string=new m(3,"string",!0);m.array=new m(4,"array",!1);m.map=new m(5,"map",!1);m.tag=new m(6,"tag",!1);m.float=new m(7,"float",!0);m.false=new m(7,"false",!0);m.true=new m(7,"true",!0);m.null=new m(7,"null",!0);m.undefined=new m(7,"undefined",!0);m.break=new m(7,"break",!0);var L=class{constructor(t,r,n){this.type=t,this.value=r,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var yr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",Sh=new TextDecoder,vh=new TextEncoder;function Yn(e){return yr&&globalThis.Buffer.isBuffer(e)}function Fc(e){return e instanceof Uint8Array?Yn(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e:Uint8Array.from(e)}var Mc=yr?(e,t,r)=>r-t>64?globalThis.Buffer.from(e.subarray(t,r)).toString("utf8"):Kc(e,t,r):(e,t,r)=>r-t>64?Sh.decode(e.subarray(t,r)):Kc(e,t,r),Vc=yr?e=>e.length>64?globalThis.Buffer.from(e):Dc(e):e=>e.length>64?vh.encode(e):Dc(e);var gr=yr?(e,t,r)=>Yn(e)?new Uint8Array(e.subarray(t,r)):e.slice(t,r):(e,t,r)=>e.slice(t,r),qc=yr?(e,t)=>(e=e.map(r=>r instanceof Uint8Array?r:globalThis.Buffer.from(r)),Fc(globalThis.Buffer.concat(e,t))):(e,t)=>{let r=new Uint8Array(t),n=0;for(let o of e)n+o.length>r.length&&(o=o.subarray(0,r.length-n)),r.set(o,n),n+=o.length;return r},Hc=yr?e=>globalThis.Buffer.allocUnsafe(e):e=>new Uint8Array(e);function zc(e,t){if(Yn(e)&&Yn(t))return e.compare(t);for(let r=0;r<e.length;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return 0}function Dc(e){let t=[],r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=o&63|128):(o&64512)===55296&&n+1<e.length&&(e.charCodeAt(n+1)&64512)===56320?(o=65536+((o&1023)<<10)+(e.charCodeAt(++n)&1023),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=o&63|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=o&63|128)}return t}function Kc(e,t,r){let n=[];for(;t<r;){let o=e[t],i=null,s=o>239?4:o>223?3:o>191?2:1;if(t+s<=r){let a,c,l,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=e[t+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=e[t+1],c=e[t+2],(a&192)===128&&(c&192)===128&&(u=(o&15)<<12|(a&63)<<6|c&63,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:a=e[t+1],c=e[t+2],l=e[t+3],(a&192)===128&&(c&192)===128&&(l&192)===128&&(u=(o&15)<<18|(a&63)<<12|(c&63)<<6|l&63,u>65535&&u<1114112&&(i=u))}}i===null?(i=65533,s=1):i>65535&&(i-=65536,n.push(i>>>10&1023|55296),i=56320|i&1023),n.push(i),t+=s}return Ah(n)}var Oc=4096;function Ah(e){let t=e.length;if(t<=Oc)return String.fromCharCode.apply(String,e);let r="",n=0;for(;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=Oc));return r}var Ih=256,Xn=class{constructor(t=Ih){this.chunkSize=t,this.cursor=0,this.maxCursor=-1,this.chunks=[],this._initReuseChunk=null}reset(){this.cursor=0,this.maxCursor=-1,this.chunks.length&&(this.chunks=[]),this._initReuseChunk!==null&&(this.chunks.push(this._initReuseChunk),this.maxCursor=this._initReuseChunk.length-1)}push(t){let r=this.chunks[this.chunks.length-1];if(this.cursor+t.length<=this.maxCursor+1){let o=r.length-(this.maxCursor-this.cursor)-1;r.set(t,o)}else{if(r){let o=r.length-(this.maxCursor-this.cursor)-1;o<r.length&&(this.chunks[this.chunks.length-1]=r.subarray(0,o),this.maxCursor=this.cursor-1)}t.length<64&&t.length<this.chunkSize?(r=Hc(this.chunkSize),this.chunks.push(r),this.maxCursor+=r.length,this._initReuseChunk===null&&(this._initReuseChunk=r),r.set(t,0)):(this.chunks.push(t),this.maxCursor+=t.length)}this.cursor+=t.length}toBytes(t=!1){let r;if(this.chunks.length===1){let n=this.chunks[0];t&&this.cursor>n.length/2?(r=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):r=gr(n,0,this.cursor)}else r=qc(this.chunks,this.cursor);return t&&this.reset(),r}};var M="CBOR decode error:",ls="CBOR encode error:",Yr=[];Yr[23]=1;Yr[24]=2;Yr[25]=3;Yr[26]=5;Yr[27]=9;function ye(e,t,r){if(e.length-t<r)throw new Error(`${M} not enough data for type`)}var dt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Rt(e,t,r){ye(e,t,1);let n=e[t];if(r.strict===!0&&n<dt[0])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Dt(e,t,r){ye(e,t,2);let n=e[t]<<8|e[t+1];if(r.strict===!0&&n<dt[1])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(e,t,r){ye(e,t,4);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(r.strict===!0&&n<dt[2])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);return n}function Ot(e,t,r){ye(e,t,8);let n=e[t]*16777216+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=e[t+4]*16777216+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(r.strict===!0&&i<dt[3])throw new Error(`${M} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(r.allowBigInt===!0)return i;throw new Error(`${M} integers outside of the safe integer range are not supported`)}function $c(e,t,r,n){return new L(m.uint,Rt(e,t+1,n),2)}function jc(e,t,r,n){return new L(m.uint,Dt(e,t+1,n),3)}function Gc(e,t,r,n){return new L(m.uint,Kt(e,t+1,n),5)}function Zc(e,t,r,n){return new L(m.uint,Ot(e,t+1,n),9)}function Ft(e,t){return mt(e,0,t.value)}function mt(e,t,r){if(r<dt[0]){let n=Number(r);e.push([t|n])}else if(r<dt[1]){let n=Number(r);e.push([t|24,n])}else if(r<dt[2]){let n=Number(r);e.push([t|25,n>>>8,n&255])}else if(r<dt[3]){let n=Number(r);e.push([t|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(r);if(n<dt[4]){let o=[t|27,0,0,0,0,0,0,0],i=Number(n&BigInt(4294967295)),s=Number(n>>BigInt(32)&BigInt(4294967295));o[8]=i&255,i=i>>8,o[7]=i&255,i=i>>8,o[6]=i&255,i=i>>8,o[5]=i&255,o[4]=s&255,s=s>>8,o[3]=s&255,s=s>>8,o[2]=s&255,s=s>>8,o[1]=s&255,e.push(o)}else throw new Error(`${M} encountered BigInt larger than allowable range`)}}Ft.encodedSize=function(t){return mt.encodedSize(t.value)};mt.encodedSize=function(t){return t<dt[0]?1:t<dt[1]?2:t<dt[2]?3:t<dt[3]?5:9};Ft.compareTokens=function(t,r){return t.value<r.value?-1:t.value>r.value?1:0};function Wc(e,t,r,n){return new L(m.negint,-1-Rt(e,t+1,n),2)}function Yc(e,t,r,n){return new L(m.negint,-1-Dt(e,t+1,n),3)}function Xc(e,t,r,n){return new L(m.negint,-1-Kt(e,t+1,n),5)}var ds=BigInt(-1),Jc=BigInt(1);function Qc(e,t,r,n){let o=Ot(e,t+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new L(m.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${M} integers outside of the safe integer range are not supported`);return new L(m.negint,ds-BigInt(o),9)}function Jn(e,t){let r=t.value,n=typeof r=="bigint"?r*ds-Jc:r*-1-1;mt(e,t.type.majorEncoded,n)}Jn.encodedSize=function(t){let r=t.value,n=typeof r=="bigint"?r*ds-Jc:r*-1-1;return n<dt[0]?1:n<dt[1]?2:n<dt[2]?3:n<dt[3]?5:9};Jn.compareTokens=function(t,r){return t.value<r.value?1:t.value>r.value?-1:0};function Xr(e,t,r,n){ye(e,t,r+n);let o=gr(e,t+r,t+r+n);return new L(m.bytes,o,r+n)}function tu(e,t,r,n){return Xr(e,t,1,r)}function eu(e,t,r,n){return Xr(e,t,2,Rt(e,t+1,n))}function ru(e,t,r,n){return Xr(e,t,3,Dt(e,t+1,n))}function nu(e,t,r,n){return Xr(e,t,5,Kt(e,t+1,n))}function ou(e,t,r,n){let o=Ot(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer bytes lengths not supported`);return Xr(e,t,9,o)}function Qn(e){return e.encodedBytes===void 0&&(e.encodedBytes=e.type===m.string?Vc(e.value):e.value),e.encodedBytes}function xr(e,t){let r=Qn(t);mt(e,t.type.majorEncoded,r.length),e.push(r)}xr.encodedSize=function(t){let r=Qn(t);return mt.encodedSize(r.length)+r.length};xr.compareTokens=function(t,r){return Bh(Qn(t),Qn(r))};function Bh(e,t){return e.length<t.length?-1:e.length>t.length?1:zc(e,t)}function Jr(e,t,r,n,o){let i=r+n;ye(e,t,i);let s=new L(m.string,Mc(e,t+r,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=gr(e,t+r,t+i)),s}function iu(e,t,r,n){return Jr(e,t,1,r,n)}function su(e,t,r,n){return Jr(e,t,2,Rt(e,t+1,n),n)}function au(e,t,r,n){return Jr(e,t,3,Dt(e,t+1,n),n)}function cu(e,t,r,n){return Jr(e,t,5,Kt(e,t+1,n),n)}function uu(e,t,r,n){let o=Ot(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer string lengths not supported`);return Jr(e,t,9,o,n)}var fu=xr;function wr(e,t,r,n){return new L(m.array,n,r)}function lu(e,t,r,n){return wr(e,t,1,r)}function du(e,t,r,n){return wr(e,t,2,Rt(e,t+1,n))}function hu(e,t,r,n){return wr(e,t,3,Dt(e,t+1,n))}function pu(e,t,r,n){return wr(e,t,5,Kt(e,t+1,n))}function mu(e,t,r,n){let o=Ot(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer array lengths not supported`);return wr(e,t,9,o)}function yu(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return wr(e,t,1,1/0)}function to(e,t){mt(e,m.array.majorEncoded,t.value)}to.compareTokens=Ft.compareTokens;to.encodedSize=function(t){return mt.encodedSize(t.value)};function br(e,t,r,n){return new L(m.map,n,r)}function gu(e,t,r,n){return br(e,t,1,r)}function xu(e,t,r,n){return br(e,t,2,Rt(e,t+1,n))}function wu(e,t,r,n){return br(e,t,3,Dt(e,t+1,n))}function bu(e,t,r,n){return br(e,t,5,Kt(e,t+1,n))}function Eu(e,t,r,n){let o=Ot(e,t+1,n);if(typeof o=="bigint")throw new Error(`${M} 64-bit integer map lengths not supported`);return br(e,t,9,o)}function Su(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return br(e,t,1,1/0)}function eo(e,t){mt(e,m.map.majorEncoded,t.value)}eo.compareTokens=Ft.compareTokens;eo.encodedSize=function(t){return mt.encodedSize(t.value)};function vu(e,t,r,n){return new L(m.tag,r,1)}function Au(e,t,r,n){return new L(m.tag,Rt(e,t+1,n),2)}function Iu(e,t,r,n){return new L(m.tag,Dt(e,t+1,n),3)}function Tu(e,t,r,n){return new L(m.tag,Kt(e,t+1,n),5)}function Bu(e,t,r,n){return new L(m.tag,Ot(e,t+1,n),9)}function ro(e,t){mt(e,m.tag.majorEncoded,t.value)}ro.compareTokens=Ft.compareTokens;ro.encodedSize=function(t){return mt.encodedSize(t.value)};var Lh=20,kh=21,Rh=22,Dh=23;function Cu(e,t,r,n){if(n.allowUndefined===!1)throw new Error(`${M} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new L(m.null,null,1):new L(m.undefined,void 0,1)}function _u(e,t,r,n){if(n.allowIndefinite===!1)throw new Error(`${M} indefinite length items not allowed`);return new L(m.break,void 0,1)}function hs(e,t,r){if(r){if(r.allowNaN===!1&&Number.isNaN(e))throw new Error(`${M} NaN values are not supported`);if(r.allowInfinity===!1&&(e===1/0||e===-1/0))throw new Error(`${M} Infinity values are not supported`)}return new L(m.float,e,t)}function Uu(e,t,r,n){return hs(ps(e,t+1),3,n)}function Pu(e,t,r,n){return hs(ms(e,t+1),5,n)}function Nu(e,t,r,n){return hs(Du(e,t+1),9,n)}function no(e,t,r){let n=t.value;if(n===!1)e.push([m.float.majorEncoded|Lh]);else if(n===!0)e.push([m.float.majorEncoded|kh]);else if(n===null)e.push([m.float.majorEncoded|Rh]);else if(n===void 0)e.push([m.float.majorEncoded|Dh]);else{let o,i=!1;(!r||r.float64!==!0)&&(ku(n),o=ps(Wt,1),n===o||Number.isNaN(n)?(Wt[0]=249,e.push(Wt.slice(0,3)),i=!0):(Ru(n),o=ms(Wt,1),n===o&&(Wt[0]=250,e.push(Wt.slice(0,5)),i=!0))),i||(Kh(n),o=Du(Wt,1),Wt[0]=251,e.push(Wt.slice(0,9)))}}no.encodedSize=function(t,r){let n=t.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!r||r.float64!==!0){ku(n);let o=ps(Wt,1);if(n===o||Number.isNaN(n))return 3;if(Ru(n),o=ms(Wt,1),n===o)return 5}return 9};var Lu=new ArrayBuffer(9),Mt=new DataView(Lu,1),Wt=new Uint8Array(Lu,0);function ku(e){if(e===1/0)Mt.setUint16(0,31744,!1);else if(e===-1/0)Mt.setUint16(0,64512,!1);else if(Number.isNaN(e))Mt.setUint16(0,32256,!1);else{Mt.setFloat32(0,e);let t=Mt.getUint32(0),r=(t&2139095040)>>23,n=t&8388607;if(r===255)Mt.setUint16(0,31744,!1);else if(r===0)Mt.setUint16(0,(e&2147483648)>>16|n>>13,!1);else{let o=r-127;o<-24?Mt.setUint16(0,0):o<-14?Mt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Mt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function ps(e,t){if(e.length-t<2)throw new Error(`${M} not enough data for float16`);let r=(e[t]<<8)+e[t+1];if(r===31744)return 1/0;if(r===64512)return-1/0;if(r===32256)return NaN;let n=r>>10&31,o=r&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,r&32768?-i:i}function Ru(e){Mt.setFloat32(0,e,!1)}function ms(e,t){if(e.length-t<4)throw new Error(`${M} not enough data for float32`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,4).getFloat32(0,!1)}function Kh(e){Mt.setFloat64(0,e,!1)}function Du(e,t){if(e.length-t<8)throw new Error(`${M} not enough data for float64`);let r=(e.byteOffset||0)+t;return new DataView(e.buffer,r,8).getFloat64(0,!1)}no.compareTokens=Ft.compareTokens;function G(e,t,r){throw new Error(`${M} encountered invalid minor (${r}) for major ${e[t]>>>5}`)}function oo(e){return()=>{throw new Error(`${M} ${e}`)}}var C=[];for(let e=0;e<=23;e++)C[e]=G;C[24]=$c;C[25]=jc;C[26]=Gc;C[27]=Zc;C[28]=G;C[29]=G;C[30]=G;C[31]=G;for(let e=32;e<=55;e++)C[e]=G;C[56]=Wc;C[57]=Yc;C[58]=Xc;C[59]=Qc;C[60]=G;C[61]=G;C[62]=G;C[63]=G;for(let e=64;e<=87;e++)C[e]=tu;C[88]=eu;C[89]=ru;C[90]=nu;C[91]=ou;C[92]=G;C[93]=G;C[94]=G;C[95]=oo("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)C[e]=iu;C[120]=su;C[121]=au;C[122]=cu;C[123]=uu;C[124]=G;C[125]=G;C[126]=G;C[127]=oo("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)C[e]=lu;C[152]=du;C[153]=hu;C[154]=pu;C[155]=mu;C[156]=G;C[157]=G;C[158]=G;C[159]=yu;for(let e=160;e<=183;e++)C[e]=gu;C[184]=xu;C[185]=wu;C[186]=bu;C[187]=Eu;C[188]=G;C[189]=G;C[190]=G;C[191]=Su;for(let e=192;e<=215;e++)C[e]=vu;C[216]=Au;C[217]=Iu;C[218]=Tu;C[219]=Bu;C[220]=G;C[221]=G;C[222]=G;C[223]=G;for(let e=224;e<=243;e++)C[e]=oo("simple values are not supported");C[244]=G;C[245]=G;C[246]=G;C[247]=Cu;C[248]=oo("simple values are not supported");C[249]=Uu;C[250]=Pu;C[251]=Nu;C[252]=G;C[253]=G;C[254]=G;C[255]=_u;var Yt=[];for(let e=0;e<24;e++)Yt[e]=new L(m.uint,e,1);for(let e=-1;e>=-24;e--)Yt[31-e]=new L(m.negint,e,1);Yt[64]=new L(m.bytes,new Uint8Array(0),1);Yt[96]=new L(m.string,"",1);Yt[128]=new L(m.array,0,1);Yt[160]=new L(m.map,0,1);Yt[244]=new L(m.false,!1,1);Yt[245]=new L(m.true,!0,1);Yt[246]=new L(m.null,null,1);function Fh(){let e=[];return e[m.uint.major]=Ft,e[m.negint.major]=Jn,e[m.bytes.major]=xr,e[m.string.major]=fu,e[m.array.major]=to,e[m.map.major]=eo,e[m.tag.major]=ro,e[m.float.major]=no,e}var qb=Fh(),Hb=new Xn,io=class e{constructor(t,r){this.obj=t,this.parent=r}includes(t){let r=this;do if(r.obj===t)return!0;while(r=r.parent);return!1}static createCheck(t,r){if(t&&t.includes(r))throw new Error(`${ls} object contains circular references`);return new e(r,t)}},Ce={null:new L(m.null,null),undefined:new L(m.undefined,void 0),true:new L(m.true,!0),false:new L(m.false,!1),emptyArray:new L(m.array,0),emptyMap:new L(m.map,0)},_e={number(e,t,r,n){return!Number.isInteger(e)||!Number.isSafeInteger(e)?new L(m.float,e):e>=0?new L(m.uint,e):new L(m.negint,e)},bigint(e,t,r,n){return e>=BigInt(0)?new L(m.uint,e):new L(m.negint,e)},Uint8Array(e,t,r,n){return new L(m.bytes,e)},string(e,t,r,n){return new L(m.string,e)},boolean(e,t,r,n){return e?Ce.true:Ce.false},null(e,t,r,n){return Ce.null},undefined(e,t,r,n){return Ce.undefined},ArrayBuffer(e,t,r,n){return new L(m.bytes,new Uint8Array(e))},DataView(e,t,r,n){return new L(m.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength))},Array(e,t,r,n){if(!e.length)return r.addBreakTokens===!0?[Ce.emptyArray,new L(m.break)]:Ce.emptyArray;n=io.createCheck(n,e);let o=[],i=0;for(let s of e)o[i++]=ys(s,r,n);return r.addBreakTokens?[new L(m.array,e.length),o,new L(m.break)]:[new L(m.array,e.length),o]},Object(e,t,r,n){let o=t!=="Object",i=o?e.keys():Object.keys(e),s=o?e.size:i.length;if(!s)return r.addBreakTokens===!0?[Ce.emptyMap,new L(m.break)]:Ce.emptyMap;n=io.createCheck(n,e);let a=[],c=0;for(let l of i)a[c++]=[ys(l,r,n),ys(o?e.get(l):e[l],r,n)];return Mh(a,r),r.addBreakTokens?[new L(m.map,s),a,new L(m.break)]:[new L(m.map,s),a]}};_e.Map=_e.Object;_e.Buffer=_e.Uint8Array;for(let e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))_e[`${e}Array`]=_e.DataView;function ys(e,t={},r){let n=Rc(e),o=t&&t.typeEncoders&&t.typeEncoders[n]||_e[n];if(typeof o=="function"){let s=o(e,n,t,r);if(s!=null)return s}let i=_e[n];if(!i)throw new Error(`${ls} unsupported type: ${n}`);return i(e,n,t,r)}function Mh(e,t){t.mapSorter&&e.sort(t.mapSorter)}var Vh={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},so=class{constructor(t,r={}){this._pos=0,this.data=t,this.options=r}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let t=this.data[this._pos],r=Yt[t];if(r===void 0){let n=C[t];if(!n)throw new Error(`${M} no decoder for major type ${t>>>5} (byte 0x${t.toString(16).padStart(2,"0")})`);let o=t&31;r=n(this.data,this._pos,o,this.options)}return this._pos+=r.encodedLength,r}},Qr=Symbol.for("DONE"),ao=Symbol.for("BREAK");function qh(e,t,r){let n=[];for(let o=0;o<e.value;o++){let i=Er(t,r);if(i===ao){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed array`)}if(i===Qr)throw new Error(`${M} found array but not enough entries (got ${o}, expected ${e.value})`);n[o]=i}return n}function Hh(e,t,r){let n=r.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<e.value;s++){let a=Er(t,r);if(a===ao){if(e.value===1/0)break;throw new Error(`${M} got unexpected break to lengthed map`)}if(a===Qr)throw new Error(`${M} found map but not enough entries (got ${s} [no key], expected ${e.value})`);if(n!==!0&&typeof a!="string")throw new Error(`${M} non-string keys not supported (got ${typeof a})`);if(r.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${M} found repeat map key "${a}"`);let c=Er(t,r);if(c===Qr)throw new Error(`${M} found map but not enough entries (got ${s} [no value], expected ${e.value})`);n?i.set(a,c):o[a]=c}return n?i:o}function Er(e,t){if(e.done())return Qr;let r=e.next();if(r.type===m.break)return ao;if(r.type.terminal)return r.value;if(r.type===m.array)return qh(r,e,t);if(r.type===m.map)return Hh(r,e,t);if(r.type===m.tag){if(t.tags&&typeof t.tags[r.value]=="function"){let n=Er(e,t);return t.tags[r.value](n)}throw new Error(`${M} tag not supported (${r.value})`)}throw new Error("unsupported")}function Ku(e,t){if(!(e instanceof Uint8Array))throw new Error(`${M} data to decode must be a Uint8Array`);t=Object.assign({},Vh,t);let r=t.tokenizer||new so(e,t),n=Er(r,t);if(n===Qr)throw new Error(`${M} did not find any content to decode`);if(n===ao)throw new Error(`${M} got unexpected break`);return[n,e.subarray(r.pos())]}function gs(e,t){let[r,n]=Ku(e,t);if(n.length>0)throw new Error(`${M} too many terminals, data makes no sense`);return r}var jh=xe("ipns:utils"),Ou=j("/ipns/");var Gh=0,Zh=18;function Fu(e){let t;if(e.pubKey!=null)try{t=yc(e.pubKey)}catch(r){throw jh.error(r),r}if(t!=null)return t}function Mu(e){let t=j("ipns-signature:");return xt([t,e])}function tn(e){return"signatureV1"in e?Zt.encode({value:j(e.value),signatureV1:e.signatureV1,validityType:e.validityType,validity:j(e.validity),sequence:e.sequence,ttl:e.ttl,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data}):Zt.encode({pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data})}function Ue(e){let t=Zt.decode(e);if(t.sequence!=null&&(t.sequence=BigInt(t.sequence)),t.ttl!=null&&(t.ttl=BigInt(t.ttl)),t.signatureV2==null||t.data==null)throw new Gt("Missing data or signatureV2");let r=Vu(t.data),n=Wh(r.Value),o=q(r.Validity);if(t.value!=null&&t.signatureV1!=null)return Yh(t),{value:n,validityType:Zt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV1:t.signatureV1,signatureV2:t.signatureV2,data:t.data};if(t.signatureV2!=null)return{value:n,validityType:Zt.ValidityType.EOL,validity:o,sequence:r.Sequence,ttl:r.TTL,pubKey:t.pubKey,signatureV2:t.signatureV2,data:t.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function en(e){return xt([Ou,e.bytes])}function Sr(e){let t=ie(e.slice(Ou.length));if(!co(t,Gh)&&!co(t,Zh))throw new je("Multihash in IPNS key was not identity or sha2-256");return t}function Vu(e){let t=gs(e);if(t.ValidityType===0)t.ValidityType=Zt.ValidityType.EOL;else throw new mr("The validity type is unsupported");return Number.isInteger(t.Sequence)&&(t.Sequence=BigInt(t.Sequence)),Number.isInteger(t.TTL)&&(t.TTL=BigInt(t.TTL)),t}function Wh(e){let t=q(e).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${Q.decode(e).toV1().toString()}`}catch{}try{return`/ipfs/${Q.parse(t).toV1().toString()}`}catch{}throw new Zn("Value must be a valid content path starting with /")}function Yh(e){if(e.data==null)throw new Wn("Record data is missing");let t=Vu(e.data);if(!rt(t.Value,e.value??new Uint8Array(0)))throw new Gt('Field "value" did not match between protobuf and CBOR');if(!rt(t.Validity,e.validity??new Uint8Array(0)))throw new Gt('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==e.validityType)throw new Gt('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==e.sequence)throw new Gt('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==e.ttl)throw new Gt('Field "ttl" did not match between protobuf and CBOR')}function co(e,t){return e.code===t}var h1=xe("ipns"),p1=5*60*1e9,Jh="/ipns/",m1=Jh.length;var qu=go(fs(),1);var uo=xe("ipns:validator"),Qh=1024*10,tp=async(e,t)=>{let r=Ue(t),n;try{let o=Mu(r.data);n=await e.verify(o,r.signatureV2)}catch{n=!1}if(!n)throw uo.error("record signature verification failed"),new Gt("Record signature verification failed");if(r.validityType===Zt.ValidityType.EOL){if(qu.default.fromString(r.validity).toDate().getTime()<Date.now())throw uo.error("record has expired"),new jn("record has expired")}else if(r.validityType!=null)throw uo.error("the validity type is unsupported"),new mr("The validity type is unsupported");uo("ipns record for %s is valid",r.value)};async function Hu(e,t){if(t.byteLength>Qh)throw new Gn("The record is too large");let r=Sr(e),n;co(r,0)&&(n=Rn(r));let o=Ue(t),i=Fu(o)??n;if(i==null)throw new Wr("Could not extract public key from IPNS record or routing key");let s=en(i.toMultihash());if(!rt(s,e))throw new Wr("Embedded public key did not match routing key");await tp(i,t)}var fo=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*rn(e,t={}){let r=/\r?\n/,n=new TextDecoder("utf8"),o="";for await(let i of e){if(typeof i=="string"&&(i=new TextEncoder().encode(i)),Qe(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new fo("Incoming message too long");let s=o.split(r);o=s.pop()??"";for(let a=0;a<s.length;a++)yield JSON.parse(s[a])}o+=n.decode(),o!==""&&(yield JSON.parse(o))}function ne(){let e={};return e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r}),e}var ws=go($u(),1);var on=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},bs=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},ju=e=>globalThis.DOMException===void 0?new bs(e):new DOMException(e),Gu=e=>{let t=e.reason===void 0?ju("This operation was aborted."):e.reason;return t instanceof Error?t:ju(t)};function Es(e,t){let{milliseconds:r,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=t,s,a,l=new Promise((u,f)=>{if(typeof r!="number"||Math.sign(r)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){let{signal:w}=t;w.aborted&&f(Gu(w)),a=()=>{f(Gu(w))},w.addEventListener("abort",a,{once:!0})}if(r===Number.POSITIVE_INFINITY){e.then(u,f);return}let d=new on;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(w){f(w)}return}typeof e.cancel=="function"&&e.cancel(),o===!1?u():o instanceof Error?f(o):(d.message=o??`Promise timed out after ${r} milliseconds`,f(d))},r),(async()=>{try{u(await e)}catch(w){f(w)}})()}).finally(()=>{l.clear(),a&&t.signal&&t.signal.removeEventListener("abort",a)});return l.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},l}function Ss(e,t,r){let n=0,o=e.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;r(e[s],t)<=0?(n=++s,o-=i+1):o=i}return n}var sn=class{#t=[];enqueue(t,r){r={priority:0,...r};let n={priority:r.priority,id:r.id,run:t};if(this.size===0||this.#t[this.size-1].priority>=r.priority){this.#t.push(n);return}let o=Ss(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}setPriority(t,r){let n=this.#t.findIndex(i=>i.id===t);if(n===-1)throw new ReferenceError(`No promise function with the id "${t}" exists in the queue.`);let[o]=this.#t.splice(n,1);this.enqueue(o.run,{priority:r,id:t})}dequeue(){return this.#t.shift()?.run}filter(t){return this.#t.filter(r=>r.priority===t.priority).map(r=>r.run)}get size(){return this.#t.length}};var an=class extends ws.default{#t;#r;#e=0;#a;#c;#p=0;#o;#u;#n;#m;#i=0;#f;#s;#y;#w=1n;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:sn,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${t.intervalCap?.toString()??""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${t.interval?.toString()??""}\` (${typeof t.interval})`);this.#t=t.carryoverConcurrencyCount,this.#r=t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,this.#a=t.intervalCap,this.#c=t.interval,this.#n=new t.queueClass,this.#m=t.queueClass,this.concurrency=t.concurrency,this.timeout=t.timeout,this.#y=t.throwOnTimeout===!0,this.#s=t.autoStart===!1}get#b(){return this.#r||this.#e<this.#a}get#E(){return this.#i<this.#f}#S(){this.#i--,this.#l(),this.emit("next")}#v(){this.#x(),this.#g(),this.#u=void 0}get#A(){let t=Date.now();if(this.#o===void 0){let r=this.#p-t;if(r<0)this.#e=this.#t?this.#i:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#v()},r)),!0}return!1}#l(){if(this.#n.size===0)return this.#o&&clearInterval(this.#o),this.#o=void 0,this.emit("empty"),this.#i===0&&this.emit("idle"),!1;if(!this.#s){let t=!this.#A;if(this.#b&&this.#E){let r=this.#n.dequeue();return r?(this.emit("active"),r(),t&&this.#g(),!0):!1}}return!1}#g(){this.#r||this.#o!==void 0||(this.#o=setInterval(()=>{this.#x()},this.#c),this.#p=Date.now()+this.#c)}#x(){this.#e===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#e=this.#t?this.#i:0,this.#d()}#d(){for(;this.#l(););}get concurrency(){return this.#f}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);this.#f=t,this.#d()}async#I(t){return new Promise((r,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}setPriority(t,r){this.#n.setPriority(t,r)}async add(t,r={}){return r.id??=(this.#w++).toString(),r={timeout:this.timeout,throwOnTimeout:this.#y,...r},new Promise((n,o)=>{this.#n.enqueue(async()=>{this.#i++,this.#e++;try{r.signal?.throwIfAborted();let i=t({signal:r.signal});r.timeout&&(i=Es(Promise.resolve(i),{milliseconds:r.timeout})),r.signal&&(i=Promise.race([i,this.#I(r.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof on&&!r.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#S()}},r),this.emit("add"),this.#l()})}async addAll(t,r){return Promise.all(t.map(async n=>this.add(n,r)))}start(){return this.#s?(this.#s=!1,this.#d(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#m}async onEmpty(){this.#n.size!==0&&await this.#h("empty")}async onSizeLessThan(t){this.#n.size<t||await this.#h("next",()=>this.#n.size<t)}async onIdle(){this.#i===0&&this.#n.size===0||await this.#h("idle")}async#h(t,r){return new Promise(n=>{let o=()=>{r&&!r()||(this.off(t,o),n())};this.on(t,o)})}get size(){return this.#n.size}sizeBy(t){return this.#n.filter(t).length}get pending(){return this.#i}get isPaused(){return this.#s}};var vr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},Xt=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function np(e){return e[Symbol.asyncIterator]!=null}function op(e){if(np(e))return(async()=>{for await(let t of e)return t})();for(let t of e)return t}var Zu=op;function ip(e){let[t,r]=e[Symbol.asyncIterator]!=null?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}}var Wu=ip;function sp(e){return e[Symbol.asyncIterator]!=null}function ap(e,t){let r=0;if(sp(e))return async function*(){for await(let c of e)yield t(c,r++)}();let n=Wu(e),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=t(o,r++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield t(c,r++)}();let a=t;return function*(){yield s;for(let c of n)yield a(c,r++)}()}var Yu=ap;var Xu=j("/ipns/");function Ju(e){return rt(e.subarray(0,Xu.byteLength),Xu)}var ho=class{client;constructor(t){this.client=t}async*findProviders(t,r={}){yield*Yu(this.client.getProviders(t,r),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,r,n){if(!Ju(t))return;let o=Sr(t),i=Q.createV1(114,o),s=Ue(r);await this.client.putIPNS(i,s,n)}async get(t,r){if(!Ju(t))throw new Jt("Not found");let n=Sr(t),o=Q.createV1(114,n);try{let i=await this.client.getIPNS(o,r);return tn(i)}catch(i){throw i.name==="BadResponseError"?new Jt("Not found"):i}}},po=class{client;constructor(t){this.client=t}async findPeer(t,r={}){let n=await Zu(this.client.getPeers(t,r));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Jt("Not found")}async*getClosestPeers(t,r={}){}};var yt=xe("delegated-routing-v1-http-api-client"),mo={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},yo=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,r={}){this.started=!1,this.shutDownController=new AbortController,this.shutDownController.signal,this.httpQueue=new an({concurrency:r.concurrentRequests??mo.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=r.timeout??mo.timeout,this.filterAddrs=r.filterAddrs,this.filterProtocols=r.filterProtocols,this.contentRouting=new ho(this),this.peerRouting=new po(this),this.cacheName=r.cacheName??mo.cacheName,this.cacheTTL=r.cacheTTL??mo.cacheTTL}get[Ts](){return this.contentRouting}get[Bs](){return this.peerRouting}isStarted(){return this.started}async start(){this.started||(this.started=!0,this.cacheTTL>0&&(this.cache=await globalThis.caches?.open(this.cacheName),this.cache!=null&&yt("cache enabled with ttl %d",this.cacheTTL)))}async stop(){this.httpQueue.clear(),this.shutDownController.abort(),await globalThis.caches?.delete(this.cacheName),this.started=!1}async*getProviders(t,r={}){yt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Zr([this.shutDownController.signal,n,r.signal]);let i=ne(),s=ne();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${t.toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l==null)throw new Xt("No response received");if(!l.ok)throw l.status===404?new Jt("No matching records found"):l.status===422?new vr("Request does not conform to schema or semantic constraints"):new Xt(`Unexpected status code: ${l.status}`);if(l.body==null)throw new Xt("Routing response had no body");let u=l.headers.get("Content-Type");if(u==null)throw new Xt("No Content-Type header received");if(u?.startsWith("application/json")){let f=await l.json();for(let d of f.Providers){let w=this.#t(d);w!=null&&(yield w)}}else if(u.includes("application/x-ndjson"))for await(let f of rn($n(l.body))){let d=this.#t(f);d!=null&&(yield d)}else throw new Xt(`Unsupported Content-Type: ${u}`)}finally{o.clear(),s.resolve(),yt("getProviders finished: %c",t)}}async*getPeers(t,r={}){yt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=Zr([this.shutDownController.signal,n,r.signal]);let i=ne(),s=ne();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${t.toCID().toString()}`);this.#r(a,r.filterAddrs,r.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},l=await this.#e(a.toString(),c);if(l.status===404)throw new Jt("No matching records found");if(l.status===422)throw new vr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Xt("Routing response had no body");if(l.headers.get("Content-Type")==="application/json"){let f=await l.json();for(let d of f.Peers){let w=this.#t(d);w!=null&&(yield w)}}else for await(let f of rn($n(l.body))){let d=this.#t(f);d!=null&&(yield d)}}catch(a){yt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),yt("getPeers finished: %c",t)}}async getIPNS(t,r={}){yt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=Zr([this.shutDownController.signal,n,r.signal]);let i=ne(),s=ne();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${t}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},l=await this.#e(a,c);if(yt("getIPNS GET %s %d",a,l.status),l.status===404)throw new Jt("No matching records found");if(l.status===422)throw new vr("Request does not conform to schema or semantic constraints");if(l.body==null)throw new Xt("GET ipns response had no body");let u=await l.arrayBuffer(),f=new Uint8Array(u,0,u.byteLength);return r.validate!==!1&&await Hu(en(t.multihash),f),Ue(f)}catch(c){throw yt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),yt("getIPNS finished: %s",t)}}async putIPNS(t,r,n={}){yt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=Zr([this.shutDownController.signal,o,n.signal]);let s=ne(),a=ne();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let l=tn(r),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:l,signal:i},f=await this.#e(c,u);if(yt("putIPNS PUT %s %d",c,f.status),f.status!==200)throw new Xt("PUT ipns response had status other than 200")}catch(l){throw yt.error("putIPNS PUT %s error:",c,l.stack),l}finally{i.clear(),a.resolve(),yt("putIPNS finished: %c",t)}}#t(t){try{let r=[],n=t.Addrs?.map(Gr)??[];return t.Protocols!=null&&r.push(...t.Protocols),t.Protocol!=null&&(r.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:wc(t.ID),Addrs:n,Protocols:r}}catch(r){yt.error("could not conform record to peer schema",r)}}#r(t,r,n){if(r!=null||this.filterAddrs!=null){let o=r?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&t.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&t.searchParams.set("filter-protocols",o)}}async#e(t,r){let n=r.method??"GET",o=`${n}-${t}`;if(n==="GET"){let c=await this.cache?.match(t);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return yt("returning cached response for %s",o),c;await this.cache?.delete(t)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return yt("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(t,r).then(async c=>{if(this.cache!=null&&c.ok&&n==="GET"){let l=Date.now()+this.cacheTTL,u=new Headers(c.headers);u.set("x-cache-expires",l.toString());let f=new Response(c.clone().body,{status:c.status,statusText:c.statusText,headers:u});await this.cache.put(t,f)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function cp(e,t={}){return new yo(new URL(e),t)}return uf(up);})();
8
4
  /*! Bundled license information:
9
5
 
10
- pvtsutils/build/index.js:
11
- (*!
12
- * MIT License
13
- *
14
- * Copyright (c) 2017-2024 Peculiar Ventures, LLC
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- *
34
- *)
35
-
36
6
  @noble/hashes/esm/utils.js:
37
7
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
38
8
 
39
9
  @noble/curves/esm/abstract/utils.js:
40
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
41
-
42
10
  @noble/curves/esm/abstract/modular.js:
43
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
44
-
45
11
  @noble/curves/esm/abstract/curve.js:
46
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
47
-
48
12
  @noble/curves/esm/abstract/edwards.js:
49
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
50
-
51
13
  @noble/curves/esm/ed25519.js:
52
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
53
-
54
- pvutils/build/utils.es.js:
55
- (*!
56
- Copyright (c) Peculiar Ventures, LLC
57
- *)
58
-
59
- asn1js/build/index.es.js:
60
- (*!
61
- * Copyright (c) 2014, GMO GlobalSign
62
- * Copyright (c) 2015-2022, Peculiar Ventures
63
- * All rights reserved.
64
- *
65
- * Author 2014-2019, Yury Strozhevsky
66
- *
67
- * Redistribution and use in source and binary forms, with or without modification,
68
- * are permitted provided that the following conditions are met:
69
- *
70
- * * Redistributions of source code must retain the above copyright notice, this
71
- * list of conditions and the following disclaimer.
72
- *
73
- * * Redistributions in binary form must reproduce the above copyright notice, this
74
- * list of conditions and the following disclaimer in the documentation and/or
75
- * other materials provided with the distribution.
76
- *
77
- * * Neither the name of the copyright holder nor the names of its
78
- * contributors may be used to endorse or promote products derived from
79
- * this software without specific prior written permission.
80
- *
81
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
82
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
83
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
84
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
85
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
86
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
87
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
88
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
89
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
91
- *
92
- *)
93
-
94
14
  @noble/curves/esm/abstract/weierstrass.js:
95
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
96
-
97
15
  @noble/curves/esm/_shortw_utils.js:
98
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
99
-
100
16
  @noble/curves/esm/secp256k1.js:
101
17
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
102
18
  */
103
19
  return HeliaDelegatedRoutingV1HttpApiClient}));
20
+ //# sourceMappingURL=index.min.js.map