@helia/routers 2.2.0-a7aebd5 → 2.2.0-e45e1de

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.
Files changed (2) hide show
  1. package/dist/index.min.js +14 -14
  2. package/package.json +2 -2
package/dist/index.min.js CHANGED
@@ -1,21 +1,21 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.HeliaRouters = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var HeliaRouters=(()=>{var gh=Object.create;var Rn=Object.defineProperty;var yh=Object.getOwnPropertyDescriptor;var wh=Object.getOwnPropertyNames;var xh=Object.getPrototypeOf,bh=Object.prototype.hasOwnProperty;var Pi=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ke=(r,e)=>{for(var t in e)Rn(r,t,{get:e[t],enumerable:!0})},Xa=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of wh(e))!bh.call(r,o)&&o!==t&&Rn(r,o,{get:()=>e[o],enumerable:!(n=yh(e,o))||n.enumerable});return r};var _n=(r,e,t)=>(t=r!=null?gh(xh(r)):{},Xa(e||!r||!r.__esModule?Rn(t,"default",{value:r,enumerable:!0}):t,r)),vh=r=>Xa(Rn({},"__esModule",{value:!0}),r);var nu=Pi(Ur=>{"use strict";var ip="[object ArrayBuffer]",Et=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===ip}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),o=r.toUint8Array(t);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(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let s of t)n+=s.byteLength;let o=new Uint8Array(n),i=0;for(let s of t){let a=this.toUint8Array(s);o.set(a,i),i+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},js="string",sp=/^[0-9a-f\s]+$/i,ap=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,cp=/^[a-zA-Z0-9-_]+$/,oo=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=Et.toUint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return decodeURIComponent(escape(n))}},qe=class{static toString(e,t=!1){let n=Et.toArrayBuffer(e),o=new DataView(n),i="";for(let s=0;s<n.byteLength;s+=2){let a=o.getUint16(s,t);i+=String.fromCharCode(a)}return i}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let i=0;i<e.length;i++)o.setUint16(i*2,e.charCodeAt(i),t);return n}},io=class r{static isHex(e){return typeof e===js&&sp.test(e)}static isBase64(e){return typeof e===js&&ap.test(e)}static isBase64Url(e){return typeof e===js&&cp.test(e)}static ToString(e,t="utf8"){let n=Et.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return qe.toString(n,!0);case"utf16":case"utf16be":return qe.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return qe.fromString(e,!0);case"utf16":case"utf16be":return qe.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Et.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return oo.fromString(e);case"utf16":case"utf16be":return qe.fromString(e);case"utf16le":case"usc2":return qe.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return oo.toString(e);case"utf16":case"utf16be":return qe.toString(e);case"utf16le":case"usc2":return qe.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=Et.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Et.toUint8Array(e),n="",o=t.length;for(let i=0;i<o;i++){let s=t[i];s<16&&(n+="0"),n+=s.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let o=0;o<t.length;o=o+2){let i=t.slice(o,o+2);n[o/2]=parseInt(i,16)}return n.buffer}static ToUtf16String(e,t=!1){return qe.toString(e,t)}static FromUtf16String(e,t=!1){return qe.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};io.DEFAULT_UTF8_ENCODING="utf8";function up(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let i in o)t[i]=o[i]}return t}function lp(...r){let e=r.map(o=>o.byteLength).reduce((o,i)=>o+i),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let i of o)t[n++]=i}),t.buffer}function fp(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}Ur.BufferSourceConverter=Et;Ur.Convert=io;Ur.assign=up;Ur.combine=lp;Ur.isEqual=fp});var Ea=Pi((p2,va)=>{var d2=function(){typeof va<"u"&&(va.exports=w);var r=86400,e=3200,t=146097*e/400,n=r*t,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(_){var v,D=new w,_=(_+="").replace(/^\s*[+\-]?\d+/,function($){var $=+$,S=1970+($-1970)%400;return D.year=$-S,S}).replace(/(?:Z|([+\-]\d{2}):?(\d{2}))$/,function(C,$,S){return $<0&&(S*=-1),v=6e4*(60*+$+ +S),""}).replace(/\.\d+$/,function(C){return D.nano=+(C+c).substr(1,9),""}).split(/\D+/);if(1<_.length?_[1]--:_[1]=0,D.time=v=Date.UTC.apply(Date,_)-(v||0),isNaN(v))throw new TypeError("Invalid Date");return d(D)},w.fromTimeT=function(b){return k(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*t*r/e),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(),_={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 C=v.getYear();return 999999<C?"+"+C:9999<C?"+"+R(C,6):0<=C?R(C,4):-999999<=C?"-"+R(-C,6):C},a:function(){return g[D.getUTCDay()]},b:function(){return h[D.getUTCMonth()]},d:function(){return P(D.getUTCDate())},e:function(){return function(C){return(9<C?"":" ")+(0|C)}(D.getUTCDate())},m:function(){return P(D.getUTCMonth()+1)}};return function C($){return $.replace(/%./g,function(S){var m=S[1],I=B[m],m=_[m];return I?C(I):m?m():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"],g=["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 _=this;if(!(_ instanceof w))return new w(b,v,D);_.time=+b||0,_.nano=+v||0,_.year=+D||0,d(_)}function d(b){var v,D,_,C=b.year,$=b.time,S=b.nano,I=((S<0||a<=S)&&(S-=(D=Math.floor(S/a))*a,$+=D,D=1),C%e);return($<-i||i<$||I)&&((v=f($/o))&&(C+=v*e,$-=v*o),(_=A($)).setUTCFullYear(I+_.getUTCFullYear()),_=($=+_)+(v=f((C-=I)/e))*o,v&&-i<=_&&_<=i&&(C-=v*e,$=_),D=1),D&&(b.year=C,b.time=$,b.nano=S),b}function A(b){var v=new Date(0);return v.setTime(b),v}function k(C,_){C=+C||0;var D=f((_=(_|0)*s)/n)+f(C/n),_=_%n+C%n,C=f(_/n);return C&&(D+=C,_-=C*n),new w(1e3*_,0,D*e)}function x(b,v,D,_,C,$){return function(I,m){var E=d(this);I=I||new Array(8),F(I,m|=0);var N=Math.floor(E.time/1e3),E=E.year*(t*r/e),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,m+C,p),S(I,m+$,E),I};function S(I,m,p){I[m+b]=p>>24&255,I[m+v]=p>>16&255,I[m+D]=p>>8&255,I[m+_]=255&p}}function U(b,v,D,_,C,$){return function(I,m){F(I,m|=0);var p=S(I,m+C);return k(S(I,m+$),p)};function S(I,m){return 16777216*I[m+b]+(I[m+v]<<16|I[m+D]<<8|I[m+_])}}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 Kf=Pi((oE,Na)=>{"use strict";var Dm=Object.prototype.hasOwnProperty,Ne="~";function kn(){}Object.create&&(kn.prototype=Object.create(null),new kn().__proto__||(Ne=!1));function Mm(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function $f(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var i=new Mm(t,n||r,o),s=Ne?Ne+e:e;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 Ii(r,e){--r._eventsCount===0?r._events=new kn:delete r._events[e]}function Ie(){this._events=new kn,this._eventsCount=0}Ie.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)Dm.call(t,n)&&e.push(Ne?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Ie.prototype.listeners=function(e){var t=Ne?Ne+e:e,n=this._events[t];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};Ie.prototype.listenerCount=function(e){var t=Ne?Ne+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Ie.prototype.emit=function(e,t,n,o,i,s){var a=Ne?Ne+e:e;if(!this._events[a])return!1;var c=this._events[a],f=arguments.length,u,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,i),!0;case 6:return c.fn.call(c.context,t,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,g;for(l=0;l<h;l++)switch(c[l].once&&this.removeListener(e,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,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!u)for(g=1,u=new Array(f-1);g<f;g++)u[g-1]=arguments[g];c[l].fn.apply(c[l].context,u)}}return!0};Ie.prototype.on=function(e,t,n){return $f(this,e,t,n,!1)};Ie.prototype.once=function(e,t,n){return $f(this,e,t,n,!0)};Ie.prototype.removeListener=function(e,t,n,o){var i=Ne?Ne+e:e;if(!this._events[i])return this;if(!t)return Ii(this,i),this;var s=this._events[i];if(s.fn)s.fn===t&&(!o||s.once)&&(!n||s.context===n)&&Ii(this,i);else{for(var a=0,c=[],f=s.length;a<f;a++)(s[a].fn!==t||o&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=c.length===1?c[0]:c:Ii(this,i)}return this};Ie.prototype.removeAllListeners=function(e){var t;return e?(t=Ne?Ne+e:e,this._events[t]&&Ii(this,t)):(this._events=new kn,this._eventsCount=0),this};Ie.prototype.off=Ie.prototype.removeListener;Ie.prototype.addListener=Ie.prototype.on;Ie.prefixed=Ne;Ie.EventEmitter=Ie;typeof Na<"u"&&(Na.exports=Ie)});var sg={};ke(sg,{delegatedHTTPRouting:()=>Xf,delegatedHTTPRoutingDefaults:()=>_i,httpGatewayRouting:()=>sh,libp2pRouting:()=>ah});var Qa=Symbol.for("@libp2p/content-routing");var Fi=Symbol.for("@libp2p/peer-id");var ec=Symbol.for("@libp2p/peer-routing");var Ee=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},fr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Re=class extends Error{static name="NotFoundError";constructor(e="Not found"){super(e),this.name="NotFoundError"}};var Ln=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},hr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var dr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var pr=(r,...e)=>{try{[...e]}catch{}};var $i={};ke($i,{base32:()=>Ge,base32hex:()=>Nh,base32hexpad:()=>Rh,base32hexpadupper:()=>_h,base32hexupper:()=>Uh,base32pad:()=>kh,base32padupper:()=>Ch,base32upper:()=>Th,base32z:()=>Lh});var dg=new Uint8Array(0);function tc(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function gt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function rc(r){return new TextEncoder().encode(r)}function nc(r){return new TextDecoder().decode(r)}function Eh(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var o=0;o<r.length;o++){var i=r.charAt(o),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[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,k=B.length;A!==k&&B[A]===0;)A++,w++;for(var x=(k-A)*u+1>>>0,U=new Uint8Array(x);A!==k;){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 k=(B.length-w)*f+1>>>0,x=new Uint8Array(k);B[w];){var U=t[B.charCodeAt(w)];if(U===255)return;for(var F=0,P=k-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=k-A;R!==k&&x[R]===0;)R++;for(var b=new Uint8Array(d+(k-R)),v=d;R!==k;)b[v++]=x[R++];return b}}}function g(B){var w=h(B);if(w)return w;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:h,decode:g}}var Bh=Eh,Ah=Bh,ic=Ah;var Di=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Mi=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let o=t.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return sc(this,e)}},Oi=class{decoders;constructor(e){this.decoders=e}or(e){return sc(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function sc(r,e){return new Oi({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Hi=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new Di(e,t,n),this.decoder=new Mi(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function mr({name:r,prefix:e,encode:t,decode:n}){return new Hi(r,e,t,n)}function Rt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=ic(t,r);return mr({prefix:e,name:r,encode:n,decode:i=>gt(o(i))})}function Sh(r,e,t,n){let o={};for(let u=0;u<e.length;++u)o[e[u]]=u;let i=r.length;for(;r[i-1]==="=";)--i;let s=new Uint8Array(i*t/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<<t|l,a+=t,a>=8&&(a-=8,s[f++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function Ih(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,i="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<t-s]),n)for(;i.length*t&7;)i+="=";return i}function ae({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return mr({prefix:e,name:r,encode(o){return Ih(o,n,t)},decode(o){return Sh(o,n,t,r)}})}var Ge=ae({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Th=ae({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),kh=ae({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ch=ae({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Nh=ae({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Uh=ae({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Rh=ae({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),_h=ae({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Lh=ae({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ki={};ke(Ki,{base58btc:()=>re,base58flickr:()=>Vh});var re=Rt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vh=Rt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var zi={};ke(zi,{base64:()=>qi,base64pad:()=>Ph,base64url:()=>Fh,base64urlpad:()=>Dh});var qi=ae({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ph=ae({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fh=ae({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Dh=ae({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function Mh(r,e){try{if(typeof r=="string"&&r.length>0)return Oh(r);if(typeof r=="number"&&isFinite(r))return e?.long?$h(r):Hh(r);throw new Error("Value is not a string or number.")}catch(t){let n=Kh(t)?`${t.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function Oh(r){if(r=String(r),r.length>100)throw new Error("Value exceeds the maximum length of 100 characters.");let e=/^(-?(?:\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(!e)return NaN;let t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*315576e5;case"weeks":case"week":case"w":return t*6048e5;case"days":case"day":case"d":return t*864e5;case"hours":case"hour":case"hrs":case"hr":case"h":return t*36e5;case"minutes":case"minute":case"mins":case"min":case"m":return t*6e4;case"seconds":case"second":case"secs":case"sec":case"s":return t*1e3;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:throw new Error(`The unit ${n} was matched, but no matching case exists.`)}}var Pn=Mh;function Hh(r){let e=Math.abs(r);return e>=864e5?`${Math.round(r/864e5)}d`:e>=36e5?`${Math.round(r/36e5)}h`:e>=6e4?`${Math.round(r/6e4)}m`:e>=1e3?`${Math.round(r/1e3)}s`:`${r}ms`}function $h(r){let e=Math.abs(r);return e>=864e5?Vn(r,e,864e5,"day"):e>=36e5?Vn(r,e,36e5,"hour"):e>=6e4?Vn(r,e,6e4,"minute"):e>=1e3?Vn(r,e,1e3,"second"):`${r} ms`}function Vn(r,e,t,n){let o=e>=t*1.5;return`${Math.round(r/t)} ${n}${o?"s":""}`}function Kh(r){return typeof r=="object"&&r!==null&&"message"in r}function ji(r){t.debug=t,t.default=t,t.coerce=c,t.disable=i,t.enable=o,t.enabled=s,t.humanize=Pn,t.destroy=f,Object.keys(r).forEach(u=>{t[u]=r[u]}),t.names=[],t.skips=[],t.formatters={};function e(u){let l=0;for(let h=0;h<u.length;h++)l=(l<<5)-l+u.charCodeAt(h),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(u){let l,h=null,g,B;function w(...d){if(!w.enabled)return;let A=w,k=Number(new Date),x=k-(l||k);A.diff=x,A.prev=l,A.curr=k,l=k,d[0]=t.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=t.formatters[R];if(typeof b=="function"){let v=d[U];P=b.call(A,v),d.splice(U,1),U--}return P}),t.formatArgs.call(A,d),(A.log||t.log).apply(A,d)}return w.namespace=u,w.useColors=t.useColors(),w.color=t.selectColor(u),w.extend=n,w.destroy=t.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(g!==t.namespaces&&(g=t.namespaces,B=t.enabled(u)),B),set:d=>{h=d}}),typeof t.init=="function"&&t.init(w),w}function n(u,l){let h=t(this.namespace+(typeof l>"u"?":":l)+u);return h.log=this.log,h}function o(u){t.save(u),t.namespaces=u,t.names=[],t.skips=[];let l,h=(typeof u=="string"?u:"").split(/[\s,]+/),g=h.length;for(l=0;l<g;l++)h[l]&&(u=h[l].replace(/\*/g,".*?"),u[0]==="-"?t.skips.push(new RegExp("^"+u.substr(1)+"$")):t.names.push(new RegExp("^"+u+"$")))}function i(){let u=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let l,h;for(l=0,h=t.skips.length;l<h;l++)if(t.skips[l].test(u))return!1;for(l=0,h=t.names.length;l<h;l++)if(t.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 t.setupFormatters(t.formatters),t.enable(t.load()),t}var Fn=Yh(),qh=["#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 zh(){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 jh(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Pn(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}var Gh=console.debug??console.log??(()=>{});function Zh(r){try{r?Fn?.setItem("debug",r):Fn?.removeItem("debug")}catch{}}function Wh(){let r;try{r=Fn?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function Yh(){try{return localStorage}catch{}}function Jh(r){r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}}var ac=ji({formatArgs:jh,save:Zh,load:Wh,useColors:zh,setupFormatters:Jh,colors:qh,storage:Fn,log:Gh});var _e=ac;_e.formatters.b=r=>r==null?"undefined":re.baseEncode(r);_e.formatters.t=r=>r==null?"undefined":Ge.baseEncode(r);_e.formatters.m=r=>r==null?"undefined":qi.baseEncode(r);_e.formatters.p=r=>r==null?"undefined":r.toString();_e.formatters.c=r=>r==null?"undefined":r.toString();_e.formatters.k=r=>r==null?"undefined":r.toString();_e.formatters.a=r=>r==null?"undefined":r.toString();_e.formatters.e=r=>r==null?"undefined":cc(r.stack)??cc(r.message)??r.toString();function Xh(r){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=r,e.destroy=()=>!0,e.extend=()=>e,e}function _t(r){let e=Xh(`${r}:trace`);return _e.enabled(`${r}:trace`)&&_e.names.map(t=>t.toString()).find(t=>t.includes(":trace"))!=null&&(e=_e(`${r}:trace`)),Object.assign(_e(r),{error:_e(`${r}:error`),trace:e})}function cc(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}var Gi={};ke(Gi,{base36:()=>gr,base36upper:()=>Qh});var gr=Rt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Qh=Rt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ed=fc,uc=128,td=127,rd=~td,nd=Math.pow(2,31);function fc(r,e,t){e=e||[],t=t||0;for(var n=t;r>=nd;)e[t++]=r&255|uc,r/=128;for(;r&rd;)e[t++]=r&255|uc,r>>>=7;return e[t]=r|0,fc.bytes=t-n+1,e}var od=Zi,id=128,lc=127;function Zi(r,n){var t=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Zi.bytes=0,new RangeError("Could not decode varint");s=r[i++],t+=o<28?(s&lc)<<o:(s&lc)*Math.pow(2,o),o+=7}while(s>=id);return Zi.bytes=i-n,t}var sd=Math.pow(2,7),ad=Math.pow(2,14),cd=Math.pow(2,21),ud=Math.pow(2,28),ld=Math.pow(2,35),fd=Math.pow(2,42),hd=Math.pow(2,49),dd=Math.pow(2,56),pd=Math.pow(2,63),md=function(r){return r<sd?1:r<ad?2:r<cd?3:r<ud?4:r<ld?5:r<fd?6:r<hd?7:r<dd?8:r<pd?9:10},gd={encode:ed,decode:od,encodingLength:md},yd=gd,Zr=yd;function Wr(r,e=0){return[Zr.decode(r,e),Zr.decode.bytes]}function yr(r,e,t=0){return Zr.encode(r,e,t),e}function wr(r){return Zr.encodingLength(r)}function Ze(r,e){let t=e.byteLength,n=wr(r),o=n+wr(t),i=new Uint8Array(o+t);return yr(r,i,0),yr(t,i,n),i.set(e,o),new xr(r,t,e,i)}function yt(r){let e=gt(r),[t,n]=Wr(e),[o,i]=Wr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new xr(t,o,s,e)}function hc(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&tc(r.bytes,t.bytes)}}var xr=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};function dc(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return xd(t,Wi(r),e??re.encoder);default:return bd(t,Wi(r),e??Ge.encoder)}}var pc=new WeakMap;function Wi(r){let e=pc.get(r);if(e==null){let t=new Map;return pc.set(r,t),t}return e}var X=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,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:e,multihash:t}=this;if(e!==Yr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==vd)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Ze(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&hc(e.multihash,n.multihash)}toString(e){return dc(this,e)}toJSON(){return{"/":dc(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:o,multihash:i,bytes:s}=t;return new r(n,o,i,s??mc(n,o,i.bytes))}else if(t[Ed]===!0){let{version:n,multihash:o,code:i}=t,s=yt(o);return r.create(n,i,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Yr)throw new Error(`Version 0 CID must use dag-pb (code: ${Yr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=mc(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Yr,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,o=gt(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let i=o.subarray(t.multihashSize-t.digestSize),s=new xr(t.multihashCode,t.digestSize,i,o);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,h]=Wr(e.subarray(t));return t+=h,l},o=n(),i=Yr;if(o===18?(o=0,t=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=t,a=n(),c=n(),f=t+c,u=f-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:u,size:f}}static parse(e,t){let[n,o]=wd(e,t),i=r.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Wi(i).set(n,e),i}};function wd(r,e){switch(r[0]){case"Q":{let t=e??re;return[re.prefix,t.decode(`${re.prefix}${r}`)]}case re.prefix:{let t=e??re;return[re.prefix,t.decode(r)]}case Ge.prefix:{let t=e??Ge;return[Ge.prefix,t.decode(r)]}case gr.prefix:{let t=e??gr;return[gr.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function xd(r,e,t){let{prefix:n}=t;if(n!==re.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let i=t.encode(r).slice(1);return e.set(n,i),i}else return o}function bd(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let i=t.encode(r);return e.set(n,i),i}else return o}var Yr=112,vd=18;function mc(r,e,t){let n=wr(r),o=n+wr(e),i=new Uint8Array(o+t.byteLength);return yr(r,i,0),yr(e,i,n),i.set(t,o),i}var Ed=Symbol.for("@ipld/js-cid/CID");var Yi={};ke(Yi,{identity:()=>We});var gc=0,Bd="identity",yc=gt;function Ad(r){return Ze(gc,yc(r))}var We={code:gc,name:Bd,encode:yc,digest:Ad};function ce(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function wc(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Sd(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function br(r,...e){if(!Sd(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function xc(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");wc(r.outputLen),wc(r.blockLen)}function vr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function bc(r,e){br(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Yt=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Mn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ye=(r,e)=>r<<32-e|r>>>e;function vc(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Jr(r){return typeof r=="string"&&(r=vc(r)),br(r),r}function Ji(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];br(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}var Er=class{clone(){return this._cloneInto()}};function On(r){let e=n=>r().update(Jr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Hn(r=32){if(Yt&&typeof Yt.getRandomValues=="function")return Yt.getRandomValues(new Uint8Array(r));if(Yt&&typeof Yt.randomBytes=="function")return Yt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Id(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),i=BigInt(4294967295),s=Number(t>>o&i),a=Number(t&i),c=n?4:0,f=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+f,a,n)}var Ec=(r,e,t)=>r&e^~r&t,Bc=(r,e,t)=>r&e^r&t^e&t,Br=class extends Er{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Mn(this.buffer)}update(e){vr(this);let{view:t,buffer:n,blockLen:o}=this;e=Jr(e);let i=e.length;for(let s=0;s<i;){let a=Math.min(o-this.pos,i-s);if(a===o){let c=Mn(e);for(;o<=i-s;s+=o)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){vr(this),bc(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;t[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++)t[l]=0;Id(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Mn(e),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:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:o,finished:i,destroyed:s,pos:a}=this;return e.length=o,e.pos=a,e.finished=i,e.destroyed=s,o%t&&e.buffer.set(n),e}};var $n=BigInt(4294967295),Xi=BigInt(32);function Ac(r,e=!1){return e?{h:Number(r&$n),l:Number(r>>Xi&$n)}:{h:Number(r>>Xi&$n)|0,l:Number(r&$n)|0}}function Td(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:i,l:s}=Ac(r[o],e);[t[o],n[o]]=[i,s]}return[t,n]}var kd=(r,e)=>BigInt(r>>>0)<<Xi|BigInt(e>>>0),Cd=(r,e,t)=>r>>>t,Nd=(r,e,t)=>r<<32-t|e>>>t,Ud=(r,e,t)=>r>>>t|e<<32-t,Rd=(r,e,t)=>r<<32-t|e>>>t,_d=(r,e,t)=>r<<64-t|e>>>t-32,Ld=(r,e,t)=>r>>>t-32|e<<64-t,Vd=(r,e)=>e,Pd=(r,e)=>r,Fd=(r,e,t)=>r<<t|e>>>32-t,Dd=(r,e,t)=>e<<t|r>>>32-t,Md=(r,e,t)=>e<<t-32|r>>>64-t,Od=(r,e,t)=>r<<t-32|e>>>64-t;function Hd(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var $d=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Kd=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,qd=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),zd=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,jd=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Gd=(r,e,t,n,o,i)=>e+t+n+o+i+(r/2**32|0)|0;var Zd={fromBig:Ac,split:Td,toBig:kd,shrSH:Cd,shrSL:Nd,rotrSH:Ud,rotrSL:Rd,rotrBH:_d,rotrBL:Ld,rotr32H:Vd,rotr32L:Pd,rotlSH:Fd,rotlSL:Dd,rotlBH:Md,rotlBL:Od,add:Hd,add3L:$d,add3H:Kd,add4L:qd,add4H:zd,add5H:Gd,add5L:jd},q=Zd;var[Wd,Yd]=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))),Vt=new Uint32Array(80),Pt=new Uint32Array(80),Qi=class extends Br{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:n,Bl:o,Ch:i,Cl:s,Dh:a,Dl:c,Eh:f,El:u,Fh:l,Fl:h,Gh:g,Gl:B,Hh:w,Hl:d}=this;return[e,t,n,o,i,s,a,c,f,u,l,h,g,B,w,d]}set(e,t,n,o,i,s,a,c,f,u,l,h,g,B,w,d){this.Ah=e|0,this.Al=t|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=g|0,this.Gl=B|0,this.Hh=w|0,this.Hl=d|0}process(e,t){for(let x=0;x<16;x++,t+=4)Vt[x]=e.getUint32(t),Pt[x]=e.getUint32(t+=4);for(let x=16;x<80;x++){let U=Vt[x-15]|0,F=Pt[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=Vt[x-2]|0,v=Pt[x-2]|0,D=q.rotrSH(b,v,19)^q.rotrBH(b,v,61)^q.shrSH(b,v,6),_=q.rotrSL(b,v,19)^q.rotrBL(b,v,61)^q.shrSL(b,v,6),C=q.add4L(R,_,Pt[x-7],Pt[x-16]),$=q.add4H(C,P,D,Vt[x-7],Vt[x-16]);Vt[x]=$|0,Pt[x]=C|0}let{Ah:n,Al:o,Bh:i,Bl:s,Ch:a,Cl:c,Dh:f,Dl:u,Eh:l,El:h,Fh:g,Fl:B,Gh:w,Gl:d,Hh:A,Hl:k}=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&g^~l&w,R=h&B^~h&d,b=q.add5L(k,F,R,Yd[x],Pt[x]),v=q.add5H(b,A,U,P,Wd[x],Vt[x]),D=b|0,_=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),C=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,k=d|0,w=g|0,d=B|0,g=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,C,S);n=q.add3H(I,v,_,$),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:g,l:B}=q.add(this.Fh|0,this.Fl|0,g|0,B|0),{h:w,l:d}=q.add(this.Gh|0,this.Gl|0,w|0,d|0),{h:A,l:k}=q.add(this.Hh|0,this.Hl|0,A|0,k|0),this.set(n,o,i,s,a,c,f,u,l,h,g,B,w,d,A,k)}roundClean(){Vt.fill(0),Pt.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 Sc=On(()=>new Qi);var zn={};ke(zn,{aInRange:()=>Le,abool:()=>Je,abytes:()=>Ar,bitGet:()=>r0,bitLen:()=>ns,bitMask:()=>Qr,bitSet:()=>n0,bytesToHex:()=>xt,bytesToNumberBE:()=>bt,bytesToNumberLE:()=>Dt,concatBytes:()=>vt,createHmacDrbg:()=>os,ensureBytes:()=>se,equalBytes:()=>e0,hexToBytes:()=>Xt,hexToNumber:()=>rs,inRange:()=>Xr,isBytes:()=>Ft,memoized:()=>er,notImplemented:()=>i0,numberToBytesBE:()=>Mt,numberToBytesLE:()=>Qt,numberToHexUnpadded:()=>Jt,numberToVarBytesBE:()=>Qd,utf8ToBytes:()=>t0,validateObject:()=>ct});var Kn=BigInt(0),qn=BigInt(1),Jd=BigInt(2);function Ft(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Ar(r){if(!Ft(r))throw new Error("Uint8Array expected")}function Je(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}var Xd=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function xt(r){Ar(r);let e="";for(let t=0;t<r.length;t++)e+=Xd[r[t]];return e}function Jt(r){let e=r.toString(16);return e.length&1?"0"+e:e}function rs(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Kn:BigInt("0x"+r)}var wt={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ic(r){if(r>=wt._0&&r<=wt._9)return r-wt._0;if(r>=wt.A&&r<=wt.F)return r-(wt.A-10);if(r>=wt.a&&r<=wt.f)return r-(wt.a-10)}function Xt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let o=0,i=0;o<t;o++,i+=2){let s=Ic(r.charCodeAt(i)),a=Ic(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 bt(r){return rs(xt(r))}function Dt(r){return Ar(r),rs(xt(Uint8Array.from(r).reverse()))}function Mt(r,e){return Xt(r.toString(16).padStart(e*2,"0"))}function Qt(r,e){return Mt(r,e).reverse()}function Qd(r){return Xt(Jt(r))}function se(r,e,t){let n;if(typeof e=="string")try{n=Xt(e)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(Ft(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(r+" of length "+t+" expected, got "+o);return n}function vt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Ar(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let i=r[n];t.set(i,o),o+=i.length}return t}function e0(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function t0(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var es=r=>typeof r=="bigint"&&Kn<=r;function Xr(r,e,t){return es(r)&&es(e)&&es(t)&&e<=r&&r<t}function Le(r,e,t,n){if(!Xr(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function ns(r){let e;for(e=0;r>Kn;r>>=qn,e+=1);return e}function r0(r,e){return r>>BigInt(e)&qn}function n0(r,e,t){return r|(t?qn:Kn)<<BigInt(e)}var Qr=r=>(Jd<<BigInt(r-1))-qn,ts=r=>new Uint8Array(r),Tc=r=>Uint8Array.from(r);function os(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=ts(r),o=ts(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>t(o,n,...l),c=(l=ts())=>{o=a(Tc([0]),l),n=a(),l.length!==0&&(o=a(Tc([1]),l),n=a())},f=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,h=[];for(;l<e;){n=a();let g=n.slice();h.push(g),l+=n.length}return vt(...h)};return(l,h)=>{s(),c(l);let g;for(;!(g=h(f()));)c();return s(),g}}var o0={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"||Ft(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function ct(r,e,t={}){let n=(o,i,s)=>{let a=o0[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(e))n(o,i,!1);for(let[o,i]of Object.entries(t))n(o,i,!0);return r}var i0=()=>{throw new Error("not implemented")};function er(r){let e=new WeakMap;return(t,...n)=>{let o=e.get(t);if(o!==void 0)return o;let i=r(t,...n);return e.set(t,i),i}}var le=BigInt(0),oe=BigInt(1),tr=BigInt(2),s0=BigInt(3),is=BigInt(4),kc=BigInt(5),Cc=BigInt(8),a0=BigInt(9),c0=BigInt(16);function Q(r,e){let t=r%e;return t>=le?t:e+t}function u0(r,e,t){if(e<le)throw new Error("invalid exponent, negatives unsupported");if(t<=le)throw new Error("invalid modulus");if(t===oe)return le;let n=oe;for(;e>le;)e&oe&&(n=n*r%t),r=r*r%t,e>>=oe;return n}function ie(r,e,t){let n=r;for(;e-- >le;)n*=n,n%=t;return n}function jn(r,e){if(r===le)throw new Error("invert: expected non-zero number");if(e<=le)throw new Error("invert: expected positive modulus, got "+e);let t=Q(r,e),n=e,o=le,i=oe,s=oe,a=le;for(;t!==le;){let f=n/t,u=n%t,l=o-s*f,h=i-a*f;n=t,t=u,o=s,i=a,s=l,a=h}if(n!==oe)throw new Error("invert: does not exist");return Q(o,e)}function l0(r){let e=(r-oe)/tr,t,n,o;for(t=r-oe,n=0;t%tr===le;t/=tr,n++);for(o=tr;o<r&&u0(o,e,r)!==r-oe;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+oe)/is;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=(t+oe)/tr;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let f=n,u=a.pow(a.mul(a.ONE,o),t),l=a.pow(c,i),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let g=1;for(let w=a.sqr(h);g<f&&!a.eql(w,a.ONE);g++)w=a.sqr(w);let B=a.pow(u,oe<<BigInt(f-g-1));u=a.sqr(B),l=a.mul(l,B),h=a.mul(h,u),f=g}return l}}function f0(r){if(r%is===s0){let e=(r+oe)/is;return function(n,o){let i=n.pow(o,e);if(!n.eql(n.sqr(i),o))throw new Error("Cannot find square root");return i}}if(r%Cc===kc){let e=(r-kc)/Cc;return function(n,o){let i=n.mul(o,tr),s=n.pow(i,e),a=n.mul(o,s),c=n.mul(n.mul(a,tr),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%c0,l0(r)}var Nc=(r,e)=>(Q(r,e)&oe)===oe,h0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ss(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=h0.reduce((n,o)=>(n[o]="function",n),e);return ct(r,t)}function d0(r,e,t){if(t<le)throw new Error("invalid exponent, negatives unsupported");if(t===le)return r.ONE;if(t===oe)return e;let n=r.ONE,o=e;for(;t>le;)t&oe&&(n=r.mul(n,o)),o=r.sqr(o),t>>=oe;return n}function p0(r,e){let t=new Array(e.length),n=e.reduce((i,s,a)=>r.is0(s)?i:(t[a]=i,r.mul(i,s)),r.ONE),o=r.inv(n);return e.reduceRight((i,s,a)=>r.is0(s)?i:(t[a]=r.mul(i,t[a]),r.mul(i,s)),o),t}function as(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ot(r,e,t=!1,n={}){if(r<=le)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=as(r,e);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:r,isLE:t,BITS:o,BYTES:i,MASK:Qr(o),ZERO:le,ONE:oe,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return le<=c&&c<r},is0:c=>c===le,isOdd:c=>(c&oe)===oe,neg:c=>Q(-c,r),eql:(c,f)=>c===f,sqr:c=>Q(c*c,r),add:(c,f)=>Q(c+f,r),sub:(c,f)=>Q(c-f,r),mul:(c,f)=>Q(c*f,r),pow:(c,f)=>d0(a,c,f),div:(c,f)=>Q(c*jn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>jn(c,r),sqrt:n.sqrt||(c=>(s||(s=f0(r)),s(a,c))),invertBatch:c=>p0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>t?Qt(c,i):Mt(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return t?Dt(c):bt(c)}});return Object.freeze(a)}function Uc(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function cs(r){let e=Uc(r);return e+Math.ceil(e/2)}function Rc(r,e,t=!1){let n=r.length,o=Uc(e),i=cs(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=t?Dt(r):bt(r),a=Q(s,e-oe)+oe;return t?Qt(a,o):Mt(a,o)}var _c=BigInt(0),Gn=BigInt(1);function us(r,e){let t=e.negate();return r?t:e}function Lc(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function ls(r,e){Lc(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function g0(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function y0(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}var fs=new WeakMap,Vc=new WeakMap;function hs(r){return Vc.get(r)||1}function Zn(r,e){return{constTimeNegate:us,hasPrecomputes(t){return hs(t)!==1},unsafeLadder(t,n,o=r.ZERO){let i=t;for(;n>_c;)n&Gn&&(o=o.add(i)),i=i.double(),n>>=Gn;return o},precomputeWindow(t,n){let{windows:o,windowSize:i}=ls(n,e),s=[],a=t,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(t,n,o){let{windows:i,windowSize:s}=ls(t,e),a=r.ZERO,c=r.BASE,f=BigInt(2**t-1),u=2**t,l=BigInt(t);for(let h=0;h<i;h++){let g=h*s,B=Number(o&f);o>>=l,B>s&&(B-=u,o+=Gn);let w=g,d=g+Math.abs(B)-1,A=h%2!==0,k=B<0;B===0?c=c.add(us(A,n[w])):a=a.add(us(k,n[d]))}return{p:a,f:c}},wNAFUnsafe(t,n,o,i=r.ZERO){let{windows:s,windowSize:a}=ls(t,e),c=BigInt(2**t-1),f=2**t,u=BigInt(t);for(let l=0;l<s;l++){let h=l*a;if(o===_c)break;let g=Number(o&c);if(o>>=u,g>a&&(g-=f,o+=Gn),g===0)continue;let B=n[h+Math.abs(g)-1];g<0&&(B=B.negate()),i=i.add(B)}return i},getPrecomputes(t,n,o){let i=fs.get(n);return i||(i=this.precomputeWindow(n,t),t!==1&&fs.set(n,o(i))),i},wNAFCached(t,n,o){let i=hs(t);return this.wNAF(i,this.getPrecomputes(i,t,o),n)},wNAFCachedUnsafe(t,n,o,i){let s=hs(t);return s===1?this.unsafeLadder(t,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,t,o),n,i)},setWindowSize(t,n){Lc(n,e),Vc.set(t,n),fs.delete(t)}}}function Wn(r,e,t,n){if(g0(t,r),y0(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,i=ns(BigInt(t.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((e.BITS-1)/s)*s,u=o;for(let l=f;l>=0;l-=s){c.fill(o);for(let g=0;g<n.length;g++){let B=n[g],w=Number(B>>BigInt(l)&BigInt(a));c[w]=c[w].add(t[g])}let h=o;for(let g=c.length-1,B=o;g>0;g--)B=B.add(c[g]),h=h.add(B);if(u=u.add(h),l!==0)for(let g=0;g<s;g++)u=u.double()}return u}function en(r){return ss(r.Fp),ct(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...as(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Xe=BigInt(0),Ve=BigInt(1),Yn=BigInt(2),w0=BigInt(8),x0={zip215:!0};function b0(r){let e=en(r);return ct(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Pc(r){let e=b0(r),{Fp:t,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=e,f=Yn<<BigInt(a*8)-Ve,u=t.create,l=Ot(e.n,e.nBitLength),h=e.uvRatio||((m,p)=>{try{return{isValid:!0,value:t.sqrt(m*t.inv(p))}}catch{return{isValid:!1,value:Xe}}}),g=e.adjustScalarBytes||(m=>m),B=e.domain||((m,p,E)=>{if(Je("phflag",E),p.length||E)throw new Error("Contexts/pre-hash are not supported");return m});function w(m,p){Le("coordinate "+m,p,Xe,f)}function d(m){if(!(m instanceof x))throw new Error("ExtendedPoint expected")}let A=er((m,p)=>{let{ex:E,ey:N,ez:M}=m,O=m.is0();p==null&&(p=O?w0:t.inv(M));let z=u(E*p),Z=u(N*p),K=u(M*p);if(O)return{x:Xe,y:Ve};if(K!==Ve)throw new Error("invZ was invalid");return{x:z,y:Z}}),k=er(m=>{let{a:p,d:E}=e;if(m.is0())throw new Error("bad point: ZERO");let{ex:N,ey:M,ez:O,et:z}=m,Z=u(N*N),K=u(M*M),J=u(O*O),te=u(J*J),he=u(Z*p),de=u(J*u(he+K)),ye=u(te+u(E*u(Z*K)));if(de!==ye)throw new Error("bad point: equation left != right (1)");let ve=u(N*M),Ue=u(O*z);if(ve!==Ue)throw new Error("bad point: equation left != right (2)");return!0});class x{constructor(p,E,N,M){this.ex=p,this.ey=E,this.ez=N,this.et=M,w("x",p),w("y",E),w("z",N),w("t",M),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,Ve,u(E*N))}static normalizeZ(p){let E=t.invertBatch(p.map(N=>N.ez));return p.map((N,M)=>N.toAffine(E[M])).map(x.fromAffine)}static msm(p,E){return Wn(x,l,p,E)}_setWindowSize(p){P.setWindowSize(this,p)}assertValidity(){k(this)}equals(p){d(p);let{ex:E,ey:N,ez:M}=this,{ex:O,ey:z,ez:Z}=p,K=u(E*Z),J=u(O*M),te=u(N*Z),he=u(z*M);return K===J&&te===he}is0(){return this.equals(x.ZERO)}negate(){return new x(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:p}=e,{ex:E,ey:N,ez:M}=this,O=u(E*E),z=u(N*N),Z=u(Yn*u(M*M)),K=u(p*O),J=E+N,te=u(u(J*J)-O-z),he=K+z,de=he-Z,ye=K-z,ve=u(te*de),Ue=u(he*ye),Te=u(te*ye),at=u(de*he);return new x(ve,Ue,at,Te)}add(p){d(p);let{a:E,d:N}=e,{ex:M,ey:O,ez:z,et:Z}=this,{ex:K,ey:J,ez:te,et:he}=p;if(E===BigInt(-1)){let za=u((O-M)*(J+K)),ja=u((O+M)*(J-K)),Vi=u(ja-za);if(Vi===Xe)return this.double();let Ga=u(z*Yn*he),Za=u(Z*Yn*te),Wa=Za+Ga,Ya=ja+za,Ja=Za-Ga,hh=u(Wa*Vi),dh=u(Ya*Ja),ph=u(Wa*Ja),mh=u(Vi*Ya);return new x(hh,dh,mh,ph)}let de=u(M*K),ye=u(O*J),ve=u(Z*N*he),Ue=u(z*te),Te=u((M+O)*(K+J)-de-ye),at=Ue-ve,mt=Ue+ve,Gr=u(ye-E*de),ch=u(Te*at),uh=u(mt*Gr),lh=u(Te*Gr),fh=u(at*mt);return new x(ch,uh,fh,lh)}subtract(p){return this.add(p.negate())}wNAF(p){return P.wNAFCached(this,p,x.normalizeZ)}multiply(p){let E=p;Le("scalar",E,Ve,n);let{p:N,f:M}=this.wNAF(E);return x.normalizeZ([N,M])[0]}multiplyUnsafe(p,E=x.ZERO){let N=p;return Le("scalar",N,Xe,n),N===Xe?F:this.is0()||N===Ve?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}=e;return p===Ve?this:this.multiplyUnsafe(p)}static fromHex(p,E=!1){let{d:N,a:M}=e,O=t.BYTES;p=se("pointHex",p,O),Je("zip215",E);let z=p.slice(),Z=p[O-1];z[O-1]=Z&-129;let K=Dt(z),J=E?f:t.ORDER;Le("pointHex.y",K,Xe,J);let te=u(K*K),he=u(te-Ve),de=u(N*te-M),{isValid:ye,value:ve}=h(he,de);if(!ye)throw new Error("Point.fromHex: invalid y coordinate");let Ue=(ve&Ve)===Ve,Te=(Z&128)!==0;if(!E&&ve===Xe&&Te)throw new Error("Point.fromHex: x=0 and x_0=1");return Te!==Ue&&(ve=u(-ve)),x.fromAffine({x:ve,y:K})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:E}=this.toAffine(),N=Qt(E,t.BYTES);return N[N.length-1]|=p&Ve?128:0,N}toHex(){return xt(this.toRawBytes())}}x.BASE=new x(e.Gx,e.Gy,Ve,u(e.Gx*e.Gy)),x.ZERO=new x(Xe,Ve,Ve,Xe);let{BASE:U,ZERO:F}=x,P=Zn(x,a*8);function R(m){return Q(m,n)}function b(m){return R(Dt(m))}function v(m){let p=t.BYTES;m=se("private key",m,p);let E=se("hashed private key",i(m),2*p),N=g(E.slice(0,p)),M=E.slice(p,2*p),O=b(N),z=U.multiply(O),Z=z.toRawBytes();return{head:N,prefix:M,scalar:O,point:z,pointBytes:Z}}function D(m){return v(m).pointBytes}function _(m=new Uint8Array,...p){let E=vt(...p);return b(i(B(E,se("context",m),!!o)))}function C(m,p,E={}){m=se("message",m),o&&(m=o(m));let{prefix:N,scalar:M,pointBytes:O}=v(p),z=_(E.context,N,m),Z=U.multiply(z).toRawBytes(),K=_(E.context,Z,O,m),J=R(z+K*M);Le("signature.s",J,Xe,n);let te=vt(Z,Qt(J,t.BYTES));return se("result",te,t.BYTES*2)}let $=x0;function S(m,p,E,N=$){let{context:M,zip215:O}=N,z=t.BYTES;m=se("signature",m,2*z),p=se("message",p),E=se("publicKey",E,z),O!==void 0&&Je("zip215",O),o&&(p=o(p));let Z=Dt(m.slice(z,2*z)),K,J,te;try{K=x.fromHex(E,O),J=x.fromHex(m.slice(0,z),O),te=U.multiplyUnsafe(Z)}catch{return!1}if(!O&&K.isSmallOrder())return!1;let he=_(M,J.toRawBytes(),K.toRawBytes(),p);return J.add(K.multiplyUnsafe(he)).subtract(te).clearCofactor().equals(x.ZERO)}return U._setWindowSize(8),{CURVE:e,getPublicKey:D,sign:C,verify:S,ExtendedPoint:x,utils:{getExtendedPublicKey:v,randomPrivateKey:()=>s(t.BYTES),precompute(m=8,p=x.BASE){return p._setWindowSize(m),p.multiply(BigInt(3)),p}}}}var ds=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Fc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),wy=BigInt(0),v0=BigInt(1),Dc=BigInt(2),xy=BigInt(3),E0=BigInt(5),B0=BigInt(8);function A0(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),i=ds,a=r*r%i*r%i,c=ie(a,Dc,i)*a%i,f=ie(c,v0,i)*r%i,u=ie(f,E0,i)*f%i,l=ie(u,e,i)*u%i,h=ie(l,t,i)*l%i,g=ie(h,n,i)*h%i,B=ie(g,o,i)*g%i,w=ie(B,o,i)*g%i,d=ie(w,e,i)*u%i;return{pow_p_5_8:ie(d,Dc,i)*r%i,b2:a}}function S0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function I0(r,e){let t=ds,n=Q(e*e*e,t),o=Q(n*n*e,t),i=A0(r*o).pow_p_5_8,s=Q(r*n*i,t),a=Q(e*s*s,t),c=s,f=Q(s*Fc,t),u=a===r,l=a===Q(-r,t),h=a===Q(-r*Fc,t);return u&&(s=c),(l||h)&&(s=f),Nc(s,t)&&(s=Q(-s,t)),{isValid:u||l,value:s}}var T0=Ot(ds,void 0,!0),k0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:T0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:B0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Sc,randomBytes:Hn,adjustScalarBytes:S0,uvRatio:I0},Mc=Pc(k0);var Jn=32;function Oc(r,e,t){return Mc.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var Xn=class{type="Ed25519";raw;constructor(e){this.raw=ps(e,Jn)}toMultihash(){return We.digest(Qn(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return re.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return Oc(this.raw,t,e)}};function ms(r){return r=ps(r,Jn),new Xn(r)}function ps(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Ee(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}function Qe(r=0){return new Uint8Array(r)}var N0=Math.pow(2,7),U0=Math.pow(2,14),R0=Math.pow(2,21),gs=Math.pow(2,28),ys=Math.pow(2,35),ws=Math.pow(2,42),xs=Math.pow(2,49),Y=128,Be=127;function Pe(r){if(r<N0)return 1;if(r<U0)return 2;if(r<R0)return 3;if(r<gs)return 4;if(r<ys)return 5;if(r<ws)return 6;if(r<xs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function bs(r,e,t=0){switch(Pe(r)){case 8:e[t++]=r&255|Y,r/=128;case 7:e[t++]=r&255|Y,r/=128;case 6:e[t++]=r&255|Y,r/=128;case 5:e[t++]=r&255|Y,r/=128;case 4:e[t++]=r&255|Y,r>>>=7;case 3:e[t++]=r&255|Y,r>>>=7;case 2:e[t++]=r&255|Y,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function _0(r,e,t=0){switch(Pe(r)){case 8:e.set(t++,r&255|Y),r/=128;case 7:e.set(t++,r&255|Y),r/=128;case 6:e.set(t++,r&255|Y),r/=128;case 5:e.set(t++,r&255|Y),r/=128;case 4:e.set(t++,r&255|Y),r>>>=7;case 3:e.set(t++,r&255|Y),r>>>=7;case 2:e.set(t++,r&255|Y),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function vs(r,e){let t=r[e],n=0;if(n+=t&Be,t<Y||(t=r[e+1],n+=(t&Be)<<7,t<Y)||(t=r[e+2],n+=(t&Be)<<14,t<Y)||(t=r[e+3],n+=(t&Be)<<21,t<Y)||(t=r[e+4],n+=(t&Be)*gs,t<Y)||(t=r[e+5],n+=(t&Be)*ys,t<Y)||(t=r[e+6],n+=(t&Be)*ws,t<Y)||(t=r[e+7],n+=(t&Be)*xs,t<Y))return n;throw new RangeError("Could not decode varint")}function L0(r,e){let t=r.get(e),n=0;if(n+=t&Be,t<Y||(t=r.get(e+1),n+=(t&Be)<<7,t<Y)||(t=r.get(e+2),n+=(t&Be)<<14,t<Y)||(t=r.get(e+3),n+=(t&Be)<<21,t<Y)||(t=r.get(e+4),n+=(t&Be)*gs,t<Y)||(t=r.get(e+5),n+=(t&Be)*ys,t<Y)||(t=r.get(e+6),n+=(t&Be)*ws,t<Y)||(t=r.get(e+7),n+=(t&Be)*xs,t<Y))return n;throw new RangeError("Could not decode varint")}function Sr(r,e,t=0){return e==null&&(e=Qe(Pe(r))),e instanceof Uint8Array?bs(r,e,t):_0(r,e,t)}function rr(r,e=0){return r instanceof Uint8Array?vs(r,e):L0(r,e)}var Es=new Float32Array([-0]),Ht=new Uint8Array(Es.buffer);function Kc(r,e,t){Es[0]=r,e[t]=Ht[0],e[t+1]=Ht[1],e[t+2]=Ht[2],e[t+3]=Ht[3]}function qc(r,e){return Ht[0]=r[e],Ht[1]=r[e+1],Ht[2]=r[e+2],Ht[3]=r[e+3],Es[0]}var Bs=new Float64Array([-0]),Ae=new Uint8Array(Bs.buffer);function zc(r,e,t){Bs[0]=r,e[t]=Ae[0],e[t+1]=Ae[1],e[t+2]=Ae[2],e[t+3]=Ae[3],e[t+4]=Ae[4],e[t+5]=Ae[5],e[t+6]=Ae[6],e[t+7]=Ae[7]}function jc(r,e){return Ae[0]=r[e],Ae[1]=r[e+1],Ae[2]=r[e+2],Ae[3]=r[e+3],Ae[4]=r[e+4],Ae[5]=r[e+5],Ae[6]=r[e+6],Ae[7]=r[e+7],Bs[0]}var V0=BigInt(Number.MAX_SAFE_INTEGER),P0=BigInt(Number.MIN_SAFE_INTEGER),De=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return nr;if(e<V0&&e>P0)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Gc&&(o=0n,++n>Gc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return nr;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):nr}},nr=new De(0,0);nr.toBigInt=function(){return 0n};nr.zzEncode=nr.zzDecode=function(){return this};nr.length=function(){return 1};var Gc=4294967296n;function Zc(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Wc(r,e,t){if(t-e<1)return"";let o,i=[],s=0,a;for(;e<t;)a=r[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&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 As(r,e,t){let n=t,o,i;for(let s=0;s<r.length;++s)o=r.charCodeAt(s),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((i=r.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function et(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function eo(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Ss=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,et(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw et(this,4);return eo(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw et(this,4);return eo(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw et(this,4);let e=qc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw et(this,4);let e=jc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw et(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Wc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw et(this,e);this.pos+=e}else do if(this.pos>=this.len)throw et(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new De(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw et(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw et(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw et(this,8);let e=eo(this.buf,this.pos+=4),t=eo(this.buf,this.pos+=4);return new De(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=vs(this.buf,this.pos);return this.pos+=Pe(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Is(r){return new Ss(r instanceof Uint8Array?r:r.subarray())}function Ir(r,e,t){let n=Is(r);return e.decode(n,void 0,t)}var Ts={};ke(Ts,{base10:()=>F0});var F0=Rt({prefix:"9",name:"base10",alphabet:"0123456789"});var ks={};ke(ks,{base16:()=>D0,base16upper:()=>M0});var D0=ae({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),M0=ae({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Cs={};ke(Cs,{base2:()=>O0});var O0=ae({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Ns={};ke(Ns,{base256emoji:()=>z0});var Jc=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=Jc.reduce((r,e,t)=>(r[t]=e,r),[]),$0=Jc.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function K0(r){return r.reduce((e,t)=>(e+=H0[t],e),"")}function q0(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let o=$0[n];if(o==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(o)}return new Uint8Array(e)}var z0=mr({prefix:"\u{1F680}",name:"base256emoji",encode:K0,decode:q0});var Us={};ke(Us,{base8:()=>j0});var j0=ae({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Rs={};ke(Rs,{identity:()=>G0});var G0=mr({prefix:"\0",name:"identity",encode:r=>nc(r),decode:r=>rc(r)});var ew=new TextEncoder,tw=new TextDecoder;var Vs={};ke(Vs,{sha256:()=>tn,sha512:()=>Y0});function Ls({name:r,code:e,encode:t}){return new _s(r,e,t)}var _s=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Ze(this.code,t):t.then(n=>Ze(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Qc(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var tn=Ls({name:"sha2-256",code:18,encode:Qc("SHA-256")}),Y0=Ls({name:"sha2-512",code:19,encode:Qc("SHA-512")});var rn={...Rs,...Cs,...Us,...Ts,...ks,...$i,...Gi,...Ki,...zi,...Ns},dw={...Vs,...Yi};function tu(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var eu=tu("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ps=tu("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Qe(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),J0={utf8:eu,"utf-8":eu,hex:rn.base16,latin1:Ps,ascii:Ps,binary:Ps,...rn},to=J0;function j(r,e="utf8"){let t=to[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Fs(r){let e=r??8192,t=e>>>1,n,o=e;return function(s){if(s<1||s>t)return Qe(s);o+s>e&&(n=Qe(e),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var or=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ds(){}var Os=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},X0=Fs();function Q0(r){return globalThis.Buffer!=null?Qe(r):X0(r)}var on=class{len;head;tail;states;constructor(){this.len=0,this.head=new or(Ds,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new or(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Hs((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(ro,10,De.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=De.fromBigInt(e);return this._push(ro,t.length(),t)}uint64Number(e){return this._push(bs,Pe(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=De.fromBigInt(e).zzEncode();return this._push(ro,t.length(),t)}sint64Number(e){let t=De.fromNumber(e).zzEncode();return this._push(ro,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ms,1,e?1:0)}fixed32(e){return this._push(nn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=De.fromBigInt(e);return this._push(nn,4,t.lo)._push(nn,4,t.hi)}fixed64Number(e){let t=De.fromNumber(e);return this._push(nn,4,t.lo)._push(nn,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Kc,4,e)}double(e){return this._push(zc,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Ms,1,0):this.uint32(t)._push(tp,t,e)}string(e){let t=Zc(e);return t!==0?this.uint32(t)._push(As,t,e):this._push(Ms,1,0)}fork(){return this.states=new Os(this),this.head=this.tail=new or(Ds,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new or(Ds,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Q0(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Ms(r,e,t){e[t]=r&255}function ep(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Hs=class extends or{next;constructor(e,t){super(ep,e,t),this.next=void 0}};function ro(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function nn(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function tp(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(on.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(rp,e,r),this},on.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(np,e,r),this});function rp(r,e,t){e.set(r,t)}function np(r,e,t){r.length<40?As(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(j(r),t)}function $s(){return new on}function Tr(r,e){let t=$s();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var kr;(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"})(kr||(kr={}));function no(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function sn(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(i,s){let a=e(i);s.int32(a)},n=function(i){let s=i.int32();return e(s)};return no("enum",kr.VARINT,t,n)}function Cr(r,e){return no("message",kr.LENGTH_DELIMITED,r,e)}var fe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(fe||(fe={}));var Ks;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Ks||(Ks={}));(function(r){r.codec=()=>sn(Ks)})(fe||(fe={}));var ut;(function(r){let e;r.codec=()=>(e==null&&(e=Cr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=fe.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Tr(t,r.codec()),r.decode=(t,n)=>Ir(t,r.codec(),n)})(ut||(ut={}));var qs;(function(r){let e;r.codec=()=>(e==null&&(e=Cr((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),fe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n,o={})=>{let i={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{i.Type=fe.codec().decode(t);break}case 2:{i.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return i})),e),r.encode=t=>Tr(t,r.codec()),r.decode=(t,n)=>Ir(t,r.codec(),n)})(qs||(qs={}));var gn={};ke(gn,{MAX_RSA_KEY_SIZE:()=>Wo,generateRSAKeyPair:()=>Xu,jwkToJWKKeyPair:()=>Qu,jwkToPkcs1:()=>xp,jwkToPkix:()=>Qs,jwkToRSAPrivateKey:()=>Ju,pkcs1ToJwk:()=>Zu,pkcs1ToRSAPrivateKey:()=>Yu,pkixToJwk:()=>Wu,pkixToRSAPublicKey:()=>ea});var op=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]),$t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Kt=new Uint32Array(64),zs=class extends Br{constructor(){super(64,32,8,!1),this.A=$t[0]|0,this.B=$t[1]|0,this.C=$t[2]|0,this.D=$t[3]|0,this.E=$t[4]|0,this.F=$t[5]|0,this.G=$t[6]|0,this.H=$t[7]|0}get(){let{A:e,B:t,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,t,n,o,i,s,a,c]}set(e,t,n,o,i,s,a,c){this.A=e|0,this.B=t|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(e,t){for(let l=0;l<16;l++,t+=4)Kt[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let h=Kt[l-15],g=Kt[l-2],B=Ye(h,7)^Ye(h,18)^h>>>3,w=Ye(g,17)^Ye(g,19)^g>>>10;Kt[l]=w+Kt[l-7]+B+Kt[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=Ye(a,6)^Ye(a,11)^Ye(a,25),g=u+h+Ec(a,c,f)+op[l]+Kt[l]|0,w=(Ye(n,2)^Ye(n,13)^Ye(n,22))+Bc(n,o,i)|0;u=f,f=c,c=a,a=s+g|0,s=i,i=o,o=n,n=g+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(){Kt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Nr=On(()=>new zs);var G=_n(nu());function ir(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function qt(r,e,t=-1){let n=t,o=r,i=0,s=Math.pow(2,e);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*e);f[i-u-1]=Math.floor(o/l),o-=f[i-u-1]*l}return c}s*=Math.pow(2,e)}return new ArrayBuffer(0)}function so(...r){let e=0,t=0;for(let i of r)e+=i.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let i of r)o.set(i,t),t+=i.length;return o}function Gs(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=ir(t,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,ir(i,8)-n}function ou(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let s=t-e,a=qt(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=qt(e,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}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function iu(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function Fe(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let s=0;s<n;s++)o[s]="0";return o.join("").concat(t)}var Zw=Math.log(2);function ao(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Zs(r){let e=0,t=0;for(let o=0;o<r.length;o++){let i=r[o];e+=i.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let i=r[o];n.set(new Uint8Array(i),t),t+=i.byteLength}return n.buffer}function It(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var cn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Zs(this.items)}},an=[new Uint8Array([1])],su="0123456789";var Vr="",tt=new ArrayBuffer(0),Ws=new Uint8Array(0),un="EndOfContent",cu="OCTET STRING",uu="BIT STRING";function Tt(r){var e;return e=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?G.BufferSourceConverter.toUint8Array(i.valueHex):Ws}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(!It(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",tt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Bt=class{constructor({blockLength:e=0,error:t=Vr,warnings:n=[],valueBeforeDecode:o=Ws}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=G.BufferSourceConverter.toUint8Array(o)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:G.Convert.ToHex(this.valueBeforeDecodeView)}}};Bt.NAME="baseBlock";var Se=class extends Bt{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Se.NAME="valueBlock";var co=class extends Tt(Bt){constructor({idBlock:e={}}={}){var t,n,o,i;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?G.BufferSourceConverter.toUint8Array(e.valueHex):Ws,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(i=e.isConstructed)!==null&&i!==void 0?i:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",tt}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let i=this.tagNumber;i&=31,t|=i,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=qt(this.tagNumber,7),i=new Uint8Array(o),s=o.byteLength,a=new Uint8Array(s+1);if(a[0]=t|31,!e){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]=t|31,!e){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(e,t,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!It(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;switch(i[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(i[0]&32)===32,this.isHexOnly=!1;let a=i[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,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 g=0;g<f.length;g++)h[g]=f[g];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=ir(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 t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};co.NAME="identificationBlock";var uo=class extends Bt{constructor({lenBlock:e={}}={}){var t,n,o;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!It(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(i.length===0)return this.error="Zero buffer length",-1;if(i[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=i[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(i[0]&128),this.longFormUsed===!1)return this.length=i[0],this.blockLength=1,t+this.blockLength;let 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=t+1,c=o.subarray(a,a+s);return c[s-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=ir(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let o=qt(this.length,8);if(o.byteLength>127)return this.error="Too big length",tt;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let i=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let s=0;s<o.byteLength;s++)n[s+1]=i[s];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};uo.NAME="lengthBlock";var L={},we=class extends Bt{constructor({name:e=Vr,optional:t=!1,primitiveSchema:n,...o}={},i){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new co(o),this.lenBlock=new uo(o),this.valueBlock=i?new i(o):new Se(o)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,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(e,t){let n=t||new cn;t||lu(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let i=this.valueBlock.toBER(e);this.lenBlock.length=i.byteLength;let s=this.lenBlock.toBER(e);n.write(s),n.write(i)}return t?tt:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():G.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return iu(t,n)}};we.NAME="BaseBlock";function lu(r){if(r instanceof L.Constructed)for(let e of r.valueBlock.value)lu(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var lo=class extends we{constructor({value:e=Vr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,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}'`}};lo.NAME="BaseStringBlock";var fo=class extends Tt(Se){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};fo.NAME="PrimitiveValueBlock";var fu,ho=class extends we{constructor(e={}){super(e,fo),this.idBlock.isConstructed=!1}};fu=ho;L.Primitive=fu;ho.NAME="PRIMITIVE";function dp(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function Go(r,e=0,t=r.length){let n=e,o=new we({},Se),i=new Bt;if(!It(i,r,e,t))return o.error=i.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=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=we;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=L.EndOfContent;break;case 1:c=L.Boolean;break;case 2:c=L.Integer;break;case 3:c=L.BitString;break;case 4:c=L.OctetString;break;case 5:c=L.Null;break;case 6:c=L.ObjectIdentifier;break;case 10:c=L.Enumerated;break;case 12:c=L.Utf8String;break;case 13:c=L.RelativeObjectIdentifier;break;case 14:c=L.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=L.Sequence;break;case 17:c=L.Set;break;case 18:c=L.NumericString;break;case 19:c=L.PrintableString;break;case 20:c=L.TeletexString;break;case 21:c=L.VideotexString;break;case 22:c=L.IA5String;break;case 23:c=L.UTCTime;break;case 24:c=L.GeneralizedTime;break;case 25:c=L.GraphicString;break;case 26:c=L.VisibleString;break;case 27:c=L.GeneralString;break;case 28:c=L.UniversalString;break;case 29:c=L.CharacterString;break;case 30:c=L.BmpString;break;case 31:c=L.DATE;break;case 32:c=L.TimeOfDay;break;case 33:c=L.DateTime;break;case 34:c=L.Duration;break;default:{let f=o.idBlock.isConstructed?new L.Constructed:new L.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?L.Constructed:L.Primitive}return o=dp(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function Ys(r){if(!r.byteLength){let e=new we({},Se);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Go(G.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function pp(r,e){return r?1:e}var lt=class extends Se{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=G.BufferSourceConverter.toUint8Array(e);if(!It(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let i=t;for(;pp(this.isIndefiniteForm,n)>0;){let s=Go(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===un)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===un?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){let n=t||new cn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?tt:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};lt.NAME="ConstructedValueBlock";var hu,zt=class extends we{constructor(e={}){super(e,lt),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,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 e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
2
+ "use strict";var HeliaRouters=(()=>{var vh=Object.create;var Vn=Object.defineProperty;var Eh=Object.getOwnPropertyDescriptor;var Bh=Object.getOwnPropertyNames;var Ah=Object.getPrototypeOf,Sh=Object.prototype.hasOwnProperty;var Di=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Ct=(r,t)=>{for(var e in t)Vn(r,e,{get:t[e],enumerable:!0})},tc=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Bh(t))!Sh.call(r,o)&&o!==e&&Vn(r,o,{get:()=>t[o],enumerable:!(n=Eh(t,o))||n.enumerable});return r};var _n=(r,t,e)=>(e=r!=null?vh(Ah(r)):{},tc(t||!r||!r.__esModule?Vn(e,"default",{value:r,enumerable:!0}):e,r)),Ih=r=>tc(Vn({},"__esModule",{value:!0}),r);var iu=Di(Rr=>{"use strict";var lp="[object ArrayBuffer]",Be=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===lp}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}},Zs="string",fp=/^[0-9a-f\s]+$/i,hp=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,dp=/^[a-zA-Z0-9-_]+$/,so=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=Be.toUint8Array(t),n="";for(let i=0;i<e.length;i++)n+=String.fromCharCode(e[i]);return decodeURIComponent(escape(n))}},zt=class{static toString(t,e=!1){let n=Be.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}},ao=class r{static isHex(t){return typeof t===Zs&&fp.test(t)}static isBase64(t){return typeof t===Zs&&hp.test(t)}static isBase64Url(t){return typeof t===Zs&&dp.test(t)}static ToString(t,e="utf8"){let n=Be.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 zt.toString(n,!0);case"utf16":case"utf16be":return zt.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 zt.fromString(t,!0);case"utf16":case"utf16be":return zt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=Be.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 so.fromString(t);case"utf16":case"utf16be":return zt.fromString(t);case"utf16le":case"usc2":return zt.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 so.toString(t);case"utf16":case"utf16be":return zt.toString(t);case"utf16le":case"usc2":return zt.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=Be.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return n}static ToHex(t){let e=Be.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 zt.toString(t,e)}static FromUtf16String(t,e=!1){return zt.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,"")||""}};ao.DEFAULT_UTF8_ENCODING="utf8";function pp(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 gp(...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 mp(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}Rr.BufferSourceConverter=Be;Rr.Convert=ao;Rr.assign=pp;Rr.combine=gp;Rr.isEqual=mp});var Aa=Di((x2,Ba)=>{var w2=function(){typeof Ba<"u"&&(Ba.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(C,$,S){return $<0&&(S*=-1),v=6e4*(60*+$+ +S),""}).replace(/\.\d+$/,function(C){return D.nano=+(C+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 T(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 C=v.getYear();return 999999<C?"+"+C:9999<C?"+"+R(C,6):0<=C?R(C,4):-999999<=C?"-"+R(-C,6):C},a:function(){return m[D.getUTCDay()]},b:function(){return h[D.getUTCMonth()]},d:function(){return P(D.getUTCDate())},e:function(){return function(C){return(9<C?"":" ")+(0|C)}(D.getUTCDate())},m:function(){return P(D.getUTCMonth()+1)}};return function C($){return $.replace(/%./g,function(S){var g=S[1],I=B[g],g=L[g];return I?C(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,C=b.year,$=b.time,S=b.nano,I=((S<0||a<=S)&&(S-=(D=Math.floor(S/a))*a,$+=D,D=1),C%t);return($<-i||i<$||I)&&((v=f($/o))&&(C+=v*t,$-=v*o),(L=A($)).setUTCFullYear(I+L.getUTCFullYear()),L=($=+L)+(v=f((C-=I)/t))*o,v&&-i<=L&&L<=i&&(C-=v*t,$=L),D=1),D&&(b.year=C,b.time=$,b.nano=S),b}function A(b){var v=new Date(0);return v.setTime(b),v}function T(C,L){C=+C||0;var D=f((L=(L|0)*s)/n)+f(C/n),L=L%n+C%n,C=f(L/n);return C&&(D+=C,L-=C*n),new w(1e3*L,0,D*t)}function x(b,v,D,L,C,$){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+C,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,C,$){return function(I,g){F(I,g|=0);var p=S(I,g+C);return T(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 Zf=Di((pE,Ra)=>{"use strict";var Kg=Object.prototype.hasOwnProperty,Ut="~";function Nn(){}Object.create&&(Nn.prototype=Object.create(null),new Nn().__proto__||(Ut=!1));function qg(r,t,e){this.fn=r,this.context=t,this.once=e||!1}function Gf(r,t,e,n,o){if(typeof e!="function")throw new TypeError("The listener must be a function");var i=new qg(e,n||r,o),s=Ut?Ut+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 Ti(r,t){--r._eventsCount===0?r._events=new Nn:delete r._events[t]}function kt(){this._events=new Nn,this._eventsCount=0}kt.prototype.eventNames=function(){var t=[],e,n;if(this._eventsCount===0)return t;for(n in e=this._events)Kg.call(e,n)&&t.push(Ut?n.slice(1):n);return Object.getOwnPropertySymbols?t.concat(Object.getOwnPropertySymbols(e)):t};kt.prototype.listeners=function(t){var e=Ut?Ut+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};kt.prototype.listenerCount=function(t){var e=Ut?Ut+t:t,n=this._events[e];return n?n.fn?1:n.length:0};kt.prototype.emit=function(t,e,n,o,i,s){var a=Ut?Ut+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};kt.prototype.on=function(t,e,n){return Gf(this,t,e,n,!1)};kt.prototype.once=function(t,e,n){return Gf(this,t,e,n,!0)};kt.prototype.removeListener=function(t,e,n,o){var i=Ut?Ut+t:t;if(!this._events[i])return this;if(!e)return Ti(this,i),this;var s=this._events[i];if(s.fn)s.fn===e&&(!o||s.once)&&(!n||s.context===n)&&Ti(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:Ti(this,i)}return this};kt.prototype.removeAllListeners=function(t){var e;return t?(e=Ut?Ut+t:t,this._events[e]&&Ti(this,e)):(this._events=new Nn,this._eventsCount=0),this};kt.prototype.off=kt.prototype.removeListener;kt.prototype.addListener=kt.prototype.on;kt.prefixed=Ut;kt.EventEmitter=kt;typeof Ra<"u"&&(Ra.exports=kt)});var fm={};Ct(fm,{delegatedHTTPRouting:()=>nh,delegatedHTTPRoutingDefaults:()=>_i,httpGatewayRouting:()=>fh,libp2pRouting:()=>hh});var ec=Symbol.for("@libp2p/content-routing");var Oi=Symbol.for("@libp2p/peer-id");var rc=Symbol.for("@libp2p/peer-routing");var Et=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},hr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var Lt=class extends Error{static name="NotFoundError";constructor(t="Not found"){super(t),this.name="NotFoundError"}};var Pn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},dr=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}};var pr=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var gr=(r,...t)=>{try{[...t]}catch{}};var qi={};Ct(qi,{base32:()=>Zt,base32hex:()=>_h,base32hexpad:()=>Fh,base32hexpadupper:()=>Dh,base32hexupper:()=>Ph,base32pad:()=>Lh,base32padupper:()=>Vh,base32upper:()=>Rh,base32z:()=>Oh});var wm=new Uint8Array(0);function nc(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 me(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 oc(r){return new TextEncoder().encode(r)}function ic(r){return new TextDecoder().decode(r)}function kh(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,T=B.length;A!==T&&B[A]===0;)A++,w++;for(var x=(T-A)*u+1>>>0,U=new Uint8Array(x);A!==T;){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 T=(B.length-w)*f+1>>>0,x=new Uint8Array(T);B[w];){var U=e[B.charCodeAt(w)];if(U===255)return;for(var F=0,P=T-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=T-A;R!==T&&x[R]===0;)R++;for(var b=new Uint8Array(d+(T-R)),v=d;R!==T;)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 Th=kh,Ch=Th,ac=Ch;var Mi=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")}},Hi=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 cc(this,t)}},$i=class{decoders;constructor(t){this.decoders=t}or(t){return cc(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 cc(r,t){return new $i({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ki=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 Mi(t,e,n),this.decoder=new Hi(t,e,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function mr({name:r,prefix:t,encode:e,decode:n}){return new Ki(r,t,e,n)}function Le({name:r,prefix:t,alphabet:e}){let{encode:n,decode:o}=ac(e,r);return mr({prefix:t,name:r,encode:n,decode:i=>me(o(i))})}function Nh(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 Uh(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 ct({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return mr({prefix:t,name:r,encode(o){return Uh(o,n,e)},decode(o){return Nh(o,n,e,r)}})}var Zt=ct({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Rh=ct({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lh=ct({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Vh=ct({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_h=ct({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ph=ct({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fh=ct({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Dh=ct({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Oh=ct({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zi={};Ct(zi,{base58btc:()=>rt,base58flickr:()=>Mh});var rt=Le({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Mh=Le({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gi={};Ct(Gi,{base64:()=>ji,base64pad:()=>Hh,base64url:()=>$h,base64urlpad:()=>Kh});var ji=ct({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Hh=ct({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$h=ct({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Kh=ct({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});function qh(r,t){try{if(typeof r=="string"&&r.length>0)return zh(r);if(typeof r=="number"&&isFinite(r))return t?.long?Gh(r):jh(r);throw new Error("Value is not a string or number.")}catch(e){let n=Zh(e)?`${e.message}. value=${JSON.stringify(r)}`:"An unknown error has occured.";throw new Error(n)}}function zh(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 Dn=qh;function jh(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 Gh(r){let t=Math.abs(r);return t>=864e5?Fn(r,t,864e5,"day"):t>=36e5?Fn(r,t,36e5,"hour"):t>=6e4?Fn(r,t,6e4,"minute"):t>=1e3?Fn(r,t,1e3,"second"):`${r} ms`}function Fn(r,t,e,n){let o=t>=e*1.5;return`${Math.round(r/e)} ${n}${o?"s":""}`}function Zh(r){return typeof r=="object"&&r!==null&&"message"in r}function Zi(r){e.debug=e,e.default=e,e.coerce=c,e.disable=i,e.enable=o,e.enabled=s,e.humanize=Dn,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,T=Number(new Date),x=T-(l||T);A.diff=x,A.prev=l,A.curr=T,l=T,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 On=ed(),Wh=["#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 Jh(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Dn(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 Qh(r){try{r?On?.setItem("debug",r):On?.removeItem("debug")}catch{}}function td(){let r;try{r=On?.getItem("debug")}catch{}return!r&&typeof globalThis.process<"u"&&"env"in globalThis.process&&(r=globalThis.process.env.DEBUG),r}function ed(){try{return localStorage}catch{}}function rd(r){r.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}var uc=Zi({formatArgs:Jh,save:Qh,load:td,useColors:Yh,setupFormatters:rd,colors:Wh,storage:On,log:Xh});var Vt=uc;Vt.formatters.b=r=>r==null?"undefined":rt.baseEncode(r);Vt.formatters.t=r=>r==null?"undefined":Zt.baseEncode(r);Vt.formatters.m=r=>r==null?"undefined":ji.baseEncode(r);Vt.formatters.p=r=>r==null?"undefined":r.toString();Vt.formatters.c=r=>r==null?"undefined":r.toString();Vt.formatters.k=r=>r==null?"undefined":r.toString();Vt.formatters.a=r=>r==null?"undefined":r.toString();Vt.formatters.e=r=>r==null?"undefined":lc(r.stack)??lc(r.message)??r.toString();function nd(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 Ve(r){let t=nd(`${r}:trace`);return Vt.enabled(`${r}:trace`)&&Vt.names.map(e=>e.toString()).find(e=>e.includes(":trace"))!=null&&(t=Vt(`${r}:trace`)),Object.assign(Vt(r),{error:Vt(`${r}:error`),trace:t})}function lc(r){if(r!=null&&(r=r.trim(),r.length!==0))return r}var Wi={};Ct(Wi,{base36:()=>yr,base36upper:()=>od});var yr=Le({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),od=Le({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var id=dc,fc=128,sd=127,ad=~sd,cd=Math.pow(2,31);function dc(r,t,e){t=t||[],e=e||0;for(var n=e;r>=cd;)t[e++]=r&255|fc,r/=128;for(;r&ad;)t[e++]=r&255|fc,r>>>=7;return t[e]=r|0,dc.bytes=e-n+1,t}var ud=Yi,ld=128,hc=127;function Yi(r,n){var e=0,n=n||0,o=0,i=n,s,a=r.length;do{if(i>=a)throw Yi.bytes=0,new RangeError("Could not decode varint");s=r[i++],e+=o<28?(s&hc)<<o:(s&hc)*Math.pow(2,o),o+=7}while(s>=ld);return Yi.bytes=i-n,e}var fd=Math.pow(2,7),hd=Math.pow(2,14),dd=Math.pow(2,21),pd=Math.pow(2,28),gd=Math.pow(2,35),md=Math.pow(2,42),yd=Math.pow(2,49),wd=Math.pow(2,56),xd=Math.pow(2,63),bd=function(r){return r<fd?1:r<hd?2:r<dd?3:r<pd?4:r<gd?5:r<md?6:r<yd?7:r<wd?8:r<xd?9:10},vd={encode:id,decode:ud,encodingLength:bd},Ed=vd,Yr=Ed;function Jr(r,t=0){return[Yr.decode(r,t),Yr.decode.bytes]}function wr(r,t,e=0){return Yr.encode(r,t,e),t}function xr(r){return Yr.encodingLength(r)}function Wt(r,t){let e=t.byteLength,n=xr(r),o=n+xr(e),i=new Uint8Array(o+e);return wr(r,i,0),wr(e,i,n),i.set(t,o),new br(r,e,t,i)}function ye(r){let t=me(r),[e,n]=Jr(t),[o,i]=Jr(t.subarray(n)),s=t.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new br(e,o,s,t)}function pc(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&nc(r.bytes,e.bytes)}}var br=class{code;size;digest;bytes;constructor(t,e,n,o){this.code=t,this.size=e,this.digest=n,this.bytes=o}};function gc(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ad(e,Ji(r),t??rt.encoder);default:return Sd(e,Ji(r),t??Zt.encoder)}}var mc=new WeakMap;function Ji(r){let t=mc.get(r);if(t==null){let e=new Map;return mc.set(r,e),e}return t}var X=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!==Xr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Id)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:t,digest:e}=this.multihash,n=Wt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&pc(t.multihash,n.multihash)}toString(t){return gc(this,t)}toJSON(){return{"/":gc(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??yc(n,o,i.bytes))}else if(e[kd]===!0){let{version:n,multihash:o,code:i}=e,s=ye(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!==Xr)throw new Error(`Version 0 CID must use dag-pb (code: ${Xr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let o=yc(t,e,n.bytes);return new r(t,e,n,o)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Xr,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=me(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 br(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]=Jr(t.subarray(e));return e+=h,l},o=n(),i=Xr;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]=Bd(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 Ji(i).set(n,t),i}};function Bd(r,t){switch(r[0]){case"Q":{let e=t??rt;return[rt.prefix,e.decode(`${rt.prefix}${r}`)]}case rt.prefix:{let e=t??rt;return[rt.prefix,e.decode(r)]}case Zt.prefix:{let e=t??Zt;return[Zt.prefix,e.decode(r)]}case yr.prefix:{let e=t??yr;return[yr.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 Ad(r,t,e){let{prefix:n}=e;if(n!==rt.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 Sd(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 Xr=112,Id=18;function yc(r,t,e){let n=xr(r),o=n+xr(t),i=new Uint8Array(o+e.byteLength);return wr(r,i,0),wr(t,i,n),i.set(e,o),i}var kd=Symbol.for("@ipld/js-cid/CID");var Xi={};Ct(Xi,{identity:()=>Yt});var wc=0,Td="identity",xc=me;function Cd(r){return Wt(wc,xc(r))}var Yt={code:wc,name:Td,encode:xc,digest:Cd};function st(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 bc(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Nd(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function vr(r,...t){if(!Nd(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 vc(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");bc(r.outputLen),bc(r.blockLen)}function Er(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 Ec(r,t){vr(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var Je=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var Hn=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Jt=(r,t)=>r<<32-t|r>>>t;function Bc(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Qr(r){return typeof r=="string"&&(r=Bc(r)),vr(r),r}function Qi(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];vr(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 Br=class{clone(){return this._cloneInto()}};function $n(r){let t=n=>r().update(Qr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function Kn(r=32){if(Je&&typeof Je.getRandomValues=="function")return Je.getRandomValues(new Uint8Array(r));if(Je&&typeof Je.randomBytes=="function")return Je.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Ud(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)}var Ac=(r,t,e)=>r&t^~r&e,Sc=(r,t,e)=>r&t^r&e^t&e,Ar=class extends Br{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=Hn(this.buffer)}update(t){Er(this);let{view:e,buffer:n,blockLen:o}=this;t=Qr(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=Hn(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){Er(this),Ec(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;Ud(n,o-8,BigInt(this.length*8),i),this.process(n,0);let a=Hn(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 qn=BigInt(4294967295),ts=BigInt(32);function Ic(r,t=!1){return t?{h:Number(r&qn),l:Number(r>>ts&qn)}:{h:Number(r>>ts&qn)|0,l:Number(r&qn)|0}}function Rd(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}=Ic(r[o],t);[e[o],n[o]]=[i,s]}return[e,n]}var Ld=(r,t)=>BigInt(r>>>0)<<ts|BigInt(t>>>0),Vd=(r,t,e)=>r>>>e,_d=(r,t,e)=>r<<32-e|t>>>e,Pd=(r,t,e)=>r>>>e|t<<32-e,Fd=(r,t,e)=>r<<32-e|t>>>e,Dd=(r,t,e)=>r<<64-e|t>>>e-32,Od=(r,t,e)=>r>>>e-32|t<<64-e,Md=(r,t)=>t,Hd=(r,t)=>r,$d=(r,t,e)=>r<<e|t>>>32-e,Kd=(r,t,e)=>t<<e|r>>>32-e,qd=(r,t,e)=>t<<e-32|r>>>64-e,zd=(r,t,e)=>r<<e-32|t>>>64-e;function jd(r,t,e,n){let o=(t>>>0)+(n>>>0);return{h:r+e+(o/2**32|0)|0,l:o|0}}var Gd=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Zd=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Wd=(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,Jd=(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 Qd={fromBig:Ic,split:Rd,toBig:Ld,shrSH:Vd,shrSL:_d,rotrSH:Pd,rotrSL:Fd,rotrBH:Dd,rotrBL:Od,rotr32H:Md,rotr32L:Hd,rotlSH:$d,rotlSL:Kd,rotlBH:qd,rotlBL:zd,add:jd,add3L:Gd,add3H:Zd,add4L:Wd,add4H:Yd,add5H:Xd,add5L:Jd},q=Qd;var[t0,e0]=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))),Pe=new Uint32Array(80),Fe=new Uint32Array(80),es=class extends Ar{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)Pe[x]=t.getUint32(e),Fe[x]=t.getUint32(e+=4);for(let x=16;x<80;x++){let U=Pe[x-15]|0,F=Fe[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=Pe[x-2]|0,v=Fe[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),C=q.add4L(R,L,Fe[x-7],Fe[x-16]),$=q.add4H(C,P,D,Pe[x-7],Pe[x-16]);Pe[x]=$|0,Fe[x]=C|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:T}=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(T,F,R,e0[x],Fe[x]),v=q.add5H(b,A,U,P,t0[x],Pe[x]),D=b|0,L=q.rotrSH(n,o,28)^q.rotrBH(n,o,34)^q.rotrBH(n,o,39),C=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,T=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,C,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:T}=q.add(this.Hh|0,this.Hl|0,A|0,T|0),this.set(n,o,i,s,a,c,f,u,l,h,m,B,w,d,A,T)}roundClean(){Pe.fill(0),Fe.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 kc=$n(()=>new es);var Gn={};Ct(Gn,{aInRange:()=>_t,abool:()=>Xt,abytes:()=>Sr,bitGet:()=>a0,bitLen:()=>is,bitMask:()=>en,bitSet:()=>c0,bytesToHex:()=>xe,bytesToNumberBE:()=>be,bytesToNumberLE:()=>Oe,concatBytes:()=>ve,createHmacDrbg:()=>ss,ensureBytes:()=>at,equalBytes:()=>i0,hexToBytes:()=>Qe,hexToNumber:()=>os,inRange:()=>tn,isBytes:()=>De,memoized:()=>er,notImplemented:()=>l0,numberToBytesBE:()=>Me,numberToBytesLE:()=>tr,numberToHexUnpadded:()=>Xe,numberToVarBytesBE:()=>o0,utf8ToBytes:()=>s0,validateObject:()=>ce});var zn=BigInt(0),jn=BigInt(1),r0=BigInt(2);function De(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Sr(r){if(!De(r))throw new Error("Uint8Array expected")}function Xt(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var n0=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function xe(r){Sr(r);let t="";for(let e=0;e<r.length;e++)t+=n0[r[e]];return t}function Xe(r){let t=r.toString(16);return t.length&1?"0"+t:t}function os(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?zn:BigInt("0x"+r)}var we={_0:48,_9:57,A:65,F:70,a:97,f:102};function Tc(r){if(r>=we._0&&r<=we._9)return r-we._0;if(r>=we.A&&r<=we.F)return r-(we.A-10);if(r>=we.a&&r<=we.f)return r-(we.a-10)}function Qe(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=Tc(r.charCodeAt(i)),a=Tc(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 be(r){return os(xe(r))}function Oe(r){return Sr(r),os(xe(Uint8Array.from(r).reverse()))}function Me(r,t){return Qe(r.toString(16).padStart(t*2,"0"))}function tr(r,t){return Me(r,t).reverse()}function o0(r){return Qe(Xe(r))}function at(r,t,e){let n;if(typeof t=="string")try{n=Qe(t)}catch(i){throw new Error(r+" must be hex string or Uint8Array, cause: "+i)}else if(De(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 ve(...r){let t=0;for(let n=0;n<r.length;n++){let o=r[n];Sr(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 i0(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 s0(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var rs=r=>typeof r=="bigint"&&zn<=r;function tn(r,t,e){return rs(r)&&rs(t)&&rs(e)&&t<=r&&r<e}function _t(r,t,e,n){if(!tn(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function is(r){let t;for(t=0;r>zn;r>>=jn,t+=1);return t}function a0(r,t){return r>>BigInt(t)&jn}function c0(r,t,e){return r|(e?jn:zn)<<BigInt(t)}var en=r=>(r0<<BigInt(r-1))-jn,ns=r=>new Uint8Array(r),Cc=r=>Uint8Array.from(r);function ss(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=ns(r),o=ns(r),i=0,s=()=>{n.fill(1),o.fill(0),i=0},a=(...l)=>e(o,n,...l),c=(l=ns())=>{o=a(Cc([0]),l),n=a(),l.length!==0&&(o=a(Cc([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 ve(...h)};return(l,h)=>{s(),c(l);let m;for(;!(m=h(f()));)c();return s(),m}}var u0={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"||De(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 ce(r,t,e={}){let n=(o,i,s)=>{let a=u0[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 l0=()=>{throw new Error("not implemented")};function er(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 lt=BigInt(0),ot=BigInt(1),rr=BigInt(2),f0=BigInt(3),as=BigInt(4),Nc=BigInt(5),Uc=BigInt(8),h0=BigInt(9),d0=BigInt(16);function Q(r,t){let e=r%t;return e>=lt?e:t+e}function p0(r,t,e){if(t<lt)throw new Error("invalid exponent, negatives unsupported");if(e<=lt)throw new Error("invalid modulus");if(e===ot)return lt;let n=ot;for(;t>lt;)t&ot&&(n=n*r%e),r=r*r%e,t>>=ot;return n}function it(r,t,e){let n=r;for(;t-- >lt;)n*=n,n%=e;return n}function Zn(r,t){if(r===lt)throw new Error("invert: expected non-zero number");if(t<=lt)throw new Error("invert: expected positive modulus, got "+t);let e=Q(r,t),n=t,o=lt,i=ot,s=ot,a=lt;for(;e!==lt;){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!==ot)throw new Error("invert: does not exist");return Q(o,t)}function g0(r){let t=(r-ot)/rr,e,n,o;for(e=r-ot,n=0;e%rr===lt;e/=rr,n++);for(o=rr;o<r&&p0(o,t,r)!==r-ot;o++)if(o>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+ot)/as;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+ot)/rr;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,ot<<BigInt(f-m-1));u=a.sqr(B),l=a.mul(l,B),h=a.mul(h,u),f=m}return l}}function m0(r){if(r%as===f0){let t=(r+ot)/as;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%Uc===Nc){let t=(r-Nc)/Uc;return function(n,o){let i=n.mul(o,rr),s=n.pow(i,t),a=n.mul(o,s),c=n.mul(n.mul(a,rr),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%d0,g0(r)}var Rc=(r,t)=>(Q(r,t)&ot)===ot,y0=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function cs(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=y0.reduce((n,o)=>(n[o]="function",n),t);return ce(r,e)}function w0(r,t,e){if(e<lt)throw new Error("invalid exponent, negatives unsupported");if(e===lt)return r.ONE;if(e===ot)return t;let n=r.ONE,o=t;for(;e>lt;)e&ot&&(n=r.mul(n,o)),o=r.sqr(o),e>>=ot;return n}function x0(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 us(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function He(r,t,e=!1,n={}){if(r<=lt)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:o,nByteLength:i}=us(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:en(o),ZERO:lt,ONE:ot,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return lt<=c&&c<r},is0:c=>c===lt,isOdd:c=>(c&ot)===ot,neg:c=>Q(-c,r),eql:(c,f)=>c===f,sqr:c=>Q(c*c,r),add:(c,f)=>Q(c+f,r),sub:(c,f)=>Q(c-f,r),mul:(c,f)=>Q(c*f,r),pow:(c,f)=>w0(a,c,f),div:(c,f)=>Q(c*Zn(f,r),r),sqrN:c=>c*c,addN:(c,f)=>c+f,subN:(c,f)=>c-f,mulN:(c,f)=>c*f,inv:c=>Zn(c,r),sqrt:n.sqrt||(c=>(s||(s=m0(r)),s(a,c))),invertBatch:c=>x0(a,c),cmov:(c,f,u)=>u?f:c,toBytes:c=>e?tr(c,i):Me(c,i),fromBytes:c=>{if(c.length!==i)throw new Error("Field.fromBytes: expected "+i+" bytes, got "+c.length);return e?Oe(c):be(c)}});return Object.freeze(a)}function Lc(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 ls(r){let t=Lc(r);return t+Math.ceil(t/2)}function Vc(r,t,e=!1){let n=r.length,o=Lc(t),i=ls(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=e?Oe(r):be(r),a=Q(s,t-ot)+ot;return e?tr(a,o):Me(a,o)}var _c=BigInt(0),Wn=BigInt(1);function fs(r,t){let e=t.negate();return r?e:t}function Pc(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function hs(r,t){Pc(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function v0(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 E0(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 ds=new WeakMap,Fc=new WeakMap;function ps(r){return Fc.get(r)||1}function Yn(r,t){return{constTimeNegate:fs,hasPrecomputes(e){return ps(e)!==1},unsafeLadder(e,n,o=r.ZERO){let i=e;for(;n>_c;)n&Wn&&(o=o.add(i)),i=i.double(),n>>=Wn;return o},precomputeWindow(e,n){let{windows:o,windowSize:i}=hs(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}=hs(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+=Wn);let w=m,d=m+Math.abs(B)-1,A=h%2!==0,T=B<0;B===0?c=c.add(fs(A,n[w])):a=a.add(fs(T,n[d]))}return{p:a,f:c}},wNAFUnsafe(e,n,o,i=r.ZERO){let{windows:s,windowSize:a}=hs(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===_c)break;let m=Number(o&c);if(o>>=u,m>a&&(m-=f,o+=Wn),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=ds.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&ds.set(n,o(i))),i},wNAFCached(e,n,o){let i=ps(e);return this.wNAF(i,this.getPrecomputes(i,e,o),n)},wNAFCachedUnsafe(e,n,o,i){let s=ps(e);return s===1?this.unsafeLadder(e,n,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,o),n,i)},setWindowSize(e,n){Pc(n,t),Fc.set(e,n),ds.delete(e)}}}function Jn(r,t,e,n){if(v0(e,r),E0(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let o=r.ZERO,i=is(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 rn(r){return cs(r.Fp),ce(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...us(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Qt=BigInt(0),Pt=BigInt(1),Xn=BigInt(2),B0=BigInt(8),A0={zip215:!0};function S0(r){let t=rn(r);return ce(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Dc(r){let t=S0(r),{Fp:e,n,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:c}=t,f=Xn<<BigInt(a*8)-Pt,u=e.create,l=He(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:Qt}}}),m=t.adjustScalarBytes||(g=>g),B=t.domain||((g,p,E)=>{if(Xt("phflag",E),p.length||E)throw new Error("Contexts/pre-hash are not supported");return g});function w(g,p){_t("coordinate "+g,p,Qt,f)}function d(g){if(!(g instanceof x))throw new Error("ExtendedPoint expected")}let A=er((g,p)=>{let{ex:E,ey:N,ez:O}=g,M=g.is0();p==null&&(p=M?B0:e.inv(O));let z=u(E*p),Z=u(N*p),K=u(O*p);if(M)return{x:Qt,y:Pt};if(K!==Pt)throw new Error("invZ was invalid");return{x:z,y:Z}}),T=er(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,Z=u(N*N),K=u(O*O),J=u(M*M),et=u(J*J),ht=u(Z*p),dt=u(J*u(ht+K)),yt=u(et+u(E*u(Z*K)));if(dt!==yt)throw new Error("bad point: equation left != right (1)");let vt=u(N*O),Rt=u(M*z);if(vt!==Rt)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,Pt,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 Jn(x,l,p,E)}_setWindowSize(p){P.setWindowSize(this,p)}assertValidity(){T(this)}equals(p){d(p);let{ex:E,ey:N,ez:O}=this,{ex:M,ey:z,ez:Z}=p,K=u(E*Z),J=u(M*O),et=u(N*Z),ht=u(z*O);return K===J&&et===ht}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),Z=u(Xn*u(O*O)),K=u(p*M),J=E+N,et=u(u(J*J)-M-z),ht=K+z,dt=ht-Z,yt=K-z,vt=u(et*dt),Rt=u(ht*yt),Tt=u(et*yt),ae=u(dt*ht);return new x(vt,Rt,ae,Tt)}add(p){d(p);let{a:E,d:N}=t,{ex:O,ey:M,ez:z,et:Z}=this,{ex:K,ey:J,ez:et,et:ht}=p;if(E===BigInt(-1)){let Ga=u((M-O)*(J+K)),Za=u((M+O)*(J-K)),Fi=u(Za-Ga);if(Fi===Qt)return this.double();let Wa=u(z*Xn*ht),Ya=u(Z*Xn*et),Ja=Ya+Wa,Xa=Za+Ga,Qa=Ya-Wa,yh=u(Ja*Fi),wh=u(Xa*Qa),xh=u(Ja*Qa),bh=u(Fi*Xa);return new x(yh,wh,bh,xh)}let dt=u(O*K),yt=u(M*J),vt=u(Z*N*ht),Rt=u(z*et),Tt=u((O+M)*(K+J)-dt-yt),ae=Rt-vt,ge=Rt+vt,Wr=u(yt-E*dt),dh=u(Tt*ae),ph=u(ge*Wr),gh=u(Tt*Wr),mh=u(ae*ge);return new x(dh,ph,mh,gh)}subtract(p){return this.add(p.negate())}wNAF(p){return P.wNAFCached(this,p,x.normalizeZ)}multiply(p){let E=p;_t("scalar",E,Pt,n);let{p:N,f:O}=this.wNAF(E);return x.normalizeZ([N,O])[0]}multiplyUnsafe(p,E=x.ZERO){let N=p;return _t("scalar",N,Qt,n),N===Qt?F:this.is0()||N===Pt?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===Pt?this:this.multiplyUnsafe(p)}static fromHex(p,E=!1){let{d:N,a:O}=t,M=e.BYTES;p=at("pointHex",p,M),Xt("zip215",E);let z=p.slice(),Z=p[M-1];z[M-1]=Z&-129;let K=Oe(z),J=E?f:e.ORDER;_t("pointHex.y",K,Qt,J);let et=u(K*K),ht=u(et-Pt),dt=u(N*et-O),{isValid:yt,value:vt}=h(ht,dt);if(!yt)throw new Error("Point.fromHex: invalid y coordinate");let Rt=(vt&Pt)===Pt,Tt=(Z&128)!==0;if(!E&&vt===Qt&&Tt)throw new Error("Point.fromHex: x=0 and x_0=1");return Tt!==Rt&&(vt=u(-vt)),x.fromAffine({x:vt,y:K})}static fromPrivateKey(p){return v(p).point}toRawBytes(){let{x:p,y:E}=this.toAffine(),N=tr(E,e.BYTES);return N[N.length-1]|=p&Pt?128:0,N}toHex(){return xe(this.toRawBytes())}}x.BASE=new x(t.Gx,t.Gy,Pt,u(t.Gx*t.Gy)),x.ZERO=new x(Qt,Pt,Pt,Qt);let{BASE:U,ZERO:F}=x,P=Yn(x,a*8);function R(g){return Q(g,n)}function b(g){return R(Oe(g))}function v(g){let p=e.BYTES;g=at("private key",g,p);let E=at("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),Z=z.toRawBytes();return{head:N,prefix:O,scalar:M,point:z,pointBytes:Z}}function D(g){return v(g).pointBytes}function L(g=new Uint8Array,...p){let E=ve(...p);return b(i(B(E,at("context",g),!!o)))}function C(g,p,E={}){g=at("message",g),o&&(g=o(g));let{prefix:N,scalar:O,pointBytes:M}=v(p),z=L(E.context,N,g),Z=U.multiply(z).toRawBytes(),K=L(E.context,Z,M,g),J=R(z+K*O);_t("signature.s",J,Qt,n);let et=ve(Z,tr(J,e.BYTES));return at("result",et,e.BYTES*2)}let $=A0;function S(g,p,E,N=$){let{context:O,zip215:M}=N,z=e.BYTES;g=at("signature",g,2*z),p=at("message",p),E=at("publicKey",E,z),M!==void 0&&Xt("zip215",M),o&&(p=o(p));let Z=Oe(g.slice(z,2*z)),K,J,et;try{K=x.fromHex(E,M),J=x.fromHex(g.slice(0,z),M),et=U.multiplyUnsafe(Z)}catch{return!1}if(!M&&K.isSmallOrder())return!1;let ht=L(O,J.toRawBytes(),K.toRawBytes(),p);return J.add(K.multiplyUnsafe(ht)).subtract(et).clearCofactor().equals(x.ZERO)}return U._setWindowSize(8),{CURVE:t,getPublicKey:D,sign:C,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 gs=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Oc=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),By=BigInt(0),I0=BigInt(1),Mc=BigInt(2),Ay=BigInt(3),k0=BigInt(5),T0=BigInt(8);function C0(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),o=BigInt(80),i=gs,a=r*r%i*r%i,c=it(a,Mc,i)*a%i,f=it(c,I0,i)*r%i,u=it(f,k0,i)*f%i,l=it(u,t,i)*u%i,h=it(l,e,i)*l%i,m=it(h,n,i)*h%i,B=it(m,o,i)*m%i,w=it(B,o,i)*m%i,d=it(w,t,i)*u%i;return{pow_p_5_8:it(d,Mc,i)*r%i,b2:a}}function N0(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function U0(r,t){let e=gs,n=Q(t*t*t,e),o=Q(n*n*t,e),i=C0(r*o).pow_p_5_8,s=Q(r*n*i,e),a=Q(t*s*s,e),c=s,f=Q(s*Oc,e),u=a===r,l=a===Q(-r,e),h=a===Q(-r*Oc,e);return u&&(s=c),(l||h)&&(s=f),Rc(s,e)&&(s=Q(-s,e)),{isValid:u||l,value:s}}var R0=He(gs,void 0,!0),L0={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:R0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:T0,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:kc,randomBytes:Kn,adjustScalarBytes:N0,uvRatio:U0},Hc=Dc(L0);var Qn=32;function $c(r,t,e){return Hc.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var to=class{type="Ed25519";raw;constructor(t){this.raw=ms(t,Qn)}toMultihash(){return Yt.digest(eo(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,e){return $c(this.raw,e,t)}};function ys(r){return r=ms(r,Qn),new to(r)}function ms(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new Et(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function Ee(r=0){return new Uint8Array(r)}function Ft(r=0){return new Uint8Array(r)}var _0=Math.pow(2,7),P0=Math.pow(2,14),F0=Math.pow(2,21),ws=Math.pow(2,28),xs=Math.pow(2,35),bs=Math.pow(2,42),vs=Math.pow(2,49),Y=128,Bt=127;function Dt(r){if(r<_0)return 1;if(r<P0)return 2;if(r<F0)return 3;if(r<ws)return 4;if(r<xs)return 5;if(r<bs)return 6;if(r<vs)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Es(r,t,e=0){switch(Dt(r)){case 8:t[e++]=r&255|Y,r/=128;case 7:t[e++]=r&255|Y,r/=128;case 6:t[e++]=r&255|Y,r/=128;case 5:t[e++]=r&255|Y,r/=128;case 4:t[e++]=r&255|Y,r>>>=7;case 3:t[e++]=r&255|Y,r>>>=7;case 2:t[e++]=r&255|Y,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function D0(r,t,e=0){switch(Dt(r)){case 8:t.set(e++,r&255|Y),r/=128;case 7:t.set(e++,r&255|Y),r/=128;case 6:t.set(e++,r&255|Y),r/=128;case 5:t.set(e++,r&255|Y),r/=128;case 4:t.set(e++,r&255|Y),r>>>=7;case 3:t.set(e++,r&255|Y),r>>>=7;case 2:t.set(e++,r&255|Y),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Bs(r,t){let e=r[t],n=0;if(n+=e&Bt,e<Y||(e=r[t+1],n+=(e&Bt)<<7,e<Y)||(e=r[t+2],n+=(e&Bt)<<14,e<Y)||(e=r[t+3],n+=(e&Bt)<<21,e<Y)||(e=r[t+4],n+=(e&Bt)*ws,e<Y)||(e=r[t+5],n+=(e&Bt)*xs,e<Y)||(e=r[t+6],n+=(e&Bt)*bs,e<Y)||(e=r[t+7],n+=(e&Bt)*vs,e<Y))return n;throw new RangeError("Could not decode varint")}function O0(r,t){let e=r.get(t),n=0;if(n+=e&Bt,e<Y||(e=r.get(t+1),n+=(e&Bt)<<7,e<Y)||(e=r.get(t+2),n+=(e&Bt)<<14,e<Y)||(e=r.get(t+3),n+=(e&Bt)<<21,e<Y)||(e=r.get(t+4),n+=(e&Bt)*ws,e<Y)||(e=r.get(t+5),n+=(e&Bt)*xs,e<Y)||(e=r.get(t+6),n+=(e&Bt)*bs,e<Y)||(e=r.get(t+7),n+=(e&Bt)*vs,e<Y))return n;throw new RangeError("Could not decode varint")}function Ir(r,t,e=0){return t==null&&(t=Ft(Dt(r))),t instanceof Uint8Array?Es(r,t,e):D0(r,t,e)}function nr(r,t=0){return r instanceof Uint8Array?Bs(r,t):O0(r,t)}var As=new Float32Array([-0]),$e=new Uint8Array(As.buffer);function zc(r,t,e){As[0]=r,t[e]=$e[0],t[e+1]=$e[1],t[e+2]=$e[2],t[e+3]=$e[3]}function jc(r,t){return $e[0]=r[t],$e[1]=r[t+1],$e[2]=r[t+2],$e[3]=r[t+3],As[0]}var Ss=new Float64Array([-0]),At=new Uint8Array(Ss.buffer);function Gc(r,t,e){Ss[0]=r,t[e]=At[0],t[e+1]=At[1],t[e+2]=At[2],t[e+3]=At[3],t[e+4]=At[4],t[e+5]=At[5],t[e+6]=At[6],t[e+7]=At[7]}function Zc(r,t){return At[0]=r[t],At[1]=r[t+1],At[2]=r[t+2],At[3]=r[t+3],At[4]=r[t+4],At[5]=r[t+5],At[6]=r[t+6],At[7]=r[t+7],Ss[0]}var M0=BigInt(Number.MAX_SAFE_INTEGER),H0=BigInt(Number.MIN_SAFE_INTEGER),Mt=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 or;if(t<M0&&t>H0)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>Wc&&(o=0n,++n>Wc&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(t){if(t===0)return or;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):or}},or=new Mt(0,0);or.toBigInt=function(){return 0n};or.zzEncode=or.zzDecode=function(){return this};or.length=function(){return 1};var Wc=4294967296n;function Yc(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 Jc(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 Is(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 te(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function ro(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var ks=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,te(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 te(this,4);return ro(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw te(this,4);return ro(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw te(this,4);let t=jc(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw te(this,4);let t=Zc(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 te(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Jc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw te(this,t);this.pos+=t}else do if(this.pos>=this.len)throw te(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 Mt(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 te(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 te(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 te(this,8);let t=ro(this.buf,this.pos+=4),e=ro(this.buf,this.pos+=4);return new Mt(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=Bs(this.buf,this.pos);return this.pos+=Dt(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 Ts(r){return new ks(r instanceof Uint8Array?r:r.subarray())}function kr(r,t,e){let n=Ts(r);return t.decode(n,void 0,e)}var Cs={};Ct(Cs,{base10:()=>$0});var $0=Le({prefix:"9",name:"base10",alphabet:"0123456789"});var Ns={};Ct(Ns,{base16:()=>K0,base16upper:()=>q0});var K0=ct({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),q0=ct({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Us={};Ct(Us,{base2:()=>z0});var z0=ct({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Rs={};Ct(Rs,{base256emoji:()=>Y0});var Qc=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}"),j0=Qc.reduce((r,t,e)=>(r[e]=t,r),[]),G0=Qc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Z0(r){return r.reduce((t,e)=>(t+=j0[e],t),"")}function W0(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let o=G0[n];if(o==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(o)}return new Uint8Array(t)}var Y0=mr({prefix:"\u{1F680}",name:"base256emoji",encode:Z0,decode:W0});var Ls={};Ct(Ls,{base8:()=>J0});var J0=ct({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Vs={};Ct(Vs,{identity:()=>X0});var X0=mr({prefix:"\0",name:"identity",encode:r=>ic(r),decode:r=>oc(r)});var iw=new TextEncoder,sw=new TextDecoder;var Fs={};Ct(Fs,{sha256:()=>nn,sha512:()=>ep});function Ps({name:r,code:t,encode:e}){return new _s(r,t,e)}var _s=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?Wt(this.code,e):e.then(n=>Wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function eu(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var nn=Ps({name:"sha2-256",code:18,encode:eu("SHA-256")}),ep=Ps({name:"sha2-512",code:19,encode:eu("SHA-512")});var on={...Vs,...Us,...Ls,...Cs,...Ns,...qi,...Wi,...zi,...Gi,...Rs},ww={...Fs,...Xi};function nu(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var ru=nu("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ds=nu("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=Ft(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),rp={utf8:ru,"utf-8":ru,hex:on.base16,latin1:Ds,ascii:Ds,binary:Ds,...on},no=rp;function j(r,t="utf8"){let e=no[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function Os(r){let t=r??8192,e=t>>>1,n,o=t;return function(s){if(s<1||s>e)return Ft(s);o+s>t&&(n=Ft(t),o=0);let a=n.subarray(o,o+=s);return o&7&&(o=(o|7)+1),a}}var ir=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Ms(){}var $s=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},np=Os();function op(r){return globalThis.Buffer!=null?Ft(r):np(r)}var an=class{len;head;tail;states;constructor(){this.len=0,this.head=new ir(Ms,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new ir(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Ks((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(oo,10,Mt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Mt.fromBigInt(t);return this._push(oo,e.length(),e)}uint64Number(t){return this._push(Es,Dt(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=Mt.fromBigInt(t).zzEncode();return this._push(oo,e.length(),e)}sint64Number(t){let e=Mt.fromNumber(t).zzEncode();return this._push(oo,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Hs,1,t?1:0)}fixed32(t){return this._push(sn,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Mt.fromBigInt(t);return this._push(sn,4,e.lo)._push(sn,4,e.hi)}fixed64Number(t){let e=Mt.fromNumber(t);return this._push(sn,4,e.lo)._push(sn,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(zc,4,t)}double(t){return this._push(Gc,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Hs,1,0):this.uint32(e)._push(sp,e,t)}string(t){let e=Yc(t);return e!==0?this.uint32(e)._push(Is,e,t):this._push(Hs,1,0)}fork(){return this.states=new $s(this),this.head=this.tail=new ir(Ms,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 ir(Ms,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=op(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Hs(r,t,e){t[e]=r&255}function ip(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Ks=class extends ir{next;constructor(t,e){super(ip,t,e),this.next=void 0}};function oo(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 sn(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 sp(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(an.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ap,t,r),this},an.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(cp,t,r),this});function ap(r,t,e){t.set(r,e)}function cp(r,t,e){r.length<40?Is(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(j(r),e)}function qs(){return new an}function Tr(r,t){let e=qs();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var Cr;(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"})(Cr||(Cr={}));function io(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function cn(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 io("enum",Cr.VARINT,e,n)}function Nr(r,t){return io("message",Cr.LENGTH_DELIMITED,r,t)}var ft;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ft||(ft={}));var zs;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(zs||(zs={}));(function(r){r.codec=()=>cn(zs)})(ft||(ft={}));var ue;(function(r){let t;r.codec=()=>(t==null&&(t=Nr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ft.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=ft.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return i})),t),r.encode=e=>Tr(e,r.codec()),r.decode=(e,n)=>kr(e,r.codec(),n)})(ue||(ue={}));var js;(function(r){let t;r.codec=()=>(t==null&&(t=Nr((e,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ft.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=ft.codec().decode(e);break}case 2:{i.Data=e.bytes();break}default:{e.skipType(a&7);break}}}return i})),t),r.encode=e=>Tr(e,r.codec()),r.decode=(e,n)=>kr(e,r.codec(),n)})(js||(js={}));var wn={};Ct(wn,{MAX_RSA_KEY_SIZE:()=>Jo,generateRSAKeyPair:()=>tl,jwkToJWKKeyPair:()=>el,jwkToPkcs1:()=>Ap,jwkToPkix:()=>ea,jwkToRSAPrivateKey:()=>Qu,pkcs1ToJwk:()=>Yu,pkcs1ToRSAPrivateKey:()=>Xu,pkixToJwk:()=>Ju,pkixToRSAPublicKey:()=>ra});var up=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]),Ke=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),qe=new Uint32Array(64),Gs=class extends Ar{constructor(){super(64,32,8,!1),this.A=Ke[0]|0,this.B=Ke[1]|0,this.C=Ke[2]|0,this.D=Ke[3]|0,this.E=Ke[4]|0,this.F=Ke[5]|0,this.G=Ke[6]|0,this.H=Ke[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)qe[l]=t.getUint32(e,!1);for(let l=16;l<64;l++){let h=qe[l-15],m=qe[l-2],B=Jt(h,7)^Jt(h,18)^h>>>3,w=Jt(m,17)^Jt(m,19)^m>>>10;qe[l]=w+qe[l-7]+B+qe[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=Jt(a,6)^Jt(a,11)^Jt(a,25),m=u+h+Ac(a,c,f)+up[l]+qe[l]|0,w=(Jt(n,2)^Jt(n,13)^Jt(n,22))+Sc(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(){qe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ur=$n(()=>new Gs);var G=_n(iu());function sr(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 ze(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 co(...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 Ws(){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=sr(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,sr(i,8)-n}function su(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=ze(s,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=ze(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 au(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 Ot(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 Qw=Math.log(2);function uo(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Ys(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 ke(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 ln=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return Ys(this.items)}},un=[new Uint8Array([1])],cu="0123456789";var Pr="",ee=new ArrayBuffer(0),Js=new Uint8Array(0),fn="EndOfContent",lu="OCTET STRING",fu="BIT STRING";function Te(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?G.BufferSourceConverter.toUint8Array(i.valueHex):Js}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(!ke(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",ee)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:G.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var Ae=class{constructor({blockLength:t=0,error:e=Pr,warnings:n=[],valueBeforeDecode:o=Js}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=G.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:G.Convert.ToHex(this.valueBeforeDecodeView)}}};Ae.NAME="baseBlock";var St=class extends Ae{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'")}};St.NAME="valueBlock";var lo=class extends Te(Ae){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?G.BufferSourceConverter.toUint8Array(t.valueHex):Js,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",ee}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=ze(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=G.BufferSourceConverter.toUint8Array(t);if(!ke(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=sr(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}}};lo.NAME="identificationBlock";var fo=class extends Ae{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=G.BufferSourceConverter.toUint8Array(t);if(!ke(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=sr(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=ze(this.length,8);if(o.byteLength>127)return this.error="Too big length",ee;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}}};fo.NAME="lengthBlock";var V={},wt=class extends Ae{constructor({name:t=Pr,optional:e=!1,primitiveSchema:n,...o}={},i){super(o),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new lo(o),this.lenBlock=new fo(o),this.valueBlock=i?new i(o):new St(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 ln;e||hu(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?ee: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():G.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${G.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 au(e,n)}};wt.NAME="BaseBlock";function hu(r){if(r instanceof V.Constructed)for(let t of r.valueBlock.value)hu(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var ho=class extends wt{constructor({value:t=Pr,...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}'`}};ho.NAME="BaseStringBlock";var po=class extends Te(St){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};po.NAME="PrimitiveValueBlock";var du,go=class extends wt{constructor(t={}){super(t,po),this.idBlock.isConstructed=!1}};du=go;V.Primitive=du;go.NAME="PRIMITIVE";function wp(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 Wo(r,t=0,e=r.length){let n=t,o=new wt({},St),i=new Ae;if(!ke(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=wt;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=wp(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 Xs(r){if(!r.byteLength){let t=new wt({},St);return t.error="Input buffer has zero length",{offset:-1,result:t}}return Wo(G.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function xp(r,t){return r?1:t}var le=class extends St{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let o=G.BufferSourceConverter.toUint8Array(t);if(!ke(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(;xp(this.isIndefiniteForm,n)>0;){let s=Wo(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===fn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===fn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(t,e){let n=e||new ln;for(let o=0;o<this.value.length;o++)this.value[o].toBER(t,n);return e?ee:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};le.NAME="ConstructedValueBlock";var pu,je=class extends wt{constructor(t={}){super(t,le),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
4
  `).map(o=>` ${o}`).join(`
5
- `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
6
- ${e.join(`
7
- `)}`:`${t} :`}};hu=zt;L.Constructed=hu;zt.NAME="CONSTRUCTED";var po=class extends Se{fromBER(e,t,n){return t}toBER(e){return tt}};po.override="EndOfContentValueBlock";var du,mo=class extends we{constructor(e={}){super(e,po),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};du=mo;L.EndOfContent=du;mo.NAME=un;var pu,Rr=class extends we{constructor(e={}){super(e,Se),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,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,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let o=new Uint8Array(n);o[0]=5,o[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};pu=Rr;L.Null=pu;Rr.NAME="NULL";var go=class extends Tt(Se){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=G.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let o=G.BufferSourceConverter.toUint8Array(e);return It(this,o,t,n)?(this.valueHexView=o.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Gs.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};go.NAME="BooleanValueBlock";var mu,yo=class extends we{constructor(e={}){super(e,go),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};mu=yo;L.Boolean=mu;yo.NAME="BOOLEAN";var wo=class extends Tt(lt){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let o=0;if(this.isConstructed){if(this.isHexOnly=!1,o=lt.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let i=0;i<this.value.length;i++){let s=this.value[i].constructor.NAME;if(s===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==cu)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,o=super.fromBER(e,t,n),this.blockLength=n;return o}toBER(e,t){return this.isConstructed?lt.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};wo.NAME="OctetStringValueBlock";var gu,xo=class r extends we{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},wo),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,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),t;if(!this.valueBlock.isConstructed){let i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(i.byteLength){let s=Go(i,0,i.byteLength);s.offset!==-1&&s.offset===n&&(this.valueBlock.value=[s.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?zt.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return G.BufferSourceConverter.concat(e)}};gu=xo;L.OctetString=gu;xo.NAME=cu;var bo=class extends Tt(lt){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let o=-1;if(this.isConstructed){if(o=lt.prototype.fromBER.call(this,e,t,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===un){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==uu)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=G.BufferSourceConverter.toUint8Array(e);if(!It(this,i,t,n))return-1;let s=i.subarray(t,t+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=Go(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,t+n}toBER(e,t){if(this.isConstructed)return lt.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return tt;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}}};bo.NAME="BitStringValueBlock";var yu,_r=class extends we{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return zt.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let o of t)e.push(o.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};yu=_r;L.BitString=yu;_r.NAME=uu;var wu;function mp(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),o=new Uint8Array(e),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]+t[0];break;default:f=i[s-l]+t[0]}switch(t[0]=f/10,!0){case l>=i.length:i=so(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return t[0]>0&&(i=so(t,i)),i}function au(r){if(r>=an.length)for(let e=an.length;e<=r;e++){let t=new Uint8Array([0]),n=an[e-1].slice(0);for(let o=n.length-1;o>=0;o--){let i=new Uint8Array([(n[o]<<1)+t[0]]);t[0]=i[0]/10,n[o]=i[0]%10}t[0]>0&&(n=so(t,n)),an.push(n)}return an[r]}function gp(r,e){let t=0,n=new Uint8Array(r),o=new Uint8Array(e),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]-t,!0){case f<0:t=1,i[s-u]=f+10;break;default:t=0,i[s-u]=f}if(t>0)for(let l=s-c+1;l>=0;l--,u++)if(f=i[s-u]-t,f<0)t=1,i[s-u]=f+10;else{t=0,i[s-u]=f;break}return i.slice()}var ln=class extends Tt(Se){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}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=Gs.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(ou(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,o=0){let i=this.fromBER(e,t,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(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let o=super.fromBER(e,t,n);return o===-1||this.setValueHex(),o}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=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 e:t=gp(au(n),t),s="-";break;default:t=mp(t,au(n))}n++,o>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(s+=su.charAt(t[c]));return a===!1&&(s+=su.charAt(0)),s}};wu=ln;ln.NAME="IntegerValueBlock";Object.defineProperty(wu.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var xu,xe=class r extends we{constructor(e={}){super(e,ln),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return ao(),BigInt(this.valueBlock.toString())}static fromBigInt(e){ao();let t=BigInt(e),n=new cn,o=t.toString(16).replace(/^-/,""),i=new Uint8Array(G.Convert.FromHex(o));if(t<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${G.Convert.ToHex(a)}`)+t,u=G.BufferSourceConverter.toUint8Array(G.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 e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}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()}`}};xu=xe;L.Integer=xu;xe.NAME="INTEGER";var bu,vo=class extends xe{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};bu=vo;L.Enumerated=bu;vo.NAME="ENUMERATED";var fn=class extends Tt(Se){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let o=G.BufferSourceConverter.toUint8Array(e);if(!It(this,o,t,n))return-1;let i=o.subarray(t,t+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=ir(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){ao();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let o=0;o<n.length;o++)n[o]=parseInt(t.slice(o*7,o*7+7),2)+(o+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)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 t=qt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",tt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n}toString(){let e="";if(this.isHexOnly)e=G.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};fn.NAME="sidBlock";var Eo=class extends Se{constructor({value:e=Vr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new fn;if(o=i.fromBER(e,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(e){let t=[];for(let n=0;n<this.value.length;n++){let o=this.value[n].toBER(e);if(o.byteLength===0)return this.error=this.value[n].error,tt;t.push(o)}return Zs(t)}fromString(e){this.value=[];let t=0,n=0,o="",i=!1;do if(n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=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 fn;if(o>Number.MAX_SAFE_INTEGER){ao();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 e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t?(o=`{${o}}`,this.value[n].isFirstSid?e=`2.{${o} - 80}`:e+=o):e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Eo.NAME="ObjectIdentifierValueBlock";var vu,Lr=class extends we{constructor(e={}){super(e,Eo),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};vu=Lr;L.ObjectIdentifier=vu;Lr.NAME="OBJECT IDENTIFIER";var hn=class extends Tt(Bt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let o=G.BufferSourceConverter.toUint8Array(e);if(!It(this,o,t,n))return-1;let i=o.subarray(t,t+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=ir(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)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 t=qt(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",tt;let n=new Uint8Array(t.byteLength);if(!e){let o=new Uint8Array(t),i=t.byteLength-1;for(let s=0;s<i;s++)n[s]=o[s]|128;n[i]=o[i]}return n.buffer}toString(){let e="";return this.isHexOnly?e=G.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};hn.NAME="relativeSidBlock";var Bo=class extends Se{constructor({value:e=Vr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let o=t;for(;n>0;){let i=new hn;if(o=i.fromBER(e,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(e,t){let n=[];for(let o=0;o<this.value.length;o++){let i=this.value[o].toBER(e);if(i.byteLength===0)return this.error=this.value[o].error,tt;n.push(i)}return Zs(n)}fromString(e){this.value=[];let t=0,n=0,o="";do{n=e.indexOf(".",t),n===-1?o=e.substring(t):o=e.substring(t,n),t=n+1;let i=new hn;if(i.valueDec=parseInt(o,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let o=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(o=`{${o}}`),e+=o}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Bo.NAME="RelativeObjectIdentifierValueBlock";var Eu,Ao=class extends we{constructor(e={}){super(e,Bo),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Eu=Ao;L.RelativeObjectIdentifier=Eu;Ao.NAME="RelativeObjectIdentifier";var Bu,At=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Bu=At;L.Sequence=Bu;At.NAME="SEQUENCE";var Au,So=class extends zt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Au=So;L.Set=Au;So.NAME="SET";var Io=class extends Tt(Se){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=Vr}toJSON(){return{...super.toJSON(),value:this.value}}};Io.NAME="StringValueBlock";var To=class extends Io{};To.NAME="SimpleStringValueBlock";var Ce=class extends lo{constructor({...e}={}){super(e,To)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let o=0;o<t;o++)n[o]=e.charCodeAt(o);this.valueBlock.value=e}};Ce.NAME="SIMPLE STRING";var ko=class extends Ce{fromBuffer(e){this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=G.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=G.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf8String(e)),this.valueBlock.value=e}};ko.NAME="Utf8StringValueBlock";var Su,St=class extends ko{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Su=St;L.Utf8String=Su;St.NAME="UTF8String";var Co=class extends Ce{fromBuffer(e){this.valueBlock.value=G.Convert.ToUtf16String(e),this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf16String(e))}};Co.NAME="BmpStringValueBlock";var Iu,No=class extends Co{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Iu=No;L.BmpString=Iu;No.NAME="BMPString";var Uo=class extends Ce{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);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(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let o=0;o<t;o++){let i=qt(e.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=e}};Uo.NAME="UniversalStringValueBlock";var Tu,Ro=class extends Uo{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Tu=Ro;L.UniversalString=Tu;Ro.NAME="UniversalString";var ku,_o=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};ku=_o;L.NumericString=ku;_o.NAME="NumericString";var Cu,Lo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Cu=Lo;L.PrintableString=Cu;Lo.NAME="PrintableString";var Nu,Vo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Nu=Vo;L.TeletexString=Nu;Vo.NAME="TeletexString";var Uu,Po=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Uu=Po;L.VideotexString=Uu;Po.NAME="VideotexString";var Ru,Fo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Ru=Fo;L.IA5String=Ru;Fo.NAME="IA5String";var _u,Do=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};_u=Do;L.GraphicString=_u;Do.NAME="GraphicString";var Lu,dn=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Lu=dn;L.VisibleString=Lu;dn.NAME="VisibleString";var Vu,Mo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Vu=Mo;L.GeneralString=Vu;Mo.NAME="GeneralString";var Pu,Oo=class extends Ce{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Pu=Oo;L.CharacterString=Pu;Oo.NAME="CharacterString";var Fu,pn=class extends dn{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let o=0;o<e.length;o++)this.valueBlock.valueHexView[o]=e.charCodeAt(o)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,G.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);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(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Fe(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Fe(this.month,2),t[2]=Fe(this.day,2),t[3]=Fe(this.hour,2),t[4]=Fe(this.minute,2),t[5]=Fe(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}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}}};Fu=pn;L.UTCTime=Fu;pn.NAME="UTCTime";var Du,Ho=class extends pn{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",o="",i=0,s,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let l=new Number(e[e.length-1]);if(isNaN(l.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){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("+"),g="";if(h===-1&&(h=n.indexOf("-"),l=-1),h!==-1){if(g=n.substring(h+1),n=n.substring(0,h),g.length!==2&&g.length!==4)throw new Error("Wrong input string for conversion");let B=parseInt(g.substring(0,2),10);if(isNaN(B.valueOf()))throw new Error("Wrong input string for conversion");if(a=l*B,g.length===4){if(B=parseInt(g.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(t===!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(e="iso"){if(e==="iso"){let t=[];return t.push(Fe(this.year,4)),t.push(Fe(this.month,2)),t.push(Fe(this.day,2)),t.push(Fe(this.hour,2)),t.push(Fe(this.minute,2)),t.push(Fe(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Fe(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Du=Ho;L.GeneralizedTime=Du;Ho.NAME="GeneralizedTime";var Mu,$o=class extends St{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Mu=$o;L.DATE=Mu;$o.NAME="DATE";var Ou,Ko=class extends St{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Ou=Ko;L.TimeOfDay=Ou;Ko.NAME="TimeOfDay";var Hu,qo=class extends St{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Hu=qo;L.DateTime=Hu;qo.NAME="DateTime";var $u,zo=class extends St{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};$u=zo;L.Duration=$u;zo.NAME="Duration";var Ku,jo=class extends St{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Ku=jo;L.TIME=Ku;jo.NAME="TIME";function ne(r,e="utf8"){let t=to[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var mn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},Zo=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var qu={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new Zo("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 e}};var jt=qu;async function zu(r){let e=await jt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await wp(e);return{privateKey:t[0],publicKey:t[1]}}async function ju(r,e){let t=await jt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await jt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Gu(r,e,t){let n=await jt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return jt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function wp(r){if(r.privateKey==null||r.publicKey==null)throw new Ee("Private and public key are required");return Promise.all([jt.get().subtle.exportKey("jwk",r.privateKey),jt.get().subtle.exportKey("jwk",r.publicKey)])}function Js(r){if(r.kty!=="RSA")throw new Ee("invalid key type");if(r.n==null)throw new Ee("invalid key modulus");return j(r.n,"base64url").length*8}var Pr=class{type="RSA";_key;_raw;_multihash;constructor(e,t){this._key=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=gn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return X.createV1(114,this._multihash)}toString(){return re.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return Gu(this._key,t,e)}},yn=class{type="RSA";_key;_raw;publicKey;constructor(e,t){this._key=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=gn.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}sign(e){return ju(this._key,e)}};var Wo=8192,Xs=18;function Zu(r){let{result:e}=Ys(r),t=e.valueBlock.value;return{n:ft(t[1]),e:ft(t[2]),d:ft(t[3]),p:ft(t[4]),q:ft(t[5]),dp:ft(t[6]),dq:ft(t[7]),qi:ft(t[8]),kty:"RSA",alg:"RS256"}}function xp(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 Ee("JWK was missing components");let t=new At({value:[new xe({value:0}),xe.fromBigInt(ht(j(r.n,"base64url"))),xe.fromBigInt(ht(j(r.e,"base64url"))),xe.fromBigInt(ht(j(r.d,"base64url"))),xe.fromBigInt(ht(j(r.p,"base64url"))),xe.fromBigInt(ht(j(r.q,"base64url"))),xe.fromBigInt(ht(j(r.dp,"base64url"))),xe.fromBigInt(ht(j(r.dq,"base64url"))),xe.fromBigInt(ht(j(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Wu(r){let{result:e}=Ys(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:ft(t[0]),e:ft(t[1])}}function Qs(r){if(r.n==null||r.e==null)throw new Ee("JWK was missing components");let t=new At({value:[new At({value:[new Lr({value:"1.2.840.113549.1.1.1"}),new Rr]}),new _r({valueHex:new At({value:[xe.fromBigInt(ht(j(r.n,"base64url"))),xe.fromBigInt(ht(j(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function ft(r){let e=r.valueBlock.valueHexView;for(;e[0]===0;)e=e.subarray(1);return ne(e,"base64url")}function ht(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function Yu(r){let e=Zu(r);return Ju(e)}function ea(r){let e=Wu(r);if(Js(e)>Wo)throw new fr("Key size is too large");let t=Nr(ut.encode({Type:fe.RSA,Data:r})),n=Ze(Xs,t);return new Pr(e,n)}function Ju(r){if(Js(r)>Wo)throw new Ee("Key size is too large");let e=Qu(r),t=Nr(ut.encode({Type:fe.RSA,Data:Qs(e.publicKey)})),n=Ze(Xs,t);return new yn(e.privateKey,new Pr(e.publicKey,n))}async function Xu(r){if(r>Wo)throw new Ee("Key size is too large");let e=await zu(r),t=Nr(ut.encode({Type:fe.RSA,Data:Qs(e.publicKey)})),n=Ze(Xs,t);return new yn(e.privateKey,new Pr(e.publicKey,n))}function Qu(r){if(r==null)throw new Ee("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Yo=class extends Er{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,xc(e);let n=Jr(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,i=new Uint8Array(o);i.set(n.length>o?e.create().update(n).digest():n);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return vr(this),this.iHash.update(e),this}digestInto(e){vr(this),br(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ta=(r,e,t)=>new Yo(r,e).update(t).digest();ta.create=(r,e)=>new Yo(r,e);function el(r){r.lowS!==void 0&&Je("lowS",r.lowS),r.prehash!==void 0&&Je("prehash",r.prehash)}function bp(r){let e=en(r);ct(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:o}=e;if(t){if(!n.eql(o,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:vp,hexToBytes:Ep}=zn,ra=class extends Error{constructor(e=""){super(e)}},kt={Err:ra,_tlv:{encode:(r,e)=>{let{Err:t}=kt;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,o=Jt(n);if(o.length/2&128)throw new t("tlv.encode: long form length too big");let i=n>127?Jt(o.length/2|128):"";return Jt(r)+i+o+e},decode(r,e){let{Err:t}=kt,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let f=e.subarray(n,n+c);if(f.length!==c)throw new t("tlv.decode: length bytes not complete");if(f[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let u of f)s=s<<8|u;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=kt;if(r<Ct)throw new e("integer: negative integers are not allowed");let t=Jt(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=kt;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return vp(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=kt,o=typeof r=="string"?Ep(r):r;Ar(o);let{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("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 e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(f)}},hexFromSig(r){let{_tlv:e,_int:t}=kt,n=e.encode(2,t.encode(r.r)),o=e.encode(2,t.encode(r.s)),i=n+o;return e.encode(48,i)}},Ct=BigInt(0),pe=BigInt(1),Sx=BigInt(2),tl=BigInt(3),Ix=BigInt(4);function Bp(r){let e=bp(r),{Fp:t}=e,n=Ot(e.n,e.nBitLength),o=e.toBytes||((w,d,A)=>{let k=d.toAffine();return vt(Uint8Array.from([4]),t.toBytes(k.x),t.toBytes(k.y))}),i=e.fromBytes||(w=>{let d=w.subarray(1),A=t.fromBytes(d.subarray(0,t.BYTES)),k=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x:A,y:k}});function s(w){let{a:d,b:A}=e,k=t.sqr(w),x=t.mul(k,w);return t.add(t.add(x,t.mul(w,d)),A)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(w){return Xr(w,pe,e.n)}function c(w){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:k,n:x}=e;if(d&&typeof w!="bigint"){if(Ft(w)&&(w=xt(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:bt(se("private key",w,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof w)}return k&&(U=Q(U,x)),Le("private key",U,pe,x),U}function f(w){if(!(w instanceof h))throw new Error("ProjectivePoint expected")}let u=er((w,d)=>{let{px:A,py:k,pz:x}=w;if(t.eql(x,t.ONE))return{x:A,y:k};let U=w.is0();d==null&&(d=U?t.ONE:t.inv(x));let F=t.mul(A,d),P=t.mul(k,d),R=t.mul(x,d);if(U)return{x:t.ZERO,y:t.ZERO};if(!t.eql(R,t.ONE))throw new Error("invZ was invalid");return{x:F,y:P}}),l=er(w=>{if(w.is0()){if(e.allowInfinityPoint&&!t.is0(w.py))return;throw new Error("bad point: ZERO")}let{x:d,y:A}=w.toAffine();if(!t.isValid(d)||!t.isValid(A))throw new Error("bad point: x or y not FE");let k=t.sqr(A),x=s(d);if(!t.eql(k,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,k){if(this.px=d,this.py=A,this.pz=k,d==null||!t.isValid(d))throw new Error("x required");if(A==null||!t.isValid(A))throw new Error("y required");if(k==null||!t.isValid(k))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:k}=d||{};if(!d||!t.isValid(A)||!t.isValid(k))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let x=U=>t.eql(U,t.ZERO);return x(A)&&x(k)?h.ZERO:new h(A,k,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=t.invertBatch(d.map(k=>k.pz));return d.map((k,x)=>k.toAffine(A[x])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(se("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return Wn(h,n,d,A)}_setWindowSize(d){B.setWindowSize(this,d)}assertValidity(){l(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:A,py:k,pz:x}=this,{px:U,py:F,pz:P}=d,R=t.eql(t.mul(A,P),t.mul(U,x)),b=t.eql(t.mul(k,P),t.mul(F,x));return R&&b}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:A}=e,k=t.mul(A,tl),{px:x,py:U,pz:F}=this,P=t.ZERO,R=t.ZERO,b=t.ZERO,v=t.mul(x,x),D=t.mul(U,U),_=t.mul(F,F),C=t.mul(x,U);return C=t.add(C,C),b=t.mul(x,F),b=t.add(b,b),P=t.mul(d,b),R=t.mul(k,_),R=t.add(P,R),P=t.sub(D,R),R=t.add(D,R),R=t.mul(P,R),P=t.mul(C,P),b=t.mul(k,b),_=t.mul(d,_),C=t.sub(v,_),C=t.mul(d,C),C=t.add(C,b),b=t.add(v,v),v=t.add(b,v),v=t.add(v,_),v=t.mul(v,C),R=t.add(R,v),_=t.mul(U,F),_=t.add(_,_),v=t.mul(_,C),P=t.sub(P,v),b=t.mul(_,D),b=t.add(b,b),b=t.add(b,b),new h(P,R,b)}add(d){f(d);let{px:A,py:k,pz:x}=this,{px:U,py:F,pz:P}=d,R=t.ZERO,b=t.ZERO,v=t.ZERO,D=e.a,_=t.mul(e.b,tl),C=t.mul(A,U),$=t.mul(k,F),S=t.mul(x,P),I=t.add(A,k),m=t.add(U,F);I=t.mul(I,m),m=t.add(C,$),I=t.sub(I,m),m=t.add(A,x);let p=t.add(U,P);return m=t.mul(m,p),p=t.add(C,S),m=t.sub(m,p),p=t.add(k,x),R=t.add(F,P),p=t.mul(p,R),R=t.add($,S),p=t.sub(p,R),v=t.mul(D,m),R=t.mul(_,S),v=t.add(R,v),R=t.sub($,v),v=t.add($,v),b=t.mul(R,v),$=t.add(C,C),$=t.add($,C),S=t.mul(D,S),m=t.mul(_,m),$=t.add($,S),S=t.sub(C,S),S=t.mul(D,S),m=t.add(m,S),C=t.mul($,m),b=t.add(b,C),C=t.mul(p,m),R=t.mul(I,R),R=t.sub(R,C),C=t.mul(I,$),v=t.mul(p,v),v=t.add(v,C),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:k}=e;Le("scalar",d,Ct,k);let x=h.ZERO;if(d===Ct)return x;if(this.is0()||d===pe)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>Ct||R>Ct;)F&pe&&(b=b.add(D)),R&pe&&(v=v.add(D)),D=D.double(),F>>=pe,R>>=pe;return U&&(b=b.negate()),P&&(v=v.negate()),v=new h(t.mul(v.px,A.beta),v.py,v.pz),b.add(v)}multiply(d){let{endo:A,n:k}=e;Le("scalar",d,pe,k);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:_,f:C}=this.wNAF(b);v=B.constTimeNegate(F,v),_=B.constTimeNegate(R,_),_=new h(t.mul(_.px,A.beta),_.py,_.pz),x=v.add(_),U=D.add(C)}else{let{p:F,f:P}=this.wNAF(d);x=F,U=P}return h.normalizeZ([x,U])[0]}multiplyAndAddUnsafe(d,A,k){let x=h.BASE,U=(P,R)=>R===Ct||R===pe||!P.equals(x)?P.multiplyUnsafe(R):P.multiply(R),F=U(this,A).add(U(d,k));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:A}=e;if(d===pe)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}=e;return d===pe?this:A?A(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return Je("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Je("isCompressed",d),xt(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let g=e.nBitLength,B=Zn(h,e.endo?Math.ceil(g/2):g);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function Ap(r){let e=en(r);return ct(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function rl(r){let e=Ap(r),{Fp:t,n}=e,o=t.BYTES+1,i=2*t.BYTES+1;function s(S){return Q(S,n)}function a(S){return jn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=Bp({...e,toBytes(S,I,m){let p=I.toAffine(),E=t.toBytes(p.x),N=vt;return Je("isCompressed",m),m?N(Uint8Array.from([I.hasEvenY()?2:3]),E):N(Uint8Array.from([4]),E,t.toBytes(p.y))},fromBytes(S){let I=S.length,m=S[0],p=S.subarray(1);if(I===o&&(m===2||m===3)){let E=bt(p);if(!Xr(E,pe,t.ORDER))throw new Error("Point is not on curve");let N=u(E),M;try{M=t.sqrt(N)}catch(Z){let K=Z instanceof Error?": "+Z.message:"";throw new Error("Point is not on curve"+K)}let O=(M&pe)===pe;return(m&1)===1!==O&&(M=t.neg(M)),{x:E,y:M}}else if(I===i&&m===4){let E=t.fromBytes(p.subarray(0,t.BYTES)),N=t.fromBytes(p.subarray(t.BYTES,2*t.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=>xt(Mt(S,e.nByteLength));function g(S){let I=n>>pe;return S>I}function B(S){return g(S)?s(-S):S}let w=(S,I,m)=>bt(S.slice(I,m));class d{constructor(I,m,p){this.r=I,this.s=m,this.recovery=p,this.assertValidity()}static fromCompact(I){let m=e.nByteLength;return I=se("compactSignature",I,m*2),new d(w(I,0,m),w(I,m,2*m))}static fromDER(I){let{r:m,s:p}=kt.toSig(se("DER",I));return new d(m,p)}assertValidity(){Le("r",this.r,pe,n),Le("s",this.s,pe,n)}addRecoveryBit(I){return new d(this.r,this.s,I)}recoverPublicKey(I){let{r:m,s:p,recovery:E}=this,N=P(se("msgHash",I));if(E==null||![0,1,2,3].includes(E))throw new Error("recovery id invalid");let M=E===2||E===3?m+e.n:m;if(M>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let O=E&1?"03":"02",z=c.fromHex(O+h(M)),Z=a(M),K=s(-N*Z),J=s(p*Z),te=c.BASE.multiplyAndAddUnsafe(z,K,J);if(!te)throw new Error("point at infinify");return te.assertValidity(),te}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Xt(this.toDERHex())}toDERHex(){return kt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Xt(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=cs(e.n);return Rc(e.randomBytes(S),e.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function k(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function x(S){let I=Ft(S),m=typeof S=="string",p=(I||m)&&S.length;return I?p===o||p===i:m?p===2*o||p===2*i:S instanceof c}function U(S,I,m=!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(m)}let F=e.bits2int||function(S){if(S.length>8192)throw new Error("input is too large");let I=bt(S),m=S.length*8-e.nBitLength;return m>0?I>>BigInt(m):I},P=e.bits2int_modN||function(S){return s(F(S))},R=Qr(e.nBitLength);function b(S){return Le("num < 2^"+e.nBitLength,S,Ct,R),Mt(S,e.nByteLength)}function v(S,I,m=D){if(["recovered","canonical"].some(de=>de in m))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:E}=e,{lowS:N,prehash:M,extraEntropy:O}=m;N==null&&(N=!0),S=se("msgHash",S),el(m),M&&(S=se("prehashed msgHash",p(S)));let z=P(S),Z=f(I),K=[b(Z),b(z)];if(O!=null&&O!==!1){let de=O===!0?E(t.BYTES):O;K.push(se("extraEntropy",de))}let J=vt(...K),te=z;function he(de){let ye=F(de);if(!l(ye))return;let ve=a(ye),Ue=c.BASE.multiply(ye).toAffine(),Te=s(Ue.x);if(Te===Ct)return;let at=s(ve*s(te+Te*Z));if(at===Ct)return;let mt=(Ue.x===Te?0:2)|Number(Ue.y&pe),Gr=at;return N&&g(at)&&(Gr=B(at),mt^=1),new d(Te,Gr,mt)}return{seed:J,k2sig:he}}let D={lowS:e.lowS,prehash:!1},_={lowS:e.lowS,prehash:!1};function C(S,I,m=D){let{seed:p,k2sig:E}=v(S,I,m),N=e;return os(N.hash.outputLen,N.nByteLength,N.hmac)(p,E)}c.BASE._setWindowSize(8);function $(S,I,m,p=_){let E=S;I=se("msgHash",I),m=se("publicKey",m);let{lowS:N,prehash:M,format:O}=p;if(el(p),"strict"in p)throw new Error("options.strict was renamed to lowS");if(O!==void 0&&O!=="compact"&&O!=="der")throw new Error("format must be compact or der");let z=typeof E=="string"||Ft(E),Z=!z&&!O&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!z&&!Z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,J;try{if(Z&&(K=new d(E.r,E.s)),z){try{O!=="compact"&&(K=d.fromDER(E))}catch(mt){if(!(mt instanceof kt.Err))throw mt}!K&&O!=="der"&&(K=d.fromCompact(E))}J=c.fromHex(m)}catch{return!1}if(!K||N&&K.hasHighS())return!1;M&&(I=e.hash(I));let{r:te,s:he}=K,de=P(I),ye=a(he),ve=s(de*ye),Ue=s(te*ye),Te=c.BASE.multiplyAndAddUnsafe(J,ve,Ue)?.toAffine();return Te?s(Te.x)===te:!1}return{CURVE:e,getPublicKey:k,getSharedSecret:U,sign:C,verify:$,ProjectivePoint:c,Signature:d,utils:A}}function Sp(r){return{hash:r,hmac:(e,...t)=>ta(r,e,Ji(...t)),randomBytes:Hn}}function nl(r,e){let t=n=>rl({...r,...Sp(n)});return{...t(e),create:t}}var sl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ol=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Ip=BigInt(1),na=BigInt(2),il=(r,e)=>(r+e/na)/e;function Tp(r){let e=sl,t=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),f=r*r*r%e,u=f*f*r%e,l=ie(u,t,e)*u%e,h=ie(l,t,e)*u%e,g=ie(h,na,e)*f%e,B=ie(g,o,e)*g%e,w=ie(B,i,e)*B%e,d=ie(w,a,e)*w%e,A=ie(d,c,e)*d%e,k=ie(A,a,e)*w%e,x=ie(k,t,e)*u%e,U=ie(x,s,e)*B%e,F=ie(U,n,e)*f%e,P=ie(F,na,e);if(!oa.eql(oa.sqr(P),r))throw new Error("Cannot find square root");return P}var oa=Ot(sl,void 0,void 0,{sqrt:Tp}),sr=nl({a:BigInt(0),b:BigInt(7),Fp:oa,n:ol,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=ol,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Ip*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,s=BigInt("0x100000000000000000000000000000000"),a=il(i*r,e),c=il(-n*r,e),f=Q(r-a*t-c*o,e),u=Q(-a*n-c*i,e),l=f>s,h=u>s;if(l&&(f=e-f),h&&(u=e-u),f>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:f,k2neg:h,k2:u}}}},Nr),Vx=BigInt(0);var Px=sr.ProjectivePoint;function Me(r,e){e==null&&(e=r.reduce((o,i)=>o+i.length,0));let t=Qe(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}function al(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function cl(r,e,t){let n=tn.digest(t instanceof Uint8Array?t:t.subarray());if(al(n))return n.then(({digest:o})=>sr.verify(e,o,r)).catch(o=>{throw new mn(String(o))});try{return sr.verify(e,n.digest,r)}catch(o){throw new mn(String(o))}}var Jo=class{type="secp256k1";raw;_key;constructor(e){this._key=ll(e),this.raw=ul(this._key)}toMultihash(){return We.digest(Qn(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return re.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:ce(this.raw,e.raw)}verify(e,t){return cl(this._key,t,e)}};function ia(r){return new Jo(r)}function ul(r){return sr.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ll(r){try{return sr.ProjectivePoint.fromHex(r),r}catch(e){throw new fr(String(e))}}function fl(r){let{Type:e,Data:t}=ut.decode(r),n=t??new Uint8Array;switch(e){case fe.RSA:return ea(n);case fe.Ed25519:return ms(n);case fe.secp256k1:return ia(n);default:throw new dr}}function Xo(r){let{Type:e,Data:t}=ut.decode(r.digest),n=t??new Uint8Array;switch(e){case fe.Ed25519:return ms(n);case fe.secp256k1:return ia(n);default:throw new dr}}function Qn(r){return ut.encode({Type:fe[r.type],Data:r.raw})}var hl=Symbol.for("nodejs.util.inspect.custom"),kp=114,wn=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Fi]=!0;toString(){return this.string==null&&(this.string=re.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return X.createV1(kp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return ce(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return ce(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[hl](){return`PeerId(${this.toString()})`}},Qo=class extends wn{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},ei=class extends wn{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},ti=class extends wn{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},Cp=2336,xn=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=We.digest(j(this.url))}[hl](){return`PeerId(${this.url})`}[Fi]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return X.createV1(Cp,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=ne(e)),e.toString()===this.toString())}};var Np=114,dl=2336;function pl(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=yt(re.decode(`z${r}`));else{if(e==null)throw new Ee('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=yt(e.decode(r))}return ml(t)}function ml(r){if(Rp(r))return new Qo({multihash:r});if(Up(r))try{let e=Xo(r);if(e.type==="Ed25519")return new ei({multihash:r,publicKey:e});if(e.type==="secp256k1")return new ti({multihash:r,publicKey:e})}catch{let t=ne(r.digest);return new xn(new URL(t))}throw new hr("Supplied PeerID Multihash is invalid")}function gl(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Np&&r.code!==dl)throw new Ln("Supplied PeerID CID is invalid");if(r.code===dl){let e=ne(r.multihash.digest);return new xn(new URL(e))}return ml(r.multihash)}function Up(r){return r.code===We.code}function Rp(r){return r.code===tn.code}var ri=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,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,e);if(!Number.isNaN(h))return h});if(u===void 0)break;if(i*=e,i+=u,i>f||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:i})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let o=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[o]=s[0],t[o+1]=s[1],t[o+2]=s[2],t[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];t[o]=i>>8,t[o+1]=i&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,o]=e(t);if(n===16)return t;if(o||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let i=new Uint8Array(14),s=16-(n+2),[a]=e(i.subarray(0,s));return t.set(i.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var yl=45,_p=15,Fr=new ri;function sa(r){if(!(r.length>_p))return Fr.new(r).parseWith(()=>Fr.readIPv4Addr())}function aa(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>yl))return Fr.new(r).parseWith(()=>Fr.readIPv6Addr())}function ni(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>yl))return Fr.new(r).parseWith(()=>Fr.readIPAddr())}var Jb=parseInt("0xFFFF",16),Xb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function bl(r){return!!sa(r)}function vl(r){return!!aa(r)}function oi(r){return!!ni(r)}var El=bl,Dp=vl,ca=function(r){let e=0;if(r=r.toString().trim(),El(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Dp(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let i=El(t[n]),s;i&&(s=ca(t[n]),t[n]=ne(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,ne(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let i=[n,1];for(n=9-t.length;n>0;n--)i.push("0");t.splice.apply(t,i)}let o=new Uint8Array(e+16);for(n=0;n<t.length;n++){let i=parseInt(t[n],16);o[e++]=i>>8&255,o[e++]=i&255}return o}throw new Error("invalid ip address")},Bl=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let o=[];for(let i=0;i<t;i++)o.push(r[e+i]);return o.join(".")}if(t===16){let o=[];for(let i=0;i<t;i+=2)o.push(n.getUint16(e+i).toString(16));return o.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Dr={},ua={},Op=[[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"]];Op.forEach(r=>{let e=Hp(...r);ua[e.code]=e,Dr[e.name]=e});function Hp(r,e,t,n,o){return{code:r,size:e,name:t,resolvable:!!n,path:!!o}}function ee(r){if(typeof r=="number"){if(ua[r]!=null)return ua[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Dr[r]!=null)return Dr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var V1=ee("ip4"),P1=ee("ip6"),F1=ee("ipcidr");function da(r,e){switch(ee(r).code){case 4:case 41:return Kp(e);case 42:return ha(e);case 43:return ne(e,"base10");case 6:case 273:case 33:case 132:return Il(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return ha(e);case 421:return Gp(e);case 444:return Sl(e);case 445:return Sl(e);case 466:return jp(e);case 481:return globalThis.encodeURIComponent(ha(e));default:return ne(e,"base16")}}function pa(r,e){switch(ee(r).code){case 4:return Al(e);case 41:return Al(e);case 42:return fa(e);case 43:return j(e,"base10");case 6:case 273:case 33:case 132:return ma(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return fa(e);case 421:return qp(e);case 444:return Zp(e);case 445:return Wp(e);case 466:return zp(e);case 481:return fa(globalThis.decodeURIComponent(e));default:return j(e,"base16")}}var la=Object.values(rn).map(r=>r.decoder),$p=function(){let r=la[0].or(la[1]);return la.slice(2).forEach(e=>r=r.or(e)),r}();function Al(r){if(!oi(r))throw new Error("invalid ip address");return ca(r)}function Kp(r){let e=Bl(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!oi(e))throw new Error("invalid ip address");return e}function ma(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Il(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function fa(r){let e=j(r),t=Uint8Array.from(Sr(e.length));return Me([t,e],t.length+e.length)}function ha(r){let e=rr(r);if(r=r.slice(Pe(e)),r.length!==e)throw new Error("inconsistent lengths");return ne(r)}function qp(r){let e;r[0]==="Q"||r[0]==="1"?e=yt(re.decode(`z${r}`)).bytes:e=X.parse(r).multihash.bytes;let t=Uint8Array.from(Sr(e.length));return Me([t,e],t.length+e.length)}function zp(r){let e=$p.decode(r),t=Uint8Array.from(Sr(e.length));return Me([t,e],t.length+e.length)}function jp(r){let e=rr(r),t=r.slice(Pe(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+ne(t,"base64url")}function Gp(r){let e=rr(r),t=r.slice(Pe(e));if(t.length!==e)throw new Error("inconsistent lengths");return ne(t,"base58btc")}function Zp(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=Ge.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ma(n);return Me([t,o],t.length+o.length)}function Wp(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Ge.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=ma(n);return Me([t,o],t.length+o.length)}function Sl(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=ne(e,"base32"),o=Il(t);return`${n}:${o}`}function Tl(r){r=ga(r);let e=[],t=[],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=ee(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(i++,i>=o.length)throw Cl("invalid address: "+r);if(a.path===!0){n=ga(o.slice(i).join("/")),e.push([a.code,pa(a.code,n)]),t.push([a.code,n]);break}let c=pa(a.code,o[i]);e.push([a.code,c]),t.push([a.code,da(a.code,c)])}return{string:kl(t),bytes:wa(e),tuples:e,stringTuples:t,path:n}}function ya(r){let e=[],t=[],n=null,o=0;for(;o<r.length;){let i=rr(r,o),s=Pe(i),a=ee(i),c=Yp(a,r.slice(o+s));if(c===0){e.push([i]),t.push([i]),o+=s;continue}let f=r.slice(o+s,o+s+c);if(o+=c+s,o>r.length)throw Cl("Invalid address Uint8Array: "+ne(r,"base16"));e.push([i,f]);let u=da(i,f);if(t.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:kl(t),tuples:e,stringTuples:t,path:n}}function kl(r){let e=[];return r.map(t=>{let n=ee(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),ga(e.join("/"))}function wa(r){return Me(r.map(e=>{let t=ee(e[0]),n=Uint8Array.from(Sr(t.code));return e.length>1&&e[1]!=null&&(n=Me([n,e[1]])),n}))}function Yp(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=rr(e instanceof Uint8Array?e:Uint8Array.from(e));return t+Pe(t)}}function ga(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function Cl(r){return new Error("Error parsing address: "+r)}var Jp=Symbol.for("nodejs.util.inspect.custom"),ba=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Xp=[ee("dns").code,ee("dns4").code,ee("dns6").code,ee("dnsaddr").code],xa=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},ii=class r{bytes;#e;#r;#t;#a;[ba]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=ya(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Tl(e)}else if(Ul(e))t=ya(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#r=t.tuples,this.#t=t.stringTuples,this.#a=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,o,i="",s=ee("tcp"),a=ee("udp"),c=ee("ip4"),f=ee("ip6"),u=ee("dns6"),l=ee("ip6zone");for(let[g,B]of this.stringTuples())g===l.code&&(i=`%${B??""}`),Xp.includes(g)&&(t=s.name,o=443,n=`${B??""}${i}`,e=g===u.code?6:4),(g===s.code||g===a.code)&&(t=ee(g).name,o=parseInt(B??"")),(g===c.code||g===f.code)&&(t=ee(g).name,n=`${B??""}${i}`,e=g===f.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:o}}protos(){return this.#r.map(([e])=>Object.assign({},ee(e)))}protoCodes(){return this.#r.map(([e])=>e)}protoNames(){return this.#r.map(([e])=>ee(e).name)}tuples(){return this.#r.map(([e,t])=>t==null?[e]:[e,t])}stringTuples(){return this.#t.map(([e,t])=>t==null?[e]:[e,t])}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),o=n.lastIndexOf(t);if(o<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,o))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(wa(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,o])=>{n===Dr.p2p.code&&e.push([n,o]),n===Dr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?ne(re.decode(`z${n}`),"base58btc"):ne(X.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(e){return ce(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(i=>i.resolvable);if(t==null)return[this];let n=Nl.get(t.name);if(n==null)throw new xa(`no available resolver for ${t.name}`);return(await n(this,e)).map(i=>ar(i))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[Jp](){return`Multiaddr(${this.#e})`}};var Nl=new Map;function Ul(r){return!!r?.[ba]}function ar(r){return new ii(r)}function bn(r){let e=new globalThis.AbortController;function t(){e.abort();for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}for(let i of r){if(i?.aborted===!0){t();break}i?.addEventListener!=null&&i.addEventListener("abort",t)}function n(){for(let i of r)i?.removeEventListener!=null&&i.removeEventListener("abort",t)}let o=e.signal;return o.clear=n,o}async function*si(r,e={}){let t=r.getReader();try{for(;;){let n=await t.read();if(n.done)return;yield n.value}}finally{e.preventCancel!==!0&&await t.cancel(),t.releaseLock()}}var Qp="/",em=new TextEncoder().encode(Qp),f2=em[0];var Lm=_n(Ea(),1);var rt=class extends Error{static name="SignatureVerificationError";constructor(e="Record signature verification failed"){super(e),this.name="SignatureVerificationError"}},ai=class extends Error{static name="RecordExpiredError";constructor(e="Record has expired"){super(e),this.name="RecordExpiredError"}},Mr=class extends Error{static name="UnsupportedValidityError";constructor(e="The validity type is unsupported"){super(e),this.name="UnsupportedValidityError"}},ci=class extends Error{static name="RecordTooLargeError";constructor(e="The record is too large"){super(e),this.name="RecordTooLargeError"}},ui=class extends Error{static name="InvalidValueError";constructor(e="Value must be a valid content path starting with /"){super(e),this.name="InvalidValueError"}},li=class extends Error{static name="InvalidRecordDataError";constructor(e="Invalid record data"){super(e),this.name="InvalidRecordDataError"}},vn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(e="Invalid embedded public key"){super(e),this.name="InvalidEmbeddedPublicKeyError"}};var nt;(function(r){let e;(function(o){o.EOL="EOL"})(e=r.ValidityType||(r.ValidityType={}));let t;(function(o){o[o.EOL=0]="EOL"})(t||(t={})),function(o){o.codec=()=>sn(t)}(e=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Cr((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=>Tr(o,r.codec()),r.decode=(o,i)=>Ir(o,r.codec(),i)})(nt||(nt={}));var tm=["string","number","bigint","symbol"],rm=["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 Rl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let e=typeof r;if(tm.includes(e))return e;if(e==="function")return"Function";if(Array.isArray(r))return"Array";if(nm(r))return"Buffer";let t=om(r);return t||"Object"}function nm(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function om(r){let e=Object.prototype.toString.call(r).slice(8,-1);if(rm.includes(e))return e}var y=class{constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.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 V=class{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}};var Or=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",im=new TextDecoder,sm=new TextEncoder;function fi(r){return Or&&globalThis.Buffer.isBuffer(r)}function Pl(r){return r instanceof Uint8Array?fi(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Fl=Or?(r,e,t)=>t-e>64?globalThis.Buffer.from(r.subarray(e,t)).toString("utf8"):Ll(r,e,t):(r,e,t)=>t-e>64?im.decode(r.subarray(e,t)):Ll(r,e,t),Dl=Or?r=>r.length>64?globalThis.Buffer.from(r):_l(r):r=>r.length>64?sm.encode(r):_l(r);var Hr=Or?(r,e,t)=>fi(r)?new Uint8Array(r.subarray(e,t)):r.slice(e,t):(r,e,t)=>r.slice(e,t),Ml=Or?(r,e)=>(r=r.map(t=>t instanceof Uint8Array?t:globalThis.Buffer.from(t)),Pl(globalThis.Buffer.concat(r,e))):(r,e)=>{let t=new Uint8Array(e),n=0;for(let o of r)n+o.length>t.length&&(o=o.subarray(0,t.length-n)),t.set(o,n),n+=o.length;return t},Ol=Or?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Hl(r,e){if(fi(r)&&fi(e))return r.compare(e);for(let t=0;t<r.length;t++)if(r[t]!==e[t])return r[t]<e[t]?-1:1;return 0}function _l(r){let e=[],t=0;for(let n=0;n<r.length;n++){let o=r.charCodeAt(n);o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=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),e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128)}return e}function Ll(r,e,t){let n=[];for(;e<t;){let o=r[e],i=null,s=o>239?4:o>223?3:o>191?2:1;if(e+s<=t){let a,c,f,u;switch(s){case 1:o<128&&(i=o);break;case 2:a=r[e+1],(a&192)===128&&(u=(o&31)<<6|a&63,u>127&&(i=u));break;case 3:a=r[e+1],c=r[e+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[e+1],c=r[e+2],f=r[e+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),e+=s}return am(n)}var Vl=4096;function am(r){let e=r.length;if(e<=Vl)return String.fromCharCode.apply(String,r);let t="",n=0;for(;n<e;)t+=String.fromCharCode.apply(String,r.slice(n,n+=Vl));return t}var cm=256,hi=class{constructor(e=cm){this.chunkSize=e,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(e){let t=this.chunks[this.chunks.length-1];if(this.cursor+e.length<=this.maxCursor+1){let o=t.length-(this.maxCursor-this.cursor)-1;t.set(e,o)}else{if(t){let o=t.length-(this.maxCursor-this.cursor)-1;o<t.length&&(this.chunks[this.chunks.length-1]=t.subarray(0,o),this.maxCursor=this.cursor-1)}e.length<64&&e.length<this.chunkSize?(t=Ol(this.chunkSize),this.chunks.push(t),this.maxCursor+=t.length,this._initReuseChunk===null&&(this._initReuseChunk=t),t.set(e,0)):(this.chunks.push(e),this.maxCursor+=e.length)}this.cursor+=e.length}toBytes(e=!1){let t;if(this.chunks.length===1){let n=this.chunks[0];e&&this.cursor>n.length/2?(t=this.cursor===n.length?n:n.subarray(0,this.cursor),this._initReuseChunk=null,this.chunks=[]):t=Hr(n,0,this.cursor)}else t=Ml(this.chunks,this.cursor);return e&&this.reset(),t}};var H="CBOR decode error:",Ba="CBOR encode error:",En=[];En[23]=1;En[24]=2;En[25]=3;En[26]=5;En[27]=9;function Nt(r,e,t){if(r.length-e<t)throw new Error(`${H} not enough data for type`)}var me=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Oe(r,e,t){Nt(r,e,1);let n=r[e];if(t.strict===!0&&n<me[0])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function He(r,e,t){Nt(r,e,2);let n=r[e]<<8|r[e+1];if(t.strict===!0&&n<me[1])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function $e(r,e,t){Nt(r,e,4);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3];if(t.strict===!0&&n<me[2])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Ke(r,e,t){Nt(r,e,8);let n=r[e]*16777216+(r[e+1]<<16)+(r[e+2]<<8)+r[e+3],o=r[e+4]*16777216+(r[e+5]<<16)+(r[e+6]<<8)+r[e+7],i=(BigInt(n)<<BigInt(32))+BigInt(o);if(t.strict===!0&&i<me[3])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(t.allowBigInt===!0)return i;throw new Error(`${H} integers outside of the safe integer range are not supported`)}function $l(r,e,t,n){return new V(y.uint,Oe(r,e+1,n),2)}function Kl(r,e,t,n){return new V(y.uint,He(r,e+1,n),3)}function ql(r,e,t,n){return new V(y.uint,$e(r,e+1,n),5)}function zl(r,e,t,n){return new V(y.uint,Ke(r,e+1,n),9)}function ze(r,e){return be(r,0,e.value)}function be(r,e,t){if(t<me[0]){let n=Number(t);r.push([e|n])}else if(t<me[1]){let n=Number(t);r.push([e|24,n])}else if(t<me[2]){let n=Number(t);r.push([e|25,n>>>8,n&255])}else if(t<me[3]){let n=Number(t);r.push([e|26,n>>>24&255,n>>>16&255,n>>>8&255,n&255])}else{let n=BigInt(t);if(n<me[4]){let o=[e|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`)}}ze.encodedSize=function(e){return be.encodedSize(e.value)};be.encodedSize=function(e){return e<me[0]?1:e<me[1]?2:e<me[2]?3:e<me[3]?5:9};ze.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};function jl(r,e,t,n){return new V(y.negint,-1-Oe(r,e+1,n),2)}function Gl(r,e,t,n){return new V(y.negint,-1-He(r,e+1,n),3)}function Zl(r,e,t,n){return new V(y.negint,-1-$e(r,e+1,n),5)}var Aa=BigInt(-1),Wl=BigInt(1);function Yl(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o!="bigint"){let i=-1-o;if(i>=Number.MIN_SAFE_INTEGER)return new V(y.negint,i,9)}if(n.allowBigInt!==!0)throw new Error(`${H} integers outside of the safe integer range are not supported`);return new V(y.negint,Aa-BigInt(o),9)}function di(r,e){let t=e.value,n=typeof t=="bigint"?t*Aa-Wl:t*-1-1;be(r,e.type.majorEncoded,n)}di.encodedSize=function(e){let t=e.value,n=typeof t=="bigint"?t*Aa-Wl:t*-1-1;return n<me[0]?1:n<me[1]?2:n<me[2]?3:n<me[3]?5:9};di.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0};function Bn(r,e,t,n){Nt(r,e,t+n);let o=Hr(r,e+t,e+t+n);return new V(y.bytes,o,t+n)}function Jl(r,e,t,n){return Bn(r,e,1,t)}function Xl(r,e,t,n){return Bn(r,e,2,Oe(r,e+1,n))}function Ql(r,e,t,n){return Bn(r,e,3,He(r,e+1,n))}function ef(r,e,t,n){return Bn(r,e,5,$e(r,e+1,n))}function tf(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer bytes lengths not supported`);return Bn(r,e,9,o)}function pi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?Dl(r.value):r.value),r.encodedBytes}function $r(r,e){let t=pi(e);be(r,e.type.majorEncoded,t.length),r.push(t)}$r.encodedSize=function(e){let t=pi(e);return be.encodedSize(t.length)+t.length};$r.compareTokens=function(e,t){return lm(pi(e),pi(t))};function lm(r,e){return r.length<e.length?-1:r.length>e.length?1:Hl(r,e)}function An(r,e,t,n,o){let i=t+n;Nt(r,e,i);let s=new V(y.string,Fl(r,e+t,e+i),i);return o.retainStringBytes===!0&&(s.byteValue=Hr(r,e+t,e+i)),s}function rf(r,e,t,n){return An(r,e,1,t,n)}function nf(r,e,t,n){return An(r,e,2,Oe(r,e+1,n),n)}function of(r,e,t,n){return An(r,e,3,He(r,e+1,n),n)}function sf(r,e,t,n){return An(r,e,5,$e(r,e+1,n),n)}function af(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer string lengths not supported`);return An(r,e,9,o,n)}var cf=$r;function Kr(r,e,t,n){return new V(y.array,n,t)}function uf(r,e,t,n){return Kr(r,e,1,t)}function lf(r,e,t,n){return Kr(r,e,2,Oe(r,e+1,n))}function ff(r,e,t,n){return Kr(r,e,3,He(r,e+1,n))}function hf(r,e,t,n){return Kr(r,e,5,$e(r,e+1,n))}function df(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer array lengths not supported`);return Kr(r,e,9,o)}function pf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return Kr(r,e,1,1/0)}function mi(r,e){be(r,y.array.majorEncoded,e.value)}mi.compareTokens=ze.compareTokens;mi.encodedSize=function(e){return be.encodedSize(e.value)};function qr(r,e,t,n){return new V(y.map,n,t)}function mf(r,e,t,n){return qr(r,e,1,t)}function gf(r,e,t,n){return qr(r,e,2,Oe(r,e+1,n))}function yf(r,e,t,n){return qr(r,e,3,He(r,e+1,n))}function wf(r,e,t,n){return qr(r,e,5,$e(r,e+1,n))}function xf(r,e,t,n){let o=Ke(r,e+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer map lengths not supported`);return qr(r,e,9,o)}function bf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return qr(r,e,1,1/0)}function gi(r,e){be(r,y.map.majorEncoded,e.value)}gi.compareTokens=ze.compareTokens;gi.encodedSize=function(e){return be.encodedSize(e.value)};function vf(r,e,t,n){return new V(y.tag,t,1)}function Ef(r,e,t,n){return new V(y.tag,Oe(r,e+1,n),2)}function Bf(r,e,t,n){return new V(y.tag,He(r,e+1,n),3)}function Af(r,e,t,n){return new V(y.tag,$e(r,e+1,n),5)}function Sf(r,e,t,n){return new V(y.tag,Ke(r,e+1,n),9)}function yi(r,e){be(r,y.tag.majorEncoded,e.value)}yi.compareTokens=ze.compareTokens;yi.encodedSize=function(e){return be.encodedSize(e.value)};var gm=20,ym=21,wm=22,xm=23;function If(r,e,t,n){if(n.allowUndefined===!1)throw new Error(`${H} undefined values are not supported`);return n.coerceUndefinedToNull===!0?new V(y.null,null,1):new V(y.undefined,void 0,1)}function Tf(r,e,t,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return new V(y.break,void 0,1)}function Sa(r,e,t){if(t){if(t.allowNaN===!1&&Number.isNaN(r))throw new Error(`${H} NaN values are not supported`);if(t.allowInfinity===!1&&(r===1/0||r===-1/0))throw new Error(`${H} Infinity values are not supported`)}return new V(y.float,r,e)}function kf(r,e,t,n){return Sa(Ia(r,e+1),3,n)}function Cf(r,e,t,n){return Sa(Ta(r,e+1),5,n)}function Nf(r,e,t,n){return Sa(Lf(r,e+1),9,n)}function wi(r,e,t){let n=e.value;if(n===!1)r.push([y.float.majorEncoded|gm]);else if(n===!0)r.push([y.float.majorEncoded|ym]);else if(n===null)r.push([y.float.majorEncoded|wm]);else if(n===void 0)r.push([y.float.majorEncoded|xm]);else{let o,i=!1;(!t||t.float64!==!0)&&(Rf(n),o=Ia(ot,1),n===o||Number.isNaN(n)?(ot[0]=249,r.push(ot.slice(0,3)),i=!0):(_f(n),o=Ta(ot,1),n===o&&(ot[0]=250,r.push(ot.slice(0,5)),i=!0))),i||(bm(n),o=Lf(ot,1),ot[0]=251,r.push(ot.slice(0,9)))}}wi.encodedSize=function(e,t){let n=e.value;if(n===!1||n===!0||n===null||n===void 0)return 1;if(!t||t.float64!==!0){Rf(n);let o=Ia(ot,1);if(n===o||Number.isNaN(n))return 3;if(_f(n),o=Ta(ot,1),n===o)return 5}return 9};var Uf=new ArrayBuffer(9),je=new DataView(Uf,1),ot=new Uint8Array(Uf,0);function Rf(r){if(r===1/0)je.setUint16(0,31744,!1);else if(r===-1/0)je.setUint16(0,64512,!1);else if(Number.isNaN(r))je.setUint16(0,32256,!1);else{je.setFloat32(0,r);let e=je.getUint32(0),t=(e&2139095040)>>23,n=e&8388607;if(t===255)je.setUint16(0,31744,!1);else if(t===0)je.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=t-127;o<-24?je.setUint16(0,0):o<-14?je.setUint16(0,(e&2147483648)>>16|1<<24+o,!1):je.setUint16(0,(e&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ia(r,e){if(r.length-e<2)throw new Error(`${H} not enough data for float16`);let t=(r[e]<<8)+r[e+1];if(t===31744)return 1/0;if(t===64512)return-1/0;if(t===32256)return NaN;let n=t>>10&31,o=t&1023,i;return n===0?i=o*2**-24:n!==31?i=(o+1024)*2**(n-25):i=o===0?1/0:NaN,t&32768?-i:i}function _f(r){je.setFloat32(0,r,!1)}function Ta(r,e){if(r.length-e<4)throw new Error(`${H} not enough data for float32`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,4).getFloat32(0,!1)}function bm(r){je.setFloat64(0,r,!1)}function Lf(r,e){if(r.length-e<8)throw new Error(`${H} not enough data for float64`);let t=(r.byteOffset||0)+e;return new DataView(r.buffer,t,8).getFloat64(0,!1)}wi.compareTokens=ze.compareTokens;function W(r,e,t){throw new Error(`${H} encountered invalid minor (${t}) for major ${r[e]>>>5}`)}function xi(r){return()=>{throw new Error(`${H} ${r}`)}}var T=[];for(let r=0;r<=23;r++)T[r]=W;T[24]=$l;T[25]=Kl;T[26]=ql;T[27]=zl;T[28]=W;T[29]=W;T[30]=W;T[31]=W;for(let r=32;r<=55;r++)T[r]=W;T[56]=jl;T[57]=Gl;T[58]=Zl;T[59]=Yl;T[60]=W;T[61]=W;T[62]=W;T[63]=W;for(let r=64;r<=87;r++)T[r]=Jl;T[88]=Xl;T[89]=Ql;T[90]=ef;T[91]=tf;T[92]=W;T[93]=W;T[94]=W;T[95]=xi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)T[r]=rf;T[120]=nf;T[121]=of;T[122]=sf;T[123]=af;T[124]=W;T[125]=W;T[126]=W;T[127]=xi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)T[r]=uf;T[152]=lf;T[153]=ff;T[154]=hf;T[155]=df;T[156]=W;T[157]=W;T[158]=W;T[159]=pf;for(let r=160;r<=183;r++)T[r]=mf;T[184]=gf;T[185]=yf;T[186]=wf;T[187]=xf;T[188]=W;T[189]=W;T[190]=W;T[191]=bf;for(let r=192;r<=215;r++)T[r]=vf;T[216]=Ef;T[217]=Bf;T[218]=Af;T[219]=Sf;T[220]=W;T[221]=W;T[222]=W;T[223]=W;for(let r=224;r<=243;r++)T[r]=xi("simple values are not supported");T[244]=W;T[245]=W;T[246]=W;T[247]=If;T[248]=xi("simple values are not supported");T[249]=kf;T[250]=Cf;T[251]=Nf;T[252]=W;T[253]=W;T[254]=W;T[255]=Tf;var it=[];for(let r=0;r<24;r++)it[r]=new V(y.uint,r,1);for(let r=-1;r>=-24;r--)it[31-r]=new V(y.negint,r,1);it[64]=new V(y.bytes,new Uint8Array(0),1);it[96]=new V(y.string,"",1);it[128]=new V(y.array,0,1);it[160]=new V(y.map,0,1);it[244]=new V(y.false,!1,1);it[245]=new V(y.true,!0,1);it[246]=new V(y.null,null,1);function Em(){let r=[];return r[y.uint.major]=ze,r[y.negint.major]=di,r[y.bytes.major]=$r,r[y.string.major]=cf,r[y.array.major]=mi,r[y.map.major]=gi,r[y.tag.major]=yi,r[y.float.major]=wi,r}var uv=Em(),lv=new hi,bi=class r{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do if(t.obj===e)return!0;while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${Ba} object contains circular references`);return new r(t,e)}},Gt={null:new V(y.null,null),undefined:new V(y.undefined,void 0),true:new V(y.true,!0),false:new V(y.false,!1),emptyArray:new V(y.array,0),emptyMap:new V(y.map,0)},Zt={number(r,e,t,n){return!Number.isInteger(r)||!Number.isSafeInteger(r)?new V(y.float,r):r>=0?new V(y.uint,r):new V(y.negint,r)},bigint(r,e,t,n){return r>=BigInt(0)?new V(y.uint,r):new V(y.negint,r)},Uint8Array(r,e,t,n){return new V(y.bytes,r)},string(r,e,t,n){return new V(y.string,r)},boolean(r,e,t,n){return r?Gt.true:Gt.false},null(r,e,t,n){return Gt.null},undefined(r,e,t,n){return Gt.undefined},ArrayBuffer(r,e,t,n){return new V(y.bytes,new Uint8Array(r))},DataView(r,e,t,n){return new V(y.bytes,new Uint8Array(r.buffer,r.byteOffset,r.byteLength))},Array(r,e,t,n){if(!r.length)return t.addBreakTokens===!0?[Gt.emptyArray,new V(y.break)]:Gt.emptyArray;n=bi.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=ka(s,t,n);return t.addBreakTokens?[new V(y.array,r.length),o,new V(y.break)]:[new V(y.array,r.length),o]},Object(r,e,t,n){let o=e!=="Object",i=o?r.keys():Object.keys(r),s=o?r.size:i.length;if(!s)return t.addBreakTokens===!0?[Gt.emptyMap,new V(y.break)]:Gt.emptyMap;n=bi.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[ka(f,t,n),ka(o?r.get(f):r[f],t,n)];return Bm(a,t),t.addBreakTokens?[new V(y.map,s),a,new V(y.break)]:[new V(y.map,s),a]}};Zt.Map=Zt.Object;Zt.Buffer=Zt.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Zt[`${r}Array`]=Zt.DataView;function ka(r,e={},t){let n=Rl(r),o=e&&e.typeEncoders&&e.typeEncoders[n]||Zt[n];if(typeof o=="function"){let s=o(r,n,e,t);if(s!=null)return s}let i=Zt[n];if(!i)throw new Error(`${Ba} unsupported type: ${n}`);return i(r,n,e,t)}function Bm(r,e){e.mapSorter&&r.sort(e.mapSorter)}var Am={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},vi=class{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){let e=this.data[this._pos],t=it[e];if(t===void 0){let n=T[e];if(!n)throw new Error(`${H} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);let o=e&31;t=n(this.data,this._pos,o,this.options)}return this._pos+=t.encodedLength,t}},Sn=Symbol.for("DONE"),Ei=Symbol.for("BREAK");function Sm(r,e,t){let n=[];for(let o=0;o<r.value;o++){let i=zr(e,t);if(i===Ei){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed array`)}if(i===Sn)throw new Error(`${H} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Im(r,e,t){let n=t.useMaps===!0,o=n?void 0:{},i=n?new Map:void 0;for(let s=0;s<r.value;s++){let a=zr(e,t);if(a===Ei){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed map`)}if(a===Sn)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(t.rejectDuplicateMapKeys===!0&&(n&&i.has(a)||!n&&a in o))throw new Error(`${H} found repeat map key "${a}"`);let c=zr(e,t);if(c===Sn)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 zr(r,e){if(r.done())return Sn;let t=r.next();if(t.type===y.break)return Ei;if(t.type.terminal)return t.value;if(t.type===y.array)return Sm(t,r,e);if(t.type===y.map)return Im(t,r,e);if(t.type===y.tag){if(e.tags&&typeof e.tags[t.value]=="function"){let n=zr(r,e);return e.tags[t.value](n)}throw new Error(`${H} tag not supported (${t.value})`)}throw new Error("unsupported")}function Vf(r,e){if(!(r instanceof Uint8Array))throw new Error(`${H} data to decode must be a Uint8Array`);e=Object.assign({},Am,e);let t=e.tokenizer||new vi(r,e),n=zr(t,e);if(n===Sn)throw new Error(`${H} did not find any content to decode`);if(n===Ei)throw new Error(`${H} got unexpected break`);return[n,r.subarray(t.pos())]}function Ca(r,e){let[t,n]=Vf(r,e);if(n.length>0)throw new Error(`${H} too many terminals, data makes no sense`);return t}var Cm=_t("ipns:utils"),Pf=j("/ipns/");var Nm=0,Um=18;function Ff(r){let e;if(r.pubKey!=null)try{e=fl(r.pubKey)}catch(t){throw Cm.error(t),t}if(e!=null)return e}function Df(r){let e=j("ipns-signature:");return Me([e,r])}function ur(r){return"signatureV1"in r?nt.encode({value:j(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:j(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):nt.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function dt(r){let e=nt.decode(r);if(e.sequence!=null&&(e.sequence=BigInt(e.sequence)),e.ttl!=null&&(e.ttl=BigInt(e.ttl)),e.signatureV2==null||e.data==null)throw new rt("Missing data or signatureV2");let t=Mf(e.data),n=Rm(t.Value),o=ne(t.Validity);if(e.value!=null&&e.signatureV1!=null)return _m(e),{value:n,validityType:nt.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV1:e.signatureV1,signatureV2:e.signatureV2,data:e.data};if(e.signatureV2!=null)return{value:n,validityType:nt.ValidityType.EOL,validity:o,sequence:t.Sequence,ttl:t.TTL,pubKey:e.pubKey,signatureV2:e.signatureV2,data:e.data};throw new Error("invalid record: does not include signatureV1 or signatureV2")}function In(r){return Me([Pf,r.bytes])}function Ut(r){let e=yt(r.slice(Pf.length));if(!Bi(e,Nm)&&!Bi(e,Um))throw new hr("Multihash in IPNS key was not identity or sha2-256");return e}function Mf(r){let e=Ca(r);if(e.ValidityType===0)e.ValidityType=nt.ValidityType.EOL;else throw new Mr("The validity type is unsupported");return Number.isInteger(e.Sequence)&&(e.Sequence=BigInt(e.Sequence)),Number.isInteger(e.TTL)&&(e.TTL=BigInt(e.TTL)),e}function Rm(r){let e=ne(r).trim();if(e.startsWith("/"))return e;try{return`/ipfs/${X.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${X.parse(e).toV1().toString()}`}catch{}throw new ui("Value must be a valid content path starting with /")}function _m(r){if(r.data==null)throw new li("Record data is missing");let e=Mf(r.data);if(!ce(e.Value,r.value??new Uint8Array(0)))throw new rt('Field "value" did not match between protobuf and CBOR');if(!ce(e.Validity,r.validity??new Uint8Array(0)))throw new rt('Field "validity" did not match between protobuf and CBOR');if(e.ValidityType!==r.validityType)throw new rt('Field "validityType" did not match between protobuf and CBOR');if(e.Sequence!==r.sequence)throw new rt('Field "sequence" did not match between protobuf and CBOR');if(e.TTL!==r.ttl)throw new rt('Field "ttl" did not match between protobuf and CBOR')}function Bi(r,e){return r.code===e}var Lv=_t("ipns"),Vv=60*60*1e9,Vm="/ipns/",Pv=Vm.length;var Of=_n(Ea(),1);var Ai=_t("ipns:validator"),Pm=1024*10,Fm=async(r,e)=>{let t=dt(e),n;try{let o=Df(t.data);n=await r.verify(o,t.signatureV2)}catch{n=!1}if(!n)throw Ai.error("record signature verification failed"),new rt("Record signature verification failed");if(t.validityType===nt.ValidityType.EOL){if(Of.default.fromString(t.validity).toDate().getTime()<Date.now())throw Ai.error("record has expired"),new ai("record has expired")}else if(t.validityType!=null)throw Ai.error("the validity type is unsupported"),new Mr("The validity type is unsupported");Ai("ipns record for %s is valid",t.value)};async function Hf(r,e){if(e.byteLength>Pm)throw new ci("The record is too large");let t=Ut(r),n;Bi(t,0)&&(n=Xo(t));let o=dt(e),i=Ff(o)??n;if(i==null)throw new vn("Could not extract public key from IPNS record or routing key");let s=In(i.toMultihash());if(!ce(r,s))throw new vn("Embedded public key did not match routing key");await Fm(i,e)}var Si=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*Tn(r,e={}){let t=/\r?\n/,n=new TextDecoder("utf8"),o="";for await(let i of r){if(typeof i=="string"&&(i=new TextEncoder().encode(i)),o+=n.decode(i,{stream:!0}),o.length>(e?.maxMessageLength??o.length))throw new Si("Incoming message too long");let s=o.split(t);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 pt(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ua=_n(Kf(),1);var Cn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Ra=class extends Error{constructor(e){super(),this.name="AbortError",this.message=e}},qf=r=>globalThis.DOMException===void 0?new Ra(r):new DOMException(r),zf=r=>{let e=r.reason===void 0?qf("This operation was aborted."):r.reason;return e instanceof Error?e:qf(e)};function _a(r,e){let{milliseconds:t,fallback:n,message:o,customTimers:i={setTimeout,clearTimeout}}=e,s,a,f=new Promise((u,l)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(e.signal){let{signal:g}=e;g.aborted&&l(zf(g)),a=()=>{l(zf(g))},g.addEventListener("abort",a,{once:!0})}if(t===Number.POSITIVE_INFINITY){r.then(u,l);return}let h=new Cn;s=i.setTimeout.call(void 0,()=>{if(n){try{u(n())}catch(g){l(g)}return}typeof r.cancel=="function"&&r.cancel(),o===!1?u():o instanceof Error?l(o):(h.message=o??`Promise timed out after ${t} milliseconds`,l(h))},t),(async()=>{try{u(await r)}catch(g){l(g)}})()}).finally(()=>{f.clear(),a&&e.signal&&e.signal.removeEventListener("abort",a)});return f.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},f}function La(r,e,t){let n=0,o=r.length;for(;o>0;){let i=Math.trunc(o/2),s=n+i;t(r[s],e)<=0?(n=++s,o-=i+1):o=i}return n}var Nn=class{#e=[];enqueue(e,t){t={priority:0,...t};let n={priority:t.priority,run:e};if(this.size&&this.#e[this.size-1].priority>=t.priority){this.#e.push(n);return}let o=La(this.#e,n,(i,s)=>s.priority-i.priority);this.#e.splice(o,0,n)}dequeue(){return this.#e.shift()?.run}filter(e){return this.#e.filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return this.#e.length}};var Un=class extends Ua.default{#e;#r;#t=0;#a;#c;#p=0;#o;#u;#n;#m;#i=0;#l;#s;#g;timeout;constructor(e){if(super(),e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Nn,...e},!(typeof e.intervalCap=="number"&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#e=e.carryoverConcurrencyCount,this.#r=e.intervalCap===Number.POSITIVE_INFINITY||e.interval===0,this.#a=e.intervalCap,this.#c=e.interval,this.#n=new e.queueClass,this.#m=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#g=e.throwOnTimeout===!0,this.#s=e.autoStart===!1}get#x(){return this.#r||this.#t<this.#a}get#b(){return this.#i<this.#l}#v(){this.#i--,this.#f(),this.emit("next")}#E(){this.#w(),this.#y(),this.#u=void 0}get#B(){let e=Date.now();if(this.#o===void 0){let t=this.#p-e;if(t<0)this.#t=this.#e?this.#i:0;else return this.#u===void 0&&(this.#u=setTimeout(()=>{this.#E()},t)),!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 e=!this.#B;if(this.#x&&this.#b){let t=this.#n.dequeue();return t?(this.emit("active"),t(),e&&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.#t===0&&this.#i===0&&this.#o&&(clearInterval(this.#o),this.#o=void 0),this.#t=this.#e?this.#i:0,this.#h()}#h(){for(;this.#f(););}get concurrency(){return this.#l}set concurrency(e){if(!(typeof e=="number"&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#l=e,this.#h()}async#A(e){return new Promise((t,n)=>{e.addEventListener("abort",()=>{n(e.reason)},{once:!0})})}async add(e,t={}){return t={timeout:this.timeout,throwOnTimeout:this.#g,...t},new Promise((n,o)=>{this.#n.enqueue(async()=>{this.#i++,this.#t++;try{t.signal?.throwIfAborted();let i=e({signal:t.signal});t.timeout&&(i=_a(Promise.resolve(i),{milliseconds:t.timeout})),t.signal&&(i=Promise.race([i,this.#A(t.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof Cn&&!t.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},t),this.emit("add"),this.#f()})}async addAll(e,t){return Promise.all(e.map(async n=>this.add(n,t)))}start(){return this.#s?(this.#s=!1,this.#h(),this):this}pause(){this.#s=!0}clear(){this.#n=new this.#m}async onEmpty(){this.#n.size!==0&&await this.#d("empty")}async onSizeLessThan(e){this.#n.size<e||await this.#d("next",()=>this.#n.size<e)}async onIdle(){this.#i===0&&this.#n.size===0||await this.#d("idle")}async#d(e,t){return new Promise(n=>{let o=()=>{t&&!t()||(this.off(e,o),n())};this.on(e,o)})}get size(){return this.#n.size}sizeBy(e){return this.#n.filter(e).length}get pending(){return this.#i}get isPaused(){return this.#s}};var jr=class extends Error{static name="InvalidRequestError";constructor(e="Invalid request"){super(e),this.name="InvalidRequestError"}},lr=class extends Error{static name="BadResponseError";constructor(e="Bad response"){super(e),this.name="BadResponseError"}};function Om(r){return r[Symbol.asyncIterator]!=null}function Hm(r){if(Om(r))return(async()=>{for await(let e of r)return e})();for(let e of r)return e}var Ti=Hm;function $m(r){let[e,t]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[t](){return this}}}var jf=$m;function Km(r){return r[Symbol.asyncIterator]!=null}function qm(r,e){let t=0;if(Km(r))return async function*(){for await(let c of r)yield e(c,t++)}();let n=jf(r),{value:o,done:i}=n.next();if(i===!0)return function*(){}();let s=e(o,t++);if(typeof s.then=="function")return async function*(){yield await s;for await(let c of n)yield e(c,t++)}();let a=e;return function*(){yield s;for(let c of n)yield a(c,t++)}()}var ki=qm;var Gf=j("/ipns/");function Zf(r){return ce(r.subarray(0,Gf.byteLength),Gf)}var Ci=class{client;constructor(e){this.client=e}async*findProviders(e,t={}){yield*ki(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(e,t,n){if(!Zf(e))return;let o=Ut(e),i=X.createV1(114,o),s=dt(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!Zf(e))throw new Re("Not found");let n=Ut(e),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return ur(i)}catch(i){throw i.name==="BadResponseError"?new Re("Not found"):i}}},Ni=class{client;constructor(e){this.client=e}async findPeer(e,t={}){let n=await Ti(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Re("Not found")}async*getClosestPeers(e,t={}){}};var ge=_t("delegated-routing-v1-http-api-client"),Ui={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},Ri=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(e,t={}){this.started=!1,this.shutDownController=new AbortController,pr(1/0,this.shutDownController.signal),this.httpQueue=new Un({concurrency:t.concurrentRequests??Ui.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=e instanceof URL?e:new URL(e),this.timeout=t.timeout??Ui.timeout,this.filterAddrs=t.filterAddrs,this.filterProtocols=t.filterProtocols,this.contentRouting=new Ci(this),this.peerRouting=new Ni(this),this.cacheName=t.cacheName??Ui.cacheName,this.cacheTTL=t.cacheTTL??Ui.cacheTTL}get[Qa](){return this.contentRouting}get[ec](){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&&ge("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(e,t={}){ge("getProviders starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);pr(1/0,n,o);let i=pt(),s=pt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/providers/${e.toString()}`);this.#r(a,t.filterAddrs,t.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#t(a.toString(),c);if(f.status===404)throw new Re("No matching records found");if(f.status===422)throw new jr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new lr("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Providers){let g=this.#e(h);g!=null&&(yield g)}}else for await(let l of Tn(si(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){ge.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),ge("getProviders finished: %c",e)}}async*getPeers(e,t={}){ge("getPeers starts: %c",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);pr(1/0,n,o);let i=pt(),s=pt();this.httpQueue.add(async()=>(i.resolve(),s.promise));try{await i.promise;let a=new URL(`${this.clientUrl}routing/v1/peers/${e.toCID().toString()}`);this.#r(a,t.filterAddrs,t.filterProtocols);let c={headers:{Accept:"application/x-ndjson"},signal:o},f=await this.#t(a.toString(),c);if(f.status===404)throw new Re("No matching records found");if(f.status===422)throw new jr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new lr("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 g=this.#e(h);g!=null&&(yield g)}}else for await(let l of Tn(si(f.body))){let h=this.#e(l);h!=null&&(yield h)}}catch(a){ge.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),ge("getPeers finished: %c",e)}}async getIPNS(e,t={}){ge("getIPNS starts: %s",e);let n=AbortSignal.timeout(this.timeout),o=bn([this.shutDownController.signal,n,t.signal]);pr(1/0,n,o);let i=pt(),s=pt();this.httpQueue.add(async()=>(i.resolve(),s.promise));let a=`${this.clientUrl}routing/v1/ipns/${e}`;try{await i.promise;let c={headers:{Accept:"application/vnd.ipfs.ipns-record"},signal:o},f=await this.#t(a,c);if(ge("getIPNS GET %s %d",a,f.status),f.status===404)throw new Re("No matching records found");if(f.status===422)throw new jr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new lr("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return t.validate!==!1&&await Hf(In(e.multihash),l),dt(l)}catch(c){throw ge.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),ge("getIPNS finished: %s",e)}}async putIPNS(e,t,n={}){ge("putIPNS starts: %c",e);let o=AbortSignal.timeout(this.timeout),i=bn([this.shutDownController.signal,o,n.signal]);pr(1/0,o,i);let s=pt(),a=pt();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${e}`;try{await s.promise;let f=ur(t),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#t(c,u);if(ge("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new lr("PUT ipns response had status other than 200")}catch(f){throw ge.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),ge("putIPNS finished: %c",e)}}#e(e){try{let t=[],n=e.Addrs?.map(ar)??[];return e.Protocols!=null&&t.push(...e.Protocols),e.Protocol!=null&&(t.push(e.Protocol),delete e.Protocol),{...e,Schema:"peer",ID:pl(e.ID),Addrs:n,Protocols:t}}catch(t){ge.error("could not conform record to peer schema",t)}}#r(e,t,n){if(t!=null||this.filterAddrs!=null){let o=t?.join(",")??this.filterAddrs?.join(",")??"";o!==""&&e.searchParams.set("filter-addrs",o)}if(n!=null||this.filterProtocols!=null){let o=n?.join(",")??this.filterProtocols?.join(",")??"";o!==""&&e.searchParams.set("filter-protocols",o)}}async#t(e,t){let n=t.method??"GET",o=`${n}-${e}`;if(n==="GET"){let c=await this.cache?.match(e);if(c!=null){if(parseInt(c.headers.get("x-cache-expires")??"0",10)>Date.now())return ge("returning cached response for %s",o),c;await this.cache?.delete(e)}}let i=this.inFlightRequests.get(o);if(i!=null){let c=await i;return ge("deduplicating outgoing request for %s",o),c.clone()}let s=fetch(e,t).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(e,l)}return c}).finally(()=>{this.inFlightRequests.delete(o)});return this.inFlightRequests.set(o,s),await s}};function Wf(r,e={}){return new Ri(new URL(r),e)}function _i(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var Yf=j("/ipns/");function Jf(r){return ce(r.subarray(0,Yf.byteLength),Yf)}var Va=class{client;constructor(e,t={}){this.client=Wf(e,t)}async provide(e,t){}async cancelReprovide(e,t){}async*findProviders(e,t){yield*ki(this.client.getProviders(e,t),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(e,t,n){if(!Jf(e))return;let o=Ut(e),i=X.createV1(114,o),s=dt(t);await this.client.putIPNS(i,s,n)}async get(e,t){if(!Jf(e))throw new Re("Not found");let n=Ut(e),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,t);return ur(i)}catch(i){throw i.name==="BadResponseError"?new Re("Not found"):i}}async findPeer(e,t){let n=await Ti(this.client.getPeers(e,t));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Re("Not found")}async*getClosestPeers(e,t){}};function Xf(r,e){let t=e??_i();return new Va(new URL(r),t)}var Qf="[a-fA-F\\d:]",Wt=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${Qf})|(?<=${Qf})(?=\\s|$))`:"",st="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",ue="[a-fA-F\\d]{1,4}",Li=`
5
+ `));let e=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return t.length?`${e} :
6
+ ${t.join(`
7
+ `)}`:`${e} :`}};pu=je;V.Constructed=pu;je.NAME="CONSTRUCTED";var mo=class extends St{fromBER(t,e,n){return e}toBER(t){return ee}};mo.override="EndOfContentValueBlock";var gu,yo=class extends wt{constructor(t={}){super(t,mo),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};gu=yo;V.EndOfContent=gu;yo.NAME=fn;var mu,Lr=class extends wt{constructor(t={}){super(t,St),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}`}};mu=Lr;V.Null=mu;Lr.NAME="NULL";var wo=class extends Te(St){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=G.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=G.BufferSourceConverter.toUint8Array(t);return ke(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,Ws.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};wo.NAME="BooleanValueBlock";var yu,xo=class extends wt{constructor(t={}){super(t,wo),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}`}};yu=xo;V.Boolean=yu;xo.NAME="BOOLEAN";var bo=class extends Te(le){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=le.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===fn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(s!==lu)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?le.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};bo.NAME="OctetStringValueBlock";var wu,vo=class r extends wt{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},bo),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=Wo(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?je.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${G.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 G.BufferSourceConverter.concat(t)}};wu=vo;V.OctetString=wu;vo.NAME=lu;var Eo=class extends Te(le){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=le.prototype.fromBER.call(this,t,e,n),o===-1)return o;for(let a of this.value){let c=a.constructor.NAME;if(c===fn){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==fu)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=G.BufferSourceConverter.toUint8Array(t);if(!ke(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=Wo(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 le.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return ee;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}}};Eo.NAME="BitStringValueBlock";var xu,Vr=class extends wt{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},Eo),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 je.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)}`}}};xu=Vr;V.BitString=xu;Vr.NAME=fu;var bu;function bp(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=co(new Uint8Array([f%10]),i);break;default:i[s-l]=f%10}}return e[0]>0&&(i=co(e,i)),i}function uu(r){if(r>=un.length)for(let t=un.length;t<=r;t++){let e=new Uint8Array([0]),n=un[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=co(e,n)),un.push(n)}return un[r]}function vp(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 hn=class extends Te(St){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=Ws.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(su(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=vp(uu(n),e),s="-";break;default:e=bp(e,uu(n))}n++,o>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(s+=cu.charAt(e[c]));return a===!1&&(s+=cu.charAt(0)),s}};bu=hn;hn.NAME="IntegerValueBlock";Object.defineProperty(bu.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var vu,xt=class r extends wt{constructor(t={}){super(t,hn),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return uo(),BigInt(this.valueBlock.toString())}static fromBigInt(t){uo();let e=BigInt(t),n=new ln,o=e.toString(16).replace(/^-/,""),i=new Uint8Array(G.Convert.FromHex(o));if(e<0){let a=new Uint8Array(i.length+(i[0]&128?1:0));a[0]|=128;let f=BigInt(`0x${G.Convert.ToHex(a)}`)+e,u=G.BufferSourceConverter.toUint8Array(G.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()}`}};vu=xt;V.Integer=vu;xt.NAME="INTEGER";var Eu,Bo=class extends xt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Eu=Bo;V.Enumerated=Eu;Bo.NAME="ENUMERATED";var dn=class extends Te(St){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=G.BufferSourceConverter.toUint8Array(t);if(!ke(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=sr(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){uo();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=ze(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",ee;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=G.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}}};dn.NAME="sidBlock";var Ao=class extends St{constructor({value:t=Pr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let o=e;for(;n>0;){let i=new dn;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,ee;e.push(o)}return Ys(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 dn;if(o>Number.MAX_SAFE_INTEGER){uo();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}};Ao.NAME="ObjectIdentifierValueBlock";var Bu,_r=class extends wt{constructor(t={}){super(t,Ao),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()}}};Bu=_r;V.ObjectIdentifier=Bu;_r.NAME="OBJECT IDENTIFIER";var pn=class extends Te(Ae){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let o=G.BufferSourceConverter.toUint8Array(t);if(!ke(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=sr(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=ze(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",ee;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=G.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};pn.NAME="relativeSidBlock";var So=class extends St{constructor({value:t=Pr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let o=e;for(;n>0;){let i=new pn;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,ee;n.push(i)}return Ys(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 pn;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}};So.NAME="RelativeObjectIdentifierValueBlock";var Au,Io=class extends wt{constructor(t={}){super(t,So),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()}}};Au=Io;V.RelativeObjectIdentifier=Au;Io.NAME="RelativeObjectIdentifier";var Su,Se=class extends je{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Su=Se;V.Sequence=Su;Se.NAME="SEQUENCE";var Iu,ko=class extends je{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Iu=ko;V.Set=Iu;ko.NAME="SET";var To=class extends Te(St){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=Pr}toJSON(){return{...super.toJSON(),value:this.value}}};To.NAME="StringValueBlock";var Co=class extends To{};Co.NAME="SimpleStringValueBlock";var Nt=class extends ho{constructor({...t}={}){super(t,Co)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,G.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}};Nt.NAME="SIMPLE STRING";var No=class extends Nt{fromBuffer(t){this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=G.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=G.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf8String(t)),this.valueBlock.value=t}};No.NAME="Utf8StringValueBlock";var ku,Ie=class extends No{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};ku=Ie;V.Utf8String=ku;Ie.NAME="UTF8String";var Uo=class extends Nt{fromBuffer(t){this.valueBlock.value=G.Convert.ToUtf16String(t),this.valueBlock.valueHexView=G.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(G.Convert.FromUtf16String(t))}};Uo.NAME="BmpStringValueBlock";var Tu,Ro=class extends Uo{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Tu=Ro;V.BmpString=Tu;Ro.NAME="BMPString";var Lo=class extends Nt{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=ze(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}};Lo.NAME="UniversalStringValueBlock";var Cu,Vo=class extends Lo{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Cu=Vo;V.UniversalString=Cu;Vo.NAME="UniversalString";var Nu,_o=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Nu=_o;V.NumericString=Nu;_o.NAME="NumericString";var Uu,Po=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Uu=Po;V.PrintableString=Uu;Po.NAME="PrintableString";var Ru,Fo=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Ru=Fo;V.TeletexString=Ru;Fo.NAME="TeletexString";var Lu,Do=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Lu=Do;V.VideotexString=Lu;Do.NAME="VideotexString";var Vu,Oo=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Vu=Oo;V.IA5String=Vu;Oo.NAME="IA5String";var _u,Mo=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};_u=Mo;V.GraphicString=_u;Mo.NAME="GraphicString";var Pu,gn=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Pu=gn;V.VisibleString=Pu;gn.NAME="VisibleString";var Fu,Ho=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Fu=Ho;V.GeneralString=Fu;Ho.NAME="GeneralString";var Du,$o=class extends Nt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Du=$o;V.CharacterString=Du;$o.NAME="CharacterString";var Ou,mn=class extends gn{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,G.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]=Ot(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Ot(this.month,2),e[2]=Ot(this.day,2),e[3]=Ot(this.hour,2),e[4]=Ot(this.minute,2),e[5]=Ot(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}}};Ou=mn;V.UTCTime=Ou;mn.NAME="UTCTime";var Mu,Ko=class extends mn{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(Ot(this.year,4)),e.push(Ot(this.month,2)),e.push(Ot(this.day,2)),e.push(Ot(this.hour,2)),e.push(Ot(this.minute,2)),e.push(Ot(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(Ot(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Mu=Ko;V.GeneralizedTime=Mu;Ko.NAME="GeneralizedTime";var Hu,qo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Hu=qo;V.DATE=Hu;qo.NAME="DATE";var $u,zo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};$u=zo;V.TimeOfDay=$u;zo.NAME="TimeOfDay";var Ku,jo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Ku=jo;V.DateTime=Ku;jo.NAME="DateTime";var qu,Go=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};qu=Go;V.Duration=qu;Go.NAME="Duration";var zu,Zo=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};zu=Zo;V.TIME=zu;Zo.NAME="TIME";function nt(r,t="utf8"){let e=no[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var yn=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},Yo=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var ju={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new Yo("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 Ge=ju;async function Gu(r){let t=await Ge.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 Bp(t);return{privateKey:e[0],publicKey:e[1]}}async function Zu(r,t){let e=await Ge.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ge.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Wu(r,t,e){let n=await Ge.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ge.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function Bp(r){if(r.privateKey==null||r.publicKey==null)throw new Et("Private and public key are required");return Promise.all([Ge.get().subtle.exportKey("jwk",r.privateKey),Ge.get().subtle.exportKey("jwk",r.publicKey)])}function Qs(r){if(r.kty!=="RSA")throw new Et("invalid key type");if(r.n==null)throw new Et("invalid key modulus");return j(r.n,"base64url").length*8}var Fr=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=wn.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return X.createV1(114,this._multihash)}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,e){return Wu(this._key,e,t)}},xn=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=wn.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}sign(t){return Zu(this._key,t)}};var Jo=8192,ta=18;function Yu(r){let{result:t}=Xs(r),e=t.valueBlock.value;return{n:fe(e[1]),e:fe(e[2]),d:fe(e[3]),p:fe(e[4]),q:fe(e[5]),dp:fe(e[6]),dq:fe(e[7]),qi:fe(e[8]),kty:"RSA",alg:"RS256"}}function Ap(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 Et("JWK was missing components");let e=new Se({value:[new xt({value:0}),xt.fromBigInt(he(j(r.n,"base64url"))),xt.fromBigInt(he(j(r.e,"base64url"))),xt.fromBigInt(he(j(r.d,"base64url"))),xt.fromBigInt(he(j(r.p,"base64url"))),xt.fromBigInt(he(j(r.q,"base64url"))),xt.fromBigInt(he(j(r.dp,"base64url"))),xt.fromBigInt(he(j(r.dq,"base64url"))),xt.fromBigInt(he(j(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Ju(r){let{result:t}=Xs(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:fe(e[0]),e:fe(e[1])}}function ea(r){if(r.n==null||r.e==null)throw new Et("JWK was missing components");let e=new Se({value:[new Se({value:[new _r({value:"1.2.840.113549.1.1.1"}),new Lr]}),new Vr({valueHex:new Se({value:[xt.fromBigInt(he(j(r.n,"base64url"))),xt.fromBigInt(he(j(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function fe(r){let t=r.valueBlock.valueHexView;for(;t[0]===0;)t=t.subarray(1);return nt(t,"base64url")}function he(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 Xu(r){let t=Yu(r);return Qu(t)}function ra(r){let t=Ju(r);if(Qs(t)>Jo)throw new hr("Key size is too large");let e=Ur(ue.encode({Type:ft.RSA,Data:r})),n=Wt(ta,e);return new Fr(t,n)}function Qu(r){if(Qs(r)>Jo)throw new Et("Key size is too large");let t=el(r),e=Ur(ue.encode({Type:ft.RSA,Data:ea(t.publicKey)})),n=Wt(ta,e);return new xn(t.privateKey,new Fr(t.publicKey,n))}async function tl(r){if(r>Jo)throw new Et("Key size is too large");let t=await Gu(r),e=Ur(ue.encode({Type:ft.RSA,Data:ea(t.publicKey)})),n=Wt(ta,e);return new xn(t.privateKey,new Fr(t.publicKey,n))}function el(r){if(r==null)throw new Et("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Xo=class extends Br{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,vc(t);let n=Qr(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 Er(this),this.iHash.update(t),this}digestInto(t){Er(this),vr(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()}},na=(r,t,e)=>new Xo(r,t).update(e).digest();na.create=(r,t)=>new Xo(r,t);function rl(r){r.lowS!==void 0&&Xt("lowS",r.lowS),r.prehash!==void 0&&Xt("prehash",r.prehash)}function Sp(r){let t=rn(r);ce(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:Ip,hexToBytes:kp}=Gn,oa=class extends Error{constructor(t=""){super(t)}},Ce={Err:oa,_tlv:{encode:(r,t)=>{let{Err:e}=Ce;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=Xe(n);if(o.length/2&128)throw new e("tlv.encode: long form length too big");let i=n>127?Xe(o.length/2|128):"";return Xe(r)+i+o+t},decode(r,t){let{Err:e}=Ce,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}=Ce;if(r<Ne)throw new t("integer: negative integers are not allowed");let e=Xe(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}=Ce;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 Ip(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=Ce,o=typeof r=="string"?kp(r):r;Sr(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}=Ce,n=t.encode(2,e.encode(r.r)),o=t.encode(2,e.encode(r.s)),i=n+o;return t.encode(48,i)}},Ne=BigInt(0),pt=BigInt(1),Nx=BigInt(2),nl=BigInt(3),Ux=BigInt(4);function Tp(r){let t=Sp(r),{Fp:e}=t,n=He(t.n,t.nBitLength),o=t.toBytes||((w,d,A)=>{let T=d.toAffine();return ve(Uint8Array.from([4]),e.toBytes(T.x),e.toBytes(T.y))}),i=t.fromBytes||(w=>{let d=w.subarray(1),A=e.fromBytes(d.subarray(0,e.BYTES)),T=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:A,y:T}});function s(w){let{a:d,b:A}=t,T=e.sqr(w),x=e.mul(T,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 tn(w,pt,t.n)}function c(w){let{allowedPrivateKeyLengths:d,nByteLength:A,wrapPrivateKey:T,n:x}=t;if(d&&typeof w!="bigint"){if(De(w)&&(w=xe(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:be(at("private key",w,A))}catch{throw new Error("invalid private key, expected hex or "+A+" bytes, got "+typeof w)}return T&&(U=Q(U,x)),_t("private key",U,pt,x),U}function f(w){if(!(w instanceof h))throw new Error("ProjectivePoint expected")}let u=er((w,d)=>{let{px:A,py:T,pz:x}=w;if(e.eql(x,e.ONE))return{x:A,y:T};let U=w.is0();d==null&&(d=U?e.ONE:e.inv(x));let F=e.mul(A,d),P=e.mul(T,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=er(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 T=e.sqr(A),x=s(d);if(!e.eql(T,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,T){if(this.px=d,this.py=A,this.pz=T,d==null||!e.isValid(d))throw new Error("x required");if(A==null||!e.isValid(A))throw new Error("y required");if(T==null||!e.isValid(T))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:A,y:T}=d||{};if(!d||!e.isValid(A)||!e.isValid(T))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(T)?h.ZERO:new h(A,T,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let A=e.invertBatch(d.map(T=>T.pz));return d.map((T,x)=>T.toAffine(A[x])).map(h.fromAffine)}static fromHex(d){let A=h.fromAffine(i(at("pointHex",d)));return A.assertValidity(),A}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,A){return Jn(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:T,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(T,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,T=e.mul(A,nl),{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),C=e.mul(x,U);return C=e.add(C,C),b=e.mul(x,F),b=e.add(b,b),P=e.mul(d,b),R=e.mul(T,L),R=e.add(P,R),P=e.sub(D,R),R=e.add(D,R),R=e.mul(P,R),P=e.mul(C,P),b=e.mul(T,b),L=e.mul(d,L),C=e.sub(v,L),C=e.mul(d,C),C=e.add(C,b),b=e.add(v,v),v=e.add(b,v),v=e.add(v,L),v=e.mul(v,C),R=e.add(R,v),L=e.mul(U,F),L=e.add(L,L),v=e.mul(L,C),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:T,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,nl),C=e.mul(A,U),$=e.mul(T,F),S=e.mul(x,P),I=e.add(A,T),g=e.add(U,F);I=e.mul(I,g),g=e.add(C,$),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(C,S),g=e.sub(g,p),p=e.add(T,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(C,C),$=e.add($,C),S=e.mul(D,S),g=e.mul(L,g),$=e.add($,S),S=e.sub(C,S),S=e.mul(D,S),g=e.add(g,S),C=e.mul($,g),b=e.add(b,C),C=e.mul(p,g),R=e.mul(I,R),R=e.sub(R,C),C=e.mul(I,$),v=e.mul(p,v),v=e.add(v,C),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:T}=t;_t("scalar",d,Ne,T);let x=h.ZERO;if(d===Ne)return x;if(this.is0()||d===pt)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>Ne||R>Ne;)F&pt&&(b=b.add(D)),R&pt&&(v=v.add(D)),D=D.double(),F>>=pt,R>>=pt;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:T}=t;_t("scalar",d,pt,T);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:C}=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(C)}else{let{p:F,f:P}=this.wNAF(d);x=F,U=P}return h.normalizeZ([x,U])[0]}multiplyAndAddUnsafe(d,A,T){let x=h.BASE,U=(P,R)=>R===Ne||R===pt||!P.equals(x)?P.multiplyUnsafe(R):P.multiply(R),F=U(this,A).add(U(d,T));return F.is0()?void 0:F}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:A}=t;if(d===pt)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===pt?this:A?A(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Xt("isCompressed",d),this.assertValidity(),o(h,this,d)}toHex(d=!0){return Xt("isCompressed",d),xe(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=Yn(h,t.endo?Math.ceil(m/2):m);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function Cp(r){let t=rn(r);return ce(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function ol(r){let t=Cp(r),{Fp:e,n}=t,o=e.BYTES+1,i=2*e.BYTES+1;function s(S){return Q(S,n)}function a(S){return Zn(S,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:l}=Tp({...t,toBytes(S,I,g){let p=I.toAffine(),E=e.toBytes(p.x),N=ve;return Xt("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=be(p);if(!tn(E,pt,e.ORDER))throw new Error("Point is not on curve");let N=u(E),O;try{O=e.sqrt(N)}catch(Z){let K=Z instanceof Error?": "+Z.message:"";throw new Error("Point is not on curve"+K)}let M=(O&pt)===pt;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=>xe(Me(S,t.nByteLength));function m(S){let I=n>>pt;return S>I}function B(S){return m(S)?s(-S):S}let w=(S,I,g)=>be(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=at("compactSignature",I,g*2),new d(w(I,0,g),w(I,g,2*g))}static fromDER(I){let{r:g,s:p}=Ce.toSig(at("DER",I));return new d(g,p)}assertValidity(){_t("r",this.r,pt,n),_t("s",this.s,pt,n)}addRecoveryBit(I){return new d(this.r,this.s,I)}recoverPublicKey(I){let{r:g,s:p,recovery:E}=this,N=P(at("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)),Z=a(O),K=s(-N*Z),J=s(p*Z),et=c.BASE.multiplyAndAddUnsafe(z,K,J);if(!et)throw new Error("point at infinify");return et.assertValidity(),et}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return Qe(this.toDERHex())}toDERHex(){return Ce.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Qe(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=ls(t.n);return Vc(t.randomBytes(S),t.n)},precompute(S=8,I=c.BASE){return I._setWindowSize(S),I.multiply(BigInt(3)),I}};function T(S,I=!0){return c.fromPrivateKey(S).toRawBytes(I)}function x(S){let I=De(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=be(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=en(t.nBitLength);function b(S){return _t("num < 2^"+t.nBitLength,S,Ne,R),Me(S,t.nByteLength)}function v(S,I,g=D){if(["recovered","canonical"].some(dt=>dt 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=at("msgHash",S),rl(g),O&&(S=at("prehashed msgHash",p(S)));let z=P(S),Z=f(I),K=[b(Z),b(z)];if(M!=null&&M!==!1){let dt=M===!0?E(e.BYTES):M;K.push(at("extraEntropy",dt))}let J=ve(...K),et=z;function ht(dt){let yt=F(dt);if(!l(yt))return;let vt=a(yt),Rt=c.BASE.multiply(yt).toAffine(),Tt=s(Rt.x);if(Tt===Ne)return;let ae=s(vt*s(et+Tt*Z));if(ae===Ne)return;let ge=(Rt.x===Tt?0:2)|Number(Rt.y&pt),Wr=ae;return N&&m(ae)&&(Wr=B(ae),ge^=1),new d(Tt,Wr,ge)}return{seed:J,k2sig:ht}}let D={lowS:t.lowS,prehash:!1},L={lowS:t.lowS,prehash:!1};function C(S,I,g=D){let{seed:p,k2sig:E}=v(S,I,g),N=t;return ss(N.hash.outputLen,N.nByteLength,N.hmac)(p,E)}c.BASE._setWindowSize(8);function $(S,I,g,p=L){let E=S;I=at("msgHash",I),g=at("publicKey",g);let{lowS:N,prehash:O,format:M}=p;if(rl(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"||De(E),Z=!z&&!M&&typeof E=="object"&&E!==null&&typeof E.r=="bigint"&&typeof E.s=="bigint";if(!z&&!Z)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,J;try{if(Z&&(K=new d(E.r,E.s)),z){try{M!=="compact"&&(K=d.fromDER(E))}catch(ge){if(!(ge instanceof Ce.Err))throw ge}!K&&M!=="der"&&(K=d.fromCompact(E))}J=c.fromHex(g)}catch{return!1}if(!K||N&&K.hasHighS())return!1;O&&(I=t.hash(I));let{r:et,s:ht}=K,dt=P(I),yt=a(ht),vt=s(dt*yt),Rt=s(et*yt),Tt=c.BASE.multiplyAndAddUnsafe(J,vt,Rt)?.toAffine();return Tt?s(Tt.x)===et:!1}return{CURVE:t,getPublicKey:T,getSharedSecret:U,sign:C,verify:$,ProjectivePoint:c,Signature:d,utils:A}}function Np(r){return{hash:r,hmac:(t,...e)=>na(r,t,Qi(...e)),randomBytes:Kn}}function il(r,t){let e=n=>ol({...r,...Np(n)});return{...e(t),create:e}}var cl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),sl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Up=BigInt(1),ia=BigInt(2),al=(r,t)=>(r+t/ia)/t;function Rp(r){let t=cl,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=it(u,e,t)*u%t,h=it(l,e,t)*u%t,m=it(h,ia,t)*f%t,B=it(m,o,t)*m%t,w=it(B,i,t)*B%t,d=it(w,a,t)*w%t,A=it(d,c,t)*d%t,T=it(A,a,t)*w%t,x=it(T,e,t)*u%t,U=it(x,s,t)*B%t,F=it(U,n,t)*f%t,P=it(F,ia,t);if(!sa.eql(sa.sqr(P),r))throw new Error("Cannot find square root");return P}var sa=He(cl,void 0,void 0,{sqrt:Rp}),ar=il({a:BigInt(0),b:BigInt(7),Fp:sa,n:sl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=sl,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Up*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=e,s=BigInt("0x100000000000000000000000000000000"),a=al(i*r,t),c=al(-n*r,t),f=Q(r-a*e-c*o,t),u=Q(-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}}}},Ur),Mx=BigInt(0);var Hx=ar.ProjectivePoint;function It(r,t){t==null&&(t=r.reduce((o,i)=>o+i.length,0));let e=Ft(t),n=0;for(let o of r)e.set(o,n),n+=o.length;return e}function ul(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function ll(r,t,e){let n=nn.digest(e instanceof Uint8Array?e:e.subarray());if(ul(n))return n.then(({digest:o})=>ar.verify(t,o,r)).catch(o=>{throw new yn(String(o))});try{return ar.verify(t,n.digest,r)}catch(o){throw new yn(String(o))}}var Qo=class{type="secp256k1";raw;_key;constructor(t){this._key=hl(t),this.raw=fl(this._key)}toMultihash(){return Yt.digest(eo(this))}toCID(){return X.createV1(114,this.toMultihash())}toString(){return rt.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:st(this.raw,t.raw)}verify(t,e){return ll(this._key,e,t)}};function aa(r){return new Qo(r)}function fl(r){return ar.ProjectivePoint.fromHex(r).toRawBytes(!0)}function hl(r){try{return ar.ProjectivePoint.fromHex(r),r}catch(t){throw new hr(String(t))}}function dl(r){let{Type:t,Data:e}=ue.decode(r),n=e??new Uint8Array;switch(t){case ft.RSA:return ra(n);case ft.Ed25519:return ys(n);case ft.secp256k1:return aa(n);default:throw new pr}}function ti(r){let{Type:t,Data:e}=ue.decode(r.digest),n=e??new Uint8Array;switch(t){case ft.Ed25519:return ys(n);case ft.secp256k1:return aa(n);default:throw new pr}}function eo(r){return ue.encode({Type:ft[r.type],Data:r.raw})}var pl=Symbol.for("nodejs.util.inspect.custom"),Lp=114,bn=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()})`}[Oi]=!0;toString(){return this.string==null&&(this.string=rt.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return X.createV1(Lp,this.multihash)}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return st(this.multihash.bytes,t);if(typeof t=="string")return this.toString()===t;if(t?.toMultihash()?.bytes!=null)return st(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[pl](){return`PeerId(${this.toString()})`}},ei=class extends bn{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},ri=class extends bn{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},ni=class extends bn{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Vp=2336,vn=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=Yt.digest(j(this.url))}[pl](){return`PeerId(${this.url})`}[Oi]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return X.createV1(Vp,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=nt(t)),t.toString()===this.toString())}};var _p=114,gl=2336;function ml(r,t){let e;if(r.charAt(0)==="1"||r.charAt(0)==="Q")e=ye(rt.decode(`z${r}`));else{if(t==null)throw new Et('Please pass a multibase decoder for strings that do not start with "1" or "Q"');e=ye(t.decode(r))}return yl(e)}function yl(r){if(Fp(r))return new ei({multihash:r});if(Pp(r))try{let t=ti(r);if(t.type==="Ed25519")return new ri({multihash:r,publicKey:t});if(t.type==="secp256k1")return new ni({multihash:r,publicKey:t})}catch{let e=nt(r.digest);return new vn(new URL(e))}throw new dr("Supplied PeerID Multihash is invalid")}function wl(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==_p&&r.code!==gl)throw new Pn("Supplied PeerID CID is invalid");if(r.code===gl){let t=nt(r.multihash.digest);return new vn(new URL(t))}return yl(r.multihash)}function Pp(r){return r.code===Yt.code}function Fp(r){return r.code===nn.code}var oi=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 xl=45,Dp=15,Dr=new oi;function ca(r){if(!(r.length>Dp))return Dr.new(r).parseWith(()=>Dr.readIPv4Addr())}function ua(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>xl))return Dr.new(r).parseWith(()=>Dr.readIPv6Addr())}function ii(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>xl))return Dr.new(r).parseWith(()=>Dr.readIPAddr())}var r1=parseInt("0xFFFF",16),n1=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function El(r){return!!ca(r)}function Bl(r){return!!ua(r)}function si(r){return!!ii(r)}var Al=El,Kp=Bl,la=function(r){let t=0;if(r=r.toString().trim(),Al(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Kp(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let i=Al(e[n]),s;i&&(s=la(e[n]),e[n]=nt(s.slice(0,2),"base16")),s!=null&&++n<8&&e.splice(n,0,nt(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")},Sl=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 Or={},fa={},zp=[[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"]];zp.forEach(r=>{let t=jp(...r);fa[t.code]=t,Or[t.name]=t});function jp(r,t,e,n,o){return{code:r,size:t,name:e,resolvable:!!n,path:!!o}}function tt(r){if(typeof r=="number"){if(fa[r]!=null)return fa[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Or[r]!=null)return Or[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var M1=tt("ip4"),H1=tt("ip6"),$1=tt("ipcidr");function ga(r,t){switch(tt(r).code){case 4:case 41:return Zp(t);case 42:return pa(t);case 43:return nt(t,"base10");case 6:case 273:case 33:case 132:return Tl(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return pa(t);case 421:return Xp(t);case 444:return kl(t);case 445:return kl(t);case 466:return Jp(t);case 481:return globalThis.encodeURIComponent(pa(t));default:return nt(t,"base16")}}function ma(r,t){switch(tt(r).code){case 4:return Il(t);case 41:return Il(t);case 42:return da(t);case 43:return j(t,"base10");case 6:case 273:case 33:case 132:return ya(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return da(t);case 421:return Wp(t);case 444:return Qp(t);case 445:return tg(t);case 466:return Yp(t);case 481:return da(globalThis.decodeURIComponent(t));default:return j(t,"base16")}}var ha=Object.values(on).map(r=>r.decoder),Gp=function(){let r=ha[0].or(ha[1]);return ha.slice(2).forEach(t=>r=r.or(t)),r}();function Il(r){if(!si(r))throw new Error("invalid ip address");return la(r)}function Zp(r){let t=Sl(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!si(t))throw new Error("invalid ip address");return t}function ya(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Tl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function da(r){let t=j(r),e=Uint8Array.from(Ir(t.length));return It([e,t],e.length+t.length)}function pa(r){let t=nr(r);if(r=r.slice(Dt(t)),r.length!==t)throw new Error("inconsistent lengths");return nt(r)}function Wp(r){let t;r[0]==="Q"||r[0]==="1"?t=ye(rt.decode(`z${r}`)).bytes:t=X.parse(r).multihash.bytes;let e=Uint8Array.from(Ir(t.length));return It([e,t],e.length+t.length)}function Yp(r){let t=Gp.decode(r),e=Uint8Array.from(Ir(t.length));return It([e,t],e.length+t.length)}function Jp(r){let t=nr(r),e=r.slice(Dt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+nt(e,"base64url")}function Xp(r){let t=nr(r),e=r.slice(Dt(t));if(e.length!==t)throw new Error("inconsistent lengths");return nt(e,"base58btc")}function Qp(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=Zt.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=ya(n);return It([e,o],e.length+o.length)}function tg(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=Zt.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=ya(n);return It([e,o],e.length+o.length)}function kl(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=nt(t,"base32"),o=Tl(e);return`${n}:${o}`}function Cl(r){r=wa(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=tt(s);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(i++,i>=o.length)throw Ul("invalid address: "+r);if(a.path===!0){n=wa(o.slice(i).join("/")),t.push([a.code,ma(a.code,n)]),e.push([a.code,n]);break}let c=ma(a.code,o[i]);t.push([a.code,c]),e.push([a.code,ga(a.code,c)])}return{string:Nl(e),bytes:ba(t),tuples:t,stringTuples:e,path:n}}function xa(r){let t=[],e=[],n=null,o=0;for(;o<r.length;){let i=nr(r,o),s=Dt(i),a=tt(i),c=eg(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 Ul("Invalid address Uint8Array: "+nt(r,"base16"));t.push([i,f]);let u=ga(i,f);if(e.push([i,u]),a.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Nl(e),tuples:t,stringTuples:e,path:n}}function Nl(r){let t=[];return r.map(e=>{let n=tt(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),wa(t.join("/"))}function ba(r){return It(r.map(t=>{let e=tt(t[0]),n=Uint8Array.from(Ir(e.code));return t.length>1&&t[1]!=null&&(n=It([n,t[1]])),n}))}function eg(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=nr(t instanceof Uint8Array?t:Uint8Array.from(t));return e+Dt(e)}}function wa(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Ul(r){return new Error("Error parsing address: "+r)}var rg=Symbol.for("nodejs.util.inspect.custom"),Ea=Symbol.for("@multiformats/js-multiaddr/multiaddr"),ng=[tt("dns").code,tt("dns4").code,tt("dns6").code,tt("dnsaddr").code],va=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},ai=class r{bytes;#t;#r;#e;#a;[Ea]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=xa(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(Ll(t))e=xa(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=tt("tcp"),a=tt("udp"),c=tt("ip4"),f=tt("ip6"),u=tt("dns6"),l=tt("ip6zone");for(let[m,B]of this.stringTuples())m===l.code&&(i=`%${B??""}`),ng.includes(m)&&(e=s.name,o=443,n=`${B??""}${i}`,t=m===u.code?6:4),(m===s.code||m===a.code)&&(e=tt(m).name,o=parseInt(B??"")),(m===c.code||m===f.code)&&(e=tt(m).name,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({},tt(t)))}protoCodes(){return this.#r.map(([t])=>t)}protoNames(){return this.#r.map(([t])=>tt(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(ba(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,o])=>{n===Or.p2p.code&&t.push([n,o]),n===Or["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?nt(rt.decode(`z${n}`),"base58btc"):nt(X.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#a}equals(t){return st(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(i=>i.resolvable);if(e==null)return[this];let n=Rl.get(e.name);if(n==null)throw new va(`no available resolver for ${e.name}`);return(await n(this,t)).map(i=>cr(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)}[rg](){return`Multiaddr(${this.#t})`}};var Rl=new Map;function Ll(r){return!!r?.[Ea]}function cr(r){return new ai(r)}function En(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*ci(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 og="/",ig=new TextEncoder().encode(og),m2=ig[0];var Og=_n(Aa(),1);var re=class extends Error{static name="SignatureVerificationError";constructor(t="Record signature verification failed"){super(t),this.name="SignatureVerificationError"}},ui=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"}},li=class extends Error{static name="RecordTooLargeError";constructor(t="The record is too large"){super(t),this.name="RecordTooLargeError"}},fi=class extends Error{static name="InvalidValueError";constructor(t="Value must be a valid content path starting with /"){super(t),this.name="InvalidValueError"}},hi=class extends Error{static name="InvalidRecordDataError";constructor(t="Invalid record data"){super(t),this.name="InvalidRecordDataError"}},Bn=class extends Error{static name="InvalidEmbeddedPublicKeyError";constructor(t="Invalid embedded public key"){super(t),this.name="InvalidEmbeddedPublicKeyError"}};var ne;(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=()=>cn(e)}(t=r.ValidityType||(r.ValidityType={}));let n;r.codec=()=>(n==null&&(n=Nr((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=>Tr(o,r.codec()),r.decode=(o,i)=>kr(o,r.codec(),i)})(ne||(ne={}));var sg=["string","number","bigint","symbol"],ag=["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 Vl(r){if(r===null)return"null";if(r===void 0)return"undefined";if(r===!0||r===!1)return"boolean";let t=typeof r;if(sg.includes(t))return t;if(t==="function")return"Function";if(Array.isArray(r))return"Array";if(cg(r))return"Buffer";let e=ug(r);return e||"Object"}function cg(r){return r&&r.constructor&&r.constructor.isBuffer&&r.constructor.isBuffer.call(null,r)}function ug(r){let t=Object.prototype.toString.call(r).slice(8,-1);if(ag.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 Hr=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&typeof globalThis.Buffer.isBuffer=="function",lg=new TextDecoder,fg=new TextEncoder;function di(r){return Hr&&globalThis.Buffer.isBuffer(r)}function Dl(r){return r instanceof Uint8Array?di(r)?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r:Uint8Array.from(r)}var Ol=Hr?(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?lg.decode(r.subarray(t,e)):Pl(r,t,e),Ml=Hr?r=>r.length>64?globalThis.Buffer.from(r):_l(r):r=>r.length>64?fg.encode(r):_l(r);var $r=Hr?(r,t,e)=>di(r)?new Uint8Array(r.subarray(t,e)):r.slice(t,e):(r,t,e)=>r.slice(t,e),Hl=Hr?(r,t)=>(r=r.map(e=>e instanceof Uint8Array?e:globalThis.Buffer.from(e)),Dl(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},$l=Hr?r=>globalThis.Buffer.allocUnsafe(r):r=>new Uint8Array(r);function Kl(r,t){if(di(r)&&di(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 _l(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 hg(n)}var Fl=4096;function hg(r){let t=r.length;if(t<=Fl)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Fl));return e}var dg=256,pi=class{constructor(t=dg){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=$l(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=Hl(this.chunks,this.cursor);return t&&this.reset(),e}};var H="CBOR decode error:",Sa="CBOR encode error:",An=[];An[23]=1;An[24]=2;An[25]=3;An[26]=5;An[27]=9;function Ue(r,t,e){if(r.length-t<e)throw new Error(`${H} not enough data for type`)}var gt=[24,256,65536,4294967296,BigInt("18446744073709551616")];function Ht(r,t,e){Ue(r,t,1);let n=r[t];if(e.strict===!0&&n<gt[0])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function $t(r,t,e){Ue(r,t,2);let n=r[t]<<8|r[t+1];if(e.strict===!0&&n<gt[1])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function Kt(r,t,e){Ue(r,t,4);let n=r[t]*16777216+(r[t+1]<<16)+(r[t+2]<<8)+r[t+3];if(e.strict===!0&&n<gt[2])throw new Error(`${H} integer encoded in more bytes than necessary (strict decode)`);return n}function qt(r,t,e){Ue(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<gt[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 ql(r,t,e,n){return new _(y.uint,Ht(r,t+1,n),2)}function zl(r,t,e,n){return new _(y.uint,$t(r,t+1,n),3)}function jl(r,t,e,n){return new _(y.uint,Kt(r,t+1,n),5)}function Gl(r,t,e,n){return new _(y.uint,qt(r,t+1,n),9)}function jt(r,t){return bt(r,0,t.value)}function bt(r,t,e){if(e<gt[0]){let n=Number(e);r.push([t|n])}else if(e<gt[1]){let n=Number(e);r.push([t|24,n])}else if(e<gt[2]){let n=Number(e);r.push([t|25,n>>>8,n&255])}else if(e<gt[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<gt[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`)}}jt.encodedSize=function(t){return bt.encodedSize(t.value)};bt.encodedSize=function(t){return t<gt[0]?1:t<gt[1]?2:t<gt[2]?3:t<gt[3]?5:9};jt.compareTokens=function(t,e){return t.value<e.value?-1:t.value>e.value?1:0};function Zl(r,t,e,n){return new _(y.negint,-1-Ht(r,t+1,n),2)}function Wl(r,t,e,n){return new _(y.negint,-1-$t(r,t+1,n),3)}function Yl(r,t,e,n){return new _(y.negint,-1-Kt(r,t+1,n),5)}var Ia=BigInt(-1),Jl=BigInt(1);function Xl(r,t,e,n){let o=qt(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,Ia-BigInt(o),9)}function gi(r,t){let e=t.value,n=typeof e=="bigint"?e*Ia-Jl:e*-1-1;bt(r,t.type.majorEncoded,n)}gi.encodedSize=function(t){let e=t.value,n=typeof e=="bigint"?e*Ia-Jl:e*-1-1;return n<gt[0]?1:n<gt[1]?2:n<gt[2]?3:n<gt[3]?5:9};gi.compareTokens=function(t,e){return t.value<e.value?1:t.value>e.value?-1:0};function Sn(r,t,e,n){Ue(r,t,e+n);let o=$r(r,t+e,t+e+n);return new _(y.bytes,o,e+n)}function Ql(r,t,e,n){return Sn(r,t,1,e)}function tf(r,t,e,n){return Sn(r,t,2,Ht(r,t+1,n))}function ef(r,t,e,n){return Sn(r,t,3,$t(r,t+1,n))}function rf(r,t,e,n){return Sn(r,t,5,Kt(r,t+1,n))}function nf(r,t,e,n){let o=qt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer bytes lengths not supported`);return Sn(r,t,9,o)}function mi(r){return r.encodedBytes===void 0&&(r.encodedBytes=r.type===y.string?Ml(r.value):r.value),r.encodedBytes}function Kr(r,t){let e=mi(t);bt(r,t.type.majorEncoded,e.length),r.push(e)}Kr.encodedSize=function(t){let e=mi(t);return bt.encodedSize(e.length)+e.length};Kr.compareTokens=function(t,e){return gg(mi(t),mi(e))};function gg(r,t){return r.length<t.length?-1:r.length>t.length?1:Kl(r,t)}function In(r,t,e,n,o){let i=e+n;Ue(r,t,i);let s=new _(y.string,Ol(r,t+e,t+i),i);return o.retainStringBytes===!0&&(s.byteValue=$r(r,t+e,t+i)),s}function of(r,t,e,n){return In(r,t,1,e,n)}function sf(r,t,e,n){return In(r,t,2,Ht(r,t+1,n),n)}function af(r,t,e,n){return In(r,t,3,$t(r,t+1,n),n)}function cf(r,t,e,n){return In(r,t,5,Kt(r,t+1,n),n)}function uf(r,t,e,n){let o=qt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer string lengths not supported`);return In(r,t,9,o,n)}var lf=Kr;function qr(r,t,e,n){return new _(y.array,n,e)}function ff(r,t,e,n){return qr(r,t,1,e)}function hf(r,t,e,n){return qr(r,t,2,Ht(r,t+1,n))}function df(r,t,e,n){return qr(r,t,3,$t(r,t+1,n))}function pf(r,t,e,n){return qr(r,t,5,Kt(r,t+1,n))}function gf(r,t,e,n){let o=qt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer array lengths not supported`);return qr(r,t,9,o)}function mf(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return qr(r,t,1,1/0)}function yi(r,t){bt(r,y.array.majorEncoded,t.value)}yi.compareTokens=jt.compareTokens;yi.encodedSize=function(t){return bt.encodedSize(t.value)};function zr(r,t,e,n){return new _(y.map,n,e)}function yf(r,t,e,n){return zr(r,t,1,e)}function wf(r,t,e,n){return zr(r,t,2,Ht(r,t+1,n))}function xf(r,t,e,n){return zr(r,t,3,$t(r,t+1,n))}function bf(r,t,e,n){return zr(r,t,5,Kt(r,t+1,n))}function vf(r,t,e,n){let o=qt(r,t+1,n);if(typeof o=="bigint")throw new Error(`${H} 64-bit integer map lengths not supported`);return zr(r,t,9,o)}function Ef(r,t,e,n){if(n.allowIndefinite===!1)throw new Error(`${H} indefinite length items not allowed`);return zr(r,t,1,1/0)}function wi(r,t){bt(r,y.map.majorEncoded,t.value)}wi.compareTokens=jt.compareTokens;wi.encodedSize=function(t){return bt.encodedSize(t.value)};function Bf(r,t,e,n){return new _(y.tag,e,1)}function Af(r,t,e,n){return new _(y.tag,Ht(r,t+1,n),2)}function Sf(r,t,e,n){return new _(y.tag,$t(r,t+1,n),3)}function If(r,t,e,n){return new _(y.tag,Kt(r,t+1,n),5)}function kf(r,t,e,n){return new _(y.tag,qt(r,t+1,n),9)}function xi(r,t){bt(r,y.tag.majorEncoded,t.value)}xi.compareTokens=jt.compareTokens;xi.encodedSize=function(t){return bt.encodedSize(t.value)};var vg=20,Eg=21,Bg=22,Ag=23;function Tf(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 Cf(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 ka(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 Nf(r,t,e,n){return ka(Ta(r,t+1),3,n)}function Uf(r,t,e,n){return ka(Ca(r,t+1),5,n)}function Rf(r,t,e,n){return ka(Pf(r,t+1),9,n)}function bi(r,t,e){let n=t.value;if(n===!1)r.push([y.float.majorEncoded|vg]);else if(n===!0)r.push([y.float.majorEncoded|Eg]);else if(n===null)r.push([y.float.majorEncoded|Bg]);else if(n===void 0)r.push([y.float.majorEncoded|Ag]);else{let o,i=!1;(!e||e.float64!==!0)&&(Vf(n),o=Ta(oe,1),n===o||Number.isNaN(n)?(oe[0]=249,r.push(oe.slice(0,3)),i=!0):(_f(n),o=Ca(oe,1),n===o&&(oe[0]=250,r.push(oe.slice(0,5)),i=!0))),i||(Sg(n),o=Pf(oe,1),oe[0]=251,r.push(oe.slice(0,9)))}}bi.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){Vf(n);let o=Ta(oe,1);if(n===o||Number.isNaN(n))return 3;if(_f(n),o=Ca(oe,1),n===o)return 5}return 9};var Lf=new ArrayBuffer(9),Gt=new DataView(Lf,1),oe=new Uint8Array(Lf,0);function Vf(r){if(r===1/0)Gt.setUint16(0,31744,!1);else if(r===-1/0)Gt.setUint16(0,64512,!1);else if(Number.isNaN(r))Gt.setUint16(0,32256,!1);else{Gt.setFloat32(0,r);let t=Gt.getUint32(0),e=(t&2139095040)>>23,n=t&8388607;if(e===255)Gt.setUint16(0,31744,!1);else if(e===0)Gt.setUint16(0,(r&2147483648)>>16|n>>13,!1);else{let o=e-127;o<-24?Gt.setUint16(0,0):o<-14?Gt.setUint16(0,(t&2147483648)>>16|1<<24+o,!1):Gt.setUint16(0,(t&2147483648)>>16|o+15<<10|n>>13,!1)}}}function Ta(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 _f(r){Gt.setFloat32(0,r,!1)}function Ca(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 Sg(r){Gt.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)}bi.compareTokens=jt.compareTokens;function W(r,t,e){throw new Error(`${H} encountered invalid minor (${e}) for major ${r[t]>>>5}`)}function vi(r){return()=>{throw new Error(`${H} ${r}`)}}var k=[];for(let r=0;r<=23;r++)k[r]=W;k[24]=ql;k[25]=zl;k[26]=jl;k[27]=Gl;k[28]=W;k[29]=W;k[30]=W;k[31]=W;for(let r=32;r<=55;r++)k[r]=W;k[56]=Zl;k[57]=Wl;k[58]=Yl;k[59]=Xl;k[60]=W;k[61]=W;k[62]=W;k[63]=W;for(let r=64;r<=87;r++)k[r]=Ql;k[88]=tf;k[89]=ef;k[90]=rf;k[91]=nf;k[92]=W;k[93]=W;k[94]=W;k[95]=vi("indefinite length bytes/strings are not supported");for(let r=96;r<=119;r++)k[r]=of;k[120]=sf;k[121]=af;k[122]=cf;k[123]=uf;k[124]=W;k[125]=W;k[126]=W;k[127]=vi("indefinite length bytes/strings are not supported");for(let r=128;r<=151;r++)k[r]=ff;k[152]=hf;k[153]=df;k[154]=pf;k[155]=gf;k[156]=W;k[157]=W;k[158]=W;k[159]=mf;for(let r=160;r<=183;r++)k[r]=yf;k[184]=wf;k[185]=xf;k[186]=bf;k[187]=vf;k[188]=W;k[189]=W;k[190]=W;k[191]=Ef;for(let r=192;r<=215;r++)k[r]=Bf;k[216]=Af;k[217]=Sf;k[218]=If;k[219]=kf;k[220]=W;k[221]=W;k[222]=W;k[223]=W;for(let r=224;r<=243;r++)k[r]=vi("simple values are not supported");k[244]=W;k[245]=W;k[246]=W;k[247]=Tf;k[248]=vi("simple values are not supported");k[249]=Nf;k[250]=Uf;k[251]=Rf;k[252]=W;k[253]=W;k[254]=W;k[255]=Cf;var ie=[];for(let r=0;r<24;r++)ie[r]=new _(y.uint,r,1);for(let r=-1;r>=-24;r--)ie[31-r]=new _(y.negint,r,1);ie[64]=new _(y.bytes,new Uint8Array(0),1);ie[96]=new _(y.string,"",1);ie[128]=new _(y.array,0,1);ie[160]=new _(y.map,0,1);ie[244]=new _(y.false,!1,1);ie[245]=new _(y.true,!0,1);ie[246]=new _(y.null,null,1);function kg(){let r=[];return r[y.uint.major]=jt,r[y.negint.major]=gi,r[y.bytes.major]=Kr,r[y.string.major]=lf,r[y.array.major]=yi,r[y.map.major]=wi,r[y.tag.major]=xi,r[y.float.major]=bi,r}var pv=kg(),gv=new pi,Ei=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(`${Sa} 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)},We={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=Ei.createCheck(n,r);let o=[],i=0;for(let s of r)o[i++]=Na(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=Ei.createCheck(n,r);let a=[],c=0;for(let f of i)a[c++]=[Na(f,e,n),Na(o?r.get(f):r[f],e,n)];return Tg(a,e),e.addBreakTokens?[new _(y.map,s),a,new _(y.break)]:[new _(y.map,s),a]}};We.Map=We.Object;We.Buffer=We.Uint8Array;for(let r of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))We[`${r}Array`]=We.DataView;function Na(r,t={},e){let n=Vl(r),o=t&&t.typeEncoders&&t.typeEncoders[n]||We[n];if(typeof o=="function"){let s=o(r,n,t,e);if(s!=null)return s}let i=We[n];if(!i)throw new Error(`${Sa} unsupported type: ${n}`);return i(r,n,t,e)}function Tg(r,t){t.mapSorter&&r.sort(t.mapSorter)}var Cg={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0},Bi=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=ie[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}},kn=Symbol.for("DONE"),Ai=Symbol.for("BREAK");function Ng(r,t,e){let n=[];for(let o=0;o<r.value;o++){let i=jr(t,e);if(i===Ai){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed array`)}if(i===kn)throw new Error(`${H} found array but not enough entries (got ${o}, expected ${r.value})`);n[o]=i}return n}function Ug(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=jr(t,e);if(a===Ai){if(r.value===1/0)break;throw new Error(`${H} got unexpected break to lengthed map`)}if(a===kn)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=jr(t,e);if(c===kn)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 jr(r,t){if(r.done())return kn;let e=r.next();if(e.type===y.break)return Ai;if(e.type.terminal)return e.value;if(e.type===y.array)return Ng(e,r,t);if(e.type===y.map)return Ug(e,r,t);if(e.type===y.tag){if(t.tags&&typeof t.tags[e.value]=="function"){let n=jr(r,t);return t.tags[e.value](n)}throw new Error(`${H} tag not supported (${e.value})`)}throw new Error("unsupported")}function Ff(r,t){if(!(r instanceof Uint8Array))throw new Error(`${H} data to decode must be a Uint8Array`);t=Object.assign({},Cg,t);let e=t.tokenizer||new Bi(r,t),n=jr(e,t);if(n===kn)throw new Error(`${H} did not find any content to decode`);if(n===Ai)throw new Error(`${H} got unexpected break`);return[n,r.subarray(e.pos())]}function Ua(r,t){let[e,n]=Ff(r,t);if(n.length>0)throw new Error(`${H} too many terminals, data makes no sense`);return e}var Vg=Ve("ipns:utils"),Df=j("/ipns/");var _g=0,Pg=18;function Of(r){let t;if(r.pubKey!=null)try{t=dl(r.pubKey)}catch(e){throw Vg.error(e),e}if(t!=null)return t}function Mf(r){let t=j("ipns-signature:");return It([t,r])}function lr(r){return"signatureV1"in r?ne.encode({value:j(r.value),signatureV1:r.signatureV1,validityType:r.validityType,validity:j(r.validity),sequence:r.sequence,ttl:r.ttl,pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data}):ne.encode({pubKey:r.pubKey,signatureV2:r.signatureV2,data:r.data})}function de(r){let t=ne.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 re("Missing data or signatureV2");let e=Hf(t.data),n=Fg(e.Value),o=nt(e.Validity);if(t.value!=null&&t.signatureV1!=null)return Dg(t),{value:n,validityType:ne.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:ne.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 Tn(r){return It([Df,r.bytes])}function Re(r){let t=ye(r.slice(Df.length));if(!Si(t,_g)&&!Si(t,Pg))throw new dr("Multihash in IPNS key was not identity or sha2-256");return t}function Hf(r){let t=Ua(r);if(t.ValidityType===0)t.ValidityType=ne.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 Fg(r){let t=nt(r).trim();if(t.startsWith("/"))return t;try{return`/ipfs/${X.decode(r).toV1().toString()}`}catch{}try{return`/ipfs/${X.parse(t).toV1().toString()}`}catch{}throw new fi("Value must be a valid content path starting with /")}function Dg(r){if(r.data==null)throw new hi("Record data is missing");let t=Hf(r.data);if(!st(t.Value,r.value??new Uint8Array(0)))throw new re('Field "value" did not match between protobuf and CBOR');if(!st(t.Validity,r.validity??new Uint8Array(0)))throw new re('Field "validity" did not match between protobuf and CBOR');if(t.ValidityType!==r.validityType)throw new re('Field "validityType" did not match between protobuf and CBOR');if(t.Sequence!==r.sequence)throw new re('Field "sequence" did not match between protobuf and CBOR');if(t.TTL!==r.ttl)throw new re('Field "ttl" did not match between protobuf and CBOR')}function Si(r,t){return r.code===t}var Ov=Ve("ipns"),Mv=60*60*1e9,Mg="/ipns/",Hv=Mg.length;var $f=_n(Aa(),1);var Ii=Ve("ipns:validator"),Hg=1024*10,$g=async(r,t)=>{let e=de(t),n;try{let o=Mf(e.data);n=await r.verify(o,e.signatureV2)}catch{n=!1}if(!n)throw Ii.error("record signature verification failed"),new re("Record signature verification failed");if(e.validityType===ne.ValidityType.EOL){if($f.default.fromString(e.validity).toDate().getTime()<Date.now())throw Ii.error("record has expired"),new ui("record has expired")}else if(e.validityType!=null)throw Ii.error("the validity type is unsupported"),new Mr("The validity type is unsupported");Ii("ipns record for %s is valid",e.value)};async function Kf(r,t){if(t.byteLength>Hg)throw new li("The record is too large");let e=Re(r),n;Si(e,0)&&(n=ti(e));let o=de(t),i=Of(o)??n;if(i==null)throw new Bn("Could not extract public key from IPNS record or routing key");let s=Tn(i.toMultihash());if(!st(r,s))throw new Bn("Embedded public key did not match routing key");await $g(i,t)}var jf=Symbol.for("@achingbrain/uint8arraylist");function qf(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 Gr(r){return!!r?.[jf]}var zf=class r{bufs;length;[jf]=!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(Gr(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(Gr(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=qf(this.bufs,t);return e.buf[e.index]}set(t,e){let n=qf(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(Gr(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 It(n,o)}subarray(t,e){let{bufs:n,length:o}=this._subList(t,e);return n.length===1?n[0]:It(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(!Gr(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=Ft(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=Ee(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=Ee(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=Ee(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=Ft(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=Ee(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=Ee(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=Ee(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=Ee(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=Ee(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(!st(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 ki=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MESSAGE_LENGTH"};async function*Cn(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)),Gr(i)&&(i=i.subarray()),o+=n.decode(i,{stream:!0}),o.length>(t?.maxMessageLength??o.length))throw new ki("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 pe(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var La=_n(Zf(),1);var Un=class extends Error{constructor(t){super(t),this.name="TimeoutError"}},Va=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t}},Wf=r=>globalThis.DOMException===void 0?new Va(r):new DOMException(r),Yf=r=>{let t=r.reason===void 0?Wf("This operation was aborted."):r.reason;return t instanceof Error?t:Wf(t)};function _a(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(Yf(m)),a=()=>{l(Yf(m))},m.addEventListener("abort",a,{once:!0})}if(e===Number.POSITIVE_INFINITY){r.then(u,l);return}let h=new Un;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 Pa(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 Rn=class{#t=[];enqueue(t,e){e={priority:0,...e};let n={priority:e.priority,run:t};if(this.size&&this.#t[this.size-1].priority>=e.priority){this.#t.push(n);return}let o=Pa(this.#t,n,(i,s)=>s.priority-i.priority);this.#t.splice(o,0,n)}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 Ln=class extends La.default{#t;#r;#e=0;#a;#c;#p=0;#o;#u;#n;#g;#i=0;#l;#s;#m;timeout;constructor(t){if(super(),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Rn,...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#x(){return this.#r||this.#e<this.#a}get#b(){return this.#i<this.#l}#v(){this.#i--,this.#f(),this.emit("next")}#E(){this.#w(),this.#y(),this.#u=void 0}get#B(){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.#E()},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.#B;if(this.#x&&this.#b){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#A(t){return new Promise((e,n)=>{t.addEventListener("abort",()=>{n(t.reason)},{once:!0})})}async add(t,e={}){return 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=_a(Promise.resolve(i),{milliseconds:e.timeout})),e.signal&&(i=Promise.race([i,this.#A(e.signal)]));let s=await i;n(s),this.emit("completed",s)}catch(i){if(i instanceof Un&&!e.throwOnTimeout){n();return}o(i),this.emit("error",i)}finally{this.#v()}},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 Zr=class extends Error{static name="InvalidRequestError";constructor(t="Invalid request"){super(t),this.name="InvalidRequestError"}},fr=class extends Error{static name="BadResponseError";constructor(t="Bad response"){super(t),this.name="BadResponseError"}};function zg(r){return r[Symbol.asyncIterator]!=null}function jg(r){if(zg(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var Ci=jg;function Gg(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 Jf=Gg;function Zg(r){return r[Symbol.asyncIterator]!=null}function Wg(r,t){let e=0;if(Zg(r))return async function*(){for await(let c of r)yield t(c,e++)}();let n=Jf(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 Ni=Wg;var Xf=j("/ipns/");function Qf(r){return st(r.subarray(0,Xf.byteLength),Xf)}var Ui=class{client;constructor(t){this.client=t}async*findProviders(t,e={}){yield*Ni(this.client.getProviders(t,e),n=>({id:n.ID,multiaddrs:n.Addrs??[]}))}async provide(){}async cancelReprovide(){}async put(t,e,n){if(!Qf(t))return;let o=Re(t),i=X.createV1(114,o),s=de(e);await this.client.putIPNS(i,s,n)}async get(t,e){if(!Qf(t))throw new Lt("Not found");let n=Re(t),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,e);return lr(i)}catch(i){throw i.name==="BadResponseError"?new Lt("Not found"):i}}},Ri=class{client;constructor(t){this.client=t}async findPeer(t,e={}){let n=await Ci(this.client.getPeers(t,e));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Lt("Not found")}async*getClosestPeers(t,e={}){}};var mt=Ve("delegated-routing-v1-http-api-client"),Li={concurrentRequests:4,timeout:3e4,cacheTTL:5*60*1e3,cacheName:"delegated-routing-v1-cache"},Vi=class{started;httpQueue;shutDownController;clientUrl;timeout;contentRouting;peerRouting;filterAddrs;filterProtocols;inFlightRequests;cacheName;cache;cacheTTL;constructor(t,e={}){this.started=!1,this.shutDownController=new AbortController,gr(1/0,this.shutDownController.signal),this.httpQueue=new Ln({concurrency:e.concurrentRequests??Li.concurrentRequests}),this.inFlightRequests=new Map,this.clientUrl=t instanceof URL?t:new URL(t),this.timeout=e.timeout??Li.timeout,this.filterAddrs=e.filterAddrs,this.filterProtocols=e.filterProtocols,this.contentRouting=new Ui(this),this.peerRouting=new Ri(this),this.cacheName=e.cacheName??Li.cacheName,this.cacheTTL=e.cacheTTL??Li.cacheTTL}get[ec](){return this.contentRouting}get[rc](){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&&mt("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={}){mt("getProviders starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=En([this.shutDownController.signal,n,e.signal]);gr(1/0,n,o);let i=pe(),s=pe();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.status===404)throw new Lt("No matching records found");if(f.status===422)throw new Zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new fr("Routing response had no body");if(f.headers.get("Content-Type")==="application/json"){let l=await f.json();for(let h of l.Providers){let m=this.#t(h);m!=null&&(yield m)}}else for await(let l of Cn(ci(f.body))){let h=this.#t(l);h!=null&&(yield h)}}catch(a){mt.error("getProviders errored:",a)}finally{o.clear(),s.resolve(),mt("getProviders finished: %c",t)}}async*getPeers(t,e={}){mt("getPeers starts: %c",t);let n=AbortSignal.timeout(this.timeout),o=En([this.shutDownController.signal,n,e.signal]);gr(1/0,n,o);let i=pe(),s=pe();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 Lt("No matching records found");if(f.status===422)throw new Zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new fr("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 Cn(ci(f.body))){let h=this.#t(l);h!=null&&(yield h)}}catch(a){mt.error("getPeers errored:",a)}finally{o.clear(),s.resolve(),mt("getPeers finished: %c",t)}}async getIPNS(t,e={}){mt("getIPNS starts: %s",t);let n=AbortSignal.timeout(this.timeout),o=En([this.shutDownController.signal,n,e.signal]);gr(1/0,n,o);let i=pe(),s=pe();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(mt("getIPNS GET %s %d",a,f.status),f.status===404)throw new Lt("No matching records found");if(f.status===422)throw new Zr("Request does not conform to schema or semantic constraints");if(f.body==null)throw new fr("GET ipns response had no body");let u=await f.arrayBuffer(),l=new Uint8Array(u,0,u.byteLength);return e.validate!==!1&&await Kf(Tn(t.multihash),l),de(l)}catch(c){throw mt.error("getIPNS GET %s error:",a,c),c}finally{o.clear(),s.resolve(),mt("getIPNS finished: %s",t)}}async putIPNS(t,e,n={}){mt("putIPNS starts: %c",t);let o=AbortSignal.timeout(this.timeout),i=En([this.shutDownController.signal,o,n.signal]);gr(1/0,o,i);let s=pe(),a=pe();this.httpQueue.add(async()=>(s.resolve(),a.promise));let c=`${this.clientUrl}routing/v1/ipns/${t}`;try{await s.promise;let f=lr(e),u={method:"PUT",headers:{"Content-Type":"application/vnd.ipfs.ipns-record"},body:f,signal:i},l=await this.#e(c,u);if(mt("putIPNS PUT %s %d",c,l.status),l.status!==200)throw new fr("PUT ipns response had status other than 200")}catch(f){throw mt.error("putIPNS PUT %s error:",c,f.stack),f}finally{i.clear(),a.resolve(),mt("putIPNS finished: %c",t)}}#t(t){try{let e=[],n=t.Addrs?.map(cr)??[];return t.Protocols!=null&&e.push(...t.Protocols),t.Protocol!=null&&(e.push(t.Protocol),delete t.Protocol),{...t,Schema:"peer",ID:ml(t.ID),Addrs:n,Protocols:e}}catch(e){mt.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 mt("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 mt("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 th(r,t={}){return new Vi(new URL(r),t)}function _i(){return{filterProtocols:["unknown","transport-bitswap","transport-ipfs-gateway-http"],filterAddrs:["https","webtransport","webrtc","webrtc-direct","wss","tls"]}}var eh=j("/ipns/");function rh(r){return st(r.subarray(0,eh.byteLength),eh)}var Fa=class{client;constructor(t,e={}){this.client=th(t,e)}async provide(t,e){}async cancelReprovide(t,e){}async*findProviders(t,e){yield*Ni(this.client.getProviders(t,e),n=>({id:n.ID,multiaddrs:n.Addrs,protocols:n.Protocols}))}async put(t,e,n){if(!rh(t))return;let o=Re(t),i=X.createV1(114,o),s=de(e);await this.client.putIPNS(i,s,n)}async get(t,e){if(!rh(t))throw new Lt("Not found");let n=Re(t),o=X.createV1(114,n);try{let i=await this.client.getIPNS(o,e);return lr(i)}catch(i){throw i.name==="BadResponseError"?new Lt("Not found"):i}}async findPeer(t,e){let n=await Ci(this.client.getPeers(t,e));if(n!=null)return{id:n.ID,multiaddrs:n.Addrs??[]};throw new Lt("Not found")}async*getClosestPeers(t,e){}};function nh(r,t){let e=t??_i();return new Fa(new URL(r),e)}var oh="[a-fA-F\\d:]",Ye=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${oh})|(?<=${oh})(?=\\s|$))`:"",se="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",ut="[a-fA-F\\d]{1,4}",Pi=`
8
8
  (?:
9
- (?:${ue}:){7}(?:${ue}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
10
- (?:${ue}:){6}(?:${st}|:${ue}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
11
- (?:${ue}:){5}(?::${st}|(?::${ue}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
12
- (?:${ue}:){4}(?:(?::${ue}){0,1}:${st}|(?::${ue}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
13
- (?:${ue}:){3}(?:(?::${ue}){0,2}:${st}|(?::${ue}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
14
- (?:${ue}:){2}(?:(?::${ue}){0,3}:${st}|(?::${ue}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
15
- (?:${ue}:){1}(?:(?::${ue}){0,4}:${st}|(?::${ue}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
16
- (?::(?:(?::${ue}){0,5}:${st}|(?::${ue}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
9
+ (?:${ut}:){7}(?:${ut}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
10
+ (?:${ut}:){6}(?:${se}|:${ut}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
11
+ (?:${ut}:){5}(?::${se}|(?::${ut}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
12
+ (?:${ut}:){4}(?:(?::${ut}){0,1}:${se}|(?::${ut}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
13
+ (?:${ut}:){3}(?:(?::${ut}){0,2}:${se}|(?::${ut}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
14
+ (?:${ut}:){2}(?:(?::${ut}){0,3}:${se}|(?::${ut}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
15
+ (?:${ut}:){1}(?:(?::${ut}){0,4}:${se}|(?::${ut}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
16
+ (?::(?:(?::${ut}){0,5}:${se}|(?::${ut}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
17
17
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
18
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),zm=new RegExp(`(?:^${st}$)|(?:^${Li}$)`),jm=new RegExp(`^${st}$`),Gm=new RegExp(`^${Li}$`),Pa=r=>r&&r.exact?zm:new RegExp(`(?:${Wt(r)}${st}${Wt(r)})|(?:${Wt(r)}${Li}${Wt(r)})`,"g");Pa.v4=r=>r&&r.exact?jm:new RegExp(`${Wt(r)}${st}${Wt(r)}`,"g");Pa.v6=r=>r&&r.exact?Gm:new RegExp(`${Wt(r)}${Li}${Wt(r)}`,"g");var Fa=Pa;function Da(r){let e=(...t)=>r(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),e}function eh(){return!1}var{toString:Zm}=Object.prototype;function Ma(r){return Zm.call(r)==="[object RegExp]"}var th={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Oa(r,e={}){if(!Ma(r))throw new TypeError("Expected a RegExp instance");let t=Object.keys(th).map(o=>(typeof e[o]=="boolean"?e[o]:r[o])?th[o]:"").join(""),n=new RegExp(e.source||r.source,t);return n.lastIndex=typeof e.lastIndex=="number"?e.lastIndex:r.lastIndex,n}function Ha(r,e,{timeout:t}={}){try{return Da(()=>Oa(r).test(e),{timeout:t})()}catch(n){if(eh(n))return!1;throw n}}var Wm=15,Ym=45,rh={timeout:400};function $a(r){return r.length>Ym?!1:Ha(Fa.v6({exact:!0}),r,rh)}function nh(r){return r.length>Wm?!1:Ha(Fa.v4({exact:!0}),r,rh)}var oh={http:"80",https:"443",ws:"80",wss:"443"},Jm=["http","https","ws","wss"];function ih(r,e){e=e??{};let t=e.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=Xm(r),a="/"+[Qm(o,t),eg(i,n),tg(n)].filter(c=>!!c).reduce((c,f)=>c.concat(f),[]).join("/");return ar(a)}function Xm(r){let[e]=r.split(":");Jm.includes(e)||(r="http"+r.substring(e.length));let{protocol:t,hostname:n,port:o}=new URL(r);if(o==null||o===""){let i=rg(e);i!=null&&(o=i),i==null&&t==="http:"&&(o="80")}return{scheme:e,hostname:n,port:o}}function Qm(r,e){if(!(r==null||r==="")){if(nh(r))return["ip4",r];if($a(r))return["ip6",r];if(r[0]==="["){let t=r.substring(1,r.length-1);if($a(t))return["ip6",t]}return[e,r]}}function eg(r,e){if(!(r==null||r===""))return e==="udp"?["udp",r]:["tcp",r]}function tg(r){if(r.match(/^tcp$|^udp$/)==null)return[r]}function rg(r){if(!(r==null||r===""||oh[r]==null))return oh[r]}var ng=["https://trustless-gateway.link","https://4everland.io"],og=2336;function ig(r){return r=r.toString(),{id:gl(X.createV1(og,We.digest(j(r)))),multiaddrs:[ih(r)]}}var Ka=class{gateways;constructor(e={}){this.gateways=(e.gateways??ng).map(t=>ig(t))}async*findProviders(e,t){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function sh(r={}){return new Ka(r)}var qa=class{libp2p;constructor(e){this.libp2p=e}async provide(e,t){await this.libp2p.contentRouting.provide(e,t)}async cancelReprovide(e,t){await this.libp2p.contentRouting.cancelReprovide(e,t)}async*findProviders(e,t){yield*this.libp2p.contentRouting.findProviders(e,t)}async put(e,t,n){await this.libp2p.contentRouting.put(e,t,n)}async get(e,t){return this.libp2p.contentRouting.get(e,t)}async findPeer(e,t){return this.libp2p.peerRouting.findPeer(e,t)}async*getClosestPeers(e,t){yield*this.libp2p.peerRouting.getClosestPeers(e,t)}};function ah(r){return new qa(r)}return vh(sg);})();
18
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Yg=new RegExp(`(?:^${se}$)|(?:^${Pi}$)`),Jg=new RegExp(`^${se}$`),Xg=new RegExp(`^${Pi}$`),Da=r=>r&&r.exact?Yg:new RegExp(`(?:${Ye(r)}${se}${Ye(r)})|(?:${Ye(r)}${Pi}${Ye(r)})`,"g");Da.v4=r=>r&&r.exact?Jg:new RegExp(`${Ye(r)}${se}${Ye(r)}`,"g");Da.v6=r=>r&&r.exact?Xg:new RegExp(`${Ye(r)}${Pi}${Ye(r)}`,"g");var Oa=Da;function Ma(r){let t=(...e)=>r(...e);return Object.defineProperty(t,"name",{value:`functionTimeout(${r.name||"<anonymous>"})`,configurable:!0}),t}function ih(){return!1}var{toString:Qg}=Object.prototype;function Ha(r){return Qg.call(r)==="[object RegExp]"}var sh={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function $a(r,t={}){if(!Ha(r))throw new TypeError("Expected a RegExp instance");let e=Object.keys(sh).map(o=>(typeof t[o]=="boolean"?t[o]:r[o])?sh[o]:"").join(""),n=new RegExp(t.source||r.source,e);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:r.lastIndex,n}function Ka(r,t,{timeout:e}={}){try{return Ma(()=>$a(r).test(t),{timeout:e})()}catch(n){if(ih(n))return!1;throw n}}var tm=15,em=45,ah={timeout:400};function qa(r){return r.length>em?!1:Ka(Oa.v6({exact:!0}),r,ah)}function ch(r){return r.length>tm?!1:Ka(Oa.v4({exact:!0}),r,ah)}var uh={http:"80",https:"443",ws:"80",wss:"443"},rm=["http","https","ws","wss"];function lh(r,t){t=t??{};let e=t.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i}=nm(r),a="/"+[om(o,e),im(i,n),sm(n)].filter(c=>!!c).reduce((c,f)=>c.concat(f),[]).join("/");return cr(a)}function nm(r){let[t]=r.split(":");rm.includes(t)||(r="http"+r.substring(t.length));let{protocol:e,hostname:n,port:o}=new URL(r);if(o==null||o===""){let i=am(t);i!=null&&(o=i),i==null&&e==="http:"&&(o="80")}return{scheme:t,hostname:n,port:o}}function om(r,t){if(!(r==null||r==="")){if(ch(r))return["ip4",r];if(qa(r))return["ip6",r];if(r[0]==="["){let e=r.substring(1,r.length-1);if(qa(e))return["ip6",e]}return[t,r]}}function im(r,t){if(!(r==null||r===""))return t==="udp"?["udp",r]:["tcp",r]}function sm(r){if(r.match(/^tcp$|^udp$/)==null)return[r]}function am(r){if(!(r==null||r===""||uh[r]==null))return uh[r]}var cm=["https://trustless-gateway.link","https://4everland.io"],um=2336;function lm(r){return r=r.toString(),{id:wl(X.createV1(um,Yt.digest(j(r)))),multiaddrs:[lh(r)]}}var za=class{gateways;constructor(t={}){this.gateways=(t.gateways??cm).map(e=>lm(e))}async*findProviders(t,e){yield*this.gateways.toSorted(()=>Math.random()>.5?1:-1).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function fh(r={}){return new za(r)}var ja=class{libp2p;constructor(t){this.libp2p=t}async provide(t,e){await this.libp2p.contentRouting.provide(t,e)}async cancelReprovide(t,e){await this.libp2p.contentRouting.cancelReprovide(t,e)}async*findProviders(t,e){yield*this.libp2p.contentRouting.findProviders(t,e)}async put(t,e,n){await this.libp2p.contentRouting.put(t,e,n)}async get(t,e){return this.libp2p.contentRouting.get(t,e)}async findPeer(t,e){return this.libp2p.peerRouting.findPeer(t,e)}async*getClosestPeers(t,e){yield*this.libp2p.peerRouting.getClosestPeers(t,e)}};function hh(r){return new ja(r)}return Ih(fm);})();
19
19
  /*! Bundled license information:
20
20
 
21
21
  pvtsutils/build/index.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helia/routers",
3
- "version": "2.2.0-a7aebd5",
3
+ "version": "2.2.0-e45e1de",
4
4
  "description": "Routers for Helia",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/ipfs/helia/tree/main/packages/routers#readme",
@@ -55,7 +55,7 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@helia/delegated-routing-v1-http-api-client": "^4.2.1",
58
- "@helia/interface": "5.1.0-a7aebd5",
58
+ "@helia/interface": "5.1.0-e45e1de",
59
59
  "@libp2p/interface": "^2.2.1",
60
60
  "@libp2p/peer-id": "^5.0.8",
61
61
  "@multiformats/uri-to-multiaddr": "^8.0.0",