/*! For license information please see 871.01aa4a7b.chunk.js.LICENSE.txt */ (self.webpackChunkcharts=self.webpackChunkcharts||[]).push([[871],{44519:(t,e,r)=>{"use strict";e.Xx=e._w=e.aP=e.KS=e.jQ=void 0;const n=r(14701),i=r(21956),s=r(63227);function o(t){const e=new Float64Array(16);if(t)for(let r=0;r>16&1),r[e-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);const t=r[15]>>16&1;r[14]&=65535,v(n,r,1-t)}for(let i=0;i<16;i++)t[2*i]=255&n[i],t[2*i+1]=n[i]>>8}function m(t,e){let r=0;for(let n=0;n<32;n++)r|=t[n]^e[n];return(1&r-1>>>8)-1}function w(t,e){const r=new Uint8Array(32),n=new Uint8Array(32);return y(r,t),y(n,e),m(r,n)}function _(t){const e=new Uint8Array(32);return y(e,t),1&e[0]}function b(t,e,r){for(let n=0;n<16;n++)t[n]=e[n]+r[n]}function E(t,e,r){for(let n=0;n<16;n++)t[n]=e[n]-r[n]}function I(t,e,r){let n,i,s=0,o=0,a=0,c=0,u=0,h=0,l=0,f=0,p=0,d=0,g=0,v=0,y=0,m=0,w=0,_=0,b=0,E=0,I=0,P=0,S=0,O=0,x=0,R=0,C=0,A=0,j=0,T=0,N=0,q=0,D=0,L=r[0],M=r[1],z=r[2],k=r[3],U=r[4],H=r[5],V=r[6],B=r[7],K=r[8],F=r[9],G=r[10],Z=r[11],W=r[12],J=r[13],Q=r[14],Y=r[15];n=e[0],s+=n*L,o+=n*M,a+=n*z,c+=n*k,u+=n*U,h+=n*H,l+=n*V,f+=n*B,p+=n*K,d+=n*F,g+=n*G,v+=n*Z,y+=n*W,m+=n*J,w+=n*Q,_+=n*Y,n=e[1],o+=n*L,a+=n*M,c+=n*z,u+=n*k,h+=n*U,l+=n*H,f+=n*V,p+=n*B,d+=n*K,g+=n*F,v+=n*G,y+=n*Z,m+=n*W,w+=n*J,_+=n*Q,b+=n*Y,n=e[2],a+=n*L,c+=n*M,u+=n*z,h+=n*k,l+=n*U,f+=n*H,p+=n*V,d+=n*B,g+=n*K,v+=n*F,y+=n*G,m+=n*Z,w+=n*W,_+=n*J,b+=n*Q,E+=n*Y,n=e[3],c+=n*L,u+=n*M,h+=n*z,l+=n*k,f+=n*U,p+=n*H,d+=n*V,g+=n*B,v+=n*K,y+=n*F,m+=n*G,w+=n*Z,_+=n*W,b+=n*J,E+=n*Q,I+=n*Y,n=e[4],u+=n*L,h+=n*M,l+=n*z,f+=n*k,p+=n*U,d+=n*H,g+=n*V,v+=n*B,y+=n*K,m+=n*F,w+=n*G,_+=n*Z,b+=n*W,E+=n*J,I+=n*Q,P+=n*Y,n=e[5],h+=n*L,l+=n*M,f+=n*z,p+=n*k,d+=n*U,g+=n*H,v+=n*V,y+=n*B,m+=n*K,w+=n*F,_+=n*G,b+=n*Z,E+=n*W,I+=n*J,P+=n*Q,S+=n*Y,n=e[6],l+=n*L,f+=n*M,p+=n*z,d+=n*k,g+=n*U,v+=n*H,y+=n*V,m+=n*B,w+=n*K,_+=n*F,b+=n*G,E+=n*Z,I+=n*W,P+=n*J,S+=n*Q,O+=n*Y,n=e[7],f+=n*L,p+=n*M,d+=n*z,g+=n*k,v+=n*U,y+=n*H,m+=n*V,w+=n*B,_+=n*K,b+=n*F,E+=n*G,I+=n*Z,P+=n*W,S+=n*J,O+=n*Q,x+=n*Y,n=e[8],p+=n*L,d+=n*M,g+=n*z,v+=n*k,y+=n*U,m+=n*H,w+=n*V,_+=n*B,b+=n*K,E+=n*F,I+=n*G,P+=n*Z,S+=n*W,O+=n*J,x+=n*Q,R+=n*Y,n=e[9],d+=n*L,g+=n*M,v+=n*z,y+=n*k,m+=n*U,w+=n*H,_+=n*V,b+=n*B,E+=n*K,I+=n*F,P+=n*G,S+=n*Z,O+=n*W,x+=n*J,R+=n*Q,C+=n*Y,n=e[10],g+=n*L,v+=n*M,y+=n*z,m+=n*k,w+=n*U,_+=n*H,b+=n*V,E+=n*B,I+=n*K,P+=n*F,S+=n*G,O+=n*Z,x+=n*W,R+=n*J,C+=n*Q,A+=n*Y,n=e[11],v+=n*L,y+=n*M,m+=n*z,w+=n*k,_+=n*U,b+=n*H,E+=n*V,I+=n*B,P+=n*K,S+=n*F,O+=n*G,x+=n*Z,R+=n*W,C+=n*J,A+=n*Q,j+=n*Y,n=e[12],y+=n*L,m+=n*M,w+=n*z,_+=n*k,b+=n*U,E+=n*H,I+=n*V,P+=n*B,S+=n*K,O+=n*F,x+=n*G,R+=n*Z,C+=n*W,A+=n*J,j+=n*Q,T+=n*Y,n=e[13],m+=n*L,w+=n*M,_+=n*z,b+=n*k,E+=n*U,I+=n*H,P+=n*V,S+=n*B,O+=n*K,x+=n*F,R+=n*G,C+=n*Z,A+=n*W,j+=n*J,T+=n*Q,N+=n*Y,n=e[14],w+=n*L,_+=n*M,b+=n*z,E+=n*k,I+=n*U,P+=n*H,S+=n*V,O+=n*B,x+=n*K,R+=n*F,C+=n*G,A+=n*Z,j+=n*W,T+=n*J,N+=n*Q,q+=n*Y,n=e[15],_+=n*L,b+=n*M,E+=n*z,I+=n*k,P+=n*U,S+=n*H,O+=n*V,x+=n*B,R+=n*K,C+=n*F,A+=n*G,j+=n*Z,T+=n*W,N+=n*J,q+=n*Q,D+=n*Y,s+=38*b,o+=38*E,a+=38*I,c+=38*P,u+=38*S,h+=38*O,l+=38*x,f+=38*R,p+=38*C,d+=38*A,g+=38*j,v+=38*T,y+=38*N,m+=38*q,w+=38*D,i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=n-65536*i,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,n=_+i+65535,i=Math.floor(n/65536),_=n-65536*i,s+=i-1+37*(i-1),t[0]=s,t[1]=o,t[2]=a,t[3]=c,t[4]=u,t[5]=h,t[6]=l,t[7]=f,t[8]=p,t[9]=d,t[10]=g,t[11]=v,t[12]=y,t[13]=m,t[14]=w,t[15]=_}function P(t,e){I(t,e,e)}function S(t,e){const r=o();let n;for(n=0;n<16;n++)r[n]=e[n];for(n=253;n>=0;n--)P(r,r),2!==n&&4!==n&&I(r,r,e);for(n=0;n<16;n++)t[n]=r[n]}function O(t,e){const r=o(),n=o(),i=o(),s=o(),a=o(),c=o(),u=o(),l=o(),f=o();E(r,t[1],t[0]),E(f,e[1],e[0]),I(r,r,f),b(n,t[0],t[1]),b(f,e[0],e[1]),I(n,n,f),I(i,t[3],e[3]),I(i,i,h),I(s,t[2],e[2]),b(s,s,s),E(a,n,r),E(c,s,i),b(u,s,i),b(l,n,r),I(t[0],a,c),I(t[1],l,u),I(t[2],u,c),I(t[3],a,l)}function x(t,e,r){for(let n=0;n<4;n++)v(t[n],e[n],r)}function R(t,e){const r=o(),n=o(),i=o();S(i,e[2]),I(r,e[0],i),I(n,e[1],i),y(t,n),t[31]^=_(r)<<7}function C(t,e,r){d(t[0],a),d(t[1],c),d(t[2],c),d(t[3],a);for(let n=255;n>=0;--n){const i=r[n/8|0]>>(7&n)&1;x(t,e,i),O(e,t),O(t,t),x(t,e,i)}}function A(t,e){const r=[o(),o(),o(),o()];d(r[0],l),d(r[1],f),d(r[2],c),I(r[3],l,f),C(t,r,e)}function j(t){if(t.length!==e.aP)throw new Error("ed25519: seed must be ".concat(e.aP," bytes"));const r=(0,i.hash)(t);r[0]&=248,r[31]&=127,r[31]|=64;const n=new Uint8Array(32),s=[o(),o(),o(),o()];A(s,r),R(n,s);const a=new Uint8Array(64);return a.set(t),a.set(n,32),{publicKey:n,secretKey:a}}e._w=j;const T=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 N(t,e){let r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i>4)*T[i],r=e[i]>>8,e[i]&=255;for(i=0;i<32;i++)e[i]-=r*T[i];for(n=0;n<32;n++)e[n+1]+=e[n]>>8,t[n]=255&e[n]}function q(t){const e=new Float64Array(64);for(let r=0;r<64;r++)e[r]=t[r];for(let r=0;r<64;r++)t[r]=0;N(t,e)}function D(t,e){const r=o(),n=o(),i=o(),s=o(),h=o(),l=o(),f=o();return d(t[2],c),function(t,e){for(let r=0;r<16;r++)t[r]=e[2*r]+(e[2*r+1]<<8);t[15]&=32767}(t[1],e),P(i,t[1]),I(s,i,u),E(i,i,t[2]),b(s,t[2],s),P(h,s),P(l,h),I(f,l,h),I(r,f,i),I(r,r,s),function(t,e){const r=o();let n;for(n=0;n<16;n++)r[n]=e[n];for(n=250;n>=0;n--)P(r,r),1!==n&&I(r,r,e);for(n=0;n<16;n++)t[n]=r[n]}(r,r),I(r,r,i),I(r,r,s),I(r,r,s),I(t[0],r,s),P(n,t[0]),I(n,n,s),w(n,i)&&I(t[0],t[0],p),P(n,t[0]),I(n,n,s),w(n,i)?-1:(_(t[0])===e[31]>>7&&E(t[0],a,t[0]),I(t[3],t[0],t[1]),0)}e.Xx=function(t,e){const r=new Float64Array(64),n=[o(),o(),o(),o()],s=(0,i.hash)(t.subarray(0,32));s[0]&=248,s[31]&=127,s[31]|=64;const a=new Uint8Array(64);a.set(s.subarray(32),32);const c=new i.SHA512;c.update(a.subarray(32)),c.update(e);const u=c.digest();c.clean(),q(u),A(n,u),R(a,n),c.reset(),c.update(a.subarray(0,32)),c.update(t.subarray(32)),c.update(e);const h=c.digest();q(h);for(let i=0;i<32;i++)r[i]=u[i];for(let i=0;i<32;i++)for(let t=0;t<32;t++)r[i+t]+=h[i]*s[t];return N(a.subarray(32),r),a}},21956:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(79734),i=r(63227);e.DIGEST_LENGTH=64,e.BLOCK_SIZE=128;var s=function(){function t(){this.digestLength=e.DIGEST_LENGTH,this.blockSize=e.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 t.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},t.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},t.prototype.clean=function(){i.wipe(this._buffer),i.wipe(this._tempHi),i.wipe(this._tempLo),this.reset()},t.prototype.update=function(t,r){if(void 0===r&&(r=t.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var n=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=t[n++],r--;this._bufferLength===this.blockSize&&(a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(n=a(this._tempHi,this._tempLo,this._stateHi,this._stateLo,t,n,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=t[n++],r--;return this},t.prototype.finish=function(t){if(!this._finished){var e=this._bytesHashed,r=this._bufferLength,i=e/536870912|0,s=e<<3,o=e%128<112?128:256;this._buffer[r]=128;for(var c=r+1;c0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},t.prototype.restoreState=function(t){return this._stateHi.set(t.stateHi),this._stateLo.set(t.stateLo),this._bufferLength=t.bufferLength,t.buffer&&this._buffer.set(t.buffer),this._bytesHashed=t.bytesHashed,this._finished=!1,this},t.prototype.cleanSavedState=function(t){i.wipe(t.stateHi),i.wipe(t.stateLo),t.buffer&&i.wipe(t.buffer),t.bufferLength=0,t.bytesHashed=0},t}();e.SHA512=s;var o=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 a(t,e,r,i,s,a,c){for(var u,h,l,f,p,d,g,v,y=r[0],m=r[1],w=r[2],_=r[3],b=r[4],E=r[5],I=r[6],P=r[7],S=i[0],O=i[1],x=i[2],R=i[3],C=i[4],A=i[5],j=i[6],T=i[7];c>=128;){for(var N=0;N<16;N++){var q=8*N+a;t[N]=n.readUint32BE(s,q),e[N]=n.readUint32BE(s,q+4)}for(N=0;N<80;N++){var D,L,M=y,z=m,k=w,U=_,H=b,V=E,B=I,K=S,F=O,G=x,Z=R,W=C,J=A,Q=j;if(p=65535&(h=T),d=h>>>16,g=65535&(u=P),v=u>>>16,p+=65535&(h=(C>>>14|b<<18)^(C>>>18|b<<14)^(b>>>9|C<<23)),d+=h>>>16,g+=65535&(u=(b>>>14|C<<18)^(b>>>18|C<<14)^(C>>>9|b<<23)),v+=u>>>16,p+=65535&(h=C&A^~C&j),d+=h>>>16,g+=65535&(u=b&E^~b&I),v+=u>>>16,u=o[2*N],p+=65535&(h=o[2*N+1]),d+=h>>>16,g+=65535&u,v+=u>>>16,u=t[N%16],d+=(h=e[N%16])>>>16,g+=65535&u,v+=u>>>16,g+=(d+=(p+=65535&h)>>>16)>>>16,p=65535&(h=f=65535&p|d<<16),d=h>>>16,g=65535&(u=l=65535&g|(v+=g>>>16)<<16),v=u>>>16,p+=65535&(h=(S>>>28|y<<4)^(y>>>2|S<<30)^(y>>>7|S<<25)),d+=h>>>16,g+=65535&(u=(y>>>28|S<<4)^(S>>>2|y<<30)^(S>>>7|y<<25)),v+=u>>>16,d+=(h=S&O^S&x^O&x)>>>16,g+=65535&(u=y&m^y&w^m&w),v+=u>>>16,D=65535&(g+=(d+=(p+=65535&h)>>>16)>>>16)|(v+=g>>>16)<<16,L=65535&p|d<<16,p=65535&(h=Z),d=h>>>16,g=65535&(u=U),v=u>>>16,d+=(h=f)>>>16,g+=65535&(u=l),v+=u>>>16,m=M,w=z,_=k,b=U=65535&(g+=(d+=(p+=65535&h)>>>16)>>>16)|(v+=g>>>16)<<16,E=H,I=V,P=B,y=D,O=K,x=F,R=G,C=Z=65535&p|d<<16,A=W,j=J,T=Q,S=L,N%16===15)for(q=0;q<16;q++)u=t[q],p=65535&(h=e[q]),d=h>>>16,g=65535&u,v=u>>>16,u=t[(q+9)%16],p+=65535&(h=e[(q+9)%16]),d+=h>>>16,g+=65535&u,v+=u>>>16,l=t[(q+1)%16],p+=65535&(h=((f=e[(q+1)%16])>>>1|l<<31)^(f>>>8|l<<24)^(f>>>7|l<<25)),d+=h>>>16,g+=65535&(u=(l>>>1|f<<31)^(l>>>8|f<<24)^l>>>7),v+=u>>>16,l=t[(q+14)%16],d+=(h=((f=e[(q+14)%16])>>>19|l<<13)^(l>>>29|f<<3)^(f>>>6|l<<26))>>>16,g+=65535&(u=(l>>>19|f<<13)^(f>>>29|l<<3)^l>>>6),v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,t[q]=65535&g|v<<16,e[q]=65535&p|d<<16}p=65535&(h=S),d=h>>>16,g=65535&(u=y),v=u>>>16,u=r[0],d+=(h=i[0])>>>16,g+=65535&u,v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,r[0]=y=65535&g|v<<16,i[0]=S=65535&p|d<<16,p=65535&(h=O),d=h>>>16,g=65535&(u=m),v=u>>>16,u=r[1],d+=(h=i[1])>>>16,g+=65535&u,v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,r[1]=m=65535&g|v<<16,i[1]=O=65535&p|d<<16,p=65535&(h=x),d=h>>>16,g=65535&(u=w),v=u>>>16,u=r[2],d+=(h=i[2])>>>16,g+=65535&u,v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,r[2]=w=65535&g|v<<16,i[2]=x=65535&p|d<<16,p=65535&(h=R),d=h>>>16,g=65535&(u=_),v=u>>>16,u=r[3],d+=(h=i[3])>>>16,g+=65535&u,v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,r[3]=_=65535&g|v<<16,i[3]=R=65535&p|d<<16,p=65535&(h=C),d=h>>>16,g=65535&(u=b),v=u>>>16,u=r[4],d+=(h=i[4])>>>16,g+=65535&u,v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,r[4]=b=65535&g|v<<16,i[4]=C=65535&p|d<<16,p=65535&(h=A),d=h>>>16,g=65535&(u=E),v=u>>>16,u=r[5],d+=(h=i[5])>>>16,g+=65535&u,v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,r[5]=E=65535&g|v<<16,i[5]=A=65535&p|d<<16,p=65535&(h=j),d=h>>>16,g=65535&(u=I),v=u>>>16,u=r[6],d+=(h=i[6])>>>16,g+=65535&u,v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,r[6]=I=65535&g|v<<16,i[6]=j=65535&p|d<<16,p=65535&(h=T),d=h>>>16,g=65535&(u=P),v=u>>>16,u=r[7],d+=(h=i[7])>>>16,g+=65535&u,v+=u>>>16,v+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,r[7]=P=65535&g|v<<16,i[7]=T=65535&p|d<<16,a+=128,c-=128}return a}e.hash=function(t){var e=new s;e.update(t);var r=e.digest();return e.clean(),r}},32760:(t,e,r)=>{"use strict";function n(){return(null===r.g||void 0===r.g?void 0:r.g.crypto)||(null===r.g||void 0===r.g?void 0:r.g.msCrypto)||{}}function i(){const t=n();return t.subtle||t.webkitSubtle}Object.defineProperty(e,"__esModule",{value:!0}),e.isBrowserCryptoAvailable=e.getSubtleCrypto=e.getBrowerCrypto=void 0,e.getBrowerCrypto=n,e.getSubtleCrypto=i,e.isBrowserCryptoAvailable=function(){return!!n()&&!!i()}},34300:(t,e)=>{"use strict";function r(){return"undefined"===typeof document&&"undefined"!==typeof navigator&&"ReactNative"===navigator.product}function n(){return"undefined"!==typeof process&&"undefined"!==typeof process.versions&&"undefined"!==typeof process.versions.node}Object.defineProperty(e,"__esModule",{value:!0}),e.isBrowser=e.isNode=e.isReactNative=void 0,e.isReactNative=r,e.isNode=n,e.isBrowser=function(){return!r()&&!n()}},55503:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(90900);n.__exportStar(r(32760),e),n.__exportStar(r(34300),e)},90900:(t,e,r)=>{"use strict";r.r(e),r.d(e,{__assign:()=>s,__asyncDelegator:()=>_,__asyncGenerator:()=>w,__asyncValues:()=>b,__await:()=>m,__awaiter:()=>h,__classPrivateFieldGet:()=>S,__classPrivateFieldSet:()=>O,__createBinding:()=>f,__decorate:()=>a,__exportStar:()=>p,__extends:()=>i,__generator:()=>l,__importDefault:()=>P,__importStar:()=>I,__makeTemplateObject:()=>E,__metadata:()=>u,__param:()=>c,__read:()=>g,__rest:()=>o,__spread:()=>v,__spreadArrays:()=>y,__values:()=>d});var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},n(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var s=function(){return s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r=0;a--)(i=t[a])&&(o=(s<3?i(o):s>3?i(e,r,o):i(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o}function c(t,e){return function(r,n){e(r,n,t)}}function u(t,e){if("object"===typeof Reflect&&"function"===typeof Reflect.metadata)return Reflect.metadata(t,e)}function h(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(e){s(e)}}function a(t){try{c(n.throw(t))}catch(e){s(e)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))}function l(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"===typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var r="function"===typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function v(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(r=i[t](e)).value instanceof m?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(n){h(s[0][3],n)}var r}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function _(t){var e,r;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,i){e[n]=t[n]?function(e){return(r=!r)?{value:m(t[n](e)),done:"return"===n}:i?i(e):e}:i}}function b(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=d(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,i){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,i,(e=t[r](e)).done,e.value)}))}}}function E(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function I(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function P(t){return t&&t.__esModule?t:{default:t}}function S(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function O(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}},62871:(t,e,r)=>{"use strict";r.d(e,{EthereumProvider:()=>ls,OPTIONAL_EVENTS:()=>$i,OPTIONAL_METHODS:()=>Qi});var n=r(68041),i=r.n(n),s=r(95935),o=r(60074),a=r(1345),c=r(91451),u=r(23375);class h extends u.q{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}class l extends u.q{constructor(t,e){super(),this.core=t,this.logger=e,this.records=new Map}}class f{constructor(t,e){this.logger=t,this.core=e}}class p extends u.q{constructor(t,e){super(),this.relayer=t,this.logger=e}}class d extends u.q{constructor(t){super()}}class g{constructor(t,e,r,n){this.core=t,this.logger=e,this.name=r}}class v extends u.q{constructor(t,e){super(),this.relayer=t,this.logger=e}}class y extends u.q{constructor(t,e){super(),this.core=t,this.logger=e}}class m{constructor(t,e){this.projectId=t,this.logger=e}}class w{constructor(t){this.opts=t,this.protocol="wc",this.version=2}}class _{constructor(t){this.client=t}}const b=t=>JSON.stringify(t,((t,e)=>"bigint"===typeof e?e.toString()+"n":e));function E(t){if("string"!==typeof t)throw new Error("Cannot safe json parse value of type ".concat(typeof t));try{return(t=>{const e=t.replace(/([\[:])?(\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,'$1"$2n"$3');return JSON.parse(e,((t,e)=>"string"===typeof e&&e.match(/^\d+n$/)?BigInt(e.substring(0,e.length-1)):e))})(t)}catch(e){return t}}function I(t){return"string"===typeof t?t:b(t)||""}var P=r(44519),S=r(14701),O=r(93659);const x=".",R="base64url",C="utf8",A="utf8",j=":",T="did",N="key",q="base58btc",D="z",L="K36";var M=r(45201),z=r(74233),k=r(49324);function U(t){return(0,z.B)((0,k.m)(I(t),C),R)}function H(t){const e=(0,k.m)(L,q),r=D+(0,z.B)((0,M.z)([e,t]),q);return[T,N,r].join(j)}function V(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(0,S.randomBytes)(32);return P._w(t)}async function B(t,e,r,n){let i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:(0,O.fromMiliseconds)(Date.now());const s={alg:"EdDSA",typ:"JWT"},o={iss:H(n.publicKey),sub:t,aud:e,iat:i,exp:i+r},a=(c={header:s,payload:o},(0,k.m)([U(c.header),U(c.payload)].join(x),A));var c;return function(t){return[U(t.header),U(t.payload),(e=t.signature,(0,z.B)(e,R))].join(x);var e}({header:s,payload:o,signature:P.Xx(n.secretKey,a)})}r(16395);var K=r(91696);const F="INTERNAL_ERROR",G="SERVER_ERROR",Z=[-32700,-32600,-32601,-32602,-32603],W={PARSE_ERROR:{code:-32700,message:"Parse error"},INVALID_REQUEST:{code:-32600,message:"Invalid Request"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params"},[F]:{code:-32603,message:"Internal error"},[G]:{code:-32e3,message:"Server error"}},J=G;function Q(t){return Z.includes(t)}function Y(t){return Object.keys(W).includes(t)?W[t]:W[J]}function $(t){const e=Object.values(W).find((e=>e.code===t));return e||W[J]}function X(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error("Unavailable ".concat(r," RPC url at ").concat(e)):t}var tt=r(55503);function et(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:3;return Date.now()*Math.pow(10,t)+Math.floor(Math.random()*Math.pow(10,t))}function rt(){return BigInt(et(arguments.length>0&&void 0!==arguments[0]?arguments[0]:6))}function nt(t,e,r){return{id:r||et(),jsonrpc:"2.0",method:t,params:e}}function it(t,e){return{id:t,jsonrpc:"2.0",result:e}}function st(t,e,r){return{id:t,jsonrpc:"2.0",error:ot(e,r)}}function ot(t,e){return"undefined"===typeof t?Y(F):("string"===typeof t&&(t=Object.assign(Object.assign({},Y(G)),{message:t})),"undefined"!==typeof e&&(t.data=e),Q(t.code)&&(t=$(t.code)),t)}class at{}class ct extends at{constructor(){super()}}class ut extends ct{constructor(t){super()}}function ht(t,e){const r=function(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(e&&e.length)return e[0]}(t);return"undefined"!==typeof r&&new RegExp(e).test(r)}function lt(t){return ht(t,"^https?:")}function ft(t){return ht(t,"^wss?:")}function pt(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function dt(t){return"object"===typeof t&&"id"in t&&"jsonrpc"in t&&"2.0"===t.jsonrpc}function gt(t){return dt(t)&&"method"in t}function vt(t){return dt(t)&&(yt(t)||mt(t))}function yt(t){return"result"in t}function mt(t){return"error"in t}class wt extends ut{constructor(t){super(t),this.events=new n.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.connection;await this.open(t)}async disconnect(){await this.close()}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async request(t,e){return this.requestStrict(nt(t.method,t.params||[],t.id||rt().toString()),e)}async requestStrict(t,e){return new Promise((async(r,n)=>{if(!this.connection.connected)try{await this.open()}catch(i){n(i)}this.events.on("".concat(t.id),(t=>{mt(t)?n(t.error):r(t.result)}));try{await this.connection.send(t,e)}catch(i){n(i)}}))}setConnection(){return arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.connection}onPayload(t){this.events.emit("payload",t),vt(t)?this.events.emit("".concat(t.id),t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&3e3===t.code&&this.events.emit("error",new Error("WebSocket connection closed abnormally with code: ".concat(t.code," ").concat(t.reason?"(".concat(t.reason,")"):""))),this.events.emit("disconnect")}async open(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.connection;this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),"string"===typeof t&&(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)}}const _t=t=>t.split("?")[0],bt="undefined"!==typeof WebSocket?WebSocket:"undefined"!==typeof r.g&&"undefined"!==typeof r.g.WebSocket?r.g.WebSocket:"undefined"!==typeof window&&"undefined"!==typeof window.WebSocket?window.WebSocket:"undefined"!==typeof self&&"undefined"!==typeof self.WebSocket?self.WebSocket:r(96578);const Et=class{constructor(t){if(this.url=t,this.events=new n.EventEmitter,this.registering=!1,!ft(t))throw new Error("Provided URL is not compatible with WebSocket connection: ".concat(t));this.url=t}get connected(){return"undefined"!==typeof this.socket}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.url;await this.register(t)}async close(){return new Promise(((t,e)=>{"undefined"!==typeof this.socket?(this.socket.onclose=e=>{this.onClose(e),t()},this.socket.close()):e(new Error("Connection already closed"))}))}async send(t,e){"undefined"===typeof this.socket&&(this.socket=await this.register());try{this.socket.send(I(t))}catch(r){this.onError(t.id,r)}}register(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.url;if(!ft(t))throw new Error("Provided URL is not compatible with WebSocket connection: ".concat(t));if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise(((t,e)=>{this.events.once("register_error",(t=>{this.resetMaxListeners(),e(t)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),"undefined"===typeof this.socket)return e(new Error("WebSocket connection is missing or invalid"));t(this.socket)}))}))}return this.url=t,this.registering=!0,new Promise(((e,n)=>{const i=(0,tt.isReactNative)()?void 0:{rejectUnauthorized:!pt(t)},s=new bt(t,[],i);"undefined"!==typeof WebSocket||"undefined"!==typeof r.g&&"undefined"!==typeof r.g.WebSocket||"undefined"!==typeof window&&"undefined"!==typeof window.WebSocket||"undefined"!==typeof self&&"undefined"!==typeof self.WebSocket?s.onerror=t=>{const e=t;n(this.emitError(e.error))}:s.on("error",(t=>{n(this.emitError(t))})),s.onopen=()=>{this.onOpen(s),e(s)}}))}onOpen(t){t.onmessage=t=>this.onPayload(t),t.onclose=t=>this.onClose(t),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("undefined"===typeof t.data)return;const e="string"===typeof t.data?E(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const r=this.parseError(e),n=st(t,r.message||r.toString());this.events.emit("payload",n)}parseError(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.url;return X(t,_t(e),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(t){const e=this.parseError(new Error((null===t||void 0===t?void 0:t.message)||"WebSocket connection failed for host: ".concat(_t(this.url))));return this.events.emit("register_error",e),e}};var It=r(23108),Pt=r.n(It);var St=function(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n>>0,o=new Uint8Array(s);t[e];){var h=r[t.charCodeAt(e)];if(255===h)return;for(var l=0,f=s-1;(0!==h||l>>0,o[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,e++}if(" "!==t[e]){for(var p=s-i;p!==s&&0===o[p];)p++;for(var d=new Uint8Array(n+(s-p)),g=n;p!==s;)d[g++]=o[p++];return d}}}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,s=e.length;i!==s&&0===e[i];)i++,r++;for(var o=(s-i)*h+1>>>0,u=new Uint8Array(o);i!==s;){for(var l=e[i],f=0,p=o-1;(0!==l||f>>0,u[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");n=f,i++}for(var d=o-n;d!==o&&0===u[d];)d++;for(var g=c.repeat(r);d{if(t instanceof Uint8Array&&"Uint8Array"===t.constructor.name)return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")};class Rt{constructor(t,e,r){this.name=t,this.prefix=e,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(t));throw Error("Unknown type, must be binary type")}}class Ct{constructor(t,e,r){if(this.name=t,this.prefix=e,void 0===e.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=r}decode(t){if("string"==typeof t){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(t),", ").concat(this.name," decoder only supports inputs prefixed with ").concat(this.prefix));return this.baseDecode(t.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(t){return jt(this,t)}}class At{constructor(t){this.decoders=t}or(t){return jt(this,t)}decode(t){const e=t[0],r=this.decoders[e];if(r)return r.decode(t);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(t),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}const jt=(t,e)=>new At({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Tt{constructor(t,e,r,n){this.name=t,this.prefix=e,this.baseEncode=r,this.baseDecode=n,this.encoder=new Rt(t,e,r),this.decoder=new Ct(t,e,n)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const Nt=t=>{let{name:e,prefix:r,encode:n,decode:i}=t;return new Tt(e,r,n,i)},qt=t=>{let{prefix:e,name:r,alphabet:n}=t;const{encode:i,decode:s}=Ot(n,r);return Nt({prefix:e,name:r,encode:i,decode:t=>xt(s(t))})},Dt=t=>{let{name:e,prefix:r,bitsPerChar:n,alphabet:i}=t;return Nt({prefix:r,name:e,encode:t=>((t,e,r)=>{const n="="===e[e.length-1],i=(1<r;)o-=r,s+=e[i&a>>o];if(o&&(s+=e[i&a<((t,e,r,n)=>{const i={};for(let h=0;h=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,n,e)})},Lt=Nt({prefix:"\0",name:"identity",encode:t=>(t=>(new TextDecoder).decode(t))(t),decode:t=>(t=>(new TextEncoder).encode(t))(t)});var Mt=Object.freeze({__proto__:null,identity:Lt});const zt=Dt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var kt=Object.freeze({__proto__:null,base2:zt});const Ut=Dt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ht=Object.freeze({__proto__:null,base8:Ut});const Vt=qt({prefix:"9",name:"base10",alphabet:"0123456789"});var Bt=Object.freeze({__proto__:null,base10:Vt});const Kt=Dt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ft=Dt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Gt=Object.freeze({__proto__:null,base16:Kt,base16upper:Ft});const Zt=Dt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Wt=Dt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Jt=Dt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qt=Dt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Yt=Dt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),$t=Dt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Xt=Dt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),te=Dt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ee=Dt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var re=Object.freeze({__proto__:null,base32:Zt,base32upper:Wt,base32pad:Jt,base32padupper:Qt,base32hex:Yt,base32hexupper:$t,base32hexpad:Xt,base32hexpadupper:te,base32z:ee});const ne=qt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ie=qt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var se=Object.freeze({__proto__:null,base36:ne,base36upper:ie});const oe=qt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ae=qt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ce=Object.freeze({__proto__:null,base58btc:oe,base58flickr:ae});const ue=Dt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),he=Dt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),le=Dt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),fe=Dt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var pe=Object.freeze({__proto__:null,base64:ue,base64pad:he,base64url:le,base64urlpad:fe});const de=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),ge=de.reduce(((t,e,r)=>(t[r]=e,t)),[]),ve=de.reduce(((t,e,r)=>(t[e.codePointAt(0)]=r,t)),[]);const ye=Nt({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(t){return t.reduce(((t,e)=>t+=ge[e]),"")},decode:function(t){const e=[];for(const r of t){const t=ve[r.codePointAt(0)];if(void 0===t)throw new Error("Non-base256emoji character: ".concat(r));e.push(t)}return new Uint8Array(e)}});var me=Object.freeze({__proto__:null,base256emoji:ye}),we=function t(e,r,n){r=r||[];for(var i=n=n||0;e>=Ee;)r[n++]=255&e|_e,e/=128;for(;e&be;)r[n++]=255&e|_e,e>>>=7;return r[n]=0|e,t.bytes=n-i+1,r},_e=128,be=-128,Ee=Math.pow(2,31);var Ie=function t(e,r){var n,i=0,s=0,o=r=r||0,a=e.length;do{if(o>=a)throw t.bytes=0,new RangeError("Could not decode varint");n=e[o++],i+=s<28?(n&Se)<=Pe);return t.bytes=o-r,i},Pe=128,Se=127;var Oe=Math.pow(2,7),xe=Math.pow(2,14),Re=Math.pow(2,21),Ce=Math.pow(2,28),Ae=Math.pow(2,35),je=Math.pow(2,42),Te=Math.pow(2,49),Ne=Math.pow(2,56),qe=Math.pow(2,63),De={encode:we,decode:Ie,encodingLength:function(t){return t2&&void 0!==arguments[2]?arguments[2]:0;return De.encode(t,e,r),e},Me=t=>De.encodingLength(t),ze=(t,e)=>{const r=e.byteLength,n=Me(t),i=n+Me(r),s=new Uint8Array(i+r);return Le(t,s,0),Le(r,s,n),s.set(e,i),new ke(t,r,e,s)};class ke{constructor(t,e,r,n){this.code=t,this.size=e,this.digest=r,this.bytes=n}}const Ue=t=>{let{name:e,code:r,encode:n}=t;return new He(e,r,n)};class He{constructor(t,e,r){this.name=t,this.code=e,this.encode=r}digest(t){if(t instanceof Uint8Array){const e=this.encode(t);return e instanceof Uint8Array?ze(this.code,e):e.then((t=>ze(this.code,t)))}throw Error("Unknown type, must be binary type")}}const Ve=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Be=Ue({name:"sha2-256",code:18,encode:Ve("SHA-256")}),Ke=Ue({name:"sha2-512",code:19,encode:Ve("SHA-512")});Object.freeze({__proto__:null,sha256:Be,sha512:Ke});const Fe=xt,Ge={code:0,name:"identity",encode:Fe,digest:t=>ze(0,Fe(t))};Object.freeze({__proto__:null,identity:Ge});new TextEncoder,new TextDecoder;const Ze={...Mt,...kt,...Ht,...Bt,...Gt,...re,...se,...ce,...pe,...me};function We(t){return null!=globalThis.Buffer?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function Je(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Qe=Je("utf8","u",(t=>"u"+new TextDecoder("utf8").decode(t)),(t=>(new TextEncoder).encode(t.substring(1)))),Ye=Je("ascii","a",(t=>{let e="a";for(let r=0;r{const e=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?We(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}((t=t.substring(1)).length);for(let r=0;r{if(!this.initialized){const t=await this.getKeyChain();typeof t<"u"&&(this.keychain=t),this.initialized=!0}},this.has=t=>(this.isInitialized(),this.keychain.has(t)),this.set=async(t,e)=>{this.isInitialized(),this.keychain.set(t,e),await this.persist()},this.get=t=>{this.isInitialized();const e=this.keychain.get(t);if(typeof e>"u"){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","".concat(this.name,": ").concat(t));throw new Error(e)}return e},this.del=async t=>{this.isInitialized(),this.keychain.delete(t),await this.persist()},this.core=t,this.logger=(0,c.generateChildLogger)(e,this.name)}get context(){return(0,c.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,(0,s.KC)(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?(0,s.IP)(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Vr{constructor(t,e,r){this.core=t,this.logger=e,this.name="crypto",this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=t=>(this.isInitialized(),this.keychain.has(t)),this.getClientId=async()=>{this.isInitialized();return H(V(await this.getClientSeed()).publicKey)},this.generateKeyPair=()=>{this.isInitialized();const t=(0,s.Au)();return this.setPrivateKey(t.publicKey,t.privateKey)},this.signJWT=async t=>{this.isInitialized();const e=V(await this.getClientSeed()),r=(0,s.jd)(),n=ir;return await B(r,t,n,e)},this.generateSharedKey=(t,e,r)=>{this.isInitialized();const n=this.getPrivateKey(t),i=(0,s.m$)(n,e);return this.setSymKey(i,r)},this.setSymKey=async(t,e)=>{this.isInitialized();const r=e||(0,s.Ym)(t);return await this.keychain.set(r,t),r},this.deleteKeyPair=async t=>{this.isInitialized(),await this.keychain.del(t)},this.deleteSymKey=async t=>{this.isInitialized(),await this.keychain.del(t)},this.encode=async(t,e,r)=>{this.isInitialized();const n=(0,s.EN)(r),i=I(e);if((0,s.Q8)(n)){const e=n.senderPublicKey,r=n.receiverPublicKey;t=await this.generateSharedKey(e,r)}const o=this.getSymKey(t),{type:a,senderPublicKey:c}=n;return(0,s.HI)({type:a,symKey:o,message:i,senderPublicKey:c})},this.decode=async(t,e,r)=>{this.isInitialized();const n=(0,s.Ll)(e,r);if((0,s.Q8)(n)){const e=n.receiverPublicKey,r=n.senderPublicKey;t=await this.generateSharedKey(e,r)}try{const r=this.getSymKey(t);return E((0,s.pe)({symKey:r,encoded:e}))}catch(l){this.logger.error("Failed to decode message from topic: '".concat(t,"', clientId: '").concat(await this.getClientId(),"'")),this.logger.error(l)}},this.getPayloadType=t=>{const e=(0,s.vB)(t);return(0,s.WG)(e.type)},this.getPayloadSenderPublicKey=t=>{const e=(0,s.vB)(t);return e.senderPublicKey?(0,K.BB)(e.senderPublicKey,s.AW):void 0},this.core=t,this.logger=(0,c.generateChildLogger)(e,this.name),this.keychain=r||new Hr(this.core,this.logger)}get context(){return(0,c.getLoggerContext)(this.logger)}async setPrivateKey(t,e){return await this.keychain.set(t,e),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(nr)}catch{t=(0,s.jd)(),await this.keychain.set(nr,t)}return function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=$e[e];if(!r)throw new Error('Unsupported encoding "'.concat(e,'"'));return"utf8"!==e&&"utf-8"!==e||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode("".concat(r.prefix).concat(t)):We(globalThis.Buffer.from(t,"utf-8"))}(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Br extends f{constructor(t,e){super(t,e),this.logger=t,this.core=e,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=tr,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const t=await this.getRelayerMessages();typeof t<"u"&&(this.messages=t),this.logger.debug("Successfully Restored records for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(t){this.logger.debug("Failed to Restore records for ".concat(this.name)),this.logger.error(t)}finally{this.initialized=!0}}},this.set=async(t,e)=>{this.isInitialized();const r=(0,s.rj)(e);let n=this.messages.get(t);return typeof n>"u"&&(n={}),typeof n[r]<"u"||(n[r]=e,this.messages.set(t,n),await this.persist()),r},this.get=t=>{this.isInitialized();let e=this.messages.get(t);return typeof e>"u"&&(e={}),e},this.has=(t,e)=>{this.isInitialized();return typeof this.get(t)[(0,s.rj)(e)]<"u"},this.del=async t=>{this.isInitialized(),this.messages.delete(t),await this.persist()},this.logger=(0,c.generateChildLogger)(t,this.name),this.core=e}get context(){return(0,c.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,(0,s.KC)(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?(0,s.IP)(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}}class Kr extends p{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.events=new n.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=(0,O.toMiliseconds)(O.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(t,e,r)=>{var n;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:t,message:e,opts:r}});try{const o=(null===r||void 0===r?void 0:r.ttl)||sr,a=(0,s._H)(r),c=(null===r||void 0===r?void 0:r.prompt)||!1,u=(null===r||void 0===r?void 0:r.tag)||0,h=(null===r||void 0===r?void 0:r.id)||rt().toString(),l={topic:t,message:e,opts:{ttl:o,relay:a,prompt:c,tag:u,id:h}},f=setTimeout((()=>this.queue.set(h,l)),this.publishTimeout);try{await await(0,s.hF)(this.rpcPublish(t,e,o,a,c,u,h),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(h),this.relayer.events.emit(dr,l)}catch(i){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,null!=(n=null===r||void 0===r?void 0:r.internal)&&n.throwOnFailedPublish)throw this.removeRequestFromQueue(h),i;return}finally{clearTimeout(f)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:t,message:e,opts:r}})}catch(o){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(o),o}},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.relayer=t,this.logger=(0,c.generateChildLogger)(e,this.name),this.registerEventListeners()}get context(){return(0,c.getLoggerContext)(this.logger)}rpcPublish(t,e,r,n,i,o,a){var c,u,h,l;const f={method:(0,s.cO)(n.protocol).publish,params:{topic:t,message:e,ttl:r,prompt:i,tag:o},id:a};return(0,s.o8)(null==(c=f.params)?void 0:c.prompt)&&(null==(u=f.params)||delete u.prompt),(0,s.o8)(null==(h=f.params)?void 0:h.tag)&&(null==(l=f.params)||delete l.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f}),this.relayer.request(f)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach((async t=>{const{topic:e,message:r,opts:n}=t;await this.publish(e,r,n)}))}registerEventListeners(){this.relayer.core.heartbeat.on(a.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(pr);this.checkQueue()})),this.relayer.on(ur,(t=>{this.removeRequestFromQueue(t.id.toString())}))}}class Fr{constructor(){this.map=new Map,this.set=(t,e)=>{const r=this.get(t);this.exists(t,e)||this.map.set(t,[...r,e])},this.get=t=>this.map.get(t)||[],this.exists=(t,e)=>this.get(t).includes(e),this.delete=(t,e)=>{if(typeof e>"u")return void this.map.delete(t);if(!this.map.has(t))return;const r=this.get(t);if(!this.exists(t,e))return;const n=r.filter((t=>t!==e));n.length?this.map.set(t,n):this.map.delete(t)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Gr=Object.defineProperty,Zr=Object.defineProperties,Wr=Object.getOwnPropertyDescriptors,Jr=Object.getOwnPropertySymbols,Qr=Object.prototype.hasOwnProperty,Yr=Object.prototype.propertyIsEnumerable,$r=(t,e,r)=>e in t?Gr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Xr=(t,e)=>{for(var r in e||(e={}))Qr.call(e,r)&&$r(t,r,e[r]);if(Jr)for(var r of Jr(e))Yr.call(e,r)&&$r(t,r,e[r]);return t},tn=(t,e)=>Zr(t,Wr(e));class en extends v{constructor(t,e){super(t,e),this.relayer=t,this.logger=e,this.subscriptions=new Map,this.topicMap=new Fr,this.events=new n.EventEmitter,this.name="subscription",this.version="0.3",this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=tr,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(t,e)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:e}});try{const r=(0,s._H)(e),n={topic:t,relay:r};this.pending.set(t,n);const i=await this.rpcSubscribe(t,r);return this.onSubscribe(i,n),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:t,opts:e}}),i}catch(h){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(h),h}},this.unsubscribe=async(t,e)=>{await this.restartToComplete(),this.isInitialized(),typeof(null===e||void 0===e?void 0:e.id)<"u"?await this.unsubscribeById(t,e.id,e):await this.unsubscribeByTopic(t,e)},this.isSubscribed=async t=>!!this.topics.includes(t)||await new Promise(((e,r)=>{const n=new O.Watch;n.start(this.pendingSubscriptionWatchLabel);const i=setInterval((()=>{!this.pending.has(t)&&this.topics.includes(t)&&(clearInterval(i),n.stop(this.pendingSubscriptionWatchLabel),e(!0)),n.elapsed(this.pendingSubscriptionWatchLabel)>=Pr&&(clearInterval(i),n.stop(this.pendingSubscriptionWatchLabel),r(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1)),this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=(0,c.generateChildLogger)(e,this.name),this.clientId=""}get context(){return(0,c.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+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,e){let r=!1;try{r=this.getSubscription(t).topic===e}catch{}return r}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,e){const r=this.topicMap.get(t);await Promise.all(r.map((async r=>await this.unsubscribeById(t,r,e))))}async unsubscribeById(t,e,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:r}});try{const n=(0,s._H)(r);await this.rpcUnsubscribe(t,e,n);const i=(0,s.D6)("USER_DISCONNECTED","".concat(this.name,", ").concat(t));await this.onUnsubscribe(t,e,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:e,opts:r}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(t,e){const r={method:(0,s.cO)(e.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await(0,s.hF)(this.relayer.request(r),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(pr)}return(0,s.rj)(t+this.clientId)}async rpcBatchSubscribe(t){if(!t.length)return;const e=t[0].relay,r={method:(0,s.cO)(e.protocol).batchSubscribe,params:{topics:t.map((t=>t.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{return await await(0,s.hF)(this.relayer.request(r),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(pr)}}rpcUnsubscribe(t,e,r){const n={method:(0,s.cO)(r.protocol).unsubscribe,params:{topic:t,id:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(t,e){this.setSubscription(t,tn(Xr({},e),{id:t})),this.pending.delete(e.topic)}onBatchSubscribe(t){t.length&&t.forEach((t=>{this.setSubscription(t.id,Xr({},t)),this.pending.delete(t.topic)}))}async onUnsubscribe(t,e,r){this.events.removeAllListeners(e),this.hasSubscription(e,t)&&this.deleteSubscription(e,r),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,e){this.subscriptions.has(t)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:e}),this.addSubscription(t,e))}addSubscription(t,e){this.subscriptions.set(t,Xr({},e)),this.topicMap.set(e.topic,t),this.events.emit(_r,e)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const e=this.subscriptions.get(t);if(!e){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","".concat(this.name,": ").concat(t));throw new Error(e)}return e}deleteSubscription(t,e){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:e});const r=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(r.topic,t),this.events.emit(br,tn(Xr({},r),{reason:e}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Er)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let e=0;e"u"||!t.length)return;if(this.subscriptions.size){const{message:t}=(0,s.Z7)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error("".concat(this.name,": ").concat(JSON.stringify(this.values))),new Error(t)}this.cached=t,this.logger.debug("Successfully Restored subscriptions for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug("Failed to Restore subscriptions for ".concat(this.name)),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const e=await this.rpcBatchSubscribe(t);(0,s.qt)(e)&&this.onBatchSubscribe(e.map(((e,r)=>tn(Xr({},t[r]),{id:e}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const t=[];this.pending.forEach((e=>{t.push(e)})),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(a.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(hr,(async()=>{await this.onConnect()})),this.relayer.on(lr,(()=>{this.onDisconnect()})),this.events.on(_r,(async t=>{const e=_r;this.logger.info("Emitting ".concat(e)),this.logger.debug({type:"event",event:e,data:t}),await this.persist()})),this.events.on(br,(async t=>{const e=br;this.logger.info("Emitting ".concat(e)),this.logger.debug({type:"event",event:e,data:t}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise((t=>{const e=setInterval((()=>{this.restartInProgress||(clearInterval(e),t())}),this.pollingInterval)}))}}var rn=Object.defineProperty,nn=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable,an=(t,e,r)=>e in t?rn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;class cn extends d{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new n.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.request=async t=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(t)}catch(e){throw this.logger.debug("Failed to Publish Request"),this.logger.error(e),e}},this.onPayloadHandler=t=>{this.onProviderPayload(t)},this.onConnectHandler=()=>{this.events.emit(hr)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(fr,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(gr,this.onPayloadHandler),this.provider.on(vr,this.onConnectHandler),this.provider.on(yr,this.onDisconnectHandler),this.provider.on(mr,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&"string"!=typeof t.logger?(0,c.generateChildLogger)(t.logger,this.name):(0,c.pino)((0,c.getDefaultLoggerOptions)({level:t.logger||"error"})),this.messages=new Br(this.logger,t.core),this.subscriber=new en(this,this.logger),this.publisher=new Kr(this,this.logger),this.relayUrl=(null===t||void 0===t?void 0:t.relayUrl)||or,this.projectId=t.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn("Connection via ".concat(this.relayUrl," failed, attempting to connect via failover domain ").concat(ar,"...")),await this.restartTransport(ar)}this.initialized=!0,setTimeout((async()=>{0===this.subscriber.topics.length&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)}),1e4)}get context(){return(0,c.getLoggerContext)(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(t,e,r){this.isInitialized(),await this.publisher.publish(t,e,r),await this.recordMessageEvent({topic:t,message:e,publishedAt:Date.now()})}async subscribe(t,e){var r;this.isInitialized();let n,i=(null==(r=this.subscriber.topicMap.get(t))?void 0:r[0])||"";if(i)return i;const s=e=>{e.topic===t&&(this.subscriber.off(_r,s),n())};return await Promise.all([new Promise((t=>{n=t,this.subscriber.on(_r,s)})),new Promise((async r=>{i=await this.subscriber.subscribe(t,e),r()}))]),i}async unsubscribe(t,e){this.isInitialized(),await this.subscriber.unsubscribe(t,e)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async transportClose(){this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await(0,s.hF)(this.provider.disconnect(),1e3,"provider.disconnect()").catch((()=>this.onProviderDisconnect())):this.connected&&await this.provider.disconnect()}async transportOpen(t){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise((t=>{if(!this.initialized)return t();this.subscriber.once(Ir,(()=>{t()}))})),new Promise((async(t,e)=>{try{await(0,s.hF)(this.provider.connect(),1e4,"Socket stalled when trying to connect to ".concat(this.relayUrl))}catch(r){return void e(r)}t()}))])}catch(e){this.logger.error(e);const t=e;if(!this.isConnectionStalled(t.message))throw e;this.provider.events.emit(yr)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(t){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=t||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await(0,s.Gg)())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(t){return this.staleConnectionErrors.some((e=>t.includes(e)))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new wt(new Et((0,s.$0)({sdkVersion:"2.10.2",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:e,message:r}=t;await this.messages.set(e,r)}async shouldIgnoreMessageEvent(t){const{topic:e,message:r}=t;if(!r||0===r.length)return this.logger.debug("Ignoring invalid/empty message: ".concat(r)),!0;if(!await this.subscriber.isSubscribed(e))return this.logger.debug("Ignoring message for non-subscribed topic ".concat(e)),!0;const n=this.messages.has(e,r);return n&&this.logger.debug("Ignoring duplicate message: ".concat(r)),n}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),gt(t)){if(!t.method.endsWith("_subscription"))return;const e=t.params,{topic:r,message:n,publishedAt:i}=e.data,s={topic:r,message:n,publishedAt:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(((t,e)=>{for(var r in e||(e={}))sn.call(e,r)&&an(t,r,e[r]);if(nn)for(var r of nn(e))on.call(e,r)&&an(t,r,e[r]);return t})({type:"event",event:e.id},s)),this.events.emit(e.id,s),await this.acknowledgePayload(t),await this.onMessageEvent(s)}else vt(t)&&this.events.emit(ur,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(cr,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const e=it(t.id,!0);await this.provider.connection.send(e)}unregisterProviderListeners(){this.provider.off(gr,this.onPayloadHandler),this.provider.off(vr,this.onConnectHandler),this.provider.off(yr,this.onDisconnectHandler),this.provider.off(mr,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(pr,(()=>{this.restartTransport().catch((t=>this.logger.error(t)))}));let t=await(0,s.Gg)();(0,s.uw)((async e=>{this.initialized&&t!==e&&(t=e,e?await this.restartTransport().catch((t=>this.logger.error(t))):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch((t=>this.logger.error(t)))))}))}onProviderDisconnect(){this.events.emit(lr),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout((async()=>{await this.restartTransport().catch((t=>this.logger.error(t)))}),(0,O.toMiliseconds)(wr)))}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise((t=>{const e=setInterval((()=>{this.connected&&(clearInterval(e),t())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var un=Object.defineProperty,hn=Object.getOwnPropertySymbols,ln=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable,pn=(t,e,r)=>e in t?un(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,dn=(t,e)=>{for(var r in e||(e={}))ln.call(e,r)&&pn(t,r,e[r]);if(hn)for(var r of hn(e))fn.call(e,r)&&pn(t,r,e[r]);return t};class gn extends g{constructor(t,e,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tr,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;super(t,e,r,n),this.core=t,this.logger=e,this.name=r,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=tr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>{this.getKey&&null!==t&&!(0,s.o8)(t)?this.map.set(this.getKey(t),t):(0,s.xW)(t)?this.map.set(t.id,t):(0,s.h1)(t)&&this.map.set(t.topic,t)})),this.cached=[],this.initialized=!0)},this.set=async(t,e)=>{this.isInitialized(),this.map.has(t)?await this.update(t,e):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:t,value:e}),this.map.set(t,e),await this.persist())},this.get=t=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:t}),this.getData(t)),this.getAll=t=>(this.isInitialized(),t?this.values.filter((e=>Object.keys(t).every((r=>Pt()(e[r],t[r]))))):this.values),this.update=async(t,e)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:t,update:e});const r=dn(dn({},this.getData(t)),e);this.map.set(t,r),await this.persist()},this.delete=async(t,e)=>{this.isInitialized(),this.map.has(t)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:t,reason:e}),this.map.delete(t),await this.persist())},this.logger=(0,c.generateChildLogger)(e,this.name),this.storagePrefix=n,this.getKey=i}get context(){return(0,c.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+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 e=this.map.get(t);if(!e){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","".concat(this.name,": ").concat(t));throw this.logger.error(e),new Error(e)}return e}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:t}=(0,s.Z7)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug("Successfully Restored value for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug("Failed to Restore value for ".concat(this.name)),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}}class vn{constructor(t,e){this.core=t,this.logger=e,this.name="pairing",this.version="0.3",this.events=new(i()),this.initialized=!1,this.storagePrefix=tr,this.ignoredPayloadTypes=[s.rV],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=t=>{let{methods:e}=t;this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]},this.create=async()=>{this.isInitialized();const t=(0,s.jd)(),e=await this.core.crypto.setSymKey(t),r=(0,s.gn)(O.FIVE_MINUTES),n={protocol:"irn"},i={topic:e,expiry:r,relay:n,active:!1},o=(0,s.Bv)({protocol:this.core.protocol,version:this.core.version,topic:e,symKey:t,relay:n});return await this.pairings.set(e,i),await this.core.relayer.subscribe(e),this.core.expirer.set(e,r),{topic:e,uri:o}},this.pair=async t=>{this.isInitialized(),this.isValidPair(t);const{topic:e,symKey:r,relay:n}=(0,s.he)(t.uri);let i;if(this.pairings.keys.includes(e)&&(i=this.pairings.get(e),i.active))throw new Error("Pairing already exists: ".concat(e,". Please try again with a new connection URI."));this.core.crypto.keychain.has(e)||(await this.core.crypto.setSymKey(r,e),await this.core.relayer.subscribe(e,{relay:n}));const o=(0,s.gn)(O.FIVE_MINUTES),a={topic:e,relay:n,expiry:o,active:!1};return await this.pairings.set(e,a),this.core.expirer.set(e,o),t.activatePairing&&await this.activate({topic:e}),this.events.emit(Or,a),a},this.activate=async t=>{let{topic:e}=t;this.isInitialized();const r=(0,s.gn)(O.THIRTY_DAYS);await this.pairings.update(e,{active:!0,expiry:r}),this.core.expirer.set(e,r)},this.ping=async t=>{this.isInitialized(),await this.isValidPing(t);const{topic:e}=t;if(this.pairings.keys.includes(e)){const t=await this.sendRequest(e,"wc_pairingPing",{}),{done:r,resolve:n,reject:i}=(0,s.H1)();this.events.once((0,s.E0)("pairing_ping",t),(t=>{let{error:e}=t;e?i(e):n()})),await r()}},this.updateExpiry=async t=>{let{topic:e,expiry:r}=t;this.isInitialized(),await this.pairings.update(e,{expiry:r})},this.updateMetadata=async t=>{let{topic:e,metadata:r}=t;this.isInitialized(),await this.pairings.update(e,{peerMetadata:r})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async t=>{this.isInitialized(),await this.isValidDisconnect(t);const{topic:e}=t;this.pairings.keys.includes(e)&&(await this.sendRequest(e,"wc_pairingDelete",(0,s.D6)("USER_DISCONNECTED")),await this.deletePairing(e))},this.sendRequest=async(t,e,r)=>{const n=nt(e,r),i=await this.core.crypto.encode(t,n),s=Sr[e].req;return this.core.history.set(t,n),this.core.relayer.publish(t,i,s),n.id},this.sendResult=async(t,e,r)=>{const n=it(t,r),i=await this.core.crypto.encode(e,n),s=await this.core.history.get(e,t),o=Sr[s.request.method].res;await this.core.relayer.publish(e,i,o),await this.core.history.resolve(n)},this.sendError=async(t,e,r)=>{const n=st(t,r),i=await this.core.crypto.encode(e,n),s=await this.core.history.get(e,t),o=Sr[s.request.method]?Sr[s.request.method].res:Sr.unregistered_method.res;await this.core.relayer.publish(e,i,o),await this.core.history.resolve(n)},this.deletePairing=async(t,e)=>{await this.core.relayer.unsubscribe(t),await Promise.all([this.pairings.delete(t,(0,s.D6)("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(t),e?Promise.resolve():this.core.expirer.del(t)])},this.cleanup=async()=>{const t=this.pairings.getAll().filter((t=>(0,s.Bw)(t.expiry)));await Promise.all(t.map((t=>this.deletePairing(t.topic))))},this.onRelayEventRequest=t=>{const{topic:e,payload:r}=t;switch(r.method){case"wc_pairingPing":return this.onPairingPingRequest(e,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(e,r);default:return this.onUnknownRpcMethodRequest(e,r)}},this.onRelayEventResponse=async t=>{const{topic:e,payload:r}=t,n=(await this.core.history.get(e,r.id)).request.method;return"wc_pairingPing"===n?this.onPairingPingResponse(e,r):this.onUnknownRpcMethodResponse(n)},this.onPairingPingRequest=async(t,e)=>{const{id:r}=e;try{this.isValidPing({topic:t}),await this.sendResult(r,t,!0),this.events.emit(Cr,{id:r,topic:t})}catch(f){await this.sendError(r,t,f),this.logger.error(f)}},this.onPairingPingResponse=(t,e)=>{const{id:r}=e;setTimeout((()=>{yt(e)?this.events.emit((0,s.E0)("pairing_ping",r),{}):mt(e)&&this.events.emit((0,s.E0)("pairing_ping",r),{error:e.error})}),500)},this.onPairingDeleteRequest=async(t,e)=>{const{id:r}=e;try{this.isValidDisconnect({topic:t}),await this.deletePairing(t),this.events.emit(Rr,{id:r,topic:t})}catch(f){await this.sendError(r,t,f),this.logger.error(f)}},this.onUnknownRpcMethodRequest=async(t,e)=>{const{id:r,method:n}=e;try{if(this.registeredMethods.includes(n))return;const e=(0,s.D6)("WC_METHOD_UNSUPPORTED",n);await this.sendError(r,t,e),this.logger.error(e)}catch(i){await this.sendError(r,t,i),this.logger.error(i)}},this.onUnknownRpcMethodResponse=t=>{this.registeredMethods.includes(t)||this.logger.error((0,s.D6)("WC_METHOD_UNSUPPORTED",t))},this.isValidPair=t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","pair() params: ".concat(t));throw new Error(e)}if(!(0,s.jv)(t.uri)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","pair() uri: ".concat(t.uri));throw new Error(e)}},this.isValidPing=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","ping() params: ".concat(t));throw new Error(e)}const{topic:e}=t;await this.isValidPairingTopic(e)},this.isValidDisconnect=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","disconnect() params: ".concat(t));throw new Error(e)}const{topic:e}=t;await this.isValidPairingTopic(e)},this.isValidPairingTopic=async t=>{if(!(0,s.M_)(t,!1)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","pairing topic should be a string: ".concat(t));throw new Error(e)}if(!this.pairings.keys.includes(t)){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","pairing topic doesn't exist: ".concat(t));throw new Error(e)}if((0,s.Bw)(this.pairings.get(t).expiry)){await this.deletePairing(t);const{message:e}=(0,s.Z7)("EXPIRED","pairing topic: ".concat(t));throw new Error(e)}},this.core=t,this.logger=(0,c.generateChildLogger)(e,this.name),this.pairings=new gn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,c.getLoggerContext)(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(cr,(async t=>{const{topic:e,message:r}=t;if(!this.pairings.keys.includes(e)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;const n=await this.core.crypto.decode(e,r);try{gt(n)?(this.core.history.set(e,n),this.onRelayEventRequest({topic:e,payload:n})):vt(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:e,payload:n}),this.core.history.delete(e,n.id))}catch(h){this.logger.error(h)}}))}registerExpirerEvents(){this.core.expirer.on(Lr,(async t=>{const{topic:e}=(0,s.iP)(t.target);e&&this.pairings.keys.includes(e)&&(await this.deletePairing(e,!0),this.events.emit(xr,{topic:e}))}))}}class yn extends l{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.records=new Map,this.events=new n.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=tr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>this.records.set(t.id,t))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(t,e,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:t,request:e,chainId:r}),this.records.has(e.id))return;const n={id:e.id,topic:t,request:{method:e.method,params:e.params||null},chainId:r,expiry:(0,s.gn)(O.THIRTY_DAYS)};this.records.set(n.id,n),this.events.emit(Ar,n)},this.resolve=async t=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:t}),!this.records.has(t.id))return;const e=await this.getRecord(t.id);typeof e.response>"u"&&(e.response=mt(t)?{error:t.error}:{result:t.result},this.records.set(e.id,e),this.events.emit(jr,e))},this.get=async(t,e)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:t,id:e}),await this.getRecord(e)),this.delete=(t,e)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:e}),this.values.forEach((r=>{if(r.topic===t){if(typeof e<"u"&&r.id!==e)return;this.records.delete(r.id),this.events.emit(Tr,r)}}))},this.exists=async(t,e)=>(this.isInitialized(),!!this.records.has(e)&&(await this.getRecord(e)).topic===t),this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.logger=(0,c.generateChildLogger)(e,this.name)}get context(){return(0,c.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+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((e=>{if(typeof e.response<"u")return;const r={topic:e.topic,request:nt(e.request.method,e.request.params,e.id),chainId:e.chainId};return t.push(r)})),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 e=this.records.get(t);if(!e){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","".concat(this.name,": ").concat(t));throw new Error(e)}return e}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Nr)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:t}=(0,s.Z7)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug("Successfully Restored records for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug("Failed to Restore records for ".concat(this.name)),this.logger.error(t)}}registerEventListeners(){this.events.on(Ar,(t=>{const e=Ar;this.logger.info("Emitting ".concat(e)),this.logger.debug({type:"event",event:e,record:t}),this.persist()})),this.events.on(jr,(t=>{const e=jr;this.logger.info("Emitting ".concat(e)),this.logger.debug({type:"event",event:e,record:t}),this.persist()})),this.events.on(Tr,(t=>{const e=Tr;this.logger.info("Emitting ".concat(e)),this.logger.debug({type:"event",event:e,record:t}),this.persist()})),this.core.heartbeat.on(a.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.records.forEach((t=>{(0,O.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info("Deleting expired history log: ".concat(t.id)),this.delete(t.topic,t.id))}))}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}}class mn extends y{constructor(t,e){super(t,e),this.core=t,this.logger=e,this.expirations=new Map,this.events=new n.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=tr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((t=>this.expirations.set(t.target,t))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=t=>{try{const e=this.formatTarget(t);return typeof this.getExpiration(e)<"u"}catch{return!1}},this.set=(t,e)=>{this.isInitialized();const r=this.formatTarget(t),n={target:r,expiry:e};this.expirations.set(r,n),this.checkExpiry(r,n),this.events.emit(qr,{target:r,expiration:n})},this.get=t=>{this.isInitialized();const e=this.formatTarget(t);return this.getExpiration(e)},this.del=t=>{if(this.isInitialized(),this.has(t)){const e=this.formatTarget(t),r=this.getExpiration(e);this.expirations.delete(e),this.events.emit(Dr,{target:e,expiration:r})}},this.on=(t,e)=>{this.events.on(t,e)},this.once=(t,e)=>{this.events.once(t,e)},this.off=(t,e)=>{this.events.off(t,e)},this.removeListener=(t,e)=>{this.events.removeListener(t,e)},this.logger=(0,c.generateChildLogger)(e,this.name)}get context(){return(0,c.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+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("string"==typeof t)return(0,s.Z4)(t);if("number"==typeof t)return(0,s.Gq)(t);const{message:e}=(0,s.Z7)("UNKNOWN_TYPE","Target type: ".concat(typeof t));throw new Error(e)}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(Mr)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:t}=(0,s.Z7)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=t,this.logger.debug("Successfully Restored expirations for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug("Failed to Restore expirations for ".concat(this.name)),this.logger.error(t)}}getExpiration(t){const e=this.expirations.get(t);if(!e){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","".concat(this.name,": ").concat(t));throw this.logger.error(e),new Error(e)}return e}checkExpiry(t,e){const{expiry:r}=e;(0,O.toMiliseconds)(r)-Date.now()<=0&&this.expire(t,e)}expire(t,e){this.expirations.delete(t),this.events.emit(Lr,{target:t,expiration:e})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((t,e)=>this.checkExpiry(e,t)))}registerEventListeners(){this.core.heartbeat.on(a.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(qr,(t=>{const e=qr;this.logger.info("Emitting ".concat(e)),this.logger.debug({type:"event",event:e,data:t}),this.persist()})),this.events.on(Lr,(t=>{const e=Lr;this.logger.info("Emitting ".concat(e)),this.logger.debug({type:"event",event:e,data:t}),this.persist()})),this.events.on(Dr,(t=>{const e=Dr;this.logger.info("Emitting ".concat(e)),this.logger.debug({type:"event",event:e,data:t}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}}}class wn extends m{constructor(t,e){super(t,e),this.projectId=t,this.logger=e,this.name=zr,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async()=>{if(this.verifyDisabled||(0,s.b$)()||!(0,s.jU)())return;const t=kr;this.verifyUrl!==t&&this.removeIframe(),this.verifyUrl=t;try{await this.createIframe()}catch(e){this.logger.info("Verify iframe failed to load: ".concat(this.verifyUrl)),this.logger.info(e)}if(!this.initialized){this.removeIframe(),this.verifyUrl=Ur;try{await this.createIframe()}catch(e){this.logger.info("Verify iframe failed to load: ".concat(this.verifyUrl)),this.logger.info(e),this.verifyDisabled=!0}}},this.register=async t=>{this.initialized?this.sendPost(t.attestationId):(this.addToQueue(t.attestationId),await this.init())},this.resolve=async t=>{if(this.isDevEnv)return"";const e=(null===t||void 0===t?void 0:t.verifyUrl)||kr;let r;try{r=await this.fetchAttestation(t.attestationId,e)}catch(f){this.logger.info("failed to resolve attestation: ".concat(t.attestationId," from url: ").concat(e)),this.logger.info(f),r=await this.fetchAttestation(t.attestationId,Ur)}return r},this.fetchAttestation=async(t,e)=>{this.logger.info("resolving attestation: ".concat(t," from url: ").concat(e));const r=this.startAbortTimer(2*O.ONE_SECOND),n=await fetch("".concat(e,"/attestation/").concat(t),{signal:this.abortController.signal});return clearTimeout(r),200===n.status?await n.json():void 0},this.addToQueue=t=>{this.queue.push(t)},this.processQueue=()=>{0!==this.queue.length&&(this.queue.forEach((t=>this.sendPost(t))),this.queue=[])},this.sendPost=t=>{var e;try{if(!this.iframe)return;null==(e=this.iframe.contentWindow)||e.postMessage(t,"*"),this.logger.info("postMessage sent: ".concat(t," ").concat(this.verifyUrl))}catch{}},this.createIframe=async()=>{let t;const e=r=>{"verify_ready"===r.data&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",e),t())};await Promise.race([new Promise((r=>{if(document.getElementById(zr))return r();window.addEventListener("message",e);const n=document.createElement("iframe");n.id=zr,n.src="".concat(this.verifyUrl,"/").concat(this.projectId),n.style.display="none",document.body.append(n),this.iframe=n,t=r})),new Promise(((t,r)=>setTimeout((()=>{window.removeEventListener("message",e),r("verify iframe load timeout")}),(0,O.toMiliseconds)(O.FIVE_SECONDS))))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.logger=(0,c.generateChildLogger)(e,this.name),this.verifyUrl=kr,this.abortController=new AbortController,this.isDevEnv=(0,s.UG)()&&{NODE_ENV:"production",PUBLIC_URL:"https://poocoin.app",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0,REACT_APP_CHAIN_ID:"56",REACT_APP_NODE_1:"https://bsc-dataseed.binance.org",REACT_APP_NODE_2:"https://bsc-dataseed1.defibit.io",REACT_APP_NODE_3:"https://bsc-dataseed1.ninicoin.io",REACT_APP_SERVER_2_URL:"https://api3.poocoin.app",REACT_APP_WALLET_CONNECT_PROJECT_ID:"f39fc63c4014dba05cd85d8ea3378bf4"}.IS_VITEST}get context(){return(0,c.getLoggerContext)(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout((()=>this.abortController.abort()),(0,O.toMiliseconds)(t))}}var _n=Object.defineProperty,bn=Object.getOwnPropertySymbols,En=Object.prototype.hasOwnProperty,In=Object.prototype.propertyIsEnumerable,Pn=(t,e,r)=>e in t?_n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Sn=(t,e)=>{for(var r in e||(e={}))En.call(e,r)&&Pn(t,r,e[r]);if(bn)for(var r of bn(e))In.call(e,r)&&Pn(t,r,e[r]);return t};class On extends h{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=Xe,this.events=new n.EventEmitter,this.initialized=!1,this.on=(t,e)=>this.events.on(t,e),this.once=(t,e)=>this.events.once(t,e),this.off=(t,e)=>this.events.off(t,e),this.removeListener=(t,e)=>this.events.removeListener(t,e),this.projectId=null===t||void 0===t?void 0:t.projectId,this.relayUrl=(null===t||void 0===t?void 0:t.relayUrl)||or,this.customStoragePrefix=null!=t&&t.customStoragePrefix?":".concat(t.customStoragePrefix):"";const e=typeof(null===t||void 0===t?void 0:t.logger)<"u"&&"string"!=typeof(null===t||void 0===t?void 0:t.logger)?t.logger:(0,c.pino)((0,c.getDefaultLoggerOptions)({level:(null===t||void 0===t?void 0:t.logger)||er}));this.logger=(0,c.generateChildLogger)(e,this.name),this.heartbeat=new a.HeartBeat,this.crypto=new Vr(this,this.logger,null===t||void 0===t?void 0:t.keychain),this.history=new yn(this,this.logger),this.expirer=new mn(this,this.logger),this.storage=null!=t&&t.storage?t.storage:new o.ZP(Sn(Sn({},rr),null===t||void 0===t?void 0:t.storageOptions)),this.relayer=new cn({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new vn(this,this.logger),this.verify=new wn(this.projectId||"",this.logger)}static async init(t){const e=new On(t);await e.initialize();const r=await e.crypto.getClientId();return await e.storage.setItem("WALLETCONNECT_CLIENT_ID",r),e}get context(){return(0,c.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 ".concat(Date.now()),t),this.logger.error(t.message),t}}}const xn=On,Rn="client",Cn="".concat("wc","@").concat(2,":").concat(Rn,":"),An=Rn,jn="error",Tn="WALLETCONNECT_DEEPLINK_CHOICE",Nn="Proposal expired",qn=O.SEVEN_DAYS,Dn={wc_sessionPropose:{req:{ttl:O.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1104},res:{ttl:O.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1106},res:{ttl:O.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:O.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:O.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1112},res:{ttl:O.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:O.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:O.THIRTY_SECONDS,prompt:!1,tag:1115}}},Ln={min:O.FIVE_MINUTES,max:O.SEVEN_DAYS},Mn="IDLE",zn="ACTIVE",kn=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Un=Object.defineProperty,Hn=Object.defineProperties,Vn=Object.getOwnPropertyDescriptors,Bn=Object.getOwnPropertySymbols,Kn=Object.prototype.hasOwnProperty,Fn=Object.prototype.propertyIsEnumerable,Gn=(t,e,r)=>e in t?Un(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Zn=(t,e)=>{for(var r in e||(e={}))Kn.call(e,r)&&Gn(t,r,e[r]);if(Bn)for(var r of Bn(e))Fn.call(e,r)&&Gn(t,r,e[r]);return t},Wn=(t,e)=>Hn(t,Vn(e));class Jn extends _{constructor(t){var e;super(t),e=this,this.name="engine",this.events=new(i()),this.initialized=!1,this.ignoredPayloadTypes=[s.rV],this.requestQueue={state:Mn,queue:[]},this.sessionRequestQueue={state:Mn,queue:[]},this.requestQueueDelay=O.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(Dn)}),this.initialized=!0,setTimeout((()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()}),(0,O.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{await this.isInitialized();const e=Wn(Zn({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(e);const{pairingTopic:r,requiredNamespaces:n,optionalNamespaces:i,sessionProperties:o,relays:a}=e;let c,u=r,h=!1;if(u&&(h=this.client.core.pairing.pairings.get(u).active),!u||!h){const{topic:t,uri:e}=await this.client.core.pairing.create();u=t,c=e}const l=await this.client.core.crypto.generateKeyPair(),f=Zn({requiredNamespaces:n,optionalNamespaces:i,relays:null!==a&&void 0!==a?a:[{protocol:"irn"}],proposer:{publicKey:l,metadata:this.client.metadata}},o&&{sessionProperties:o}),{reject:p,resolve:d,done:g}=(0,s.H1)(O.FIVE_MINUTES,Nn);if(this.events.once((0,s.E0)("session_connect"),(async t=>{let{error:e,session:r}=t;if(e)p(e);else if(r){r.self.publicKey=l;const t=Wn(Zn({},r),{requiredNamespaces:r.requiredNamespaces,optionalNamespaces:r.optionalNamespaces});await this.client.session.set(r.topic,t),await this.setExpiry(r.topic,r.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:r.peer.metadata}),d(t)}})),!u){const{message:t}=(0,s.Z7)("NO_MATCHING_KEY","connect() pairing topic: ".concat(u));throw new Error(t)}const v=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:f}),y=(0,s.gn)(O.FIVE_MINUTES);return await this.setProposal(v,Zn({id:v,expiry:y},f)),{uri:c,approval:g}},this.pair=async t=>(await this.isInitialized(),await this.client.core.pairing.pair(t)),this.approve=async t=>{await this.isInitialized(),await this.isValidApprove(t);const{id:e,relayProtocol:r,namespaces:n,sessionProperties:i}=t,o=this.client.proposal.get(e);let{pairingTopic:a,proposer:c,requiredNamespaces:u,optionalNamespaces:h}=o;a=a||"",(0,s.L5)(u)||(u=(0,s.fc)(n,"approve()"));const l=await this.client.core.crypto.generateKeyPair(),f=c.publicKey,p=await this.client.core.crypto.generateSharedKey(l,f);a&&e&&(await this.client.core.pairing.updateMetadata({topic:a,metadata:c.metadata}),await this.sendResult({id:e,topic:a,result:{relay:{protocol:null!==r&&void 0!==r?r:"irn"},responderPublicKey:l}}),await this.client.proposal.delete(e,(0,s.D6)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:a}));const d=Zn({relay:{protocol:null!==r&&void 0!==r?r:"irn"},namespaces:n,requiredNamespaces:u,optionalNamespaces:h,pairingTopic:a,controller:{publicKey:l,metadata:this.client.metadata},expiry:(0,s.gn)(qn)},i&&{sessionProperties:i});await this.client.core.relayer.subscribe(p),await this.sendRequest({topic:p,method:"wc_sessionSettle",params:d,throwOnFailedPublish:!0});const g=Wn(Zn({},d),{topic:p,pairingTopic:a,acknowledged:!1,self:d.controller,peer:{publicKey:c.publicKey,metadata:c.metadata},controller:l});return await this.client.session.set(p,g),await this.setExpiry(p,(0,s.gn)(qn)),{topic:p,acknowledged:()=>new Promise((t=>setTimeout((()=>t(this.client.session.get(p))),500)))}},this.reject=async t=>{await this.isInitialized(),await this.isValidReject(t);const{id:e,reason:r}=t,{pairingTopic:n}=this.client.proposal.get(e);n&&(await this.sendError(e,n,r),await this.client.proposal.delete(e,(0,s.D6)("USER_DISCONNECTED")))},this.update=async t=>{await this.isInitialized(),await this.isValidUpdate(t);const{topic:e,namespaces:r}=t,n=await this.sendRequest({topic:e,method:"wc_sessionUpdate",params:{namespaces:r}}),{done:i,resolve:o,reject:a}=(0,s.H1)();return this.events.once((0,s.E0)("session_update",n),(t=>{let{error:e}=t;e?a(e):o()})),await this.client.session.update(e,{namespaces:r}),{acknowledged:i}},this.extend=async t=>{await this.isInitialized(),await this.isValidExtend(t);const{topic:e}=t,r=await this.sendRequest({topic:e,method:"wc_sessionExtend",params:{}}),{done:n,resolve:i,reject:o}=(0,s.H1)();return this.events.once((0,s.E0)("session_extend",r),(t=>{let{error:e}=t;e?o(e):i()})),await this.setExpiry(e,(0,s.gn)(qn)),{acknowledged:n}},this.request=async t=>{await this.isInitialized(),await this.isValidRequest(t);const{chainId:e,request:r,topic:n,expiry:i}=t,o=et(),{done:a,resolve:c,reject:u}=(0,s.H1)(i,"Request expired. Please try again.");return this.events.once((0,s.E0)("session_request",o),(t=>{let{error:e,result:r}=t;e?u(e):c(r)})),await Promise.all([new Promise((async t=>{await this.sendRequest({clientRpcId:o,topic:n,method:"wc_sessionRequest",params:{request:r,chainId:e},expiry:i,throwOnFailedPublish:!0}).catch((t=>u(t))),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:e,id:o}),t()})),new Promise((async t=>{const e=await this.client.core.storage.getItem(Tn);(0,s.Hh)({id:o,topic:n,wcDeepLink:e}),t()})),a()]).then((t=>t[2]))},this.respond=async t=>{await this.isInitialized(),await this.isValidRespond(t);const{topic:e,response:r}=t,{id:n}=r;yt(r)?await this.sendResult({id:n,topic:e,result:r.result,throwOnFailedPublish:!0}):mt(r)&&await this.sendError(n,e,r.error),this.cleanupAfterResponse(t)},this.ping=async t=>{await this.isInitialized(),await this.isValidPing(t);const{topic:e}=t;if(this.client.session.keys.includes(e)){const t=await this.sendRequest({topic:e,method:"wc_sessionPing",params:{}}),{done:r,resolve:n,reject:i}=(0,s.H1)();this.events.once((0,s.E0)("session_ping",t),(t=>{let{error:e}=t;e?i(e):n()})),await r()}else this.client.core.pairing.pairings.keys.includes(e)&&await this.client.core.pairing.ping({topic:e})},this.emit=async t=>{await this.isInitialized(),await this.isValidEmit(t);const{topic:e,event:r,chainId:n}=t;await this.sendRequest({topic:e,method:"wc_sessionEvent",params:{event:r,chainId:n}})},this.disconnect=async t=>{await this.isInitialized(),await this.isValidDisconnect(t);const{topic:e}=t;this.client.session.keys.includes(e)?(await this.sendRequest({topic:e,method:"wc_sessionDelete",params:(0,s.D6)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(e)):await this.client.core.pairing.disconnect({topic:e})},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter((e=>(0,s.Ih)(e,t)))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{const e=this.client.core.pairing.pairings.get(t.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter((r=>{var n,i;return(null==(n=r.peerMetadata)?void 0:n.url)&&(null==(i=r.peerMetadata)?void 0:i.url)===t.peer.metadata.url&&r.topic&&r.topic!==e.topic}));if(0===r.length)return;this.client.logger.info("Cleaning up ".concat(r.length," duplicate pairing(s)")),await Promise.all(r.map((t=>this.client.core.pairing.disconnect({topic:t.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}},this.deleteSession=async(t,e)=>{const{self:r}=this.client.session.get(t);await this.client.core.relayer.unsubscribe(t),this.client.session.delete(t,(0,s.D6)("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(r.publicKey)&&await this.client.core.crypto.deleteKeyPair(r.publicKey),this.client.core.crypto.keychain.has(t)&&await this.client.core.crypto.deleteSymKey(t),e||this.client.core.expirer.del(t),this.client.core.storage.removeItem(Tn).catch((t=>this.client.logger.warn(t)))},this.deleteProposal=async(t,e)=>{await Promise.all([this.client.proposal.delete(t,(0,s.D6)("USER_DISCONNECTED")),e?Promise.resolve():this.client.core.expirer.del(t)])},this.deletePendingSessionRequest=async function(t,r){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];await Promise.all([e.client.pendingRequest.delete(t,r),n?Promise.resolve():e.client.core.expirer.del(t)]),e.sessionRequestQueue.queue=e.sessionRequestQueue.queue.filter((e=>e.id!==t)),n&&(e.sessionRequestQueue.state=Mn)},this.setExpiry=async(t,e)=>{this.client.session.keys.includes(t)&&await this.client.session.update(t,{expiry:e}),this.client.core.expirer.set(t,e)},this.setProposal=async(t,e)=>{await this.client.proposal.set(t,e),this.client.core.expirer.set(t,e.expiry)},this.setPendingSessionRequest=async t=>{const e=Dn.wc_sessionRequest.req.ttl,{id:r,topic:n,params:i,verifyContext:o}=t;await this.client.pendingRequest.set(r,{id:r,topic:n,params:i,verifyContext:o}),e&&this.client.core.expirer.set(r,(0,s.gn)(e))},this.sendRequest=async t=>{const{topic:e,method:r,params:n,expiry:i,relayRpcId:o,clientRpcId:a,throwOnFailedPublish:c}=t,u=nt(r,n,a);if((0,s.jU)()&&kn.includes(r)){const t=(0,s.rj)(JSON.stringify(u));this.client.core.verify.register({attestationId:t})}const h=await this.client.core.crypto.encode(e,u),l=Dn[r].req;return i&&(l.ttl=i),o&&(l.id=o),this.client.core.history.set(e,u),c?(l.internal=Wn(Zn({},l.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(e,h,l)):this.client.core.relayer.publish(e,h,l).catch((t=>this.client.logger.error(t))),u.id},this.sendResult=async t=>{const{id:e,topic:r,result:n,throwOnFailedPublish:i}=t,s=it(e,n),o=await this.client.core.crypto.encode(r,s),a=await this.client.core.history.get(r,e),c=Dn[a.request.method].res;i?(c.internal=Wn(Zn({},c.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,o,c)):this.client.core.relayer.publish(r,o,c).catch((t=>this.client.logger.error(t))),await this.client.core.history.resolve(s)},this.sendError=async(t,e,r)=>{const n=st(t,r),i=await this.client.core.crypto.encode(e,n),s=await this.client.core.history.get(e,t),o=Dn[s.request.method].res;this.client.core.relayer.publish(e,i,o),await this.client.core.history.resolve(n)},this.cleanup=async()=>{const t=[],e=[];this.client.session.getAll().forEach((e=>{(0,s.Bw)(e.expiry)&&t.push(e.topic)})),this.client.proposal.getAll().forEach((t=>{(0,s.Bw)(t.expiry)&&e.push(t.id)})),await Promise.all([...t.map((t=>this.deleteSession(t))),...e.map((t=>this.deleteProposal(t)))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state!==zn){for(this.client.logger.info("Request queue starting with ".concat(this.requestQueue.queue.length," requests"));this.requestQueue.queue.length>0;){this.requestQueue.state=zn;const e=this.requestQueue.queue.shift();if(e)try{this.processRequest(e),await new Promise((t=>setTimeout(t,300)))}catch(t){this.client.logger.warn(t)}}this.requestQueue.state=Mn}else this.client.logger.info("Request queue already active, skipping...")},this.processRequest=t=>{const{topic:e,payload:r}=t,n=r.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeRequest(e,r);case"wc_sessionSettle":return this.onSessionSettleRequest(e,r);case"wc_sessionUpdate":return this.onSessionUpdateRequest(e,r);case"wc_sessionExtend":return this.onSessionExtendRequest(e,r);case"wc_sessionPing":return this.onSessionPingRequest(e,r);case"wc_sessionDelete":return this.onSessionDeleteRequest(e,r);case"wc_sessionRequest":return this.onSessionRequest(e,r);case"wc_sessionEvent":return this.onSessionEventRequest(e,r);default:return this.client.logger.info("Unsupported request method ".concat(n))}},this.onRelayEventResponse=async t=>{const{topic:e,payload:r}=t,n=(await this.client.core.history.get(e,r.id)).request.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeResponse(e,r);case"wc_sessionSettle":return this.onSessionSettleResponse(e,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(e,r);case"wc_sessionExtend":return this.onSessionExtendResponse(e,r);case"wc_sessionPing":return this.onSessionPingResponse(e,r);case"wc_sessionRequest":return this.onSessionRequestResponse(e,r);default:return this.client.logger.info("Unsupported response method ".concat(n))}},this.onRelayEventUnknownPayload=t=>{const{topic:e}=t,{message:r}=(0,s.Z7)("MISSING_OR_INVALID","Decoded payload on topic ".concat(e," is not identifiable as a JSON-RPC request or a response."));throw new Error(r)},this.onSessionProposeRequest=async(t,e)=>{const{params:r,id:n}=e;try{this.isValidConnect(Zn({},e.params));const i=(0,s.gn)(O.FIVE_MINUTES),o=Zn({id:n,pairingTopic:t,expiry:i},r);await this.setProposal(n,o);const a=(0,s.rj)(JSON.stringify(e)),c=await this.getVerifyContext(a,o.proposer.metadata);this.client.events.emit("session_proposal",{id:n,params:o,verifyContext:c})}catch(h){await this.sendError(n,t,h),this.client.logger.error(h)}},this.onSessionProposeResponse=async(t,e)=>{const{id:r}=e;if(yt(e)){const{result:n}=e;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:n});const i=this.client.proposal.get(r);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:i});const s=i.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:s});const o=n.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:o});const a=await this.client.core.crypto.generateSharedKey(s,o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:a});const c=await this.client.core.relayer.subscribe(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:c}),await this.client.core.pairing.activate({topic:t})}else mt(e)&&(await this.client.proposal.delete(r,(0,s.D6)("USER_DISCONNECTED")),this.events.emit((0,s.E0)("session_connect"),{error:e.error}))},this.onSessionSettleRequest=async(t,e)=>{const{id:r,params:n}=e;try{this.isValidSessionSettleRequest(n);const{relay:r,controller:i,expiry:o,namespaces:a,requiredNamespaces:c,optionalNamespaces:u,sessionProperties:h,pairingTopic:l}=e.params,f=Zn({topic:t,relay:r,expiry:o,namespaces:a,acknowledged:!0,pairingTopic:l,requiredNamespaces:c,optionalNamespaces:u,controller:i.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:i.publicKey,metadata:i.metadata}},h&&{sessionProperties:h});await this.sendResult({id:e.id,topic:t,result:!0}),this.events.emit((0,s.E0)("session_connect"),{session:f}),this.cleanupDuplicatePairings(f)}catch(h){await this.sendError(r,t,h),this.client.logger.error(h)}},this.onSessionSettleResponse=async(t,e)=>{const{id:r}=e;yt(e)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit((0,s.E0)("session_approve",r),{})):mt(e)&&(await this.client.session.delete(t,(0,s.D6)("USER_DISCONNECTED")),this.events.emit((0,s.E0)("session_approve",r),{error:e.error}))},this.onSessionUpdateRequest=async(t,e)=>{const{params:r,id:n}=e;try{const e="".concat(t,"_session_update"),i=s.O6.get(e);if(i&&this.isRequestOutOfSync(i,n))return void this.client.logger.info("Discarding out of sync request - ".concat(n));this.isValidUpdate(Zn({topic:t},r)),await this.client.session.update(t,{namespaces:r.namespaces}),await this.sendResult({id:n,topic:t,result:!0}),this.client.events.emit("session_update",{id:n,topic:t,params:r}),s.O6.set(e,n)}catch(h){await this.sendError(n,t,h),this.client.logger.error(h)}},this.isRequestOutOfSync=(t,e)=>parseInt(e.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,e)=>{const{id:r}=e;yt(e)?this.events.emit((0,s.E0)("session_update",r),{}):mt(e)&&this.events.emit((0,s.E0)("session_update",r),{error:e.error})},this.onSessionExtendRequest=async(t,e)=>{const{id:r}=e;try{this.isValidExtend({topic:t}),await this.setExpiry(t,(0,s.gn)(qn)),await this.sendResult({id:r,topic:t,result:!0}),this.client.events.emit("session_extend",{id:r,topic:t})}catch(n){await this.sendError(r,t,n),this.client.logger.error(n)}},this.onSessionExtendResponse=(t,e)=>{const{id:r}=e;yt(e)?this.events.emit((0,s.E0)("session_extend",r),{}):mt(e)&&this.events.emit((0,s.E0)("session_extend",r),{error:e.error})},this.onSessionPingRequest=async(t,e)=>{const{id:r}=e;try{this.isValidPing({topic:t}),await this.sendResult({id:r,topic:t,result:!0}),this.client.events.emit("session_ping",{id:r,topic:t})}catch(n){await this.sendError(r,t,n),this.client.logger.error(n)}},this.onSessionPingResponse=(t,e)=>{const{id:r}=e;setTimeout((()=>{yt(e)?this.events.emit((0,s.E0)("session_ping",r),{}):mt(e)&&this.events.emit((0,s.E0)("session_ping",r),{error:e.error})}),500)},this.onSessionDeleteRequest=async(t,e)=>{const{id:r}=e;try{this.isValidDisconnect({topic:t,reason:e.params}),await Promise.all([new Promise((e=>{this.client.core.relayer.once(dr,(async()=>{e(await this.deleteSession(t))}))})),this.sendResult({id:r,topic:t,result:!0})]),this.client.events.emit("session_delete",{id:r,topic:t})}catch(n){this.client.logger.error(n)}},this.onSessionRequest=async(t,e)=>{const{id:r,params:n}=e;try{this.isValidRequest(Zn({topic:t},n));const e=(0,s.rj)(JSON.stringify(nt("wc_sessionRequest",n,r))),i=this.client.session.get(t),o={id:r,topic:t,params:n,verifyContext:await this.getVerifyContext(e,i.peer.metadata)};await this.setPendingSessionRequest(o),this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue()}catch(h){await this.sendError(r,t,h),this.client.logger.error(h)}},this.onSessionRequestResponse=(t,e)=>{const{id:r}=e;yt(e)?this.events.emit((0,s.E0)("session_request",r),{result:e.result}):mt(e)&&this.events.emit((0,s.E0)("session_request",r),{error:e.error})},this.onSessionEventRequest=async(t,e)=>{const{id:r,params:n}=e;try{const e="".concat(t,"_session_event_").concat(n.event.name),i=s.O6.get(e);if(i&&this.isRequestOutOfSync(i,r))return void this.client.logger.info("Discarding out of sync request - ".concat(r));this.isValidEmit(Zn({topic:t},n)),this.client.events.emit("session_event",{id:r,topic:t,params:n}),s.O6.set(e,r)}catch(h){await this.sendError(r,t,h),this.client.logger.error(h)}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.sessionRequestQueue.state=Mn,this.processSessionRequestQueue()}),(0,O.toMiliseconds)(this.requestQueueDelay))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===zn)return void this.client.logger.info("session request queue is already active.");const t=this.sessionRequestQueue.queue[0];if(t)try{this.sessionRequestQueue.state=zn,this.client.events.emit("session_request",t)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")},this.onPairingCreated=t=>{if(t.active)return;const e=this.client.proposal.getAll().find((e=>e.pairingTopic===t.topic));e&&this.onSessionProposeRequest(t.topic,nt("wc_sessionPropose",{requiredNamespaces:e.requiredNamespaces,optionalNamespaces:e.optionalNamespaces,relays:e.relays,proposer:e.proposer},e.id))},this.isValidConnect=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","connect() params: ".concat(JSON.stringify(t)));throw new Error(e)}const{pairingTopic:e,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:i,relays:o}=t;if((0,s.o8)(e)||await this.isValidPairingTopic(e),!(0,s.PM)(o,!0)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","connect() relays: ".concat(o));throw new Error(t)}!(0,s.o8)(r)&&0!==(0,s.L5)(r)&&this.validateNamespaces(r,"requiredNamespaces"),!(0,s.o8)(n)&&0!==(0,s.L5)(n)&&this.validateNamespaces(n,"optionalNamespaces"),(0,s.o8)(i)||this.validateSessionProps(i,"sessionProperties")},this.validateNamespaces=(t,e)=>{const r=(0,s.n)(t,"connect()",e);if(r)throw new Error(r.message)},this.isValidApprove=async t=>{if(!(0,s.EJ)(t))throw new Error((0,s.Z7)("MISSING_OR_INVALID","approve() params: ".concat(t)).message);const{id:e,namespaces:r,relayProtocol:n,sessionProperties:i}=t;await this.isValidProposalId(e);const o=this.client.proposal.get(e),a=(0,s.in)(r,"approve()");if(a)throw new Error(a.message);const c=(0,s.rF)(o.requiredNamespaces,r,"approve()");if(c)throw new Error(c.message);if(!(0,s.M_)(n,!0)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","approve() relayProtocol: ".concat(n));throw new Error(t)}(0,s.o8)(i)||this.validateSessionProps(i,"sessionProperties")},this.isValidReject=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","reject() params: ".concat(t));throw new Error(e)}const{id:e,reason:r}=t;if(await this.isValidProposalId(e),!(0,s.$t)(r)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","reject() reason: ".concat(JSON.stringify(r)));throw new Error(t)}},this.isValidSessionSettleRequest=t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","onSessionSettleRequest() params: ".concat(t));throw new Error(e)}const{relay:e,controller:r,namespaces:n,expiry:i}=t;if(!(0,s.Z2)(e)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(t)}const o=(0,s.Dd)(r,"onSessionSettleRequest()");if(o)throw new Error(o.message);const a=(0,s.in)(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);if((0,s.Bw)(i)){const{message:t}=(0,s.Z7)("EXPIRED","onSessionSettleRequest()");throw new Error(t)}},this.isValidUpdate=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","update() params: ".concat(t));throw new Error(e)}const{topic:e,namespaces:r}=t;await this.isValidSessionTopic(e);const n=this.client.session.get(e),i=(0,s.in)(r,"update()");if(i)throw new Error(i.message);const o=(0,s.rF)(n.requiredNamespaces,r,"update()");if(o)throw new Error(o.message)},this.isValidExtend=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","extend() params: ".concat(t));throw new Error(e)}const{topic:e}=t;await this.isValidSessionTopic(e)},this.isValidRequest=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","request() params: ".concat(t));throw new Error(e)}const{topic:e,request:r,chainId:n,expiry:i}=t;await this.isValidSessionTopic(e);const{namespaces:o}=this.client.session.get(e);if(!(0,s.p8)(o,n)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","request() chainId: ".concat(n));throw new Error(t)}if(!(0,s.hH)(r)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","request() ".concat(JSON.stringify(r)));throw new Error(t)}if(!(0,s.al)(o,n,r.method)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","request() method: ".concat(r.method));throw new Error(t)}if(i&&!(0,s.ON)(i,Ln)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","request() expiry: ".concat(i,". Expiry must be a number (in seconds) between ").concat(Ln.min," and ").concat(Ln.max));throw new Error(t)}},this.isValidRespond=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","respond() params: ".concat(t));throw new Error(e)}const{topic:e,response:r}=t;if(await this.isValidSessionTopic(e),!(0,s.JT)(r)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","respond() response: ".concat(JSON.stringify(r)));throw new Error(t)}},this.isValidPing=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","ping() params: ".concat(t));throw new Error(e)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e)},this.isValidEmit=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","emit() params: ".concat(t));throw new Error(e)}const{topic:e,event:r,chainId:n}=t;await this.isValidSessionTopic(e);const{namespaces:i}=this.client.session.get(e);if(!(0,s.p8)(i,n)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","emit() chainId: ".concat(n));throw new Error(t)}if(!(0,s.nf)(r)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","emit() event: ".concat(JSON.stringify(r)));throw new Error(t)}if(!(0,s.sI)(i,n,r.name)){const{message:t}=(0,s.Z7)("MISSING_OR_INVALID","emit() event: ".concat(JSON.stringify(r)));throw new Error(t)}},this.isValidDisconnect=async t=>{if(!(0,s.EJ)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","disconnect() params: ".concat(t));throw new Error(e)}const{topic:e}=t;await this.isValidSessionOrPairingTopic(e)},this.getVerifyContext=async(t,e)=>{const r={verified:{verifyUrl:e.verifyUrl||kr,validation:"UNKNOWN",origin:e.url||""}};try{const n=await this.client.core.verify.resolve({attestationId:t,verifyUrl:e.verifyUrl});n&&(r.verified.origin=n.origin,r.verified.isScam=n.isScam,r.verified.validation=n.origin===new URL(e.url).origin?"VALID":"INVALID")}catch(n){this.client.logger.info(n)}return this.client.logger.info("Verify context: ".concat(JSON.stringify(r))),r},this.validateSessionProps=(t,e)=>{Object.values(t).forEach((t=>{if(!(0,s.M_)(t,!1)){const{message:r}=(0,s.Z7)("MISSING_OR_INVALID","".concat(e," must be in Record format. Received: ").concat(JSON.stringify(t)));throw new Error(r)}}))}}async isInitialized(){if(!this.initialized){const{message:t}=(0,s.Z7)("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(cr,(async t=>{const{topic:e,message:r}=t;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(r)))return;const n=await this.client.core.crypto.decode(e,r);try{gt(n)?(this.client.core.history.set(e,n),this.onRelayEventRequest({topic:e,payload:n})):vt(n)?(await this.client.core.history.resolve(n),await this.onRelayEventResponse({topic:e,payload:n}),this.client.core.history.delete(e,n.id)):this.onRelayEventUnknownPayload({topic:e,payload:n})}catch(i){this.client.logger.error(i)}}))}registerExpirerEvents(){this.client.core.expirer.on(Lr,(async t=>{const{topic:e,id:r}=(0,s.iP)(t.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,(0,s.Z7)("EXPIRED"),!0);e?this.client.session.keys.includes(e)&&(await this.deleteSession(e,!0),this.client.events.emit("session_expire",{topic:e})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))}))}registerPairingEvents(){this.client.core.pairing.events.on(Or,(t=>this.onPairingCreated(t)))}isValidPairingTopic(t){if(!(0,s.M_)(t,!1)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","pairing topic should be a string: ".concat(t));throw new Error(e)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","pairing topic doesn't exist: ".concat(t));throw new Error(e)}if((0,s.Bw)(this.client.core.pairing.pairings.get(t).expiry)){const{message:e}=(0,s.Z7)("EXPIRED","pairing topic: ".concat(t));throw new Error(e)}}async isValidSessionTopic(t){if(!(0,s.M_)(t,!1)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","session topic should be a string: ".concat(t));throw new Error(e)}if(!this.client.session.keys.includes(t)){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","session topic doesn't exist: ".concat(t));throw new Error(e)}if((0,s.Bw)(this.client.session.get(t).expiry)){await this.deleteSession(t);const{message:e}=(0,s.Z7)("EXPIRED","session topic: ".concat(t));throw new Error(e)}}async isValidSessionOrPairingTopic(t){if(this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else{if(!this.client.core.pairing.pairings.keys.includes(t)){if((0,s.M_)(t,!1)){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","session or pairing topic doesn't exist: ".concat(t));throw new Error(e)}{const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","session or pairing topic should be a string: ".concat(t));throw new Error(e)}}this.isValidPairingTopic(t)}}async isValidProposalId(t){if(!(0,s.Q0)(t)){const{message:e}=(0,s.Z7)("MISSING_OR_INVALID","proposal id should be a number: ".concat(t));throw new Error(e)}if(!this.client.proposal.keys.includes(t)){const{message:e}=(0,s.Z7)("NO_MATCHING_KEY","proposal id doesn't exist: ".concat(t));throw new Error(e)}if((0,s.Bw)(this.client.proposal.get(t).expiry)){await this.deleteProposal(t);const{message:e}=(0,s.Z7)("EXPIRED","proposal id: ".concat(t));throw new Error(e)}}}class Qn extends gn{constructor(t,e){super(t,e,"proposal",Cn),this.core=t,this.logger=e}}class Yn extends gn{constructor(t,e){super(t,e,"session",Cn),this.core=t,this.logger=e}}class $n extends gn{constructor(t,e){super(t,e,"request",Cn,(t=>t.id)),this.core=t,this.logger=e}}class Xn extends w{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=An,this.events=new n.EventEmitter,this.on=(t,e)=>this.events.on(t,e),this.once=(t,e)=>this.events.once(t,e),this.off=(t,e)=>this.events.off(t,e),this.removeListener=(t,e)=>this.events.removeListener(t,e),this.removeAllListeners=t=>this.events.removeAllListeners(t),this.connect=async t=>{try{return await this.engine.connect(t)}catch(e){throw this.logger.error(e.message),e}},this.pair=async t=>{try{return await this.engine.pair(t)}catch(e){throw this.logger.error(e.message),e}},this.approve=async t=>{try{return await this.engine.approve(t)}catch(e){throw this.logger.error(e.message),e}},this.reject=async t=>{try{return await this.engine.reject(t)}catch(e){throw this.logger.error(e.message),e}},this.update=async t=>{try{return await this.engine.update(t)}catch(e){throw this.logger.error(e.message),e}},this.extend=async t=>{try{return await this.engine.extend(t)}catch(e){throw this.logger.error(e.message),e}},this.request=async t=>{try{return await this.engine.request(t)}catch(e){throw this.logger.error(e.message),e}},this.respond=async t=>{try{return await this.engine.respond(t)}catch(e){throw this.logger.error(e.message),e}},this.ping=async t=>{try{return await this.engine.ping(t)}catch(e){throw this.logger.error(e.message),e}},this.emit=async t=>{try{return await this.engine.emit(t)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async t=>{try{return await this.engine.disconnect(t)}catch(e){throw this.logger.error(e.message),e}},this.find=t=>{try{return this.engine.find(t)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(t){throw this.logger.error(t.message),t}},this.name=(null===t||void 0===t?void 0:t.name)||An,this.metadata=(null===t||void 0===t?void 0:t.metadata)||(0,s.D)();const e=typeof(null===t||void 0===t?void 0:t.logger)<"u"&&"string"!=typeof(null===t||void 0===t?void 0:t.logger)?t.logger:(0,c.pino)((0,c.getDefaultLoggerOptions)({level:(null===t||void 0===t?void 0:t.logger)||jn}));this.core=(null===t||void 0===t?void 0:t.core)||new xn(t),this.logger=(0,c.generateChildLogger)(e,this.name),this.session=new Yn(this.core,this.logger),this.proposal=new Qn(this.core,this.logger),this.pendingRequest=new $n(this.core,this.logger),this.engine=new Jn(this)}static async init(t){const e=new Xn(t);return await e.initialize(),e}get context(){return(0,c.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}}}var ti=r(7605),ei=r.n(ti);const ri={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class ni{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.url=t,this.disableProviderPing=e,this.events=new n.EventEmitter,this.isAvailable=!1,this.registering=!1,!lt(t))throw new Error("Provided URL is not compatible with HTTP connection: ".concat(t));this.url=t,this.disableProviderPing=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}async open(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.url;await this.register(t)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(t,e){this.isAvailable||await this.register();try{const e=I(t),r=await ei()(this.url,Object.assign(Object.assign({},ri),{body:e})),n=await r.json();this.onPayload({data:n})}catch(r){this.onError(t.id,r)}}async register(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.url;if(!lt(t))throw new Error("Provided URL is not compatible with HTTP connection: ".concat(t));if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise(((t,e)=>{this.events.once("register_error",(t=>{this.resetMaxListeners(),e(t)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),"undefined"===typeof this.isAvailable)return e(new Error("HTTP connection is missing or invalid"));t()}))}))}this.url=t,this.registering=!0;try{if(!this.disableProviderPing){const e=I({id:1,jsonrpc:"2.0",method:"test",params:[]});await ei()(t,Object.assign(Object.assign({},ri),{body:e}))}this.onOpen()}catch(e){const t=this.parseError(e);throw this.events.emit("register_error",t),this.onClose(),t}}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("undefined"===typeof t.data)return;const e="string"===typeof t.data?E(t.data):t.data;this.events.emit("payload",e)}onError(t,e){const r=this.parseError(e),n=st(t,r.message||r.toString());this.events.emit("payload",n)}parseError(t){return X(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.url,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}const ii=ni,si="error",oi="".concat("wc","@2:").concat("universal_provider",":"),ai="default_chain_changed";var ci=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof r.g<"u"?r.g:typeof self<"u"?self:{},ui={exports:{}};!function(t,e){(function(){var r,n="Expected a function",i="__lodash_hash_undefined__",s="__lodash_placeholder__",o=16,a=32,c=64,u=128,h=256,l=1/0,f=9007199254740991,p=NaN,d=4294967295,g=[["ary",u],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",a],["partialRight",c],["rearg",h]],v="[object Arguments]",y="[object Array]",m="[object Boolean]",w="[object Date]",_="[object Error]",b="[object Function]",E="[object GeneratorFunction]",I="[object Map]",P="[object Number]",S="[object Object]",O="[object Promise]",x="[object RegExp]",R="[object Set]",C="[object String]",A="[object Symbol]",j="[object WeakMap]",T="[object ArrayBuffer]",N="[object DataView]",q="[object Float32Array]",D="[object Float64Array]",L="[object Int8Array]",M="[object Int16Array]",z="[object Int32Array]",k="[object Uint8Array]",U="[object Uint8ClampedArray]",H="[object Uint16Array]",V="[object Uint32Array]",B=/\b__p \+= '';/g,K=/\b(__p \+=) '' \+/g,F=/(__e\(.*?\)|\b__t\)) \+\n'';/g,G=/&(?:amp|lt|gt|quot|#39);/g,Z=/[&<>"']/g,W=RegExp(G.source),J=RegExp(Z.source),Q=/<%-([\s\S]+?)%>/g,Y=/<%([\s\S]+?)%>/g,$=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tt=/^\w*$/,et=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rt=/[\\^$.*+?()[\]{}|]/g,nt=RegExp(rt.source),it=/^\s+/,st=/\s/,ot=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,at=/\{\n\/\* \[wrapped with (.+)\] \*/,ct=/,? & /,ut=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ht=/[()=,{}\[\]\/\s]/,lt=/\\(\\)?/g,ft=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pt=/\w*$/,dt=/^[-+]0x[0-9a-f]+$/i,gt=/^0b[01]+$/i,vt=/^\[object .+?Constructor\]$/,yt=/^0o[0-7]+$/i,mt=/^(?:0|[1-9]\d*)$/,wt=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,_t=/($^)/,bt=/['\n\r\u2028\u2029\\]/g,Et="\\ud800-\\udfff",It="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Pt="\\u2700-\\u27bf",St="a-z\\xdf-\\xf6\\xf8-\\xff",Ot="A-Z\\xc0-\\xd6\\xd8-\\xde",xt="\\ufe0e\\ufe0f",Rt="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\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",Ct="['\u2019]",At="["+Et+"]",jt="["+Rt+"]",Tt="["+It+"]",Nt="\\d+",qt="["+Pt+"]",Dt="["+St+"]",Lt="[^"+Et+Rt+Nt+Pt+St+Ot+"]",Mt="\\ud83c[\\udffb-\\udfff]",zt="[^"+Et+"]",kt="(?:\\ud83c[\\udde6-\\uddff]){2}",Ut="[\\ud800-\\udbff][\\udc00-\\udfff]",Ht="["+Ot+"]",Vt="\\u200d",Bt="(?:"+Dt+"|"+Lt+")",Kt="(?:"+Ht+"|"+Lt+")",Ft="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",Gt="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",Zt="(?:"+Tt+"|"+Mt+")"+"?",Wt="["+xt+"]?",Jt=Wt+Zt+("(?:"+Vt+"(?:"+[zt,kt,Ut].join("|")+")"+Wt+Zt+")*"),Qt="(?:"+[qt,kt,Ut].join("|")+")"+Jt,Yt="(?:"+[zt+Tt+"?",Tt,kt,Ut,At].join("|")+")",$t=RegExp(Ct,"g"),Xt=RegExp(Tt,"g"),te=RegExp(Mt+"(?="+Mt+")|"+Yt+Jt,"g"),ee=RegExp([Ht+"?"+Dt+"+"+Ft+"(?="+[jt,Ht,"$"].join("|")+")",Kt+"+"+Gt+"(?="+[jt,Ht+Bt,"$"].join("|")+")",Ht+"?"+Bt+"+"+Ft,Ht+"+"+Gt,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Nt,Qt].join("|"),"g"),re=RegExp("["+Vt+Et+It+xt+"]"),ne=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,ie=["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"],se=-1,oe={};oe[q]=oe[D]=oe[L]=oe[M]=oe[z]=oe[k]=oe[U]=oe[H]=oe[V]=!0,oe[v]=oe[y]=oe[T]=oe[m]=oe[N]=oe[w]=oe[_]=oe[b]=oe[I]=oe[P]=oe[S]=oe[x]=oe[R]=oe[C]=oe[j]=!1;var ae={};ae[v]=ae[y]=ae[T]=ae[N]=ae[m]=ae[w]=ae[q]=ae[D]=ae[L]=ae[M]=ae[z]=ae[I]=ae[P]=ae[S]=ae[x]=ae[R]=ae[C]=ae[A]=ae[k]=ae[U]=ae[H]=ae[V]=!0,ae[_]=ae[b]=ae[j]=!1;var ce={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ue=parseFloat,he=parseInt,le="object"==typeof ci&&ci&&ci.Object===Object&&ci,fe="object"==typeof self&&self&&self.Object===Object&&self,pe=le||fe||Function("return this")(),de=e&&!e.nodeType&&e,ge=de&&t&&!t.nodeType&&t,ve=ge&&ge.exports===de,ye=ve&&le.process,me=function(){try{return ge&&ge.require&&ge.require("util").types||ye&&ye.binding&&ye.binding("util")}catch{}}(),we=me&&me.isArrayBuffer,_e=me&&me.isDate,be=me&&me.isMap,Ee=me&&me.isRegExp,Ie=me&&me.isSet,Pe=me&&me.isTypedArray;function Se(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function Oe(t,e,r,n){for(var i=-1,s=null==t?0:t.length;++i-1}function Te(t,e,r){for(var n=-1,i=null==t?0:t.length;++n-1;);return r}function er(t,e){for(var r=t.length;r--&&He(e,t[r],0)>-1;);return r}var rr=Ge({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),nr=Ge({"&":"&","<":"<",">":">",'"':""","'":"'"});function ir(t){return"\\"+ce[t]}function sr(t){return re.test(t)}function or(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function ar(t,e){return function(r){return t(e(r))}}function cr(t,e){for(var r=-1,n=t.length,i=0,o=[];++r",""":'"',"'":"'"});var dr=function t(e){var st=(e=null==e?pe:dr.defaults(pe.Object(),e,dr.pick(pe,ie))).Array,Et=e.Date,It=e.Error,Pt=e.Function,St=e.Math,Ot=e.Object,xt=e.RegExp,Rt=e.String,Ct=e.TypeError,At=st.prototype,jt=Pt.prototype,Tt=Ot.prototype,Nt=e["__core-js_shared__"],qt=jt.toString,Dt=Tt.hasOwnProperty,Lt=0,Mt=function(){var t=/[^.]+$/.exec(Nt&&Nt.keys&&Nt.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),zt=Tt.toString,kt=qt.call(Ot),Ut=pe._,Ht=xt("^"+qt.call(Dt).replace(rt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Vt=ve?e.Buffer:r,Bt=e.Symbol,Kt=e.Uint8Array,Ft=Vt?Vt.allocUnsafe:r,Gt=ar(Ot.getPrototypeOf,Ot),Zt=Ot.create,Wt=Tt.propertyIsEnumerable,Jt=At.splice,Qt=Bt?Bt.isConcatSpreadable:r,Yt=Bt?Bt.iterator:r,te=Bt?Bt.toStringTag:r,re=function(){try{var t=hs(Ot,"defineProperty");return t({},"",{}),t}catch{}}(),ce=e.clearTimeout!==pe.clearTimeout&&e.clearTimeout,le=Et&&Et.now!==pe.Date.now&&Et.now,fe=e.setTimeout!==pe.setTimeout&&e.setTimeout,de=St.ceil,ge=St.floor,ye=Ot.getOwnPropertySymbols,me=Vt?Vt.isBuffer:r,ze=e.isFinite,Ge=At.join,gr=ar(Ot.keys,Ot),vr=St.max,yr=St.min,mr=Et.now,wr=e.parseInt,_r=St.random,br=At.reverse,Er=hs(e,"DataView"),Ir=hs(e,"Map"),Pr=hs(e,"Promise"),Sr=hs(e,"Set"),Or=hs(e,"WeakMap"),xr=hs(Ot,"create"),Rr=Or&&new Or,Cr={},Ar=Ls(Er),jr=Ls(Ir),Tr=Ls(Pr),Nr=Ls(Sr),qr=Ls(Or),Dr=Bt?Bt.prototype:r,Lr=Dr?Dr.valueOf:r,Mr=Dr?Dr.toString:r;function zr(t){if(ta(t)&&!Bo(t)&&!(t instanceof Vr)){if(t instanceof Hr)return t;if(Dt.call(t,"__wrapped__"))return Ms(t)}return new Hr(t)}var kr=function(){function t(){}return function(e){if(!Xo(e))return{};if(Zt)return Zt(e);t.prototype=e;var n=new t;return t.prototype=r,n}}();function Ur(){}function Hr(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=r}function Vr(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=d,this.__views__=[]}function Br(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e=e?t:e)),t}function an(t,e,n,i,s,o){var a,c=1&e,u=2&e,h=4&e;if(n&&(a=s?n(t,i,s,o):n(t)),a!==r)return a;if(!Xo(t))return t;var l=Bo(t);if(l){if(a=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Dt.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!c)return Ri(t,a)}else{var f=ps(t),p=f==b||f==E;if(Zo(t))return Ei(t,c);if(f==S||f==v||p&&!s){if(a=u||p?{}:gs(t),!c)return u?function(t,e){return Ci(t,fs(t),e)}(t,function(t,e){return t&&Ci(e,ja(e),t)}(a,t)):function(t,e){return Ci(t,ls(t),e)}(t,rn(a,t))}else{if(!ae[f])return s?t:{};a=function(t,e,r){var n=t.constructor;switch(e){case T:return Ii(t);case m:case w:return new n(+t);case N:return function(t,e){var r=e?Ii(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case q:case D:case L:case M:case z:case k:case U:case H:case V:return Pi(t,r);case I:return new n;case P:case C:return new n(t);case x:return function(t){var e=new t.constructor(t.source,pt.exec(t));return e.lastIndex=t.lastIndex,e}(t);case R:return new n;case A:return function(t){return Lr?Ot(Lr.call(t)):{}}(t)}}(t,f,c)}}o||(o=new Zr);var d=o.get(t);if(d)return d;o.set(t,a),sa(t)?t.forEach((function(r){a.add(an(r,e,n,r,t,o))})):ea(t)&&t.forEach((function(r,i){a.set(i,an(r,e,n,i,t,o))}));var g=l?r:(h?u?ns:rs:u?ja:Aa)(t);return xe(g||t,(function(r,i){g&&(r=t[i=r]),Xr(a,i,an(r,e,n,i,t,o))})),a}function cn(t,e,n){var i=n.length;if(null==t)return!i;for(t=Ot(t);i--;){var s=n[i],o=e[s],a=t[s];if(a===r&&!(s in t)||!o(a))return!1}return!0}function un(t,e,i){if("function"!=typeof t)throw new Ct(n);return Cs((function(){t.apply(r,i)}),e)}function hn(t,e,r,n){var i=-1,s=je,o=!0,a=t.length,c=[],u=e.length;if(!a)return c;r&&(e=Ne(e,Ye(r))),n?(s=Te,o=!1):e.length>=200&&(s=Xe,o=!1,e=new Gr(e));t:for(;++i-1},Kr.prototype.set=function(t,e){var r=this.__data__,n=tn(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},Fr.prototype.clear=function(){this.size=0,this.__data__={hash:new Br,map:new(Ir||Kr),string:new Br}},Fr.prototype.delete=function(t){var e=cs(this,t).delete(t);return this.size-=e?1:0,e},Fr.prototype.get=function(t){return cs(this,t).get(t)},Fr.prototype.has=function(t){return cs(this,t).has(t)},Fr.prototype.set=function(t,e){var r=cs(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Gr.prototype.add=Gr.prototype.push=function(t){return this.__data__.set(t,i),this},Gr.prototype.has=function(t){return this.__data__.has(t)},Zr.prototype.clear=function(){this.__data__=new Kr,this.size=0},Zr.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Zr.prototype.get=function(t){return this.__data__.get(t)},Zr.prototype.has=function(t){return this.__data__.has(t)},Zr.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Kr){var n=r.__data__;if(!Ir||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Fr(n)}return r.set(t,e),this.size=r.size,this};var ln=Ti(wn),fn=Ti(_n,!0);function pn(t,e){var r=!0;return ln(t,(function(t,n,i){return r=!!e(t,n,i)})),r}function dn(t,e,n){for(var i=-1,s=t.length;++i0&&r(a)?e>1?vn(a,e-1,r,n,i):qe(i,a):n||(i[i.length]=a)}return i}var yn=Ni(),mn=Ni(!0);function wn(t,e){return t&&yn(t,e,Aa)}function _n(t,e){return t&&mn(t,e,Aa)}function bn(t,e){return Ae(e,(function(e){return Qo(t[e])}))}function En(t,e){for(var n=0,i=(e=mi(e,t)).length;null!=t&&ne}function On(t,e){return null!=t&&Dt.call(t,e)}function xn(t,e){return null!=t&&e in Ot(t)}function Rn(t,e,n){for(var i=n?Te:je,s=t[0].length,o=t.length,a=o,c=st(o),u=1/0,h=[];a--;){var l=t[a];a&&e&&(l=Ne(l,Ye(e))),u=yr(l.length,u),c[a]=!n&&(e||s>=120&&l.length>=120)?new Gr(a&&l):r}l=t[0];var f=-1,p=c[0];t:for(;++f=a?c:c*("desc"==r[n]?-1:1)}return t.index-e.index}(t,e,r)}))}function Kn(t,e,r){for(var n=-1,i=e.length,s={};++n-1;)a!==t&&Jt.call(a,c,1),Jt.call(t,c,1);return t}function Gn(t,e){for(var r=t?e.length:0,n=r-1;r--;){var i=e[r];if(r==n||i!==s){var s=i;ys(i)?Jt.call(t,i,1):hi(t,i)}}return t}function Zn(t,e){return t+ge(_r()*(e-t+1))}function Wn(t,e){var r="";if(!t||e<1||e>f)return r;do{e%2&&(r+=t),(e=ge(e/2))&&(t+=t)}while(e);return r}function Jn(t,e){return As(Ss(t,e,rc),t+"")}function Qn(t){return Jr(ka(t))}function Yn(t,e){var r=ka(t);return Ns(r,on(e,0,r.length))}function $n(t,e,n,i){if(!Xo(t))return t;for(var s=-1,o=(e=mi(e,t)).length,a=o-1,c=t;null!=c&&++si?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var s=st(i);++n>>1,o=t[s];null!==o&&!aa(o)&&(r?o<=e:o=200){var u=e?null:Wi(t);if(u)return ur(u);o=!1,i=Xe,c=new Gr}else c=e?[]:a;t:for(;++n=i?t:ri(t,e,n)}var bi=ce||function(t){return pe.clearTimeout(t)};function Ei(t,e){if(e)return t.slice();var r=t.length,n=Ft?Ft(r):new t.constructor(r);return t.copy(n),n}function Ii(t){var e=new t.constructor(t.byteLength);return new Kt(e).set(new Kt(t)),e}function Pi(t,e){var r=e?Ii(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}function Si(t,e){if(t!==e){var n=t!==r,i=null===t,s=t===t,o=aa(t),a=e!==r,c=null===e,u=e===e,h=aa(e);if(!c&&!h&&!o&&t>e||o&&a&&u&&!c&&!h||i&&a&&u||!n&&u||!s)return 1;if(!i&&!o&&!h&&t1?n[s-1]:r,a=s>2?n[2]:r;for(o=t.length>3&&"function"==typeof o?(s--,o):r,a&&ms(n[0],n[1],a)&&(o=s<3?r:o,s=1),e=Ot(e);++i-1?s[o?e[a]:a]:r}}function zi(t){return es((function(e){var i=e.length,s=i,o=Hr.prototype.thru;for(t&&e.reverse();s--;){var a=e[s];if("function"!=typeof a)throw new Ct(n);if(o&&!c&&"wrapper"==ss(a))var c=new Hr([],!0)}for(s=c?s:i;++s1&&w.reverse(),f&&hc))return!1;var h=o.get(t),l=o.get(e);if(h&&l)return h==e&&l==t;var f=-1,p=!0,d=2&n?new Gr:r;for(o.set(t,e),o.set(e,t);++f-1&&t%1==0&&t1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(ot,"{\n/* [wrapped with "+e+"] */\n")}(n,function(t,e){return xe(g,(function(r){var n="_."+r[0];e&r[1]&&!je(t,n)&&t.push(n)})),t.sort()}(function(t){var e=t.match(at);return e?e[1].split(ct):[]}(n),r)))}function Ts(t){var e=0,n=0;return function(){var i=mr(),s=16-(i-n);if(n=i,s>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(r,arguments)}}function Ns(t,e){var n=-1,i=t.length,s=i-1;for(e=e===r?i:e;++n1?t[e-1]:r;return n="function"==typeof n?(t.pop(),n):r,no(t,n)}));function ho(t){var e=zr(t);return e.__chain__=!0,e}function lo(t,e){return e(t)}var fo=es((function(t){var e=t.length,n=e?t[0]:0,i=this.__wrapped__,s=function(e){return sn(e,t)};return!(e>1||this.__actions__.length)&&i instanceof Vr&&ys(n)?((i=i.slice(n,+n+(e?1:0))).__actions__.push({func:lo,args:[s],thisArg:r}),new Hr(i,this.__chain__).thru((function(t){return e&&!t.length&&t.push(r),t}))):this.thru(s)}));var po=Ai((function(t,e,r){Dt.call(t,r)?++t[r]:nn(t,r,1)}));var go=Mi(Hs),vo=Mi(Vs);function yo(t,e){return(Bo(t)?xe:ln)(t,as(e,3))}function mo(t,e){return(Bo(t)?Re:fn)(t,as(e,3))}var wo=Ai((function(t,e,r){Dt.call(t,r)?t[r].push(e):nn(t,r,[e])}));var _o=Jn((function(t,e,r){var n=-1,i="function"==typeof e,s=Fo(t)?st(t.length):[];return ln(t,(function(t){s[++n]=i?Se(e,t,r):Cn(t,e,r)})),s})),bo=Ai((function(t,e,r){nn(t,r,e)}));function Eo(t,e){return(Bo(t)?Ne:zn)(t,as(e,3))}var Io=Ai((function(t,e,r){t[r?0:1].push(e)}),(function(){return[[],[]]}));var Po=Jn((function(t,e){if(null==t)return[];var r=e.length;return r>1&&ms(t,e[0],e[1])?e=[]:r>2&&ms(e[0],e[1],e[2])&&(e=[e[0]]),Bn(t,vn(e,1),[])})),So=le||function(){return pe.Date.now()};function Oo(t,e,n){return e=n?r:e,e=t&&null==e?t.length:e,Qi(t,u,r,r,r,r,e)}function xo(t,e){var i;if("function"!=typeof e)throw new Ct(n);return t=pa(t),function(){return--t>0&&(i=e.apply(this,arguments)),t<=1&&(e=r),i}}var Ro=Jn((function(t,e,r){var n=1;if(r.length){var i=cr(r,os(Ro));n|=a}return Qi(t,n,e,r,i)})),Co=Jn((function(t,e,r){var n=3;if(r.length){var i=cr(r,os(Co));n|=a}return Qi(e,n,t,r,i)}));function Ao(t,e,i){var s,o,a,c,u,h,l=0,f=!1,p=!1,d=!0;if("function"!=typeof t)throw new Ct(n);function g(e){var n=s,i=o;return s=o=r,l=e,c=t.apply(i,n)}function v(t){var n=t-h;return h===r||n>=e||n<0||p&&t-l>=a}function y(){var t=So();if(v(t))return m(t);u=Cs(y,function(t){var r=e-(t-h);return p?yr(r,a-(t-l)):r}(t))}function m(t){return u=r,d&&s?g(t):(s=o=r,c)}function w(){var t=So(),n=v(t);if(s=arguments,o=this,h=t,n){if(u===r)return function(t){return l=t,u=Cs(y,e),f?g(t):c}(h);if(p)return bi(u),u=Cs(y,e),g(h)}return u===r&&(u=Cs(y,e)),c}return e=ga(e)||0,Xo(i)&&(f=!!i.leading,a=(p="maxWait"in i)?vr(ga(i.maxWait)||0,e):a,d="trailing"in i?!!i.trailing:d),w.cancel=function(){u!==r&&bi(u),l=0,s=h=o=u=r},w.flush=function(){return u===r?c:m(So())},w}var jo=Jn((function(t,e){return un(t,1,e)})),To=Jn((function(t,e,r){return un(t,ga(e)||0,r)}));function No(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new Ct(n);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=t.apply(this,n);return r.cache=s.set(i,o)||s,o};return r.cache=new(No.Cache||Fr),r}function qo(t){if("function"!=typeof t)throw new Ct(n);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}No.Cache=Fr;var Do=wi((function(t,e){var r=(e=1==e.length&&Bo(e[0])?Ne(e[0],Ye(as())):Ne(vn(e,1),Ye(as()))).length;return Jn((function(n){for(var i=-1,s=yr(n.length,r);++i=e})),Vo=An(function(){return arguments}())?An:function(t){return ta(t)&&Dt.call(t,"callee")&&!Wt.call(t,"callee")},Bo=st.isArray,Ko=we?Ye(we):function(t){return ta(t)&&Pn(t)==T};function Fo(t){return null!=t&&$o(t.length)&&!Qo(t)}function Go(t){return ta(t)&&Fo(t)}var Zo=me||gc,Wo=_e?Ye(_e):function(t){return ta(t)&&Pn(t)==w};function Jo(t){if(!ta(t))return!1;var e=Pn(t);return e==_||"[object DOMException]"==e||"string"==typeof t.message&&"string"==typeof t.name&&!na(t)}function Qo(t){if(!Xo(t))return!1;var e=Pn(t);return e==b||e==E||"[object AsyncFunction]"==e||"[object Proxy]"==e}function Yo(t){return"number"==typeof t&&t==pa(t)}function $o(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=f}function Xo(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ta(t){return null!=t&&"object"==typeof t}var ea=be?Ye(be):function(t){return ta(t)&&ps(t)==I};function ra(t){return"number"==typeof t||ta(t)&&Pn(t)==P}function na(t){if(!ta(t)||Pn(t)!=S)return!1;var e=Gt(t);if(null===e)return!0;var r=Dt.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&qt.call(r)==kt}var ia=Ee?Ye(Ee):function(t){return ta(t)&&Pn(t)==x};var sa=Ie?Ye(Ie):function(t){return ta(t)&&ps(t)==R};function oa(t){return"string"==typeof t||!Bo(t)&&ta(t)&&Pn(t)==C}function aa(t){return"symbol"==typeof t||ta(t)&&Pn(t)==A}var ca=Pe?Ye(Pe):function(t){return ta(t)&&$o(t.length)&&!!oe[Pn(t)]};var ua=Fi(Mn),ha=Fi((function(t,e){return t<=e}));function la(t){if(!t)return[];if(Fo(t))return oa(t)?lr(t):Ri(t);if(Yt&&t[Yt])return function(t){for(var e,r=[];!(e=t.next()).done;)r.push(e.value);return r}(t[Yt]());var e=ps(t);return(e==I?or:e==R?ur:ka)(t)}function fa(t){return t?(t=ga(t))===l||t===-l?17976931348623157e292*(t<0?-1:1):t===t?t:0:0===t?t:0}function pa(t){var e=fa(t),r=e%1;return e===e?r?e-r:e:0}function da(t){return t?on(pa(t),0,d):0}function ga(t){if("number"==typeof t)return t;if(aa(t))return p;if(Xo(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=Xo(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=Qe(t);var r=gt.test(t);return r||yt.test(t)?he(t.slice(2),r?2:8):dt.test(t)?p:+t}function va(t){return Ci(t,ja(t))}function ya(t){return null==t?"":ci(t)}var ma=ji((function(t,e){if(Es(e)||Fo(e))Ci(e,Aa(e),t);else for(var r in e)Dt.call(e,r)&&Xr(t,r,e[r])})),wa=ji((function(t,e){Ci(e,ja(e),t)})),_a=ji((function(t,e,r,n){Ci(e,ja(e),t,n)})),ba=ji((function(t,e,r,n){Ci(e,Aa(e),t,n)})),Ea=es(sn);var Ia=Jn((function(t,e){t=Ot(t);var n=-1,i=e.length,s=i>2?e[2]:r;for(s&&ms(e[0],e[1],s)&&(i=1);++n1),e})),Ci(t,ns(t),r),n&&(r=an(r,7,Xi));for(var i=e.length;i--;)hi(r,e[i]);return r}));var Da=es((function(t,e){return null==t?{}:function(t,e){return Kn(t,e,(function(e,r){return Oa(t,r)}))}(t,e)}));function La(t,e){if(null==t)return{};var r=Ne(ns(t),(function(t){return[t]}));return e=as(e),Kn(t,r,(function(t,r){return e(t,r[0])}))}var Ma=Ji(Aa),za=Ji(ja);function ka(t){return null==t?[]:$e(t,Aa(t))}var Ua=Di((function(t,e,r){return e=e.toLowerCase(),t+(r?Ha(e):e)}));function Ha(t){return Ja(ya(t).toLowerCase())}function Va(t){return(t=ya(t))&&t.replace(wt,rr).replace(Xt,"")}var Ba=Di((function(t,e,r){return t+(r?"-":"")+e.toLowerCase()})),Ka=Di((function(t,e,r){return t+(r?" ":"")+e.toLowerCase()})),Fa=qi("toLowerCase");var Ga=Di((function(t,e,r){return t+(r?"_":"")+e.toLowerCase()}));var Za=Di((function(t,e,r){return t+(r?" ":"")+Ja(e)}));var Wa=Di((function(t,e,r){return t+(r?" ":"")+e.toUpperCase()})),Ja=qi("toUpperCase");function Qa(t,e,n){return t=ya(t),(e=n?r:e)===r?function(t){return ne.test(t)}(t)?function(t){return t.match(ee)||[]}(t):function(t){return t.match(ut)||[]}(t):t.match(e)||[]}var Ya=Jn((function(t,e){try{return Se(t,r,e)}catch(n){return Jo(n)?n:new It(n)}})),$a=es((function(t,e){return xe(e,(function(e){e=Ds(e),nn(t,e,Ro(t[e],t))})),t}));function Xa(t){return function(){return t}}var tc=zi(),ec=zi(!0);function rc(t){return t}function nc(t){return qn("function"==typeof t?t:an(t,1))}var ic=Jn((function(t,e){return function(r){return Cn(r,t,e)}})),sc=Jn((function(t,e){return function(r){return Cn(t,r,e)}}));function oc(t,e,r){var n=Aa(e),i=bn(e,n);null==r&&(!Xo(e)||!i.length&&n.length)&&(r=e,e=t,t=this,i=bn(e,Aa(e)));var s=!(Xo(r)&&"chain"in r)||!!r.chain,o=Qo(t);return xe(i,(function(r){var n=e[r];t[r]=n,o&&(t.prototype[r]=function(){var e=this.__chain__;if(s||e){var r=t(this.__wrapped__);return(r.__actions__=Ri(this.__actions__)).push({func:n,args:arguments,thisArg:t}),r.__chain__=e,r}return n.apply(t,qe([this.value()],arguments))})})),t}function ac(){}var cc=Vi(Ne),uc=Vi(Ce),hc=Vi(Me);function lc(t){return ws(t)?Fe(Ds(t)):function(t){return function(e){return En(e,t)}}(t)}var fc=Ki(),pc=Ki(!0);function dc(){return[]}function gc(){return!1}var vc=Hi((function(t,e){return t+e}),0),yc=Zi("ceil"),mc=Hi((function(t,e){return t/e}),1),wc=Zi("floor");var _c=Hi((function(t,e){return t*e}),1),bc=Zi("round"),Ec=Hi((function(t,e){return t-e}),0);return zr.after=function(t,e){if("function"!=typeof e)throw new Ct(n);return t=pa(t),function(){if(--t<1)return e.apply(this,arguments)}},zr.ary=Oo,zr.assign=ma,zr.assignIn=wa,zr.assignInWith=_a,zr.assignWith=ba,zr.at=Ea,zr.before=xo,zr.bind=Ro,zr.bindAll=$a,zr.bindKey=Co,zr.castArray=function(){if(!arguments.length)return[];var t=arguments[0];return Bo(t)?t:[t]},zr.chain=ho,zr.chunk=function(t,e,n){e=(n?ms(t,e,n):e===r)?1:vr(pa(e),0);var i=null==t?0:t.length;if(!i||e<1)return[];for(var s=0,o=0,a=st(de(i/e));ss?0:s+n),(i=i===r||i>s?s:pa(i))<0&&(i+=s),i=n>i?0:da(i);n>>0)?(t=ya(t))&&("string"==typeof e||null!=e&&!ia(e))&&(!(e=ci(e))&&sr(t))?_i(lr(t),0,n):t.split(e,n):[]},zr.spread=function(t,e){if("function"!=typeof t)throw new Ct(n);return e=null==e?0:vr(pa(e),0),Jn((function(r){var n=r[e],i=_i(r,0,e);return n&&qe(i,n),Se(t,this,i)}))},zr.tail=function(t){var e=null==t?0:t.length;return e?ri(t,1,e):[]},zr.take=function(t,e,n){return t&&t.length?ri(t,0,(e=n||e===r?1:pa(e))<0?0:e):[]},zr.takeRight=function(t,e,n){var i=null==t?0:t.length;return i?ri(t,(e=i-(e=n||e===r?1:pa(e)))<0?0:e,i):[]},zr.takeRightWhile=function(t,e){return t&&t.length?fi(t,as(e,3),!1,!0):[]},zr.takeWhile=function(t,e){return t&&t.length?fi(t,as(e,3)):[]},zr.tap=function(t,e){return e(t),t},zr.throttle=function(t,e,r){var i=!0,s=!0;if("function"!=typeof t)throw new Ct(n);return Xo(r)&&(i="leading"in r?!!r.leading:i,s="trailing"in r?!!r.trailing:s),Ao(t,e,{leading:i,maxWait:e,trailing:s})},zr.thru=lo,zr.toArray=la,zr.toPairs=Ma,zr.toPairsIn=za,zr.toPath=function(t){return Bo(t)?Ne(t,Ds):aa(t)?[t]:Ri(qs(ya(t)))},zr.toPlainObject=va,zr.transform=function(t,e,r){var n=Bo(t),i=n||Zo(t)||ca(t);if(e=as(e,4),null==r){var s=t&&t.constructor;r=i?n?new s:[]:Xo(t)&&Qo(s)?kr(Gt(t)):{}}return(i?xe:wn)(t,(function(t,n,i){return e(r,t,n,i)})),r},zr.unary=function(t){return Oo(t,1)},zr.union=Xs,zr.unionBy=to,zr.unionWith=eo,zr.uniq=function(t){return t&&t.length?ui(t):[]},zr.uniqBy=function(t,e){return t&&t.length?ui(t,as(e,2)):[]},zr.uniqWith=function(t,e){return e="function"==typeof e?e:r,t&&t.length?ui(t,r,e):[]},zr.unset=function(t,e){return null==t||hi(t,e)},zr.unzip=ro,zr.unzipWith=no,zr.update=function(t,e,r){return null==t?t:li(t,e,yi(r))},zr.updateWith=function(t,e,n,i){return i="function"==typeof i?i:r,null==t?t:li(t,e,yi(n),i)},zr.values=ka,zr.valuesIn=function(t){return null==t?[]:$e(t,ja(t))},zr.without=io,zr.words=Qa,zr.wrap=function(t,e){return Lo(yi(e),t)},zr.xor=so,zr.xorBy=oo,zr.xorWith=ao,zr.zip=co,zr.zipObject=function(t,e){return gi(t||[],e||[],Xr)},zr.zipObjectDeep=function(t,e){return gi(t||[],e||[],$n)},zr.zipWith=uo,zr.entries=Ma,zr.entriesIn=za,zr.extend=wa,zr.extendWith=_a,oc(zr,zr),zr.add=vc,zr.attempt=Ya,zr.camelCase=Ua,zr.capitalize=Ha,zr.ceil=yc,zr.clamp=function(t,e,n){return n===r&&(n=e,e=r),n!==r&&(n=(n=ga(n))===n?n:0),e!==r&&(e=(e=ga(e))===e?e:0),on(ga(t),e,n)},zr.clone=function(t){return an(t,4)},zr.cloneDeep=function(t){return an(t,5)},zr.cloneDeepWith=function(t,e){return an(t,5,e="function"==typeof e?e:r)},zr.cloneWith=function(t,e){return an(t,4,e="function"==typeof e?e:r)},zr.conformsTo=function(t,e){return null==e||cn(t,e,Aa(e))},zr.deburr=Va,zr.defaultTo=function(t,e){return null==t||t!==t?e:t},zr.divide=mc,zr.endsWith=function(t,e,n){t=ya(t),e=ci(e);var i=t.length,s=n=n===r?i:on(pa(n),0,i);return(n-=e.length)>=0&&t.slice(n,s)==e},zr.eq=ko,zr.escape=function(t){return(t=ya(t))&&J.test(t)?t.replace(Z,nr):t},zr.escapeRegExp=function(t){return(t=ya(t))&&nt.test(t)?t.replace(rt,"\\$&"):t},zr.every=function(t,e,n){var i=Bo(t)?Ce:pn;return n&&ms(t,e,n)&&(e=r),i(t,as(e,3))},zr.find=go,zr.findIndex=Hs,zr.findKey=function(t,e){return ke(t,as(e,3),wn)},zr.findLast=vo,zr.findLastIndex=Vs,zr.findLastKey=function(t,e){return ke(t,as(e,3),_n)},zr.floor=wc,zr.forEach=yo,zr.forEachRight=mo,zr.forIn=function(t,e){return null==t?t:yn(t,as(e,3),ja)},zr.forInRight=function(t,e){return null==t?t:mn(t,as(e,3),ja)},zr.forOwn=function(t,e){return t&&wn(t,as(e,3))},zr.forOwnRight=function(t,e){return t&&_n(t,as(e,3))},zr.get=Sa,zr.gt=Uo,zr.gte=Ho,zr.has=function(t,e){return null!=t&&ds(t,e,On)},zr.hasIn=Oa,zr.head=Ks,zr.identity=rc,zr.includes=function(t,e,r,n){t=Fo(t)?t:ka(t),r=r&&!n?pa(r):0;var i=t.length;return r<0&&(r=vr(i+r,0)),oa(t)?r<=i&&t.indexOf(e,r)>-1:!!i&&He(t,e,r)>-1},zr.indexOf=function(t,e,r){var n=null==t?0:t.length;if(!n)return-1;var i=null==r?0:pa(r);return i<0&&(i=vr(n+i,0)),He(t,e,i)},zr.inRange=function(t,e,n){return e=fa(e),n===r?(n=e,e=0):n=fa(n),function(t,e,r){return t>=yr(e,r)&&t=-f&&t<=f},zr.isSet=sa,zr.isString=oa,zr.isSymbol=aa,zr.isTypedArray=ca,zr.isUndefined=function(t){return t===r},zr.isWeakMap=function(t){return ta(t)&&ps(t)==j},zr.isWeakSet=function(t){return ta(t)&&"[object WeakSet]"==Pn(t)},zr.join=function(t,e){return null==t?"":Ge.call(t,e)},zr.kebabCase=Ba,zr.last=Ws,zr.lastIndexOf=function(t,e,n){var i=null==t?0:t.length;if(!i)return-1;var s=i;return n!==r&&(s=(s=pa(n))<0?vr(i+s,0):yr(s,i-1)),e===e?function(t,e,r){for(var n=r+1;n--;)if(t[n]===e)return n;return n}(t,e,s):Ue(t,Be,s,!0)},zr.lowerCase=Ka,zr.lowerFirst=Fa,zr.lt=ua,zr.lte=ha,zr.max=function(t){return t&&t.length?dn(t,rc,Sn):r},zr.maxBy=function(t,e){return t&&t.length?dn(t,as(e,2),Sn):r},zr.mean=function(t){return Ke(t,rc)},zr.meanBy=function(t,e){return Ke(t,as(e,2))},zr.min=function(t){return t&&t.length?dn(t,rc,Mn):r},zr.minBy=function(t,e){return t&&t.length?dn(t,as(e,2),Mn):r},zr.stubArray=dc,zr.stubFalse=gc,zr.stubObject=function(){return{}},zr.stubString=function(){return""},zr.stubTrue=function(){return!0},zr.multiply=_c,zr.nth=function(t,e){return t&&t.length?Vn(t,pa(e)):r},zr.noConflict=function(){return pe._===this&&(pe._=Ut),this},zr.noop=ac,zr.now=So,zr.pad=function(t,e,r){t=ya(t);var n=(e=pa(e))?hr(t):0;if(!e||n>=e)return t;var i=(e-n)/2;return Bi(ge(i),r)+t+Bi(de(i),r)},zr.padEnd=function(t,e,r){t=ya(t);var n=(e=pa(e))?hr(t):0;return e&&ne){var i=t;t=e,e=i}if(n||t%1||e%1){var s=_r();return yr(t+s*(e-t+ue("1e-"+((s+"").length-1))),e)}return Zn(t,e)},zr.reduce=function(t,e,r){var n=Bo(t)?De:Ze,i=arguments.length<3;return n(t,as(e,4),r,i,ln)},zr.reduceRight=function(t,e,r){var n=Bo(t)?Le:Ze,i=arguments.length<3;return n(t,as(e,4),r,i,fn)},zr.repeat=function(t,e,n){return e=(n?ms(t,e,n):e===r)?1:pa(e),Wn(ya(t),e)},zr.replace=function(){var t=arguments,e=ya(t[0]);return t.length<3?e:e.replace(t[1],t[2])},zr.result=function(t,e,n){var i=-1,s=(e=mi(e,t)).length;for(s||(s=1,t=r);++if)return[];var r=d,n=yr(t,d);e=as(e),t-=d;for(var i=Je(n,e);++r=o)return t;var c=n-hr(i);if(c<1)return i;var u=a?_i(a,0,c).join(""):t.slice(0,c);if(s===r)return u+i;if(a&&(c+=u.length-c),ia(s)){if(t.slice(c).search(s)){var h,l=u;for(s.global||(s=xt(s.source,ya(pt.exec(s))+"g")),s.lastIndex=0;h=s.exec(l);)var f=h.index;u=u.slice(0,f===r?c:f)}}else if(t.indexOf(ci(s),c)!=c){var p=u.lastIndexOf(s);p>-1&&(u=u.slice(0,p))}return u+i},zr.unescape=function(t){return(t=ya(t))&&W.test(t)?t.replace(G,pr):t},zr.uniqueId=function(t){var e=++Lt;return ya(t)+e},zr.upperCase=Wa,zr.upperFirst=Ja,zr.each=yo,zr.eachRight=mo,zr.first=Ks,oc(zr,function(){var t={};return wn(zr,(function(e,r){Dt.call(zr.prototype,r)||(t[r]=e)})),t}(),{chain:!1}),zr.VERSION="4.17.21",xe(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(t){zr[t].placeholder=zr})),xe(["drop","take"],(function(t,e){Vr.prototype[t]=function(n){n=n===r?1:vr(pa(n),0);var i=this.__filtered__&&!e?new Vr(this):this.clone();return i.__filtered__?i.__takeCount__=yr(n,i.__takeCount__):i.__views__.push({size:yr(n,d),type:t+(i.__dir__<0?"Right":"")}),i},Vr.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}})),xe(["filter","map","takeWhile"],(function(t,e){var r=e+1,n=1==r||3==r;Vr.prototype[t]=function(t){var e=this.clone();return e.__iteratees__.push({iteratee:as(t,3),type:r}),e.__filtered__=e.__filtered__||n,e}})),xe(["head","last"],(function(t,e){var r="take"+(e?"Right":"");Vr.prototype[t]=function(){return this[r](1).value()[0]}})),xe(["initial","tail"],(function(t,e){var r="drop"+(e?"":"Right");Vr.prototype[t]=function(){return this.__filtered__?new Vr(this):this[r](1)}})),Vr.prototype.compact=function(){return this.filter(rc)},Vr.prototype.find=function(t){return this.filter(t).head()},Vr.prototype.findLast=function(t){return this.reverse().find(t)},Vr.prototype.invokeMap=Jn((function(t,e){return"function"==typeof t?new Vr(this):this.map((function(r){return Cn(r,t,e)}))})),Vr.prototype.reject=function(t){return this.filter(qo(as(t)))},Vr.prototype.slice=function(t,e){t=pa(t);var n=this;return n.__filtered__&&(t>0||e<0)?new Vr(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==r&&(n=(e=pa(e))<0?n.dropRight(-e):n.take(e-t)),n)},Vr.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Vr.prototype.toArray=function(){return this.take(d)},wn(Vr.prototype,(function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),i=/^(?:head|last)$/.test(e),s=zr[i?"take"+("last"==e?"Right":""):e],o=i||/^find/.test(e);s&&(zr.prototype[e]=function(){var e=this.__wrapped__,a=i?[1]:arguments,c=e instanceof Vr,u=a[0],h=c||Bo(e),l=function(t){var e=s.apply(zr,qe([t],a));return i&&f?e[0]:e};h&&n&&"function"==typeof u&&1!=u.length&&(c=h=!1);var f=this.__chain__,p=!!this.__actions__.length,d=o&&!f,g=c&&!p;if(!o&&h){e=g?e:new Vr(this);var v=t.apply(e,a);return v.__actions__.push({func:lo,args:[l],thisArg:r}),new Hr(v,f)}return d&&g?t.apply(this,a):(v=this.thru(l),d?i?v.value()[0]:v.value():v)})})),xe(["pop","push","shift","sort","splice","unshift"],(function(t){var e=At[t],r=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",n=/^(?:pop|shift)$/.test(t);zr.prototype[t]=function(){var t=arguments;if(n&&!this.__chain__){var i=this.value();return e.apply(Bo(i)?i:[],t)}return this[r]((function(r){return e.apply(Bo(r)?r:[],t)}))}})),wn(Vr.prototype,(function(t,e){var r=zr[e];if(r){var n=r.name+"";Dt.call(Cr,n)||(Cr[n]=[]),Cr[n].push({name:e,func:r})}})),Cr[ki(r,2).name]=[{name:"wrapper",func:r}],Vr.prototype.clone=function(){var t=new Vr(this.__wrapped__);return t.__actions__=Ri(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ri(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ri(this.__views__),t},Vr.prototype.reverse=function(){if(this.__filtered__){var t=new Vr(this);t.__dir__=-1,t.__filtered__=!0}else(t=this.clone()).__dir__*=-1;return t},Vr.prototype.value=function(){var t=this.__wrapped__.value(),e=this.__dir__,r=Bo(t),n=e<0,i=r?t.length:0,s=function(t,e,r){for(var n=-1,i=r.length;++n=this.__values__.length;return{done:t,value:t?r:this.__values__[this.__index__++]}},zr.prototype.plant=function(t){for(var e,n=this;n instanceof Ur;){var i=Ms(n);i.__index__=0,i.__values__=r,e?s.__wrapped__=i:e=i;var s=i;n=n.__wrapped__}return s.__wrapped__=t,e},zr.prototype.reverse=function(){var t=this.__wrapped__;if(t instanceof Vr){var e=t;return this.__actions__.length&&(e=new Vr(this)),(e=e.reverse()).__actions__.push({func:lo,args:[$s],thisArg:r}),new Hr(e,this.__chain__)}return this.thru($s)},zr.prototype.toJSON=zr.prototype.valueOf=zr.prototype.value=function(){return pi(this.__wrapped__,this.__actions__)},zr.prototype.first=zr.prototype.head,Yt&&(zr.prototype[Yt]=function(){return this}),zr}();ge?((ge.exports=dr)._=dr,de._=dr):pe._=dr}).call(ci)}(ui,ui.exports);var hi=Object.defineProperty,li=Object.defineProperties,fi=Object.getOwnPropertyDescriptors,pi=Object.getOwnPropertySymbols,di=Object.prototype.hasOwnProperty,gi=Object.prototype.propertyIsEnumerable,vi=(t,e,r)=>e in t?hi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yi=(t,e)=>{for(var r in e||(e={}))di.call(e,r)&&vi(t,r,e[r]);if(pi)for(var r of pi(e))gi.call(e,r)&&vi(t,r,e[r]);return t},mi=(t,e)=>li(t,fi(e));function wi(t,e,r){var n;const i=(0,s.DQ)(t);return(null==(n=e.rpcMap)?void 0:n[i.reference])||"".concat("https://rpc.walletconnect.com/v1/","?chainId=").concat(i.namespace,":").concat(i.reference,"&projectId=").concat(r)}function _i(t){return t.includes(":")?t.split(":")[1]:t}function bi(t){return t.map((t=>"".concat(t.split(":")[0],":").concat(t.split(":")[1])))}function Ei(t){var e,r,n,i;const o={};if(!(0,s.L5)(t))return o;for(const[a,c]of Object.entries(t)){const t=(0,s.gp)(a)?[a]:c.chains,u=c.methods||[],h=c.events||[],l=c.rpcMap||{},f=(0,s.M)(a);o[f]=mi(yi(yi({},o[f]),c),{chains:(0,s.eG)(t,null==(e=o[f])?void 0:e.chains),methods:(0,s.eG)(u,null==(r=o[f])?void 0:r.methods),events:(0,s.eG)(h,null==(n=o[f])?void 0:n.events),rpcMap:yi(yi({},l),null==(i=o[f])?void 0:i.rpcMap)})}return o}function Ii(t){return t.includes(":")?t.split(":")[2]:t}function Pi(t){const e={};for(const[r,n]of Object.entries(t)){const t=n.methods||[],i=n.events||[],o=n.accounts||[],a=(0,s.gp)(r)?[r]:n.chains?n.chains:bi(n.accounts);e[r]={chains:a,methods:t,events:i,accounts:o}}return e}function Si(t){return"number"==typeof t?t:t.includes("0x")?parseInt(t,16):t.includes(":")?Number(t.split(":")[1]):Number(t)}const Oi={},xi=t=>Oi[t],Ri=(t,e)=>{Oi[t]=e};class Ci{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=xi("events"),this.client=xi("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,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(ai,"".concat(this.name,":").concat(t))}getAccounts(){const t=this.namespace.accounts;return t&&t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2]))||[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const n=_i(e);t[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t="".concat(this.name,":").concat(this.chainId),e=this.httpProviders[t];if(typeof e>"u")throw new Error("JSON-RPC provider for ".concat(t," not found"));return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||wi(t,this.namespace,this.client.core.projectId);if(!r)throw new Error("No RPC url provided for chainId: ".concat(t));return new wt(new ii(r,xi("disableProviderPing")))}}class Ai{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=xi("events"),this.client=xi("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":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,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(ai,"".concat(this.name,":").concat(t))}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,e){const r=e||wi("".concat(this.name,":").concat(t),this.namespace,this.client.core.projectId);if(!r)throw new Error("No RPC url provided for chainId: ".concat(t));return new wt(new ni(r,xi("disableProviderPing")))}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const n=parseInt(_i(e));t[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error("JSON-RPC provider for ".concat(t," not found"));return e}async handleSwitchChain(t){var e,r;let n=t.request.params?null==(e=t.request.params[0])?void 0:e.chainId:"0x0";n=n.startsWith("0x")?n:"0x".concat(n);const i=parseInt(n,16);if(this.isChainApproved(i))this.setDefaultChain("".concat(i));else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error("Failed to switch to chain 'eip155:".concat(i,"'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method."));await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:n}]},chainId:null==(r=this.namespace.chains)?void 0:r[0]}),this.setDefaultChain("".concat(i))}return null}isChainApproved(t){return this.namespace.chains.includes("".concat(this.name,":").concat(t))}}class ji{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=xi("events"),this.client=xi("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,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(ai,"".concat(this.name,":").concat(t))}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((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const n=_i(e);t[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t="".concat(this.name,":").concat(this.chainId),e=this.httpProviders[t];if(typeof e>"u")throw new Error("JSON-RPC provider for ".concat(t," not found"));return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||wi(t,this.namespace,this.client.core.projectId);if(!r)throw new Error("No RPC url provided for chainId: ".concat(t));return new wt(new ii(r,xi("disableProviderPing")))}}class Ti{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=xi("events"),this.client=xi("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,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(ai,"".concat(this.name,":").concat(this.chainId))}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const n=_i(e);t[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t="".concat(this.name,":").concat(this.chainId),e=this.httpProviders[t];if(typeof e>"u")throw new Error("JSON-RPC provider for ".concat(t," not found"));return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||wi(t,this.namespace,this.client.core.projectId);if(!r)throw new Error("No RPC url provided for chainId: ".concat(t));return new wt(new ii(r,xi("disableProviderPing")))}}class Ni{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=xi("events"),this.client=xi("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,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(ai,"".concat(this.name,":").concat(this.chainId))}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{const r=this.getCardanoRPCUrl(e),n=_i(e);t[n]=this.createHttpProvider(n,r)})),t}getHttpProvider(){const t="".concat(this.name,":").concat(this.chainId),e=this.httpProviders[t];if(typeof e>"u")throw new Error("JSON-RPC provider for ".concat(t," not found"));return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||this.getCardanoRPCUrl(t);if(!r)throw new Error("No RPC url provided for chainId: ".concat(t));return new wt(new ii(r,xi("disableProviderPing")))}}class qi{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=xi("events"),this.client=xi("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,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(ai,"".concat(this.name,":").concat(t))}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((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const n=_i(e);t[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t="".concat(this.name,":").concat(this.chainId),e=this.httpProviders[t];if(typeof e>"u")throw new Error("JSON-RPC provider for ".concat(t," not found"));return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||wi(t,this.namespace,this.client.core.projectId);if(!r)throw new Error("No RPC url provided for chainId: ".concat(t));return new wt(new ii(r,xi("disableProviderPing")))}}class Di{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=xi("events"),this.client=xi("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,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(ai,"".concat(this.name,":").concat(t))}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((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2])))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;const n=_i(e);t[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t="".concat(this.name,":").concat(this.chainId),e=this.httpProviders[t];if(typeof e>"u")throw new Error("JSON-RPC provider for ".concat(t," not found"));return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||wi(t,this.namespace,this.client.core.projectId);if(!r)throw new Error("No RPC url provided for chainId: ".concat(t));return new wt(new ii(r,xi("disableProviderPing")))}}class Li{constructor(t){this.name="near",this.namespace=t.namespace,this.events=xi("events"),this.client=xi("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,e){if(this.chainId=t,!this.httpProviders[t]){const r=e||wi("".concat(this.name,":").concat(t),this.namespace);if(!r)throw new Error("No RPC url provided for chainId: ".concat(t));this.setHttpProvider(t,r)}this.events.emit(ai,"".concat(this.name,":").concat(this.chainId))}getAccounts(){const t=this.namespace.accounts;return t&&t.filter((t=>t.split(":")[1]===this.chainId.toString())).map((t=>t.split(":")[2]))||[]}createHttpProviders(){const t={};return this.namespace.chains.forEach((e=>{var r;t[e]=this.createHttpProvider(e,null==(r=this.namespace.rpcMap)?void 0:r[e])})),t}getHttpProvider(){const t="".concat(this.name,":").concat(this.chainId),e=this.httpProviders[t];if(typeof e>"u")throw new Error("JSON-RPC provider for ".concat(t," not found"));return e}setHttpProvider(t,e){const r=this.createHttpProvider(t,e);r&&(this.httpProviders[t]=r)}createHttpProvider(t,e){const r=e||wi(t,this.namespace);return typeof r>"u"?void 0:new wt(new ii(r,xi("disableProviderPing")))}}var Mi=Object.defineProperty,zi=Object.defineProperties,ki=Object.getOwnPropertyDescriptors,Ui=Object.getOwnPropertySymbols,Hi=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable,Bi=(t,e,r)=>e in t?Mi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ki=(t,e)=>{for(var r in e||(e={}))Hi.call(e,r)&&Bi(t,r,e[r]);if(Ui)for(var r of Ui(e))Vi.call(e,r)&&Bi(t,r,e[r]);return t},Fi=(t,e)=>zi(t,ki(e));class Gi{constructor(t){this.events=new(i()),this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(null===t||void 0===t?void 0:t.logger)<"u"&&"string"!=typeof(null===t||void 0===t?void 0:t.logger)?t.logger:(0,c.pino)((0,c.getDefaultLoggerOptions)({level:(null===t||void 0===t?void 0:t.logger)||si})),this.disableProviderPing=(null===t||void 0===t?void 0:t.disableProviderPing)||!1}static async init(t){const e=new Gi(t);return await e.initialize(),e}async request(t,e){const[r,n]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(r).request({request:Ki({},t),chainId:"".concat(r,":").concat(n),topic:this.session.topic})}sendAsync(t,e,r){this.request(t,r).then((t=>e(null,t))).catch((t=>e(t,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:null==(t=this.session)?void 0:t.topic,reason:(0,s.D6)("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,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:r,approval:n}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});r&&(this.uri=r,this.events.emit("display_uri",r)),await n().then((t=>{this.session=t,this.namespaces||(this.namespaces=Pi(t.namespaces),this.persist("namespaces",this.namespaces))})).catch((t=>{if(t.message!==Nn)throw t;e++}))}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[r,n]=this.validateChain(t);this.getProvider(r).setDefaultChain(n,e)}catch(v){if(!/Please call connect/.test(v.message))throw v}}async cleanupPendingPairings(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if((0,s.qt)(e)){for(const r of e)t.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info("Inactive pairings cleared: ".concat(e.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 Xn.init({logger:this.providerOpts.logger||si,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.com",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((t=>(0,s.M)(t))))];Ri("client",this.client),Ri("events",this.events),Ri("disableProviderPing",this.disableProviderPing),t.forEach((t=>{if(!this.session)return;const e=function(t,e){const r=Object.keys(e.namespaces).filter((e=>e.includes(t)));if(!r.length)return[];const n=[];return r.forEach((t=>{const r=e.namespaces[t].accounts;n.push(...r)})),n}(t,this.session),r=bi(e),n=function(){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const e=Ei(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),r=Ei(t);return ui.exports.merge(e,r)}(this.namespaces,this.optionalNamespaces),i=Fi(Ki({},n[t]),{accounts:e,chains:r});switch(t){case"eip155":this.rpcProviders[t]=new Ai({namespace:i});break;case"solana":this.rpcProviders[t]=new ji({namespace:i});break;case"cosmos":this.rpcProviders[t]=new Ti({namespace:i});break;case"polkadot":this.rpcProviders[t]=new Ci({namespace:i});break;case"cip34":this.rpcProviders[t]=new Ni({namespace:i});break;case"elrond":this.rpcProviders[t]=new qi({namespace:i});break;case"multiversx":this.rpcProviders[t]=new Di({namespace:i});break;case"near":this.rpcProviders[t]=new Li({namespace:i})}}))}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:e}=t,{event:r}=e;if("accountsChanged"===r.name){const t=r.data;t&&(0,s.qt)(t)&&this.events.emit("accountsChanged",t.map(Ii))}else if("chainChanged"===r.name){const t=e.chainId,r=e.event.data,n=(0,s.M)(t),i=Si(t)!==Si(r)?"".concat(n,":").concat(Si(r)):t;this.onChainChanged(i)}else this.events.emit(r.name,r.data);this.events.emit("session_event",t)})),this.client.on("session_update",(t=>{let{topic:e,params:r}=t;var n;const{namespaces:i}=r,s=null==(n=this.client)?void 0:n.session.get(e);this.session=Fi(Ki({},s),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})})),this.client.on("session_delete",(async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",Fi(Ki({},(0,s.D6)("USER_DISCONNECTED")),{data:t.topic}))})),this.on(ai,(t=>{this.onChainChanged(t,!0)}))}getProvider(t){if(!this.rpcProviders[t])throw new Error("Provider not found: ".concat(t));return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach((t=>{var e;this.getProvider(t).updateNamespace(null==(e=this.session)?void 0:e.namespaces[t])}))}setNamespaces(t){const{namespaces:e,optionalNamespaces:r,sessionProperties:n}=t;e&&Object.keys(e).length&&(this.namespaces=e),r&&Object.keys(r).length&&(this.optionalNamespaces=r),this.sessionProperties=n,this.persist("namespaces",e),this.persist("optionalNamespaces",r)}validateChain(t){const[e,r]=(null===t||void 0===t?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,r];if(e&&!Object.keys(this.namespaces||{}).map((t=>(0,s.M)(t))).includes(e))throw new Error("Namespace '".concat(e,"' is not configured. Please call connect() first with namespace config."));if(e&&r)return[e,r];const n=(0,s.M)(Object.keys(this.namespaces)[0]);return[n,this.rpcProviders[n].getDefaultChain()]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];var r;if(!this.namespaces)return;const[n,i]=this.validateChain(t);e||this.getProvider(n).setDefaultChain(i),(null!=(r=this.namespaces[n])?r:this.namespaces["".concat(n,":").concat(i)]).defaultChain=i,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i)}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,e){this.client.core.storage.setItem("".concat(oi,"/").concat(t),e)}async getFromStore(t){return await this.client.core.storage.getItem("".concat(oi,"/").concat(t))}}const Zi=Gi,Wi="".concat("wc","@2:").concat("ethereum_provider",":"),Ji=["eth_sendTransaction","personal_sign"],Qi=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],Yi=["chainChanged","accountsChanged"],$i=["chainChanged","accountsChanged","message","disconnect","connect"];var Xi=Object.defineProperty,ts=Object.defineProperties,es=Object.getOwnPropertyDescriptors,rs=Object.getOwnPropertySymbols,ns=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,ss=(t,e,r)=>e in t?Xi(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,os=(t,e)=>{for(var r in e||(e={}))ns.call(e,r)&&ss(t,r,e[r]);if(rs)for(var r of rs(e))is.call(e,r)&&ss(t,r,e[r]);return t},as=(t,e)=>ts(t,es(e));function cs(t){return Number(t[0].split(":")[1])}function us(t){return"0x".concat(t.toString(16))}class hs{constructor(){this.events=new n.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=Wi,this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new hs;return await e.initialize(t),e}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,e){this.signer.sendAsync(t,e,this.formatChainId(this.chainId))}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}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:e,optional:r}=function(t){const{chains:e,optionalChains:r,methods:n,optionalMethods:i,events:o,optionalEvents:a,rpcMap:c}=t;if(!(0,s.qt)(e))throw new Error("Invalid chains");const u={chains:e,methods:n||Ji,events:o||Yi,rpcMap:os({},e.length?{[cs(e)]:c[cs(e)]}:{})},h=null===o||void 0===o?void 0:o.filter((t=>!Yi.includes(t))),l=null===n||void 0===n?void 0:n.filter((t=>!Ji.includes(t)));if(!r&&!a&&!i&&(null==h||!h.length)&&(null==l||!l.length))return{required:e.length?u:void 0};const f=(null===h||void 0===h?void 0:h.length)&&(null===l||void 0===l?void 0:l.length)||!r,p={chains:[...new Set(f?u.chains.concat(r||[]):r)],methods:[...new Set(u.methods.concat(null!=i&&i.length?i:Qi))],events:[...new Set(u.events.concat(null!=a&&a.length?a:$i))],rpcMap:c};return{required:e.length?u:void 0,optional:r.length?p:void 0}}(this.rpc);try{const n=await new Promise((async(n,i)=>{var s;this.rpc.showQrModal&&(null==(s=this.modal)||s.subscribeModal((t=>{!t.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),i(new Error("Connection request reset. Please try again.")))}))),await this.signer.connect(as(os({namespaces:os({},e&&{[this.namespace]:e})},r&&{optionalNamespaces:{[this.namespace]:r}}),{pairingTopic:null===t||void 0===t?void 0:t.pairingTopic})).then((t=>{n(t)})).catch((t=>{i(new Error(t.message))}))}));if(!n)return;const i=(0,s.gu)(n.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:i),this.setAccounts(i),this.events.emit("connect",{chainId:us(this.chainId)})}catch(h){throw this.signer.logger.error(h),h}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:e}=t,{event:r}=e;"accountsChanged"===r.name?(this.accounts=this.parseAccounts(r.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===r.name?this.setChainId(this.formatChainId(r.data)):this.events.emit(r.name,r.data),this.events.emit("session_event",t)})),this.signer.on("chainChanged",(t=>{const e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",us(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",as(os({},(0,s.D6)("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))})),this.signer.on("display_uri",(t=>{var e,r;this.rpc.showQrModal&&(null==(e=this.modal)||e.closeModal(),null==(r=this.modal)||r.openModal({uri:t})),this.events.emit("display_uri",t)}))}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return"string"==typeof t&&t.startsWith("".concat(this.namespace,":"))}formatChainId(t){return"".concat(this.namespace,":").concat(t)}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const e=t.filter((t=>this.isCompatibleChainId(t))).map((t=>this.parseChainId(t)));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",us(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,r,n]=t.split(":");return{chainId:"".concat(e,":").concat(r),address:n}}setAccounts(t){this.accounts=t.filter((t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId)).map((t=>this.parseAccountId(t).address)),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,r;const n=null!=(e=null===t||void 0===t?void 0:t.chains)?e:[],i=null!=(r=null===t||void 0===t?void 0:t.optionalChains)?r:[],s=n.concat(i);if(!s.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const o=n.length?(null===t||void 0===t?void 0:t.methods)||Ji:[],a=n.length?(null===t||void 0===t?void 0:t.events)||Yi:[],c=(null===t||void 0===t?void 0:t.optionalMethods)||[],u=(null===t||void 0===t?void 0:t.optionalEvents)||[],h=(null===t||void 0===t?void 0:t.rpcMap)||this.buildRpcMap(s,t.projectId),l=(null===t||void 0===t?void 0:t.qrModalOptions)||void 0;return{chains:null===n||void 0===n?void 0:n.map((t=>this.formatChainId(t))),optionalChains:i.map((t=>this.formatChainId(t))),methods:o,events:a,optionalMethods:c,optionalEvents:u,rpcMap:h,showQrModal:!(null==t||!t.showQrModal),qrModalOptions:l,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const r={};return t.forEach((t=>{r[t]=this.getRpcUrl(t,e)})),r}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?cs(this.rpc.chains):cs(this.rpc.optionalChains),this.signer=await Zi.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 t;try{const{WalletConnectModal:e}=await r.e(199).then(r.bind(r,41199));t=e}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(t)try{this.modal=new t(os({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(e){throw this.signer.logger.error(e),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:e,optionalChains:r,rpcMap:n}=t;e&&(0,s.qt)(e)&&(this.rpc.chains=e.map((t=>this.formatChainId(t))),e.forEach((t=>{this.rpc.rpcMap[t]=(null===n||void 0===n?void 0:n[t])||this.getRpcUrl(t)}))),r&&(0,s.qt)(r)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=null===r||void 0===r?void 0:r.map((t=>this.formatChainId(t))),r.forEach((t=>{this.rpc.rpcMap[t]=(null===n||void 0===n?void 0:n[t])||this.getRpcUrl(t)})))}getRpcUrl(t,e){var r;return(null==(r=this.rpc.rpcMap)?void 0:r[t])||"".concat("https://rpc.walletconnect.com/v1/","?chainId=eip155:").concat(t,"&projectId=").concat(e||this.rpc.projectId)}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem("".concat(this.STORAGE_KEY,"/chainId")),e=this.session.namespaces["".concat(this.namespace,":").concat(t)]?this.session.namespaces["".concat(this.namespace,":").concat(t)]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:null===e||void 0===e?void 0:e.accounts),this.setAccounts(null===e||void 0===e?void 0:e.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem("".concat(this.STORAGE_KEY,"/chainId"),this.chainId)}parseAccounts(t){return"string"==typeof t||t instanceof String?[this.parseAccount(t)]:t.map((t=>this.parseAccount(t)))}}const ls=hs},23375:(t,e,r)=>{"use strict";r.d(e,{q:()=>n});class n{}},66727:(t,e,r)=>{"use strict";r.r(e),r.d(e,{IEvents:()=>n.q});var n=r(23375)},3918:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HEARTBEAT_EVENTS=e.HEARTBEAT_INTERVAL=void 0;const n=r(93659);e.HEARTBEAT_INTERVAL=n.FIVE_SECONDS,e.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"}},17122:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});r(58182).__exportStar(r(3918),e)},80588:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.HeartBeat=void 0;const n=r(58182),i=r(68041),s=r(93659),o=r(45326),a=r(17122);class c extends o.IHeartBeat{constructor(t){super(t),this.events=new i.EventEmitter,this.interval=a.HEARTBEAT_INTERVAL,this.interval=(null===t||void 0===t?void 0:t.interval)||a.HEARTBEAT_INTERVAL}static init(t){return n.__awaiter(this,void 0,void 0,(function*(){const e=new c(t);return yield e.init(),e}))}init(){return n.__awaiter(this,void 0,void 0,(function*(){yield this.initialize()}))}stop(){clearInterval(this.intervalRef)}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}off(t,e){this.events.off(t,e)}removeListener(t,e){this.events.removeListener(t,e)}initialize(){return n.__awaiter(this,void 0,void 0,(function*(){this.intervalRef=setInterval((()=>this.pulse()),s.toMiliseconds(this.interval))}))}pulse(){this.events.emit(a.HEARTBEAT_EVENTS.pulse)}}e.HeartBeat=c},1345:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(58182);n.__exportStar(r(80588),e),n.__exportStar(r(45326),e),n.__exportStar(r(17122),e)},61398:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IHeartBeat=void 0;const n=r(66727);class i extends n.IEvents{constructor(t){super()}}e.IHeartBeat=i},45326:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});r(58182).__exportStar(r(61398),e)},58182:(t,e,r)=>{"use strict";r.r(e),r.d(e,{__assign:()=>s,__asyncDelegator:()=>_,__asyncGenerator:()=>w,__asyncValues:()=>b,__await:()=>m,__awaiter:()=>h,__classPrivateFieldGet:()=>S,__classPrivateFieldSet:()=>O,__createBinding:()=>f,__decorate:()=>a,__exportStar:()=>p,__extends:()=>i,__generator:()=>l,__importDefault:()=>P,__importStar:()=>I,__makeTemplateObject:()=>E,__metadata:()=>u,__param:()=>c,__read:()=>g,__rest:()=>o,__spread:()=>v,__spreadArrays:()=>y,__values:()=>d});var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},n(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var s=function(){return s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r=0;a--)(i=t[a])&&(o=(s<3?i(o):s>3?i(e,r,o):i(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o}function c(t,e){return function(r,n){e(r,n,t)}}function u(t,e){if("object"===typeof Reflect&&"function"===typeof Reflect.metadata)return Reflect.metadata(t,e)}function h(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(e){s(e)}}function a(t){try{c(n.throw(t))}catch(e){s(e)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))}function l(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"===typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var r="function"===typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function v(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(r=i[t](e)).value instanceof m?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(n){h(s[0][3],n)}var r}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function _(t){var e,r;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,i){e[n]=t[n]?function(e){return(r=!r)?{value:m(t[n](e)),done:"return"===n}:i?i(e):e}:i}}function b(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=d(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,i){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,i,(e=t[r](e)).done,e.value)}))}}}function E(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function I(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function P(t){return t&&t.__esModule?t:{default:t}}function S(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function O(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}},96578:t=>{"use strict";t.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},60074:(t,e,r)=>{"use strict";const n=r(21888),i=r(84217),s=n.__importDefault(r(82703)),o=r(72038);class a{constructor(){this.localStorage=s.default}getKeys(){return n.__awaiter(this,void 0,void 0,(function*(){return Object.keys(this.localStorage)}))}getEntries(){return n.__awaiter(this,void 0,void 0,(function*(){return Object.entries(this.localStorage).map(o.parseEntry)}))}getItem(t){return n.__awaiter(this,void 0,void 0,(function*(){const e=this.localStorage.getItem(t);if(null!==e)return i.safeJsonParse(e)}))}setItem(t,e){return n.__awaiter(this,void 0,void 0,(function*(){this.localStorage.setItem(t,i.safeJsonStringify(e))}))}removeItem(t){return n.__awaiter(this,void 0,void 0,(function*(){this.localStorage.removeItem(t)}))}}e.ZP=a},82703:(t,e,r)=>{"use strict";!function(){let e;function n(){}e=n,e.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},e.prototype.setItem=function(t,e){this[t]=String(e)},e.prototype.removeItem=function(t){delete this[t]},e.prototype.clear=function(){const t=this;Object.keys(t).forEach((function(e){t[e]=void 0,delete t[e]}))},e.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},e.prototype.__defineGetter__("length",(function(){return Object.keys(this).length})),"undefined"!==typeof r.g&&r.g.localStorage?t.exports=r.g.localStorage:"undefined"!==typeof window&&window.localStorage?t.exports=window.localStorage:t.exports=new n}()},72038:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});const n=r(21888);n.__exportStar(r(28383),e),n.__exportStar(r(99483),e)},28383:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.IKeyValueStorage=void 0;e.IKeyValueStorage=class{}},99483:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseEntry=void 0;const n=r(84217);e.parseEntry=function(t){var e;return[t[0],n.safeJsonParse(null!==(e=t[1])&&void 0!==e?e:"")]}},21888:(t,e,r)=>{"use strict";r.r(e),r.d(e,{__assign:()=>s,__asyncDelegator:()=>_,__asyncGenerator:()=>w,__asyncValues:()=>b,__await:()=>m,__awaiter:()=>h,__classPrivateFieldGet:()=>S,__classPrivateFieldSet:()=>O,__createBinding:()=>f,__decorate:()=>a,__exportStar:()=>p,__extends:()=>i,__generator:()=>l,__importDefault:()=>P,__importStar:()=>I,__makeTemplateObject:()=>E,__metadata:()=>u,__param:()=>c,__read:()=>g,__rest:()=>o,__spread:()=>v,__spreadArrays:()=>y,__values:()=>d});var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},n(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var s=function(){return s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r=0;a--)(i=t[a])&&(o=(s<3?i(o):s>3?i(e,r,o):i(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o}function c(t,e){return function(r,n){e(r,n,t)}}function u(t,e){if("object"===typeof Reflect&&"function"===typeof Reflect.metadata)return Reflect.metadata(t,e)}function h(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(e){s(e)}}function a(t){try{c(n.throw(t))}catch(e){s(e)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))}function l(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"===typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var r="function"===typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function v(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(r=i[t](e)).value instanceof m?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(n){h(s[0][3],n)}var r}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function _(t){var e,r;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,i){e[n]=t[n]?function(e){return(r=!r)?{value:m(t[n](e)),done:"return"===n}:i?i(e):e}:i}}function b(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=d(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,i){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,i,(e=t[r](e)).done,e.value)}))}}}function E(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function I(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function P(t){return t&&t.__esModule?t:{default:t}}function S(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function O(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}},82923:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PINO_CUSTOM_CONTEXT_KEY=e.PINO_LOGGER_DEFAULTS=void 0,e.PINO_LOGGER_DEFAULTS={level:"info"},e.PINO_CUSTOM_CONTEXT_KEY="custom_context"},91451:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.pino=void 0;const n=r(36254),i=n.__importDefault(r(24));Object.defineProperty(e,"pino",{enumerable:!0,get:function(){return i.default}}),n.__exportStar(r(82923),e),n.__exportStar(r(41067),e)},41067:(t,e,r)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generateChildLogger=e.formatChildLoggerContext=e.getLoggerContext=e.setBrowserLoggerContext=e.getBrowserLoggerContext=e.getDefaultLoggerOptions=void 0;const n=r(82923);function i(t){return t[arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.PINO_CUSTOM_CONTEXT_KEY]||""}function s(t,e){return t[arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.PINO_CUSTOM_CONTEXT_KEY]=e,t}function o(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:n.PINO_CUSTOM_CONTEXT_KEY,r="";return r="undefined"===typeof t.bindings?i(t,e):t.bindings().context||"",r}function a(t,e){const r=o(t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.PINO_CUSTOM_CONTEXT_KEY);return r.trim()?"".concat(r,"/").concat(e):e}e.getDefaultLoggerOptions=function(t){return Object.assign(Object.assign({},t),{level:(null===t||void 0===t?void 0:t.level)||n.PINO_LOGGER_DEFAULTS.level})},e.getBrowserLoggerContext=i,e.setBrowserLoggerContext=s,e.getLoggerContext=o,e.formatChildLoggerContext=a,e.generateChildLogger=function(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n.PINO_CUSTOM_CONTEXT_KEY;const i=a(t,e,r);return s(t.child({context:i}),i,r)}},36254:(t,e,r)=>{"use strict";r.r(e),r.d(e,{__assign:()=>s,__asyncDelegator:()=>_,__asyncGenerator:()=>w,__asyncValues:()=>b,__await:()=>m,__awaiter:()=>h,__classPrivateFieldGet:()=>S,__classPrivateFieldSet:()=>O,__createBinding:()=>f,__decorate:()=>a,__exportStar:()=>p,__extends:()=>i,__generator:()=>l,__importDefault:()=>P,__importStar:()=>I,__makeTemplateObject:()=>E,__metadata:()=>u,__param:()=>c,__read:()=>g,__rest:()=>o,__spread:()=>v,__spreadArrays:()=>y,__values:()=>d});var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},n(t,e)};function i(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var s=function(){return s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r=0;a--)(i=t[a])&&(o=(s<3?i(o):s>3?i(e,r,o):i(e,r))||o);return s>3&&o&&Object.defineProperty(e,r,o),o}function c(t,e){return function(r,n){e(r,n,t)}}function u(t,e){if("object"===typeof Reflect&&"function"===typeof Reflect.metadata)return Reflect.metadata(t,e)}function h(t,e,r,n){return new(r||(r=Promise))((function(i,s){function o(t){try{c(n.next(t))}catch(e){s(e)}}function a(t){try{c(n.throw(t))}catch(e){s(e)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,a)}c((n=n.apply(t,e||[])).next())}))}function l(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"===typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===s[0]||2===s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var r="function"===typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,s=r.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(a){i={error:a}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(i)throw i.error}}return o}function v(){for(var t=[],e=0;e1||a(t,e)}))})}function a(t,e){try{(r=i[t](e)).value instanceof m?Promise.resolve(r.value.v).then(c,u):h(s[0][2],r)}catch(n){h(s[0][3],n)}var r}function c(t){a("next",t)}function u(t){a("throw",t)}function h(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}function _(t){var e,r;return e={},n("next"),n("throw",(function(t){throw t})),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,i){e[n]=t[n]?function(e){return(r=!r)?{value:m(t[n](e)),done:"return"===n}:i?i(e):e}:i}}function b(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=d(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise((function(n,i){(function(t,e,r,n){Promise.resolve(n).then((function(e){t({value:e,done:r})}),e)})(n,i,(e=t[r](e)).done,e.value)}))}}}function E(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function I(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function P(t){return t&&t.__esModule?t:{default:t}}function S(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function O(t,e,r){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,r),r}},16395:()=>{},7605:function(t,e){var r="undefined"!==typeof self?self:this,n=function(){function t(){this.fetch=!1,this.DOMException=r.DOMException}return t.prototype=r,new t}();!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),s="FormData"in t,o="ArrayBuffer"in t;if(o)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function u(t){if("string"!==typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!==typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function p(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function d(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function g(t){var e=new FileReader,r=d(e);return e.readAsArrayBuffer(t),r}function v(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"===typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(t)||c(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"===typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=p(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var t=p(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,r=d(e);return e.readAsText(t),r}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(r)}function _(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function b(t){var e=new f;return t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e}function E(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},y.call(w.prototype),y.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:0,statusText:""});return t.type="error",t};var I=[301,302,303,307,308];E.redirect=function(t,e){if(-1===I.indexOf(e))throw new RangeError("Invalid status code");return new E(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(S){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function P(t,r){return new Promise((function(n,s){var o=new w(t,r);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var t={status:a.status,statusText:a.statusText,headers:b(a.getAllResponseHeaders()||"")};t.url="responseURL"in a?a.responseURL:t.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;n(new E(e,t))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(new e.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),o.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),o.signal&&(o.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",c)}),a.send("undefined"===typeof o._bodyInit?null:o._bodyInit)}))}P.polyfill=!0,t.fetch||(t.fetch=P,t.Headers=f,t.Request=w,t.Response=E),e.Headers=f,e.Request=w,e.Response=E,e.fetch=P,Object.defineProperty(e,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;(e=i.fetch).default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e},23108:(t,e,r)=>{t=r.nmd(t);var n="__lodash_hash_undefined__",i=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",u="[object AsyncFunction]",h="[object Boolean]",l="[object Date]",f="[object Error]",p="[object Function]",d="[object GeneratorFunction]",g="[object Map]",v="[object Number]",y="[object Null]",m="[object Object]",w="[object Promise]",_="[object Proxy]",b="[object RegExp]",E="[object Set]",I="[object String]",P="[object Symbol]",S="[object Undefined]",O="[object WeakMap]",x="[object ArrayBuffer]",R="[object DataView]",C=/^\[object .+?Constructor\]$/,A=/^(?:0|[1-9]\d*)$/,j={};j["[object Float32Array]"]=j["[object Float64Array]"]=j["[object Int8Array]"]=j["[object Int16Array]"]=j["[object Int32Array]"]=j["[object Uint8Array]"]=j["[object Uint8ClampedArray]"]=j["[object Uint16Array]"]=j["[object Uint32Array]"]=!0,j[a]=j[c]=j[x]=j[h]=j[R]=j[l]=j[f]=j[p]=j[g]=j[v]=j[m]=j[b]=j[E]=j[I]=j[O]=!1;var T="object"==typeof r.g&&r.g&&r.g.Object===Object&&r.g,N="object"==typeof self&&self&&self.Object===Object&&self,q=T||N||Function("return this")(),D=e&&!e.nodeType&&e,L=D&&t&&!t.nodeType&&t,M=L&&L.exports===D,z=M&&T.process,k=function(){try{return z&&z.binding&&z.binding("util")}catch(t){}}(),U=k&&k.isTypedArray;function H(t,e){for(var r=-1,n=null==t?0:t.length;++ru))return!1;var l=a.get(t);if(l&&a.get(e))return l==e;var f=-1,p=!0,d=r&s?new Ot:void 0;for(a.set(t,e),a.set(e,t);++f-1},Pt.prototype.set=function(t,e){var r=this.__data__,n=Ct(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this},St.prototype.clear=function(){this.size=0,this.__data__={hash:new It,map:new(lt||Pt),string:new It}},St.prototype.delete=function(t){var e=Mt(this,t).delete(t);return this.size-=e?1:0,e},St.prototype.get=function(t){return Mt(this,t).get(t)},St.prototype.has=function(t){return Mt(this,t).has(t)},St.prototype.set=function(t,e){var r=Mt(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Ot.prototype.add=Ot.prototype.push=function(t){return this.__data__.set(t,n),this},Ot.prototype.has=function(t){return this.__data__.has(t)},xt.prototype.clear=function(){this.__data__=new Pt,this.size=0},xt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},xt.prototype.get=function(t){return this.__data__.get(t)},xt.prototype.has=function(t){return this.__data__.has(t)},xt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Pt){var n=r.__data__;if(!lt||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new St(n)}return r.set(t,e),this.size=r.size,this};var kt=at?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var r=-1,n=null==t?0:t.length,i=0,s=[];++r-1&&t%1==0&&t-1&&t%1==0&&t<=o}function Jt(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function Qt(t){return null!=t&&"object"==typeof t}var Yt=U?function(t){return function(e){return t(e)}}(U):function(t){return Qt(t)&&Wt(t.length)&&!!j[At(t)]};function $t(t){return null!=(e=t)&&Wt(e.length)&&!Zt(e)?Rt(t):qt(t);var e}t.exports=function(t,e){return Tt(t,e)}},24791:t=>{"use strict";function e(t){try{return JSON.stringify(t)}catch(e){return'"[Circular]"'}}t.exports=function(t,r,n){var i=n&&n.stringify||e;if("object"===typeof t&&null!==t){var s=r.length+1;if(1===s)return t;var o=new Array(s);o[0]=i(t);for(var a=1;a-1?l:0,t.charCodeAt(p+1)){case 100:case 102:if(h>=c)break;if(null==r[h])break;l=c)break;if(null==r[h])break;l=c)break;if(void 0===r[h])break;l",l=p+2,p++;break}u+=i(r[h]),l=p+2,p++;break;case 115:if(h>=c)break;l{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.safeJsonParse=function(t){if("string"!==typeof t)throw new Error("Cannot safe json parse value of type ".concat(typeof t));try{return JSON.parse(t)}catch(e){return t}},e.safeJsonStringify=function(t){return"string"===typeof t?t:JSON.stringify(t,((t,e)=>"undefined"===typeof e?null:e))}},24:(t,e,r)=>{"use strict";const n=r(24791);t.exports=o;const i=function(){function t(t){return"undefined"!==typeof t&&t}try{return"undefined"!==typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(e){return t(self)||t(window)||t(this)||{}}}().console||{},s={mapHttpRequest:f,mapHttpResponse:f,wrapRequestSerializer:p,wrapResponseSerializer:p,wrapErrorSerializer:p,req:f,res:f,err:function(t){const e={type:t.constructor.name,msg:t.message,stack:t.stack};for(const r in t)void 0===e[r]&&(e[r]=t[r]);return e}};function o(t){(t=t||{}).browser=t.browser||{};const e=t.browser.transmit;if(e&&"function"!==typeof e.send)throw Error("pino: transmit option must have a send function");const r=t.browser.write||i;t.browser.write&&(t.browser.asObject=!0);const n=t.serializers||{},s=function(t,e){if(Array.isArray(t))return t.filter((function(t){return"!stdSerializers.err"!==t}));return!0===t&&Object.keys(e)}(t.browser.serialize,n);let f=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(f=!1);"function"===typeof r&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),!1===t.enabled&&(t.level="silent");const p=t.level||"info",g=Object.create(r);g.log||(g.log=d),Object.defineProperty(g,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(g,"level",{get:function(){return this._level},set:function(t){if("silent"!==t&&!this.levels.values[t])throw Error("unknown level "+t);this._level=t,a(v,g,"error","log"),a(v,g,"fatal","error"),a(v,g,"warn","error"),a(v,g,"info","log"),a(v,g,"debug","log"),a(v,g,"trace","log")}});const v={transmit:e,serialize:s,asObject:t.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:l(t)};return g.levels=o.levels,g.level=p,g.setMaxListeners=g.getMaxListeners=g.emit=g.addListener=g.on=g.prependListener=g.once=g.prependOnceListener=g.removeListener=g.removeAllListeners=g.listeners=g.listenerCount=g.eventNames=g.write=g.flush=d,g.serializers=n,g._serialize=s,g._stdErrSerialize=f,g.child=function(r,i){if(!r)throw new Error("missing bindings for child Pino");i=i||{},s&&r.serializers&&(i.serializers=r.serializers);const o=i.serializers;if(s&&o){var a=Object.assign({},n,o),l=!0===t.browser.serialize?Object.keys(a):s;delete r.serializers,c([r],l,a,this._stdErrSerialize)}function f(t){this._childLevel=1+(0|t._childLevel),this.error=u(t,r,"error"),this.fatal=u(t,r,"fatal"),this.warn=u(t,r,"warn"),this.info=u(t,r,"info"),this.debug=u(t,r,"debug"),this.trace=u(t,r,"trace"),a&&(this.serializers=a,this._serialize=l),e&&(this._logEvent=h([].concat(t._logEvent.bindings,r)))}return f.prototype=this,new f(this)},e&&(g._logEvent=h()),g}function a(t,e,r,s){const a=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?d:a[r]?a[r]:i[r]||i[s]||d,function(t,e,r){if(!t.transmit&&e[r]===d)return;e[r]=(s=e[r],function(){const a=t.timestamp(),u=new Array(arguments.length),l=Object.getPrototypeOf&&Object.getPrototypeOf(this)===i?i:this;for(var f=0;f-1&&n in r&&(t[i][n]=r[n](t[i][n]))}function u(t,e,r){return function(){const n=new Array(1+arguments.length);n[0]=e;for(var i=1;i