@dcl/profile-site 0.4.1-5824379211.commit-5c7e1a0 → 0.4.1-5825543253.commit-f8e4ddd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ import{z as $_,r as D_,b as Zi,A as vr,C as cr,t as yr,D as jc,d as Xi,u as F_,j as Fr,g as M_,N as tu,F as Sl,_ as j_}from"./index-c0709bb3.js";import{t as Vr}from"./tslib-171b5081.js";import{s as q_,a as z_,d as H_,f as Mo,g as ru,c as B_,b as jo,e as ed,h as iu}from"./index-aa2489d5.js";let K_=class{};class k_ extends K_{constructor(){super()}}class V_ extends k_{constructor(t){super()}}const W_="^https?:",G_="^wss?:";function Y_(n){const t=n.match(new RegExp(/^\w+:/,"gi"));if(!(!t||!t.length))return t[0]}function td(n,t){const r=Y_(n);return typeof r>"u"?!1:new RegExp(t).test(r)}function Il(n){return td(n,W_)}function xl(n){return td(n,G_)}function J_(n){return new RegExp("wss?://localhost(:d{2,5})?").test(n)}function rd(n){return typeof n=="object"&&"id"in n&&"jsonrpc"in n&&n.jsonrpc==="2.0"}function nu(n){return rd(n)&&"method"in n}function qo(n){return rd(n)&&(gi(n)||Kr(n))}function gi(n){return"result"in n}function Kr(n){return"error"in n}var su={},zo={},De={},id={};(function(n){Object.defineProperty(n,"__esModule",{value:!0});function t(d,v){var b=d>>>16&65535,x=d&65535,$=v>>>16&65535,j=v&65535;return x*j+(b*j+x*$<<16>>>0)|0}n.mul=Math.imul||t;function r(d,v){return d+v|0}n.add=r;function s(d,v){return d-v|0}n.sub=s;function a(d,v){return d<<v|d>>>32-v}n.rotl=a;function l(d,v){return d<<32-v|d>>>v}n.rotr=l;function p(d){return typeof d=="number"&&isFinite(d)&&Math.floor(d)===d}n.isInteger=Number.isInteger||p,n.MAX_SAFE_INTEGER=9007199254740991,n.isSafeInteger=function(d){return n.isInteger(d)&&d>=-n.MAX_SAFE_INTEGER&&d<=n.MAX_SAFE_INTEGER}})(id);Object.defineProperty(De,"__esModule",{value:!0});var nd=id;function X_(n,t){return t===void 0&&(t=0),(n[t+0]<<8|n[t+1])<<16>>16}De.readInt16BE=X_;function Q_(n,t){return t===void 0&&(t=0),(n[t+0]<<8|n[t+1])>>>0}De.readUint16BE=Q_;function Z_(n,t){return t===void 0&&(t=0),(n[t+1]<<8|n[t])<<16>>16}De.readInt16LE=Z_;function em(n,t){return t===void 0&&(t=0),(n[t+1]<<8|n[t])>>>0}De.readUint16LE=em;function sd(n,t,r){return t===void 0&&(t=new Uint8Array(2)),r===void 0&&(r=0),t[r+0]=n>>>8,t[r+1]=n>>>0,t}De.writeUint16BE=sd;De.writeInt16BE=sd;function od(n,t,r){return t===void 0&&(t=new Uint8Array(2)),r===void 0&&(r=0),t[r+0]=n>>>0,t[r+1]=n>>>8,t}De.writeUint16LE=od;De.writeInt16LE=od;function qc(n,t){return t===void 0&&(t=0),n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}De.readInt32BE=qc;function zc(n,t){return t===void 0&&(t=0),(n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3])>>>0}De.readUint32BE=zc;function Hc(n,t){return t===void 0&&(t=0),n[t+3]<<24|n[t+2]<<16|n[t+1]<<8|n[t]}De.readInt32LE=Hc;function Bc(n,t){return t===void 0&&(t=0),(n[t+3]<<24|n[t+2]<<16|n[t+1]<<8|n[t])>>>0}De.readUint32LE=Bc;function No(n,t,r){return t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0),t[r+0]=n>>>24,t[r+1]=n>>>16,t[r+2]=n>>>8,t[r+3]=n>>>0,t}De.writeUint32BE=No;De.writeInt32BE=No;function Co(n,t,r){return t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0),t[r+0]=n>>>0,t[r+1]=n>>>8,t[r+2]=n>>>16,t[r+3]=n>>>24,t}De.writeUint32LE=Co;De.writeInt32LE=Co;function tm(n,t){t===void 0&&(t=0);var r=qc(n,t),s=qc(n,t+4);return r*4294967296+s-(s>>31)*4294967296}De.readInt64BE=tm;function rm(n,t){t===void 0&&(t=0);var r=zc(n,t),s=zc(n,t+4);return r*4294967296+s}De.readUint64BE=rm;function im(n,t){t===void 0&&(t=0);var r=Hc(n,t),s=Hc(n,t+4);return s*4294967296+r-(r>>31)*4294967296}De.readInt64LE=im;function nm(n,t){t===void 0&&(t=0);var r=Bc(n,t),s=Bc(n,t+4);return s*4294967296+r}De.readUint64LE=nm;function ad(n,t,r){return t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0),No(n/4294967296>>>0,t,r),No(n>>>0,t,r+4),t}De.writeUint64BE=ad;De.writeInt64BE=ad;function cd(n,t,r){return t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0),Co(n>>>0,t,r),Co(n/4294967296>>>0,t,r+4),t}De.writeUint64LE=cd;De.writeInt64LE=cd;function sm(n,t,r){if(r===void 0&&(r=0),n%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(n/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var s=0,a=1,l=n/8+r-1;l>=r;l--)s+=t[l]*a,a*=256;return s}De.readUintBE=sm;function om(n,t,r){if(r===void 0&&(r=0),n%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(n/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var s=0,a=1,l=r;l<r+n/8;l++)s+=t[l]*a,a*=256;return s}De.readUintLE=om;function am(n,t,r,s){if(r===void 0&&(r=new Uint8Array(n/8)),s===void 0&&(s=0),n%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!nd.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var a=1,l=n/8+s-1;l>=s;l--)r[l]=t/a&255,a*=256;return r}De.writeUintBE=am;function cm(n,t,r,s){if(r===void 0&&(r=new Uint8Array(n/8)),s===void 0&&(s=0),n%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!nd.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var a=1,l=s;l<s+n/8;l++)r[l]=t/a&255,a*=256;return r}De.writeUintLE=cm;function um(n,t){t===void 0&&(t=0);var r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.getFloat32(t)}De.readFloat32BE=um;function hm(n,t){t===void 0&&(t=0);var r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.getFloat32(t,!0)}De.readFloat32LE=hm;function lm(n,t){t===void 0&&(t=0);var r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.getFloat64(t)}De.readFloat64BE=lm;function fm(n,t){t===void 0&&(t=0);var r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.getFloat64(t,!0)}De.readFloat64LE=fm;function dm(n,t,r){t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0);var s=new DataView(t.buffer,t.byteOffset,t.byteLength);return s.setFloat32(r,n),t}De.writeFloat32BE=dm;function pm(n,t,r){t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0);var s=new DataView(t.buffer,t.byteOffset,t.byteLength);return s.setFloat32(r,n,!0),t}De.writeFloat32LE=pm;function gm(n,t,r){t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0);var s=new DataView(t.buffer,t.byteOffset,t.byteLength);return s.setFloat64(r,n),t}De.writeFloat64BE=gm;function vm(n,t,r){t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0);var s=new DataView(t.buffer,t.byteOffset,t.byteLength);return s.setFloat64(r,n,!0),t}De.writeFloat64LE=vm;var Ir={};Object.defineProperty(Ir,"__esModule",{value:!0});function ym(n){for(var t=0;t<n.length;t++)n[t]=0;return n}Ir.wipe=ym;Object.defineProperty(zo,"__esModule",{value:!0});var Qt=De,Kc=Ir,_m=20;function mm(n,t,r){for(var s=1634760805,a=857760878,l=2036477234,p=1797285236,d=r[3]<<24|r[2]<<16|r[1]<<8|r[0],v=r[7]<<24|r[6]<<16|r[5]<<8|r[4],b=r[11]<<24|r[10]<<16|r[9]<<8|r[8],x=r[15]<<24|r[14]<<16|r[13]<<8|r[12],$=r[19]<<24|r[18]<<16|r[17]<<8|r[16],j=r[23]<<24|r[22]<<16|r[21]<<8|r[20],U=r[27]<<24|r[26]<<16|r[25]<<8|r[24],z=r[31]<<24|r[30]<<16|r[29]<<8|r[28],B=t[3]<<24|t[2]<<16|t[1]<<8|t[0],K=t[7]<<24|t[6]<<16|t[5]<<8|t[4],oe=t[11]<<24|t[10]<<16|t[9]<<8|t[8],T=t[15]<<24|t[14]<<16|t[13]<<8|t[12],D=s,S=a,P=l,m=p,u=d,_=v,W=b,V=x,se=$,ce=j,ge=U,N=z,q=B,le=K,te=oe,G=T,ee=0;ee<_m;ee+=2)D=D+u|0,q^=D,q=q>>>32-16|q<<16,se=se+q|0,u^=se,u=u>>>32-12|u<<12,S=S+_|0,le^=S,le=le>>>32-16|le<<16,ce=ce+le|0,_^=ce,_=_>>>32-12|_<<12,P=P+W|0,te^=P,te=te>>>32-16|te<<16,ge=ge+te|0,W^=ge,W=W>>>32-12|W<<12,m=m+V|0,G^=m,G=G>>>32-16|G<<16,N=N+G|0,V^=N,V=V>>>32-12|V<<12,P=P+W|0,te^=P,te=te>>>32-8|te<<8,ge=ge+te|0,W^=ge,W=W>>>32-7|W<<7,m=m+V|0,G^=m,G=G>>>32-8|G<<8,N=N+G|0,V^=N,V=V>>>32-7|V<<7,S=S+_|0,le^=S,le=le>>>32-8|le<<8,ce=ce+le|0,_^=ce,_=_>>>32-7|_<<7,D=D+u|0,q^=D,q=q>>>32-8|q<<8,se=se+q|0,u^=se,u=u>>>32-7|u<<7,D=D+_|0,G^=D,G=G>>>32-16|G<<16,ge=ge+G|0,_^=ge,_=_>>>32-12|_<<12,S=S+W|0,q^=S,q=q>>>32-16|q<<16,N=N+q|0,W^=N,W=W>>>32-12|W<<12,P=P+V|0,le^=P,le=le>>>32-16|le<<16,se=se+le|0,V^=se,V=V>>>32-12|V<<12,m=m+u|0,te^=m,te=te>>>32-16|te<<16,ce=ce+te|0,u^=ce,u=u>>>32-12|u<<12,P=P+V|0,le^=P,le=le>>>32-8|le<<8,se=se+le|0,V^=se,V=V>>>32-7|V<<7,m=m+u|0,te^=m,te=te>>>32-8|te<<8,ce=ce+te|0,u^=ce,u=u>>>32-7|u<<7,S=S+W|0,q^=S,q=q>>>32-8|q<<8,N=N+q|0,W^=N,W=W>>>32-7|W<<7,D=D+_|0,G^=D,G=G>>>32-8|G<<8,ge=ge+G|0,_^=ge,_=_>>>32-7|_<<7;Qt.writeUint32LE(D+s|0,n,0),Qt.writeUint32LE(S+a|0,n,4),Qt.writeUint32LE(P+l|0,n,8),Qt.writeUint32LE(m+p|0,n,12),Qt.writeUint32LE(u+d|0,n,16),Qt.writeUint32LE(_+v|0,n,20),Qt.writeUint32LE(W+b|0,n,24),Qt.writeUint32LE(V+x|0,n,28),Qt.writeUint32LE(se+$|0,n,32),Qt.writeUint32LE(ce+j|0,n,36),Qt.writeUint32LE(ge+U|0,n,40),Qt.writeUint32LE(N+z|0,n,44),Qt.writeUint32LE(q+B|0,n,48),Qt.writeUint32LE(le+K|0,n,52),Qt.writeUint32LE(te+oe|0,n,56),Qt.writeUint32LE(G+T|0,n,60)}function ud(n,t,r,s,a){if(a===void 0&&(a=0),n.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(s.length<r.length)throw new Error("ChaCha: destination is shorter than source");var l,p;if(a===0){if(t.length!==8&&t.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");l=new Uint8Array(16),p=l.length-t.length,l.set(t,p)}else{if(t.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");l=t,p=a}for(var d=new Uint8Array(64),v=0;v<r.length;v+=64){mm(d,l,n);for(var b=v;b<v+64&&b<r.length;b++)s[b]=r[b]^d[b-v];bm(l,0,p)}return Kc.wipe(d),a===0&&Kc.wipe(l),s}zo.streamXOR=ud;function wm(n,t,r,s){return s===void 0&&(s=0),Kc.wipe(r),ud(n,t,r,r,s)}zo.stream=wm;function bm(n,t,r){for(var s=1;r--;)s=s+(n[t]&255)|0,n[t]=s&255,s>>>=8,t++;if(s>0)throw new Error("ChaCha: counter overflow")}var hd={},Ni={};Object.defineProperty(Ni,"__esModule",{value:!0});function Em(n,t,r){return~(n-1)&t|n-1&r}Ni.select=Em;function Sm(n,t){return(n|0)-(t|0)-1>>>31&1}Ni.lessOrEqual=Sm;function ld(n,t){if(n.length!==t.length)return 0;for(var r=0,s=0;s<n.length;s++)r|=n[s]^t[s];return 1&r-1>>>8}Ni.compare=ld;function Im(n,t){return n.length===0||t.length===0?!1:ld(n,t)!==0}Ni.equal=Im;(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t=Ni,r=Ir;n.DIGEST_LENGTH=16;var s=function(){function p(d){this.digestLength=n.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 v=d[0]|d[1]<<8;this._r[0]=v&8191;var b=d[2]|d[3]<<8;this._r[1]=(v>>>13|b<<3)&8191;var x=d[4]|d[5]<<8;this._r[2]=(b>>>10|x<<6)&7939;var $=d[6]|d[7]<<8;this._r[3]=(x>>>7|$<<9)&8191;var j=d[8]|d[9]<<8;this._r[4]=($>>>4|j<<12)&255,this._r[5]=j>>>1&8190;var U=d[10]|d[11]<<8;this._r[6]=(j>>>14|U<<2)&8191;var z=d[12]|d[13]<<8;this._r[7]=(U>>>11|z<<5)&8065;var B=d[14]|d[15]<<8;this._r[8]=(z>>>8|B<<8)&8191,this._r[9]=B>>>5&127,this._pad[0]=d[16]|d[17]<<8,this._pad[1]=d[18]|d[19]<<8,this._pad[2]=d[20]|d[21]<<8,this._pad[3]=d[22]|d[23]<<8,this._pad[4]=d[24]|d[25]<<8,this._pad[5]=d[26]|d[27]<<8,this._pad[6]=d[28]|d[29]<<8,this._pad[7]=d[30]|d[31]<<8}return p.prototype._blocks=function(d,v,b){for(var x=this._fin?0:2048,$=this._h[0],j=this._h[1],U=this._h[2],z=this._h[3],B=this._h[4],K=this._h[5],oe=this._h[6],T=this._h[7],D=this._h[8],S=this._h[9],P=this._r[0],m=this._r[1],u=this._r[2],_=this._r[3],W=this._r[4],V=this._r[5],se=this._r[6],ce=this._r[7],ge=this._r[8],N=this._r[9];b>=16;){var q=d[v+0]|d[v+1]<<8;$+=q&8191;var le=d[v+2]|d[v+3]<<8;j+=(q>>>13|le<<3)&8191;var te=d[v+4]|d[v+5]<<8;U+=(le>>>10|te<<6)&8191;var G=d[v+6]|d[v+7]<<8;z+=(te>>>7|G<<9)&8191;var ee=d[v+8]|d[v+9]<<8;B+=(G>>>4|ee<<12)&8191,K+=ee>>>1&8191;var Y=d[v+10]|d[v+11]<<8;oe+=(ee>>>14|Y<<2)&8191;var re=d[v+12]|d[v+13]<<8;T+=(Y>>>11|re<<5)&8191;var Oe=d[v+14]|d[v+15]<<8;D+=(re>>>8|Oe<<8)&8191,S+=Oe>>>5|x;var ie=0,we=ie;we+=$*P,we+=j*(5*N),we+=U*(5*ge),we+=z*(5*ce),we+=B*(5*se),ie=we>>>13,we&=8191,we+=K*(5*V),we+=oe*(5*W),we+=T*(5*_),we+=D*(5*u),we+=S*(5*m),ie+=we>>>13,we&=8191;var he=ie;he+=$*m,he+=j*P,he+=U*(5*N),he+=z*(5*ge),he+=B*(5*ce),ie=he>>>13,he&=8191,he+=K*(5*se),he+=oe*(5*V),he+=T*(5*W),he+=D*(5*_),he+=S*(5*u),ie+=he>>>13,he&=8191;var _e=ie;_e+=$*u,_e+=j*m,_e+=U*P,_e+=z*(5*N),_e+=B*(5*ge),ie=_e>>>13,_e&=8191,_e+=K*(5*ce),_e+=oe*(5*se),_e+=T*(5*V),_e+=D*(5*W),_e+=S*(5*_),ie+=_e>>>13,_e&=8191;var M=ie;M+=$*_,M+=j*u,M+=U*m,M+=z*P,M+=B*(5*N),ie=M>>>13,M&=8191,M+=K*(5*ge),M+=oe*(5*ce),M+=T*(5*se),M+=D*(5*V),M+=S*(5*W),ie+=M>>>13,M&=8191;var F=ie;F+=$*W,F+=j*_,F+=U*u,F+=z*m,F+=B*P,ie=F>>>13,F&=8191,F+=K*(5*N),F+=oe*(5*ge),F+=T*(5*ce),F+=D*(5*se),F+=S*(5*V),ie+=F>>>13,F&=8191;var A=ie;A+=$*V,A+=j*W,A+=U*_,A+=z*u,A+=B*m,ie=A>>>13,A&=8191,A+=K*P,A+=oe*(5*N),A+=T*(5*ge),A+=D*(5*ce),A+=S*(5*se),ie+=A>>>13,A&=8191;var h=ie;h+=$*se,h+=j*V,h+=U*W,h+=z*_,h+=B*u,ie=h>>>13,h&=8191,h+=K*m,h+=oe*P,h+=T*(5*N),h+=D*(5*ge),h+=S*(5*ce),ie+=h>>>13,h&=8191;var I=ie;I+=$*ce,I+=j*se,I+=U*V,I+=z*W,I+=B*_,ie=I>>>13,I&=8191,I+=K*u,I+=oe*m,I+=T*P,I+=D*(5*N),I+=S*(5*ge),ie+=I>>>13,I&=8191;var ne=ie;ne+=$*ge,ne+=j*ce,ne+=U*se,ne+=z*V,ne+=B*W,ie=ne>>>13,ne&=8191,ne+=K*_,ne+=oe*u,ne+=T*m,ne+=D*P,ne+=S*(5*N),ie+=ne>>>13,ne&=8191;var fe=ie;fe+=$*N,fe+=j*ge,fe+=U*ce,fe+=z*se,fe+=B*V,ie=fe>>>13,fe&=8191,fe+=K*W,fe+=oe*_,fe+=T*u,fe+=D*m,fe+=S*P,ie+=fe>>>13,fe&=8191,ie=(ie<<2)+ie|0,ie=ie+we|0,we=ie&8191,ie=ie>>>13,he+=ie,$=we,j=he,U=_e,z=M,B=F,K=A,oe=h,T=I,D=ne,S=fe,v+=16,b-=16}this._h[0]=$,this._h[1]=j,this._h[2]=U,this._h[3]=z,this._h[4]=B,this._h[5]=K,this._h[6]=oe,this._h[7]=T,this._h[8]=D,this._h[9]=S},p.prototype.finish=function(d,v){v===void 0&&(v=0);var b=new Uint16Array(10),x,$,j,U;if(this._leftover){for(U=this._leftover,this._buffer[U++]=1;U<16;U++)this._buffer[U]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(x=this._h[1]>>>13,this._h[1]&=8191,U=2;U<10;U++)this._h[U]+=x,x=this._h[U]>>>13,this._h[U]&=8191;for(this._h[0]+=x*5,x=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=x,x=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=x,b[0]=this._h[0]+5,x=b[0]>>>13,b[0]&=8191,U=1;U<10;U++)b[U]=this._h[U]+x,x=b[U]>>>13,b[U]&=8191;for(b[9]-=8192,$=(x^1)-1,U=0;U<10;U++)b[U]&=$;for($=~$,U=0;U<10;U++)this._h[U]=this._h[U]&$|b[U];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,j=this._h[0]+this._pad[0],this._h[0]=j&65535,U=1;U<8;U++)j=(this._h[U]+this._pad[U]|0)+(j>>>16)|0,this._h[U]=j&65535;return d[v+0]=this._h[0]>>>0,d[v+1]=this._h[0]>>>8,d[v+2]=this._h[1]>>>0,d[v+3]=this._h[1]>>>8,d[v+4]=this._h[2]>>>0,d[v+5]=this._h[2]>>>8,d[v+6]=this._h[3]>>>0,d[v+7]=this._h[3]>>>8,d[v+8]=this._h[4]>>>0,d[v+9]=this._h[4]>>>8,d[v+10]=this._h[5]>>>0,d[v+11]=this._h[5]>>>8,d[v+12]=this._h[6]>>>0,d[v+13]=this._h[6]>>>8,d[v+14]=this._h[7]>>>0,d[v+15]=this._h[7]>>>8,this._finished=!0,this},p.prototype.update=function(d){var v=0,b=d.length,x;if(this._leftover){x=16-this._leftover,x>b&&(x=b);for(var $=0;$<x;$++)this._buffer[this._leftover+$]=d[v+$];if(b-=x,v+=x,this._leftover+=x,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(b>=16&&(x=b-b%16,this._blocks(d,v,x),v+=x,b-=x),b){for(var $=0;$<b;$++)this._buffer[this._leftover+$]=d[v+$];this._leftover+=b}return this},p.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var d=new Uint8Array(16);return this.finish(d),d},p.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},p}();n.Poly1305=s;function a(p,d){var v=new s(p);v.update(d);var b=v.digest();return v.clean(),b}n.oneTimeAuth=a;function l(p,d){return p.length!==n.DIGEST_LENGTH||d.length!==n.DIGEST_LENGTH?!1:t.equal(p,d)}n.equal=l})(hd);(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t=zo,r=hd,s=Ir,a=De,l=Ni;n.KEY_LENGTH=32,n.NONCE_LENGTH=12,n.TAG_LENGTH=16;var p=new Uint8Array(16),d=function(){function v(b){if(this.nonceLength=n.NONCE_LENGTH,this.tagLength=n.TAG_LENGTH,b.length!==n.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(b)}return v.prototype.seal=function(b,x,$,j){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var U=new Uint8Array(16);U.set(b,U.length-b.length);var z=new Uint8Array(32);t.stream(this._key,U,z,4);var B=x.length+this.tagLength,K;if(j){if(j.length!==B)throw new Error("ChaCha20Poly1305: incorrect destination length");K=j}else K=new Uint8Array(B);return t.streamXOR(this._key,U,x,K,4),this._authenticate(K.subarray(K.length-this.tagLength,K.length),z,K.subarray(0,K.length-this.tagLength),$),s.wipe(U),K},v.prototype.open=function(b,x,$,j){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(x.length<this.tagLength)return null;var U=new Uint8Array(16);U.set(b,U.length-b.length);var z=new Uint8Array(32);t.stream(this._key,U,z,4);var B=new Uint8Array(this.tagLength);if(this._authenticate(B,z,x.subarray(0,x.length-this.tagLength),$),!l.equal(B,x.subarray(x.length-this.tagLength,x.length)))return null;var K=x.length-this.tagLength,oe;if(j){if(j.length!==K)throw new Error("ChaCha20Poly1305: incorrect destination length");oe=j}else oe=new Uint8Array(K);return t.streamXOR(this._key,U,x.subarray(0,x.length-this.tagLength),oe,4),s.wipe(U),oe},v.prototype.clean=function(){return s.wipe(this._key),this},v.prototype._authenticate=function(b,x,$,j){var U=new r.Poly1305(x);j&&(U.update(j),j.length%16>0&&U.update(p.subarray(j.length%16))),U.update($),$.length%16>0&&U.update(p.subarray($.length%16));var z=new Uint8Array(8);j&&a.writeUint64LE(j.length,z),U.update(z),a.writeUint64LE($.length,z),U.update(z);for(var B=U.digest(),K=0;K<B.length;K++)b[K]=B[K];U.clean(),s.wipe(B),s.wipe(z)},v}();n.ChaCha20Poly1305=d})(su);var fd={},gs={},ou={};Object.defineProperty(ou,"__esModule",{value:!0});function xm(n){return typeof n.saveState<"u"&&typeof n.restoreState<"u"&&typeof n.cleanSavedState<"u"}ou.isSerializableHash=xm;Object.defineProperty(gs,"__esModule",{value:!0});var Zr=ou,Om=Ni,Pm=Ir,dd=function(){function n(t,r){this._finished=!1,this._inner=new t,this._outer=new t,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var s=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(s).clean():s.set(r);for(var a=0;a<s.length;a++)s[a]^=54;this._inner.update(s);for(var a=0;a<s.length;a++)s[a]^=106;this._outer.update(s),Zr.isSerializableHash(this._inner)&&Zr.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),Pm.wipe(s)}return n.prototype.reset=function(){if(!Zr.isSerializableHash(this._inner)||!Zr.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},n.prototype.clean=function(){Zr.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Zr.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},n.prototype.update=function(t){return this._inner.update(t),this},n.prototype.finish=function(t){return this._finished?(this._outer.finish(t),this):(this._inner.finish(t),this._outer.update(t.subarray(0,this.digestLength)).finish(t),this._finished=!0,this)},n.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},n.prototype.saveState=function(){if(!Zr.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},n.prototype.restoreState=function(t){if(!Zr.isSerializableHash(this._inner)||!Zr.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(t),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},n.prototype.cleanSavedState=function(t){if(!Zr.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(t)},n}();gs.HMAC=dd;function Am(n,t,r){var s=new dd(n,t);s.update(r);var a=s.digest();return s.clean(),a}gs.hmac=Am;gs.equal=Om.equal;Object.defineProperty(fd,"__esModule",{value:!0});var Ol=gs,Pl=Ir,Tm=function(){function n(t,r,s,a){s===void 0&&(s=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=t,this._info=a;var l=Ol.hmac(this._hash,s,r);this._hmac=new Ol.HMAC(t,l),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return n.prototype._fillBuffer=function(){this._counter[0]++;var t=this._counter[0];if(t===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),t>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},n.prototype.expand=function(t){for(var r=new Uint8Array(t),s=0;s<r.length;s++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[s]=this._buffer[this._bufpos++];return r},n.prototype.clean=function(){this._hmac.clean(),Pl.wipe(this._buffer),Pl.wipe(this._counter),this._bufpos=0},n}(),Nm=fd.HKDF=Tm,Nn={},Ho={},Bo={};Object.defineProperty(Bo,"__esModule",{value:!0});Bo.BrowserRandomSource=void 0;const Al=65536;class Cm{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const t=typeof self<"u"?self.crypto||self.msCrypto:null;t&&t.getRandomValues!==void 0&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(t);for(let s=0;s<r.length;s+=Al)this._crypto.getRandomValues(r.subarray(s,s+Math.min(r.length-s,Al)));return r}}Bo.BrowserRandomSource=Cm;var Ko={};Object.defineProperty(Ko,"__esModule",{value:!0});Ko.NodeRandomSource=void 0;const Rm=Ir;class Um{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof $_<"u"){const t=D_;t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(t);if(r.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");const s=new Uint8Array(t);for(let a=0;a<s.length;a++)s[a]=r[a];return(0,Rm.wipe)(r),s}}Ko.NodeRandomSource=Um;Object.defineProperty(Ho,"__esModule",{value:!0});Ho.SystemRandomSource=void 0;const Lm=Bo,$m=Ko;class Dm{constructor(){if(this.isAvailable=!1,this.name="",this._source=new Lm.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new $m.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}}Ho.SystemRandomSource=Dm;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.randomStringForEntropy=n.randomString=n.randomUint32=n.randomBytes=n.defaultRandomSource=void 0;const t=Ho,r=De,s=Ir;n.defaultRandomSource=new t.SystemRandomSource;function a(b,x=n.defaultRandomSource){return x.randomBytes(b)}n.randomBytes=a;function l(b=n.defaultRandomSource){const x=a(4,b),$=(0,r.readUint32LE)(x);return(0,s.wipe)(x),$}n.randomUint32=l;const p="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function d(b,x=p,$=n.defaultRandomSource){if(x.length<2)throw new Error("randomString charset is too short");if(x.length>256)throw new Error("randomString charset is too long");let j="";const U=x.length,z=256-256%U;for(;b>0;){const B=a(Math.ceil(b*256/z),$);for(let K=0;K<B.length&&b>0;K++){const oe=B[K];oe<z&&(j+=x.charAt(oe%U),b--)}(0,s.wipe)(B)}return j}n.randomString=d;function v(b,x=p,$=n.defaultRandomSource){const j=Math.ceil(b/(Math.log(x.length)/Math.LN2));return d(j,x,$)}n.randomStringForEntropy=v})(Nn);var ko={};(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t=De,r=Ir;n.DIGEST_LENGTH=32,n.BLOCK_SIZE=64;var s=function(){function d(){this.digestLength=n.DIGEST_LENGTH,this.blockSize=n.BLOCK_SIZE,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 d.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},d.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},d.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},d.prototype.update=function(v,b){if(b===void 0&&(b=v.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var x=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&b>0;)this._buffer[this._bufferLength++]=v[x++],b--;this._bufferLength===this.blockSize&&(l(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(x=l(this._temp,this._state,v,x,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=v[x++],b--;return this},d.prototype.finish=function(v){if(!this._finished){var b=this._bytesHashed,x=this._bufferLength,$=b/536870912|0,j=b<<3,U=b%64<56?64:128;this._buffer[x]=128;for(var z=x+1;z<U-8;z++)this._buffer[z]=0;t.writeUint32BE($,this._buffer,U-8),t.writeUint32BE(j,this._buffer,U-4),l(this._temp,this._state,this._buffer,0,U),this._finished=!0}for(var z=0;z<this.digestLength/4;z++)t.writeUint32BE(this._state[z],v,z*4);return this},d.prototype.digest=function(){var v=new Uint8Array(this.digestLength);return this.finish(v),v},d.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},d.prototype.restoreState=function(v){return this._state.set(v.state),this._bufferLength=v.bufferLength,v.buffer&&this._buffer.set(v.buffer),this._bytesHashed=v.bytesHashed,this._finished=!1,this},d.prototype.cleanSavedState=function(v){r.wipe(v.state),v.buffer&&r.wipe(v.buffer),v.bufferLength=0,v.bytesHashed=0},d}();n.SHA256=s;var a=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 l(d,v,b,x,$){for(;$>=64;){for(var j=v[0],U=v[1],z=v[2],B=v[3],K=v[4],oe=v[5],T=v[6],D=v[7],S=0;S<16;S++){var P=x+S*4;d[S]=t.readUint32BE(b,P)}for(var S=16;S<64;S++){var m=d[S-2],u=(m>>>17|m<<32-17)^(m>>>19|m<<32-19)^m>>>10;m=d[S-15];var _=(m>>>7|m<<32-7)^(m>>>18|m<<32-18)^m>>>3;d[S]=(u+d[S-7]|0)+(_+d[S-16]|0)}for(var S=0;S<64;S++){var u=(((K>>>6|K<<26)^(K>>>11|K<<21)^(K>>>25|K<<7))+(K&oe^~K&T)|0)+(D+(a[S]+d[S]|0)|0)|0,_=((j>>>2|j<<32-2)^(j>>>13|j<<32-13)^(j>>>22|j<<32-22))+(j&U^j&z^U&z)|0;D=T,T=oe,oe=K,K=B+u|0,B=z,z=U,U=j,j=u+_|0}v[0]+=j,v[1]+=U,v[2]+=z,v[3]+=B,v[4]+=K,v[5]+=oe,v[6]+=T,v[7]+=D,x+=64,$-=64}return x}function p(d){var v=new s;v.update(d);var b=v.digest();return v.clean(),b}n.hash=p})(ko);var au={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.sharedKey=n.generateKeyPair=n.generateKeyPairFromSeed=n.scalarMultBase=n.scalarMult=n.SHARED_KEY_LENGTH=n.SECRET_KEY_LENGTH=n.PUBLIC_KEY_LENGTH=void 0;const t=Nn,r=Ir;n.PUBLIC_KEY_LENGTH=32,n.SECRET_KEY_LENGTH=32,n.SHARED_KEY_LENGTH=32;function s(S){const P=new Float64Array(16);if(S)for(let m=0;m<S.length;m++)P[m]=S[m];return P}const a=new Uint8Array(32);a[0]=9;const l=s([56129,1]);function p(S){let P=1;for(let m=0;m<16;m++){let u=S[m]+P+65535;P=Math.floor(u/65536),S[m]=u-P*65536}S[0]+=P-1+37*(P-1)}function d(S,P,m){const u=~(m-1);for(let _=0;_<16;_++){const W=u&(S[_]^P[_]);S[_]^=W,P[_]^=W}}function v(S,P){const m=s(),u=s();for(let _=0;_<16;_++)u[_]=P[_];p(u),p(u),p(u);for(let _=0;_<2;_++){m[0]=u[0]-65517;for(let V=1;V<15;V++)m[V]=u[V]-65535-(m[V-1]>>16&1),m[V-1]&=65535;m[15]=u[15]-32767-(m[14]>>16&1);const W=m[15]>>16&1;m[14]&=65535,d(u,m,1-W)}for(let _=0;_<16;_++)S[2*_]=u[_]&255,S[2*_+1]=u[_]>>8}function b(S,P){for(let m=0;m<16;m++)S[m]=P[2*m]+(P[2*m+1]<<8);S[15]&=32767}function x(S,P,m){for(let u=0;u<16;u++)S[u]=P[u]+m[u]}function $(S,P,m){for(let u=0;u<16;u++)S[u]=P[u]-m[u]}function j(S,P,m){let u,_,W=0,V=0,se=0,ce=0,ge=0,N=0,q=0,le=0,te=0,G=0,ee=0,Y=0,re=0,Oe=0,ie=0,we=0,he=0,_e=0,M=0,F=0,A=0,h=0,I=0,ne=0,fe=0,Ie=0,He=0,ke=0,Fe=0,pt=0,gt=0,je=m[0],xe=m[1],Ue=m[2],Le=m[3],qe=m[4],Ae=m[5],$e=m[6],Se=m[7],Te=m[8],Be=m[9],Pe=m[10],Ve=m[11],Ge=m[12],et=m[13],tt=m[14],Je=m[15];u=P[0],W+=u*je,V+=u*xe,se+=u*Ue,ce+=u*Le,ge+=u*qe,N+=u*Ae,q+=u*$e,le+=u*Se,te+=u*Te,G+=u*Be,ee+=u*Pe,Y+=u*Ve,re+=u*Ge,Oe+=u*et,ie+=u*tt,we+=u*Je,u=P[1],V+=u*je,se+=u*xe,ce+=u*Ue,ge+=u*Le,N+=u*qe,q+=u*Ae,le+=u*$e,te+=u*Se,G+=u*Te,ee+=u*Be,Y+=u*Pe,re+=u*Ve,Oe+=u*Ge,ie+=u*et,we+=u*tt,he+=u*Je,u=P[2],se+=u*je,ce+=u*xe,ge+=u*Ue,N+=u*Le,q+=u*qe,le+=u*Ae,te+=u*$e,G+=u*Se,ee+=u*Te,Y+=u*Be,re+=u*Pe,Oe+=u*Ve,ie+=u*Ge,we+=u*et,he+=u*tt,_e+=u*Je,u=P[3],ce+=u*je,ge+=u*xe,N+=u*Ue,q+=u*Le,le+=u*qe,te+=u*Ae,G+=u*$e,ee+=u*Se,Y+=u*Te,re+=u*Be,Oe+=u*Pe,ie+=u*Ve,we+=u*Ge,he+=u*et,_e+=u*tt,M+=u*Je,u=P[4],ge+=u*je,N+=u*xe,q+=u*Ue,le+=u*Le,te+=u*qe,G+=u*Ae,ee+=u*$e,Y+=u*Se,re+=u*Te,Oe+=u*Be,ie+=u*Pe,we+=u*Ve,he+=u*Ge,_e+=u*et,M+=u*tt,F+=u*Je,u=P[5],N+=u*je,q+=u*xe,le+=u*Ue,te+=u*Le,G+=u*qe,ee+=u*Ae,Y+=u*$e,re+=u*Se,Oe+=u*Te,ie+=u*Be,we+=u*Pe,he+=u*Ve,_e+=u*Ge,M+=u*et,F+=u*tt,A+=u*Je,u=P[6],q+=u*je,le+=u*xe,te+=u*Ue,G+=u*Le,ee+=u*qe,Y+=u*Ae,re+=u*$e,Oe+=u*Se,ie+=u*Te,we+=u*Be,he+=u*Pe,_e+=u*Ve,M+=u*Ge,F+=u*et,A+=u*tt,h+=u*Je,u=P[7],le+=u*je,te+=u*xe,G+=u*Ue,ee+=u*Le,Y+=u*qe,re+=u*Ae,Oe+=u*$e,ie+=u*Se,we+=u*Te,he+=u*Be,_e+=u*Pe,M+=u*Ve,F+=u*Ge,A+=u*et,h+=u*tt,I+=u*Je,u=P[8],te+=u*je,G+=u*xe,ee+=u*Ue,Y+=u*Le,re+=u*qe,Oe+=u*Ae,ie+=u*$e,we+=u*Se,he+=u*Te,_e+=u*Be,M+=u*Pe,F+=u*Ve,A+=u*Ge,h+=u*et,I+=u*tt,ne+=u*Je,u=P[9],G+=u*je,ee+=u*xe,Y+=u*Ue,re+=u*Le,Oe+=u*qe,ie+=u*Ae,we+=u*$e,he+=u*Se,_e+=u*Te,M+=u*Be,F+=u*Pe,A+=u*Ve,h+=u*Ge,I+=u*et,ne+=u*tt,fe+=u*Je,u=P[10],ee+=u*je,Y+=u*xe,re+=u*Ue,Oe+=u*Le,ie+=u*qe,we+=u*Ae,he+=u*$e,_e+=u*Se,M+=u*Te,F+=u*Be,A+=u*Pe,h+=u*Ve,I+=u*Ge,ne+=u*et,fe+=u*tt,Ie+=u*Je,u=P[11],Y+=u*je,re+=u*xe,Oe+=u*Ue,ie+=u*Le,we+=u*qe,he+=u*Ae,_e+=u*$e,M+=u*Se,F+=u*Te,A+=u*Be,h+=u*Pe,I+=u*Ve,ne+=u*Ge,fe+=u*et,Ie+=u*tt,He+=u*Je,u=P[12],re+=u*je,Oe+=u*xe,ie+=u*Ue,we+=u*Le,he+=u*qe,_e+=u*Ae,M+=u*$e,F+=u*Se,A+=u*Te,h+=u*Be,I+=u*Pe,ne+=u*Ve,fe+=u*Ge,Ie+=u*et,He+=u*tt,ke+=u*Je,u=P[13],Oe+=u*je,ie+=u*xe,we+=u*Ue,he+=u*Le,_e+=u*qe,M+=u*Ae,F+=u*$e,A+=u*Se,h+=u*Te,I+=u*Be,ne+=u*Pe,fe+=u*Ve,Ie+=u*Ge,He+=u*et,ke+=u*tt,Fe+=u*Je,u=P[14],ie+=u*je,we+=u*xe,he+=u*Ue,_e+=u*Le,M+=u*qe,F+=u*Ae,A+=u*$e,h+=u*Se,I+=u*Te,ne+=u*Be,fe+=u*Pe,Ie+=u*Ve,He+=u*Ge,ke+=u*et,Fe+=u*tt,pt+=u*Je,u=P[15],we+=u*je,he+=u*xe,_e+=u*Ue,M+=u*Le,F+=u*qe,A+=u*Ae,h+=u*$e,I+=u*Se,ne+=u*Te,fe+=u*Be,Ie+=u*Pe,He+=u*Ve,ke+=u*Ge,Fe+=u*et,pt+=u*tt,gt+=u*Je,W+=38*he,V+=38*_e,se+=38*M,ce+=38*F,ge+=38*A,N+=38*h,q+=38*I,le+=38*ne,te+=38*fe,G+=38*Ie,ee+=38*He,Y+=38*ke,re+=38*Fe,Oe+=38*pt,ie+=38*gt,_=1,u=W+_+65535,_=Math.floor(u/65536),W=u-_*65536,u=V+_+65535,_=Math.floor(u/65536),V=u-_*65536,u=se+_+65535,_=Math.floor(u/65536),se=u-_*65536,u=ce+_+65535,_=Math.floor(u/65536),ce=u-_*65536,u=ge+_+65535,_=Math.floor(u/65536),ge=u-_*65536,u=N+_+65535,_=Math.floor(u/65536),N=u-_*65536,u=q+_+65535,_=Math.floor(u/65536),q=u-_*65536,u=le+_+65535,_=Math.floor(u/65536),le=u-_*65536,u=te+_+65535,_=Math.floor(u/65536),te=u-_*65536,u=G+_+65535,_=Math.floor(u/65536),G=u-_*65536,u=ee+_+65535,_=Math.floor(u/65536),ee=u-_*65536,u=Y+_+65535,_=Math.floor(u/65536),Y=u-_*65536,u=re+_+65535,_=Math.floor(u/65536),re=u-_*65536,u=Oe+_+65535,_=Math.floor(u/65536),Oe=u-_*65536,u=ie+_+65535,_=Math.floor(u/65536),ie=u-_*65536,u=we+_+65535,_=Math.floor(u/65536),we=u-_*65536,W+=_-1+37*(_-1),_=1,u=W+_+65535,_=Math.floor(u/65536),W=u-_*65536,u=V+_+65535,_=Math.floor(u/65536),V=u-_*65536,u=se+_+65535,_=Math.floor(u/65536),se=u-_*65536,u=ce+_+65535,_=Math.floor(u/65536),ce=u-_*65536,u=ge+_+65535,_=Math.floor(u/65536),ge=u-_*65536,u=N+_+65535,_=Math.floor(u/65536),N=u-_*65536,u=q+_+65535,_=Math.floor(u/65536),q=u-_*65536,u=le+_+65535,_=Math.floor(u/65536),le=u-_*65536,u=te+_+65535,_=Math.floor(u/65536),te=u-_*65536,u=G+_+65535,_=Math.floor(u/65536),G=u-_*65536,u=ee+_+65535,_=Math.floor(u/65536),ee=u-_*65536,u=Y+_+65535,_=Math.floor(u/65536),Y=u-_*65536,u=re+_+65535,_=Math.floor(u/65536),re=u-_*65536,u=Oe+_+65535,_=Math.floor(u/65536),Oe=u-_*65536,u=ie+_+65535,_=Math.floor(u/65536),ie=u-_*65536,u=we+_+65535,_=Math.floor(u/65536),we=u-_*65536,W+=_-1+37*(_-1),S[0]=W,S[1]=V,S[2]=se,S[3]=ce,S[4]=ge,S[5]=N,S[6]=q,S[7]=le,S[8]=te,S[9]=G,S[10]=ee,S[11]=Y,S[12]=re,S[13]=Oe,S[14]=ie,S[15]=we}function U(S,P){j(S,P,P)}function z(S,P){const m=s();for(let u=0;u<16;u++)m[u]=P[u];for(let u=253;u>=0;u--)U(m,m),u!==2&&u!==4&&j(m,m,P);for(let u=0;u<16;u++)S[u]=m[u]}function B(S,P){const m=new Uint8Array(32),u=new Float64Array(80),_=s(),W=s(),V=s(),se=s(),ce=s(),ge=s();for(let te=0;te<31;te++)m[te]=S[te];m[31]=S[31]&127|64,m[0]&=248,b(u,P);for(let te=0;te<16;te++)W[te]=u[te];_[0]=se[0]=1;for(let te=254;te>=0;--te){const G=m[te>>>3]>>>(te&7)&1;d(_,W,G),d(V,se,G),x(ce,_,V),$(_,_,V),x(V,W,se),$(W,W,se),U(se,ce),U(ge,_),j(_,V,_),j(V,W,ce),x(ce,_,V),$(_,_,V),U(W,_),$(V,se,ge),j(_,V,l),x(_,_,se),j(V,V,_),j(_,se,ge),j(se,W,u),U(W,ce),d(_,W,G),d(V,se,G)}for(let te=0;te<16;te++)u[te+16]=_[te],u[te+32]=V[te],u[te+48]=W[te],u[te+64]=se[te];const N=u.subarray(32),q=u.subarray(16);z(N,N),j(q,q,N);const le=new Uint8Array(32);return v(le,q),le}n.scalarMult=B;function K(S){return B(S,a)}n.scalarMultBase=K;function oe(S){if(S.length!==n.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${n.SECRET_KEY_LENGTH} bytes`);const P=new Uint8Array(S);return{publicKey:K(P),secretKey:P}}n.generateKeyPairFromSeed=oe;function T(S){const P=(0,t.randomBytes)(32,S),m=oe(P);return(0,r.wipe)(P),m}n.generateKeyPair=T;function D(S,P,m=!1){if(S.length!==n.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(P.length!==n.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const u=B(S,P);if(m){let _=0;for(let W=0;W<u.length;W++)_|=u[W];if(_===0)throw new Error("X25519: invalid shared key")}return u}n.sharedKey=D})(au);var Tl=globalThis&&globalThis.__spreadArray||function(n,t,r){if(r||arguments.length===2)for(var s=0,a=t.length,l;s<a;s++)(l||!(s in t))&&(l||(l=Array.prototype.slice.call(t,0,s)),l[s]=t[s]);return n.concat(l||Array.prototype.slice.call(t))},Fm=function(){function n(t,r,s){this.name=t,this.version=r,this.os=s,this.type="browser"}return n}(),Mm=function(){function n(t){this.version=t,this.type="node",this.name="node",this.os=Zi.platform}return n}(),jm=function(){function n(t,r,s,a){this.name=t,this.version=r,this.os=s,this.bot=a,this.type="bot-device"}return n}(),qm=function(){function n(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return n}(),zm=function(){function n(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return n}(),Hm=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Bm=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Nl=3,Km=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Hm]],Cl=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function km(n){return n?Rl(n):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new zm:typeof navigator<"u"?Rl(navigator.userAgent):Gm()}function Vm(n){return n!==""&&Km.reduce(function(t,r){var s=r[0],a=r[1];if(t)return t;var l=a.exec(n);return!!l&&[s,l]},!1)}function Rl(n){var t=Vm(n);if(!t)return null;var r=t[0],s=t[1];if(r==="searchbot")return new qm;var a=s[1]&&s[1].split(".").join("_").split("_").slice(0,3);a?a.length<Nl&&(a=Tl(Tl([],a,!0),Ym(Nl-a.length),!0)):a=[];var l=a.join("."),p=Wm(n),d=Bm.exec(n);return d&&d[1]?new jm(r,l,p,d[1]):new Fm(r,l,p)}function Wm(n){for(var t=0,r=Cl.length;t<r;t++){var s=Cl[t],a=s[0],l=s[1],p=l.exec(n);if(p)return a}return null}function Gm(){var n=typeof Zi<"u"&&Zi.version;return n?new Mm(Zi.version.slice(1)):null}function Ym(n){for(var t=[],r=0;r<n;r++)t.push("0");return t}var ve={},mc={},Zn={},Ul;function Jm(){if(Ul)return Zn;Ul=1,Object.defineProperty(Zn,"__esModule",{value:!0}),Zn.delay=void 0;function n(t){return new Promise(r=>{setTimeout(()=>{r(!0)},t)})}return Zn.delay=n,Zn}var Wi={},wc={},Gi={},Ll;function Xm(){return Ll||(Ll=1,Object.defineProperty(Gi,"__esModule",{value:!0}),Gi.ONE_THOUSAND=Gi.ONE_HUNDRED=void 0,Gi.ONE_HUNDRED=100,Gi.ONE_THOUSAND=1e3),Gi}var bc={},$l;function Qm(){return $l||($l=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.ONE_YEAR=n.FOUR_WEEKS=n.THREE_WEEKS=n.TWO_WEEKS=n.ONE_WEEK=n.THIRTY_DAYS=n.SEVEN_DAYS=n.FIVE_DAYS=n.THREE_DAYS=n.ONE_DAY=n.TWENTY_FOUR_HOURS=n.TWELVE_HOURS=n.SIX_HOURS=n.THREE_HOURS=n.ONE_HOUR=n.SIXTY_MINUTES=n.THIRTY_MINUTES=n.TEN_MINUTES=n.FIVE_MINUTES=n.ONE_MINUTE=n.SIXTY_SECONDS=n.THIRTY_SECONDS=n.TEN_SECONDS=n.FIVE_SECONDS=n.ONE_SECOND=void 0,n.ONE_SECOND=1,n.FIVE_SECONDS=5,n.TEN_SECONDS=10,n.THIRTY_SECONDS=30,n.SIXTY_SECONDS=60,n.ONE_MINUTE=n.SIXTY_SECONDS,n.FIVE_MINUTES=n.ONE_MINUTE*5,n.TEN_MINUTES=n.ONE_MINUTE*10,n.THIRTY_MINUTES=n.ONE_MINUTE*30,n.SIXTY_MINUTES=n.ONE_MINUTE*60,n.ONE_HOUR=n.SIXTY_MINUTES,n.THREE_HOURS=n.ONE_HOUR*3,n.SIX_HOURS=n.ONE_HOUR*6,n.TWELVE_HOURS=n.ONE_HOUR*12,n.TWENTY_FOUR_HOURS=n.ONE_HOUR*24,n.ONE_DAY=n.TWENTY_FOUR_HOURS,n.THREE_DAYS=n.ONE_DAY*3,n.FIVE_DAYS=n.ONE_DAY*5,n.SEVEN_DAYS=n.ONE_DAY*7,n.THIRTY_DAYS=n.ONE_DAY*30,n.ONE_WEEK=n.SEVEN_DAYS,n.TWO_WEEKS=n.ONE_WEEK*2,n.THREE_WEEKS=n.ONE_WEEK*3,n.FOUR_WEEKS=n.ONE_WEEK*4,n.ONE_YEAR=n.ONE_DAY*365}(bc)),bc}var Dl;function pd(){return Dl||(Dl=1,function(n){Object.defineProperty(n,"__esModule",{value:!0});const t=Vr;t.__exportStar(Xm(),n),t.__exportStar(Qm(),n)}(wc)),wc}var Fl;function Zm(){if(Fl)return Wi;Fl=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.fromMiliseconds=Wi.toMiliseconds=void 0;const n=pd();function t(s){return s*n.ONE_THOUSAND}Wi.toMiliseconds=t;function r(s){return Math.floor(s/n.ONE_THOUSAND)}return Wi.fromMiliseconds=r,Wi}var Ml;function ew(){return Ml||(Ml=1,function(n){Object.defineProperty(n,"__esModule",{value:!0});const t=Vr;t.__exportStar(Jm(),n),t.__exportStar(Zm(),n)}(mc)),mc}var xn={},jl;function tw(){if(jl)return xn;jl=1,Object.defineProperty(xn,"__esModule",{value:!0}),xn.Watch=void 0;class n{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const s=this.get(r);if(typeof s.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const a=Date.now()-s.started;this.timestamps.set(r,{started:s.started,elapsed:a})}get(r){const s=this.timestamps.get(r);if(typeof s>"u")throw new Error(`No timestamp found for label: ${r}`);return s}elapsed(r){const s=this.get(r);return s.elapsed||Date.now()-s.started}}return xn.Watch=n,xn.default=n,xn}var Ec={},es={},ql;function rw(){if(ql)return es;ql=1,Object.defineProperty(es,"__esModule",{value:!0}),es.IWatch=void 0;class n{}return es.IWatch=n,es}var zl;function iw(){return zl||(zl=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),Vr.__exportStar(rw(),n)}(Ec)),Ec}(function(n){Object.defineProperty(n,"__esModule",{value:!0});const t=Vr;t.__exportStar(ew(),n),t.__exportStar(tw(),n),t.__exportStar(iw(),n),t.__exportStar(pd(),n)})(ve);var lt={};Object.defineProperty(lt,"__esModule",{value:!0});lt.getLocalStorage=lt.getLocalStorageOrThrow=lt.getCrypto=lt.getCryptoOrThrow=vd=lt.getLocation=lt.getLocationOrThrow=cu=lt.getNavigator=lt.getNavigatorOrThrow=gd=lt.getDocument=lt.getDocumentOrThrow=lt.getFromWindowOrThrow=lt.getFromWindow=void 0;function en(n){let t;return typeof window<"u"&&typeof window[n]<"u"&&(t=window[n]),t}lt.getFromWindow=en;function Cn(n){const t=en(n);if(!t)throw new Error(`${n} is not defined in Window`);return t}lt.getFromWindowOrThrow=Cn;function nw(){return Cn("document")}lt.getDocumentOrThrow=nw;function sw(){return en("document")}var gd=lt.getDocument=sw;function ow(){return Cn("navigator")}lt.getNavigatorOrThrow=ow;function aw(){return en("navigator")}var cu=lt.getNavigator=aw;function cw(){return Cn("location")}lt.getLocationOrThrow=cw;function uw(){return en("location")}var vd=lt.getLocation=uw;function hw(){return Cn("crypto")}lt.getCryptoOrThrow=hw;function lw(){return en("crypto")}lt.getCrypto=lw;function fw(){return Cn("localStorage")}lt.getLocalStorageOrThrow=fw;function dw(){return en("localStorage")}lt.getLocalStorage=dw;var uu={};Object.defineProperty(uu,"__esModule",{value:!0});var yd=uu.getWindowMetadata=void 0;const Hl=lt;function pw(){let n,t;try{n=Hl.getDocumentOrThrow(),t=Hl.getLocationOrThrow()}catch{return null}function r(){const $=n.getElementsByTagName("link"),j=[];for(let U=0;U<$.length;U++){const z=$[U],B=z.getAttribute("rel");if(B&&B.toLowerCase().indexOf("icon")>-1){const K=z.getAttribute("href");if(K)if(K.toLowerCase().indexOf("https:")===-1&&K.toLowerCase().indexOf("http:")===-1&&K.indexOf("//")!==0){let oe=t.protocol+"//"+t.host;if(K.indexOf("/")===0)oe+=K;else{const T=t.pathname.split("/");T.pop();const D=T.join("/");oe+=D+"/"+K}j.push(oe)}else if(K.indexOf("//")===0){const oe=t.protocol+K;j.push(oe)}else j.push(K)}}return j}function s(...$){const j=n.getElementsByTagName("meta");for(let U=0;U<j.length;U++){const z=j[U],B=["itemprop","property","name"].map(K=>z.getAttribute(K)).filter(K=>K?$.includes(K):!1);if(B.length&&B){const K=z.getAttribute("content");if(K)return K}}return""}function a(){let $=s("name","og:site_name","og:title","twitter:title");return $||($=n.title),$}function l(){return s("description","og:description","twitter:description","keywords")}const p=a(),d=l(),v=t.origin,b=r();return{description:d,url:v,icons:b,name:p}}yd=uu.getWindowMetadata=pw;var ds={},gw=function(n,t){for(var r={},s=Object.keys(n),a=Array.isArray(t),l=0;l<s.length;l++){var p=s[l],d=n[p];(a?t.indexOf(p)!==-1:t(p,d,n))&&(r[p]=d)}return r};(function(n){const t=z_,r=H_,s=q_,a=gw,l=T=>T==null,p=Symbol("encodeFragmentIdentifier");function d(T){switch(T.arrayFormat){case"index":return D=>(S,P)=>{const m=S.length;return P===void 0||T.skipNull&&P===null||T.skipEmptyString&&P===""?S:P===null?[...S,[x(D,T),"[",m,"]"].join("")]:[...S,[x(D,T),"[",x(m,T),"]=",x(P,T)].join("")]};case"bracket":return D=>(S,P)=>P===void 0||T.skipNull&&P===null||T.skipEmptyString&&P===""?S:P===null?[...S,[x(D,T),"[]"].join("")]:[...S,[x(D,T),"[]=",x(P,T)].join("")];case"colon-list-separator":return D=>(S,P)=>P===void 0||T.skipNull&&P===null||T.skipEmptyString&&P===""?S:P===null?[...S,[x(D,T),":list="].join("")]:[...S,[x(D,T),":list=",x(P,T)].join("")];case"comma":case"separator":case"bracket-separator":{const D=T.arrayFormat==="bracket-separator"?"[]=":"=";return S=>(P,m)=>m===void 0||T.skipNull&&m===null||T.skipEmptyString&&m===""?P:(m=m===null?"":m,P.length===0?[[x(S,T),D,x(m,T)].join("")]:[[P,x(m,T)].join(T.arrayFormatSeparator)])}default:return D=>(S,P)=>P===void 0||T.skipNull&&P===null||T.skipEmptyString&&P===""?S:P===null?[...S,x(D,T)]:[...S,[x(D,T),"=",x(P,T)].join("")]}}function v(T){let D;switch(T.arrayFormat){case"index":return(S,P,m)=>{if(D=/\[(\d*)\]$/.exec(S),S=S.replace(/\[\d*\]$/,""),!D){m[S]=P;return}m[S]===void 0&&(m[S]={}),m[S][D[1]]=P};case"bracket":return(S,P,m)=>{if(D=/(\[\])$/.exec(S),S=S.replace(/\[\]$/,""),!D){m[S]=P;return}if(m[S]===void 0){m[S]=[P];return}m[S]=[].concat(m[S],P)};case"colon-list-separator":return(S,P,m)=>{if(D=/(:list)$/.exec(S),S=S.replace(/:list$/,""),!D){m[S]=P;return}if(m[S]===void 0){m[S]=[P];return}m[S]=[].concat(m[S],P)};case"comma":case"separator":return(S,P,m)=>{const u=typeof P=="string"&&P.includes(T.arrayFormatSeparator),_=typeof P=="string"&&!u&&$(P,T).includes(T.arrayFormatSeparator);P=_?$(P,T):P;const W=u||_?P.split(T.arrayFormatSeparator).map(V=>$(V,T)):P===null?P:$(P,T);m[S]=W};case"bracket-separator":return(S,P,m)=>{const u=/(\[\])$/.test(S);if(S=S.replace(/\[\]$/,""),!u){m[S]=P&&$(P,T);return}const _=P===null?[]:P.split(T.arrayFormatSeparator).map(W=>$(W,T));if(m[S]===void 0){m[S]=_;return}m[S]=[].concat(m[S],_)};default:return(S,P,m)=>{if(m[S]===void 0){m[S]=P;return}m[S]=[].concat(m[S],P)}}}function b(T){if(typeof T!="string"||T.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function x(T,D){return D.encode?D.strict?t(T):encodeURIComponent(T):T}function $(T,D){return D.decode?r(T):T}function j(T){return Array.isArray(T)?T.sort():typeof T=="object"?j(Object.keys(T)).sort((D,S)=>Number(D)-Number(S)).map(D=>T[D]):T}function U(T){const D=T.indexOf("#");return D!==-1&&(T=T.slice(0,D)),T}function z(T){let D="";const S=T.indexOf("#");return S!==-1&&(D=T.slice(S)),D}function B(T){T=U(T);const D=T.indexOf("?");return D===-1?"":T.slice(D+1)}function K(T,D){return D.parseNumbers&&!Number.isNaN(Number(T))&&typeof T=="string"&&T.trim()!==""?T=Number(T):D.parseBooleans&&T!==null&&(T.toLowerCase()==="true"||T.toLowerCase()==="false")&&(T=T.toLowerCase()==="true"),T}function oe(T,D){D=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},D),b(D.arrayFormatSeparator);const S=v(D),P=Object.create(null);if(typeof T!="string"||(T=T.trim().replace(/^[?#&]/,""),!T))return P;for(const m of T.split("&")){if(m==="")continue;let[u,_]=s(D.decode?m.replace(/\+/g," "):m,"=");_=_===void 0?null:["comma","separator","bracket-separator"].includes(D.arrayFormat)?_:$(_,D),S($(u,D),_,P)}for(const m of Object.keys(P)){const u=P[m];if(typeof u=="object"&&u!==null)for(const _ of Object.keys(u))u[_]=K(u[_],D);else P[m]=K(u,D)}return D.sort===!1?P:(D.sort===!0?Object.keys(P).sort():Object.keys(P).sort(D.sort)).reduce((m,u)=>{const _=P[u];return _&&typeof _=="object"&&!Array.isArray(_)?m[u]=j(_):m[u]=_,m},Object.create(null))}n.extract=B,n.parse=oe,n.stringify=(T,D)=>{if(!T)return"";D=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},D),b(D.arrayFormatSeparator);const S=_=>D.skipNull&&l(T[_])||D.skipEmptyString&&T[_]==="",P=d(D),m={};for(const _ of Object.keys(T))S(_)||(m[_]=T[_]);const u=Object.keys(m);return D.sort!==!1&&u.sort(D.sort),u.map(_=>{const W=T[_];return W===void 0?"":W===null?x(_,D):Array.isArray(W)?W.length===0&&D.arrayFormat==="bracket-separator"?x(_,D)+"[]":W.reduce(P(_),[]).join("&"):x(_,D)+"="+x(W,D)}).filter(_=>_.length>0).join("&")},n.parseUrl=(T,D)=>{D=Object.assign({decode:!0},D);const[S,P]=s(T,"#");return Object.assign({url:S.split("?")[0]||"",query:oe(B(T),D)},D&&D.parseFragmentIdentifier&&P?{fragmentIdentifier:$(P,D)}:{})},n.stringifyUrl=(T,D)=>{D=Object.assign({encode:!0,strict:!0,[p]:!0},D);const S=U(T.url).split("?")[0]||"",P=n.extract(T.url),m=n.parse(P,{sort:!1}),u=Object.assign(m,T.query);let _=n.stringify(u,D);_&&(_=`?${_}`);let W=z(T.url);return T.fragmentIdentifier&&(W=`#${D[p]?x(T.fragmentIdentifier,D):T.fragmentIdentifier}`),`${S}${_}${W}`},n.pick=(T,D,S)=>{S=Object.assign({parseFragmentIdentifier:!0,[p]:!1},S);const{url:P,query:m,fragmentIdentifier:u}=n.parseUrl(T,S);return n.stringifyUrl({url:P,query:a(m,D),fragmentIdentifier:u},S)},n.exclude=(T,D,S)=>{const P=Array.isArray(D)?m=>!D.includes(m):(m,u)=>!D(m,u);return n.pick(T,P,S)}})(ds);const vw={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe"}};function yw(n,t=[]){const r=[];return Object.keys(n).forEach(s=>{if(t.length&&!t.includes(s))return;const a=n[s];r.push(...a.accounts)}),r}function _d(n,t){return n.includes(":")?[n]:t.chains||[]}const md="base10",ar="base16",kc="base64pad",hu="utf8",wd=0,tn=1,_w=0,Bl=1,Vc=12,lu=32;function mw(){const n=au.generateKeyPair();return{privateKey:cr(n.secretKey,ar),publicKey:cr(n.publicKey,ar)}}function Wc(){const n=Nn.randomBytes(lu);return cr(n,ar)}function ww(n,t){const r=au.sharedKey(vr(n,ar),vr(t,ar)),s=new Nm(ko.SHA256,r).expand(lu);return cr(s,ar)}function bw(n){const t=ko.hash(vr(n,ar));return cr(t,ar)}function An(n){const t=ko.hash(vr(n,hu));return cr(t,ar)}function Ew(n){return vr(`${n}`,md)}function vs(n){return Number(cr(n,md))}function Sw(n){const t=Ew(typeof n.type<"u"?n.type:wd);if(vs(t)===tn&&typeof n.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof n.senderPublicKey<"u"?vr(n.senderPublicKey,ar):void 0,s=typeof n.iv<"u"?vr(n.iv,ar):Nn.randomBytes(Vc),a=new su.ChaCha20Poly1305(vr(n.symKey,ar)).seal(s,vr(n.message,hu));return xw({type:t,sealed:a,iv:s,senderPublicKey:r})}function Iw(n){const t=new su.ChaCha20Poly1305(vr(n.symKey,ar)),{sealed:r,iv:s}=Ro(n.encoded),a=t.open(s,r);if(a===null)throw new Error("Failed to decrypt");return cr(a,hu)}function xw(n){if(vs(n.type)===tn){if(typeof n.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return cr(jc([n.type,n.senderPublicKey,n.iv,n.sealed]),kc)}return cr(jc([n.type,n.iv,n.sealed]),kc)}function Ro(n){const t=vr(n,kc),r=t.slice(_w,Bl),s=Bl;if(vs(r)===tn){const d=s+lu,v=d+Vc,b=t.slice(s,d),x=t.slice(d,v),$=t.slice(v);return{type:r,sealed:$,iv:x,senderPublicKey:b}}const a=s+Vc,l=t.slice(s,a),p=t.slice(a);return{type:r,sealed:p,iv:l}}function Ow(n,t){const r=Ro(n);return bd({type:vs(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?cr(r.senderPublicKey,ar):void 0,receiverPublicKey:t==null?void 0:t.receiverPublicKey})}function bd(n){const t=(n==null?void 0:n.type)||wd;if(t===tn){if(typeof(n==null?void 0:n.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(n==null?void 0:n.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:n==null?void 0:n.senderPublicKey,receiverPublicKey:n==null?void 0:n.receiverPublicKey}}function Kl(n){return n.type===tn&&typeof n.senderPublicKey=="string"&&typeof n.receiverPublicKey=="string"}var Pw=Object.defineProperty,kl=Object.getOwnPropertySymbols,Aw=Object.prototype.hasOwnProperty,Tw=Object.prototype.propertyIsEnumerable,Vl=(n,t,r)=>t in n?Pw(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Wl=(n,t)=>{for(var r in t||(t={}))Aw.call(t,r)&&Vl(n,r,t[r]);if(kl)for(var r of kl(t))Tw.call(t,r)&&Vl(n,r,t[r]);return n};const Nw="ReactNative",Ai={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Cw="js";function fu(){return typeof Zi<"u"&&typeof Zi.versions<"u"&&typeof Zi.versions.node<"u"}function Ed(){return!gd()&&!!cu()&&navigator.product===Nw}function du(){return!fu()&&!!cu()}function pu(){return Ed()?Ai.reactNative:fu()?Ai.node:du()?Ai.browser:Ai.unknown}function Rw(n,t){let r=ds.parse(n);return r=Wl(Wl({},r),t),n=ds.stringify(r),n}function Uw(){return yd()||{name:"",description:"",url:"",icons:[""]}}function Lw(){if(pu()===Ai.reactNative&&typeof yr<"u"&&typeof(yr==null?void 0:yr.Platform)<"u"){const{OS:r,Version:s}=yr.Platform;return[r,s].join("-")}const n=km();if(n===null)return"unknown";const t=n.os?n.os.replace(" ","").toLowerCase():"unknown";return n.type==="browser"?[t,n.name,n.version].join("-"):[t,n.version].join("-")}function $w(){var n;const t=pu();return t===Ai.browser?[t,((n=vd())==null?void 0:n.host)||"unknown"].join(":"):t}function Dw(n,t,r){const s=Lw(),a=$w();return[[n,t].join("-"),[Cw,r].join("-"),s,a].join("/")}function Fw({protocol:n,version:t,relayUrl:r,sdkVersion:s,auth:a,projectId:l,useOnCloseEvent:p}){const d=r.split("?"),v=Dw(n,t,s),b={auth:a,ua:v,projectId:l,useOnCloseEvent:p||void 0},x=Rw(d[1]||"",b);return d[0]+"?"+x}function Qi(n,t){return n.filter(r=>t.includes(r)).length===n.length}function Sd(n){return Object.fromEntries(n.entries())}function Id(n){return new Map(Object.entries(n))}function On(n=ve.FIVE_MINUTES,t){const r=ve.toMiliseconds(n||ve.FIVE_MINUTES);let s,a,l;return{resolve:p=>{l&&s&&(clearTimeout(l),s(p))},reject:p=>{l&&a&&(clearTimeout(l),a(p))},done:()=>new Promise((p,d)=>{l=setTimeout(()=>{d(new Error(t))},r),s=p,a=d})}}function Uo(n,t,r){return new Promise(async(s,a)=>{const l=setTimeout(()=>a(new Error(r)),t);try{const p=await n;s(p)}catch(p){a(p)}clearTimeout(l)})}function xd(n,t){if(typeof t=="string"&&t.startsWith(`${n}:`))return t;if(n.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(n.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${n}`)}function Mw(n){return xd("topic",n)}function jw(n){return xd("id",n)}function Od(n){const[t,r]=n.split(":"),s={id:void 0,topic:void 0};if(t==="topic"&&typeof r=="string")s.topic=r;else if(t==="id"&&Number.isInteger(Number(r)))s.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);return s}function kr(n,t){return ve.fromMiliseconds((t||Date.now())+ve.toMiliseconds(n))}function Pi(n){return Date.now()>=ve.toMiliseconds(n)}function Ht(n,t){return`${n}${t?`:${t}`:""}`}function Sc(n=[],t=[]){return[...new Set([...n,...t])]}async function qw({id:n,topic:t,wcDeepLink:r}){try{if(!r)return;const s=typeof r=="string"?JSON.parse(r):r;let a=s==null?void 0:s.href;if(typeof a!="string")return;a.endsWith("/")&&(a=a.slice(0,-1));const l=`${a}/wc?requestId=${n}&sessionTopic=${t}`,p=pu();p===Ai.browser?l.startsWith("https://")?window.open(l,"_blank","noreferrer noopener"):window.open(l,"_self","noreferrer noopener"):p===Ai.reactNative&&typeof(yr==null?void 0:yr.Linking)<"u"&&await yr.Linking.openURL(l)}catch(s){console.error(s)}}const zw="irn";function Gc(n){return(n==null?void 0:n.relay)||{protocol:zw}}function Po(n){const t=vw[n];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${n}`);return t}var Hw=Object.defineProperty,Gl=Object.getOwnPropertySymbols,Bw=Object.prototype.hasOwnProperty,Kw=Object.prototype.propertyIsEnumerable,Yl=(n,t,r)=>t in n?Hw(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,kw=(n,t)=>{for(var r in t||(t={}))Bw.call(t,r)&&Yl(n,r,t[r]);if(Gl)for(var r of Gl(t))Kw.call(t,r)&&Yl(n,r,t[r]);return n};function Vw(n,t="-"){const r={},s="relay"+t;return Object.keys(n).forEach(a=>{if(a.startsWith(s)){const l=a.replace(s,""),p=n[a];r[l]=p}}),r}function Ww(n){const t=n.indexOf(":"),r=n.indexOf("?")!==-1?n.indexOf("?"):void 0,s=n.substring(0,t),a=n.substring(t+1,r).split("@"),l=typeof r<"u"?n.substring(r):"",p=ds.parse(l);return{protocol:s,topic:Gw(a[0]),version:parseInt(a[1],10),symKey:p.symKey,relay:Vw(p)}}function Gw(n){return n.startsWith("//")?n.substring(2):n}function Yw(n,t="-"){const r="relay",s={};return Object.keys(n).forEach(a=>{const l=r+t+a;n[a]&&(s[l]=n[a])}),s}function Jw(n){return`${n.protocol}:${n.topic}@${n.version}?`+ds.stringify(kw({symKey:n.symKey},Yw(n.relay)))}function Rn(n){const t=[];return n.forEach(r=>{const[s,a]=r.split(":");t.push(`${s}:${a}`)}),t}function Xw(n){const t=[];return Object.values(n).forEach(r=>{t.push(...Rn(r.accounts))}),t}function Qw(n,t){const r=[];return Object.values(n).forEach(s=>{Rn(s.accounts).includes(t)&&r.push(...s.methods)}),r}function Zw(n,t){const r=[];return Object.values(n).forEach(s=>{Rn(s.accounts).includes(t)&&r.push(...s.events)}),r}function eb(n,t){const r=To(n,t);if(r)throw new Error(r.message);const s={};for(const[a,l]of Object.entries(n))s[a]={methods:l.methods,events:l.events,chains:l.accounts.map(p=>`${p.split(":")[0]}:${p.split(":")[1]}`)};return s}function gu(n){return n.includes(":")}function Ao(n){return gu(n)?n.split(":")[0]:n}const tb={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},rb={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function ue(n,t){const{message:r,code:s}=rb[n];return{message:t?`${r} ${t}`:r,code:s}}function Ut(n,t){const{message:r,code:s}=tb[n];return{message:t?`${r} ${t}`:r,code:s}}function ri(n,t){return Array.isArray(n)?typeof t<"u"&&n.length?n.every(t):!0:!1}function Tn(n){return Object.getPrototypeOf(n)===Object.prototype&&Object.keys(n).length}function or(n){return typeof n>"u"}function Wt(n,t){return t&&or(n)?!0:typeof n=="string"&&!!n.trim().length}function vu(n,t){return t&&or(n)?!0:typeof n=="number"&&!isNaN(n)}function ib(n,t){const{requiredNamespaces:r}=t,s=Object.keys(n.namespaces),a=Object.keys(r);let l=!0;return Qi(a,s)?(s.forEach(p=>{const{accounts:d,methods:v,events:b}=n.namespaces[p],x=Rn(d),$=r[p];(!Qi(_d(p,$),x)||!Qi($.methods,v)||!Qi($.events,b))&&(l=!1)}),l):!1}function Lo(n){return Wt(n,!1)&&n.includes(":")?n.split(":").length===2:!1}function nb(n){if(Wt(n,!1)&&n.includes(":")){const t=n.split(":");if(t.length===3){const r=t[0]+":"+t[1];return!!t[2]&&Lo(r)}}return!1}function sb(n){if(Wt(n,!1))try{return typeof new URL(n)<"u"}catch{return!1}return!1}function ob(n){var t;return(t=n==null?void 0:n.proposer)==null?void 0:t.publicKey}function ab(n){return n==null?void 0:n.topic}function cb(n,t){let r=null;return Wt(n==null?void 0:n.publicKey,!1)||(r=ue("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}function Jl(n){let t=!0;return ri(n)?n.length&&(t=n.every(r=>Wt(r,!1))):t=!1,t}function ub(n,t,r){let s=null;return ri(t)&&t.length?t.forEach(a=>{s||Lo(a)||(s=Ut("UNSUPPORTED_CHAINS",`${r}, chain ${a} should be a string and conform to "namespace:chainId" format`))}):Lo(n)||(s=Ut("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),s}function hb(n,t,r){let s=null;return Object.entries(n).forEach(([a,l])=>{if(s)return;const p=ub(a,_d(a,l),`${t} ${r}`);p&&(s=p)}),s}function lb(n,t){let r=null;return ri(n)?n.forEach(s=>{r||nb(s)||(r=Ut("UNSUPPORTED_ACCOUNTS",`${t}, account ${s} should be a string and conform to "namespace:chainId:address" format`))}):r=Ut("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function fb(n,t){let r=null;return Object.values(n).forEach(s=>{if(r)return;const a=lb(s==null?void 0:s.accounts,`${t} namespace`);a&&(r=a)}),r}function db(n,t){let r=null;return Jl(n==null?void 0:n.methods)?Jl(n==null?void 0:n.events)||(r=Ut("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=Ut("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}function Pd(n,t){let r=null;return Object.values(n).forEach(s=>{if(r)return;const a=db(s,`${t}, namespace`);a&&(r=a)}),r}function pb(n,t,r){let s=null;if(n&&Tn(n)){const a=Pd(n,t);a&&(s=a);const l=hb(n,t,r);l&&(s=l)}else s=ue("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return s}function To(n,t){let r=null;if(n&&Tn(n)){const s=Pd(n,t);s&&(r=s);const a=fb(n,t);a&&(r=a)}else r=ue("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function Ad(n){return Wt(n.protocol,!0)}function gb(n,t){let r=!1;return t&&!n?r=!0:n&&ri(n)&&n.length&&n.forEach(s=>{r=Ad(s)}),r}function vb(n){return typeof n=="number"}function gr(n){return typeof n<"u"&&typeof n!==null}function yb(n){return!(!n||typeof n!="object"||!n.code||!vu(n.code,!1)||!n.message||!Wt(n.message,!1))}function _b(n){return!(or(n)||!Wt(n.method,!1))}function mb(n){return!(or(n)||or(n.result)&&or(n.error)||!vu(n.id,!1)||!Wt(n.jsonrpc,!1))}function wb(n){return!(or(n)||!Wt(n.name,!1))}function Xl(n,t){return!(!Lo(t)||!Xw(n).includes(t))}function bb(n,t,r){return Wt(r,!1)?Qw(n,t).includes(r):!1}function Eb(n,t,r){return Wt(r,!1)?Zw(n,t).includes(r):!1}function Ql(n,t,r){let s=null;const a=Sb(n),l=Ib(t),p=Object.keys(a),d=Object.keys(l),v=Zl(Object.keys(n)),b=Zl(Object.keys(t)),x=v.filter($=>!b.includes($));return x.length&&(s=ue("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
2
+ Required: ${x.toString()}
3
+ Received: ${Object.keys(t).toString()}`)),Qi(p,d)||(s=ue("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
4
+ Required: ${p.toString()}
5
+ Approved: ${d.toString()}`)),Object.keys(t).forEach($=>{if(!$.includes(":")||s)return;const j=Rn(t[$].accounts);j.includes($)||(s=ue("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${$}
6
+ Required: ${$}
7
+ Approved: ${j.toString()}`))}),p.forEach($=>{s||(Qi(a[$].methods,l[$].methods)?Qi(a[$].events,l[$].events)||(s=ue("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${$}`)):s=ue("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${$}`))}),s}function Sb(n){const t={};return Object.keys(n).forEach(r=>{var s;r.includes(":")?t[r]=n[r]:(s=n[r].chains)==null||s.forEach(a=>{t[a]={methods:n[r].methods,events:n[r].events}})}),t}function Zl(n){return[...new Set(n.map(t=>t.includes(":")?t.split(":")[0]:t))]}function Ib(n){const t={};return Object.keys(n).forEach(r=>{if(r.includes(":"))t[r]=n[r];else{const s=Rn(n[r].accounts);s==null||s.forEach(a=>{t[a]={accounts:n[r].accounts.filter(l=>l.includes(`${a}:`)),methods:n[r].methods,events:n[r].events}})}}),t}function xb(n,t){return vu(n,!1)&&n<=t.max&&n>=t.min}var Vo={},ys={};Object.defineProperty(ys,"__esModule",{value:!0});function Ob(n){if(typeof n!="string")throw new Error(`Cannot safe json parse value of type ${typeof n}`);try{return JSON.parse(n)}catch{return n}}ys.safeJsonParse=Ob;function Pb(n){return typeof n=="string"?n:JSON.stringify(n,(t,r)=>typeof r>"u"?null:r)}ys.safeJsonStringify=Pb;var ts={exports:{}},ef;function Ab(){return ef||(ef=1,function(){let n;function t(){}n=t,n.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},n.prototype.setItem=function(r,s){this[r]=String(s)},n.prototype.removeItem=function(r){delete this[r]},n.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(s){r[s]=void 0,delete r[s]})},n.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},n.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Xi<"u"&&Xi.localStorage?ts.exports=Xi.localStorage:typeof window<"u"&&window.localStorage?ts.exports=window.localStorage:ts.exports=new t}()),ts.exports}var Ic={},rs={},tf;function Tb(){if(tf)return rs;tf=1,Object.defineProperty(rs,"__esModule",{value:!0}),rs.IKeyValueStorage=void 0;class n{}return rs.IKeyValueStorage=n,rs}var is={},rf;function Nb(){if(rf)return is;rf=1,Object.defineProperty(is,"__esModule",{value:!0}),is.parseEntry=void 0;const n=ys;function t(r){var s;return[r[0],n.safeJsonParse((s=r[1])!==null&&s!==void 0?s:"")]}return is.parseEntry=t,is}var nf;function Cb(){return nf||(nf=1,function(n){Object.defineProperty(n,"__esModule",{value:!0});const t=Vr;t.__exportStar(Tb(),n),t.__exportStar(Nb(),n)}(Ic)),Ic}Object.defineProperty(Vo,"__esModule",{value:!0});Vo.KeyValueStorage=void 0;const Pn=Vr,sf=ys,Rb=Pn.__importDefault(Ab()),Ub=Cb();class Td{constructor(){this.localStorage=Rb.default}getKeys(){return Pn.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return Pn.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(Ub.parseEntry)})}getItem(t){return Pn.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(t);if(r!==null)return sf.safeJsonParse(r)})}setItem(t,r){return Pn.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(t,sf.safeJsonStringify(r))})}removeItem(t){return Pn.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(t)})}}Vo.KeyValueStorage=Td;var Lb=Vo.default=Td,Un={},ns={},xc={},ss={};class rn{}const $b=Object.freeze(Object.defineProperty({__proto__:null,IEvents:rn},Symbol.toStringTag,{value:"Module"})),Db=F_($b);var of;function Fb(){if(of)return ss;of=1,Object.defineProperty(ss,"__esModule",{value:!0}),ss.IHeartBeat=void 0;const n=Db;class t extends n.IEvents{constructor(s){super()}}return ss.IHeartBeat=t,ss}var af;function Nd(){return af||(af=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),Vr.__exportStar(Fb(),n)}(xc)),xc}var Oc={},Yi={},cf;function Mb(){if(cf)return Yi;cf=1,Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.HEARTBEAT_EVENTS=Yi.HEARTBEAT_INTERVAL=void 0;const n=ve;return Yi.HEARTBEAT_INTERVAL=n.FIVE_SECONDS,Yi.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},Yi}var uf;function Cd(){return uf||(uf=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),Vr.__exportStar(Mb(),n)}(Oc)),Oc}var hf;function jb(){if(hf)return ns;hf=1,Object.defineProperty(ns,"__esModule",{value:!0}),ns.HeartBeat=void 0;const n=Vr,t=Fr,r=ve,s=Nd(),a=Cd();class l extends s.IHeartBeat{constructor(d){super(d),this.events=new t.EventEmitter,this.interval=a.HEARTBEAT_INTERVAL,this.interval=(d==null?void 0:d.interval)||a.HEARTBEAT_INTERVAL}static init(d){return n.__awaiter(this,void 0,void 0,function*(){const v=new l(d);return yield v.init(),v})}init(){return n.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(d,v){this.events.on(d,v)}once(d,v){this.events.once(d,v)}off(d,v){this.events.off(d,v)}removeListener(d,v){this.events.removeListener(d,v)}initialize(){return n.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(a.HEARTBEAT_EVENTS.pulse)}}return ns.HeartBeat=l,ns}(function(n){Object.defineProperty(n,"__esModule",{value:!0});const t=Vr;t.__exportStar(jb(),n),t.__exportStar(Nd(),n),t.__exportStar(Cd(),n)})(Un);var Ze={},Pc,lf;function qb(){if(lf)return Pc;lf=1;function n(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}Pc=t;function t(r,s,a){var l=a&&a.stringify||n,p=1;if(typeof r=="object"&&r!==null){var d=s.length+p;if(d===1)return r;var v=new Array(d);v[0]=l(r);for(var b=1;b<d;b++)v[b]=l(s[b]);return v.join(" ")}if(typeof r!="string")return r;var x=s.length;if(x===0)return r;for(var $="",j=1-p,U=-1,z=r&&r.length||0,B=0;B<z;){if(r.charCodeAt(B)===37&&B+1<z){switch(U=U>-1?U:0,r.charCodeAt(B+1)){case 100:case 102:if(j>=x||s[j]==null)break;U<B&&($+=r.slice(U,B)),$+=Number(s[j]),U=B+2,B++;break;case 105:if(j>=x||s[j]==null)break;U<B&&($+=r.slice(U,B)),$+=Math.floor(Number(s[j])),U=B+2,B++;break;case 79:case 111:case 106:if(j>=x||s[j]===void 0)break;U<B&&($+=r.slice(U,B));var K=typeof s[j];if(K==="string"){$+="'"+s[j]+"'",U=B+2,B++;break}if(K==="function"){$+=s[j].name||"<anonymous>",U=B+2,B++;break}$+=l(s[j]),U=B+2,B++;break;case 115:if(j>=x)break;U<B&&($+=r.slice(U,B)),$+=String(s[j]),U=B+2,B++;break;case 37:U<B&&($+=r.slice(U,B)),$+="%",U=B+2,B++,j--;break}++j}++B}return U===-1?r:(U<z&&($+=r.slice(U)),$)}return Pc}var Ac,ff;function zb(){if(ff)return Ac;ff=1;const n=qb();Ac=a;const t=P().console||{},r={mapHttpRequest:z,mapHttpResponse:z,wrapRequestSerializer:B,wrapResponseSerializer:B,wrapErrorSerializer:B,req:z,res:z,err:j};function s(m,u){return Array.isArray(m)?m.filter(function(W){return W!=="!stdSerializers.err"}):m===!0?Object.keys(u):!1}function a(m){m=m||{},m.browser=m.browser||{};const u=m.browser.transmit;if(u&&typeof u.send!="function")throw Error("pino: transmit option must have a send function");const _=m.browser.write||t;m.browser.write&&(m.browser.asObject=!0);const W=m.serializers||{},V=s(m.browser.serialize,W);let se=m.browser.serialize;Array.isArray(m.browser.serialize)&&m.browser.serialize.indexOf("!stdSerializers.err")>-1&&(se=!1);const ce=["error","fatal","warn","info","debug","trace"];typeof _=="function"&&(_.error=_.fatal=_.warn=_.info=_.debug=_.trace=_),m.enabled===!1&&(m.level="silent");const ge=m.level||"info",N=Object.create(_);N.log||(N.log=K),Object.defineProperty(N,"levelVal",{get:le}),Object.defineProperty(N,"level",{get:te,set:G});const q={transmit:u,serialize:V,asObject:m.browser.asObject,levels:ce,timestamp:U(m)};N.levels=a.levels,N.level=ge,N.setMaxListeners=N.getMaxListeners=N.emit=N.addListener=N.on=N.prependListener=N.once=N.prependOnceListener=N.removeListener=N.removeAllListeners=N.listeners=N.listenerCount=N.eventNames=N.write=N.flush=K,N.serializers=W,N._serialize=V,N._stdErrSerialize=se,N.child=ee,u&&(N._logEvent=$());function le(){return this.level==="silent"?1/0:this.levels.values[this.level]}function te(){return this._level}function G(Y){if(Y!=="silent"&&!this.levels.values[Y])throw Error("unknown level "+Y);this._level=Y,l(q,N,"error","log"),l(q,N,"fatal","error"),l(q,N,"warn","error"),l(q,N,"info","log"),l(q,N,"debug","log"),l(q,N,"trace","log")}function ee(Y,re){if(!Y)throw new Error("missing bindings for child Pino");re=re||{},V&&Y.serializers&&(re.serializers=Y.serializers);const Oe=re.serializers;if(V&&Oe){var ie=Object.assign({},W,Oe),we=m.browser.serialize===!0?Object.keys(ie):V;delete Y.serializers,v([Y],we,ie,this._stdErrSerialize)}function he(_e){this._childLevel=(_e._childLevel|0)+1,this.error=b(_e,Y,"error"),this.fatal=b(_e,Y,"fatal"),this.warn=b(_e,Y,"warn"),this.info=b(_e,Y,"info"),this.debug=b(_e,Y,"debug"),this.trace=b(_e,Y,"trace"),ie&&(this.serializers=ie,this._serialize=we),u&&(this._logEvent=$([].concat(_e._logEvent.bindings,Y)))}return he.prototype=this,new he(this)}return N}a.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},a.stdSerializers=r,a.stdTimeFunctions=Object.assign({},{nullTime:oe,epochTime:T,unixTime:D,isoTime:S});function l(m,u,_,W){const V=Object.getPrototypeOf(u);u[_]=u.levelVal>u.levels.values[_]?K:V[_]?V[_]:t[_]||t[W]||K,p(m,u,_)}function p(m,u,_){!m.transmit&&u[_]===K||(u[_]=function(W){return function(){const se=m.timestamp(),ce=new Array(arguments.length),ge=Object.getPrototypeOf&&Object.getPrototypeOf(this)===t?t:this;for(var N=0;N<ce.length;N++)ce[N]=arguments[N];if(m.serialize&&!m.asObject&&v(ce,this._serialize,this.serializers,this._stdErrSerialize),m.asObject?W.call(ge,d(this,_,ce,se)):W.apply(ge,ce),m.transmit){const q=m.transmit.level||u.level,le=a.levels.values[q],te=a.levels.values[_];if(te<le)return;x(this,{ts:se,methodLevel:_,methodValue:te,transmitLevel:q,transmitValue:a.levels.values[m.transmit.level||u.level],send:m.transmit.send,val:u.levelVal},ce)}}}(u[_]))}function d(m,u,_,W){m._serialize&&v(_,m._serialize,m.serializers,m._stdErrSerialize);const V=_.slice();let se=V[0];const ce={};W&&(ce.time=W),ce.level=a.levels.values[u];let ge=(m._childLevel|0)+1;if(ge<1&&(ge=1),se!==null&&typeof se=="object"){for(;ge--&&typeof V[0]=="object";)Object.assign(ce,V.shift());se=V.length?n(V.shift(),V):void 0}else typeof se=="string"&&(se=n(V.shift(),V));return se!==void 0&&(ce.msg=se),ce}function v(m,u,_,W){for(const V in m)if(W&&m[V]instanceof Error)m[V]=a.stdSerializers.err(m[V]);else if(typeof m[V]=="object"&&!Array.isArray(m[V]))for(const se in m[V])u&&u.indexOf(se)>-1&&se in _&&(m[V][se]=_[se](m[V][se]))}function b(m,u,_){return function(){const W=new Array(1+arguments.length);W[0]=u;for(var V=1;V<W.length;V++)W[V]=arguments[V-1];return m[_].apply(this,W)}}function x(m,u,_){const W=u.send,V=u.ts,se=u.methodLevel,ce=u.methodValue,ge=u.val,N=m._logEvent.bindings;v(_,m._serialize||Object.keys(m.serializers),m.serializers,m._stdErrSerialize===void 0?!0:m._stdErrSerialize),m._logEvent.ts=V,m._logEvent.messages=_.filter(function(q){return N.indexOf(q)===-1}),m._logEvent.level.label=se,m._logEvent.level.value=ce,W(se,m._logEvent,ge),m._logEvent=$(N)}function $(m){return{ts:0,messages:[],bindings:m||[],level:{label:"",value:0}}}function j(m){const u={type:m.constructor.name,msg:m.message,stack:m.stack};for(const _ in m)u[_]===void 0&&(u[_]=m[_]);return u}function U(m){return typeof m.timestamp=="function"?m.timestamp:m.timestamp===!1?oe:T}function z(){return{}}function B(m){return m}function K(){}function oe(){return!1}function T(){return Date.now()}function D(){return Math.round(Date.now()/1e3)}function S(){return new Date(Date.now()).toISOString()}function P(){function m(u){return typeof u<"u"&&u}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return m(self)||m(window)||m(this)||{}}}return Ac}var Ji={},df;function Rd(){return df||(df=1,Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.PINO_CUSTOM_CONTEXT_KEY=Ji.PINO_LOGGER_DEFAULTS=void 0,Ji.PINO_LOGGER_DEFAULTS={level:"info"},Ji.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Ji}var sr={},pf;function Hb(){if(pf)return sr;pf=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.generateChildLogger=sr.formatChildLoggerContext=sr.getLoggerContext=sr.setBrowserLoggerContext=sr.getBrowserLoggerContext=sr.getDefaultLoggerOptions=void 0;const n=Rd();function t(d){return Object.assign(Object.assign({},d),{level:(d==null?void 0:d.level)||n.PINO_LOGGER_DEFAULTS.level})}sr.getDefaultLoggerOptions=t;function r(d,v=n.PINO_CUSTOM_CONTEXT_KEY){return d[v]||""}sr.getBrowserLoggerContext=r;function s(d,v,b=n.PINO_CUSTOM_CONTEXT_KEY){return d[b]=v,d}sr.setBrowserLoggerContext=s;function a(d,v=n.PINO_CUSTOM_CONTEXT_KEY){let b="";return typeof d.bindings>"u"?b=r(d,v):b=d.bindings().context||"",b}sr.getLoggerContext=a;function l(d,v,b=n.PINO_CUSTOM_CONTEXT_KEY){const x=a(d,b);return x.trim()?`${x}/${v}`:v}sr.formatChildLoggerContext=l;function p(d,v,b=n.PINO_CUSTOM_CONTEXT_KEY){const x=l(d,v,b),$=d.child({context:x});return s($,x,b)}return sr.generateChildLogger=p,sr}(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.pino=void 0;const t=Vr,r=t.__importDefault(zb());Object.defineProperty(n,"pino",{enumerable:!0,get:function(){return r.default}}),t.__exportStar(Rd(),n),t.__exportStar(Hb(),n)})(Ze);class Bb extends rn{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}class Kb extends rn{constructor(t,r){super(),this.core=t,this.logger=r,this.records=new Map}}class kb{constructor(t,r){this.logger=t,this.core=r}}let Vb=class extends rn{constructor(t,r){super(),this.relayer=t,this.logger=r}},Wb=class extends rn{constructor(t){super()}},Gb=class{constructor(t,r,s,a){this.core=t,this.logger=r,this.name=s}};class Yb extends rn{constructor(t,r){super(),this.relayer=t,this.logger=r}}let Jb=class extends rn{constructor(t,r){super(),this.core=t,this.logger=r}},Xb=class{constructor(t,r){this.projectId=t,this.logger=r}};class Qb{constructor(t){this.opts=t,this.protocol="wc",this.version=2}}let Zb=class{constructor(t){this.client=t}};const eE=n=>JSON.stringify(n,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),tE=n=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=n.replace(t,'$1"$2n"$3');return JSON.parse(r,(s,a)=>typeof a=="string"&&a.match(/^\d+n$/)?BigInt(a.substring(0,a.length-1)):a)};function yu(n){if(typeof n!="string")throw new Error(`Cannot safe json parse value of type ${typeof n}`);try{return tE(n)}catch{return n}}function ps(n){return typeof n=="string"?n:eE(n)||""}var _u={},Ud={};(function(n){Object.defineProperty(n,"__esModule",{value:!0});var t=De,r=Ir;n.DIGEST_LENGTH=64,n.BLOCK_SIZE=128;var s=function(){function d(){this.digestLength=n.DIGEST_LENGTH,this.blockSize=n.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return d.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},d.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},d.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},d.prototype.update=function(v,b){if(b===void 0&&(b=v.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var x=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength<n.BLOCK_SIZE&&b>0;)this._buffer[this._bufferLength++]=v[x++],b--;this._bufferLength===this.blockSize&&(l(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(x=l(this._tempHi,this._tempLo,this._stateHi,this._stateLo,v,x,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=v[x++],b--;return this},d.prototype.finish=function(v){if(!this._finished){var b=this._bytesHashed,x=this._bufferLength,$=b/536870912|0,j=b<<3,U=b%128<112?128:256;this._buffer[x]=128;for(var z=x+1;z<U-8;z++)this._buffer[z]=0;t.writeUint32BE($,this._buffer,U-8),t.writeUint32BE(j,this._buffer,U-4),l(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,U),this._finished=!0}for(var z=0;z<this.digestLength/8;z++)t.writeUint32BE(this._stateHi[z],v,z*8),t.writeUint32BE(this._stateLo[z],v,z*8+4);return this},d.prototype.digest=function(){var v=new Uint8Array(this.digestLength);return this.finish(v),v},d.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},d.prototype.restoreState=function(v){return this._stateHi.set(v.stateHi),this._stateLo.set(v.stateLo),this._bufferLength=v.bufferLength,v.buffer&&this._buffer.set(v.buffer),this._bytesHashed=v.bytesHashed,this._finished=!1,this},d.prototype.cleanSavedState=function(v){r.wipe(v.stateHi),r.wipe(v.stateLo),v.buffer&&r.wipe(v.buffer),v.bufferLength=0,v.bytesHashed=0},d}();n.SHA512=s;var a=new Int32Array([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]);function l(d,v,b,x,$,j,U){for(var z=b[0],B=b[1],K=b[2],oe=b[3],T=b[4],D=b[5],S=b[6],P=b[7],m=x[0],u=x[1],_=x[2],W=x[3],V=x[4],se=x[5],ce=x[6],ge=x[7],N,q,le,te,G,ee,Y,re;U>=128;){for(var Oe=0;Oe<16;Oe++){var ie=8*Oe+j;d[Oe]=t.readUint32BE($,ie),v[Oe]=t.readUint32BE($,ie+4)}for(var Oe=0;Oe<80;Oe++){var we=z,he=B,_e=K,M=oe,F=T,A=D,h=S,I=P,ne=m,fe=u,Ie=_,He=W,ke=V,Fe=se,pt=ce,gt=ge;if(N=P,q=ge,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=(T>>>14|V<<32-14)^(T>>>18|V<<32-18)^(V>>>41-32|T<<32-(41-32)),q=(V>>>14|T<<32-14)^(V>>>18|T<<32-18)^(T>>>41-32|V<<32-(41-32)),G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,N=T&D^~T&S,q=V&se^~V&ce,G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,N=a[Oe*2],q=a[Oe*2+1],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,N=d[Oe%16],q=v[Oe%16],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,le=Y&65535|re<<16,te=G&65535|ee<<16,N=le,q=te,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=(z>>>28|m<<32-28)^(m>>>34-32|z<<32-(34-32))^(m>>>39-32|z<<32-(39-32)),q=(m>>>28|z<<32-28)^(z>>>34-32|m<<32-(34-32))^(z>>>39-32|m<<32-(39-32)),G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,N=z&B^z&K^B&K,q=m&u^m&_^u&_,G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,I=Y&65535|re<<16,gt=G&65535|ee<<16,N=M,q=He,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=le,q=te,G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,M=Y&65535|re<<16,He=G&65535|ee<<16,B=we,K=he,oe=_e,T=M,D=F,S=A,P=h,z=I,u=ne,_=fe,W=Ie,V=He,se=ke,ce=Fe,ge=pt,m=gt,Oe%16===15)for(var ie=0;ie<16;ie++)N=d[ie],q=v[ie],G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=d[(ie+9)%16],q=v[(ie+9)%16],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,le=d[(ie+1)%16],te=v[(ie+1)%16],N=(le>>>1|te<<32-1)^(le>>>8|te<<32-8)^le>>>7,q=(te>>>1|le<<32-1)^(te>>>8|le<<32-8)^(te>>>7|le<<32-7),G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,le=d[(ie+14)%16],te=v[(ie+14)%16],N=(le>>>19|te<<32-19)^(te>>>61-32|le<<32-(61-32))^le>>>6,q=(te>>>19|le<<32-19)^(le>>>61-32|te<<32-(61-32))^(te>>>6|le<<32-6),G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,d[ie]=Y&65535|re<<16,v[ie]=G&65535|ee<<16}N=z,q=m,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=b[0],q=x[0],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,b[0]=z=Y&65535|re<<16,x[0]=m=G&65535|ee<<16,N=B,q=u,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=b[1],q=x[1],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,b[1]=B=Y&65535|re<<16,x[1]=u=G&65535|ee<<16,N=K,q=_,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=b[2],q=x[2],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,b[2]=K=Y&65535|re<<16,x[2]=_=G&65535|ee<<16,N=oe,q=W,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=b[3],q=x[3],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,b[3]=oe=Y&65535|re<<16,x[3]=W=G&65535|ee<<16,N=T,q=V,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=b[4],q=x[4],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,b[4]=T=Y&65535|re<<16,x[4]=V=G&65535|ee<<16,N=D,q=se,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=b[5],q=x[5],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,b[5]=D=Y&65535|re<<16,x[5]=se=G&65535|ee<<16,N=S,q=ce,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=b[6],q=x[6],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,b[6]=S=Y&65535|re<<16,x[6]=ce=G&65535|ee<<16,N=P,q=ge,G=q&65535,ee=q>>>16,Y=N&65535,re=N>>>16,N=b[7],q=x[7],G+=q&65535,ee+=q>>>16,Y+=N&65535,re+=N>>>16,ee+=G>>>16,Y+=ee>>>16,re+=Y>>>16,b[7]=P=Y&65535|re<<16,x[7]=ge=G&65535|ee<<16,j+=128,U-=128}return j}function p(d){var v=new s;v.update(d);var b=v.digest();return v.clean(),b}n.hash=p})(Ud);(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.convertSecretKeyToX25519=n.convertPublicKeyToX25519=n.verify=n.sign=n.extractPublicKeyFromSecretKey=n.generateKeyPair=n.generateKeyPairFromSeed=n.SEED_LENGTH=n.SECRET_KEY_LENGTH=n.PUBLIC_KEY_LENGTH=n.SIGNATURE_LENGTH=void 0;const t=Nn,r=Ud,s=Ir;n.SIGNATURE_LENGTH=64,n.PUBLIC_KEY_LENGTH=32,n.SECRET_KEY_LENGTH=64,n.SEED_LENGTH=32;function a(M){const F=new Float64Array(16);if(M)for(let A=0;A<M.length;A++)F[A]=M[A];return F}const l=new Uint8Array(32);l[0]=9;const p=a(),d=a([1]),v=a([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),b=a([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),x=a([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),$=a([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),j=a([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function U(M,F){for(let A=0;A<16;A++)M[A]=F[A]|0}function z(M){let F=1;for(let A=0;A<16;A++){let h=M[A]+F+65535;F=Math.floor(h/65536),M[A]=h-F*65536}M[0]+=F-1+37*(F-1)}function B(M,F,A){const h=~(A-1);for(let I=0;I<16;I++){const ne=h&(M[I]^F[I]);M[I]^=ne,F[I]^=ne}}function K(M,F){const A=a(),h=a();for(let I=0;I<16;I++)h[I]=F[I];z(h),z(h),z(h);for(let I=0;I<2;I++){A[0]=h[0]-65517;for(let fe=1;fe<15;fe++)A[fe]=h[fe]-65535-(A[fe-1]>>16&1),A[fe-1]&=65535;A[15]=h[15]-32767-(A[14]>>16&1);const ne=A[15]>>16&1;A[14]&=65535,B(h,A,1-ne)}for(let I=0;I<16;I++)M[2*I]=h[I]&255,M[2*I+1]=h[I]>>8}function oe(M,F){let A=0;for(let h=0;h<32;h++)A|=M[h]^F[h];return(1&A-1>>>8)-1}function T(M,F){const A=new Uint8Array(32),h=new Uint8Array(32);return K(A,M),K(h,F),oe(A,h)}function D(M){const F=new Uint8Array(32);return K(F,M),F[0]&1}function S(M,F){for(let A=0;A<16;A++)M[A]=F[2*A]+(F[2*A+1]<<8);M[15]&=32767}function P(M,F,A){for(let h=0;h<16;h++)M[h]=F[h]+A[h]}function m(M,F,A){for(let h=0;h<16;h++)M[h]=F[h]-A[h]}function u(M,F,A){let h,I,ne=0,fe=0,Ie=0,He=0,ke=0,Fe=0,pt=0,gt=0,je=0,xe=0,Ue=0,Le=0,qe=0,Ae=0,$e=0,Se=0,Te=0,Be=0,Pe=0,Ve=0,Ge=0,et=0,tt=0,Je=0,Zt=0,ur=0,Wr=0,er=0,ii=0,vi=0,Ui=0,bt=A[0],vt=A[1],Et=A[2],St=A[3],mt=A[4],yt=A[5],$t=A[6],Dt=A[7],It=A[8],Ft=A[9],xt=A[10],Tt=A[11],Ot=A[12],ht=A[13],Mt=A[14],jt=A[15];h=F[0],ne+=h*bt,fe+=h*vt,Ie+=h*Et,He+=h*St,ke+=h*mt,Fe+=h*yt,pt+=h*$t,gt+=h*Dt,je+=h*It,xe+=h*Ft,Ue+=h*xt,Le+=h*Tt,qe+=h*Ot,Ae+=h*ht,$e+=h*Mt,Se+=h*jt,h=F[1],fe+=h*bt,Ie+=h*vt,He+=h*Et,ke+=h*St,Fe+=h*mt,pt+=h*yt,gt+=h*$t,je+=h*Dt,xe+=h*It,Ue+=h*Ft,Le+=h*xt,qe+=h*Tt,Ae+=h*Ot,$e+=h*ht,Se+=h*Mt,Te+=h*jt,h=F[2],Ie+=h*bt,He+=h*vt,ke+=h*Et,Fe+=h*St,pt+=h*mt,gt+=h*yt,je+=h*$t,xe+=h*Dt,Ue+=h*It,Le+=h*Ft,qe+=h*xt,Ae+=h*Tt,$e+=h*Ot,Se+=h*ht,Te+=h*Mt,Be+=h*jt,h=F[3],He+=h*bt,ke+=h*vt,Fe+=h*Et,pt+=h*St,gt+=h*mt,je+=h*yt,xe+=h*$t,Ue+=h*Dt,Le+=h*It,qe+=h*Ft,Ae+=h*xt,$e+=h*Tt,Se+=h*Ot,Te+=h*ht,Be+=h*Mt,Pe+=h*jt,h=F[4],ke+=h*bt,Fe+=h*vt,pt+=h*Et,gt+=h*St,je+=h*mt,xe+=h*yt,Ue+=h*$t,Le+=h*Dt,qe+=h*It,Ae+=h*Ft,$e+=h*xt,Se+=h*Tt,Te+=h*Ot,Be+=h*ht,Pe+=h*Mt,Ve+=h*jt,h=F[5],Fe+=h*bt,pt+=h*vt,gt+=h*Et,je+=h*St,xe+=h*mt,Ue+=h*yt,Le+=h*$t,qe+=h*Dt,Ae+=h*It,$e+=h*Ft,Se+=h*xt,Te+=h*Tt,Be+=h*Ot,Pe+=h*ht,Ve+=h*Mt,Ge+=h*jt,h=F[6],pt+=h*bt,gt+=h*vt,je+=h*Et,xe+=h*St,Ue+=h*mt,Le+=h*yt,qe+=h*$t,Ae+=h*Dt,$e+=h*It,Se+=h*Ft,Te+=h*xt,Be+=h*Tt,Pe+=h*Ot,Ve+=h*ht,Ge+=h*Mt,et+=h*jt,h=F[7],gt+=h*bt,je+=h*vt,xe+=h*Et,Ue+=h*St,Le+=h*mt,qe+=h*yt,Ae+=h*$t,$e+=h*Dt,Se+=h*It,Te+=h*Ft,Be+=h*xt,Pe+=h*Tt,Ve+=h*Ot,Ge+=h*ht,et+=h*Mt,tt+=h*jt,h=F[8],je+=h*bt,xe+=h*vt,Ue+=h*Et,Le+=h*St,qe+=h*mt,Ae+=h*yt,$e+=h*$t,Se+=h*Dt,Te+=h*It,Be+=h*Ft,Pe+=h*xt,Ve+=h*Tt,Ge+=h*Ot,et+=h*ht,tt+=h*Mt,Je+=h*jt,h=F[9],xe+=h*bt,Ue+=h*vt,Le+=h*Et,qe+=h*St,Ae+=h*mt,$e+=h*yt,Se+=h*$t,Te+=h*Dt,Be+=h*It,Pe+=h*Ft,Ve+=h*xt,Ge+=h*Tt,et+=h*Ot,tt+=h*ht,Je+=h*Mt,Zt+=h*jt,h=F[10],Ue+=h*bt,Le+=h*vt,qe+=h*Et,Ae+=h*St,$e+=h*mt,Se+=h*yt,Te+=h*$t,Be+=h*Dt,Pe+=h*It,Ve+=h*Ft,Ge+=h*xt,et+=h*Tt,tt+=h*Ot,Je+=h*ht,Zt+=h*Mt,ur+=h*jt,h=F[11],Le+=h*bt,qe+=h*vt,Ae+=h*Et,$e+=h*St,Se+=h*mt,Te+=h*yt,Be+=h*$t,Pe+=h*Dt,Ve+=h*It,Ge+=h*Ft,et+=h*xt,tt+=h*Tt,Je+=h*Ot,Zt+=h*ht,ur+=h*Mt,Wr+=h*jt,h=F[12],qe+=h*bt,Ae+=h*vt,$e+=h*Et,Se+=h*St,Te+=h*mt,Be+=h*yt,Pe+=h*$t,Ve+=h*Dt,Ge+=h*It,et+=h*Ft,tt+=h*xt,Je+=h*Tt,Zt+=h*Ot,ur+=h*ht,Wr+=h*Mt,er+=h*jt,h=F[13],Ae+=h*bt,$e+=h*vt,Se+=h*Et,Te+=h*St,Be+=h*mt,Pe+=h*yt,Ve+=h*$t,Ge+=h*Dt,et+=h*It,tt+=h*Ft,Je+=h*xt,Zt+=h*Tt,ur+=h*Ot,Wr+=h*ht,er+=h*Mt,ii+=h*jt,h=F[14],$e+=h*bt,Se+=h*vt,Te+=h*Et,Be+=h*St,Pe+=h*mt,Ve+=h*yt,Ge+=h*$t,et+=h*Dt,tt+=h*It,Je+=h*Ft,Zt+=h*xt,ur+=h*Tt,Wr+=h*Ot,er+=h*ht,ii+=h*Mt,vi+=h*jt,h=F[15],Se+=h*bt,Te+=h*vt,Be+=h*Et,Pe+=h*St,Ve+=h*mt,Ge+=h*yt,et+=h*$t,tt+=h*Dt,Je+=h*It,Zt+=h*Ft,ur+=h*xt,Wr+=h*Tt,er+=h*Ot,ii+=h*ht,vi+=h*Mt,Ui+=h*jt,ne+=38*Te,fe+=38*Be,Ie+=38*Pe,He+=38*Ve,ke+=38*Ge,Fe+=38*et,pt+=38*tt,gt+=38*Je,je+=38*Zt,xe+=38*ur,Ue+=38*Wr,Le+=38*er,qe+=38*ii,Ae+=38*vi,$e+=38*Ui,I=1,h=ne+I+65535,I=Math.floor(h/65536),ne=h-I*65536,h=fe+I+65535,I=Math.floor(h/65536),fe=h-I*65536,h=Ie+I+65535,I=Math.floor(h/65536),Ie=h-I*65536,h=He+I+65535,I=Math.floor(h/65536),He=h-I*65536,h=ke+I+65535,I=Math.floor(h/65536),ke=h-I*65536,h=Fe+I+65535,I=Math.floor(h/65536),Fe=h-I*65536,h=pt+I+65535,I=Math.floor(h/65536),pt=h-I*65536,h=gt+I+65535,I=Math.floor(h/65536),gt=h-I*65536,h=je+I+65535,I=Math.floor(h/65536),je=h-I*65536,h=xe+I+65535,I=Math.floor(h/65536),xe=h-I*65536,h=Ue+I+65535,I=Math.floor(h/65536),Ue=h-I*65536,h=Le+I+65535,I=Math.floor(h/65536),Le=h-I*65536,h=qe+I+65535,I=Math.floor(h/65536),qe=h-I*65536,h=Ae+I+65535,I=Math.floor(h/65536),Ae=h-I*65536,h=$e+I+65535,I=Math.floor(h/65536),$e=h-I*65536,h=Se+I+65535,I=Math.floor(h/65536),Se=h-I*65536,ne+=I-1+37*(I-1),I=1,h=ne+I+65535,I=Math.floor(h/65536),ne=h-I*65536,h=fe+I+65535,I=Math.floor(h/65536),fe=h-I*65536,h=Ie+I+65535,I=Math.floor(h/65536),Ie=h-I*65536,h=He+I+65535,I=Math.floor(h/65536),He=h-I*65536,h=ke+I+65535,I=Math.floor(h/65536),ke=h-I*65536,h=Fe+I+65535,I=Math.floor(h/65536),Fe=h-I*65536,h=pt+I+65535,I=Math.floor(h/65536),pt=h-I*65536,h=gt+I+65535,I=Math.floor(h/65536),gt=h-I*65536,h=je+I+65535,I=Math.floor(h/65536),je=h-I*65536,h=xe+I+65535,I=Math.floor(h/65536),xe=h-I*65536,h=Ue+I+65535,I=Math.floor(h/65536),Ue=h-I*65536,h=Le+I+65535,I=Math.floor(h/65536),Le=h-I*65536,h=qe+I+65535,I=Math.floor(h/65536),qe=h-I*65536,h=Ae+I+65535,I=Math.floor(h/65536),Ae=h-I*65536,h=$e+I+65535,I=Math.floor(h/65536),$e=h-I*65536,h=Se+I+65535,I=Math.floor(h/65536),Se=h-I*65536,ne+=I-1+37*(I-1),M[0]=ne,M[1]=fe,M[2]=Ie,M[3]=He,M[4]=ke,M[5]=Fe,M[6]=pt,M[7]=gt,M[8]=je,M[9]=xe,M[10]=Ue,M[11]=Le,M[12]=qe,M[13]=Ae,M[14]=$e,M[15]=Se}function _(M,F){u(M,F,F)}function W(M,F){const A=a();let h;for(h=0;h<16;h++)A[h]=F[h];for(h=253;h>=0;h--)_(A,A),h!==2&&h!==4&&u(A,A,F);for(h=0;h<16;h++)M[h]=A[h]}function V(M,F){const A=a();let h;for(h=0;h<16;h++)A[h]=F[h];for(h=250;h>=0;h--)_(A,A),h!==1&&u(A,A,F);for(h=0;h<16;h++)M[h]=A[h]}function se(M,F){const A=a(),h=a(),I=a(),ne=a(),fe=a(),Ie=a(),He=a(),ke=a(),Fe=a();m(A,M[1],M[0]),m(Fe,F[1],F[0]),u(A,A,Fe),P(h,M[0],M[1]),P(Fe,F[0],F[1]),u(h,h,Fe),u(I,M[3],F[3]),u(I,I,b),u(ne,M[2],F[2]),P(ne,ne,ne),m(fe,h,A),m(Ie,ne,I),P(He,ne,I),P(ke,h,A),u(M[0],fe,Ie),u(M[1],ke,He),u(M[2],He,Ie),u(M[3],fe,ke)}function ce(M,F,A){for(let h=0;h<4;h++)B(M[h],F[h],A)}function ge(M,F){const A=a(),h=a(),I=a();W(I,F[2]),u(A,F[0],I),u(h,F[1],I),K(M,h),M[31]^=D(A)<<7}function N(M,F,A){U(M[0],p),U(M[1],d),U(M[2],d),U(M[3],p);for(let h=255;h>=0;--h){const I=A[h/8|0]>>(h&7)&1;ce(M,F,I),se(F,M),se(M,M),ce(M,F,I)}}function q(M,F){const A=[a(),a(),a(),a()];U(A[0],x),U(A[1],$),U(A[2],d),u(A[3],x,$),N(M,A,F)}function le(M){if(M.length!==n.SEED_LENGTH)throw new Error(`ed25519: seed must be ${n.SEED_LENGTH} bytes`);const F=(0,r.hash)(M);F[0]&=248,F[31]&=127,F[31]|=64;const A=new Uint8Array(32),h=[a(),a(),a(),a()];q(h,F),ge(A,h);const I=new Uint8Array(64);return I.set(M),I.set(A,32),{publicKey:A,secretKey:I}}n.generateKeyPairFromSeed=le;function te(M){const F=(0,t.randomBytes)(32,M),A=le(F);return(0,s.wipe)(F),A}n.generateKeyPair=te;function G(M){if(M.length!==n.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${n.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(M.subarray(32))}n.extractPublicKeyFromSecretKey=G;const ee=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Y(M,F){let A,h,I,ne;for(h=63;h>=32;--h){for(A=0,I=h-32,ne=h-12;I<ne;++I)F[I]+=A-16*F[h]*ee[I-(h-32)],A=Math.floor((F[I]+128)/256),F[I]-=A*256;F[I]+=A,F[h]=0}for(A=0,I=0;I<32;I++)F[I]+=A-(F[31]>>4)*ee[I],A=F[I]>>8,F[I]&=255;for(I=0;I<32;I++)F[I]-=A*ee[I];for(h=0;h<32;h++)F[h+1]+=F[h]>>8,M[h]=F[h]&255}function re(M){const F=new Float64Array(64);for(let A=0;A<64;A++)F[A]=M[A];for(let A=0;A<64;A++)M[A]=0;Y(M,F)}function Oe(M,F){const A=new Float64Array(64),h=[a(),a(),a(),a()],I=(0,r.hash)(M.subarray(0,32));I[0]&=248,I[31]&=127,I[31]|=64;const ne=new Uint8Array(64);ne.set(I.subarray(32),32);const fe=new r.SHA512;fe.update(ne.subarray(32)),fe.update(F);const Ie=fe.digest();fe.clean(),re(Ie),q(h,Ie),ge(ne,h),fe.reset(),fe.update(ne.subarray(0,32)),fe.update(M.subarray(32)),fe.update(F);const He=fe.digest();re(He);for(let ke=0;ke<32;ke++)A[ke]=Ie[ke];for(let ke=0;ke<32;ke++)for(let Fe=0;Fe<32;Fe++)A[ke+Fe]+=He[ke]*I[Fe];return Y(ne.subarray(32),A),ne}n.sign=Oe;function ie(M,F){const A=a(),h=a(),I=a(),ne=a(),fe=a(),Ie=a(),He=a();return U(M[2],d),S(M[1],F),_(I,M[1]),u(ne,I,v),m(I,I,M[2]),P(ne,M[2],ne),_(fe,ne),_(Ie,fe),u(He,Ie,fe),u(A,He,I),u(A,A,ne),V(A,A),u(A,A,I),u(A,A,ne),u(A,A,ne),u(M[0],A,ne),_(h,M[0]),u(h,h,ne),T(h,I)&&u(M[0],M[0],j),_(h,M[0]),u(h,h,ne),T(h,I)?-1:(D(M[0])===F[31]>>7&&m(M[0],p,M[0]),u(M[3],M[0],M[1]),0)}function we(M,F,A){const h=new Uint8Array(32),I=[a(),a(),a(),a()],ne=[a(),a(),a(),a()];if(A.length!==n.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${n.SIGNATURE_LENGTH} bytes`);if(ie(ne,M))return!1;const fe=new r.SHA512;fe.update(A.subarray(0,32)),fe.update(M),fe.update(F);const Ie=fe.digest();return re(Ie),N(I,ne,Ie),q(ne,A.subarray(32)),se(I,ne),ge(h,I),!oe(A,h)}n.verify=we;function he(M){let F=[a(),a(),a(),a()];if(ie(F,M))throw new Error("Ed25519: invalid public key");let A=a(),h=a(),I=F[1];P(A,d,I),m(h,d,I),W(h,h),u(A,A,h);let ne=new Uint8Array(32);return K(ne,A),ne}n.convertPublicKeyToX25519=he;function _e(M){const F=(0,r.hash)(M.subarray(0,32));F[0]&=248,F[31]&=127,F[31]|=64;const A=new Uint8Array(F.subarray(0,32));return(0,s.wipe)(F),A}n.convertSecretKeyToX25519=_e})(_u);const rE="EdDSA",iE="JWT",Ld=".",$d="base64url",nE="utf8",sE="utf8",oE=":",aE="did",cE="key",gf="base58btc",uE="z",hE="K36",lE=32;function $o(n){return cr(vr(ps(n),nE),$d)}function Dd(n){const t=vr(hE,gf),r=uE+cr(jc([t,n]),gf);return[aE,cE,r].join(oE)}function fE(n){return cr(n,$d)}function dE(n){return vr([$o(n.header),$o(n.payload)].join(Ld),sE)}function pE(n){return[$o(n.header),$o(n.payload),fE(n.signature)].join(Ld)}function vf(n=Nn.randomBytes(lE)){return _u.generateKeyPairFromSeed(n)}async function gE(n,t,r,s,a=ve.fromMiliseconds(Date.now())){const l={alg:rE,typ:iE},p=Dd(s.publicKey),d=a+r,v={iss:p,sub:n,aud:t,iat:a,exp:d},b=dE({header:l,payload:v}),x=_u.sign(s.secretKey,b);return pE({header:l,payload:v,signature:x})}class Ci extends V_{constructor(t){super(t),this.events=new Fr.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async request(t,r){return this.requestStrict(Mo(t.method,t.params||[],t.id||ru().toString()),r)}async requestStrict(t,r){return new Promise(async(s,a)=>{if(!this.connection.connected)try{await this.open()}catch(l){a(l)}this.events.on(`${t.id}`,l=>{Kr(l)?a(l.error):s(l.result)});try{await this.connection.send(t,r)}catch(l){a(l)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),qo(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}var Tc,yf;function vE(){return yf||(yf=1,Tc=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}),Tc}const yE=()=>typeof WebSocket<"u"?WebSocket:typeof yr<"u"&&typeof yr.WebSocket<"u"?yr.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:vE(),_E=()=>typeof WebSocket<"u"||typeof yr<"u"&&typeof yr.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",_f=n=>n.split("?")[0],mf=10,mE=yE();class wE{constructor(t){if(this.url=t,this.events=new Fr.EventEmitter,this.registering=!1,!xl(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=s=>{this.onClose(s),t()},this.socket.close()})}async send(t,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(ps(t))}catch(s){this.onError(t.id,s)}}register(t=this.url){if(!xl(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,a)=>{this.events.once("register_error",l=>{this.resetMaxListeners(),a(l)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return a(new Error("WebSocket connection is missing or invalid"));s(this.socket)})})}return this.url=t,this.registering=!0,new Promise((r,s)=>{const a=B_.isReactNative()?void 0:{rejectUnauthorized:!J_(t)},l=new mE(t,[],a);_E()?l.onerror=p=>{const d=p;s(this.emitError(d.error))}:l.on("error",p=>{s(this.emitError(p))}),l.onopen=()=>{this.onOpen(l),r(l)}})}onOpen(t){t.onmessage=r=>this.onPayload(r),t.onclose=r=>this.onClose(r),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?yu(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const s=this.parseError(r),a=s.message||s.toString(),l=jo(t,a);this.events.emit("payload",l)}parseError(t,r=this.url){return ed(t,_f(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>mf&&this.events.setMaxListeners(mf)}emitError(t){const r=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${_f(this.url)}`));return this.events.emit("register_error",r),r}}var Do={exports:{}};Do.exports;(function(n,t){var r=200,s="__lodash_hash_undefined__",a=1,l=2,p=9007199254740991,d="[object Arguments]",v="[object Array]",b="[object AsyncFunction]",x="[object Boolean]",$="[object Date]",j="[object Error]",U="[object Function]",z="[object GeneratorFunction]",B="[object Map]",K="[object Number]",oe="[object Null]",T="[object Object]",D="[object Promise]",S="[object Proxy]",P="[object RegExp]",m="[object Set]",u="[object String]",_="[object Symbol]",W="[object Undefined]",V="[object WeakMap]",se="[object ArrayBuffer]",ce="[object DataView]",ge="[object Float32Array]",N="[object Float64Array]",q="[object Int8Array]",le="[object Int16Array]",te="[object Int32Array]",G="[object Uint8Array]",ee="[object Uint8ClampedArray]",Y="[object Uint16Array]",re="[object Uint32Array]",Oe=/[\\^$.*+?()[\]{}|]/g,ie=/^\[object .+?Constructor\]$/,we=/^(?:0|[1-9]\d*)$/,he={};he[ge]=he[N]=he[q]=he[le]=he[te]=he[G]=he[ee]=he[Y]=he[re]=!0,he[d]=he[v]=he[se]=he[x]=he[ce]=he[$]=he[j]=he[U]=he[B]=he[K]=he[T]=he[P]=he[m]=he[u]=he[V]=!1;var _e=typeof Xi=="object"&&Xi&&Xi.Object===Object&&Xi,M=typeof self=="object"&&self&&self.Object===Object&&self,F=_e||M||Function("return this")(),A=t&&!t.nodeType&&t,h=A&&!0&&n&&!n.nodeType&&n,I=h&&h.exports===A,ne=I&&_e.process,fe=function(){try{return ne&&ne.binding&&ne.binding("util")}catch{}}(),Ie=fe&&fe.isTypedArray;function He(w,C){for(var Q=-1,de=w==null?0:w.length,at=0,Ce=[];++Q<de;){var ft=w[Q];C(ft,Q,w)&&(Ce[at++]=ft)}return Ce}function ke(w,C){for(var Q=-1,de=C.length,at=w.length;++Q<de;)w[at+Q]=C[Q];return w}function Fe(w,C){for(var Q=-1,de=w==null?0:w.length;++Q<de;)if(C(w[Q],Q,w))return!0;return!1}function pt(w,C){for(var Q=-1,de=Array(w);++Q<w;)de[Q]=C(Q);return de}function gt(w){return function(C){return w(C)}}function je(w,C){return w.has(C)}function xe(w,C){return w==null?void 0:w[C]}function Ue(w){var C=-1,Q=Array(w.size);return w.forEach(function(de,at){Q[++C]=[at,de]}),Q}function Le(w,C){return function(Q){return w(C(Q))}}function qe(w){var C=-1,Q=Array(w.size);return w.forEach(function(de){Q[++C]=de}),Q}var Ae=Array.prototype,$e=Function.prototype,Se=Object.prototype,Te=F["__core-js_shared__"],Be=$e.toString,Pe=Se.hasOwnProperty,Ve=function(){var w=/[^.]+$/.exec(Te&&Te.keys&&Te.keys.IE_PROTO||"");return w?"Symbol(src)_1."+w:""}(),Ge=Se.toString,et=RegExp("^"+Be.call(Pe).replace(Oe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),tt=I?F.Buffer:void 0,Je=F.Symbol,Zt=F.Uint8Array,ur=Se.propertyIsEnumerable,Wr=Ae.splice,er=Je?Je.toStringTag:void 0,ii=Object.getOwnPropertySymbols,vi=tt?tt.isBuffer:void 0,Ui=Le(Object.keys,Object),bt=_r(F,"DataView"),vt=_r(F,"Map"),Et=_r(F,"Promise"),St=_r(F,"Set"),mt=_r(F,"WeakMap"),yt=_r(Object,"create"),$t=si(bt),Dt=si(vt),It=si(Et),Ft=si(St),xt=si(mt),Tt=Je?Je.prototype:void 0,Ot=Tt?Tt.valueOf:void 0;function ht(w){var C=-1,Q=w==null?0:w.length;for(this.clear();++C<Q;){var de=w[C];this.set(de[0],de[1])}}function Mt(){this.__data__=yt?yt(null):{},this.size=0}function jt(w){var C=this.has(w)&&delete this.__data__[w];return this.size-=C?1:0,C}function Yo(w){var C=this.__data__;if(yt){var Q=C[w];return Q===s?void 0:Q}return Pe.call(C,w)?C[w]:void 0}function Jo(w){var C=this.__data__;return yt?C[w]!==void 0:Pe.call(C,w)}function Xo(w,C){var Q=this.__data__;return this.size+=this.has(w)?0:1,Q[w]=yt&&C===void 0?s:C,this}ht.prototype.clear=Mt,ht.prototype.delete=jt,ht.prototype.get=Yo,ht.prototype.has=Jo,ht.prototype.set=Xo;function xr(w){var C=-1,Q=w==null?0:w.length;for(this.clear();++C<Q;){var de=w[C];this.set(de[0],de[1])}}function Qo(){this.__data__=[],this.size=0}function Zo(w){var C=this.__data__,Q=Li(C,w);if(Q<0)return!1;var de=C.length-1;return Q==de?C.pop():Wr.call(C,Q,1),--this.size,!0}function ea(w){var C=this.__data__,Q=Li(C,w);return Q<0?void 0:C[Q][1]}function ta(w){return Li(this.__data__,w)>-1}function ra(w,C){var Q=this.__data__,de=Li(Q,w);return de<0?(++this.size,Q.push([w,C])):Q[de][1]=C,this}xr.prototype.clear=Qo,xr.prototype.delete=Zo,xr.prototype.get=ea,xr.prototype.has=ta,xr.prototype.set=ra;function ni(w){var C=-1,Q=w==null?0:w.length;for(this.clear();++C<Q;){var de=w[C];this.set(de[0],de[1])}}function sn(){this.size=0,this.__data__={hash:new ht,map:new(vt||xr),string:new ht}}function ia(w){var C=yi(this,w).delete(w);return this.size-=C?1:0,C}function on(w){return yi(this,w).get(w)}function na(w){return yi(this,w).has(w)}function sa(w,C){var Q=yi(this,w),de=Q.size;return Q.set(w,C),this.size+=Q.size==de?0:1,this}ni.prototype.clear=sn,ni.prototype.delete=ia,ni.prototype.get=on,ni.prototype.has=na,ni.prototype.set=sa;function an(w){var C=-1,Q=w==null?0:w.length;for(this.__data__=new ni;++C<Q;)this.add(w[C])}function ms(w){return this.__data__.set(w,s),this}function ws(w){return this.__data__.has(w)}an.prototype.add=an.prototype.push=ms,an.prototype.has=ws;function Mr(w){var C=this.__data__=new xr(w);this.size=C.size}function oa(){this.__data__=new xr,this.size=0}function aa(w){var C=this.__data__,Q=C.delete(w);return this.size=C.size,Q}function ca(w){return this.__data__.get(w)}function ua(w){return this.__data__.has(w)}function bs(w,C){var Q=this.__data__;if(Q instanceof xr){var de=Q.__data__;if(!vt||de.length<r-1)return de.push([w,C]),this.size=++Q.size,this;Q=this.__data__=new ni(de)}return Q.set(w,C),this.size=Q.size,this}Mr.prototype.clear=oa,Mr.prototype.delete=aa,Mr.prototype.get=ca,Mr.prototype.has=ua,Mr.prototype.set=bs;function Es(w,C){var Q=hn(w),de=!Q&&Ls(w),at=!Q&&!de&&Dn(w),Ce=!Q&&!de&&!at&&Fs(w),ft=Q||de||at||Ce,qt=ft?pt(w.length,String):[],Xe=qt.length;for(var ct in w)(C||Pe.call(w,ct))&&!(ft&&(ct=="length"||at&&(ct=="offset"||ct=="parent")||Ce&&(ct=="buffer"||ct=="byteLength"||ct=="byteOffset")||Ts(ct,Xe)))&&qt.push(ct);return qt}function Li(w,C){for(var Q=w.length;Q--;)if(Us(w[Q][0],C))return Q;return-1}function Ln(w,C,Q){var de=C(w);return hn(w)?de:ke(de,Q(w))}function $i(w){return w==null?w===void 0?W:oe:er&&er in Object(w)?Ps(w):fa(w)}function $n(w){return Fi(w)&&$i(w)==d}function Di(w,C,Q,de,at){return w===C?!0:w==null||C==null||!Fi(w)&&!Fi(C)?w!==w&&C!==C:Ss(w,C,Q,de,Di,at)}function Ss(w,C,Q,de,at,Ce){var ft=hn(w),qt=hn(C),Xe=ft?v:Gr(w),ct=qt?v:Gr(C);Xe=Xe==d?T:Xe,ct=ct==d?T:ct;var Nt=Xe==T,hr=ct==T,zt=Xe==ct;if(zt&&Dn(w)){if(!Dn(C))return!1;ft=!0,Nt=!1}if(zt&&!Nt)return Ce||(Ce=new Mr),ft||Fs(w)?cn(w,C,Q,de,at,Ce):la(w,C,Xe,Q,de,at,Ce);if(!(Q&a)){var dt=Nt&&Pe.call(w,"__wrapped__"),tr=hr&&Pe.call(C,"__wrapped__");if(dt||tr){var jr=dt?w.value():w,Or=tr?C.value():C;return Ce||(Ce=new Mr),at(jr,Or,Q,de,Ce)}}return zt?(Ce||(Ce=new Mr),Os(w,C,Q,de,at,Ce)):!1}function ha(w){if(!Ds(w)||Cs(w))return!1;var C=ln(w)?et:ie;return C.test(si(w))}function Is(w){return Fi(w)&&$s(w.length)&&!!he[$i(w)]}function xs(w){if(!Rs(w))return Ui(w);var C=[];for(var Q in Object(w))Pe.call(w,Q)&&Q!="constructor"&&C.push(Q);return C}function cn(w,C,Q,de,at,Ce){var ft=Q&a,qt=w.length,Xe=C.length;if(qt!=Xe&&!(ft&&Xe>qt))return!1;var ct=Ce.get(w);if(ct&&Ce.get(C))return ct==C;var Nt=-1,hr=!0,zt=Q&l?new an:void 0;for(Ce.set(w,C),Ce.set(C,w);++Nt<qt;){var dt=w[Nt],tr=C[Nt];if(de)var jr=ft?de(tr,dt,Nt,C,w,Ce):de(dt,tr,Nt,w,C,Ce);if(jr!==void 0){if(jr)continue;hr=!1;break}if(zt){if(!Fe(C,function(Or,Yr){if(!je(zt,Yr)&&(dt===Or||at(dt,Or,Q,de,Ce)))return zt.push(Yr)})){hr=!1;break}}else if(!(dt===tr||at(dt,tr,Q,de,Ce))){hr=!1;break}}return Ce.delete(w),Ce.delete(C),hr}function la(w,C,Q,de,at,Ce,ft){switch(Q){case ce:if(w.byteLength!=C.byteLength||w.byteOffset!=C.byteOffset)return!1;w=w.buffer,C=C.buffer;case se:return!(w.byteLength!=C.byteLength||!Ce(new Zt(w),new Zt(C)));case x:case $:case K:return Us(+w,+C);case j:return w.name==C.name&&w.message==C.message;case P:case u:return w==C+"";case B:var qt=Ue;case m:var Xe=de&a;if(qt||(qt=qe),w.size!=C.size&&!Xe)return!1;var ct=ft.get(w);if(ct)return ct==C;de|=l,ft.set(w,C);var Nt=cn(qt(w),qt(C),de,at,Ce,ft);return ft.delete(w),Nt;case _:if(Ot)return Ot.call(w)==Ot.call(C)}return!1}function Os(w,C,Q,de,at,Ce){var ft=Q&a,qt=un(w),Xe=qt.length,ct=un(C),Nt=ct.length;if(Xe!=Nt&&!ft)return!1;for(var hr=Xe;hr--;){var zt=qt[hr];if(!(ft?zt in C:Pe.call(C,zt)))return!1}var dt=Ce.get(w);if(dt&&Ce.get(C))return dt==C;var tr=!0;Ce.set(w,C),Ce.set(C,w);for(var jr=ft;++hr<Xe;){zt=qt[hr];var Or=w[zt],Yr=C[zt];if(de)var Fn=ft?de(Yr,Or,zt,C,w,Ce):de(Or,Yr,zt,w,C,Ce);if(!(Fn===void 0?Or===Yr||at(Or,Yr,Q,de,Ce):Fn)){tr=!1;break}jr||(jr=zt=="constructor")}if(tr&&!jr){var Mi=w.constructor,kt=C.constructor;Mi!=kt&&"constructor"in w&&"constructor"in C&&!(typeof Mi=="function"&&Mi instanceof Mi&&typeof kt=="function"&&kt instanceof kt)&&(tr=!1)}return Ce.delete(w),Ce.delete(C),tr}function un(w){return Ln(w,ga,As)}function yi(w,C){var Q=w.__data__;return Ns(C)?Q[typeof C=="string"?"string":"hash"]:Q.map}function _r(w,C){var Q=xe(w,C);return ha(Q)?Q:void 0}function Ps(w){var C=Pe.call(w,er),Q=w[er];try{w[er]=void 0;var de=!0}catch{}var at=Ge.call(w);return de&&(C?w[er]=Q:delete w[er]),at}var As=ii?function(w){return w==null?[]:(w=Object(w),He(ii(w),function(C){return ur.call(w,C)}))}:ot,Gr=$i;(bt&&Gr(new bt(new ArrayBuffer(1)))!=ce||vt&&Gr(new vt)!=B||Et&&Gr(Et.resolve())!=D||St&&Gr(new St)!=m||mt&&Gr(new mt)!=V)&&(Gr=function(w){var C=$i(w),Q=C==T?w.constructor:void 0,de=Q?si(Q):"";if(de)switch(de){case $t:return ce;case Dt:return B;case It:return D;case Ft:return m;case xt:return V}return C});function Ts(w,C){return C=C??p,!!C&&(typeof w=="number"||we.test(w))&&w>-1&&w%1==0&&w<C}function Ns(w){var C=typeof w;return C=="string"||C=="number"||C=="symbol"||C=="boolean"?w!=="__proto__":w===null}function Cs(w){return!!Ve&&Ve in w}function Rs(w){var C=w&&w.constructor,Q=typeof C=="function"&&C.prototype||Se;return w===Q}function fa(w){return Ge.call(w)}function si(w){if(w!=null){try{return Be.call(w)}catch{}try{return w+""}catch{}}return""}function Us(w,C){return w===C||w!==w&&C!==C}var Ls=$n(function(){return arguments}())?$n:function(w){return Fi(w)&&Pe.call(w,"callee")&&!ur.call(w,"callee")},hn=Array.isArray;function da(w){return w!=null&&$s(w.length)&&!ln(w)}var Dn=vi||st;function pa(w,C){return Di(w,C)}function ln(w){if(!Ds(w))return!1;var C=$i(w);return C==U||C==z||C==b||C==S}function $s(w){return typeof w=="number"&&w>-1&&w%1==0&&w<=p}function Ds(w){var C=typeof w;return w!=null&&(C=="object"||C=="function")}function Fi(w){return w!=null&&typeof w=="object"}var Fs=Ie?gt(Ie):Is;function ga(w){return da(w)?Es(w):xs(w)}function ot(){return[]}function st(){return!1}n.exports=pa})(Do,Do.exports);var bE=Do.exports;const EE=M_(bE);function SE(n,t){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var a=0;a<n.length;a++){var l=n.charAt(a),p=l.charCodeAt(0);if(r[p]!==255)throw new TypeError(l+" is ambiguous");r[p]=a}var d=n.length,v=n.charAt(0),b=Math.log(d)/Math.log(256),x=Math.log(256)/Math.log(d);function $(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(z.length===0)return"";for(var B=0,K=0,oe=0,T=z.length;oe!==T&&z[oe]===0;)oe++,B++;for(var D=(T-oe)*x+1>>>0,S=new Uint8Array(D);oe!==T;){for(var P=z[oe],m=0,u=D-1;(P!==0||m<K)&&u!==-1;u--,m++)P+=256*S[u]>>>0,S[u]=P%d>>>0,P=P/d>>>0;if(P!==0)throw new Error("Non-zero carry");K=m,oe++}for(var _=D-K;_!==D&&S[_]===0;)_++;for(var W=v.repeat(B);_<D;++_)W+=n.charAt(S[_]);return W}function j(z){if(typeof z!="string")throw new TypeError("Expected String");if(z.length===0)return new Uint8Array;var B=0;if(z[B]!==" "){for(var K=0,oe=0;z[B]===v;)K++,B++;for(var T=(z.length-B)*b+1>>>0,D=new Uint8Array(T);z[B];){var S=r[z.charCodeAt(B)];if(S===255)return;for(var P=0,m=T-1;(S!==0||P<oe)&&m!==-1;m--,P++)S+=d*D[m]>>>0,D[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");oe=P,B++}if(z[B]!==" "){for(var u=T-oe;u!==T&&D[u]===0;)u++;for(var _=new Uint8Array(K+(T-u)),W=K;u!==T;)_[W++]=D[u++];return _}}}function U(z){var B=j(z);if(B)return B;throw new Error(`Non-${t} character`)}return{encode:$,decodeUnsafe:j,decode:U}}var IE=SE,xE=IE;const Fd=n=>{if(n instanceof Uint8Array&&n.constructor.name==="Uint8Array")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")},OE=n=>new TextEncoder().encode(n),PE=n=>new TextDecoder().decode(n);class AE{constructor(t,r,s){this.name=t,this.prefix=r,this.baseEncode=s}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class TE{constructor(t,r,s){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=s}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Md(this,t)}}class NE{constructor(t){this.decoders=t}or(t){return Md(this,t)}decode(t){const r=t[0],s=this.decoders[r];if(s)return s.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Md=(n,t)=>new NE({...n.decoders||{[n.prefix]:n},...t.decoders||{[t.prefix]:t}});class CE{constructor(t,r,s,a){this.name=t,this.prefix=r,this.baseEncode=s,this.baseDecode=a,this.encoder=new AE(t,r,s),this.decoder=new TE(t,r,a)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const Wo=({name:n,prefix:t,encode:r,decode:s})=>new CE(n,t,r,s),_s=({prefix:n,name:t,alphabet:r})=>{const{encode:s,decode:a}=xE(r,t);return Wo({prefix:n,name:t,encode:s,decode:l=>Fd(a(l))})},RE=(n,t,r,s)=>{const a={};for(let x=0;x<t.length;++x)a[t[x]]=x;let l=n.length;for(;n[l-1]==="=";)--l;const p=new Uint8Array(l*r/8|0);let d=0,v=0,b=0;for(let x=0;x<l;++x){const $=a[n[x]];if($===void 0)throw new SyntaxError(`Non-${s} character`);v=v<<r|$,d+=r,d>=8&&(d-=8,p[b++]=255&v>>d)}if(d>=r||255&v<<8-d)throw new SyntaxError("Unexpected end of data");return p},UE=(n,t,r)=>{const s=t[t.length-1]==="=",a=(1<<r)-1;let l="",p=0,d=0;for(let v=0;v<n.length;++v)for(d=d<<8|n[v],p+=8;p>r;)p-=r,l+=t[a&d>>p];if(p&&(l+=t[a&d<<r-p]),s)for(;l.length*r&7;)l+="=";return l},Yt=({name:n,prefix:t,bitsPerChar:r,alphabet:s})=>Wo({prefix:t,name:n,encode(a){return UE(a,s,r)},decode(a){return RE(a,s,r,n)}}),LE=Wo({prefix:"\0",name:"identity",encode:n=>PE(n),decode:n=>OE(n)});var $E=Object.freeze({__proto__:null,identity:LE});const DE=Yt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var FE=Object.freeze({__proto__:null,base2:DE});const ME=Yt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jE=Object.freeze({__proto__:null,base8:ME});const qE=_s({prefix:"9",name:"base10",alphabet:"0123456789"});var zE=Object.freeze({__proto__:null,base10:qE});const HE=Yt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),BE=Yt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var KE=Object.freeze({__proto__:null,base16:HE,base16upper:BE});const kE=Yt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),VE=Yt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),WE=Yt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),GE=Yt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),YE=Yt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),JE=Yt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),XE=Yt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),QE=Yt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ZE=Yt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var e6=Object.freeze({__proto__:null,base32:kE,base32upper:VE,base32pad:WE,base32padupper:GE,base32hex:YE,base32hexupper:JE,base32hexpad:XE,base32hexpadupper:QE,base32z:ZE});const t6=_s({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),r6=_s({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var i6=Object.freeze({__proto__:null,base36:t6,base36upper:r6});const n6=_s({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),s6=_s({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var o6=Object.freeze({__proto__:null,base58btc:n6,base58flickr:s6});const a6=Yt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c6=Yt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),u6=Yt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),h6=Yt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var l6=Object.freeze({__proto__:null,base64:a6,base64pad:c6,base64url:u6,base64urlpad:h6});const jd=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),f6=jd.reduce((n,t,r)=>(n[r]=t,n),[]),d6=jd.reduce((n,t,r)=>(n[t.codePointAt(0)]=r,n),[]);function p6(n){return n.reduce((t,r)=>(t+=f6[r],t),"")}function g6(n){const t=[];for(const r of n){const s=d6[r.codePointAt(0)];if(s===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(s)}return new Uint8Array(t)}const v6=Wo({prefix:"🚀",name:"base256emoji",encode:p6,decode:g6});var y6=Object.freeze({__proto__:null,base256emoji:v6}),_6=qd,wf=128,m6=127,w6=~m6,b6=Math.pow(2,31);function qd(n,t,r){t=t||[],r=r||0;for(var s=r;n>=b6;)t[r++]=n&255|wf,n/=128;for(;n&w6;)t[r++]=n&255|wf,n>>>=7;return t[r]=n|0,qd.bytes=r-s+1,t}var E6=Yc,S6=128,bf=127;function Yc(n,s){var r=0,s=s||0,a=0,l=s,p,d=n.length;do{if(l>=d)throw Yc.bytes=0,new RangeError("Could not decode varint");p=n[l++],r+=a<28?(p&bf)<<a:(p&bf)*Math.pow(2,a),a+=7}while(p>=S6);return Yc.bytes=l-s,r}var I6=Math.pow(2,7),x6=Math.pow(2,14),O6=Math.pow(2,21),P6=Math.pow(2,28),A6=Math.pow(2,35),T6=Math.pow(2,42),N6=Math.pow(2,49),C6=Math.pow(2,56),R6=Math.pow(2,63),U6=function(n){return n<I6?1:n<x6?2:n<O6?3:n<P6?4:n<A6?5:n<T6?6:n<N6?7:n<C6?8:n<R6?9:10},L6={encode:_6,decode:E6,encodingLength:U6},zd=L6;const Ef=(n,t,r=0)=>(zd.encode(n,t,r),t),Sf=n=>zd.encodingLength(n),Jc=(n,t)=>{const r=t.byteLength,s=Sf(n),a=s+Sf(r),l=new Uint8Array(a+r);return Ef(n,l,0),Ef(r,l,s),l.set(t,a),new $6(n,r,t,l)};class $6{constructor(t,r,s,a){this.code=t,this.size=r,this.digest=s,this.bytes=a}}const Hd=({name:n,code:t,encode:r})=>new D6(n,t,r);class D6{constructor(t,r,s){this.name=t,this.code=r,this.encode=s}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?Jc(this.code,r):r.then(s=>Jc(this.code,s))}else throw Error("Unknown type, must be binary type")}}const Bd=n=>async t=>new Uint8Array(await crypto.subtle.digest(n,t)),F6=Hd({name:"sha2-256",code:18,encode:Bd("SHA-256")}),M6=Hd({name:"sha2-512",code:19,encode:Bd("SHA-512")});var j6=Object.freeze({__proto__:null,sha256:F6,sha512:M6});const Kd=0,q6="identity",kd=Fd,z6=n=>Jc(Kd,kd(n)),H6={code:Kd,name:q6,encode:kd,digest:z6};var B6=Object.freeze({__proto__:null,identity:H6});new TextEncoder,new TextDecoder;const If={...$E,...FE,...jE,...zE,...KE,...e6,...i6,...o6,...l6,...y6};({...j6,...B6});function Vd(n){return globalThis.Buffer!=null?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n}function K6(n=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Vd(globalThis.Buffer.allocUnsafe(n)):new Uint8Array(n)}function Wd(n,t,r,s){return{name:n,prefix:t,encoder:{name:n,prefix:t,encode:r},decoder:{decode:s}}}const xf=Wd("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>new TextEncoder().encode(n.substring(1))),Nc=Wd("ascii","a",n=>{let t="a";for(let r=0;r<n.length;r++)t+=String.fromCharCode(n[r]);return t},n=>{n=n.substring(1);const t=K6(n.length);for(let r=0;r<n.length;r++)t[r]=n.charCodeAt(r);return t}),k6={utf8:xf,"utf-8":xf,hex:If.base16,latin1:Nc,ascii:Nc,binary:Nc,...If};function V6(n,t="utf8"){const r=k6[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Vd(globalThis.Buffer.from(n,"utf-8")):r.decoder.decode(`${r.prefix}${n}`)}const Gd="wc",W6=2,mu="core",Ti=`${Gd}@2:${mu}:`,G6={name:mu,logger:"error"},Y6={database:":memory:"},J6="crypto",Of="client_ed25519_seed",X6=ve.ONE_DAY,Q6="keychain",Z6="0.3",e2="messages",t2="0.3",r2=ve.SIX_HOURS,i2="publisher",Yd="irn",n2="error",Jd="wss://relay.walletconnect.com",Pf="wss://relay.walletconnect.org",s2="relayer",At={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},o2="_subscription",os={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},a2=ve.ONE_SECOND/2,c2="2.9.2",u2=1e4,h2="0.3",l2="WALLETCONNECT_CLIENT_ID",ti={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},f2="subscription",d2="0.3",p2=ve.FIVE_SECONDS*1e3,g2="pairing",v2="0.3",as={wc_pairingDelete:{req:{ttl:ve.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ve.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ve.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ve.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ve.ONE_DAY,prompt:!1,tag:0},res:{ttl:ve.ONE_DAY,prompt:!1,tag:0}}},ei={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},y2="history",_2="0.3",m2="expirer",$r={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},w2="0.3",Cc="verify-api",Af="https://verify.walletconnect.com";class b2{constructor(t,r){this.core=t,this.logger=r,this.keychain=new Map,this.name=Q6,this.version=Z6,this.initialized=!1,this.storagePrefix=Ti,this.init=async()=>{if(!this.initialized){const s=await this.getKeyChain();typeof s<"u"&&(this.keychain=s),this.initialized=!0}},this.has=s=>(this.isInitialized(),this.keychain.has(s)),this.set=async(s,a)=>{this.isInitialized(),this.keychain.set(s,a),await this.persist()},this.get=s=>{this.isInitialized();const a=this.keychain.get(s);if(typeof a>"u"){const{message:l}=ue("NO_MATCHING_KEY",`${this.name}: ${s}`);throw new Error(l)}return a},this.del=async s=>{this.isInitialized(),this.keychain.delete(s),await this.persist()},this.core=t,this.logger=Ze.generateChildLogger(r,this.name)}get context(){return Ze.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,Sd(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Id(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}}class E2{constructor(t,r,s){this.core=t,this.logger=r,this.name=J6,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=a=>(this.isInitialized(),this.keychain.has(a)),this.getClientId=async()=>{this.isInitialized();const a=await this.getClientSeed(),l=vf(a);return Dd(l.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const a=mw();return this.setPrivateKey(a.publicKey,a.privateKey)},this.signJWT=async a=>{this.isInitialized();const l=await this.getClientSeed(),p=vf(l),d=Wc();return await gE(d,a,X6,p)},this.generateSharedKey=(a,l,p)=>{this.isInitialized();const d=this.getPrivateKey(a),v=ww(d,l);return this.setSymKey(v,p)},this.setSymKey=async(a,l)=>{this.isInitialized();const p=l||bw(a);return await this.keychain.set(p,a),p},this.deleteKeyPair=async a=>{this.isInitialized(),await this.keychain.del(a)},this.deleteSymKey=async a=>{this.isInitialized(),await this.keychain.del(a)},this.encode=async(a,l,p)=>{this.isInitialized();const d=bd(p),v=ps(l);if(Kl(d)){const j=d.senderPublicKey,U=d.receiverPublicKey;a=await this.generateSharedKey(j,U)}const b=this.getSymKey(a),{type:x,senderPublicKey:$}=d;return Sw({type:x,symKey:b,message:v,senderPublicKey:$})},this.decode=async(a,l,p)=>{this.isInitialized();const d=Ow(l,p);if(Kl(d)){const v=d.receiverPublicKey,b=d.senderPublicKey;a=await this.generateSharedKey(v,b)}try{const v=this.getSymKey(a),b=Iw({symKey:v,encoded:l});return yu(b)}catch(v){this.logger.error(`Failed to decode message from topic: '${a}', clientId: '${await this.getClientId()}'`),this.logger.error(v)}},this.getPayloadType=a=>{const l=Ro(a);return vs(l.type)},this.getPayloadSenderPublicKey=a=>{const l=Ro(a);return l.senderPublicKey?cr(l.senderPublicKey,ar):void 0},this.core=t,this.logger=Ze.generateChildLogger(r,this.name),this.keychain=s||new b2(this.core,this.logger)}get context(){return Ze.getLoggerContext(this.logger)}async setPrivateKey(t,r){return await this.keychain.set(t,r),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(Of)}catch{t=Wc(),await this.keychain.set(Of,t)}return V6(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}}class S2 extends kb{constructor(t,r){super(t,r),this.logger=t,this.core=r,this.messages=new Map,this.name=e2,this.version=t2,this.initialized=!1,this.storagePrefix=Ti,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const s=await this.getRelayerMessages();typeof s<"u"&&(this.messages=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(s){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(s)}finally{this.initialized=!0}}},this.set=async(s,a)=>{this.isInitialized();const l=An(a);let p=this.messages.get(s);return typeof p>"u"&&(p={}),typeof p[l]<"u"||(p[l]=a,this.messages.set(s,p),await this.persist()),l},this.get=s=>{this.isInitialized();let a=this.messages.get(s);return typeof a>"u"&&(a={}),a},this.has=(s,a)=>{this.isInitialized();const l=this.get(s),p=An(a);return typeof l[p]<"u"},this.del=async s=>{this.isInitialized(),this.messages.delete(s),await this.persist()},this.logger=Ze.generateChildLogger(t,this.name),this.core=r}get context(){return Ze.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,Sd(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Id(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}}class I2 extends Vb{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new Fr.EventEmitter,this.name=i2,this.queue=new Map,this.publishTimeout=ve.toMiliseconds(ve.TEN_SECONDS),this.queueTimeout=ve.toMiliseconds(ve.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(s,a,l)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:a,opts:l}});try{const p=(l==null?void 0:l.ttl)||r2,d=Gc(l),v=(l==null?void 0:l.prompt)||!1,b=(l==null?void 0:l.tag)||0,x=(l==null?void 0:l.id)||ru().toString(),$={topic:s,message:a,opts:{ttl:p,relay:d,prompt:v,tag:b,id:x}},j=setTimeout(()=>this.queue.set(x,$),this.queueTimeout);try{await await Uo(this.rpcPublish(s,a,p,d,v,b,x),this.publishTimeout),clearTimeout(j),this.relayer.events.emit(At.publish,$)}catch{this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0;return}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:a,opts:l}})}catch(p){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(p),p}},this.on=(s,a)=>{this.events.on(s,a)},this.once=(s,a)=>{this.events.once(s,a)},this.off=(s,a)=>{this.events.off(s,a)},this.removeListener=(s,a)=>{this.events.removeListener(s,a)},this.relayer=t,this.logger=Ze.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Ze.getLoggerContext(this.logger)}rpcPublish(t,r,s,a,l,p,d){var v,b,x,$;const j={method:Po(a.protocol).publish,params:{topic:t,message:r,ttl:s,prompt:l,tag:p},id:d};return or((v=j.params)==null?void 0:v.prompt)&&((b=j.params)==null||delete b.prompt),or((x=j.params)==null?void 0:x.tag)&&(($=j.params)==null||delete $.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:j}),this.relayer.request(j)}onPublish(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:r,message:s,opts:a}=t;await this.publish(r,s,a)})}registerEventListeners(){this.relayer.core.heartbeat.on(Un.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(At.connection_stalled);return}this.checkQueue()}),this.relayer.on(At.message_ack,t=>{this.onPublish(t.id.toString())})}}class x2{constructor(){this.map=new Map,this.set=(t,r)=>{const s=this.get(t);this.exists(t,r)||this.map.set(t,[...s,r])},this.get=t=>this.map.get(t)||[],this.exists=(t,r)=>this.get(t).includes(r),this.delete=(t,r)=>{if(typeof r>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const s=this.get(t);if(!this.exists(t,r))return;const a=s.filter(l=>l!==r);if(!a.length){this.map.delete(t);return}this.map.set(t,a)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var O2=Object.defineProperty,P2=Object.defineProperties,A2=Object.getOwnPropertyDescriptors,Tf=Object.getOwnPropertySymbols,T2=Object.prototype.hasOwnProperty,N2=Object.prototype.propertyIsEnumerable,Nf=(n,t,r)=>t in n?O2(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,cs=(n,t)=>{for(var r in t||(t={}))T2.call(t,r)&&Nf(n,r,t[r]);if(Tf)for(var r of Tf(t))N2.call(t,r)&&Nf(n,r,t[r]);return n},Rc=(n,t)=>P2(n,A2(t));class C2 extends Yb{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new x2,this.events=new Fr.EventEmitter,this.name=f2,this.version=d2,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Ti,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(s,a)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:a}});try{const l=Gc(a),p={topic:s,relay:l};this.pending.set(s,p);const d=await this.rpcSubscribe(s,l);return this.onSubscribe(d,p),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:a}}),d}catch(l){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(l),l}},this.unsubscribe=async(s,a)=>{await this.restartToComplete(),this.isInitialized(),typeof(a==null?void 0:a.id)<"u"?await this.unsubscribeById(s,a.id,a):await this.unsubscribeByTopic(s,a)},this.isSubscribed=async s=>this.topics.includes(s)?!0:await new Promise((a,l)=>{const p=new ve.Watch;p.start(this.pendingSubscriptionWatchLabel);const d=setInterval(()=>{!this.pending.has(s)&&this.topics.includes(s)&&(clearInterval(d),p.stop(this.pendingSubscriptionWatchLabel),a(!0)),p.elapsed(this.pendingSubscriptionWatchLabel)>=p2&&(clearInterval(d),p.stop(this.pendingSubscriptionWatchLabel),l(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(s,a)=>{this.events.on(s,a)},this.once=(s,a)=>{this.events.once(s,a)},this.off=(s,a)=>{this.events.off(s,a)},this.removeListener=(s,a)=>{this.events.removeListener(s,a)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=Ze.generateChildLogger(r,this.name),this.clientId=""}get context(){return Ze.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,r){let s=!1;try{s=this.getSubscription(t).topic===r}catch{}return s}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,r){const s=this.topicMap.get(t);await Promise.all(s.map(async a=>await this.unsubscribeById(t,a,r)))}async unsubscribeById(t,r,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:s}});try{const a=Gc(s);await this.rpcUnsubscribe(t,r,a);const l=Ut("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,r,l),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:s}})}catch(a){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(a),a}}async rpcSubscribe(t,r){const s={method:Po(r.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await Uo(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(At.connection_stalled)}return An(t+this.clientId)}async rpcBatchSubscribe(t){if(!t.length)return;const r=t[0].relay,s={method:Po(r.protocol).batchSubscribe,params:{topics:t.map(a=>a.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{return await await Uo(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(At.connection_stalled)}}rpcUnsubscribe(t,r,s){const a={method:Po(s.protocol).unsubscribe,params:{topic:t,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:a}),this.relayer.request(a)}onSubscribe(t,r){this.setSubscription(t,Rc(cs({},r),{id:t})),this.pending.delete(r.topic)}onBatchSubscribe(t){t.length&&t.forEach(r=>{this.setSubscription(r.id,cs({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(t,r,s){this.events.removeAllListeners(r),this.hasSubscription(r,t)&&this.deleteSubscription(r,s),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,r){this.subscriptions.has(t)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:r}),this.addSubscription(t,r))}addSubscription(t,r){this.subscriptions.set(t,cs({},r)),this.topicMap.set(r.topic,t),this.events.emit(ti.created,r)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const r=this.subscriptions.get(t);if(!r){const{message:s}=ue("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(s)}return r}deleteSubscription(t,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:r});const s=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(s.topic,t),this.events.emit(ti.deleted,Rc(cs({},s),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ti.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){const s=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(ti.resubscribed)}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:r}=ue("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const r=await this.rpcBatchSubscribe(t);ri(r)&&this.onBatchSubscribe(r.map((s,a)=>Rc(cs({},t[a]),{id:s})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const t=[];this.pending.forEach(r=>{t.push(r)}),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(Un.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(At.connect,async()=>{await this.onConnect()}),this.relayer.on(At.disconnect,()=>{this.onDisconnect()}),this.events.on(ti.created,async t=>{const r=ti.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()}),this.events.on(ti.deleted,async t=>{const r=ti.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),t())},this.pollingInterval)})}}var R2=Object.defineProperty,Cf=Object.getOwnPropertySymbols,U2=Object.prototype.hasOwnProperty,L2=Object.prototype.propertyIsEnumerable,Rf=(n,t,r)=>t in n?R2(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,$2=(n,t)=>{for(var r in t||(t={}))U2.call(t,r)&&Rf(n,r,t[r]);if(Cf)for(var r of Cf(t))L2.call(t,r)&&Rf(n,r,t[r]);return n};class D2 extends Wb{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new Fr.EventEmitter,this.name=s2,this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async r=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(r)}catch(s){throw this.logger.debug("Failed to Publish Request"),this.logger.error(s),s}},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?Ze.generateChildLogger(t.logger,this.name):Ze.pino(Ze.getDefaultLoggerOptions({level:t.logger||n2})),this.messages=new S2(this.logger,t.core),this.subscriber=new C2(this,this.logger),this.publisher=new I2(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||Jd,this.projectId=t.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${Pf}...`),await this.restartTransport(Pf)}this.registerEventListeners(),this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},u2)}get context(){return Ze.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(t,r,s){this.isInitialized(),await this.publisher.publish(t,r,s),await this.recordMessageEvent({topic:t,message:r,publishedAt:Date.now()})}async subscribe(t,r){var s;this.isInitialized();let a=((s=this.subscriber.topicMap.get(t))==null?void 0:s[0])||"";return a||(await Promise.all([new Promise(l=>{this.subscriber.once(ti.created,p=>{p.topic===t&&l()})}),new Promise(async l=>{a=await this.subscriber.subscribe(t,r),l()})]),a)}async unsubscribe(t,r){this.isInitialized(),await this.subscriber.unsubscribe(t,r)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit(At.transport_closed))}async transportOpen(t){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=t||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise(r=>{this.initialized||r(),this.subscriber.once(ti.resubscribed,()=>{r()})}),await Promise.race([new Promise(async(r,s)=>{await Uo(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(a=>s(a)).then(()=>r()).finally(()=>this.removeListener(At.transport_closed,this.rejectTransportOpen))}),new Promise(r=>this.once(At.transport_closed,this.rejectTransportOpen))])])}catch(r){this.logger.error(r);const s=r;if(!this.isConnectionStalled(s.message))throw r;this.events.emit(At.transport_closed)}finally{this.reconnecting=!1}}}async restartTransport(t){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=t||this.relayUrl,this.connected&&await Promise.all([new Promise(r=>{this.provider.once(os.disconnect,()=>{r()})}),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(t){return this.staleConnectionErrors.some(r=>t.includes(r))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ci(new wE(Fw({sdkVersion:c2,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:r,message:s}=t;await this.messages.set(r,s)}async shouldIgnoreMessageEvent(t){const{topic:r,message:s}=t;if(!s||s.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const a=this.messages.has(r,s);return a&&this.logger.debug(`Ignoring duplicate message: ${s}`),a}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),nu(t)){if(!t.method.endsWith(o2))return;const r=t.params,{topic:s,message:a,publishedAt:l}=r.data,p={topic:s,message:a,publishedAt:l};this.logger.debug("Emitting Relayer Payload"),this.logger.trace($2({type:"event",event:r.id},p)),this.events.emit(r.id,p),await this.acknowledgePayload(t),await this.onMessageEvent(p)}else qo(t)&&this.events.emit(At.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(At.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const r=iu(t.id,!0);await this.provider.connection.send(r)}registerProviderListeners(){this.provider.on(os.payload,t=>this.onProviderPayload(t)),this.provider.on(os.connect,()=>{this.events.emit(At.connect)}),this.provider.on(os.disconnect,()=>{this.onProviderDisconnect()}),this.provider.on(os.error,t=>{this.logger.error(t),this.events.emit(At.error,t)})}registerEventListeners(){this.events.on(At.connection_stalled,async()=>{await this.restartTransport()})}onProviderDisconnect(){this.events.emit(At.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout(async()=>{await this.restartTransport()},ve.toMiliseconds(a2))}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise(t=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),t())},this.connectionStatusPollingInterval)});await this.restartTransport()}}}var F2=Object.defineProperty,Uf=Object.getOwnPropertySymbols,M2=Object.prototype.hasOwnProperty,j2=Object.prototype.propertyIsEnumerable,Lf=(n,t,r)=>t in n?F2(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,$f=(n,t)=>{for(var r in t||(t={}))M2.call(t,r)&&Lf(n,r,t[r]);if(Uf)for(var r of Uf(t))j2.call(t,r)&&Lf(n,r,t[r]);return n};class Go extends Gb{constructor(t,r,s,a=Ti,l=void 0){super(t,r,s,a),this.core=t,this.logger=r,this.name=s,this.map=new Map,this.version=h2,this.cached=[],this.initialized=!1,this.storagePrefix=Ti,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(p=>{this.getKey&&p!==null&&!or(p)?this.map.set(this.getKey(p),p):ob(p)?this.map.set(p.id,p):ab(p)&&this.map.set(p.topic,p)}),this.cached=[],this.initialized=!0)},this.set=async(p,d)=>{this.isInitialized(),this.map.has(p)?await this.update(p,d):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:p,value:d}),this.map.set(p,d),await this.persist())},this.get=p=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:p}),this.getData(p)),this.getAll=p=>(this.isInitialized(),p?this.values.filter(d=>Object.keys(p).every(v=>EE(d[v],p[v]))):this.values),this.update=async(p,d)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:p,update:d});const v=$f($f({},this.getData(p)),d);this.map.set(p,v),await this.persist()},this.delete=async(p,d)=>{this.isInitialized(),this.map.has(p)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:p,reason:d}),this.map.delete(p),await this.persist())},this.logger=Ze.generateChildLogger(r,this.name),this.storagePrefix=a,this.getKey=l}get context(){return Ze.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const r=this.map.get(t);if(!r){const{message:s}=ue("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:r}=ue("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}}class q2{constructor(t,r){this.core=t,this.logger=r,this.name=g2,this.version=v2,this.events=new tu,this.initialized=!1,this.storagePrefix=Ti,this.ignoredPayloadTypes=[tn],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:s})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...s])]},this.create=async()=>{this.isInitialized();const s=Wc(),a=await this.core.crypto.setSymKey(s),l=kr(ve.FIVE_MINUTES),p={protocol:Yd},d={topic:a,expiry:l,relay:p,active:!1},v=Jw({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:s,relay:p});return await this.pairings.set(a,d),await this.core.relayer.subscribe(a),this.core.expirer.set(a,l),{topic:a,uri:v}},this.pair=async s=>{this.isInitialized(),this.isValidPair(s);const{topic:a,symKey:l,relay:p}=Ww(s.uri);if(this.pairings.keys.includes(a))throw new Error(`Pairing already exists: ${a}`);if(this.core.crypto.hasKeys(a))throw new Error(`Keychain already exists: ${a}`);const d=kr(ve.FIVE_MINUTES),v={topic:a,relay:p,expiry:d,active:!1};return await this.pairings.set(a,v),await this.core.crypto.setSymKey(l,a),await this.core.relayer.subscribe(a,{relay:p}),this.core.expirer.set(a,d),s.activatePairing&&await this.activate({topic:a}),v},this.activate=async({topic:s})=>{this.isInitialized();const a=kr(ve.THIRTY_DAYS);await this.pairings.update(s,{active:!0,expiry:a}),this.core.expirer.set(s,a)},this.ping=async s=>{this.isInitialized(),await this.isValidPing(s);const{topic:a}=s;if(this.pairings.keys.includes(a)){const l=await this.sendRequest(a,"wc_pairingPing",{}),{done:p,resolve:d,reject:v}=On();this.events.once(Ht("pairing_ping",l),({error:b})=>{b?v(b):d()}),await p()}},this.updateExpiry=async({topic:s,expiry:a})=>{this.isInitialized(),await this.pairings.update(s,{expiry:a})},this.updateMetadata=async({topic:s,metadata:a})=>{this.isInitialized(),await this.pairings.update(s,{peerMetadata:a})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async s=>{this.isInitialized(),await this.isValidDisconnect(s);const{topic:a}=s;this.pairings.keys.includes(a)&&(await this.sendRequest(a,"wc_pairingDelete",Ut("USER_DISCONNECTED")),await this.deletePairing(a))},this.sendRequest=async(s,a,l)=>{const p=Mo(a,l),d=await this.core.crypto.encode(s,p),v=as[a].req;return this.core.history.set(s,p),this.core.relayer.publish(s,d,v),p.id},this.sendResult=async(s,a,l)=>{const p=iu(s,l),d=await this.core.crypto.encode(a,p),v=await this.core.history.get(a,s),b=as[v.request.method].res;await this.core.relayer.publish(a,d,b),await this.core.history.resolve(p)},this.sendError=async(s,a,l)=>{const p=jo(s,l),d=await this.core.crypto.encode(a,p),v=await this.core.history.get(a,s),b=as[v.request.method]?as[v.request.method].res:as.unregistered_method.res;await this.core.relayer.publish(a,d,b),await this.core.history.resolve(p)},this.deletePairing=async(s,a)=>{await this.core.relayer.unsubscribe(s),await Promise.all([this.pairings.delete(s,Ut("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(s),a?Promise.resolve():this.core.expirer.del(s)])},this.cleanup=async()=>{const s=this.pairings.getAll().filter(a=>Pi(a.expiry));await Promise.all(s.map(a=>this.deletePairing(a.topic)))},this.onRelayEventRequest=s=>{const{topic:a,payload:l}=s;switch(l.method){case"wc_pairingPing":return this.onPairingPingRequest(a,l);case"wc_pairingDelete":return this.onPairingDeleteRequest(a,l);default:return this.onUnknownRpcMethodRequest(a,l)}},this.onRelayEventResponse=async s=>{const{topic:a,payload:l}=s,p=(await this.core.history.get(a,l.id)).request.method;switch(p){case"wc_pairingPing":return this.onPairingPingResponse(a,l);default:return this.onUnknownRpcMethodResponse(p)}},this.onPairingPingRequest=async(s,a)=>{const{id:l}=a;try{this.isValidPing({topic:s}),await this.sendResult(l,s,!0),this.events.emit("pairing_ping",{id:l,topic:s})}catch(p){await this.sendError(l,s,p),this.logger.error(p)}},this.onPairingPingResponse=(s,a)=>{const{id:l}=a;setTimeout(()=>{gi(a)?this.events.emit(Ht("pairing_ping",l),{}):Kr(a)&&this.events.emit(Ht("pairing_ping",l),{error:a.error})},500)},this.onPairingDeleteRequest=async(s,a)=>{const{id:l}=a;try{this.isValidDisconnect({topic:s}),await this.deletePairing(s),this.events.emit("pairing_delete",{id:l,topic:s})}catch(p){await this.sendError(l,s,p),this.logger.error(p)}},this.onUnknownRpcMethodRequest=async(s,a)=>{const{id:l,method:p}=a;try{if(this.registeredMethods.includes(p))return;const d=Ut("WC_METHOD_UNSUPPORTED",p);await this.sendError(l,s,d),this.logger.error(d)}catch(d){await this.sendError(l,s,d),this.logger.error(d)}},this.onUnknownRpcMethodResponse=s=>{this.registeredMethods.includes(s)||this.logger.error(Ut("WC_METHOD_UNSUPPORTED",s))},this.isValidPair=s=>{if(!gr(s)){const{message:a}=ue("MISSING_OR_INVALID",`pair() params: ${s}`);throw new Error(a)}if(!sb(s.uri)){const{message:a}=ue("MISSING_OR_INVALID",`pair() uri: ${s.uri}`);throw new Error(a)}},this.isValidPing=async s=>{if(!gr(s)){const{message:l}=ue("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(l)}const{topic:a}=s;await this.isValidPairingTopic(a)},this.isValidDisconnect=async s=>{if(!gr(s)){const{message:l}=ue("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(l)}const{topic:a}=s;await this.isValidPairingTopic(a)},this.isValidPairingTopic=async s=>{if(!Wt(s,!1)){const{message:a}=ue("MISSING_OR_INVALID",`pairing topic should be a string: ${s}`);throw new Error(a)}if(!this.pairings.keys.includes(s)){const{message:a}=ue("NO_MATCHING_KEY",`pairing topic doesn't exist: ${s}`);throw new Error(a)}if(Pi(this.pairings.get(s).expiry)){await this.deletePairing(s);const{message:a}=ue("EXPIRED",`pairing topic: ${s}`);throw new Error(a)}},this.core=t,this.logger=Ze.generateChildLogger(r,this.name),this.pairings=new Go(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Ze.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(At.message,async t=>{const{topic:r,message:s}=t;if(!this.pairings.keys.includes(r)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))return;const a=await this.core.crypto.decode(r,s);try{nu(a)?(this.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a})):qo(a)&&(await this.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a}),this.core.history.delete(r,a.id))}catch(l){this.logger.error(l)}})}registerExpirerEvents(){this.core.expirer.on($r.expired,async t=>{const{topic:r}=Od(t.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit("pairing_expire",{topic:r}))})}}class z2 extends Kb{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new Fr.EventEmitter,this.name=y2,this.version=_2,this.cached=[],this.initialized=!1,this.storagePrefix=Ti,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.records.set(s.id,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(s,a,l)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:s,request:a,chainId:l}),this.records.has(a.id))return;const p={id:a.id,topic:s,request:{method:a.method,params:a.params||null},chainId:l,expiry:kr(ve.THIRTY_DAYS)};this.records.set(p.id,p),this.events.emit(ei.created,p)},this.resolve=async s=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:s}),!this.records.has(s.id))return;const a=await this.getRecord(s.id);typeof a.response>"u"&&(a.response=Kr(s)?{error:s.error}:{result:s.result},this.records.set(a.id,a),this.events.emit(ei.updated,a))},this.get=async(s,a)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:s,id:a}),await this.getRecord(a)),this.delete=(s,a)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:a}),this.values.forEach(l=>{if(l.topic===s){if(typeof a<"u"&&l.id!==a)return;this.records.delete(l.id),this.events.emit(ei.deleted,l)}})},this.exists=async(s,a)=>(this.isInitialized(),this.records.has(a)?(await this.getRecord(a)).topic===s:!1),this.on=(s,a)=>{this.events.on(s,a)},this.once=(s,a)=>{this.events.once(s,a)},this.off=(s,a)=>{this.events.off(s,a)},this.removeListener=(s,a)=>{this.events.removeListener(s,a)},this.logger=Ze.generateChildLogger(r,this.name)}get context(){return Ze.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const t=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const s={topic:r.topic,request:Mo(r.request.method,r.request.params,r.id),chainId:r.chainId};return t.push(s)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const r=this.records.get(t);if(!r){const{message:s}=ue("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(s)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(ei.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:r}=ue("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(ei.created,t=>{const r=ei.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(ei.updated,t=>{const r=ei.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(ei.deleted,t=>{const r=ei.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.core.heartbeat.on(Un.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(t=>{ve.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.delete(t.topic,t.id))})}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}}class H2 extends Jb{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new Fr.EventEmitter,this.name=m2,this.version=w2,this.cached=[],this.initialized=!1,this.storagePrefix=Ti,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.expirations.set(s.target,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=s=>{try{const a=this.formatTarget(s);return typeof this.getExpiration(a)<"u"}catch{return!1}},this.set=(s,a)=>{this.isInitialized();const l=this.formatTarget(s),p={target:l,expiry:a};this.expirations.set(l,p),this.checkExpiry(l,p),this.events.emit($r.created,{target:l,expiration:p})},this.get=s=>{this.isInitialized();const a=this.formatTarget(s);return this.getExpiration(a)},this.del=s=>{if(this.isInitialized(),this.has(s)){const a=this.formatTarget(s),l=this.getExpiration(a);this.expirations.delete(a),this.events.emit($r.deleted,{target:a,expiration:l})}},this.on=(s,a)=>{this.events.on(s,a)},this.once=(s,a)=>{this.events.once(s,a)},this.off=(s,a)=>{this.events.off(s,a)},this.removeListener=(s,a)=>{this.events.removeListener(s,a)},this.logger=Ze.generateChildLogger(r,this.name)}get context(){return Ze.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if(typeof t=="string")return Mw(t);if(typeof t=="number")return jw(t);const{message:r}=ue("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(r)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit($r.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:r}=ue("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const r=this.expirations.get(t);if(!r){const{message:s}=ue("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(s),new Error(s)}return r}checkExpiry(t,r){const{expiry:s}=r;ve.toMiliseconds(s)-Date.now()<=0&&this.expire(t,r)}expire(t,r){this.expirations.delete(t),this.events.emit($r.expired,{target:t,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,r)=>this.checkExpiry(r,t))}registerEventListeners(){this.core.heartbeat.on(Un.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on($r.created,t=>{const r=$r.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on($r.expired,t=>{const r=$r.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on($r.deleted,t=>{const r=$r.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}}class B2 extends Xb{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.name=Cc,this.initialized=!1,this.init=async s=>{Ed()||!du()||(this.verifyUrl=(s==null?void 0:s.verifyUrl)||Af,await this.createIframe())},this.register=async s=>{var a;if(this.initialized||await this.init(),!!this.iframe)try{(a=this.iframe.contentWindow)==null||a.postMessage(s.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${s.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async s=>{var a;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${s.attestationId}`);const l=this.startAbortTimer(ve.FIVE_SECONDS),p=await fetch(`${this.verifyUrl}/attestation/${s.attestationId}`,{signal:this.abortController.signal});return clearTimeout(l),p.status===200?(a=await p.json())==null?void 0:a.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise((s,a)=>{if(document.getElementById(Cc))return s();const l=document.createElement("iframe");l.setAttribute("id",Cc),l.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),l.style.display="none",l.addEventListener("load",()=>{this.initialized=!0,s()}),l.addEventListener("error",p=>{a(p)}),document.body.append(l),this.iframe=l}),new Promise(s=>{setTimeout(()=>s("iframe load timeout"),ve.toMiliseconds(ve.ONE_SECOND/2))})])}catch(s){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(s)}},this.logger=Ze.generateChildLogger(r,this.name),this.verifyUrl=Af,this.abortController=new AbortController,this.isDevEnv=fu()&&{}.IS_VITEST}get context(){return Ze.getLoggerContext(this.logger)}startAbortTimer(t){return setTimeout(()=>this.abortController.abort(),ve.toMiliseconds(t))}}var K2=Object.defineProperty,Df=Object.getOwnPropertySymbols,k2=Object.prototype.hasOwnProperty,V2=Object.prototype.propertyIsEnumerable,Ff=(n,t,r)=>t in n?K2(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Mf=(n,t)=>{for(var r in t||(t={}))k2.call(t,r)&&Ff(n,r,t[r]);if(Df)for(var r of Df(t))V2.call(t,r)&&Ff(n,r,t[r]);return n};class wu extends Bb{constructor(t){super(t),this.protocol=Gd,this.version=W6,this.name=mu,this.events=new Fr.EventEmitter,this.initialized=!1,this.on=(s,a)=>this.events.on(s,a),this.once=(s,a)=>this.events.once(s,a),this.off=(s,a)=>this.events.off(s,a),this.removeListener=(s,a)=>this.events.removeListener(s,a),this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||Jd;const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ze.pino(Ze.getDefaultLoggerOptions({level:(t==null?void 0:t.logger)||G6.logger}));this.logger=Ze.generateChildLogger(r,this.name),this.heartbeat=new Un.HeartBeat,this.crypto=new E2(this,this.logger,t==null?void 0:t.keychain),this.history=new z2(this,this.logger),this.expirer=new H2(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new Lb(Mf(Mf({},Y6),t==null?void 0:t.storageOptions)),this.relayer=new D2({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new q2(this,this.logger),this.verify=new B2(this.projectId||"",this.logger)}static async init(t){const r=new wu(t);await r.initialize();const s=await r.crypto.getClientId();return await r.storage.setItem(l2,s),r}get context(){return Ze.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}}const W2=wu,Xd="wc",Qd=2,Zd="client",bu=`${Xd}@${Qd}:${Zd}:`,Uc={name:Zd,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},jf="WALLETCONNECT_DEEPLINK_CHOICE",G2="proposal",ep="Proposal expired",Y2="session",Io=ve.SEVEN_DAYS,J2="engine",us={wc_sessionPropose:{req:{ttl:ve.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ve.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:ve.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ve.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ve.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ve.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ve.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ve.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ve.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ve.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ve.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ve.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ve.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ve.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ve.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:ve.THIRTY_SECONDS,prompt:!1,tag:1115}}},Lc={min:ve.FIVE_MINUTES,max:ve.SEVEN_DAYS},hs={idle:"idle",active:"active"},X2="request",Q2=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Z2=Object.defineProperty,e5=Object.defineProperties,t5=Object.getOwnPropertyDescriptors,qf=Object.getOwnPropertySymbols,r5=Object.prototype.hasOwnProperty,i5=Object.prototype.propertyIsEnumerable,zf=(n,t,r)=>t in n?Z2(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Lr=(n,t)=>{for(var r in t||(t={}))r5.call(t,r)&&zf(n,r,t[r]);if(qf)for(var r of qf(t))i5.call(t,r)&&zf(n,r,t[r]);return n},$c=(n,t)=>e5(n,t5(t));class n5 extends Zb{constructor(t){super(t),this.name=J2,this.events=new tu,this.initialized=!1,this.ignoredPayloadTypes=[tn],this.requestQueue={state:hs.idle,requests:[]},this.requestQueueDelay=ve.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(us)}),this.initialized=!0,setTimeout(()=>{this.requestQueue.requests=this.getPendingSessionRequests(),this.processRequestQueue()},ve.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{this.isInitialized();const s=$c(Lr({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:a,requiredNamespaces:l,optionalNamespaces:p,sessionProperties:d,relays:v}=s;let b=a,x,$=!1;if(b&&($=this.client.core.pairing.pairings.get(b).active),!b||!$){const{topic:D,uri:S}=await this.client.core.pairing.create();b=D,x=S}const j=await this.client.core.crypto.generateKeyPair(),U=Lr({requiredNamespaces:l,optionalNamespaces:p,relays:v??[{protocol:Yd}],proposer:{publicKey:j,metadata:this.client.metadata}},d&&{sessionProperties:d}),{reject:z,resolve:B,done:K}=On(ve.FIVE_MINUTES,ep);if(this.events.once(Ht("session_connect"),async({error:D,session:S})=>{if(D)z(D);else if(S){S.self.publicKey=j;const P=$c(Lr({},S),{requiredNamespaces:S.requiredNamespaces,optionalNamespaces:S.optionalNamespaces});await this.client.session.set(S.topic,P),await this.setExpiry(S.topic,S.expiry),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:S.peer.metadata}),B(P)}}),!b){const{message:D}=ue("NO_MATCHING_KEY",`connect() pairing topic: ${b}`);throw new Error(D)}const oe=await this.sendRequest(b,"wc_sessionPropose",U),T=kr(ve.FIVE_MINUTES);return await this.setProposal(oe,Lr({id:oe,expiry:T},U)),{uri:x,approval:K}},this.pair=async r=>(this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:s,relayProtocol:a,namespaces:l,sessionProperties:p}=r,d=this.client.proposal.get(s);let{pairingTopic:v,proposer:b,requiredNamespaces:x,optionalNamespaces:$}=d;v=v||"",Tn(x)||(x=eb(l,"approve()"));const j=await this.client.core.crypto.generateKeyPair(),U=b.publicKey,z=await this.client.core.crypto.generateSharedKey(j,U);v&&s&&(await this.client.core.pairing.updateMetadata({topic:v,metadata:b.metadata}),await this.sendResult(s,v,{relay:{protocol:a??"irn"},responderPublicKey:j}),await this.client.proposal.delete(s,Ut("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:v}));const B=Lr({relay:{protocol:a??"irn"},namespaces:l,requiredNamespaces:x,optionalNamespaces:$,pairingTopic:v,controller:{publicKey:j,metadata:this.client.metadata},expiry:kr(Io)},p&&{sessionProperties:p});await this.client.core.relayer.subscribe(z),await this.sendRequest(z,"wc_sessionSettle",B);const K=$c(Lr({},B),{topic:z,pairingTopic:v,acknowledged:!1,self:B.controller,peer:{publicKey:b.publicKey,metadata:b.metadata},controller:j});return await this.client.session.set(z,K),await this.setExpiry(z,kr(Io)),{topic:z,acknowledged:()=>new Promise(oe=>setTimeout(()=>oe(this.client.session.get(z)),500))}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:s,reason:a}=r,{pairingTopic:l}=this.client.proposal.get(s);l&&(await this.sendError(s,l,a),await this.client.proposal.delete(s,Ut("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:s,namespaces:a}=r,l=await this.sendRequest(s,"wc_sessionUpdate",{namespaces:a}),{done:p,resolve:d,reject:v}=On();return this.events.once(Ht("session_update",l),({error:b})=>{b?v(b):d()}),await this.client.session.update(s,{namespaces:a}),{acknowledged:p}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:s}=r,a=await this.sendRequest(s,"wc_sessionExtend",{}),{done:l,resolve:p,reject:d}=On();return this.events.once(Ht("session_extend",a),({error:v})=>{v?d(v):p()}),await this.setExpiry(s,kr(Io)),{acknowledged:l}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:s,request:a,topic:l,expiry:p}=r,d=await this.sendRequest(l,"wc_sessionRequest",{request:a,chainId:s},p),{done:v,resolve:b,reject:x}=On(p);this.events.once(Ht("session_request",d),({error:j,result:U})=>{j?x(j):b(U)}),this.client.events.emit("session_request_sent",{topic:l,request:a,chainId:s,id:d});const $=await this.client.core.storage.getItem(jf);return qw({id:d,topic:l,wcDeepLink:$}),await v()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:s,response:a}=r,{id:l}=a;gi(a)?await this.sendResult(l,s,a.result):Kr(a)&&await this.sendError(l,s,a.error),this.cleanupAfterResponse(r)},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:s}=r;if(this.client.session.keys.includes(s)){const a=await this.sendRequest(s,"wc_sessionPing",{}),{done:l,resolve:p,reject:d}=On();this.events.once(Ht("session_ping",a),({error:v})=>{v?d(v):p()}),await l()}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s})},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:s,event:a,chainId:l}=r;await this.sendRequest(s,"wc_sessionEvent",{event:a,chainId:l})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:s}=r;if(this.client.session.keys.includes(s)){const a=ru().toString();let l;const p=d=>{(d==null?void 0:d.id.toString())===a&&(this.client.core.relayer.events.removeListener(At.message_ack,p),l())};await Promise.all([new Promise(d=>{l=d,this.client.core.relayer.on(At.message_ack,p)}),this.sendRequest(s,"wc_sessionDelete",Ut("USER_DISCONNECTED"),void 0,a)]),await this.deleteSession(s)}else await this.client.core.pairing.disconnect({topic:s})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(s=>ib(s,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{const s=this.client.core.pairing.pairings.get(r.pairingTopic),a=this.client.core.pairing.pairings.getAll().filter(l=>{var p,d;return((p=l.peerMetadata)==null?void 0:p.url)&&((d=l.peerMetadata)==null?void 0:d.url)===r.peer.metadata.url&&l.topic&&l.topic!==s.topic});if(a.length===0)return;this.client.logger.info(`Cleaning up ${a.length} duplicate pairing(s)`),await Promise.all(a.map(l=>this.client.core.pairing.disconnect({topic:l.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(s){this.client.logger.error(s)}},this.deleteSession=async(r,s)=>{const{self:a}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,Ut("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(a.publicKey)&&await this.client.core.crypto.deleteKeyPair(a.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),s||this.client.core.expirer.del(r),this.client.core.storage.removeItem(jf).catch(l=>this.client.logger.warn(l))},this.deleteProposal=async(r,s)=>{await Promise.all([this.client.proposal.delete(r,Ut("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(r)])},this.deletePendingSessionRequest=async(r,s,a=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,s),a?Promise.resolve():this.client.core.expirer.del(r)]),this.requestQueue.requests=this.requestQueue.requests.filter(l=>l.id!==r),a&&(this.requestQueue.state=hs.idle)},this.setExpiry=async(r,s)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:s}),this.client.core.expirer.set(r,s)},this.setProposal=async(r,s)=>{await this.client.proposal.set(r,s),this.client.core.expirer.set(r,s.expiry)},this.setPendingSessionRequest=async r=>{const s=us.wc_sessionRequest.req.ttl,{id:a,topic:l,params:p}=r;await this.client.pendingRequest.set(a,{id:a,topic:l,params:p}),s&&this.client.core.expirer.set(a,kr(s))},this.sendRequest=async(r,s,a,l,p)=>{const d=Mo(s,a);if(du()&&Q2.includes(s)){const x=An(JSON.stringify(d));await this.client.core.verify.register({attestationId:x})}const v=await this.client.core.crypto.encode(r,d),b=us[s].req;return l&&(b.ttl=l),p&&(b.id=p),this.client.core.history.set(r,d),this.client.core.relayer.publish(r,v,b),d.id},this.sendResult=async(r,s,a)=>{const l=iu(r,a),p=await this.client.core.crypto.encode(s,l),d=await this.client.core.history.get(s,r),v=us[d.request.method].res;this.client.core.relayer.publish(s,p,v),await this.client.core.history.resolve(l)},this.sendError=async(r,s,a)=>{const l=jo(r,a),p=await this.client.core.crypto.encode(s,l),d=await this.client.core.history.get(s,r),v=us[d.request.method].res;this.client.core.relayer.publish(s,p,v),await this.client.core.history.resolve(l)},this.cleanup=async()=>{const r=[],s=[];this.client.session.getAll().forEach(a=>{Pi(a.expiry)&&r.push(a.topic)}),this.client.proposal.getAll().forEach(a=>{Pi(a.expiry)&&s.push(a.id)}),await Promise.all([...r.map(a=>this.deleteSession(a)),...s.map(a=>this.deleteProposal(a))])},this.onRelayEventRequest=r=>{const{topic:s,payload:a}=r,l=a.method;switch(l){case"wc_sessionPropose":return this.onSessionProposeRequest(s,a);case"wc_sessionSettle":return this.onSessionSettleRequest(s,a);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,a);case"wc_sessionExtend":return this.onSessionExtendRequest(s,a);case"wc_sessionPing":return this.onSessionPingRequest(s,a);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,a);case"wc_sessionRequest":return this.onSessionRequest(s,a);case"wc_sessionEvent":return this.onSessionEventRequest(s,a);default:return this.client.logger.info(`Unsupported request method ${l}`)}},this.onRelayEventResponse=async r=>{const{topic:s,payload:a}=r,l=(await this.client.core.history.get(s,a.id)).request.method;switch(l){case"wc_sessionPropose":return this.onSessionProposeResponse(s,a);case"wc_sessionSettle":return this.onSessionSettleResponse(s,a);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,a);case"wc_sessionExtend":return this.onSessionExtendResponse(s,a);case"wc_sessionPing":return this.onSessionPingResponse(s,a);case"wc_sessionRequest":return this.onSessionRequestResponse(s,a);default:return this.client.logger.info(`Unsupported response method ${l}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:s}=r,{message:a}=ue("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(a)},this.onSessionProposeRequest=async(r,s)=>{const{params:a,id:l}=s;try{this.isValidConnect(Lr({},s.params));const p=kr(ve.FIVE_MINUTES),d=Lr({id:l,pairingTopic:r,expiry:p},a);await this.setProposal(l,d);const v=An(JSON.stringify(s)),b=await this.getVerifyContext(v,d.proposer.metadata);this.client.events.emit("session_proposal",{id:l,params:d,verifyContext:b})}catch(p){await this.sendError(l,r,p),this.client.logger.error(p)}},this.onSessionProposeResponse=async(r,s)=>{const{id:a}=s;if(gi(s)){const{result:l}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:l});const p=this.client.proposal.get(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:p});const d=p.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:d});const v=l.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:v});const b=await this.client.core.crypto.generateSharedKey(d,v);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});const x=await this.client.core.relayer.subscribe(b);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:x}),await this.client.core.pairing.activate({topic:r})}else Kr(s)&&(await this.client.proposal.delete(a,Ut("USER_DISCONNECTED")),this.events.emit(Ht("session_connect"),{error:s.error}))},this.onSessionSettleRequest=async(r,s)=>{const{id:a,params:l}=s;try{this.isValidSessionSettleRequest(l);const{relay:p,controller:d,expiry:v,namespaces:b,requiredNamespaces:x,optionalNamespaces:$,sessionProperties:j,pairingTopic:U}=s.params,z=Lr({topic:r,relay:p,expiry:v,namespaces:b,acknowledged:!0,pairingTopic:U,requiredNamespaces:x,optionalNamespaces:$,controller:d.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:d.publicKey,metadata:d.metadata}},j&&{sessionProperties:j});await this.sendResult(s.id,r,!0),this.events.emit(Ht("session_connect"),{session:z}),this.cleanupDuplicatePairings(z)}catch(p){await this.sendError(a,r,p),this.client.logger.error(p)}},this.onSessionSettleResponse=async(r,s)=>{const{id:a}=s;gi(s)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Ht("session_approve",a),{})):Kr(s)&&(await this.client.session.delete(r,Ut("USER_DISCONNECTED")),this.events.emit(Ht("session_approve",a),{error:s.error}))},this.onSessionUpdateRequest=async(r,s)=>{const{params:a,id:l}=s;try{this.isValidUpdate(Lr({topic:r},a)),await this.client.session.update(r,{namespaces:a.namespaces}),await this.sendResult(l,r,!0),this.client.events.emit("session_update",{id:l,topic:r,params:a})}catch(p){await this.sendError(l,r,p),this.client.logger.error(p)}},this.onSessionUpdateResponse=(r,s)=>{const{id:a}=s;gi(s)?this.events.emit(Ht("session_update",a),{}):Kr(s)&&this.events.emit(Ht("session_update",a),{error:s.error})},this.onSessionExtendRequest=async(r,s)=>{const{id:a}=s;try{this.isValidExtend({topic:r}),await this.setExpiry(r,kr(Io)),await this.sendResult(a,r,!0),this.client.events.emit("session_extend",{id:a,topic:r})}catch(l){await this.sendError(a,r,l),this.client.logger.error(l)}},this.onSessionExtendResponse=(r,s)=>{const{id:a}=s;gi(s)?this.events.emit(Ht("session_extend",a),{}):Kr(s)&&this.events.emit(Ht("session_extend",a),{error:s.error})},this.onSessionPingRequest=async(r,s)=>{const{id:a}=s;try{this.isValidPing({topic:r}),await this.sendResult(a,r,!0),this.client.events.emit("session_ping",{id:a,topic:r})}catch(l){await this.sendError(a,r,l),this.client.logger.error(l)}},this.onSessionPingResponse=(r,s)=>{const{id:a}=s;setTimeout(()=>{gi(s)?this.events.emit(Ht("session_ping",a),{}):Kr(s)&&this.events.emit(Ht("session_ping",a),{error:s.error})},500)},this.onSessionDeleteRequest=async(r,s)=>{const{id:a}=s;try{this.isValidDisconnect({topic:r,reason:s.params}),await Promise.all([new Promise(l=>{this.client.core.relayer.once(At.publish,async()=>{l(await this.deleteSession(r))})}),this.sendResult(a,r,!0)]),this.client.events.emit("session_delete",{id:a,topic:r})}catch(l){this.client.logger.error(l)}},this.onSessionRequest=async(r,s)=>{const{id:a,params:l}=s;try{this.isValidRequest(Lr({topic:r},l)),await this.setPendingSessionRequest({id:a,topic:r,params:l}),this.addRequestToQueue({id:a,topic:r,params:l}),await this.processRequestQueue()}catch(p){await this.sendError(a,r,p),this.client.logger.error(p)}},this.onSessionRequestResponse=(r,s)=>{const{id:a}=s;gi(s)?this.events.emit(Ht("session_request",a),{result:s.result}):Kr(s)&&this.events.emit(Ht("session_request",a),{error:s.error})},this.onSessionEventRequest=async(r,s)=>{const{id:a,params:l}=s;try{this.isValidEmit(Lr({topic:r},l)),this.client.events.emit("session_event",{id:a,topic:r,params:l})}catch(p){await this.sendError(a,r,p),this.client.logger.error(p)}},this.addRequestToQueue=r=>{this.requestQueue.requests.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.requestQueue.state=hs.idle,this.processRequestQueue()},ve.toMiliseconds(this.requestQueueDelay))},this.processRequestQueue=async()=>{if(this.requestQueue.state===hs.active){this.client.logger.info("session request queue is already active.");return}const r=this.requestQueue.requests[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{const{id:s,topic:a,params:l}=r,p=An(JSON.stringify({id:s,params:l})),d=this.client.session.get(a),v=await this.getVerifyContext(p,d.peer.metadata);this.requestQueue.state=hs.active,this.client.events.emit("session_request",{id:s,topic:a,params:l,verifyContext:v})}catch(s){this.client.logger.error(s)}},this.isValidConnect=async r=>{if(!gr(r)){const{message:v}=ue("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(v)}const{pairingTopic:s,requiredNamespaces:a,optionalNamespaces:l,sessionProperties:p,relays:d}=r;if(or(s)||await this.isValidPairingTopic(s),!gb(d,!0)){const{message:v}=ue("MISSING_OR_INVALID",`connect() relays: ${d}`);throw new Error(v)}!or(a)&&Tn(a)!==0&&this.validateNamespaces(a,"requiredNamespaces"),!or(l)&&Tn(l)!==0&&this.validateNamespaces(l,"optionalNamespaces"),or(p)||this.validateSessionProps(p,"sessionProperties")},this.validateNamespaces=(r,s)=>{const a=pb(r,"connect()",s);if(a)throw new Error(a.message)},this.isValidApprove=async r=>{if(!gr(r))throw new Error(ue("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:s,namespaces:a,relayProtocol:l,sessionProperties:p}=r;await this.isValidProposalId(s);const d=this.client.proposal.get(s),v=To(a,"approve()");if(v)throw new Error(v.message);const b=Ql(d.requiredNamespaces,a,"approve()");if(b)throw new Error(b.message);if(!Wt(l,!0)){const{message:x}=ue("MISSING_OR_INVALID",`approve() relayProtocol: ${l}`);throw new Error(x)}or(p)||this.validateSessionProps(p,"sessionProperties")},this.isValidReject=async r=>{if(!gr(r)){const{message:l}=ue("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(l)}const{id:s,reason:a}=r;if(await this.isValidProposalId(s),!yb(a)){const{message:l}=ue("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(a)}`);throw new Error(l)}},this.isValidSessionSettleRequest=r=>{if(!gr(r)){const{message:b}=ue("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(b)}const{relay:s,controller:a,namespaces:l,expiry:p}=r;if(!Ad(s)){const{message:b}=ue("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(b)}const d=cb(a,"onSessionSettleRequest()");if(d)throw new Error(d.message);const v=To(l,"onSessionSettleRequest()");if(v)throw new Error(v.message);if(Pi(p)){const{message:b}=ue("EXPIRED","onSessionSettleRequest()");throw new Error(b)}},this.isValidUpdate=async r=>{if(!gr(r)){const{message:v}=ue("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(v)}const{topic:s,namespaces:a}=r;await this.isValidSessionTopic(s);const l=this.client.session.get(s),p=To(a,"update()");if(p)throw new Error(p.message);const d=Ql(l.requiredNamespaces,a,"update()");if(d)throw new Error(d.message)},this.isValidExtend=async r=>{if(!gr(r)){const{message:a}=ue("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(a)}const{topic:s}=r;await this.isValidSessionTopic(s)},this.isValidRequest=async r=>{if(!gr(r)){const{message:v}=ue("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(v)}const{topic:s,request:a,chainId:l,expiry:p}=r;await this.isValidSessionTopic(s);const{namespaces:d}=this.client.session.get(s);if(!Xl(d,l)){const{message:v}=ue("MISSING_OR_INVALID",`request() chainId: ${l}`);throw new Error(v)}if(!_b(a)){const{message:v}=ue("MISSING_OR_INVALID",`request() ${JSON.stringify(a)}`);throw new Error(v)}if(!bb(d,l,a.method)){const{message:v}=ue("MISSING_OR_INVALID",`request() method: ${a.method}`);throw new Error(v)}if(p&&!xb(p,Lc)){const{message:v}=ue("MISSING_OR_INVALID",`request() expiry: ${p}. Expiry must be a number (in seconds) between ${Lc.min} and ${Lc.max}`);throw new Error(v)}},this.isValidRespond=async r=>{if(!gr(r)){const{message:l}=ue("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(l)}const{topic:s,response:a}=r;if(await this.isValidSessionTopic(s),!mb(a)){const{message:l}=ue("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(l)}},this.isValidPing=async r=>{if(!gr(r)){const{message:a}=ue("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(a)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.isValidEmit=async r=>{if(!gr(r)){const{message:d}=ue("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(d)}const{topic:s,event:a,chainId:l}=r;await this.isValidSessionTopic(s);const{namespaces:p}=this.client.session.get(s);if(!Xl(p,l)){const{message:d}=ue("MISSING_OR_INVALID",`emit() chainId: ${l}`);throw new Error(d)}if(!wb(a)){const{message:d}=ue("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(a)}`);throw new Error(d)}if(!Eb(p,l,a.name)){const{message:d}=ue("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(a)}`);throw new Error(d)}},this.isValidDisconnect=async r=>{if(!gr(r)){const{message:a}=ue("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(a)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.getVerifyContext=async(r,s)=>{const a={verified:{verifyUrl:s.verifyUrl||"",validation:"UNKNOWN",origin:s.url||""}};try{const l=await this.client.core.verify.resolve({attestationId:r,verifyUrl:s.verifyUrl});l&&(a.verified.origin=l,a.verified.validation=l===s.url?"VALID":"INVALID")}catch(l){this.client.logger.error(l)}return this.client.logger.info(`Verify context: ${JSON.stringify(a)}`),a},this.validateSessionProps=(r,s)=>{Object.values(r).forEach(a=>{if(!Wt(a,!1)){const{message:l}=ue("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(a)}`);throw new Error(l)}})}}isInitialized(){if(!this.initialized){const{message:t}=ue("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.client.core.relayer.on(At.message,async t=>{const{topic:r,message:s}=t;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const a=await this.client.core.crypto.decode(r,s);try{nu(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a})):qo(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a})}catch(l){this.client.logger.error(l)}})}registerExpirerEvents(){this.client.core.expirer.on($r.expired,async t=>{const{topic:r,id:s}=Od(t.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,ue("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}))})}isValidPairingTopic(t){if(!Wt(t,!1)){const{message:r}=ue("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:r}=ue("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(r)}if(Pi(this.client.core.pairing.pairings.get(t).expiry)){const{message:r}=ue("EXPIRED",`pairing topic: ${t}`);throw new Error(r)}}async isValidSessionTopic(t){if(!Wt(t,!1)){const{message:r}=ue("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(r)}if(!this.client.session.keys.includes(t)){const{message:r}=ue("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(r)}if(Pi(this.client.session.get(t).expiry)){await this.deleteSession(t);const{message:r}=ue("EXPIRED",`session topic: ${t}`);throw new Error(r)}}async isValidSessionOrPairingTopic(t){if(this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(Wt(t,!1)){const{message:r}=ue("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(r)}else{const{message:r}=ue("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(r)}}async isValidProposalId(t){if(!vb(t)){const{message:r}=ue("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(r)}if(!this.client.proposal.keys.includes(t)){const{message:r}=ue("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(r)}if(Pi(this.client.proposal.get(t).expiry)){await this.deleteProposal(t);const{message:r}=ue("EXPIRED",`proposal id: ${t}`);throw new Error(r)}}}class s5 extends Go{constructor(t,r){super(t,r,G2,bu),this.core=t,this.logger=r}}class o5 extends Go{constructor(t,r){super(t,r,Y2,bu),this.core=t,this.logger=r}}class a5 extends Go{constructor(t,r){super(t,r,X2,bu,s=>s.id),this.core=t,this.logger=r}}let c5=class tp extends Qb{constructor(t){super(t),this.protocol=Xd,this.version=Qd,this.name=Uc.name,this.events=new Fr.EventEmitter,this.on=(s,a)=>this.events.on(s,a),this.once=(s,a)=>this.events.once(s,a),this.off=(s,a)=>this.events.off(s,a),this.removeListener=(s,a)=>this.events.removeListener(s,a),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(a){throw this.logger.error(a.message),a}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(a){throw this.logger.error(a.message),a}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(a){throw this.logger.error(a.message),a}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(a){throw this.logger.error(a.message),a}},this.update=async s=>{try{return await this.engine.update(s)}catch(a){throw this.logger.error(a.message),a}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(a){throw this.logger.error(a.message),a}},this.request=async s=>{try{return await this.engine.request(s)}catch(a){throw this.logger.error(a.message),a}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(a){throw this.logger.error(a.message),a}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(a){throw this.logger.error(a.message),a}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(a){throw this.logger.error(a.message),a}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(a){throw this.logger.error(a.message),a}},this.find=s=>{try{return this.engine.find(s)}catch(a){throw this.logger.error(a.message),a}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=(t==null?void 0:t.name)||Uc.name,this.metadata=(t==null?void 0:t.metadata)||Uw();const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ze.pino(Ze.getDefaultLoggerOptions({level:(t==null?void 0:t.logger)||Uc.logger}));this.core=(t==null?void 0:t.core)||new W2(t),this.logger=Ze.generateChildLogger(r,this.name),this.session=new o5(this.core,this.logger),this.proposal=new s5(this.core,this.logger),this.pendingRequest=new a5(this.core,this.logger),this.engine=new n5(this)}static async init(t){const r=new tp(t);return await r.initialize(),r}get context(){return Ze.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}};const u5={Accept:"application/json","Content-Type":"application/json"},h5="POST",Hf={headers:u5,method:h5},Bf=10;class nn{constructor(t,r=!1){if(this.url=t,this.disableProviderPing=r,this.events=new Fr.EventEmitter,this.isAvailable=!1,this.registering=!1,!Il(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t,r){this.isAvailable||await this.register();try{const s=ps(t),l=await(await Sl(this.url,Object.assign(Object.assign({},Hf),{body:s}))).json();this.onPayload({data:l})}catch(s){this.onError(t.id,s)}}async register(t=this.url){if(!Il(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,a)=>{this.events.once("register_error",l=>{this.resetMaxListeners(),a(l)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return a(new Error("HTTP connection is missing or invalid"));s()})})}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const r=ps({id:1,jsonrpc:"2.0",method:"test",params:[]});await Sl(t,Object.assign(Object.assign({},Hf),{body:r}))}this.onOpen()}catch(r){const s=this.parseError(r);throw this.events.emit("register_error",s),this.onClose(),s}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?yu(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const s=this.parseError(r),a=s.message||s.toString(),l=jo(t,a);this.events.emit("payload",l)}parseError(t,r=this.url){return ed(t,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Bf&&this.events.setMaxListeners(Bf)}}const Kf="error",l5="wss://relay.walletconnect.com",f5="wc",d5="universal_provider",kf=`${f5}@2:${d5}:`,p5="https://rpc.walletconnect.com/v1",Ri={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var ls=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof yr<"u"?yr:typeof self<"u"?self:{},Xc={exports:{}};/**
8
+ * @license
9
+ * Lodash <https://lodash.com/>
10
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
11
+ * Released under MIT license <https://lodash.com/license>
12
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
13
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
14
+ */(function(n,t){(function(){var r,s="4.17.21",a=200,l="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",p="Expected a function",d="Invalid `variable` option passed into `_.template`",v="__lodash_hash_undefined__",b=500,x="__lodash_placeholder__",$=1,j=2,U=4,z=1,B=2,K=1,oe=2,T=4,D=8,S=16,P=32,m=64,u=128,_=256,W=512,V=30,se="...",ce=800,ge=16,N=1,q=2,le=3,te=1/0,G=9007199254740991,ee=17976931348623157e292,Y=0/0,re=4294967295,Oe=re-1,ie=re>>>1,we=[["ary",u],["bind",K],["bindKey",oe],["curry",D],["curryRight",S],["flip",W],["partial",P],["partialRight",m],["rearg",_]],he="[object Arguments]",_e="[object Array]",M="[object AsyncFunction]",F="[object Boolean]",A="[object Date]",h="[object DOMException]",I="[object Error]",ne="[object Function]",fe="[object GeneratorFunction]",Ie="[object Map]",He="[object Number]",ke="[object Null]",Fe="[object Object]",pt="[object Promise]",gt="[object Proxy]",je="[object RegExp]",xe="[object Set]",Ue="[object String]",Le="[object Symbol]",qe="[object Undefined]",Ae="[object WeakMap]",$e="[object WeakSet]",Se="[object ArrayBuffer]",Te="[object DataView]",Be="[object Float32Array]",Pe="[object Float64Array]",Ve="[object Int8Array]",Ge="[object Int16Array]",et="[object Int32Array]",tt="[object Uint8Array]",Je="[object Uint8ClampedArray]",Zt="[object Uint16Array]",ur="[object Uint32Array]",Wr=/\b__p \+= '';/g,er=/\b(__p \+=) '' \+/g,ii=/(__e\(.*?\)|\b__t\)) \+\n'';/g,vi=/&(?:amp|lt|gt|quot|#39);/g,Ui=/[&<>"']/g,bt=RegExp(vi.source),vt=RegExp(Ui.source),Et=/<%-([\s\S]+?)%>/g,St=/<%([\s\S]+?)%>/g,mt=/<%=([\s\S]+?)%>/g,yt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$t=/^\w*$/,Dt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,It=/[\\^$.*+?()[\]{}|]/g,Ft=RegExp(It.source),xt=/^\s+/,Tt=/\s/,Ot=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ht=/\{\n\/\* \[wrapped with (.+)\] \*/,Mt=/,? & /,jt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Yo=/[()=,{}\[\]\/\s]/,Jo=/\\(\\)?/g,Xo=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,xr=/\w*$/,Qo=/^[-+]0x[0-9a-f]+$/i,Zo=/^0b[01]+$/i,ea=/^\[object .+?Constructor\]$/,ta=/^0o[0-7]+$/i,ra=/^(?:0|[1-9]\d*)$/,ni=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,sn=/($^)/,ia=/['\n\r\u2028\u2029\\]/g,on="\\ud800-\\udfff",na="\\u0300-\\u036f",sa="\\ufe20-\\ufe2f",an="\\u20d0-\\u20ff",ms=na+sa+an,ws="\\u2700-\\u27bf",Mr="a-z\\xdf-\\xf6\\xf8-\\xff",oa="\\xac\\xb1\\xd7\\xf7",aa="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ca="\\u2000-\\u206f",ua=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",bs="A-Z\\xc0-\\xd6\\xd8-\\xde",Es="\\ufe0e\\ufe0f",Li=oa+aa+ca+ua,Ln="['’]",$i="["+on+"]",$n="["+Li+"]",Di="["+ms+"]",Ss="\\d+",ha="["+ws+"]",Is="["+Mr+"]",xs="[^"+on+Li+Ss+ws+Mr+bs+"]",cn="\\ud83c[\\udffb-\\udfff]",la="(?:"+Di+"|"+cn+")",Os="[^"+on+"]",un="(?:\\ud83c[\\udde6-\\uddff]){2}",yi="[\\ud800-\\udbff][\\udc00-\\udfff]",_r="["+bs+"]",Ps="\\u200d",As="(?:"+Is+"|"+xs+")",Gr="(?:"+_r+"|"+xs+")",Ts="(?:"+Ln+"(?:d|ll|m|re|s|t|ve))?",Ns="(?:"+Ln+"(?:D|LL|M|RE|S|T|VE))?",Cs=la+"?",Rs="["+Es+"]?",fa="(?:"+Ps+"(?:"+[Os,un,yi].join("|")+")"+Rs+Cs+")*",si="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Us="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ls=Rs+Cs+fa,hn="(?:"+[ha,un,yi].join("|")+")"+Ls,da="(?:"+[Os+Di+"?",Di,un,yi,$i].join("|")+")",Dn=RegExp(Ln,"g"),pa=RegExp(Di,"g"),ln=RegExp(cn+"(?="+cn+")|"+da+Ls,"g"),$s=RegExp([_r+"?"+Is+"+"+Ts+"(?="+[$n,_r,"$"].join("|")+")",Gr+"+"+Ns+"(?="+[$n,_r+As,"$"].join("|")+")",_r+"?"+As+"+"+Ts,_r+"+"+Ns,Us,si,Ss,hn].join("|"),"g"),Ds=RegExp("["+Ps+on+ms+Es+"]"),Fi=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fs=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],ga=-1,ot={};ot[Be]=ot[Pe]=ot[Ve]=ot[Ge]=ot[et]=ot[tt]=ot[Je]=ot[Zt]=ot[ur]=!0,ot[he]=ot[_e]=ot[Se]=ot[F]=ot[Te]=ot[A]=ot[I]=ot[ne]=ot[Ie]=ot[He]=ot[Fe]=ot[je]=ot[xe]=ot[Ue]=ot[Ae]=!1;var st={};st[he]=st[_e]=st[Se]=st[Te]=st[F]=st[A]=st[Be]=st[Pe]=st[Ve]=st[Ge]=st[et]=st[Ie]=st[He]=st[Fe]=st[je]=st[xe]=st[Ue]=st[Le]=st[tt]=st[Je]=st[Zt]=st[ur]=!0,st[I]=st[ne]=st[Ae]=!1;var w={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},C={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Q={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},de={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,Ce=parseInt,ft=typeof ls=="object"&&ls&&ls.Object===Object&&ls,qt=typeof self=="object"&&self&&self.Object===Object&&self,Xe=ft||qt||Function("return this")(),ct=t&&!t.nodeType&&t,Nt=ct&&!0&&n&&!n.nodeType&&n,hr=Nt&&Nt.exports===ct,zt=hr&&ft.process,dt=function(){try{var R=Nt&&Nt.require&&Nt.require("util").types;return R||zt&&zt.binding&&zt.binding("util")}catch{}}(),tr=dt&&dt.isArrayBuffer,jr=dt&&dt.isDate,Or=dt&&dt.isMap,Yr=dt&&dt.isRegExp,Fn=dt&&dt.isSet,Mi=dt&&dt.isTypedArray;function kt(R,k,H){switch(H.length){case 0:return R.call(k);case 1:return R.call(k,H[0]);case 2:return R.call(k,H[0],H[1]);case 3:return R.call(k,H[0],H[1],H[2])}return R.apply(k,H)}function np(R,k,H,pe){for(var Ne=-1,rt=R==null?0:R.length;++Ne<rt;){var Bt=R[Ne];k(pe,Bt,H(Bt),R)}return pe}function Pr(R,k){for(var H=-1,pe=R==null?0:R.length;++H<pe&&k(R[H],H,R)!==!1;);return R}function sp(R,k){for(var H=R==null?0:R.length;H--&&k(R[H],H,R)!==!1;);return R}function Iu(R,k){for(var H=-1,pe=R==null?0:R.length;++H<pe;)if(!k(R[H],H,R))return!1;return!0}function _i(R,k){for(var H=-1,pe=R==null?0:R.length,Ne=0,rt=[];++H<pe;){var Bt=R[H];k(Bt,H,R)&&(rt[Ne++]=Bt)}return rt}function Ms(R,k){var H=R==null?0:R.length;return!!H&&fn(R,k,0)>-1}function va(R,k,H){for(var pe=-1,Ne=R==null?0:R.length;++pe<Ne;)if(H(k,R[pe]))return!0;return!1}function _t(R,k){for(var H=-1,pe=R==null?0:R.length,Ne=Array(pe);++H<pe;)Ne[H]=k(R[H],H,R);return Ne}function mi(R,k){for(var H=-1,pe=k.length,Ne=R.length;++H<pe;)R[Ne+H]=k[H];return R}function ya(R,k,H,pe){var Ne=-1,rt=R==null?0:R.length;for(pe&&rt&&(H=R[++Ne]);++Ne<rt;)H=k(H,R[Ne],Ne,R);return H}function op(R,k,H,pe){var Ne=R==null?0:R.length;for(pe&&Ne&&(H=R[--Ne]);Ne--;)H=k(H,R[Ne],Ne,R);return H}function _a(R,k){for(var H=-1,pe=R==null?0:R.length;++H<pe;)if(k(R[H],H,R))return!0;return!1}var ap=ma("length");function cp(R){return R.split("")}function up(R){return R.match(jt)||[]}function xu(R,k,H){var pe;return H(R,function(Ne,rt,Bt){if(k(Ne,rt,Bt))return pe=rt,!1}),pe}function js(R,k,H,pe){for(var Ne=R.length,rt=H+(pe?1:-1);pe?rt--:++rt<Ne;)if(k(R[rt],rt,R))return rt;return-1}function fn(R,k,H){return k===k?bp(R,k,H):js(R,Ou,H)}function hp(R,k,H,pe){for(var Ne=H-1,rt=R.length;++Ne<rt;)if(pe(R[Ne],k))return Ne;return-1}function Ou(R){return R!==R}function Pu(R,k){var H=R==null?0:R.length;return H?ba(R,k)/H:Y}function ma(R){return function(k){return k==null?r:k[R]}}function wa(R){return function(k){return R==null?r:R[k]}}function Au(R,k,H,pe,Ne){return Ne(R,function(rt,Bt,ut){H=pe?(pe=!1,rt):k(H,rt,Bt,ut)}),H}function lp(R,k){var H=R.length;for(R.sort(k);H--;)R[H]=R[H].value;return R}function ba(R,k){for(var H,pe=-1,Ne=R.length;++pe<Ne;){var rt=k(R[pe]);rt!==r&&(H=H===r?rt:H+rt)}return H}function Ea(R,k){for(var H=-1,pe=Array(R);++H<R;)pe[H]=k(H);return pe}function fp(R,k){return _t(k,function(H){return[H,R[H]]})}function Tu(R){return R&&R.slice(0,Uu(R)+1).replace(xt,"")}function mr(R){return function(k){return R(k)}}function Sa(R,k){return _t(k,function(H){return R[H]})}function Mn(R,k){return R.has(k)}function Nu(R,k){for(var H=-1,pe=R.length;++H<pe&&fn(k,R[H],0)>-1;);return H}function Cu(R,k){for(var H=R.length;H--&&fn(k,R[H],0)>-1;);return H}function dp(R,k){for(var H=R.length,pe=0;H--;)R[H]===k&&++pe;return pe}var pp=wa(w),gp=wa(C);function vp(R){return"\\"+de[R]}function yp(R,k){return R==null?r:R[k]}function dn(R){return Ds.test(R)}function _p(R){return Fi.test(R)}function mp(R){for(var k,H=[];!(k=R.next()).done;)H.push(k.value);return H}function Ia(R){var k=-1,H=Array(R.size);return R.forEach(function(pe,Ne){H[++k]=[Ne,pe]}),H}function Ru(R,k){return function(H){return R(k(H))}}function wi(R,k){for(var H=-1,pe=R.length,Ne=0,rt=[];++H<pe;){var Bt=R[H];(Bt===k||Bt===x)&&(R[H]=x,rt[Ne++]=H)}return rt}function qs(R){var k=-1,H=Array(R.size);return R.forEach(function(pe){H[++k]=pe}),H}function wp(R){var k=-1,H=Array(R.size);return R.forEach(function(pe){H[++k]=[pe,pe]}),H}function bp(R,k,H){for(var pe=H-1,Ne=R.length;++pe<Ne;)if(R[pe]===k)return pe;return-1}function Ep(R,k,H){for(var pe=H+1;pe--;)if(R[pe]===k)return pe;return pe}function pn(R){return dn(R)?Ip(R):ap(R)}function qr(R){return dn(R)?xp(R):cp(R)}function Uu(R){for(var k=R.length;k--&&Tt.test(R.charAt(k)););return k}var Sp=wa(Q);function Ip(R){for(var k=ln.lastIndex=0;ln.test(R);)++k;return k}function xp(R){return R.match(ln)||[]}function Op(R){return R.match($s)||[]}var Pp=function R(k){k=k==null?Xe:gn.defaults(Xe.Object(),k,gn.pick(Xe,Fs));var H=k.Array,pe=k.Date,Ne=k.Error,rt=k.Function,Bt=k.Math,ut=k.Object,xa=k.RegExp,Ap=k.String,Ar=k.TypeError,zs=H.prototype,Tp=rt.prototype,vn=ut.prototype,Hs=k["__core-js_shared__"],Bs=Tp.toString,nt=vn.hasOwnProperty,Np=0,Lu=function(){var e=/[^.]+$/.exec(Hs&&Hs.keys&&Hs.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ks=vn.toString,Cp=Bs.call(ut),Rp=Xe._,Up=xa("^"+Bs.call(nt).replace(It,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ks=hr?k.Buffer:r,bi=k.Symbol,Vs=k.Uint8Array,$u=ks?ks.allocUnsafe:r,Ws=Ru(ut.getPrototypeOf,ut),Du=ut.create,Fu=vn.propertyIsEnumerable,Gs=zs.splice,Mu=bi?bi.isConcatSpreadable:r,jn=bi?bi.iterator:r,ji=bi?bi.toStringTag:r,Ys=function(){try{var e=Ki(ut,"defineProperty");return e({},"",{}),e}catch{}}(),Lp=k.clearTimeout!==Xe.clearTimeout&&k.clearTimeout,$p=pe&&pe.now!==Xe.Date.now&&pe.now,Dp=k.setTimeout!==Xe.setTimeout&&k.setTimeout,Js=Bt.ceil,Xs=Bt.floor,Oa=ut.getOwnPropertySymbols,Fp=ks?ks.isBuffer:r,ju=k.isFinite,Mp=zs.join,jp=Ru(ut.keys,ut),Kt=Bt.max,Jt=Bt.min,qp=pe.now,zp=k.parseInt,qu=Bt.random,Hp=zs.reverse,Pa=Ki(k,"DataView"),qn=Ki(k,"Map"),Aa=Ki(k,"Promise"),yn=Ki(k,"Set"),zn=Ki(k,"WeakMap"),Hn=Ki(ut,"create"),Qs=zn&&new zn,_n={},Bp=ki(Pa),Kp=ki(qn),kp=ki(Aa),Vp=ki(yn),Wp=ki(zn),Zs=bi?bi.prototype:r,Bn=Zs?Zs.valueOf:r,zu=Zs?Zs.toString:r;function g(e){if(Pt(e)&&!Re(e)&&!(e instanceof Ye)){if(e instanceof Tr)return e;if(nt.call(e,"__wrapped__"))return Hh(e)}return new Tr(e)}var mn=function(){function e(){}return function(i){if(!wt(i))return{};if(Du)return Du(i);e.prototype=i;var o=new e;return e.prototype=r,o}}();function eo(){}function Tr(e,i){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!i,this.__index__=0,this.__values__=r}g.templateSettings={escape:Et,evaluate:St,interpolate:mt,variable:"",imports:{_:g}},g.prototype=eo.prototype,g.prototype.constructor=g,Tr.prototype=mn(eo.prototype),Tr.prototype.constructor=Tr;function Ye(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=re,this.__views__=[]}function Gp(){var e=new Ye(this.__wrapped__);return e.__actions__=lr(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=lr(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=lr(this.__views__),e}function Yp(){if(this.__filtered__){var e=new Ye(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function Jp(){var e=this.__wrapped__.value(),i=this.__dir__,o=Re(e),c=i<0,f=o?e.length:0,y=c0(0,f,this.__views__),E=y.start,O=y.end,L=O-E,J=c?O:E-1,X=this.__iteratees__,Z=X.length,ae=0,ye=Jt(L,this.__takeCount__);if(!o||!c&&f==L&&ye==L)return lh(e,this.__actions__);var be=[];e:for(;L--&&ae<ye;){J+=i;for(var ze=-1,Ee=e[J];++ze<Z;){var We=X[ze],Qe=We.iteratee,Er=We.type,nr=Qe(Ee);if(Er==q)Ee=nr;else if(!nr){if(Er==N)continue e;break e}}be[ae++]=Ee}return be}Ye.prototype=mn(eo.prototype),Ye.prototype.constructor=Ye;function qi(e){var i=-1,o=e==null?0:e.length;for(this.clear();++i<o;){var c=e[i];this.set(c[0],c[1])}}function Xp(){this.__data__=Hn?Hn(null):{},this.size=0}function Qp(e){var i=this.has(e)&&delete this.__data__[e];return this.size-=i?1:0,i}function Zp(e){var i=this.__data__;if(Hn){var o=i[e];return o===v?r:o}return nt.call(i,e)?i[e]:r}function eg(e){var i=this.__data__;return Hn?i[e]!==r:nt.call(i,e)}function tg(e,i){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=Hn&&i===r?v:i,this}qi.prototype.clear=Xp,qi.prototype.delete=Qp,qi.prototype.get=Zp,qi.prototype.has=eg,qi.prototype.set=tg;function oi(e){var i=-1,o=e==null?0:e.length;for(this.clear();++i<o;){var c=e[i];this.set(c[0],c[1])}}function rg(){this.__data__=[],this.size=0}function ig(e){var i=this.__data__,o=to(i,e);if(o<0)return!1;var c=i.length-1;return o==c?i.pop():Gs.call(i,o,1),--this.size,!0}function ng(e){var i=this.__data__,o=to(i,e);return o<0?r:i[o][1]}function sg(e){return to(this.__data__,e)>-1}function og(e,i){var o=this.__data__,c=to(o,e);return c<0?(++this.size,o.push([e,i])):o[c][1]=i,this}oi.prototype.clear=rg,oi.prototype.delete=ig,oi.prototype.get=ng,oi.prototype.has=sg,oi.prototype.set=og;function ai(e){var i=-1,o=e==null?0:e.length;for(this.clear();++i<o;){var c=e[i];this.set(c[0],c[1])}}function ag(){this.size=0,this.__data__={hash:new qi,map:new(qn||oi),string:new qi}}function cg(e){var i=po(this,e).delete(e);return this.size-=i?1:0,i}function ug(e){return po(this,e).get(e)}function hg(e){return po(this,e).has(e)}function lg(e,i){var o=po(this,e),c=o.size;return o.set(e,i),this.size+=o.size==c?0:1,this}ai.prototype.clear=ag,ai.prototype.delete=cg,ai.prototype.get=ug,ai.prototype.has=hg,ai.prototype.set=lg;function zi(e){var i=-1,o=e==null?0:e.length;for(this.__data__=new ai;++i<o;)this.add(e[i])}function fg(e){return this.__data__.set(e,v),this}function dg(e){return this.__data__.has(e)}zi.prototype.add=zi.prototype.push=fg,zi.prototype.has=dg;function zr(e){var i=this.__data__=new oi(e);this.size=i.size}function pg(){this.__data__=new oi,this.size=0}function gg(e){var i=this.__data__,o=i.delete(e);return this.size=i.size,o}function vg(e){return this.__data__.get(e)}function yg(e){return this.__data__.has(e)}function _g(e,i){var o=this.__data__;if(o instanceof oi){var c=o.__data__;if(!qn||c.length<a-1)return c.push([e,i]),this.size=++o.size,this;o=this.__data__=new ai(c)}return o.set(e,i),this.size=o.size,this}zr.prototype.clear=pg,zr.prototype.delete=gg,zr.prototype.get=vg,zr.prototype.has=yg,zr.prototype.set=_g;function Hu(e,i){var o=Re(e),c=!o&&Vi(e),f=!o&&!c&&Oi(e),y=!o&&!c&&!f&&Sn(e),E=o||c||f||y,O=E?Ea(e.length,Ap):[],L=O.length;for(var J in e)(i||nt.call(e,J))&&!(E&&(J=="length"||f&&(J=="offset"||J=="parent")||y&&(J=="buffer"||J=="byteLength"||J=="byteOffset")||li(J,L)))&&O.push(J);return O}function Bu(e){var i=e.length;return i?e[ja(0,i-1)]:r}function mg(e,i){return go(lr(e),Hi(i,0,e.length))}function wg(e){return go(lr(e))}function Ta(e,i,o){(o!==r&&!Hr(e[i],o)||o===r&&!(i in e))&&ci(e,i,o)}function Kn(e,i,o){var c=e[i];(!(nt.call(e,i)&&Hr(c,o))||o===r&&!(i in e))&&ci(e,i,o)}function to(e,i){for(var o=e.length;o--;)if(Hr(e[o][0],i))return o;return-1}function bg(e,i,o,c){return Ei(e,function(f,y,E){i(c,f,o(f),E)}),c}function Ku(e,i){return e&&Xr(i,Vt(i),e)}function Eg(e,i){return e&&Xr(i,dr(i),e)}function ci(e,i,o){i=="__proto__"&&Ys?Ys(e,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[i]=o}function Na(e,i){for(var o=-1,c=i.length,f=H(c),y=e==null;++o<c;)f[o]=y?r:hc(e,i[o]);return f}function Hi(e,i,o){return e===e&&(o!==r&&(e=e<=o?e:o),i!==r&&(e=e>=i?e:i)),e}function Nr(e,i,o,c,f,y){var E,O=i&$,L=i&j,J=i&U;if(o&&(E=f?o(e,c,f,y):o(e)),E!==r)return E;if(!wt(e))return e;var X=Re(e);if(X){if(E=h0(e),!O)return lr(e,E)}else{var Z=Xt(e),ae=Z==ne||Z==fe;if(Oi(e))return ph(e,O);if(Z==Fe||Z==he||ae&&!f){if(E=L||ae?{}:Uh(e),!O)return L?Zg(e,Eg(E,e)):Qg(e,Ku(E,e))}else{if(!st[Z])return f?e:{};E=l0(e,Z,O)}}y||(y=new zr);var ye=y.get(e);if(ye)return ye;y.set(e,E),cl(e)?e.forEach(function(Ee){E.add(Nr(Ee,i,o,Ee,e,y))}):ol(e)&&e.forEach(function(Ee,We){E.set(We,Nr(Ee,i,o,We,e,y))});var be=J?L?Ja:Ya:L?dr:Vt,ze=X?r:be(e);return Pr(ze||e,function(Ee,We){ze&&(We=Ee,Ee=e[We]),Kn(E,We,Nr(Ee,i,o,We,e,y))}),E}function Sg(e){var i=Vt(e);return function(o){return ku(o,e,i)}}function ku(e,i,o){var c=o.length;if(e==null)return!c;for(e=ut(e);c--;){var f=o[c],y=i[f],E=e[f];if(E===r&&!(f in e)||!y(E))return!1}return!0}function Vu(e,i,o){if(typeof e!="function")throw new Ar(p);return Xn(function(){e.apply(r,o)},i)}function kn(e,i,o,c){var f=-1,y=Ms,E=!0,O=e.length,L=[],J=i.length;if(!O)return L;o&&(i=_t(i,mr(o))),c?(y=va,E=!1):i.length>=a&&(y=Mn,E=!1,i=new zi(i));e:for(;++f<O;){var X=e[f],Z=o==null?X:o(X);if(X=c||X!==0?X:0,E&&Z===Z){for(var ae=J;ae--;)if(i[ae]===Z)continue e;L.push(X)}else y(i,Z,c)||L.push(X)}return L}var Ei=mh(Jr),Wu=mh(Ra,!0);function Ig(e,i){var o=!0;return Ei(e,function(c,f,y){return o=!!i(c,f,y),o}),o}function ro(e,i,o){for(var c=-1,f=e.length;++c<f;){var y=e[c],E=i(y);if(E!=null&&(O===r?E===E&&!br(E):o(E,O)))var O=E,L=y}return L}function xg(e,i,o,c){var f=e.length;for(o=Me(o),o<0&&(o=-o>f?0:f+o),c=c===r||c>f?f:Me(c),c<0&&(c+=f),c=o>c?0:hl(c);o<c;)e[o++]=i;return e}function Gu(e,i){var o=[];return Ei(e,function(c,f,y){i(c,f,y)&&o.push(c)}),o}function Gt(e,i,o,c,f){var y=-1,E=e.length;for(o||(o=d0),f||(f=[]);++y<E;){var O=e[y];i>0&&o(O)?i>1?Gt(O,i-1,o,c,f):mi(f,O):c||(f[f.length]=O)}return f}var Ca=wh(),Yu=wh(!0);function Jr(e,i){return e&&Ca(e,i,Vt)}function Ra(e,i){return e&&Yu(e,i,Vt)}function io(e,i){return _i(i,function(o){return fi(e[o])})}function Bi(e,i){i=Ii(i,e);for(var o=0,c=i.length;e!=null&&o<c;)e=e[Qr(i[o++])];return o&&o==c?e:r}function Ju(e,i,o){var c=i(e);return Re(e)?c:mi(c,o(e))}function rr(e){return e==null?e===r?qe:ke:ji&&ji in ut(e)?a0(e):w0(e)}function Ua(e,i){return e>i}function Og(e,i){return e!=null&&nt.call(e,i)}function Pg(e,i){return e!=null&&i in ut(e)}function Ag(e,i,o){return e>=Jt(i,o)&&e<Kt(i,o)}function La(e,i,o){for(var c=o?va:Ms,f=e[0].length,y=e.length,E=y,O=H(y),L=1/0,J=[];E--;){var X=e[E];E&&i&&(X=_t(X,mr(i))),L=Jt(X.length,L),O[E]=!o&&(i||f>=120&&X.length>=120)?new zi(E&&X):r}X=e[0];var Z=-1,ae=O[0];e:for(;++Z<f&&J.length<L;){var ye=X[Z],be=i?i(ye):ye;if(ye=o||ye!==0?ye:0,!(ae?Mn(ae,be):c(J,be,o))){for(E=y;--E;){var ze=O[E];if(!(ze?Mn(ze,be):c(e[E],be,o)))continue e}ae&&ae.push(be),J.push(ye)}}return J}function Tg(e,i,o,c){return Jr(e,function(f,y,E){i(c,o(f),y,E)}),c}function Vn(e,i,o){i=Ii(i,e),e=Fh(e,i);var c=e==null?e:e[Qr(Rr(i))];return c==null?r:kt(c,e,o)}function Xu(e){return Pt(e)&&rr(e)==he}function Ng(e){return Pt(e)&&rr(e)==Se}function Cg(e){return Pt(e)&&rr(e)==A}function Wn(e,i,o,c,f){return e===i?!0:e==null||i==null||!Pt(e)&&!Pt(i)?e!==e&&i!==i:Rg(e,i,o,c,Wn,f)}function Rg(e,i,o,c,f,y){var E=Re(e),O=Re(i),L=E?_e:Xt(e),J=O?_e:Xt(i);L=L==he?Fe:L,J=J==he?Fe:J;var X=L==Fe,Z=J==Fe,ae=L==J;if(ae&&Oi(e)){if(!Oi(i))return!1;E=!0,X=!1}if(ae&&!X)return y||(y=new zr),E||Sn(e)?Nh(e,i,o,c,f,y):s0(e,i,L,o,c,f,y);if(!(o&z)){var ye=X&&nt.call(e,"__wrapped__"),be=Z&&nt.call(i,"__wrapped__");if(ye||be){var ze=ye?e.value():e,Ee=be?i.value():i;return y||(y=new zr),f(ze,Ee,o,c,y)}}return ae?(y||(y=new zr),o0(e,i,o,c,f,y)):!1}function Ug(e){return Pt(e)&&Xt(e)==Ie}function $a(e,i,o,c){var f=o.length,y=f,E=!c;if(e==null)return!y;for(e=ut(e);f--;){var O=o[f];if(E&&O[2]?O[1]!==e[O[0]]:!(O[0]in e))return!1}for(;++f<y;){O=o[f];var L=O[0],J=e[L],X=O[1];if(E&&O[2]){if(J===r&&!(L in e))return!1}else{var Z=new zr;if(c)var ae=c(J,X,L,e,i,Z);if(!(ae===r?Wn(X,J,z|B,c,Z):ae))return!1}}return!0}function Qu(e){if(!wt(e)||g0(e))return!1;var i=fi(e)?Up:ea;return i.test(ki(e))}function Lg(e){return Pt(e)&&rr(e)==je}function $g(e){return Pt(e)&&Xt(e)==xe}function Dg(e){return Pt(e)&&bo(e.length)&&!!ot[rr(e)]}function Zu(e){return typeof e=="function"?e:e==null?pr:typeof e=="object"?Re(e)?rh(e[0],e[1]):th(e):bl(e)}function Da(e){if(!Jn(e))return jp(e);var i=[];for(var o in ut(e))nt.call(e,o)&&o!="constructor"&&i.push(o);return i}function Fg(e){if(!wt(e))return m0(e);var i=Jn(e),o=[];for(var c in e)c=="constructor"&&(i||!nt.call(e,c))||o.push(c);return o}function Fa(e,i){return e<i}function eh(e,i){var o=-1,c=fr(e)?H(e.length):[];return Ei(e,function(f,y,E){c[++o]=i(f,y,E)}),c}function th(e){var i=Qa(e);return i.length==1&&i[0][2]?$h(i[0][0],i[0][1]):function(o){return o===e||$a(o,e,i)}}function rh(e,i){return ec(e)&&Lh(i)?$h(Qr(e),i):function(o){var c=hc(o,e);return c===r&&c===i?lc(o,e):Wn(i,c,z|B)}}function no(e,i,o,c,f){e!==i&&Ca(i,function(y,E){if(f||(f=new zr),wt(y))Mg(e,i,E,o,no,c,f);else{var O=c?c(rc(e,E),y,E+"",e,i,f):r;O===r&&(O=y),Ta(e,E,O)}},dr)}function Mg(e,i,o,c,f,y,E){var O=rc(e,o),L=rc(i,o),J=E.get(L);if(J){Ta(e,o,J);return}var X=y?y(O,L,o+"",e,i,E):r,Z=X===r;if(Z){var ae=Re(L),ye=!ae&&Oi(L),be=!ae&&!ye&&Sn(L);X=L,ae||ye||be?Re(O)?X=O:Ct(O)?X=lr(O):ye?(Z=!1,X=ph(L,!0)):be?(Z=!1,X=gh(L,!0)):X=[]:Qn(L)||Vi(L)?(X=O,Vi(O)?X=ll(O):(!wt(O)||fi(O))&&(X=Uh(L))):Z=!1}Z&&(E.set(L,X),f(X,L,c,y,E),E.delete(L)),Ta(e,o,X)}function ih(e,i){var o=e.length;if(o)return i+=i<0?o:0,li(i,o)?e[i]:r}function nh(e,i,o){i.length?i=_t(i,function(y){return Re(y)?function(E){return Bi(E,y.length===1?y[0]:y)}:y}):i=[pr];var c=-1;i=_t(i,mr(me()));var f=eh(e,function(y,E,O){var L=_t(i,function(J){return J(y)});return{criteria:L,index:++c,value:y}});return lp(f,function(y,E){return Xg(y,E,o)})}function jg(e,i){return sh(e,i,function(o,c){return lc(e,c)})}function sh(e,i,o){for(var c=-1,f=i.length,y={};++c<f;){var E=i[c],O=Bi(e,E);o(O,E)&&Gn(y,Ii(E,e),O)}return y}function qg(e){return function(i){return Bi(i,e)}}function Ma(e,i,o,c){var f=c?hp:fn,y=-1,E=i.length,O=e;for(e===i&&(i=lr(i)),o&&(O=_t(e,mr(o)));++y<E;)for(var L=0,J=i[y],X=o?o(J):J;(L=f(O,X,L,c))>-1;)O!==e&&Gs.call(O,L,1),Gs.call(e,L,1);return e}function oh(e,i){for(var o=e?i.length:0,c=o-1;o--;){var f=i[o];if(o==c||f!==y){var y=f;li(f)?Gs.call(e,f,1):Ha(e,f)}}return e}function ja(e,i){return e+Xs(qu()*(i-e+1))}function zg(e,i,o,c){for(var f=-1,y=Kt(Js((i-e)/(o||1)),0),E=H(y);y--;)E[c?y:++f]=e,e+=o;return E}function qa(e,i){var o="";if(!e||i<1||i>G)return o;do i%2&&(o+=e),i=Xs(i/2),i&&(e+=e);while(i);return o}function Ke(e,i){return ic(Dh(e,i,pr),e+"")}function Hg(e){return Bu(In(e))}function Bg(e,i){var o=In(e);return go(o,Hi(i,0,o.length))}function Gn(e,i,o,c){if(!wt(e))return e;i=Ii(i,e);for(var f=-1,y=i.length,E=y-1,O=e;O!=null&&++f<y;){var L=Qr(i[f]),J=o;if(L==="__proto__"||L==="constructor"||L==="prototype")return e;if(f!=E){var X=O[L];J=c?c(X,L,O):r,J===r&&(J=wt(X)?X:li(i[f+1])?[]:{})}Kn(O,L,J),O=O[L]}return e}var ah=Qs?function(e,i){return Qs.set(e,i),e}:pr,Kg=Ys?function(e,i){return Ys(e,"toString",{configurable:!0,enumerable:!1,value:dc(i),writable:!0})}:pr;function kg(e){return go(In(e))}function Cr(e,i,o){var c=-1,f=e.length;i<0&&(i=-i>f?0:f+i),o=o>f?f:o,o<0&&(o+=f),f=i>o?0:o-i>>>0,i>>>=0;for(var y=H(f);++c<f;)y[c]=e[c+i];return y}function Vg(e,i){var o;return Ei(e,function(c,f,y){return o=i(c,f,y),!o}),!!o}function so(e,i,o){var c=0,f=e==null?c:e.length;if(typeof i=="number"&&i===i&&f<=ie){for(;c<f;){var y=c+f>>>1,E=e[y];E!==null&&!br(E)&&(o?E<=i:E<i)?c=y+1:f=y}return f}return za(e,i,pr,o)}function za(e,i,o,c){var f=0,y=e==null?0:e.length;if(y===0)return 0;i=o(i);for(var E=i!==i,O=i===null,L=br(i),J=i===r;f<y;){var X=Xs((f+y)/2),Z=o(e[X]),ae=Z!==r,ye=Z===null,be=Z===Z,ze=br(Z);if(E)var Ee=c||be;else J?Ee=be&&(c||ae):O?Ee=be&&ae&&(c||!ye):L?Ee=be&&ae&&!ye&&(c||!ze):ye||ze?Ee=!1:Ee=c?Z<=i:Z<i;Ee?f=X+1:y=X}return Jt(y,Oe)}function ch(e,i){for(var o=-1,c=e.length,f=0,y=[];++o<c;){var E=e[o],O=i?i(E):E;if(!o||!Hr(O,L)){var L=O;y[f++]=E===0?0:E}}return y}function uh(e){return typeof e=="number"?e:br(e)?Y:+e}function wr(e){if(typeof e=="string")return e;if(Re(e))return _t(e,wr)+"";if(br(e))return zu?zu.call(e):"";var i=e+"";return i=="0"&&1/e==-te?"-0":i}function Si(e,i,o){var c=-1,f=Ms,y=e.length,E=!0,O=[],L=O;if(o)E=!1,f=va;else if(y>=a){var J=i?null:i0(e);if(J)return qs(J);E=!1,f=Mn,L=new zi}else L=i?[]:O;e:for(;++c<y;){var X=e[c],Z=i?i(X):X;if(X=o||X!==0?X:0,E&&Z===Z){for(var ae=L.length;ae--;)if(L[ae]===Z)continue e;i&&L.push(Z),O.push(X)}else f(L,Z,o)||(L!==O&&L.push(Z),O.push(X))}return O}function Ha(e,i){return i=Ii(i,e),e=Fh(e,i),e==null||delete e[Qr(Rr(i))]}function hh(e,i,o,c){return Gn(e,i,o(Bi(e,i)),c)}function oo(e,i,o,c){for(var f=e.length,y=c?f:-1;(c?y--:++y<f)&&i(e[y],y,e););return o?Cr(e,c?0:y,c?y+1:f):Cr(e,c?y+1:0,c?f:y)}function lh(e,i){var o=e;return o instanceof Ye&&(o=o.value()),ya(i,function(c,f){return f.func.apply(f.thisArg,mi([c],f.args))},o)}function Ba(e,i,o){var c=e.length;if(c<2)return c?Si(e[0]):[];for(var f=-1,y=H(c);++f<c;)for(var E=e[f],O=-1;++O<c;)O!=f&&(y[f]=kn(y[f]||E,e[O],i,o));return Si(Gt(y,1),i,o)}function fh(e,i,o){for(var c=-1,f=e.length,y=i.length,E={};++c<f;){var O=c<y?i[c]:r;o(E,e[c],O)}return E}function Ka(e){return Ct(e)?e:[]}function ka(e){return typeof e=="function"?e:pr}function Ii(e,i){return Re(e)?e:ec(e,i)?[e]:zh(it(e))}var Wg=Ke;function xi(e,i,o){var c=e.length;return o=o===r?c:o,!i&&o>=c?e:Cr(e,i,o)}var dh=Lp||function(e){return Xe.clearTimeout(e)};function ph(e,i){if(i)return e.slice();var o=e.length,c=$u?$u(o):new e.constructor(o);return e.copy(c),c}function Va(e){var i=new e.constructor(e.byteLength);return new Vs(i).set(new Vs(e)),i}function Gg(e,i){var o=i?Va(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}function Yg(e){var i=new e.constructor(e.source,xr.exec(e));return i.lastIndex=e.lastIndex,i}function Jg(e){return Bn?ut(Bn.call(e)):{}}function gh(e,i){var o=i?Va(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}function vh(e,i){if(e!==i){var o=e!==r,c=e===null,f=e===e,y=br(e),E=i!==r,O=i===null,L=i===i,J=br(i);if(!O&&!J&&!y&&e>i||y&&E&&L&&!O&&!J||c&&E&&L||!o&&L||!f)return 1;if(!c&&!y&&!J&&e<i||J&&o&&f&&!c&&!y||O&&o&&f||!E&&f||!L)return-1}return 0}function Xg(e,i,o){for(var c=-1,f=e.criteria,y=i.criteria,E=f.length,O=o.length;++c<E;){var L=vh(f[c],y[c]);if(L){if(c>=O)return L;var J=o[c];return L*(J=="desc"?-1:1)}}return e.index-i.index}function yh(e,i,o,c){for(var f=-1,y=e.length,E=o.length,O=-1,L=i.length,J=Kt(y-E,0),X=H(L+J),Z=!c;++O<L;)X[O]=i[O];for(;++f<E;)(Z||f<y)&&(X[o[f]]=e[f]);for(;J--;)X[O++]=e[f++];return X}function _h(e,i,o,c){for(var f=-1,y=e.length,E=-1,O=o.length,L=-1,J=i.length,X=Kt(y-O,0),Z=H(X+J),ae=!c;++f<X;)Z[f]=e[f];for(var ye=f;++L<J;)Z[ye+L]=i[L];for(;++E<O;)(ae||f<y)&&(Z[ye+o[E]]=e[f++]);return Z}function lr(e,i){var o=-1,c=e.length;for(i||(i=H(c));++o<c;)i[o]=e[o];return i}function Xr(e,i,o,c){var f=!o;o||(o={});for(var y=-1,E=i.length;++y<E;){var O=i[y],L=c?c(o[O],e[O],O,o,e):r;L===r&&(L=e[O]),f?ci(o,O,L):Kn(o,O,L)}return o}function Qg(e,i){return Xr(e,Za(e),i)}function Zg(e,i){return Xr(e,Ch(e),i)}function ao(e,i){return function(o,c){var f=Re(o)?np:bg,y=i?i():{};return f(o,e,me(c,2),y)}}function wn(e){return Ke(function(i,o){var c=-1,f=o.length,y=f>1?o[f-1]:r,E=f>2?o[2]:r;for(y=e.length>3&&typeof y=="function"?(f--,y):r,E&&ir(o[0],o[1],E)&&(y=f<3?r:y,f=1),i=ut(i);++c<f;){var O=o[c];O&&e(i,O,c,y)}return i})}function mh(e,i){return function(o,c){if(o==null)return o;if(!fr(o))return e(o,c);for(var f=o.length,y=i?f:-1,E=ut(o);(i?y--:++y<f)&&c(E[y],y,E)!==!1;);return o}}function wh(e){return function(i,o,c){for(var f=-1,y=ut(i),E=c(i),O=E.length;O--;){var L=E[e?O:++f];if(o(y[L],L,y)===!1)break}return i}}function e0(e,i,o){var c=i&K,f=Yn(e);function y(){var E=this&&this!==Xe&&this instanceof y?f:e;return E.apply(c?o:this,arguments)}return y}function bh(e){return function(i){i=it(i);var o=dn(i)?qr(i):r,c=o?o[0]:i.charAt(0),f=o?xi(o,1).join(""):i.slice(1);return c[e]()+f}}function bn(e){return function(i){return ya(ml(_l(i).replace(Dn,"")),e,"")}}function Yn(e){return function(){var i=arguments;switch(i.length){case 0:return new e;case 1:return new e(i[0]);case 2:return new e(i[0],i[1]);case 3:return new e(i[0],i[1],i[2]);case 4:return new e(i[0],i[1],i[2],i[3]);case 5:return new e(i[0],i[1],i[2],i[3],i[4]);case 6:return new e(i[0],i[1],i[2],i[3],i[4],i[5]);case 7:return new e(i[0],i[1],i[2],i[3],i[4],i[5],i[6])}var o=mn(e.prototype),c=e.apply(o,i);return wt(c)?c:o}}function t0(e,i,o){var c=Yn(e);function f(){for(var y=arguments.length,E=H(y),O=y,L=En(f);O--;)E[O]=arguments[O];var J=y<3&&E[0]!==L&&E[y-1]!==L?[]:wi(E,L);if(y-=J.length,y<o)return Oh(e,i,co,f.placeholder,r,E,J,r,r,o-y);var X=this&&this!==Xe&&this instanceof f?c:e;return kt(X,this,E)}return f}function Eh(e){return function(i,o,c){var f=ut(i);if(!fr(i)){var y=me(o,3);i=Vt(i),o=function(O){return y(f[O],O,f)}}var E=e(i,o,c);return E>-1?f[y?i[E]:E]:r}}function Sh(e){return hi(function(i){var o=i.length,c=o,f=Tr.prototype.thru;for(e&&i.reverse();c--;){var y=i[c];if(typeof y!="function")throw new Ar(p);if(f&&!E&&fo(y)=="wrapper")var E=new Tr([],!0)}for(c=E?c:o;++c<o;){y=i[c];var O=fo(y),L=O=="wrapper"?Xa(y):r;L&&tc(L[0])&&L[1]==(u|D|P|_)&&!L[4].length&&L[9]==1?E=E[fo(L[0])].apply(E,L[3]):E=y.length==1&&tc(y)?E[O]():E.thru(y)}return function(){var J=arguments,X=J[0];if(E&&J.length==1&&Re(X))return E.plant(X).value();for(var Z=0,ae=o?i[Z].apply(this,J):X;++Z<o;)ae=i[Z].call(this,ae);return ae}})}function co(e,i,o,c,f,y,E,O,L,J){var X=i&u,Z=i&K,ae=i&oe,ye=i&(D|S),be=i&W,ze=ae?r:Yn(e);function Ee(){for(var We=arguments.length,Qe=H(We),Er=We;Er--;)Qe[Er]=arguments[Er];if(ye)var nr=En(Ee),Sr=dp(Qe,nr);if(c&&(Qe=yh(Qe,c,f,ye)),y&&(Qe=_h(Qe,y,E,ye)),We-=Sr,ye&&We<J){var Rt=wi(Qe,nr);return Oh(e,i,co,Ee.placeholder,o,Qe,Rt,O,L,J-We)}var Br=Z?o:this,pi=ae?Br[e]:e;return We=Qe.length,O?Qe=b0(Qe,O):be&&We>1&&Qe.reverse(),X&&L<We&&(Qe.length=L),this&&this!==Xe&&this instanceof Ee&&(pi=ze||Yn(pi)),pi.apply(Br,Qe)}return Ee}function Ih(e,i){return function(o,c){return Tg(o,e,i(c),{})}}function uo(e,i){return function(o,c){var f;if(o===r&&c===r)return i;if(o!==r&&(f=o),c!==r){if(f===r)return c;typeof o=="string"||typeof c=="string"?(o=wr(o),c=wr(c)):(o=uh(o),c=uh(c)),f=e(o,c)}return f}}function Wa(e){return hi(function(i){return i=_t(i,mr(me())),Ke(function(o){var c=this;return e(i,function(f){return kt(f,c,o)})})})}function ho(e,i){i=i===r?" ":wr(i);var o=i.length;if(o<2)return o?qa(i,e):i;var c=qa(i,Js(e/pn(i)));return dn(i)?xi(qr(c),0,e).join(""):c.slice(0,e)}function r0(e,i,o,c){var f=i&K,y=Yn(e);function E(){for(var O=-1,L=arguments.length,J=-1,X=c.length,Z=H(X+L),ae=this&&this!==Xe&&this instanceof E?y:e;++J<X;)Z[J]=c[J];for(;L--;)Z[J++]=arguments[++O];return kt(ae,f?o:this,Z)}return E}function xh(e){return function(i,o,c){return c&&typeof c!="number"&&ir(i,o,c)&&(o=c=r),i=di(i),o===r?(o=i,i=0):o=di(o),c=c===r?i<o?1:-1:di(c),zg(i,o,c,e)}}function lo(e){return function(i,o){return typeof i=="string"&&typeof o=="string"||(i=Ur(i),o=Ur(o)),e(i,o)}}function Oh(e,i,o,c,f,y,E,O,L,J){var X=i&D,Z=X?E:r,ae=X?r:E,ye=X?y:r,be=X?r:y;i|=X?P:m,i&=~(X?m:P),i&T||(i&=~(K|oe));var ze=[e,i,f,ye,Z,be,ae,O,L,J],Ee=o.apply(r,ze);return tc(e)&&Mh(Ee,ze),Ee.placeholder=c,jh(Ee,e,i)}function Ga(e){var i=Bt[e];return function(o,c){if(o=Ur(o),c=c==null?0:Jt(Me(c),292),c&&ju(o)){var f=(it(o)+"e").split("e"),y=i(f[0]+"e"+(+f[1]+c));return f=(it(y)+"e").split("e"),+(f[0]+"e"+(+f[1]-c))}return i(o)}}var i0=yn&&1/qs(new yn([,-0]))[1]==te?function(e){return new yn(e)}:vc;function Ph(e){return function(i){var o=Xt(i);return o==Ie?Ia(i):o==xe?wp(i):fp(i,e(i))}}function ui(e,i,o,c,f,y,E,O){var L=i&oe;if(!L&&typeof e!="function")throw new Ar(p);var J=c?c.length:0;if(J||(i&=~(P|m),c=f=r),E=E===r?E:Kt(Me(E),0),O=O===r?O:Me(O),J-=f?f.length:0,i&m){var X=c,Z=f;c=f=r}var ae=L?r:Xa(e),ye=[e,i,o,c,f,X,Z,y,E,O];if(ae&&_0(ye,ae),e=ye[0],i=ye[1],o=ye[2],c=ye[3],f=ye[4],O=ye[9]=ye[9]===r?L?0:e.length:Kt(ye[9]-J,0),!O&&i&(D|S)&&(i&=~(D|S)),!i||i==K)var be=e0(e,i,o);else i==D||i==S?be=t0(e,i,O):(i==P||i==(K|P))&&!f.length?be=r0(e,i,o,c):be=co.apply(r,ye);var ze=ae?ah:Mh;return jh(ze(be,ye),e,i)}function Ah(e,i,o,c){return e===r||Hr(e,vn[o])&&!nt.call(c,o)?i:e}function Th(e,i,o,c,f,y){return wt(e)&&wt(i)&&(y.set(i,e),no(e,i,r,Th,y),y.delete(i)),e}function n0(e){return Qn(e)?r:e}function Nh(e,i,o,c,f,y){var E=o&z,O=e.length,L=i.length;if(O!=L&&!(E&&L>O))return!1;var J=y.get(e),X=y.get(i);if(J&&X)return J==i&&X==e;var Z=-1,ae=!0,ye=o&B?new zi:r;for(y.set(e,i),y.set(i,e);++Z<O;){var be=e[Z],ze=i[Z];if(c)var Ee=E?c(ze,be,Z,i,e,y):c(be,ze,Z,e,i,y);if(Ee!==r){if(Ee)continue;ae=!1;break}if(ye){if(!_a(i,function(We,Qe){if(!Mn(ye,Qe)&&(be===We||f(be,We,o,c,y)))return ye.push(Qe)})){ae=!1;break}}else if(!(be===ze||f(be,ze,o,c,y))){ae=!1;break}}return y.delete(e),y.delete(i),ae}function s0(e,i,o,c,f,y,E){switch(o){case Te:if(e.byteLength!=i.byteLength||e.byteOffset!=i.byteOffset)return!1;e=e.buffer,i=i.buffer;case Se:return!(e.byteLength!=i.byteLength||!y(new Vs(e),new Vs(i)));case F:case A:case He:return Hr(+e,+i);case I:return e.name==i.name&&e.message==i.message;case je:case Ue:return e==i+"";case Ie:var O=Ia;case xe:var L=c&z;if(O||(O=qs),e.size!=i.size&&!L)return!1;var J=E.get(e);if(J)return J==i;c|=B,E.set(e,i);var X=Nh(O(e),O(i),c,f,y,E);return E.delete(e),X;case Le:if(Bn)return Bn.call(e)==Bn.call(i)}return!1}function o0(e,i,o,c,f,y){var E=o&z,O=Ya(e),L=O.length,J=Ya(i),X=J.length;if(L!=X&&!E)return!1;for(var Z=L;Z--;){var ae=O[Z];if(!(E?ae in i:nt.call(i,ae)))return!1}var ye=y.get(e),be=y.get(i);if(ye&&be)return ye==i&&be==e;var ze=!0;y.set(e,i),y.set(i,e);for(var Ee=E;++Z<L;){ae=O[Z];var We=e[ae],Qe=i[ae];if(c)var Er=E?c(Qe,We,ae,i,e,y):c(We,Qe,ae,e,i,y);if(!(Er===r?We===Qe||f(We,Qe,o,c,y):Er)){ze=!1;break}Ee||(Ee=ae=="constructor")}if(ze&&!Ee){var nr=e.constructor,Sr=i.constructor;nr!=Sr&&"constructor"in e&&"constructor"in i&&!(typeof nr=="function"&&nr instanceof nr&&typeof Sr=="function"&&Sr instanceof Sr)&&(ze=!1)}return y.delete(e),y.delete(i),ze}function hi(e){return ic(Dh(e,r,kh),e+"")}function Ya(e){return Ju(e,Vt,Za)}function Ja(e){return Ju(e,dr,Ch)}var Xa=Qs?function(e){return Qs.get(e)}:vc;function fo(e){for(var i=e.name+"",o=_n[i],c=nt.call(_n,i)?o.length:0;c--;){var f=o[c],y=f.func;if(y==null||y==e)return f.name}return i}function En(e){var i=nt.call(g,"placeholder")?g:e;return i.placeholder}function me(){var e=g.iteratee||pc;return e=e===pc?Zu:e,arguments.length?e(arguments[0],arguments[1]):e}function po(e,i){var o=e.__data__;return p0(i)?o[typeof i=="string"?"string":"hash"]:o.map}function Qa(e){for(var i=Vt(e),o=i.length;o--;){var c=i[o],f=e[c];i[o]=[c,f,Lh(f)]}return i}function Ki(e,i){var o=yp(e,i);return Qu(o)?o:r}function a0(e){var i=nt.call(e,ji),o=e[ji];try{e[ji]=r;var c=!0}catch{}var f=Ks.call(e);return c&&(i?e[ji]=o:delete e[ji]),f}var Za=Oa?function(e){return e==null?[]:(e=ut(e),_i(Oa(e),function(i){return Fu.call(e,i)}))}:yc,Ch=Oa?function(e){for(var i=[];e;)mi(i,Za(e)),e=Ws(e);return i}:yc,Xt=rr;(Pa&&Xt(new Pa(new ArrayBuffer(1)))!=Te||qn&&Xt(new qn)!=Ie||Aa&&Xt(Aa.resolve())!=pt||yn&&Xt(new yn)!=xe||zn&&Xt(new zn)!=Ae)&&(Xt=function(e){var i=rr(e),o=i==Fe?e.constructor:r,c=o?ki(o):"";if(c)switch(c){case Bp:return Te;case Kp:return Ie;case kp:return pt;case Vp:return xe;case Wp:return Ae}return i});function c0(e,i,o){for(var c=-1,f=o.length;++c<f;){var y=o[c],E=y.size;switch(y.type){case"drop":e+=E;break;case"dropRight":i-=E;break;case"take":i=Jt(i,e+E);break;case"takeRight":e=Kt(e,i-E);break}}return{start:e,end:i}}function u0(e){var i=e.match(ht);return i?i[1].split(Mt):[]}function Rh(e,i,o){i=Ii(i,e);for(var c=-1,f=i.length,y=!1;++c<f;){var E=Qr(i[c]);if(!(y=e!=null&&o(e,E)))break;e=e[E]}return y||++c!=f?y:(f=e==null?0:e.length,!!f&&bo(f)&&li(E,f)&&(Re(e)||Vi(e)))}function h0(e){var i=e.length,o=new e.constructor(i);return i&&typeof e[0]=="string"&&nt.call(e,"index")&&(o.index=e.index,o.input=e.input),o}function Uh(e){return typeof e.constructor=="function"&&!Jn(e)?mn(Ws(e)):{}}function l0(e,i,o){var c=e.constructor;switch(i){case Se:return Va(e);case F:case A:return new c(+e);case Te:return Gg(e,o);case Be:case Pe:case Ve:case Ge:case et:case tt:case Je:case Zt:case ur:return gh(e,o);case Ie:return new c;case He:case Ue:return new c(e);case je:return Yg(e);case xe:return new c;case Le:return Jg(e)}}function f0(e,i){var o=i.length;if(!o)return e;var c=o-1;return i[c]=(o>1?"& ":"")+i[c],i=i.join(o>2?", ":" "),e.replace(Ot,`{
15
+ /* [wrapped with `+i+`] */
16
+ `)}function d0(e){return Re(e)||Vi(e)||!!(Mu&&e&&e[Mu])}function li(e,i){var o=typeof e;return i=i??G,!!i&&(o=="number"||o!="symbol"&&ra.test(e))&&e>-1&&e%1==0&&e<i}function ir(e,i,o){if(!wt(o))return!1;var c=typeof i;return(c=="number"?fr(o)&&li(i,o.length):c=="string"&&i in o)?Hr(o[i],e):!1}function ec(e,i){if(Re(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||br(e)?!0:$t.test(e)||!yt.test(e)||i!=null&&e in ut(i)}function p0(e){var i=typeof e;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?e!=="__proto__":e===null}function tc(e){var i=fo(e),o=g[i];if(typeof o!="function"||!(i in Ye.prototype))return!1;if(e===o)return!0;var c=Xa(o);return!!c&&e===c[0]}function g0(e){return!!Lu&&Lu in e}var v0=Hs?fi:_c;function Jn(e){var i=e&&e.constructor,o=typeof i=="function"&&i.prototype||vn;return e===o}function Lh(e){return e===e&&!wt(e)}function $h(e,i){return function(o){return o==null?!1:o[e]===i&&(i!==r||e in ut(o))}}function y0(e){var i=mo(e,function(c){return o.size===b&&o.clear(),c}),o=i.cache;return i}function _0(e,i){var o=e[1],c=i[1],f=o|c,y=f<(K|oe|u),E=c==u&&o==D||c==u&&o==_&&e[7].length<=i[8]||c==(u|_)&&i[7].length<=i[8]&&o==D;if(!(y||E))return e;c&K&&(e[2]=i[2],f|=o&K?0:T);var O=i[3];if(O){var L=e[3];e[3]=L?yh(L,O,i[4]):O,e[4]=L?wi(e[3],x):i[4]}return O=i[5],O&&(L=e[5],e[5]=L?_h(L,O,i[6]):O,e[6]=L?wi(e[5],x):i[6]),O=i[7],O&&(e[7]=O),c&u&&(e[8]=e[8]==null?i[8]:Jt(e[8],i[8])),e[9]==null&&(e[9]=i[9]),e[0]=i[0],e[1]=f,e}function m0(e){var i=[];if(e!=null)for(var o in ut(e))i.push(o);return i}function w0(e){return Ks.call(e)}function Dh(e,i,o){return i=Kt(i===r?e.length-1:i,0),function(){for(var c=arguments,f=-1,y=Kt(c.length-i,0),E=H(y);++f<y;)E[f]=c[i+f];f=-1;for(var O=H(i+1);++f<i;)O[f]=c[f];return O[i]=o(E),kt(e,this,O)}}function Fh(e,i){return i.length<2?e:Bi(e,Cr(i,0,-1))}function b0(e,i){for(var o=e.length,c=Jt(i.length,o),f=lr(e);c--;){var y=i[c];e[c]=li(y,o)?f[y]:r}return e}function rc(e,i){if(!(i==="constructor"&&typeof e[i]=="function")&&i!="__proto__")return e[i]}var Mh=qh(ah),Xn=Dp||function(e,i){return Xe.setTimeout(e,i)},ic=qh(Kg);function jh(e,i,o){var c=i+"";return ic(e,f0(c,E0(u0(c),o)))}function qh(e){var i=0,o=0;return function(){var c=qp(),f=ge-(c-o);if(o=c,f>0){if(++i>=ce)return arguments[0]}else i=0;return e.apply(r,arguments)}}function go(e,i){var o=-1,c=e.length,f=c-1;for(i=i===r?c:i;++o<i;){var y=ja(o,f),E=e[y];e[y]=e[o],e[o]=E}return e.length=i,e}var zh=y0(function(e){var i=[];return e.charCodeAt(0)===46&&i.push(""),e.replace(Dt,function(o,c,f,y){i.push(f?y.replace(Jo,"$1"):c||o)}),i});function Qr(e){if(typeof e=="string"||br(e))return e;var i=e+"";return i=="0"&&1/e==-te?"-0":i}function ki(e){if(e!=null){try{return Bs.call(e)}catch{}try{return e+""}catch{}}return""}function E0(e,i){return Pr(we,function(o){var c="_."+o[0];i&o[1]&&!Ms(e,c)&&e.push(c)}),e.sort()}function Hh(e){if(e instanceof Ye)return e.clone();var i=new Tr(e.__wrapped__,e.__chain__);return i.__actions__=lr(e.__actions__),i.__index__=e.__index__,i.__values__=e.__values__,i}function S0(e,i,o){(o?ir(e,i,o):i===r)?i=1:i=Kt(Me(i),0);var c=e==null?0:e.length;if(!c||i<1)return[];for(var f=0,y=0,E=H(Js(c/i));f<c;)E[y++]=Cr(e,f,f+=i);return E}function I0(e){for(var i=-1,o=e==null?0:e.length,c=0,f=[];++i<o;){var y=e[i];y&&(f[c++]=y)}return f}function x0(){var e=arguments.length;if(!e)return[];for(var i=H(e-1),o=arguments[0],c=e;c--;)i[c-1]=arguments[c];return mi(Re(o)?lr(o):[o],Gt(i,1))}var O0=Ke(function(e,i){return Ct(e)?kn(e,Gt(i,1,Ct,!0)):[]}),P0=Ke(function(e,i){var o=Rr(i);return Ct(o)&&(o=r),Ct(e)?kn(e,Gt(i,1,Ct,!0),me(o,2)):[]}),A0=Ke(function(e,i){var o=Rr(i);return Ct(o)&&(o=r),Ct(e)?kn(e,Gt(i,1,Ct,!0),r,o):[]});function T0(e,i,o){var c=e==null?0:e.length;return c?(i=o||i===r?1:Me(i),Cr(e,i<0?0:i,c)):[]}function N0(e,i,o){var c=e==null?0:e.length;return c?(i=o||i===r?1:Me(i),i=c-i,Cr(e,0,i<0?0:i)):[]}function C0(e,i){return e&&e.length?oo(e,me(i,3),!0,!0):[]}function R0(e,i){return e&&e.length?oo(e,me(i,3),!0):[]}function U0(e,i,o,c){var f=e==null?0:e.length;return f?(o&&typeof o!="number"&&ir(e,i,o)&&(o=0,c=f),xg(e,i,o,c)):[]}function Bh(e,i,o){var c=e==null?0:e.length;if(!c)return-1;var f=o==null?0:Me(o);return f<0&&(f=Kt(c+f,0)),js(e,me(i,3),f)}function Kh(e,i,o){var c=e==null?0:e.length;if(!c)return-1;var f=c-1;return o!==r&&(f=Me(o),f=o<0?Kt(c+f,0):Jt(f,c-1)),js(e,me(i,3),f,!0)}function kh(e){var i=e==null?0:e.length;return i?Gt(e,1):[]}function L0(e){var i=e==null?0:e.length;return i?Gt(e,te):[]}function $0(e,i){var o=e==null?0:e.length;return o?(i=i===r?1:Me(i),Gt(e,i)):[]}function D0(e){for(var i=-1,o=e==null?0:e.length,c={};++i<o;){var f=e[i];c[f[0]]=f[1]}return c}function Vh(e){return e&&e.length?e[0]:r}function F0(e,i,o){var c=e==null?0:e.length;if(!c)return-1;var f=o==null?0:Me(o);return f<0&&(f=Kt(c+f,0)),fn(e,i,f)}function M0(e){var i=e==null?0:e.length;return i?Cr(e,0,-1):[]}var j0=Ke(function(e){var i=_t(e,Ka);return i.length&&i[0]===e[0]?La(i):[]}),q0=Ke(function(e){var i=Rr(e),o=_t(e,Ka);return i===Rr(o)?i=r:o.pop(),o.length&&o[0]===e[0]?La(o,me(i,2)):[]}),z0=Ke(function(e){var i=Rr(e),o=_t(e,Ka);return i=typeof i=="function"?i:r,i&&o.pop(),o.length&&o[0]===e[0]?La(o,r,i):[]});function H0(e,i){return e==null?"":Mp.call(e,i)}function Rr(e){var i=e==null?0:e.length;return i?e[i-1]:r}function B0(e,i,o){var c=e==null?0:e.length;if(!c)return-1;var f=c;return o!==r&&(f=Me(o),f=f<0?Kt(c+f,0):Jt(f,c-1)),i===i?Ep(e,i,f):js(e,Ou,f,!0)}function K0(e,i){return e&&e.length?ih(e,Me(i)):r}var k0=Ke(Wh);function Wh(e,i){return e&&e.length&&i&&i.length?Ma(e,i):e}function V0(e,i,o){return e&&e.length&&i&&i.length?Ma(e,i,me(o,2)):e}function W0(e,i,o){return e&&e.length&&i&&i.length?Ma(e,i,r,o):e}var G0=hi(function(e,i){var o=e==null?0:e.length,c=Na(e,i);return oh(e,_t(i,function(f){return li(f,o)?+f:f}).sort(vh)),c});function Y0(e,i){var o=[];if(!(e&&e.length))return o;var c=-1,f=[],y=e.length;for(i=me(i,3);++c<y;){var E=e[c];i(E,c,e)&&(o.push(E),f.push(c))}return oh(e,f),o}function nc(e){return e==null?e:Hp.call(e)}function J0(e,i,o){var c=e==null?0:e.length;return c?(o&&typeof o!="number"&&ir(e,i,o)?(i=0,o=c):(i=i==null?0:Me(i),o=o===r?c:Me(o)),Cr(e,i,o)):[]}function X0(e,i){return so(e,i)}function Q0(e,i,o){return za(e,i,me(o,2))}function Z0(e,i){var o=e==null?0:e.length;if(o){var c=so(e,i);if(c<o&&Hr(e[c],i))return c}return-1}function e1(e,i){return so(e,i,!0)}function t1(e,i,o){return za(e,i,me(o,2),!0)}function r1(e,i){var o=e==null?0:e.length;if(o){var c=so(e,i,!0)-1;if(Hr(e[c],i))return c}return-1}function i1(e){return e&&e.length?ch(e):[]}function n1(e,i){return e&&e.length?ch(e,me(i,2)):[]}function s1(e){var i=e==null?0:e.length;return i?Cr(e,1,i):[]}function o1(e,i,o){return e&&e.length?(i=o||i===r?1:Me(i),Cr(e,0,i<0?0:i)):[]}function a1(e,i,o){var c=e==null?0:e.length;return c?(i=o||i===r?1:Me(i),i=c-i,Cr(e,i<0?0:i,c)):[]}function c1(e,i){return e&&e.length?oo(e,me(i,3),!1,!0):[]}function u1(e,i){return e&&e.length?oo(e,me(i,3)):[]}var h1=Ke(function(e){return Si(Gt(e,1,Ct,!0))}),l1=Ke(function(e){var i=Rr(e);return Ct(i)&&(i=r),Si(Gt(e,1,Ct,!0),me(i,2))}),f1=Ke(function(e){var i=Rr(e);return i=typeof i=="function"?i:r,Si(Gt(e,1,Ct,!0),r,i)});function d1(e){return e&&e.length?Si(e):[]}function p1(e,i){return e&&e.length?Si(e,me(i,2)):[]}function g1(e,i){return i=typeof i=="function"?i:r,e&&e.length?Si(e,r,i):[]}function sc(e){if(!(e&&e.length))return[];var i=0;return e=_i(e,function(o){if(Ct(o))return i=Kt(o.length,i),!0}),Ea(i,function(o){return _t(e,ma(o))})}function Gh(e,i){if(!(e&&e.length))return[];var o=sc(e);return i==null?o:_t(o,function(c){return kt(i,r,c)})}var v1=Ke(function(e,i){return Ct(e)?kn(e,i):[]}),y1=Ke(function(e){return Ba(_i(e,Ct))}),_1=Ke(function(e){var i=Rr(e);return Ct(i)&&(i=r),Ba(_i(e,Ct),me(i,2))}),m1=Ke(function(e){var i=Rr(e);return i=typeof i=="function"?i:r,Ba(_i(e,Ct),r,i)}),w1=Ke(sc);function b1(e,i){return fh(e||[],i||[],Kn)}function E1(e,i){return fh(e||[],i||[],Gn)}var S1=Ke(function(e){var i=e.length,o=i>1?e[i-1]:r;return o=typeof o=="function"?(e.pop(),o):r,Gh(e,o)});function Yh(e){var i=g(e);return i.__chain__=!0,i}function I1(e,i){return i(e),e}function vo(e,i){return i(e)}var x1=hi(function(e){var i=e.length,o=i?e[0]:0,c=this.__wrapped__,f=function(y){return Na(y,e)};return i>1||this.__actions__.length||!(c instanceof Ye)||!li(o)?this.thru(f):(c=c.slice(o,+o+(i?1:0)),c.__actions__.push({func:vo,args:[f],thisArg:r}),new Tr(c,this.__chain__).thru(function(y){return i&&!y.length&&y.push(r),y}))});function O1(){return Yh(this)}function P1(){return new Tr(this.value(),this.__chain__)}function A1(){this.__values__===r&&(this.__values__=ul(this.value()));var e=this.__index__>=this.__values__.length,i=e?r:this.__values__[this.__index__++];return{done:e,value:i}}function T1(){return this}function N1(e){for(var i,o=this;o instanceof eo;){var c=Hh(o);c.__index__=0,c.__values__=r,i?f.__wrapped__=c:i=c;var f=c;o=o.__wrapped__}return f.__wrapped__=e,i}function C1(){var e=this.__wrapped__;if(e instanceof Ye){var i=e;return this.__actions__.length&&(i=new Ye(this)),i=i.reverse(),i.__actions__.push({func:vo,args:[nc],thisArg:r}),new Tr(i,this.__chain__)}return this.thru(nc)}function R1(){return lh(this.__wrapped__,this.__actions__)}var U1=ao(function(e,i,o){nt.call(e,o)?++e[o]:ci(e,o,1)});function L1(e,i,o){var c=Re(e)?Iu:Ig;return o&&ir(e,i,o)&&(i=r),c(e,me(i,3))}function $1(e,i){var o=Re(e)?_i:Gu;return o(e,me(i,3))}var D1=Eh(Bh),F1=Eh(Kh);function M1(e,i){return Gt(yo(e,i),1)}function j1(e,i){return Gt(yo(e,i),te)}function q1(e,i,o){return o=o===r?1:Me(o),Gt(yo(e,i),o)}function Jh(e,i){var o=Re(e)?Pr:Ei;return o(e,me(i,3))}function Xh(e,i){var o=Re(e)?sp:Wu;return o(e,me(i,3))}var z1=ao(function(e,i,o){nt.call(e,o)?e[o].push(i):ci(e,o,[i])});function H1(e,i,o,c){e=fr(e)?e:In(e),o=o&&!c?Me(o):0;var f=e.length;return o<0&&(o=Kt(f+o,0)),Eo(e)?o<=f&&e.indexOf(i,o)>-1:!!f&&fn(e,i,o)>-1}var B1=Ke(function(e,i,o){var c=-1,f=typeof i=="function",y=fr(e)?H(e.length):[];return Ei(e,function(E){y[++c]=f?kt(i,E,o):Vn(E,i,o)}),y}),K1=ao(function(e,i,o){ci(e,o,i)});function yo(e,i){var o=Re(e)?_t:eh;return o(e,me(i,3))}function k1(e,i,o,c){return e==null?[]:(Re(i)||(i=i==null?[]:[i]),o=c?r:o,Re(o)||(o=o==null?[]:[o]),nh(e,i,o))}var V1=ao(function(e,i,o){e[o?0:1].push(i)},function(){return[[],[]]});function W1(e,i,o){var c=Re(e)?ya:Au,f=arguments.length<3;return c(e,me(i,4),o,f,Ei)}function G1(e,i,o){var c=Re(e)?op:Au,f=arguments.length<3;return c(e,me(i,4),o,f,Wu)}function Y1(e,i){var o=Re(e)?_i:Gu;return o(e,wo(me(i,3)))}function J1(e){var i=Re(e)?Bu:Hg;return i(e)}function X1(e,i,o){(o?ir(e,i,o):i===r)?i=1:i=Me(i);var c=Re(e)?mg:Bg;return c(e,i)}function Q1(e){var i=Re(e)?wg:kg;return i(e)}function Z1(e){if(e==null)return 0;if(fr(e))return Eo(e)?pn(e):e.length;var i=Xt(e);return i==Ie||i==xe?e.size:Da(e).length}function ev(e,i,o){var c=Re(e)?_a:Vg;return o&&ir(e,i,o)&&(i=r),c(e,me(i,3))}var tv=Ke(function(e,i){if(e==null)return[];var o=i.length;return o>1&&ir(e,i[0],i[1])?i=[]:o>2&&ir(i[0],i[1],i[2])&&(i=[i[0]]),nh(e,Gt(i,1),[])}),_o=$p||function(){return Xe.Date.now()};function rv(e,i){if(typeof i!="function")throw new Ar(p);return e=Me(e),function(){if(--e<1)return i.apply(this,arguments)}}function Qh(e,i,o){return i=o?r:i,i=e&&i==null?e.length:i,ui(e,u,r,r,r,r,i)}function Zh(e,i){var o;if(typeof i!="function")throw new Ar(p);return e=Me(e),function(){return--e>0&&(o=i.apply(this,arguments)),e<=1&&(i=r),o}}var oc=Ke(function(e,i,o){var c=K;if(o.length){var f=wi(o,En(oc));c|=P}return ui(e,c,i,o,f)}),el=Ke(function(e,i,o){var c=K|oe;if(o.length){var f=wi(o,En(el));c|=P}return ui(i,c,e,o,f)});function tl(e,i,o){i=o?r:i;var c=ui(e,D,r,r,r,r,r,i);return c.placeholder=tl.placeholder,c}function rl(e,i,o){i=o?r:i;var c=ui(e,S,r,r,r,r,r,i);return c.placeholder=rl.placeholder,c}function il(e,i,o){var c,f,y,E,O,L,J=0,X=!1,Z=!1,ae=!0;if(typeof e!="function")throw new Ar(p);i=Ur(i)||0,wt(o)&&(X=!!o.leading,Z="maxWait"in o,y=Z?Kt(Ur(o.maxWait)||0,i):y,ae="trailing"in o?!!o.trailing:ae);function ye(Rt){var Br=c,pi=f;return c=f=r,J=Rt,E=e.apply(pi,Br),E}function be(Rt){return J=Rt,O=Xn(We,i),X?ye(Rt):E}function ze(Rt){var Br=Rt-L,pi=Rt-J,El=i-Br;return Z?Jt(El,y-pi):El}function Ee(Rt){var Br=Rt-L,pi=Rt-J;return L===r||Br>=i||Br<0||Z&&pi>=y}function We(){var Rt=_o();if(Ee(Rt))return Qe(Rt);O=Xn(We,ze(Rt))}function Qe(Rt){return O=r,ae&&c?ye(Rt):(c=f=r,E)}function Er(){O!==r&&dh(O),J=0,c=L=f=O=r}function nr(){return O===r?E:Qe(_o())}function Sr(){var Rt=_o(),Br=Ee(Rt);if(c=arguments,f=this,L=Rt,Br){if(O===r)return be(L);if(Z)return dh(O),O=Xn(We,i),ye(L)}return O===r&&(O=Xn(We,i)),E}return Sr.cancel=Er,Sr.flush=nr,Sr}var iv=Ke(function(e,i){return Vu(e,1,i)}),nv=Ke(function(e,i,o){return Vu(e,Ur(i)||0,o)});function sv(e){return ui(e,W)}function mo(e,i){if(typeof e!="function"||i!=null&&typeof i!="function")throw new Ar(p);var o=function(){var c=arguments,f=i?i.apply(this,c):c[0],y=o.cache;if(y.has(f))return y.get(f);var E=e.apply(this,c);return o.cache=y.set(f,E)||y,E};return o.cache=new(mo.Cache||ai),o}mo.Cache=ai;function wo(e){if(typeof e!="function")throw new Ar(p);return function(){var i=arguments;switch(i.length){case 0:return!e.call(this);case 1:return!e.call(this,i[0]);case 2:return!e.call(this,i[0],i[1]);case 3:return!e.call(this,i[0],i[1],i[2])}return!e.apply(this,i)}}function ov(e){return Zh(2,e)}var av=Wg(function(e,i){i=i.length==1&&Re(i[0])?_t(i[0],mr(me())):_t(Gt(i,1),mr(me()));var o=i.length;return Ke(function(c){for(var f=-1,y=Jt(c.length,o);++f<y;)c[f]=i[f].call(this,c[f]);return kt(e,this,c)})}),ac=Ke(function(e,i){var o=wi(i,En(ac));return ui(e,P,r,i,o)}),nl=Ke(function(e,i){var o=wi(i,En(nl));return ui(e,m,r,i,o)}),cv=hi(function(e,i){return ui(e,_,r,r,r,i)});function uv(e,i){if(typeof e!="function")throw new Ar(p);return i=i===r?i:Me(i),Ke(e,i)}function hv(e,i){if(typeof e!="function")throw new Ar(p);return i=i==null?0:Kt(Me(i),0),Ke(function(o){var c=o[i],f=xi(o,0,i);return c&&mi(f,c),kt(e,this,f)})}function lv(e,i,o){var c=!0,f=!0;if(typeof e!="function")throw new Ar(p);return wt(o)&&(c="leading"in o?!!o.leading:c,f="trailing"in o?!!o.trailing:f),il(e,i,{leading:c,maxWait:i,trailing:f})}function fv(e){return Qh(e,1)}function dv(e,i){return ac(ka(i),e)}function pv(){if(!arguments.length)return[];var e=arguments[0];return Re(e)?e:[e]}function gv(e){return Nr(e,U)}function vv(e,i){return i=typeof i=="function"?i:r,Nr(e,U,i)}function yv(e){return Nr(e,$|U)}function _v(e,i){return i=typeof i=="function"?i:r,Nr(e,$|U,i)}function mv(e,i){return i==null||ku(e,i,Vt(i))}function Hr(e,i){return e===i||e!==e&&i!==i}var wv=lo(Ua),bv=lo(function(e,i){return e>=i}),Vi=Xu(function(){return arguments}())?Xu:function(e){return Pt(e)&&nt.call(e,"callee")&&!Fu.call(e,"callee")},Re=H.isArray,Ev=tr?mr(tr):Ng;function fr(e){return e!=null&&bo(e.length)&&!fi(e)}function Ct(e){return Pt(e)&&fr(e)}function Sv(e){return e===!0||e===!1||Pt(e)&&rr(e)==F}var Oi=Fp||_c,Iv=jr?mr(jr):Cg;function xv(e){return Pt(e)&&e.nodeType===1&&!Qn(e)}function Ov(e){if(e==null)return!0;if(fr(e)&&(Re(e)||typeof e=="string"||typeof e.splice=="function"||Oi(e)||Sn(e)||Vi(e)))return!e.length;var i=Xt(e);if(i==Ie||i==xe)return!e.size;if(Jn(e))return!Da(e).length;for(var o in e)if(nt.call(e,o))return!1;return!0}function Pv(e,i){return Wn(e,i)}function Av(e,i,o){o=typeof o=="function"?o:r;var c=o?o(e,i):r;return c===r?Wn(e,i,r,o):!!c}function cc(e){if(!Pt(e))return!1;var i=rr(e);return i==I||i==h||typeof e.message=="string"&&typeof e.name=="string"&&!Qn(e)}function Tv(e){return typeof e=="number"&&ju(e)}function fi(e){if(!wt(e))return!1;var i=rr(e);return i==ne||i==fe||i==M||i==gt}function sl(e){return typeof e=="number"&&e==Me(e)}function bo(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=G}function wt(e){var i=typeof e;return e!=null&&(i=="object"||i=="function")}function Pt(e){return e!=null&&typeof e=="object"}var ol=Or?mr(Or):Ug;function Nv(e,i){return e===i||$a(e,i,Qa(i))}function Cv(e,i,o){return o=typeof o=="function"?o:r,$a(e,i,Qa(i),o)}function Rv(e){return al(e)&&e!=+e}function Uv(e){if(v0(e))throw new Ne(l);return Qu(e)}function Lv(e){return e===null}function $v(e){return e==null}function al(e){return typeof e=="number"||Pt(e)&&rr(e)==He}function Qn(e){if(!Pt(e)||rr(e)!=Fe)return!1;var i=Ws(e);if(i===null)return!0;var o=nt.call(i,"constructor")&&i.constructor;return typeof o=="function"&&o instanceof o&&Bs.call(o)==Cp}var uc=Yr?mr(Yr):Lg;function Dv(e){return sl(e)&&e>=-G&&e<=G}var cl=Fn?mr(Fn):$g;function Eo(e){return typeof e=="string"||!Re(e)&&Pt(e)&&rr(e)==Ue}function br(e){return typeof e=="symbol"||Pt(e)&&rr(e)==Le}var Sn=Mi?mr(Mi):Dg;function Fv(e){return e===r}function Mv(e){return Pt(e)&&Xt(e)==Ae}function jv(e){return Pt(e)&&rr(e)==$e}var qv=lo(Fa),zv=lo(function(e,i){return e<=i});function ul(e){if(!e)return[];if(fr(e))return Eo(e)?qr(e):lr(e);if(jn&&e[jn])return mp(e[jn]());var i=Xt(e),o=i==Ie?Ia:i==xe?qs:In;return o(e)}function di(e){if(!e)return e===0?e:0;if(e=Ur(e),e===te||e===-te){var i=e<0?-1:1;return i*ee}return e===e?e:0}function Me(e){var i=di(e),o=i%1;return i===i?o?i-o:i:0}function hl(e){return e?Hi(Me(e),0,re):0}function Ur(e){if(typeof e=="number")return e;if(br(e))return Y;if(wt(e)){var i=typeof e.valueOf=="function"?e.valueOf():e;e=wt(i)?i+"":i}if(typeof e!="string")return e===0?e:+e;e=Tu(e);var o=Zo.test(e);return o||ta.test(e)?Ce(e.slice(2),o?2:8):Qo.test(e)?Y:+e}function ll(e){return Xr(e,dr(e))}function Hv(e){return e?Hi(Me(e),-G,G):e===0?e:0}function it(e){return e==null?"":wr(e)}var Bv=wn(function(e,i){if(Jn(i)||fr(i)){Xr(i,Vt(i),e);return}for(var o in i)nt.call(i,o)&&Kn(e,o,i[o])}),fl=wn(function(e,i){Xr(i,dr(i),e)}),So=wn(function(e,i,o,c){Xr(i,dr(i),e,c)}),Kv=wn(function(e,i,o,c){Xr(i,Vt(i),e,c)}),kv=hi(Na);function Vv(e,i){var o=mn(e);return i==null?o:Ku(o,i)}var Wv=Ke(function(e,i){e=ut(e);var o=-1,c=i.length,f=c>2?i[2]:r;for(f&&ir(i[0],i[1],f)&&(c=1);++o<c;)for(var y=i[o],E=dr(y),O=-1,L=E.length;++O<L;){var J=E[O],X=e[J];(X===r||Hr(X,vn[J])&&!nt.call(e,J))&&(e[J]=y[J])}return e}),Gv=Ke(function(e){return e.push(r,Th),kt(dl,r,e)});function Yv(e,i){return xu(e,me(i,3),Jr)}function Jv(e,i){return xu(e,me(i,3),Ra)}function Xv(e,i){return e==null?e:Ca(e,me(i,3),dr)}function Qv(e,i){return e==null?e:Yu(e,me(i,3),dr)}function Zv(e,i){return e&&Jr(e,me(i,3))}function ey(e,i){return e&&Ra(e,me(i,3))}function ty(e){return e==null?[]:io(e,Vt(e))}function ry(e){return e==null?[]:io(e,dr(e))}function hc(e,i,o){var c=e==null?r:Bi(e,i);return c===r?o:c}function iy(e,i){return e!=null&&Rh(e,i,Og)}function lc(e,i){return e!=null&&Rh(e,i,Pg)}var ny=Ih(function(e,i,o){i!=null&&typeof i.toString!="function"&&(i=Ks.call(i)),e[i]=o},dc(pr)),sy=Ih(function(e,i,o){i!=null&&typeof i.toString!="function"&&(i=Ks.call(i)),nt.call(e,i)?e[i].push(o):e[i]=[o]},me),oy=Ke(Vn);function Vt(e){return fr(e)?Hu(e):Da(e)}function dr(e){return fr(e)?Hu(e,!0):Fg(e)}function ay(e,i){var o={};return i=me(i,3),Jr(e,function(c,f,y){ci(o,i(c,f,y),c)}),o}function cy(e,i){var o={};return i=me(i,3),Jr(e,function(c,f,y){ci(o,f,i(c,f,y))}),o}var uy=wn(function(e,i,o){no(e,i,o)}),dl=wn(function(e,i,o,c){no(e,i,o,c)}),hy=hi(function(e,i){var o={};if(e==null)return o;var c=!1;i=_t(i,function(y){return y=Ii(y,e),c||(c=y.length>1),y}),Xr(e,Ja(e),o),c&&(o=Nr(o,$|j|U,n0));for(var f=i.length;f--;)Ha(o,i[f]);return o});function ly(e,i){return pl(e,wo(me(i)))}var fy=hi(function(e,i){return e==null?{}:jg(e,i)});function pl(e,i){if(e==null)return{};var o=_t(Ja(e),function(c){return[c]});return i=me(i),sh(e,o,function(c,f){return i(c,f[0])})}function dy(e,i,o){i=Ii(i,e);var c=-1,f=i.length;for(f||(f=1,e=r);++c<f;){var y=e==null?r:e[Qr(i[c])];y===r&&(c=f,y=o),e=fi(y)?y.call(e):y}return e}function py(e,i,o){return e==null?e:Gn(e,i,o)}function gy(e,i,o,c){return c=typeof c=="function"?c:r,e==null?e:Gn(e,i,o,c)}var gl=Ph(Vt),vl=Ph(dr);function vy(e,i,o){var c=Re(e),f=c||Oi(e)||Sn(e);if(i=me(i,4),o==null){var y=e&&e.constructor;f?o=c?new y:[]:wt(e)?o=fi(y)?mn(Ws(e)):{}:o={}}return(f?Pr:Jr)(e,function(E,O,L){return i(o,E,O,L)}),o}function yy(e,i){return e==null?!0:Ha(e,i)}function _y(e,i,o){return e==null?e:hh(e,i,ka(o))}function my(e,i,o,c){return c=typeof c=="function"?c:r,e==null?e:hh(e,i,ka(o),c)}function In(e){return e==null?[]:Sa(e,Vt(e))}function wy(e){return e==null?[]:Sa(e,dr(e))}function by(e,i,o){return o===r&&(o=i,i=r),o!==r&&(o=Ur(o),o=o===o?o:0),i!==r&&(i=Ur(i),i=i===i?i:0),Hi(Ur(e),i,o)}function Ey(e,i,o){return i=di(i),o===r?(o=i,i=0):o=di(o),e=Ur(e),Ag(e,i,o)}function Sy(e,i,o){if(o&&typeof o!="boolean"&&ir(e,i,o)&&(i=o=r),o===r&&(typeof i=="boolean"?(o=i,i=r):typeof e=="boolean"&&(o=e,e=r)),e===r&&i===r?(e=0,i=1):(e=di(e),i===r?(i=e,e=0):i=di(i)),e>i){var c=e;e=i,i=c}if(o||e%1||i%1){var f=qu();return Jt(e+f*(i-e+at("1e-"+((f+"").length-1))),i)}return ja(e,i)}var Iy=bn(function(e,i,o){return i=i.toLowerCase(),e+(o?yl(i):i)});function yl(e){return fc(it(e).toLowerCase())}function _l(e){return e=it(e),e&&e.replace(ni,pp).replace(pa,"")}function xy(e,i,o){e=it(e),i=wr(i);var c=e.length;o=o===r?c:Hi(Me(o),0,c);var f=o;return o-=i.length,o>=0&&e.slice(o,f)==i}function Oy(e){return e=it(e),e&&vt.test(e)?e.replace(Ui,gp):e}function Py(e){return e=it(e),e&&Ft.test(e)?e.replace(It,"\\$&"):e}var Ay=bn(function(e,i,o){return e+(o?"-":"")+i.toLowerCase()}),Ty=bn(function(e,i,o){return e+(o?" ":"")+i.toLowerCase()}),Ny=bh("toLowerCase");function Cy(e,i,o){e=it(e),i=Me(i);var c=i?pn(e):0;if(!i||c>=i)return e;var f=(i-c)/2;return ho(Xs(f),o)+e+ho(Js(f),o)}function Ry(e,i,o){e=it(e),i=Me(i);var c=i?pn(e):0;return i&&c<i?e+ho(i-c,o):e}function Uy(e,i,o){e=it(e),i=Me(i);var c=i?pn(e):0;return i&&c<i?ho(i-c,o)+e:e}function Ly(e,i,o){return o||i==null?i=0:i&&(i=+i),zp(it(e).replace(xt,""),i||0)}function $y(e,i,o){return(o?ir(e,i,o):i===r)?i=1:i=Me(i),qa(it(e),i)}function Dy(){var e=arguments,i=it(e[0]);return e.length<3?i:i.replace(e[1],e[2])}var Fy=bn(function(e,i,o){return e+(o?"_":"")+i.toLowerCase()});function My(e,i,o){return o&&typeof o!="number"&&ir(e,i,o)&&(i=o=r),o=o===r?re:o>>>0,o?(e=it(e),e&&(typeof i=="string"||i!=null&&!uc(i))&&(i=wr(i),!i&&dn(e))?xi(qr(e),0,o):e.split(i,o)):[]}var jy=bn(function(e,i,o){return e+(o?" ":"")+fc(i)});function qy(e,i,o){return e=it(e),o=o==null?0:Hi(Me(o),0,e.length),i=wr(i),e.slice(o,o+i.length)==i}function zy(e,i,o){var c=g.templateSettings;o&&ir(e,i,o)&&(i=r),e=it(e),i=So({},i,c,Ah);var f=So({},i.imports,c.imports,Ah),y=Vt(f),E=Sa(f,y),O,L,J=0,X=i.interpolate||sn,Z="__p += '",ae=xa((i.escape||sn).source+"|"+X.source+"|"+(X===mt?Xo:sn).source+"|"+(i.evaluate||sn).source+"|$","g"),ye="//# sourceURL="+(nt.call(i,"sourceURL")?(i.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++ga+"]")+`
17
+ `;e.replace(ae,function(Ee,We,Qe,Er,nr,Sr){return Qe||(Qe=Er),Z+=e.slice(J,Sr).replace(ia,vp),We&&(O=!0,Z+=`' +
18
+ __e(`+We+`) +
19
+ '`),nr&&(L=!0,Z+=`';
20
+ `+nr+`;
21
+ __p += '`),Qe&&(Z+=`' +
22
+ ((__t = (`+Qe+`)) == null ? '' : __t) +
23
+ '`),J=Sr+Ee.length,Ee}),Z+=`';
24
+ `;var be=nt.call(i,"variable")&&i.variable;if(!be)Z=`with (obj) {
25
+ `+Z+`
26
+ }
27
+ `;else if(Yo.test(be))throw new Ne(d);Z=(L?Z.replace(Wr,""):Z).replace(er,"$1").replace(ii,"$1;"),Z="function("+(be||"obj")+`) {
28
+ `+(be?"":`obj || (obj = {});
29
+ `)+"var __t, __p = ''"+(O?", __e = _.escape":"")+(L?`, __j = Array.prototype.join;
30
+ function print() { __p += __j.call(arguments, '') }
31
+ `:`;
32
+ `)+Z+`return __p
33
+ }`;var ze=wl(function(){return rt(y,ye+"return "+Z).apply(r,E)});if(ze.source=Z,cc(ze))throw ze;return ze}function Hy(e){return it(e).toLowerCase()}function By(e){return it(e).toUpperCase()}function Ky(e,i,o){if(e=it(e),e&&(o||i===r))return Tu(e);if(!e||!(i=wr(i)))return e;var c=qr(e),f=qr(i),y=Nu(c,f),E=Cu(c,f)+1;return xi(c,y,E).join("")}function ky(e,i,o){if(e=it(e),e&&(o||i===r))return e.slice(0,Uu(e)+1);if(!e||!(i=wr(i)))return e;var c=qr(e),f=Cu(c,qr(i))+1;return xi(c,0,f).join("")}function Vy(e,i,o){if(e=it(e),e&&(o||i===r))return e.replace(xt,"");if(!e||!(i=wr(i)))return e;var c=qr(e),f=Nu(c,qr(i));return xi(c,f).join("")}function Wy(e,i){var o=V,c=se;if(wt(i)){var f="separator"in i?i.separator:f;o="length"in i?Me(i.length):o,c="omission"in i?wr(i.omission):c}e=it(e);var y=e.length;if(dn(e)){var E=qr(e);y=E.length}if(o>=y)return e;var O=o-pn(c);if(O<1)return c;var L=E?xi(E,0,O).join(""):e.slice(0,O);if(f===r)return L+c;if(E&&(O+=L.length-O),uc(f)){if(e.slice(O).search(f)){var J,X=L;for(f.global||(f=xa(f.source,it(xr.exec(f))+"g")),f.lastIndex=0;J=f.exec(X);)var Z=J.index;L=L.slice(0,Z===r?O:Z)}}else if(e.indexOf(wr(f),O)!=O){var ae=L.lastIndexOf(f);ae>-1&&(L=L.slice(0,ae))}return L+c}function Gy(e){return e=it(e),e&&bt.test(e)?e.replace(vi,Sp):e}var Yy=bn(function(e,i,o){return e+(o?" ":"")+i.toUpperCase()}),fc=bh("toUpperCase");function ml(e,i,o){return e=it(e),i=o?r:i,i===r?_p(e)?Op(e):up(e):e.match(i)||[]}var wl=Ke(function(e,i){try{return kt(e,r,i)}catch(o){return cc(o)?o:new Ne(o)}}),Jy=hi(function(e,i){return Pr(i,function(o){o=Qr(o),ci(e,o,oc(e[o],e))}),e});function Xy(e){var i=e==null?0:e.length,o=me();return e=i?_t(e,function(c){if(typeof c[1]!="function")throw new Ar(p);return[o(c[0]),c[1]]}):[],Ke(function(c){for(var f=-1;++f<i;){var y=e[f];if(kt(y[0],this,c))return kt(y[1],this,c)}})}function Qy(e){return Sg(Nr(e,$))}function dc(e){return function(){return e}}function Zy(e,i){return e==null||e!==e?i:e}var e_=Sh(),t_=Sh(!0);function pr(e){return e}function pc(e){return Zu(typeof e=="function"?e:Nr(e,$))}function r_(e){return th(Nr(e,$))}function i_(e,i){return rh(e,Nr(i,$))}var n_=Ke(function(e,i){return function(o){return Vn(o,e,i)}}),s_=Ke(function(e,i){return function(o){return Vn(e,o,i)}});function gc(e,i,o){var c=Vt(i),f=io(i,c);o==null&&!(wt(i)&&(f.length||!c.length))&&(o=i,i=e,e=this,f=io(i,Vt(i)));var y=!(wt(o)&&"chain"in o)||!!o.chain,E=fi(e);return Pr(f,function(O){var L=i[O];e[O]=L,E&&(e.prototype[O]=function(){var J=this.__chain__;if(y||J){var X=e(this.__wrapped__),Z=X.__actions__=lr(this.__actions__);return Z.push({func:L,args:arguments,thisArg:e}),X.__chain__=J,X}return L.apply(e,mi([this.value()],arguments))})}),e}function o_(){return Xe._===this&&(Xe._=Rp),this}function vc(){}function a_(e){return e=Me(e),Ke(function(i){return ih(i,e)})}var c_=Wa(_t),u_=Wa(Iu),h_=Wa(_a);function bl(e){return ec(e)?ma(Qr(e)):qg(e)}function l_(e){return function(i){return e==null?r:Bi(e,i)}}var f_=xh(),d_=xh(!0);function yc(){return[]}function _c(){return!1}function p_(){return{}}function g_(){return""}function v_(){return!0}function y_(e,i){if(e=Me(e),e<1||e>G)return[];var o=re,c=Jt(e,re);i=me(i),e-=re;for(var f=Ea(c,i);++o<e;)i(o);return f}function __(e){return Re(e)?_t(e,Qr):br(e)?[e]:lr(zh(it(e)))}function m_(e){var i=++Np;return it(e)+i}var w_=uo(function(e,i){return e+i},0),b_=Ga("ceil"),E_=uo(function(e,i){return e/i},1),S_=Ga("floor");function I_(e){return e&&e.length?ro(e,pr,Ua):r}function x_(e,i){return e&&e.length?ro(e,me(i,2),Ua):r}function O_(e){return Pu(e,pr)}function P_(e,i){return Pu(e,me(i,2))}function A_(e){return e&&e.length?ro(e,pr,Fa):r}function T_(e,i){return e&&e.length?ro(e,me(i,2),Fa):r}var N_=uo(function(e,i){return e*i},1),C_=Ga("round"),R_=uo(function(e,i){return e-i},0);function U_(e){return e&&e.length?ba(e,pr):0}function L_(e,i){return e&&e.length?ba(e,me(i,2)):0}return g.after=rv,g.ary=Qh,g.assign=Bv,g.assignIn=fl,g.assignInWith=So,g.assignWith=Kv,g.at=kv,g.before=Zh,g.bind=oc,g.bindAll=Jy,g.bindKey=el,g.castArray=pv,g.chain=Yh,g.chunk=S0,g.compact=I0,g.concat=x0,g.cond=Xy,g.conforms=Qy,g.constant=dc,g.countBy=U1,g.create=Vv,g.curry=tl,g.curryRight=rl,g.debounce=il,g.defaults=Wv,g.defaultsDeep=Gv,g.defer=iv,g.delay=nv,g.difference=O0,g.differenceBy=P0,g.differenceWith=A0,g.drop=T0,g.dropRight=N0,g.dropRightWhile=C0,g.dropWhile=R0,g.fill=U0,g.filter=$1,g.flatMap=M1,g.flatMapDeep=j1,g.flatMapDepth=q1,g.flatten=kh,g.flattenDeep=L0,g.flattenDepth=$0,g.flip=sv,g.flow=e_,g.flowRight=t_,g.fromPairs=D0,g.functions=ty,g.functionsIn=ry,g.groupBy=z1,g.initial=M0,g.intersection=j0,g.intersectionBy=q0,g.intersectionWith=z0,g.invert=ny,g.invertBy=sy,g.invokeMap=B1,g.iteratee=pc,g.keyBy=K1,g.keys=Vt,g.keysIn=dr,g.map=yo,g.mapKeys=ay,g.mapValues=cy,g.matches=r_,g.matchesProperty=i_,g.memoize=mo,g.merge=uy,g.mergeWith=dl,g.method=n_,g.methodOf=s_,g.mixin=gc,g.negate=wo,g.nthArg=a_,g.omit=hy,g.omitBy=ly,g.once=ov,g.orderBy=k1,g.over=c_,g.overArgs=av,g.overEvery=u_,g.overSome=h_,g.partial=ac,g.partialRight=nl,g.partition=V1,g.pick=fy,g.pickBy=pl,g.property=bl,g.propertyOf=l_,g.pull=k0,g.pullAll=Wh,g.pullAllBy=V0,g.pullAllWith=W0,g.pullAt=G0,g.range=f_,g.rangeRight=d_,g.rearg=cv,g.reject=Y1,g.remove=Y0,g.rest=uv,g.reverse=nc,g.sampleSize=X1,g.set=py,g.setWith=gy,g.shuffle=Q1,g.slice=J0,g.sortBy=tv,g.sortedUniq=i1,g.sortedUniqBy=n1,g.split=My,g.spread=hv,g.tail=s1,g.take=o1,g.takeRight=a1,g.takeRightWhile=c1,g.takeWhile=u1,g.tap=I1,g.throttle=lv,g.thru=vo,g.toArray=ul,g.toPairs=gl,g.toPairsIn=vl,g.toPath=__,g.toPlainObject=ll,g.transform=vy,g.unary=fv,g.union=h1,g.unionBy=l1,g.unionWith=f1,g.uniq=d1,g.uniqBy=p1,g.uniqWith=g1,g.unset=yy,g.unzip=sc,g.unzipWith=Gh,g.update=_y,g.updateWith=my,g.values=In,g.valuesIn=wy,g.without=v1,g.words=ml,g.wrap=dv,g.xor=y1,g.xorBy=_1,g.xorWith=m1,g.zip=w1,g.zipObject=b1,g.zipObjectDeep=E1,g.zipWith=S1,g.entries=gl,g.entriesIn=vl,g.extend=fl,g.extendWith=So,gc(g,g),g.add=w_,g.attempt=wl,g.camelCase=Iy,g.capitalize=yl,g.ceil=b_,g.clamp=by,g.clone=gv,g.cloneDeep=yv,g.cloneDeepWith=_v,g.cloneWith=vv,g.conformsTo=mv,g.deburr=_l,g.defaultTo=Zy,g.divide=E_,g.endsWith=xy,g.eq=Hr,g.escape=Oy,g.escapeRegExp=Py,g.every=L1,g.find=D1,g.findIndex=Bh,g.findKey=Yv,g.findLast=F1,g.findLastIndex=Kh,g.findLastKey=Jv,g.floor=S_,g.forEach=Jh,g.forEachRight=Xh,g.forIn=Xv,g.forInRight=Qv,g.forOwn=Zv,g.forOwnRight=ey,g.get=hc,g.gt=wv,g.gte=bv,g.has=iy,g.hasIn=lc,g.head=Vh,g.identity=pr,g.includes=H1,g.indexOf=F0,g.inRange=Ey,g.invoke=oy,g.isArguments=Vi,g.isArray=Re,g.isArrayBuffer=Ev,g.isArrayLike=fr,g.isArrayLikeObject=Ct,g.isBoolean=Sv,g.isBuffer=Oi,g.isDate=Iv,g.isElement=xv,g.isEmpty=Ov,g.isEqual=Pv,g.isEqualWith=Av,g.isError=cc,g.isFinite=Tv,g.isFunction=fi,g.isInteger=sl,g.isLength=bo,g.isMap=ol,g.isMatch=Nv,g.isMatchWith=Cv,g.isNaN=Rv,g.isNative=Uv,g.isNil=$v,g.isNull=Lv,g.isNumber=al,g.isObject=wt,g.isObjectLike=Pt,g.isPlainObject=Qn,g.isRegExp=uc,g.isSafeInteger=Dv,g.isSet=cl,g.isString=Eo,g.isSymbol=br,g.isTypedArray=Sn,g.isUndefined=Fv,g.isWeakMap=Mv,g.isWeakSet=jv,g.join=H0,g.kebabCase=Ay,g.last=Rr,g.lastIndexOf=B0,g.lowerCase=Ty,g.lowerFirst=Ny,g.lt=qv,g.lte=zv,g.max=I_,g.maxBy=x_,g.mean=O_,g.meanBy=P_,g.min=A_,g.minBy=T_,g.stubArray=yc,g.stubFalse=_c,g.stubObject=p_,g.stubString=g_,g.stubTrue=v_,g.multiply=N_,g.nth=K0,g.noConflict=o_,g.noop=vc,g.now=_o,g.pad=Cy,g.padEnd=Ry,g.padStart=Uy,g.parseInt=Ly,g.random=Sy,g.reduce=W1,g.reduceRight=G1,g.repeat=$y,g.replace=Dy,g.result=dy,g.round=C_,g.runInContext=R,g.sample=J1,g.size=Z1,g.snakeCase=Fy,g.some=ev,g.sortedIndex=X0,g.sortedIndexBy=Q0,g.sortedIndexOf=Z0,g.sortedLastIndex=e1,g.sortedLastIndexBy=t1,g.sortedLastIndexOf=r1,g.startCase=jy,g.startsWith=qy,g.subtract=R_,g.sum=U_,g.sumBy=L_,g.template=zy,g.times=y_,g.toFinite=di,g.toInteger=Me,g.toLength=hl,g.toLower=Hy,g.toNumber=Ur,g.toSafeInteger=Hv,g.toString=it,g.toUpper=By,g.trim=Ky,g.trimEnd=ky,g.trimStart=Vy,g.truncate=Wy,g.unescape=Gy,g.uniqueId=m_,g.upperCase=Yy,g.upperFirst=fc,g.each=Jh,g.eachRight=Xh,g.first=Vh,gc(g,function(){var e={};return Jr(g,function(i,o){nt.call(g.prototype,o)||(e[o]=i)}),e}(),{chain:!1}),g.VERSION=s,Pr(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){g[e].placeholder=g}),Pr(["drop","take"],function(e,i){Ye.prototype[e]=function(o){o=o===r?1:Kt(Me(o),0);var c=this.__filtered__&&!i?new Ye(this):this.clone();return c.__filtered__?c.__takeCount__=Jt(o,c.__takeCount__):c.__views__.push({size:Jt(o,re),type:e+(c.__dir__<0?"Right":"")}),c},Ye.prototype[e+"Right"]=function(o){return this.reverse()[e](o).reverse()}}),Pr(["filter","map","takeWhile"],function(e,i){var o=i+1,c=o==N||o==le;Ye.prototype[e]=function(f){var y=this.clone();return y.__iteratees__.push({iteratee:me(f,3),type:o}),y.__filtered__=y.__filtered__||c,y}}),Pr(["head","last"],function(e,i){var o="take"+(i?"Right":"");Ye.prototype[e]=function(){return this[o](1).value()[0]}}),Pr(["initial","tail"],function(e,i){var o="drop"+(i?"":"Right");Ye.prototype[e]=function(){return this.__filtered__?new Ye(this):this[o](1)}}),Ye.prototype.compact=function(){return this.filter(pr)},Ye.prototype.find=function(e){return this.filter(e).head()},Ye.prototype.findLast=function(e){return this.reverse().find(e)},Ye.prototype.invokeMap=Ke(function(e,i){return typeof e=="function"?new Ye(this):this.map(function(o){return Vn(o,e,i)})}),Ye.prototype.reject=function(e){return this.filter(wo(me(e)))},Ye.prototype.slice=function(e,i){e=Me(e);var o=this;return o.__filtered__&&(e>0||i<0)?new Ye(o):(e<0?o=o.takeRight(-e):e&&(o=o.drop(e)),i!==r&&(i=Me(i),o=i<0?o.dropRight(-i):o.take(i-e)),o)},Ye.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Ye.prototype.toArray=function(){return this.take(re)},Jr(Ye.prototype,function(e,i){var o=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),f=g[c?"take"+(i=="last"?"Right":""):i],y=c||/^find/.test(i);f&&(g.prototype[i]=function(){var E=this.__wrapped__,O=c?[1]:arguments,L=E instanceof Ye,J=O[0],X=L||Re(E),Z=function(We){var Qe=f.apply(g,mi([We],O));return c&&ae?Qe[0]:Qe};X&&o&&typeof J=="function"&&J.length!=1&&(L=X=!1);var ae=this.__chain__,ye=!!this.__actions__.length,be=y&&!ae,ze=L&&!ye;if(!y&&X){E=ze?E:new Ye(this);var Ee=e.apply(E,O);return Ee.__actions__.push({func:vo,args:[Z],thisArg:r}),new Tr(Ee,ae)}return be&&ze?e.apply(this,O):(Ee=this.thru(Z),be?c?Ee.value()[0]:Ee.value():Ee)})}),Pr(["pop","push","shift","sort","splice","unshift"],function(e){var i=zs[e],o=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);g.prototype[e]=function(){var f=arguments;if(c&&!this.__chain__){var y=this.value();return i.apply(Re(y)?y:[],f)}return this[o](function(E){return i.apply(Re(E)?E:[],f)})}}),Jr(Ye.prototype,function(e,i){var o=g[i];if(o){var c=o.name+"";nt.call(_n,c)||(_n[c]=[]),_n[c].push({name:i,func:o})}}),_n[co(r,oe).name]=[{name:"wrapper",func:r}],Ye.prototype.clone=Gp,Ye.prototype.reverse=Yp,Ye.prototype.value=Jp,g.prototype.at=x1,g.prototype.chain=O1,g.prototype.commit=P1,g.prototype.next=A1,g.prototype.plant=N1,g.prototype.reverse=C1,g.prototype.toJSON=g.prototype.valueOf=g.prototype.value=R1,g.prototype.first=g.prototype.head,jn&&(g.prototype[jn]=T1),g},gn=Pp();Nt?((Nt.exports=gn)._=gn,ct._=gn):Xe._=gn}).call(ls)})(Xc,Xc.exports);var g5=Object.defineProperty,v5=Object.defineProperties,y5=Object.getOwnPropertyDescriptors,Vf=Object.getOwnPropertySymbols,_5=Object.prototype.hasOwnProperty,m5=Object.prototype.propertyIsEnumerable,Wf=(n,t,r)=>t in n?g5(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,xo=(n,t)=>{for(var r in t||(t={}))_5.call(t,r)&&Wf(n,r,t[r]);if(Vf)for(var r of Vf(t))m5.call(t,r)&&Wf(n,r,t[r]);return n},w5=(n,t)=>v5(n,y5(t));function Dr(n,t,r){let s;const a=Qc(n);return t.rpcMap&&(s=t.rpcMap[a]),s||(s=`${p5}?chainId=eip155:${a}&projectId=${r}`),s}function Qc(n){return n.includes("eip155")?Number(n.split(":")[1]):Number(n)}function rp(n){return n.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function b5(n,t){const r=Object.keys(t.namespaces).filter(a=>a.includes(n));if(!r.length)return[];const s=[];return r.forEach(a=>{const l=t.namespaces[a].accounts;s.push(...l)}),s}function E5(n={},t={}){const r=Gf(n),s=Gf(t);return Xc.exports.merge(r,s)}function Gf(n){var t,r,s,a;const l={};if(!Tn(n))return l;for(const[p,d]of Object.entries(n)){const v=gu(p)?[p]:d.chains,b=d.methods||[],x=d.events||[],$=d.rpcMap||{},j=Ao(p);l[j]=w5(xo(xo({},l[j]),d),{chains:Sc(v,(t=l[j])==null?void 0:t.chains),methods:Sc(b,(r=l[j])==null?void 0:r.methods),events:Sc(x,(s=l[j])==null?void 0:s.events),rpcMap:xo(xo({},$),(a=l[j])==null?void 0:a.rpcMap)})}return l}function S5(n){return n.includes(":")?n.split(":")[2]:n}function I5(n){const t={};for(const[r,s]of Object.entries(n)){const a=s.methods||[],l=s.events||[],p=s.accounts||[],d=gu(r)?[r]:s.chains?s.chains:rp(s.accounts);t[r]={chains:d,methods:a,events:l,accounts:p}}return t}const ip={},Lt=n=>ip[n],Dc=(n,t)=>{ip[n]=t};class x5{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=Lt("events"),this.client=Lt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Dr(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Ri.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Dr(t,this.namespace);return typeof s>"u"?void 0:new Ci(new nn(s,Lt("disableProviderPing")))}}class O5{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=Lt("events"),this.client=Lt("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,r){const s=Qc(t);if(!this.httpProviders[s]){const a=r||Dr(`${this.name}:${s}`,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${s}`);this.setHttpProvider(s,a)}this.chainId=s,this.events.emit(Ri.DEFAULT_CHAIN_CHANGED,`${this.name}:${s}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,r){const s=r||Dr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new Ci(new nn(s,Lt("disableProviderPing")))}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=Qc(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,s;let a=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const l=parseInt(a,16);if(this.isChainApproved(l))this.setDefaultChain(`${l}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:a}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${l}`);else throw new Error(`Failed to switch to chain 'eip155:${l}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class P5{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=Lt("events"),this.client=Lt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(!this.httpProviders[t]){const s=r||Dr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(Ri.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Dr(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new Ci(new nn(s,Lt("disableProviderPing")))}}class A5{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=Lt("events"),this.client=Lt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Dr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Ri.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Dr(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new Ci(new nn(s,Lt("disableProviderPing")))}}class T5{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=Lt("events"),this.client=Lt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Ri.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r);t[r]=this.createHttpProvider(r,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||this.getCardanoRPCUrl(t);return typeof s>"u"?void 0:new Ci(new nn(s,Lt("disableProviderPing")))}}class N5{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=Lt("events"),this.client=Lt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(!this.httpProviders[t]){const s=r||Dr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(Ri.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Dr(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new Ci(new nn(s,Lt("disableProviderPing")))}}class C5{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=Lt("events"),this.client=Lt("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(!this.httpProviders[t]){const s=r||Dr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(Ri.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Dr(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new Ci(new nn(s,Lt("disableProviderPing")))}}var R5=Object.defineProperty,U5=Object.defineProperties,L5=Object.getOwnPropertyDescriptors,Yf=Object.getOwnPropertySymbols,$5=Object.prototype.hasOwnProperty,D5=Object.prototype.propertyIsEnumerable,Jf=(n,t,r)=>t in n?R5(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,Oo=(n,t)=>{for(var r in t||(t={}))$5.call(t,r)&&Jf(n,r,t[r]);if(Yf)for(var r of Yf(t))D5.call(t,r)&&Jf(n,r,t[r]);return n},Fc=(n,t)=>U5(n,L5(t));class Eu{constructor(t){this.events=new tu,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Ze.pino(Ze.getDefaultLoggerOptions({level:(t==null?void 0:t.logger)||Kf})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Eu(t);return await r.initialize(),r}async request(t,r){const[s,a]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Oo({},t),chainId:`${s}:${a}`,topic:this.session.topic})}sendAsync(t,r,s){this.request(t,s).then(a=>r(null,a)).catch(a=>r(a,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:Ut("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:a}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await a().then(l=>{this.session=l,this.namespaces||(this.namespaces=I5(l.namespaces),this.persist("namespaces",this.namespaces))}).catch(l=>{if(l.message!==ep)throw l;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,a]=this.validateChain(t);this.getProvider(s).setDefaultChain(a,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(ri(r)){for(const s of r)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await c5.init({logger:this.providerOpts.logger||Kf,relayUrl:this.providerOpts.relayUrl||l5,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(r=>Ao(r)))];Dc("client",this.client),Dc("events",this.events),Dc("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=b5(r,this.session),a=rp(s),l=E5(this.namespaces,this.optionalNamespaces),p=Fc(Oo({},l[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new O5({namespace:p});break;case"solana":this.rpcProviders[r]=new P5({namespace:p});break;case"cosmos":this.rpcProviders[r]=new A5({namespace:p});break;case"polkadot":this.rpcProviders[r]=new x5({namespace:p});break;case"cip34":this.rpcProviders[r]=new T5({namespace:p});break;case"elrond":this.rpcProviders[r]=new N5({namespace:p});break;case"multiversx":this.rpcProviders[r]=new C5({namespace:p});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:r}=t,{event:s}=r;if(s.name==="accountsChanged"){const a=s.data;a&&ri(a)&&this.events.emit("accountsChanged",a.map(S5))}else s.name==="chainChanged"?this.onChainChanged(r.chainId):this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:a}=r,l=(s=this.client)==null?void 0:s.session.get(t);this.session=Fc(Oo({},l),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",Fc(Oo({},Ut("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Ri.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:s,sessionProperties:a}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=a,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(t){const[r,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(p=>Ao(p)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const a=Ao(Object.keys(this.namespaces)[0]),l=this.rpcProviders[a].getDefaultChain();return[a,l]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[a,l]=this.validateChain(t);r||this.getProvider(a).setDefaultChain(l),((s=this.namespaces[a])!=null?s:this.namespaces[`${a}:${l}`]).defaultChain=l,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",l)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${kf}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${kf}/${t}`)}}const F5=Eu,M5="wc",j5="ethereum_provider",q5=`${M5}@2:${j5}:`,z5="https://rpc.walletconnect.com/v1/",Zc=["eth_sendTransaction","personal_sign"],H5=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],eu=["chainChanged","accountsChanged"],B5=["message","disconnect","connect"];var K5=Object.defineProperty,k5=Object.defineProperties,V5=Object.getOwnPropertyDescriptors,Xf=Object.getOwnPropertySymbols,W5=Object.prototype.hasOwnProperty,G5=Object.prototype.propertyIsEnumerable,Qf=(n,t,r)=>t in n?K5(n,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[t]=r,fs=(n,t)=>{for(var r in t||(t={}))W5.call(t,r)&&Qf(n,r,t[r]);if(Xf)for(var r of Xf(t))G5.call(t,r)&&Qf(n,r,t[r]);return n},Zf=(n,t)=>k5(n,V5(t));function Fo(n){return Number(n[0].split(":")[1])}function Mc(n){return`0x${n.toString(16)}`}function Y5(n){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:l,optionalEvents:p,rpcMap:d}=n;if(!ri(t))throw new Error("Invalid chains");const v={chains:t,methods:s||Zc,events:l||eu,rpcMap:fs({},t.length?{[Fo(t)]:d[Fo(t)]}:{})},b=l==null?void 0:l.filter(U=>!eu.includes(U)),x=s==null?void 0:s.filter(U=>!Zc.includes(U));if(!r&&!p&&!a&&!(b!=null&&b.length)&&!(x!=null&&x.length))return{required:t.length?v:void 0};const $=(b==null?void 0:b.length)&&(x==null?void 0:x.length)||!r,j={chains:[...new Set($?v.chains.concat(r||[]):r)],methods:[...new Set(v.methods.concat(a!=null&&a.length?a:H5))],events:[...new Set(v.events.concat(p||B5))],rpcMap:d};return{required:t.length?v:void 0,optional:r.length?j:void 0}}class Su{constructor(){this.events=new Fr.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=q5,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Su;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:s}=Y5(this.rpc);try{const a=await new Promise(async(p,d)=>{var v;this.rpc.showQrModal&&((v=this.modal)==null||v.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),d(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Zf(fs({namespaces:fs({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{p(b)}).catch(b=>{d(new Error(b.message))})});if(!a)return;this.setChainIds(this.rpc.chains);const l=yw(a.namespaces,[this.namespace]);this.setAccounts(l),this.events.emit("connect",{chainId:Mc(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",Mc(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",Zf(fs({},Ut("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",Mc(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,a]=t.split(":");return{chainId:`${r}:${s}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const a=(r=t==null?void 0:t.chains)!=null?r:[],l=(s=t==null?void 0:t.optionalChains)!=null?s:[],p=a.concat(l);if(!p.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const d=a.length?(t==null?void 0:t.methods)||Zc:[],v=a.length?(t==null?void 0:t.events)||eu:[],b=(t==null?void 0:t.optionalMethods)||[],x=(t==null?void 0:t.optionalEvents)||[],$=(t==null?void 0:t.rpcMap)||this.buildRpcMap(p,t.projectId),j=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(U=>this.formatChainId(U)),optionalChains:l.map(U=>this.formatChainId(U)),methods:d,events:v,optionalMethods:b,optionalEvents:x,rpcMap:$,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:j,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(a=>{s[a]=this.getRpcUrl(a,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?Fo(this.rpc.chains):Fo(this.rpc.optionalChains),this.signer=await F5.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:s}=await j_(()=>import("./index-5be098ea.js").then(a=>a.i),["assets/index-5be098ea.js","assets/index-c0709bb3.js","assets/index-9ea1eca8.css"]);r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(fs({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:s,rpcMap:a}=t;r&&ri(r)&&(this.rpc.chains=r.map(l=>this.formatChainId(l)),r.forEach(l=>{this.rpc.rpcMap[l]=(a==null?void 0:a[l])||this.getRpcUrl(l)})),s&&ri(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(l=>this.formatChainId(l)),s.forEach(l=>{this.rpc.rpcMap[l]=(a==null?void 0:a[l])||this.getRpcUrl(l)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${z5}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const oS=Su;export{oS as EthereumProvider,B5 as OPTIONAL_EVENTS,H5 as OPTIONAL_METHODS,eu as REQUIRED_EVENTS,Zc as REQUIRED_METHODS,Su as default};