From e5030b27f5d1cce77ee59e7ffa75acf5db60516d Mon Sep 17 00:00:00 2001 From: status-im-auto Date: Tue, 20 Sep 2022 01:27:08 +0000 Subject: [PATCH] Updates --- light-js/index.html | 4 +++- relay-angular-chat/index.html | 2 +- .../{main.19e54953c2b04148.js => main.30c153659dd6ac69.js} | 2 +- relay-js/index.html | 2 +- relay-reactjs-chat/asset-manifest.json | 6 +++--- relay-reactjs-chat/index.html | 2 +- .../static/js/{main.8a4afe82.js => main.ba6c8d6d.js} | 6 +++--- ...8a4afe82.js.LICENSE.txt => main.ba6c8d6d.js.LICENSE.txt} | 0 .../js/{main.8a4afe82.js.map => main.ba6c8d6d.js.map} | 2 +- 9 files changed, 14 insertions(+), 12 deletions(-) rename relay-angular-chat/{main.19e54953c2b04148.js => main.30c153659dd6ac69.js} (55%) rename relay-reactjs-chat/static/js/{main.8a4afe82.js => main.ba6c8d6d.js} (99%) rename relay-reactjs-chat/static/js/{main.8a4afe82.js.LICENSE.txt => main.ba6c8d6d.js.LICENSE.txt} (100%) rename relay-reactjs-chat/static/js/{main.8a4afe82.js.map => main.ba6c8d6d.js.map} (97%) diff --git a/light-js/index.html b/light-js/index.html index a13a456..05d3f83 100644 --- a/light-js/index.html +++ b/light-js/index.html @@ -56,7 +56,7 @@ const textInput = document.getElementById('textInput'); const sendButton = document.getElementById('sendButton'); - const ContentTopic = "/light-js/0/message/utf8"; + const ContentTopic = "/js-waku-examples/1/chat/utf8"; let messages = [] let unsubscribe; @@ -106,12 +106,14 @@ subscribeButton.onclick = async () => { unsubscribe = await node.filter.subscribe(callback, [ContentTopic]) unsubscribeButton.disabled = false; + subscribeButton.disabled = true; } unsubscribeButton.onclick = async () => { await unsubscribe(); unsubscribe = undefined unsubscribeButton.disabled = true; + subscribeButton.disabled = false; } sendButton.onclick = async () => { diff --git a/relay-angular-chat/index.html b/relay-angular-chat/index.html index 0073240..00e5d5f 100644 --- a/relay-angular-chat/index.html +++ b/relay-angular-chat/index.html @@ -7,6 +7,6 @@ - + \ No newline at end of file diff --git a/relay-angular-chat/main.19e54953c2b04148.js b/relay-angular-chat/main.30c153659dd6ac69.js similarity index 55% rename from relay-angular-chat/main.19e54953c2b04148.js rename to relay-angular-chat/main.30c153659dd6ac69.js index ae9e376..01152c3 100644 --- a/relay-angular-chat/main.19e54953c2b04148.js +++ b/relay-angular-chat/main.30c153659dd6ac69.js @@ -1 +1 @@ -var C$=Object.defineProperty,I$=(Y,U,x)=>U in Y?C$(Y,U,{enumerable:!0,configurable:!0,writable:!0,value:x}):Y[U]=x,cb=(Y,U,x)=>(I$(Y,"symbol"!=typeof U?U+"":U,x),x),tx=(Y,U,x)=>{if(!U.has(Y))throw TypeError("Cannot "+x)},aa=(Y,U,x)=>(tx(Y,U,"read from private field"),x?x.call(Y):U.get(Y)),hp=(Y,U,x)=>{if(U.has(Y))throw TypeError("Cannot add the same private member more than once");U instanceof WeakSet?U.add(Y):U.set(Y,x)},So=(Y,U,x,y)=>(tx(Y,U,"write to private field"),y?y.call(Y,x):U.set(Y,x),x),ub=(Y,U,x,y)=>({set _(l){So(Y,U,l,x)},get _(){return aa(Y,U,y)}});(self.webpackChunkrelay_angular_chat=self.webpackChunkrelay_angular_chat||[]).push([[179],{1873:(Y,U,x)=>{"use strict";Y.exports=x(4729)},4729:(Y,U,x)=>{"use strict";var y=U;function l(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(3542),y.BufferWriter=x(989),y.Reader=x(6913),y.BufferReader=x(1872),y.util=x(6138),y.rpc=x(9852),y.roots=x(935),y.configure=l,l()},6913:(Y,U,x)=>{"use strict";Y.exports=h;var l,y=x(6138),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new l(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){l=E,h.create=f(),l._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},1872:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(6913);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(6138);function g(w){y.call(this,w)}g._configure=function(){l.Buffer&&(g.prototype._slice=l.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},935:Y=>{"use strict";Y.exports={}},9852:(Y,U,x)=>{"use strict";U.Service=x(3939)},3939:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(6138);function l(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(l.prototype=Object.create(y.EventEmitter.prototype)).constructor=l,l.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},l.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},6723:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(6138);function l(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=l.zero=new l(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=l.zeroHash="\0\0\0\0\0\0\0\0";l.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new l(d,b)},l.from=function(c){if("number"==typeof c)return l.fromNumber(c);if(y.isString(c)){if(!y.Long)return l.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new l(c.low>>>0,c.high>>>0):g},l.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},l.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;l.fromHash=function(c){return c===w?g:new l((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},l.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},l.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},l.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},l.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},6138:function(Y,U,x){"use strict";var y=U;function l(w,m,h){for(var c=Object.keys(m),f=0;f0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=l,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Y.exports=d;var l,y=x(6138),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new l})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(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 h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){l=P,d.create=b(),l._configure()}},989:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(3542);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(6138);function g(){y.call(this)}function w(m,h,c){m.length<40?l.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=l._Buffer_allocUnsafe,g.writeBytesBuffer=l.Buffer&&l.Buffer.prototype instanceof Uint8Array&&"set"===l.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=l.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},3683:(Y,U,x)=>{var js,Va,Ha,y={};x.r(y),x.d(y,{identity:()=>JB});var l={};x.r(l),x.d(l,{base2:()=>e6});var g={};x.r(g),x.d(g,{base8:()=>t6});var w={};x.r(w),x.d(w,{base10:()=>n6});var m={};x.r(m),x.d(m,{base16:()=>r6,base16upper:()=>i6});var h={};x.r(h),x.d(h,{base32:()=>co,base32hex:()=>c6,base32hexpad:()=>l6,base32hexpadupper:()=>f6,base32hexupper:()=>u6,base32pad:()=>o6,base32padupper:()=>a6,base32upper:()=>s6,base32z:()=>d6});var c={};x.r(c),x.d(c,{base36:()=>h6,base36upper:()=>p6});var f={};x.r(f),x.d(f,{base58btc:()=>ui,base58flickr:()=>g6});var d={};x.r(d),x.d(d,{base64:()=>jd,base64pad:()=>y6,base64url:()=>m6,base64urlpad:()=>v6});var b={};x.r(b),x.d(b,{base256emoji:()=>D6});var S={};x.r(S),x.d(S,{sha256:()=>mi,sha512:()=>j6});var E={};x.r(E),x.d(E,{identity:()=>Uc});var v={};x.r(v),x.d(v,{code:()=>W6,decode:()=>Y6,encode:()=>q6,name:()=>z6});var p={};x.r(p),x.d(p,{code:()=>J6,decode:()=>tF,encode:()=>eF,name:()=>X6});var I={};x.r(I),x.d(I,{RsaPrivateKey:()=>rh,RsaPublicKey:()=>Z0,fromJwk:()=>WF,generateKeyPair:()=>qF,unmarshalRsaPrivateKey:()=>GF,unmarshalRsaPublicKey:()=>zF});var A={};x.r(A),x.d(A,{Ed25519PrivateKey:()=>xl,Ed25519PublicKey:()=>vm,generateKeyPair:()=>b5,generateKeyPairFromSeed:()=>w5,unmarshalEd25519PrivateKey:()=>v5,unmarshalEd25519PublicKey:()=>E5});var P={};function D(n){return"function"==typeof n}function T(n){const t=n(r=>{Error.call(r),r.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}x.r(P),x.d(P,{Secp256k1PrivateKey:()=>Sm,Secp256k1PublicKey:()=>Dm,generateKeyPair:()=>R5,unmarshalSecp256k1PrivateKey:()=>A5,unmarshalSecp256k1PublicKey:()=>x5});const M=T(n=>function(t){n(this),this.message=t?`${t.length} errors occurred during unsubscription:\n${t.map((r,i)=>`${i+1}) ${r.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=t});function k(n,e){if(n){const t=n.indexOf(e);0<=t&&n.splice(t,1)}}class F{constructor(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let e;if(!this.closed){this.closed=!0;const{_parentage:t}=this;if(t)if(this._parentage=null,Array.isArray(t))for(const s of t)s.remove(this);else t.remove(this);const{initialTeardown:r}=this;if(D(r))try{r()}catch(s){e=s instanceof M?s.errors:[s]}const{_finalizers:i}=this;if(i){this._finalizers=null;for(const s of i)try{O(s)}catch(o){e=e??[],o instanceof M?e=[...e,...o.errors]:e.push(o)}}if(e)throw new M(e)}}add(e){var t;if(e&&e!==this)if(this.closed)O(e);else{if(e instanceof F){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(t=this._finalizers)&&void 0!==t?t:[]).push(e)}}_hasParent(e){const{_parentage:t}=this;return t===e||Array.isArray(t)&&t.includes(e)}_addParent(e){const{_parentage:t}=this;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e}_removeParent(e){const{_parentage:t}=this;t===e?this._parentage=null:Array.isArray(t)&&k(t,e)}remove(e){const{_finalizers:t}=this;t&&k(t,e),e instanceof F&&e._removeParent(this)}}F.EMPTY=(()=>{const n=new F;return n.closed=!0,n})();const G=F.EMPTY;function C(n){return n instanceof F||n&&"closed"in n&&D(n.remove)&&D(n.add)&&D(n.unsubscribe)}function O(n){D(n)?n():n.unsubscribe()}const V={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},L={setTimeout(n,e,...t){const{delegate:r}=L;return r?.setTimeout?r.setTimeout(n,e,...t):setTimeout(n,e,...t)},clearTimeout(n){const{delegate:e}=L;return(e?.clearTimeout||clearTimeout)(n)},delegate:void 0};function $(n){L.setTimeout(()=>{const{onUnhandledError:e}=V;if(!e)throw n;e(n)})}function re(){}const z=q("C",void 0,void 0);function q(n,e,t){return{kind:n,value:e,error:t}}let ne=null;function se(n){if(V.useDeprecatedSynchronousErrorHandling){const e=!ne;if(e&&(ne={errorThrown:!1,error:null}),n(),e){const{errorThrown:t,error:r}=ne;if(ne=null,t)throw r}}else n()}class pe extends F{constructor(e){super(),this.isStopped=!1,e?(this.destination=e,C(e)&&e.add(this)):this.destination=Te}static create(e,t,r){return new be(e,t,r)}next(e){this.isStopped?Ee(function X(n){return q("N",n,void 0)}(e),this):this._next(e)}error(e){this.isStopped?Ee(function te(n){return q("E",void 0,n)}(e),this):(this.isStopped=!0,this._error(e))}complete(){this.isStopped?Ee(z,this):(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe(),this.destination=null)}_next(e){this.destination.next(e)}_error(e){try{this.destination.error(e)}finally{this.unsubscribe()}}_complete(){try{this.destination.complete()}finally{this.unsubscribe()}}}const Le=Function.prototype.bind;function Se(n,e){return Le.call(n,e)}class Pe{constructor(e){this.partialObserver=e}next(e){const{partialObserver:t}=this;if(t.next)try{t.next(e)}catch(r){$e(r)}}error(e){const{partialObserver:t}=this;if(t.error)try{t.error(e)}catch(r){$e(r)}else $e(e)}complete(){const{partialObserver:e}=this;if(e.complete)try{e.complete()}catch(t){$e(t)}}}class be extends pe{constructor(e,t,r){let i;if(super(),D(e)||!e)i={next:e??void 0,error:t??void 0,complete:r??void 0};else{let s;this&&V.useDeprecatedNextContext?(s=Object.create(e),s.unsubscribe=()=>this.unsubscribe(),i={next:e.next&&Se(e.next,s),error:e.error&&Se(e.error,s),complete:e.complete&&Se(e.complete,s)}):i=e}this.destination=new Pe(i)}}function $e(n){V.useDeprecatedSynchronousErrorHandling?function de(n){V.useDeprecatedSynchronousErrorHandling&&ne&&(ne.errorThrown=!0,ne.error=n)}(n):$(n)}function Ee(n,e){const{onStoppedNotification:t}=V;t&&L.setTimeout(()=>t(n,e))}const Te={closed:!0,next:re,error:function H(n){throw n},complete:re},xe="function"==typeof Symbol&&Symbol.observable||"@@observable";function He(n){return n}let Xe=(()=>{class n{constructor(t){t&&(this._subscribe=t)}lift(t){const r=new n;return r.source=this,r.operator=t,r}subscribe(t,r,i){const s=function _t(n){return n&&n instanceof pe||function pt(n){return n&&D(n.next)&&D(n.error)&&D(n.complete)}(n)&&C(n)}(t)?t:new be(t,r,i);return se(()=>{const{operator:o,source:a}=this;s.add(o?o.call(s,a):a?this._subscribe(s):this._trySubscribe(s))}),s}_trySubscribe(t){try{return this._subscribe(t)}catch(r){t.error(r)}}forEach(t,r){return new(r=Nt(r))((i,s)=>{const o=new be({next:a=>{try{t(a)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});this.subscribe(o)})}_subscribe(t){var r;return null===(r=this.source)||void 0===r?void 0:r.subscribe(t)}[xe](){return this}pipe(...t){return function Je(n){return 0===n.length?He:1===n.length?n[0]:function(t){return n.reduce((r,i)=>i(r),t)}}(t)(this)}toPromise(t){return new(t=Nt(t))((r,i)=>{let s;this.subscribe(o=>s=o,o=>i(o),()=>r(s))})}}return n.create=e=>new n(e),n})();function Nt(n){var e;return null!==(e=n??V.Promise)&&void 0!==e?e:Promise}const Or=T(n=>function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let gr=(()=>{class n extends Xe{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(t){const r=new Hr(this,this);return r.operator=t,r}_throwIfClosed(){if(this.closed)throw new Or}next(t){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(const r of this.currentObservers)r.next(t)}})}error(t){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=t;const{observers:r}=this;for(;r.length;)r.shift().error(t)}})}complete(){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;const{observers:t}=this;for(;t.length;)t.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0}_trySubscribe(t){return this._throwIfClosed(),super._trySubscribe(t)}_subscribe(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)}_innerSubscribe(t){const{hasError:r,isStopped:i,observers:s}=this;return r||i?G:(this.currentObservers=null,s.push(t),new F(()=>{this.currentObservers=null,k(s,t)}))}_checkFinalizedStatuses(t){const{hasError:r,thrownError:i,isStopped:s}=this;r?t.error(i):s&&t.complete()}asObservable(){const t=new Xe;return t.source=this,t}}return n.create=(e,t)=>new Hr(e,t),n})();class Hr extends gr{constructor(e,t){super(),this.destination=e,this.source=t}next(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)}error(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)}complete(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)}_subscribe(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:G}}function fe(n){return e=>{if(function ie(n){return D(n?.lift)}(e))return e.lift(function(t){try{return n(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function ye(n,e,t,r,i){return new me(n,e,t,r,i)}class me extends pe{constructor(e,t,r,i,s,o){super(e),this.onFinalize=s,this.shouldUnsubscribe=o,this._next=t?function(a){try{t(a)}catch(u){e.error(u)}}:super._next,this._error=i?function(a){try{i(a)}catch(u){e.error(u)}finally{this.unsubscribe()}}:super._error,this._complete=r?function(){try{r()}catch(a){e.error(a)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){const{closed:t}=this;super.unsubscribe(),!t&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}}}function Bt(n){return this instanceof Bt?(this.v=n,this):new Bt(n)}function pn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=t.apply(n,e||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(B){r[B]&&(i[B]=function(K){return new Promise(function(Z,J){s.push([B,K,Z,J])>1||a(B,K)})})}function a(B,K){try{!function u(B){B.value instanceof Bt?Promise.resolve(B.value.v).then(_,R):N(s[0][2],B)}(r[B](K))}catch(Z){N(s[0][3],Z)}}function _(B){a("next",B)}function R(B){a("throw",B)}function N(B,K){B(K),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ft(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,e=n[Symbol.asyncIterator];return e?e.call(n):(n=function dt(n){var e="function"==typeof Symbol&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&"number"==typeof n.length)return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,u){!function i(s,o,a,u){Promise.resolve(u).then(function(_){s({value:_,done:a})},o)}(a,u,(o=n[s](o)).done,o.value)})}}}const vn=n=>n&&"number"==typeof n.length&&"function"!=typeof n;function ur(n){return D(n?.then)}function Qn(n){return D(n[xe])}function En(n){return Symbol.asyncIterator&&D(n?.[Symbol.asyncIterator])}function Ft(n){return new TypeError(`You provided ${null!==n&&"object"==typeof n?"an invalid object":`'${n}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}const ce=function ct(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function ve(n){return D(n?.[ce])}function yt(n){return pn(this,arguments,function*(){const t=n.getReader();try{for(;;){const{value:r,done:i}=yield Bt(t.read());if(i)return yield Bt(void 0);yield yield Bt(r)}}finally{t.releaseLock()}})}function Dt(n){return D(n?.getReader)}function gn(n){if(n instanceof Xe)return n;if(null!=n){if(Qn(n))return function je(n){return new Xe(e=>{const t=n[xe]();if(D(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(n);if(vn(n))return function Ye(n){return new Xe(e=>{for(let t=0;t{n.then(t=>{e.closed||(e.next(t),e.complete())},t=>e.error(t)).then(null,$)})}(n);if(En(n))return ht(n);if(ve(n))return function Ge(n){return new Xe(e=>{for(const t of n)if(e.next(t),e.closed)return;e.complete()})}(n);if(Dt(n))return function Et(n){return ht(yt(n))}(n)}throw Ft(n)}function ht(n){return new Xe(e=>{(function ut(n,e){var t,r,i,s;return function ge(n,e,t,r){return new(t||(t=Promise))(function(s,o){function a(R){try{_(r.next(R))}catch(N){o(N)}}function u(R){try{_(r.throw(R))}catch(N){o(N)}}function _(R){R.done?s(R.value):function i(s){return s instanceof t?s:new t(function(o){o(s)})}(R.value).then(a,u)}_((r=r.apply(n,e||[])).next())})}(this,void 0,void 0,function*(){try{for(t=ft(n);!(r=yield t.next()).done;)if(e.next(r.value),e.closed)return}catch(o){i={error:o}}finally{try{r&&!r.done&&(s=t.return)&&(yield s.call(t))}finally{if(i)throw i.error}}e.complete()})})(n,e).catch(t=>e.error(t))})}function St(n,e,t,r=0,i=!1){const s=e.schedule(function(){t(),i?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(s),!i)return s}function Ut(n,e,t=1/0){return D(e)?Ut((r,i)=>function _e(n,e){return fe((t,r)=>{let i=0;t.subscribe(ye(r,s=>{r.next(n.call(e,s,i++))}))})}((s,o)=>e(r,s,i,o))(gn(n(r,i))),t):("number"==typeof e&&(t=e),fe((r,i)=>function $t(n,e,t,r,i,s,o,a){const u=[];let _=0,R=0,N=!1;const B=()=>{N&&!u.length&&!_&&e.complete()},K=J=>_{s&&e.next(J),_++;let oe=!1;gn(t(J,R++)).subscribe(ye(e,he=>{i?.(he),s?K(he):e.next(he)},()=>{oe=!0},void 0,()=>{if(oe)try{for(_--;u.length&&_Z(he)):Z(he)}B()}catch(he){e.error(he)}}))};return n.subscribe(ye(e,K,()=>{N=!0,B()})),()=>{a?.()}}(r,i,n,t)))}const Dn=new Xe(n=>n.complete());function Co(n){return n[n.length-1]}function Q(n,e=0){return fe((t,r)=>{t.subscribe(ye(r,i=>St(r,n,()=>r.next(i),e),()=>St(r,n,()=>r.complete(),e),i=>St(r,n,()=>r.error(i),e)))})}function ee(n,e=0){return fe((t,r)=>{r.add(n.schedule(()=>t.subscribe(r),e))})}function Ze(n,e){if(!n)throw new Error("Iterable cannot be null");return new Xe(t=>{St(t,e,()=>{const r=n[Symbol.asyncIterator]();St(t,e,()=>{r.next().then(i=>{i.done?t.complete():t.next(i.value)})},0,!0)})})}function ei(...n){const e=function ua(n){return function ca(n){return n&&D(n.schedule)}(Co(n))?n.pop():void 0}(n),t=function W(n,e){return"number"==typeof Co(n)?n.pop():e}(n,1/0),r=n;return r.length?1===r.length?gn(r[0]):function An(n=1/0){return Ut(He,n)}(t)(function di(n,e){return e?function yr(n,e){if(null!=n){if(Qn(n))return function le(n,e){return gn(n).pipe(ee(e),Q(e))}(n,e);if(vn(n))return function Ve(n,e){return new Xe(t=>{let r=0;return e.schedule(function(){r===n.length?t.complete():(t.next(n[r++]),t.closed||this.schedule())})})}(n,e);if(ur(n))return function ke(n,e){return gn(n).pipe(ee(e),Q(e))}(n,e);if(En(n))return Ze(n,e);if(ve(n))return function tt(n,e){return new Xe(t=>{let r;return St(t,e,()=>{r=n[ce](),St(t,e,()=>{let i,s;try{({value:i,done:s}=r.next())}catch(o){return void t.error(o)}s?t.complete():t.next(i)},0,!0)}),()=>D(r?.return)&&r.return()})}(n,e);if(Dt(n))return function rn(n,e){return Ze(yt(n),e)}(n,e)}throw Ft(n)}(n,e):gn(n)}(r,e)):Dn}function Io(n,e,...t){if(!0===e)return void n();if(!1===e)return;const r=new be({next:()=>{r.unsubscribe(),n()}});return e(...t).subscribe(r)}function Xt(n){for(let e in n)if(n[e]===Xt)return e;throw Error("Could not find renamed property on target object.")}function bn(n){if("string"==typeof n)return n;if(Array.isArray(n))return"["+n.map(bn).join(", ")+"]";if(null==n)return""+n;if(n.overriddenName)return`${n.overriddenName}`;if(n.name)return`${n.name}`;const e=n.toString();if(null==e)return""+e;const t=e.indexOf("\n");return-1===t?e:e.substring(0,t)}function Li(n,e){return null==n||""===n?null===e?"":e:null==e||""===e?n:n+" "+e}const Eu=Xt({__forward_ref__:Xt});function pp(n){return n.__forward_ref__=pp,n.toString=function(){return bn(this())},n}function Rt(n){return function gp(n){return"function"==typeof n&&n.hasOwnProperty(Eu)&&n.__forward_ref__===pp}(n)?n():n}class Tt extends Error{constructor(e,t){super(function af(n,e){return`NG0${Math.abs(n)}${e?": "+e.trim():""}`}(e,t)),this.code=e}}function Vt(n){return"string"==typeof n?n:null==n?"":String(n)}function cf(n,e){throw new Tt(-201,!1)}function Ci(n,e){null==n&&function xn(n,e,t,r){throw new Error(`ASSERTION ERROR: ${n}`+(null==r?"":` [Expected=> ${t} ${r} ${e} <=Actual]`))}(e,n,null,"!=")}function zn(n){return{token:n.token,providedIn:n.providedIn||null,factory:n.factory,value:void 0}}function Ka(n){return{providers:n.providers||[],imports:n.imports||[]}}function uf(n){return lb(n,lf)||lb(n,db)}function lb(n,e){return n.hasOwnProperty(e)?n[e]:null}function fb(n){return n&&(n.hasOwnProperty(yp)||n.hasOwnProperty(ux))?n[yp]:null}const lf=Xt({\u0275prov:Xt}),yp=Xt({\u0275inj:Xt}),db=Xt({ngInjectableDef:Xt}),ux=Xt({ngInjectorDef:Xt});var Mt=(()=>((Mt=Mt||{})[Mt.Default=0]="Default",Mt[Mt.Host=1]="Host",Mt[Mt.Self=2]="Self",Mt[Mt.SkipSelf=4]="SkipSelf",Mt[Mt.Optional=8]="Optional",Mt))();let mp;function Bi(n){const e=mp;return mp=n,e}function hb(n,e,t){const r=uf(n);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:t&Mt.Optional?null:void 0!==e?e:void cf(bn(n))}function To(n){return{toString:n}.toString()}var rs=(()=>((rs=rs||{})[rs.OnPush=0]="OnPush",rs[rs.Default=1]="Default",rs))(),Is=(()=>{return(n=Is||(Is={}))[n.Emulated=0]="Emulated",n[n.None=2]="None",n[n.ShadowDom=3]="ShadowDom",Is;var n})();const Fn=(()=>typeof globalThis<"u"&&globalThis||typeof global<"u"&&global||typeof window<"u"&&window||typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self)(),$a={},Cn=[],ff=Xt({\u0275cmp:Xt}),vp=Xt({\u0275dir:Xt}),Ep=Xt({\u0275pipe:Xt}),pb=Xt({\u0275mod:Xt}),zs=Xt({\u0275fac:Xt}),bu=Xt({__NG_ELEMENT_ID__:Xt});let fx=0;function df(n){return To(()=>{const t=!0===n.standalone,r={},i={type:n.type,providersResolver:null,decls:n.decls,vars:n.vars,factory:null,template:n.template||null,consts:n.consts||null,ngContentSelectors:n.ngContentSelectors,hostBindings:n.hostBindings||null,hostVars:n.hostVars||0,hostAttrs:n.hostAttrs||null,contentQueries:n.contentQueries||null,declaredInputs:r,inputs:null,outputs:null,exportAs:n.exportAs||null,onPush:n.changeDetection===rs.OnPush,directiveDefs:null,pipeDefs:null,standalone:t,dependencies:t&&n.dependencies||null,getStandaloneInjector:null,selectors:n.selectors||Cn,viewQuery:n.viewQuery||null,features:n.features||null,data:n.data||{},encapsulation:n.encapsulation||Is.Emulated,id:"c"+fx++,styles:n.styles||Cn,_:null,setInput:null,schemas:n.schemas||null,tView:null},s=n.dependencies,o=n.features;return i.inputs=mb(n.inputs,r),i.outputs=mb(n.outputs),o&&o.forEach(a=>a(i)),i.directiveDefs=s?()=>("function"==typeof s?s():s).map(gb).filter(yb):null,i.pipeDefs=s?()=>("function"==typeof s?s():s).map(ri).filter(yb):null,i})}function gb(n){return Pn(n)||ni(n)}function yb(n){return null!==n}function wu(n){return To(()=>({type:n.type,bootstrap:n.bootstrap||Cn,declarations:n.declarations||Cn,imports:n.imports||Cn,exports:n.exports||Cn,transitiveCompileScopes:null,schemas:n.schemas||null,id:n.id||null}))}function mb(n,e){if(null==n)return $a;const t={};for(const r in n)if(n.hasOwnProperty(r)){let i=n[r],s=i;Array.isArray(i)&&(s=i[1],i=i[0]),t[i]=r,e&&(e[i]=s)}return t}const Fi=df;function Pn(n){return n[ff]||null}function ni(n){return n[vp]||null}function ri(n){return n[Ep]||null}function pi(n){return Array.isArray(n)&&"object"==typeof n[1]}function ss(n){return Array.isArray(n)&&!0===n[1]}function _p(n){return 0!=(8&n.flags)}function yf(n){return 2==(2&n.flags)}function mf(n){return 1==(1&n.flags)}function os(n){return null!==n.template}function mx(n){return 0!=(256&n[2])}function pa(n,e){return n.hasOwnProperty(zs)?n[zs]:null}class bx{constructor(e,t,r){this.previousValue=e,this.currentValue=t,this.firstChange=r}isFirstChange(){return this.firstChange}}function bb(n){return n.type.prototype.ngOnChanges&&(n.setInput=_x),wx}function wx(){const n=_b(this),e=n?.current;if(e){const t=n.previous;if(t===$a)n.previous=e;else for(let r in e)t[r]=e[r];n.current=null,this.ngOnChanges(e)}}function _x(n,e,t,r){const i=_b(n)||function Dx(n,e){return n[wb]=e}(n,{previous:$a,current:null}),s=i.current||(i.current={}),o=i.previous,a=this.declaredInputs[t],u=o[a];s[a]=new bx(u&&u.currentValue,e,o===$a),n[r]=e}const wb="__ngSimpleChanges__";function _b(n){return n[wb]||null}function mr(n){for(;Array.isArray(n);)n=n[0];return n}function Hi(n,e){return mr(e[n.index])}function Tp(n,e){return n.data[e]}function Ai(n,e){const t=e[n];return pi(t)?t:t[0]}function bf(n){return 64==(64&n[2])}function Ao(n,e){return null==e?null:n[e]}function Db(n){n[18]=0}function Ap(n,e){n[5]+=e;let t=n,r=n[3];for(;null!==r&&(1===e&&1===t[5]||-1===e&&0===t[5]);)r[5]+=e,t=r,r=r[3]}const kt={lFrame:Mb(null),bindingsEnabled:!0};function Cb(){return kt.bindingsEnabled}function Ue(){return kt.lFrame.lView}function fn(){return kt.lFrame.tView}function Tr(){let n=Ib();for(;null!==n&&64===n.type;)n=n.parent;return n}function Ib(){return kt.lFrame.currentTNode}function Ts(n,e){const t=kt.lFrame;t.currentTNode=n,t.isParent=e}function xp(){return kt.lFrame.isParent}function qa(){return kt.lFrame.bindingIndex++}function Vx(n,e){const t=kt.lFrame;t.bindingIndex=t.bindingRootIndex=n,Pp(e)}function Pp(n){kt.lFrame.currentDirectiveIndex=n}function Mp(n){kt.lFrame.currentQueryIndex=n}function Kx(n){const e=n[1];return 2===e.type?e.declTNode:1===e.type?n[6]:null}function Pb(n,e,t){if(t&Mt.SkipSelf){let i=e,s=n;for(;!(i=i.parent,null!==i||t&Mt.Host||(i=Kx(s),null===i||(s=s[15],10&i.type))););if(null===i)return!1;e=i,n=s}const r=kt.lFrame=Nb();return r.currentTNode=e,r.lView=n,!0}function Op(n){const e=Nb(),t=n[1];kt.lFrame=e,e.currentTNode=t.firstChild,e.lView=n,e.tView=t,e.contextLView=n,e.bindingIndex=t.bindingStartIndex,e.inI18n=!1}function Nb(){const n=kt.lFrame,e=null===n?null:n.child;return null===e?Mb(n):e}function Mb(n){const e={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:n,child:null,inI18n:!1};return null!==n&&(n.child=e),e}function Ob(){const n=kt.lFrame;return kt.lFrame=n.parent,n.currentTNode=null,n.lView=null,n}const kb=Ob;function kp(){const n=Ob();n.isParent=!0,n.tView=null,n.selectedIndex=-1,n.contextLView=null,n.elementDepthCount=0,n.currentDirectiveIndex=-1,n.currentNamespace=null,n.bindingRootIndex=-1,n.bindingIndex=-1,n.currentQueryIndex=0}function si(){return kt.lFrame.selectedIndex}function xo(n){kt.lFrame.selectedIndex=n}function wf(n,e){for(let t=e.directiveStart,r=e.directiveEnd;t=r)break}else e[u]<0&&(n[18]+=65536),(a>11>16&&(3&n[2])===e){n[2]+=2048;try{s.call(a)}finally{}}}else try{s.call(a)}finally{}}class Au{constructor(e,t,r){this.factory=e,this.resolving=!1,this.canSeeViewProviders=t,this.injectImpl=r}}function Sf(n,e,t){let r=0;for(;re){o=s-1;break}}}for(;s>16}(n),r=e;for(;t>0;)r=r[15],t--;return r}let Fp=!0;function If(n){const e=Fp;return Fp=n,e}let rR=0;const As={};function Ru(n,e){const t=Vp(n,e);if(-1!==t)return t;const r=e[1];r.firstCreatePass&&(n.injectorIndex=e.length,Up(r.data,n),Up(e,null),Up(r.blueprint,null));const i=Tf(n,e),s=n.injectorIndex;if(Vb(i)){const o=Ya(i),a=Qa(i,e),u=a[1].data;for(let _=0;_<8;_++)e[s+_]=a[o+_]|u[o+_]}return e[s+8]=i,s}function Up(n,e){n.push(0,0,0,0,0,0,0,0,e)}function Vp(n,e){return-1===n.injectorIndex||n.parent&&n.parent.injectorIndex===n.injectorIndex||null===e[n.injectorIndex+8]?-1:n.injectorIndex}function Tf(n,e){if(n.parent&&-1!==n.parent.injectorIndex)return n.parent.injectorIndex;let t=0,r=null,i=e;for(;null!==i;){if(r=Yb(i),null===r)return-1;if(t++,i=i[15],-1!==r.injectorIndex)return r.injectorIndex|t<<16}return-1}function Af(n,e,t){!function iR(n,e,t){let r;"string"==typeof t?r=t.charCodeAt(0)||0:t.hasOwnProperty(bu)&&(r=t[bu]),null==r&&(r=t[bu]=rR++);const i=255&r;e.data[n+(i>>5)]|=1<=0?255&e:cR:e}(t);if("function"==typeof s){if(!Pb(e,n,r))return r&Mt.Host?$b(i,0,r):jb(e,t,r,i);try{const o=s(r);if(null!=o||r&Mt.Optional)return o;cf()}finally{kb()}}else if("number"==typeof s){let o=null,a=Vp(n,e),u=-1,_=r&Mt.Host?e[16][6]:null;for((-1===a||r&Mt.SkipSelf)&&(u=-1===a?Tf(n,e):e[a+8],-1!==u&&qb(r,!1)?(o=e[1],a=Ya(u),e=Qa(u,e)):a=-1);-1!==a;){const R=e[1];if(Wb(s,a,R.data)){const N=oR(a,e,t,o,r,_);if(N!==As)return N}u=e[a+8],-1!==u&&qb(r,e[1].data[a+8]===_)&&Wb(s,a,e)?(o=R,a=Ya(u),e=Qa(u,e)):a=-1}}return i}function oR(n,e,t,r,i,s){const o=e[1],a=o.data[n+8],R=function xf(n,e,t,r,i){const s=n.providerIndexes,o=e.data,a=1048575&s,u=n.directiveStart,R=s>>20,B=i?a+R:n.directiveEnd;for(let K=r?a:a+R;K=u&&Z.type===t)return K}if(i){const K=o[u];if(K&&os(K)&&K.type===t)return u}return null}(a,o,t,null==r?yf(a)&&Fp:r!=o&&0!=(3&a.type),i&Mt.Host&&s===a);return null!==R?Pu(e,o,R,a):As}function Pu(n,e,t,r){let i=n[t];const s=e.data;if(function Xx(n){return n instanceof Au}(i)){const o=i;o.resolving&&function nx(n,e){const t=e?`. Dependency path: ${e.join(" > ")} > ${n}`:"";throw new Tt(-200,`Circular dependency in DI detected for ${n}${t}`)}(function Sn(n){return"function"==typeof n?n.name||n.toString():"object"==typeof n&&null!=n&&"function"==typeof n.type?n.type.name||n.type.toString():Vt(n)}(s[t]));const a=If(o.canSeeViewProviders);o.resolving=!0;const u=o.injectImpl?Bi(o.injectImpl):null;Pb(n,r,Mt.Default);try{i=n[t]=o.factory(void 0,s,n,r),e.firstCreatePass&&t>=r.directiveStart&&function Qx(n,e,t){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:s}=e.type.prototype;if(r){const o=bb(e);(t.preOrderHooks||(t.preOrderHooks=[])).push(n,o),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,o)}i&&(t.preOrderHooks||(t.preOrderHooks=[])).push(0-n,i),s&&((t.preOrderHooks||(t.preOrderHooks=[])).push(n,s),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,s))}(t,s[t],e)}finally{null!==u&&Bi(u),If(a),o.resolving=!1,kb()}}return i}function Wb(n,e,t){return!!(t[e+(n>>5)]&1<{const r=function $p(n){return function(...t){if(n){const r=n(...t);for(const i in r)this[i]=r[i]}}}(e);function i(...s){if(this instanceof i)return r.apply(this,s),this;const o=new i(...s);return a.annotation=o,a;function a(u,_,R){const N=u.hasOwnProperty(Ja)?u[Ja]:Object.defineProperty(u,Ja,{value:[]})[Ja];for(;N.length<=R;)N.push(null);return(N[R]=N[R]||[]).push(o),u}}return t&&(i.prototype=Object.create(t.prototype)),i.prototype.ngMetadataName=n,i.annotationCls=i,i})}class sn{constructor(e,t){this._desc=e,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,"number"==typeof t?this.__NG_ELEMENT_ID__=t:void 0!==t&&(this.\u0275prov=zn({token:this,providedIn:t.providedIn||"root",factory:t.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}}function Ys(n,e){n.forEach(t=>Array.isArray(t)?Ys(t,e):e(t))}function Zb(n,e,t){e>=n.length?n.push(t):n.splice(e,0,t)}function Rf(n,e){return e>=n.length-1?n.pop():n.splice(e,1)[0]}const ku={},Wp="__NG_DI_FLAG__",Nf="ngTempTokenPath",_R=/\n/gm,tw="__source";let Lu;function rc(n){const e=Lu;return Lu=n,e}function SR(n,e=Mt.Default){if(void 0===Lu)throw new Tt(-203,!1);return null===Lu?hb(n,void 0,e):Lu.get(n,e&Mt.Optional?null:void 0,e)}function Rn(n,e=Mt.Default){return(function lx(){return mp}()||SR)(Rt(n),e)}function qp(n){const e=[];for(let t=0;t{const o=s;rg(o,t,[],r)&&(i||(i=[]),i.push(o))}),void 0!==i&&Aw(i,t),t}function Aw(n,e){for(let t=0;t{e.push(s)})}}function rg(n,e,t,r){if(!(n=Rt(n)))return!1;let i=null,s=fb(n);const o=!s&&Pn(n);if(s||o){if(o&&!o.standalone)return!1;i=n}else{const u=n.ngModule;if(s=fb(u),!s)return!1;i=u}const a=r.has(i);if(o){if(a)return!1;if(r.add(i),o.dependencies){const u="function"==typeof o.dependencies?o.dependencies():o.dependencies;for(const _ of u)rg(_,e,t,r)}}else{if(!s)return!1;{if(null!=s.imports&&!a){let _;r.add(i);try{Ys(s.imports,R=>{rg(R,e,t,r)&&(_||(_=[]),_.push(R))})}finally{}void 0!==_&&Aw(_,e)}if(!a){const _=pa(i)||(()=>new i);e.push({provide:i,useFactory:_,deps:Cn},{provide:Cw,useValue:i,multi:!0},{provide:Dw,useValue:()=>Rn(i),multi:!0})}const u=s.providers;null==u||a||Ys(u,R=>{e.push(R)})}}return i!==n&&void 0!==n.providers}const fP=Xt({provide:String,useValue:Xt});function ig(n){return null!==n&&"object"==typeof n&&fP in n}function ga(n){return"function"==typeof n}const sg=new sn("Set Injector scope."),Vf={},hP={};let og;function Hf(){return void 0===og&&(og=new Iw),og}class oc{}class Pw extends oc{constructor(e,t,r,i){super(),this.parent=t,this.source=r,this.scopes=i,this.records=new Map,this._ngOnDestroyHooks=new Set,this._onDestroyHooks=[],this._destroyed=!1,cg(e,o=>this.processProvider(o)),this.records.set(Sw,ac(void 0,this)),i.has("environment")&&this.records.set(oc,ac(void 0,this));const s=this.records.get(sg);null!=s&&"string"==typeof s.value&&this.scopes.add(s.value),this.injectorDefTypes=new Set(this.get(Cw.multi,Cn,Mt.Self))}get destroyed(){return this._destroyed}destroy(){this.assertNotDestroyed(),this._destroyed=!0;try{for(const e of this._ngOnDestroyHooks)e.ngOnDestroy();for(const e of this._onDestroyHooks)e()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),this._onDestroyHooks.length=0}}onDestroy(e){this._onDestroyHooks.push(e)}runInContext(e){this.assertNotDestroyed();const t=rc(this),r=Bi(void 0);try{return e()}finally{rc(t),Bi(r)}}get(e,t=ku,r=Mt.Default){this.assertNotDestroyed();const i=rc(this),s=Bi(void 0);try{if(!(r&Mt.SkipSelf)){let a=this.records.get(e);if(void 0===a){const u=function vP(n){return"function"==typeof n||"object"==typeof n&&n instanceof sn}(e)&&uf(e);a=u&&this.injectableDefInScope(u)?ac(ag(e),Vf):null,this.records.set(e,a)}if(null!=a)return this.hydrate(e,a)}return(r&Mt.Self?Hf():this.parent).get(e,t=r&Mt.Optional&&t===ku?null:t)}catch(o){if("NullInjectorError"===o.name){if((o[Nf]=o[Nf]||[]).unshift(bn(e)),i)throw o;return function TR(n,e,t,r){const i=n[Nf];throw e[tw]&&i.unshift(e[tw]),n.message=function AR(n,e,t,r=null){n=n&&"\n"===n.charAt(0)&&"\u0275"==n.charAt(1)?n.slice(2):n;let i=bn(e);if(Array.isArray(e))i=e.map(bn).join(" -> ");else if("object"==typeof e){let s=[];for(let o in e)if(e.hasOwnProperty(o)){let a=e[o];s.push(o+":"+("string"==typeof a?JSON.stringify(a):bn(a)))}i=`{${s.join(", ")}}`}return`${t}${r?"("+r+")":""}[${i}]: ${n.replace(_R,"\n ")}`}("\n"+n.message,i,t,r),n.ngTokenPath=i,n[Nf]=null,n}(o,e,"R3InjectorError",this.source)}throw o}finally{Bi(s),rc(i)}}resolveInjectorInitializers(){const e=rc(this),t=Bi(void 0);try{const r=this.get(Dw.multi,Cn,Mt.Self);for(const i of r)i()}finally{rc(e),Bi(t)}}toString(){const e=[],t=this.records;for(const r of t.keys())e.push(bn(r));return`R3Injector[${e.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new Tt(205,!1)}processProvider(e){let t=ga(e=Rt(e))?e:Rt(e&&e.provide);const r=function gP(n){return ig(n)?ac(void 0,n.useValue):ac(function Nw(n,e,t){let r;if(ga(n)){const i=Rt(n);return pa(i)||ag(i)}if(ig(n))r=()=>Rt(n.useValue);else if(function Rw(n){return!(!n||!n.useFactory)}(n))r=()=>n.useFactory(...qp(n.deps||[]));else if(function xw(n){return!(!n||!n.useExisting)}(n))r=()=>Rn(Rt(n.useExisting));else{const i=Rt(n&&(n.useClass||n.provide));if(!function yP(n){return!!n.deps}(n))return pa(i)||ag(i);r=()=>new i(...qp(n.deps))}return r}(n),Vf)}(e);if(ga(e)||!0!==e.multi)this.records.get(t);else{let i=this.records.get(t);i||(i=ac(void 0,Vf,!0),i.factory=()=>qp(i.multi),this.records.set(t,i)),t=e,i.multi.push(e)}this.records.set(t,r)}hydrate(e,t){return t.value===Vf&&(t.value=hP,t.value=t.factory()),"object"==typeof t.value&&t.value&&function mP(n){return null!==n&&"object"==typeof n&&"function"==typeof n.ngOnDestroy}(t.value)&&this._ngOnDestroyHooks.add(t.value),t.value}injectableDefInScope(e){if(!e.providedIn)return!1;const t=Rt(e.providedIn);return"string"==typeof t?"any"===t||this.scopes.has(t):this.injectorDefTypes.has(t)}}function ag(n){const e=uf(n),t=null!==e?e.factory:pa(n);if(null!==t)return t;if(n instanceof sn)throw new Tt(204,!1);if(n instanceof Function)return function pP(n){const e=n.length;if(e>0)throw function Ou(n,e){const t=[];for(let r=0;rt.factory(n):()=>new n}(n);throw new Tt(204,!1)}function ac(n,e,t=!1){return{factory:n,value:e,multi:t?[]:void 0}}function EP(n){return!!n.\u0275providers}function cg(n,e){for(const t of n)Array.isArray(t)?cg(t,e):EP(t)?cg(t.\u0275providers,e):e(t)}class Mw{}class _P{resolveComponentFactory(e){throw function wP(n){const e=Error(`No component factory found for ${bn(n)}. Did you add it to @NgModule.entryComponents?`);return e.ngComponent=n,e}(e)}}let Kf=(()=>{class n{}return n.NULL=new _P,n})();function DP(){return cc(Tr(),Ue())}function cc(n,e){return new uc(Hi(n,e))}let uc=(()=>{class n{constructor(t){this.nativeElement=t}}return n.__NG_ELEMENT_ID__=DP,n})();class kw{}let IP=(()=>{class n{}return n.\u0275prov=zn({token:n,providedIn:"root",factory:()=>null}),n})();class ug{constructor(e){this.full=e,this.major=e.split(".")[0],this.minor=e.split(".")[1],this.patch=e.split(".").slice(2).join(".")}}const TP=new ug("14.2.2"),lg={};function gg(n){return n.ngOriginalError}class lc{constructor(){this._console=console}handleError(e){const t=this._findOriginalError(e);this._console.error("ERROR",e),t&&this._console.error("ORIGINAL ERROR",t)}_findOriginalError(e){let t=e&&gg(e);for(;t&&gg(t);)t=gg(t);return t||null}}const yg=new Map;let UP=0;const vg="__ngContext__";function jr(n,e){pi(e)?(n[vg]=e[20],function HP(n){yg.set(n[20],n)}(e)):n[vg]=e}var gi=(()=>((gi=gi||{})[gi.Important=1]="Important",gi[gi.DashCase=2]="DashCase",gi))();function bg(n,e){return undefined(n,e)}function ju(n){const e=n[3];return ss(e)?e[3]:e}function wg(n){return Qw(n[13])}function _g(n){return Qw(n[4])}function Qw(n){for(;null!==n&&!ss(n);)n=n[4];return n}function dc(n,e,t,r,i){if(null!=r){let s,o=!1;ss(r)?s=r:pi(r)&&(o=!0,r=r[0]);const a=mr(r);0===n&&null!==t?null==i?n_(e,t,a):ya(e,t,a,i||null,!0):1===n&&null!==t?ya(e,t,a,i||null,!0):2===n?function u_(n,e,t){const r=$f(n,e);r&&function pN(n,e,t,r){n.removeChild(e,t,r)}(n,r,e,t)}(e,a,o):3===n&&e.destroyNode(a),null!=s&&function mN(n,e,t,r,i){const s=t[7];s!==mr(t)&&dc(e,n,r,s,i);for(let a=10;a0&&(n[t-1][4]=r[4]);const s=Rf(n,10+e);!function oN(n,e){Gu(n,e,e[11],2,null,null),e[0]=null,e[6]=null}(r[1],r);const o=s[19];null!==o&&o.detachView(s[1]),r[3]=null,r[4]=null,r[2]&=-65}return r}function Jw(n,e){if(!(128&e[2])){const t=e[11];t.destroyNode&&Gu(n,e,t,3,null,null),function uN(n){let e=n[13];if(!e)return Ig(n[1],n);for(;e;){let t=null;if(pi(e))t=e[13];else{const r=e[10];r&&(t=r)}if(!t){for(;e&&!e[4]&&e!==n;)pi(e)&&Ig(e[1],e),e=e[3];null===e&&(e=n),pi(e)&&Ig(e[1],e),t=e&&e[4]}e=t}}(e)}}function Ig(n,e){if(!(128&e[2])){e[2]&=-65,e[2]|=128,function hN(n,e){let t;if(null!=n&&null!=(t=n.destroyHooks))for(let r=0;r=0?r[i=_]():r[i=-_].unsubscribe(),s+=2}else{const o=r[i=t[s+1]];t[s].call(o)}if(null!==r){for(let s=i+1;ss?"":i[N+1].toLowerCase();const K=8&r?B:null;if(K&&-1!==d_(K,_,0)||2&r&&_!==B){if(as(r))return!1;o=!0}}}}else{if(!o&&!as(r)&&!as(u))return!1;if(o&&as(u))continue;o=!1,r=u|1&r}}return as(r)||o}function as(n){return 0==(1&n)}function _N(n,e,t,r){if(null===e)return-1;let i=0;if(r||!t){let s=!1;for(;i-1)for(t++;t0?'="'+a+'"':"")+"]"}else 8&r?i+="."+o:4&r&&(i+=" "+o);else""!==i&&!as(o)&&(e+=y_(s,i),i=""),r=o,s=s||!as(r);t++}return""!==i&&(e+=y_(s,i)),e}const Ht={};function zu(n){m_(fn(),Ue(),si()+n,!1)}function m_(n,e,t,r){if(!r)if(3==(3&e[2])){const s=n.preOrderCheckHooks;null!==s&&_f(e,s,t)}else{const s=n.preOrderHooks;null!==s&&Df(e,s,0,t)}xo(t)}function w_(n,e=null,t=null,r){const i=__(n,e,t,r);return i.resolveInjectorInitializers(),i}function __(n,e=null,t=null,r,i=new Set){const s=[t||Cn,lP(n)];return r=r||("object"==typeof n?void 0:bn(n)),new Pw(s,e||Hf(),r||null,i)}let ma=(()=>{class n{static create(t,r){if(Array.isArray(t))return w_({name:""},r,t,"");{const i=t.name??"";return w_({name:i},t.parent,t.providers,i)}}}return n.THROW_IF_NOT_FOUND=ku,n.NULL=new Iw,n.\u0275prov=zn({token:n,providedIn:"any",factory:()=>Rn(Sw)}),n.__NG_ELEMENT_ID__=-1,n})();function Zt(n,e=Mt.Default){const t=Ue();return null===t?Rn(n,e):Gb(Tr(),t,Rt(n),e)}function U_(n,e){const t=n.contentQueries;if(null!==t)for(let r=0;r22&&m_(n,e,22,!1),t(r,i)}finally{xo(s)}}function Wg(n,e,t){!Cb()||(function gM(n,e,t,r){const i=t.directiveStart,s=t.directiveEnd;n.firstCreatePass||Ru(t,e),jr(r,e);const o=t.initialInputs;for(let a=i;a0;){const t=n[--e];if("number"==typeof t&&t<0)return t}return 0})(a)!=u&&a.push(u),a.push(r,i,o)}}function q_(n,e){null!==n.hostBindings&&n.hostBindings(1,e)}function Y_(n,e){e.flags|=2,(n.components||(n.components=[])).push(e.index)}function EM(n,e,t){if(t){if(e.exportAs)for(let r=0;r0&&Xg(t)}}function Xg(n){for(let r=wg(n);null!==r;r=_g(r))for(let i=10;i0&&Xg(s)}const t=n[1].components;if(null!==t)for(let r=0;r0&&Xg(i)}}function IM(n,e){const t=Ai(e,n),r=t[1];(function TM(n,e){for(let t=e.length;t-1&&(Cg(e,r),Rf(t,r))}this._attachedToViewContainer=!1}Jw(this._lView[1],this._lView)}onDestroy(e){!function $_(n,e,t,r){const i=J_(e);null===t?i.push(r):(i.push(t),n.firstCreatePass&&e1(n).push(r,i.length-1))}(this._lView[1],this._lView,null,e)}markForCheck(){Jg(this._cdRefInjectingView||this._lView)}detach(){this._lView[2]&=-65}reattach(){this._lView[2]|=64}detectChanges(){Jf(this._lView[1],this._lView,this.context)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new Tt(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function cN(n,e){Gu(n,e,e[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new Tt(902,!1);this._appRef=e}}class AM extends Wu{constructor(e){super(e),this._view=e}detectChanges(){const e=this._view;Jf(e[1],e,e[8],!1)}checkNoChanges(){}get context(){return null}}class ny extends Kf{constructor(e){super(),this.ngModule=e}resolveComponentFactory(e){const t=Pn(e);return new qu(t,this.ngModule)}}function r1(n){const e=[];for(let t in n)n.hasOwnProperty(t)&&e.push({propName:n[t],templateName:t});return e}class RM{constructor(e,t){this.injector=e,this.parentInjector=t}get(e,t,r){const i=this.injector.get(e,lg,r);return i!==lg||t===lg?i:this.parentInjector.get(e,t,r)}}class qu extends Mw{constructor(e,t){super(),this.componentDef=e,this.ngModule=t,this.componentType=e.type,this.selector=function AN(n){return n.map(TN).join(",")}(e.selectors),this.ngContentSelectors=e.ngContentSelectors?e.ngContentSelectors:[],this.isBoundToModule=!!t}get inputs(){return r1(this.componentDef.inputs)}get outputs(){return r1(this.componentDef.outputs)}create(e,t,r,i){let s=(i=i||this.ngModule)instanceof oc?i:i?.injector;s&&null!==this.componentDef.getStandaloneInjector&&(s=this.componentDef.getStandaloneInjector(s)||s);const o=s?new RM(e,s):e,a=o.get(kw,null);if(null===a)throw new Tt(407,!1);const u=o.get(IP,null),_=a.createRenderer(null,this.componentDef),R=this.componentDef.selectors[0][0]||"div",N=r?function uM(n,e,t){return n.selectRootElement(e,t===Is.ShadowDom)}(_,r,this.componentDef.encapsulation):Sg(a.createRenderer(null,this.componentDef),R,function xM(n){const e=n.toLowerCase();return"svg"===e?"svg":"math"===e?"math":null}(R)),B=this.componentDef.onPush?288:272,K=Yg(0,null,null,1,0,null,null,null,null,null),Z=Qf(null,K,null,B,null,null,a,_,u,o,null);let J,oe;Op(Z);try{const he=function MM(n,e,t,r,i,s){const o=t[1];t[22]=n;const u=pc(o,22,2,"#host",null),_=u.mergedAttrs=e.hostAttrs;null!==_&&(ed(u,_,!0),null!==n&&(Sf(i,n,_),null!==u.classes&&Rg(i,n,u.classes),null!==u.styles&&f_(i,n,u.styles)));const R=r.createRenderer(n,e),N=Qf(t,K_(e),null,e.onPush?32:16,t[22],u,r,R,s||null,null,null);return o.firstCreatePass&&(Af(Ru(u,t),o,e.type),Y_(o,u),Q_(u,t.length,1)),Xf(t,N),t[22]=N}(N,this.componentDef,Z,a,_);if(N)if(r)Sf(_,N,["ng-version",TP.full]);else{const{attrs:Ie,classes:ue}=function xN(n){const e=[],t=[];let r=1,i=2;for(;r0&&Rg(_,N,ue.join(" "))}if(oe=Tp(K,22),void 0!==t){const Ie=oe.projection=[];for(let ue=0;uea(mr(ze[r.index])):r.index;let Re=null;if(!a&&u&&(Re=function eO(n,e,t,r){const i=n.cleanup;if(null!=i)for(let s=0;su?a[u]:null}"string"==typeof o&&(s+=2)}return null}(n,e,i,r.index)),null!==Re)(Re.__ngLastListenerFn__||Re).__ngNextListenerFn__=s,Re.__ngLastListenerFn__=s,K=!1;else{s=_1(r,e,N,s,!1);const ze=t.listen(he,i,s);B.push(s,ze),R&&R.push(i,ue,Ie,Ie+1)}}else s=_1(r,e,N,s,!1);const Z=r.outputs;let J;if(K&&null!==Z&&(J=Z[i])){const oe=J.length;if(oe)for(let he=0;het()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}}class wy extends class K3{}{constructor(e){super(),this.moduleType=e}create(e){return new UD(this.moduleType,e)}}function Dy(n){return e=>{setTimeout(n,void 0,e)}}const no=class vk extends gr{constructor(e=!1){super(),this.__isAsync=e}emit(e){super.next(e)}subscribe(e,t,r){let i=e,s=t||(()=>null),o=r;if(e&&"object"==typeof e){const u=e;i=u.next?.bind(u),s=u.error?.bind(u),o=u.complete?.bind(u)}this.__isAsync&&(s=Dy(s),i&&(i=Dy(i)),o&&(o=Dy(o)));const a=super.subscribe({next:i,error:s,complete:o});return e instanceof F&&e.add(a),a}};let ro=(()=>{class n{}return n.__NG_ELEMENT_ID__=_k,n})();const bk=ro,wk=class extends bk{constructor(e,t,r){super(),this._declarationLView=e,this._declarationTContainer=t,this.elementRef=r}createEmbeddedView(e,t){const r=this._declarationTContainer.tViews,i=Qf(this._declarationLView,r,e,16,null,r.declTNode,null,null,null,null,t||null);i[17]=this._declarationLView[this._declarationTContainer.index];const o=this._declarationLView[19];return null!==o&&(i[19]=o.createEmbeddedView(r)),zg(r,i,e),new Wu(i)}};function _k(){return function fd(n,e){return 4&n.type?new wk(e,n,cc(n,e)):null}(Tr(),Ue())}let Ms=(()=>{class n{}return n.__NG_ELEMENT_ID__=Dk,n})();function Dk(){return function eS(n,e){let t;const r=e[n.index];if(ss(r))t=r;else{let i;if(8&n.type)i=mr(r);else{const s=e[11];i=s.createComment("");const o=Hi(n,e);ya(s,$f(s,o),i,function gN(n,e){return n.nextSibling(e)}(s,o),!1)}e[n.index]=t=X_(r,e,i,n),Xf(e,t)}return new XD(t,n,e)}(Tr(),Ue())}const Sk=Ms,XD=class extends Sk{constructor(e,t,r){super(),this._lContainer=e,this._hostTNode=t,this._hostLView=r}get element(){return cc(this._hostTNode,this._hostLView)}get injector(){return new Za(this._hostTNode,this._hostLView)}get parentInjector(){const e=Tf(this._hostTNode,this._hostLView);if(Vb(e)){const t=Qa(e,this._hostLView),r=Ya(e);return new Za(t[1].data[r+8],t)}return new Za(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){const t=JD(this._lContainer);return null!==t&&t[e]||null}get length(){return this._lContainer.length-10}createEmbeddedView(e,t,r){let i,s;"number"==typeof r?i=r:null!=r&&(i=r.index,s=r.injector);const o=e.createEmbeddedView(t||{},s);return this.insert(o,i),o}createComponent(e,t,r,i,s){const o=e&&!function Mu(n){return"function"==typeof n}(e);let a;if(o)a=t;else{const N=t||{};a=N.index,r=N.injector,i=N.projectableNodes,s=N.environmentInjector||N.ngModuleRef}const u=o?e:new qu(Pn(e)),_=r||this.parentInjector;if(!s&&null==u.ngModule){const B=(o?_:this.parentInjector).get(oc,null);B&&(s=B)}const R=u.create(_,i,void 0,s);return this.insert(R.hostView,a),R}insert(e,t){const r=e._lView,i=r[1];if(function Rx(n){return ss(n[3])}(r)){const R=this.indexOf(e);if(-1!==R)this.detach(R);else{const N=r[3],B=new XD(N,N[6],N[3]);B.detach(B.indexOf(e))}}const s=this._adjustIndex(t),o=this._lContainer;!function lN(n,e,t,r){const i=10+r,s=t.length;r>0&&(t[i-1][4]=e),r{class n{constructor(t){this.appInits=t,this.resolve=hd,this.reject=hd,this.initialized=!1,this.done=!1,this.donePromise=new Promise((r,i)=>{this.resolve=r,this.reject=i})}runInitializers(){if(this.initialized)return;const t=[],r=()=>{this.done=!0,this.resolve()};if(this.appInits)for(let i=0;i{s.subscribe({complete:a,error:u})});t.push(o)}}Promise.all(t).then(()=>{r()}).catch(i=>{this.reject(i)}),0===t.length&&r(),this.initialized=!0}}return n.\u0275fac=function(t){return new(t||n)(Rn(SS,8))},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();const ol=new sn("AppId",{providedIn:"root",factory:function CS(){return`${ky()}${ky()}${ky()}`}});function ky(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const IS=new sn("Platform Initializer"),TS=new sn("Platform ID",{providedIn:"platform",factory:()=>"unknown"}),rL=new sn("appBootstrapListener"),io=new sn("LocaleId",{providedIn:"root",factory:()=>function CR(n,e=Mt.Default){return"number"!=typeof e&&(e=0|(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)),Rn(n,e)}(io,Mt.Optional|Mt.SkipSelf)||function iL(){return typeof $localize<"u"&&$localize.locale||Ac}()}),uL=(()=>Promise.resolve(0))();function Ly(n){typeof Zone>"u"?uL.then(()=>{n&&n.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",n)}class zr{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:t=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new no(!1),this.onMicrotaskEmpty=new no(!1),this.onStable=new no(!1),this.onError=new no(!1),typeof Zone>"u")throw new Tt(908,!1);Zone.assertZonePatched();const i=this;if(i._nesting=0,i._outer=i._inner=Zone.current,Zone.AsyncStackTaggingZoneSpec){const s=Zone.AsyncStackTaggingZoneSpec;i._inner=i._inner.fork(new s("Angular"))}Zone.TaskTrackingZoneSpec&&(i._inner=i._inner.fork(new Zone.TaskTrackingZoneSpec)),e&&Zone.longStackTraceZoneSpec&&(i._inner=i._inner.fork(Zone.longStackTraceZoneSpec)),i.shouldCoalesceEventChangeDetection=!r&&t,i.shouldCoalesceRunChangeDetection=r,i.lastRequestAnimationFrameId=-1,i.nativeRequestAnimationFrame=function lL(){let n=Fn.requestAnimationFrame,e=Fn.cancelAnimationFrame;if(typeof Zone<"u"&&n&&e){const t=n[Zone.__symbol__("OriginalDelegate")];t&&(n=t);const r=e[Zone.__symbol__("OriginalDelegate")];r&&(e=r)}return{nativeRequestAnimationFrame:n,nativeCancelAnimationFrame:e}}().nativeRequestAnimationFrame,function hL(n){const e=()=>{!function dL(n){n.isCheckStableRunning||-1!==n.lastRequestAnimationFrameId||(n.lastRequestAnimationFrameId=n.nativeRequestAnimationFrame.call(Fn,()=>{n.fakeTopEventTask||(n.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{n.lastRequestAnimationFrameId=-1,Fy(n),n.isCheckStableRunning=!0,By(n),n.isCheckStableRunning=!1},void 0,()=>{},()=>{})),n.fakeTopEventTask.invoke()}),Fy(n))}(n)};n._inner=n._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(t,r,i,s,o,a)=>{try{return RS(n),t.invokeTask(i,s,o,a)}finally{(n.shouldCoalesceEventChangeDetection&&"eventTask"===s.type||n.shouldCoalesceRunChangeDetection)&&e(),PS(n)}},onInvoke:(t,r,i,s,o,a,u)=>{try{return RS(n),t.invoke(i,s,o,a,u)}finally{n.shouldCoalesceRunChangeDetection&&e(),PS(n)}},onHasTask:(t,r,i,s)=>{t.hasTask(i,s),r===i&&("microTask"==s.change?(n._hasPendingMicrotasks=s.microTask,Fy(n),By(n)):"macroTask"==s.change&&(n.hasPendingMacrotasks=s.macroTask))},onHandleError:(t,r,i,s)=>(t.handleError(i,s),n.runOutsideAngular(()=>n.onError.emit(s)),!1)})}(i)}static isInAngularZone(){return typeof Zone<"u"&&!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!zr.isInAngularZone())throw new Tt(909,!1)}static assertNotInAngularZone(){if(zr.isInAngularZone())throw new Tt(909,!1)}run(e,t,r){return this._inner.run(e,t,r)}runTask(e,t,r,i){const s=this._inner,o=s.scheduleEventTask("NgZoneEvent: "+i,e,fL,hd,hd);try{return s.runTask(o,t,r)}finally{s.cancelTask(o)}}runGuarded(e,t,r){return this._inner.runGuarded(e,t,r)}runOutsideAngular(e){return this._outer.run(e)}}const fL={};function By(n){if(0==n._nesting&&!n.hasPendingMicrotasks&&!n.isStable)try{n._nesting++,n.onMicrotaskEmpty.emit(null)}finally{if(n._nesting--,!n.hasPendingMicrotasks)try{n.runOutsideAngular(()=>n.onStable.emit(null))}finally{n.isStable=!0}}}function Fy(n){n.hasPendingMicrotasks=!!(n._hasPendingMicrotasks||(n.shouldCoalesceEventChangeDetection||n.shouldCoalesceRunChangeDetection)&&-1!==n.lastRequestAnimationFrameId)}function RS(n){n._nesting++,n.isStable&&(n.isStable=!1,n.onUnstable.emit(null))}function PS(n){n._nesting--,By(n)}class pL{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new no,this.onMicrotaskEmpty=new no,this.onStable=new no,this.onError=new no}run(e,t,r){return e.apply(t,r)}runGuarded(e,t,r){return e.apply(t,r)}runOutsideAngular(e){return e()}runTask(e,t,r,i){return e.apply(t,r)}}const NS=new sn(""),gd=new sn("");let Hy,Uy=(()=>{class n{constructor(t,r,i){this._ngZone=t,this.registry=r,this._pendingCount=0,this._isZoneStable=!0,this._didWork=!1,this._callbacks=[],this.taskTrackingZone=null,Hy||(function gL(n){Hy=n}(i),i.addToWindow(r)),this._watchAngularEvents(),t.run(()=>{this.taskTrackingZone=typeof Zone>"u"?null:Zone.current.get("TaskTrackingZone")})}_watchAngularEvents(){this._ngZone.onUnstable.subscribe({next:()=>{this._didWork=!0,this._isZoneStable=!1}}),this._ngZone.runOutsideAngular(()=>{this._ngZone.onStable.subscribe({next:()=>{zr.assertNotInAngularZone(),Ly(()=>{this._isZoneStable=!0,this._runCallbacksIfReady()})}})})}increasePendingRequestCount(){return this._pendingCount+=1,this._didWork=!0,this._pendingCount}decreasePendingRequestCount(){if(this._pendingCount-=1,this._pendingCount<0)throw new Error("pending async requests below zero");return this._runCallbacksIfReady(),this._pendingCount}isStable(){return this._isZoneStable&&0===this._pendingCount&&!this._ngZone.hasPendingMacrotasks}_runCallbacksIfReady(){if(this.isStable())Ly(()=>{for(;0!==this._callbacks.length;){let t=this._callbacks.pop();clearTimeout(t.timeoutId),t.doneCb(this._didWork)}this._didWork=!1});else{let t=this.getPendingTasks();this._callbacks=this._callbacks.filter(r=>!r.updateCb||!r.updateCb(t)||(clearTimeout(r.timeoutId),!1)),this._didWork=!0}}getPendingTasks(){return this.taskTrackingZone?this.taskTrackingZone.macroTasks.map(t=>({source:t.source,creationLocation:t.creationLocation,data:t.data})):[]}addCallback(t,r,i){let s=-1;r&&r>0&&(s=setTimeout(()=>{this._callbacks=this._callbacks.filter(o=>o.timeoutId!==s),t(this._didWork,this.getPendingTasks())},r)),this._callbacks.push({doneCb:t,timeoutId:s,updateCb:i})}whenStable(t,r,i){if(i&&!this.taskTrackingZone)throw new Error('Task tracking zone is required when passing an update callback to whenStable(). Is "zone.js/plugins/task-tracking" loaded?');this.addCallback(t,r,i),this._runCallbacksIfReady()}getPendingRequestCount(){return this._pendingCount}registerApplication(t){this.registry.registerApplication(t,this)}unregisterApplication(t){this.registry.unregisterApplication(t)}findProviders(t,r,i){return[]}}return n.\u0275fac=function(t){return new(t||n)(Rn(zr),Rn(Vy),Rn(gd))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})(),Vy=(()=>{class n{constructor(){this._applications=new Map}registerApplication(t,r){this._applications.set(t,r)}unregisterApplication(t){this._applications.delete(t)}unregisterAllApplications(){this._applications.clear()}getTestability(t){return this._applications.get(t)||null}getAllTestabilities(){return Array.from(this._applications.values())}getAllRootElements(){return Array.from(this._applications.keys())}findTestabilityInTree(t,r=!0){return Hy?.findTestabilityInTree(this,t,r)??null}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})(),Oo=null;const MS=new sn("AllowMultipleToken"),Ky=new sn("PlatformDestroyListeners");function kS(n,e,t=[]){const r=`Platform: ${e}`,i=new sn(r);return(s=[])=>{let o=$y();if(!o||o.injector.get(MS,!1)){const a=[...t,...s,{provide:i,useValue:!0}];n?n(a):function vL(n){if(Oo&&!Oo.get(MS,!1))throw new Tt(400,!1);Oo=n;const e=n.get(BS);(function OS(n){const e=n.get(IS,null);e&&e.forEach(t=>t())})(n)}(function LS(n=[],e){return ma.create({name:e,providers:[{provide:sg,useValue:"platform"},{provide:Ky,useValue:new Set([()=>Oo=null])},...n]})}(a,r))}return function bL(n){const e=$y();if(!e)throw new Tt(401,!1);return e}()}}function $y(){return Oo?.get(BS)??null}let BS=(()=>{class n{constructor(t){this._injector=t,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(t,r){const i=function US(n,e){let t;return t="noop"===n?new pL:("zone.js"===n?void 0:n)||new zr(e),t}(r?.ngZone,function FS(n){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:!(!n||!n.ngZoneEventCoalescing)||!1,shouldCoalesceRunChangeDetection:!(!n||!n.ngZoneRunCoalescing)||!1}}(r)),s=[{provide:zr,useValue:i}];return i.run(()=>{const o=ma.create({providers:s,parent:this.injector,name:t.moduleType.name}),a=t.create(o),u=a.injector.get(lc,null);if(!u)throw new Tt(402,!1);return i.runOutsideAngular(()=>{const _=i.onError.subscribe({next:R=>{u.handleError(R)}});a.onDestroy(()=>{yd(this._modules,a),_.unsubscribe()})}),function VS(n,e,t){try{const r=t();return uy(r)?r.catch(i=>{throw e.runOutsideAngular(()=>n.handleError(i)),i}):r}catch(r){throw e.runOutsideAngular(()=>n.handleError(r)),r}}(u,i,()=>{const _=a.injector.get(pd);return _.runInitializers(),_.donePromise.then(()=>(function pD(n){Ci(n,"Expected localeId to be defined"),"string"==typeof n&&(hD=n.toLowerCase().replace(/_/g,"-"))}(a.injector.get(io,Ac)||Ac),this._moduleDoBootstrap(a),a))})})}bootstrapModule(t,r=[]){const i=HS({},r);return function yL(n,e,t){const r=new wy(t);return Promise.resolve(r)}(0,0,t).then(s=>this.bootstrapModuleFactory(s,i))}_moduleDoBootstrap(t){const r=t.injector.get(jy);if(t._bootstrapComponents.length>0)t._bootstrapComponents.forEach(i=>r.bootstrap(i));else{if(!t.instance.ngDoBootstrap)throw new Tt(403,!1);t.instance.ngDoBootstrap(r)}this._modules.push(t)}onDestroy(t){this._destroyListeners.push(t)}get injector(){return this._injector}destroy(){if(this._destroyed)throw new Tt(404,!1);this._modules.slice().forEach(r=>r.destroy()),this._destroyListeners.forEach(r=>r());const t=this._injector.get(Ky,null);t&&(t.forEach(r=>r()),t.clear()),this._destroyed=!0}get destroyed(){return this._destroyed}}return n.\u0275fac=function(t){return new(t||n)(Rn(ma))},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})();function HS(n,e){return Array.isArray(e)?e.reduce(HS,n):{...n,...e}}let jy=(()=>{class n{constructor(t,r,i){this._zone=t,this._injector=r,this._exceptionHandler=i,this._bootstrapListeners=[],this._views=[],this._runningTick=!1,this._stable=!0,this._destroyed=!1,this._destroyListeners=[],this.componentTypes=[],this.components=[],this._onMicrotaskEmptySubscription=this._zone.onMicrotaskEmpty.subscribe({next:()=>{this._zone.run(()=>{this.tick()})}});const s=new Xe(a=>{this._stable=this._zone.isStable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks,this._zone.runOutsideAngular(()=>{a.next(this._stable),a.complete()})}),o=new Xe(a=>{let u;this._zone.runOutsideAngular(()=>{u=this._zone.onStable.subscribe(()=>{zr.assertNotInAngularZone(),Ly(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,a.next(!0))})})});const _=this._zone.onUnstable.subscribe(()=>{zr.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{a.next(!1)}))});return()=>{u.unsubscribe(),_.unsubscribe()}});this.isStable=ei(s,o.pipe(function ns(n={}){const{connector:e=(()=>new gr),resetOnError:t=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=n;return s=>{let o,a,u,_=0,R=!1,N=!1;const B=()=>{a?.unsubscribe(),a=void 0},K=()=>{B(),o=u=void 0,R=N=!1},Z=()=>{const J=o;K(),J?.unsubscribe()};return fe((J,oe)=>{_++,!N&&!R&&B();const he=u=u??e();oe.add(()=>{_--,0===_&&!N&&!R&&(a=Io(Z,i))}),he.subscribe(oe),!o&&_>0&&(o=new be({next:Ie=>he.next(Ie),error:Ie=>{N=!0,B(),a=Io(K,t,Ie),he.error(Ie)},complete:()=>{R=!0,B(),a=Io(K,r),he.complete()}}),gn(J).subscribe(o))})(s)}}()))}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(t,r){const i=t instanceof Mw;if(!this._injector.get(pd).done)throw!i&&function _u(n){const e=Pn(n)||ni(n)||ri(n);return null!==e&&e.standalone}(t),new Tt(405,false);let o;o=i?t:this._injector.get(Kf).resolveComponentFactory(t),this.componentTypes.push(o.componentType);const a=function mL(n){return n.isBoundToModule}(o)?void 0:this._injector.get(xc),_=o.create(ma.NULL,[],r||o.selector,a),R=_.location.nativeElement,N=_.injector.get(NS,null);return N?.registerApplication(R),_.onDestroy(()=>{this.detachView(_.hostView),yd(this.components,_),N?.unregisterApplication(R)}),this._loadComponent(_),_}tick(){if(this._runningTick)throw new Tt(101,!1);try{this._runningTick=!0;for(let t of this._views)t.detectChanges()}catch(t){this._zone.runOutsideAngular(()=>this._exceptionHandler.handleError(t))}finally{this._runningTick=!1}}attachView(t){const r=t;this._views.push(r),r.attachToAppRef(this)}detachView(t){const r=t;yd(this._views,r),r.detachFromAppRef()}_loadComponent(t){this.attachView(t.hostView),this.tick(),this.components.push(t),this._injector.get(rL,[]).concat(this._bootstrapListeners).forEach(i=>i(t))}ngOnDestroy(){if(!this._destroyed)try{this._destroyListeners.forEach(t=>t()),this._views.slice().forEach(t=>t.destroy()),this._onMicrotaskEmptySubscription.unsubscribe()}finally{this._destroyed=!0,this._views=[],this._bootstrapListeners=[],this._destroyListeners=[]}}onDestroy(t){return this._destroyListeners.push(t),()=>yd(this._destroyListeners,t)}destroy(){if(this._destroyed)throw new Tt(406,!1);const t=this._injector;t.destroy&&!t.destroyed&&t.destroy()}get viewCount(){return this._views.length}warnIfDestroyed(){}}return n.\u0275fac=function(t){return new(t||n)(Rn(zr),Rn(oc),Rn(lc))},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function yd(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}let $S=!0;class qS{constructor(){}supports(e){return Yu(e)}create(e){return new PL(e)}}const RL=(n,e)=>e;class PL{constructor(e){this.length=0,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=e||RL}forEachItem(e){let t;for(t=this._itHead;null!==t;t=t._next)e(t)}forEachOperation(e){let t=this._itHead,r=this._removalsHead,i=0,s=null;for(;t||r;){const o=!r||t&&t.currentIndex{o=this._trackByFn(i,a),null!==t&&Object.is(t.trackById,o)?(r&&(t=this._verifyReinsertion(t,a,o,i)),Object.is(t.item,a)||this._addIdentityChange(t,a)):(t=this._mismatch(t,a,o,i),r=!0),t=t._next,i++}),this.length=i;return this._truncate(t),this.collection=e,this.isDirty}get isDirty(){return null!==this._additionsHead||null!==this._movesHead||null!==this._removalsHead||null!==this._identityChangesHead}_reset(){if(this.isDirty){let e;for(e=this._previousItHead=this._itHead;null!==e;e=e._next)e._nextPrevious=e._next;for(e=this._additionsHead;null!==e;e=e._nextAdded)e.previousIndex=e.currentIndex;for(this._additionsHead=this._additionsTail=null,e=this._movesHead;null!==e;e=e._nextMoved)e.previousIndex=e.currentIndex;this._movesHead=this._movesTail=null,this._removalsHead=this._removalsTail=null,this._identityChangesHead=this._identityChangesTail=null}}_mismatch(e,t,r,i){let s;return null===e?s=this._itTail:(s=e._prev,this._remove(e)),null!==(e=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._reinsertAfter(e,s,i)):null!==(e=null===this._linkedRecords?null:this._linkedRecords.get(r,i))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._moveAfter(e,s,i)):e=this._addAfter(new NL(t,r),s,i),e}_verifyReinsertion(e,t,r,i){let s=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null);return null!==s?e=this._reinsertAfter(s,e._prev,i):e.currentIndex!=i&&(e.currentIndex=i,this._addToMoves(e,i)),e}_truncate(e){for(;null!==e;){const t=e._next;this._addToRemovals(this._unlink(e)),e=t}null!==this._unlinkedRecords&&this._unlinkedRecords.clear(),null!==this._additionsTail&&(this._additionsTail._nextAdded=null),null!==this._movesTail&&(this._movesTail._nextMoved=null),null!==this._itTail&&(this._itTail._next=null),null!==this._removalsTail&&(this._removalsTail._nextRemoved=null),null!==this._identityChangesTail&&(this._identityChangesTail._nextIdentityChange=null)}_reinsertAfter(e,t,r){null!==this._unlinkedRecords&&this._unlinkedRecords.remove(e);const i=e._prevRemoved,s=e._nextRemoved;return null===i?this._removalsHead=s:i._nextRemoved=s,null===s?this._removalsTail=i:s._prevRemoved=i,this._insertAfter(e,t,r),this._addToMoves(e,r),e}_moveAfter(e,t,r){return this._unlink(e),this._insertAfter(e,t,r),this._addToMoves(e,r),e}_addAfter(e,t,r){return this._insertAfter(e,t,r),this._additionsTail=null===this._additionsTail?this._additionsHead=e:this._additionsTail._nextAdded=e,e}_insertAfter(e,t,r){const i=null===t?this._itHead:t._next;return e._next=i,e._prev=t,null===i?this._itTail=e:i._prev=e,null===t?this._itHead=e:t._next=e,null===this._linkedRecords&&(this._linkedRecords=new YS),this._linkedRecords.put(e),e.currentIndex=r,e}_remove(e){return this._addToRemovals(this._unlink(e))}_unlink(e){null!==this._linkedRecords&&this._linkedRecords.remove(e);const t=e._prev,r=e._next;return null===t?this._itHead=r:t._next=r,null===r?this._itTail=t:r._prev=t,e}_addToMoves(e,t){return e.previousIndex===t||(this._movesTail=null===this._movesTail?this._movesHead=e:this._movesTail._nextMoved=e),e}_addToRemovals(e){return null===this._unlinkedRecords&&(this._unlinkedRecords=new YS),this._unlinkedRecords.put(e),e.currentIndex=null,e._nextRemoved=null,null===this._removalsTail?(this._removalsTail=this._removalsHead=e,e._prevRemoved=null):(e._prevRemoved=this._removalsTail,this._removalsTail=this._removalsTail._nextRemoved=e),e}_addIdentityChange(e,t){return e.item=t,this._identityChangesTail=null===this._identityChangesTail?this._identityChangesHead=e:this._identityChangesTail._nextIdentityChange=e,e}}class NL{constructor(e,t){this.item=e,this.trackById=t,this.currentIndex=null,this.previousIndex=null,this._nextPrevious=null,this._prev=null,this._next=null,this._prevDup=null,this._nextDup=null,this._prevRemoved=null,this._nextRemoved=null,this._nextAdded=null,this._nextMoved=null,this._nextIdentityChange=null}}class ML{constructor(){this._head=null,this._tail=null}add(e){null===this._head?(this._head=this._tail=e,e._nextDup=null,e._prevDup=null):(this._tail._nextDup=e,e._prevDup=this._tail,e._nextDup=null,this._tail=e)}get(e,t){let r;for(r=this._head;null!==r;r=r._nextDup)if((null===t||t<=r.currentIndex)&&Object.is(r.trackById,e))return r;return null}remove(e){const t=e._prevDup,r=e._nextDup;return null===t?this._head=r:t._nextDup=r,null===r?this._tail=t:r._prevDup=t,null===this._head}}class YS{constructor(){this.map=new Map}put(e){const t=e.trackById;let r=this.map.get(t);r||(r=new ML,this.map.set(t,r)),r.add(e)}get(e,t){const i=this.map.get(e);return i?i.get(e,t):null}remove(e){const t=e.trackById;return this.map.get(t).remove(e)&&this.map.delete(t),e}get isEmpty(){return 0===this.map.size}clear(){this.map.clear()}}function QS(n,e,t){const r=n.previousIndex;if(null===r)return r;let i=0;return t&&r{class n{constructor(t){this.factories=t}static create(t,r){if(null!=r){const i=r.factories.slice();t=t.concat(i)}return new n(t)}static extend(t){return{provide:n,useFactory:r=>n.create(t,r||XS()),deps:[[n,new Of,new Mf]]}}find(t){const r=this.factories.find(i=>i.supports(t));if(null!=r)return r;throw new Tt(901,!1)}}return n.\u0275prov=zn({token:n,providedIn:"root",factory:XS}),n})();const FL=kS(null,"core",[]);let UL=(()=>{class n{constructor(t){}}return n.\u0275fac=function(t){return new(t||n)(Rn(jy))},n.\u0275mod=wu({type:n}),n.\u0275inj=Ka({}),n})(),bd=null;function cl(){return bd}const oo=new sn("DocumentToken");class R8{constructor(e,t,r,i){this.$implicit=e,this.ngForOf=t,this.index=r,this.count=i}get first(){return 0===this.index}get last(){return this.index===this.count-1}get even(){return this.index%2==0}get odd(){return!this.even}}let fC=(()=>{class n{constructor(t,r,i){this._viewContainer=t,this._template=r,this._differs=i,this._ngForOf=null,this._ngForOfDirty=!0,this._differ=null}set ngForOf(t){this._ngForOf=t,this._ngForOfDirty=!0}set ngForTrackBy(t){this._trackByFn=t}get ngForTrackBy(){return this._trackByFn}set ngForTemplate(t){t&&(this._template=t)}ngDoCheck(){if(this._ngForOfDirty){this._ngForOfDirty=!1;const t=this._ngForOf;!this._differ&&t&&(this._differ=this._differs.find(t).create(this.ngForTrackBy))}if(this._differ){const t=this._differ.diff(this._ngForOf);t&&this._applyChanges(t)}}_applyChanges(t){const r=this._viewContainer;t.forEachOperation((i,s,o)=>{if(null==i.previousIndex)r.createEmbeddedView(this._template,new R8(i.item,this._ngForOf,-1,-1),null===o?void 0:o);else if(null==o)r.remove(null===s?void 0:s);else if(null!==s){const a=r.get(s);r.move(a,o),dC(a,i)}});for(let i=0,s=r.length;i{dC(r.get(i.currentIndex),i)})}static ngTemplateContextGuard(t,r){return!0}}return n.\u0275fac=function(t){return new(t||n)(Zt(Ms),Zt(ro),Zt(Ed))},n.\u0275dir=Fi({type:n,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"},standalone:!0}),n})();function dC(n,e){n.context.$implicit=e.item}let o4=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=wu({type:n}),n.\u0275inj=Ka({}),n})();class f0 extends class R4 extends class KL{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function HL(n){bd||(bd=n)}(new f0)}onAndCancel(e,t,r){return e.addEventListener(t,r,!1),()=>{e.removeEventListener(t,r,!1)}}dispatchEvent(e,t){e.dispatchEvent(t)}remove(e){e.parentNode&&e.parentNode.removeChild(e)}createElement(e,t){return(t=t||this.getDefaultDocument()).createElement(e)}createHtmlDocument(){return document.implementation.createHTMLDocument("fakeTitle")}getDefaultDocument(){return document}isElementNode(e){return e.nodeType===Node.ELEMENT_NODE}isShadowRoot(e){return e instanceof DocumentFragment}getGlobalEventTarget(e,t){return"window"===t?window:"document"===t?e:"body"===t?e.body:null}getBaseHref(e){const t=function P4(){return dl=dl||document.querySelector("base"),dl?dl.getAttribute("href"):null}();return null==t?null:function N4(n){Pd=Pd||document.createElement("a"),Pd.setAttribute("href",n);const e=Pd.pathname;return"/"===e.charAt(0)?e:`/${e}`}(t)}resetBaseElement(){dl=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return function T8(n,e){e=encodeURIComponent(e);for(const t of n.split(";")){const r=t.indexOf("="),[i,s]=-1==r?[t,""]:[t.slice(0,r),t.slice(r+1)];if(i.trim()===e)return decodeURIComponent(s)}return null}(document.cookie,e)}}let Pd,dl=null;const wC=new sn("TRANSITION_ID"),O4=[{provide:SS,useFactory:function M4(n,e,t){return()=>{t.get(pd).donePromise.then(()=>{const r=cl(),i=e.querySelectorAll(`style[ng-transition="${n}"]`);for(let s=0;s{class n{build(){return new XMLHttpRequest}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();const Nd=new sn("EventManagerPlugins");let Md=(()=>{class n{constructor(t,r){this._zone=r,this._eventNameToPlugin=new Map,t.forEach(i=>i.manager=this),this._plugins=t.slice().reverse()}addEventListener(t,r,i){return this._findPluginFor(r).addEventListener(t,r,i)}addGlobalEventListener(t,r,i){return this._findPluginFor(r).addGlobalEventListener(t,r,i)}getZone(){return this._zone}_findPluginFor(t){const r=this._eventNameToPlugin.get(t);if(r)return r;const i=this._plugins;for(let s=0;s{class n{constructor(){this._stylesSet=new Set}addStyles(t){const r=new Set;t.forEach(i=>{this._stylesSet.has(i)||(this._stylesSet.add(i),r.add(i))}),this.onStylesAdded(r)}onStylesAdded(t){}getAllStyles(){return Array.from(this._stylesSet)}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})(),hl=(()=>{class n extends DC{constructor(t){super(),this._doc=t,this._hostNodes=new Map,this._hostNodes.set(t.head,[])}_addStylesToHost(t,r,i){t.forEach(s=>{const o=this._doc.createElement("style");o.textContent=s,i.push(r.appendChild(o))})}addHost(t){const r=[];this._addStylesToHost(this._stylesSet,t,r),this._hostNodes.set(t,r)}removeHost(t){const r=this._hostNodes.get(t);r&&r.forEach(SC),this._hostNodes.delete(t)}onStylesAdded(t){this._hostNodes.forEach((r,i)=>{this._addStylesToHost(t,i,r)})}ngOnDestroy(){this._hostNodes.forEach(t=>t.forEach(SC))}}return n.\u0275fac=function(t){return new(t||n)(Rn(oo))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();function SC(n){cl().remove(n)}const d0={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",math:"http://www.w3.org/1998/MathML/"},h0=/%COMP%/g;function Od(n,e,t){for(let r=0;r{if("__ngUnwrap__"===e)return n;!1===n(e)&&(e.preventDefault(),e.returnValue=!1)}}let p0=(()=>{class n{constructor(t,r,i){this.eventManager=t,this.sharedStylesHost=r,this.appId=i,this.rendererByCompId=new Map,this.defaultRenderer=new g0(t)}createRenderer(t,r){if(!t||!r)return this.defaultRenderer;switch(r.encapsulation){case Is.Emulated:{let i=this.rendererByCompId.get(r.id);return i||(i=new K4(this.eventManager,this.sharedStylesHost,r,this.appId),this.rendererByCompId.set(r.id,i)),i.applyToHost(t),i}case 1:case Is.ShadowDom:return new $4(this.eventManager,this.sharedStylesHost,t,r);default:if(!this.rendererByCompId.has(r.id)){const i=Od(r.id,r.styles,[]);this.sharedStylesHost.addStyles(i),this.rendererByCompId.set(r.id,this.defaultRenderer)}return this.defaultRenderer}}begin(){}end(){}}return n.\u0275fac=function(t){return new(t||n)(Rn(Md),Rn(hl),Rn(ol))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();class g0{constructor(e){this.eventManager=e,this.data=Object.create(null),this.destroyNode=null}destroy(){}createElement(e,t){return t?document.createElementNS(d0[t]||t,e):document.createElement(e)}createComment(e){return document.createComment(e)}createText(e){return document.createTextNode(e)}appendChild(e,t){(xC(e)?e.content:e).appendChild(t)}insertBefore(e,t,r){e&&(xC(e)?e.content:e).insertBefore(t,r)}removeChild(e,t){e&&e.removeChild(t)}selectRootElement(e,t){let r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error(`The selector "${e}" did not match any elements`);return t||(r.textContent=""),r}parentNode(e){return e.parentNode}nextSibling(e){return e.nextSibling}setAttribute(e,t,r,i){if(i){t=i+":"+t;const s=d0[i];s?e.setAttributeNS(s,t,r):e.setAttribute(t,r)}else e.setAttribute(t,r)}removeAttribute(e,t,r){if(r){const i=d0[r];i?e.removeAttributeNS(i,t):e.removeAttribute(`${r}:${t}`)}else e.removeAttribute(t)}addClass(e,t){e.classList.add(t)}removeClass(e,t){e.classList.remove(t)}setStyle(e,t,r,i){i&(gi.DashCase|gi.Important)?e.style.setProperty(t,r,i&gi.Important?"important":""):e.style[t]=r}removeStyle(e,t,r){r&gi.DashCase?e.style.removeProperty(t):e.style[t]=""}setProperty(e,t,r){e[t]=r}setValue(e,t){e.nodeValue=t}listen(e,t,r){return"string"==typeof e?this.eventManager.addGlobalEventListener(e,t,TC(r)):this.eventManager.addEventListener(e,t,TC(r))}}function xC(n){return"TEMPLATE"===n.tagName&&void 0!==n.content}class K4 extends g0{constructor(e,t,r,i){super(e),this.component=r;const s=Od(i+"-"+r.id,r.styles,[]);t.addStyles(s),this.contentAttr=function U4(n){return"_ngcontent-%COMP%".replace(h0,n)}(i+"-"+r.id),this.hostAttr=function V4(n){return"_nghost-%COMP%".replace(h0,n)}(i+"-"+r.id)}applyToHost(e){super.setAttribute(e,this.hostAttr,"")}createElement(e,t){const r=super.createElement(e,t);return super.setAttribute(r,this.contentAttr,""),r}}class $4 extends g0{constructor(e,t,r,i){super(e),this.sharedStylesHost=t,this.hostEl=r,this.shadowRoot=r.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);const s=Od(i.id,i.styles,[]);for(let o=0;o{class n extends _C{constructor(t){super(t)}supports(t){return!0}addEventListener(t,r,i){return t.addEventListener(r,i,!1),()=>this.removeEventListener(t,r,i)}removeEventListener(t,r,i){return t.removeEventListener(r,i)}}return n.\u0275fac=function(t){return new(t||n)(Rn(oo))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();const RC=["alt","control","meta","shift"],G4={"\b":"Backspace","\t":"Tab","\x7f":"Delete","\x1b":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},z4={alt:n=>n.altKey,control:n=>n.ctrlKey,meta:n=>n.metaKey,shift:n=>n.shiftKey};let W4=(()=>{class n extends _C{constructor(t){super(t)}supports(t){return null!=n.parseEventName(t)}addEventListener(t,r,i){const s=n.parseEventName(r),o=n.eventCallback(s.fullKey,i,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>cl().onAndCancel(t,s.domEventName,o))}static parseEventName(t){const r=t.toLowerCase().split("."),i=r.shift();if(0===r.length||"keydown"!==i&&"keyup"!==i)return null;const s=n._normalizeKey(r.pop());let o="",a=r.indexOf("code");if(a>-1&&(r.splice(a,1),o="code."),RC.forEach(_=>{const R=r.indexOf(_);R>-1&&(r.splice(R,1),o+=_+".")}),o+=s,0!=r.length||0===s.length)return null;const u={};return u.domEventName=i,u.fullKey=o,u}static matchEventFullKeyCode(t,r){let i=G4[t.key]||t.key,s="";return r.indexOf("code.")>-1&&(i=t.code,s="code."),!(null==i||!i)&&(i=i.toLowerCase()," "===i?i="space":"."===i&&(i="dot"),RC.forEach(o=>{o!==i&&(0,z4[o])(t)&&(s+=o+".")}),s+=i,s===r)}static eventCallback(t,r,i){return s=>{n.matchEventFullKeyCode(s,t)&&i.runGuarded(()=>r(s))}}static _normalizeKey(t){return"esc"===t?"escape":t}}return n.\u0275fac=function(t){return new(t||n)(Rn(oo))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();const NC=[{provide:TS,useValue:"browser"},{provide:IS,useValue:function q4(){f0.makeCurrent()},multi:!0},{provide:oo,useFactory:function Q4(){return function FR(n){Qp=n}(document),document},deps:[]}],Z4=kS(FL,"browser",NC),MC=new sn(""),OC=[{provide:gd,useClass:class k4{addToWindow(e){Fn.getAngularTestability=(r,i=!0)=>{const s=e.findTestabilityInTree(r,i);if(null==s)throw new Error("Could not find testability for element.");return s},Fn.getAllAngularTestabilities=()=>e.getAllTestabilities(),Fn.getAllAngularRootElements=()=>e.getAllRootElements(),Fn.frameworkStabilizers||(Fn.frameworkStabilizers=[]),Fn.frameworkStabilizers.push(r=>{const i=Fn.getAllAngularTestabilities();let s=i.length,o=!1;const a=function(u){o=o||u,s--,0==s&&r(o)};i.forEach(function(u){u.whenStable(a)})})}findTestabilityInTree(e,t,r){return null==t?null:e.getTestability(t)??(r?cl().isShadowRoot(t)?this.findTestabilityInTree(e,t.host,!0):this.findTestabilityInTree(e,t.parentElement,!0):null)}},deps:[]},{provide:NS,useClass:Uy,deps:[zr,Vy,gd]},{provide:Uy,useClass:Uy,deps:[zr,Vy,gd]}],kC=[{provide:sg,useValue:"root"},{provide:lc,useFactory:function Y4(){return new lc},deps:[]},{provide:Nd,useClass:j4,multi:!0,deps:[oo,zr,TS]},{provide:Nd,useClass:W4,multi:!0,deps:[oo]},{provide:p0,useClass:p0,deps:[Md,hl,ol]},{provide:kw,useExisting:p0},{provide:DC,useExisting:hl},{provide:hl,useClass:hl,deps:[oo]},{provide:Md,useClass:Md,deps:[Nd,zr]},{provide:class f4{},useClass:L4,deps:[]},[]];let X4=(()=>{class n{constructor(t){}static withServerTransition(t){return{ngModule:n,providers:[{provide:ol,useValue:t.appId},{provide:wC,useExisting:ol},O4]}}}return n.\u0275fac=function(t){return new(t||n)(Rn(MC,12))},n.\u0275mod=wu({type:n}),n.\u0275inj=Ka({providers:[...kC,...OC],imports:[o4,UL]}),n})();typeof window<"u"&&window;class cB extends gr{constructor(e){super(),this._value=e}get value(){return this.getValue()}_subscribe(e){const t=super._subscribe(e);return!t.closed&&e.next(this._value),t}getValue(){const{hasError:e,thrownError:t,_value:r}=this;if(e)throw t;return this._throwIfClosed(),r}next(e){super.next(this._value=e)}}function FC(n,e,t,r,i,s,o){try{var a=n[s](o),u=a.value}catch(_){return void t(_)}a.done?e(u):Promise.resolve(u).then(r,i)}function j(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(u){FC(s,r,i,o,a,"next",u)}function a(u){FC(s,r,i,o,a,"throw",u)}o(void 0)})}}var uB=x(5705),v0=x(5006),UC=x(893),VC=x(5876);const lB={hashSHA256:n=>(0,UC.vp)(n),getHKDF(n,e){const i=new uB.t(UC.mE,e,n).expand(96);return[i.subarray(0,32),i.subarray(32,64),i.subarray(64,96)]},generateX25519KeyPair(){const n=v0.Au();return{publicKey:n.publicKey,privateKey:n.secretKey}},generateX25519KeyPairFromSeed(n){const e=v0._w(n);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey:(n,e)=>v0.gi(n,e),chaCha20Poly1305Encrypt:(n,e,t,r)=>new VC.OK(r).seal(e,n,t),chaCha20Poly1305Decrypt:(n,e,t,r)=>new VC.OK(r).open(e,n,t)};function HC(n){this.wrapped=n}function pl(n){var e,t;function i(o,a){try{var u=n[o](a),_=u.value,R=_ instanceof HC;Promise.resolve(R?_.wrapped:_).then(function(N){R?i("return"===o?"return":"next",N):s(u.done?"return":"normal",N)},function(N){i("throw",N)})}catch(N){s("throw",N)}}function s(o,a){switch(o){case"return":e.resolve({value:a,done:!0});break;case"throw":e.reject(a);break;default:e.resolve({value:a,done:!1})}(e=e.next)?i(e.key,e.arg):t=null}this._invoke=function r(o,a){return new Promise(function(u,_){var R={key:o,arg:a,resolve:u,reject:_,next:null};t?t=t.next=R:(e=t=R,i(o,a))})},"function"!=typeof n.return&&(this.return=void 0)}function dn(n){return function(){return new pl(n.apply(this,arguments))}}function lt(n){return new HC(n)}function Pt(n){var e,t,r,i=2;for(typeof Symbol<"u"&&(t=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(t&&null!=(e=n[t]))return e.call(n);if(r&&null!=(e=n[r]))return new kd(e.call(n));t="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function kd(n){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var r=t.done;return Promise.resolve(t.value).then(function(i){return{value:i,done:r}})}return(kd=function(r){this.s=r,this.n=r.next}).prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var i=this.s.return;return void 0===i?Promise.resolve({value:r,done:!0}):e(i.apply(this.s,arguments))},throw:function(r){var i=this.s.return;return void 0===i?Promise.reject(r):e(i.apply(this.s,arguments))}},new kd(n)}function Mr(n,e){var t={},r=!1;function i(s,o){return r=!0,o=new Promise(function(a){a(n[s](o))}),{done:!1,value:e(o)}}return t[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},t.next=function(s){return r?(r=!1,s):i("next",s)},"function"==typeof n.throw&&(t.throw=function(s){if(r)throw r=!1,s;return i("throw",s)}),"function"==typeof n.return&&(t.return=function(s){return r?(r=!1,s):i("return",s)}),t}function Lo(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.alloc?globalThis.Buffer.alloc(n):new Uint8Array(n)}function Nc(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}function wr(n,e){e||(e=n.reduce((i,s)=>i+s.length,0));const t=Nc(e);let r=0;for(const i of n)t.set(i,r),r+=i.length;return t}function kr(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(const r of e)if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.push(r);else{if(!E0(r))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.push(...r.bufs)}this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(const r of e.reverse())if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.unshift(r);else{if(!E0(r))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.unshift(...r.bufs)}this.length+=t}get(e){const t=$C(this.bufs,e);return t.buf[t.index]}set(e,t){const r=$C(this.bufs,e);r.buf[r.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let r=0;r0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}slice(e,t){const{bufs:r,length:i}=this._subList(e,t);return wr(r,i)}subarray(e,t){const{bufs:r,length:i}=this._subList(e,t);return 1===r.length?r[0]:wr(r,i)}sublist(e,t){const{bufs:r,length:i}=this._subList(e,t),s=new qr;return s.length=i,s.bufs=r,s}_subList(e,t){if((e=e??0)<0&&(e=this.length+e),(t=t??this.length)<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:[...this.bufs],length:this.length};const r=[];let i=0;for(let s=0;s=u)continue;const _=e>=a&&ea&&t<=u;if(_&&R){if(e===a&&t===u){r.push(o);break}const N=e-a;r.push(o.subarray(N,N+(t-e)));break}if(_){if(0===e){r.push(o);continue}r.push(o.subarray(e-a))}else{if(R){if(t===u){r.push(o);break}r.push(o.subarray(0,t-a));break}r.push(o)}}return{bufs:r,length:t-e}}getInt8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=Nc(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){const i=Lo(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,r),this.write(i,e)}getInt32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,r),this.write(i,e)}getBigInt64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,r),this.write(i,e)}getUint8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){const r=Nc(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){const i=Lo(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,r),this.write(i,e)}getUint32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,r),this.write(i,e)}getBigUint64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,r),this.write(i,e)}getFloat32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,r),this.write(i,e)}getFloat64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,r),this.write(i,e)}equals(e){if(null==e||!(e instanceof qr)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;ti+s.byteLength,0)),r.length=t,r}}class jC{constructor(e){if(!(e>0)||0!=(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class b0{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new jC(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=e?.byteLength?e.byteLength:1}push(e){null!=e?.value&&(this.size+=this.calculateSize(e.value)),this.head.push(e)||(this.head=this.head.next=new jC(2*this.head.buffer.length),this.head.push(e))}shift(){let e=this.tail.shift();if(void 0===e&&null!=this.tail.next){const t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return null!=e?.value&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}}function Mc(n={}){return GC(t=>{const r=t.shift();if(null==r)return{done:!0};if(null!=r.error)throw r.error;return{done:!0===r.done,value:r.value}},n)}function GC(n,e){let i,s,o,t=(e=e??{}).onEnd,r=new b0;const a=function(){var J=j(function*(){return r.isEmpty()?o?{done:!0}:yield new Promise((oe,he)=>{s=Ie=>{s=null,r.push(Ie);try{oe(n(r))}catch(ue){he(ue)}return i}}):n(r)});return function(){return J.apply(this,arguments)}}(),u=J=>null!=s?s(J):(r.push(J),i),R=J=>{if(o)return i;if(!0!==e?.objectMode&&null==J?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:J})},N=J=>o?i:(o=!0,null!=J?(J=>(r=new b0,null!=s?s({error:J}):(r.push({error:J}),i)))(J):u({done:!0}));if(i={[Symbol.asyncIterator](){return this},next:a,return:()=>(r=new b0,N(),{done:!0}),throw:J=>(N(J),{done:!0}),push:R,end:N,get readableLength(){return r.size}},null==t)return i;const Z=i;return i={[Symbol.asyncIterator](){return this},next:()=>Z.next(),throw:J=>(Z.throw(J),null!=t&&(t(J),t=void 0),{done:!0}),return:()=>(Z.return(),null!=t&&(t(),t=void 0),{done:!0}),push:R,end:J=>(Z.end(J),null!=t&&(t(J),t=void 0),i),get readableLength(){return Z.readableLength}},i}function w0(){const n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}function Ld(n){const e=Mc(),t=function fB(n){const e=dn(function*(){let t=yield,r=new qr;var o,i=!1,s=!1;try{for(var u,a=Pt(n);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;if(null!=t)for(r.append(_);r.length>=t;){const R=r.sublist(0,t);if(r.consume(t),t=yield R,null==t){r.length>0&&(t=yield r,r=new qr);break}}else r.append(_),t=yield r,r=new qr}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}if(null!=t)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:r})})();return e.next(),e}(n.source),r=w0();let i;const s=n.sink(dn(function*(){yield*Mr(Pt(e),lt);const a=yield lt(r.promise);yield*Mr(Pt(a),lt)})());s.catch(a=>{i=a});const o={sink:(a=j(function*(u){return null!=i?yield Promise.reject(i):(r.resolve(u),yield s)}),function(_){return a.apply(this,arguments)}),source:t};var a;return{reader:t,writer:e,stream:o,rest:()=>e.end(),write:e.push,read:function(){var a=j(function*(){const u=yield t.next();if(null!=u.value)return u.value});return function(){return a.apply(this,arguments)}}()}}function zC(n){return n instanceof Uint8Array?{get:e=>n[e],set(e,t){n[e]=t}}:{get:e=>n.get(e),set(e,t){n.set(e,t)}}}const WC=4294967296;class Gi{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(!0===e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!=0){const t=1+~this.lo>>>0;let r=~this.hi>>>0;return 0===t&&(r=r+1>>>0),-(BigInt(t)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){const e=-(1&this.lo);return new Gi((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new Gi(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=zC(e);for(;this.hi>0;)r.set(t++,127&this.lo|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)r.set(t++,127&this.lo|128),this.lo=this.lo>>>7;r.set(t++,this.lo)}static fromBigInt(e){if(0n===e)return new Gi;const t=e<0;t&&(e=-e);let r=0|Number(e>>32n),i=0|Number(e-(BigInt(r)<<32n));return t&&(r=~r>>>0,i=~i>>>0,++i>WC&&(i=0,++r>WC&&(r=0))),new Gi(r,i)}static fromNumber(e){if(0===e)return new Gi;const t=e<0;t&&(e=-e);let r=e>>>0,i=(e-r)/4294967296>>>0;return t&&(i=~i>>>0,r=~r>>>0,++r>4294967295&&(r=0,++i>4294967295&&(i=0))),new Gi(i,r)}static fromBytes(e,t=0){const r=zC(e),i=new Gi;let s=0;if(e.length-t>4){for(;s<4;++s)if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i;if(i.lo=(i.lo|(127&r.get(t))<<28)>>>0,i.hi=(i.hi|(127&r.get(t))>>4)>>>0,r.get(t++)<128)return i;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i}if(e.length-t>4){for(;s<5;++s)if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}else if(t=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}throw RangeError("invalid varint encoding")}}const hB=Math.pow(2,7),pB=Math.pow(2,14),gB=Math.pow(2,21),yB=Math.pow(2,28),mB=Math.pow(2,35),vB=Math.pow(2,42),EB=Math.pow(2,49),bB=Math.pow(2,56),wB=Math.pow(2,63),Ni={encodingLength:n=>nNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return null==e&&(e=Nc(Ni.encodingLength(n))),Gi.fromNumber(n).toBytes(e,t),e},decode:(n,e=0)=>Gi.fromBytes(n,e).toNumber(!0)},Bd=n=>{const e=Ni.encodingLength(n),t=function DB(n){return null!=globalThis?.Buffer?.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}(e);return Ni.encode(n,t),Bd.bytes=e,t};function Os(n){const e=(n=n??{}).lengthEncoder??Bd;return function(){var r=dn(function*(i){var a,s=!1,o=!1;try{for(var _,u=Pt(i);s=!(_=yield lt(u.next())).done;s=!1){const R=_.value,N=e(R.byteLength);N instanceof Uint8Array?yield N:yield*Mr(Pt(N),lt),R instanceof Uint8Array?yield R:yield*Mr(Pt(R),lt)}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield lt(u.return()))}finally{if(o)throw a}}});return function(s){return r.apply(this,arguments)}}()}Bd.bytes=0,Os.single=(n,e)=>new qr(((e=e??{}).lengthEncoder??Bd)(n.byteLength),n);var ae=x(2535),Bo=(()=>{return(n=Bo||(Bo={}))[n.LENGTH=0]="LENGTH",n[n.DATA=1]="DATA",Bo;var n})();const _0=n=>{const e=Ni.decode(n);return _0.bytes=Ni.encodingLength(e),e};function ps(n){return function(){var t=dn(function*(r){const i=new qr;let s=Bo.LENGTH,o=-1;const a=n?.lengthDecoder??_0,u=n?.maxLengthLength??8,_=n?.maxDataLength??4194304;var B,R=!1,N=!1;try{for(var Z,K=Pt(r);R=!(Z=yield lt(K.next())).done;R=!1)for(i.append(Z.value);i.byteLength>0;){if(s===Bo.LENGTH)try{if(o=a(i),o<0)throw ae(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>_)throw ae(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");i.consume(a.bytes),null!=n?.onLength&&n.onLength(o),s=Bo.DATA}catch(oe){if(oe instanceof RangeError){if(i.byteLength>u)throw ae(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw oe}if(s===Bo.DATA){if(i.byteLength0)throw ae(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")});return function(i){return t.apply(this,arguments)}}()}function qC(n,e={}){const t=Ld(n),r=ps.fromReader(t.reader,e),i={read:(s=j(function*(o){const{value:a}=yield t.reader.next(o);if(null==a)throw new Error("Value is null");return a}),function(a){return s.apply(this,arguments)}),readLP:function(){var s=j(function*(){const{value:o}=yield r.next();if(null==o)throw new Error("Value is null");return o});return function(){return s.apply(this,arguments)}}(),readPB:function(){var s=j(function*(o){const a=yield i.readLP();if(null==a)throw new Error("Value is null");const u=a instanceof Uint8Array?a:a.slice();return o.decode(u)});return function(a){return s.apply(this,arguments)}}(),write:s=>{s instanceof Uint8Array?t.writer.push(s):t.writer.push(s.slice())},writeLP:s=>{i.write(Os.single(s,e))},writePB:(s,o)=>{i.writeLP(o.encode(s))},pb:s=>{return{read:(o=j(function*(){return yield i.readPB(s)}),function(){return o.apply(this,arguments)}),write:o=>i.writePB(o,s)};var o},unwrap:()=>(t.rest(),t.stream)};var s;return i}function YC(){const n=w0();let e=!1;return{sink:(t=j(function*(r){if(e)throw new Error("already piped");e=!0,n.resolve(r)}),function(i){return t.apply(this,arguments)}),source:dn(function*(){const t=yield lt(n.promise);yield*Mr(Pt(t),lt)})()};var t}_0.bytes=0,ps.fromReader=(n,e)=>{let t=1;const r=dn(function*(){for(;;)try{const{done:s,value:o}=yield lt(n.next(t));if(!0===s)return;null!=o&&(yield o)}catch(s){if("ERR_UNDER_READ"===s.code)return{done:!0,value:null};throw s}finally{t=1}})();return ps({...e??{},onLength:s=>{t=s}})(r)};var Fd=x(5061);const QC=n=>null!=n&&("function"==typeof n[Symbol.asyncIterator]||"function"==typeof n[Symbol.iterator]||"function"==typeof n.next),D0=n=>null!=n&&"function"==typeof n.sink&&QC(n.source),AB=n=>e=>{const t=n.sink(e);if(null!=t.then){const r=Mc({objectMode:!0});return t.then(()=>{r.end()},s=>{r.end(s)}),Fd(r,function(){var s=dn(function*(){yield*Mr(Pt(n.source),lt),r.end()});return function(){return s.apply(this,arguments)}}()())}return n.source};function Wn(n,...e){if(D0(n)){const r=n;n=()=>r.source}else if(QC(n)){const r=n;n=()=>r}const t=[n,...e];if(t.length>1&&D0(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let r=1;r{let e;for(;n.length>0;)e=n.shift()(e);return e})(...t)}const gl=65535,xB=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS),Ud=n=>{const e=globalThis.Buffer?globalThis.Buffer.allocUnsafe(2):new Uint8Array(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint16(0,n,!1),e};Ud.bytes=2;const Vd=n=>{if(n.length<2)throw RangeError("Could not decode int16BE");return n instanceof Uint8Array?new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,!1):n.getUint16(0)};Vd.bytes=2;class Hd extends Error{constructor(e="Unexpected Peer"){super(e),this.code=Hd.code}static get code(){return"ERR_UNEXPECTED_PEER"}}class Oc extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=Oc.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}}Error;var S0=x(3863),C0=x.n(S0);const I0=S0.Reader;function Wt(n,e){const t=I0.create(n instanceof Uint8Array?n:n.subarray());return e.decode(t)}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=I0.prototype[n];I0.prototype[n]=function(){return BigInt(e.call(this).toString())}});const T0=S0.Writer;function qt(n,e){const t=T0.create();return e.encode(n,t,{lengthDelimited:!1}),t.finish()}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=T0.prototype[n];T0.prototype[n]=function(t){return e.call(this,t.toString())}});var yl=(()=>{return(n=yl||(yl={}))[n.VARINT=0]="VARINT",n[n.BIT64=1]="BIT64",n[n.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",n[n.START_GROUP=3]="START_GROUP",n[n.END_GROUP=4]="END_GROUP",n[n.BIT32=5]="BIT32",yl;var n})();function JC(n,e,t,r){return{name:n,type:e,encode:t,decode:r}}function Fo(n){function e(i){if(null==n[i.toString()])throw new Error("Invalid enum value");return n[i]}return JC("enum",yl.VARINT,function(s,o){const a=e(s);o.int32(a)},function(s){return e(s.uint32())})}function Yt(n,e){return JC("message",yl.LENGTH_DELIMITED,n,e)}var kc,Lc,tr=(()=>{return(n=tr||(tr={})).RSA="RSA",n.Ed25519="Ed25519",n.Secp256k1="Secp256k1",tr;var n})(),Kd=(()=>{return(n=Kd||(Kd={}))[n.RSA=0]="RSA",n[n.Ed25519=1]="Ed25519",n[n.Secp256k1=2]="Secp256k1",Kd;var n})();(tr||(tr={})).codec=()=>Fo(Kd),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(r.uint32(8),tr.codec().encode(t.Type,r),null==t.Data)throw new Error('Protocol error: required field "Data" was not found in object');r.uint32(18),r.bytes(t.Data),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={Type:tr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=tr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}if(null==i.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==i.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(kc||(kc={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(r.uint32(8),tr.codec().encode(t.Type,r),null==t.Data)throw new Error('Protocol error: required field "Data" was not found in object');r.uint32(18),r.bytes(t.Data),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={Type:tr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=tr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}if(null==i.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==i.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Lc||(Lc={})),x(7791),x(2158);var Un=x(8659);const KB=function UB(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,ue=new Uint8Array(Ie);Z[J];){var Re=t[Z.charCodeAt(J)];if(255===Re)return;for(var ze=0,Oe=Ie-1;(0!==Re||ze>>0)%256>>>0,Re=Re/256>>>0;if(0!==Re)throw new Error("Non-zero carry");he=ze,J++}if(" "!==Z[J]){for(var bt=Ie-he;bt!==Ie&&0===ue[bt];)bt++;for(var vt=new Uint8Array(oe+(Ie-bt)),hn=oe;bt!==Ie;)vt[hn++]=ue[bt++];return vt}}}return{encode:function N(Z){if(Z instanceof Uint8Array||(ArrayBuffer.isView(Z)?Z=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Array.isArray(Z)&&(Z=Uint8Array.from(Z))),!(Z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===Z.length)return"";for(var J=0,oe=0,he=0,Ie=Z.length;he!==Ie&&0===Z[he];)he++,J++;for(var ue=(Ie-he)*R+1>>>0,Re=new Uint8Array(ue);he!==Ie;){for(var ze=Z[he],Oe=0,bt=ue-1;(0!==ze||Oe>>0)%a>>>0,ze=ze/a>>>0;if(0!==ze)throw new Error("Non-zero carry");oe=Oe,he++}for(var vt=ue-oe;vt!==ue&&0===Re[vt];)vt++;for(var hn=u.repeat(J);vt{if(n instanceof Uint8Array&&"Uint8Array"===n.constructor.name)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")});class WB{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class qB{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return eI(this,e)}}class YB{constructor(e){this.decoders=e}or(e){return eI(this,e)}decode(e){const r=this.decoders[e[0]];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const eI=(n,e)=>new YB({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class QB{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new WB(e,t,r),this.decoder=new qB(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const $d=({name:n,prefix:e,encode:t,decode:r})=>new QB(n,e,t,r),ml=({prefix:n,name:e,alphabet:t})=>{const{encode:r,decode:i}=KB(t,e);return $d({prefix:n,name:e,encode:r,decode:s=>Bc(i(s))})},Lr=({name:n,prefix:e,bitsPerChar:t,alphabet:r})=>$d({prefix:e,name:n,encode:i=>((n,e,t)=>{const r="="===e[e.length-1],i=(1<t;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<((n,e,t,r)=>{const i={};for(let R=0;R=8&&(a-=8,o[_++]=255&u>>a)}if(a>=t||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o})(i,r,t,n)}),JB=$d({prefix:"\0",name:"identity",encode:n=>(n=>(new TextDecoder).decode(n))(n),decode:n=>(n=>(new TextEncoder).encode(n))(n)}),e6=Lr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),t6=Lr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),n6=ml({prefix:"9",name:"base10",alphabet:"0123456789"}),r6=Lr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),i6=Lr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),co=Lr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),s6=Lr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),o6=Lr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),a6=Lr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),c6=Lr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),u6=Lr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),l6=Lr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),f6=Lr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),d6=Lr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),h6=ml({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),p6=ml({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ui=ml({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),g6=ml({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),jd=Lr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),y6=Lr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),m6=Lr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),v6=Lr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),tI=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}"),E6=tI.reduce((n,e,t)=>(n[t]=e,n),[]),b6=tI.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]),D6=$d({prefix:"\u{1f680}",name:"base256emoji",encode:function w6(n){return n.reduce((e,t)=>e+E6[t],"")},decode:function _6(n){const e=[];for(const t of n){const r=b6[t.codePointAt(0)];if(void 0===r)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}});var T6=Math.pow(2,31),R6=Math.pow(2,7),P6=Math.pow(2,14),N6=Math.pow(2,21),M6=Math.pow(2,28),O6=Math.pow(2,35),k6=Math.pow(2,42),L6=Math.pow(2,49),B6=Math.pow(2,56),F6=Math.pow(2,63),V6={encode:function rI(n,e,t){e=e||[];for(var r=t=t||0;n>=T6;)e[t++]=255&n|128,n/=128;for(;-128&n;)e[t++]=255&n|128,n>>>=7;return e[t]=0|n,rI.bytes=t-r+1,e},decode:function A0(n,r){var o,t=0,i=0,s=r=r||0,a=n.length;do{if(s>=a)throw A0.bytes=0,new RangeError("Could not decode varint");o=n[s++],t+=i<28?(127&o)<=128);return A0.bytes=s-r,t},encodingLength:function(n){return n[Gd.decode(n),Gd.decode.bytes],zd=(n,e,t=0)=>(Gd.encode(n,e,t),e),Wd=n=>Gd.encodingLength(n),Fc=(n,e)=>{const t=e.byteLength,r=Wd(n),i=r+Wd(t),s=new Uint8Array(i+t);return zd(n,s,0),zd(t,s,r),s.set(e,i),new R0(n,t,e,s)},qd=n=>{const e=Bc(n),[t,r]=x0(e),[i,s]=x0(e.subarray(r)),o=e.subarray(r+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new R0(t,i,o,e)};class R0{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const sI=({name:n,code:e,encode:t})=>new $6(n,e,t);class $6{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Fc(this.code,t):t.then(r=>Fc(this.code,r))}throw Error("Unknown type, must be binary type")}}const oI=n=>function(){var e=j(function*(t){return new Uint8Array(yield crypto.subtle.digest(n,t))});return function(t){return e.apply(this,arguments)}}(),mi=sI({name:"sha2-256",code:18,encode:oI("SHA-256")}),j6=sI({name:"sha2-512",code:19,encode:oI("SHA-512")}),cI=Bc,Uc={code:0,name:"identity",encode:cI,digest:n=>Fc(0,cI(n))},z6="raw",W6=85,q6=n=>Bc(n),Y6=n=>Bc(n),Q6=new TextEncoder,Z6=new TextDecoder,X6="json",J6=512,eF=n=>Q6.encode(JSON.stringify(n)),tF=n=>JSON.parse(Z6.decode(n));class _r{constructor(e,t,r,i){this.code=t,this.version=e,this.multihash=r,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Qd,byteLength:Qd,code:Yd,version:Yd,multihash:Yd,bytes:Yd,_baseCache:Qd,asCID:Qd})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==vl)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==sF)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return _r.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=Fc(e,t);return _r.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((n,e)=>n===e||n.code===e.code&&n.size===e.size&&((n,e)=>{if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t{const[N,B]=x0(e.subarray(t));return t+=B,N};let i=r(),s=vl;if(18===i?(i=0,t=0):1===i&&(s=r()),0!==i&&1!==i)throw new RangeError(`Invalid CID version ${i}`);const o=t,a=r(),u=r(),_=t+u;return{version:i,codec:s,multihashCode:a,digestSize:u,multihashSize:_-o,size:_}}static parse(e,t){const[r,i]=nF(e,t),s=_r.decode(i);return s._baseCache.set(r,e),s}}const nF=(n,e)=>{switch(n[0]){case"Q":return[ui.prefix,(e||ui).decode(`${ui.prefix}${n}`)];case ui.prefix:return[ui.prefix,(e||ui).decode(n)];case co.prefix:return[co.prefix,(e||co).decode(n)];default:if(null==e)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],e.decode(n)]}},rF=(n,e,t)=>{const{prefix:r}=t;if(r!==ui.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);const i=e.get(r);if(null==i){const s=t.encode(n).slice(1);return e.set(r,s),s}return i},iF=(n,e,t)=>{const{prefix:r}=t,i=e.get(r);if(null==i){const s=t.encode(n);return e.set(r,s),s}return i},vl=112,sF=18,uI=(n,e,t)=>{const r=Wd(n),i=r+Wd(e),s=new Uint8Array(i+t.byteLength);return zd(n,s,0),zd(e,s,r),s.set(t,i),s},lI=Symbol.for("@ipld/js-cid/CID"),Yd={writable:!1,configurable:!1,enumerable:!0},Qd={writable:!1,enumerable:!1,configurable:!1},aF=(n,e)=>{if(!n.test("0.0.0-dev"))throw new Error(e);console.warn(e)},cF="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n",El={...y,...l,...g,...w,...m,...h,...c,...f,...d,...b};function fI(n,e,t,r){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:r}}}const dI=fI("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>(new TextEncoder).encode(n.substring(1))),P0=fI("ascii","a",n=>{let e="a";for(let t=0;t{const e=Nc((n=n.substring(1)).length);for(let t=0;te)throw new Error("byte array longer than desired length");t=wr([new Uint8Array(e-t.length),t])}return Lt(t,"base64url")}function gs(n){const e=function dF(n,e){let t=Ot(n,"base64urlpad");if(null!=e){if(t.length>e)throw new Error("byte array longer than desired length");t=wr([new Uint8Array(e-t.length),t])}return t}(n);return new Un.jsbn.BigInteger(Lt(e,"base16"),16)}x(730);function vI(n){const e=n?.algorithm??"AES-GCM";let t=n?.keyLength??16;const r=n?.nonceLength??12,i=n?.digest??"SHA-256",s=n?.saltLength??16,o=n?.iterations??32767,a=ks.get();function _(){return(_=j(function*(K,Z){const J=a.getRandomValues(new Uint8Array(s)),oe=a.getRandomValues(new Uint8Array(r)),he={name:e,iv:oe};"string"==typeof Z&&(Z=Ot(Z));const Ie={name:"PBKDF2",salt:J,iterations:o,hash:{name:i}},ue=yield a.subtle.importKey("raw",Z,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Re=yield a.subtle.deriveKey(Ie,ue,{name:e,length:t},!0,["encrypt"]),ze=yield a.subtle.encrypt(he,Re,K);return wr([J,he.iv,new Uint8Array(ze)])})).apply(this,arguments)}function N(){return(N=j(function*(K,Z){const J=K.slice(0,s),oe=K.slice(s,s+r),he=K.slice(s+r),Ie={name:e,iv:oe};"string"==typeof Z&&(Z=Ot(Z));const ue={name:"PBKDF2",salt:J,iterations:o,hash:{name:i}},Re=yield a.subtle.importKey("raw",Z,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),ze=yield a.subtle.deriveKey(ue,Re,{name:e,length:t},!0,["decrypt"]),Oe=yield a.subtle.decrypt(Ie,ze,he);return new Uint8Array(Oe)})).apply(this,arguments)}return t*=8,{encrypt:function u(K,Z){return _.apply(this,arguments)},decrypt:function R(K,Z){return N.apply(this,arguments)}}}function gF(n,e){return L0.apply(this,arguments)}function L0(){return(L0=j(function*(n,e){const t=jd.decode(n);return yield vI().decrypt(t,e)})).apply(this,arguments)}Object.keys({"P-256":256,"P-384":384,"P-521":521}).join(" / "),x(8985);var yF=x(5856),mF=x.t(yF,2);const un=BigInt(0),qn=BigInt(1),Uo=BigInt(2),bl=BigInt(3),vF=BigInt(8),Nn=Object.freeze({a:un,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:qn,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});function EI(n){const{a:e,b:t}=Nn,r=at(n*n),i=at(r*n);return at(i+e*n+t)}const Zd=Nn.a===un;class B0 extends Error{constructor(e){super(e)}}class Mn{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof In))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new Mn(e.x,e.y,qn)}static toAffineBatch(e){const t=function DF(n,e=Nn.P){const t=new Array(n.length),i=$c(n.reduce((s,o,a)=>o===un?s:(t[a]=s,at(s*o,e)),qn),e);return n.reduceRight((s,o,a)=>o===un?s:(t[a]=at(s*t[a],e),at(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return Mn.toAffineBatch(e).map(Mn.fromAffine)}equals(e){if(!(e instanceof Mn))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,u=at(i*i),_=at(a*a),R=at(t*_),N=at(s*u),B=at(at(r*a)*_),K=at(at(o*i)*u);return R===N&&B===K}negate(){return new Mn(this.x,at(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,i=at(e*e),s=at(t*t),o=at(s*s),a=e+s,u=at(Uo*(at(a*a)-i-o)),_=at(bl*i),R=at(_*_),N=at(R-Uo*u),B=at(_*(u-N)-vF*o),K=at(Uo*t*r);return new Mn(N,B,K)}add(e){if(!(e instanceof Mn))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e;if(s===un||o===un)return this;if(t===un||r===un)return e;const u=at(i*i),_=at(a*a),R=at(t*_),N=at(s*u),B=at(at(r*a)*_),K=at(at(o*i)*u),Z=at(N-R),J=at(K-B);if(Z===un)return J===un?this.double():Mn.ZERO;const oe=at(Z*Z),he=at(Z*oe),Ie=at(R*oe),ue=at(J*J-he-Uo*Ie),Re=at(J*(Ie-ue)-B*he),ze=at(i*a*Z);return new Mn(ue,Re,ze)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Mn.ZERO;if("bigint"==typeof e&&e===un)return t;let r=_I(e);if(r===qn)return this;if(!Zd){let N=t,B=this;for(;r>un;)r&qn&&(N=N.add(B)),B=B.double(),r>>=qn;return N}let{k1neg:i,k1:s,k2neg:o,k2:a}=SI(r),u=t,_=t,R=this;for(;s>un||a>un;)s&qn&&(u=u.add(R)),a&qn&&(_=_.add(R)),R=R.double(),s>>=qn,a>>=qn;return i&&(u=u.negate()),o&&(_=_.negate()),_=new Mn(at(_.x*Nn.beta),_.y,_.z),u.add(_)}precomputeWindow(e){const t=Zd?128/e+1:256/e+1,r=[];let i=this,s=i;for(let o=0;o>=N,Z>u&&(Z-=R,e+=qn),0===Z){let J=i[K];B%2&&(J=J.negate()),o=o.add(J)}else{let J=i[K+Math.abs(Z)-1];Z<0&&(J=J.negate()),s=s.add(J)}}return{p:s,f:o}}multiply(e,t){let i,s,r=_I(e);if(Zd){const{k1neg:o,k1:a,k2neg:u,k2:_}=SI(r);let{p:R,f:N}=this.wNAF(a,t),{p:B,f:K}=this.wNAF(_,t);o&&(R=R.negate()),u&&(B=B.negate()),B=new Mn(at(B.x*Nn.beta),B.y,B.z),i=R.add(B),s=N.add(K)}else{const{p:o,f:a}=this.wNAF(r,t);i=o,s=a}return Mn.normalizeZ([i,s])[0]}toAffine(e=$c(this.z)){const{x:t,y:r,z:i}=this,s=e,o=at(s*s),a=at(o*s),u=at(t*o),_=at(r*a);if(at(i*s)!==qn)throw new Error("invZ was invalid");return new In(u,_)}}Mn.BASE=new Mn(Nn.Gx,Nn.Gy,qn),Mn.ZERO=new Mn(un,qn,un);const F0=new WeakMap;class In{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,F0.delete(this)}hasEvenY(){return this.y%Uo===un}static fromCompressedHex(e){const t=32===e.length,r=vi(t?e:e.subarray(1));if(!Jd(r))throw new Error("Point is not on curve");let s=function _F(n){const{P:e}=Nn,t=BigInt(6),r=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),u=n*n*n%e,_=u*u*n%e,R=zi(_,bl)*_%e,N=zi(R,bl)*_%e,B=zi(N,Uo)*u%e,K=zi(B,r)*B%e,Z=zi(K,i)*K%e,J=zi(Z,o)*Z%e,oe=zi(J,a)*J%e,he=zi(oe,o)*Z%e,Ie=zi(he,bl)*_%e,ue=zi(Ie,s)*K%e,Re=zi(ue,t)*u%e;return zi(Re,Uo)}(EI(r));const o=(s&qn)===qn;t?o&&(s=at(-s)):1==(1&e[0])!==o&&(s=at(-s));const a=new In(r,s);return a.assertValidity(),a}static fromUncompressedHex(e){const t=vi(e.subarray(1,33)),r=vi(e.subarray(33,65)),i=new In(t,r);return i.assertValidity(),i}static fromHex(e){const t=Bs(e),r=t.length,i=t[0];if(32===r||33===r&&(2===i||3===i))return this.fromCompressedHex(t);if(65===r&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(e){return In.BASE.multiply(_a(e))}static fromSignature(e,t,r){const i=CI(e=Bs(e)),{r:s,s:o}=AI(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");const u=In.fromHex((1&r?"03":"02")+Vo(s)),{n:_}=Nn,R=$c(s,_),N=at(-i*R,_),B=at(o*R,_),K=In.BASE.multiplyAndAddUnsafe(u,N,B);if(!K)throw new Error("Cannot recover signature: point at infinify");return K.assertValidity(),K}toRawBytes(e=!1){return Ho(this.toHex(e))}toHex(e=!1){const t=Vo(this.x);return e?`${this.hasEvenY()?"02":"03"}${t}`:`04${t}${Vo(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!Jd(t)||!Jd(r))throw new Error(e);const i=at(r*r);if(at(i-EI(t))!==un)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new In(this.x,at(-this.y))}double(){return Mn.fromAffine(this).double().toAffine()}add(e){return Mn.fromAffine(this).add(Mn.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Mn.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const i=Mn.fromAffine(this),s=t===un||t===qn||this!==In.BASE?i.multiplyUnsafe(t):i.multiply(t),o=Mn.fromAffine(e).multiplyUnsafe(r),a=s.add(o);return a.equals(Mn.ZERO)?void 0:a.toAffine()}}function bI(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function wI(n){if(n.length<2||2!==n[0])throw new Error(`Invalid signature integer tag: ${Hc(n)}`);const e=n[1],t=n.subarray(2,e+2);if(!e||t.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===t[0]&&t[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:vi(t),left:n.subarray(e+2)}}In.BASE=new In(Nn.Gx,Nn.Gy),In.ZERO=new In(un,un);class uo{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const i=t?Hc(e):e;if(128!==i.length)throw new Error(`${r}: Expected 64-byte hex`);return new uo(Xd(i.slice(0,64)),Xd(i.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:i}=function EF(n){if(n.length<2||48!=n[0])throw new Error(`Invalid signature tag: ${Hc(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:t}=wI(n.subarray(2)),{data:r,left:i}=wI(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${Hc(i)}`);return{r:e,s:r}}(t?e:Ho(e));return new uo(r,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Gc(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Gc(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){return this.s>Nn.n>>qn}normalizeS(){return this.hasHighS()?new uo(this.r,Nn.n-this.s):this}toDERRawBytes(e=!1){return Ho(this.toDERHex(e))}toDERHex(e=!1){const t=bI(wl(this.s));if(e)return t;const r=bI(wl(this.r)),i=wl(r.length/2),s=wl(t.length/2);return`30${wl(r.length/2+t.length/2+4)}02${i}${r}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Ho(this.toCompactHex())}toCompactHex(){return Vo(this.r)+Vo(this.s)}}function Vc(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function Hc(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t0)return BigInt(n);if("bigint"==typeof n&&Gc(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function at(n,e=Nn.P){const t=n%e;return t>=un?t:e+t}function zi(n,e){const{P:t}=Nn;let r=n;for(;e-- >un;)r*=r,r%=t;return r}function $c(n,e=Nn.P){if(n===un||e<=un)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=at(n,e),r=e,i=un,s=qn,o=qn,a=un;for(;t!==un;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==qn)throw new Error("invert: does not exist");return at(i,e)}const DI=(n,e)=>(n+e/Uo)/e,SF={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-qn*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function SI(n){const{n:e}=Nn,{a1:t,b1:r,a2:i,b2:s,POW_2_128:o}=SF,a=DI(s*n,e),u=DI(-r*n,e);let _=at(n-a*t-u*i,e),R=at(-a*r-u*s,e);const N=_>o,B=R>o;if(N&&(_=e-_),B&&(R=e-R),_>o||R>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:N,k1:_,k2neg:B,k2:R}}function CI(n){const{n:e}=Nn,r=8*n.length-256;let i=vi(n);return r>0&&(i>>=BigInt(r)),i>=e&&(i-=e),i}let jc,_l;class II{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return Yr.hmacSha256(this.k,...e)}hmacSync(...e){return _l(this.k,...e)}checkSync(){if("function"!=typeof _l)throw new B0("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}reseed(e=new Uint8Array){var t=this;return j(function*(){t.k=yield t.hmac(t.v,Uint8Array.from([0]),e),t.v=yield t.hmac(t.v),0!==e.length&&(t.k=yield t.hmac(t.v,Uint8Array.from([1]),e),t.v=yield t.hmac(t.v))})()}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}generate(){var e=this;return j(function*(){return e.incr(),e.v=yield e.hmac(e.v),e.v})()}generateSync(){return this.checkSync(),this.incr(),this.v=this.hmacSync(this.v),this.v}}function Gc(n){return un0)e=BigInt(n);else if("string"==typeof n){if(64!==n.length)throw new Error("Expected 32 bytes of private key");e=Xd(n)}else{if(!(n instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==n.length)throw new Error("Expected 32 bytes of private key");e=vi(n)}if(!Gc(e))throw new Error("Expected private key: 0 < key < n");return e}function U0(n){return n instanceof In?(n.assertValidity(),n):In.fromHex(n)}function AI(n){if(n instanceof uo)return n.assertValidity(),n;try{return uo.fromDER(n)}catch{return uo.fromCompact(n)}}function Dl(n,e=!1){return In.fromPrivateKey(n).toRawBytes(e)}function xI(n){const e=n instanceof Uint8Array,t="string"==typeof n,r=(e||t)&&n.length;return e?33===r||65===r:t?66===r||130===r:n instanceof In}function RI(n){return vi(n.length>32?n.slice(0,32):n)}function TF(n){const e=RI(n),t=at(e,Nn.n);return PI(t{if((n=Bs(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Kc(at(vi(n),Nn.n-qn)+qn)},randomBytes:(n=32)=>{if(Mi.web)return Mi.web.getRandomValues(new Uint8Array(n));if(Mi.node){const{randomBytes:e}=Mi.node;return Uint8Array.from(e(n))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Yr.hashToPrivateKey(Yr.randomBytes(40)),sha256:(n=j(function*(...e){if(Mi.web){const t=yield Mi.web.subtle.digest("SHA-256",Vc(...e));return new Uint8Array(t)}if(Mi.node){const{createHash:t}=Mi.node,r=t("sha256");return e.forEach(i=>r.update(i)),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")}),function(){return n.apply(this,arguments)}),hmacSha256:function(){var n=j(function*(e,...t){if(Mi.web){const r=yield Mi.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=Vc(...t),s=yield Mi.web.subtle.sign("HMAC",r,i);return new Uint8Array(s)}if(Mi.node){const{createHmac:r}=Mi.node,i=r("sha256",e);return t.forEach(s=>i.update(s)),Uint8Array.from(i.digest())}throw new Error("The environment doesn't have hmac-sha256 function")});return function(t){return n.apply(this,arguments)}}(),sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:function(){var n=j(function*(e,...t){let r=th[e];if(void 0===r){const i=yield Yr.sha256(Uint8Array.from(e,s=>s.charCodeAt(0)));r=Vc(i,i),th[e]=r}return Yr.sha256(r,...t)});return function(t){return n.apply(this,arguments)}}(),taggedHashSync:(n,...e)=>{if("function"!=typeof jc)throw new B0("sha256Sync is undefined, you need to set it");let t=th[n];if(void 0===t){const r=jc(Uint8Array.from(n,i=>i.charCodeAt(0)));t=Vc(r,r),th[n]=t}return jc(t,...e)},precompute(n=8,e=In.BASE){const t=e===In.BASE?e:new In(e.x,e.y);return t._setWindowSize(n),t.multiply(bl),t}};var n;function nh(n){if(isNaN(n)||n<=0)throw ae(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return Yr.randomBytes(n)}function MF(n){const e=Un.asn1.fromDer(Lt(n,"ascii")),t=Un.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:Ls(t.n),e:Ls(t.e),d:Ls(t.d),p:Ls(t.p),q:Ls(t.q),dp:Ls(t.dP),dq:Ls(t.dQ),qi:Ls(t.qInv),alg:"RS256"}}function VI(n,e){return e.map(t=>gs(n[t]))}function UF(n){return $0.apply(this,arguments)}function $0(){return $0=j(function*(n){const e=yield ks.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:n,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=yield KI(e);return{privateKey:t[0],publicKey:t[1]}}),$0.apply(this,arguments)}function HI(n){return j0.apply(this,arguments)}function j0(){return j0=j(function*(n){const t=[yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),yield KF(n)],r=yield KI({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}),j0.apply(this,arguments)}function G0(){return G0=j(function*(n,e){const t=yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=yield ks.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(r,0,r.byteLength)}),G0.apply(this,arguments)}function z0(){return z0=j(function*(n,e,t){const r=yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return yield ks.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},r,e,t)}),z0.apply(this,arguments)}function KI(n){return W0.apply(this,arguments)}function W0(){return W0=j(function*(n){if(null==n.privateKey||null==n.publicKey)throw ae(new Error("Private and public key are required"),"ERR_INVALID_PARAMETERS");return yield Promise.all([ks.get().subtle.exportKey("jwk",n.privateKey),ks.get().subtle.exportKey("jwk",n.publicKey)])}),W0.apply(this,arguments)}function KF(n){return q0.apply(this,arguments)}function q0(){return q0=j(function*(n){return yield ks.get().subtle.importKey("jwk",{kty:n.kty,n:n.n,e:n.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}),q0.apply(this,arguments)}function $I(n,e,t,r){const i=e?function FF(n){return Un.pki.setRsaPublicKey(...VI(n,["n","e"]))}(n):function BF(n){return Un.pki.setRsaPrivateKey(...VI(n,["n","e","d","p","q","dp","dq","qi"]))}(n);return Ot(r(Lt(Uint8Array.from(t),"ascii"),i),"ascii")}function Y0(n,e){return Q0.apply(this,arguments)}function Q0(){return Q0=j(function*(n,e){const r=yield vI().encrypt(n,e);return jd.encode(r)}),Q0.apply(this,arguments)}Object.defineProperties(Yr,{sha256Sync:{configurable:!1,get:()=>jc,set(n){jc||(jc=n)}},hmacSha256Sync:{configurable:!1,get:()=>_l,set(n){_l||(_l=n)}}}),x(5517);class Z0{constructor(e){this._key=e}verify(e,t){var r=this;return j(function*(){return yield function HF(n,e,t){return z0.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function LF(n){if(null==n.n||null==n.e)throw ae(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Un.pki.publicKeyToAsn1({n:gs(n.n),e:gs(n.e)});return Ot(Un.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return kc.encode({Type:tr.RSA,Data:this.marshal()}).subarray()}encrypt(e){return function $F(n,e){return $I(n,!0,e,(t,r)=>r.encrypt(t))}(this._key,e)}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class rh{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return nh(16)}sign(e){var t=this;return j(function*(){return yield function VF(n,e){return G0.apply(this,arguments)}(t._key,e)})()}get public(){if(null==this._publicKey)throw ae(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new Z0(this._publicKey)}decrypt(e){return function jF(n,e){return $I(n,!1,e,(t,r)=>r.decrypt(t))}(this._key,e)}marshal(){return function OF(n){if(null==n.n||null==n.e||null==n.d||null==n.p||null==n.q||null==n.dp||null==n.dq||null==n.qi)throw ae(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Un.pki.privateKeyToAsn1({n:gs(n.n),e:gs(n.e),d:gs(n.d),p:gs(n.p),q:gs(n.q),dP:gs(n.dp),dQ:gs(n.dq),qInv:gs(n.qi)});return Ot(Un.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Lc.encode({Type:tr.RSA,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){return Lt(yield e.public.hash(),"base58btc")})()}export(e,t="pkcs-8"){var r=this;return j(function*(){if("pkcs-8"===t){const i=new Un.util.ByteBuffer(r.marshal()),s=Un.asn1.fromDer(i),o=Un.pki.privateKeyFromAsn1(s);return Un.pki.encryptRsaPrivateKey(o,e,{algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"})}if("libp2p-key"===t)return yield Y0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function GF(n){return X0.apply(this,arguments)}function X0(){return X0=j(function*(n){const e=MF(n),t=yield HI(e);return new rh(t.privateKey,t.publicKey)}),X0.apply(this,arguments)}function zF(n){const e=function kF(n){const e=Un.asn1.fromDer(Lt(n,"ascii")),t=Un.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:Ls(t.n),e:Ls(t.e)}}(n);return new Z0(e)}function WF(n){return J0.apply(this,arguments)}function J0(){return J0=j(function*(n){const e=yield HI(n);return new rh(e.privateKey,e.publicKey)}),J0.apply(this,arguments)}function qF(n){return em.apply(this,arguments)}function em(){return em=j(function*(n){const e=yield UF(n);return new rh(e.privateKey,e.publicKey)}),em.apply(this,arguments)}var YF=x(7420),QF=x.t(YF,2);const ar=BigInt(0),an=BigInt(1),Wc=BigInt(2),jI=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),Vn=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:jI,n:jI,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),GI=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),Sl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),ZF=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),XF=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),JF=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),e5=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class wn{constructor(e,t,r,i){this.x=e,this.y=t,this.z=r,this.t=i}static fromAffine(e){if(!(e instanceof nr))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(nr.ZERO)?wn.ZERO:new wn(e.x,e.y,an,Me(e.x*e.y))}static toAffineBatch(e){const t=function r5(n,e=Vn.P){const t=new Array(n.length),i=ih(n.reduce((s,o,a)=>o===ar?s:(t[a]=s,Me(s*o,e)),an),e);return n.reduceRight((s,o,a)=>o===ar?s:(t[a]=Me(s*t[a],e),Me(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){zI(e);const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,u=Me(t*a),_=Me(s*i),R=Me(r*a),N=Me(o*i);return u===_&&R===N}negate(){return new wn(Me(-this.x),this.y,this.z,Me(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:i}=Vn,s=Me(e*e),o=Me(t*t),a=Me(Wc*Me(r*r)),u=Me(i*s),_=e+t,R=Me(Me(_*_)-s-o),N=u+o,B=N-a,K=u-o,Z=Me(R*B),J=Me(N*K),oe=Me(R*K),he=Me(B*N);return new wn(Z,J,he,oe)}add(e){zI(e);const{x:t,y:r,z:i,t:s}=this,{x:o,y:a,z:u,t:_}=e,R=Me((r-t)*(a+o)),N=Me((r+t)*(a-o)),B=Me(N-R);if(B===ar)return this.double();const K=Me(i*Wc*_),Z=Me(s*Wc*u),J=Z+K,oe=N+R,he=Z-K,Ie=Me(J*B),ue=Me(oe*he),Re=Me(J*he),ze=Me(B*oe);return new wn(Ie,ue,ze,Re)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let i=this,s=i;for(let o=0;o>=N,Z>u&&(Z-=R,e+=an),0===Z){let J=i[K];B%2&&(J=J.negate()),o=o.add(J)}else{let J=i[K+Math.abs(Z)-1];Z<0&&(J=J.negate()),s=s.add(J)}}return wn.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(Zc(e,Vn.l),t)}multiplyUnsafe(e){let t=Zc(e,Vn.l,!1);const r=wn.BASE,i=wn.ZERO;if(t===ar)return i;if(this.equals(i)||t===an)return this;if(this.equals(r))return this.wNAF(t);let s=i,o=this;for(;t>ar;)t&an&&(s=s.add(o)),o=o.double(),t>>=an;return s}isSmallOrder(){return this.multiplyUnsafe(Vn.h).equals(wn.ZERO)}isTorsionFree(){return this.multiplyUnsafe(Vn.l).equals(wn.ZERO)}toAffine(e=ih(this.z)){const{x:t,y:r,z:i}=this,s=Me(t*e),o=Me(r*e);if(Me(i*e)!==an)throw new Error("invZ was invalid");return new nr(s,o)}fromRistrettoBytes(){nm()}toRistrettoBytes(){nm()}fromRistrettoHash(){nm()}}function zI(n){if(!(n instanceof wn))throw new TypeError("ExtendedPoint expected")}function tm(n){if(!(n instanceof Wi))throw new TypeError("RistrettoPoint expected")}function nm(){throw new Error("Legacy method: switch to RistrettoPoint")}wn.BASE=new wn(Vn.Gx,Vn.Gy,an,Me(Vn.Gx*Vn.Gy)),wn.ZERO=new wn(ar,an,an,ar);class Wi{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=Vn,r=Me(Sl*e*e),i=Me((r+an)*JF);let s=BigInt(-1);const o=Me((s-t*r)*Me(r+t));let{isValid:a,value:u}=om(i,o),_=Me(u*e);$o(_)||(_=Me(-_)),a||(u=_),a||(s=r);const R=Me(s*(r-an)*e5-o),N=u*u,B=Me((u+u)*o),K=Me(R*ZF),Z=Me(an-N),J=Me(an+N);return new wn(Me(B*J),Me(Z*K),Me(K*J),Me(B*Z))}static hashToCurve(e){const t=sm((e=ms(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),i=sm(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new Wi(r.add(s))}static fromHex(e){e=ms(e,32);const{a:t,d:r}=Vn,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=sm(e);if(!function i5(n,e){if(n.length!==e.length)return!1;for(let t=0;t=i)throw new Error("Expected 0 < hex < P");if(!t&&o>=GI)throw new Error("Expected 0 < hex < 2**256");const a=Me(o*o),u=Me(a-an),_=Me(r*a+an);let{isValid:R,value:N}=om(u,_);if(!R)throw new Error("Point.fromHex: invalid y coordinate");return 0!=(128&e[31])!=((N&an)===an)&&(N=Me(-N)),new nr(N,o)}static fromPrivateKey(e){return j(function*(){return(yield Tl(e)).point})()}toRawBytes(){const e=Yc(this.y);return e[31]|=this.x&an?128:0,e}toHex(){return Cl(this.toRawBytes())}toX25519(){const{y:e}=this;return Yc(Me((an+e)*ih(an-e)))}isTorsionFree(){return wn.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new nr(Me(-this.x),this.y)}add(e){return wn.fromAffine(this).add(wn.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return wn.fromAffine(this).multiply(e,this).toAffine()}}nr.BASE=new nr(Vn.Gx,Vn.Gy),nr.ZERO=new nr(ar,an);class qc{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=ms(e,64),r=nr.fromHex(t.slice(0,32),!1),i=Da(t.slice(32,64));return new qc(r,i)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof nr))throw new Error("Expected Point instance");return Zc(t,Vn.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Yc(this.s),32),e}toHex(){return Cl(this.toRawBytes())}}function WI(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Expected Uint8Array list");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function Cl(n){if(!(n instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t=ar?t:e+t}function ih(n,e=Vn.P){if(n===ar||e<=ar)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Me(n,e),r=e,i=ar,s=an,o=an,a=ar;for(;t!==ar;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==an)throw new Error("invert: does not exist");return Me(i,e)}function ys(n,e){const{P:t}=Vn;let r=n;for(;e-- >ar;)r*=r,r%=t;return r}function om(n,e){const t=Me(e*e*e),r=Me(t*t*e);let s=Me(n*t*function YI(n){const{P:e}=Vn,t=BigInt(5),r=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),u=n*n%e*n%e,_=ys(u,Wc)*u%e,R=ys(_,an)*n%e,N=ys(R,t)*R%e,B=ys(N,r)*N%e,K=ys(B,i)*B%e,Z=ys(K,s)*K%e,J=ys(Z,o)*Z%e,oe=ys(J,o)*Z%e,he=ys(oe,r)*N%e;return{pow_p_5_8:ys(he,Wc)*n%e,b2:u}}(n*r).pow_p_5_8);const o=Me(e*s*s),a=s,u=Me(s*Sl),_=o===n,R=o===Me(-n),N=o===Me(-n*Sl);return _&&(s=a),(R||N)&&(s=u),$o(s)&&(s=Me(-s)),{isValid:_||R,value:s}}function QI(n){return om(an,n)}function Qc(n){return Me(Da(n),Vn.l)}function ms(n,e){const t=n instanceof Uint8Array?Uint8Array.from(n):im(n);if("number"==typeof e&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function Zc(n,e,t=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof n&&Number.isSafeInteger(n)&&(n=BigInt(n)),"bigint"==typeof n&&n{if((n=ms(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Me(Da(n),Vn.l-an)+an},randomBytes:(n=32)=>{if(jo.web)return jo.web.getRandomValues(new Uint8Array(n));if(jo.node){const{randomBytes:e}=jo.node;return new Uint8Array(e(n).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Sa.randomBytes(32),sha512:function(){var n=j(function*(...e){const t=WI(...e);if(jo.web){const r=yield jo.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(r)}if(jo.node)return Uint8Array.from(jo.node.createHash("sha512").update(t).digest());throw new Error("The environment doesn't have sha512 function")});return function(){return n.apply(this,arguments)}}(),precompute(n=8,e=nr.BASE){const t=e.equals(nr.BASE)?e:new nr(e.x,e.y);return t._setWindowSize(n),t.multiply(Wc),t},sha512Sync:void 0};function p5(){return pm.apply(this,arguments)}function pm(){return pm=j(function*(){const n=Sa.randomPrivateKey(),e=yield e2(n);return{privateKey:r2(n,e),publicKey:e}}),pm.apply(this,arguments)}function g5(n){return gm.apply(this,arguments)}function gm(){return gm=j(function*(n){if(32!==n.length)throw new TypeError('"seed" must be 32 bytes in length.');if(!(n instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const e=n,t=yield e2(e);return{privateKey:r2(e,t),publicKey:t}}),gm.apply(this,arguments)}function ym(){return ym=j(function*(n,e){const t=n.slice(0,32);return yield a5(e,t)}),ym.apply(this,arguments)}function mm(){return mm=j(function*(n,e,t){return yield u5(e,t,n)}),mm.apply(this,arguments)}function r2(n,e){const t=new Uint8Array(64);for(let r=0;r<32;r++)t[r]=n[r],t[32+r]=e[r];return t}Object.defineProperties(Sa,{sha512Sync:{configurable:!1,get:()=>Il,set(n){Il||(Il=n)}}});class vm{constructor(e){this._key=Xc(e,32)}verify(e,t){var r=this;return j(function*(){return yield function m5(n,e,t){return mm.apply(this,arguments)}(r._key,t,e)})()}marshal(){return this._key}get bytes(){return kc.encode({Type:tr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class xl{constructor(e,t){this._key=Xc(e,64),this._publicKey=Xc(t,32)}sign(e){var t=this;return j(function*(){return yield function y5(n,e){return ym.apply(this,arguments)}(t._key,e)})()}get public(){return new vm(this._publicKey)}marshal(){return this._key}get bytes(){return Lc.encode({Type:tr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){const t=yield Uc.digest(e.public.bytes);return ui.encode(t.bytes).substring(1)})()}export(e,t="libp2p-key"){var r=this;return j(function*(){if("libp2p-key"===t)return yield Y0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function v5(n){if(n.length>64){const r=(n=Xc(n,96)).slice(0,64),i=n.slice(64,n.length);return new xl(r,i)}const e=(n=Xc(n,64)).slice(0,64),t=n.slice(32);return new xl(e,t)}function E5(n){return n=Xc(n,32),new vm(n)}function b5(){return Em.apply(this,arguments)}function Em(){return Em=j(function*(){const{privateKey:n,publicKey:e}=yield p5();return new xl(n,e)}),Em.apply(this,arguments)}function w5(n){return bm.apply(this,arguments)}function bm(){return bm=j(function*(n){const{privateKey:e,publicKey:t}=yield g5(n);return new xl(e,t)}),bm.apply(this,arguments)}function Xc(n,e){if((n=Uint8Array.from(n??[])).length!==e)throw ae(new Error(`Key must be a Uint8Array of length ${e}, got ${n.length}`),"ERR_INVALID_KEY_TYPE");return n}function _5(){return Yr.randomPrivateKey()}function wm(){return wm=j(function*(n,e){const{digest:t}=yield mi.digest(e);try{return yield OI(t,n)}catch(r){throw ae(r,"ERR_INVALID_INPUT")}}),wm.apply(this,arguments)}function _m(){return _m=j(function*(n,e,t){try{const{digest:r}=yield mi.digest(t);return xF(e,r,n)}catch(r){throw ae(r,"ERR_INVALID_INPUT")}}),_m.apply(this,arguments)}function i2(n){try{In.fromHex(n)}catch(e){throw ae(e,"ERR_INVALID_PUBLIC_KEY")}}class Dm{constructor(e){i2(e),this._key=e}verify(e,t){var r=this;return j(function*(){return yield function S5(n,e,t){return _m.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function C5(n){return In.fromHex(n).toRawBytes(!0)}(this._key)}get bytes(){return kc.encode({Type:tr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class Sm{constructor(e,t){this._key=e,this._publicKey=t??function T5(n){try{return Dl(n,!0)}catch(e){throw ae(e,"ERR_INVALID_PRIVATE_KEY")}}(e),function I5(n){try{Dl(n,!0)}catch(e){throw ae(e,"ERR_INVALID_PRIVATE_KEY")}}(this._key),i2(this._publicKey)}sign(e){var t=this;return j(function*(){return yield function D5(n,e){return wm.apply(this,arguments)}(t._key,e)})()}get public(){return new Dm(this._publicKey)}marshal(){return this._key}get bytes(){return Lc.encode({Type:tr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){return Lt(yield e.public.hash(),"base58btc")})()}export(e,t="libp2p-key"){var r=this;return j(function*(){if("libp2p-key"===t)return yield Y0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function A5(n){return new Sm(n)}function x5(n){return new Dm(n)}function R5(){return Cm.apply(this,arguments)}function Cm(){return Cm=j(function*(){const n=yield _5();return new Sm(n)}),Cm.apply(this,arguments)}const lo={rsa:I,ed25519:A,secp256k1:P};function Im(n){const e=Object.keys(lo).join(" / ");return ae(new Error(`invalid or unsupported key type ${n}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}function Tm(n){if("rsa"===(n=n.toLowerCase())||"ed25519"===n||"secp256k1"===n)return lo[n];throw Im(n)}function s2(n,e){return Am.apply(this,arguments)}function Am(){return Am=j(function*(n,e){return yield Tm(n).generateKeyPair(e??2048)}),Am.apply(this,arguments)}function Rl(n){const e=kc.decode(n),t=e.Data;switch(e.Type){case tr.RSA:return lo.rsa.unmarshalRsaPublicKey(t);case tr.Ed25519:return lo.ed25519.unmarshalEd25519PublicKey(t);case tr.Secp256k1:return lo.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Im(e.Type)}}function o2(n,e){return Tm(e=(e??"rsa").toLowerCase()),n.bytes}function Pl(n){return Rm.apply(this,arguments)}function Rm(){return Rm=j(function*(n){const e=Lc.decode(n),t=e.Data;switch(e.Type){case tr.RSA:return yield lo.rsa.unmarshalRsaPrivateKey(t);case tr.Ed25519:return lo.ed25519.unmarshalEd25519PrivateKey(t);case tr.Secp256k1:return lo.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Im(e.Type)}}),Rm.apply(this,arguments)}function P5(n,e){return Tm(e=(e??"rsa").toLowerCase()),n.bytes}function Pm(n,e){return Nm.apply(this,arguments)}function Nm(){return Nm=j(function*(n,e){try{const i=yield gF(n,e);return yield Pl(i)}catch{}const t=Un.pki.decryptRsaPrivateKey(n,e);if(null===t)throw ae(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let r=Un.asn1.toDer(Un.pki.privateKeyToAsn1(t));return r=Ot(r.getBytes(),"ascii"),yield lo.rsa.unmarshalRsaPrivateKey(r)}),Nm.apply(this,arguments)}const a2=Symbol.for("@libp2p/peer-id");function c2(n){return null!=n&&Boolean(n[a2])}const u2=Object.values(El).map(n=>n.decoder).reduce((n,e)=>n.or(e),El.identity.decoder);class ch{constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[a2](){return!0}toString(){return null==this.string&&(this.string=ui.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return _r.createV1(114,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return kr(this.multihash.bytes,e);if("string"==typeof e)return fr(e).equals(this);if(null!=e?.multihash?.bytes)return kr(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}}class Nl extends ch{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}}class Ml extends ch{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}}class Ol extends ch{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}}function Br(n){if("RSA"===n.type)return new Nl(n);if("Ed25519"===n.type)return new Ml(n);if("secp256k1"===n.type)return new Ol(n);throw ae(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function fr(n,e){if(e=e??u2,"1"===n.charAt(0)||"Q"===n.charAt(0)){const t=qd(ui.decode(`z${n}`));return n.startsWith("12D")?new Ml({multihash:t}):n.startsWith("16U")?new Ol({multihash:t}):new Nl({multihash:t})}return Jc(u2.decode(n))}function Jc(n){try{const e=qd(n);if(e.code===Uc.code){if(36===e.digest.length)return new Ml({multihash:e});if(37===e.digest.length)return new Ol({multihash:e})}if(e.code===mi.code)return new Nl({multihash:e})}catch{return function N5(n){if(null==n||null==n.multihash||null==n.version||1===n.version&&114!==n.code)throw new Error("Supplied PeerID CID is invalid");const e=n.multihash;if(e.code===mi.code)return new Nl({multihash:n.multihash});if(e.code===Uc.code){if(36===e.digest.length)return new Ml({multihash:n.multihash});if(37===e.digest.length)return new Ol({multihash:n.multihash})}throw new Error("Supplied PeerID CID is invalid")}(_r.decode(n))}throw new Error("Supplied PeerID CID is invalid")}function kl(n,e){return km.apply(this,arguments)}function km(){return km=j(function*(n,e){return 36===n.length?new Ml({multihash:Fc(Uc.code,n),privateKey:e}):37===n.length?new Ol({multihash:Fc(Uc.code,n),privateKey:e}):new Nl({multihash:yield mi.digest(n),publicKey:n,privateKey:e})}),km.apply(this,arguments)}var Lm;!function(n){let e;!function(t){let r;t.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.identityKey)throw new Error('Protocol error: required field "identityKey" was not found in object');if(s.uint32(10),s.bytes(i.identityKey),null==i.identitySig)throw new Error('Protocol error: required field "identitySig" was not found in object');if(s.uint32(18),s.bytes(i.identitySig),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(26),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0),data:new Uint8Array(0)},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.identityKey=i.bytes();break;case 2:o.identitySig=i.bytes();break;case 3:o.data=i.bytes();break;default:i.skipType(7&u)}}if(null==o.identityKey)throw new Error('Protocol error: value for required field "identityKey" was not found in protobuf');if(null==o.identitySig)throw new Error('Protocol error: value for required field "identitySig" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),t.encode=i=>qt(i,t.codec()),t.decode=i=>Wt(i,t.codec())}(e=n.NoiseHandshakePayload||(n.NoiseHandshakePayload={}))}(Lm||(Lm={}));const f2=Lm.NoiseHandshakePayload;function Bm(){return Bm=j(function*(n,e,t){const r=yield k5(n,p2(e)),i=t??new Uint8Array(0);if(null==n.publicKey)throw new Error("PublicKey was missing from local PeerId");return O5(n.publicKey,r,i)}),Bm.apply(this,arguments)}function O5(n,e,t){return f2.encode({identityKey:n,identitySig:e,data:t??new Uint8Array(0)}).subarray()}function k5(n,e){return Fm.apply(this,arguments)}function Fm(){return Fm=j(function*(n,e){if(null==n.privateKey)throw new Error("PrivateKey was missing from PeerId");return yield(yield Pl(n.privateKey)).sign(e)}),Fm.apply(this,arguments)}function d2(n){return Um.apply(this,arguments)}function Um(){return Um=j(function*(n){return yield kl(n.identityKey)}),Um.apply(this,arguments)}function h2(n){return f2.decode(n)}function p2(n){const e=Ot("noise-libp2p-static-key:");return wr([e,n],e.length+n.length)}function g2(n,e,t){return Vm.apply(this,arguments)}function Vm(){return Vm=j(function*(n,e,t){const r=yield kl(e.identityKey);if(!r.equals(t))throw new Error("Peer ID doesn't match libp2p public key.");const i=p2(n);if(null==r.publicKey)throw new Error("PublicKey was missing from PeerId");if(null==e.identitySig)throw new Error("Signature was missing from message");if(!(yield Rl(r.publicKey).verify(i,e.identitySig)))throw new Error("Static key doesn't match to peer that signed payload!");return r}),Vm.apply(this,arguments)}function uh(n){return!(!(n instanceof Uint8Array)||32!==n.length)}var dr=x(1455);function Gt(n){return Object.assign(dr(n),{error:dr(`${n}:error`),trace:dr(`${n}:trace`)})}dr.formatters.b=n=>null==n?"undefined":ui.baseEncode(n),dr.formatters.t=n=>null==n?"undefined":co.baseEncode(n),dr.formatters.m=n=>null==n?"undefined":jd.baseEncode(n),dr.formatters.p=n=>null==n?"undefined":n.toString(),dr.formatters.c=n=>null==n?"undefined":n.toString(),dr.formatters.k=n=>null==n?"undefined":n.toString();const Qr=Gt("libp2p:noise");let qi;function y2(n){n?(qi(`LOCAL_PUBLIC_EPHEMERAL_KEY ${Lt(n.publicKey,"hex")}`),qi(`LOCAL_PRIVATE_EPHEMERAL_KEY ${Lt(n.privateKey,"hex")}`)):qi("Missing local ephemeral keys.")}function m2(n){qi(`REMOTE_EPHEMERAL_PUBLIC_KEY ${Lt(n,"hex")}`)}qi=xB?Qr:Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});class K5{constructor(e=0){this.n=e,this.bytes=new Uint8Array(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>4294967295)throw new Error("Cipherstate has reached maximum n, a new handshake must be performed")}}class j5 extends class $5{constructor(e){this.crypto=e}encryptWithAd(e,t,r){const i=this.encrypt(e.k,e.n,t,r);return e.n.increment(),i}decryptWithAd(e,t,r){const{plaintext:i,valid:s}=this.decrypt(e.k,e.n,t,r);return s&&e.n.increment(),{plaintext:i,valid:s}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(e){return kr(this.createEmptyKey(),e)}encrypt(e,t,r,i){return t.assertValue(),this.crypto.chaCha20Poly1305Encrypt(i,t.getBytes(),r,e)}encryptAndHash(e,t){let r;return r=this.hasKey(e.cs)?this.encryptWithAd(e.cs,e.h,t):t,this.mixHash(e,r),r}decrypt(e,t,r,i){t.assertValue();const s=this.crypto.chaCha20Poly1305Decrypt(i,t.getBytes(),r,e);return s?{plaintext:s,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(e,t){let r,i=!0;return this.hasKey(e.cs)?({plaintext:r,valid:i}=this.decryptWithAd(e.cs,e.h,t)):r=t,this.mixHash(e,t),{plaintext:r,valid:i}}dh(e,t){try{const r=this.crypto.generateX25519SharedKey(e,t);return 32===r.length?r:r.subarray(0,32)}catch(r){return Qr(r.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(wr([e,t],e.length+t.length))}mixKey(e,t){const[r,i]=this.crypto.getHKDF(e.ck,t);e.cs=this.initializeKey(i),e.ck=r}initializeKey(e){return{k:e,n:new K5}}initializeSymmetric(e){const t=Ot(e,"utf-8"),r=this.hashProtocolName(t),i=r,s=this.createEmptyKey();return{cs:this.initializeKey(s),ck:i,h:r}}hashProtocolName(e){if(e.length<=32){const t=new Uint8Array(32);return t.set(e),t}return this.getHash(e,new Uint8Array(0))}split(e){const[t,r]=this.crypto.getHKDF(e.ck,new Uint8Array(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,new Uint8Array(0),t);return{ne:this.createEmptyKey(),ns:new Uint8Array(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,new Uint8Array(0),t.ciphertext)}}{initializeInitiator(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}initializeResponder(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}writeMessageA(e,t,r){const i=new Uint8Array(0);e.e=void 0!==r?r:this.crypto.generateX25519KeyPair();const s=e.e.publicKey;return this.mixHash(e.ss,s),{ne:s,ns:i,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=this.crypto.generateX25519KeyPair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const s=this.encryptAndHash(e.ss,e.s.publicKey);return this.mixKey(e.ss,this.dh(e.s.privateKey,e.re)),{ne:r,ns:s,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const i=this.encryptAndHash(e.ss,e.s.publicKey);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const s=this.encryptAndHash(e.ss,t),a={ne:this.createEmptyKey(),ns:i,ciphertext:s},{cs1:u,cs2:_}=this.split(e.ss);return{h:e.ss.h,messageBuffer:a,cs1:u,cs2:_}}readMessageA(e,t){return uh(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(uh(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&uh(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:s,valid:i&&o}}readMessageC(e,t){const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);if(i&&uh(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:a,cs2:u}=this.split(e.ss);return{h:e.ss.h,plaintext:s,valid:i&&o,cs1:a,cs2:u}}initSession(e,t,r){const i=this.createEmptyKey(),s=new Uint8Array(32);let o;return o=e?this.initializeInitiator(t,r,s,i):this.initializeResponder(t,r,s,i),{hs:o,i:e,mc:0}}sendMessage(e,t,r){let i;if(0===e.mc)i=this.writeMessageA(e.hs,t,r);else if(1===e.mc)i=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:s,messageBuffer:o,cs1:a,cs2:u}=this.writeMessageC(e.hs,t);i=o,e.h=s,e.cs1=a,e.cs2=u}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");i=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");i=this.writeMessageRegular(e.cs2,t)}}return e.mc++,i}recvMessage(e,t){let r=new Uint8Array(0),i=!1;if(0===e.mc)({plaintext:r,valid:i}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:i}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:s,plaintext:o,valid:a,cs1:u,cs2:_}=this.readMessageC(e.hs,t);r=o,i=a,e.h=s,e.cs1=u,e.cs2=_}return e.mc++,{plaintext:r,valid:i}}}class G5{constructor(e,t,r,i,s,o,a,u){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=u??new j5(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=new Uint8Array(0)}propose(){var e=this;return j(function*(){if(function L5(n){qi(`LOCAL_STATIC_PUBLIC_KEY ${Lt(n.publicKey,"hex")}`),qi(`LOCAL_STATIC_PRIVATE_KEY ${Lt(n.privateKey,"hex")}`)}(e.session.hs.s),e.isInitiator){Qr("Stage 0 - Initiator starting to send first message.");const t=e.xx.sendMessage(e.session,new Uint8Array(0));e.connection.writeLP(function MB(n){return wr([n.ne,n.ciphertext],n.ne.length+n.ciphertext.length)}(t)),Qr("Stage 0 - Initiator finished sending first message."),y2(e.session.hs.e)}else{Qr("Stage 0 - Responder waiting to receive first message...");const t=function LB(n){if(n.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:n.subarray(0,32),ciphertext:n.subarray(32,n.length),ns:new Uint8Array(0)}}((yield e.connection.readLP()).subarray()),{valid:r}=e.xx.recvMessage(e.session,t);if(!r)throw new Oc("xx handshake stage 0 validation fail");Qr("Stage 0 - Responder received first message."),m2(e.session.hs.re)}})()}exchange(){var e=this;return j(function*(){if(e.isInitiator){Qr("Stage 1 - Initiator waiting to receive first message from responder...");const t=function BB(n){if(n.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:n.subarray(0,32),ns:n.subarray(32,80),ciphertext:n.subarray(80,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Oc("xx handshake stage 1 validation fail");Qr("Stage 1 - Initiator received the message."),m2(e.session.hs.re),function B5(n){qi(`REMOTE_STATIC_PUBLIC_KEY ${Lt(n,"hex")}`)}(e.session.hs.rs),Qr("Initiator going to check remote's signature...");try{const s=h2(r);e.remotePeer=e.remotePeer||(yield d2(s)),yield g2(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new Hd(`Error occurred while verifying signed payload: ${s.message}`)}Qr("All good with the signature!")}else{Qr("Stage 1 - Responder sending out first message with signed payload and static key.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function OB(n){return wr([n.ne,n.ns,n.ciphertext],n.ne.length+n.ns.length+n.ciphertext.length)}(t)),Qr("Stage 1 - Responder sent the second handshake message with signed payload."),y2(e.session.hs.e)}})()}finish(){var e=this;return j(function*(){if(e.isInitiator){Qr("Stage 2 - Initiator sending third handshake message.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function kB(n){return wr([n.ns,n.ciphertext],n.ns.length+n.ciphertext.length)}(t)),Qr("Stage 2 - Initiator sent message with signed payload.")}else{Qr("Stage 2 - Responder waiting for third handshake message...");const t=function FB(n){if(n.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:n.subarray(0,48),ciphertext:n.subarray(48,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Oc("xx handshake stage 2 validation fail");Qr("Stage 2 - Responder received the message, finished handshake.");try{const s=h2(r);e.remotePeer=e.remotePeer||(yield d2(s)),yield g2(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new Hd(`Error occurred while verifying signed payload: ${s.message}`)}}!function F5(n){n.cs1&&n.cs2?(qi(`CIPHER_STATE_1 ${n.cs1.n.getUint64()} ${Lt(n.cs1.k,"hex")}`),qi(`CIPHER_STATE_2 ${n.cs2.n.getUint64()} ${Lt(n.cs2.k,"hex")}`)):qi("Missing cipher state.")}(e.session)})()}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,new Uint8Array(0),e)}decrypt(e,t){const r=this.getCS(t,!1);return this.xx.decryptWithAd(r,new Uint8Array(0),e)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Oc("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=e)}}class z5{constructor(e,t,r=lB,i){this.protocol="/noise",this.earlyData=t??new Uint8Array(0),this.crypto=r,this.staticKeys=e?this.crypto.generateX25519KeyPairFromSeed(e):this.crypto.generateX25519KeyPair(),this.prologue=i??new Uint8Array(0)}secureOutbound(e,t,r){var i=this;return j(function*(){const s=qC(t,{lengthEncoder:Ud,lengthDecoder:Vd,maxDataLength:gl}),o=yield i.performHandshake({connection:s,isInitiator:!0,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteEarlyData:o.remoteEarlyData,remotePeer:o.remotePeer}})()}secureInbound(e,t,r){var i=this;return j(function*(){const s=qC(t,{lengthEncoder:Ud,lengthDecoder:Vd,maxDataLength:gl}),o=yield i.performHandshake({connection:s,isInitiator:!1,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteEarlyData:o.remoteEarlyData,remotePeer:o.remotePeer}})()}performHandshake(e){var t=this;return j(function*(){const r=yield function M5(n,e,t){return Bm.apply(this,arguments)}(e.localPeer,t.staticKeys.publicKey,t.earlyData);return yield t.performXXHandshake(e,r)})()}performXXHandshake(e,t){var r=this;return j(function*(){const{isInitiator:i,remotePeer:s,connection:o}=e,a=new G5(i,t,r.prologue,r.crypto,r.staticKeys,o,s);try{yield a.propose(),yield a.exchange(),yield a.finish()}catch(u){if(u instanceof Error)throw u.message=`Error occurred during XX handshake: ${u.message}`,u}return a})()}createSecureConnection(e,t){return j(function*(){const[r,i]=function IB(){const n=YC(),e=YC();return[{source:n.source,sink:e.sink},{source:e.source,sink:n.sink}]}(),s=e.unwrap();return yield Wn(r,function RB(n){return function(){var e=dn(function*(t){var s,r=!1,i=!1;try{for(var a,o=Pt(t);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;for(let _=0;_u.length&&(R=u.length),yield n.encrypt(u.subarray(_,R),n.session)}}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),Os({lengthEncoder:Ud}),s,ps({lengthDecoder:Vd}),function PB(n){return function(){var e=dn(function*(t){var s,r=!1,i=!1;try{for(var a,o=Pt(t);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;for(let _=0;_u.length&&(R=u.length);const{plaintext:N,valid:B}=yield lt(n.decrypt(u.subarray(_,R),n.session));if(!B)throw new Error("Failed to validate decrypted chunk");yield N}}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),r),i})()}}function fo(n){return null!=n&&"function"==typeof n.start&&"function"==typeof n.stop}function Fr(n){return null!=n&&"function"==typeof n.init}class ho{constructor(e={}){this.started=!1,null!=e.peerId&&this.setPeerId(e.peerId),null!=e.addressManager&&this.setAddressManager(e.addressManager),null!=e.peerStore&&this.setPeerStore(e.peerStore),null!=e.upgrader&&this.setUpgrader(e.upgrader),null!=e.metrics&&this.setMetrics(e.metrics),null!=e.registrar&&this.setRegistrar(e.registrar),null!=e.connectionManager&&this.setConnectionManager(e.connectionManager),null!=e.transportManager&&this.setTransportManager(e.transportManager),null!=e.connectionGater&&this.setConnectionGater(e.connectionGater),null!=e.contentRouting&&this.setContentRouting(e.contentRouting),null!=e.peerRouting&&this.setPeerRouting(e.peerRouting),null!=e.datastore&&this.setDatastore(e.datastore),null!=e.connectionProtector&&this.setConnectionProtector(e.connectionProtector),null!=e.dht&&this.setDHT(e.dht),null!=e.pubsub&&this.setPubSub(e.pubsub)}isStarted(){return this.started}beforeStart(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}()))})()}start(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){yield r.start()});return function(r){return t.apply(this,arguments)}}())),e.started=!0})()}afterStart(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}()))})()}beforeStop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}()))})()}stop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){yield r.stop()});return function(r){return t.apply(this,arguments)}}())),e.started=!1})()}afterStop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}()))})()}setPeerId(e){return this.peerId=e,e}getPeerId(){if(null==this.peerId)throw ae(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this.peerId}setMetrics(e){return this.metrics=e,Fr(e)&&e.init(this),e}getMetrics(){return this.metrics}setAddressManager(e){return this.addressManager=e,Fr(e)&&e.init(this),e}getAddressManager(){if(null==this.addressManager)throw ae(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this.addressManager}setPeerStore(e){return this.peerStore=e,Fr(e)&&e.init(this),e}getPeerStore(){if(null==this.peerStore)throw ae(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this.peerStore}setUpgrader(e){return this.upgrader=e,Fr(e)&&e.init(this),e}getUpgrader(){if(null==this.upgrader)throw ae(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this.upgrader}setRegistrar(e){return this.registrar=e,Fr(e)&&e.init(this),e}getRegistrar(){if(null==this.registrar)throw ae(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this.registrar}setConnectionManager(e){return this.connectionManager=e,Fr(e)&&e.init(this),e}getConnectionManager(){if(null==this.connectionManager)throw ae(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this.connectionManager}setTransportManager(e){return this.transportManager=e,Fr(e)&&e.init(this),e}getTransportManager(){if(null==this.transportManager)throw ae(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this.transportManager}setConnectionGater(e){return this.connectionGater=e,Fr(e)&&e.init(this),e}getConnectionGater(){if(null==this.connectionGater)throw ae(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this.connectionGater}setContentRouting(e){return this.contentRouting=e,Fr(e)&&e.init(this),e}getContentRouting(){if(null==this.contentRouting)throw ae(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this.contentRouting}setPeerRouting(e){return this.peerRouting=e,Fr(e)&&e.init(this),e}getPeerRouting(){if(null==this.peerRouting)throw ae(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this.peerRouting}setDatastore(e){return this.datastore=e,Fr(e)&&e.init(this),e}getDatastore(){if(null==this.datastore)throw ae(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this.datastore}setConnectionProtector(e){return this.connectionProtector=e,Fr(e)&&e.init(this),e}getConnectionProtector(){return this.connectionProtector}setDHT(e){return this.dht=e,Fr(e)&&e.init(this),e}getDHT(){if(null==this.dht)throw ae(new Error("dht not set"),"ERR_SERVICE_MISSING");return this.dht}setPubSub(e){return this.pubsub=e,Fr(e)&&e.init(this),e}getPubSub(){if(null==this.pubsub)throw ae(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}setDialer(e){return this.dialer=e,Fr(e)&&e.init(this),e}getDialer(){if(null==this.dialer)throw ae(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this.dialer}}class v2 extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function vs(n,e,t){const r=t??{},i=function W5(n){if(null!=n){if("function"==typeof n[Symbol.iterator])return n[Symbol.iterator]();if("function"==typeof n[Symbol.asyncIterator])return n[Symbol.asyncIterator]();if("function"==typeof n.next)return n}throw new Error("argument is not an iterator or iterable")}(n);function o(){return(o=dn(function*(){let a;const u=()=>{a?.()};for(e.addEventListener("abort",u);;){let _;try{if(e.aborted){const{abortMessage:N,abortCode:B}=r;throw new v2(N,B)}const R=new Promise((N,B)=>{a=()=>{const{abortMessage:K,abortCode:Z}=r;B(new v2(K,Z))}});_=yield lt(Promise.race([R,i.next()])),a=null}catch(R){e.removeEventListener("abort",u);const N="aborted"===R.type&&e.aborted;if(N&&null!=r.onAbort&&(yield lt(r.onAbort(n))),"function"==typeof i.return)try{const B=i.return();B instanceof Promise&&B.catch(K=>{null!=r.onReturnError&&r.onReturnError(K)})}catch(B){null!=r.onReturnError&&r.onReturnError(B)}if(N&&!0===r.returnOnAbort)return;throw R}if(!0===_.done)break;yield _.value}e.removeEventListener("abort",u)})).apply(this,arguments)}return function s(){return o.apply(this,arguments)}()}function q5(n,e,t){return r=>n(vs(r,e,t))}function zo(n,e,t){return{sink:q5(n.sink,e,{...t,onAbort:void 0}),source:vs(n.source,e,t)}}var hr=x(1732);function E2(n){return new Uint8Array(n)}var cn=(()=>(function(n){n[n.NEW_STREAM=0]="NEW_STREAM",n[n.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",n[n.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",n[n.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",n[n.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",n[n.RESET_RECEIVER=5]="RESET_RECEIVER",n[n.RESET_INITIATOR=6]="RESET_INITIATOR"}(cn||(cn={})),cn))();const $m=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),b2=Object.freeze({NEW_STREAM:cn.NEW_STREAM,MESSAGE:cn.MESSAGE_INITIATOR,CLOSE:cn.CLOSE_INITIATOR,RESET:cn.RESET_INITIATOR}),Y5=Object.freeze({MESSAGE:cn.MESSAGE_RECEIVER,CLOSE:cn.CLOSE_RECEIVER,RESET:cn.RESET_RECEIVER}),w2=new class Q5{constructor(){this._pool=E2(10240),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;hr.encode(e.id<<3|e.type,t,r),r+=hr.encode.bytes,hr.encode(e.type!==cn.NEW_STREAM&&e.type!==cn.MESSAGE_INITIATOR&&e.type!==cn.MESSAGE_RECEIVER||null==e.data?0:e.data.length,t,r),r+=hr.encode.bytes;const i=t.subarray(this._poolOffset,r);return 10240-r<100?(this._pool=E2(10240),this._poolOffset=0):this._poolOffset=r,e.type!==cn.NEW_STREAM&&e.type!==cn.MESSAGE_INITIATOR&&e.type!==cn.MESSAGE_RECEIVER||null==e.data?[i]:[i,...e.data instanceof Uint8Array?[e.data]:e.data]}};function Gm(){return Gm=dn(function*(n){var r,e=!1,t=!1;try{for(var s,i=Pt(n);e=!(s=yield lt(i.next())).done;e=!1){const o=s.value;if(Array.isArray(o))for(const a of o)yield*Mr(Pt(w2.write(a)),lt);else yield*Mr(Pt(w2.write(o)),lt)}}catch(o){t=!0,r=o}finally{try{e&&null!=i.return&&(yield lt(i.return()))}finally{if(t)throw r}}}),Gm.apply(this,arguments)}class X5{constructor(){this._buffer=new qr,this._headerInfo=null}write(e){if(null==e||0===e.length)return[];this._buffer.append(e);const t=[];for(;0!==this._buffer.length;){if(null==this._headerInfo)try{this._headerInfo=this._decodeHeader(this._buffer)}catch{break}const{id:r,type:i,length:s,offset:o}=this._headerInfo;if(this._buffer.length-o>3,type:o,offset:r+s,length:i}}}function D2(n,e=0){let s,t=0,r=0,i=e;const o=n.length;do{if(i>=o||r>49)throw e=0,new RangeError("Could not decode varint");s=n.get(i++),t+=r<28?(127&s)<=128);return{value:t,offset:e=i-e}}function eU(n){return zm.apply(this,arguments)}function zm(){return zm=dn(function*(n){const e=new X5;var i,t=!1,r=!1;try{for(var o,s=Pt(n);t=!(o=yield lt(s.next())).done;t=!1){const u=e.write(o.value);u.length>0&&(yield u)}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield lt(s.return()))}finally{if(r)throw i}}}),zm.apply(this,arguments)}const S2=1<<20;var lh=x(772);const Es=Gt("libp2p:mplex:stream"),Wm="ERR_STREAM_RESET";class oU extends Map{constructor(e){super();const{system:t,component:r,metric:i,metrics:s}=e;this.system=t??"libp2p",this.component=r,this.metric=i,this.metrics=s,this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){const t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metrics.updateComponentMetric({system:this.system,component:this.component,metric:this.metric,value:this.size})}}function Ll(n){const{system:e,component:t,metric:r,metrics:i}=n;let s;return s=null!=i?new oU({system:e,component:t,metric:r,metrics:i}):new Map,s}var aU=x(7813);const bs=Gt("libp2p:mplex");function C2(n){const e={...n,type:`${$m[n.type]} (${n.type})`};return n.type===cn.NEW_STREAM&&(e.data=Lt(n.data instanceof Uint8Array?n.data:n.data.subarray())),(n.type===cn.MESSAGE_INITIATOR||n.type===cn.MESSAGE_RECEIVER)&&(e.data=Lt(n.data instanceof Uint8Array?n.data:n.data.subarray(),"base16")),e}class dU{constructor(e,t){this.protocol="/mplex/6.7.0",t=t??{},this._streamId=0,this._streams={initiators:Ll({metrics:e.getMetrics(),component:"mplex",metric:"initiatorStreams"}),receivers:Ll({metrics:e.getMetrics(),component:"mplex",metric:"receiverStreams"})},this._init=t,this.sink=this._createSink();const r=this._createSource();this._source=r,this.source=r,this.closeController=new AbortController,this.rateLimiter=new aU.RateLimiterMemory({points:t.disconnectThreshold??5,duration:1})}init(e){}get streams(){const e=[];for(const t of this._streams.initiators.values())e.push(t);for(const t of this._streams.receivers.values())e.push(t);return e}newStream(e){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");const t=this._streamId++;return e=null==e?t.toString():e.toString(),this._newStream({id:t,name:e,type:"initiator",registry:this._streams.initiators})}close(e){this.closeController.signal.aborted||(this.streams.forEach(null!=e?t=>t.abort(e):t=>t.close()),this.closeController.abort())}_newReceiverStream(e){const{id:t,name:r}=e;return this._newStream({id:t,name:r,type:"receiver",registry:this._streams.receivers})}_newStream(e){const{id:t,name:r,type:i,registry:s}=e;if(bs("new %s stream %s %s",i,t),"initiator"===i&&this._streams.initiators.size===(this._init.maxOutboundStreams??1024))throw ae(new Error("Too many outbound streams open"),"ERR_TOO_MANY_OUTBOUND_STREAMS");if(s.has(t))throw new Error(`${i} stream ${t} already exists!`);const u=function sU(n){const{id:e,name:t,send:r,onEnd:i,type:s="initiator",maxMsgSize:o=S2}=n,a=new AbortController,u=new AbortController,_=new AbortController,R="initiator"===s?b2:Y5,N="initiator"===s?`i${e}`:`r${e}`,B=`${t??e}`;let oe,K=!1,Z=!1,J=!1;const he={open:Date.now()},ue=Oe=>{Z||(Z=!0,Es.trace("%s stream %s sink end - err: %o",s,B,Oe),null!=Oe&&null==oe&&(oe=Oe),K&&(he.close=Date.now(),i?.(oe)))},Re=Mc({onEnd:Oe=>{K||(K=!0,Es.trace("%s stream %s source end - err: %o",s,B,Oe),null!=Oe&&null==oe&&(oe=Oe),Z&&(ze.stat.timeline.close=Date.now(),i?.(oe)))}}),ze={close:()=>{Es.trace("%s stream %s close",s,B),ze.closeRead(),ze.closeWrite()},closeRead:()=>{Es.trace("%s stream %s closeRead",s,B),!K&&Re.end()},closeWrite:()=>{if(Es.trace("%s stream %s closeWrite",s,B),!Z){_.abort();try{r({id:e,type:R.CLOSE})}catch(Oe){Es.trace("%s stream %s error sending close",s,t,Oe)}ue()}},abort:Oe=>{Es.trace("%s stream %s abort",s,B,Oe),Re.end(Oe),a.abort(),ue(Oe)},reset:()=>{const Oe=ae(new Error("stream reset"),Wm);u.abort(),Re.end(Oe),ue(Oe)},sink:(Oe=j(function*(bt){if(J)throw ae(new Error("sink already called on stream"),"ERR_DOUBLE_SINK");if(J=!0,Z)throw ae(new Error("stream closed for writing"),"ERR_SINK_ENDED");bt=vs(bt,(0,lh.anySignal)([a.signal,u.signal,_.signal]));try{"initiator"===s&&r({id:e,type:b2.NEW_STREAM,data:new qr(Ot(B))});const Yn=new qr;var Bn,vt=!1,hn=!1;try{for(var Di,cr=Pt(bt);vt=!(Di=yield cr.next()).done;vt=!1)for(Yn.append(Di.value);0!==Yn.length;){if(Yn.length<=o){r({id:e,type:R.MESSAGE,data:Yn.sublist()}),Yn.consume(Yn.length);break}r({id:e,type:R.MESSAGE,data:Yn.sublist(0,o)}),Yn.consume(o)}}catch(Do){hn=!0,Bn=Do}finally{try{vt&&null!=cr.return&&(yield cr.return())}finally{if(hn)throw Bn}}}catch(Yn){if("aborted"===Yn.type&&"The operation was aborted"===Yn.message){if(_.signal.aborted)return;u.signal.aborted&&(Yn.message="stream reset",Yn.code=Wm),a.signal.aborted&&(Yn.message="stream aborted",Yn.code="ERR_STREAM_ABORT")}if(Yn.code===Wm)Es.trace("%s stream %s reset",s,t);else{Es.trace("%s stream %s error",s,t,Yn);try{r({id:e,type:R.RESET})}catch(Do){Es.trace("%s stream %s error sending reset",s,t,Do)}}return Re.end(Yn),void ue(Yn)}try{r({id:e,type:R.CLOSE})}catch(Yn){Es.trace("%s stream %s error sending close",s,t,Yn)}ue()}),function(vt){return Oe.apply(this,arguments)}),source:Re,sourcePush:Oe=>{Re.push(Oe)},sourceReadableLength:()=>Re.readableLength,stat:{direction:"initiator"===s?"outbound":"inbound",timeline:he},metadata:{},id:N};var Oe;return ze}({id:t,name:r,send:_=>{bs.enabled&&bs.trace("%s stream %s send",i,t,C2(_)),this._source.push(_)},type:i,onEnd:()=>{bs("%s stream with id %s and protocol %s ended",i,t,u.stat.protocol),s.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(u)},maxMsgSize:this._init.maxMsgSize});return s.set(t,u),u}_createSink(){var e=this;return function(){var r=j(function*(i){const s=[e.closeController.signal];null!=e._init.signal&&s.push(e._init.signal),i=vs(i,lh(s));try{yield Wn(i,eU,function tU(n){const e=n??S2,t=r=>{if((r.type===cn.NEW_STREAM||r.type===cn.MESSAGE_INITIATOR||r.type===cn.MESSAGE_RECEIVER)&&r.data.byteLength>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return r=>{return(i=dn(function*(){var u,o=!1,a=!1;try{for(var R,_=Pt(r);o=!(R=yield lt(_.next())).done;o=!1){const N=R.value;Array.isArray(N)?(N.forEach(t),yield*Mr(Pt(N),lt)):(t(N),yield N)}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield lt(_.return()))}finally{if(a)throw u}}}),function s(){return i.apply(this,arguments)})();var i}}(e._init.maxMsgSize),function(){var o=j(function*(a){var R,u=!1,_=!1;try{for(var B,N=Pt(a);u=!(B=yield N.next()).done;u=!1){const K=B.value;yield e._handleIncoming(K)}}catch(K){_=!0,R=K}finally{try{u&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()),e._source.end()}catch(o){bs("error in sink",o),e._source.end(o)}});return function(s){return r.apply(this,arguments)}}()}_createSource(){const t=function dB(n={}){return GC(t=>{let r;const i=[];for(;!t.isEmpty()&&(r=t.shift(),null!=r);){if(null!=r.error)throw r.error;!1===r.done&&i.push(r.value)}return null==r?{done:!0}:{done:!0===r.done,value:i}},n)}({objectMode:!0,onEnd:r=>{this.close(r)}});return Object.assign(function Z5(n){return Gm.apply(this,arguments)}(t),{push:t.push,end:t.end,return:t.return})}_handleIncoming(e){var t=this;return j(function*(){const{id:r,type:i}=e;if(bs.enabled&&bs.trace("incoming message",C2(e)),e.type===cn.NEW_STREAM){if(t._streams.receivers.size===(t._init.maxInboundStreams??1024)){bs("too many inbound streams open"),t._source.push({id:r,type:cn.RESET_RECEIVER});try{yield t.rateLimiter.consume("new-stream",1)}catch{return bs("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),void t._source.end(new Error("Too many open streams"))}return}const u=t._newReceiverStream({id:r,name:Lt(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=t._init.onIncomingStream&&t._init.onIncomingStream(u))}const o=(1==(1&i)?t._streams.initiators:t._streams.receivers).get(r);if(null==o)return void bs("missing stream %s for message type %s",r,$m[i]);const a=t._init.maxStreamBufferSize??4194304;switch(i){case cn.MESSAGE_INITIATOR:case cn.MESSAGE_RECEIVER:if(o.sourceReadableLength()>a){t._source.push({id:e.id,type:i===cn.MESSAGE_INITIATOR?cn.RESET_RECEIVER:cn.RESET_INITIATOR});const u=ae(new Error("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers"),"ERR_STREAM_INPUT_BUFFER_FULL");return void o.abort(u)}o.sourcePush(e.data);break;case cn.CLOSE_INITIATOR:case cn.CLOSE_RECEIVER:o.closeRead();break;case cn.RESET_INITIATOR:case cn.RESET_RECEIVER:o.reset();break;default:bs("unknown message type %s",i)}})()}}class hU{constructor(e={}){this.protocol="/mplex/6.7.0",this.components=new ho,this._init=e}init(e){this.components=e}createStreamMuxer(e={}){return new dU(this.components,{...e,...this._init})}}const pU=WebSocket;var gU=x(3676);function I2(n){return n instanceof ArrayBuffer||"ArrayBuffer"===n?.constructor?.name&&"number"==typeof n?.byteLength}const yU=n=>{n.binaryType="arraybuffer";const e=function(){var s=j(function*(){return yield new Promise((o,a)=>{if(r)return o();if(null!=i)return a(i);const u=N=>{n.removeEventListener("open",_),n.removeEventListener("error",R),N()},_=()=>u(o),R=N=>{u(()=>a(N.error??new Error(`connect ECONNREFUSED ${n.url}`)))};n.addEventListener("open",_),n.addEventListener("error",R)})});return function(){return s.apply(this,arguments)}}(),t=dn(function*(){const s=new gU.zN(({push:N,stop:B,fail:K})=>{const Z=oe=>{let he=null;"string"==typeof oe.data&&(he=Ot(oe.data)),I2(oe.data)&&(he=new Uint8Array(oe.data)),oe.data instanceof Uint8Array&&(he=oe.data),null!=he&&N(he)},J=oe=>K(oe.error??new Error("Socket error"));return n.addEventListener("message",Z),n.addEventListener("error",J),n.addEventListener("close",B),()=>{n.removeEventListener("message",Z),n.removeEventListener("error",J),n.removeEventListener("close",B)}},{highWaterMark:1/0});yield lt(e());var u,o=!1,a=!1;try{for(var R,_=Pt(s);o=!(R=yield lt(_.next())).done;o=!1){const N=R.value;yield I2(N)?new Uint8Array(N):N}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield lt(_.return()))}finally{if(a)throw u}}})();let i,r=1===n.readyState;return n.addEventListener("open",()=>{r=!0,i=null}),n.addEventListener("close",()=>{r=!1,i=null}),n.addEventListener("error",s=>{r||(i=s.error??new Error(`connect ECONNREFUSED ${n.url}`))}),Object.assign(t,{connected:e})},mU=n=>{if(n.readyState>=2)throw new Error("socket closed");if(1!==n.readyState)return new Promise((e,t)=>{function r(){n.removeEventListener("open",i),n.removeEventListener("error",s)}function i(){r(),e()}function s(o){r(),t(o.error??new Error(`connect ECONNREFUSED ${n.url}`))}n.addEventListener("open",i),n.addEventListener("error",s)})},vU=(n,e)=>((e=e??{}).closeOnEnd=!1!==e.closeOnEnd,function(){var r=j(function*(i){var a,s=!1,o=!1;try{for(var _,u=Pt(i);s=!(_=yield u.next()).done;s=!1){const R=_.value;try{yield mU(n)}catch(N){if("socket closed"===N.message)break;throw N}n.send(R)}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}if(null!=e.closeOnEnd&&n.readyState<=1)return yield new Promise((R,N)=>{n.addEventListener("close",B=>{if(B.wasClean||1006===B.code)R();else{const K=Object.assign(new Error("ws error"),{event:B});N(K)}}),setTimeout(()=>n.close())})});return function(s){return r.apply(this,arguments)}}()),EU=(n,e)=>{e=e??{};const t=yU(n);let r=e.remoteAddress,i=e.remotePort;if(null!=n.url)try{const o=new URL(n.url);r=o.hostname,i=parseInt(o.port,10)}catch{}if(null==r||null==i)throw new Error("Remote connection did not have address and/or port");return{sink:vU(n,e),source:t,connected:(o=j(function*(){return yield t.connected()}),function(){return o.apply(this,arguments)}),close:function(){var o=j(function*(){(n.readyState===n.CONNECTING||n.readyState===n.OPEN)&&(yield new Promise(a=>{n.addEventListener("close",()=>{a()}),n.close()}))});return function(){return o.apply(this,arguments)}}(),destroy:()=>{null!=n.terminate?n.terminate():n.close()},remoteAddress:r,remotePort:i,socket:n};var o};var bU=x(8596);const wU={http:"ws",https:"wss"};const T2="[a-fA-F\\d:]",Wo=n=>n&&n.includeBoundaries?`(?:(?<=\\s|^)(?=${T2})|(?<=${T2})(?=\\s|$))`:"",ws="(?: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}",Dr="[a-fA-F\\d]{1,4}",fh=`\n(?:\n(?:${Dr}:){7}(?:${Dr}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${Dr}:){6}(?:${ws}|:${Dr}|:)| // 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\n(?:${Dr}:){5}(?::${ws}|(?::${Dr}){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\n(?:${Dr}:){4}(?:(?::${Dr}){0,1}:${ws}|(?::${Dr}){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\n(?:${Dr}:){3}(?:(?::${Dr}){0,2}:${ws}|(?::${Dr}){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\n(?:${Dr}:){2}(?:(?::${Dr}){0,3}:${ws}|(?::${Dr}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${Dr}:){1}(?:(?::${Dr}){0,4}:${ws}|(?::${Dr}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${Dr}){0,5}:${ws}|(?::${Dr}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),CU=new RegExp(`(?:^${ws}$)|(?:^${fh}$)`),IU=new RegExp(`^${ws}$`),TU=new RegExp(`^${fh}$`),qm=n=>n&&n.exact?CU:new RegExp(`(?:${Wo(n)}${ws}${Wo(n)})|(?:${Wo(n)}${fh}${Wo(n)})`,"g");qm.v4=n=>n&&n.exact?IU:new RegExp(`${Wo(n)}${ws}${Wo(n)}`,"g"),qm.v6=n=>n&&n.exact?TU:new RegExp(`${Wo(n)}${fh}${Wo(n)}`,"g");const Ym=qm,{toString:RU}=Object.prototype,A2={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Qm(n,e,{}={}){try{return function AU(n){const e=(...t)=>n(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${n.name||""})`,configurable:!0}),e}(()=>function NU(n,e={}){if(!function PU(n){return"[object RegExp]"===RU.call(n)}(n))throw new TypeError("Expected a RegExp instance");const t=Object.keys(A2).map(i=>("boolean"==typeof e[i]?e[i]:n[i])?A2[i]:"").join(""),r=new RegExp(e.source||n.source,t);return r.lastIndex="number"==typeof e.lastIndex?e.lastIndex:n.lastIndex,r}(n).test(e))()}catch(r){throw r}}const Zm={timeout:400};function Xm(n){return Qm(Ym({exact:!0}),n.slice(0,45),Zm)}const N2=function OU(n){return Qm(Ym.v4({exact:!0}),n.slice(0,15),Zm)},kU=function P2(n){return Qm(Ym.v6({exact:!0}),n.slice(0,45),Zm)},M2=function(n){let t,e=0;if(n=n.trim(),N2(n))t=new Uint8Array(e+4),n.split(/\./g).forEach(r=>{t[e++]=255&parseInt(r,10)});else if(kU(n)){const r=n.split(":",8);let i;for(i=0;i0;i--)s.push("0");r.splice.apply(r,s)}for(t=new Uint8Array(e+16),i=0;i>8&255,t[e++]=255&s}}if(null==t)throw new Error(`invalid ip address "${n}"`);return t},_s=-1,dh={},Jm={};function Sr(n){if("number"==typeof n){if(null!=Jm[n])return Jm[n];throw new Error(`no protocol with code: ${n}`)}if("string"==typeof n){if(null!=dh[n])return dh[n];throw new Error(`no protocol with name: ${n}`)}throw new Error("invalid protocol id type: "+typeof n)}function O2(n,e){switch(Sr(n).code){case 4:case 41:return function UU(n){const e=function(n,e=0,t){e=~~e,t=t??n.length-e;const r=[];let i="";const s=new DataView(n.buffer);if(4===t){for(let o=0;o65536)throw new Error("Port number is not in range(1, 65536)");const i=tv(r);return wr([t,i],t.length+i.length)}(e);case 445:return function WU(n){const e=n.split(":");if(2!==e.length)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(56!==e[0].length)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);const t=co.decode(`b${e[0]}`),r=parseInt(e[1],10);if(r<1||r>65536)throw new Error("Port number is not in range(1, 65536)");const i=tv(r);return wr([t,i],t.length+i.length)}(e);case 466:return function $U(n){const e=FU.decode(n),t=Uint8Array.from(hr.encode(e.length));return wr([t,e],t.length+e.length)}(e);default:return Ot(e,"base16")}}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,_s,"ip6zone"],[53,_s,"dns",!0],[54,_s,"dns4",!0],[55,_s,"dns6",!0],[56,_s,"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"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,_s,"unix",!1,!0],[421,_s,"ipfs"],[421,_s,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,_s,"garlic64"],[460,0,"quic"],[466,_s,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,_s,"memory"]].forEach(n=>{const e=function BU(n,e,t,r,i){return{code:n,size:e,name:t,resolvable:Boolean(r),path:Boolean(i)}}(...n);Jm[e.code]=e,dh[e.name]=e});const ev=Object.values(El).map(n=>n.decoder),FU=function(){let n=ev[0].or(ev[1]);return ev.slice(2).forEach(e=>n=n.or(e)),n}();function tv(n){const e=new ArrayBuffer(2);return new DataView(e).setUint16(0,n),new Uint8Array(e)}function B2(n){return new DataView(n.buffer).getUint16(n.byteOffset)}function U2(n){return n.map(e=>{const t=ph(e);return null!=e[1]?[t.code,O2(t.code,e[1])]:[t.code]})}function V2(n){return rv(wr(n.map(e=>{const t=ph(e);let r=Uint8Array.from(hr.encode(t.code));return e.length>1&&null!=e[1]&&(r=wr([r,e[1]])),r})))}function H2(n,e){return n.size>0?n.size/8:0===n.size?0:hr.decode(e)+hr.decode.bytes}function hh(n){const e=[];let t=0;for(;tn.length)throw $2("Invalid address Uint8Array: "+Lt(n,"base16"));e.push([r,a])}return e}function nv(n){return function YU(n){const e=[];return n.map(t=>{const r=ph(t);return e.push(r.name),t.length>1&&null!=t[1]&&e.push(t[1]),null}),iv(e.join("/"))}(U2(hh(n)))}function rv(n){const e=function K2(n){try{hh(n)}catch(e){return e}}(n);if(null!=e)throw e;return Uint8Array.from(n)}function iv(n){return"/"+n.trim().split("/").filter(e=>e).join("/")}function $2(n){return new Error("Error parsing address: "+n)}function ph(n){return Sr(n[0])}const JU=Symbol.for("nodejs.util.inspect.custom"),j2=[Sr("dns").code,Sr("dns4").code,Sr("dns6").code,Sr("dnsaddr").code],eV=[Sr("p2p").code,Sr("ipfs").code],G2=new Map,z2=Symbol.for("@multiformats/js-multiaddr/multiaddr");let yn=(()=>{class n{constructor(t){if(null==t&&(t=""),Object.defineProperty(this,z2,{value:!0}),t instanceof Uint8Array)this.bytes=rv(t);else if("string"==typeof t){if(t.length>0&&"/"!==t.charAt(0))throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=function XU(n){return function ZU(n){const e=function qU(n){const e=[],t=n.split("/").slice(1);if(1===t.length&&""===t[0])return[];for(let r=0;r=t.length)throw $2("invalid address: "+n);if(!0===s.path){e.push([i,iv(t.slice(r).join("/"))]);break}e.push([i,t[r]])}else e.push([i])}return e}(n=iv(n)),t=function QU(n){return n.map(e=>{Array.isArray(e)||(e=[e]);const t=ph(e);return e.length>1?[t.code,k2(t.code,e[1])]:[t.code]})}(e);return V2(t)}(n)}(t)}else{if(!n.isMultiaddr(t))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=rv(t.bytes)}}toString(){return nv(this.bytes)}toJSON(){return this.toString()}toOptions(){const t=this.protoCodes(),r=this.toString().split("/").slice(1);let i,s;if(r.length>2)j2.includes(t[0])&&eV.includes(t[1])?(i=Sr("tcp").name,s=443):(i=Sr(r[2]).name,s=parseInt(r[3]));else{if(!j2.includes(t[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');i=Sr("tcp").name,s=443}return{family:41===t[0]||55===t[0]?6:4,host:r[1],transport:i,port:s}}protos(){return this.protoCodes().map(t=>Object.assign({},Sr(t)))}protoCodes(){const t=[],r=this.bytes;let i=0;for(;it.name)}tuples(){return hh(this.bytes)}stringTuples(){return U2(hh(this.bytes))}encapsulate(t){return t=new n(t),new n(this.toString()+t.toString())}decapsulate(t){const r=t.toString(),i=this.toString(),s=i.lastIndexOf(r);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new n(i.slice(0,s))}decapsulateCode(t){const r=this.tuples();for(let i=r.length-1;i>=0;i--)if(r[i][0]===t)return new n(V2(r.slice(0,i)));return this}getPeerId(){try{const r=this.stringTuples().filter(i=>i[0]===dh.ipfs.code).pop();if(null!=r?.[1]){const i=r[1];return Lt("Q"===i[0]||"1"===i[0]?ui.decode(`z${i}`):_r.parse(i).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(r=>!0===Sr(r[0]).path)[0][1],null==t&&(t=null)}catch{t=null}return t}equals(t){return kr(this.bytes,t.bytes)}resolve(t){var r=this;return j(function*(){const i=r.protos().find(a=>a.resolvable);if(null==i)return[r];const s=G2.get(i.name);if(null==s)throw ae(new Error(`no available resolver for ${i.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(yield s(r,t)).map(a=>new n(a))})()}nodeAddress(){const t=this.toOptions();if("tcp"!==t.transport&&"udp"!==t.transport)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){const r=(t??this).protos();return!(2!==r.length||4!==r[0].code&&41!==r[0].code||6!==r[1].code&&273!==r[1].code)}static fromNodeAddress(t,r){if(null==t)throw new Error("requires node address object");if(null==r)throw new Error("requires transport protocol");let i;switch(t.family){case 4:i="ip4";break;case 6:i="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new n("/"+[i,t.address,r,t.port].join("/"))}static isName(t){return!!n.isMultiaddr(t)&&t.protos().some(r=>r.resolvable)}static isMultiaddr(t){return Boolean(t?.[z2])}[JU](){return""}inspect(){return""}}return n.resolvers=G2,n})();const gh=(n,e)=>e,rV={ip4:gh,ip6:(n,e,t,r)=>1===r.length&&"ip6"===r[0].protocol?e:`[${e}]`,tcp:(n,e,t,r,i)=>r.some(s=>["http","https","ws","wss"].includes(s.protocol))?`${n}:${e}`:((n,e,t,r)=>{if(null!=r&&!1===r.assumeHttp)return`tcp://${n}:${e}`;let i="tcp",s=`:${e}`;return"tcp"===t[t.length-1].protocol&&(i="443"===e?"https":"http",s="443"===e||"80"===e?"":s),`${i}://${n}${s}`})(n,e,r,i),udp:(n,e)=>`udp://${n}:${e}`,dnsaddr:gh,dns4:gh,dns6:gh,ipfs:(n,e)=>`${n}/ipfs/${e}`,p2p:(n,e)=>`${n}/p2p/${e}`,http:n=>`http://${n}`,https:n=>`https://${n}`,ws:n=>`ws://${n}`,wss:n=>`wss://${n}`,"p2p-websocket-star":n=>`${n}/p2p-websocket-star`,"p2p-webrtc-star":n=>`${n}/p2p-webrtc-star`,"p2p-webrtc-direct":n=>`${n}/p2p-webrtc-direct`};class eu extends Error{constructor(e="The operation was aborted"){super(e),this.code=eu.code,this.type=eu.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}}var sV=x(9456);const sv="object"==typeof window&&"object"==typeof document&&9===document.nodeType,yh=sV(),mh=sv&&!yh,oV=yh&&!sv,aV=yh&&sv,cV=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&"node"===globalThis.process.release.name&&!yh,W2="function"==typeof importScripts&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,uV=(typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis,typeof navigator<"u"&&"ReactNative"===navigator.product);class pV extends Error{constructor(e){super(e),this.name="TimeoutError"}}class gV extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Q2=n=>void 0===globalThis.DOMException?new gV(n):new DOMException(n),Z2=n=>{const e=void 0===n.reason?Q2("This operation was aborted."):n.reason;return e instanceof Error?e:Q2(e)},X2=Gt("libp2p:websockets:socket");const vV=It("dns4"),EV=It("dns6"),bV=It("dnsaddr"),Ca=Zr(It("dns"),bV,vV,EV),vh=Zr(It("ip4"),It("ip6")),Bl=Zr(Jt(vh,It("tcp")),Jt(Ca,It("tcp"))),J2=Jt(vh,It("udp")),wV=Jt(J2,It("utp")),_V=Jt(J2,It("quic")),tu=Zr(Jt(Bl,It("ws")),Jt(Ca,It("ws"))),Ia=Zr(Jt(Bl,It("wss")),Jt(Ca,It("wss"))),ov=Zr(Jt(Bl,It("http")),Jt(vh,It("http")),Jt(Ca,It("http"))),av=Zr(Jt(Bl,It("https")),Jt(vh,It("https")),Jt(Ca,It("https"))),eT=Zr(Jt(tu,It("p2p-webrtc-star"),It("p2p")),Jt(Ia,It("p2p-webrtc-star"),It("p2p")),Jt(tu,It("p2p-webrtc-star")),Jt(Ia,It("p2p-webrtc-star"))),tT=(Zr(Jt(tu,It("p2p-websocket-star"),It("p2p")),Jt(Ia,It("p2p-websocket-star"),It("p2p")),Jt(tu,It("p2p-websocket-star")),Jt(Ia,It("p2p-websocket-star"))),Zr(Jt(ov,It("p2p-webrtc-direct"),It("p2p")),Jt(av,It("p2p-webrtc-direct"),It("p2p")),Jt(ov,It("p2p-webrtc-direct")),Jt(av,It("p2p-webrtc-direct")))),Fl=Zr(tu,Ia,ov,av,eT,tT,Bl,wV,_V,Ca),qo=(Zr(Jt(Fl,It("p2p-stardust"),It("p2p")),Jt(Fl,It("p2p-stardust"))),Zr(Jt(Fl,It("p2p")),eT,tT,It("p2p"))),nT=Zr(Jt(qo,It("p2p-circuit"),qo),Jt(qo,It("p2p-circuit")),Jt(It("p2p-circuit"),qo),Jt(Fl,It("p2p-circuit")),Jt(It("p2p-circuit"),Fl),It("p2p-circuit")),rT=()=>Zr(Jt(nT,rT),nT),nu=rT();function iT(n){return function e(t){let r;try{r=new yn(t)}catch{return!1}const i=n(r.protoNames());return null!==i&&(!0===i||!1===i?i:0===i.length)}}function Jt(...n){function e(t){if(t.length(r="function"==typeof i?i().partialMatch(t):i.partialMatch(t),Array.isArray(r)&&(t=r),null===r)),r}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:iT(e),partialMatch:e}}function Zr(...n){function e(r){let i=null;return n.some(s=>{const o="function"==typeof s?s().partialMatch(r):s.partialMatch(r);return null!=o&&(i=o,!0)}),i}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:iT(e),partialMatch:e}}function It(n){const e=n;return{toString:function(){return e},matches:function t(i){let s;try{s=new yn(i)}catch{return!1}const o=s.protoNames();return 1===o.length&&o[0]===e},partialMatch:function r(i){return 0===i.length?null:i[0]===e?i.slice(1):null}}}function sT(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return tu.matches(t)||Ia.matches(t)})}Zr(Jt(nu,qo,nu),Jt(qo,nu),Jt(nu,qo),nu,qo);const cv=Symbol.for("@libp2p/transport"),Yo=Gt("libp2p:websockets");class SV{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[cv](){return!0}dial(e,t){var r=this;return j(function*(){Yo("dialing %s",e),t=t??{};const s=function mV(n,e,t){const r={sink:i=>j(function*(){null!=t?.signal&&(i=vs(i,t.signal));try{yield n.sink(i)}catch(s){"aborted"!==s.type&&X2.error(s)}})(),source:null!=(t=t??{}).signal?vs(n.source,t.signal):n.source,remoteAddr:e,timeline:{open:Date.now()},close:()=>j(function*(){const i=Date.now();try{yield function yV(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((u,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(Z2(R)),R.addEventListener("abort",()=>{_(Z2(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{u(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new pV("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),j(function*(){try{u(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else u(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}(n.close(),{milliseconds:2e3})}catch{const{host:o,port:a}=r.remoteAddr.toOptions();X2("timeout closing stream to %s:%s after %dms, destroying it manually",o,a,Date.now()-i),n.destroy()}finally{r.timeline.close=Date.now()}})()};return null!=n.socket.once&&n.socket.once("close",()=>{null==r.timeline.close&&(r.timeline.close=Date.now())}),r}(yield r._connect(e,t),e);Yo("new outbound connection %s",s.remoteAddr);const o=yield t.upgrader.upgradeOutbound(s);return Yo("outbound connection %s upgraded",s.remoteAddr),o})()}_connect(e,t){var r=this;return j(function*(){if(!0===t?.signal?.aborted)throw new eu;const i=e.toOptions();Yo("dialing %s:%s",i.host,i.port);const s=w0(),o=R=>{Yo.error("connection error:",R),s.reject(R)},a=function SU(n,e){e=e??{};const r=((n,e)=>(0,bU.relative)(n,e,wU,"ws"))(n,(typeof window>"u"?"":window.location).toString()),i=new pU(r,e.websocket);return EU(i,e)}(function iV(n,e){const t=new yn(n),r=n.toString().split("/").slice(1);return t.tuples().map(i=>({protocol:r.shift()??"",content:null!=i[1]?r.shift()??"":""})).reduce((i,s,o,a)=>{const u=rV[s.protocol];if(null==u)throw new Error(`Unsupported protocol ${s.protocol}`);return u(i,s.content,o,a,e)},"")}(e),r.init);if(null!=a.socket.on?a.socket.on("error",o):a.socket.onerror=o,null==t.signal)return yield Promise.race([a.connected(),s.promise]),Yo("connected %s",e),a;let u;const _=new Promise((R,N)=>{if(u=()=>{N(new eu),setTimeout(()=>{a.close().catch(B=>{Yo.error("error closing raw socket",B)})})},!0===t?.signal?.aborted)return u();t?.signal?.addEventListener("abort",u)});try{yield Promise.race([_,s.promise,a.connected()])}finally{null!=u&&t?.signal?.removeEventListener("abort",u)}return Yo("connected %s",e),a})()}createListener(e){return function lV(){throw new Error("WebSocket Servers can not be created in the browser!")}()}filter(e){return e=Array.isArray(e)?e:[e],null!=this.init?.filter?this.init?.filter(e):mh||W2?function DV(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return Ia.matches(t)&&Ca.matches(t.decapsulateCode(6).decapsulateCode(478))})}(e):sT(e)}}var po,Ta=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class Ei extends EventTarget{constructor(){super(...arguments),po.set(this,new Map)}listenerCount(e){const t=Ta(this,po,"f").get(e);return null==t?0:t.length}addEventListener(e,t,r){super.addEventListener(e,t,r);let i=Ta(this,po,"f").get(e);null==i&&(i=[],Ta(this,po,"f").set(e,i)),i.push({callback:t,once:(!0!==r&&!1!==r&&r?.once)??!1})}removeEventListener(e,t,r){super.removeEventListener(e.toString(),t??null,r);let i=Ta(this,po,"f").get(e);null!=i&&(i=i.filter(({callback:s})=>s!==t),Ta(this,po,"f").set(e,i))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=Ta(this,po,"f").get(e.type);return null==r||(r=r.filter(({once:i})=>!i),Ta(this,po,"f").set(e.type,r)),t}}po=new WeakMap;class CV extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}}const tn=globalThis.CustomEvent??CV;var Ul=x(5357);const oT=(n,e)=>dn(function*(){const t=yield lt(Ul(n));yield*Mr(Pt(t.sort(e)),lt)})();var Qo=x(7414),Ds=x(6225),aT=x(0);const go="/",cT=(new TextEncoder).encode(go),Eh=cT[0];class Ur{constructor(e,t){if("string"==typeof e)this._buf=Ot(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==Eh)throw new Error("Invalid key")}toString(e="utf8"){return Lt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Ur(e.join(go))}static random(){return new Ur(((n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||"string"==typeof e?new Ur(e):"function"==typeof e.uint8Array?new Ur(e.uint8Array()):null}clean(){if((null==this._buf||0===this._buf.byteLength)&&(this._buf=cT),this._buf[0]!==Eh){const e=new Uint8Array(this._buf.byteLength+1);e.fill(Eh,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Eh;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let i=0;io)return!1}return t.lengtht.namespaces()))])}}function NV(n){return[].concat(...n)}class OV extends class IV{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}putMany(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const{key:_,value:R}=u.value;yield lt(r.put(_,R,t)),yield{key:_,value:R}}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}getMany(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;yield r.get(_,t)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}deleteMany(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;yield lt(r.delete(_,t)),yield _}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}batch(){var e=this;let t=[],r=[];return{put(i,s){t.push({key:i,value:s})},delete(i){r.push(i)},commit:(i=j(function*(s){yield Qo(e.putMany(t,s)),t=[],yield Qo(e.deleteMany(r,s)),r=[]}),function(o){return i.apply(this,arguments)})};var i}_all(e,t){return dn(function*(){throw new Error("._all is not implemented")})()}_allKeys(e,t){return dn(function*(){throw new Error("._allKeys is not implemented")})()}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>oT(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=aT(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>oT(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=aT(r,e.limit)),r}}{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}put(e,t){var r=this;return j(function*(){r.data[e.toString()]=t})()}get(e){var t=this;return j(function*(){if(!(yield t.has(e)))throw function MV(n){return n=n||new Error("Not Found"),ae(n,"ERR_NOT_FOUND")}();return t.data[e.toString()]})()}has(e){var t=this;return j(function*(){return void 0!==t.data[e.toString()]})()}delete(e){var t=this;return j(function*(){delete t.data[e.toString()]})()}_all(){var e=this;return dn(function*(){yield*Mr(Pt(Object.entries(e.data).map(([t,r])=>({key:new Ur(t),value:r}))),lt)})()}_allKeys(){var e=this;return dn(function*(){yield*Mr(Pt(Object.entries(e.data).map(([t])=>new Ur(t))),lt)})()}}var _n=(()=>(function(n){n.NOT_STARTED_YET="The libp2p node is not started yet",n.DHT_DISABLED="DHT is not available",n.PUBSUB_DISABLED="PubSub is not available",n.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",n.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",n.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",n.NOT_FOUND="Not found"}(_n||(_n={})),_n))(),Ce=(()=>(function(n){n.DHT_DISABLED="ERR_DHT_DISABLED",n.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",n.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",n.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",n.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",n.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",n.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",n.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",n.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",n.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",n.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",n.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",n.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",n.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",n.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",n.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",n.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",n.ERR_DIALED_SELF="ERR_DIALED_SELF",n.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",n.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",n.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",n.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",n.ERR_INVALID_KEY="ERR_INVALID_KEY",n.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",n.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",n.ERR_INVALID_PEER="ERR_INVALID_PEER",n.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",n.ERR_NOT_FOUND="ERR_NOT_FOUND",n.ERR_TIMEOUT="ERR_TIMEOUT",n.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",n.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",n.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",n.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",n.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",n.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",n.ERR_FIND_SELF="ERR_FIND_SELF",n.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",n.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",n.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",n.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",n.ERR_INVALID_CMS="ERR_INVALID_CMS",n.ERR_MISSING_KEYS="ERR_MISSING_KEYS",n.ERR_NO_KEY="ERR_NO_KEY",n.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",n.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",n.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",n.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",n.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",n.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",n.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",n.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",n.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",n.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",n.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",n.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",n.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",n.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",n.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",n.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",n.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",n.ERR_INVALID_RECORD="ERR_INVALID_RECORD",n.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",n.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",n.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",n.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS"}(Ce||(Ce={})),Ce))(),uv=x(6930);function lv(n,e){return fv.apply(this,arguments)}function fv(){return fv=dn(function*(n,e){yield*Mr(Pt(uv(n,function(){var t=j(function*(r){return yield e.addressBook.add(r.id,r.multiaddrs),r});return function(r){return t.apply(this,arguments)}}())),lt)}),fv.apply(this,arguments)}function uT(n){const e=new Set;return Ds(n,t=>!e.has(t.id.toString())&&(e.add(t.id.toString()),!0))}function lT(n){return dv.apply(this,arguments)}function dv(){return dv=dn(function*(n,e=1){let t=0;var s,r=!1,i=!1;try{for(var a,o=Pt(n);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;t++,yield u}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}if(tdn(function*(){try{yield yield lt(s.findPeer(e,t))}catch(o){fT.error(o)}})())),s=>Ds(s,Boolean),s=>lv(s,r.components.getPeerStore()),function(){var s=j(function*(o){return yield Aa(o)});return function(o){return s.apply(this,arguments)}}());if(null!=i)return i;throw ae(new Error(_n.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getClosestPeers(e,t){var r=this;return dn(function*(){if(0===r.routers.length)throw ae(new Error("No peer routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield*Mr(Pt(Wn(Fd(...r.routers.map(i=>i.getClosestPeers(e,t))),i=>lv(i,r.components.getPeerStore()),i=>uT(i),i=>lT(i))),lt)})()}}class LV{constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started=!0})()}stop(){var e=this;return j(function*(){e.started=!1})()}findProviders(e,t={}){var r=this;return dn(function*(){if(0===r.routers.length)throw ae(new Error("No content this.routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield*Mr(Pt(Wn(Fd(...r.routers.map(i=>i.findProviders(e,t))),i=>lv(i,r.components.getPeerStore()),i=>uT(i),i=>lT(i))),lt)})()}provide(e,t={}){var r=this;return j(function*(){if(0===r.routers.length)throw ae(new Error("No content routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield Promise.all(r.routers.map(function(){var i=j(function*(s){return yield s.provide(e,t)});return function(s){return i.apply(this,arguments)}}()))})()}put(e,t,r){var i=this;return j(function*(){if(!i.isStarted())throw ae(new Error(_n.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);const s=i.components.getDHT();null!=s&&(yield Qo(s.put(e,t,r)))})()}get(e,t){var r=this;return j(function*(){if(!r.isStarted())throw ae(new Error(_n.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);const i=r.components.getDHT();if(null!=i){var a,s=!1,o=!1;try{for(var _,u=Pt(i.get(e,t));s=!(_=yield u.next()).done;s=!1){const R=_.value;if("VALUE"===R.name)return R.value}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}}throw ae(new Error(_n.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getMany(e,t,r){var i=this;return dn(function*(){if(!i.isStarted())throw ae(new Error(_n.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);if(null==t||0===t)return;let s=0;const o=i.components.getDHT();if(null!=o){var _,a=!1,u=!1;try{for(var N,R=Pt(o.get(e,r));a=!(N=yield lt(R.next())).done;a=!1){const B=N.value;if("VALUE"===B.name&&(yield{from:B.from,val:B.value},s++,s===t))break}}catch(B){u=!0,_=B}finally{try{a&&null!=R.return&&(yield lt(R.return()))}finally{if(u)throw _}}}if(0===s)throw ae(new Error(_n.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}}function Vl(n){if(c2(n))return{id:n,multiaddrs:[],protocols:[]};let e;return"string"==typeof n&&(n=new yn(n)),yn.isMultiaddr(n)&&(e=n,n=function BV(n){const e=n.getPeerId();if(null==e)throw ae(new Error(`${n.toString()} does not have a valid peer type`),Ce.ERR_INVALID_MULTIADDR);try{return fr(e)}catch{throw ae(new Error(`${n.toString()} is not a valid peer type`),Ce.ERR_INVALID_MULTIADDR)}}(n)),{id:n,multiaddrs:null!=e?[e]:[],protocols:[]}}const FV=n=>n;class UV extends Ei{constructor(e,t){super();const{listen:r=[],announce:i=[]}=t;this.components=e,this.listen=new Set(r.map(s=>s.toString())),this.announce=new Set(i.map(s=>s.toString())),this.observed=new Set,this.announceFilter=t.announceFilter??FV}getListenAddrs(){return Array.from(this.listen).map(e=>new yn(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>new yn(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>new yn(e))}addObservedAddr(e){let t=new yn(e);const r=t.getPeerId();null!=r&&fr(r).equals(this.components.getPeerId())&&(t=t.decapsulate(new yn(`/p2p/${this.components.getPeerId().toString()}`)));const i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new tn("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(r=>r.toString());0===e.length&&(e=this.components.getTransportManager().getAddrs().map(r=>r.toString())),e=e.concat(this.getObservedAddrs().map(r=>r.toString()));const t=new Set(e);return this.announceFilter(Array.from(t).map(r=>new yn(r))).map(r=>r.getPeerId()===this.components.getPeerId().toString()?r:r.encapsulate(`/p2p/${this.components.getPeerId().toString()}`))}}const Hl=x(7820),dT=Gt("libp2p:connection-manager:latency-monitor:visibility-change-emitter");class HV extends Ei{constructor(){super(),this.hidden="hidden",this.visibilityChange="visibilityChange",null!=globalThis.document&&(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener())}_initializeVisibilityVarNames(){let e="hidden",t="visibilitychange";typeof globalThis.document.hidden<"u"?(e="hidden",t="visibilitychange"):typeof globalThis.document.mozHidden<"u"?(e="mozHidden",t="mozvisibilitychange"):typeof globalThis.document.msHidden<"u"?(e="msHidden",t="msvisibilitychange"):typeof globalThis.document.webkitHidden<"u"&&(e="webkitHidden",t="webkitvisibilitychange"),this.hidden=e,this.visibilityChange=t}_addVisibilityChangeListener(){typeof globalThis.document.addEventListener>"u"||typeof document[this.hidden]>"u"?dT("Checking page visibility requires a browser that supports the Page Visibility API."):globalThis.document.addEventListener(this.visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(void 0!==this.hidden&&void 0!==document[this.hidden])return null==document[this.hidden]}_handleVisibilityChange(){const e=!1===globalThis.document[this.hidden];dT(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new tn("visibilityChange",{detail:e}))}}const yo=Gt("libp2p:connection-manager:latency-monitor");class KV extends Ei{constructor(e={}){super();const{latencyCheckIntervalMs:t,dataEmitIntervalMs:r,asyncTestFn:i,latencyRandomPercentage:s}=e;this.latencyCheckIntervalMs=t??500,this.latencyRandomPercentage=s??10,this.latencyCheckMultiply=this.latencyRandomPercentage/100*2*this.latencyCheckIntervalMs,this.latencyCheckSubtract=this.latencyCheckMultiply/2,this.dataEmitIntervalMs=null===r||0===r?void 0:r??5e3,yo("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),null!=this.dataEmitIntervalMs?yo("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):yo("Not emitting summaries"),this.asyncTestFn=i,null!=globalThis.process?.hrtime?(yo("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=o=>{const a=this.now(o);return 1e3*a[0]+a[1]/1e6}):typeof window<"u"&&null!=window.performance?.now?(yo("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(yo("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){(function $V(){return typeof globalThis.window<"u"})()&&(this.visibilityChangeEmitter=new HV,this.visibilityChangeEmitter.addEventListener("visibilityChange",e=>{const{detail:t}=e;t?this._startTimers():(this._emitSummary(),this._stopTimers())})),!0===this.visibilityChangeEmitter?.isVisible()&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){null==this.checkLatencyID&&(this.checkLatency(),null!=this.dataEmitIntervalMs&&(this.emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),"function"==typeof this.emitIntervalID.unref&&this.emitIntervalID.unref()))}_stopTimers(){null!=this.checkLatencyID&&(clearTimeout(this.checkLatencyID),this.checkLatencyID=void 0),null!=this.emitIntervalID&&(clearInterval(this.emitIntervalID),this.emitIntervalID=void 0)}_emitSummary(){const e=this.getSummary();e.events>0&&this.dispatchEvent(new tn("data",{detail:e}))}getSummary(){const e={events:this.latencyData.events,minMs:this.latencyData.minMs,maxMs:this.latencyData.maxMs,avgMs:this.latencyData.events>0?this.latencyData.totalMs/this.latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this.latencyData.startTime)};return this.latencyData=this.initLatencyData(),yo.trace("Summary: %O",e),e}checkLatency(){const e=Math.random()*this.latencyCheckMultiply-this.latencyCheckSubtract,t={deltaOffset:Math.ceil(this.latencyCheckIntervalMs+e),startTime:this.now()},r=()=>{if(null==this.checkLatencyID)return;const i=this.getDeltaMS(t.startTime)-t.deltaOffset;this.checkLatency(),this.latencyData.events++,this.latencyData.minMs=Math.min(this.latencyData.minMs,i),this.latencyData.maxMs=Math.max(this.latencyData.maxMs,i),this.latencyData.totalMs+=i,yo.trace("MS: %s Data: %O",i,this.latencyData)};yo.trace("localData: %O",t),this.checkLatencyID=setTimeout(()=>{null!=this.asyncTestFn?(t.deltaOffset=0,t.startTime=this.now(),this.asyncTestFn(r)):(t.deltaOffset-=1,r())},t.deltaOffset),"function"==typeof this.checkLatencyID.unref&&this.checkLatencyID.unref()}initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}var Kl=x(2502);const pT="CLOSING",hv="CLOSED";var jV=x(8614);const gT=Gt("libp2p:dialer:dial-request");class GV{constructor(e){const{addrs:t,dialAction:r,dialer:i}=e;this.addrs=t,this.dialer=i,this.dialAction=r}run(e={}){var t=this;return j(function*(){const r=t.dialer.getTokens(t.addrs.length);if(r.length<1)throw ae(new Error("No dial tokens available"),Ce.ERR_NO_DIAL_TOKENS);const i=new jV;for(const u of r)i.push(u).catch(_=>{gT.error(_)});const s=t.addrs.map(()=>{const u=new AbortController;try{(0,Vr.setMaxListeners)?.(1/0,u.signal)}catch{}return u});if(null!=e.signal)try{(0,Vr.setMaxListeners)?.(1/0,e.signal)}catch{}let o=0,a=!1;try{return yield Promise.any(t.addrs.map(function(){var u=j(function*(_,R){const N=yield i.shift();if(a)throw t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0]),ae(new Error("dialAction already succeeded"),Ce.ERR_ALREADY_SUCCEEDED);const B=s[R];if(null==B)throw ae(new Error("dialAction did not come with an AbortController"),Ce.ERR_INVALID_PARAMETERS);let K;try{const Z=B.signal;K=yield t.dialAction(_,{...e,signal:null!=e.signal?(0,lh.anySignal)([Z,e.signal]):Z}),s[R]=void 0}finally{o++,t.addrs.length-o>=r.length?i.push(N).catch(Z=>{gT.error(Z)}):t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0])}if(null==K)throw ae(new Error("dialAction led to empty object"),Ce.ERR_TRANSPORT_DIAL_FAILED);return a=!0,K});return function(_,R){return u.apply(this,arguments)}}()))}finally{s.forEach(u=>{void 0!==u&&u.abort()}),r.forEach(u=>t.dialer.releaseToken(u))}})()}}var yT=x(4108);function mT(n){const{address:e}=n.nodeAddress();return Boolean(yT(e))}function pv(n,e){const t=mT(n.multiaddr),r=mT(e.multiaddr);return t&&!r?1:!t&&r||n.isCertified&&!e.isCertified?-1:!n.isCertified&&e.isCertified?1:0}var gv=x(4297);const Fs=Gt("libp2p:dialer"),wT="dialler";class ZV{constructor(e={}){this.components=new ho,this.started=!1,this.addressSorter=e.addressSorter??pv,this.maxAddrsToDial=e.maxAddrsToDial??25,this.timeout=e.dialTimeout??3e4,this.maxDialsPerPeer=e.maxDialsPerPeer??4,this.tokens=[...new Array(e.maxParallelDials??100)].map((t,r)=>r),this.pendingDials=Ll({component:wT,metric:"pending-dials",metrics:e.metrics}),this.pendingDialTargets=Ll({component:wT,metric:"pending-dial-targets",metrics:e.metrics});for(const[t,r]of Object.entries(e.resolvers??{}))yn.resolvers.set(t,r)}init(e){this.components=e}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started=!0})()}stop(){var e=this;return j(function*(){e.started=!1;for(const t of e.pendingDials.values())try{t.controller.abort()}catch(r){Fs.error(r)}e.pendingDials.clear();for(const t of e.pendingDialTargets.values())t.reject(new eu("Dialer was destroyed"));e.pendingDialTargets.clear()})()}dial(e,t={}){var r=this;return j(function*(){const{id:i,multiaddrs:s}=Vl(e);if(r.components.getPeerId().equals(i))throw ae(new Error("Tried to dial self"),Ce.ERR_DIALED_SELF);if(Fs("check multiaddrs %p",i),null!=s&&s.length>0&&(Fs("storing multiaddrs %p",i,s),yield r.components.getPeerStore().addressBook.add(i,s)),yield r.components.getConnectionGater().denyDialPeer(i))throw ae(new Error("The dial request is blocked by gater.allowDialPeer"),Ce.ERR_PEER_DIAL_INTERCEPTED);Fs("creating dial target for %p",i);const o=yield r._createCancellableDialTarget(i,t);if(0===o.addrs.length)throw ae(new Error("The dial request has no valid addresses"),Ce.ERR_NO_VALID_ADDRESSES);const a=r.pendingDials.get(o.id)??r._createPendingDial(o,t);try{const u=yield a.promise;return Fs("dial succeeded to %s",o.id),u}catch(u){throw Fs("dial failed to %s",o.id,u),a.controller.signal.aborted&&(u.code=Ce.ERR_TIMEOUT),Fs.error(u),u}finally{a.destroy()}})()}_createCancellableDialTarget(e,t){var r=this;return j(function*(){const i=`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`,s=new Promise((o,a)=>{r.pendingDialTargets.set(i,{resolve:o,reject:a})});try{return yield Promise.race([r._createDialTarget(e,t),s])}finally{r.pendingDialTargets.delete(i)}})()}_createDialTarget(e,t){var r=this;return j(function*(){const i=yield Wn(yield r.components.getPeerStore().addressBook.get(e),a=>Ds(a,function(){var u=j(function*(_){return!(yield r.components.getConnectionGater().denyDialMultiaddr(e,_.multiaddr))});return function(_){return u.apply(this,arguments)}}()),a=>gv(a,r.addressSorter),a=>uv(a,u=>{const _=u.multiaddr;return e.toString()===_.getPeerId()?_:_.encapsulate(`/p2p/${e.toString()}`)}),function(){var a=j(function*(u){return yield Ul(u)});return function(u){return a.apply(this,arguments)}}()),s=[];for(const a of i)(yield r._resolve(a,t)).forEach(_=>s.push(_));const o=s.filter(a=>r.components.getTransportManager().transportForMultiaddr(a));if(o.length>r.maxAddrsToDial)throw yield r.components.getPeerStore().delete(e),ae(new Error("dial with more addresses than allowed"),Ce.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:o}})()}_createPendingDial(e,t={}){var r=this;const i=function(){var R=j(function*(N,B={}){if(!0===B.signal?.aborted)throw ae(new Error("already aborted"),Ce.ERR_ALREADY_ABORTED);return yield r.components.getTransportManager().dial(N,B)});return function(B){return R.apply(this,arguments)}}(),s=new GV({addrs:e.addrs,dialAction:i,dialer:this}),o=new bi.TimeoutController(this.timeout),a=[o.signal];null!=t.signal&&a.push(t.signal);const u=(0,lh.anySignal)(a);try{(0,Vr.setMaxListeners)?.(1/0,u)}catch{}const _={dialRequest:s,controller:o,promise:s.run({...t,signal:u}),destroy:()=>{o.clear(),this.pendingDials.delete(e.id)}};return this.pendingDials.set(e.id,_),_}getTokens(e){const t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),r=this.tokens.splice(0,t);return Fs("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.includes(e)||(Fs("token %d released",e),this.tokens.push(e))}_resolve(e,t){var r=this;return j(function*(){if(!e.protoNames().includes("dnsaddr"))return[e];const s=yield r._resolveRecord(e,t);return(yield Promise.all(s.map(function(){var u=j(function*(_){return yield r._resolve(_,t)});return function(_){return u.apply(this,arguments)}}()))).flat().reduce((u,_)=>(null==u.find(R=>R.equals(_))&&u.push(_),u),[])})()}_resolveRecord(e,t){return j(function*(){try{return e=new yn(e.toString()),yield e.resolve(t)}catch(r){return Fs.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}})()}}function wh(n,e){const t={[Symbol.iterator]:()=>t,next:()=>{const r=n.next(),i=r.value;return!0===r.done||null==i?{done:!0,value:void 0}:{done:!1,value:e(i)}}};return t}class XV{constructor(e){if(this.map=new Map,null!=e)for(const[t,r]of e.entries())this.map.set(t.toString(),r)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return wh(this.map.entries(),e=>[fr(e[0]),e[1]])}forEach(e){this.map.forEach((t,r)=>{e(t,fr(r),this)})}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),t)}keys(){return wh(this.map.keys(),e=>fr(e))}values(){return this.map.values()}get size(){return this.map.size}}class JV{constructor(e){if(this.set=new Set,null!=e)for(const t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return wh(this.set.entries(),e=>{const t=fr(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{const r=fr(t);e(r,r,this)})}has(e){return this.set.has(e.toString())}values(){return wh(this.set.values(),e=>fr(e))}}Symbol;const Xr=Gt("libp2p:connection-manager"),t7={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4},mv="libp2p",vv="connection-manager";class r7 extends Ei{constructor(e){if(super(),this.components=new ho,this.opts=Hl.call({ignoreUndefined:!0},t7,e),this.opts.maxConnections{const t={inbound:0,outbound:0};for(const r of this.connections.values())for(const i of r)"inbound"===i.stat.direction?t.inbound++:t.outbound++;return t}}),this.components.getMetrics()?.updateComponentMetric({system:mv,component:vv,metric:"protocol-streams-total",label:"protocol",value:()=>{const t={};for(const r of this.connections.values())for(const i of r)for(const s of i.streams){const o=`${s.stat.direction} ${s.stat.protocol??"unnegotiated"}`;t[o]=(t[o]??0)+1}return t}}),this.components.getMetrics()?.updateComponentMetric({system:mv,component:vv,metric:"protocol-streams-per-connection-90th-percentile",label:"protocol",value:()=>{const t={};for(const i of this.connections.values())for(const s of i){const o={};for(const a of s.streams){const u=`${a.stat.direction} ${a.stat.protocol??"unnegotiated"}`;o[u]=(o[u]??0)+1}for(const[a,u]of Object.entries(o))t[a]=t[a]??[],t[a].push(u)}const r={};for(let[i,s]of Object.entries(t)){s=s.sort((a,u)=>a-u);const o=Math.floor(.9*s.length);r[i]=s[o]}return r}})}isStarted(){return this.started}start(){var e=this;return j(function*(){null!=e.components.getMetrics()&&(e.timer=e.timer??Kl(e._checkMetrics,e.opts.pollInterval)),e.latencyMonitor.start(),e._onLatencyMeasure=e._onLatencyMeasure.bind(e),e.latencyMonitor.addEventListener("data",e._onLatencyMeasure),yield e.dialer.start(),e.started=!0,Xr("started")})()}afterStart(){var e=this;return j(function*(){e.components.getUpgrader().addEventListener("connection",e.onConnect),e.components.getUpgrader().addEventListener("connectionEnd",e.onDisconnect),Promise.resolve().then(j(function*(){const t=[];for(const r of yield e.components.getPeerStore().all())(yield e.components.getPeerStore().getTags(r.id)).filter(o=>"keep-alive"===o.name).length>0&&t.push(r.id);e.connectOnStartupController?.clear(),e.connectOnStartupController=new bi.TimeoutController(e.startupReconnectTimeout);try{(0,Vr.setMaxListeners)?.(1/0,e.connectOnStartupController.signal)}catch{}yield Promise.all(t.map(function(){var r=j(function*(i){yield e.openConnection(i,{signal:e.connectOnStartupController?.signal}).catch(s=>{Xr.error(s)})});return function(i){return r.apply(this,arguments)}}()))})).catch(t=>{Xr.error(t)}).finally(()=>{e.connectOnStartupController?.clear()})})()}beforeStop(){var e=this;return j(function*(){e.connectOnStartupController?.abort(),e.components.getUpgrader().removeEventListener("connection",e.onConnect),e.components.getUpgrader().removeEventListener("connectionEnd",e.onDisconnect)})()}stop(){var e=this;return j(function*(){e.timer?.clear(),e.latencyMonitor.removeEventListener("data",e._onLatencyMeasure),e.latencyMonitor.stop(),yield e.dialer.stop(),e.started=!1,yield e._close(),Xr("stopped")})()}_close(){var e=this;return j(function*(){const t=[];for(const r of e.connections.values())for(const i of r)t.push(j(function*(){try{yield i.close()}catch(s){Xr.error(s)}})());Xr("closing %d connections",t.length),yield Promise.all(t),e.connections.clear()})()}_checkMetrics(){var e=this;return j(function*(){const t=e.components.getMetrics();if(null!=t)try{const r=t.getGlobal().getMovingAverages(),i=r.dataReceived[e.opts.movingAverageInterval].movingAverage;yield e._checkMaxLimit("maxReceivedData",i);const s=r.dataSent[e.opts.movingAverageInterval].movingAverage;yield e._checkMaxLimit("maxSentData",s);const o=i+s;yield e._checkMaxLimit("maxData",o),Xr.trace("metrics update",o)}finally{e.timer=Kl(e._checkMetrics,e.opts.pollInterval)}})()}onConnect(e){this._onConnect(e).catch(t=>{Xr.error(t)})}_onConnect(e){var t=this;return j(function*(){const{detail:r}=e;if(!t.started)return void(yield r.close());const i=r.remotePeer,s=i.toString(),o=t.connections.get(s);null!=o?o.push(r):t.connections.set(s,[r]),null!=i.publicKey&&(yield t.components.getPeerStore().keyBook.set(i,i.publicKey));const a=t.getConnections().length,u=a-t.opts.maxConnections;yield t._checkMaxLimit("maxConnections",a,u),t.dispatchEvent(new tn("peer:connect",{detail:r}))})()}onDisconnect(e){const{detail:t}=e;if(!this.started)return;const r=t.remotePeer.toString();let i=this.connections.get(r);null!=i&&i.length>1?(i=i.filter(s=>s.id!==t.id),this.connections.set(r,i)):null!=i&&(this.connections.delete(r),this.dispatchEvent(new tn("peer:disconnect",{detail:t})),this.components.getMetrics()?.onPeerDisconnected(t.remotePeer))}getConnections(e){if(null!=e)return this.connections.get(e.toString())??[];let t=[];for(const r of this.connections.values())t=t.concat(r);return t}openConnection(e,t={}){var r=this;return j(function*(){Xr("dial to %p",e);const i=r.getConnections(e);if(i.length>0)return Xr("had an existing connection to %p",e),i[0];let s;if(null==t?.signal){s=new bi.TimeoutController(r.dialTimeout),t.signal=s.signal;try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}}try{const o=yield r.dialer.dial(e,t);let a=r.connections.get(e.toString());null==a&&(a=[],r.connections.set(e.toString(),a));let u=!1;for(const _ of a)_.id===o.id&&(u=!0);return u||a.push(o),o}finally{s?.clear()}})()}closeConnections(e){var t=this;return j(function*(){const r=t.connections.get(e.toString())??[];yield Promise.all(r.map(function(){var i=j(function*(s){return yield s.close()});return function(s){return i.apply(this,arguments)}}()))})()}getAll(e){if(!c2(e))throw ae(new Error("peerId must be an instance of peer-id"),Ce.ERR_INVALID_PARAMETERS);const t=e.toString(),r=this.connections.get(t);return null!=r?r.filter(i=>"OPEN"===i.stat.status):[]}_onLatencyMeasure(e){const{detail:t}=e;this._checkMaxLimit("maxEventLoopDelay",t.avgMs,1).catch(r=>{Xr.error(r)})}_checkMaxLimit(e,t,r=1){var i=this;return j(function*(){const s=i.opts[e];Xr.trace("checking limit of %s. current value: %d of %d",e,t,s),t>s&&(Xr("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",i.components.getPeerId(),e,t,s,r),yield i._maybePruneConnections(r))})()}_maybePruneConnections(e){var t=this;return j(function*(){const r=t.getConnections();if(r.length<=t.opts.minConnections||e<1)return;const i=new XV;for(const a of r){const u=a.remotePeer;if(i.has(u))continue;const _=yield t.components.getPeerStore().getTags(u);i.set(u,_.reduce((R,N)=>R+N.value,0))}const s=r.sort((a,u)=>{const _=i.get(a.remotePeer)??0,R=i.get(u.remotePeer)??0;return _>R?1:_{Zo.error("could start autodial",t)}),Zo("started")):Zo("not enabled")})()}stop(){var e=this;return j(function*(){e.options.enabled?(e.running=!1,null!=e.autoDialTimeout&&e.autoDialTimeout.clear(),Zo("stopped")):Zo("not enabled")})()}_autoDial(){var e=this;return j(function*(){null!=e.autoDialTimeout&&e.autoDialTimeout.clear();const t=e.options.minConnections;if(e.components.getConnectionManager().getConnections().length>=t)return void(e.autoDialTimeout=Kl(e._autoDial,e.options.autoDialInterval));const r=yield e.components.getPeerStore().all(),i=yield Wn(r.sort(()=>Math.random()>.5?1:-1),s=>Ds(s,o=>!o.id.equals(e.components.getPeerId())),s=>gv(s,(o,a)=>a.protocols.length>o.protocols.length||null!=a.id.publicKey&&null==o.id.publicKey?1:-1),function(){var s=j(function*(o){return yield Ul(o)});return function(o){return s.apply(this,arguments)}}());for(let s=0;e.running&&sFo(t)}(e=n.Status||(n.Status={})),function(a){a.HOP="HOP",a.STOP="STOP",a.STATUS="STATUS",a.CAN_HOP="CAN_HOP"}(r=n.Type||(n.Type={})),function(a){a[a.HOP=1]="HOP",a[a.STOP=2]="STOP",a[a.STATUS=3]="STATUS",a[a.CAN_HOP=4]="CAN_HOP"}(i||(i={})),function(a){a.codec=()=>Fo(i)}(r=n.Type||(n.Type={})),function(a){let u;a.codec=()=>(null==u&&(u=Yt((_,R,N={})=>{if(!1!==N.lengthDelimited&&R.fork(),null==_.id)throw new Error('Protocol error: required field "id" was not found in object');if(R.uint32(10),R.bytes(_.id),null==_.addrs)throw new Error('Protocol error: required field "addrs" was not found in object');for(const B of _.addrs)R.uint32(18),R.bytes(B);!1!==N.lengthDelimited&&R.ldelim()},(_,R)=>{const N={},B=null==R?_.len:_.pos+R;for(;_.pos>>3){case 1:N.id=_.bytes();break;case 2:N.addrs=N.addrs??[],N.addrs.push(_.bytes());break;default:_.skipType(7&K)}}if(N.addrs=N.addrs??[],null==N.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');if(null==N.addrs)throw new Error('Protocol error: value for required field "addrs" was not found in protobuf');return N})),u),a.encode=_=>qt(_,a.codec()),a.decode=_=>Wt(_,a.codec())}(s=n.Peer||(n.Peer={})),n.codec=()=>(null==o&&(o=Yt((a,u,_={})=>{!1!==_.lengthDelimited&&u.fork(),null!=a.type&&(u.uint32(8),n.Type.codec().encode(a.type,u)),null!=a.srcPeer&&(u.uint32(18),n.Peer.codec().encode(a.srcPeer,u)),null!=a.dstPeer&&(u.uint32(26),n.Peer.codec().encode(a.dstPeer,u)),null!=a.code&&(u.uint32(32),n.Status.codec().encode(a.code,u)),!1!==_.lengthDelimited&&u.ldelim()},(a,u)=>{const _={},R=null==u?a.len:a.pos+u;for(;a.pos>>3){case 1:_.type=n.Type.codec().decode(a);break;case 2:_.srcPeer=n.Peer.codec().decode(a,a.uint32());break;case 3:_.dstPeer=n.Peer.codec().decode(a,a.uint32());break;case 4:_.code=n.Status.codec().decode(a);break;default:a.skipType(7&N)}}return _})),o),n.encode=a=>qt(a,n.codec()),n.decode=a=>Wt(a,n.codec())}(nn||(nn={}));const o7=Gt("libp2p:stream:converter");function _T(n,e={}){const{stream:t,remoteAddr:r}=n,{sink:i,source:s}=t,o=dn(function*(){var B,R=!1,N=!1;try{for(var Z,K=Pt(s);R=!(Z=yield lt(K.next())).done;R=!1){const J=Z.value;yield*Mr(Pt(J),lt)}}catch(J){N=!0,B=J}finally{try{R&&null!=K.return&&(yield lt(K.return()))}finally{if(N)throw B}}})(),a={sink:R=>j(function*(){null!=e.signal&&(R=vs(R,e.signal));try{yield i(R),yield u()}catch(N){"aborted"!==N.type&&o7(N)}})(),source:null!=e.signal?vs(o,e.signal):o,remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:()=>j(function*(){yield i(dn(function*(){yield new Uint8Array(0)})()),yield u()})()};function u(){return _.apply(this,arguments)}function _(){return(_=j(function*(){return null==a.timeline.close&&(a.timeline.close=Date.now()),yield Promise.resolve()})).apply(this,arguments)}return a}const $l="/libp2p/circuit/relay/0.1.0";function DT(n,e){n.write({type:nn.Type.STATUS,code:e})}function ST(n,e){try{null!=n.dstPeer?.addrs&&n.dstPeer.addrs.forEach(t=>new yn(t))}catch(t){throw DT(e,n.type===nn.Type.HOP?nn.Status.HOP_DST_MULTIADDR_INVALID:nn.Status.STOP_DST_MULTIADDR_INVALID),t}try{null!=n.srcPeer?.addrs&&n.srcPeer.addrs.forEach(t=>new yn(t))}catch(t){throw DT(e,n.type===nn.Type.HOP?nn.Status.HOP_SRC_MULTIADDR_INVALID:nn.Status.STOP_SRC_MULTIADDR_INVALID),t}}const jl=Gt("libp2p:circuit:stream-handler");class _h{constructor(e){const{stream:t,maxLength:r=4096}=e;this.stream=t,this.shake=Ld(this.stream),this.decoder=ps.fromReader(this.shake.reader,{maxDataLength:r})}read(){var e=this;return j(function*(){const t=yield e.decoder.next();if(null!=t.value){const r=nn.decode(t.value);return jl("read message type",r.type),r}jl("read received no value, closing stream"),e.close()})()}write(e){jl("write message type %s",e.type),this.shake.write(Os.single(nn.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){jl("closing the stream"),this.rest().sink([]).catch(e=>{jl.error(e)})}}const Gl=Gt("libp2p:circuit:stop");function u7(n){return Ev.apply(this,arguments)}function Ev(){return Ev=j(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream($l,{signal:r});Gl("starting stop request to %p",e.remotePeer);const s=new _h({stream:i});s.write(t);const o=yield s.read();if(null!=o)return o.code===nn.Status.SUCCESS?(Gl("stop request to %p was successful",e.remotePeer),s.rest()):(Gl("stop request failed with code %d",o.code),void s.close());s.close()}),Ev.apply(this,arguments)}const Yi=Gt("libp2p:circuit:hop");function bv(){return bv=j(function*(n){const{connection:e,request:t,streamHandler:r,circuit:i,connectionManager:s}=n;if(!i.hopEnabled())return Yi("HOP request received but we are not acting as a relay"),r.end({type:nn.Type.STATUS,code:nn.Status.HOP_CANT_SPEAK_RELAY});try{ST(t,r)}catch(N){return void Yi.error("invalid hop request via peer %p %o",e.remotePeer,N)}if(null==t.dstPeer)return void Yi("HOP request received but we do not receive a dstPeer");const o=Jc(t.dstPeer.id),a=s.getConnections(o);if(0===a.length&&!i.hopActive())return Yi("HOP request received but we are not connected to the destination peer"),r.end({type:nn.Type.STATUS,code:nn.Status.HOP_NO_CONN_TO_DST});if(0===a.length)return Yi("did not have connection to remote peer"),r.end({type:nn.Type.STATUS,code:nn.Status.HOP_NO_CONN_TO_DST});const u={type:nn.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let _;try{Yi("performing STOP request");const N=yield u7({connection:a[0],request:u});if(null==N)throw new Error("Could not stop");_=N}catch(N){return void Yi.error(N)}Yi("hop request from %p is valid",e.remotePeer),r.write({type:nn.Type.STATUS,code:nn.Status.SUCCESS});const R=r.rest();return Yi("creating related connections"),yield Wn(R,_,R)}),bv.apply(this,arguments)}function wv(){return wv=j(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream($l,{signal:r}),s=new _h({stream:i});s.write(t);const o=yield s.read();if(null==o)throw ae(new Error("HOP request had no response"),Ce.ERR_HOP_REQUEST_FAILED);if(o.code===nn.Status.SUCCESS)return Yi("hop request was successful"),s.rest();throw Yi("hop request failed with code %d, closing stream",o.code),s.close(),ae(new Error(`HOP request failed with code "${o.code??"unknown"}"`),Ce.ERR_HOP_REQUEST_FAILED)}),wv.apply(this,arguments)}function _v(){return _v=j(function*(n){const{connection:e,signal:t}=n,r=yield e.newStream($l,{signal:t}),i=new _h({stream:r});i.write({type:nn.Type.CAN_HOP});const s=yield i.read();return yield i.close(),!(null==s||s.code!==nn.Status.SUCCESS)}),_v.apply(this,arguments)}const Qi=Gt("libp2p:circuit");class p7{constructor(e){this.components=new ho,this._init=e}init(e){this.components=e,this.components.getRegistrar().handle($l,t=>{this._onProtocol(t).catch(r=>{Qi.error(r)})}).catch(t=>{Qi.error(t)})}hopEnabled(){return!0}hopActive(){return!0}get[cv](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}_onProtocol(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t._init.hop.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=zo(i,s.signal),a=new _h({stream:{...i,...o}}),u=yield a.read();if(null==u)return Qi("request was invalid, could not read from stream"),a.write({type:nn.Type.STATUS,code:nn.Status.MALFORMED_MESSAGE}),void a.close();let _;switch(u.type){case nn.Type.CAN_HOP:Qi("received CAN_HOP request from %p",r.remotePeer),yield function h7(n){const{connection:e,streamHandler:t,circuit:r}=n,i=r.hopEnabled();Yi("can hop (%s) request from %p",i,e.remotePeer),t.end({type:nn.Type.STATUS,code:i?nn.Status.SUCCESS:nn.Status.HOP_CANT_SPEAK_RELAY})}({circuit:t,connection:r,streamHandler:a});break;case nn.Type.HOP:Qi("received HOP request from %p",r.remotePeer),yield function l7(n){return bv.apply(this,arguments)}({connection:r,request:u,streamHandler:a,circuit:t,connectionManager:t.components.getConnectionManager()});break;case nn.Type.STOP:Qi("received STOP request from %p",r.remotePeer),_=yield function c7(n){const{connection:e,request:t,streamHandler:r}=n;try{ST(t,r)}catch(i){return void Gl.error("invalid stop request via peer %p %o",e.remotePeer,i)}return Gl("stop request is valid"),r.write({type:nn.Type.STATUS,code:nn.Status.SUCCESS}),r.rest()}({connection:r,request:u,streamHandler:a});break;default:return Qi("Request of type %s not supported",u.type),a.write({type:nn.Type.STATUS,code:nn.Status.MALFORMED_MESSAGE}),void a.close()}if(null!=_){const B=_T({stream:_,remoteAddr:r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(new yn(u.dstPeer?.addrs[0])),localAddr:new yn(u.srcPeer?.addrs[0])}),K=u.type===nn.Type.HOP?"relay":"inbound";Qi("new %s connection %s",K,B.remoteAddr);const Z=yield t.components.getUpgrader().upgradeInbound(B);Qi("%s connection %s upgraded",K,B.remoteAddr),null!=t.handler&&t.handler(Z)}}finally{s.clear()}})()}dial(e,t={}){var r=this;return j(function*(){const i=e.toString().split("/p2p-circuit"),s=new yn(i[0]),o=new yn(i[i.length-1]),a=s.getPeerId(),u=o.getPeerId();if(null==a||null==u){const Z="Circuit relay dial failed as addresses did not have peer id";throw Qi.error(Z),ae(new Error(Z),Ce.ERR_RELAYED_DIAL)}const _=fr(a),R=fr(u);let N=!1,K=r.components.getConnectionManager().getConnections(_)[0];null==K&&(yield r.components.getPeerStore().addressBook.add(_,[s]),K=yield r.components.getConnectionManager().openConnection(_,t),N=!0);try{const Z=yield function f7(n){return wv.apply(this,arguments)}({...t,connection:K,request:{type:nn.Type.HOP,srcPeer:{id:r.components.getPeerId().toBytes(),addrs:r.components.getAddressManager().getAddresses().map(he=>he.bytes)},dstPeer:{id:R.toBytes(),addrs:[new yn(o).bytes]}}}),J=s.encapsulate(`/p2p-circuit/p2p/${r.components.getPeerId().toString()}`),oe=_T({stream:Z,remoteAddr:e,localAddr:J});return Qi("new outbound connection %s",oe.remoteAddr),yield r.components.getUpgrader().upgradeOutbound(oe)}catch(Z){throw Qi.error("Circuit relay dial failed",Z),N&&(yield K.close()),Z}})()}createListener(e){return this.handler=e.handler,function a7(n){const e=new Map;function r(){return(r=j(function*(o){const a=o.toString().split("/p2p-circuit").find(K=>""!==K),u=new yn(a),_=u.getPeerId();if(null==_)throw new Error("Could not determine relay peer from multiaddr");const R=fr(_);yield n.peerStore.addressBook.add(R,[u]);const N=yield n.connectionManager.openConnection(R),B=N.remoteAddr.encapsulate("/p2p-circuit");e.set(N.remotePeer.toString(),B),s.dispatchEvent(new tn("listening"))})).apply(this,arguments)}const s=Object.assign(new Ei,{close:(o=j(function*(){return yield Promise.resolve()}),function(){return o.apply(this,arguments)}),listen:function t(o){return r.apply(this,arguments)},getAddrs:function i(){const o=[];for(const a of e.values())o.push(a);return o}});var o;return n.connectionManager.addEventListener("peer:disconnect",o=>{const{detail:a}=o;e.delete(a.remotePeer.toString())&&s.dispatchEvent(new tn("close"))}),s}({connectionManager:this.components.getConnectionManager(),peerStore:this.components.getPeerStore()})}filter(e){return(e=Array.isArray(e)?e:[e]).filter(t=>nu.matches(t))}}function CT(n){return Dv.apply(this,arguments)}function Dv(){return Dv=j(function*(n){const e=(new TextEncoder).encode(n),t=yield mi.digest(e);return _r.createV0(t)}),Dv.apply(this,arguments)}const TT="hop_relay",xT="/libp2p/relay",zl=Gt("libp2p:auto-relay"),v7=()=>{};class E7{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??pv,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??v7,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.getPeerStore().addEventListener("change:protocols",r=>{this._onProtocolChange(r).catch(i=>{zl.error(i)})}),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onPeerDisconnected)}_onProtocolChange(e){var t=this;return j(function*(){const{peerId:r,protocols:i}=e.detail,s=r.toString();if(null!=i.find(a=>a===$l)){if(!t.listenRelays.has(s))try{const a=t.components.getConnectionManager().getConnections(r);if(0===a.length)return;const u=a[0];if(u.remoteAddr.protoCodes().includes(290))return void zl(`relayed connection to ${s} will not be used to hop on`);(yield function d7(n){return _v.apply(this,arguments)}({connection:u}))&&(yield t.components.getPeerStore().metadataBook.setValue(r,TT,Ot("true")),yield t._addListenRelay(u,s))}catch(a){t.onError(a)}}else t.listenRelays.has(s)&&(yield t._removeListenRelay(s))})()}_onPeerDisconnected(e){const i=e.detail.remotePeer.toString();!this.listenRelays.has(i)||this._removeListenRelay(i).catch(s=>{zl.error(s)})}_addListenRelay(e,t){var r=this;return j(function*(){try{if(r.listenRelays.size>=r.maxListeners)return;const i=yield Wn(yield r.components.getPeerStore().addressBook.get(e.remotePeer),o=>gv(o,r.addressSorter),function(){var o=j(function*(a){return yield Ul(a)});return function(a){return o.apply(this,arguments)}}());(yield Promise.all(i.map(function(){var o=j(function*(a){try{let u=a.multiaddr;return null==u.getPeerId()&&(u=u.encapsulate(`/p2p/${e.remotePeer.toString()}`)),u=u.encapsulate("/p2p-circuit"),yield r.components.getTransportManager().listen([u]),!0}catch(u){zl.error("error listening on circuit address",u),r.onError(u)}return!1});return function(a){return o.apply(this,arguments)}}()))).includes(!0)&&r.listenRelays.add(t)}catch(i){r.onError(i),r.listenRelays.delete(t)}})()}_removeListenRelay(e){var t=this;return j(function*(){t.listenRelays.delete(e)&&(yield t._listenOnAvailableHopRelays([e]))})()}_listenOnAvailableHopRelays(e=[]){var t=this;return j(function*(){if(t.listenRelays.size>=t.maxListeners)return;const r=[],i=yield t.components.getPeerStore().all();for(const{id:R,metadata:N}of i){const B=R.toString();if(t.listenRelays.has(B)||e.includes(B))continue;const K=N.get(TT);if(null==K||"true"!==Lt(K))continue;const Z=t.components.getConnectionManager().getConnections(R);if(0!==Z.length){if(yield t._addListenRelay(Z[0],B),t.listenRelays.size>=t.maxListeners)return}else r.push(R)}for(const R of r)if(yield t._tryToListenOnRelay(R),t.listenRelays.size>=t.maxListeners)return;try{const R=yield CT(xT);var a,s=!1,o=!1;try{for(var _,u=Pt(t.components.getContentRouting().findProviders(R));s=!(_=yield u.next()).done;s=!1){const N=_.value;if(0===N.multiaddrs.length)continue;const B=N.id;if(yield t.components.getPeerStore().addressBook.add(B,N.multiaddrs),yield t._tryToListenOnRelay(B),t.listenRelays.size>=t.maxListeners)return}}catch(N){o=!0,a=N}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}}catch(R){t.onError(R)}})()}_tryToListenOnRelay(e){var t=this;return j(function*(){try{const r=yield t.components.getConnectionManager().openConnection(e);yield t._addListenRelay(r,e.toString())}catch(r){zl.error("Could not use %p as relay",e,r),t.onError(r,`could not connect and listen on known hop relay ${e.toString()}`)}})()}}const RT=Gt("libp2p:relay");class b7{constructor(e,t){this.components=e,this.autoRelay=!1!==t.autoRelay?.enabled?new E7(e,{addressSorter:t.addressSorter,...t.autoRelay}):void 0,this.started=!1,this.init=t,this._advertiseService=this._advertiseService.bind(this)}isStarted(){return this.started}start(){var e=this;return j(function*(){!1!==e.init.hop.enabled&&!1!==e.init.advertise.enabled&&(e.timeout=(0,bh.setDelayedInterval)(e._advertiseService,e.init.advertise.ttl,e.init.advertise.bootDelay)),e.started=!0})()}stop(){var e=this;return j(function*(){null!=e.timeout&&(0,bh.clearDelayedInterval)(e.timeout),e.started=!1})()}_advertiseService(){var e=this;return j(function*(){try{const t=yield CT(xT);yield e.components.getContentRouting().provide(t)}catch(t){t.code===Ce.ERR_NO_ROUTERS_AVAILABLE?(RT.error("a content router, such as a DHT, must be provided in order to advertise the relay service",t),yield e.stop()):RT.error(t)}})()}}var w7=x(9014);x(422),x(5911);const PT=Un.pki;function Sv(){return Sv=j(function*(n,e){const t=n.map(e);return n[(yield Promise.all(t)).findIndex(s=>s)]}),Sv.apply(this,arguments)}const S7=Gt("libp2p:keychain:cms"),Cv=new WeakMap;class C7{constructor(e,t){if(null==e)throw ae(new Error("keychain is required"),Ce.ERR_KEYCHAIN_REQUIRED);this.keychain=e,Cv.set(this,{dek:t})}encrypt(e,t){var r=this;return j(function*(){if(!(t instanceof Uint8Array))throw ae(new Error("Plain data must be a Uint8Array"),Ce.ERR_INVALID_PARAMETERS);const i=yield r.keychain.findKeyByName(e),s=yield r.keychain.getPrivateKey(e),o=Cv.get(r);if(null==o)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=Un.pki.decryptRsaPrivateKey(s,o.dek),_=yield((n,e)=>{const t=PT.rsa.setPublicKey(e.n,e.e),r=PT.createCertificate();r.publicKey=t,r.serialNumber="01",r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+10);const i=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:n.id}];return r.setSubject(i),r.setIssuer(i),r.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),r.sign(e),r})(i,u),R=Un.pkcs7.createEnvelopedData();return R.addRecipient(_),R.content=Un.util.createBuffer(t),R.encrypt(),Ot(Un.asn1.toDer(R.toAsn1()).getBytes(),"ascii")})()}decrypt(e){var t=this;return j(function*(){if(!(e instanceof Uint8Array))throw ae(new Error("CMS data is required"),Ce.ERR_INVALID_PARAMETERS);let r;try{const N=Un.util.createBuffer(Lt(e,"ascii")),B=Un.asn1.fromDer(N);r=Un.pkcs7.messageFromAsn1(B)}catch(N){throw S7.error(N),ae(new Error("Invalid CMS"),Ce.ERR_INVALID_CMS)}const i=r.recipients.filter(N=>N.issuer.find(B=>"O"===B.shortName&&"ipfs"===B.value)).filter(N=>N.issuer.find(B=>"CN"===B.shortName)).map(N=>({recipient:N,keyId:N.issuer.find(B=>"CN"===B.shortName).value})),s=yield function D7(n,e){return Sv.apply(this,arguments)}(i,function(){var N=j(function*(B){try{if(null!=(yield t.keychain.findKeyById(B.keyId)))return!0}catch{return!1}return!1});return function(B){return N.apply(this,arguments)}}());if(null==s){const N=i.map(B=>B.keyId);throw ae(new Error(`Decryption needs one of the key(s): ${N.join(", ")}`),Ce.ERR_MISSING_KEYS,{missingKeys:N})}const o=yield t.keychain.findKeyById(s.keyId);if(null==o)throw ae(new Error("No key available to decrypto"),Ce.ERR_NO_KEY);const a=yield t.keychain.getPrivateKey(o.name),u=Cv.get(t);if(null==u)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const R=Un.pki.decryptRsaPrivateKey(a,u.dek);return r.decrypt(s.recipient,R),Ot(r.content.getBytes(),"ascii")})()}}x(1298);var I7=x(7949);const MT={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function OT(n,e,t,r,i){if("sha1"!==i&&"sha2-256"!==i&&"sha2-512"!==i){const a=Object.keys(MT).join(" / ");throw ae(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}const o=I7(n,e,t,r,MT[i]);return fF.encode64(o,null)}const Dh=Gt("libp2p:keychain"),Xo=new WeakMap,Tv={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function mo(n){return null!=n&&"string"==typeof n&&n===w7(n.trim())&&n.length>0}function kn(){return Av.apply(this,arguments)}function Av(){return(Av=j(function*(){const t=800*Math.random()+200;yield new Promise(r=>setTimeout(r,t))})).apply(this,arguments)}function Us(n){return new Ur("/pkcs8/"+n)}function Jo(n){return new Ur("/info/"+n)}class LT{constructor(e,t){if(this.components=e,this.init=Hl(Tv,t),null!=this.init.pass&&this.init.pass?.length<20)throw new Error("pass must be least 20 characters");if(null!=this.init.dek?.keyLength&&this.init.dek.keyLength<14)throw new Error("dek.keyLength must be least 14 bytes");if(null!=this.init.dek?.salt?.length&&this.init.dek.salt.length<16)throw new Error("dek.saltLength must be least 16 bytes");if(null!=this.init.dek?.iterationCount&&this.init.dek.iterationCount<1e3)throw new Error("dek.iterationCount must be least 1000");const r=null!=this.init.pass&&null!=this.init.dek?.salt?OT(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";Xo.set(this,{dek:r})}get cms(){const e=Xo.get(this);if(null==e)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);return new C7(this,e.dek)}static generateOptions(){const e=Object.assign({},Tv),t=3*Math.ceil(16/3);return e.dek.salt=Lt(nh(t),"base64"),e}static get options(){return Tv}createKey(e,t,r=2048){var i=this;return j(function*(){if(!mo(e)||"self"===e)throw yield kn(),ae(new Error("Invalid key name"),Ce.ERR_INVALID_KEY_NAME);if("string"!=typeof t)throw yield kn(),ae(new Error("Invalid key type"),Ce.ERR_INVALID_KEY_TYPE);const s=Us(e);if(yield i.components.getDatastore().has(s))throw yield kn(),ae(new Error("Key name already exists"),Ce.ERR_KEY_ALREADY_EXISTS);if("rsa"===t.toLowerCase()&&(!Number.isSafeInteger(r)||r<2048))throw yield kn(),ae(new Error("Invalid RSA key size"),Ce.ERR_INVALID_KEY_SIZE);let a;try{const u=yield s2(t,r),_=yield u.id(),R=Xo.get(i);if(null==R)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const N=R.dek,B=yield u.export(N);a={name:e,id:_};const K=i.components.getDatastore().batch();K.put(s,Ot(B)),K.put(Jo(e),Ot(JSON.stringify(a))),yield K.commit()}catch(u){throw yield kn(),u}return a})()}listKeys(){var e=this;return j(function*(){const t={prefix:"/info/"},r=[];var o,i=!1,s=!1;try{for(var u,a=Pt(e.components.getDatastore().query(t));i=!(u=yield a.next()).done;i=!1)r.push(JSON.parse(Lt(u.value.value)))}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}return r})()}findKeyById(e){var t=this;return j(function*(){try{return(yield t.listKeys()).find(i=>i.id===e)}catch(r){throw yield kn(),r}})()}findKeyByName(e){var t=this;return j(function*(){if(!mo(e))throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);const r=Jo(e);try{const i=yield t.components.getDatastore().get(r);return JSON.parse(Lt(i))}catch(i){throw yield kn(),Dh.error(i),ae(new Error(`Key '${e}' does not exist.`),Ce.ERR_KEY_NOT_FOUND)}})()}removeKey(e){var t=this;return j(function*(){if(!mo(e)||"self"===e)throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);const r=Us(e),i=yield t.findKeyByName(e),s=t.components.getDatastore().batch();return s.delete(r),s.delete(Jo(e)),yield s.commit(),i})()}renameKey(e,t){var r=this;return j(function*(){if(!mo(e)||"self"===e)throw yield kn(),ae(new Error(`Invalid old key name '${e}'`),Ce.ERR_OLD_KEY_NAME_INVALID);if(!mo(t)||"self"===t)throw yield kn(),ae(new Error(`Invalid new key name '${t}'`),Ce.ERR_NEW_KEY_NAME_INVALID);const i=Us(e),s=Us(t),o=Jo(e),a=Jo(t);if(yield r.components.getDatastore().has(s))throw yield kn(),ae(new Error(`Key '${t}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);try{const _=yield r.components.getDatastore().get(i),R=yield r.components.getDatastore().get(o),N=JSON.parse(Lt(R));N.name=t;const B=r.components.getDatastore().batch();return B.put(s,_),B.put(a,Ot(JSON.stringify(N))),B.delete(i),B.delete(o),yield B.commit(),N}catch(_){throw yield kn(),_}})()}exportKey(e,t){var r=this;return j(function*(){if(!mo(e))throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t)throw yield kn(),ae(new Error("Password is required"),Ce.ERR_PASSWORD_REQUIRED);const i=Us(e);try{const o=Lt(yield r.components.getDatastore().get(i)),a=Xo.get(r);if(null==a)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=a.dek;return yield(yield Pm(o,u)).export(t)}catch(s){throw yield kn(),s}})()}importKey(e,t,r){var i=this;return j(function*(){if(!mo(e)||"self"===e)throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t)throw yield kn(),ae(new Error("PEM encoded key is required"),Ce.ERR_PEM_REQUIRED);const s=Us(e);if(yield i.components.getDatastore().has(s))throw yield kn(),ae(new Error(`Key '${e}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);let a,u;try{a=yield Pm(t,r)}catch{throw yield kn(),ae(new Error("Cannot read the key, most likely the password is wrong"),Ce.ERR_CANNOT_READ_KEY)}try{u=yield a.id();const N=Xo.get(i);if(null==N)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const B=N.dek;t=yield a.export(B)}catch(N){throw yield kn(),N}const _={name:e,id:u},R=i.components.getDatastore().batch();return R.put(s,Ot(t)),R.put(Jo(e),Ot(JSON.stringify(_))),yield R.commit(),_})()}importPeer(e,t){var r=this;return j(function*(){try{if(!mo(e))throw ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t||null==t.privateKey)throw ae(new Error("Peer.privKey is required"),Ce.ERR_MISSING_PRIVATE_KEY);const i=yield Pl(t.privateKey),s=Us(e);if(yield r.components.getDatastore().has(s))throw yield kn(),ae(new Error(`Key '${e}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);const a=Xo.get(r);if(null==a)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=a.dek,_=yield i.export(u),R={name:e,id:t.toString()},N=r.components.getDatastore().batch();return N.put(s,Ot(_)),N.put(Jo(e),Ot(JSON.stringify(R))),yield N.commit(),R}catch(i){throw yield kn(),i}})()}getPrivateKey(e){var t=this;return j(function*(){if(!mo(e))throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);try{const r=Us(e);return Lt(yield t.components.getDatastore().get(r))}catch(r){throw yield kn(),Dh.error(r),ae(new Error(`Key '${e}' does not exist.`),Ce.ERR_KEY_NOT_FOUND)}})()}rotateKeychainPass(e,t){var r=this;return j(function*(){if("string"!=typeof e)throw yield kn(),ae(new Error(`Invalid old pass type '${typeof e}'`),Ce.ERR_INVALID_OLD_PASS_TYPE);if("string"!=typeof t)throw yield kn(),ae(new Error(`Invalid new pass type '${typeof t}'`),Ce.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw yield kn(),ae(new Error(`Invalid pass length ${t.length}`),Ce.ERR_INVALID_PASS_LENGTH);Dh("recreating keychain");const i=Xo.get(r);if(null==i)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const s=i.dek;r.init.pass=t;const o=null!=t&&null!=r.init.dek?.salt?OT(t,r.init.dek.salt,r.init.dek?.iterationCount,r.init.dek?.keyLength,r.init.dek?.hash):"";Xo.set(r,{dek:o});const a=yield r.listKeys();for(const u of a){const R=Lt(yield r.components.getDatastore().get(Us(u.name))),N=yield Pm(R,s),B=o.toString(),K=yield N.export(B),Z=r.components.getDatastore().batch(),J={name:u.name,id:u.id};Z.put(Us(u.name),Ot(K)),Z.put(Jo(u.name),Ot(JSON.stringify(J))),yield Z.commit()}Dh("keychain reconstructed")})()}}var xv=x(1349),A7=x(5550);class x7{constructor(e){if("number"!=typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");this.timespan=e,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(e,t){return 1-Math.exp(-(e-t)/this.timespan)}push(e,t){if(null!=this.previousTime){const r=this.alpha(e,this.previousTime),i=t-this.movingAverage,s=r*i;this.movingAverage=r*t+(1-r)*this.movingAverage,this.variance=(1-r)*(this.variance+i*s),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+r*i}else this.movingAverage=t;this.previousTime=e}}function BT(n){return new x7(n)}class Rv extends Ei{constructor(e){super(),this.enabled=e.enabled,this.queue=[],this.stats={dataReceived:0n,dataSent:0n},this.frequencyLastTime=Date.now(),this.frequencyAccumulators={},this.movingAverages={dataReceived:[],dataSent:[]},this.computeThrottleMaxQueueSize=e.computeThrottleMaxQueueSize,this.computeThrottleTimeout=e.computeThrottleTimeout,this._update=this._update.bind(this),this.movingAverageIntervals=e.movingAverageIntervals;for(let t=0;t0&&this._resetComputeTimeout()}stop(){null!=this.timeout&&(this.timeout.clear(),this.timeout=null)}getSnapshot(){return Object.assign({},this.stats)}getMovingAverages(){return Object.assign({},this.movingAverages)}push(e,t){this.queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this.timeout=Kl(this._update,this._nextTimeout())}_nextTimeout(){return Math.max(this.computeThrottleTimeout*(1-this.queue.length/this.computeThrottleMaxQueueSize),0)}_update(){if(this.timeout=null,this.queue.length>0){let e=["",0,0];for(e of this.queue)this._applyOp(e);this.queue=[],e.length>2&&""!==e[0]&&this._updateFrequency(e[2]),this.dispatchEvent(new tn("update",{detail:this.stats}))}}_updateFrequency(e){const t=e-this.frequencyLastTime;this._updateFrequencyFor("dataReceived",t,e),this._updateFrequencyFor("dataSent",t,e),this.frequencyLastTime=e}_updateFrequencyFor(e,t,r){const i=this.frequencyAccumulators[e]??0;this.frequencyAccumulators[e]=0;const o=i/(t??1)*1e3;let a=this.movingAverages[e];null==a&&(a=this.movingAverages[e]=[]);const u=this.movingAverageIntervals;for(let _=0;_s:s})}forPeer(e){const t=e.toString();return this.peerStats.get(t)??this.oldPeers.get(t)}getProtocols(){return Array.from(this.protocolStats.keys())}forProtocol(e){return this.protocolStats.get(e)}onPeerDisconnected(e){const t=e.toString(),r=this.peerStats.get(t);null!=r&&(r.stop(),this.peerStats.delete(t),this.oldPeers.set(t,r))}_onMessage(e){if(!this.running)return;const{remotePeer:t,protocol:r,direction:i,dataLength:s}=e,o=P7[i];let a=this.forPeer(t);if(null==a){const u=new Rv(this.statsInit);this.peerStats.set(t.toString(),u),a=u}if(a.push(o,s),this.globalStats.push(o,s),null!=r){let u=this.forProtocol(r);if(null==u){const _=new Rv(this.statsInit);this.protocolStats.set(r,_),u=_}u.push(o,s)}}updatePlaceholder(e,t){if(!this.running)return;const r=e.toString(),i=this.peerStats.get(r)??this.oldPeers.get(r),s=t.toString(),o=this.peerStats.get(s)??this.oldPeers.get(s);let a=i;null!=o&&(a=function M7(n,e){return n.stop(),e.stop(),n.queue=[...n.queue,...e.queue],n}(o,a),this.oldPeers.remove(s)),this.peerStats.delete(e.toString()),this.peerStats.set(s,a),a.start()}trackStream(e){var t=this;const{stream:r,remotePeer:i,protocol:s}=e;if(!this.running)return;r.source=xv(r.source,u=>this._onMessage({remotePeer:i,protocol:s,direction:"in",dataLength:u.byteLength}));const a=r.sink;r.sink=function(){var u=j(function*(_){return yield Wn(_,R=>xv(R,N=>{t._onMessage({remotePeer:i,protocol:s,direction:"out",dataLength:N.byteLength})}),a)});return function(_){return u.apply(this,arguments)}}()}}function Pv(n){return Nv.apply(this,arguments)}function Nv(){return Nv=j(function*(n){try{return{status:"fulfilled",value:yield n,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}),Nv.apply(this,arguments)}class O7{constructor(e){cb(this,"value"),cb(this,"next"),this.value=e}}class k7{constructor(){hp(this,js,void 0),hp(this,Va,void 0),hp(this,Ha,void 0),this.clear()}enqueue(e){const t=new O7(e);aa(this,js)?(aa(this,Va).next=t,So(this,Va,t)):(So(this,js,t),So(this,Va,t)),ub(this,Ha)._++}dequeue(){const e=aa(this,js);if(e)return So(this,js,aa(this,js).next),ub(this,Ha)._--,e.value}clear(){So(this,js,void 0),So(this,Va,void 0),So(this,Ha,0)}get size(){return aa(this,Ha)}*[Symbol.iterator](){let e=aa(this,js);for(;e;)yield e.value,e=e.next}}function L7(n){if(!Number.isInteger(n)&&n!==Number.POSITIVE_INFINITY||!(n>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const e=new k7;let t=0;const i=function(){var a=j(function*(u,_,R){t++;const N=j(function*(){return u(...R)})();_(N);try{yield N}catch{}t--,e.size>0&&e.dequeue()()});return function(_,R,N){return a.apply(this,arguments)}}(),o=(a,...u)=>new Promise(_=>{((a,u,_)=>{e.enqueue(i.bind(void 0,a,u,_)),j(function*(){yield Promise.resolve(),t0&&e.dequeue()()})()})(a,_,u)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}function B7(n){return Mv.apply(this,arguments)}function Mv(){return Mv=j(function*(n,e={}){const{concurrency:t=Number.POSITIVE_INFINITY}=e,r=L7(t);return Promise.all(n.map(i=>Pv(i&&"function"==typeof i.then?i:"function"==typeof i?r(()=>i()):Promise.resolve(i))))}),Mv.apply(this,arguments)}js=new WeakMap,Va=new WeakMap,Ha=new WeakMap;const Ra=Gt("libp2p:transports");class F7 extends Ei{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=Ll({component:"transport-manager",metric:"listeners",metrics:this.components.getMetrics()}),this.faultTolerance=t.faultTolerance??Pa.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw ae(new Error("Transport must have a valid tag"),Ce.ERR_INVALID_KEY);if(this.transports.has(t))throw ae(new Error("There is already a transport with this tag"),Ce.ERR_DUPLICATE_TRANSPORT);Ra("adding transport %s",t),this.transports.set(t,e),this.listeners.has(t)||this.listeners.set(t,[])}isStarted(){return this.started}start(){var e=this;return j(function*(){const t=e.components.getAddressManager().getListenAddrs();yield e.listen(t),e.started=!0})()}stop(){var e=this;return j(function*(){const t=[];for(const[r,i]of e.listeners)for(Ra("closing listeners for %s",r);i.length>0;){const s=i.pop();null!=s&&t.push(s.close())}yield Promise.all(t),Ra("all listeners closed");for(const r of e.listeners.keys())e.listeners.set(r,[]);e.started=!1})()}dial(e,t){var r=this;return j(function*(){const i=r.transportForMultiaddr(e);if(null==i)throw ae(new Error(`No transport available for address ${String(e)}`),Ce.ERR_TRANSPORT_UNAVAILABLE);try{return yield i.dial(e,{...t,upgrader:r.components.getUpgrader()})}catch(s){throw null==s.code&&(s.code=Ce.ERR_TRANSPORT_DIAL_FAILED),s}})()}getAddrs(){let e=[];for(const t of this.listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}transportForMultiaddr(e){for(const t of this.transports.values())if(t.filter([e]).length>0)return t}listen(e){var t=this;return j(function*(){if(null==e||0===e.length)return void Ra("no addresses were provided for listening, this node is dial only");const r=[];for(const[i,s]of t.transports.entries()){const o=s.filter(e),a=[];for(const R of o){Ra("creating listener for %s on %s",i,R);const N=s.createListener({upgrader:t.components.getUpgrader()});let B=t.listeners.get(i);null==B&&(B=[],t.listeners.set(i,B)),B.push(N),N.addEventListener("listening",()=>{t.dispatchEvent(new tn("listener:listening",{detail:N}))}),N.addEventListener("close",()=>{t.dispatchEvent(new tn("listener:close",{detail:N}))}),a.push(N.listen(R))}if(0!==a.length){if(null==(yield B7(a)).find(R=>R.isFulfilled)&&t.faultTolerance!==Pa.NO_FATAL)throw ae(new Error(`Transport (${i}) could not listen on any available address`),Ce.ERR_NO_VALID_ADDRESSES)}else r.push(i)}if(r.length===t.transports.size){const i=`no valid addresses were provided for transports [${r.join(", ")}]`;if(t.faultTolerance===Pa.FATAL_ALL)throw ae(new Error(i),Ce.ERR_NO_VALID_ADDRESSES);Ra(`libp2p in dial mode only: ${i}`)}})()}remove(e){var t=this;return j(function*(){Ra("removing %s",e);for(const r of t.listeners.get(e)??[])yield r.close();t.transports.delete(e),t.listeners.delete(e)})()}removeAll(){var e=this;return j(function*(){const t=[];for(const r of e.transports.keys())t.push(e.remove(r));yield Promise.all(t)})()}}var Pa=(()=>(function(n){n[n.FATAL_ALL=0]="FATAL_ALL",n[n.NO_FATAL=1]="NO_FATAL"}(Pa||(Pa={})),Pa))();const ru="/multistream/1.0.0",FT=Ot("\n");function Ov(n){const e=new qr(n,FT);return Os.single(e)}function Wl(n,e,t={}){const r=Ov(e);n.push(!0===t.writeBytes?r.subarray():r)}function U7(n,e,t={}){const r=new qr;for(const i of e)r.append(Ov(i));n.push(!0===t.writeBytes?r.subarray():r)}function V7(n,e){return kv.apply(this,arguments)}function kv(){return kv=j(function*(n,e){let t=1;const r={[Symbol.asyncIterator]:()=>r,next:(a=j(function*(){return yield n.next(t)}),function(){return a.apply(this,arguments)})};var a;let i=r;null!=e?.signal&&(i=vs(r,e.signal));const o=yield Wn(i,ps({onLength:a=>{t=a}}),function(){var a=j(function*(u){return yield Aa(u)});return function(u){return a.apply(this,arguments)}}());if(null==o)throw ae(new Error("no buffer returned"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(o.get(o.byteLength-1)!==FT[0])throw ae(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}),kv.apply(this,arguments)}function Sh(n,e){return Lv.apply(this,arguments)}function Lv(){return Lv=j(function*(n,e){return Lt((yield V7(n,e)).subarray())}),Lv.apply(this,arguments)}const ql=Gt("libp2p:mss:select");function Bv(n,e){return Fv.apply(this,arguments)}function Fv(){return Fv=j(function*(n,e,t={}){e=Array.isArray(e)?[...e]:[e];const{reader:r,writer:i,rest:s,stream:o}=Ld(n),a=e.shift();if(null==a)throw new Error("At least one protocol must be specified");ql('select: write ["%s", "%s"]',ru,a),U7(i,[Ot(ru),Ot(a)],t);let R=yield Sh(r,t);if(ql('select: read "%s"',R),R===ru&&(R=yield Sh(r,t),ql('select: read "%s"',R)),R===a)return s(),{stream:o,protocol:a};for(const N of e){ql('select: write "%s"',N),Wl(i,Ot(N),t);const B=yield Sh(r,t);if(ql('select: read "%s" for "%s"',B,N),B===N)return s(),{stream:o,protocol:N}}throw s(),ae(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}),Fv.apply(this,arguments)}const Yl=Gt("libp2p:mss:handle");function Uv(n,e,t){return Vv.apply(this,arguments)}function Vv(){return Vv=j(function*(n,e,t){e=Array.isArray(e)?e:[e];const{writer:r,reader:i,rest:s,stream:o}=Ld(n);for(;;){const a=yield Sh(i,t);if(Yl('read "%s"',a),a!==ru){if(e.includes(a))return Wl(r,Ot(a),t),Yl('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};"ls"!==a?(Wl(r,Ot("na"),t),Yl('respond with "na" for "%s"',a)):(Wl(r,new qr(...e.map(u=>Ov(Ot(u)))),t),Yl('respond with "%s" for %s',e,a))}else Yl('respond with "%s" for "%s"',ru,a),Wl(r,Ot(ru),t)}}),Vv.apply(this,arguments)}var UT=x(344);const VT=Symbol.for("@libp2p/connection"),H7=Gt("libp2p:connection");class K7{constructor(e){const{remoteAddr:t,remotePeer:r,newStream:i,close:s,getStreams:o,stat:a}=e;this.id=`${parseInt(String(1e9*Math.random())).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=r,this.stat={...a,status:"OPEN"},this._newStream=i,this._close=s,this._getStreams=o,this.tags=[],this._closing=!1}get[Symbol.toStringTag](){return"Connection"}get[VT](){return!0}get streams(){return this._getStreams()}newStream(e,t){var r=this;return j(function*(){if(r.stat.status===pT)throw ae(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(r.stat.status===hv)throw ae(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);const i=yield r._newStream(e,t);return i.stat.direction="outbound",i})()}addStream(e){e.stat.direction="inbound"}removeStream(e){}close(){var e=this;return j(function*(){if(e.stat.status!==hv&&!e._closing){e.stat.status=pT;try{e.streams.forEach(t=>t.close())}catch(t){H7.error(t)}e._closing=!0,yield e._close(),e._closing=!1,e.stat.timeline.close=Date.now(),e.stat.status=hv}})()}}const Hv=Symbol.for("@libp2p/topology"),HT=Gt("libp2p:registrar");class G7{constructor(e){this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onProtocolChange=this._onProtocolChange.bind(this),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onDisconnect),this.components.getPeerStore().addEventListener("change:protocols",this._onProtocolChange)}getProtocols(){return Array.from(new Set([...this.topologies.keys(),...this.handlers.keys()])).sort()}getHandler(e){const t=this.handlers.get(e);if(null==t)throw ae(new Error(`No handler registered for protocol ${e}`),Ce.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){const t=this.topologies.get(e);return null==t?[]:[...t.values()]}handle(e,t,r){var i=this;return j(function*(){if(i.handlers.has(e))throw ae(new Error(`Handler already registered for protocol ${e}`),Ce.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const s=Hl.bind({ignoreUndefined:!0})({maxInboundStreams:32,maxOutboundStreams:64},r);i.handlers.set(e,{handler:t,options:s}),yield i.components.getPeerStore().protoBook.add(i.components.getPeerId(),[e])})()}unhandle(e){var t=this;return j(function*(){const r=Array.isArray(e)?e:[e];r.forEach(i=>{t.handlers.delete(i)}),yield t.components.getPeerStore().protoBook.remove(t.components.getPeerId(),r)})()}register(e,t){var r=this;return j(function*(){if(!function j7(n){return null!=n&&Boolean(n[Hv])}(t))throw HT.error("topology must be an instance of interfaces/topology"),ae(new Error("topology must be an instance of interfaces/topology"),Ce.ERR_INVALID_PARAMETERS);const i=`${(1e9*Math.random()).toString(36)}${Date.now()}`;let s=r.topologies.get(e);return null==s&&(s=new Map,r.topologies.set(e,s)),s.set(i,t),yield t.setRegistrar(r),i})()}unregister(e){for(const[t,r]of this.topologies.entries())r.has(e)&&(r.delete(e),0===r.size&&this.topologies.delete(t))}_onDisconnect(e){const t=e.detail;this.components.getPeerStore().protoBook.get(t.remotePeer).then(r=>{for(const i of r){const s=this.topologies.get(i);if(null!=s)for(const o of s.values())o.onDisconnect(t.remotePeer)}}).catch(r=>{HT.error(r)})}_onProtocolChange(e){const{peerId:t,protocols:r,oldProtocols:i}=e.detail,s=i.filter(a=>!r.includes(a)),o=r.filter(a=>!i.includes(a));for(const a of s){const u=this.topologies.get(a);if(null!=u)for(const _ of u.values())_.onDisconnect(t)}for(const a of o){const u=this.topologies.get(a);if(null!=u)for(const _ of u.values()){const R=this.components.getConnectionManager().getConnections(t)[0];null!=R&&_.onConnect(t,R)}}}}const Gn=Gt("libp2p:upgrader");function jT(n,e,t){let r=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===n&&r++}),r}class q7 extends Ei{constructor(e,t){super(),this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(r=>{this.connectionEncryption.set(r.protocol,r)}),this.muxers=new Map,t.muxers.forEach(r=>{this.muxers.set(r.protocol,r)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout}upgradeInbound(e){var t=this;return j(function*(){let r,i,s,o,a,u,_;const R=t.components.getMetrics(),N=new bi.TimeoutController(t.inboundUpgradeTimeout);try{(0,Vr.setMaxListeners)?.(1/0,N.signal)}catch{}try{const B=zo(e,N.signal);if(e.source=B.source,e.sink=B.sink,yield t.components.getConnectionGater().denyInboundConnection(e))throw ae(new Error("The multiaddr connection is blocked by gater.acceptConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(null!=R){({setTarget:u,proxy:_}=UT());const J=`${(1e9*Math.random()).toString(36)}${Date.now()}`;u({toString:()=>J}),R.trackStream({stream:e,remotePeer:_})}Gn("starting the inbound connection upgrade");let K=e;const Z=t.components.getConnectionProtector();null!=Z&&(Gn("protecting the inbound connection"),K=yield Z.protect(e));try{if(({conn:r,remotePeer:i,protocol:a}=yield t._encryptInbound(K)),yield t.components.getConnectionGater().denyInboundEncryptedConnection(i,{...K,...r}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const J=yield t._multiplexInbound({...K,...r},t.muxers);o=J.muxerFactory,s=J.stream}else s=r}catch(J){throw Gn.error("Failed to upgrade inbound connection",J),yield e.close(J),J}if(yield t.components.getConnectionGater().denyInboundUpgradedConnection(i,{...K,...r}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);return null!=R&&(R.updatePlaceholder(_,i),u(i)),Gn("Successfully upgraded inbound connection"),t._createConnection({cryptoProtocol:a,direction:"inbound",maConn:e,upgradedConn:s,muxerFactory:o,remotePeer:i})}finally{N.clear()}})()}upgradeOutbound(e){var t=this;return j(function*(){const r=e.remoteAddr.getPeerId();if(null==r)throw ae(new Error("outbound connection must have a peer id"),Ce.ERR_INVALID_MULTIADDR);const i=fr(r);if(yield t.components.getConnectionGater().denyOutboundConnection(i,e))throw ae(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),Ce.ERR_CONNECTION_INTERCEPTED);let s,o,a,u,_,R,N;const B=t.components.getMetrics();if(null!=B){({setTarget:R,proxy:N}=UT());const J=`${(1e9*Math.random()).toString(36)}${Date.now()}`;R({toB58String:()=>J}),B.trackStream({stream:e,remotePeer:N})}Gn("Starting the outbound connection upgrade");let K=e;const Z=t.components.getConnectionProtector();null!=Z&&(K=yield Z.protect(e));try{if(({conn:s,remotePeer:o,protocol:u}=yield t._encryptOutbound(K,i)),yield t.components.getConnectionGater().denyOutboundEncryptedConnection(o,{...K,...s}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const J=yield t._multiplexOutbound({...K,...s},t.muxers);_=J.muxerFactory,a=J.stream}else a=s}catch(J){throw Gn.error("Failed to upgrade outbound connection",J),yield e.close(J),J}if(yield t.components.getConnectionGater().denyOutboundUpgradedConnection(o,{...K,...s}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);return null!=B&&(B.updatePlaceholder(N,o),R(o)),Gn("Successfully upgraded outbound connection"),t._createConnection({cryptoProtocol:u,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:_,remotePeer:o})})()}_createConnection(e){var t=this;const{cryptoProtocol:r,direction:i,maConn:s,upgradedConn:o,remotePeer:a,muxerFactory:u}=e;let _,R,N;null!=u&&(_=u.createStreamMuxer({direction:i,onIncomingStream:Z=>{null!=N&&Promise.resolve().then(j(function*(){const J=t.components.getRegistrar().getProtocols(),{stream:oe,protocol:he}=yield Uv(Z,J);if(Gn("%s: incoming stream opened on %s",i,he),t.components.getMetrics()?.trackStream({stream:oe,remotePeer:a,protocol:he}),null==N)return;const ue=function z7(n,e){try{const{options:t}=e.getHandler(n);return t.maxInboundStreams}catch(t){if(t.code!==Ce.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 32}(he,t.components.getRegistrar());jT(he,"inbound",N)!==ue?(Z.stat.protocol=he,t.components.getPeerStore().protoBook.add(a,[he]).catch(ze=>Gn.error(ze)),N.addStream(Z),t._onStream({connection:N,stream:{...Z,...oe},protocol:he})):Z.abort(ae(new Error(`Too many inbound protocol streams for protocol "${he}" - limit ${ue}`),Ce.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS))})).catch(J=>{Gn.error(J),null==Z.stat.timeline.close&&Z.close()})},onStreamEnd:Z=>{N?.removeStream(Z.id)}}),Fr(_)&&_.init(this.components),R=function(){var Z=j(function*(J,oe={}){if(null==_)throw ae(new Error("Stream is not multiplexed"),Ce.ERR_MUXER_UNAVAILABLE);Gn("%s: starting new stream on %s",i,J);const he=_.newStream(),Ie=t.components.getMetrics();let ue;try{if(null==oe.signal){Gn("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",J),ue=new bi.TimeoutController(3e4),oe.signal=ue.signal;try{(0,Vr.setMaxListeners)?.(1/0,ue.signal)}catch{}}const{stream:Re,protocol:ze}=yield Bv(he,J,oe);Ie?.trackStream({stream:Re,remotePeer:a,protocol:ze});const Oe=function W7(n,e){try{const{options:t}=e.getHandler(n);return t.maxOutboundStreams}catch(t){if(t.code!==Ce.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 64}(ze,t.components.getRegistrar());if(jT(ze,"outbound",N)===Oe){const vt=ae(new Error(`Too many outbound protocol streams for protocol "${ze}" - limit ${Oe}`),Ce.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw he.abort(vt),vt}return he.stat.protocol=ze,t.components.getPeerStore().protoBook.add(a,[ze]).catch(vt=>Gn.error(vt)),{...he,...Re,stat:{...he.stat,protocol:ze}}}catch(Re){throw Gn.error("could not create new stream",Re),null==he.stat.timeline.close&&he.close(),null!=Re.code?Re:ae(Re,Ce.ERR_UNSUPPORTED_PROTOCOL)}finally{ue?.clear()}});return function(oe){return Z.apply(this,arguments)}}(),Wn(o,_,o).catch(Gn.error));const B=s.timeline;s.timeline=new Proxy(B,{set:(...Z)=>(null!=N&&"close"===Z[1]&&null!=Z[2]&&null==B.close&&j(function*(){try{"OPEN"===N.stat.status&&(yield N.close())}catch(J){Gn.error(J)}finally{t.dispatchEvent(new tn("connectionEnd",{detail:N}))}})().catch(J=>{Gn.error(J)}),Reflect.set(...Z))}),s.timeline.upgraded=Date.now();const K=()=>{throw ae(new Error("connection is not multiplexed"),Ce.ERR_CONNECTION_NOT_MULTIPLEXED)};return N=function $7(n){return new K7(n)}({remoteAddr:s.remoteAddr,remotePeer:a,stat:{status:"OPEN",direction:i,timeline:s.timeline,multiplexer:_?.protocol,encryption:r},newStream:R??K,getStreams:()=>null!=_?_.streams:K(),close:(Z=j(function*(){yield s.close(),_?.close()}),function(){return Z.apply(this,arguments)})}),this.dispatchEvent(new tn("connection",{detail:N})),N;var Z}_onStream(e){const{connection:t,stream:r,protocol:i}=e,{handler:s}=this.components.getRegistrar().getHandler(i);s({connection:t,stream:r})}_encryptInbound(e){var t=this;return j(function*(){const r=Array.from(t.connectionEncryption.keys());Gn("handling inbound crypto protocol selection",r);try{const{stream:i,protocol:s}=yield Uv(e,r,{writeBytes:!0}),o=t.connectionEncryption.get(s);if(null==o)throw new Error(`no crypto module found for ${s}`);return Gn("encrypting inbound connection..."),{...yield o.secureInbound(t.components.getPeerId(),i),protocol:s}}catch(i){throw ae(i,Ce.ERR_ENCRYPTION_FAILED)}})()}_encryptOutbound(e,t){var r=this;return j(function*(){const i=Array.from(r.connectionEncryption.keys());Gn("selecting outbound crypto protocol",i);try{const{stream:s,protocol:o}=yield Bv(e,i,{writeBytes:!0}),a=r.connectionEncryption.get(o);if(null==a)throw new Error(`no crypto module found for ${o}`);return Gn("encrypting outbound connection to %p",t),{...yield a.secureOutbound(r.components.getPeerId(),s,t),protocol:o}}catch(s){throw ae(s,Ce.ERR_ENCRYPTION_FAILED)}})()}_multiplexOutbound(e,t){return j(function*(){const r=Array.from(t.keys());Gn("outbound selecting muxer %s",r);try{const{stream:i,protocol:s}=yield Bv(e,r,{writeBytes:!0});return Gn("%s selected as muxer protocol",s),{stream:i,muxerFactory:t.get(s)}}catch(i){throw Gn.error("error multiplexing outbound stream",i),ae(i,Ce.ERR_MUXER_UNAVAILABLE)}})()}_multiplexInbound(e,t){return j(function*(){const r=Array.from(t.keys());Gn("inbound handling muxers %s",r);try{const{stream:i,protocol:s}=yield Uv(e,r,{writeBytes:!0});return{stream:i,muxerFactory:t.get(s)}}catch(i){throw Gn.error("error multiplexing inbound stream",i),ae(i,Ce.ERR_MUXER_UNAVAILABLE)}})()}}var Na;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.protocolVersion&&(r.uint32(42),r.string(t.protocolVersion)),null!=t.agentVersion&&(r.uint32(50),r.string(t.agentVersion)),null!=t.publicKey&&(r.uint32(10),r.bytes(t.publicKey)),null==t.listenAddrs)throw new Error('Protocol error: required field "listenAddrs" was not found in object');for(const s of t.listenAddrs)r.uint32(18),r.bytes(s);if(null!=t.observedAddr&&(r.uint32(34),r.bytes(t.observedAddr)),null==t.protocols)throw new Error('Protocol error: required field "protocols" was not found in object');for(const s of t.protocols)r.uint32(26),r.string(s);null!=t.signedPeerRecord&&(r.uint32(66),r.bytes(t.signedPeerRecord)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 5:i.protocolVersion=t.string();break;case 6:i.agentVersion=t.string();break;case 1:i.publicKey=t.bytes();break;case 2:i.listenAddrs=i.listenAddrs??[],i.listenAddrs.push(t.bytes());break;case 4:i.observedAddr=t.bytes();break;case 3:i.protocols=i.protocols??[],i.protocols.push(t.string());break;case 8:i.signedPeerRecord=t.bytes();break;default:t.skipType(7&o)}}if(i.listenAddrs=i.listenAddrs??[],i.protocols=i.protocols??[],null==i.listenAddrs)throw new Error('Protocol error: value for required field "listenAddrs" was not found in protobuf');if(null==i.protocols)throw new Error('Protocol error: value for required field "protocols" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Na||(Na={}));var Ch;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.publicKey)throw new Error('Protocol error: required field "publicKey" was not found in object');if(r.uint32(10),r.bytes(t.publicKey),null==t.payloadType)throw new Error('Protocol error: required field "payloadType" was not found in object');if(r.uint32(18),r.bytes(t.payloadType),null==t.payload)throw new Error('Protocol error: required field "payload" was not found in object');if(r.uint32(26),r.bytes(t.payload),null==t.signature)throw new Error('Protocol error: required field "signature" was not found in object');r.uint32(42),r.bytes(t.signature),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.publicKey=t.bytes();break;case 2:i.payloadType=t.bytes();break;case 3:i.payload=t.bytes();break;case 5:i.signature=t.bytes();break;default:t.skipType(7&o)}}if(null==i.publicKey)throw new Error('Protocol error: value for required field "publicKey" was not found in protobuf');if(null==i.payloadType)throw new Error('Protocol error: value for required field "payloadType" was not found in protobuf');if(null==i.payload)throw new Error('Protocol error: value for required field "payload" was not found in protobuf');if(null==i.signature)throw new Error('Protocol error: value for required field "signature" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Ch||(Ch={}));class wi{constructor(e){const{peerId:t,payloadType:r,payload:i,signature:s}=e;this.peerId=t,this.payloadType=r,this.payload=i,this.signature=s}marshal(){if(null==this.peerId.publicKey)throw new Error("Missing public key");return null==this.marshaled&&(this.marshaled=Ch.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return kr(this.marshal(),e.marshal())}validate(e){var t=this;return j(function*(){const r=GT(e,t.payloadType,t.payload);if(null==t.peerId.publicKey)throw new Error("Missing public key");return yield Rl(t.peerId.publicKey).verify(r.subarray(),t.signature)})()}}wi.createFromProtobuf=function(){var n=j(function*(e){const t=Ch.decode(e),r=yield kl(t.publicKey);return new wi({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})});return function(e){return n.apply(this,arguments)}}(),wi.seal=function(){var n=j(function*(e,t){if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,i=e.codec,s=e.marshal(),o=GT(r,i,s),u=yield(yield Pl(t.privateKey)).sign(o.subarray());return new wi({peerId:t,payloadType:i,payload:s,signature:u})});return function(e,t){return n.apply(this,arguments)}}(),wi.openAndCertify=function(){var n=j(function*(e,t){const r=yield wi.createFromProtobuf(e);if(!(yield r.validate(t)))throw ae(new Error("envelope signature is not valid for the given domain"),"ERR_SIGNATURE_NOT_VALID");return r});return function(e,t){return n.apply(this,arguments)}}();const GT=(n,e,t)=>{const r=Ot(n),i=Ni.encode(r.byteLength),s=Ni.encode(e.length),o=Ni.encode(t.length);return new qr(i,r,s,e,o,t)};var Ih;!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Yt((s,o,a={})=>{if(!1!==a.lengthDelimited&&o.fork(),null==s.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');o.uint32(10),o.bytes(s.multiaddr),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={multiaddr:new Uint8Array(0)},u=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.multiaddr=s.bytes():s.skipType(7&_)}if(null==a.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return a})),i),r.encode=s=>qt(s,r.codec()),r.decode=s=>Wt(s,r.codec())}(e=n.AddressInfo||(n.AddressInfo={})),n.codec=()=>(null==t&&(t=Yt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null==r.peerId)throw new Error('Protocol error: required field "peerId" was not found in object');if(i.uint32(10),i.bytes(r.peerId),null==r.seq)throw new Error('Protocol error: required field "seq" was not found in object');if(i.uint32(16),i.uint64(r.seq),null==r.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');for(const o of r.addresses)i.uint32(26),n.AddressInfo.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={peerId:new Uint8Array(0),seq:0n,addresses:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.peerId=r.bytes();break;case 2:s.seq=r.uint64();break;case 3:s.addresses.push(n.AddressInfo.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}if(null==s.peerId)throw new Error('Protocol error: value for required field "peerId" was not found in protobuf');if(null==s.seq)throw new Error('Protocol error: value for required field "seq" was not found in protobuf');return s})),t),n.encode=r=>qt(r,n.codec()),n.decode=r=>Wt(r,n.codec())}(Ih||(Ih={}));const J7=Uint8Array.from([3,1]);let iu=(()=>{class n{constructor(t){this.domain=n.DOMAIN,this.codec=n.CODEC;const{peerId:r,multiaddrs:i,seqNumber:s}=t;this.peerId=r,this.multiaddrs=i??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=Ih.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!!(t instanceof n&&this.peerId.equals(t.peerId)&&this.seqNumber===t.seqNumber&&function Z7(n,e){const t=(r,i)=>r.toString().localeCompare(i.toString());return n.length===e.length&&e.sort(t)&&n.sort(t).every((r,i)=>e[i].equals(r))}(this.multiaddrs,t.multiaddrs))}}return n.createFromProtobuf=e=>{const t=Ih.decode(e),r=Jc(t.peerId),i=(t.addresses??[]).map(o=>new yn(o.multiaddr));return new n({peerId:r,multiaddrs:i,seqNumber:t.seq})},n.DOMAIN="libp2p-peer-record",n.CODEC=J7,n})();const WT="js-libp2p/0.0.0",Hn=Gt("libp2p:identify");class Kv{constructor(e,t){this.components=e,this.started=!1,this.init=t,this.identifyProtocolStr=`/${t.protocolPrefix}/id/1.0.0`,this.identifyPushProtocolStr=`/${t.protocolPrefix}/id/push/1.0.0`,this.host={protocolVersion:`${t.protocolPrefix}/0.1.0`,...t.host},this.components.getConnectionManager().addEventListener("peer:connect",r=>{this.identify(r.detail).catch(Hn.error)}),this.components.getPeerStore().addEventListener("change:multiaddrs",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Hn.error(s))}),this.components.getPeerStore().addEventListener("change:protocols",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Hn.error(s))})}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started||(yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"AgentVersion",Ot(e.host.agentVersion)),yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"ProtocolVersion",Ot(e.host.protocolVersion)),yield e.components.getRegistrar().handle(e.identifyProtocolStr,t=>{e._handleIdentify(t).catch(r=>{Hn.error(r)})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),yield e.components.getRegistrar().handle(e.identifyPushProtocolStr,t=>{e._handlePush(t).catch(r=>{Hn.error(r)})},{maxInboundStreams:e.init.maxPushIncomingStreams,maxOutboundStreams:e.init.maxPushOutgoingStreams}),e.started=!0)})()}stop(){var e=this;return j(function*(){yield e.components.getRegistrar().unhandle(e.identifyProtocolStr),yield e.components.getRegistrar().unhandle(e.identifyPushProtocolStr),e.started=!1})()}push(e){var t=this;return j(function*(){const r=yield t.components.getPeerStore().addressBook.getRawEnvelope(t.components.getPeerId()),i=t.components.getAddressManager().getAddresses().map(a=>a.bytes),s=yield t.components.getPeerStore().protoBook.get(t.components.getPeerId()),o=e.map(function(){var a=j(function*(u){let _;const R=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,R.signal)}catch{}try{_=yield u.newStream([t.identifyPushProtocolStr],{signal:R.signal});const N=zo(_,R.signal);yield Wn([Na.encode({listenAddrs:i,signedPeerRecord:r,protocols:s})],Os(),N,Qo)}catch(N){Hn.error("could not push identify update to peer",N)}finally{_?.close(),R.clear()}});return function(u){return a.apply(this,arguments)}}());yield Promise.all(o)})()}pushToPeerStore(){var e=this;return j(function*(){if(!e.isStarted())return;const t=[];for(const r of e.components.getConnectionManager().getConnections()){const i=r.remotePeer;!(yield e.components.getPeerStore().get(i)).protocols.includes(e.identifyPushProtocolStr)||t.push(r)}yield e.push(t)})()}_identify(e,t={}){var r=this;return j(function*(){let i,o,s=t.signal;if(null==s){i=new bi.TimeoutController(r.init.timeout),s=i.signal;try{(0,Vr.setMaxListeners)?.(1/0,i.signal)}catch{}}try{o=yield e.newStream([r.identifyProtocolStr],{signal:s});const a=zo(o,s),u=yield Wn([],a,ps({maxDataLength:r.init.maxIdentifyMessageSize??8192}),function(){var _=j(function*(R){return yield Aa(R)});return function(R){return _.apply(this,arguments)}}());if(null==u)throw ae(new Error("No data could be retrieved"),Ce.ERR_CONNECTION_ENDED);try{return Na.decode(u)}catch(_){throw ae(_,Ce.ERR_INVALID_MESSAGE)}}finally{i?.clear(),o?.close()}})()}identify(e,t={}){var r=this;return j(function*(){const i=yield r._identify(e,t),{publicKey:s,listenAddrs:o,protocols:a,observedAddr:u,signedPeerRecord:_,agentVersion:R,protocolVersion:N}=i;if(null==s)throw ae(new Error("public key was missing from identify message"),Ce.ERR_MISSING_PUBLIC_KEY);const B=yield kl(s);if(!e.remotePeer.equals(B))throw ae(new Error("identified peer does not match the expected peer"),Ce.ERR_INVALID_PEER);if(r.components.getPeerId().equals(B))throw ae(new Error("identified peer is our own peer id?"),Ce.ERR_INVALID_PEER);const K=Kv.getCleanMultiaddr(u);if(null!=_){Hn("received signed peer record from %p",B);try{const Z=yield wi.openAndCertify(_,iu.DOMAIN);if(!Z.peerId.equals(B))throw ae(new Error("identified peer does not match the expected peer"),Ce.ERR_INVALID_PEER);if(yield r.components.getPeerStore().addressBook.consumePeerRecord(Z))return yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",Ot(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",Ot(N))),void Hn("identify completed for peer %p and protocols %o",B,a)}catch(Z){Hn("received invalid envelope, discard it and fallback to listenAddrs is available",Z)}}else Hn("no signed peer record received from %p",B);Hn("falling back to legacy addresses from %p",B);try{yield r.components.getPeerStore().addressBook.set(B,o.map(Z=>new yn(Z)))}catch(Z){Hn.error("received invalid addrs",Z)}yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",Ot(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",Ot(N))),Hn("identify completed for peer %p and protocols %o",B,a),Hn("received observed address of %s",K?.toString())})()}_handleIdentify(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=t.components.getPeerId().publicKey??new Uint8Array(0),a=yield t.components.getPeerStore().get(t.components.getPeerId()),u=t.components.getAddressManager().getAddresses().map(B=>B.decapsulateCode(Sr("p2p").code));let _=a.peerRecordEnvelope;if(u.length>0&&null==_){const B=new iu({peerId:t.components.getPeerId(),multiaddrs:u}),K=yield wi.seal(B,t.components.getPeerId());yield t.components.getPeerStore().addressBook.consumePeerRecord(K),_=K.marshal().subarray()}const R=Na.encode({protocolVersion:t.host.protocolVersion,agentVersion:t.host.agentVersion,publicKey:o,listenAddrs:u.map(B=>B.bytes),signedPeerRecord:_,observedAddr:r.remoteAddr.bytes,protocols:a.protocols}),N=zo(i,s.signal);yield Wn([R],Os(),N,Qo)}catch(o){Hn.error("could not respond to identify request",o)}finally{i.close(),s.clear()}})()}_handlePush(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}let o;try{const u=zo(i,s.signal),_=yield Wn([],u,ps({maxDataLength:t.init.maxIdentifyMessageSize??8192}),function(){var R=j(function*(N){return yield Aa(N)});return function(N){return R.apply(this,arguments)}}());null!=_&&(o=Na.decode(_))}catch(u){return Hn.error("received invalid message",u)}finally{i.close(),s.clear()}if(null==o)return Hn.error("received invalid message");const a=r.remotePeer;if(t.components.getPeerId().equals(a))Hn("received push from ourselves?");else{if(Hn("received push from %p",a),null!=o.signedPeerRecord){Hn("received signedPeerRecord in push");try{const u=yield wi.openAndCertify(o.signedPeerRecord,iu.DOMAIN);if(yield t.components.getPeerStore().addressBook.consumePeerRecord(u))return Hn("consumed signedPeerRecord sent in push"),void(yield t.components.getPeerStore().protoBook.set(a,o.protocols));Hn("failed to consume signedPeerRecord sent in push")}catch(u){Hn("received invalid envelope, discard it and fallback to listenAddrs is available",u)}}else Hn("did not receive signedPeerRecord in push");try{yield t.components.getPeerStore().addressBook.set(a,o.listenAddrs.map(u=>new yn(u)))}catch(u){Hn.error("received invalid addrs",u)}try{yield t.components.getPeerStore().protoBook.set(a,o.protocols)}catch(u){Hn.error("received invalid protocols",u)}Hn("handled push from %p",a)}})()}static getCleanMultiaddr(e){if(null!=e&&e.length>0)try{return new yn(e)}catch{}}}var Th,Vs;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.identifier)throw new Error('Protocol error: required field "identifier" was not found in object');r.uint32(10),r.string(t.identifier),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.identifier=t.string():t.skipType(7&o)}if(null==i.identifier)throw new Error('Protocol error: value for required field "identifier" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Th||(Th={})),function(n){let e;var i;let t,r;(i=e=n.StatusCode||(n.StatusCode={})).OK="OK",i.NOT_FOUND="NOT_FOUND",i.ERROR="ERROR",function(i){i[i.OK=0]="OK",i[i.NOT_FOUND=1]="NOT_FOUND",i[i.ERROR=2]="ERROR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.StatusCode||(n.StatusCode={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.status)throw new Error('Protocol error: required field "status" was not found in object');if(s.uint32(8),n.StatusCode.codec().encode(i.status,s),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(18),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.status=n.StatusCode.codec().decode(i);break;case 2:o.data=i.bytes();break;default:i.skipType(7&u)}}if(null==o.status)throw new Error('Protocol error: value for required field "status" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(Vs||(Vs={}));const YT=Gt("libp2p:fetch");class l9{constructor(e,t){this.started=!1,this.components=e,this.protocol=`/${t.protocolPrefix??"libp2p"}/fetch/0.0.1`,this.lookupFunctions=new Map,this.handleMessage=this.handleMessage.bind(this),this.init=t}start(){var e=this;return j(function*(){yield e.components.getRegistrar().handle(e.protocol,t=>{e.handleMessage(t).catch(r=>{YT.error(r)}).finally(()=>{t.stream.close()})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return j(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}fetch(e,t,r={}){var i=this;return j(function*(){YT("dialing %s to %p",i.protocol,e);const s=yield i.components.getConnectionManager().openConnection(e,r);let o,u,a=r.signal;if(null==a){o=new bi.TimeoutController(i.init.timeout),a=o.signal;try{(0,Vr.setMaxListeners)?.(1/0,o.signal)}catch{}}try{u=yield s.newStream([i.protocol],{signal:a});const _=zo(u,a);return(yield Wn([Th.encode({identifier:t})],Os(),_,ps(),function(){var N=j(function*(B){const K=yield Aa(B);if(null==K)throw ae(new Error("No data received"),Ce.ERR_INVALID_MESSAGE);const Z=Vs.decode(K);switch(Z.status){case Vs.StatusCode.OK:return Z.data;case Vs.StatusCode.NOT_FOUND:return null;case Vs.StatusCode.ERROR:{const J=(new TextDecoder).decode(Z.data);throw ae(new Error("Error in fetch protocol response: "+J),Ce.ERR_INVALID_PARAMETERS)}default:throw ae(new Error("Unknown response status"),Ce.ERR_INVALID_MESSAGE)}});return function(B){return N.apply(this,arguments)}}()))??null}finally{o?.clear(),u?.close()}})()}handleMessage(e){var t=this;return j(function*(){const{stream:r}=e,i=t;yield Wn(r,ps(),function(){var s=dn(function*(o){const a=yield lt(Aa(o));if(null==a)throw ae(new Error("No data received"),Ce.ERR_INVALID_MESSAGE);const u=Th.decode(a);let _;const R=i._getLookupFunction(u.identifier);if(null!=R){const N=yield lt(R(u.identifier));_=null!=N?{status:Vs.StatusCode.OK,data:N}:{status:Vs.StatusCode.NOT_FOUND,data:new Uint8Array(0)}}else{const N=(new TextEncoder).encode("No lookup function registered for key: "+u.identifier);_={status:Vs.StatusCode.ERROR,data:N}}yield Vs.encode(_)});return function(o){return s.apply(this,arguments)}}(),Os(),r)})()}_getLookupFunction(e){for(const t of this.lookupFunctions.keys())if(e.startsWith(t))return this.lookupFunctions.get(t)}registerLookupFunction(e,t){if(this.lookupFunctions.has(e))throw ae(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),Ce.ERR_KEY_ALREADY_EXISTS);this.lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){null!=t&&this.lookupFunctions.get(e)!==t||this.lookupFunctions.delete(e)}}const QT=Gt("libp2p:ping");class p9{constructor(e,t){this.components=e,this.started=!1,this.protocol=`/${t.protocolPrefix}/ping/1.0.0`,this.init=t}start(){var e=this;return j(function*(){yield e.components.getRegistrar().handle(e.protocol,e.handleMessage,{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return j(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}handleMessage(e){const{stream:t}=e;Wn(t,t).catch(r=>{QT.error(r)})}ping(e,t={}){var r=this;return j(function*(){QT("dialing %s to %p",r.protocol,e);const i=Date.now(),s=nh(32),o=yield r.components.getConnectionManager().openConnection(e,t);let a,_,u=t.signal;if(null==u){a=new bi.TimeoutController(r.init.timeout),u=a.signal;try{(0,Vr.setMaxListeners)?.(1/0,a.signal)}catch{}}try{_=yield o.newStream([r.protocol],{signal:u});const R=zo(_,u),N=yield Wn([s],R,function(){var K=j(function*(Z){return yield Aa(Z)});return function(Z){return K.apply(this,arguments)}}()),B=Date.now();if(null==N||!kr(s,N.subarray()))throw ae(new Error("Received wrong ping ack"),Ce.ERR_WRONG_PING_ACK);return B-i}finally{a?.clear(),_?.close()}})()}}function $v(){return($v=j(function*(){throw new Error("Not supported in browsers")})).apply(this,arguments)}function m9(n){const{address:e}=n.nodeAddress();return function y9(n){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(n)||/^::1$/.test(n)}(e)}const Gv=Gt("libp2p:nat");function v9(n=1024,e=65535){return Math.floor(Math.random()*(e-n+1)+n)}class E9{constructor(e,t){if(this.components=e,this.started=!1,this.enabled=t.enabled,this.externalAddress=t.externalAddress,this.localAddress=t.localAddress,this.description=t.description??`libp2p@0.0.0 ${this.components.getPeerId().toString()}`,this.ttl=t.ttl??7200,this.keepAlive=t.keepAlive??!0,this.gateway=t.gateway,this.ttl<7200)throw ae(new Error("NatManager ttl should be at least 7200 seconds"),Ce.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){mh||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{Gv.error(e)}))}_start(){var e=this;return j(function*(){const t=e.components.getTransportManager().getAddrs();for(const r of t){const{family:i,host:s,port:o,transport:a}=r.toOptions();if(!r.isThinWaistAddress()||"tcp"!==a||m9(r)||4!==i)continue;const u=yield e._getClient(),_=e.externalAddress??(yield u.externalIp());if(yT(_))throw new Error(`${_} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);const R=v9();Gv(`opening uPnP connection from ${_}:${R} to ${s}:${o}`),yield u.map({publicPort:R,localPort:o,localAddress:e.localAddress,protocol:"TCP"===a.toUpperCase()?"TCP":"UDP"}),e.components.getAddressManager().addObservedAddr(yn.fromNodeAddress({family:4,address:_,port:R},a))}})()}_getClient(){var e=this;return j(function*(){return null!=e.client||(e.client=yield function g9(){return $v.apply(this,arguments)}({description:e.description,ttl:e.ttl,keepAlive:e.keepAlive,gateway:e.gateway})),e.client})()}stop(){var e=this;return j(function*(){if(!mh&&null!=e.client)try{yield e.client.close(),e.client=void 0}catch(t){Gv.error(t)}})()}}const b9=Gt("libp2p:peer-record-updater");class w9{constructor(e){this.components=e,this.started=!1,this.update=this.update.bind(this)}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started=!0,e.components.getTransportManager().addEventListener("listener:listening",e.update),e.components.getTransportManager().addEventListener("listener:close",e.update),e.components.getAddressManager().addEventListener("change:addresses",e.update)})()}stop(){var e=this;return j(function*(){e.started=!1,e.components.getTransportManager().removeEventListener("listener:listening",e.update),e.components.getTransportManager().removeEventListener("listener:close",e.update),e.components.getAddressManager().removeEventListener("change:addresses",e.update)})()}update(){var e=this;Promise.resolve().then(j(function*(){const t=new iu({peerId:e.components.getPeerId(),multiaddrs:e.components.getAddressManager().getAddresses().map(i=>i.decapsulateCode(Sr("p2p").code))}),r=yield wi.seal(t,e.components.getPeerId());yield e.components.getPeerStore().addressBook.consumePeerRecord(r)})).catch(t=>{b9.error("Could not update self peer record: %o",t)})}}class _9{constructor(e){this.dht=e}findPeer(e,t={}){var r=this;return j(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.findPeer(e,t));i=!(u=yield a.next()).done;i=!1){const _=u.value;if("FINAL_PEER"===_.name)return _.peer}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw ae(new Error(_n.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getClosestPeers(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.getClosestPeers(e,t));i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;"PEER_RESPONSE"===_.name&&(yield*Mr(Pt(_.closer),lt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}}const Ln=Gt("libp2p:peer-store:address-book"),Ah="change:multiaddrs";function D9(){return Wv.apply(this,arguments)}function Wv(){return(Wv=j(function*(){return!0})).apply(this,arguments)}class S9{constructor(e,t,r){this.dispatchEvent=e,this.store=t,this.addressFilter=r??D9}consumePeerRecord(e){var t=this;return j(function*(){Ln.trace("consumePeerRecord await write lock");const r=yield t.store.lock.writeLock();let i,s,o;Ln.trace("consumePeerRecord got write lock");try{let a;try{a=iu.createFromProtobuf(e.payload)}catch{return Ln.error("invalid peer record received"),!1}i=a.peerId;const u=a.multiaddrs;if(!i.equals(e.peerId))return Ln("signing key does not match PeerId in the PeerRecord"),!1;if(null==u||0===u.length)return!1;if((yield t.store.has(i))&&(s=yield t.store.load(i),null!=s.peerRecordEnvelope)){const R=yield wi.createFromProtobuf(s.peerRecordEnvelope),N=iu.createFromProtobuf(R.payload);if(N.seqNumber>=a.seqNumber)return Ln("sequence number was lower or equal to existing sequence number - stored: %d received: %d",N.seqNumber,a.seqNumber),!1}const _=yield qv(i,u,t.addressFilter,!0);o=yield t.store.patchOrCreate(i,{addresses:_,peerRecordEnvelope:e.marshal().subarray()}),Ln("stored provided peer record for %p",a.peerId)}finally{Ln.trace("consumePeerRecord release write lock"),r()}return t.dispatchEvent(new tn(Ah,{detail:{peerId:i,multiaddrs:o.addresses.map(({multiaddr:a})=>a),oldMultiaddrs:null==s?[]:s.addresses.map(({multiaddr:a})=>a)}})),!0})()}getRawEnvelope(e){var t=this;return j(function*(){Ln.trace("getRawEnvelope await read lock");const r=yield t.store.lock.readLock();Ln.trace("getRawEnvelope got read lock");try{return(yield t.store.load(e)).peerRecordEnvelope}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ln.trace("getRawEnvelope release read lock"),r()}})()}getPeerRecord(e){var t=this;return j(function*(){const r=yield t.getRawEnvelope(e);if(null!=r)return yield wi.createFromProtobuf(r)})()}get(e){var t=this;return j(function*(){e=Br(e),Ln.trace("get wait for read lock");const r=yield t.store.lock.readLock();Ln.trace("get got read lock");try{return(yield t.store.load(e)).addresses}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ln.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ln.error("multiaddrs must be an array of Multiaddrs"),ae(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Ln.trace("set await write lock");const i=yield r.store.lock.writeLock();Ln.trace("set got write lock");let o,a,s=!1;try{const u=yield qv(e,t,r.addressFilter);if(0===u.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...u.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length&&u.length===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.patchOrCreate(e,{addresses:u}),Ln("set multiaddrs for %p",e)}finally{Ln.trace("set multiaddrs for %p",e),Ln("set release write lock"),i()}r.dispatchEvent(new tn(Ah,{detail:{peerId:e,multiaddrs:a.addresses.map(u=>u.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:u})=>u)}})),s||r.dispatchEvent(new tn("peer",{detail:{id:e,multiaddrs:a.addresses.map(u=>u.multiaddr),protocols:a.protocols}}))})()}add(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ln.error("multiaddrs must be an array of Multiaddrs"),ae(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Ln.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o,a;Ln.trace("add got write lock");try{const u=yield qv(e,t,r.addressFilter);if(0===u.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...u.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.mergeOrCreate(e,{addresses:u}),Ln("added multiaddrs for %p",e)}finally{Ln.trace("set release write lock"),i()}r.dispatchEvent(new tn(Ah,{detail:{peerId:e,multiaddrs:a.addresses.map(u=>u.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:u})=>u)}})),!0===s&&r.dispatchEvent(new tn("peer",{detail:{id:e,multiaddrs:a.addresses.map(u=>u.multiaddr),protocols:a.protocols}}))})()}delete(e){var t=this;return j(function*(){e=Br(e),Ln.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Ln.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{addresses:[]})}finally{Ln.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new tn(Ah,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:null==i?[]:i.addresses.map(({multiaddr:s})=>s)}}))})()}}function qv(n,e,t){return Yv.apply(this,arguments)}function Yv(){return Yv=j(function*(n,e,t,r=!1){return yield Wn(e,i=>xv(i,s=>{if(!yn.isMultiaddr(s))throw Ln.error("multiaddr must be an instance of Multiaddr"),ae(new Error("multiaddr must be an instance of Multiaddr"),"ERR_INVALID_PARAMETERS")}),i=>Ds(i,function(){var s=j(function*(o){return yield t(n,o)});return function(o){return s.apply(this,arguments)}}()),i=>uv(i,s=>({multiaddr:new yn(s.toString()),isCertified:r})),function(){var i=j(function*(s){return yield Ul(s)});return function(s){return i.apply(this,arguments)}}())}),Yv.apply(this,arguments)}const Hs=Gt("libp2p:peer-store:key-book"),ZT="change:pubkey";class C9{constructor(e,t){this.dispatchEvent=e,this.store=t}set(e,t){var r=this;return j(function*(){if(e=Br(e),!(t instanceof Uint8Array))throw Hs.error("publicKey must be an instance of Uint8Array to store data"),ae(new Error("publicKey must be an instance of PublicKey"),"ERR_INVALID_PARAMETERS");Hs.trace("set await write lock");const i=yield r.store.lock.writeLock();Hs.trace("set got write lock");let o,s=!1;try{try{if(o=yield r.store.load(e),null!=o.pubKey&&kr(o.pubKey,t))return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}yield r.store.patchOrCreate(e,{pubKey:t}),s=!0}finally{Hs.trace("set release write lock"),i()}s&&r.dispatchEvent(new tn(ZT,{detail:{peerId:e,publicKey:t,oldPublicKey:o?.pubKey}}))})()}get(e){var t=this;return j(function*(){e=Br(e),Hs.trace("get await write lock");const r=yield t.store.lock.readLock();Hs.trace("get got write lock");try{return(yield t.store.load(e)).pubKey}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Hs("get release write lock"),r()}})()}delete(e){var t=this;return j(function*(){e=Br(e),Hs.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Hs.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{pubKey:void 0})}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Hs.trace("delete release write lock"),r()}t.dispatchEvent(new tn(ZT,{detail:{peerId:e,publicKey:void 0,oldPublicKey:i?.pubKey}}))})()}}const Cr=Gt("libp2p:peer-store:metadata-book"),xh="change:metadata";class I9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return j(function*(){e=Br(e),Cr.trace("get await read lock");const r=yield t.store.lock.readLock();Cr.trace("get got read lock");try{return(yield t.store.load(e)).metadata}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Cr.trace("get release read lock"),r()}return new Map})()}getValue(e,t){var r=this;return j(function*(){e=Br(e),Cr.trace("getValue await read lock");const i=yield r.store.lock.readLock();Cr.trace("getValue got read lock");try{return(yield r.store.load(e)).metadata.get(t)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Cr.trace("getValue release write lock"),i()}})()}set(e,t){var r=this;return j(function*(){if(e=Br(e),!(t instanceof Map))throw Cr.error("valid metadata must be provided to store data"),ae(new Error("valid metadata must be provided"),"ERR_INVALID_PARAMETERS");Cr.trace("set await write lock");const i=yield r.store.lock.writeLock();let s;Cr.trace("set got write lock");try{try{s=yield r.store.load(e)}catch(o){if("ERR_NOT_FOUND"!==o.code)throw o}yield r.store.mergeOrCreate(e,{metadata:t})}finally{Cr.trace("set release write lock"),i()}r.dispatchEvent(new tn(xh,{detail:{peerId:e,metadata:t,oldMetadata:null==s?new Map:s.metadata}}))})()}setValue(e,t,r){var i=this;return j(function*(){if(e=Br(e),"string"!=typeof t||!(r instanceof Uint8Array))throw Cr.error("valid key and value must be provided to store data"),ae(new Error("valid key and value must be provided"),"ERR_INVALID_PARAMETERS");Cr.trace("setValue await write lock");const s=yield i.store.lock.writeLock();let o,a;Cr.trace("setValue got write lock");try{try{o=yield i.store.load(e);const u=o.metadata.get(t);if(null!=u&&kr(r,u))return}catch(u){if("ERR_NOT_FOUND"!==u.code)throw u}a=yield i.store.mergeOrCreate(e,{metadata:new Map([[t,r]])})}finally{Cr.trace("setValue release write lock"),s()}i.dispatchEvent(new tn(xh,{detail:{peerId:e,metadata:a.metadata,oldMetadata:null==o?new Map:o.metadata}}))})()}delete(e){var t=this;return j(function*(){e=Br(e),Cr.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Cr.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}null!=i&&(yield t.store.patch(e,{metadata:new Map}))}finally{Cr.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new tn(xh,{detail:{peerId:e,metadata:new Map,oldMetadata:i.metadata}}))})()}deleteValue(e,t){var r=this;return j(function*(){e=Br(e),Cr.trace("deleteValue await write lock");const i=yield r.store.lock.writeLock();let s,o;Cr.trace("deleteValue got write lock");try{o=yield r.store.load(e),s=o.metadata,s.delete(t),yield r.store.patch(e,{metadata:s})}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}finally{Cr.trace("deleteValue release write lock"),i()}null!=s&&r.dispatchEvent(new tn(xh,{detail:{peerId:e,metadata:s,oldMetadata:null==o?new Map:o.metadata}}))})()}}const Ir=Gt("libp2p:peer-store:proto-book"),Rh="change:protocols";class T9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return j(function*(){Ir.trace("get wait for read lock");const r=yield t.store.lock.readLock();Ir.trace("get got read lock");try{return(yield t.store.load(e)).protocols}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ir.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("set await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("set got write lock");try{try{if(s=yield r.store.load(e),new Set([...t]).size===s.protocols.length)return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t}),Ir("stored provided protocols for %p",e)}finally{Ir.trace("set release write lock"),i()}r.dispatchEvent(new tn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}add(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("add got write lock");try{try{if(s=yield r.store.load(e),new Set([...s.protocols,...t]).size===s.protocols.length)return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.mergeOrCreate(e,{protocols:t}),Ir("added provided protocols for %p",e)}finally{Ir.trace("add release write lock"),i()}r.dispatchEvent(new tn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}remove(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("remove await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("remove got write lock");try{try{s=yield r.store.load(e);const a=new Set(s.protocols);for(const u of t)a.delete(u);if(s.protocols.length===a.size)return;t=Array.from(a)}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t})}finally{Ir.trace("remove release write lock"),i()}r.dispatchEvent(new tn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}delete(e){var t=this;return j(function*(){e=Br(e),Ir.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Ir.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{protocols:[]})}finally{Ir.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new tn(Rh,{detail:{peerId:e,protocols:[],oldProtocols:i.protocols}}))})()}}var Ph,Nh,Mh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');for(const s of t.addresses)r.uint32(10),Nh.codec().encode(s,r);if(null==t.protocols)throw new Error('Protocol error: required field "protocols" was not found in object');for(const s of t.protocols)r.uint32(18),r.string(s);if(null==t.metadata)throw new Error('Protocol error: required field "metadata" was not found in object');for(const s of t.metadata)r.uint32(26),Mh.codec().encode(s,r);null!=t.pubKey&&(r.uint32(34),r.bytes(t.pubKey)),null!=t.peerRecordEnvelope&&(r.uint32(42),r.bytes(t.peerRecordEnvelope)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={addresses:[],protocols:[],metadata:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.addresses.push(Nh.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(Mh.codec().decode(t,t.uint32()));break;case 4:i.pubKey=t.bytes();break;case 5:i.peerRecordEnvelope=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Ph||(Ph={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');r.uint32(10),r.bytes(t.multiaddr),null!=t.isCertified&&(r.uint32(16),r.bool(t.isCertified)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={multiaddr:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.multiaddr=t.bytes();break;case 2:i.isCertified=t.bool();break;default:t.skipType(7&o)}}if(null==i.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Nh||(Nh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.key)throw new Error('Protocol error: required field "key" was not found in object');if(r.uint32(10),r.string(t.key),null==t.value)throw new Error('Protocol error: required field "value" was not found in object');r.uint32(18),r.bytes(t.value),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={key:"",value:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.key=t.string();break;case 2:i.value=t.bytes();break;default:t.skipType(7&o)}}if(null==i.key)throw new Error('Protocol error: value for required field "key" was not found in protobuf');if(null==i.value)throw new Error('Protocol error: value for required field "value" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Mh||(Mh={}));var A9=x(2005);class XT extends Error{constructor(e){super(e),this.name="TimeoutError"}}class x9 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const JT=n=>void 0===globalThis.DOMException?new x9(n):new DOMException(n),eA=n=>{const e=void 0===n.reason?JT("This operation was aborted."):n.reason;return e instanceof Error?e:JT(e)};function tA(n,e,t,r){let i;const s=new Promise((o,a)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:u}=r;u.aborted&&a(eA(u)),u.addEventListener("abort",()=>{a(eA(u))})}i=r.customTimers.setTimeout.call(void 0,()=>{if("function"==typeof t){try{o(t())}catch(R){a(R)}return}const _=t instanceof Error?t:new XT("string"==typeof t?t:`Promise timed out after ${e} milliseconds`);"function"==typeof n.cancel&&n.cancel(),a(_)},e),j(function*(){try{o(yield n)}catch(u){a(u)}finally{r.customTimers.clearTimeout.call(void 0,i)}})()}else o(n)});return s.clear=()=>{clearTimeout(i),i=void 0},s}var vo,Ma=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class P9{constructor(){vo.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&Ma(this,vo,"f")[this.size-1].priority>=t.priority)return void Ma(this,vo,"f").push(r);const i=function R9(n,e,t){let r=0,i=n.length;for(;i>0;){const s=Math.trunc(i/2);let o=r+s;t(n[o],e)<=0?(r=++o,i-=s+1):i=s}return r}(Ma(this,vo,"f"),r,(s,o)=>o.priority-s.priority);Ma(this,vo,"f").splice(i,0,r)}dequeue(){return Ma(this,vo,"f").shift()?.run}filter(e){return Ma(this,vo,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Ma(this,vo,"f").length}}vo=new WeakMap;var pr,Ql,Zl,ea,Oh,Xl,kh,Ss,Jl,Oi,Lh,ki,ef,ta,Bh,nA,rA,iA,sA,oA,aA,Fh,Qv,Zv,Uh,Vh,rr=function(n,e,t,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?n!==e||!i:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(n,t):i?i.value=t:e.set(n,t),t},gt=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};const N9=new XT;class M9 extends Error{}class cA extends A9{constructor(e){var t,r,i,s;if(super(),pr.add(this),Ql.set(this,void 0),Zl.set(this,void 0),ea.set(this,0),Oh.set(this,void 0),Xl.set(this,void 0),kh.set(this,0),Ss.set(this,void 0),Jl.set(this,void 0),Oi.set(this,void 0),Lh.set(this,void 0),ki.set(this,0),ef.set(this,void 0),ta.set(this,void 0),Bh.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:P9,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(s=null===(i=e.interval)||void 0===i?void 0:i.toString())&&void 0!==s?s:""}\` (${typeof e.interval})`);rr(this,Ql,e.carryoverConcurrencyCount,"f"),rr(this,Zl,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),rr(this,Oh,e.intervalCap,"f"),rr(this,Xl,e.interval,"f"),rr(this,Oi,new e.queueClass,"f"),rr(this,Lh,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,rr(this,Bh,!0===e.throwOnTimeout,"f"),rr(this,ta,!1===e.autoStart,"f")}get concurrency(){return gt(this,ef,"f")}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);rr(this,ef,e,"f"),gt(this,pr,"m",Uh).call(this)}add(e,t={}){var r=this;return j(function*(){return new Promise((i,s)=>{const o=function(){var a=j(function*(){var u,_,R;rr(r,ki,(_=gt(r,ki,"f"),++_),"f"),rr(r,ea,(R=gt(r,ea,"f"),++R),"f");try{if(null!==(u=t.signal)&&void 0!==u&&u.aborted)return void s(new M9("The task was aborted."));const B=yield void 0===r.timeout&&void 0===t.timeout?e({signal:t.signal}):tA(Promise.resolve(e({signal:t.signal})),void 0===t.timeout?r.timeout:t.timeout,()=>{(void 0===t.throwOnTimeout?gt(r,Bh,"f"):t.throwOnTimeout)&&s(N9)});i(B),r.emit("completed",B)}catch(N){s(N),r.emit("error",N)}gt(r,pr,"m",iA).call(r)});return function(){return a.apply(this,arguments)}}();gt(r,Oi,"f").enqueue(o,t),gt(r,pr,"m",Fh).call(r),r.emit("add")})})()}addAll(e,t){var r=this;return j(function*(){return Promise.all(e.map(function(){var i=j(function*(s){return r.add(s,t)});return function(s){return i.apply(this,arguments)}}()))})()}start(){return gt(this,ta,"f")?(rr(this,ta,!1,"f"),gt(this,pr,"m",Uh).call(this),this):this}pause(){rr(this,ta,!0,"f")}clear(){rr(this,Oi,new(gt(this,Lh,"f")),"f")}onEmpty(){var e=this;return j(function*(){0!==gt(e,Oi,"f").size&&(yield gt(e,pr,"m",Vh).call(e,"empty"))})()}onSizeLessThan(e){var t=this;return j(function*(){gt(t,Oi,"f").sizegt(t,Oi,"f").size{gt(this,pr,"m",oA).call(this)},t),"f"),!0;rr(this,ea,gt(this,Ql,"f")?gt(this,ki,"f"):0,"f")}return!1},Fh=function(){if(0===gt(this,Oi,"f").size)return gt(this,Ss,"f")&&clearInterval(gt(this,Ss,"f")),rr(this,Ss,void 0,"f"),gt(this,pr,"m",sA).call(this),!1;if(!gt(this,ta,"f")){const e=!gt(this,pr,"a",aA);if(gt(this,pr,"a",nA)&>(this,pr,"a",rA)){const t=gt(this,Oi,"f").dequeue();return!!t&&(this.emit("active"),t(),e&>(this,pr,"m",Qv).call(this),!0)}}return!1},Qv=function(){gt(this,Zl,"f")||void 0!==gt(this,Ss,"f")||(rr(this,Ss,setInterval(()=>{gt(this,pr,"m",Zv).call(this)},gt(this,Xl,"f")),"f"),rr(this,kh,Date.now()+gt(this,Xl,"f"),"f"))},Zv=function(){0===gt(this,ea,"f")&&0===gt(this,ki,"f")&>(this,Ss,"f")&&(clearInterval(gt(this,Ss,"f")),rr(this,Ss,void 0,"f")),rr(this,ea,gt(this,Ql,"f")?gt(this,ki,"f"):0,"f"),gt(this,pr,"m",Uh).call(this)},Uh=function(){for(;gt(this,pr,"m",Fh).call(this););},Vh=function(){var n=j(function*(t,r){return new Promise(i=>{const s=()=>{r&&!r()||(this.off(t,s),i())};this.on(t,s)})});return function e(t,r){return n.apply(this,arguments)}}();class O9 extends Error{constructor(e){super(e),this.name="TimeoutError"}}class k9 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const uA=n=>void 0===globalThis.DOMException?new k9(n):new DOMException(n),lA=n=>{const e=void 0===n.reason?uA("This operation was aborted."):n.reason;return e instanceof Error?e:uA(e)};function L9(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((u,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(lA(R)),R.addEventListener("abort",()=>{_(lA(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{u(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new O9("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),j(function*(){try{u(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else u(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}const fA="lock:worker:request-read",dA="lock:worker:release-read",hA="lock:master:grant-read",pA="lock:worker:request-write",gA="lock:worker:release-write",yA="lock:master:grant-write",na={},su=n=>{n.addEventListener("message",e=>{su.dispatchEvent("message",n,e)}),null!=n.port&&n.port.addEventListener("message",e=>{su.dispatchEvent("message",n,e)})};su.addEventListener=(n,e)=>{null==na[n]&&(na[n]=[]),na[n].push(e)},su.removeEventListener=(n,e)=>{null!=na[n]&&(na[n]=na[n].filter(t=>t===e))},su.dispatchEvent=function(n,e,t){null!=na[n]&&na[n].forEach(r=>r(e,t))};const mA=su,vA=(n,e,t,r,i)=>(s,o)=>{if(o.data.type!==t)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};var u;n.dispatchEvent(new MessageEvent(e,{data:{name:a.name,handler:(u=j(function*(){return s.postMessage({type:i,name:a.name,identifier:a.identifier}),yield new Promise(_=>{const R=N=>{null!=N&&null!=N.data&&N.data.type===r&&N.data.identifier===a.identifier&&(s.removeEventListener("message",R),_())};s.addEventListener("message",R)})}),function(){return u.apply(this,arguments)})}}))},EA=(n,e,t,r)=>j(function*(){const i=((n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))();return globalThis.postMessage({type:e,identifier:i,name:n}),yield new Promise(s=>{const o=a=>{null!=a&&null!=a.data&&a.data.type===t&&a.data.identifier===i&&(globalThis.removeEventListener("message",o),s(()=>{globalThis.postMessage({type:r,identifier:i,name:n})}))};globalThis.addEventListener("message",o)})}),V9={singleProcess:!1},Oa={};let ra;function Xv(n,e){return Jv.apply(this,arguments)}function Jv(){return Jv=j(function*(n,e){let t;const r=new Promise(i=>{t=i});return n.add(j(function*(){return yield L9(j(function*(){return yield new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})})),yield r}),Jv.apply(this,arguments)}const $9={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};const bA=Gt("libp2p:peer-store:store"),wA="/peers/";class G9{constructor(){this.components=new ho,this.lock=function j9(n){const e=Object.assign({},$9,n);return null==ra&&(ra=(n=>{if(n=Object.assign({},V9,n),Boolean(globalThis.document)||n.singleProcess){const t=new EventTarget;return mA.addEventListener("message",vA(t,"requestReadLock",fA,dA,hA)),mA.addEventListener("message",vA(t,"requestWriteLock",pA,gA,yA)),t}return{isWorker:!0,readLock:t=>EA(t,fA,hA,dA),writeLock:t=>EA(t,pA,yA,gA)}})(e),!0!==ra.isWorker&&(ra.addEventListener("requestReadLock",t=>{null!=Oa[t.data.name]&&Oa[t.data.name].readLock().then(function(){var r=j(function*(i){return yield t.data.handler().finally(()=>i())});return function(i){return r.apply(this,arguments)}}())}),ra.addEventListener("requestWriteLock",function(){var t=j(function*(r){null!=Oa[r.data.name]&&Oa[r.data.name].writeLock().then(function(){var i=j(function*(s){return yield r.data.handler().finally(()=>s())});return function(s){return i.apply(this,arguments)}}())});return function(r){return t.apply(this,arguments)}}()))),null==Oa[e.name]&&(Oa[e.name]=((n,e)=>{if(!0===ra.isWorker)return{readLock:ra.readLock(n,e),writeLock:ra.writeLock(n,e)};const t=new cA({concurrency:1});let r;return{readLock:()=>j(function*(){if(null!=r)return yield Xv(r,e);r=new cA({concurrency:e.concurrency,autoStart:!1});const i=r,s=Xv(r,e);return t.add(j(function*(){return i.start(),yield i.onIdle().then(()=>{r===i&&(r=null)})})),yield s})(),writeLock:()=>j(function*(){return r=null,yield Xv(t,e)})()}})(e.name,e)),Oa[e.name]}({name:"peer-store",singleProcess:!0})}init(e){this.components=e}_peerIdToDatastoreKey(e){if(null==e.type)throw bA.error("peerId must be an instance of peer-id to store data"),ae(new Error("peerId must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");const t=e.toCID().toString();return new Ur(`${wA}${t}`)}has(e){var t=this;return j(function*(){return yield t.components.getDatastore().has(t._peerIdToDatastoreKey(e))})()}delete(e){var t=this;return j(function*(){yield t.components.getDatastore().delete(t._peerIdToDatastoreKey(e))})()}load(e){var t=this;return j(function*(){const r=yield t.components.getDatastore().get(t._peerIdToDatastoreKey(e)),i=Ph.decode(r),s=new Map;for(const o of i.metadata)s.set(o.key,o.value);return{...i,id:e,addresses:i.addresses.map(({multiaddr:o,isCertified:a})=>({multiaddr:new yn(o),isCertified:a??!1})),metadata:s,pubKey:i.pubKey??void 0,peerRecordEnvelope:i.peerRecordEnvelope??void 0}})()}save(e){var t=this;return j(function*(){if(null!=e.pubKey&&null!=e.id.publicKey&&!kr(e.pubKey,e.id.publicKey))throw bA.error("peer publicKey bytes do not match peer id publicKey bytes"),ae(new Error("publicKey bytes do not match peer id publicKey bytes"),"ERR_INVALID_PARAMETERS");const r=new Set,i=e.addresses.filter(a=>!r.has(a.multiaddr.toString())&&(r.add(a.multiaddr.toString()),!0)).sort((a,u)=>a.multiaddr.toString().localeCompare(u.multiaddr.toString())).map(({multiaddr:a,isCertified:u})=>({multiaddr:a.bytes,isCertified:u})),s=[];[...e.metadata.keys()].sort().forEach(a=>{const u=e.metadata.get(a);null!=u&&s.push({key:a,value:u})});const o=Ph.encode({addresses:i,protocols:e.protocols.sort(),pubKey:e.pubKey,metadata:s,peerRecordEnvelope:e.peerRecordEnvelope});return yield t.components.getDatastore().put(t._peerIdToDatastoreKey(e.id),o.subarray()),yield t.load(e.id)})()}patch(e,t){var r=this;return j(function*(){const i=yield r.load(e);return yield r._patch(e,t,i)})()}patchOrCreate(e,t){var r=this;return j(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._patch(e,t,i)})()}_patch(e,t,r){var i=this;return j(function*(){return yield i.save({...r,...t,id:e})})()}merge(e,t){var r=this;return j(function*(){const i=yield r.load(e);return yield r._merge(e,t,i)})()}mergeOrCreate(e,t){var r=this;return j(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._merge(e,t,i)})()}_merge(e,t,r){var i=this;return j(function*(){const s=new Map;return r.addresses.forEach(o=>{s.set(o.multiaddr.toString(),o.isCertified)}),(t.addresses??[]).forEach(o=>{const a=o.multiaddr.toString(),_=Boolean(s.get(a))||o.isCertified;s.set(a,_)}),yield i.save({id:e,addresses:Array.from(s.entries()).map(([o,a])=>({multiaddr:new yn(o),isCertified:a})),protocols:Array.from(new Set([...r.protocols??[],...t.protocols??[]])),metadata:new Map([...r.metadata?.entries()??[],...t.metadata?.entries()??[]]),pubKey:t.pubKey??r?.pubKey,peerRecordEnvelope:t.peerRecordEnvelope??r?.peerRecordEnvelope})})()}all(){var e=this;return dn(function*(){var i,t=!1,r=!1;try{for(var o,s=Pt(e.components.getDatastore().queryKeys({prefix:wA}));t=!(o=yield lt(s.next())).done;t=!1){const u=o.value.toString().split("/")[2],_=co.decode(u);yield e.load(Jc(_))}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield lt(s.return()))}finally{if(r)throw i}}})()}}var ia,Hh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.tags)throw new Error('Protocol error: required field "tags" was not found in object');for(const s of t.tags)r.uint32(10),Hh.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={tags:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.tags.push(Hh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ia||(ia={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.name)throw new Error('Protocol error: required field "name" was not found in object');r.uint32(10),r.string(t.name),null!=t.value&&(r.uint32(16),r.uint32(t.value)),null!=t.expiry&&(r.uint32(24),r.uint64(t.expiry)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={name:""},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.name=t.string();break;case 2:i.value=t.uint32();break;case 3:i.expiry=t.uint64();break;default:t.skipType(7&o)}}if(null==i.name)throw new Error('Protocol error: value for required field "name" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Hh||(Hh={}));const Zi=Gt("libp2p:peer-store");class z9 extends Ei{constructor(e={}){super(),this.components=new ho,this.store=new G9,this.addressBook=new S9(this.dispatchEvent.bind(this),this.store,e.addressFilter),this.keyBook=new C9(this.dispatchEvent.bind(this),this.store),this.metadataBook=new I9(this.dispatchEvent.bind(this),this.store),this.protoBook=new T9(this.dispatchEvent.bind(this),this.store)}init(e){this.components=e,this.store.init(e)}forEach(e){var t=this;return j(function*(){Zi.trace("getPeers await read lock");const r=yield t.store.lock.readLock();Zi.trace("getPeers got read lock");try{var o,i=!1,s=!1;try{for(var u,a=Pt(t.store.all());i=!(u=yield a.next()).done;i=!1){const _=u.value;_.id.equals(t.components.getPeerId())||e(_)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}}finally{Zi.trace("getPeers release read lock"),r()}})()}all(){var e=this;return j(function*(){const t=[];return yield e.forEach(r=>{t.push(r)}),t})()}delete(e){var t=this;return j(function*(){Zi.trace("delete await write lock");const r=yield t.store.lock.writeLock();Zi.trace("delete got write lock");try{yield t.store.delete(e)}finally{Zi.trace("delete release write lock"),r()}})()}get(e){var t=this;return j(function*(){Zi.trace("get await read lock");const r=yield t.store.lock.readLock();Zi.trace("get got read lock");try{return yield t.store.load(e)}finally{Zi.trace("get release read lock"),r()}})()}has(e){var t=this;return j(function*(){Zi.trace("has await read lock");const r=yield t.store.lock.readLock();Zi.trace("has got read lock");try{return yield t.store.has(e)}finally{Zi.trace("has release read lock"),r()}})()}tagPeer(e,t,r={}){var i=this;return j(function*(){const s=r.value??0,o=Math.round(s),a=r.ttl??void 0;if(o!==s||o<0||o>100)throw ae(new Error("Tag value must be between 0-100"),"ERR_TAG_VALUE_OUT_OF_BOUNDS");const u=yield i.metadataBook.getValue(e,"tags");let _=[];null!=u&&(_=ia.decode(u).tags);for(const R of _)if(R.name===t)throw ae(new Error("Peer already tagged"),"ERR_DUPLICATE_TAG");_.push({name:t,value:o,expiry:null==a?void 0:BigInt(Date.now()+a)}),yield i.metadataBook.setValue(e,"tags",ia.encode({tags:_}).subarray())})()}unTagPeer(e,t){var r=this;return j(function*(){const i=yield r.metadataBook.getValue(e,"tags");let s=[];null!=i&&(s=ia.decode(i).tags),s=s.filter(o=>o.name!==t),yield r.metadataBook.setValue(e,"tags",ia.encode({tags:s}).subarray())})()}getTags(e){var t=this;return j(function*(){const r=yield t.metadataBook.getValue(e,"tags");let i=[];null!=r&&(i=ia.decode(r).tags);const s=BigInt(Date.now()),o=i.filter(a=>null==a.expiry||a.expiry>s);return o.length!==i.length&&(yield t.metadataBook.setValue(e,"tags",ia.encode({tags:o}).subarray())),o.map(a=>({name:a.name,value:a.value??0}))})()}}class W9{constructor(e){this.dht=e}provide(e){var t=this;return j(function*(){yield Qo(t.dht.provide(e))})()}findProviders(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.findProviders(e,t));i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;"PROVIDER"===_.name&&(yield*Mr(Pt(_.providers),lt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}put(e,t,r){var i=this;return j(function*(){yield Qo(i.dht.put(e,t,r))})()}get(e,t){var r=this;return j(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.get(e,t));i=!(u=yield a.next()).done;i=!1){const _=u.value;if("VALUE"===_.name)return _.value}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw ae(new Error("Not found"),"ERR_NOT_FOUND")})()}}const _A=Gt("libp2p:dialer:auto-dialer");class q9{constructor(e,t){this.components=e,this.enabled=t.enabled,this.minConnections=t.minConnections,this.dialTimeout=t.dialTimeout}handle(e){const{detail:t}=e;if(this.enabled&&0===this.components.getConnectionManager().getConnections(t.id).length&&(this.minConnections??0)>this.components.getConnectionManager().getConnections().length){_A("auto-dialing discovered peer %p with timeout %d",t.id,this.dialTimeout);const o=new bi.TimeoutController(this.dialTimeout);try{(0,Vr.setMaxListeners)?.(1/0,o.signal)}catch{}this.components.getConnectionManager().openConnection(t.id,{signal:o.signal}).catch(a=>{_A.error("could not connect to discovered peer %p with %o",t.id,a)}).finally(()=>{o.clear()})}}}var DA=x(4033);const Y9=globalThis.fetch,Q9=globalThis.Headers;function eE(n,e,t){return`${n}?name=${e}&type=${t}`}function Z9(n,e){return tE.apply(this,arguments)}function tE(){return tE=j(function*(n,e){return yield(yield Y9(n,{headers:new Q9({accept:"application/dns-json"}),signal:e})).json()}),tE.apply(this,arguments)}function ou(n,e){return`${e}_${n}`}globalThis,globalThis;const nE=Object.assign(dr("dns-over-http-resolver"),{error:dr("dns-over-http-resolver:error")}),J9=class X9{constructor(e={}){this._cache=new DA({max:e?.maxCache??100}),this._TXTcache=new DA({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??Z9,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>e.abort())}getServers(){return this._servers}_getShuffledServers(){const e=[...this._servers];for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),i=e[t];e[t]=e[r],e[r]=i}return e}setServers(e){this._servers=e}resolve(e,t="A"){var r=this;return j(function*(){switch(t){case"A":return yield r.resolve4(e);case"AAAA":return yield r.resolve6(e);case"TXT":return yield r.resolveTxt(e);default:throw new Error(`${t} is not supported`)}})()}resolve4(e){var t=this;return j(function*(){const i=t._cache.get(ou(e,"A"));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(eE(o,e,"A"),a.signal),_=u.Answer.map(N=>N.data),R=Math.min(...u.Answer.map(N=>N.TTL));return t._cache.set(ou(e,"A"),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),nE.error(`${o} could not resolve ${e} record A`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record A`)})()}resolve6(e){var t=this;return j(function*(){const r="AAAA",i=t._cache.get(ou(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(eE(o,e,r),a.signal),_=u.Answer.map(N=>N.data),R=Math.min(...u.Answer.map(N=>N.TTL));return t._cache.set(ou(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),nE.error(`${o} could not resolve ${e} record AAAA`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record AAAA`)})()}resolveTxt(e){var t=this;return j(function*(){const r="TXT",i=t._TXTcache.get(ou(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(eE(o,e,r),a.signal),_=u.Answer.map(N=>[N.data.replace(/['"]+/g,"")]),R=Math.min(...u.Answer.map(N=>N.TTL));return t._TXTcache.set(ou(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),nE.error(`${o} could not resolve ${e} record TXT`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record TXT`)})()}clearCache(){this._cache.clear(),this._TXTcache.clear()}},{code:eH}=Sr("dnsaddr");function rE(){return rE=j(function*(n,e={}){const t=new J9;null!=e.signal&&e.signal.addEventListener("abort",()=>{t.cancel()});const r=n.getPeerId(),[,i]=n.stringTuples().find(([a])=>a===eH)??[];if(null==i)throw new Error("No hostname found in multiaddr");let o=(yield t.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]);return null!=r&&(o=o.filter(a=>a.includes(r))),o}),rE.apply(this,arguments)}const nH={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:n=>n},connectionManager:{maxConnections:300,minConnections:50,autoDial:!0,autoDialInterval:1e4,maxParallelDials:100,maxDialsPerPeer:4,dialTimeout:3e4,inboundUpgradeTimeout:3e4,resolvers:{dnsaddr:function tH(n){return rE.apply(this,arguments)}},addressSorter:pv},connectionGater:{},transportManager:{faultTolerance:Pa.FATAL_ALL},metrics:{enabled:!1,computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},nat:{enabled:!0,ttl:7200,keepAlive:!0},relay:{enabled:!0,advertise:{bootDelay:9e5,enabled:!1,ttl:18e5},hop:{enabled:!1,active:!1,timeout:3e4},autoRelay:{enabled:!1,maxListeners:2}},identify:{protocolPrefix:"ipfs",host:{agentVersion:WT},timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1},ping:{protocolPrefix:"ipfs",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4},fetch:{protocolPrefix:"libp2p",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4}};function rH(n){const e=Hl(nH,n);if(null==e.transports||e.transports.length<1)throw ae(new Error(_n.ERR_TRANSPORTS_REQUIRED),Ce.ERR_TRANSPORTS_REQUIRED);if(null==e.connectionEncryption||0===e.connectionEncryption.length)throw ae(new Error(_n.CONN_ENCRYPTION_REQUIRED),Ce.CONN_ENCRYPTION_REQUIRED);if(null===e.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw ae(new Error(_n.ERR_PROTECTOR_REQUIRED),Ce.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===WT&&(cV||oV?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(mh||W2||aV||uV)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}var SA;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.id)throw new Error('Protocol error: required field "id" was not found in object');r.uint32(10),r.bytes(t.id),null!=t.pubKey&&(r.uint32(18),r.bytes(t.pubKey)),null!=t.privKey&&(r.uint32(26),r.bytes(t.privKey)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={id:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.id=t.bytes();break;case 2:i.pubKey=t.bytes();break;case 3:i.privKey=t.bytes();break;default:t.skipType(7&o)}}if(null==i.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(SA||(SA={}));const iH=function(){var n=j(function*(){const e=yield s2("Ed25519"),t=yield function CA(n){return sE.apply(this,arguments)}(e);if("Ed25519"===t.type)return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)});return function(){return n.apply(this,arguments)}}();function sE(){return sE=j(function*(n){return yield kl(o2(n.public),P5(n))}),sE.apply(this,arguments)}const uE=Symbol.for("@libp2p/peer-discovery");class oH extends Ei{get[uE](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}get lan(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}get(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}findProviders(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}findPeer(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}getClosestPeers(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}provide(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}put(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}getMode(){return j(function*(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)})()}setMode(){return j(function*(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)})()}refreshRoutingTable(){return j(function*(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)})()}}class aH extends Ei{isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}get multicodecs(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getPeers(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getTopics(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}subscribe(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}unsubscribe(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getSubscribers(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}publish(){return j(function*(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)})()}}const Eo=Gt("libp2p");class cH extends Ei{constructor(e){var o;super(),this.initializables=[],this.started=!1,this.peerId=e.peerId,this.components=new ho({peerId:e.peerId,datastore:e.datastore??new OV,connectionGater:{denyDialPeer:(o=j(function*(){return yield Promise.resolve(!1)}),function(){return o.apply(this,arguments)}),denyDialMultiaddr:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundEncryptedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundEncryptedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundUpgradedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundUpgradedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),filterMultiaddrForPeer:function(){var o=j(function*(){return yield Promise.resolve(!0)});return function(){return o.apply(this,arguments)}}(),...e.connectionGater}}),this.components.setPeerStore(new z9({addressFilter:this.components.getConnectionGater().filterMultiaddrForPeer,...e.peerStore})),this.services=[this.components],e.metrics.enabled&&(this.metrics=this.components.setMetrics(new N7(e.metrics))),this.peerStore=this.components.getPeerStore(),this.peerStore.addEventListener("peer",o=>{const{detail:a}=o;this.dispatchEvent(new tn("peer:discovery",{detail:a}))}),null!=e.connectionProtector&&this.components.setConnectionProtector(e.connectionProtector),this.components.setUpgrader(new q7(this.components,{connectionEncryption:(e.connectionEncryption??[]).map(o=>this.configureComponent(o)),muxers:(e.streamMuxers??[]).map(o=>this.configureComponent(o)),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout})),this.connectionManager=this.components.setConnectionManager(new r7(e.connectionManager)),this.registrar=this.components.setRegistrar(new G7(this.components)),this.components.setTransportManager(new F7(this.components,e.transportManager)),this.components.setAddressManager(new UV(this.components,e.addresses)),this.configureComponent(new w9(this.components)),this.configureComponent(new s7(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));const t=LT.generateOptions();this.keychain=this.configureComponent(new LT(this.components,{...t,...e.keychain})),this.services.push(new E9(this.components,e.nat)),e.transports.forEach(o=>{this.components.getTransportManager().add(this.configureComponent(o))}),null!=e.streamMuxers&&e.streamMuxers.length>0&&(this.identifyService=new Kv(this.components,{...e.identify}),this.configureComponent(this.identifyService)),this.dht=null!=e.dht?this.components.setDHT(e.dht):new oH,this.pubsub=null!=e.pubsub?this.components.setPubSub(e.pubsub):new aH;const r=(e.peerRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&(r.push(this.configureComponent(new _9(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.setPeerRouting(this.configureComponent(new kV(this.components,{...e.peerRouting,routers:r})));const i=(e.contentRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&i.push(this.configureComponent(new W9(this.dht))),this.contentRouting=this.components.setContentRouting(this.configureComponent(new LV(this.components,{routers:i}))),e.relay.enabled&&(this.components.getTransportManager().add(this.configureComponent(new p7(e.relay))),this.configureComponent(new b7(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new l9(this.components,{...e.fetch})),this.pingService=this.configureComponent(new p9(this.components,{...e.ping}));const s=this.configureComponent(new q9(this.components,{enabled:!1!==e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,dialTimeout:e.connectionManager.dialTimeout??3e4}));this.addEventListener("peer:discovery",o=>{!this.isStarted()||s.handle(o)});for(const o of e.peerDiscovery??[])this.configureComponent(o),o.addEventListener("peer",a=>{this.onDiscoveryPeer(a)})}configureComponent(e){return fo(e)&&this.services.push(e),Fr(e)&&this.initializables.push(e),e}start(){var e=this;return j(function*(){if(!e.started){e.started=!0,Eo("libp2p is starting");try{e.initializables.forEach(t=>{t.init(e.components)}),yield Promise.all(e.services.map(function(){var t=j(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.start())),yield Promise.all(e.services.map(function(){var t=j(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has started")}catch(t){throw Eo.error("An error occurred starting libp2p",t),yield e.stop(),t}}})()}stop(){var e=this;return j(function*(){!e.started||(Eo("libp2p is stopping"),e.started=!1,yield Promise.all(e.services.map(function(){var t=j(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.stop())),yield Promise.all(e.services.map(function(){var t=j(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has stopped"))})()}loadKeychain(){var e=this;return j(function*(){if(null!=e.keychain)try{yield e.keychain.findKeyByName("self")}catch{yield e.keychain.importPeer("self",e.peerId)}})()}isStarted(){return this.started}getConnections(e){return this.components.getConnectionManager().getConnections(e)}getPeers(){const e=new JV;for(const t of this.components.getConnectionManager().getConnections())e.add(t.remotePeer);return Array.from(e)}dial(e,t={}){var r=this;return j(function*(){const{id:i,multiaddrs:s}=Vl(e);return yield r.components.getPeerStore().addressBook.add(i,s),yield r.components.getConnectionManager().openConnection(i,t)})()}dialProtocol(e,t,r={}){var i=this;return j(function*(){if(null==t)throw ae(new Error("no protocols were provided to open a stream"),Ce.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw ae(new Error("no protocols were provided to open a stream"),Ce.ERR_INVALID_PROTOCOLS_FOR_STREAM);return yield(yield i.dial(e,r)).newStream(t,r)})()}getMultiaddrs(){return this.components.getAddressManager().getAddresses()}hangUp(e){var t=this;return j(function*(){const{id:r}=Vl(e);yield t.components.getConnectionManager().closeConnections(r)})()}getPublicKey(e,t={}){var r=this;return j(function*(){if(Eo("getPublicKey %p",e),null!=e.publicKey)return e.publicKey;const i=yield r.peerStore.get(e);if(null!=i.pubKey)return i.pubKey;if(null==r.dht)throw ae(new Error("Public key was not in the peer store and the DHT is not enabled"),Ce.ERR_NO_ROUTERS_AVAILABLE);const s=wr([Ot("/pk/"),e.multihash.digest]);var u,o=!1,a=!1;try{for(var R,_=Pt(r.dht.get(s,t));o=!(R=yield _.next()).done;o=!1){const N=R.value;if("VALUE"===N.name){const B=Rl(N.value);return yield r.peerStore.keyBook.set(e,N.value),B.bytes}}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw u}}throw ae(new Error(`Node not responding with its public key: ${e.toString()}`),Ce.ERR_INVALID_RECORD)})()}fetch(e,t,r={}){var i=this;return j(function*(){const{id:s,multiaddrs:o}=Vl(e);return null!=o&&(yield i.components.getPeerStore().addressBook.add(s,o)),yield i.fetchService.fetch(s,t,r)})()}ping(e,t={}){var r=this;return j(function*(){const{id:i,multiaddrs:s}=Vl(e);return s.length>0&&(yield r.components.getPeerStore().addressBook.add(i,s)),yield r.pingService.ping(i,t)})()}handle(e,t,r){var i=this;return j(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var s=j(function*(o){yield i.components.getRegistrar().handle(o,t,r)});return function(o){return s.apply(this,arguments)}}()))})()}unhandle(e){var t=this;return j(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var r=j(function*(i){yield t.components.getRegistrar().unhandle(i)});return function(i){return r.apply(this,arguments)}}()))})()}onDiscoveryPeer(e){const{detail:t}=e;t.id.toString()!==this.peerId.toString()?(t.multiaddrs.length>0&&this.components.getPeerStore().addressBook.add(t.id,t.multiaddrs).catch(r=>Eo.error(r)),t.protocols.length>0&&this.components.getPeerStore().protoBook.set(t.id,t.protocols).catch(r=>Eo.error(r)),this.dispatchEvent(new tn("peer:discovery",{detail:t}))):Eo.error(new Error(Ce.ERR_DISCOVERED_SELF))}}function uH(n){return lE.apply(this,arguments)}function lE(){return lE=j(function*(n){return null==n.peerId&&(n.peerId=yield iH()),new cH(rH(n))}),lE.apply(this,arguments)}function lH(n){return fE.apply(this,arguments)}function fE(){return fE=j(function*(n){return yield uH(n)}),fE.apply(this,arguments)}function TA(n,e){return n.length<=e||n.length<=1?n:function dH(n){if(n.length<=1)return n;for(let t=0;t{class n extends Ei{constructor(t,r){super(),this.interval=r?.interval??n.DefaultInterval;const i=r?.maxPeers??t?.length,s=t.map(o=>"string"==typeof o?new yn(o):o);this.peers=function fH(n){return n.map(e=>{const t=e.getPeerId();return{id:t?fr(t):null,multiaddrs:[e.decapsulateCode(421)],protocols:[]}}).filter(e=>null!==e.id)}(TA(s,i)),AA("Use provided list of peers (reduced to maxPeers)",this.peers.map(o=>o.toString()))}start(){this._startTimer()}_startTimer(){if(this.peers){if(AA("Starting to emit static peers."),null!=this.timer)return;this.timer=setInterval(()=>this._returnPeers(),this.interval),this._returnPeers()}}_returnPeers(){null!=this.timer&&this.peers.forEach(t=>{this.dispatchEvent(new tn("peer",{detail:t}))})}stop(){null!=this.timer&&clearInterval(this.timer),this.timer=void 0}get[uE](){return!0}get[Symbol.toStringTag](){return"@waku/peer-discovery-static-list"}}return n.DefaultInterval=200,n})();var au=(()=>(function(n){n.Prod="prod",n.Test="test"}(au||(au={})),au))();const dE_fleets={"wakuv2.prod":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.prod":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD","node-01.do-ams3.wakuv2.prod":"/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e","node-01.gc-us-central1-a.wakuv2.prod":"/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA"}},"wakuv2.test":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.test":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm","node-01.do-ams3.wakuv2.test":"/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ","node-01.gc-us-central1-a.wakuv2.test":"/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS"}}};function cu(n){return"string"==typeof n?Ot(n.replace(/^0x/i,"").toLowerCase(),"base16"):n}function Cs(n,e){const t=e??n.reduce((s,o)=>s+o.length,0),r=new Uint8Array(t);let i=0;for(const s of n)r.set(s,i),i+=s.length;return r}var $h;dr("waku:select-peer"),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}($h||($h={}));var bH=x(6577),wH=x(4237);const uu_algorithm={name:"AES-GCM",length:128},jh={node:bH,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0};function Xi(){if(jh.web)return jh.web.subtle;if(jh.node)return jh.node.webcrypto.subtle;throw new Error("The environment doesn't have Crypto Subtle API (if in the browser, be sure to use to be in a secure context, ie, https)")}const lu=Yr.randomBytes,gE=Yr.sha256;function _H(n,e){return yE.apply(this,arguments)}function yE(){return yE=j(function*(n,e){const[t,r]=yield OI(n,e,{recovered:!0,der:!1});return Cs([t,new Uint8Array([r])],t.length+1)}),yE.apply(this,arguments)}function mE(n){return new Uint8Array(wH.keccak256.arrayBuffer(n))}function xA(n,e){let t=1,r=0,i=Promise.resolve(new Uint8Array);for(;r>24,t>>16,t>>8,t]),o=Cs([s,n],s.length+n.length),a=gE(o);i=i.then(u=>a.then(_=>{const R=new Uint8Array(_);return Cs([u,R],u.length+R.length)})),r+=32,t+=1}return i}function DH(n,e,t){return Xi().importKey("raw",e,"AES-CTR",!1,["encrypt"]).then(r=>Xi().encrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function SH(n,e,t){return Xi().importKey("raw",e,"AES-CTR",!1,["decrypt"]).then(r=>Xi().decrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function CH(n,e){const t={name:"HMAC",hash:{name:"SHA-256"}};return Xi().importKey("raw",n,t,!1,["sign"]).then(r=>Xi().sign(t,r,e)).then(r=>new Uint8Array(r))}function IH(n,e,t){const r={name:"HMAC",hash:{name:"SHA-256"}};return Xi().importKey("raw",n,r,!1,["verify"]).then(s=>Xi().verify(r,s,t,e))}function RA(n,e){if(32!==n.length)throw new Error(`Bad private key, it should be 32 bytes but it's actually ${n.length} bytes long`);if(65!==e.length)throw new Error(`Bad public key, it should be 65 bytes but it's actually ${e.length} bytes long`);if(4!==e[0])throw new Error("Bad public key, a valid public key would begin with 4");{const t=function IF(n,e,t=!1){if(xI(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!xI(e))throw new TypeError("getSharedSecret: second arg must be public key");const r=U0(e);return r.assertValidity(),r.multiply(_a(n)).toRawBytes(t)}(n,e,!0);return new Uint8Array(cu(t).slice(1))}}function TH(n,e){return vE.apply(this,arguments)}function vE(){return vE=j(function*(n,e){const t=lu(32),r=yield RA(t,n),i=yield xA(r,32),s=lu(16),o=i.slice(0,16),a=yield DH(s,o,e),u=Cs([s,a],s.length+a.length),_=yield gE(i.slice(16)),R=yield CH(_,u),N=Dl(t,!1);return Cs([N,u,R],N.length+u.length+R.length)}),vE.apply(this,arguments)}function AH(n,e){return bE.apply(this,arguments)}function bE(){return bE=j(function*(n,e){if(e.length<=113)throw new Error("Invalid Ciphertext. Data is too small. It should ba at least 113 bytes");if(4!==e[0])throw new Error(`Not a valid ciphertext. It should begin with 4 but actually begin with ${e[0]}`);{const t=e.slice(0,65),r=e.length-113,i=e.slice(65,81),s=e.slice(65,81+r),o=s.slice(16),a=e.slice(81+r),u=RA(n,t),_=yield xA(u,32),[R,N]=yield gE(_.slice(16)).then(B=>[_.slice(0,16),B]);if(!(yield IH(N,s,a)))throw new Error("Incorrect MAC");return SH(i,R,o)}}),bE.apply(this,arguments)}function xH(n,e,t){return wE.apply(this,arguments)}function wE(){return wE=j(function*(n,e,t){return Xi().importKey("raw",e,uu_algorithm,!1,["encrypt"]).then(r=>Xi().encrypt({iv:n,...uu_algorithm},r,t)).then(r=>new Uint8Array(r))}),wE.apply(this,arguments)}function RH(n,e,t){return _E.apply(this,arguments)}function _E(){return _E=j(function*(n,e,t){return Xi().importKey("raw",e,uu_algorithm,!1,["decrypt"]).then(r=>Xi().decrypt({iv:n,...uu_algorithm},r,t)).then(r=>new Uint8Array(r))}),_E.apply(this,arguments)}function PH(){return lu(12)}function NA(n,e){return CE.apply(this,arguments)}function CE(){return CE=j(function*(n,e){let t=new Uint8Array([0]);t=VH(t,n),t=Cs([t,n]);let r=1+kA(n)+n.length;e&&(r+=65);const s=256-r%256,o=lu(s);if(!HH(o,s))throw new Error("failed to generate random padding of size "+s);let a;if(t=Cs([t,o]),e){t[0]|=4;const u=mE(t),_=yield _H(u,e);t=Cs([t,_]),a={signature:_,publicKey:Dl(e,!1)}}return{payload:t,sig:a}}),CE.apply(this,arguments)}function IE(){return IE=j(function*(n,e){return TH(cu(e),n)}),IE.apply(this,arguments)}function MA(n,e){return TE.apply(this,arguments)}function TE(){return TE=j(function*(n,e){return AH(e,n)}),TE.apply(this,arguments)}function AE(){return AE=j(function*(n,e){const t=PH();return Cs([yield xH(t,cu(e),n),t])}),AE.apply(this,arguments)}function OA(n,e){return xE.apply(this,arguments)}function xE(){return xE=j(function*(n,e){const t=n.length-12,r=n.slice(0,t);return RH(n.slice(t),cu(e),r)}),xE.apply(this,arguments)}function VH(n,e){const t=kA(e);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e.length,!0),r=r.slice(0,t),(n=Cs([n,r]))[0]|=t,n}function kA(n){let e=1;for(let t=n.length;t>=256;t/=256)e++;return e}function HH(n,e){return n.length===e&&(e<=3||-1!==n.findIndex(t=>0!==t))}const sa=dr("waku:message"),LA=BigInt(1e6);var Gh,zh,BA,Wh,tf=(()=>(function(n){n.Asymmetric="asymmetric",n.Symmetric="symmetric"}(tf||(tf={})),tf))();class oa{constructor(e,t,r){this.proto=e,this._signaturePublicKey=t,this._signature=r}static fromUtf8String(e,t,r){return j(function*(){const i=(n=>Ot(n,"utf8"))(e);return oa.fromBytes(i,t,r)})()}static fromBytes(e,t,r){return j(function*(){const{timestamp:i,encPublicKey:s,symKey:o,sigPrivKey:a}=Object.assign({timestamp:new Date},r||{});let R,u=e,_=0;if(s&&o)throw"Pass either `encPublicKey` or `symKey`, not both.";if(s){const N=yield NA(u,a);u=yield function FH(n,e){return IE.apply(this,arguments)}(N.payload,s),R=N.sig,_=1}else if(o){const N=yield NA(u,a);u=yield function UH(n,e){return AE.apply(this,arguments)}(N.payload,o),R=N.sig,_=1}return new oa({payload:u,timestampDeprecated:i.valueOf()/1e3,timestamp:BigInt(i.valueOf())*LA,version:_,contentTopic:t},R?.publicKey,R?.signature)})()}static decode(e,t){return j(function*(){const r=$h.decode(e);return oa.decodeProto(r,t)})()}static decodeProto(e,t){return j(function*(){const r=e.payload;let i,s;if(1===e.version&&r){if(void 0===t)return void sa("Payload is encrypted but no private keys have been provided.");const o=yield Promise.all(t.map(function(){var N=j(function*({key:B,method:K,contentTopics:Z}){if(!Z||e.contentTopic&&Z.includes(e.contentTopic))switch(K){case tf.Asymmetric:try{return yield MA(r,B)}catch(J){return void sa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",J)}case tf.Symmetric:try{return yield OA(r,B)}catch(J){return void sa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",J)}default:try{return yield OA(r,B)}catch(J){sa("Failed to decrypt message using symmetric encryption",J);try{return yield MA(r,B)}catch(oe){return void sa("Failed to decrypt message using asymmetric encryption",oe)}}}});return function(B){return N.apply(this,arguments)}}())),u=o.filter(N=>!!N);if(0===u.length)return void sa("Failed to decrypt payload.");const _=u[0],R=yield function OH(n){const e=function kH(n){return 3&new DataView(n.buffer).getUint8(0)}(n);if(0===e)return;const t=function LH(n,e){let t=n.slice(1,1+e);return e<4&&(t=Cs([t,new Uint8Array(4-e)],4)),new DataView(t.buffer).getInt32(0,!0)}(n,e),r=1+e,i=n.slice(r,r+t),s=function BH(n){return 4==(4&new DataView(n.buffer).getUint8(0))}(n);let o;if(s){const a=function KH(n){return n.slice(n.length-65,n.length)}(n),u=function $H(n,e){return mE(e?n.slice(0,n.length-65):n)}(n,s),_=function jH(n,e){const r=new DataView(e.slice(64).buffer).getUint8(0);return function CF(n,e,t,r=!1){return In.fromSignature(n,e,t).toRawBytes(r)}(n,uo.fromCompact(e.slice(0,64)),r,!1)}(u,a);o={signature:a,publicKey:_}}return{payload:i,sig:o}}(_);if(!R)return void sa("Failed to decode payload.");Object.assign(e,{payload:R.payload}),i=R.sig?.publicKey,s=R.sig?.signature}return new oa(e,i,s)})()}encode(){return $h.encode(this.proto)}get payloadAsUtf8(){if(!this.payload)return"";try{return(n=>Lt(this.payload,"utf8"))()}catch(e){return sa("Could not decode byte as UTF-8",e),""}}get payload(){if(this.proto.payload)return new Uint8Array(this.proto.payload)}get contentTopic(){return this.proto.contentTopic}get version(){return this.proto.version??0}get timestamp(){try{if(this.proto.timestamp)return new Date(Number(this.proto.timestamp/LA));if(this.proto.timestampDeprecated)return new Date(1e3*this.proto.timestampDeprecated)}catch{return}}get signaturePublicKey(){return this._signaturePublicKey}get signature(){return this._signature}}!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Yt((s,o,a={})=>{!1!==a.lengthDelimited&&o.fork(),null!=s.contentTopic&&(o.uint32(10),o.string(s.contentTopic)),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={},u=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.contentTopic=s.string():s.skipType(7&_)}return a})),i),r.encode=s=>qt(s,r.codec()),r.decode=s=>Wt(s,r.codec())}(e=n.ContentFilter||(n.ContentFilter={})),n.codec=()=>(null==t&&(t=Yt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null!=r.subscribe&&(i.uint32(8),i.bool(r.subscribe)),null!=r.topic&&(i.uint32(18),i.string(r.topic)),null==r.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const o of r.contentFilters)i.uint32(26),n.ContentFilter.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={contentFilters:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.subscribe=r.bool();break;case 2:s.topic=r.string();break;case 3:s.contentFilters.push(n.ContentFilter.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}return s})),t),n.encode=r=>qt(r,n.codec()),n.decode=r=>Wt(r,n.codec())}(Gh||(Gh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const s of t.messages)r.uint32(10),Wh.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={messages:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.messages.push(Wh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(zh||(zh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Gh.codec().encode(t.request,r)),null!=t.push&&(r.uint32(26),zh.codec().encode(t.push,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Gh.codec().decode(t,t.uint32());break;case 3:i.push=zh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(BA||(BA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Wh||(Wh={}));const ka="/vac/waku/filter/2.0.0-beta1";var qh,Yh,FA,Qh;dr("waku:filter"),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(10),r.string(t.pubSubTopic)),null!=t.message&&(r.uint32(18),Qh.codec().encode(t.message,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.pubSubTopic=t.string();break;case 2:i.message=Qh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(qh||(qh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.isSuccess&&(r.uint32(8),r.bool(t.isSuccess)),null!=t.info&&(r.uint32(18),r.string(t.info)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.isSuccess=t.bool();break;case 2:i.info=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Yh||(Yh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),qh.codec().encode(t.request,r)),null!=t.response&&(r.uint32(26),Yh.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=qh.codec().decode(t,t.uint32());break;case 3:i.response=Yh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(FA||(FA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Qh||(Qh={})),dr("waku:light-push");const nf="/vac/waku/lightpush/2.0.0-beta1",La=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"];var Zh,fu,Xh,Jh,rf,UA,ep;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(16),r.sint64(t.receivedTime)),null!=t.senderTime&&(r.uint32(24),r.sint64(t.senderTime)),null!=t.pubsubTopic&&(r.uint32(34),r.string(t.pubsubTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.sint64();break;case 3:i.senderTime=t.sint64();break;case 4:i.pubsubTopic=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Zh||(Zh={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),Zh.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=Zh.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(fu||(fu={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Xh||(Xh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),Xh.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),fu.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(40),r.sint64(t.startTime)),null!=t.endTime&&(r.uint32(48),r.sint64(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(Xh.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=fu.codec().decode(t,t.uint32());break;case 5:i.startTime=t.sint64();break;case 6:i.endTime=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Jh||(Jh={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),ep.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),fu.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(ep.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=fu.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(rf||(rf={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),Jh.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),rf.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=Jh.codec().decode(t,t.uint32());break;case 3:i.response=rf.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(UA||(UA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ep||(ep={}));var tp,du,np,rp,ip,VA,sp,sf=(()=>(function(n){n.V2Beta3="/vac/waku/store/2.0.0-beta3",n.V2Beta4="/vac/waku/store/2.0.0-beta4"}(sf||(sf={})),sf))();!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(17),r.double(t.receivedTime)),null!=t.senderTime&&(r.uint32(25),r.double(t.senderTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.double();break;case 3:i.senderTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(tp||(tp={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),tp.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=tp.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(du||(du={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(np||(np={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),np.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),du.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(41),r.double(t.startTime)),null!=t.endTime&&(r.uint32(49),r.double(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(np.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=du.codec().decode(t,t.uint32());break;case 5:i.startTime=t.double();break;case 6:i.endTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(rp||(rp={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),sp.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),du.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(sp.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=du.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(ip||(ip={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),rp.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),ip.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=rp.codec().decode(t,t.uint32());break;case 3:i.response=ip.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(VA||(VA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(sp||(sp={})),BigInt(1e6),dr("waku:store");const OE=dr("waku:waku");var Jr=(()=>(function(n){n.Relay="relay",n.Store="store",n.LightPush="lightpush",n.Filter="filter"}(Jr||(Jr={})),Jr))();class tK{constructor(e,t,r,i,s){this.libp2p=t,this.store=r,this.filter=s,this.lightPush=i,function nK(n){if(n)try{return n.multicodecs.includes(La[La.length-1])}catch{}return!1}(t.pubsub)&&(this.relay=t.pubsub),OE("Waku node created",this.libp2p.peerId.toString(),`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`),this.pingKeepAliveTimers={},this.relayKeepAliveTimers={};const o=e.pingKeepAlive||0,a=this.relay?e.relayKeepAlive||300:0;t.connectionManager.addEventListener("peer:connect",u=>{this.startKeepAlive(u.detail.remotePeer,o,a)}),t.connectionManager.addEventListener("peer:disconnect",u=>{this.stopKeepAlive(u.detail.remotePeer)}),e?.decryptionKeys?.forEach(u=>{this.addDecryptionKey(u)})}dial(e,t){var r=this;return j(function*(){const i=t??[Jr.Relay],s=[];if(i.includes(Jr.Relay)&&La.forEach(o=>s.push(o)),i.includes(Jr.Store))for(const o of Object.values(sf))s.push(o);return i.includes(Jr.LightPush)&&s.push(nf),i.includes(Jr.Filter)&&s.push(ka),r.libp2p.dialProtocol(e,s)})()}addPeerToAddressBook(e,t){var r=this;return j(function*(){let i;i="string"==typeof e?fr(e):e;const s=t.map(o=>"string"==typeof o?function tV(n){return new yn(n)}(o):o);yield r.libp2p.peerStore.addressBook.set(i,s)})()}start(){var e=this;return j(function*(){yield e.libp2p.start()})()}stop(){var e=this;return j(function*(){e.stopAllKeepAlives(),yield e.libp2p.stop()})()}isStarted(){return this.libp2p.isStarted()}addDecryptionKey(e,t){this.relay&&this.relay.addDecryptionKey(e,t),this.store&&this.store.addDecryptionKey(e,t),this.filter&&this.filter.addDecryptionKey(e,t)}deleteDecryptionKey(e){this.relay&&this.relay.deleteDecryptionKey(e),this.store&&this.store.deleteDecryptionKey(e),this.filter&&this.filter.deleteDecryptionKey(e)}getLocalMultiaddrWithID(){const e=this.libp2p.getMultiaddrs().find(t=>t.toString().match(/127\.0\.0\.1/));if(!e||""===e.toString())throw"Not listening on localhost";return e+"/p2p/"+this.libp2p.peerId.toString()}startKeepAlive(e,t,r){this.stopKeepAlive(e);const i=e.toString();0!==t&&(this.pingKeepAliveTimers[i]=setInterval(()=>{this.libp2p.ping(e).catch(o=>{OE(`Ping failed (${i})`,o)})},1e3*t));const s=this.relay;s&&0!==r&&(this.relayKeepAliveTimers[i]=setInterval(()=>{OE("Sending Waku Relay ping message"),oa.fromBytes(new Uint8Array,"/relay-ping/1/ping/null").then(o=>s.send(o))},1e3*r))}stopKeepAlive(e){const t=e.toString();this.pingKeepAliveTimers[t]&&(clearInterval(this.pingKeepAliveTimers[t]),delete this.pingKeepAliveTimers[t]),this.relayKeepAliveTimers[t]&&(clearInterval(this.relayKeepAliveTimers[t]),delete this.relayKeepAliveTimers[t])}stopAllKeepAlives(){for(const e of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(e);this.pingKeepAliveTimers={},this.relayKeepAliveTimers={}}}const $A=()=>{};class rK{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??$A,this.onDisconnect=e.onDisconnect??$A}get[Symbol.toStringTag](){return Hv.toString()}get[Hv](){return!0}setRegistrar(e){var t=this;return j(function*(){t.registrar=e})()}disconnect(e){this.onDisconnect(e)}}class sK{constructor(e,t,r){this.gossip=e,this.msgs=new Map,this.history=[],this.msgIdToStrFn=r;for(let i=0;i{const s=this.msgs.get(i.msgIdStr);if(s&&s.validated&&e.has(i.topic)){let o=t.get(i.topic);o||(o=[],t.set(i.topic,o)),o.push(i.msgId)}});return t}validate(e){const t=this.msgs.get(e);if(!t)return null;const{message:r,originatingPeers:i}=t;return t.validated=!0,t.originatingPeers=new Set,{message:r,originatingPeers:i}}shift(){this.history[this.history.length-1].forEach(t=>{this.msgs.delete(t.msgIdStr)}),this.history.pop(),this.history.unshift([])}remove(e){const t=this.msgs.get(e);return t?(this.msgs.delete(e),t):null}}var oK=x(8479);const{RPC:ap}=oK,jA="/floodsub/1.0.0",GA="/meshsub/1.0.0",LE="/meshsub/1.1.0",gu=5e3;function bo(n=[],e){return{subscriptions:[],messages:n,control:e?{graft:e.graft||[],prune:e.prune||[],ihave:e.ihave||[],iwant:e.iwant||[]}:void 0}}function wo(n){if(n.length<=1)return n;for(let t=0;t(function(n){n.StrictSign="StrictSign",n.StrictNoSign="StrictNoSign"}(up||(up={})),up))(),Ba=(()=>(function(n){n[n.Signing=0]="Signing",n[n.Anonymous=1]="Anonymous"}(Ba||(Ba={})),Ba))(),$s=(()=>(function(n){n.Accept="accept",n.Ignore="ignore",n.Reject="reject"}($s||($s={})),$s))(),Ji=(()=>(function(n){n.Error="error",n.Ignore="ignore",n.Reject="reject",n.Blacklisted="blacklisted"}(Ji||(Ji={})),Ji))(),li=(()=>(function(n){n.InvalidSignature="invalid_signature",n.InvalidSeqno="invalid_seqno",n.InvalidPeerId="invalid_peerid",n.SignaturePresent="signature_present",n.SeqnoPresent="seqno_present",n.FromPresent="from_present",n.TransformFailed="transform_failed"}(li||(li={})),li))(),es=(()=>(function(n){n.duplicate="duplicate",n.invalid="invalid",n.valid="valid"}(es||(es={})),es))();function WA(n){switch(n){case $s.Ignore:return Ji.Ignore;case $s.Reject:return Ji.Reject}}function FE(){return FE=j(function*(n,e){switch(n){case cp:{if(!e)throw Error("Must provide PeerId");if(null==e.privateKey)throw Error("Cannot sign message, no private key present");if(null==e.publicKey)throw Error("Cannot sign message, no public key present");const t=yield Pl(e.privateKey);return{type:Ba.Signing,author:e,key:e.publicKey,privateKey:t}}case BE:return{type:Ba.Anonymous};default:throw new Error(`Unknown signature policy "${n}"`)}}),FE.apply(this,arguments)}const Kn="ERR_INVALID_PEER_SCORE_PARAMS",UK={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyThreshold:0,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},VK={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3};function HK(n={}){return{...UK,...n,topics:n.topics?Object.entries(n.topics).reduce((e,[t,r])=>(e[t]=function KK(n={}){return{...VK,...n}}(r),e),{}):{}}}function jK(n){if(n.topicWeight<0)throw ae(new Error("invalid topic weight; must be >= 0"),Kn);if(0===n.timeInMeshQuantum)throw ae(new Error("invalid TimeInMeshQuantum; must be non zero"),Kn);if(n.timeInMeshWeight<0)throw ae(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Kn);if(0!==n.timeInMeshWeight&&n.timeInMeshQuantum<=0)throw ae(new Error("invalid TimeInMeshQuantum; must be positive"),Kn);if(0!==n.timeInMeshWeight&&n.timeInMeshCap<=0)throw ae(new Error("invalid TimeInMeshCap; must be positive"),Kn);if(n.firstMessageDeliveriesWeight<0)throw ae(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Kn);if(0!==n.firstMessageDeliveriesWeight&&(n.firstMessageDeliveriesDecay<=0||n.firstMessageDeliveriesDecay>=1))throw ae(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Kn);if(0!==n.firstMessageDeliveriesWeight&&n.firstMessageDeliveriesCap<=0)throw ae(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Kn);if(n.meshMessageDeliveriesWeight>0)throw ae(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.meshMessageDeliveriesWeight&&(n.meshMessageDeliveriesDecay<=0||n.meshMessageDeliveriesDecay>=1))throw ae(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesCap<=0)throw ae(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesThreshold<=0)throw ae(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Kn);if(n.meshMessageDeliveriesWindow<0)throw ae(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesActivation<1e3)throw ae(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Kn);if(n.meshFailurePenaltyWeight>0)throw ae(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.meshFailurePenaltyWeight&&(n.meshFailurePenaltyDecay<=0||n.meshFailurePenaltyDecay>=1))throw ae(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Kn);if(n.invalidMessageDeliveriesWeight>0)throw ae(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Kn);if(n.invalidMessageDeliveriesDecay<=0||n.invalidMessageDeliveriesDecay>=1)throw ae(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Kn)}const GK={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function zK(n={}){return{...GK,...n}}function WK(n,e,t,r){let i=0;if(Object.entries(e.topics).forEach(([o,a])=>{const u=t.topics[o];if(void 0===u)return;let _=0;if(a.inMesh){let K=a.meshTime/u.timeInMeshQuantum;K>u.timeInMeshCap&&(K=u.timeInMeshCap),_+=K*u.timeInMeshWeight}let R=a.firstMessageDeliveries;if(R>u.firstMessageDeliveriesCap&&(R=u.firstMessageDeliveriesCap),_+=R*u.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries0&&i>t.topicScoreCap&&(i=t.topicScoreCap),i+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(o=>{if(t.IPColocationFactorWhitelist.has(o))return;const a=r.get(o),u=a?a.size:0;if(u>t.IPColocationFactorThreshold){const _=u-t.IPColocationFactorThreshold;i+=_*_*t.IPColocationFactorWeight}}),e.behaviourPenalty>t.behaviourPenaltyThreshold){const o=e.behaviourPenalty-t.behaviourPenaltyThreshold;i+=o*o*t.behaviourPenaltyWeight}return i}var qK=x(1807),fi=(()=>(function(n){n[n.unknown=0]="unknown",n[n.valid=1]="valid",n[n.invalid=2]="invalid",n[n.ignored=3]="ignored"}(fi||(fi={})),fi))();class YK{constructor(){this.records=new Map,this.queue=new qK}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:fi.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(e,t);const r={msgId:e,expire:Date.now()+12e4};return this.queue.push(r),t}gc(){const e=Date.now();let t=this.queue.peekFront();for(;t&&t.expire0)throw ae(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.IPColocationFactorWeight&&n.IPColocationFactorThreshold<1)throw ae(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Kn);if(n.behaviourPenaltyWeight>0)throw ae(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.behaviourPenaltyWeight&&(n.behaviourPenaltyDecay<=0||n.behaviourPenaltyDecay>=1))throw ae(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Kn);if(n.decayInterval<1e3)throw ae(new Error("invalid DecayInterval; must be at least 1s"),Kn);if(n.decayToZero<=0||n.decayToZero>=1)throw ae(new Error("invalid DecayToZero; must be between 0 and 1"),Kn)}(e),this.scoreCacheValidityMs=r.scoreCacheValidityMs,this.computeScore=r.computeScore??WK}init(e){this.components=e}get size(){return this.peerStats.size}start(){this._backgroundInterval?yu("Peer score already running"):(this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),yu("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),yu("stopped")):yu("Peer score already stopped")}background(){this.refreshScores(),this.updateIPs(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map(([e,t])=>[e,t]))}refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach((r,i)=>{r.connected?(Object.entries(r.topics).forEach(([s,o])=>{const a=this.params.topics[s];void 0!==a&&(o.firstMessageDeliveries*=a.firstMessageDeliveriesDecay,o.firstMessageDeliveriesa.meshMessageDeliveriesActivation&&(o.meshMessageDeliveriesActive=!0)))}),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenaltyr.expire&&(this.removeIPs(i,r.ips),this.peerStats.delete(i),this.scoreCache.delete(i))})}score(e){this.metrics?.scoreFnCalls.inc();const t=this.peerStats.get(e);if(!t)return 0;const r=Date.now(),i=this.scoreCache.get(e);if(i&&i.cacheUntil>r)return i.score;this.metrics?.scoreFnRuns.inc();const s=this.computeScore(e,t,this.params,this.peerIPs),o=r+this.scoreCacheValidityMs;return i?(this.metrics?.scoreCachedDelta.observe(Math.abs(s-i.score)),i.score=s,i.cacheUntil=o):this.scoreCache.set(e,{score:s,cacheUntil:o}),s}addPenalty(e,t,r){const i=this.peerStats.get(e);i&&(i.behaviourPenalty+=t,this.metrics?.onScorePenalty(r))}addPeer(e){const t={connected:!0,expire:0,topics:{},ips:[],behaviourPenalty:0};this.peerStats.set(e,t);const r=this.getIPs(e);this.setIPs(e,r,t.ips),t.ips=r}removePeer(e){const t=this.peerStats.get(e);if(t){if(this.score(e)>0)return this.removeIPs(e,t.ips),void this.peerStats.delete(e);Object.entries(t.topics).forEach(([r,i])=>{i.firstMessageDeliveries=0;const s=this.params.topics[r].meshMessageDeliveriesThreshold;if(i.inMesh&&i.meshMessageDeliveriesActive&&i.meshMessageDeliveries{o!==e.toString()&&this.markDuplicateMessageDelivery(o,r)})):yu("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,fi[i.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,i){switch(i){case Ji.Error:return void this.markInvalidMessageDelivery(e,r);case Ji.Blacklisted:return}const s=this.deliveryRecords.ensureRecord(t);if(s.status===fi.unknown)return i===Ji.Ignore?(s.status=fi.ignored,void s.peers.clear()):(s.status=fi.invalid,this.markInvalidMessageDelivery(e,r),s.peers.forEach(o=>{this.markInvalidMessageDelivery(o,r)}),void s.peers.clear());yu("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,fi[s.status])}duplicateMessage(e,t,r){const i=this.deliveryRecords.ensureRecord(t);if(!i.peers.has(e))switch(i.status){case fi.unknown:i.peers.add(e);break;case fi.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,r,i.validated);break;case fi.invalid:this.markInvalidMessageDelivery(e,r)}}markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);i&&(i.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);if(i){let s=this.params.topics[t].firstMessageDeliveriesCap;i.firstMessageDeliveries=Math.min(s,i.firstMessageDeliveries+1),i.inMesh&&(s=this.params.topics[t].meshMessageDeliveriesCap,i.meshMessageDeliveries=Math.min(s,i.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(e,t,r){const i=this.peerStats.get(e);if(i){const s=void 0!==r?Date.now():0,o=this.getPtopicStats(i,t);if(o&&o.inMesh){const a=this.params.topics[t];if(void 0!==r){const _=s-r,R=_>a.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(t,_,R),R)return}o.meshMessageDeliveries=Math.min(a.meshMessageDeliveriesCap,o.meshMessageDeliveries+1)}}}getIPs(e){return this.components.getConnectionManager().getConnections(fr(e)).map(t=>t.remoteAddr.toOptions().host)}setIPs(e,t,r){e:for(const i of t){for(const o of r)if(i===o)continue e;let s=this.peerIPs.get(i);s||(s=new Set,this.peerIPs.set(i,s)),s.add(e)}e:for(const i of r){for(const o of t)if(i===o)continue e;const s=this.peerIPs.get(i);!s||(s.delete(e),s.size||this.peerIPs.delete(i))}}removeIPs(e,t){t.forEach(r=>{const i=this.peerIPs.get(r);!i||(i.delete(e),i.size||this.peerIPs.delete(r))})}updateIPs(){this.peerStats.forEach((e,t)=>{const r=this.getIPs(t);this.setIPs(t,r,e.ips),e.ips=r})}getPtopicStats(e,t){let r=e.topics[t];return void 0!==r?r:void 0!==this.params.topics[t]?(r={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e.topics[t]=r,r):null}}class ZK{constructor(e,t,r){this.gossipsubIWantFollowupMs=e,this.msgIdToStrFn=t,this.metrics=r,this.promises=new Map,this.requestMsByMsg=new Map,this.requestMsByMsgExpire=10*e}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(e,t){const r=Math.floor(Math.random()*t.length),s=this.msgIdToStrFn(t[r]);let o=this.promises.get(s);o||(o=new Map,this.promises.set(s,o));const a=Date.now();o.has(e)||(o.set(e,a+this.gossipsubIWantFollowupMs),this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(s)||this.requestMsByMsg.set(s,a)))}getBrokenPromises(){const e=Date.now(),t=new Map;let r=0;return this.promises.forEach((i,s)=>{i.forEach((o,a)=>{o=Date.now()?t.value:void 0}clear(){this.entries.clear()}}var _o=(()=>(function(n){n.Fanout="fanout",n.Random="random",n.Subscribed="subscribed",n.Outbound="outbound",n.NotEnough="not_enough",n.Opportunistic="opportunistic"}(_o||(_o={})),_o))(),Fa=(()=>(function(n){n.Dc="disconnected",n.BadScore="bad_score",n.Prune="prune",n.Unsub="unsubscribed",n.Excess="excess"}(Fa||(Fa={})),Fa))(),mu=(()=>(function(n){n.GraftBackoff="graft_backoff",n.BrokenPromise="broken_promise",n.MessageDeficit="message_deficit",n.IPColocation="IP_colocation"}(mu||(mu={})),mu))(),vu=(()=>(function(n){n.LowScore="low_score",n.MaxIhave="max_ihave",n.MaxIasked="max_iasked"}(vu||(vu={})),vu))(),Ua=(()=>(function(n){n.graylist="graylist",n.publish="publish",n.gossip="gossip",n.mesh="mesh"}(Ua||(Ua={})),Ua))();const qA=Ot("libp2p-pubsub:");function VE(){return VE=j(function*(n,e,t,r){switch(n.type){case Ba.Signing:{const i={from:n.author.toBytes(),data:r,seqno:nh(8),topic:e,signature:void 0,key:void 0},s=wr([qA,ap.Message.encode(i).finish()]);return i.signature=yield n.privateKey.sign(s),i.key=n.key,{raw:i,msg:{type:"signed",from:n.author,data:t,sequenceNumber:BigInt(`0x${Lt(i.seqno,"base16")}`),topic:e,signature:i.signature,key:i.key}}}case Ba.Anonymous:return{raw:{from:void 0,data:r,seqno:void 0,topic:e,signature:void 0,key:void 0},msg:{type:"unsigned",data:t,topic:e}}}}),VE.apply(this,arguments)}function HE(){return HE=j(function*(n,e){switch(n){case BE:return null!=e.signature?{valid:!1,error:li.SignaturePresent}:null!=e.seqno?{valid:!1,error:li.SeqnoPresent}:null!=e.key?{valid:!1,error:li.FromPresent}:{valid:!0,message:{type:"unsigned",topic:e.topic,data:e.data??new Uint8Array(0)}};case cp:{if(null==e.seqno)return{valid:!1,error:li.InvalidSeqno};if(8!==e.seqno.length)return{valid:!1,error:li.InvalidSeqno};if(null==e.signature)return{valid:!1,error:li.InvalidSignature};if(null==e.from)return{valid:!1,error:li.InvalidPeerId};let t,r;try{t=Jc(e.from)}catch{return{valid:!1,error:li.InvalidPeerId}}if(e.key){if(r=Rl(e.key),void 0!==t.publicKey&&!kr(r.bytes,t.publicKey))return{valid:!1,error:li.InvalidPeerId}}else{if(null==t.publicKey)return{valid:!1,error:li.InvalidPeerId};r=Rl(t.publicKey)}const s=wr([qA,ap.Message.encode({from:e.from,data:e.data,seqno:e.seqno,topic:e.topic,signature:void 0,key:void 0}).finish()]);return(yield r.verify(s,e.signature))?{valid:!0,message:{type:"signed",from:t,data:e.data??new Uint8Array(0),sequenceNumber:BigInt(`0x${Lt(e.seqno,"base16")}`),topic:e.topic,signature:e.signature,key:e.key??o2(r)}}:{valid:!1,error:li.InvalidSignature}}}}),HE.apply(this,arguments)}function i$(n){if("signed"!==n.type)throw new Error("expected signed message type");if(null==n.sequenceNumber)throw Error("missing seqno field");return((n,e)=>{const t=Ot(e.toString(16).padStart(16,"0"),"base16"),r=new Uint8Array(n.length+t.length);return r.set(n,0),r.set(t,n.length),r})(n.from.toBytes(),n.sequenceNumber)}function s$(n){return KE.apply(this,arguments)}function KE(){return KE=j(function*(n){return yield mi.encode(n.data)}),KE.apply(this,arguments)}function o$(n,e,t,r,i){let s=0;const o=new Map;if(Object.entries(e.topics).forEach(([B,K])=>{const Z=i.get(B)??"unknown",J=t.topics[B];if(void 0===J)return;let oe=o.get(Z);oe||(oe={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(Z,oe));let he=0,Ie=0,ue=0,Re=0,ze=0;K.inMesh&&(he+=Math.max(K.meshTime/J.timeInMeshQuantum,J.timeInMeshCap)*J.timeInMeshWeight);let Oe=K.firstMessageDeliveries;if(Oe>J.firstMessageDeliveriesCap&&(Oe=J.firstMessageDeliveriesCap),Ie+=Oe*J.firstMessageDeliveriesWeight,K.meshMessageDeliveriesActive&&K.meshMessageDeliveries0&&s>t.topicScoreCap){s=t.topicScoreCap;const B=t.topicScoreCap/s;for(const K of o.values())K.p1w*=B,K.p2w*=B,K.p3w*=B,K.p3bw*=B,K.p4w*=B}let a=0,u=0,_=0;return a+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(B=>{if(t.IPColocationFactorWhitelist.has(B))return;const K=r.get(B),Z=K?K.size:0;if(Z>t.IPColocationFactorThreshold){const J=Z-t.IPColocationFactorThreshold;u+=J*J*t.IPColocationFactorWeight}}),_+=e.behaviourPenalty*e.behaviourPenalty*t.behaviourPenaltyWeight,s+=a+u+_,{byTopic:o,p5w:a,p6w:u,p7w:_,score:s}}function $E(n,e,t=(()=>!0)){const r=new Set;if(e<=0)return r;for(const i of n){if(r.size>=e)break;t(i)&&(r.add(i),n.delete(i))}return r}class u${constructor(e,t,r){this.rawStream=e,this.pushable=Mc({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=r.maxBufferSize??1/0,Wn(vs(this.pushable,this.closeController.signal,{returnOnAbort:!0}),Os(),this.rawStream).catch(t)}get protocol(){return this.rawStream.stat.protocol}push(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(e)}close(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}}class l${constructor(e){this.rawStream=e,this.closeController=new AbortController,this.source=vs(Wn(this.rawStream,ps()),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}}var _i=(()=>(function(n){n[n.started=0]="started",n[n.stopped=1]="stopped"}(_i||(_i={})),_i))();class YA extends Ei{constructor(e={}){super(),this.multicodecs=[LE,GA],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=Mc({objectMode:!0}),this.direct=new Set,this.floodsubPeers=new Set,this.acceptFromWhitelist=new Map,this.topics=new Map,this.subscriptions=new Set,this.mesh=new Map,this.fanout=new Map,this.fanoutLastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.topicValidators=new Map,this.heartbeatTicks=0,this.components=new ho,this.directPeerInitial=null,this.status={code:_i.stopped},this.heartbeatTimer=null,this.runHeartbeat=()=>{const r=this.metrics?.heartbeatDuration.startTimer();this.heartbeat().catch(i=>{this.log("Error running heartbeat",i)}).finally(()=>{if(r?.(),this.status.code===_i.started){clearTimeout(this.status.heartbeatTimeout);let i=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;i<.25*this.opts.heartbeatInterval&&(i+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,i)}})};const t={fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:6,Dlo:4,Dhi:12,Dscore:4,Dout:2,Dlazy:6,heartbeatInterval:1e3,fanoutTTL:6e4,mcacheLength:5,mcacheGossip:3,seenTTL:12e4,gossipsubIWantFollowupMs:3e3,prunePeers:16,pruneBackoff:6e4,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300,...e,scoreParams:HK(e.scoreParams),scoreThresholds:zK(e.scoreThresholds)};if(this.globalSignaturePolicy=t.globalSignaturePolicy??cp,t.fallbackToFloodsub&&this.multicodecs.push(jA),this.log=Gt(t.debugName??"libp2p:gossipsub"),this.opts=t,this.direct=new Set(t.directPeers.map(r=>r.id.toString())),this.seenCache=new UE({validityMs:t.seenTTL}),this.publishedMessageIds=new UE({validityMs:t.seenTTL}),e.msgIdFn)this.msgIdFn=e.msgIdFn;else switch(this.globalSignaturePolicy){case cp:this.msgIdFn=i$;break;case BE:this.msgIdFn=s$}if(e.fastMsgIdFn&&(this.fastMsgIdFn=e.fastMsgIdFn,this.fastMsgIdCache=new UE({validityMs:t.seenTTL})),this.msgIdToStrFn=e.msgIdToStrFn??BK,this.mcache=e.messageCache||new sK(t.mcacheGossip,t.mcacheLength,this.msgIdToStrFn),e.dataTransform&&(this.dataTransform=e.dataTransform),e.metricsRegister){if(!e.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");const r=Math.max(...Object.values(t.scoreParams.topics).map(s=>s.meshMessageDeliveriesWindow),1e3),i=function XK(n,e,t){return{protocolsEnabled:n.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:n.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:n.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:n.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEvents:n.gauge({name:"gossipsub_mesh_peer_inclusion_events_total",help:"Number of times we include peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),meshPeerChurnEvents:n.gauge({name:"gossipsub_peer_churn_events_total",help:"Number of times we remove peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),peersPerProtocol:n.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:n.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:n.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),asyncValidationResult:n.gauge({name:"gossipsub_async_validation_result_total",help:"Message validation result for each topic",labelNames:["topic","acceptance"]}),asyncValidationMcacheHit:n.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),rpcRecvBytes:n.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:n.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:n.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:n.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:n.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:n.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:n.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:n.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:n.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcRecvNotAccepted:n.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:n.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:n.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:n.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:n.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:n.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:n.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:n.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:n.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:n.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:n.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeers:n.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),msgPublishPeersByGroup:n.gauge({name:"gossipsub_msg_publish_peers_by_group",help:"Total count of peers (by group) that we publish a msg to",labelNames:["topic","peerGroup"]}),msgPublishBytes:n.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgForwardCount:n.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:n.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:n.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedStatus:n.gauge({name:"gossipsub_msg_received_status_total",help:"Tracks distribution of recv msgs by duplicate, invalid, valid",labelNames:["topic","status"]}),msgReceivedInvalid:n.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["topic","error"]}),duplicateMsgDeliveryDelay:n.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*t.maxMeshMessageDeliveriesWindowSec,.5*t.maxMeshMessageDeliveriesWindowSec,1*t.maxMeshMessageDeliveriesWindowSec,2*t.maxMeshMessageDeliveriesWindowSec,4*t.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:n.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),scoreFnCalls:n.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:n.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:n.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:n.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:n.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores",labelNames:["topic","p"]}),scoreWeights:n.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:n.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:n.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:n.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*t.behaviourPenaltyThreshold,.5*t.behaviourPenaltyThreshold,1*t.behaviourPenaltyThreshold,2*t.behaviourPenaltyThreshold,4*t.behaviourPenaltyThreshold]}),ihaveRcvIgnored:n.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:n.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:n.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:n.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:n.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:n.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:n.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedPeers:n.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:n.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantPromiseDeliveryTime:n.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*t.gossipPromiseExpireSec,1*t.gossipPromiseExpireSec,2*t.gossipPromiseExpireSec,4*t.gossipPromiseExpireSec]}),cacheSize:n.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:n.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),topicStrToLabel:e,toTopic(r){return this.topicStrToLabel.get(r)??r},onJoin(r){this.topicSubscriptionStatus.set({topicStr:r},1),this.meshPeerCounts.set({topicStr:r},0)},onLeave(r){this.topicSubscriptionStatus.set({topicStr:r},0),this.meshPeerCounts.set({topicStr:r},0)},onAddToMesh(r,i,s){const o=this.toTopic(r);this.meshPeerInclusionEvents.inc({topic:o,reason:i},s)},onRemoveFromMesh(r,i,s){const o=this.toTopic(r);this.meshPeerChurnEvents.inc({topic:o,reason:i},s)},onReportValidationMcacheHit(r){this.asyncValidationMcacheHit.inc({hit:r?"hit":"miss"})},onReportValidation(r,i){const s=this.toTopic(r);this.asyncValidationResult.inc({topic:s,acceptance:i})},onScorePenalty(r){this.scoringPenalties.inc({penalty:r},1)},onIhaveRcv(r,i,s){const o=this.toTopic(r);this.ihaveRcvMsgids.inc({topic:o},i),this.ihaveRcvNotSeenMsgids.inc({topic:o},s)},onIwantRcv(r,i){for(const[s,o]of r){const a=this.toTopic(s);this.iwantRcvMsgids.inc({topic:a},o)}this.iwantRcvDonthaveMsgids.inc(i)},onForwardMsg(r,i){const s=this.toTopic(r);this.msgForwardCount.inc({topic:s},1),this.msgForwardPeers.inc({topic:s},i)},onPublishMsg(r,i,s,o){const a=this.toTopic(r);this.msgPublishCount.inc({topic:a},1),this.msgPublishBytes.inc({topic:a},s*o),this.msgPublishPeers.inc({topic:a},s),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"direct"},i.direct),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"floodsub"},i.floodsub),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"mesh"},i.mesh),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"fanout"},i.fanout)},onMsgRecvPreValidation(r){const i=this.toTopic(r);this.msgReceivedPreValidation.inc({topic:i},1)},onMsgRecvResult(r,i){const s=this.toTopic(r);this.msgReceivedStatus.inc({topic:s,status:i})},onMsgRecvInvalid(r,i){const s=this.toTopic(r);this.msgReceivedInvalid.inc({topic:s,error:i.reason===Ji.Error?i.error:i.reason},1)},onDuplicateMsgDelivery(r,i,s){if(this.duplicateMsgDeliveryDelay.observe(i/1e3),s){const o=this.toTopic(r);this.duplicateMsgLateDelivery.inc({topic:o},1)}},onRpcRecv(r,i){this.rpcRecvBytes.inc(i),this.rpcRecvCount.inc(1),r.subscriptions&&this.rpcRecvSubscription.inc(r.subscriptions.length),r.messages&&this.rpcRecvMessage.inc(r.messages.length),r.control&&(this.rpcRecvControl.inc(1),r.control.ihave&&this.rpcRecvIHave.inc(r.control.ihave.length),r.control.iwant&&this.rpcRecvIWant.inc(r.control.iwant.length),r.control.graft&&this.rpcRecvGraft.inc(r.control.graft.length),r.control.prune&&this.rpcRecvPrune.inc(r.control.prune.length))},onRpcSent(r,i){if(this.rpcSentBytes.inc(i),this.rpcSentCount.inc(1),r.subscriptions&&this.rpcSentSubscription.inc(r.subscriptions.length),r.messages&&this.rpcSentMessage.inc(r.messages.length),r.control){const s=r.control.ihave?.length??0,o=r.control.iwant?.length??0,a=r.control.graft?.length??0,u=r.control.prune?.length??0;s>0&&this.rpcSentIHave.inc(s),o>0&&this.rpcSentIWant.inc(o),a>0&&this.rpcSentGraft.inc(a),u>0&&this.rpcSentPrune.inc(u),(s>0||o>0||a>0||u>0)&&this.rpcSentControl.inc(1)}},registerScores(r,i){let s=0,o=0,a=0,u=0;for(const _ of r)_>=i.graylistThreshold&&s++,_>=i.publishThreshold&&o++,_>=i.gossipThreshold&&a++,_>=0&&u++;this.peersByScoreThreshold.set({threshold:Ua.graylist},s),this.peersByScoreThreshold.set({threshold:Ua.publish},o),this.peersByScoreThreshold.set({threshold:Ua.gossip},a),this.peersByScoreThreshold.set({threshold:Ua.mesh},u),this.score.set(r)},registerScoreWeights(r){for(const[i,s]of r.byTopic)this.scoreWeights.set({topic:i,p:"p1"},s.p1w),this.scoreWeights.set({topic:i,p:"p2"},s.p2w),this.scoreWeights.set({topic:i,p:"p3"},s.p3w),this.scoreWeights.set({topic:i,p:"p3b"},s.p3bw),this.scoreWeights.set({topic:i,p:"p4"},s.p4w);this.scoreWeights.set({p:"p5"},r.p5w),this.scoreWeights.set({p:"p6"},r.p6w),this.scoreWeights.set({p:"p7"},r.p7w)},registerScorePerMesh(r,i){const s=new Map;r.forEach((o,a)=>{const u=this.topicStrToLabel.get(a)??"unknown";let _=s.get(u);_||(_=new Set,s.set(u,_)),o.forEach(R=>_?.add(R))});for(const[o,a]of s){const u=[];a.forEach(_=>{u.push(i.get(_)??0)}),this.scorePerMesh.set({topic:o},u)}}}}(e.metricsRegister,e.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:t.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:r/1e3});i.mcacheSize.addCollect(()=>this.onScrapeMetrics(i));for(const s of this.multicodecs)i.protocolsEnabled.set({protocol:s},1);this.metrics=i}else this.metrics=null;this.gossipTracer=new ZK(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new QK(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:t.heartbeatInterval}),this.maxInboundStreams=e.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams}getPeers(){return[...this.peers.keys()].map(e=>fr(e))}isStarted(){return this.status.code===_i.started}init(e){var t=this;return j(function*(){t.components=e,t.score.init(e)})()}start(){var e=this;return j(function*(){if(e.isStarted())return;e.log("starting"),e.publishConfig=yield function FK(n,e){return FE.apply(this,arguments)}(e.globalSignaturePolicy,e.components.getPeerId()),e.outboundInflightQueue=Mc({objectMode:!0}),Wn(e.outboundInflightQueue,function(){var o=j(function*(a){var R,u=!1,_=!1;try{for(var B,N=Pt(a);u=!(B=yield N.next()).done;u=!1){const{peerId:K,connection:Z}=B.value;yield e.createOutboundStream(K,Z)}}catch(K){_=!0,R=K}finally{try{u&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()).catch(o=>e.log.error("outbound inflight queue error",o)),yield Promise.all(e.opts.directPeers.map(function(){var o=j(function*(a){yield e.components.getPeerStore().addressBook.add(a.id,a.addrs)});return function(a){return o.apply(this,arguments)}}()));const t=e.components.getRegistrar();yield Promise.all(e.multicodecs.map(o=>t.handle(o,e.onIncomingStream.bind(e),{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams})));const r=function iK(n){return new rK(n)}({onConnect:e.onPeerConnected.bind(e),onDisconnect:e.onPeerDisconnected.bind(e)}),i=yield Promise.all(e.multicodecs.map(o=>t.register(o,r))),s=setTimeout(e.runHeartbeat,100);e.status={code:_i.started,registrarTopologyIds:i,heartbeatTimeout:s,hearbeatStartMs:Date.now()+100},e.score.start(),e.directPeerInitial=setTimeout(()=>{Promise.resolve().then(j(function*(){yield Promise.all(Array.from(e.direct).map(function(){var o=j(function*(a){return yield e.connect(a)});return function(a){return o.apply(this,arguments)}}()))})).catch(o=>{e.log(o)})},1e3),e.log("started")})()}stop(){var e=this;return j(function*(){if(e.log("stopping"),e.status.code!==_i.started)return;const{registrarTopologyIds:t}=e.status;e.status={code:_i.stopped};const r=e.components.getRegistrar();t.forEach(i=>r.unregister(i)),e.outboundInflightQueue.end();for(const i of e.streamsOutbound.values())i.close();e.streamsOutbound.clear();for(const i of e.streamsInbound.values())i.close();e.streamsInbound.clear(),e.peers.clear(),e.subscriptions.clear(),e.heartbeatTimer&&(e.heartbeatTimer.cancel(),e.heartbeatTimer=null),e.score.stop(),e.mesh.clear(),e.fanout.clear(),e.fanoutLastpub.clear(),e.gossip.clear(),e.control.clear(),e.peerhave.clear(),e.iasked.clear(),e.backoff.clear(),e.outbound.clear(),e.gossipTracer.clear(),e.seenCache.clear(),e.fastMsgIdCache&&e.fastMsgIdCache.clear(),e.directPeerInitial&&clearTimeout(e.directPeerInitial),e.log("stopped")})()}dumpPeerScoreStats(){return this.score.dumpPeerScoreStats()}onIncomingStream({stream:e,connection:t}){if(!this.isStarted())return;const r=t.remotePeer;this.addPeer(r,t.stat.direction),this.createInboundStream(r,e),this.outboundInflightQueue.push({peerId:r,connection:t})}onPeerConnected(e,t){!this.isStarted()||(this.addPeer(e,t.stat.direction),this.outboundInflightQueue.push({peerId:e,connection:t}))}onPeerDisconnected(e){this.log("connection ended %p",e),this.removePeer(e)}createOutboundStream(e,t){var r=this;return j(function*(){if(!r.isStarted())return;const i=e.toString();if(r.peers.has(i)&&!r.streamsOutbound.has(i))try{const s=new u$(yield t.newStream(r.multicodecs),a=>r.log.error("outbound pipe error",a),{maxBufferSize:r.opts.maxOutboundBufferSize});r.log("create outbound stream %p",e),r.streamsOutbound.set(i,s);const o=s.protocol;o===jA&&r.floodsubPeers.add(i),r.metrics?.peersPerProtocol.inc({protocol:o},1),r.subscriptions.size>0&&(r.log("send subscriptions to",i),r.sendSubscriptions(i,Array.from(r.subscriptions),!0))}catch(s){r.log.error("createOutboundStream error",s)}})()}createInboundStream(e,t){var r=this;return j(function*(){if(!r.isStarted())return;const i=e.toString();if(!r.peers.has(i))return;const s=r.streamsInbound.get(i);void 0!==s&&(r.log("replacing existing inbound steam %s",i),s.close()),r.log("create inbound stream %s",i);const o=new l$(t);r.streamsInbound.set(i,o),r.pipePeerReadStream(e,o.source).catch(a=>r.log(a))})()}addPeer(e,t){const r=e.toString();this.peers.has(r)||(this.log("new peer %p",e),this.peers.add(r),this.score.addPeer(r),this.outbound.has(r)||this.outbound.set(r,"outbound"===t))}removePeer(e){const t=e.toString();if(!this.peers.has(t))return;this.log("delete peer %p",e),this.peers.delete(t);const r=this.streamsOutbound.get(t),i=this.streamsInbound.get(t);r&&this.metrics?.peersPerProtocol.inc({protocol:r.protocol},-1),r?.close(),i?.close(),this.streamsOutbound.delete(t),this.streamsInbound.delete(t);for(const s of this.topics.values())s.delete(t);for(const[s,o]of this.mesh)!0===o.delete(t)&&this.metrics?.onRemoveFromMesh(s,Fa.Dc,1);for(const s of this.fanout.values())s.delete(t);this.floodsubPeers.delete(t),this.gossip.delete(t),this.control.delete(t),this.outbound.delete(t),this.score.removePeer(t),this.acceptFromWhitelist.delete(t)}get started(){return this.status.code===_i.started}getMeshPeers(e){const t=this.mesh.get(e);return t?Array.from(t):[]}getSubscribers(e){const t=this.topics.get(e);return(t?Array.from(t):[]).map(r=>fr(r))}getTopics(){return Array.from(this.subscriptions)}pipePeerReadStream(e,t){var r=this;return j(function*(){try{yield Wn(t,function(){var i=j(function*(s){var u,o=!1,a=!1;try{for(var R,_=Pt(s);o=!(R=yield _.next()).done;o=!1){const N=R.value;try{const B=N.subarray(),K=ap.decode(B);r.metrics?.onRpcRecv(K,B.length),r.opts.awaitRpcHandler?yield r.handleReceivedRpc(e,K):r.handleReceivedRpc(e,K).catch(Z=>r.log(Z))}catch(B){r.log(B)}}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw u}}});return function(s){return i.apply(this,arguments)}}())}catch(i){r.log.error(i),r.onPeerDisconnected(e)}})()}handleReceivedRpc(e,t){var r=this;return j(function*(){if(!r.acceptFrom(e.toString()))return r.log("received message from unacceptable peer %p",e),void r.metrics?.rpcRecvNotAccepted.inc();if(r.log("rpc from %p",e),t.subscriptions&&t.subscriptions.length>0&&(t.subscriptions.forEach(i=>{r.handleReceivedSubscription(e,i)}),r.dispatchEvent(new tn("subscription-change",{detail:{peerId:e,subscriptions:t.subscriptions.filter(i=>null!==i.topic).map(i=>({topic:i.topic??"",subscribe:Boolean(i.subscribe)}))}}))),t.messages)for(const i of t.messages){const s=r.handleReceivedMessage(e,i).catch(o=>r.log(o));r.opts.awaitRpcMessageHandler&&(yield s)}t.control&&(yield r.handleControlMessage(e.toString(),t.control))})()}handleReceivedSubscription(e,t){if(null==t.topic)return;this.log("subscription update from %p topic %s",e,t.topic);let r=this.topics.get(t.topic);null==r&&(r=new Set,this.topics.set(t.topic,r)),t.subscribe?r.add(e.toString()):r.delete(e.toString())}handleReceivedMessage(e,t){var r=()=>super.dispatchEvent,i=this;return j(function*(){i.metrics?.onMsgRecvPreValidation(t.topic);const s=yield i.validateReceivedMessage(e,t);switch(i.metrics?.onMsgRecvResult(t.topic,s.code),s.code){case es.duplicate:return i.score.duplicateMessage(e.toString(),s.msgIdStr,t.topic),void i.mcache.observeDuplicate(s.msgIdStr,e.toString());case es.invalid:if(s.msgIdStr){const o=s.msgIdStr;i.score.rejectMessage(e.toString(),o,t.topic,s.reason),i.gossipTracer.rejectMessage(o,s.reason)}else i.score.rejectInvalidMessage(e.toString(),t.topic);return void i.metrics?.onMsgRecvInvalid(t.topic,s);case es.valid:i.score.validateMessage(s.messageId.msgIdStr),i.gossipTracer.deliverMessage(s.messageId.msgIdStr),i.mcache.put(s.messageId,t,!i.opts.asyncValidation),i.subscriptions.has(t.topic)&&(!i.components.getPeerId().equals(e)||i.opts.emitSelf)&&(r().call(i,new tn("gossipsub:message",{detail:{propagationSource:e,msgId:s.messageId.msgIdStr,msg:s.msg}})),r().call(i,new tn("message",{detail:s.msg}))),i.opts.asyncValidation||i.forwardMessage(s.messageId.msgIdStr,t,e.toString())}})()}validateReceivedMessage(e,t){var r=this;return j(function*(){const i=r.fastMsgIdFn?.(t),s=i?r.fastMsgIdCache?.get(i):void 0;if(s)return{code:es.duplicate,msgIdStr:s};const o=yield function e$(n,e){return HE.apply(this,arguments)}(r.globalSignaturePolicy,t);if(!o.valid)return{code:es.invalid,reason:Ji.Error,error:o.error};const a=o.message;try{r.dataTransform&&(a.data=r.dataTransform.inboundTransform(t.topic,a.data))}catch(B){return r.log("Invalid message, transform failed",B),{code:es.invalid,reason:Ji.Error,error:li.TransformFailed}}const u=yield r.msgIdFn(a),_=r.msgIdToStrFn(u),R={msgId:u,msgIdStr:_};if(i&&r.fastMsgIdCache?.put(i,_),r.seenCache.has(_))return{code:es.duplicate,msgIdStr:_};r.seenCache.put(_);const N=r.topicValidators.get(t.topic);if(null!=N){let B;try{B=yield N(a.topic,a,e)}catch(K){const Z=K.code;"ERR_TOPIC_VALIDATOR_IGNORE"===Z&&(B=$s.Ignore),B="ERR_TOPIC_VALIDATOR_REJECT"===Z?$s.Reject:$s.Ignore}if(B!==$s.Accept)return{code:es.invalid,reason:WA(B),msgIdStr:_}}return{code:es.valid,messageId:R,msg:a}})()}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,r){this.sendRpc(e,{subscriptions:t.map(i=>({topic:i,subscribe:r})),messages:[]})}handleControlMessage(e,t){var r=this;return j(function*(){if(void 0===t)return;const i=t.ihave?r.handleIHave(e,t.ihave):[],s=t.iwant?r.handleIWant(e,t.iwant):[],o=t.graft?yield r.handleGraft(e,t.graft):[];t.prune&&(yield r.handlePrune(e,t.prune)),(i.length||s.length||o.length)&&r.sendRpc(e,bo(s,{iwant:i,prune:o}))})()}acceptFrom(e){if(this.direct.has(e))return!0;const t=Date.now(),r=this.acceptFromWhitelist.get(e);if(r&&r.messagesAccepted<128&&r.acceptUntil>=t)return r.messagesAccepted+=1,!0;const i=this.score.score(e);return i>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),i>=this.opts.scoreThresholds.graylistThreshold}handleIHave(e,t){if(!t.length)return[];const r=this.score.score(e);if(r10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,i),this.metrics?.ihaveRcvIgnored.inc({reason:vu.MaxIhave}),[];const s=this.iasked.get(e)??0;if(s>=gu)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,s),this.metrics?.ihaveRcvIgnored.inc({reason:vu.MaxIasked}),[];const o=new Map;if(t.forEach(({topicID:_,messageIDs:R})=>{if(!_||!R||!this.mesh.has(_))return;let N=0;R.forEach(B=>{const K=this.msgIdToStrFn(B);this.seenCache.has(K)||(o.set(K,B),N++)}),this.metrics?.onIhaveRcv(_,R.length,N)}),!o.size)return[];let a=o.size;a+s>gu&&(a=gu-s),this.log("IHAVE: Asking for %d out of %d messages from %s",a,o.size,e);let u=Array.from(o.values());return wo(u),u=u.slice(0,a),this.iasked.set(e,s+a),this.gossipTracer.addPromise(e,u),[{messageIDs:u}]}handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{a&&a.forEach(u=>{const _=this.msgIdToStrFn(u),R=this.mcache.getWithIWantCount(_,e);null!=R?(s.set(R.msg.topic,1+(s.get(R.msg.topic)??0)),R.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,u):i.set(_,R.msg)):o++})}),this.metrics?.onIwantRcv(s,o),i.size?(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values())):(this.log("IWANT: Could not provide any wanted messages to %s",e),[])}handleGraft(e,t){var r=this;return j(function*(){const i=[],s=r.score.score(e),o=Date.now();let a=r.opts.doPX;return t.forEach(({topicID:u})=>{if(!u)return;const _=r.mesh.get(u);if(!_)return void(a=!1);if(_.has(e))return;if(r.direct.has(e))return r.log("GRAFT: ignoring request from direct peer %s",e),i.push(u),void(a=!1);const R=r.backoff.get(u)?.get(e);return"number"==typeof R&&o=r.opts.Dhi&&!r.outbound.get(e)?(i.push(u),void r.addBackoff(e,u)):(r.log("GRAFT: Add mesh link from %s in %s",e,u),r.score.graft(e,u),_.add(e),void r.metrics?.onAddToMesh(u,_o.Subscribed,1))}),i.length?yield Promise.all(i.map(u=>r.makePrune(e,u,a))):[]})()}handlePrune(e,t){var r=this;return j(function*(){const i=r.score.score(e);for(const{topicID:s,backoff:o,peers:a}of t){if(null==s)continue;const u=r.mesh.get(s);if(!u)return;if(r.log("PRUNE: Remove mesh link to %s in %s",e,s),r.score.prune(e,s),u.has(e)&&(u.delete(e),r.metrics?.onRemoveFromMesh(s,Fa.Unsub,1)),"number"==typeof o&&o>0?r.doAddBackoff(e,s,1e3*o):r.addBackoff(e,s),a&&a.length){if(i{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e,mu.BrokenPromise)})}clearBackoff(){if(this.heartbeatTicks%15!=0)return;const e=Date.now();this.backoff.forEach((t,r)=>{t.forEach((i,s)=>{i{e.streamsOutbound.has(r)||t.push(r)}),yield Promise.all(t.map(function(){var r=j(function*(i){return yield e.connect(i)});return function(i){return r.apply(this,arguments)}}()))})()}pxConnect(e){var t=this;return j(function*(){e.length>t.opts.prunePeers&&(wo(e),e=e.slice(0,t.opts.prunePeers));const r=[];yield Promise.all(e.map(function(){var i=j(function*(s){if(!s.peerID)return;const o=Jc(s.peerID).toString();if(!t.peers.has(o)){if(!s.signedPeerRecord)return void r.push(o);try{const a=yield wi.openAndCertify(s.signedPeerRecord,"libp2p-peer-record"),u=a.peerId;if(!a.peerId.equals(o))return void t.log("bogus peer record obtained through px: peer ID %p doesn't match expected peer %p",u,o);if(!(yield t.components.getPeerStore().addressBook.consumePeerRecord(a)))return void t.log("bogus peer record obtained through px: could not add peer record to address book");r.push(o)}catch{t.log("bogus peer record obtained through px: invalid signature or not a peer record")}}});return function(s){return i.apply(this,arguments)}}())),r.length&&(yield Promise.all(r.map(function(){var i=j(function*(s){return yield t.connect(s)});return function(s){return i.apply(this,arguments)}}())))})()}connect(e){var t=this;return j(function*(){t.log("Initiating connection with %s",e);const r=fr(e),i=yield t.components.getConnectionManager().openConnection(r);for(const s of t.multicodecs)for(const o of t.components.getRegistrar().getTopologies(s))o.onConnect(r,i)})()}subscribe(e){if(this.status.code!==_i.started)throw new Error("Pubsub has not started");if(!this.subscriptions.has(e)){this.subscriptions.add(e);for(const t of this.peers.keys())this.sendSubscriptions(t,[e],!0)}this.join(e)}unsubscribe(e){if(this.status.code!==_i.started)throw new Error("Pubsub is not started");const t=this.subscriptions.delete(e);if(this.log("unsubscribe from %s - am subscribed %s",e,t),t)for(const r of this.peers.keys())this.sendSubscriptions(r,[e],!1);this.leave(e).catch(r=>{this.log(r)})}join(e){if(this.status.code!==_i.started)throw new Error("Gossipsub has not started");if(this.mesh.has(e))return;this.log("JOIN %s",e),this.metrics?.onJoin(e);const t=new Set,r=this.fanout.get(e);if(r&&(this.fanout.delete(e),this.fanoutLastpub.delete(e),r.forEach(i=>{!this.direct.has(i)&&this.score.score(i)>=0&&t.add(i)}),this.metrics?.onAddToMesh(e,_o.Fanout,t.size)),t.size!t.has(o)&&!this.direct.has(o)&&this.score.score(o)>=0).forEach(o=>{t.add(o)}),this.metrics?.onAddToMesh(e,_o.Random,t.size-i)}this.mesh.set(e,t),t.forEach(i=>{this.log("JOIN: Add mesh link to %s in %s",i,e),this.sendGraft(i,e)})}leave(e){var t=this;return j(function*(){if(t.status.code!==_i.started)throw new Error("Gossipsub has not started");t.log("LEAVE %s",e),t.metrics?.onLeave(e);const r=t.mesh.get(e);r&&(yield Promise.all(Array.from(r).map(function(){var i=j(function*(s){return t.log("LEAVE: Remove mesh link to %s in %s",s,e),yield t.sendPrune(s,e)});return function(s){return i.apply(this,arguments)}}())),t.mesh.delete(e))})()}selectPeersToForward(e,t,r){const i=new Set,s=this.topics.get(e);s&&(this.direct.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&i.add(a)}),this.floodsubPeers.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&this.score.score(a)>=this.opts.scoreThresholds.publishThreshold&&i.add(a)}));const o=this.mesh.get(e);return o&&o.size>0&&o.forEach(a=>{t!==a&&!r?.has(a)&&i.add(a)}),i}selectPeersToPublish(e){const t=new Set,r={direct:0,floodsub:0,mesh:0,fanout:0},i=this.topics.get(e);if(i)if(this.opts.floodPublish)i.forEach(s=>{this.direct.has(s)?(t.add(s),r.direct++):this.score.score(s)>=this.opts.scoreThresholds.publishThreshold&&(t.add(s),r.floodsub++)});else{this.direct.forEach(o=>{i.has(o)&&(t.add(o),r.direct++)}),this.floodsubPeers.forEach(o=>{i.has(o)&&this.score.score(o)>=this.opts.scoreThresholds.publishThreshold&&(t.add(o),r.floodsub++)});const s=this.mesh.get(e);if(s&&s.size>0)s.forEach(o=>{t.add(o),r.mesh++});else{const o=this.fanout.get(e);if(o&&o.size>0)o.forEach(a=>{t.add(a),r.fanout++});else{const a=this.getRandomGossipPeers(e,this.opts.D,u=>this.score.score(u)>=this.opts.scoreThresholds.publishThreshold);a.size>0&&(this.fanout.set(e,a),a.forEach(u=>{t.add(u),r.fanout++}))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:t,tosendCount:r}}forwardMessage(e,t,r,i){r&&this.score.deliverMessage(r,e,t.topic);const s=this.selectPeersToForward(t.topic,r,i),o=bo([t]);s.forEach(a=>{this.sendRpc(a,o)}),this.metrics?.onForwardMsg(t.topic,s.size)}publish(e,t){var r=()=>super.dispatchEvent,i=this;return j(function*(){const s=i.dataTransform?i.dataTransform.outboundTransform(e,t):t;if(null==i.publishConfig)throw Error("PublishError.Uninitialized");const{raw:o,msg:a}=yield function JK(n,e,t,r){return VE.apply(this,arguments)}(i.publishConfig,e,t,s),u=yield i.msgIdFn(a),_=i.msgIdToStrFn(u);if(i.seenCache.has(_))throw Error("PublishError.Duplicate");const{tosend:R,tosendCount:N}=i.selectPeersToPublish(e),B=!0===i.opts.emitSelf&&i.subscriptions.has(e);if(0===R.size&&!i.opts.allowPublishToZeroPeers&&!B)throw Error("PublishError.InsufficientPeers");i.seenCache.put(_),i.mcache.put({msgId:u,msgIdStr:_},o,!0),i.publishedMessageIds.put(_);const K=bo([o]);for(const Z of R)i.sendRpc(Z,K)||R.delete(Z);return i.metrics?.onPublishMsg(e,N,R.size,null!=o.data?o.data.length:0),B&&(R.add(i.components.getPeerId().toString()),r().call(i,new tn("gossipsub:message",{detail:{propagationSource:i.components.getPeerId(),msgId:_,msg:a}})),r().call(i,new tn("message",{detail:a}))),{recipients:Array.from(R.values()).map(Z=>fr(Z))}})()}reportMessageValidationResult(e,t,r){if(r===$s.Accept){const i=this.mcache.validate(e);if(this.metrics?.onReportValidationMcacheHit(null!==i),null!=i){const{message:s,originatingPeers:o}=i;this.score.deliverMessage(t.toString(),e,s.topic),this.forwardMessage(e,i.message,t.toString(),o),this.metrics?.onReportValidation(s.topic,r)}}else{const i=this.mcache.remove(e);if(this.metrics?.onReportValidationMcacheHit(null!==i),i){const s=WA(r),{message:o,originatingPeers:a}=i;this.score.rejectMessage(t.toString(),e,o.topic,s);for(const u of a)this.score.rejectMessage(u,e,o.topic,s);this.metrics?.onReportValidation(o.topic,r)}}}sendGraft(e,t){const i=bo([],{graft:[{topicID:t}]});this.sendRpc(e,i)}sendPrune(e,t){var r=this;return j(function*(){const s=bo([],{prune:[yield r.makePrune(e,t,r.opts.doPX)]});r.sendRpc(e,s)})()}sendRpc(e,t){const r=this.streamsOutbound.get(e);if(!r)return this.log(`Cannot send RPC to ${e} as there is no open stream to it available`),!1;const i=this.control.get(e);i&&(this.piggybackControl(e,t,i),this.control.delete(e));const s=this.gossip.get(e);s&&(this.piggybackGossip(e,t,s),this.gossip.delete(e));const o=ap.encode(t).finish();try{r.push(o)}catch(a){return this.log.error(`Cannot send rpc to ${e}`,a),i&&this.control.set(e,i),s&&this.gossip.set(e,s),!1}return this.metrics?.onRpcSent(t,o.length),!0}piggybackControl(e,t,r){const i=(r.graft||[]).filter(({topicID:o})=>(o&&this.mesh.get(o)||new Set).has(e)),s=(r.prune||[]).filter(({topicID:o})=>!(o&&this.mesh.get(o)||new Set).has(e));!i.length&&!s.length||(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(i),t.control.prune=t.control.prune&&t.control.prune.concat(s)):t.control={graft:i,prune:s,ihave:[],iwant:[]})}piggybackGossip(e,t,r){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=r}sendGraftPrune(e,t,r){var i=this;return j(function*(){const s=i.opts.doPX;for(const[o,a]of e){const u=a.map(B=>({topicID:B}));let _=[];const R=t.get(o);R&&(_=yield Promise.all(R.map(function(){var B=j(function*(K){return yield i.makePrune(o,K,s&&!r.get(o))});return function(K){return B.apply(this,arguments)}}())),t.delete(o));const N=bo([],{graft:u,prune:_});i.sendRpc(o,N)}for(const[o,a]of t){const u=yield Promise.all(a.map(function(){var R=j(function*(N){return yield i.makePrune(o,N,s&&!r.get(o))});return function(N){return R.apply(this,arguments)}}())),_=bo([],{prune:u});i.sendRpc(o,_)}})()}emitGossip(e){const t=this.mcache.getGossipIDs(new Set(e.keys()));for(const[r,i]of e)this.doEmitGossip(r,i,t.get(r)??[])}doEmitGossip(e,t,r){if(!r.length||(wo(r),r.length>gu&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length),!t.size))return;let i=this.opts.Dlazy;const s=.25*t.size;let o=t;s>i&&(i=s),i>o.size?i=o.size:o=wo(Array.from(o)).slice(0,i),o.forEach(a=>{let u=r;r.length>gu&&(u=wo(u.slice()).slice(0,gu)),this.pushGossip(a,{topicID:e,messageIDs:u})})}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,bo([],{ihave:t}));for(const[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,bo([],{graft:t.graft,prune:t.prune}))}pushGossip(e,t){this.log("Add gossip to %s",e);const r=this.gossip.get(e)||[];this.gossip.set(e,r.concat(t))}makePrune(e,t,r){var i=this;return j(function*(){if(i.score.prune(e,t),i.streamsOutbound.get(e).protocol===GA)return{topicID:t,peers:[]};const s=i.opts.pruneBackoff/1e3;if(!r)return{topicID:t,peers:[],backoff:s};const o=i.getRandomGossipPeers(t,i.opts.prunePeers,u=>u!==e&&i.score.score(u)>=0),a=yield Promise.all(Array.from(o).map(function(){var u=j(function*(_){const R=fr(_);return{peerID:R.toBytes(),signedPeerRecord:yield i.components.getPeerStore().addressBook.getRawEnvelope(R)}});return function(_){return u.apply(this,arguments)}}()));return{topicID:t,peers:a,backoff:s}})()}heartbeat(){var e=this;return j(function*(){const{D:t,Dlo:r,Dhi:i,Dscore:s,Dout:o,fanoutTTL:a}=e.opts;e.heartbeatTicks++;const u=new Map,_=J=>{let oe=u.get(J);return void 0===oe&&(oe=e.score.score(J),u.set(J,oe)),oe},R=new Map,N=new Map,B=new Map;e.clearBackoff(),e.peerhave.clear(),e.metrics?.cacheSize.set({cache:"iasked"},e.iasked.size),e.iasked.clear(),e.applyIwantPenalties(),e.heartbeatTicks%e.opts.directConnectTicks==0&&(yield e.directConnect()),e.fastMsgIdCache?.prune(),e.seenCache.prune(),e.gossipTracer.prune(),e.publishedMessageIds.prune();const K=new Map;e.mesh.forEach((J,oe)=>{const he=e.topics.get(oe),Ie=new Set,ue=new Set;if(K.set(oe,ue),he){const Oe=wo(Array.from(he)),bt=e.backoff.get(oe);for(const vt of Oe){const hn=e.streamsOutbound.get(vt);if(hn&&e.multicodecs.includes(hn.protocol)&&!J.has(vt)&&!e.direct.has(vt)){const Bn=_(vt);(!bt||!bt.has(vt))&&Bn>=0&&Ie.add(vt),Bn>=e.opts.scoreThresholds.gossipThreshold&&ue.add(vt)}}}const Re=(Oe,bt)=>{e.log("HEARTBEAT: Remove mesh link to %s in %s",Oe,oe),e.addBackoff(Oe,oe),J.delete(Oe),_(Oe)>=e.opts.scoreThresholds.gossipThreshold&&ue.add(Oe),e.metrics?.onRemoveFromMesh(oe,bt,1);const vt=N.get(Oe);vt?vt.push(oe):N.set(Oe,[oe])},ze=(Oe,bt)=>{e.log("HEARTBEAT: Add mesh link to %s in %s",Oe,oe),e.score.graft(Oe,oe),J.add(Oe),ue.delete(Oe),e.metrics?.onAddToMesh(oe,bt,1);const vt=R.get(Oe);vt?vt.push(oe):R.set(Oe,[oe])};if(J.forEach(Oe=>{const bt=_(Oe);bt<0&&(e.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",Oe,bt,oe),Re(Oe,Fa.BadScore),B.set(Oe,!0))}),J.size!0)}(Ie,t-J.size).forEach(vt=>{ze(vt,_o.NotEnough)}),J.size>i){let Oe=Array.from(J);Oe.sort((vt,hn)=>_(hn)-_(vt)),Oe=Oe.slice(0,s).concat(wo(Oe.slice(s)));let bt=0;if(Oe.slice(0,t).forEach(vt=>{e.outbound.get(vt)&&bt++}),bt{const cr=Oe[Bn];for(let Di=Bn;Di>0;Di--)Oe[Di]=Oe[Di-1];Oe[0]=cr};if(bt>0){let Bn=bt;for(let cr=1;cr0;cr++)e.outbound.get(Oe[cr])&&(vt(cr),Bn--)}let hn=t-bt;for(let Bn=t;Bn0;Bn++)e.outbound.get(Oe[Bn])&&(vt(Bn),hn--)}Oe.slice(t).forEach(vt=>{Re(vt,Fa.Excess)})}if(J.size>=r){let Oe=0;J.forEach(bt=>{e.outbound.get(bt)&&Oe++}),Oe!0===e.outbound.get(hn)).forEach(hn=>{ze(hn,_o.Outbound)})}if(e.heartbeatTicks%e.opts.opportunisticGraftTicks==0&&J.size>1){const Oe=Array.from(J).sort((hn,Bn)=>_(hn)-_(Bn)),bt=Math.floor(J.size/2),vt=_(Oe[bt]);if(vt_(cr)>vt);for(const cr of Bn)e.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",cr,oe),ze(cr,_o.Opportunistic)}}});const Z=Date.now();e.fanoutLastpub.forEach((J,oe)=>{J+a{const he=e.topics.get(oe);J.forEach(ze=>{(!he.has(ze)||_(ze)=e.opts.scoreThresholds.publishThreshold&&ue.push(Oe),vt>=e.opts.scoreThresholds.gossipThreshold&&Re.add(Oe)}}}J.size{J.add(Oe),Re?.delete(Oe)})}),e.emitGossip(K),yield e.sendGraftPrune(R,N,B),e.flush(),e.mcache.shift(),e.dispatchEvent(new tn("gossipsub:heartbeat"))})()}getRandomGossipPeers(e,t,r=(()=>!0)){const i=this.topics.get(e);if(!i)return new Set;let s=[];return i.forEach(o=>{const a=this.streamsOutbound.get(o);!a||this.multicodecs.includes(a.protocol)&&r(o)&&s.push(o)}),s=wo(s),t>0&&s.length>t&&(s=s.slice(0,t)),new Set(s)}onScrapeMetrics(e){e.mcacheSize.set(this.mcache.size),e.cacheSize.set({cache:"direct"},this.direct.size),e.cacheSize.set({cache:"seenCache"},this.seenCache.size),e.cacheSize.set({cache:"fastMsgIdCache"},this.fastMsgIdCache?.size??0),e.cacheSize.set({cache:"publishedMessageIds"},this.publishedMessageIds.size),e.cacheSize.set({cache:"mcache"},this.mcache.size),e.cacheSize.set({cache:"score"},this.score.size),e.cacheSize.set({cache:"gossipTracer.promises"},this.gossipTracer.size),e.cacheSize.set({cache:"gossipTracer.requests"},this.gossipTracer.requestMsByMsgSize),e.cacheSize.set({cache:"topics"},this.topics.size),e.cacheSize.set({cache:"subscriptions"},this.subscriptions.size),e.cacheSize.set({cache:"mesh"},this.mesh.size),e.cacheSize.set({cache:"fanout"},this.fanout.size),e.cacheSize.set({cache:"peers"},this.peers.size),e.cacheSize.set({cache:"streamsOutbound"},this.streamsOutbound.size),e.cacheSize.set({cache:"streamsInbound"},this.streamsInbound.size),e.cacheSize.set({cache:"acceptFromWhitelist"},this.acceptFromWhitelist.size),e.cacheSize.set({cache:"gossip"},this.gossip.size),e.cacheSize.set({cache:"control"},this.control.size),e.cacheSize.set({cache:"peerhave"},this.peerhave.size),e.cacheSize.set({cache:"outbound"},this.outbound.size);let t=0;for(const o of this.backoff.values())t+=o.size;e.cacheSize.set({cache:"backoff"},t);for(const[o,a]of this.topics)e.topicPeersCount.set({topicStr:o},a.size);for(const[o,a]of this.mesh)e.meshPeerCounts.set({topicStr:o},a.size);const r=[],i=new Map;e.behaviourPenalty.reset();for(const o of this.peers.keys()){const a=this.score.score(o);r.push(a),i.set(o,a),e.behaviourPenalty.observe(this.score.peerStats.get(o)?.behaviourPenalty??0)}e.registerScores(r,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,i);const s=function a$(n,e,t,r,i){const s={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(const o of n){const a=e.get(o);if(a){const u=o$(o,a,t,r,i);for(const[_,R]of u.byTopic){let N=s.byTopic.get(_);N||(N={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},s.byTopic.set(_,N)),N.p1w.push(R.p1w),N.p2w.push(R.p2w),N.p3w.push(R.p3w),N.p3bw.push(R.p3bw),N.p4w.push(R.p4w)}s.p5w.push(u.p5w),s.p6w.push(u.p6w),s.p7w.push(u.p7w),s.score.push(u.score)}else s.p5w.push(0),s.p6w.push(0),s.p7w.push(0),s.score.push(0)}return s}(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(s)}}YA.multicodec=LE;const jE=dr("waku:relay");class GE extends YA{constructor(e){super(e=Object.assign(e??{},{globalSignaturePolicy:up.StrictNoSign,fallbackToFloodsub:!1})),this.multicodecs=La,this.observers={},this.decryptionKeys=new Map,this.pubSubTopic=e?.pubSubTopic??"/waku/2/default-waku/proto",e?.decryptionKeys?.forEach(t=>{this.addDecryptionKey(t)})}start(){var e=()=>super.start,t=this;return j(function*(){yield e().call(t),t.subscribe(t.pubSubTopic)})()}send(e){var t=this;return j(function*(){const r=e.encode();yield t.publish(t.pubSubTopic,r)})()}addDecryptionKey(e,t){this.decryptionKeys.set(cu(e),t??{})}deleteDecryptionKey(e){this.decryptionKeys.delete(cu(e))}addObserver(e,t=[]){0===t.length?(this.observers[""]||(this.observers[""]=new Set),this.observers[""].add(e)):t.forEach(r=>{this.observers[r]||(this.observers[r]=new Set),this.observers[r].add(e)})}deleteObserver(e,t=[]){0===t.length?this.observers[""]&&this.observers[""].delete(e):t.forEach(r=>{this.observers[r]&&this.observers[r].delete(e)})}subscribe(e){this.addEventListener("gossipsub:message",t=>{if(t.detail.msg.topic===e){const r=Array.from(this.decryptionKeys).map(([i,{method:s,contentTopics:o}])=>({key:i,method:s,contentTopics:o}));jE(`Message received on ${e}`),oa.decode(t.detail.msg.data,r).then(i=>{i?(this.observers[""]&&this.observers[""].forEach(s=>{s(i)}),i.contentTopic&&this.observers[i.contentTopic]&&this.observers[i.contentTopic].forEach(s=>{s(i)})):jE("Failed to decode Waku Message")}).catch(i=>{jE("Failed to decode Waku Message",i)})}}),super.subscribe(e)}getMeshPeers(e){return super.getMeshPeers(e??this.pubSubTopic)}}function WE(){return WE=j(function*(n){const e=n?.libp2p??{},t=e.peerDiscovery??[];n?.defaultBootstrap&&(t.push(fp()),Object.assign(e,{peerDiscovery:t}));const r=yield dp(new GE(n),e);return new tK(n??{},r)}),WE.apply(this,arguments)}function fp(){return new hH(function gH(n=au.Prod,e=1){if(e<=0)return[];let t;switch(n){case au.Prod:t=dE_fleets["wakuv2.prod"]["waku-websocket"];break;case au.Test:t=dE_fleets["wakuv2.test"]["waku-websocket"];break;default:t=dE_fleets["wakuv2.prod"]["waku-websocket"]}return t=Object.values(t),t=t.map(r=>new yn(r)),TA(t,e)}())}function dp(n,e){return QE.apply(this,arguments)}function QE(){return QE=j(function*(n,e){return lH(Object.assign({transports:[new SV({filter:sT})],streamMuxers:[new hU],connectionEncryption:[new z5]},n?{pubsub:n}:{},e??{}))}),QE.apply(this,arguments)}GE.multicodec=La[0],GE.multicodec=La[La.length-1];function h$(n,e,t){"function"==typeof t&&(t={filter:t});const r=function d$(n,e,t){let r;const i=new Promise((s,o)=>{if(!((t={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...t}).count>=0)||t.count!==Number.POSITIVE_INFINITY&&!Number.isInteger(t.count))throw new TypeError("The `count` option should be at least 0 or more");const a=[e].flat(),u=[],{addListener:_,removeListener:R}=(n=>{const e=n.on||n.addListener||n.addEventListener,t=n.off||n.removeListener||n.removeEventListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(n),removeListener:t.bind(n)}})(n),N=(...K)=>{const Z=t.multiArgs?K:K[0];t.filter&&!t.filter(Z)||(u.push(Z),t.count===u.length&&(r(),s(u)))},B=K=>{r(),o(K)};r=()=>{for(const K of a)R(K,N);for(const K of t.rejectionEvents)R(K,B)};for(const K of a)_(K,N);for(const K of t.rejectionEvents)_(K,B);t.resolveImmediately&&s(u)});if(i.cancel=r,"number"==typeof t.timeout){const s=tA(i,t.timeout);return s.cancel=r,s}return i}(n,e,t={...t,count:1,resolveImmediately:!1}),i=r.then(s=>s[0]);return i.cancel=r.cancel,i}const ZA=dr("waku:wait-for-remote-peer");function ZE(){return ZE=j(function*(n,e,t){if(e=e??v$(n),!n.isStarted())return Promise.reject("Waku node is not started");const r=[];if(e.includes(Jr.Relay)){if(!n.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");r.push(g$(n.relay))}if(e.includes(Jr.Store)){if(!n.store)throw new Error("Cannot wait for Store peer: protocol not mounted");r.push(XE(n.store,Object.values(sf)))}if(e.includes(Jr.LightPush)){if(!n.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");r.push(XE(n.lightPush,[nf]))}if(e.includes(Jr.Filter)){if(!n.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");r.push(XE(n.filter,[ka]))}t?yield m$(Promise.all(r),t,"Timed out waiting for a remote peer."):yield Promise.all(r)}),ZE.apply(this,arguments)}function XE(n,e){return JE.apply(this,arguments)}function JE(){return JE=j(function*(n,e){const t=yield n.peers();t.length?ZA(`${e} peer found: `,t[0].id.toString()):yield new Promise(r=>{const i=s=>{for(const o of e)if(s.detail.protocols.includes(o)){ZA("Resolving for",o,s.detail.protocols),n.libp2p.peerStore.removeEventListener("change:protocols",i),r();break}};n.libp2p.peerStore.addEventListener("change:protocols",i)})}),JE.apply(this,arguments)}function g$(n){return eb.apply(this,arguments)}function eb(){return eb=j(function*(n){let e=n.getMeshPeers();for(;0==e.length;)yield h$(n,"gossipsub:heartbeat"),e=n.getMeshPeers()}),eb.apply(this,arguments)}const y$=(n,e)=>new Promise((t,r)=>setTimeout(()=>r(e),n));function m$(n,e,t){return tb.apply(this,arguments)}function tb(){return tb=j(function*(n,e,t){yield Promise.race([n,y$(e,t)])}),tb.apply(this,arguments)}function v$(n){const e=[];return n.relay&&e.push(Jr.Relay),n.filter&&e.push(Jr.Filter),n.store&&e.push(Jr.Store),n.lightPush&&e.push(Jr.LightPush),e}let XA=(()=>{class n{constructor(){this.wakuSubject=new gr,this.waku=this.wakuSubject.asObservable(),this.wakuStatusSubject=new cB(""),this.wakuStatus=this.wakuStatusSubject.asObservable()}init(){(function f$(n){return WE.apply(this,arguments)})({defaultBootstrap:!0}).then(t=>{t.start().then(()=>{this.wakuSubject.next(t),this.wakuStatusSubject.next("Connecting..."),function p$(n,e,t){return ZE.apply(this,arguments)}(t).then(()=>{this.wakuStatusSubject.next("Connected")})})})}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function b$(n,e){if(1&n&&(eo(0,"li")(1,"span"),Ic(2),to()()),2&n){const t=e.$implicit;zu(2),py("",t.timestamp," ",t.text,"")}}dr("waku:enr");const sb=new(C0().Type)("ChatMessage").add(new(C0().Field)("timestamp",1,"uint32")).add(new(C0().Field)("text",2,"string"));let w$=(()=>{class n{constructor(t){this.wakuService=t,this.contentTopic="/relay-angular-chat/1/chat/proto",this.messages=[],this.messageCount=0,this.processIncomingMessages=r=>{if(!r.payload)return;const{text:i,timestamp:s}=sb.decode(r.payload),o=new Date;o.setTime(Number(s)),this.messages.push({text:i,timestamp:o})}}ngOnInit(){this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t}),this.wakuService.waku.subscribe(t=>{this.waku=t,this.waku.relay.addObserver(this.processIncomingMessages,[this.contentTopic])}),window.onbeforeunload=()=>this.ngOnDestroy()}ngOnDestroy(){this.waku.relay.deleteObserver(this.processIncomingMessages,[this.contentTopic])}sendMessage(){const t=(new Date).getTime(),r=sb.create({timestamp:t,text:`Here is a message #${this.messageCount}`}),i=sb.encode(r).finish();oa.fromBytes(i,this.contentTopic).then(s=>{this.waku.relay.send(s).then(()=>{console.log(`Message #${this.messageCount} sent`),this.messageCount+=1})})}}return n.\u0275fac=function(t){return new(t||n)(Zt(XA))},n.\u0275cmp=df({type:n,selectors:[["app-messages"]],decls:6,vars:2,consts:[[3,"disabled","click"],[1,"messages"],[4,"ngFor","ngForOf"]],template:function(t,r){1&t&&(eo(0,"button",0),ly("click",function(){return r.sendMessage()}),Ic(1,"Send Message"),to(),eo(2,"h2"),Ic(3,"Messages"),to(),eo(4,"ul",1),function y1(n,e,t,r,i,s,o,a){const u=Ue(),_=fn(),R=n+22,N=_.firstCreatePass?function WM(n,e,t,r,i,s,o,a,u){const _=e.consts,R=pc(e,n,4,o||null,Ao(_,a));Qg(e,t,R,Ao(_,u)),wf(e,R);const N=R.tViews=Yg(2,R,r,i,s,e.directiveRegistry,e.pipeRegistry,null,e.schemas,_);return null!==e.queries&&(e.queries.template(e,R),N.queries=e.queries.embeddedTView(R)),R}(R,_,u,e,t,r,i,s,o):_.data[R];Ts(N,!1);const B=u[11].createComment("");jf(_,u,B,N),jr(B,u),Xf(u,u[R]=X_(B,u,B,N)),mf(N)&&Wg(_,u,N),null!=o&&qg(u,N,a)}(5,b$,3,2,"li",2),to()),2&t&&(id("disabled","Connected"!==r.wakuStatus),zu(5),id("ngForOf",r.messages))},dependencies:[fC]}),n})(),_$=(()=>{class n{constructor(t){this.wakuService=t,this.title="relay-angular-chat"}ngOnInit(){this.wakuService.init(),this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t})}}return n.\u0275fac=function(t){return new(t||n)(Zt(XA))},n.\u0275cmp=df({type:n,selectors:[["app-root"]],decls:5,vars:2,template:function(t,r){1&t&&(eo(0,"h1"),Ic(1),to(),eo(2,"p"),Ic(3),to(),oy(4,"app-messages")),2&t&&(zu(1),hy(r.title),zu(2),od("Waku node's status: ",r.wakuStatus,""))},dependencies:[w$],styles:["h1[_ngcontent-%COMP%]{color:#369;font-family:Arial,Helvetica,sans-serif;font-size:250%}h2[_ngcontent-%COMP%], h3[_ngcontent-%COMP%]{color:#444;font-family:Arial,Helvetica,sans-serif;font-weight:lighter}body[_ngcontent-%COMP%]{margin:2em}body[_ngcontent-%COMP%], input[type=text][_ngcontent-%COMP%], button[_ngcontent-%COMP%]{color:#333;font-family:Cambria,Georgia,serif}*[_ngcontent-%COMP%]{font-family:Arial,Helvetica,sans-serif}"]}),n})(),D$=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=wu({type:n,bootstrap:[_$]}),n.\u0275inj=Ka({imports:[X4]}),n})();x(8583),function _L(){$S=!1}(),Z4().bootstrapModule(D$).catch(n=>console.error(n))},1280:Y=>{"use strict";Y.exports=function U(x,y){for(var l=new Array(arguments.length-1),g=0,w=2,m=!0;w{"use strict";var x=U;x.length=function(h){var c=h.length;if(!c)return 0;for(var f=0;--c%4>1&&"="===h.charAt(c);)++f;return Math.ceil(3*h.length)/4-f};for(var y=new Array(64),l=new Array(123),g=0;g<64;)l[y[g]=g<26?g+65:g<52?g+71:g<62?g-4:g-59|43]=g++;x.encode=function(h,c,f){for(var v,d=null,b=[],S=0,E=0;c>2],v=(3&p)<<4,E=1;break;case 1:b[S++]=y[v|p>>4],v=(15&p)<<2,E=2;break;case 2:b[S++]=y[v|p>>6],b[S++]=y[63&p],E=0}S>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,b)),S=0)}return E&&(b[S++]=y[v],b[S++]=61,1===E&&(b[S++]=61)),d?(S&&d.push(String.fromCharCode.apply(String,b.slice(0,S))),d.join("")):String.fromCharCode.apply(String,b.slice(0,S))};var w="invalid encoding";x.decode=function(h,c,f){for(var S,d=f,b=0,E=0;E1)break;if(void 0===(v=l[v]))throw Error(w);switch(b){case 0:S=v,b=1;break;case 1:c[f++]=S<<2|(48&v)>>4,S=v,b=2;break;case 2:c[f++]=(15&S)<<4|(60&v)>>2,S=v,b=3;break;case 3:c[f++]=(3&S)<<6|v,b=0}}if(1===b)throw Error(w);return f-d},x.test=function(h){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(h)}},9749:Y=>{"use strict";function U(x,y){"string"==typeof x&&(y=x,x=void 0);var l=[];function g(m){if("string"!=typeof m){var h=w();if(U.verbose&&console.log("codegen: "+h),h="return "+h,m){for(var c=Object.keys(m),f=new Array(c.length+1),d=new Array(c.length),b=0;b{"use strict";function U(){this._listeners={}}Y.exports=U,U.prototype.on=function(y,l,g){return(this._listeners[y]||(this._listeners[y]=[])).push({fn:l,ctx:g||this}),this},U.prototype.off=function(y,l){if(void 0===y)this._listeners={};else if(void 0===l)this._listeners[y]=[];else for(var g=this._listeners[y],w=0;w{"use strict";Y.exports=w;var y=x(1280),g=x(716)("fs");function w(m,h,c){return"function"==typeof h?(c=h,h={}):h||(h={}),c?!h.xhr&&g&&g.readFile?g.readFile(m,function(d,b){return d&&typeof XMLHttpRequest<"u"?w.xhr(m,h,c):d?c(d):c(null,h.binary?b:b.toString("utf8"))}):w.xhr(m,h,c):y(w,this,m,h)}w.xhr=function(h,c,f){var d=new XMLHttpRequest;d.onreadystatechange=function(){if(4===d.readyState){if(0!==d.status&&200!==d.status)return f(Error("status "+d.status));if(c.binary){var S=d.response;if(!S){S=[];for(var E=0;E{"use strict";function U(w){return typeof Float32Array<"u"?function(){var m=new Float32Array([-0]),h=new Uint8Array(m.buffer),c=128===h[3];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3]}function d(E,v,p){m[0]=E,v[p]=h[3],v[p+1]=h[2],v[p+2]=h[1],v[p+3]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],m[0]}function S(E,v){return h[3]=E[v],h[2]=E[v+1],h[1]=E[v+2],h[0]=E[v+3],m[0]}w.writeFloatLE=c?f:d,w.writeFloatBE=c?d:f,w.readFloatLE=c?b:S,w.readFloatBE=c?S:b}():function(){function m(c,f,d,b){var S=f<0?1:0;if(S&&(f=-f),0===f)c(1/f>0?0:2147483648,d,b);else if(isNaN(f))c(2143289344,d,b);else if(f>34028234663852886e22)c((S<<31|2139095040)>>>0,d,b);else if(f<11754943508222875e-54)c((S<<31|Math.round(f/1401298464324817e-60))>>>0,d,b);else{var E=Math.floor(Math.log(f)/Math.LN2);c((S<<31|E+127<<23|8388607&Math.round(f*Math.pow(2,-E)*8388608))>>>0,d,b)}}function h(c,f,d){var b=c(f,d),S=2*(b>>31)+1,E=b>>>23&255,v=8388607&b;return 255===E?v?NaN:S*(1/0):0===E?1401298464324817e-60*S*v:S*Math.pow(2,E-150)*(v+8388608)}w.writeFloatLE=m.bind(null,x),w.writeFloatBE=m.bind(null,y),w.readFloatLE=h.bind(null,l),w.readFloatBE=h.bind(null,g)}(),typeof Float64Array<"u"?function(){var m=new Float64Array([-0]),h=new Uint8Array(m.buffer),c=128===h[7];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3],v[p+4]=h[4],v[p+5]=h[5],v[p+6]=h[6],v[p+7]=h[7]}function d(E,v,p){m[0]=E,v[p]=h[7],v[p+1]=h[6],v[p+2]=h[5],v[p+3]=h[4],v[p+4]=h[3],v[p+5]=h[2],v[p+6]=h[1],v[p+7]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],h[4]=E[v+4],h[5]=E[v+5],h[6]=E[v+6],h[7]=E[v+7],m[0]}function S(E,v){return h[7]=E[v],h[6]=E[v+1],h[5]=E[v+2],h[4]=E[v+3],h[3]=E[v+4],h[2]=E[v+5],h[1]=E[v+6],h[0]=E[v+7],m[0]}w.writeDoubleLE=c?f:d,w.writeDoubleBE=c?d:f,w.readDoubleLE=c?b:S,w.readDoubleBE=c?S:b}():function(){function m(c,f,d,b,S,E){var v=b<0?1:0;if(v&&(b=-b),0===b)c(0,S,E+f),c(1/b>0?0:2147483648,S,E+d);else if(isNaN(b))c(0,S,E+f),c(2146959360,S,E+d);else if(b>17976931348623157e292)c(0,S,E+f),c((v<<31|2146435072)>>>0,S,E+d);else{var p;if(b<22250738585072014e-324)c((p=b/5e-324)>>>0,S,E+f),c((v<<31|p/4294967296)>>>0,S,E+d);else{var I=Math.floor(Math.log(b)/Math.LN2);1024===I&&(I=1023),c(4503599627370496*(p=b*Math.pow(2,-I))>>>0,S,E+f),c((v<<31|I+1023<<20|1048576*p&1048575)>>>0,S,E+d)}}}function h(c,f,d,b,S){var E=c(b,S+f),v=c(b,S+d),p=2*(v>>31)+1,I=v>>>20&2047,A=4294967296*(1048575&v)+E;return 2047===I?A?NaN:p*(1/0):0===I?5e-324*p*A:p*Math.pow(2,I-1075)*(A+4503599627370496)}w.writeDoubleLE=m.bind(null,x,0,4),w.writeDoubleBE=m.bind(null,y,4,0),w.readDoubleLE=h.bind(null,l,0,4),w.readDoubleBE=h.bind(null,g,4,0)}(),w}function x(w,m,h){m[h]=255&w,m[h+1]=w>>>8&255,m[h+2]=w>>>16&255,m[h+3]=w>>>24}function y(w,m,h){m[h]=w>>>24,m[h+1]=w>>>16&255,m[h+2]=w>>>8&255,m[h+3]=255&w}function l(w,m){return(w[m]|w[m+1]<<8|w[m+2]<<16|w[m+3]<<24)>>>0}function g(w,m){return(w[m]<<24|w[m+1]<<16|w[m+2]<<8|w[m+3])>>>0}Y.exports=U(U)},716:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(Y){}return null}module.exports=inquire},1311:(Y,U)=>{"use strict";var x=U,y=x.isAbsolute=function(w){return/^(?:\/|\w+:)/.test(w)},l=x.normalize=function(w){var m=(w=w.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),h=y(w),c="";h&&(c=m.shift()+"/");for(var f=0;f0&&".."!==m[f-1]?m.splice(--f,2):h?m.splice(f,1):++f:"."===m[f]?m.splice(f,1):++f;return c+m.join("/")};x.resolve=function(w,m,h){return h||(m=l(m)),y(m)?m:(h||(w=l(w)),(w=w.replace(/(?:\/|^)[^/]+$/,"")).length?l(w+"/"+m):m)}},4479:Y=>{"use strict";Y.exports=function U(x,y,l){var g=l||8192,w=g>>>1,m=null,h=g;return function(f){if(f<1||f>w)return x(f);h+f>g&&(m=x(g),h=0);var d=y.call(m,h,h+=f);return 7&h&&(h=1+(7|h)),d}}},7768:(Y,U)=>{"use strict";var x=U;x.length=function(l){for(var g=0,w=0,m=0;m191&&d<224?c[f++]=(31&d)<<6|63&l[g++]:d>239&&d<365?(d=((7&d)<<18|(63&l[g++])<<12|(63&l[g++])<<6|63&l[g++])-65536,c[f++]=55296+(d>>10),c[f++]=56320+(1023&d)):c[f++]=(15&d)<<12|(63&l[g++])<<6|63&l[g++],f>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,c)),f=0);return h?(f&&h.push(String.fromCharCode.apply(String,c.slice(0,f))),h.join("")):String.fromCharCode.apply(String,c.slice(0,f))},x.write=function(l,g,w){for(var h,c,m=w,f=0;f>6|192,g[w++]=63&h|128):55296==(64512&h)&&56320==(64512&(c=l.charCodeAt(f+1)))?(++f,g[w++]=(h=65536+((1023&h)<<10)+(1023&c))>>18|240,g[w++]=h>>12&63|128,g[w++]=h>>6&63|128,g[w++]=63&h|128):(g[w++]=h>>12|224,g[w++]=h>>6&63|128,g[w++]=63&h|128);return w-m}},4502:(Y,U,x)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(8046);function h(X,q,ne){return void 0===q&&(q=new Uint8Array(2)),void 0===ne&&(ne=0),q[ne+0]=X>>>8,q[ne+1]=X>>>0,q}function c(X,q,ne){return void 0===q&&(q=new Uint8Array(2)),void 0===ne&&(ne=0),q[ne+0]=X>>>0,q[ne+1]=X>>>8,q}function f(X,q){return void 0===q&&(q=0),X[q]<<24|X[q+1]<<16|X[q+2]<<8|X[q+3]}function d(X,q){return void 0===q&&(q=0),(X[q]<<24|X[q+1]<<16|X[q+2]<<8|X[q+3])>>>0}function b(X,q){return void 0===q&&(q=0),X[q+3]<<24|X[q+2]<<16|X[q+1]<<8|X[q]}function S(X,q){return void 0===q&&(q=0),(X[q+3]<<24|X[q+2]<<16|X[q+1]<<8|X[q])>>>0}function E(X,q,ne){return void 0===q&&(q=new Uint8Array(4)),void 0===ne&&(ne=0),q[ne+0]=X>>>24,q[ne+1]=X>>>16,q[ne+2]=X>>>8,q[ne+3]=X>>>0,q}function v(X,q,ne){return void 0===q&&(q=new Uint8Array(4)),void 0===ne&&(ne=0),q[ne+0]=X>>>0,q[ne+1]=X>>>8,q[ne+2]=X>>>16,q[ne+3]=X>>>24,q}function D(X,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),E(X/4294967296>>>0,q,ne),E(X>>>0,q,ne+4),q}function T(X,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),v(X>>>0,q,ne),v(X/4294967296>>>0,q,ne+4),q}U.readInt16BE=function l(X,q){return void 0===q&&(q=0),(X[q+0]<<8|X[q+1])<<16>>16},U.readUint16BE=function g(X,q){return void 0===q&&(q=0),(X[q+0]<<8|X[q+1])>>>0},U.readInt16LE=function w(X,q){return void 0===q&&(q=0),(X[q+1]<<8|X[q])<<16>>16},U.readUint16LE=function m(X,q){return void 0===q&&(q=0),(X[q+1]<<8|X[q])>>>0},U.writeUint16BE=h,U.writeInt16BE=h,U.writeUint16LE=c,U.writeInt16LE=c,U.readInt32BE=f,U.readUint32BE=d,U.readInt32LE=b,U.readUint32LE=S,U.writeUint32BE=E,U.writeInt32BE=E,U.writeUint32LE=v,U.writeInt32LE=v,U.readInt64BE=function p(X,q){void 0===q&&(q=0);var ne=f(X,q),se=f(X,q+4);return 4294967296*ne+se-4294967296*(se>>31)},U.readUint64BE=function I(X,q){return void 0===q&&(q=0),4294967296*d(X,q)+d(X,q+4)},U.readInt64LE=function A(X,q){void 0===q&&(q=0);var ne=b(X,q);return 4294967296*b(X,q+4)+ne-4294967296*(ne>>31)},U.readUint64LE=function P(X,q){void 0===q&&(q=0);var ne=S(X,q);return 4294967296*S(X,q+4)+ne},U.writeUint64BE=D,U.writeInt64BE=D,U.writeUint64LE=T,U.writeInt64LE=T,U.readUintBE=function M(X,q,ne){if(void 0===ne&&(ne=0),X%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(X/8>q.length-ne)throw new Error("readUintBE: array is too short for the given bitLength");for(var se=0,de=1,pe=X/8+ne-1;pe>=ne;pe--)se+=q[pe]*de,de*=256;return se},U.readUintLE=function k(X,q,ne){if(void 0===ne&&(ne=0),X%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(X/8>q.length-ne)throw new Error("readUintLE: array is too short for the given bitLength");for(var se=0,de=1,pe=ne;pe=se;pe--)ne[pe]=q/de&255,de*=256;return ne},U.writeUintLE=function G(X,q,ne,se){if(void 0===ne&&(ne=new Uint8Array(X/8)),void 0===se&&(se=0),X%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!y.isSafeInteger(q))throw new Error("writeUintLE value must be an integer");for(var de=1,pe=se;pe{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(4502),l=x(9815);function w(f,d,b){for(var S=1634760805,E=857760878,v=2036477234,p=1797285236,I=b[3]<<24|b[2]<<16|b[1]<<8|b[0],A=b[7]<<24|b[6]<<16|b[5]<<8|b[4],P=b[11]<<24|b[10]<<16|b[9]<<8|b[8],D=b[15]<<24|b[14]<<16|b[13]<<8|b[12],T=b[19]<<24|b[18]<<16|b[17]<<8|b[16],M=b[23]<<24|b[22]<<16|b[21]<<8|b[20],k=b[27]<<24|b[26]<<16|b[25]<<8|b[24],F=b[31]<<24|b[30]<<16|b[29]<<8|b[28],G=d[3]<<24|d[2]<<16|d[1]<<8|d[0],C=d[7]<<24|d[6]<<16|d[5]<<8|d[4],O=d[11]<<24|d[10]<<16|d[9]<<8|d[8],V=d[15]<<24|d[14]<<16|d[13]<<8|d[12],L=S,$=E,re=v,z=p,te=I,X=A,q=P,ne=D,se=T,de=M,pe=k,Le=F,Se=G,Pe=C,be=O,$e=V,H=0;H<20;H+=2)te=(te^=se=se+(Se=(Se^=L=L+te|0)>>>16|Se<<16)|0)>>>20|te<<12,X=(X^=de=de+(Pe=(Pe^=$=$+X|0)>>>16|Pe<<16)|0)>>>20|X<<12,q=(q^=pe=pe+(be=(be^=re=re+q|0)>>>16|be<<16)|0)>>>20|q<<12,ne=(ne^=Le=Le+($e=($e^=z=z+ne|0)>>>16|$e<<16)|0)>>>20|ne<<12,q=(q^=pe=pe+(be=(be^=re=re+q|0)>>>24|be<<8)|0)>>>25|q<<7,ne=(ne^=Le=Le+($e=($e^=z=z+ne|0)>>>24|$e<<8)|0)>>>25|ne<<7,X=(X^=de=de+(Pe=(Pe^=$=$+X|0)>>>24|Pe<<8)|0)>>>25|X<<7,te=(te^=se=se+(Se=(Se^=L=L+te|0)>>>24|Se<<8)|0)>>>25|te<<7,X=(X^=pe=pe+($e=($e^=L=L+X|0)>>>16|$e<<16)|0)>>>20|X<<12,q=(q^=Le=Le+(Se=(Se^=$=$+q|0)>>>16|Se<<16)|0)>>>20|q<<12,ne=(ne^=se=se+(Pe=(Pe^=re=re+ne|0)>>>16|Pe<<16)|0)>>>20|ne<<12,te=(te^=de=de+(be=(be^=z=z+te|0)>>>16|be<<16)|0)>>>20|te<<12,ne=(ne^=se=se+(Pe=(Pe^=re=re+ne|0)>>>24|Pe<<8)|0)>>>25|ne<<7,te=(te^=de=de+(be=(be^=z=z+te|0)>>>24|be<<8)|0)>>>25|te<<7,q=(q^=Le=Le+(Se=(Se^=$=$+q|0)>>>24|Se<<8)|0)>>>25|q<<7,X=(X^=pe=pe+($e=($e^=L=L+X|0)>>>24|$e<<8)|0)>>>25|X<<7;y.writeUint32LE(L+S|0,f,0),y.writeUint32LE($+E|0,f,4),y.writeUint32LE(re+v|0,f,8),y.writeUint32LE(z+p|0,f,12),y.writeUint32LE(te+I|0,f,16),y.writeUint32LE(X+A|0,f,20),y.writeUint32LE(q+P|0,f,24),y.writeUint32LE(ne+D|0,f,28),y.writeUint32LE(se+T|0,f,32),y.writeUint32LE(de+M|0,f,36),y.writeUint32LE(pe+k|0,f,40),y.writeUint32LE(Le+F|0,f,44),y.writeUint32LE(Se+G|0,f,48),y.writeUint32LE(Pe+C|0,f,52),y.writeUint32LE(be+O|0,f,56),y.writeUint32LE($e+V|0,f,60)}function m(f,d,b,S,E){if(void 0===E&&(E=0),32!==f.length)throw new Error("ChaCha: key size must be 32 bytes");if(S.length>>=8,d++;if(S>0)throw new Error("ChaCha: counter overflow")}U.streamXOR=m,U.stream=function h(f,d,b,S){return void 0===S&&(S=0),l.wipe(b),m(f,d,b,b,S)}},5876:(Y,U,x)=>{"use strict";var l=x(4484),g=x(314),w=x(9815),m=x(4502),h=x(9976);U.Cv=32,U.WH=12,U.pg=16;var c=new Uint8Array(16),f=function(){function d(b){if(this.nonceLength=U.WH,this.tagLength=U.pg,b.length!==U.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(b)}return d.prototype.seal=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var p=new Uint8Array(16);p.set(b,p.length-b.length);var I=new Uint8Array(32);l.stream(this._key,p,I,4);var P,A=S.length+this.tagLength;if(v){if(v.length!==A)throw new Error("ChaCha20Poly1305: incorrect destination length");P=v}else P=new Uint8Array(A);return l.streamXOR(this._key,p,S,P,4),this._authenticate(P.subarray(P.length-this.tagLength,P.length),I,P.subarray(0,P.length-this.tagLength),E),w.wipe(p),P},d.prototype.open=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(S.length0&&p.update(c.subarray(v.length%16))),p.update(E),E.length%16>0&&p.update(c.subarray(E.length%16));var I=new Uint8Array(8);v&&m.writeUint64LE(v.length,I),p.update(I),m.writeUint64LE(E.length,I),p.update(I);for(var A=p.digest(),P=0;P{"use strict";function l(w,m){if(w.length!==m.length)return 0;for(var h=0,c=0;c>>8}Object.defineProperty(U,"__esModule",{value:!0}),U.select=function x(w,m,h){return~(w-1)&m|w-1&h},U.lessOrEqual=function y(w,m){return(0|w)-(0|m)-1>>>31&1},U.compare=l,U.equal=function g(w,m){return 0!==w.length&&0!==m.length&&0!==l(w,m)}},5571:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.isSerializableHash=function x(y){return typeof y.saveState<"u"&&typeof y.restoreState<"u"&&typeof y.cleanSavedState<"u"}},5705:(Y,U,x)=>{"use strict";var l=x(4193),g=x(9815),w=function(){function m(h,c,f,d){void 0===f&&(f=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=h,this._info=d;var b=l.hmac(this._hash,f,c);this._hmac=new l.HMAC(h,b),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return m.prototype._fillBuffer=function(){this._counter[0]++;var h=this._counter[0];if(0===h)throw new Error("hkdf: cannot expand more");this._hmac.reset(),h>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},m.prototype.expand=function(h){for(var c=new Uint8Array(h),f=0;f{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(5571),l=x(9976),g=x(9815),w=function(){function h(c,f){this._finished=!1,this._inner=new c,this._outer=new c,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var d=new Uint8Array(this.blockSize);f.length>this.blockSize?this._inner.update(f).finish(d).clean():d.set(f);for(var b=0;b{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.mul=Math.imul||function x(h,c){var d=65535&h,S=65535&c;return d*S+((h>>>16&65535)*S+d*(c>>>16&65535)<<16>>>0)|0},U.add=function y(h,c){return h+c|0},U.sub=function l(h,c){return h-c|0},U.rotl=function g(h,c){return h<>>32-c},U.rotr=function w(h,c){return h<<32-c|h>>>c},U.isInteger=Number.isInteger||function m(h){return"number"==typeof h&&isFinite(h)&&Math.floor(h)===h},U.MAX_SAFE_INTEGER=9007199254740991,U.isSafeInteger=function(h){return U.isInteger(h)&&h>=-U.MAX_SAFE_INTEGER&&h<=U.MAX_SAFE_INTEGER}},314:(Y,U,x)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(9976),l=x(9815);U.DIGEST_LENGTH=16;var g=function(){function h(c){this.digestLength=U.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var f=c[0]|c[1]<<8;this._r[0]=8191&f;var d=c[2]|c[3]<<8;this._r[1]=8191&(f>>>13|d<<3);var b=c[4]|c[5]<<8;this._r[2]=7939&(d>>>10|b<<6);var S=c[6]|c[7]<<8;this._r[3]=8191&(b>>>7|S<<9);var E=c[8]|c[9]<<8;this._r[4]=255&(S>>>4|E<<12),this._r[5]=E>>>1&8190;var v=c[10]|c[11]<<8;this._r[6]=8191&(E>>>14|v<<2);var p=c[12]|c[13]<<8;this._r[7]=8065&(v>>>11|p<<5);var I=c[14]|c[15]<<8;this._r[8]=8191&(p>>>8|I<<8),this._r[9]=I>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return h.prototype._blocks=function(c,f,d){for(var b=this._fin?0:2048,S=this._h[0],E=this._h[1],v=this._h[2],p=this._h[3],I=this._h[4],A=this._h[5],P=this._h[6],D=this._h[7],T=this._h[8],M=this._h[9],k=this._r[0],F=this._r[1],G=this._r[2],C=this._r[3],O=this._r[4],V=this._r[5],L=this._r[6],$=this._r[7],re=this._r[8],z=this._r[9];d>=16;){var te=c[f+0]|c[f+1]<<8,X=c[f+2]|c[f+3]<<8,q=c[f+4]|c[f+5]<<8,ne=c[f+6]|c[f+7]<<8,se=c[f+8]|c[f+9]<<8,de=c[f+10]|c[f+11]<<8,pe=c[f+12]|c[f+13]<<8,Le=c[f+14]|c[f+15]<<8,Se=0,Pe=Se;Pe+=(S+=8191&te)*k,Pe+=(E+=8191&(te>>>13|X<<3))*(5*z),Pe+=(v+=8191&(X>>>10|q<<6))*(5*re),Pe+=(p+=8191&(q>>>7|ne<<9))*(5*$),Se=(Pe+=(I+=8191&(ne>>>4|se<<12))*(5*L))>>>13,Pe&=8191,Pe+=(A+=se>>>1&8191)*(5*V),Pe+=(P+=8191&(se>>>14|de<<2))*(5*O),Pe+=(D+=8191&(de>>>11|pe<<5))*(5*C),Pe+=(T+=8191&(pe>>>8|Le<<8))*(5*G);var be=Se+=(Pe+=(M+=Le>>>5|b)*(5*F))>>>13;be+=S*F,be+=E*k,be+=v*(5*z),be+=p*(5*re),Se=(be+=I*(5*$))>>>13,be&=8191,be+=A*(5*L),be+=P*(5*V),be+=D*(5*O),be+=T*(5*C),Se+=(be+=M*(5*G))>>>13,be&=8191;var $e=Se;$e+=S*G,$e+=E*F,$e+=v*k,$e+=p*(5*z),Se=($e+=I*(5*re))>>>13,$e&=8191,$e+=A*(5*$),$e+=P*(5*L),$e+=D*(5*V),$e+=T*(5*O);var H=Se+=($e+=M*(5*C))>>>13;H+=S*C,H+=E*G,H+=v*F,H+=p*k,Se=(H+=I*(5*z))>>>13,H&=8191,H+=A*(5*re),H+=P*(5*$),H+=D*(5*L),H+=T*(5*V);var Ee=Se+=(H+=M*(5*O))>>>13;Ee+=S*O,Ee+=E*C,Ee+=v*G,Ee+=p*F,Se=(Ee+=I*k)>>>13,Ee&=8191,Ee+=A*(5*z),Ee+=P*(5*re),Ee+=D*(5*$),Ee+=T*(5*L);var Te=Se+=(Ee+=M*(5*V))>>>13;Te+=S*V,Te+=E*O,Te+=v*C,Te+=p*G,Se=(Te+=I*F)>>>13,Te&=8191,Te+=A*k,Te+=P*(5*z),Te+=D*(5*re),Te+=T*(5*$);var xe=Se+=(Te+=M*(5*L))>>>13;xe+=S*L,xe+=E*V,xe+=v*O,xe+=p*C,Se=(xe+=I*G)>>>13,xe&=8191,xe+=A*F,xe+=P*k,xe+=D*(5*z),xe+=T*(5*re);var He=Se+=(xe+=M*(5*$))>>>13;He+=S*$,He+=E*L,He+=v*V,He+=p*O,Se=(He+=I*C)>>>13,He&=8191,He+=A*G,He+=P*F,He+=D*k,He+=T*(5*z);var We=Se+=(He+=M*(5*re))>>>13;We+=S*re,We+=E*$,We+=v*L,We+=p*V,Se=(We+=I*O)>>>13,We&=8191,We+=A*C,We+=P*G,We+=D*F,We+=T*k;var Je=Se+=(We+=M*(5*z))>>>13;Je+=S*z,Je+=E*re,Je+=v*$,Je+=p*L,Se=(Je+=I*V)>>>13,Je&=8191,Je+=A*O,Je+=P*C,Je+=D*G,Je+=T*F,S=Pe=8191&(Se=(Se=((Se+=(Je+=M*k)>>>13)<<2)+Se|0)+(Pe&=8191)|0),E=be+=Se>>>=13,v=$e&=8191,p=H&=8191,I=Ee&=8191,A=Te&=8191,P=xe&=8191,D=He&=8191,T=We&=8191,M=Je&=8191,f+=16,d-=16}this._h[0]=S,this._h[1]=E,this._h[2]=v,this._h[3]=p,this._h[4]=I,this._h[5]=A,this._h[6]=P,this._h[7]=D,this._h[8]=T,this._h[9]=M},h.prototype.finish=function(c,f){void 0===f&&(f=0);var b,S,E,v,d=new Uint16Array(10);if(this._leftover){for(v=this._leftover,this._buffer[v++]=1;v<16;v++)this._buffer[v]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(b=this._h[1]>>>13,this._h[1]&=8191,v=2;v<10;v++)this._h[v]+=b,b=this._h[v]>>>13,this._h[v]&=8191;for(this._h[0]+=5*b,b=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=b,b=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=b,d[0]=this._h[0]+5,b=d[0]>>>13,d[0]&=8191,v=1;v<10;v++)d[v]=this._h[v]+b,b=d[v]>>>13,d[v]&=8191;for(d[9]-=8192,S=(1^b)-1,v=0;v<10;v++)d[v]&=S;for(S=~S,v=0;v<10;v++)this._h[v]=this._h[v]&S|d[v];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),this._h[0]=65535&(E=this._h[0]+this._pad[0]),v=1;v<8;v++)this._h[v]=65535&(E=(this._h[v]+this._pad[v]|0)+(E>>>16)|0);return c[f+0]=this._h[0]>>>0,c[f+1]=this._h[0]>>>8,c[f+2]=this._h[1]>>>0,c[f+3]=this._h[1]>>>8,c[f+4]=this._h[2]>>>0,c[f+5]=this._h[2]>>>8,c[f+6]=this._h[3]>>>0,c[f+7]=this._h[3]>>>8,c[f+8]=this._h[4]>>>0,c[f+9]=this._h[4]>>>8,c[f+10]=this._h[5]>>>0,c[f+11]=this._h[5]>>>8,c[f+12]=this._h[6]>>>0,c[f+13]=this._h[6]>>>8,c[f+14]=this._h[7]>>>0,c[f+15]=this._h[7]>>>8,this._finished=!0,this},h.prototype.update=function(c){var b,f=0,d=c.length;if(this._leftover){(b=16-this._leftover)>d&&(b=d);for(var S=0;S=16&&(this._blocks(c,f,b=d-d%16),f+=b,d-=b),d){for(S=0;S{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.randomStringForEntropy=U.randomString=U.randomUint32=U.randomBytes=U.defaultRandomSource=void 0;const y=x(9753),l=x(4502),g=x(9815);function w(d,b=U.defaultRandomSource){return b.randomBytes(d)}U.defaultRandomSource=new y.SystemRandomSource,U.randomBytes=w,U.randomUint32=function m(d=U.defaultRandomSource){const b=w(4,d),S=(0,l.readUint32LE)(b);return(0,g.wipe)(b),S};const h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(d,b=h,S=U.defaultRandomSource){if(b.length<2)throw new Error("randomString charset is too short");if(b.length>256)throw new Error("randomString charset is too long");let E="";const v=b.length,p=256-256%v;for(;d>0;){const I=w(Math.ceil(256*d/p),S);for(let A=0;A0;A++){const P=I[A];P{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.BrowserRandomSource=void 0,U.BrowserRandomSource=class y{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const g=typeof self<"u"?self.crypto||self.msCrypto:null;g&&void 0!==g.getRandomValues&&(this._crypto=g,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(g){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const w=new Uint8Array(g);for(let m=0;m{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.NodeRandomSource=void 0;const y=x(9815);U.NodeRandomSource=class l{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const w=x(5883);w&&w.randomBytes&&(this._crypto=w,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(w){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let m=this._crypto.randomBytes(w);if(m.length!==w)throw new Error("NodeRandomSource: got fewer bytes than requested");const h=new Uint8Array(w);for(let c=0;c{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.SystemRandomSource=void 0;const y=x(7170),l=x(1382);U.SystemRandomSource=class g{constructor(){return this.isAvailable=!1,this.name="",this._source=new y.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new l.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(m){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(m)}}},893:(Y,U,x)=>{"use strict";var l=x(4502),g=x(9815);U.k=32,U.cn=64;var w=function(){function f(){this.digestLength=U.k,this.blockSize=U.cn,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){g.wipe(this._buffer),g.wipe(this._temp),this.reset()},f.prototype.update=function(d,b){if(void 0===b&&(b=d.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var S=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=d[S++],b--;this._bufferLength===this.blockSize&&(h(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(S=h(this._temp,this._state,d,S,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=d[S++],b--;return this},f.prototype.finish=function(d){if(!this._finished){var b=this._bytesHashed,S=this._bufferLength,E=b/536870912|0,v=b<<3,p=b%64<56?64:128;this._buffer[S]=128;for(var I=S+1;I0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(d){return this._state.set(d.state),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(d){g.wipe(d.state),d.buffer&&g.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},f}();U.mE=w;var m=new Int32Array([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]);function h(f,d,b,S,E){for(;E>=64;){for(var v=d[0],p=d[1],I=d[2],A=d[3],P=d[4],D=d[5],T=d[6],M=d[7],k=0;k<16;k++)f[k]=l.readUint32BE(b,S+4*k);for(k=16;k<64;k++){var G=f[k-2];f[k]=((C=(G>>>17|G<<15)^(G>>>19|G<<13)^G>>>10)+f[k-7]|0)+((O=((G=f[k-15])>>>7|G<<25)^(G>>>18|G<<14)^G>>>3)+f[k-16]|0)}for(k=0;k<64;k++){var C=(((P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7))+(P&D^~P&T)|0)+(M+(m[k]+f[k]|0)|0)|0,O=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&p^v&I^p&I)|0;M=T,T=D,D=P,P=A+C|0,A=I,I=p,p=v,v=C+O|0}d[0]+=v,d[1]+=p,d[2]+=I,d[3]+=A,d[4]+=P,d[5]+=D,d[6]+=T,d[7]+=M,S+=64,E-=64}return S}U.vp=function c(f){var d=new w;d.update(f);var b=d.digest();return d.clean(),b}},9815:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.wipe=function x(y){for(var l=0;l{"use strict";U.gi=U.Au=U._w=U.KS=U.kz=void 0;const l=x(5784),g=x(9815);function w(k){const F=new Float64Array(16);if(k)for(let G=0;G=0;--ne){const se=G[ne>>>3]>>>(7&ne)&1;f(O,V,se),f(L,$,se),S(re,O,L),E(O,O,L),S(L,V,$),E(V,V,$),p($,re),p(z,O),v(O,L,O),v(L,V,re),S(re,O,L),E(O,O,L),p(V,O),E(L,$,z),v(O,L,h),S(O,O,$),v(L,L,O),v(O,$,z),v($,V,C),p(V,re),f(O,V,se),f(L,$,se)}for(let ne=0;ne<16;ne++)C[ne+16]=O[ne],C[ne+32]=L[ne],C[ne+48]=V[ne],C[ne+64]=$[ne];const te=C.subarray(32),X=C.subarray(16);(function I(k,F){const G=w();for(let C=0;C<16;C++)G[C]=F[C];for(let C=253;C>=0;C--)p(G,G),2!==C&&4!==C&&v(G,G,F);for(let C=0;C<16;C++)k[C]=G[C]})(te,te),v(X,X,te);const q=new Uint8Array(32);return function d(k,F){const G=w(),C=w();for(let O=0;O<16;O++)C[O]=F[O];c(C),c(C),c(C);for(let O=0;O<2;O++){G[0]=C[0]-65517;for(let L=1;L<15;L++)G[L]=C[L]-65535-(G[L-1]>>16&1),G[L-1]&=65535;G[15]=C[15]-32767-(G[14]>>16&1);const V=G[15]>>16&1;G[14]&=65535,f(C,G,1-V)}for(let O=0;O<16;O++)k[2*O]=255&C[O],k[2*O+1]=C[O]>>8}(q,X),q}function P(k){return A(k,m)}function D(k){if(k.length!==U.KS)throw new Error(`x25519: seed must be ${U.KS} bytes`);const F=new Uint8Array(k);return{publicKey:P(F),secretKey:F}}U._w=D,U.Au=function T(k){const F=(0,l.randomBytes)(32,k),G=D(F);return(0,g.wipe)(F),G},U.gi=function M(k,F,G=!1){if(k.length!==U.kz)throw new Error("X25519: incorrect secret key length");if(F.length!==U.kz)throw new Error("X25519: incorrect public key length");const C=A(k,F);if(G){let O=0;for(let V=0;V{function U(x){const y=new globalThis.AbortController;function l(){y.abort();for(const g of x)!g||!g.removeEventListener||g.removeEventListener("abort",l)}for(const g of x)if(g&&g.addEventListener){if(g.aborted){l();break}g.addEventListener("abort",l)}return y.signal}Y.exports=U,Y.exports.anySignal=U},3210:Y=>{var U=1e3,x=60*U,y=60*x,l=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Y.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*l;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=l?f(d,b,l,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=U?f(d,b,U,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=l?Math.round(d/l)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=U?Math.round(d/U)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},1455:(Y,U,x)=>{U.formatArgs=function l(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+Y.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;c.splice(1,0,f,"color: inherit");let d=0,b=0;c[0].replace(/%[a-zA-Z%]/g,S=>{"%%"!==S&&(d++,"%c"===S&&(b=d))}),c.splice(b,0,f)},U.save=function g(c){try{c?U.storage.setItem("debug",c):U.storage.removeItem("debug")}catch{}},U.load=function w(){let c;try{c=U.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c},U.useColors=function y(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},U.storage=function m(){try{return localStorage}catch{}}(),U.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),U.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],U.log=console.debug||console.log||(()=>{}),Y.exports=x(3283)(U);const{formatters:h}=Y.exports;h.j=function(c){try{return JSON.stringify(c)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}},3283:(Y,U,x)=>{Y.exports=function y(l){function w(E){let v,I,A,p=null;function P(...D){if(!P.enabled)return;const T=P,M=Number(new Date);T.diff=M-(v||M),T.prev=v,T.curr=M,v=M,D[0]=w.coerce(D[0]),"string"!=typeof D[0]&&D.unshift("%O");let F=0;D[0]=D[0].replace(/%([a-zA-Z%])/g,(C,O)=>{if("%%"===C)return"%";F++;const V=w.formatters[O];return"function"==typeof V&&(C=V.call(T,D[F]),D.splice(F,1),F--),C}),w.formatArgs.call(T,D),(T.log||w.log).apply(T,D)}return P.namespace=E,P.useColors=w.useColors(),P.color=w.selectColor(E),P.extend=m,P.destroy=w.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==p?p:(I!==w.namespaces&&(I=w.namespaces,A=w.enabled(E)),A),set:D=>{p=D}}),"function"==typeof w.init&&w.init(P),P}function m(E,v){const p=w(this.namespace+(typeof v>"u"?":":v)+E);return p.log=this.log,p}function d(E){return E.toString().substring(2,E.toString().length-2).replace(/\.\*\?$/,"*")}return w.debug=w,w.default=w,w.coerce=function b(E){return E instanceof Error?E.stack||E.message:E},w.disable=function c(){const E=[...w.names.map(d),...w.skips.map(d).map(v=>"-"+v)].join(",");return w.enable(""),E},w.enable=function h(E){let v;w.save(E),w.namespaces=E,w.names=[],w.skips=[];const p=("string"==typeof E?E:"").split(/[\s,]+/),I=p.length;for(v=0;v{w[E]=l[E]}),w.names=[],w.skips=[],w.formatters={},w.selectColor=function g(E){let v=0;for(let p=0;p{"use strict";function U(x,l){l=l||{},this._head=0,this._tail=0,this._capacity=l.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(x)&&this._fromArray(x)}U.prototype.peekAt=function(y){var l=y;if(l===(0|l)){var g=this.size();if(!(l>=g||l<-g))return l<0&&(l+=g),this._list[l=this._head+l&this._capacityMask]}},U.prototype.get=function(y){return this.peekAt(y)},U.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},U.prototype.peekFront=function(){return this.peek()},U.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(U.prototype,"length",{get:function(){return this.size()}}),U.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),l}},U.prototype.push=function(y){if(void 0===y)return this.size();var l=this._tail;return this._list[l]=y,this._tail=l+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&y<=l>>>2&&this._shrinkArray(),g}},U.prototype.removeOne=function(y){var l=y;if(l===(0|l)&&this._head!==this._tail){var g=this.size(),w=this._list.length;if(!(l>=g||l<-g)){l<0&&(l+=g);var h,m=this._list[l=this._head+l&this._capacityMask];if(y0;h--)this._list[l]=this._list[l=l-1+w&this._capacityMask];this._list[l]=void 0,this._head=this._head+1+w&this._capacityMask}else{for(h=g-1-y;h>0;h--)this._list[l]=this._list[l=l+1+w&this._capacityMask];this._list[l]=void 0,this._tail=this._tail-1+w&this._capacityMask}return m}}},U.prototype.remove=function(y,l){var w,g=y,m=l;if(g===(0|g)&&this._head!==this._tail){var h=this.size(),c=this._list.length;if(!(g>=h||g<-h||l<1)){if(g<0&&(g+=h),1===l||!l)return(w=new Array(1))[0]=this.removeOne(g),w;if(0===g&&g+l>=h)return w=this.toArray(),this.clear(),w;var f;for(g+l>h&&(l=h-g),w=new Array(l),f=0;f0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(0===y){for(this._head=this._head+l+c&this._capacityMask,f=l-1;f>0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(g0;f--)this.unshift(this._list[g=g-1+c&this._capacityMask]);for(g=this._head-1+c&this._capacityMask;m>0;)this._list[g=g-1+c&this._capacityMask]=void 0,m--;y<0&&(this._tail=g)}else{for(this._tail=g,g=g+l+c&this._capacityMask,f=h-(l+y);f>0;f--)this.push(this._list[g++]);for(g=this._tail;m>0;)this._list[g=g+1+c&this._capacityMask]=void 0,m--}return this._head<2&&this._tail>1e4&&this._tail<=c>>>2&&this._shrinkArray(),w}}},U.prototype.splice=function(y,l){var g=y;if(g===(0|g)){var w=this.size();if(g<0&&(g+=w),!(g>w)){if(arguments.length>2){var m,h,c,f=arguments.length,d=this._list.length,b=2;if(!w||g0&&(this._head=this._head+g+d&this._capacityMask)):(c=this.remove(g,l),this._head=this._head+g+d&this._capacityMask);f>b;)this.unshift(arguments[--f]);for(m=g;m>0;m--)this.unshift(h[m-1])}else{var S=(h=new Array(w-(g+l))).length;for(m=0;mthis._tail){for(m=this._head;m>>=1,this._capacityMask>>>=1},Y.exports=U},2535:Y=>{"use strict";function U(y,l){for(const g in l)Object.defineProperty(y,g,{value:l[g],enumerable:!0,configurable:!0});return y}Y.exports=function x(y,l,g){if(!y||"string"==typeof y)throw new TypeError("Please pass an Error to err-code");g||(g={}),"object"==typeof l&&(g=l,l=""),l&&(g.code=l);try{return U(y,g)}catch{g.message=y.message,g.stack=y.stack;const m=function(){};return m.prototype=Object.create(Object.getPrototypeOf(y)),U(new m,g)}}},3676:(Y,U,x)=>{"use strict";const l=x(649);U.zN=l.EventIterator},649:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});class x{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(g){if(this.isStopped)return;const w={value:g,done:!1};if(this.pullQueue.length){const m=this.pullQueue.shift();m&&m.resolve(w)}else this.pushQueue.push(Promise.resolve(w)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const g of this.pullQueue)g.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(g){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const w of this.pullQueue)w.reject(g);this.pullQueue.length=0}else{const w=Promise.reject(g);w.catch(()=>{}),this.pushQueue.push(w)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:g=>{const w=this.pushQueue.shift();return w?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),w):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((m,h)=>{this.pullQueue.push({resolve:m,reject:h})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class y{constructor(g,{highWaterMark:w=100,lowWaterMark:m=1}={}){const h=new x;h.highWaterMark=w,h.lowWaterMark=m,h.removeCallback=g({push:c=>h.push(c),stop:()=>h.stop(),fail:c=>h.fail(c),on:(c,f)=>{h.eventHandlers[c]=f}})||(()=>{}),this[Symbol.asyncIterator]=()=>h[Symbol.asyncIterator](),Object.freeze(this)}}U.EventIterator=y,U.default=y},2005:Y=>{"use strict";var U=Object.prototype.hasOwnProperty,x="~";function y(){}function l(h,c,f){this.fn=h,this.context=c,this.once=f||!1}function g(h,c,f,d,b){if("function"!=typeof f)throw new TypeError("The listener must be a function");var S=new l(f,d||h,b),E=x?x+c:c;return h._events[E]?h._events[E].fn?h._events[E]=[h._events[E],S]:h._events[E].push(S):(h._events[E]=S,h._eventsCount++),h}function w(h,c){0==--h._eventsCount?h._events=new y:delete h._events[c]}function m(){this._events=new y,this._eventsCount=0}Object.create&&(y.prototype=Object.create(null),(new y).__proto__||(x=!1)),m.prototype.eventNames=function(){var f,d,c=[];if(0===this._eventsCount)return c;for(d in f=this._events)U.call(f,d)&&c.push(x?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(f)):c},m.prototype.listeners=function(c){var d=this._events[x?x+c:c];if(!d)return[];if(d.fn)return[d.fn];for(var b=0,S=d.length,E=new Array(S);b{"use strict";var y,U="object"==typeof Reflect?Reflect:null,x=U&&"function"==typeof U.apply?U.apply:function(M,k,F){return Function.prototype.apply.call(M,k,F)};y=U&&"function"==typeof U.ownKeys?U.ownKeys:Object.getOwnPropertySymbols?function(M){return Object.getOwnPropertyNames(M).concat(Object.getOwnPropertySymbols(M))}:function(M){return Object.getOwnPropertyNames(M)};var g=Number.isNaN||function(M){return M!=M};function w(){w.init.call(this)}Y.exports=w,Y.exports.once=function A(T,M){return new Promise(function(k,F){function G(O){T.removeListener(M,C),F(O)}function C(){"function"==typeof T.removeListener&&T.removeListener("error",G),k([].slice.call(arguments))}D(T,M,C,{once:!0}),"error"!==M&&function P(T,M,k){"function"==typeof T.on&&D(T,"error",M,k)}(T,G,{once:!0})})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var m=10;function h(T){if("function"!=typeof T)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}function c(T){return void 0===T._maxListeners?w.defaultMaxListeners:T._maxListeners}function f(T,M,k,F){var G,C,O;if(h(k),void 0===(C=T._events)?(C=T._events=Object.create(null),T._eventsCount=0):(void 0!==C.newListener&&(T.emit("newListener",M,k.listener?k.listener:k),C=T._events),O=C[M]),void 0===O)O=C[M]=k,++T._eventsCount;else if("function"==typeof O?O=C[M]=F?[k,O]:[O,k]:F?O.unshift(k):O.push(k),(G=c(T))>0&&O.length>G&&!O.warned){O.warned=!0;var V=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(M)+" listeners added. Use emitter.setMaxListeners() to increase limit");V.name="MaxListenersExceededWarning",V.emitter=T,V.type=M,V.count=O.length,function l(T){console&&console.warn&&console.warn(T)}(V)}return T}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function b(T,M,k){var F={fired:!1,wrapFn:void 0,target:T,type:M,listener:k},G=d.bind(F);return G.listener=k,F.wrapFn=G,G}function S(T,M,k){var F=T._events;if(void 0===F)return[];var G=F[M];return void 0===G?[]:"function"==typeof G?k?[G.listener||G]:[G]:k?function I(T){for(var M=new Array(T.length),k=0;k0&&(O=k[0]),O instanceof Error)throw O;var V=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw V.context=O,V}var L=C[M];if(void 0===L)return!1;if("function"==typeof L)x(L,this,k);else{var $=L.length,re=v(L,$);for(F=0;F<$;++F)x(re[F],this,k)}return!0},w.prototype.on=w.prototype.addListener=function(M,k){return f(this,M,k,!1)},w.prototype.prependListener=function(M,k){return f(this,M,k,!0)},w.prototype.once=function(M,k){return h(k),this.on(M,b(this,M,k)),this},w.prototype.prependOnceListener=function(M,k){return h(k),this.prependListener(M,b(this,M,k)),this},w.prototype.off=w.prototype.removeListener=function(M,k){var F,G,C,O,V;if(h(k),void 0===(G=this._events))return this;if(void 0===(F=G[M]))return this;if(F===k||F.listener===k)0==--this._eventsCount?this._events=Object.create(null):(delete G[M],G.removeListener&&this.emit("removeListener",M,F.listener||k));else if("function"!=typeof F){for(C=-1,O=F.length-1;O>=0;O--)if(F[O]===k||F[O].listener===k){V=F[O].listener,C=O;break}if(C<0)return this;0===C?F.shift():function p(T,M){for(;M+1=0;G--)this.removeListener(M,k[G]);return this},w.prototype.listeners=function(M){return S(this,M,!0)},w.prototype.rawListeners=function(M){return S(this,M,!1)},w.listenerCount=function(T,M){return"function"==typeof T.listenerCount?T.listenerCount(M):E.call(T,M)},w.prototype.listenerCount=E,w.prototype.eventNames=function(){return this._eventsCount>0?y(this._events):[]}},3111:Y=>{Y.exports=class{constructor(x){if(!(x>0)||0!=(x-1&x))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(x),this.mask=x-1,this.top=0,this.btm=0,this.next=null}push(x){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=x,this.top=this.top+1&this.mask,!0)}shift(){const x=this.buffer[this.btm];if(void 0!==x)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,x}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},1159:(Y,U,x)=>{const y=x(3111);Y.exports=class{constructor(g){this.hwm=g||16,this.head=new y(this.hwm),this.tail=this.head}push(g){this.head.push(g)||(this.head=this.head.next=new y(2*this.head.buffer.length),this.head.push(g))}shift(){const g=this.tail.shift();if(void 0===g&&this.tail.next){const w=this.tail.next;return this.tail.next=null,this.tail=w,this.tail.shift()}return g}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}},5550:Y=>{Y.exports=function(U){if(!U)throw Error("hashlru must have a max value, of type number, greater than 0");var x=0,y=Object.create(null),l=Object.create(null);function g(w,m){y[w]=m,++x>=U&&(x=0,l=y,y=Object.create(null))}return{has:function(w){return void 0!==y[w]||void 0!==l[w]},remove:function(w){void 0!==y[w]&&(y[w]=void 0),void 0!==l[w]&&(l[w]=void 0)},get:function(w){var m=y[w];return void 0!==m?m:void 0!==(m=l[w])?(g(w,m),m):void 0},set:function(w,m){void 0!==y[w]?y[w]=m:g(w,m)},clear:function(){y=Object.create(null),l=Object.create(null)}}}},4066:Y=>{"use strict";const U="[a-fA-F\\d:]",x=f=>f&&f.includeBoundaries?`(?:(?<=\\s|^)(?=${U})|(?<=${U})(?=\\s|$))`:"",y="(?: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}",l="[a-fA-F\\d]{1,4}",g=`\n(?:\n(?:${l}:){7}(?:${l}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${l}:){6}(?:${y}|:${l}|:)| // 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\n(?:${l}:){5}(?::${y}|(?::${l}){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\n(?:${l}:){4}(?:(?::${l}){0,1}:${y}|(?::${l}){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\n(?:${l}:){3}(?:(?::${l}){0,2}:${y}|(?::${l}){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\n(?:${l}:){2}(?:(?::${l}){0,3}:${y}|(?::${l}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${l}:){1}(?:(?::${l}){0,4}:${y}|(?::${l}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${l}){0,5}:${y}|(?::${l}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),w=new RegExp(`(?:^${y}$)|(?:^${g}$)`),m=new RegExp(`^${y}$`),h=new RegExp(`^${g}$`),c=f=>f&&f.exact?w:new RegExp(`(?:${x(f)}${y}${x(f)})|(?:${x(f)}${g}${x(f)})`,"g");c.v4=f=>f&&f.exact?m:new RegExp(`${x(f)}${y}${x(f)}`,"g"),c.v6=f=>f&&f.exact?h:new RegExp(`${x(f)}${g}${x(f)}`,"g"),Y.exports=c},1396:function(Y){!function(U){"use strict";const x="(0?\\d+|0x[a-f0-9]+)",y={fourOctet:new RegExp(`^${x}\\.${x}\\.${x}\\.${x}$`,"i"),threeOctet:new RegExp(`^${x}\\.${x}\\.${x}$`,"i"),twoOctet:new RegExp(`^${x}\\.${x}$`,"i"),longValue:new RegExp(`^${x}$`,"i")},l=new RegExp("^0[0-7]+$","i"),g=new RegExp("^0x[a-f0-9]+$","i"),w="%[0-9a-z]{1,}",m="(?:[0-9a-f]+::?)+",h={zoneIndex:new RegExp(w,"i"),native:new RegExp(`^(::)?(${m})?([0-9a-f]+)?(::)?(${w})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${x}\\.${x}\\.${x}\\.${x}(${w})?)$`,"i"),transitional:new RegExp(`^((?:${m})|(?:::)(?:${m})?)${x}\\.${x}\\.${x}\\.${x}(${w})?$`,"i")};function c(E,v){if(E.indexOf("::")!==E.lastIndexOf("::"))return null;let P,D,p=0,I=-1,A=(E.match(h.zoneIndex)||[])[0];for(A&&(A=A.substring(1),E=E.replace(/%.+$/,""));(I=E.indexOf(":",I+1))>=0;)p++;if("::"===E.substr(0,2)&&p--,"::"===E.substr(-2,2)&&p--,p>v)return null;for(D=v-p,P=":";D--;)P+="0:";return":"===(E=E.replace("::",P))[0]&&(E=E.slice(1)),":"===E[E.length-1]&&(E=E.slice(0,-1)),{parts:v=function(){const T=E.split(":"),M=[];for(let k=0;k0;){if(P=p-I,P<0&&(P=0),E[A]>>P!=v[A]>>P)return!1;I-=p,A+=1}return!0}function d(E){if(g.test(E))return parseInt(E,16);if("0"===E[0]&&!isNaN(parseInt(E[1],10))){if(l.test(E))return parseInt(E,8);throw new Error(`ipaddr: cannot parse ${E} as octal`)}return parseInt(E,10)}function b(E,v){for(;E.length=0;A-=1){if(P=this.octets[A],!(P in I))return null;if(D=I[P],p&&0!==D)return null;8!==D&&(p=!0),v+=D}return 32-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){return this.octets.slice(0)},E.prototype.toIPv4MappedAddress=function(){return S.IPv6.parse(`::ffff:${this.toString()}`)},E.prototype.toNormalizedString=function(){return this.toString()},E.prototype.toString=function(){return this.octets.join(".")},E}(),S.IPv4.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<4;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.isIPv4=function(E){return null!==this.parser(E)},S.IPv4.isValid=function(E){try{return new this(this.parser(E)),!0}catch{return!1}},S.IPv4.isValidFourPartDecimal=function(E){return!(!S.IPv4.isValid(E)||!E.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},S.IPv4.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<4;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.parse=function(E){const v=this.parser(E);if(null===v)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(v)},S.IPv4.parseCIDR=function(E){let v;if(v=E.match(/^(.+)\/(\d+)$/)){const p=parseInt(v[2]);if(p>=0&&p<=32){const I=[this.parse(v[1]),p];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},S.IPv4.parser=function(E){let v,p,I;if(v=E.match(y.fourOctet))return function(){const A=v.slice(1,6),P=[];for(let D=0;D4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const A=[];let P;for(P=0;P<=24;P+=8)A.push(I>>P&255);return A}().reverse()}return(v=E.match(y.twoOctet))?function(){const A=v.slice(1,4),P=[];if(I=d(A[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(I>>16&255),P.push(I>>8&255),P.push(255&I),P}():(v=E.match(y.threeOctet))?function(){const A=v.slice(1,5),P=[];if(I=d(A[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(d(A[1])),P.push(I>>8&255),P.push(255&I),P}():null},S.IPv4.subnetMaskFromPrefixLength=function(E){if((E=parseInt(E))<0||E>32)throw new Error("ipaddr: invalid IPv4 prefix length");const v=[0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p=0;D-=1){if(A=this.parts[D],!(A in I))return null;if(P=I[A],p&&0!==P)return null;16!==P&&(p=!0),v+=P}return 128-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){let v;const p=[],I=this.parts;for(let A=0;A>8),p.push(255&v);return p},E.prototype.toFixedLengthString=function(){const v=function(){const I=[];for(let A=0;A>8,255&p,I>>8,255&I])},E.prototype.toNormalizedString=function(){const v=function(){const I=[];for(let A=0;AA&&(I=P.index,A=P[0].length);return A<0?p:`${p.substring(0,I)}::${p.substring(I+A)}`},E.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},E}(),S.IPv6.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<16;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch(v){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${v})`)}},S.IPv6.isIPv6=function(E){return null!==this.parser(E)},S.IPv6.isValid=function(E){if("string"==typeof E&&-1===E.indexOf(":"))return!1;try{const v=this.parser(E);return new this(v.parts,v.zoneId),!0}catch{return!1}},S.IPv6.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<16;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch(D){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${D})`)}},S.IPv6.parse=function(E){const v=this.parser(E);if(null===v.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(v.parts,v.zoneId)},S.IPv6.parseCIDR=function(E){let v,p,I;if((p=E.match(/^(.+)\/(\d+)$/))&&(v=parseInt(p[2]),v>=0&&v<=128))return I=[this.parse(p[1]),v],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},S.IPv6.parser=function(E){let v,p,I,A,P,D;if(I=E.match(h.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(h.native.test(E))return c(E,8);if((I=E.match(h.transitional))&&(D=I[6]||"",v=c(I[1].slice(0,-1)+D,6),v.parts)){for(P=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],p=0;p128)throw new Error("ipaddr: invalid IPv6 prefix length");const v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p{Y.exports=function U(){return typeof window<"u"&&"object"==typeof window.process&&"renderer"===window.process.type||typeof process<"u"&&"object"==typeof process.versions&&!!process.versions.electron||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0}},7494:Y=>{"use strict";Y.exports=U=>{if("[object Object]"!==Object.prototype.toString.call(U))return!1;const x=Object.getPrototypeOf(U);return null===x||x===Object.prototype}},8596:(Y,U,x)=>{"use strict";const{URLWithLegacySupport:y,format:l,URLSearchParams:g,defaultBase:w}=x(5695),m=x(340);Y.exports={URL:y,URLSearchParams:g,format:l,relative:m,defaultBase:w}},340:(Y,U,x)=>{"use strict";const{URLWithLegacySupport:y,format:l}=x(5695);Y.exports=(g,w={},m={},h)=>{let f,c=w.protocol?w.protocol.replace(":",""):"http";c=(m[c]||h||c)+":";try{f=new y(g)}catch{f={}}const d=Object.assign({},w,{protocol:c||f.protocol,host:w.host||f.host});return new y(g,l(d)).toString()}},5695:Y=>{"use strict";const U=typeof navigator<"u"&&"ReactNative"===navigator.product,y=self.URL,l=function x(){return U?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}();Y.exports={URLWithLegacySupport:class g{constructor(h="",c=l){this.super=new y(h,c),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(h){this.super.hash=h}set host(h){this.super.host=h}set hostname(h){this.super.hostname=h}set href(h){this.super.href=h}set password(h){this.super.password=h}set pathname(h){this.super.pathname=h}set port(h){this.super.port=h}set protocol(h){this.super.protocol=h}set search(h){this.super.search=h}set username(h){this.super.username=h}static createObjectURL(h){return y.createObjectURL(h)}static revokeObjectURL(h){y.revokeObjectURL(h)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:l,format:function w(m){if("string"==typeof m)return new y(m).toString();if(!(m instanceof y)){const c=m.auth?m.auth+"@":"",f=m.port?":"+m.port:"",S=m.hostname||"",E=m.search||(m.query?"?"+m.query:""),p=m.pathname||"";return`${m.protocol?m.protocol+"//":""}${(m.username&&m.password?`${m.username}:${m.password}@`:"")||c}${m.host||S+f}${m.path||p+E}${m.hash||""}`}}}},5357:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){const h=[];var d,c=!1,f=!1;try{for(var S,b=l(m);c=!(S=yield b.next()).done;c=!1)h.push(S.value)}catch(E){f=!0,d=E}finally{try{c&&null!=b.return&&(yield b.return())}finally{if(f)throw d}}return h});return function(h){return w.apply(this,arguments)}}()},7414:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var d=l(m);h=!(yield d.next()).done;h=!1);}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},6225:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;(yield y(c(v)))&&(yield v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},4943:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var b,d=l(m);h=!(b=yield d.next()).done;h=!1)return b.value}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},1349:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield y(c(v)),yield v}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},6930:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield c(v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},5061:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8186).default,g=x(6737).default,w=x(8237).default,m=x(8131).default;const h=x(6343);Y.exports=function(){var f=l(function*(...d){const b=h();setTimeout(y(function*(){try{yield Promise.all(d.map(function(){var S=y(function*(E){var I,v=!1,p=!1;try{for(var P,A=w(E);v=!(P=yield A.next()).done;v=!1)b.push(P.value)}catch(D){p=!0,I=D}finally{try{v&&null!=A.return&&(yield A.return())}finally{if(p)throw I}}});return function(E){return S.apply(this,arguments)}}())),b.end()}catch(S){b.end(S)}}),0),yield*m(w(b),g)});return function(){return f.apply(this,arguments)}}()},6343:(Y,U,x)=>{const y=x(1159);Y.exports=l=>{let g;"function"==typeof(l=l||{})?(g=l,l={}):g=l.onEnd;let m,h,c,w=new y;const d=A=>h?h(A):(w.push(A),m),S=A=>c?m:d({done:!1,value:A}),E=A=>c?m:(c=!0,A?(A=>(w=new y,h?h({error:A}):(w.push({error:A}),m)))(A):d({done:!0}));if(m={[Symbol.asyncIterator](){return this},next:()=>{if(!w.isEmpty()){if(l.writev){let P;const D=[];for(;!w.isEmpty();){if(P=w.shift(),P.error)throw P.error;D.push(P.value)}return{done:P.done,value:D}}const A=w.shift();if(A.error)throw A.error;return A}return c?{done:!0}:new Promise((A,P)=>{h=D=>(h=null,D.error?P(D.error):A(l.writev&&!D.done?{done:D.done,value:[D.value]}:D),m)})},return:()=>(w=new y,E(),{done:!0}),throw:A=>(E(A),{done:!0}),push:S,end:E},!g)return m;const I=m;return m={[Symbol.asyncIterator](){return this},next:()=>I.next(),throw:A=>(I.throw(A),g&&(g(A),g=null),{done:!0}),return:()=>(I.return(),g&&(g(),g=null),{done:!0}),push:S,end:A=>(I.end(A),g&&(g(A),g=null),m)},m}},4297:(Y,U,x)=>{"use strict";var y=x(8186).default,l=x(6737).default,g=x(8237).default,w=x(8131).default;const m=x(5357);Y.exports=function(){var c=y(function*(f,d){const b=yield l(m(f));yield*w(g(b.sort(d)),l)});return function(d,b){return c.apply(this,arguments)}}()},0:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){let f=0;if(!(c<1)){var S,d=!1,b=!1;try{for(var v,E=g(h);d=!(v=yield y(E.next())).done;d=!1)if(yield v.value,f++,f===c)return}catch(p){b=!0,S=p}finally{try{d&&null!=E.return&&(yield y(E.return()))}finally{if(b)throw S}}}});return function(c,f){return m.apply(this,arguments)}}()},4237:(Y,U,x)=>{var y;!function(){"use strict";var l="input is invalid type",w="object"==typeof window,m=w?window:{};m.JS_SHA3_NO_WINDOW&&(w=!1);var h=!w&&"object"==typeof self;!m.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?m=global:h&&(m=self);var f=!m.JS_SHA3_NO_COMMON_JS&&Y.exports,d=x.amdO,b=!m.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",S="0123456789abcdef".split(""),v=[4,1024,262144,67108864],A=[0,8,16,24],P=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],D=[224,256,384,512],T=[128,256],M=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136};(m.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(H){return"[object Array]"===Object.prototype.toString.call(H)}),b&&(m.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(H){return"object"==typeof H&&H.buffer&&H.buffer.constructor===ArrayBuffer});for(var F=function(H,Ee,Te){return function(xe){return new Pe(H,Ee,H).update(xe)[Te]()}},G=function(H,Ee,Te){return function(xe,He){return new Pe(H,Ee,He).update(xe)[Te]()}},C=function(H,Ee,Te){return function(xe,He,We,Je){return X["cshake"+H].update(xe,He,We,Je)[Te]()}},O=function(H,Ee,Te){return function(xe,He,We,Je){return X["kmac"+H].update(xe,He,We,Je)[Te]()}},V=function(H,Ee,Te,xe){for(var He=0;He>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Te>>5,this.extraBytes=(31&Te)>>3;for(var xe=0;xe<50;++xe)this.s[xe]=0}function be(H,Ee,Te){Pe.call(this,H,Ee,Te)}Pe.prototype.update=function(H){if(this.finalized)throw new Error("finalize already called");var Ee,Te=typeof H;if("string"!==Te){if("object"!==Te)throw new Error(l);if(null===H)throw new Error(l);if(b&&H.constructor===ArrayBuffer)H=new Uint8Array(H);else if(!(Array.isArray(H)||b&&ArrayBuffer.isView(H)))throw new Error(l);Ee=!0}for(var pt,_t,xe=this.blocks,He=this.byteCount,We=H.length,Je=this.blockCount,Xe=0,Nt=this.s;Xe>2]|=H[Xe]<>2]|=_t<>2]|=(192|_t>>6)<>2]|=(128|63&_t)<=57344?(xe[pt>>2]|=(224|_t>>12)<>2]|=(128|_t>>6&63)<>2]|=(128|63&_t)<>2]|=(240|_t>>18)<>2]|=(128|_t>>12&63)<>2]|=(128|_t>>6&63)<>2]|=(128|63&_t)<=He){for(this.start=pt-He,this.block=xe[Je],pt=0;pt>=8);Te>0;)He.unshift(Te),Te=255&(H>>=8),++xe;return Ee?He.push(xe):He.unshift(xe),this.update(He),He.length},Pe.prototype.encodeString=function(H){var Ee,Te=typeof H;if("string"!==Te){if("object"!==Te)throw new Error(l);if(null===H)throw new Error(l);if(b&&H.constructor===ArrayBuffer)H=new Uint8Array(H);else if(!(Array.isArray(H)||b&&ArrayBuffer.isView(H)))throw new Error(l);Ee=!0}var xe=0;if(Ee)xe=H.length;else for(var We=0;We=57344?xe+=3:(Je=65536+((1023&Je)<<10|1023&H.charCodeAt(++We)),xe+=4)}return xe+=this.encode(8*xe),this.update(H),xe},Pe.prototype.bytepad=function(H,Ee){for(var Te=this.encode(Ee),xe=0;xe>2]|=this.padding[3&Ee],this.lastByteIndex===this.byteCount)for(H[0]=H[Te],Ee=1;Ee>4&15]+S[15&Xe]+S[Xe>>12&15]+S[Xe>>8&15]+S[Xe>>20&15]+S[Xe>>16&15]+S[Xe>>28&15]+S[Xe>>24&15];We%H==0&&($e(Ee),He=0)}return xe&&(Je+=S[(Xe=Ee[He])>>4&15]+S[15&Xe],xe>1&&(Je+=S[Xe>>12&15]+S[Xe>>8&15]),xe>2&&(Je+=S[Xe>>20&15]+S[Xe>>16&15])),Je},Pe.prototype.buffer=Pe.prototype.arrayBuffer=function(){this.finalize();var Xe,H=this.blockCount,Ee=this.s,Te=this.outputBlocks,xe=this.extraBytes,He=0,We=0,Je=this.outputBits>>3;Xe=xe?new ArrayBuffer(Te+1<<2):new ArrayBuffer(Je);for(var Nt=new Uint32Array(Xe);We>8&255,Je[Xe+2]=Nt>>16&255,Je[Xe+3]=Nt>>24&255;We%H==0&&$e(Ee)}return xe&&(Je[Xe=We<<2]=255&(Nt=Ee[He]),xe>1&&(Je[Xe+1]=Nt>>8&255),xe>2&&(Je[Xe+2]=Nt>>16&255)),Je},(be.prototype=new Pe).finalize=function(){return this.encode(this.outputBits,!0),Pe.prototype.finalize.call(this)};var $e=function(H){var Ee,Te,xe,He,We,Je,Xe,Nt,pt,_t,Or,gr,Hr,ie,fe,ye,me,_e,Ne,Qe,qe,it,nt,Ke,we,ge,De,Fe,Be,dt,xt,mt,et,Tn,Bt,pn,en,ft,ln,st,Kt,wt,Jn,Pr,On,vn,ur,Qn,En,Ft,ct,ce,ve,yt,Dt,gn,je,Ye,Ae,Ge,ht,Et,ut;for(xe=0;xe<48;xe+=2)He=H[0]^H[10]^H[20]^H[30]^H[40],We=H[1]^H[11]^H[21]^H[31]^H[41],Nt=H[4]^H[14]^H[24]^H[34]^H[44],pt=H[5]^H[15]^H[25]^H[35]^H[45],_t=H[6]^H[16]^H[26]^H[36]^H[46],Or=H[7]^H[17]^H[27]^H[37]^H[47],Te=(Hr=H[9]^H[19]^H[29]^H[39]^H[49])^((Xe=H[3]^H[13]^H[23]^H[33]^H[43])<<1|(Je=H[2]^H[12]^H[22]^H[32]^H[42])>>>31),H[0]^=Ee=(gr=H[8]^H[18]^H[28]^H[38]^H[48])^(Je<<1|Xe>>>31),H[1]^=Te,H[10]^=Ee,H[11]^=Te,H[20]^=Ee,H[21]^=Te,H[30]^=Ee,H[31]^=Te,H[40]^=Ee,H[41]^=Te,Te=We^(pt<<1|Nt>>>31),H[2]^=Ee=He^(Nt<<1|pt>>>31),H[3]^=Te,H[12]^=Ee,H[13]^=Te,H[22]^=Ee,H[23]^=Te,H[32]^=Ee,H[33]^=Te,H[42]^=Ee,H[43]^=Te,Te=Xe^(Or<<1|_t>>>31),H[4]^=Ee=Je^(_t<<1|Or>>>31),H[5]^=Te,H[14]^=Ee,H[15]^=Te,H[24]^=Ee,H[25]^=Te,H[34]^=Ee,H[35]^=Te,H[44]^=Ee,H[45]^=Te,Te=pt^(Hr<<1|gr>>>31),H[6]^=Ee=Nt^(gr<<1|Hr>>>31),H[7]^=Te,H[16]^=Ee,H[17]^=Te,H[26]^=Ee,H[27]^=Te,H[36]^=Ee,H[37]^=Te,H[46]^=Ee,H[47]^=Te,Te=Or^(We<<1|He>>>31),H[8]^=Ee=_t^(He<<1|We>>>31),H[9]^=Te,H[18]^=Ee,H[19]^=Te,H[28]^=Ee,H[29]^=Te,H[38]^=Ee,H[39]^=Te,H[48]^=Ee,H[49]^=Te,fe=H[1],vn=H[11]<<4|H[10]>>>28,ur=H[10]<<4|H[11]>>>28,Fe=H[20]<<3|H[21]>>>29,Be=H[21]<<3|H[20]>>>29,Ge=H[31]<<9|H[30]>>>23,ht=H[30]<<9|H[31]>>>23,wt=H[40]<<18|H[41]>>>14,Jn=H[41]<<18|H[40]>>>14,Tn=H[2]<<1|H[3]>>>31,Bt=H[3]<<1|H[2]>>>31,me=H[12]<<12|H[13]>>>20,Qn=H[22]<<10|H[23]>>>22,En=H[23]<<10|H[22]>>>22,dt=H[33]<<13|H[32]>>>19,xt=H[32]<<13|H[33]>>>19,Et=H[42]<<2|H[43]>>>30,ut=H[43]<<2|H[42]>>>30,yt=H[5]<<30|H[4]>>>2,Dt=H[4]<<30|H[5]>>>2,pn=H[14]<<6|H[15]>>>26,en=H[15]<<6|H[14]>>>26,Ne=H[24]<<11|H[25]>>>21,Ft=H[34]<<15|H[35]>>>17,ct=H[35]<<15|H[34]>>>17,mt=H[45]<<29|H[44]>>>3,et=H[44]<<29|H[45]>>>3,Ke=H[6]<<28|H[7]>>>4,we=H[7]<<28|H[6]>>>4,gn=H[17]<<23|H[16]>>>9,je=H[16]<<23|H[17]>>>9,ft=H[26]<<25|H[27]>>>7,ln=H[27]<<25|H[26]>>>7,Qe=H[36]<<21|H[37]>>>11,qe=H[37]<<21|H[36]>>>11,ce=H[47]<<24|H[46]>>>8,ve=H[46]<<24|H[47]>>>8,Pr=H[8]<<27|H[9]>>>5,On=H[9]<<27|H[8]>>>5,ge=H[18]<<20|H[19]>>>12,De=H[19]<<20|H[18]>>>12,Ye=H[29]<<7|H[28]>>>25,Ae=H[28]<<7|H[29]>>>25,st=H[38]<<8|H[39]>>>24,Kt=H[39]<<8|H[38]>>>24,it=H[48]<<14|H[49]>>>18,nt=H[49]<<14|H[48]>>>18,H[0]=(ie=H[0])^~(ye=H[13]<<12|H[12]>>>20)&(_e=H[25]<<11|H[24]>>>21),H[1]=fe^~me&Ne,H[10]=Ke^~ge&Fe,H[11]=we^~De&Be,H[20]=Tn^~pn&ft,H[21]=Bt^~en&ln,H[30]=Pr^~vn&Qn,H[31]=On^~ur&En,H[40]=yt^~gn&Ye,H[41]=Dt^~je&Ae,H[2]=ye^~_e&Qe,H[3]=me^~Ne&qe,H[12]=ge^~Fe&dt,H[13]=De^~Be&xt,H[22]=pn^~ft&st,H[23]=en^~ln&Kt,H[32]=vn^~Qn&Ft,H[33]=ur^~En&ct,H[42]=gn^~Ye&Ge,H[43]=je^~Ae&ht,H[4]=_e^~Qe&it,H[5]=Ne^~qe&nt,H[14]=Fe^~dt&mt,H[15]=Be^~xt&et,H[24]=ft^~st&wt,H[25]=ln^~Kt&Jn,H[34]=Qn^~Ft&ce,H[35]=En^~ct&ve,H[44]=Ye^~Ge&Et,H[45]=Ae^~ht&ut,H[6]=Qe^~it&ie,H[7]=qe^~nt&fe,H[16]=dt^~mt&Ke,H[17]=xt^~et&we,H[26]=st^~wt&Tn,H[27]=Kt^~Jn&Bt,H[36]=Ft^~ce&Pr,H[37]=ct^~ve&On,H[46]=Ge^~Et&yt,H[47]=ht^~ut&Dt,H[8]=it^~ie&ye,H[9]=nt^~fe&me,H[18]=mt^~Ke&ge,H[19]=et^~we&De,H[28]=wt^~Tn&pn,H[29]=Jn^~Bt&en,H[38]=ce^~Pr&vn,H[39]=ve^~On&ur,H[48]=Et^~yt&gn,H[49]=ut^~Dt&je,H[0]^=P[xe],H[1]^=P[xe+1]};if(f)Y.exports=X;else{for(ne=0;neObject.defineProperty(p,I,{value:A,writable:!0,enumerable:!0,configurable:!0}),m=this,h={concatArrays:!1,ignoreUndefined:!1},c=p=>{const I=[];for(const A in p)l.call(p,A)&&I.push(A);if(Object.getOwnPropertySymbols){const A=Object.getOwnPropertySymbols(p);for(const P of A)g.call(p,P)&&I.push(P)}return I};function f(p){return Array.isArray(p)?function d(p){const I=p.slice(0,0);return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):y(p)?function b(p){const I=null===Object.getPrototypeOf(p)?Object.create(null):{};return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):p}const S=(p,I,A,P)=>(A.forEach(D=>{typeof I[D]>"u"&&P.ignoreUndefined||(D in p&&p[D]!==Object.getPrototypeOf(p)?w(p,D,v(p[D],I[D],P)):w(p,D,f(I[D])))}),p);function v(p,I,A){return A.concatArrays&&Array.isArray(p)&&Array.isArray(I)?((p,I,A)=>{let P=p.slice(0,0),D=0;return[p,I].forEach(T=>{const M=[];for(let k=0;k!M.includes(k)),A)}),P})(p,I,A):y(I)&&y(p)?S(p,I,c(I),A):f(I)}Y.exports=function(...p){const I=v(f(h),this!==m&&this||{},h);let A={_:{}};for(const P of p)if(void 0!==P){if(!y(P))throw new TypeError("`"+P+"` is not an Option Object");A=v(A,{_:P},I)}return A._}},4366:Y=>{var U=1e3,x=60*U,y=60*x,l=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Y.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*l;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=l?f(d,b,l,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=U?f(d,b,U,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=l?Math.round(d/l)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=U?Math.round(d/U)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},344:Y=>{"use strict";function U(x){if(Array.isArray(x)){for(var y=0,l=Array(x.length);y>>24,(f&255<<16)>>>16,(65280&f)>>>8,255&f].join(".")},h=function(f){var d,S,E,v,p;for(d=[],S=E=0;E<=3&&0!==f.length;S=++E){if(S>0){if("."!==f[0])throw new Error("Invalid IP");f=f.substring(1)}v=(p=y(f))[0],f=f.substring(p[1]),d.push(v)}if(0!==f.length)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},g=(l=function(f){return f.charCodeAt(0)})("0"),m=l("a"),w=l("A"),y=function(f){var d,b,S,E,v;for(E=0,d=10,b="9",S=0,f.length>1&&"0"===f[S]&&("x"===f[S+1]||"X"===f[S+1]?(S+=2,d=16):"0"<=f[S+1]&&f[S+1]<="9"&&(S++,d=8,b="7")),v=S;S>>0;else{if(16!==d)break;if("a"<=f[S]&&f[S]<="f")E=E*d+(10+l(f[S])-m)>>>0;else{if(!("A"<=f[S]&&f[S]<="F"))break;E=E*d+(10+l(f[S])-w)>>>0}}if(E>4294967295)throw new Error("too large");S++}if(S===v)throw new Error("empty octet");return[E,S]},x=function(){function f(d,b){var E,v,p;if("string"!=typeof d)throw new Error("Missing `net' parameter");if(b||(p=d.split("/",2),d=p[0],b=p[1]),b||(b=32),"string"==typeof b&&b.indexOf(".")>-1){try{this.maskLong=h(b)}catch(I){throw new Error("Invalid mask: "+b)}for(E=v=32;v>=0;E=--v)if(this.maskLong===4294967295<<32-E>>>0){this.bitmask=E;break}}else{if(!b&&0!==b)throw new Error("Invalid mask: empty");this.bitmask=parseInt(b,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(h(d)&this.maskLong)>>>0}catch(I){throw new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+b);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=c(this.bitmask<=30?this.netLong+this.size-2:this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return f.prototype.contains=function(d){return"string"==typeof d&&(d.indexOf("/")>0||4!==d.split(".").length)&&(d=new f(d)),d instanceof f?this.contains(d.base)&&this.contains(d.broadcast||d.last):(h(d)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},f.prototype.next=function(d){return null==d&&(d=1),new f(c(this.netLong+this.size*d),this.mask)},f.prototype.forEach=function(d){var b,S,E;for(E=h(this.first),S=h(this.last),b=0;E<=S;)d(c(E),E,b),b++,E++},f.prototype.toString=function(){return this.base+"/"+this.bitmask},f}(),U.ip2long=h,U.long2ip=c,U.Netmask=x}).call(this)},1298:(Y,U,x)=>{var y=x(8659);function l(p,I){y.cipher.registerAlgorithm(p,function(){return new y.aes.Algorithm(p,I)})}x(3311),x(3481),x(4747),Y.exports=y.aes=y.aes||{},y.aes.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P});return D.start(I),D},y.aes.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.aes.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P});return D.start(I),D},y.aes.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.aes.Algorithm=function(p,I){g||b();var A=this;A.name=p,A.mode=new I({blockSize:16,cipher:{encrypt:function(P,D){return E(A._w,P,D,!1)},decrypt:function(P,D){return E(A._w,P,D,!0)}}}),A._init=!1},y.aes.Algorithm.prototype.initialize=function(p){if(!this._init){var A,I=p.key;if("string"!=typeof I||16!==I.length&&24!==I.length&&32!==I.length){if(y.util.isArray(I)&&(16===I.length||24===I.length||32===I.length)){A=I,I=y.util.createBuffer();for(var P=0;P>>=2,P=0;P>8^255&k^99,h[k]=A,G=(F=p[k])<<24^k<<16^k<<8^k^F,C=((D=p[A])^(T=p[D])^(M=p[T]))<<24^(A^M)<<16^(A^T^M)<<8^A^D^M;for(var O=0;O<4;++O)f[O][A]=G,d[O][k]=C,G=G<<24|G>>>8,C=C<<24|C>>>8;0===A?A=P=1:(A=D^p[p[p[D^M]]],P^=p[p[P]])}}function S(p,I){for(var P,A=p.slice(0),D=1,T=A.length,k=4*(T+6+1),F=T;F>>16&255]<<24^m[P>>>8&255]<<16^m[255&P]<<8^m[P>>>24]^c[D]<<24,D++):T>6&&F%T==4&&(P=m[P>>>24]<<24^m[P>>>16&255]<<16^m[P>>>8&255]<<8^m[255&P]),A[F]=A[F-T]^P;if(I){for(var G,C=d[0],O=d[1],V=d[2],L=d[3],$=A.slice(0),re=(F=0,(k=A.length)-4);F>>24]]^O[m[G>>>16&255]]^V[m[G>>>8&255]]^L[m[255&G]];A=$}return A}function E(p,I,A,P){var T,M,k,F,G,C,O,V,L,$,re,z,D=p.length/4-1;P?(T=d[0],M=d[1],k=d[2],F=d[3],G=h):(T=f[0],M=f[1],k=f[2],F=f[3],G=m),C=I[0]^p[0],O=I[P?3:1]^p[1],V=I[2]^p[2],L=I[P?1:3]^p[3];for(var te=3,X=1;X>>24]^M[O>>>16&255]^k[V>>>8&255]^F[255&L]^p[++te],re=T[O>>>24]^M[V>>>16&255]^k[L>>>8&255]^F[255&C]^p[++te],z=T[V>>>24]^M[L>>>16&255]^k[C>>>8&255]^F[255&O]^p[++te],L=T[L>>>24]^M[C>>>16&255]^k[O>>>8&255]^F[255&V]^p[++te],C=$,O=re,V=z;A[0]=G[C>>>24]<<24^G[O>>>16&255]<<16^G[V>>>8&255]<<8^G[255&L]^p[++te],A[P?3:1]=G[O>>>24]<<24^G[V>>>16&255]<<16^G[L>>>8&255]<<8^G[255&C]^p[++te],A[2]=G[V>>>24]<<24^G[L>>>16&255]<<16^G[C>>>8&255]<<8^G[255&O]^p[++te],A[P?1:3]=G[L>>>24]<<24^G[C>>>16&255]<<16^G[O>>>8&255]<<8^G[255&V]^p[++te]}function v(p){var P,A="AES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},7791:(Y,U,x)=>{var y=x(8659);x(4747),x(6078);var l=Y.exports=y.asn1=y.asn1||{};function g(c,f,d){if(d>f){var b=new Error("Too few bytes to parse DER.");throw b.available=c.length(),b.remaining=f,b.requested=d,b}}function m(c,f,d,b){var S;g(c,f,2);var E=c.getByte();f--;var v=192&E,p=31&E;S=c.length();var I=function(c,f){var d=c.getByte();if(f--,128!==d){var b;if(128&d){var E=127&d;g(c,f,E),b=c.getInt(E<<3)}else b=d;if(b<0)throw new Error("Negative length: "+b);return b}}(c,f);if(f-=S-c.length(),void 0!==I&&I>f){if(b.strict){var A=new Error("Too few bytes to read ASN.1 value.");throw A.available=c.length(),A.remaining=f,A.requested=I,A}I=f}var P,D,T=32==(32&E);if(T)if(P=[],void 0===I)for(;;){if(g(c,f,2),c.bytes(2)===String.fromCharCode(0,0)){c.getBytes(2),f-=2;break}S=c.length(),P.push(m(c,f,d+1,b)),f-=S-c.length()}else for(;I>0;)S=c.length(),P.push(m(c,I,d+1,b)),f-=S-c.length(),I-=S-c.length();if(void 0===P&&v===l.Class.UNIVERSAL&&p===l.Type.BITSTRING&&(D=c.bytes(I)),void 0===P&&b.decodeBitStrings&&v===l.Class.UNIVERSAL&&p===l.Type.BITSTRING&&I>1){var M=c.read,k=f,F=0;if(p===l.Type.BITSTRING&&(g(c,f,1),F=c.getByte(),f--),0===F)try{S=c.length();var C=m(c,f,d+1,{strict:!0,decodeBitStrings:!0}),O=S-c.length();f-=O,p==l.Type.BITSTRING&&O++;var V=C.tagClass;O===I&&(V===l.Class.UNIVERSAL||V===l.Class.CONTEXT_SPECIFIC)&&(P=[C])}catch{}void 0===P&&(c.read=M,f=k)}if(void 0===P){if(void 0===I){if(b.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");I=f}if(p===l.Type.BMPSTRING)for(P="";I>0;I-=2)g(c,f,2),P+=String.fromCharCode(c.getInt16()),f-=2;else P=c.getBytes(I),f-=I}return l.create(v,p,T,P,void 0===D?null:{bitStringContents:D})}l.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},l.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},l.create=function(c,f,d,b,S){if(y.util.isArray(b)){for(var E=[],v=0;v1&&(0===c.value.charCodeAt(0)&&0==(128&c.value.charCodeAt(1))||255===c.value.charCodeAt(0)&&128==(128&c.value.charCodeAt(1)))?b.putBytes(c.value.substr(1)):b.putBytes(c.value);if(f.putByte(d),b.length()<=127)f.putByte(127&b.length());else{var v=b.length(),p="";do{p+=String.fromCharCode(255&v),v>>>=8}while(v>0);for(f.putByte(128|p.length),E=p.length-1;E>=0;--E)f.putByte(p.charCodeAt(E))}return f.putBuffer(b),f},l.oidToDer=function(c){var f=c.split("."),d=y.util.createBuffer();d.putByte(40*parseInt(f[0],10)+parseInt(f[1],10));for(var b,S,E,v,p=2;p>>=7,b||(v|=128),S.push(v),b=!1}while(E>0);for(var I=S.length-1;I>=0;--I)d.putByte(S[I])}return d},l.derToOid=function(c){var f;"string"==typeof c&&(c=y.util.createBuffer(c));var d=c.getByte();f=Math.floor(d/40)+"."+d%40;for(var b=0;c.length()>0;)b<<=7,128&(d=c.getByte())?b+=127&d:(f+="."+(b+d),b=0);return f},l.utcTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,2),10);d=d>=50?1900+d:2e3+d;var b=parseInt(c.substr(2,2),10)-1,S=parseInt(c.substr(4,2),10),E=parseInt(c.substr(6,2),10),v=parseInt(c.substr(8,2),10),p=0;if(c.length>11){var I=c.charAt(10),A=10;"+"!==I&&"-"!==I&&(p=parseInt(c.substr(10,2),10),A+=2)}if(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,0),A&&("+"===(I=c.charAt(A))||"-"===I)){var T=60*parseInt(c.substr(A+1,2),10)+parseInt(c.substr(A+4,2),10);T*=6e4,f.setTime("+"===I?+f-T:+f+T)}return f},l.generalizedTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,4),10),b=parseInt(c.substr(4,2),10)-1,S=parseInt(c.substr(6,2),10),E=parseInt(c.substr(8,2),10),v=parseInt(c.substr(10,2),10),p=parseInt(c.substr(12,2),10),I=0,A=0,P=!1;"Z"===c.charAt(c.length-1)&&(P=!0);var D=c.length-5,T=c.charAt(D);return"+"!==T&&"-"!==T||(A=60*parseInt(c.substr(D+1,2),10)+parseInt(c.substr(D+4,2),10),A*=6e4,"+"===T&&(A*=-1),P=!0),"."===c.charAt(14)&&(I=1e3*parseFloat(c.substr(14),10)),P?(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,I),f.setTime(+f+A)):(f.setFullYear(d,b,S),f.setHours(E,v,p,I)),f},l.dateToUtcTime=function(c){if("string"==typeof c)return c;var f="",d=[];d.push((""+c.getUTCFullYear()).substr(2)),d.push(""+(c.getUTCMonth()+1)),d.push(""+c.getUTCDate()),d.push(""+c.getUTCHours()),d.push(""+c.getUTCMinutes()),d.push(""+c.getUTCSeconds());for(var b=0;b=-128&&c<128)return f.putSignedInt(c,8);if(c>=-32768&&c<32768)return f.putSignedInt(c,16);if(c>=-8388608&&c<8388608)return f.putSignedInt(c,24);if(c>=-2147483648&&c<2147483648)return f.putSignedInt(c,32);var d=new Error("Integer too large; max is 32-bits.");throw d.integer=c,d},l.derToInteger=function(c){"string"==typeof c&&(c=y.util.createBuffer(c));var f=8*c.length();if(f>32)throw new Error("Integer too large; max is 32-bits.");return c.getSignedInt(f)},l.validate=function(c,f,d,b){var S=!1;if((c.tagClass===f.tagClass||typeof f.tagClass>"u")&&(c.type===f.type||typeof f.type>"u"))if(c.constructed===f.constructed||typeof f.constructed>"u"){if(S=!0,f.value&&y.util.isArray(f.value))for(var E=0,v=0;S&&v0&&(b+="\n");for(var S="",E=0;E1?"0x"+y.util.bytesToHex(c.value.slice(1)):"(none)",c.value.length>0){var A=c.value.charCodeAt(0);1==A?b+=" (1 unused bit shown)":A>1&&(b+=" ("+A+" unused bits shown)")}}else if(c.type===l.Type.OCTETSTRING)h.test(c.value)||(b+="("+c.value+") "),b+="0x"+y.util.bytesToHex(c.value);else if(c.type===l.Type.UTF8)try{b+=y.util.decodeUtf8(c.value)}catch(P){if("URI malformed"!==P.message)throw P;b+="0x"+y.util.bytesToHex(c.value)+" (malformed UTF8)"}else c.type===l.Type.PRINTABLESTRING||c.type===l.Type.IA5String?b+=c.value:h.test(c.value)?b+="0x"+y.util.bytesToHex(c.value):b+=0===c.value.length?"[null]":c.value}return b}},2020:Y=>{var U={};Y.exports=U;var x={};U.encode=function(l,g,w){if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');if(void 0!==w&&"number"!=typeof w)throw new TypeError('"maxline" must be a number.');var m="";if(l instanceof Uint8Array){var h=0,c=g.length,f=g.charAt(0),d=[0];for(h=0;h0;)d.push(S%c),S=S/c|0}for(h=0;0===l[h]&&h=0;--h)m+=g[d[h]]}else m=function y(l,g){var w=0,m=g.length,h=g.charAt(0),c=[0];for(w=0;w0;)c.push(d%m),d=d/m|0}var b="";for(w=0;0===l.at(w)&&w=0;--w)b+=g[c[w]];return b}(l,g);if(w){var E=new RegExp(".{1,"+w+"}","g");m=m.match(E).join("\r\n")}return m},U.decode=function(l,g){if("string"!=typeof l)throw new TypeError('"input" must be a string.');if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');var w=x[g];if(!w){w=x[g]=[];for(var m=0;m>=8;for(;S>0;)f.push(255&S),S>>=8}for(var E=0;l[E]===c&&E{var y=x(8659);x(4747),Y.exports=y.cipher=y.cipher||{},y.cipher.algorithms=y.cipher.algorithms||{},y.cipher.createCipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!1})},y.cipher.createDecipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!0})},y.cipher.registerAlgorithm=function(g,w){g=g.toUpperCase(),y.cipher.algorithms[g]=w},y.cipher.getAlgorithm=function(g){return(g=g.toUpperCase())in y.cipher.algorithms?y.cipher.algorithms[g]:null};var l=y.cipher.BlockCipher=function(g){this.algorithm=g.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=g.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=g.decrypt,this.algorithm.initialize(g)};l.prototype.start=function(g){g=g||{};var w={};for(var m in g)w[m]=g[m];w.decrypt=this._decrypt,this._finish=!1,this._input=y.util.createBuffer(),this.output=g.output||y.util.createBuffer(),this.mode.start(w)},l.prototype.update=function(g){for(g&&this._input.putBuffer(g);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},l.prototype.finish=function(g){g&&("ECB"===this.mode.name||"CBC"===this.mode.name)&&(this.mode.pad=function(m){return g(this.blockSize,m,!1)},this.mode.unpad=function(m){return g(this.blockSize,m,!0)});var w={};return w.decrypt=this._decrypt,w.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,w)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,w))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,w))}},3481:(Y,U,x)=>{var y=x(8659);x(4747),y.cipher=y.cipher||{};var l=Y.exports=y.cipher.modes=y.cipher.modes||{};function g(h,c){if("string"==typeof h&&(h=y.util.createBuffer(h)),y.util.isArray(h)&&h.length>4){var f=h;h=y.util.createBuffer();for(var d=0;d0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},l.cbc=function(h){h=h||{},this.name="CBC",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},l.cbc.prototype.start=function(h){if(null===h.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._prev=this._iv.slice(0)}},l.cbc.prototype.encrypt=function(h,c,f){if(h.length()0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},l.cfb=function(h){h=h||{},this.name="CFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.cfb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.cfb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.cfb.prototype.decrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.ofb=function(h){h=h||{},this.name="OFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.ofb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.ofb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===h.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.ofb.prototype.decrypt=l.ofb.prototype.encrypt,l.ctr=function(h){h=h||{},this.name="CTR",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.ctr.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.ctr.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&(h.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}w(this._inBlock)},l.ctr.prototype.decrypt=l.ctr.prototype.encrypt,l.gcm=function(h){h=h||{},this.name="GCM",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0,this._R=3774873600},l.gcm.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");var f,c=y.util.createBuffer(h.iv);if(this._cipherLength=0,f="additionalData"in h?y.util.createBuffer(h.additionalData):y.util.createBuffer(),this._tagLength="tagLength"in h?h.tagLength:128,this._tag=null,h.decrypt&&(this._tag=y.util.createBuffer(h.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var d=c.length();if(12===d)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(m(8*d)))}this._inBlock=this._j0.slice(0),w(this._inBlock),this._partialBytes=0,f=y.util.createBuffer(f),this._aDataLength=m(8*f.length());var b=f.length()%this.blockSize;for(b&&f.fillWithByte(0,this.blockSize-b),this._s=[0,0,0,0];f.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[f.getInt32(),f.getInt32(),f.getInt32(),f.getInt32()])},l.gcm.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return h.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),w(this._inBlock)},l.gcm.prototype.decrypt=function(h,c,f){var d=h.length();if(d0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),w(this._inBlock),this._hashBlock[0]=h.getInt32(),this._hashBlock[1]=h.getInt32(),this._hashBlock[2]=h.getInt32(),this._hashBlock[3]=h.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var b=0;b0;--d)c[d]=h[d]>>>1|(1&h[d-1])<<31;c[0]=h[0]>>>1,f&&(c[0]^=this._R)},l.gcm.prototype.tableMultiply=function(h){for(var c=[0,0,0,0],f=0;f<32;++f){var S=this._m[f][h[f/8|0]>>>4*(7-f%8)&15];c[0]^=S[0],c[1]^=S[1],c[2]^=S[2],c[3]^=S[3]}return c},l.gcm.prototype.ghash=function(h,c,f){return c[0]^=f[0],c[1]^=f[1],c[2]^=f[2],c[3]^=f[3],this.tableMultiply(c)},l.gcm.prototype.generateHashTable=function(h,c){for(var f=8/c,d=4*f,b=16*f,S=new Array(b),E=0;E>>1,b=new Array(f);b[d]=h.slice(0);for(var S=d>>>1;S>0;)this.pow(b[2*S],b[S]=[]),S>>=1;for(S=2;S{var y=x(8659);function l(p,I){y.cipher.registerAlgorithm(p,function(){return new y.des.Algorithm(p,I)})}x(3311),x(3481),x(4747),Y.exports=y.des=y.des||{},y.des.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.des.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.des.Algorithm=function(p,I){var A=this;A.name=p,A.mode=new I({blockSize:8,cipher:{encrypt:function(P,D){return E(A._keys,P,D,!1)},decrypt:function(P,D){return E(A._keys,P,D,!0)}}}),A._init=!1},y.des.Algorithm.prototype.initialize=function(p){if(!this._init){var I=y.util.createBuffer(p.key);if(0===this.name.indexOf("3DES")&&24!==I.length())throw new Error("Invalid Triple-DES key size: "+8*I.length());this._keys=function S(p){for(var q,I=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],A=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],P=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],D=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],T=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],M=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],k=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],F=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],G=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],C=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],O=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],V=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],L=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],$=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],re=p.length()>8?3:1,z=[],te=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],X=0,ne=0;ne>>4^de))<<4,se^=q=65535&((de^=q)>>>-16^se),se^=(q=858993459&(se>>>2^(de^=q<<-16)))<<2,se^=q=65535&((de^=q)>>>-16^se),se^=(q=1431655765&(se>>>1^(de^=q<<-16)))<<1,se^=q=16711935&((de^=q)>>>8^se),q=(se^=(q=1431655765&(se>>>1^(de^=q<<8)))<<1)<<8|(de^=q)>>>20&240,se=de<<24|de<<8&16711680|de>>>8&65280|de>>>24&240,de=q;for(var pe=0;pe>>26,de=de<<2|de>>>26):(se=se<<1|se>>>27,de=de<<1|de>>>27);var Le=I[(se&=-15)>>>28]|A[se>>>24&15]|P[se>>>20&15]|D[se>>>16&15]|T[se>>>12&15]|M[se>>>8&15]|k[se>>>4&15],Se=F[(de&=-15)>>>28]|G[de>>>24&15]|C[de>>>20&15]|O[de>>>16&15]|V[de>>>12&15]|L[de>>>8&15]|$[de>>>4&15];z[X++]=Le^(q=65535&(Se>>>16^Le)),z[X++]=Se^q<<16}}return z}(I),this._init=!0}},l("DES-ECB",y.cipher.modes.ecb),l("DES-CBC",y.cipher.modes.cbc),l("DES-CFB",y.cipher.modes.cfb),l("DES-OFB",y.cipher.modes.ofb),l("DES-CTR",y.cipher.modes.ctr),l("3DES-ECB",y.cipher.modes.ecb),l("3DES-CBC",y.cipher.modes.cbc),l("3DES-CFB",y.cipher.modes.cfb),l("3DES-OFB",y.cipher.modes.ofb),l("3DES-CTR",y.cipher.modes.ctr);var g=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],w=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],m=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],h=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],c=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],f=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],d=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],b=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function E(p,I,A,P){var T,D=32===p.length?3:9;T=3===D?P?[30,-2,-2]:[0,32,2]:P?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var M,k=I[0],F=I[1];k^=(M=252645135&(k>>>4^F))<<4,k^=(M=65535&(k>>>16^(F^=M)))<<16,k^=M=858993459&((F^=M)>>>2^k),k^=M=16711935&((F^=M<<2)>>>8^k),k=(k^=(M=1431655765&(k>>>1^(F^=M<<8)))<<1)<<1|k>>>31,F=(F^=M)<<1|F>>>31;for(var G=0;G>>4|F<<28)^p[V+1];M=k,k=F,F=M^(w[L>>>24&63]|h[L>>>16&63]|f[L>>>8&63]|b[63&L]|g[$>>>24&63]|m[$>>>16&63]|c[$>>>8&63]|d[63&$])}M=k,k=F,F=M}F=F>>>1|F<<31,F^=M=1431655765&((k=k>>>1|k<<31)>>>1^F),F^=(M=16711935&(F>>>8^(k^=M<<1)))<<8,F^=(M=858993459&(F>>>2^(k^=M)))<<2,F^=M=65535&((k^=M)>>>16^F),F^=M=252645135&((k^=M<<16)>>>4^F),A[0]=k^=M<<4,A[1]=F}function v(p){var P,A="DES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},8659:Y=>{Y.exports={options:{usePureJavaScript:!1}}},9032:(Y,U,x)=>{var y=x(8659);x(979),x(4747),(Y.exports=y.hmac=y.hmac||{}).create=function(){var g=null,w=null,m=null,h=null,c={start:function(f,d){if(null!==f)if("string"==typeof f){if(!((f=f.toLowerCase())in y.md.algorithms))throw new Error('Unknown hash algorithm "'+f+'"');w=y.md.algorithms[f].create()}else w=f;if(null===d)d=g;else{if("string"==typeof d)d=y.util.createBuffer(d);else if(y.util.isArray(d)){var b=d;d=y.util.createBuffer();for(var S=0;Sw.blockLength&&(w.start(),w.update(d.bytes()),d=w.digest()),m=y.util.createBuffer(),h=y.util.createBuffer(),E=d.length(),S=0;S{var l,y=x(8659);function m(W,Q,ee){this.data=[],null!=W&&("number"==typeof W?this.fromNumber(W,Q,ee):this.fromString(W,null==Q&&"string"!=typeof W?256:Q))}function h(){return new m(null)}function d(W,Q,ee,le,ke,Ve){for(var tt=16383&Q,Ze=Q>>14;--Ve>=0;){var rn=16383&this.data[W],yr=this.data[W++]>>14,di=Ze*rn+yr*tt;ke=((rn=tt*rn+((16383&di)<<14)+ee.data[le]+ke)>>28)+(di>>14)+Ze*yr,ee.data[le++]=268435455&rn}return ke}Y.exports=y.jsbn=y.jsbn||{},y.jsbn.BigInteger=m,typeof navigator>"u"?(m.prototype.am=d,l=28):"Microsoft Internet Explorer"==navigator.appName?(m.prototype.am=function f(W,Q,ee,le,ke,Ve){for(var tt=32767&Q,Ze=Q>>15;--Ve>=0;){var rn=32767&this.data[W],yr=this.data[W++]>>15,di=Ze*rn+yr*tt;ke=((rn=tt*rn+((32767&di)<<15)+ee.data[le]+(1073741823&ke))>>>30)+(di>>>15)+Ze*yr+(ke>>>30),ee.data[le++]=1073741823&rn}return ke},l=30):"Netscape"!=navigator.appName?(m.prototype.am=function c(W,Q,ee,le,ke,Ve){for(;--Ve>=0;){var tt=Q*this.data[W++]+ee.data[le]+ke;ke=Math.floor(tt/67108864),ee.data[le++]=67108863&tt}return ke},l=26):(m.prototype.am=d,l=28),m.prototype.DB=l,m.prototype.DM=(1<>>16)&&(W=ee,Q+=16),0!=(ee=W>>8)&&(W=ee,Q+=8),0!=(ee=W>>4)&&(W=ee,Q+=4),0!=(ee=W>>2)&&(W=ee,Q+=2),0!=(ee=W>>1)&&(W=ee,Q+=1),Q}function pe(W){this.m=W}function Ee(W){this.m=W,this.mp=W.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,Q+=16),0==(255&W)&&(W>>=8,Q+=8),0==(15&W)&&(W>>=4,Q+=4),0==(3&W)&&(W>>=2,Q+=2),0==(1&W)&&++Q,Q}function en(W){for(var Q=0;0!=W;)W&=W-1,++Q;return Q}function ve(){}function yt(W){return W}function Ge(W){this.r2=h(),this.q3=h(),m.ONE.dlShiftTo(2*W.t,this.r2),this.mu=this.r2.divide(W),this.m=W}pe.prototype.convert=function Le(W){return W.s<0||W.compareTo(this.m)>=0?W.mod(this.m):W},pe.prototype.revert=function Se(W){return W},pe.prototype.reduce=function Pe(W){W.divRemTo(this.m,null,W)},pe.prototype.mulTo=function be(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},pe.prototype.sqrTo=function $e(W,Q){W.squareTo(Q),this.reduce(Q)},Ee.prototype.convert=function Te(W){var Q=h();return W.abs().dlShiftTo(this.m.t,Q),Q.divRemTo(this.m,null,Q),W.s<0&&Q.compareTo(m.ZERO)>0&&this.m.subTo(Q,Q),Q},Ee.prototype.revert=function xe(W){var Q=h();return W.copyTo(Q),this.reduce(Q),Q},Ee.prototype.reduce=function He(W){for(;W.t<=this.mt2;)W.data[W.t++]=0;for(var Q=0;Q>15)*this.mpl&this.um)<<15)&W.DM;for(W.data[ee=Q+this.m.t]+=this.m.am(0,le,W,Q,0,this.m.t);W.data[ee]>=W.DV;)W.data[ee]-=W.DV,W.data[++ee]++}W.clamp(),W.drShiftTo(this.m.t,W),W.compareTo(this.m)>=0&&W.subTo(this.m,W)},Ee.prototype.mulTo=function Je(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},Ee.prototype.sqrTo=function We(W,Q){W.squareTo(Q),this.reduce(Q)},m.prototype.copyTo=function P(W){for(var Q=this.t-1;Q>=0;--Q)W.data[Q]=this.data[Q];W.t=this.t,W.s=this.s},m.prototype.fromInt=function D(W){this.t=1,this.s=W<0?-1:0,W>0?this.data[0]=W:W<-1?this.data[0]=W+this.DV:this.t=0},m.prototype.fromString=function M(W,Q){var ee;if(16==Q)ee=4;else if(8==Q)ee=3;else if(256==Q)ee=8;else if(2==Q)ee=1;else if(32==Q)ee=5;else{if(4!=Q)return void this.fromRadix(W,Q);ee=2}this.t=0,this.s=0;for(var le=W.length,ke=!1,Ve=0;--le>=0;){var tt=8==ee?255&W[le]:A(W,le);tt<0?"-"==W.charAt(le)&&(ke=!0):(ke=!1,0==Ve?this.data[this.t++]=tt:Ve+ee>this.DB?(this.data[this.t-1]|=(tt&(1<>this.DB-Ve):this.data[this.t-1]|=tt<=this.DB&&(Ve-=this.DB))}8==ee&&0!=(128&W[0])&&(this.s=-1,Ve>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==W;)--this.t},m.prototype.dlShiftTo=function $(W,Q){var ee;for(ee=this.t-1;ee>=0;--ee)Q.data[ee+W]=this.data[ee];for(ee=W-1;ee>=0;--ee)Q.data[ee]=0;Q.t=this.t+W,Q.s=this.s},m.prototype.drShiftTo=function re(W,Q){for(var ee=W;ee=0;--Ze)Q.data[Ze+Ve+1]=this.data[Ze]>>le|tt,tt=(this.data[Ze]&ke)<=0;--Ze)Q.data[Ze]=0;Q.data[Ve]=tt,Q.t=this.t+Ve+1,Q.s=this.s,Q.clamp()},m.prototype.rShiftTo=function te(W,Q){Q.s=this.s;var ee=Math.floor(W/this.DB);if(ee>=this.t)Q.t=0;else{var le=W%this.DB,ke=this.DB-le,Ve=(1<>le;for(var tt=ee+1;tt>le;le>0&&(Q.data[this.t-ee-1]|=(this.s&Ve)<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le-=W.s}Q.s=le<0?-1:0,le<-1?Q.data[ee++]=this.DV+le:le>0&&(Q.data[ee++]=le),Q.t=ee,Q.clamp()},m.prototype.multiplyTo=function q(W,Q){var ee=this.abs(),le=W.abs(),ke=ee.t;for(Q.t=ke+le.t;--ke>=0;)Q.data[ke]=0;for(ke=0;ke=0;)W.data[ee]=0;for(ee=0;ee=Q.DV&&(W.data[ee+Q.t]-=Q.DV,W.data[ee+Q.t+1]=1)}W.t>0&&(W.data[W.t-1]+=Q.am(ee,Q.data[ee],W,2*ee,0,1)),W.s=0,W.clamp()},m.prototype.divRemTo=function se(W,Q,ee){var le=W.abs();if(!(le.t<=0)){var ke=this.abs();if(ke.t0?(le.lShiftTo(rn,Ve),ke.lShiftTo(rn,ee)):(le.copyTo(Ve),ke.copyTo(ee));var yr=Ve.t,di=Ve.data[yr-1];if(0!=di){var ei=di*(1<1?Ve.data[yr-2]>>this.F2:0),ns=this.FV/ei,Io=(1<=0&&(ee.data[ee.t++]=1,ee.subTo(Li,ee)),m.ONE.dlShiftTo(yr,Li),Li.subTo(Ve,Ve);Ve.t=0;){var Eu=ee.data[--ti]==di?this.DM:Math.floor(ee.data[ti]*ns+(ee.data[ti-1]+Xt)*Io);if((ee.data[ti]+=Ve.am(0,Eu,ee,bn,0,yr))0&&ee.rShiftTo(rn,ee),tt<0&&m.ZERO.subTo(ee,ee)}}},m.prototype.invDigit=function H(){if(this.t<1)return 0;var W=this.data[0];if(0==(1&W))return 0;var Q=3&W;return(Q=(Q=(Q=(Q=Q*(2-(15&W)*Q)&15)*(2-(255&W)*Q)&255)*(2-((65535&W)*Q&65535))&65535)*(2-W*Q%this.DV)%this.DV)>0?this.DV-Q:-Q},m.prototype.isEven=function Xe(){return 0==(this.t>0?1&this.data[0]:this.s)},m.prototype.exp=function Nt(W,Q){if(W>4294967295||W<1)return m.ONE;var ee=h(),le=h(),ke=Q.convert(this),Ve=V(W)-1;for(ke.copyTo(ee);--Ve>=0;)if(Q.sqrTo(ee,le),(W&1<0)Q.mulTo(le,ke,ee);else{var tt=ee;ee=le,le=tt}return Q.revert(ee)},m.prototype.toString=function F(W){if(this.s<0)return"-"+this.negate().toString(W);var Q;if(16==W)Q=4;else if(8==W)Q=3;else if(2==W)Q=1;else if(32==W)Q=5;else{if(4!=W)return this.toRadix(W);Q=2}var le,ee=(1<0)for(Ze>Ze)>0&&(ke=!0,Ve=I(le));tt>=0;)Ze>(Ze+=this.DB-Q)):(le=this.data[tt]>>(Ze-=Q)&ee,Ze<=0&&(Ze+=this.DB,--tt)),le>0&&(ke=!0),ke&&(Ve+=I(le));return ke?Ve:"0"},m.prototype.negate=function G(){var W=h();return m.ZERO.subTo(this,W),W},m.prototype.abs=function C(){return this.s<0?this.negate():this},m.prototype.compareTo=function O(W){var Q=this.s-W.s;if(0!=Q)return Q;var ee=this.t;if(0!=(Q=ee-W.t))return this.s<0?-Q:Q;for(;--ee>=0;)if(0!=(Q=this.data[ee]-W.data[ee]))return Q;return 0},m.prototype.bitLength=function L(){return this.t<=0?0:this.DB*(this.t-1)+V(this.data[this.t-1]^this.s&this.DM)},m.prototype.mod=function de(W){var Q=h();return this.abs().divRemTo(W,null,Q),this.s<0&&Q.compareTo(m.ZERO)>0&&W.subTo(Q,Q),Q},m.prototype.modPowInt=function pt(W,Q){var ee;return ee=W<256||Q.isEven()?new pe(Q):new Ee(Q),this.exp(W,ee)},m.ZERO=T(0),m.ONE=T(1),ve.prototype.convert=yt,ve.prototype.revert=yt,ve.prototype.mulTo=function Dt(W,Q,ee){W.multiplyTo(Q,ee)},ve.prototype.sqrTo=function gn(W,Q){W.squareTo(Q)},Ge.prototype.convert=function ht(W){if(W.s<0||W.t>2*this.m.t)return W.mod(this.m);if(W.compareTo(this.m)<0)return W;var Q=h();return W.copyTo(Q),this.reduce(Q),Q},Ge.prototype.revert=function Et(W){return W},Ge.prototype.reduce=function ut(W){for(W.drShiftTo(this.m.t-1,this.r2),W.t>this.m.t+1&&(W.t=this.m.t+1,W.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);W.compareTo(this.r2)<0;)W.dAddOffset(1,this.m.t+1);for(W.subTo(this.r2,W);W.compareTo(this.m)>=0;)W.subTo(this.m,W)},Ge.prototype.mulTo=function $t(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},Ge.prototype.sqrTo=function St(W,Q){W.squareTo(Q),this.reduce(Q)};var Zn=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],ca=(1<<26)/Zn[Zn.length-1];m.prototype.chunkSize=function ie(W){return Math.floor(Math.LN2*this.DB/Math.log(W))},m.prototype.toRadix=function ye(W){if(null==W&&(W=10),0==this.signum()||W<2||W>36)return"0";var Q=this.chunkSize(W),ee=Math.pow(W,Q),le=T(ee),ke=h(),Ve=h(),tt="";for(this.divRemTo(le,ke,Ve);ke.signum()>0;)tt=(ee+Ve.intValue()).toString(W).substr(1)+tt,ke.divRemTo(le,ke,Ve);return Ve.intValue().toString(W)+tt},m.prototype.fromRadix=function me(W,Q){this.fromInt(0),null==Q&&(Q=10);for(var ee=this.chunkSize(Q),le=Math.pow(Q,ee),ke=!1,Ve=0,tt=0,Ze=0;Ze=ee&&(this.dMultiply(le),this.dAddOffset(tt,0),Ve=0,tt=0))}Ve>0&&(this.dMultiply(Math.pow(Q,Ve)),this.dAddOffset(tt,0)),ke&&m.ZERO.subTo(this,this)},m.prototype.fromNumber=function _e(W,Q,ee){if("number"==typeof Q)if(W<2)this.fromInt(1);else for(this.fromNumber(W,ee),this.testBit(W-1)||this.bitwiseTo(m.ONE.shiftLeft(W-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(Q);)this.dAddOffset(2,0),this.bitLength()>W&&this.subTo(m.ONE.shiftLeft(W-1),this);else{var le=new Array,ke=7&W;le.length=1+(W>>3),Q.nextBytes(le),ke>0?le[0]&=(1<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le+=W.s}Q.s=le<0?-1:0,le>0?Q.data[ee++]=le:le<-1&&(Q.data[ee++]=this.DV+le),Q.t=ee,Q.clamp()},m.prototype.dMultiply=function ct(W){this.data[this.t]=this.am(0,W-1,this,0,0,this.t),++this.t,this.clamp()},m.prototype.dAddOffset=function ce(W,Q){if(0!=W){for(;this.t<=Q;)this.data[this.t++]=0;for(this.data[Q]+=W;this.data[Q]>=this.DV;)this.data[Q]-=this.DV,++Q>=this.t&&(this.data[this.t++]=0),++this.data[Q]}},m.prototype.multiplyLowerTo=function Ye(W,Q,ee){var ke,le=Math.min(this.t+W.t,Q);for(ee.s=0,ee.t=le;le>0;)ee.data[--le]=0;for(ke=ee.t-this.t;le=0;)ee.data[le]=0;for(le=Math.max(Q-this.t,0);le0)if(0==Q)ee=this.data[0]%W;else for(var le=this.t-1;le>=0;--le)ee=(Q*ee+this.data[le])%W;return ee},m.prototype.millerRabin=function of(W){var Q=this.subtract(m.ONE),ee=Q.getLowestSetBit();if(ee<=0)return!1;for(var Ve,le=Q.shiftRight(ee),ke=function ua(){return{nextBytes:function(W){for(var Q=0;Q=0);var Ze=Ve.modPow(le,this);if(0!=Ze.compareTo(m.ONE)&&0!=Ze.compareTo(Q)){for(var rn=1;rn++>24},m.prototype.shortValue=function Hr(){return 0==this.t?this.s:this.data[0]<<16>>16},m.prototype.signum=function fe(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},m.prototype.toByteArray=function Ne(){var W=this.t,Q=new Array;Q[0]=this.s;var le,ee=this.DB-W*this.DB%8,ke=0;if(W-- >0)for(ee>ee)!=(this.s&this.DM)>>ee&&(Q[ke++]=le|this.s<=0;)ee<8?(le=(this.data[W]&(1<>(ee+=this.DB-8)):(le=this.data[W]>>(ee-=8)&255,ee<=0&&(ee+=this.DB,--W)),0!=(128&le)&&(le|=-256),0==ke&&(128&this.s)!=(128&le)&&++ke,(ke>0||le!=this.s)&&(Q[ke++]=le);return Q},m.prototype.equals=function Qe(W){return 0==this.compareTo(W)},m.prototype.min=function qe(W){return this.compareTo(W)<0?this:W},m.prototype.max=function it(W){return this.compareTo(W)>0?this:W},m.prototype.and=function we(W){var Q=h();return this.bitwiseTo(W,Ke,Q),Q},m.prototype.or=function De(W){var Q=h();return this.bitwiseTo(W,ge,Q),Q},m.prototype.xor=function Be(W){var Q=h();return this.bitwiseTo(W,Fe,Q),Q},m.prototype.andNot=function xt(W){var Q=h();return this.bitwiseTo(W,dt,Q),Q},m.prototype.not=function mt(){for(var W=h(),Q=0;Q=this.t?0!=this.s:0!=(this.data[Q]&1<1){var di=h();for(Ve.sqrTo(tt[1],di);Ze<=yr;)tt[Ze]=h(),Ve.mulTo(di,tt[Ze-2],tt[Ze]),Ze+=2}var ns,ti,ei=W.t-1,Io=!0,Xt=h();for(ee=V(W.data[ei])-1;ei>=0;){for(ee>=rn?ns=W.data[ei]>>ee-rn&yr:(ns=(W.data[ei]&(1<0&&(ns|=W.data[ei-1]>>this.DB+ee-rn)),Ze=le;0==(1&ns);)ns>>=1,--Ze;if((ee-=Ze)<0&&(ee+=this.DB,--ei),Io)tt[ns].copyTo(ke),Io=!1;else{for(;Ze>1;)Ve.sqrTo(ke,Xt),Ve.sqrTo(Xt,ke),Ze-=2;Ze>0?Ve.sqrTo(ke,Xt):(ti=ke,ke=Xt,Xt=ti),Ve.mulTo(Xt,tt[ns],ke)}for(;ei>=0&&0==(W.data[ei]&1<=0?(ee.subTo(le,ee),Q&&ke.subTo(tt,ke),Ve.subTo(Ze,Ve)):(le.subTo(ee,le),Q&&tt.subTo(ke,tt),Ze.subTo(Ve,Ze))}return 0!=le.compareTo(m.ONE)?m.ZERO:Ze.compareTo(W)>=0?Ze.subtract(W):Ze.signum()<0?(Ze.addTo(W,Ze),Ze.signum()<0?Ze.add(W):Ze):Ze},m.prototype.pow=function je(W){return this.exp(W,new ve)},m.prototype.gcd=function An(W){var Q=this.s<0?this.negate():this.clone(),ee=W.s<0?W.negate():W.clone();if(Q.compareTo(ee)<0){var le=Q;Q=ee,ee=le}var ke=Q.getLowestSetBit(),Ve=ee.getLowestSetBit();if(Ve<0)return Q;for(ke0&&(Q.rShiftTo(Ve,Q),ee.rShiftTo(Ve,ee));Q.signum()>0;)(ke=Q.getLowestSetBit())>0&&Q.rShiftTo(ke,Q),(ke=ee.getLowestSetBit())>0&&ee.rShiftTo(ke,ee),Q.compareTo(ee)>=0?(Q.subTo(ee,Q),Q.rShiftTo(1,Q)):(ee.subTo(Q,ee),ee.rShiftTo(1,ee));return Ve>0&&ee.lShiftTo(Ve,ee),ee},m.prototype.isProbablePrime=function Co(W){var Q,ee=this.abs();if(1==ee.t&&ee.data[0]<=Zn[Zn.length-1]){for(Q=0;Q{var y=x(8659);Y.exports=y.md=y.md||{},y.md.algorithms=y.md.algorithms||{}},9386:(Y,U,x)=>{var y=x(8659);x(8449),Y.exports=y.mgf=y.mgf||{},y.mgf.mgf1=y.mgf1},8449:(Y,U,x)=>{var y=x(8659);x(4747),y.mgf=y.mgf||{},(Y.exports=y.mgf.mgf1=y.mgf1=y.mgf1||{}).create=function(g){return{generate:function(m,h){for(var c=new y.util.ByteBuffer,f=Math.ceil(h/g.digestLength),d=0;d{var y=x(8659);y.pki=y.pki||{};var l=Y.exports=y.pki.oids=y.oids=y.oids||{};function g(m,h){l[m]=h,l[h]=m}function w(m,h){l[m]=h}g("1.2.840.113549.1.1.1","rsaEncryption"),g("1.2.840.113549.1.1.4","md5WithRSAEncryption"),g("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),g("1.2.840.113549.1.1.7","RSAES-OAEP"),g("1.2.840.113549.1.1.8","mgf1"),g("1.2.840.113549.1.1.9","pSpecified"),g("1.2.840.113549.1.1.10","RSASSA-PSS"),g("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),g("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),g("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),g("1.3.101.112","EdDSA25519"),g("1.2.840.10040.4.3","dsa-with-sha1"),g("1.3.14.3.2.7","desCBC"),g("1.3.14.3.2.26","sha1"),g("1.3.14.3.2.29","sha1WithRSASignature"),g("2.16.840.1.101.3.4.2.1","sha256"),g("2.16.840.1.101.3.4.2.2","sha384"),g("2.16.840.1.101.3.4.2.3","sha512"),g("2.16.840.1.101.3.4.2.4","sha224"),g("2.16.840.1.101.3.4.2.5","sha512-224"),g("2.16.840.1.101.3.4.2.6","sha512-256"),g("1.2.840.113549.2.2","md2"),g("1.2.840.113549.2.5","md5"),g("1.2.840.113549.1.7.1","data"),g("1.2.840.113549.1.7.2","signedData"),g("1.2.840.113549.1.7.3","envelopedData"),g("1.2.840.113549.1.7.4","signedAndEnvelopedData"),g("1.2.840.113549.1.7.5","digestedData"),g("1.2.840.113549.1.7.6","encryptedData"),g("1.2.840.113549.1.9.1","emailAddress"),g("1.2.840.113549.1.9.2","unstructuredName"),g("1.2.840.113549.1.9.3","contentType"),g("1.2.840.113549.1.9.4","messageDigest"),g("1.2.840.113549.1.9.5","signingTime"),g("1.2.840.113549.1.9.6","counterSignature"),g("1.2.840.113549.1.9.7","challengePassword"),g("1.2.840.113549.1.9.8","unstructuredAddress"),g("1.2.840.113549.1.9.14","extensionRequest"),g("1.2.840.113549.1.9.20","friendlyName"),g("1.2.840.113549.1.9.21","localKeyId"),g("1.2.840.113549.1.9.22.1","x509Certificate"),g("1.2.840.113549.1.12.10.1.1","keyBag"),g("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),g("1.2.840.113549.1.12.10.1.3","certBag"),g("1.2.840.113549.1.12.10.1.4","crlBag"),g("1.2.840.113549.1.12.10.1.5","secretBag"),g("1.2.840.113549.1.12.10.1.6","safeContentsBag"),g("1.2.840.113549.1.5.13","pkcs5PBES2"),g("1.2.840.113549.1.5.12","pkcs5PBKDF2"),g("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),g("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),g("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),g("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),g("1.2.840.113549.2.7","hmacWithSHA1"),g("1.2.840.113549.2.8","hmacWithSHA224"),g("1.2.840.113549.2.9","hmacWithSHA256"),g("1.2.840.113549.2.10","hmacWithSHA384"),g("1.2.840.113549.2.11","hmacWithSHA512"),g("1.2.840.113549.3.7","des-EDE3-CBC"),g("2.16.840.1.101.3.4.1.2","aes128-CBC"),g("2.16.840.1.101.3.4.1.22","aes192-CBC"),g("2.16.840.1.101.3.4.1.42","aes256-CBC"),g("2.5.4.3","commonName"),g("2.5.4.4","surname"),g("2.5.4.5","serialNumber"),g("2.5.4.6","countryName"),g("2.5.4.7","localityName"),g("2.5.4.8","stateOrProvinceName"),g("2.5.4.9","streetAddress"),g("2.5.4.10","organizationName"),g("2.5.4.11","organizationalUnitName"),g("2.5.4.12","title"),g("2.5.4.13","description"),g("2.5.4.15","businessCategory"),g("2.5.4.17","postalCode"),g("2.5.4.42","givenName"),g("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),g("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),g("2.16.840.1.113730.1.1","nsCertType"),g("2.16.840.1.113730.1.13","nsComment"),w("2.5.29.1","authorityKeyIdentifier"),w("2.5.29.2","keyAttributes"),w("2.5.29.3","certificatePolicies"),w("2.5.29.4","keyUsageRestriction"),w("2.5.29.5","policyMapping"),w("2.5.29.6","subtreesConstraint"),w("2.5.29.7","subjectAltName"),w("2.5.29.8","issuerAltName"),w("2.5.29.9","subjectDirectoryAttributes"),w("2.5.29.10","basicConstraints"),w("2.5.29.11","nameConstraints"),w("2.5.29.12","policyConstraints"),w("2.5.29.13","basicConstraints"),g("2.5.29.14","subjectKeyIdentifier"),g("2.5.29.15","keyUsage"),w("2.5.29.16","privateKeyUsagePeriod"),g("2.5.29.17","subjectAltName"),g("2.5.29.18","issuerAltName"),g("2.5.29.19","basicConstraints"),w("2.5.29.20","cRLNumber"),w("2.5.29.21","cRLReason"),w("2.5.29.22","expirationDate"),w("2.5.29.23","instructionCode"),w("2.5.29.24","invalidityDate"),w("2.5.29.25","cRLDistributionPoints"),w("2.5.29.26","issuingDistributionPoint"),w("2.5.29.27","deltaCRLIndicator"),w("2.5.29.28","issuingDistributionPoint"),w("2.5.29.29","certificateIssuer"),w("2.5.29.30","nameConstraints"),g("2.5.29.31","cRLDistributionPoints"),g("2.5.29.32","certificatePolicies"),w("2.5.29.33","policyMappings"),w("2.5.29.34","policyConstraints"),g("2.5.29.35","authorityKeyIdentifier"),w("2.5.29.36","policyConstraints"),g("2.5.29.37","extKeyUsage"),w("2.5.29.46","freshestCRL"),w("2.5.29.54","inhibitAnyPolicy"),g("1.3.6.1.4.1.11129.2.4.2","timestampList"),g("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),g("1.3.6.1.5.5.7.3.1","serverAuth"),g("1.3.6.1.5.5.7.3.2","clientAuth"),g("1.3.6.1.5.5.7.3.3","codeSigning"),g("1.3.6.1.5.5.7.3.4","emailProtection"),g("1.3.6.1.5.5.7.3.8","timeStamping")},2158:(Y,U,x)=>{var y=x(8659);if(x(1298),x(7791),x(279),x(979),x(6078),x(7949),x(8604),x(8365),x(209),x(5517),x(4747),typeof l>"u")var l=y.jsbn.BigInteger;var g=y.asn1,w=y.pki=y.pki||{};Y.exports=w.pbe=y.pbe=y.pbe||{};var m=w.oids,h={name:"EncryptedPrivateKeyInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},c={name:"PBES2Algorithms",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},f={name:"pkcs-12PbeParams",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"iterations"}]};function d(v,p){return v.start().update(p).digest().getBytes()}function b(v){var p;if(v){if(!(p=w.oids[g.derToOid(v)])){var I=new Error("Unsupported PRF OID.");throw I.oid=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}}else p="hmacWithSHA1";return S(p)}function S(v){var p=y.md;switch(v){case"hmacWithSHA224":p=y.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":v=v.substr(8).toLowerCase();break;default:var I=new Error("Unsupported PRF algorithm.");throw I.algorithm=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}if(!p||!(v in p))throw new Error("Unknown hash algorithm: "+v);return p[v].create()}w.encryptPrivateKeyInfo=function(v,p,I){(I=I||{}).saltSize=I.saltSize||8,I.count=I.count||2048,I.algorithm=I.algorithm||"aes128",I.prfAlgorithm=I.prfAlgorithm||"sha1";var T,M,k,A=y.random.getBytesSync(I.saltSize),P=I.count,D=g.integerToDer(P);if(0===I.algorithm.indexOf("aes")||"des"===I.algorithm){var F,G,C;switch(I.algorithm){case"aes128":T=16,F=16,G=m["aes128-CBC"],C=y.aes.createEncryptionCipher;break;case"aes192":T=24,F=16,G=m["aes192-CBC"],C=y.aes.createEncryptionCipher;break;case"aes256":T=32,F=16,G=m["aes256-CBC"],C=y.aes.createEncryptionCipher;break;case"des":T=8,F=8,G=m.desCBC,C=y.des.createEncryptionCipher;break;default:throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O}var V="hmacWith"+I.prfAlgorithm.toUpperCase(),L=S(V),$=y.pkcs5.pbkdf2(p,A,P,T,L),re=y.random.getBytesSync(F);(z=C($)).start(re),z.update(g.toDer(v)),z.finish(),k=z.output.getBytes();var te=function E(v,p,I,A){var P=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,v),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,p.getBytes())]);return"hmacWithSHA1"!==A&&P.value.push(g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,y.util.hexToBytes(I.toString(16))),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(w.oids[A]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")])),P}(A,D,T,V);M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBES2).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBKDF2).getBytes()),te]),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(G).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,re)])])])}else{var O;if("3des"!==I.algorithm)throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O;T=24;var z,X=new y.util.ByteBuffer(A);$=w.pbe.generatePkcs12Key(p,X,1,P,T),re=w.pbe.generatePkcs12Key(p,X,2,P,T),(z=y.des.createEncryptionCipher($)).start(re),z.update(g.toDer(v)),z.finish(),k=z.output.getBytes(),M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,A),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,D.getBytes())])])}return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[M,g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,k)])},w.decryptPrivateKeyInfo=function(v,p){var I=null,A={},P=[];if(!g.validate(v,h,A,P)){var D=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw D.errors=P,D}var T=g.derToOid(A.encryptionOid),M=w.pbe.getCipher(T,A.encryptionParams,p),k=y.util.createBuffer(A.encryptedData);return M.update(k),M.finish()&&(I=g.fromDer(M.output)),I},w.encryptedPrivateKeyToPem=function(v,p){var I={type:"ENCRYPTED PRIVATE KEY",body:g.toDer(v).getBytes()};return y.pem.encode(I,{maxline:p})},w.encryptedPrivateKeyFromPem=function(v){var p=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==p.type){var I=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw I.headerType=p.type,I}if(p.procType&&"ENCRYPTED"===p.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return g.fromDer(p.body)},w.encryptRsaPrivateKey=function(v,p,I){if(!(I=I||{}).legacy){var A=w.wrapRsaPrivateKey(w.privateKeyToAsn1(v));return A=w.encryptPrivateKeyInfo(A,p,I),w.encryptedPrivateKeyToPem(A)}var P,D,T,M;switch(I.algorithm){case"aes128":P="AES-128-CBC",T=16,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes192":P="AES-192-CBC",T=24,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes256":P="AES-256-CBC",T=32,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"3des":P="DES-EDE3-CBC",T=24,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;case"des":P="DES-CBC",T=8,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;default:var k=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+I.algorithm+'".');throw k.algorithm=I.algorithm,k}var G=M(y.pbe.opensslDeriveBytes(p,D.substr(0,8),T));G.start(D),G.update(g.toDer(w.privateKeyToAsn1(v))),G.finish();var C={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:P,parameters:y.util.bytesToHex(D).toUpperCase()},body:G.output.getBytes()};return y.pem.encode(C)},w.decryptRsaPrivateKey=function(v,p){var I=null,A=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==A.type&&"PRIVATE KEY"!==A.type&&"RSA PRIVATE KEY"!==A.type)throw(P=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=P,P;if(A.procType&&"ENCRYPTED"===A.procType.type){var D,T;switch(A.dekInfo.algorithm){case"DES-CBC":D=8,T=y.des.createDecryptionCipher;break;case"DES-EDE3-CBC":D=24,T=y.des.createDecryptionCipher;break;case"AES-128-CBC":D=16,T=y.aes.createDecryptionCipher;break;case"AES-192-CBC":D=24,T=y.aes.createDecryptionCipher;break;case"AES-256-CBC":D=32,T=y.aes.createDecryptionCipher;break;case"RC2-40-CBC":D=5,T=function(C){return y.rc2.createDecryptionCipher(C,40)};break;case"RC2-64-CBC":D=8,T=function(C){return y.rc2.createDecryptionCipher(C,64)};break;case"RC2-128-CBC":D=16,T=function(C){return y.rc2.createDecryptionCipher(C,128)};break;default:var P;throw(P=new Error('Could not decrypt private key; unsupported encryption algorithm "'+A.dekInfo.algorithm+'".')).algorithm=A.dekInfo.algorithm,P}var M=y.util.hexToBytes(A.dekInfo.parameters),F=T(y.pbe.opensslDeriveBytes(p,M.substr(0,8),D));if(F.start(M),F.update(y.util.createBuffer(A.body)),!F.finish())return I;I=F.output.getBytes()}else I=A.body;return null!==(I="ENCRYPTED PRIVATE KEY"===A.type?w.decryptPrivateKeyInfo(g.fromDer(I),p):g.fromDer(I))&&(I=w.privateKeyFromAsn1(I)),I},w.pbe.generatePkcs12Key=function(v,p,I,A,P,D){var T,M;if(typeof D>"u"||null===D){if(!("sha1"in y.md))throw new Error('"sha1" hash algorithm unavailable.');D=y.md.sha1.create()}var k=D.digestLength,F=D.blockLength,G=new y.util.ByteBuffer,C=new y.util.ByteBuffer;if(null!=v){for(M=0;M=0;M--)be>>=8,be+=pe.at(M)+Pe.at(M),Pe.setAt(M,255&be);Se.putBuffer(Pe)}X=Se,G.putBuffer(se)}return G.truncate(G.length()-P),G},w.pbe.getCipher=function(v,p,I){switch(v){case w.oids.pkcs5PBES2:return w.pbe.getCipherForPBES2(v,p,I);case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case w.oids["pbewithSHAAnd40BitRC2-CBC"]:return w.pbe.getCipherForPKCS12PBE(v,p,I);default:var A=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw A.oid=v,A.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],A}},w.pbe.getCipherForPBES2=function(v,p,I){var D,A={},P=[];if(!g.validate(p,c,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;if((v=g.derToOid(A.kdfOid))!==w.oids.pkcs5PBKDF2)throw(D=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=v,D.supportedOids=["pkcs5PBKDF2"],D;if((v=g.derToOid(A.encOid))!==w.oids["aes128-CBC"]&&v!==w.oids["aes192-CBC"]&&v!==w.oids["aes256-CBC"]&&v!==w.oids["des-EDE3-CBC"]&&v!==w.oids.desCBC)throw(D=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=v,D.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],D;var k,F,T=A.kdfSalt,M=y.util.createBuffer(A.kdfIterationCount);switch(M=M.getInt(M.length()<<3),w.oids[v]){case"aes128-CBC":k=16,F=y.aes.createDecryptionCipher;break;case"aes192-CBC":k=24,F=y.aes.createDecryptionCipher;break;case"aes256-CBC":k=32,F=y.aes.createDecryptionCipher;break;case"des-EDE3-CBC":k=24,F=y.des.createDecryptionCipher;break;case"desCBC":k=8,F=y.des.createDecryptionCipher}var G=b(A.prfOid),C=y.pkcs5.pbkdf2(I,T,M,k,G),O=A.encIv,V=F(C);return V.start(O),V},w.pbe.getCipherForPKCS12PBE=function(v,p,I){var A={},P=[];if(!g.validate(p,f,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;var k,F,G,T=y.util.createBuffer(A.salt),M=y.util.createBuffer(A.iterations);switch(M=M.getInt(M.length()<<3),v){case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:k=24,F=8,G=y.des.startDecrypting;break;case w.oids["pbewithSHAAnd40BitRC2-CBC"]:k=5,F=8,G=function($,re){var z=y.rc2.createDecryptionCipher($,40);return z.start(re,null),z};break;default:var D;throw(D=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=v,D}var C=b(A.prfOid),O=w.pbe.generatePkcs12Key(I,T,1,M,k,C);return C.start(),G(O,w.pbe.generatePkcs12Key(I,T,2,M,F,C))},w.pbe.opensslDeriveBytes=function(v,p,I,A){if(typeof A>"u"||null===A){if(!("md5"in y.md))throw new Error('"md5" hash algorithm unavailable.');A=y.md.md5.create()}null===p&&(p="");for(var P=[d(A,v+p)],D=16,T=1;D{var y=x(8659);x(9032),x(979),x(4747);var g,l=y.pkcs5=y.pkcs5||{};y.util.isNodejs&&!y.options.usePureJavaScript&&(g=x(5819)),Y.exports=y.pbkdf2=l.pbkdf2=function(w,m,h,c,f,d){if("function"==typeof f&&(d=f,f=null),y.util.isNodejs&&!y.options.usePureJavaScript&&g.pbkdf2&&(null===f||"object"!=typeof f)&&(g.pbkdf2Sync.length>4||!f||"sha1"===f))return"string"!=typeof f&&(f="sha1"),w=Buffer.from(w,"binary"),m=Buffer.from(m,"binary"),d?4===g.pbkdf2Sync.length?g.pbkdf2(w,m,h,c,function(G,C){if(G)return d(G);d(null,C.toString("binary"))}):g.pbkdf2(w,m,h,c,f,function(G,C){if(G)return d(G);d(null,C.toString("binary"))}):4===g.pbkdf2Sync.length?g.pbkdf2Sync(w,m,h,c).toString("binary"):g.pbkdf2Sync(w,m,h,c,f).toString("binary");if((typeof f>"u"||null===f)&&(f="sha1"),"string"==typeof f){if(!(f in y.md.algorithms))throw new Error("Unknown hash algorithm: "+f);f=y.md[f].create()}var b=f.digestLength;if(c>4294967295*b){var S=new Error("Derived key is too long.");if(d)return d(S);throw S}var E=Math.ceil(c/b),v=c-(E-1)*b,p=y.hmac.create();p.start(f,w);var A,P,D,I="";if(!d){for(var T=1;T<=E;++T){p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes();for(var M=2;M<=h;++M)p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P;I+=TE)return d(null,I);p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes(),M=2,F()}function F(){if(M<=h)return p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P,++M,y.util.setImmediate(F);I+=T{var y=x(8659);x(4747);var l=Y.exports=y.pem=y.pem||{};function g(m){for(var h=m.name+": ",c=[],f=function(v,p){return" "+p},d=0;d65&&-1!==S){var E=h[S];","===E?(++S,h=h.substr(0,S)+"\r\n "+h.substr(S)):h=h.substr(0,S)+"\r\n"+E+h.substr(S+1),b=d-S-1,S=-1,++d}else(" "===h[d]||"\t"===h[d]||","===h[d])&&(S=d);return h}function w(m){return m.replace(/^\s+/,"")}l.encode=function(m,h){h=h||{};var f,c="-----BEGIN "+m.type+"-----\r\n";if(m.procType&&(c+=g(f={name:"Proc-Type",values:[String(m.procType.version),m.procType.type]})),m.contentDomain&&(c+=g(f={name:"Content-Domain",values:[m.contentDomain]})),m.dekInfo&&(f={name:"DEK-Info",values:[m.dekInfo.algorithm]},m.dekInfo.parameters&&f.values.push(m.dekInfo.parameters),c+=g(f)),m.headers)for(var d=0;d{var y=x(8659);x(4747),x(8365),x(7690);var l=Y.exports=y.pkcs1=y.pkcs1||{};function g(w,m,h){h||(h=y.md.sha1.create());for(var c="",f=Math.ceil(m/h.digestLength),d=0;d>24&255,d>>16&255,d>>8&255,255&d);h.start(),h.update(w+b),c+=h.digest().getBytes()}return c.substring(0,m)}l.encode_rsa_oaep=function(w,m,h){var c,f,d,b;"string"==typeof h?(c=h,f=arguments[3]||void 0,d=arguments[4]||void 0):h&&(c=h.label||void 0,f=h.seed||void 0,d=h.md||void 0,h.mgf1&&h.mgf1.md&&(b=h.mgf1.md)),d?d.start():d=y.md.sha1.create(),b||(b=d);var S=Math.ceil(w.n.bitLength()/8),E=S-2*d.digestLength-2;if(m.length>E)throw(v=new Error("RSAES-OAEP input message length is too long.")).length=m.length,v.maxLength=E,v;c||(c=""),d.update(c,"raw");for(var p=d.digest(),I="",A=E-m.length,P=0;P{var y=x(8659);x(1298),x(7791),x(279),x(6078),x(8604),x(4957),x(8365),x(4747),x(5911);var l=y.asn1,g=Y.exports=y.pkcs7=y.pkcs7||{};function w(A){var P={},D=[];if(!l.validate(A,g.asn1.recipientInfoValidator,P,D)){var T=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw T.errors=D,T}return{version:P.version.charCodeAt(0),issuer:y.pki.RDNAttributesAsArray(P.issuer),serialNumber:y.util.createBuffer(P.serial).toHex(),encryptedContent:{algorithm:l.derToOid(P.encAlgorithm),parameter:P.encParameter?P.encParameter.value:void 0,content:P.encKey}}}function m(A){return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(A.version).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[y.pki.distinguishedNameToAsn1({attributes:A.issuer}),l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,y.util.hexToBytes(A.serialNumber))]),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(A.encryptedContent.algorithm).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")]),l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,A.encryptedContent.content)])}function c(A){for(var P=[],D=0;D0){for(var D=l.create(l.Class.CONTEXT_SPECIFIC,1,!0,[]),T=0;T=D&&M0&&F.value[0].value.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!0,T)),k.length>0&&F.value[0].value.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,k)),F.value[0].value.push(l.create(l.Class.UNIVERSAL,l.Type.SET,!0,A.signerInfos)),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(A.type).getBytes()),F])},addSigner:function(T){var M=T.issuer,k=T.serialNumber;if(T.certificate){var F=T.certificate;"string"==typeof F&&(F=y.pki.certificateFromPem(F)),M=F.issuer.attributes,k=F.serialNumber}var G=T.key;if(!G)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof G&&(G=y.pki.privateKeyFromPem(G));var C=T.digestAlgorithm||y.pki.oids.sha1;switch(C){case y.pki.oids.sha1:case y.pki.oids.sha256:case y.pki.oids.sha384:case y.pki.oids.sha512:case y.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+C)}var O=T.authenticatedAttributes||[];if(O.length>0){for(var V=!1,L=!1,$=0;${var y=x(8659);x(7791),x(4747);var l=y.asn1,g=Y.exports=y.pkcs7asn1=y.pkcs7asn1||{};y.pkcs7=y.pkcs7||{},y.pkcs7.asn1=g;var w={name:"ContentInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};g.contentInfoValidator=w;var m={name:"EncryptedContentInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};g.envelopedDataValidator={name:"EnvelopedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(m)},g.encryptedDataValidator={name:"EncryptedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"}].concat(m)},g.signedDataValidator={name:"SignedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},w,{name:"SignedData.Certificates",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,capture:"signerInfos",optional:!0,value:[{name:"SignerInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:l.Class.UNIVERSAL,type:l.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]}]}]},g.recipientInfoValidator={name:"RecipientInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:l.Class.UNIVERSAL,type:l.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},9709:(Y,U,x)=>{var y=x(8659);x(4747),x(730),x(8365),function(){if(y.prime)Y.exports=y.prime;else{var l=Y.exports=y.prime=y.prime||{},g=y.jsbn.BigInteger,w=[6,4,2,4,2,4,6,2],m=new g(null);m.fromInt(30);var h=function(v,p){return v|p};l.generateProbablePrime=function(v,p,I){"function"==typeof p&&(I=p,p={});var A=(p=p||{}).algorithm||"PRIMEINC";"string"==typeof A&&(A={name:A}),A.options=A.options||{};var P=p.prng||y.random;if("PRIMEINC"===A.name)return function c(v,p,I,A){return"workers"in I?function b(v,p,I,A){if(typeof Worker>"u")return f(v,p,I,A);var P=S(v,p),D=I.workers,T=I.workLoad||100,M=30*T/8,k=I.workerScript||"forge/prime.worker.js";if(-1===D)return y.util.estimateCores(function(G,C){G&&(C=2),D=C-1,F()});function F(){D=Math.max(1,D);for(var G=[],C=0;Cv&&(P=S(v,p));var te=P.toString(16);$.target.postMessage({hex:te,workLoad:T}),P.dAddOffset(M,0)}}}F()}(v,p,I,A):f(v,p,I,A)}(v,{nextBytes:function(T){for(var M=P.getBytesSync(T.length),k=0;kp&&(v=S(p,I)),v.isProbablePrime(P))return T(null,v);v.dAddOffset(w[A++%8],0)}while(D<0||+new Date-M{var y=x(8659);x(4747);var l=null;y.util.isNodejs&&!y.options.usePureJavaScript&&!process.versions["node-webkit"]&&(l=x(5819)),(Y.exports=y.prng=y.prng||{}).create=function(w){for(var m={plugin:w,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},h=w.md,c=new Array(32),f=0;f<32;++f)c[f]=h.create();function b(){if(m.pools[0].messageLength>=32)return S();m.collect(m.seedFileSync(32-m.pools[0].messageLength<<5)),S()}function S(){m.reseeds=4294967295===m.reseeds?0:m.reseeds+1;var v=m.plugin.md.create();v.update(m.keyBytes);for(var p=1,I=0;I<32;++I)m.reseeds%p==0&&(v.update(m.pools[I].digest().getBytes()),m.pools[I].start()),p<<=1;m.keyBytes=v.digest().getBytes(),v.start(),v.update(m.keyBytes);var A=v.digest().getBytes();m.key=m.plugin.formatKey(m.keyBytes),m.seed=m.plugin.formatSeed(A),m.generated=0}function E(v){var p=null,I=y.util.globalScope,A=I.crypto||I.msCrypto;A&&A.getRandomValues&&(p=function(O){return A.getRandomValues(O)});var P=y.util.createBuffer();if(p)for(;P.length()>16)))<<16,C=4294967295&(F=(2147483647&(F+=k>>15))+(F>>31)),M=0;M<3;++M)G=C>>>(M<<3),G^=Math.floor(256*Math.random()),P.putByte(255&G);return P.getBytes(v)}return m.pools=c,m.pool=0,m.generate=function(v,p){if(!p)return m.generateSync(v);var I=m.plugin.cipher,A=m.plugin.increment,P=m.plugin.formatKey,D=m.plugin.formatSeed,T=y.util.createBuffer();m.key=null,function M(k){if(k)return p(k);if(T.length()>=v)return p(null,T.getBytes(v));if(m.generated>1048575&&(m.key=null),null===m.key)return y.util.nextTick(function(){!function d(v){if(m.pools[0].messageLength>=32)return S(),v();m.seedFile(32-m.pools[0].messageLength<<5,function(I,A){if(I)return v(I);m.collect(A),S(),v()})}(M)});var F=I(m.key,m.seed);m.generated+=F.length,T.putBytes(F),m.key=P(I(m.key,A(m.seed))),m.seed=D(I(m.key,m.seed)),y.util.setImmediate(M)}()},m.generateSync=function(v){var p=m.plugin.cipher,I=m.plugin.increment,A=m.plugin.formatKey,P=m.plugin.formatSeed;m.key=null;for(var D=y.util.createBuffer();D.length()1048575&&(m.key=null),null===m.key&&b();var T=p(m.key,m.seed);m.generated+=T.length,D.putBytes(T),m.key=A(p(m.key,I(m.seed))),m.seed=P(p(m.key,m.seed))}return D.getBytes(v)},l?(m.seedFile=function(v,p){l.randomBytes(v,function(I,A){if(I)return p(I);p(null,A.toString())})},m.seedFileSync=function(v){return l.randomBytes(v).toString()}):(m.seedFile=function(v,p){try{p(null,E(v))}catch(I){p(I)}},m.seedFileSync=E),m.collect=function(v){for(var p=v.length,I=0;I>A&255);m.collect(I)},m.registerWorker=function(v){v===self?m.seedFile=function(I,A){self.addEventListener("message",function P(D){var T=D.data;T.forge&&T.forge.prng&&(self.removeEventListener("message",P),A(T.forge.prng.err,T.forge.prng.bytes))}),self.postMessage({forge:{prng:{needed:I}}})}:v.addEventListener("message",function(I){var A=I.data;A.forge&&A.forge.prng&&m.seedFile(A.forge.prng.needed,function(P,D){v.postMessage({forge:{prng:{err:P,bytes:D}}})})})},m}},7256:(Y,U,x)=>{var y=x(8659);x(8365),x(4747),(Y.exports=y.pss=y.pss||{}).create=function(g){3===arguments.length&&(g={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var f,w=g.md,m=g.mgf,h=w.digestLength,c=g.salt||null;if("string"==typeof c&&(c=y.util.createBuffer(c)),"saltLength"in g)f=g.saltLength;else{if(null===c)throw new Error("Salt length not specified or specific salt not given.");f=c.length()}if(null!==c&&c.length()!==f)throw new Error("Given salt length does not match length of given salt.");var d=g.prng||y.random,b={encode:function(S,E){var v,P,p=E-1,I=Math.ceil(p/8),A=S.digest().getBytes();if(I>8*I-p&255;return(C=String.fromCharCode(C.charCodeAt(0)&~O)+C.substr(1))+T+String.fromCharCode(188)},verify:function(S,E,v){var p,I=v-1,A=Math.ceil(I/8);if(E=E.substr(-A),A>8*A-I&255;if(0!=(D.charCodeAt(0)&M))throw new Error("Bits beyond keysize not zero as expected.");var k=m.generate(T,P),F="";for(p=0;p{var y=x(8659);x(1298),x(1594),x(4473),x(4747),y.random&&y.random.getBytes?Y.exports=y.random:function(l){var g={},w=new Array(4),m=y.util.createBuffer();function h(){var v=y.prng.create(g);return v.getBytes=function(p,I){return v.generate(p,I)},v.getBytesSync=function(p){return v.generate(p)},v}g.formatKey=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),y.aes._expandKey(v,!1)},g.formatSeed=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),v},g.cipher=function(v,p){return y.aes._updateBlock(v,p,w,!1),m.putInt32(w[0]),m.putInt32(w[1]),m.putInt32(w[2]),m.putInt32(w[3]),m.getBytes()},g.increment=function(v){return++v[3],v},g.md=y.md.sha256;var c=h(),f=null,d=y.util.globalScope,b=d.crypto||d.msCrypto;if(b&&b.getRandomValues&&(f=function(v){return b.getRandomValues(v)}),y.options.usePureJavaScript||!y.util.isNodejs&&!f){if(typeof window>"u"||window,c.collectInt(+new Date,32),typeof navigator<"u"){var S="";for(var E in navigator)try{"string"==typeof navigator[E]&&(S+=navigator[E])}catch{}c.collect(S),S=null}l&&(l().mousemove(function(v){c.collectInt(v.clientX,16),c.collectInt(v.clientY,16)}),l().keypress(function(v){c.collectInt(v.charCode,8)}))}if(y.random)for(var E in c)y.random[E]=c[E];else y.random=c;y.random.createInstance=h,Y.exports=y.random}(typeof jQuery<"u"?jQuery:null)},209:(Y,U,x)=>{var y=x(8659);x(4747);var l=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],g=[1,2,3,5],w=function(c,f){return c<>16-f},m=function(c,f){return(65535&c)>>f|c<<16-f&65535};Y.exports=y.rc2=y.rc2||{},y.rc2.expandKey=function(c,f){"string"==typeof c&&(c=y.util.createBuffer(c)),f=f||128;var p,d=c,b=c.length(),S=f,E=Math.ceil(S/8),v=255>>(7&S);for(p=b;p<128;p++)d.putByte(l[d.at(p-1)+d.at(p-b)&255]);for(d.setAt(128-E,l[d.at(128-E)&v]),p=127-E;p>=0;p--)d.setAt(p,l[d.at(p+1)^d.at(p+E)]);return d};var h=function(c,f,d){var p,I,A,P,b=!1,S=null,E=null,v=null,D=[];for(c=y.rc2.expandKey(c,f),A=0;A<64;A++)D.push(c.getInt16Le());d?(p=function(k){for(A=0;A<4;A++)k[A]+=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),k[A]=w(k[A],g[A]),P++},I=function(k){for(A=0;A<4;A++)k[A]+=D[63&k[(A+3)%4]]}):(p=function(k){for(A=3;A>=0;A--)k[A]=m(k[A],g[A]),k[A]-=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),P--},I=function(k){for(A=3;A>=0;A--)k[A]-=D[63&k[(A+3)%4]]});var T=function(k){var F=[];for(A=0;A<4;A++){var G=S.getInt16Le();null!==v&&(d?G^=v.getInt16Le():v.putInt16Le(G)),F.push(65535&G)}P=d?0:63;for(var C=0;C=8;)T([[5,p],[1,I],[6,p],[1,I],[5,p]])},finish:function(k){var F=!0;if(d)if(k)F=k(8,S,!d);else{var G=8===S.length()?8:8-S.length();S.fillWithByte(G,G)}if(F&&(b=!0,M.update()),!d&&(F=0===S.length()))if(k)F=k(8,E,!d);else{var C=E.length(),O=E.at(C-1);O>C?F=!1:E.truncate(O)}return F}}};y.rc2.startEncrypting=function(c,f,d){var b=y.rc2.createEncryptionCipher(c,128);return b.start(f,d),b},y.rc2.createEncryptionCipher=function(c,f){return h(c,f,!0)},y.rc2.startDecrypting=function(c,f,d){var b=y.rc2.createDecryptionCipher(c,128);return b.start(f,d),b},y.rc2.createDecryptionCipher=function(c,f){return h(c,f,!1)}},5517:(Y,U,x)=>{var y=x(8659);if(x(7791),x(730),x(6078),x(7246),x(9709),x(8365),x(4747),typeof l>"u")var l=y.jsbn.BigInteger;var g=y.util.isNodejs?x(5819):null,w=y.asn1,m=y.util;y.pki=y.pki||{},Y.exports=y.pki.rsa=y.rsa=y.rsa||{};var h=y.pki,c=[6,4,2,4,2,4,6,2],f={name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},d={name:"RSAPrivateKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},b={name:"RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},S=y.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},E={name:"DigestInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:w.Class.UNIVERSAL,type:w.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},v=function(L){if(!(L.algorithm in h.oids)){var re=new Error("Unknown message digest algorithm.");throw re.algorithm=L.algorithm,re}var z=w.oidToDer(h.oids[L.algorithm]).getBytes(),te=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]),X=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]);X.value.push(w.create(w.Class.UNIVERSAL,w.Type.OID,!1,z)),X.value.push(w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,""));var q=w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,L.digest().getBytes());return te.value.push(X),te.value.push(q),w.toDer(te).getBytes()},p=function(L,$,re){if(re)return L.modPow($.e,$.n);if(!$.p||!$.q)return L.modPow($.d,$.n);var z;$.dP||($.dP=$.d.mod($.p.subtract(l.ONE))),$.dQ||($.dQ=$.d.mod($.q.subtract(l.ONE))),$.qInv||($.qInv=$.q.modInverse($.p));do{z=new l(y.util.bytesToHex(y.random.getBytes($.n.bitLength()/8)),16)}while(z.compareTo($.n)>=0||!z.gcd($.n).equals(l.ONE));for(var te=(L=L.multiply(z.modPow($.e,$.n)).mod($.n)).mod($.p).modPow($.dP,$.p),X=L.mod($.q).modPow($.dQ,$.q);te.compareTo(X)<0;)te=te.add($.p);var q=te.subtract(X).multiply($.qInv).mod($.p).multiply($.q).add(X);return q.multiply(z.modInverse($.n)).mod($.n)};function I(L,$,re){var z=y.util.createBuffer(),te=Math.ceil($.n.bitLength()/8);if(L.length>te-11){var X=new Error("Message is too long for PKCS#1 v1.5 padding.");throw X.length=L.length,X.max=te-11,X}z.putByte(0),z.putByte(re);var ne,q=te-3-L.length;if(0===re||1===re){ne=0===re?0:255;for(var se=0;se0;){var de=0,pe=y.random.getBytes(q);for(se=0;se"u")throw new Error("Encryption block is invalid.");var se=0;if(0===ne){se=te-3-z;for(var de=0;de1;){if(255!==X.getByte()){--X.read;break}++se}else if(2===ne)for(se=0;X.length()>1;){if(0===X.getByte()){--X.read;break}++se}if(0!==X.getByte()||se!==te-3-X.length())throw new Error("Encryption block is invalid.");return X.getBytes()}function P(L,$,re){"function"==typeof $&&(re=$,$={});var z={algorithm:{name:($=$||{}).algorithm||"PRIMEINC",options:{workers:$.workers||2,workLoad:$.workLoad||100,workerScript:$.workerScript}}};function te(){X(L.pBits,function(ne,se){return ne?re(ne):(L.p=se,null!==L.q?q(ne,L.q):void X(L.qBits,q))})}function X(ne,se){y.prime.generateProbablePrime(ne,z,se)}function q(ne,se){if(ne)return re(ne);if(L.q=se,L.p.compareTo(L.q)<0){var de=L.p;L.p=L.q,L.q=de}if(0!==L.p.subtract(l.ONE).gcd(L.e).compareTo(l.ONE))return L.p=null,void te();if(0!==L.q.subtract(l.ONE).gcd(L.e).compareTo(l.ONE))return L.q=null,void X(L.qBits,q);if(L.p1=L.p.subtract(l.ONE),L.q1=L.q.subtract(l.ONE),L.phi=L.p1.multiply(L.q1),0!==L.phi.gcd(L.e).compareTo(l.ONE))return L.p=L.q=null,void te();if(L.n=L.p.multiply(L.q),L.n.bitLength()!==L.bits)return L.q=null,void X(L.qBits,q);var pe=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,pe,L.p,L.q,pe.mod(L.p1),pe.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)},re(null,L.keys)}"prng"in $&&(z.prng=$.prng),te()}function D(L){var $=L.toString(16);$[0]>="8"&&($="00"+$);var re=y.util.hexToBytes($);return re.length>1&&(0===re.charCodeAt(0)&&0==(128&re.charCodeAt(1))||255===re.charCodeAt(0)&&128==(128&re.charCodeAt(1)))?re.substr(1):re}function T(L){return L<=100?27:L<=150?18:L<=200?15:L<=250?12:L<=300?9:L<=350?8:L<=400?7:L<=500?6:L<=600?5:L<=800?4:L<=1250?3:2}function M(L){return y.util.isNodejs&&"function"==typeof g[L]}function k(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.crypto&&"object"==typeof m.globalScope.crypto.subtle&&"function"==typeof m.globalScope.crypto.subtle[L]}function F(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.msCrypto&&"object"==typeof m.globalScope.msCrypto.subtle&&"function"==typeof m.globalScope.msCrypto.subtle[L]}function G(L){for(var $=y.util.hexToBytes(L.toString(16)),re=new Uint8Array($.length),z=0;z<$.length;++z)re[z]=$.charCodeAt(z);return re}h.rsa.encrypt=function(L,$,re){var te,z=re,X=Math.ceil($.n.bitLength()/8);!1!==re&&!0!==re?(z=2===re,te=I(L,$,re)):(te=y.util.createBuffer()).putBytes(L);for(var q=new l(te.toHex(),16),se=p(q,$,z).toString(16),de=y.util.createBuffer(),pe=X-Math.ceil(se.length/2);pe>0;)de.putByte(0),--pe;return de.putBytes(y.util.hexToBytes(se)),de.getBytes()},h.rsa.decrypt=function(L,$,re,z){var te=Math.ceil($.n.bitLength()/8);if(L.length!==te){var X=new Error("Encrypted message length is invalid.");throw X.length=L.length,X.expected=te,X}var q=new l(y.util.createBuffer(L).toHex(),16);if(q.compareTo($.n)>=0)throw new Error("Encrypted message is invalid.");for(var se=p(q,$,re).toString(16),de=y.util.createBuffer(),pe=te-Math.ceil(se.length/2);pe>0;)de.putByte(0),--pe;return de.putBytes(y.util.hexToBytes(se)),!1!==z?A(de.getBytes(),$,re):de.getBytes()},h.rsa.createKeyPairGenerationState=function(L,$,re){"string"==typeof L&&(L=parseInt(L,10)),L=L||2048;var q,z=(re=re||{}).prng||y.random,te={nextBytes:function(ne){for(var se=z.getBytesSync(ne.length),de=0;de>1,pBits:L-(L>>1),pqState:0,num:null,keys:null}).e.fromInt(q.eInt),q},h.rsa.stepKeyPairGenerationState=function(L,$){"algorithm"in L||(L.algorithm="PRIMEINC");var re=new l(null);re.fromInt(30);for(var q,z=0,te=function(Le,Se){return Le|Se},X=+new Date,ne=0;null===L.keys&&($<=0||ne<$);){if(0===L.state){var se=null===L.p?L.pBits:L.qBits,de=se-1;0===L.pqState?(L.num=new l(se,L.rng),L.num.testBit(de)||L.num.bitwiseTo(l.ONE.shiftLeft(de),te,L.num),L.num.dAddOffset(31-L.num.mod(re).byteValue(),0),z=0,++L.pqState):1===L.pqState?L.num.bitLength()>se?L.pqState=0:L.num.isProbablePrime(T(L.num.bitLength()))?++L.pqState:L.num.dAddOffset(c[z++%8],0):2===L.pqState?L.pqState=0===L.num.subtract(l.ONE).gcd(L.e).compareTo(l.ONE)?3:0:3===L.pqState&&(L.pqState=0,null===L.p?L.p=L.num:L.q=L.num,null!==L.p&&null!==L.q&&++L.state,L.num=null)}else if(1===L.state)L.p.compareTo(L.q)<0&&(L.num=L.p,L.p=L.q,L.q=L.num),++L.state;else if(2===L.state)L.p1=L.p.subtract(l.ONE),L.q1=L.q.subtract(l.ONE),L.phi=L.p1.multiply(L.q1),++L.state;else if(3===L.state)0===L.phi.gcd(L.e).compareTo(l.ONE)?++L.state:(L.p=null,L.q=null,L.state=0);else if(4===L.state)L.n=L.p.multiply(L.q),L.n.bitLength()===L.bits?++L.state:(L.q=null,L.state=0);else if(5===L.state){var pe=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,pe,L.p,L.q,pe.mod(L.p1),pe.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)}}ne+=(q=+new Date)-X,X=q}return null!==L.keys},h.rsa.generateKeyPair=function(L,$,re,z){if(1===arguments.length?"object"==typeof L?(re=L,L=void 0):"function"==typeof L&&(z=L,L=void 0):2===arguments.length?"number"==typeof L?"function"==typeof $?(z=$,$=void 0):"number"!=typeof $&&(re=$,$=void 0):(re=L,z=$,L=void 0,$=void 0):3===arguments.length&&("number"==typeof $?"function"==typeof re&&(z=re,re=void 0):(z=re,re=$,$=void 0)),re=re||{},void 0===L&&(L=re.bits||2048),void 0===$&&($=re.e||65537),!y.options.usePureJavaScript&&!re.prng&&L>=256&&L<=16384&&(65537===$||3===$))if(z){if(M("generateKeyPair"))return g.generateKeyPair("rsa",{modulusLength:L,publicExponent:$,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(ne,se,de){if(ne)return z(ne);z(null,{privateKey:h.privateKeyFromPem(de),publicKey:h.publicKeyFromPem(se)})});if(k("generateKey")&&k("exportKey"))return m.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:G($),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(ne){return m.globalScope.crypto.subtle.exportKey("pkcs8",ne.privateKey)}).then(void 0,function(ne){z(ne)}).then(function(ne){if(ne){var se=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(ne)));z(null,{privateKey:se,publicKey:h.setRsaPublicKey(se.n,se.e)})}});if(F("generateKey")&&F("exportKey")){var te=m.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:G($),hash:{name:"SHA-256"}},!0,["sign","verify"]);return te.oncomplete=function(ne){var de=m.globalScope.msCrypto.subtle.exportKey("pkcs8",ne.target.result.privateKey);de.oncomplete=function(pe){var Se=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(pe.target.result)));z(null,{privateKey:Se,publicKey:h.setRsaPublicKey(Se.n,Se.e)})},de.onerror=function(pe){z(pe)}},void(te.onerror=function(ne){z(ne)})}}else if(M("generateKeyPairSync")){var X=g.generateKeyPairSync("rsa",{modulusLength:L,publicExponent:$,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:h.privateKeyFromPem(X.privateKey),publicKey:h.publicKeyFromPem(X.publicKey)}}var q=h.rsa.createKeyPairGenerationState(L,$,re);if(!z)return h.rsa.stepKeyPairGenerationState(q,0),q.keys;P(q,re,z)},h.setRsaPublicKey=h.rsa.setPublicKey=function(L,$){var re={n:L,e:$,encrypt:function(z,te,X){if("string"==typeof te?te=te.toUpperCase():void 0===te&&(te="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===te)te={encode:function(ne,se,de){return I(ne,se,2).getBytes()}};else if("RSA-OAEP"===te||"RSAES-OAEP"===te)te={encode:function(ne,se){return y.pkcs1.encode_rsa_oaep(se,ne,X)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(te))te={encode:function(ne){return ne}};else if("string"==typeof te)throw new Error('Unsupported encryption scheme: "'+te+'".');var q=te.encode(z,re,!0);return h.rsa.encrypt(q,re,!0)},verify:function(z,te,X,q){"string"==typeof X?X=X.toUpperCase():void 0===X&&(X="RSASSA-PKCS1-V1_5"),void 0===q&&(q={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in q||(q._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===X?X={verify:function(se,de){de=A(de,re,!0);var pe=w.fromDer(de,{parseAllBytes:q._parseAllDigestBytes}),Le={},Se=[];if(!w.validate(pe,E,Le,Se))throw(Pe=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=Se,Pe;var Pe,be=w.derToOid(Le.algorithmIdentifier);if(be!==y.oids.md2&&be!==y.oids.md5&&be!==y.oids.sha1&&be!==y.oids.sha224&&be!==y.oids.sha256&&be!==y.oids.sha384&&be!==y.oids.sha512&&be!==y.oids["sha512-224"]&&be!==y.oids["sha512-256"])throw(Pe=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=be,Pe;if((be===y.oids.md2||be===y.oids.md5)&&!("parameters"in Le))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return se===Le.digest}}:("NONE"===X||"NULL"===X||null===X)&&(X={verify:function(se,de){return se===A(de,re,!0)}});var ne=h.rsa.decrypt(te,re,!0,!1);return X.verify(z,ne,re.n.bitLength())}};return re},h.setRsaPrivateKey=h.rsa.setPrivateKey=function(L,$,re,z,te,X,q,ne){var se={n:L,e:$,d:re,p:z,q:te,dP:X,dQ:q,qInv:ne,decrypt:function(de,pe,Le){"string"==typeof pe?pe=pe.toUpperCase():void 0===pe&&(pe="RSAES-PKCS1-V1_5");var Se=h.rsa.decrypt(de,se,!1,!1);if("RSAES-PKCS1-V1_5"===pe)pe={decode:A};else if("RSA-OAEP"===pe||"RSAES-OAEP"===pe)pe={decode:function(Pe,be){return y.pkcs1.decode_rsa_oaep(be,Pe,Le)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(pe))throw new Error('Unsupported encryption scheme: "'+pe+'".');pe={decode:function(Pe){return Pe}}}return pe.decode(Se,se,!1)},sign:function(de,pe){var Le=!1;"string"==typeof pe&&(pe=pe.toUpperCase()),void 0===pe||"RSASSA-PKCS1-V1_5"===pe?(pe={encode:v},Le=1):("NONE"===pe||"NULL"===pe||null===pe)&&(pe={encode:function(){return de}},Le=1);var Se=pe.encode(de,se.n.bitLength());return h.rsa.encrypt(Se,se,Le)}};return se},h.wrapRsaPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,w.toDer(L).getBytes())])},h.privateKeyFromAsn1=function(L){var te,X,q,ne,se,de,pe,Le,$={},re=[];if(w.validate(L,f,$,re)&&(L=w.fromDer(y.util.createBuffer($.privateKey))),!w.validate(L,d,$={},re=[])){var z=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw z.errors=re,z}return te=y.util.createBuffer($.privateKeyModulus).toHex(),X=y.util.createBuffer($.privateKeyPublicExponent).toHex(),q=y.util.createBuffer($.privateKeyPrivateExponent).toHex(),ne=y.util.createBuffer($.privateKeyPrime1).toHex(),se=y.util.createBuffer($.privateKeyPrime2).toHex(),de=y.util.createBuffer($.privateKeyExponent1).toHex(),pe=y.util.createBuffer($.privateKeyExponent2).toHex(),Le=y.util.createBuffer($.privateKeyCoefficient).toHex(),h.setRsaPrivateKey(new l(te,16),new l(X,16),new l(q,16),new l(ne,16),new l(se,16),new l(de,16),new l(pe,16),new l(Le,16))},h.privateKeyToAsn1=h.privateKeyToRSAPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.d)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.p)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.q)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dP)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dQ)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.qInv))])},h.publicKeyFromAsn1=function(L){var $={},re=[];if(w.validate(L,S,$,re)){var te,z=w.derToOid($.publicKeyOid);if(z!==h.oids.rsaEncryption)throw(te=new Error("Cannot read public key. Unknown OID.")).oid=z,te;L=$.rsaPublicKey}if(!w.validate(L,b,$,re=[]))throw(te=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=re,te;var X=y.util.createBuffer($.publicKeyModulus).toHex(),q=y.util.createBuffer($.publicKeyExponent).toHex();return h.setRsaPublicKey(new l(X,16),new l(q,16))},h.publicKeyToAsn1=h.publicKeyToSubjectPublicKeyInfo=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.BITSTRING,!1,[h.publicKeyToRSAPublicKey(L)])])},h.publicKeyToRSAPublicKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e))])}},7690:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha1=y.sha1||{};y.md.sha1=y.md.algorithms.sha1=l,l.create=function(){w||function m(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),w=!0}();var c=null,f=y.util.createBuffer(),d=new Array(80),b={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){b.messageLength=0,b.fullMessageLength=b.messageLength64=[];for(var S=b.messageLengthSize/4,E=0;E>>0,v>>>0];for(var p=b.fullMessageLength.length-1;p>=0;--p)b.fullMessageLength[p]+=v[1],v[1]=v[0]+(b.fullMessageLength[p]/4294967296>>>0),b.fullMessageLength[p]=b.fullMessageLength[p]>>>0,v[0]=v[1]/4294967296>>>0;return f.putBytes(S),h(c,d,f),(f.read>2048||0===f.length())&&f.compact(),b},b.digest=function(){var S=y.util.createBuffer();S.putBytes(f.bytes()),S.putBytes(g.substr(0,b.blockLength-(b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize&b.blockLength-1)));for(var p,A=8*b.fullMessageLength[0],P=0;P>>0)>>>0),A=p>>>0;S.putInt32(A);var D={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3,h4:c.h4};h(D,d,S);var T=y.util.createBuffer();return T.putInt32(D.h0),T.putInt32(D.h1),T.putInt32(D.h2),T.putInt32(D.h3),T.putInt32(D.h4),T},b};var g=null,w=!1;function h(c,f,d){for(var b,S,E,v,p,I,P,D=d.length();D>=64;){for(S=c.h0,E=c.h1,v=c.h2,p=c.h3,I=c.h4,P=0;P<16;++P)b=d.getInt32(),f[P]=b,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<20;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<32;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<40;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<60;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E&v|p&(E^v))+I+2400959708+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<80;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+3395469782+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;c.h0=c.h0+S|0,c.h1=c.h1+E|0,c.h2=c.h2+v|0,c.h3=c.h3+p|0,c.h4=c.h4+I|0,D-=64}}},1594:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha256=y.sha256||{};y.md.sha256=y.md.algorithms.sha256=l,l.create=function(){w||function h(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),m=[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],w=!0}();var f=null,d=y.util.createBuffer(),b=new Array(64),S={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];for(var E=S.messageLengthSize/4,v=0;v>>0,p>>>0];for(var I=S.fullMessageLength.length-1;I>=0;--I)S.fullMessageLength[I]+=p[1],p[1]=p[0]+(S.fullMessageLength[I]/4294967296>>>0),S.fullMessageLength[I]=S.fullMessageLength[I]>>>0,p[0]=p[1]/4294967296>>>0;return d.putBytes(E),c(f,b,d),(d.read>2048||0===d.length())&&d.compact(),S},S.digest=function(){var E=y.util.createBuffer();E.putBytes(d.bytes()),E.putBytes(g.substr(0,S.blockLength-(S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize&S.blockLength-1)));for(var I,P=8*S.fullMessageLength[0],D=0;D>>0)>>>0),P=I>>>0;E.putInt32(P);var T={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4,h5:f.h5,h6:f.h6,h7:f.h7};c(T,b,E);var M=y.util.createBuffer();return M.putInt32(T.h0),M.putInt32(T.h1),M.putInt32(T.h2),M.putInt32(T.h3),M.putInt32(T.h4),M.putInt32(T.h5),M.putInt32(T.h6),M.putInt32(T.h7),M},S};var g=null,w=!1,m=null;function c(f,d,b){for(var S,E,A,P,D,T,M,k,F,G,C,O,V=b.length();V>=64;){for(P=0;P<16;++P)d[P]=b.getInt32();for(;P<64;++P)d[P]=(S=((S=d[P-2])>>>17|S<<15)^(S>>>19|S<<13)^S>>>10)+d[P-7]+(E=((E=d[P-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3)+d[P-16]|0;for(D=f.h0,T=f.h1,M=f.h2,k=f.h3,F=f.h4,G=f.h5,C=f.h6,O=f.h7,P=0;P<64;++P)A=D&T|M&(D^T),S=O+((F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7))+(C^F&(G^C))+m[P]+d[P],O=C,C=G,G=F,F=k+S>>>0,k=M,M=T,T=D,D=S+(E=((D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10))+A)>>>0;f.h0=f.h0+D|0,f.h1=f.h1+T|0,f.h2=f.h2+M|0,f.h3=f.h3+k|0,f.h4=f.h4+F|0,f.h5=f.h5+G|0,f.h6=f.h6+C|0,f.h7=f.h7+O|0,V-=64}}},8985:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha512=y.sha512||{};y.md.sha512=y.md.algorithms.sha512=l;var g=y.sha384=y.sha512.sha384=y.sha512.sha384||{};g.create=function(){return l.create("SHA-384")},y.md.sha384=y.md.algorithms.sha384=g,y.sha512.sha256=y.sha512.sha256||{create:function(){return l.create("SHA-512/256")}},y.md["sha512/256"]=y.md.algorithms["sha512/256"]=y.sha512.sha256,y.sha512.sha224=y.sha512.sha224||{create:function(){return l.create("SHA-512/224")}},y.md["sha512/224"]=y.md.algorithms["sha512/224"]=y.sha512.sha224,l.create=function(b){if(m||function f(){w=String.fromCharCode(128),w+=y.util.fillString(String.fromCharCode(0),128),h=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(c={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],m=!0}(),typeof b>"u"&&(b="SHA-512"),!(b in c))throw new Error("Invalid SHA-512 algorithm: "+b);for(var S=c[b],E=null,v=y.util.createBuffer(),p=new Array(80),I=0;I<80;++I)p[I]=new Array(2);var A=64;switch(b){case"SHA-384":A=48;break;case"SHA-512/256":A=32;break;case"SHA-512/224":A=28}var P={algorithm:b.replace("-","").toLowerCase(),blockLength:128,digestLength:A,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){P.messageLength=0,P.fullMessageLength=P.messageLength128=[];for(var D=P.messageLengthSize/4,T=0;T>>0,M>>>0];for(var k=P.fullMessageLength.length-1;k>=0;--k)P.fullMessageLength[k]+=M[1],M[1]=M[0]+(P.fullMessageLength[k]/4294967296>>>0),P.fullMessageLength[k]=P.fullMessageLength[k]>>>0,M[0]=M[1]/4294967296>>>0;return v.putBytes(D),d(E,p,v),(v.read>2048||0===v.length())&&v.compact(),P},P.digest=function(){var D=y.util.createBuffer();D.putBytes(v.bytes()),D.putBytes(w.substr(0,P.blockLength-(P.fullMessageLength[P.fullMessageLength.length-1]+P.messageLengthSize&P.blockLength-1)));for(var k,G=8*P.fullMessageLength[0],C=0;C>>0)>>>0),G=k>>>0;D.putInt32(G);var O=new Array(E.length);for(C=0;C=128;){for(be=0;be<16;++be)S[be][0]=E.getInt32()>>>0,S[be][1]=E.getInt32()>>>0;for(;be<80;++be)p=((($e=(Ee=S[be-2])[0])<<13|(H=Ee[1])>>>19)^(H<<3|$e>>>29)^($e<<26|H>>>6))>>>0,S[be][0]=(v=(($e>>>19|H<<13)^(H>>>29|$e<<3)^$e>>>6)>>>0)+(Te=S[be-7])[0]+(I=((($e=(xe=S[be-15])[0])>>>1|(H=xe[1])<<31)^($e>>>8|H<<24)^$e>>>7)>>>0)+(He=S[be-16])[0]+((H=p+Te[1]+(A=(($e<<31|H>>>1)^($e<<24|H>>>8)^($e<<25|H>>>7))>>>0)+He[1])/4294967296>>>0)>>>0,S[be][1]=H>>>0;for(O=b[0][0],V=b[0][1],L=b[1][0],$=b[1][1],re=b[2][0],z=b[2][1],te=b[3][0],X=b[3][1],q=b[4][0],ne=b[4][1],se=b[5][0],de=b[5][1],pe=b[6][0],Le=b[6][1],Se=b[7][0],Pe=b[7][1],be=0;be<80;++be)v=Se+(((q>>>14|ne<<18)^(q>>>18|ne<<14)^(ne>>>9|q<<23))>>>0)+((pe^q&(se^pe))>>>0)+h[be][0]+S[be][0]+((H=Pe+(((q<<18|ne>>>14)^(q<<14|ne>>>18)^(ne<<23|q>>>9))>>>0)+((Le^ne&(de^Le))>>>0)+h[be][1]+S[be][1])/4294967296>>>0)>>>0,p=H>>>0,I=(((O>>>28|V<<4)^(V>>>2|O<<30)^(V>>>7|O<<25))>>>0)+((O&L|re&(O^L))>>>0)+((H=(((O<<4|V>>>28)^(V<<30|O>>>2)^(V<<25|O>>>7))>>>0)+((V&$|z&(V^$))>>>0))/4294967296>>>0)>>>0,A=H>>>0,Se=pe,Pe=Le,pe=se,Le=de,se=q,de=ne,q=te+v+((H=X+p)/4294967296>>>0)>>>0,ne=H>>>0,te=re,X=z,re=L,z=$,L=O,$=V,O=v+I+((H=p+A)/4294967296>>>0)>>>0,V=H>>>0;b[0][0]=b[0][0]+O+((H=b[0][1]+V)/4294967296>>>0)>>>0,b[0][1]=H>>>0,b[1][0]=b[1][0]+L+((H=b[1][1]+$)/4294967296>>>0)>>>0,b[1][1]=H>>>0,b[2][0]=b[2][0]+re+((H=b[2][1]+z)/4294967296>>>0)>>>0,b[2][1]=H>>>0,b[3][0]=b[3][0]+te+((H=b[3][1]+X)/4294967296>>>0)>>>0,b[3][1]=H>>>0,b[4][0]=b[4][0]+q+((H=b[4][1]+ne)/4294967296>>>0)>>>0,b[4][1]=H>>>0,b[5][0]=b[5][0]+se+((H=b[5][1]+de)/4294967296>>>0)>>>0,b[5][1]=H>>>0,b[6][0]=b[6][0]+pe+((H=b[6][1]+Le)/4294967296>>>0)>>>0,b[6][1]=H>>>0,b[7][0]=b[7][0]+Se+((H=b[7][1]+Pe)/4294967296>>>0)>>>0,b[7][1]=H>>>0,We-=128}}},4747:(Y,U,x)=>{var y=x(8659),l=x(2020),g=Y.exports=y.util=y.util||{};function w(D){if(8!==D&&16!==D&&24!==D&&32!==D)throw new Error("Only 8, 16, 24, or 32 bits supported: "+D)}function m(D){if(this.data="",this.read=0,"string"==typeof D)this.data=D;else if(g.isArrayBuffer(D)||g.isArrayBufferView(D))if(typeof Buffer<"u"&&D instanceof Buffer)this.data=D.toString("binary");else{var T=new Uint8Array(D);try{this.data=String.fromCharCode.apply(null,T)}catch{for(var M=0;M15?(M=Date.now(),G(V)):(T.push(V),1===T.length&&F.setAttribute("a",k=!k))}}g.nextTick=g.setImmediate})(),g.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,g.globalScope=g.isNodejs?global:typeof self>"u"?window:self,g.isArray=Array.isArray||function(D){return"[object Array]"===Object.prototype.toString.call(D)},g.isArrayBuffer=function(D){return typeof ArrayBuffer<"u"&&D instanceof ArrayBuffer},g.isArrayBufferView=function(D){return D&&g.isArrayBuffer(D.buffer)&&void 0!==D.byteLength},g.ByteBuffer=m,g.ByteStringBuffer=m,g.ByteStringBuffer.prototype._optimizeConstructedString=function(D){this._constructedStringLength+=D,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},g.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},g.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},g.ByteStringBuffer.prototype.putByte=function(D){return this.putBytes(String.fromCharCode(D))},g.ByteStringBuffer.prototype.fillWithByte=function(D,T){D=String.fromCharCode(D);for(var M=this.data;T>0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return this.data=M,this._optimizeConstructedString(T),this},g.ByteStringBuffer.prototype.putBytes=function(D){return this.data+=D,this._optimizeConstructedString(D.length),this},g.ByteStringBuffer.prototype.putString=function(D){return this.putBytes(g.encodeUtf8(D))},g.ByteStringBuffer.prototype.putInt16=function(D){return this.putBytes(String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt24=function(D){return this.putBytes(String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt32=function(D){return this.putBytes(String.fromCharCode(D>>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt16Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255))},g.ByteStringBuffer.prototype.putInt24Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255))},g.ByteStringBuffer.prototype.putInt32Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>24&255))},g.ByteStringBuffer.prototype.putInt=function(D,T){w(T);var M="";do{T-=8,M+=String.fromCharCode(D>>T&255)}while(T>0);return this.putBytes(M)},g.ByteStringBuffer.prototype.putSignedInt=function(D,T){return D<0&&(D+=2<0);return T},g.ByteStringBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.ByteStringBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.ByteStringBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.ByteStringBuffer.prototype.at=function(D){return this.data.charCodeAt(this.read+D)},g.ByteStringBuffer.prototype.setAt=function(D,T){return this.data=this.data.substr(0,this.read+D)+String.fromCharCode(T)+this.data.substr(this.read+D+1),this},g.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},g.ByteStringBuffer.prototype.copy=function(){var D=g.createBuffer(this.data);return D.read=this.read,D},g.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},g.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},g.ByteStringBuffer.prototype.truncate=function(D){var T=Math.max(0,this.length()-D);return this.data=this.data.substr(this.read,T),this.read=0,this},g.ByteStringBuffer.prototype.toHex=function(){for(var D="",T=this.read;T=D)return this;T=Math.max(T||this.growSize,D);var M=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),k=new Uint8Array(this.length()+T);return k.set(M),this.data=new DataView(k.buffer),this},g.DataBuffer.prototype.putByte=function(D){return this.accommodate(1),this.data.setUint8(this.write++,D),this},g.DataBuffer.prototype.fillWithByte=function(D,T){this.accommodate(T);for(var M=0;M>8&65535),this.data.setInt8(this.write,D>>16&255),this.write+=3,this},g.DataBuffer.prototype.putInt32=function(D){return this.accommodate(4),this.data.setInt32(this.write,D),this.write+=4,this},g.DataBuffer.prototype.putInt16Le=function(D){return this.accommodate(2),this.data.setInt16(this.write,D,!0),this.write+=2,this},g.DataBuffer.prototype.putInt24Le=function(D){return this.accommodate(3),this.data.setInt8(this.write,D>>16&255),this.data.setInt16(this.write,D>>8&65535,!0),this.write+=3,this},g.DataBuffer.prototype.putInt32Le=function(D){return this.accommodate(4),this.data.setInt32(this.write,D,!0),this.write+=4,this},g.DataBuffer.prototype.putInt=function(D,T){w(T),this.accommodate(T/8);do{T-=8,this.data.setInt8(this.write++,D>>T&255)}while(T>0);return this},g.DataBuffer.prototype.putSignedInt=function(D,T){return w(T),this.accommodate(T/8),D<0&&(D+=2<0);return T},g.DataBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.DataBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.DataBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.DataBuffer.prototype.at=function(D){return this.data.getUint8(this.read+D)},g.DataBuffer.prototype.setAt=function(D,T){return this.data.setUint8(D,T),this},g.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},g.DataBuffer.prototype.copy=function(){return new g.DataBuffer(this)},g.DataBuffer.prototype.compact=function(){if(this.read>0){var D=new Uint8Array(this.data.buffer,this.read),T=new Uint8Array(D.byteLength);T.set(D),this.data=new DataView(T),this.write-=this.read,this.read=0}return this},g.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},g.DataBuffer.prototype.truncate=function(D){return this.write=Math.max(0,this.length()-D),this.read=Math.min(this.read,this.write),this},g.DataBuffer.prototype.toHex=function(){for(var D="",T=this.read;T0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return M},g.xorBytes=function(D,T,M){for(var k="",F="",G="",C=0,O=0;M>0;--M,++C)F=D.charCodeAt(C)^T.charCodeAt(C),O>=10&&(k+=G,G="",O=0),G+=String.fromCharCode(F),++O;return k+G},g.hexToBytes=function(D){var T="",M=0;for(!0&D.length&&(M=1,T+=String.fromCharCode(parseInt(D[0],16)));M>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D)};var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";g.encode64=function(D,T){for(var F,G,C,M="",k="",O=0;O>2),M+=f.charAt((3&F)<<4|G>>4),isNaN(G)?M+="==":(M+=f.charAt((15&G)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.decode64=function(D){D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var M,k,F,G,T="",C=0;C>4),64!==F&&(T+=String.fromCharCode((15&k)<<4|F>>2),64!==G&&(T+=String.fromCharCode((3&F)<<6|G)));return T},g.encodeUtf8=function(D){return unescape(encodeURIComponent(D))},g.decodeUtf8=function(D){return decodeURIComponent(escape(D))},g.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:l.encode,decode:l.decode}},g.binary.raw.encode=function(D){return String.fromCharCode.apply(null,D)},g.binary.raw.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,G=0;G>2),M+=f.charAt((3&F)<<4|G>>4),isNaN(G)?M+="==":(M+=f.charAt((15&G)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.binary.base64.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(3*Math.ceil(D.length/4))),D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var F,G,C,O,V=0,L=M=M||0;V>4,64!==C&&(k[L++]=(15&G)<<4|C>>2,64!==O&&(k[L++]=(3&C)<<6|O));return T?L-M:k.subarray(0,L)},g.binary.base58.encode=function(D,T){return g.binary.baseN.encode(D,b,T)},g.binary.base58.decode=function(D,T){return g.binary.baseN.decode(D,b,T)},g.text={utf8:{},utf16:{}},g.text.utf8.encode=function(D,T,M){D=g.encodeUtf8(D);var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,G=0;G"u"&&(M=["web","flash"]);var F,G=!1,C=null;for(var O in M){F=M[O];try{if("flash"===F||"both"===F){if(null===T[0])throw new Error("Flash local storage not available.");k=D.apply(this,T),G="flash"===F}("web"===F||"both"===F)&&(T[0]=localStorage,k=D.apply(this,T),G=!0)}catch(V){C=V}if(G)break}if(!G)throw C;return k};g.setItem=function(D,T,M,k,F){P(v,arguments,F)},g.getItem=function(D,T,M,k){return P(p,arguments,k)},g.removeItem=function(D,T,M,k){P(I,arguments,k)},g.clearItems=function(D,T,M){P(A,arguments,M)},g.isEmpty=function(D){for(var T in D)if(D.hasOwnProperty(T))return!1;return!0},g.format=function(D){for(var M,k,T=/%./g,F=0,G=[],C=0;M=T.exec(D);){(k=D.substring(C,T.lastIndex-2)).length>0&&G.push(k),C=T.lastIndex;var O=M[0][1];switch(O){case"s":case"o":G.push(F");break;case"%":G.push("%");break;default:G.push("<%"+O+"?>")}}return G.push(D.substring(C)),G.join("")},g.formatNumber=function(D,T,M,k){var F=D,G=isNaN(T=Math.abs(T))?2:T,C=void 0===M?",":M,O=void 0===k?".":k,V=F<0?"-":"",L=parseInt(F=Math.abs(+F||0).toFixed(G),10)+"",$=L.length>3?L.length%3:0;return V+($?L.substr(0,$)+O:"")+L.substr($).replace(/(\d{3})(?=\d)/g,"$1"+O)+(G?C+Math.abs(F-L).toFixed(G).slice(2):"")},g.formatSize=function(D){return D>=1073741824?g.formatNumber(D/1073741824,2,".","")+" GiB":D>=1048576?g.formatNumber(D/1048576,2,".","")+" MiB":D>=1024?g.formatNumber(D/1024,0)+" KiB":g.formatNumber(D,0)+" bytes"},g.bytesFromIP=function(D){return-1!==D.indexOf(".")?g.bytesFromIPv4(D):-1!==D.indexOf(":")?g.bytesFromIPv6(D):null},g.bytesFromIPv4=function(D){if(4!==(D=D.split(".")).length)return null;for(var T=g.createBuffer(),M=0;MM[k].end-M[k].start&&(k=M.length-1)):M.push({start:O,end:O})}T.push(G)}if(M.length>0){var V=M[k];V.end-V.start>0&&(T.splice(V.start,V.end-V.start+1,""),0===V.start&&T.unshift(""),7===V.end&&T.push(""))}return T.join(":")},g.estimateCores=function(D,T){if("function"==typeof D&&(T=D,D={}),D=D||{},"cores"in g&&!D.update)return T(null,g.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return g.cores=navigator.hardwareConcurrency,T(null,g.cores);if(typeof Worker>"u")return g.cores=1,T(null,g.cores);if(typeof Blob>"u")return g.cores=2,T(null,g.cores);var M=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(C){for(var O=Date.now(),V=O+4;Date.now()te.st&&$.st$.st&&te.st<$.et)&&re.push(z)}return V.reduce(function(X,q){return Math.max(X,q.length)},0)}(V,re)),k(C,O-1,V)})}([],5,16)}},5911:(Y,U,x)=>{var y=x(8659);x(1298),x(7791),x(279),x(979),x(9386),x(6078),x(8604),x(7256),x(5517),x(4747);var l=y.asn1,g=Y.exports=y.pki=y.pki||{},w=g.oids,m={};m.CN=w.commonName,m.commonName="CN",m.C=w.countryName,m.countryName="C",m.L=w.localityName,m.localityName="L",m.ST=w.stateOrProvinceName,m.stateOrProvinceName="ST",m.O=w.organizationName,m.organizationName="O",m.OU=w.organizationalUnitName,m.organizationalUnitName="OU",m.E=w.emailAddress,m.emailAddress="E";var h=y.pki.rsa.publicKeyValidator,c={name:"Certificate",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:l.Class.UNIVERSAL,type:l.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:l.Class.UNIVERSAL,type:l.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:l.Class.UNIVERSAL,type:l.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:l.Class.UNIVERSAL,type:l.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},h,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:l.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:l.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},f={name:"rsapss",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:l.Class.UNIVERSAL,type:l.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:l.Class.UNIVERSAL,type:l.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:l.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:l.Class.UNIVERSAL,type:l.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:l.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:l.Class.UNIVERSAL,type:l.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},b={name:"CertificationRequest",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[{name:"CertificationRequestInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},h,{name:"CertificationRequestInfo.attributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0}]}]}]},{name:"CertificationRequest.signatureAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function S(C,O){"string"==typeof O&&(O={shortName:O});for(var L,V=null,$=0;null===V&&$"u"&&(O.type&&O.type in g.oids?O.name=g.oids[O.type]:O.shortName&&O.shortName in m&&(O.name=g.oids[m[O.shortName]])),typeof O.type>"u"){if(!O.name||!(O.name in g.oids))throw(L=new Error("Attribute type not specified.")).attribute=O,L;O.type=g.oids[O.name]}if(typeof O.shortName>"u"&&O.name&&O.name in m&&(O.shortName=m[O.name]),O.type===w.extensionRequest&&(O.valueConstructed=!0,O.valueTagClass=l.Type.SEQUENCE,!O.value&&O.extensions)){O.value=[];for(var $=0;$"u")throw(L=new Error("Attribute value not specified.")).attribute=O,L}}function D(C,O){if(O=O||{},typeof C.name>"u"&&C.id&&C.id in g.oids&&(C.name=g.oids[C.id]),typeof C.id>"u"){if(!C.name||!(C.name in g.oids))throw(V=new Error("Extension ID not specified.")).extension=C,V;C.id=g.oids[C.name]}if(typeof C.value<"u")return C;if("keyUsage"===C.name){var L=0,$=0,re=0;C.digitalSignature&&($|=128,L=7),C.nonRepudiation&&($|=64,L=6),C.keyEncipherment&&($|=32,L=5),C.dataEncipherment&&($|=16,L=4),C.keyAgreement&&($|=8,L=3),C.keyCertSign&&($|=4,L=2),C.cRLSign&&($|=2,L=1),C.encipherOnly&&($|=1,L=0),C.decipherOnly&&(re|=128,L=7);var z=String.fromCharCode(L);0!==re?z+=String.fromCharCode($)+String.fromCharCode(re):0!==$&&(z+=String.fromCharCode($)),C.value=l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,z)}else if("basicConstraints"===C.name)C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),C.cA&&C.value.value.push(l.create(l.Class.UNIVERSAL,l.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in C&&C.value.value.push(l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(C.pathLenConstraint).getBytes()));else if("extKeyUsage"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);var te=C.value.value;for(var X in C)!0===C[X]&&(X in w?te.push(l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(w[X]).getBytes())):-1!==X.indexOf(".")&&te.push(l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(X).getBytes())))}else if("nsCertType"===C.name)L=0,$=0,C.client&&($|=128,L=7),C.server&&($|=64,L=6),C.email&&($|=32,L=5),C.objsign&&($|=16,L=4),C.reserved&&($|=8,L=3),C.sslCA&&($|=4,L=2),C.emailCA&&($|=2,L=1),C.objCA&&($|=1,L=0),z=String.fromCharCode(L),0!==$&&(z+=String.fromCharCode($)),C.value=l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,z);else if("subjectAltName"===C.name||"issuerAltName"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);for(var ne=0;ne128)throw new Error('Invalid "nsComment" content.');C.value=l.create(l.Class.UNIVERSAL,l.Type.IA5STRING,!1,C.comment)}else if("subjectKeyIdentifier"===C.name&&O.cert){var se=O.cert.generateSubjectKeyIdentifier();C.subjectKeyIdentifier=se.toHex(),C.value=l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,se.getBytes())}else if("authorityKeyIdentifier"===C.name&&O.cert){if(C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),te=C.value.value,C.keyIdentifier){var de=!0===C.keyIdentifier?O.cert.generateSubjectKeyIdentifier().getBytes():C.keyIdentifier;te.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!1,de))}if(C.authorityCertIssuer){var pe=[l.create(l.Class.CONTEXT_SPECIFIC,4,!0,[I(!0===C.authorityCertIssuer?O.cert.issuer:C.authorityCertIssuer)])];te.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,pe))}if(C.serialNumber){var Le=y.util.hexToBytes(!0===C.serialNumber?O.cert.serialNumber:C.serialNumber);te.push(l.create(l.Class.CONTEXT_SPECIFIC,2,!1,Le))}}else if("cRLDistributionPoints"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),te=C.value.value;var q,Se=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),Pe=l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[]);for(ne=0;ne"u")throw(V=new Error("Extension value not specified.")).extension=C,V;return C}function T(C,O){if(C===w["RSASSA-PSS"]){var V=[];return void 0!==O.hash.algorithmOid&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.hash.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")])])),void 0!==O.mgf.algorithmOid&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,[l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.mgf.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.mgf.hash.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")])])])),void 0!==O.saltLength&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,2,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(O.saltLength).getBytes())])),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,V)}return l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")}function M(C){var O=l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===C.attributes.length)return O;for(var V=C.attributes,L=0;L2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(X.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(z.validity.notBefore=X[0],z.validity.notAfter=X[1],z.tbsCertificate=V.tbsCertificate,O){z.md=v({signatureOid:z.signatureOid,type:"certificate"});var q=l.toDer(z.tbsCertificate);z.md.update(q.getBytes())}var ne=y.md.sha1.create(),se=l.toDer(V.certIssuer);ne.update(se.getBytes()),z.issuer.getField=function(Le){return S(z.issuer,Le)},z.issuer.addField=function(Le){P([Le]),z.issuer.attributes.push(Le)},z.issuer.attributes=g.RDNAttributesAsArray(V.certIssuer),V.certIssuerUniqueId&&(z.issuer.uniqueId=V.certIssuerUniqueId),z.issuer.hash=ne.digest().toHex();var de=y.md.sha1.create(),pe=l.toDer(V.certSubject);return de.update(pe.getBytes()),z.subject.getField=function(Le){return S(z.subject,Le)},z.subject.addField=function(Le){P([Le]),z.subject.attributes.push(Le)},z.subject.attributes=g.RDNAttributesAsArray(V.certSubject),V.certSubjectUniqueId&&(z.subject.uniqueId=V.certSubjectUniqueId),z.subject.hash=de.digest().toHex(),z.extensions=V.certExtensions?g.certificateExtensionsFromAsn1(V.certExtensions):[],z.publicKey=g.publicKeyFromAsn1(V.subjectPublicKeyInfo),z},g.certificateExtensionsFromAsn1=function(C){for(var O=[],V=0;V1&&(L=V.value.charCodeAt(1),$=V.value.length>2?V.value.charCodeAt(2):0),O.digitalSignature=128==(128&L),O.nonRepudiation=64==(64&L),O.keyEncipherment=32==(32&L),O.dataEncipherment=16==(16&L),O.keyAgreement=8==(8&L),O.keyCertSign=4==(4&L),O.cRLSign=2==(2&L),O.encipherOnly=1==(1&L),O.decipherOnly=128==(128&$)}else if("basicConstraints"===O.name){var V=l.fromDer(O.value);O.cA=V.value.length>0&&V.value[0].type===l.Type.BOOLEAN&&0!==V.value[0].value.charCodeAt(0);var re=null;V.value.length>0&&V.value[0].type===l.Type.INTEGER?re=V.value[0].value:V.value.length>1&&(re=V.value[1].value),null!==re&&(O.pathLenConstraint=l.derToInteger(re))}else if("extKeyUsage"===O.name){V=l.fromDer(O.value);for(var z=0;z1&&(L=V.value.charCodeAt(1)),O.client=128==(128&L),O.server=64==(64&L),O.email=32==(32&L),O.objsign=16==(16&L),O.reserved=8==(8&L),O.sslCA=4==(4&L),O.emailCA=2==(2&L),O.objCA=1==(1&L);else if("subjectAltName"===O.name||"issuerAltName"===O.name){O.altNames=[],V=l.fromDer(O.value);for(var X,q=0;q=k&&C0&&L.value.push(g.certificateExtensionsToAsn1(C.extensions)),L},g.getCertificationRequestInfo=function(C){return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(C.version).getBytes()),I(C.subject),g.publicKeyToAsn1(C.publicKey),M(C)])},g.distinguishedNameToAsn1=function(C){return I(C)},g.certificateToAsn1=function(C){var O=C.tbsCertificate||g.getTBSCertificate(C);return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[O,l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(C.signatureOid).getBytes()),T(C.signatureOid,C.signatureParameters)]),l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,String.fromCharCode(0)+C.signature)])},g.certificateExtensionsToAsn1=function(C){var O=l.create(l.Class.CONTEXT_SPECIFIC,3,!0,[]),V=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);O.value.push(V);for(var L=0;L"u"&&($=new Date);var re=!0,z=null,te=0;do{var X=O.shift(),q=null,ne=!1;if($&&($X.validity.notAfter)&&(z={message:"Certificate is not valid yet or has expired.",error:g.certificateError.certificate_expired,notBefore:X.validity.notBefore,notAfter:X.validity.notAfter,now:$}),null===z){if(null===(q=O[0]||C.getIssuer(X))&&X.isIssuer(X)&&(ne=!0,q=X),q){var se=q;y.util.isArray(se)||(se=[se]);for(var de=!1;!de&&se.length>0;){q=se.shift();try{de=q.verify(X)}catch{}}de||(z={message:"Certificate signature is invalid.",error:g.certificateError.bad_certificate})}null===z&&(!q||ne)&&!C.hasCertificate(X)&&(z={message:"Certificate is not trusted.",error:g.certificateError.unknown_ca})}if(null===z&&q&&!X.isIssuer(q)&&(z={message:"Certificate issuer is invalid.",error:g.certificateError.bad_certificate}),null===z)for(var pe={keyUsage:!0,basicConstraints:!0},Le=0;null===z&&LePe.pathLenConstraint&&(z={message:"Certificate basicConstraints pathLenConstraint violated.",error:g.certificateError.bad_certificate})}var H=null===z||z.error,Ee=V.verify?V.verify(H,te,L):H;if(!0!==Ee)throw!0===H&&(z={message:"The application rejected the certificate.",error:g.certificateError.bad_certificate}),(Ee||0===Ee)&&("object"!=typeof Ee||y.util.isArray(Ee)?"string"==typeof Ee&&(z.error=Ee):(Ee.message&&(z.message=Ee.message),Ee.error&&(z.error=Ee.error))),z;z=null,re=!1,++te}while(O.length>0);return!0}},8614:(Y,U,x)=>{const y=x(1159),l=x(281);Y.exports=class{constructor(){this._buffer=new y,this._waitingConsumers=new y}push(w){const{promise:m,resolve:h}=l();return this._buffer.push({chunk:w,resolve:h}),this._consume(),m}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const w=this._waitingConsumers.shift(),m=this._buffer.shift();w.resolve(m.chunk),m.resolve()}}shift(){const{promise:w,resolve:m}=l();return this._waitingConsumers.push({resolve:m}),this._consume(),w}isEmpty(){return this._buffer.isEmpty()}}},281:Y=>{"use strict";Y.exports=()=>{const x={};return x.promise=new Promise((y,l)=>{x.resolve=y,x.reject=l}),x}},4108:(Y,U,x)=>{"use strict";Y.exports=x(8777).default},8777:function(Y,U,x){"use strict";var y=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(U,"__esModule",{value:!0});const l=x(7910),g=y(x(4066)),w=y(x(382)),m=x(1396),c=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map(b=>new l.Netmask(b));function d(b){return/^::$/.test(b)||/^::1$/.test(b)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(b)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(b)||/^ff([0-9a-fA-F]{2,2}):/i.test(b)}U.default=b=>{if((0,m.isValid)(b)){const S=(0,m.parse)(b);if("ipv4"===S.kind())return function f(b){for(let S of c)if(S.contains(b))return!0;return!1}(S.toNormalizedString());if("ipv6"===S.kind())return d(b)}else if((0,w.default)(b)&&g.default.v6().test(b))return d(b)}},382:(Y,U,x)=>{"use strict";const y=x(4066),l=g=>y({exact:!0}).test(g);l.v4=g=>y.v4({exact:!0}).test(g),l.v6=g=>y.v6({exact:!0}).test(g),l.version=g=>l(g)?l.v4(g)?4:6:void 0,Y.exports=l},3863:(Y,U,x)=>{"use strict";Y.exports=x(2540)},4599:Y=>{"use strict";Y.exports=x;var y,U=/\/|\./;function x(l,g){U.test(l)||(l="google/protobuf/"+l+".proto",g={nested:{google:{nested:{protobuf:{nested:g}}}}}),x[l]=g}x("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),x("duration",{Duration:y={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),x("timestamp",{Timestamp:y}),x("empty",{Empty:{fields:{}}}),x("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),x("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),x("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),x.get=function(g){return x[g]||null}},6533:(Y,U,x)=>{"use strict";var y=U,l=x(4269),g=x(8572);function w(h,c,f,d){var b=!1;if(c.resolvedType)if(c.resolvedType instanceof l){h("switch(d%s){",d);for(var S=c.resolvedType.values,E=Object.keys(S),v=0;v>>0",d,d);break;case"int32":case"sint32":case"sfixed32":h("m%s=d%s|0",d,d);break;case"uint64":p=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",d,d,p)('else if(typeof d%s==="string")',d)("m%s=parseInt(d%s,10)",d,d)('else if(typeof d%s==="number")',d)("m%s=d%s",d,d)('else if(typeof d%s==="object")',d)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",d,d,d,p?"true":"");break;case"bytes":h('if(typeof d%s==="string")',d)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",d,d,d)("else if(d%s.length >= 0)",d)("m%s=d%s",d,d);break;case"string":h("m%s=String(d%s)",d,d);break;case"bool":h("m%s=Boolean(d%s)",d,d)}}return h}function m(h,c,f,d){if(c.resolvedType)c.resolvedType instanceof l?h("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",d,f,d,d,f,d,d):h("d%s=types[%i].toObject(m%s,o)",d,f,d);else{var b=!1;switch(c.type){case"double":case"float":h("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",d,d,d,d);break;case"uint64":b=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h('if(typeof m%s==="number")',d)("d%s=o.longs===String?String(m%s):m%s",d,d,d)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",d,d,d,d,b?"true":"",d);break;case"bytes":h("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",d,d,d,d,d);break;default:h("d%s=m%s",d,d)}}return h}y.fromObject=function(c){var f=c.fieldsArray,d=g.codegen(["d"],c.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!f.length)return d("return new this.ctor");d("var m=new this.ctor");for(var b=0;b{"use strict";Y.exports=function m(h){var c=g.codegen(["r","l"],h.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(h.fieldsArray.filter(function(v){return v.map}).length?",k,value":""))("while(r.pos>>3){");for(var f=0;f>>3){")("case 1: k=r.%s(); break",d.keyType)("case 2:"),void 0===l.basic[b]?c("value=types[%i].decode(r,r.uint32())",f):c("value=r.%s()",b),c("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),c(void 0!==l.long[d.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",S)):d.repeated?(c("if(!(%s&&%s.length))",S,S)("%s=[]",S),void 0!==l.packed[b]&&c("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";Y.exports=function m(h){for(var d,c=g.codegen(["m","w"],h.name+"$encode")("if(!w)")("w=Writer.create()"),b=h.fieldsArray.slice().sort(g.compareFieldsById),f=0;f>>0,8|l.mapKey[S.keyType],S.keyType),void 0===p?c("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",E,d):c(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|p,v,d),c("}")("}")):S.repeated?(c("if(%s!=null&&%s.length){",d,d),S.packed&&void 0!==l.packed[v]?c("w.uint32(%i).fork()",(S.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",d)("w.%s(%s[i])",v,d)("w.ldelim()"):(c("for(var i=0;i<%s.length;++i)",d),void 0===p?w(c,S,E,d+"[i]"):c("w.uint32(%i).%s(%s[i])",(S.id<<3|p)>>>0,v,d)),c("}")):(S.optional&&c("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",d,S.name),void 0===p?w(c,S,E,d):c("w.uint32(%i).%s(%s)",(S.id<<3|p)>>>0,v,d))}return c("return w")};var y=x(4269),l=x(688),g=x(8572);function w(h,c,f,d){return c.resolvedType.group?h("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",f,d,(c.id<<3|3)>>>0,(c.id<<3|4)>>>0):h("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",f,d,(c.id<<3|2)>>>0)}},4269:(Y,U,x)=>{"use strict";Y.exports=w;var y=x(9487);((w.prototype=Object.create(y.prototype)).constructor=w).className="Enum";var l=x(326),g=x(8572);function w(m,h,c,f,d,b){if(y.call(this,m,c),h&&"object"!=typeof h)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=f,this.comments=d||{},this.valuesOptions=b,this.reserved=void 0,h)for(var S=Object.keys(h),E=0;E{"use strict";Y.exports=c;var y=x(9487);((c.prototype=Object.create(y.prototype)).constructor=c).className="Field";var m,l=x(4269),g=x(688),w=x(8572),h=/^required|optional|repeated$/;function c(f,d,b,S,E,v,p){if(w.isObject(S)?(p=E,v=S,S=E=void 0):w.isObject(E)&&(p=v,v=E,E=void 0),y.call(this,f,v),!w.isInteger(d)||d<0)throw TypeError("id must be a non-negative integer");if(!w.isString(b))throw TypeError("type must be a string");if(void 0!==S&&!h.test(S=S.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==E&&!w.isString(E))throw TypeError("extend must be a string");"proto3_optional"===S&&(S="optional"),this.rule=S&&"optional"!==S?S:void 0,this.type=b,this.id=d,this.extend=E||void 0,this.required="required"===S,this.optional=!this.required,this.repeated="repeated"===S,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!w.Long&&void 0!==g.long[b],this.bytes="bytes"===b,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=p}c.fromJSON=function(d,b){return new c(d,b.id,b.type,b.rule,b.extend,b.options,b.comment)},Object.defineProperty(c.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),c.prototype.setOption=function(d,b,S){return"packed"===d&&(this._packed=null),y.prototype.setOption.call(this,d,b,S)},c.prototype.toJSON=function(d){var b=!!d&&Boolean(d.keepComments);return w.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",b?this.comment:void 0])},c.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=g.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.typeDefault=this.resolvedType instanceof m?null:this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof l&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&((!0===this.options.packed||void 0!==this.options.packed&&this.resolvedType&&!(this.resolvedType instanceof l))&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=w.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var d;w.base64.test(this.typeDefault)?w.base64.decode(this.typeDefault,d=w.newBuffer(w.base64.length(this.typeDefault)),0):w.utf8.write(this.typeDefault,d=w.newBuffer(w.utf8.length(this.typeDefault)),0),this.typeDefault=d}return this.defaultValue=this.map?w.emptyObject:this.repeated?w.emptyArray:this.typeDefault,this.parent instanceof m&&(this.parent.ctor.prototype[this.name]=this.defaultValue),y.prototype.resolve.call(this)},c.d=function(d,b,S,E){return"function"==typeof b?b=w.decorateType(b).name:b&&"object"==typeof b&&(b=w.decorateEnum(b).name),function(p,I){w.decorateType(p.constructor).add(new c(I,d,b,S,{default:E}))}},c._configure=function(d){m=d}},5803:(Y,U,x)=>{"use strict";var y=Y.exports=x(95);y.build="light",y.load=function l(w,m,h){return"function"==typeof m?(h=m,m=new y.Root):m||(m=new y.Root),m.load(w,h)},y.loadSync=function g(w,m){return m||(m=new y.Root),m.loadSync(w)},y.encoder=x(133),y.decoder=x(225),y.verifier=x(8617),y.converter=x(6533),y.ReflectionObject=x(9487),y.Namespace=x(326),y.Root=x(5257),y.Enum=x(4269),y.Type=x(7845),y.Field=x(2986),y.OneOf=x(7397),y.MapField=x(9455),y.Service=x(9630),y.Method=x(1618),y.Message=x(1413),y.wrappers=x(761),y.types=x(688),y.util=x(8572),y.ReflectionObject._configure(y.Root),y.Namespace._configure(y.Type,y.Service,y.Enum),y.Root._configure(y.Type),y.Field._configure(y.Type)},95:(Y,U,x)=>{"use strict";var y=U;function l(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(1650),y.BufferWriter=x(813),y.Reader=x(7270),y.BufferReader=x(4354),y.util=x(7211),y.rpc=x(7830),y.roots=x(6671),y.configure=l,l()},2540:(Y,U,x)=>{"use strict";var y=Y.exports=x(5803);y.build="full",y.tokenize=x(691),y.parse=x(8992),y.common=x(4599),y.Root._configure(y.Type,y.parse,y.common)},9455:(Y,U,x)=>{"use strict";Y.exports=w;var y=x(2986);((w.prototype=Object.create(y.prototype)).constructor=w).className="MapField";var l=x(688),g=x(8572);function w(m,h,c,f,d,b){if(y.call(this,m,h,f,void 0,void 0,d,b),!g.isString(c))throw TypeError("keyType must be a string");this.keyType=c,this.resolvedKeyType=null,this.map=!0}w.fromJSON=function(h,c){return new w(h,c.id,c.keyType,c.type,c.options,c.comment)},w.prototype.toJSON=function(h){var c=!!h&&Boolean(h.keepComments);return g.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",c?this.comment:void 0])},w.prototype.resolve=function(){if(this.resolved)return this;if(void 0===l.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return y.prototype.resolve.call(this)},w.d=function(h,c,f){return"function"==typeof f?f=g.decorateType(f).name:f&&"object"==typeof f&&(f=g.decorateEnum(f).name),function(b,S){g.decorateType(b.constructor).add(new w(S,h,c,f))}}},1413:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(g){if(g)for(var w=Object.keys(g),m=0;m{"use strict";Y.exports=g;var y=x(9487);((g.prototype=Object.create(y.prototype)).constructor=g).className="Method";var l=x(8572);function g(w,m,h,c,f,d,b,S,E){if(l.isObject(f)?(b=f,f=d=void 0):l.isObject(d)&&(b=d,d=void 0),void 0!==m&&!l.isString(m))throw TypeError("type must be a string");if(!l.isString(h))throw TypeError("requestType must be a string");if(!l.isString(c))throw TypeError("responseType must be a string");y.call(this,w,b),this.type=m||"rpc",this.requestType=h,this.requestStream=!!f||void 0,this.responseType=c,this.responseStream=!!d||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=S,this.parsedOptions=E}g.fromJSON=function(m,h){return new g(m,h.type,h.requestType,h.responseType,h.requestStream,h.responseStream,h.options,h.comment,h.parsedOptions)},g.prototype.toJSON=function(m){var h=!!m&&Boolean(m.keepComments);return l.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",h?this.comment:void 0,"parsedOptions",this.parsedOptions])},g.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),y.prototype.resolve.call(this))}},326:(Y,U,x)=>{"use strict";Y.exports=d;var y=x(9487);((d.prototype=Object.create(y.prototype)).constructor=d).className="Namespace";var m,h,c,l=x(2986),g=x(8572),w=x(7397);function f(S,E){if(S&&S.length){for(var v={},p=0;pv)return!0;return!1},d.isReservedName=function(E,v){if(E)for(var p=0;p0;){var I=E.shift();if(p.nested&&p.nested[I]){if(!((p=p.nested[I])instanceof d))throw Error("path conflicts with non-namespace objects")}else p.add(p=new d(I))}return v&&p.addJSON(v),p},d.prototype.resolveAll=function(){for(var E=this.nestedArray,v=0;v-1)return I}else if(I instanceof d&&(I=I.lookup(E.slice(1),v,!0)))return I}else for(var A=0;A{"use strict";Y.exports=g,g.className="ReflectionObject";var l,y=x(8572);function g(w,m){if(!y.isString(w))throw TypeError("name must be a string");if(m&&!y.isObject(m))throw TypeError("options must be an object");this.options=m,this.parsedOptions=null,this.name=w,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(g.prototype,{root:{get:function(){for(var w=this;null!==w.parent;)w=w.parent;return w}},fullName:{get:function(){for(var w=[this.name],m=this.parent;m;)w.unshift(m.name),m=m.parent;return w.join(".")}}}),g.prototype.toJSON=function(){throw Error()},g.prototype.onAdd=function(m){this.parent&&this.parent!==m&&this.parent.remove(this),this.parent=m,this.resolved=!1;var h=m.root;h instanceof l&&h._handleAdd(this)},g.prototype.onRemove=function(m){var h=m.root;h instanceof l&&h._handleRemove(this),this.parent=null,this.resolved=!1},g.prototype.resolve=function(){return this.resolved||this.root instanceof l&&(this.resolved=!0),this},g.prototype.getOption=function(m){if(this.options)return this.options[m]},g.prototype.setOption=function(m,h,c){return(!c||!this.options||void 0===this.options[m])&&((this.options||(this.options={}))[m]=h),this},g.prototype.setParsedOption=function(m,h,c){this.parsedOptions||(this.parsedOptions=[]);var f=this.parsedOptions;if(c){var d=f.find(function(E){return Object.prototype.hasOwnProperty.call(E,m)});d?y.setProperty(d[m],c,h):((d={})[m]=y.setProperty({},c,h),f.push(d))}else{var S={};S[m]=h,f.push(S)}return this},g.prototype.setOptions=function(m,h){if(m)for(var c=Object.keys(m),f=0;f{"use strict";Y.exports=w;var y=x(9487);((w.prototype=Object.create(y.prototype)).constructor=w).className="OneOf";var l=x(2986),g=x(8572);function w(h,c,f,d){if(Array.isArray(c)||(f=c,c=void 0),y.call(this,h,f),void 0!==c&&!Array.isArray(c))throw TypeError("fieldNames must be an Array");this.oneof=c||[],this.fieldsArray=[],this.comment=d}function m(h){if(h.parent)for(var c=0;c-1&&this.oneof.splice(f,1),c.partOf=null,this},w.prototype.onAdd=function(c){y.prototype.onAdd.call(this,c);for(var d=0;d{"use strict";Y.exports=F,F.filename=null,F.defaults={keepCase:!1};var y=x(691),l=x(5257),g=x(7845),w=x(2986),m=x(9455),h=x(7397),c=x(4269),f=x(9630),d=x(1618),b=x(688),S=x(8572),E=/^[1-9][0-9]*$/,v=/^-?[1-9][0-9]*$/,p=/^0[x][0-9a-fA-F]+$/,I=/^-?0[x][0-9a-fA-F]+$/,A=/^0[0-7]+$/,P=/^-?0[0-7]+$/,D=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,T=/^[a-zA-Z_][a-zA-Z_0-9]*$/,M=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,k=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function F(G,C,O){C instanceof l||(O=C,C=new l),O||(O=F.defaults);var ne,se,de,pe,Ke,V=O.preferTrailingComment||!1,L=y(G,O.alternateCommentMode||!1),$=L.next,re=L.push,z=L.peek,te=L.skip,X=L.cmnt,q=!0,Le=!1,Se=C,Pe=O.keepCase?function(we){return we}:S.camelCase;function be(we,ge,De){var Fe=F.filename;return De||(F.filename=null),Error("illegal "+(ge||"token")+" '"+we+"' ("+(Fe?Fe+", ":"")+"line "+L.line+")")}function $e(){var ge,we=[];do{if('"'!==(ge=$())&&"'"!==ge)throw be(ge);we.push($()),te(ge),ge=z()}while('"'===ge||"'"===ge);return we.join("")}function H(we){var ge=$();switch(ge){case"'":case'"':return re(ge),$e();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function Te(we,ge){var De=1;switch("-"===we.charAt(0)&&(De=-1,we=we.substring(1)),we){case"inf":case"INF":case"Inf":return De*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(E.test(we))return De*parseInt(we,10);if(p.test(we))return De*parseInt(we,16);if(A.test(we))return De*parseInt(we,8);if(D.test(we))return De*parseFloat(we);throw be(we,"number",ge)}(ge,!0)}catch{if(we&&M.test(ge))return ge;throw be(ge,"value")}}function Ee(we,ge){var De,Fe;do{!ge||'"'!==(De=z())&&"'"!==De?we.push([Fe=xe($()),te("to",!0)?xe($()):Fe]):we.push($e())}while(te(",",!0));te(";")}function xe(we,ge){switch(we){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!ge&&"-"===we.charAt(0))throw be(we,"id");if(v.test(we))return parseInt(we,10);if(I.test(we))return parseInt(we,16);if(P.test(we))return parseInt(we,8);throw be(we,"id")}function He(){if(void 0!==ne)throw be("package");if(ne=$(),!M.test(ne))throw be(ne,"name");Se=Se.define(ne),te(";")}function We(){var ge,we=z();switch(we){case"weak":ge=de||(de=[]),$();break;case"public":$();default:ge=se||(se=[])}we=$e(),te(";"),ge.push(we)}function Je(){if(te("="),pe=$e(),!(Le="proto3"===pe)&&"proto2"!==pe)throw be(pe,"syntax");te(";")}function Xe(we,ge){switch(ge){case"option":return ye(we,ge),te(";"),!0;case"message":return pt(we,ge),!0;case"enum":return ie(we,ge),!0;case"service":return function qe(we,ge){if(!T.test(ge=$()))throw be(ge,"service name");var De=new f(ge);Nt(De,function(Be){if(!Xe(De,Be)){if("rpc"!==Be)throw be(Be);!function it(we,ge){var De=X(),Fe=ge;if(!T.test(ge=$()))throw be(ge,"name");var dt,xt,mt,et,Be=ge;if(te("("),te("stream",!0)&&(xt=!0),!M.test(ge=$())||(dt=ge,te(")"),te("returns"),te("("),te("stream",!0)&&(et=!0),!M.test(ge=$())))throw be(ge);mt=ge,te(")");var Tn=new d(Be,Fe,dt,mt,xt,et);Tn.comment=De,Nt(Tn,function(pn){if("option"!==pn)throw be(pn);ye(Tn,pn),te(";")}),we.add(Tn)}(De,Be)}}),we.add(De)}(we,ge),!0;case"extend":return function nt(we,ge){if(!M.test(ge=$()))throw be(ge,"reference");var De=ge;Nt(null,function(Be){switch(Be){case"required":case"repeated":_t(we,Be,De);break;case"optional":_t(we,Le?"proto3_optional":"optional",De);break;default:if(!Le||!M.test(Be))throw be(Be);re(Be),_t(we,"optional",De)}})}(we,ge),!0}return!1}function Nt(we,ge,De){var Fe=L.line;if(we&&("string"!=typeof we.comment&&(we.comment=X()),we.filename=F.filename),te("{",!0)){for(var Be;"}"!==(Be=$());)ge(Be);te(";",!0)}else De&&De(),te(";"),we&&("string"!=typeof we.comment||V)&&(we.comment=X(Fe)||we.comment)}function pt(we,ge){if(!T.test(ge=$()))throw be(ge,"type name");var De=new g(ge);Nt(De,function(Be){if(!Xe(De,Be))switch(Be){case"map":!function gr(we){te("<");var ge=$();if(void 0===b.mapKey[ge])throw be(ge,"type");te(",");var De=$();if(!M.test(De))throw be(De,"type");te(">");var Fe=$();if(!T.test(Fe))throw be(Fe,"name");te("=");var Be=new m(Pe(Fe),xe($()),ge,De);Nt(Be,function(xt){if("option"!==xt)throw be(xt);ye(Be,xt),te(";")},function(){Qe(Be)}),we.add(Be)}(De);break;case"required":case"repeated":_t(De,Be);break;case"optional":_t(De,Le?"proto3_optional":"optional");break;case"oneof":!function Hr(we,ge){if(!T.test(ge=$()))throw be(ge,"name");var De=new h(Pe(ge));Nt(De,function(Be){"option"===Be?(ye(De,Be),te(";")):(re(Be),_t(De,"optional"))}),we.add(De)}(De,Be);break;case"extensions":Ee(De.extensions||(De.extensions=[]));break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:if(!Le||!M.test(Be))throw be(Be);re(Be),_t(De,"optional")}}),we.add(De)}function _t(we,ge,De){var Fe=$();if("group"!==Fe){if(!M.test(Fe))throw be(Fe,"type");var Be=$();if(!T.test(Be))throw be(Be,"name");Be=Pe(Be),te("=");var dt=new w(Be,xe($()),Fe,ge,De);if(Nt(dt,function(et){if("option"!==et)throw be(et);ye(dt,et),te(";")},function(){Qe(dt)}),"proto3_optional"===ge){var xt=new h("_"+Be);dt.setOption("proto3_optional",!0),xt.add(dt),we.add(xt)}else we.add(dt);!Le&&dt.repeated&&(void 0!==b.packed[Fe]||void 0===b.basic[Fe])&&dt.setOption("packed",!1,!0)}else!function Or(we,ge){var De=$();if(!T.test(De))throw be(De,"name");var Fe=S.lcFirst(De);De===Fe&&(De=S.ucFirst(De)),te("=");var Be=xe($()),dt=new g(De);dt.group=!0;var xt=new w(Fe,Be,De,ge);xt.filename=F.filename,Nt(dt,function(et){switch(et){case"option":ye(dt,et),te(";");break;case"required":case"repeated":_t(dt,et);break;case"optional":_t(dt,Le?"proto3_optional":"optional");break;case"message":pt(dt,et);break;case"enum":ie(dt,et);break;default:throw be(et)}}),we.add(dt).add(xt)}(we,ge)}function ie(we,ge){if(!T.test(ge=$()))throw be(ge,"name");var De=new c(ge);Nt(De,function(Be){switch(Be){case"option":ye(De,Be),te(";");break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:!function fe(we,ge){if(!T.test(ge))throw be(ge,"name");te("=");var De=xe($(),!0),Fe={options:void 0,setOption:function(Be,dt){void 0===this.options&&(this.options={}),this.options[Be]=dt}};Nt(Fe,function(dt){if("option"!==dt)throw be(dt);ye(Fe,dt),te(";")},function(){Qe(Fe)}),we.add(ge,De,Fe.comment,Fe.options)}(De,Be)}}),we.add(De)}function ye(we,ge){var De=te("(",!0);if(!M.test(ge=$()))throw be(ge,"name");var dt,Fe=ge,Be=Fe;De&&(te(")"),Be=Fe="("+Fe+")",ge=z(),k.test(ge)&&(dt=ge.slice(1),Fe+=ge,$())),te("="),function Ne(we,ge,De,Fe){we.setParsedOption&&we.setParsedOption(ge,De,Fe)}(we,Be,me(we,Fe),dt)}function me(we,ge){if(te("{",!0)){for(var De={};!te("}",!0);){if(!T.test(Ke=$()))throw be(Ke,"name");var Fe,Be=Ke;if(te(":",!0),"{"===z())Fe=me(we,ge+"."+Ke);else if("["===z()){var dt;if(Fe=[],te("[",!0)){do{dt=H(!0),Fe.push(dt)}while(te(",",!0));te("]"),typeof dt<"u"&&_e(we,ge+"."+Ke,dt)}}else Fe=H(!0),_e(we,ge+"."+Ke,Fe);var xt=De[Be];xt&&(Fe=[].concat(xt).concat(Fe)),De[Be]=Fe,te(",",!0),te(";",!0)}return De}var mt=H(!0);return _e(we,ge,mt),mt}function _e(we,ge,De){we.setOption&&we.setOption(ge,De)}function Qe(we){if(te("[",!0)){do{ye(we,"option")}while(te(",",!0));te("]")}return we}for(;null!==(Ke=$());)switch(Ke){case"package":if(!q)throw be(Ke);He();break;case"import":if(!q)throw be(Ke);We();break;case"syntax":if(!q)throw be(Ke);Je();break;case"option":ye(Se,Ke),te(";");break;default:if(Xe(Se,Ke)){q=!1;continue}throw be(Ke)}return F.filename=null,{package:ne,imports:se,weakImports:de,syntax:pe,root:C}}},7270:(Y,U,x)=>{"use strict";Y.exports=h;var l,y=x(7211),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new l(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){l=E,h.create=f(),l._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},4354:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(7270);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(7211);function g(w){y.call(this,w)}g._configure=function(){l.Buffer&&(g.prototype._slice=l.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},5257:(Y,U,x)=>{"use strict";Y.exports=d;var y=x(326);((d.prototype=Object.create(y.prototype)).constructor=d).className="Root";var h,c,f,l=x(2986),g=x(4269),w=x(7397),m=x(8572);function d(v){y.call(this,"",v),this.deferred=[],this.files=[]}function b(){}d.fromJSON=function(p,I){return I||(I=new d),p.options&&I.setOptions(p.options),I.addJSON(p.nested)},d.prototype.resolvePath=m.path.resolve,d.prototype.fetch=m.fetch,d.prototype.load=function v(p,I,A){"function"==typeof I&&(A=I,I=void 0);var P=this;if(!A)return m.asPromise(v,P,p,I);var D=A===b;function T(V,L){if(A){var $=A;if(A=null,D)throw V;$(V,L)}}function M(V){var L=V.lastIndexOf("google/protobuf/");if(L>-1){var $=V.substring(L);if($ in f)return $}return null}function k(V,L){try{if(m.isString(L)&&"{"===L.charAt(0)&&(L=JSON.parse(L)),m.isString(L)){c.filename=V;var re,$=c(L,P,I),z=0;if($.imports)for(;z<$.imports.length;++z)(re=M($.imports[z])||P.resolvePath(V,$.imports[z]))&&F(re);if($.weakImports)for(z=0;z<$.weakImports.length;++z)(re=M($.weakImports[z])||P.resolvePath(V,$.weakImports[z]))&&F(re,!0)}else P.setOptions(L.options).addJSON(L.nested)}catch(te){T(te)}!D&&!G&&T(null,P)}function F(V,L){if(!(P.files.indexOf(V)>-1)){if(P.files.push(V),V in f)return void(D?k(V,f[V]):(++G,setTimeout(function(){--G,k(V,f[V])})));if(D){var $;try{$=m.fs.readFileSync(V).toString("utf8")}catch(re){return void(L||T(re))}k(V,$)}else++G,P.fetch(V,function(re,z){if(--G,A){if(re)return void(L?G||T(null,P):T(re));k(V,z)}})}}var G=0;m.isString(p)&&(p=[p]);for(var O,C=0;C-1&&this.deferred.splice(I,1)}}else if(p instanceof g)S.test(p.name)&&delete p.parent[p.name];else if(p instanceof y){for(var A=0;A{"use strict";Y.exports={}},7830:(Y,U,x)=>{"use strict";U.Service=x(6346)},6346:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(l.prototype=Object.create(y.EventEmitter.prototype)).constructor=l,l.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},l.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},9630:(Y,U,x)=>{"use strict";Y.exports=m;var y=x(326);((m.prototype=Object.create(y.prototype)).constructor=m).className="Service";var l=x(1618),g=x(8572),w=x(7830);function m(c,f){y.call(this,c,f),this.methods={},this._methodsArray=null}function h(c){return c._methodsArray=null,c}m.fromJSON=function(f,d){var b=new m(f,d.options);if(d.methods)for(var S=Object.keys(d.methods),E=0;E{"use strict";Y.exports=d;var U=/[\s{}=;:[\],'"()<>]/g,x=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,y=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,l=/^ *[*/]+ */,g=/^\s*\*?\/*/,w=/\n/g,m=/\s/,h=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function f(b){return b.replace(h,function(S,E){switch(E){case"\\":case"":return E;default:return c[E]||""}})}function d(b,S){b=b.toString();var E=0,v=b.length,p=1,I=0,A={},P=[],D=null;function T(z){return Error("illegal "+z+" (line "+p+")")}function k(z){return b.charAt(z)}function F(z,te,X){var de,q={type:b.charAt(z++),lineEmpty:!1,leading:X},se=z-(S?2:3);do{if(--se<0||"\n"===(de=b.charAt(se))){q.lineEmpty=!0;break}}while(" "===de||"\t"===de);for(var pe=b.substring(z,te).split(w),Le=0;Le0)return P.shift();if(D)return function M(){var z="'"===D?y:x;z.lastIndex=E-1;var te=z.exec(b);if(!te)throw T("string");return E=z.lastIndex,V(D),D=null,f(te[1])}();var z,te,X,q,ne,se=0===E;do{if(E===v)return null;for(z=!1;m.test(X=k(E));)if("\n"===X&&(se=!0,++p),++E===v)return null;if("/"===k(E)){if(++E===v)throw T("comment");if("/"===k(E))if(S){if(q=E,ne=!1,G(E)){ne=!0;do{if((E=C(E))===v||(E++,!se))break}while(G(E))}else E=Math.min(v,C(E)+1);ne&&(F(q,E,se),se=!0),p++,z=!0}else{for(ne="/"===k(q=E+1);"\n"!==k(++E);)if(E===v)return null;++E,ne&&(F(q,E-1,se),se=!0),++p,z=!0}else{if("*"!==(X=k(E)))return"/";q=E+1,ne=S||"*"===k(q);do{if("\n"===X&&++p,++E===v)throw T("comment");te=X,X=k(E)}while("*"!==te||"/"!==X);++E,ne&&(F(q,E-2,se),se=!0),z=!0}}}while(z);var de=E;if(U.lastIndex=0,!U.test(k(de++)))for(;de{"use strict";Y.exports=A;var y=x(326);((A.prototype=Object.create(y.prototype)).constructor=A).className="Type";var l=x(4269),g=x(7397),w=x(2986),m=x(9455),h=x(9630),c=x(1413),f=x(7270),d=x(1650),b=x(8572),S=x(133),E=x(225),v=x(8617),p=x(6533),I=x(761);function A(D,T){y.call(this,D,T),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function P(D){return D._fieldsById=D._fieldsArray=D._oneofsArray=null,delete D.encode,delete D.decode,delete D.verify,D}Object.defineProperties(A.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var D=Object.keys(this.fields),T=0;T{"use strict";var y=U,l=x(8572),g=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function w(m,h){var c=0,f={};for(h|=0;c{"use strict";var g,w,y=Y.exports=x(7211),l=x(6671);y.codegen=x(9749),y.fetch=x(8832),y.path=x(1311),y.fs=y.inquire("fs"),y.toArray=function(b){if(b){for(var S=Object.keys(b),E=new Array(S.length),v=0;v0)p[P]=v(p[P]||{},I,A);else{var D=p[P];D&&(A=[].concat(D).concat(A)),p[P]=A}return p}(b,S=S.split("."),E)},Object.defineProperty(y,"decorateRoot",{get:function(){return l.decorated||(l.decorated=new(x(5257)))}})},942:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=l.zero=new l(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=l.zeroHash="\0\0\0\0\0\0\0\0";l.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new l(d,b)},l.from=function(c){if("number"==typeof c)return l.fromNumber(c);if(y.isString(c)){if(!y.Long)return l.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new l(c.low>>>0,c.high>>>0):g},l.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},l.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;l.fromHash=function(c){return c===w?g:new l((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},l.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},l.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},l.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},l.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},7211:function(Y,U,x){"use strict";var y=U;function l(w,m,h){for(var c=Object.keys(m),f=0;fw,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),m}y.asPromise=x(1280),y.base64=x(9039),y.EventEmitter=x(9889),y.float=x(530),y.inquire=x(716),y.utf8=x(7768),y.pool=x(4479),y.LongBits=x(942),y.isNode=Boolean(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),y.global=y.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||this,y.emptyArray=Object.freeze?Object.freeze([]):[],y.emptyObject=Object.freeze?Object.freeze({}):{},y.isInteger=Number.isInteger||function(m){return"number"==typeof m&&isFinite(m)&&Math.floor(m)===m},y.isString=function(m){return"string"==typeof m||m instanceof String},y.isObject=function(m){return m&&"object"==typeof m},y.isset=y.isSet=function(m,h){var c=m[h];return!(null==c||!m.hasOwnProperty(h))&&("object"!=typeof c||(Array.isArray(c)?c.length:Object.keys(c).length)>0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=l,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Y.exports=function h(c){var f=l.codegen(["m"],c.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),b={};c.oneofsArray.length&&f("var p={}");for(var S=0;S{"use strict";var y=U,l=x(1413);y[".google.protobuf.Any"]={fromObject:function(g){if(g&&g["@type"]){var w=g["@type"].substring(g["@type"].lastIndexOf("/")+1),m=this.lookup(w);if(m){var h="."===g["@type"].charAt(0)?g["@type"].slice(1):g["@type"];return-1===h.indexOf("/")&&(h="/"+h),this.create({type_url:h,value:m.encode(m.fromObject(g)).finish()})}}return this.fromObject(g)},toObject:function(g,w){var h="",c="";if(w&&w.json&&g.type_url&&g.value){c=g.type_url.substring(g.type_url.lastIndexOf("/")+1),h=g.type_url.substring(0,g.type_url.lastIndexOf("/")+1);var f=this.lookup(c);f&&(g=f.decode(g.value))}if(!(g instanceof this.ctor)&&g instanceof l){var d=g.$type.toObject(g,w),b="."===g.$type.fullName[0]?g.$type.fullName.slice(1):g.$type.fullName;return""===h&&(h="type.googleapis.com/"),d["@type"]=c=h+b,d}return this.toObject(g,w)}}},1650:(Y,U,x)=>{"use strict";Y.exports=d;var l,y=x(7211),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new l})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(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 h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){l=P,d.create=b(),l._configure()}},813:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(1650);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(7211);function g(){y.call(this)}function w(m,h,c){m.length<40?l.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=l._Buffer_allocUnsafe,g.writeBytesBuffer=l.Buffer&&l.Buffer.prototype instanceof Uint8Array&&"set"===l.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=l.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},7813:(Y,U,x)=>{const y=x(9301),l=x(6217),g=x(7840),w=x(939),{RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c}=x(9644),f=x(4849),d=x(6492),b=x(5936),S=x(8592),E=x(2816),v=x(9062),p=x(9658);Y.exports={RateLimiterRedis:y,RateLimiterMongo:l,RateLimiterMySQL:g,RateLimiterPostgres:w,RateLimiterMemory:f,RateLimiterMemcache:d,RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c,RLWrapperBlackAndWhite:b,RateLimiterUnion:S,RateLimiterQueue:E,BurstyRateLimiter:v,RateLimiterRes:p}},9062:(Y,U,x)=>{const y=x(9658);Y.exports=class{constructor(g,w){this._rateLimiter=g,this._burstLimiter=w}_combineRes(g,w){return new y(g.remainingPoints,Math.min(g.msBeforeNext,w.msBeforeNext),g.consumedPoints,g.isFirstInDuration)}consume(g,w=1,m={}){return this._rateLimiter.consume(g,w,m).catch(h=>h instanceof y?this._burstLimiter.consume(g,w,m).then(c=>Promise.resolve(this._combineRes(h,c))).catch(c=>Promise.reject(c instanceof y?this._combineRes(h,c):c)):Promise.reject(h))}get(g){return Promise.all([this._rateLimiter.get(g),this._burstLimiter.get(g)]).then(([w,m])=>this._combineRes(w,m))}get points(){return this._rateLimiter.points}}},5936:(Y,U,x)=>{const y=x(9658);Y.exports=class{constructor(g={}){this.limiter=g.limiter,this.blackList=g.blackList,this.whiteList=g.whiteList,this.isBlackListed=g.isBlackListed,this.isWhiteListed=g.isWhiteListed,this.runActionAnyway=g.runActionAnyway}get limiter(){return this._limiter}set limiter(g){if(typeof g>"u")throw new Error("limiter is not set");this._limiter=g}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(g){this._runActionAnyway=!(typeof g>"u")&&g}get blackList(){return this._blackList}set blackList(g){this._blackList=Array.isArray(g)?g:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isBlackListed must be function");this._isBlackListed=g}get whiteList(){return this._whiteList}set whiteList(g){this._whiteList=Array.isArray(g)?g:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isWhiteListed must be function");this._isWhiteListed=g}isBlackListedSomewhere(g){return this.blackList.indexOf(g)>=0||this.isBlackListed(g)}isWhiteListedSomewhere(g){return this.whiteList.indexOf(g)>=0||this.isWhiteListed(g)}getBlackRes(){return new y(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new y(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(g,w=1){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.rejectBlack()),typeof m>"u"?this.limiter.consume(g,w):(this.runActionAnyway&&this.limiter.consume(g,w).catch(()=>{}),m)}block(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.block(g,w):(this.runActionAnyway&&this.limiter.block(g,w).catch(()=>{}),m)}penalty(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.penalty(g,w):(this.runActionAnyway&&this.limiter.penalty(g,w).catch(()=>{}),m)}reward(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.reward(g,w):(this.runActionAnyway&&this.limiter.reward(g,w).catch(()=>{}),m)}get(g){let w;return this.isWhiteListedSomewhere(g)?w=this.resolveWhite():this.isBlackListedSomewhere(g)&&(w=this.resolveBlack()),typeof w>"u"||this.runActionAnyway?this.limiter.get(g):w}delete(g){return this.limiter.delete(g)}}},6953:Y=>{Y.exports=class{constructor(x={}){this.points=x.points,this.duration=x.duration,this.blockDuration=x.blockDuration,this.execEvenly=x.execEvenly,this.execEvenlyMinDelayMs=x.execEvenlyMinDelayMs,this.keyPrefix=x.keyPrefix}get points(){return this._points}set points(x){this._points=x>=0?x:4}get duration(){return this._duration}set duration(x){this._duration=typeof x>"u"?1:x}get msDuration(){return 1e3*this.duration}get blockDuration(){return this._blockDuration}set blockDuration(x){this._blockDuration=typeof x>"u"?0:x}get msBlockDuration(){return 1e3*this.blockDuration}get execEvenly(){return this._execEvenly}set execEvenly(x){this._execEvenly=!(typeof x>"u")&&Boolean(x)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(x){this._execEvenlyMinDelayMs=typeof x>"u"?Math.ceil(this.msDuration/this.points):x}get keyPrefix(){return this._keyPrefix}set keyPrefix(x){if(typeof x>"u"&&(x="rlflx"),"string"!=typeof x)throw new Error("keyPrefix must be string");this._keyPrefix=x}_getKeySecDuration(x={}){return x&&x.customDuration>=0?x.customDuration:this.duration}getKey(x){return this.keyPrefix.length>0?`${this.keyPrefix}:${x}`:x}parseKey(x){return x.substring(this.keyPrefix.length)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}},9644:(Y,U,x)=>{const y=x(1265),l=x(5539),g=x(6953),w=x(4849),m=x(9658),h="rate_limiter_flexible";let c=null;const f=function(D,T,M,k){let F;F=null===k||!0===k||!1===k?k:{remainingPoints:k.remainingPoints,msBeforeNext:k.msBeforeNext,consumedPoints:k.consumedPoints,isFirstInDuration:k.isFirstInDuration},D.send({channel:h,keyPrefix:T.keyPrefix,promiseId:T.promiseId,type:M,data:F})},d=function(D){setTimeout(()=>{this._initiated?process.send(D):typeof this._promises[D.promiseId]<"u"&&d.call(this,D)},30)},b=function(D,T,M,k,F){const G={channel:h,keyPrefix:this.keyPrefix,func:D,promiseId:T,data:{key:M,arg:k,opts:F}};this._initiated?process.send(G):d.call(this,G)},S=function(D,T){if(!T||T.channel!==h||typeof this._rateLimiters[T.keyPrefix]>"u")return!1;let M;switch(T.func){case"consume":M=this._rateLimiters[T.keyPrefix].consume(T.data.key,T.data.arg,T.data.opts);break;case"penalty":M=this._rateLimiters[T.keyPrefix].penalty(T.data.key,T.data.arg,T.data.opts);break;case"reward":M=this._rateLimiters[T.keyPrefix].reward(T.data.key,T.data.arg,T.data.opts);break;case"block":M=this._rateLimiters[T.keyPrefix].block(T.data.key,T.data.arg,T.data.opts);break;case"get":M=this._rateLimiters[T.keyPrefix].get(T.data.key,T.data.opts);break;case"delete":M=this._rateLimiters[T.keyPrefix].delete(T.data.key,T.data.opts);break;default:return!1}M&&M.then(k=>{f(D,T,"resolve",k)}).catch(k=>{f(D,T,"reject",k)})},E=function(D){if(!D||D.channel!==h||D.keyPrefix!==this.keyPrefix)return!1;if(this._promises[D.promiseId]){let T;switch(clearTimeout(this._promises[D.promiseId].timeoutId),T=null===D.data||!0===D.data||!1===D.data?D.data:new m(D.data.remainingPoints,D.data.msBeforeNext,D.data.consumedPoints,D.data.isFirstInDuration),D.type){case"resolve":this._promises[D.promiseId].resolve(T);break;case"reject":this._promises[D.promiseId].reject(T);break;default:throw new Error(`RateLimiterCluster: no such message type '${D.type}'`)}delete this._promises[D.promiseId]}},v=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},p=function(D,T){const M=process.hrtime();let k=M[0].toString()+M[1].toString();return typeof this._promises[k]<"u"&&(k+=l.randomBytes(12).toString("base64")),this._promises[k]={resolve:D,reject:T,timeoutId:setTimeout(()=>{delete this._promises[k],T(new Error("RateLimiterCluster timeout: no answer from master in time"))},this.timeoutMs)},k};Y.exports={RateLimiterClusterMaster:class I{constructor(){if(c)return c;this._rateLimiters={},y.setMaxListeners(0),y.on("message",(T,M)=>{M&&M.channel===h&&"init"===M.type?(typeof this._rateLimiters[M.opts.keyPrefix]>"u"&&(this._rateLimiters[M.opts.keyPrefix]=new w(M.opts)),T.send({channel:h,type:"init",keyPrefix:M.opts.keyPrefix})):S.call(this,T,M)}),c=this}},RateLimiterClusterMasterPM2:class A{constructor(T){if(c)return c;this._rateLimiters={},T.launchBus((M,k)=>{k.on("process:msg",F=>{const G=F.raw;G&&G.channel===h&&"init"===G.type?(typeof this._rateLimiters[G.opts.keyPrefix]>"u"&&(this._rateLimiters[G.opts.keyPrefix]=new w(G.opts)),T.sendDataToProcessId(F.process.pm_id,{data:{},topic:h,channel:h,type:"init",keyPrefix:G.opts.keyPrefix},(C,O)=>{C&&console.log(C,O)})):S.call(this,{send:O=>{const V=O;V.topic=h,typeof V.data>"u"&&(V.data={}),T.sendDataToProcessId(F.process.pm_id,V,(L,$)=>{L&&console.log(L,$)})}},G)})}),c=this}},RateLimiterCluster:class P extends g{get timeoutMs(){return this._timeoutMs}set timeoutMs(T){this._timeoutMs=typeof T>"u"?5e3:Math.abs(parseInt(T))}constructor(T={}){super(T),process.setMaxListeners(0),this.timeoutMs=T.timeoutMs,this._initiated=!1,process.on("message",M=>{M&&M.channel===h&&"init"===M.type&&M.keyPrefix===this.keyPrefix?this._initiated=!0:E.call(this,M)}),process.send({channel:h,type:"init",opts:v.call(this)}),this._promises={}}consume(T,M=1,k={}){return new Promise((F,G)=>{const C=p.call(this,F,G);b.call(this,"consume",C,T,M,k)})}penalty(T,M=1,k={}){return new Promise((F,G)=>{const C=p.call(this,F,G);b.call(this,"penalty",C,T,M,k)})}reward(T,M=1,k={}){return new Promise((F,G)=>{const C=p.call(this,F,G);b.call(this,"reward",C,T,M,k)})}block(T,M,k={}){return new Promise((F,G)=>{const C=p.call(this,F,G);b.call(this,"block",C,T,M,k)})}get(T,M={}){return new Promise((k,F)=>{const G=p.call(this,k,F);b.call(this,"get",G,T,M)})}delete(T,M={}){return new Promise((k,F)=>{const G=p.call(this,k,F);b.call(this,"delete",G,T,M)})}}}},6492:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m){super(m),this.client=m.storeClient}_getRateLimiterRes(m,h,c){const f=new l;return f.consumedPoints=parseInt(c.consumedPoints),f.isFirstInDuration=c.consumedPoints===h,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=c.msBeforeNext,f}_upsert(m,h,c,f=!1,d={}){return new Promise((b,S)=>{const E=Date.now(),v=Math.floor(c/1e3);f?this.client.set(m,h,v,p=>{p?S(p):this.client.set(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.incr(m,h,(p,I)=>{p||!1===I?this.client.add(m,h,v,(A,P)=>{if(A||!P)if(typeof d.attemptNumber>"u"||d.attemptNumber<3){const D=Object.assign({},d);D.attemptNumber=D.attemptNumber?D.attemptNumber+1:1,this._upsert(m,h,c,f,D).then(T=>b(T)).catch(T=>S(T))}else S(new Error("Can not add key"));else this.client.add(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.get(`${m}_expire`,(A,P)=>{if(A)S(A);else{const D=!1===P?0:P,T={consumedPoints:I,msBeforeNext:D>=0?Math.max(D-E,0):-1};b(T)}})})})}_get(m){return new Promise((h,c)=>{const f=Date.now();this.client.get(m,(d,b)=>{b?this.client.get(`${m}_expire`,(S,E)=>{if(S)c(S);else{const v=!1===E?0:E,p={consumedPoints:b,msBeforeNext:v>=0?Math.max(v-f,0):-1};h(p)}}):h(null)})})}_delete(m){return new Promise((h,c)=>{this.client.del(m,(f,d)=>{f?c(f):!1===d?h(d):this.client.del(`${m}_expire`,b=>{b?c(b):h(d)})})})}}},4849:(Y,U,x)=>{const y=x(6953),l=x(6216),g=x(9658);Y.exports=class w extends y{constructor(h={}){super(h),this._memoryStorage=new l}consume(h,c=1,f={}){return new Promise((d,b)=>{const S=this.getKey(h),E=this._getKeySecDuration(f);let v=this._memoryStorage.incrby(S,c,E);if(v.remainingPoints=Math.max(this.points-v.consumedPoints,0),v.consumedPoints>this.points)this.blockDuration>0&&v.consumedPoints<=this.points+c&&(v=this._memoryStorage.set(S,v.consumedPoints,this.blockDuration)),b(v);else if(this.execEvenly&&v.msBeforeNext>0&&!v.isFirstInDuration){let p=Math.ceil(v.msBeforeNext/(v.remainingPoints+2));p{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}reward(h,c=1,f={}){const d=this.getKey(h);return new Promise(b=>{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,-c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}block(h,c){const f=1e3*c,d=this.points+1;return this._memoryStorage.set(this.getKey(h),d,c),Promise.resolve(new g(0,0===f?-1:f,d))}set(h,c,f){const d=1e3*(f>=0?f:this.duration);return this._memoryStorage.set(this.getKey(h),c,f),Promise.resolve(new g(0,0===d?-1:d,c))}get(h){const c=this._memoryStorage.get(this.getKey(h));return null!==c&&(c.remainingPoints=Math.max(this.points-c.consumedPoints,0)),Promise.resolve(c)}delete(h){return Promise.resolve(this._memoryStorage.delete(this.getKey(h)))}}},6217:(Y,U,x)=>{const y=x(3129),l=x(9658);function g(m){try{const h=m.client?m.client:m,{version:c}=h.topology.s.options.metadata.driver,f=c.split(".").map(d=>parseInt(d));return{major:f[0],feature:f[1],patch:f[2]}}catch{return{major:0,feature:0,patch:0}}}class w extends y{constructor(h){super(h),this.dbName=h.dbName,this.tableName=h.tableName,this.indexKeyPrefix=h.indexKeyPrefix,this.client=h.mongo?h.mongo:h.storeClient,"function"==typeof this.client.then?this.client.then(c=>{this.client=c,this._initCollection(),this._driverVersion=g(this.client)}):(this._initCollection(),this._driverVersion=g(this.client))}get dbName(){return this._dbName}set dbName(h){this._dbName=typeof h>"u"?w.getDbName():h}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(h){this._tableName=typeof h>"u"?this.keyPrefix:h}get client(){return this._client}set client(h){if(typeof h>"u")throw new Error("mongo is not set");this._client=h}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(h){this._indexKeyPrefix=h||{}}_initCollection(){const c=("function"==typeof this.client.db?this.client.db(this.dbName):this.client).collection(this.tableName);c.createIndex({expire:-1},{expireAfterSeconds:0}),c.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=c}_getRateLimiterRes(h,c,f){const d=new l;let b;return b=typeof f.value>"u"?f:f.value,d.isFirstInDuration=b.points===c,d.consumedPoints=b.points,d.remainingPoints=Math.max(this.points-d.consumedPoints,0),d.msBeforeNext=null!==b.expire?Math.max(new Date(b.expire).getTime()-Date.now(),0):-1,d}_upsert(h,c,f,d=!1,b={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const S=b.attrs||{};let E,v;d?(E={key:h},E=Object.assign(E,S),v={$set:{key:h,points:c,expire:f>0?new Date(Date.now()+f):null}},v.$set=Object.assign(v.$set,S)):(E={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:h},E=Object.assign(E,S),v={$setOnInsert:{key:h,expire:f>0?new Date(Date.now()+f):null},$inc:{points:c}},v.$setOnInsert=Object.assign(v.$setOnInsert,S));const p={upsert:!0};return this._driverVersion.major>=4||3===this._driverVersion.major&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?p.returnDocument="after":p.returnOriginal=!1,new Promise((I,A)=>{this._collection.findOneAndUpdate(E,v,p).then(P=>{I(P)}).catch(P=>{if(P&&11e3===P.code){const D=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:h},S),T={$set:Object.assign({key:h,points:c,expire:f>0?new Date(Date.now()+f):null},S)};this._collection.findOneAndUpdate(D,T,p).then(M=>{I(M)}).catch(M=>{M&&11e3===M.code?this._upsert(h,c,f,d).then(k=>I(k)).catch(k=>A(k)):A(M)})}else A(P)})})}_get(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const f=c.attrs||{},d=Object.assign({key:h,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},f);return this._collection.findOne(d)}_delete(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const d=Object.assign({key:h},c.attrs||{});return this._collection.deleteOne(d).then(b=>b.deletedCount>0)}}Y.exports=w},7840:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.dbName=m.dbName,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._getConnection().then(c=>{c.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,m],()=>{this._releaseConnection(c),h()})}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise((m,h)=>{this.client.getConnection((c,f)=>{if(c)return h(c);m(f)})});case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(m){switch(this.clientType){case"pool":return m.release();case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m);default:return!0}}_createDbAndTable(){return new Promise((m,h)=>{this._getConnection().then(c=>{c.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,f=>{if(f)return this._releaseConnection(c),h(f);c.query(this._getCreateTableStmt(),d=>{if(d)return this._releaseConnection(c),h(d);this._releaseConnection(c),m()})})}).catch(c=>{h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (\`key\` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\`points\` INT(9) NOT NULL default 0,\`expire\` BIGINT UNSIGNED,PRIMARY KEY (\`key\`)) ENGINE = INNODB;`}get clientType(){return this._clientType}set clientType(m){if(typeof m>"u")if("Connection"===this.client.constructor.name)m="connection";else if("Pool"===this.client.constructor.name)m="pool";else{if("Sequelize"!==this.client.constructor.name)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get dbName(){return this._dbName}set dbName(m){this._dbName=typeof m>"u"?"rtlmtrflx":m}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new l,[d]=c;return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_upsertTransaction(m,h,c,f,d){return new Promise((b,S)=>{m.query("BEGIN",E=>{if(E)return m.rollback(),S(E);const v=Date.now(),p=f>0?v+f:null;let I,A;d?(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;",A=[this.dbName,this.tableName,h,c,p,c,p]):(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = IF(expire <= ?, ?, points + (?)), \n expire = IF(expire <= ?, ?, expire);",A=[this.dbName,this.tableName,h,c,p,v,c,c,v,p]),m.query(I,A,P=>{if(P)return m.rollback(),S(P);m.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,h],(D,T)=>{if(D)return m.rollback(),S(D);m.query("COMMIT",M=>{if(M)return m.rollback(),S(M);b(T)})})})})})}_upsert(m,h,c,f=!1){return this.tableCreated?new Promise((d,b)=>{this._getConnection().then(S=>{this._upsertTransaction(S,m,h,c,f).then(E=>{d(E),this._releaseConnection(S)}).catch(E=>{b(E),this._releaseConnection(S)})}).catch(S=>{b(S)})}):Promise.reject(Error("Table is not created yet"))}_get(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,m,Date.now()],(d,b)=>{d?c(d):h(0===b.length?null:b),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,m],(d,b)=>{d?c(d):h(b.affectedRows>0),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}}},939:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?"function"==typeof h&&h():this._createTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._query({name:"rlflx-clear-expired",text:`DELETE FROM ${this.tableName} WHERE expire < $1`,values:[m]}).then(()=>{h()}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":default:return Promise.resolve(this.client);case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();case"typeorm":return Promise.resolve(this.client.driver.master)}}_releaseConnection(m){switch(this.clientType){case"pool":case"typeorm":default:return!0;case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m)}}_createTable(){return new Promise((m,h)=>{this._query({text:this._getCreateTableStmt()}).then(()=>{m()}).catch(c=>{"23505"===c.code?m():h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS ${this.tableName} ( \n key varchar(255) PRIMARY KEY,\n points integer NOT NULL DEFAULT 0,\n expire bigint\n );`}get clientType(){return this._clientType}set clientType(m){const h=this.client.constructor.name;if(typeof m>"u")if("Client"===h)m="client";else if("Pool"===h||"BoundPool"===h)m="pool";else{if("Sequelize"!==h)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new l,d=c.rows[0];return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_query(m){const c={name:`${this.tableName.toLowerCase()}:${m.name}`,text:m.text,values:m.values};return new Promise((f,d)=>{this._getConnection().then(b=>{b.query(c).then(S=>{f(S),this._releaseConnection(b)}).catch(S=>{d(S),this._releaseConnection(b)})}).catch(b=>{d(b)})})}_upsert(m,h,c,f=!1){if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));const d=c>0?Date.now()+c:null;return this._query({name:f?"rlflx-upsert-force":"rlflx-upsert",text:`\n INSERT INTO ${this.tableName} VALUES ($1, $2, $3)\n ON CONFLICT(key) DO UPDATE SET\n points = CASE\n WHEN (${this.tableName}.expire <= $4 OR 1=${f?1:0}) THEN $2\n ELSE ${this.tableName}.points + ($2)\n END,\n expire = ${f?" $3 ":` CASE\n WHEN ${this.tableName}.expire <= $4 THEN $3\n ELSE ${this.tableName}.expire\n END `}\n RETURNING points, expire;`,values:[m,h,d,Date.now()]})}_get(m){return this.tableCreated?new Promise((h,c)=>{this._query({name:"rlflx-get",text:`\n SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,values:[m,Date.now()]}).then(f=>{0===f.rowCount&&(f=null),h(f)}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?this._query({name:"rlflx-delete",text:`DELETE FROM ${this.tableName} WHERE key = $1`,values:[m]}).then(h=>h.rowCount>0):Promise.reject(Error("Table is not created yet"))}}},2816:(Y,U,x)=>{const y=x(2047),l=4294967295,g="limiter";Y.exports=class{constructor(h,c={maxQueueSize:l}){this._queueLimiters={KEY_DEFAULT:new w(h,c)},this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(h=g){return this._queueLimiters[h]?this._queueLimiters[h].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(h,c=g){return this._queueLimiters[c]||(this._queueLimiters[c]=new w(this._limiterFlexible,{key:c,maxQueueSize:this._maxQueueSize})),this._queueLimiters[c].removeTokens(h)}};class w{constructor(h,c={maxQueueSize:l,key:g}){this._key=c.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then(h=>null!==h?h.remainingPoints:this._limiterFlexible.points)}removeTokens(h){const c=this;return new Promise((f,d)=>{h>c._limiterFlexible.points?d(new y(`Requested tokens ${h} exceeds maximum ${c._limiterFlexible.points} tokens per interval`)):c._queue.length>0?c._queueRequest.call(c,f,d,h):c._limiterFlexible.consume(c._key,h).then(b=>{f(b.remainingPoints)}).catch(b=>{b instanceof Error?d(b):(c._queueRequest.call(c,f,d,h),null===c._waitTimeout&&(c._waitTimeout=setTimeout(c._processFIFO.bind(c),b.msBeforeNext)))})})}_queueRequest(h,c,f){const d=this;d._queue.length{c.resolve(f.remainingPoints),h._processFIFO.call(h)}).catch(f=>{f instanceof Error?(c.reject(f),h._processFIFO.call(h)):(h._queue.unshift(c),null===h._waitTimeout&&(h._waitTimeout=setTimeout(h._processFIFO.bind(h),f.msBeforeNext)))})}}},9301:(Y,U,x)=>{const y=x(3129),l=x(9658),g="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";Y.exports=class w extends y{constructor(h){super(h),this.client=h.redis?h.redis:h.storeClient,"function"==typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:g})}_getRateLimiterRes(h,c,f){let[d,b]=f;Array.isArray(d)&&([,d]=d,[,b]=b);const S=new l;return S.consumedPoints=parseInt(d),S.isFirstInDuration=S.consumedPoints===c,S.remainingPoints=Math.max(this.points-S.consumedPoints,0),S.msBeforeNext=b,S}_upsert(h,c,f,d=!1){return new Promise((b,S)=>{const E=Math.floor(f/1e3),v=this.client.multi();if(d)E>0?v.set(h,c,"EX",E):v.set(h,c),v.pttl(h).exec((p,I)=>p?S(p):b(I));else if(E>0){const p=function(I,A){return I?S(I):b(A)};"function"==typeof this.client.rlflxIncr?this.client.rlflxIncr(h,c,E,p):this.client.eval(g,1,h,c,E,p)}else v.incrby(h,c).pttl(h).exec((p,I)=>p?S(p):b(I))})}_get(h){return new Promise((c,f)=>{this.client.multi().get(h).pttl(h).exec((d,b)=>{if(d)f(d);else{const[S]=b;if(null===S)return c(null);c(b)}})})}_delete(h){return new Promise((c,f)=>{this.client.del(h,(d,b)=>{d?f(d):c(b>0)})})}}},9658:Y=>{Y.exports=class{constructor(x,y,l,g){this.remainingPoints=typeof x>"u"?0:x,this.msBeforeNext=typeof y>"u"?0:y,this.consumedPoints=typeof l>"u"?0:l,this.isFirstInDuration=!(typeof g>"u")&&g}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(x){return this._msBeforeNext=x,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(x){return this._remainingPoints=x,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(x){return this._consumedPoints=x,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(x){this._isFirstInDuration=Boolean(x)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}},3129:(Y,U,x)=>{const y=x(6953),l=x(8442),g=x(9658);Y.exports=class extends y{constructor(m={}){super(m),this.inmemoryBlockOnConsumed=m.inmemoryBlockOnConsumed,this.inmemoryBlockDuration=m.inmemoryBlockDuration,this.insuranceLimiter=m.insuranceLimiter,this._inmemoryBlockedKeys=new l}get client(){return this._client}set client(m){if(typeof m>"u")throw new Error("storeClient is not set");this._client=m}_afterConsume(m,h,c,f,d,b={}){const S=this._getRateLimiterRes(c,f,d);if(this.inmemoryBlockOnConsumed>0&&!(this.inmemoryBlockDuration>0)&&S.consumedPoints>=this.inmemoryBlockOnConsumed)return this._inmemoryBlockedKeys.addMs(c,S.msBeforeNext),S.consumedPoints>this.points?h(S):m(S);if(S.consumedPoints>this.points){let E=Promise.resolve();this.blockDuration>0&&S.consumedPoints<=this.points+f&&(S.msBeforeNext=this.msBlockDuration,E=this._block(c,S.consumedPoints,this.msBlockDuration,b)),this.inmemoryBlockOnConsumed>0&&S.consumedPoints>=this.inmemoryBlockOnConsumed&&(this._inmemoryBlockedKeys.add(c,this.inmemoryBlockDuration),S.msBeforeNext=this.msInmemoryBlockDuration),E.then(()=>{h(S)}).catch(v=>{h(v)})}else if(this.execEvenly&&S.msBeforeNext>0&&!S.isFirstInDuration){let E=Math.ceil(S.msBeforeNext/(S.remainingPoints+2));E{c(E)}).catch(E=>{f(E)}):f(m)}getInmemoryBlockMsBeforeExpire(m){return this.inmemoryBlockOnConsumed>0?this._inmemoryBlockedKeys.msBeforeExpire(m):0}get inmemoryBlockOnConsumed(){return this._inmemoryBlockOnConsumed}set inmemoryBlockOnConsumed(m){if(this._inmemoryBlockOnConsumed=m?parseInt(m):0,this.inmemoryBlockOnConsumed>0&&this.points>this.inmemoryBlockOnConsumed)throw new Error('inmemoryBlockOnConsumed option must be greater or equal "points" option')}get inmemoryBlockDuration(){return this._inmemoryBlockDuration}set inmemoryBlockDuration(m){if(this._inmemoryBlockDuration=m?parseInt(m):0,this.inmemoryBlockDuration>0&&0===this.inmemoryBlockOnConsumed)throw new Error("inmemoryBlockOnConsumed option must be set up")}get msInmemoryBlockDuration(){return 1e3*this._inmemoryBlockDuration}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(m){if(typeof m<"u"&&!(m instanceof y))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=m,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(m,h,c={}){const f=1e3*h;return this._block(this.getKey(m),this.points+1,f,c)}set(m,h,c,f={}){const d=1e3*(c>=0?c:this.duration);return this._block(this.getKey(m),h,d,f)}consume(m,h=1,c={}){return new Promise((f,d)=>{const b=this.getKey(m),S=this.getInmemoryBlockMsBeforeExpire(b);if(S>0)return d(new g(0,S));this._upsert(b,h,1e3*this._getKeySecDuration(c),!1,c).then(E=>{this._afterConsume(f,d,b,h,E)}).catch(E=>{this._handleError(E,"consume",f,d,m,h,c)})})}penalty(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,h,S))}).catch(S=>{this._handleError(S,"penalty",d,b,m,h,c)})})}reward(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,-h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,-h,S))}).catch(S=>{this._handleError(S,"reward",d,b,m,h,c)})})}get(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._get(c,h).then(b=>{f(null===b||typeof b>"u"?null:this._getRateLimiterRes(c,0,b))}).catch(b=>{this._handleError(b,"get",f,d,m,h)})})}delete(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._delete(c,h).then(b=>{this._inmemoryBlockedKeys.delete(c),f(b)}).catch(b=>{this._handleError(b,"delete",f,d,m,h)})})}deleteInMemoryBlockedAll(){this._inmemoryBlockedKeys.delete()}_getRateLimiterRes(m,h,c){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(m,h,c,f={}){return new Promise((d,b)=>{this._upsert(m,h,c,!0,f).then(()=>{d(new g(0,c>0?c:-1,h))}).catch(S=>{this._handleError(S,"block",d,b,this.parseKey(m),c/1e3,f)})})}_get(m,h={}){throw new Error("You have to implement the method '_get'!")}_delete(m,h={}){throw new Error("You have to implement the method '_delete'!")}_upsert(){throw new Error("You have to implement the method '_upsert'!")}}},8592:(Y,U,x)=>{const y=x(6953);Y.exports=class{constructor(...g){if(g.length<2)throw new Error("RateLimiterUnion: at least two limiters have to be set");g.forEach(w=>{if(!(w instanceof y))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")}),this._limiters=g}consume(g,w=1){return new Promise((m,h)=>{const c=[];this._limiters.forEach(f=>{c.push(f.consume(g,w).catch(d=>({rejected:!0,rej:d})))}),Promise.all(c).then(f=>{const d={};let b=!1;f.forEach(S=>{!0===S.rejected&&(b=!0)});for(let S=0;S{Y.exports=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const x=Date.now();Object.keys(this._keys).forEach(y=>{this._keys[y]<=x&&delete this._keys[y]}),this._addedKeysAmount=Object.keys(this._keys).length}add(x,y){this.addMs(x,1e3*y)}addMs(x,y){this._keys[x]=Date.now()+y,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(x){const y=this._keys[x];if(y&&y>=Date.now()){this.collectExpired();const l=Date.now();return y>=l?y-l:0}return 0}delete(x){x?delete this._keys[x]:Object.keys(this._keys).forEach(y=>{delete this._keys[y]})}}},8442:(Y,U,x)=>{const y=x(2585);Y.exports=y},6216:(Y,U,x)=>{const y=x(7105),l=x(9658);Y.exports=class{constructor(){this._storage={}}incrby(w,m,h){if(this._storage[w]){const c=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return 0!==c?(this._storage[w].value=this._storage[w].value+m,new l(0,c,this._storage[w].value,!1)):this.set(w,m,h)}return this.set(w,m,h)}set(w,m,h){const c=1e3*h;return this._storage[w]&&this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),this._storage[w]=new y(m,c>0?new Date(Date.now()+c):null),c>0&&(this._storage[w].timeoutId=setTimeout(()=>{delete this._storage[w]},c),this._storage[w].timeoutId.unref&&this._storage[w].timeoutId.unref()),new l(0,0===c?-1:c,this._storage[w].value,!0)}get(w){if(this._storage[w]){const m=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return new l(0,m,this._storage[w].value,!1)}return null}delete(w){return!!this._storage[w]&&(this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),delete this._storage[w],!0)}}},7105:Y=>{Y.exports=class{constructor(x,y,l=null){this.value=x,this.expiresAt=y,this.timeoutId=l}get value(){return this._value}set value(x){this._value=parseInt(x)}get expiresAt(){return this._expiresAt}set expiresAt(x){!(x instanceof Date)&&Number.isInteger(x)&&(x=new Date(x)),this._expiresAt=x}get timeoutId(){return this._timeoutId}set timeoutId(x){this._timeoutId=x}}},2047:Y=>{Y.exports=class extends Error{constructor(x,y){super(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="CustomError",this.message=x,y&&(this.extra=y)}}},4033:(Y,U,x)=>{"use strict";Y.exports=m;var y=x(4366),l=m.prototype,g=new Date%1e9;function m(h){this.id=(h=h||{}).id||function w(){return(1e9*Math.random()>>>0)+g++}(),this.max=h.max||1/0,this.items=h.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(h.lastModified||new Date);for(var c,f,d=this.items.length;d--;)c=this.items[d],f=new Date(c.expires)-new Date,this._lookup[c.key]=c,f>0?this.expire(c.key,f):f<=0&&this.delete(c.key)}l.has=function(h){return h in this._lookup},l.get=function(h){if(!this.has(h))return null;var c=this._lookup[h];return c.refresh&&this.expire(h,c.refresh),this.items.splice(this.items.indexOf(c),1),this.items.push(c),c.value},l.meta=function(h){if(!this.has(h))return null;var c=this._lookup[h];return"meta"in c?c.meta:null},l.set=function(h,c,f){var d=this._lookup[h],b=this._lookup[h]={key:h,value:c};return this.lastModified=new Date,d?(clearTimeout(d.timeout),this.items.splice(this.items.indexOf(d),1,b)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(b),this.size++),f&&("ttl"in f&&this.expire(h,f.ttl),"meta"in f&&(b.meta=f.meta),f.refresh&&(b.refresh=f.ttl)),this},l.delete=function(h){var c=this._lookup[h];return!!c&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(c),1),clearTimeout(c.timeout),delete this._lookup[h],this.size--,this)},l.expire=function(h,c){var f=c||0,d=this._lookup[h];if(!d)return this;if("string"==typeof f&&(f=y(c)),"number"!=typeof f)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(d.timeout),d.timeout=setTimeout(this.delete.bind(this,d.key),f),d.expires=Number(new Date)+f,this},l.clear=function(){for(var h=this.items.length;h--;)this.delete(this.items[h].key);return this},l.toJSON=function(){for(var c,h=new Array(this.items.length),f=h.length;f--;)h[f]={key:(c=this.items[f]).key,meta:c.meta,value:c.value,expires:c.expires,refresh:c.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:h}}},2502:(Y,U,x)=>{"use strict";const y=x(7806);class l{constructor(m,h,c){const f=this;this._started=y(),this._rescheduled=0,this._scheduled=h,this._args=c,this._triggered=!1,this._timerWrapper=()=>{f._rescheduled>0?(f._scheduled=f._rescheduled-(y()-f._started),f._schedule(f._scheduled)):(f._triggered=!0,m.apply(null,f._args))},this._timer=setTimeout(this._timerWrapper,h)}reschedule(m){m||(m=this._scheduled);const h=y();h+m-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(m)):this._triggered?this._schedule(m):(this._started=h,this._rescheduled=m)}_schedule(m){this._triggered=!1,this._started=y(),this._rescheduled=0,this._scheduled=m,this._timer=setTimeout(this._timerWrapper,m)}clear(){clearTimeout(this._timer)}}Y.exports=function g(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");let w;if(arguments.length>0){w=new Array(arguments.length-2);for(var m=0;m{"use strict";Y.exports=function(){return Date.now()}},9014:(Y,U,x)=>{"use strict";var y=x(9942),l=/[\/\?<>\\:\*\|"]/g,g=/[\x00-\x1f\x80-\x9f]/g,w=/^\.+$/,m=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,h=/[\. ]+$/;function c(f,d){if("string"!=typeof f)throw new Error("Input must be string");var b=f.replace(l,d).replace(g,d).replace(w,d).replace(m,d).replace(h,d);return y(b,255)}Y.exports=function(f,d){var b=d&&d.replacement||"",S=c(f,b);return""===b?S:c(S,"")}},1466:(Y,U,x)=>{"use strict";var y=x(7156).default;const l=new Map;function m(){return(m=y(function*(f,d,b){for(;l.get(b);){try{yield f()}catch(S){setTimeout(()=>{throw S},1);break}if(!l.get(b))break;yield new Promise(S=>{const E=setTimeout(S,d);l.set(b,E)})}})).apply(this,arguments)}Y.exports={setDelayedInterval:function h(f,d,b){b=b||d;const S=`${Date.now()}:${Math.floor(1e6*Math.random())}`,E=setTimeout(()=>{!function w(f,d,b){m.apply(this,arguments)}(f,d,S)},b);return l.set(S,E),S},clearDelayedInterval:function c(f){const d=l.get(f);d&&(clearTimeout(d),l.delete(f))}}},1420:(Y,U,x)=>{"use strict";const{AbortController:y}=globalThis,l=x(2502);class g extends y{constructor(m){super(),this._ms=m,this._timer=l(()=>this.abort(),m),Object.setPrototypeOf(this,g.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=l(()=>this.abort(),this._ms)}}Y.exports={TimeoutController:g}},9942:(Y,U,x)=>{"use strict";var y=x(8831),l=x(8871);Y.exports=y.bind(null,l)},8831:Y=>{"use strict";function x(y){return y>=56320&&y<=57343}Y.exports=function(l,g,w){if("string"!=typeof g)throw new Error("Input must be string");for(var c,f,m=g.length,h=0,d=0;d=55296&&y<=56319&&x(g.charCodeAt(d+1))&&(f+=g[d+=1]),(h+=l(f))===w)return g.slice(0,d+1);if(h>w)return g.slice(0,d-f.length+1)}var y;return g}},8871:Y=>{"use strict";function U(y){return y>=55296&&y<=56319}Y.exports=function(l){if("string"!=typeof l)throw new Error("Input must be string");for(var g=l.length,w=0,m=null,h=null,c=0;c=56320&&y<=57343?null!=h&&U(h)?w+=1:w+=3:m<=127?w+=1:m>=128&&m<=2047?w+=2:m>=2048&&m<=65535&&(w+=3),h=m;var y;return w}},3004:Y=>{Y.exports=function y(l,m){var f,w=0,h=0,c=m=m||0,d=l.length;do{if(c>=d||h>49)throw y.bytes=0,new RangeError("Could not decode varint");f=l[c++],w+=h<28?(127&f)<=128);return y.bytes=c-m,w}},5723:Y=>{Y.exports=function g(w,m,h){if(Number.MAX_SAFE_INTEGER&&w>Number.MAX_SAFE_INTEGER)throw g.bytes=0,new RangeError("Could not encode varint");m=m||[];for(var c=h=h||0;w>=l;)m[h++]=255&w|128,w/=128;for(;-128&w;)m[h++]=255&w|128,w>>>=7;return m[h]=0|w,g.bytes=h-c+1,m};var l=Math.pow(2,31)},1732:(Y,U,x)=>{Y.exports={encode:x(5723),decode:x(3004),encodingLength:x(4036)}},4036:Y=>{var U=Math.pow(2,7),x=Math.pow(2,14),y=Math.pow(2,21),l=Math.pow(2,28),g=Math.pow(2,35),w=Math.pow(2,42),m=Math.pow(2,49),h=Math.pow(2,56),c=Math.pow(2,63);Y.exports=function(f){return f{"use strict";!function(ie){const fe=ie.performance;function ye(Ft){fe&&fe.mark&&fe.mark(Ft)}function me(Ft,ct){fe&&fe.measure&&fe.measure(Ft,ct)}ye("Zone");const _e=ie.__Zone_symbol_prefix||"__zone_symbol__";function Ne(Ft){return _e+Ft}const Qe=!0===ie[Ne("forceDuplicateZoneCheck")];if(ie.Zone){if(Qe||"function"!=typeof ie.Zone.__symbol__)throw new Error("Zone already loaded.");return ie.Zone}let qe=(()=>{class Ft{constructor(ce,ve){this._parent=ce,this._name=ve?ve.name||"unnamed":"",this._properties=ve&&ve.properties||{},this._zoneDelegate=new nt(this,this._parent&&this._parent._zoneDelegate,ve)}static assertZonePatched(){if(ie.Promise!==Pr.ZoneAwarePromise)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")}static get root(){let ce=Ft.current;for(;ce.parent;)ce=ce.parent;return ce}static get current(){return vn.zone}static get currentTask(){return ur}static __load_patch(ce,ve,yt=!1){if(Pr.hasOwnProperty(ce)){if(!yt&&Qe)throw Error("Already loaded patch: "+ce)}else if(!ie["__Zone_disable_"+ce]){const Dt="Zone:"+ce;ye(Dt),Pr[ce]=ve(ie,Ft,On),me(Dt,Dt)}}get parent(){return this._parent}get name(){return this._name}get(ce){const ve=this.getZoneWith(ce);if(ve)return ve._properties[ce]}getZoneWith(ce){let ve=this;for(;ve;){if(ve._properties.hasOwnProperty(ce))return ve;ve=ve._parent}return null}fork(ce){if(!ce)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,ce)}wrap(ce,ve){if("function"!=typeof ce)throw new Error("Expecting function got: "+ce);const yt=this._zoneDelegate.intercept(this,ce,ve),Dt=this;return function(){return Dt.runGuarded(yt,this,arguments,ve)}}run(ce,ve,yt,Dt){vn={parent:vn,zone:this};try{return this._zoneDelegate.invoke(this,ce,ve,yt,Dt)}finally{vn=vn.parent}}runGuarded(ce,ve=null,yt,Dt){vn={parent:vn,zone:this};try{try{return this._zoneDelegate.invoke(this,ce,ve,yt,Dt)}catch(gn){if(this._zoneDelegate.handleError(this,gn))throw gn}}finally{vn=vn.parent}}runTask(ce,ve,yt){if(ce.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(ce.zone||Tn).name+"; Execution: "+this.name+")");if(ce.state===Bt&&(ce.type===Jn||ce.type===wt))return;const Dt=ce.state!=ft;Dt&&ce._transitionTo(ft,en),ce.runCount++;const gn=ur;ur=ce,vn={parent:vn,zone:this};try{ce.type==wt&&ce.data&&!ce.data.isPeriodic&&(ce.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,ce,ve,yt)}catch(je){if(this._zoneDelegate.handleError(this,je))throw je}}finally{ce.state!==Bt&&ce.state!==st&&(ce.type==Jn||ce.data&&ce.data.isPeriodic?Dt&&ce._transitionTo(en,ft):(ce.runCount=0,this._updateTaskCount(ce,-1),Dt&&ce._transitionTo(Bt,ft,Bt))),vn=vn.parent,ur=gn}}scheduleTask(ce){if(ce.zone&&ce.zone!==this){let yt=this;for(;yt;){if(yt===ce.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${ce.zone.name}`);yt=yt.parent}}ce._transitionTo(pn,Bt);const ve=[];ce._zoneDelegates=ve,ce._zone=this;try{ce=this._zoneDelegate.scheduleTask(this,ce)}catch(yt){throw ce._transitionTo(st,pn,Bt),this._zoneDelegate.handleError(this,yt),yt}return ce._zoneDelegates===ve&&this._updateTaskCount(ce,1),ce.state==pn&&ce._transitionTo(en,pn),ce}scheduleMicroTask(ce,ve,yt,Dt){return this.scheduleTask(new Ke(Kt,ce,ve,yt,Dt,void 0))}scheduleMacroTask(ce,ve,yt,Dt,gn){return this.scheduleTask(new Ke(wt,ce,ve,yt,Dt,gn))}scheduleEventTask(ce,ve,yt,Dt,gn){return this.scheduleTask(new Ke(Jn,ce,ve,yt,Dt,gn))}cancelTask(ce){if(ce.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(ce.zone||Tn).name+"; Execution: "+this.name+")");ce._transitionTo(ln,en,ft);try{this._zoneDelegate.cancelTask(this,ce)}catch(ve){throw ce._transitionTo(st,ln),this._zoneDelegate.handleError(this,ve),ve}return this._updateTaskCount(ce,-1),ce._transitionTo(Bt,ln),ce.runCount=0,ce}_updateTaskCount(ce,ve){const yt=ce._zoneDelegates;-1==ve&&(ce._zoneDelegates=null);for(let Dt=0;DtFt.hasTask(ce,ve),onScheduleTask:(Ft,ct,ce,ve)=>Ft.scheduleTask(ce,ve),onInvokeTask:(Ft,ct,ce,ve,yt,Dt)=>Ft.invokeTask(ce,ve,yt,Dt),onCancelTask:(Ft,ct,ce,ve)=>Ft.cancelTask(ce,ve)};class nt{constructor(ct,ce,ve){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=ct,this._parentDelegate=ce,this._forkZS=ve&&(ve&&ve.onFork?ve:ce._forkZS),this._forkDlgt=ve&&(ve.onFork?ce:ce._forkDlgt),this._forkCurrZone=ve&&(ve.onFork?this.zone:ce._forkCurrZone),this._interceptZS=ve&&(ve.onIntercept?ve:ce._interceptZS),this._interceptDlgt=ve&&(ve.onIntercept?ce:ce._interceptDlgt),this._interceptCurrZone=ve&&(ve.onIntercept?this.zone:ce._interceptCurrZone),this._invokeZS=ve&&(ve.onInvoke?ve:ce._invokeZS),this._invokeDlgt=ve&&(ve.onInvoke?ce:ce._invokeDlgt),this._invokeCurrZone=ve&&(ve.onInvoke?this.zone:ce._invokeCurrZone),this._handleErrorZS=ve&&(ve.onHandleError?ve:ce._handleErrorZS),this._handleErrorDlgt=ve&&(ve.onHandleError?ce:ce._handleErrorDlgt),this._handleErrorCurrZone=ve&&(ve.onHandleError?this.zone:ce._handleErrorCurrZone),this._scheduleTaskZS=ve&&(ve.onScheduleTask?ve:ce._scheduleTaskZS),this._scheduleTaskDlgt=ve&&(ve.onScheduleTask?ce:ce._scheduleTaskDlgt),this._scheduleTaskCurrZone=ve&&(ve.onScheduleTask?this.zone:ce._scheduleTaskCurrZone),this._invokeTaskZS=ve&&(ve.onInvokeTask?ve:ce._invokeTaskZS),this._invokeTaskDlgt=ve&&(ve.onInvokeTask?ce:ce._invokeTaskDlgt),this._invokeTaskCurrZone=ve&&(ve.onInvokeTask?this.zone:ce._invokeTaskCurrZone),this._cancelTaskZS=ve&&(ve.onCancelTask?ve:ce._cancelTaskZS),this._cancelTaskDlgt=ve&&(ve.onCancelTask?ce:ce._cancelTaskDlgt),this._cancelTaskCurrZone=ve&&(ve.onCancelTask?this.zone:ce._cancelTaskCurrZone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const yt=ve&&ve.onHasTask;(yt||ce&&ce._hasTaskZS)&&(this._hasTaskZS=yt?ve:it,this._hasTaskDlgt=ce,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=ct,ve.onScheduleTask||(this._scheduleTaskZS=it,this._scheduleTaskDlgt=ce,this._scheduleTaskCurrZone=this.zone),ve.onInvokeTask||(this._invokeTaskZS=it,this._invokeTaskDlgt=ce,this._invokeTaskCurrZone=this.zone),ve.onCancelTask||(this._cancelTaskZS=it,this._cancelTaskDlgt=ce,this._cancelTaskCurrZone=this.zone))}fork(ct,ce){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,ct,ce):new qe(ct,ce)}intercept(ct,ce,ve){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,ct,ce,ve):ce}invoke(ct,ce,ve,yt,Dt){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,ct,ce,ve,yt,Dt):ce.apply(ve,yt)}handleError(ct,ce){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,ct,ce)}scheduleTask(ct,ce){let ve=ce;if(this._scheduleTaskZS)this._hasTaskZS&&ve._zoneDelegates.push(this._hasTaskDlgtOwner),ve=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,ct,ce),ve||(ve=ce);else if(ce.scheduleFn)ce.scheduleFn(ce);else{if(ce.type!=Kt)throw new Error("Task is missing scheduleFn.");mt(ce)}return ve}invokeTask(ct,ce,ve,yt){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,ct,ce,ve,yt):ce.callback.apply(ve,yt)}cancelTask(ct,ce){let ve;if(this._cancelTaskZS)ve=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,ct,ce);else{if(!ce.cancelFn)throw Error("Task is not cancelable");ve=ce.cancelFn(ce)}return ve}hasTask(ct,ce){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,ct,ce)}catch(ve){this.handleError(ct,ve)}}_updateTaskCount(ct,ce){const ve=this._taskCounts,yt=ve[ct],Dt=ve[ct]=yt+ce;if(Dt<0)throw new Error("More tasks executed then were scheduled.");0!=yt&&0!=Dt||this.hasTask(this.zone,{microTask:ve.microTask>0,macroTask:ve.macroTask>0,eventTask:ve.eventTask>0,change:ct})}}class Ke{constructor(ct,ce,ve,yt,Dt,gn){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=ct,this.source=ce,this.data=yt,this.scheduleFn=Dt,this.cancelFn=gn,!ve)throw new Error("callback is not defined");this.callback=ve;const je=this;this.invoke=ct===Jn&&yt&&yt.useG?Ke.invokeTask:function(){return Ke.invokeTask.call(ie,je,this,arguments)}}static invokeTask(ct,ce,ve){ct||(ct=this),Qn++;try{return ct.runCount++,ct.zone.runTask(ct,ce,ve)}finally{1==Qn&&et(),Qn--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(Bt,pn)}_transitionTo(ct,ce,ve){if(this._state!==ce&&this._state!==ve)throw new Error(`${this.type} '${this.source}': can not transition to '${ct}', expecting state '${ce}'${ve?" or '"+ve+"'":""}, was '${this._state}'.`);this._state=ct,ct==Bt&&(this._zoneDelegates=null)}toString(){return this.data&&typeof this.data.handleId<"u"?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const we=Ne("setTimeout"),ge=Ne("Promise"),De=Ne("then");let dt,Fe=[],Be=!1;function xt(Ft){if(dt||ie[ge]&&(dt=ie[ge].resolve(0)),dt){let ct=dt[De];ct||(ct=dt.then),ct.call(dt,Ft)}else ie[we](Ft,0)}function mt(Ft){0===Qn&&0===Fe.length&&xt(et),Ft&&Fe.push(Ft)}function et(){if(!Be){for(Be=!0;Fe.length;){const Ft=Fe;Fe=[];for(let ct=0;ctvn,onUnhandledError:En,microtaskDrainDone:En,scheduleMicroTask:mt,showUncaughtError:()=>!qe[Ne("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:En,patchMethod:()=>En,bindArguments:()=>[],patchThen:()=>En,patchMacroTask:()=>En,patchEventPrototype:()=>En,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>En,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>En,wrapWithCurrentZone:()=>En,filterProperties:()=>[],attachOriginToPatched:()=>En,_redefineProperty:()=>En,patchCallbacks:()=>En,nativeScheduleMicroTask:xt};let vn={parent:null,zone:new qe(null,null)},ur=null,Qn=0;function En(){}me("Zone","Zone"),ie.Zone=qe}(typeof window<"u"&&window||typeof self<"u"&&self||global);const Y=Object.getOwnPropertyDescriptor,U=Object.defineProperty,x=Object.getPrototypeOf,y=Object.create,l=Array.prototype.slice,g="addEventListener",w="removeEventListener",m=Zone.__symbol__(g),h=Zone.__symbol__(w),c="true",f="false",d=Zone.__symbol__("");function b(ie,fe){return Zone.current.wrap(ie,fe)}function S(ie,fe,ye,me,_e){return Zone.current.scheduleMacroTask(ie,fe,ye,me,_e)}const E=Zone.__symbol__,v=typeof window<"u",p=v?window:void 0,I=v&&p||"object"==typeof self&&self||global;function P(ie,fe){for(let ye=ie.length-1;ye>=0;ye--)"function"==typeof ie[ye]&&(ie[ye]=b(ie[ye],fe+"_"+ye));return ie}function T(ie){return!ie||!1!==ie.writable&&!("function"==typeof ie.get&&typeof ie.set>"u")}const M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,k=!("nw"in I)&&typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process),F=!k&&!M&&!(!v||!p.HTMLElement),G=typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process)&&!M&&!(!v||!p.HTMLElement),C={},O=function(ie){if(!(ie=ie||I.event))return;let fe=C[ie.type];fe||(fe=C[ie.type]=E("ON_PROPERTY"+ie.type));const ye=this||ie.target||I,me=ye[fe];let _e;if(F&&ye===p&&"error"===ie.type){const Ne=ie;_e=me&&me.call(this,Ne.message,Ne.filename,Ne.lineno,Ne.colno,Ne.error),!0===_e&&ie.preventDefault()}else _e=me&&me.apply(this,arguments),null!=_e&&!_e&&ie.preventDefault();return _e};function V(ie,fe,ye){let me=Y(ie,fe);if(!me&&ye&&Y(ye,fe)&&(me={enumerable:!0,configurable:!0}),!me||!me.configurable)return;const _e=E("on"+fe+"patched");if(ie.hasOwnProperty(_e)&&ie[_e])return;delete me.writable,delete me.value;const Ne=me.get,Qe=me.set,qe=fe.slice(2);let it=C[qe];it||(it=C[qe]=E("ON_PROPERTY"+qe)),me.set=function(nt){let Ke=this;!Ke&&ie===I&&(Ke=I),Ke&&("function"==typeof Ke[it]&&Ke.removeEventListener(qe,O),Qe&&Qe.call(Ke,null),Ke[it]=nt,"function"==typeof nt&&Ke.addEventListener(qe,O,!1))},me.get=function(){let nt=this;if(!nt&&ie===I&&(nt=I),!nt)return null;const Ke=nt[it];if(Ke)return Ke;if(Ne){let we=Ne.call(this);if(we)return me.set.call(this,we),"function"==typeof nt.removeAttribute&&nt.removeAttribute(fe),we}return null},U(ie,fe,me),ie[_e]=!0}function L(ie,fe,ye){if(fe)for(let me=0;mefunction(Qe,qe){const it=ye(Qe,qe);return it.cbIdx>=0&&"function"==typeof qe[it.cbIdx]?S(it.name,qe[it.cbIdx],it,_e):Ne.apply(Qe,qe)})}function X(ie,fe){ie[E("OriginalDelegate")]=fe}let q=!1,ne=!1;function de(){if(q)return ne;q=!0;try{const ie=p.navigator.userAgent;(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/")||-1!==ie.indexOf("Edge/"))&&(ne=!0)}catch{}return ne}Zone.__load_patch("ZoneAwarePromise",(ie,fe,ye)=>{const me=Object.getOwnPropertyDescriptor,_e=Object.defineProperty,Qe=ye.symbol,qe=[],it=!0===ie[Qe("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")],nt=Qe("Promise"),Ke=Qe("then");ye.onUnhandledError=je=>{if(ye.showUncaughtError()){const Ye=je&&je.rejection;Ye?console.error("Unhandled Promise rejection:",Ye instanceof Error?Ye.message:Ye,"; Zone:",je.zone.name,"; Task:",je.task&&je.task.source,"; Value:",Ye,Ye instanceof Error?Ye.stack:void 0):console.error(je)}},ye.microtaskDrainDone=()=>{for(;qe.length;){const je=qe.shift();try{je.zone.runGuarded(()=>{throw je.throwOriginal?je.rejection:je})}catch(Ye){De(Ye)}}};const ge=Qe("unhandledPromiseRejectionHandler");function De(je){ye.onUnhandledError(je);try{const Ye=fe[ge];"function"==typeof Ye&&Ye.call(this,je)}catch{}}function Fe(je){return je&&je.then}function Be(je){return je}function dt(je){return ce.reject(je)}const xt=Qe("state"),mt=Qe("value"),et=Qe("finally"),Tn=Qe("parentPromiseValue"),Bt=Qe("parentPromiseState"),en=null,ln=!1;function Kt(je,Ye){return Ae=>{try{On(je,Ye,Ae)}catch(Ge){On(je,!1,Ge)}}}const wt=function(){let je=!1;return function(Ae){return function(){je||(je=!0,Ae.apply(null,arguments))}}},Pr=Qe("currentTaskTrace");function On(je,Ye,Ae){const Ge=wt();if(je===Ae)throw new TypeError("Promise resolved with itself");if(je[xt]===en){let ht=null;try{("object"==typeof Ae||"function"==typeof Ae)&&(ht=Ae&&Ae.then)}catch(Et){return Ge(()=>{On(je,!1,Et)})(),je}if(Ye!==ln&&Ae instanceof ce&&Ae.hasOwnProperty(xt)&&Ae.hasOwnProperty(mt)&&Ae[xt]!==en)ur(Ae),On(je,Ae[xt],Ae[mt]);else if(Ye!==ln&&"function"==typeof ht)try{ht.call(Ae,Ge(Kt(je,Ye)),Ge(Kt(je,!1)))}catch(Et){Ge(()=>{On(je,!1,Et)})()}else{je[xt]=Ye;const Et=je[mt];if(je[mt]=Ae,je[et]===et&&!0===Ye&&(je[xt]=je[Bt],je[mt]=je[Tn]),Ye===ln&&Ae instanceof Error){const ut=fe.currentTask&&fe.currentTask.data&&fe.currentTask.data.__creationTrace__;ut&&_e(Ae,Pr,{configurable:!0,enumerable:!1,writable:!0,value:ut})}for(let ut=0;ut{try{const St=je[mt],$t=!!Ae&&et===Ae[et];$t&&(Ae[Tn]=St,Ae[Bt]=Et);const Ut=Ye.run(ut,void 0,$t&&ut!==dt&&ut!==Be?[]:[St]);On(Ae,!0,Ut)}catch(St){On(Ae,!1,St)}},Ae)}const Ft=function(){},ct=ie.AggregateError;class ce{static toString(){return"function ZoneAwarePromise() { [native code] }"}static resolve(Ye){return On(new this(null),!0,Ye)}static reject(Ye){return On(new this(null),ln,Ye)}static any(Ye){if(!Ye||"function"!=typeof Ye[Symbol.iterator])return Promise.reject(new ct([],"All promises were rejected"));const Ae=[];let Ge=0;try{for(let ut of Ye)Ge++,Ae.push(ce.resolve(ut))}catch{return Promise.reject(new ct([],"All promises were rejected"))}if(0===Ge)return Promise.reject(new ct([],"All promises were rejected"));let ht=!1;const Et=[];return new ce((ut,St)=>{for(let $t=0;$t{ht||(ht=!0,ut(Ut))},Ut=>{Et.push(Ut),Ge--,0===Ge&&(ht=!0,St(new ct(Et,"All promises were rejected")))})})}static race(Ye){let Ae,Ge,ht=new this((St,$t)=>{Ae=St,Ge=$t});function Et(St){Ae(St)}function ut(St){Ge(St)}for(let St of Ye)Fe(St)||(St=this.resolve(St)),St.then(Et,ut);return ht}static all(Ye){return ce.allWithCallback(Ye)}static allSettled(Ye){return(this&&this.prototype instanceof ce?this:ce).allWithCallback(Ye,{thenCallback:Ge=>({status:"fulfilled",value:Ge}),errorCallback:Ge=>({status:"rejected",reason:Ge})})}static allWithCallback(Ye,Ae){let Ge,ht,Et=new this((Ut,An)=>{Ge=Ut,ht=An}),ut=2,St=0;const $t=[];for(let Ut of Ye){Fe(Ut)||(Ut=this.resolve(Ut));const An=St;try{Ut.then(Dn=>{$t[An]=Ae?Ae.thenCallback(Dn):Dn,ut--,0===ut&&Ge($t)},Dn=>{Ae?($t[An]=Ae.errorCallback(Dn),ut--,0===ut&&Ge($t)):ht(Dn)})}catch(Dn){ht(Dn)}ut++,St++}return ut-=2,0===ut&&Ge($t),Et}constructor(Ye){const Ae=this;if(!(Ae instanceof ce))throw new Error("Must be an instanceof Promise.");Ae[xt]=en,Ae[mt]=[];try{const Ge=wt();Ye&&Ye(Ge(Kt(Ae,!0)),Ge(Kt(Ae,ln)))}catch(Ge){On(Ae,!1,Ge)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return ce}then(Ye,Ae){var Ge;let ht=null===(Ge=this.constructor)||void 0===Ge?void 0:Ge[Symbol.species];(!ht||"function"!=typeof ht)&&(ht=this.constructor||ce);const Et=new ht(Ft),ut=fe.current;return this[xt]==en?this[mt].push(ut,Et,Ye,Ae):Qn(this,ut,Et,Ye,Ae),Et}catch(Ye){return this.then(null,Ye)}finally(Ye){var Ae;let Ge=null===(Ae=this.constructor)||void 0===Ae?void 0:Ae[Symbol.species];(!Ge||"function"!=typeof Ge)&&(Ge=ce);const ht=new Ge(Ft);ht[et]=et;const Et=fe.current;return this[xt]==en?this[mt].push(Et,ht,Ye,Ye):Qn(this,Et,ht,Ye,Ye),ht}}ce.resolve=ce.resolve,ce.reject=ce.reject,ce.race=ce.race,ce.all=ce.all;const ve=ie[nt]=ie.Promise;ie.Promise=ce;const yt=Qe("thenPatched");function Dt(je){const Ye=je.prototype,Ae=me(Ye,"then");if(Ae&&(!1===Ae.writable||!Ae.configurable))return;const Ge=Ye.then;Ye[Ke]=Ge,je.prototype.then=function(ht,Et){return new ce((St,$t)=>{Ge.call(this,St,$t)}).then(ht,Et)},je[yt]=!0}return ye.patchThen=Dt,ve&&(Dt(ve),z(ie,"fetch",je=>function gn(je){return function(Ye,Ae){let Ge=je.apply(Ye,Ae);if(Ge instanceof ce)return Ge;let ht=Ge.constructor;return ht[yt]||Dt(ht),Ge}}(je))),Promise[fe.__symbol__("uncaughtPromiseErrors")]=qe,ce}),Zone.__load_patch("toString",ie=>{const fe=Function.prototype.toString,ye=E("OriginalDelegate"),me=E("Promise"),_e=E("Error"),Ne=function(){if("function"==typeof this){const nt=this[ye];if(nt)return"function"==typeof nt?fe.call(nt):Object.prototype.toString.call(nt);if(this===Promise){const Ke=ie[me];if(Ke)return fe.call(Ke)}if(this===Error){const Ke=ie[_e];if(Ke)return fe.call(Ke)}}return fe.call(this)};Ne[ye]=fe,Function.prototype.toString=Ne;const Qe=Object.prototype.toString;Object.prototype.toString=function(){return"function"==typeof Promise&&this instanceof Promise?"[object Promise]":Qe.call(this)}});let pe=!1;if(typeof window<"u")try{const ie=Object.defineProperty({},"passive",{get:function(){pe=!0}});window.addEventListener("test",ie,ie),window.removeEventListener("test",ie,ie)}catch{pe=!1}const Le={useG:!0},Se={},Pe={},be=new RegExp("^"+d+"(\\w+)(true|false)$"),$e=E("propagationStopped");function H(ie,fe){const ye=(fe?fe(ie):ie)+f,me=(fe?fe(ie):ie)+c,_e=d+ye,Ne=d+me;Se[ie]={},Se[ie][f]=_e,Se[ie][c]=Ne}function Ee(ie,fe,ye,me){const _e=me&&me.add||g,Ne=me&&me.rm||w,Qe=me&&me.listeners||"eventListeners",qe=me&&me.rmAll||"removeAllListeners",it=E(_e),nt="."+_e+":",ge=function(mt,et,Tn){if(mt.isRemoved)return;const Bt=mt.callback;let pn;"object"==typeof Bt&&Bt.handleEvent&&(mt.callback=ft=>Bt.handleEvent(ft),mt.originalDelegate=Bt);try{mt.invoke(mt,et,[Tn])}catch(ft){pn=ft}const en=mt.options;return en&&"object"==typeof en&&en.once&&et[Ne].call(et,Tn.type,mt.originalDelegate?mt.originalDelegate:mt.callback,en),pn};function De(mt,et,Tn){if(!(et=et||ie.event))return;const Bt=mt||et.target||ie,pn=Bt[Se[et.type][Tn?c:f]];if(pn){const en=[];if(1===pn.length){const ft=ge(pn[0],Bt,et);ft&&en.push(ft)}else{const ft=pn.slice();for(let ln=0;ln{throw ln})}}}const Fe=function(mt){return De(this,mt,!1)},Be=function(mt){return De(this,mt,!0)};function dt(mt,et){if(!mt)return!1;let Tn=!0;et&&void 0!==et.useG&&(Tn=et.useG);const Bt=et&&et.vh;let pn=!0;et&&void 0!==et.chkDup&&(pn=et.chkDup);let en=!1;et&&void 0!==et.rt&&(en=et.rt);let ft=mt;for(;ft&&!ft.hasOwnProperty(_e);)ft=x(ft);if(!ft&&mt[_e]&&(ft=mt),!ft||ft[it])return!1;const ln=et&&et.eventNameToString,st={},Kt=ft[it]=ft[_e],wt=ft[E(Ne)]=ft[Ne],Jn=ft[E(Qe)]=ft[Qe],Pr=ft[E(qe)]=ft[qe];let On;function vn(Ae,Ge){return!pe&&"object"==typeof Ae&&Ae?!!Ae.capture:pe&&Ge?"boolean"==typeof Ae?{capture:Ae,passive:!0}:Ae?"object"==typeof Ae&&!1!==Ae.passive?Object.assign(Object.assign({},Ae),{passive:!0}):Ae:{passive:!0}:Ae}et&&et.prepend&&(On=ft[E(et.prepend)]=ft[et.prepend]);const ce=Tn?function(Ae){if(!st.isExisting)return Kt.call(st.target,st.eventName,st.capture?Be:Fe,st.options)}:function(Ae){return Kt.call(st.target,st.eventName,Ae.invoke,st.options)},ve=Tn?function(Ae){if(!Ae.isRemoved){const Ge=Se[Ae.eventName];let ht;Ge&&(ht=Ge[Ae.capture?c:f]);const Et=ht&&Ae.target[ht];if(Et)for(let ut=0;utfunction(_e,Ne){_e[$e]=!0,me&&me.apply(_e,Ne)})}function He(ie,fe,ye,me,_e){const Ne=Zone.__symbol__(me);if(fe[Ne])return;const Qe=fe[Ne]=fe[me];fe[me]=function(qe,it,nt){return it&&it.prototype&&_e.forEach(function(Ke){const we=`${ye}.${me}::`+Ke,ge=it.prototype;try{if(ge.hasOwnProperty(Ke)){const De=ie.ObjectGetOwnPropertyDescriptor(ge,Ke);De&&De.value?(De.value=ie.wrapWithCurrentZone(De.value,we),ie._redefineProperty(it.prototype,Ke,De)):ge[Ke]&&(ge[Ke]=ie.wrapWithCurrentZone(ge[Ke],we))}else ge[Ke]&&(ge[Ke]=ie.wrapWithCurrentZone(ge[Ke],we))}catch{}}),Qe.call(fe,qe,it,nt)},ie.attachOriginToPatched(fe[me],Qe)}function We(ie,fe,ye){if(!ye||0===ye.length)return fe;const me=ye.filter(Ne=>Ne.target===ie);if(!me||0===me.length)return fe;const _e=me[0].ignoreProperties;return fe.filter(Ne=>-1===_e.indexOf(Ne))}function Je(ie,fe,ye,me){ie&&L(ie,We(ie,fe,ye),me)}function Xe(ie){return Object.getOwnPropertyNames(ie).filter(fe=>fe.startsWith("on")&&fe.length>2).map(fe=>fe.substring(2))}Zone.__load_patch("util",(ie,fe,ye)=>{const me=Xe(ie);ye.patchOnProperties=L,ye.patchMethod=z,ye.bindArguments=P,ye.patchMacroTask=te;const _e=fe.__symbol__("BLACK_LISTED_EVENTS"),Ne=fe.__symbol__("UNPATCHED_EVENTS");ie[Ne]&&(ie[_e]=ie[Ne]),ie[_e]&&(fe[_e]=fe[Ne]=ie[_e]),ye.patchEventPrototype=xe,ye.patchEventTarget=Ee,ye.isIEOrEdge=de,ye.ObjectDefineProperty=U,ye.ObjectGetOwnPropertyDescriptor=Y,ye.ObjectCreate=y,ye.ArraySlice=l,ye.patchClass=re,ye.wrapWithCurrentZone=b,ye.filterProperties=We,ye.attachOriginToPatched=X,ye._redefineProperty=Object.defineProperty,ye.patchCallbacks=He,ye.getGlobalObjects=()=>({globalSources:Pe,zoneSymbolEventNames:Se,eventNames:me,isBrowser:F,isMix:G,isNode:k,TRUE_STR:c,FALSE_STR:f,ZONE_SYMBOL_PREFIX:d,ADD_EVENT_LISTENER_STR:g,REMOVE_EVENT_LISTENER_STR:w})});const pt=E("zoneTask");function _t(ie,fe,ye,me){let _e=null,Ne=null;ye+=me;const Qe={};function qe(nt){const Ke=nt.data;return Ke.args[0]=function(){return nt.invoke.apply(this,arguments)},Ke.handleId=_e.apply(ie,Ke.args),nt}function it(nt){return Ne.call(ie,nt.data.handleId)}_e=z(ie,fe+=me,nt=>function(Ke,we){if("function"==typeof we[0]){const ge={isPeriodic:"Interval"===me,delay:"Timeout"===me||"Interval"===me?we[1]||0:void 0,args:we},De=we[0];we[0]=function(){try{return De.apply(this,arguments)}finally{ge.isPeriodic||("number"==typeof ge.handleId?delete Qe[ge.handleId]:ge.handleId&&(ge.handleId[pt]=null))}};const Fe=S(fe,we[0],ge,qe,it);if(!Fe)return Fe;const Be=Fe.data.handleId;return"number"==typeof Be?Qe[Be]=Fe:Be&&(Be[pt]=Fe),Be&&Be.ref&&Be.unref&&"function"==typeof Be.ref&&"function"==typeof Be.unref&&(Fe.ref=Be.ref.bind(Be),Fe.unref=Be.unref.bind(Be)),"number"==typeof Be||Be?Be:Fe}return nt.apply(ie,we)}),Ne=z(ie,ye,nt=>function(Ke,we){const ge=we[0];let De;"number"==typeof ge?De=Qe[ge]:(De=ge&&ge[pt],De||(De=ge)),De&&"string"==typeof De.type?"notScheduled"!==De.state&&(De.cancelFn&&De.data.isPeriodic||0===De.runCount)&&("number"==typeof ge?delete Qe[ge]:ge&&(ge[pt]=null),De.zone.cancelTask(De)):nt.apply(ie,we)})}Zone.__load_patch("legacy",ie=>{const fe=ie[Zone.__symbol__("legacyPatch")];fe&&fe()}),Zone.__load_patch("queueMicrotask",(ie,fe,ye)=>{ye.patchMethod(ie,"queueMicrotask",me=>function(_e,Ne){fe.current.scheduleMicroTask("queueMicrotask",Ne[0])})}),Zone.__load_patch("timers",ie=>{const ye="clear";_t(ie,"set",ye,"Timeout"),_t(ie,"set",ye,"Interval"),_t(ie,"set",ye,"Immediate")}),Zone.__load_patch("requestAnimationFrame",ie=>{_t(ie,"request","cancel","AnimationFrame"),_t(ie,"mozRequest","mozCancel","AnimationFrame"),_t(ie,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(ie,fe)=>{const ye=["alert","prompt","confirm"];for(let me=0;mefunction(it,nt){return fe.current.run(Ne,ie,nt,qe)})}),Zone.__load_patch("EventTarget",(ie,fe,ye)=>{(function Hr(ie,fe){fe.patchEventPrototype(ie,fe)})(ie,ye),function gr(ie,fe){if(Zone[fe.symbol("patchEventTarget")])return;const{eventNames:ye,zoneSymbolEventNames:me,TRUE_STR:_e,FALSE_STR:Ne,ZONE_SYMBOL_PREFIX:Qe}=fe.getGlobalObjects();for(let it=0;it{re("MutationObserver"),re("WebKitMutationObserver")}),Zone.__load_patch("IntersectionObserver",(ie,fe,ye)=>{re("IntersectionObserver")}),Zone.__load_patch("FileReader",(ie,fe,ye)=>{re("FileReader")}),Zone.__load_patch("on_property",(ie,fe,ye)=>{!function Nt(ie,fe){if(k&&!G||Zone[ie.symbol("patchEvents")])return;const ye=fe.__Zone_ignore_on_properties;let me=[];if(F){const _e=window;me=me.concat(["Document","SVGElement","Element","HTMLElement","HTMLBodyElement","HTMLMediaElement","HTMLFrameSetElement","HTMLFrameElement","HTMLIFrameElement","HTMLMarqueeElement","Worker"]);const Ne=function se(){try{const ie=p.navigator.userAgent;if(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/"))return!0}catch{}return!1}()?[{target:_e,ignoreProperties:["error"]}]:[];Je(_e,Xe(_e),ye&&ye.concat(Ne),x(_e))}me=me.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let _e=0;_e{!function Or(ie,fe){const{isBrowser:ye,isMix:me}=fe.getGlobalObjects();(ye||me)&&ie.customElements&&"customElements"in ie&&fe.patchCallbacks(fe,ie.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(ie,ye)}),Zone.__load_patch("XHR",(ie,fe)=>{!function it(nt){const Ke=nt.XMLHttpRequest;if(!Ke)return;const we=Ke.prototype;let De=we[m],Fe=we[h];if(!De){const st=nt.XMLHttpRequestEventTarget;if(st){const Kt=st.prototype;De=Kt[m],Fe=Kt[h]}}const Be="readystatechange",dt="scheduled";function xt(st){const Kt=st.data,wt=Kt.target;wt[Ne]=!1,wt[qe]=!1;const Jn=wt[_e];De||(De=wt[m],Fe=wt[h]),Jn&&Fe.call(wt,Be,Jn);const Pr=wt[_e]=()=>{if(wt.readyState===wt.DONE)if(!Kt.aborted&&wt[Ne]&&st.state===dt){const vn=wt[fe.__symbol__("loadfalse")];if(0!==wt.status&&vn&&vn.length>0){const ur=st.invoke;st.invoke=function(){const Qn=wt[fe.__symbol__("loadfalse")];for(let En=0;Enfunction(st,Kt){return st[me]=0==Kt[2],st[Qe]=Kt[1],Tn.apply(st,Kt)}),pn=E("fetchTaskAborting"),en=E("fetchTaskScheduling"),ft=z(we,"send",()=>function(st,Kt){if(!0===fe.current[en]||st[me])return ft.apply(st,Kt);{const wt={target:st,url:st[Qe],isPeriodic:!1,args:Kt,aborted:!1},Jn=S("XMLHttpRequest.send",mt,wt,xt,et);st&&!0===st[qe]&&!wt.aborted&&Jn.state===dt&&Jn.invoke()}}),ln=z(we,"abort",()=>function(st,Kt){const wt=function ge(st){return st[ye]}(st);if(wt&&"string"==typeof wt.type){if(null==wt.cancelFn||wt.data&&wt.data.aborted)return;wt.zone.cancelTask(wt)}else if(!0===fe.current[pn])return ln.apply(st,Kt)})}(ie);const ye=E("xhrTask"),me=E("xhrSync"),_e=E("xhrListener"),Ne=E("xhrScheduled"),Qe=E("xhrURL"),qe=E("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",ie=>{ie.navigator&&ie.navigator.geolocation&&function D(ie,fe){const ye=ie.constructor.name;for(let me=0;me{const it=function(){return qe.apply(this,P(arguments,ye+"."+_e))};return X(it,qe),it})(Ne)}}}(ie.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(ie,fe)=>{function ye(me){return function(_e){Te(ie,me).forEach(Qe=>{const qe=ie.PromiseRejectionEvent;if(qe){const it=new qe(me,{promise:_e.promise,reason:_e.rejection});Qe.invoke(it)}})}}ie.PromiseRejectionEvent&&(fe[E("unhandledPromiseRejectionHandler")]=ye("unhandledrejection"),fe[E("rejectionHandledHandler")]=ye("rejectionhandled"))})},7420:()=>{},5856:()=>{},5883:()=>{},6577:()=>{},5819:()=>{},1265:()=>{},5539:()=>{},8479:function(Y,U,x){"use strict";var l,g;l=[x(1873)],void 0!==(g=function(w){var m=w.Reader,h=w.Writer,c=w.util,f=w.roots.default||(w.roots.default={});return f.RPC=function(){function d(S){if(this.subscriptions=[],this.messages=[],S)for(var E=Object.keys(S),v=0;v>>3){case 1:I.subscriptions&&I.subscriptions.length||(I.subscriptions=[]),I.subscriptions.push(f.RPC.SubOpts.decode(E,E.uint32()));break;case 2:I.messages&&I.messages.length||(I.messages=[]),I.messages.push(f.RPC.Message.decode(E,E.uint32()));break;case 3:I.control=f.RPC.ControlMessage.decode(E,E.uint32());break;default:E.skipType(7&A)}}return I},d.fromObject=function(E){if(E instanceof f.RPC)return E;var v=new f.RPC;if(E.subscriptions){if(!Array.isArray(E.subscriptions))throw TypeError(".RPC.subscriptions: array expected");v.subscriptions=[];for(var p=0;p>>3){case 1:P.subscribe=p.bool();break;case 2:P.topic=p.string();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.SubOpts)return p;var I=new f.RPC.SubOpts;return null!=p.subscribe&&(I.subscribe=Boolean(p.subscribe)),null!=p.topic&&(I.topic=String(p.topic)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.subscribe&&p.hasOwnProperty("subscribe")&&(A.subscribe=p.subscribe,I.oneofs&&(A._subscribe="subscribe")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic,I.oneofs&&(A._topic="topic")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.Message=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.from=p.bytes();break;case 2:P.data=p.bytes();break;case 3:P.seqno=p.bytes();break;case 4:P.topic=p.string();break;case 5:P.signature=p.bytes();break;case 6:P.key=p.bytes();break;default:p.skipType(7&D)}}if(!P.hasOwnProperty("topic"))throw c.ProtocolError("missing required 'topic'",{instance:P});return P},S.fromObject=function(p){if(p instanceof f.RPC.Message)return p;var I=new f.RPC.Message;return null!=p.from&&("string"==typeof p.from?c.base64.decode(p.from,I.from=c.newBuffer(c.base64.length(p.from)),0):p.from.length&&(I.from=p.from)),null!=p.data&&("string"==typeof p.data?c.base64.decode(p.data,I.data=c.newBuffer(c.base64.length(p.data)),0):p.data.length&&(I.data=p.data)),null!=p.seqno&&("string"==typeof p.seqno?c.base64.decode(p.seqno,I.seqno=c.newBuffer(c.base64.length(p.seqno)),0):p.seqno.length&&(I.seqno=p.seqno)),null!=p.topic&&(I.topic=String(p.topic)),null!=p.signature&&("string"==typeof p.signature?c.base64.decode(p.signature,I.signature=c.newBuffer(c.base64.length(p.signature)),0):p.signature.length&&(I.signature=p.signature)),null!=p.key&&("string"==typeof p.key?c.base64.decode(p.key,I.key=c.newBuffer(c.base64.length(p.key)),0):p.key.length&&(I.key=p.key)),I},S.toObject=function(p,I){I||(I={});var A={};return I.defaults&&(A.topic=""),null!=p.from&&p.hasOwnProperty("from")&&(A.from=I.bytes===String?c.base64.encode(p.from,0,p.from.length):I.bytes===Array?Array.prototype.slice.call(p.from):p.from,I.oneofs&&(A._from="from")),null!=p.data&&p.hasOwnProperty("data")&&(A.data=I.bytes===String?c.base64.encode(p.data,0,p.data.length):I.bytes===Array?Array.prototype.slice.call(p.data):p.data,I.oneofs&&(A._data="data")),null!=p.seqno&&p.hasOwnProperty("seqno")&&(A.seqno=I.bytes===String?c.base64.encode(p.seqno,0,p.seqno.length):I.bytes===Array?Array.prototype.slice.call(p.seqno):p.seqno,I.oneofs&&(A._seqno="seqno")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic),null!=p.signature&&p.hasOwnProperty("signature")&&(A.signature=I.bytes===String?c.base64.encode(p.signature,0,p.signature.length):I.bytes===Array?Array.prototype.slice.call(p.signature):p.signature,I.oneofs&&(A._signature="signature")),null!=p.key&&p.hasOwnProperty("key")&&(A.key=I.bytes===String?c.base64.encode(p.key,0,p.key.length):I.bytes===Array?Array.prototype.slice.call(p.key):p.key,I.oneofs&&(A._key="key")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlMessage=function(){function S(E){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],E)for(var v=Object.keys(E),p=0;p>>3){case 1:A.ihave&&A.ihave.length||(A.ihave=[]),A.ihave.push(f.RPC.ControlIHave.decode(v,v.uint32()));break;case 2:A.iwant&&A.iwant.length||(A.iwant=[]),A.iwant.push(f.RPC.ControlIWant.decode(v,v.uint32()));break;case 3:A.graft&&A.graft.length||(A.graft=[]),A.graft.push(f.RPC.ControlGraft.decode(v,v.uint32()));break;case 4:A.prune&&A.prune.length||(A.prune=[]),A.prune.push(f.RPC.ControlPrune.decode(v,v.uint32()));break;default:v.skipType(7&P)}}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlMessage)return v;var p=new f.RPC.ControlMessage;if(v.ihave){if(!Array.isArray(v.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");p.ihave=[];for(var I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.messageIDs&&P.messageIDs.length||(P.messageIDs=[]),P.messageIDs.push(p.bytes());break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlIHave)return p;var I=new f.RPC.ControlIHave;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.messageIDs){if(!Array.isArray(p.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");I.messageIDs=[];for(var A=0;A>>3==1?(A.messageIDs&&A.messageIDs.length||(A.messageIDs=[]),A.messageIDs.push(v.bytes())):v.skipType(7&P)}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlIWant)return v;var p=new f.RPC.ControlIWant;if(v.messageIDs){if(!Array.isArray(v.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");p.messageIDs=[];for(var I=0;I>>3==1?P.topicID=p.string():p.skipType(7&D)}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlGraft)return p;var I=new f.RPC.ControlGraft;return null!=p.topicID&&(I.topicID=String(p.topicID)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlPrune=function(){function S(v){if(this.peers=[],v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.peers&&P.peers.length||(P.peers=[]),P.peers.push(f.RPC.PeerInfo.decode(p,p.uint32()));break;case 3:P.backoff=p.uint64();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlPrune)return p;var I=new f.RPC.ControlPrune;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.peers){if(!Array.isArray(p.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");I.peers=[];for(var A=0;A>>0,p.backoff.high>>>0).toNumber(!0))),I},S.toObject=function(p,I){I||(I={});var A={};if((I.arrays||I.defaults)&&(A.peers=[]),null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),p.peers&&p.peers.length){A.peers=[];for(var P=0;P>>0,p.backoff.high>>>0).toNumber(!0):p.backoff,I.oneofs&&(A._backoff="backoff")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.PeerInfo=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.peerID=p.bytes();break;case 2:P.signedPeerRecord=p.bytes();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.PeerInfo)return p;var I=new f.RPC.PeerInfo;return null!=p.peerID&&("string"==typeof p.peerID?c.base64.decode(p.peerID,I.peerID=c.newBuffer(c.base64.length(p.peerID)),0):p.peerID.length&&(I.peerID=p.peerID)),null!=p.signedPeerRecord&&("string"==typeof p.signedPeerRecord?c.base64.decode(p.signedPeerRecord,I.signedPeerRecord=c.newBuffer(c.base64.length(p.signedPeerRecord)),0):p.signedPeerRecord.length&&(I.signedPeerRecord=p.signedPeerRecord)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.peerID&&p.hasOwnProperty("peerID")&&(A.peerID=I.bytes===String?c.base64.encode(p.peerID,0,p.peerID.length):I.bytes===Array?Array.prototype.slice.call(p.peerID):p.peerID,I.oneofs&&(A._peerID="peerID")),null!=p.signedPeerRecord&&p.hasOwnProperty("signedPeerRecord")&&(A.signedPeerRecord=I.bytes===String?c.base64.encode(p.signedPeerRecord,0,p.signedPeerRecord.length):I.bytes===Array?Array.prototype.slice.call(p.signedPeerRecord):p.signedPeerRecord,I.oneofs&&(A._signedPeerRecord="signedPeerRecord")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d}(),f}.apply(U,l))&&(Y.exports=g)},4642:(Y,U,x)=>{var y=x(9805);function l(g){var w,m;function c(d,b){try{var S=g[d](b),E=S.value,v=E instanceof y;Promise.resolve(v?E.wrapped:E).then(function(p){v?c("return"===d?"return":"next",p):f(S.done?"return":"normal",p)},function(p){c("throw",p)})}catch(p){f("throw",p)}}function f(d,b){switch(d){case"return":w.resolve({value:b,done:!0});break;case"throw":w.reject(b);break;default:w.resolve({value:b,done:!1})}(w=w.next)?c(w.key,w.arg):m=null}this._invoke=function h(d,b){return new Promise(function(S,E){var v={key:d,arg:b,resolve:S,reject:E,next:null};m?m=m.next=v:(w=m=v,c(d,b))})},"function"!=typeof g.return&&(this.return=void 0)}l.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},l.prototype.next=function(g){return this._invoke("next",g)},l.prototype.throw=function(g){return this._invoke("throw",g)},l.prototype.return=function(g){return this._invoke("return",g)},Y.exports=l,Y.exports.__esModule=!0,Y.exports.default=Y.exports},9805:Y=>{Y.exports=function U(x){this.wrapped=x},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8131:Y=>{Y.exports=function U(x,y){var l={},g=!1;function w(m,h){return g=!0,h=new Promise(function(c){c(x[m](h))}),{done:!1,value:y(h)}}return l[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},l.next=function(m){return g?(g=!1,m):w("next",m)},"function"==typeof x.throw&&(l.throw=function(m){if(g)throw g=!1,m;return w("throw",m)}),"function"==typeof x.return&&(l.return=function(m){return g?(g=!1,m):w("return",m)}),l},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8237:Y=>{function x(y){function l(g){if(Object(g)!==g)return Promise.reject(new TypeError(g+" is not an object."));var w=g.done;return Promise.resolve(g.value).then(function(m){return{value:m,done:w}})}return(x=function(w){this.s=w,this.n=w.next}).prototype={s:null,n:null,next:function(){return l(this.n.apply(this.s,arguments))},return:function(w){var m=this.s.return;return void 0===m?Promise.resolve({value:w,done:!0}):l(m.apply(this.s,arguments))},throw:function(w){var m=this.s.return;return void 0===m?Promise.reject(w):l(m.apply(this.s,arguments))}},new x(y)}Y.exports=function U(y){var l,g,w,m=2;for(typeof Symbol<"u"&&(g=Symbol.asyncIterator,w=Symbol.iterator);m--;){if(g&&null!=(l=y[g]))return l.call(y);if(w&&null!=(l=y[w]))return new x(l.call(y));g="@@asyncIterator",w="@@iterator"}throw new TypeError("Object is not async iterable")},Y.exports.__esModule=!0,Y.exports.default=Y.exports},7156:Y=>{function U(y,l,g,w,m,h,c){try{var f=y[h](c),d=f.value}catch(b){return void g(b)}f.done?l(d):Promise.resolve(d).then(w,m)}Y.exports=function x(y){return function(){var l=this,g=arguments;return new Promise(function(w,m){var h=y.apply(l,g);function c(d){U(h,w,m,c,f,"next",d)}function f(d){U(h,w,m,c,f,"throw",d)}c(void 0)})}},Y.exports.__esModule=!0,Y.exports.default=Y.exports},6737:(Y,U,x)=>{var y=x(9805);Y.exports=function l(g){return new y(g)},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8186:(Y,U,x)=>{var y=x(4642);Y.exports=function l(g){return function(){return new y(g.apply(this,arguments))}},Y.exports.__esModule=!0,Y.exports.default=Y.exports}},Y=>{Y(Y.s=3683)}]); \ No newline at end of file +var C$=Object.defineProperty,I$=(Y,U,x)=>U in Y?C$(Y,U,{enumerable:!0,configurable:!0,writable:!0,value:x}):Y[U]=x,cb=(Y,U,x)=>(I$(Y,"symbol"!=typeof U?U+"":U,x),x),tx=(Y,U,x)=>{if(!U.has(Y))throw TypeError("Cannot "+x)},aa=(Y,U,x)=>(tx(Y,U,"read from private field"),x?x.call(Y):U.get(Y)),hp=(Y,U,x)=>{if(U.has(Y))throw TypeError("Cannot add the same private member more than once");U instanceof WeakSet?U.add(Y):U.set(Y,x)},So=(Y,U,x,y)=>(tx(Y,U,"write to private field"),y?y.call(Y,x):U.set(Y,x),x),ub=(Y,U,x,y)=>({set _(l){So(Y,U,l,x)},get _(){return aa(Y,U,y)}});(self.webpackChunkrelay_angular_chat=self.webpackChunkrelay_angular_chat||[]).push([[179],{1873:(Y,U,x)=>{"use strict";Y.exports=x(4729)},4729:(Y,U,x)=>{"use strict";var y=U;function l(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(3542),y.BufferWriter=x(989),y.Reader=x(6913),y.BufferReader=x(1872),y.util=x(6138),y.rpc=x(9852),y.roots=x(935),y.configure=l,l()},6913:(Y,U,x)=>{"use strict";Y.exports=h;var l,y=x(6138),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new l(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){l=E,h.create=f(),l._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},1872:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(6913);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(6138);function g(w){y.call(this,w)}g._configure=function(){l.Buffer&&(g.prototype._slice=l.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},935:Y=>{"use strict";Y.exports={}},9852:(Y,U,x)=>{"use strict";U.Service=x(3939)},3939:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(6138);function l(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(l.prototype=Object.create(y.EventEmitter.prototype)).constructor=l,l.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},l.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},6723:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(6138);function l(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=l.zero=new l(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=l.zeroHash="\0\0\0\0\0\0\0\0";l.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new l(d,b)},l.from=function(c){if("number"==typeof c)return l.fromNumber(c);if(y.isString(c)){if(!y.Long)return l.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new l(c.low>>>0,c.high>>>0):g},l.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},l.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;l.fromHash=function(c){return c===w?g:new l((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},l.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},l.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},l.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},l.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},6138:function(Y,U,x){"use strict";var y=U;function l(w,m,h){for(var c=Object.keys(m),f=0;f0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=l,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Y.exports=d;var l,y=x(6138),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new l})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(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 h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){l=P,d.create=b(),l._configure()}},989:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(3542);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(6138);function g(){y.call(this)}function w(m,h,c){m.length<40?l.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=l._Buffer_allocUnsafe,g.writeBytesBuffer=l.Buffer&&l.Buffer.prototype instanceof Uint8Array&&"set"===l.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=l.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},3683:(Y,U,x)=>{var js,Va,Ha,y={};x.r(y),x.d(y,{identity:()=>JB});var l={};x.r(l),x.d(l,{base2:()=>e6});var g={};x.r(g),x.d(g,{base8:()=>t6});var w={};x.r(w),x.d(w,{base10:()=>n6});var m={};x.r(m),x.d(m,{base16:()=>r6,base16upper:()=>i6});var h={};x.r(h),x.d(h,{base32:()=>co,base32hex:()=>c6,base32hexpad:()=>l6,base32hexpadupper:()=>f6,base32hexupper:()=>u6,base32pad:()=>o6,base32padupper:()=>a6,base32upper:()=>s6,base32z:()=>d6});var c={};x.r(c),x.d(c,{base36:()=>h6,base36upper:()=>p6});var f={};x.r(f),x.d(f,{base58btc:()=>ui,base58flickr:()=>g6});var d={};x.r(d),x.d(d,{base64:()=>jd,base64pad:()=>y6,base64url:()=>m6,base64urlpad:()=>v6});var b={};x.r(b),x.d(b,{base256emoji:()=>D6});var S={};x.r(S),x.d(S,{sha256:()=>mi,sha512:()=>j6});var E={};x.r(E),x.d(E,{identity:()=>Uc});var v={};x.r(v),x.d(v,{code:()=>W6,decode:()=>Y6,encode:()=>q6,name:()=>z6});var p={};x.r(p),x.d(p,{code:()=>J6,decode:()=>tF,encode:()=>eF,name:()=>X6});var I={};x.r(I),x.d(I,{RsaPrivateKey:()=>rh,RsaPublicKey:()=>Z0,fromJwk:()=>WF,generateKeyPair:()=>qF,unmarshalRsaPrivateKey:()=>GF,unmarshalRsaPublicKey:()=>zF});var A={};x.r(A),x.d(A,{Ed25519PrivateKey:()=>xl,Ed25519PublicKey:()=>vm,generateKeyPair:()=>b5,generateKeyPairFromSeed:()=>w5,unmarshalEd25519PrivateKey:()=>v5,unmarshalEd25519PublicKey:()=>E5});var P={};function D(n){return"function"==typeof n}function T(n){const t=n(r=>{Error.call(r),r.stack=(new Error).stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}x.r(P),x.d(P,{Secp256k1PrivateKey:()=>Sm,Secp256k1PublicKey:()=>Dm,generateKeyPair:()=>R5,unmarshalSecp256k1PrivateKey:()=>A5,unmarshalSecp256k1PublicKey:()=>x5});const M=T(n=>function(t){n(this),this.message=t?`${t.length} errors occurred during unsubscription:\n${t.map((r,i)=>`${i+1}) ${r.toString()}`).join("\n ")}`:"",this.name="UnsubscriptionError",this.errors=t});function k(n,e){if(n){const t=n.indexOf(e);0<=t&&n.splice(t,1)}}class F{constructor(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}unsubscribe(){let e;if(!this.closed){this.closed=!0;const{_parentage:t}=this;if(t)if(this._parentage=null,Array.isArray(t))for(const s of t)s.remove(this);else t.remove(this);const{initialTeardown:r}=this;if(D(r))try{r()}catch(s){e=s instanceof M?s.errors:[s]}const{_finalizers:i}=this;if(i){this._finalizers=null;for(const s of i)try{O(s)}catch(o){e=e??[],o instanceof M?e=[...e,...o.errors]:e.push(o)}}if(e)throw new M(e)}}add(e){var t;if(e&&e!==this)if(this.closed)O(e);else{if(e instanceof F){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=null!==(t=this._finalizers)&&void 0!==t?t:[]).push(e)}}_hasParent(e){const{_parentage:t}=this;return t===e||Array.isArray(t)&&t.includes(e)}_addParent(e){const{_parentage:t}=this;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e}_removeParent(e){const{_parentage:t}=this;t===e?this._parentage=null:Array.isArray(t)&&k(t,e)}remove(e){const{_finalizers:t}=this;t&&k(t,e),e instanceof F&&e._removeParent(this)}}F.EMPTY=(()=>{const n=new F;return n.closed=!0,n})();const G=F.EMPTY;function C(n){return n instanceof F||n&&"closed"in n&&D(n.remove)&&D(n.add)&&D(n.unsubscribe)}function O(n){D(n)?n():n.unsubscribe()}const V={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},L={setTimeout(n,e,...t){const{delegate:r}=L;return r?.setTimeout?r.setTimeout(n,e,...t):setTimeout(n,e,...t)},clearTimeout(n){const{delegate:e}=L;return(e?.clearTimeout||clearTimeout)(n)},delegate:void 0};function $(n){L.setTimeout(()=>{const{onUnhandledError:e}=V;if(!e)throw n;e(n)})}function re(){}const z=q("C",void 0,void 0);function q(n,e,t){return{kind:n,value:e,error:t}}let ne=null;function se(n){if(V.useDeprecatedSynchronousErrorHandling){const e=!ne;if(e&&(ne={errorThrown:!1,error:null}),n(),e){const{errorThrown:t,error:r}=ne;if(ne=null,t)throw r}}else n()}class pe extends F{constructor(e){super(),this.isStopped=!1,e?(this.destination=e,C(e)&&e.add(this)):this.destination=Te}static create(e,t,r){return new be(e,t,r)}next(e){this.isStopped?Ee(function X(n){return q("N",n,void 0)}(e),this):this._next(e)}error(e){this.isStopped?Ee(function te(n){return q("E",void 0,n)}(e),this):(this.isStopped=!0,this._error(e))}complete(){this.isStopped?Ee(z,this):(this.isStopped=!0,this._complete())}unsubscribe(){this.closed||(this.isStopped=!0,super.unsubscribe(),this.destination=null)}_next(e){this.destination.next(e)}_error(e){try{this.destination.error(e)}finally{this.unsubscribe()}}_complete(){try{this.destination.complete()}finally{this.unsubscribe()}}}const Le=Function.prototype.bind;function Se(n,e){return Le.call(n,e)}class Pe{constructor(e){this.partialObserver=e}next(e){const{partialObserver:t}=this;if(t.next)try{t.next(e)}catch(r){$e(r)}}error(e){const{partialObserver:t}=this;if(t.error)try{t.error(e)}catch(r){$e(r)}else $e(e)}complete(){const{partialObserver:e}=this;if(e.complete)try{e.complete()}catch(t){$e(t)}}}class be extends pe{constructor(e,t,r){let i;if(super(),D(e)||!e)i={next:e??void 0,error:t??void 0,complete:r??void 0};else{let s;this&&V.useDeprecatedNextContext?(s=Object.create(e),s.unsubscribe=()=>this.unsubscribe(),i={next:e.next&&Se(e.next,s),error:e.error&&Se(e.error,s),complete:e.complete&&Se(e.complete,s)}):i=e}this.destination=new Pe(i)}}function $e(n){V.useDeprecatedSynchronousErrorHandling?function de(n){V.useDeprecatedSynchronousErrorHandling&&ne&&(ne.errorThrown=!0,ne.error=n)}(n):$(n)}function Ee(n,e){const{onStoppedNotification:t}=V;t&&L.setTimeout(()=>t(n,e))}const Te={closed:!0,next:re,error:function H(n){throw n},complete:re},xe="function"==typeof Symbol&&Symbol.observable||"@@observable";function He(n){return n}let Xe=(()=>{class n{constructor(t){t&&(this._subscribe=t)}lift(t){const r=new n;return r.source=this,r.operator=t,r}subscribe(t,r,i){const s=function _t(n){return n&&n instanceof pe||function pt(n){return n&&D(n.next)&&D(n.error)&&D(n.complete)}(n)&&C(n)}(t)?t:new be(t,r,i);return se(()=>{const{operator:o,source:a}=this;s.add(o?o.call(s,a):a?this._subscribe(s):this._trySubscribe(s))}),s}_trySubscribe(t){try{return this._subscribe(t)}catch(r){t.error(r)}}forEach(t,r){return new(r=Nt(r))((i,s)=>{const o=new be({next:a=>{try{t(a)}catch(u){s(u),o.unsubscribe()}},error:s,complete:i});this.subscribe(o)})}_subscribe(t){var r;return null===(r=this.source)||void 0===r?void 0:r.subscribe(t)}[xe](){return this}pipe(...t){return function Je(n){return 0===n.length?He:1===n.length?n[0]:function(t){return n.reduce((r,i)=>i(r),t)}}(t)(this)}toPromise(t){return new(t=Nt(t))((r,i)=>{let s;this.subscribe(o=>s=o,o=>i(o),()=>r(s))})}}return n.create=e=>new n(e),n})();function Nt(n){var e;return null!==(e=n??V.Promise)&&void 0!==e?e:Promise}const Or=T(n=>function(){n(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"});let gr=(()=>{class n extends Xe{constructor(){super(),this.closed=!1,this.currentObservers=null,this.observers=[],this.isStopped=!1,this.hasError=!1,this.thrownError=null}lift(t){const r=new Hr(this,this);return r.operator=t,r}_throwIfClosed(){if(this.closed)throw new Or}next(t){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.currentObservers||(this.currentObservers=Array.from(this.observers));for(const r of this.currentObservers)r.next(t)}})}error(t){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.hasError=this.isStopped=!0,this.thrownError=t;const{observers:r}=this;for(;r.length;)r.shift().error(t)}})}complete(){se(()=>{if(this._throwIfClosed(),!this.isStopped){this.isStopped=!0;const{observers:t}=this;for(;t.length;)t.shift().complete()}})}unsubscribe(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null}get observed(){var t;return(null===(t=this.observers)||void 0===t?void 0:t.length)>0}_trySubscribe(t){return this._throwIfClosed(),super._trySubscribe(t)}_subscribe(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)}_innerSubscribe(t){const{hasError:r,isStopped:i,observers:s}=this;return r||i?G:(this.currentObservers=null,s.push(t),new F(()=>{this.currentObservers=null,k(s,t)}))}_checkFinalizedStatuses(t){const{hasError:r,thrownError:i,isStopped:s}=this;r?t.error(i):s&&t.complete()}asObservable(){const t=new Xe;return t.source=this,t}}return n.create=(e,t)=>new Hr(e,t),n})();class Hr extends gr{constructor(e,t){super(),this.destination=e,this.source=t}next(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===r||r.call(t,e)}error(e){var t,r;null===(r=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===r||r.call(t,e)}complete(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)}_subscribe(e){var t,r;return null!==(r=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==r?r:G}}function fe(n){return e=>{if(function ie(n){return D(n?.lift)}(e))return e.lift(function(t){try{return n(t,this)}catch(r){this.error(r)}});throw new TypeError("Unable to lift unknown Observable type")}}function ye(n,e,t,r,i){return new me(n,e,t,r,i)}class me extends pe{constructor(e,t,r,i,s,o){super(e),this.onFinalize=s,this.shouldUnsubscribe=o,this._next=t?function(a){try{t(a)}catch(u){e.error(u)}}:super._next,this._error=i?function(a){try{i(a)}catch(u){e.error(u)}finally{this.unsubscribe()}}:super._error,this._complete=r?function(){try{r()}catch(a){e.error(a)}finally{this.unsubscribe()}}:super._complete}unsubscribe(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){const{closed:t}=this;super.unsubscribe(),!t&&(null===(e=this.onFinalize)||void 0===e||e.call(this))}}}function Bt(n){return this instanceof Bt?(this.v=n,this):new Bt(n)}function pn(n,e,t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=t.apply(n,e||[]),s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(B){r[B]&&(i[B]=function(K){return new Promise(function(Z,J){s.push([B,K,Z,J])>1||a(B,K)})})}function a(B,K){try{!function u(B){B.value instanceof Bt?Promise.resolve(B.value.v).then(_,R):N(s[0][2],B)}(r[B](K))}catch(Z){N(s[0][3],Z)}}function _(B){a("next",B)}function R(B){a("throw",B)}function N(B,K){B(K),s.shift(),s.length&&a(s[0][0],s[0][1])}}function ft(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,e=n[Symbol.asyncIterator];return e?e.call(n):(n=function dt(n){var e="function"==typeof Symbol&&Symbol.iterator,t=e&&n[e],r=0;if(t)return t.call(n);if(n&&"number"==typeof n.length)return{next:function(){return n&&r>=n.length&&(n=void 0),{value:n&&n[r++],done:!n}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(n),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(s){t[s]=n[s]&&function(o){return new Promise(function(a,u){!function i(s,o,a,u){Promise.resolve(u).then(function(_){s({value:_,done:a})},o)}(a,u,(o=n[s](o)).done,o.value)})}}}const vn=n=>n&&"number"==typeof n.length&&"function"!=typeof n;function ur(n){return D(n?.then)}function Qn(n){return D(n[xe])}function En(n){return Symbol.asyncIterator&&D(n?.[Symbol.asyncIterator])}function Ft(n){return new TypeError(`You provided ${null!==n&&"object"==typeof n?"an invalid object":`'${n}'`} where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}const ce=function ct(){return"function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator"}();function ve(n){return D(n?.[ce])}function yt(n){return pn(this,arguments,function*(){const t=n.getReader();try{for(;;){const{value:r,done:i}=yield Bt(t.read());if(i)return yield Bt(void 0);yield yield Bt(r)}}finally{t.releaseLock()}})}function Dt(n){return D(n?.getReader)}function gn(n){if(n instanceof Xe)return n;if(null!=n){if(Qn(n))return function je(n){return new Xe(e=>{const t=n[xe]();if(D(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}(n);if(vn(n))return function Ye(n){return new Xe(e=>{for(let t=0;t{n.then(t=>{e.closed||(e.next(t),e.complete())},t=>e.error(t)).then(null,$)})}(n);if(En(n))return ht(n);if(ve(n))return function Ge(n){return new Xe(e=>{for(const t of n)if(e.next(t),e.closed)return;e.complete()})}(n);if(Dt(n))return function Et(n){return ht(yt(n))}(n)}throw Ft(n)}function ht(n){return new Xe(e=>{(function ut(n,e){var t,r,i,s;return function ge(n,e,t,r){return new(t||(t=Promise))(function(s,o){function a(R){try{_(r.next(R))}catch(N){o(N)}}function u(R){try{_(r.throw(R))}catch(N){o(N)}}function _(R){R.done?s(R.value):function i(s){return s instanceof t?s:new t(function(o){o(s)})}(R.value).then(a,u)}_((r=r.apply(n,e||[])).next())})}(this,void 0,void 0,function*(){try{for(t=ft(n);!(r=yield t.next()).done;)if(e.next(r.value),e.closed)return}catch(o){i={error:o}}finally{try{r&&!r.done&&(s=t.return)&&(yield s.call(t))}finally{if(i)throw i.error}}e.complete()})})(n,e).catch(t=>e.error(t))})}function St(n,e,t,r=0,i=!1){const s=e.schedule(function(){t(),i?n.add(this.schedule(null,r)):this.unsubscribe()},r);if(n.add(s),!i)return s}function Ut(n,e,t=1/0){return D(e)?Ut((r,i)=>function _e(n,e){return fe((t,r)=>{let i=0;t.subscribe(ye(r,s=>{r.next(n.call(e,s,i++))}))})}((s,o)=>e(r,s,i,o))(gn(n(r,i))),t):("number"==typeof e&&(t=e),fe((r,i)=>function $t(n,e,t,r,i,s,o,a){const u=[];let _=0,R=0,N=!1;const B=()=>{N&&!u.length&&!_&&e.complete()},K=J=>_{s&&e.next(J),_++;let oe=!1;gn(t(J,R++)).subscribe(ye(e,he=>{i?.(he),s?K(he):e.next(he)},()=>{oe=!0},void 0,()=>{if(oe)try{for(_--;u.length&&_Z(he)):Z(he)}B()}catch(he){e.error(he)}}))};return n.subscribe(ye(e,K,()=>{N=!0,B()})),()=>{a?.()}}(r,i,n,t)))}const Dn=new Xe(n=>n.complete());function Co(n){return n[n.length-1]}function Q(n,e=0){return fe((t,r)=>{t.subscribe(ye(r,i=>St(r,n,()=>r.next(i),e),()=>St(r,n,()=>r.complete(),e),i=>St(r,n,()=>r.error(i),e)))})}function ee(n,e=0){return fe((t,r)=>{r.add(n.schedule(()=>t.subscribe(r),e))})}function Ze(n,e){if(!n)throw new Error("Iterable cannot be null");return new Xe(t=>{St(t,e,()=>{const r=n[Symbol.asyncIterator]();St(t,e,()=>{r.next().then(i=>{i.done?t.complete():t.next(i.value)})},0,!0)})})}function ei(...n){const e=function ua(n){return function ca(n){return n&&D(n.schedule)}(Co(n))?n.pop():void 0}(n),t=function W(n,e){return"number"==typeof Co(n)?n.pop():e}(n,1/0),r=n;return r.length?1===r.length?gn(r[0]):function An(n=1/0){return Ut(He,n)}(t)(function di(n,e){return e?function yr(n,e){if(null!=n){if(Qn(n))return function le(n,e){return gn(n).pipe(ee(e),Q(e))}(n,e);if(vn(n))return function Ve(n,e){return new Xe(t=>{let r=0;return e.schedule(function(){r===n.length?t.complete():(t.next(n[r++]),t.closed||this.schedule())})})}(n,e);if(ur(n))return function ke(n,e){return gn(n).pipe(ee(e),Q(e))}(n,e);if(En(n))return Ze(n,e);if(ve(n))return function tt(n,e){return new Xe(t=>{let r;return St(t,e,()=>{r=n[ce](),St(t,e,()=>{let i,s;try{({value:i,done:s}=r.next())}catch(o){return void t.error(o)}s?t.complete():t.next(i)},0,!0)}),()=>D(r?.return)&&r.return()})}(n,e);if(Dt(n))return function rn(n,e){return Ze(yt(n),e)}(n,e)}throw Ft(n)}(n,e):gn(n)}(r,e)):Dn}function Io(n,e,...t){if(!0===e)return void n();if(!1===e)return;const r=new be({next:()=>{r.unsubscribe(),n()}});return e(...t).subscribe(r)}function Xt(n){for(let e in n)if(n[e]===Xt)return e;throw Error("Could not find renamed property on target object.")}function bn(n){if("string"==typeof n)return n;if(Array.isArray(n))return"["+n.map(bn).join(", ")+"]";if(null==n)return""+n;if(n.overriddenName)return`${n.overriddenName}`;if(n.name)return`${n.name}`;const e=n.toString();if(null==e)return""+e;const t=e.indexOf("\n");return-1===t?e:e.substring(0,t)}function Li(n,e){return null==n||""===n?null===e?"":e:null==e||""===e?n:n+" "+e}const Eu=Xt({__forward_ref__:Xt});function pp(n){return n.__forward_ref__=pp,n.toString=function(){return bn(this())},n}function Rt(n){return function gp(n){return"function"==typeof n&&n.hasOwnProperty(Eu)&&n.__forward_ref__===pp}(n)?n():n}class Tt extends Error{constructor(e,t){super(function af(n,e){return`NG0${Math.abs(n)}${e?": "+e.trim():""}`}(e,t)),this.code=e}}function Vt(n){return"string"==typeof n?n:null==n?"":String(n)}function cf(n,e){throw new Tt(-201,!1)}function Ci(n,e){null==n&&function xn(n,e,t,r){throw new Error(`ASSERTION ERROR: ${n}`+(null==r?"":` [Expected=> ${t} ${r} ${e} <=Actual]`))}(e,n,null,"!=")}function zn(n){return{token:n.token,providedIn:n.providedIn||null,factory:n.factory,value:void 0}}function Ka(n){return{providers:n.providers||[],imports:n.imports||[]}}function uf(n){return lb(n,lf)||lb(n,db)}function lb(n,e){return n.hasOwnProperty(e)?n[e]:null}function fb(n){return n&&(n.hasOwnProperty(yp)||n.hasOwnProperty(ux))?n[yp]:null}const lf=Xt({\u0275prov:Xt}),yp=Xt({\u0275inj:Xt}),db=Xt({ngInjectableDef:Xt}),ux=Xt({ngInjectorDef:Xt});var Mt=(()=>((Mt=Mt||{})[Mt.Default=0]="Default",Mt[Mt.Host=1]="Host",Mt[Mt.Self=2]="Self",Mt[Mt.SkipSelf=4]="SkipSelf",Mt[Mt.Optional=8]="Optional",Mt))();let mp;function Bi(n){const e=mp;return mp=n,e}function hb(n,e,t){const r=uf(n);return r&&"root"==r.providedIn?void 0===r.value?r.value=r.factory():r.value:t&Mt.Optional?null:void 0!==e?e:void cf(bn(n))}function To(n){return{toString:n}.toString()}var rs=(()=>((rs=rs||{})[rs.OnPush=0]="OnPush",rs[rs.Default=1]="Default",rs))(),Is=(()=>{return(n=Is||(Is={}))[n.Emulated=0]="Emulated",n[n.None=2]="None",n[n.ShadowDom=3]="ShadowDom",Is;var n})();const Fn=(()=>typeof globalThis<"u"&&globalThis||typeof global<"u"&&global||typeof window<"u"&&window||typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&self)(),$a={},Cn=[],ff=Xt({\u0275cmp:Xt}),vp=Xt({\u0275dir:Xt}),Ep=Xt({\u0275pipe:Xt}),pb=Xt({\u0275mod:Xt}),zs=Xt({\u0275fac:Xt}),bu=Xt({__NG_ELEMENT_ID__:Xt});let fx=0;function df(n){return To(()=>{const t=!0===n.standalone,r={},i={type:n.type,providersResolver:null,decls:n.decls,vars:n.vars,factory:null,template:n.template||null,consts:n.consts||null,ngContentSelectors:n.ngContentSelectors,hostBindings:n.hostBindings||null,hostVars:n.hostVars||0,hostAttrs:n.hostAttrs||null,contentQueries:n.contentQueries||null,declaredInputs:r,inputs:null,outputs:null,exportAs:n.exportAs||null,onPush:n.changeDetection===rs.OnPush,directiveDefs:null,pipeDefs:null,standalone:t,dependencies:t&&n.dependencies||null,getStandaloneInjector:null,selectors:n.selectors||Cn,viewQuery:n.viewQuery||null,features:n.features||null,data:n.data||{},encapsulation:n.encapsulation||Is.Emulated,id:"c"+fx++,styles:n.styles||Cn,_:null,setInput:null,schemas:n.schemas||null,tView:null},s=n.dependencies,o=n.features;return i.inputs=mb(n.inputs,r),i.outputs=mb(n.outputs),o&&o.forEach(a=>a(i)),i.directiveDefs=s?()=>("function"==typeof s?s():s).map(gb).filter(yb):null,i.pipeDefs=s?()=>("function"==typeof s?s():s).map(ri).filter(yb):null,i})}function gb(n){return Pn(n)||ni(n)}function yb(n){return null!==n}function wu(n){return To(()=>({type:n.type,bootstrap:n.bootstrap||Cn,declarations:n.declarations||Cn,imports:n.imports||Cn,exports:n.exports||Cn,transitiveCompileScopes:null,schemas:n.schemas||null,id:n.id||null}))}function mb(n,e){if(null==n)return $a;const t={};for(const r in n)if(n.hasOwnProperty(r)){let i=n[r],s=i;Array.isArray(i)&&(s=i[1],i=i[0]),t[i]=r,e&&(e[i]=s)}return t}const Fi=df;function Pn(n){return n[ff]||null}function ni(n){return n[vp]||null}function ri(n){return n[Ep]||null}function pi(n){return Array.isArray(n)&&"object"==typeof n[1]}function ss(n){return Array.isArray(n)&&!0===n[1]}function _p(n){return 0!=(8&n.flags)}function yf(n){return 2==(2&n.flags)}function mf(n){return 1==(1&n.flags)}function os(n){return null!==n.template}function mx(n){return 0!=(256&n[2])}function pa(n,e){return n.hasOwnProperty(zs)?n[zs]:null}class bx{constructor(e,t,r){this.previousValue=e,this.currentValue=t,this.firstChange=r}isFirstChange(){return this.firstChange}}function bb(n){return n.type.prototype.ngOnChanges&&(n.setInput=_x),wx}function wx(){const n=_b(this),e=n?.current;if(e){const t=n.previous;if(t===$a)n.previous=e;else for(let r in e)t[r]=e[r];n.current=null,this.ngOnChanges(e)}}function _x(n,e,t,r){const i=_b(n)||function Dx(n,e){return n[wb]=e}(n,{previous:$a,current:null}),s=i.current||(i.current={}),o=i.previous,a=this.declaredInputs[t],u=o[a];s[a]=new bx(u&&u.currentValue,e,o===$a),n[r]=e}const wb="__ngSimpleChanges__";function _b(n){return n[wb]||null}function mr(n){for(;Array.isArray(n);)n=n[0];return n}function Hi(n,e){return mr(e[n.index])}function Tp(n,e){return n.data[e]}function Ai(n,e){const t=e[n];return pi(t)?t:t[0]}function bf(n){return 64==(64&n[2])}function Ao(n,e){return null==e?null:n[e]}function Db(n){n[18]=0}function Ap(n,e){n[5]+=e;let t=n,r=n[3];for(;null!==r&&(1===e&&1===t[5]||-1===e&&0===t[5]);)r[5]+=e,t=r,r=r[3]}const kt={lFrame:Mb(null),bindingsEnabled:!0};function Cb(){return kt.bindingsEnabled}function Ue(){return kt.lFrame.lView}function fn(){return kt.lFrame.tView}function Tr(){let n=Ib();for(;null!==n&&64===n.type;)n=n.parent;return n}function Ib(){return kt.lFrame.currentTNode}function Ts(n,e){const t=kt.lFrame;t.currentTNode=n,t.isParent=e}function xp(){return kt.lFrame.isParent}function qa(){return kt.lFrame.bindingIndex++}function Vx(n,e){const t=kt.lFrame;t.bindingIndex=t.bindingRootIndex=n,Pp(e)}function Pp(n){kt.lFrame.currentDirectiveIndex=n}function Mp(n){kt.lFrame.currentQueryIndex=n}function Kx(n){const e=n[1];return 2===e.type?e.declTNode:1===e.type?n[6]:null}function Pb(n,e,t){if(t&Mt.SkipSelf){let i=e,s=n;for(;!(i=i.parent,null!==i||t&Mt.Host||(i=Kx(s),null===i||(s=s[15],10&i.type))););if(null===i)return!1;e=i,n=s}const r=kt.lFrame=Nb();return r.currentTNode=e,r.lView=n,!0}function Op(n){const e=Nb(),t=n[1];kt.lFrame=e,e.currentTNode=t.firstChild,e.lView=n,e.tView=t,e.contextLView=n,e.bindingIndex=t.bindingStartIndex,e.inI18n=!1}function Nb(){const n=kt.lFrame,e=null===n?null:n.child;return null===e?Mb(n):e}function Mb(n){const e={currentTNode:null,isParent:!0,lView:null,tView:null,selectedIndex:-1,contextLView:null,elementDepthCount:0,currentNamespace:null,currentDirectiveIndex:-1,bindingRootIndex:-1,bindingIndex:-1,currentQueryIndex:0,parent:n,child:null,inI18n:!1};return null!==n&&(n.child=e),e}function Ob(){const n=kt.lFrame;return kt.lFrame=n.parent,n.currentTNode=null,n.lView=null,n}const kb=Ob;function kp(){const n=Ob();n.isParent=!0,n.tView=null,n.selectedIndex=-1,n.contextLView=null,n.elementDepthCount=0,n.currentDirectiveIndex=-1,n.currentNamespace=null,n.bindingRootIndex=-1,n.bindingIndex=-1,n.currentQueryIndex=0}function si(){return kt.lFrame.selectedIndex}function xo(n){kt.lFrame.selectedIndex=n}function wf(n,e){for(let t=e.directiveStart,r=e.directiveEnd;t=r)break}else e[u]<0&&(n[18]+=65536),(a>11>16&&(3&n[2])===e){n[2]+=2048;try{s.call(a)}finally{}}}else try{s.call(a)}finally{}}class Au{constructor(e,t,r){this.factory=e,this.resolving=!1,this.canSeeViewProviders=t,this.injectImpl=r}}function Sf(n,e,t){let r=0;for(;re){o=s-1;break}}}for(;s>16}(n),r=e;for(;t>0;)r=r[15],t--;return r}let Fp=!0;function If(n){const e=Fp;return Fp=n,e}let rR=0;const As={};function Ru(n,e){const t=Vp(n,e);if(-1!==t)return t;const r=e[1];r.firstCreatePass&&(n.injectorIndex=e.length,Up(r.data,n),Up(e,null),Up(r.blueprint,null));const i=Tf(n,e),s=n.injectorIndex;if(Vb(i)){const o=Ya(i),a=Qa(i,e),u=a[1].data;for(let _=0;_<8;_++)e[s+_]=a[o+_]|u[o+_]}return e[s+8]=i,s}function Up(n,e){n.push(0,0,0,0,0,0,0,0,e)}function Vp(n,e){return-1===n.injectorIndex||n.parent&&n.parent.injectorIndex===n.injectorIndex||null===e[n.injectorIndex+8]?-1:n.injectorIndex}function Tf(n,e){if(n.parent&&-1!==n.parent.injectorIndex)return n.parent.injectorIndex;let t=0,r=null,i=e;for(;null!==i;){if(r=Yb(i),null===r)return-1;if(t++,i=i[15],-1!==r.injectorIndex)return r.injectorIndex|t<<16}return-1}function Af(n,e,t){!function iR(n,e,t){let r;"string"==typeof t?r=t.charCodeAt(0)||0:t.hasOwnProperty(bu)&&(r=t[bu]),null==r&&(r=t[bu]=rR++);const i=255&r;e.data[n+(i>>5)]|=1<=0?255&e:cR:e}(t);if("function"==typeof s){if(!Pb(e,n,r))return r&Mt.Host?$b(i,0,r):jb(e,t,r,i);try{const o=s(r);if(null!=o||r&Mt.Optional)return o;cf()}finally{kb()}}else if("number"==typeof s){let o=null,a=Vp(n,e),u=-1,_=r&Mt.Host?e[16][6]:null;for((-1===a||r&Mt.SkipSelf)&&(u=-1===a?Tf(n,e):e[a+8],-1!==u&&qb(r,!1)?(o=e[1],a=Ya(u),e=Qa(u,e)):a=-1);-1!==a;){const R=e[1];if(Wb(s,a,R.data)){const N=oR(a,e,t,o,r,_);if(N!==As)return N}u=e[a+8],-1!==u&&qb(r,e[1].data[a+8]===_)&&Wb(s,a,e)?(o=R,a=Ya(u),e=Qa(u,e)):a=-1}}return i}function oR(n,e,t,r,i,s){const o=e[1],a=o.data[n+8],R=function xf(n,e,t,r,i){const s=n.providerIndexes,o=e.data,a=1048575&s,u=n.directiveStart,R=s>>20,B=i?a+R:n.directiveEnd;for(let K=r?a:a+R;K=u&&Z.type===t)return K}if(i){const K=o[u];if(K&&os(K)&&K.type===t)return u}return null}(a,o,t,null==r?yf(a)&&Fp:r!=o&&0!=(3&a.type),i&Mt.Host&&s===a);return null!==R?Pu(e,o,R,a):As}function Pu(n,e,t,r){let i=n[t];const s=e.data;if(function Xx(n){return n instanceof Au}(i)){const o=i;o.resolving&&function nx(n,e){const t=e?`. Dependency path: ${e.join(" > ")} > ${n}`:"";throw new Tt(-200,`Circular dependency in DI detected for ${n}${t}`)}(function Sn(n){return"function"==typeof n?n.name||n.toString():"object"==typeof n&&null!=n&&"function"==typeof n.type?n.type.name||n.type.toString():Vt(n)}(s[t]));const a=If(o.canSeeViewProviders);o.resolving=!0;const u=o.injectImpl?Bi(o.injectImpl):null;Pb(n,r,Mt.Default);try{i=n[t]=o.factory(void 0,s,n,r),e.firstCreatePass&&t>=r.directiveStart&&function Qx(n,e,t){const{ngOnChanges:r,ngOnInit:i,ngDoCheck:s}=e.type.prototype;if(r){const o=bb(e);(t.preOrderHooks||(t.preOrderHooks=[])).push(n,o),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,o)}i&&(t.preOrderHooks||(t.preOrderHooks=[])).push(0-n,i),s&&((t.preOrderHooks||(t.preOrderHooks=[])).push(n,s),(t.preOrderCheckHooks||(t.preOrderCheckHooks=[])).push(n,s))}(t,s[t],e)}finally{null!==u&&Bi(u),If(a),o.resolving=!1,kb()}}return i}function Wb(n,e,t){return!!(t[e+(n>>5)]&1<{const r=function $p(n){return function(...t){if(n){const r=n(...t);for(const i in r)this[i]=r[i]}}}(e);function i(...s){if(this instanceof i)return r.apply(this,s),this;const o=new i(...s);return a.annotation=o,a;function a(u,_,R){const N=u.hasOwnProperty(Ja)?u[Ja]:Object.defineProperty(u,Ja,{value:[]})[Ja];for(;N.length<=R;)N.push(null);return(N[R]=N[R]||[]).push(o),u}}return t&&(i.prototype=Object.create(t.prototype)),i.prototype.ngMetadataName=n,i.annotationCls=i,i})}class sn{constructor(e,t){this._desc=e,this.ngMetadataName="InjectionToken",this.\u0275prov=void 0,"number"==typeof t?this.__NG_ELEMENT_ID__=t:void 0!==t&&(this.\u0275prov=zn({token:this,providedIn:t.providedIn||"root",factory:t.factory}))}get multi(){return this}toString(){return`InjectionToken ${this._desc}`}}function Ys(n,e){n.forEach(t=>Array.isArray(t)?Ys(t,e):e(t))}function Zb(n,e,t){e>=n.length?n.push(t):n.splice(e,0,t)}function Rf(n,e){return e>=n.length-1?n.pop():n.splice(e,1)[0]}const ku={},Wp="__NG_DI_FLAG__",Nf="ngTempTokenPath",_R=/\n/gm,tw="__source";let Lu;function rc(n){const e=Lu;return Lu=n,e}function SR(n,e=Mt.Default){if(void 0===Lu)throw new Tt(-203,!1);return null===Lu?hb(n,void 0,e):Lu.get(n,e&Mt.Optional?null:void 0,e)}function Rn(n,e=Mt.Default){return(function lx(){return mp}()||SR)(Rt(n),e)}function qp(n){const e=[];for(let t=0;t{const o=s;rg(o,t,[],r)&&(i||(i=[]),i.push(o))}),void 0!==i&&Aw(i,t),t}function Aw(n,e){for(let t=0;t{e.push(s)})}}function rg(n,e,t,r){if(!(n=Rt(n)))return!1;let i=null,s=fb(n);const o=!s&&Pn(n);if(s||o){if(o&&!o.standalone)return!1;i=n}else{const u=n.ngModule;if(s=fb(u),!s)return!1;i=u}const a=r.has(i);if(o){if(a)return!1;if(r.add(i),o.dependencies){const u="function"==typeof o.dependencies?o.dependencies():o.dependencies;for(const _ of u)rg(_,e,t,r)}}else{if(!s)return!1;{if(null!=s.imports&&!a){let _;r.add(i);try{Ys(s.imports,R=>{rg(R,e,t,r)&&(_||(_=[]),_.push(R))})}finally{}void 0!==_&&Aw(_,e)}if(!a){const _=pa(i)||(()=>new i);e.push({provide:i,useFactory:_,deps:Cn},{provide:Cw,useValue:i,multi:!0},{provide:Dw,useValue:()=>Rn(i),multi:!0})}const u=s.providers;null==u||a||Ys(u,R=>{e.push(R)})}}return i!==n&&void 0!==n.providers}const fP=Xt({provide:String,useValue:Xt});function ig(n){return null!==n&&"object"==typeof n&&fP in n}function ga(n){return"function"==typeof n}const sg=new sn("Set Injector scope."),Vf={},hP={};let og;function Hf(){return void 0===og&&(og=new Iw),og}class oc{}class Pw extends oc{constructor(e,t,r,i){super(),this.parent=t,this.source=r,this.scopes=i,this.records=new Map,this._ngOnDestroyHooks=new Set,this._onDestroyHooks=[],this._destroyed=!1,cg(e,o=>this.processProvider(o)),this.records.set(Sw,ac(void 0,this)),i.has("environment")&&this.records.set(oc,ac(void 0,this));const s=this.records.get(sg);null!=s&&"string"==typeof s.value&&this.scopes.add(s.value),this.injectorDefTypes=new Set(this.get(Cw.multi,Cn,Mt.Self))}get destroyed(){return this._destroyed}destroy(){this.assertNotDestroyed(),this._destroyed=!0;try{for(const e of this._ngOnDestroyHooks)e.ngOnDestroy();for(const e of this._onDestroyHooks)e()}finally{this.records.clear(),this._ngOnDestroyHooks.clear(),this.injectorDefTypes.clear(),this._onDestroyHooks.length=0}}onDestroy(e){this._onDestroyHooks.push(e)}runInContext(e){this.assertNotDestroyed();const t=rc(this),r=Bi(void 0);try{return e()}finally{rc(t),Bi(r)}}get(e,t=ku,r=Mt.Default){this.assertNotDestroyed();const i=rc(this),s=Bi(void 0);try{if(!(r&Mt.SkipSelf)){let a=this.records.get(e);if(void 0===a){const u=function vP(n){return"function"==typeof n||"object"==typeof n&&n instanceof sn}(e)&&uf(e);a=u&&this.injectableDefInScope(u)?ac(ag(e),Vf):null,this.records.set(e,a)}if(null!=a)return this.hydrate(e,a)}return(r&Mt.Self?Hf():this.parent).get(e,t=r&Mt.Optional&&t===ku?null:t)}catch(o){if("NullInjectorError"===o.name){if((o[Nf]=o[Nf]||[]).unshift(bn(e)),i)throw o;return function TR(n,e,t,r){const i=n[Nf];throw e[tw]&&i.unshift(e[tw]),n.message=function AR(n,e,t,r=null){n=n&&"\n"===n.charAt(0)&&"\u0275"==n.charAt(1)?n.slice(2):n;let i=bn(e);if(Array.isArray(e))i=e.map(bn).join(" -> ");else if("object"==typeof e){let s=[];for(let o in e)if(e.hasOwnProperty(o)){let a=e[o];s.push(o+":"+("string"==typeof a?JSON.stringify(a):bn(a)))}i=`{${s.join(", ")}}`}return`${t}${r?"("+r+")":""}[${i}]: ${n.replace(_R,"\n ")}`}("\n"+n.message,i,t,r),n.ngTokenPath=i,n[Nf]=null,n}(o,e,"R3InjectorError",this.source)}throw o}finally{Bi(s),rc(i)}}resolveInjectorInitializers(){const e=rc(this),t=Bi(void 0);try{const r=this.get(Dw.multi,Cn,Mt.Self);for(const i of r)i()}finally{rc(e),Bi(t)}}toString(){const e=[],t=this.records;for(const r of t.keys())e.push(bn(r));return`R3Injector[${e.join(", ")}]`}assertNotDestroyed(){if(this._destroyed)throw new Tt(205,!1)}processProvider(e){let t=ga(e=Rt(e))?e:Rt(e&&e.provide);const r=function gP(n){return ig(n)?ac(void 0,n.useValue):ac(function Nw(n,e,t){let r;if(ga(n)){const i=Rt(n);return pa(i)||ag(i)}if(ig(n))r=()=>Rt(n.useValue);else if(function Rw(n){return!(!n||!n.useFactory)}(n))r=()=>n.useFactory(...qp(n.deps||[]));else if(function xw(n){return!(!n||!n.useExisting)}(n))r=()=>Rn(Rt(n.useExisting));else{const i=Rt(n&&(n.useClass||n.provide));if(!function yP(n){return!!n.deps}(n))return pa(i)||ag(i);r=()=>new i(...qp(n.deps))}return r}(n),Vf)}(e);if(ga(e)||!0!==e.multi)this.records.get(t);else{let i=this.records.get(t);i||(i=ac(void 0,Vf,!0),i.factory=()=>qp(i.multi),this.records.set(t,i)),t=e,i.multi.push(e)}this.records.set(t,r)}hydrate(e,t){return t.value===Vf&&(t.value=hP,t.value=t.factory()),"object"==typeof t.value&&t.value&&function mP(n){return null!==n&&"object"==typeof n&&"function"==typeof n.ngOnDestroy}(t.value)&&this._ngOnDestroyHooks.add(t.value),t.value}injectableDefInScope(e){if(!e.providedIn)return!1;const t=Rt(e.providedIn);return"string"==typeof t?"any"===t||this.scopes.has(t):this.injectorDefTypes.has(t)}}function ag(n){const e=uf(n),t=null!==e?e.factory:pa(n);if(null!==t)return t;if(n instanceof sn)throw new Tt(204,!1);if(n instanceof Function)return function pP(n){const e=n.length;if(e>0)throw function Ou(n,e){const t=[];for(let r=0;rt.factory(n):()=>new n}(n);throw new Tt(204,!1)}function ac(n,e,t=!1){return{factory:n,value:e,multi:t?[]:void 0}}function EP(n){return!!n.\u0275providers}function cg(n,e){for(const t of n)Array.isArray(t)?cg(t,e):EP(t)?cg(t.\u0275providers,e):e(t)}class Mw{}class _P{resolveComponentFactory(e){throw function wP(n){const e=Error(`No component factory found for ${bn(n)}. Did you add it to @NgModule.entryComponents?`);return e.ngComponent=n,e}(e)}}let Kf=(()=>{class n{}return n.NULL=new _P,n})();function DP(){return cc(Tr(),Ue())}function cc(n,e){return new uc(Hi(n,e))}let uc=(()=>{class n{constructor(t){this.nativeElement=t}}return n.__NG_ELEMENT_ID__=DP,n})();class kw{}let IP=(()=>{class n{}return n.\u0275prov=zn({token:n,providedIn:"root",factory:()=>null}),n})();class ug{constructor(e){this.full=e,this.major=e.split(".")[0],this.minor=e.split(".")[1],this.patch=e.split(".").slice(2).join(".")}}const TP=new ug("14.2.2"),lg={};function gg(n){return n.ngOriginalError}class lc{constructor(){this._console=console}handleError(e){const t=this._findOriginalError(e);this._console.error("ERROR",e),t&&this._console.error("ORIGINAL ERROR",t)}_findOriginalError(e){let t=e&&gg(e);for(;t&&gg(t);)t=gg(t);return t||null}}const yg=new Map;let UP=0;const vg="__ngContext__";function jr(n,e){pi(e)?(n[vg]=e[20],function HP(n){yg.set(n[20],n)}(e)):n[vg]=e}var gi=(()=>((gi=gi||{})[gi.Important=1]="Important",gi[gi.DashCase=2]="DashCase",gi))();function bg(n,e){return undefined(n,e)}function ju(n){const e=n[3];return ss(e)?e[3]:e}function wg(n){return Qw(n[13])}function _g(n){return Qw(n[4])}function Qw(n){for(;null!==n&&!ss(n);)n=n[4];return n}function dc(n,e,t,r,i){if(null!=r){let s,o=!1;ss(r)?s=r:pi(r)&&(o=!0,r=r[0]);const a=mr(r);0===n&&null!==t?null==i?n_(e,t,a):ya(e,t,a,i||null,!0):1===n&&null!==t?ya(e,t,a,i||null,!0):2===n?function u_(n,e,t){const r=$f(n,e);r&&function pN(n,e,t,r){n.removeChild(e,t,r)}(n,r,e,t)}(e,a,o):3===n&&e.destroyNode(a),null!=s&&function mN(n,e,t,r,i){const s=t[7];s!==mr(t)&&dc(e,n,r,s,i);for(let a=10;a0&&(n[t-1][4]=r[4]);const s=Rf(n,10+e);!function oN(n,e){Gu(n,e,e[11],2,null,null),e[0]=null,e[6]=null}(r[1],r);const o=s[19];null!==o&&o.detachView(s[1]),r[3]=null,r[4]=null,r[2]&=-65}return r}function Jw(n,e){if(!(128&e[2])){const t=e[11];t.destroyNode&&Gu(n,e,t,3,null,null),function uN(n){let e=n[13];if(!e)return Ig(n[1],n);for(;e;){let t=null;if(pi(e))t=e[13];else{const r=e[10];r&&(t=r)}if(!t){for(;e&&!e[4]&&e!==n;)pi(e)&&Ig(e[1],e),e=e[3];null===e&&(e=n),pi(e)&&Ig(e[1],e),t=e&&e[4]}e=t}}(e)}}function Ig(n,e){if(!(128&e[2])){e[2]&=-65,e[2]|=128,function hN(n,e){let t;if(null!=n&&null!=(t=n.destroyHooks))for(let r=0;r=0?r[i=_]():r[i=-_].unsubscribe(),s+=2}else{const o=r[i=t[s+1]];t[s].call(o)}if(null!==r){for(let s=i+1;ss?"":i[N+1].toLowerCase();const K=8&r?B:null;if(K&&-1!==d_(K,_,0)||2&r&&_!==B){if(as(r))return!1;o=!0}}}}else{if(!o&&!as(r)&&!as(u))return!1;if(o&&as(u))continue;o=!1,r=u|1&r}}return as(r)||o}function as(n){return 0==(1&n)}function _N(n,e,t,r){if(null===e)return-1;let i=0;if(r||!t){let s=!1;for(;i-1)for(t++;t0?'="'+a+'"':"")+"]"}else 8&r?i+="."+o:4&r&&(i+=" "+o);else""!==i&&!as(o)&&(e+=y_(s,i),i=""),r=o,s=s||!as(r);t++}return""!==i&&(e+=y_(s,i)),e}const Ht={};function zu(n){m_(fn(),Ue(),si()+n,!1)}function m_(n,e,t,r){if(!r)if(3==(3&e[2])){const s=n.preOrderCheckHooks;null!==s&&_f(e,s,t)}else{const s=n.preOrderHooks;null!==s&&Df(e,s,0,t)}xo(t)}function w_(n,e=null,t=null,r){const i=__(n,e,t,r);return i.resolveInjectorInitializers(),i}function __(n,e=null,t=null,r,i=new Set){const s=[t||Cn,lP(n)];return r=r||("object"==typeof n?void 0:bn(n)),new Pw(s,e||Hf(),r||null,i)}let ma=(()=>{class n{static create(t,r){if(Array.isArray(t))return w_({name:""},r,t,"");{const i=t.name??"";return w_({name:i},t.parent,t.providers,i)}}}return n.THROW_IF_NOT_FOUND=ku,n.NULL=new Iw,n.\u0275prov=zn({token:n,providedIn:"any",factory:()=>Rn(Sw)}),n.__NG_ELEMENT_ID__=-1,n})();function Zt(n,e=Mt.Default){const t=Ue();return null===t?Rn(n,e):Gb(Tr(),t,Rt(n),e)}function U_(n,e){const t=n.contentQueries;if(null!==t)for(let r=0;r22&&m_(n,e,22,!1),t(r,i)}finally{xo(s)}}function Wg(n,e,t){!Cb()||(function gM(n,e,t,r){const i=t.directiveStart,s=t.directiveEnd;n.firstCreatePass||Ru(t,e),jr(r,e);const o=t.initialInputs;for(let a=i;a0;){const t=n[--e];if("number"==typeof t&&t<0)return t}return 0})(a)!=u&&a.push(u),a.push(r,i,o)}}function q_(n,e){null!==n.hostBindings&&n.hostBindings(1,e)}function Y_(n,e){e.flags|=2,(n.components||(n.components=[])).push(e.index)}function EM(n,e,t){if(t){if(e.exportAs)for(let r=0;r0&&Xg(t)}}function Xg(n){for(let r=wg(n);null!==r;r=_g(r))for(let i=10;i0&&Xg(s)}const t=n[1].components;if(null!==t)for(let r=0;r0&&Xg(i)}}function IM(n,e){const t=Ai(e,n),r=t[1];(function TM(n,e){for(let t=e.length;t-1&&(Cg(e,r),Rf(t,r))}this._attachedToViewContainer=!1}Jw(this._lView[1],this._lView)}onDestroy(e){!function $_(n,e,t,r){const i=J_(e);null===t?i.push(r):(i.push(t),n.firstCreatePass&&e1(n).push(r,i.length-1))}(this._lView[1],this._lView,null,e)}markForCheck(){Jg(this._cdRefInjectingView||this._lView)}detach(){this._lView[2]&=-65}reattach(){this._lView[2]|=64}detectChanges(){Jf(this._lView[1],this._lView,this.context)}checkNoChanges(){}attachToViewContainerRef(){if(this._appRef)throw new Tt(902,!1);this._attachedToViewContainer=!0}detachFromAppRef(){this._appRef=null,function cN(n,e){Gu(n,e,e[11],2,null,null)}(this._lView[1],this._lView)}attachToAppRef(e){if(this._attachedToViewContainer)throw new Tt(902,!1);this._appRef=e}}class AM extends Wu{constructor(e){super(e),this._view=e}detectChanges(){const e=this._view;Jf(e[1],e,e[8],!1)}checkNoChanges(){}get context(){return null}}class ny extends Kf{constructor(e){super(),this.ngModule=e}resolveComponentFactory(e){const t=Pn(e);return new qu(t,this.ngModule)}}function r1(n){const e=[];for(let t in n)n.hasOwnProperty(t)&&e.push({propName:n[t],templateName:t});return e}class RM{constructor(e,t){this.injector=e,this.parentInjector=t}get(e,t,r){const i=this.injector.get(e,lg,r);return i!==lg||t===lg?i:this.parentInjector.get(e,t,r)}}class qu extends Mw{constructor(e,t){super(),this.componentDef=e,this.ngModule=t,this.componentType=e.type,this.selector=function AN(n){return n.map(TN).join(",")}(e.selectors),this.ngContentSelectors=e.ngContentSelectors?e.ngContentSelectors:[],this.isBoundToModule=!!t}get inputs(){return r1(this.componentDef.inputs)}get outputs(){return r1(this.componentDef.outputs)}create(e,t,r,i){let s=(i=i||this.ngModule)instanceof oc?i:i?.injector;s&&null!==this.componentDef.getStandaloneInjector&&(s=this.componentDef.getStandaloneInjector(s)||s);const o=s?new RM(e,s):e,a=o.get(kw,null);if(null===a)throw new Tt(407,!1);const u=o.get(IP,null),_=a.createRenderer(null,this.componentDef),R=this.componentDef.selectors[0][0]||"div",N=r?function uM(n,e,t){return n.selectRootElement(e,t===Is.ShadowDom)}(_,r,this.componentDef.encapsulation):Sg(a.createRenderer(null,this.componentDef),R,function xM(n){const e=n.toLowerCase();return"svg"===e?"svg":"math"===e?"math":null}(R)),B=this.componentDef.onPush?288:272,K=Yg(0,null,null,1,0,null,null,null,null,null),Z=Qf(null,K,null,B,null,null,a,_,u,o,null);let J,oe;Op(Z);try{const he=function MM(n,e,t,r,i,s){const o=t[1];t[22]=n;const u=pc(o,22,2,"#host",null),_=u.mergedAttrs=e.hostAttrs;null!==_&&(ed(u,_,!0),null!==n&&(Sf(i,n,_),null!==u.classes&&Rg(i,n,u.classes),null!==u.styles&&f_(i,n,u.styles)));const R=r.createRenderer(n,e),N=Qf(t,K_(e),null,e.onPush?32:16,t[22],u,r,R,s||null,null,null);return o.firstCreatePass&&(Af(Ru(u,t),o,e.type),Y_(o,u),Q_(u,t.length,1)),Xf(t,N),t[22]=N}(N,this.componentDef,Z,a,_);if(N)if(r)Sf(_,N,["ng-version",TP.full]);else{const{attrs:Ie,classes:ue}=function xN(n){const e=[],t=[];let r=1,i=2;for(;r0&&Rg(_,N,ue.join(" "))}if(oe=Tp(K,22),void 0!==t){const Ie=oe.projection=[];for(let ue=0;uea(mr(ze[r.index])):r.index;let Re=null;if(!a&&u&&(Re=function eO(n,e,t,r){const i=n.cleanup;if(null!=i)for(let s=0;su?a[u]:null}"string"==typeof o&&(s+=2)}return null}(n,e,i,r.index)),null!==Re)(Re.__ngLastListenerFn__||Re).__ngNextListenerFn__=s,Re.__ngLastListenerFn__=s,K=!1;else{s=_1(r,e,N,s,!1);const ze=t.listen(he,i,s);B.push(s,ze),R&&R.push(i,ue,Ie,Ie+1)}}else s=_1(r,e,N,s,!1);const Z=r.outputs;let J;if(K&&null!==Z&&(J=Z[i])){const oe=J.length;if(oe)for(let he=0;het()),this.destroyCbs=null}onDestroy(e){this.destroyCbs.push(e)}}class wy extends class K3{}{constructor(e){super(),this.moduleType=e}create(e){return new UD(this.moduleType,e)}}function Dy(n){return e=>{setTimeout(n,void 0,e)}}const no=class vk extends gr{constructor(e=!1){super(),this.__isAsync=e}emit(e){super.next(e)}subscribe(e,t,r){let i=e,s=t||(()=>null),o=r;if(e&&"object"==typeof e){const u=e;i=u.next?.bind(u),s=u.error?.bind(u),o=u.complete?.bind(u)}this.__isAsync&&(s=Dy(s),i&&(i=Dy(i)),o&&(o=Dy(o)));const a=super.subscribe({next:i,error:s,complete:o});return e instanceof F&&e.add(a),a}};let ro=(()=>{class n{}return n.__NG_ELEMENT_ID__=_k,n})();const bk=ro,wk=class extends bk{constructor(e,t,r){super(),this._declarationLView=e,this._declarationTContainer=t,this.elementRef=r}createEmbeddedView(e,t){const r=this._declarationTContainer.tViews,i=Qf(this._declarationLView,r,e,16,null,r.declTNode,null,null,null,null,t||null);i[17]=this._declarationLView[this._declarationTContainer.index];const o=this._declarationLView[19];return null!==o&&(i[19]=o.createEmbeddedView(r)),zg(r,i,e),new Wu(i)}};function _k(){return function fd(n,e){return 4&n.type?new wk(e,n,cc(n,e)):null}(Tr(),Ue())}let Ms=(()=>{class n{}return n.__NG_ELEMENT_ID__=Dk,n})();function Dk(){return function eS(n,e){let t;const r=e[n.index];if(ss(r))t=r;else{let i;if(8&n.type)i=mr(r);else{const s=e[11];i=s.createComment("");const o=Hi(n,e);ya(s,$f(s,o),i,function gN(n,e){return n.nextSibling(e)}(s,o),!1)}e[n.index]=t=X_(r,e,i,n),Xf(e,t)}return new XD(t,n,e)}(Tr(),Ue())}const Sk=Ms,XD=class extends Sk{constructor(e,t,r){super(),this._lContainer=e,this._hostTNode=t,this._hostLView=r}get element(){return cc(this._hostTNode,this._hostLView)}get injector(){return new Za(this._hostTNode,this._hostLView)}get parentInjector(){const e=Tf(this._hostTNode,this._hostLView);if(Vb(e)){const t=Qa(e,this._hostLView),r=Ya(e);return new Za(t[1].data[r+8],t)}return new Za(null,this._hostLView)}clear(){for(;this.length>0;)this.remove(this.length-1)}get(e){const t=JD(this._lContainer);return null!==t&&t[e]||null}get length(){return this._lContainer.length-10}createEmbeddedView(e,t,r){let i,s;"number"==typeof r?i=r:null!=r&&(i=r.index,s=r.injector);const o=e.createEmbeddedView(t||{},s);return this.insert(o,i),o}createComponent(e,t,r,i,s){const o=e&&!function Mu(n){return"function"==typeof n}(e);let a;if(o)a=t;else{const N=t||{};a=N.index,r=N.injector,i=N.projectableNodes,s=N.environmentInjector||N.ngModuleRef}const u=o?e:new qu(Pn(e)),_=r||this.parentInjector;if(!s&&null==u.ngModule){const B=(o?_:this.parentInjector).get(oc,null);B&&(s=B)}const R=u.create(_,i,void 0,s);return this.insert(R.hostView,a),R}insert(e,t){const r=e._lView,i=r[1];if(function Rx(n){return ss(n[3])}(r)){const R=this.indexOf(e);if(-1!==R)this.detach(R);else{const N=r[3],B=new XD(N,N[6],N[3]);B.detach(B.indexOf(e))}}const s=this._adjustIndex(t),o=this._lContainer;!function lN(n,e,t,r){const i=10+r,s=t.length;r>0&&(t[i-1][4]=e),r{class n{constructor(t){this.appInits=t,this.resolve=hd,this.reject=hd,this.initialized=!1,this.done=!1,this.donePromise=new Promise((r,i)=>{this.resolve=r,this.reject=i})}runInitializers(){if(this.initialized)return;const t=[],r=()=>{this.done=!0,this.resolve()};if(this.appInits)for(let i=0;i{s.subscribe({complete:a,error:u})});t.push(o)}}Promise.all(t).then(()=>{r()}).catch(i=>{this.reject(i)}),0===t.length&&r(),this.initialized=!0}}return n.\u0275fac=function(t){return new(t||n)(Rn(SS,8))},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();const ol=new sn("AppId",{providedIn:"root",factory:function CS(){return`${ky()}${ky()}${ky()}`}});function ky(){return String.fromCharCode(97+Math.floor(25*Math.random()))}const IS=new sn("Platform Initializer"),TS=new sn("Platform ID",{providedIn:"platform",factory:()=>"unknown"}),rL=new sn("appBootstrapListener"),io=new sn("LocaleId",{providedIn:"root",factory:()=>function CR(n,e=Mt.Default){return"number"!=typeof e&&(e=0|(e.optional&&8)|(e.host&&1)|(e.self&&2)|(e.skipSelf&&4)),Rn(n,e)}(io,Mt.Optional|Mt.SkipSelf)||function iL(){return typeof $localize<"u"&&$localize.locale||Ac}()}),uL=(()=>Promise.resolve(0))();function Ly(n){typeof Zone>"u"?uL.then(()=>{n&&n.apply(null,null)}):Zone.current.scheduleMicroTask("scheduleMicrotask",n)}class zr{constructor({enableLongStackTrace:e=!1,shouldCoalesceEventChangeDetection:t=!1,shouldCoalesceRunChangeDetection:r=!1}){if(this.hasPendingMacrotasks=!1,this.hasPendingMicrotasks=!1,this.isStable=!0,this.onUnstable=new no(!1),this.onMicrotaskEmpty=new no(!1),this.onStable=new no(!1),this.onError=new no(!1),typeof Zone>"u")throw new Tt(908,!1);Zone.assertZonePatched();const i=this;if(i._nesting=0,i._outer=i._inner=Zone.current,Zone.AsyncStackTaggingZoneSpec){const s=Zone.AsyncStackTaggingZoneSpec;i._inner=i._inner.fork(new s("Angular"))}Zone.TaskTrackingZoneSpec&&(i._inner=i._inner.fork(new Zone.TaskTrackingZoneSpec)),e&&Zone.longStackTraceZoneSpec&&(i._inner=i._inner.fork(Zone.longStackTraceZoneSpec)),i.shouldCoalesceEventChangeDetection=!r&&t,i.shouldCoalesceRunChangeDetection=r,i.lastRequestAnimationFrameId=-1,i.nativeRequestAnimationFrame=function lL(){let n=Fn.requestAnimationFrame,e=Fn.cancelAnimationFrame;if(typeof Zone<"u"&&n&&e){const t=n[Zone.__symbol__("OriginalDelegate")];t&&(n=t);const r=e[Zone.__symbol__("OriginalDelegate")];r&&(e=r)}return{nativeRequestAnimationFrame:n,nativeCancelAnimationFrame:e}}().nativeRequestAnimationFrame,function hL(n){const e=()=>{!function dL(n){n.isCheckStableRunning||-1!==n.lastRequestAnimationFrameId||(n.lastRequestAnimationFrameId=n.nativeRequestAnimationFrame.call(Fn,()=>{n.fakeTopEventTask||(n.fakeTopEventTask=Zone.root.scheduleEventTask("fakeTopEventTask",()=>{n.lastRequestAnimationFrameId=-1,Fy(n),n.isCheckStableRunning=!0,By(n),n.isCheckStableRunning=!1},void 0,()=>{},()=>{})),n.fakeTopEventTask.invoke()}),Fy(n))}(n)};n._inner=n._inner.fork({name:"angular",properties:{isAngularZone:!0},onInvokeTask:(t,r,i,s,o,a)=>{try{return RS(n),t.invokeTask(i,s,o,a)}finally{(n.shouldCoalesceEventChangeDetection&&"eventTask"===s.type||n.shouldCoalesceRunChangeDetection)&&e(),PS(n)}},onInvoke:(t,r,i,s,o,a,u)=>{try{return RS(n),t.invoke(i,s,o,a,u)}finally{n.shouldCoalesceRunChangeDetection&&e(),PS(n)}},onHasTask:(t,r,i,s)=>{t.hasTask(i,s),r===i&&("microTask"==s.change?(n._hasPendingMicrotasks=s.microTask,Fy(n),By(n)):"macroTask"==s.change&&(n.hasPendingMacrotasks=s.macroTask))},onHandleError:(t,r,i,s)=>(t.handleError(i,s),n.runOutsideAngular(()=>n.onError.emit(s)),!1)})}(i)}static isInAngularZone(){return typeof Zone<"u"&&!0===Zone.current.get("isAngularZone")}static assertInAngularZone(){if(!zr.isInAngularZone())throw new Tt(909,!1)}static assertNotInAngularZone(){if(zr.isInAngularZone())throw new Tt(909,!1)}run(e,t,r){return this._inner.run(e,t,r)}runTask(e,t,r,i){const s=this._inner,o=s.scheduleEventTask("NgZoneEvent: "+i,e,fL,hd,hd);try{return s.runTask(o,t,r)}finally{s.cancelTask(o)}}runGuarded(e,t,r){return this._inner.runGuarded(e,t,r)}runOutsideAngular(e){return this._outer.run(e)}}const fL={};function By(n){if(0==n._nesting&&!n.hasPendingMicrotasks&&!n.isStable)try{n._nesting++,n.onMicrotaskEmpty.emit(null)}finally{if(n._nesting--,!n.hasPendingMicrotasks)try{n.runOutsideAngular(()=>n.onStable.emit(null))}finally{n.isStable=!0}}}function Fy(n){n.hasPendingMicrotasks=!!(n._hasPendingMicrotasks||(n.shouldCoalesceEventChangeDetection||n.shouldCoalesceRunChangeDetection)&&-1!==n.lastRequestAnimationFrameId)}function RS(n){n._nesting++,n.isStable&&(n.isStable=!1,n.onUnstable.emit(null))}function PS(n){n._nesting--,By(n)}class pL{constructor(){this.hasPendingMicrotasks=!1,this.hasPendingMacrotasks=!1,this.isStable=!0,this.onUnstable=new no,this.onMicrotaskEmpty=new no,this.onStable=new no,this.onError=new no}run(e,t,r){return e.apply(t,r)}runGuarded(e,t,r){return e.apply(t,r)}runOutsideAngular(e){return e()}runTask(e,t,r,i){return e.apply(t,r)}}const NS=new sn(""),gd=new sn("");let Hy,Uy=(()=>{class n{constructor(t,r,i){this._ngZone=t,this.registry=r,this._pendingCount=0,this._isZoneStable=!0,this._didWork=!1,this._callbacks=[],this.taskTrackingZone=null,Hy||(function gL(n){Hy=n}(i),i.addToWindow(r)),this._watchAngularEvents(),t.run(()=>{this.taskTrackingZone=typeof Zone>"u"?null:Zone.current.get("TaskTrackingZone")})}_watchAngularEvents(){this._ngZone.onUnstable.subscribe({next:()=>{this._didWork=!0,this._isZoneStable=!1}}),this._ngZone.runOutsideAngular(()=>{this._ngZone.onStable.subscribe({next:()=>{zr.assertNotInAngularZone(),Ly(()=>{this._isZoneStable=!0,this._runCallbacksIfReady()})}})})}increasePendingRequestCount(){return this._pendingCount+=1,this._didWork=!0,this._pendingCount}decreasePendingRequestCount(){if(this._pendingCount-=1,this._pendingCount<0)throw new Error("pending async requests below zero");return this._runCallbacksIfReady(),this._pendingCount}isStable(){return this._isZoneStable&&0===this._pendingCount&&!this._ngZone.hasPendingMacrotasks}_runCallbacksIfReady(){if(this.isStable())Ly(()=>{for(;0!==this._callbacks.length;){let t=this._callbacks.pop();clearTimeout(t.timeoutId),t.doneCb(this._didWork)}this._didWork=!1});else{let t=this.getPendingTasks();this._callbacks=this._callbacks.filter(r=>!r.updateCb||!r.updateCb(t)||(clearTimeout(r.timeoutId),!1)),this._didWork=!0}}getPendingTasks(){return this.taskTrackingZone?this.taskTrackingZone.macroTasks.map(t=>({source:t.source,creationLocation:t.creationLocation,data:t.data})):[]}addCallback(t,r,i){let s=-1;r&&r>0&&(s=setTimeout(()=>{this._callbacks=this._callbacks.filter(o=>o.timeoutId!==s),t(this._didWork,this.getPendingTasks())},r)),this._callbacks.push({doneCb:t,timeoutId:s,updateCb:i})}whenStable(t,r,i){if(i&&!this.taskTrackingZone)throw new Error('Task tracking zone is required when passing an update callback to whenStable(). Is "zone.js/plugins/task-tracking" loaded?');this.addCallback(t,r,i),this._runCallbacksIfReady()}getPendingRequestCount(){return this._pendingCount}registerApplication(t){this.registry.registerApplication(t,this)}unregisterApplication(t){this.registry.unregisterApplication(t)}findProviders(t,r,i){return[]}}return n.\u0275fac=function(t){return new(t||n)(Rn(zr),Rn(Vy),Rn(gd))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})(),Vy=(()=>{class n{constructor(){this._applications=new Map}registerApplication(t,r){this._applications.set(t,r)}unregisterApplication(t){this._applications.delete(t)}unregisterAllApplications(){this._applications.clear()}getTestability(t){return this._applications.get(t)||null}getAllTestabilities(){return Array.from(this._applications.values())}getAllRootElements(){return Array.from(this._applications.keys())}findTestabilityInTree(t,r=!0){return Hy?.findTestabilityInTree(this,t,r)??null}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})(),Oo=null;const MS=new sn("AllowMultipleToken"),Ky=new sn("PlatformDestroyListeners");function kS(n,e,t=[]){const r=`Platform: ${e}`,i=new sn(r);return(s=[])=>{let o=$y();if(!o||o.injector.get(MS,!1)){const a=[...t,...s,{provide:i,useValue:!0}];n?n(a):function vL(n){if(Oo&&!Oo.get(MS,!1))throw new Tt(400,!1);Oo=n;const e=n.get(BS);(function OS(n){const e=n.get(IS,null);e&&e.forEach(t=>t())})(n)}(function LS(n=[],e){return ma.create({name:e,providers:[{provide:sg,useValue:"platform"},{provide:Ky,useValue:new Set([()=>Oo=null])},...n]})}(a,r))}return function bL(n){const e=$y();if(!e)throw new Tt(401,!1);return e}()}}function $y(){return Oo?.get(BS)??null}let BS=(()=>{class n{constructor(t){this._injector=t,this._modules=[],this._destroyListeners=[],this._destroyed=!1}bootstrapModuleFactory(t,r){const i=function US(n,e){let t;return t="noop"===n?new pL:("zone.js"===n?void 0:n)||new zr(e),t}(r?.ngZone,function FS(n){return{enableLongStackTrace:!1,shouldCoalesceEventChangeDetection:!(!n||!n.ngZoneEventCoalescing)||!1,shouldCoalesceRunChangeDetection:!(!n||!n.ngZoneRunCoalescing)||!1}}(r)),s=[{provide:zr,useValue:i}];return i.run(()=>{const o=ma.create({providers:s,parent:this.injector,name:t.moduleType.name}),a=t.create(o),u=a.injector.get(lc,null);if(!u)throw new Tt(402,!1);return i.runOutsideAngular(()=>{const _=i.onError.subscribe({next:R=>{u.handleError(R)}});a.onDestroy(()=>{yd(this._modules,a),_.unsubscribe()})}),function VS(n,e,t){try{const r=t();return uy(r)?r.catch(i=>{throw e.runOutsideAngular(()=>n.handleError(i)),i}):r}catch(r){throw e.runOutsideAngular(()=>n.handleError(r)),r}}(u,i,()=>{const _=a.injector.get(pd);return _.runInitializers(),_.donePromise.then(()=>(function pD(n){Ci(n,"Expected localeId to be defined"),"string"==typeof n&&(hD=n.toLowerCase().replace(/_/g,"-"))}(a.injector.get(io,Ac)||Ac),this._moduleDoBootstrap(a),a))})})}bootstrapModule(t,r=[]){const i=HS({},r);return function yL(n,e,t){const r=new wy(t);return Promise.resolve(r)}(0,0,t).then(s=>this.bootstrapModuleFactory(s,i))}_moduleDoBootstrap(t){const r=t.injector.get(jy);if(t._bootstrapComponents.length>0)t._bootstrapComponents.forEach(i=>r.bootstrap(i));else{if(!t.instance.ngDoBootstrap)throw new Tt(403,!1);t.instance.ngDoBootstrap(r)}this._modules.push(t)}onDestroy(t){this._destroyListeners.push(t)}get injector(){return this._injector}destroy(){if(this._destroyed)throw new Tt(404,!1);this._modules.slice().forEach(r=>r.destroy()),this._destroyListeners.forEach(r=>r());const t=this._injector.get(Ky,null);t&&(t.forEach(r=>r()),t.clear()),this._destroyed=!0}get destroyed(){return this._destroyed}}return n.\u0275fac=function(t){return new(t||n)(Rn(ma))},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"platform"}),n})();function HS(n,e){return Array.isArray(e)?e.reduce(HS,n):{...n,...e}}let jy=(()=>{class n{constructor(t,r,i){this._zone=t,this._injector=r,this._exceptionHandler=i,this._bootstrapListeners=[],this._views=[],this._runningTick=!1,this._stable=!0,this._destroyed=!1,this._destroyListeners=[],this.componentTypes=[],this.components=[],this._onMicrotaskEmptySubscription=this._zone.onMicrotaskEmpty.subscribe({next:()=>{this._zone.run(()=>{this.tick()})}});const s=new Xe(a=>{this._stable=this._zone.isStable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks,this._zone.runOutsideAngular(()=>{a.next(this._stable),a.complete()})}),o=new Xe(a=>{let u;this._zone.runOutsideAngular(()=>{u=this._zone.onStable.subscribe(()=>{zr.assertNotInAngularZone(),Ly(()=>{!this._stable&&!this._zone.hasPendingMacrotasks&&!this._zone.hasPendingMicrotasks&&(this._stable=!0,a.next(!0))})})});const _=this._zone.onUnstable.subscribe(()=>{zr.assertInAngularZone(),this._stable&&(this._stable=!1,this._zone.runOutsideAngular(()=>{a.next(!1)}))});return()=>{u.unsubscribe(),_.unsubscribe()}});this.isStable=ei(s,o.pipe(function ns(n={}){const{connector:e=(()=>new gr),resetOnError:t=!0,resetOnComplete:r=!0,resetOnRefCountZero:i=!0}=n;return s=>{let o,a,u,_=0,R=!1,N=!1;const B=()=>{a?.unsubscribe(),a=void 0},K=()=>{B(),o=u=void 0,R=N=!1},Z=()=>{const J=o;K(),J?.unsubscribe()};return fe((J,oe)=>{_++,!N&&!R&&B();const he=u=u??e();oe.add(()=>{_--,0===_&&!N&&!R&&(a=Io(Z,i))}),he.subscribe(oe),!o&&_>0&&(o=new be({next:Ie=>he.next(Ie),error:Ie=>{N=!0,B(),a=Io(K,t,Ie),he.error(Ie)},complete:()=>{R=!0,B(),a=Io(K,r),he.complete()}}),gn(J).subscribe(o))})(s)}}()))}get destroyed(){return this._destroyed}get injector(){return this._injector}bootstrap(t,r){const i=t instanceof Mw;if(!this._injector.get(pd).done)throw!i&&function _u(n){const e=Pn(n)||ni(n)||ri(n);return null!==e&&e.standalone}(t),new Tt(405,false);let o;o=i?t:this._injector.get(Kf).resolveComponentFactory(t),this.componentTypes.push(o.componentType);const a=function mL(n){return n.isBoundToModule}(o)?void 0:this._injector.get(xc),_=o.create(ma.NULL,[],r||o.selector,a),R=_.location.nativeElement,N=_.injector.get(NS,null);return N?.registerApplication(R),_.onDestroy(()=>{this.detachView(_.hostView),yd(this.components,_),N?.unregisterApplication(R)}),this._loadComponent(_),_}tick(){if(this._runningTick)throw new Tt(101,!1);try{this._runningTick=!0;for(let t of this._views)t.detectChanges()}catch(t){this._zone.runOutsideAngular(()=>this._exceptionHandler.handleError(t))}finally{this._runningTick=!1}}attachView(t){const r=t;this._views.push(r),r.attachToAppRef(this)}detachView(t){const r=t;yd(this._views,r),r.detachFromAppRef()}_loadComponent(t){this.attachView(t.hostView),this.tick(),this.components.push(t),this._injector.get(rL,[]).concat(this._bootstrapListeners).forEach(i=>i(t))}ngOnDestroy(){if(!this._destroyed)try{this._destroyListeners.forEach(t=>t()),this._views.slice().forEach(t=>t.destroy()),this._onMicrotaskEmptySubscription.unsubscribe()}finally{this._destroyed=!0,this._views=[],this._bootstrapListeners=[],this._destroyListeners=[]}}onDestroy(t){return this._destroyListeners.push(t),()=>yd(this._destroyListeners,t)}destroy(){if(this._destroyed)throw new Tt(406,!1);const t=this._injector;t.destroy&&!t.destroyed&&t.destroy()}get viewCount(){return this._views.length}warnIfDestroyed(){}}return n.\u0275fac=function(t){return new(t||n)(Rn(zr),Rn(oc),Rn(lc))},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function yd(n,e){const t=n.indexOf(e);t>-1&&n.splice(t,1)}let $S=!0;class qS{constructor(){}supports(e){return Yu(e)}create(e){return new PL(e)}}const RL=(n,e)=>e;class PL{constructor(e){this.length=0,this._linkedRecords=null,this._unlinkedRecords=null,this._previousItHead=null,this._itHead=null,this._itTail=null,this._additionsHead=null,this._additionsTail=null,this._movesHead=null,this._movesTail=null,this._removalsHead=null,this._removalsTail=null,this._identityChangesHead=null,this._identityChangesTail=null,this._trackByFn=e||RL}forEachItem(e){let t;for(t=this._itHead;null!==t;t=t._next)e(t)}forEachOperation(e){let t=this._itHead,r=this._removalsHead,i=0,s=null;for(;t||r;){const o=!r||t&&t.currentIndex{o=this._trackByFn(i,a),null!==t&&Object.is(t.trackById,o)?(r&&(t=this._verifyReinsertion(t,a,o,i)),Object.is(t.item,a)||this._addIdentityChange(t,a)):(t=this._mismatch(t,a,o,i),r=!0),t=t._next,i++}),this.length=i;return this._truncate(t),this.collection=e,this.isDirty}get isDirty(){return null!==this._additionsHead||null!==this._movesHead||null!==this._removalsHead||null!==this._identityChangesHead}_reset(){if(this.isDirty){let e;for(e=this._previousItHead=this._itHead;null!==e;e=e._next)e._nextPrevious=e._next;for(e=this._additionsHead;null!==e;e=e._nextAdded)e.previousIndex=e.currentIndex;for(this._additionsHead=this._additionsTail=null,e=this._movesHead;null!==e;e=e._nextMoved)e.previousIndex=e.currentIndex;this._movesHead=this._movesTail=null,this._removalsHead=this._removalsTail=null,this._identityChangesHead=this._identityChangesTail=null}}_mismatch(e,t,r,i){let s;return null===e?s=this._itTail:(s=e._prev,this._remove(e)),null!==(e=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._reinsertAfter(e,s,i)):null!==(e=null===this._linkedRecords?null:this._linkedRecords.get(r,i))?(Object.is(e.item,t)||this._addIdentityChange(e,t),this._moveAfter(e,s,i)):e=this._addAfter(new NL(t,r),s,i),e}_verifyReinsertion(e,t,r,i){let s=null===this._unlinkedRecords?null:this._unlinkedRecords.get(r,null);return null!==s?e=this._reinsertAfter(s,e._prev,i):e.currentIndex!=i&&(e.currentIndex=i,this._addToMoves(e,i)),e}_truncate(e){for(;null!==e;){const t=e._next;this._addToRemovals(this._unlink(e)),e=t}null!==this._unlinkedRecords&&this._unlinkedRecords.clear(),null!==this._additionsTail&&(this._additionsTail._nextAdded=null),null!==this._movesTail&&(this._movesTail._nextMoved=null),null!==this._itTail&&(this._itTail._next=null),null!==this._removalsTail&&(this._removalsTail._nextRemoved=null),null!==this._identityChangesTail&&(this._identityChangesTail._nextIdentityChange=null)}_reinsertAfter(e,t,r){null!==this._unlinkedRecords&&this._unlinkedRecords.remove(e);const i=e._prevRemoved,s=e._nextRemoved;return null===i?this._removalsHead=s:i._nextRemoved=s,null===s?this._removalsTail=i:s._prevRemoved=i,this._insertAfter(e,t,r),this._addToMoves(e,r),e}_moveAfter(e,t,r){return this._unlink(e),this._insertAfter(e,t,r),this._addToMoves(e,r),e}_addAfter(e,t,r){return this._insertAfter(e,t,r),this._additionsTail=null===this._additionsTail?this._additionsHead=e:this._additionsTail._nextAdded=e,e}_insertAfter(e,t,r){const i=null===t?this._itHead:t._next;return e._next=i,e._prev=t,null===i?this._itTail=e:i._prev=e,null===t?this._itHead=e:t._next=e,null===this._linkedRecords&&(this._linkedRecords=new YS),this._linkedRecords.put(e),e.currentIndex=r,e}_remove(e){return this._addToRemovals(this._unlink(e))}_unlink(e){null!==this._linkedRecords&&this._linkedRecords.remove(e);const t=e._prev,r=e._next;return null===t?this._itHead=r:t._next=r,null===r?this._itTail=t:r._prev=t,e}_addToMoves(e,t){return e.previousIndex===t||(this._movesTail=null===this._movesTail?this._movesHead=e:this._movesTail._nextMoved=e),e}_addToRemovals(e){return null===this._unlinkedRecords&&(this._unlinkedRecords=new YS),this._unlinkedRecords.put(e),e.currentIndex=null,e._nextRemoved=null,null===this._removalsTail?(this._removalsTail=this._removalsHead=e,e._prevRemoved=null):(e._prevRemoved=this._removalsTail,this._removalsTail=this._removalsTail._nextRemoved=e),e}_addIdentityChange(e,t){return e.item=t,this._identityChangesTail=null===this._identityChangesTail?this._identityChangesHead=e:this._identityChangesTail._nextIdentityChange=e,e}}class NL{constructor(e,t){this.item=e,this.trackById=t,this.currentIndex=null,this.previousIndex=null,this._nextPrevious=null,this._prev=null,this._next=null,this._prevDup=null,this._nextDup=null,this._prevRemoved=null,this._nextRemoved=null,this._nextAdded=null,this._nextMoved=null,this._nextIdentityChange=null}}class ML{constructor(){this._head=null,this._tail=null}add(e){null===this._head?(this._head=this._tail=e,e._nextDup=null,e._prevDup=null):(this._tail._nextDup=e,e._prevDup=this._tail,e._nextDup=null,this._tail=e)}get(e,t){let r;for(r=this._head;null!==r;r=r._nextDup)if((null===t||t<=r.currentIndex)&&Object.is(r.trackById,e))return r;return null}remove(e){const t=e._prevDup,r=e._nextDup;return null===t?this._head=r:t._nextDup=r,null===r?this._tail=t:r._prevDup=t,null===this._head}}class YS{constructor(){this.map=new Map}put(e){const t=e.trackById;let r=this.map.get(t);r||(r=new ML,this.map.set(t,r)),r.add(e)}get(e,t){const i=this.map.get(e);return i?i.get(e,t):null}remove(e){const t=e.trackById;return this.map.get(t).remove(e)&&this.map.delete(t),e}get isEmpty(){return 0===this.map.size}clear(){this.map.clear()}}function QS(n,e,t){const r=n.previousIndex;if(null===r)return r;let i=0;return t&&r{class n{constructor(t){this.factories=t}static create(t,r){if(null!=r){const i=r.factories.slice();t=t.concat(i)}return new n(t)}static extend(t){return{provide:n,useFactory:r=>n.create(t,r||XS()),deps:[[n,new Of,new Mf]]}}find(t){const r=this.factories.find(i=>i.supports(t));if(null!=r)return r;throw new Tt(901,!1)}}return n.\u0275prov=zn({token:n,providedIn:"root",factory:XS}),n})();const FL=kS(null,"core",[]);let UL=(()=>{class n{constructor(t){}}return n.\u0275fac=function(t){return new(t||n)(Rn(jy))},n.\u0275mod=wu({type:n}),n.\u0275inj=Ka({}),n})(),bd=null;function cl(){return bd}const oo=new sn("DocumentToken");class R8{constructor(e,t,r,i){this.$implicit=e,this.ngForOf=t,this.index=r,this.count=i}get first(){return 0===this.index}get last(){return this.index===this.count-1}get even(){return this.index%2==0}get odd(){return!this.even}}let fC=(()=>{class n{constructor(t,r,i){this._viewContainer=t,this._template=r,this._differs=i,this._ngForOf=null,this._ngForOfDirty=!0,this._differ=null}set ngForOf(t){this._ngForOf=t,this._ngForOfDirty=!0}set ngForTrackBy(t){this._trackByFn=t}get ngForTrackBy(){return this._trackByFn}set ngForTemplate(t){t&&(this._template=t)}ngDoCheck(){if(this._ngForOfDirty){this._ngForOfDirty=!1;const t=this._ngForOf;!this._differ&&t&&(this._differ=this._differs.find(t).create(this.ngForTrackBy))}if(this._differ){const t=this._differ.diff(this._ngForOf);t&&this._applyChanges(t)}}_applyChanges(t){const r=this._viewContainer;t.forEachOperation((i,s,o)=>{if(null==i.previousIndex)r.createEmbeddedView(this._template,new R8(i.item,this._ngForOf,-1,-1),null===o?void 0:o);else if(null==o)r.remove(null===s?void 0:s);else if(null!==s){const a=r.get(s);r.move(a,o),dC(a,i)}});for(let i=0,s=r.length;i{dC(r.get(i.currentIndex),i)})}static ngTemplateContextGuard(t,r){return!0}}return n.\u0275fac=function(t){return new(t||n)(Zt(Ms),Zt(ro),Zt(Ed))},n.\u0275dir=Fi({type:n,selectors:[["","ngFor","","ngForOf",""]],inputs:{ngForOf:"ngForOf",ngForTrackBy:"ngForTrackBy",ngForTemplate:"ngForTemplate"},standalone:!0}),n})();function dC(n,e){n.context.$implicit=e.item}let o4=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=wu({type:n}),n.\u0275inj=Ka({}),n})();class f0 extends class R4 extends class KL{}{constructor(){super(...arguments),this.supportsDOMEvents=!0}}{static makeCurrent(){!function HL(n){bd||(bd=n)}(new f0)}onAndCancel(e,t,r){return e.addEventListener(t,r,!1),()=>{e.removeEventListener(t,r,!1)}}dispatchEvent(e,t){e.dispatchEvent(t)}remove(e){e.parentNode&&e.parentNode.removeChild(e)}createElement(e,t){return(t=t||this.getDefaultDocument()).createElement(e)}createHtmlDocument(){return document.implementation.createHTMLDocument("fakeTitle")}getDefaultDocument(){return document}isElementNode(e){return e.nodeType===Node.ELEMENT_NODE}isShadowRoot(e){return e instanceof DocumentFragment}getGlobalEventTarget(e,t){return"window"===t?window:"document"===t?e:"body"===t?e.body:null}getBaseHref(e){const t=function P4(){return dl=dl||document.querySelector("base"),dl?dl.getAttribute("href"):null}();return null==t?null:function N4(n){Pd=Pd||document.createElement("a"),Pd.setAttribute("href",n);const e=Pd.pathname;return"/"===e.charAt(0)?e:`/${e}`}(t)}resetBaseElement(){dl=null}getUserAgent(){return window.navigator.userAgent}getCookie(e){return function T8(n,e){e=encodeURIComponent(e);for(const t of n.split(";")){const r=t.indexOf("="),[i,s]=-1==r?[t,""]:[t.slice(0,r),t.slice(r+1)];if(i.trim()===e)return decodeURIComponent(s)}return null}(document.cookie,e)}}let Pd,dl=null;const wC=new sn("TRANSITION_ID"),O4=[{provide:SS,useFactory:function M4(n,e,t){return()=>{t.get(pd).donePromise.then(()=>{const r=cl(),i=e.querySelectorAll(`style[ng-transition="${n}"]`);for(let s=0;s{class n{build(){return new XMLHttpRequest}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();const Nd=new sn("EventManagerPlugins");let Md=(()=>{class n{constructor(t,r){this._zone=r,this._eventNameToPlugin=new Map,t.forEach(i=>i.manager=this),this._plugins=t.slice().reverse()}addEventListener(t,r,i){return this._findPluginFor(r).addEventListener(t,r,i)}addGlobalEventListener(t,r,i){return this._findPluginFor(r).addGlobalEventListener(t,r,i)}getZone(){return this._zone}_findPluginFor(t){const r=this._eventNameToPlugin.get(t);if(r)return r;const i=this._plugins;for(let s=0;s{class n{constructor(){this._stylesSet=new Set}addStyles(t){const r=new Set;t.forEach(i=>{this._stylesSet.has(i)||(this._stylesSet.add(i),r.add(i))}),this.onStylesAdded(r)}onStylesAdded(t){}getAllStyles(){return Array.from(this._stylesSet)}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})(),hl=(()=>{class n extends DC{constructor(t){super(),this._doc=t,this._hostNodes=new Map,this._hostNodes.set(t.head,[])}_addStylesToHost(t,r,i){t.forEach(s=>{const o=this._doc.createElement("style");o.textContent=s,i.push(r.appendChild(o))})}addHost(t){const r=[];this._addStylesToHost(this._stylesSet,t,r),this._hostNodes.set(t,r)}removeHost(t){const r=this._hostNodes.get(t);r&&r.forEach(SC),this._hostNodes.delete(t)}onStylesAdded(t){this._hostNodes.forEach((r,i)=>{this._addStylesToHost(t,i,r)})}ngOnDestroy(){this._hostNodes.forEach(t=>t.forEach(SC))}}return n.\u0275fac=function(t){return new(t||n)(Rn(oo))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();function SC(n){cl().remove(n)}const d0={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",math:"http://www.w3.org/1998/MathML/"},h0=/%COMP%/g;function Od(n,e,t){for(let r=0;r{if("__ngUnwrap__"===e)return n;!1===n(e)&&(e.preventDefault(),e.returnValue=!1)}}let p0=(()=>{class n{constructor(t,r,i){this.eventManager=t,this.sharedStylesHost=r,this.appId=i,this.rendererByCompId=new Map,this.defaultRenderer=new g0(t)}createRenderer(t,r){if(!t||!r)return this.defaultRenderer;switch(r.encapsulation){case Is.Emulated:{let i=this.rendererByCompId.get(r.id);return i||(i=new K4(this.eventManager,this.sharedStylesHost,r,this.appId),this.rendererByCompId.set(r.id,i)),i.applyToHost(t),i}case 1:case Is.ShadowDom:return new $4(this.eventManager,this.sharedStylesHost,t,r);default:if(!this.rendererByCompId.has(r.id)){const i=Od(r.id,r.styles,[]);this.sharedStylesHost.addStyles(i),this.rendererByCompId.set(r.id,this.defaultRenderer)}return this.defaultRenderer}}begin(){}end(){}}return n.\u0275fac=function(t){return new(t||n)(Rn(Md),Rn(hl),Rn(ol))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();class g0{constructor(e){this.eventManager=e,this.data=Object.create(null),this.destroyNode=null}destroy(){}createElement(e,t){return t?document.createElementNS(d0[t]||t,e):document.createElement(e)}createComment(e){return document.createComment(e)}createText(e){return document.createTextNode(e)}appendChild(e,t){(xC(e)?e.content:e).appendChild(t)}insertBefore(e,t,r){e&&(xC(e)?e.content:e).insertBefore(t,r)}removeChild(e,t){e&&e.removeChild(t)}selectRootElement(e,t){let r="string"==typeof e?document.querySelector(e):e;if(!r)throw new Error(`The selector "${e}" did not match any elements`);return t||(r.textContent=""),r}parentNode(e){return e.parentNode}nextSibling(e){return e.nextSibling}setAttribute(e,t,r,i){if(i){t=i+":"+t;const s=d0[i];s?e.setAttributeNS(s,t,r):e.setAttribute(t,r)}else e.setAttribute(t,r)}removeAttribute(e,t,r){if(r){const i=d0[r];i?e.removeAttributeNS(i,t):e.removeAttribute(`${r}:${t}`)}else e.removeAttribute(t)}addClass(e,t){e.classList.add(t)}removeClass(e,t){e.classList.remove(t)}setStyle(e,t,r,i){i&(gi.DashCase|gi.Important)?e.style.setProperty(t,r,i&gi.Important?"important":""):e.style[t]=r}removeStyle(e,t,r){r&gi.DashCase?e.style.removeProperty(t):e.style[t]=""}setProperty(e,t,r){e[t]=r}setValue(e,t){e.nodeValue=t}listen(e,t,r){return"string"==typeof e?this.eventManager.addGlobalEventListener(e,t,TC(r)):this.eventManager.addEventListener(e,t,TC(r))}}function xC(n){return"TEMPLATE"===n.tagName&&void 0!==n.content}class K4 extends g0{constructor(e,t,r,i){super(e),this.component=r;const s=Od(i+"-"+r.id,r.styles,[]);t.addStyles(s),this.contentAttr=function U4(n){return"_ngcontent-%COMP%".replace(h0,n)}(i+"-"+r.id),this.hostAttr=function V4(n){return"_nghost-%COMP%".replace(h0,n)}(i+"-"+r.id)}applyToHost(e){super.setAttribute(e,this.hostAttr,"")}createElement(e,t){const r=super.createElement(e,t);return super.setAttribute(r,this.contentAttr,""),r}}class $4 extends g0{constructor(e,t,r,i){super(e),this.sharedStylesHost=t,this.hostEl=r,this.shadowRoot=r.attachShadow({mode:"open"}),this.sharedStylesHost.addHost(this.shadowRoot);const s=Od(i.id,i.styles,[]);for(let o=0;o{class n extends _C{constructor(t){super(t)}supports(t){return!0}addEventListener(t,r,i){return t.addEventListener(r,i,!1),()=>this.removeEventListener(t,r,i)}removeEventListener(t,r,i){return t.removeEventListener(r,i)}}return n.\u0275fac=function(t){return new(t||n)(Rn(oo))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();const RC=["alt","control","meta","shift"],G4={"\b":"Backspace","\t":"Tab","\x7f":"Delete","\x1b":"Escape",Del:"Delete",Esc:"Escape",Left:"ArrowLeft",Right:"ArrowRight",Up:"ArrowUp",Down:"ArrowDown",Menu:"ContextMenu",Scroll:"ScrollLock",Win:"OS"},z4={alt:n=>n.altKey,control:n=>n.ctrlKey,meta:n=>n.metaKey,shift:n=>n.shiftKey};let W4=(()=>{class n extends _C{constructor(t){super(t)}supports(t){return null!=n.parseEventName(t)}addEventListener(t,r,i){const s=n.parseEventName(r),o=n.eventCallback(s.fullKey,i,this.manager.getZone());return this.manager.getZone().runOutsideAngular(()=>cl().onAndCancel(t,s.domEventName,o))}static parseEventName(t){const r=t.toLowerCase().split("."),i=r.shift();if(0===r.length||"keydown"!==i&&"keyup"!==i)return null;const s=n._normalizeKey(r.pop());let o="",a=r.indexOf("code");if(a>-1&&(r.splice(a,1),o="code."),RC.forEach(_=>{const R=r.indexOf(_);R>-1&&(r.splice(R,1),o+=_+".")}),o+=s,0!=r.length||0===s.length)return null;const u={};return u.domEventName=i,u.fullKey=o,u}static matchEventFullKeyCode(t,r){let i=G4[t.key]||t.key,s="";return r.indexOf("code.")>-1&&(i=t.code,s="code."),!(null==i||!i)&&(i=i.toLowerCase()," "===i?i="space":"."===i&&(i="dot"),RC.forEach(o=>{o!==i&&(0,z4[o])(t)&&(s+=o+".")}),s+=i,s===r)}static eventCallback(t,r,i){return s=>{n.matchEventFullKeyCode(s,t)&&i.runGuarded(()=>r(s))}}static _normalizeKey(t){return"esc"===t?"escape":t}}return n.\u0275fac=function(t){return new(t||n)(Rn(oo))},n.\u0275prov=zn({token:n,factory:n.\u0275fac}),n})();const NC=[{provide:TS,useValue:"browser"},{provide:IS,useValue:function q4(){f0.makeCurrent()},multi:!0},{provide:oo,useFactory:function Q4(){return function FR(n){Qp=n}(document),document},deps:[]}],Z4=kS(FL,"browser",NC),MC=new sn(""),OC=[{provide:gd,useClass:class k4{addToWindow(e){Fn.getAngularTestability=(r,i=!0)=>{const s=e.findTestabilityInTree(r,i);if(null==s)throw new Error("Could not find testability for element.");return s},Fn.getAllAngularTestabilities=()=>e.getAllTestabilities(),Fn.getAllAngularRootElements=()=>e.getAllRootElements(),Fn.frameworkStabilizers||(Fn.frameworkStabilizers=[]),Fn.frameworkStabilizers.push(r=>{const i=Fn.getAllAngularTestabilities();let s=i.length,o=!1;const a=function(u){o=o||u,s--,0==s&&r(o)};i.forEach(function(u){u.whenStable(a)})})}findTestabilityInTree(e,t,r){return null==t?null:e.getTestability(t)??(r?cl().isShadowRoot(t)?this.findTestabilityInTree(e,t.host,!0):this.findTestabilityInTree(e,t.parentElement,!0):null)}},deps:[]},{provide:NS,useClass:Uy,deps:[zr,Vy,gd]},{provide:Uy,useClass:Uy,deps:[zr,Vy,gd]}],kC=[{provide:sg,useValue:"root"},{provide:lc,useFactory:function Y4(){return new lc},deps:[]},{provide:Nd,useClass:j4,multi:!0,deps:[oo,zr,TS]},{provide:Nd,useClass:W4,multi:!0,deps:[oo]},{provide:p0,useClass:p0,deps:[Md,hl,ol]},{provide:kw,useExisting:p0},{provide:DC,useExisting:hl},{provide:hl,useClass:hl,deps:[oo]},{provide:Md,useClass:Md,deps:[Nd,zr]},{provide:class f4{},useClass:L4,deps:[]},[]];let X4=(()=>{class n{constructor(t){}static withServerTransition(t){return{ngModule:n,providers:[{provide:ol,useValue:t.appId},{provide:wC,useExisting:ol},O4]}}}return n.\u0275fac=function(t){return new(t||n)(Rn(MC,12))},n.\u0275mod=wu({type:n}),n.\u0275inj=Ka({providers:[...kC,...OC],imports:[o4,UL]}),n})();typeof window<"u"&&window;class cB extends gr{constructor(e){super(),this._value=e}get value(){return this.getValue()}_subscribe(e){const t=super._subscribe(e);return!t.closed&&e.next(this._value),t}getValue(){const{hasError:e,thrownError:t,_value:r}=this;if(e)throw t;return this._throwIfClosed(),r}next(e){super.next(this._value=e)}}function FC(n,e,t,r,i,s,o){try{var a=n[s](o),u=a.value}catch(_){return void t(_)}a.done?e(u):Promise.resolve(u).then(r,i)}function j(n){return function(){var e=this,t=arguments;return new Promise(function(r,i){var s=n.apply(e,t);function o(u){FC(s,r,i,o,a,"next",u)}function a(u){FC(s,r,i,o,a,"throw",u)}o(void 0)})}}var uB=x(5705),v0=x(5006),UC=x(893),VC=x(5876);const lB={hashSHA256:n=>(0,UC.vp)(n),getHKDF(n,e){const i=new uB.t(UC.mE,e,n).expand(96);return[i.subarray(0,32),i.subarray(32,64),i.subarray(64,96)]},generateX25519KeyPair(){const n=v0.Au();return{publicKey:n.publicKey,privateKey:n.secretKey}},generateX25519KeyPairFromSeed(n){const e=v0._w(n);return{publicKey:e.publicKey,privateKey:e.secretKey}},generateX25519SharedKey:(n,e)=>v0.gi(n,e),chaCha20Poly1305Encrypt:(n,e,t,r)=>new VC.OK(r).seal(e,n,t),chaCha20Poly1305Decrypt:(n,e,t,r)=>new VC.OK(r).open(e,n,t)};function HC(n){this.wrapped=n}function pl(n){var e,t;function i(o,a){try{var u=n[o](a),_=u.value,R=_ instanceof HC;Promise.resolve(R?_.wrapped:_).then(function(N){R?i("return"===o?"return":"next",N):s(u.done?"return":"normal",N)},function(N){i("throw",N)})}catch(N){s("throw",N)}}function s(o,a){switch(o){case"return":e.resolve({value:a,done:!0});break;case"throw":e.reject(a);break;default:e.resolve({value:a,done:!1})}(e=e.next)?i(e.key,e.arg):t=null}this._invoke=function r(o,a){return new Promise(function(u,_){var R={key:o,arg:a,resolve:u,reject:_,next:null};t?t=t.next=R:(e=t=R,i(o,a))})},"function"!=typeof n.return&&(this.return=void 0)}function dn(n){return function(){return new pl(n.apply(this,arguments))}}function lt(n){return new HC(n)}function Pt(n){var e,t,r,i=2;for(typeof Symbol<"u"&&(t=Symbol.asyncIterator,r=Symbol.iterator);i--;){if(t&&null!=(e=n[t]))return e.call(n);if(r&&null!=(e=n[r]))return new kd(e.call(n));t="@@asyncIterator",r="@@iterator"}throw new TypeError("Object is not async iterable")}function kd(n){function e(t){if(Object(t)!==t)return Promise.reject(new TypeError(t+" is not an object."));var r=t.done;return Promise.resolve(t.value).then(function(i){return{value:i,done:r}})}return(kd=function(r){this.s=r,this.n=r.next}).prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var i=this.s.return;return void 0===i?Promise.resolve({value:r,done:!0}):e(i.apply(this.s,arguments))},throw:function(r){var i=this.s.return;return void 0===i?Promise.reject(r):e(i.apply(this.s,arguments))}},new kd(n)}function Mr(n,e){var t={},r=!1;function i(s,o){return r=!0,o=new Promise(function(a){a(n[s](o))}),{done:!1,value:e(o)}}return t[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},t.next=function(s){return r?(r=!1,s):i("next",s)},"function"==typeof n.throw&&(t.throw=function(s){if(r)throw r=!1,s;return i("throw",s)}),"function"==typeof n.return&&(t.return=function(s){return r?(r=!1,s):i("return",s)}),t}function Lo(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.alloc?globalThis.Buffer.alloc(n):new Uint8Array(n)}function Nc(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}function wr(n,e){e||(e=n.reduce((i,s)=>i+s.length,0));const t=Nc(e);let r=0;for(const i of n)t.set(i,r),r+=i.length;return t}function kr(n,e){if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(const r of e)if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.push(r);else{if(!E0(r))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.push(...r.bufs)}this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(const r of e.reverse())if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.unshift(r);else{if(!E0(r))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.unshift(...r.bufs)}this.length+=t}get(e){const t=$C(this.bufs,e);return t.buf[t.index]}set(e,t){const r=$C(this.bufs,e);r.buf[r.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let r=0;r0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}slice(e,t){const{bufs:r,length:i}=this._subList(e,t);return wr(r,i)}subarray(e,t){const{bufs:r,length:i}=this._subList(e,t);return 1===r.length?r[0]:wr(r,i)}sublist(e,t){const{bufs:r,length:i}=this._subList(e,t),s=new qr;return s.length=i,s.bufs=r,s}_subList(e,t){if((e=e??0)<0&&(e=this.length+e),(t=t??this.length)<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:[...this.bufs],length:this.length};const r=[];let i=0;for(let s=0;s=u)continue;const _=e>=a&&ea&&t<=u;if(_&&R){if(e===a&&t===u){r.push(o);break}const N=e-a;r.push(o.subarray(N,N+(t-e)));break}if(_){if(0===e){r.push(o);continue}r.push(o.subarray(e-a))}else{if(R){if(t===u){r.push(o);break}r.push(o.subarray(0,t-a));break}r.push(o)}}return{bufs:r,length:t-e}}getInt8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=Nc(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){const i=Lo(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt16(0,t,r),this.write(i,e)}getInt32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setInt32(0,t,r),this.write(i,e)}getBigInt64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigInt64(0,t,r),this.write(i,e)}getUint8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){const r=Nc(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){const i=Lo(2);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint16(0,t,r),this.write(i,e)}getUint32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setUint32(0,t,r),this.write(i,e)}getBigUint64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setBigUint64(0,t,r),this.write(i,e)}getFloat32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){const i=Lo(4);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat32(0,t,r),this.write(i,e)}getFloat64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){const i=Lo(8);new DataView(i.buffer,i.byteOffset,i.byteLength).setFloat64(0,t,r),this.write(i,e)}equals(e){if(null==e||!(e instanceof qr)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;ti+s.byteLength,0)),r.length=t,r}}class jC{constructor(e){if(!(e>0)||0!=(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class b0{constructor(e={}){this.hwm=e.splitLimit??16,this.head=new jC(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=e?.byteLength?e.byteLength:1}push(e){null!=e?.value&&(this.size+=this.calculateSize(e.value)),this.head.push(e)||(this.head=this.head.next=new jC(2*this.head.buffer.length),this.head.push(e))}shift(){let e=this.tail.shift();if(void 0===e&&null!=this.tail.next){const t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return null!=e?.value&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}}function Mc(n={}){return GC(t=>{const r=t.shift();if(null==r)return{done:!0};if(null!=r.error)throw r.error;return{done:!0===r.done,value:r.value}},n)}function GC(n,e){let i,s,o,t=(e=e??{}).onEnd,r=new b0;const a=function(){var J=j(function*(){return r.isEmpty()?o?{done:!0}:yield new Promise((oe,he)=>{s=Ie=>{s=null,r.push(Ie);try{oe(n(r))}catch(ue){he(ue)}return i}}):n(r)});return function(){return J.apply(this,arguments)}}(),u=J=>null!=s?s(J):(r.push(J),i),R=J=>{if(o)return i;if(!0!==e?.objectMode&&null==J?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return u({done:!1,value:J})},N=J=>o?i:(o=!0,null!=J?(J=>(r=new b0,null!=s?s({error:J}):(r.push({error:J}),i)))(J):u({done:!0}));if(i={[Symbol.asyncIterator](){return this},next:a,return:()=>(r=new b0,N(),{done:!0}),throw:J=>(N(J),{done:!0}),push:R,end:N,get readableLength(){return r.size}},null==t)return i;const Z=i;return i={[Symbol.asyncIterator](){return this},next:()=>Z.next(),throw:J=>(Z.throw(J),null!=t&&(t(J),t=void 0),{done:!0}),return:()=>(Z.return(),null!=t&&(t(),t=void 0),{done:!0}),push:R,end:J=>(Z.end(J),null!=t&&(t(J),t=void 0),i),get readableLength(){return Z.readableLength}},i}function w0(){const n={};return n.promise=new Promise((e,t)=>{n.resolve=e,n.reject=t}),n}function Ld(n){const e=Mc(),t=function fB(n){const e=dn(function*(){let t=yield,r=new qr;var o,i=!1,s=!1;try{for(var u,a=Pt(n);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;if(null!=t)for(r.append(_);r.length>=t;){const R=r.sublist(0,t);if(r.consume(t),t=yield R,null==t){r.length>0&&(t=yield r,r=new qr);break}}else r.append(_),t=yield r,r=new qr}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}if(null!=t)throw Object.assign(new Error(`stream ended before ${t} bytes became available`),{code:"ERR_UNDER_READ",buffer:r})})();return e.next(),e}(n.source),r=w0();let i;const s=n.sink(dn(function*(){yield*Mr(Pt(e),lt);const a=yield lt(r.promise);yield*Mr(Pt(a),lt)})());s.catch(a=>{i=a});const o={sink:(a=j(function*(u){return null!=i?yield Promise.reject(i):(r.resolve(u),yield s)}),function(_){return a.apply(this,arguments)}),source:t};var a;return{reader:t,writer:e,stream:o,rest:()=>e.end(),write:e.push,read:function(){var a=j(function*(){const u=yield t.next();if(null!=u.value)return u.value});return function(){return a.apply(this,arguments)}}()}}function zC(n){return n instanceof Uint8Array?{get:e=>n[e],set(e,t){n[e]=t}}:{get:e=>n.get(e),set(e,t){n.set(e,t)}}}const WC=4294967296;class Gi{constructor(e=0,t=0){this.hi=e,this.lo=t}toBigInt(e){if(!0===e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!=0){const t=1+~this.lo>>>0;let r=~this.hi>>>0;return 0===t&&(r=r+1>>>0),-(BigInt(t)+(BigInt(r)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toNumber(e){return Number(this.toBigInt(e))}zzDecode(){const e=-(1&this.lo);return new Gi((this.hi>>>1^e)>>>0,((this.lo>>>1|this.hi<<31)^e)>>>0)}zzEncode(){const e=this.hi>>31;return new Gi(((this.hi<<1|this.lo>>>31)^e)>>>0,(this.lo<<1^e)>>>0)}toBytes(e,t=0){const r=zC(e);for(;this.hi>0;)r.set(t++,127&this.lo|128),this.lo=(this.lo>>>7|this.hi<<25)>>>0,this.hi>>>=7;for(;this.lo>127;)r.set(t++,127&this.lo|128),this.lo=this.lo>>>7;r.set(t++,this.lo)}static fromBigInt(e){if(0n===e)return new Gi;const t=e<0;t&&(e=-e);let r=0|Number(e>>32n),i=0|Number(e-(BigInt(r)<<32n));return t&&(r=~r>>>0,i=~i>>>0,++i>WC&&(i=0,++r>WC&&(r=0))),new Gi(r,i)}static fromNumber(e){if(0===e)return new Gi;const t=e<0;t&&(e=-e);let r=e>>>0,i=(e-r)/4294967296>>>0;return t&&(i=~i>>>0,r=~r>>>0,++r>4294967295&&(r=0,++i>4294967295&&(i=0))),new Gi(i,r)}static fromBytes(e,t=0){const r=zC(e),i=new Gi;let s=0;if(e.length-t>4){for(;s<4;++s)if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i;if(i.lo=(i.lo|(127&r.get(t))<<28)>>>0,i.hi=(i.hi|(127&r.get(t))>>4)>>>0,r.get(t++)<128)return i;s=0}else for(;s<4;++s){if(t>=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.lo=(i.lo|(127&r.get(t))<<7*s)>>>0,r.get(t++)<128)return i}if(e.length-t>4){for(;s<5;++s)if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}else if(t=e.length)throw RangeError(`index out of range: ${t} > ${e.length}`);if(i.hi=(i.hi|(127&r.get(t))<<7*s+3)>>>0,r.get(t++)<128)return i}throw RangeError("invalid varint encoding")}}const hB=Math.pow(2,7),pB=Math.pow(2,14),gB=Math.pow(2,21),yB=Math.pow(2,28),mB=Math.pow(2,35),vB=Math.pow(2,42),EB=Math.pow(2,49),bB=Math.pow(2,56),wB=Math.pow(2,63),Ni={encodingLength:n=>nNumber.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return null==e&&(e=Nc(Ni.encodingLength(n))),Gi.fromNumber(n).toBytes(e,t),e},decode:(n,e=0)=>Gi.fromBytes(n,e).toNumber(!0)},Bd=n=>{const e=Ni.encodingLength(n),t=function DB(n){return null!=globalThis?.Buffer?.allocUnsafe?globalThis.Buffer.allocUnsafe(n):new Uint8Array(n)}(e);return Ni.encode(n,t),Bd.bytes=e,t};function Os(n){const e=(n=n??{}).lengthEncoder??Bd;return function(){var r=dn(function*(i){var a,s=!1,o=!1;try{for(var _,u=Pt(i);s=!(_=yield lt(u.next())).done;s=!1){const R=_.value,N=e(R.byteLength);N instanceof Uint8Array?yield N:yield*Mr(Pt(N),lt),R instanceof Uint8Array?yield R:yield*Mr(Pt(R),lt)}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield lt(u.return()))}finally{if(o)throw a}}});return function(s){return r.apply(this,arguments)}}()}Bd.bytes=0,Os.single=(n,e)=>new qr(((e=e??{}).lengthEncoder??Bd)(n.byteLength),n);var ae=x(2535),Bo=(()=>{return(n=Bo||(Bo={}))[n.LENGTH=0]="LENGTH",n[n.DATA=1]="DATA",Bo;var n})();const _0=n=>{const e=Ni.decode(n);return _0.bytes=Ni.encodingLength(e),e};function ps(n){return function(){var t=dn(function*(r){const i=new qr;let s=Bo.LENGTH,o=-1;const a=n?.lengthDecoder??_0,u=n?.maxLengthLength??8,_=n?.maxDataLength??4194304;var B,R=!1,N=!1;try{for(var Z,K=Pt(r);R=!(Z=yield lt(K.next())).done;R=!1)for(i.append(Z.value);i.byteLength>0;){if(s===Bo.LENGTH)try{if(o=a(i),o<0)throw ae(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(o>_)throw ae(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");i.consume(a.bytes),null!=n?.onLength&&n.onLength(o),s=Bo.DATA}catch(oe){if(oe instanceof RangeError){if(i.byteLength>u)throw ae(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw oe}if(s===Bo.DATA){if(i.byteLength0)throw ae(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")});return function(i){return t.apply(this,arguments)}}()}function qC(n,e={}){const t=Ld(n),r=ps.fromReader(t.reader,e),i={read:(s=j(function*(o){const{value:a}=yield t.reader.next(o);if(null==a)throw new Error("Value is null");return a}),function(a){return s.apply(this,arguments)}),readLP:function(){var s=j(function*(){const{value:o}=yield r.next();if(null==o)throw new Error("Value is null");return o});return function(){return s.apply(this,arguments)}}(),readPB:function(){var s=j(function*(o){const a=yield i.readLP();if(null==a)throw new Error("Value is null");const u=a instanceof Uint8Array?a:a.slice();return o.decode(u)});return function(a){return s.apply(this,arguments)}}(),write:s=>{s instanceof Uint8Array?t.writer.push(s):t.writer.push(s.slice())},writeLP:s=>{i.write(Os.single(s,e))},writePB:(s,o)=>{i.writeLP(o.encode(s))},pb:s=>{return{read:(o=j(function*(){return yield i.readPB(s)}),function(){return o.apply(this,arguments)}),write:o=>i.writePB(o,s)};var o},unwrap:()=>(t.rest(),t.stream)};var s;return i}function YC(){const n=w0();let e=!1;return{sink:(t=j(function*(r){if(e)throw new Error("already piped");e=!0,n.resolve(r)}),function(i){return t.apply(this,arguments)}),source:dn(function*(){const t=yield lt(n.promise);yield*Mr(Pt(t),lt)})()};var t}_0.bytes=0,ps.fromReader=(n,e)=>{let t=1;const r=dn(function*(){for(;;)try{const{done:s,value:o}=yield lt(n.next(t));if(!0===s)return;null!=o&&(yield o)}catch(s){if("ERR_UNDER_READ"===s.code)return{done:!0,value:null};throw s}finally{t=1}})();return ps({...e??{},onLength:s=>{t=s}})(r)};var Fd=x(5061);const QC=n=>null!=n&&("function"==typeof n[Symbol.asyncIterator]||"function"==typeof n[Symbol.iterator]||"function"==typeof n.next),D0=n=>null!=n&&"function"==typeof n.sink&&QC(n.source),AB=n=>e=>{const t=n.sink(e);if(null!=t.then){const r=Mc({objectMode:!0});return t.then(()=>{r.end()},s=>{r.end(s)}),Fd(r,function(){var s=dn(function*(){yield*Mr(Pt(n.source),lt),r.end()});return function(){return s.apply(this,arguments)}}()())}return n.source};function Wn(n,...e){if(D0(n)){const r=n;n=()=>r.source}else if(QC(n)){const r=n;n=()=>r}const t=[n,...e];if(t.length>1&&D0(t[t.length-1])&&(t[t.length-1]=t[t.length-1].sink),t.length>2)for(let r=1;r{let e;for(;n.length>0;)e=n.shift()(e);return e})(...t)}const gl=65535,xB=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS),Ud=n=>{const e=globalThis.Buffer?globalThis.Buffer.allocUnsafe(2):new Uint8Array(2);return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint16(0,n,!1),e};Ud.bytes=2;const Vd=n=>{if(n.length<2)throw RangeError("Could not decode int16BE");return n instanceof Uint8Array?new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,!1):n.getUint16(0)};Vd.bytes=2;class Hd extends Error{constructor(e="Unexpected Peer"){super(e),this.code=Hd.code}static get code(){return"ERR_UNEXPECTED_PEER"}}class Oc extends Error{constructor(e="Invalid crypto exchange"){super(e),this.code=Oc.code}static get code(){return"ERR_INVALID_CRYPTO_EXCHANGE"}}Error;var S0=x(3863),C0=x.n(S0);const I0=S0.Reader;function Wt(n,e){const t=I0.create(n instanceof Uint8Array?n:n.subarray());return e.decode(t)}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=I0.prototype[n];I0.prototype[n]=function(){return BigInt(e.call(this).toString())}});const T0=S0.Writer;function qt(n,e){const t=T0.create();return e.encode(n,t,{lengthDelimited:!1}),t.finish()}["uint64","int64","sint64","fixed64","sfixed64"].forEach(n=>{const e=T0.prototype[n];T0.prototype[n]=function(t){return e.call(this,t.toString())}});var yl=(()=>{return(n=yl||(yl={}))[n.VARINT=0]="VARINT",n[n.BIT64=1]="BIT64",n[n.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",n[n.START_GROUP=3]="START_GROUP",n[n.END_GROUP=4]="END_GROUP",n[n.BIT32=5]="BIT32",yl;var n})();function JC(n,e,t,r){return{name:n,type:e,encode:t,decode:r}}function Fo(n){function e(i){if(null==n[i.toString()])throw new Error("Invalid enum value");return n[i]}return JC("enum",yl.VARINT,function(s,o){const a=e(s);o.int32(a)},function(s){return e(s.uint32())})}function Yt(n,e){return JC("message",yl.LENGTH_DELIMITED,n,e)}var kc,Lc,tr=(()=>{return(n=tr||(tr={})).RSA="RSA",n.Ed25519="Ed25519",n.Secp256k1="Secp256k1",tr;var n})(),Kd=(()=>{return(n=Kd||(Kd={}))[n.RSA=0]="RSA",n[n.Ed25519=1]="Ed25519",n[n.Secp256k1=2]="Secp256k1",Kd;var n})();(tr||(tr={})).codec=()=>Fo(Kd),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(r.uint32(8),tr.codec().encode(t.Type,r),null==t.Data)throw new Error('Protocol error: required field "Data" was not found in object');r.uint32(18),r.bytes(t.Data),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={Type:tr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=tr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}if(null==i.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==i.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(kc||(kc={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.Type)throw new Error('Protocol error: required field "Type" was not found in object');if(r.uint32(8),tr.codec().encode(t.Type,r),null==t.Data)throw new Error('Protocol error: required field "Data" was not found in object');r.uint32(18),r.bytes(t.Data),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={Type:tr.RSA,Data:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.Type=tr.codec().decode(t);break;case 2:i.Data=t.bytes();break;default:t.skipType(7&o)}}if(null==i.Type)throw new Error('Protocol error: value for required field "Type" was not found in protobuf');if(null==i.Data)throw new Error('Protocol error: value for required field "Data" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Lc||(Lc={})),x(7791),x(2158);var Un=x(8659);const KB=function UB(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,ue=new Uint8Array(Ie);Z[J];){var Re=t[Z.charCodeAt(J)];if(255===Re)return;for(var ze=0,Oe=Ie-1;(0!==Re||ze>>0)%256>>>0,Re=Re/256>>>0;if(0!==Re)throw new Error("Non-zero carry");he=ze,J++}if(" "!==Z[J]){for(var bt=Ie-he;bt!==Ie&&0===ue[bt];)bt++;for(var vt=new Uint8Array(oe+(Ie-bt)),hn=oe;bt!==Ie;)vt[hn++]=ue[bt++];return vt}}}return{encode:function N(Z){if(Z instanceof Uint8Array||(ArrayBuffer.isView(Z)?Z=new Uint8Array(Z.buffer,Z.byteOffset,Z.byteLength):Array.isArray(Z)&&(Z=Uint8Array.from(Z))),!(Z instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===Z.length)return"";for(var J=0,oe=0,he=0,Ie=Z.length;he!==Ie&&0===Z[he];)he++,J++;for(var ue=(Ie-he)*R+1>>>0,Re=new Uint8Array(ue);he!==Ie;){for(var ze=Z[he],Oe=0,bt=ue-1;(0!==ze||Oe>>0)%a>>>0,ze=ze/a>>>0;if(0!==ze)throw new Error("Non-zero carry");oe=Oe,he++}for(var vt=ue-oe;vt!==ue&&0===Re[vt];)vt++;for(var hn=u.repeat(J);vt{if(n instanceof Uint8Array&&"Uint8Array"===n.constructor.name)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")});class WB{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class qB{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return eI(this,e)}}class YB{constructor(e){this.decoders=e}or(e){return eI(this,e)}decode(e){const r=this.decoders[e[0]];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const eI=(n,e)=>new YB({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class QB{constructor(e,t,r,i){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=i,this.encoder=new WB(e,t,r),this.decoder=new qB(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const $d=({name:n,prefix:e,encode:t,decode:r})=>new QB(n,e,t,r),ml=({prefix:n,name:e,alphabet:t})=>{const{encode:r,decode:i}=KB(t,e);return $d({prefix:n,name:e,encode:r,decode:s=>Bc(i(s))})},Lr=({name:n,prefix:e,bitsPerChar:t,alphabet:r})=>$d({prefix:e,name:n,encode:i=>((n,e,t)=>{const r="="===e[e.length-1],i=(1<t;)o-=t,s+=e[i&a>>o];if(o&&(s+=e[i&a<((n,e,t,r)=>{const i={};for(let R=0;R=8&&(a-=8,o[_++]=255&u>>a)}if(a>=t||255&u<<8-a)throw new SyntaxError("Unexpected end of data");return o})(i,r,t,n)}),JB=$d({prefix:"\0",name:"identity",encode:n=>(n=>(new TextDecoder).decode(n))(n),decode:n=>(n=>(new TextEncoder).encode(n))(n)}),e6=Lr({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),t6=Lr({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),n6=ml({prefix:"9",name:"base10",alphabet:"0123456789"}),r6=Lr({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),i6=Lr({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),co=Lr({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),s6=Lr({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),o6=Lr({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),a6=Lr({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),c6=Lr({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),u6=Lr({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),l6=Lr({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),f6=Lr({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),d6=Lr({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),h6=ml({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),p6=ml({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ui=ml({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),g6=ml({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),jd=Lr({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),y6=Lr({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),m6=Lr({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),v6=Lr({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),tI=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}"),E6=tI.reduce((n,e,t)=>(n[t]=e,n),[]),b6=tI.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]),D6=$d({prefix:"\u{1f680}",name:"base256emoji",encode:function w6(n){return n.reduce((e,t)=>e+E6[t],"")},decode:function _6(n){const e=[];for(const t of n){const r=b6[t.codePointAt(0)];if(void 0===r)throw new Error(`Non-base256emoji character: ${t}`);e.push(r)}return new Uint8Array(e)}});var T6=Math.pow(2,31),R6=Math.pow(2,7),P6=Math.pow(2,14),N6=Math.pow(2,21),M6=Math.pow(2,28),O6=Math.pow(2,35),k6=Math.pow(2,42),L6=Math.pow(2,49),B6=Math.pow(2,56),F6=Math.pow(2,63),V6={encode:function rI(n,e,t){e=e||[];for(var r=t=t||0;n>=T6;)e[t++]=255&n|128,n/=128;for(;-128&n;)e[t++]=255&n|128,n>>>=7;return e[t]=0|n,rI.bytes=t-r+1,e},decode:function A0(n,r){var o,t=0,i=0,s=r=r||0,a=n.length;do{if(s>=a)throw A0.bytes=0,new RangeError("Could not decode varint");o=n[s++],t+=i<28?(127&o)<=128);return A0.bytes=s-r,t},encodingLength:function(n){return n[Gd.decode(n),Gd.decode.bytes],zd=(n,e,t=0)=>(Gd.encode(n,e,t),e),Wd=n=>Gd.encodingLength(n),Fc=(n,e)=>{const t=e.byteLength,r=Wd(n),i=r+Wd(t),s=new Uint8Array(i+t);return zd(n,s,0),zd(t,s,r),s.set(e,i),new R0(n,t,e,s)},qd=n=>{const e=Bc(n),[t,r]=x0(e),[i,s]=x0(e.subarray(r)),o=e.subarray(r+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new R0(t,i,o,e)};class R0{constructor(e,t,r,i){this.code=e,this.size=t,this.digest=r,this.bytes=i}}const sI=({name:n,code:e,encode:t})=>new $6(n,e,t);class $6{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Fc(this.code,t):t.then(r=>Fc(this.code,r))}throw Error("Unknown type, must be binary type")}}const oI=n=>function(){var e=j(function*(t){return new Uint8Array(yield crypto.subtle.digest(n,t))});return function(t){return e.apply(this,arguments)}}(),mi=sI({name:"sha2-256",code:18,encode:oI("SHA-256")}),j6=sI({name:"sha2-512",code:19,encode:oI("SHA-512")}),cI=Bc,Uc={code:0,name:"identity",encode:cI,digest:n=>Fc(0,cI(n))},z6="raw",W6=85,q6=n=>Bc(n),Y6=n=>Bc(n),Q6=new TextEncoder,Z6=new TextDecoder,X6="json",J6=512,eF=n=>Q6.encode(JSON.stringify(n)),tF=n=>JSON.parse(Z6.decode(n));class _r{constructor(e,t,r,i){this.code=t,this.version=e,this.multihash=r,this.bytes=i,this.byteOffset=i.byteOffset,this.byteLength=i.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Qd,byteLength:Qd,code:Yd,version:Yd,multihash:Yd,bytes:Yd,_baseCache:Qd,asCID:Qd})}toV0(){if(0===this.version)return this;{const{code:e,multihash:t}=this;if(e!==vl)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==sF)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return _r.createV0(t)}}toV1(){switch(this.version){case 0:{const{code:e,digest:t}=this.multihash,r=Fc(e,t);return _r.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&((n,e)=>n===e||n.code===e.code&&n.size===e.size&&((n,e)=>{if(n===e)return!0;if(n.byteLength!==e.byteLength)return!1;for(let t=0;t{const[N,B]=x0(e.subarray(t));return t+=B,N};let i=r(),s=vl;if(18===i?(i=0,t=0):1===i&&(s=r()),0!==i&&1!==i)throw new RangeError(`Invalid CID version ${i}`);const o=t,a=r(),u=r(),_=t+u;return{version:i,codec:s,multihashCode:a,digestSize:u,multihashSize:_-o,size:_}}static parse(e,t){const[r,i]=nF(e,t),s=_r.decode(i);return s._baseCache.set(r,e),s}}const nF=(n,e)=>{switch(n[0]){case"Q":return[ui.prefix,(e||ui).decode(`${ui.prefix}${n}`)];case ui.prefix:return[ui.prefix,(e||ui).decode(n)];case co.prefix:return[co.prefix,(e||co).decode(n)];default:if(null==e)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[n[0],e.decode(n)]}},rF=(n,e,t)=>{const{prefix:r}=t;if(r!==ui.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);const i=e.get(r);if(null==i){const s=t.encode(n).slice(1);return e.set(r,s),s}return i},iF=(n,e,t)=>{const{prefix:r}=t,i=e.get(r);if(null==i){const s=t.encode(n);return e.set(r,s),s}return i},vl=112,sF=18,uI=(n,e,t)=>{const r=Wd(n),i=r+Wd(e),s=new Uint8Array(i+t.byteLength);return zd(n,s,0),zd(e,s,r),s.set(t,i),s},lI=Symbol.for("@ipld/js-cid/CID"),Yd={writable:!1,configurable:!1,enumerable:!0},Qd={writable:!1,enumerable:!1,configurable:!1},aF=(n,e)=>{if(!n.test("0.0.0-dev"))throw new Error(e);console.warn(e)},cF="CID.isCID(v) is deprecated and will be removed in the next major release.\nFollowing code pattern:\n\nif (CID.isCID(value)) {\n doSomethingWithCID(value)\n}\n\nIs replaced with:\n\nconst cid = CID.asCID(value)\nif (cid) {\n // Make sure to use cid instead of value\n doSomethingWithCID(cid)\n}\n",El={...y,...l,...g,...w,...m,...h,...c,...f,...d,...b};function fI(n,e,t,r){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:r}}}const dI=fI("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>(new TextEncoder).encode(n.substring(1))),P0=fI("ascii","a",n=>{let e="a";for(let t=0;t{const e=Nc((n=n.substring(1)).length);for(let t=0;te)throw new Error("byte array longer than desired length");t=wr([new Uint8Array(e-t.length),t])}return Lt(t,"base64url")}function gs(n){const e=function dF(n,e){let t=Ot(n,"base64urlpad");if(null!=e){if(t.length>e)throw new Error("byte array longer than desired length");t=wr([new Uint8Array(e-t.length),t])}return t}(n);return new Un.jsbn.BigInteger(Lt(e,"base16"),16)}x(730);function vI(n){const e=n?.algorithm??"AES-GCM";let t=n?.keyLength??16;const r=n?.nonceLength??12,i=n?.digest??"SHA-256",s=n?.saltLength??16,o=n?.iterations??32767,a=ks.get();function _(){return(_=j(function*(K,Z){const J=a.getRandomValues(new Uint8Array(s)),oe=a.getRandomValues(new Uint8Array(r)),he={name:e,iv:oe};"string"==typeof Z&&(Z=Ot(Z));const Ie={name:"PBKDF2",salt:J,iterations:o,hash:{name:i}},ue=yield a.subtle.importKey("raw",Z,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),Re=yield a.subtle.deriveKey(Ie,ue,{name:e,length:t},!0,["encrypt"]),ze=yield a.subtle.encrypt(he,Re,K);return wr([J,he.iv,new Uint8Array(ze)])})).apply(this,arguments)}function N(){return(N=j(function*(K,Z){const J=K.slice(0,s),oe=K.slice(s,s+r),he=K.slice(s+r),Ie={name:e,iv:oe};"string"==typeof Z&&(Z=Ot(Z));const ue={name:"PBKDF2",salt:J,iterations:o,hash:{name:i}},Re=yield a.subtle.importKey("raw",Z,{name:"PBKDF2"},!1,["deriveKey","deriveBits"]),ze=yield a.subtle.deriveKey(ue,Re,{name:e,length:t},!0,["decrypt"]),Oe=yield a.subtle.decrypt(Ie,ze,he);return new Uint8Array(Oe)})).apply(this,arguments)}return t*=8,{encrypt:function u(K,Z){return _.apply(this,arguments)},decrypt:function R(K,Z){return N.apply(this,arguments)}}}function gF(n,e){return L0.apply(this,arguments)}function L0(){return(L0=j(function*(n,e){const t=jd.decode(n);return yield vI().decrypt(t,e)})).apply(this,arguments)}Object.keys({"P-256":256,"P-384":384,"P-521":521}).join(" / "),x(8985);var yF=x(5856),mF=x.t(yF,2);const un=BigInt(0),qn=BigInt(1),Uo=BigInt(2),bl=BigInt(3),vF=BigInt(8),Nn=Object.freeze({a:un,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:qn,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});function EI(n){const{a:e,b:t}=Nn,r=at(n*n),i=at(r*n);return at(i+e*n+t)}const Zd=Nn.a===un;class B0 extends Error{constructor(e){super(e)}}class Mn{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof In))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new Mn(e.x,e.y,qn)}static toAffineBatch(e){const t=function DF(n,e=Nn.P){const t=new Array(n.length),i=$c(n.reduce((s,o,a)=>o===un?s:(t[a]=s,at(s*o,e)),qn),e);return n.reduceRight((s,o,a)=>o===un?s:(t[a]=at(s*t[a],e),at(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return Mn.toAffineBatch(e).map(Mn.fromAffine)}equals(e){if(!(e instanceof Mn))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,u=at(i*i),_=at(a*a),R=at(t*_),N=at(s*u),B=at(at(r*a)*_),K=at(at(o*i)*u);return R===N&&B===K}negate(){return new Mn(this.x,at(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,i=at(e*e),s=at(t*t),o=at(s*s),a=e+s,u=at(Uo*(at(a*a)-i-o)),_=at(bl*i),R=at(_*_),N=at(R-Uo*u),B=at(_*(u-N)-vF*o),K=at(Uo*t*r);return new Mn(N,B,K)}add(e){if(!(e instanceof Mn))throw new TypeError("JacobianPoint expected");const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e;if(s===un||o===un)return this;if(t===un||r===un)return e;const u=at(i*i),_=at(a*a),R=at(t*_),N=at(s*u),B=at(at(r*a)*_),K=at(at(o*i)*u),Z=at(N-R),J=at(K-B);if(Z===un)return J===un?this.double():Mn.ZERO;const oe=at(Z*Z),he=at(Z*oe),Ie=at(R*oe),ue=at(J*J-he-Uo*Ie),Re=at(J*(Ie-ue)-B*he),ze=at(i*a*Z);return new Mn(ue,Re,ze)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Mn.ZERO;if("bigint"==typeof e&&e===un)return t;let r=_I(e);if(r===qn)return this;if(!Zd){let N=t,B=this;for(;r>un;)r&qn&&(N=N.add(B)),B=B.double(),r>>=qn;return N}let{k1neg:i,k1:s,k2neg:o,k2:a}=SI(r),u=t,_=t,R=this;for(;s>un||a>un;)s&qn&&(u=u.add(R)),a&qn&&(_=_.add(R)),R=R.double(),s>>=qn,a>>=qn;return i&&(u=u.negate()),o&&(_=_.negate()),_=new Mn(at(_.x*Nn.beta),_.y,_.z),u.add(_)}precomputeWindow(e){const t=Zd?128/e+1:256/e+1,r=[];let i=this,s=i;for(let o=0;o>=N,Z>u&&(Z-=R,e+=qn),0===Z){let J=i[K];B%2&&(J=J.negate()),o=o.add(J)}else{let J=i[K+Math.abs(Z)-1];Z<0&&(J=J.negate()),s=s.add(J)}}return{p:s,f:o}}multiply(e,t){let i,s,r=_I(e);if(Zd){const{k1neg:o,k1:a,k2neg:u,k2:_}=SI(r);let{p:R,f:N}=this.wNAF(a,t),{p:B,f:K}=this.wNAF(_,t);o&&(R=R.negate()),u&&(B=B.negate()),B=new Mn(at(B.x*Nn.beta),B.y,B.z),i=R.add(B),s=N.add(K)}else{const{p:o,f:a}=this.wNAF(r,t);i=o,s=a}return Mn.normalizeZ([i,s])[0]}toAffine(e=$c(this.z)){const{x:t,y:r,z:i}=this,s=e,o=at(s*s),a=at(o*s),u=at(t*o),_=at(r*a);if(at(i*s)!==qn)throw new Error("invZ was invalid");return new In(u,_)}}Mn.BASE=new Mn(Nn.Gx,Nn.Gy,qn),Mn.ZERO=new Mn(un,qn,un);const F0=new WeakMap;class In{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,F0.delete(this)}hasEvenY(){return this.y%Uo===un}static fromCompressedHex(e){const t=32===e.length,r=vi(t?e:e.subarray(1));if(!Jd(r))throw new Error("Point is not on curve");let s=function _F(n){const{P:e}=Nn,t=BigInt(6),r=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),u=n*n*n%e,_=u*u*n%e,R=zi(_,bl)*_%e,N=zi(R,bl)*_%e,B=zi(N,Uo)*u%e,K=zi(B,r)*B%e,Z=zi(K,i)*K%e,J=zi(Z,o)*Z%e,oe=zi(J,a)*J%e,he=zi(oe,o)*Z%e,Ie=zi(he,bl)*_%e,ue=zi(Ie,s)*K%e,Re=zi(ue,t)*u%e;return zi(Re,Uo)}(EI(r));const o=(s&qn)===qn;t?o&&(s=at(-s)):1==(1&e[0])!==o&&(s=at(-s));const a=new In(r,s);return a.assertValidity(),a}static fromUncompressedHex(e){const t=vi(e.subarray(1,33)),r=vi(e.subarray(33,65)),i=new In(t,r);return i.assertValidity(),i}static fromHex(e){const t=Bs(e),r=t.length,i=t[0];if(32===r||33===r&&(2===i||3===i))return this.fromCompressedHex(t);if(65===r&&4===i)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(e){return In.BASE.multiply(_a(e))}static fromSignature(e,t,r){const i=CI(e=Bs(e)),{r:s,s:o}=AI(t);if(0!==r&&1!==r)throw new Error("Cannot recover signature: invalid recovery bit");const u=In.fromHex((1&r?"03":"02")+Vo(s)),{n:_}=Nn,R=$c(s,_),N=at(-i*R,_),B=at(o*R,_),K=In.BASE.multiplyAndAddUnsafe(u,N,B);if(!K)throw new Error("Cannot recover signature: point at infinify");return K.assertValidity(),K}toRawBytes(e=!1){return Ho(this.toHex(e))}toHex(e=!1){const t=Vo(this.x);return e?`${this.hasEvenY()?"02":"03"}${t}`:`04${t}${Vo(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!Jd(t)||!Jd(r))throw new Error(e);const i=at(r*r);if(at(i-EI(t))!==un)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new In(this.x,at(-this.y))}double(){return Mn.fromAffine(this).double().toAffine()}add(e){return Mn.fromAffine(this).add(Mn.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Mn.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const i=Mn.fromAffine(this),s=t===un||t===qn||this!==In.BASE?i.multiplyUnsafe(t):i.multiply(t),o=Mn.fromAffine(e).multiplyUnsafe(r),a=s.add(o);return a.equals(Mn.ZERO)?void 0:a.toAffine()}}function bI(n){return Number.parseInt(n[0],16)>=8?"00"+n:n}function wI(n){if(n.length<2||2!==n[0])throw new Error(`Invalid signature integer tag: ${Hc(n)}`);const e=n[1],t=n.subarray(2,e+2);if(!e||t.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===t[0]&&t[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:vi(t),left:n.subarray(e+2)}}In.BASE=new In(Nn.Gx,Nn.Gy),In.ZERO=new In(un,un);class uo{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const i=t?Hc(e):e;if(128!==i.length)throw new Error(`${r}: Expected 64-byte hex`);return new uo(Xd(i.slice(0,64)),Xd(i.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!=typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:i}=function EF(n){if(n.length<2||48!=n[0])throw new Error(`Invalid signature tag: ${Hc(n)}`);if(n[1]!==n.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:t}=wI(n.subarray(2)),{data:r,left:i}=wI(t);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${Hc(i)}`);return{r:e,s:r}}(t?e:Ho(e));return new uo(r,i)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Gc(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Gc(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){return this.s>Nn.n>>qn}normalizeS(){return this.hasHighS()?new uo(this.r,Nn.n-this.s):this}toDERRawBytes(e=!1){return Ho(this.toDERHex(e))}toDERHex(e=!1){const t=bI(wl(this.s));if(e)return t;const r=bI(wl(this.r)),i=wl(r.length/2),s=wl(t.length/2);return`30${wl(r.length/2+t.length/2+4)}02${i}${r}02${s}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return Ho(this.toCompactHex())}toCompactHex(){return Vo(this.r)+Vo(this.s)}}function Vc(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Uint8Array list expected");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function Hc(n){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let t=0;t0)return BigInt(n);if("bigint"==typeof n&&Gc(n))return n;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function at(n,e=Nn.P){const t=n%e;return t>=un?t:e+t}function zi(n,e){const{P:t}=Nn;let r=n;for(;e-- >un;)r*=r,r%=t;return r}function $c(n,e=Nn.P){if(n===un||e<=un)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=at(n,e),r=e,i=un,s=qn,o=qn,a=un;for(;t!==un;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==qn)throw new Error("invert: does not exist");return at(i,e)}const DI=(n,e)=>(n+e/Uo)/e,SF={a1:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),b1:-qn*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),a2:BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),b2:BigInt("0x3086d221a7d46bcde86c90e49284eb15"),POW_2_128:BigInt("0x100000000000000000000000000000000")};function SI(n){const{n:e}=Nn,{a1:t,b1:r,a2:i,b2:s,POW_2_128:o}=SF,a=DI(s*n,e),u=DI(-r*n,e);let _=at(n-a*t-u*i,e),R=at(-a*r-u*s,e);const N=_>o,B=R>o;if(N&&(_=e-_),B&&(R=e-R),_>o||R>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+n);return{k1neg:N,k1:_,k2neg:B,k2:R}}function CI(n){const{n:e}=Nn,r=8*n.length-256;let i=vi(n);return r>0&&(i>>=BigInt(r)),i>=e&&(i-=e),i}let jc,_l;class II{constructor(){this.v=new Uint8Array(32).fill(1),this.k=new Uint8Array(32).fill(0),this.counter=0}hmac(...e){return Yr.hmacSha256(this.k,...e)}hmacSync(...e){return _l(this.k,...e)}checkSync(){if("function"!=typeof _l)throw new B0("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}reseed(e=new Uint8Array){var t=this;return j(function*(){t.k=yield t.hmac(t.v,Uint8Array.from([0]),e),t.v=yield t.hmac(t.v),0!==e.length&&(t.k=yield t.hmac(t.v,Uint8Array.from([1]),e),t.v=yield t.hmac(t.v))})()}reseedSync(e=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}generate(){var e=this;return j(function*(){return e.incr(),e.v=yield e.hmac(e.v),e.v})()}generateSync(){return this.checkSync(),this.incr(),this.v=this.hmacSync(this.v),this.v}}function Gc(n){return un0)e=BigInt(n);else if("string"==typeof n){if(64!==n.length)throw new Error("Expected 32 bytes of private key");e=Xd(n)}else{if(!(n instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==n.length)throw new Error("Expected 32 bytes of private key");e=vi(n)}if(!Gc(e))throw new Error("Expected private key: 0 < key < n");return e}function U0(n){return n instanceof In?(n.assertValidity(),n):In.fromHex(n)}function AI(n){if(n instanceof uo)return n.assertValidity(),n;try{return uo.fromDER(n)}catch{return uo.fromCompact(n)}}function Dl(n,e=!1){return In.fromPrivateKey(n).toRawBytes(e)}function xI(n){const e=n instanceof Uint8Array,t="string"==typeof n,r=(e||t)&&n.length;return e?33===r||65===r:t?66===r||130===r:n instanceof In}function RI(n){return vi(n.length>32?n.slice(0,32):n)}function TF(n){const e=RI(n),t=at(e,Nn.n);return PI(t{if((n=Bs(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Kc(at(vi(n),Nn.n-qn)+qn)},randomBytes:(n=32)=>{if(Mi.web)return Mi.web.getRandomValues(new Uint8Array(n));if(Mi.node){const{randomBytes:e}=Mi.node;return Uint8Array.from(e(n))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Yr.hashToPrivateKey(Yr.randomBytes(40)),sha256:(n=j(function*(...e){if(Mi.web){const t=yield Mi.web.subtle.digest("SHA-256",Vc(...e));return new Uint8Array(t)}if(Mi.node){const{createHash:t}=Mi.node,r=t("sha256");return e.forEach(i=>r.update(i)),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")}),function(){return n.apply(this,arguments)}),hmacSha256:function(){var n=j(function*(e,...t){if(Mi.web){const r=yield Mi.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),i=Vc(...t),s=yield Mi.web.subtle.sign("HMAC",r,i);return new Uint8Array(s)}if(Mi.node){const{createHmac:r}=Mi.node,i=r("sha256",e);return t.forEach(s=>i.update(s)),Uint8Array.from(i.digest())}throw new Error("The environment doesn't have hmac-sha256 function")});return function(t){return n.apply(this,arguments)}}(),sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:function(){var n=j(function*(e,...t){let r=th[e];if(void 0===r){const i=yield Yr.sha256(Uint8Array.from(e,s=>s.charCodeAt(0)));r=Vc(i,i),th[e]=r}return Yr.sha256(r,...t)});return function(t){return n.apply(this,arguments)}}(),taggedHashSync:(n,...e)=>{if("function"!=typeof jc)throw new B0("sha256Sync is undefined, you need to set it");let t=th[n];if(void 0===t){const r=jc(Uint8Array.from(n,i=>i.charCodeAt(0)));t=Vc(r,r),th[n]=t}return jc(t,...e)},precompute(n=8,e=In.BASE){const t=e===In.BASE?e:new In(e.x,e.y);return t._setWindowSize(n),t.multiply(bl),t}};var n;function nh(n){if(isNaN(n)||n<=0)throw ae(new Error("random bytes length must be a Number bigger than 0"),"ERR_INVALID_LENGTH");return Yr.randomBytes(n)}function MF(n){const e=Un.asn1.fromDer(Lt(n,"ascii")),t=Un.pki.privateKeyFromAsn1(e);return{kty:"RSA",n:Ls(t.n),e:Ls(t.e),d:Ls(t.d),p:Ls(t.p),q:Ls(t.q),dp:Ls(t.dP),dq:Ls(t.dQ),qi:Ls(t.qInv),alg:"RS256"}}function VI(n,e){return e.map(t=>gs(n[t]))}function UF(n){return $0.apply(this,arguments)}function $0(){return $0=j(function*(n){const e=yield ks.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:n,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=yield KI(e);return{privateKey:t[0],publicKey:t[1]}}),$0.apply(this,arguments)}function HI(n){return j0.apply(this,arguments)}function j0(){return j0=j(function*(n){const t=[yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),yield KF(n)],r=yield KI({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}),j0.apply(this,arguments)}function G0(){return G0=j(function*(n,e){const t=yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=yield ks.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,Uint8Array.from(e));return new Uint8Array(r,0,r.byteLength)}),G0.apply(this,arguments)}function z0(){return z0=j(function*(n,e,t){const r=yield ks.get().subtle.importKey("jwk",n,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return yield ks.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},r,e,t)}),z0.apply(this,arguments)}function KI(n){return W0.apply(this,arguments)}function W0(){return W0=j(function*(n){if(null==n.privateKey||null==n.publicKey)throw ae(new Error("Private and public key are required"),"ERR_INVALID_PARAMETERS");return yield Promise.all([ks.get().subtle.exportKey("jwk",n.privateKey),ks.get().subtle.exportKey("jwk",n.publicKey)])}),W0.apply(this,arguments)}function KF(n){return q0.apply(this,arguments)}function q0(){return q0=j(function*(n){return yield ks.get().subtle.importKey("jwk",{kty:n.kty,n:n.n,e:n.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}),q0.apply(this,arguments)}function $I(n,e,t,r){const i=e?function FF(n){return Un.pki.setRsaPublicKey(...VI(n,["n","e"]))}(n):function BF(n){return Un.pki.setRsaPrivateKey(...VI(n,["n","e","d","p","q","dp","dq","qi"]))}(n);return Ot(r(Lt(Uint8Array.from(t),"ascii"),i),"ascii")}function Y0(n,e){return Q0.apply(this,arguments)}function Q0(){return Q0=j(function*(n,e){const r=yield vI().encrypt(n,e);return jd.encode(r)}),Q0.apply(this,arguments)}Object.defineProperties(Yr,{sha256Sync:{configurable:!1,get:()=>jc,set(n){jc||(jc=n)}},hmacSha256Sync:{configurable:!1,get:()=>_l,set(n){_l||(_l=n)}}}),x(5517);class Z0{constructor(e){this._key=e}verify(e,t){var r=this;return j(function*(){return yield function HF(n,e,t){return z0.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function LF(n){if(null==n.n||null==n.e)throw ae(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Un.pki.publicKeyToAsn1({n:gs(n.n),e:gs(n.e)});return Ot(Un.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return kc.encode({Type:tr.RSA,Data:this.marshal()}).subarray()}encrypt(e){return function $F(n,e){return $I(n,!0,e,(t,r)=>r.encrypt(t))}(this._key,e)}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class rh{constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return nh(16)}sign(e){var t=this;return j(function*(){return yield function VF(n,e){return G0.apply(this,arguments)}(t._key,e)})()}get public(){if(null==this._publicKey)throw ae(new Error("public key not provided"),"ERR_PUBKEY_NOT_PROVIDED");return new Z0(this._publicKey)}decrypt(e){return function jF(n,e){return $I(n,!1,e,(t,r)=>r.decrypt(t))}(this._key,e)}marshal(){return function OF(n){if(null==n.n||null==n.e||null==n.d||null==n.p||null==n.q||null==n.dp||null==n.dq||null==n.qi)throw ae(new Error("JWK was missing components"),"ERR_INVALID_PARAMETERS");const e=Un.pki.privateKeyToAsn1({n:gs(n.n),e:gs(n.e),d:gs(n.d),p:gs(n.p),q:gs(n.q),dP:gs(n.dp),dQ:gs(n.dq),qInv:gs(n.qi)});return Ot(Un.asn1.toDer(e).getBytes(),"ascii")}(this._key)}get bytes(){return Lc.encode({Type:tr.RSA,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){return Lt(yield e.public.hash(),"base58btc")})()}export(e,t="pkcs-8"){var r=this;return j(function*(){if("pkcs-8"===t){const i=new Un.util.ByteBuffer(r.marshal()),s=Un.asn1.fromDer(i),o=Un.pki.privateKeyFromAsn1(s);return Un.pki.encryptRsaPrivateKey(o,e,{algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"})}if("libp2p-key"===t)return yield Y0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function GF(n){return X0.apply(this,arguments)}function X0(){return X0=j(function*(n){const e=MF(n),t=yield HI(e);return new rh(t.privateKey,t.publicKey)}),X0.apply(this,arguments)}function zF(n){const e=function kF(n){const e=Un.asn1.fromDer(Lt(n,"ascii")),t=Un.pki.publicKeyFromAsn1(e);return{kty:"RSA",n:Ls(t.n),e:Ls(t.e)}}(n);return new Z0(e)}function WF(n){return J0.apply(this,arguments)}function J0(){return J0=j(function*(n){const e=yield HI(n);return new rh(e.privateKey,e.publicKey)}),J0.apply(this,arguments)}function qF(n){return em.apply(this,arguments)}function em(){return em=j(function*(n){const e=yield UF(n);return new rh(e.privateKey,e.publicKey)}),em.apply(this,arguments)}var YF=x(7420),QF=x.t(YF,2);const ar=BigInt(0),an=BigInt(1),Wc=BigInt(2),jI=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),Vn=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:jI,n:jI,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),GI=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),Sl=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),ZF=(BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742"),BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235")),XF=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),JF=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),e5=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class wn{constructor(e,t,r,i){this.x=e,this.y=t,this.z=r,this.t=i}static fromAffine(e){if(!(e instanceof nr))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(nr.ZERO)?wn.ZERO:new wn(e.x,e.y,an,Me(e.x*e.y))}static toAffineBatch(e){const t=function r5(n,e=Vn.P){const t=new Array(n.length),i=ih(n.reduce((s,o,a)=>o===ar?s:(t[a]=s,Me(s*o,e)),an),e);return n.reduceRight((s,o,a)=>o===ar?s:(t[a]=Me(s*t[a],e),Me(s*o,e)),i),t}(e.map(r=>r.z));return e.map((r,i)=>r.toAffine(t[i]))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){zI(e);const{x:t,y:r,z:i}=this,{x:s,y:o,z:a}=e,u=Me(t*a),_=Me(s*i),R=Me(r*a),N=Me(o*i);return u===_&&R===N}negate(){return new wn(Me(-this.x),this.y,this.z,Me(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:i}=Vn,s=Me(e*e),o=Me(t*t),a=Me(Wc*Me(r*r)),u=Me(i*s),_=e+t,R=Me(Me(_*_)-s-o),N=u+o,B=N-a,K=u-o,Z=Me(R*B),J=Me(N*K),oe=Me(R*K),he=Me(B*N);return new wn(Z,J,he,oe)}add(e){zI(e);const{x:t,y:r,z:i,t:s}=this,{x:o,y:a,z:u,t:_}=e,R=Me((r-t)*(a+o)),N=Me((r+t)*(a-o)),B=Me(N-R);if(B===ar)return this.double();const K=Me(i*Wc*_),Z=Me(s*Wc*u),J=Z+K,oe=N+R,he=Z-K,Ie=Me(J*B),ue=Me(oe*he),Re=Me(J*he),ze=Me(B*oe);return new wn(Ie,ue,ze,Re)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let i=this,s=i;for(let o=0;o>=N,Z>u&&(Z-=R,e+=an),0===Z){let J=i[K];B%2&&(J=J.negate()),o=o.add(J)}else{let J=i[K+Math.abs(Z)-1];Z<0&&(J=J.negate()),s=s.add(J)}}return wn.normalizeZ([s,o])[0]}multiply(e,t){return this.wNAF(Zc(e,Vn.l),t)}multiplyUnsafe(e){let t=Zc(e,Vn.l,!1);const r=wn.BASE,i=wn.ZERO;if(t===ar)return i;if(this.equals(i)||t===an)return this;if(this.equals(r))return this.wNAF(t);let s=i,o=this;for(;t>ar;)t&an&&(s=s.add(o)),o=o.double(),t>>=an;return s}isSmallOrder(){return this.multiplyUnsafe(Vn.h).equals(wn.ZERO)}isTorsionFree(){return this.multiplyUnsafe(Vn.l).equals(wn.ZERO)}toAffine(e=ih(this.z)){const{x:t,y:r,z:i}=this,s=Me(t*e),o=Me(r*e);if(Me(i*e)!==an)throw new Error("invZ was invalid");return new nr(s,o)}fromRistrettoBytes(){nm()}toRistrettoBytes(){nm()}fromRistrettoHash(){nm()}}function zI(n){if(!(n instanceof wn))throw new TypeError("ExtendedPoint expected")}function tm(n){if(!(n instanceof Wi))throw new TypeError("RistrettoPoint expected")}function nm(){throw new Error("Legacy method: switch to RistrettoPoint")}wn.BASE=new wn(Vn.Gx,Vn.Gy,an,Me(Vn.Gx*Vn.Gy)),wn.ZERO=new wn(ar,an,an,ar);class Wi{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=Vn,r=Me(Sl*e*e),i=Me((r+an)*JF);let s=BigInt(-1);const o=Me((s-t*r)*Me(r+t));let{isValid:a,value:u}=om(i,o),_=Me(u*e);$o(_)||(_=Me(-_)),a||(u=_),a||(s=r);const R=Me(s*(r-an)*e5-o),N=u*u,B=Me((u+u)*o),K=Me(R*ZF),Z=Me(an-N),J=Me(an+N);return new wn(Me(B*J),Me(Z*K),Me(K*J),Me(B*Z))}static hashToCurve(e){const t=sm((e=ms(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),i=sm(e.slice(32,64)),s=this.calcElligatorRistrettoMap(i);return new Wi(r.add(s))}static fromHex(e){e=ms(e,32);const{a:t,d:r}=Vn,i="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",s=sm(e);if(!function i5(n,e){if(n.length!==e.length)return!1;for(let t=0;t=i)throw new Error("Expected 0 < hex < P");if(!t&&o>=GI)throw new Error("Expected 0 < hex < 2**256");const a=Me(o*o),u=Me(a-an),_=Me(r*a+an);let{isValid:R,value:N}=om(u,_);if(!R)throw new Error("Point.fromHex: invalid y coordinate");return 0!=(128&e[31])!=((N&an)===an)&&(N=Me(-N)),new nr(N,o)}static fromPrivateKey(e){return j(function*(){return(yield Tl(e)).point})()}toRawBytes(){const e=Yc(this.y);return e[31]|=this.x&an?128:0,e}toHex(){return Cl(this.toRawBytes())}toX25519(){const{y:e}=this;return Yc(Me((an+e)*ih(an-e)))}isTorsionFree(){return wn.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new nr(Me(-this.x),this.y)}add(e){return wn.fromAffine(this).add(wn.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return wn.fromAffine(this).multiply(e,this).toAffine()}}nr.BASE=new nr(Vn.Gx,Vn.Gy),nr.ZERO=new nr(ar,an);class qc{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=ms(e,64),r=nr.fromHex(t.slice(0,32),!1),i=Da(t.slice(32,64));return new qc(r,i)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof nr))throw new Error("Expected Point instance");return Zc(t,Vn.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(Yc(this.s),32),e}toHex(){return Cl(this.toRawBytes())}}function WI(...n){if(!n.every(r=>r instanceof Uint8Array))throw new Error("Expected Uint8Array list");if(1===n.length)return n[0];const e=n.reduce((r,i)=>r+i.length,0),t=new Uint8Array(e);for(let r=0,i=0;re.toString(16).padStart(2,"0"));function Cl(n){if(!(n instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let t=0;t=ar?t:e+t}function ih(n,e=Vn.P){if(n===ar||e<=ar)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=Me(n,e),r=e,i=ar,s=an,o=an,a=ar;for(;t!==ar;){const _=r/t,R=r%t,N=i-o*_,B=s-a*_;r=t,t=R,i=o,s=a,o=N,a=B}if(r!==an)throw new Error("invert: does not exist");return Me(i,e)}function ys(n,e){const{P:t}=Vn;let r=n;for(;e-- >ar;)r*=r,r%=t;return r}function om(n,e){const t=Me(e*e*e),r=Me(t*t*e);let s=Me(n*t*function YI(n){const{P:e}=Vn,t=BigInt(5),r=BigInt(10),i=BigInt(20),s=BigInt(40),o=BigInt(80),u=n*n%e*n%e,_=ys(u,Wc)*u%e,R=ys(_,an)*n%e,N=ys(R,t)*R%e,B=ys(N,r)*N%e,K=ys(B,i)*B%e,Z=ys(K,s)*K%e,J=ys(Z,o)*Z%e,oe=ys(J,o)*Z%e,he=ys(oe,r)*N%e;return{pow_p_5_8:ys(he,Wc)*n%e,b2:u}}(n*r).pow_p_5_8);const o=Me(e*s*s),a=s,u=Me(s*Sl),_=o===n,R=o===Me(-n),N=o===Me(-n*Sl);return _&&(s=a),(R||N)&&(s=u),$o(s)&&(s=Me(-s)),{isValid:_||R,value:s}}function QI(n){return om(an,n)}function Qc(n){return Me(Da(n),Vn.l)}function ms(n,e){const t=n instanceof Uint8Array?Uint8Array.from(n):im(n);if("number"==typeof e&&t.length!==e)throw new Error(`Expected ${e} bytes`);return t}function Zc(n,e,t=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof n&&Number.isSafeInteger(n)&&(n=BigInt(n)),"bigint"==typeof n&&n{if((n=ms(n)).length<40||n.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Me(Da(n),Vn.l-an)+an},randomBytes:(n=32)=>{if(jo.web)return jo.web.getRandomValues(new Uint8Array(n));if(jo.node){const{randomBytes:e}=jo.node;return new Uint8Array(e(n).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Sa.randomBytes(32),sha512:function(){var n=j(function*(...e){const t=WI(...e);if(jo.web){const r=yield jo.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(r)}if(jo.node)return Uint8Array.from(jo.node.createHash("sha512").update(t).digest());throw new Error("The environment doesn't have sha512 function")});return function(){return n.apply(this,arguments)}}(),precompute(n=8,e=nr.BASE){const t=e.equals(nr.BASE)?e:new nr(e.x,e.y);return t._setWindowSize(n),t.multiply(Wc),t},sha512Sync:void 0};function p5(){return pm.apply(this,arguments)}function pm(){return pm=j(function*(){const n=Sa.randomPrivateKey(),e=yield e2(n);return{privateKey:r2(n,e),publicKey:e}}),pm.apply(this,arguments)}function g5(n){return gm.apply(this,arguments)}function gm(){return gm=j(function*(n){if(32!==n.length)throw new TypeError('"seed" must be 32 bytes in length.');if(!(n instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const e=n,t=yield e2(e);return{privateKey:r2(e,t),publicKey:t}}),gm.apply(this,arguments)}function ym(){return ym=j(function*(n,e){const t=n.slice(0,32);return yield a5(e,t)}),ym.apply(this,arguments)}function mm(){return mm=j(function*(n,e,t){return yield u5(e,t,n)}),mm.apply(this,arguments)}function r2(n,e){const t=new Uint8Array(64);for(let r=0;r<32;r++)t[r]=n[r],t[32+r]=e[r];return t}Object.defineProperties(Sa,{sha512Sync:{configurable:!1,get:()=>Il,set(n){Il||(Il=n)}}});class vm{constructor(e){this._key=Xc(e,32)}verify(e,t){var r=this;return j(function*(){return yield function m5(n,e,t){return mm.apply(this,arguments)}(r._key,t,e)})()}marshal(){return this._key}get bytes(){return kc.encode({Type:tr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class xl{constructor(e,t){this._key=Xc(e,64),this._publicKey=Xc(t,32)}sign(e){var t=this;return j(function*(){return yield function y5(n,e){return ym.apply(this,arguments)}(t._key,e)})()}get public(){return new vm(this._publicKey)}marshal(){return this._key}get bytes(){return Lc.encode({Type:tr.Ed25519,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){const t=yield Uc.digest(e.public.bytes);return ui.encode(t.bytes).substring(1)})()}export(e,t="libp2p-key"){var r=this;return j(function*(){if("libp2p-key"===t)return yield Y0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function v5(n){if(n.length>64){const r=(n=Xc(n,96)).slice(0,64),i=n.slice(64,n.length);return new xl(r,i)}const e=(n=Xc(n,64)).slice(0,64),t=n.slice(32);return new xl(e,t)}function E5(n){return n=Xc(n,32),new vm(n)}function b5(){return Em.apply(this,arguments)}function Em(){return Em=j(function*(){const{privateKey:n,publicKey:e}=yield p5();return new xl(n,e)}),Em.apply(this,arguments)}function w5(n){return bm.apply(this,arguments)}function bm(){return bm=j(function*(n){const{privateKey:e,publicKey:t}=yield g5(n);return new xl(e,t)}),bm.apply(this,arguments)}function Xc(n,e){if((n=Uint8Array.from(n??[])).length!==e)throw ae(new Error(`Key must be a Uint8Array of length ${e}, got ${n.length}`),"ERR_INVALID_KEY_TYPE");return n}function _5(){return Yr.randomPrivateKey()}function wm(){return wm=j(function*(n,e){const{digest:t}=yield mi.digest(e);try{return yield OI(t,n)}catch(r){throw ae(r,"ERR_INVALID_INPUT")}}),wm.apply(this,arguments)}function _m(){return _m=j(function*(n,e,t){try{const{digest:r}=yield mi.digest(t);return xF(e,r,n)}catch(r){throw ae(r,"ERR_INVALID_INPUT")}}),_m.apply(this,arguments)}function i2(n){try{In.fromHex(n)}catch(e){throw ae(e,"ERR_INVALID_PUBLIC_KEY")}}class Dm{constructor(e){i2(e),this._key=e}verify(e,t){var r=this;return j(function*(){return yield function S5(n,e,t){return _m.apply(this,arguments)}(r._key,t,e)})()}marshal(){return function C5(n){return In.fromHex(n).toRawBytes(!0)}(this._key)}get bytes(){return kc.encode({Type:tr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}}class Sm{constructor(e,t){this._key=e,this._publicKey=t??function T5(n){try{return Dl(n,!0)}catch(e){throw ae(e,"ERR_INVALID_PRIVATE_KEY")}}(e),function I5(n){try{Dl(n,!0)}catch(e){throw ae(e,"ERR_INVALID_PRIVATE_KEY")}}(this._key),i2(this._publicKey)}sign(e){var t=this;return j(function*(){return yield function D5(n,e){return wm.apply(this,arguments)}(t._key,e)})()}get public(){return new Dm(this._publicKey)}marshal(){return this._key}get bytes(){return Lc.encode({Type:tr.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return kr(this.bytes,e.bytes)}hash(){var e=this;return j(function*(){const{bytes:t}=yield mi.digest(e.bytes);return t})()}id(){var e=this;return j(function*(){return Lt(yield e.public.hash(),"base58btc")})()}export(e,t="libp2p-key"){var r=this;return j(function*(){if("libp2p-key"===t)return yield Y0(r.bytes,e);throw ae(new Error(`export format '${t}' is not supported`),"ERR_INVALID_EXPORT_FORMAT")})()}}function A5(n){return new Sm(n)}function x5(n){return new Dm(n)}function R5(){return Cm.apply(this,arguments)}function Cm(){return Cm=j(function*(){const n=yield _5();return new Sm(n)}),Cm.apply(this,arguments)}const lo={rsa:I,ed25519:A,secp256k1:P};function Im(n){const e=Object.keys(lo).join(" / ");return ae(new Error(`invalid or unsupported key type ${n}. Must be ${e}`),"ERR_UNSUPPORTED_KEY_TYPE")}function Tm(n){if("rsa"===(n=n.toLowerCase())||"ed25519"===n||"secp256k1"===n)return lo[n];throw Im(n)}function s2(n,e){return Am.apply(this,arguments)}function Am(){return Am=j(function*(n,e){return yield Tm(n).generateKeyPair(e??2048)}),Am.apply(this,arguments)}function Rl(n){const e=kc.decode(n),t=e.Data;switch(e.Type){case tr.RSA:return lo.rsa.unmarshalRsaPublicKey(t);case tr.Ed25519:return lo.ed25519.unmarshalEd25519PublicKey(t);case tr.Secp256k1:return lo.secp256k1.unmarshalSecp256k1PublicKey(t);default:throw Im(e.Type)}}function o2(n,e){return Tm(e=(e??"rsa").toLowerCase()),n.bytes}function Pl(n){return Rm.apply(this,arguments)}function Rm(){return Rm=j(function*(n){const e=Lc.decode(n),t=e.Data;switch(e.Type){case tr.RSA:return yield lo.rsa.unmarshalRsaPrivateKey(t);case tr.Ed25519:return lo.ed25519.unmarshalEd25519PrivateKey(t);case tr.Secp256k1:return lo.secp256k1.unmarshalSecp256k1PrivateKey(t);default:throw Im(e.Type)}}),Rm.apply(this,arguments)}function P5(n,e){return Tm(e=(e??"rsa").toLowerCase()),n.bytes}function Pm(n,e){return Nm.apply(this,arguments)}function Nm(){return Nm=j(function*(n,e){try{const i=yield gF(n,e);return yield Pl(i)}catch{}const t=Un.pki.decryptRsaPrivateKey(n,e);if(null===t)throw ae(new Error("Cannot read the key, most likely the password is wrong or not a RSA key"),"ERR_CANNOT_DECRYPT_PEM");let r=Un.asn1.toDer(Un.pki.privateKeyToAsn1(t));return r=Ot(r.getBytes(),"ascii"),yield lo.rsa.unmarshalRsaPrivateKey(r)}),Nm.apply(this,arguments)}const a2=Symbol.for("@libp2p/peer-id");function c2(n){return null!=n&&Boolean(n[a2])}const u2=Object.values(El).map(n=>n.decoder).reduce((n,e)=>n.or(e),El.identity.decoder);class ch{constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}get[a2](){return!0}toString(){return null==this.string&&(this.string=ui.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return _r.createV1(114,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(e instanceof Uint8Array)return kr(this.multihash.bytes,e);if("string"==typeof e)return fr(e).equals(this);if(null!=e?.multihash?.bytes)return kr(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}}class Nl extends ch{constructor(e){super({...e,type:"RSA"}),this.type="RSA",this.publicKey=e.publicKey}}class Ml extends ch{constructor(e){super({...e,type:"Ed25519"}),this.type="Ed25519",this.publicKey=e.multihash.digest}}class Ol extends ch{constructor(e){super({...e,type:"secp256k1"}),this.type="secp256k1",this.publicKey=e.multihash.digest}}function Br(n){if("RSA"===n.type)return new Nl(n);if("Ed25519"===n.type)return new Ml(n);if("secp256k1"===n.type)return new Ol(n);throw ae(new Error("Not a PeerId"),"ERR_INVALID_PARAMETERS")}function fr(n,e){if(e=e??u2,"1"===n.charAt(0)||"Q"===n.charAt(0)){const t=qd(ui.decode(`z${n}`));return n.startsWith("12D")?new Ml({multihash:t}):n.startsWith("16U")?new Ol({multihash:t}):new Nl({multihash:t})}return Jc(u2.decode(n))}function Jc(n){try{const e=qd(n);if(e.code===Uc.code){if(36===e.digest.length)return new Ml({multihash:e});if(37===e.digest.length)return new Ol({multihash:e})}if(e.code===mi.code)return new Nl({multihash:e})}catch{return function N5(n){if(null==n||null==n.multihash||null==n.version||1===n.version&&114!==n.code)throw new Error("Supplied PeerID CID is invalid");const e=n.multihash;if(e.code===mi.code)return new Nl({multihash:n.multihash});if(e.code===Uc.code){if(36===e.digest.length)return new Ml({multihash:n.multihash});if(37===e.digest.length)return new Ol({multihash:n.multihash})}throw new Error("Supplied PeerID CID is invalid")}(_r.decode(n))}throw new Error("Supplied PeerID CID is invalid")}function kl(n,e){return km.apply(this,arguments)}function km(){return km=j(function*(n,e){return 36===n.length?new Ml({multihash:Fc(Uc.code,n),privateKey:e}):37===n.length?new Ol({multihash:Fc(Uc.code,n),privateKey:e}):new Nl({multihash:yield mi.digest(n),publicKey:n,privateKey:e})}),km.apply(this,arguments)}var Lm;!function(n){let e;!function(t){let r;t.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.identityKey)throw new Error('Protocol error: required field "identityKey" was not found in object');if(s.uint32(10),s.bytes(i.identityKey),null==i.identitySig)throw new Error('Protocol error: required field "identitySig" was not found in object');if(s.uint32(18),s.bytes(i.identitySig),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(26),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={identityKey:new Uint8Array(0),identitySig:new Uint8Array(0),data:new Uint8Array(0)},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.identityKey=i.bytes();break;case 2:o.identitySig=i.bytes();break;case 3:o.data=i.bytes();break;default:i.skipType(7&u)}}if(null==o.identityKey)throw new Error('Protocol error: value for required field "identityKey" was not found in protobuf');if(null==o.identitySig)throw new Error('Protocol error: value for required field "identitySig" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),t.encode=i=>qt(i,t.codec()),t.decode=i=>Wt(i,t.codec())}(e=n.NoiseHandshakePayload||(n.NoiseHandshakePayload={}))}(Lm||(Lm={}));const f2=Lm.NoiseHandshakePayload;function Bm(){return Bm=j(function*(n,e,t){const r=yield k5(n,p2(e)),i=t??new Uint8Array(0);if(null==n.publicKey)throw new Error("PublicKey was missing from local PeerId");return O5(n.publicKey,r,i)}),Bm.apply(this,arguments)}function O5(n,e,t){return f2.encode({identityKey:n,identitySig:e,data:t??new Uint8Array(0)}).subarray()}function k5(n,e){return Fm.apply(this,arguments)}function Fm(){return Fm=j(function*(n,e){if(null==n.privateKey)throw new Error("PrivateKey was missing from PeerId");return yield(yield Pl(n.privateKey)).sign(e)}),Fm.apply(this,arguments)}function d2(n){return Um.apply(this,arguments)}function Um(){return Um=j(function*(n){return yield kl(n.identityKey)}),Um.apply(this,arguments)}function h2(n){return f2.decode(n)}function p2(n){const e=Ot("noise-libp2p-static-key:");return wr([e,n],e.length+n.length)}function g2(n,e,t){return Vm.apply(this,arguments)}function Vm(){return Vm=j(function*(n,e,t){const r=yield kl(e.identityKey);if(!r.equals(t))throw new Error("Peer ID doesn't match libp2p public key.");const i=p2(n);if(null==r.publicKey)throw new Error("PublicKey was missing from PeerId");if(null==e.identitySig)throw new Error("Signature was missing from message");if(!(yield Rl(r.publicKey).verify(i,e.identitySig)))throw new Error("Static key doesn't match to peer that signed payload!");return r}),Vm.apply(this,arguments)}function uh(n){return!(!(n instanceof Uint8Array)||32!==n.length)}var dr=x(1455);function Gt(n){return Object.assign(dr(n),{error:dr(`${n}:error`),trace:dr(`${n}:trace`)})}dr.formatters.b=n=>null==n?"undefined":ui.baseEncode(n),dr.formatters.t=n=>null==n?"undefined":co.baseEncode(n),dr.formatters.m=n=>null==n?"undefined":jd.baseEncode(n),dr.formatters.p=n=>null==n?"undefined":n.toString(),dr.formatters.c=n=>null==n?"undefined":n.toString(),dr.formatters.k=n=>null==n?"undefined":n.toString();const Qr=Gt("libp2p:noise");let qi;function y2(n){n?(qi(`LOCAL_PUBLIC_EPHEMERAL_KEY ${Lt(n.publicKey,"hex")}`),qi(`LOCAL_PRIVATE_EPHEMERAL_KEY ${Lt(n.privateKey,"hex")}`)):qi("Missing local ephemeral keys.")}function m2(n){qi(`REMOTE_EPHEMERAL_PUBLIC_KEY ${Lt(n,"hex")}`)}qi=xB?Qr:Object.assign(()=>{},{enabled:!1,trace:()=>{},error:()=>{}});class K5{constructor(e=0){this.n=e,this.bytes=new Uint8Array(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>4294967295)throw new Error("Cipherstate has reached maximum n, a new handshake must be performed")}}class j5 extends class $5{constructor(e){this.crypto=e}encryptWithAd(e,t,r){const i=this.encrypt(e.k,e.n,t,r);return e.n.increment(),i}decryptWithAd(e,t,r){const{plaintext:i,valid:s}=this.decrypt(e.k,e.n,t,r);return s&&e.n.increment(),{plaintext:i,valid:s}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return new Uint8Array(32)}isEmptyKey(e){return kr(this.createEmptyKey(),e)}encrypt(e,t,r,i){return t.assertValue(),this.crypto.chaCha20Poly1305Encrypt(i,t.getBytes(),r,e)}encryptAndHash(e,t){let r;return r=this.hasKey(e.cs)?this.encryptWithAd(e.cs,e.h,t):t,this.mixHash(e,r),r}decrypt(e,t,r,i){t.assertValue();const s=this.crypto.chaCha20Poly1305Decrypt(i,t.getBytes(),r,e);return s?{plaintext:s,valid:!0}:{plaintext:new Uint8Array(0),valid:!1}}decryptAndHash(e,t){let r,i=!0;return this.hasKey(e.cs)?({plaintext:r,valid:i}=this.decryptWithAd(e.cs,e.h,t)):r=t,this.mixHash(e,t),{plaintext:r,valid:i}}dh(e,t){try{const r=this.crypto.generateX25519SharedKey(e,t);return 32===r.length?r:r.subarray(0,32)}catch(r){return Qr(r.message),new Uint8Array(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(wr([e,t],e.length+t.length))}mixKey(e,t){const[r,i]=this.crypto.getHKDF(e.ck,t);e.cs=this.initializeKey(i),e.ck=r}initializeKey(e){return{k:e,n:new K5}}initializeSymmetric(e){const t=Ot(e,"utf-8"),r=this.hashProtocolName(t),i=r,s=this.createEmptyKey();return{cs:this.initializeKey(s),ck:i,h:r}}hashProtocolName(e){if(e.length<=32){const t=new Uint8Array(32);return t.set(e),t}return this.getHash(e,new Uint8Array(0))}split(e){const[t,r]=this.crypto.getHKDF(e.ck,new Uint8Array(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,new Uint8Array(0),t);return{ne:this.createEmptyKey(),ns:new Uint8Array(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,new Uint8Array(0),t.ciphertext)}}{initializeInitiator(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}initializeResponder(e,t,r,i){const o=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");return this.mixHash(o,e),{ss:o,s:t,rs:r,psk:i,re:new Uint8Array(32)}}writeMessageA(e,t,r){const i=new Uint8Array(0);e.e=void 0!==r?r:this.crypto.generateX25519KeyPair();const s=e.e.publicKey;return this.mixHash(e.ss,s),{ne:s,ns:i,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=this.crypto.generateX25519KeyPair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const s=this.encryptAndHash(e.ss,e.s.publicKey);return this.mixKey(e.ss,this.dh(e.s.privateKey,e.re)),{ne:r,ns:s,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const i=this.encryptAndHash(e.ss,e.s.publicKey);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const s=this.encryptAndHash(e.ss,t),a={ne:this.createEmptyKey(),ns:i,ciphertext:s},{cs1:u,cs2:_}=this.split(e.ss);return{h:e.ss.h,messageBuffer:a,cs1:u,cs2:_}}readMessageA(e,t){return uh(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(uh(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);i&&uh(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:s,valid:i&&o}}readMessageC(e,t){const{plaintext:r,valid:i}=this.decryptAndHash(e.ss,t.ns);if(i&&uh(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:s,valid:o}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:a,cs2:u}=this.split(e.ss);return{h:e.ss.h,plaintext:s,valid:i&&o,cs1:a,cs2:u}}initSession(e,t,r){const i=this.createEmptyKey(),s=new Uint8Array(32);let o;return o=e?this.initializeInitiator(t,r,s,i):this.initializeResponder(t,r,s,i),{hs:o,i:e,mc:0}}sendMessage(e,t,r){let i;if(0===e.mc)i=this.writeMessageA(e.hs,t,r);else if(1===e.mc)i=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:s,messageBuffer:o,cs1:a,cs2:u}=this.writeMessageC(e.hs,t);i=o,e.h=s,e.cs1=a,e.cs2=u}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");i=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");i=this.writeMessageRegular(e.cs2,t)}}return e.mc++,i}recvMessage(e,t){let r=new Uint8Array(0),i=!1;if(0===e.mc)({plaintext:r,valid:i}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:i}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:s,plaintext:o,valid:a,cs1:u,cs2:_}=this.readMessageC(e.hs,t);r=o,i=a,e.h=s,e.cs1=u,e.cs2=_}return e.mc++,{plaintext:r,valid:i}}}class G5{constructor(e,t,r,i,s,o,a,u){this.isInitiator=e,this.payload=t,this.prologue=r,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=u??new j5(i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair),this.remoteEarlyData=new Uint8Array(0)}propose(){var e=this;return j(function*(){if(function L5(n){qi(`LOCAL_STATIC_PUBLIC_KEY ${Lt(n.publicKey,"hex")}`),qi(`LOCAL_STATIC_PRIVATE_KEY ${Lt(n.privateKey,"hex")}`)}(e.session.hs.s),e.isInitiator){Qr("Stage 0 - Initiator starting to send first message.");const t=e.xx.sendMessage(e.session,new Uint8Array(0));e.connection.writeLP(function MB(n){return wr([n.ne,n.ciphertext],n.ne.length+n.ciphertext.length)}(t)),Qr("Stage 0 - Initiator finished sending first message."),y2(e.session.hs.e)}else{Qr("Stage 0 - Responder waiting to receive first message...");const t=function LB(n){if(n.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:n.subarray(0,32),ciphertext:n.subarray(32,n.length),ns:new Uint8Array(0)}}((yield e.connection.readLP()).subarray()),{valid:r}=e.xx.recvMessage(e.session,t);if(!r)throw new Oc("xx handshake stage 0 validation fail");Qr("Stage 0 - Responder received first message."),m2(e.session.hs.re)}})()}exchange(){var e=this;return j(function*(){if(e.isInitiator){Qr("Stage 1 - Initiator waiting to receive first message from responder...");const t=function BB(n){if(n.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:n.subarray(0,32),ns:n.subarray(32,80),ciphertext:n.subarray(80,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Oc("xx handshake stage 1 validation fail");Qr("Stage 1 - Initiator received the message."),m2(e.session.hs.re),function B5(n){qi(`REMOTE_STATIC_PUBLIC_KEY ${Lt(n,"hex")}`)}(e.session.hs.rs),Qr("Initiator going to check remote's signature...");try{const s=h2(r);e.remotePeer=e.remotePeer||(yield d2(s)),yield g2(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new Hd(`Error occurred while verifying signed payload: ${s.message}`)}Qr("All good with the signature!")}else{Qr("Stage 1 - Responder sending out first message with signed payload and static key.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function OB(n){return wr([n.ne,n.ns,n.ciphertext],n.ne.length+n.ns.length+n.ciphertext.length)}(t)),Qr("Stage 1 - Responder sent the second handshake message with signed payload."),y2(e.session.hs.e)}})()}finish(){var e=this;return j(function*(){if(e.isInitiator){Qr("Stage 2 - Initiator sending third handshake message.");const t=e.xx.sendMessage(e.session,e.payload);e.connection.writeLP(function kB(n){return wr([n.ns,n.ciphertext],n.ns.length+n.ciphertext.length)}(t)),Qr("Stage 2 - Initiator sent message with signed payload.")}else{Qr("Stage 2 - Responder waiting for third handshake message...");const t=function FB(n){if(n.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:new Uint8Array(0),ns:n.subarray(0,48),ciphertext:n.subarray(48,n.length)}}((yield e.connection.readLP()).subarray()),{plaintext:r,valid:i}=e.xx.recvMessage(e.session,t);if(!i)throw new Oc("xx handshake stage 2 validation fail");Qr("Stage 2 - Responder received the message, finished handshake.");try{const s=h2(r);e.remotePeer=e.remotePeer||(yield d2(s)),yield g2(e.session.hs.rs,s,e.remotePeer),e.setRemoteEarlyData(s.data)}catch(s){throw new Hd(`Error occurred while verifying signed payload: ${s.message}`)}}!function F5(n){n.cs1&&n.cs2?(qi(`CIPHER_STATE_1 ${n.cs1.n.getUint64()} ${Lt(n.cs1.k,"hex")}`),qi(`CIPHER_STATE_2 ${n.cs2.n.getUint64()} ${Lt(n.cs2.k,"hex")}`)):qi("Missing cipher state.")}(e.session)})()}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,new Uint8Array(0),e)}decrypt(e,t){const r=this.getCS(t,!1);return this.xx.decryptWithAd(r,new Uint8Array(0),e)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e,t=!0){if(!e.cs1||!e.cs2)throw new Oc("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteEarlyData(e){e&&(this.remoteEarlyData=e)}}class z5{constructor(e,t,r=lB,i){this.protocol="/noise",this.earlyData=t??new Uint8Array(0),this.crypto=r,this.staticKeys=e?this.crypto.generateX25519KeyPairFromSeed(e):this.crypto.generateX25519KeyPair(),this.prologue=i??new Uint8Array(0)}secureOutbound(e,t,r){var i=this;return j(function*(){const s=qC(t,{lengthEncoder:Ud,lengthDecoder:Vd,maxDataLength:gl}),o=yield i.performHandshake({connection:s,isInitiator:!0,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteEarlyData:o.remoteEarlyData,remotePeer:o.remotePeer}})()}secureInbound(e,t,r){var i=this;return j(function*(){const s=qC(t,{lengthEncoder:Ud,lengthDecoder:Vd,maxDataLength:gl}),o=yield i.performHandshake({connection:s,isInitiator:!1,localPeer:e,remotePeer:r});return{conn:yield i.createSecureConnection(s,o),remoteEarlyData:o.remoteEarlyData,remotePeer:o.remotePeer}})()}performHandshake(e){var t=this;return j(function*(){const r=yield function M5(n,e,t){return Bm.apply(this,arguments)}(e.localPeer,t.staticKeys.publicKey,t.earlyData);return yield t.performXXHandshake(e,r)})()}performXXHandshake(e,t){var r=this;return j(function*(){const{isInitiator:i,remotePeer:s,connection:o}=e,a=new G5(i,t,r.prologue,r.crypto,r.staticKeys,o,s);try{yield a.propose(),yield a.exchange(),yield a.finish()}catch(u){if(u instanceof Error)throw u.message=`Error occurred during XX handshake: ${u.message}`,u}return a})()}createSecureConnection(e,t){return j(function*(){const[r,i]=function IB(){const n=YC(),e=YC();return[{source:n.source,sink:e.sink},{source:e.source,sink:n.sink}]}(),s=e.unwrap();return yield Wn(r,function RB(n){return function(){var e=dn(function*(t){var s,r=!1,i=!1;try{for(var a,o=Pt(t);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;for(let _=0;_u.length&&(R=u.length),yield n.encrypt(u.subarray(_,R),n.session)}}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),Os({lengthEncoder:Ud}),s,ps({lengthDecoder:Vd}),function PB(n){return function(){var e=dn(function*(t){var s,r=!1,i=!1;try{for(var a,o=Pt(t);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;for(let _=0;_u.length&&(R=u.length);const{plaintext:N,valid:B}=yield lt(n.decrypt(u.subarray(_,R),n.session));if(!B)throw new Error("Failed to validate decrypted chunk");yield N}}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}});return function(t){return e.apply(this,arguments)}}()}(t),r),i})()}}function fo(n){return null!=n&&"function"==typeof n.start&&"function"==typeof n.stop}function Fr(n){return null!=n&&"function"==typeof n.init}class ho{constructor(e={}){this.started=!1,null!=e.peerId&&this.setPeerId(e.peerId),null!=e.addressManager&&this.setAddressManager(e.addressManager),null!=e.peerStore&&this.setPeerStore(e.peerStore),null!=e.upgrader&&this.setUpgrader(e.upgrader),null!=e.metrics&&this.setMetrics(e.metrics),null!=e.registrar&&this.setRegistrar(e.registrar),null!=e.connectionManager&&this.setConnectionManager(e.connectionManager),null!=e.transportManager&&this.setTransportManager(e.transportManager),null!=e.connectionGater&&this.setConnectionGater(e.connectionGater),null!=e.contentRouting&&this.setContentRouting(e.contentRouting),null!=e.peerRouting&&this.setPeerRouting(e.peerRouting),null!=e.datastore&&this.setDatastore(e.datastore),null!=e.connectionProtector&&this.setConnectionProtector(e.connectionProtector),null!=e.dht&&this.setDHT(e.dht),null!=e.pubsub&&this.setPubSub(e.pubsub)}isStarted(){return this.started}beforeStart(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}()))})()}start(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){yield r.start()});return function(r){return t.apply(this,arguments)}}())),e.started=!0})()}afterStart(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}()))})()}beforeStop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}()))})()}stop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){yield r.stop()});return function(r){return t.apply(this,arguments)}}())),e.started=!1})()}afterStop(){var e=this;return j(function*(){yield Promise.all(Object.values(e).filter(t=>fo(t)).map(function(){var t=j(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}()))})()}setPeerId(e){return this.peerId=e,e}getPeerId(){if(null==this.peerId)throw ae(new Error("peerId not set"),"ERR_SERVICE_MISSING");return this.peerId}setMetrics(e){return this.metrics=e,Fr(e)&&e.init(this),e}getMetrics(){return this.metrics}setAddressManager(e){return this.addressManager=e,Fr(e)&&e.init(this),e}getAddressManager(){if(null==this.addressManager)throw ae(new Error("addressManager not set"),"ERR_SERVICE_MISSING");return this.addressManager}setPeerStore(e){return this.peerStore=e,Fr(e)&&e.init(this),e}getPeerStore(){if(null==this.peerStore)throw ae(new Error("peerStore not set"),"ERR_SERVICE_MISSING");return this.peerStore}setUpgrader(e){return this.upgrader=e,Fr(e)&&e.init(this),e}getUpgrader(){if(null==this.upgrader)throw ae(new Error("upgrader not set"),"ERR_SERVICE_MISSING");return this.upgrader}setRegistrar(e){return this.registrar=e,Fr(e)&&e.init(this),e}getRegistrar(){if(null==this.registrar)throw ae(new Error("registrar not set"),"ERR_SERVICE_MISSING");return this.registrar}setConnectionManager(e){return this.connectionManager=e,Fr(e)&&e.init(this),e}getConnectionManager(){if(null==this.connectionManager)throw ae(new Error("connectionManager not set"),"ERR_SERVICE_MISSING");return this.connectionManager}setTransportManager(e){return this.transportManager=e,Fr(e)&&e.init(this),e}getTransportManager(){if(null==this.transportManager)throw ae(new Error("transportManager not set"),"ERR_SERVICE_MISSING");return this.transportManager}setConnectionGater(e){return this.connectionGater=e,Fr(e)&&e.init(this),e}getConnectionGater(){if(null==this.connectionGater)throw ae(new Error("connectionGater not set"),"ERR_SERVICE_MISSING");return this.connectionGater}setContentRouting(e){return this.contentRouting=e,Fr(e)&&e.init(this),e}getContentRouting(){if(null==this.contentRouting)throw ae(new Error("contentRouting not set"),"ERR_SERVICE_MISSING");return this.contentRouting}setPeerRouting(e){return this.peerRouting=e,Fr(e)&&e.init(this),e}getPeerRouting(){if(null==this.peerRouting)throw ae(new Error("peerRouting not set"),"ERR_SERVICE_MISSING");return this.peerRouting}setDatastore(e){return this.datastore=e,Fr(e)&&e.init(this),e}getDatastore(){if(null==this.datastore)throw ae(new Error("datastore not set"),"ERR_SERVICE_MISSING");return this.datastore}setConnectionProtector(e){return this.connectionProtector=e,Fr(e)&&e.init(this),e}getConnectionProtector(){return this.connectionProtector}setDHT(e){return this.dht=e,Fr(e)&&e.init(this),e}getDHT(){if(null==this.dht)throw ae(new Error("dht not set"),"ERR_SERVICE_MISSING");return this.dht}setPubSub(e){return this.pubsub=e,Fr(e)&&e.init(this),e}getPubSub(){if(null==this.pubsub)throw ae(new Error("pubsub not set"),"ERR_SERVICE_MISSING");return this.pubsub}setDialer(e){return this.dialer=e,Fr(e)&&e.init(this),e}getDialer(){if(null==this.dialer)throw ae(new Error("dialer not set"),"ERR_SERVICE_MISSING");return this.dialer}}class v2 extends Error{constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function vs(n,e,t){const r=t??{},i=function W5(n){if(null!=n){if("function"==typeof n[Symbol.iterator])return n[Symbol.iterator]();if("function"==typeof n[Symbol.asyncIterator])return n[Symbol.asyncIterator]();if("function"==typeof n.next)return n}throw new Error("argument is not an iterator or iterable")}(n);function o(){return(o=dn(function*(){let a;const u=()=>{a?.()};for(e.addEventListener("abort",u);;){let _;try{if(e.aborted){const{abortMessage:N,abortCode:B}=r;throw new v2(N,B)}const R=new Promise((N,B)=>{a=()=>{const{abortMessage:K,abortCode:Z}=r;B(new v2(K,Z))}});_=yield lt(Promise.race([R,i.next()])),a=null}catch(R){e.removeEventListener("abort",u);const N="aborted"===R.type&&e.aborted;if(N&&null!=r.onAbort&&(yield lt(r.onAbort(n))),"function"==typeof i.return)try{const B=i.return();B instanceof Promise&&B.catch(K=>{null!=r.onReturnError&&r.onReturnError(K)})}catch(B){null!=r.onReturnError&&r.onReturnError(B)}if(N&&!0===r.returnOnAbort)return;throw R}if(!0===_.done)break;yield _.value}e.removeEventListener("abort",u)})).apply(this,arguments)}return function s(){return o.apply(this,arguments)}()}function q5(n,e,t){return r=>n(vs(r,e,t))}function zo(n,e,t){return{sink:q5(n.sink,e,{...t,onAbort:void 0}),source:vs(n.source,e,t)}}var hr=x(1732);function E2(n){return new Uint8Array(n)}var cn=(()=>(function(n){n[n.NEW_STREAM=0]="NEW_STREAM",n[n.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",n[n.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",n[n.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",n[n.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",n[n.RESET_RECEIVER=5]="RESET_RECEIVER",n[n.RESET_INITIATOR=6]="RESET_INITIATOR"}(cn||(cn={})),cn))();const $m=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),b2=Object.freeze({NEW_STREAM:cn.NEW_STREAM,MESSAGE:cn.MESSAGE_INITIATOR,CLOSE:cn.CLOSE_INITIATOR,RESET:cn.RESET_INITIATOR}),Y5=Object.freeze({MESSAGE:cn.MESSAGE_RECEIVER,CLOSE:cn.CLOSE_RECEIVER,RESET:cn.RESET_RECEIVER}),w2=new class Q5{constructor(){this._pool=E2(10240),this._poolOffset=0}write(e){const t=this._pool;let r=this._poolOffset;hr.encode(e.id<<3|e.type,t,r),r+=hr.encode.bytes,hr.encode(e.type!==cn.NEW_STREAM&&e.type!==cn.MESSAGE_INITIATOR&&e.type!==cn.MESSAGE_RECEIVER||null==e.data?0:e.data.length,t,r),r+=hr.encode.bytes;const i=t.subarray(this._poolOffset,r);return 10240-r<100?(this._pool=E2(10240),this._poolOffset=0):this._poolOffset=r,e.type!==cn.NEW_STREAM&&e.type!==cn.MESSAGE_INITIATOR&&e.type!==cn.MESSAGE_RECEIVER||null==e.data?[i]:[i,...e.data instanceof Uint8Array?[e.data]:e.data]}};function Gm(){return Gm=dn(function*(n){var r,e=!1,t=!1;try{for(var s,i=Pt(n);e=!(s=yield lt(i.next())).done;e=!1){const o=s.value;if(Array.isArray(o))for(const a of o)yield*Mr(Pt(w2.write(a)),lt);else yield*Mr(Pt(w2.write(o)),lt)}}catch(o){t=!0,r=o}finally{try{e&&null!=i.return&&(yield lt(i.return()))}finally{if(t)throw r}}}),Gm.apply(this,arguments)}class X5{constructor(){this._buffer=new qr,this._headerInfo=null}write(e){if(null==e||0===e.length)return[];this._buffer.append(e);const t=[];for(;0!==this._buffer.length;){if(null==this._headerInfo)try{this._headerInfo=this._decodeHeader(this._buffer)}catch{break}const{id:r,type:i,length:s,offset:o}=this._headerInfo;if(this._buffer.length-o>3,type:o,offset:r+s,length:i}}}function D2(n,e=0){let s,t=0,r=0,i=e;const o=n.length;do{if(i>=o||r>49)throw e=0,new RangeError("Could not decode varint");s=n.get(i++),t+=r<28?(127&s)<=128);return{value:t,offset:e=i-e}}function eU(n){return zm.apply(this,arguments)}function zm(){return zm=dn(function*(n){const e=new X5;var i,t=!1,r=!1;try{for(var o,s=Pt(n);t=!(o=yield lt(s.next())).done;t=!1){const u=e.write(o.value);u.length>0&&(yield u)}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield lt(s.return()))}finally{if(r)throw i}}}),zm.apply(this,arguments)}const S2=1<<20;var lh=x(772);const Es=Gt("libp2p:mplex:stream"),Wm="ERR_STREAM_RESET";class oU extends Map{constructor(e){super();const{system:t,component:r,metric:i,metrics:s}=e;this.system=t??"libp2p",this.component=r,this.metric=i,this.metrics=s,this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){const t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metrics.updateComponentMetric({system:this.system,component:this.component,metric:this.metric,value:this.size})}}function Ll(n){const{system:e,component:t,metric:r,metrics:i}=n;let s;return s=null!=i?new oU({system:e,component:t,metric:r,metrics:i}):new Map,s}var aU=x(7813);const bs=Gt("libp2p:mplex");function C2(n){const e={...n,type:`${$m[n.type]} (${n.type})`};return n.type===cn.NEW_STREAM&&(e.data=Lt(n.data instanceof Uint8Array?n.data:n.data.subarray())),(n.type===cn.MESSAGE_INITIATOR||n.type===cn.MESSAGE_RECEIVER)&&(e.data=Lt(n.data instanceof Uint8Array?n.data:n.data.subarray(),"base16")),e}class dU{constructor(e,t){this.protocol="/mplex/6.7.0",t=t??{},this._streamId=0,this._streams={initiators:Ll({metrics:e.getMetrics(),component:"mplex",metric:"initiatorStreams"}),receivers:Ll({metrics:e.getMetrics(),component:"mplex",metric:"receiverStreams"})},this._init=t,this.sink=this._createSink();const r=this._createSource();this._source=r,this.source=r,this.closeController=new AbortController,this.rateLimiter=new aU.RateLimiterMemory({points:t.disconnectThreshold??5,duration:1})}init(e){}get streams(){const e=[];for(const t of this._streams.initiators.values())e.push(t);for(const t of this._streams.receivers.values())e.push(t);return e}newStream(e){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");const t=this._streamId++;return e=null==e?t.toString():e.toString(),this._newStream({id:t,name:e,type:"initiator",registry:this._streams.initiators})}close(e){this.closeController.signal.aborted||(this.streams.forEach(null!=e?t=>t.abort(e):t=>t.close()),this.closeController.abort())}_newReceiverStream(e){const{id:t,name:r}=e;return this._newStream({id:t,name:r,type:"receiver",registry:this._streams.receivers})}_newStream(e){const{id:t,name:r,type:i,registry:s}=e;if(bs("new %s stream %s %s",i,t),"initiator"===i&&this._streams.initiators.size===(this._init.maxOutboundStreams??1024))throw ae(new Error("Too many outbound streams open"),"ERR_TOO_MANY_OUTBOUND_STREAMS");if(s.has(t))throw new Error(`${i} stream ${t} already exists!`);const u=function sU(n){const{id:e,name:t,send:r,onEnd:i,type:s="initiator",maxMsgSize:o=S2}=n,a=new AbortController,u=new AbortController,_=new AbortController,R="initiator"===s?b2:Y5,N="initiator"===s?`i${e}`:`r${e}`,B=`${t??e}`;let oe,K=!1,Z=!1,J=!1;const he={open:Date.now()},ue=Oe=>{Z||(Z=!0,Es.trace("%s stream %s sink end - err: %o",s,B,Oe),null!=Oe&&null==oe&&(oe=Oe),K&&(he.close=Date.now(),i?.(oe)))},Re=Mc({onEnd:Oe=>{K||(K=!0,Es.trace("%s stream %s source end - err: %o",s,B,Oe),null!=Oe&&null==oe&&(oe=Oe),Z&&(ze.stat.timeline.close=Date.now(),i?.(oe)))}}),ze={close:()=>{Es.trace("%s stream %s close",s,B),ze.closeRead(),ze.closeWrite()},closeRead:()=>{Es.trace("%s stream %s closeRead",s,B),!K&&Re.end()},closeWrite:()=>{if(Es.trace("%s stream %s closeWrite",s,B),!Z){_.abort();try{r({id:e,type:R.CLOSE})}catch(Oe){Es.trace("%s stream %s error sending close",s,t,Oe)}ue()}},abort:Oe=>{Es.trace("%s stream %s abort",s,B,Oe),Re.end(Oe),a.abort(),ue(Oe)},reset:()=>{const Oe=ae(new Error("stream reset"),Wm);u.abort(),Re.end(Oe),ue(Oe)},sink:(Oe=j(function*(bt){if(J)throw ae(new Error("sink already called on stream"),"ERR_DOUBLE_SINK");if(J=!0,Z)throw ae(new Error("stream closed for writing"),"ERR_SINK_ENDED");bt=vs(bt,(0,lh.anySignal)([a.signal,u.signal,_.signal]));try{"initiator"===s&&r({id:e,type:b2.NEW_STREAM,data:new qr(Ot(B))});const Yn=new qr;var Bn,vt=!1,hn=!1;try{for(var Di,cr=Pt(bt);vt=!(Di=yield cr.next()).done;vt=!1)for(Yn.append(Di.value);0!==Yn.length;){if(Yn.length<=o){r({id:e,type:R.MESSAGE,data:Yn.sublist()}),Yn.consume(Yn.length);break}r({id:e,type:R.MESSAGE,data:Yn.sublist(0,o)}),Yn.consume(o)}}catch(Do){hn=!0,Bn=Do}finally{try{vt&&null!=cr.return&&(yield cr.return())}finally{if(hn)throw Bn}}}catch(Yn){if("aborted"===Yn.type&&"The operation was aborted"===Yn.message){if(_.signal.aborted)return;u.signal.aborted&&(Yn.message="stream reset",Yn.code=Wm),a.signal.aborted&&(Yn.message="stream aborted",Yn.code="ERR_STREAM_ABORT")}if(Yn.code===Wm)Es.trace("%s stream %s reset",s,t);else{Es.trace("%s stream %s error",s,t,Yn);try{r({id:e,type:R.RESET})}catch(Do){Es.trace("%s stream %s error sending reset",s,t,Do)}}return Re.end(Yn),void ue(Yn)}try{r({id:e,type:R.CLOSE})}catch(Yn){Es.trace("%s stream %s error sending close",s,t,Yn)}ue()}),function(vt){return Oe.apply(this,arguments)}),source:Re,sourcePush:Oe=>{Re.push(Oe)},sourceReadableLength:()=>Re.readableLength,stat:{direction:"initiator"===s?"outbound":"inbound",timeline:he},metadata:{},id:N};var Oe;return ze}({id:t,name:r,send:_=>{bs.enabled&&bs.trace("%s stream %s send",i,t,C2(_)),this._source.push(_)},type:i,onEnd:()=>{bs("%s stream with id %s and protocol %s ended",i,t,u.stat.protocol),s.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(u)},maxMsgSize:this._init.maxMsgSize});return s.set(t,u),u}_createSink(){var e=this;return function(){var r=j(function*(i){const s=[e.closeController.signal];null!=e._init.signal&&s.push(e._init.signal),i=vs(i,lh(s));try{yield Wn(i,eU,function tU(n){const e=n??S2,t=r=>{if((r.type===cn.NEW_STREAM||r.type===cn.MESSAGE_INITIATOR||r.type===cn.MESSAGE_RECEIVER)&&r.data.byteLength>e)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"})};return r=>{return(i=dn(function*(){var u,o=!1,a=!1;try{for(var R,_=Pt(r);o=!(R=yield lt(_.next())).done;o=!1){const N=R.value;Array.isArray(N)?(N.forEach(t),yield*Mr(Pt(N),lt)):(t(N),yield N)}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield lt(_.return()))}finally{if(a)throw u}}}),function s(){return i.apply(this,arguments)})();var i}}(e._init.maxMsgSize),function(){var o=j(function*(a){var R,u=!1,_=!1;try{for(var B,N=Pt(a);u=!(B=yield N.next()).done;u=!1){const K=B.value;yield e._handleIncoming(K)}}catch(K){_=!0,R=K}finally{try{u&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()),e._source.end()}catch(o){bs("error in sink",o),e._source.end(o)}});return function(s){return r.apply(this,arguments)}}()}_createSource(){const t=function dB(n={}){return GC(t=>{let r;const i=[];for(;!t.isEmpty()&&(r=t.shift(),null!=r);){if(null!=r.error)throw r.error;!1===r.done&&i.push(r.value)}return null==r?{done:!0}:{done:!0===r.done,value:i}},n)}({objectMode:!0,onEnd:r=>{this.close(r)}});return Object.assign(function Z5(n){return Gm.apply(this,arguments)}(t),{push:t.push,end:t.end,return:t.return})}_handleIncoming(e){var t=this;return j(function*(){const{id:r,type:i}=e;if(bs.enabled&&bs.trace("incoming message",C2(e)),e.type===cn.NEW_STREAM){if(t._streams.receivers.size===(t._init.maxInboundStreams??1024)){bs("too many inbound streams open"),t._source.push({id:r,type:cn.RESET_RECEIVER});try{yield t.rateLimiter.consume("new-stream",1)}catch{return bs("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),void t._source.end(new Error("Too many open streams"))}return}const u=t._newReceiverStream({id:r,name:Lt(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=t._init.onIncomingStream&&t._init.onIncomingStream(u))}const o=(1==(1&i)?t._streams.initiators:t._streams.receivers).get(r);if(null==o)return void bs("missing stream %s for message type %s",r,$m[i]);const a=t._init.maxStreamBufferSize??4194304;switch(i){case cn.MESSAGE_INITIATOR:case cn.MESSAGE_RECEIVER:if(o.sourceReadableLength()>a){t._source.push({id:e.id,type:i===cn.MESSAGE_INITIATOR?cn.RESET_RECEIVER:cn.RESET_INITIATOR});const u=ae(new Error("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers"),"ERR_STREAM_INPUT_BUFFER_FULL");return void o.abort(u)}o.sourcePush(e.data);break;case cn.CLOSE_INITIATOR:case cn.CLOSE_RECEIVER:o.closeRead();break;case cn.RESET_INITIATOR:case cn.RESET_RECEIVER:o.reset();break;default:bs("unknown message type %s",i)}})()}}class hU{constructor(e={}){this.protocol="/mplex/6.7.0",this.components=new ho,this._init=e}init(e){this.components=e}createStreamMuxer(e={}){return new dU(this.components,{...e,...this._init})}}const pU=WebSocket;var gU=x(3676);function I2(n){return n instanceof ArrayBuffer||"ArrayBuffer"===n?.constructor?.name&&"number"==typeof n?.byteLength}const yU=n=>{n.binaryType="arraybuffer";const e=function(){var s=j(function*(){return yield new Promise((o,a)=>{if(r)return o();if(null!=i)return a(i);const u=N=>{n.removeEventListener("open",_),n.removeEventListener("error",R),N()},_=()=>u(o),R=N=>{u(()=>a(N.error??new Error(`connect ECONNREFUSED ${n.url}`)))};n.addEventListener("open",_),n.addEventListener("error",R)})});return function(){return s.apply(this,arguments)}}(),t=dn(function*(){const s=new gU.zN(({push:N,stop:B,fail:K})=>{const Z=oe=>{let he=null;"string"==typeof oe.data&&(he=Ot(oe.data)),I2(oe.data)&&(he=new Uint8Array(oe.data)),oe.data instanceof Uint8Array&&(he=oe.data),null!=he&&N(he)},J=oe=>K(oe.error??new Error("Socket error"));return n.addEventListener("message",Z),n.addEventListener("error",J),n.addEventListener("close",B),()=>{n.removeEventListener("message",Z),n.removeEventListener("error",J),n.removeEventListener("close",B)}},{highWaterMark:1/0});yield lt(e());var u,o=!1,a=!1;try{for(var R,_=Pt(s);o=!(R=yield lt(_.next())).done;o=!1){const N=R.value;yield I2(N)?new Uint8Array(N):N}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield lt(_.return()))}finally{if(a)throw u}}})();let i,r=1===n.readyState;return n.addEventListener("open",()=>{r=!0,i=null}),n.addEventListener("close",()=>{r=!1,i=null}),n.addEventListener("error",s=>{r||(i=s.error??new Error(`connect ECONNREFUSED ${n.url}`))}),Object.assign(t,{connected:e})},mU=n=>{if(n.readyState>=2)throw new Error("socket closed");if(1!==n.readyState)return new Promise((e,t)=>{function r(){n.removeEventListener("open",i),n.removeEventListener("error",s)}function i(){r(),e()}function s(o){r(),t(o.error??new Error(`connect ECONNREFUSED ${n.url}`))}n.addEventListener("open",i),n.addEventListener("error",s)})},vU=(n,e)=>((e=e??{}).closeOnEnd=!1!==e.closeOnEnd,function(){var r=j(function*(i){var a,s=!1,o=!1;try{for(var _,u=Pt(i);s=!(_=yield u.next()).done;s=!1){const R=_.value;try{yield mU(n)}catch(N){if("socket closed"===N.message)break;throw N}n.send(R)}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}if(null!=e.closeOnEnd&&n.readyState<=1)return yield new Promise((R,N)=>{n.addEventListener("close",B=>{if(B.wasClean||1006===B.code)R();else{const K=Object.assign(new Error("ws error"),{event:B});N(K)}}),setTimeout(()=>n.close())})});return function(s){return r.apply(this,arguments)}}()),EU=(n,e)=>{e=e??{};const t=yU(n);let r=e.remoteAddress,i=e.remotePort;if(null!=n.url)try{const o=new URL(n.url);r=o.hostname,i=parseInt(o.port,10)}catch{}if(null==r||null==i)throw new Error("Remote connection did not have address and/or port");return{sink:vU(n,e),source:t,connected:(o=j(function*(){return yield t.connected()}),function(){return o.apply(this,arguments)}),close:function(){var o=j(function*(){(n.readyState===n.CONNECTING||n.readyState===n.OPEN)&&(yield new Promise(a=>{n.addEventListener("close",()=>{a()}),n.close()}))});return function(){return o.apply(this,arguments)}}(),destroy:()=>{null!=n.terminate?n.terminate():n.close()},remoteAddress:r,remotePort:i,socket:n};var o};var bU=x(8596);const wU={http:"ws",https:"wss"};const T2="[a-fA-F\\d:]",Wo=n=>n&&n.includeBoundaries?`(?:(?<=\\s|^)(?=${T2})|(?<=${T2})(?=\\s|$))`:"",ws="(?: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}",Dr="[a-fA-F\\d]{1,4}",fh=`\n(?:\n(?:${Dr}:){7}(?:${Dr}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${Dr}:){6}(?:${ws}|:${Dr}|:)| // 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\n(?:${Dr}:){5}(?::${ws}|(?::${Dr}){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\n(?:${Dr}:){4}(?:(?::${Dr}){0,1}:${ws}|(?::${Dr}){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\n(?:${Dr}:){3}(?:(?::${Dr}){0,2}:${ws}|(?::${Dr}){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\n(?:${Dr}:){2}(?:(?::${Dr}){0,3}:${ws}|(?::${Dr}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${Dr}:){1}(?:(?::${Dr}){0,4}:${ws}|(?::${Dr}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${Dr}){0,5}:${ws}|(?::${Dr}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),CU=new RegExp(`(?:^${ws}$)|(?:^${fh}$)`),IU=new RegExp(`^${ws}$`),TU=new RegExp(`^${fh}$`),qm=n=>n&&n.exact?CU:new RegExp(`(?:${Wo(n)}${ws}${Wo(n)})|(?:${Wo(n)}${fh}${Wo(n)})`,"g");qm.v4=n=>n&&n.exact?IU:new RegExp(`${Wo(n)}${ws}${Wo(n)}`,"g"),qm.v6=n=>n&&n.exact?TU:new RegExp(`${Wo(n)}${fh}${Wo(n)}`,"g");const Ym=qm,{toString:RU}=Object.prototype,A2={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function Qm(n,e,{}={}){try{return function AU(n){const e=(...t)=>n(...t);return Object.defineProperty(e,"name",{value:`functionTimeout(${n.name||""})`,configurable:!0}),e}(()=>function NU(n,e={}){if(!function PU(n){return"[object RegExp]"===RU.call(n)}(n))throw new TypeError("Expected a RegExp instance");const t=Object.keys(A2).map(i=>("boolean"==typeof e[i]?e[i]:n[i])?A2[i]:"").join(""),r=new RegExp(e.source||n.source,t);return r.lastIndex="number"==typeof e.lastIndex?e.lastIndex:n.lastIndex,r}(n).test(e))()}catch(r){throw r}}const Zm={timeout:400};function Xm(n){return Qm(Ym({exact:!0}),n.slice(0,45),Zm)}const N2=function OU(n){return Qm(Ym.v4({exact:!0}),n.slice(0,15),Zm)},kU=function P2(n){return Qm(Ym.v6({exact:!0}),n.slice(0,45),Zm)},M2=function(n){let t,e=0;if(n=n.trim(),N2(n))t=new Uint8Array(e+4),n.split(/\./g).forEach(r=>{t[e++]=255&parseInt(r,10)});else if(kU(n)){const r=n.split(":",8);let i;for(i=0;i0;i--)s.push("0");r.splice.apply(r,s)}for(t=new Uint8Array(e+16),i=0;i>8&255,t[e++]=255&s}}if(null==t)throw new Error(`invalid ip address "${n}"`);return t},_s=-1,dh={},Jm={};function Sr(n){if("number"==typeof n){if(null!=Jm[n])return Jm[n];throw new Error(`no protocol with code: ${n}`)}if("string"==typeof n){if(null!=dh[n])return dh[n];throw new Error(`no protocol with name: ${n}`)}throw new Error("invalid protocol id type: "+typeof n)}function O2(n,e){switch(Sr(n).code){case 4:case 41:return function UU(n){const e=function(n,e=0,t){e=~~e,t=t??n.length-e;const r=[];let i="";const s=new DataView(n.buffer);if(4===t){for(let o=0;o65536)throw new Error("Port number is not in range(1, 65536)");const i=tv(r);return wr([t,i],t.length+i.length)}(e);case 445:return function WU(n){const e=n.split(":");if(2!==e.length)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(56!==e[0].length)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);const t=co.decode(`b${e[0]}`),r=parseInt(e[1],10);if(r<1||r>65536)throw new Error("Port number is not in range(1, 65536)");const i=tv(r);return wr([t,i],t.length+i.length)}(e);case 466:return function $U(n){const e=FU.decode(n),t=Uint8Array.from(hr.encode(e.length));return wr([t,e],t.length+e.length)}(e);default:return Ot(e,"base16")}}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,_s,"ip6zone"],[53,_s,"dns",!0],[54,_s,"dns4",!0],[55,_s,"dns6",!0],[56,_s,"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"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,_s,"unix",!1,!0],[421,_s,"ipfs"],[421,_s,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,_s,"garlic64"],[460,0,"quic"],[466,_s,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,_s,"memory"]].forEach(n=>{const e=function BU(n,e,t,r,i){return{code:n,size:e,name:t,resolvable:Boolean(r),path:Boolean(i)}}(...n);Jm[e.code]=e,dh[e.name]=e});const ev=Object.values(El).map(n=>n.decoder),FU=function(){let n=ev[0].or(ev[1]);return ev.slice(2).forEach(e=>n=n.or(e)),n}();function tv(n){const e=new ArrayBuffer(2);return new DataView(e).setUint16(0,n),new Uint8Array(e)}function B2(n){return new DataView(n.buffer).getUint16(n.byteOffset)}function U2(n){return n.map(e=>{const t=ph(e);return null!=e[1]?[t.code,O2(t.code,e[1])]:[t.code]})}function V2(n){return rv(wr(n.map(e=>{const t=ph(e);let r=Uint8Array.from(hr.encode(t.code));return e.length>1&&null!=e[1]&&(r=wr([r,e[1]])),r})))}function H2(n,e){return n.size>0?n.size/8:0===n.size?0:hr.decode(e)+hr.decode.bytes}function hh(n){const e=[];let t=0;for(;tn.length)throw $2("Invalid address Uint8Array: "+Lt(n,"base16"));e.push([r,a])}return e}function nv(n){return function YU(n){const e=[];return n.map(t=>{const r=ph(t);return e.push(r.name),t.length>1&&null!=t[1]&&e.push(t[1]),null}),iv(e.join("/"))}(U2(hh(n)))}function rv(n){const e=function K2(n){try{hh(n)}catch(e){return e}}(n);if(null!=e)throw e;return Uint8Array.from(n)}function iv(n){return"/"+n.trim().split("/").filter(e=>e).join("/")}function $2(n){return new Error("Error parsing address: "+n)}function ph(n){return Sr(n[0])}const JU=Symbol.for("nodejs.util.inspect.custom"),j2=[Sr("dns").code,Sr("dns4").code,Sr("dns6").code,Sr("dnsaddr").code],eV=[Sr("p2p").code,Sr("ipfs").code],G2=new Map,z2=Symbol.for("@multiformats/js-multiaddr/multiaddr");let yn=(()=>{class n{constructor(t){if(null==t&&(t=""),Object.defineProperty(this,z2,{value:!0}),t instanceof Uint8Array)this.bytes=rv(t);else if("string"==typeof t){if(t.length>0&&"/"!==t.charAt(0))throw new Error(`multiaddr "${t}" must start with a "/"`);this.bytes=function XU(n){return function ZU(n){const e=function qU(n){const e=[],t=n.split("/").slice(1);if(1===t.length&&""===t[0])return[];for(let r=0;r=t.length)throw $2("invalid address: "+n);if(!0===s.path){e.push([i,iv(t.slice(r).join("/"))]);break}e.push([i,t[r]])}else e.push([i])}return e}(n=iv(n)),t=function QU(n){return n.map(e=>{Array.isArray(e)||(e=[e]);const t=ph(e);return e.length>1?[t.code,k2(t.code,e[1])]:[t.code]})}(e);return V2(t)}(n)}(t)}else{if(!n.isMultiaddr(t))throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=rv(t.bytes)}}toString(){return nv(this.bytes)}toJSON(){return this.toString()}toOptions(){const t=this.protoCodes(),r=this.toString().split("/").slice(1);let i,s;if(r.length>2)j2.includes(t[0])&&eV.includes(t[1])?(i=Sr("tcp").name,s=443):(i=Sr(r[2]).name,s=parseInt(r[3]));else{if(!j2.includes(t[0]))throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');i=Sr("tcp").name,s=443}return{family:41===t[0]||55===t[0]?6:4,host:r[1],transport:i,port:s}}protos(){return this.protoCodes().map(t=>Object.assign({},Sr(t)))}protoCodes(){const t=[],r=this.bytes;let i=0;for(;it.name)}tuples(){return hh(this.bytes)}stringTuples(){return U2(hh(this.bytes))}encapsulate(t){return t=new n(t),new n(this.toString()+t.toString())}decapsulate(t){const r=t.toString(),i=this.toString(),s=i.lastIndexOf(r);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new n(i.slice(0,s))}decapsulateCode(t){const r=this.tuples();for(let i=r.length-1;i>=0;i--)if(r[i][0]===t)return new n(V2(r.slice(0,i)));return this}getPeerId(){try{const r=this.stringTuples().filter(i=>i[0]===dh.ipfs.code).pop();if(null!=r?.[1]){const i=r[1];return Lt("Q"===i[0]||"1"===i[0]?ui.decode(`z${i}`):_r.parse(i).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){let t=null;try{t=this.stringTuples().filter(r=>!0===Sr(r[0]).path)[0][1],null==t&&(t=null)}catch{t=null}return t}equals(t){return kr(this.bytes,t.bytes)}resolve(t){var r=this;return j(function*(){const i=r.protos().find(a=>a.resolvable);if(null==i)return[r];const s=G2.get(i.name);if(null==s)throw ae(new Error(`no available resolver for ${i.name}`),"ERR_NO_AVAILABLE_RESOLVER");return(yield s(r,t)).map(a=>new n(a))})()}nodeAddress(){const t=this.toOptions();if("tcp"!==t.transport&&"udp"!==t.transport)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){const r=(t??this).protos();return!(2!==r.length||4!==r[0].code&&41!==r[0].code||6!==r[1].code&&273!==r[1].code)}static fromNodeAddress(t,r){if(null==t)throw new Error("requires node address object");if(null==r)throw new Error("requires transport protocol");let i;switch(t.family){case 4:i="ip4";break;case 6:i="ip6";break;default:throw Error("Invalid addr family, should be 4 or 6.")}return new n("/"+[i,t.address,r,t.port].join("/"))}static isName(t){return!!n.isMultiaddr(t)&&t.protos().some(r=>r.resolvable)}static isMultiaddr(t){return Boolean(t?.[z2])}[JU](){return""}inspect(){return""}}return n.resolvers=G2,n})();const gh=(n,e)=>e,rV={ip4:gh,ip6:(n,e,t,r)=>1===r.length&&"ip6"===r[0].protocol?e:`[${e}]`,tcp:(n,e,t,r,i)=>r.some(s=>["http","https","ws","wss"].includes(s.protocol))?`${n}:${e}`:((n,e,t,r)=>{if(null!=r&&!1===r.assumeHttp)return`tcp://${n}:${e}`;let i="tcp",s=`:${e}`;return"tcp"===t[t.length-1].protocol&&(i="443"===e?"https":"http",s="443"===e||"80"===e?"":s),`${i}://${n}${s}`})(n,e,r,i),udp:(n,e)=>`udp://${n}:${e}`,dnsaddr:gh,dns4:gh,dns6:gh,ipfs:(n,e)=>`${n}/ipfs/${e}`,p2p:(n,e)=>`${n}/p2p/${e}`,http:n=>`http://${n}`,https:n=>`https://${n}`,ws:n=>`ws://${n}`,wss:n=>`wss://${n}`,"p2p-websocket-star":n=>`${n}/p2p-websocket-star`,"p2p-webrtc-star":n=>`${n}/p2p-webrtc-star`,"p2p-webrtc-direct":n=>`${n}/p2p-webrtc-direct`};class eu extends Error{constructor(e="The operation was aborted"){super(e),this.code=eu.code,this.type=eu.type}static get code(){return"ABORT_ERR"}static get type(){return"aborted"}}var sV=x(9456);const sv="object"==typeof window&&"object"==typeof document&&9===document.nodeType,yh=sV(),mh=sv&&!yh,oV=yh&&!sv,aV=yh&&sv,cV=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&"node"===globalThis.process.release.name&&!yh,W2="function"==typeof importScripts&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,uV=(typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis,typeof navigator<"u"&&"ReactNative"===navigator.product);class pV extends Error{constructor(e){super(e),this.name="TimeoutError"}}class gV extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Q2=n=>void 0===globalThis.DOMException?new gV(n):new DOMException(n),Z2=n=>{const e=void 0===n.reason?Q2("This operation was aborted."):n.reason;return e instanceof Error?e:Q2(e)},X2=Gt("libp2p:websockets:socket");const vV=It("dns4"),EV=It("dns6"),bV=It("dnsaddr"),Ca=Zr(It("dns"),bV,vV,EV),vh=Zr(It("ip4"),It("ip6")),Bl=Zr(Jt(vh,It("tcp")),Jt(Ca,It("tcp"))),J2=Jt(vh,It("udp")),wV=Jt(J2,It("utp")),_V=Jt(J2,It("quic")),tu=Zr(Jt(Bl,It("ws")),Jt(Ca,It("ws"))),Ia=Zr(Jt(Bl,It("wss")),Jt(Ca,It("wss"))),ov=Zr(Jt(Bl,It("http")),Jt(vh,It("http")),Jt(Ca,It("http"))),av=Zr(Jt(Bl,It("https")),Jt(vh,It("https")),Jt(Ca,It("https"))),eT=Zr(Jt(tu,It("p2p-webrtc-star"),It("p2p")),Jt(Ia,It("p2p-webrtc-star"),It("p2p")),Jt(tu,It("p2p-webrtc-star")),Jt(Ia,It("p2p-webrtc-star"))),tT=(Zr(Jt(tu,It("p2p-websocket-star"),It("p2p")),Jt(Ia,It("p2p-websocket-star"),It("p2p")),Jt(tu,It("p2p-websocket-star")),Jt(Ia,It("p2p-websocket-star"))),Zr(Jt(ov,It("p2p-webrtc-direct"),It("p2p")),Jt(av,It("p2p-webrtc-direct"),It("p2p")),Jt(ov,It("p2p-webrtc-direct")),Jt(av,It("p2p-webrtc-direct")))),Fl=Zr(tu,Ia,ov,av,eT,tT,Bl,wV,_V,Ca),qo=(Zr(Jt(Fl,It("p2p-stardust"),It("p2p")),Jt(Fl,It("p2p-stardust"))),Zr(Jt(Fl,It("p2p")),eT,tT,It("p2p"))),nT=Zr(Jt(qo,It("p2p-circuit"),qo),Jt(qo,It("p2p-circuit")),Jt(It("p2p-circuit"),qo),Jt(Fl,It("p2p-circuit")),Jt(It("p2p-circuit"),Fl),It("p2p-circuit")),rT=()=>Zr(Jt(nT,rT),nT),nu=rT();function iT(n){return function e(t){let r;try{r=new yn(t)}catch{return!1}const i=n(r.protoNames());return null!==i&&(!0===i||!1===i?i:0===i.length)}}function Jt(...n){function e(t){if(t.length(r="function"==typeof i?i().partialMatch(t):i.partialMatch(t),Array.isArray(r)&&(t=r),null===r)),r}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:iT(e),partialMatch:e}}function Zr(...n){function e(r){let i=null;return n.some(s=>{const o="function"==typeof s?s().partialMatch(r):s.partialMatch(r);return null!=o&&(i=o,!0)}),i}return{toString:function(){return"{ "+n.join(" ")+" }"},input:n,matches:iT(e),partialMatch:e}}function It(n){const e=n;return{toString:function(){return e},matches:function t(i){let s;try{s=new yn(i)}catch{return!1}const o=s.protoNames();return 1===o.length&&o[0]===e},partialMatch:function r(i){return 0===i.length?null:i[0]===e?i.slice(1):null}}}function sT(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return tu.matches(t)||Ia.matches(t)})}Zr(Jt(nu,qo,nu),Jt(qo,nu),Jt(nu,qo),nu,qo);const cv=Symbol.for("@libp2p/transport"),Yo=Gt("libp2p:websockets");class SV{constructor(e){this.init=e}get[Symbol.toStringTag](){return"@libp2p/websockets"}get[cv](){return!0}dial(e,t){var r=this;return j(function*(){Yo("dialing %s",e),t=t??{};const s=function mV(n,e,t){const r={sink:i=>j(function*(){null!=t?.signal&&(i=vs(i,t.signal));try{yield n.sink(i)}catch(s){"aborted"!==s.type&&X2.error(s)}})(),source:null!=(t=t??{}).signal?vs(n.source,t.signal):n.source,remoteAddr:e,timeline:{open:Date.now()},close:()=>j(function*(){const i=Date.now();try{yield function yV(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((u,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(Z2(R)),R.addEventListener("abort",()=>{_(Z2(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{u(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new pV("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),j(function*(){try{u(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else u(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}(n.close(),{milliseconds:2e3})}catch{const{host:o,port:a}=r.remoteAddr.toOptions();X2("timeout closing stream to %s:%s after %dms, destroying it manually",o,a,Date.now()-i),n.destroy()}finally{r.timeline.close=Date.now()}})()};return null!=n.socket.once&&n.socket.once("close",()=>{null==r.timeline.close&&(r.timeline.close=Date.now())}),r}(yield r._connect(e,t),e);Yo("new outbound connection %s",s.remoteAddr);const o=yield t.upgrader.upgradeOutbound(s);return Yo("outbound connection %s upgraded",s.remoteAddr),o})()}_connect(e,t){var r=this;return j(function*(){if(!0===t?.signal?.aborted)throw new eu;const i=e.toOptions();Yo("dialing %s:%s",i.host,i.port);const s=w0(),o=R=>{Yo.error("connection error:",R),s.reject(R)},a=function SU(n,e){e=e??{};const r=((n,e)=>(0,bU.relative)(n,e,wU,"ws"))(n,(typeof window>"u"?"":window.location).toString()),i=new pU(r,e.websocket);return EU(i,e)}(function iV(n,e){const t=new yn(n),r=n.toString().split("/").slice(1);return t.tuples().map(i=>({protocol:r.shift()??"",content:null!=i[1]?r.shift()??"":""})).reduce((i,s,o,a)=>{const u=rV[s.protocol];if(null==u)throw new Error(`Unsupported protocol ${s.protocol}`);return u(i,s.content,o,a,e)},"")}(e),r.init);if(null!=a.socket.on?a.socket.on("error",o):a.socket.onerror=o,null==t.signal)return yield Promise.race([a.connected(),s.promise]),Yo("connected %s",e),a;let u;const _=new Promise((R,N)=>{if(u=()=>{N(new eu),setTimeout(()=>{a.close().catch(B=>{Yo.error("error closing raw socket",B)})})},!0===t?.signal?.aborted)return u();t?.signal?.addEventListener("abort",u)});try{yield Promise.race([_,s.promise,a.connected()])}finally{null!=u&&t?.signal?.removeEventListener("abort",u)}return Yo("connected %s",e),a})()}createListener(e){return function lV(){throw new Error("WebSocket Servers can not be created in the browser!")}()}filter(e){return e=Array.isArray(e)?e:[e],null!=this.init?.filter?this.init?.filter(e):mh||W2?function DV(n){return n.filter(e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return Ia.matches(t)&&Ca.matches(t.decapsulateCode(6).decapsulateCode(478))})}(e):sT(e)}}var po,Ta=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class Ei extends EventTarget{constructor(){super(...arguments),po.set(this,new Map)}listenerCount(e){const t=Ta(this,po,"f").get(e);return null==t?0:t.length}addEventListener(e,t,r){super.addEventListener(e,t,r);let i=Ta(this,po,"f").get(e);null==i&&(i=[],Ta(this,po,"f").set(e,i)),i.push({callback:t,once:(!0!==r&&!1!==r&&r?.once)??!1})}removeEventListener(e,t,r){super.removeEventListener(e.toString(),t??null,r);let i=Ta(this,po,"f").get(e);null!=i&&(i=i.filter(({callback:s})=>s!==t),Ta(this,po,"f").set(e,i))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=Ta(this,po,"f").get(e.type);return null==r||(r=r.filter(({once:i})=>!i),Ta(this,po,"f").set(e.type,r)),t}}po=new WeakMap;class CV extends Event{constructor(e,t){super(e,t),this.detail=t?.detail}}const tn=globalThis.CustomEvent??CV;var Ul=x(5357);const oT=(n,e)=>dn(function*(){const t=yield lt(Ul(n));yield*Mr(Pt(t.sort(e)),lt)})();var Qo=x(7414),Ds=x(6225),aT=x(0);const go="/",cT=(new TextEncoder).encode(go),Eh=cT[0];class Ur{constructor(e,t){if("string"==typeof e)this._buf=Ot(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==Eh)throw new Error("Invalid key")}toString(e="utf8"){return Lt(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Ur(e.join(go))}static random(){return new Ur(((n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))().replace(/-/g,""))}static asKey(e){return e instanceof Uint8Array||"string"==typeof e?new Ur(e):"function"==typeof e.uint8Array?new Ur(e.uint8Array()):null}clean(){if((null==this._buf||0===this._buf.byteLength)&&(this._buf=cT),this._buf[0]!==Eh){const e=new Uint8Array(this._buf.byteLength+1);e.fill(Eh,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Eh;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let i=0;io)return!1}return t.lengtht.namespaces()))])}}function NV(n){return[].concat(...n)}class OV extends class IV{open(){return Promise.reject(new Error(".open is not implemented"))}close(){return Promise.reject(new Error(".close is not implemented"))}put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}putMany(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const{key:_,value:R}=u.value;yield lt(r.put(_,R,t)),yield{key:_,value:R}}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}getMany(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;yield r.get(_,t)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}deleteMany(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(e);i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;yield lt(r.delete(_,t)),yield _}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}batch(){var e=this;let t=[],r=[];return{put(i,s){t.push({key:i,value:s})},delete(i){r.push(i)},commit:(i=j(function*(s){yield Qo(e.putMany(t,s)),t=[],yield Qo(e.deleteMany(r,s)),r=[]}),function(o){return i.apply(this,arguments)})};var i}_all(e,t){return dn(function*(){throw new Error("._all is not implemented")})()}_allKeys(e,t){return dn(function*(){throw new Error("._allKeys is not implemented")})()}query(e,t){let r=this._all(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.key.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>oT(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=aT(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix&&(r=Ds(r,i=>i.toString().startsWith(e.prefix))),Array.isArray(e.filters)&&(r=e.filters.reduce((i,s)=>Ds(i,s),r)),Array.isArray(e.orders)&&(r=e.orders.reduce((i,s)=>oT(i,s),r)),null!=e.offset){let i=0;r=Ds(r,()=>i++>=e.offset)}return null!=e.limit&&(r=aT(r,e.limit)),r}}{constructor(){super(),this.data={}}open(){return Promise.resolve()}close(){return Promise.resolve()}put(e,t){var r=this;return j(function*(){r.data[e.toString()]=t})()}get(e){var t=this;return j(function*(){if(!(yield t.has(e)))throw function MV(n){return n=n||new Error("Not Found"),ae(n,"ERR_NOT_FOUND")}();return t.data[e.toString()]})()}has(e){var t=this;return j(function*(){return void 0!==t.data[e.toString()]})()}delete(e){var t=this;return j(function*(){delete t.data[e.toString()]})()}_all(){var e=this;return dn(function*(){yield*Mr(Pt(Object.entries(e.data).map(([t,r])=>({key:new Ur(t),value:r}))),lt)})()}_allKeys(){var e=this;return dn(function*(){yield*Mr(Pt(Object.entries(e.data).map(([t])=>new Ur(t))),lt)})()}}var _n=(()=>(function(n){n.NOT_STARTED_YET="The libp2p node is not started yet",n.DHT_DISABLED="DHT is not available",n.PUBSUB_DISABLED="PubSub is not available",n.CONN_ENCRYPTION_REQUIRED="At least one connection encryption module is required",n.ERR_TRANSPORTS_REQUIRED="At least one transport module is required",n.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",n.NOT_FOUND="Not found"}(_n||(_n={})),_n))(),Ce=(()=>(function(n){n.DHT_DISABLED="ERR_DHT_DISABLED",n.ERR_PUBSUB_DISABLED="ERR_PUBSUB_DISABLED",n.PUBSUB_NOT_STARTED="ERR_PUBSUB_NOT_STARTED",n.DHT_NOT_STARTED="ERR_DHT_NOT_STARTED",n.CONN_ENCRYPTION_REQUIRED="ERR_CONN_ENCRYPTION_REQUIRED",n.ERR_TRANSPORTS_REQUIRED="ERR_TRANSPORTS_REQUIRED",n.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",n.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",n.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",n.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",n.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",n.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",n.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",n.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",n.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",n.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",n.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",n.ERR_DIALED_SELF="ERR_DIALED_SELF",n.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",n.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",n.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",n.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",n.ERR_INVALID_KEY="ERR_INVALID_KEY",n.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",n.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",n.ERR_INVALID_PEER="ERR_INVALID_PEER",n.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",n.ERR_NOT_FOUND="ERR_NOT_FOUND",n.ERR_TIMEOUT="ERR_TIMEOUT",n.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",n.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",n.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",n.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",n.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",n.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",n.ERR_FIND_SELF="ERR_FIND_SELF",n.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",n.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",n.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",n.ERR_KEYCHAIN_REQUIRED="ERR_KEYCHAIN_REQUIRED",n.ERR_INVALID_CMS="ERR_INVALID_CMS",n.ERR_MISSING_KEYS="ERR_MISSING_KEYS",n.ERR_NO_KEY="ERR_NO_KEY",n.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",n.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",n.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",n.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",n.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",n.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",n.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",n.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",n.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",n.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",n.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",n.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",n.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",n.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",n.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",n.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",n.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",n.ERR_INVALID_RECORD="ERR_INVALID_RECORD",n.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",n.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",n.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",n.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS"}(Ce||(Ce={})),Ce))(),uv=x(6930);function lv(n,e){return fv.apply(this,arguments)}function fv(){return fv=dn(function*(n,e){yield*Mr(Pt(uv(n,function(){var t=j(function*(r){return yield e.addressBook.add(r.id,r.multiaddrs),r});return function(r){return t.apply(this,arguments)}}())),lt)}),fv.apply(this,arguments)}function uT(n){const e=new Set;return Ds(n,t=>!e.has(t.id.toString())&&(e.add(t.id.toString()),!0))}function lT(n){return dv.apply(this,arguments)}function dv(){return dv=dn(function*(n,e=1){let t=0;var s,r=!1,i=!1;try{for(var a,o=Pt(n);r=!(a=yield lt(o.next())).done;r=!1){const u=a.value;t++,yield u}}catch(u){i=!0,s=u}finally{try{r&&null!=o.return&&(yield lt(o.return()))}finally{if(i)throw s}}if(tdn(function*(){try{yield yield lt(s.findPeer(e,t))}catch(o){fT.error(o)}})())),s=>Ds(s,Boolean),s=>lv(s,r.components.getPeerStore()),function(){var s=j(function*(o){return yield Aa(o)});return function(o){return s.apply(this,arguments)}}());if(null!=i)return i;throw ae(new Error(_n.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getClosestPeers(e,t){var r=this;return dn(function*(){if(0===r.routers.length)throw ae(new Error("No peer routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield*Mr(Pt(Wn(Fd(...r.routers.map(i=>i.getClosestPeers(e,t))),i=>lv(i,r.components.getPeerStore()),i=>uT(i),i=>lT(i))),lt)})()}}class LV{constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started=!0})()}stop(){var e=this;return j(function*(){e.started=!1})()}findProviders(e,t={}){var r=this;return dn(function*(){if(0===r.routers.length)throw ae(new Error("No content this.routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield*Mr(Pt(Wn(Fd(...r.routers.map(i=>i.findProviders(e,t))),i=>lv(i,r.components.getPeerStore()),i=>uT(i),i=>lT(i))),lt)})()}provide(e,t={}){var r=this;return j(function*(){if(0===r.routers.length)throw ae(new Error("No content routers available"),Ce.ERR_NO_ROUTERS_AVAILABLE);yield Promise.all(r.routers.map(function(){var i=j(function*(s){return yield s.provide(e,t)});return function(s){return i.apply(this,arguments)}}()))})()}put(e,t,r){var i=this;return j(function*(){if(!i.isStarted())throw ae(new Error(_n.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);const s=i.components.getDHT();null!=s&&(yield Qo(s.put(e,t,r)))})()}get(e,t){var r=this;return j(function*(){if(!r.isStarted())throw ae(new Error(_n.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);const i=r.components.getDHT();if(null!=i){var a,s=!1,o=!1;try{for(var _,u=Pt(i.get(e,t));s=!(_=yield u.next()).done;s=!1){const R=_.value;if("VALUE"===R.name)return R.value}}catch(R){o=!0,a=R}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}}throw ae(new Error(_n.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getMany(e,t,r){var i=this;return dn(function*(){if(!i.isStarted())throw ae(new Error(_n.NOT_STARTED_YET),Ce.DHT_NOT_STARTED);if(null==t||0===t)return;let s=0;const o=i.components.getDHT();if(null!=o){var _,a=!1,u=!1;try{for(var N,R=Pt(o.get(e,r));a=!(N=yield lt(R.next())).done;a=!1){const B=N.value;if("VALUE"===B.name&&(yield{from:B.from,val:B.value},s++,s===t))break}}catch(B){u=!0,_=B}finally{try{a&&null!=R.return&&(yield lt(R.return()))}finally{if(u)throw _}}}if(0===s)throw ae(new Error(_n.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}}function Vl(n){if(c2(n))return{id:n,multiaddrs:[],protocols:[]};let e;return"string"==typeof n&&(n=new yn(n)),yn.isMultiaddr(n)&&(e=n,n=function BV(n){const e=n.getPeerId();if(null==e)throw ae(new Error(`${n.toString()} does not have a valid peer type`),Ce.ERR_INVALID_MULTIADDR);try{return fr(e)}catch{throw ae(new Error(`${n.toString()} is not a valid peer type`),Ce.ERR_INVALID_MULTIADDR)}}(n)),{id:n,multiaddrs:null!=e?[e]:[],protocols:[]}}const FV=n=>n;class UV extends Ei{constructor(e,t){super();const{listen:r=[],announce:i=[]}=t;this.components=e,this.listen=new Set(r.map(s=>s.toString())),this.announce=new Set(i.map(s=>s.toString())),this.observed=new Set,this.announceFilter=t.announceFilter??FV}getListenAddrs(){return Array.from(this.listen).map(e=>new yn(e))}getAnnounceAddrs(){return Array.from(this.announce).map(e=>new yn(e))}getObservedAddrs(){return Array.from(this.observed).map(e=>new yn(e))}addObservedAddr(e){let t=new yn(e);const r=t.getPeerId();null!=r&&fr(r).equals(this.components.getPeerId())&&(t=t.decapsulate(new yn(`/p2p/${this.components.getPeerId().toString()}`)));const i=t.toString();this.observed.has(i)||(this.observed.add(i),this.dispatchEvent(new tn("change:addresses")))}getAddresses(){let e=this.getAnnounceAddrs().map(r=>r.toString());0===e.length&&(e=this.components.getTransportManager().getAddrs().map(r=>r.toString())),e=e.concat(this.getObservedAddrs().map(r=>r.toString()));const t=new Set(e);return this.announceFilter(Array.from(t).map(r=>new yn(r))).map(r=>r.getPeerId()===this.components.getPeerId().toString()?r:r.encapsulate(`/p2p/${this.components.getPeerId().toString()}`))}}const Hl=x(7820),dT=Gt("libp2p:connection-manager:latency-monitor:visibility-change-emitter");class HV extends Ei{constructor(){super(),this.hidden="hidden",this.visibilityChange="visibilityChange",null!=globalThis.document&&(this._initializeVisibilityVarNames(),this._addVisibilityChangeListener())}_initializeVisibilityVarNames(){let e="hidden",t="visibilitychange";typeof globalThis.document.hidden<"u"?(e="hidden",t="visibilitychange"):typeof globalThis.document.mozHidden<"u"?(e="mozHidden",t="mozvisibilitychange"):typeof globalThis.document.msHidden<"u"?(e="msHidden",t="msvisibilitychange"):typeof globalThis.document.webkitHidden<"u"&&(e="webkitHidden",t="webkitvisibilitychange"),this.hidden=e,this.visibilityChange=t}_addVisibilityChangeListener(){typeof globalThis.document.addEventListener>"u"||typeof document[this.hidden]>"u"?dT("Checking page visibility requires a browser that supports the Page Visibility API."):globalThis.document.addEventListener(this.visibilityChange,this._handleVisibilityChange.bind(this),!1)}isVisible(){if(void 0!==this.hidden&&void 0!==document[this.hidden])return null==document[this.hidden]}_handleVisibilityChange(){const e=!1===globalThis.document[this.hidden];dT(e?"Page Visible":"Page Hidden"),this.dispatchEvent(new tn("visibilityChange",{detail:e}))}}const yo=Gt("libp2p:connection-manager:latency-monitor");class KV extends Ei{constructor(e={}){super();const{latencyCheckIntervalMs:t,dataEmitIntervalMs:r,asyncTestFn:i,latencyRandomPercentage:s}=e;this.latencyCheckIntervalMs=t??500,this.latencyRandomPercentage=s??10,this.latencyCheckMultiply=this.latencyRandomPercentage/100*2*this.latencyCheckIntervalMs,this.latencyCheckSubtract=this.latencyCheckMultiply/2,this.dataEmitIntervalMs=null===r||0===r?void 0:r??5e3,yo("latencyCheckIntervalMs: %s dataEmitIntervalMs: %s",this.latencyCheckIntervalMs,this.dataEmitIntervalMs),null!=this.dataEmitIntervalMs?yo("Expecting ~%s events per summary",this.latencyCheckIntervalMs/this.dataEmitIntervalMs):yo("Not emitting summaries"),this.asyncTestFn=i,null!=globalThis.process?.hrtime?(yo("Using process.hrtime for timing"),this.now=globalThis.process.hrtime,this.getDeltaMS=o=>{const a=this.now(o);return 1e3*a[0]+a[1]/1e6}):typeof window<"u"&&null!=window.performance?.now?(yo("Using performance.now for timing"),this.now=window.performance.now.bind(window.performance),this.getDeltaMS=o=>Math.round(this.now()-o)):(yo("Using Date.now for timing"),this.now=Date.now,this.getDeltaMS=o=>this.now()-o),this.latencyData=this.initLatencyData()}start(){(function $V(){return typeof globalThis.window<"u"})()&&(this.visibilityChangeEmitter=new HV,this.visibilityChangeEmitter.addEventListener("visibilityChange",e=>{const{detail:t}=e;t?this._startTimers():(this._emitSummary(),this._stopTimers())})),!0===this.visibilityChangeEmitter?.isVisible()&&this._startTimers()}stop(){this._stopTimers()}_startTimers(){null==this.checkLatencyID&&(this.checkLatency(),null!=this.dataEmitIntervalMs&&(this.emitIntervalID=setInterval(()=>this._emitSummary(),this.dataEmitIntervalMs),"function"==typeof this.emitIntervalID.unref&&this.emitIntervalID.unref()))}_stopTimers(){null!=this.checkLatencyID&&(clearTimeout(this.checkLatencyID),this.checkLatencyID=void 0),null!=this.emitIntervalID&&(clearInterval(this.emitIntervalID),this.emitIntervalID=void 0)}_emitSummary(){const e=this.getSummary();e.events>0&&this.dispatchEvent(new tn("data",{detail:e}))}getSummary(){const e={events:this.latencyData.events,minMs:this.latencyData.minMs,maxMs:this.latencyData.maxMs,avgMs:this.latencyData.events>0?this.latencyData.totalMs/this.latencyData.events:Number.POSITIVE_INFINITY,lengthMs:this.getDeltaMS(this.latencyData.startTime)};return this.latencyData=this.initLatencyData(),yo.trace("Summary: %O",e),e}checkLatency(){const e=Math.random()*this.latencyCheckMultiply-this.latencyCheckSubtract,t={deltaOffset:Math.ceil(this.latencyCheckIntervalMs+e),startTime:this.now()},r=()=>{if(null==this.checkLatencyID)return;const i=this.getDeltaMS(t.startTime)-t.deltaOffset;this.checkLatency(),this.latencyData.events++,this.latencyData.minMs=Math.min(this.latencyData.minMs,i),this.latencyData.maxMs=Math.max(this.latencyData.maxMs,i),this.latencyData.totalMs+=i,yo.trace("MS: %s Data: %O",i,this.latencyData)};yo.trace("localData: %O",t),this.checkLatencyID=setTimeout(()=>{null!=this.asyncTestFn?(t.deltaOffset=0,t.startTime=this.now(),this.asyncTestFn(r)):(t.deltaOffset-=1,r())},t.deltaOffset),"function"==typeof this.checkLatencyID.unref&&this.checkLatencyID.unref()}initLatencyData(){return{startTime:this.now(),minMs:Number.POSITIVE_INFINITY,maxMs:Number.NEGATIVE_INFINITY,events:0,totalMs:0}}}var Kl=x(2502);const pT="CLOSING",hv="CLOSED";var jV=x(8614);const gT=Gt("libp2p:dialer:dial-request");class GV{constructor(e){const{addrs:t,dialAction:r,dialer:i}=e;this.addrs=t,this.dialer=i,this.dialAction=r}run(e={}){var t=this;return j(function*(){const r=t.dialer.getTokens(t.addrs.length);if(r.length<1)throw ae(new Error("No dial tokens available"),Ce.ERR_NO_DIAL_TOKENS);const i=new jV;for(const u of r)i.push(u).catch(_=>{gT.error(_)});const s=t.addrs.map(()=>{const u=new AbortController;try{(0,Vr.setMaxListeners)?.(1/0,u.signal)}catch{}return u});if(null!=e.signal)try{(0,Vr.setMaxListeners)?.(1/0,e.signal)}catch{}let o=0,a=!1;try{return yield Promise.any(t.addrs.map(function(){var u=j(function*(_,R){const N=yield i.shift();if(a)throw t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0]),ae(new Error("dialAction already succeeded"),Ce.ERR_ALREADY_SUCCEEDED);const B=s[R];if(null==B)throw ae(new Error("dialAction did not come with an AbortController"),Ce.ERR_INVALID_PARAMETERS);let K;try{const Z=B.signal;K=yield t.dialAction(_,{...e,signal:null!=e.signal?(0,lh.anySignal)([Z,e.signal]):Z}),s[R]=void 0}finally{o++,t.addrs.length-o>=r.length?i.push(N).catch(Z=>{gT.error(Z)}):t.dialer.releaseToken(r.splice(r.indexOf(N),1)[0])}if(null==K)throw ae(new Error("dialAction led to empty object"),Ce.ERR_TRANSPORT_DIAL_FAILED);return a=!0,K});return function(_,R){return u.apply(this,arguments)}}()))}finally{s.forEach(u=>{void 0!==u&&u.abort()}),r.forEach(u=>t.dialer.releaseToken(u))}})()}}var yT=x(4108);function mT(n){const{address:e}=n.nodeAddress();return Boolean(yT(e))}function pv(n,e){const t=mT(n.multiaddr),r=mT(e.multiaddr);return t&&!r?1:!t&&r||n.isCertified&&!e.isCertified?-1:!n.isCertified&&e.isCertified?1:0}var gv=x(4297);const Fs=Gt("libp2p:dialer"),wT="dialler";class ZV{constructor(e={}){this.components=new ho,this.started=!1,this.addressSorter=e.addressSorter??pv,this.maxAddrsToDial=e.maxAddrsToDial??25,this.timeout=e.dialTimeout??3e4,this.maxDialsPerPeer=e.maxDialsPerPeer??4,this.tokens=[...new Array(e.maxParallelDials??100)].map((t,r)=>r),this.pendingDials=Ll({component:wT,metric:"pending-dials",metrics:e.metrics}),this.pendingDialTargets=Ll({component:wT,metric:"pending-dial-targets",metrics:e.metrics});for(const[t,r]of Object.entries(e.resolvers??{}))yn.resolvers.set(t,r)}init(e){this.components=e}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started=!0})()}stop(){var e=this;return j(function*(){e.started=!1;for(const t of e.pendingDials.values())try{t.controller.abort()}catch(r){Fs.error(r)}e.pendingDials.clear();for(const t of e.pendingDialTargets.values())t.reject(new eu("Dialer was destroyed"));e.pendingDialTargets.clear()})()}dial(e,t={}){var r=this;return j(function*(){const{id:i,multiaddrs:s}=Vl(e);if(r.components.getPeerId().equals(i))throw ae(new Error("Tried to dial self"),Ce.ERR_DIALED_SELF);if(Fs("check multiaddrs %p",i),null!=s&&s.length>0&&(Fs("storing multiaddrs %p",i,s),yield r.components.getPeerStore().addressBook.add(i,s)),yield r.components.getConnectionGater().denyDialPeer(i))throw ae(new Error("The dial request is blocked by gater.allowDialPeer"),Ce.ERR_PEER_DIAL_INTERCEPTED);Fs("creating dial target for %p",i);const o=yield r._createCancellableDialTarget(i,t);if(0===o.addrs.length)throw ae(new Error("The dial request has no valid addresses"),Ce.ERR_NO_VALID_ADDRESSES);const a=r.pendingDials.get(o.id)??r._createPendingDial(o,t);try{const u=yield a.promise;return Fs("dial succeeded to %s",o.id),u}catch(u){throw Fs("dial failed to %s",o.id,u),a.controller.signal.aborted&&(u.code=Ce.ERR_TIMEOUT),Fs.error(u),u}finally{a.destroy()}})()}_createCancellableDialTarget(e,t){var r=this;return j(function*(){const i=`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`,s=new Promise((o,a)=>{r.pendingDialTargets.set(i,{resolve:o,reject:a})});try{return yield Promise.race([r._createDialTarget(e,t),s])}finally{r.pendingDialTargets.delete(i)}})()}_createDialTarget(e,t){var r=this;return j(function*(){const i=yield Wn(yield r.components.getPeerStore().addressBook.get(e),a=>Ds(a,function(){var u=j(function*(_){return!(yield r.components.getConnectionGater().denyDialMultiaddr(e,_.multiaddr))});return function(_){return u.apply(this,arguments)}}()),a=>gv(a,r.addressSorter),a=>uv(a,u=>{const _=u.multiaddr;return e.toString()===_.getPeerId()?_:_.encapsulate(`/p2p/${e.toString()}`)}),function(){var a=j(function*(u){return yield Ul(u)});return function(u){return a.apply(this,arguments)}}()),s=[];for(const a of i)(yield r._resolve(a,t)).forEach(_=>s.push(_));const o=s.filter(a=>r.components.getTransportManager().transportForMultiaddr(a));if(o.length>r.maxAddrsToDial)throw yield r.components.getPeerStore().delete(e),ae(new Error("dial with more addresses than allowed"),Ce.ERR_TOO_MANY_ADDRESSES);return{id:e.toString(),addrs:o}})()}_createPendingDial(e,t={}){var r=this;const i=function(){var R=j(function*(N,B={}){if(!0===B.signal?.aborted)throw ae(new Error("already aborted"),Ce.ERR_ALREADY_ABORTED);return yield r.components.getTransportManager().dial(N,B)});return function(B){return R.apply(this,arguments)}}(),s=new GV({addrs:e.addrs,dialAction:i,dialer:this}),o=new bi.TimeoutController(this.timeout),a=[o.signal];null!=t.signal&&a.push(t.signal);const u=(0,lh.anySignal)(a);try{(0,Vr.setMaxListeners)?.(1/0,u)}catch{}const _={dialRequest:s,controller:o,promise:s.run({...t,signal:u}),destroy:()=>{o.clear(),this.pendingDials.delete(e.id)}};return this.pendingDials.set(e.id,_),_}getTokens(e){const t=Math.min(e,this.maxDialsPerPeer,this.tokens.length),r=this.tokens.splice(0,t);return Fs("%d tokens request, returning %d, %d remaining",e,t,this.tokens.length),r}releaseToken(e){this.tokens.includes(e)||(Fs("token %d released",e),this.tokens.push(e))}_resolve(e,t){var r=this;return j(function*(){if(!e.protoNames().includes("dnsaddr"))return[e];const s=yield r._resolveRecord(e,t);return(yield Promise.all(s.map(function(){var u=j(function*(_){return yield r._resolve(_,t)});return function(_){return u.apply(this,arguments)}}()))).flat().reduce((u,_)=>(null==u.find(R=>R.equals(_))&&u.push(_),u),[])})()}_resolveRecord(e,t){return j(function*(){try{return e=new yn(e.toString()),yield e.resolve(t)}catch(r){return Fs.error(`multiaddr ${e.toString()} could not be resolved`,r),[]}})()}}function wh(n,e){const t={[Symbol.iterator]:()=>t,next:()=>{const r=n.next(),i=r.value;return!0===r.done||null==i?{done:!0,value:void 0}:{done:!1,value:e(i)}}};return t}class XV{constructor(e){if(this.map=new Map,null!=e)for(const[t,r]of e.entries())this.map.set(t.toString(),r)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){this.map.delete(e.toString())}entries(){return wh(this.map.entries(),e=>[fr(e[0]),e[1]])}forEach(e){this.map.forEach((t,r)=>{e(t,fr(r),this)})}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),t)}keys(){return wh(this.map.keys(),e=>fr(e))}values(){return this.map.values()}get size(){return this.map.size}}class JV{constructor(e){if(this.set=new Set,null!=e)for(const t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return wh(this.set.entries(),e=>{const t=fr(e[0]);return[t,t]})}forEach(e){this.set.forEach(t=>{const r=fr(t);e(r,r,this)})}has(e){return this.set.has(e.toString())}values(){return wh(this.set.values(),e=>fr(e))}}Symbol;const Xr=Gt("libp2p:connection-manager"),t7={maxConnections:1/0,minConnections:0,maxData:1/0,maxSentData:1/0,maxReceivedData:1/0,maxEventLoopDelay:1/0,pollInterval:2e3,autoDialInterval:1e4,movingAverageInterval:6e4},mv="libp2p",vv="connection-manager";class r7 extends Ei{constructor(e){if(super(),this.components=new ho,this.opts=Hl.call({ignoreUndefined:!0},t7,e),this.opts.maxConnections{const t={inbound:0,outbound:0};for(const r of this.connections.values())for(const i of r)"inbound"===i.stat.direction?t.inbound++:t.outbound++;return t}}),this.components.getMetrics()?.updateComponentMetric({system:mv,component:vv,metric:"protocol-streams-total",label:"protocol",value:()=>{const t={};for(const r of this.connections.values())for(const i of r)for(const s of i.streams){const o=`${s.stat.direction} ${s.stat.protocol??"unnegotiated"}`;t[o]=(t[o]??0)+1}return t}}),this.components.getMetrics()?.updateComponentMetric({system:mv,component:vv,metric:"protocol-streams-per-connection-90th-percentile",label:"protocol",value:()=>{const t={};for(const i of this.connections.values())for(const s of i){const o={};for(const a of s.streams){const u=`${a.stat.direction} ${a.stat.protocol??"unnegotiated"}`;o[u]=(o[u]??0)+1}for(const[a,u]of Object.entries(o))t[a]=t[a]??[],t[a].push(u)}const r={};for(let[i,s]of Object.entries(t)){s=s.sort((a,u)=>a-u);const o=Math.floor(.9*s.length);r[i]=s[o]}return r}})}isStarted(){return this.started}start(){var e=this;return j(function*(){null!=e.components.getMetrics()&&(e.timer=e.timer??Kl(e._checkMetrics,e.opts.pollInterval)),e.latencyMonitor.start(),e._onLatencyMeasure=e._onLatencyMeasure.bind(e),e.latencyMonitor.addEventListener("data",e._onLatencyMeasure),yield e.dialer.start(),e.started=!0,Xr("started")})()}afterStart(){var e=this;return j(function*(){e.components.getUpgrader().addEventListener("connection",e.onConnect),e.components.getUpgrader().addEventListener("connectionEnd",e.onDisconnect),Promise.resolve().then(j(function*(){const t=[];for(const r of yield e.components.getPeerStore().all())(yield e.components.getPeerStore().getTags(r.id)).filter(o=>"keep-alive"===o.name).length>0&&t.push(r.id);e.connectOnStartupController?.clear(),e.connectOnStartupController=new bi.TimeoutController(e.startupReconnectTimeout);try{(0,Vr.setMaxListeners)?.(1/0,e.connectOnStartupController.signal)}catch{}yield Promise.all(t.map(function(){var r=j(function*(i){yield e.openConnection(i,{signal:e.connectOnStartupController?.signal}).catch(s=>{Xr.error(s)})});return function(i){return r.apply(this,arguments)}}()))})).catch(t=>{Xr.error(t)}).finally(()=>{e.connectOnStartupController?.clear()})})()}beforeStop(){var e=this;return j(function*(){e.connectOnStartupController?.abort(),e.components.getUpgrader().removeEventListener("connection",e.onConnect),e.components.getUpgrader().removeEventListener("connectionEnd",e.onDisconnect)})()}stop(){var e=this;return j(function*(){e.timer?.clear(),e.latencyMonitor.removeEventListener("data",e._onLatencyMeasure),e.latencyMonitor.stop(),yield e.dialer.stop(),e.started=!1,yield e._close(),Xr("stopped")})()}_close(){var e=this;return j(function*(){const t=[];for(const r of e.connections.values())for(const i of r)t.push(j(function*(){try{yield i.close()}catch(s){Xr.error(s)}})());Xr("closing %d connections",t.length),yield Promise.all(t),e.connections.clear()})()}_checkMetrics(){var e=this;return j(function*(){const t=e.components.getMetrics();if(null!=t)try{const r=t.getGlobal().getMovingAverages(),i=r.dataReceived[e.opts.movingAverageInterval].movingAverage;yield e._checkMaxLimit("maxReceivedData",i);const s=r.dataSent[e.opts.movingAverageInterval].movingAverage;yield e._checkMaxLimit("maxSentData",s);const o=i+s;yield e._checkMaxLimit("maxData",o),Xr.trace("metrics update",o)}finally{e.timer=Kl(e._checkMetrics,e.opts.pollInterval)}})()}onConnect(e){this._onConnect(e).catch(t=>{Xr.error(t)})}_onConnect(e){var t=this;return j(function*(){const{detail:r}=e;if(!t.started)return void(yield r.close());const i=r.remotePeer,s=i.toString(),o=t.connections.get(s);null!=o?o.push(r):t.connections.set(s,[r]),null!=i.publicKey&&(yield t.components.getPeerStore().keyBook.set(i,i.publicKey));const a=t.getConnections().length,u=a-t.opts.maxConnections;yield t._checkMaxLimit("maxConnections",a,u),t.dispatchEvent(new tn("peer:connect",{detail:r}))})()}onDisconnect(e){const{detail:t}=e;if(!this.started)return;const r=t.remotePeer.toString();let i=this.connections.get(r);null!=i&&i.length>1?(i=i.filter(s=>s.id!==t.id),this.connections.set(r,i)):null!=i&&(this.connections.delete(r),this.dispatchEvent(new tn("peer:disconnect",{detail:t})),this.components.getMetrics()?.onPeerDisconnected(t.remotePeer))}getConnections(e){if(null!=e)return this.connections.get(e.toString())??[];let t=[];for(const r of this.connections.values())t=t.concat(r);return t}openConnection(e,t={}){var r=this;return j(function*(){Xr("dial to %p",e);const i=r.getConnections(e);if(i.length>0)return Xr("had an existing connection to %p",e),i[0];let s;if(null==t?.signal){s=new bi.TimeoutController(r.dialTimeout),t.signal=s.signal;try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}}try{const o=yield r.dialer.dial(e,t);let a=r.connections.get(e.toString());null==a&&(a=[],r.connections.set(e.toString(),a));let u=!1;for(const _ of a)_.id===o.id&&(u=!0);return u||a.push(o),o}finally{s?.clear()}})()}closeConnections(e){var t=this;return j(function*(){const r=t.connections.get(e.toString())??[];yield Promise.all(r.map(function(){var i=j(function*(s){return yield s.close()});return function(s){return i.apply(this,arguments)}}()))})()}getAll(e){if(!c2(e))throw ae(new Error("peerId must be an instance of peer-id"),Ce.ERR_INVALID_PARAMETERS);const t=e.toString(),r=this.connections.get(t);return null!=r?r.filter(i=>"OPEN"===i.stat.status):[]}_onLatencyMeasure(e){const{detail:t}=e;this._checkMaxLimit("maxEventLoopDelay",t.avgMs,1).catch(r=>{Xr.error(r)})}_checkMaxLimit(e,t,r=1){var i=this;return j(function*(){const s=i.opts[e];Xr.trace("checking limit of %s. current value: %d of %d",e,t,s),t>s&&(Xr("%s: limit exceeded: %p, %d/%d, pruning %d connection(s)",i.components.getPeerId(),e,t,s,r),yield i._maybePruneConnections(r))})()}_maybePruneConnections(e){var t=this;return j(function*(){const r=t.getConnections();if(r.length<=t.opts.minConnections||e<1)return;const i=new XV;for(const a of r){const u=a.remotePeer;if(i.has(u))continue;const _=yield t.components.getPeerStore().getTags(u);i.set(u,_.reduce((R,N)=>R+N.value,0))}const s=r.sort((a,u)=>{const _=i.get(a.remotePeer)??0,R=i.get(u.remotePeer)??0;return _>R?1:_{Zo.error("could start autodial",t)}),Zo("started")):Zo("not enabled")})()}stop(){var e=this;return j(function*(){e.options.enabled?(e.running=!1,null!=e.autoDialTimeout&&e.autoDialTimeout.clear(),Zo("stopped")):Zo("not enabled")})()}_autoDial(){var e=this;return j(function*(){null!=e.autoDialTimeout&&e.autoDialTimeout.clear();const t=e.options.minConnections;if(e.components.getConnectionManager().getConnections().length>=t)return void(e.autoDialTimeout=Kl(e._autoDial,e.options.autoDialInterval));const r=yield e.components.getPeerStore().all(),i=yield Wn(r.sort(()=>Math.random()>.5?1:-1),s=>Ds(s,o=>!o.id.equals(e.components.getPeerId())),s=>gv(s,(o,a)=>a.protocols.length>o.protocols.length||null!=a.id.publicKey&&null==o.id.publicKey?1:-1),function(){var s=j(function*(o){return yield Ul(o)});return function(o){return s.apply(this,arguments)}}());for(let s=0;e.running&&sFo(t)}(e=n.Status||(n.Status={})),function(a){a.HOP="HOP",a.STOP="STOP",a.STATUS="STATUS",a.CAN_HOP="CAN_HOP"}(r=n.Type||(n.Type={})),function(a){a[a.HOP=1]="HOP",a[a.STOP=2]="STOP",a[a.STATUS=3]="STATUS",a[a.CAN_HOP=4]="CAN_HOP"}(i||(i={})),function(a){a.codec=()=>Fo(i)}(r=n.Type||(n.Type={})),function(a){let u;a.codec=()=>(null==u&&(u=Yt((_,R,N={})=>{if(!1!==N.lengthDelimited&&R.fork(),null==_.id)throw new Error('Protocol error: required field "id" was not found in object');if(R.uint32(10),R.bytes(_.id),null==_.addrs)throw new Error('Protocol error: required field "addrs" was not found in object');for(const B of _.addrs)R.uint32(18),R.bytes(B);!1!==N.lengthDelimited&&R.ldelim()},(_,R)=>{const N={},B=null==R?_.len:_.pos+R;for(;_.pos>>3){case 1:N.id=_.bytes();break;case 2:N.addrs=N.addrs??[],N.addrs.push(_.bytes());break;default:_.skipType(7&K)}}if(N.addrs=N.addrs??[],null==N.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');if(null==N.addrs)throw new Error('Protocol error: value for required field "addrs" was not found in protobuf');return N})),u),a.encode=_=>qt(_,a.codec()),a.decode=_=>Wt(_,a.codec())}(s=n.Peer||(n.Peer={})),n.codec=()=>(null==o&&(o=Yt((a,u,_={})=>{!1!==_.lengthDelimited&&u.fork(),null!=a.type&&(u.uint32(8),n.Type.codec().encode(a.type,u)),null!=a.srcPeer&&(u.uint32(18),n.Peer.codec().encode(a.srcPeer,u)),null!=a.dstPeer&&(u.uint32(26),n.Peer.codec().encode(a.dstPeer,u)),null!=a.code&&(u.uint32(32),n.Status.codec().encode(a.code,u)),!1!==_.lengthDelimited&&u.ldelim()},(a,u)=>{const _={},R=null==u?a.len:a.pos+u;for(;a.pos>>3){case 1:_.type=n.Type.codec().decode(a);break;case 2:_.srcPeer=n.Peer.codec().decode(a,a.uint32());break;case 3:_.dstPeer=n.Peer.codec().decode(a,a.uint32());break;case 4:_.code=n.Status.codec().decode(a);break;default:a.skipType(7&N)}}return _})),o),n.encode=a=>qt(a,n.codec()),n.decode=a=>Wt(a,n.codec())}(nn||(nn={}));const o7=Gt("libp2p:stream:converter");function _T(n,e={}){const{stream:t,remoteAddr:r}=n,{sink:i,source:s}=t,o=dn(function*(){var B,R=!1,N=!1;try{for(var Z,K=Pt(s);R=!(Z=yield lt(K.next())).done;R=!1){const J=Z.value;yield*Mr(Pt(J),lt)}}catch(J){N=!0,B=J}finally{try{R&&null!=K.return&&(yield lt(K.return()))}finally{if(N)throw B}}})(),a={sink:R=>j(function*(){null!=e.signal&&(R=vs(R,e.signal));try{yield i(R),yield u()}catch(N){"aborted"!==N.type&&o7(N)}})(),source:null!=e.signal?vs(o,e.signal):o,remoteAddr:r,timeline:{open:Date.now(),close:void 0},close:()=>j(function*(){yield i(dn(function*(){yield new Uint8Array(0)})()),yield u()})()};function u(){return _.apply(this,arguments)}function _(){return(_=j(function*(){return null==a.timeline.close&&(a.timeline.close=Date.now()),yield Promise.resolve()})).apply(this,arguments)}return a}const $l="/libp2p/circuit/relay/0.1.0";function DT(n,e){n.write({type:nn.Type.STATUS,code:e})}function ST(n,e){try{null!=n.dstPeer?.addrs&&n.dstPeer.addrs.forEach(t=>new yn(t))}catch(t){throw DT(e,n.type===nn.Type.HOP?nn.Status.HOP_DST_MULTIADDR_INVALID:nn.Status.STOP_DST_MULTIADDR_INVALID),t}try{null!=n.srcPeer?.addrs&&n.srcPeer.addrs.forEach(t=>new yn(t))}catch(t){throw DT(e,n.type===nn.Type.HOP?nn.Status.HOP_SRC_MULTIADDR_INVALID:nn.Status.STOP_SRC_MULTIADDR_INVALID),t}}const jl=Gt("libp2p:circuit:stream-handler");class _h{constructor(e){const{stream:t,maxLength:r=4096}=e;this.stream=t,this.shake=Ld(this.stream),this.decoder=ps.fromReader(this.shake.reader,{maxDataLength:r})}read(){var e=this;return j(function*(){const t=yield e.decoder.next();if(null!=t.value){const r=nn.decode(t.value);return jl("read message type",r.type),r}jl("read received no value, closing stream"),e.close()})()}write(e){jl("write message type %s",e.type),this.shake.write(Os.single(nn.encode(e)))}rest(){return this.shake.rest(),this.shake.stream}end(e){this.write(e),this.close()}close(){jl("closing the stream"),this.rest().sink([]).catch(e=>{jl.error(e)})}}const Gl=Gt("libp2p:circuit:stop");function u7(n){return Ev.apply(this,arguments)}function Ev(){return Ev=j(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream($l,{signal:r});Gl("starting stop request to %p",e.remotePeer);const s=new _h({stream:i});s.write(t);const o=yield s.read();if(null!=o)return o.code===nn.Status.SUCCESS?(Gl("stop request to %p was successful",e.remotePeer),s.rest()):(Gl("stop request failed with code %d",o.code),void s.close());s.close()}),Ev.apply(this,arguments)}const Yi=Gt("libp2p:circuit:hop");function bv(){return bv=j(function*(n){const{connection:e,request:t,streamHandler:r,circuit:i,connectionManager:s}=n;if(!i.hopEnabled())return Yi("HOP request received but we are not acting as a relay"),r.end({type:nn.Type.STATUS,code:nn.Status.HOP_CANT_SPEAK_RELAY});try{ST(t,r)}catch(N){return void Yi.error("invalid hop request via peer %p %o",e.remotePeer,N)}if(null==t.dstPeer)return void Yi("HOP request received but we do not receive a dstPeer");const o=Jc(t.dstPeer.id),a=s.getConnections(o);if(0===a.length&&!i.hopActive())return Yi("HOP request received but we are not connected to the destination peer"),r.end({type:nn.Type.STATUS,code:nn.Status.HOP_NO_CONN_TO_DST});if(0===a.length)return Yi("did not have connection to remote peer"),r.end({type:nn.Type.STATUS,code:nn.Status.HOP_NO_CONN_TO_DST});const u={type:nn.Type.STOP,dstPeer:t.dstPeer,srcPeer:t.srcPeer};let _;try{Yi("performing STOP request");const N=yield u7({connection:a[0],request:u});if(null==N)throw new Error("Could not stop");_=N}catch(N){return void Yi.error(N)}Yi("hop request from %p is valid",e.remotePeer),r.write({type:nn.Type.STATUS,code:nn.Status.SUCCESS});const R=r.rest();return Yi("creating related connections"),yield Wn(R,_,R)}),bv.apply(this,arguments)}function wv(){return wv=j(function*(n){const{connection:e,request:t,signal:r}=n,i=yield e.newStream($l,{signal:r}),s=new _h({stream:i});s.write(t);const o=yield s.read();if(null==o)throw ae(new Error("HOP request had no response"),Ce.ERR_HOP_REQUEST_FAILED);if(o.code===nn.Status.SUCCESS)return Yi("hop request was successful"),s.rest();throw Yi("hop request failed with code %d, closing stream",o.code),s.close(),ae(new Error(`HOP request failed with code "${o.code??"unknown"}"`),Ce.ERR_HOP_REQUEST_FAILED)}),wv.apply(this,arguments)}function _v(){return _v=j(function*(n){const{connection:e,signal:t}=n,r=yield e.newStream($l,{signal:t}),i=new _h({stream:r});i.write({type:nn.Type.CAN_HOP});const s=yield i.read();return yield i.close(),!(null==s||s.code!==nn.Status.SUCCESS)}),_v.apply(this,arguments)}const Qi=Gt("libp2p:circuit");class p7{constructor(e){this.components=new ho,this._init=e}init(e){this.components=e,this.components.getRegistrar().handle($l,t=>{this._onProtocol(t).catch(r=>{Qi.error(r)})}).catch(t=>{Qi.error(t)})}hopEnabled(){return!0}hopActive(){return!0}get[cv](){return!0}get[Symbol.toStringTag](){return"libp2p/circuit-relay-v1"}_onProtocol(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t._init.hop.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=zo(i,s.signal),a=new _h({stream:{...i,...o}}),u=yield a.read();if(null==u)return Qi("request was invalid, could not read from stream"),a.write({type:nn.Type.STATUS,code:nn.Status.MALFORMED_MESSAGE}),void a.close();let _;switch(u.type){case nn.Type.CAN_HOP:Qi("received CAN_HOP request from %p",r.remotePeer),yield function h7(n){const{connection:e,streamHandler:t,circuit:r}=n,i=r.hopEnabled();Yi("can hop (%s) request from %p",i,e.remotePeer),t.end({type:nn.Type.STATUS,code:i?nn.Status.SUCCESS:nn.Status.HOP_CANT_SPEAK_RELAY})}({circuit:t,connection:r,streamHandler:a});break;case nn.Type.HOP:Qi("received HOP request from %p",r.remotePeer),yield function l7(n){return bv.apply(this,arguments)}({connection:r,request:u,streamHandler:a,circuit:t,connectionManager:t.components.getConnectionManager()});break;case nn.Type.STOP:Qi("received STOP request from %p",r.remotePeer),_=yield function c7(n){const{connection:e,request:t,streamHandler:r}=n;try{ST(t,r)}catch(i){return void Gl.error("invalid stop request via peer %p %o",e.remotePeer,i)}return Gl("stop request is valid"),r.write({type:nn.Type.STATUS,code:nn.Status.SUCCESS}),r.rest()}({connection:r,request:u,streamHandler:a});break;default:return Qi("Request of type %s not supported",u.type),a.write({type:nn.Type.STATUS,code:nn.Status.MALFORMED_MESSAGE}),void a.close()}if(null!=_){const B=_T({stream:_,remoteAddr:r.remoteAddr.encapsulate("/p2p-circuit").encapsulate(new yn(u.dstPeer?.addrs[0])),localAddr:new yn(u.srcPeer?.addrs[0])}),K=u.type===nn.Type.HOP?"relay":"inbound";Qi("new %s connection %s",K,B.remoteAddr);const Z=yield t.components.getUpgrader().upgradeInbound(B);Qi("%s connection %s upgraded",K,B.remoteAddr),null!=t.handler&&t.handler(Z)}}finally{s.clear()}})()}dial(e,t={}){var r=this;return j(function*(){const i=e.toString().split("/p2p-circuit"),s=new yn(i[0]),o=new yn(i[i.length-1]),a=s.getPeerId(),u=o.getPeerId();if(null==a||null==u){const Z="Circuit relay dial failed as addresses did not have peer id";throw Qi.error(Z),ae(new Error(Z),Ce.ERR_RELAYED_DIAL)}const _=fr(a),R=fr(u);let N=!1,K=r.components.getConnectionManager().getConnections(_)[0];null==K&&(yield r.components.getPeerStore().addressBook.add(_,[s]),K=yield r.components.getConnectionManager().openConnection(_,t),N=!0);try{const Z=yield function f7(n){return wv.apply(this,arguments)}({...t,connection:K,request:{type:nn.Type.HOP,srcPeer:{id:r.components.getPeerId().toBytes(),addrs:r.components.getAddressManager().getAddresses().map(he=>he.bytes)},dstPeer:{id:R.toBytes(),addrs:[new yn(o).bytes]}}}),J=s.encapsulate(`/p2p-circuit/p2p/${r.components.getPeerId().toString()}`),oe=_T({stream:Z,remoteAddr:e,localAddr:J});return Qi("new outbound connection %s",oe.remoteAddr),yield r.components.getUpgrader().upgradeOutbound(oe)}catch(Z){throw Qi.error("Circuit relay dial failed",Z),N&&(yield K.close()),Z}})()}createListener(e){return this.handler=e.handler,function a7(n){const e=new Map;function r(){return(r=j(function*(o){const a=o.toString().split("/p2p-circuit").find(K=>""!==K),u=new yn(a),_=u.getPeerId();if(null==_)throw new Error("Could not determine relay peer from multiaddr");const R=fr(_);yield n.peerStore.addressBook.add(R,[u]);const N=yield n.connectionManager.openConnection(R),B=N.remoteAddr.encapsulate("/p2p-circuit");e.set(N.remotePeer.toString(),B),s.dispatchEvent(new tn("listening"))})).apply(this,arguments)}const s=Object.assign(new Ei,{close:(o=j(function*(){return yield Promise.resolve()}),function(){return o.apply(this,arguments)}),listen:function t(o){return r.apply(this,arguments)},getAddrs:function i(){const o=[];for(const a of e.values())o.push(a);return o}});var o;return n.connectionManager.addEventListener("peer:disconnect",o=>{const{detail:a}=o;e.delete(a.remotePeer.toString())&&s.dispatchEvent(new tn("close"))}),s}({connectionManager:this.components.getConnectionManager(),peerStore:this.components.getPeerStore()})}filter(e){return(e=Array.isArray(e)?e:[e]).filter(t=>nu.matches(t))}}function CT(n){return Dv.apply(this,arguments)}function Dv(){return Dv=j(function*(n){const e=(new TextEncoder).encode(n),t=yield mi.digest(e);return _r.createV0(t)}),Dv.apply(this,arguments)}const TT="hop_relay",xT="/libp2p/relay",zl=Gt("libp2p:auto-relay"),v7=()=>{};class E7{constructor(e,t){this.components=e,this.addressSorter=t.addressSorter??pv,this.maxListeners=t.maxListeners??1,this.listenRelays=new Set,this.onError=t.onError??v7,this._onProtocolChange=this._onProtocolChange.bind(this),this._onPeerDisconnected=this._onPeerDisconnected.bind(this),this.components.getPeerStore().addEventListener("change:protocols",r=>{this._onProtocolChange(r).catch(i=>{zl.error(i)})}),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onPeerDisconnected)}_onProtocolChange(e){var t=this;return j(function*(){const{peerId:r,protocols:i}=e.detail,s=r.toString();if(null!=i.find(a=>a===$l)){if(!t.listenRelays.has(s))try{const a=t.components.getConnectionManager().getConnections(r);if(0===a.length)return;const u=a[0];if(u.remoteAddr.protoCodes().includes(290))return void zl(`relayed connection to ${s} will not be used to hop on`);(yield function d7(n){return _v.apply(this,arguments)}({connection:u}))&&(yield t.components.getPeerStore().metadataBook.setValue(r,TT,Ot("true")),yield t._addListenRelay(u,s))}catch(a){t.onError(a)}}else t.listenRelays.has(s)&&(yield t._removeListenRelay(s))})()}_onPeerDisconnected(e){const i=e.detail.remotePeer.toString();!this.listenRelays.has(i)||this._removeListenRelay(i).catch(s=>{zl.error(s)})}_addListenRelay(e,t){var r=this;return j(function*(){try{if(r.listenRelays.size>=r.maxListeners)return;const i=yield Wn(yield r.components.getPeerStore().addressBook.get(e.remotePeer),o=>gv(o,r.addressSorter),function(){var o=j(function*(a){return yield Ul(a)});return function(a){return o.apply(this,arguments)}}());(yield Promise.all(i.map(function(){var o=j(function*(a){try{let u=a.multiaddr;return null==u.getPeerId()&&(u=u.encapsulate(`/p2p/${e.remotePeer.toString()}`)),u=u.encapsulate("/p2p-circuit"),yield r.components.getTransportManager().listen([u]),!0}catch(u){zl.error("error listening on circuit address",u),r.onError(u)}return!1});return function(a){return o.apply(this,arguments)}}()))).includes(!0)&&r.listenRelays.add(t)}catch(i){r.onError(i),r.listenRelays.delete(t)}})()}_removeListenRelay(e){var t=this;return j(function*(){t.listenRelays.delete(e)&&(yield t._listenOnAvailableHopRelays([e]))})()}_listenOnAvailableHopRelays(e=[]){var t=this;return j(function*(){if(t.listenRelays.size>=t.maxListeners)return;const r=[],i=yield t.components.getPeerStore().all();for(const{id:R,metadata:N}of i){const B=R.toString();if(t.listenRelays.has(B)||e.includes(B))continue;const K=N.get(TT);if(null==K||"true"!==Lt(K))continue;const Z=t.components.getConnectionManager().getConnections(R);if(0!==Z.length){if(yield t._addListenRelay(Z[0],B),t.listenRelays.size>=t.maxListeners)return}else r.push(R)}for(const R of r)if(yield t._tryToListenOnRelay(R),t.listenRelays.size>=t.maxListeners)return;try{const R=yield CT(xT);var a,s=!1,o=!1;try{for(var _,u=Pt(t.components.getContentRouting().findProviders(R));s=!(_=yield u.next()).done;s=!1){const N=_.value;if(0===N.multiaddrs.length)continue;const B=N.id;if(yield t.components.getPeerStore().addressBook.add(B,N.multiaddrs),yield t._tryToListenOnRelay(B),t.listenRelays.size>=t.maxListeners)return}}catch(N){o=!0,a=N}finally{try{s&&null!=u.return&&(yield u.return())}finally{if(o)throw a}}}catch(R){t.onError(R)}})()}_tryToListenOnRelay(e){var t=this;return j(function*(){try{const r=yield t.components.getConnectionManager().openConnection(e);yield t._addListenRelay(r,e.toString())}catch(r){zl.error("Could not use %p as relay",e,r),t.onError(r,`could not connect and listen on known hop relay ${e.toString()}`)}})()}}const RT=Gt("libp2p:relay");class b7{constructor(e,t){this.components=e,this.autoRelay=!1!==t.autoRelay?.enabled?new E7(e,{addressSorter:t.addressSorter,...t.autoRelay}):void 0,this.started=!1,this.init=t,this._advertiseService=this._advertiseService.bind(this)}isStarted(){return this.started}start(){var e=this;return j(function*(){!1!==e.init.hop.enabled&&!1!==e.init.advertise.enabled&&(e.timeout=(0,bh.setDelayedInterval)(e._advertiseService,e.init.advertise.ttl,e.init.advertise.bootDelay)),e.started=!0})()}stop(){var e=this;return j(function*(){null!=e.timeout&&(0,bh.clearDelayedInterval)(e.timeout),e.started=!1})()}_advertiseService(){var e=this;return j(function*(){try{const t=yield CT(xT);yield e.components.getContentRouting().provide(t)}catch(t){t.code===Ce.ERR_NO_ROUTERS_AVAILABLE?(RT.error("a content router, such as a DHT, must be provided in order to advertise the relay service",t),yield e.stop()):RT.error(t)}})()}}var w7=x(9014);x(422),x(5911);const PT=Un.pki;function Sv(){return Sv=j(function*(n,e){const t=n.map(e);return n[(yield Promise.all(t)).findIndex(s=>s)]}),Sv.apply(this,arguments)}const S7=Gt("libp2p:keychain:cms"),Cv=new WeakMap;class C7{constructor(e,t){if(null==e)throw ae(new Error("keychain is required"),Ce.ERR_KEYCHAIN_REQUIRED);this.keychain=e,Cv.set(this,{dek:t})}encrypt(e,t){var r=this;return j(function*(){if(!(t instanceof Uint8Array))throw ae(new Error("Plain data must be a Uint8Array"),Ce.ERR_INVALID_PARAMETERS);const i=yield r.keychain.findKeyByName(e),s=yield r.keychain.getPrivateKey(e),o=Cv.get(r);if(null==o)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=Un.pki.decryptRsaPrivateKey(s,o.dek),_=yield((n,e)=>{const t=PT.rsa.setPublicKey(e.n,e.e),r=PT.createCertificate();r.publicKey=t,r.serialNumber="01",r.validity.notBefore=new Date,r.validity.notAfter=new Date,r.validity.notAfter.setFullYear(r.validity.notBefore.getFullYear()+10);const i=[{name:"organizationName",value:"ipfs"},{shortName:"OU",value:"keystore"},{name:"commonName",value:n.id}];return r.setSubject(i),r.setIssuer(i),r.setExtensions([{name:"basicConstraints",cA:!0},{name:"keyUsage",keyCertSign:!0,digitalSignature:!0,nonRepudiation:!0,keyEncipherment:!0,dataEncipherment:!0},{name:"extKeyUsage",serverAuth:!0,clientAuth:!0,codeSigning:!0,emailProtection:!0,timeStamping:!0},{name:"nsCertType",client:!0,server:!0,email:!0,objsign:!0,sslCA:!0,emailCA:!0,objCA:!0}]),r.sign(e),r})(i,u),R=Un.pkcs7.createEnvelopedData();return R.addRecipient(_),R.content=Un.util.createBuffer(t),R.encrypt(),Ot(Un.asn1.toDer(R.toAsn1()).getBytes(),"ascii")})()}decrypt(e){var t=this;return j(function*(){if(!(e instanceof Uint8Array))throw ae(new Error("CMS data is required"),Ce.ERR_INVALID_PARAMETERS);let r;try{const N=Un.util.createBuffer(Lt(e,"ascii")),B=Un.asn1.fromDer(N);r=Un.pkcs7.messageFromAsn1(B)}catch(N){throw S7.error(N),ae(new Error("Invalid CMS"),Ce.ERR_INVALID_CMS)}const i=r.recipients.filter(N=>N.issuer.find(B=>"O"===B.shortName&&"ipfs"===B.value)).filter(N=>N.issuer.find(B=>"CN"===B.shortName)).map(N=>({recipient:N,keyId:N.issuer.find(B=>"CN"===B.shortName).value})),s=yield function D7(n,e){return Sv.apply(this,arguments)}(i,function(){var N=j(function*(B){try{if(null!=(yield t.keychain.findKeyById(B.keyId)))return!0}catch{return!1}return!1});return function(B){return N.apply(this,arguments)}}());if(null==s){const N=i.map(B=>B.keyId);throw ae(new Error(`Decryption needs one of the key(s): ${N.join(", ")}`),Ce.ERR_MISSING_KEYS,{missingKeys:N})}const o=yield t.keychain.findKeyById(s.keyId);if(null==o)throw ae(new Error("No key available to decrypto"),Ce.ERR_NO_KEY);const a=yield t.keychain.getPrivateKey(o.name),u=Cv.get(t);if(null==u)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const R=Un.pki.decryptRsaPrivateKey(a,u.dek);return r.decrypt(s.recipient,R),Ot(r.content.getBytes(),"ascii")})()}}x(1298);var I7=x(7949);const MT={sha1:"sha1","sha2-256":"sha256","sha2-512":"sha512"};function OT(n,e,t,r,i){if("sha1"!==i&&"sha2-256"!==i&&"sha2-512"!==i){const a=Object.keys(MT).join(" / ");throw ae(new Error(`Hash '${i}' is unknown or not supported. Must be ${a}`),"ERR_UNSUPPORTED_HASH_TYPE")}const o=I7(n,e,t,r,MT[i]);return fF.encode64(o,null)}const Dh=Gt("libp2p:keychain"),Xo=new WeakMap,Tv={dek:{keyLength:64,iterationCount:1e4,salt:"you should override this value with a crypto secure random number",hash:"sha2-512"}};function mo(n){return null!=n&&"string"==typeof n&&n===w7(n.trim())&&n.length>0}function kn(){return Av.apply(this,arguments)}function Av(){return(Av=j(function*(){const t=800*Math.random()+200;yield new Promise(r=>setTimeout(r,t))})).apply(this,arguments)}function Us(n){return new Ur("/pkcs8/"+n)}function Jo(n){return new Ur("/info/"+n)}class LT{constructor(e,t){if(this.components=e,this.init=Hl(Tv,t),null!=this.init.pass&&this.init.pass?.length<20)throw new Error("pass must be least 20 characters");if(null!=this.init.dek?.keyLength&&this.init.dek.keyLength<14)throw new Error("dek.keyLength must be least 14 bytes");if(null!=this.init.dek?.salt?.length&&this.init.dek.salt.length<16)throw new Error("dek.saltLength must be least 16 bytes");if(null!=this.init.dek?.iterationCount&&this.init.dek.iterationCount<1e3)throw new Error("dek.iterationCount must be least 1000");const r=null!=this.init.pass&&null!=this.init.dek?.salt?OT(this.init.pass,this.init.dek?.salt,this.init.dek?.iterationCount,this.init.dek?.keyLength,this.init.dek?.hash):"";Xo.set(this,{dek:r})}get cms(){const e=Xo.get(this);if(null==e)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);return new C7(this,e.dek)}static generateOptions(){const e=Object.assign({},Tv),t=3*Math.ceil(16/3);return e.dek.salt=Lt(nh(t),"base64"),e}static get options(){return Tv}createKey(e,t,r=2048){var i=this;return j(function*(){if(!mo(e)||"self"===e)throw yield kn(),ae(new Error("Invalid key name"),Ce.ERR_INVALID_KEY_NAME);if("string"!=typeof t)throw yield kn(),ae(new Error("Invalid key type"),Ce.ERR_INVALID_KEY_TYPE);const s=Us(e);if(yield i.components.getDatastore().has(s))throw yield kn(),ae(new Error("Key name already exists"),Ce.ERR_KEY_ALREADY_EXISTS);if("rsa"===t.toLowerCase()&&(!Number.isSafeInteger(r)||r<2048))throw yield kn(),ae(new Error("Invalid RSA key size"),Ce.ERR_INVALID_KEY_SIZE);let a;try{const u=yield s2(t,r),_=yield u.id(),R=Xo.get(i);if(null==R)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const N=R.dek,B=yield u.export(N);a={name:e,id:_};const K=i.components.getDatastore().batch();K.put(s,Ot(B)),K.put(Jo(e),Ot(JSON.stringify(a))),yield K.commit()}catch(u){throw yield kn(),u}return a})()}listKeys(){var e=this;return j(function*(){const t={prefix:"/info/"},r=[];var o,i=!1,s=!1;try{for(var u,a=Pt(e.components.getDatastore().query(t));i=!(u=yield a.next()).done;i=!1)r.push(JSON.parse(Lt(u.value.value)))}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}return r})()}findKeyById(e){var t=this;return j(function*(){try{return(yield t.listKeys()).find(i=>i.id===e)}catch(r){throw yield kn(),r}})()}findKeyByName(e){var t=this;return j(function*(){if(!mo(e))throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);const r=Jo(e);try{const i=yield t.components.getDatastore().get(r);return JSON.parse(Lt(i))}catch(i){throw yield kn(),Dh.error(i),ae(new Error(`Key '${e}' does not exist.`),Ce.ERR_KEY_NOT_FOUND)}})()}removeKey(e){var t=this;return j(function*(){if(!mo(e)||"self"===e)throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);const r=Us(e),i=yield t.findKeyByName(e),s=t.components.getDatastore().batch();return s.delete(r),s.delete(Jo(e)),yield s.commit(),i})()}renameKey(e,t){var r=this;return j(function*(){if(!mo(e)||"self"===e)throw yield kn(),ae(new Error(`Invalid old key name '${e}'`),Ce.ERR_OLD_KEY_NAME_INVALID);if(!mo(t)||"self"===t)throw yield kn(),ae(new Error(`Invalid new key name '${t}'`),Ce.ERR_NEW_KEY_NAME_INVALID);const i=Us(e),s=Us(t),o=Jo(e),a=Jo(t);if(yield r.components.getDatastore().has(s))throw yield kn(),ae(new Error(`Key '${t}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);try{const _=yield r.components.getDatastore().get(i),R=yield r.components.getDatastore().get(o),N=JSON.parse(Lt(R));N.name=t;const B=r.components.getDatastore().batch();return B.put(s,_),B.put(a,Ot(JSON.stringify(N))),B.delete(i),B.delete(o),yield B.commit(),N}catch(_){throw yield kn(),_}})()}exportKey(e,t){var r=this;return j(function*(){if(!mo(e))throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t)throw yield kn(),ae(new Error("Password is required"),Ce.ERR_PASSWORD_REQUIRED);const i=Us(e);try{const o=Lt(yield r.components.getDatastore().get(i)),a=Xo.get(r);if(null==a)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=a.dek;return yield(yield Pm(o,u)).export(t)}catch(s){throw yield kn(),s}})()}importKey(e,t,r){var i=this;return j(function*(){if(!mo(e)||"self"===e)throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t)throw yield kn(),ae(new Error("PEM encoded key is required"),Ce.ERR_PEM_REQUIRED);const s=Us(e);if(yield i.components.getDatastore().has(s))throw yield kn(),ae(new Error(`Key '${e}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);let a,u;try{a=yield Pm(t,r)}catch{throw yield kn(),ae(new Error("Cannot read the key, most likely the password is wrong"),Ce.ERR_CANNOT_READ_KEY)}try{u=yield a.id();const N=Xo.get(i);if(null==N)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const B=N.dek;t=yield a.export(B)}catch(N){throw yield kn(),N}const _={name:e,id:u},R=i.components.getDatastore().batch();return R.put(s,Ot(t)),R.put(Jo(e),Ot(JSON.stringify(_))),yield R.commit(),_})()}importPeer(e,t){var r=this;return j(function*(){try{if(!mo(e))throw ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);if(null==t||null==t.privateKey)throw ae(new Error("Peer.privKey is required"),Ce.ERR_MISSING_PRIVATE_KEY);const i=yield Pl(t.privateKey),s=Us(e);if(yield r.components.getDatastore().has(s))throw yield kn(),ae(new Error(`Key '${e}' already exists`),Ce.ERR_KEY_ALREADY_EXISTS);const a=Xo.get(r);if(null==a)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const u=a.dek,_=yield i.export(u),R={name:e,id:t.toString()},N=r.components.getDatastore().batch();return N.put(s,Ot(_)),N.put(Jo(e),Ot(JSON.stringify(R))),yield N.commit(),R}catch(i){throw yield kn(),i}})()}getPrivateKey(e){var t=this;return j(function*(){if(!mo(e))throw yield kn(),ae(new Error(`Invalid key name '${e}'`),Ce.ERR_INVALID_KEY_NAME);try{const r=Us(e);return Lt(yield t.components.getDatastore().get(r))}catch(r){throw yield kn(),Dh.error(r),ae(new Error(`Key '${e}' does not exist.`),Ce.ERR_KEY_NOT_FOUND)}})()}rotateKeychainPass(e,t){var r=this;return j(function*(){if("string"!=typeof e)throw yield kn(),ae(new Error(`Invalid old pass type '${typeof e}'`),Ce.ERR_INVALID_OLD_PASS_TYPE);if("string"!=typeof t)throw yield kn(),ae(new Error(`Invalid new pass type '${typeof t}'`),Ce.ERR_INVALID_NEW_PASS_TYPE);if(t.length<20)throw yield kn(),ae(new Error(`Invalid pass length ${t.length}`),Ce.ERR_INVALID_PASS_LENGTH);Dh("recreating keychain");const i=Xo.get(r);if(null==i)throw ae(new Error("dek missing"),Ce.ERR_INVALID_PARAMETERS);const s=i.dek;r.init.pass=t;const o=null!=t&&null!=r.init.dek?.salt?OT(t,r.init.dek.salt,r.init.dek?.iterationCount,r.init.dek?.keyLength,r.init.dek?.hash):"";Xo.set(r,{dek:o});const a=yield r.listKeys();for(const u of a){const R=Lt(yield r.components.getDatastore().get(Us(u.name))),N=yield Pm(R,s),B=o.toString(),K=yield N.export(B),Z=r.components.getDatastore().batch(),J={name:u.name,id:u.id};Z.put(Us(u.name),Ot(K)),Z.put(Jo(u.name),Ot(JSON.stringify(J))),yield Z.commit()}Dh("keychain reconstructed")})()}}var xv=x(1349),A7=x(5550);class x7{constructor(e){if("number"!=typeof e)throw new Error("must provide a timespan to the moving average constructor");if(e<=0)throw new Error("must provide a timespan > 0 to the moving average constructor");this.timespan=e,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(e,t){return 1-Math.exp(-(e-t)/this.timespan)}push(e,t){if(null!=this.previousTime){const r=this.alpha(e,this.previousTime),i=t-this.movingAverage,s=r*i;this.movingAverage=r*t+(1-r)*this.movingAverage,this.variance=(1-r)*(this.variance+i*s),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+r*i}else this.movingAverage=t;this.previousTime=e}}function BT(n){return new x7(n)}class Rv extends Ei{constructor(e){super(),this.enabled=e.enabled,this.queue=[],this.stats={dataReceived:0n,dataSent:0n},this.frequencyLastTime=Date.now(),this.frequencyAccumulators={},this.movingAverages={dataReceived:[],dataSent:[]},this.computeThrottleMaxQueueSize=e.computeThrottleMaxQueueSize,this.computeThrottleTimeout=e.computeThrottleTimeout,this._update=this._update.bind(this),this.movingAverageIntervals=e.movingAverageIntervals;for(let t=0;t0&&this._resetComputeTimeout()}stop(){null!=this.timeout&&(this.timeout.clear(),this.timeout=null)}getSnapshot(){return Object.assign({},this.stats)}getMovingAverages(){return Object.assign({},this.movingAverages)}push(e,t){this.queue.push([e,t,Date.now()]),this._resetComputeTimeout()}_resetComputeTimeout(){this.timeout=Kl(this._update,this._nextTimeout())}_nextTimeout(){return Math.max(this.computeThrottleTimeout*(1-this.queue.length/this.computeThrottleMaxQueueSize),0)}_update(){if(this.timeout=null,this.queue.length>0){let e=["",0,0];for(e of this.queue)this._applyOp(e);this.queue=[],e.length>2&&""!==e[0]&&this._updateFrequency(e[2]),this.dispatchEvent(new tn("update",{detail:this.stats}))}}_updateFrequency(e){const t=e-this.frequencyLastTime;this._updateFrequencyFor("dataReceived",t,e),this._updateFrequencyFor("dataSent",t,e),this.frequencyLastTime=e}_updateFrequencyFor(e,t,r){const i=this.frequencyAccumulators[e]??0;this.frequencyAccumulators[e]=0;const o=i/(t??1)*1e3;let a=this.movingAverages[e];null==a&&(a=this.movingAverages[e]=[]);const u=this.movingAverageIntervals;for(let _=0;_s:s})}forPeer(e){const t=e.toString();return this.peerStats.get(t)??this.oldPeers.get(t)}getProtocols(){return Array.from(this.protocolStats.keys())}forProtocol(e){return this.protocolStats.get(e)}onPeerDisconnected(e){const t=e.toString(),r=this.peerStats.get(t);null!=r&&(r.stop(),this.peerStats.delete(t),this.oldPeers.set(t,r))}_onMessage(e){if(!this.running)return;const{remotePeer:t,protocol:r,direction:i,dataLength:s}=e,o=P7[i];let a=this.forPeer(t);if(null==a){const u=new Rv(this.statsInit);this.peerStats.set(t.toString(),u),a=u}if(a.push(o,s),this.globalStats.push(o,s),null!=r){let u=this.forProtocol(r);if(null==u){const _=new Rv(this.statsInit);this.protocolStats.set(r,_),u=_}u.push(o,s)}}updatePlaceholder(e,t){if(!this.running)return;const r=e.toString(),i=this.peerStats.get(r)??this.oldPeers.get(r),s=t.toString(),o=this.peerStats.get(s)??this.oldPeers.get(s);let a=i;null!=o&&(a=function M7(n,e){return n.stop(),e.stop(),n.queue=[...n.queue,...e.queue],n}(o,a),this.oldPeers.remove(s)),this.peerStats.delete(e.toString()),this.peerStats.set(s,a),a.start()}trackStream(e){var t=this;const{stream:r,remotePeer:i,protocol:s}=e;if(!this.running)return;r.source=xv(r.source,u=>this._onMessage({remotePeer:i,protocol:s,direction:"in",dataLength:u.byteLength}));const a=r.sink;r.sink=function(){var u=j(function*(_){return yield Wn(_,R=>xv(R,N=>{t._onMessage({remotePeer:i,protocol:s,direction:"out",dataLength:N.byteLength})}),a)});return function(_){return u.apply(this,arguments)}}()}}function Pv(n){return Nv.apply(this,arguments)}function Nv(){return Nv=j(function*(n){try{return{status:"fulfilled",value:yield n,isFulfilled:!0,isRejected:!1}}catch(e){return{status:"rejected",reason:e,isFulfilled:!1,isRejected:!0}}}),Nv.apply(this,arguments)}class O7{constructor(e){cb(this,"value"),cb(this,"next"),this.value=e}}class k7{constructor(){hp(this,js,void 0),hp(this,Va,void 0),hp(this,Ha,void 0),this.clear()}enqueue(e){const t=new O7(e);aa(this,js)?(aa(this,Va).next=t,So(this,Va,t)):(So(this,js,t),So(this,Va,t)),ub(this,Ha)._++}dequeue(){const e=aa(this,js);if(e)return So(this,js,aa(this,js).next),ub(this,Ha)._--,e.value}clear(){So(this,js,void 0),So(this,Va,void 0),So(this,Ha,0)}get size(){return aa(this,Ha)}*[Symbol.iterator](){let e=aa(this,js);for(;e;)yield e.value,e=e.next}}function L7(n){if(!Number.isInteger(n)&&n!==Number.POSITIVE_INFINITY||!(n>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const e=new k7;let t=0;const i=function(){var a=j(function*(u,_,R){t++;const N=j(function*(){return u(...R)})();_(N);try{yield N}catch{}t--,e.size>0&&e.dequeue()()});return function(_,R,N){return a.apply(this,arguments)}}(),o=(a,...u)=>new Promise(_=>{((a,u,_)=>{e.enqueue(i.bind(void 0,a,u,_)),j(function*(){yield Promise.resolve(),t0&&e.dequeue()()})()})(a,_,u)});return Object.defineProperties(o,{activeCount:{get:()=>t},pendingCount:{get:()=>e.size},clearQueue:{value:()=>{e.clear()}}}),o}function B7(n){return Mv.apply(this,arguments)}function Mv(){return Mv=j(function*(n,e={}){const{concurrency:t=Number.POSITIVE_INFINITY}=e,r=L7(t);return Promise.all(n.map(i=>Pv(i&&"function"==typeof i.then?i:"function"==typeof i?r(()=>i()):Promise.resolve(i))))}),Mv.apply(this,arguments)}js=new WeakMap,Va=new WeakMap,Ha=new WeakMap;const Ra=Gt("libp2p:transports");class F7 extends Ei{constructor(e,t={}){super(),this.components=e,this.started=!1,this.transports=new Map,this.listeners=Ll({component:"transport-manager",metric:"listeners",metrics:this.components.getMetrics()}),this.faultTolerance=t.faultTolerance??Pa.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw ae(new Error("Transport must have a valid tag"),Ce.ERR_INVALID_KEY);if(this.transports.has(t))throw ae(new Error("There is already a transport with this tag"),Ce.ERR_DUPLICATE_TRANSPORT);Ra("adding transport %s",t),this.transports.set(t,e),this.listeners.has(t)||this.listeners.set(t,[])}isStarted(){return this.started}start(){var e=this;return j(function*(){const t=e.components.getAddressManager().getListenAddrs();yield e.listen(t),e.started=!0})()}stop(){var e=this;return j(function*(){const t=[];for(const[r,i]of e.listeners)for(Ra("closing listeners for %s",r);i.length>0;){const s=i.pop();null!=s&&t.push(s.close())}yield Promise.all(t),Ra("all listeners closed");for(const r of e.listeners.keys())e.listeners.set(r,[]);e.started=!1})()}dial(e,t){var r=this;return j(function*(){const i=r.transportForMultiaddr(e);if(null==i)throw ae(new Error(`No transport available for address ${String(e)}`),Ce.ERR_TRANSPORT_UNAVAILABLE);try{return yield i.dial(e,{...t,upgrader:r.components.getUpgrader()})}catch(s){throw null==s.code&&(s.code=Ce.ERR_TRANSPORT_DIAL_FAILED),s}})()}getAddrs(){let e=[];for(const t of this.listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}transportForMultiaddr(e){for(const t of this.transports.values())if(t.filter([e]).length>0)return t}listen(e){var t=this;return j(function*(){if(null==e||0===e.length)return void Ra("no addresses were provided for listening, this node is dial only");const r=[];for(const[i,s]of t.transports.entries()){const o=s.filter(e),a=[];for(const R of o){Ra("creating listener for %s on %s",i,R);const N=s.createListener({upgrader:t.components.getUpgrader()});let B=t.listeners.get(i);null==B&&(B=[],t.listeners.set(i,B)),B.push(N),N.addEventListener("listening",()=>{t.dispatchEvent(new tn("listener:listening",{detail:N}))}),N.addEventListener("close",()=>{t.dispatchEvent(new tn("listener:close",{detail:N}))}),a.push(N.listen(R))}if(0!==a.length){if(null==(yield B7(a)).find(R=>R.isFulfilled)&&t.faultTolerance!==Pa.NO_FATAL)throw ae(new Error(`Transport (${i}) could not listen on any available address`),Ce.ERR_NO_VALID_ADDRESSES)}else r.push(i)}if(r.length===t.transports.size){const i=`no valid addresses were provided for transports [${r.join(", ")}]`;if(t.faultTolerance===Pa.FATAL_ALL)throw ae(new Error(i),Ce.ERR_NO_VALID_ADDRESSES);Ra(`libp2p in dial mode only: ${i}`)}})()}remove(e){var t=this;return j(function*(){Ra("removing %s",e);for(const r of t.listeners.get(e)??[])yield r.close();t.transports.delete(e),t.listeners.delete(e)})()}removeAll(){var e=this;return j(function*(){const t=[];for(const r of e.transports.keys())t.push(e.remove(r));yield Promise.all(t)})()}}var Pa=(()=>(function(n){n[n.FATAL_ALL=0]="FATAL_ALL",n[n.NO_FATAL=1]="NO_FATAL"}(Pa||(Pa={})),Pa))();const ru="/multistream/1.0.0",FT=Ot("\n");function Ov(n){const e=new qr(n,FT);return Os.single(e)}function Wl(n,e,t={}){const r=Ov(e);n.push(!0===t.writeBytes?r.subarray():r)}function U7(n,e,t={}){const r=new qr;for(const i of e)r.append(Ov(i));n.push(!0===t.writeBytes?r.subarray():r)}function V7(n,e){return kv.apply(this,arguments)}function kv(){return kv=j(function*(n,e){let t=1;const r={[Symbol.asyncIterator]:()=>r,next:(a=j(function*(){return yield n.next(t)}),function(){return a.apply(this,arguments)})};var a;let i=r;null!=e?.signal&&(i=vs(r,e.signal));const o=yield Wn(i,ps({onLength:a=>{t=a}}),function(){var a=j(function*(u){return yield Aa(u)});return function(u){return a.apply(this,arguments)}}());if(null==o)throw ae(new Error("no buffer returned"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");if(o.get(o.byteLength-1)!==FT[0])throw ae(new Error("missing newline"),"ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return o.sublist(0,-1)}),kv.apply(this,arguments)}function Sh(n,e){return Lv.apply(this,arguments)}function Lv(){return Lv=j(function*(n,e){return Lt((yield V7(n,e)).subarray())}),Lv.apply(this,arguments)}const ql=Gt("libp2p:mss:select");function Bv(n,e){return Fv.apply(this,arguments)}function Fv(){return Fv=j(function*(n,e,t={}){e=Array.isArray(e)?[...e]:[e];const{reader:r,writer:i,rest:s,stream:o}=Ld(n),a=e.shift();if(null==a)throw new Error("At least one protocol must be specified");ql('select: write ["%s", "%s"]',ru,a),U7(i,[Ot(ru),Ot(a)],t);let R=yield Sh(r,t);if(ql('select: read "%s"',R),R===ru&&(R=yield Sh(r,t),ql('select: read "%s"',R)),R===a)return s(),{stream:o,protocol:a};for(const N of e){ql('select: write "%s"',N),Wl(i,Ot(N),t);const B=yield Sh(r,t);if(ql('select: read "%s" for "%s"',B,N),B===N)return s(),{stream:o,protocol:N}}throw s(),ae(new Error("protocol selection failed"),"ERR_UNSUPPORTED_PROTOCOL")}),Fv.apply(this,arguments)}const Yl=Gt("libp2p:mss:handle");function Uv(n,e,t){return Vv.apply(this,arguments)}function Vv(){return Vv=j(function*(n,e,t){e=Array.isArray(e)?e:[e];const{writer:r,reader:i,rest:s,stream:o}=Ld(n);for(;;){const a=yield Sh(i,t);if(Yl('read "%s"',a),a!==ru){if(e.includes(a))return Wl(r,Ot(a),t),Yl('respond with "%s" for "%s"',a,a),s(),{stream:o,protocol:a};"ls"!==a?(Wl(r,Ot("na"),t),Yl('respond with "na" for "%s"',a)):(Wl(r,new qr(...e.map(u=>Ov(Ot(u)))),t),Yl('respond with "%s" for %s',e,a))}else Yl('respond with "%s" for "%s"',ru,a),Wl(r,Ot(ru),t)}}),Vv.apply(this,arguments)}var UT=x(344);const VT=Symbol.for("@libp2p/connection"),H7=Gt("libp2p:connection");class K7{constructor(e){const{remoteAddr:t,remotePeer:r,newStream:i,close:s,getStreams:o,stat:a}=e;this.id=`${parseInt(String(1e9*Math.random())).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=r,this.stat={...a,status:"OPEN"},this._newStream=i,this._close=s,this._getStreams=o,this.tags=[],this._closing=!1}get[Symbol.toStringTag](){return"Connection"}get[VT](){return!0}get streams(){return this._getStreams()}newStream(e,t){var r=this;return j(function*(){if(r.stat.status===pT)throw ae(new Error("the connection is being closed"),"ERR_CONNECTION_BEING_CLOSED");if(r.stat.status===hv)throw ae(new Error("the connection is closed"),"ERR_CONNECTION_CLOSED");Array.isArray(e)||(e=[e]);const i=yield r._newStream(e,t);return i.stat.direction="outbound",i})()}addStream(e){e.stat.direction="inbound"}removeStream(e){}close(){var e=this;return j(function*(){if(e.stat.status!==hv&&!e._closing){e.stat.status=pT;try{e.streams.forEach(t=>t.close())}catch(t){H7.error(t)}e._closing=!0,yield e._close(),e._closing=!1,e.stat.timeline.close=Date.now(),e.stat.status=hv}})()}}const Hv=Symbol.for("@libp2p/topology"),HT=Gt("libp2p:registrar");class G7{constructor(e){this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onProtocolChange=this._onProtocolChange.bind(this),this.components.getConnectionManager().addEventListener("peer:disconnect",this._onDisconnect),this.components.getPeerStore().addEventListener("change:protocols",this._onProtocolChange)}getProtocols(){return Array.from(new Set([...this.topologies.keys(),...this.handlers.keys()])).sort()}getHandler(e){const t=this.handlers.get(e);if(null==t)throw ae(new Error(`No handler registered for protocol ${e}`),Ce.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){const t=this.topologies.get(e);return null==t?[]:[...t.values()]}handle(e,t,r){var i=this;return j(function*(){if(i.handlers.has(e))throw ae(new Error(`Handler already registered for protocol ${e}`),Ce.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const s=Hl.bind({ignoreUndefined:!0})({maxInboundStreams:32,maxOutboundStreams:64},r);i.handlers.set(e,{handler:t,options:s}),yield i.components.getPeerStore().protoBook.add(i.components.getPeerId(),[e])})()}unhandle(e){var t=this;return j(function*(){const r=Array.isArray(e)?e:[e];r.forEach(i=>{t.handlers.delete(i)}),yield t.components.getPeerStore().protoBook.remove(t.components.getPeerId(),r)})()}register(e,t){var r=this;return j(function*(){if(!function j7(n){return null!=n&&Boolean(n[Hv])}(t))throw HT.error("topology must be an instance of interfaces/topology"),ae(new Error("topology must be an instance of interfaces/topology"),Ce.ERR_INVALID_PARAMETERS);const i=`${(1e9*Math.random()).toString(36)}${Date.now()}`;let s=r.topologies.get(e);return null==s&&(s=new Map,r.topologies.set(e,s)),s.set(i,t),yield t.setRegistrar(r),i})()}unregister(e){for(const[t,r]of this.topologies.entries())r.has(e)&&(r.delete(e),0===r.size&&this.topologies.delete(t))}_onDisconnect(e){const t=e.detail;this.components.getPeerStore().protoBook.get(t.remotePeer).then(r=>{for(const i of r){const s=this.topologies.get(i);if(null!=s)for(const o of s.values())o.onDisconnect(t.remotePeer)}}).catch(r=>{HT.error(r)})}_onProtocolChange(e){const{peerId:t,protocols:r,oldProtocols:i}=e.detail,s=i.filter(a=>!r.includes(a)),o=r.filter(a=>!i.includes(a));for(const a of s){const u=this.topologies.get(a);if(null!=u)for(const _ of u.values())_.onDisconnect(t)}for(const a of o){const u=this.topologies.get(a);if(null!=u)for(const _ of u.values()){const R=this.components.getConnectionManager().getConnections(t)[0];null!=R&&_.onConnect(t,R)}}}}const Gn=Gt("libp2p:upgrader");function jT(n,e,t){let r=0;return t.streams.forEach(i=>{i.stat.direction===e&&i.stat.protocol===n&&r++}),r}class q7 extends Ei{constructor(e,t){super(),this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(r=>{this.connectionEncryption.set(r.protocol,r)}),this.muxers=new Map,t.muxers.forEach(r=>{this.muxers.set(r.protocol,r)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout}upgradeInbound(e){var t=this;return j(function*(){let r,i,s,o,a,u,_;const R=t.components.getMetrics(),N=new bi.TimeoutController(t.inboundUpgradeTimeout);try{(0,Vr.setMaxListeners)?.(1/0,N.signal)}catch{}try{const B=zo(e,N.signal);if(e.source=B.source,e.sink=B.sink,yield t.components.getConnectionGater().denyInboundConnection(e))throw ae(new Error("The multiaddr connection is blocked by gater.acceptConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(null!=R){({setTarget:u,proxy:_}=UT());const J=`${(1e9*Math.random()).toString(36)}${Date.now()}`;u({toString:()=>J}),R.trackStream({stream:e,remotePeer:_})}Gn("starting the inbound connection upgrade");let K=e;const Z=t.components.getConnectionProtector();null!=Z&&(Gn("protecting the inbound connection"),K=yield Z.protect(e));try{if(({conn:r,remotePeer:i,protocol:a}=yield t._encryptInbound(K)),yield t.components.getConnectionGater().denyInboundEncryptedConnection(i,{...K,...r}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const J=yield t._multiplexInbound({...K,...r},t.muxers);o=J.muxerFactory,s=J.stream}else s=r}catch(J){throw Gn.error("Failed to upgrade inbound connection",J),yield e.close(J),J}if(yield t.components.getConnectionGater().denyInboundUpgradedConnection(i,{...K,...r}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);return null!=R&&(R.updatePlaceholder(_,i),u(i)),Gn("Successfully upgraded inbound connection"),t._createConnection({cryptoProtocol:a,direction:"inbound",maConn:e,upgradedConn:s,muxerFactory:o,remotePeer:i})}finally{N.clear()}})()}upgradeOutbound(e){var t=this;return j(function*(){const r=e.remoteAddr.getPeerId();if(null==r)throw ae(new Error("outbound connection must have a peer id"),Ce.ERR_INVALID_MULTIADDR);const i=fr(r);if(yield t.components.getConnectionGater().denyOutboundConnection(i,e))throw ae(new Error("The multiaddr connection is blocked by connectionGater.denyOutboundConnection"),Ce.ERR_CONNECTION_INTERCEPTED);let s,o,a,u,_,R,N;const B=t.components.getMetrics();if(null!=B){({setTarget:R,proxy:N}=UT());const J=`${(1e9*Math.random()).toString(36)}${Date.now()}`;R({toB58String:()=>J}),B.trackStream({stream:e,remotePeer:N})}Gn("Starting the outbound connection upgrade");let K=e;const Z=t.components.getConnectionProtector();null!=Z&&(K=yield Z.protect(e));try{if(({conn:s,remotePeer:o,protocol:u}=yield t._encryptOutbound(K,i)),yield t.components.getConnectionGater().denyOutboundEncryptedConnection(o,{...K,...s}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);if(t.muxers.size>0){const J=yield t._multiplexOutbound({...K,...s},t.muxers);_=J.muxerFactory,a=J.stream}else a=s}catch(J){throw Gn.error("Failed to upgrade outbound connection",J),yield e.close(J),J}if(yield t.components.getConnectionGater().denyOutboundUpgradedConnection(o,{...K,...s}))throw ae(new Error("The multiaddr connection is blocked by gater.acceptEncryptedConnection"),Ce.ERR_CONNECTION_INTERCEPTED);return null!=B&&(B.updatePlaceholder(N,o),R(o)),Gn("Successfully upgraded outbound connection"),t._createConnection({cryptoProtocol:u,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:_,remotePeer:o})})()}_createConnection(e){var t=this;const{cryptoProtocol:r,direction:i,maConn:s,upgradedConn:o,remotePeer:a,muxerFactory:u}=e;let _,R,N;null!=u&&(_=u.createStreamMuxer({direction:i,onIncomingStream:Z=>{null!=N&&Promise.resolve().then(j(function*(){const J=t.components.getRegistrar().getProtocols(),{stream:oe,protocol:he}=yield Uv(Z,J);if(Gn("%s: incoming stream opened on %s",i,he),t.components.getMetrics()?.trackStream({stream:oe,remotePeer:a,protocol:he}),null==N)return;const ue=function z7(n,e){try{const{options:t}=e.getHandler(n);return t.maxInboundStreams}catch(t){if(t.code!==Ce.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 32}(he,t.components.getRegistrar());jT(he,"inbound",N)!==ue?(Z.stat.protocol=he,t.components.getPeerStore().protoBook.add(a,[he]).catch(ze=>Gn.error(ze)),N.addStream(Z),t._onStream({connection:N,stream:{...Z,...oe},protocol:he})):Z.abort(ae(new Error(`Too many inbound protocol streams for protocol "${he}" - limit ${ue}`),Ce.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS))})).catch(J=>{Gn.error(J),null==Z.stat.timeline.close&&Z.close()})},onStreamEnd:Z=>{N?.removeStream(Z.id)}}),Fr(_)&&_.init(this.components),R=function(){var Z=j(function*(J,oe={}){if(null==_)throw ae(new Error("Stream is not multiplexed"),Ce.ERR_MUXER_UNAVAILABLE);Gn("%s: starting new stream on %s",i,J);const he=_.newStream(),Ie=t.components.getMetrics();let ue;try{if(null==oe.signal){Gn("No abort signal was passed while trying to negotiate protocols %s falling back to default timeout",J),ue=new bi.TimeoutController(3e4),oe.signal=ue.signal;try{(0,Vr.setMaxListeners)?.(1/0,ue.signal)}catch{}}const{stream:Re,protocol:ze}=yield Bv(he,J,oe);Ie?.trackStream({stream:Re,remotePeer:a,protocol:ze});const Oe=function W7(n,e){try{const{options:t}=e.getHandler(n);return t.maxOutboundStreams}catch(t){if(t.code!==Ce.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return 64}(ze,t.components.getRegistrar());if(jT(ze,"outbound",N)===Oe){const vt=ae(new Error(`Too many outbound protocol streams for protocol "${ze}" - limit ${Oe}`),Ce.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw he.abort(vt),vt}return he.stat.protocol=ze,t.components.getPeerStore().protoBook.add(a,[ze]).catch(vt=>Gn.error(vt)),{...he,...Re,stat:{...he.stat,protocol:ze}}}catch(Re){throw Gn.error("could not create new stream",Re),null==he.stat.timeline.close&&he.close(),null!=Re.code?Re:ae(Re,Ce.ERR_UNSUPPORTED_PROTOCOL)}finally{ue?.clear()}});return function(oe){return Z.apply(this,arguments)}}(),Wn(o,_,o).catch(Gn.error));const B=s.timeline;s.timeline=new Proxy(B,{set:(...Z)=>(null!=N&&"close"===Z[1]&&null!=Z[2]&&null==B.close&&j(function*(){try{"OPEN"===N.stat.status&&(yield N.close())}catch(J){Gn.error(J)}finally{t.dispatchEvent(new tn("connectionEnd",{detail:N}))}})().catch(J=>{Gn.error(J)}),Reflect.set(...Z))}),s.timeline.upgraded=Date.now();const K=()=>{throw ae(new Error("connection is not multiplexed"),Ce.ERR_CONNECTION_NOT_MULTIPLEXED)};return N=function $7(n){return new K7(n)}({remoteAddr:s.remoteAddr,remotePeer:a,stat:{status:"OPEN",direction:i,timeline:s.timeline,multiplexer:_?.protocol,encryption:r},newStream:R??K,getStreams:()=>null!=_?_.streams:K(),close:(Z=j(function*(){yield s.close(),_?.close()}),function(){return Z.apply(this,arguments)})}),this.dispatchEvent(new tn("connection",{detail:N})),N;var Z}_onStream(e){const{connection:t,stream:r,protocol:i}=e,{handler:s}=this.components.getRegistrar().getHandler(i);s({connection:t,stream:r})}_encryptInbound(e){var t=this;return j(function*(){const r=Array.from(t.connectionEncryption.keys());Gn("handling inbound crypto protocol selection",r);try{const{stream:i,protocol:s}=yield Uv(e,r,{writeBytes:!0}),o=t.connectionEncryption.get(s);if(null==o)throw new Error(`no crypto module found for ${s}`);return Gn("encrypting inbound connection..."),{...yield o.secureInbound(t.components.getPeerId(),i),protocol:s}}catch(i){throw ae(i,Ce.ERR_ENCRYPTION_FAILED)}})()}_encryptOutbound(e,t){var r=this;return j(function*(){const i=Array.from(r.connectionEncryption.keys());Gn("selecting outbound crypto protocol",i);try{const{stream:s,protocol:o}=yield Bv(e,i,{writeBytes:!0}),a=r.connectionEncryption.get(o);if(null==a)throw new Error(`no crypto module found for ${o}`);return Gn("encrypting outbound connection to %p",t),{...yield a.secureOutbound(r.components.getPeerId(),s,t),protocol:o}}catch(s){throw ae(s,Ce.ERR_ENCRYPTION_FAILED)}})()}_multiplexOutbound(e,t){return j(function*(){const r=Array.from(t.keys());Gn("outbound selecting muxer %s",r);try{const{stream:i,protocol:s}=yield Bv(e,r,{writeBytes:!0});return Gn("%s selected as muxer protocol",s),{stream:i,muxerFactory:t.get(s)}}catch(i){throw Gn.error("error multiplexing outbound stream",i),ae(i,Ce.ERR_MUXER_UNAVAILABLE)}})()}_multiplexInbound(e,t){return j(function*(){const r=Array.from(t.keys());Gn("inbound handling muxers %s",r);try{const{stream:i,protocol:s}=yield Uv(e,r,{writeBytes:!0});return{stream:i,muxerFactory:t.get(s)}}catch(i){throw Gn.error("error multiplexing inbound stream",i),ae(i,Ce.ERR_MUXER_UNAVAILABLE)}})()}}var Na;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.protocolVersion&&(r.uint32(42),r.string(t.protocolVersion)),null!=t.agentVersion&&(r.uint32(50),r.string(t.agentVersion)),null!=t.publicKey&&(r.uint32(10),r.bytes(t.publicKey)),null==t.listenAddrs)throw new Error('Protocol error: required field "listenAddrs" was not found in object');for(const s of t.listenAddrs)r.uint32(18),r.bytes(s);if(null!=t.observedAddr&&(r.uint32(34),r.bytes(t.observedAddr)),null==t.protocols)throw new Error('Protocol error: required field "protocols" was not found in object');for(const s of t.protocols)r.uint32(26),r.string(s);null!=t.signedPeerRecord&&(r.uint32(66),r.bytes(t.signedPeerRecord)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 5:i.protocolVersion=t.string();break;case 6:i.agentVersion=t.string();break;case 1:i.publicKey=t.bytes();break;case 2:i.listenAddrs=i.listenAddrs??[],i.listenAddrs.push(t.bytes());break;case 4:i.observedAddr=t.bytes();break;case 3:i.protocols=i.protocols??[],i.protocols.push(t.string());break;case 8:i.signedPeerRecord=t.bytes();break;default:t.skipType(7&o)}}if(i.listenAddrs=i.listenAddrs??[],i.protocols=i.protocols??[],null==i.listenAddrs)throw new Error('Protocol error: value for required field "listenAddrs" was not found in protobuf');if(null==i.protocols)throw new Error('Protocol error: value for required field "protocols" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Na||(Na={}));var Ch;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.publicKey)throw new Error('Protocol error: required field "publicKey" was not found in object');if(r.uint32(10),r.bytes(t.publicKey),null==t.payloadType)throw new Error('Protocol error: required field "payloadType" was not found in object');if(r.uint32(18),r.bytes(t.payloadType),null==t.payload)throw new Error('Protocol error: required field "payload" was not found in object');if(r.uint32(26),r.bytes(t.payload),null==t.signature)throw new Error('Protocol error: required field "signature" was not found in object');r.uint32(42),r.bytes(t.signature),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.publicKey=t.bytes();break;case 2:i.payloadType=t.bytes();break;case 3:i.payload=t.bytes();break;case 5:i.signature=t.bytes();break;default:t.skipType(7&o)}}if(null==i.publicKey)throw new Error('Protocol error: value for required field "publicKey" was not found in protobuf');if(null==i.payloadType)throw new Error('Protocol error: value for required field "payloadType" was not found in protobuf');if(null==i.payload)throw new Error('Protocol error: value for required field "payload" was not found in protobuf');if(null==i.signature)throw new Error('Protocol error: value for required field "signature" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Ch||(Ch={}));class wi{constructor(e){const{peerId:t,payloadType:r,payload:i,signature:s}=e;this.peerId=t,this.payloadType=r,this.payload=i,this.signature=s}marshal(){if(null==this.peerId.publicKey)throw new Error("Missing public key");return null==this.marshaled&&(this.marshaled=Ch.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return kr(this.marshal(),e.marshal())}validate(e){var t=this;return j(function*(){const r=GT(e,t.payloadType,t.payload);if(null==t.peerId.publicKey)throw new Error("Missing public key");return yield Rl(t.peerId.publicKey).verify(r.subarray(),t.signature)})()}}wi.createFromProtobuf=function(){var n=j(function*(e){const t=Ch.decode(e),r=yield kl(t.publicKey);return new wi({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})});return function(e){return n.apply(this,arguments)}}(),wi.seal=function(){var n=j(function*(e,t){if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,i=e.codec,s=e.marshal(),o=GT(r,i,s),u=yield(yield Pl(t.privateKey)).sign(o.subarray());return new wi({peerId:t,payloadType:i,payload:s,signature:u})});return function(e,t){return n.apply(this,arguments)}}(),wi.openAndCertify=function(){var n=j(function*(e,t){const r=yield wi.createFromProtobuf(e);if(!(yield r.validate(t)))throw ae(new Error("envelope signature is not valid for the given domain"),"ERR_SIGNATURE_NOT_VALID");return r});return function(e,t){return n.apply(this,arguments)}}();const GT=(n,e,t)=>{const r=Ot(n),i=Ni.encode(r.byteLength),s=Ni.encode(e.length),o=Ni.encode(t.length);return new qr(i,r,s,e,o,t)};var Ih;!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Yt((s,o,a={})=>{if(!1!==a.lengthDelimited&&o.fork(),null==s.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');o.uint32(10),o.bytes(s.multiaddr),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={multiaddr:new Uint8Array(0)},u=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.multiaddr=s.bytes():s.skipType(7&_)}if(null==a.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return a})),i),r.encode=s=>qt(s,r.codec()),r.decode=s=>Wt(s,r.codec())}(e=n.AddressInfo||(n.AddressInfo={})),n.codec=()=>(null==t&&(t=Yt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null==r.peerId)throw new Error('Protocol error: required field "peerId" was not found in object');if(i.uint32(10),i.bytes(r.peerId),null==r.seq)throw new Error('Protocol error: required field "seq" was not found in object');if(i.uint32(16),i.uint64(r.seq),null==r.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');for(const o of r.addresses)i.uint32(26),n.AddressInfo.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={peerId:new Uint8Array(0),seq:0n,addresses:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.peerId=r.bytes();break;case 2:s.seq=r.uint64();break;case 3:s.addresses.push(n.AddressInfo.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}if(null==s.peerId)throw new Error('Protocol error: value for required field "peerId" was not found in protobuf');if(null==s.seq)throw new Error('Protocol error: value for required field "seq" was not found in protobuf');return s})),t),n.encode=r=>qt(r,n.codec()),n.decode=r=>Wt(r,n.codec())}(Ih||(Ih={}));const J7=Uint8Array.from([3,1]);let iu=(()=>{class n{constructor(t){this.domain=n.DOMAIN,this.codec=n.CODEC;const{peerId:r,multiaddrs:i,seqNumber:s}=t;this.peerId=r,this.multiaddrs=i??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=Ih.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!!(t instanceof n&&this.peerId.equals(t.peerId)&&this.seqNumber===t.seqNumber&&function Z7(n,e){const t=(r,i)=>r.toString().localeCompare(i.toString());return n.length===e.length&&e.sort(t)&&n.sort(t).every((r,i)=>e[i].equals(r))}(this.multiaddrs,t.multiaddrs))}}return n.createFromProtobuf=e=>{const t=Ih.decode(e),r=Jc(t.peerId),i=(t.addresses??[]).map(o=>new yn(o.multiaddr));return new n({peerId:r,multiaddrs:i,seqNumber:t.seq})},n.DOMAIN="libp2p-peer-record",n.CODEC=J7,n})();const WT="js-libp2p/0.0.0",Hn=Gt("libp2p:identify");class Kv{constructor(e,t){this.components=e,this.started=!1,this.init=t,this.identifyProtocolStr=`/${t.protocolPrefix}/id/1.0.0`,this.identifyPushProtocolStr=`/${t.protocolPrefix}/id/push/1.0.0`,this.host={protocolVersion:`${t.protocolPrefix}/0.1.0`,...t.host},this.components.getConnectionManager().addEventListener("peer:connect",r=>{this.identify(r.detail).catch(Hn.error)}),this.components.getPeerStore().addEventListener("change:multiaddrs",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Hn.error(s))}),this.components.getPeerStore().addEventListener("change:protocols",r=>{const{peerId:i}=r.detail;this.components.getPeerId().equals(i)&&this.pushToPeerStore().catch(s=>Hn.error(s))})}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started||(yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"AgentVersion",Ot(e.host.agentVersion)),yield e.components.getPeerStore().metadataBook.setValue(e.components.getPeerId(),"ProtocolVersion",Ot(e.host.protocolVersion)),yield e.components.getRegistrar().handle(e.identifyProtocolStr,t=>{e._handleIdentify(t).catch(r=>{Hn.error(r)})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),yield e.components.getRegistrar().handle(e.identifyPushProtocolStr,t=>{e._handlePush(t).catch(r=>{Hn.error(r)})},{maxInboundStreams:e.init.maxPushIncomingStreams,maxOutboundStreams:e.init.maxPushOutgoingStreams}),e.started=!0)})()}stop(){var e=this;return j(function*(){yield e.components.getRegistrar().unhandle(e.identifyProtocolStr),yield e.components.getRegistrar().unhandle(e.identifyPushProtocolStr),e.started=!1})()}push(e){var t=this;return j(function*(){const r=yield t.components.getPeerStore().addressBook.getRawEnvelope(t.components.getPeerId()),i=t.components.getAddressManager().getAddresses().map(a=>a.bytes),s=yield t.components.getPeerStore().protoBook.get(t.components.getPeerId()),o=e.map(function(){var a=j(function*(u){let _;const R=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,R.signal)}catch{}try{_=yield u.newStream([t.identifyPushProtocolStr],{signal:R.signal});const N=zo(_,R.signal);yield Wn([Na.encode({listenAddrs:i,signedPeerRecord:r,protocols:s})],Os(),N,Qo)}catch(N){Hn.error("could not push identify update to peer",N)}finally{_?.close(),R.clear()}});return function(u){return a.apply(this,arguments)}}());yield Promise.all(o)})()}pushToPeerStore(){var e=this;return j(function*(){if(!e.isStarted())return;const t=[];for(const r of e.components.getConnectionManager().getConnections()){const i=r.remotePeer;!(yield e.components.getPeerStore().get(i)).protocols.includes(e.identifyPushProtocolStr)||t.push(r)}yield e.push(t)})()}_identify(e,t={}){var r=this;return j(function*(){let i,o,s=t.signal;if(null==s){i=new bi.TimeoutController(r.init.timeout),s=i.signal;try{(0,Vr.setMaxListeners)?.(1/0,i.signal)}catch{}}try{o=yield e.newStream([r.identifyProtocolStr],{signal:s});const a=zo(o,s),u=yield Wn([],a,ps({maxDataLength:r.init.maxIdentifyMessageSize??8192}),function(){var _=j(function*(R){return yield Aa(R)});return function(R){return _.apply(this,arguments)}}());if(null==u)throw ae(new Error("No data could be retrieved"),Ce.ERR_CONNECTION_ENDED);try{return Na.decode(u)}catch(_){throw ae(_,Ce.ERR_INVALID_MESSAGE)}}finally{i?.clear(),o?.close()}})()}identify(e,t={}){var r=this;return j(function*(){const i=yield r._identify(e,t),{publicKey:s,listenAddrs:o,protocols:a,observedAddr:u,signedPeerRecord:_,agentVersion:R,protocolVersion:N}=i;if(null==s)throw ae(new Error("public key was missing from identify message"),Ce.ERR_MISSING_PUBLIC_KEY);const B=yield kl(s);if(!e.remotePeer.equals(B))throw ae(new Error("identified peer does not match the expected peer"),Ce.ERR_INVALID_PEER);if(r.components.getPeerId().equals(B))throw ae(new Error("identified peer is our own peer id?"),Ce.ERR_INVALID_PEER);const K=Kv.getCleanMultiaddr(u);if(null!=_){Hn("received signed peer record from %p",B);try{const Z=yield wi.openAndCertify(_,iu.DOMAIN);if(!Z.peerId.equals(B))throw ae(new Error("identified peer does not match the expected peer"),Ce.ERR_INVALID_PEER);if(yield r.components.getPeerStore().addressBook.consumePeerRecord(Z))return yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",Ot(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",Ot(N))),void Hn("identify completed for peer %p and protocols %o",B,a)}catch(Z){Hn("received invalid envelope, discard it and fallback to listenAddrs is available",Z)}}else Hn("no signed peer record received from %p",B);Hn("falling back to legacy addresses from %p",B);try{yield r.components.getPeerStore().addressBook.set(B,o.map(Z=>new yn(Z)))}catch(Z){Hn.error("received invalid addrs",Z)}yield r.components.getPeerStore().protoBook.set(B,a),null!=R&&(yield r.components.getPeerStore().metadataBook.setValue(B,"AgentVersion",Ot(R))),null!=N&&(yield r.components.getPeerStore().metadataBook.setValue(B,"ProtocolVersion",Ot(N))),Hn("identify completed for peer %p and protocols %o",B,a),Hn("received observed address of %s",K?.toString())})()}_handleIdentify(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}try{const o=t.components.getPeerId().publicKey??new Uint8Array(0),a=yield t.components.getPeerStore().get(t.components.getPeerId()),u=t.components.getAddressManager().getAddresses().map(B=>B.decapsulateCode(Sr("p2p").code));let _=a.peerRecordEnvelope;if(u.length>0&&null==_){const B=new iu({peerId:t.components.getPeerId(),multiaddrs:u}),K=yield wi.seal(B,t.components.getPeerId());yield t.components.getPeerStore().addressBook.consumePeerRecord(K),_=K.marshal().subarray()}const R=Na.encode({protocolVersion:t.host.protocolVersion,agentVersion:t.host.agentVersion,publicKey:o,listenAddrs:u.map(B=>B.bytes),signedPeerRecord:_,observedAddr:r.remoteAddr.bytes,protocols:a.protocols}),N=zo(i,s.signal);yield Wn([R],Os(),N,Qo)}catch(o){Hn.error("could not respond to identify request",o)}finally{i.close(),s.clear()}})()}_handlePush(e){var t=this;return j(function*(){const{connection:r,stream:i}=e,s=new bi.TimeoutController(t.init.timeout);try{(0,Vr.setMaxListeners)?.(1/0,s.signal)}catch{}let o;try{const u=zo(i,s.signal),_=yield Wn([],u,ps({maxDataLength:t.init.maxIdentifyMessageSize??8192}),function(){var R=j(function*(N){return yield Aa(N)});return function(N){return R.apply(this,arguments)}}());null!=_&&(o=Na.decode(_))}catch(u){return Hn.error("received invalid message",u)}finally{i.close(),s.clear()}if(null==o)return Hn.error("received invalid message");const a=r.remotePeer;if(t.components.getPeerId().equals(a))Hn("received push from ourselves?");else{if(Hn("received push from %p",a),null!=o.signedPeerRecord){Hn("received signedPeerRecord in push");try{const u=yield wi.openAndCertify(o.signedPeerRecord,iu.DOMAIN);if(yield t.components.getPeerStore().addressBook.consumePeerRecord(u))return Hn("consumed signedPeerRecord sent in push"),void(yield t.components.getPeerStore().protoBook.set(a,o.protocols));Hn("failed to consume signedPeerRecord sent in push")}catch(u){Hn("received invalid envelope, discard it and fallback to listenAddrs is available",u)}}else Hn("did not receive signedPeerRecord in push");try{yield t.components.getPeerStore().addressBook.set(a,o.listenAddrs.map(u=>new yn(u)))}catch(u){Hn.error("received invalid addrs",u)}try{yield t.components.getPeerStore().protoBook.set(a,o.protocols)}catch(u){Hn.error("received invalid protocols",u)}Hn("handled push from %p",a)}})()}static getCleanMultiaddr(e){if(null!=e&&e.length>0)try{return new yn(e)}catch{}}}var Th,Vs;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.identifier)throw new Error('Protocol error: required field "identifier" was not found in object');r.uint32(10),r.string(t.identifier),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.identifier=t.string():t.skipType(7&o)}if(null==i.identifier)throw new Error('Protocol error: value for required field "identifier" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Th||(Th={})),function(n){let e;var i;let t,r;(i=e=n.StatusCode||(n.StatusCode={})).OK="OK",i.NOT_FOUND="NOT_FOUND",i.ERROR="ERROR",function(i){i[i.OK=0]="OK",i[i.NOT_FOUND=1]="NOT_FOUND",i[i.ERROR=2]="ERROR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.StatusCode||(n.StatusCode={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.status)throw new Error('Protocol error: required field "status" was not found in object');if(s.uint32(8),n.StatusCode.codec().encode(i.status,s),null==i.data)throw new Error('Protocol error: required field "data" was not found in object');s.uint32(18),s.bytes(i.data),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.status=n.StatusCode.codec().decode(i);break;case 2:o.data=i.bytes();break;default:i.skipType(7&u)}}if(null==o.status)throw new Error('Protocol error: value for required field "status" was not found in protobuf');if(null==o.data)throw new Error('Protocol error: value for required field "data" was not found in protobuf');return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(Vs||(Vs={}));const YT=Gt("libp2p:fetch");class l9{constructor(e,t){this.started=!1,this.components=e,this.protocol=`/${t.protocolPrefix??"libp2p"}/fetch/0.0.1`,this.lookupFunctions=new Map,this.handleMessage=this.handleMessage.bind(this),this.init=t}start(){var e=this;return j(function*(){yield e.components.getRegistrar().handle(e.protocol,t=>{e.handleMessage(t).catch(r=>{YT.error(r)}).finally(()=>{t.stream.close()})},{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return j(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}fetch(e,t,r={}){var i=this;return j(function*(){YT("dialing %s to %p",i.protocol,e);const s=yield i.components.getConnectionManager().openConnection(e,r);let o,u,a=r.signal;if(null==a){o=new bi.TimeoutController(i.init.timeout),a=o.signal;try{(0,Vr.setMaxListeners)?.(1/0,o.signal)}catch{}}try{u=yield s.newStream([i.protocol],{signal:a});const _=zo(u,a);return(yield Wn([Th.encode({identifier:t})],Os(),_,ps(),function(){var N=j(function*(B){const K=yield Aa(B);if(null==K)throw ae(new Error("No data received"),Ce.ERR_INVALID_MESSAGE);const Z=Vs.decode(K);switch(Z.status){case Vs.StatusCode.OK:return Z.data;case Vs.StatusCode.NOT_FOUND:return null;case Vs.StatusCode.ERROR:{const J=(new TextDecoder).decode(Z.data);throw ae(new Error("Error in fetch protocol response: "+J),Ce.ERR_INVALID_PARAMETERS)}default:throw ae(new Error("Unknown response status"),Ce.ERR_INVALID_MESSAGE)}});return function(B){return N.apply(this,arguments)}}()))??null}finally{o?.clear(),u?.close()}})()}handleMessage(e){var t=this;return j(function*(){const{stream:r}=e,i=t;yield Wn(r,ps(),function(){var s=dn(function*(o){const a=yield lt(Aa(o));if(null==a)throw ae(new Error("No data received"),Ce.ERR_INVALID_MESSAGE);const u=Th.decode(a);let _;const R=i._getLookupFunction(u.identifier);if(null!=R){const N=yield lt(R(u.identifier));_=null!=N?{status:Vs.StatusCode.OK,data:N}:{status:Vs.StatusCode.NOT_FOUND,data:new Uint8Array(0)}}else{const N=(new TextEncoder).encode("No lookup function registered for key: "+u.identifier);_={status:Vs.StatusCode.ERROR,data:N}}yield Vs.encode(_)});return function(o){return s.apply(this,arguments)}}(),Os(),r)})()}_getLookupFunction(e){for(const t of this.lookupFunctions.keys())if(e.startsWith(t))return this.lookupFunctions.get(t)}registerLookupFunction(e,t){if(this.lookupFunctions.has(e))throw ae(new Error("Fetch protocol handler for key prefix '"+e+"' already registered"),Ce.ERR_KEY_ALREADY_EXISTS);this.lookupFunctions.set(e,t)}unregisterLookupFunction(e,t){null!=t&&this.lookupFunctions.get(e)!==t||this.lookupFunctions.delete(e)}}const QT=Gt("libp2p:ping");class p9{constructor(e,t){this.components=e,this.started=!1,this.protocol=`/${t.protocolPrefix}/ping/1.0.0`,this.init=t}start(){var e=this;return j(function*(){yield e.components.getRegistrar().handle(e.protocol,e.handleMessage,{maxInboundStreams:e.init.maxInboundStreams,maxOutboundStreams:e.init.maxOutboundStreams}),e.started=!0})()}stop(){var e=this;return j(function*(){yield e.components.getRegistrar().unhandle(e.protocol),e.started=!1})()}isStarted(){return this.started}handleMessage(e){const{stream:t}=e;Wn(t,t).catch(r=>{QT.error(r)})}ping(e,t={}){var r=this;return j(function*(){QT("dialing %s to %p",r.protocol,e);const i=Date.now(),s=nh(32),o=yield r.components.getConnectionManager().openConnection(e,t);let a,_,u=t.signal;if(null==u){a=new bi.TimeoutController(r.init.timeout),u=a.signal;try{(0,Vr.setMaxListeners)?.(1/0,a.signal)}catch{}}try{_=yield o.newStream([r.protocol],{signal:u});const R=zo(_,u),N=yield Wn([s],R,function(){var K=j(function*(Z){return yield Aa(Z)});return function(Z){return K.apply(this,arguments)}}()),B=Date.now();if(null==N||!kr(s,N.subarray()))throw ae(new Error("Received wrong ping ack"),Ce.ERR_WRONG_PING_ACK);return B-i}finally{a?.clear(),_?.close()}})()}}function $v(){return($v=j(function*(){throw new Error("Not supported in browsers")})).apply(this,arguments)}function m9(n){const{address:e}=n.nodeAddress();return function y9(n){return/^127\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/i.test(n)||/^::1$/.test(n)}(e)}const Gv=Gt("libp2p:nat");function v9(n=1024,e=65535){return Math.floor(Math.random()*(e-n+1)+n)}class E9{constructor(e,t){if(this.components=e,this.started=!1,this.enabled=t.enabled,this.externalAddress=t.externalAddress,this.localAddress=t.localAddress,this.description=t.description??`libp2p@0.0.0 ${this.components.getPeerId().toString()}`,this.ttl=t.ttl??7200,this.keepAlive=t.keepAlive??!0,this.gateway=t.gateway,this.ttl<7200)throw ae(new Error("NatManager ttl should be at least 7200 seconds"),Ce.ERR_INVALID_PARAMETERS)}isStarted(){return this.started}start(){}afterStart(){mh||!this.enabled||this.started||(this.started=!0,this._start().catch(e=>{Gv.error(e)}))}_start(){var e=this;return j(function*(){const t=e.components.getTransportManager().getAddrs();for(const r of t){const{family:i,host:s,port:o,transport:a}=r.toOptions();if(!r.isThinWaistAddress()||"tcp"!==a||m9(r)||4!==i)continue;const u=yield e._getClient(),_=e.externalAddress??(yield u.externalIp());if(yT(_))throw new Error(`${_} is private - please set config.nat.externalIp to an externally routable IP or ensure you are not behind a double NAT`);const R=v9();Gv(`opening uPnP connection from ${_}:${R} to ${s}:${o}`),yield u.map({publicPort:R,localPort:o,localAddress:e.localAddress,protocol:"TCP"===a.toUpperCase()?"TCP":"UDP"}),e.components.getAddressManager().addObservedAddr(yn.fromNodeAddress({family:4,address:_,port:R},a))}})()}_getClient(){var e=this;return j(function*(){return null!=e.client||(e.client=yield function g9(){return $v.apply(this,arguments)}({description:e.description,ttl:e.ttl,keepAlive:e.keepAlive,gateway:e.gateway})),e.client})()}stop(){var e=this;return j(function*(){if(!mh&&null!=e.client)try{yield e.client.close(),e.client=void 0}catch(t){Gv.error(t)}})()}}const b9=Gt("libp2p:peer-record-updater");class w9{constructor(e){this.components=e,this.started=!1,this.update=this.update.bind(this)}isStarted(){return this.started}start(){var e=this;return j(function*(){e.started=!0,e.components.getTransportManager().addEventListener("listener:listening",e.update),e.components.getTransportManager().addEventListener("listener:close",e.update),e.components.getAddressManager().addEventListener("change:addresses",e.update)})()}stop(){var e=this;return j(function*(){e.started=!1,e.components.getTransportManager().removeEventListener("listener:listening",e.update),e.components.getTransportManager().removeEventListener("listener:close",e.update),e.components.getAddressManager().removeEventListener("change:addresses",e.update)})()}update(){var e=this;Promise.resolve().then(j(function*(){const t=new iu({peerId:e.components.getPeerId(),multiaddrs:e.components.getAddressManager().getAddresses().map(i=>i.decapsulateCode(Sr("p2p").code))}),r=yield wi.seal(t,e.components.getPeerId());yield e.components.getPeerStore().addressBook.consumePeerRecord(r)})).catch(t=>{b9.error("Could not update self peer record: %o",t)})}}class _9{constructor(e){this.dht=e}findPeer(e,t={}){var r=this;return j(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.findPeer(e,t));i=!(u=yield a.next()).done;i=!1){const _=u.value;if("FINAL_PEER"===_.name)return _.peer}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw ae(new Error(_n.NOT_FOUND),Ce.ERR_NOT_FOUND)})()}getClosestPeers(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.getClosestPeers(e,t));i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;"PEER_RESPONSE"===_.name&&(yield*Mr(Pt(_.closer),lt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}}const Ln=Gt("libp2p:peer-store:address-book"),Ah="change:multiaddrs";function D9(){return Wv.apply(this,arguments)}function Wv(){return(Wv=j(function*(){return!0})).apply(this,arguments)}class S9{constructor(e,t,r){this.dispatchEvent=e,this.store=t,this.addressFilter=r??D9}consumePeerRecord(e){var t=this;return j(function*(){Ln.trace("consumePeerRecord await write lock");const r=yield t.store.lock.writeLock();let i,s,o;Ln.trace("consumePeerRecord got write lock");try{let a;try{a=iu.createFromProtobuf(e.payload)}catch{return Ln.error("invalid peer record received"),!1}i=a.peerId;const u=a.multiaddrs;if(!i.equals(e.peerId))return Ln("signing key does not match PeerId in the PeerRecord"),!1;if(null==u||0===u.length)return!1;if((yield t.store.has(i))&&(s=yield t.store.load(i),null!=s.peerRecordEnvelope)){const R=yield wi.createFromProtobuf(s.peerRecordEnvelope),N=iu.createFromProtobuf(R.payload);if(N.seqNumber>=a.seqNumber)return Ln("sequence number was lower or equal to existing sequence number - stored: %d received: %d",N.seqNumber,a.seqNumber),!1}const _=yield qv(i,u,t.addressFilter,!0);o=yield t.store.patchOrCreate(i,{addresses:_,peerRecordEnvelope:e.marshal().subarray()}),Ln("stored provided peer record for %p",a.peerId)}finally{Ln.trace("consumePeerRecord release write lock"),r()}return t.dispatchEvent(new tn(Ah,{detail:{peerId:i,multiaddrs:o.addresses.map(({multiaddr:a})=>a),oldMultiaddrs:null==s?[]:s.addresses.map(({multiaddr:a})=>a)}})),!0})()}getRawEnvelope(e){var t=this;return j(function*(){Ln.trace("getRawEnvelope await read lock");const r=yield t.store.lock.readLock();Ln.trace("getRawEnvelope got read lock");try{return(yield t.store.load(e)).peerRecordEnvelope}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ln.trace("getRawEnvelope release read lock"),r()}})()}getPeerRecord(e){var t=this;return j(function*(){const r=yield t.getRawEnvelope(e);if(null!=r)return yield wi.createFromProtobuf(r)})()}get(e){var t=this;return j(function*(){e=Br(e),Ln.trace("get wait for read lock");const r=yield t.store.lock.readLock();Ln.trace("get got read lock");try{return(yield t.store.load(e)).addresses}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ln.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ln.error("multiaddrs must be an array of Multiaddrs"),ae(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Ln.trace("set await write lock");const i=yield r.store.lock.writeLock();Ln.trace("set got write lock");let o,a,s=!1;try{const u=yield qv(e,t,r.addressFilter);if(0===u.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...u.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length&&u.length===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.patchOrCreate(e,{addresses:u}),Ln("set multiaddrs for %p",e)}finally{Ln.trace("set multiaddrs for %p",e),Ln("set release write lock"),i()}r.dispatchEvent(new tn(Ah,{detail:{peerId:e,multiaddrs:a.addresses.map(u=>u.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:u})=>u)}})),s||r.dispatchEvent(new tn("peer",{detail:{id:e,multiaddrs:a.addresses.map(u=>u.multiaddr),protocols:a.protocols}}))})()}add(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ln.error("multiaddrs must be an array of Multiaddrs"),ae(new Error("multiaddrs must be an array of Multiaddrs"),"ERR_INVALID_PARAMETERS");Ln.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o,a;Ln.trace("add got write lock");try{const u=yield qv(e,t,r.addressFilter);if(0===u.length)return;try{if(o=yield r.store.load(e),s=!0,new Set([...u.map(({multiaddr:_})=>_.toString()),...o.addresses.map(({multiaddr:_})=>_.toString())]).size===o.addresses.length)return}catch(_){if("ERR_NOT_FOUND"!==_.code)throw _}a=yield r.store.mergeOrCreate(e,{addresses:u}),Ln("added multiaddrs for %p",e)}finally{Ln.trace("set release write lock"),i()}r.dispatchEvent(new tn(Ah,{detail:{peerId:e,multiaddrs:a.addresses.map(u=>u.multiaddr),oldMultiaddrs:null==o?[]:o.addresses.map(({multiaddr:u})=>u)}})),!0===s&&r.dispatchEvent(new tn("peer",{detail:{id:e,multiaddrs:a.addresses.map(u=>u.multiaddr),protocols:a.protocols}}))})()}delete(e){var t=this;return j(function*(){e=Br(e),Ln.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Ln.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{addresses:[]})}finally{Ln.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new tn(Ah,{detail:{peerId:e,multiaddrs:[],oldMultiaddrs:null==i?[]:i.addresses.map(({multiaddr:s})=>s)}}))})()}}function qv(n,e,t){return Yv.apply(this,arguments)}function Yv(){return Yv=j(function*(n,e,t,r=!1){return yield Wn(e,i=>xv(i,s=>{if(!yn.isMultiaddr(s))throw Ln.error("multiaddr must be an instance of Multiaddr"),ae(new Error("multiaddr must be an instance of Multiaddr"),"ERR_INVALID_PARAMETERS")}),i=>Ds(i,function(){var s=j(function*(o){return yield t(n,o)});return function(o){return s.apply(this,arguments)}}()),i=>uv(i,s=>({multiaddr:new yn(s.toString()),isCertified:r})),function(){var i=j(function*(s){return yield Ul(s)});return function(s){return i.apply(this,arguments)}}())}),Yv.apply(this,arguments)}const Hs=Gt("libp2p:peer-store:key-book"),ZT="change:pubkey";class C9{constructor(e,t){this.dispatchEvent=e,this.store=t}set(e,t){var r=this;return j(function*(){if(e=Br(e),!(t instanceof Uint8Array))throw Hs.error("publicKey must be an instance of Uint8Array to store data"),ae(new Error("publicKey must be an instance of PublicKey"),"ERR_INVALID_PARAMETERS");Hs.trace("set await write lock");const i=yield r.store.lock.writeLock();Hs.trace("set got write lock");let o,s=!1;try{try{if(o=yield r.store.load(e),null!=o.pubKey&&kr(o.pubKey,t))return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}yield r.store.patchOrCreate(e,{pubKey:t}),s=!0}finally{Hs.trace("set release write lock"),i()}s&&r.dispatchEvent(new tn(ZT,{detail:{peerId:e,publicKey:t,oldPublicKey:o?.pubKey}}))})()}get(e){var t=this;return j(function*(){e=Br(e),Hs.trace("get await write lock");const r=yield t.store.lock.readLock();Hs.trace("get got write lock");try{return(yield t.store.load(e)).pubKey}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Hs("get release write lock"),r()}})()}delete(e){var t=this;return j(function*(){e=Br(e),Hs.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Hs.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{pubKey:void 0})}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Hs.trace("delete release write lock"),r()}t.dispatchEvent(new tn(ZT,{detail:{peerId:e,publicKey:void 0,oldPublicKey:i?.pubKey}}))})()}}const Cr=Gt("libp2p:peer-store:metadata-book"),xh="change:metadata";class I9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return j(function*(){e=Br(e),Cr.trace("get await read lock");const r=yield t.store.lock.readLock();Cr.trace("get got read lock");try{return(yield t.store.load(e)).metadata}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Cr.trace("get release read lock"),r()}return new Map})()}getValue(e,t){var r=this;return j(function*(){e=Br(e),Cr.trace("getValue await read lock");const i=yield r.store.lock.readLock();Cr.trace("getValue got read lock");try{return(yield r.store.load(e)).metadata.get(t)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}finally{Cr.trace("getValue release write lock"),i()}})()}set(e,t){var r=this;return j(function*(){if(e=Br(e),!(t instanceof Map))throw Cr.error("valid metadata must be provided to store data"),ae(new Error("valid metadata must be provided"),"ERR_INVALID_PARAMETERS");Cr.trace("set await write lock");const i=yield r.store.lock.writeLock();let s;Cr.trace("set got write lock");try{try{s=yield r.store.load(e)}catch(o){if("ERR_NOT_FOUND"!==o.code)throw o}yield r.store.mergeOrCreate(e,{metadata:t})}finally{Cr.trace("set release write lock"),i()}r.dispatchEvent(new tn(xh,{detail:{peerId:e,metadata:t,oldMetadata:null==s?new Map:s.metadata}}))})()}setValue(e,t,r){var i=this;return j(function*(){if(e=Br(e),"string"!=typeof t||!(r instanceof Uint8Array))throw Cr.error("valid key and value must be provided to store data"),ae(new Error("valid key and value must be provided"),"ERR_INVALID_PARAMETERS");Cr.trace("setValue await write lock");const s=yield i.store.lock.writeLock();let o,a;Cr.trace("setValue got write lock");try{try{o=yield i.store.load(e);const u=o.metadata.get(t);if(null!=u&&kr(r,u))return}catch(u){if("ERR_NOT_FOUND"!==u.code)throw u}a=yield i.store.mergeOrCreate(e,{metadata:new Map([[t,r]])})}finally{Cr.trace("setValue release write lock"),s()}i.dispatchEvent(new tn(xh,{detail:{peerId:e,metadata:a.metadata,oldMetadata:null==o?new Map:o.metadata}}))})()}delete(e){var t=this;return j(function*(){e=Br(e),Cr.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Cr.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}null!=i&&(yield t.store.patch(e,{metadata:new Map}))}finally{Cr.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new tn(xh,{detail:{peerId:e,metadata:new Map,oldMetadata:i.metadata}}))})()}deleteValue(e,t){var r=this;return j(function*(){e=Br(e),Cr.trace("deleteValue await write lock");const i=yield r.store.lock.writeLock();let s,o;Cr.trace("deleteValue got write lock");try{o=yield r.store.load(e),s=o.metadata,s.delete(t),yield r.store.patch(e,{metadata:s})}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}finally{Cr.trace("deleteValue release write lock"),i()}null!=s&&r.dispatchEvent(new tn(xh,{detail:{peerId:e,metadata:s,oldMetadata:null==o?new Map:o.metadata}}))})()}}const Ir=Gt("libp2p:peer-store:proto-book"),Rh="change:protocols";class T9{constructor(e,t){this.dispatchEvent=e,this.store=t}get(e){var t=this;return j(function*(){Ir.trace("get wait for read lock");const r=yield t.store.lock.readLock();Ir.trace("get got read lock");try{return(yield t.store.load(e)).protocols}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}finally{Ir.trace("get release read lock"),r()}return[]})()}set(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("set await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("set got write lock");try{try{if(s=yield r.store.load(e),new Set([...t]).size===s.protocols.length)return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t}),Ir("stored provided protocols for %p",e)}finally{Ir.trace("set release write lock"),i()}r.dispatchEvent(new tn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}add(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("add await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("add got write lock");try{try{if(s=yield r.store.load(e),new Set([...s.protocols,...t]).size===s.protocols.length)return}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.mergeOrCreate(e,{protocols:t}),Ir("added provided protocols for %p",e)}finally{Ir.trace("add release write lock"),i()}r.dispatchEvent(new tn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}remove(e,t){var r=this;return j(function*(){if(e=Br(e),!Array.isArray(t))throw Ir.error("protocols must be provided to store data"),ae(new Error("protocols must be provided"),"ERR_INVALID_PARAMETERS");Ir.trace("remove await write lock");const i=yield r.store.lock.writeLock();let s,o;Ir.trace("remove got write lock");try{try{s=yield r.store.load(e);const a=new Set(s.protocols);for(const u of t)a.delete(u);if(s.protocols.length===a.size)return;t=Array.from(a)}catch(a){if("ERR_NOT_FOUND"!==a.code)throw a}o=yield r.store.patchOrCreate(e,{protocols:t})}finally{Ir.trace("remove release write lock"),i()}r.dispatchEvent(new tn(Rh,{detail:{peerId:e,protocols:o.protocols,oldProtocols:null==s?[]:s.protocols}}))})()}delete(e){var t=this;return j(function*(){e=Br(e),Ir.trace("delete await write lock");const r=yield t.store.lock.writeLock();let i;Ir.trace("delete got write lock");try{try{i=yield t.store.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}yield t.store.patchOrCreate(e,{protocols:[]})}finally{Ir.trace("delete release write lock"),r()}null!=i&&t.dispatchEvent(new tn(Rh,{detail:{peerId:e,protocols:[],oldProtocols:i.protocols}}))})()}}var Ph,Nh,Mh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.addresses)throw new Error('Protocol error: required field "addresses" was not found in object');for(const s of t.addresses)r.uint32(10),Nh.codec().encode(s,r);if(null==t.protocols)throw new Error('Protocol error: required field "protocols" was not found in object');for(const s of t.protocols)r.uint32(18),r.string(s);if(null==t.metadata)throw new Error('Protocol error: required field "metadata" was not found in object');for(const s of t.metadata)r.uint32(26),Mh.codec().encode(s,r);null!=t.pubKey&&(r.uint32(34),r.bytes(t.pubKey)),null!=t.peerRecordEnvelope&&(r.uint32(42),r.bytes(t.peerRecordEnvelope)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={addresses:[],protocols:[],metadata:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.addresses.push(Nh.codec().decode(t,t.uint32()));break;case 2:i.protocols.push(t.string());break;case 3:i.metadata.push(Mh.codec().decode(t,t.uint32()));break;case 4:i.pubKey=t.bytes();break;case 5:i.peerRecordEnvelope=t.bytes();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Ph||(Ph={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.multiaddr)throw new Error('Protocol error: required field "multiaddr" was not found in object');r.uint32(10),r.bytes(t.multiaddr),null!=t.isCertified&&(r.uint32(16),r.bool(t.isCertified)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={multiaddr:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.multiaddr=t.bytes();break;case 2:i.isCertified=t.bool();break;default:t.skipType(7&o)}}if(null==i.multiaddr)throw new Error('Protocol error: value for required field "multiaddr" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Nh||(Nh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.key)throw new Error('Protocol error: required field "key" was not found in object');if(r.uint32(10),r.string(t.key),null==t.value)throw new Error('Protocol error: required field "value" was not found in object');r.uint32(18),r.bytes(t.value),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={key:"",value:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.key=t.string();break;case 2:i.value=t.bytes();break;default:t.skipType(7&o)}}if(null==i.key)throw new Error('Protocol error: value for required field "key" was not found in protobuf');if(null==i.value)throw new Error('Protocol error: value for required field "value" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Mh||(Mh={}));var A9=x(2005);class XT extends Error{constructor(e){super(e),this.name="TimeoutError"}}class x9 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const JT=n=>void 0===globalThis.DOMException?new x9(n):new DOMException(n),eA=n=>{const e=void 0===n.reason?JT("This operation was aborted."):n.reason;return e instanceof Error?e:JT(e)};function tA(n,e,t,r){let i;const s=new Promise((o,a)=>{if("number"!=typeof e||1!==Math.sign(e))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${e}\``);if(e!==Number.POSITIVE_INFINITY){if((r={customTimers:{setTimeout,clearTimeout},...r}).signal){const{signal:u}=r;u.aborted&&a(eA(u)),u.addEventListener("abort",()=>{a(eA(u))})}i=r.customTimers.setTimeout.call(void 0,()=>{if("function"==typeof t){try{o(t())}catch(R){a(R)}return}const _=t instanceof Error?t:new XT("string"==typeof t?t:`Promise timed out after ${e} milliseconds`);"function"==typeof n.cancel&&n.cancel(),a(_)},e),j(function*(){try{o(yield n)}catch(u){a(u)}finally{r.customTimers.clearTimeout.call(void 0,i)}})()}else o(n)});return s.clear=()=>{clearTimeout(i),i=void 0},s}var vo,Ma=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};class P9{constructor(){vo.set(this,[])}enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&Ma(this,vo,"f")[this.size-1].priority>=t.priority)return void Ma(this,vo,"f").push(r);const i=function R9(n,e,t){let r=0,i=n.length;for(;i>0;){const s=Math.trunc(i/2);let o=r+s;t(n[o],e)<=0?(r=++o,i-=s+1):i=s}return r}(Ma(this,vo,"f"),r,(s,o)=>o.priority-s.priority);Ma(this,vo,"f").splice(i,0,r)}dequeue(){return Ma(this,vo,"f").shift()?.run}filter(e){return Ma(this,vo,"f").filter(t=>t.priority===e.priority).map(t=>t.run)}get size(){return Ma(this,vo,"f").length}}vo=new WeakMap;var pr,Ql,Zl,ea,Oh,Xl,kh,Ss,Jl,Oi,Lh,ki,ef,ta,Bh,nA,rA,iA,sA,oA,aA,Fh,Qv,Zv,Uh,Vh,rr=function(n,e,t,r,i){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?n!==e||!i:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?i.call(n,t):i?i.value=t:e.set(n,t),t},gt=function(n,e,t,r){if("a"===t&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?n!==e||!r:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?r:"a"===t?r.call(n):r?r.value:e.get(n)};const N9=new XT;class M9 extends Error{}class cA extends A9{constructor(e){var t,r,i,s;if(super(),pr.add(this),Ql.set(this,void 0),Zl.set(this,void 0),ea.set(this,0),Oh.set(this,void 0),Xl.set(this,void 0),kh.set(this,0),Ss.set(this,void 0),Jl.set(this,void 0),Oi.set(this,void 0),Lh.set(this,void 0),ki.set(this,0),ef.set(this,void 0),ta.set(this,void 0),Bh.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:P9,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${null!==(r=null===(t=e.intervalCap)||void 0===t?void 0:t.toString())&&void 0!==r?r:""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${null!==(s=null===(i=e.interval)||void 0===i?void 0:i.toString())&&void 0!==s?s:""}\` (${typeof e.interval})`);rr(this,Ql,e.carryoverConcurrencyCount,"f"),rr(this,Zl,e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,"f"),rr(this,Oh,e.intervalCap,"f"),rr(this,Xl,e.interval,"f"),rr(this,Oi,new e.queueClass,"f"),rr(this,Lh,e.queueClass,"f"),this.concurrency=e.concurrency,this.timeout=e.timeout,rr(this,Bh,!0===e.throwOnTimeout,"f"),rr(this,ta,!1===e.autoStart,"f")}get concurrency(){return gt(this,ef,"f")}set concurrency(e){if(!("number"==typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);rr(this,ef,e,"f"),gt(this,pr,"m",Uh).call(this)}add(e,t={}){var r=this;return j(function*(){return new Promise((i,s)=>{const o=function(){var a=j(function*(){var u,_,R;rr(r,ki,(_=gt(r,ki,"f"),++_),"f"),rr(r,ea,(R=gt(r,ea,"f"),++R),"f");try{if(null!==(u=t.signal)&&void 0!==u&&u.aborted)return void s(new M9("The task was aborted."));const B=yield void 0===r.timeout&&void 0===t.timeout?e({signal:t.signal}):tA(Promise.resolve(e({signal:t.signal})),void 0===t.timeout?r.timeout:t.timeout,()=>{(void 0===t.throwOnTimeout?gt(r,Bh,"f"):t.throwOnTimeout)&&s(N9)});i(B),r.emit("completed",B)}catch(N){s(N),r.emit("error",N)}gt(r,pr,"m",iA).call(r)});return function(){return a.apply(this,arguments)}}();gt(r,Oi,"f").enqueue(o,t),gt(r,pr,"m",Fh).call(r),r.emit("add")})})()}addAll(e,t){var r=this;return j(function*(){return Promise.all(e.map(function(){var i=j(function*(s){return r.add(s,t)});return function(s){return i.apply(this,arguments)}}()))})()}start(){return gt(this,ta,"f")?(rr(this,ta,!1,"f"),gt(this,pr,"m",Uh).call(this),this):this}pause(){rr(this,ta,!0,"f")}clear(){rr(this,Oi,new(gt(this,Lh,"f")),"f")}onEmpty(){var e=this;return j(function*(){0!==gt(e,Oi,"f").size&&(yield gt(e,pr,"m",Vh).call(e,"empty"))})()}onSizeLessThan(e){var t=this;return j(function*(){gt(t,Oi,"f").sizegt(t,Oi,"f").size{gt(this,pr,"m",oA).call(this)},t),"f"),!0;rr(this,ea,gt(this,Ql,"f")?gt(this,ki,"f"):0,"f")}return!1},Fh=function(){if(0===gt(this,Oi,"f").size)return gt(this,Ss,"f")&&clearInterval(gt(this,Ss,"f")),rr(this,Ss,void 0,"f"),gt(this,pr,"m",sA).call(this),!1;if(!gt(this,ta,"f")){const e=!gt(this,pr,"a",aA);if(gt(this,pr,"a",nA)&>(this,pr,"a",rA)){const t=gt(this,Oi,"f").dequeue();return!!t&&(this.emit("active"),t(),e&>(this,pr,"m",Qv).call(this),!0)}}return!1},Qv=function(){gt(this,Zl,"f")||void 0!==gt(this,Ss,"f")||(rr(this,Ss,setInterval(()=>{gt(this,pr,"m",Zv).call(this)},gt(this,Xl,"f")),"f"),rr(this,kh,Date.now()+gt(this,Xl,"f"),"f"))},Zv=function(){0===gt(this,ea,"f")&&0===gt(this,ki,"f")&>(this,Ss,"f")&&(clearInterval(gt(this,Ss,"f")),rr(this,Ss,void 0,"f")),rr(this,ea,gt(this,Ql,"f")?gt(this,ki,"f"):0,"f"),gt(this,pr,"m",Uh).call(this)},Uh=function(){for(;gt(this,pr,"m",Fh).call(this););},Vh=function(){var n=j(function*(t,r){return new Promise(i=>{const s=()=>{r&&!r()||(this.off(t,s),i())};this.on(t,s)})});return function e(t,r){return n.apply(this,arguments)}}();class O9 extends Error{constructor(e){super(e),this.name="TimeoutError"}}class k9 extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const uA=n=>void 0===globalThis.DOMException?new k9(n):new DOMException(n),lA=n=>{const e=void 0===n.reason?uA("This operation was aborted."):n.reason;return e instanceof Error?e:uA(e)};function L9(n,e){const{milliseconds:t,fallback:r,message:i,customTimers:s={setTimeout,clearTimeout}}=e;let o;const a=new Promise((u,_)=>{if("number"!=typeof t||1!==Math.sign(t))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t!==Number.POSITIVE_INFINITY){if(e.signal){const{signal:R}=e;R.aborted&&_(lA(R)),R.addEventListener("abort",()=>{_(lA(R))})}o=s.setTimeout.call(void 0,()=>{if(r){try{u(r())}catch(B){_(B)}return}const N=i instanceof Error?i:new O9("string"==typeof i?i:`Promise timed out after ${t} milliseconds`);"function"==typeof n.cancel&&n.cancel(),_(N)},t),j(function*(){try{u(yield n)}catch(R){_(R)}finally{s.clearTimeout.call(void 0,o)}})()}else u(n)});return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}const fA="lock:worker:request-read",dA="lock:worker:release-read",hA="lock:master:grant-read",pA="lock:worker:request-write",gA="lock:worker:release-write",yA="lock:master:grant-write",na={},su=n=>{n.addEventListener("message",e=>{su.dispatchEvent("message",n,e)}),null!=n.port&&n.port.addEventListener("message",e=>{su.dispatchEvent("message",n,e)})};su.addEventListener=(n,e)=>{null==na[n]&&(na[n]=[]),na[n].push(e)},su.removeEventListener=(n,e)=>{null!=na[n]&&(na[n]=na[n].filter(t=>t===e))},su.dispatchEvent=function(n,e,t){null!=na[n]&&na[n].forEach(r=>r(e,t))};const mA=su,vA=(n,e,t,r,i)=>(s,o)=>{if(o.data.type!==t)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};var u;n.dispatchEvent(new MessageEvent(e,{data:{name:a.name,handler:(u=j(function*(){return s.postMessage({type:i,name:a.name,identifier:a.identifier}),yield new Promise(_=>{const R=N=>{null!=N&&null!=N.data&&N.data.type===r&&N.data.identifier===a.identifier&&(s.removeEventListener("message",R),_())};s.addEventListener("message",R)})}),function(){return u.apply(this,arguments)})}}))},EA=(n,e,t,r)=>j(function*(){const i=((n=21)=>crypto.getRandomValues(new Uint8Array(n)).reduce((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_"),""))();return globalThis.postMessage({type:e,identifier:i,name:n}),yield new Promise(s=>{const o=a=>{null!=a&&null!=a.data&&a.data.type===t&&a.data.identifier===i&&(globalThis.removeEventListener("message",o),s(()=>{globalThis.postMessage({type:r,identifier:i,name:n})}))};globalThis.addEventListener("message",o)})}),V9={singleProcess:!1},Oa={};let ra;function Xv(n,e){return Jv.apply(this,arguments)}function Jv(){return Jv=j(function*(n,e){let t;const r=new Promise(i=>{t=i});return n.add(j(function*(){return yield L9(j(function*(){return yield new Promise(i=>{t(()=>{i()})})})(),{milliseconds:e.timeout})})),yield r}),Jv.apply(this,arguments)}const $9={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};const bA=Gt("libp2p:peer-store:store"),wA="/peers/";class G9{constructor(){this.components=new ho,this.lock=function j9(n){const e=Object.assign({},$9,n);return null==ra&&(ra=(n=>{if(n=Object.assign({},V9,n),Boolean(globalThis.document)||n.singleProcess){const t=new EventTarget;return mA.addEventListener("message",vA(t,"requestReadLock",fA,dA,hA)),mA.addEventListener("message",vA(t,"requestWriteLock",pA,gA,yA)),t}return{isWorker:!0,readLock:t=>EA(t,fA,hA,dA),writeLock:t=>EA(t,pA,yA,gA)}})(e),!0!==ra.isWorker&&(ra.addEventListener("requestReadLock",t=>{null!=Oa[t.data.name]&&Oa[t.data.name].readLock().then(function(){var r=j(function*(i){return yield t.data.handler().finally(()=>i())});return function(i){return r.apply(this,arguments)}}())}),ra.addEventListener("requestWriteLock",function(){var t=j(function*(r){null!=Oa[r.data.name]&&Oa[r.data.name].writeLock().then(function(){var i=j(function*(s){return yield r.data.handler().finally(()=>s())});return function(s){return i.apply(this,arguments)}}())});return function(r){return t.apply(this,arguments)}}()))),null==Oa[e.name]&&(Oa[e.name]=((n,e)=>{if(!0===ra.isWorker)return{readLock:ra.readLock(n,e),writeLock:ra.writeLock(n,e)};const t=new cA({concurrency:1});let r;return{readLock:()=>j(function*(){if(null!=r)return yield Xv(r,e);r=new cA({concurrency:e.concurrency,autoStart:!1});const i=r,s=Xv(r,e);return t.add(j(function*(){return i.start(),yield i.onIdle().then(()=>{r===i&&(r=null)})})),yield s})(),writeLock:()=>j(function*(){return r=null,yield Xv(t,e)})()}})(e.name,e)),Oa[e.name]}({name:"peer-store",singleProcess:!0})}init(e){this.components=e}_peerIdToDatastoreKey(e){if(null==e.type)throw bA.error("peerId must be an instance of peer-id to store data"),ae(new Error("peerId must be an instance of peer-id"),"ERR_INVALID_PARAMETERS");const t=e.toCID().toString();return new Ur(`${wA}${t}`)}has(e){var t=this;return j(function*(){return yield t.components.getDatastore().has(t._peerIdToDatastoreKey(e))})()}delete(e){var t=this;return j(function*(){yield t.components.getDatastore().delete(t._peerIdToDatastoreKey(e))})()}load(e){var t=this;return j(function*(){const r=yield t.components.getDatastore().get(t._peerIdToDatastoreKey(e)),i=Ph.decode(r),s=new Map;for(const o of i.metadata)s.set(o.key,o.value);return{...i,id:e,addresses:i.addresses.map(({multiaddr:o,isCertified:a})=>({multiaddr:new yn(o),isCertified:a??!1})),metadata:s,pubKey:i.pubKey??void 0,peerRecordEnvelope:i.peerRecordEnvelope??void 0}})()}save(e){var t=this;return j(function*(){if(null!=e.pubKey&&null!=e.id.publicKey&&!kr(e.pubKey,e.id.publicKey))throw bA.error("peer publicKey bytes do not match peer id publicKey bytes"),ae(new Error("publicKey bytes do not match peer id publicKey bytes"),"ERR_INVALID_PARAMETERS");const r=new Set,i=e.addresses.filter(a=>!r.has(a.multiaddr.toString())&&(r.add(a.multiaddr.toString()),!0)).sort((a,u)=>a.multiaddr.toString().localeCompare(u.multiaddr.toString())).map(({multiaddr:a,isCertified:u})=>({multiaddr:a.bytes,isCertified:u})),s=[];[...e.metadata.keys()].sort().forEach(a=>{const u=e.metadata.get(a);null!=u&&s.push({key:a,value:u})});const o=Ph.encode({addresses:i,protocols:e.protocols.sort(),pubKey:e.pubKey,metadata:s,peerRecordEnvelope:e.peerRecordEnvelope});return yield t.components.getDatastore().put(t._peerIdToDatastoreKey(e.id),o.subarray()),yield t.load(e.id)})()}patch(e,t){var r=this;return j(function*(){const i=yield r.load(e);return yield r._patch(e,t,i)})()}patchOrCreate(e,t){var r=this;return j(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._patch(e,t,i)})()}_patch(e,t,r){var i=this;return j(function*(){return yield i.save({...r,...t,id:e})})()}merge(e,t){var r=this;return j(function*(){const i=yield r.load(e);return yield r._merge(e,t,i)})()}mergeOrCreate(e,t){var r=this;return j(function*(){let i;try{i=yield r.load(e)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s;i={id:e,addresses:[],protocols:[],metadata:new Map}}return yield r._merge(e,t,i)})()}_merge(e,t,r){var i=this;return j(function*(){const s=new Map;return r.addresses.forEach(o=>{s.set(o.multiaddr.toString(),o.isCertified)}),(t.addresses??[]).forEach(o=>{const a=o.multiaddr.toString(),_=Boolean(s.get(a))||o.isCertified;s.set(a,_)}),yield i.save({id:e,addresses:Array.from(s.entries()).map(([o,a])=>({multiaddr:new yn(o),isCertified:a})),protocols:Array.from(new Set([...r.protocols??[],...t.protocols??[]])),metadata:new Map([...r.metadata?.entries()??[],...t.metadata?.entries()??[]]),pubKey:t.pubKey??r?.pubKey,peerRecordEnvelope:t.peerRecordEnvelope??r?.peerRecordEnvelope})})()}all(){var e=this;return dn(function*(){var i,t=!1,r=!1;try{for(var o,s=Pt(e.components.getDatastore().queryKeys({prefix:wA}));t=!(o=yield lt(s.next())).done;t=!1){const u=o.value.toString().split("/")[2],_=co.decode(u);yield e.load(Jc(_))}}catch(a){r=!0,i=a}finally{try{t&&null!=s.return&&(yield lt(s.return()))}finally{if(r)throw i}}})()}}var ia,Hh;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.tags)throw new Error('Protocol error: required field "tags" was not found in object');for(const s of t.tags)r.uint32(10),Hh.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={tags:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.tags.push(Hh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ia||(ia={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.name)throw new Error('Protocol error: required field "name" was not found in object');r.uint32(10),r.string(t.name),null!=t.value&&(r.uint32(16),r.uint32(t.value)),null!=t.expiry&&(r.uint32(24),r.uint64(t.expiry)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={name:""},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.name=t.string();break;case 2:i.value=t.uint32();break;case 3:i.expiry=t.uint64();break;default:t.skipType(7&o)}}if(null==i.name)throw new Error('Protocol error: value for required field "name" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Hh||(Hh={}));const Zi=Gt("libp2p:peer-store");class z9 extends Ei{constructor(e={}){super(),this.components=new ho,this.store=new G9,this.addressBook=new S9(this.dispatchEvent.bind(this),this.store,e.addressFilter),this.keyBook=new C9(this.dispatchEvent.bind(this),this.store),this.metadataBook=new I9(this.dispatchEvent.bind(this),this.store),this.protoBook=new T9(this.dispatchEvent.bind(this),this.store)}init(e){this.components=e,this.store.init(e)}forEach(e){var t=this;return j(function*(){Zi.trace("getPeers await read lock");const r=yield t.store.lock.readLock();Zi.trace("getPeers got read lock");try{var o,i=!1,s=!1;try{for(var u,a=Pt(t.store.all());i=!(u=yield a.next()).done;i=!1){const _=u.value;_.id.equals(t.components.getPeerId())||e(_)}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}}finally{Zi.trace("getPeers release read lock"),r()}})()}all(){var e=this;return j(function*(){const t=[];return yield e.forEach(r=>{t.push(r)}),t})()}delete(e){var t=this;return j(function*(){Zi.trace("delete await write lock");const r=yield t.store.lock.writeLock();Zi.trace("delete got write lock");try{yield t.store.delete(e)}finally{Zi.trace("delete release write lock"),r()}})()}get(e){var t=this;return j(function*(){Zi.trace("get await read lock");const r=yield t.store.lock.readLock();Zi.trace("get got read lock");try{return yield t.store.load(e)}finally{Zi.trace("get release read lock"),r()}})()}has(e){var t=this;return j(function*(){Zi.trace("has await read lock");const r=yield t.store.lock.readLock();Zi.trace("has got read lock");try{return yield t.store.has(e)}finally{Zi.trace("has release read lock"),r()}})()}tagPeer(e,t,r={}){var i=this;return j(function*(){const s=r.value??0,o=Math.round(s),a=r.ttl??void 0;if(o!==s||o<0||o>100)throw ae(new Error("Tag value must be between 0-100"),"ERR_TAG_VALUE_OUT_OF_BOUNDS");const u=yield i.metadataBook.getValue(e,"tags");let _=[];null!=u&&(_=ia.decode(u).tags);for(const R of _)if(R.name===t)throw ae(new Error("Peer already tagged"),"ERR_DUPLICATE_TAG");_.push({name:t,value:o,expiry:null==a?void 0:BigInt(Date.now()+a)}),yield i.metadataBook.setValue(e,"tags",ia.encode({tags:_}).subarray())})()}unTagPeer(e,t){var r=this;return j(function*(){const i=yield r.metadataBook.getValue(e,"tags");let s=[];null!=i&&(s=ia.decode(i).tags),s=s.filter(o=>o.name!==t),yield r.metadataBook.setValue(e,"tags",ia.encode({tags:s}).subarray())})()}getTags(e){var t=this;return j(function*(){const r=yield t.metadataBook.getValue(e,"tags");let i=[];null!=r&&(i=ia.decode(r).tags);const s=BigInt(Date.now()),o=i.filter(a=>null==a.expiry||a.expiry>s);return o.length!==i.length&&(yield t.metadataBook.setValue(e,"tags",ia.encode({tags:o}).subarray())),o.map(a=>({name:a.name,value:a.value??0}))})()}}class W9{constructor(e){this.dht=e}provide(e){var t=this;return j(function*(){yield Qo(t.dht.provide(e))})()}findProviders(e,t={}){var r=this;return dn(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.findProviders(e,t));i=!(u=yield lt(a.next())).done;i=!1){const _=u.value;"PROVIDER"===_.name&&(yield*Mr(Pt(_.providers),lt))}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield lt(a.return()))}finally{if(s)throw o}}})()}put(e,t,r){var i=this;return j(function*(){yield Qo(i.dht.put(e,t,r))})()}get(e,t){var r=this;return j(function*(){var o,i=!1,s=!1;try{for(var u,a=Pt(r.dht.get(e,t));i=!(u=yield a.next()).done;i=!1){const _=u.value;if("VALUE"===_.name)return _.value}}catch(_){s=!0,o=_}finally{try{i&&null!=a.return&&(yield a.return())}finally{if(s)throw o}}throw ae(new Error("Not found"),"ERR_NOT_FOUND")})()}}const _A=Gt("libp2p:dialer:auto-dialer");class q9{constructor(e,t){this.components=e,this.enabled=t.enabled,this.minConnections=t.minConnections,this.dialTimeout=t.dialTimeout}handle(e){const{detail:t}=e;if(this.enabled&&0===this.components.getConnectionManager().getConnections(t.id).length&&(this.minConnections??0)>this.components.getConnectionManager().getConnections().length){_A("auto-dialing discovered peer %p with timeout %d",t.id,this.dialTimeout);const o=new bi.TimeoutController(this.dialTimeout);try{(0,Vr.setMaxListeners)?.(1/0,o.signal)}catch{}this.components.getConnectionManager().openConnection(t.id,{signal:o.signal}).catch(a=>{_A.error("could not connect to discovered peer %p with %o",t.id,a)}).finally(()=>{o.clear()})}}}var DA=x(4033);const Y9=globalThis.fetch,Q9=globalThis.Headers;function eE(n,e,t){return`${n}?name=${e}&type=${t}`}function Z9(n,e){return tE.apply(this,arguments)}function tE(){return tE=j(function*(n,e){return yield(yield Y9(n,{headers:new Q9({accept:"application/dns-json"}),signal:e})).json()}),tE.apply(this,arguments)}function ou(n,e){return`${e}_${n}`}globalThis,globalThis;const nE=Object.assign(dr("dns-over-http-resolver"),{error:dr("dns-over-http-resolver:error")}),J9=class X9{constructor(e={}){this._cache=new DA({max:e?.maxCache??100}),this._TXTcache=new DA({max:e?.maxCache??100}),this._servers=["https://cloudflare-dns.com/dns-query","https://dns.google/resolve"],this._request=e.request??Z9,this._abortControllers=[]}cancel(){this._abortControllers.forEach(e=>e.abort())}getServers(){return this._servers}_getShuffledServers(){const e=[...this._servers];for(let t=e.length-1;t>0;t--){const r=Math.floor(Math.random()*t),i=e[t];e[t]=e[r],e[r]=i}return e}setServers(e){this._servers=e}resolve(e,t="A"){var r=this;return j(function*(){switch(t){case"A":return yield r.resolve4(e);case"AAAA":return yield r.resolve6(e);case"TXT":return yield r.resolveTxt(e);default:throw new Error(`${t} is not supported`)}})()}resolve4(e){var t=this;return j(function*(){const i=t._cache.get(ou(e,"A"));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(eE(o,e,"A"),a.signal),_=u.Answer.map(N=>N.data),R=Math.min(...u.Answer.map(N=>N.TTL));return t._cache.set(ou(e,"A"),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),nE.error(`${o} could not resolve ${e} record A`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryA ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record A`)})()}resolve6(e){var t=this;return j(function*(){const r="AAAA",i=t._cache.get(ou(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(eE(o,e,r),a.signal),_=u.Answer.map(N=>N.data),R=Math.min(...u.Answer.map(N=>N.TTL));return t._cache.set(ou(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),nE.error(`${o} could not resolve ${e} record AAAA`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryAaaa ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record AAAA`)})()}resolveTxt(e){var t=this;return j(function*(){const r="TXT",i=t._TXTcache.get(ou(e,r));if(null!=i)return i;let s=!1;for(const o of t._getShuffledServers()){const a=new AbortController;t._abortControllers.push(a);try{const u=yield t._request(eE(o,e,r),a.signal),_=u.Answer.map(N=>[N.data.replace(/['"]+/g,"")]),R=Math.min(...u.Answer.map(N=>N.TTL));return t._TXTcache.set(ou(e,r),_,{ttl:R}),_}catch{a.signal.aborted&&(s=!0),nE.error(`${o} could not resolve ${e} record TXT`)}finally{t._abortControllers=t._abortControllers.filter(u=>u!==a)}}throw s?Object.assign(new Error("queryTxt ECANCELLED"),{code:"ECANCELLED"}):new Error(`Could not resolve ${e} record TXT`)})()}clearCache(){this._cache.clear(),this._TXTcache.clear()}},{code:eH}=Sr("dnsaddr");function rE(){return rE=j(function*(n,e={}){const t=new J9;null!=e.signal&&e.signal.addEventListener("abort",()=>{t.cancel()});const r=n.getPeerId(),[,i]=n.stringTuples().find(([a])=>a===eH)??[];if(null==i)throw new Error("No hostname found in multiaddr");let o=(yield t.resolveTxt(`_dnsaddr.${i}`)).flat().map(a=>a.split("=")[1]);return null!=r&&(o=o.filter(a=>a.includes(r))),o}),rE.apply(this,arguments)}const nH={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:n=>n},connectionManager:{maxConnections:300,minConnections:50,autoDial:!0,autoDialInterval:1e4,maxParallelDials:100,maxDialsPerPeer:4,dialTimeout:3e4,inboundUpgradeTimeout:3e4,resolvers:{dnsaddr:function tH(n){return rE.apply(this,arguments)}},addressSorter:pv},connectionGater:{},transportManager:{faultTolerance:Pa.FATAL_ALL},metrics:{enabled:!1,computeThrottleMaxQueueSize:1e3,computeThrottleTimeout:2e3,movingAverageIntervals:[6e4,3e5,9e5],maxOldPeersRetention:50},peerRouting:{refreshManager:{enabled:!0,interval:6e5,bootDelay:1e4}},nat:{enabled:!0,ttl:7200,keepAlive:!0},relay:{enabled:!0,advertise:{bootDelay:9e5,enabled:!1,ttl:18e5},hop:{enabled:!1,active:!1,timeout:3e4},autoRelay:{enabled:!1,maxListeners:2}},identify:{protocolPrefix:"ipfs",host:{agentVersion:WT},timeout:6e4,maxInboundStreams:1,maxOutboundStreams:1,maxPushIncomingStreams:1,maxPushOutgoingStreams:1},ping:{protocolPrefix:"ipfs",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4},fetch:{protocolPrefix:"libp2p",maxInboundStreams:1,maxOutboundStreams:1,timeout:1e4}};function rH(n){const e=Hl(nH,n);if(null==e.transports||e.transports.length<1)throw ae(new Error(_n.ERR_TRANSPORTS_REQUIRED),Ce.ERR_TRANSPORTS_REQUIRED);if(null==e.connectionEncryption||0===e.connectionEncryption.length)throw ae(new Error(_n.CONN_ENCRYPTION_REQUIRED),Ce.CONN_ENCRYPTION_REQUIRED);if(null===e.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw ae(new Error(_n.ERR_PROTECTOR_REQUIRED),Ce.ERR_PROTECTOR_REQUIRED);return e.identify.host.agentVersion===WT&&(cV||oV?e.identify.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(mh||W2||aV||uV)&&(e.identify.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`)),e}var SA;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.id)throw new Error('Protocol error: required field "id" was not found in object');r.uint32(10),r.bytes(t.id),null!=t.pubKey&&(r.uint32(18),r.bytes(t.pubKey)),null!=t.privKey&&(r.uint32(26),r.bytes(t.privKey)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={id:new Uint8Array(0)},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.id=t.bytes();break;case 2:i.pubKey=t.bytes();break;case 3:i.privKey=t.bytes();break;default:t.skipType(7&o)}}if(null==i.id)throw new Error('Protocol error: value for required field "id" was not found in protobuf');return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(SA||(SA={}));const iH=function(){var n=j(function*(){const e=yield s2("Ed25519"),t=yield function CA(n){return sE.apply(this,arguments)}(e);if("Ed25519"===t.type)return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)});return function(){return n.apply(this,arguments)}}();function sE(){return sE=j(function*(n){return yield kl(o2(n.public),P5(n))}),sE.apply(this,arguments)}const uE=Symbol.for("@libp2p/peer-discovery");class oH extends Ei{get[uE](){return!0}get[Symbol.toStringTag](){return"@libp2p/dummy-dht"}get wan(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}get lan(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}get(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}findProviders(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}findPeer(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}getClosestPeers(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}provide(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}put(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)}getMode(){return j(function*(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)})()}setMode(){return j(function*(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)})()}refreshRoutingTable(){return j(function*(){throw ae(new Error(_n.DHT_DISABLED),Ce.DHT_DISABLED)})()}}class aH extends Ei{isStarted(){return!1}start(){}stop(){}get globalSignaturePolicy(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}get multicodecs(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getPeers(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getTopics(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}subscribe(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}unsubscribe(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}getSubscribers(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)}publish(){return j(function*(){throw ae(new Error(_n.PUBSUB_DISABLED),Ce.ERR_PUBSUB_DISABLED)})()}}const Eo=Gt("libp2p");class cH extends Ei{constructor(e){var o;super(),this.initializables=[],this.started=!1,this.peerId=e.peerId,this.components=new ho({peerId:e.peerId,datastore:e.datastore??new OV,connectionGater:{denyDialPeer:(o=j(function*(){return yield Promise.resolve(!1)}),function(){return o.apply(this,arguments)}),denyDialMultiaddr:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundEncryptedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundEncryptedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyInboundUpgradedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),denyOutboundUpgradedConnection:function(){var o=j(function*(){return yield Promise.resolve(!1)});return function(){return o.apply(this,arguments)}}(),filterMultiaddrForPeer:function(){var o=j(function*(){return yield Promise.resolve(!0)});return function(){return o.apply(this,arguments)}}(),...e.connectionGater}}),this.components.setPeerStore(new z9({addressFilter:this.components.getConnectionGater().filterMultiaddrForPeer,...e.peerStore})),this.services=[this.components],e.metrics.enabled&&(this.metrics=this.components.setMetrics(new N7(e.metrics))),this.peerStore=this.components.getPeerStore(),this.peerStore.addEventListener("peer",o=>{const{detail:a}=o;this.dispatchEvent(new tn("peer:discovery",{detail:a}))}),null!=e.connectionProtector&&this.components.setConnectionProtector(e.connectionProtector),this.components.setUpgrader(new q7(this.components,{connectionEncryption:(e.connectionEncryption??[]).map(o=>this.configureComponent(o)),muxers:(e.streamMuxers??[]).map(o=>this.configureComponent(o)),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout})),this.connectionManager=this.components.setConnectionManager(new r7(e.connectionManager)),this.registrar=this.components.setRegistrar(new G7(this.components)),this.components.setTransportManager(new F7(this.components,e.transportManager)),this.components.setAddressManager(new UV(this.components,e.addresses)),this.configureComponent(new w9(this.components)),this.configureComponent(new s7(this.components,{enabled:e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,autoDialInterval:e.connectionManager.autoDialInterval}));const t=LT.generateOptions();this.keychain=this.configureComponent(new LT(this.components,{...t,...e.keychain})),this.services.push(new E9(this.components,e.nat)),e.transports.forEach(o=>{this.components.getTransportManager().add(this.configureComponent(o))}),null!=e.streamMuxers&&e.streamMuxers.length>0&&(this.identifyService=new Kv(this.components,{...e.identify}),this.configureComponent(this.identifyService)),this.dht=null!=e.dht?this.components.setDHT(e.dht):new oH,this.pubsub=null!=e.pubsub?this.components.setPubSub(e.pubsub):new aH;const r=(e.peerRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&(r.push(this.configureComponent(new _9(this.dht))),this.dht.addEventListener("peer",o=>{this.onDiscoveryPeer(o)})),this.peerRouting=this.components.setPeerRouting(this.configureComponent(new kV(this.components,{...e.peerRouting,routers:r})));const i=(e.contentRouters??[]).map(o=>this.configureComponent(o));null!=e.dht&&i.push(this.configureComponent(new W9(this.dht))),this.contentRouting=this.components.setContentRouting(this.configureComponent(new LV(this.components,{routers:i}))),e.relay.enabled&&(this.components.getTransportManager().add(this.configureComponent(new p7(e.relay))),this.configureComponent(new b7(this.components,{addressSorter:e.connectionManager.addressSorter,...e.relay}))),this.fetchService=this.configureComponent(new l9(this.components,{...e.fetch})),this.pingService=this.configureComponent(new p9(this.components,{...e.ping}));const s=this.configureComponent(new q9(this.components,{enabled:!1!==e.connectionManager.autoDial,minConnections:e.connectionManager.minConnections,dialTimeout:e.connectionManager.dialTimeout??3e4}));this.addEventListener("peer:discovery",o=>{!this.isStarted()||s.handle(o)});for(const o of e.peerDiscovery??[])this.configureComponent(o),o.addEventListener("peer",a=>{this.onDiscoveryPeer(a)})}configureComponent(e){return fo(e)&&this.services.push(e),Fr(e)&&this.initializables.push(e),e}start(){var e=this;return j(function*(){if(!e.started){e.started=!0,Eo("libp2p is starting");try{e.initializables.forEach(t=>{t.init(e.components)}),yield Promise.all(e.services.map(function(){var t=j(function*(r){null!=r.beforeStart&&(yield r.beforeStart())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.start())),yield Promise.all(e.services.map(function(){var t=j(function*(r){null!=r.afterStart&&(yield r.afterStart())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has started")}catch(t){throw Eo.error("An error occurred starting libp2p",t),yield e.stop(),t}}})()}stop(){var e=this;return j(function*(){!e.started||(Eo("libp2p is stopping"),e.started=!1,yield Promise.all(e.services.map(function(){var t=j(function*(r){null!=r.beforeStop&&(yield r.beforeStop())});return function(r){return t.apply(this,arguments)}}())),yield Promise.all(e.services.map(t=>t.stop())),yield Promise.all(e.services.map(function(){var t=j(function*(r){null!=r.afterStop&&(yield r.afterStop())});return function(r){return t.apply(this,arguments)}}())),Eo("libp2p has stopped"))})()}loadKeychain(){var e=this;return j(function*(){if(null!=e.keychain)try{yield e.keychain.findKeyByName("self")}catch{yield e.keychain.importPeer("self",e.peerId)}})()}isStarted(){return this.started}getConnections(e){return this.components.getConnectionManager().getConnections(e)}getPeers(){const e=new JV;for(const t of this.components.getConnectionManager().getConnections())e.add(t.remotePeer);return Array.from(e)}dial(e,t={}){var r=this;return j(function*(){const{id:i,multiaddrs:s}=Vl(e);return yield r.components.getPeerStore().addressBook.add(i,s),yield r.components.getConnectionManager().openConnection(i,t)})()}dialProtocol(e,t,r={}){var i=this;return j(function*(){if(null==t)throw ae(new Error("no protocols were provided to open a stream"),Ce.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw ae(new Error("no protocols were provided to open a stream"),Ce.ERR_INVALID_PROTOCOLS_FOR_STREAM);return yield(yield i.dial(e,r)).newStream(t,r)})()}getMultiaddrs(){return this.components.getAddressManager().getAddresses()}hangUp(e){var t=this;return j(function*(){const{id:r}=Vl(e);yield t.components.getConnectionManager().closeConnections(r)})()}getPublicKey(e,t={}){var r=this;return j(function*(){if(Eo("getPublicKey %p",e),null!=e.publicKey)return e.publicKey;const i=yield r.peerStore.get(e);if(null!=i.pubKey)return i.pubKey;if(null==r.dht)throw ae(new Error("Public key was not in the peer store and the DHT is not enabled"),Ce.ERR_NO_ROUTERS_AVAILABLE);const s=wr([Ot("/pk/"),e.multihash.digest]);var u,o=!1,a=!1;try{for(var R,_=Pt(r.dht.get(s,t));o=!(R=yield _.next()).done;o=!1){const N=R.value;if("VALUE"===N.name){const B=Rl(N.value);return yield r.peerStore.keyBook.set(e,N.value),B.bytes}}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw u}}throw ae(new Error(`Node not responding with its public key: ${e.toString()}`),Ce.ERR_INVALID_RECORD)})()}fetch(e,t,r={}){var i=this;return j(function*(){const{id:s,multiaddrs:o}=Vl(e);return null!=o&&(yield i.components.getPeerStore().addressBook.add(s,o)),yield i.fetchService.fetch(s,t,r)})()}ping(e,t={}){var r=this;return j(function*(){const{id:i,multiaddrs:s}=Vl(e);return s.length>0&&(yield r.components.getPeerStore().addressBook.add(i,s)),yield r.pingService.ping(i,t)})()}handle(e,t,r){var i=this;return j(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var s=j(function*(o){yield i.components.getRegistrar().handle(o,t,r)});return function(o){return s.apply(this,arguments)}}()))})()}unhandle(e){var t=this;return j(function*(){Array.isArray(e)||(e=[e]),yield Promise.all(e.map(function(){var r=j(function*(i){yield t.components.getRegistrar().unhandle(i)});return function(i){return r.apply(this,arguments)}}()))})()}onDiscoveryPeer(e){const{detail:t}=e;t.id.toString()!==this.peerId.toString()?(t.multiaddrs.length>0&&this.components.getPeerStore().addressBook.add(t.id,t.multiaddrs).catch(r=>Eo.error(r)),t.protocols.length>0&&this.components.getPeerStore().protoBook.set(t.id,t.protocols).catch(r=>Eo.error(r)),this.dispatchEvent(new tn("peer:discovery",{detail:t}))):Eo.error(new Error(Ce.ERR_DISCOVERED_SELF))}}function uH(n){return lE.apply(this,arguments)}function lE(){return lE=j(function*(n){return null==n.peerId&&(n.peerId=yield iH()),new cH(rH(n))}),lE.apply(this,arguments)}function lH(n){return fE.apply(this,arguments)}function fE(){return fE=j(function*(n){return yield uH(n)}),fE.apply(this,arguments)}function TA(n,e){return n.length<=e||n.length<=1?n:function dH(n){if(n.length<=1)return n;for(let t=0;t{class n extends Ei{constructor(t,r){super(),this.interval=r?.interval??n.DefaultInterval;const i=r?.maxPeers??t?.length,s=t.map(o=>"string"==typeof o?new yn(o):o);this.peers=function fH(n){return n.map(e=>{const t=e.getPeerId();return{id:t?fr(t):null,multiaddrs:[e.decapsulateCode(421)],protocols:[]}}).filter(e=>null!==e.id)}(TA(s,i)),AA("Use provided list of peers (reduced to maxPeers)",this.peers.map(o=>o.toString()))}start(){this._startTimer()}_startTimer(){if(this.peers){if(AA("Starting to emit static peers."),null!=this.timer)return;this.timer=setInterval(()=>this._returnPeers(),this.interval),this._returnPeers()}}_returnPeers(){null!=this.timer&&this.peers.forEach(t=>{this.dispatchEvent(new tn("peer",{detail:t}))})}stop(){null!=this.timer&&clearInterval(this.timer),this.timer=void 0}get[uE](){return!0}get[Symbol.toStringTag](){return"@waku/peer-discovery-static-list"}}return n.DefaultInterval=200,n})();var au=(()=>(function(n){n.Prod="prod",n.Test="test"}(au||(au={})),au))();const dE_fleets={"wakuv2.prod":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.prod":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAm4v86W3bmT1BiH6oSPzcsSr24iDQpSN5Qa992BCjjwgrD","node-01.do-ams3.wakuv2.prod":"/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e","node-01.gc-us-central1-a.wakuv2.prod":"/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/443/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA"}},"wakuv2.test":{"waku-websocket":{"node-01.ac-cn-hongkong-c.wakuv2.test":"/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm","node-01.do-ams3.wakuv2.test":"/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ","node-01.gc-us-central1-a.wakuv2.test":"/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS"}}};function cu(n){return"string"==typeof n?Ot(n.replace(/^0x/i,"").toLowerCase(),"base16"):n}function Cs(n,e){const t=e??n.reduce((s,o)=>s+o.length,0),r=new Uint8Array(t);let i=0;for(const s of n)r.set(s,i),i+=s.length;return r}var $h;dr("waku:select-peer"),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}($h||($h={}));var bH=x(6577),wH=x(4237);const uu_algorithm={name:"AES-GCM",length:128},jh={node:bH,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0};function Xi(){if(jh.web)return jh.web.subtle;if(jh.node)return jh.node.webcrypto.subtle;throw new Error("The environment doesn't have Crypto Subtle API (if in the browser, be sure to use to be in a secure context, ie, https)")}const lu=Yr.randomBytes,gE=Yr.sha256;function _H(n,e){return yE.apply(this,arguments)}function yE(){return yE=j(function*(n,e){const[t,r]=yield OI(n,e,{recovered:!0,der:!1});return Cs([t,new Uint8Array([r])],t.length+1)}),yE.apply(this,arguments)}function mE(n){return new Uint8Array(wH.keccak256.arrayBuffer(n))}function xA(n,e){let t=1,r=0,i=Promise.resolve(new Uint8Array);for(;r>24,t>>16,t>>8,t]),o=Cs([s,n],s.length+n.length),a=gE(o);i=i.then(u=>a.then(_=>{const R=new Uint8Array(_);return Cs([u,R],u.length+R.length)})),r+=32,t+=1}return i}function DH(n,e,t){return Xi().importKey("raw",e,"AES-CTR",!1,["encrypt"]).then(r=>Xi().encrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function SH(n,e,t){return Xi().importKey("raw",e,"AES-CTR",!1,["decrypt"]).then(r=>Xi().decrypt({name:"AES-CTR",counter:n,length:128},r,t)).then(r=>new Uint8Array(r))}function CH(n,e){const t={name:"HMAC",hash:{name:"SHA-256"}};return Xi().importKey("raw",n,t,!1,["sign"]).then(r=>Xi().sign(t,r,e)).then(r=>new Uint8Array(r))}function IH(n,e,t){const r={name:"HMAC",hash:{name:"SHA-256"}};return Xi().importKey("raw",n,r,!1,["verify"]).then(s=>Xi().verify(r,s,t,e))}function RA(n,e){if(32!==n.length)throw new Error(`Bad private key, it should be 32 bytes but it's actually ${n.length} bytes long`);if(65!==e.length)throw new Error(`Bad public key, it should be 65 bytes but it's actually ${e.length} bytes long`);if(4!==e[0])throw new Error("Bad public key, a valid public key would begin with 4");{const t=function IF(n,e,t=!1){if(xI(n))throw new TypeError("getSharedSecret: first arg must be private key");if(!xI(e))throw new TypeError("getSharedSecret: second arg must be public key");const r=U0(e);return r.assertValidity(),r.multiply(_a(n)).toRawBytes(t)}(n,e,!0);return new Uint8Array(cu(t).slice(1))}}function TH(n,e){return vE.apply(this,arguments)}function vE(){return vE=j(function*(n,e){const t=lu(32),r=yield RA(t,n),i=yield xA(r,32),s=lu(16),o=i.slice(0,16),a=yield DH(s,o,e),u=Cs([s,a],s.length+a.length),_=yield gE(i.slice(16)),R=yield CH(_,u),N=Dl(t,!1);return Cs([N,u,R],N.length+u.length+R.length)}),vE.apply(this,arguments)}function AH(n,e){return bE.apply(this,arguments)}function bE(){return bE=j(function*(n,e){if(e.length<=113)throw new Error("Invalid Ciphertext. Data is too small. It should ba at least 113 bytes");if(4!==e[0])throw new Error(`Not a valid ciphertext. It should begin with 4 but actually begin with ${e[0]}`);{const t=e.slice(0,65),r=e.length-113,i=e.slice(65,81),s=e.slice(65,81+r),o=s.slice(16),a=e.slice(81+r),u=RA(n,t),_=yield xA(u,32),[R,N]=yield gE(_.slice(16)).then(B=>[_.slice(0,16),B]);if(!(yield IH(N,s,a)))throw new Error("Incorrect MAC");return SH(i,R,o)}}),bE.apply(this,arguments)}function xH(n,e,t){return wE.apply(this,arguments)}function wE(){return wE=j(function*(n,e,t){return Xi().importKey("raw",e,uu_algorithm,!1,["encrypt"]).then(r=>Xi().encrypt({iv:n,...uu_algorithm},r,t)).then(r=>new Uint8Array(r))}),wE.apply(this,arguments)}function RH(n,e,t){return _E.apply(this,arguments)}function _E(){return _E=j(function*(n,e,t){return Xi().importKey("raw",e,uu_algorithm,!1,["decrypt"]).then(r=>Xi().decrypt({iv:n,...uu_algorithm},r,t)).then(r=>new Uint8Array(r))}),_E.apply(this,arguments)}function PH(){return lu(12)}function NA(n,e){return CE.apply(this,arguments)}function CE(){return CE=j(function*(n,e){let t=new Uint8Array([0]);t=VH(t,n),t=Cs([t,n]);let r=1+kA(n)+n.length;e&&(r+=65);const s=256-r%256,o=lu(s);if(!HH(o,s))throw new Error("failed to generate random padding of size "+s);let a;if(t=Cs([t,o]),e){t[0]|=4;const u=mE(t),_=yield _H(u,e);t=Cs([t,_]),a={signature:_,publicKey:Dl(e,!1)}}return{payload:t,sig:a}}),CE.apply(this,arguments)}function IE(){return IE=j(function*(n,e){return TH(cu(e),n)}),IE.apply(this,arguments)}function MA(n,e){return TE.apply(this,arguments)}function TE(){return TE=j(function*(n,e){return AH(e,n)}),TE.apply(this,arguments)}function AE(){return AE=j(function*(n,e){const t=PH();return Cs([yield xH(t,cu(e),n),t])}),AE.apply(this,arguments)}function OA(n,e){return xE.apply(this,arguments)}function xE(){return xE=j(function*(n,e){const t=n.length-12,r=n.slice(0,t);return RH(n.slice(t),cu(e),r)}),xE.apply(this,arguments)}function VH(n,e){const t=kA(e);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,e.length,!0),r=r.slice(0,t),(n=Cs([n,r]))[0]|=t,n}function kA(n){let e=1;for(let t=n.length;t>=256;t/=256)e++;return e}function HH(n,e){return n.length===e&&(e<=3||-1!==n.findIndex(t=>0!==t))}const sa=dr("waku:message"),LA=BigInt(1e6);var Gh,zh,BA,Wh,tf=(()=>(function(n){n.Asymmetric="asymmetric",n.Symmetric="symmetric"}(tf||(tf={})),tf))();class oa{constructor(e,t,r){this.proto=e,this._signaturePublicKey=t,this._signature=r}static fromUtf8String(e,t,r){return j(function*(){const i=(n=>Ot(n,"utf8"))(e);return oa.fromBytes(i,t,r)})()}static fromBytes(e,t,r){return j(function*(){const{timestamp:i,encPublicKey:s,symKey:o,sigPrivKey:a}=Object.assign({timestamp:new Date},r||{});let R,u=e,_=0;if(s&&o)throw"Pass either `encPublicKey` or `symKey`, not both.";if(s){const N=yield NA(u,a);u=yield function FH(n,e){return IE.apply(this,arguments)}(N.payload,s),R=N.sig,_=1}else if(o){const N=yield NA(u,a);u=yield function UH(n,e){return AE.apply(this,arguments)}(N.payload,o),R=N.sig,_=1}return new oa({payload:u,timestampDeprecated:i.valueOf()/1e3,timestamp:BigInt(i.valueOf())*LA,version:_,contentTopic:t},R?.publicKey,R?.signature)})()}static decode(e,t){return j(function*(){const r=$h.decode(e);return oa.decodeProto(r,t)})()}static decodeProto(e,t){return j(function*(){const r=e.payload;let i,s;if(1===e.version&&r){if(void 0===t)return void sa("Payload is encrypted but no private keys have been provided.");const o=yield Promise.all(t.map(function(){var N=j(function*({key:B,method:K,contentTopics:Z}){if(!Z||e.contentTopic&&Z.includes(e.contentTopic))switch(K){case tf.Asymmetric:try{return yield MA(r,B)}catch(J){return void sa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",J)}case tf.Symmetric:try{return yield OA(r,B)}catch(J){return void sa("Failed to decrypt message using asymmetric encryption despite decryption method being specified",J)}default:try{return yield OA(r,B)}catch(J){sa("Failed to decrypt message using symmetric encryption",J);try{return yield MA(r,B)}catch(oe){return void sa("Failed to decrypt message using asymmetric encryption",oe)}}}});return function(B){return N.apply(this,arguments)}}())),u=o.filter(N=>!!N);if(0===u.length)return void sa("Failed to decrypt payload.");const _=u[0],R=yield function OH(n){const e=function kH(n){return 3&new DataView(n.buffer).getUint8(0)}(n);if(0===e)return;const t=function LH(n,e){let t=n.slice(1,1+e);return e<4&&(t=Cs([t,new Uint8Array(4-e)],4)),new DataView(t.buffer).getInt32(0,!0)}(n,e),r=1+e,i=n.slice(r,r+t),s=function BH(n){return 4==(4&new DataView(n.buffer).getUint8(0))}(n);let o;if(s){const a=function KH(n){return n.slice(n.length-65,n.length)}(n),u=function $H(n,e){return mE(e?n.slice(0,n.length-65):n)}(n,s),_=function jH(n,e){const r=new DataView(e.slice(64).buffer).getUint8(0);return function CF(n,e,t,r=!1){return In.fromSignature(n,e,t).toRawBytes(r)}(n,uo.fromCompact(e.slice(0,64)),r,!1)}(u,a);o={signature:a,publicKey:_}}return{payload:i,sig:o}}(_);if(!R)return void sa("Failed to decode payload.");Object.assign(e,{payload:R.payload}),i=R.sig?.publicKey,s=R.sig?.signature}return new oa(e,i,s)})()}encode(){return $h.encode(this.proto)}get payloadAsUtf8(){if(!this.payload)return"";try{return(n=>Lt(this.payload,"utf8"))()}catch(e){return sa("Could not decode byte as UTF-8",e),""}}get payload(){if(this.proto.payload)return new Uint8Array(this.proto.payload)}get contentTopic(){return this.proto.contentTopic}get version(){return this.proto.version??0}get timestamp(){try{if(this.proto.timestamp)return new Date(Number(this.proto.timestamp/LA));if(this.proto.timestampDeprecated)return new Date(1e3*this.proto.timestampDeprecated)}catch{return}}get signaturePublicKey(){return this._signaturePublicKey}get signature(){return this._signature}}!function(n){let e,t;!function(r){let i;r.codec=()=>(null==i&&(i=Yt((s,o,a={})=>{!1!==a.lengthDelimited&&o.fork(),null!=s.contentTopic&&(o.uint32(10),o.string(s.contentTopic)),!1!==a.lengthDelimited&&o.ldelim()},(s,o)=>{const a={},u=null==o?s.len:s.pos+o;for(;s.pos>>3==1?a.contentTopic=s.string():s.skipType(7&_)}return a})),i),r.encode=s=>qt(s,r.codec()),r.decode=s=>Wt(s,r.codec())}(e=n.ContentFilter||(n.ContentFilter={})),n.codec=()=>(null==t&&(t=Yt((r,i,s={})=>{if(!1!==s.lengthDelimited&&i.fork(),null!=r.subscribe&&(i.uint32(8),i.bool(r.subscribe)),null!=r.topic&&(i.uint32(18),i.string(r.topic)),null==r.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const o of r.contentFilters)i.uint32(26),n.ContentFilter.codec().encode(o,i);!1!==s.lengthDelimited&&i.ldelim()},(r,i)=>{const s={contentFilters:[]},o=null==i?r.len:r.pos+i;for(;r.pos>>3){case 1:s.subscribe=r.bool();break;case 2:s.topic=r.string();break;case 3:s.contentFilters.push(n.ContentFilter.codec().decode(r,r.uint32()));break;default:r.skipType(7&a)}}return s})),t),n.encode=r=>qt(r,n.codec()),n.decode=r=>Wt(r,n.codec())}(Gh||(Gh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null==t.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const s of t.messages)r.uint32(10),Wh.codec().encode(s,r);!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={messages:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.messages.push(Wh.codec().decode(t,t.uint32())):t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(zh||(zh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),Gh.codec().encode(t.request,r)),null!=t.push&&(r.uint32(26),zh.codec().encode(t.push,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=Gh.codec().decode(t,t.uint32());break;case 3:i.push=zh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(BA||(BA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Wh||(Wh={}));const ka="/vac/waku/filter/2.0.0-beta1";var qh,Yh,FA,Qh;dr("waku:filter"),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(10),r.string(t.pubSubTopic)),null!=t.message&&(r.uint32(18),Qh.codec().encode(t.message,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.pubSubTopic=t.string();break;case 2:i.message=Qh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(qh||(qh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.isSuccess&&(r.uint32(8),r.bool(t.isSuccess)),null!=t.info&&(r.uint32(18),r.string(t.info)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.isSuccess=t.bool();break;case 2:i.info=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Yh||(Yh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.request&&(r.uint32(18),qh.codec().encode(t.request,r)),null!=t.response&&(r.uint32(26),Yh.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.request=qh.codec().decode(t,t.uint32());break;case 3:i.response=Yh.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(FA||(FA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Qh||(Qh={})),dr("waku:light-push");const nf="/vac/waku/lightpush/2.0.0-beta1",La=["/vac/waku/relay/2.0.0-beta2","/vac/waku/relay/2.0.0"];var Zh,fu,Xh,Jh,rf,UA,ep;!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(16),r.sint64(t.receivedTime)),null!=t.senderTime&&(r.uint32(24),r.sint64(t.senderTime)),null!=t.pubsubTopic&&(r.uint32(34),r.string(t.pubsubTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.sint64();break;case 3:i.senderTime=t.sint64();break;case 4:i.pubsubTopic=t.string();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Zh||(Zh={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),Zh.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=Zh.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(fu||(fu={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Xh||(Xh={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),Xh.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),fu.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(40),r.sint64(t.startTime)),null!=t.endTime&&(r.uint32(48),r.sint64(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(Xh.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=fu.codec().decode(t,t.uint32());break;case 5:i.startTime=t.sint64();break;case 6:i.endTime=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(Jh||(Jh={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),ep.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),fu.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(ep.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=fu.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(rf||(rf={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),Jh.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),rf.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=Jh.codec().decode(t,t.uint32());break;case 3:i.response=rf.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(UA||(UA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(ep||(ep={}));var tp,du,np,rp,ip,VA,sp,sf=(()=>(function(n){n.V2Beta3="/vac/waku/store/2.0.0-beta3",n.V2Beta4="/vac/waku/store/2.0.0-beta4"}(sf||(sf={})),sf))();!function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.digest&&(r.uint32(10),r.bytes(t.digest)),null!=t.receivedTime&&(r.uint32(17),r.double(t.receivedTime)),null!=t.senderTime&&(r.uint32(25),r.double(t.senderTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.digest=t.bytes();break;case 2:i.receivedTime=t.double();break;case 3:i.senderTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(tp||(tp={})),function(n){let e;var i;let t,r;(i=e=n.Direction||(n.Direction={})).DIRECTION_BACKWARD_UNSPECIFIED="DIRECTION_BACKWARD_UNSPECIFIED",i.DIRECTION_FORWARD="DIRECTION_FORWARD",function(i){i[i.DIRECTION_BACKWARD_UNSPECIFIED=0]="DIRECTION_BACKWARD_UNSPECIFIED",i[i.DIRECTION_FORWARD=1]="DIRECTION_FORWARD"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.Direction||(n.Direction={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{!1!==o.lengthDelimited&&s.fork(),null!=i.pageSize&&(s.uint32(8),s.uint64(i.pageSize)),null!=i.cursor&&(s.uint32(18),tp.codec().encode(i.cursor,s)),null!=i.direction&&(s.uint32(24),n.Direction.codec().encode(i.direction,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 1:o.pageSize=i.uint64();break;case 2:o.cursor=tp.codec().decode(i,i.uint32());break;case 3:o.direction=n.Direction.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(du||(du={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.contentTopic&&(r.uint32(10),r.string(t.contentTopic)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3==1?i.contentTopic=t.string():t.skipType(7&o)}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(np||(np={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{if(!1!==i.lengthDelimited&&r.fork(),null!=t.pubSubTopic&&(r.uint32(18),r.string(t.pubSubTopic)),null==t.contentFilters)throw new Error('Protocol error: required field "contentFilters" was not found in object');for(const s of t.contentFilters)r.uint32(26),np.codec().encode(s,r);null!=t.pagingInfo&&(r.uint32(34),du.codec().encode(t.pagingInfo,r)),null!=t.startTime&&(r.uint32(41),r.double(t.startTime)),null!=t.endTime&&(r.uint32(49),r.double(t.endTime)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={contentFilters:[]},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 2:i.pubSubTopic=t.string();break;case 3:i.contentFilters.push(np.codec().decode(t,t.uint32()));break;case 4:i.pagingInfo=du.codec().decode(t,t.uint32());break;case 5:i.startTime=t.double();break;case 6:i.endTime=t.double();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(rp||(rp={})),function(n){let e;var i;let t,r;(i=e=n.HistoryError||(n.HistoryError={})).ERROR_NONE_UNSPECIFIED="ERROR_NONE_UNSPECIFIED",i.ERROR_INVALID_CURSOR="ERROR_INVALID_CURSOR",function(i){i[i.ERROR_NONE_UNSPECIFIED=0]="ERROR_NONE_UNSPECIFIED",i[i.ERROR_INVALID_CURSOR=1]="ERROR_INVALID_CURSOR"}(t||(t={})),function(i){i.codec=()=>Fo(t)}(e=n.HistoryError||(n.HistoryError={})),n.codec=()=>(null==r&&(r=Yt((i,s,o={})=>{if(!1!==o.lengthDelimited&&s.fork(),null==i.messages)throw new Error('Protocol error: required field "messages" was not found in object');for(const a of i.messages)s.uint32(18),sp.codec().encode(a,s);null!=i.pagingInfo&&(s.uint32(26),du.codec().encode(i.pagingInfo,s)),null!=i.error&&(s.uint32(32),n.HistoryError.codec().encode(i.error,s)),!1!==o.lengthDelimited&&s.ldelim()},(i,s)=>{const o={messages:[]},a=null==s?i.len:i.pos+s;for(;i.pos>>3){case 2:o.messages.push(sp.codec().decode(i,i.uint32()));break;case 3:o.pagingInfo=du.codec().decode(i,i.uint32());break;case 4:o.error=n.HistoryError.codec().decode(i);break;default:i.skipType(7&u)}}return o})),r),n.encode=i=>qt(i,n.codec()),n.decode=i=>Wt(i,n.codec())}(ip||(ip={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.query&&(r.uint32(18),rp.codec().encode(t.query,r)),null!=t.response&&(r.uint32(26),ip.codec().encode(t.response,r)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.requestId=t.string();break;case 2:i.query=rp.codec().decode(t,t.uint32());break;case 3:i.response=ip.codec().decode(t,t.uint32());break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(VA||(VA={})),function(n){let e;n.codec=()=>(null==e&&(e=Yt((t,r,i={})=>{!1!==i.lengthDelimited&&r.fork(),null!=t.payload&&(r.uint32(10),r.bytes(t.payload)),null!=t.contentTopic&&(r.uint32(18),r.string(t.contentTopic)),null!=t.version&&(r.uint32(24),r.uint32(t.version)),null!=t.timestampDeprecated&&(r.uint32(33),r.double(t.timestampDeprecated)),null!=t.timestamp&&(r.uint32(80),r.sint64(t.timestamp)),!1!==i.lengthDelimited&&r.ldelim()},(t,r)=>{const i={},s=null==r?t.len:t.pos+r;for(;t.pos>>3){case 1:i.payload=t.bytes();break;case 2:i.contentTopic=t.string();break;case 3:i.version=t.uint32();break;case 4:i.timestampDeprecated=t.double();break;case 10:i.timestamp=t.sint64();break;default:t.skipType(7&o)}}return i})),e),n.encode=t=>qt(t,n.codec()),n.decode=t=>Wt(t,n.codec())}(sp||(sp={})),BigInt(1e6),dr("waku:store");const OE=dr("waku:waku");var Jr=(()=>(function(n){n.Relay="relay",n.Store="store",n.LightPush="lightpush",n.Filter="filter"}(Jr||(Jr={})),Jr))();class tK{constructor(e,t,r,i,s){this.libp2p=t,this.store=r,this.filter=s,this.lightPush=i,function nK(n){if(n)try{return n.multicodecs.includes(La[La.length-1])}catch{}return!1}(t.pubsub)&&(this.relay=t.pubsub),OE("Waku node created",this.libp2p.peerId.toString(),`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`),this.pingKeepAliveTimers={},this.relayKeepAliveTimers={};const o=e.pingKeepAlive||0,a=this.relay?e.relayKeepAlive||300:0;t.connectionManager.addEventListener("peer:connect",u=>{this.startKeepAlive(u.detail.remotePeer,o,a)}),t.connectionManager.addEventListener("peer:disconnect",u=>{this.stopKeepAlive(u.detail.remotePeer)}),e?.decryptionKeys?.forEach(u=>{this.addDecryptionKey(u)})}dial(e,t){var r=this;return j(function*(){const i=t??[Jr.Relay],s=[];if(i.includes(Jr.Relay)&&La.forEach(o=>s.push(o)),i.includes(Jr.Store))for(const o of Object.values(sf))s.push(o);return i.includes(Jr.LightPush)&&s.push(nf),i.includes(Jr.Filter)&&s.push(ka),r.libp2p.dialProtocol(e,s)})()}addPeerToAddressBook(e,t){var r=this;return j(function*(){let i;i="string"==typeof e?fr(e):e;const s=t.map(o=>"string"==typeof o?function tV(n){return new yn(n)}(o):o);yield r.libp2p.peerStore.addressBook.set(i,s)})()}start(){var e=this;return j(function*(){yield e.libp2p.start()})()}stop(){var e=this;return j(function*(){e.stopAllKeepAlives(),yield e.libp2p.stop()})()}isStarted(){return this.libp2p.isStarted()}addDecryptionKey(e,t){this.relay&&this.relay.addDecryptionKey(e,t),this.store&&this.store.addDecryptionKey(e,t),this.filter&&this.filter.addDecryptionKey(e,t)}deleteDecryptionKey(e){this.relay&&this.relay.deleteDecryptionKey(e),this.store&&this.store.deleteDecryptionKey(e),this.filter&&this.filter.deleteDecryptionKey(e)}getLocalMultiaddrWithID(){const e=this.libp2p.getMultiaddrs().find(t=>t.toString().match(/127\.0\.0\.1/));if(!e||""===e.toString())throw"Not listening on localhost";return e+"/p2p/"+this.libp2p.peerId.toString()}startKeepAlive(e,t,r){this.stopKeepAlive(e);const i=e.toString();0!==t&&(this.pingKeepAliveTimers[i]=setInterval(()=>{this.libp2p.ping(e).catch(o=>{OE(`Ping failed (${i})`,o)})},1e3*t));const s=this.relay;s&&0!==r&&(this.relayKeepAliveTimers[i]=setInterval(()=>{OE("Sending Waku Relay ping message"),oa.fromBytes(new Uint8Array,"/relay-ping/1/ping/null").then(o=>s.send(o))},1e3*r))}stopKeepAlive(e){const t=e.toString();this.pingKeepAliveTimers[t]&&(clearInterval(this.pingKeepAliveTimers[t]),delete this.pingKeepAliveTimers[t]),this.relayKeepAliveTimers[t]&&(clearInterval(this.relayKeepAliveTimers[t]),delete this.relayKeepAliveTimers[t])}stopAllKeepAlives(){for(const e of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(e);this.pingKeepAliveTimers={},this.relayKeepAliveTimers={}}}const $A=()=>{};class rK{constructor(e){this.min=e.min??0,this.max=e.max??1/0,this.peers=new Set,this.onConnect=e.onConnect??$A,this.onDisconnect=e.onDisconnect??$A}get[Symbol.toStringTag](){return Hv.toString()}get[Hv](){return!0}setRegistrar(e){var t=this;return j(function*(){t.registrar=e})()}disconnect(e){this.onDisconnect(e)}}class sK{constructor(e,t,r){this.gossip=e,this.msgs=new Map,this.history=[],this.msgIdToStrFn=r;for(let i=0;i{const s=this.msgs.get(i.msgIdStr);if(s&&s.validated&&e.has(i.topic)){let o=t.get(i.topic);o||(o=[],t.set(i.topic,o)),o.push(i.msgId)}});return t}validate(e){const t=this.msgs.get(e);if(!t)return null;const{message:r,originatingPeers:i}=t;return t.validated=!0,t.originatingPeers=new Set,{message:r,originatingPeers:i}}shift(){this.history[this.history.length-1].forEach(t=>{this.msgs.delete(t.msgIdStr)}),this.history.pop(),this.history.unshift([])}remove(e){const t=this.msgs.get(e);return t?(this.msgs.delete(e),t):null}}var oK=x(8479);const{RPC:ap}=oK,jA="/floodsub/1.0.0",GA="/meshsub/1.0.0",LE="/meshsub/1.1.0",gu=5e3;function bo(n=[],e){return{subscriptions:[],messages:n,control:e?{graft:e.graft||[],prune:e.prune||[],ihave:e.ihave||[],iwant:e.iwant||[]}:void 0}}function wo(n){if(n.length<=1)return n;for(let t=0;t(function(n){n.StrictSign="StrictSign",n.StrictNoSign="StrictNoSign"}(up||(up={})),up))(),Ba=(()=>(function(n){n[n.Signing=0]="Signing",n[n.Anonymous=1]="Anonymous"}(Ba||(Ba={})),Ba))(),$s=(()=>(function(n){n.Accept="accept",n.Ignore="ignore",n.Reject="reject"}($s||($s={})),$s))(),Ji=(()=>(function(n){n.Error="error",n.Ignore="ignore",n.Reject="reject",n.Blacklisted="blacklisted"}(Ji||(Ji={})),Ji))(),li=(()=>(function(n){n.InvalidSignature="invalid_signature",n.InvalidSeqno="invalid_seqno",n.InvalidPeerId="invalid_peerid",n.SignaturePresent="signature_present",n.SeqnoPresent="seqno_present",n.FromPresent="from_present",n.TransformFailed="transform_failed"}(li||(li={})),li))(),es=(()=>(function(n){n.duplicate="duplicate",n.invalid="invalid",n.valid="valid"}(es||(es={})),es))();function WA(n){switch(n){case $s.Ignore:return Ji.Ignore;case $s.Reject:return Ji.Reject}}function FE(){return FE=j(function*(n,e){switch(n){case cp:{if(!e)throw Error("Must provide PeerId");if(null==e.privateKey)throw Error("Cannot sign message, no private key present");if(null==e.publicKey)throw Error("Cannot sign message, no public key present");const t=yield Pl(e.privateKey);return{type:Ba.Signing,author:e,key:e.publicKey,privateKey:t}}case BE:return{type:Ba.Anonymous};default:throw new Error(`Unknown signature policy "${n}"`)}}),FE.apply(this,arguments)}const Kn="ERR_INVALID_PEER_SCORE_PARAMS",UK={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyThreshold:0,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},VK={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3};function HK(n={}){return{...UK,...n,topics:n.topics?Object.entries(n.topics).reduce((e,[t,r])=>(e[t]=function KK(n={}){return{...VK,...n}}(r),e),{}):{}}}function jK(n){if(n.topicWeight<0)throw ae(new Error("invalid topic weight; must be >= 0"),Kn);if(0===n.timeInMeshQuantum)throw ae(new Error("invalid TimeInMeshQuantum; must be non zero"),Kn);if(n.timeInMeshWeight<0)throw ae(new Error("invalid TimeInMeshWeight; must be positive (or 0 to disable)"),Kn);if(0!==n.timeInMeshWeight&&n.timeInMeshQuantum<=0)throw ae(new Error("invalid TimeInMeshQuantum; must be positive"),Kn);if(0!==n.timeInMeshWeight&&n.timeInMeshCap<=0)throw ae(new Error("invalid TimeInMeshCap; must be positive"),Kn);if(n.firstMessageDeliveriesWeight<0)throw ae(new Error("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)"),Kn);if(0!==n.firstMessageDeliveriesWeight&&(n.firstMessageDeliveriesDecay<=0||n.firstMessageDeliveriesDecay>=1))throw ae(new Error("invalid FirstMessageDeliveriesDecay; must be between 0 and 1"),Kn);if(0!==n.firstMessageDeliveriesWeight&&n.firstMessageDeliveriesCap<=0)throw ae(new Error("invalid FirstMessageDeliveriesCap; must be positive"),Kn);if(n.meshMessageDeliveriesWeight>0)throw ae(new Error("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.meshMessageDeliveriesWeight&&(n.meshMessageDeliveriesDecay<=0||n.meshMessageDeliveriesDecay>=1))throw ae(new Error("invalid MeshMessageDeliveriesDecay; must be between 0 and 1"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesCap<=0)throw ae(new Error("invalid MeshMessageDeliveriesCap; must be positive"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesThreshold<=0)throw ae(new Error("invalid MeshMessageDeliveriesThreshold; must be positive"),Kn);if(n.meshMessageDeliveriesWindow<0)throw ae(new Error("invalid MeshMessageDeliveriesWindow; must be non-negative"),Kn);if(0!==n.meshMessageDeliveriesWeight&&n.meshMessageDeliveriesActivation<1e3)throw ae(new Error("invalid MeshMessageDeliveriesActivation; must be at least 1s"),Kn);if(n.meshFailurePenaltyWeight>0)throw ae(new Error("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.meshFailurePenaltyWeight&&(n.meshFailurePenaltyDecay<=0||n.meshFailurePenaltyDecay>=1))throw ae(new Error("invalid MeshFailurePenaltyDecay; must be between 0 and 1"),Kn);if(n.invalidMessageDeliveriesWeight>0)throw ae(new Error("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)"),Kn);if(n.invalidMessageDeliveriesDecay<=0||n.invalidMessageDeliveriesDecay>=1)throw ae(new Error("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1"),Kn)}const GK={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function zK(n={}){return{...GK,...n}}function WK(n,e,t,r){let i=0;if(Object.entries(e.topics).forEach(([o,a])=>{const u=t.topics[o];if(void 0===u)return;let _=0;if(a.inMesh){let K=a.meshTime/u.timeInMeshQuantum;K>u.timeInMeshCap&&(K=u.timeInMeshCap),_+=K*u.timeInMeshWeight}let R=a.firstMessageDeliveries;if(R>u.firstMessageDeliveriesCap&&(R=u.firstMessageDeliveriesCap),_+=R*u.firstMessageDeliveriesWeight,a.meshMessageDeliveriesActive&&a.meshMessageDeliveries0&&i>t.topicScoreCap&&(i=t.topicScoreCap),i+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(o=>{if(t.IPColocationFactorWhitelist.has(o))return;const a=r.get(o),u=a?a.size:0;if(u>t.IPColocationFactorThreshold){const _=u-t.IPColocationFactorThreshold;i+=_*_*t.IPColocationFactorWeight}}),e.behaviourPenalty>t.behaviourPenaltyThreshold){const o=e.behaviourPenalty-t.behaviourPenaltyThreshold;i+=o*o*t.behaviourPenaltyWeight}return i}var qK=x(1807),fi=(()=>(function(n){n[n.unknown=0]="unknown",n[n.valid=1]="valid",n[n.invalid=2]="invalid",n[n.ignored=3]="ignored"}(fi||(fi={})),fi))();class YK{constructor(){this.records=new Map,this.queue=new qK}ensureRecord(e){let t=this.records.get(e);if(t)return t;t={status:fi.unknown,firstSeen:Date.now(),validated:0,peers:new Set},this.records.set(e,t);const r={msgId:e,expire:Date.now()+12e4};return this.queue.push(r),t}gc(){const e=Date.now();let t=this.queue.peekFront();for(;t&&t.expire0)throw ae(new Error("invalid IPColocationFactorWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.IPColocationFactorWeight&&n.IPColocationFactorThreshold<1)throw ae(new Error("invalid IPColocationFactorThreshold; must be at least 1"),Kn);if(n.behaviourPenaltyWeight>0)throw ae(new Error("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)"),Kn);if(0!==n.behaviourPenaltyWeight&&(n.behaviourPenaltyDecay<=0||n.behaviourPenaltyDecay>=1))throw ae(new Error("invalid BehaviourPenaltyDecay; must be between 0 and 1"),Kn);if(n.decayInterval<1e3)throw ae(new Error("invalid DecayInterval; must be at least 1s"),Kn);if(n.decayToZero<=0||n.decayToZero>=1)throw ae(new Error("invalid DecayToZero; must be between 0 and 1"),Kn)}(e),this.scoreCacheValidityMs=r.scoreCacheValidityMs,this.computeScore=r.computeScore??WK}init(e){this.components=e}get size(){return this.peerStats.size}start(){this._backgroundInterval?yu("Peer score already running"):(this._backgroundInterval=setInterval(()=>this.background(),this.params.decayInterval),yu("started"))}stop(){this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),yu("stopped")):yu("Peer score already stopped")}background(){this.refreshScores(),this.updateIPs(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map(([e,t])=>[e,t]))}refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach((r,i)=>{r.connected?(Object.entries(r.topics).forEach(([s,o])=>{const a=this.params.topics[s];void 0!==a&&(o.firstMessageDeliveries*=a.firstMessageDeliveriesDecay,o.firstMessageDeliveriesa.meshMessageDeliveriesActivation&&(o.meshMessageDeliveriesActive=!0)))}),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenaltyr.expire&&(this.removeIPs(i,r.ips),this.peerStats.delete(i),this.scoreCache.delete(i))})}score(e){this.metrics?.scoreFnCalls.inc();const t=this.peerStats.get(e);if(!t)return 0;const r=Date.now(),i=this.scoreCache.get(e);if(i&&i.cacheUntil>r)return i.score;this.metrics?.scoreFnRuns.inc();const s=this.computeScore(e,t,this.params,this.peerIPs),o=r+this.scoreCacheValidityMs;return i?(this.metrics?.scoreCachedDelta.observe(Math.abs(s-i.score)),i.score=s,i.cacheUntil=o):this.scoreCache.set(e,{score:s,cacheUntil:o}),s}addPenalty(e,t,r){const i=this.peerStats.get(e);i&&(i.behaviourPenalty+=t,this.metrics?.onScorePenalty(r))}addPeer(e){const t={connected:!0,expire:0,topics:{},ips:[],behaviourPenalty:0};this.peerStats.set(e,t);const r=this.getIPs(e);this.setIPs(e,r,t.ips),t.ips=r}removePeer(e){const t=this.peerStats.get(e);if(t){if(this.score(e)>0)return this.removeIPs(e,t.ips),void this.peerStats.delete(e);Object.entries(t.topics).forEach(([r,i])=>{i.firstMessageDeliveries=0;const s=this.params.topics[r].meshMessageDeliveriesThreshold;if(i.inMesh&&i.meshMessageDeliveriesActive&&i.meshMessageDeliveries{o!==e.toString()&&this.markDuplicateMessageDelivery(o,r)})):yu("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,s-i.firstSeen,fi[i.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,i){switch(i){case Ji.Error:return void this.markInvalidMessageDelivery(e,r);case Ji.Blacklisted:return}const s=this.deliveryRecords.ensureRecord(t);if(s.status===fi.unknown)return i===Ji.Ignore?(s.status=fi.ignored,void s.peers.clear()):(s.status=fi.invalid,this.markInvalidMessageDelivery(e,r),s.peers.forEach(o=>{this.markInvalidMessageDelivery(o,r)}),void s.peers.clear());yu("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-s.firstSeen,fi[s.status])}duplicateMessage(e,t,r){const i=this.deliveryRecords.ensureRecord(t);if(!i.peers.has(e))switch(i.status){case fi.unknown:i.peers.add(e);break;case fi.valid:i.peers.add(e),this.markDuplicateMessageDelivery(e,r,i.validated);break;case fi.invalid:this.markInvalidMessageDelivery(e,r)}}markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);i&&(i.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);if(r){const i=this.getPtopicStats(r,t);if(i){let s=this.params.topics[t].firstMessageDeliveriesCap;i.firstMessageDeliveries=Math.min(s,i.firstMessageDeliveries+1),i.inMesh&&(s=this.params.topics[t].meshMessageDeliveriesCap,i.meshMessageDeliveries=Math.min(s,i.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(e,t,r){const i=this.peerStats.get(e);if(i){const s=void 0!==r?Date.now():0,o=this.getPtopicStats(i,t);if(o&&o.inMesh){const a=this.params.topics[t];if(void 0!==r){const _=s-r,R=_>a.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(t,_,R),R)return}o.meshMessageDeliveries=Math.min(a.meshMessageDeliveriesCap,o.meshMessageDeliveries+1)}}}getIPs(e){return this.components.getConnectionManager().getConnections(fr(e)).map(t=>t.remoteAddr.toOptions().host)}setIPs(e,t,r){e:for(const i of t){for(const o of r)if(i===o)continue e;let s=this.peerIPs.get(i);s||(s=new Set,this.peerIPs.set(i,s)),s.add(e)}e:for(const i of r){for(const o of t)if(i===o)continue e;const s=this.peerIPs.get(i);!s||(s.delete(e),s.size||this.peerIPs.delete(i))}}removeIPs(e,t){t.forEach(r=>{const i=this.peerIPs.get(r);!i||(i.delete(e),i.size||this.peerIPs.delete(r))})}updateIPs(){this.peerStats.forEach((e,t)=>{const r=this.getIPs(t);this.setIPs(t,r,e.ips),e.ips=r})}getPtopicStats(e,t){let r=e.topics[t];return void 0!==r?r:void 0!==this.params.topics[t]?(r={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e.topics[t]=r,r):null}}class ZK{constructor(e,t,r){this.gossipsubIWantFollowupMs=e,this.msgIdToStrFn=t,this.metrics=r,this.promises=new Map,this.requestMsByMsg=new Map,this.requestMsByMsgExpire=10*e}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(e,t){const r=Math.floor(Math.random()*t.length),s=this.msgIdToStrFn(t[r]);let o=this.promises.get(s);o||(o=new Map,this.promises.set(s,o));const a=Date.now();o.has(e)||(o.set(e,a+this.gossipsubIWantFollowupMs),this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(s)||this.requestMsByMsg.set(s,a)))}getBrokenPromises(){const e=Date.now(),t=new Map;let r=0;return this.promises.forEach((i,s)=>{i.forEach((o,a)=>{o=Date.now()?t.value:void 0}clear(){this.entries.clear()}}var _o=(()=>(function(n){n.Fanout="fanout",n.Random="random",n.Subscribed="subscribed",n.Outbound="outbound",n.NotEnough="not_enough",n.Opportunistic="opportunistic"}(_o||(_o={})),_o))(),Fa=(()=>(function(n){n.Dc="disconnected",n.BadScore="bad_score",n.Prune="prune",n.Unsub="unsubscribed",n.Excess="excess"}(Fa||(Fa={})),Fa))(),mu=(()=>(function(n){n.GraftBackoff="graft_backoff",n.BrokenPromise="broken_promise",n.MessageDeficit="message_deficit",n.IPColocation="IP_colocation"}(mu||(mu={})),mu))(),vu=(()=>(function(n){n.LowScore="low_score",n.MaxIhave="max_ihave",n.MaxIasked="max_iasked"}(vu||(vu={})),vu))(),Ua=(()=>(function(n){n.graylist="graylist",n.publish="publish",n.gossip="gossip",n.mesh="mesh"}(Ua||(Ua={})),Ua))();const qA=Ot("libp2p-pubsub:");function VE(){return VE=j(function*(n,e,t,r){switch(n.type){case Ba.Signing:{const i={from:n.author.toBytes(),data:r,seqno:nh(8),topic:e,signature:void 0,key:void 0},s=wr([qA,ap.Message.encode(i).finish()]);return i.signature=yield n.privateKey.sign(s),i.key=n.key,{raw:i,msg:{type:"signed",from:n.author,data:t,sequenceNumber:BigInt(`0x${Lt(i.seqno,"base16")}`),topic:e,signature:i.signature,key:i.key}}}case Ba.Anonymous:return{raw:{from:void 0,data:r,seqno:void 0,topic:e,signature:void 0,key:void 0},msg:{type:"unsigned",data:t,topic:e}}}}),VE.apply(this,arguments)}function HE(){return HE=j(function*(n,e){switch(n){case BE:return null!=e.signature?{valid:!1,error:li.SignaturePresent}:null!=e.seqno?{valid:!1,error:li.SeqnoPresent}:null!=e.key?{valid:!1,error:li.FromPresent}:{valid:!0,message:{type:"unsigned",topic:e.topic,data:e.data??new Uint8Array(0)}};case cp:{if(null==e.seqno)return{valid:!1,error:li.InvalidSeqno};if(8!==e.seqno.length)return{valid:!1,error:li.InvalidSeqno};if(null==e.signature)return{valid:!1,error:li.InvalidSignature};if(null==e.from)return{valid:!1,error:li.InvalidPeerId};let t,r;try{t=Jc(e.from)}catch{return{valid:!1,error:li.InvalidPeerId}}if(e.key){if(r=Rl(e.key),void 0!==t.publicKey&&!kr(r.bytes,t.publicKey))return{valid:!1,error:li.InvalidPeerId}}else{if(null==t.publicKey)return{valid:!1,error:li.InvalidPeerId};r=Rl(t.publicKey)}const s=wr([qA,ap.Message.encode({from:e.from,data:e.data,seqno:e.seqno,topic:e.topic,signature:void 0,key:void 0}).finish()]);return(yield r.verify(s,e.signature))?{valid:!0,message:{type:"signed",from:t,data:e.data??new Uint8Array(0),sequenceNumber:BigInt(`0x${Lt(e.seqno,"base16")}`),topic:e.topic,signature:e.signature,key:e.key??o2(r)}}:{valid:!1,error:li.InvalidSignature}}}}),HE.apply(this,arguments)}function i$(n){if("signed"!==n.type)throw new Error("expected signed message type");if(null==n.sequenceNumber)throw Error("missing seqno field");return((n,e)=>{const t=Ot(e.toString(16).padStart(16,"0"),"base16"),r=new Uint8Array(n.length+t.length);return r.set(n,0),r.set(t,n.length),r})(n.from.toBytes(),n.sequenceNumber)}function s$(n){return KE.apply(this,arguments)}function KE(){return KE=j(function*(n){return yield mi.encode(n.data)}),KE.apply(this,arguments)}function o$(n,e,t,r,i){let s=0;const o=new Map;if(Object.entries(e.topics).forEach(([B,K])=>{const Z=i.get(B)??"unknown",J=t.topics[B];if(void 0===J)return;let oe=o.get(Z);oe||(oe={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(Z,oe));let he=0,Ie=0,ue=0,Re=0,ze=0;K.inMesh&&(he+=Math.max(K.meshTime/J.timeInMeshQuantum,J.timeInMeshCap)*J.timeInMeshWeight);let Oe=K.firstMessageDeliveries;if(Oe>J.firstMessageDeliveriesCap&&(Oe=J.firstMessageDeliveriesCap),Ie+=Oe*J.firstMessageDeliveriesWeight,K.meshMessageDeliveriesActive&&K.meshMessageDeliveries0&&s>t.topicScoreCap){s=t.topicScoreCap;const B=t.topicScoreCap/s;for(const K of o.values())K.p1w*=B,K.p2w*=B,K.p3w*=B,K.p3bw*=B,K.p4w*=B}let a=0,u=0,_=0;return a+=t.appSpecificScore(n)*t.appSpecificWeight,e.ips.forEach(B=>{if(t.IPColocationFactorWhitelist.has(B))return;const K=r.get(B),Z=K?K.size:0;if(Z>t.IPColocationFactorThreshold){const J=Z-t.IPColocationFactorThreshold;u+=J*J*t.IPColocationFactorWeight}}),_+=e.behaviourPenalty*e.behaviourPenalty*t.behaviourPenaltyWeight,s+=a+u+_,{byTopic:o,p5w:a,p6w:u,p7w:_,score:s}}function $E(n,e,t=(()=>!0)){const r=new Set;if(e<=0)return r;for(const i of n){if(r.size>=e)break;t(i)&&(r.add(i),n.delete(i))}return r}class u${constructor(e,t,r){this.rawStream=e,this.pushable=Mc({objectMode:!1}),this.closeController=new AbortController,this.maxBufferSize=r.maxBufferSize??1/0,Wn(vs(this.pushable,this.closeController.signal,{returnOnAbort:!0}),Os(),this.rawStream).catch(t)}get protocol(){return this.rawStream.stat.protocol}push(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(e)}close(){this.closeController.abort(),this.pushable.return(),this.rawStream.close()}}class l${constructor(e){this.rawStream=e,this.closeController=new AbortController,this.source=vs(Wn(this.rawStream,ps()),this.closeController.signal,{returnOnAbort:!0})}close(){this.closeController.abort(),this.rawStream.close()}}var _i=(()=>(function(n){n[n.started=0]="started",n[n.stopped=1]="stopped"}(_i||(_i={})),_i))();class YA extends Ei{constructor(e={}){super(),this.multicodecs=[LE,GA],this.peers=new Set,this.streamsInbound=new Map,this.streamsOutbound=new Map,this.outboundInflightQueue=Mc({objectMode:!0}),this.direct=new Set,this.floodsubPeers=new Set,this.acceptFromWhitelist=new Map,this.topics=new Map,this.subscriptions=new Set,this.mesh=new Map,this.fanout=new Map,this.fanoutLastpub=new Map,this.gossip=new Map,this.control=new Map,this.peerhave=new Map,this.iasked=new Map,this.backoff=new Map,this.outbound=new Map,this.topicValidators=new Map,this.heartbeatTicks=0,this.components=new ho,this.directPeerInitial=null,this.status={code:_i.stopped},this.heartbeatTimer=null,this.runHeartbeat=()=>{const r=this.metrics?.heartbeatDuration.startTimer();this.heartbeat().catch(i=>{this.log("Error running heartbeat",i)}).finally(()=>{if(r?.(),this.status.code===_i.started){clearTimeout(this.status.heartbeatTimeout);let i=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;i<.25*this.opts.heartbeatInterval&&(i+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,i)}})};const t={fallbackToFloodsub:!0,floodPublish:!0,doPX:!1,directPeers:[],D:6,Dlo:4,Dhi:12,Dscore:4,Dout:2,Dlazy:6,heartbeatInterval:1e3,fanoutTTL:6e4,mcacheLength:5,mcacheGossip:3,seenTTL:12e4,gossipsubIWantFollowupMs:3e3,prunePeers:16,pruneBackoff:6e4,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300,...e,scoreParams:HK(e.scoreParams),scoreThresholds:zK(e.scoreThresholds)};if(this.globalSignaturePolicy=t.globalSignaturePolicy??cp,t.fallbackToFloodsub&&this.multicodecs.push(jA),this.log=Gt(t.debugName??"libp2p:gossipsub"),this.opts=t,this.direct=new Set(t.directPeers.map(r=>r.id.toString())),this.seenCache=new UE({validityMs:t.seenTTL}),this.publishedMessageIds=new UE({validityMs:t.seenTTL}),e.msgIdFn)this.msgIdFn=e.msgIdFn;else switch(this.globalSignaturePolicy){case cp:this.msgIdFn=i$;break;case BE:this.msgIdFn=s$}if(e.fastMsgIdFn&&(this.fastMsgIdFn=e.fastMsgIdFn,this.fastMsgIdCache=new UE({validityMs:t.seenTTL})),this.msgIdToStrFn=e.msgIdToStrFn??BK,this.mcache=e.messageCache||new sK(t.mcacheGossip,t.mcacheLength,this.msgIdToStrFn),e.dataTransform&&(this.dataTransform=e.dataTransform),e.metricsRegister){if(!e.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");const r=Math.max(...Object.values(t.scoreParams.topics).map(s=>s.meshMessageDeliveriesWindow),1e3),i=function XK(n,e,t){return{protocolsEnabled:n.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:n.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:n.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:n.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEvents:n.gauge({name:"gossipsub_mesh_peer_inclusion_events_total",help:"Number of times we include peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),meshPeerChurnEvents:n.gauge({name:"gossipsub_peer_churn_events_total",help:"Number of times we remove peers in a topic mesh for different reasons",labelNames:["topic","reason"]}),peersPerProtocol:n.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:n.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:n.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),asyncValidationResult:n.gauge({name:"gossipsub_async_validation_result_total",help:"Message validation result for each topic",labelNames:["topic","acceptance"]}),asyncValidationMcacheHit:n.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),rpcRecvBytes:n.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:n.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:n.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:n.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:n.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:n.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:n.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:n.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:n.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcRecvNotAccepted:n.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:n.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:n.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:n.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:n.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:n.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:n.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:n.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:n.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:n.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:n.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeers:n.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),msgPublishPeersByGroup:n.gauge({name:"gossipsub_msg_publish_peers_by_group",help:"Total count of peers (by group) that we publish a msg to",labelNames:["topic","peerGroup"]}),msgPublishBytes:n.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgForwardCount:n.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:n.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:n.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedStatus:n.gauge({name:"gossipsub_msg_received_status_total",help:"Tracks distribution of recv msgs by duplicate, invalid, valid",labelNames:["topic","status"]}),msgReceivedInvalid:n.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["topic","error"]}),duplicateMsgDeliveryDelay:n.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*t.maxMeshMessageDeliveriesWindowSec,.5*t.maxMeshMessageDeliveriesWindowSec,1*t.maxMeshMessageDeliveriesWindowSec,2*t.maxMeshMessageDeliveriesWindowSec,4*t.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:n.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),scoreFnCalls:n.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:n.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:n.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:n.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:n.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores",labelNames:["topic","p"]}),scoreWeights:n.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:n.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:n.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:n.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*t.behaviourPenaltyThreshold,.5*t.behaviourPenaltyThreshold,1*t.behaviourPenaltyThreshold,2*t.behaviourPenaltyThreshold,4*t.behaviourPenaltyThreshold]}),ihaveRcvIgnored:n.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:n.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:n.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:n.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:n.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:n.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:n.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedPeers:n.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:n.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantPromiseDeliveryTime:n.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*t.gossipPromiseExpireSec,1*t.gossipPromiseExpireSec,2*t.gossipPromiseExpireSec,4*t.gossipPromiseExpireSec]}),cacheSize:n.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:n.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),topicStrToLabel:e,toTopic(r){return this.topicStrToLabel.get(r)??r},onJoin(r){this.topicSubscriptionStatus.set({topicStr:r},1),this.meshPeerCounts.set({topicStr:r},0)},onLeave(r){this.topicSubscriptionStatus.set({topicStr:r},0),this.meshPeerCounts.set({topicStr:r},0)},onAddToMesh(r,i,s){const o=this.toTopic(r);this.meshPeerInclusionEvents.inc({topic:o,reason:i},s)},onRemoveFromMesh(r,i,s){const o=this.toTopic(r);this.meshPeerChurnEvents.inc({topic:o,reason:i},s)},onReportValidationMcacheHit(r){this.asyncValidationMcacheHit.inc({hit:r?"hit":"miss"})},onReportValidation(r,i){const s=this.toTopic(r);this.asyncValidationResult.inc({topic:s,acceptance:i})},onScorePenalty(r){this.scoringPenalties.inc({penalty:r},1)},onIhaveRcv(r,i,s){const o=this.toTopic(r);this.ihaveRcvMsgids.inc({topic:o},i),this.ihaveRcvNotSeenMsgids.inc({topic:o},s)},onIwantRcv(r,i){for(const[s,o]of r){const a=this.toTopic(s);this.iwantRcvMsgids.inc({topic:a},o)}this.iwantRcvDonthaveMsgids.inc(i)},onForwardMsg(r,i){const s=this.toTopic(r);this.msgForwardCount.inc({topic:s},1),this.msgForwardPeers.inc({topic:s},i)},onPublishMsg(r,i,s,o){const a=this.toTopic(r);this.msgPublishCount.inc({topic:a},1),this.msgPublishBytes.inc({topic:a},s*o),this.msgPublishPeers.inc({topic:a},s),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"direct"},i.direct),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"floodsub"},i.floodsub),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"mesh"},i.mesh),this.msgPublishPeersByGroup.inc({topic:a,peerGroup:"fanout"},i.fanout)},onMsgRecvPreValidation(r){const i=this.toTopic(r);this.msgReceivedPreValidation.inc({topic:i},1)},onMsgRecvResult(r,i){const s=this.toTopic(r);this.msgReceivedStatus.inc({topic:s,status:i})},onMsgRecvInvalid(r,i){const s=this.toTopic(r);this.msgReceivedInvalid.inc({topic:s,error:i.reason===Ji.Error?i.error:i.reason},1)},onDuplicateMsgDelivery(r,i,s){if(this.duplicateMsgDeliveryDelay.observe(i/1e3),s){const o=this.toTopic(r);this.duplicateMsgLateDelivery.inc({topic:o},1)}},onRpcRecv(r,i){this.rpcRecvBytes.inc(i),this.rpcRecvCount.inc(1),r.subscriptions&&this.rpcRecvSubscription.inc(r.subscriptions.length),r.messages&&this.rpcRecvMessage.inc(r.messages.length),r.control&&(this.rpcRecvControl.inc(1),r.control.ihave&&this.rpcRecvIHave.inc(r.control.ihave.length),r.control.iwant&&this.rpcRecvIWant.inc(r.control.iwant.length),r.control.graft&&this.rpcRecvGraft.inc(r.control.graft.length),r.control.prune&&this.rpcRecvPrune.inc(r.control.prune.length))},onRpcSent(r,i){if(this.rpcSentBytes.inc(i),this.rpcSentCount.inc(1),r.subscriptions&&this.rpcSentSubscription.inc(r.subscriptions.length),r.messages&&this.rpcSentMessage.inc(r.messages.length),r.control){const s=r.control.ihave?.length??0,o=r.control.iwant?.length??0,a=r.control.graft?.length??0,u=r.control.prune?.length??0;s>0&&this.rpcSentIHave.inc(s),o>0&&this.rpcSentIWant.inc(o),a>0&&this.rpcSentGraft.inc(a),u>0&&this.rpcSentPrune.inc(u),(s>0||o>0||a>0||u>0)&&this.rpcSentControl.inc(1)}},registerScores(r,i){let s=0,o=0,a=0,u=0;for(const _ of r)_>=i.graylistThreshold&&s++,_>=i.publishThreshold&&o++,_>=i.gossipThreshold&&a++,_>=0&&u++;this.peersByScoreThreshold.set({threshold:Ua.graylist},s),this.peersByScoreThreshold.set({threshold:Ua.publish},o),this.peersByScoreThreshold.set({threshold:Ua.gossip},a),this.peersByScoreThreshold.set({threshold:Ua.mesh},u),this.score.set(r)},registerScoreWeights(r){for(const[i,s]of r.byTopic)this.scoreWeights.set({topic:i,p:"p1"},s.p1w),this.scoreWeights.set({topic:i,p:"p2"},s.p2w),this.scoreWeights.set({topic:i,p:"p3"},s.p3w),this.scoreWeights.set({topic:i,p:"p3b"},s.p3bw),this.scoreWeights.set({topic:i,p:"p4"},s.p4w);this.scoreWeights.set({p:"p5"},r.p5w),this.scoreWeights.set({p:"p6"},r.p6w),this.scoreWeights.set({p:"p7"},r.p7w)},registerScorePerMesh(r,i){const s=new Map;r.forEach((o,a)=>{const u=this.topicStrToLabel.get(a)??"unknown";let _=s.get(u);_||(_=new Set,s.set(u,_)),o.forEach(R=>_?.add(R))});for(const[o,a]of s){const u=[];a.forEach(_=>{u.push(i.get(_)??0)}),this.scorePerMesh.set({topic:o},u)}}}}(e.metricsRegister,e.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:t.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:r/1e3});i.mcacheSize.addCollect(()=>this.onScrapeMetrics(i));for(const s of this.multicodecs)i.protocolsEnabled.set({protocol:s},1);this.metrics=i}else this.metrics=null;this.gossipTracer=new ZK(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new QK(this.opts.scoreParams,this.metrics,{scoreCacheValidityMs:t.heartbeatInterval}),this.maxInboundStreams=e.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams}getPeers(){return[...this.peers.keys()].map(e=>fr(e))}isStarted(){return this.status.code===_i.started}init(e){var t=this;return j(function*(){t.components=e,t.score.init(e)})()}start(){var e=this;return j(function*(){if(e.isStarted())return;e.log("starting"),e.publishConfig=yield function FK(n,e){return FE.apply(this,arguments)}(e.globalSignaturePolicy,e.components.getPeerId()),e.outboundInflightQueue=Mc({objectMode:!0}),Wn(e.outboundInflightQueue,function(){var o=j(function*(a){var R,u=!1,_=!1;try{for(var B,N=Pt(a);u=!(B=yield N.next()).done;u=!1){const{peerId:K,connection:Z}=B.value;yield e.createOutboundStream(K,Z)}}catch(K){_=!0,R=K}finally{try{u&&null!=N.return&&(yield N.return())}finally{if(_)throw R}}});return function(a){return o.apply(this,arguments)}}()).catch(o=>e.log.error("outbound inflight queue error",o)),yield Promise.all(e.opts.directPeers.map(function(){var o=j(function*(a){yield e.components.getPeerStore().addressBook.add(a.id,a.addrs)});return function(a){return o.apply(this,arguments)}}()));const t=e.components.getRegistrar();yield Promise.all(e.multicodecs.map(o=>t.handle(o,e.onIncomingStream.bind(e),{maxInboundStreams:e.maxInboundStreams,maxOutboundStreams:e.maxOutboundStreams})));const r=function iK(n){return new rK(n)}({onConnect:e.onPeerConnected.bind(e),onDisconnect:e.onPeerDisconnected.bind(e)}),i=yield Promise.all(e.multicodecs.map(o=>t.register(o,r))),s=setTimeout(e.runHeartbeat,100);e.status={code:_i.started,registrarTopologyIds:i,heartbeatTimeout:s,hearbeatStartMs:Date.now()+100},e.score.start(),e.directPeerInitial=setTimeout(()=>{Promise.resolve().then(j(function*(){yield Promise.all(Array.from(e.direct).map(function(){var o=j(function*(a){return yield e.connect(a)});return function(a){return o.apply(this,arguments)}}()))})).catch(o=>{e.log(o)})},1e3),e.log("started")})()}stop(){var e=this;return j(function*(){if(e.log("stopping"),e.status.code!==_i.started)return;const{registrarTopologyIds:t}=e.status;e.status={code:_i.stopped};const r=e.components.getRegistrar();t.forEach(i=>r.unregister(i)),e.outboundInflightQueue.end();for(const i of e.streamsOutbound.values())i.close();e.streamsOutbound.clear();for(const i of e.streamsInbound.values())i.close();e.streamsInbound.clear(),e.peers.clear(),e.subscriptions.clear(),e.heartbeatTimer&&(e.heartbeatTimer.cancel(),e.heartbeatTimer=null),e.score.stop(),e.mesh.clear(),e.fanout.clear(),e.fanoutLastpub.clear(),e.gossip.clear(),e.control.clear(),e.peerhave.clear(),e.iasked.clear(),e.backoff.clear(),e.outbound.clear(),e.gossipTracer.clear(),e.seenCache.clear(),e.fastMsgIdCache&&e.fastMsgIdCache.clear(),e.directPeerInitial&&clearTimeout(e.directPeerInitial),e.log("stopped")})()}dumpPeerScoreStats(){return this.score.dumpPeerScoreStats()}onIncomingStream({stream:e,connection:t}){if(!this.isStarted())return;const r=t.remotePeer;this.addPeer(r,t.stat.direction),this.createInboundStream(r,e),this.outboundInflightQueue.push({peerId:r,connection:t})}onPeerConnected(e,t){!this.isStarted()||(this.addPeer(e,t.stat.direction),this.outboundInflightQueue.push({peerId:e,connection:t}))}onPeerDisconnected(e){this.log("connection ended %p",e),this.removePeer(e)}createOutboundStream(e,t){var r=this;return j(function*(){if(!r.isStarted())return;const i=e.toString();if(r.peers.has(i)&&!r.streamsOutbound.has(i))try{const s=new u$(yield t.newStream(r.multicodecs),a=>r.log.error("outbound pipe error",a),{maxBufferSize:r.opts.maxOutboundBufferSize});r.log("create outbound stream %p",e),r.streamsOutbound.set(i,s);const o=s.protocol;o===jA&&r.floodsubPeers.add(i),r.metrics?.peersPerProtocol.inc({protocol:o},1),r.subscriptions.size>0&&(r.log("send subscriptions to",i),r.sendSubscriptions(i,Array.from(r.subscriptions),!0))}catch(s){r.log.error("createOutboundStream error",s)}})()}createInboundStream(e,t){var r=this;return j(function*(){if(!r.isStarted())return;const i=e.toString();if(!r.peers.has(i))return;const s=r.streamsInbound.get(i);void 0!==s&&(r.log("replacing existing inbound steam %s",i),s.close()),r.log("create inbound stream %s",i);const o=new l$(t);r.streamsInbound.set(i,o),r.pipePeerReadStream(e,o.source).catch(a=>r.log(a))})()}addPeer(e,t){const r=e.toString();this.peers.has(r)||(this.log("new peer %p",e),this.peers.add(r),this.score.addPeer(r),this.outbound.has(r)||this.outbound.set(r,"outbound"===t))}removePeer(e){const t=e.toString();if(!this.peers.has(t))return;this.log("delete peer %p",e),this.peers.delete(t);const r=this.streamsOutbound.get(t),i=this.streamsInbound.get(t);r&&this.metrics?.peersPerProtocol.inc({protocol:r.protocol},-1),r?.close(),i?.close(),this.streamsOutbound.delete(t),this.streamsInbound.delete(t);for(const s of this.topics.values())s.delete(t);for(const[s,o]of this.mesh)!0===o.delete(t)&&this.metrics?.onRemoveFromMesh(s,Fa.Dc,1);for(const s of this.fanout.values())s.delete(t);this.floodsubPeers.delete(t),this.gossip.delete(t),this.control.delete(t),this.outbound.delete(t),this.score.removePeer(t),this.acceptFromWhitelist.delete(t)}get started(){return this.status.code===_i.started}getMeshPeers(e){const t=this.mesh.get(e);return t?Array.from(t):[]}getSubscribers(e){const t=this.topics.get(e);return(t?Array.from(t):[]).map(r=>fr(r))}getTopics(){return Array.from(this.subscriptions)}pipePeerReadStream(e,t){var r=this;return j(function*(){try{yield Wn(t,function(){var i=j(function*(s){var u,o=!1,a=!1;try{for(var R,_=Pt(s);o=!(R=yield _.next()).done;o=!1){const N=R.value;try{const B=N.subarray(),K=ap.decode(B);r.metrics?.onRpcRecv(K,B.length),r.opts.awaitRpcHandler?yield r.handleReceivedRpc(e,K):r.handleReceivedRpc(e,K).catch(Z=>r.log(Z))}catch(B){r.log(B)}}}catch(N){a=!0,u=N}finally{try{o&&null!=_.return&&(yield _.return())}finally{if(a)throw u}}});return function(s){return i.apply(this,arguments)}}())}catch(i){r.log.error(i),r.onPeerDisconnected(e)}})()}handleReceivedRpc(e,t){var r=this;return j(function*(){if(!r.acceptFrom(e.toString()))return r.log("received message from unacceptable peer %p",e),void r.metrics?.rpcRecvNotAccepted.inc();if(r.log("rpc from %p",e),t.subscriptions&&t.subscriptions.length>0&&(t.subscriptions.forEach(i=>{r.handleReceivedSubscription(e,i)}),r.dispatchEvent(new tn("subscription-change",{detail:{peerId:e,subscriptions:t.subscriptions.filter(i=>null!==i.topic).map(i=>({topic:i.topic??"",subscribe:Boolean(i.subscribe)}))}}))),t.messages)for(const i of t.messages){const s=r.handleReceivedMessage(e,i).catch(o=>r.log(o));r.opts.awaitRpcMessageHandler&&(yield s)}t.control&&(yield r.handleControlMessage(e.toString(),t.control))})()}handleReceivedSubscription(e,t){if(null==t.topic)return;this.log("subscription update from %p topic %s",e,t.topic);let r=this.topics.get(t.topic);null==r&&(r=new Set,this.topics.set(t.topic,r)),t.subscribe?r.add(e.toString()):r.delete(e.toString())}handleReceivedMessage(e,t){var r=()=>super.dispatchEvent,i=this;return j(function*(){i.metrics?.onMsgRecvPreValidation(t.topic);const s=yield i.validateReceivedMessage(e,t);switch(i.metrics?.onMsgRecvResult(t.topic,s.code),s.code){case es.duplicate:return i.score.duplicateMessage(e.toString(),s.msgIdStr,t.topic),void i.mcache.observeDuplicate(s.msgIdStr,e.toString());case es.invalid:if(s.msgIdStr){const o=s.msgIdStr;i.score.rejectMessage(e.toString(),o,t.topic,s.reason),i.gossipTracer.rejectMessage(o,s.reason)}else i.score.rejectInvalidMessage(e.toString(),t.topic);return void i.metrics?.onMsgRecvInvalid(t.topic,s);case es.valid:i.score.validateMessage(s.messageId.msgIdStr),i.gossipTracer.deliverMessage(s.messageId.msgIdStr),i.mcache.put(s.messageId,t,!i.opts.asyncValidation),i.subscriptions.has(t.topic)&&(!i.components.getPeerId().equals(e)||i.opts.emitSelf)&&(r().call(i,new tn("gossipsub:message",{detail:{propagationSource:e,msgId:s.messageId.msgIdStr,msg:s.msg}})),r().call(i,new tn("message",{detail:s.msg}))),i.opts.asyncValidation||i.forwardMessage(s.messageId.msgIdStr,t,e.toString())}})()}validateReceivedMessage(e,t){var r=this;return j(function*(){const i=r.fastMsgIdFn?.(t),s=i?r.fastMsgIdCache?.get(i):void 0;if(s)return{code:es.duplicate,msgIdStr:s};const o=yield function e$(n,e){return HE.apply(this,arguments)}(r.globalSignaturePolicy,t);if(!o.valid)return{code:es.invalid,reason:Ji.Error,error:o.error};const a=o.message;try{r.dataTransform&&(a.data=r.dataTransform.inboundTransform(t.topic,a.data))}catch(B){return r.log("Invalid message, transform failed",B),{code:es.invalid,reason:Ji.Error,error:li.TransformFailed}}const u=yield r.msgIdFn(a),_=r.msgIdToStrFn(u),R={msgId:u,msgIdStr:_};if(i&&r.fastMsgIdCache?.put(i,_),r.seenCache.has(_))return{code:es.duplicate,msgIdStr:_};r.seenCache.put(_);const N=r.topicValidators.get(t.topic);if(null!=N){let B;try{B=yield N(a.topic,a,e)}catch(K){const Z=K.code;"ERR_TOPIC_VALIDATOR_IGNORE"===Z&&(B=$s.Ignore),B="ERR_TOPIC_VALIDATOR_REJECT"===Z?$s.Reject:$s.Ignore}if(B!==$s.Accept)return{code:es.invalid,reason:WA(B),msgIdStr:_}}return{code:es.valid,messageId:R,msg:a}})()}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,r){this.sendRpc(e,{subscriptions:t.map(i=>({topic:i,subscribe:r})),messages:[]})}handleControlMessage(e,t){var r=this;return j(function*(){if(void 0===t)return;const i=t.ihave?r.handleIHave(e,t.ihave):[],s=t.iwant?r.handleIWant(e,t.iwant):[],o=t.graft?yield r.handleGraft(e,t.graft):[];t.prune&&(yield r.handlePrune(e,t.prune)),(i.length||s.length||o.length)&&r.sendRpc(e,bo(s,{iwant:i,prune:o}))})()}acceptFrom(e){if(this.direct.has(e))return!0;const t=Date.now(),r=this.acceptFromWhitelist.get(e);if(r&&r.messagesAccepted<128&&r.acceptUntil>=t)return r.messagesAccepted+=1,!0;const i=this.score.score(e);return i>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),i>=this.opts.scoreThresholds.graylistThreshold}handleIHave(e,t){if(!t.length)return[];const r=this.score.score(e);if(r10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,i),this.metrics?.ihaveRcvIgnored.inc({reason:vu.MaxIhave}),[];const s=this.iasked.get(e)??0;if(s>=gu)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,s),this.metrics?.ihaveRcvIgnored.inc({reason:vu.MaxIasked}),[];const o=new Map;if(t.forEach(({topicID:_,messageIDs:R})=>{if(!_||!R||!this.mesh.has(_))return;let N=0;R.forEach(B=>{const K=this.msgIdToStrFn(B);this.seenCache.has(K)||(o.set(K,B),N++)}),this.metrics?.onIhaveRcv(_,R.length,N)}),!o.size)return[];let a=o.size;a+s>gu&&(a=gu-s),this.log("IHAVE: Asking for %d out of %d messages from %s",a,o.size,e);let u=Array.from(o.values());return wo(u),u=u.slice(0,a),this.iasked.set(e,s+a),this.gossipTracer.addPromise(e,u),[{messageIDs:u}]}handleIWant(e,t){if(!t.length)return[];const r=this.score.score(e);if(r{a&&a.forEach(u=>{const _=this.msgIdToStrFn(u),R=this.mcache.getWithIWantCount(_,e);null!=R?(s.set(R.msg.topic,1+(s.get(R.msg.topic)??0)),R.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,u):i.set(_,R.msg)):o++})}),this.metrics?.onIwantRcv(s,o),i.size?(this.log("IWANT: Sending %d messages to %s",i.size,e),Array.from(i.values())):(this.log("IWANT: Could not provide any wanted messages to %s",e),[])}handleGraft(e,t){var r=this;return j(function*(){const i=[],s=r.score.score(e),o=Date.now();let a=r.opts.doPX;return t.forEach(({topicID:u})=>{if(!u)return;const _=r.mesh.get(u);if(!_)return void(a=!1);if(_.has(e))return;if(r.direct.has(e))return r.log("GRAFT: ignoring request from direct peer %s",e),i.push(u),void(a=!1);const R=r.backoff.get(u)?.get(e);return"number"==typeof R&&o=r.opts.Dhi&&!r.outbound.get(e)?(i.push(u),void r.addBackoff(e,u)):(r.log("GRAFT: Add mesh link from %s in %s",e,u),r.score.graft(e,u),_.add(e),void r.metrics?.onAddToMesh(u,_o.Subscribed,1))}),i.length?yield Promise.all(i.map(u=>r.makePrune(e,u,a))):[]})()}handlePrune(e,t){var r=this;return j(function*(){const i=r.score.score(e);for(const{topicID:s,backoff:o,peers:a}of t){if(null==s)continue;const u=r.mesh.get(s);if(!u)return;if(r.log("PRUNE: Remove mesh link to %s in %s",e,s),r.score.prune(e,s),u.has(e)&&(u.delete(e),r.metrics?.onRemoveFromMesh(s,Fa.Unsub,1)),"number"==typeof o&&o>0?r.doAddBackoff(e,s,1e3*o):r.addBackoff(e,s),a&&a.length){if(i{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e,mu.BrokenPromise)})}clearBackoff(){if(this.heartbeatTicks%15!=0)return;const e=Date.now();this.backoff.forEach((t,r)=>{t.forEach((i,s)=>{i{e.streamsOutbound.has(r)||t.push(r)}),yield Promise.all(t.map(function(){var r=j(function*(i){return yield e.connect(i)});return function(i){return r.apply(this,arguments)}}()))})()}pxConnect(e){var t=this;return j(function*(){e.length>t.opts.prunePeers&&(wo(e),e=e.slice(0,t.opts.prunePeers));const r=[];yield Promise.all(e.map(function(){var i=j(function*(s){if(!s.peerID)return;const o=Jc(s.peerID).toString();if(!t.peers.has(o)){if(!s.signedPeerRecord)return void r.push(o);try{const a=yield wi.openAndCertify(s.signedPeerRecord,"libp2p-peer-record"),u=a.peerId;if(!a.peerId.equals(o))return void t.log("bogus peer record obtained through px: peer ID %p doesn't match expected peer %p",u,o);if(!(yield t.components.getPeerStore().addressBook.consumePeerRecord(a)))return void t.log("bogus peer record obtained through px: could not add peer record to address book");r.push(o)}catch{t.log("bogus peer record obtained through px: invalid signature or not a peer record")}}});return function(s){return i.apply(this,arguments)}}())),r.length&&(yield Promise.all(r.map(function(){var i=j(function*(s){return yield t.connect(s)});return function(s){return i.apply(this,arguments)}}())))})()}connect(e){var t=this;return j(function*(){t.log("Initiating connection with %s",e);const r=fr(e),i=yield t.components.getConnectionManager().openConnection(r);for(const s of t.multicodecs)for(const o of t.components.getRegistrar().getTopologies(s))o.onConnect(r,i)})()}subscribe(e){if(this.status.code!==_i.started)throw new Error("Pubsub has not started");if(!this.subscriptions.has(e)){this.subscriptions.add(e);for(const t of this.peers.keys())this.sendSubscriptions(t,[e],!0)}this.join(e)}unsubscribe(e){if(this.status.code!==_i.started)throw new Error("Pubsub is not started");const t=this.subscriptions.delete(e);if(this.log("unsubscribe from %s - am subscribed %s",e,t),t)for(const r of this.peers.keys())this.sendSubscriptions(r,[e],!1);this.leave(e).catch(r=>{this.log(r)})}join(e){if(this.status.code!==_i.started)throw new Error("Gossipsub has not started");if(this.mesh.has(e))return;this.log("JOIN %s",e),this.metrics?.onJoin(e);const t=new Set,r=this.fanout.get(e);if(r&&(this.fanout.delete(e),this.fanoutLastpub.delete(e),r.forEach(i=>{!this.direct.has(i)&&this.score.score(i)>=0&&t.add(i)}),this.metrics?.onAddToMesh(e,_o.Fanout,t.size)),t.size!t.has(o)&&!this.direct.has(o)&&this.score.score(o)>=0).forEach(o=>{t.add(o)}),this.metrics?.onAddToMesh(e,_o.Random,t.size-i)}this.mesh.set(e,t),t.forEach(i=>{this.log("JOIN: Add mesh link to %s in %s",i,e),this.sendGraft(i,e)})}leave(e){var t=this;return j(function*(){if(t.status.code!==_i.started)throw new Error("Gossipsub has not started");t.log("LEAVE %s",e),t.metrics?.onLeave(e);const r=t.mesh.get(e);r&&(yield Promise.all(Array.from(r).map(function(){var i=j(function*(s){return t.log("LEAVE: Remove mesh link to %s in %s",s,e),yield t.sendPrune(s,e)});return function(s){return i.apply(this,arguments)}}())),t.mesh.delete(e))})()}selectPeersToForward(e,t,r){const i=new Set,s=this.topics.get(e);s&&(this.direct.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&i.add(a)}),this.floodsubPeers.forEach(a=>{s.has(a)&&t!==a&&!r?.has(a)&&this.score.score(a)>=this.opts.scoreThresholds.publishThreshold&&i.add(a)}));const o=this.mesh.get(e);return o&&o.size>0&&o.forEach(a=>{t!==a&&!r?.has(a)&&i.add(a)}),i}selectPeersToPublish(e){const t=new Set,r={direct:0,floodsub:0,mesh:0,fanout:0},i=this.topics.get(e);if(i)if(this.opts.floodPublish)i.forEach(s=>{this.direct.has(s)?(t.add(s),r.direct++):this.score.score(s)>=this.opts.scoreThresholds.publishThreshold&&(t.add(s),r.floodsub++)});else{this.direct.forEach(o=>{i.has(o)&&(t.add(o),r.direct++)}),this.floodsubPeers.forEach(o=>{i.has(o)&&this.score.score(o)>=this.opts.scoreThresholds.publishThreshold&&(t.add(o),r.floodsub++)});const s=this.mesh.get(e);if(s&&s.size>0)s.forEach(o=>{t.add(o),r.mesh++});else{const o=this.fanout.get(e);if(o&&o.size>0)o.forEach(a=>{t.add(a),r.fanout++});else{const a=this.getRandomGossipPeers(e,this.opts.D,u=>this.score.score(u)>=this.opts.scoreThresholds.publishThreshold);a.size>0&&(this.fanout.set(e,a),a.forEach(u=>{t.add(u),r.fanout++}))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:t,tosendCount:r}}forwardMessage(e,t,r,i){r&&this.score.deliverMessage(r,e,t.topic);const s=this.selectPeersToForward(t.topic,r,i),o=bo([t]);s.forEach(a=>{this.sendRpc(a,o)}),this.metrics?.onForwardMsg(t.topic,s.size)}publish(e,t){var r=()=>super.dispatchEvent,i=this;return j(function*(){const s=i.dataTransform?i.dataTransform.outboundTransform(e,t):t;if(null==i.publishConfig)throw Error("PublishError.Uninitialized");const{raw:o,msg:a}=yield function JK(n,e,t,r){return VE.apply(this,arguments)}(i.publishConfig,e,t,s),u=yield i.msgIdFn(a),_=i.msgIdToStrFn(u);if(i.seenCache.has(_))throw Error("PublishError.Duplicate");const{tosend:R,tosendCount:N}=i.selectPeersToPublish(e),B=!0===i.opts.emitSelf&&i.subscriptions.has(e);if(0===R.size&&!i.opts.allowPublishToZeroPeers&&!B)throw Error("PublishError.InsufficientPeers");i.seenCache.put(_),i.mcache.put({msgId:u,msgIdStr:_},o,!0),i.publishedMessageIds.put(_);const K=bo([o]);for(const Z of R)i.sendRpc(Z,K)||R.delete(Z);return i.metrics?.onPublishMsg(e,N,R.size,null!=o.data?o.data.length:0),B&&(R.add(i.components.getPeerId().toString()),r().call(i,new tn("gossipsub:message",{detail:{propagationSource:i.components.getPeerId(),msgId:_,msg:a}})),r().call(i,new tn("message",{detail:a}))),{recipients:Array.from(R.values()).map(Z=>fr(Z))}})()}reportMessageValidationResult(e,t,r){if(r===$s.Accept){const i=this.mcache.validate(e);if(this.metrics?.onReportValidationMcacheHit(null!==i),null!=i){const{message:s,originatingPeers:o}=i;this.score.deliverMessage(t.toString(),e,s.topic),this.forwardMessage(e,i.message,t.toString(),o),this.metrics?.onReportValidation(s.topic,r)}}else{const i=this.mcache.remove(e);if(this.metrics?.onReportValidationMcacheHit(null!==i),i){const s=WA(r),{message:o,originatingPeers:a}=i;this.score.rejectMessage(t.toString(),e,o.topic,s);for(const u of a)this.score.rejectMessage(u,e,o.topic,s);this.metrics?.onReportValidation(o.topic,r)}}}sendGraft(e,t){const i=bo([],{graft:[{topicID:t}]});this.sendRpc(e,i)}sendPrune(e,t){var r=this;return j(function*(){const s=bo([],{prune:[yield r.makePrune(e,t,r.opts.doPX)]});r.sendRpc(e,s)})()}sendRpc(e,t){const r=this.streamsOutbound.get(e);if(!r)return this.log(`Cannot send RPC to ${e} as there is no open stream to it available`),!1;const i=this.control.get(e);i&&(this.piggybackControl(e,t,i),this.control.delete(e));const s=this.gossip.get(e);s&&(this.piggybackGossip(e,t,s),this.gossip.delete(e));const o=ap.encode(t).finish();try{r.push(o)}catch(a){return this.log.error(`Cannot send rpc to ${e}`,a),i&&this.control.set(e,i),s&&this.gossip.set(e,s),!1}return this.metrics?.onRpcSent(t,o.length),!0}piggybackControl(e,t,r){const i=(r.graft||[]).filter(({topicID:o})=>(o&&this.mesh.get(o)||new Set).has(e)),s=(r.prune||[]).filter(({topicID:o})=>!(o&&this.mesh.get(o)||new Set).has(e));!i.length&&!s.length||(t.control?(t.control.graft=t.control.graft&&t.control.graft.concat(i),t.control.prune=t.control.prune&&t.control.prune.concat(s)):t.control={graft:i,prune:s,ihave:[],iwant:[]})}piggybackGossip(e,t,r){t.control||(t.control={ihave:[],iwant:[],graft:[],prune:[]}),t.control.ihave=r}sendGraftPrune(e,t,r){var i=this;return j(function*(){const s=i.opts.doPX;for(const[o,a]of e){const u=a.map(B=>({topicID:B}));let _=[];const R=t.get(o);R&&(_=yield Promise.all(R.map(function(){var B=j(function*(K){return yield i.makePrune(o,K,s&&!r.get(o))});return function(K){return B.apply(this,arguments)}}())),t.delete(o));const N=bo([],{graft:u,prune:_});i.sendRpc(o,N)}for(const[o,a]of t){const u=yield Promise.all(a.map(function(){var R=j(function*(N){return yield i.makePrune(o,N,s&&!r.get(o))});return function(N){return R.apply(this,arguments)}}())),_=bo([],{prune:u});i.sendRpc(o,_)}})()}emitGossip(e){const t=this.mcache.getGossipIDs(new Set(e.keys()));for(const[r,i]of e)this.doEmitGossip(r,i,t.get(r)??[])}doEmitGossip(e,t,r){if(!r.length||(wo(r),r.length>gu&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length),!t.size))return;let i=this.opts.Dlazy;const s=.25*t.size;let o=t;s>i&&(i=s),i>o.size?i=o.size:o=wo(Array.from(o)).slice(0,i),o.forEach(a=>{let u=r;r.length>gu&&(u=wo(u.slice()).slice(0,gu)),this.pushGossip(a,{topicID:e,messageIDs:u})})}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,bo([],{ihave:t}));for(const[e,t]of this.control.entries())this.control.delete(e),this.sendRpc(e,bo([],{graft:t.graft,prune:t.prune}))}pushGossip(e,t){this.log("Add gossip to %s",e);const r=this.gossip.get(e)||[];this.gossip.set(e,r.concat(t))}makePrune(e,t,r){var i=this;return j(function*(){if(i.score.prune(e,t),i.streamsOutbound.get(e).protocol===GA)return{topicID:t,peers:[]};const s=i.opts.pruneBackoff/1e3;if(!r)return{topicID:t,peers:[],backoff:s};const o=i.getRandomGossipPeers(t,i.opts.prunePeers,u=>u!==e&&i.score.score(u)>=0),a=yield Promise.all(Array.from(o).map(function(){var u=j(function*(_){const R=fr(_);return{peerID:R.toBytes(),signedPeerRecord:yield i.components.getPeerStore().addressBook.getRawEnvelope(R)}});return function(_){return u.apply(this,arguments)}}()));return{topicID:t,peers:a,backoff:s}})()}heartbeat(){var e=this;return j(function*(){const{D:t,Dlo:r,Dhi:i,Dscore:s,Dout:o,fanoutTTL:a}=e.opts;e.heartbeatTicks++;const u=new Map,_=J=>{let oe=u.get(J);return void 0===oe&&(oe=e.score.score(J),u.set(J,oe)),oe},R=new Map,N=new Map,B=new Map;e.clearBackoff(),e.peerhave.clear(),e.metrics?.cacheSize.set({cache:"iasked"},e.iasked.size),e.iasked.clear(),e.applyIwantPenalties(),e.heartbeatTicks%e.opts.directConnectTicks==0&&(yield e.directConnect()),e.fastMsgIdCache?.prune(),e.seenCache.prune(),e.gossipTracer.prune(),e.publishedMessageIds.prune();const K=new Map;e.mesh.forEach((J,oe)=>{const he=e.topics.get(oe),Ie=new Set,ue=new Set;if(K.set(oe,ue),he){const Oe=wo(Array.from(he)),bt=e.backoff.get(oe);for(const vt of Oe){const hn=e.streamsOutbound.get(vt);if(hn&&e.multicodecs.includes(hn.protocol)&&!J.has(vt)&&!e.direct.has(vt)){const Bn=_(vt);(!bt||!bt.has(vt))&&Bn>=0&&Ie.add(vt),Bn>=e.opts.scoreThresholds.gossipThreshold&&ue.add(vt)}}}const Re=(Oe,bt)=>{e.log("HEARTBEAT: Remove mesh link to %s in %s",Oe,oe),e.addBackoff(Oe,oe),J.delete(Oe),_(Oe)>=e.opts.scoreThresholds.gossipThreshold&&ue.add(Oe),e.metrics?.onRemoveFromMesh(oe,bt,1);const vt=N.get(Oe);vt?vt.push(oe):N.set(Oe,[oe])},ze=(Oe,bt)=>{e.log("HEARTBEAT: Add mesh link to %s in %s",Oe,oe),e.score.graft(Oe,oe),J.add(Oe),ue.delete(Oe),e.metrics?.onAddToMesh(oe,bt,1);const vt=R.get(Oe);vt?vt.push(oe):R.set(Oe,[oe])};if(J.forEach(Oe=>{const bt=_(Oe);bt<0&&(e.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",Oe,bt,oe),Re(Oe,Fa.BadScore),B.set(Oe,!0))}),J.size!0)}(Ie,t-J.size).forEach(vt=>{ze(vt,_o.NotEnough)}),J.size>i){let Oe=Array.from(J);Oe.sort((vt,hn)=>_(hn)-_(vt)),Oe=Oe.slice(0,s).concat(wo(Oe.slice(s)));let bt=0;if(Oe.slice(0,t).forEach(vt=>{e.outbound.get(vt)&&bt++}),bt{const cr=Oe[Bn];for(let Di=Bn;Di>0;Di--)Oe[Di]=Oe[Di-1];Oe[0]=cr};if(bt>0){let Bn=bt;for(let cr=1;cr0;cr++)e.outbound.get(Oe[cr])&&(vt(cr),Bn--)}let hn=t-bt;for(let Bn=t;Bn0;Bn++)e.outbound.get(Oe[Bn])&&(vt(Bn),hn--)}Oe.slice(t).forEach(vt=>{Re(vt,Fa.Excess)})}if(J.size>=r){let Oe=0;J.forEach(bt=>{e.outbound.get(bt)&&Oe++}),Oe!0===e.outbound.get(hn)).forEach(hn=>{ze(hn,_o.Outbound)})}if(e.heartbeatTicks%e.opts.opportunisticGraftTicks==0&&J.size>1){const Oe=Array.from(J).sort((hn,Bn)=>_(hn)-_(Bn)),bt=Math.floor(J.size/2),vt=_(Oe[bt]);if(vt_(cr)>vt);for(const cr of Bn)e.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",cr,oe),ze(cr,_o.Opportunistic)}}});const Z=Date.now();e.fanoutLastpub.forEach((J,oe)=>{J+a{const he=e.topics.get(oe);J.forEach(ze=>{(!he.has(ze)||_(ze)=e.opts.scoreThresholds.publishThreshold&&ue.push(Oe),vt>=e.opts.scoreThresholds.gossipThreshold&&Re.add(Oe)}}}J.size{J.add(Oe),Re?.delete(Oe)})}),e.emitGossip(K),yield e.sendGraftPrune(R,N,B),e.flush(),e.mcache.shift(),e.dispatchEvent(new tn("gossipsub:heartbeat"))})()}getRandomGossipPeers(e,t,r=(()=>!0)){const i=this.topics.get(e);if(!i)return new Set;let s=[];return i.forEach(o=>{const a=this.streamsOutbound.get(o);!a||this.multicodecs.includes(a.protocol)&&r(o)&&s.push(o)}),s=wo(s),t>0&&s.length>t&&(s=s.slice(0,t)),new Set(s)}onScrapeMetrics(e){e.mcacheSize.set(this.mcache.size),e.cacheSize.set({cache:"direct"},this.direct.size),e.cacheSize.set({cache:"seenCache"},this.seenCache.size),e.cacheSize.set({cache:"fastMsgIdCache"},this.fastMsgIdCache?.size??0),e.cacheSize.set({cache:"publishedMessageIds"},this.publishedMessageIds.size),e.cacheSize.set({cache:"mcache"},this.mcache.size),e.cacheSize.set({cache:"score"},this.score.size),e.cacheSize.set({cache:"gossipTracer.promises"},this.gossipTracer.size),e.cacheSize.set({cache:"gossipTracer.requests"},this.gossipTracer.requestMsByMsgSize),e.cacheSize.set({cache:"topics"},this.topics.size),e.cacheSize.set({cache:"subscriptions"},this.subscriptions.size),e.cacheSize.set({cache:"mesh"},this.mesh.size),e.cacheSize.set({cache:"fanout"},this.fanout.size),e.cacheSize.set({cache:"peers"},this.peers.size),e.cacheSize.set({cache:"streamsOutbound"},this.streamsOutbound.size),e.cacheSize.set({cache:"streamsInbound"},this.streamsInbound.size),e.cacheSize.set({cache:"acceptFromWhitelist"},this.acceptFromWhitelist.size),e.cacheSize.set({cache:"gossip"},this.gossip.size),e.cacheSize.set({cache:"control"},this.control.size),e.cacheSize.set({cache:"peerhave"},this.peerhave.size),e.cacheSize.set({cache:"outbound"},this.outbound.size);let t=0;for(const o of this.backoff.values())t+=o.size;e.cacheSize.set({cache:"backoff"},t);for(const[o,a]of this.topics)e.topicPeersCount.set({topicStr:o},a.size);for(const[o,a]of this.mesh)e.meshPeerCounts.set({topicStr:o},a.size);const r=[],i=new Map;e.behaviourPenalty.reset();for(const o of this.peers.keys()){const a=this.score.score(o);r.push(a),i.set(o,a),e.behaviourPenalty.observe(this.score.peerStats.get(o)?.behaviourPenalty??0)}e.registerScores(r,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,i);const s=function a$(n,e,t,r,i){const s={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(const o of n){const a=e.get(o);if(a){const u=o$(o,a,t,r,i);for(const[_,R]of u.byTopic){let N=s.byTopic.get(_);N||(N={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},s.byTopic.set(_,N)),N.p1w.push(R.p1w),N.p2w.push(R.p2w),N.p3w.push(R.p3w),N.p3bw.push(R.p3bw),N.p4w.push(R.p4w)}s.p5w.push(u.p5w),s.p6w.push(u.p6w),s.p7w.push(u.p7w),s.score.push(u.score)}else s.p5w.push(0),s.p6w.push(0),s.p7w.push(0),s.score.push(0)}return s}(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(s)}}YA.multicodec=LE;const jE=dr("waku:relay");class GE extends YA{constructor(e){super(e=Object.assign(e??{},{globalSignaturePolicy:up.StrictNoSign,fallbackToFloodsub:!1})),this.multicodecs=La,this.observers={},this.decryptionKeys=new Map,this.pubSubTopic=e?.pubSubTopic??"/waku/2/default-waku/proto",e?.decryptionKeys?.forEach(t=>{this.addDecryptionKey(t)})}start(){var e=()=>super.start,t=this;return j(function*(){yield e().call(t),t.subscribe(t.pubSubTopic)})()}send(e){var t=this;return j(function*(){const r=e.encode();yield t.publish(t.pubSubTopic,r)})()}addDecryptionKey(e,t){this.decryptionKeys.set(cu(e),t??{})}deleteDecryptionKey(e){this.decryptionKeys.delete(cu(e))}addObserver(e,t=[]){0===t.length?(this.observers[""]||(this.observers[""]=new Set),this.observers[""].add(e)):t.forEach(r=>{this.observers[r]||(this.observers[r]=new Set),this.observers[r].add(e)})}deleteObserver(e,t=[]){0===t.length?this.observers[""]&&this.observers[""].delete(e):t.forEach(r=>{this.observers[r]&&this.observers[r].delete(e)})}subscribe(e){this.addEventListener("gossipsub:message",t=>{if(t.detail.msg.topic===e){const r=Array.from(this.decryptionKeys).map(([i,{method:s,contentTopics:o}])=>({key:i,method:s,contentTopics:o}));jE(`Message received on ${e}`),oa.decode(t.detail.msg.data,r).then(i=>{i?(this.observers[""]&&this.observers[""].forEach(s=>{s(i)}),i.contentTopic&&this.observers[i.contentTopic]&&this.observers[i.contentTopic].forEach(s=>{s(i)})):jE("Failed to decode Waku Message")}).catch(i=>{jE("Failed to decode Waku Message",i)})}}),super.subscribe(e)}getMeshPeers(e){return super.getMeshPeers(e??this.pubSubTopic)}}function WE(){return WE=j(function*(n){const e=n?.libp2p??{},t=e.peerDiscovery??[];n?.defaultBootstrap&&(t.push(fp()),Object.assign(e,{peerDiscovery:t}));const r=yield dp(new GE(n),e);return new tK(n??{},r)}),WE.apply(this,arguments)}function fp(){return new hH(function gH(n=au.Prod,e=1){if(e<=0)return[];let t;switch(n){case au.Prod:t=dE_fleets["wakuv2.prod"]["waku-websocket"];break;case au.Test:t=dE_fleets["wakuv2.test"]["waku-websocket"];break;default:t=dE_fleets["wakuv2.prod"]["waku-websocket"]}return t=Object.values(t),t=t.map(r=>new yn(r)),TA(t,e)}())}function dp(n,e){return QE.apply(this,arguments)}function QE(){return QE=j(function*(n,e){return lH(Object.assign({transports:[new SV({filter:sT})],streamMuxers:[new hU],connectionEncryption:[new z5]},n?{pubsub:n}:{},e??{}))}),QE.apply(this,arguments)}GE.multicodec=La[0],GE.multicodec=La[La.length-1];function h$(n,e,t){"function"==typeof t&&(t={filter:t});const r=function d$(n,e,t){let r;const i=new Promise((s,o)=>{if(!((t={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...t}).count>=0)||t.count!==Number.POSITIVE_INFINITY&&!Number.isInteger(t.count))throw new TypeError("The `count` option should be at least 0 or more");const a=[e].flat(),u=[],{addListener:_,removeListener:R}=(n=>{const e=n.on||n.addListener||n.addEventListener,t=n.off||n.removeListener||n.removeEventListener;if(!e||!t)throw new TypeError("Emitter is not compatible");return{addListener:e.bind(n),removeListener:t.bind(n)}})(n),N=(...K)=>{const Z=t.multiArgs?K:K[0];t.filter&&!t.filter(Z)||(u.push(Z),t.count===u.length&&(r(),s(u)))},B=K=>{r(),o(K)};r=()=>{for(const K of a)R(K,N);for(const K of t.rejectionEvents)R(K,B)};for(const K of a)_(K,N);for(const K of t.rejectionEvents)_(K,B);t.resolveImmediately&&s(u)});if(i.cancel=r,"number"==typeof t.timeout){const s=tA(i,t.timeout);return s.cancel=r,s}return i}(n,e,t={...t,count:1,resolveImmediately:!1}),i=r.then(s=>s[0]);return i.cancel=r.cancel,i}const ZA=dr("waku:wait-for-remote-peer");function ZE(){return ZE=j(function*(n,e,t){if(e=e??v$(n),!n.isStarted())return Promise.reject("Waku node is not started");const r=[];if(e.includes(Jr.Relay)){if(!n.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");r.push(g$(n.relay))}if(e.includes(Jr.Store)){if(!n.store)throw new Error("Cannot wait for Store peer: protocol not mounted");r.push(XE(n.store,Object.values(sf)))}if(e.includes(Jr.LightPush)){if(!n.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");r.push(XE(n.lightPush,[nf]))}if(e.includes(Jr.Filter)){if(!n.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");r.push(XE(n.filter,[ka]))}t?yield m$(Promise.all(r),t,"Timed out waiting for a remote peer."):yield Promise.all(r)}),ZE.apply(this,arguments)}function XE(n,e){return JE.apply(this,arguments)}function JE(){return JE=j(function*(n,e){const t=yield n.peers();t.length?ZA(`${e} peer found: `,t[0].id.toString()):yield new Promise(r=>{const i=s=>{for(const o of e)if(s.detail.protocols.includes(o)){ZA("Resolving for",o,s.detail.protocols),n.libp2p.peerStore.removeEventListener("change:protocols",i),r();break}};n.libp2p.peerStore.addEventListener("change:protocols",i)})}),JE.apply(this,arguments)}function g$(n){return eb.apply(this,arguments)}function eb(){return eb=j(function*(n){let e=n.getMeshPeers();for(;0==e.length;)yield h$(n,"gossipsub:heartbeat"),e=n.getMeshPeers()}),eb.apply(this,arguments)}const y$=(n,e)=>new Promise((t,r)=>setTimeout(()=>r(e),n));function m$(n,e,t){return tb.apply(this,arguments)}function tb(){return tb=j(function*(n,e,t){yield Promise.race([n,y$(e,t)])}),tb.apply(this,arguments)}function v$(n){const e=[];return n.relay&&e.push(Jr.Relay),n.filter&&e.push(Jr.Filter),n.store&&e.push(Jr.Store),n.lightPush&&e.push(Jr.LightPush),e}let XA=(()=>{class n{constructor(){this.wakuSubject=new gr,this.waku=this.wakuSubject.asObservable(),this.wakuStatusSubject=new cB(""),this.wakuStatus=this.wakuStatusSubject.asObservable()}init(){(function f$(n){return WE.apply(this,arguments)})({defaultBootstrap:!0}).then(t=>{t.start().then(()=>{this.wakuSubject.next(t),this.wakuStatusSubject.next("Connecting..."),function p$(n,e,t){return ZE.apply(this,arguments)}(t).then(()=>{this.wakuStatusSubject.next("Connected")})})})}}return n.\u0275fac=function(t){return new(t||n)},n.\u0275prov=zn({token:n,factory:n.\u0275fac,providedIn:"root"}),n})();function b$(n,e){if(1&n&&(eo(0,"li")(1,"span"),Ic(2),to()()),2&n){const t=e.$implicit;zu(2),py("",t.timestamp," ",t.text,"")}}dr("waku:enr");const sb=new(C0().Type)("ChatMessage").add(new(C0().Field)("timestamp",1,"uint32")).add(new(C0().Field)("text",2,"string"));let w$=(()=>{class n{constructor(t){this.wakuService=t,this.contentTopic="/js-waku-examples/1/chat/proto",this.messages=[],this.messageCount=0,this.processIncomingMessages=r=>{if(!r.payload)return;const{text:i,timestamp:s}=sb.decode(r.payload),o=new Date;o.setTime(Number(s)),this.messages.push({text:i,timestamp:o})}}ngOnInit(){this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t}),this.wakuService.waku.subscribe(t=>{this.waku=t,this.waku.relay.addObserver(this.processIncomingMessages,[this.contentTopic])}),window.onbeforeunload=()=>this.ngOnDestroy()}ngOnDestroy(){this.waku.relay.deleteObserver(this.processIncomingMessages,[this.contentTopic])}sendMessage(){const t=(new Date).getTime(),r=sb.create({timestamp:t,text:`Here is a message #${this.messageCount}`}),i=sb.encode(r).finish();oa.fromBytes(i,this.contentTopic).then(s=>{this.waku.relay.send(s).then(()=>{console.log(`Message #${this.messageCount} sent`),this.messageCount+=1})})}}return n.\u0275fac=function(t){return new(t||n)(Zt(XA))},n.\u0275cmp=df({type:n,selectors:[["app-messages"]],decls:6,vars:2,consts:[[3,"disabled","click"],[1,"messages"],[4,"ngFor","ngForOf"]],template:function(t,r){1&t&&(eo(0,"button",0),ly("click",function(){return r.sendMessage()}),Ic(1,"Send Message"),to(),eo(2,"h2"),Ic(3,"Messages"),to(),eo(4,"ul",1),function y1(n,e,t,r,i,s,o,a){const u=Ue(),_=fn(),R=n+22,N=_.firstCreatePass?function WM(n,e,t,r,i,s,o,a,u){const _=e.consts,R=pc(e,n,4,o||null,Ao(_,a));Qg(e,t,R,Ao(_,u)),wf(e,R);const N=R.tViews=Yg(2,R,r,i,s,e.directiveRegistry,e.pipeRegistry,null,e.schemas,_);return null!==e.queries&&(e.queries.template(e,R),N.queries=e.queries.embeddedTView(R)),R}(R,_,u,e,t,r,i,s,o):_.data[R];Ts(N,!1);const B=u[11].createComment("");jf(_,u,B,N),jr(B,u),Xf(u,u[R]=X_(B,u,B,N)),mf(N)&&Wg(_,u,N),null!=o&&qg(u,N,a)}(5,b$,3,2,"li",2),to()),2&t&&(id("disabled","Connected"!==r.wakuStatus),zu(5),id("ngForOf",r.messages))},dependencies:[fC]}),n})(),_$=(()=>{class n{constructor(t){this.wakuService=t,this.title="relay-angular-chat"}ngOnInit(){this.wakuService.init(),this.wakuService.wakuStatus.subscribe(t=>{this.wakuStatus=t})}}return n.\u0275fac=function(t){return new(t||n)(Zt(XA))},n.\u0275cmp=df({type:n,selectors:[["app-root"]],decls:5,vars:2,template:function(t,r){1&t&&(eo(0,"h1"),Ic(1),to(),eo(2,"p"),Ic(3),to(),oy(4,"app-messages")),2&t&&(zu(1),hy(r.title),zu(2),od("Waku node's status: ",r.wakuStatus,""))},dependencies:[w$],styles:["h1[_ngcontent-%COMP%]{color:#369;font-family:Arial,Helvetica,sans-serif;font-size:250%}h2[_ngcontent-%COMP%], h3[_ngcontent-%COMP%]{color:#444;font-family:Arial,Helvetica,sans-serif;font-weight:lighter}body[_ngcontent-%COMP%]{margin:2em}body[_ngcontent-%COMP%], input[type=text][_ngcontent-%COMP%], button[_ngcontent-%COMP%]{color:#333;font-family:Cambria,Georgia,serif}*[_ngcontent-%COMP%]{font-family:Arial,Helvetica,sans-serif}"]}),n})(),D$=(()=>{class n{}return n.\u0275fac=function(t){return new(t||n)},n.\u0275mod=wu({type:n,bootstrap:[_$]}),n.\u0275inj=Ka({imports:[X4]}),n})();x(8583),function _L(){$S=!1}(),Z4().bootstrapModule(D$).catch(n=>console.error(n))},1280:Y=>{"use strict";Y.exports=function U(x,y){for(var l=new Array(arguments.length-1),g=0,w=2,m=!0;w{"use strict";var x=U;x.length=function(h){var c=h.length;if(!c)return 0;for(var f=0;--c%4>1&&"="===h.charAt(c);)++f;return Math.ceil(3*h.length)/4-f};for(var y=new Array(64),l=new Array(123),g=0;g<64;)l[y[g]=g<26?g+65:g<52?g+71:g<62?g-4:g-59|43]=g++;x.encode=function(h,c,f){for(var v,d=null,b=[],S=0,E=0;c>2],v=(3&p)<<4,E=1;break;case 1:b[S++]=y[v|p>>4],v=(15&p)<<2,E=2;break;case 2:b[S++]=y[v|p>>6],b[S++]=y[63&p],E=0}S>8191&&((d||(d=[])).push(String.fromCharCode.apply(String,b)),S=0)}return E&&(b[S++]=y[v],b[S++]=61,1===E&&(b[S++]=61)),d?(S&&d.push(String.fromCharCode.apply(String,b.slice(0,S))),d.join("")):String.fromCharCode.apply(String,b.slice(0,S))};var w="invalid encoding";x.decode=function(h,c,f){for(var S,d=f,b=0,E=0;E1)break;if(void 0===(v=l[v]))throw Error(w);switch(b){case 0:S=v,b=1;break;case 1:c[f++]=S<<2|(48&v)>>4,S=v,b=2;break;case 2:c[f++]=(15&S)<<4|(60&v)>>2,S=v,b=3;break;case 3:c[f++]=(3&S)<<6|v,b=0}}if(1===b)throw Error(w);return f-d},x.test=function(h){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(h)}},9749:Y=>{"use strict";function U(x,y){"string"==typeof x&&(y=x,x=void 0);var l=[];function g(m){if("string"!=typeof m){var h=w();if(U.verbose&&console.log("codegen: "+h),h="return "+h,m){for(var c=Object.keys(m),f=new Array(c.length+1),d=new Array(c.length),b=0;b{"use strict";function U(){this._listeners={}}Y.exports=U,U.prototype.on=function(y,l,g){return(this._listeners[y]||(this._listeners[y]=[])).push({fn:l,ctx:g||this}),this},U.prototype.off=function(y,l){if(void 0===y)this._listeners={};else if(void 0===l)this._listeners[y]=[];else for(var g=this._listeners[y],w=0;w{"use strict";Y.exports=w;var y=x(1280),g=x(716)("fs");function w(m,h,c){return"function"==typeof h?(c=h,h={}):h||(h={}),c?!h.xhr&&g&&g.readFile?g.readFile(m,function(d,b){return d&&typeof XMLHttpRequest<"u"?w.xhr(m,h,c):d?c(d):c(null,h.binary?b:b.toString("utf8"))}):w.xhr(m,h,c):y(w,this,m,h)}w.xhr=function(h,c,f){var d=new XMLHttpRequest;d.onreadystatechange=function(){if(4===d.readyState){if(0!==d.status&&200!==d.status)return f(Error("status "+d.status));if(c.binary){var S=d.response;if(!S){S=[];for(var E=0;E{"use strict";function U(w){return typeof Float32Array<"u"?function(){var m=new Float32Array([-0]),h=new Uint8Array(m.buffer),c=128===h[3];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3]}function d(E,v,p){m[0]=E,v[p]=h[3],v[p+1]=h[2],v[p+2]=h[1],v[p+3]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],m[0]}function S(E,v){return h[3]=E[v],h[2]=E[v+1],h[1]=E[v+2],h[0]=E[v+3],m[0]}w.writeFloatLE=c?f:d,w.writeFloatBE=c?d:f,w.readFloatLE=c?b:S,w.readFloatBE=c?S:b}():function(){function m(c,f,d,b){var S=f<0?1:0;if(S&&(f=-f),0===f)c(1/f>0?0:2147483648,d,b);else if(isNaN(f))c(2143289344,d,b);else if(f>34028234663852886e22)c((S<<31|2139095040)>>>0,d,b);else if(f<11754943508222875e-54)c((S<<31|Math.round(f/1401298464324817e-60))>>>0,d,b);else{var E=Math.floor(Math.log(f)/Math.LN2);c((S<<31|E+127<<23|8388607&Math.round(f*Math.pow(2,-E)*8388608))>>>0,d,b)}}function h(c,f,d){var b=c(f,d),S=2*(b>>31)+1,E=b>>>23&255,v=8388607&b;return 255===E?v?NaN:S*(1/0):0===E?1401298464324817e-60*S*v:S*Math.pow(2,E-150)*(v+8388608)}w.writeFloatLE=m.bind(null,x),w.writeFloatBE=m.bind(null,y),w.readFloatLE=h.bind(null,l),w.readFloatBE=h.bind(null,g)}(),typeof Float64Array<"u"?function(){var m=new Float64Array([-0]),h=new Uint8Array(m.buffer),c=128===h[7];function f(E,v,p){m[0]=E,v[p]=h[0],v[p+1]=h[1],v[p+2]=h[2],v[p+3]=h[3],v[p+4]=h[4],v[p+5]=h[5],v[p+6]=h[6],v[p+7]=h[7]}function d(E,v,p){m[0]=E,v[p]=h[7],v[p+1]=h[6],v[p+2]=h[5],v[p+3]=h[4],v[p+4]=h[3],v[p+5]=h[2],v[p+6]=h[1],v[p+7]=h[0]}function b(E,v){return h[0]=E[v],h[1]=E[v+1],h[2]=E[v+2],h[3]=E[v+3],h[4]=E[v+4],h[5]=E[v+5],h[6]=E[v+6],h[7]=E[v+7],m[0]}function S(E,v){return h[7]=E[v],h[6]=E[v+1],h[5]=E[v+2],h[4]=E[v+3],h[3]=E[v+4],h[2]=E[v+5],h[1]=E[v+6],h[0]=E[v+7],m[0]}w.writeDoubleLE=c?f:d,w.writeDoubleBE=c?d:f,w.readDoubleLE=c?b:S,w.readDoubleBE=c?S:b}():function(){function m(c,f,d,b,S,E){var v=b<0?1:0;if(v&&(b=-b),0===b)c(0,S,E+f),c(1/b>0?0:2147483648,S,E+d);else if(isNaN(b))c(0,S,E+f),c(2146959360,S,E+d);else if(b>17976931348623157e292)c(0,S,E+f),c((v<<31|2146435072)>>>0,S,E+d);else{var p;if(b<22250738585072014e-324)c((p=b/5e-324)>>>0,S,E+f),c((v<<31|p/4294967296)>>>0,S,E+d);else{var I=Math.floor(Math.log(b)/Math.LN2);1024===I&&(I=1023),c(4503599627370496*(p=b*Math.pow(2,-I))>>>0,S,E+f),c((v<<31|I+1023<<20|1048576*p&1048575)>>>0,S,E+d)}}}function h(c,f,d,b,S){var E=c(b,S+f),v=c(b,S+d),p=2*(v>>31)+1,I=v>>>20&2047,A=4294967296*(1048575&v)+E;return 2047===I?A?NaN:p*(1/0):0===I?5e-324*p*A:p*Math.pow(2,I-1075)*(A+4503599627370496)}w.writeDoubleLE=m.bind(null,x,0,4),w.writeDoubleBE=m.bind(null,y,4,0),w.readDoubleLE=h.bind(null,l,0,4),w.readDoubleBE=h.bind(null,g,4,0)}(),w}function x(w,m,h){m[h]=255&w,m[h+1]=w>>>8&255,m[h+2]=w>>>16&255,m[h+3]=w>>>24}function y(w,m,h){m[h]=w>>>24,m[h+1]=w>>>16&255,m[h+2]=w>>>8&255,m[h+3]=255&w}function l(w,m){return(w[m]|w[m+1]<<8|w[m+2]<<16|w[m+3]<<24)>>>0}function g(w,m){return(w[m]<<24|w[m+1]<<16|w[m+2]<<8|w[m+3])>>>0}Y.exports=U(U)},716:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(Y){}return null}module.exports=inquire},1311:(Y,U)=>{"use strict";var x=U,y=x.isAbsolute=function(w){return/^(?:\/|\w+:)/.test(w)},l=x.normalize=function(w){var m=(w=w.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),h=y(w),c="";h&&(c=m.shift()+"/");for(var f=0;f0&&".."!==m[f-1]?m.splice(--f,2):h?m.splice(f,1):++f:"."===m[f]?m.splice(f,1):++f;return c+m.join("/")};x.resolve=function(w,m,h){return h||(m=l(m)),y(m)?m:(h||(w=l(w)),(w=w.replace(/(?:\/|^)[^/]+$/,"")).length?l(w+"/"+m):m)}},4479:Y=>{"use strict";Y.exports=function U(x,y,l){var g=l||8192,w=g>>>1,m=null,h=g;return function(f){if(f<1||f>w)return x(f);h+f>g&&(m=x(g),h=0);var d=y.call(m,h,h+=f);return 7&h&&(h=1+(7|h)),d}}},7768:(Y,U)=>{"use strict";var x=U;x.length=function(l){for(var g=0,w=0,m=0;m191&&d<224?c[f++]=(31&d)<<6|63&l[g++]:d>239&&d<365?(d=((7&d)<<18|(63&l[g++])<<12|(63&l[g++])<<6|63&l[g++])-65536,c[f++]=55296+(d>>10),c[f++]=56320+(1023&d)):c[f++]=(15&d)<<12|(63&l[g++])<<6|63&l[g++],f>8191&&((h||(h=[])).push(String.fromCharCode.apply(String,c)),f=0);return h?(f&&h.push(String.fromCharCode.apply(String,c.slice(0,f))),h.join("")):String.fromCharCode.apply(String,c.slice(0,f))},x.write=function(l,g,w){for(var h,c,m=w,f=0;f>6|192,g[w++]=63&h|128):55296==(64512&h)&&56320==(64512&(c=l.charCodeAt(f+1)))?(++f,g[w++]=(h=65536+((1023&h)<<10)+(1023&c))>>18|240,g[w++]=h>>12&63|128,g[w++]=h>>6&63|128,g[w++]=63&h|128):(g[w++]=h>>12|224,g[w++]=h>>6&63|128,g[w++]=63&h|128);return w-m}},4502:(Y,U,x)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(8046);function h(X,q,ne){return void 0===q&&(q=new Uint8Array(2)),void 0===ne&&(ne=0),q[ne+0]=X>>>8,q[ne+1]=X>>>0,q}function c(X,q,ne){return void 0===q&&(q=new Uint8Array(2)),void 0===ne&&(ne=0),q[ne+0]=X>>>0,q[ne+1]=X>>>8,q}function f(X,q){return void 0===q&&(q=0),X[q]<<24|X[q+1]<<16|X[q+2]<<8|X[q+3]}function d(X,q){return void 0===q&&(q=0),(X[q]<<24|X[q+1]<<16|X[q+2]<<8|X[q+3])>>>0}function b(X,q){return void 0===q&&(q=0),X[q+3]<<24|X[q+2]<<16|X[q+1]<<8|X[q]}function S(X,q){return void 0===q&&(q=0),(X[q+3]<<24|X[q+2]<<16|X[q+1]<<8|X[q])>>>0}function E(X,q,ne){return void 0===q&&(q=new Uint8Array(4)),void 0===ne&&(ne=0),q[ne+0]=X>>>24,q[ne+1]=X>>>16,q[ne+2]=X>>>8,q[ne+3]=X>>>0,q}function v(X,q,ne){return void 0===q&&(q=new Uint8Array(4)),void 0===ne&&(ne=0),q[ne+0]=X>>>0,q[ne+1]=X>>>8,q[ne+2]=X>>>16,q[ne+3]=X>>>24,q}function D(X,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),E(X/4294967296>>>0,q,ne),E(X>>>0,q,ne+4),q}function T(X,q,ne){return void 0===q&&(q=new Uint8Array(8)),void 0===ne&&(ne=0),v(X>>>0,q,ne),v(X/4294967296>>>0,q,ne+4),q}U.readInt16BE=function l(X,q){return void 0===q&&(q=0),(X[q+0]<<8|X[q+1])<<16>>16},U.readUint16BE=function g(X,q){return void 0===q&&(q=0),(X[q+0]<<8|X[q+1])>>>0},U.readInt16LE=function w(X,q){return void 0===q&&(q=0),(X[q+1]<<8|X[q])<<16>>16},U.readUint16LE=function m(X,q){return void 0===q&&(q=0),(X[q+1]<<8|X[q])>>>0},U.writeUint16BE=h,U.writeInt16BE=h,U.writeUint16LE=c,U.writeInt16LE=c,U.readInt32BE=f,U.readUint32BE=d,U.readInt32LE=b,U.readUint32LE=S,U.writeUint32BE=E,U.writeInt32BE=E,U.writeUint32LE=v,U.writeInt32LE=v,U.readInt64BE=function p(X,q){void 0===q&&(q=0);var ne=f(X,q),se=f(X,q+4);return 4294967296*ne+se-4294967296*(se>>31)},U.readUint64BE=function I(X,q){return void 0===q&&(q=0),4294967296*d(X,q)+d(X,q+4)},U.readInt64LE=function A(X,q){void 0===q&&(q=0);var ne=b(X,q);return 4294967296*b(X,q+4)+ne-4294967296*(ne>>31)},U.readUint64LE=function P(X,q){void 0===q&&(q=0);var ne=S(X,q);return 4294967296*S(X,q+4)+ne},U.writeUint64BE=D,U.writeInt64BE=D,U.writeUint64LE=T,U.writeInt64LE=T,U.readUintBE=function M(X,q,ne){if(void 0===ne&&(ne=0),X%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(X/8>q.length-ne)throw new Error("readUintBE: array is too short for the given bitLength");for(var se=0,de=1,pe=X/8+ne-1;pe>=ne;pe--)se+=q[pe]*de,de*=256;return se},U.readUintLE=function k(X,q,ne){if(void 0===ne&&(ne=0),X%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(X/8>q.length-ne)throw new Error("readUintLE: array is too short for the given bitLength");for(var se=0,de=1,pe=ne;pe=se;pe--)ne[pe]=q/de&255,de*=256;return ne},U.writeUintLE=function G(X,q,ne,se){if(void 0===ne&&(ne=new Uint8Array(X/8)),void 0===se&&(se=0),X%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!y.isSafeInteger(q))throw new Error("writeUintLE value must be an integer");for(var de=1,pe=se;pe{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(4502),l=x(9815);function w(f,d,b){for(var S=1634760805,E=857760878,v=2036477234,p=1797285236,I=b[3]<<24|b[2]<<16|b[1]<<8|b[0],A=b[7]<<24|b[6]<<16|b[5]<<8|b[4],P=b[11]<<24|b[10]<<16|b[9]<<8|b[8],D=b[15]<<24|b[14]<<16|b[13]<<8|b[12],T=b[19]<<24|b[18]<<16|b[17]<<8|b[16],M=b[23]<<24|b[22]<<16|b[21]<<8|b[20],k=b[27]<<24|b[26]<<16|b[25]<<8|b[24],F=b[31]<<24|b[30]<<16|b[29]<<8|b[28],G=d[3]<<24|d[2]<<16|d[1]<<8|d[0],C=d[7]<<24|d[6]<<16|d[5]<<8|d[4],O=d[11]<<24|d[10]<<16|d[9]<<8|d[8],V=d[15]<<24|d[14]<<16|d[13]<<8|d[12],L=S,$=E,re=v,z=p,te=I,X=A,q=P,ne=D,se=T,de=M,pe=k,Le=F,Se=G,Pe=C,be=O,$e=V,H=0;H<20;H+=2)te=(te^=se=se+(Se=(Se^=L=L+te|0)>>>16|Se<<16)|0)>>>20|te<<12,X=(X^=de=de+(Pe=(Pe^=$=$+X|0)>>>16|Pe<<16)|0)>>>20|X<<12,q=(q^=pe=pe+(be=(be^=re=re+q|0)>>>16|be<<16)|0)>>>20|q<<12,ne=(ne^=Le=Le+($e=($e^=z=z+ne|0)>>>16|$e<<16)|0)>>>20|ne<<12,q=(q^=pe=pe+(be=(be^=re=re+q|0)>>>24|be<<8)|0)>>>25|q<<7,ne=(ne^=Le=Le+($e=($e^=z=z+ne|0)>>>24|$e<<8)|0)>>>25|ne<<7,X=(X^=de=de+(Pe=(Pe^=$=$+X|0)>>>24|Pe<<8)|0)>>>25|X<<7,te=(te^=se=se+(Se=(Se^=L=L+te|0)>>>24|Se<<8)|0)>>>25|te<<7,X=(X^=pe=pe+($e=($e^=L=L+X|0)>>>16|$e<<16)|0)>>>20|X<<12,q=(q^=Le=Le+(Se=(Se^=$=$+q|0)>>>16|Se<<16)|0)>>>20|q<<12,ne=(ne^=se=se+(Pe=(Pe^=re=re+ne|0)>>>16|Pe<<16)|0)>>>20|ne<<12,te=(te^=de=de+(be=(be^=z=z+te|0)>>>16|be<<16)|0)>>>20|te<<12,ne=(ne^=se=se+(Pe=(Pe^=re=re+ne|0)>>>24|Pe<<8)|0)>>>25|ne<<7,te=(te^=de=de+(be=(be^=z=z+te|0)>>>24|be<<8)|0)>>>25|te<<7,q=(q^=Le=Le+(Se=(Se^=$=$+q|0)>>>24|Se<<8)|0)>>>25|q<<7,X=(X^=pe=pe+($e=($e^=L=L+X|0)>>>24|$e<<8)|0)>>>25|X<<7;y.writeUint32LE(L+S|0,f,0),y.writeUint32LE($+E|0,f,4),y.writeUint32LE(re+v|0,f,8),y.writeUint32LE(z+p|0,f,12),y.writeUint32LE(te+I|0,f,16),y.writeUint32LE(X+A|0,f,20),y.writeUint32LE(q+P|0,f,24),y.writeUint32LE(ne+D|0,f,28),y.writeUint32LE(se+T|0,f,32),y.writeUint32LE(de+M|0,f,36),y.writeUint32LE(pe+k|0,f,40),y.writeUint32LE(Le+F|0,f,44),y.writeUint32LE(Se+G|0,f,48),y.writeUint32LE(Pe+C|0,f,52),y.writeUint32LE(be+O|0,f,56),y.writeUint32LE($e+V|0,f,60)}function m(f,d,b,S,E){if(void 0===E&&(E=0),32!==f.length)throw new Error("ChaCha: key size must be 32 bytes");if(S.length>>=8,d++;if(S>0)throw new Error("ChaCha: counter overflow")}U.streamXOR=m,U.stream=function h(f,d,b,S){return void 0===S&&(S=0),l.wipe(b),m(f,d,b,b,S)}},5876:(Y,U,x)=>{"use strict";var l=x(4484),g=x(314),w=x(9815),m=x(4502),h=x(9976);U.Cv=32,U.WH=12,U.pg=16;var c=new Uint8Array(16),f=function(){function d(b){if(this.nonceLength=U.WH,this.tagLength=U.pg,b.length!==U.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(b)}return d.prototype.seal=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var p=new Uint8Array(16);p.set(b,p.length-b.length);var I=new Uint8Array(32);l.stream(this._key,p,I,4);var P,A=S.length+this.tagLength;if(v){if(v.length!==A)throw new Error("ChaCha20Poly1305: incorrect destination length");P=v}else P=new Uint8Array(A);return l.streamXOR(this._key,p,S,P,4),this._authenticate(P.subarray(P.length-this.tagLength,P.length),I,P.subarray(0,P.length-this.tagLength),E),w.wipe(p),P},d.prototype.open=function(b,S,E,v){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(S.length0&&p.update(c.subarray(v.length%16))),p.update(E),E.length%16>0&&p.update(c.subarray(E.length%16));var I=new Uint8Array(8);v&&m.writeUint64LE(v.length,I),p.update(I),m.writeUint64LE(E.length,I),p.update(I);for(var A=p.digest(),P=0;P{"use strict";function l(w,m){if(w.length!==m.length)return 0;for(var h=0,c=0;c>>8}Object.defineProperty(U,"__esModule",{value:!0}),U.select=function x(w,m,h){return~(w-1)&m|w-1&h},U.lessOrEqual=function y(w,m){return(0|w)-(0|m)-1>>>31&1},U.compare=l,U.equal=function g(w,m){return 0!==w.length&&0!==m.length&&0!==l(w,m)}},5571:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.isSerializableHash=function x(y){return typeof y.saveState<"u"&&typeof y.restoreState<"u"&&typeof y.cleanSavedState<"u"}},5705:(Y,U,x)=>{"use strict";var l=x(4193),g=x(9815),w=function(){function m(h,c,f,d){void 0===f&&(f=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=h,this._info=d;var b=l.hmac(this._hash,f,c);this._hmac=new l.HMAC(h,b),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return m.prototype._fillBuffer=function(){this._counter[0]++;var h=this._counter[0];if(0===h)throw new Error("hkdf: cannot expand more");this._hmac.reset(),h>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},m.prototype.expand=function(h){for(var c=new Uint8Array(h),f=0;f{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(5571),l=x(9976),g=x(9815),w=function(){function h(c,f){this._finished=!1,this._inner=new c,this._outer=new c,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var d=new Uint8Array(this.blockSize);f.length>this.blockSize?this._inner.update(f).finish(d).clean():d.set(f);for(var b=0;b{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.mul=Math.imul||function x(h,c){var d=65535&h,S=65535&c;return d*S+((h>>>16&65535)*S+d*(c>>>16&65535)<<16>>>0)|0},U.add=function y(h,c){return h+c|0},U.sub=function l(h,c){return h-c|0},U.rotl=function g(h,c){return h<>>32-c},U.rotr=function w(h,c){return h<<32-c|h>>>c},U.isInteger=Number.isInteger||function m(h){return"number"==typeof h&&isFinite(h)&&Math.floor(h)===h},U.MAX_SAFE_INTEGER=9007199254740991,U.isSafeInteger=function(h){return U.isInteger(h)&&h>=-U.MAX_SAFE_INTEGER&&h<=U.MAX_SAFE_INTEGER}},314:(Y,U,x)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});var y=x(9976),l=x(9815);U.DIGEST_LENGTH=16;var g=function(){function h(c){this.digestLength=U.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var f=c[0]|c[1]<<8;this._r[0]=8191&f;var d=c[2]|c[3]<<8;this._r[1]=8191&(f>>>13|d<<3);var b=c[4]|c[5]<<8;this._r[2]=7939&(d>>>10|b<<6);var S=c[6]|c[7]<<8;this._r[3]=8191&(b>>>7|S<<9);var E=c[8]|c[9]<<8;this._r[4]=255&(S>>>4|E<<12),this._r[5]=E>>>1&8190;var v=c[10]|c[11]<<8;this._r[6]=8191&(E>>>14|v<<2);var p=c[12]|c[13]<<8;this._r[7]=8065&(v>>>11|p<<5);var I=c[14]|c[15]<<8;this._r[8]=8191&(p>>>8|I<<8),this._r[9]=I>>>5&127,this._pad[0]=c[16]|c[17]<<8,this._pad[1]=c[18]|c[19]<<8,this._pad[2]=c[20]|c[21]<<8,this._pad[3]=c[22]|c[23]<<8,this._pad[4]=c[24]|c[25]<<8,this._pad[5]=c[26]|c[27]<<8,this._pad[6]=c[28]|c[29]<<8,this._pad[7]=c[30]|c[31]<<8}return h.prototype._blocks=function(c,f,d){for(var b=this._fin?0:2048,S=this._h[0],E=this._h[1],v=this._h[2],p=this._h[3],I=this._h[4],A=this._h[5],P=this._h[6],D=this._h[7],T=this._h[8],M=this._h[9],k=this._r[0],F=this._r[1],G=this._r[2],C=this._r[3],O=this._r[4],V=this._r[5],L=this._r[6],$=this._r[7],re=this._r[8],z=this._r[9];d>=16;){var te=c[f+0]|c[f+1]<<8,X=c[f+2]|c[f+3]<<8,q=c[f+4]|c[f+5]<<8,ne=c[f+6]|c[f+7]<<8,se=c[f+8]|c[f+9]<<8,de=c[f+10]|c[f+11]<<8,pe=c[f+12]|c[f+13]<<8,Le=c[f+14]|c[f+15]<<8,Se=0,Pe=Se;Pe+=(S+=8191&te)*k,Pe+=(E+=8191&(te>>>13|X<<3))*(5*z),Pe+=(v+=8191&(X>>>10|q<<6))*(5*re),Pe+=(p+=8191&(q>>>7|ne<<9))*(5*$),Se=(Pe+=(I+=8191&(ne>>>4|se<<12))*(5*L))>>>13,Pe&=8191,Pe+=(A+=se>>>1&8191)*(5*V),Pe+=(P+=8191&(se>>>14|de<<2))*(5*O),Pe+=(D+=8191&(de>>>11|pe<<5))*(5*C),Pe+=(T+=8191&(pe>>>8|Le<<8))*(5*G);var be=Se+=(Pe+=(M+=Le>>>5|b)*(5*F))>>>13;be+=S*F,be+=E*k,be+=v*(5*z),be+=p*(5*re),Se=(be+=I*(5*$))>>>13,be&=8191,be+=A*(5*L),be+=P*(5*V),be+=D*(5*O),be+=T*(5*C),Se+=(be+=M*(5*G))>>>13,be&=8191;var $e=Se;$e+=S*G,$e+=E*F,$e+=v*k,$e+=p*(5*z),Se=($e+=I*(5*re))>>>13,$e&=8191,$e+=A*(5*$),$e+=P*(5*L),$e+=D*(5*V),$e+=T*(5*O);var H=Se+=($e+=M*(5*C))>>>13;H+=S*C,H+=E*G,H+=v*F,H+=p*k,Se=(H+=I*(5*z))>>>13,H&=8191,H+=A*(5*re),H+=P*(5*$),H+=D*(5*L),H+=T*(5*V);var Ee=Se+=(H+=M*(5*O))>>>13;Ee+=S*O,Ee+=E*C,Ee+=v*G,Ee+=p*F,Se=(Ee+=I*k)>>>13,Ee&=8191,Ee+=A*(5*z),Ee+=P*(5*re),Ee+=D*(5*$),Ee+=T*(5*L);var Te=Se+=(Ee+=M*(5*V))>>>13;Te+=S*V,Te+=E*O,Te+=v*C,Te+=p*G,Se=(Te+=I*F)>>>13,Te&=8191,Te+=A*k,Te+=P*(5*z),Te+=D*(5*re),Te+=T*(5*$);var xe=Se+=(Te+=M*(5*L))>>>13;xe+=S*L,xe+=E*V,xe+=v*O,xe+=p*C,Se=(xe+=I*G)>>>13,xe&=8191,xe+=A*F,xe+=P*k,xe+=D*(5*z),xe+=T*(5*re);var He=Se+=(xe+=M*(5*$))>>>13;He+=S*$,He+=E*L,He+=v*V,He+=p*O,Se=(He+=I*C)>>>13,He&=8191,He+=A*G,He+=P*F,He+=D*k,He+=T*(5*z);var We=Se+=(He+=M*(5*re))>>>13;We+=S*re,We+=E*$,We+=v*L,We+=p*V,Se=(We+=I*O)>>>13,We&=8191,We+=A*C,We+=P*G,We+=D*F,We+=T*k;var Je=Se+=(We+=M*(5*z))>>>13;Je+=S*z,Je+=E*re,Je+=v*$,Je+=p*L,Se=(Je+=I*V)>>>13,Je&=8191,Je+=A*O,Je+=P*C,Je+=D*G,Je+=T*F,S=Pe=8191&(Se=(Se=((Se+=(Je+=M*k)>>>13)<<2)+Se|0)+(Pe&=8191)|0),E=be+=Se>>>=13,v=$e&=8191,p=H&=8191,I=Ee&=8191,A=Te&=8191,P=xe&=8191,D=He&=8191,T=We&=8191,M=Je&=8191,f+=16,d-=16}this._h[0]=S,this._h[1]=E,this._h[2]=v,this._h[3]=p,this._h[4]=I,this._h[5]=A,this._h[6]=P,this._h[7]=D,this._h[8]=T,this._h[9]=M},h.prototype.finish=function(c,f){void 0===f&&(f=0);var b,S,E,v,d=new Uint16Array(10);if(this._leftover){for(v=this._leftover,this._buffer[v++]=1;v<16;v++)this._buffer[v]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(b=this._h[1]>>>13,this._h[1]&=8191,v=2;v<10;v++)this._h[v]+=b,b=this._h[v]>>>13,this._h[v]&=8191;for(this._h[0]+=5*b,b=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=b,b=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=b,d[0]=this._h[0]+5,b=d[0]>>>13,d[0]&=8191,v=1;v<10;v++)d[v]=this._h[v]+b,b=d[v]>>>13,d[v]&=8191;for(d[9]-=8192,S=(1^b)-1,v=0;v<10;v++)d[v]&=S;for(S=~S,v=0;v<10;v++)this._h[v]=this._h[v]&S|d[v];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),this._h[0]=65535&(E=this._h[0]+this._pad[0]),v=1;v<8;v++)this._h[v]=65535&(E=(this._h[v]+this._pad[v]|0)+(E>>>16)|0);return c[f+0]=this._h[0]>>>0,c[f+1]=this._h[0]>>>8,c[f+2]=this._h[1]>>>0,c[f+3]=this._h[1]>>>8,c[f+4]=this._h[2]>>>0,c[f+5]=this._h[2]>>>8,c[f+6]=this._h[3]>>>0,c[f+7]=this._h[3]>>>8,c[f+8]=this._h[4]>>>0,c[f+9]=this._h[4]>>>8,c[f+10]=this._h[5]>>>0,c[f+11]=this._h[5]>>>8,c[f+12]=this._h[6]>>>0,c[f+13]=this._h[6]>>>8,c[f+14]=this._h[7]>>>0,c[f+15]=this._h[7]>>>8,this._finished=!0,this},h.prototype.update=function(c){var b,f=0,d=c.length;if(this._leftover){(b=16-this._leftover)>d&&(b=d);for(var S=0;S=16&&(this._blocks(c,f,b=d-d%16),f+=b,d-=b),d){for(S=0;S{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.randomStringForEntropy=U.randomString=U.randomUint32=U.randomBytes=U.defaultRandomSource=void 0;const y=x(9753),l=x(4502),g=x(9815);function w(d,b=U.defaultRandomSource){return b.randomBytes(d)}U.defaultRandomSource=new y.SystemRandomSource,U.randomBytes=w,U.randomUint32=function m(d=U.defaultRandomSource){const b=w(4,d),S=(0,l.readUint32LE)(b);return(0,g.wipe)(b),S};const h="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(d,b=h,S=U.defaultRandomSource){if(b.length<2)throw new Error("randomString charset is too short");if(b.length>256)throw new Error("randomString charset is too long");let E="";const v=b.length,p=256-256%v;for(;d>0;){const I=w(Math.ceil(256*d/p),S);for(let A=0;A0;A++){const P=I[A];P{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.BrowserRandomSource=void 0,U.BrowserRandomSource=class y{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const g=typeof self<"u"?self.crypto||self.msCrypto:null;g&&void 0!==g.getRandomValues&&(this._crypto=g,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(g){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const w=new Uint8Array(g);for(let m=0;m{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.NodeRandomSource=void 0;const y=x(9815);U.NodeRandomSource=class l{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const w=x(5883);w&&w.randomBytes&&(this._crypto=w,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(w){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let m=this._crypto.randomBytes(w);if(m.length!==w)throw new Error("NodeRandomSource: got fewer bytes than requested");const h=new Uint8Array(w);for(let c=0;c{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.SystemRandomSource=void 0;const y=x(7170),l=x(1382);U.SystemRandomSource=class g{constructor(){return this.isAvailable=!1,this.name="",this._source=new y.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new l.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(m){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(m)}}},893:(Y,U,x)=>{"use strict";var l=x(4502),g=x(9815);U.k=32,U.cn=64;var w=function(){function f(){this.digestLength=U.k,this.blockSize=U.cn,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){g.wipe(this._buffer),g.wipe(this._temp),this.reset()},f.prototype.update=function(d,b){if(void 0===b&&(b=d.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var S=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=d[S++],b--;this._bufferLength===this.blockSize&&(h(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(S=h(this._temp,this._state,d,S,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=d[S++],b--;return this},f.prototype.finish=function(d){if(!this._finished){var b=this._bytesHashed,S=this._bufferLength,E=b/536870912|0,v=b<<3,p=b%64<56?64:128;this._buffer[S]=128;for(var I=S+1;I0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(d){return this._state.set(d.state),this._bufferLength=d.bufferLength,d.buffer&&this._buffer.set(d.buffer),this._bytesHashed=d.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(d){g.wipe(d.state),d.buffer&&g.wipe(d.buffer),d.bufferLength=0,d.bytesHashed=0},f}();U.mE=w;var m=new Int32Array([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]);function h(f,d,b,S,E){for(;E>=64;){for(var v=d[0],p=d[1],I=d[2],A=d[3],P=d[4],D=d[5],T=d[6],M=d[7],k=0;k<16;k++)f[k]=l.readUint32BE(b,S+4*k);for(k=16;k<64;k++){var G=f[k-2];f[k]=((C=(G>>>17|G<<15)^(G>>>19|G<<13)^G>>>10)+f[k-7]|0)+((O=((G=f[k-15])>>>7|G<<25)^(G>>>18|G<<14)^G>>>3)+f[k-16]|0)}for(k=0;k<64;k++){var C=(((P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7))+(P&D^~P&T)|0)+(M+(m[k]+f[k]|0)|0)|0,O=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&p^v&I^p&I)|0;M=T,T=D,D=P,P=A+C|0,A=I,I=p,p=v,v=C+O|0}d[0]+=v,d[1]+=p,d[2]+=I,d[3]+=A,d[4]+=P,d[5]+=D,d[6]+=T,d[7]+=M,S+=64,E-=64}return S}U.vp=function c(f){var d=new w;d.update(f);var b=d.digest();return d.clean(),b}},9815:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0}),U.wipe=function x(y){for(var l=0;l{"use strict";U.gi=U.Au=U._w=U.KS=U.kz=void 0;const l=x(5784),g=x(9815);function w(k){const F=new Float64Array(16);if(k)for(let G=0;G=0;--ne){const se=G[ne>>>3]>>>(7&ne)&1;f(O,V,se),f(L,$,se),S(re,O,L),E(O,O,L),S(L,V,$),E(V,V,$),p($,re),p(z,O),v(O,L,O),v(L,V,re),S(re,O,L),E(O,O,L),p(V,O),E(L,$,z),v(O,L,h),S(O,O,$),v(L,L,O),v(O,$,z),v($,V,C),p(V,re),f(O,V,se),f(L,$,se)}for(let ne=0;ne<16;ne++)C[ne+16]=O[ne],C[ne+32]=L[ne],C[ne+48]=V[ne],C[ne+64]=$[ne];const te=C.subarray(32),X=C.subarray(16);(function I(k,F){const G=w();for(let C=0;C<16;C++)G[C]=F[C];for(let C=253;C>=0;C--)p(G,G),2!==C&&4!==C&&v(G,G,F);for(let C=0;C<16;C++)k[C]=G[C]})(te,te),v(X,X,te);const q=new Uint8Array(32);return function d(k,F){const G=w(),C=w();for(let O=0;O<16;O++)C[O]=F[O];c(C),c(C),c(C);for(let O=0;O<2;O++){G[0]=C[0]-65517;for(let L=1;L<15;L++)G[L]=C[L]-65535-(G[L-1]>>16&1),G[L-1]&=65535;G[15]=C[15]-32767-(G[14]>>16&1);const V=G[15]>>16&1;G[14]&=65535,f(C,G,1-V)}for(let O=0;O<16;O++)k[2*O]=255&C[O],k[2*O+1]=C[O]>>8}(q,X),q}function P(k){return A(k,m)}function D(k){if(k.length!==U.KS)throw new Error(`x25519: seed must be ${U.KS} bytes`);const F=new Uint8Array(k);return{publicKey:P(F),secretKey:F}}U._w=D,U.Au=function T(k){const F=(0,l.randomBytes)(32,k),G=D(F);return(0,g.wipe)(F),G},U.gi=function M(k,F,G=!1){if(k.length!==U.kz)throw new Error("X25519: incorrect secret key length");if(F.length!==U.kz)throw new Error("X25519: incorrect public key length");const C=A(k,F);if(G){let O=0;for(let V=0;V{function U(x){const y=new globalThis.AbortController;function l(){y.abort();for(const g of x)!g||!g.removeEventListener||g.removeEventListener("abort",l)}for(const g of x)if(g&&g.addEventListener){if(g.aborted){l();break}g.addEventListener("abort",l)}return y.signal}Y.exports=U,Y.exports.anySignal=U},3210:Y=>{var U=1e3,x=60*U,y=60*x,l=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Y.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*l;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=l?f(d,b,l,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=U?f(d,b,U,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=l?Math.round(d/l)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=U?Math.round(d/U)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},1455:(Y,U,x)=>{U.formatArgs=function l(c){if(c[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+c[0]+(this.useColors?"%c ":" ")+"+"+Y.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;c.splice(1,0,f,"color: inherit");let d=0,b=0;c[0].replace(/%[a-zA-Z%]/g,S=>{"%%"!==S&&(d++,"%c"===S&&(b=d))}),c.splice(b,0,f)},U.save=function g(c){try{c?U.storage.setItem("debug",c):U.storage.removeItem("debug")}catch{}},U.load=function w(){let c;try{c=U.storage.getItem("debug")}catch{}return!c&&typeof process<"u"&&"env"in process&&(c=process.env.DEBUG),c},U.useColors=function y(){return!(!(typeof window<"u"&&window.process)||"renderer"!==window.process.type&&!window.process.__nwjs)||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},U.storage=function m(){try{return localStorage}catch{}}(),U.destroy=(()=>{let c=!1;return()=>{c||(c=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),U.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],U.log=console.debug||console.log||(()=>{}),Y.exports=x(3283)(U);const{formatters:h}=Y.exports;h.j=function(c){try{return JSON.stringify(c)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}},3283:(Y,U,x)=>{Y.exports=function y(l){function w(E){let v,I,A,p=null;function P(...D){if(!P.enabled)return;const T=P,M=Number(new Date);T.diff=M-(v||M),T.prev=v,T.curr=M,v=M,D[0]=w.coerce(D[0]),"string"!=typeof D[0]&&D.unshift("%O");let F=0;D[0]=D[0].replace(/%([a-zA-Z%])/g,(C,O)=>{if("%%"===C)return"%";F++;const V=w.formatters[O];return"function"==typeof V&&(C=V.call(T,D[F]),D.splice(F,1),F--),C}),w.formatArgs.call(T,D),(T.log||w.log).apply(T,D)}return P.namespace=E,P.useColors=w.useColors(),P.color=w.selectColor(E),P.extend=m,P.destroy=w.destroy,Object.defineProperty(P,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==p?p:(I!==w.namespaces&&(I=w.namespaces,A=w.enabled(E)),A),set:D=>{p=D}}),"function"==typeof w.init&&w.init(P),P}function m(E,v){const p=w(this.namespace+(typeof v>"u"?":":v)+E);return p.log=this.log,p}function d(E){return E.toString().substring(2,E.toString().length-2).replace(/\.\*\?$/,"*")}return w.debug=w,w.default=w,w.coerce=function b(E){return E instanceof Error?E.stack||E.message:E},w.disable=function c(){const E=[...w.names.map(d),...w.skips.map(d).map(v=>"-"+v)].join(",");return w.enable(""),E},w.enable=function h(E){let v;w.save(E),w.namespaces=E,w.names=[],w.skips=[];const p=("string"==typeof E?E:"").split(/[\s,]+/),I=p.length;for(v=0;v{w[E]=l[E]}),w.names=[],w.skips=[],w.formatters={},w.selectColor=function g(E){let v=0;for(let p=0;p{"use strict";function U(x,l){l=l||{},this._head=0,this._tail=0,this._capacity=l.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(x)&&this._fromArray(x)}U.prototype.peekAt=function(y){var l=y;if(l===(0|l)){var g=this.size();if(!(l>=g||l<-g))return l<0&&(l+=g),this._list[l=this._head+l&this._capacityMask]}},U.prototype.get=function(y){return this.peekAt(y)},U.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},U.prototype.peekFront=function(){return this.peek()},U.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(U.prototype,"length",{get:function(){return this.size()}}),U.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),l}},U.prototype.push=function(y){if(void 0===y)return this.size();var l=this._tail;return this._list[l]=y,this._tail=l+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&y<=l>>>2&&this._shrinkArray(),g}},U.prototype.removeOne=function(y){var l=y;if(l===(0|l)&&this._head!==this._tail){var g=this.size(),w=this._list.length;if(!(l>=g||l<-g)){l<0&&(l+=g);var h,m=this._list[l=this._head+l&this._capacityMask];if(y0;h--)this._list[l]=this._list[l=l-1+w&this._capacityMask];this._list[l]=void 0,this._head=this._head+1+w&this._capacityMask}else{for(h=g-1-y;h>0;h--)this._list[l]=this._list[l=l+1+w&this._capacityMask];this._list[l]=void 0,this._tail=this._tail-1+w&this._capacityMask}return m}}},U.prototype.remove=function(y,l){var w,g=y,m=l;if(g===(0|g)&&this._head!==this._tail){var h=this.size(),c=this._list.length;if(!(g>=h||g<-h||l<1)){if(g<0&&(g+=h),1===l||!l)return(w=new Array(1))[0]=this.removeOne(g),w;if(0===g&&g+l>=h)return w=this.toArray(),this.clear(),w;var f;for(g+l>h&&(l=h-g),w=new Array(l),f=0;f0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(0===y){for(this._head=this._head+l+c&this._capacityMask,f=l-1;f>0;f--)this._list[g=g+1+c&this._capacityMask]=void 0;return w}if(g0;f--)this.unshift(this._list[g=g-1+c&this._capacityMask]);for(g=this._head-1+c&this._capacityMask;m>0;)this._list[g=g-1+c&this._capacityMask]=void 0,m--;y<0&&(this._tail=g)}else{for(this._tail=g,g=g+l+c&this._capacityMask,f=h-(l+y);f>0;f--)this.push(this._list[g++]);for(g=this._tail;m>0;)this._list[g=g+1+c&this._capacityMask]=void 0,m--}return this._head<2&&this._tail>1e4&&this._tail<=c>>>2&&this._shrinkArray(),w}}},U.prototype.splice=function(y,l){var g=y;if(g===(0|g)){var w=this.size();if(g<0&&(g+=w),!(g>w)){if(arguments.length>2){var m,h,c,f=arguments.length,d=this._list.length,b=2;if(!w||g0&&(this._head=this._head+g+d&this._capacityMask)):(c=this.remove(g,l),this._head=this._head+g+d&this._capacityMask);f>b;)this.unshift(arguments[--f]);for(m=g;m>0;m--)this.unshift(h[m-1])}else{var S=(h=new Array(w-(g+l))).length;for(m=0;mthis._tail){for(m=this._head;m>>=1,this._capacityMask>>>=1},Y.exports=U},2535:Y=>{"use strict";function U(y,l){for(const g in l)Object.defineProperty(y,g,{value:l[g],enumerable:!0,configurable:!0});return y}Y.exports=function x(y,l,g){if(!y||"string"==typeof y)throw new TypeError("Please pass an Error to err-code");g||(g={}),"object"==typeof l&&(g=l,l=""),l&&(g.code=l);try{return U(y,g)}catch{g.message=y.message,g.stack=y.stack;const m=function(){};return m.prototype=Object.create(Object.getPrototypeOf(y)),U(new m,g)}}},3676:(Y,U,x)=>{"use strict";const l=x(649);U.zN=l.EventIterator},649:(Y,U)=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});class x{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(g){if(this.isStopped)return;const w={value:g,done:!1};if(this.pullQueue.length){const m=this.pullQueue.shift();m&&m.resolve(w)}else this.pushQueue.push(Promise.resolve(w)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const g of this.pullQueue)g.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(g){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const w of this.pullQueue)w.reject(g);this.pullQueue.length=0}else{const w=Promise.reject(g);w.catch(()=>{}),this.pushQueue.push(w)}}remove(){Promise.resolve().then(()=>{this.removeCallback&&this.removeCallback()})}[Symbol.asyncIterator](){return{next:g=>{const w=this.pushQueue.shift();return w?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),w):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise((m,h)=>{this.pullQueue.push({resolve:m,reject:h})})},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class y{constructor(g,{highWaterMark:w=100,lowWaterMark:m=1}={}){const h=new x;h.highWaterMark=w,h.lowWaterMark=m,h.removeCallback=g({push:c=>h.push(c),stop:()=>h.stop(),fail:c=>h.fail(c),on:(c,f)=>{h.eventHandlers[c]=f}})||(()=>{}),this[Symbol.asyncIterator]=()=>h[Symbol.asyncIterator](),Object.freeze(this)}}U.EventIterator=y,U.default=y},2005:Y=>{"use strict";var U=Object.prototype.hasOwnProperty,x="~";function y(){}function l(h,c,f){this.fn=h,this.context=c,this.once=f||!1}function g(h,c,f,d,b){if("function"!=typeof f)throw new TypeError("The listener must be a function");var S=new l(f,d||h,b),E=x?x+c:c;return h._events[E]?h._events[E].fn?h._events[E]=[h._events[E],S]:h._events[E].push(S):(h._events[E]=S,h._eventsCount++),h}function w(h,c){0==--h._eventsCount?h._events=new y:delete h._events[c]}function m(){this._events=new y,this._eventsCount=0}Object.create&&(y.prototype=Object.create(null),(new y).__proto__||(x=!1)),m.prototype.eventNames=function(){var f,d,c=[];if(0===this._eventsCount)return c;for(d in f=this._events)U.call(f,d)&&c.push(x?d.slice(1):d);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(f)):c},m.prototype.listeners=function(c){var d=this._events[x?x+c:c];if(!d)return[];if(d.fn)return[d.fn];for(var b=0,S=d.length,E=new Array(S);b{"use strict";var y,U="object"==typeof Reflect?Reflect:null,x=U&&"function"==typeof U.apply?U.apply:function(M,k,F){return Function.prototype.apply.call(M,k,F)};y=U&&"function"==typeof U.ownKeys?U.ownKeys:Object.getOwnPropertySymbols?function(M){return Object.getOwnPropertyNames(M).concat(Object.getOwnPropertySymbols(M))}:function(M){return Object.getOwnPropertyNames(M)};var g=Number.isNaN||function(M){return M!=M};function w(){w.init.call(this)}Y.exports=w,Y.exports.once=function A(T,M){return new Promise(function(k,F){function G(O){T.removeListener(M,C),F(O)}function C(){"function"==typeof T.removeListener&&T.removeListener("error",G),k([].slice.call(arguments))}D(T,M,C,{once:!0}),"error"!==M&&function P(T,M,k){"function"==typeof T.on&&D(T,"error",M,k)}(T,G,{once:!0})})},w.EventEmitter=w,w.prototype._events=void 0,w.prototype._eventsCount=0,w.prototype._maxListeners=void 0;var m=10;function h(T){if("function"!=typeof T)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof T)}function c(T){return void 0===T._maxListeners?w.defaultMaxListeners:T._maxListeners}function f(T,M,k,F){var G,C,O;if(h(k),void 0===(C=T._events)?(C=T._events=Object.create(null),T._eventsCount=0):(void 0!==C.newListener&&(T.emit("newListener",M,k.listener?k.listener:k),C=T._events),O=C[M]),void 0===O)O=C[M]=k,++T._eventsCount;else if("function"==typeof O?O=C[M]=F?[k,O]:[O,k]:F?O.unshift(k):O.push(k),(G=c(T))>0&&O.length>G&&!O.warned){O.warned=!0;var V=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(M)+" listeners added. Use emitter.setMaxListeners() to increase limit");V.name="MaxListenersExceededWarning",V.emitter=T,V.type=M,V.count=O.length,function l(T){console&&console.warn&&console.warn(T)}(V)}return T}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function b(T,M,k){var F={fired:!1,wrapFn:void 0,target:T,type:M,listener:k},G=d.bind(F);return G.listener=k,F.wrapFn=G,G}function S(T,M,k){var F=T._events;if(void 0===F)return[];var G=F[M];return void 0===G?[]:"function"==typeof G?k?[G.listener||G]:[G]:k?function I(T){for(var M=new Array(T.length),k=0;k0&&(O=k[0]),O instanceof Error)throw O;var V=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw V.context=O,V}var L=C[M];if(void 0===L)return!1;if("function"==typeof L)x(L,this,k);else{var $=L.length,re=v(L,$);for(F=0;F<$;++F)x(re[F],this,k)}return!0},w.prototype.on=w.prototype.addListener=function(M,k){return f(this,M,k,!1)},w.prototype.prependListener=function(M,k){return f(this,M,k,!0)},w.prototype.once=function(M,k){return h(k),this.on(M,b(this,M,k)),this},w.prototype.prependOnceListener=function(M,k){return h(k),this.prependListener(M,b(this,M,k)),this},w.prototype.off=w.prototype.removeListener=function(M,k){var F,G,C,O,V;if(h(k),void 0===(G=this._events))return this;if(void 0===(F=G[M]))return this;if(F===k||F.listener===k)0==--this._eventsCount?this._events=Object.create(null):(delete G[M],G.removeListener&&this.emit("removeListener",M,F.listener||k));else if("function"!=typeof F){for(C=-1,O=F.length-1;O>=0;O--)if(F[O]===k||F[O].listener===k){V=F[O].listener,C=O;break}if(C<0)return this;0===C?F.shift():function p(T,M){for(;M+1=0;G--)this.removeListener(M,k[G]);return this},w.prototype.listeners=function(M){return S(this,M,!0)},w.prototype.rawListeners=function(M){return S(this,M,!1)},w.listenerCount=function(T,M){return"function"==typeof T.listenerCount?T.listenerCount(M):E.call(T,M)},w.prototype.listenerCount=E,w.prototype.eventNames=function(){return this._eventsCount>0?y(this._events):[]}},3111:Y=>{Y.exports=class{constructor(x){if(!(x>0)||0!=(x-1&x))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(x),this.mask=x-1,this.top=0,this.btm=0,this.next=null}push(x){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=x,this.top=this.top+1&this.mask,!0)}shift(){const x=this.buffer[this.btm];if(void 0!==x)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,x}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},1159:(Y,U,x)=>{const y=x(3111);Y.exports=class{constructor(g){this.hwm=g||16,this.head=new y(this.hwm),this.tail=this.head}push(g){this.head.push(g)||(this.head=this.head.next=new y(2*this.head.buffer.length),this.head.push(g))}shift(){const g=this.tail.shift();if(void 0===g&&this.tail.next){const w=this.tail.next;return this.tail.next=null,this.tail=w,this.tail.shift()}return g}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}},5550:Y=>{Y.exports=function(U){if(!U)throw Error("hashlru must have a max value, of type number, greater than 0");var x=0,y=Object.create(null),l=Object.create(null);function g(w,m){y[w]=m,++x>=U&&(x=0,l=y,y=Object.create(null))}return{has:function(w){return void 0!==y[w]||void 0!==l[w]},remove:function(w){void 0!==y[w]&&(y[w]=void 0),void 0!==l[w]&&(l[w]=void 0)},get:function(w){var m=y[w];return void 0!==m?m:void 0!==(m=l[w])?(g(w,m),m):void 0},set:function(w,m){void 0!==y[w]?y[w]=m:g(w,m)},clear:function(){y=Object.create(null),l=Object.create(null)}}}},4066:Y=>{"use strict";const U="[a-fA-F\\d:]",x=f=>f&&f.includeBoundaries?`(?:(?<=\\s|^)(?=${U})|(?<=${U})(?=\\s|$))`:"",y="(?: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}",l="[a-fA-F\\d]{1,4}",g=`\n(?:\n(?:${l}:){7}(?:${l}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:${l}:){6}(?:${y}|:${l}|:)| // 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\n(?:${l}:){5}(?::${y}|(?::${l}){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\n(?:${l}:){4}(?:(?::${l}){0,1}:${y}|(?::${l}){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\n(?:${l}:){3}(?:(?::${l}){0,2}:${y}|(?::${l}){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\n(?:${l}:){2}(?:(?::${l}){0,3}:${y}|(?::${l}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:${l}:){1}(?:(?::${l}){0,4}:${y}|(?::${l}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::${l}){0,5}:${y}|(?::${l}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n`.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),w=new RegExp(`(?:^${y}$)|(?:^${g}$)`),m=new RegExp(`^${y}$`),h=new RegExp(`^${g}$`),c=f=>f&&f.exact?w:new RegExp(`(?:${x(f)}${y}${x(f)})|(?:${x(f)}${g}${x(f)})`,"g");c.v4=f=>f&&f.exact?m:new RegExp(`${x(f)}${y}${x(f)}`,"g"),c.v6=f=>f&&f.exact?h:new RegExp(`${x(f)}${g}${x(f)}`,"g"),Y.exports=c},1396:function(Y){!function(U){"use strict";const x="(0?\\d+|0x[a-f0-9]+)",y={fourOctet:new RegExp(`^${x}\\.${x}\\.${x}\\.${x}$`,"i"),threeOctet:new RegExp(`^${x}\\.${x}\\.${x}$`,"i"),twoOctet:new RegExp(`^${x}\\.${x}$`,"i"),longValue:new RegExp(`^${x}$`,"i")},l=new RegExp("^0[0-7]+$","i"),g=new RegExp("^0x[a-f0-9]+$","i"),w="%[0-9a-z]{1,}",m="(?:[0-9a-f]+::?)+",h={zoneIndex:new RegExp(w,"i"),native:new RegExp(`^(::)?(${m})?([0-9a-f]+)?(::)?(${w})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${x}\\.${x}\\.${x}\\.${x}(${w})?)$`,"i"),transitional:new RegExp(`^((?:${m})|(?:::)(?:${m})?)${x}\\.${x}\\.${x}\\.${x}(${w})?$`,"i")};function c(E,v){if(E.indexOf("::")!==E.lastIndexOf("::"))return null;let P,D,p=0,I=-1,A=(E.match(h.zoneIndex)||[])[0];for(A&&(A=A.substring(1),E=E.replace(/%.+$/,""));(I=E.indexOf(":",I+1))>=0;)p++;if("::"===E.substr(0,2)&&p--,"::"===E.substr(-2,2)&&p--,p>v)return null;for(D=v-p,P=":";D--;)P+="0:";return":"===(E=E.replace("::",P))[0]&&(E=E.slice(1)),":"===E[E.length-1]&&(E=E.slice(0,-1)),{parts:v=function(){const T=E.split(":"),M=[];for(let k=0;k0;){if(P=p-I,P<0&&(P=0),E[A]>>P!=v[A]>>P)return!1;I-=p,A+=1}return!0}function d(E){if(g.test(E))return parseInt(E,16);if("0"===E[0]&&!isNaN(parseInt(E[1],10))){if(l.test(E))return parseInt(E,8);throw new Error(`ipaddr: cannot parse ${E} as octal`)}return parseInt(E,10)}function b(E,v){for(;E.length=0;A-=1){if(P=this.octets[A],!(P in I))return null;if(D=I[P],p&&0!==D)return null;8!==D&&(p=!0),v+=D}return 32-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){return this.octets.slice(0)},E.prototype.toIPv4MappedAddress=function(){return S.IPv6.parse(`::ffff:${this.toString()}`)},E.prototype.toNormalizedString=function(){return this.toString()},E.prototype.toString=function(){return this.octets.join(".")},E}(),S.IPv4.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<4;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.isIPv4=function(E){return null!==this.parser(E)},S.IPv4.isValid=function(E){try{return new this(this.parser(E)),!0}catch{return!1}},S.IPv4.isValidFourPartDecimal=function(E){return!(!S.IPv4.isValid(E)||!E.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},S.IPv4.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<4;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},S.IPv4.parse=function(E){const v=this.parser(E);if(null===v)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(v)},S.IPv4.parseCIDR=function(E){let v;if(v=E.match(/^(.+)\/(\d+)$/)){const p=parseInt(v[2]);if(p>=0&&p<=32){const I=[this.parse(v[1]),p];return Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},S.IPv4.parser=function(E){let v,p,I;if(v=E.match(y.fourOctet))return function(){const A=v.slice(1,6),P=[];for(let D=0;D4294967295||I<0)throw new Error("ipaddr: address outside defined range");return function(){const A=[];let P;for(P=0;P<=24;P+=8)A.push(I>>P&255);return A}().reverse()}return(v=E.match(y.twoOctet))?function(){const A=v.slice(1,4),P=[];if(I=d(A[1]),I>16777215||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(I>>16&255),P.push(I>>8&255),P.push(255&I),P}():(v=E.match(y.threeOctet))?function(){const A=v.slice(1,5),P=[];if(I=d(A[2]),I>65535||I<0)throw new Error("ipaddr: address outside defined range");return P.push(d(A[0])),P.push(d(A[1])),P.push(I>>8&255),P.push(255&I),P}():null},S.IPv4.subnetMaskFromPrefixLength=function(E){if((E=parseInt(E))<0||E>32)throw new Error("ipaddr: invalid IPv4 prefix length");const v=[0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p=0;D-=1){if(A=this.parts[D],!(A in I))return null;if(P=I[A],p&&0!==P)return null;16!==P&&(p=!0),v+=P}return 128-v},E.prototype.range=function(){return S.subnetMatch(this,this.SpecialRanges)},E.prototype.toByteArray=function(){let v;const p=[],I=this.parts;for(let A=0;A>8),p.push(255&v);return p},E.prototype.toFixedLengthString=function(){const v=function(){const I=[];for(let A=0;A>8,255&p,I>>8,255&I])},E.prototype.toNormalizedString=function(){const v=function(){const I=[];for(let A=0;AA&&(I=P.index,A=P[0].length);return A<0?p:`${p.substring(0,I)}::${p.substring(I+A)}`},E.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},E}(),S.IPv6.broadcastAddressFromCIDR=function(E){try{const v=this.parseCIDR(E),p=v[0].toByteArray(),I=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[];let P=0;for(;P<16;)A.push(parseInt(p[P],10)|255^parseInt(I[P],10)),P++;return new this(A)}catch(v){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${v})`)}},S.IPv6.isIPv6=function(E){return null!==this.parser(E)},S.IPv6.isValid=function(E){if("string"==typeof E&&-1===E.indexOf(":"))return!1;try{const v=this.parser(E);return new this(v.parts,v.zoneId),!0}catch{return!1}},S.IPv6.networkAddressFromCIDR=function(E){let v,p,I,A,P;try{for(v=this.parseCIDR(E),I=v[0].toByteArray(),P=this.subnetMaskFromPrefixLength(v[1]).toByteArray(),A=[],p=0;p<16;)A.push(parseInt(I[p],10)&parseInt(P[p],10)),p++;return new this(A)}catch(D){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${D})`)}},S.IPv6.parse=function(E){const v=this.parser(E);if(null===v.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(v.parts,v.zoneId)},S.IPv6.parseCIDR=function(E){let v,p,I;if((p=E.match(/^(.+)\/(\d+)$/))&&(v=parseInt(p[2]),v>=0&&v<=128))return I=[this.parse(p[1]),v],Object.defineProperty(I,"toString",{value:function(){return this.join("/")}}),I;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},S.IPv6.parser=function(E){let v,p,I,A,P,D;if(I=E.match(h.deprecatedTransitional))return this.parser(`::ffff:${I[1]}`);if(h.native.test(E))return c(E,8);if((I=E.match(h.transitional))&&(D=I[6]||"",v=c(I[1].slice(0,-1)+D,6),v.parts)){for(P=[parseInt(I[2]),parseInt(I[3]),parseInt(I[4]),parseInt(I[5])],p=0;p128)throw new Error("ipaddr: invalid IPv6 prefix length");const v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let p=0;const I=Math.floor(E/8);for(;p{Y.exports=function U(){return typeof window<"u"&&"object"==typeof window.process&&"renderer"===window.process.type||typeof process<"u"&&"object"==typeof process.versions&&!!process.versions.electron||"object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0}},7494:Y=>{"use strict";Y.exports=U=>{if("[object Object]"!==Object.prototype.toString.call(U))return!1;const x=Object.getPrototypeOf(U);return null===x||x===Object.prototype}},8596:(Y,U,x)=>{"use strict";const{URLWithLegacySupport:y,format:l,URLSearchParams:g,defaultBase:w}=x(5695),m=x(340);Y.exports={URL:y,URLSearchParams:g,format:l,relative:m,defaultBase:w}},340:(Y,U,x)=>{"use strict";const{URLWithLegacySupport:y,format:l}=x(5695);Y.exports=(g,w={},m={},h)=>{let f,c=w.protocol?w.protocol.replace(":",""):"http";c=(m[c]||h||c)+":";try{f=new y(g)}catch{f={}}const d=Object.assign({},w,{protocol:c||f.protocol,host:w.host||f.host});return new y(g,l(d)).toString()}},5695:Y=>{"use strict";const U=typeof navigator<"u"&&"ReactNative"===navigator.product,y=self.URL,l=function x(){return U?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:""}();Y.exports={URLWithLegacySupport:class g{constructor(h="",c=l){this.super=new y(h,c),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(h){this.super.hash=h}set host(h){this.super.host=h}set hostname(h){this.super.hostname=h}set href(h){this.super.href=h}set password(h){this.super.password=h}set pathname(h){this.super.pathname=h}set port(h){this.super.port=h}set protocol(h){this.super.protocol=h}set search(h){this.super.search=h}set username(h){this.super.username=h}static createObjectURL(h){return y.createObjectURL(h)}static revokeObjectURL(h){y.revokeObjectURL(h)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:l,format:function w(m){if("string"==typeof m)return new y(m).toString();if(!(m instanceof y)){const c=m.auth?m.auth+"@":"",f=m.port?":"+m.port:"",S=m.hostname||"",E=m.search||(m.query?"?"+m.query:""),p=m.pathname||"";return`${m.protocol?m.protocol+"//":""}${(m.username&&m.password?`${m.username}:${m.password}@`:"")||c}${m.host||S+f}${m.path||p+E}${m.hash||""}`}}}},5357:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){const h=[];var d,c=!1,f=!1;try{for(var S,b=l(m);c=!(S=yield b.next()).done;c=!1)h.push(S.value)}catch(E){f=!0,d=E}finally{try{c&&null!=b.return&&(yield b.return())}finally{if(f)throw d}}return h});return function(h){return w.apply(this,arguments)}}()},7414:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var d=l(m);h=!(yield d.next()).done;h=!1);}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},6225:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;(yield y(c(v)))&&(yield v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},4943:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8237).default;Y.exports=function(){var w=y(function*(m){var f,h=!1,c=!1;try{for(var b,d=l(m);h=!(b=yield d.next()).done;h=!1)return b.value}catch(S){c=!0,f=S}finally{try{h&&null!=d.return&&(yield d.return())}finally{if(c)throw f}}});return function(h){return w.apply(this,arguments)}}()},1349:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield y(c(v)),yield v}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},6930:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){var b,f=!1,d=!1;try{for(var E,S=g(h);f=!(E=yield y(S.next())).done;f=!1){const v=E.value;yield c(v)}}catch(v){d=!0,b=v}finally{try{f&&null!=S.return&&(yield y(S.return()))}finally{if(d)throw b}}});return function(c,f){return m.apply(this,arguments)}}()},5061:(Y,U,x)=>{"use strict";var y=x(7156).default,l=x(8186).default,g=x(6737).default,w=x(8237).default,m=x(8131).default;const h=x(6343);Y.exports=function(){var f=l(function*(...d){const b=h();setTimeout(y(function*(){try{yield Promise.all(d.map(function(){var S=y(function*(E){var I,v=!1,p=!1;try{for(var P,A=w(E);v=!(P=yield A.next()).done;v=!1)b.push(P.value)}catch(D){p=!0,I=D}finally{try{v&&null!=A.return&&(yield A.return())}finally{if(p)throw I}}});return function(E){return S.apply(this,arguments)}}())),b.end()}catch(S){b.end(S)}}),0),yield*m(w(b),g)});return function(){return f.apply(this,arguments)}}()},6343:(Y,U,x)=>{const y=x(1159);Y.exports=l=>{let g;"function"==typeof(l=l||{})?(g=l,l={}):g=l.onEnd;let m,h,c,w=new y;const d=A=>h?h(A):(w.push(A),m),S=A=>c?m:d({done:!1,value:A}),E=A=>c?m:(c=!0,A?(A=>(w=new y,h?h({error:A}):(w.push({error:A}),m)))(A):d({done:!0}));if(m={[Symbol.asyncIterator](){return this},next:()=>{if(!w.isEmpty()){if(l.writev){let P;const D=[];for(;!w.isEmpty();){if(P=w.shift(),P.error)throw P.error;D.push(P.value)}return{done:P.done,value:D}}const A=w.shift();if(A.error)throw A.error;return A}return c?{done:!0}:new Promise((A,P)=>{h=D=>(h=null,D.error?P(D.error):A(l.writev&&!D.done?{done:D.done,value:[D.value]}:D),m)})},return:()=>(w=new y,E(),{done:!0}),throw:A=>(E(A),{done:!0}),push:S,end:E},!g)return m;const I=m;return m={[Symbol.asyncIterator](){return this},next:()=>I.next(),throw:A=>(I.throw(A),g&&(g(A),g=null),{done:!0}),return:()=>(I.return(),g&&(g(),g=null),{done:!0}),push:S,end:A=>(I.end(A),g&&(g(A),g=null),m)},m}},4297:(Y,U,x)=>{"use strict";var y=x(8186).default,l=x(6737).default,g=x(8237).default,w=x(8131).default;const m=x(5357);Y.exports=function(){var c=y(function*(f,d){const b=yield l(m(f));yield*w(g(b.sort(d)),l)});return function(d,b){return c.apply(this,arguments)}}()},0:(Y,U,x)=>{"use strict";var y=x(6737).default,l=x(8186).default,g=x(8237).default;Y.exports=function(){var m=l(function*(h,c){let f=0;if(!(c<1)){var S,d=!1,b=!1;try{for(var v,E=g(h);d=!(v=yield y(E.next())).done;d=!1)if(yield v.value,f++,f===c)return}catch(p){b=!0,S=p}finally{try{d&&null!=E.return&&(yield y(E.return()))}finally{if(b)throw S}}}});return function(c,f){return m.apply(this,arguments)}}()},4237:(Y,U,x)=>{var y;!function(){"use strict";var l="input is invalid type",w="object"==typeof window,m=w?window:{};m.JS_SHA3_NO_WINDOW&&(w=!1);var h=!w&&"object"==typeof self;!m.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?m=global:h&&(m=self);var f=!m.JS_SHA3_NO_COMMON_JS&&Y.exports,d=x.amdO,b=!m.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",S="0123456789abcdef".split(""),v=[4,1024,262144,67108864],A=[0,8,16,24],P=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],D=[224,256,384,512],T=[128,256],M=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136};(m.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(H){return"[object Array]"===Object.prototype.toString.call(H)}),b&&(m.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(H){return"object"==typeof H&&H.buffer&&H.buffer.constructor===ArrayBuffer});for(var F=function(H,Ee,Te){return function(xe){return new Pe(H,Ee,H).update(xe)[Te]()}},G=function(H,Ee,Te){return function(xe,He){return new Pe(H,Ee,He).update(xe)[Te]()}},C=function(H,Ee,Te){return function(xe,He,We,Je){return X["cshake"+H].update(xe,He,We,Je)[Te]()}},O=function(H,Ee,Te){return function(xe,He,We,Je){return X["kmac"+H].update(xe,He,We,Je)[Te]()}},V=function(H,Ee,Te,xe){for(var He=0;He>5,this.byteCount=this.blockCount<<2,this.outputBlocks=Te>>5,this.extraBytes=(31&Te)>>3;for(var xe=0;xe<50;++xe)this.s[xe]=0}function be(H,Ee,Te){Pe.call(this,H,Ee,Te)}Pe.prototype.update=function(H){if(this.finalized)throw new Error("finalize already called");var Ee,Te=typeof H;if("string"!==Te){if("object"!==Te)throw new Error(l);if(null===H)throw new Error(l);if(b&&H.constructor===ArrayBuffer)H=new Uint8Array(H);else if(!(Array.isArray(H)||b&&ArrayBuffer.isView(H)))throw new Error(l);Ee=!0}for(var pt,_t,xe=this.blocks,He=this.byteCount,We=H.length,Je=this.blockCount,Xe=0,Nt=this.s;Xe>2]|=H[Xe]<>2]|=_t<>2]|=(192|_t>>6)<>2]|=(128|63&_t)<=57344?(xe[pt>>2]|=(224|_t>>12)<>2]|=(128|_t>>6&63)<>2]|=(128|63&_t)<>2]|=(240|_t>>18)<>2]|=(128|_t>>12&63)<>2]|=(128|_t>>6&63)<>2]|=(128|63&_t)<=He){for(this.start=pt-He,this.block=xe[Je],pt=0;pt>=8);Te>0;)He.unshift(Te),Te=255&(H>>=8),++xe;return Ee?He.push(xe):He.unshift(xe),this.update(He),He.length},Pe.prototype.encodeString=function(H){var Ee,Te=typeof H;if("string"!==Te){if("object"!==Te)throw new Error(l);if(null===H)throw new Error(l);if(b&&H.constructor===ArrayBuffer)H=new Uint8Array(H);else if(!(Array.isArray(H)||b&&ArrayBuffer.isView(H)))throw new Error(l);Ee=!0}var xe=0;if(Ee)xe=H.length;else for(var We=0;We=57344?xe+=3:(Je=65536+((1023&Je)<<10|1023&H.charCodeAt(++We)),xe+=4)}return xe+=this.encode(8*xe),this.update(H),xe},Pe.prototype.bytepad=function(H,Ee){for(var Te=this.encode(Ee),xe=0;xe>2]|=this.padding[3&Ee],this.lastByteIndex===this.byteCount)for(H[0]=H[Te],Ee=1;Ee>4&15]+S[15&Xe]+S[Xe>>12&15]+S[Xe>>8&15]+S[Xe>>20&15]+S[Xe>>16&15]+S[Xe>>28&15]+S[Xe>>24&15];We%H==0&&($e(Ee),He=0)}return xe&&(Je+=S[(Xe=Ee[He])>>4&15]+S[15&Xe],xe>1&&(Je+=S[Xe>>12&15]+S[Xe>>8&15]),xe>2&&(Je+=S[Xe>>20&15]+S[Xe>>16&15])),Je},Pe.prototype.buffer=Pe.prototype.arrayBuffer=function(){this.finalize();var Xe,H=this.blockCount,Ee=this.s,Te=this.outputBlocks,xe=this.extraBytes,He=0,We=0,Je=this.outputBits>>3;Xe=xe?new ArrayBuffer(Te+1<<2):new ArrayBuffer(Je);for(var Nt=new Uint32Array(Xe);We>8&255,Je[Xe+2]=Nt>>16&255,Je[Xe+3]=Nt>>24&255;We%H==0&&$e(Ee)}return xe&&(Je[Xe=We<<2]=255&(Nt=Ee[He]),xe>1&&(Je[Xe+1]=Nt>>8&255),xe>2&&(Je[Xe+2]=Nt>>16&255)),Je},(be.prototype=new Pe).finalize=function(){return this.encode(this.outputBits,!0),Pe.prototype.finalize.call(this)};var $e=function(H){var Ee,Te,xe,He,We,Je,Xe,Nt,pt,_t,Or,gr,Hr,ie,fe,ye,me,_e,Ne,Qe,qe,it,nt,Ke,we,ge,De,Fe,Be,dt,xt,mt,et,Tn,Bt,pn,en,ft,ln,st,Kt,wt,Jn,Pr,On,vn,ur,Qn,En,Ft,ct,ce,ve,yt,Dt,gn,je,Ye,Ae,Ge,ht,Et,ut;for(xe=0;xe<48;xe+=2)He=H[0]^H[10]^H[20]^H[30]^H[40],We=H[1]^H[11]^H[21]^H[31]^H[41],Nt=H[4]^H[14]^H[24]^H[34]^H[44],pt=H[5]^H[15]^H[25]^H[35]^H[45],_t=H[6]^H[16]^H[26]^H[36]^H[46],Or=H[7]^H[17]^H[27]^H[37]^H[47],Te=(Hr=H[9]^H[19]^H[29]^H[39]^H[49])^((Xe=H[3]^H[13]^H[23]^H[33]^H[43])<<1|(Je=H[2]^H[12]^H[22]^H[32]^H[42])>>>31),H[0]^=Ee=(gr=H[8]^H[18]^H[28]^H[38]^H[48])^(Je<<1|Xe>>>31),H[1]^=Te,H[10]^=Ee,H[11]^=Te,H[20]^=Ee,H[21]^=Te,H[30]^=Ee,H[31]^=Te,H[40]^=Ee,H[41]^=Te,Te=We^(pt<<1|Nt>>>31),H[2]^=Ee=He^(Nt<<1|pt>>>31),H[3]^=Te,H[12]^=Ee,H[13]^=Te,H[22]^=Ee,H[23]^=Te,H[32]^=Ee,H[33]^=Te,H[42]^=Ee,H[43]^=Te,Te=Xe^(Or<<1|_t>>>31),H[4]^=Ee=Je^(_t<<1|Or>>>31),H[5]^=Te,H[14]^=Ee,H[15]^=Te,H[24]^=Ee,H[25]^=Te,H[34]^=Ee,H[35]^=Te,H[44]^=Ee,H[45]^=Te,Te=pt^(Hr<<1|gr>>>31),H[6]^=Ee=Nt^(gr<<1|Hr>>>31),H[7]^=Te,H[16]^=Ee,H[17]^=Te,H[26]^=Ee,H[27]^=Te,H[36]^=Ee,H[37]^=Te,H[46]^=Ee,H[47]^=Te,Te=Or^(We<<1|He>>>31),H[8]^=Ee=_t^(He<<1|We>>>31),H[9]^=Te,H[18]^=Ee,H[19]^=Te,H[28]^=Ee,H[29]^=Te,H[38]^=Ee,H[39]^=Te,H[48]^=Ee,H[49]^=Te,fe=H[1],vn=H[11]<<4|H[10]>>>28,ur=H[10]<<4|H[11]>>>28,Fe=H[20]<<3|H[21]>>>29,Be=H[21]<<3|H[20]>>>29,Ge=H[31]<<9|H[30]>>>23,ht=H[30]<<9|H[31]>>>23,wt=H[40]<<18|H[41]>>>14,Jn=H[41]<<18|H[40]>>>14,Tn=H[2]<<1|H[3]>>>31,Bt=H[3]<<1|H[2]>>>31,me=H[12]<<12|H[13]>>>20,Qn=H[22]<<10|H[23]>>>22,En=H[23]<<10|H[22]>>>22,dt=H[33]<<13|H[32]>>>19,xt=H[32]<<13|H[33]>>>19,Et=H[42]<<2|H[43]>>>30,ut=H[43]<<2|H[42]>>>30,yt=H[5]<<30|H[4]>>>2,Dt=H[4]<<30|H[5]>>>2,pn=H[14]<<6|H[15]>>>26,en=H[15]<<6|H[14]>>>26,Ne=H[24]<<11|H[25]>>>21,Ft=H[34]<<15|H[35]>>>17,ct=H[35]<<15|H[34]>>>17,mt=H[45]<<29|H[44]>>>3,et=H[44]<<29|H[45]>>>3,Ke=H[6]<<28|H[7]>>>4,we=H[7]<<28|H[6]>>>4,gn=H[17]<<23|H[16]>>>9,je=H[16]<<23|H[17]>>>9,ft=H[26]<<25|H[27]>>>7,ln=H[27]<<25|H[26]>>>7,Qe=H[36]<<21|H[37]>>>11,qe=H[37]<<21|H[36]>>>11,ce=H[47]<<24|H[46]>>>8,ve=H[46]<<24|H[47]>>>8,Pr=H[8]<<27|H[9]>>>5,On=H[9]<<27|H[8]>>>5,ge=H[18]<<20|H[19]>>>12,De=H[19]<<20|H[18]>>>12,Ye=H[29]<<7|H[28]>>>25,Ae=H[28]<<7|H[29]>>>25,st=H[38]<<8|H[39]>>>24,Kt=H[39]<<8|H[38]>>>24,it=H[48]<<14|H[49]>>>18,nt=H[49]<<14|H[48]>>>18,H[0]=(ie=H[0])^~(ye=H[13]<<12|H[12]>>>20)&(_e=H[25]<<11|H[24]>>>21),H[1]=fe^~me&Ne,H[10]=Ke^~ge&Fe,H[11]=we^~De&Be,H[20]=Tn^~pn&ft,H[21]=Bt^~en&ln,H[30]=Pr^~vn&Qn,H[31]=On^~ur&En,H[40]=yt^~gn&Ye,H[41]=Dt^~je&Ae,H[2]=ye^~_e&Qe,H[3]=me^~Ne&qe,H[12]=ge^~Fe&dt,H[13]=De^~Be&xt,H[22]=pn^~ft&st,H[23]=en^~ln&Kt,H[32]=vn^~Qn&Ft,H[33]=ur^~En&ct,H[42]=gn^~Ye&Ge,H[43]=je^~Ae&ht,H[4]=_e^~Qe&it,H[5]=Ne^~qe&nt,H[14]=Fe^~dt&mt,H[15]=Be^~xt&et,H[24]=ft^~st&wt,H[25]=ln^~Kt&Jn,H[34]=Qn^~Ft&ce,H[35]=En^~ct&ve,H[44]=Ye^~Ge&Et,H[45]=Ae^~ht&ut,H[6]=Qe^~it&ie,H[7]=qe^~nt&fe,H[16]=dt^~mt&Ke,H[17]=xt^~et&we,H[26]=st^~wt&Tn,H[27]=Kt^~Jn&Bt,H[36]=Ft^~ce&Pr,H[37]=ct^~ve&On,H[46]=Ge^~Et&yt,H[47]=ht^~ut&Dt,H[8]=it^~ie&ye,H[9]=nt^~fe&me,H[18]=mt^~Ke&ge,H[19]=et^~we&De,H[28]=wt^~Tn&pn,H[29]=Jn^~Bt&en,H[38]=ce^~Pr&vn,H[39]=ve^~On&ur,H[48]=Et^~yt&gn,H[49]=ut^~Dt&je,H[0]^=P[xe],H[1]^=P[xe+1]};if(f)Y.exports=X;else{for(ne=0;neObject.defineProperty(p,I,{value:A,writable:!0,enumerable:!0,configurable:!0}),m=this,h={concatArrays:!1,ignoreUndefined:!1},c=p=>{const I=[];for(const A in p)l.call(p,A)&&I.push(A);if(Object.getOwnPropertySymbols){const A=Object.getOwnPropertySymbols(p);for(const P of A)g.call(p,P)&&I.push(P)}return I};function f(p){return Array.isArray(p)?function d(p){const I=p.slice(0,0);return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):y(p)?function b(p){const I=null===Object.getPrototypeOf(p)?Object.create(null):{};return c(p).forEach(A=>{w(I,A,f(p[A]))}),I}(p):p}const S=(p,I,A,P)=>(A.forEach(D=>{typeof I[D]>"u"&&P.ignoreUndefined||(D in p&&p[D]!==Object.getPrototypeOf(p)?w(p,D,v(p[D],I[D],P)):w(p,D,f(I[D])))}),p);function v(p,I,A){return A.concatArrays&&Array.isArray(p)&&Array.isArray(I)?((p,I,A)=>{let P=p.slice(0,0),D=0;return[p,I].forEach(T=>{const M=[];for(let k=0;k!M.includes(k)),A)}),P})(p,I,A):y(I)&&y(p)?S(p,I,c(I),A):f(I)}Y.exports=function(...p){const I=v(f(h),this!==m&&this||{},h);let A={_:{}};for(const P of p)if(void 0!==P){if(!y(P))throw new TypeError("`"+P+"` is not an Option Object");A=v(A,{_:P},I)}return A._}},4366:Y=>{var U=1e3,x=60*U,y=60*x,l=24*y;function f(d,b,S,E){var v=b>=1.5*S;return Math.round(d/S)+" "+E+(v?"s":"")}Y.exports=function(d,b){b=b||{};var S=typeof d;if("string"===S&&d.length>0)return function m(d){if(!((d=String(d)).length>100)){var b=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(b){var S=parseFloat(b[1]);switch((b[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*S;case"weeks":case"week":case"w":return 6048e5*S;case"days":case"day":case"d":return S*l;case"hours":case"hour":case"hrs":case"hr":case"h":return S*y;case"minutes":case"minute":case"mins":case"min":case"m":return S*x;case"seconds":case"second":case"secs":case"sec":case"s":return S*U;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return S;default:return}}}}(d);if("number"===S&&isFinite(d))return b.long?function c(d){var b=Math.abs(d);return b>=l?f(d,b,l,"day"):b>=y?f(d,b,y,"hour"):b>=x?f(d,b,x,"minute"):b>=U?f(d,b,U,"second"):d+" ms"}(d):function h(d){var b=Math.abs(d);return b>=l?Math.round(d/l)+"d":b>=y?Math.round(d/y)+"h":b>=x?Math.round(d/x)+"m":b>=U?Math.round(d/U)+"s":d+"ms"}(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},344:Y=>{"use strict";function U(x){if(Array.isArray(x)){for(var y=0,l=Array(x.length);y>>24,(f&255<<16)>>>16,(65280&f)>>>8,255&f].join(".")},h=function(f){var d,S,E,v,p;for(d=[],S=E=0;E<=3&&0!==f.length;S=++E){if(S>0){if("."!==f[0])throw new Error("Invalid IP");f=f.substring(1)}v=(p=y(f))[0],f=f.substring(p[1]),d.push(v)}if(0!==f.length)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},g=(l=function(f){return f.charCodeAt(0)})("0"),m=l("a"),w=l("A"),y=function(f){var d,b,S,E,v;for(E=0,d=10,b="9",S=0,f.length>1&&"0"===f[S]&&("x"===f[S+1]||"X"===f[S+1]?(S+=2,d=16):"0"<=f[S+1]&&f[S+1]<="9"&&(S++,d=8,b="7")),v=S;S>>0;else{if(16!==d)break;if("a"<=f[S]&&f[S]<="f")E=E*d+(10+l(f[S])-m)>>>0;else{if(!("A"<=f[S]&&f[S]<="F"))break;E=E*d+(10+l(f[S])-w)>>>0}}if(E>4294967295)throw new Error("too large");S++}if(S===v)throw new Error("empty octet");return[E,S]},x=function(){function f(d,b){var E,v,p;if("string"!=typeof d)throw new Error("Missing `net' parameter");if(b||(p=d.split("/",2),d=p[0],b=p[1]),b||(b=32),"string"==typeof b&&b.indexOf(".")>-1){try{this.maskLong=h(b)}catch(I){throw new Error("Invalid mask: "+b)}for(E=v=32;v>=0;E=--v)if(this.maskLong===4294967295<<32-E>>>0){this.bitmask=E;break}}else{if(!b&&0!==b)throw new Error("Invalid mask: empty");this.bitmask=parseInt(b,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(h(d)&this.maskLong)>>>0}catch(I){throw new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+b);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=c(this.bitmask<=30?this.netLong+this.size-2:this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return f.prototype.contains=function(d){return"string"==typeof d&&(d.indexOf("/")>0||4!==d.split(".").length)&&(d=new f(d)),d instanceof f?this.contains(d.base)&&this.contains(d.broadcast||d.last):(h(d)&this.maskLong)>>>0==(this.netLong&this.maskLong)>>>0},f.prototype.next=function(d){return null==d&&(d=1),new f(c(this.netLong+this.size*d),this.mask)},f.prototype.forEach=function(d){var b,S,E;for(E=h(this.first),S=h(this.last),b=0;E<=S;)d(c(E),E,b),b++,E++},f.prototype.toString=function(){return this.base+"/"+this.bitmask},f}(),U.ip2long=h,U.long2ip=c,U.Netmask=x}).call(this)},1298:(Y,U,x)=>{var y=x(8659);function l(p,I){y.cipher.registerAlgorithm(p,function(){return new y.aes.Algorithm(p,I)})}x(3311),x(3481),x(4747),Y.exports=y.aes=y.aes||{},y.aes.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P});return D.start(I),D},y.aes.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.aes.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P});return D.start(I),D},y.aes.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.aes.Algorithm=function(p,I){g||b();var A=this;A.name=p,A.mode=new I({blockSize:16,cipher:{encrypt:function(P,D){return E(A._w,P,D,!1)},decrypt:function(P,D){return E(A._w,P,D,!0)}}}),A._init=!1},y.aes.Algorithm.prototype.initialize=function(p){if(!this._init){var A,I=p.key;if("string"!=typeof I||16!==I.length&&24!==I.length&&32!==I.length){if(y.util.isArray(I)&&(16===I.length||24===I.length||32===I.length)){A=I,I=y.util.createBuffer();for(var P=0;P>>=2,P=0;P>8^255&k^99,h[k]=A,G=(F=p[k])<<24^k<<16^k<<8^k^F,C=((D=p[A])^(T=p[D])^(M=p[T]))<<24^(A^M)<<16^(A^T^M)<<8^A^D^M;for(var O=0;O<4;++O)f[O][A]=G,d[O][k]=C,G=G<<24|G>>>8,C=C<<24|C>>>8;0===A?A=P=1:(A=D^p[p[p[D^M]]],P^=p[p[P]])}}function S(p,I){for(var P,A=p.slice(0),D=1,T=A.length,k=4*(T+6+1),F=T;F>>16&255]<<24^m[P>>>8&255]<<16^m[255&P]<<8^m[P>>>24]^c[D]<<24,D++):T>6&&F%T==4&&(P=m[P>>>24]<<24^m[P>>>16&255]<<16^m[P>>>8&255]<<8^m[255&P]),A[F]=A[F-T]^P;if(I){for(var G,C=d[0],O=d[1],V=d[2],L=d[3],$=A.slice(0),re=(F=0,(k=A.length)-4);F>>24]]^O[m[G>>>16&255]]^V[m[G>>>8&255]]^L[m[255&G]];A=$}return A}function E(p,I,A,P){var T,M,k,F,G,C,O,V,L,$,re,z,D=p.length/4-1;P?(T=d[0],M=d[1],k=d[2],F=d[3],G=h):(T=f[0],M=f[1],k=f[2],F=f[3],G=m),C=I[0]^p[0],O=I[P?3:1]^p[1],V=I[2]^p[2],L=I[P?1:3]^p[3];for(var te=3,X=1;X>>24]^M[O>>>16&255]^k[V>>>8&255]^F[255&L]^p[++te],re=T[O>>>24]^M[V>>>16&255]^k[L>>>8&255]^F[255&C]^p[++te],z=T[V>>>24]^M[L>>>16&255]^k[C>>>8&255]^F[255&O]^p[++te],L=T[L>>>24]^M[C>>>16&255]^k[O>>>8&255]^F[255&V]^p[++te],C=$,O=re,V=z;A[0]=G[C>>>24]<<24^G[O>>>16&255]<<16^G[V>>>8&255]<<8^G[255&L]^p[++te],A[P?3:1]=G[O>>>24]<<24^G[V>>>16&255]<<16^G[L>>>8&255]<<8^G[255&C]^p[++te],A[2]=G[V>>>24]<<24^G[L>>>16&255]<<16^G[C>>>8&255]<<8^G[255&O]^p[++te],A[P?1:3]=G[L>>>24]<<24^G[C>>>16&255]<<16^G[O>>>8&255]<<8^G[255&V]^p[++te]}function v(p){var P,A="AES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},7791:(Y,U,x)=>{var y=x(8659);x(4747),x(6078);var l=Y.exports=y.asn1=y.asn1||{};function g(c,f,d){if(d>f){var b=new Error("Too few bytes to parse DER.");throw b.available=c.length(),b.remaining=f,b.requested=d,b}}function m(c,f,d,b){var S;g(c,f,2);var E=c.getByte();f--;var v=192&E,p=31&E;S=c.length();var I=function(c,f){var d=c.getByte();if(f--,128!==d){var b;if(128&d){var E=127&d;g(c,f,E),b=c.getInt(E<<3)}else b=d;if(b<0)throw new Error("Negative length: "+b);return b}}(c,f);if(f-=S-c.length(),void 0!==I&&I>f){if(b.strict){var A=new Error("Too few bytes to read ASN.1 value.");throw A.available=c.length(),A.remaining=f,A.requested=I,A}I=f}var P,D,T=32==(32&E);if(T)if(P=[],void 0===I)for(;;){if(g(c,f,2),c.bytes(2)===String.fromCharCode(0,0)){c.getBytes(2),f-=2;break}S=c.length(),P.push(m(c,f,d+1,b)),f-=S-c.length()}else for(;I>0;)S=c.length(),P.push(m(c,I,d+1,b)),f-=S-c.length(),I-=S-c.length();if(void 0===P&&v===l.Class.UNIVERSAL&&p===l.Type.BITSTRING&&(D=c.bytes(I)),void 0===P&&b.decodeBitStrings&&v===l.Class.UNIVERSAL&&p===l.Type.BITSTRING&&I>1){var M=c.read,k=f,F=0;if(p===l.Type.BITSTRING&&(g(c,f,1),F=c.getByte(),f--),0===F)try{S=c.length();var C=m(c,f,d+1,{strict:!0,decodeBitStrings:!0}),O=S-c.length();f-=O,p==l.Type.BITSTRING&&O++;var V=C.tagClass;O===I&&(V===l.Class.UNIVERSAL||V===l.Class.CONTEXT_SPECIFIC)&&(P=[C])}catch{}void 0===P&&(c.read=M,f=k)}if(void 0===P){if(void 0===I){if(b.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");I=f}if(p===l.Type.BMPSTRING)for(P="";I>0;I-=2)g(c,f,2),P+=String.fromCharCode(c.getInt16()),f-=2;else P=c.getBytes(I),f-=I}return l.create(v,p,T,P,void 0===D?null:{bitStringContents:D})}l.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},l.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},l.create=function(c,f,d,b,S){if(y.util.isArray(b)){for(var E=[],v=0;v1&&(0===c.value.charCodeAt(0)&&0==(128&c.value.charCodeAt(1))||255===c.value.charCodeAt(0)&&128==(128&c.value.charCodeAt(1)))?b.putBytes(c.value.substr(1)):b.putBytes(c.value);if(f.putByte(d),b.length()<=127)f.putByte(127&b.length());else{var v=b.length(),p="";do{p+=String.fromCharCode(255&v),v>>>=8}while(v>0);for(f.putByte(128|p.length),E=p.length-1;E>=0;--E)f.putByte(p.charCodeAt(E))}return f.putBuffer(b),f},l.oidToDer=function(c){var f=c.split("."),d=y.util.createBuffer();d.putByte(40*parseInt(f[0],10)+parseInt(f[1],10));for(var b,S,E,v,p=2;p>>=7,b||(v|=128),S.push(v),b=!1}while(E>0);for(var I=S.length-1;I>=0;--I)d.putByte(S[I])}return d},l.derToOid=function(c){var f;"string"==typeof c&&(c=y.util.createBuffer(c));var d=c.getByte();f=Math.floor(d/40)+"."+d%40;for(var b=0;c.length()>0;)b<<=7,128&(d=c.getByte())?b+=127&d:(f+="."+(b+d),b=0);return f},l.utcTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,2),10);d=d>=50?1900+d:2e3+d;var b=parseInt(c.substr(2,2),10)-1,S=parseInt(c.substr(4,2),10),E=parseInt(c.substr(6,2),10),v=parseInt(c.substr(8,2),10),p=0;if(c.length>11){var I=c.charAt(10),A=10;"+"!==I&&"-"!==I&&(p=parseInt(c.substr(10,2),10),A+=2)}if(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,0),A&&("+"===(I=c.charAt(A))||"-"===I)){var T=60*parseInt(c.substr(A+1,2),10)+parseInt(c.substr(A+4,2),10);T*=6e4,f.setTime("+"===I?+f-T:+f+T)}return f},l.generalizedTimeToDate=function(c){var f=new Date,d=parseInt(c.substr(0,4),10),b=parseInt(c.substr(4,2),10)-1,S=parseInt(c.substr(6,2),10),E=parseInt(c.substr(8,2),10),v=parseInt(c.substr(10,2),10),p=parseInt(c.substr(12,2),10),I=0,A=0,P=!1;"Z"===c.charAt(c.length-1)&&(P=!0);var D=c.length-5,T=c.charAt(D);return"+"!==T&&"-"!==T||(A=60*parseInt(c.substr(D+1,2),10)+parseInt(c.substr(D+4,2),10),A*=6e4,"+"===T&&(A*=-1),P=!0),"."===c.charAt(14)&&(I=1e3*parseFloat(c.substr(14),10)),P?(f.setUTCFullYear(d,b,S),f.setUTCHours(E,v,p,I),f.setTime(+f+A)):(f.setFullYear(d,b,S),f.setHours(E,v,p,I)),f},l.dateToUtcTime=function(c){if("string"==typeof c)return c;var f="",d=[];d.push((""+c.getUTCFullYear()).substr(2)),d.push(""+(c.getUTCMonth()+1)),d.push(""+c.getUTCDate()),d.push(""+c.getUTCHours()),d.push(""+c.getUTCMinutes()),d.push(""+c.getUTCSeconds());for(var b=0;b=-128&&c<128)return f.putSignedInt(c,8);if(c>=-32768&&c<32768)return f.putSignedInt(c,16);if(c>=-8388608&&c<8388608)return f.putSignedInt(c,24);if(c>=-2147483648&&c<2147483648)return f.putSignedInt(c,32);var d=new Error("Integer too large; max is 32-bits.");throw d.integer=c,d},l.derToInteger=function(c){"string"==typeof c&&(c=y.util.createBuffer(c));var f=8*c.length();if(f>32)throw new Error("Integer too large; max is 32-bits.");return c.getSignedInt(f)},l.validate=function(c,f,d,b){var S=!1;if((c.tagClass===f.tagClass||typeof f.tagClass>"u")&&(c.type===f.type||typeof f.type>"u"))if(c.constructed===f.constructed||typeof f.constructed>"u"){if(S=!0,f.value&&y.util.isArray(f.value))for(var E=0,v=0;S&&v0&&(b+="\n");for(var S="",E=0;E1?"0x"+y.util.bytesToHex(c.value.slice(1)):"(none)",c.value.length>0){var A=c.value.charCodeAt(0);1==A?b+=" (1 unused bit shown)":A>1&&(b+=" ("+A+" unused bits shown)")}}else if(c.type===l.Type.OCTETSTRING)h.test(c.value)||(b+="("+c.value+") "),b+="0x"+y.util.bytesToHex(c.value);else if(c.type===l.Type.UTF8)try{b+=y.util.decodeUtf8(c.value)}catch(P){if("URI malformed"!==P.message)throw P;b+="0x"+y.util.bytesToHex(c.value)+" (malformed UTF8)"}else c.type===l.Type.PRINTABLESTRING||c.type===l.Type.IA5String?b+=c.value:h.test(c.value)?b+="0x"+y.util.bytesToHex(c.value):b+=0===c.value.length?"[null]":c.value}return b}},2020:Y=>{var U={};Y.exports=U;var x={};U.encode=function(l,g,w){if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');if(void 0!==w&&"number"!=typeof w)throw new TypeError('"maxline" must be a number.');var m="";if(l instanceof Uint8Array){var h=0,c=g.length,f=g.charAt(0),d=[0];for(h=0;h0;)d.push(S%c),S=S/c|0}for(h=0;0===l[h]&&h=0;--h)m+=g[d[h]]}else m=function y(l,g){var w=0,m=g.length,h=g.charAt(0),c=[0];for(w=0;w0;)c.push(d%m),d=d/m|0}var b="";for(w=0;0===l.at(w)&&w=0;--w)b+=g[c[w]];return b}(l,g);if(w){var E=new RegExp(".{1,"+w+"}","g");m=m.match(E).join("\r\n")}return m},U.decode=function(l,g){if("string"!=typeof l)throw new TypeError('"input" must be a string.');if("string"!=typeof g)throw new TypeError('"alphabet" must be a string.');var w=x[g];if(!w){w=x[g]=[];for(var m=0;m>=8;for(;S>0;)f.push(255&S),S>>=8}for(var E=0;l[E]===c&&E{var y=x(8659);x(4747),Y.exports=y.cipher=y.cipher||{},y.cipher.algorithms=y.cipher.algorithms||{},y.cipher.createCipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!1})},y.cipher.createDecipher=function(g,w){var m=g;if("string"==typeof m&&(m=y.cipher.getAlgorithm(m))&&(m=m()),!m)throw new Error("Unsupported algorithm: "+g);return new y.cipher.BlockCipher({algorithm:m,key:w,decrypt:!0})},y.cipher.registerAlgorithm=function(g,w){g=g.toUpperCase(),y.cipher.algorithms[g]=w},y.cipher.getAlgorithm=function(g){return(g=g.toUpperCase())in y.cipher.algorithms?y.cipher.algorithms[g]:null};var l=y.cipher.BlockCipher=function(g){this.algorithm=g.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=g.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=g.decrypt,this.algorithm.initialize(g)};l.prototype.start=function(g){g=g||{};var w={};for(var m in g)w[m]=g[m];w.decrypt=this._decrypt,this._finish=!1,this._input=y.util.createBuffer(),this.output=g.output||y.util.createBuffer(),this.mode.start(w)},l.prototype.update=function(g){for(g&&this._input.putBuffer(g);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},l.prototype.finish=function(g){g&&("ECB"===this.mode.name||"CBC"===this.mode.name)&&(this.mode.pad=function(m){return g(this.blockSize,m,!1)},this.mode.unpad=function(m){return g(this.blockSize,m,!0)});var w={};return w.decrypt=this._decrypt,w.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,w)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,w))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,w))}},3481:(Y,U,x)=>{var y=x(8659);x(4747),y.cipher=y.cipher||{};var l=Y.exports=y.cipher.modes=y.cipher.modes||{};function g(h,c){if("string"==typeof h&&(h=y.util.createBuffer(h)),y.util.isArray(h)&&h.length>4){var f=h;h=y.util.createBuffer();for(var d=0;d0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},l.cbc=function(h){h=h||{},this.name="CBC",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},l.cbc.prototype.start=function(h){if(null===h.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._prev=this._iv.slice(0)}},l.cbc.prototype.encrypt=function(h,c,f){if(h.length()0))return!0;for(var d=0;d0))return!0;for(var d=0;d0)return!1;var f=h.length(),d=h.at(f-1);return!(d>this.blockSize<<2||(h.truncate(d),0))},l.cfb=function(h){h=h||{},this.name="CFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.cfb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.cfb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.cfb.prototype.decrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.ofb=function(h){h=h||{},this.name="OFB",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.ofb.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.ofb.prototype.encrypt=function(h,c,f){var d=h.length();if(0===h.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0)h.read-=this.blockSize;else for(b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}},l.ofb.prototype.decrypt=l.ofb.prototype.encrypt,l.ctr=function(h){h=h||{},this.name="CTR",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0},l.ctr.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");this._iv=g(h.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},l.ctr.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize)for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&(h.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}w(this._inBlock)},l.ctr.prototype.decrypt=l.ctr.prototype.encrypt,l.gcm=function(h){h=h||{},this.name="GCM",this.cipher=h.cipher,this.blockSize=h.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=y.util.createBuffer(),this._partialBytes=0,this._R=3774873600},l.gcm.prototype.start=function(h){if(!("iv"in h))throw new Error("Invalid IV parameter.");var f,c=y.util.createBuffer(h.iv);if(this._cipherLength=0,f="additionalData"in h?y.util.createBuffer(h.additionalData):y.util.createBuffer(),this._tagLength="tagLength"in h?h.tagLength:128,this._tag=null,h.decrypt&&(this._tag=y.util.createBuffer(h.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var d=c.length();if(12===d)this._j0=[c.getInt32(),c.getInt32(),c.getInt32(),1];else{for(this._j0=[0,0,0,0];c.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[c.getInt32(),c.getInt32(),c.getInt32(),c.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(m(8*d)))}this._inBlock=this._j0.slice(0),w(this._inBlock),this._partialBytes=0,f=y.util.createBuffer(f),this._aDataLength=m(8*f.length());var b=f.length()%this.blockSize;for(b&&f.fillWithByte(0,this.blockSize-b),this._s=[0,0,0,0];f.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[f.getInt32(),f.getInt32(),f.getInt32(),f.getInt32()])},l.gcm.prototype.encrypt=function(h,c,f){var d=h.length();if(0===d)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&d>=this.blockSize){for(var b=0;b0&&(S=this.blockSize-S),this._partialOutput.clear(),b=0;b0&&this._partialOutput.getBytes(this._partialBytes),S>0&&!f)return h.read-=this.blockSize,c.putBytes(this._partialOutput.getBytes(S-this._partialBytes)),this._partialBytes=S,!0;c.putBytes(this._partialOutput.getBytes(d-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),w(this._inBlock)},l.gcm.prototype.decrypt=function(h,c,f){var d=h.length();if(d0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),w(this._inBlock),this._hashBlock[0]=h.getInt32(),this._hashBlock[1]=h.getInt32(),this._hashBlock[2]=h.getInt32(),this._hashBlock[3]=h.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var b=0;b0;--d)c[d]=h[d]>>>1|(1&h[d-1])<<31;c[0]=h[0]>>>1,f&&(c[0]^=this._R)},l.gcm.prototype.tableMultiply=function(h){for(var c=[0,0,0,0],f=0;f<32;++f){var S=this._m[f][h[f/8|0]>>>4*(7-f%8)&15];c[0]^=S[0],c[1]^=S[1],c[2]^=S[2],c[3]^=S[3]}return c},l.gcm.prototype.ghash=function(h,c,f){return c[0]^=f[0],c[1]^=f[1],c[2]^=f[2],c[3]^=f[3],this.tableMultiply(c)},l.gcm.prototype.generateHashTable=function(h,c){for(var f=8/c,d=4*f,b=16*f,S=new Array(b),E=0;E>>1,b=new Array(f);b[d]=h.slice(0);for(var S=d>>>1;S>0;)this.pow(b[2*S],b[S]=[]),S>>=1;for(S=2;S{var y=x(8659);function l(p,I){y.cipher.registerAlgorithm(p,function(){return new y.des.Algorithm(p,I)})}x(3311),x(3481),x(4747),Y.exports=y.des=y.des||{},y.des.startEncrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!1,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createEncryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!1,mode:I})},y.des.startDecrypting=function(p,I,A,P){var D=v({key:p,output:A,decrypt:!0,mode:P||(null===I?"ECB":"CBC")});return D.start(I),D},y.des.createDecryptionCipher=function(p,I){return v({key:p,output:null,decrypt:!0,mode:I})},y.des.Algorithm=function(p,I){var A=this;A.name=p,A.mode=new I({blockSize:8,cipher:{encrypt:function(P,D){return E(A._keys,P,D,!1)},decrypt:function(P,D){return E(A._keys,P,D,!0)}}}),A._init=!1},y.des.Algorithm.prototype.initialize=function(p){if(!this._init){var I=y.util.createBuffer(p.key);if(0===this.name.indexOf("3DES")&&24!==I.length())throw new Error("Invalid Triple-DES key size: "+8*I.length());this._keys=function S(p){for(var q,I=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],A=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],P=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],D=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],T=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],M=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],k=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],F=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],G=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],C=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],O=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],V=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],L=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],$=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],re=p.length()>8?3:1,z=[],te=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],X=0,ne=0;ne>>4^de))<<4,se^=q=65535&((de^=q)>>>-16^se),se^=(q=858993459&(se>>>2^(de^=q<<-16)))<<2,se^=q=65535&((de^=q)>>>-16^se),se^=(q=1431655765&(se>>>1^(de^=q<<-16)))<<1,se^=q=16711935&((de^=q)>>>8^se),q=(se^=(q=1431655765&(se>>>1^(de^=q<<8)))<<1)<<8|(de^=q)>>>20&240,se=de<<24|de<<8&16711680|de>>>8&65280|de>>>24&240,de=q;for(var pe=0;pe>>26,de=de<<2|de>>>26):(se=se<<1|se>>>27,de=de<<1|de>>>27);var Le=I[(se&=-15)>>>28]|A[se>>>24&15]|P[se>>>20&15]|D[se>>>16&15]|T[se>>>12&15]|M[se>>>8&15]|k[se>>>4&15],Se=F[(de&=-15)>>>28]|G[de>>>24&15]|C[de>>>20&15]|O[de>>>16&15]|V[de>>>12&15]|L[de>>>8&15]|$[de>>>4&15];z[X++]=Le^(q=65535&(Se>>>16^Le)),z[X++]=Se^q<<16}}return z}(I),this._init=!0}},l("DES-ECB",y.cipher.modes.ecb),l("DES-CBC",y.cipher.modes.cbc),l("DES-CFB",y.cipher.modes.cfb),l("DES-OFB",y.cipher.modes.ofb),l("DES-CTR",y.cipher.modes.ctr),l("3DES-ECB",y.cipher.modes.ecb),l("3DES-CBC",y.cipher.modes.cbc),l("3DES-CFB",y.cipher.modes.cfb),l("3DES-OFB",y.cipher.modes.ofb),l("3DES-CTR",y.cipher.modes.ctr);var g=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],w=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],m=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],h=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],c=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],f=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],d=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],b=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function E(p,I,A,P){var T,D=32===p.length?3:9;T=3===D?P?[30,-2,-2]:[0,32,2]:P?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var M,k=I[0],F=I[1];k^=(M=252645135&(k>>>4^F))<<4,k^=(M=65535&(k>>>16^(F^=M)))<<16,k^=M=858993459&((F^=M)>>>2^k),k^=M=16711935&((F^=M<<2)>>>8^k),k=(k^=(M=1431655765&(k>>>1^(F^=M<<8)))<<1)<<1|k>>>31,F=(F^=M)<<1|F>>>31;for(var G=0;G>>4|F<<28)^p[V+1];M=k,k=F,F=M^(w[L>>>24&63]|h[L>>>16&63]|f[L>>>8&63]|b[63&L]|g[$>>>24&63]|m[$>>>16&63]|c[$>>>8&63]|d[63&$])}M=k,k=F,F=M}F=F>>>1|F<<31,F^=M=1431655765&((k=k>>>1|k<<31)>>>1^F),F^=(M=16711935&(F>>>8^(k^=M<<1)))<<8,F^=(M=858993459&(F>>>2^(k^=M)))<<2,F^=M=65535&((k^=M)>>>16^F),F^=M=252645135&((k^=M<<16)>>>4^F),A[0]=k^=M<<4,A[1]=F}function v(p){var P,A="DES-"+((p=p||{}).mode||"CBC").toUpperCase(),D=(P=p.decrypt?y.cipher.createDecipher(A,p.key):y.cipher.createCipher(A,p.key)).start;return P.start=function(T,M){var k=null;M instanceof y.util.ByteBuffer&&(k=M,M={}),(M=M||{}).output=k,M.iv=T,D.call(P,M)},P}},8659:Y=>{Y.exports={options:{usePureJavaScript:!1}}},9032:(Y,U,x)=>{var y=x(8659);x(979),x(4747),(Y.exports=y.hmac=y.hmac||{}).create=function(){var g=null,w=null,m=null,h=null,c={start:function(f,d){if(null!==f)if("string"==typeof f){if(!((f=f.toLowerCase())in y.md.algorithms))throw new Error('Unknown hash algorithm "'+f+'"');w=y.md.algorithms[f].create()}else w=f;if(null===d)d=g;else{if("string"==typeof d)d=y.util.createBuffer(d);else if(y.util.isArray(d)){var b=d;d=y.util.createBuffer();for(var S=0;Sw.blockLength&&(w.start(),w.update(d.bytes()),d=w.digest()),m=y.util.createBuffer(),h=y.util.createBuffer(),E=d.length(),S=0;S{var l,y=x(8659);function m(W,Q,ee){this.data=[],null!=W&&("number"==typeof W?this.fromNumber(W,Q,ee):this.fromString(W,null==Q&&"string"!=typeof W?256:Q))}function h(){return new m(null)}function d(W,Q,ee,le,ke,Ve){for(var tt=16383&Q,Ze=Q>>14;--Ve>=0;){var rn=16383&this.data[W],yr=this.data[W++]>>14,di=Ze*rn+yr*tt;ke=((rn=tt*rn+((16383&di)<<14)+ee.data[le]+ke)>>28)+(di>>14)+Ze*yr,ee.data[le++]=268435455&rn}return ke}Y.exports=y.jsbn=y.jsbn||{},y.jsbn.BigInteger=m,typeof navigator>"u"?(m.prototype.am=d,l=28):"Microsoft Internet Explorer"==navigator.appName?(m.prototype.am=function f(W,Q,ee,le,ke,Ve){for(var tt=32767&Q,Ze=Q>>15;--Ve>=0;){var rn=32767&this.data[W],yr=this.data[W++]>>15,di=Ze*rn+yr*tt;ke=((rn=tt*rn+((32767&di)<<15)+ee.data[le]+(1073741823&ke))>>>30)+(di>>>15)+Ze*yr+(ke>>>30),ee.data[le++]=1073741823&rn}return ke},l=30):"Netscape"!=navigator.appName?(m.prototype.am=function c(W,Q,ee,le,ke,Ve){for(;--Ve>=0;){var tt=Q*this.data[W++]+ee.data[le]+ke;ke=Math.floor(tt/67108864),ee.data[le++]=67108863&tt}return ke},l=26):(m.prototype.am=d,l=28),m.prototype.DB=l,m.prototype.DM=(1<>>16)&&(W=ee,Q+=16),0!=(ee=W>>8)&&(W=ee,Q+=8),0!=(ee=W>>4)&&(W=ee,Q+=4),0!=(ee=W>>2)&&(W=ee,Q+=2),0!=(ee=W>>1)&&(W=ee,Q+=1),Q}function pe(W){this.m=W}function Ee(W){this.m=W,this.mp=W.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,Q+=16),0==(255&W)&&(W>>=8,Q+=8),0==(15&W)&&(W>>=4,Q+=4),0==(3&W)&&(W>>=2,Q+=2),0==(1&W)&&++Q,Q}function en(W){for(var Q=0;0!=W;)W&=W-1,++Q;return Q}function ve(){}function yt(W){return W}function Ge(W){this.r2=h(),this.q3=h(),m.ONE.dlShiftTo(2*W.t,this.r2),this.mu=this.r2.divide(W),this.m=W}pe.prototype.convert=function Le(W){return W.s<0||W.compareTo(this.m)>=0?W.mod(this.m):W},pe.prototype.revert=function Se(W){return W},pe.prototype.reduce=function Pe(W){W.divRemTo(this.m,null,W)},pe.prototype.mulTo=function be(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},pe.prototype.sqrTo=function $e(W,Q){W.squareTo(Q),this.reduce(Q)},Ee.prototype.convert=function Te(W){var Q=h();return W.abs().dlShiftTo(this.m.t,Q),Q.divRemTo(this.m,null,Q),W.s<0&&Q.compareTo(m.ZERO)>0&&this.m.subTo(Q,Q),Q},Ee.prototype.revert=function xe(W){var Q=h();return W.copyTo(Q),this.reduce(Q),Q},Ee.prototype.reduce=function He(W){for(;W.t<=this.mt2;)W.data[W.t++]=0;for(var Q=0;Q>15)*this.mpl&this.um)<<15)&W.DM;for(W.data[ee=Q+this.m.t]+=this.m.am(0,le,W,Q,0,this.m.t);W.data[ee]>=W.DV;)W.data[ee]-=W.DV,W.data[++ee]++}W.clamp(),W.drShiftTo(this.m.t,W),W.compareTo(this.m)>=0&&W.subTo(this.m,W)},Ee.prototype.mulTo=function Je(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},Ee.prototype.sqrTo=function We(W,Q){W.squareTo(Q),this.reduce(Q)},m.prototype.copyTo=function P(W){for(var Q=this.t-1;Q>=0;--Q)W.data[Q]=this.data[Q];W.t=this.t,W.s=this.s},m.prototype.fromInt=function D(W){this.t=1,this.s=W<0?-1:0,W>0?this.data[0]=W:W<-1?this.data[0]=W+this.DV:this.t=0},m.prototype.fromString=function M(W,Q){var ee;if(16==Q)ee=4;else if(8==Q)ee=3;else if(256==Q)ee=8;else if(2==Q)ee=1;else if(32==Q)ee=5;else{if(4!=Q)return void this.fromRadix(W,Q);ee=2}this.t=0,this.s=0;for(var le=W.length,ke=!1,Ve=0;--le>=0;){var tt=8==ee?255&W[le]:A(W,le);tt<0?"-"==W.charAt(le)&&(ke=!0):(ke=!1,0==Ve?this.data[this.t++]=tt:Ve+ee>this.DB?(this.data[this.t-1]|=(tt&(1<>this.DB-Ve):this.data[this.t-1]|=tt<=this.DB&&(Ve-=this.DB))}8==ee&&0!=(128&W[0])&&(this.s=-1,Ve>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==W;)--this.t},m.prototype.dlShiftTo=function $(W,Q){var ee;for(ee=this.t-1;ee>=0;--ee)Q.data[ee+W]=this.data[ee];for(ee=W-1;ee>=0;--ee)Q.data[ee]=0;Q.t=this.t+W,Q.s=this.s},m.prototype.drShiftTo=function re(W,Q){for(var ee=W;ee=0;--Ze)Q.data[Ze+Ve+1]=this.data[Ze]>>le|tt,tt=(this.data[Ze]&ke)<=0;--Ze)Q.data[Ze]=0;Q.data[Ve]=tt,Q.t=this.t+Ve+1,Q.s=this.s,Q.clamp()},m.prototype.rShiftTo=function te(W,Q){Q.s=this.s;var ee=Math.floor(W/this.DB);if(ee>=this.t)Q.t=0;else{var le=W%this.DB,ke=this.DB-le,Ve=(1<>le;for(var tt=ee+1;tt>le;le>0&&(Q.data[this.t-ee-1]|=(this.s&Ve)<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le-=W.s}Q.s=le<0?-1:0,le<-1?Q.data[ee++]=this.DV+le:le>0&&(Q.data[ee++]=le),Q.t=ee,Q.clamp()},m.prototype.multiplyTo=function q(W,Q){var ee=this.abs(),le=W.abs(),ke=ee.t;for(Q.t=ke+le.t;--ke>=0;)Q.data[ke]=0;for(ke=0;ke=0;)W.data[ee]=0;for(ee=0;ee=Q.DV&&(W.data[ee+Q.t]-=Q.DV,W.data[ee+Q.t+1]=1)}W.t>0&&(W.data[W.t-1]+=Q.am(ee,Q.data[ee],W,2*ee,0,1)),W.s=0,W.clamp()},m.prototype.divRemTo=function se(W,Q,ee){var le=W.abs();if(!(le.t<=0)){var ke=this.abs();if(ke.t0?(le.lShiftTo(rn,Ve),ke.lShiftTo(rn,ee)):(le.copyTo(Ve),ke.copyTo(ee));var yr=Ve.t,di=Ve.data[yr-1];if(0!=di){var ei=di*(1<1?Ve.data[yr-2]>>this.F2:0),ns=this.FV/ei,Io=(1<=0&&(ee.data[ee.t++]=1,ee.subTo(Li,ee)),m.ONE.dlShiftTo(yr,Li),Li.subTo(Ve,Ve);Ve.t=0;){var Eu=ee.data[--ti]==di?this.DM:Math.floor(ee.data[ti]*ns+(ee.data[ti-1]+Xt)*Io);if((ee.data[ti]+=Ve.am(0,Eu,ee,bn,0,yr))0&&ee.rShiftTo(rn,ee),tt<0&&m.ZERO.subTo(ee,ee)}}},m.prototype.invDigit=function H(){if(this.t<1)return 0;var W=this.data[0];if(0==(1&W))return 0;var Q=3&W;return(Q=(Q=(Q=(Q=Q*(2-(15&W)*Q)&15)*(2-(255&W)*Q)&255)*(2-((65535&W)*Q&65535))&65535)*(2-W*Q%this.DV)%this.DV)>0?this.DV-Q:-Q},m.prototype.isEven=function Xe(){return 0==(this.t>0?1&this.data[0]:this.s)},m.prototype.exp=function Nt(W,Q){if(W>4294967295||W<1)return m.ONE;var ee=h(),le=h(),ke=Q.convert(this),Ve=V(W)-1;for(ke.copyTo(ee);--Ve>=0;)if(Q.sqrTo(ee,le),(W&1<0)Q.mulTo(le,ke,ee);else{var tt=ee;ee=le,le=tt}return Q.revert(ee)},m.prototype.toString=function F(W){if(this.s<0)return"-"+this.negate().toString(W);var Q;if(16==W)Q=4;else if(8==W)Q=3;else if(2==W)Q=1;else if(32==W)Q=5;else{if(4!=W)return this.toRadix(W);Q=2}var le,ee=(1<0)for(Ze>Ze)>0&&(ke=!0,Ve=I(le));tt>=0;)Ze>(Ze+=this.DB-Q)):(le=this.data[tt]>>(Ze-=Q)&ee,Ze<=0&&(Ze+=this.DB,--tt)),le>0&&(ke=!0),ke&&(Ve+=I(le));return ke?Ve:"0"},m.prototype.negate=function G(){var W=h();return m.ZERO.subTo(this,W),W},m.prototype.abs=function C(){return this.s<0?this.negate():this},m.prototype.compareTo=function O(W){var Q=this.s-W.s;if(0!=Q)return Q;var ee=this.t;if(0!=(Q=ee-W.t))return this.s<0?-Q:Q;for(;--ee>=0;)if(0!=(Q=this.data[ee]-W.data[ee]))return Q;return 0},m.prototype.bitLength=function L(){return this.t<=0?0:this.DB*(this.t-1)+V(this.data[this.t-1]^this.s&this.DM)},m.prototype.mod=function de(W){var Q=h();return this.abs().divRemTo(W,null,Q),this.s<0&&Q.compareTo(m.ZERO)>0&&W.subTo(Q,Q),Q},m.prototype.modPowInt=function pt(W,Q){var ee;return ee=W<256||Q.isEven()?new pe(Q):new Ee(Q),this.exp(W,ee)},m.ZERO=T(0),m.ONE=T(1),ve.prototype.convert=yt,ve.prototype.revert=yt,ve.prototype.mulTo=function Dt(W,Q,ee){W.multiplyTo(Q,ee)},ve.prototype.sqrTo=function gn(W,Q){W.squareTo(Q)},Ge.prototype.convert=function ht(W){if(W.s<0||W.t>2*this.m.t)return W.mod(this.m);if(W.compareTo(this.m)<0)return W;var Q=h();return W.copyTo(Q),this.reduce(Q),Q},Ge.prototype.revert=function Et(W){return W},Ge.prototype.reduce=function ut(W){for(W.drShiftTo(this.m.t-1,this.r2),W.t>this.m.t+1&&(W.t=this.m.t+1,W.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);W.compareTo(this.r2)<0;)W.dAddOffset(1,this.m.t+1);for(W.subTo(this.r2,W);W.compareTo(this.m)>=0;)W.subTo(this.m,W)},Ge.prototype.mulTo=function $t(W,Q,ee){W.multiplyTo(Q,ee),this.reduce(ee)},Ge.prototype.sqrTo=function St(W,Q){W.squareTo(Q),this.reduce(Q)};var Zn=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],ca=(1<<26)/Zn[Zn.length-1];m.prototype.chunkSize=function ie(W){return Math.floor(Math.LN2*this.DB/Math.log(W))},m.prototype.toRadix=function ye(W){if(null==W&&(W=10),0==this.signum()||W<2||W>36)return"0";var Q=this.chunkSize(W),ee=Math.pow(W,Q),le=T(ee),ke=h(),Ve=h(),tt="";for(this.divRemTo(le,ke,Ve);ke.signum()>0;)tt=(ee+Ve.intValue()).toString(W).substr(1)+tt,ke.divRemTo(le,ke,Ve);return Ve.intValue().toString(W)+tt},m.prototype.fromRadix=function me(W,Q){this.fromInt(0),null==Q&&(Q=10);for(var ee=this.chunkSize(Q),le=Math.pow(Q,ee),ke=!1,Ve=0,tt=0,Ze=0;Ze=ee&&(this.dMultiply(le),this.dAddOffset(tt,0),Ve=0,tt=0))}Ve>0&&(this.dMultiply(Math.pow(Q,Ve)),this.dAddOffset(tt,0)),ke&&m.ZERO.subTo(this,this)},m.prototype.fromNumber=function _e(W,Q,ee){if("number"==typeof Q)if(W<2)this.fromInt(1);else for(this.fromNumber(W,ee),this.testBit(W-1)||this.bitwiseTo(m.ONE.shiftLeft(W-1),ge,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(Q);)this.dAddOffset(2,0),this.bitLength()>W&&this.subTo(m.ONE.shiftLeft(W-1),this);else{var le=new Array,ke=7&W;le.length=1+(W>>3),Q.nextBytes(le),ke>0?le[0]&=(1<>=this.DB;if(W.t>=this.DB;le+=this.s}else{for(le+=this.s;ee>=this.DB;le+=W.s}Q.s=le<0?-1:0,le>0?Q.data[ee++]=le:le<-1&&(Q.data[ee++]=this.DV+le),Q.t=ee,Q.clamp()},m.prototype.dMultiply=function ct(W){this.data[this.t]=this.am(0,W-1,this,0,0,this.t),++this.t,this.clamp()},m.prototype.dAddOffset=function ce(W,Q){if(0!=W){for(;this.t<=Q;)this.data[this.t++]=0;for(this.data[Q]+=W;this.data[Q]>=this.DV;)this.data[Q]-=this.DV,++Q>=this.t&&(this.data[this.t++]=0),++this.data[Q]}},m.prototype.multiplyLowerTo=function Ye(W,Q,ee){var ke,le=Math.min(this.t+W.t,Q);for(ee.s=0,ee.t=le;le>0;)ee.data[--le]=0;for(ke=ee.t-this.t;le=0;)ee.data[le]=0;for(le=Math.max(Q-this.t,0);le0)if(0==Q)ee=this.data[0]%W;else for(var le=this.t-1;le>=0;--le)ee=(Q*ee+this.data[le])%W;return ee},m.prototype.millerRabin=function of(W){var Q=this.subtract(m.ONE),ee=Q.getLowestSetBit();if(ee<=0)return!1;for(var Ve,le=Q.shiftRight(ee),ke=function ua(){return{nextBytes:function(W){for(var Q=0;Q=0);var Ze=Ve.modPow(le,this);if(0!=Ze.compareTo(m.ONE)&&0!=Ze.compareTo(Q)){for(var rn=1;rn++>24},m.prototype.shortValue=function Hr(){return 0==this.t?this.s:this.data[0]<<16>>16},m.prototype.signum=function fe(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},m.prototype.toByteArray=function Ne(){var W=this.t,Q=new Array;Q[0]=this.s;var le,ee=this.DB-W*this.DB%8,ke=0;if(W-- >0)for(ee>ee)!=(this.s&this.DM)>>ee&&(Q[ke++]=le|this.s<=0;)ee<8?(le=(this.data[W]&(1<>(ee+=this.DB-8)):(le=this.data[W]>>(ee-=8)&255,ee<=0&&(ee+=this.DB,--W)),0!=(128&le)&&(le|=-256),0==ke&&(128&this.s)!=(128&le)&&++ke,(ke>0||le!=this.s)&&(Q[ke++]=le);return Q},m.prototype.equals=function Qe(W){return 0==this.compareTo(W)},m.prototype.min=function qe(W){return this.compareTo(W)<0?this:W},m.prototype.max=function it(W){return this.compareTo(W)>0?this:W},m.prototype.and=function we(W){var Q=h();return this.bitwiseTo(W,Ke,Q),Q},m.prototype.or=function De(W){var Q=h();return this.bitwiseTo(W,ge,Q),Q},m.prototype.xor=function Be(W){var Q=h();return this.bitwiseTo(W,Fe,Q),Q},m.prototype.andNot=function xt(W){var Q=h();return this.bitwiseTo(W,dt,Q),Q},m.prototype.not=function mt(){for(var W=h(),Q=0;Q=this.t?0!=this.s:0!=(this.data[Q]&1<1){var di=h();for(Ve.sqrTo(tt[1],di);Ze<=yr;)tt[Ze]=h(),Ve.mulTo(di,tt[Ze-2],tt[Ze]),Ze+=2}var ns,ti,ei=W.t-1,Io=!0,Xt=h();for(ee=V(W.data[ei])-1;ei>=0;){for(ee>=rn?ns=W.data[ei]>>ee-rn&yr:(ns=(W.data[ei]&(1<0&&(ns|=W.data[ei-1]>>this.DB+ee-rn)),Ze=le;0==(1&ns);)ns>>=1,--Ze;if((ee-=Ze)<0&&(ee+=this.DB,--ei),Io)tt[ns].copyTo(ke),Io=!1;else{for(;Ze>1;)Ve.sqrTo(ke,Xt),Ve.sqrTo(Xt,ke),Ze-=2;Ze>0?Ve.sqrTo(ke,Xt):(ti=ke,ke=Xt,Xt=ti),Ve.mulTo(Xt,tt[ns],ke)}for(;ei>=0&&0==(W.data[ei]&1<=0?(ee.subTo(le,ee),Q&&ke.subTo(tt,ke),Ve.subTo(Ze,Ve)):(le.subTo(ee,le),Q&&tt.subTo(ke,tt),Ze.subTo(Ve,Ze))}return 0!=le.compareTo(m.ONE)?m.ZERO:Ze.compareTo(W)>=0?Ze.subtract(W):Ze.signum()<0?(Ze.addTo(W,Ze),Ze.signum()<0?Ze.add(W):Ze):Ze},m.prototype.pow=function je(W){return this.exp(W,new ve)},m.prototype.gcd=function An(W){var Q=this.s<0?this.negate():this.clone(),ee=W.s<0?W.negate():W.clone();if(Q.compareTo(ee)<0){var le=Q;Q=ee,ee=le}var ke=Q.getLowestSetBit(),Ve=ee.getLowestSetBit();if(Ve<0)return Q;for(ke0&&(Q.rShiftTo(Ve,Q),ee.rShiftTo(Ve,ee));Q.signum()>0;)(ke=Q.getLowestSetBit())>0&&Q.rShiftTo(ke,Q),(ke=ee.getLowestSetBit())>0&&ee.rShiftTo(ke,ee),Q.compareTo(ee)>=0?(Q.subTo(ee,Q),Q.rShiftTo(1,Q)):(ee.subTo(Q,ee),ee.rShiftTo(1,ee));return Ve>0&&ee.lShiftTo(Ve,ee),ee},m.prototype.isProbablePrime=function Co(W){var Q,ee=this.abs();if(1==ee.t&&ee.data[0]<=Zn[Zn.length-1]){for(Q=0;Q{var y=x(8659);Y.exports=y.md=y.md||{},y.md.algorithms=y.md.algorithms||{}},9386:(Y,U,x)=>{var y=x(8659);x(8449),Y.exports=y.mgf=y.mgf||{},y.mgf.mgf1=y.mgf1},8449:(Y,U,x)=>{var y=x(8659);x(4747),y.mgf=y.mgf||{},(Y.exports=y.mgf.mgf1=y.mgf1=y.mgf1||{}).create=function(g){return{generate:function(m,h){for(var c=new y.util.ByteBuffer,f=Math.ceil(h/g.digestLength),d=0;d{var y=x(8659);y.pki=y.pki||{};var l=Y.exports=y.pki.oids=y.oids=y.oids||{};function g(m,h){l[m]=h,l[h]=m}function w(m,h){l[m]=h}g("1.2.840.113549.1.1.1","rsaEncryption"),g("1.2.840.113549.1.1.4","md5WithRSAEncryption"),g("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),g("1.2.840.113549.1.1.7","RSAES-OAEP"),g("1.2.840.113549.1.1.8","mgf1"),g("1.2.840.113549.1.1.9","pSpecified"),g("1.2.840.113549.1.1.10","RSASSA-PSS"),g("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),g("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),g("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),g("1.3.101.112","EdDSA25519"),g("1.2.840.10040.4.3","dsa-with-sha1"),g("1.3.14.3.2.7","desCBC"),g("1.3.14.3.2.26","sha1"),g("1.3.14.3.2.29","sha1WithRSASignature"),g("2.16.840.1.101.3.4.2.1","sha256"),g("2.16.840.1.101.3.4.2.2","sha384"),g("2.16.840.1.101.3.4.2.3","sha512"),g("2.16.840.1.101.3.4.2.4","sha224"),g("2.16.840.1.101.3.4.2.5","sha512-224"),g("2.16.840.1.101.3.4.2.6","sha512-256"),g("1.2.840.113549.2.2","md2"),g("1.2.840.113549.2.5","md5"),g("1.2.840.113549.1.7.1","data"),g("1.2.840.113549.1.7.2","signedData"),g("1.2.840.113549.1.7.3","envelopedData"),g("1.2.840.113549.1.7.4","signedAndEnvelopedData"),g("1.2.840.113549.1.7.5","digestedData"),g("1.2.840.113549.1.7.6","encryptedData"),g("1.2.840.113549.1.9.1","emailAddress"),g("1.2.840.113549.1.9.2","unstructuredName"),g("1.2.840.113549.1.9.3","contentType"),g("1.2.840.113549.1.9.4","messageDigest"),g("1.2.840.113549.1.9.5","signingTime"),g("1.2.840.113549.1.9.6","counterSignature"),g("1.2.840.113549.1.9.7","challengePassword"),g("1.2.840.113549.1.9.8","unstructuredAddress"),g("1.2.840.113549.1.9.14","extensionRequest"),g("1.2.840.113549.1.9.20","friendlyName"),g("1.2.840.113549.1.9.21","localKeyId"),g("1.2.840.113549.1.9.22.1","x509Certificate"),g("1.2.840.113549.1.12.10.1.1","keyBag"),g("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),g("1.2.840.113549.1.12.10.1.3","certBag"),g("1.2.840.113549.1.12.10.1.4","crlBag"),g("1.2.840.113549.1.12.10.1.5","secretBag"),g("1.2.840.113549.1.12.10.1.6","safeContentsBag"),g("1.2.840.113549.1.5.13","pkcs5PBES2"),g("1.2.840.113549.1.5.12","pkcs5PBKDF2"),g("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),g("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),g("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),g("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),g("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),g("1.2.840.113549.2.7","hmacWithSHA1"),g("1.2.840.113549.2.8","hmacWithSHA224"),g("1.2.840.113549.2.9","hmacWithSHA256"),g("1.2.840.113549.2.10","hmacWithSHA384"),g("1.2.840.113549.2.11","hmacWithSHA512"),g("1.2.840.113549.3.7","des-EDE3-CBC"),g("2.16.840.1.101.3.4.1.2","aes128-CBC"),g("2.16.840.1.101.3.4.1.22","aes192-CBC"),g("2.16.840.1.101.3.4.1.42","aes256-CBC"),g("2.5.4.3","commonName"),g("2.5.4.4","surname"),g("2.5.4.5","serialNumber"),g("2.5.4.6","countryName"),g("2.5.4.7","localityName"),g("2.5.4.8","stateOrProvinceName"),g("2.5.4.9","streetAddress"),g("2.5.4.10","organizationName"),g("2.5.4.11","organizationalUnitName"),g("2.5.4.12","title"),g("2.5.4.13","description"),g("2.5.4.15","businessCategory"),g("2.5.4.17","postalCode"),g("2.5.4.42","givenName"),g("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),g("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),g("2.16.840.1.113730.1.1","nsCertType"),g("2.16.840.1.113730.1.13","nsComment"),w("2.5.29.1","authorityKeyIdentifier"),w("2.5.29.2","keyAttributes"),w("2.5.29.3","certificatePolicies"),w("2.5.29.4","keyUsageRestriction"),w("2.5.29.5","policyMapping"),w("2.5.29.6","subtreesConstraint"),w("2.5.29.7","subjectAltName"),w("2.5.29.8","issuerAltName"),w("2.5.29.9","subjectDirectoryAttributes"),w("2.5.29.10","basicConstraints"),w("2.5.29.11","nameConstraints"),w("2.5.29.12","policyConstraints"),w("2.5.29.13","basicConstraints"),g("2.5.29.14","subjectKeyIdentifier"),g("2.5.29.15","keyUsage"),w("2.5.29.16","privateKeyUsagePeriod"),g("2.5.29.17","subjectAltName"),g("2.5.29.18","issuerAltName"),g("2.5.29.19","basicConstraints"),w("2.5.29.20","cRLNumber"),w("2.5.29.21","cRLReason"),w("2.5.29.22","expirationDate"),w("2.5.29.23","instructionCode"),w("2.5.29.24","invalidityDate"),w("2.5.29.25","cRLDistributionPoints"),w("2.5.29.26","issuingDistributionPoint"),w("2.5.29.27","deltaCRLIndicator"),w("2.5.29.28","issuingDistributionPoint"),w("2.5.29.29","certificateIssuer"),w("2.5.29.30","nameConstraints"),g("2.5.29.31","cRLDistributionPoints"),g("2.5.29.32","certificatePolicies"),w("2.5.29.33","policyMappings"),w("2.5.29.34","policyConstraints"),g("2.5.29.35","authorityKeyIdentifier"),w("2.5.29.36","policyConstraints"),g("2.5.29.37","extKeyUsage"),w("2.5.29.46","freshestCRL"),w("2.5.29.54","inhibitAnyPolicy"),g("1.3.6.1.4.1.11129.2.4.2","timestampList"),g("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),g("1.3.6.1.5.5.7.3.1","serverAuth"),g("1.3.6.1.5.5.7.3.2","clientAuth"),g("1.3.6.1.5.5.7.3.3","codeSigning"),g("1.3.6.1.5.5.7.3.4","emailProtection"),g("1.3.6.1.5.5.7.3.8","timeStamping")},2158:(Y,U,x)=>{var y=x(8659);if(x(1298),x(7791),x(279),x(979),x(6078),x(7949),x(8604),x(8365),x(209),x(5517),x(4747),typeof l>"u")var l=y.jsbn.BigInteger;var g=y.asn1,w=y.pki=y.pki||{};Y.exports=w.pbe=y.pbe=y.pbe||{};var m=w.oids,h={name:"EncryptedPrivateKeyInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},c={name:"PBES2Algorithms",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},f={name:"pkcs-12PbeParams",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"iterations"}]};function d(v,p){return v.start().update(p).digest().getBytes()}function b(v){var p;if(v){if(!(p=w.oids[g.derToOid(v)])){var I=new Error("Unsupported PRF OID.");throw I.oid=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}}else p="hmacWithSHA1";return S(p)}function S(v){var p=y.md;switch(v){case"hmacWithSHA224":p=y.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":v=v.substr(8).toLowerCase();break;default:var I=new Error("Unsupported PRF algorithm.");throw I.algorithm=v,I.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],I}if(!p||!(v in p))throw new Error("Unknown hash algorithm: "+v);return p[v].create()}w.encryptPrivateKeyInfo=function(v,p,I){(I=I||{}).saltSize=I.saltSize||8,I.count=I.count||2048,I.algorithm=I.algorithm||"aes128",I.prfAlgorithm=I.prfAlgorithm||"sha1";var T,M,k,A=y.random.getBytesSync(I.saltSize),P=I.count,D=g.integerToDer(P);if(0===I.algorithm.indexOf("aes")||"des"===I.algorithm){var F,G,C;switch(I.algorithm){case"aes128":T=16,F=16,G=m["aes128-CBC"],C=y.aes.createEncryptionCipher;break;case"aes192":T=24,F=16,G=m["aes192-CBC"],C=y.aes.createEncryptionCipher;break;case"aes256":T=32,F=16,G=m["aes256-CBC"],C=y.aes.createEncryptionCipher;break;case"des":T=8,F=8,G=m.desCBC,C=y.des.createEncryptionCipher;break;default:throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O}var V="hmacWith"+I.prfAlgorithm.toUpperCase(),L=S(V),$=y.pkcs5.pbkdf2(p,A,P,T,L),re=y.random.getBytesSync(F);(z=C($)).start(re),z.update(g.toDer(v)),z.finish(),k=z.output.getBytes();var te=function E(v,p,I,A){var P=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,v),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,p.getBytes())]);return"hmacWithSHA1"!==A&&P.value.push(g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,y.util.hexToBytes(I.toString(16))),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(w.oids[A]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")])),P}(A,D,T,V);M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBES2).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m.pkcs5PBKDF2).getBytes()),te]),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(G).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,re)])])])}else{var O;if("3des"!==I.algorithm)throw(O=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=I.algorithm,O;T=24;var z,X=new y.util.ByteBuffer(A);$=w.pbe.generatePkcs12Key(p,X,1,P,T),re=w.pbe.generatePkcs12Key(p,X,2,P,T),(z=y.des.createEncryptionCipher($)).start(re),z.update(g.toDer(v)),z.finish(),k=z.output.getBytes(),M=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(m["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,A),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,D.getBytes())])])}return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[M,g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,k)])},w.decryptPrivateKeyInfo=function(v,p){var I=null,A={},P=[];if(!g.validate(v,h,A,P)){var D=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw D.errors=P,D}var T=g.derToOid(A.encryptionOid),M=w.pbe.getCipher(T,A.encryptionParams,p),k=y.util.createBuffer(A.encryptedData);return M.update(k),M.finish()&&(I=g.fromDer(M.output)),I},w.encryptedPrivateKeyToPem=function(v,p){var I={type:"ENCRYPTED PRIVATE KEY",body:g.toDer(v).getBytes()};return y.pem.encode(I,{maxline:p})},w.encryptedPrivateKeyFromPem=function(v){var p=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==p.type){var I=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw I.headerType=p.type,I}if(p.procType&&"ENCRYPTED"===p.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return g.fromDer(p.body)},w.encryptRsaPrivateKey=function(v,p,I){if(!(I=I||{}).legacy){var A=w.wrapRsaPrivateKey(w.privateKeyToAsn1(v));return A=w.encryptPrivateKeyInfo(A,p,I),w.encryptedPrivateKeyToPem(A)}var P,D,T,M;switch(I.algorithm){case"aes128":P="AES-128-CBC",T=16,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes192":P="AES-192-CBC",T=24,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"aes256":P="AES-256-CBC",T=32,D=y.random.getBytesSync(16),M=y.aes.createEncryptionCipher;break;case"3des":P="DES-EDE3-CBC",T=24,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;case"des":P="DES-CBC",T=8,D=y.random.getBytesSync(8),M=y.des.createEncryptionCipher;break;default:var k=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+I.algorithm+'".');throw k.algorithm=I.algorithm,k}var G=M(y.pbe.opensslDeriveBytes(p,D.substr(0,8),T));G.start(D),G.update(g.toDer(w.privateKeyToAsn1(v))),G.finish();var C={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:P,parameters:y.util.bytesToHex(D).toUpperCase()},body:G.output.getBytes()};return y.pem.encode(C)},w.decryptRsaPrivateKey=function(v,p){var I=null,A=y.pem.decode(v)[0];if("ENCRYPTED PRIVATE KEY"!==A.type&&"PRIVATE KEY"!==A.type&&"RSA PRIVATE KEY"!==A.type)throw(P=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=P,P;if(A.procType&&"ENCRYPTED"===A.procType.type){var D,T;switch(A.dekInfo.algorithm){case"DES-CBC":D=8,T=y.des.createDecryptionCipher;break;case"DES-EDE3-CBC":D=24,T=y.des.createDecryptionCipher;break;case"AES-128-CBC":D=16,T=y.aes.createDecryptionCipher;break;case"AES-192-CBC":D=24,T=y.aes.createDecryptionCipher;break;case"AES-256-CBC":D=32,T=y.aes.createDecryptionCipher;break;case"RC2-40-CBC":D=5,T=function(C){return y.rc2.createDecryptionCipher(C,40)};break;case"RC2-64-CBC":D=8,T=function(C){return y.rc2.createDecryptionCipher(C,64)};break;case"RC2-128-CBC":D=16,T=function(C){return y.rc2.createDecryptionCipher(C,128)};break;default:var P;throw(P=new Error('Could not decrypt private key; unsupported encryption algorithm "'+A.dekInfo.algorithm+'".')).algorithm=A.dekInfo.algorithm,P}var M=y.util.hexToBytes(A.dekInfo.parameters),F=T(y.pbe.opensslDeriveBytes(p,M.substr(0,8),D));if(F.start(M),F.update(y.util.createBuffer(A.body)),!F.finish())return I;I=F.output.getBytes()}else I=A.body;return null!==(I="ENCRYPTED PRIVATE KEY"===A.type?w.decryptPrivateKeyInfo(g.fromDer(I),p):g.fromDer(I))&&(I=w.privateKeyFromAsn1(I)),I},w.pbe.generatePkcs12Key=function(v,p,I,A,P,D){var T,M;if(typeof D>"u"||null===D){if(!("sha1"in y.md))throw new Error('"sha1" hash algorithm unavailable.');D=y.md.sha1.create()}var k=D.digestLength,F=D.blockLength,G=new y.util.ByteBuffer,C=new y.util.ByteBuffer;if(null!=v){for(M=0;M=0;M--)be>>=8,be+=pe.at(M)+Pe.at(M),Pe.setAt(M,255&be);Se.putBuffer(Pe)}X=Se,G.putBuffer(se)}return G.truncate(G.length()-P),G},w.pbe.getCipher=function(v,p,I){switch(v){case w.oids.pkcs5PBES2:return w.pbe.getCipherForPBES2(v,p,I);case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case w.oids["pbewithSHAAnd40BitRC2-CBC"]:return w.pbe.getCipherForPKCS12PBE(v,p,I);default:var A=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw A.oid=v,A.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],A}},w.pbe.getCipherForPBES2=function(v,p,I){var D,A={},P=[];if(!g.validate(p,c,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;if((v=g.derToOid(A.kdfOid))!==w.oids.pkcs5PBKDF2)throw(D=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=v,D.supportedOids=["pkcs5PBKDF2"],D;if((v=g.derToOid(A.encOid))!==w.oids["aes128-CBC"]&&v!==w.oids["aes192-CBC"]&&v!==w.oids["aes256-CBC"]&&v!==w.oids["des-EDE3-CBC"]&&v!==w.oids.desCBC)throw(D=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=v,D.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],D;var k,F,T=A.kdfSalt,M=y.util.createBuffer(A.kdfIterationCount);switch(M=M.getInt(M.length()<<3),w.oids[v]){case"aes128-CBC":k=16,F=y.aes.createDecryptionCipher;break;case"aes192-CBC":k=24,F=y.aes.createDecryptionCipher;break;case"aes256-CBC":k=32,F=y.aes.createDecryptionCipher;break;case"des-EDE3-CBC":k=24,F=y.des.createDecryptionCipher;break;case"desCBC":k=8,F=y.des.createDecryptionCipher}var G=b(A.prfOid),C=y.pkcs5.pbkdf2(I,T,M,k,G),O=A.encIv,V=F(C);return V.start(O),V},w.pbe.getCipherForPKCS12PBE=function(v,p,I){var A={},P=[];if(!g.validate(p,f,A,P))throw(D=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=P,D;var k,F,G,T=y.util.createBuffer(A.salt),M=y.util.createBuffer(A.iterations);switch(M=M.getInt(M.length()<<3),v){case w.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:k=24,F=8,G=y.des.startDecrypting;break;case w.oids["pbewithSHAAnd40BitRC2-CBC"]:k=5,F=8,G=function($,re){var z=y.rc2.createDecryptionCipher($,40);return z.start(re,null),z};break;default:var D;throw(D=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=v,D}var C=b(A.prfOid),O=w.pbe.generatePkcs12Key(I,T,1,M,k,C);return C.start(),G(O,w.pbe.generatePkcs12Key(I,T,2,M,F,C))},w.pbe.opensslDeriveBytes=function(v,p,I,A){if(typeof A>"u"||null===A){if(!("md5"in y.md))throw new Error('"md5" hash algorithm unavailable.');A=y.md.md5.create()}null===p&&(p="");for(var P=[d(A,v+p)],D=16,T=1;D{var y=x(8659);x(9032),x(979),x(4747);var g,l=y.pkcs5=y.pkcs5||{};y.util.isNodejs&&!y.options.usePureJavaScript&&(g=x(5819)),Y.exports=y.pbkdf2=l.pbkdf2=function(w,m,h,c,f,d){if("function"==typeof f&&(d=f,f=null),y.util.isNodejs&&!y.options.usePureJavaScript&&g.pbkdf2&&(null===f||"object"!=typeof f)&&(g.pbkdf2Sync.length>4||!f||"sha1"===f))return"string"!=typeof f&&(f="sha1"),w=Buffer.from(w,"binary"),m=Buffer.from(m,"binary"),d?4===g.pbkdf2Sync.length?g.pbkdf2(w,m,h,c,function(G,C){if(G)return d(G);d(null,C.toString("binary"))}):g.pbkdf2(w,m,h,c,f,function(G,C){if(G)return d(G);d(null,C.toString("binary"))}):4===g.pbkdf2Sync.length?g.pbkdf2Sync(w,m,h,c).toString("binary"):g.pbkdf2Sync(w,m,h,c,f).toString("binary");if((typeof f>"u"||null===f)&&(f="sha1"),"string"==typeof f){if(!(f in y.md.algorithms))throw new Error("Unknown hash algorithm: "+f);f=y.md[f].create()}var b=f.digestLength;if(c>4294967295*b){var S=new Error("Derived key is too long.");if(d)return d(S);throw S}var E=Math.ceil(c/b),v=c-(E-1)*b,p=y.hmac.create();p.start(f,w);var A,P,D,I="";if(!d){for(var T=1;T<=E;++T){p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes();for(var M=2;M<=h;++M)p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P;I+=TE)return d(null,I);p.start(null,null),p.update(m),p.update(y.util.int32ToBytes(T)),A=D=p.digest().getBytes(),M=2,F()}function F(){if(M<=h)return p.start(null,null),p.update(D),P=p.digest().getBytes(),A=y.util.xorBytes(A,P,b),D=P,++M,y.util.setImmediate(F);I+=T{var y=x(8659);x(4747);var l=Y.exports=y.pem=y.pem||{};function g(m){for(var h=m.name+": ",c=[],f=function(v,p){return" "+p},d=0;d65&&-1!==S){var E=h[S];","===E?(++S,h=h.substr(0,S)+"\r\n "+h.substr(S)):h=h.substr(0,S)+"\r\n"+E+h.substr(S+1),b=d-S-1,S=-1,++d}else(" "===h[d]||"\t"===h[d]||","===h[d])&&(S=d);return h}function w(m){return m.replace(/^\s+/,"")}l.encode=function(m,h){h=h||{};var f,c="-----BEGIN "+m.type+"-----\r\n";if(m.procType&&(c+=g(f={name:"Proc-Type",values:[String(m.procType.version),m.procType.type]})),m.contentDomain&&(c+=g(f={name:"Content-Domain",values:[m.contentDomain]})),m.dekInfo&&(f={name:"DEK-Info",values:[m.dekInfo.algorithm]},m.dekInfo.parameters&&f.values.push(m.dekInfo.parameters),c+=g(f)),m.headers)for(var d=0;d{var y=x(8659);x(4747),x(8365),x(7690);var l=Y.exports=y.pkcs1=y.pkcs1||{};function g(w,m,h){h||(h=y.md.sha1.create());for(var c="",f=Math.ceil(m/h.digestLength),d=0;d>24&255,d>>16&255,d>>8&255,255&d);h.start(),h.update(w+b),c+=h.digest().getBytes()}return c.substring(0,m)}l.encode_rsa_oaep=function(w,m,h){var c,f,d,b;"string"==typeof h?(c=h,f=arguments[3]||void 0,d=arguments[4]||void 0):h&&(c=h.label||void 0,f=h.seed||void 0,d=h.md||void 0,h.mgf1&&h.mgf1.md&&(b=h.mgf1.md)),d?d.start():d=y.md.sha1.create(),b||(b=d);var S=Math.ceil(w.n.bitLength()/8),E=S-2*d.digestLength-2;if(m.length>E)throw(v=new Error("RSAES-OAEP input message length is too long.")).length=m.length,v.maxLength=E,v;c||(c=""),d.update(c,"raw");for(var p=d.digest(),I="",A=E-m.length,P=0;P{var y=x(8659);x(1298),x(7791),x(279),x(6078),x(8604),x(4957),x(8365),x(4747),x(5911);var l=y.asn1,g=Y.exports=y.pkcs7=y.pkcs7||{};function w(A){var P={},D=[];if(!l.validate(A,g.asn1.recipientInfoValidator,P,D)){var T=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw T.errors=D,T}return{version:P.version.charCodeAt(0),issuer:y.pki.RDNAttributesAsArray(P.issuer),serialNumber:y.util.createBuffer(P.serial).toHex(),encryptedContent:{algorithm:l.derToOid(P.encAlgorithm),parameter:P.encParameter?P.encParameter.value:void 0,content:P.encKey}}}function m(A){return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(A.version).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[y.pki.distinguishedNameToAsn1({attributes:A.issuer}),l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,y.util.hexToBytes(A.serialNumber))]),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(A.encryptedContent.algorithm).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")]),l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,A.encryptedContent.content)])}function c(A){for(var P=[],D=0;D0){for(var D=l.create(l.Class.CONTEXT_SPECIFIC,1,!0,[]),T=0;T=D&&M0&&F.value[0].value.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!0,T)),k.length>0&&F.value[0].value.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,k)),F.value[0].value.push(l.create(l.Class.UNIVERSAL,l.Type.SET,!0,A.signerInfos)),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(A.type).getBytes()),F])},addSigner:function(T){var M=T.issuer,k=T.serialNumber;if(T.certificate){var F=T.certificate;"string"==typeof F&&(F=y.pki.certificateFromPem(F)),M=F.issuer.attributes,k=F.serialNumber}var G=T.key;if(!G)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof G&&(G=y.pki.privateKeyFromPem(G));var C=T.digestAlgorithm||y.pki.oids.sha1;switch(C){case y.pki.oids.sha1:case y.pki.oids.sha256:case y.pki.oids.sha384:case y.pki.oids.sha512:case y.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+C)}var O=T.authenticatedAttributes||[];if(O.length>0){for(var V=!1,L=!1,$=0;${var y=x(8659);x(7791),x(4747);var l=y.asn1,g=Y.exports=y.pkcs7asn1=y.pkcs7asn1||{};y.pkcs7=y.pkcs7||{},y.pkcs7.asn1=g;var w={name:"ContentInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};g.contentInfoValidator=w;var m={name:"EncryptedContentInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};g.envelopedDataValidator={name:"EnvelopedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(m)},g.encryptedDataValidator={name:"EncryptedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"}].concat(m)},g.signedDataValidator={name:"SignedData",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},w,{name:"SignedData.Certificates",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,capture:"signerInfos",optional:!0,value:[{name:"SignerInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:l.Class.UNIVERSAL,type:l.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]}]}]},g.recipientInfoValidator={name:"RecipientInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:l.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:l.Class.UNIVERSAL,type:l.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},9709:(Y,U,x)=>{var y=x(8659);x(4747),x(730),x(8365),function(){if(y.prime)Y.exports=y.prime;else{var l=Y.exports=y.prime=y.prime||{},g=y.jsbn.BigInteger,w=[6,4,2,4,2,4,6,2],m=new g(null);m.fromInt(30);var h=function(v,p){return v|p};l.generateProbablePrime=function(v,p,I){"function"==typeof p&&(I=p,p={});var A=(p=p||{}).algorithm||"PRIMEINC";"string"==typeof A&&(A={name:A}),A.options=A.options||{};var P=p.prng||y.random;if("PRIMEINC"===A.name)return function c(v,p,I,A){return"workers"in I?function b(v,p,I,A){if(typeof Worker>"u")return f(v,p,I,A);var P=S(v,p),D=I.workers,T=I.workLoad||100,M=30*T/8,k=I.workerScript||"forge/prime.worker.js";if(-1===D)return y.util.estimateCores(function(G,C){G&&(C=2),D=C-1,F()});function F(){D=Math.max(1,D);for(var G=[],C=0;Cv&&(P=S(v,p));var te=P.toString(16);$.target.postMessage({hex:te,workLoad:T}),P.dAddOffset(M,0)}}}F()}(v,p,I,A):f(v,p,I,A)}(v,{nextBytes:function(T){for(var M=P.getBytesSync(T.length),k=0;kp&&(v=S(p,I)),v.isProbablePrime(P))return T(null,v);v.dAddOffset(w[A++%8],0)}while(D<0||+new Date-M{var y=x(8659);x(4747);var l=null;y.util.isNodejs&&!y.options.usePureJavaScript&&!process.versions["node-webkit"]&&(l=x(5819)),(Y.exports=y.prng=y.prng||{}).create=function(w){for(var m={plugin:w,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},h=w.md,c=new Array(32),f=0;f<32;++f)c[f]=h.create();function b(){if(m.pools[0].messageLength>=32)return S();m.collect(m.seedFileSync(32-m.pools[0].messageLength<<5)),S()}function S(){m.reseeds=4294967295===m.reseeds?0:m.reseeds+1;var v=m.plugin.md.create();v.update(m.keyBytes);for(var p=1,I=0;I<32;++I)m.reseeds%p==0&&(v.update(m.pools[I].digest().getBytes()),m.pools[I].start()),p<<=1;m.keyBytes=v.digest().getBytes(),v.start(),v.update(m.keyBytes);var A=v.digest().getBytes();m.key=m.plugin.formatKey(m.keyBytes),m.seed=m.plugin.formatSeed(A),m.generated=0}function E(v){var p=null,I=y.util.globalScope,A=I.crypto||I.msCrypto;A&&A.getRandomValues&&(p=function(O){return A.getRandomValues(O)});var P=y.util.createBuffer();if(p)for(;P.length()>16)))<<16,C=4294967295&(F=(2147483647&(F+=k>>15))+(F>>31)),M=0;M<3;++M)G=C>>>(M<<3),G^=Math.floor(256*Math.random()),P.putByte(255&G);return P.getBytes(v)}return m.pools=c,m.pool=0,m.generate=function(v,p){if(!p)return m.generateSync(v);var I=m.plugin.cipher,A=m.plugin.increment,P=m.plugin.formatKey,D=m.plugin.formatSeed,T=y.util.createBuffer();m.key=null,function M(k){if(k)return p(k);if(T.length()>=v)return p(null,T.getBytes(v));if(m.generated>1048575&&(m.key=null),null===m.key)return y.util.nextTick(function(){!function d(v){if(m.pools[0].messageLength>=32)return S(),v();m.seedFile(32-m.pools[0].messageLength<<5,function(I,A){if(I)return v(I);m.collect(A),S(),v()})}(M)});var F=I(m.key,m.seed);m.generated+=F.length,T.putBytes(F),m.key=P(I(m.key,A(m.seed))),m.seed=D(I(m.key,m.seed)),y.util.setImmediate(M)}()},m.generateSync=function(v){var p=m.plugin.cipher,I=m.plugin.increment,A=m.plugin.formatKey,P=m.plugin.formatSeed;m.key=null;for(var D=y.util.createBuffer();D.length()1048575&&(m.key=null),null===m.key&&b();var T=p(m.key,m.seed);m.generated+=T.length,D.putBytes(T),m.key=A(p(m.key,I(m.seed))),m.seed=P(p(m.key,m.seed))}return D.getBytes(v)},l?(m.seedFile=function(v,p){l.randomBytes(v,function(I,A){if(I)return p(I);p(null,A.toString())})},m.seedFileSync=function(v){return l.randomBytes(v).toString()}):(m.seedFile=function(v,p){try{p(null,E(v))}catch(I){p(I)}},m.seedFileSync=E),m.collect=function(v){for(var p=v.length,I=0;I>A&255);m.collect(I)},m.registerWorker=function(v){v===self?m.seedFile=function(I,A){self.addEventListener("message",function P(D){var T=D.data;T.forge&&T.forge.prng&&(self.removeEventListener("message",P),A(T.forge.prng.err,T.forge.prng.bytes))}),self.postMessage({forge:{prng:{needed:I}}})}:v.addEventListener("message",function(I){var A=I.data;A.forge&&A.forge.prng&&m.seedFile(A.forge.prng.needed,function(P,D){v.postMessage({forge:{prng:{err:P,bytes:D}}})})})},m}},7256:(Y,U,x)=>{var y=x(8659);x(8365),x(4747),(Y.exports=y.pss=y.pss||{}).create=function(g){3===arguments.length&&(g={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var f,w=g.md,m=g.mgf,h=w.digestLength,c=g.salt||null;if("string"==typeof c&&(c=y.util.createBuffer(c)),"saltLength"in g)f=g.saltLength;else{if(null===c)throw new Error("Salt length not specified or specific salt not given.");f=c.length()}if(null!==c&&c.length()!==f)throw new Error("Given salt length does not match length of given salt.");var d=g.prng||y.random,b={encode:function(S,E){var v,P,p=E-1,I=Math.ceil(p/8),A=S.digest().getBytes();if(I>8*I-p&255;return(C=String.fromCharCode(C.charCodeAt(0)&~O)+C.substr(1))+T+String.fromCharCode(188)},verify:function(S,E,v){var p,I=v-1,A=Math.ceil(I/8);if(E=E.substr(-A),A>8*A-I&255;if(0!=(D.charCodeAt(0)&M))throw new Error("Bits beyond keysize not zero as expected.");var k=m.generate(T,P),F="";for(p=0;p{var y=x(8659);x(1298),x(1594),x(4473),x(4747),y.random&&y.random.getBytes?Y.exports=y.random:function(l){var g={},w=new Array(4),m=y.util.createBuffer();function h(){var v=y.prng.create(g);return v.getBytes=function(p,I){return v.generate(p,I)},v.getBytesSync=function(p){return v.generate(p)},v}g.formatKey=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),y.aes._expandKey(v,!1)},g.formatSeed=function(v){var p=y.util.createBuffer(v);return(v=new Array(4))[0]=p.getInt32(),v[1]=p.getInt32(),v[2]=p.getInt32(),v[3]=p.getInt32(),v},g.cipher=function(v,p){return y.aes._updateBlock(v,p,w,!1),m.putInt32(w[0]),m.putInt32(w[1]),m.putInt32(w[2]),m.putInt32(w[3]),m.getBytes()},g.increment=function(v){return++v[3],v},g.md=y.md.sha256;var c=h(),f=null,d=y.util.globalScope,b=d.crypto||d.msCrypto;if(b&&b.getRandomValues&&(f=function(v){return b.getRandomValues(v)}),y.options.usePureJavaScript||!y.util.isNodejs&&!f){if(typeof window>"u"||window,c.collectInt(+new Date,32),typeof navigator<"u"){var S="";for(var E in navigator)try{"string"==typeof navigator[E]&&(S+=navigator[E])}catch{}c.collect(S),S=null}l&&(l().mousemove(function(v){c.collectInt(v.clientX,16),c.collectInt(v.clientY,16)}),l().keypress(function(v){c.collectInt(v.charCode,8)}))}if(y.random)for(var E in c)y.random[E]=c[E];else y.random=c;y.random.createInstance=h,Y.exports=y.random}(typeof jQuery<"u"?jQuery:null)},209:(Y,U,x)=>{var y=x(8659);x(4747);var l=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],g=[1,2,3,5],w=function(c,f){return c<>16-f},m=function(c,f){return(65535&c)>>f|c<<16-f&65535};Y.exports=y.rc2=y.rc2||{},y.rc2.expandKey=function(c,f){"string"==typeof c&&(c=y.util.createBuffer(c)),f=f||128;var p,d=c,b=c.length(),S=f,E=Math.ceil(S/8),v=255>>(7&S);for(p=b;p<128;p++)d.putByte(l[d.at(p-1)+d.at(p-b)&255]);for(d.setAt(128-E,l[d.at(128-E)&v]),p=127-E;p>=0;p--)d.setAt(p,l[d.at(p+1)^d.at(p+E)]);return d};var h=function(c,f,d){var p,I,A,P,b=!1,S=null,E=null,v=null,D=[];for(c=y.rc2.expandKey(c,f),A=0;A<64;A++)D.push(c.getInt16Le());d?(p=function(k){for(A=0;A<4;A++)k[A]+=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),k[A]=w(k[A],g[A]),P++},I=function(k){for(A=0;A<4;A++)k[A]+=D[63&k[(A+3)%4]]}):(p=function(k){for(A=3;A>=0;A--)k[A]=m(k[A],g[A]),k[A]-=D[P]+(k[(A+3)%4]&k[(A+2)%4])+(~k[(A+3)%4]&k[(A+1)%4]),P--},I=function(k){for(A=3;A>=0;A--)k[A]-=D[63&k[(A+3)%4]]});var T=function(k){var F=[];for(A=0;A<4;A++){var G=S.getInt16Le();null!==v&&(d?G^=v.getInt16Le():v.putInt16Le(G)),F.push(65535&G)}P=d?0:63;for(var C=0;C=8;)T([[5,p],[1,I],[6,p],[1,I],[5,p]])},finish:function(k){var F=!0;if(d)if(k)F=k(8,S,!d);else{var G=8===S.length()?8:8-S.length();S.fillWithByte(G,G)}if(F&&(b=!0,M.update()),!d&&(F=0===S.length()))if(k)F=k(8,E,!d);else{var C=E.length(),O=E.at(C-1);O>C?F=!1:E.truncate(O)}return F}}};y.rc2.startEncrypting=function(c,f,d){var b=y.rc2.createEncryptionCipher(c,128);return b.start(f,d),b},y.rc2.createEncryptionCipher=function(c,f){return h(c,f,!0)},y.rc2.startDecrypting=function(c,f,d){var b=y.rc2.createDecryptionCipher(c,128);return b.start(f,d),b},y.rc2.createDecryptionCipher=function(c,f){return h(c,f,!1)}},5517:(Y,U,x)=>{var y=x(8659);if(x(7791),x(730),x(6078),x(7246),x(9709),x(8365),x(4747),typeof l>"u")var l=y.jsbn.BigInteger;var g=y.util.isNodejs?x(5819):null,w=y.asn1,m=y.util;y.pki=y.pki||{},Y.exports=y.pki.rsa=y.rsa=y.rsa||{};var h=y.pki,c=[6,4,2,4,2,4,6,2],f={name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},d={name:"RSAPrivateKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},b={name:"RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:w.Class.UNIVERSAL,type:w.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},S=y.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},E={name:"DigestInfo",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:w.Class.UNIVERSAL,type:w.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:w.Class.UNIVERSAL,type:w.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:w.Class.UNIVERSAL,type:w.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:w.Class.UNIVERSAL,type:w.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},v=function(L){if(!(L.algorithm in h.oids)){var re=new Error("Unknown message digest algorithm.");throw re.algorithm=L.algorithm,re}var z=w.oidToDer(h.oids[L.algorithm]).getBytes(),te=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]),X=w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[]);X.value.push(w.create(w.Class.UNIVERSAL,w.Type.OID,!1,z)),X.value.push(w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,""));var q=w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,L.digest().getBytes());return te.value.push(X),te.value.push(q),w.toDer(te).getBytes()},p=function(L,$,re){if(re)return L.modPow($.e,$.n);if(!$.p||!$.q)return L.modPow($.d,$.n);var z;$.dP||($.dP=$.d.mod($.p.subtract(l.ONE))),$.dQ||($.dQ=$.d.mod($.q.subtract(l.ONE))),$.qInv||($.qInv=$.q.modInverse($.p));do{z=new l(y.util.bytesToHex(y.random.getBytes($.n.bitLength()/8)),16)}while(z.compareTo($.n)>=0||!z.gcd($.n).equals(l.ONE));for(var te=(L=L.multiply(z.modPow($.e,$.n)).mod($.n)).mod($.p).modPow($.dP,$.p),X=L.mod($.q).modPow($.dQ,$.q);te.compareTo(X)<0;)te=te.add($.p);var q=te.subtract(X).multiply($.qInv).mod($.p).multiply($.q).add(X);return q.multiply(z.modInverse($.n)).mod($.n)};function I(L,$,re){var z=y.util.createBuffer(),te=Math.ceil($.n.bitLength()/8);if(L.length>te-11){var X=new Error("Message is too long for PKCS#1 v1.5 padding.");throw X.length=L.length,X.max=te-11,X}z.putByte(0),z.putByte(re);var ne,q=te-3-L.length;if(0===re||1===re){ne=0===re?0:255;for(var se=0;se0;){var de=0,pe=y.random.getBytes(q);for(se=0;se"u")throw new Error("Encryption block is invalid.");var se=0;if(0===ne){se=te-3-z;for(var de=0;de1;){if(255!==X.getByte()){--X.read;break}++se}else if(2===ne)for(se=0;X.length()>1;){if(0===X.getByte()){--X.read;break}++se}if(0!==X.getByte()||se!==te-3-X.length())throw new Error("Encryption block is invalid.");return X.getBytes()}function P(L,$,re){"function"==typeof $&&(re=$,$={});var z={algorithm:{name:($=$||{}).algorithm||"PRIMEINC",options:{workers:$.workers||2,workLoad:$.workLoad||100,workerScript:$.workerScript}}};function te(){X(L.pBits,function(ne,se){return ne?re(ne):(L.p=se,null!==L.q?q(ne,L.q):void X(L.qBits,q))})}function X(ne,se){y.prime.generateProbablePrime(ne,z,se)}function q(ne,se){if(ne)return re(ne);if(L.q=se,L.p.compareTo(L.q)<0){var de=L.p;L.p=L.q,L.q=de}if(0!==L.p.subtract(l.ONE).gcd(L.e).compareTo(l.ONE))return L.p=null,void te();if(0!==L.q.subtract(l.ONE).gcd(L.e).compareTo(l.ONE))return L.q=null,void X(L.qBits,q);if(L.p1=L.p.subtract(l.ONE),L.q1=L.q.subtract(l.ONE),L.phi=L.p1.multiply(L.q1),0!==L.phi.gcd(L.e).compareTo(l.ONE))return L.p=L.q=null,void te();if(L.n=L.p.multiply(L.q),L.n.bitLength()!==L.bits)return L.q=null,void X(L.qBits,q);var pe=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,pe,L.p,L.q,pe.mod(L.p1),pe.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)},re(null,L.keys)}"prng"in $&&(z.prng=$.prng),te()}function D(L){var $=L.toString(16);$[0]>="8"&&($="00"+$);var re=y.util.hexToBytes($);return re.length>1&&(0===re.charCodeAt(0)&&0==(128&re.charCodeAt(1))||255===re.charCodeAt(0)&&128==(128&re.charCodeAt(1)))?re.substr(1):re}function T(L){return L<=100?27:L<=150?18:L<=200?15:L<=250?12:L<=300?9:L<=350?8:L<=400?7:L<=500?6:L<=600?5:L<=800?4:L<=1250?3:2}function M(L){return y.util.isNodejs&&"function"==typeof g[L]}function k(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.crypto&&"object"==typeof m.globalScope.crypto.subtle&&"function"==typeof m.globalScope.crypto.subtle[L]}function F(L){return typeof m.globalScope<"u"&&"object"==typeof m.globalScope.msCrypto&&"object"==typeof m.globalScope.msCrypto.subtle&&"function"==typeof m.globalScope.msCrypto.subtle[L]}function G(L){for(var $=y.util.hexToBytes(L.toString(16)),re=new Uint8Array($.length),z=0;z<$.length;++z)re[z]=$.charCodeAt(z);return re}h.rsa.encrypt=function(L,$,re){var te,z=re,X=Math.ceil($.n.bitLength()/8);!1!==re&&!0!==re?(z=2===re,te=I(L,$,re)):(te=y.util.createBuffer()).putBytes(L);for(var q=new l(te.toHex(),16),se=p(q,$,z).toString(16),de=y.util.createBuffer(),pe=X-Math.ceil(se.length/2);pe>0;)de.putByte(0),--pe;return de.putBytes(y.util.hexToBytes(se)),de.getBytes()},h.rsa.decrypt=function(L,$,re,z){var te=Math.ceil($.n.bitLength()/8);if(L.length!==te){var X=new Error("Encrypted message length is invalid.");throw X.length=L.length,X.expected=te,X}var q=new l(y.util.createBuffer(L).toHex(),16);if(q.compareTo($.n)>=0)throw new Error("Encrypted message is invalid.");for(var se=p(q,$,re).toString(16),de=y.util.createBuffer(),pe=te-Math.ceil(se.length/2);pe>0;)de.putByte(0),--pe;return de.putBytes(y.util.hexToBytes(se)),!1!==z?A(de.getBytes(),$,re):de.getBytes()},h.rsa.createKeyPairGenerationState=function(L,$,re){"string"==typeof L&&(L=parseInt(L,10)),L=L||2048;var q,z=(re=re||{}).prng||y.random,te={nextBytes:function(ne){for(var se=z.getBytesSync(ne.length),de=0;de>1,pBits:L-(L>>1),pqState:0,num:null,keys:null}).e.fromInt(q.eInt),q},h.rsa.stepKeyPairGenerationState=function(L,$){"algorithm"in L||(L.algorithm="PRIMEINC");var re=new l(null);re.fromInt(30);for(var q,z=0,te=function(Le,Se){return Le|Se},X=+new Date,ne=0;null===L.keys&&($<=0||ne<$);){if(0===L.state){var se=null===L.p?L.pBits:L.qBits,de=se-1;0===L.pqState?(L.num=new l(se,L.rng),L.num.testBit(de)||L.num.bitwiseTo(l.ONE.shiftLeft(de),te,L.num),L.num.dAddOffset(31-L.num.mod(re).byteValue(),0),z=0,++L.pqState):1===L.pqState?L.num.bitLength()>se?L.pqState=0:L.num.isProbablePrime(T(L.num.bitLength()))?++L.pqState:L.num.dAddOffset(c[z++%8],0):2===L.pqState?L.pqState=0===L.num.subtract(l.ONE).gcd(L.e).compareTo(l.ONE)?3:0:3===L.pqState&&(L.pqState=0,null===L.p?L.p=L.num:L.q=L.num,null!==L.p&&null!==L.q&&++L.state,L.num=null)}else if(1===L.state)L.p.compareTo(L.q)<0&&(L.num=L.p,L.p=L.q,L.q=L.num),++L.state;else if(2===L.state)L.p1=L.p.subtract(l.ONE),L.q1=L.q.subtract(l.ONE),L.phi=L.p1.multiply(L.q1),++L.state;else if(3===L.state)0===L.phi.gcd(L.e).compareTo(l.ONE)?++L.state:(L.p=null,L.q=null,L.state=0);else if(4===L.state)L.n=L.p.multiply(L.q),L.n.bitLength()===L.bits?++L.state:(L.q=null,L.state=0);else if(5===L.state){var pe=L.e.modInverse(L.phi);L.keys={privateKey:h.rsa.setPrivateKey(L.n,L.e,pe,L.p,L.q,pe.mod(L.p1),pe.mod(L.q1),L.q.modInverse(L.p)),publicKey:h.rsa.setPublicKey(L.n,L.e)}}ne+=(q=+new Date)-X,X=q}return null!==L.keys},h.rsa.generateKeyPair=function(L,$,re,z){if(1===arguments.length?"object"==typeof L?(re=L,L=void 0):"function"==typeof L&&(z=L,L=void 0):2===arguments.length?"number"==typeof L?"function"==typeof $?(z=$,$=void 0):"number"!=typeof $&&(re=$,$=void 0):(re=L,z=$,L=void 0,$=void 0):3===arguments.length&&("number"==typeof $?"function"==typeof re&&(z=re,re=void 0):(z=re,re=$,$=void 0)),re=re||{},void 0===L&&(L=re.bits||2048),void 0===$&&($=re.e||65537),!y.options.usePureJavaScript&&!re.prng&&L>=256&&L<=16384&&(65537===$||3===$))if(z){if(M("generateKeyPair"))return g.generateKeyPair("rsa",{modulusLength:L,publicExponent:$,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(ne,se,de){if(ne)return z(ne);z(null,{privateKey:h.privateKeyFromPem(de),publicKey:h.publicKeyFromPem(se)})});if(k("generateKey")&&k("exportKey"))return m.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:G($),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(ne){return m.globalScope.crypto.subtle.exportKey("pkcs8",ne.privateKey)}).then(void 0,function(ne){z(ne)}).then(function(ne){if(ne){var se=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(ne)));z(null,{privateKey:se,publicKey:h.setRsaPublicKey(se.n,se.e)})}});if(F("generateKey")&&F("exportKey")){var te=m.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:L,publicExponent:G($),hash:{name:"SHA-256"}},!0,["sign","verify"]);return te.oncomplete=function(ne){var de=m.globalScope.msCrypto.subtle.exportKey("pkcs8",ne.target.result.privateKey);de.oncomplete=function(pe){var Se=h.privateKeyFromAsn1(w.fromDer(y.util.createBuffer(pe.target.result)));z(null,{privateKey:Se,publicKey:h.setRsaPublicKey(Se.n,Se.e)})},de.onerror=function(pe){z(pe)}},void(te.onerror=function(ne){z(ne)})}}else if(M("generateKeyPairSync")){var X=g.generateKeyPairSync("rsa",{modulusLength:L,publicExponent:$,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:h.privateKeyFromPem(X.privateKey),publicKey:h.publicKeyFromPem(X.publicKey)}}var q=h.rsa.createKeyPairGenerationState(L,$,re);if(!z)return h.rsa.stepKeyPairGenerationState(q,0),q.keys;P(q,re,z)},h.setRsaPublicKey=h.rsa.setPublicKey=function(L,$){var re={n:L,e:$,encrypt:function(z,te,X){if("string"==typeof te?te=te.toUpperCase():void 0===te&&(te="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===te)te={encode:function(ne,se,de){return I(ne,se,2).getBytes()}};else if("RSA-OAEP"===te||"RSAES-OAEP"===te)te={encode:function(ne,se){return y.pkcs1.encode_rsa_oaep(se,ne,X)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(te))te={encode:function(ne){return ne}};else if("string"==typeof te)throw new Error('Unsupported encryption scheme: "'+te+'".');var q=te.encode(z,re,!0);return h.rsa.encrypt(q,re,!0)},verify:function(z,te,X,q){"string"==typeof X?X=X.toUpperCase():void 0===X&&(X="RSASSA-PKCS1-V1_5"),void 0===q&&(q={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in q||(q._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===X?X={verify:function(se,de){de=A(de,re,!0);var pe=w.fromDer(de,{parseAllBytes:q._parseAllDigestBytes}),Le={},Se=[];if(!w.validate(pe,E,Le,Se))throw(Pe=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=Se,Pe;var Pe,be=w.derToOid(Le.algorithmIdentifier);if(be!==y.oids.md2&&be!==y.oids.md5&&be!==y.oids.sha1&&be!==y.oids.sha224&&be!==y.oids.sha256&&be!==y.oids.sha384&&be!==y.oids.sha512&&be!==y.oids["sha512-224"]&&be!==y.oids["sha512-256"])throw(Pe=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=be,Pe;if((be===y.oids.md2||be===y.oids.md5)&&!("parameters"in Le))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return se===Le.digest}}:("NONE"===X||"NULL"===X||null===X)&&(X={verify:function(se,de){return se===A(de,re,!0)}});var ne=h.rsa.decrypt(te,re,!0,!1);return X.verify(z,ne,re.n.bitLength())}};return re},h.setRsaPrivateKey=h.rsa.setPrivateKey=function(L,$,re,z,te,X,q,ne){var se={n:L,e:$,d:re,p:z,q:te,dP:X,dQ:q,qInv:ne,decrypt:function(de,pe,Le){"string"==typeof pe?pe=pe.toUpperCase():void 0===pe&&(pe="RSAES-PKCS1-V1_5");var Se=h.rsa.decrypt(de,se,!1,!1);if("RSAES-PKCS1-V1_5"===pe)pe={decode:A};else if("RSA-OAEP"===pe||"RSAES-OAEP"===pe)pe={decode:function(Pe,be){return y.pkcs1.decode_rsa_oaep(be,Pe,Le)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(pe))throw new Error('Unsupported encryption scheme: "'+pe+'".');pe={decode:function(Pe){return Pe}}}return pe.decode(Se,se,!1)},sign:function(de,pe){var Le=!1;"string"==typeof pe&&(pe=pe.toUpperCase()),void 0===pe||"RSASSA-PKCS1-V1_5"===pe?(pe={encode:v},Le=1):("NONE"===pe||"NULL"===pe||null===pe)&&(pe={encode:function(){return de}},Le=1);var Se=pe.encode(de,se.n.bitLength());return h.rsa.encrypt(Se,se,Le)}};return se},h.wrapRsaPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.OCTETSTRING,!1,w.toDer(L).getBytes())])},h.privateKeyFromAsn1=function(L){var te,X,q,ne,se,de,pe,Le,$={},re=[];if(w.validate(L,f,$,re)&&(L=w.fromDer(y.util.createBuffer($.privateKey))),!w.validate(L,d,$={},re=[])){var z=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw z.errors=re,z}return te=y.util.createBuffer($.privateKeyModulus).toHex(),X=y.util.createBuffer($.privateKeyPublicExponent).toHex(),q=y.util.createBuffer($.privateKeyPrivateExponent).toHex(),ne=y.util.createBuffer($.privateKeyPrime1).toHex(),se=y.util.createBuffer($.privateKeyPrime2).toHex(),de=y.util.createBuffer($.privateKeyExponent1).toHex(),pe=y.util.createBuffer($.privateKeyExponent2).toHex(),Le=y.util.createBuffer($.privateKeyCoefficient).toHex(),h.setRsaPrivateKey(new l(te,16),new l(X,16),new l(q,16),new l(ne,16),new l(se,16),new l(de,16),new l(pe,16),new l(Le,16))},h.privateKeyToAsn1=h.privateKeyToRSAPrivateKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,w.integerToDer(0).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.d)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.p)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.q)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dP)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.dQ)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.qInv))])},h.publicKeyFromAsn1=function(L){var $={},re=[];if(w.validate(L,S,$,re)){var te,z=w.derToOid($.publicKeyOid);if(z!==h.oids.rsaEncryption)throw(te=new Error("Cannot read public key. Unknown OID.")).oid=z,te;L=$.rsaPublicKey}if(!w.validate(L,b,$,re=[]))throw(te=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=re,te;var X=y.util.createBuffer($.publicKeyModulus).toHex(),q=y.util.createBuffer($.publicKeyExponent).toHex();return h.setRsaPublicKey(new l(X,16),new l(q,16))},h.publicKeyToAsn1=h.publicKeyToSubjectPublicKeyInfo=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.OID,!1,w.oidToDer(h.oids.rsaEncryption).getBytes()),w.create(w.Class.UNIVERSAL,w.Type.NULL,!1,"")]),w.create(w.Class.UNIVERSAL,w.Type.BITSTRING,!1,[h.publicKeyToRSAPublicKey(L)])])},h.publicKeyToRSAPublicKey=function(L){return w.create(w.Class.UNIVERSAL,w.Type.SEQUENCE,!0,[w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.n)),w.create(w.Class.UNIVERSAL,w.Type.INTEGER,!1,D(L.e))])}},7690:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha1=y.sha1||{};y.md.sha1=y.md.algorithms.sha1=l,l.create=function(){w||function m(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),w=!0}();var c=null,f=y.util.createBuffer(),d=new Array(80),b={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){b.messageLength=0,b.fullMessageLength=b.messageLength64=[];for(var S=b.messageLengthSize/4,E=0;E>>0,v>>>0];for(var p=b.fullMessageLength.length-1;p>=0;--p)b.fullMessageLength[p]+=v[1],v[1]=v[0]+(b.fullMessageLength[p]/4294967296>>>0),b.fullMessageLength[p]=b.fullMessageLength[p]>>>0,v[0]=v[1]/4294967296>>>0;return f.putBytes(S),h(c,d,f),(f.read>2048||0===f.length())&&f.compact(),b},b.digest=function(){var S=y.util.createBuffer();S.putBytes(f.bytes()),S.putBytes(g.substr(0,b.blockLength-(b.fullMessageLength[b.fullMessageLength.length-1]+b.messageLengthSize&b.blockLength-1)));for(var p,A=8*b.fullMessageLength[0],P=0;P>>0)>>>0),A=p>>>0;S.putInt32(A);var D={h0:c.h0,h1:c.h1,h2:c.h2,h3:c.h3,h4:c.h4};h(D,d,S);var T=y.util.createBuffer();return T.putInt32(D.h0),T.putInt32(D.h1),T.putInt32(D.h2),T.putInt32(D.h3),T.putInt32(D.h4),T},b};var g=null,w=!1;function h(c,f,d){for(var b,S,E,v,p,I,P,D=d.length();D>=64;){for(S=c.h0,E=c.h1,v=c.h2,p=c.h3,I=c.h4,P=0;P<16;++P)b=d.getInt32(),f[P]=b,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<20;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(p^E&(v^p))+I+1518500249+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<32;++P)f[P]=b=(b=f[P-3]^f[P-8]^f[P-14]^f[P-16])<<1|b>>>31,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<40;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+1859775393+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<60;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E&v|p&(E^v))+I+2400959708+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;for(;P<80;++P)f[P]=b=(b=f[P-6]^f[P-16]^f[P-28]^f[P-32])<<2|b>>>30,b=(S<<5|S>>>27)+(E^v^p)+I+3395469782+b,I=p,p=v,v=(E<<30|E>>>2)>>>0,E=S,S=b;c.h0=c.h0+S|0,c.h1=c.h1+E|0,c.h2=c.h2+v|0,c.h3=c.h3+p|0,c.h4=c.h4+I|0,D-=64}}},1594:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha256=y.sha256||{};y.md.sha256=y.md.algorithms.sha256=l,l.create=function(){w||function h(){g=String.fromCharCode(128),g+=y.util.fillString(String.fromCharCode(0),64),m=[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],w=!0}();var f=null,d=y.util.createBuffer(),b=new Array(64),S={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){S.messageLength=0,S.fullMessageLength=S.messageLength64=[];for(var E=S.messageLengthSize/4,v=0;v>>0,p>>>0];for(var I=S.fullMessageLength.length-1;I>=0;--I)S.fullMessageLength[I]+=p[1],p[1]=p[0]+(S.fullMessageLength[I]/4294967296>>>0),S.fullMessageLength[I]=S.fullMessageLength[I]>>>0,p[0]=p[1]/4294967296>>>0;return d.putBytes(E),c(f,b,d),(d.read>2048||0===d.length())&&d.compact(),S},S.digest=function(){var E=y.util.createBuffer();E.putBytes(d.bytes()),E.putBytes(g.substr(0,S.blockLength-(S.fullMessageLength[S.fullMessageLength.length-1]+S.messageLengthSize&S.blockLength-1)));for(var I,P=8*S.fullMessageLength[0],D=0;D>>0)>>>0),P=I>>>0;E.putInt32(P);var T={h0:f.h0,h1:f.h1,h2:f.h2,h3:f.h3,h4:f.h4,h5:f.h5,h6:f.h6,h7:f.h7};c(T,b,E);var M=y.util.createBuffer();return M.putInt32(T.h0),M.putInt32(T.h1),M.putInt32(T.h2),M.putInt32(T.h3),M.putInt32(T.h4),M.putInt32(T.h5),M.putInt32(T.h6),M.putInt32(T.h7),M},S};var g=null,w=!1,m=null;function c(f,d,b){for(var S,E,A,P,D,T,M,k,F,G,C,O,V=b.length();V>=64;){for(P=0;P<16;++P)d[P]=b.getInt32();for(;P<64;++P)d[P]=(S=((S=d[P-2])>>>17|S<<15)^(S>>>19|S<<13)^S>>>10)+d[P-7]+(E=((E=d[P-15])>>>7|E<<25)^(E>>>18|E<<14)^E>>>3)+d[P-16]|0;for(D=f.h0,T=f.h1,M=f.h2,k=f.h3,F=f.h4,G=f.h5,C=f.h6,O=f.h7,P=0;P<64;++P)A=D&T|M&(D^T),S=O+((F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7))+(C^F&(G^C))+m[P]+d[P],O=C,C=G,G=F,F=k+S>>>0,k=M,M=T,T=D,D=S+(E=((D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10))+A)>>>0;f.h0=f.h0+D|0,f.h1=f.h1+T|0,f.h2=f.h2+M|0,f.h3=f.h3+k|0,f.h4=f.h4+F|0,f.h5=f.h5+G|0,f.h6=f.h6+C|0,f.h7=f.h7+O|0,V-=64}}},8985:(Y,U,x)=>{var y=x(8659);x(979),x(4747);var l=Y.exports=y.sha512=y.sha512||{};y.md.sha512=y.md.algorithms.sha512=l;var g=y.sha384=y.sha512.sha384=y.sha512.sha384||{};g.create=function(){return l.create("SHA-384")},y.md.sha384=y.md.algorithms.sha384=g,y.sha512.sha256=y.sha512.sha256||{create:function(){return l.create("SHA-512/256")}},y.md["sha512/256"]=y.md.algorithms["sha512/256"]=y.sha512.sha256,y.sha512.sha224=y.sha512.sha224||{create:function(){return l.create("SHA-512/224")}},y.md["sha512/224"]=y.md.algorithms["sha512/224"]=y.sha512.sha224,l.create=function(b){if(m||function f(){w=String.fromCharCode(128),w+=y.util.fillString(String.fromCharCode(0),128),h=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(c={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],c["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],c["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],c["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],m=!0}(),typeof b>"u"&&(b="SHA-512"),!(b in c))throw new Error("Invalid SHA-512 algorithm: "+b);for(var S=c[b],E=null,v=y.util.createBuffer(),p=new Array(80),I=0;I<80;++I)p[I]=new Array(2);var A=64;switch(b){case"SHA-384":A=48;break;case"SHA-512/256":A=32;break;case"SHA-512/224":A=28}var P={algorithm:b.replace("-","").toLowerCase(),blockLength:128,digestLength:A,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){P.messageLength=0,P.fullMessageLength=P.messageLength128=[];for(var D=P.messageLengthSize/4,T=0;T>>0,M>>>0];for(var k=P.fullMessageLength.length-1;k>=0;--k)P.fullMessageLength[k]+=M[1],M[1]=M[0]+(P.fullMessageLength[k]/4294967296>>>0),P.fullMessageLength[k]=P.fullMessageLength[k]>>>0,M[0]=M[1]/4294967296>>>0;return v.putBytes(D),d(E,p,v),(v.read>2048||0===v.length())&&v.compact(),P},P.digest=function(){var D=y.util.createBuffer();D.putBytes(v.bytes()),D.putBytes(w.substr(0,P.blockLength-(P.fullMessageLength[P.fullMessageLength.length-1]+P.messageLengthSize&P.blockLength-1)));for(var k,G=8*P.fullMessageLength[0],C=0;C>>0)>>>0),G=k>>>0;D.putInt32(G);var O=new Array(E.length);for(C=0;C=128;){for(be=0;be<16;++be)S[be][0]=E.getInt32()>>>0,S[be][1]=E.getInt32()>>>0;for(;be<80;++be)p=((($e=(Ee=S[be-2])[0])<<13|(H=Ee[1])>>>19)^(H<<3|$e>>>29)^($e<<26|H>>>6))>>>0,S[be][0]=(v=(($e>>>19|H<<13)^(H>>>29|$e<<3)^$e>>>6)>>>0)+(Te=S[be-7])[0]+(I=((($e=(xe=S[be-15])[0])>>>1|(H=xe[1])<<31)^($e>>>8|H<<24)^$e>>>7)>>>0)+(He=S[be-16])[0]+((H=p+Te[1]+(A=(($e<<31|H>>>1)^($e<<24|H>>>8)^($e<<25|H>>>7))>>>0)+He[1])/4294967296>>>0)>>>0,S[be][1]=H>>>0;for(O=b[0][0],V=b[0][1],L=b[1][0],$=b[1][1],re=b[2][0],z=b[2][1],te=b[3][0],X=b[3][1],q=b[4][0],ne=b[4][1],se=b[5][0],de=b[5][1],pe=b[6][0],Le=b[6][1],Se=b[7][0],Pe=b[7][1],be=0;be<80;++be)v=Se+(((q>>>14|ne<<18)^(q>>>18|ne<<14)^(ne>>>9|q<<23))>>>0)+((pe^q&(se^pe))>>>0)+h[be][0]+S[be][0]+((H=Pe+(((q<<18|ne>>>14)^(q<<14|ne>>>18)^(ne<<23|q>>>9))>>>0)+((Le^ne&(de^Le))>>>0)+h[be][1]+S[be][1])/4294967296>>>0)>>>0,p=H>>>0,I=(((O>>>28|V<<4)^(V>>>2|O<<30)^(V>>>7|O<<25))>>>0)+((O&L|re&(O^L))>>>0)+((H=(((O<<4|V>>>28)^(V<<30|O>>>2)^(V<<25|O>>>7))>>>0)+((V&$|z&(V^$))>>>0))/4294967296>>>0)>>>0,A=H>>>0,Se=pe,Pe=Le,pe=se,Le=de,se=q,de=ne,q=te+v+((H=X+p)/4294967296>>>0)>>>0,ne=H>>>0,te=re,X=z,re=L,z=$,L=O,$=V,O=v+I+((H=p+A)/4294967296>>>0)>>>0,V=H>>>0;b[0][0]=b[0][0]+O+((H=b[0][1]+V)/4294967296>>>0)>>>0,b[0][1]=H>>>0,b[1][0]=b[1][0]+L+((H=b[1][1]+$)/4294967296>>>0)>>>0,b[1][1]=H>>>0,b[2][0]=b[2][0]+re+((H=b[2][1]+z)/4294967296>>>0)>>>0,b[2][1]=H>>>0,b[3][0]=b[3][0]+te+((H=b[3][1]+X)/4294967296>>>0)>>>0,b[3][1]=H>>>0,b[4][0]=b[4][0]+q+((H=b[4][1]+ne)/4294967296>>>0)>>>0,b[4][1]=H>>>0,b[5][0]=b[5][0]+se+((H=b[5][1]+de)/4294967296>>>0)>>>0,b[5][1]=H>>>0,b[6][0]=b[6][0]+pe+((H=b[6][1]+Le)/4294967296>>>0)>>>0,b[6][1]=H>>>0,b[7][0]=b[7][0]+Se+((H=b[7][1]+Pe)/4294967296>>>0)>>>0,b[7][1]=H>>>0,We-=128}}},4747:(Y,U,x)=>{var y=x(8659),l=x(2020),g=Y.exports=y.util=y.util||{};function w(D){if(8!==D&&16!==D&&24!==D&&32!==D)throw new Error("Only 8, 16, 24, or 32 bits supported: "+D)}function m(D){if(this.data="",this.read=0,"string"==typeof D)this.data=D;else if(g.isArrayBuffer(D)||g.isArrayBufferView(D))if(typeof Buffer<"u"&&D instanceof Buffer)this.data=D.toString("binary");else{var T=new Uint8Array(D);try{this.data=String.fromCharCode.apply(null,T)}catch{for(var M=0;M15?(M=Date.now(),G(V)):(T.push(V),1===T.length&&F.setAttribute("a",k=!k))}}g.nextTick=g.setImmediate})(),g.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,g.globalScope=g.isNodejs?global:typeof self>"u"?window:self,g.isArray=Array.isArray||function(D){return"[object Array]"===Object.prototype.toString.call(D)},g.isArrayBuffer=function(D){return typeof ArrayBuffer<"u"&&D instanceof ArrayBuffer},g.isArrayBufferView=function(D){return D&&g.isArrayBuffer(D.buffer)&&void 0!==D.byteLength},g.ByteBuffer=m,g.ByteStringBuffer=m,g.ByteStringBuffer.prototype._optimizeConstructedString=function(D){this._constructedStringLength+=D,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},g.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},g.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},g.ByteStringBuffer.prototype.putByte=function(D){return this.putBytes(String.fromCharCode(D))},g.ByteStringBuffer.prototype.fillWithByte=function(D,T){D=String.fromCharCode(D);for(var M=this.data;T>0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return this.data=M,this._optimizeConstructedString(T),this},g.ByteStringBuffer.prototype.putBytes=function(D){return this.data+=D,this._optimizeConstructedString(D.length),this},g.ByteStringBuffer.prototype.putString=function(D){return this.putBytes(g.encodeUtf8(D))},g.ByteStringBuffer.prototype.putInt16=function(D){return this.putBytes(String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt24=function(D){return this.putBytes(String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt32=function(D){return this.putBytes(String.fromCharCode(D>>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D))},g.ByteStringBuffer.prototype.putInt16Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255))},g.ByteStringBuffer.prototype.putInt24Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255))},g.ByteStringBuffer.prototype.putInt32Le=function(D){return this.putBytes(String.fromCharCode(255&D)+String.fromCharCode(D>>8&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>24&255))},g.ByteStringBuffer.prototype.putInt=function(D,T){w(T);var M="";do{T-=8,M+=String.fromCharCode(D>>T&255)}while(T>0);return this.putBytes(M)},g.ByteStringBuffer.prototype.putSignedInt=function(D,T){return D<0&&(D+=2<0);return T},g.ByteStringBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.ByteStringBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.ByteStringBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.ByteStringBuffer.prototype.at=function(D){return this.data.charCodeAt(this.read+D)},g.ByteStringBuffer.prototype.setAt=function(D,T){return this.data=this.data.substr(0,this.read+D)+String.fromCharCode(T)+this.data.substr(this.read+D+1),this},g.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},g.ByteStringBuffer.prototype.copy=function(){var D=g.createBuffer(this.data);return D.read=this.read,D},g.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},g.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},g.ByteStringBuffer.prototype.truncate=function(D){var T=Math.max(0,this.length()-D);return this.data=this.data.substr(this.read,T),this.read=0,this},g.ByteStringBuffer.prototype.toHex=function(){for(var D="",T=this.read;T=D)return this;T=Math.max(T||this.growSize,D);var M=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),k=new Uint8Array(this.length()+T);return k.set(M),this.data=new DataView(k.buffer),this},g.DataBuffer.prototype.putByte=function(D){return this.accommodate(1),this.data.setUint8(this.write++,D),this},g.DataBuffer.prototype.fillWithByte=function(D,T){this.accommodate(T);for(var M=0;M>8&65535),this.data.setInt8(this.write,D>>16&255),this.write+=3,this},g.DataBuffer.prototype.putInt32=function(D){return this.accommodate(4),this.data.setInt32(this.write,D),this.write+=4,this},g.DataBuffer.prototype.putInt16Le=function(D){return this.accommodate(2),this.data.setInt16(this.write,D,!0),this.write+=2,this},g.DataBuffer.prototype.putInt24Le=function(D){return this.accommodate(3),this.data.setInt8(this.write,D>>16&255),this.data.setInt16(this.write,D>>8&65535,!0),this.write+=3,this},g.DataBuffer.prototype.putInt32Le=function(D){return this.accommodate(4),this.data.setInt32(this.write,D,!0),this.write+=4,this},g.DataBuffer.prototype.putInt=function(D,T){w(T),this.accommodate(T/8);do{T-=8,this.data.setInt8(this.write++,D>>T&255)}while(T>0);return this},g.DataBuffer.prototype.putSignedInt=function(D,T){return w(T),this.accommodate(T/8),D<0&&(D+=2<0);return T},g.DataBuffer.prototype.getSignedInt=function(D){var T=this.getInt(D),M=2<=M&&(T-=M<<1),T},g.DataBuffer.prototype.getBytes=function(D){var T;return D?(D=Math.min(this.length(),D),T=this.data.slice(this.read,this.read+D),this.read+=D):0===D?T="":(T=0===this.read?this.data:this.data.slice(this.read),this.clear()),T},g.DataBuffer.prototype.bytes=function(D){return typeof D>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+D)},g.DataBuffer.prototype.at=function(D){return this.data.getUint8(this.read+D)},g.DataBuffer.prototype.setAt=function(D,T){return this.data.setUint8(D,T),this},g.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},g.DataBuffer.prototype.copy=function(){return new g.DataBuffer(this)},g.DataBuffer.prototype.compact=function(){if(this.read>0){var D=new Uint8Array(this.data.buffer,this.read),T=new Uint8Array(D.byteLength);T.set(D),this.data=new DataView(T),this.write-=this.read,this.read=0}return this},g.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},g.DataBuffer.prototype.truncate=function(D){return this.write=Math.max(0,this.length()-D),this.read=Math.min(this.read,this.write),this},g.DataBuffer.prototype.toHex=function(){for(var D="",T=this.read;T0;)1&T&&(M+=D),(T>>>=1)>0&&(D+=D);return M},g.xorBytes=function(D,T,M){for(var k="",F="",G="",C=0,O=0;M>0;--M,++C)F=D.charCodeAt(C)^T.charCodeAt(C),O>=10&&(k+=G,G="",O=0),G+=String.fromCharCode(F),++O;return k+G},g.hexToBytes=function(D){var T="",M=0;for(!0&D.length&&(M=1,T+=String.fromCharCode(parseInt(D[0],16)));M>24&255)+String.fromCharCode(D>>16&255)+String.fromCharCode(D>>8&255)+String.fromCharCode(255&D)};var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",d=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";g.encode64=function(D,T){for(var F,G,C,M="",k="",O=0;O>2),M+=f.charAt((3&F)<<4|G>>4),isNaN(G)?M+="==":(M+=f.charAt((15&G)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.decode64=function(D){D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var M,k,F,G,T="",C=0;C>4),64!==F&&(T+=String.fromCharCode((15&k)<<4|F>>2),64!==G&&(T+=String.fromCharCode((3&F)<<6|G)));return T},g.encodeUtf8=function(D){return unescape(encodeURIComponent(D))},g.decodeUtf8=function(D){return decodeURIComponent(escape(D))},g.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:l.encode,decode:l.decode}},g.binary.raw.encode=function(D){return String.fromCharCode.apply(null,D)},g.binary.raw.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,G=0;G>2),M+=f.charAt((3&F)<<4|G>>4),isNaN(G)?M+="==":(M+=f.charAt((15&G)<<2|C>>6),M+=isNaN(C)?"=":f.charAt(63&C)),T&&M.length>T&&(k+=M.substr(0,T)+"\r\n",M=M.substr(T));return k+M},g.binary.base64.decode=function(D,T,M){var k=T;k||(k=new Uint8Array(3*Math.ceil(D.length/4))),D=D.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var F,G,C,O,V=0,L=M=M||0;V>4,64!==C&&(k[L++]=(15&G)<<4|C>>2,64!==O&&(k[L++]=(3&C)<<6|O));return T?L-M:k.subarray(0,L)},g.binary.base58.encode=function(D,T){return g.binary.baseN.encode(D,b,T)},g.binary.base58.decode=function(D,T){return g.binary.baseN.decode(D,b,T)},g.text={utf8:{},utf16:{}},g.text.utf8.encode=function(D,T,M){D=g.encodeUtf8(D);var k=T;k||(k=new Uint8Array(D.length));for(var F=M=M||0,G=0;G"u"&&(M=["web","flash"]);var F,G=!1,C=null;for(var O in M){F=M[O];try{if("flash"===F||"both"===F){if(null===T[0])throw new Error("Flash local storage not available.");k=D.apply(this,T),G="flash"===F}("web"===F||"both"===F)&&(T[0]=localStorage,k=D.apply(this,T),G=!0)}catch(V){C=V}if(G)break}if(!G)throw C;return k};g.setItem=function(D,T,M,k,F){P(v,arguments,F)},g.getItem=function(D,T,M,k){return P(p,arguments,k)},g.removeItem=function(D,T,M,k){P(I,arguments,k)},g.clearItems=function(D,T,M){P(A,arguments,M)},g.isEmpty=function(D){for(var T in D)if(D.hasOwnProperty(T))return!1;return!0},g.format=function(D){for(var M,k,T=/%./g,F=0,G=[],C=0;M=T.exec(D);){(k=D.substring(C,T.lastIndex-2)).length>0&&G.push(k),C=T.lastIndex;var O=M[0][1];switch(O){case"s":case"o":G.push(F");break;case"%":G.push("%");break;default:G.push("<%"+O+"?>")}}return G.push(D.substring(C)),G.join("")},g.formatNumber=function(D,T,M,k){var F=D,G=isNaN(T=Math.abs(T))?2:T,C=void 0===M?",":M,O=void 0===k?".":k,V=F<0?"-":"",L=parseInt(F=Math.abs(+F||0).toFixed(G),10)+"",$=L.length>3?L.length%3:0;return V+($?L.substr(0,$)+O:"")+L.substr($).replace(/(\d{3})(?=\d)/g,"$1"+O)+(G?C+Math.abs(F-L).toFixed(G).slice(2):"")},g.formatSize=function(D){return D>=1073741824?g.formatNumber(D/1073741824,2,".","")+" GiB":D>=1048576?g.formatNumber(D/1048576,2,".","")+" MiB":D>=1024?g.formatNumber(D/1024,0)+" KiB":g.formatNumber(D,0)+" bytes"},g.bytesFromIP=function(D){return-1!==D.indexOf(".")?g.bytesFromIPv4(D):-1!==D.indexOf(":")?g.bytesFromIPv6(D):null},g.bytesFromIPv4=function(D){if(4!==(D=D.split(".")).length)return null;for(var T=g.createBuffer(),M=0;MM[k].end-M[k].start&&(k=M.length-1)):M.push({start:O,end:O})}T.push(G)}if(M.length>0){var V=M[k];V.end-V.start>0&&(T.splice(V.start,V.end-V.start+1,""),0===V.start&&T.unshift(""),7===V.end&&T.push(""))}return T.join(":")},g.estimateCores=function(D,T){if("function"==typeof D&&(T=D,D={}),D=D||{},"cores"in g&&!D.update)return T(null,g.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return g.cores=navigator.hardwareConcurrency,T(null,g.cores);if(typeof Worker>"u")return g.cores=1,T(null,g.cores);if(typeof Blob>"u")return g.cores=2,T(null,g.cores);var M=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(C){for(var O=Date.now(),V=O+4;Date.now()te.st&&$.st$.st&&te.st<$.et)&&re.push(z)}return V.reduce(function(X,q){return Math.max(X,q.length)},0)}(V,re)),k(C,O-1,V)})}([],5,16)}},5911:(Y,U,x)=>{var y=x(8659);x(1298),x(7791),x(279),x(979),x(9386),x(6078),x(8604),x(7256),x(5517),x(4747);var l=y.asn1,g=Y.exports=y.pki=y.pki||{},w=g.oids,m={};m.CN=w.commonName,m.commonName="CN",m.C=w.countryName,m.countryName="C",m.L=w.localityName,m.localityName="L",m.ST=w.stateOrProvinceName,m.stateOrProvinceName="ST",m.O=w.organizationName,m.organizationName="O",m.OU=w.organizationalUnitName,m.organizationalUnitName="OU",m.E=w.emailAddress,m.emailAddress="E";var h=y.pki.rsa.publicKeyValidator,c={name:"Certificate",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:l.Class.UNIVERSAL,type:l.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:l.Class.UNIVERSAL,type:l.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:l.Class.UNIVERSAL,type:l.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:l.Class.UNIVERSAL,type:l.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},h,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:l.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:l.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},f={name:"rsapss",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:l.Class.UNIVERSAL,type:l.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:l.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:l.Class.UNIVERSAL,type:l.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:l.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:l.Class.UNIVERSAL,type:l.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:l.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:l.Class.UNIVERSAL,type:l.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},b={name:"CertificationRequest",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[{name:"CertificationRequestInfo",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:l.Class.UNIVERSAL,type:l.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},h,{name:"CertificationRequestInfo.attributes",tagClass:l.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:l.Class.UNIVERSAL,type:l.Type.SET,constructed:!0}]}]}]},{name:"CertificationRequest.signatureAlgorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:l.Class.UNIVERSAL,type:l.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:l.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:l.Class.UNIVERSAL,type:l.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function S(C,O){"string"==typeof O&&(O={shortName:O});for(var L,V=null,$=0;null===V&&$"u"&&(O.type&&O.type in g.oids?O.name=g.oids[O.type]:O.shortName&&O.shortName in m&&(O.name=g.oids[m[O.shortName]])),typeof O.type>"u"){if(!O.name||!(O.name in g.oids))throw(L=new Error("Attribute type not specified.")).attribute=O,L;O.type=g.oids[O.name]}if(typeof O.shortName>"u"&&O.name&&O.name in m&&(O.shortName=m[O.name]),O.type===w.extensionRequest&&(O.valueConstructed=!0,O.valueTagClass=l.Type.SEQUENCE,!O.value&&O.extensions)){O.value=[];for(var $=0;$"u")throw(L=new Error("Attribute value not specified.")).attribute=O,L}}function D(C,O){if(O=O||{},typeof C.name>"u"&&C.id&&C.id in g.oids&&(C.name=g.oids[C.id]),typeof C.id>"u"){if(!C.name||!(C.name in g.oids))throw(V=new Error("Extension ID not specified.")).extension=C,V;C.id=g.oids[C.name]}if(typeof C.value<"u")return C;if("keyUsage"===C.name){var L=0,$=0,re=0;C.digitalSignature&&($|=128,L=7),C.nonRepudiation&&($|=64,L=6),C.keyEncipherment&&($|=32,L=5),C.dataEncipherment&&($|=16,L=4),C.keyAgreement&&($|=8,L=3),C.keyCertSign&&($|=4,L=2),C.cRLSign&&($|=2,L=1),C.encipherOnly&&($|=1,L=0),C.decipherOnly&&(re|=128,L=7);var z=String.fromCharCode(L);0!==re?z+=String.fromCharCode($)+String.fromCharCode(re):0!==$&&(z+=String.fromCharCode($)),C.value=l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,z)}else if("basicConstraints"===C.name)C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),C.cA&&C.value.value.push(l.create(l.Class.UNIVERSAL,l.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in C&&C.value.value.push(l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(C.pathLenConstraint).getBytes()));else if("extKeyUsage"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);var te=C.value.value;for(var X in C)!0===C[X]&&(X in w?te.push(l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(w[X]).getBytes())):-1!==X.indexOf(".")&&te.push(l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(X).getBytes())))}else if("nsCertType"===C.name)L=0,$=0,C.client&&($|=128,L=7),C.server&&($|=64,L=6),C.email&&($|=32,L=5),C.objsign&&($|=16,L=4),C.reserved&&($|=8,L=3),C.sslCA&&($|=4,L=2),C.emailCA&&($|=2,L=1),C.objCA&&($|=1,L=0),z=String.fromCharCode(L),0!==$&&(z+=String.fromCharCode($)),C.value=l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,z);else if("subjectAltName"===C.name||"issuerAltName"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);for(var ne=0;ne128)throw new Error('Invalid "nsComment" content.');C.value=l.create(l.Class.UNIVERSAL,l.Type.IA5STRING,!1,C.comment)}else if("subjectKeyIdentifier"===C.name&&O.cert){var se=O.cert.generateSubjectKeyIdentifier();C.subjectKeyIdentifier=se.toHex(),C.value=l.create(l.Class.UNIVERSAL,l.Type.OCTETSTRING,!1,se.getBytes())}else if("authorityKeyIdentifier"===C.name&&O.cert){if(C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),te=C.value.value,C.keyIdentifier){var de=!0===C.keyIdentifier?O.cert.generateSubjectKeyIdentifier().getBytes():C.keyIdentifier;te.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!1,de))}if(C.authorityCertIssuer){var pe=[l.create(l.Class.CONTEXT_SPECIFIC,4,!0,[I(!0===C.authorityCertIssuer?O.cert.issuer:C.authorityCertIssuer)])];te.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,pe))}if(C.serialNumber){var Le=y.util.hexToBytes(!0===C.serialNumber?O.cert.serialNumber:C.serialNumber);te.push(l.create(l.Class.CONTEXT_SPECIFIC,2,!1,Le))}}else if("cRLDistributionPoints"===C.name){C.value=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),te=C.value.value;var q,Se=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]),Pe=l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[]);for(ne=0;ne"u")throw(V=new Error("Extension value not specified.")).extension=C,V;return C}function T(C,O){if(C===w["RSASSA-PSS"]){var V=[];return void 0!==O.hash.algorithmOid&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.hash.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")])])),void 0!==O.mgf.algorithmOid&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,1,!0,[l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.mgf.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(O.mgf.hash.algorithmOid).getBytes()),l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")])])])),void 0!==O.saltLength&&V.push(l.create(l.Class.CONTEXT_SPECIFIC,2,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(O.saltLength).getBytes())])),l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,V)}return l.create(l.Class.UNIVERSAL,l.Type.NULL,!1,"")}function M(C){var O=l.create(l.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===C.attributes.length)return O;for(var V=C.attributes,L=0;L2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(X.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(z.validity.notBefore=X[0],z.validity.notAfter=X[1],z.tbsCertificate=V.tbsCertificate,O){z.md=v({signatureOid:z.signatureOid,type:"certificate"});var q=l.toDer(z.tbsCertificate);z.md.update(q.getBytes())}var ne=y.md.sha1.create(),se=l.toDer(V.certIssuer);ne.update(se.getBytes()),z.issuer.getField=function(Le){return S(z.issuer,Le)},z.issuer.addField=function(Le){P([Le]),z.issuer.attributes.push(Le)},z.issuer.attributes=g.RDNAttributesAsArray(V.certIssuer),V.certIssuerUniqueId&&(z.issuer.uniqueId=V.certIssuerUniqueId),z.issuer.hash=ne.digest().toHex();var de=y.md.sha1.create(),pe=l.toDer(V.certSubject);return de.update(pe.getBytes()),z.subject.getField=function(Le){return S(z.subject,Le)},z.subject.addField=function(Le){P([Le]),z.subject.attributes.push(Le)},z.subject.attributes=g.RDNAttributesAsArray(V.certSubject),V.certSubjectUniqueId&&(z.subject.uniqueId=V.certSubjectUniqueId),z.subject.hash=de.digest().toHex(),z.extensions=V.certExtensions?g.certificateExtensionsFromAsn1(V.certExtensions):[],z.publicKey=g.publicKeyFromAsn1(V.subjectPublicKeyInfo),z},g.certificateExtensionsFromAsn1=function(C){for(var O=[],V=0;V1&&(L=V.value.charCodeAt(1),$=V.value.length>2?V.value.charCodeAt(2):0),O.digitalSignature=128==(128&L),O.nonRepudiation=64==(64&L),O.keyEncipherment=32==(32&L),O.dataEncipherment=16==(16&L),O.keyAgreement=8==(8&L),O.keyCertSign=4==(4&L),O.cRLSign=2==(2&L),O.encipherOnly=1==(1&L),O.decipherOnly=128==(128&$)}else if("basicConstraints"===O.name){var V=l.fromDer(O.value);O.cA=V.value.length>0&&V.value[0].type===l.Type.BOOLEAN&&0!==V.value[0].value.charCodeAt(0);var re=null;V.value.length>0&&V.value[0].type===l.Type.INTEGER?re=V.value[0].value:V.value.length>1&&(re=V.value[1].value),null!==re&&(O.pathLenConstraint=l.derToInteger(re))}else if("extKeyUsage"===O.name){V=l.fromDer(O.value);for(var z=0;z1&&(L=V.value.charCodeAt(1)),O.client=128==(128&L),O.server=64==(64&L),O.email=32==(32&L),O.objsign=16==(16&L),O.reserved=8==(8&L),O.sslCA=4==(4&L),O.emailCA=2==(2&L),O.objCA=1==(1&L);else if("subjectAltName"===O.name||"issuerAltName"===O.name){O.altNames=[],V=l.fromDer(O.value);for(var X,q=0;q=k&&C0&&L.value.push(g.certificateExtensionsToAsn1(C.extensions)),L},g.getCertificationRequestInfo=function(C){return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.INTEGER,!1,l.integerToDer(C.version).getBytes()),I(C.subject),g.publicKeyToAsn1(C.publicKey),M(C)])},g.distinguishedNameToAsn1=function(C){return I(C)},g.certificateToAsn1=function(C){var O=C.tbsCertificate||g.getTBSCertificate(C);return l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[O,l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[l.create(l.Class.UNIVERSAL,l.Type.OID,!1,l.oidToDer(C.signatureOid).getBytes()),T(C.signatureOid,C.signatureParameters)]),l.create(l.Class.UNIVERSAL,l.Type.BITSTRING,!1,String.fromCharCode(0)+C.signature)])},g.certificateExtensionsToAsn1=function(C){var O=l.create(l.Class.CONTEXT_SPECIFIC,3,!0,[]),V=l.create(l.Class.UNIVERSAL,l.Type.SEQUENCE,!0,[]);O.value.push(V);for(var L=0;L"u"&&($=new Date);var re=!0,z=null,te=0;do{var X=O.shift(),q=null,ne=!1;if($&&($X.validity.notAfter)&&(z={message:"Certificate is not valid yet or has expired.",error:g.certificateError.certificate_expired,notBefore:X.validity.notBefore,notAfter:X.validity.notAfter,now:$}),null===z){if(null===(q=O[0]||C.getIssuer(X))&&X.isIssuer(X)&&(ne=!0,q=X),q){var se=q;y.util.isArray(se)||(se=[se]);for(var de=!1;!de&&se.length>0;){q=se.shift();try{de=q.verify(X)}catch{}}de||(z={message:"Certificate signature is invalid.",error:g.certificateError.bad_certificate})}null===z&&(!q||ne)&&!C.hasCertificate(X)&&(z={message:"Certificate is not trusted.",error:g.certificateError.unknown_ca})}if(null===z&&q&&!X.isIssuer(q)&&(z={message:"Certificate issuer is invalid.",error:g.certificateError.bad_certificate}),null===z)for(var pe={keyUsage:!0,basicConstraints:!0},Le=0;null===z&&LePe.pathLenConstraint&&(z={message:"Certificate basicConstraints pathLenConstraint violated.",error:g.certificateError.bad_certificate})}var H=null===z||z.error,Ee=V.verify?V.verify(H,te,L):H;if(!0!==Ee)throw!0===H&&(z={message:"The application rejected the certificate.",error:g.certificateError.bad_certificate}),(Ee||0===Ee)&&("object"!=typeof Ee||y.util.isArray(Ee)?"string"==typeof Ee&&(z.error=Ee):(Ee.message&&(z.message=Ee.message),Ee.error&&(z.error=Ee.error))),z;z=null,re=!1,++te}while(O.length>0);return!0}},8614:(Y,U,x)=>{const y=x(1159),l=x(281);Y.exports=class{constructor(){this._buffer=new y,this._waitingConsumers=new y}push(w){const{promise:m,resolve:h}=l();return this._buffer.push({chunk:w,resolve:h}),this._consume(),m}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const w=this._waitingConsumers.shift(),m=this._buffer.shift();w.resolve(m.chunk),m.resolve()}}shift(){const{promise:w,resolve:m}=l();return this._waitingConsumers.push({resolve:m}),this._consume(),w}isEmpty(){return this._buffer.isEmpty()}}},281:Y=>{"use strict";Y.exports=()=>{const x={};return x.promise=new Promise((y,l)=>{x.resolve=y,x.reject=l}),x}},4108:(Y,U,x)=>{"use strict";Y.exports=x(8777).default},8777:function(Y,U,x){"use strict";var y=this&&this.__importDefault||function(b){return b&&b.__esModule?b:{default:b}};Object.defineProperty(U,"__esModule",{value:!0});const l=x(7910),g=y(x(4066)),w=y(x(382)),m=x(1396),c=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map(b=>new l.Netmask(b));function d(b){return/^::$/.test(b)||/^::1$/.test(b)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(b)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(b)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(b)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(b)||/^ff([0-9a-fA-F]{2,2}):/i.test(b)}U.default=b=>{if((0,m.isValid)(b)){const S=(0,m.parse)(b);if("ipv4"===S.kind())return function f(b){for(let S of c)if(S.contains(b))return!0;return!1}(S.toNormalizedString());if("ipv6"===S.kind())return d(b)}else if((0,w.default)(b)&&g.default.v6().test(b))return d(b)}},382:(Y,U,x)=>{"use strict";const y=x(4066),l=g=>y({exact:!0}).test(g);l.v4=g=>y.v4({exact:!0}).test(g),l.v6=g=>y.v6({exact:!0}).test(g),l.version=g=>l(g)?l.v4(g)?4:6:void 0,Y.exports=l},3863:(Y,U,x)=>{"use strict";Y.exports=x(2540)},4599:Y=>{"use strict";Y.exports=x;var y,U=/\/|\./;function x(l,g){U.test(l)||(l="google/protobuf/"+l+".proto",g={nested:{google:{nested:{protobuf:{nested:g}}}}}),x[l]=g}x("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),x("duration",{Duration:y={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),x("timestamp",{Timestamp:y}),x("empty",{Empty:{fields:{}}}),x("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),x("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),x("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),x.get=function(g){return x[g]||null}},6533:(Y,U,x)=>{"use strict";var y=U,l=x(4269),g=x(8572);function w(h,c,f,d){var b=!1;if(c.resolvedType)if(c.resolvedType instanceof l){h("switch(d%s){",d);for(var S=c.resolvedType.values,E=Object.keys(S),v=0;v>>0",d,d);break;case"int32":case"sint32":case"sfixed32":h("m%s=d%s|0",d,d);break;case"uint64":p=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",d,d,p)('else if(typeof d%s==="string")',d)("m%s=parseInt(d%s,10)",d,d)('else if(typeof d%s==="number")',d)("m%s=d%s",d,d)('else if(typeof d%s==="object")',d)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",d,d,d,p?"true":"");break;case"bytes":h('if(typeof d%s==="string")',d)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",d,d,d)("else if(d%s.length >= 0)",d)("m%s=d%s",d,d);break;case"string":h("m%s=String(d%s)",d,d);break;case"bool":h("m%s=Boolean(d%s)",d,d)}}return h}function m(h,c,f,d){if(c.resolvedType)c.resolvedType instanceof l?h("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",d,f,d,d,f,d,d):h("d%s=types[%i].toObject(m%s,o)",d,f,d);else{var b=!1;switch(c.type){case"double":case"float":h("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",d,d,d,d);break;case"uint64":b=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":h('if(typeof m%s==="number")',d)("d%s=o.longs===String?String(m%s):m%s",d,d,d)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",d,d,d,d,b?"true":"",d);break;case"bytes":h("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",d,d,d,d,d);break;default:h("d%s=m%s",d,d)}}return h}y.fromObject=function(c){var f=c.fieldsArray,d=g.codegen(["d"],c.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!f.length)return d("return new this.ctor");d("var m=new this.ctor");for(var b=0;b{"use strict";Y.exports=function m(h){var c=g.codegen(["r","l"],h.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(h.fieldsArray.filter(function(v){return v.map}).length?",k,value":""))("while(r.pos>>3){");for(var f=0;f>>3){")("case 1: k=r.%s(); break",d.keyType)("case 2:"),void 0===l.basic[b]?c("value=types[%i].decode(r,r.uint32())",f):c("value=r.%s()",b),c("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),c(void 0!==l.long[d.keyType]?'%s[typeof k==="object"?util.longToHash(k):k]=value':"%s[k]=value",S)):d.repeated?(c("if(!(%s&&%s.length))",S,S)("%s=[]",S),void 0!==l.packed[b]&&c("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";Y.exports=function m(h){for(var d,c=g.codegen(["m","w"],h.name+"$encode")("if(!w)")("w=Writer.create()"),b=h.fieldsArray.slice().sort(g.compareFieldsById),f=0;f>>0,8|l.mapKey[S.keyType],S.keyType),void 0===p?c("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",E,d):c(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|p,v,d),c("}")("}")):S.repeated?(c("if(%s!=null&&%s.length){",d,d),S.packed&&void 0!==l.packed[v]?c("w.uint32(%i).fork()",(S.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",d)("w.%s(%s[i])",v,d)("w.ldelim()"):(c("for(var i=0;i<%s.length;++i)",d),void 0===p?w(c,S,E,d+"[i]"):c("w.uint32(%i).%s(%s[i])",(S.id<<3|p)>>>0,v,d)),c("}")):(S.optional&&c("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",d,S.name),void 0===p?w(c,S,E,d):c("w.uint32(%i).%s(%s)",(S.id<<3|p)>>>0,v,d))}return c("return w")};var y=x(4269),l=x(688),g=x(8572);function w(h,c,f,d){return c.resolvedType.group?h("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",f,d,(c.id<<3|3)>>>0,(c.id<<3|4)>>>0):h("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",f,d,(c.id<<3|2)>>>0)}},4269:(Y,U,x)=>{"use strict";Y.exports=w;var y=x(9487);((w.prototype=Object.create(y.prototype)).constructor=w).className="Enum";var l=x(326),g=x(8572);function w(m,h,c,f,d,b){if(y.call(this,m,c),h&&"object"!=typeof h)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=f,this.comments=d||{},this.valuesOptions=b,this.reserved=void 0,h)for(var S=Object.keys(h),E=0;E{"use strict";Y.exports=c;var y=x(9487);((c.prototype=Object.create(y.prototype)).constructor=c).className="Field";var m,l=x(4269),g=x(688),w=x(8572),h=/^required|optional|repeated$/;function c(f,d,b,S,E,v,p){if(w.isObject(S)?(p=E,v=S,S=E=void 0):w.isObject(E)&&(p=v,v=E,E=void 0),y.call(this,f,v),!w.isInteger(d)||d<0)throw TypeError("id must be a non-negative integer");if(!w.isString(b))throw TypeError("type must be a string");if(void 0!==S&&!h.test(S=S.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==E&&!w.isString(E))throw TypeError("extend must be a string");"proto3_optional"===S&&(S="optional"),this.rule=S&&"optional"!==S?S:void 0,this.type=b,this.id=d,this.extend=E||void 0,this.required="required"===S,this.optional=!this.required,this.repeated="repeated"===S,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!w.Long&&void 0!==g.long[b],this.bytes="bytes"===b,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=p}c.fromJSON=function(d,b){return new c(d,b.id,b.type,b.rule,b.extend,b.options,b.comment)},Object.defineProperty(c.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),c.prototype.setOption=function(d,b,S){return"packed"===d&&(this._packed=null),y.prototype.setOption.call(this,d,b,S)},c.prototype.toJSON=function(d){var b=!!d&&Boolean(d.keepComments);return w.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",b?this.comment:void 0])},c.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=g.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.typeDefault=this.resolvedType instanceof m?null:this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof l&&"string"==typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&((!0===this.options.packed||void 0!==this.options.packed&&this.resolvedType&&!(this.resolvedType instanceof l))&&delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=w.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"==typeof this.typeDefault){var d;w.base64.test(this.typeDefault)?w.base64.decode(this.typeDefault,d=w.newBuffer(w.base64.length(this.typeDefault)),0):w.utf8.write(this.typeDefault,d=w.newBuffer(w.utf8.length(this.typeDefault)),0),this.typeDefault=d}return this.defaultValue=this.map?w.emptyObject:this.repeated?w.emptyArray:this.typeDefault,this.parent instanceof m&&(this.parent.ctor.prototype[this.name]=this.defaultValue),y.prototype.resolve.call(this)},c.d=function(d,b,S,E){return"function"==typeof b?b=w.decorateType(b).name:b&&"object"==typeof b&&(b=w.decorateEnum(b).name),function(p,I){w.decorateType(p.constructor).add(new c(I,d,b,S,{default:E}))}},c._configure=function(d){m=d}},5803:(Y,U,x)=>{"use strict";var y=Y.exports=x(95);y.build="light",y.load=function l(w,m,h){return"function"==typeof m?(h=m,m=new y.Root):m||(m=new y.Root),m.load(w,h)},y.loadSync=function g(w,m){return m||(m=new y.Root),m.loadSync(w)},y.encoder=x(133),y.decoder=x(225),y.verifier=x(8617),y.converter=x(6533),y.ReflectionObject=x(9487),y.Namespace=x(326),y.Root=x(5257),y.Enum=x(4269),y.Type=x(7845),y.Field=x(2986),y.OneOf=x(7397),y.MapField=x(9455),y.Service=x(9630),y.Method=x(1618),y.Message=x(1413),y.wrappers=x(761),y.types=x(688),y.util=x(8572),y.ReflectionObject._configure(y.Root),y.Namespace._configure(y.Type,y.Service,y.Enum),y.Root._configure(y.Type),y.Field._configure(y.Type)},95:(Y,U,x)=>{"use strict";var y=U;function l(){y.util._configure(),y.Writer._configure(y.BufferWriter),y.Reader._configure(y.BufferReader)}y.build="minimal",y.Writer=x(1650),y.BufferWriter=x(813),y.Reader=x(7270),y.BufferReader=x(4354),y.util=x(7211),y.rpc=x(7830),y.roots=x(6671),y.configure=l,l()},2540:(Y,U,x)=>{"use strict";var y=Y.exports=x(5803);y.build="full",y.tokenize=x(691),y.parse=x(8992),y.common=x(4599),y.Root._configure(y.Type,y.parse,y.common)},9455:(Y,U,x)=>{"use strict";Y.exports=w;var y=x(2986);((w.prototype=Object.create(y.prototype)).constructor=w).className="MapField";var l=x(688),g=x(8572);function w(m,h,c,f,d,b){if(y.call(this,m,h,f,void 0,void 0,d,b),!g.isString(c))throw TypeError("keyType must be a string");this.keyType=c,this.resolvedKeyType=null,this.map=!0}w.fromJSON=function(h,c){return new w(h,c.id,c.keyType,c.type,c.options,c.comment)},w.prototype.toJSON=function(h){var c=!!h&&Boolean(h.keepComments);return g.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",c?this.comment:void 0])},w.prototype.resolve=function(){if(this.resolved)return this;if(void 0===l.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return y.prototype.resolve.call(this)},w.d=function(h,c,f){return"function"==typeof f?f=g.decorateType(f).name:f&&"object"==typeof f&&(f=g.decorateEnum(f).name),function(b,S){g.decorateType(b.constructor).add(new w(S,h,c,f))}}},1413:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(g){if(g)for(var w=Object.keys(g),m=0;m{"use strict";Y.exports=g;var y=x(9487);((g.prototype=Object.create(y.prototype)).constructor=g).className="Method";var l=x(8572);function g(w,m,h,c,f,d,b,S,E){if(l.isObject(f)?(b=f,f=d=void 0):l.isObject(d)&&(b=d,d=void 0),void 0!==m&&!l.isString(m))throw TypeError("type must be a string");if(!l.isString(h))throw TypeError("requestType must be a string");if(!l.isString(c))throw TypeError("responseType must be a string");y.call(this,w,b),this.type=m||"rpc",this.requestType=h,this.requestStream=!!f||void 0,this.responseType=c,this.responseStream=!!d||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=S,this.parsedOptions=E}g.fromJSON=function(m,h){return new g(m,h.type,h.requestType,h.responseType,h.requestStream,h.responseStream,h.options,h.comment,h.parsedOptions)},g.prototype.toJSON=function(m){var h=!!m&&Boolean(m.keepComments);return l.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",h?this.comment:void 0,"parsedOptions",this.parsedOptions])},g.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),y.prototype.resolve.call(this))}},326:(Y,U,x)=>{"use strict";Y.exports=d;var y=x(9487);((d.prototype=Object.create(y.prototype)).constructor=d).className="Namespace";var m,h,c,l=x(2986),g=x(8572),w=x(7397);function f(S,E){if(S&&S.length){for(var v={},p=0;pv)return!0;return!1},d.isReservedName=function(E,v){if(E)for(var p=0;p0;){var I=E.shift();if(p.nested&&p.nested[I]){if(!((p=p.nested[I])instanceof d))throw Error("path conflicts with non-namespace objects")}else p.add(p=new d(I))}return v&&p.addJSON(v),p},d.prototype.resolveAll=function(){for(var E=this.nestedArray,v=0;v-1)return I}else if(I instanceof d&&(I=I.lookup(E.slice(1),v,!0)))return I}else for(var A=0;A{"use strict";Y.exports=g,g.className="ReflectionObject";var l,y=x(8572);function g(w,m){if(!y.isString(w))throw TypeError("name must be a string");if(m&&!y.isObject(m))throw TypeError("options must be an object");this.options=m,this.parsedOptions=null,this.name=w,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(g.prototype,{root:{get:function(){for(var w=this;null!==w.parent;)w=w.parent;return w}},fullName:{get:function(){for(var w=[this.name],m=this.parent;m;)w.unshift(m.name),m=m.parent;return w.join(".")}}}),g.prototype.toJSON=function(){throw Error()},g.prototype.onAdd=function(m){this.parent&&this.parent!==m&&this.parent.remove(this),this.parent=m,this.resolved=!1;var h=m.root;h instanceof l&&h._handleAdd(this)},g.prototype.onRemove=function(m){var h=m.root;h instanceof l&&h._handleRemove(this),this.parent=null,this.resolved=!1},g.prototype.resolve=function(){return this.resolved||this.root instanceof l&&(this.resolved=!0),this},g.prototype.getOption=function(m){if(this.options)return this.options[m]},g.prototype.setOption=function(m,h,c){return(!c||!this.options||void 0===this.options[m])&&((this.options||(this.options={}))[m]=h),this},g.prototype.setParsedOption=function(m,h,c){this.parsedOptions||(this.parsedOptions=[]);var f=this.parsedOptions;if(c){var d=f.find(function(E){return Object.prototype.hasOwnProperty.call(E,m)});d?y.setProperty(d[m],c,h):((d={})[m]=y.setProperty({},c,h),f.push(d))}else{var S={};S[m]=h,f.push(S)}return this},g.prototype.setOptions=function(m,h){if(m)for(var c=Object.keys(m),f=0;f{"use strict";Y.exports=w;var y=x(9487);((w.prototype=Object.create(y.prototype)).constructor=w).className="OneOf";var l=x(2986),g=x(8572);function w(h,c,f,d){if(Array.isArray(c)||(f=c,c=void 0),y.call(this,h,f),void 0!==c&&!Array.isArray(c))throw TypeError("fieldNames must be an Array");this.oneof=c||[],this.fieldsArray=[],this.comment=d}function m(h){if(h.parent)for(var c=0;c-1&&this.oneof.splice(f,1),c.partOf=null,this},w.prototype.onAdd=function(c){y.prototype.onAdd.call(this,c);for(var d=0;d{"use strict";Y.exports=F,F.filename=null,F.defaults={keepCase:!1};var y=x(691),l=x(5257),g=x(7845),w=x(2986),m=x(9455),h=x(7397),c=x(4269),f=x(9630),d=x(1618),b=x(688),S=x(8572),E=/^[1-9][0-9]*$/,v=/^-?[1-9][0-9]*$/,p=/^0[x][0-9a-fA-F]+$/,I=/^-?0[x][0-9a-fA-F]+$/,A=/^0[0-7]+$/,P=/^-?0[0-7]+$/,D=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,T=/^[a-zA-Z_][a-zA-Z_0-9]*$/,M=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,k=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function F(G,C,O){C instanceof l||(O=C,C=new l),O||(O=F.defaults);var ne,se,de,pe,Ke,V=O.preferTrailingComment||!1,L=y(G,O.alternateCommentMode||!1),$=L.next,re=L.push,z=L.peek,te=L.skip,X=L.cmnt,q=!0,Le=!1,Se=C,Pe=O.keepCase?function(we){return we}:S.camelCase;function be(we,ge,De){var Fe=F.filename;return De||(F.filename=null),Error("illegal "+(ge||"token")+" '"+we+"' ("+(Fe?Fe+", ":"")+"line "+L.line+")")}function $e(){var ge,we=[];do{if('"'!==(ge=$())&&"'"!==ge)throw be(ge);we.push($()),te(ge),ge=z()}while('"'===ge||"'"===ge);return we.join("")}function H(we){var ge=$();switch(ge){case"'":case'"':return re(ge),$e();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function Te(we,ge){var De=1;switch("-"===we.charAt(0)&&(De=-1,we=we.substring(1)),we){case"inf":case"INF":case"Inf":return De*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(E.test(we))return De*parseInt(we,10);if(p.test(we))return De*parseInt(we,16);if(A.test(we))return De*parseInt(we,8);if(D.test(we))return De*parseFloat(we);throw be(we,"number",ge)}(ge,!0)}catch{if(we&&M.test(ge))return ge;throw be(ge,"value")}}function Ee(we,ge){var De,Fe;do{!ge||'"'!==(De=z())&&"'"!==De?we.push([Fe=xe($()),te("to",!0)?xe($()):Fe]):we.push($e())}while(te(",",!0));te(";")}function xe(we,ge){switch(we){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!ge&&"-"===we.charAt(0))throw be(we,"id");if(v.test(we))return parseInt(we,10);if(I.test(we))return parseInt(we,16);if(P.test(we))return parseInt(we,8);throw be(we,"id")}function He(){if(void 0!==ne)throw be("package");if(ne=$(),!M.test(ne))throw be(ne,"name");Se=Se.define(ne),te(";")}function We(){var ge,we=z();switch(we){case"weak":ge=de||(de=[]),$();break;case"public":$();default:ge=se||(se=[])}we=$e(),te(";"),ge.push(we)}function Je(){if(te("="),pe=$e(),!(Le="proto3"===pe)&&"proto2"!==pe)throw be(pe,"syntax");te(";")}function Xe(we,ge){switch(ge){case"option":return ye(we,ge),te(";"),!0;case"message":return pt(we,ge),!0;case"enum":return ie(we,ge),!0;case"service":return function qe(we,ge){if(!T.test(ge=$()))throw be(ge,"service name");var De=new f(ge);Nt(De,function(Be){if(!Xe(De,Be)){if("rpc"!==Be)throw be(Be);!function it(we,ge){var De=X(),Fe=ge;if(!T.test(ge=$()))throw be(ge,"name");var dt,xt,mt,et,Be=ge;if(te("("),te("stream",!0)&&(xt=!0),!M.test(ge=$())||(dt=ge,te(")"),te("returns"),te("("),te("stream",!0)&&(et=!0),!M.test(ge=$())))throw be(ge);mt=ge,te(")");var Tn=new d(Be,Fe,dt,mt,xt,et);Tn.comment=De,Nt(Tn,function(pn){if("option"!==pn)throw be(pn);ye(Tn,pn),te(";")}),we.add(Tn)}(De,Be)}}),we.add(De)}(we,ge),!0;case"extend":return function nt(we,ge){if(!M.test(ge=$()))throw be(ge,"reference");var De=ge;Nt(null,function(Be){switch(Be){case"required":case"repeated":_t(we,Be,De);break;case"optional":_t(we,Le?"proto3_optional":"optional",De);break;default:if(!Le||!M.test(Be))throw be(Be);re(Be),_t(we,"optional",De)}})}(we,ge),!0}return!1}function Nt(we,ge,De){var Fe=L.line;if(we&&("string"!=typeof we.comment&&(we.comment=X()),we.filename=F.filename),te("{",!0)){for(var Be;"}"!==(Be=$());)ge(Be);te(";",!0)}else De&&De(),te(";"),we&&("string"!=typeof we.comment||V)&&(we.comment=X(Fe)||we.comment)}function pt(we,ge){if(!T.test(ge=$()))throw be(ge,"type name");var De=new g(ge);Nt(De,function(Be){if(!Xe(De,Be))switch(Be){case"map":!function gr(we){te("<");var ge=$();if(void 0===b.mapKey[ge])throw be(ge,"type");te(",");var De=$();if(!M.test(De))throw be(De,"type");te(">");var Fe=$();if(!T.test(Fe))throw be(Fe,"name");te("=");var Be=new m(Pe(Fe),xe($()),ge,De);Nt(Be,function(xt){if("option"!==xt)throw be(xt);ye(Be,xt),te(";")},function(){Qe(Be)}),we.add(Be)}(De);break;case"required":case"repeated":_t(De,Be);break;case"optional":_t(De,Le?"proto3_optional":"optional");break;case"oneof":!function Hr(we,ge){if(!T.test(ge=$()))throw be(ge,"name");var De=new h(Pe(ge));Nt(De,function(Be){"option"===Be?(ye(De,Be),te(";")):(re(Be),_t(De,"optional"))}),we.add(De)}(De,Be);break;case"extensions":Ee(De.extensions||(De.extensions=[]));break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:if(!Le||!M.test(Be))throw be(Be);re(Be),_t(De,"optional")}}),we.add(De)}function _t(we,ge,De){var Fe=$();if("group"!==Fe){if(!M.test(Fe))throw be(Fe,"type");var Be=$();if(!T.test(Be))throw be(Be,"name");Be=Pe(Be),te("=");var dt=new w(Be,xe($()),Fe,ge,De);if(Nt(dt,function(et){if("option"!==et)throw be(et);ye(dt,et),te(";")},function(){Qe(dt)}),"proto3_optional"===ge){var xt=new h("_"+Be);dt.setOption("proto3_optional",!0),xt.add(dt),we.add(xt)}else we.add(dt);!Le&&dt.repeated&&(void 0!==b.packed[Fe]||void 0===b.basic[Fe])&&dt.setOption("packed",!1,!0)}else!function Or(we,ge){var De=$();if(!T.test(De))throw be(De,"name");var Fe=S.lcFirst(De);De===Fe&&(De=S.ucFirst(De)),te("=");var Be=xe($()),dt=new g(De);dt.group=!0;var xt=new w(Fe,Be,De,ge);xt.filename=F.filename,Nt(dt,function(et){switch(et){case"option":ye(dt,et),te(";");break;case"required":case"repeated":_t(dt,et);break;case"optional":_t(dt,Le?"proto3_optional":"optional");break;case"message":pt(dt,et);break;case"enum":ie(dt,et);break;default:throw be(et)}}),we.add(dt).add(xt)}(we,ge)}function ie(we,ge){if(!T.test(ge=$()))throw be(ge,"name");var De=new c(ge);Nt(De,function(Be){switch(Be){case"option":ye(De,Be),te(";");break;case"reserved":Ee(De.reserved||(De.reserved=[]),!0);break;default:!function fe(we,ge){if(!T.test(ge))throw be(ge,"name");te("=");var De=xe($(),!0),Fe={options:void 0,setOption:function(Be,dt){void 0===this.options&&(this.options={}),this.options[Be]=dt}};Nt(Fe,function(dt){if("option"!==dt)throw be(dt);ye(Fe,dt),te(";")},function(){Qe(Fe)}),we.add(ge,De,Fe.comment,Fe.options)}(De,Be)}}),we.add(De)}function ye(we,ge){var De=te("(",!0);if(!M.test(ge=$()))throw be(ge,"name");var dt,Fe=ge,Be=Fe;De&&(te(")"),Be=Fe="("+Fe+")",ge=z(),k.test(ge)&&(dt=ge.slice(1),Fe+=ge,$())),te("="),function Ne(we,ge,De,Fe){we.setParsedOption&&we.setParsedOption(ge,De,Fe)}(we,Be,me(we,Fe),dt)}function me(we,ge){if(te("{",!0)){for(var De={};!te("}",!0);){if(!T.test(Ke=$()))throw be(Ke,"name");var Fe,Be=Ke;if(te(":",!0),"{"===z())Fe=me(we,ge+"."+Ke);else if("["===z()){var dt;if(Fe=[],te("[",!0)){do{dt=H(!0),Fe.push(dt)}while(te(",",!0));te("]"),typeof dt<"u"&&_e(we,ge+"."+Ke,dt)}}else Fe=H(!0),_e(we,ge+"."+Ke,Fe);var xt=De[Be];xt&&(Fe=[].concat(xt).concat(Fe)),De[Be]=Fe,te(",",!0),te(";",!0)}return De}var mt=H(!0);return _e(we,ge,mt),mt}function _e(we,ge,De){we.setOption&&we.setOption(ge,De)}function Qe(we){if(te("[",!0)){do{ye(we,"option")}while(te(",",!0));te("]")}return we}for(;null!==(Ke=$());)switch(Ke){case"package":if(!q)throw be(Ke);He();break;case"import":if(!q)throw be(Ke);We();break;case"syntax":if(!q)throw be(Ke);Je();break;case"option":ye(Se,Ke),te(";");break;default:if(Xe(Se,Ke)){q=!1;continue}throw be(Ke)}return F.filename=null,{package:ne,imports:se,weakImports:de,syntax:pe,root:C}}},7270:(Y,U,x)=>{"use strict";Y.exports=h;var l,y=x(7211),g=y.LongBits,w=y.utf8;function m(E,v){return RangeError("index out of range: "+E.pos+" + "+(v||1)+" > "+E.len)}function h(E){this.buf=E,this.pos=0,this.len=E.length}var v,c=typeof Uint8Array<"u"?function(v){if(v instanceof Uint8Array||Array.isArray(v))return new h(v);throw Error("illegal buffer")}:function(v){if(Array.isArray(v))return new h(v);throw Error("illegal buffer")},f=function(){return y.Buffer?function(p){return(h.create=function(A){return y.Buffer.isBuffer(A)?new l(A):c(A)})(p)}:c};function d(){var E=new g(0,0),v=0;if(!(this.len-this.pos>4)){for(;v<3;++v){if(this.pos>=this.len)throw m(this);if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E}return E.lo=(E.lo|(127&this.buf[this.pos++])<<7*v)>>>0,E}for(;v<4;++v)if(E.lo=(E.lo|(127&this.buf[this.pos])<<7*v)>>>0,this.buf[this.pos++]<128)return E;if(E.lo=(E.lo|(127&this.buf[this.pos])<<28)>>>0,E.hi=(E.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return E;if(v=0,this.len-this.pos>4){for(;v<5;++v)if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}else for(;v<5;++v){if(this.pos>=this.len)throw m(this);if(E.hi=(E.hi|(127&this.buf[this.pos])<<7*v+3)>>>0,this.buf[this.pos++]<128)return E}throw Error("invalid varint encoding")}function b(E,v){return(E[v-4]|E[v-3]<<8|E[v-2]<<16|E[v-1]<<24)>>>0}function S(){if(this.pos+8>this.len)throw m(this,8);return new g(b(this.buf,this.pos+=4),b(this.buf,this.pos+=4))}h.create=f(),h.prototype._slice=y.Array.prototype.subarray||y.Array.prototype.slice,h.prototype.uint32=(v=4294967295,function(){if(v=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128||(v=(v|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)||(v=(v|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)||(v=(v|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128))return v;if((this.pos+=5)>this.len)throw this.pos=this.len,m(this,10);return v}),h.prototype.int32=function(){return 0|this.uint32()},h.prototype.sint32=function(){var v=this.uint32();return v>>>1^-(1&v)|0},h.prototype.bool=function(){return 0!==this.uint32()},h.prototype.fixed32=function(){if(this.pos+4>this.len)throw m(this,4);return b(this.buf,this.pos+=4)},h.prototype.sfixed32=function(){if(this.pos+4>this.len)throw m(this,4);return 0|b(this.buf,this.pos+=4)},h.prototype.float=function(){if(this.pos+4>this.len)throw m(this,4);var v=y.float.readFloatLE(this.buf,this.pos);return this.pos+=4,v},h.prototype.double=function(){if(this.pos+8>this.len)throw m(this,4);var v=y.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,v},h.prototype.bytes=function(){var v=this.uint32(),p=this.pos,I=this.pos+v;if(I>this.len)throw m(this,v);return this.pos+=v,Array.isArray(this.buf)?this.buf.slice(p,I):p===I?new this.buf.constructor(0):this._slice.call(this.buf,p,I)},h.prototype.string=function(){var v=this.bytes();return w.read(v,0,v.length)},h.prototype.skip=function(v){if("number"==typeof v){if(this.pos+v>this.len)throw m(this,v);this.pos+=v}else do{if(this.pos>=this.len)throw m(this)}while(128&this.buf[this.pos++]);return this},h.prototype.skipType=function(E){switch(E){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(E=7&this.uint32());)this.skipType(E);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+E+" at offset "+this.pos)}return this},h._configure=function(E){l=E,h.create=f(),l._configure();var v=y.Long?"toLong":"toNumber";y.merge(h.prototype,{int64:function(){return d.call(this)[v](!1)},uint64:function(){return d.call(this)[v](!0)},sint64:function(){return d.call(this).zzDecode()[v](!1)},fixed64:function(){return S.call(this)[v](!0)},sfixed64:function(){return S.call(this)[v](!1)}})}},4354:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(7270);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(7211);function g(w){y.call(this,w)}g._configure=function(){l.Buffer&&(g.prototype._slice=l.Buffer.prototype.slice)},g.prototype.string=function(){var m=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+m,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+m,this.len))},g._configure()},5257:(Y,U,x)=>{"use strict";Y.exports=d;var y=x(326);((d.prototype=Object.create(y.prototype)).constructor=d).className="Root";var h,c,f,l=x(2986),g=x(4269),w=x(7397),m=x(8572);function d(v){y.call(this,"",v),this.deferred=[],this.files=[]}function b(){}d.fromJSON=function(p,I){return I||(I=new d),p.options&&I.setOptions(p.options),I.addJSON(p.nested)},d.prototype.resolvePath=m.path.resolve,d.prototype.fetch=m.fetch,d.prototype.load=function v(p,I,A){"function"==typeof I&&(A=I,I=void 0);var P=this;if(!A)return m.asPromise(v,P,p,I);var D=A===b;function T(V,L){if(A){var $=A;if(A=null,D)throw V;$(V,L)}}function M(V){var L=V.lastIndexOf("google/protobuf/");if(L>-1){var $=V.substring(L);if($ in f)return $}return null}function k(V,L){try{if(m.isString(L)&&"{"===L.charAt(0)&&(L=JSON.parse(L)),m.isString(L)){c.filename=V;var re,$=c(L,P,I),z=0;if($.imports)for(;z<$.imports.length;++z)(re=M($.imports[z])||P.resolvePath(V,$.imports[z]))&&F(re);if($.weakImports)for(z=0;z<$.weakImports.length;++z)(re=M($.weakImports[z])||P.resolvePath(V,$.weakImports[z]))&&F(re,!0)}else P.setOptions(L.options).addJSON(L.nested)}catch(te){T(te)}!D&&!G&&T(null,P)}function F(V,L){if(!(P.files.indexOf(V)>-1)){if(P.files.push(V),V in f)return void(D?k(V,f[V]):(++G,setTimeout(function(){--G,k(V,f[V])})));if(D){var $;try{$=m.fs.readFileSync(V).toString("utf8")}catch(re){return void(L||T(re))}k(V,$)}else++G,P.fetch(V,function(re,z){if(--G,A){if(re)return void(L?G||T(null,P):T(re));k(V,z)}})}}var G=0;m.isString(p)&&(p=[p]);for(var O,C=0;C-1&&this.deferred.splice(I,1)}}else if(p instanceof g)S.test(p.name)&&delete p.parent[p.name];else if(p instanceof y){for(var A=0;A{"use strict";Y.exports={}},7830:(Y,U,x)=>{"use strict";U.Service=x(6346)},6346:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(g,w,m){if("function"!=typeof g)throw TypeError("rpcImpl must be a function");y.EventEmitter.call(this),this.rpcImpl=g,this.requestDelimited=Boolean(w),this.responseDelimited=Boolean(m)}(l.prototype=Object.create(y.EventEmitter.prototype)).constructor=l,l.prototype.rpcCall=function g(w,m,h,c,f){if(!c)throw TypeError("request must be specified");var d=this;if(!f)return y.asPromise(g,d,w,m,h,c);if(d.rpcImpl)try{return d.rpcImpl(w,m[d.requestDelimited?"encodeDelimited":"encode"](c).finish(),function(S,E){if(S)return d.emit("error",S,w),f(S);if(null!==E){if(!(E instanceof h))try{E=h[d.responseDelimited?"decodeDelimited":"decode"](E)}catch(v){return d.emit("error",v,w),f(v)}return d.emit("data",E,w),f(null,E)}d.end(!0)})}catch(b){return d.emit("error",b,w),void setTimeout(function(){f(b)},0)}else setTimeout(function(){f(Error("already ended"))},0)},l.prototype.end=function(w){return this.rpcImpl&&(w||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},9630:(Y,U,x)=>{"use strict";Y.exports=m;var y=x(326);((m.prototype=Object.create(y.prototype)).constructor=m).className="Service";var l=x(1618),g=x(8572),w=x(7830);function m(c,f){y.call(this,c,f),this.methods={},this._methodsArray=null}function h(c){return c._methodsArray=null,c}m.fromJSON=function(f,d){var b=new m(f,d.options);if(d.methods)for(var S=Object.keys(d.methods),E=0;E{"use strict";Y.exports=d;var U=/[\s{}=;:[\],'"()<>]/g,x=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,y=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,l=/^ *[*/]+ */,g=/^\s*\*?\/*/,w=/\n/g,m=/\s/,h=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function f(b){return b.replace(h,function(S,E){switch(E){case"\\":case"":return E;default:return c[E]||""}})}function d(b,S){b=b.toString();var E=0,v=b.length,p=1,I=0,A={},P=[],D=null;function T(z){return Error("illegal "+z+" (line "+p+")")}function k(z){return b.charAt(z)}function F(z,te,X){var de,q={type:b.charAt(z++),lineEmpty:!1,leading:X},se=z-(S?2:3);do{if(--se<0||"\n"===(de=b.charAt(se))){q.lineEmpty=!0;break}}while(" "===de||"\t"===de);for(var pe=b.substring(z,te).split(w),Le=0;Le0)return P.shift();if(D)return function M(){var z="'"===D?y:x;z.lastIndex=E-1;var te=z.exec(b);if(!te)throw T("string");return E=z.lastIndex,V(D),D=null,f(te[1])}();var z,te,X,q,ne,se=0===E;do{if(E===v)return null;for(z=!1;m.test(X=k(E));)if("\n"===X&&(se=!0,++p),++E===v)return null;if("/"===k(E)){if(++E===v)throw T("comment");if("/"===k(E))if(S){if(q=E,ne=!1,G(E)){ne=!0;do{if((E=C(E))===v||(E++,!se))break}while(G(E))}else E=Math.min(v,C(E)+1);ne&&(F(q,E,se),se=!0),p++,z=!0}else{for(ne="/"===k(q=E+1);"\n"!==k(++E);)if(E===v)return null;++E,ne&&(F(q,E-1,se),se=!0),++p,z=!0}else{if("*"!==(X=k(E)))return"/";q=E+1,ne=S||"*"===k(q);do{if("\n"===X&&++p,++E===v)throw T("comment");te=X,X=k(E)}while("*"!==te||"/"!==X);++E,ne&&(F(q,E-2,se),se=!0),z=!0}}}while(z);var de=E;if(U.lastIndex=0,!U.test(k(de++)))for(;de{"use strict";Y.exports=A;var y=x(326);((A.prototype=Object.create(y.prototype)).constructor=A).className="Type";var l=x(4269),g=x(7397),w=x(2986),m=x(9455),h=x(9630),c=x(1413),f=x(7270),d=x(1650),b=x(8572),S=x(133),E=x(225),v=x(8617),p=x(6533),I=x(761);function A(D,T){y.call(this,D,T),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function P(D){return D._fieldsById=D._fieldsArray=D._oneofsArray=null,delete D.encode,delete D.decode,delete D.verify,D}Object.defineProperties(A.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var D=Object.keys(this.fields),T=0;T{"use strict";var y=U,l=x(8572),g=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function w(m,h){var c=0,f={};for(h|=0;c{"use strict";var g,w,y=Y.exports=x(7211),l=x(6671);y.codegen=x(9749),y.fetch=x(8832),y.path=x(1311),y.fs=y.inquire("fs"),y.toArray=function(b){if(b){for(var S=Object.keys(b),E=new Array(S.length),v=0;v0)p[P]=v(p[P]||{},I,A);else{var D=p[P];D&&(A=[].concat(D).concat(A)),p[P]=A}return p}(b,S=S.split("."),E)},Object.defineProperty(y,"decorateRoot",{get:function(){return l.decorated||(l.decorated=new(x(5257)))}})},942:(Y,U,x)=>{"use strict";Y.exports=l;var y=x(7211);function l(h,c){this.lo=h>>>0,this.hi=c>>>0}var g=l.zero=new l(0,0);g.toNumber=function(){return 0},g.zzEncode=g.zzDecode=function(){return this},g.length=function(){return 1};var w=l.zeroHash="\0\0\0\0\0\0\0\0";l.fromNumber=function(c){if(0===c)return g;var f=c<0;f&&(c=-c);var d=c>>>0,b=(c-d)/4294967296>>>0;return f&&(b=~b>>>0,d=~d>>>0,++d>4294967295&&(d=0,++b>4294967295&&(b=0))),new l(d,b)},l.from=function(c){if("number"==typeof c)return l.fromNumber(c);if(y.isString(c)){if(!y.Long)return l.fromNumber(parseInt(c,10));c=y.Long.fromString(c)}return c.low||c.high?new l(c.low>>>0,c.high>>>0):g},l.prototype.toNumber=function(c){if(!c&&this.hi>>>31){var f=1+~this.lo>>>0,d=~this.hi>>>0;return f||(d=d+1>>>0),-(f+4294967296*d)}return this.lo+4294967296*this.hi},l.prototype.toLong=function(c){return y.Long?new y.Long(0|this.lo,0|this.hi,Boolean(c)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(c)}};var m=String.prototype.charCodeAt;l.fromHash=function(c){return c===w?g:new l((m.call(c,0)|m.call(c,1)<<8|m.call(c,2)<<16|m.call(c,3)<<24)>>>0,(m.call(c,4)|m.call(c,5)<<8|m.call(c,6)<<16|m.call(c,7)<<24)>>>0)},l.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},l.prototype.zzEncode=function(){var c=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^c)>>>0,this.lo=(this.lo<<1^c)>>>0,this},l.prototype.zzDecode=function(){var c=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^c)>>>0,this.hi=(this.hi>>>1^c)>>>0,this},l.prototype.length=function(){var c=this.lo,f=(this.lo>>>28|this.hi<<4)>>>0,d=this.hi>>>24;return 0===d?0===f?c<16384?c<128?1:2:c<2097152?3:4:f<16384?f<128?5:6:f<2097152?7:8:d<128?9:10}},7211:function(Y,U,x){"use strict";var y=U;function l(w,m,h){for(var c=Object.keys(m),f=0;fw,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),m}y.asPromise=x(1280),y.base64=x(9039),y.EventEmitter=x(9889),y.float=x(530),y.inquire=x(716),y.utf8=x(7768),y.pool=x(4479),y.LongBits=x(942),y.isNode=Boolean(typeof global<"u"&&global&&global.process&&global.process.versions&&global.process.versions.node),y.global=y.isNode&&global||typeof window<"u"&&window||typeof self<"u"&&self||this,y.emptyArray=Object.freeze?Object.freeze([]):[],y.emptyObject=Object.freeze?Object.freeze({}):{},y.isInteger=Number.isInteger||function(m){return"number"==typeof m&&isFinite(m)&&Math.floor(m)===m},y.isString=function(m){return"string"==typeof m||m instanceof String},y.isObject=function(m){return m&&"object"==typeof m},y.isset=y.isSet=function(m,h){var c=m[h];return!(null==c||!m.hasOwnProperty(h))&&("object"!=typeof c||(Array.isArray(c)?c.length:Object.keys(c).length)>0)},y.Buffer=function(){try{var w=y.inquire("buffer").Buffer;return w.prototype.utf8Write?w:null}catch{return null}}(),y._Buffer_from=null,y._Buffer_allocUnsafe=null,y.newBuffer=function(m){return"number"==typeof m?y.Buffer?y._Buffer_allocUnsafe(m):new y.Array(m):y.Buffer?y._Buffer_from(m):typeof Uint8Array>"u"?m:new Uint8Array(m)},y.Array=typeof Uint8Array<"u"?Uint8Array:Array,y.Long=y.global.dcodeIO&&y.global.dcodeIO.Long||y.global.Long||y.inquire("long"),y.key2Re=/^true|false|0|1$/,y.key32Re=/^-?(?:0|[1-9][0-9]*)$/,y.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,y.longToHash=function(m){return m?y.LongBits.from(m).toHash():y.LongBits.zeroHash},y.longFromHash=function(m,h){var c=y.LongBits.fromHash(m);return y.Long?y.Long.fromBits(c.lo,c.hi,h):c.toNumber(Boolean(h))},y.merge=l,y.lcFirst=function(m){return m.charAt(0).toLowerCase()+m.substring(1)},y.newError=g,y.ProtocolError=g("ProtocolError"),y.oneOfGetter=function(m){for(var h={},c=0;c-1;--d)if(1===h[f[d]]&&null!=this[f[d]])return f[d]}},y.oneOfSetter=function(m){return function(h){for(var c=0;c{"use strict";Y.exports=function h(c){var f=l.codegen(["m"],c.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),b={};c.oneofsArray.length&&f("var p={}");for(var S=0;S{"use strict";var y=U,l=x(1413);y[".google.protobuf.Any"]={fromObject:function(g){if(g&&g["@type"]){var w=g["@type"].substring(g["@type"].lastIndexOf("/")+1),m=this.lookup(w);if(m){var h="."===g["@type"].charAt(0)?g["@type"].slice(1):g["@type"];return-1===h.indexOf("/")&&(h="/"+h),this.create({type_url:h,value:m.encode(m.fromObject(g)).finish()})}}return this.fromObject(g)},toObject:function(g,w){var h="",c="";if(w&&w.json&&g.type_url&&g.value){c=g.type_url.substring(g.type_url.lastIndexOf("/")+1),h=g.type_url.substring(0,g.type_url.lastIndexOf("/")+1);var f=this.lookup(c);f&&(g=f.decode(g.value))}if(!(g instanceof this.ctor)&&g instanceof l){var d=g.$type.toObject(g,w),b="."===g.$type.fullName[0]?g.$type.fullName.slice(1):g.$type.fullName;return""===h&&(h="type.googleapis.com/"),d["@type"]=c=h+b,d}return this.toObject(g,w)}}},1650:(Y,U,x)=>{"use strict";Y.exports=d;var l,y=x(7211),g=y.LongBits,w=y.base64,m=y.utf8;function h(P,D,T){this.fn=P,this.len=D,this.next=void 0,this.val=T}function c(){}function f(P){this.head=P.head,this.tail=P.tail,this.len=P.len,this.next=P.states}function d(){this.len=0,this.head=new h(c,0,0),this.tail=this.head,this.states=null}var b=function(){return y.Buffer?function(){return(d.create=function(){return new l})()}:function(){return new d}};function S(P,D,T){D[T]=255&P}function v(P,D){this.len=P,this.next=void 0,this.val=D}function p(P,D,T){for(;P.hi;)D[T++]=127&P.lo|128,P.lo=(P.lo>>>7|P.hi<<25)>>>0,P.hi>>>=7;for(;P.lo>127;)D[T++]=127&P.lo|128,P.lo=P.lo>>>7;D[T++]=P.lo}function I(P,D,T){D[T]=255&P,D[T+1]=P>>>8&255,D[T+2]=P>>>16&255,D[T+3]=P>>>24}d.create=b(),d.alloc=function(D){return new y.Array(D)},y.Array!==Array&&(d.alloc=y.pool(d.alloc,y.Array.prototype.subarray)),d.prototype._push=function(D,T,M){return this.tail=this.tail.next=new h(D,T,M),this.len+=T,this},(v.prototype=Object.create(h.prototype)).fn=function E(P,D,T){for(;P>127;)D[T++]=127&P|128,P>>>=7;D[T]=P},d.prototype.uint32=function(D){return this.len+=(this.tail=this.tail.next=new v((D>>>=0)<128?1:D<16384?2:D<2097152?3:D<268435456?4:5,D)).len,this},d.prototype.int32=function(D){return D<0?this._push(p,10,g.fromNumber(D)):this.uint32(D)},d.prototype.sint32=function(D){return this.uint32((D<<1^D>>31)>>>0)},d.prototype.int64=d.prototype.uint64=function(D){var T=g.from(D);return this._push(p,T.length(),T)},d.prototype.sint64=function(D){var T=g.from(D).zzEncode();return this._push(p,T.length(),T)},d.prototype.bool=function(D){return this._push(S,1,D?1:0)},d.prototype.sfixed32=d.prototype.fixed32=function(D){return this._push(I,4,D>>>0)},d.prototype.sfixed64=d.prototype.fixed64=function(D){var T=g.from(D);return this._push(I,4,T.lo)._push(I,4,T.hi)},d.prototype.float=function(D){return this._push(y.float.writeFloatLE,4,D)},d.prototype.double=function(D){return this._push(y.float.writeDoubleLE,8,D)};var A=y.Array.prototype.set?function(D,T,M){T.set(D,M)}:function(D,T,M){for(var k=0;k>>0;if(!T)return this._push(S,1,0);if(y.isString(D)){var M=d.alloc(T=w.length(D));w.decode(D,M,0),D=M}return this.uint32(T)._push(A,T,D)},d.prototype.string=function(D){var T=m.length(D);return T?this.uint32(T)._push(m.write,T,D):this._push(S,1,0)},d.prototype.fork=function(){return this.states=new f(this),this.head=this.tail=new h(c,0,0),this.len=0,this},d.prototype.reset=function(){return this.states?(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 h(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var D=this.head,T=this.tail,M=this.len;return this.reset().uint32(M),M&&(this.tail.next=D.next,this.tail=T,this.len+=M),this},d.prototype.finish=function(){for(var D=this.head.next,T=this.constructor.alloc(this.len),M=0;D;)D.fn(D.val,T,M),M+=D.len,D=D.next;return T},d._configure=function(P){l=P,d.create=b(),l._configure()}},813:(Y,U,x)=>{"use strict";Y.exports=g;var y=x(1650);(g.prototype=Object.create(y.prototype)).constructor=g;var l=x(7211);function g(){y.call(this)}function w(m,h,c){m.length<40?l.utf8.write(m,h,c):h.utf8Write?h.utf8Write(m,c):h.write(m,c)}g._configure=function(){g.alloc=l._Buffer_allocUnsafe,g.writeBytesBuffer=l.Buffer&&l.Buffer.prototype instanceof Uint8Array&&"set"===l.Buffer.prototype.set.name?function(h,c,f){c.set(h,f)}:function(h,c,f){if(h.copy)h.copy(c,f,0,h.length);else for(var d=0;d>>0;return this.uint32(c),c&&this._push(g.writeBytesBuffer,c,h),this},g.prototype.string=function(h){var c=l.Buffer.byteLength(h);return this.uint32(c),c&&this._push(w,c,h),this},g._configure()},7813:(Y,U,x)=>{const y=x(9301),l=x(6217),g=x(7840),w=x(939),{RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c}=x(9644),f=x(4849),d=x(6492),b=x(5936),S=x(8592),E=x(2816),v=x(9062),p=x(9658);Y.exports={RateLimiterRedis:y,RateLimiterMongo:l,RateLimiterMySQL:g,RateLimiterPostgres:w,RateLimiterMemory:f,RateLimiterMemcache:d,RateLimiterClusterMaster:m,RateLimiterClusterMasterPM2:h,RateLimiterCluster:c,RLWrapperBlackAndWhite:b,RateLimiterUnion:S,RateLimiterQueue:E,BurstyRateLimiter:v,RateLimiterRes:p}},9062:(Y,U,x)=>{const y=x(9658);Y.exports=class{constructor(g,w){this._rateLimiter=g,this._burstLimiter=w}_combineRes(g,w){return new y(g.remainingPoints,Math.min(g.msBeforeNext,w.msBeforeNext),g.consumedPoints,g.isFirstInDuration)}consume(g,w=1,m={}){return this._rateLimiter.consume(g,w,m).catch(h=>h instanceof y?this._burstLimiter.consume(g,w,m).then(c=>Promise.resolve(this._combineRes(h,c))).catch(c=>Promise.reject(c instanceof y?this._combineRes(h,c):c)):Promise.reject(h))}get(g){return Promise.all([this._rateLimiter.get(g),this._burstLimiter.get(g)]).then(([w,m])=>this._combineRes(w,m))}get points(){return this._rateLimiter.points}}},5936:(Y,U,x)=>{const y=x(9658);Y.exports=class{constructor(g={}){this.limiter=g.limiter,this.blackList=g.blackList,this.whiteList=g.whiteList,this.isBlackListed=g.isBlackListed,this.isWhiteListed=g.isWhiteListed,this.runActionAnyway=g.runActionAnyway}get limiter(){return this._limiter}set limiter(g){if(typeof g>"u")throw new Error("limiter is not set");this._limiter=g}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(g){this._runActionAnyway=!(typeof g>"u")&&g}get blackList(){return this._blackList}set blackList(g){this._blackList=Array.isArray(g)?g:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isBlackListed must be function");this._isBlackListed=g}get whiteList(){return this._whiteList}set whiteList(g){this._whiteList=Array.isArray(g)?g:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(g){if(typeof g>"u"&&(g=()=>!1),"function"!=typeof g)throw new Error("isWhiteListed must be function");this._isWhiteListed=g}isBlackListedSomewhere(g){return this.blackList.indexOf(g)>=0||this.isBlackListed(g)}isWhiteListedSomewhere(g){return this.whiteList.indexOf(g)>=0||this.isWhiteListed(g)}getBlackRes(){return new y(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new y(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(g,w=1){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.rejectBlack()),typeof m>"u"?this.limiter.consume(g,w):(this.runActionAnyway&&this.limiter.consume(g,w).catch(()=>{}),m)}block(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.block(g,w):(this.runActionAnyway&&this.limiter.block(g,w).catch(()=>{}),m)}penalty(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.penalty(g,w):(this.runActionAnyway&&this.limiter.penalty(g,w).catch(()=>{}),m)}reward(g,w){let m;return this.isWhiteListedSomewhere(g)?m=this.resolveWhite():this.isBlackListedSomewhere(g)&&(m=this.resolveBlack()),typeof m>"u"?this.limiter.reward(g,w):(this.runActionAnyway&&this.limiter.reward(g,w).catch(()=>{}),m)}get(g){let w;return this.isWhiteListedSomewhere(g)?w=this.resolveWhite():this.isBlackListedSomewhere(g)&&(w=this.resolveBlack()),typeof w>"u"||this.runActionAnyway?this.limiter.get(g):w}delete(g){return this.limiter.delete(g)}}},6953:Y=>{Y.exports=class{constructor(x={}){this.points=x.points,this.duration=x.duration,this.blockDuration=x.blockDuration,this.execEvenly=x.execEvenly,this.execEvenlyMinDelayMs=x.execEvenlyMinDelayMs,this.keyPrefix=x.keyPrefix}get points(){return this._points}set points(x){this._points=x>=0?x:4}get duration(){return this._duration}set duration(x){this._duration=typeof x>"u"?1:x}get msDuration(){return 1e3*this.duration}get blockDuration(){return this._blockDuration}set blockDuration(x){this._blockDuration=typeof x>"u"?0:x}get msBlockDuration(){return 1e3*this.blockDuration}get execEvenly(){return this._execEvenly}set execEvenly(x){this._execEvenly=!(typeof x>"u")&&Boolean(x)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(x){this._execEvenlyMinDelayMs=typeof x>"u"?Math.ceil(this.msDuration/this.points):x}get keyPrefix(){return this._keyPrefix}set keyPrefix(x){if(typeof x>"u"&&(x="rlflx"),"string"!=typeof x)throw new Error("keyPrefix must be string");this._keyPrefix=x}_getKeySecDuration(x={}){return x&&x.customDuration>=0?x.customDuration:this.duration}getKey(x){return this.keyPrefix.length>0?`${this.keyPrefix}:${x}`:x}parseKey(x){return x.substring(this.keyPrefix.length)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}},9644:(Y,U,x)=>{const y=x(1265),l=x(5539),g=x(6953),w=x(4849),m=x(9658),h="rate_limiter_flexible";let c=null;const f=function(D,T,M,k){let F;F=null===k||!0===k||!1===k?k:{remainingPoints:k.remainingPoints,msBeforeNext:k.msBeforeNext,consumedPoints:k.consumedPoints,isFirstInDuration:k.isFirstInDuration},D.send({channel:h,keyPrefix:T.keyPrefix,promiseId:T.promiseId,type:M,data:F})},d=function(D){setTimeout(()=>{this._initiated?process.send(D):typeof this._promises[D.promiseId]<"u"&&d.call(this,D)},30)},b=function(D,T,M,k,F){const G={channel:h,keyPrefix:this.keyPrefix,func:D,promiseId:T,data:{key:M,arg:k,opts:F}};this._initiated?process.send(G):d.call(this,G)},S=function(D,T){if(!T||T.channel!==h||typeof this._rateLimiters[T.keyPrefix]>"u")return!1;let M;switch(T.func){case"consume":M=this._rateLimiters[T.keyPrefix].consume(T.data.key,T.data.arg,T.data.opts);break;case"penalty":M=this._rateLimiters[T.keyPrefix].penalty(T.data.key,T.data.arg,T.data.opts);break;case"reward":M=this._rateLimiters[T.keyPrefix].reward(T.data.key,T.data.arg,T.data.opts);break;case"block":M=this._rateLimiters[T.keyPrefix].block(T.data.key,T.data.arg,T.data.opts);break;case"get":M=this._rateLimiters[T.keyPrefix].get(T.data.key,T.data.opts);break;case"delete":M=this._rateLimiters[T.keyPrefix].delete(T.data.key,T.data.opts);break;default:return!1}M&&M.then(k=>{f(D,T,"resolve",k)}).catch(k=>{f(D,T,"reject",k)})},E=function(D){if(!D||D.channel!==h||D.keyPrefix!==this.keyPrefix)return!1;if(this._promises[D.promiseId]){let T;switch(clearTimeout(this._promises[D.promiseId].timeoutId),T=null===D.data||!0===D.data||!1===D.data?D.data:new m(D.data.remainingPoints,D.data.msBeforeNext,D.data.consumedPoints,D.data.isFirstInDuration),D.type){case"resolve":this._promises[D.promiseId].resolve(T);break;case"reject":this._promises[D.promiseId].reject(T);break;default:throw new Error(`RateLimiterCluster: no such message type '${D.type}'`)}delete this._promises[D.promiseId]}},v=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},p=function(D,T){const M=process.hrtime();let k=M[0].toString()+M[1].toString();return typeof this._promises[k]<"u"&&(k+=l.randomBytes(12).toString("base64")),this._promises[k]={resolve:D,reject:T,timeoutId:setTimeout(()=>{delete this._promises[k],T(new Error("RateLimiterCluster timeout: no answer from master in time"))},this.timeoutMs)},k};Y.exports={RateLimiterClusterMaster:class I{constructor(){if(c)return c;this._rateLimiters={},y.setMaxListeners(0),y.on("message",(T,M)=>{M&&M.channel===h&&"init"===M.type?(typeof this._rateLimiters[M.opts.keyPrefix]>"u"&&(this._rateLimiters[M.opts.keyPrefix]=new w(M.opts)),T.send({channel:h,type:"init",keyPrefix:M.opts.keyPrefix})):S.call(this,T,M)}),c=this}},RateLimiterClusterMasterPM2:class A{constructor(T){if(c)return c;this._rateLimiters={},T.launchBus((M,k)=>{k.on("process:msg",F=>{const G=F.raw;G&&G.channel===h&&"init"===G.type?(typeof this._rateLimiters[G.opts.keyPrefix]>"u"&&(this._rateLimiters[G.opts.keyPrefix]=new w(G.opts)),T.sendDataToProcessId(F.process.pm_id,{data:{},topic:h,channel:h,type:"init",keyPrefix:G.opts.keyPrefix},(C,O)=>{C&&console.log(C,O)})):S.call(this,{send:O=>{const V=O;V.topic=h,typeof V.data>"u"&&(V.data={}),T.sendDataToProcessId(F.process.pm_id,V,(L,$)=>{L&&console.log(L,$)})}},G)})}),c=this}},RateLimiterCluster:class P extends g{get timeoutMs(){return this._timeoutMs}set timeoutMs(T){this._timeoutMs=typeof T>"u"?5e3:Math.abs(parseInt(T))}constructor(T={}){super(T),process.setMaxListeners(0),this.timeoutMs=T.timeoutMs,this._initiated=!1,process.on("message",M=>{M&&M.channel===h&&"init"===M.type&&M.keyPrefix===this.keyPrefix?this._initiated=!0:E.call(this,M)}),process.send({channel:h,type:"init",opts:v.call(this)}),this._promises={}}consume(T,M=1,k={}){return new Promise((F,G)=>{const C=p.call(this,F,G);b.call(this,"consume",C,T,M,k)})}penalty(T,M=1,k={}){return new Promise((F,G)=>{const C=p.call(this,F,G);b.call(this,"penalty",C,T,M,k)})}reward(T,M=1,k={}){return new Promise((F,G)=>{const C=p.call(this,F,G);b.call(this,"reward",C,T,M,k)})}block(T,M,k={}){return new Promise((F,G)=>{const C=p.call(this,F,G);b.call(this,"block",C,T,M,k)})}get(T,M={}){return new Promise((k,F)=>{const G=p.call(this,k,F);b.call(this,"get",G,T,M)})}delete(T,M={}){return new Promise((k,F)=>{const G=p.call(this,k,F);b.call(this,"delete",G,T,M)})}}}},6492:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m){super(m),this.client=m.storeClient}_getRateLimiterRes(m,h,c){const f=new l;return f.consumedPoints=parseInt(c.consumedPoints),f.isFirstInDuration=c.consumedPoints===h,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=c.msBeforeNext,f}_upsert(m,h,c,f=!1,d={}){return new Promise((b,S)=>{const E=Date.now(),v=Math.floor(c/1e3);f?this.client.set(m,h,v,p=>{p?S(p):this.client.set(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.incr(m,h,(p,I)=>{p||!1===I?this.client.add(m,h,v,(A,P)=>{if(A||!P)if(typeof d.attemptNumber>"u"||d.attemptNumber<3){const D=Object.assign({},d);D.attemptNumber=D.attemptNumber?D.attemptNumber+1:1,this._upsert(m,h,c,f,D).then(T=>b(T)).catch(T=>S(T))}else S(new Error("Can not add key"));else this.client.add(`${m}_expire`,v>0?E+1e3*v:-1,v,()=>{b({consumedPoints:h,msBeforeNext:v>0?1e3*v:-1})})}):this.client.get(`${m}_expire`,(A,P)=>{if(A)S(A);else{const D=!1===P?0:P,T={consumedPoints:I,msBeforeNext:D>=0?Math.max(D-E,0):-1};b(T)}})})})}_get(m){return new Promise((h,c)=>{const f=Date.now();this.client.get(m,(d,b)=>{b?this.client.get(`${m}_expire`,(S,E)=>{if(S)c(S);else{const v=!1===E?0:E,p={consumedPoints:b,msBeforeNext:v>=0?Math.max(v-f,0):-1};h(p)}}):h(null)})})}_delete(m){return new Promise((h,c)=>{this.client.del(m,(f,d)=>{f?c(f):!1===d?h(d):this.client.del(`${m}_expire`,b=>{b?c(b):h(d)})})})}}},4849:(Y,U,x)=>{const y=x(6953),l=x(6216),g=x(9658);Y.exports=class w extends y{constructor(h={}){super(h),this._memoryStorage=new l}consume(h,c=1,f={}){return new Promise((d,b)=>{const S=this.getKey(h),E=this._getKeySecDuration(f);let v=this._memoryStorage.incrby(S,c,E);if(v.remainingPoints=Math.max(this.points-v.consumedPoints,0),v.consumedPoints>this.points)this.blockDuration>0&&v.consumedPoints<=this.points+c&&(v=this._memoryStorage.set(S,v.consumedPoints,this.blockDuration)),b(v);else if(this.execEvenly&&v.msBeforeNext>0&&!v.isFirstInDuration){let p=Math.ceil(v.msBeforeNext/(v.remainingPoints+2));p{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}reward(h,c=1,f={}){const d=this.getKey(h);return new Promise(b=>{const S=this._getKeySecDuration(f),E=this._memoryStorage.incrby(d,-c,S);E.remainingPoints=Math.max(this.points-E.consumedPoints,0),b(E)})}block(h,c){const f=1e3*c,d=this.points+1;return this._memoryStorage.set(this.getKey(h),d,c),Promise.resolve(new g(0,0===f?-1:f,d))}set(h,c,f){const d=1e3*(f>=0?f:this.duration);return this._memoryStorage.set(this.getKey(h),c,f),Promise.resolve(new g(0,0===d?-1:d,c))}get(h){const c=this._memoryStorage.get(this.getKey(h));return null!==c&&(c.remainingPoints=Math.max(this.points-c.consumedPoints,0)),Promise.resolve(c)}delete(h){return Promise.resolve(this._memoryStorage.delete(this.getKey(h)))}}},6217:(Y,U,x)=>{const y=x(3129),l=x(9658);function g(m){try{const h=m.client?m.client:m,{version:c}=h.topology.s.options.metadata.driver,f=c.split(".").map(d=>parseInt(d));return{major:f[0],feature:f[1],patch:f[2]}}catch{return{major:0,feature:0,patch:0}}}class w extends y{constructor(h){super(h),this.dbName=h.dbName,this.tableName=h.tableName,this.indexKeyPrefix=h.indexKeyPrefix,this.client=h.mongo?h.mongo:h.storeClient,"function"==typeof this.client.then?this.client.then(c=>{this.client=c,this._initCollection(),this._driverVersion=g(this.client)}):(this._initCollection(),this._driverVersion=g(this.client))}get dbName(){return this._dbName}set dbName(h){this._dbName=typeof h>"u"?w.getDbName():h}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(h){this._tableName=typeof h>"u"?this.keyPrefix:h}get client(){return this._client}set client(h){if(typeof h>"u")throw new Error("mongo is not set");this._client=h}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(h){this._indexKeyPrefix=h||{}}_initCollection(){const c=("function"==typeof this.client.db?this.client.db(this.dbName):this.client).collection(this.tableName);c.createIndex({expire:-1},{expireAfterSeconds:0}),c.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=c}_getRateLimiterRes(h,c,f){const d=new l;let b;return b=typeof f.value>"u"?f:f.value,d.isFirstInDuration=b.points===c,d.consumedPoints=b.points,d.remainingPoints=Math.max(this.points-d.consumedPoints,0),d.msBeforeNext=null!==b.expire?Math.max(new Date(b.expire).getTime()-Date.now(),0):-1,d}_upsert(h,c,f,d=!1,b={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const S=b.attrs||{};let E,v;d?(E={key:h},E=Object.assign(E,S),v={$set:{key:h,points:c,expire:f>0?new Date(Date.now()+f):null}},v.$set=Object.assign(v.$set,S)):(E={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:h},E=Object.assign(E,S),v={$setOnInsert:{key:h,expire:f>0?new Date(Date.now()+f):null},$inc:{points:c}},v.$setOnInsert=Object.assign(v.$setOnInsert,S));const p={upsert:!0};return this._driverVersion.major>=4||3===this._driverVersion.major&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?p.returnDocument="after":p.returnOriginal=!1,new Promise((I,A)=>{this._collection.findOneAndUpdate(E,v,p).then(P=>{I(P)}).catch(P=>{if(P&&11e3===P.code){const D=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:h},S),T={$set:Object.assign({key:h,points:c,expire:f>0?new Date(Date.now()+f):null},S)};this._collection.findOneAndUpdate(D,T,p).then(M=>{I(M)}).catch(M=>{M&&11e3===M.code?this._upsert(h,c,f,d).then(k=>I(k)).catch(k=>A(k)):A(M)})}else A(P)})})}_get(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const f=c.attrs||{},d=Object.assign({key:h,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},f);return this._collection.findOne(d)}_delete(h,c={}){if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const d=Object.assign({key:h},c.attrs||{});return this._collection.deleteOne(d).then(b=>b.deletedCount>0)}}Y.exports=w},7840:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.dbName=m.dbName,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()):this._createDbAndTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._getConnection().then(c=>{c.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,m],()=>{this._releaseConnection(c),h()})}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise((m,h)=>{this.client.getConnection((c,f)=>{if(c)return h(c);m(f)})});case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(m){switch(this.clientType){case"pool":return m.release();case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m);default:return!0}}_createDbAndTable(){return new Promise((m,h)=>{this._getConnection().then(c=>{c.query(`CREATE DATABASE IF NOT EXISTS \`${this.dbName}\`;`,f=>{if(f)return this._releaseConnection(c),h(f);c.query(this._getCreateTableStmt(),d=>{if(d)return this._releaseConnection(c),h(d);this._releaseConnection(c),m()})})}).catch(c=>{h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS \`${this.dbName}\`.\`${this.tableName}\` (\`key\` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\`points\` INT(9) NOT NULL default 0,\`expire\` BIGINT UNSIGNED,PRIMARY KEY (\`key\`)) ENGINE = INNODB;`}get clientType(){return this._clientType}set clientType(m){if(typeof m>"u")if("Connection"===this.client.constructor.name)m="connection";else if("Pool"===this.client.constructor.name)m="pool";else{if("Sequelize"!==this.client.constructor.name)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get dbName(){return this._dbName}set dbName(m){this._dbName=typeof m>"u"?"rtlmtrflx":m}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new l,[d]=c;return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_upsertTransaction(m,h,c,f,d){return new Promise((b,S)=>{m.query("BEGIN",E=>{if(E)return m.rollback(),S(E);const v=Date.now(),p=f>0?v+f:null;let I,A;d?(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;",A=[this.dbName,this.tableName,h,c,p,c,p]):(I="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = IF(expire <= ?, ?, points + (?)), \n expire = IF(expire <= ?, ?, expire);",A=[this.dbName,this.tableName,h,c,p,v,c,c,v,p]),m.query(I,A,P=>{if(P)return m.rollback(),S(P);m.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,h],(D,T)=>{if(D)return m.rollback(),S(D);m.query("COMMIT",M=>{if(M)return m.rollback(),S(M);b(T)})})})})})}_upsert(m,h,c,f=!1){return this.tableCreated?new Promise((d,b)=>{this._getConnection().then(S=>{this._upsertTransaction(S,m,h,c,f).then(E=>{d(E),this._releaseConnection(S)}).catch(E=>{b(E),this._releaseConnection(S)})}).catch(S=>{b(S)})}):Promise.reject(Error("Table is not created yet"))}_get(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,m,Date.now()],(d,b)=>{d?c(d):h(0===b.length?null:b),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?new Promise((h,c)=>{this._getConnection().then(f=>{f.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,m],(d,b)=>{d?c(d):h(b.affectedRows>0),this._releaseConnection(f)})}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}}},939:(Y,U,x)=>{const y=x(3129),l=x(9658);Y.exports=class g extends y{constructor(m,h=null){super(m),this.client=m.storeClient,this.clientType=m.storeType,this.tableName=m.tableName,this.clearExpiredByTimeout=m.clearExpiredByTimeout,this.tableCreated=m.tableCreated,this.tableCreated?"function"==typeof h&&h():this._createTable().then(()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"==typeof h&&h()}).catch(c=>{if("function"!=typeof h)throw c;h(c)})}clearExpired(m){return new Promise(h=>{this._query({name:"rlflx-clear-expired",text:`DELETE FROM ${this.tableName} WHERE expire < $1`,values:[m]}).then(()=>{h()}).catch(()=>{h()})})}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout(()=>{this.clearExpired(Date.now()-36e5).then(()=>{this._clearExpiredHourAgo()})},3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":default:return Promise.resolve(this.client);case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();case"typeorm":return Promise.resolve(this.client.driver.master)}}_releaseConnection(m){switch(this.clientType){case"pool":case"typeorm":default:return!0;case"sequelize":return this.client.connectionManager.releaseConnection(m);case"knex":return this.client.client.releaseConnection(m)}}_createTable(){return new Promise((m,h)=>{this._query({text:this._getCreateTableStmt()}).then(()=>{m()}).catch(c=>{"23505"===c.code?m():h(c)})})}_getCreateTableStmt(){return`CREATE TABLE IF NOT EXISTS ${this.tableName} ( \n key varchar(255) PRIMARY KEY,\n points integer NOT NULL DEFAULT 0,\n expire bigint\n );`}get clientType(){return this._clientType}set clientType(m){const h=this.client.constructor.name;if(typeof m>"u")if("Client"===h)m="client";else if("Pool"===h||"BoundPool"===h)m="pool";else{if("Sequelize"!==h)throw new Error("storeType is not defined");m="sequelize"}this._clientType=m.toLowerCase()}get tableName(){return this._tableName}set tableName(m){this._tableName=typeof m>"u"?this.keyPrefix:m}get tableCreated(){return this._tableCreated}set tableCreated(m){this._tableCreated=!(typeof m>"u"||!m)}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(m){this._clearExpiredByTimeout=typeof m>"u"||Boolean(m)}_getRateLimiterRes(m,h,c){const f=new l,d=c.rows[0];return f.isFirstInDuration=h===d.points,f.consumedPoints=f.isFirstInDuration?h:d.points,f.remainingPoints=Math.max(this.points-f.consumedPoints,0),f.msBeforeNext=d.expire?Math.max(d.expire-Date.now(),0):-1,f}_query(m){const c={name:`${this.tableName.toLowerCase()}:${m.name}`,text:m.text,values:m.values};return new Promise((f,d)=>{this._getConnection().then(b=>{b.query(c).then(S=>{f(S),this._releaseConnection(b)}).catch(S=>{d(S),this._releaseConnection(b)})}).catch(b=>{d(b)})})}_upsert(m,h,c,f=!1){if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));const d=c>0?Date.now()+c:null;return this._query({name:f?"rlflx-upsert-force":"rlflx-upsert",text:`\n INSERT INTO ${this.tableName} VALUES ($1, $2, $3)\n ON CONFLICT(key) DO UPDATE SET\n points = CASE\n WHEN (${this.tableName}.expire <= $4 OR 1=${f?1:0}) THEN $2\n ELSE ${this.tableName}.points + ($2)\n END,\n expire = ${f?" $3 ":` CASE\n WHEN ${this.tableName}.expire <= $4 THEN $3\n ELSE ${this.tableName}.expire\n END `}\n RETURNING points, expire;`,values:[m,h,d,Date.now()]})}_get(m){return this.tableCreated?new Promise((h,c)=>{this._query({name:"rlflx-get",text:`\n SELECT points, expire FROM ${this.tableName} WHERE key = $1 AND (expire > $2 OR expire IS NULL);`,values:[m,Date.now()]}).then(f=>{0===f.rowCount&&(f=null),h(f)}).catch(f=>{c(f)})}):Promise.reject(Error("Table is not created yet"))}_delete(m){return this.tableCreated?this._query({name:"rlflx-delete",text:`DELETE FROM ${this.tableName} WHERE key = $1`,values:[m]}).then(h=>h.rowCount>0):Promise.reject(Error("Table is not created yet"))}}},2816:(Y,U,x)=>{const y=x(2047),l=4294967295,g="limiter";Y.exports=class{constructor(h,c={maxQueueSize:l}){this._queueLimiters={KEY_DEFAULT:new w(h,c)},this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(h=g){return this._queueLimiters[h]?this._queueLimiters[h].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(h,c=g){return this._queueLimiters[c]||(this._queueLimiters[c]=new w(this._limiterFlexible,{key:c,maxQueueSize:this._maxQueueSize})),this._queueLimiters[c].removeTokens(h)}};class w{constructor(h,c={maxQueueSize:l,key:g}){this._key=c.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=h,this._maxQueueSize=c.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then(h=>null!==h?h.remainingPoints:this._limiterFlexible.points)}removeTokens(h){const c=this;return new Promise((f,d)=>{h>c._limiterFlexible.points?d(new y(`Requested tokens ${h} exceeds maximum ${c._limiterFlexible.points} tokens per interval`)):c._queue.length>0?c._queueRequest.call(c,f,d,h):c._limiterFlexible.consume(c._key,h).then(b=>{f(b.remainingPoints)}).catch(b=>{b instanceof Error?d(b):(c._queueRequest.call(c,f,d,h),null===c._waitTimeout&&(c._waitTimeout=setTimeout(c._processFIFO.bind(c),b.msBeforeNext)))})})}_queueRequest(h,c,f){const d=this;d._queue.length{c.resolve(f.remainingPoints),h._processFIFO.call(h)}).catch(f=>{f instanceof Error?(c.reject(f),h._processFIFO.call(h)):(h._queue.unshift(c),null===h._waitTimeout&&(h._waitTimeout=setTimeout(h._processFIFO.bind(h),f.msBeforeNext)))})}}},9301:(Y,U,x)=>{const y=x(3129),l=x(9658),g="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";Y.exports=class w extends y{constructor(h){super(h),this.client=h.redis?h.redis:h.storeClient,"function"==typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:g})}_getRateLimiterRes(h,c,f){let[d,b]=f;Array.isArray(d)&&([,d]=d,[,b]=b);const S=new l;return S.consumedPoints=parseInt(d),S.isFirstInDuration=S.consumedPoints===c,S.remainingPoints=Math.max(this.points-S.consumedPoints,0),S.msBeforeNext=b,S}_upsert(h,c,f,d=!1){return new Promise((b,S)=>{const E=Math.floor(f/1e3),v=this.client.multi();if(d)E>0?v.set(h,c,"EX",E):v.set(h,c),v.pttl(h).exec((p,I)=>p?S(p):b(I));else if(E>0){const p=function(I,A){return I?S(I):b(A)};"function"==typeof this.client.rlflxIncr?this.client.rlflxIncr(h,c,E,p):this.client.eval(g,1,h,c,E,p)}else v.incrby(h,c).pttl(h).exec((p,I)=>p?S(p):b(I))})}_get(h){return new Promise((c,f)=>{this.client.multi().get(h).pttl(h).exec((d,b)=>{if(d)f(d);else{const[S]=b;if(null===S)return c(null);c(b)}})})}_delete(h){return new Promise((c,f)=>{this.client.del(h,(d,b)=>{d?f(d):c(b>0)})})}}},9658:Y=>{Y.exports=class{constructor(x,y,l,g){this.remainingPoints=typeof x>"u"?0:x,this.msBeforeNext=typeof y>"u"?0:y,this.consumedPoints=typeof l>"u"?0:l,this.isFirstInDuration=!(typeof g>"u")&&g}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(x){return this._msBeforeNext=x,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(x){return this._remainingPoints=x,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(x){return this._consumedPoints=x,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(x){this._isFirstInDuration=Boolean(x)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}},3129:(Y,U,x)=>{const y=x(6953),l=x(8442),g=x(9658);Y.exports=class extends y{constructor(m={}){super(m),this.inmemoryBlockOnConsumed=m.inmemoryBlockOnConsumed,this.inmemoryBlockDuration=m.inmemoryBlockDuration,this.insuranceLimiter=m.insuranceLimiter,this._inmemoryBlockedKeys=new l}get client(){return this._client}set client(m){if(typeof m>"u")throw new Error("storeClient is not set");this._client=m}_afterConsume(m,h,c,f,d,b={}){const S=this._getRateLimiterRes(c,f,d);if(this.inmemoryBlockOnConsumed>0&&!(this.inmemoryBlockDuration>0)&&S.consumedPoints>=this.inmemoryBlockOnConsumed)return this._inmemoryBlockedKeys.addMs(c,S.msBeforeNext),S.consumedPoints>this.points?h(S):m(S);if(S.consumedPoints>this.points){let E=Promise.resolve();this.blockDuration>0&&S.consumedPoints<=this.points+f&&(S.msBeforeNext=this.msBlockDuration,E=this._block(c,S.consumedPoints,this.msBlockDuration,b)),this.inmemoryBlockOnConsumed>0&&S.consumedPoints>=this.inmemoryBlockOnConsumed&&(this._inmemoryBlockedKeys.add(c,this.inmemoryBlockDuration),S.msBeforeNext=this.msInmemoryBlockDuration),E.then(()=>{h(S)}).catch(v=>{h(v)})}else if(this.execEvenly&&S.msBeforeNext>0&&!S.isFirstInDuration){let E=Math.ceil(S.msBeforeNext/(S.remainingPoints+2));E{c(E)}).catch(E=>{f(E)}):f(m)}getInmemoryBlockMsBeforeExpire(m){return this.inmemoryBlockOnConsumed>0?this._inmemoryBlockedKeys.msBeforeExpire(m):0}get inmemoryBlockOnConsumed(){return this._inmemoryBlockOnConsumed}set inmemoryBlockOnConsumed(m){if(this._inmemoryBlockOnConsumed=m?parseInt(m):0,this.inmemoryBlockOnConsumed>0&&this.points>this.inmemoryBlockOnConsumed)throw new Error('inmemoryBlockOnConsumed option must be greater or equal "points" option')}get inmemoryBlockDuration(){return this._inmemoryBlockDuration}set inmemoryBlockDuration(m){if(this._inmemoryBlockDuration=m?parseInt(m):0,this.inmemoryBlockDuration>0&&0===this.inmemoryBlockOnConsumed)throw new Error("inmemoryBlockOnConsumed option must be set up")}get msInmemoryBlockDuration(){return 1e3*this._inmemoryBlockDuration}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(m){if(typeof m<"u"&&!(m instanceof y))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=m,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(m,h,c={}){const f=1e3*h;return this._block(this.getKey(m),this.points+1,f,c)}set(m,h,c,f={}){const d=1e3*(c>=0?c:this.duration);return this._block(this.getKey(m),h,d,f)}consume(m,h=1,c={}){return new Promise((f,d)=>{const b=this.getKey(m),S=this.getInmemoryBlockMsBeforeExpire(b);if(S>0)return d(new g(0,S));this._upsert(b,h,1e3*this._getKeySecDuration(c),!1,c).then(E=>{this._afterConsume(f,d,b,h,E)}).catch(E=>{this._handleError(E,"consume",f,d,m,h,c)})})}penalty(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,h,S))}).catch(S=>{this._handleError(S,"penalty",d,b,m,h,c)})})}reward(m,h=1,c={}){const f=this.getKey(m);return new Promise((d,b)=>{this._upsert(f,-h,1e3*this._getKeySecDuration(c),!1,c).then(S=>{d(this._getRateLimiterRes(f,-h,S))}).catch(S=>{this._handleError(S,"reward",d,b,m,h,c)})})}get(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._get(c,h).then(b=>{f(null===b||typeof b>"u"?null:this._getRateLimiterRes(c,0,b))}).catch(b=>{this._handleError(b,"get",f,d,m,h)})})}delete(m,h={}){const c=this.getKey(m);return new Promise((f,d)=>{this._delete(c,h).then(b=>{this._inmemoryBlockedKeys.delete(c),f(b)}).catch(b=>{this._handleError(b,"delete",f,d,m,h)})})}deleteInMemoryBlockedAll(){this._inmemoryBlockedKeys.delete()}_getRateLimiterRes(m,h,c){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(m,h,c,f={}){return new Promise((d,b)=>{this._upsert(m,h,c,!0,f).then(()=>{d(new g(0,c>0?c:-1,h))}).catch(S=>{this._handleError(S,"block",d,b,this.parseKey(m),c/1e3,f)})})}_get(m,h={}){throw new Error("You have to implement the method '_get'!")}_delete(m,h={}){throw new Error("You have to implement the method '_delete'!")}_upsert(){throw new Error("You have to implement the method '_upsert'!")}}},8592:(Y,U,x)=>{const y=x(6953);Y.exports=class{constructor(...g){if(g.length<2)throw new Error("RateLimiterUnion: at least two limiters have to be set");g.forEach(w=>{if(!(w instanceof y))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")}),this._limiters=g}consume(g,w=1){return new Promise((m,h)=>{const c=[];this._limiters.forEach(f=>{c.push(f.consume(g,w).catch(d=>({rejected:!0,rej:d})))}),Promise.all(c).then(f=>{const d={};let b=!1;f.forEach(S=>{!0===S.rejected&&(b=!0)});for(let S=0;S{Y.exports=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const x=Date.now();Object.keys(this._keys).forEach(y=>{this._keys[y]<=x&&delete this._keys[y]}),this._addedKeysAmount=Object.keys(this._keys).length}add(x,y){this.addMs(x,1e3*y)}addMs(x,y){this._keys[x]=Date.now()+y,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(x){const y=this._keys[x];if(y&&y>=Date.now()){this.collectExpired();const l=Date.now();return y>=l?y-l:0}return 0}delete(x){x?delete this._keys[x]:Object.keys(this._keys).forEach(y=>{delete this._keys[y]})}}},8442:(Y,U,x)=>{const y=x(2585);Y.exports=y},6216:(Y,U,x)=>{const y=x(7105),l=x(9658);Y.exports=class{constructor(){this._storage={}}incrby(w,m,h){if(this._storage[w]){const c=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return 0!==c?(this._storage[w].value=this._storage[w].value+m,new l(0,c,this._storage[w].value,!1)):this.set(w,m,h)}return this.set(w,m,h)}set(w,m,h){const c=1e3*h;return this._storage[w]&&this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),this._storage[w]=new y(m,c>0?new Date(Date.now()+c):null),c>0&&(this._storage[w].timeoutId=setTimeout(()=>{delete this._storage[w]},c),this._storage[w].timeoutId.unref&&this._storage[w].timeoutId.unref()),new l(0,0===c?-1:c,this._storage[w].value,!0)}get(w){if(this._storage[w]){const m=this._storage[w].expiresAt?this._storage[w].expiresAt.getTime()-(new Date).getTime():-1;return new l(0,m,this._storage[w].value,!1)}return null}delete(w){return!!this._storage[w]&&(this._storage[w].timeoutId&&clearTimeout(this._storage[w].timeoutId),delete this._storage[w],!0)}}},7105:Y=>{Y.exports=class{constructor(x,y,l=null){this.value=x,this.expiresAt=y,this.timeoutId=l}get value(){return this._value}set value(x){this._value=parseInt(x)}get expiresAt(){return this._expiresAt}set expiresAt(x){!(x instanceof Date)&&Number.isInteger(x)&&(x=new Date(x)),this._expiresAt=x}get timeoutId(){return this._timeoutId}set timeoutId(x){this._timeoutId=x}}},2047:Y=>{Y.exports=class extends Error{constructor(x,y){super(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="CustomError",this.message=x,y&&(this.extra=y)}}},4033:(Y,U,x)=>{"use strict";Y.exports=m;var y=x(4366),l=m.prototype,g=new Date%1e9;function m(h){this.id=(h=h||{}).id||function w(){return(1e9*Math.random()>>>0)+g++}(),this.max=h.max||1/0,this.items=h.items||[],this._lookup={},this.size=this.items.length,this.lastModified=new Date(h.lastModified||new Date);for(var c,f,d=this.items.length;d--;)c=this.items[d],f=new Date(c.expires)-new Date,this._lookup[c.key]=c,f>0?this.expire(c.key,f):f<=0&&this.delete(c.key)}l.has=function(h){return h in this._lookup},l.get=function(h){if(!this.has(h))return null;var c=this._lookup[h];return c.refresh&&this.expire(h,c.refresh),this.items.splice(this.items.indexOf(c),1),this.items.push(c),c.value},l.meta=function(h){if(!this.has(h))return null;var c=this._lookup[h];return"meta"in c?c.meta:null},l.set=function(h,c,f){var d=this._lookup[h],b=this._lookup[h]={key:h,value:c};return this.lastModified=new Date,d?(clearTimeout(d.timeout),this.items.splice(this.items.indexOf(d),1,b)):(this.size>=this.max&&this.delete(this.items[0].key),this.items.push(b),this.size++),f&&("ttl"in f&&this.expire(h,f.ttl),"meta"in f&&(b.meta=f.meta),f.refresh&&(b.refresh=f.ttl)),this},l.delete=function(h){var c=this._lookup[h];return!!c&&(this.lastModified=new Date,this.items.splice(this.items.indexOf(c),1),clearTimeout(c.timeout),delete this._lookup[h],this.size--,this)},l.expire=function(h,c){var f=c||0,d=this._lookup[h];if(!d)return this;if("string"==typeof f&&(f=y(c)),"number"!=typeof f)throw new TypeError("Expiration time must be a string or number.");return clearTimeout(d.timeout),d.timeout=setTimeout(this.delete.bind(this,d.key),f),d.expires=Number(new Date)+f,this},l.clear=function(){for(var h=this.items.length;h--;)this.delete(this.items[h].key);return this},l.toJSON=function(){for(var c,h=new Array(this.items.length),f=h.length;f--;)h[f]={key:(c=this.items[f]).key,meta:c.meta,value:c.value,expires:c.expires,refresh:c.refresh};return{id:this.id,max:isFinite(this.max)?this.max:void 0,lastModified:this.lastModified,items:h}}},2502:(Y,U,x)=>{"use strict";const y=x(7806);class l{constructor(m,h,c){const f=this;this._started=y(),this._rescheduled=0,this._scheduled=h,this._args=c,this._triggered=!1,this._timerWrapper=()=>{f._rescheduled>0?(f._scheduled=f._rescheduled-(y()-f._started),f._schedule(f._scheduled)):(f._triggered=!0,m.apply(null,f._args))},this._timer=setTimeout(this._timerWrapper,h)}reschedule(m){m||(m=this._scheduled);const h=y();h+m-(this._started+this._scheduled)<0?(clearTimeout(this._timer),this._schedule(m)):this._triggered?this._schedule(m):(this._started=h,this._rescheduled=m)}_schedule(m){this._triggered=!1,this._started=y(),this._rescheduled=0,this._scheduled=m,this._timer=setTimeout(this._timerWrapper,m)}clear(){clearTimeout(this._timer)}}Y.exports=function g(){if("function"!=typeof arguments[0])throw new Error("callback needed");if("number"!=typeof arguments[1])throw new Error("timeout needed");let w;if(arguments.length>0){w=new Array(arguments.length-2);for(var m=0;m{"use strict";Y.exports=function(){return Date.now()}},9014:(Y,U,x)=>{"use strict";var y=x(9942),l=/[\/\?<>\\:\*\|"]/g,g=/[\x00-\x1f\x80-\x9f]/g,w=/^\.+$/,m=/^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i,h=/[\. ]+$/;function c(f,d){if("string"!=typeof f)throw new Error("Input must be string");var b=f.replace(l,d).replace(g,d).replace(w,d).replace(m,d).replace(h,d);return y(b,255)}Y.exports=function(f,d){var b=d&&d.replacement||"",S=c(f,b);return""===b?S:c(S,"")}},1466:(Y,U,x)=>{"use strict";var y=x(7156).default;const l=new Map;function m(){return(m=y(function*(f,d,b){for(;l.get(b);){try{yield f()}catch(S){setTimeout(()=>{throw S},1);break}if(!l.get(b))break;yield new Promise(S=>{const E=setTimeout(S,d);l.set(b,E)})}})).apply(this,arguments)}Y.exports={setDelayedInterval:function h(f,d,b){b=b||d;const S=`${Date.now()}:${Math.floor(1e6*Math.random())}`,E=setTimeout(()=>{!function w(f,d,b){m.apply(this,arguments)}(f,d,S)},b);return l.set(S,E),S},clearDelayedInterval:function c(f){const d=l.get(f);d&&(clearTimeout(d),l.delete(f))}}},1420:(Y,U,x)=>{"use strict";const{AbortController:y}=globalThis,l=x(2502);class g extends y{constructor(m){super(),this._ms=m,this._timer=l(()=>this.abort(),m),Object.setPrototypeOf(this,g.prototype)}abort(){return this._timer.clear(),super.abort()}clear(){this._timer.clear()}reset(){this._timer.clear(),this._timer=l(()=>this.abort(),this._ms)}}Y.exports={TimeoutController:g}},9942:(Y,U,x)=>{"use strict";var y=x(8831),l=x(8871);Y.exports=y.bind(null,l)},8831:Y=>{"use strict";function x(y){return y>=56320&&y<=57343}Y.exports=function(l,g,w){if("string"!=typeof g)throw new Error("Input must be string");for(var c,f,m=g.length,h=0,d=0;d=55296&&y<=56319&&x(g.charCodeAt(d+1))&&(f+=g[d+=1]),(h+=l(f))===w)return g.slice(0,d+1);if(h>w)return g.slice(0,d-f.length+1)}var y;return g}},8871:Y=>{"use strict";function U(y){return y>=55296&&y<=56319}Y.exports=function(l){if("string"!=typeof l)throw new Error("Input must be string");for(var g=l.length,w=0,m=null,h=null,c=0;c=56320&&y<=57343?null!=h&&U(h)?w+=1:w+=3:m<=127?w+=1:m>=128&&m<=2047?w+=2:m>=2048&&m<=65535&&(w+=3),h=m;var y;return w}},3004:Y=>{Y.exports=function y(l,m){var f,w=0,h=0,c=m=m||0,d=l.length;do{if(c>=d||h>49)throw y.bytes=0,new RangeError("Could not decode varint");f=l[c++],w+=h<28?(127&f)<=128);return y.bytes=c-m,w}},5723:Y=>{Y.exports=function g(w,m,h){if(Number.MAX_SAFE_INTEGER&&w>Number.MAX_SAFE_INTEGER)throw g.bytes=0,new RangeError("Could not encode varint");m=m||[];for(var c=h=h||0;w>=l;)m[h++]=255&w|128,w/=128;for(;-128&w;)m[h++]=255&w|128,w>>>=7;return m[h]=0|w,g.bytes=h-c+1,m};var l=Math.pow(2,31)},1732:(Y,U,x)=>{Y.exports={encode:x(5723),decode:x(3004),encodingLength:x(4036)}},4036:Y=>{var U=Math.pow(2,7),x=Math.pow(2,14),y=Math.pow(2,21),l=Math.pow(2,28),g=Math.pow(2,35),w=Math.pow(2,42),m=Math.pow(2,49),h=Math.pow(2,56),c=Math.pow(2,63);Y.exports=function(f){return f{"use strict";!function(ie){const fe=ie.performance;function ye(Ft){fe&&fe.mark&&fe.mark(Ft)}function me(Ft,ct){fe&&fe.measure&&fe.measure(Ft,ct)}ye("Zone");const _e=ie.__Zone_symbol_prefix||"__zone_symbol__";function Ne(Ft){return _e+Ft}const Qe=!0===ie[Ne("forceDuplicateZoneCheck")];if(ie.Zone){if(Qe||"function"!=typeof ie.Zone.__symbol__)throw new Error("Zone already loaded.");return ie.Zone}let qe=(()=>{class Ft{constructor(ce,ve){this._parent=ce,this._name=ve?ve.name||"unnamed":"",this._properties=ve&&ve.properties||{},this._zoneDelegate=new nt(this,this._parent&&this._parent._zoneDelegate,ve)}static assertZonePatched(){if(ie.Promise!==Pr.ZoneAwarePromise)throw new Error("Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.\nMost likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)")}static get root(){let ce=Ft.current;for(;ce.parent;)ce=ce.parent;return ce}static get current(){return vn.zone}static get currentTask(){return ur}static __load_patch(ce,ve,yt=!1){if(Pr.hasOwnProperty(ce)){if(!yt&&Qe)throw Error("Already loaded patch: "+ce)}else if(!ie["__Zone_disable_"+ce]){const Dt="Zone:"+ce;ye(Dt),Pr[ce]=ve(ie,Ft,On),me(Dt,Dt)}}get parent(){return this._parent}get name(){return this._name}get(ce){const ve=this.getZoneWith(ce);if(ve)return ve._properties[ce]}getZoneWith(ce){let ve=this;for(;ve;){if(ve._properties.hasOwnProperty(ce))return ve;ve=ve._parent}return null}fork(ce){if(!ce)throw new Error("ZoneSpec required!");return this._zoneDelegate.fork(this,ce)}wrap(ce,ve){if("function"!=typeof ce)throw new Error("Expecting function got: "+ce);const yt=this._zoneDelegate.intercept(this,ce,ve),Dt=this;return function(){return Dt.runGuarded(yt,this,arguments,ve)}}run(ce,ve,yt,Dt){vn={parent:vn,zone:this};try{return this._zoneDelegate.invoke(this,ce,ve,yt,Dt)}finally{vn=vn.parent}}runGuarded(ce,ve=null,yt,Dt){vn={parent:vn,zone:this};try{try{return this._zoneDelegate.invoke(this,ce,ve,yt,Dt)}catch(gn){if(this._zoneDelegate.handleError(this,gn))throw gn}}finally{vn=vn.parent}}runTask(ce,ve,yt){if(ce.zone!=this)throw new Error("A task can only be run in the zone of creation! (Creation: "+(ce.zone||Tn).name+"; Execution: "+this.name+")");if(ce.state===Bt&&(ce.type===Jn||ce.type===wt))return;const Dt=ce.state!=ft;Dt&&ce._transitionTo(ft,en),ce.runCount++;const gn=ur;ur=ce,vn={parent:vn,zone:this};try{ce.type==wt&&ce.data&&!ce.data.isPeriodic&&(ce.cancelFn=void 0);try{return this._zoneDelegate.invokeTask(this,ce,ve,yt)}catch(je){if(this._zoneDelegate.handleError(this,je))throw je}}finally{ce.state!==Bt&&ce.state!==st&&(ce.type==Jn||ce.data&&ce.data.isPeriodic?Dt&&ce._transitionTo(en,ft):(ce.runCount=0,this._updateTaskCount(ce,-1),Dt&&ce._transitionTo(Bt,ft,Bt))),vn=vn.parent,ur=gn}}scheduleTask(ce){if(ce.zone&&ce.zone!==this){let yt=this;for(;yt;){if(yt===ce.zone)throw Error(`can not reschedule task to ${this.name} which is descendants of the original zone ${ce.zone.name}`);yt=yt.parent}}ce._transitionTo(pn,Bt);const ve=[];ce._zoneDelegates=ve,ce._zone=this;try{ce=this._zoneDelegate.scheduleTask(this,ce)}catch(yt){throw ce._transitionTo(st,pn,Bt),this._zoneDelegate.handleError(this,yt),yt}return ce._zoneDelegates===ve&&this._updateTaskCount(ce,1),ce.state==pn&&ce._transitionTo(en,pn),ce}scheduleMicroTask(ce,ve,yt,Dt){return this.scheduleTask(new Ke(Kt,ce,ve,yt,Dt,void 0))}scheduleMacroTask(ce,ve,yt,Dt,gn){return this.scheduleTask(new Ke(wt,ce,ve,yt,Dt,gn))}scheduleEventTask(ce,ve,yt,Dt,gn){return this.scheduleTask(new Ke(Jn,ce,ve,yt,Dt,gn))}cancelTask(ce){if(ce.zone!=this)throw new Error("A task can only be cancelled in the zone of creation! (Creation: "+(ce.zone||Tn).name+"; Execution: "+this.name+")");ce._transitionTo(ln,en,ft);try{this._zoneDelegate.cancelTask(this,ce)}catch(ve){throw ce._transitionTo(st,ln),this._zoneDelegate.handleError(this,ve),ve}return this._updateTaskCount(ce,-1),ce._transitionTo(Bt,ln),ce.runCount=0,ce}_updateTaskCount(ce,ve){const yt=ce._zoneDelegates;-1==ve&&(ce._zoneDelegates=null);for(let Dt=0;DtFt.hasTask(ce,ve),onScheduleTask:(Ft,ct,ce,ve)=>Ft.scheduleTask(ce,ve),onInvokeTask:(Ft,ct,ce,ve,yt,Dt)=>Ft.invokeTask(ce,ve,yt,Dt),onCancelTask:(Ft,ct,ce,ve)=>Ft.cancelTask(ce,ve)};class nt{constructor(ct,ce,ve){this._taskCounts={microTask:0,macroTask:0,eventTask:0},this.zone=ct,this._parentDelegate=ce,this._forkZS=ve&&(ve&&ve.onFork?ve:ce._forkZS),this._forkDlgt=ve&&(ve.onFork?ce:ce._forkDlgt),this._forkCurrZone=ve&&(ve.onFork?this.zone:ce._forkCurrZone),this._interceptZS=ve&&(ve.onIntercept?ve:ce._interceptZS),this._interceptDlgt=ve&&(ve.onIntercept?ce:ce._interceptDlgt),this._interceptCurrZone=ve&&(ve.onIntercept?this.zone:ce._interceptCurrZone),this._invokeZS=ve&&(ve.onInvoke?ve:ce._invokeZS),this._invokeDlgt=ve&&(ve.onInvoke?ce:ce._invokeDlgt),this._invokeCurrZone=ve&&(ve.onInvoke?this.zone:ce._invokeCurrZone),this._handleErrorZS=ve&&(ve.onHandleError?ve:ce._handleErrorZS),this._handleErrorDlgt=ve&&(ve.onHandleError?ce:ce._handleErrorDlgt),this._handleErrorCurrZone=ve&&(ve.onHandleError?this.zone:ce._handleErrorCurrZone),this._scheduleTaskZS=ve&&(ve.onScheduleTask?ve:ce._scheduleTaskZS),this._scheduleTaskDlgt=ve&&(ve.onScheduleTask?ce:ce._scheduleTaskDlgt),this._scheduleTaskCurrZone=ve&&(ve.onScheduleTask?this.zone:ce._scheduleTaskCurrZone),this._invokeTaskZS=ve&&(ve.onInvokeTask?ve:ce._invokeTaskZS),this._invokeTaskDlgt=ve&&(ve.onInvokeTask?ce:ce._invokeTaskDlgt),this._invokeTaskCurrZone=ve&&(ve.onInvokeTask?this.zone:ce._invokeTaskCurrZone),this._cancelTaskZS=ve&&(ve.onCancelTask?ve:ce._cancelTaskZS),this._cancelTaskDlgt=ve&&(ve.onCancelTask?ce:ce._cancelTaskDlgt),this._cancelTaskCurrZone=ve&&(ve.onCancelTask?this.zone:ce._cancelTaskCurrZone),this._hasTaskZS=null,this._hasTaskDlgt=null,this._hasTaskDlgtOwner=null,this._hasTaskCurrZone=null;const yt=ve&&ve.onHasTask;(yt||ce&&ce._hasTaskZS)&&(this._hasTaskZS=yt?ve:it,this._hasTaskDlgt=ce,this._hasTaskDlgtOwner=this,this._hasTaskCurrZone=ct,ve.onScheduleTask||(this._scheduleTaskZS=it,this._scheduleTaskDlgt=ce,this._scheduleTaskCurrZone=this.zone),ve.onInvokeTask||(this._invokeTaskZS=it,this._invokeTaskDlgt=ce,this._invokeTaskCurrZone=this.zone),ve.onCancelTask||(this._cancelTaskZS=it,this._cancelTaskDlgt=ce,this._cancelTaskCurrZone=this.zone))}fork(ct,ce){return this._forkZS?this._forkZS.onFork(this._forkDlgt,this.zone,ct,ce):new qe(ct,ce)}intercept(ct,ce,ve){return this._interceptZS?this._interceptZS.onIntercept(this._interceptDlgt,this._interceptCurrZone,ct,ce,ve):ce}invoke(ct,ce,ve,yt,Dt){return this._invokeZS?this._invokeZS.onInvoke(this._invokeDlgt,this._invokeCurrZone,ct,ce,ve,yt,Dt):ce.apply(ve,yt)}handleError(ct,ce){return!this._handleErrorZS||this._handleErrorZS.onHandleError(this._handleErrorDlgt,this._handleErrorCurrZone,ct,ce)}scheduleTask(ct,ce){let ve=ce;if(this._scheduleTaskZS)this._hasTaskZS&&ve._zoneDelegates.push(this._hasTaskDlgtOwner),ve=this._scheduleTaskZS.onScheduleTask(this._scheduleTaskDlgt,this._scheduleTaskCurrZone,ct,ce),ve||(ve=ce);else if(ce.scheduleFn)ce.scheduleFn(ce);else{if(ce.type!=Kt)throw new Error("Task is missing scheduleFn.");mt(ce)}return ve}invokeTask(ct,ce,ve,yt){return this._invokeTaskZS?this._invokeTaskZS.onInvokeTask(this._invokeTaskDlgt,this._invokeTaskCurrZone,ct,ce,ve,yt):ce.callback.apply(ve,yt)}cancelTask(ct,ce){let ve;if(this._cancelTaskZS)ve=this._cancelTaskZS.onCancelTask(this._cancelTaskDlgt,this._cancelTaskCurrZone,ct,ce);else{if(!ce.cancelFn)throw Error("Task is not cancelable");ve=ce.cancelFn(ce)}return ve}hasTask(ct,ce){try{this._hasTaskZS&&this._hasTaskZS.onHasTask(this._hasTaskDlgt,this._hasTaskCurrZone,ct,ce)}catch(ve){this.handleError(ct,ve)}}_updateTaskCount(ct,ce){const ve=this._taskCounts,yt=ve[ct],Dt=ve[ct]=yt+ce;if(Dt<0)throw new Error("More tasks executed then were scheduled.");0!=yt&&0!=Dt||this.hasTask(this.zone,{microTask:ve.microTask>0,macroTask:ve.macroTask>0,eventTask:ve.eventTask>0,change:ct})}}class Ke{constructor(ct,ce,ve,yt,Dt,gn){if(this._zone=null,this.runCount=0,this._zoneDelegates=null,this._state="notScheduled",this.type=ct,this.source=ce,this.data=yt,this.scheduleFn=Dt,this.cancelFn=gn,!ve)throw new Error("callback is not defined");this.callback=ve;const je=this;this.invoke=ct===Jn&&yt&&yt.useG?Ke.invokeTask:function(){return Ke.invokeTask.call(ie,je,this,arguments)}}static invokeTask(ct,ce,ve){ct||(ct=this),Qn++;try{return ct.runCount++,ct.zone.runTask(ct,ce,ve)}finally{1==Qn&&et(),Qn--}}get zone(){return this._zone}get state(){return this._state}cancelScheduleRequest(){this._transitionTo(Bt,pn)}_transitionTo(ct,ce,ve){if(this._state!==ce&&this._state!==ve)throw new Error(`${this.type} '${this.source}': can not transition to '${ct}', expecting state '${ce}'${ve?" or '"+ve+"'":""}, was '${this._state}'.`);this._state=ct,ct==Bt&&(this._zoneDelegates=null)}toString(){return this.data&&typeof this.data.handleId<"u"?this.data.handleId.toString():Object.prototype.toString.call(this)}toJSON(){return{type:this.type,state:this.state,source:this.source,zone:this.zone.name,runCount:this.runCount}}}const we=Ne("setTimeout"),ge=Ne("Promise"),De=Ne("then");let dt,Fe=[],Be=!1;function xt(Ft){if(dt||ie[ge]&&(dt=ie[ge].resolve(0)),dt){let ct=dt[De];ct||(ct=dt.then),ct.call(dt,Ft)}else ie[we](Ft,0)}function mt(Ft){0===Qn&&0===Fe.length&&xt(et),Ft&&Fe.push(Ft)}function et(){if(!Be){for(Be=!0;Fe.length;){const Ft=Fe;Fe=[];for(let ct=0;ctvn,onUnhandledError:En,microtaskDrainDone:En,scheduleMicroTask:mt,showUncaughtError:()=>!qe[Ne("ignoreConsoleErrorUncaughtError")],patchEventTarget:()=>[],patchOnProperties:En,patchMethod:()=>En,bindArguments:()=>[],patchThen:()=>En,patchMacroTask:()=>En,patchEventPrototype:()=>En,isIEOrEdge:()=>!1,getGlobalObjects:()=>{},ObjectDefineProperty:()=>En,ObjectGetOwnPropertyDescriptor:()=>{},ObjectCreate:()=>{},ArraySlice:()=>[],patchClass:()=>En,wrapWithCurrentZone:()=>En,filterProperties:()=>[],attachOriginToPatched:()=>En,_redefineProperty:()=>En,patchCallbacks:()=>En,nativeScheduleMicroTask:xt};let vn={parent:null,zone:new qe(null,null)},ur=null,Qn=0;function En(){}me("Zone","Zone"),ie.Zone=qe}(typeof window<"u"&&window||typeof self<"u"&&self||global);const Y=Object.getOwnPropertyDescriptor,U=Object.defineProperty,x=Object.getPrototypeOf,y=Object.create,l=Array.prototype.slice,g="addEventListener",w="removeEventListener",m=Zone.__symbol__(g),h=Zone.__symbol__(w),c="true",f="false",d=Zone.__symbol__("");function b(ie,fe){return Zone.current.wrap(ie,fe)}function S(ie,fe,ye,me,_e){return Zone.current.scheduleMacroTask(ie,fe,ye,me,_e)}const E=Zone.__symbol__,v=typeof window<"u",p=v?window:void 0,I=v&&p||"object"==typeof self&&self||global;function P(ie,fe){for(let ye=ie.length-1;ye>=0;ye--)"function"==typeof ie[ye]&&(ie[ye]=b(ie[ye],fe+"_"+ye));return ie}function T(ie){return!ie||!1!==ie.writable&&!("function"==typeof ie.get&&typeof ie.set>"u")}const M=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,k=!("nw"in I)&&typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process),F=!k&&!M&&!(!v||!p.HTMLElement),G=typeof I.process<"u"&&"[object process]"==={}.toString.call(I.process)&&!M&&!(!v||!p.HTMLElement),C={},O=function(ie){if(!(ie=ie||I.event))return;let fe=C[ie.type];fe||(fe=C[ie.type]=E("ON_PROPERTY"+ie.type));const ye=this||ie.target||I,me=ye[fe];let _e;if(F&&ye===p&&"error"===ie.type){const Ne=ie;_e=me&&me.call(this,Ne.message,Ne.filename,Ne.lineno,Ne.colno,Ne.error),!0===_e&&ie.preventDefault()}else _e=me&&me.apply(this,arguments),null!=_e&&!_e&&ie.preventDefault();return _e};function V(ie,fe,ye){let me=Y(ie,fe);if(!me&&ye&&Y(ye,fe)&&(me={enumerable:!0,configurable:!0}),!me||!me.configurable)return;const _e=E("on"+fe+"patched");if(ie.hasOwnProperty(_e)&&ie[_e])return;delete me.writable,delete me.value;const Ne=me.get,Qe=me.set,qe=fe.slice(2);let it=C[qe];it||(it=C[qe]=E("ON_PROPERTY"+qe)),me.set=function(nt){let Ke=this;!Ke&&ie===I&&(Ke=I),Ke&&("function"==typeof Ke[it]&&Ke.removeEventListener(qe,O),Qe&&Qe.call(Ke,null),Ke[it]=nt,"function"==typeof nt&&Ke.addEventListener(qe,O,!1))},me.get=function(){let nt=this;if(!nt&&ie===I&&(nt=I),!nt)return null;const Ke=nt[it];if(Ke)return Ke;if(Ne){let we=Ne.call(this);if(we)return me.set.call(this,we),"function"==typeof nt.removeAttribute&&nt.removeAttribute(fe),we}return null},U(ie,fe,me),ie[_e]=!0}function L(ie,fe,ye){if(fe)for(let me=0;mefunction(Qe,qe){const it=ye(Qe,qe);return it.cbIdx>=0&&"function"==typeof qe[it.cbIdx]?S(it.name,qe[it.cbIdx],it,_e):Ne.apply(Qe,qe)})}function X(ie,fe){ie[E("OriginalDelegate")]=fe}let q=!1,ne=!1;function de(){if(q)return ne;q=!0;try{const ie=p.navigator.userAgent;(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/")||-1!==ie.indexOf("Edge/"))&&(ne=!0)}catch{}return ne}Zone.__load_patch("ZoneAwarePromise",(ie,fe,ye)=>{const me=Object.getOwnPropertyDescriptor,_e=Object.defineProperty,Qe=ye.symbol,qe=[],it=!0===ie[Qe("DISABLE_WRAPPING_UNCAUGHT_PROMISE_REJECTION")],nt=Qe("Promise"),Ke=Qe("then");ye.onUnhandledError=je=>{if(ye.showUncaughtError()){const Ye=je&&je.rejection;Ye?console.error("Unhandled Promise rejection:",Ye instanceof Error?Ye.message:Ye,"; Zone:",je.zone.name,"; Task:",je.task&&je.task.source,"; Value:",Ye,Ye instanceof Error?Ye.stack:void 0):console.error(je)}},ye.microtaskDrainDone=()=>{for(;qe.length;){const je=qe.shift();try{je.zone.runGuarded(()=>{throw je.throwOriginal?je.rejection:je})}catch(Ye){De(Ye)}}};const ge=Qe("unhandledPromiseRejectionHandler");function De(je){ye.onUnhandledError(je);try{const Ye=fe[ge];"function"==typeof Ye&&Ye.call(this,je)}catch{}}function Fe(je){return je&&je.then}function Be(je){return je}function dt(je){return ce.reject(je)}const xt=Qe("state"),mt=Qe("value"),et=Qe("finally"),Tn=Qe("parentPromiseValue"),Bt=Qe("parentPromiseState"),en=null,ln=!1;function Kt(je,Ye){return Ae=>{try{On(je,Ye,Ae)}catch(Ge){On(je,!1,Ge)}}}const wt=function(){let je=!1;return function(Ae){return function(){je||(je=!0,Ae.apply(null,arguments))}}},Pr=Qe("currentTaskTrace");function On(je,Ye,Ae){const Ge=wt();if(je===Ae)throw new TypeError("Promise resolved with itself");if(je[xt]===en){let ht=null;try{("object"==typeof Ae||"function"==typeof Ae)&&(ht=Ae&&Ae.then)}catch(Et){return Ge(()=>{On(je,!1,Et)})(),je}if(Ye!==ln&&Ae instanceof ce&&Ae.hasOwnProperty(xt)&&Ae.hasOwnProperty(mt)&&Ae[xt]!==en)ur(Ae),On(je,Ae[xt],Ae[mt]);else if(Ye!==ln&&"function"==typeof ht)try{ht.call(Ae,Ge(Kt(je,Ye)),Ge(Kt(je,!1)))}catch(Et){Ge(()=>{On(je,!1,Et)})()}else{je[xt]=Ye;const Et=je[mt];if(je[mt]=Ae,je[et]===et&&!0===Ye&&(je[xt]=je[Bt],je[mt]=je[Tn]),Ye===ln&&Ae instanceof Error){const ut=fe.currentTask&&fe.currentTask.data&&fe.currentTask.data.__creationTrace__;ut&&_e(Ae,Pr,{configurable:!0,enumerable:!1,writable:!0,value:ut})}for(let ut=0;ut{try{const St=je[mt],$t=!!Ae&&et===Ae[et];$t&&(Ae[Tn]=St,Ae[Bt]=Et);const Ut=Ye.run(ut,void 0,$t&&ut!==dt&&ut!==Be?[]:[St]);On(Ae,!0,Ut)}catch(St){On(Ae,!1,St)}},Ae)}const Ft=function(){},ct=ie.AggregateError;class ce{static toString(){return"function ZoneAwarePromise() { [native code] }"}static resolve(Ye){return On(new this(null),!0,Ye)}static reject(Ye){return On(new this(null),ln,Ye)}static any(Ye){if(!Ye||"function"!=typeof Ye[Symbol.iterator])return Promise.reject(new ct([],"All promises were rejected"));const Ae=[];let Ge=0;try{for(let ut of Ye)Ge++,Ae.push(ce.resolve(ut))}catch{return Promise.reject(new ct([],"All promises were rejected"))}if(0===Ge)return Promise.reject(new ct([],"All promises were rejected"));let ht=!1;const Et=[];return new ce((ut,St)=>{for(let $t=0;$t{ht||(ht=!0,ut(Ut))},Ut=>{Et.push(Ut),Ge--,0===Ge&&(ht=!0,St(new ct(Et,"All promises were rejected")))})})}static race(Ye){let Ae,Ge,ht=new this((St,$t)=>{Ae=St,Ge=$t});function Et(St){Ae(St)}function ut(St){Ge(St)}for(let St of Ye)Fe(St)||(St=this.resolve(St)),St.then(Et,ut);return ht}static all(Ye){return ce.allWithCallback(Ye)}static allSettled(Ye){return(this&&this.prototype instanceof ce?this:ce).allWithCallback(Ye,{thenCallback:Ge=>({status:"fulfilled",value:Ge}),errorCallback:Ge=>({status:"rejected",reason:Ge})})}static allWithCallback(Ye,Ae){let Ge,ht,Et=new this((Ut,An)=>{Ge=Ut,ht=An}),ut=2,St=0;const $t=[];for(let Ut of Ye){Fe(Ut)||(Ut=this.resolve(Ut));const An=St;try{Ut.then(Dn=>{$t[An]=Ae?Ae.thenCallback(Dn):Dn,ut--,0===ut&&Ge($t)},Dn=>{Ae?($t[An]=Ae.errorCallback(Dn),ut--,0===ut&&Ge($t)):ht(Dn)})}catch(Dn){ht(Dn)}ut++,St++}return ut-=2,0===ut&&Ge($t),Et}constructor(Ye){const Ae=this;if(!(Ae instanceof ce))throw new Error("Must be an instanceof Promise.");Ae[xt]=en,Ae[mt]=[];try{const Ge=wt();Ye&&Ye(Ge(Kt(Ae,!0)),Ge(Kt(Ae,ln)))}catch(Ge){On(Ae,!1,Ge)}}get[Symbol.toStringTag](){return"Promise"}get[Symbol.species](){return ce}then(Ye,Ae){var Ge;let ht=null===(Ge=this.constructor)||void 0===Ge?void 0:Ge[Symbol.species];(!ht||"function"!=typeof ht)&&(ht=this.constructor||ce);const Et=new ht(Ft),ut=fe.current;return this[xt]==en?this[mt].push(ut,Et,Ye,Ae):Qn(this,ut,Et,Ye,Ae),Et}catch(Ye){return this.then(null,Ye)}finally(Ye){var Ae;let Ge=null===(Ae=this.constructor)||void 0===Ae?void 0:Ae[Symbol.species];(!Ge||"function"!=typeof Ge)&&(Ge=ce);const ht=new Ge(Ft);ht[et]=et;const Et=fe.current;return this[xt]==en?this[mt].push(Et,ht,Ye,Ye):Qn(this,Et,ht,Ye,Ye),ht}}ce.resolve=ce.resolve,ce.reject=ce.reject,ce.race=ce.race,ce.all=ce.all;const ve=ie[nt]=ie.Promise;ie.Promise=ce;const yt=Qe("thenPatched");function Dt(je){const Ye=je.prototype,Ae=me(Ye,"then");if(Ae&&(!1===Ae.writable||!Ae.configurable))return;const Ge=Ye.then;Ye[Ke]=Ge,je.prototype.then=function(ht,Et){return new ce((St,$t)=>{Ge.call(this,St,$t)}).then(ht,Et)},je[yt]=!0}return ye.patchThen=Dt,ve&&(Dt(ve),z(ie,"fetch",je=>function gn(je){return function(Ye,Ae){let Ge=je.apply(Ye,Ae);if(Ge instanceof ce)return Ge;let ht=Ge.constructor;return ht[yt]||Dt(ht),Ge}}(je))),Promise[fe.__symbol__("uncaughtPromiseErrors")]=qe,ce}),Zone.__load_patch("toString",ie=>{const fe=Function.prototype.toString,ye=E("OriginalDelegate"),me=E("Promise"),_e=E("Error"),Ne=function(){if("function"==typeof this){const nt=this[ye];if(nt)return"function"==typeof nt?fe.call(nt):Object.prototype.toString.call(nt);if(this===Promise){const Ke=ie[me];if(Ke)return fe.call(Ke)}if(this===Error){const Ke=ie[_e];if(Ke)return fe.call(Ke)}}return fe.call(this)};Ne[ye]=fe,Function.prototype.toString=Ne;const Qe=Object.prototype.toString;Object.prototype.toString=function(){return"function"==typeof Promise&&this instanceof Promise?"[object Promise]":Qe.call(this)}});let pe=!1;if(typeof window<"u")try{const ie=Object.defineProperty({},"passive",{get:function(){pe=!0}});window.addEventListener("test",ie,ie),window.removeEventListener("test",ie,ie)}catch{pe=!1}const Le={useG:!0},Se={},Pe={},be=new RegExp("^"+d+"(\\w+)(true|false)$"),$e=E("propagationStopped");function H(ie,fe){const ye=(fe?fe(ie):ie)+f,me=(fe?fe(ie):ie)+c,_e=d+ye,Ne=d+me;Se[ie]={},Se[ie][f]=_e,Se[ie][c]=Ne}function Ee(ie,fe,ye,me){const _e=me&&me.add||g,Ne=me&&me.rm||w,Qe=me&&me.listeners||"eventListeners",qe=me&&me.rmAll||"removeAllListeners",it=E(_e),nt="."+_e+":",ge=function(mt,et,Tn){if(mt.isRemoved)return;const Bt=mt.callback;let pn;"object"==typeof Bt&&Bt.handleEvent&&(mt.callback=ft=>Bt.handleEvent(ft),mt.originalDelegate=Bt);try{mt.invoke(mt,et,[Tn])}catch(ft){pn=ft}const en=mt.options;return en&&"object"==typeof en&&en.once&&et[Ne].call(et,Tn.type,mt.originalDelegate?mt.originalDelegate:mt.callback,en),pn};function De(mt,et,Tn){if(!(et=et||ie.event))return;const Bt=mt||et.target||ie,pn=Bt[Se[et.type][Tn?c:f]];if(pn){const en=[];if(1===pn.length){const ft=ge(pn[0],Bt,et);ft&&en.push(ft)}else{const ft=pn.slice();for(let ln=0;ln{throw ln})}}}const Fe=function(mt){return De(this,mt,!1)},Be=function(mt){return De(this,mt,!0)};function dt(mt,et){if(!mt)return!1;let Tn=!0;et&&void 0!==et.useG&&(Tn=et.useG);const Bt=et&&et.vh;let pn=!0;et&&void 0!==et.chkDup&&(pn=et.chkDup);let en=!1;et&&void 0!==et.rt&&(en=et.rt);let ft=mt;for(;ft&&!ft.hasOwnProperty(_e);)ft=x(ft);if(!ft&&mt[_e]&&(ft=mt),!ft||ft[it])return!1;const ln=et&&et.eventNameToString,st={},Kt=ft[it]=ft[_e],wt=ft[E(Ne)]=ft[Ne],Jn=ft[E(Qe)]=ft[Qe],Pr=ft[E(qe)]=ft[qe];let On;function vn(Ae,Ge){return!pe&&"object"==typeof Ae&&Ae?!!Ae.capture:pe&&Ge?"boolean"==typeof Ae?{capture:Ae,passive:!0}:Ae?"object"==typeof Ae&&!1!==Ae.passive?Object.assign(Object.assign({},Ae),{passive:!0}):Ae:{passive:!0}:Ae}et&&et.prepend&&(On=ft[E(et.prepend)]=ft[et.prepend]);const ce=Tn?function(Ae){if(!st.isExisting)return Kt.call(st.target,st.eventName,st.capture?Be:Fe,st.options)}:function(Ae){return Kt.call(st.target,st.eventName,Ae.invoke,st.options)},ve=Tn?function(Ae){if(!Ae.isRemoved){const Ge=Se[Ae.eventName];let ht;Ge&&(ht=Ge[Ae.capture?c:f]);const Et=ht&&Ae.target[ht];if(Et)for(let ut=0;utfunction(_e,Ne){_e[$e]=!0,me&&me.apply(_e,Ne)})}function He(ie,fe,ye,me,_e){const Ne=Zone.__symbol__(me);if(fe[Ne])return;const Qe=fe[Ne]=fe[me];fe[me]=function(qe,it,nt){return it&&it.prototype&&_e.forEach(function(Ke){const we=`${ye}.${me}::`+Ke,ge=it.prototype;try{if(ge.hasOwnProperty(Ke)){const De=ie.ObjectGetOwnPropertyDescriptor(ge,Ke);De&&De.value?(De.value=ie.wrapWithCurrentZone(De.value,we),ie._redefineProperty(it.prototype,Ke,De)):ge[Ke]&&(ge[Ke]=ie.wrapWithCurrentZone(ge[Ke],we))}else ge[Ke]&&(ge[Ke]=ie.wrapWithCurrentZone(ge[Ke],we))}catch{}}),Qe.call(fe,qe,it,nt)},ie.attachOriginToPatched(fe[me],Qe)}function We(ie,fe,ye){if(!ye||0===ye.length)return fe;const me=ye.filter(Ne=>Ne.target===ie);if(!me||0===me.length)return fe;const _e=me[0].ignoreProperties;return fe.filter(Ne=>-1===_e.indexOf(Ne))}function Je(ie,fe,ye,me){ie&&L(ie,We(ie,fe,ye),me)}function Xe(ie){return Object.getOwnPropertyNames(ie).filter(fe=>fe.startsWith("on")&&fe.length>2).map(fe=>fe.substring(2))}Zone.__load_patch("util",(ie,fe,ye)=>{const me=Xe(ie);ye.patchOnProperties=L,ye.patchMethod=z,ye.bindArguments=P,ye.patchMacroTask=te;const _e=fe.__symbol__("BLACK_LISTED_EVENTS"),Ne=fe.__symbol__("UNPATCHED_EVENTS");ie[Ne]&&(ie[_e]=ie[Ne]),ie[_e]&&(fe[_e]=fe[Ne]=ie[_e]),ye.patchEventPrototype=xe,ye.patchEventTarget=Ee,ye.isIEOrEdge=de,ye.ObjectDefineProperty=U,ye.ObjectGetOwnPropertyDescriptor=Y,ye.ObjectCreate=y,ye.ArraySlice=l,ye.patchClass=re,ye.wrapWithCurrentZone=b,ye.filterProperties=We,ye.attachOriginToPatched=X,ye._redefineProperty=Object.defineProperty,ye.patchCallbacks=He,ye.getGlobalObjects=()=>({globalSources:Pe,zoneSymbolEventNames:Se,eventNames:me,isBrowser:F,isMix:G,isNode:k,TRUE_STR:c,FALSE_STR:f,ZONE_SYMBOL_PREFIX:d,ADD_EVENT_LISTENER_STR:g,REMOVE_EVENT_LISTENER_STR:w})});const pt=E("zoneTask");function _t(ie,fe,ye,me){let _e=null,Ne=null;ye+=me;const Qe={};function qe(nt){const Ke=nt.data;return Ke.args[0]=function(){return nt.invoke.apply(this,arguments)},Ke.handleId=_e.apply(ie,Ke.args),nt}function it(nt){return Ne.call(ie,nt.data.handleId)}_e=z(ie,fe+=me,nt=>function(Ke,we){if("function"==typeof we[0]){const ge={isPeriodic:"Interval"===me,delay:"Timeout"===me||"Interval"===me?we[1]||0:void 0,args:we},De=we[0];we[0]=function(){try{return De.apply(this,arguments)}finally{ge.isPeriodic||("number"==typeof ge.handleId?delete Qe[ge.handleId]:ge.handleId&&(ge.handleId[pt]=null))}};const Fe=S(fe,we[0],ge,qe,it);if(!Fe)return Fe;const Be=Fe.data.handleId;return"number"==typeof Be?Qe[Be]=Fe:Be&&(Be[pt]=Fe),Be&&Be.ref&&Be.unref&&"function"==typeof Be.ref&&"function"==typeof Be.unref&&(Fe.ref=Be.ref.bind(Be),Fe.unref=Be.unref.bind(Be)),"number"==typeof Be||Be?Be:Fe}return nt.apply(ie,we)}),Ne=z(ie,ye,nt=>function(Ke,we){const ge=we[0];let De;"number"==typeof ge?De=Qe[ge]:(De=ge&&ge[pt],De||(De=ge)),De&&"string"==typeof De.type?"notScheduled"!==De.state&&(De.cancelFn&&De.data.isPeriodic||0===De.runCount)&&("number"==typeof ge?delete Qe[ge]:ge&&(ge[pt]=null),De.zone.cancelTask(De)):nt.apply(ie,we)})}Zone.__load_patch("legacy",ie=>{const fe=ie[Zone.__symbol__("legacyPatch")];fe&&fe()}),Zone.__load_patch("queueMicrotask",(ie,fe,ye)=>{ye.patchMethod(ie,"queueMicrotask",me=>function(_e,Ne){fe.current.scheduleMicroTask("queueMicrotask",Ne[0])})}),Zone.__load_patch("timers",ie=>{const ye="clear";_t(ie,"set",ye,"Timeout"),_t(ie,"set",ye,"Interval"),_t(ie,"set",ye,"Immediate")}),Zone.__load_patch("requestAnimationFrame",ie=>{_t(ie,"request","cancel","AnimationFrame"),_t(ie,"mozRequest","mozCancel","AnimationFrame"),_t(ie,"webkitRequest","webkitCancel","AnimationFrame")}),Zone.__load_patch("blocking",(ie,fe)=>{const ye=["alert","prompt","confirm"];for(let me=0;mefunction(it,nt){return fe.current.run(Ne,ie,nt,qe)})}),Zone.__load_patch("EventTarget",(ie,fe,ye)=>{(function Hr(ie,fe){fe.patchEventPrototype(ie,fe)})(ie,ye),function gr(ie,fe){if(Zone[fe.symbol("patchEventTarget")])return;const{eventNames:ye,zoneSymbolEventNames:me,TRUE_STR:_e,FALSE_STR:Ne,ZONE_SYMBOL_PREFIX:Qe}=fe.getGlobalObjects();for(let it=0;it{re("MutationObserver"),re("WebKitMutationObserver")}),Zone.__load_patch("IntersectionObserver",(ie,fe,ye)=>{re("IntersectionObserver")}),Zone.__load_patch("FileReader",(ie,fe,ye)=>{re("FileReader")}),Zone.__load_patch("on_property",(ie,fe,ye)=>{!function Nt(ie,fe){if(k&&!G||Zone[ie.symbol("patchEvents")])return;const ye=fe.__Zone_ignore_on_properties;let me=[];if(F){const _e=window;me=me.concat(["Document","SVGElement","Element","HTMLElement","HTMLBodyElement","HTMLMediaElement","HTMLFrameSetElement","HTMLFrameElement","HTMLIFrameElement","HTMLMarqueeElement","Worker"]);const Ne=function se(){try{const ie=p.navigator.userAgent;if(-1!==ie.indexOf("MSIE ")||-1!==ie.indexOf("Trident/"))return!0}catch{}return!1}()?[{target:_e,ignoreProperties:["error"]}]:[];Je(_e,Xe(_e),ye&&ye.concat(Ne),x(_e))}me=me.concat(["XMLHttpRequest","XMLHttpRequestEventTarget","IDBIndex","IDBRequest","IDBOpenDBRequest","IDBDatabase","IDBTransaction","IDBCursor","WebSocket"]);for(let _e=0;_e{!function Or(ie,fe){const{isBrowser:ye,isMix:me}=fe.getGlobalObjects();(ye||me)&&ie.customElements&&"customElements"in ie&&fe.patchCallbacks(fe,ie.customElements,"customElements","define",["connectedCallback","disconnectedCallback","adoptedCallback","attributeChangedCallback"])}(ie,ye)}),Zone.__load_patch("XHR",(ie,fe)=>{!function it(nt){const Ke=nt.XMLHttpRequest;if(!Ke)return;const we=Ke.prototype;let De=we[m],Fe=we[h];if(!De){const st=nt.XMLHttpRequestEventTarget;if(st){const Kt=st.prototype;De=Kt[m],Fe=Kt[h]}}const Be="readystatechange",dt="scheduled";function xt(st){const Kt=st.data,wt=Kt.target;wt[Ne]=!1,wt[qe]=!1;const Jn=wt[_e];De||(De=wt[m],Fe=wt[h]),Jn&&Fe.call(wt,Be,Jn);const Pr=wt[_e]=()=>{if(wt.readyState===wt.DONE)if(!Kt.aborted&&wt[Ne]&&st.state===dt){const vn=wt[fe.__symbol__("loadfalse")];if(0!==wt.status&&vn&&vn.length>0){const ur=st.invoke;st.invoke=function(){const Qn=wt[fe.__symbol__("loadfalse")];for(let En=0;Enfunction(st,Kt){return st[me]=0==Kt[2],st[Qe]=Kt[1],Tn.apply(st,Kt)}),pn=E("fetchTaskAborting"),en=E("fetchTaskScheduling"),ft=z(we,"send",()=>function(st,Kt){if(!0===fe.current[en]||st[me])return ft.apply(st,Kt);{const wt={target:st,url:st[Qe],isPeriodic:!1,args:Kt,aborted:!1},Jn=S("XMLHttpRequest.send",mt,wt,xt,et);st&&!0===st[qe]&&!wt.aborted&&Jn.state===dt&&Jn.invoke()}}),ln=z(we,"abort",()=>function(st,Kt){const wt=function ge(st){return st[ye]}(st);if(wt&&"string"==typeof wt.type){if(null==wt.cancelFn||wt.data&&wt.data.aborted)return;wt.zone.cancelTask(wt)}else if(!0===fe.current[pn])return ln.apply(st,Kt)})}(ie);const ye=E("xhrTask"),me=E("xhrSync"),_e=E("xhrListener"),Ne=E("xhrScheduled"),Qe=E("xhrURL"),qe=E("xhrErrorBeforeScheduled")}),Zone.__load_patch("geolocation",ie=>{ie.navigator&&ie.navigator.geolocation&&function D(ie,fe){const ye=ie.constructor.name;for(let me=0;me{const it=function(){return qe.apply(this,P(arguments,ye+"."+_e))};return X(it,qe),it})(Ne)}}}(ie.navigator.geolocation,["getCurrentPosition","watchPosition"])}),Zone.__load_patch("PromiseRejectionEvent",(ie,fe)=>{function ye(me){return function(_e){Te(ie,me).forEach(Qe=>{const qe=ie.PromiseRejectionEvent;if(qe){const it=new qe(me,{promise:_e.promise,reason:_e.rejection});Qe.invoke(it)}})}}ie.PromiseRejectionEvent&&(fe[E("unhandledPromiseRejectionHandler")]=ye("unhandledrejection"),fe[E("rejectionHandledHandler")]=ye("rejectionhandled"))})},7420:()=>{},5856:()=>{},5883:()=>{},6577:()=>{},5819:()=>{},1265:()=>{},5539:()=>{},8479:function(Y,U,x){"use strict";var l,g;l=[x(1873)],void 0!==(g=function(w){var m=w.Reader,h=w.Writer,c=w.util,f=w.roots.default||(w.roots.default={});return f.RPC=function(){function d(S){if(this.subscriptions=[],this.messages=[],S)for(var E=Object.keys(S),v=0;v>>3){case 1:I.subscriptions&&I.subscriptions.length||(I.subscriptions=[]),I.subscriptions.push(f.RPC.SubOpts.decode(E,E.uint32()));break;case 2:I.messages&&I.messages.length||(I.messages=[]),I.messages.push(f.RPC.Message.decode(E,E.uint32()));break;case 3:I.control=f.RPC.ControlMessage.decode(E,E.uint32());break;default:E.skipType(7&A)}}return I},d.fromObject=function(E){if(E instanceof f.RPC)return E;var v=new f.RPC;if(E.subscriptions){if(!Array.isArray(E.subscriptions))throw TypeError(".RPC.subscriptions: array expected");v.subscriptions=[];for(var p=0;p>>3){case 1:P.subscribe=p.bool();break;case 2:P.topic=p.string();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.SubOpts)return p;var I=new f.RPC.SubOpts;return null!=p.subscribe&&(I.subscribe=Boolean(p.subscribe)),null!=p.topic&&(I.topic=String(p.topic)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.subscribe&&p.hasOwnProperty("subscribe")&&(A.subscribe=p.subscribe,I.oneofs&&(A._subscribe="subscribe")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic,I.oneofs&&(A._topic="topic")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.Message=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.from=p.bytes();break;case 2:P.data=p.bytes();break;case 3:P.seqno=p.bytes();break;case 4:P.topic=p.string();break;case 5:P.signature=p.bytes();break;case 6:P.key=p.bytes();break;default:p.skipType(7&D)}}if(!P.hasOwnProperty("topic"))throw c.ProtocolError("missing required 'topic'",{instance:P});return P},S.fromObject=function(p){if(p instanceof f.RPC.Message)return p;var I=new f.RPC.Message;return null!=p.from&&("string"==typeof p.from?c.base64.decode(p.from,I.from=c.newBuffer(c.base64.length(p.from)),0):p.from.length&&(I.from=p.from)),null!=p.data&&("string"==typeof p.data?c.base64.decode(p.data,I.data=c.newBuffer(c.base64.length(p.data)),0):p.data.length&&(I.data=p.data)),null!=p.seqno&&("string"==typeof p.seqno?c.base64.decode(p.seqno,I.seqno=c.newBuffer(c.base64.length(p.seqno)),0):p.seqno.length&&(I.seqno=p.seqno)),null!=p.topic&&(I.topic=String(p.topic)),null!=p.signature&&("string"==typeof p.signature?c.base64.decode(p.signature,I.signature=c.newBuffer(c.base64.length(p.signature)),0):p.signature.length&&(I.signature=p.signature)),null!=p.key&&("string"==typeof p.key?c.base64.decode(p.key,I.key=c.newBuffer(c.base64.length(p.key)),0):p.key.length&&(I.key=p.key)),I},S.toObject=function(p,I){I||(I={});var A={};return I.defaults&&(A.topic=""),null!=p.from&&p.hasOwnProperty("from")&&(A.from=I.bytes===String?c.base64.encode(p.from,0,p.from.length):I.bytes===Array?Array.prototype.slice.call(p.from):p.from,I.oneofs&&(A._from="from")),null!=p.data&&p.hasOwnProperty("data")&&(A.data=I.bytes===String?c.base64.encode(p.data,0,p.data.length):I.bytes===Array?Array.prototype.slice.call(p.data):p.data,I.oneofs&&(A._data="data")),null!=p.seqno&&p.hasOwnProperty("seqno")&&(A.seqno=I.bytes===String?c.base64.encode(p.seqno,0,p.seqno.length):I.bytes===Array?Array.prototype.slice.call(p.seqno):p.seqno,I.oneofs&&(A._seqno="seqno")),null!=p.topic&&p.hasOwnProperty("topic")&&(A.topic=p.topic),null!=p.signature&&p.hasOwnProperty("signature")&&(A.signature=I.bytes===String?c.base64.encode(p.signature,0,p.signature.length):I.bytes===Array?Array.prototype.slice.call(p.signature):p.signature,I.oneofs&&(A._signature="signature")),null!=p.key&&p.hasOwnProperty("key")&&(A.key=I.bytes===String?c.base64.encode(p.key,0,p.key.length):I.bytes===Array?Array.prototype.slice.call(p.key):p.key,I.oneofs&&(A._key="key")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlMessage=function(){function S(E){if(this.ihave=[],this.iwant=[],this.graft=[],this.prune=[],E)for(var v=Object.keys(E),p=0;p>>3){case 1:A.ihave&&A.ihave.length||(A.ihave=[]),A.ihave.push(f.RPC.ControlIHave.decode(v,v.uint32()));break;case 2:A.iwant&&A.iwant.length||(A.iwant=[]),A.iwant.push(f.RPC.ControlIWant.decode(v,v.uint32()));break;case 3:A.graft&&A.graft.length||(A.graft=[]),A.graft.push(f.RPC.ControlGraft.decode(v,v.uint32()));break;case 4:A.prune&&A.prune.length||(A.prune=[]),A.prune.push(f.RPC.ControlPrune.decode(v,v.uint32()));break;default:v.skipType(7&P)}}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlMessage)return v;var p=new f.RPC.ControlMessage;if(v.ihave){if(!Array.isArray(v.ihave))throw TypeError(".RPC.ControlMessage.ihave: array expected");p.ihave=[];for(var I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.messageIDs&&P.messageIDs.length||(P.messageIDs=[]),P.messageIDs.push(p.bytes());break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlIHave)return p;var I=new f.RPC.ControlIHave;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.messageIDs){if(!Array.isArray(p.messageIDs))throw TypeError(".RPC.ControlIHave.messageIDs: array expected");I.messageIDs=[];for(var A=0;A>>3==1?(A.messageIDs&&A.messageIDs.length||(A.messageIDs=[]),A.messageIDs.push(v.bytes())):v.skipType(7&P)}return A},S.fromObject=function(v){if(v instanceof f.RPC.ControlIWant)return v;var p=new f.RPC.ControlIWant;if(v.messageIDs){if(!Array.isArray(v.messageIDs))throw TypeError(".RPC.ControlIWant.messageIDs: array expected");p.messageIDs=[];for(var I=0;I>>3==1?P.topicID=p.string():p.skipType(7&D)}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlGraft)return p;var I=new f.RPC.ControlGraft;return null!=p.topicID&&(I.topicID=String(p.topicID)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.ControlPrune=function(){function S(v){if(this.peers=[],v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.topicID=p.string();break;case 2:P.peers&&P.peers.length||(P.peers=[]),P.peers.push(f.RPC.PeerInfo.decode(p,p.uint32()));break;case 3:P.backoff=p.uint64();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.ControlPrune)return p;var I=new f.RPC.ControlPrune;if(null!=p.topicID&&(I.topicID=String(p.topicID)),p.peers){if(!Array.isArray(p.peers))throw TypeError(".RPC.ControlPrune.peers: array expected");I.peers=[];for(var A=0;A>>0,p.backoff.high>>>0).toNumber(!0))),I},S.toObject=function(p,I){I||(I={});var A={};if((I.arrays||I.defaults)&&(A.peers=[]),null!=p.topicID&&p.hasOwnProperty("topicID")&&(A.topicID=p.topicID,I.oneofs&&(A._topicID="topicID")),p.peers&&p.peers.length){A.peers=[];for(var P=0;P>>0,p.backoff.high>>>0).toNumber(!0):p.backoff,I.oneofs&&(A._backoff="backoff")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d.PeerInfo=function(){function S(v){if(v)for(var p=Object.keys(v),I=0;I>>3){case 1:P.peerID=p.bytes();break;case 2:P.signedPeerRecord=p.bytes();break;default:p.skipType(7&D)}}return P},S.fromObject=function(p){if(p instanceof f.RPC.PeerInfo)return p;var I=new f.RPC.PeerInfo;return null!=p.peerID&&("string"==typeof p.peerID?c.base64.decode(p.peerID,I.peerID=c.newBuffer(c.base64.length(p.peerID)),0):p.peerID.length&&(I.peerID=p.peerID)),null!=p.signedPeerRecord&&("string"==typeof p.signedPeerRecord?c.base64.decode(p.signedPeerRecord,I.signedPeerRecord=c.newBuffer(c.base64.length(p.signedPeerRecord)),0):p.signedPeerRecord.length&&(I.signedPeerRecord=p.signedPeerRecord)),I},S.toObject=function(p,I){I||(I={});var A={};return null!=p.peerID&&p.hasOwnProperty("peerID")&&(A.peerID=I.bytes===String?c.base64.encode(p.peerID,0,p.peerID.length):I.bytes===Array?Array.prototype.slice.call(p.peerID):p.peerID,I.oneofs&&(A._peerID="peerID")),null!=p.signedPeerRecord&&p.hasOwnProperty("signedPeerRecord")&&(A.signedPeerRecord=I.bytes===String?c.base64.encode(p.signedPeerRecord,0,p.signedPeerRecord.length):I.bytes===Array?Array.prototype.slice.call(p.signedPeerRecord):p.signedPeerRecord,I.oneofs&&(A._signedPeerRecord="signedPeerRecord")),A},S.prototype.toJSON=function(){return this.constructor.toObject(this,w.util.toJSONOptions)},S}(),d}(),f}.apply(U,l))&&(Y.exports=g)},4642:(Y,U,x)=>{var y=x(9805);function l(g){var w,m;function c(d,b){try{var S=g[d](b),E=S.value,v=E instanceof y;Promise.resolve(v?E.wrapped:E).then(function(p){v?c("return"===d?"return":"next",p):f(S.done?"return":"normal",p)},function(p){c("throw",p)})}catch(p){f("throw",p)}}function f(d,b){switch(d){case"return":w.resolve({value:b,done:!0});break;case"throw":w.reject(b);break;default:w.resolve({value:b,done:!1})}(w=w.next)?c(w.key,w.arg):m=null}this._invoke=function h(d,b){return new Promise(function(S,E){var v={key:d,arg:b,resolve:S,reject:E,next:null};m?m=m.next=v:(w=m=v,c(d,b))})},"function"!=typeof g.return&&(this.return=void 0)}l.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},l.prototype.next=function(g){return this._invoke("next",g)},l.prototype.throw=function(g){return this._invoke("throw",g)},l.prototype.return=function(g){return this._invoke("return",g)},Y.exports=l,Y.exports.__esModule=!0,Y.exports.default=Y.exports},9805:Y=>{Y.exports=function U(x){this.wrapped=x},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8131:Y=>{Y.exports=function U(x,y){var l={},g=!1;function w(m,h){return g=!0,h=new Promise(function(c){c(x[m](h))}),{done:!1,value:y(h)}}return l[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},l.next=function(m){return g?(g=!1,m):w("next",m)},"function"==typeof x.throw&&(l.throw=function(m){if(g)throw g=!1,m;return w("throw",m)}),"function"==typeof x.return&&(l.return=function(m){return g?(g=!1,m):w("return",m)}),l},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8237:Y=>{function x(y){function l(g){if(Object(g)!==g)return Promise.reject(new TypeError(g+" is not an object."));var w=g.done;return Promise.resolve(g.value).then(function(m){return{value:m,done:w}})}return(x=function(w){this.s=w,this.n=w.next}).prototype={s:null,n:null,next:function(){return l(this.n.apply(this.s,arguments))},return:function(w){var m=this.s.return;return void 0===m?Promise.resolve({value:w,done:!0}):l(m.apply(this.s,arguments))},throw:function(w){var m=this.s.return;return void 0===m?Promise.reject(w):l(m.apply(this.s,arguments))}},new x(y)}Y.exports=function U(y){var l,g,w,m=2;for(typeof Symbol<"u"&&(g=Symbol.asyncIterator,w=Symbol.iterator);m--;){if(g&&null!=(l=y[g]))return l.call(y);if(w&&null!=(l=y[w]))return new x(l.call(y));g="@@asyncIterator",w="@@iterator"}throw new TypeError("Object is not async iterable")},Y.exports.__esModule=!0,Y.exports.default=Y.exports},7156:Y=>{function U(y,l,g,w,m,h,c){try{var f=y[h](c),d=f.value}catch(b){return void g(b)}f.done?l(d):Promise.resolve(d).then(w,m)}Y.exports=function x(y){return function(){var l=this,g=arguments;return new Promise(function(w,m){var h=y.apply(l,g);function c(d){U(h,w,m,c,f,"next",d)}function f(d){U(h,w,m,c,f,"throw",d)}c(void 0)})}},Y.exports.__esModule=!0,Y.exports.default=Y.exports},6737:(Y,U,x)=>{var y=x(9805);Y.exports=function l(g){return new y(g)},Y.exports.__esModule=!0,Y.exports.default=Y.exports},8186:(Y,U,x)=>{var y=x(4642);Y.exports=function l(g){return function(){return new y(g.apply(this,arguments))}},Y.exports.__esModule=!0,Y.exports.default=Y.exports}},Y=>{Y(Y.s=3683)}]); \ No newline at end of file diff --git a/relay-js/index.html b/relay-js/index.html index e55d92d..a4f461f 100644 --- a/relay-js/index.html +++ b/relay-js/index.html @@ -50,7 +50,7 @@ // Recommendation: `/dapp-name/version/functionality/codec` // We recommend to use protobuf as codec (`proto`), this demo uses utf-8 // for simplicity's sake. - const contentTopic = '/relay-demo/1/message/utf-8'; + const contentTopic = '/js-waku-examples/1/chat/utf8'; try { statusDiv.innerHTML = '

Starting

'; diff --git a/relay-reactjs-chat/asset-manifest.json b/relay-reactjs-chat/asset-manifest.json index 955b487..573640f 100644 --- a/relay-reactjs-chat/asset-manifest.json +++ b/relay-reactjs-chat/asset-manifest.json @@ -1,13 +1,13 @@ { "files": { "main.css": "/relay-reactjs-chat/static/css/main.e6c13ad2.css", - "main.js": "/relay-reactjs-chat/static/js/main.8a4afe82.js", + "main.js": "/relay-reactjs-chat/static/js/main.ba6c8d6d.js", "index.html": "/relay-reactjs-chat/index.html", "main.e6c13ad2.css.map": "/relay-reactjs-chat/static/css/main.e6c13ad2.css.map", - "main.8a4afe82.js.map": "/relay-reactjs-chat/static/js/main.8a4afe82.js.map" + "main.ba6c8d6d.js.map": "/relay-reactjs-chat/static/js/main.ba6c8d6d.js.map" }, "entrypoints": [ "static/css/main.e6c13ad2.css", - "static/js/main.8a4afe82.js" + "static/js/main.ba6c8d6d.js" ] } \ No newline at end of file diff --git a/relay-reactjs-chat/index.html b/relay-reactjs-chat/index.html index 6f62046..d125f87 100644 --- a/relay-reactjs-chat/index.html +++ b/relay-reactjs-chat/index.html @@ -1 +1 @@ -React App
\ No newline at end of file +React App
\ No newline at end of file diff --git a/relay-reactjs-chat/static/js/main.8a4afe82.js b/relay-reactjs-chat/static/js/main.ba6c8d6d.js similarity index 99% rename from relay-reactjs-chat/static/js/main.8a4afe82.js rename to relay-reactjs-chat/static/js/main.ba6c8d6d.js index b526ec7..eda705b 100644 --- a/relay-reactjs-chat/static/js/main.8a4afe82.js +++ b/relay-reactjs-chat/static/js/main.ba6c8d6d.js @@ -1,3 +1,3 @@ -/*! For license information please see main.8a4afe82.js.LICENSE.txt */ -(()=>{var __webpack_modules__={2001:(e,t,r)=>{"use strict";e.exports=r(6181)},6181:(e,t,r)=>{"use strict";var n=t;function i(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}n.build="minimal",n.Writer=r(9800),n.BufferWriter=r(6489),n.Reader=r(5684),n.BufferReader=r(1229),n.util=r(9584),n.rpc=r(1872),n.roots=r(9358),n.configure=i,i()},5684:(e,t,r)=>{"use strict";e.exports=c;var n,i=r(9584),s=i.LongBits,o=i.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var l="undefined"!==typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},u=function(){return i.Buffer?function(e){return(c.create=function(e){return i.Buffer.isBuffer(e)?new n(e):l(e)})(e)}:l};function h(){var e=new s(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new s(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=u(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=function(){var e=4294967295;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return e}}(),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},c.prototype.string=function(){var e=this.bytes();return o.read(e,0,e.length)},c.prototype.skip=function(e){if("number"===typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){n=e,c.create=u(),n._configure();var t=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},1229:(e,t,r)=>{"use strict";e.exports=s;var n=r(5684);(s.prototype=Object.create(n.prototype)).constructor=s;var i=r(9584);function s(e){n.call(this,e)}s._configure=function(){i.Buffer&&(s.prototype._slice=i.Buffer.prototype.slice)},s.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},s._configure()},9358:e=>{"use strict";e.exports={}},1872:(e,t,r)=>{"use strict";t.Service=r(4648)},4648:(e,t,r)=>{"use strict";e.exports=i;var n=r(9584);function i(e,t,r){if("function"!==typeof e)throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(i.prototype=Object.create(n.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,r,i,s,o){if(!s)throw TypeError("request must be specified");var a=this;if(!o)return n.asPromise(e,a,t,r,i,s);if(a.rpcImpl)try{return a.rpcImpl(t,r[a.requestDelimited?"encodeDelimited":"encode"](s).finish(),(function(e,r){if(e)return a.emit("error",e,t),o(e);if(null!==r){if(!(r instanceof i))try{r=i[a.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return a.emit("error",e,t),o(e)}return a.emit("data",r,t),o(null,r)}a.end(!0)}))}catch(c){return a.emit("error",c,t),void setTimeout((function(){o(c)}),0)}else setTimeout((function(){o(Error("already ended"))}),0)},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},6880:(e,t,r)=>{"use strict";e.exports=i;var n=r(9584);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var s=i.zero=new i(0,0);s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1};var o=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return s;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)},i.from=function(e){if("number"===typeof e)return i.fromNumber(e);if(n.isString(e)){if(!n.Long)return i.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):s},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;i.fromHash=function(e){return e===o?s:new i((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},9584:function(e,t,r){"use strict";var n=t;function i(e,t,r){for(var n=Object.keys(t),i=0;i0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(t){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"===typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"===typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!==typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=i,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=s,n.ProtocolError=s("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r{"use strict";e.exports=h;var n,i=r(9584),s=i.LongBits,o=i.base64,a=i.utf8;function c(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function l(){}function u(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function h(){this.len=0,this.head=new c(l,0,0),this.tail=this.head,this.states=null}var d=function(){return i.Buffer?function(){return(h.create=function(){return new n})()}:function(){return new h}};function f(e,t,r){t[r]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function y(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}h.create=d(),h.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(h.alloc=i.pool(h.alloc,i.Array.prototype.subarray)),h.prototype._push=function(e,t,r){return this.tail=this.tail.next=new c(e,t,r),this.len+=t,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},h.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},h.prototype.int32=function(e){return e<0?this._push(g,10,s.fromNumber(e)):this.uint32(e)},h.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},h.prototype.uint64=function(e){var t=s.from(e);return this._push(g,t.length(),t)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(e){var t=s.from(e).zzEncode();return this._push(g,t.length(),t)},h.prototype.bool=function(e){return this._push(f,1,e?1:0)},h.prototype.fixed32=function(e){return this._push(y,4,e>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(e){var t=s.from(e);return this._push(y,4,t.lo)._push(y,4,t.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},h.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var m=i.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n>>0;if(!t)return this._push(f,1,0);if(i.isString(e)){var r=h.alloc(t=o.length(e));o.decode(e,r,0),e=r}return this.uint32(t)._push(m,t,e)},h.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(f,1,0)},h.prototype.fork=function(){return this.states=new u(this),this.head=this.tail=new c(l,0,0),this.len=0,this},h.prototype.reset=function(){return this.states?(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 c(l,0,0),this.len=0),this},h.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},h.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},h._configure=function(e){n=e,h.create=d(),n._configure()}},6489:(e,t,r)=>{"use strict";e.exports=s;var n=r(9800);(s.prototype=Object.create(n.prototype)).constructor=s;var i=r(9584);function s(){n.call(this)}function o(e,t,r){e.length<40?i.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}s._configure=function(){s.alloc=i._Buffer_allocUnsafe,s.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n>>0;return this.uint32(t),t&&this._push(s.writeBytesBuffer,t,e),this},s.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(o,t,e),this},s._configure()},7206:e=>{"use strict";e.exports=function(e,t){var r=new Array(arguments.length-1),n=0,i=2,s=!0;for(;i{"use strict";var r=t;r.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),i=new Array(123),s=0;s<64;)i[n[s]=s<26?s+65:s<52?s+71:s<62?s-4:s-59|43]=s++;r.encode=function(e,t,r){for(var i,s=null,o=[],a=0,c=0;t>2],i=(3&l)<<4,c=1;break;case 1:o[a++]=n[i|l>>4],i=(15&l)<<2,c=2;break;case 2:o[a++]=n[i|l>>6],o[a++]=n[63&l],c=0}a>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,o)),a=0)}return c&&(o[a++]=n[i],o[a++]=61,1===c&&(o[a++]=61)),s?(a&&s.push(String.fromCharCode.apply(String,o.slice(0,a))),s.join("")):String.fromCharCode.apply(String,o.slice(0,a))};var o="invalid encoding";r.decode=function(e,t,r){for(var n,s=r,a=0,c=0;c1)break;if(void 0===(l=i[l]))throw Error(o);switch(a){case 0:n=l,a=1;break;case 1:t[r++]=n<<2|(48&l)>>4,n=l,a=2;break;case 2:t[r++]=(15&n)<<4|(60&l)>>2,n=l,a=3;break;case 3:t[r++]=(3&n)<<6|l,a=0}}if(1===a)throw Error(o);return r-s},r.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},3297:e=>{"use strict";function t(e,r){"string"===typeof e&&(r=e,e=void 0);var n=[];function i(e){if("string"!==typeof e){var r=s();if(t.verbose&&console.log("codegen: "+r),r="return "+r,e){for(var o=Object.keys(e),a=new Array(o.length+1),c=new Array(o.length),l=0;l{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n{"use strict";e.exports=s;var n=r(7206),i=r(7172)("fs");function s(e,t,r){return"function"===typeof t?(r=t,t={}):t||(t={}),r?!t.xhr&&i&&i.readFile?i.readFile(e,(function(n,i){return n&&"undefined"!==typeof XMLHttpRequest?s.xhr(e,t,r):n?r(n):r(null,t.binary?i:i.toString("utf8"))})):s.xhr(e,t,r):n(s,this,e,t)}s.xhr=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){if(4===n.readyState){if(0!==n.status&&200!==n.status)return r(Error("status "+n.status));if(t.binary){var e=n.response;if(!e){e=[];for(var i=0;i{"use strict";function t(e){return"undefined"!==typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3]}function s(e,n,i){t[0]=e,n[i]=r[3],n[i+1]=r[2],n[i+2]=r[1],n[i+3]=r[0]}function o(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function a(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?i:s,e.writeFloatBE=n?s:i,e.readFloatLE=n?o:a,e.readFloatBE=n?a:o}():function(){function t(e,t,r,n){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var s=Math.floor(Math.log(t)/Math.LN2);e((i<<31|s+127<<23|8388607&Math.round(t*Math.pow(2,-s)*8388608))>>>0,r,n)}}function o(e,t,r){var n=e(t,r),i=2*(n>>31)+1,s=n>>>23&255,o=8388607&n;return 255===s?o?NaN:i*(1/0):0===s?1401298464324817e-60*i*o:i*Math.pow(2,s-150)*(o+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,n),e.readFloatLE=o.bind(null,i),e.readFloatBE=o.bind(null,s)}(),"undefined"!==typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3],n[i+4]=r[4],n[i+5]=r[5],n[i+6]=r[6],n[i+7]=r[7]}function s(e,n,i){t[0]=e,n[i]=r[7],n[i+1]=r[6],n[i+2]=r[5],n[i+3]=r[4],n[i+4]=r[3],n[i+5]=r[2],n[i+6]=r[1],n[i+7]=r[0]}function o(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function a(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?i:s,e.writeDoubleBE=n?s:i,e.readDoubleLE=n?o:a,e.readDoubleBE=n?a:o}():function(){function t(e,t,r,n,i,s){var o=n<0?1:0;if(o&&(n=-n),0===n)e(0,i,s+t),e(1/n>0?0:2147483648,i,s+r);else if(isNaN(n))e(0,i,s+t),e(2146959360,i,s+r);else if(n>17976931348623157e292)e(0,i,s+t),e((o<<31|2146435072)>>>0,i,s+r);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,i,s+t),e((o<<31|a/4294967296)>>>0,i,s+r);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=n*Math.pow(2,-c))>>>0,i,s+t),e((o<<31|c+1023<<20|1048576*a&1048575)>>>0,i,s+r)}}}function o(e,t,r,n,i){var s=e(n,i+t),o=e(n,i+r),a=2*(o>>31)+1,c=o>>>20&2047,l=4294967296*(1048575&o)+s;return 2047===c?l?NaN:a*(1/0):0===c?5e-324*a*l:a*Math.pow(2,c-1075)*(l+4503599627370496)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,n,4,0),e.readDoubleLE=o.bind(null,i,0,4),e.readDoubleBE=o.bind(null,s,4,0)}(),e}function r(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function s(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},7172:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},7468:(e,t)=>{"use strict";var r=t,n=r.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},i=r.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),r=n(e),i="";r&&(i=t.shift()+"/");for(var s=0;s0&&".."!==t[s-1]?t.splice(--s,2):r?t.splice(s,1):++s:"."===t[s]?t.splice(s,1):++s;return i+t.join("/")};r.resolve=function(e,t,r){return r||(t=i(t)),n(t)?t:(r||(e=i(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?i(e+"/"+t):t)}},8236:e=>{"use strict";e.exports=function(e,t,r){var n=r||8192,i=n>>>1,s=null,o=n;return function(r){if(r<1||r>i)return e(r);o+r>n&&(s=e(n),o=0);var a=t.call(s,o,o+=r);return 7&o&&(o=1+(7|o)),a}}},3861:(e,t)=>{"use strict";var r=t;r.length=function(e){for(var t=0,r=0,n=0;n191&&n<224?s[o++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,s[o++]=55296+(n>>10),s[o++]=56320+(1023&n)):s[o++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),o=0);return i?(o&&i.push(String.fromCharCode.apply(String,s.slice(0,o))),i.join("")):String.fromCharCode.apply(String,s.slice(0,o))},r.write=function(e,t,r){for(var n,i,s=r,o=0;o>6|192,t[r++]=63&n|128):55296===(64512&n)&&56320===(64512&(i=e.charCodeAt(o+1)))?(n=65536+((1023&n)<<10)+(1023&i),++o,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-s}},6232:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(5073);function i(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>8,t[r+1]=e>>>0,t}function s(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}function o(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function a(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function c(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function l(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function u(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}function h(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}function d(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),u(e/4294967296>>>0,t,r),u(e>>>0,t,r+4),t}function f(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),h(e>>>0,t,r),h(e/4294967296>>>0,t,r+4),t}t.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},t.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},t.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},t.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},t.writeUint16BE=i,t.writeInt16BE=i,t.writeUint16LE=s,t.writeInt16LE=s,t.readInt32BE=o,t.readUint32BE=a,t.readInt32LE=c,t.readUint32LE=l,t.writeUint32BE=u,t.writeInt32BE=u,t.writeUint32LE=h,t.writeInt32LE=h,t.readInt64BE=function(e,t){void 0===t&&(t=0);var r=o(e,t),n=o(e,t+4);return 4294967296*r+n-4294967296*(n>>31)},t.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*a(e,t)+a(e,t+4)},t.readInt64LE=function(e,t){void 0===t&&(t=0);var r=c(e,t);return 4294967296*c(e,t+4)+r-4294967296*(r>>31)},t.readUint64LE=function(e,t){void 0===t&&(t=0);var r=l(e,t);return 4294967296*l(e,t+4)+r},t.writeUint64BE=d,t.writeInt64BE=d,t.writeUint64LE=f,t.writeInt64LE=f,t.readUintBE=function(e,t,r){if(void 0===r&&(r=0),e%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=e/8+r-1;s>=r;s--)n+=t[s]*i,i*=256;return n},t.readUintLE=function(e,t,r){if(void 0===r&&(r=0),e%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s=i;o--)r[o]=t/s&255,s*=256;return r},t.writeUintLE=function(e,t,r,i){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===i&&(i=0),e%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!n.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var s=1,o=i;o{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(6232),i=r(9116);function s(e,t,r){for(var i=1634760805,s=857760878,o=2036477234,a=1797285236,c=r[3]<<24|r[2]<<16|r[1]<<8|r[0],l=r[7]<<24|r[6]<<16|r[5]<<8|r[4],u=r[11]<<24|r[10]<<16|r[9]<<8|r[8],h=r[15]<<24|r[14]<<16|r[13]<<8|r[12],d=r[19]<<24|r[18]<<16|r[17]<<8|r[16],f=r[23]<<24|r[22]<<16|r[21]<<8|r[20],p=r[27]<<24|r[26]<<16|r[25]<<8|r[24],g=r[31]<<24|r[30]<<16|r[29]<<8|r[28],y=t[3]<<24|t[2]<<16|t[1]<<8|t[0],m=t[7]<<24|t[6]<<16|t[5]<<8|t[4],v=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],w=i,E=s,_=o,S=a,I=c,C=l,A=u,T=h,k=d,R=f,P=p,D=g,N=y,O=m,L=v,x=b,B=0;B<20;B+=2)I=(I^=k=k+(N=(N^=w=w+I|0)>>>16|N<<16)|0)>>>20|I<<12,C=(C^=R=R+(O=(O^=E=E+C|0)>>>16|O<<16)|0)>>>20|C<<12,A=(A^=P=P+(L=(L^=_=_+A|0)>>>16|L<<16)|0)>>>20|A<<12,T=(T^=D=D+(x=(x^=S=S+T|0)>>>16|x<<16)|0)>>>20|T<<12,A=(A^=P=P+(L=(L^=_=_+A|0)>>>24|L<<8)|0)>>>25|A<<7,T=(T^=D=D+(x=(x^=S=S+T|0)>>>24|x<<8)|0)>>>25|T<<7,C=(C^=R=R+(O=(O^=E=E+C|0)>>>24|O<<8)|0)>>>25|C<<7,I=(I^=k=k+(N=(N^=w=w+I|0)>>>24|N<<8)|0)>>>25|I<<7,C=(C^=P=P+(x=(x^=w=w+C|0)>>>16|x<<16)|0)>>>20|C<<12,A=(A^=D=D+(N=(N^=E=E+A|0)>>>16|N<<16)|0)>>>20|A<<12,T=(T^=k=k+(O=(O^=_=_+T|0)>>>16|O<<16)|0)>>>20|T<<12,I=(I^=R=R+(L=(L^=S=S+I|0)>>>16|L<<16)|0)>>>20|I<<12,T=(T^=k=k+(O=(O^=_=_+T|0)>>>24|O<<8)|0)>>>25|T<<7,I=(I^=R=R+(L=(L^=S=S+I|0)>>>24|L<<8)|0)>>>25|I<<7,A=(A^=D=D+(N=(N^=E=E+A|0)>>>24|N<<8)|0)>>>25|A<<7,C=(C^=P=P+(x=(x^=w=w+C|0)>>>24|x<<8)|0)>>>25|C<<7;n.writeUint32LE(w+i|0,e,0),n.writeUint32LE(E+s|0,e,4),n.writeUint32LE(_+o|0,e,8),n.writeUint32LE(S+a|0,e,12),n.writeUint32LE(I+c|0,e,16),n.writeUint32LE(C+l|0,e,20),n.writeUint32LE(A+u|0,e,24),n.writeUint32LE(T+h|0,e,28),n.writeUint32LE(k+d|0,e,32),n.writeUint32LE(R+f|0,e,36),n.writeUint32LE(P+p|0,e,40),n.writeUint32LE(D+g|0,e,44),n.writeUint32LE(N+y|0,e,48),n.writeUint32LE(O+m|0,e,52),n.writeUint32LE(L+v|0,e,56),n.writeUint32LE(x+b|0,e,60)}function o(e,t,r,n,o){if(void 0===o&&(o=0),32!==e.length)throw new Error("ChaCha: key size must be 32 bytes");if(n.length>>=8,t++;if(n>0)throw new Error("ChaCha: counter overflow")}t.streamXOR=o,t.stream=function(e,t,r,n){return void 0===n&&(n=0),i.wipe(r),o(e,t,r,r,n)}},3642:(e,t,r)=>{"use strict";var n=r(8284),i=r(5629),s=r(9116),o=r(6232),a=r(8770);t.Cv=32,t.WH=12,t.pg=16;var c=new Uint8Array(16),l=function(){function e(e){if(this.nonceLength=t.WH,this.tagLength=t.pg,e.length!==t.Cv)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return e.prototype.seal=function(e,t,r,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var o=new Uint8Array(16);o.set(e,o.length-e.length);var a=new Uint8Array(32);n.stream(this._key,o,a,4);var c,l=t.length+this.tagLength;if(i){if(i.length!==l)throw new Error("ChaCha20Poly1305: incorrect destination length");c=i}else c=new Uint8Array(l);return n.streamXOR(this._key,o,t,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),a,c.subarray(0,c.length-this.tagLength),r),s.wipe(o),c},e.prototype.open=function(e,t,r,i){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&a.update(c.subarray(n.length%16))),a.update(r),r.length%16>0&&a.update(c.subarray(r.length%16));var l=new Uint8Array(8);n&&o.writeUint64LE(n.length,l),a.update(l),o.writeUint64LE(r.length,l),a.update(l);for(var u=a.digest(),h=0;h{"use strict";function r(e,t){if(e.length!==t.length)return 0;for(var r=0,n=0;n>>8}Object.defineProperty(t,"__esModule",{value:!0}),t.select=function(e,t,r){return~(e-1)&t|e-1&r},t.lessOrEqual=function(e,t){return(0|e)-(0|t)-1>>>31&1},t.compare=r,t.equal=function(e,t){return 0!==e.length&&0!==t.length&&0!==r(e,t)}},1412:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isSerializableHash=function(e){return"undefined"!==typeof e.saveState&&"undefined"!==typeof e.restoreState&&"undefined"!==typeof e.cleanSavedState}},2497:(e,t,r)=>{"use strict";var n=r(5499),i=r(9116),s=function(){function e(e,t,r,i){void 0===r&&(r=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=n.hmac(this._hash,r,t);this._hmac=new n.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return e.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(0===e)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},e.prototype.expand=function(e){for(var t=new Uint8Array(e),r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(1412),i=r(8770),s=r(9116),o=function(){function e(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var r=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(r).clean():r.set(t);for(var i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.mul=Math.imul||function(e,t){var r=65535&e,n=65535&t;return r*n+((e>>>16&65535)*n+r*(t>>>16&65535)<<16>>>0)|0},t.add=function(e,t){return e+t|0},t.sub=function(e,t){return e-t|0},t.rotl=function(e,t){return e<>>32-t},t.rotr=function(e,t){return e<<32-t|e>>>t},t.isInteger=Number.isInteger||function(e){return"number"===typeof e&&isFinite(e)&&Math.floor(e)===e},t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(e){return t.isInteger(e)&&e>=-t.MAX_SAFE_INTEGER&&e<=t.MAX_SAFE_INTEGER}},5629:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(8770),i=r(9116);t.DIGEST_LENGTH=16;var s=function(){function e(e){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=e[0]|e[1]<<8;this._r[0]=8191&r;var n=e[2]|e[3]<<8;this._r[1]=8191&(r>>>13|n<<3);var i=e[4]|e[5]<<8;this._r[2]=7939&(n>>>10|i<<6);var s=e[6]|e[7]<<8;this._r[3]=8191&(i>>>7|s<<9);var o=e[8]|e[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var c=e[12]|e[13]<<8;this._r[7]=8065&(a>>>11|c<<5);var l=e[14]|e[15]<<8;this._r[8]=8191&(c>>>8|l<<8),this._r[9]=l>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return e.prototype._blocks=function(e,t,r){for(var n=this._fin?0:2048,i=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],c=this._h[4],l=this._h[5],u=this._h[6],h=this._h[7],d=this._h[8],f=this._h[9],p=this._r[0],g=this._r[1],y=this._r[2],m=this._r[3],v=this._r[4],b=this._r[5],w=this._r[6],E=this._r[7],_=this._r[8],S=this._r[9];r>=16;){var I=e[t+0]|e[t+1]<<8;i+=8191&I;var C=e[t+2]|e[t+3]<<8;s+=8191&(I>>>13|C<<3);var A=e[t+4]|e[t+5]<<8;o+=8191&(C>>>10|A<<6);var T=e[t+6]|e[t+7]<<8;a+=8191&(A>>>7|T<<9);var k=e[t+8]|e[t+9]<<8;c+=8191&(T>>>4|k<<12),l+=k>>>1&8191;var R=e[t+10]|e[t+11]<<8;u+=8191&(k>>>14|R<<2);var P=e[t+12]|e[t+13]<<8;h+=8191&(R>>>11|P<<5);var D=e[t+14]|e[t+15]<<8,N=0,O=N;O+=i*p,O+=s*(5*S),O+=o*(5*_),O+=a*(5*E),N=(O+=c*(5*w))>>>13,O&=8191,O+=l*(5*b),O+=u*(5*v),O+=h*(5*m),O+=(d+=8191&(P>>>8|D<<8))*(5*y);var L=N+=(O+=(f+=D>>>5|n)*(5*g))>>>13;L+=i*g,L+=s*p,L+=o*(5*S),L+=a*(5*_),N=(L+=c*(5*E))>>>13,L&=8191,L+=l*(5*w),L+=u*(5*b),L+=h*(5*v),L+=d*(5*m),N+=(L+=f*(5*y))>>>13,L&=8191;var x=N;x+=i*y,x+=s*g,x+=o*p,x+=a*(5*S),N=(x+=c*(5*_))>>>13,x&=8191,x+=l*(5*E),x+=u*(5*w),x+=h*(5*b),x+=d*(5*v);var B=N+=(x+=f*(5*m))>>>13;B+=i*m,B+=s*y,B+=o*g,B+=a*p,N=(B+=c*(5*S))>>>13,B&=8191,B+=l*(5*_),B+=u*(5*E),B+=h*(5*w),B+=d*(5*b);var M=N+=(B+=f*(5*v))>>>13;M+=i*v,M+=s*m,M+=o*y,M+=a*g,N=(M+=c*p)>>>13,M&=8191,M+=l*(5*S),M+=u*(5*_),M+=h*(5*E),M+=d*(5*w);var U=N+=(M+=f*(5*b))>>>13;U+=i*b,U+=s*v,U+=o*m,U+=a*y,N=(U+=c*g)>>>13,U&=8191,U+=l*p,U+=u*(5*S),U+=h*(5*_),U+=d*(5*E);var F=N+=(U+=f*(5*w))>>>13;F+=i*w,F+=s*b,F+=o*v,F+=a*m,N=(F+=c*y)>>>13,F&=8191,F+=l*g,F+=u*p,F+=h*(5*S),F+=d*(5*_);var V=N+=(F+=f*(5*E))>>>13;V+=i*E,V+=s*w,V+=o*b,V+=a*v,N=(V+=c*m)>>>13,V&=8191,V+=l*y,V+=u*g,V+=h*p,V+=d*(5*S);var j=N+=(V+=f*(5*_))>>>13;j+=i*_,j+=s*E,j+=o*w,j+=a*b,N=(j+=c*v)>>>13,j&=8191,j+=l*m,j+=u*y,j+=h*g,j+=d*p;var K=N+=(j+=f*(5*S))>>>13;K+=i*S,K+=s*_,K+=o*E,K+=a*w,N=(K+=c*b)>>>13,K&=8191,K+=l*v,K+=u*m,K+=h*y,K+=d*g,i=O=8191&(N=(N=((N+=(K+=f*p)>>>13)<<2)+N|0)+(O&=8191)|0),s=L+=N>>>=13,o=x&=8191,a=B&=8191,c=M&=8191,l=U&=8191,u=F&=8191,h=V&=8191,d=j&=8191,f=K&=8191,t+=16,r-=16}this._h[0]=i,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=c,this._h[5]=l,this._h[6]=u,this._h[7]=h,this._h[8]=d,this._h[9]=f},e.prototype.finish=function(e,t){void 0===t&&(t=0);var r,n,i,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,n=(1^r)-1,s=0;s<10;s++)o[s]&=n;for(n=~n,s=0;s<10;s++)this._h[s]=this._h[s]&n|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),i=this._h[0]+this._pad[0],this._h[0]=65535&i,s=1;s<8;s++)i=(this._h[s]+this._pad[s]|0)+(i>>>16)|0,this._h[s]=65535&i;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},e.prototype.update=function(e){var t,r=0,n=e.length;if(this._leftover){(t=16-this._leftover)>n&&(t=n);for(var i=0;i=16&&(t=n-n%16,this._blocks(e,r,t),r+=t,n-=t),n){for(i=0;i{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.randomStringForEntropy=t.randomString=t.randomUint32=t.randomBytes=t.defaultRandomSource=void 0;const n=r(933),i=r(6232),s=r(9116);function o(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.defaultRandomSource;return r.randomBytes(e)}t.defaultRandomSource=new n.SystemRandomSource,t.randomBytes=o,t.randomUint32=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t.defaultRandomSource;const r=o(4,e),n=(0,i.readUint32LE)(r);return(0,s.wipe)(r),n};const a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function c(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.defaultRandomSource;if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let i="";const c=r.length,l=256-256%c;for(;e>0;){const t=o(Math.ceil(256*e/l),n);for(let n=0;n0;n++){const s=t[n];s1&&void 0!==arguments[1]?arguments[1]:a,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.defaultRandomSource;const i=Math.ceil(e/(Math.log(r.length)/Math.LN2));return c(i,r,n)}},8136:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BrowserRandomSource=void 0;t.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e="undefined"!==typeof self?self.crypto||self.msCrypto:null;e&&void 0!==e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const t=new Uint8Array(e);for(let r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NodeRandomSource=void 0;const n=r(9116);t.NodeRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;{const e=r(5883);e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const r=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SystemRandomSource=void 0;const n=r(8136),i=r(8188);t.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new n.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new i.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}},4888:(e,t,r)=>{"use strict";var n=r(6232),i=r(9116);t.k=32,t.cn=64;var s=function(){function e(){this.digestLength=t.k,this.blockSize=t.cn,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return e.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},e.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},e.prototype.clean=function(){i.wipe(this._buffer),i.wipe(this._temp),this.reset()},e.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[r++],t--;this._bufferLength===this.blockSize&&(a(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(r=a(this._temp,this._state,e,r,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[r++],t--;return this},e.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,r=this._bufferLength,i=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[r]=128;for(var c=r+1;c0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},e.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},e.prototype.cleanSavedState=function(e){i.wipe(e.state),e.buffer&&i.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},e}();t.mE=s;var o=new Int32Array([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]);function a(e,t,r,i,s){for(;s>=64;){for(var a=t[0],c=t[1],l=t[2],u=t[3],h=t[4],d=t[5],f=t[6],p=t[7],g=0;g<16;g++){var y=i+4*g;e[g]=n.readUint32BE(r,y)}for(g=16;g<64;g++){var m=e[g-2],v=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[g-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3;e[g]=(v+e[g-7]|0)+(b+e[g-16]|0)}for(g=0;g<64;g++){v=(((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(h&d^~h&f)|0)+(p+(o[g]+e[g]|0)|0)|0,b=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&c^a&l^c&l)|0;p=f,f=d,d=h,h=u+v|0,u=l,l=c,c=a,a=v+b|0}t[0]+=a,t[1]+=c,t[2]+=l,t[3]+=u,t[4]+=h,t[5]+=d,t[6]+=f,t[7]+=p,i+=64,s-=64}return i}t.vp=function(e){var t=new s;t.update(e);var r=t.digest();return t.clean(),r}},9116:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.wipe=function(e){for(var t=0;t{"use strict";t.gi=t.Au=t._w=t.KS=t.kz=void 0;const n=r(6271),i=r(9116);function s(e){const t=new Float64Array(16);if(e)for(let r=0;r=0;--s){const e=r[s>>>3]>>>(7&s)&1;l(i,o,e),l(p,g,e),u(y,i,p),h(i,i,p),u(p,o,g),h(o,o,g),f(g,y),f(m,i),d(i,p,i),d(p,o,y),u(y,i,p),h(i,i,p),f(o,i),h(p,g,m),d(i,p,a),u(i,i,g),d(p,p,i),d(i,g,m),d(g,o,n),f(o,y),l(i,o,e),l(p,g,e)}for(let s=0;s<16;s++)n[s+16]=i[s],n[s+32]=p[s],n[s+48]=o[s],n[s+64]=g[s];const v=n.subarray(32),b=n.subarray(16);!function(e,t){const r=s();for(let n=0;n<16;n++)r[n]=t[n];for(let n=253;n>=0;n--)f(r,r),2!==n&&4!==n&&d(r,r,t);for(let n=0;n<16;n++)e[n]=r[n]}(v,v),d(b,b,v);const w=new Uint8Array(32);return function(e,t){const r=s(),n=s();for(let i=0;i<16;i++)n[i]=t[i];c(n),c(n),c(n);for(let i=0;i<2;i++){r[0]=n[0]-65517;for(let t=1;t<15;t++)r[t]=n[t]-65535-(r[t-1]>>16&1),r[t-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,l(n,r,1-e)}for(let i=0;i<16;i++)e[2*i]=255&n[i],e[2*i+1]=n[i]>>8}(w,b),w}function g(e){return p(e,o)}function y(e){if(e.length!==t.KS)throw new Error("x25519: seed must be ".concat(t.KS," bytes"));const r=new Uint8Array(e);return{publicKey:g(r),secretKey:r}}t._w=y,t.Au=function(e){const t=(0,n.randomBytes)(32,e),r=y(t);return(0,i.wipe)(t),r},t.gi=function(e,r){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e.length!==t.kz)throw new Error("X25519: incorrect secret key length");if(r.length!==t.kz)throw new Error("X25519: incorrect public key length");const i=p(e,r);if(n){let e=0;for(let t=0;t{function t(e){const t=new globalThis.AbortController;function r(){t.abort();for(const t of e)t&&t.removeEventListener&&t.removeEventListener("abort",r)}for(const n of e)if(n&&n.addEventListener){if(n.aborted){r();break}n.addEventListener("abort",r)}return t.signal}e.exports=t,e.exports.anySignal=t},312:e=>{var t=1e3,r=60*t,n=60*r,i=24*n,s=7*i,o=365.25*i;function a(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*i;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var s=Math.abs(e);if(s>=i)return a(e,s,i,"day");if(s>=n)return a(e,s,n,"hour");if(s>=r)return a(e,s,r,"minute");if(s>=t)return a(e,s,t,"second");return e+" ms"}(e):function(e){var s=Math.abs(e);if(s>=i)return Math.round(e/i)+"d";if(s>=n)return Math.round(e/n)+"h";if(s>=r)return Math.round(e/r)+"m";if(s>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},8392:(e,t,r)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(r){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(r){}!e&&"undefined"!==typeof process&&"env"in process&&(e={NODE_ENV:"production",PUBLIC_URL:"/relay-reactjs-chat",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DEBUG);return e},t.useColors=function(){if("undefined"!==typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!==typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!==typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=r(8472)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},8472:(e,t,r)=>{e.exports=function(e){function t(e){let r,i,s,o=null;function a(){for(var e=arguments.length,n=new Array(e),i=0;i{if("%%"===e)return"%";l++;const i=t.formatters[r];if("function"===typeof i){const t=n[l];e=i.call(s,t),n.splice(l,1),l--}return e})),t.formatArgs.call(s,n);const u=s.log||t.log;u.apply(s,n)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"===typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+("undefined"===typeof r?":":r)+e);return n.log=this.log,n}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"===typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t{"use strict";function t(e,t){t=t||{};this._head=0,this._tail=0,this._capacity=t.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(e)&&this._fromArray(e)}t.prototype.peekAt=function(e){var t=e;if(t===(0|t)){var r=this.size();if(!(t>=r||t<-r))return t<0&&(t+=r),t=this._head+t&this._capacityMask,this._list[t]}},t.prototype.get=function(e){return this.peekAt(e)},t.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},t.prototype.peekFront=function(){return this.peek()},t.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(t.prototype,"length",{get:function(){return this.size()}}),t.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},t.prototype.push=function(e){if(void 0===e)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&e<=t>>>2&&this._shrinkArray(),r}},t.prototype.removeOne=function(e){var t=e;if(t===(0|t)&&this._head!==this._tail){var r=this.size(),n=this._list.length;if(!(t>=r||t<-r)){t<0&&(t+=r),t=this._head+t&this._capacityMask;var i,s=this._list[t];if(e0;i--)this._list[t]=this._list[t=t-1+n&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(i=r-1-e;i>0;i--)this._list[t]=this._list[t=t+1+n&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+n&this._capacityMask}return s}}},t.prototype.remove=function(e,t){var r,n=e,i=t;if(n===(0|n)&&this._head!==this._tail){var s=this.size(),o=this._list.length;if(!(n>=s||n<-s||t<1)){if(n<0&&(n+=s),1===t||!t)return(r=new Array(1))[0]=this.removeOne(n),r;if(0===n&&n+t>=s)return r=this.toArray(),this.clear(),r;var a;for(n+t>s&&(t=s-n),r=new Array(t),a=0;a0;a--)this._list[n=n+1+o&this._capacityMask]=void 0;return r}if(0===e){for(this._head=this._head+t+o&this._capacityMask,a=t-1;a>0;a--)this._list[n=n+1+o&this._capacityMask]=void 0;return r}if(n0;a--)this.unshift(this._list[n=n-1+o&this._capacityMask]);for(n=this._head-1+o&this._capacityMask;i>0;)this._list[n=n-1+o&this._capacityMask]=void 0,i--;e<0&&(this._tail=n)}else{for(this._tail=n,n=n+t+o&this._capacityMask,a=s-(t+e);a>0;a--)this.push(this._list[n++]);for(n=this._tail;i>0;)this._list[n=n+1+o&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=o>>>2&&this._shrinkArray(),r}}},t.prototype.splice=function(e,t){var r=e;if(r===(0|r)){var n=this.size();if(r<0&&(r+=n),!(r>n)){if(arguments.length>2){var i,s,o,a=arguments.length,c=this._list.length,l=2;if(!n||r0&&(this._head=this._head+r+c&this._capacityMask)):(o=this.remove(r,t),this._head=this._head+r+c&this._capacityMask);a>l;)this.unshift(arguments[--a]);for(i=r;i>0;i--)this.unshift(s[i-1])}else{var u=(s=new Array(n-(r+t))).length;for(i=0;ithis._tail){for(t=this._head;t>>=1,this._capacityMask>>>=1},e.exports=t},7963:e=>{"use strict";function t(e,t){for(const r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}e.exports=function(e,r,n){if(!e||"string"===typeof e)throw new TypeError("Please pass an Error to err-code");n||(n={}),"object"===typeof r&&(n=r,r=""),r&&(n.code=r);try{return t(e,n)}catch(i){n.message=e.message,n.stack=e.stack;const r=function(){};r.prototype=Object.create(Object.getPrototypeOf(e));return t(new r,n)}}},3634:(e,t,r)=>{"use strict";const n=r(5413);t.zN=n.EventIterator,n.EventIterator},5413:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;const t={value:e,done:!1};if(this.pullQueue.length){const e=this.pullQueue.shift();e&&e.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn("EventIterator queue reached ".concat(this.pushQueue.length," items")))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const t of this.pullQueue)t.reject(e);this.pullQueue.length=0}else{const t=Promise.reject(e);t.catch((()=>{})),this.pushQueue.push(t)}}remove(){Promise.resolve().then((()=>{this.removeCallback&&this.removeCallback()}))}[Symbol.asyncIterator](){return{next:e=>{const t=this.pushQueue.shift();return t?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise(((e,t)=>{this.pullQueue.push({resolve:e,reject:t})}))},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class n{constructor(e){let{highWaterMark:t=100,lowWaterMark:n=1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new r;i.highWaterMark=t,i.lowWaterMark=n,i.removeCallback=e({push:e=>i.push(e),stop:()=>i.stop(),fail:e=>i.fail(e),on:(e,t)=>{i.eventHandlers[e]=t}})||(()=>{}),this[Symbol.asyncIterator]=()=>i[Symbol.asyncIterator](),Object.freeze(this)}}t.EventIterator=n,t.default=n},7143:e=>{"use strict";var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,o){if("function"!==typeof n)throw new TypeError("The listener must be a function");var a=new i(n,s||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i{"use strict";var t,r="object"===typeof Reflect?Reflect:null,n=r&&"function"===typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"===typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}e.exports=s,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,s),n(r)}function s(){"function"===typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}g(e,t,s,{once:!0}),"error"!==t&&function(e,t,r){"function"===typeof e.on&&g(e,"error",t,r)}(e,i,{once:!0})}))},s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var o=10;function a(e){if("function"!==typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?s.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var i,s,o,l;if(a(r),void 0===(s=e._events)?(s=e._events=Object.create(null),e._eventsCount=0):(void 0!==s.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),o=s[t]),void 0===o)o=s[t]=r,++e._eventsCount;else if("function"===typeof o?o=s[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),(i=c(e))>0&&o.length>i&&!o.warned){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,l=u,console&&console.warn&&console.warn(l)}return e}function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=u.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"===typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var c=s[e];if(void 0===c)return!1;if("function"===typeof c)n(c,this,t);else{var l=c.length,u=p(c,l);for(r=0;r=0;s--)if(r[s]===t||r[s].listener===t){o=r[s].listener,i=s;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return d(this,e,!0)},s.prototype.rawListeners=function(e){return d(this,e,!1)},s.listenerCount=function(e,t){return"function"===typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},s.prototype.listenerCount=f,s.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},1167:e=>{e.exports=class{constructor(e){if(!(e>0)||0!==(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return void 0===this.buffer[this.btm]}}},5125:(e,t,r)=>{const n=r(1167);e.exports=class{constructor(e){this.hwm=e||16,this.head=new n(this.hwm),this.tail=this.head}push(e){if(!this.head.push(e)){const t=this.head;this.head=t.next=new n(2*this.head.buffer.length),this.head.push(e)}}shift(){const e=this.tail.shift();if(void 0===e&&this.tail.next){const e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}peek(){return this.tail.peek()}isEmpty(){return this.head.isEmpty()}}},4737:e=>{e.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function i(i,s){r[i]=s,++t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==n[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==n[e]&&(n[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(i(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:i(e,t)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},8974:e=>{"use strict";const t="[a-fA-F\\d:]",r=e=>e&&e.includeBoundaries?"(?:(?<=\\s|^)(?=".concat(t,")|(?<=").concat(t,")(?=\\s|$))"):"",n="(?: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}",i="[a-fA-F\\d]{1,4}",s="\n(?:\n(?:".concat(i,":){7}(?:").concat(i,"|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8\n(?:").concat(i,":){6}(?:").concat(n,"|:").concat(i,"|:)| // 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\n(?:").concat(i,":){5}(?::").concat(n,"|(?::").concat(i,"){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\n(?:").concat(i,":){4}(?:(?::").concat(i,"){0,1}:").concat(n,"|(?::").concat(i,"){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\n(?:").concat(i,":){3}(?:(?::").concat(i,"){0,2}:").concat(n,"|(?::").concat(i,"){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\n(?:").concat(i,":){2}(?:(?::").concat(i,"){0,3}:").concat(n,"|(?::").concat(i,"){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4\n(?:").concat(i,":){1}(?:(?::").concat(i,"){0,4}:").concat(n,"|(?::").concat(i,"){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4\n(?::(?:(?::").concat(i,"){0,5}:").concat(n,"|(?::").concat(i,"){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4\n)(?:%[0-9a-zA-Z]{1,})? // %eth0 %1\n").replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),o=new RegExp("(?:^".concat(n,"$)|(?:^").concat(s,"$)")),a=new RegExp("^".concat(n,"$")),c=new RegExp("^".concat(s,"$")),l=e=>e&&e.exact?o:new RegExp("(?:".concat(r(e)).concat(n).concat(r(e),")|(?:").concat(r(e)).concat(s).concat(r(e),")"),"g");l.v4=e=>e&&e.exact?a:new RegExp("".concat(r(e)).concat(n).concat(r(e)),"g"),l.v6=e=>e&&e.exact?c:new RegExp("".concat(r(e)).concat(s).concat(r(e)),"g"),e.exports=l},7201:function(e){!function(t){"use strict";const r="(0?\\d+|0x[a-f0-9]+)",n={fourOctet:new RegExp("^".concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"$"),"i"),threeOctet:new RegExp("^".concat(r,"\\.").concat(r,"\\.").concat(r,"$"),"i"),twoOctet:new RegExp("^".concat(r,"\\.").concat(r,"$"),"i"),longValue:new RegExp("^".concat(r,"$"),"i")},i=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",a="(?:[0-9a-f]+::?)+",c={zoneIndex:new RegExp(o,"i"),native:new RegExp("^(::)?(".concat(a,")?([0-9a-f]+)?(::)?(").concat(o,")?$"),"i"),deprecatedTransitional:new RegExp("^(?:::)(".concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"(").concat(o,")?)$"),"i"),transitional:new RegExp("^((?:".concat(a,")|(?:::)(?:").concat(a,")?)").concat(r,"\\.").concat(r,"\\.").concat(r,"\\.").concat(r,"(").concat(o,")?$"),"i")};function l(e,t){if(e.indexOf("::")!==e.lastIndexOf("::"))return null;let r,n,i=0,s=-1,o=(e.match(c.zoneIndex)||[])[0];for(o&&(o=o.substring(1),e=e.replace(/%.+$/,""));(s=e.indexOf(":",s+1))>=0;)i++;if("::"===e.substr(0,2)&&i--,"::"===e.substr(-2,2)&&i--,i>t)return null;for(n=t-i,r=":";n--;)r+="0:";return":"===(e=e.replace("::",r))[0]&&(e=e.slice(1)),":"===e[e.length-1]&&(e=e.slice(0,-1)),{parts:t=function(){const t=e.split(":"),r=[];for(let e=0;e0;){if(i=r-n,i<0&&(i=0),e[s]>>i!==t[s]>>i)return!1;n-=r,s+=1}return!0}function h(e){if(s.test(e))return parseInt(e,16);if("0"===e[0]&&!isNaN(parseInt(e[1],10))){if(i.test(e))return parseInt(e,8);throw new Error("ipaddr: cannot parse ".concat(e," as octal"))}return parseInt(e,10)}function d(e,t){for(;e.length=0;n-=1){if(i=this.octets[n],!(i in r))return null;if(s=r[i],t&&0!==s)return null;8!==s&&(t=!0),e+=s}return 32-e},e.prototype.range=function(){return f.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){return this.octets.slice(0)},e.prototype.toIPv4MappedAddress=function(){return f.IPv6.parse("::ffff:".concat(this.toString()))},e.prototype.toNormalizedString=function(){return this.toString()},e.prototype.toString=function(){return this.octets.join(".")},e}(),f.IPv4.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),n=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[];let s=0;for(;s<4;)i.push(parseInt(r[s],10)|255^parseInt(n[s],10)),s++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},f.IPv4.isIPv4=function(e){return null!==this.parser(e)},f.IPv4.isValid=function(e){try{return new this(this.parser(e)),!0}catch(t){return!1}},f.IPv4.isValidFourPartDecimal=function(e){return!(!f.IPv4.isValid(e)||!e.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},f.IPv4.networkAddressFromCIDR=function(e){let t,r,n,i,s;try{for(t=this.parseCIDR(e),n=t[0].toByteArray(),s=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],r=0;r<4;)i.push(parseInt(n[r],10)&parseInt(s[r],10)),r++;return new this(i)}catch(o){throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},f.IPv4.parse=function(e){const t=this.parser(e);if(null===t)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(t)},f.IPv4.parseCIDR=function(e){let t;if(t=e.match(/^(.+)\/(\d+)$/)){const e=parseInt(t[2]);if(e>=0&&e<=32){const r=[this.parse(t[1]),e];return Object.defineProperty(r,"toString",{value:function(){return this.join("/")}}),r}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},f.IPv4.parser=function(e){let t,r,i;if(t=e.match(n.fourOctet))return function(){const e=t.slice(1,6),n=[];for(let t=0;t4294967295||i<0)throw new Error("ipaddr: address outside defined range");return function(){const e=[];let t;for(t=0;t<=24;t+=8)e.push(i>>t&255);return e}().reverse()}return(t=e.match(n.twoOctet))?function(){const e=t.slice(1,4),r=[];if(i=h(e[1]),i>16777215||i<0)throw new Error("ipaddr: address outside defined range");return r.push(h(e[0])),r.push(i>>16&255),r.push(i>>8&255),r.push(255&i),r}():(t=e.match(n.threeOctet))?function(){const e=t.slice(1,5),r=[];if(i=h(e[2]),i>65535||i<0)throw new Error("ipaddr: address outside defined range");return r.push(h(e[0])),r.push(h(e[1])),r.push(i>>8&255),r.push(255&i),r}():null},f.IPv4.subnetMaskFromPrefixLength=function(e){if((e=parseInt(e))<0||e>32)throw new Error("ipaddr: invalid IPv4 prefix length");const t=[0,0,0,0];let r=0;const n=Math.floor(e/8);for(;r=0;s-=1){if(n=this.parts[s],!(n in r))return null;if(i=r[n],t&&0!==i)return null;16!==i&&(t=!0),e+=i}return 128-e},e.prototype.range=function(){return f.subnetMatch(this,this.SpecialRanges)},e.prototype.toByteArray=function(){let e;const t=[],r=this.parts;for(let n=0;n>8),t.push(255&e);return t},e.prototype.toFixedLengthString=function(){const e=function(){const e=[];for(let t=0;t>8,255&t,r>>8,255&r])},e.prototype.toNormalizedString=function(){const e=function(){const e=[];for(let t=0;ti&&(n=r.index,i=r[0].length);return i<0?t:"".concat(t.substring(0,n),"::").concat(t.substring(n+i))},e.prototype.toString=function(){return this.toNormalizedString().replace(/((^|:)(0(:|$))+)/,"::")},e}(),f.IPv6.broadcastAddressFromCIDR=function(e){try{const t=this.parseCIDR(e),r=t[0].toByteArray(),n=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[];let s=0;for(;s<16;)i.push(parseInt(r[s],10)|255^parseInt(n[s],10)),s++;return new this(i)}catch(t){throw new Error("ipaddr: the address does not have IPv6 CIDR format (".concat(t,")"))}},f.IPv6.isIPv6=function(e){return null!==this.parser(e)},f.IPv6.isValid=function(e){if("string"===typeof e&&-1===e.indexOf(":"))return!1;try{const t=this.parser(e);return new this(t.parts,t.zoneId),!0}catch(t){return!1}},f.IPv6.networkAddressFromCIDR=function(e){let t,r,n,i,s;try{for(t=this.parseCIDR(e),n=t[0].toByteArray(),s=this.subnetMaskFromPrefixLength(t[1]).toByteArray(),i=[],r=0;r<16;)i.push(parseInt(n[r],10)&parseInt(s[r],10)),r++;return new this(i)}catch(o){throw new Error("ipaddr: the address does not have IPv6 CIDR format (".concat(o,")"))}},f.IPv6.parse=function(e){const t=this.parser(e);if(null===t.parts)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(t.parts,t.zoneId)},f.IPv6.parseCIDR=function(e){let t,r,n;if((r=e.match(/^(.+)\/(\d+)$/))&&(t=parseInt(r[2]),t>=0&&t<=128))return n=[this.parse(r[1]),t],Object.defineProperty(n,"toString",{value:function(){return this.join("/")}}),n;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},f.IPv6.parser=function(e){let t,r,n,i,s,o;if(n=e.match(c.deprecatedTransitional))return this.parser("::ffff:".concat(n[1]));if(c.native.test(e))return l(e,8);if((n=e.match(c.transitional))&&(o=n[6]||"",t=l(n[1].slice(0,-1)+o,6),t.parts)){for(s=[parseInt(n[2]),parseInt(n[3]),parseInt(n[4]),parseInt(n[5])],r=0;r128)throw new Error("ipaddr: invalid IPv6 prefix length");const t=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];let r=0;const n=Math.floor(e/8);for(;r{e.exports=function(){return"undefined"!==typeof window&&"object"===typeof window.process&&"renderer"===window.process.type||(!("undefined"===typeof process||"object"!==typeof process.versions||!process.versions.electron)||"object"===typeof navigator&&"string"===typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}},887:e=>{"use strict";e.exports=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}},6791:(e,t,r)=>{"use strict";const{URLWithLegacySupport:n,format:i,URLSearchParams:s,defaultBase:o}=r(5732),a=r(9640);e.exports={URL:n,URLSearchParams:s,format:i,relative:a,defaultBase:o}},9640:(e,t,r)=>{"use strict";const{URLWithLegacySupport:n,format:i}=r(5732);e.exports=function(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=arguments.length>3?arguments[3]:void 0,a=r.protocol?r.protocol.replace(":",""):"http";a=(s[a]||o||a)+":";try{t=new n(e)}catch(l){t={}}const c=Object.assign({},r,{protocol:a||t.protocol,host:r.host||t.host});return new n(e,i(c)).toString()}},5732:e=>{"use strict";const t="undefined"!==typeof navigator&&"ReactNative"===navigator.product;const r=self.URL,n=t?"http://localhost":self.location?self.location.protocol+"//"+self.location.host:"";e.exports={URLWithLegacySupport:class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n;this.super=new r(e,t),this.path=this.pathname+this.search,this.auth=this.username&&this.password?this.username+":"+this.password:null,this.query=this.search&&this.search.startsWith("?")?this.search.slice(1):null}get hash(){return this.super.hash}get host(){return this.super.host}get hostname(){return this.super.hostname}get href(){return this.super.href}get origin(){return this.super.origin}get password(){return this.super.password}get pathname(){return this.super.pathname}get port(){return this.super.port}get protocol(){return this.super.protocol}get search(){return this.super.search}get searchParams(){return this.super.searchParams}get username(){return this.super.username}set hash(e){this.super.hash=e}set host(e){this.super.host=e}set hostname(e){this.super.hostname=e}set href(e){this.super.href=e}set password(e){this.super.password=e}set pathname(e){this.super.pathname=e}set port(e){this.super.port=e}set protocol(e){this.super.protocol=e}set search(e){this.super.search=e}set username(e){this.super.username=e}static createObjectURL(e){return r.createObjectURL(e)}static revokeObjectURL(e){r.revokeObjectURL(e)}toJSON(){return this.super.toJSON()}toString(){return this.super.toString()}format(){return this.toString()}},URLSearchParams:self.URLSearchParams,defaultBase:n,format:function(e){if("string"===typeof e){return new r(e).toString()}if(!(e instanceof r)){const t=e.username&&e.password?"".concat(e.username,":").concat(e.password,"@"):"",r=e.auth?e.auth+"@":"",n=e.port?":"+e.port:"",i=e.protocol?e.protocol+"//":"",s=e.host||"",o=e.hostname||"",a=e.search||(e.query?"?"+e.query:""),c=e.hash||"",l=e.pathname||"",u=e.path||l+a;return"".concat(i).concat(t||r).concat(s||o+n).concat(u).concat(c)}}}},464:e=>{"use strict";e.exports=async e=>{const t=[];for await(const r of e)t.push(r);return t}},9272:e=>{"use strict";e.exports=async e=>{for await(const t of e);}},2393:e=>{"use strict";e.exports=async function*(e,t){for await(const r of e)await t(r)&&(yield r)}},4744:e=>{"use strict";e.exports=async e=>{for await(const t of e)return t}},1309:e=>{"use strict";e.exports=async function*(e,t){for await(const r of e)await t(r),yield r}},7889:e=>{"use strict";e.exports=async function*(e,t){for await(const r of e)yield t(r)}},6155:(e,t,r)=>{"use strict";const n=r(9202);e.exports=async function*(){for(var e=arguments.length,t=new Array(e),r=0;r{try{await Promise.all(t.map((async e=>{for await(const t of e)i.push(t)}))),i.end()}catch(e){i.end(e)}}),0),yield*i}},9202:(e,t,r)=>{const n=r(5125);e.exports=e=>{let t;"function"===typeof(e=e||{})?(t=e,e={}):t=e.onEnd;let r,i,s,o=new n;const a=e=>i?i(e):(o.push(e),r),c=e=>s?r:a({done:!1,value:e}),l=e=>s?r:(s=!0,e?(e=>(o=new n,i?i({error:e}):(o.push({error:e}),r)))(e):a({done:!0}));if(r={[Symbol.asyncIterator](){return this},next:()=>{if(!o.isEmpty()){if(e.writev){let e;const t=[];for(;!o.isEmpty();){if(e=o.shift(),e.error)throw e.error;t.push(e.value)}return{done:e.done,value:t}}const t=o.shift();if(t.error)throw t.error;return t}return s?{done:!0}:new Promise(((t,n)=>{i=s=>(i=null,s.error?n(s.error):e.writev&&!s.done?t({done:s.done,value:[s.value]}):t(s),r)}))},return:()=>(o=new n,l(),{done:!0}),throw:e=>(l(e),{done:!0}),push:c,end:l},!t)return r;const u=r;return r={[Symbol.asyncIterator](){return this},next:()=>u.next(),throw:e=>(u.throw(e),t&&(t(e),t=null),{done:!0}),return:()=>(u.return(),t&&(t(),t=null),{done:!0}),push:c,end:e=>(u.end(e),t&&(t(e),t=null),r)},r}},2035:(e,t,r)=>{"use strict";const n=r(464);e.exports=async function*(e,t){const r=await n(e);yield*r.sort(t)}},5959:e=>{"use strict";e.exports=async function*(e,t){let r=0;if(!(t<1))for await(const n of e)if(yield n,r++,r===t)return}},7898:(e,t,r)=>{var n;!function(){"use strict";var i="input is invalid type",s="object"===typeof window,o=s?window:{};o.JS_SHA3_NO_WINDOW&&(s=!1);var a=!s&&"object"===typeof self;!o.JS_SHA3_NO_NODE_JS&&"object"===typeof process&&process.versions&&process.versions.node?o=r.g:a&&(o=self);var c=!o.JS_SHA3_NO_COMMON_JS&&e.exports,l=r.amdO,u=!o.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!==typeof ArrayBuffer,h="0123456789abcdef".split(""),d=[4,1024,262144,67108864],f=[0,8,16,24],p=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],y=[128,256],m=["hex","buffer","arrayBuffer","array","digest"],v={128:168,256:136};!o.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)}),!u||!o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(e){return"object"===typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer});for(var b=function(e,t,r){return function(n){return new L(e,t,e).update(n)[r]()}},w=function(e,t,r){return function(n,i){return new L(e,t,i).update(n)[r]()}},E=function(e,t,r){return function(t,n,i,s){return A["cshake"+e].update(t,n,i,s)[r]()}},_=function(e,t,r){return function(t,n,i,s){return A["kmac"+e].update(t,n,i,s)[r]()}},S=function(e,t,r,n){for(var i=0;i>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function x(e,t,r){L.call(this,e,t,r)}L.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(i);if(null===e)throw new Error(i);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!u||!ArrayBuffer.isView(e)))throw new Error(i);t=!0}for(var n,s,o=this.blocks,a=this.byteCount,c=e.length,l=this.blockCount,h=0,d=this.s;h>2]|=e[h]<>2]|=s<>2]|=(192|s>>6)<>2]|=(128|63&s)<=57344?(o[n>>2]|=(224|s>>12)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<>2]|=(240|s>>18)<>2]|=(128|s>>12&63)<>2]|=(128|s>>6&63)<>2]|=(128|63&s)<=a){for(this.start=n-a,this.block=o[l],n=0;n>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},L.prototype.encodeString=function(e){var t,r=typeof e;if("string"!==r){if("object"!==r)throw new Error(i);if(null===e)throw new Error(i);if(u&&e.constructor===ArrayBuffer)e=new Uint8Array(e);else if(!Array.isArray(e)&&(!u||!ArrayBuffer.isView(e)))throw new Error(i);t=!0}var n=0,s=e.length;if(t)n=s;else for(var o=0;o=57344?n+=3:(a=65536+((1023&a)<<10|1023&e.charCodeAt(++o)),n+=4)}return n+=this.encode(8*n),this.update(e),n},L.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+h[15&e]+h[e>>12&15]+h[e>>8&15]+h[e>>20&15]+h[e>>16&15]+h[e>>28&15]+h[e>>24&15];o%t===0&&(B(r),s=0)}return i&&(e=r[s],a+=h[e>>4&15]+h[15&e],i>1&&(a+=h[e>>12&15]+h[e>>8&15]),i>2&&(a+=h[e>>20&15]+h[e>>16&15])),a},L.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,s=0,o=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(e);o>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;a%r===0&&B(n)}return s&&(e=a<<2,t=n[o],c[e]=255&t,s>1&&(c[e+1]=t>>8&255),s>2&&(c[e+2]=t>>16&255)),c},x.prototype=new L,x.prototype.finalize=function(){return this.encode(this.outputBits,!0),L.prototype.finalize.call(this)};var B=function(e){var t,r,n,i,s,o,a,c,l,u,h,d,f,g,y,m,v,b,w,E,_,S,I,C,A,T,k,R,P,D,N,O,L,x,B,M,U,F,V,j,K,z,q,H,W,G,Q,Y,$,X,J,Z,ee,te,re,ne,ie,se,oe,ae,ce,le,ue;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],s=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],l=e[5]^e[15]^e[25]^e[35]^e[45],u=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(o<<1|a>>>31),r=(f=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|o>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|l>>>31),r=s^(l<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=o^(u<<1|h>>>31),r=a^(h<<1|u>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|f>>>31),r=l^(f<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=u^(i<<1|s>>>31),r=h^(s<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,g=e[0],y=e[1],G=e[11]<<4|e[10]>>>28,Q=e[10]<<4|e[11]>>>28,R=e[20]<<3|e[21]>>>29,P=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,x=e[2]<<1|e[3]>>>31,B=e[3]<<1|e[2]>>>31,m=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,$=e[23]<<10|e[22]>>>22,D=e[33]<<13|e[32]>>>19,N=e[32]<<13|e[33]>>>19,le=e[42]<<2|e[43]>>>30,ue=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,M=e[14]<<6|e[15]>>>26,U=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,X=e[34]<<15|e[35]>>>17,J=e[35]<<15|e[34]>>>17,O=e[45]<<29|e[44]>>>3,L=e[44]<<29|e[45]>>>3,C=e[6]<<28|e[7]>>>4,A=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,F=e[26]<<25|e[27]>>>7,V=e[27]<<25|e[26]>>>7,E=e[36]<<21|e[37]>>>11,_=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,H=e[8]<<27|e[9]>>>5,W=e[9]<<27|e[8]>>>5,T=e[18]<<20|e[19]>>>12,k=e[19]<<20|e[18]>>>12,se=e[29]<<7|e[28]>>>25,oe=e[28]<<7|e[29]>>>25,j=e[38]<<8|e[39]>>>24,K=e[39]<<8|e[38]>>>24,S=e[48]<<14|e[49]>>>18,I=e[49]<<14|e[48]>>>18,e[0]=g^~m&b,e[1]=y^~v&w,e[10]=C^~T&R,e[11]=A^~k&P,e[20]=x^~M&F,e[21]=B^~U&V,e[30]=H^~G&Y,e[31]=W^~Q&$,e[40]=te^~ne&se,e[41]=re^~ie&oe,e[2]=m^~b&E,e[3]=v^~w&_,e[12]=T^~R&D,e[13]=k^~P&N,e[22]=M^~F&j,e[23]=U^~V&K,e[32]=G^~Y&X,e[33]=Q^~$&J,e[42]=ne^~se&ae,e[43]=ie^~oe&ce,e[4]=b^~E&S,e[5]=w^~_&I,e[14]=R^~D&O,e[15]=P^~N&L,e[24]=F^~j&z,e[25]=V^~K&q,e[34]=Y^~X&Z,e[35]=$^~J&ee,e[44]=se^~ae&le,e[45]=oe^~ce&ue,e[6]=E^~S&g,e[7]=_^~I&y,e[16]=D^~O&C,e[17]=N^~L&A,e[26]=j^~z&x,e[27]=K^~q&B,e[36]=X^~Z&H,e[37]=J^~ee&W,e[46]=ae^~le&te,e[47]=ce^~ue&re,e[8]=S^~g&m,e[9]=I^~y&v,e[18]=O^~C&T,e[19]=L^~A&k,e[28]=z^~x&M,e[29]=q^~B&U,e[38]=Z^~H&G,e[39]=ee^~W&Q,e[48]=le^~te&ne,e[49]=ue^~re&ie,e[0]^=p[n],e[1]^=p[n+1]};if(c)e.exports=A;else{for(k=0;kObject.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},l=e=>{const t=[];for(const r in e)i.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)s.call(e,n)&&t.push(n)}return t};function u(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return l(e).forEach((r=>{o(t,r,u(e[r]))})),t}(e):n(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return l(e).forEach((r=>{o(t,r,u(e[r]))})),t}(e):e}const h=(e,t,r,n)=>(r.forEach((r=>{"undefined"===typeof t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?o(e,r,d(e[r],t[r],n)):o(e,r,u(t[r])))})),e);function d(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?((e,t,r)=>{let n=e.slice(0,0),s=0;return[e,t].forEach((t=>{const a=[];for(let r=0;r!a.includes(e))),r)})),n})(e,t,r):n(t)&&n(e)?h(e,t,l(t),r):u(t)}e.exports=function(){const e=d(u(c),this!==a&&this||{},c);let t={_:{}};for(var r=arguments.length,i=new Array(r),s=0;s{var t=1e3,r=60*t,n=60*r,i=24*n,s=7*i,o=365.25*i;function a(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*i;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var s=Math.abs(e);if(s>=i)return a(e,s,i,"day");if(s>=n)return a(e,s,n,"hour");if(s>=r)return a(e,s,r,"minute");if(s>=t)return a(e,s,t,"second");return e+" ms"}(e):function(e){var s=Math.abs(e);if(s>=i)return Math.round(e/i)+"d";if(s>=n)return Math.round(e/n)+"h";if(s>=r)return Math.round(e/r)+"m";if(s>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},486:e=>{"use strict";function t(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t>>24,(e&255<<16)>>>16,(65280&e)>>>8,255&e].join(".")},a=function(e){var t,n,i,s,o,a;for(t=[],i=s=0;s<=3&&0!==e.length;i=++s){if(i>0){if("."!==e[0])throw new Error("Invalid IP");e=e.substring(1)}o=(a=r(e))[0],n=a[1],e=e.substring(n),t.push(o)}if(0!==e.length)throw new Error("Invalid IP");switch(t.length){case 1:if(t[0]>4294967295)throw new Error("Invalid IP");return t[0]>>>0;case 2:if(t[0]>255||t[1]>16777215)throw new Error("Invalid IP");return(t[0]<<24|t[1])>>>0;case 3:if(t[0]>255||t[1]>255||t[2]>65535)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2])>>>0;case 4:if(t[0]>255||t[1]>255||t[2]>255||t[3]>255)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0;default:throw new Error("Invalid IP")}},i=(n=function(e){return e.charCodeAt(0)})("0"),o=n("a"),s=n("A"),r=function(e){var t,r,a,c,l;for(c=0,t=10,r="9",a=0,e.length>1&&"0"===e[a]&&("x"===e[a+1]||"X"===e[a+1]?(a+=2,t=16):"0"<=e[a+1]&&e[a+1]<="9"&&(a++,t=8,r="7")),l=a;a>>0;else{if(16!==t)break;if("a"<=e[a]&&e[a]<="f")c=c*t+(10+n(e[a])-o)>>>0;else{if(!("A"<=e[a]&&e[a]<="F"))break;c=c*t+(10+n(e[a])-s)>>>0}}if(c>4294967295)throw new Error("too large");a++}if(a===l)throw new Error("empty octet");return[c,a]},e=function(){function e(e,t){var r,n,i;if("string"!==typeof e)throw new Error("Missing `net' parameter");if(t||(i=e.split("/",2),e=i[0],t=i[1]),t||(t=32),"string"===typeof t&&t.indexOf(".")>-1){try{this.maskLong=a(t)}catch(s){throw s,new Error("Invalid mask: "+t)}for(r=n=32;n>=0;r=--n)if(this.maskLong===4294967295<<32-r>>>0){this.bitmask=r;break}}else{if(!t&&0!==t)throw new Error("Invalid mask: empty");this.bitmask=parseInt(t,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(a(e)&this.maskLong)>>>0}catch(s){throw s,new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+t);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return e.prototype.contains=function(t){return"string"===typeof t&&(t.indexOf("/")>0||4!==t.split(".").length)&&(t=new e(t)),t instanceof e?this.contains(t.base)&&this.contains(t.broadcast||t.last):(a(t)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},e.prototype.next=function(t){return null==t&&(t=1),new e(c(this.netLong+this.size*t),this.mask)},e.prototype.forEach=function(e){var t,r,n;for(n=a(this.first),r=a(this.last),t=0;n<=r;)e(c(n),n,t),t++,n++},e.prototype.toString=function(){return this.base+"/"+this.bitmask},e}(),t.ip2long=a,t.long2ip=c,t.Netmask=e}).call(this)},8605:(e,t,r)=>{var n=r(392);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.aes.Algorithm(e,t)}))}r(3397),r(4533),r(3877),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){u||h();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return f(r._w,e,t,!1)},decrypt:function(e,t){return f(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!==typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i>>=2;for(i=0;i>8^255&h^99,s[g]=h,o[h]=g,f=(d=e[h])<<24^h<<16^h<<8^h^d,p=((r=e[g])^(n=e[r])^(i=e[n]))<<24^(g^i)<<16^(g^n^i)<<8^g^r^i;for(var m=0;m<4;++m)c[m][g]=f,l[m][h]=p,f=f<<24|f>>>8,p=p<<24|p>>>8;0===g?g=y=1:(g=r^e[e[e[r^i]]],y^=e[e[y]])}}function d(e,t){for(var r,n=e.slice(0),i=1,o=n.length,c=4*(o+6+1),u=o;u>>16&255]<<24^s[r>>>8&255]<<16^s[255&r]<<8^s[r>>>24]^a[i]<<24,i++):o>6&&u%o===4&&(r=s[r>>>24]<<24^s[r>>>16&255]<<16^s[r>>>8&255]<<8^s[255&r]),n[u]=n[u-o]^r;if(t){for(var h,d=l[0],f=l[1],p=l[2],g=l[3],y=n.slice(0),m=(u=0,(c=n.length)-4);u>>24]]^f[s[h>>>16&255]]^p[s[h>>>8&255]]^g[s[255&h]];n=y}return n}function f(e,t,r,n){var i,a,u,h,d,f,p,g,y,m,v,b,w=e.length/4-1;n?(i=l[0],a=l[1],u=l[2],h=l[3],d=o):(i=c[0],a=c[1],u=c[2],h=c[3],d=s),f=t[0]^e[0],p=t[n?3:1]^e[1],g=t[2]^e[2],y=t[n?1:3]^e[3];for(var E=3,_=1;_>>24]^a[p>>>16&255]^u[g>>>8&255]^h[255&y]^e[++E],v=i[p>>>24]^a[g>>>16&255]^u[y>>>8&255]^h[255&f]^e[++E],b=i[g>>>24]^a[y>>>16&255]^u[f>>>8&255]^h[255&p]^e[++E],y=i[y>>>24]^a[f>>>16&255]^u[p>>>8&255]^h[255&g]^e[++E],f=m,p=v,g=b;r[0]=d[f>>>24]<<24^d[p>>>16&255]<<16^d[g>>>8&255]<<8^d[255&y]^e[++E],r[n?3:1]=d[p>>>24]<<24^d[g>>>16&255]<<16^d[y>>>8&255]<<8^d[255&f]^e[++E],r[2]=d[g>>>24]<<24^d[y>>>16&255]<<16^d[f>>>8&255]<<8^d[255&p]^e[++E],r[n?1:3]=d[y>>>24]<<24^d[f>>>16&255]<<16^d[p>>>8&255]<<8^d[255&g]^e[++E]}function p(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=e,i.call(t,r)},t}},5049:(e,t,r)=>{var n=r(392);r(3877),r(2886);var i=e.exports=n.asn1=n.asn1||{};function s(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(e,t,r,s,o){if(n.util.isArray(s)){for(var a=[],c=0;ct){if(n.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=t,p.requested=f,p}f=t}var g=32===(32&c);if(g)if(h=[],void 0===f)for(;;){if(s(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}a=e.length(),h.push(o(e,t,r+1,n)),t-=a-e.length()}else for(;f>0;)a=e.length(),h.push(o(e,f,r+1,n)),t-=a-e.length(),f-=a-e.length();if(void 0===h&&l===i.Class.UNIVERSAL&&u===i.Type.BITSTRING&&(d=e.bytes(f)),void 0===h&&n.decodeBitStrings&&l===i.Class.UNIVERSAL&&u===i.Type.BITSTRING&&f>1){var y=e.read,m=t,v=0;if(u===i.Type.BITSTRING&&(s(e,t,1),v=e.getByte(),t--),0===v)try{a=e.length();var b=o(e,t,r+1,{strict:!0,decodeBitStrings:!0}),w=a-e.length();t-=w,u==i.Type.BITSTRING&&w++;var E=b.tagClass;w!==f||E!==i.Class.UNIVERSAL&&E!==i.Class.CONTEXT_SPECIFIC||(h=[b])}catch(S){}void 0===h&&(e.read=y,t=m)}if(void 0===h){if(void 0===f){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");f=t}if(u===i.Type.BMPSTRING)for(h="";f>0;f-=2)s(e,t,2),h+=String.fromCharCode(e.getInt16()),t-=2;else h=e.getBytes(f),t-=f}var _=void 0===d?null:{bitStringContents:d};return i.create(l,u,g,h,_)}i.fromDer=function(e,t){void 0===t&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),"boolean"===typeof t&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.length(),i=o(e,e.length(),0,t);if(t.parseAllBytes&&0!==e.length()){var s=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw s.byteCount=r,s.remaining=e.length(),s}return i},i.toDer=function(e){var t=n.util.createBuffer(),r=e.tagClass|e.type,s=n.util.createBuffer(),o=!1;if("bitStringContents"in e&&(o=!0,e.original&&(o=i.equals(e,e.original))),o)s.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:s.putByte(0);for(var a=0;a1&&(0===e.value.charCodeAt(0)&&0===(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128===(128&e.value.charCodeAt(1)))?s.putBytes(e.value.substr(1)):s.putBytes(e.value);if(t.putByte(r),s.length()<=127)t.putByte(127&s.length());else{var c=s.length(),l="";do{l+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|l.length);for(a=l.length-1;a>=0;--a)t.putByte(l.charCodeAt(a))}return t.putBuffer(s),t},i.oidToDer=function(e){var t,r,i,s,o=e.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var c=2;c>>=7,t||(s|=128),r.push(s),t=!1}while(i>0);for(var l=r.length-1;l>=0;--l)a.putByte(r[l])}return a},i.derToOid=function(e){var t;"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var i=0;e.length()>0;)i<<=7,128&(r=e.getByte())?i+=127&r:(t+="."+(i+r),i=0);return t},i.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),a=0;if(e.length>11){var c=e.charAt(10),l=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(s,o,a,0),l&&("+"===(c=e.charAt(l))||"-"===c)){var u=60*parseInt(e.substr(l+1,2),10)+parseInt(e.substr(l+4,2),10);u*=6e4,"+"===c?t.setTime(+t-u):t.setTime(+t+u)}return t},i.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),c=0,l=0,u=!1;"Z"===e.charAt(e.length-1)&&(u=!0);var h=e.length-5,d=e.charAt(h);"+"!==d&&"-"!==d||(l=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),l*=6e4,"+"===d&&(l*=-1),u=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),u?(t.setUTCFullYear(r,n,i),t.setUTCHours(s,o,a,c),t.setTime(+t+l)):(t.setFullYear(r,n,i),t.setHours(s,o,a,c)),t},i.dateToUtcTime=function(e){if("string"===typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},i.derToInteger=function(e){"string"===typeof e&&(e=n.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},i.validate=function(e,t,r,s){var o=!1;if(e.tagClass!==t.tagClass&&"undefined"!==typeof t.tagClass||e.type!==t.type&&"undefined"!==typeof t.type)s&&(e.tagClass!==t.tagClass&&s.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&s.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||"undefined"===typeof t.constructed){if(o=!0,t.value&&n.util.isArray(t.value))for(var a=0,c=0;o&&c0&&(s+="\n");for(var o="",c=0;c1?s+="0x"+n.util.bytesToHex(e.value.slice(1)):s+="(none)",e.value.length>0){var d=e.value.charCodeAt(0);1==d?s+=" (1 unused bit shown)":d>1&&(s+=" ("+d+" unused bits shown)")}}else if(e.type===i.Type.OCTETSTRING)a.test(e.value)||(s+="("+e.value+") "),s+="0x"+n.util.bytesToHex(e.value);else if(e.type===i.Type.UTF8)try{s+=n.util.decodeUtf8(e.value)}catch(p){if("URI malformed"!==p.message)throw p;s+="0x"+n.util.bytesToHex(e.value)+" (malformed UTF8)"}else e.type===i.Type.PRINTABLESTRING||e.type===i.Type.IA5String?s+=e.value:a.test(e.value)?s+="0x"+n.util.bytesToHex(e.value):0===e.value.length?s+="[null]":s+=e.value}return s}},5754:e=>{var t={};e.exports=t;var r={};t.encode=function(e,t,r){if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!==typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,s=t.length,o=t.charAt(0),a=[0];for(i=0;i0;)a.push(l%s),l=l/s|0}for(i=0;0===e[i]&&i=0;--i)n+=t[a[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),s=[0];for(r=0;r0;)s.push(a%n),a=a/n|0}var c="";for(r=0;0===e.at(r)&&r=0;--r)c+=t[s[r]];return c}(e,t);if(r){var u=new RegExp(".{1,"+r+"}","g");n=n.match(u).join("\r\n")}return n},t.decode=function(e,t){if("string"!==typeof e)throw new TypeError('"input" must be a string.');if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');var n=r[t];if(!n){n=r[t]=[];for(var i=0;i>=8;for(;u>0;)a.push(255&u),u>>=8}for(var h=0;e[h]===o&&h{var n=r(392);r(3877),e.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},n.cipher.createDecipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},n.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),n.cipher.algorithms[e]=t},n.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[e]:null};var i=n.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};i.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=e.output||n.util.createBuffer(),this.mode.start(t)},i.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))}},4533:(e,t,r)=>{var n=r(392);r(3877),n.cipher=n.cipher||{};var i=e.exports=n.cipher.modes=n.cipher.modes||{};function s(e,t){if("string"===typeof e&&(e=n.util.createBuffer(e)),n.util.isArray(e)&&e.length>4){var r=e;e=n.util.createBuffer();for(var i=0;i0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(e,t,r){if(e.length()0))return!0;for(var n=0;n0))return!0;for(var n=0;n0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0)e.read-=this.blockSize;else for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}o(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=n.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?n.util.createBuffer(e.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),o(this._inBlock),this._partialBytes=0,t=n.util.createBuffer(t),this._aDataLength=a(8*t.length());var s=t.length()%this.blockSize;for(s&&t.fillWithByte(0,this.blockSize-s),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},i.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),o(this._inBlock)},i.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),o(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},i.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},i.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},i.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,s=new Array(i),o=0;o>>1,i=new Array(r);i[n]=e.slice(0);for(var s=n>>>1;s>0;)this.pow(i[2*s],i[s]=[]),s>>=1;for(s=2;s{var n=r(392);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.des.Algorithm(e,t)}))}r(3397),r(4533),r(3877),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return f(r._keys,e,t,!1)},decrypt:function(e,t){return f(r._keys,e,t,!0)}}}),r._init=!1},n.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=n.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],s=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],l=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],u=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],f=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],y=e.length()>8?3:1,m=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],b=0,w=0;w>>4^_))<<4,E^=t=65535&((_^=t)>>>-16^E),E^=(t=858993459&(E>>>2^(_^=t<<-16)))<<2,E^=t=65535&((_^=t)>>>-16^E),E^=(t=1431655765&(E>>>1^(_^=t<<-16)))<<1,E^=t=16711935&((_^=t)>>>8^E),t=(E^=(t=1431655765&(E>>>1^(_^=t<<8)))<<1)<<8|(_^=t)>>>20&240,E=_<<24|_<<8&16711680|_>>>8&65280|_>>>24&240,_=t;for(var S=0;S>>26,_=_<<2|_>>>26):(E=E<<1|E>>>27,_=_<<1|_>>>27),_&=-15;var I=r[(E&=-15)>>>28]|n[E>>>24&15]|i[E>>>20&15]|s[E>>>16&15]|o[E>>>12&15]|a[E>>>8&15]|c[E>>>4&15],C=l[_>>>28]|u[_>>>24&15]|h[_>>>20&15]|d[_>>>16&15]|f[_>>>12&15]|p[_>>>8&15]|g[_>>>4&15];t=65535&(C>>>16^I),m[b++]=I^t,m[b++]=C^t<<16}}return m}(t),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var s=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],l=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],u=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],h=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],d=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function f(e,t,r,n){var i,f,p=32===e.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var g=t[0],y=t[1];g^=(f=252645135&(g>>>4^y))<<4,g^=(f=65535&(g>>>16^(y^=f)))<<16,g^=f=858993459&((y^=f)>>>2^g),g^=f=16711935&((y^=f<<2)>>>8^g),g=(g^=(f=1431655765&(g>>>1^(y^=f<<8)))<<1)<<1|g>>>31,y=(y^=f)<<1|y>>>31;for(var m=0;m>>4|y<<28)^e[w+1];f=g,g=y,y=f^(o[E>>>24&63]|c[E>>>16&63]|u[E>>>8&63]|d[63&E]|s[_>>>24&63]|a[_>>>16&63]|l[_>>>8&63]|h[63&_])}f=g,g=y,y=f}y=y>>>1|y<<31,y^=f=1431655765&((g=g>>>1|g<<31)>>>1^y),y^=(f=16711935&(y>>>8^(g^=f<<1)))<<8,y^=(f=858993459&(y>>>2^(g^=f)))<<2,y^=f=65535&((g^=f)>>>16^y),y^=f=252645135&((g^=f<<16)>>>4^y),g^=f<<4,r[0]=g,r[1]=y}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=e,i.call(t,r)},t}},392:e=>{e.exports={options:{usePureJavaScript:!1}}},878:(e,t,r)=>{var n=r(392);r(29),r(3877),(e.exports=n.hmac=n.hmac||{}).create=function(){var e=null,t=null,r=null,i=null,s={start:function(s,o){if(null!==s)if("string"===typeof s){if(!((s=s.toLowerCase())in n.md.algorithms))throw new Error('Unknown hash algorithm "'+s+'"');t=n.md.algorithms[s].create()}else t=s;if(null===o)o=e;else{if("string"===typeof o)o=n.util.createBuffer(o);else if(n.util.isArray(o)){var a=o;o=n.util.createBuffer();for(var c=0;ct.blockLength&&(t.start(),t.update(o.bytes()),o=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),l=o.length();for(c=0;c{var n,i=r(392);e.exports=i.jsbn=i.jsbn||{};function s(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function o(){return new s(null)}function a(e,t,r,n,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var c=16383&this.data[e],l=this.data[e++]>>14,u=a*c+l*o;i=((c=o*c+((16383&u)<<14)+r.data[n]+i)>>28)+(u>>14)+a*l,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=s,"undefined"===typeof navigator?(s.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(s.prototype.am=function(e,t,r,n,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var c=32767&this.data[e],l=this.data[e++]>>15,u=a*c+l*o;i=((c=o*c+((32767&u)<<15)+r.data[n]+(1073741823&i))>>>30)+(u>>>15)+a*l+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(s.prototype.am=function(e,t,r,n,i,s){for(;--s>=0;){var o=t*this.data[e++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=67108863&o}return i},n=26):(s.prototype.am=a,n=28),s.prototype.DB=n,s.prototype.DM=(1<>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function g(e){this.m=e}function y(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function _(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function S(){}function I(e){return e}function C(e){this.r2=o(),this.q3=o(),s.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}g.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},g.prototype.revert=function(e){return e},g.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},g.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},g.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},y.prototype.convert=function(e){var t=o();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(s.ZERO)>0&&this.m.subTo(t,t),t},y.prototype.revert=function(e){var t=o();return e.copyTo(t),this.reduce(t),t},y.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},s.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},s.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},s.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var a=8==r?255&e[n]:d(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this.data[this.t++]=a:o+r>this.DB?(this.data[this.t-1]|=(a&(1<>this.DB-o):this.data[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t},s.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},s.prototype.drShiftTo=function(e,t){for(var r=e;r=0;--r)t.data[r+o+1]=this.data[r]>>i|a,a=(this.data[r]&s)<=0;--r)t.data[r]=0;t.data[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},s.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,s=(1<>n;for(var o=r+1;o>n;n>0&&(t.data[this.t-r-1]|=(this.s&s)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},s.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i=0;)e.data[r]=0;for(r=0;r=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},s.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,a),i.lShiftTo(u,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,d=a.data[h-1];if(0!=d){var f=d*(1<1?a.data[h-2]>>this.F2:0),g=this.FV/f,y=(1<=0&&(r.data[r.t++]=1,r.subTo(w,r)),s.ONE.dlShiftTo(h,w),w.subTo(a,a);a.t=0;){var E=r.data[--v]==d?this.DM:Math.floor(r.data[v]*g+(r.data[v-1]+m)*y);if((r.data[v]+=a.am(0,E,r,b,0,h))0&&r.rShiftTo(u,r),c<0&&s.ZERO.subTo(r,r)}}},s.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},s.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},s.prototype.exp=function(e,t){if(e>4294967295||e<1)return s.ONE;var r=o(),n=o(),i=t.convert(this),a=p(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var c=r;r=n,n=c}return t.revert(r)},s.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(a>a)>0&&(i=!0,s=h(r));o>=0;)a>(a+=this.DB-t)):(r=this.data[o]>>(a-=t)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=h(r));return i?s:"0"},s.prototype.negate=function(){var e=o();return s.ZERO.subTo(this,e),e},s.prototype.abs=function(){return this.s<0?this.negate():this},s.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},s.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+p(this.data[this.t-1]^this.s&this.DM)},s.prototype.mod=function(e){var t=o();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(s.ZERO)>0&&e.subTo(t,t),t},s.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new g(t):new y(t),this.exp(e,r)},s.ZERO=f(0),s.ONE=f(1),S.prototype.convert=I,S.prototype.revert=I,S.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},S.prototype.sqrTo=function(e,t){e.squareTo(t)},C.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=o();return e.copyTo(t),this.reduce(t),t},C.prototype.revert=function(e){return e},C.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},C.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},C.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var A=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],T=(1<<26)/A[A.length-1];s.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},s.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=f(r),i=o(),s=o(),a="";for(this.divRemTo(n,i,s);i.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,s);return s.intValue().toString(e)+a},s.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,a=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,0)),i&&s.ZERO.subTo(this,this)},s.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(s.ONE.shiftLeft(e-1),v,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(s.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},s.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},s.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},s.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},s.prototype.millerRabin=function(e){var t=this.subtract(s.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),o={nextBytes:function(e){for(var t=0;t=0);var c=n.modPow(i,this);if(0!=c.compareTo(s.ONE)&&0!=c.compareTo(t)){for(var l=1;l++>24},s.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},s.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},s.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this.data[e]&(1<>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},s.prototype.equals=function(e){return 0==this.compareTo(e)},s.prototype.min=function(e){return this.compareTo(e)<0?this:e},s.prototype.max=function(e){return this.compareTo(e)>0?this:e},s.prototype.and=function(e){var t=o();return this.bitwiseTo(e,m,t),t},s.prototype.or=function(e){var t=o();return this.bitwiseTo(e,v,t),t},s.prototype.xor=function(e){var t=o();return this.bitwiseTo(e,b,t),t},s.prototype.andNot=function(e){var t=o();return this.bitwiseTo(e,w,t),t},s.prototype.not=function(){for(var e=o(),t=0;t=this.t?0!=this.s:0!=(this.data[t]&1<1){var h=o();for(n.sqrTo(a[1],h);c<=u;)a[c]=o(),n.mulTo(h,a[c-2],a[c]),c+=2}var d,m,v=e.t-1,b=!0,w=o();for(i=p(e.data[v])-1;v>=0;){for(i>=l?d=e.data[v]>>i-l&u:(d=(e.data[v]&(1<0&&(d|=e.data[v-1]>>this.DB+i-l)),c=r;0==(1&d);)d>>=1,--c;if((i-=c)<0&&(i+=this.DB,--v),b)a[d].copyTo(s),b=!1;else{for(;c>1;)n.sqrTo(s,w),n.sqrTo(w,s),c-=2;c>0?n.sqrTo(s,w):(m=s,s=w,w=m),n.mulTo(w,a[d],s)}for(;v>=0&&0==(e.data[v]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),o.subTo(c,o)):(n.subTo(r,n),t&&a.subTo(i,a),c.subTo(o,c))}return 0!=n.compareTo(s.ONE)?s.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},s.prototype.pow=function(e){return this.exp(e,new S)},s.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return t;for(i0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},s.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=A[A.length-1]){for(t=0;t{var n=r(392);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},1746:(e,t,r)=>{var n=r(392);r(7263),e.exports=n.mgf=n.mgf||{},n.mgf.mgf1=n.mgf1},7263:(e,t,r)=>{var n=r(392);r(3877),n.mgf=n.mgf||{},(e.exports=n.mgf.mgf1=n.mgf1=n.mgf1||{}).create=function(e){return{generate:function(t,r){for(var i=new n.util.ByteBuffer,s=Math.ceil(r/e.digestLength),o=0;o{var n=r(392);n.pki=n.pki||{};var i=e.exports=n.pki.oids=n.oids=n.oids||{};function s(e,t){i[e]=t,i[t]=e}function o(e,t){i[e]=t}s("1.2.840.113549.1.1.1","rsaEncryption"),s("1.2.840.113549.1.1.4","md5WithRSAEncryption"),s("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),s("1.2.840.113549.1.1.7","RSAES-OAEP"),s("1.2.840.113549.1.1.8","mgf1"),s("1.2.840.113549.1.1.9","pSpecified"),s("1.2.840.113549.1.1.10","RSASSA-PSS"),s("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),s("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),s("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),s("1.3.101.112","EdDSA25519"),s("1.2.840.10040.4.3","dsa-with-sha1"),s("1.3.14.3.2.7","desCBC"),s("1.3.14.3.2.26","sha1"),s("1.3.14.3.2.29","sha1WithRSASignature"),s("2.16.840.1.101.3.4.2.1","sha256"),s("2.16.840.1.101.3.4.2.2","sha384"),s("2.16.840.1.101.3.4.2.3","sha512"),s("2.16.840.1.101.3.4.2.4","sha224"),s("2.16.840.1.101.3.4.2.5","sha512-224"),s("2.16.840.1.101.3.4.2.6","sha512-256"),s("1.2.840.113549.2.2","md2"),s("1.2.840.113549.2.5","md5"),s("1.2.840.113549.1.7.1","data"),s("1.2.840.113549.1.7.2","signedData"),s("1.2.840.113549.1.7.3","envelopedData"),s("1.2.840.113549.1.7.4","signedAndEnvelopedData"),s("1.2.840.113549.1.7.5","digestedData"),s("1.2.840.113549.1.7.6","encryptedData"),s("1.2.840.113549.1.9.1","emailAddress"),s("1.2.840.113549.1.9.2","unstructuredName"),s("1.2.840.113549.1.9.3","contentType"),s("1.2.840.113549.1.9.4","messageDigest"),s("1.2.840.113549.1.9.5","signingTime"),s("1.2.840.113549.1.9.6","counterSignature"),s("1.2.840.113549.1.9.7","challengePassword"),s("1.2.840.113549.1.9.8","unstructuredAddress"),s("1.2.840.113549.1.9.14","extensionRequest"),s("1.2.840.113549.1.9.20","friendlyName"),s("1.2.840.113549.1.9.21","localKeyId"),s("1.2.840.113549.1.9.22.1","x509Certificate"),s("1.2.840.113549.1.12.10.1.1","keyBag"),s("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),s("1.2.840.113549.1.12.10.1.3","certBag"),s("1.2.840.113549.1.12.10.1.4","crlBag"),s("1.2.840.113549.1.12.10.1.5","secretBag"),s("1.2.840.113549.1.12.10.1.6","safeContentsBag"),s("1.2.840.113549.1.5.13","pkcs5PBES2"),s("1.2.840.113549.1.5.12","pkcs5PBKDF2"),s("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),s("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),s("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),s("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),s("1.2.840.113549.2.7","hmacWithSHA1"),s("1.2.840.113549.2.8","hmacWithSHA224"),s("1.2.840.113549.2.9","hmacWithSHA256"),s("1.2.840.113549.2.10","hmacWithSHA384"),s("1.2.840.113549.2.11","hmacWithSHA512"),s("1.2.840.113549.3.7","des-EDE3-CBC"),s("2.16.840.1.101.3.4.1.2","aes128-CBC"),s("2.16.840.1.101.3.4.1.22","aes192-CBC"),s("2.16.840.1.101.3.4.1.42","aes256-CBC"),s("2.5.4.3","commonName"),s("2.5.4.4","surname"),s("2.5.4.5","serialNumber"),s("2.5.4.6","countryName"),s("2.5.4.7","localityName"),s("2.5.4.8","stateOrProvinceName"),s("2.5.4.9","streetAddress"),s("2.5.4.10","organizationName"),s("2.5.4.11","organizationalUnitName"),s("2.5.4.12","title"),s("2.5.4.13","description"),s("2.5.4.15","businessCategory"),s("2.5.4.17","postalCode"),s("2.5.4.42","givenName"),s("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),s("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),s("2.16.840.1.113730.1.1","nsCertType"),s("2.16.840.1.113730.1.13","nsComment"),o("2.5.29.1","authorityKeyIdentifier"),o("2.5.29.2","keyAttributes"),o("2.5.29.3","certificatePolicies"),o("2.5.29.4","keyUsageRestriction"),o("2.5.29.5","policyMapping"),o("2.5.29.6","subtreesConstraint"),o("2.5.29.7","subjectAltName"),o("2.5.29.8","issuerAltName"),o("2.5.29.9","subjectDirectoryAttributes"),o("2.5.29.10","basicConstraints"),o("2.5.29.11","nameConstraints"),o("2.5.29.12","policyConstraints"),o("2.5.29.13","basicConstraints"),s("2.5.29.14","subjectKeyIdentifier"),s("2.5.29.15","keyUsage"),o("2.5.29.16","privateKeyUsagePeriod"),s("2.5.29.17","subjectAltName"),s("2.5.29.18","issuerAltName"),s("2.5.29.19","basicConstraints"),o("2.5.29.20","cRLNumber"),o("2.5.29.21","cRLReason"),o("2.5.29.22","expirationDate"),o("2.5.29.23","instructionCode"),o("2.5.29.24","invalidityDate"),o("2.5.29.25","cRLDistributionPoints"),o("2.5.29.26","issuingDistributionPoint"),o("2.5.29.27","deltaCRLIndicator"),o("2.5.29.28","issuingDistributionPoint"),o("2.5.29.29","certificateIssuer"),o("2.5.29.30","nameConstraints"),s("2.5.29.31","cRLDistributionPoints"),s("2.5.29.32","certificatePolicies"),o("2.5.29.33","policyMappings"),o("2.5.29.34","policyConstraints"),s("2.5.29.35","authorityKeyIdentifier"),o("2.5.29.36","policyConstraints"),s("2.5.29.37","extKeyUsage"),o("2.5.29.46","freshestCRL"),o("2.5.29.54","inhibitAnyPolicy"),s("1.3.6.1.4.1.11129.2.4.2","timestampList"),s("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),s("1.3.6.1.5.5.7.3.1","serverAuth"),s("1.3.6.1.5.5.7.3.2","clientAuth"),s("1.3.6.1.5.5.7.3.3","codeSigning"),s("1.3.6.1.5.5.7.3.4","emailProtection"),s("1.3.6.1.5.5.7.3.8","timeStamping")},9835:(e,t,r)=>{var n=r(392);if(r(8605),r(5049),r(1400),r(29),r(2886),r(6019),r(6193),r(3860),r(654),r(5493),r(3877),"undefined"===typeof i)var i=n.jsbn.BigInteger;var s=n.asn1,o=n.pki=n.pki||{};e.exports=o.pbe=n.pbe=n.pbe||{};var a=o.oids,c={name:"EncryptedPrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},l={name:"PBES2Algorithms",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},u={name:"pkcs-12PbeParams",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"iterations"}]};function h(e,t){return e.start().update(t).digest().getBytes()}function d(e){var t;if(e){if(!(t=o.oids[s.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return f(t)}function f(e){var t=n.md;switch(e){case"hmacWithSHA224":t=n.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}o.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var i,c,l,u=n.random.getBytesSync(r.saltSize),h=r.count,d=s.integerToDer(h);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var p,g,y;switch(r.algorithm){case"aes128":i=16,p=16,g=a["aes128-CBC"],y=n.aes.createEncryptionCipher;break;case"aes192":i=24,p=16,g=a["aes192-CBC"],y=n.aes.createEncryptionCipher;break;case"aes256":i=32,p=16,g=a["aes256-CBC"],y=n.aes.createEncryptionCipher;break;case"des":i=8,p=8,g=a.desCBC,y=n.des.createEncryptionCipher;break;default:throw(_=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,_}var m="hmacWith"+r.prfAlgorithm.toUpperCase(),v=f(m),b=n.pkcs5.pbkdf2(t,u,h,i,v),w=n.random.getBytesSync(p);(S=y(b)).start(w),S.update(s.toDer(e)),S.finish(),l=S.output.getBytes();var E=function(e,t,r,i){var a=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,e),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==i&&a.value.push(s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,n.util.hexToBytes(r.toString(16))),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(o.oids[i]).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]));return a}(u,d,i,m);c=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a.pkcs5PBES2).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a.pkcs5PBKDF2).getBytes()),E]),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(g).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,w)])])])}else{var _;if("3des"!==r.algorithm)throw(_=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,_;i=24;var S,I=new n.util.ByteBuffer(u);b=o.pbe.generatePkcs12Key(t,I,1,h,i),w=o.pbe.generatePkcs12Key(t,I,2,h,i);(S=n.des.createEncryptionCipher(b)).start(w),S.update(s.toDer(e)),S.finish(),l=S.output.getBytes(),c=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,u),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,d.getBytes())])])}return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[c,s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,l)])},o.decryptPrivateKeyInfo=function(e,t){var r=null,i={},a=[];if(!s.validate(e,c,i,a)){var l=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw l.errors=a,l}var u=s.derToOid(i.encryptionOid),h=o.pbe.getCipher(u,i.encryptionParams,t),d=n.util.createBuffer(i.encryptedData);return h.update(d),h.finish()&&(r=s.fromDer(h.output)),r},o.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:s.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})},o.encryptedPrivateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return s.fromDer(t.body)},o.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var i=o.wrapRsaPrivateKey(o.privateKeyToAsn1(e));return i=o.encryptPrivateKeyInfo(i,t,r),o.encryptedPrivateKeyToPem(i)}var a,c,l,u;switch(r.algorithm){case"aes128":a="AES-128-CBC",l=16,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",l=24,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",l=32,c=n.random.getBytesSync(16),u=n.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",l=24,c=n.random.getBytesSync(8),u=n.des.createEncryptionCipher;break;case"des":a="DES-CBC",l=8,c=n.random.getBytesSync(8),u=n.des.createEncryptionCipher;break;default:var h=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw h.algorithm=r.algorithm,h}var d=u(n.pbe.opensslDeriveBytes(t,c.substr(0,8),l));d.start(c),d.update(s.toDer(o.privateKeyToAsn1(e))),d.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:n.util.bytesToHex(c).toUpperCase()},body:d.output.getBytes()};return n.pem.encode(f)},o.decryptRsaPrivateKey=function(e,t){var r=null,i=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==i.type&&"PRIVATE KEY"!==i.type&&"RSA PRIVATE KEY"!==i.type)throw(l=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=l,l;if(i.procType&&"ENCRYPTED"===i.procType.type){var a,c;switch(i.dekInfo.algorithm){case"DES-CBC":a=8,c=n.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,c=n.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,c=n.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,c=n.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,c=n.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,c=function(e){return n.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,c=function(e){return n.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,c=function(e){return n.rc2.createDecryptionCipher(e,128)};break;default:var l;throw(l=new Error('Could not decrypt private key; unsupported encryption algorithm "'+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,l}var u=n.util.hexToBytes(i.dekInfo.parameters),h=c(n.pbe.opensslDeriveBytes(t,u.substr(0,8),a));if(h.start(u),h.update(n.util.createBuffer(i.body)),!h.finish())return r;r=h.output.getBytes()}else r=i.body;return null!==(r="ENCRYPTED PRIVATE KEY"===i.type?o.decryptPrivateKeyInfo(s.fromDer(r),t):s.fromDer(r))&&(r=o.privateKeyFromAsn1(r)),r},o.pbe.generatePkcs12Key=function(e,t,r,i,s,o){var a,c;if("undefined"===typeof o||null===o){if(!("sha1"in n.md))throw new Error('"sha1" hash algorithm unavailable.');o=n.md.sha1.create()}var l=o.digestLength,u=o.blockLength,h=new n.util.ByteBuffer,d=new n.util.ByteBuffer;if(null!==e&&void 0!==e){for(c=0;c=0;c--)R>>=8,R+=C.at(c)+k.at(c),k.setAt(c,255&R);T.putBuffer(k)}w=T,h.putBuffer(S)}return h.truncate(h.length()-s),h},o.pbe.getCipher=function(e,t,r){switch(e){case o.oids.pkcs5PBES2:return o.pbe.getCipherForPBES2(e,t,r);case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case o.oids["pbewithSHAAnd40BitRC2-CBC"]:return o.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},o.pbe.getCipherForPBES2=function(e,t,r){var i,a={},c=[];if(!s.validate(t,l,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((e=s.derToOid(a.kdfOid))!==o.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,i.supportedOids=["pkcs5PBKDF2"],i;if((e=s.derToOid(a.encOid))!==o.oids["aes128-CBC"]&&e!==o.oids["aes192-CBC"]&&e!==o.oids["aes256-CBC"]&&e!==o.oids["des-EDE3-CBC"]&&e!==o.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var u,h,f=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),o.oids[e]){case"aes128-CBC":u=16,h=n.aes.createDecryptionCipher;break;case"aes192-CBC":u=24,h=n.aes.createDecryptionCipher;break;case"aes256-CBC":u=32,h=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":u=24,h=n.des.createDecryptionCipher;break;case"desCBC":u=8,h=n.des.createDecryptionCipher}var g=d(a.prfOid),y=n.pkcs5.pbkdf2(r,f,p,u,g),m=a.encIv,v=h(y);return v.start(m),v},o.pbe.getCipherForPKCS12PBE=function(e,t,r){var i={},a=[];if(!s.validate(t,u,i,a))throw(g=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,g;var c,l,h,f=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),e){case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,l=8,h=n.des.startDecrypting;break;case o.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,l=8,h=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var g;throw(g=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,g}var y=d(i.prfOid),m=o.pbe.generatePkcs12Key(r,f,1,p,c,y);return y.start(),h(m,o.pbe.generatePkcs12Key(r,f,2,p,l,y))},o.pbe.opensslDeriveBytes=function(e,t,r,i){if("undefined"===typeof i||null===i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===t&&(t="");for(var s=[h(i,e+t)],o=16,a=1;o{var n=r(392);r(878),r(29),r(3877);var i,s=n.pkcs5=n.pkcs5||{};n.util.isNodejs&&!n.options.usePureJavaScript&&(i=r(5819)),e.exports=n.pbkdf2=s.pbkdf2=function(e,t,r,s,o,a){if("function"===typeof o&&(a=o,o=null),n.util.isNodejs&&!n.options.usePureJavaScript&&i.pbkdf2&&(null===o||"object"!==typeof o)&&(i.pbkdf2Sync.length>4||!o||"sha1"===o))return"string"!==typeof o&&(o="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),a?4===i.pbkdf2Sync.length?i.pbkdf2(e,t,r,s,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):i.pbkdf2(e,t,r,s,o,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(e,t,r,s).toString("binary"):i.pbkdf2Sync(e,t,r,s,o).toString("binary");if("undefined"!==typeof o&&null!==o||(o="sha1"),"string"===typeof o){if(!(o in n.md.algorithms))throw new Error("Unknown hash algorithm: "+o);o=n.md[o].create()}var c=o.digestLength;if(s>4294967295*c){var l=new Error("Derived key is too long.");if(a)return a(l);throw l}var u=Math.ceil(s/c),h=s-(u-1)*c,d=n.hmac.create();d.start(o,e);var f,p,g,y="";if(!a){for(var m=1;m<=u;++m){d.start(null,null),d.update(t),d.update(n.util.int32ToBytes(m)),f=g=d.digest().getBytes();for(var v=2;v<=r;++v)d.start(null,null),d.update(g),p=d.digest().getBytes(),f=n.util.xorBytes(f,p,c),g=p;y+=mu)return a(null,y);d.start(null,null),d.update(t),d.update(n.util.int32ToBytes(m)),f=g=d.digest().getBytes(),v=2,w()}function w(){if(v<=r)return d.start(null,null),d.update(g),p=d.digest().getBytes(),f=n.util.xorBytes(f,p,c),g=p,++v,n.util.setImmediate(w);y+=m{var n=r(392);r(3877);var i=e.exports=n.pem=n.pem||{};function s(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i65&&-1!==o){var a=t[o];","===a?(++o,t=t.substr(0,o)+"\r\n "+t.substr(o)):t=t.substr(0,o)+"\r\n"+a+t.substr(o+1),s=i-o-1,o=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(o=i);return t}function o(e){return e.replace(/^\s+/,"")}i.encode=function(e,t){t=t||{};var r,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=s(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=s(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=s(r)),e.headers)for(var o=0;o{var n=r(392);r(3877),r(3860),r(928);var i=e.exports=n.pkcs1=n.pkcs1||{};function s(e,t,r){r||(r=n.md.sha1.create());for(var i="",s=Math.ceil(t/r.digestLength),o=0;o>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(e+a),i+=r.digest().getBytes()}return i.substring(0,t)}i.encode_rsa_oaep=function(e,t,r){var i,o,a,c;"string"===typeof r?(i=r,o=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,o=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var l=Math.ceil(e.n.bitLength()/8),u=l-2*a.digestLength-2;if(t.length>u)throw(y=new Error("RSAES-OAEP input message length is too long.")).length=t.length,y.maxLength=u,y;i||(i=""),a.update(i,"raw");for(var h=a.digest(),d="",f=u-t.length,p=0;p{var n=r(392);r(8605),r(5049),r(1400),r(2886),r(6193),r(4922),r(3860),r(3877),r(3391);var i=n.asn1,s=e.exports=n.pkcs7=n.pkcs7||{};function o(e){var t={},r=[];if(!i.validate(e,s.asn1.recipientInfoValidator,t,r)){var o=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw o.errors=r,o}return{version:t.version.charCodeAt(0),issuer:n.pki.RDNAttributesAsArray(t.issuer),serialNumber:n.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:i.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function a(e){for(var t,r=[],s=0;s0){for(var r=i.create(i.Class.CONTEXT_SPECIFIC,1,!0,[]),s=0;s=r&&o0&&o.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!0,t)),s.length>0&&o.value[0].value.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,s)),o.value[0].value.push(i.create(i.Class.UNIVERSAL,i.Type.SET,!0,e.signerInfos)),i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.type).getBytes()),o])},addSigner:function(t){var r=t.issuer,i=t.serialNumber;if(t.certificate){var s=t.certificate;"string"===typeof s&&(s=n.pki.certificateFromPem(s)),r=s.issuer.attributes,i=s.serialNumber}var o=t.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"===typeof o&&(o=n.pki.privateKeyFromPem(o));var a=t.digestAlgorithm||n.pki.oids.sha1;switch(a){case n.pki.oids.sha1:case n.pki.oids.sha256:case n.pki.oids.sha384:case n.pki.oids.sha512:case n.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+a)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var l=!1,u=!1,h=0;h{var n=r(392);r(5049),r(3877);var i=n.asn1,s=e.exports=n.pkcs7asn1=n.pkcs7asn1||{};n.pkcs7=n.pkcs7||{},n.pkcs7.asn1=s;var o={name:"ContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};s.contentInfoValidator=o;var a={name:"EncryptedContentInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};s.envelopedDataValidator={name:"EnvelopedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(a)},s.encryptedDataValidator={name:"EncryptedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"}].concat(a)};var c={name:"SignerInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};s.signedDataValidator={name:"SignedData",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},o,{name:"SignedData.Certificates",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,capture:"signerInfos",optional:!0,value:[c]}]},s.recipientInfoValidator={name:"RecipientInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:i.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:i.Class.UNIVERSAL,type:i.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]}},5132:(e,t,r)=>{var n=r(392);r(3877),r(3055),r(3860),function(){if(n.prime)e.exports=n.prime;else{var t=e.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],s=new r(null);s.fromInt(30);var o=function(e,t){return e|t};t.generateProbablePrime=function(e,t,i){"function"===typeof t&&(i=t,t={});var s=(t=t||{}).algorithm||"PRIMEINC";"string"===typeof s&&(s={name:s}),s.options=s.options||{};var o=t.prng||n.random,c={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;re&&(o=l(e,t));var f=o.toString(16);i.target.postMessage({hex:f,workLoad:u}),o.dAddOffset(h,0)}}}f()}(e,t,i,s);return a(e,t,i,s)}(e,c,s.options,i);throw new Error("Invalid prime generation algorithm: "+s.name)}}function a(e,t,r,n){var i=l(e,t),s=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(s=r.millerRabinTests);var o=10;"maxBlockTime"in r&&(o=r.maxBlockTime),c(i,e,t,0,s,o,n)}function c(e,t,r,s,o,a,u){var h=+new Date;do{if(e.bitLength()>t&&(e=l(t,r)),e.isProbablePrime(o))return u(null,e);e.dAddOffset(i[s++%8],0)}while(a<0||+new Date-h{var n=r(392);r(3877);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||process.versions["node-webkit"]||(i=r(5819)),(e.exports=n.prng=n.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,s=new Array(32),o=0;o<32;++o)s[o]=r.create();function a(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r===0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function l(e){var t=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(t=function(e){return i.getRandomValues(e)});var s=n.util.createBuffer();if(t)for(;s.length()>16)))<<16,d=4294967295&(u=(2147483647&(u+=l>>15))+(u>>31));for(c=0;c<3;++c)h=d>>>(c<<3),h^=Math.floor(256*Math.random()),s.putByte(255&h)}return s.getBytes(e)}return t.pools=s,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var i=t.plugin.cipher,s=t.plugin.increment,o=t.plugin.formatKey,a=t.plugin.formatSeed,l=n.util.createBuffer();t.key=null,function u(h){if(h)return r(h);if(l.length()>=e)return r(null,l.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return n.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),c(),e()}))}(u)}));var d=i(t.key,t.seed);t.generated+=d.length,l.putBytes(d),t.key=o(i(t.key,s(t.seed))),t.seed=a(i(t.key,t.seed)),n.util.setImmediate(u)}()},t.generateSync=function(e){var r=t.plugin.cipher,i=t.plugin.increment,s=t.plugin.formatKey,o=t.plugin.formatSeed;t.key=null;for(var c=n.util.createBuffer();c.length()1048575&&(t.key=null),null===t.key&&a();var l=r(t.key,t.seed);t.generated+=l.length,c.putBytes(l),t.key=s(r(t.key,i(t.seed))),t.seed=o(r(t.key,t.seed))}return c.getBytes(e)},i?(t.seedFile=function(e,t){i.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return i.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,l(e))}catch(r){t(r)}},t.seedFileSync=l),t.collect=function(e){for(var r=e.length,n=0;n>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}},325:(e,t,r)=>{var n=r(392);r(3860),r(3877),(e.exports=n.pss=n.pss||{}).create=function(e){3===arguments.length&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t,r=e.md,i=e.mgf,s=r.digestLength,o=e.salt||null;if("string"===typeof o&&(o=n.util.createBuffer(o)),"saltLength"in e)t=e.saltLength;else{if(null===o)throw new Error("Salt length not specified or specific salt not given.");t=o.length()}if(null!==o&&o.length()!==t)throw new Error("Given salt length does not match length of given salt.");var a=e.prng||n.random,c={encode:function(e,c){var l,u,h=c-1,d=Math.ceil(h/8),f=e.digest().getBytes();if(d>8*d-h&255;return(w=String.fromCharCode(w.charCodeAt(0)&~E)+w.substr(1))+g+String.fromCharCode(188)},verify:function(e,o,a){var c,l=a-1,u=Math.ceil(l/8);if(o=o.substr(-u),u>8*u-l&255;if(0!==(d.charCodeAt(0)&p))throw new Error("Bits beyond keysize not zero as expected.");var g=i.generate(f,h),y="";for(c=0;c{var n=r(392);r(8605),r(7404),r(6140),r(3877),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),s=n.util.createBuffer();function o(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),s.putInt32(i[0]),s.putInt32(i[1]),s.putInt32(i[2]),s.putInt32(i[3]),s.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var a=o(),c=null,l=n.util.globalScope,u=l.crypto||l.msCrypto;if(u&&u.getRandomValues&&(c=function(e){return u.getRandomValues(e)}),n.options.usePureJavaScript||!n.util.isNodejs&&!c){if("undefined"===typeof window||window.document,a.collectInt(+new Date,32),"undefined"!==typeof navigator){var h="";for(var d in navigator)try{"string"==typeof navigator[d]&&(h+=navigator[d])}catch(f){}a.collect(h),h=null}t&&(t().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),t().keypress((function(e){a.collectInt(e.charCode,8)})))}if(n.random)for(var d in a)n.random[d]=a[d];else n.random=a;n.random.createInstance=o,e.exports=n.random}("undefined"!==typeof jQuery?jQuery:null)},654:(e,t,r)=>{var n=r(392);r(3877);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],s=[1,2,3,5],o=function(e,t){return e<>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){"string"===typeof e&&(e=n.util.createBuffer(e)),t=t||128;var r,s=e,o=e.length(),a=t,c=Math.ceil(a/8),l=255>>(7&a);for(r=o;r<128;r++)s.putByte(i[s.at(r-1)+s.at(r-o)&255]);for(s.setAt(128-c,i[s.at(128-c)&l]),r=127-c;r>=0;r--)s.setAt(r,i[s.at(r+1)^s.at(r+c)]);return s};var c=function(e,t,r){var i,c,l,u,h=!1,d=null,f=null,p=null,g=[];for(e=n.rc2.expandKey(e,t),l=0;l<64;l++)g.push(e.getInt16Le());r?(i=function(e){for(l=0;l<4;l++)e[l]+=g[u]+(e[(l+3)%4]&e[(l+2)%4])+(~e[(l+3)%4]&e[(l+1)%4]),e[l]=o(e[l],s[l]),u++},c=function(e){for(l=0;l<4;l++)e[l]+=g[63&e[(l+3)%4]]}):(i=function(e){for(l=3;l>=0;l--)e[l]=a(e[l],s[l]),e[l]-=g[u]+(e[(l+3)%4]&e[(l+2)%4])+(~e[(l+3)%4]&e[(l+1)%4]),u--},c=function(e){for(l=3;l>=0;l--)e[l]-=g[63&e[(l+3)%4]]});var y=function(e){var t=[];for(l=0;l<4;l++){var n=d.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}u=r?0:63;for(var i=0;i=8;)y([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,d,!r);else{var n=8===d.length()?8:8-d.length();d.fillWithByte(n,n)}if(t&&(h=!0,m.update()),!r&&(t=0===d.length()))if(e)t=e(8,f,!r);else{var i=f.length(),s=f.at(i-1);s>i?t=!1:f.truncate(s)}return t}}};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},5493:(e,t,r)=>{var n=r(392);if(r(5049),r(3055),r(2886),r(2627),r(5132),r(3860),r(3877),"undefined"===typeof i)var i=n.jsbn.BigInteger;var s=n.util.isNodejs?r(5819):null,o=n.asn1,a=n.util;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var c=n.pki,l=[6,4,2,4,2,4,6,2],u={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},h={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},d={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},f=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p={name:"DigestInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},g=function(e){var t;if(!(e.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=c.oids[e.algorithm];var n=o.oidToDer(t).getBytes(),i=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);s.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,n)),s.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var a=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(s),i.value.push(a),o.toDer(i).getBytes()},y=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var s;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{s=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(s.compareTo(t.n)>=0||!s.gcd(t.n).equals(i.ONE));for(var o=(e=e.multiply(s.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);o.compareTo(a)<0;)o=o.add(t.p);var c=o.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return c=c.multiply(s.modInverse(t.n)).mod(t.n)};function m(e,t,r){var i=n.util.createBuffer(),s=Math.ceil(t.n.bitLength()/8);if(e.length>s-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=e.length,o.max=s-11,o}i.putByte(0),i.putByte(r);var a,c=s-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var l=0;l0;){var u=0,h=n.random.getBytes(c);for(l=0;l1;){if(255!==o.getByte()){--o.read;break}++l}else if(2===c)for(l=0;o.length()>1;){if(0===o.getByte()){--o.read;break}++l}if(0!==o.getByte()||l!==s-3-o.length())throw new Error("Encryption block is invalid.");return o.getBytes()}function b(e,t,r){"function"===typeof t&&(r=t,t={});var s={algorithm:{name:(t=t||{}).algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};function o(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?l(t,e.q):void a(e.qBits,l))}))}function a(e,t){n.prime.generateProbablePrime(e,s,t)}function l(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var s=e.p;e.p=e.q,e.q=s}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void o();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void a(e.qBits,l);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void o();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,l);var u=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,u,e.p,e.q,u.mod(e.p1),u.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}"prng"in t&&(s.prng=t.prng),o()}function w(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=n.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0===(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128===(128&r.charCodeAt(1)))?r.substr(1):r}function E(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function _(e){return n.util.isNodejs&&"function"===typeof s[e]}function S(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.crypto&&"object"===typeof a.globalScope.crypto.subtle&&"function"===typeof a.globalScope.crypto.subtle[e]}function I(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.msCrypto&&"object"===typeof a.globalScope.msCrypto.subtle&&"function"===typeof a.globalScope.msCrypto.subtle[e]}function C(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i0;)u.putByte(0),--h;return u.putBytes(n.util.hexToBytes(l)),u.getBytes()},c.rsa.decrypt=function(e,t,r,s){var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=o,a}var c=new i(n.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var l=y(c,t,r).toString(16),u=n.util.createBuffer(),h=o-Math.ceil(l.length/2);h>0;)u.putByte(0),--h;return u.putBytes(n.util.hexToBytes(l)),!1!==s?v(u.getBytes(),t,r):u.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"===typeof e&&(e=parseInt(e,10)),e=e||2048;var s,o=(r=r||{}).prng||n.random,a={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;r>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(s.eInt),s},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,s=0,o=function(e,t){return e|t},a=+new Date,u=0;null===e.keys&&(t<=0||uh?e.pqState=0:e.num.isProbablePrime(E(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(l[s++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var f=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}u+=(n=+new Date)-a,a=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,i){if(1===arguments.length?"object"===typeof e?(r=e,e=void 0):"function"===typeof e&&(i=e,e=void 0):2===arguments.length?"number"===typeof e?"function"===typeof t?(i=t,t=void 0):"number"!==typeof t&&(r=t,t=void 0):(r=e,i=t,e=void 0,t=void 0):3===arguments.length&&("number"===typeof t?"function"===typeof r&&(i=r,r=void 0):(i=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(i){if(_("generateKeyPair"))return s.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return i(e);i(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(S("generateKey")&&S("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:C(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return a.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){i(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(e)));i(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(I("generateKey")&&I("exportKey")){var l=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:C(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return l.oncomplete=function(e){var t=e.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(t)));i(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){i(e)}},void(l.onerror=function(e){i(e)})}}else if(_("generateKeyPairSync")){var u=s.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(u.privateKey),publicKey:c.publicKeyFromPem(u.publicKey)}}var h=c.rsa.createKeyPairGenerationState(e,t,r);if(!i)return c.rsa.stepKeyPairGenerationState(h,0),h.keys;b(h,r,i)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,i){if("string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return m(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"===typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var s=t.encode(e,r,!0);return c.rsa.encrypt(s,r,!0)},verify:function(e,t,i,s){"string"===typeof i?i=i.toUpperCase():void 0===i&&(i="RSASSA-PKCS1-V1_5"),void 0===s&&(s={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in s||(s._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===i?i={verify:function(e,t){t=v(t,r,!0);var i=o.fromDer(t,{parseAllBytes:s._parseAllDigestBytes}),a={},c=[];if(!o.validate(i,p,a,c))throw(l=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=c,l;var l,u=o.derToOid(a.algorithmIdentifier);if(u!==n.oids.md2&&u!==n.oids.md5&&u!==n.oids.sha1&&u!==n.oids.sha224&&u!==n.oids.sha256&&u!==n.oids.sha384&&u!==n.oids.sha512&&u!==n.oids["sha512-224"]&&u!==n.oids["sha512-256"])throw(l=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=u,l;if((u===n.oids.md2||u===n.oids.md5)&&!("parameters"in a))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return e===a.digest}}:"NONE"!==i&&"NULL"!==i&&null!==i||(i={verify:function(e,t){return e===(t=v(t,r,!0))}});var a=c.rsa.decrypt(t,r,!0,!1);return i.verify(e,a,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,i,s,o,a,l){var u={n:e,e:t,d:r,p:i,q:s,dP:o,dQ:a,qInv:l,decrypt:function(e,t,r){"string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(e,u,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:v};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(i,u,!1)},sign:function(e,t){var r=!1;"string"===typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:g},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,u.n.bitLength());return c.rsa.encrypt(n,u,r)}};return u},c.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,s,a,l,d,f,p,g={},y=[];if(o.validate(e,u,g,y)&&(e=o.fromDer(n.util.createBuffer(g.privateKey))),g={},y=[],!o.validate(e,h,g,y)){var m=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw m.errors=y,m}return t=n.util.createBuffer(g.privateKeyModulus).toHex(),r=n.util.createBuffer(g.privateKeyPublicExponent).toHex(),s=n.util.createBuffer(g.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(g.privateKeyPrime1).toHex(),l=n.util.createBuffer(g.privateKeyPrime2).toHex(),d=n.util.createBuffer(g.privateKeyExponent1).toHex(),f=n.util.createBuffer(g.privateKeyExponent2).toHex(),p=n.util.createBuffer(g.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(t,16),new i(r,16),new i(s,16),new i(a,16),new i(l,16),new i(d,16),new i(f,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(o.validate(e,f,t,r)){var s,a=o.derToOid(t.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(s=new Error("Cannot read public key. Unknown OID.")).oid=a,s;e=t.rsaPublicKey}if(r=[],!o.validate(e,d,t,r))throw(s=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,s;var l=n.util.createBuffer(t.publicKeyModulus).toHex(),u=n.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(l,16),new i(u,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.e))])}},928:(e,t,r)=>{var n=r(392);r(29),r(3877);var i=e.exports=n.sha1=n.sha1||{};n.md.sha1=n.md.algorithms.sha1=i,i.create=function(){o||(s=String.fromCharCode(128),s+=n.util.fillString(String.fromCharCode(0),64),o=!0);var e=null,t=n.util.createBuffer(),r=new Array(80),i={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,s=0;s>>0,c>>>0];for(var l=i.fullMessageLength.length-1;l>=0;--l)i.fullMessageLength[l]+=c[1],c[1]=c[0]+(i.fullMessageLength[l]/4294967296>>>0),i.fullMessageLength[l]=i.fullMessageLength[l]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(s),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(t.bytes());var c,l=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-l));for(var u=8*i.fullMessageLength[0],h=0;h>>0,o.putInt32(u>>>0),u=c>>>0;o.putInt32(u);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(d,r,o);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f},i};var s=null,o=!1;function a(e,t,r){for(var n,i,s,o,a,c,l,u=r.length();u>=64;){for(i=e.h0,s=e.h1,o=e.h2,a=e.h3,c=e.h4,l=0;l<16;++l)n=r.getInt32(),t[l]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<20;++l)n=(n=t[l-3]^t[l-8]^t[l-14]^t[l-16])<<1|n>>>31,t[l]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<32;++l)n=(n=t[l-3]^t[l-8]^t[l-14]^t[l-16])<<1|n>>>31,t[l]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<40;++l)n=(n=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|n>>>30,t[l]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<60;++l)n=(n=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|n>>>30,t[l]=n,n=(i<<5|i>>>27)+(s&o|a&(s^o))+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;l<80;++l)n=(n=t[l-6]^t[l-16]^t[l-28]^t[l-32])<<2|n>>>30,t[l]=n,n=(i<<5|i>>>27)+(s^o^a)+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+s|0,e.h2=e.h2+o|0,e.h3=e.h3+a|0,e.h4=e.h4+c|0,u-=64}}},7404:(e,t,r)=>{var n=r(392);r(29),r(3877);var i=e.exports=n.sha256=n.sha256||{};n.md.sha256=n.md.algorithms.sha256=i,i.create=function(){o||(s=String.fromCharCode(128),s+=n.util.fillString(String.fromCharCode(0),64),a=[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],o=!0);var e=null,t=n.util.createBuffer(),r=new Array(64),i={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,s=0;s>>0,a>>>0];for(var l=i.fullMessageLength.length-1;l>=0;--l)i.fullMessageLength[l]+=a[1],a[1]=a[0]+(i.fullMessageLength[l]/4294967296>>>0),i.fullMessageLength[l]=i.fullMessageLength[l]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(s),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(t.bytes());var a,l=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-l));for(var u=8*i.fullMessageLength[0],h=0;h>>0,o.putInt32(u>>>0),u=a>>>0;o.putInt32(u);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(d,r,o);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f.putInt32(d.h5),f.putInt32(d.h6),f.putInt32(d.h7),f},i};var s=null,o=!1,a=null;function c(e,t,r){for(var n,i,s,o,c,l,u,h,d,f,p,g,y,m=r.length();m>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(l=e.h0,u=e.h1,h=e.h2,d=e.h3,f=e.h4,p=e.h5,g=e.h6,y=e.h7,c=0;c<64;++c)s=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),o=l&u|h&(l^u),n=y+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(g^f&(p^g))+a[c]+t[c],y=g,g=p,p=f,f=d+n>>>0,d=h,h=u,u=l,l=n+(i=s+o)>>>0;e.h0=e.h0+l|0,e.h1=e.h1+u|0,e.h2=e.h2+h|0,e.h3=e.h3+d|0,e.h4=e.h4+f|0,e.h5=e.h5+p|0,e.h6=e.h6+g|0,e.h7=e.h7+y|0,m-=64}}},4770:(e,t,r)=>{var n=r(392);r(29),r(3877);var i=e.exports=n.sha512=n.sha512||{};n.md.sha512=n.md.algorithms.sha512=i;var s=n.sha384=n.sha512.sha384=n.sha512.sha384||{};s.create=function(){return i.create("SHA-384")},n.md.sha384=n.md.algorithms.sha384=s,n.sha512.sha256=n.sha512.sha256||{create:function(){return i.create("SHA-512/256")}},n.md["sha512/256"]=n.md.algorithms["sha512/256"]=n.sha512.sha256,n.sha512.sha224=n.sha512.sha224||{create:function(){return i.create("SHA-512/224")}},n.md["sha512/224"]=n.md.algorithms["sha512/224"]=n.sha512.sha224,i.create=function(e){if(a||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),128),c=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(l={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],l["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],l["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],l["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),"undefined"===typeof e&&(e="SHA-512"),!(e in l))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=l[e],r=null,i=n.util.createBuffer(),s=new Array(80),h=0;h<80;++h)s[h]=new Array(2);var d=64;switch(e){case"SHA-384":d=48;break;case"SHA-512/256":d=32;break;case"SHA-512/224":d=28}var f={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var e=f.messageLengthSize/4,s=0;s>>0,o>>>0];for(var a=f.fullMessageLength.length-1;a>=0;--a)f.fullMessageLength[a]+=o[1],o[1]=o[0]+(f.fullMessageLength[a]/4294967296>>>0),f.fullMessageLength[a]=f.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return i.putBytes(e),u(r,s,i),(i.read>2048||0===i.length())&&i.compact(),f},f.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,c=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;t.putBytes(o.substr(0,f.blockLength-c));for(var l=8*f.fullMessageLength[0],h=0;h>>0,t.putInt32(l>>>0),l=a>>>0;t.putInt32(l);var d=new Array(r.length);for(h=0;h=128;){for(P=0;P<16;++P)t[P][0]=r.getInt32()>>>0,t[P][1]=r.getInt32()>>>0;for(;P<80;++P)n=(((D=(O=t[P-2])[0])>>>19|(N=O[1])<<13)^(N>>>29|D<<3)^D>>>6)>>>0,i=((D<<13|N>>>19)^(N<<3|D>>>29)^(D<<26|N>>>6))>>>0,s=(((D=(x=t[P-15])[0])>>>1|(N=x[1])<<31)^(D>>>8|N<<24)^D>>>7)>>>0,o=((D<<31|N>>>1)^(D<<24|N>>>8)^(D<<25|N>>>7))>>>0,L=t[P-7],B=t[P-16],N=i+L[1]+o+B[1],t[P][0]=n+L[0]+s+B[0]+(N/4294967296>>>0)>>>0,t[P][1]=N>>>0;for(p=e[0][0],g=e[0][1],y=e[1][0],m=e[1][1],v=e[2][0],b=e[2][1],w=e[3][0],E=e[3][1],_=e[4][0],S=e[4][1],I=e[5][0],C=e[5][1],A=e[6][0],T=e[6][1],k=e[7][0],R=e[7][1],P=0;P<80;++P)u=((_>>>14|S<<18)^(_>>>18|S<<14)^(S>>>9|_<<23))>>>0,h=(A^_&(I^A))>>>0,a=((p>>>28|g<<4)^(g>>>2|p<<30)^(g>>>7|p<<25))>>>0,l=((p<<4|g>>>28)^(g<<30|p>>>2)^(g<<25|p>>>7))>>>0,d=(p&y|v&(p^y))>>>0,f=(g&m|b&(g^m))>>>0,N=R+(((_<<18|S>>>14)^(_<<14|S>>>18)^(S<<23|_>>>9))>>>0)+((T^S&(C^T))>>>0)+c[P][1]+t[P][1],n=k+u+h+c[P][0]+t[P][0]+(N/4294967296>>>0)>>>0,i=N>>>0,s=a+d+((N=l+f)/4294967296>>>0)>>>0,o=N>>>0,k=A,R=T,A=I,T=C,I=_,C=S,_=w+n+((N=E+i)/4294967296>>>0)>>>0,S=N>>>0,w=v,E=b,v=y,b=m,y=p,m=g,p=n+s+((N=i+o)/4294967296>>>0)>>>0,g=N>>>0;N=e[0][1]+g,e[0][0]=e[0][0]+p+(N/4294967296>>>0)>>>0,e[0][1]=N>>>0,N=e[1][1]+m,e[1][0]=e[1][0]+y+(N/4294967296>>>0)>>>0,e[1][1]=N>>>0,N=e[2][1]+b,e[2][0]=e[2][0]+v+(N/4294967296>>>0)>>>0,e[2][1]=N>>>0,N=e[3][1]+E,e[3][0]=e[3][0]+w+(N/4294967296>>>0)>>>0,e[3][1]=N>>>0,N=e[4][1]+S,e[4][0]=e[4][0]+_+(N/4294967296>>>0)>>>0,e[4][1]=N>>>0,N=e[5][1]+C,e[5][0]=e[5][0]+I+(N/4294967296>>>0)>>>0,e[5][1]=N>>>0,N=e[6][1]+T,e[6][0]=e[6][0]+A+(N/4294967296>>>0)>>>0,e[6][1]=N>>>0,N=e[7][1]+R,e[7][0]=e[7][0]+k+(N/4294967296>>>0)>>>0,e[7][1]=N>>>0,M-=128}}},3877:(e,t,r)=>{var n=r(392),i=r(5754),s=e.exports=n.util=n.util||{};function o(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function a(e){if(this.data="",this.read=0,"string"===typeof e)this.data=e;else if(s.isArrayBuffer(e)||s.isArrayBufferView(e))if("undefined"!==typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(n){for(var r=0;r15?(r=Date.now(),o(e)):(t.push(e),1===t.length&&i.setAttribute("a",n=!n))}}s.nextTick=s.setImmediate}(),s.isNodejs="undefined"!==typeof process&&process.versions&&process.versions.node,s.globalScope=s.isNodejs?r.g:"undefined"===typeof self?window:self,s.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s.isArrayBuffer=function(e){return"undefined"!==typeof ArrayBuffer&&e instanceof ArrayBuffer},s.isArrayBufferView=function(e){return e&&s.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},s.ByteBuffer=a,s.ByteStringBuffer=a;s.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},s.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},s.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},s.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},s.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},s.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},s.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(s.encodeUtf8(e))},s.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},s.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},s.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},s.ByteStringBuffer.prototype.putInt=function(e,t){o(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},s.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<0);return t},s.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},s.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},s.ByteStringBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},s.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},s.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},s.ByteStringBuffer.prototype.copy=function(){var e=s.createBuffer(this.data);return e.read=this.read,e},s.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},s.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},s.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},s.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},s.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},s.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},s.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},s.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},s.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},s.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},s.DataBuffer.prototype.putInt=function(e,t){o(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},s.DataBuffer.prototype.putSignedInt=function(e,t){return o(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},s.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<=r&&(t-=r<<1),t},s.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},s.DataBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},s.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},s.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},s.DataBuffer.prototype.copy=function(){return new s.DataBuffer(this)},s.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},s.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},s.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},s.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},s.xorBytes=function(e,t,r){for(var n="",i="",s="",o=0,a=0;r>0;--r,++o)i=e.charCodeAt(o)^t.charCodeAt(o),a>=10&&(n+=s,s="",a=0),s+=String.fromCharCode(i),++a;return n+=s},s.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],u="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";s.encode64=function(e,t){for(var r,n,i,s="",o="",a=0;a>2),s+=c.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=c.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":c.charAt(63&i)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},s.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,s="",o=0;o>4),64!==n&&(s+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(s+=String.fromCharCode((3&n)<<6|i)));return s},s.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},s.decodeUtf8=function(e){return decodeURIComponent(escape(e))},s.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:i.encode,decode:i.decode}},s.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},s.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,s=0;s>2),s+=c.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=c.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":c.charAt(63&i)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},s.binary.base64.decode=function(e,t,r){var n,i,s,o,a=t;a||(a=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,u=r=r||0;c>4,64!==s&&(a[u++]=(15&i)<<4|s>>2,64!==o&&(a[u++]=(3&s)<<6|o));return t?u-r:a.subarray(0,u)},s.binary.base58.encode=function(e,t){return s.binary.baseN.encode(e,u,t)},s.binary.base58.decode=function(e,t){return s.binary.baseN.decode(e,u,t)},s.text={utf8:{},utf16:{}},s.text.utf8.encode=function(e,t,r){e=s.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o0&&s.push(r),o=n.lastIndex;var a=t[0][1];switch(a){case"s":case"o":i");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(e.substring(o)),s.join("")},s.formatNumber=function(e,t,r,n){var i=e,s=isNaN(t=Math.abs(t))?2:t,o=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",l=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",u=l.length>3?l.length%3:0;return c+(u?l.substr(0,u)+a:"")+l.substr(u).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(i-l).toFixed(s).slice(2):"")},s.formatSize=function(e){return e=e>=1073741824?s.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?s.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?s.formatNumber(e/1024,0)+" KiB":s.formatNumber(e,0)+" bytes"},s.bytesFromIP=function(e){return-1!==e.indexOf(".")?s.bytesFromIPv4(e):-1!==e.indexOf(":")?s.bytesFromIPv6(e):null},s.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=s.createBuffer(),r=0;rr[n].end-r[n].start&&(n=r.length-1)):r.push({start:c,end:c})}t.push(o)}if(r.length>0){var l=r[n];l.end-l.start>0&&(t.splice(l.start,l.end-l.start+1,""),0===l.start&&t.unshift(""),7===l.end&&t.push(""))}return t.join(":")},s.estimateCores=function(e,t){if("function"===typeof e&&(t=e,e={}),e=e||{},"cores"in s&&!e.update)return t(null,s.cores);if("undefined"!==typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return s.cores=navigator.hardwareConcurrency,t(null,s.cores);if("undefined"===typeof Worker)return s.cores=1,t(null,s.cores);if("undefined"===typeof Blob)return s.cores=2,t(null,s.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()a.st&&i.sti.st&&a.st{var n=r(392);r(8605),r(5049),r(1400),r(29),r(1746),r(2886),r(6193),r(325),r(5493),r(3877);var i=n.asn1,s=e.exports=n.pki=n.pki||{},o=s.oids,a={};a.CN=o.commonName,a.commonName="CN",a.C=o.countryName,a.countryName="C",a.L=o.localityName,a.localityName="L",a.ST=o.stateOrProvinceName,a.stateOrProvinceName="ST",a.O=o.organizationName,a.organizationName="O",a.OU=o.organizationalUnitName,a.organizationalUnitName="OU",a.E=o.emailAddress,a.emailAddress="E";var c=n.pki.rsa.publicKeyValidator,l={name:"Certificate",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:i.Class.UNIVERSAL,type:i.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:i.Class.UNIVERSAL,type:i.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:i.Class.UNIVERSAL,type:i.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:i.Class.UNIVERSAL,type:i.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},c,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:i.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:i.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},u={name:"rsapss",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:i.Class.UNIVERSAL,type:i.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:i.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:i.Class.UNIVERSAL,type:i.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:i.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:i.Class.UNIVERSAL,type:i.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:i.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:i.Class.UNIVERSAL,type:i.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},h={name:"CertificationRequestInfo",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:i.Class.UNIVERSAL,type:i.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},c,{name:"CertificationRequestInfo.attributes",tagClass:i.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:i.Class.UNIVERSAL,type:i.Type.SET,constructed:!0}]}]}]},d={name:"CertificationRequest",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[h,{name:"CertificationRequest.signatureAlgorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:i.Class.UNIVERSAL,type:i.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:i.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:i.Class.UNIVERSAL,type:i.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function f(e,t){"string"===typeof t&&(t={shortName:t});for(var r,n=null,i=0;null===n&&i128)throw new Error('Invalid "nsComment" content.');e.value=i.create(i.Class.UNIVERSAL,i.Type.IA5STRING,!1,e.comment)}else if("subjectKeyIdentifier"===e.name&&t.cert){var f=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=f.toHex(),e.value=i.create(i.Class.UNIVERSAL,i.Type.OCTETSTRING,!1,f.getBytes())}else if("authorityKeyIdentifier"===e.name&&t.cert){e.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);u=e.value.value;if(e.keyIdentifier){var p=!0===e.keyIdentifier?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;u.push(i.create(i.Class.CONTEXT_SPECIFIC,0,!1,p))}if(e.authorityCertIssuer){var g=[i.create(i.Class.CONTEXT_SPECIFIC,4,!0,[m(!0===e.authorityCertIssuer?t.cert.issuer:e.authorityCertIssuer)])];u.push(i.create(i.Class.CONTEXT_SPECIFIC,1,!0,g))}if(e.serialNumber){var y=n.util.hexToBytes(!0===e.serialNumber?t.cert.serialNumber:e.serialNumber);u.push(i.create(i.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if("cRLDistributionPoints"===e.name){e.value=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);u=e.value.value;var v,b=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]),w=i.create(i.Class.CONTEXT_SPECIFIC,0,!0,[]);for(d=0;d2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(h.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(c.validity.notBefore=h[0],c.validity.notAfter=h[1],c.tbsCertificate=r.tbsCertificate,t){c.md=g({signatureOid:c.signatureOid,type:"certificate"});var d=i.toDer(c.tbsCertificate);c.md.update(d.getBytes())}var y=n.md.sha1.create(),m=i.toDer(r.certIssuer);y.update(m.getBytes()),c.issuer.getField=function(e){return f(c.issuer,e)},c.issuer.addField=function(e){v([e]),c.issuer.attributes.push(e)},c.issuer.attributes=s.RDNAttributesAsArray(r.certIssuer),r.certIssuerUniqueId&&(c.issuer.uniqueId=r.certIssuerUniqueId),c.issuer.hash=y.digest().toHex();var b=n.md.sha1.create(),w=i.toDer(r.certSubject);return b.update(w.getBytes()),c.subject.getField=function(e){return f(c.subject,e)},c.subject.addField=function(e){v([e]),c.subject.attributes.push(e)},c.subject.attributes=s.RDNAttributesAsArray(r.certSubject),r.certSubjectUniqueId&&(c.subject.uniqueId=r.certSubjectUniqueId),c.subject.hash=b.digest().toHex(),r.certExtensions?c.extensions=s.certificateExtensionsFromAsn1(r.certExtensions):c.extensions=[],c.publicKey=s.publicKeyFromAsn1(r.subjectPublicKeyInfo),c},s.certificateExtensionsFromAsn1=function(e){for(var t=[],r=0;r1&&(r=c.value.charCodeAt(1),s=c.value.length>2?c.value.charCodeAt(2):0),t.digitalSignature=128===(128&r),t.nonRepudiation=64===(64&r),t.keyEncipherment=32===(32&r),t.dataEncipherment=16===(16&r),t.keyAgreement=8===(8&r),t.keyCertSign=4===(4&r),t.cRLSign=2===(2&r),t.encipherOnly=1===(1&r),t.decipherOnly=128===(128&s)}else if("basicConstraints"===t.name){(c=i.fromDer(t.value)).value.length>0&&c.value[0].type===i.Type.BOOLEAN?t.cA=0!==c.value[0].value.charCodeAt(0):t.cA=!1;var a=null;c.value.length>0&&c.value[0].type===i.Type.INTEGER?a=c.value[0].value:c.value.length>1&&(a=c.value[1].value),null!==a&&(t.pathLenConstraint=i.derToInteger(a))}else if("extKeyUsage"===t.name)for(var c=i.fromDer(t.value),l=0;l1&&(r=c.value.charCodeAt(1)),t.client=128===(128&r),t.server=64===(64&r),t.email=32===(32&r),t.objsign=16===(16&r),t.reserved=8===(8&r),t.sslCA=4===(4&r),t.emailCA=2===(2&r),t.objCA=1===(1&r)}else if("subjectAltName"===t.name||"issuerAltName"===t.name){var h;t.altNames=[];c=i.fromDer(t.value);for(var d=0;d=_&&e0&&o.value.push(s.certificateExtensionsToAsn1(e.extensions)),o},s.getCertificationRequestInfo=function(e){return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.INTEGER,!1,i.integerToDer(e.version).getBytes()),m(e.subject),s.publicKeyToAsn1(e.publicKey),E(e)])},s.distinguishedNameToAsn1=function(e){return m(e)},s.certificateToAsn1=function(e){var t=e.tbsCertificate||s.getTBSCertificate(e);return i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[t,i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[i.create(i.Class.UNIVERSAL,i.Type.OID,!1,i.oidToDer(e.signatureOid).getBytes()),w(e.signatureOid,e.signatureParameters)]),i.create(i.Class.UNIVERSAL,i.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},s.certificateExtensionsToAsn1=function(e){var t=i.create(i.Class.CONTEXT_SPECIFIC,3,!0,[]),r=i.create(i.Class.UNIVERSAL,i.Type.SEQUENCE,!0,[]);t.value.push(r);for(var n=0;nu.validity.notAfter)&&(c={message:"Certificate is not valid yet or has expired.",error:s.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:o}),null===c){if(null===(h=t[0]||e.getIssuer(u))&&u.isIssuer(u)&&(d=!0,h=u),h){var f=h;n.util.isArray(f)||(f=[f]);for(var p=!1;!p&&f.length>0;){h=f.shift();try{p=h.verify(u)}catch(_){}}p||(c={message:"Certificate signature is invalid.",error:s.certificateError.bad_certificate})}null!==c||h&&!d||e.hasCertificate(u)||(c={message:"Certificate is not trusted.",error:s.certificateError.unknown_ca})}if(null===c&&h&&!u.isIssuer(h)&&(c={message:"Certificate issuer is invalid.",error:s.certificateError.bad_certificate}),null===c)for(var g={keyUsage:!0,basicConstraints:!0},y=0;null===c&&yv.pathLenConstraint&&(c={message:"Certificate basicConstraints pathLenConstraint violated.",error:s.certificateError.bad_certificate})}var w=null===c||c.error,E=r.verify?r.verify(w,l,i):w;if(!0!==E)throw!0===w&&(c={message:"The application rejected the certificate.",error:s.certificateError.bad_certificate}),(E||0===E)&&("object"!==typeof E||n.util.isArray(E)?"string"===typeof E&&(c.error=E):(E.message&&(c.message=E.message),E.error&&(c.error=E.error))),c;c=null,a=!1,++l}while(t.length>0);return!0}},9879:(e,t,r)=>{const n=r(5125),i=r(2673);e.exports=class{constructor(){this._buffer=new n,this._waitingConsumers=new n}push(e){const{promise:t,resolve:r}=i();return this._buffer.push({chunk:e,resolve:r}),this._consume(),t}_consume(){for(;!this._waitingConsumers.isEmpty()&&!this._buffer.isEmpty();){const e=this._waitingConsumers.shift(),t=this._buffer.shift();e.resolve(t.chunk),t.resolve()}}shift(){const{promise:e,resolve:t}=i();return this._waitingConsumers.push({resolve:t}),this._consume(),e}isEmpty(){return this._buffer.isEmpty()}}},2673:e=>{"use strict";e.exports=()=>{const e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}},3931:(e,t,r)=>{"use strict";e.exports=r(3794).default},3794:function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=r(7922),s=n(r(8974)),o=n(r(4514)),a=r(7201),c=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map((e=>new i.Netmask(e)));function l(e){return/^::$/.test(e)||/^::1$/.test(e)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}t.default=e=>{if((0,a.isValid)(e)){const t=(0,a.parse)(e);if("ipv4"===t.kind())return function(e){for(let t of c)if(t.contains(e))return!0;return!1}(t.toNormalizedString());if("ipv6"===t.kind())return l(e)}else if((0,o.default)(e)&&s.default.v6().test(e))return l(e)}},4514:(e,t,r)=>{"use strict";const n=r(8974),i=e=>n({exact:!0}).test(e);i.v4=e=>n.v4({exact:!0}).test(e),i.v6=e=>n.v6({exact:!0}).test(e),i.version=e=>i(e)?i.v4(e)?4:6:void 0,e.exports=i},5368:(e,t,r)=>{"use strict";e.exports=r(8154)},1427:e=>{"use strict";e.exports=n;var t,r=/\/|\./;function n(e,t){r.test(e)||(e="google/protobuf/"+e+".proto",t={nested:{google:{nested:{protobuf:{nested:t}}}}}),n[e]=t}n("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),n("duration",{Duration:t={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),n("timestamp",{Timestamp:t}),n("empty",{Empty:{fields:{}}}),n("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),n("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),n("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),n.get=function(e){return n[e]||null}},7276:(e,t,r)=>{"use strict";var n=t,i=r(222),s=r(2440);function o(e,t,r,n){var s=!1;if(t.resolvedType)if(t.resolvedType instanceof i){e("switch(d%s){",n);for(var o=t.resolvedType.values,a=Object.keys(o),c=0;c>>0",n,n);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",n,n);break;case"uint64":l=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",n,n,l)('else if(typeof d%s==="string")',n)("m%s=parseInt(d%s,10)",n,n)('else if(typeof d%s==="number")',n)("m%s=d%s",n,n)('else if(typeof d%s==="object")',n)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",n,n,n,l?"true":"");break;case"bytes":e('if(typeof d%s==="string")',n)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",n,n,n)("else if(d%s.length >= 0)",n)("m%s=d%s",n,n);break;case"string":e("m%s=String(d%s)",n,n);break;case"bool":e("m%s=Boolean(d%s)",n,n)}}return e}function a(e,t,r,n){if(t.resolvedType)t.resolvedType instanceof i?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",n,r,n,n,r,n,n):e("d%s=types[%i].toObject(m%s,o)",n,r,n);else{var s=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",n,n,n,n);break;case"uint64":s=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',n)("d%s=o.longs===String?String(m%s):m%s",n,n,n)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",n,n,n,n,s?"true":"",n);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",n,n,n,n,n);break;default:e("d%s=m%s",n,n)}}return e}n.fromObject=function(e){var t=e.fieldsArray,r=s.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return r("return new this.ctor");r("var m=new this.ctor");for(var n=0;n{"use strict";e.exports=function(e){var t=s.codegen(["r","l"],e.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(e.fieldsArray.filter((function(e){return e.map})).length?",k,value":""))("while(r.pos>>3){");for(var r=0;r>>3){")("case 1: k=r.%s(); break",a.keyType)("case 2:"),void 0===i.basic[c]?t("value=types[%i].decode(r,r.uint32())",r):t("value=r.%s()",c),t("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==i.long[a.keyType]?t('%s[typeof k==="object"?util.longToHash(k):k]=value',l):t("%s[k]=value",l)):a.repeated?(t("if(!(%s&&%s.length))",l,l)("%s=[]",l),void 0!==i.packed[c]&&t("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos{"use strict";e.exports=function(e){for(var t,r=s.codegen(["m","w"],e.name+"$encode")("if(!w)")("w=Writer.create()"),a=e.fieldsArray.slice().sort(s.compareFieldsById),c=0;c>>0,8|i.mapKey[l.keyType],l.keyType),void 0===d?r("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,t):r(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|d,h,t),r("}")("}")):l.repeated?(r("if(%s!=null&&%s.length){",t,t),l.packed&&void 0!==i.packed[h]?r("w.uint32(%i).fork()",(l.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",t)("w.%s(%s[i])",h,t)("w.ldelim()"):(r("for(var i=0;i<%s.length;++i)",t),void 0===d?o(r,l,u,t+"[i]"):r("w.uint32(%i).%s(%s[i])",(l.id<<3|d)>>>0,h,t)),r("}")):(l.optional&&r("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",t,l.name),void 0===d?o(r,l,u,t):r("w.uint32(%i).%s(%s)",(l.id<<3|d)>>>0,h,t))}return r("return w")};var n=r(222),i=r(8517),s=r(2440);function o(e,t,r,n){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",r,n,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",r,n,(t.id<<3|2)>>>0)}},222:(e,t,r)=>{"use strict";e.exports=o;var n=r(5154);((o.prototype=Object.create(n.prototype)).constructor=o).className="Enum";var i=r(3452),s=r(2440);function o(e,t,r,i,s,o){if(n.call(this,e,r),t&&"object"!==typeof t)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=i,this.comments=s||{},this.valuesOptions=o,this.reserved=void 0,t)for(var a=Object.keys(t),c=0;c{"use strict";e.exports=l;var n=r(5154);((l.prototype=Object.create(n.prototype)).constructor=l).className="Field";var i,s=r(222),o=r(8517),a=r(2440),c=/^required|optional|repeated$/;function l(e,t,r,i,s,l,u){if(a.isObject(i)?(u=s,l=i,i=s=void 0):a.isObject(s)&&(u=l,l=s,s=void 0),n.call(this,e,l),!a.isInteger(t)||t<0)throw TypeError("id must be a non-negative integer");if(!a.isString(r))throw TypeError("type must be a string");if(void 0!==i&&!c.test(i=i.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==s&&!a.isString(s))throw TypeError("extend must be a string");"proto3_optional"===i&&(i="optional"),this.rule=i&&"optional"!==i?i:void 0,this.type=r,this.id=t,this.extend=s||void 0,this.required="required"===i,this.optional=!this.required,this.repeated="repeated"===i,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!a.Long&&void 0!==o.long[r],this.bytes="bytes"===r,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=u}l.fromJSON=function(e,t){return new l(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(l.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),l.prototype.setOption=function(e,t,r){return"packed"===e&&(this._packed=null),n.prototype.setOption.call(this,e,t,r)},l.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return a.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},l.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=o.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof i?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof s&&"string"===typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof s)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=a.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"===typeof this.typeDefault){var e;a.base64.test(this.typeDefault)?a.base64.decode(this.typeDefault,e=a.newBuffer(a.base64.length(this.typeDefault)),0):a.utf8.write(this.typeDefault,e=a.newBuffer(a.utf8.length(this.typeDefault)),0),this.typeDefault=e}return this.map?this.defaultValue=a.emptyObject:this.repeated?this.defaultValue=a.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof i&&(this.parent.ctor.prototype[this.name]=this.defaultValue),n.prototype.resolve.call(this)},l.d=function(e,t,r,n){return"function"===typeof t?t=a.decorateType(t).name:t&&"object"===typeof t&&(t=a.decorateEnum(t).name),function(i,s){a.decorateType(i.constructor).add(new l(s,e,t,r,{default:n}))}},l._configure=function(e){i=e}},4582:(e,t,r)=>{"use strict";var n=e.exports=r(4722);n.build="light",n.load=function(e,t,r){return"function"===typeof t?(r=t,t=new n.Root):t||(t=new n.Root),t.load(e,r)},n.loadSync=function(e,t){return t||(t=new n.Root),t.loadSync(e)},n.encoder=r(6886),n.decoder=r(2715),n.verifier=r(709),n.converter=r(7276),n.ReflectionObject=r(5154),n.Namespace=r(3452),n.Root=r(8622),n.Enum=r(222),n.Type=r(8716),n.Field=r(6734),n.OneOf=r(9794),n.MapField=r(4479),n.Service=r(4173),n.Method=r(4865),n.Message=r(4486),n.wrappers=r(9025),n.types=r(8517),n.util=r(2440),n.ReflectionObject._configure(n.Root),n.Namespace._configure(n.Type,n.Service,n.Enum),n.Root._configure(n.Type),n.Field._configure(n.Type)},4722:(e,t,r)=>{"use strict";var n=t;function i(){n.util._configure(),n.Writer._configure(n.BufferWriter),n.Reader._configure(n.BufferReader)}n.build="minimal",n.Writer=r(7063),n.BufferWriter=r(2815),n.Reader=r(6216),n.BufferReader=r(3557),n.util=r(3097),n.rpc=r(9994),n.roots=r(7907),n.configure=i,i()},8154:(e,t,r)=>{"use strict";var n=e.exports=r(4582);n.build="full",n.tokenize=r(3077),n.parse=r(7781),n.common=r(1427),n.Root._configure(n.Type,n.parse,n.common)},4479:(e,t,r)=>{"use strict";e.exports=o;var n=r(6734);((o.prototype=Object.create(n.prototype)).constructor=o).className="MapField";var i=r(8517),s=r(2440);function o(e,t,r,i,o,a){if(n.call(this,e,t,i,void 0,void 0,o,a),!s.isString(r))throw TypeError("keyType must be a string");this.keyType=r,this.resolvedKeyType=null,this.map=!0}o.fromJSON=function(e,t){return new o(e,t.id,t.keyType,t.type,t.options,t.comment)},o.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return s.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},o.prototype.resolve=function(){if(this.resolved)return this;if(void 0===i.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return n.prototype.resolve.call(this)},o.d=function(e,t,r){return"function"===typeof r?r=s.decorateType(r).name:r&&"object"===typeof r&&(r=s.decorateEnum(r).name),function(n,i){s.decorateType(n.constructor).add(new o(i,e,t,r))}}},4486:(e,t,r)=>{"use strict";e.exports=i;var n=r(3097);function i(e){if(e)for(var t=Object.keys(e),r=0;r{"use strict";e.exports=s;var n=r(5154);((s.prototype=Object.create(n.prototype)).constructor=s).className="Method";var i=r(2440);function s(e,t,r,s,o,a,c,l,u){if(i.isObject(o)?(c=o,o=a=void 0):i.isObject(a)&&(c=a,a=void 0),void 0!==t&&!i.isString(t))throw TypeError("type must be a string");if(!i.isString(r))throw TypeError("requestType must be a string");if(!i.isString(s))throw TypeError("responseType must be a string");n.call(this,e,c),this.type=t||"rpc",this.requestType=r,this.requestStream=!!o||void 0,this.responseType=s,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=l,this.parsedOptions=u}s.fromJSON=function(e,t){return new s(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},s.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return i.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",t?this.comment:void 0,"parsedOptions",this.parsedOptions])},s.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),n.prototype.resolve.call(this))}},3452:(e,t,r)=>{"use strict";e.exports=h;var n=r(5154);((h.prototype=Object.create(n.prototype)).constructor=h).className="Namespace";var i,s,o,a=r(6734),c=r(2440),l=r(9794);function u(e,t){if(e&&e.length){for(var r={},n=0;nt)return!0;return!1},h.isReservedName=function(e,t){if(e)for(var r=0;r0;){var n=e.shift();if(r.nested&&r.nested[n]){if(!((r=r.nested[n])instanceof h))throw Error("path conflicts with non-namespace objects")}else r.add(r=new h(n))}return t&&r.addJSON(t),r},h.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t-1)return n}else if(n instanceof h&&(n=n.lookup(e.slice(1),t,!0)))return n}else for(var i=0;i{"use strict";e.exports=s,s.className="ReflectionObject";var n,i=r(2440);function s(e,t){if(!i.isString(e))throw TypeError("name must be a string");if(t&&!i.isObject(t))throw TypeError("options must be an object");this.options=t,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(s.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),s.prototype.toJSON=function(){throw Error()},s.prototype.onAdd=function(e){this.parent&&this.parent!==e&&this.parent.remove(this),this.parent=e,this.resolved=!1;var t=e.root;t instanceof n&&t._handleAdd(this)},s.prototype.onRemove=function(e){var t=e.root;t instanceof n&&t._handleRemove(this),this.parent=null,this.resolved=!1},s.prototype.resolve=function(){return this.resolved||this.root instanceof n&&(this.resolved=!0),this},s.prototype.getOption=function(e){if(this.options)return this.options[e]},s.prototype.setOption=function(e,t,r){return r&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},s.prototype.setParsedOption=function(e,t,r){this.parsedOptions||(this.parsedOptions=[]);var n=this.parsedOptions;if(r){var s=n.find((function(t){return Object.prototype.hasOwnProperty.call(t,e)}));if(s){var o=s[e];i.setProperty(o,r,t)}else(s={})[e]=i.setProperty({},r,t),n.push(s)}else{var a={};a[e]=t,n.push(a)}return this},s.prototype.setOptions=function(e,t){if(e)for(var r=Object.keys(e),n=0;n{"use strict";e.exports=o;var n=r(5154);((o.prototype=Object.create(n.prototype)).constructor=o).className="OneOf";var i=r(6734),s=r(2440);function o(e,t,r,i){if(Array.isArray(t)||(r=t,t=void 0),n.call(this,e,r),void 0!==t&&!Array.isArray(t))throw TypeError("fieldNames must be an Array");this.oneof=t||[],this.fieldsArray=[],this.comment=i}function a(e){if(e.parent)for(var t=0;t-1&&this.oneof.splice(t,1),e.partOf=null,this},o.prototype.onAdd=function(e){n.prototype.onAdd.call(this,e);for(var t=0;t{"use strict";e.exports=I,I.filename=null,I.defaults={keepCase:!1};var n=r(3077),i=r(8622),s=r(8716),o=r(6734),a=r(4479),c=r(9794),l=r(222),u=r(4173),h=r(4865),d=r(8517),f=r(2440),p=/^[1-9][0-9]*$/,g=/^-?[1-9][0-9]*$/,y=/^0[x][0-9a-fA-F]+$/,m=/^-?0[x][0-9a-fA-F]+$/,v=/^0[0-7]+$/,b=/^-?0[0-7]+$/,w=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,E=/^[a-zA-Z_][a-zA-Z_0-9]*$/,_=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,S=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function I(e,t,r){t instanceof i||(r=t,t=new i),r||(r=I.defaults);var C,A,T,k,R,P=r.preferTrailingComment||!1,D=n(e,r.alternateCommentMode||!1),N=D.next,O=D.push,L=D.peek,x=D.skip,B=D.cmnt,M=!0,U=!1,F=t,V=r.keepCase?function(e){return e}:f.camelCase;function j(e,t,r){var n=I.filename;return r||(I.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(n?n+", ":"")+"line "+D.line+")")}function K(){var e,t=[];do{if('"'!==(e=N())&&"'"!==e)throw j(e);t.push(N()),x(e),e=L()}while('"'===e||"'"===e);return t.join("")}function z(e){var t=N();switch(t){case"'":case'"':return O(t),K();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var r=1;"-"===e.charAt(0)&&(r=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return r*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(p.test(e))return r*parseInt(e,10);if(y.test(e))return r*parseInt(e,16);if(v.test(e))return r*parseInt(e,8);if(w.test(e))return r*parseFloat(e);throw j(e,"number",t)}(t,!0)}catch(r){if(e&&_.test(t))return t;throw j(t,"value")}}function q(e,t){var r,n;do{!t||'"'!==(r=L())&&"'"!==r?e.push([n=H(N()),x("to",!0)?H(N()):n]):e.push(K())}while(x(",",!0));x(";")}function H(e,t){switch(e){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!t&&"-"===e.charAt(0))throw j(e,"id");if(g.test(e))return parseInt(e,10);if(m.test(e))return parseInt(e,16);if(b.test(e))return parseInt(e,8);throw j(e,"id")}function W(){if(void 0!==C)throw j("package");if(C=N(),!_.test(C))throw j(C,"name");F=F.define(C),x(";")}function G(){var e,t=L();switch(t){case"weak":e=T||(T=[]),N();break;case"public":N();default:e=A||(A=[])}t=K(),x(";"),e.push(t)}function Q(){if(x("="),k=K(),!(U="proto3"===k)&&"proto2"!==k)throw j(k,"syntax");x(";")}function Y(e,t){switch(t){case"option":return ee(e,t),x(";"),!0;case"message":return X(e,t),!0;case"enum":return Z(e,t),!0;case"service":return function(e,t){if(!E.test(t=N()))throw j(t,"service name");var r=new u(t);$(r,(function(e){if(!Y(r,e)){if("rpc"!==e)throw j(e);!function(e,t){var r=B(),n=t;if(!E.test(t=N()))throw j(t,"name");var i,s,o,a,c=t;x("("),x("stream",!0)&&(s=!0);if(!_.test(t=N()))throw j(t);i=t,x(")"),x("returns"),x("("),x("stream",!0)&&(a=!0);if(!_.test(t=N()))throw j(t);o=t,x(")");var l=new h(c,n,i,o,s,a);l.comment=r,$(l,(function(e){if("option"!==e)throw j(e);ee(l,e),x(";")})),e.add(l)}(r,e)}})),e.add(r)}(e,t),!0;case"extend":return function(e,t){if(!_.test(t=N()))throw j(t,"reference");var r=t;$(null,(function(t){switch(t){case"required":case"repeated":J(e,t,r);break;case"optional":J(e,U?"proto3_optional":"optional",r);break;default:if(!U||!_.test(t))throw j(t);O(t),J(e,"optional",r)}}))}(e,t),!0}return!1}function $(e,t,r){var n=D.line;if(e&&("string"!==typeof e.comment&&(e.comment=B()),e.filename=I.filename),x("{",!0)){for(var i;"}"!==(i=N());)t(i);x(";",!0)}else r&&r(),x(";"),e&&("string"!==typeof e.comment||P)&&(e.comment=B(n)||e.comment)}function X(e,t){if(!E.test(t=N()))throw j(t,"type name");var r=new s(t);$(r,(function(e){if(!Y(r,e))switch(e){case"map":!function(e){x("<");var t=N();if(void 0===d.mapKey[t])throw j(t,"type");x(",");var r=N();if(!_.test(r))throw j(r,"type");x(">");var n=N();if(!E.test(n))throw j(n,"name");x("=");var i=new a(V(n),H(N()),t,r);$(i,(function(e){if("option"!==e)throw j(e);ee(i,e),x(";")}),(function(){ne(i)})),e.add(i)}(r);break;case"required":case"repeated":J(r,e);break;case"optional":J(r,U?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!E.test(t=N()))throw j(t,"name");var r=new c(V(t));$(r,(function(e){"option"===e?(ee(r,e),x(";")):(O(e),J(r,"optional"))})),e.add(r)}(r,e);break;case"extensions":q(r.extensions||(r.extensions=[]));break;case"reserved":q(r.reserved||(r.reserved=[]),!0);break;default:if(!U||!_.test(e))throw j(e);O(e),J(r,"optional")}})),e.add(r)}function J(e,t,r){var n=N();if("group"!==n){if(!_.test(n))throw j(n,"type");var i=N();if(!E.test(i))throw j(i,"name");i=V(i),x("=");var a=new o(i,H(N()),n,t,r);if($(a,(function(e){if("option"!==e)throw j(e);ee(a,e),x(";")}),(function(){ne(a)})),"proto3_optional"===t){var l=new c("_"+i);a.setOption("proto3_optional",!0),l.add(a),e.add(l)}else e.add(a);U||!a.repeated||void 0===d.packed[n]&&void 0!==d.basic[n]||a.setOption("packed",!1,!0)}else!function(e,t){var r=N();if(!E.test(r))throw j(r,"name");var n=f.lcFirst(r);r===n&&(r=f.ucFirst(r));x("=");var i=H(N()),a=new s(r);a.group=!0;var c=new o(n,i,r,t);c.filename=I.filename,$(a,(function(e){switch(e){case"option":ee(a,e),x(";");break;case"required":case"repeated":J(a,e);break;case"optional":J(a,U?"proto3_optional":"optional");break;case"message":X(a,e);break;case"enum":Z(a,e);break;default:throw j(e)}})),e.add(a).add(c)}(e,t)}function Z(e,t){if(!E.test(t=N()))throw j(t,"name");var r=new l(t);$(r,(function(e){switch(e){case"option":ee(r,e),x(";");break;case"reserved":q(r.reserved||(r.reserved=[]),!0);break;default:!function(e,t){if(!E.test(t))throw j(t,"name");x("=");var r=H(N(),!0),n={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};$(n,(function(e){if("option"!==e)throw j(e);ee(n,e),x(";")}),(function(){ne(n)})),e.add(t,r,n.comment,n.options)}(r,e)}})),e.add(r)}function ee(e,t){var r=x("(",!0);if(!_.test(t=N()))throw j(t,"name");var n,i=t,s=i;r&&(x(")"),s=i="("+i+")",t=L(),S.test(t)&&(n=t.slice(1),i+=t,N())),x("="),function(e,t,r,n){e.setParsedOption&&e.setParsedOption(t,r,n)}(e,s,te(e,i),n)}function te(e,t){if(x("{",!0)){for(var r={};!x("}",!0);){if(!E.test(R=N()))throw j(R,"name");var n,i=R;if(x(":",!0),"{"===L())n=te(e,t+"."+R);else if("["===L()){var s;if(n=[],x("[",!0)){do{s=z(!0),n.push(s)}while(x(",",!0));x("]"),"undefined"!==typeof s&&re(e,t+"."+R,s)}}else n=z(!0),re(e,t+"."+R,n);var o=r[i];o&&(n=[].concat(o).concat(n)),r[i]=n,x(",",!0),x(";",!0)}return r}var a=z(!0);return re(e,t,a),a}function re(e,t,r){e.setOption&&e.setOption(t,r)}function ne(e){if(x("[",!0)){do{ee(e,"option")}while(x(",",!0));x("]")}return e}for(;null!==(R=N());)switch(R){case"package":if(!M)throw j(R);W();break;case"import":if(!M)throw j(R);G();break;case"syntax":if(!M)throw j(R);Q();break;case"option":ee(F,R),x(";");break;default:if(Y(F,R)){M=!1;continue}throw j(R)}return I.filename=null,{package:C,imports:A,weakImports:T,syntax:k,root:t}}},6216:(e,t,r)=>{"use strict";e.exports=c;var n,i=r(3097),s=i.LongBits,o=i.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var l="undefined"!==typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},u=function(){return i.Buffer?function(e){return(c.create=function(e){return i.Buffer.isBuffer(e)?new n(e):l(e)})(e)}:l};function h(){var e=new s(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new s(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=u(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=function(){var e=4294967295;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return e}}(),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)|0},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,r):t===r?new this.buf.constructor(0):this._slice.call(this.buf,t,r)},c.prototype.string=function(){var e=this.bytes();return o.read(e,0,e.length)},c.prototype.skip=function(e){if("number"===typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){n=e,c.create=u(),n._configure();var t=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},3557:(e,t,r)=>{"use strict";e.exports=s;var n=r(6216);(s.prototype=Object.create(n.prototype)).constructor=s;var i=r(3097);function s(e){n.call(this,e)}s._configure=function(){i.Buffer&&(s.prototype._slice=i.Buffer.prototype.slice)},s.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},s._configure()},8622:(e,t,r)=>{"use strict";e.exports=h;var n=r(3452);((h.prototype=Object.create(n.prototype)).constructor=h).className="Root";var i,s,o,a=r(6734),c=r(222),l=r(9794),u=r(2440);function h(e){n.call(this,"",e),this.deferred=[],this.files=[]}function d(){}h.fromJSON=function(e,t){return t||(t=new h),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},h.prototype.resolvePath=u.path.resolve,h.prototype.fetch=u.fetch,h.prototype.load=function e(t,r,n){"function"===typeof r&&(n=r,r=void 0);var i=this;if(!n)return u.asPromise(e,i,t,r);var a=n===d;function c(e,t){if(n){var r=n;if(n=null,a)throw e;r(e,t)}}function l(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var r=e.substring(t);if(r in o)return r}return null}function h(e,t){try{if(u.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),u.isString(t)){s.filename=e;var n,o=s(t,i,r),h=0;if(o.imports)for(;h-1))if(i.files.push(e),e in o)a?h(e,o[e]):(++p,setTimeout((function(){--p,h(e,o[e])})));else if(a){var r;try{r=u.fs.readFileSync(e).toString("utf8")}catch(s){return void(t||c(s))}h(e,r)}else++p,i.fetch(e,(function(r,s){--p,n&&(r?t?p||c(null,i):c(r):h(e,s))}))}var p=0;u.isString(t)&&(t=[t]);for(var g,y=0;y-1&&this.deferred.splice(t,1)}}else if(e instanceof c)f.test(e.name)&&delete e.parent[e.name];else if(e instanceof n){for(var r=0;r{"use strict";e.exports={}},9994:(e,t,r)=>{"use strict";t.Service=r(4281)},4281:(e,t,r)=>{"use strict";e.exports=i;var n=r(3097);function i(e,t,r){if("function"!==typeof e)throw TypeError("rpcImpl must be a function");n.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(r)}(i.prototype=Object.create(n.EventEmitter.prototype)).constructor=i,i.prototype.rpcCall=function e(t,r,i,s,o){if(!s)throw TypeError("request must be specified");var a=this;if(!o)return n.asPromise(e,a,t,r,i,s);if(a.rpcImpl)try{return a.rpcImpl(t,r[a.requestDelimited?"encodeDelimited":"encode"](s).finish(),(function(e,r){if(e)return a.emit("error",e,t),o(e);if(null!==r){if(!(r instanceof i))try{r=i[a.responseDelimited?"decodeDelimited":"decode"](r)}catch(e){return a.emit("error",e,t),o(e)}return a.emit("data",r,t),o(null,r)}a.end(!0)}))}catch(c){return a.emit("error",c,t),void setTimeout((function(){o(c)}),0)}else setTimeout((function(){o(Error("already ended"))}),0)},i.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},4173:(e,t,r)=>{"use strict";e.exports=a;var n=r(3452);((a.prototype=Object.create(n.prototype)).constructor=a).className="Service";var i=r(4865),s=r(2440),o=r(9994);function a(e,t){n.call(this,e,t),this.methods={},this._methodsArray=null}function c(e){return e._methodsArray=null,e}a.fromJSON=function(e,t){var r=new a(e,t.options);if(t.methods)for(var n=Object.keys(t.methods),s=0;s{"use strict";e.exports=h;var t=/[\s{}=;:[\],'"()<>]/g,r=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,n=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,i=/^ *[*/]+ */,s=/^\s*\*?\/*/,o=/\n/g,a=/\s/,c=/\\(.?)/g,l={0:"\0",r:"\r",n:"\n",t:"\t"};function u(e){return e.replace(c,(function(e,t){switch(t){case"\\":case"":return t;default:return l[t]||""}}))}function h(e,c){e=e.toString();var l=0,h=e.length,d=1,f=0,p={},g=[],y=null;function m(e){return Error("illegal "+e+" (line "+d+")")}function v(t){return e.charAt(t)}function b(t,r,n){var a,l={type:e.charAt(t++),lineEmpty:!1,leading:n},u=t-(c?2:3);do{if(--u<0||"\n"===(a=e.charAt(u))){l.lineEmpty=!0;break}}while(" "===a||"\t"===a);for(var h=e.substring(t,r).split(o),g=0;g0)return g.shift();if(y)return function(){var t="'"===y?n:r;t.lastIndex=l-1;var i=t.exec(e);if(!i)throw m("string");return l=t.lastIndex,S(y),y=null,u(i[1])}();var i,s,o,f,p,_=0===l;do{if(l===h)return null;for(i=!1;a.test(o=v(l));)if("\n"===o&&(_=!0,++d),++l===h)return null;if("/"===v(l)){if(++l===h)throw m("comment");if("/"===v(l))if(c){if(f=l,p=!1,w(l)){p=!0;do{if((l=E(l))===h)break;if(l++,!_)break}while(w(l))}else l=Math.min(h,E(l)+1);p&&(b(f,l,_),_=!0),d++,i=!0}else{for(p="/"===v(f=l+1);"\n"!==v(++l);)if(l===h)return null;++l,p&&(b(f,l-1,_),_=!0),++d,i=!0}else{if("*"!==(o=v(l)))return"/";f=l+1,p=c||"*"===v(f);do{if("\n"===o&&++d,++l===h)throw m("comment");s=o,o=v(l)}while("*"!==s||"/"!==o);++l,p&&(b(f,l-2,_),_=!0),i=!0}}}while(i);var I=l;if(t.lastIndex=0,!t.test(v(I++)))for(;I{"use strict";e.exports=v;var n=r(3452);((v.prototype=Object.create(n.prototype)).constructor=v).className="Type";var i=r(222),s=r(9794),o=r(6734),a=r(4479),c=r(4173),l=r(4486),u=r(6216),h=r(7063),d=r(2440),f=r(6886),p=r(2715),g=r(709),y=r(7276),m=r(9025);function v(e,t){n.call(this,e,t),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function b(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}Object.defineProperties(v.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t{"use strict";var n=t,i=r(2440),s=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function o(e,t){var r=0,n={};for(t|=0;r{"use strict";var n,i,s=e.exports=r(3097),o=r(7907);s.codegen=r(3297),s.fetch=r(7635),s.path=r(7468),s.fs=s.inquire("fs"),s.toArray=function(e){if(e){for(var t=Object.keys(e),r=new Array(t.length),n=0;n0)t[i]=e(t[i]||{},r,n);else{var s=t[i];s&&(n=[].concat(s).concat(n)),t[i]=n}return t}(e,t=t.split("."),r)},Object.defineProperty(s,"decorateRoot",{get:function(){return o.decorated||(o.decorated=new(r(8622)))}})},9351:(e,t,r)=>{"use strict";e.exports=i;var n=r(3097);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var s=i.zero=new i(0,0);s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1};var o=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return s;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)},i.from=function(e){if("number"===typeof e)return i.fromNumber(e);if(n.isString(e)){if(!n.Long)return i.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):s},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;i.fromHash=function(e){return e===o?s:new i((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},3097:function(e,t,r){"use strict";var n=t;function i(e,t,r){for(var n=Object.keys(t),i=0;ie,set:void 0,enumerable:!1,configurable:!0},toString:{value(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}n.asPromise=r(7206),n.base64=r(1),n.EventEmitter=r(7111),n.float=r(802),n.inquire=r(7172),n.utf8=r(3861),n.pool=r(8236),n.LongBits=r(9351),n.isNode=Boolean("undefined"!==typeof r.g&&r.g&&r.g.process&&r.g.process.versions&&r.g.process.versions.node),n.global=n.isNode&&r.g||"undefined"!==typeof window&&window||"undefined"!==typeof self&&self||this,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(e){return"number"===typeof e&&isFinite(e)&&Math.floor(e)===e},n.isString=function(e){return"string"===typeof e||e instanceof String},n.isObject=function(e){return e&&"object"===typeof e},n.isset=n.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t))&&("object"!==typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(t){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"===typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"===typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!==typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=i,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=s,n.ProtocolError=s("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r{"use strict";e.exports=function(e){var t=i.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),r=e.oneofsArray,n={};r.length&&t("var p={}");for(var c=0;c{"use strict";var n=t,i=r(4486);n[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),r=this.lookup(t);if(r){var n="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===n.indexOf("/")&&(n="/"+n),this.create({type_url:n,value:r.encode(r.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,t){var r="",n="";if(t&&t.json&&e.type_url&&e.value){n=e.type_url.substring(e.type_url.lastIndexOf("/")+1),r=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var s=this.lookup(n);s&&(e=s.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof i){var o=e.$type.toObject(e,t);return""===r&&(r="type.googleapis.com/"),n=r+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),o["@type"]=n,o}return this.toObject(e,t)}}},7063:(e,t,r)=>{"use strict";e.exports=h;var n,i=r(3097),s=i.LongBits,o=i.base64,a=i.utf8;function c(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function l(){}function u(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function h(){this.len=0,this.head=new c(l,0,0),this.tail=this.head,this.states=null}var d=function(){return i.Buffer?function(){return(h.create=function(){return new n})()}:function(){return new h}};function f(e,t,r){t[r]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function y(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}h.create=d(),h.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(h.alloc=i.pool(h.alloc,i.Array.prototype.subarray)),h.prototype._push=function(e,t,r){return this.tail=this.tail.next=new c(e,t,r),this.len+=t,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},h.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},h.prototype.int32=function(e){return e<0?this._push(g,10,s.fromNumber(e)):this.uint32(e)},h.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},h.prototype.uint64=function(e){var t=s.from(e);return this._push(g,t.length(),t)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(e){var t=s.from(e).zzEncode();return this._push(g,t.length(),t)},h.prototype.bool=function(e){return this._push(f,1,e?1:0)},h.prototype.fixed32=function(e){return this._push(y,4,e>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(e){var t=s.from(e);return this._push(y,4,t.lo)._push(y,4,t.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},h.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var m=i.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n>>0;if(!t)return this._push(f,1,0);if(i.isString(e)){var r=h.alloc(t=o.length(e));o.decode(e,r,0),e=r}return this.uint32(t)._push(m,t,e)},h.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(f,1,0)},h.prototype.fork=function(){return this.states=new u(this),this.head=this.tail=new c(l,0,0),this.len=0,this},h.prototype.reset=function(){return this.states?(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 c(l,0,0),this.len=0),this},h.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},h.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},h._configure=function(e){n=e,h.create=d(),n._configure()}},2815:(e,t,r)=>{"use strict";e.exports=s;var n=r(7063);(s.prototype=Object.create(n.prototype)).constructor=s;var i=r(3097);function s(){n.call(this)}function o(e,t,r){e.length<40?i.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}s._configure=function(){s.alloc=i._Buffer_allocUnsafe,s.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n>>0;return this.uint32(t),t&&this._push(s.writeBytesBuffer,t,e),this},s.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(o,t,e),this},s._configure()},7896:(e,t,r)=>{const n=r(8139),i=r(5339),s=r(4052),o=r(3654),{RateLimiterClusterMaster:a,RateLimiterClusterMasterPM2:c,RateLimiterCluster:l}=r(5503),u=r(2408),h=r(8134),d=r(5e3),f=r(4066),p=r(3081),g=r(438),y=r(4819);e.exports={RateLimiterRedis:n,RateLimiterMongo:i,RateLimiterMySQL:s,RateLimiterPostgres:o,RateLimiterMemory:u,RateLimiterMemcache:h,RateLimiterClusterMaster:a,RateLimiterClusterMasterPM2:c,RateLimiterCluster:l,RLWrapperBlackAndWhite:d,RateLimiterUnion:f,RateLimiterQueue:p,BurstyRateLimiter:g,RateLimiterRes:y}},438:(e,t,r)=>{const n=r(4819);e.exports=class{constructor(e,t){this._rateLimiter=e,this._burstLimiter=t}_combineRes(e,t){return new n(e.remainingPoints,Math.min(e.msBeforeNext,t.msBeforeNext),e.consumedPoints,e.isFirstInDuration)}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this._rateLimiter.consume(e,t,r).catch((i=>i instanceof n?this._burstLimiter.consume(e,t,r).then((e=>Promise.resolve(this._combineRes(i,e)))).catch((e=>e instanceof n?Promise.reject(this._combineRes(i,e)):Promise.reject(e))):Promise.reject(i)))}get(e){return Promise.all([this._rateLimiter.get(e),this._burstLimiter.get(e)]).then((e=>{let[t,r]=e;return this._combineRes(t,r)}))}get points(){return this._rateLimiter.points}}},5e3:(e,t,r)=>{const n=r(4819);e.exports=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.limiter=e.limiter,this.blackList=e.blackList,this.whiteList=e.whiteList,this.isBlackListed=e.isBlackListed,this.isWhiteListed=e.isWhiteListed,this.runActionAnyway=e.runActionAnyway}get limiter(){return this._limiter}set limiter(e){if("undefined"===typeof e)throw new Error("limiter is not set");this._limiter=e}get runActionAnyway(){return this._runActionAnyway}set runActionAnyway(e){this._runActionAnyway="undefined"!==typeof e&&e}get blackList(){return this._blackList}set blackList(e){this._blackList=Array.isArray(e)?e:[]}get isBlackListed(){return this._isBlackListed}set isBlackListed(e){if("undefined"===typeof e&&(e=()=>!1),"function"!==typeof e)throw new Error("isBlackListed must be function");this._isBlackListed=e}get whiteList(){return this._whiteList}set whiteList(e){this._whiteList=Array.isArray(e)?e:[]}get isWhiteListed(){return this._isWhiteListed}set isWhiteListed(e){if("undefined"===typeof e&&(e=()=>!1),"function"!==typeof e)throw new Error("isWhiteListed must be function");this._isWhiteListed=e}isBlackListedSomewhere(e){return this.blackList.indexOf(e)>=0||this.isBlackListed(e)}isWhiteListedSomewhere(e){return this.whiteList.indexOf(e)>=0||this.isWhiteListed(e)}getBlackRes(){return new n(0,Number.MAX_SAFE_INTEGER,0,!1)}getWhiteRes(){return new n(Number.MAX_SAFE_INTEGER,0,0,!1)}rejectBlack(){return Promise.reject(this.getBlackRes())}resolveBlack(){return Promise.resolve(this.getBlackRes())}resolveWhite(){return Promise.resolve(this.getWhiteRes())}consume(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.isWhiteListedSomewhere(e)?t=this.resolveWhite():this.isBlackListedSomewhere(e)&&(t=this.rejectBlack()),"undefined"===typeof t?this.limiter.consume(e,r):(this.runActionAnyway&&this.limiter.consume(e,r).catch((()=>{})),t)}block(e,t){let r;return this.isWhiteListedSomewhere(e)?r=this.resolveWhite():this.isBlackListedSomewhere(e)&&(r=this.resolveBlack()),"undefined"===typeof r?this.limiter.block(e,t):(this.runActionAnyway&&this.limiter.block(e,t).catch((()=>{})),r)}penalty(e,t){let r;return this.isWhiteListedSomewhere(e)?r=this.resolveWhite():this.isBlackListedSomewhere(e)&&(r=this.resolveBlack()),"undefined"===typeof r?this.limiter.penalty(e,t):(this.runActionAnyway&&this.limiter.penalty(e,t).catch((()=>{})),r)}reward(e,t){let r;return this.isWhiteListedSomewhere(e)?r=this.resolveWhite():this.isBlackListedSomewhere(e)&&(r=this.resolveBlack()),"undefined"===typeof r?this.limiter.reward(e,t):(this.runActionAnyway&&this.limiter.reward(e,t).catch((()=>{})),r)}get(e){let t;return this.isWhiteListedSomewhere(e)?t=this.resolveWhite():this.isBlackListedSomewhere(e)&&(t=this.resolveBlack()),"undefined"===typeof t||this.runActionAnyway?this.limiter.get(e):t}delete(e){return this.limiter.delete(e)}}},8855:e=>{e.exports=class{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.points=e.points,this.duration=e.duration,this.blockDuration=e.blockDuration,this.execEvenly=e.execEvenly,this.execEvenlyMinDelayMs=e.execEvenlyMinDelayMs,this.keyPrefix=e.keyPrefix}get points(){return this._points}set points(e){this._points=e>=0?e:4}get duration(){return this._duration}set duration(e){this._duration="undefined"===typeof e?1:e}get msDuration(){return 1e3*this.duration}get blockDuration(){return this._blockDuration}set blockDuration(e){this._blockDuration="undefined"===typeof e?0:e}get msBlockDuration(){return 1e3*this.blockDuration}get execEvenly(){return this._execEvenly}set execEvenly(e){this._execEvenly="undefined"!==typeof e&&Boolean(e)}get execEvenlyMinDelayMs(){return this._execEvenlyMinDelayMs}set execEvenlyMinDelayMs(e){this._execEvenlyMinDelayMs="undefined"===typeof e?Math.ceil(this.msDuration/this.points):e}get keyPrefix(){return this._keyPrefix}set keyPrefix(e){if("undefined"===typeof e&&(e="rlflx"),"string"!==typeof e)throw new Error("keyPrefix must be string");this._keyPrefix=e}_getKeySecDuration(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e&&e.customDuration>=0?e.customDuration:this.duration}getKey(e){return this.keyPrefix.length>0?"".concat(this.keyPrefix,":").concat(e):e}parseKey(e){return e.substring(this.keyPrefix.length)}consume(){throw new Error("You have to implement the method 'consume'!")}penalty(){throw new Error("You have to implement the method 'penalty'!")}reward(){throw new Error("You have to implement the method 'reward'!")}get(){throw new Error("You have to implement the method 'get'!")}set(){throw new Error("You have to implement the method 'set'!")}block(){throw new Error("You have to implement the method 'block'!")}delete(){throw new Error("You have to implement the method 'delete'!")}}},5503:(e,t,r)=>{const n=r(1265),i=r(5539),s=r(8855),o=r(2408),a=r(4819),c="rate_limiter_flexible";let l=null;const u=function(e,t,r,n){let i;i=null===n||!0===n||!1===n?n:{remainingPoints:n.remainingPoints,msBeforeNext:n.msBeforeNext,consumedPoints:n.consumedPoints,isFirstInDuration:n.isFirstInDuration},e.send({channel:c,keyPrefix:t.keyPrefix,promiseId:t.promiseId,type:r,data:i})},h=function(e){setTimeout((()=>{this._initiated?process.send(e):"undefined"!==typeof this._promises[e.promiseId]&&h.call(this,e)}),30)},d=function(e,t,r,n,i){const s={channel:c,keyPrefix:this.keyPrefix,func:e,promiseId:t,data:{key:r,arg:n,opts:i}};this._initiated?process.send(s):h.call(this,s)},f=function(e,t){if(!t||t.channel!==c||"undefined"===typeof this._rateLimiters[t.keyPrefix])return!1;let r;switch(t.func){case"consume":r=this._rateLimiters[t.keyPrefix].consume(t.data.key,t.data.arg,t.data.opts);break;case"penalty":r=this._rateLimiters[t.keyPrefix].penalty(t.data.key,t.data.arg,t.data.opts);break;case"reward":r=this._rateLimiters[t.keyPrefix].reward(t.data.key,t.data.arg,t.data.opts);break;case"block":r=this._rateLimiters[t.keyPrefix].block(t.data.key,t.data.arg,t.data.opts);break;case"get":r=this._rateLimiters[t.keyPrefix].get(t.data.key,t.data.opts);break;case"delete":r=this._rateLimiters[t.keyPrefix].delete(t.data.key,t.data.opts);break;default:return!1}r&&r.then((r=>{u(e,t,"resolve",r)})).catch((r=>{u(e,t,"reject",r)}))},p=function(e){if(!e||e.channel!==c||e.keyPrefix!==this.keyPrefix)return!1;if(this._promises[e.promiseId]){let t;switch(clearTimeout(this._promises[e.promiseId].timeoutId),t=null===e.data||!0===e.data||!1===e.data?e.data:new a(e.data.remainingPoints,e.data.msBeforeNext,e.data.consumedPoints,e.data.isFirstInDuration),e.type){case"resolve":this._promises[e.promiseId].resolve(t);break;case"reject":this._promises[e.promiseId].reject(t);break;default:throw new Error("RateLimiterCluster: no such message type '".concat(e.type,"'"))}delete this._promises[e.promiseId]}},g=function(){return{points:this.points,duration:this.duration,blockDuration:this.blockDuration,execEvenly:this.execEvenly,execEvenlyMinDelayMs:this.execEvenlyMinDelayMs,keyPrefix:this.keyPrefix}},y=function(e,t){const r=process.hrtime();let n=r[0].toString()+r[1].toString();return"undefined"!==typeof this._promises[n]&&(n+=i.randomBytes(12).toString("base64")),this._promises[n]={resolve:e,reject:t,timeoutId:setTimeout((()=>{delete this._promises[n],t(new Error("RateLimiterCluster timeout: no answer from master in time"))}),this.timeoutMs)},n};e.exports={RateLimiterClusterMaster:class{constructor(){if(l)return l;this._rateLimiters={},n.setMaxListeners(0),n.on("message",((e,t)=>{t&&t.channel===c&&"init"===t.type?("undefined"===typeof this._rateLimiters[t.opts.keyPrefix]&&(this._rateLimiters[t.opts.keyPrefix]=new o(t.opts)),e.send({channel:c,type:"init",keyPrefix:t.opts.keyPrefix})):f.call(this,e,t)})),l=this}},RateLimiterClusterMasterPM2:class{constructor(e){if(l)return l;this._rateLimiters={},e.launchBus(((t,r)=>{r.on("process:msg",(t=>{const r=t.raw;if(r&&r.channel===c&&"init"===r.type)"undefined"===typeof this._rateLimiters[r.opts.keyPrefix]&&(this._rateLimiters[r.opts.keyPrefix]=new o(r.opts)),e.sendDataToProcessId(t.process.pm_id,{data:{},topic:c,channel:c,type:"init",keyPrefix:r.opts.keyPrefix},((e,t)=>{e&&console.log(e,t)}));else{f.call(this,{send:r=>{const n=r;n.topic=c,"undefined"===typeof n.data&&(n.data={}),e.sendDataToProcessId(t.process.pm_id,n,((e,t)=>{e&&console.log(e,t)}))}},r)}}))})),l=this}},RateLimiterCluster:class extends s{get timeoutMs(){return this._timeoutMs}set timeoutMs(e){this._timeoutMs="undefined"===typeof e?5e3:Math.abs(parseInt(e))}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),process.setMaxListeners(0),this.timeoutMs=e.timeoutMs,this._initiated=!1,process.on("message",(e=>{e&&e.channel===c&&"init"===e.type&&e.keyPrefix===this.keyPrefix?this._initiated=!0:p.call(this,e)})),process.send({channel:c,type:"init",opts:g.call(this)}),this._promises={}}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const s=y.call(this,n,i);d.call(this,"consume",s,e,t,r)}))}penalty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const s=y.call(this,n,i);d.call(this,"penalty",s,e,t,r)}))}reward(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const s=y.call(this,n,i);d.call(this,"reward",s,e,t,r)}))}block(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const s=y.call(this,n,i);d.call(this,"block",s,e,t,r)}))}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((r,n)=>{const i=y.call(this,r,n);d.call(this,"get",i,e,t)}))}delete(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise(((r,n)=>{const i=y.call(this,r,n);d.call(this,"delete",i,e,t)}))}}}},8134:(e,t,r)=>{const n=r(1434),i=r(4819);e.exports=class extends n{constructor(e){super(e),this.client=e.storeClient}_getRateLimiterRes(e,t,r){const n=new i;return n.consumedPoints=parseInt(r.consumedPoints),n.isFirstInDuration=r.consumedPoints===t,n.remainingPoints=Math.max(this.points-n.consumedPoints,0),n.msBeforeNext=r.msBeforeNext,n}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return new Promise(((s,o)=>{const a=Date.now(),c=Math.floor(r/1e3);n?this.client.set(e,t,c,(r=>{r?o(r):this.client.set("".concat(e,"_expire"),c>0?a+1e3*c:-1,c,(()=>{s({consumedPoints:t,msBeforeNext:c>0?1e3*c:-1})}))})):this.client.incr(e,t,((l,u)=>{l||!1===u?this.client.add(e,t,c,((l,u)=>{if(l||!u)if("undefined"===typeof i.attemptNumber||i.attemptNumber<3){const a=Object.assign({},i);a.attemptNumber=a.attemptNumber?a.attemptNumber+1:1,this._upsert(e,t,r,n,a).then((e=>s(e))).catch((e=>o(e)))}else o(new Error("Can not add key"));else this.client.add("".concat(e,"_expire"),c>0?a+1e3*c:-1,c,(()=>{s({consumedPoints:t,msBeforeNext:c>0?1e3*c:-1})}))})):this.client.get("".concat(e,"_expire"),((e,t)=>{if(e)o(e);else{const e=!1===t?0:t,r={consumedPoints:u,msBeforeNext:e>=0?Math.max(e-a,0):-1};s(r)}}))}))}))}_get(e){return new Promise(((t,r)=>{const n=Date.now();this.client.get(e,((i,s)=>{s?this.client.get("".concat(e,"_expire"),((e,i)=>{if(e)r(e);else{const e=!1===i?0:i,r={consumedPoints:s,msBeforeNext:e>=0?Math.max(e-n,0):-1};t(r)}})):t(null)}))}))}_delete(e){return new Promise(((t,r)=>{this.client.del(e,((n,i)=>{n?r(n):!1===i?t(i):this.client.del("".concat(e,"_expire"),(e=>{e?r(e):t(i)}))}))}))}}},2408:(e,t,r)=>{const n=r(8855),i=r(4327),s=r(4819);e.exports=class extends n{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this._memoryStorage=new i}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const s=this.getKey(e),o=this._getKeySecDuration(r);let a=this._memoryStorage.incrby(s,t,o);if(a.remainingPoints=Math.max(this.points-a.consumedPoints,0),a.consumedPoints>this.points)this.blockDuration>0&&a.consumedPoints<=this.points+t&&(a=this._memoryStorage.set(s,a.consumedPoints,this.blockDuration)),i(a);else if(this.execEvenly&&a.msBeforeNext>0&&!a.isFirstInDuration){let e=Math.ceil(a.msBeforeNext/(a.remainingPoints+2));e1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e);return new Promise((e=>{const i=this._getKeySecDuration(r),s=this._memoryStorage.incrby(n,t,i);s.remainingPoints=Math.max(this.points-s.consumedPoints,0),e(s)}))}reward(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e);return new Promise((e=>{const i=this._getKeySecDuration(r),s=this._memoryStorage.incrby(n,-t,i);s.remainingPoints=Math.max(this.points-s.consumedPoints,0),e(s)}))}block(e,t){const r=1e3*t,n=this.points+1;return this._memoryStorage.set(this.getKey(e),n,t),Promise.resolve(new s(0,0===r?-1:r,n))}set(e,t,r){const n=1e3*(r>=0?r:this.duration);return this._memoryStorage.set(this.getKey(e),t,r),Promise.resolve(new s(0,0===n?-1:n,t))}get(e){const t=this._memoryStorage.get(this.getKey(e));return null!==t&&(t.remainingPoints=Math.max(this.points-t.consumedPoints,0)),Promise.resolve(t)}delete(e){return Promise.resolve(this._memoryStorage.delete(this.getKey(e)))}}},5339:(e,t,r)=>{const n=r(1434),i=r(4819);function s(e){try{const t=e.client?e.client:e,{version:r}=t.topology.s.options.metadata.driver,n=r.split(".").map((e=>parseInt(e)));return{major:n[0],feature:n[1],patch:n[2]}}catch(t){return{major:0,feature:0,patch:0}}}class o extends n{constructor(e){super(e),this.dbName=e.dbName,this.tableName=e.tableName,this.indexKeyPrefix=e.indexKeyPrefix,e.mongo?this.client=e.mongo:this.client=e.storeClient,"function"===typeof this.client.then?this.client.then((e=>{this.client=e,this._initCollection(),this._driverVersion=s(this.client)})):(this._initCollection(),this._driverVersion=s(this.client))}get dbName(){return this._dbName}set dbName(e){this._dbName="undefined"===typeof e?o.getDbName():e}static getDbName(){return"node-rate-limiter-flexible"}get tableName(){return this._tableName}set tableName(e){this._tableName="undefined"===typeof e?this.keyPrefix:e}get client(){return this._client}set client(e){if("undefined"===typeof e)throw new Error("mongo is not set");this._client=e}get indexKeyPrefix(){return this._indexKeyPrefix}set indexKeyPrefix(e){this._indexKeyPrefix=e||{}}_initCollection(){const e=("function"===typeof this.client.db?this.client.db(this.dbName):this.client).collection(this.tableName);e.createIndex({expire:-1},{expireAfterSeconds:0}),e.createIndex(Object.assign({},this.indexKeyPrefix,{key:1}),{unique:!0}),this._collection=e}_getRateLimiterRes(e,t,r){const n=new i;let s;return s="undefined"===typeof r.value?r:r.value,n.isFirstInDuration=s.points===t,n.consumedPoints=s.points,n.remainingPoints=Math.max(this.points-n.consumedPoints,0),n.msBeforeNext=null!==s.expire?Math.max(new Date(s.expire).getTime()-Date.now(),0):-1,n}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const s=i.attrs||{};let o,a;n?(o={key:e},o=Object.assign(o,s),a={$set:{key:e,points:t,expire:r>0?new Date(Date.now()+r):null}},a.$set=Object.assign(a.$set,s)):(o={$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}],key:e},o=Object.assign(o,s),a={$setOnInsert:{key:e,expire:r>0?new Date(Date.now()+r):null},$inc:{points:t}},a.$setOnInsert=Object.assign(a.$setOnInsert,s));const c={upsert:!0};return this._driverVersion.major>=4||3===this._driverVersion.major&&this._driverVersion.feature>=7||this._driverVersion.feature>=6&&this._driverVersion.patch>=7?c.returnDocument="after":c.returnOriginal=!1,new Promise(((i,l)=>{this._collection.findOneAndUpdate(o,a,c).then((e=>{i(e)})).catch((o=>{if(o&&11e3===o.code){const o=Object.assign({$or:[{expire:{$lte:new Date}},{expire:{$eq:null}}],key:e},s),a={$set:Object.assign({key:e,points:t,expire:r>0?new Date(Date.now()+r):null},s)};this._collection.findOneAndUpdate(o,a,c).then((e=>{i(e)})).catch((s=>{s&&11e3===s.code?this._upsert(e,t,r,n).then((e=>i(e))).catch((e=>l(e))):l(s)}))}else l(o)}))}))}_get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const r=t.attrs||{},n=Object.assign({key:e,$or:[{expire:{$gt:new Date}},{expire:{$eq:null}}]},r);return this._collection.findOne(n)}_delete(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this._collection)return Promise.reject(Error("Mongo connection is not established"));const r=t.attrs||{},n=Object.assign({key:e},r);return this._collection.deleteOne(n).then((e=>e.deletedCount>0))}}e.exports=o},4052:(e,t,r)=>{const n=r(1434),i=r(4819);e.exports=class extends n{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e),this.client=e.storeClient,this.clientType=e.storeType,this.dbName=e.dbName,this.tableName=e.tableName,this.clearExpiredByTimeout=e.clearExpiredByTimeout,this.tableCreated=e.tableCreated,this.tableCreated?(this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"===typeof t&&t()):this._createDbAndTable().then((()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"===typeof t&&t()})).catch((e=>{if("function"!==typeof t)throw e;t(e)}))}clearExpired(e){return new Promise((t=>{this._getConnection().then((r=>{r.query("DELETE FROM ??.?? WHERE expire < ?",[this.dbName,this.tableName,e],(()=>{this._releaseConnection(r),t()}))})).catch((()=>{t()}))}))}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout((()=>{this.clearExpired(Date.now()-36e5).then((()=>{this._clearExpiredHourAgo()}))}),3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":return new Promise(((e,t)=>{this.client.getConnection(((r,n)=>{if(r)return t(r);e(n)}))}));case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();default:return Promise.resolve(this.client)}}_releaseConnection(e){switch(this.clientType){case"pool":return e.release();case"sequelize":return this.client.connectionManager.releaseConnection(e);case"knex":return this.client.client.releaseConnection(e);default:return!0}}_createDbAndTable(){return new Promise(((e,t)=>{this._getConnection().then((r=>{r.query("CREATE DATABASE IF NOT EXISTS `".concat(this.dbName,"`;"),(n=>{if(n)return this._releaseConnection(r),t(n);r.query(this._getCreateTableStmt(),(n=>{if(n)return this._releaseConnection(r),t(n);this._releaseConnection(r),e()}))}))})).catch((e=>{t(e)}))}))}_getCreateTableStmt(){return"CREATE TABLE IF NOT EXISTS `".concat(this.dbName,"`.`").concat(this.tableName,"` (")+"`key` VARCHAR(255) CHARACTER SET utf8 NOT NULL,`points` INT(9) NOT NULL default 0,`expire` BIGINT UNSIGNED,PRIMARY KEY (`key`)) ENGINE = INNODB;"}get clientType(){return this._clientType}set clientType(e){if("undefined"===typeof e)if("Connection"===this.client.constructor.name)e="connection";else if("Pool"===this.client.constructor.name)e="pool";else{if("Sequelize"!==this.client.constructor.name)throw new Error("storeType is not defined");e="sequelize"}this._clientType=e.toLowerCase()}get dbName(){return this._dbName}set dbName(e){this._dbName="undefined"===typeof e?"rtlmtrflx":e}get tableName(){return this._tableName}set tableName(e){this._tableName="undefined"===typeof e?this.keyPrefix:e}get tableCreated(){return this._tableCreated}set tableCreated(e){this._tableCreated="undefined"!==typeof e&&!!e}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(e){this._clearExpiredByTimeout="undefined"===typeof e||Boolean(e)}_getRateLimiterRes(e,t,r){const n=new i,[s]=r;return n.isFirstInDuration=t===s.points,n.consumedPoints=n.isFirstInDuration?t:s.points,n.remainingPoints=Math.max(this.points-n.consumedPoints,0),n.msBeforeNext=s.expire?Math.max(s.expire-Date.now(),0):-1,n}_upsertTransaction(e,t,r,n,i){return new Promise(((s,o)=>{e.query("BEGIN",(a=>{if(a)return e.rollback(),o(a);const c=Date.now(),l=n>0?c+n:null;let u,h;i?(u="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = ?, \n expire = ?;",h=[this.dbName,this.tableName,t,r,l,r,l]):(u="INSERT INTO ??.?? VALUES (?, ?, ?)\n ON DUPLICATE KEY UPDATE \n points = IF(expire <= ?, ?, points + (?)), \n expire = IF(expire <= ?, ?, expire);",h=[this.dbName,this.tableName,t,r,l,c,r,r,c,l]),e.query(u,h,(r=>{if(r)return e.rollback(),o(r);e.query("SELECT points, expire FROM ??.?? WHERE `key` = ?;",[this.dbName,this.tableName,t],((t,r)=>{if(t)return e.rollback(),o(t);e.query("COMMIT",(t=>{if(t)return e.rollback(),o(t);s(r)}))}))}))}))}))}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return this.tableCreated?new Promise(((i,s)=>{this._getConnection().then((o=>{this._upsertTransaction(o,e,t,r,n).then((e=>{i(e),this._releaseConnection(o)})).catch((e=>{s(e),this._releaseConnection(o)}))})).catch((e=>{s(e)}))})):Promise.reject(Error("Table is not created yet"))}_get(e){return this.tableCreated?new Promise(((t,r)=>{this._getConnection().then((n=>{n.query("SELECT points, expire FROM ??.?? WHERE `key` = ? AND (`expire` > ? OR `expire` IS NULL)",[this.dbName,this.tableName,e,Date.now()],((e,i)=>{e?r(e):0===i.length?t(null):t(i),this._releaseConnection(n)}))})).catch((e=>{r(e)}))})):Promise.reject(Error("Table is not created yet"))}_delete(e){return this.tableCreated?new Promise(((t,r)=>{this._getConnection().then((n=>{n.query("DELETE FROM ??.?? WHERE `key` = ?",[this.dbName,this.tableName,e],((e,i)=>{e?r(e):t(i.affectedRows>0),this._releaseConnection(n)}))})).catch((e=>{r(e)}))})):Promise.reject(Error("Table is not created yet"))}}},3654:(e,t,r)=>{const n=r(1434),i=r(4819);e.exports=class extends n{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;super(e),this.client=e.storeClient,this.clientType=e.storeType,this.tableName=e.tableName,this.clearExpiredByTimeout=e.clearExpiredByTimeout,this.tableCreated=e.tableCreated,this.tableCreated?"function"===typeof t&&t():this._createTable().then((()=>{this.tableCreated=!0,this.clearExpiredByTimeout&&this._clearExpiredHourAgo(),"function"===typeof t&&t()})).catch((e=>{if("function"!==typeof t)throw e;t(e)}))}clearExpired(e){return new Promise((t=>{const r={name:"rlflx-clear-expired",text:"DELETE FROM ".concat(this.tableName," WHERE expire < $1"),values:[e]};this._query(r).then((()=>{t()})).catch((()=>{t()}))}))}_clearExpiredHourAgo(){this._clearExpiredTimeoutId&&clearTimeout(this._clearExpiredTimeoutId),this._clearExpiredTimeoutId=setTimeout((()=>{this.clearExpired(Date.now()-36e5).then((()=>{this._clearExpiredHourAgo()}))}),3e5),this._clearExpiredTimeoutId.unref()}_getConnection(){switch(this.clientType){case"pool":default:return Promise.resolve(this.client);case"sequelize":return this.client.connectionManager.getConnection();case"knex":return this.client.client.acquireConnection();case"typeorm":return Promise.resolve(this.client.driver.master)}}_releaseConnection(e){switch(this.clientType){case"pool":case"typeorm":default:return!0;case"sequelize":return this.client.connectionManager.releaseConnection(e);case"knex":return this.client.client.releaseConnection(e)}}_createTable(){return new Promise(((e,t)=>{this._query({text:this._getCreateTableStmt()}).then((()=>{e()})).catch((r=>{"23505"===r.code?e():t(r)}))}))}_getCreateTableStmt(){return"CREATE TABLE IF NOT EXISTS ".concat(this.tableName," ( \n key varchar(255) PRIMARY KEY,\n points integer NOT NULL DEFAULT 0,\n expire bigint\n );")}get clientType(){return this._clientType}set clientType(e){const t=this.client.constructor.name;if("undefined"===typeof e)if("Client"===t)e="client";else if("Pool"===t||"BoundPool"===t)e="pool";else{if("Sequelize"!==t)throw new Error("storeType is not defined");e="sequelize"}this._clientType=e.toLowerCase()}get tableName(){return this._tableName}set tableName(e){this._tableName="undefined"===typeof e?this.keyPrefix:e}get tableCreated(){return this._tableCreated}set tableCreated(e){this._tableCreated="undefined"!==typeof e&&!!e}get clearExpiredByTimeout(){return this._clearExpiredByTimeout}set clearExpiredByTimeout(e){this._clearExpiredByTimeout="undefined"===typeof e||Boolean(e)}_getRateLimiterRes(e,t,r){const n=new i,s=r.rows[0];return n.isFirstInDuration=t===s.points,n.consumedPoints=n.isFirstInDuration?t:s.points,n.remainingPoints=Math.max(this.points-n.consumedPoints,0),n.msBeforeNext=s.expire?Math.max(s.expire-Date.now(),0):-1,n}_query(e){const t=this.tableName.toLowerCase(),r={name:"".concat(t,":").concat(e.name),text:e.text,values:e.values};return new Promise(((e,t)=>{this._getConnection().then((n=>{n.query(r).then((t=>{e(t),this._releaseConnection(n)})).catch((e=>{t(e),this._releaseConnection(n)}))})).catch((e=>{t(e)}))}))}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!this.tableCreated)return Promise.reject(Error("Table is not created yet"));const i=r>0?Date.now()+r:null,s=n?" $3 ":" CASE\n WHEN ".concat(this.tableName,".expire <= $4 THEN $3\n ELSE ").concat(this.tableName,".expire\n END ");return this._query({name:n?"rlflx-upsert-force":"rlflx-upsert",text:"\n INSERT INTO ".concat(this.tableName," VALUES ($1, $2, $3)\n ON CONFLICT(key) DO UPDATE SET\n points = CASE\n WHEN (").concat(this.tableName,".expire <= $4 OR 1=").concat(n?1:0,") THEN $2\n ELSE ").concat(this.tableName,".points + ($2)\n END,\n expire = ").concat(s,"\n RETURNING points, expire;"),values:[e,t,i,Date.now()]})}_get(e){return this.tableCreated?new Promise(((t,r)=>{this._query({name:"rlflx-get",text:"\n SELECT points, expire FROM ".concat(this.tableName," WHERE key = $1 AND (expire > $2 OR expire IS NULL);"),values:[e,Date.now()]}).then((e=>{0===e.rowCount&&(e=null),t(e)})).catch((e=>{r(e)}))})):Promise.reject(Error("Table is not created yet"))}_delete(e){return this.tableCreated?this._query({name:"rlflx-delete",text:"DELETE FROM ".concat(this.tableName," WHERE key = $1"),values:[e]}).then((e=>e.rowCount>0)):Promise.reject(Error("Table is not created yet"))}}},3081:(e,t,r)=>{const n=r(4688),i=4294967295,s="limiter";e.exports=class{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{maxQueueSize:i};this._queueLimiters={KEY_DEFAULT:new o(e,t)},this._limiterFlexible=e,this._maxQueueSize=t.maxQueueSize}getTokensRemaining(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s;return this._queueLimiters[e]?this._queueLimiters[e].getTokensRemaining():Promise.resolve(this._limiterFlexible.points)}removeTokens(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s;return this._queueLimiters[t]||(this._queueLimiters[t]=new o(this._limiterFlexible,{key:t,maxQueueSize:this._maxQueueSize})),this._queueLimiters[t].removeTokens(e)}};class o{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{maxQueueSize:i,key:s};this._key=t.key,this._waitTimeout=null,this._queue=[],this._limiterFlexible=e,this._maxQueueSize=t.maxQueueSize}getTokensRemaining(){return this._limiterFlexible.get(this._key).then((e=>null!==e?e.remainingPoints:this._limiterFlexible.points))}removeTokens(e){const t=this;return new Promise(((r,i)=>{e>t._limiterFlexible.points?i(new n("Requested tokens ".concat(e," exceeds maximum ").concat(t._limiterFlexible.points," tokens per interval"))):t._queue.length>0?t._queueRequest.call(t,r,i,e):t._limiterFlexible.consume(t._key,e).then((e=>{r(e.remainingPoints)})).catch((n=>{n instanceof Error?i(n):(t._queueRequest.call(t,r,i,e),null===t._waitTimeout&&(t._waitTimeout=setTimeout(t._processFIFO.bind(t),n.msBeforeNext)))}))}))}_queueRequest(e,t,r){const i=this;i._queue.length{t.resolve(r.remainingPoints),e._processFIFO.call(e)})).catch((r=>{r instanceof Error?(t.reject(r),e._processFIFO.call(e)):(e._queue.unshift(t),null===e._waitTimeout&&(e._waitTimeout=setTimeout(e._processFIFO.bind(e),r.msBeforeNext)))}))}}},8139:(e,t,r)=>{const n=r(1434),i=r(4819),s="redis.call('set', KEYS[1], 0, 'EX', ARGV[2], 'NX') local consumed = redis.call('incrby', KEYS[1], ARGV[1]) local ttl = redis.call('pttl', KEYS[1]) if ttl == -1 then redis.call('expire', KEYS[1], ARGV[2]) ttl = 1000 * ARGV[2] end return {consumed, ttl} ";e.exports=class extends n{constructor(e){super(e),e.redis?this.client=e.redis:this.client=e.storeClient,"function"===typeof this.client.defineCommand&&this.client.defineCommand("rlflxIncr",{numberOfKeys:1,lua:s})}_getRateLimiterRes(e,t,r){let[n,s]=r;Array.isArray(n)&&([,n]=n,[,s]=s);const o=new i;return o.consumedPoints=parseInt(n),o.isFirstInDuration=o.consumedPoints===t,o.remainingPoints=Math.max(this.points-o.consumedPoints,0),o.msBeforeNext=s,o}_upsert(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];return new Promise(((i,o)=>{const a=Math.floor(r/1e3),c=this.client.multi();if(n)a>0?c.set(e,t,"EX",a):c.set(e,t),c.pttl(e).exec(((e,t)=>e?o(e):i(t)));else if(a>0){const r=function(e,t){return e?o(e):i(t)};"function"===typeof this.client.rlflxIncr?this.client.rlflxIncr(e,t,a,r):this.client.eval(s,1,e,t,a,r)}else c.incrby(e,t).pttl(e).exec(((e,t)=>e?o(e):i(t)))}))}_get(e){return new Promise(((t,r)=>{this.client.multi().get(e).pttl(e).exec(((e,n)=>{if(e)r(e);else{const[e]=n;if(null===e)return t(null);t(n)}}))}))}_delete(e){return new Promise(((t,r)=>{this.client.del(e,((e,n)=>{e?r(e):t(n>0)}))}))}}},4819:e=>{e.exports=class{constructor(e,t,r,n){this.remainingPoints="undefined"===typeof e?0:e,this.msBeforeNext="undefined"===typeof t?0:t,this.consumedPoints="undefined"===typeof r?0:r,this.isFirstInDuration="undefined"!==typeof n&&n}get msBeforeNext(){return this._msBeforeNext}set msBeforeNext(e){return this._msBeforeNext=e,this}get remainingPoints(){return this._remainingPoints}set remainingPoints(e){return this._remainingPoints=e,this}get consumedPoints(){return this._consumedPoints}set consumedPoints(e){return this._consumedPoints=e,this}get isFirstInDuration(){return this._isFirstInDuration}set isFirstInDuration(e){this._isFirstInDuration=Boolean(e)}_getDecoratedProperties(){return{remainingPoints:this.remainingPoints,msBeforeNext:this.msBeforeNext,consumedPoints:this.consumedPoints,isFirstInDuration:this.isFirstInDuration}}[Symbol.for("nodejs.util.inspect.custom")](){return this._getDecoratedProperties()}toString(){return JSON.stringify(this._getDecoratedProperties())}toJSON(){return this._getDecoratedProperties()}}},1434:(e,t,r)=>{const n=r(8855),i=r(6704),s=r(4819);e.exports=class extends n{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.inmemoryBlockOnConsumed=e.inmemoryBlockOnConsumed,this.inmemoryBlockDuration=e.inmemoryBlockDuration,this.insuranceLimiter=e.insuranceLimiter,this._inmemoryBlockedKeys=new i}get client(){return this._client}set client(e){if("undefined"===typeof e)throw new Error("storeClient is not set");this._client=e}_afterConsume(e,t,r,n,i){let s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};const o=this._getRateLimiterRes(r,n,i);if(this.inmemoryBlockOnConsumed>0&&!(this.inmemoryBlockDuration>0)&&o.consumedPoints>=this.inmemoryBlockOnConsumed)return this._inmemoryBlockedKeys.addMs(r,o.msBeforeNext),o.consumedPoints>this.points?t(o):e(o);if(o.consumedPoints>this.points){let e=Promise.resolve();this.blockDuration>0&&o.consumedPoints<=this.points+n&&(o.msBeforeNext=this.msBlockDuration,e=this._block(r,o.consumedPoints,this.msBlockDuration,s)),this.inmemoryBlockOnConsumed>0&&o.consumedPoints>=this.inmemoryBlockOnConsumed&&(this._inmemoryBlockedKeys.add(r,this.inmemoryBlockDuration),o.msBeforeNext=this.msInmemoryBlockDuration),e.then((()=>{t(o)})).catch((e=>{t(e)}))}else if(this.execEvenly&&o.msBeforeNext>0&&!o.isFirstInDuration){let t=Math.ceil(o.msBeforeNext/(o.remainingPoints+2));t5&&void 0!==arguments[5]&&arguments[5],a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:{};this.insuranceLimiter instanceof n?this.insuranceLimiter[t](s,o,a).then((e=>{r(e)})).catch((e=>{i(e)})):i(e)}getInmemoryBlockMsBeforeExpire(e){return this.inmemoryBlockOnConsumed>0?this._inmemoryBlockedKeys.msBeforeExpire(e):0}get inmemoryBlockOnConsumed(){return this._inmemoryBlockOnConsumed}set inmemoryBlockOnConsumed(e){if(this._inmemoryBlockOnConsumed=e?parseInt(e):0,this.inmemoryBlockOnConsumed>0&&this.points>this.inmemoryBlockOnConsumed)throw new Error('inmemoryBlockOnConsumed option must be greater or equal "points" option')}get inmemoryBlockDuration(){return this._inmemoryBlockDuration}set inmemoryBlockDuration(e){if(this._inmemoryBlockDuration=e?parseInt(e):0,this.inmemoryBlockDuration>0&&0===this.inmemoryBlockOnConsumed)throw new Error("inmemoryBlockOnConsumed option must be set up")}get msInmemoryBlockDuration(){return 1e3*this._inmemoryBlockDuration}get insuranceLimiter(){return this._insuranceLimiter}set insuranceLimiter(e){if("undefined"!==typeof e&&!(e instanceof n))throw new Error("insuranceLimiter must be instance of RateLimiterAbstract");this._insuranceLimiter=e,this._insuranceLimiter&&(this._insuranceLimiter.blockDuration=this.blockDuration,this._insuranceLimiter.execEvenly=this.execEvenly)}block(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=1e3*t;return this._block(this.getKey(e),this.points+1,n,r)}set(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const i=1e3*(r>=0?r:this.duration);return this._block(this.getKey(e),t,i,n)}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return new Promise(((n,i)=>{const o=this.getKey(e),a=this.getInmemoryBlockMsBeforeExpire(o);if(a>0)return i(new s(0,a));this._upsert(o,t,1e3*this._getKeySecDuration(r),!1,r).then((e=>{this._afterConsume(n,i,o,t,e)})).catch((s=>{this._handleError(s,"consume",n,i,e,t,r)}))}))}penalty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e);return new Promise(((i,s)=>{this._upsert(n,t,1e3*this._getKeySecDuration(r),!1,r).then((e=>{i(this._getRateLimiterRes(n,t,e))})).catch((n=>{this._handleError(n,"penalty",i,s,e,t,r)}))}))}reward(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e);return new Promise(((i,s)=>{this._upsert(n,-t,1e3*this._getKeySecDuration(r),!1,r).then((e=>{i(this._getRateLimiterRes(n,-t,e))})).catch((n=>{this._handleError(n,"reward",i,s,e,t,r)}))}))}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=this.getKey(e);return new Promise(((n,i)=>{this._get(r,t).then((e=>{n(null===e||"undefined"===typeof e?null:this._getRateLimiterRes(r,0,e))})).catch((r=>{this._handleError(r,"get",n,i,e,t)}))}))}delete(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=this.getKey(e);return new Promise(((n,i)=>{this._delete(r,t).then((e=>{this._inmemoryBlockedKeys.delete(r),n(e)})).catch((r=>{this._handleError(r,"delete",n,i,e,t)}))}))}deleteInMemoryBlockedAll(){this._inmemoryBlockedKeys.delete()}_getRateLimiterRes(e,t,r){throw new Error("You have to implement the method '_getRateLimiterRes'!")}_block(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new Promise(((i,o)=>{this._upsert(e,t,r,!0,n).then((()=>{i(new s(0,r>0?r:-1,t))})).catch((t=>{this._handleError(t,"block",i,o,this.parseKey(e),r/1e3,n)}))}))}_get(e){throw new Error("You have to implement the method '_get'!")}_delete(e){throw new Error("You have to implement the method '_delete'!")}_upsert(){throw new Error("You have to implement the method '_upsert'!")}}},4066:(e,t,r)=>{const n=r(8855);e.exports=class{constructor(){for(var e=arguments.length,t=new Array(e),r=0;r{if(!(e instanceof n))throw new Error("RateLimiterUnion: all limiters have to be instance of RateLimiterAbstract")})),this._limiters=t}consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return new Promise(((r,n)=>{const i=[];this._limiters.forEach((r=>{i.push(r.consume(e,t).catch((e=>({rejected:!0,rej:e}))))})),Promise.all(i).then((e=>{const t={};let i=!1;e.forEach((e=>{!0===e.rejected&&(i=!0)}));for(let r=0;r{e.exports=class{constructor(){this._keys={},this._addedKeysAmount=0}collectExpired(){const e=Date.now();Object.keys(this._keys).forEach((t=>{this._keys[t]<=e&&delete this._keys[t]})),this._addedKeysAmount=Object.keys(this._keys).length}add(e,t){this.addMs(e,1e3*t)}addMs(e,t){this._keys[e]=Date.now()+t,this._addedKeysAmount++,this._addedKeysAmount>999&&this.collectExpired()}msBeforeExpire(e){const t=this._keys[e];if(t&&t>=Date.now()){this.collectExpired();const e=Date.now();return t>=e?t-e:0}return 0}delete(e){e?delete this._keys[e]:Object.keys(this._keys).forEach((e=>{delete this._keys[e]}))}}},6704:(e,t,r)=>{const n=r(9682);e.exports=n},4327:(e,t,r)=>{const n=r(9359),i=r(4819);e.exports=class{constructor(){this._storage={}}incrby(e,t,r){if(this._storage[e]){const n=this._storage[e].expiresAt?this._storage[e].expiresAt.getTime()-(new Date).getTime():-1;return 0!==n?(this._storage[e].value=this._storage[e].value+t,new i(0,n,this._storage[e].value,!1)):this.set(e,t,r)}return this.set(e,t,r)}set(e,t,r){const s=1e3*r;return this._storage[e]&&this._storage[e].timeoutId&&clearTimeout(this._storage[e].timeoutId),this._storage[e]=new n(t,s>0?new Date(Date.now()+s):null),s>0&&(this._storage[e].timeoutId=setTimeout((()=>{delete this._storage[e]}),s),this._storage[e].timeoutId.unref&&this._storage[e].timeoutId.unref()),new i(0,0===s?-1:s,this._storage[e].value,!0)}get(e){if(this._storage[e]){const t=this._storage[e].expiresAt?this._storage[e].expiresAt.getTime()-(new Date).getTime():-1;return new i(0,t,this._storage[e].value,!1)}return null}delete(e){return!!this._storage[e]&&(this._storage[e].timeoutId&&clearTimeout(this._storage[e].timeoutId),delete this._storage[e],!0)}}},9359:e=>{e.exports=class{constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;this.value=e,this.expiresAt=t,this.timeoutId=r}get value(){return this._value}set value(e){this._value=parseInt(e)}get expiresAt(){return this._expiresAt}set expiresAt(e){e instanceof Date||!Number.isInteger(e)||(e=new Date(e)),this._expiresAt=e}get timeoutId(){return this._timeoutId}set timeoutId(e){this._timeoutId=e}}},4688:e=>{e.exports=class extends Error{constructor(e,t){super(),Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="CustomError",this.message=e,t&&(this.extra=t)}}},4463:(e,t,r)=>{"use strict";var n=r(2791),i=r(5296);function s(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r